From 784f694d0f3ca927361aa0c26de1aa340eb5b275 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:39 +0200 Subject: wl12xx: replace wl->mac_addr with vif->addr The mac address of the interface already exists in vif->addr. Use it instead of wl->mac_addr. It seems that due to some fw bug, we still need to set nvs->mac to the actual mac addresss, otherwise the fw doesn't function well (e.g. can't get dhcp address). Thus, use wl->mac_addr for this purpose, and don't delete it yet. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 9 +++++---- drivers/net/wireless/wl12xx/cmd.h | 5 +++-- drivers/net/wireless/wl12xx/event.c | 2 +- drivers/net/wireless/wl12xx/init.c | 29 ++++++++++++++++------------- drivers/net/wireless/wl12xx/init.h | 4 ++-- drivers/net/wireless/wl12xx/main.c | 19 +++++++++++++------ drivers/net/wireless/wl12xx/scan.c | 32 ++++++++++++++++++-------------- drivers/net/wireless/wl12xx/scan.h | 5 +++-- drivers/net/wireless/wl12xx/wl12xx.h | 1 + 9 files changed, 62 insertions(+), 44 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index a52299e548fa..bee44c7d67fd 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -358,7 +358,8 @@ static int wl1271_cmd_wait_for_event(struct wl1271 *wl, u32 mask) return 0; } -int wl12xx_cmd_role_enable(struct wl1271 *wl, u8 role_type, u8 *role_id) +int wl12xx_cmd_role_enable(struct wl1271 *wl, u8 *addr, u8 role_type, + u8 *role_id) { struct wl12xx_cmd_role_enable *cmd; int ret; @@ -381,7 +382,7 @@ int wl12xx_cmd_role_enable(struct wl1271 *wl, u8 role_type, u8 *role_id) goto out_free; } - memcpy(cmd->mac_address, wl->mac_addr, ETH_ALEN); + memcpy(cmd->mac_address, addr, ETH_ALEN); cmd->role_type = role_type; ret = wl1271_cmd_send(wl, CMD_ROLE_ENABLE, cmd, sizeof(*cmd), 0); @@ -1200,14 +1201,14 @@ int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, __be32 ip_addr) return ret; } -int wl1271_build_qos_null_data(struct wl1271 *wl) +int wl1271_build_qos_null_data(struct wl1271 *wl, struct ieee80211_vif *vif) { struct ieee80211_qos_hdr template; memset(&template, 0, sizeof(template)); memcpy(template.addr1, wl->bssid, ETH_ALEN); - memcpy(template.addr2, wl->mac_addr, ETH_ALEN); + memcpy(template.addr2, vif->addr, ETH_ALEN); memcpy(template.addr3, wl->bssid, ETH_ALEN); template.frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index b7bd42769aa7..1ae949f00c14 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -36,7 +36,8 @@ int wl128x_cmd_general_parms(struct wl1271 *wl); int wl1271_cmd_radio_parms(struct wl1271 *wl); int wl128x_cmd_radio_parms(struct wl1271 *wl); int wl1271_cmd_ext_radio_parms(struct wl1271 *wl); -int wl12xx_cmd_role_enable(struct wl1271 *wl, u8 role_type, u8 *role_id); +int wl12xx_cmd_role_enable(struct wl1271 *wl, u8 *addr, u8 role_type, + u8 *role_id); int wl12xx_cmd_role_disable(struct wl1271 *wl, u8 *role_id); int wl12xx_cmd_role_start_dev(struct wl1271 *wl); int wl12xx_cmd_role_stop_dev(struct wl1271 *wl); @@ -62,7 +63,7 @@ int wl1271_cmd_build_probe_req(struct wl1271 *wl, struct sk_buff *wl1271_cmd_build_ap_probe_req(struct wl1271 *wl, struct sk_buff *skb); int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, __be32 ip_addr); -int wl1271_build_qos_null_data(struct wl1271 *wl); +int wl1271_build_qos_null_data(struct wl1271 *wl, struct ieee80211_vif *vif); int wl1271_cmd_build_klv_null_data(struct wl1271 *wl); int wl12xx_cmd_set_default_wep_key(struct wl1271 *wl, u8 id, u8 hlid); int wl1271_cmd_set_sta_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index 674ad2a9e409..7e3ff808feef 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -234,7 +234,7 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) wl1271_debug(DEBUG_EVENT, "status: 0x%x", mbox->scheduled_scan_status); - wl1271_scan_stm(wl); + wl1271_scan_stm(wl, wl->scan_vif); } if (vector & PERIODIC_SCAN_REPORT_EVENT_ID) { diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index 04db64c94e9a..4692a91ca737 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -123,7 +123,8 @@ out: return ret; } -static int wl1271_ap_init_null_template(struct wl1271 *wl) +static int wl1271_ap_init_null_template(struct wl1271 *wl, + struct ieee80211_vif *vif) { struct ieee80211_hdr_3addr *nullfunc; int ret; @@ -141,8 +142,8 @@ static int wl1271_ap_init_null_template(struct wl1271 *wl) /* nullfunc->addr1 is filled by FW */ - memcpy(nullfunc->addr2, wl->mac_addr, ETH_ALEN); - memcpy(nullfunc->addr3, wl->mac_addr, ETH_ALEN); + memcpy(nullfunc->addr2, vif->addr, ETH_ALEN); + memcpy(nullfunc->addr3, vif->addr, ETH_ALEN); rate = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, nullfunc, @@ -153,7 +154,8 @@ out: return ret; } -static int wl1271_ap_init_qos_null_template(struct wl1271 *wl) +static int wl1271_ap_init_qos_null_template(struct wl1271 *wl, + struct ieee80211_vif *vif) { struct ieee80211_qos_hdr *qosnull; int ret; @@ -171,8 +173,8 @@ static int wl1271_ap_init_qos_null_template(struct wl1271 *wl) /* qosnull->addr1 is filled by FW */ - memcpy(qosnull->addr2, wl->mac_addr, ETH_ALEN); - memcpy(qosnull->addr3, wl->mac_addr, ETH_ALEN); + memcpy(qosnull->addr2, vif->addr, ETH_ALEN); + memcpy(qosnull->addr3, vif->addr, ETH_ALEN); rate = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, qosnull, @@ -449,7 +451,7 @@ static int wl1271_ap_hw_init(struct wl1271 *wl) return 0; } -int wl1271_ap_init_templates(struct wl1271 *wl) +int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif) { int ret; @@ -457,11 +459,11 @@ int wl1271_ap_init_templates(struct wl1271 *wl) if (ret < 0) return ret; - ret = wl1271_ap_init_null_template(wl); + ret = wl1271_ap_init_null_template(wl, vif); if (ret < 0) return ret; - ret = wl1271_ap_init_qos_null_template(wl); + ret = wl1271_ap_init_qos_null_template(wl, vif); if (ret < 0) return ret; @@ -476,9 +478,10 @@ int wl1271_ap_init_templates(struct wl1271 *wl) return 0; } -static int wl1271_ap_hw_init_post_mem(struct wl1271 *wl) +static int wl1271_ap_hw_init_post_mem(struct wl1271 *wl, + struct ieee80211_vif *vif) { - return wl1271_ap_init_templates(wl); + return wl1271_ap_init_templates(wl, vif); } int wl1271_init_ap_rates(struct wl1271 *wl) @@ -576,7 +579,7 @@ out: } -int wl1271_hw_init(struct wl1271 *wl) +int wl1271_hw_init(struct wl1271 *wl, struct ieee80211_vif *vif) { struct conf_tx_ac_category *conf_ac; struct conf_tx_tid *conf_tid; @@ -694,7 +697,7 @@ int wl1271_hw_init(struct wl1271 *wl) /* Mode specific init - post mem init */ if (is_ap) - ret = wl1271_ap_hw_init_post_mem(wl); + ret = wl1271_ap_hw_init_post_mem(wl, vif); else ret = wl1271_sta_hw_init_post_mem(wl); diff --git a/drivers/net/wireless/wl12xx/init.h b/drivers/net/wireless/wl12xx/init.h index 3a3c230fd292..b1f97bcc47c0 100644 --- a/drivers/net/wireless/wl12xx/init.h +++ b/drivers/net/wireless/wl12xx/init.h @@ -32,8 +32,8 @@ int wl1271_init_phy_config(struct wl1271 *wl); int wl1271_init_pta(struct wl1271 *wl); int wl1271_init_energy_detection(struct wl1271 *wl); int wl1271_chip_specific_init(struct wl1271 *wl); -int wl1271_hw_init(struct wl1271 *wl); +int wl1271_hw_init(struct wl1271 *wl, struct ieee80211_vif *vif); int wl1271_init_ap_rates(struct wl1271 *wl); -int wl1271_ap_init_templates(struct wl1271 *wl); +int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif); #endif diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 884f82b63219..652471e8c61b 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1896,6 +1896,10 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, ret = -EINVAL; goto out; } + /* + * we still need this in order to configure the fw + * while uploading the nvs + */ memcpy(wl->mac_addr, vif->addr, ETH_ALEN); if (wl->state != WL1271_STATE_OFF) { @@ -1923,18 +1927,19 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, * the STA role can get packets only from * its associated bssid) */ - ret = wl12xx_cmd_role_enable(wl, + ret = wl12xx_cmd_role_enable(wl, vif->addr, WL1271_ROLE_DEVICE, &wl->dev_role_id); if (ret < 0) goto irq_disable; } - ret = wl12xx_cmd_role_enable(wl, role_type, &wl->role_id); + ret = wl12xx_cmd_role_enable(wl, vif->addr, + role_type, &wl->role_id); if (ret < 0) goto irq_disable; - ret = wl1271_hw_init(wl); + ret = wl1271_hw_init(wl, vif); if (ret < 0) goto irq_disable; @@ -2019,6 +2024,7 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, if (wl->scan.state != WL1271_SCAN_STATE_IDLE) { wl->scan.state = WL1271_SCAN_STATE_IDLE; memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch)); + wl->scan_vif = NULL; wl->scan.req = NULL; ieee80211_scan_completed(wl->hw, true); } @@ -2885,7 +2891,7 @@ static int wl1271_op_hw_scan(struct ieee80211_hw *hw, wl12xx_cmd_role_stop_dev(wl); } - ret = wl1271_scan(hw->priv, ssid, len, req); + ret = wl1271_scan(hw->priv, vif, ssid, len, req); out_sleep: wl1271_ps_elp_sleep(wl); out: @@ -2921,6 +2927,7 @@ static void wl1271_op_cancel_hw_scan(struct ieee80211_hw *hw, } wl->scan.state = WL1271_SCAN_STATE_IDLE; memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch)); + wl->scan_vif = NULL; wl->scan.req = NULL; ieee80211_scan_completed(wl->hw, true); @@ -3295,7 +3302,7 @@ static void wl1271_bss_info_changed_ap(struct wl1271 *wl, goto out; } - ret = wl1271_ap_init_templates(wl); + ret = wl1271_ap_init_templates(wl, vif); if (ret < 0) goto out; } @@ -3428,7 +3435,7 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, if (ret < 0) goto out; - ret = wl1271_build_qos_null_data(wl); + ret = wl1271_build_qos_null_data(wl, vif); if (ret < 0) goto out; diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index 128ccb79318c..a8576181ab7f 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -53,6 +53,7 @@ void wl1271_scan_complete_work(struct work_struct *work) wl->scan.state = WL1271_SCAN_STATE_IDLE; memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch)); wl->scan.req = NULL; + wl->scan_vif = NULL; ret = wl1271_ps_elp_wakeup(wl); if (ret < 0) @@ -155,8 +156,9 @@ static int wl1271_get_scan_channels(struct wl1271 *wl, #define WL1271_NOTHING_TO_SCAN 1 -static int wl1271_scan_send(struct wl1271 *wl, enum ieee80211_band band, - bool passive, u32 basic_rate) +static int wl1271_scan_send(struct wl1271 *wl, struct ieee80211_vif *vif, + enum ieee80211_band band, + bool passive, u32 basic_rate) { struct wl1271_cmd_scan *cmd; struct wl1271_cmd_trigger_scan_to *trigger; @@ -208,7 +210,7 @@ static int wl1271_scan_send(struct wl1271 *wl, enum ieee80211_band band, memcpy(cmd->params.ssid, wl->scan.ssid, wl->scan.ssid_len); } - memcpy(cmd->addr, wl->mac_addr, ETH_ALEN); + memcpy(cmd->addr, vif->addr, ETH_ALEN); ret = wl1271_cmd_build_probe_req(wl, wl->scan.ssid, wl->scan.ssid_len, wl->scan.req->ie, wl->scan.req->ie_len, @@ -241,7 +243,7 @@ out: return ret; } -void wl1271_scan_stm(struct wl1271 *wl) +void wl1271_scan_stm(struct wl1271 *wl, struct ieee80211_vif *vif) { int ret = 0; enum ieee80211_band band; @@ -254,10 +256,10 @@ void wl1271_scan_stm(struct wl1271 *wl) case WL1271_SCAN_STATE_2GHZ_ACTIVE: band = IEEE80211_BAND_2GHZ; rate = wl1271_tx_min_rate_get(wl, wl->bitrate_masks[band]); - ret = wl1271_scan_send(wl, band, false, rate); + ret = wl1271_scan_send(wl, vif, band, false, rate); if (ret == WL1271_NOTHING_TO_SCAN) { wl->scan.state = WL1271_SCAN_STATE_2GHZ_PASSIVE; - wl1271_scan_stm(wl); + wl1271_scan_stm(wl, vif); } break; @@ -265,13 +267,13 @@ void wl1271_scan_stm(struct wl1271 *wl) case WL1271_SCAN_STATE_2GHZ_PASSIVE: band = IEEE80211_BAND_2GHZ; rate = wl1271_tx_min_rate_get(wl, wl->bitrate_masks[band]); - ret = wl1271_scan_send(wl, band, true, rate); + ret = wl1271_scan_send(wl, vif, band, true, rate); if (ret == WL1271_NOTHING_TO_SCAN) { if (wl->enable_11a) wl->scan.state = WL1271_SCAN_STATE_5GHZ_ACTIVE; else wl->scan.state = WL1271_SCAN_STATE_DONE; - wl1271_scan_stm(wl); + wl1271_scan_stm(wl, vif); } break; @@ -279,10 +281,10 @@ void wl1271_scan_stm(struct wl1271 *wl) case WL1271_SCAN_STATE_5GHZ_ACTIVE: band = IEEE80211_BAND_5GHZ; rate = wl1271_tx_min_rate_get(wl, wl->bitrate_masks[band]); - ret = wl1271_scan_send(wl, band, false, rate); + ret = wl1271_scan_send(wl, vif, band, false, rate); if (ret == WL1271_NOTHING_TO_SCAN) { wl->scan.state = WL1271_SCAN_STATE_5GHZ_PASSIVE; - wl1271_scan_stm(wl); + wl1271_scan_stm(wl, vif); } break; @@ -290,10 +292,10 @@ void wl1271_scan_stm(struct wl1271 *wl) case WL1271_SCAN_STATE_5GHZ_PASSIVE: band = IEEE80211_BAND_5GHZ; rate = wl1271_tx_min_rate_get(wl, wl->bitrate_masks[band]); - ret = wl1271_scan_send(wl, band, true, rate); + ret = wl1271_scan_send(wl, vif, band, true, rate); if (ret == WL1271_NOTHING_TO_SCAN) { wl->scan.state = WL1271_SCAN_STATE_DONE; - wl1271_scan_stm(wl); + wl1271_scan_stm(wl, vif); } break; @@ -317,7 +319,8 @@ void wl1271_scan_stm(struct wl1271 *wl) } } -int wl1271_scan(struct wl1271 *wl, const u8 *ssid, size_t ssid_len, +int wl1271_scan(struct wl1271 *wl, struct ieee80211_vif *vif, + const u8 *ssid, size_t ssid_len, struct cfg80211_scan_request *req) { /* @@ -338,6 +341,7 @@ int wl1271_scan(struct wl1271 *wl, const u8 *ssid, size_t ssid_len, wl->scan.ssid_len = 0; } + wl->scan_vif = vif; wl->scan.req = req; memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch)); @@ -346,7 +350,7 @@ int wl1271_scan(struct wl1271 *wl, const u8 *ssid, size_t ssid_len, ieee80211_queue_delayed_work(wl->hw, &wl->scan_complete_work, msecs_to_jiffies(WL1271_SCAN_TIMEOUT)); - wl1271_scan_stm(wl); + wl1271_scan_stm(wl, vif); return 0; } diff --git a/drivers/net/wireless/wl12xx/scan.h b/drivers/net/wireless/wl12xx/scan.h index 92115156522f..15177bdfb542 100644 --- a/drivers/net/wireless/wl12xx/scan.h +++ b/drivers/net/wireless/wl12xx/scan.h @@ -26,13 +26,14 @@ #include "wl12xx.h" -int wl1271_scan(struct wl1271 *wl, const u8 *ssid, size_t ssid_len, +int wl1271_scan(struct wl1271 *wl, struct ieee80211_vif *vif, + const u8 *ssid, size_t ssid_len, struct cfg80211_scan_request *req); int wl1271_scan_stop(struct wl1271 *wl); int wl1271_scan_build_probe_req(struct wl1271 *wl, const u8 *ssid, size_t ssid_len, const u8 *ie, size_t ie_len, u8 band); -void wl1271_scan_stm(struct wl1271 *wl); +void wl1271_scan_stm(struct wl1271 *wl, struct ieee80211_vif *vif); void wl1271_scan_complete_work(struct work_struct *work); int wl1271_scan_sched_scan_config(struct wl1271 *wl, struct cfg80211_sched_scan_request *req, diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 1ec90fc7505e..b8de2f5e052b 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -507,6 +507,7 @@ struct wl1271 { u32 mbox_ptr[2]; /* Are we currently scanning */ + struct ieee80211_vif *scan_vif; struct wl1271_scan scan; struct delayed_work scan_complete_work; -- cgit v1.2.3 From 92c77c734f958474ac73af670834bc32cb833e54 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:40 +0200 Subject: wl12xx: start reworking the init sequence Split the init sequence into common commands (non role-specific) and role-specific commands. We still need to call the common commands only on add_interface() (rather than on start()) as the fw must get the mac address when uploading the nvs. Future patches will refactor the init sequence further more. Signed-off-by: Eliad Peller [fixed a couple of sparse warnings] Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/init.c | 306 ++++++++++++++++++++----------------- drivers/net/wireless/wl12xx/init.h | 5 +- drivers/net/wireless/wl12xx/main.c | 8 +- 3 files changed, 171 insertions(+), 148 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index 4692a91ca737..145601dddab0 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -33,7 +33,7 @@ #include "tx.h" #include "io.h" -int wl1271_sta_init_templates_config(struct wl1271 *wl) +int wl1271_init_templates_config(struct wl1271 *wl) { int ret, i; @@ -88,6 +88,29 @@ int wl1271_sta_init_templates_config(struct wl1271 *wl) if (ret < 0) return ret; + /* + * Put very large empty placeholders for all templates. These + * reserve memory for later. + */ + ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_PROBE_RESPONSE, NULL, + WL1271_CMD_TEMPL_MAX_SIZE, + 0, WL1271_RATE_AUTOMATIC); + if (ret < 0) + return ret; + + ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_BEACON, NULL, + WL1271_CMD_TEMPL_MAX_SIZE, + 0, WL1271_RATE_AUTOMATIC); + if (ret < 0) + return ret; + + ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP, NULL, + sizeof + (struct wl12xx_disconn_template), + 0, WL1271_RATE_AUTOMATIC); + if (ret < 0) + return ret; + for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) { ret = wl1271_cmd_template_set(wl, CMD_TEMPL_KLV, NULL, WL1271_CMD_TEMPL_DFLT_SIZE, i, @@ -185,68 +208,32 @@ out: return ret; } -static int wl1271_ap_init_templates_config(struct wl1271 *wl) +static int wl12xx_init_rx_config(struct wl1271 *wl) { int ret; - /* - * Put very large empty placeholders for all templates. These - * reserve memory for later. - */ - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_PROBE_RESPONSE, NULL, - WL1271_CMD_TEMPL_MAX_SIZE, - 0, WL1271_RATE_AUTOMATIC); - if (ret < 0) - return ret; - - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_BEACON, NULL, - WL1271_CMD_TEMPL_MAX_SIZE, - 0, WL1271_RATE_AUTOMATIC); - if (ret < 0) - return ret; - - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP, NULL, - sizeof - (struct wl12xx_disconn_template), - 0, WL1271_RATE_AUTOMATIC); - if (ret < 0) - return ret; - - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, NULL, - sizeof(struct wl12xx_null_data_template), - 0, WL1271_RATE_AUTOMATIC); - if (ret < 0) - return ret; - - ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL, - sizeof - (struct wl12xx_qos_null_data_template), - 0, WL1271_RATE_AUTOMATIC); + ret = wl1271_acx_rx_msdu_life_time(wl); if (ret < 0) return ret; return 0; } -static int wl12xx_init_rx_config(struct wl1271 *wl) +int wl1271_init_phy_config(struct wl1271 *wl) { int ret; - ret = wl1271_acx_rx_msdu_life_time(wl); + ret = wl1271_acx_pd_threshold(wl); if (ret < 0) return ret; return 0; } -int wl1271_init_phy_config(struct wl1271 *wl) +static int wl12xx_init_phy_vif_config(struct wl1271 *wl) { int ret; - ret = wl1271_acx_pd_threshold(wl); - if (ret < 0) - return ret; - ret = wl1271_acx_slot(wl, DEFAULT_SLOT_TIME); if (ret < 0) return ret; @@ -329,6 +316,7 @@ static int wl12xx_init_fwlog(struct wl1271 *wl) return 0; } +/* generic sta initialization (non vif-specific) */ static int wl1271_sta_hw_init(struct wl1271 *wl) { int ret; @@ -344,57 +332,20 @@ static int wl1271_sta_hw_init(struct wl1271 *wl) if (ret < 0) return ret; - ret = wl1271_sta_init_templates_config(wl); - if (ret < 0) - return ret; - - ret = wl1271_acx_group_address_tbl(wl, true, NULL, 0); - if (ret < 0) - return ret; - - /* Initialize connection monitoring thresholds */ - ret = wl1271_acx_conn_monit_params(wl, false); - if (ret < 0) - return ret; - - /* Beacon filtering */ - ret = wl1271_init_beacon_filter(wl); - if (ret < 0) - return ret; - /* FM WLAN coexistence */ ret = wl1271_acx_fm_coex(wl); if (ret < 0) return ret; - /* Beacons and broadcast settings */ - ret = wl1271_init_beacon_broadcast(wl); - if (ret < 0) - return ret; - /* Configure for ELP power saving */ ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP); if (ret < 0) return ret; - /* Configure rssi/snr averaging weights */ - ret = wl1271_acx_rssi_snr_avg_weights(wl); - if (ret < 0) - return ret; - ret = wl1271_acx_sta_rate_policies(wl); if (ret < 0) return ret; - ret = wl12xx_acx_mem_cfg(wl); - if (ret < 0) - return ret; - - /* Configure the FW logger */ - ret = wl12xx_init_fwlog(wl); - if (ret < 0) - return ret; - return 0; } @@ -418,14 +369,11 @@ static int wl1271_sta_hw_init_post_mem(struct wl1271 *wl) return 0; } +/* generic ap initialization (non vif-specific) */ static int wl1271_ap_hw_init(struct wl1271 *wl) { int ret; - ret = wl1271_ap_init_templates_config(wl); - if (ret < 0) - return ret; - /* Configure for power always on */ ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM); if (ret < 0) @@ -435,19 +383,6 @@ static int wl1271_ap_hw_init(struct wl1271 *wl) if (ret < 0) return ret; - ret = wl1271_acx_ap_max_tx_retry(wl); - if (ret < 0) - return ret; - - ret = wl12xx_acx_mem_cfg(wl); - if (ret < 0) - return ret; - - /* initialize Tx power */ - ret = wl1271_acx_tx_power(wl, wl->power_level); - if (ret < 0) - return ret; - return 0; } @@ -578,14 +513,133 @@ out: return ret; } +/* vif-specifc initialization */ +static int wl12xx_init_sta_role(struct wl1271 *wl, struct ieee80211_vif *vif) +{ + int ret; + + ret = wl1271_acx_group_address_tbl(wl, true, NULL, 0); + if (ret < 0) + return ret; + + /* Initialize connection monitoring thresholds */ + ret = wl1271_acx_conn_monit_params(wl, false); + if (ret < 0) + return ret; + + /* Beacon filtering */ + ret = wl1271_init_beacon_filter(wl); + if (ret < 0) + return ret; + + /* Beacons and broadcast settings */ + ret = wl1271_init_beacon_broadcast(wl); + if (ret < 0) + return ret; -int wl1271_hw_init(struct wl1271 *wl, struct ieee80211_vif *vif) + /* Configure rssi/snr averaging weights */ + ret = wl1271_acx_rssi_snr_avg_weights(wl); + if (ret < 0) + return ret; + + return 0; +} + +/* vif-specific intialization */ +static int wl12xx_init_ap_role(struct wl1271 *wl, struct ieee80211_vif *vif) +{ + int ret; + + ret = wl1271_acx_ap_max_tx_retry(wl); + if (ret < 0) + return ret; + + /* initialize Tx power */ + ret = wl1271_acx_tx_power(wl, wl->power_level); + if (ret < 0) + return ret; + + return 0; +} + +int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) { struct conf_tx_ac_category *conf_ac; struct conf_tx_tid *conf_tid; - int ret, i; bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); + int ret, i; + + /* Mode specific init */ + if (is_ap) { + ret = wl1271_ap_hw_init(wl); + if (ret < 0) + return ret; + + ret = wl12xx_init_ap_role(wl, vif); + if (ret < 0) + return ret; + } else { + ret = wl1271_sta_hw_init(wl); + if (ret < 0) + return ret; + + ret = wl12xx_init_sta_role(wl, vif); + if (ret < 0) + return ret; + } + + wl12xx_init_phy_vif_config(wl); + + /* Default TID/AC configuration */ + BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count); + for (i = 0; i < wl->conf.tx.tid_conf_count; i++) { + conf_ac = &wl->conf.tx.ac_conf[i]; + ret = wl1271_acx_ac_cfg(wl, conf_ac->ac, conf_ac->cw_min, + conf_ac->cw_max, conf_ac->aifsn, + conf_ac->tx_op_limit); + if (ret < 0) + return ret; + + conf_tid = &wl->conf.tx.tid_conf[i]; + ret = wl1271_acx_tid_cfg(wl, + conf_tid->queue_id, + conf_tid->channel_type, + conf_tid->tsid, + conf_tid->ps_scheme, + conf_tid->ack_policy, + conf_tid->apsd_conf[0], + conf_tid->apsd_conf[1]); + if (ret < 0) + return ret; + } + + /* Configure HW encryption */ + ret = wl1271_acx_feature_cfg(wl); + if (ret < 0) + return ret; + + /* Mode specific init - post mem init */ + if (is_ap) + ret = wl1271_ap_hw_init_post_mem(wl, vif); + else + ret = wl1271_sta_hw_init_post_mem(wl); + + if (ret < 0) + return ret; + + /* Configure initiator BA sessions policies */ + ret = wl1271_set_ba_policies(wl); + if (ret < 0) + return ret; + + return 0; +} + +int wl1271_hw_init(struct wl1271 *wl) +{ + int ret; + if (wl->chip.id == CHIP_ID_1283_PG20) ret = wl128x_cmd_general_parms(wl); else @@ -605,12 +659,17 @@ int wl1271_hw_init(struct wl1271 *wl, struct ieee80211_vif *vif) if (ret < 0) return ret; - /* Mode specific init */ - if (is_ap) - ret = wl1271_ap_hw_init(wl); - else - ret = wl1271_sta_hw_init(wl); + /* Init templates */ + ret = wl1271_init_templates_config(wl); + if (ret < 0) + return ret; + ret = wl12xx_acx_mem_cfg(wl); + if (ret < 0) + return ret; + + /* Configure the FW logger */ + ret = wl12xx_init_fwlog(wl); if (ret < 0) return ret; @@ -658,61 +717,20 @@ int wl1271_hw_init(struct wl1271 *wl, struct ieee80211_vif *vif) if (ret < 0) goto out_free_memmap; - /* Default TID/AC configuration */ - BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count); - for (i = 0; i < wl->conf.tx.tid_conf_count; i++) { - conf_ac = &wl->conf.tx.ac_conf[i]; - ret = wl1271_acx_ac_cfg(wl, conf_ac->ac, conf_ac->cw_min, - conf_ac->cw_max, conf_ac->aifsn, - conf_ac->tx_op_limit); - if (ret < 0) - goto out_free_memmap; - - conf_tid = &wl->conf.tx.tid_conf[i]; - ret = wl1271_acx_tid_cfg(wl, conf_tid->queue_id, - conf_tid->channel_type, - conf_tid->tsid, - conf_tid->ps_scheme, - conf_tid->ack_policy, - conf_tid->apsd_conf[0], - conf_tid->apsd_conf[1]); - if (ret < 0) - goto out_free_memmap; - } - /* Enable data path */ ret = wl1271_cmd_data_path(wl, 1); if (ret < 0) goto out_free_memmap; - /* Configure HW encryption */ - ret = wl1271_acx_feature_cfg(wl); - if (ret < 0) - goto out_free_memmap; - /* configure PM */ ret = wl1271_acx_pm_config(wl); if (ret < 0) goto out_free_memmap; - /* Mode specific init - post mem init */ - if (is_ap) - ret = wl1271_ap_hw_init_post_mem(wl, vif); - else - ret = wl1271_sta_hw_init_post_mem(wl); - - if (ret < 0) - goto out_free_memmap; - ret = wl12xx_acx_set_rate_mgmt_params(wl); if (ret < 0) goto out_free_memmap; - /* Configure initiator BA sessions policies */ - ret = wl1271_set_ba_policies(wl); - if (ret < 0) - goto out_free_memmap; - /* configure hangover */ ret = wl12xx_acx_config_hangover(wl); if (ret < 0) diff --git a/drivers/net/wireless/wl12xx/init.h b/drivers/net/wireless/wl12xx/init.h index b1f97bcc47c0..64320c0224ca 100644 --- a/drivers/net/wireless/wl12xx/init.h +++ b/drivers/net/wireless/wl12xx/init.h @@ -27,12 +27,13 @@ #include "wl12xx.h" int wl1271_hw_init_power_auth(struct wl1271 *wl); -int wl1271_sta_init_templates_config(struct wl1271 *wl); +int wl1271_init_templates_config(struct wl1271 *wl); int wl1271_init_phy_config(struct wl1271 *wl); int wl1271_init_pta(struct wl1271 *wl); int wl1271_init_energy_detection(struct wl1271 *wl); int wl1271_chip_specific_init(struct wl1271 *wl); -int wl1271_hw_init(struct wl1271 *wl, struct ieee80211_vif *vif); +int wl1271_hw_init(struct wl1271 *wl); +int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif); int wl1271_init_ap_rates(struct wl1271 *wl); int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 652471e8c61b..901e43a8334b 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -676,7 +676,7 @@ static int wl1271_plt_init(struct wl1271 *wl) if (ret < 0) return ret; - ret = wl1271_sta_init_templates_config(wl); + ret = wl1271_init_templates_config(wl); if (ret < 0) return ret; @@ -1919,6 +1919,10 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, if (ret < 0) goto power_off; + ret = wl1271_hw_init(wl); + if (ret < 0) + goto irq_disable; + if (wl->bss_type == BSS_TYPE_STA_BSS || wl->bss_type == BSS_TYPE_IBSS) { /* @@ -1939,7 +1943,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, if (ret < 0) goto irq_disable; - ret = wl1271_hw_init(wl, vif); + ret = wl1271_init_vif_specific(wl, vif); if (ret < 0) goto irq_disable; -- cgit v1.2.3 From 87fbcb0f8c5c8fd57a4e3e7e638977c04ce1e0ca Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:41 +0200 Subject: wl12xx: define wl12xx_vif Define a per-vif data struct. This struct holds all the vif-specifc data, which is currently being hold by the global wl struct. Start by moving the basic_rate_set field into it. NOTE: in order to make the patches a bit smaller, start by using wl->vif in some functions, instead of changing all the function prototypes at once. finally, wl->vif will be removed altogether. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 21 ++++++----- drivers/net/wireless/wl12xx/cmd.h | 9 +++-- drivers/net/wireless/wl12xx/debugfs.c | 1 - drivers/net/wireless/wl12xx/init.c | 34 ++++++++++------- drivers/net/wireless/wl12xx/init.h | 2 +- drivers/net/wireless/wl12xx/main.c | 70 ++++++++++++++++++++++------------- drivers/net/wireless/wl12xx/wl12xx.h | 16 +++++++- 7 files changed, 96 insertions(+), 57 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index bee44c7d67fd..c99fc61113d1 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -555,7 +555,7 @@ out: return ret; } -int wl12xx_cmd_role_start_sta(struct wl1271 *wl) +int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct wl12xx_cmd_role_start *cmd; int ret; @@ -572,7 +572,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl) if (wl->band == IEEE80211_BAND_5GHZ) cmd->band = WL12XX_BAND_5GHZ; cmd->channel = wl->channel; - cmd->sta.basic_rate_set = cpu_to_le32(wl->basic_rate_set); + cmd->sta.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set); cmd->sta.beacon_interval = cpu_to_le16(wl->beacon_int); cmd->sta.ssid_type = WL12XX_SSID_TYPE_ANY; cmd->sta.ssid_len = wl->ssid_len; @@ -592,7 +592,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl) wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d " "basic_rate_set: 0x%x, remote_rates: 0x%x", wl->role_id, cmd->sta.hlid, cmd->sta.session, - wl->basic_rate_set, wl->rate_set); + wlvif->basic_rate_set, wl->rate_set); ret = wl1271_cmd_send(wl, CMD_ROLE_START, cmd, sizeof(*cmd), 0); if (ret < 0) { @@ -649,7 +649,7 @@ out: return ret; } -int wl12xx_cmd_role_start_ap(struct wl1271 *wl) +int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct wl12xx_cmd_role_start *cmd; struct ieee80211_bss_conf *bss_conf = &wl->vif->bss_conf; @@ -683,7 +683,7 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl) cmd->ap.bss_index = WL1271_AP_BSS_INDEX; cmd->ap.global_hlid = wl->ap_global_hlid; cmd->ap.broadcast_hlid = wl->ap_bcast_hlid; - cmd->ap.basic_rate_set = cpu_to_le32(wl->basic_rate_set); + cmd->ap.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set); cmd->ap.beacon_interval = cpu_to_le16(wl->beacon_int); cmd->ap.dtim_interval = bss_conf->dtim_period; cmd->ap.beacon_expiry = WL1271_AP_DEF_BEACON_EXP; @@ -767,7 +767,7 @@ out: return ret; } -int wl12xx_cmd_role_start_ibss(struct wl1271 *wl) +int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct wl12xx_cmd_role_start *cmd; struct ieee80211_bss_conf *bss_conf = &wl->vif->bss_conf; @@ -785,7 +785,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl) if (wl->band == IEEE80211_BAND_5GHZ) cmd->band = WL12XX_BAND_5GHZ; cmd->channel = wl->channel; - cmd->ibss.basic_rate_set = cpu_to_le32(wl->basic_rate_set); + cmd->ibss.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set); cmd->ibss.beacon_interval = cpu_to_le16(wl->beacon_int); cmd->ibss.dtim_interval = bss_conf->dtim_period; cmd->ibss.ssid_type = WL12XX_SSID_TYPE_ANY; @@ -805,7 +805,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl) wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d " "basic_rate_set: 0x%x, remote_rates: 0x%x", wl->role_id, cmd->sta.hlid, cmd->sta.session, - wl->basic_rate_set, wl->rate_set); + wlvif->basic_rate_set, wl->rate_set); wl1271_debug(DEBUG_CMD, "wl->bssid = %pM", wl->bssid); @@ -1085,7 +1085,8 @@ out: } -int wl1271_cmd_build_ps_poll(struct wl1271 *wl, u16 aid) +int wl1271_cmd_build_ps_poll(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u16 aid) { struct sk_buff *skb; int ret = 0; @@ -1095,7 +1096,7 @@ int wl1271_cmd_build_ps_poll(struct wl1271 *wl, u16 aid) goto out; ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PS_POLL, skb->data, - skb->len, 0, wl->basic_rate_set); + skb->len, 0, wlvif->basic_rate_set); out: dev_kfree_skb(skb); diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index 1ae949f00c14..234a8dc90559 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -41,11 +41,11 @@ int wl12xx_cmd_role_enable(struct wl1271 *wl, u8 *addr, u8 role_type, int wl12xx_cmd_role_disable(struct wl1271 *wl, u8 *role_id); int wl12xx_cmd_role_start_dev(struct wl1271 *wl); int wl12xx_cmd_role_stop_dev(struct wl1271 *wl); -int wl12xx_cmd_role_start_sta(struct wl1271 *wl); +int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_role_stop_sta(struct wl1271 *wl); -int wl12xx_cmd_role_start_ap(struct wl1271 *wl); +int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_role_stop_ap(struct wl1271 *wl); -int wl12xx_cmd_role_start_ibss(struct wl1271 *wl); +int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer); int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len); int wl1271_cmd_configure(struct wl1271 *wl, u16 id, void *buf, size_t len); @@ -56,7 +56,8 @@ int wl1271_cmd_read_memory(struct wl1271 *wl, u32 addr, void *answer, int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id, void *buf, size_t buf_len, int index, u32 rates); int wl1271_cmd_build_null_data(struct wl1271 *wl); -int wl1271_cmd_build_ps_poll(struct wl1271 *wl, u16 aid); +int wl1271_cmd_build_ps_poll(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u16 aid); int wl1271_cmd_build_probe_req(struct wl1271 *wl, const u8 *ssid, size_t ssid_len, const u8 *ie, size_t ie_len, u8 band); diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 3999fd528302..0419aafe5c57 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -353,7 +353,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, DRIVER_STATE_PRINT_INT(bss_type); DRIVER_STATE_PRINT_INT(channel); DRIVER_STATE_PRINT_HEX(rate_set); - DRIVER_STATE_PRINT_HEX(basic_rate_set); DRIVER_STATE_PRINT_HEX(basic_rate); DRIVER_STATE_PRINT_INT(band); DRIVER_STATE_PRINT_INT(beacon_int); diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index 145601dddab0..c00bdf8a3584 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -122,7 +122,8 @@ int wl1271_init_templates_config(struct wl1271 *wl) return 0; } -static int wl1271_ap_init_deauth_template(struct wl1271 *wl) +static int wl1271_ap_init_deauth_template(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { struct wl12xx_disconn_template *tmpl; int ret; @@ -137,7 +138,7 @@ static int wl1271_ap_init_deauth_template(struct wl1271 *wl) tmpl->header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_DEAUTH); - rate = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); + rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP, tmpl, sizeof(*tmpl), 0, rate); @@ -149,6 +150,7 @@ out: static int wl1271_ap_init_null_template(struct wl1271 *wl, struct ieee80211_vif *vif) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct ieee80211_hdr_3addr *nullfunc; int ret; u32 rate; @@ -168,7 +170,7 @@ static int wl1271_ap_init_null_template(struct wl1271 *wl, memcpy(nullfunc->addr2, vif->addr, ETH_ALEN); memcpy(nullfunc->addr3, vif->addr, ETH_ALEN); - rate = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); + rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, nullfunc, sizeof(*nullfunc), 0, rate); @@ -180,6 +182,7 @@ out: static int wl1271_ap_init_qos_null_template(struct wl1271 *wl, struct ieee80211_vif *vif) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct ieee80211_qos_hdr *qosnull; int ret; u32 rate; @@ -199,7 +202,7 @@ static int wl1271_ap_init_qos_null_template(struct wl1271 *wl, memcpy(qosnull->addr2, vif->addr, ETH_ALEN); memcpy(qosnull->addr3, vif->addr, ETH_ALEN); - rate = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); + rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, qosnull, sizeof(*qosnull), 0, rate); @@ -370,7 +373,7 @@ static int wl1271_sta_hw_init_post_mem(struct wl1271 *wl) } /* generic ap initialization (non vif-specific) */ -static int wl1271_ap_hw_init(struct wl1271 *wl) +static int wl1271_ap_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int ret; @@ -379,7 +382,7 @@ static int wl1271_ap_hw_init(struct wl1271 *wl) if (ret < 0) return ret; - ret = wl1271_init_ap_rates(wl); + ret = wl1271_init_ap_rates(wl, wlvif); if (ret < 0) return ret; @@ -388,9 +391,10 @@ static int wl1271_ap_hw_init(struct wl1271 *wl) int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret; - ret = wl1271_ap_init_deauth_template(wl); + ret = wl1271_ap_init_deauth_template(wl, wlvif); if (ret < 0) return ret; @@ -419,18 +423,19 @@ static int wl1271_ap_hw_init_post_mem(struct wl1271 *wl, return wl1271_ap_init_templates(wl, vif); } -int wl1271_init_ap_rates(struct wl1271 *wl) +int wl1271_init_ap_rates(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int i, ret; struct conf_tx_rate_class rc; u32 supported_rates; - wl1271_debug(DEBUG_AP, "AP basic rate set: 0x%x", wl->basic_rate_set); + wl1271_debug(DEBUG_AP, "AP basic rate set: 0x%x", + wlvif->basic_rate_set); - if (wl->basic_rate_set == 0) + if (wlvif->basic_rate_set == 0) return -EINVAL; - rc.enabled_rates = wl->basic_rate_set; + rc.enabled_rates = wlvif->basic_rate_set; rc.long_retry_limit = 10; rc.short_retry_limit = 10; rc.aflags = 0; @@ -439,7 +444,7 @@ int wl1271_init_ap_rates(struct wl1271 *wl) return ret; /* use the min basic rate for AP broadcast/multicast */ - rc.enabled_rates = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); + rc.enabled_rates = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); rc.short_retry_limit = 10; rc.long_retry_limit = 10; rc.aflags = 0; @@ -451,7 +456,7 @@ int wl1271_init_ap_rates(struct wl1271 *wl) * If the basic rates contain OFDM rates, use OFDM only * rates for unicast TX as well. Else use all supported rates. */ - if ((wl->basic_rate_set & CONF_TX_OFDM_RATES)) + if ((wlvif->basic_rate_set & CONF_TX_OFDM_RATES)) supported_rates = CONF_TX_OFDM_RATES; else supported_rates = CONF_TX_AP_ENABLED_RATES; @@ -564,6 +569,7 @@ static int wl12xx_init_ap_role(struct wl1271 *wl, struct ieee80211_vif *vif) int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct conf_tx_ac_category *conf_ac; struct conf_tx_tid *conf_tid; bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); @@ -572,7 +578,7 @@ int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) /* Mode specific init */ if (is_ap) { - ret = wl1271_ap_hw_init(wl); + ret = wl1271_ap_hw_init(wl, wlvif); if (ret < 0) return ret; diff --git a/drivers/net/wireless/wl12xx/init.h b/drivers/net/wireless/wl12xx/init.h index 64320c0224ca..81140b81f654 100644 --- a/drivers/net/wireless/wl12xx/init.h +++ b/drivers/net/wireless/wl12xx/init.h @@ -34,7 +34,7 @@ int wl1271_init_energy_detection(struct wl1271 *wl); int wl1271_chip_specific_init(struct wl1271 *wl); int wl1271_hw_init(struct wl1271 *wl); int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif); -int wl1271_init_ap_rates(struct wl1271 *wl); +int wl1271_init_ap_rates(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif); #endif diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 901e43a8334b..0c43cf55f9bf 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1837,6 +1837,11 @@ static u8 wl12xx_get_role_type(struct wl1271 *wl) return WL12XX_INVALID_ROLE_TYPE; } +static void wl12xx_init_vif_data(struct wl12xx_vif *wlvif) +{ + wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC; +} + static int wl1271_op_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { @@ -1857,6 +1862,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, ret = -EBUSY; goto out; } + wl12xx_init_vif_data(wl12xx_vif_to_data(vif)); /* * in some very corner case HW recovery scenarios its possible to @@ -2163,7 +2169,8 @@ static void wl1271_op_remove_interface(struct ieee80211_hw *hw, cancel_work_sync(&wl->recovery_work); } -static int wl1271_join(struct wl1271 *wl, bool set_assoc) +static int wl1271_join(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool set_assoc) { int ret; bool is_ibss = (wl->bss_type == BSS_TYPE_IBSS); @@ -2184,9 +2191,9 @@ static int wl1271_join(struct wl1271 *wl, bool set_assoc) set_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags); if (is_ibss) - ret = wl12xx_cmd_role_start_ibss(wl); + ret = wl12xx_cmd_role_start_ibss(wl, wlvif); else - ret = wl12xx_cmd_role_start_sta(wl); + ret = wl12xx_cmd_role_start_sta(wl, wlvif); if (ret < 0) goto out; @@ -2244,10 +2251,10 @@ out: return ret; } -static void wl1271_set_band_rate(struct wl1271 *wl) +static void wl1271_set_band_rate(struct wl1271 *wl, struct wl12xx_vif *wlvif) { - wl->basic_rate_set = wl->bitrate_masks[wl->band]; - wl->rate_set = wl->basic_rate_set; + wlvif->basic_rate_set = wl->bitrate_masks[wl->band]; + wl->rate_set = wlvif->basic_rate_set; } static bool wl12xx_is_roc(struct wl1271 *wl) @@ -2261,7 +2268,8 @@ static bool wl12xx_is_roc(struct wl1271 *wl) return true; } -static int wl1271_sta_handle_idle(struct wl1271 *wl, bool idle) +static int wl1271_sta_handle_idle(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool idle) { int ret; @@ -2276,7 +2284,8 @@ static int wl1271_sta_handle_idle(struct wl1271 *wl, bool idle) if (ret < 0) goto out; } - wl->rate_set = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); + wl->rate_set = wl1271_tx_min_rate_get(wl, + wlvif->basic_rate_set); ret = wl1271_acx_sta_rate_policies(wl); if (ret < 0) goto out; @@ -2310,6 +2319,8 @@ out: static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) { struct wl1271 *wl = hw->priv; + struct ieee80211_vif *vif = wl->vif; /* TODO: reconfig all vifs */ + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct ieee80211_conf *conf = &hw->conf; int channel, ret = 0; bool is_ap; @@ -2371,10 +2382,11 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) * association frames and other control messages. */ if (!test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) - wl1271_set_band_rate(wl); + wl1271_set_band_rate(wl, wlvif); wl->basic_rate = - wl1271_tx_min_rate_get(wl, wl->basic_rate_set); + wl1271_tx_min_rate_get(wl, + wlvif->basic_rate_set); ret = wl1271_acx_sta_rate_policies(wl); if (ret < 0) wl1271_warning("rate policy for channel " @@ -2387,7 +2399,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) if (ret < 0) goto out_sleep; } - ret = wl1271_join(wl, false); + ret = wl1271_join(wl, wlvif, false); if (ret < 0) wl1271_warning("cmd join on channel " "failed %d", ret); @@ -2413,7 +2425,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) } if (changed & IEEE80211_CONF_CHANGE_IDLE && !is_ap) { - ret = wl1271_sta_handle_idle(wl, + ret = wl1271_sta_handle_idle(wl, wlvif, conf->flags & IEEE80211_CONF_IDLE); if (ret < 0) wl1271_warning("idle mode change failed %d", ret); @@ -3207,6 +3219,7 @@ static int wl1271_bss_beacon_info_changed(struct wl1271 *wl, struct ieee80211_bss_conf *bss_conf, u32 changed) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); int ret = 0; @@ -3235,7 +3248,7 @@ static int wl1271_bss_beacon_info_changed(struct wl1271 *wl, dev_kfree_skb(beacon); goto out; } - min_rate = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); + min_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); tmpl_id = is_ap ? CMD_TEMPL_AP_BEACON : CMD_TEMPL_BEACON; ret = wl1271_cmd_template_set(wl, tmpl_id, @@ -3290,17 +3303,18 @@ static void wl1271_bss_info_changed_ap(struct wl1271 *wl, struct ieee80211_bss_conf *bss_conf, u32 changed) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret = 0; if ((changed & BSS_CHANGED_BASIC_RATES)) { u32 rates = bss_conf->basic_rates; - wl->basic_rate_set = wl1271_tx_enabled_rates_get(wl, rates, + wlvif->basic_rate_set = wl1271_tx_enabled_rates_get(wl, rates, wl->band); wl->basic_rate = wl1271_tx_min_rate_get(wl, - wl->basic_rate_set); + wlvif->basic_rate_set); - ret = wl1271_init_ap_rates(wl); + ret = wl1271_init_ap_rates(wl, wlvif); if (ret < 0) { wl1271_error("AP rate policy change failed %d", ret); goto out; @@ -3318,7 +3332,7 @@ static void wl1271_bss_info_changed_ap(struct wl1271 *wl, if ((changed & BSS_CHANGED_BEACON_ENABLED)) { if (bss_conf->enable_beacon) { if (!test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) { - ret = wl12xx_cmd_role_start_ap(wl); + ret = wl12xx_cmd_role_start_ap(wl, wlvif); if (ret < 0) goto out; @@ -3366,6 +3380,7 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, struct ieee80211_bss_conf *bss_conf, u32 changed) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); bool do_join = false, set_assoc = false; bool is_ibss = (wl->bss_type == BSS_TYPE_IBSS); bool ibss_joined = false; @@ -3480,11 +3495,12 @@ sta_not_found: * to use with control frames. */ rates = bss_conf->basic_rates; - wl->basic_rate_set = + wlvif->basic_rate_set = wl1271_tx_enabled_rates_get(wl, rates, wl->band); wl->basic_rate = - wl1271_tx_min_rate_get(wl, wl->basic_rate_set); + wl1271_tx_min_rate_get(wl, + wlvif->basic_rate_set); if (sta_rate_set) wl->rate_set = wl1271_tx_enabled_rates_get(wl, sta_rate_set, @@ -3499,7 +3515,7 @@ sta_not_found: * updates it by itself when the first beacon is * received after a join. */ - ret = wl1271_cmd_build_ps_poll(wl, wl->aid); + ret = wl1271_cmd_build_ps_poll(wl, wlvif, wl->aid); if (ret < 0) goto out; @@ -3534,9 +3550,10 @@ sta_not_found: ieee80211_enable_dyn_ps(wl->vif); /* revert back to minimum rates for the current band */ - wl1271_set_band_rate(wl); + wl1271_set_band_rate(wl, wlvif); wl->basic_rate = - wl1271_tx_min_rate_get(wl, wl->basic_rate_set); + wl1271_tx_min_rate_get(wl, + wlvif->basic_rate_set); ret = wl1271_acx_sta_rate_policies(wl); if (ret < 0) goto out; @@ -3587,11 +3604,12 @@ sta_not_found: if (bss_conf->ibss_joined) { u32 rates = bss_conf->basic_rates; - wl->basic_rate_set = + wlvif->basic_rate_set = wl1271_tx_enabled_rates_get(wl, rates, wl->band); wl->basic_rate = - wl1271_tx_min_rate_get(wl, wl->basic_rate_set); + wl1271_tx_min_rate_get(wl, + wlvif->basic_rate_set); /* by default, use 11b + OFDM rates */ wl->rate_set = CONF_TX_IBSS_DEFAULT_RATES; @@ -3634,7 +3652,7 @@ sta_not_found: } if (do_join) { - ret = wl1271_join(wl, set_assoc); + ret = wl1271_join(wl, wlvif, set_assoc); if (ret < 0) { wl1271_warning("cmd join failed %d", ret); goto out; @@ -4750,6 +4768,7 @@ int wl1271_init_ieee80211(struct wl1271 *wl) SET_IEEE80211_DEV(wl->hw, wl1271_wl_to_dev(wl)); wl->hw->sta_data_size = sizeof(struct wl1271_station); + wl->hw->vif_data_size = sizeof(struct wl12xx_vif); wl->hw->max_rx_aggregation_subframes = 8; @@ -4824,7 +4843,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->rx_counter = 0; wl->psm_entry_retry = 0; wl->power_level = WL1271_DEFAULT_POWER_LEVEL; - wl->basic_rate_set = CONF_TX_RATE_MASK_BASIC; wl->basic_rate = CONF_TX_RATE_MASK_BASIC; wl->rate_set = CONF_TX_RATE_MASK_BASIC; wl->band = IEEE80211_BAND_2GHZ; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index b8de2f5e052b..7e30dd53cb88 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -525,7 +525,6 @@ struct wl1271 { * bits 16-23 - 802.11n MCS index mask * support only 1 stream, thus only 8 bits for the MCS rates (0-7). */ - u32 basic_rate_set; u32 basic_rate; u32 rate_set; u32 bitrate_masks[IEEE80211_NUM_BANDS]; @@ -639,6 +638,21 @@ struct wl1271_station { u8 hlid; }; +struct wl12xx_vif { + u32 basic_rate_set; +}; + +static inline struct wl12xx_vif *wl12xx_vif_to_data(struct ieee80211_vif *vif) +{ + return (struct wl12xx_vif *)vif->drv_priv; +} + +static inline +struct ieee80211_vif *wl12xx_wlvif_to_vif(struct wl12xx_vif *wlvif) +{ + return container_of((void *)wlvif, struct ieee80211_vif, drv_priv); +} + int wl1271_plt_start(struct wl1271 *wl); int wl1271_plt_stop(struct wl1271 *wl); int wl1271_recalc_rx_streaming(struct wl1271 *wl); -- cgit v1.2.3 From 30d0c8fd5b87d1c5486705d6420545a21533e115 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:42 +0200 Subject: wl12xx: move rate_set into wlvif move rate_set into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/acx.c | 6 +++--- drivers/net/wireless/wl12xx/acx.h | 2 +- drivers/net/wireless/wl12xx/cmd.c | 12 ++++++------ drivers/net/wireless/wl12xx/debugfs.c | 1 - drivers/net/wireless/wl12xx/init.c | 6 +++--- drivers/net/wireless/wl12xx/main.c | 24 ++++++++++++------------ drivers/net/wireless/wl12xx/wl12xx.h | 9 ++++++++- 7 files changed, 33 insertions(+), 27 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/acx.c b/drivers/net/wireless/wl12xx/acx.c index ca044a743191..1ef9b0b48635 100644 --- a/drivers/net/wireless/wl12xx/acx.c +++ b/drivers/net/wireless/wl12xx/acx.c @@ -739,7 +739,7 @@ int wl1271_acx_statistics(struct wl1271 *wl, struct acx_statistics *stats) return 0; } -int wl1271_acx_sta_rate_policies(struct wl1271 *wl) +int wl1271_acx_sta_rate_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct acx_rate_policy *acx; struct conf_tx_rate_class *c = &wl->conf.tx.sta_rc_conf; @@ -755,7 +755,7 @@ int wl1271_acx_sta_rate_policies(struct wl1271 *wl) } wl1271_debug(DEBUG_ACX, "basic_rate: 0x%x, full_rate: 0x%x", - wl->basic_rate, wl->rate_set); + wl->basic_rate, wlvif->rate_set); /* configure one basic rate class */ acx->rate_policy_idx = cpu_to_le32(ACX_TX_BASIC_RATE); @@ -772,7 +772,7 @@ int wl1271_acx_sta_rate_policies(struct wl1271 *wl) /* configure one AP supported rate class */ acx->rate_policy_idx = cpu_to_le32(ACX_TX_AP_FULL_RATE); - acx->rate_policy.enabled_rates = cpu_to_le32(wl->rate_set); + acx->rate_policy.enabled_rates = cpu_to_le32(wlvif->rate_set); acx->rate_policy.short_retry_limit = c->short_retry_limit; acx->rate_policy.long_retry_limit = c->long_retry_limit; acx->rate_policy.aflags = c->aflags; diff --git a/drivers/net/wireless/wl12xx/acx.h b/drivers/net/wireless/wl12xx/acx.h index e3f93b4b3429..81779f45ab41 100644 --- a/drivers/net/wireless/wl12xx/acx.h +++ b/drivers/net/wireless/wl12xx/acx.h @@ -1261,7 +1261,7 @@ int wl1271_acx_set_preamble(struct wl1271 *wl, enum acx_preamble_type preamble); int wl1271_acx_cts_protect(struct wl1271 *wl, enum acx_ctsprotect_type ctsprotect); int wl1271_acx_statistics(struct wl1271 *wl, struct acx_statistics *stats); -int wl1271_acx_sta_rate_policies(struct wl1271 *wl); +int wl1271_acx_sta_rate_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl1271_acx_ap_rate_policy(struct wl1271 *wl, struct conf_tx_rate_class *c, u8 idx); int wl1271_acx_ac_cfg(struct wl1271 *wl, u8 ac, u8 cw_min, u16 cw_max, diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index c99fc61113d1..6a2f758eb1d3 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -578,7 +578,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->sta.ssid_len = wl->ssid_len; memcpy(cmd->sta.ssid, wl->ssid, wl->ssid_len); memcpy(cmd->sta.bssid, wl->bssid, ETH_ALEN); - cmd->sta.local_rates = cpu_to_le32(wl->rate_set); + cmd->sta.local_rates = cpu_to_le32(wlvif->rate_set); if (wl->sta_hlid == WL12XX_INVALID_LINK_ID) { ret = wl12xx_allocate_link(wl, &wl->sta_hlid); @@ -587,12 +587,12 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) } cmd->sta.hlid = wl->sta_hlid; cmd->sta.session = wl12xx_get_new_session_id(wl); - cmd->sta.remote_rates = cpu_to_le32(wl->rate_set); + cmd->sta.remote_rates = cpu_to_le32(wlvif->rate_set); wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d " "basic_rate_set: 0x%x, remote_rates: 0x%x", wl->role_id, cmd->sta.hlid, cmd->sta.session, - wlvif->basic_rate_set, wl->rate_set); + wlvif->basic_rate_set, wlvif->rate_set); ret = wl1271_cmd_send(wl, CMD_ROLE_START, cmd, sizeof(*cmd), 0); if (ret < 0) { @@ -792,7 +792,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->ibss.ssid_len = wl->ssid_len; memcpy(cmd->ibss.ssid, wl->ssid, wl->ssid_len); memcpy(cmd->ibss.bssid, wl->bssid, ETH_ALEN); - cmd->sta.local_rates = cpu_to_le32(wl->rate_set); + cmd->sta.local_rates = cpu_to_le32(wlvif->rate_set); if (wl->sta_hlid == WL12XX_INVALID_LINK_ID) { ret = wl12xx_allocate_link(wl, &wl->sta_hlid); @@ -800,12 +800,12 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out_free; } cmd->ibss.hlid = wl->sta_hlid; - cmd->ibss.remote_rates = cpu_to_le32(wl->rate_set); + cmd->ibss.remote_rates = cpu_to_le32(wlvif->rate_set); wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d " "basic_rate_set: 0x%x, remote_rates: 0x%x", wl->role_id, cmd->sta.hlid, cmd->sta.session, - wlvif->basic_rate_set, wl->rate_set); + wlvif->basic_rate_set, wlvif->rate_set); wl1271_debug(DEBUG_CMD, "wl->bssid = %pM", wl->bssid); diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 0419aafe5c57..e63fea4b120d 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -352,7 +352,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, DRIVER_STATE_PRINT_INT(state); DRIVER_STATE_PRINT_INT(bss_type); DRIVER_STATE_PRINT_INT(channel); - DRIVER_STATE_PRINT_HEX(rate_set); DRIVER_STATE_PRINT_HEX(basic_rate); DRIVER_STATE_PRINT_INT(band); DRIVER_STATE_PRINT_INT(beacon_int); diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index c00bdf8a3584..37955dad1f93 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -320,7 +320,7 @@ static int wl12xx_init_fwlog(struct wl1271 *wl) } /* generic sta initialization (non vif-specific) */ -static int wl1271_sta_hw_init(struct wl1271 *wl) +static int wl1271_sta_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int ret; @@ -345,7 +345,7 @@ static int wl1271_sta_hw_init(struct wl1271 *wl) if (ret < 0) return ret; - ret = wl1271_acx_sta_rate_policies(wl); + ret = wl1271_acx_sta_rate_policies(wl, wlvif); if (ret < 0) return ret; @@ -586,7 +586,7 @@ int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) if (ret < 0) return ret; } else { - ret = wl1271_sta_hw_init(wl); + ret = wl1271_sta_hw_init(wl, wlvif); if (ret < 0) return ret; diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 0c43cf55f9bf..195dcbdf1fc7 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1840,6 +1840,7 @@ static u8 wl12xx_get_role_type(struct wl1271 *wl) static void wl12xx_init_vif_data(struct wl12xx_vif *wlvif) { wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC; + wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; } static int wl1271_op_add_interface(struct ieee80211_hw *hw, @@ -2106,7 +2107,6 @@ deinit: wl->tx_packets_count = 0; wl->time_offset = 0; wl->session_counter = 0; - wl->rate_set = CONF_TX_RATE_MASK_BASIC; wl->bitrate_masks[IEEE80211_BAND_2GHZ] = wl->conf.tx.basic_rate; wl->bitrate_masks[IEEE80211_BAND_5GHZ] = wl->conf.tx.basic_rate_5; wl->vif = NULL; @@ -2254,7 +2254,7 @@ out: static void wl1271_set_band_rate(struct wl1271 *wl, struct wl12xx_vif *wlvif) { wlvif->basic_rate_set = wl->bitrate_masks[wl->band]; - wl->rate_set = wlvif->basic_rate_set; + wlvif->rate_set = wlvif->basic_rate_set; } static bool wl12xx_is_roc(struct wl1271 *wl) @@ -2284,9 +2284,9 @@ static int wl1271_sta_handle_idle(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (ret < 0) goto out; } - wl->rate_set = wl1271_tx_min_rate_get(wl, - wlvif->basic_rate_set); - ret = wl1271_acx_sta_rate_policies(wl); + wlvif->rate_set = + wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); + ret = wl1271_acx_sta_rate_policies(wl, wlvif); if (ret < 0) goto out; ret = wl1271_acx_keep_alive_config( @@ -2387,7 +2387,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) wl->basic_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); - ret = wl1271_acx_sta_rate_policies(wl); + ret = wl1271_acx_sta_rate_policies(wl, wlvif); if (ret < 0) wl1271_warning("rate policy for channel " "failed %d", ret); @@ -3502,10 +3502,11 @@ sta_not_found: wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); if (sta_rate_set) - wl->rate_set = wl1271_tx_enabled_rates_get(wl, + wlvif->rate_set = + wl1271_tx_enabled_rates_get(wl, sta_rate_set, wl->band); - ret = wl1271_acx_sta_rate_policies(wl); + ret = wl1271_acx_sta_rate_policies(wl, wlvif); if (ret < 0) goto out; @@ -3554,7 +3555,7 @@ sta_not_found: wl->basic_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); - ret = wl1271_acx_sta_rate_policies(wl); + ret = wl1271_acx_sta_rate_policies(wl, wlvif); if (ret < 0) goto out; @@ -3612,8 +3613,8 @@ sta_not_found: wlvif->basic_rate_set); /* by default, use 11b + OFDM rates */ - wl->rate_set = CONF_TX_IBSS_DEFAULT_RATES; - ret = wl1271_acx_sta_rate_policies(wl); + wlvif->rate_set = CONF_TX_IBSS_DEFAULT_RATES; + ret = wl1271_acx_sta_rate_policies(wl, wlvif); if (ret < 0) goto out; } @@ -4844,7 +4845,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->psm_entry_retry = 0; wl->power_level = WL1271_DEFAULT_POWER_LEVEL; wl->basic_rate = CONF_TX_RATE_MASK_BASIC; - wl->rate_set = CONF_TX_RATE_MASK_BASIC; wl->band = IEEE80211_BAND_2GHZ; wl->vif = NULL; wl->flags = 0; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 7e30dd53cb88..6f3efbae740e 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -526,7 +526,6 @@ struct wl1271 { * support only 1 stream, thus only 8 bits for the MCS rates (0-7). */ u32 basic_rate; - u32 rate_set; u32 bitrate_masks[IEEE80211_NUM_BANDS]; /* The current band */ @@ -640,6 +639,14 @@ struct wl1271_station { struct wl12xx_vif { u32 basic_rate_set; + + /* + * currently configured rate set: + * bits 0-15 - 802.11abg rates + * bits 16-23 - 802.11n MCS index mask + * support only 1 stream, thus only 8 bits for the MCS rates (0-7). + */ + u32 rate_set; }; static inline struct wl12xx_vif *wl12xx_vif_to_data(struct ieee80211_vif *vif) -- cgit v1.2.3 From d2d66c56cf6c8727662aa321991f791604c22094 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:43 +0200 Subject: wl12xx: move basic_rate into wlvif move basic_rate into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/acx.c | 8 +++--- drivers/net/wireless/wl12xx/acx.h | 2 +- drivers/net/wireless/wl12xx/cmd.c | 23 ++++++++++------- drivers/net/wireless/wl12xx/cmd.h | 8 +++--- drivers/net/wireless/wl12xx/debugfs.c | 1 - drivers/net/wireless/wl12xx/event.c | 21 +++++++++++----- drivers/net/wireless/wl12xx/init.c | 2 +- drivers/net/wireless/wl12xx/main.c | 47 ++++++++++++++++++++--------------- drivers/net/wireless/wl12xx/wl12xx.h | 8 +----- 9 files changed, 68 insertions(+), 52 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/acx.c b/drivers/net/wireless/wl12xx/acx.c index 1ef9b0b48635..015938f94805 100644 --- a/drivers/net/wireless/wl12xx/acx.c +++ b/drivers/net/wireless/wl12xx/acx.c @@ -755,11 +755,11 @@ int wl1271_acx_sta_rate_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif) } wl1271_debug(DEBUG_ACX, "basic_rate: 0x%x, full_rate: 0x%x", - wl->basic_rate, wlvif->rate_set); + wlvif->basic_rate, wlvif->rate_set); /* configure one basic rate class */ acx->rate_policy_idx = cpu_to_le32(ACX_TX_BASIC_RATE); - acx->rate_policy.enabled_rates = cpu_to_le32(wl->basic_rate); + acx->rate_policy.enabled_rates = cpu_to_le32(wlvif->basic_rate); acx->rate_policy.short_retry_limit = c->short_retry_limit; acx->rate_policy.long_retry_limit = c->long_retry_limit; acx->rate_policy.aflags = c->aflags; @@ -1567,7 +1567,7 @@ out: return ret; } -int wl1271_acx_config_ps(struct wl1271 *wl) +int wl12xx_acx_config_ps(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct wl1271_acx_config_ps *config_ps; int ret; @@ -1582,7 +1582,7 @@ int wl1271_acx_config_ps(struct wl1271 *wl) config_ps->exit_retries = wl->conf.conn.psm_exit_retries; config_ps->enter_retries = wl->conf.conn.psm_entry_retries; - config_ps->null_data_rate = cpu_to_le32(wl->basic_rate); + config_ps->null_data_rate = cpu_to_le32(wlvif->basic_rate); ret = wl1271_cmd_configure(wl, ACX_CONFIG_PS, config_ps, sizeof(*config_ps)); diff --git a/drivers/net/wireless/wl12xx/acx.h b/drivers/net/wireless/wl12xx/acx.h index 81779f45ab41..2678e1d505f9 100644 --- a/drivers/net/wireless/wl12xx/acx.h +++ b/drivers/net/wireless/wl12xx/acx.h @@ -1295,7 +1295,7 @@ int wl12xx_acx_set_ba_receiver_session(struct wl1271 *wl, u8 tid_index, int wl1271_acx_tsf_info(struct wl1271 *wl, u64 *mactime); int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, bool enable); int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl); -int wl1271_acx_config_ps(struct wl1271 *wl); +int wl12xx_acx_config_ps(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl1271_acx_set_inconnection_sta(struct wl1271 *wl, u8 *addr); int wl1271_acx_fm_coex(struct wl1271 *wl); int wl12xx_acx_set_rate_mgmt_params(struct wl1271 *wl); diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 6a2f758eb1d3..ce734157980a 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -1031,7 +1031,7 @@ out: return ret; } -int wl1271_cmd_build_null_data(struct wl1271 *wl) +int wl12xx_cmd_build_null_data(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct sk_buff *skb = NULL; int size; @@ -1043,7 +1043,8 @@ int wl1271_cmd_build_null_data(struct wl1271 *wl) size = sizeof(struct wl12xx_null_data_template); ptr = NULL; } else { - skb = ieee80211_nullfunc_get(wl->hw, wl->vif); + skb = ieee80211_nullfunc_get(wl->hw, + wl12xx_wlvif_to_vif(wlvif)); if (!skb) goto out; size = skb->len; @@ -1051,7 +1052,7 @@ int wl1271_cmd_build_null_data(struct wl1271 *wl) } ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, ptr, size, 0, - wl->basic_rate); + wlvif->basic_rate); out: dev_kfree_skb(skb); @@ -1062,19 +1063,21 @@ out: } -int wl1271_cmd_build_klv_null_data(struct wl1271 *wl) +int wl12xx_cmd_build_klv_null_data(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); struct sk_buff *skb = NULL; int ret = -ENOMEM; - skb = ieee80211_nullfunc_get(wl->hw, wl->vif); + skb = ieee80211_nullfunc_get(wl->hw, vif); if (!skb) goto out; ret = wl1271_cmd_template_set(wl, CMD_TEMPL_KLV, skb->data, skb->len, CMD_TEMPL_KLV_IDX_NULL_DATA, - wl->basic_rate); + wlvif->basic_rate); out: dev_kfree_skb(skb); @@ -1161,7 +1164,8 @@ out: return skb; } -int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, __be32 ip_addr) +int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, struct wl12xx_vif *wlvif, + __be32 ip_addr) { int ret; struct wl12xx_arp_rsp_template tmpl; @@ -1197,13 +1201,14 @@ int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, __be32 ip_addr) ret = wl1271_cmd_template_set(wl, CMD_TEMPL_ARP_RSP, &tmpl, sizeof(tmpl), 0, - wl->basic_rate); + wlvif->basic_rate); return ret; } int wl1271_build_qos_null_data(struct wl1271 *wl, struct ieee80211_vif *vif) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct ieee80211_qos_hdr template; memset(&template, 0, sizeof(template)); @@ -1221,7 +1226,7 @@ int wl1271_build_qos_null_data(struct wl1271 *wl, struct ieee80211_vif *vif) return wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, &template, sizeof(template), 0, - wl->basic_rate); + wlvif->basic_rate); } int wl12xx_cmd_set_default_wep_key(struct wl1271 *wl, u8 id, u8 hlid) diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index 234a8dc90559..d5749f5b3bf1 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -55,7 +55,7 @@ int wl1271_cmd_read_memory(struct wl1271 *wl, u32 addr, void *answer, size_t len); int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id, void *buf, size_t buf_len, int index, u32 rates); -int wl1271_cmd_build_null_data(struct wl1271 *wl); +int wl12xx_cmd_build_null_data(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl1271_cmd_build_ps_poll(struct wl1271 *wl, struct wl12xx_vif *wlvif, u16 aid); int wl1271_cmd_build_probe_req(struct wl1271 *wl, @@ -63,9 +63,11 @@ int wl1271_cmd_build_probe_req(struct wl1271 *wl, const u8 *ie, size_t ie_len, u8 band); struct sk_buff *wl1271_cmd_build_ap_probe_req(struct wl1271 *wl, struct sk_buff *skb); -int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, __be32 ip_addr); +int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, struct wl12xx_vif *wlvif, + __be32 ip_addr); int wl1271_build_qos_null_data(struct wl1271 *wl, struct ieee80211_vif *vif); -int wl1271_cmd_build_klv_null_data(struct wl1271 *wl); +int wl12xx_cmd_build_klv_null_data(struct wl1271 *wl, + struct wl12xx_vif *wlvif); int wl12xx_cmd_set_default_wep_key(struct wl1271 *wl, u8 id, u8 hlid); int wl1271_cmd_set_sta_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, u8 key_size, const u8 *key, const u8 *addr, diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index e63fea4b120d..620acbfd9ec3 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -352,7 +352,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, DRIVER_STATE_PRINT_INT(state); DRIVER_STATE_PRINT_INT(bss_type); DRIVER_STATE_PRINT_INT(channel); - DRIVER_STATE_PRINT_HEX(basic_rate); DRIVER_STATE_PRINT_INT(band); DRIVER_STATE_PRINT_INT(beacon_int); DRIVER_STATE_PRINT_INT(psm_entry_retry); diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index 7e3ff808feef..af4cef366a3e 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -31,12 +31,16 @@ void wl1271_pspoll_work(struct work_struct *work) { + struct ieee80211_vif *vif; + struct wl12xx_vif *wlvif; struct delayed_work *dwork; struct wl1271 *wl; int ret; dwork = container_of(work, struct delayed_work, work); wl = container_of(dwork, struct wl1271, pspoll_work); + vif = wl->vif; /* TODO: move work into vif struct */ + wlvif = wl12xx_vif_to_data(vif); wl1271_debug(DEBUG_EVENT, "pspoll work"); @@ -60,14 +64,16 @@ void wl1271_pspoll_work(struct work_struct *work) if (ret < 0) goto out; - wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE, wl->basic_rate, true); + wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE, wlvif->basic_rate, + true); wl1271_ps_elp_sleep(wl); out: mutex_unlock(&wl->mutex); }; -static void wl1271_event_pspoll_delivery_fail(struct wl1271 *wl) +static void wl1271_event_pspoll_delivery_fail(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { int delay = wl->conf.conn.ps_poll_recovery_period; int ret; @@ -80,7 +86,7 @@ static void wl1271_event_pspoll_delivery_fail(struct wl1271 *wl) /* force active mode receive data from the AP */ if (test_bit(WL1271_FLAG_PSM, &wl->flags)) { ret = wl1271_ps_set_mode(wl, STATION_ACTIVE_MODE, - wl->basic_rate, true); + wlvif->basic_rate, true); if (ret < 0) return; set_bit(WL1271_FLAG_PSPOLL_FAILURE, &wl->flags); @@ -97,6 +103,7 @@ static void wl1271_event_pspoll_delivery_fail(struct wl1271 *wl) } static int wl1271_event_ps_report(struct wl1271 *wl, + struct wl12xx_vif *wlvif, struct event_mailbox *mbox, bool *beacon_loss) { @@ -118,7 +125,7 @@ static int wl1271_event_ps_report(struct wl1271 *wl, if (wl->psm_entry_retry < total_retries) { wl->psm_entry_retry++; ret = wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE, - wl->basic_rate, true); + wlvif->basic_rate, true); } else { wl1271_info("No ack to nullfunc from AP."); wl->psm_entry_retry = 0; @@ -217,6 +224,8 @@ static void wl1271_event_mbox_dump(struct event_mailbox *mbox) static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) { + struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret; u32 vector; bool beacon_loss = false; @@ -276,13 +285,13 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) if ((vector & PS_REPORT_EVENT_ID) && !is_ap) { wl1271_debug(DEBUG_EVENT, "PS_REPORT_EVENT"); - ret = wl1271_event_ps_report(wl, mbox, &beacon_loss); + ret = wl1271_event_ps_report(wl, wlvif, mbox, &beacon_loss); if (ret < 0) return ret; } if ((vector & PSPOLL_DELIVERY_FAILURE_EVENT_ID) && !is_ap) - wl1271_event_pspoll_delivery_fail(wl); + wl1271_event_pspoll_delivery_fail(wl, wlvif); if (vector & RSSI_SNR_TRIGGER_0_EVENT_ID) { wl1271_debug(DEBUG_EVENT, "RSSI_SNR_TRIGGER_0_EVENT"); diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index 37955dad1f93..ed27c5f06bb2 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -331,7 +331,7 @@ static int wl1271_sta_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif) } /* PS config */ - ret = wl1271_acx_config_ps(wl); + ret = wl12xx_acx_config_ps(wl, wlvif); if (ret < 0) return ret; diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 195dcbdf1fc7..8863ea542ea6 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1609,7 +1609,8 @@ static struct notifier_block wl1271_dev_notifier = { }; #ifdef CONFIG_PM -static int wl1271_configure_suspend_sta(struct wl1271 *wl) +static int wl1271_configure_suspend_sta(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { int ret = 0; @@ -1628,7 +1629,7 @@ static int wl1271_configure_suspend_sta(struct wl1271 *wl) wl->ps_compl = &compl; ret = wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE, - wl->basic_rate, true); + wlvif->basic_rate, true); if (ret < 0) goto out_sleep; @@ -1682,16 +1683,18 @@ out_unlock: } -static int wl1271_configure_suspend(struct wl1271 *wl) +static int wl1271_configure_suspend(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { if (wl->bss_type == BSS_TYPE_STA_BSS) - return wl1271_configure_suspend_sta(wl); + return wl1271_configure_suspend_sta(wl, wlvif); if (wl->bss_type == BSS_TYPE_AP_BSS) return wl1271_configure_suspend_ap(wl); return 0; } -static void wl1271_configure_resume(struct wl1271 *wl) +static void wl1271_configure_resume(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { int ret; bool is_sta = wl->bss_type == BSS_TYPE_STA_BSS; @@ -1709,7 +1712,7 @@ static void wl1271_configure_resume(struct wl1271 *wl) /* exit psm if it wasn't configured */ if (!test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags)) wl1271_ps_set_mode(wl, STATION_ACTIVE_MODE, - wl->basic_rate, true); + wlvif->basic_rate, true); } else if (is_ap) { wl1271_acx_beacon_filter_opt(wl, false); } @@ -1723,13 +1726,15 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wow) { struct wl1271 *wl = hw->priv; + struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret; wl1271_debug(DEBUG_MAC80211, "mac80211 suspend wow=%d", !!wow); WARN_ON(!wow || !wow->any); wl->wow_enabled = true; - ret = wl1271_configure_suspend(wl); + ret = wl1271_configure_suspend(wl, wlvif); if (ret < 0) { wl1271_warning("couldn't prepare device to suspend"); return ret; @@ -1760,6 +1765,8 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw, static int wl1271_op_resume(struct ieee80211_hw *hw) { struct wl1271 *wl = hw->priv; + struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); unsigned long flags; bool run_irq_work = false; @@ -1783,7 +1790,7 @@ static int wl1271_op_resume(struct ieee80211_hw *hw) wl1271_irq(0, wl); wl1271_enable_interrupts(wl); } - wl1271_configure_resume(wl); + wl1271_configure_resume(wl, wlvif); wl->wow_enabled = false; return 0; @@ -1840,6 +1847,7 @@ static u8 wl12xx_get_role_type(struct wl1271 *wl) static void wl12xx_init_vif_data(struct wl12xx_vif *wlvif) { wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC; + wlvif->basic_rate = CONF_TX_RATE_MASK_BASIC; wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; } @@ -2214,7 +2222,7 @@ static int wl1271_join(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (ret < 0) goto out; - ret = wl1271_cmd_build_klv_null_data(wl); + ret = wl12xx_cmd_build_klv_null_data(wl, wlvif); if (ret < 0) goto out; @@ -2384,7 +2392,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) if (!test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) wl1271_set_band_rate(wl, wlvif); - wl->basic_rate = + wlvif->basic_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); ret = wl1271_acx_sta_rate_policies(wl, wlvif); @@ -2450,7 +2458,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) { wl1271_debug(DEBUG_PSM, "psm enabled"); ret = wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE, - wl->basic_rate, true); + wlvif->basic_rate, true); } } else if (!(conf->flags & IEEE80211_CONF_PS) && test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags)) { @@ -2460,7 +2468,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) if (test_bit(WL1271_FLAG_PSM, &wl->flags)) ret = wl1271_ps_set_mode(wl, STATION_ACTIVE_MODE, - wl->basic_rate, true); + wlvif->basic_rate, true); } if (conf->power_level != wl->power_level) { @@ -3311,7 +3319,7 @@ static void wl1271_bss_info_changed_ap(struct wl1271 *wl, wlvif->basic_rate_set = wl1271_tx_enabled_rates_get(wl, rates, wl->band); - wl->basic_rate = wl1271_tx_min_rate_get(wl, + wlvif->basic_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); ret = wl1271_init_ap_rates(wl, wlvif); @@ -3450,7 +3458,7 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, memcpy(wl->bssid, bss_conf->bssid, ETH_ALEN); if (!is_zero_ether_addr(wl->bssid)) { - ret = wl1271_cmd_build_null_data(wl); + ret = wl12xx_cmd_build_null_data(wl, wlvif); if (ret < 0) goto out; @@ -3498,7 +3506,7 @@ sta_not_found: wlvif->basic_rate_set = wl1271_tx_enabled_rates_get(wl, rates, wl->band); - wl->basic_rate = + wlvif->basic_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); if (sta_rate_set) @@ -3552,7 +3560,7 @@ sta_not_found: /* revert back to minimum rates for the current band */ wl1271_set_band_rate(wl, wlvif); - wl->basic_rate = + wlvif->basic_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); ret = wl1271_acx_sta_rate_policies(wl, wlvif); @@ -3608,7 +3616,7 @@ sta_not_found: wlvif->basic_rate_set = wl1271_tx_enabled_rates_get(wl, rates, wl->band); - wl->basic_rate = + wlvif->basic_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); @@ -3636,7 +3644,7 @@ sta_not_found: * isn't being set (when sending), so we have to * reconfigure the template upon every ip change. */ - ret = wl1271_cmd_build_arp_rsp(wl, addr); + ret = wl1271_cmd_build_arp_rsp(wl, wlvif, addr); if (ret < 0) { wl1271_warning("build arp rsp failed: %d", ret); goto out; @@ -3689,7 +3697,7 @@ sta_not_found: mode = STATION_POWER_SAVE_MODE; ret = wl1271_ps_set_mode(wl, mode, - wl->basic_rate, + wlvif->basic_rate, true); if (ret < 0) goto out; @@ -4844,7 +4852,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->rx_counter = 0; wl->psm_entry_retry = 0; wl->power_level = WL1271_DEFAULT_POWER_LEVEL; - wl->basic_rate = CONF_TX_RATE_MASK_BASIC; wl->band = IEEE80211_BAND_2GHZ; wl->vif = NULL; wl->flags = 0; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 6f3efbae740e..d355c737044b 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -519,13 +519,6 @@ struct wl1271 { /* Our association ID */ u16 aid; - /* - * currently configured rate set: - * bits 0-15 - 802.11abg rates - * bits 16-23 - 802.11n MCS index mask - * support only 1 stream, thus only 8 bits for the MCS rates (0-7). - */ - u32 basic_rate; u32 bitrate_masks[IEEE80211_NUM_BANDS]; /* The current band */ @@ -646,6 +639,7 @@ struct wl12xx_vif { * bits 16-23 - 802.11n MCS index mask * support only 1 stream, thus only 8 bits for the MCS rates (0-7). */ + u32 basic_rate; u32 rate_set; }; -- cgit v1.2.3 From cdf09495588fda7e9c15c25bc20cb828e07be314 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:44 +0200 Subject: wl12xx: replace wl->bssid with vif->bss_conf.bssid Use the per-interface vif->bss_conf instead of the global wl->bssid. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 13 ++++++++----- drivers/net/wireless/wl12xx/event.c | 2 +- drivers/net/wireless/wl12xx/main.c | 15 ++------------- drivers/net/wireless/wl12xx/wl12xx.h | 1 - 4 files changed, 11 insertions(+), 20 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index ce734157980a..b9bb76b22f58 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -557,6 +557,7 @@ out: int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) { + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); struct wl12xx_cmd_role_start *cmd; int ret; @@ -577,7 +578,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->sta.ssid_type = WL12XX_SSID_TYPE_ANY; cmd->sta.ssid_len = wl->ssid_len; memcpy(cmd->sta.ssid, wl->ssid, wl->ssid_len); - memcpy(cmd->sta.bssid, wl->bssid, ETH_ALEN); + memcpy(cmd->sta.bssid, vif->bss_conf.bssid, ETH_ALEN); cmd->sta.local_rates = cpu_to_le32(wlvif->rate_set); if (wl->sta_hlid == WL12XX_INVALID_LINK_ID) { @@ -769,6 +770,7 @@ out: int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) { + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); struct wl12xx_cmd_role_start *cmd; struct ieee80211_bss_conf *bss_conf = &wl->vif->bss_conf; int ret; @@ -791,7 +793,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->ibss.ssid_type = WL12XX_SSID_TYPE_ANY; cmd->ibss.ssid_len = wl->ssid_len; memcpy(cmd->ibss.ssid, wl->ssid, wl->ssid_len); - memcpy(cmd->ibss.bssid, wl->bssid, ETH_ALEN); + memcpy(cmd->ibss.bssid, vif->bss_conf.bssid, ETH_ALEN); cmd->sta.local_rates = cpu_to_le32(wlvif->rate_set); if (wl->sta_hlid == WL12XX_INVALID_LINK_ID) { @@ -807,7 +809,8 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) wl->role_id, cmd->sta.hlid, cmd->sta.session, wlvif->basic_rate_set, wlvif->rate_set); - wl1271_debug(DEBUG_CMD, "wl->bssid = %pM", wl->bssid); + wl1271_debug(DEBUG_CMD, "vif->bss_conf.bssid = %pM", + vif->bss_conf.bssid); ret = wl1271_cmd_send(wl, CMD_ROLE_START, cmd, sizeof(*cmd), 0); if (ret < 0) { @@ -1213,9 +1216,9 @@ int wl1271_build_qos_null_data(struct wl1271 *wl, struct ieee80211_vif *vif) memset(&template, 0, sizeof(template)); - memcpy(template.addr1, wl->bssid, ETH_ALEN); + memcpy(template.addr1, vif->bss_conf.bssid, ETH_ALEN); memcpy(template.addr2, vif->addr, ETH_ALEN); - memcpy(template.addr3, wl->bssid, ETH_ALEN); + memcpy(template.addr3, vif->bss_conf.bssid, ETH_ALEN); template.frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_NULLFUNC | diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index af4cef366a3e..30d05fd24672 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -184,7 +184,7 @@ static void wl1271_stop_ba_event(struct wl1271 *wl) if (!wl->ba_rx_bitmap) return; ieee80211_stop_rx_ba_session(wl->vif, wl->ba_rx_bitmap, - wl->bssid); + wl->vif->bss_conf.bssid); } else { int i; struct wl1271_link *lnk; diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 8863ea542ea6..d19c3fe34860 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2098,7 +2098,6 @@ deinit: wl1271_tx_reset(wl, reset_tx_queues); wl1271_power_off(wl); - memset(wl->bssid, 0, ETH_ALEN); memset(wl->ssid, 0, IEEE80211_MAX_SSID_LEN + 1); wl->ssid_len = 0; wl->bss_type = MAX_BSS_TYPE; @@ -2249,8 +2248,6 @@ static int wl1271_unjoin(struct wl1271 *wl) if (ret < 0) goto out; - memset(wl->bssid, 0, ETH_ALEN); - /* reset TX security counters on a clean disconnect */ wl->tx_security_last_seq_lsb = 0; wl->tx_security_seq = 0; @@ -3449,15 +3446,8 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, wl->rssi_thold = bss_conf->cqm_rssi_thold; } - if ((changed & BSS_CHANGED_BSSID) && - /* - * Now we know the correct bssid, so we send a new join command - * and enable the BSSID filter - */ - memcmp(wl->bssid, bss_conf->bssid, ETH_ALEN)) { - memcpy(wl->bssid, bss_conf->bssid, ETH_ALEN); - - if (!is_zero_ether_addr(wl->bssid)) { + if (changed & BSS_CHANGED_BSSID) + if (!is_zero_ether_addr(bss_conf->bssid)) { ret = wl12xx_cmd_build_null_data(wl, wlvif); if (ret < 0) goto out; @@ -3469,7 +3459,6 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, /* Need to update the BSSID (for filtering etc) */ do_join = true; } - } if (changed & (BSS_CHANGED_ASSOC | BSS_CHANGED_HT)) { rcu_read_lock(); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index d355c737044b..44a5daeff07e 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -399,7 +399,6 @@ struct wl1271 { s8 hw_pg_ver; - u8 bssid[ETH_ALEN]; u8 mac_addr[ETH_ALEN]; u8 bss_type; u8 set_bss_type; -- cgit v1.2.3 From 536129c8ad35de87ff2f864f205a54ac32bfebcc Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:45 +0200 Subject: wl12xx: move bss_type into wlvif move bss_type into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 2 +- drivers/net/wireless/wl12xx/debugfs.c | 1 - drivers/net/wireless/wl12xx/event.c | 10 ++-- drivers/net/wireless/wl12xx/init.c | 10 ++-- drivers/net/wireless/wl12xx/main.c | 109 +++++++++++++++++++--------------- drivers/net/wireless/wl12xx/rx.c | 4 +- drivers/net/wireless/wl12xx/scan.c | 12 ++-- drivers/net/wireless/wl12xx/scan.h | 3 +- drivers/net/wireless/wl12xx/tx.c | 86 +++++++++++++++++---------- drivers/net/wireless/wl12xx/tx.h | 2 +- drivers/net/wireless/wl12xx/wl12xx.h | 3 +- 11 files changed, 141 insertions(+), 101 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index b9bb76b22f58..096a713a8c94 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -1042,7 +1042,7 @@ int wl12xx_cmd_build_null_data(struct wl1271 *wl, struct wl12xx_vif *wlvif) int ret = -ENOMEM; - if (wl->bss_type == BSS_TYPE_IBSS) { + if (wlvif->bss_type == BSS_TYPE_IBSS) { size = sizeof(struct wl12xx_null_data_template); ptr = NULL; } else { diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 620acbfd9ec3..8f88ad6496f9 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -350,7 +350,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, DRIVER_STATE_PRINT_INT(rx_counter); DRIVER_STATE_PRINT_INT(session_counter); DRIVER_STATE_PRINT_INT(state); - DRIVER_STATE_PRINT_INT(bss_type); DRIVER_STATE_PRINT_INT(channel); DRIVER_STATE_PRINT_INT(band); DRIVER_STATE_PRINT_INT(beacon_int); diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index 30d05fd24672..072addc0bffc 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -178,9 +178,9 @@ static void wl1271_event_rssi_trigger(struct wl1271 *wl, wl->last_rssi_event = event; } -static void wl1271_stop_ba_event(struct wl1271 *wl) +static void wl1271_stop_ba_event(struct wl1271 *wl, struct wl12xx_vif *wlvif) { - if (wl->bss_type != BSS_TYPE_AP_BSS) { + if (wlvif->bss_type != BSS_TYPE_AP_BSS) { if (!wl->ba_rx_bitmap) return; ieee80211_stop_rx_ba_session(wl->vif, wl->ba_rx_bitmap, @@ -229,7 +229,7 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) int ret; u32 vector; bool beacon_loss = false; - bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); + bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); bool disconnect_sta = false; unsigned long sta_bitmap = 0; @@ -263,7 +263,7 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) } if (vector & SOFT_GEMINI_SENSE_EVENT_ID && - wl->bss_type == BSS_TYPE_STA_BSS) + wlvif->bss_type == BSS_TYPE_STA_BSS) wl12xx_event_soft_gemini_sense(wl, mbox->soft_gemini_sense_info); @@ -306,7 +306,7 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) wl->ba_allowed = !!mbox->rx_ba_allowed; if (wl->vif && !wl->ba_allowed) - wl1271_stop_ba_event(wl); + wl1271_stop_ba_event(wl, wlvif); } if ((vector & CHANNEL_SWITCH_COMPLETE_EVENT_ID) && !is_ap) { diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index ed27c5f06bb2..e54cc693ff69 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -478,7 +478,7 @@ int wl1271_init_ap_rates(struct wl1271 *wl, struct wl12xx_vif *wlvif) return 0; } -static int wl1271_set_ba_policies(struct wl1271 *wl) +static int wl1271_set_ba_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif) { /* Reset the BA RX indicators */ wl->ba_rx_bitmap = 0; @@ -486,8 +486,8 @@ static int wl1271_set_ba_policies(struct wl1271 *wl) wl->ba_rx_session_count = 0; /* BA is supported in STA/AP modes */ - if (wl->bss_type != BSS_TYPE_AP_BSS && - wl->bss_type != BSS_TYPE_STA_BSS) { + if (wlvif->bss_type != BSS_TYPE_AP_BSS && + wlvif->bss_type != BSS_TYPE_STA_BSS) { wl->ba_support = false; return 0; } @@ -572,7 +572,7 @@ int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct conf_tx_ac_category *conf_ac; struct conf_tx_tid *conf_tid; - bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); + bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); int ret, i; @@ -635,7 +635,7 @@ int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) return ret; /* Configure initiator BA sessions policies */ - ret = wl1271_set_ba_policies(wl); + ret = wl1271_set_ba_policies(wl, wlvif); if (ret < 0) return ret; diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index d19c3fe34860..5b13af0f8e8e 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -377,6 +377,7 @@ static char *fwlog_param; static bool bug_on_recovery; static void __wl1271_op_remove_interface(struct wl1271 *wl, + struct ieee80211_vif *vif, bool reset_tx_queues); static void wl1271_free_ap_keys(struct wl1271 *wl); @@ -844,6 +845,8 @@ static void wl12xx_irq_update_links_status(struct wl1271 *wl, static void wl12xx_fw_status(struct wl1271 *wl, struct wl12xx_fw_status *status) { + struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct timespec ts; u32 old_tx_blk_count = wl->tx_blocks_available; int avail, freed_blocks; @@ -898,7 +901,7 @@ static void wl12xx_fw_status(struct wl1271 *wl, clear_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags); /* for AP update num of allocated TX blocks per link and ps status */ - if (wl->bss_type == BSS_TYPE_AP_BSS) + if (wlvif->bss_type == BSS_TYPE_AP_BSS) wl12xx_irq_update_links_status(wl, status); /* update the host-chipset time offset */ @@ -1004,7 +1007,7 @@ irqreturn_t wl1271_irq(int irq, void *cookie) * In order to avoid starvation of the TX path, * call the work function directly. */ - wl1271_tx_work_locked(wl); + wl1271_tx_work_locked(wl, wl->vif); } else { spin_unlock_irqrestore(&wl->wl_lock, flags); } @@ -1251,7 +1254,7 @@ static void wl1271_recovery_work(struct work_struct *work) } /* reboot the chipset */ - __wl1271_op_remove_interface(wl, false); + __wl1271_op_remove_interface(wl, wl->vif, false); clear_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags); @@ -1389,8 +1392,6 @@ int wl1271_plt_start(struct wl1271 *wl) goto out; } - wl->bss_type = BSS_TYPE_STA_BSS; - while (retries) { retries--; ret = wl1271_chip_wakeup(wl); @@ -1482,6 +1483,8 @@ int wl1271_plt_stop(struct wl1271 *wl) static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { struct wl1271 *wl = hw->priv; + struct ieee80211_tx_info *control = IEEE80211_SKB_CB(skb); + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(control->control.vif); unsigned long flags; int q, mapping; u8 hlid = 0; @@ -1489,13 +1492,13 @@ static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) mapping = skb_get_queue_mapping(skb); q = wl1271_tx_get_queue(mapping); - if (wl->bss_type == BSS_TYPE_AP_BSS) + if (wlvif->bss_type == BSS_TYPE_AP_BSS) hlid = wl12xx_tx_get_hlid_ap(wl, skb); spin_lock_irqsave(&wl->wl_lock, flags); /* queue the packet */ - if (wl->bss_type == BSS_TYPE_AP_BSS) { + if (wlvif->bss_type == BSS_TYPE_AP_BSS) { if (!wl1271_is_active_sta(wl, hlid)) { wl1271_debug(DEBUG_TX, "DROP skb hlid %d q %d", hlid, q); @@ -1552,7 +1555,7 @@ int wl1271_tx_dummy_packet(struct wl1271 *wl) /* The FW is low on RX memory blocks, so send the dummy packet asap */ if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags)) - wl1271_tx_work_locked(wl); + wl1271_tx_work_locked(wl, wl->vif); /* * If the FW TX is busy, TX work will be scheduled by the threaded @@ -1686,9 +1689,9 @@ out_unlock: static int wl1271_configure_suspend(struct wl1271 *wl, struct wl12xx_vif *wlvif) { - if (wl->bss_type == BSS_TYPE_STA_BSS) + if (wlvif->bss_type == BSS_TYPE_STA_BSS) return wl1271_configure_suspend_sta(wl, wlvif); - if (wl->bss_type == BSS_TYPE_AP_BSS) + if (wlvif->bss_type == BSS_TYPE_AP_BSS) return wl1271_configure_suspend_ap(wl); return 0; } @@ -1697,8 +1700,8 @@ static void wl1271_configure_resume(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int ret; - bool is_sta = wl->bss_type == BSS_TYPE_STA_BSS; - bool is_ap = wl->bss_type == BSS_TYPE_AP_BSS; + bool is_sta = wlvif->bss_type == BSS_TYPE_STA_BSS; + bool is_ap = wlvif->bss_type == BSS_TYPE_AP_BSS; if (!is_sta && !is_ap) return; @@ -1820,9 +1823,9 @@ static void wl1271_op_stop(struct ieee80211_hw *hw) wl1271_debug(DEBUG_MAC80211, "mac80211 stop"); } -static u8 wl12xx_get_role_type(struct wl1271 *wl) +static u8 wl12xx_get_role_type(struct wl1271 *wl, struct wl12xx_vif *wlvif) { - switch (wl->bss_type) { + switch (wlvif->bss_type) { case BSS_TYPE_AP_BSS: if (wl->p2p) return WL1271_ROLE_P2P_GO; @@ -1839,13 +1842,14 @@ static u8 wl12xx_get_role_type(struct wl1271 *wl) return WL1271_ROLE_IBSS; default: - wl1271_error("invalid bss_type: %d", wl->bss_type); + wl1271_error("invalid bss_type: %d", wlvif->bss_type); } return WL12XX_INVALID_ROLE_TYPE; } static void wl12xx_init_vif_data(struct wl12xx_vif *wlvif) { + wlvif->bss_type = MAX_BSS_TYPE; wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC; wlvif->basic_rate = CONF_TX_RATE_MASK_BASIC; wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; @@ -1856,6 +1860,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, { struct wl1271 *wl = hw->priv; struct wiphy *wiphy = hw->wiphy; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int retries = WL1271_BOOT_RETRIES; int ret = 0; u8 role_type; @@ -1871,7 +1876,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, ret = -EBUSY; goto out; } - wl12xx_init_vif_data(wl12xx_vif_to_data(vif)); + wl12xx_init_vif_data(wlvif); /* * in some very corner case HW recovery scenarios its possible to @@ -1888,25 +1893,25 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, wl->p2p = 1; /* fall-through */ case NL80211_IFTYPE_STATION: - wl->bss_type = BSS_TYPE_STA_BSS; + wlvif->bss_type = BSS_TYPE_STA_BSS; wl->set_bss_type = BSS_TYPE_STA_BSS; break; case NL80211_IFTYPE_ADHOC: - wl->bss_type = BSS_TYPE_IBSS; + wlvif->bss_type = BSS_TYPE_IBSS; wl->set_bss_type = BSS_TYPE_STA_BSS; break; case NL80211_IFTYPE_P2P_GO: wl->p2p = 1; /* fall-through */ case NL80211_IFTYPE_AP: - wl->bss_type = BSS_TYPE_AP_BSS; + wlvif->bss_type = BSS_TYPE_AP_BSS; break; default: ret = -EOPNOTSUPP; goto out; } - role_type = wl12xx_get_role_type(wl); + role_type = wl12xx_get_role_type(wl, wlvif); if (role_type == WL12XX_INVALID_ROLE_TYPE) { ret = -EINVAL; goto out; @@ -1938,8 +1943,8 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, if (ret < 0) goto irq_disable; - if (wl->bss_type == BSS_TYPE_STA_BSS || - wl->bss_type == BSS_TYPE_IBSS) { + if (wlvif->bss_type == BSS_TYPE_STA_BSS || + wlvif->bss_type == BSS_TYPE_IBSS) { /* * The device role is a special role used for * rx and tx frames prior to association (as @@ -2020,8 +2025,10 @@ out: } static void __wl1271_op_remove_interface(struct wl1271 *wl, + struct ieee80211_vif *vif, bool reset_tx_queues) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret, i; wl1271_debug(DEBUG_MAC80211, "mac80211 remove interface"); @@ -2037,7 +2044,7 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, mutex_unlock(&wl_list_mutex); /* enable dyn ps just in case (if left on due to fw crash etc) */ - if (wl->bss_type == BSS_TYPE_STA_BSS) + if (wlvif->bss_type == BSS_TYPE_STA_BSS) ieee80211_enable_dyn_ps(wl->vif); if (wl->scan.state != WL1271_SCAN_STATE_IDLE) { @@ -2054,7 +2061,7 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, if (ret < 0) goto deinit; - if (wl->bss_type == BSS_TYPE_STA_BSS) { + if (wlvif->bss_type == BSS_TYPE_STA_BSS) { ret = wl12xx_cmd_role_disable(wl, &wl->dev_role_id); if (ret < 0) goto deinit; @@ -2100,7 +2107,6 @@ deinit: memset(wl->ssid, 0, IEEE80211_MAX_SSID_LEN + 1); wl->ssid_len = 0; - wl->bss_type = MAX_BSS_TYPE; wl->set_bss_type = MAX_BSS_TYPE; wl->p2p = 0; wl->band = IEEE80211_BAND_2GHZ; @@ -2169,7 +2175,7 @@ static void wl1271_op_remove_interface(struct ieee80211_hw *hw, */ if (wl->vif) { WARN_ON(wl->vif != vif); - __wl1271_op_remove_interface(wl, true); + __wl1271_op_remove_interface(wl, vif, true); } mutex_unlock(&wl->mutex); @@ -2180,7 +2186,7 @@ static int wl1271_join(struct wl1271 *wl, struct wl12xx_vif *wlvif, bool set_assoc) { int ret; - bool is_ibss = (wl->bss_type == BSS_TYPE_IBSS); + bool is_ibss = (wlvif->bss_type == BSS_TYPE_IBSS); /* * One of the side effects of the JOIN command is that is clears @@ -2364,7 +2370,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) goto out; } - is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); + is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); ret = wl1271_ps_elp_wakeup(wl); if (ret < 0) @@ -2375,7 +2381,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) ((wl->band != conf->channel->band) || (wl->channel != channel))) { /* send all pending packets */ - wl1271_tx_work_locked(wl); + wl1271_tx_work_locked(wl, vif); wl->band = conf->channel->band; wl->channel = channel; @@ -2536,6 +2542,9 @@ static void wl1271_op_configure_filter(struct ieee80211_hw *hw, { struct wl1271_filter_params *fp = (void *)(unsigned long)multicast; struct wl1271 *wl = hw->priv; + struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + int ret; wl1271_debug(DEBUG_MAC80211, "mac80211 configure filter changed %x" @@ -2553,7 +2562,7 @@ static void wl1271_op_configure_filter(struct ieee80211_hw *hw, if (ret < 0) goto out; - if (wl->bss_type != BSS_TYPE_AP_BSS) { + if (wlvif->bss_type != BSS_TYPE_AP_BSS) { if (*total & FIF_ALLMULTI) ret = wl1271_acx_group_address_tbl(wl, false, NULL, 0); else if (fp) @@ -2673,12 +2682,13 @@ out: return ret; } -static int wl1271_set_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, +static int wl1271_set_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u16 action, u8 id, u8 key_type, u8 key_size, const u8 *key, u32 tx_seq_32, u16 tx_seq_16, struct ieee80211_sta *sta) { int ret; - bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); + bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); if (is_ap) { struct wl1271_station *wl_sta; @@ -2774,6 +2784,7 @@ static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, struct ieee80211_key_conf *key_conf) { struct wl1271 *wl = hw->priv; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret; u32 tx_seq_32 = 0; u16 tx_seq_16 = 0; @@ -2833,7 +2844,7 @@ static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, switch (cmd) { case SET_KEY: - ret = wl1271_set_key(wl, KEY_ADD_OR_REPLACE, + ret = wl1271_set_key(wl, wlvif, KEY_ADD_OR_REPLACE, key_conf->keyidx, key_type, key_conf->keylen, key_conf->key, tx_seq_32, tx_seq_16, sta); @@ -2844,7 +2855,7 @@ static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, break; case DISABLE_KEY: - ret = wl1271_set_key(wl, KEY_REMOVE, + ret = wl1271_set_key(wl, wlvif, KEY_REMOVE, key_conf->keyidx, key_type, key_conf->keylen, key_conf->key, 0, 0, sta); @@ -2966,6 +2977,7 @@ static int wl1271_op_sched_scan_start(struct ieee80211_hw *hw, struct ieee80211_sched_scan_ies *ies) { struct wl1271 *wl = hw->priv; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret; wl1271_debug(DEBUG_MAC80211, "wl1271_op_sched_scan_start"); @@ -2976,11 +2988,11 @@ static int wl1271_op_sched_scan_start(struct ieee80211_hw *hw, if (ret < 0) goto out; - ret = wl1271_scan_sched_scan_config(wl, req, ies); + ret = wl1271_scan_sched_scan_config(wl, wlvif, req, ies); if (ret < 0) goto out_sleep; - ret = wl1271_scan_sched_scan_start(wl); + ret = wl1271_scan_sched_scan_start(wl, wlvif); if (ret < 0) goto out_sleep; @@ -3225,7 +3237,7 @@ static int wl1271_bss_beacon_info_changed(struct wl1271 *wl, u32 changed) { struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); - bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); + bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); int ret = 0; if ((changed & BSS_CHANGED_BEACON_INT)) { @@ -3387,7 +3399,7 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, { struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); bool do_join = false, set_assoc = false; - bool is_ibss = (wl->bss_type == BSS_TYPE_IBSS); + bool is_ibss = (wlvif->bss_type == BSS_TYPE_IBSS); bool ibss_joined = false; u32 sta_rate_set = 0; int ret; @@ -3623,7 +3635,7 @@ sta_not_found: if (changed & BSS_CHANGED_ARP_FILTER) { __be32 addr = bss_conf->arp_addr_list[0]; - WARN_ON(wl->bss_type != BSS_TYPE_STA_BSS); + WARN_ON(wlvif->bss_type != BSS_TYPE_STA_BSS); if (bss_conf->arp_addr_cnt == 1 && bss_conf->arp_filter_enabled) { @@ -3742,7 +3754,8 @@ static void wl1271_op_bss_info_changed(struct ieee80211_hw *hw, u32 changed) { struct wl1271 *wl = hw->priv; - bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); int ret; wl1271_debug(DEBUG_MAC80211, "mac80211 bss info changed 0x%x", @@ -3933,6 +3946,7 @@ static int wl1271_op_sta_add(struct ieee80211_hw *hw, struct ieee80211_sta *sta) { struct wl1271 *wl = hw->priv; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret = 0; u8 hlid; @@ -3941,7 +3955,7 @@ static int wl1271_op_sta_add(struct ieee80211_hw *hw, if (unlikely(wl->state == WL1271_STATE_OFF)) goto out; - if (wl->bss_type != BSS_TYPE_AP_BSS) + if (wlvif->bss_type != BSS_TYPE_AP_BSS) goto out; wl1271_debug(DEBUG_MAC80211, "mac80211 add sta %d", (int)sta->aid); @@ -3983,6 +3997,7 @@ static int wl1271_op_sta_remove(struct ieee80211_hw *hw, struct ieee80211_sta *sta) { struct wl1271 *wl = hw->priv; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct wl1271_station *wl_sta; int ret = 0, id; @@ -3991,7 +4006,7 @@ static int wl1271_op_sta_remove(struct ieee80211_hw *hw, if (unlikely(wl->state == WL1271_STATE_OFF)) goto out; - if (wl->bss_type != BSS_TYPE_AP_BSS) + if (wlvif->bss_type != BSS_TYPE_AP_BSS) goto out; wl1271_debug(DEBUG_MAC80211, "mac80211 remove sta %d", (int)sta->aid); @@ -4026,6 +4041,7 @@ static int wl1271_op_ampdu_action(struct ieee80211_hw *hw, u8 buf_size) { struct wl1271 *wl = hw->priv; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret; u8 hlid, *ba_bitmap; @@ -4043,10 +4059,10 @@ static int wl1271_op_ampdu_action(struct ieee80211_hw *hw, goto out; } - if (wl->bss_type == BSS_TYPE_STA_BSS) { + if (wlvif->bss_type == BSS_TYPE_STA_BSS) { hlid = wl->sta_hlid; ba_bitmap = &wl->ba_rx_bitmap; - } else if (wl->bss_type == BSS_TYPE_AP_BSS) { + } else if (wlvif->bss_type == BSS_TYPE_AP_BSS) { struct wl1271_station *wl_sta; wl_sta = (struct wl1271_station *)sta->drv_priv; @@ -4197,10 +4213,6 @@ static bool wl1271_tx_frames_pending(struct ieee80211_hw *hw) /* packets are considered pending if in the TX queue or the FW */ ret = (wl1271_tx_total_queue_count(wl) > 0) || (wl->tx_frames_cnt > 0); - - /* the above is appropriate for STA mode for PS purposes */ - WARN_ON(wl->bss_type != BSS_TYPE_STA_BSS); - out: mutex_unlock(&wl->mutex); @@ -4846,7 +4858,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->flags = 0; wl->sg_enabled = true; wl->hw_pg_ver = -1; - wl->bss_type = MAX_BSS_TYPE; wl->set_bss_type = MAX_BSS_TYPE; wl->last_tx_hlid = 0; wl->ap_ps_map = 0; diff --git a/drivers/net/wireless/wl12xx/rx.c b/drivers/net/wireless/wl12xx/rx.c index dee4cfe9ccc1..9cfa0b25a6f8 100644 --- a/drivers/net/wireless/wl12xx/rx.c +++ b/drivers/net/wireless/wl12xx/rx.c @@ -185,6 +185,8 @@ static int wl1271_rx_handle_data(struct wl1271 *wl, u8 *data, u32 length, void wl12xx_rx(struct wl1271 *wl, struct wl12xx_fw_status *status) { struct wl1271_acx_mem_map *wl_mem_map = wl->target_mem_map; + struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); u32 buf_size; u32 fw_rx_counter = status->fw_rx_counter & NUM_RX_PKT_DESC_MOD_MASK; u32 drv_rx_counter = wl->rx_counter & NUM_RX_PKT_DESC_MOD_MASK; @@ -192,7 +194,7 @@ void wl12xx_rx(struct wl1271 *wl, struct wl12xx_fw_status *status) u32 mem_block; u32 pkt_length; u32 pkt_offset; - bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); + bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); bool had_data = false; bool unaligned = false; diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index a8576181ab7f..197d2c2b1e74 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -34,6 +34,7 @@ void wl1271_scan_complete_work(struct work_struct *work) { struct delayed_work *dwork; struct wl1271 *wl; + struct wl12xx_vif *wlvif; int ret; bool is_sta, is_ibss; @@ -50,6 +51,8 @@ void wl1271_scan_complete_work(struct work_struct *work) if (wl->scan.state == WL1271_SCAN_STATE_IDLE) goto out; + wlvif = wl12xx_vif_to_data(wl->scan_vif); + wl->scan.state = WL1271_SCAN_STATE_IDLE; memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch)); wl->scan.req = NULL; @@ -65,8 +68,8 @@ void wl1271_scan_complete_work(struct work_struct *work) } /* return to ROC if needed */ - is_sta = (wl->bss_type == BSS_TYPE_STA_BSS); - is_ibss = (wl->bss_type == BSS_TYPE_IBSS); + is_sta = (wlvif->bss_type == BSS_TYPE_STA_BSS); + is_ibss = (wlvif->bss_type == BSS_TYPE_IBSS); if (((is_sta && !test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) || (is_ibss && !test_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags))) && !test_bit(wl->dev_role_id, wl->roc_map)) { @@ -589,6 +592,7 @@ out: } int wl1271_scan_sched_scan_config(struct wl1271 *wl, + struct wl12xx_vif *wlvif, struct cfg80211_sched_scan_request *req, struct ieee80211_sched_scan_ies *ies) { @@ -671,14 +675,14 @@ out: return ret; } -int wl1271_scan_sched_scan_start(struct wl1271 *wl) +int wl1271_scan_sched_scan_start(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct wl1271_cmd_sched_scan_start *start; int ret = 0; wl1271_debug(DEBUG_CMD, "cmd periodic scan start"); - if (wl->bss_type != BSS_TYPE_STA_BSS) + if (wlvif->bss_type != BSS_TYPE_STA_BSS) return -EOPNOTSUPP; if (!test_bit(WL1271_FLAG_IDLE, &wl->flags)) diff --git a/drivers/net/wireless/wl12xx/scan.h b/drivers/net/wireless/wl12xx/scan.h index 15177bdfb542..a7ed43dc08c9 100644 --- a/drivers/net/wireless/wl12xx/scan.h +++ b/drivers/net/wireless/wl12xx/scan.h @@ -36,9 +36,10 @@ int wl1271_scan_build_probe_req(struct wl1271 *wl, void wl1271_scan_stm(struct wl1271 *wl, struct ieee80211_vif *vif); void wl1271_scan_complete_work(struct work_struct *work); int wl1271_scan_sched_scan_config(struct wl1271 *wl, + struct wl12xx_vif *wlvif, struct cfg80211_sched_scan_request *req, struct ieee80211_sched_scan_ies *ies); -int wl1271_scan_sched_scan_start(struct wl1271 *wl); +int wl1271_scan_sched_scan_start(struct wl1271 *wl, struct wl12xx_vif *wlvif); void wl1271_scan_sched_scan_stop(struct wl1271 *wl); void wl1271_scan_sched_scan_results(struct wl1271 *wl); diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index bad9e29d49b0..5561ec2d4b4f 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -32,10 +32,11 @@ #include "tx.h" #include "event.h" -static int wl1271_set_default_wep_key(struct wl1271 *wl, u8 id) +static int wl1271_set_default_wep_key(struct wl1271 *wl, + struct wl12xx_vif *wlvif, u8 id) { int ret; - bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); + bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); if (is_ap) ret = wl12xx_cmd_set_default_wep_key(wl, id, @@ -178,14 +179,17 @@ u8 wl12xx_tx_get_hlid_ap(struct wl1271 *wl, struct sk_buff *skb) } } -static u8 wl1271_tx_get_hlid(struct wl1271 *wl, struct sk_buff *skb) +static u8 wl1271_tx_get_hlid(struct wl1271 *wl, struct ieee80211_vif *vif, + struct sk_buff *skb) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + if (wl12xx_is_dummy_packet(wl, skb)) return wl->system_hlid; - if (wl->bss_type == BSS_TYPE_AP_BSS) + if (wlvif->bss_type == BSS_TYPE_AP_BSS) return wl12xx_tx_get_hlid_ap(wl, skb); wl1271_tx_update_filters(wl, skb); @@ -208,9 +212,11 @@ static unsigned int wl12xx_calc_packet_alignment(struct wl1271 *wl, return ALIGN(packet_length, WL1271_TX_ALIGN_TO); } -static int wl1271_tx_allocate(struct wl1271 *wl, struct sk_buff *skb, u32 extra, - u32 buf_offset, u8 hlid) +static int wl1271_tx_allocate(struct wl1271 *wl, struct ieee80211_vif *vif, + struct sk_buff *skb, u32 extra, u32 buf_offset, + u8 hlid) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct wl1271_tx_hw_descr *desc; u32 total_len = skb->len + sizeof(struct wl1271_tx_hw_descr) + extra; u32 len; @@ -257,7 +263,7 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct sk_buff *skb, u32 extra, ac = wl1271_tx_get_queue(skb_get_queue_mapping(skb)); wl->tx_allocated_pkts[ac]++; - if (wl->bss_type == BSS_TYPE_AP_BSS && + if (wlvif->bss_type == BSS_TYPE_AP_BSS && hlid >= WL1271_AP_STA_HLID_START) wl->links[hlid].allocated_pkts++; @@ -273,10 +279,11 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct sk_buff *skb, u32 extra, return ret; } -static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct sk_buff *skb, - u32 extra, struct ieee80211_tx_info *control, - u8 hlid) +static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct ieee80211_vif *vif, + struct sk_buff *skb, u32 extra, + struct ieee80211_tx_info *control, u8 hlid) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct timespec ts; struct wl1271_tx_hw_descr *desc; int aligned_len, ac, rate_idx; @@ -298,7 +305,7 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct sk_buff *skb, hosttime = (timespec_to_ns(&ts) >> 10); desc->start_time = cpu_to_le32(hosttime - wl->time_offset); - if (wl->bss_type != BSS_TYPE_AP_BSS) + if (wlvif->bss_type != BSS_TYPE_AP_BSS) desc->life_time = cpu_to_le16(TX_HW_MGMT_PKT_LIFETIME_TU); else desc->life_time = cpu_to_le16(TX_HW_AP_MODE_PKT_LIFETIME_TU); @@ -324,8 +331,7 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct sk_buff *skb, } desc->hlid = hlid; - - if (wl->bss_type != BSS_TYPE_AP_BSS) { + if (wlvif->bss_type != BSS_TYPE_AP_BSS) { /* if the packets are destined for AP (have a STA entry) send them with AP rate policies, otherwise use default basic rates */ @@ -383,16 +389,27 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct sk_buff *skb, u32 buf_offset) { struct ieee80211_tx_info *info; + struct ieee80211_vif *vif; + struct wl12xx_vif *wlvif; u32 extra = 0; int ret = 0; u32 total_len; u8 hlid; + bool is_dummy; if (!skb) return -EINVAL; info = IEEE80211_SKB_CB(skb); + /* TODO: handle dummy packets on multi-vifs */ + is_dummy = wl12xx_is_dummy_packet(wl, skb); + if (is_dummy) + info->control.vif = wl->vif; + + vif = info->control.vif; + wlvif = wl12xx_vif_to_data(vif); + if (info->control.hw_key && info->control.hw_key->cipher == WLAN_CIPHER_SUITE_TKIP) extra = WL1271_TKIP_IV_SPACE; @@ -406,26 +423,25 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct sk_buff *skb, (cipher == WLAN_CIPHER_SUITE_WEP104); if (unlikely(is_wep && wl->default_key != idx)) { - ret = wl1271_set_default_wep_key(wl, idx); + ret = wl1271_set_default_wep_key(wl, wlvif, idx); if (ret < 0) return ret; wl->default_key = idx; } } - - hlid = wl1271_tx_get_hlid(wl, skb); + hlid = wl1271_tx_get_hlid(wl, vif, skb); if (hlid == WL12XX_INVALID_LINK_ID) { wl1271_error("invalid hlid. dropping skb 0x%p", skb); return -EINVAL; } - ret = wl1271_tx_allocate(wl, skb, extra, buf_offset, hlid); + ret = wl1271_tx_allocate(wl, vif, skb, extra, buf_offset, hlid); if (ret < 0) return ret; - wl1271_tx_fill_hdr(wl, skb, extra, info, hlid); + wl1271_tx_fill_hdr(wl, vif, skb, extra, info, hlid); - if (wl->bss_type == BSS_TYPE_AP_BSS) { + if (wlvif->bss_type == BSS_TYPE_AP_BSS && !is_dummy) { wl1271_tx_ap_update_inconnection_sta(wl, skb); wl1271_tx_regulate_link(wl, hlid); } @@ -444,7 +460,7 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct sk_buff *skb, memset(wl->aggr_buf + buf_offset + skb->len, 0, total_len - skb->len); /* Revert side effects in the dummy packet skb, so it can be reused */ - if (wl12xx_is_dummy_packet(wl, skb)) + if (is_dummy) skb_pull(skb, sizeof(struct wl1271_tx_hw_descr)); return total_len; @@ -586,12 +602,13 @@ static struct sk_buff *wl1271_ap_skb_dequeue(struct wl1271 *wl) return skb; } -static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl) +static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { unsigned long flags; struct sk_buff *skb = NULL; - if (wl->bss_type == BSS_TYPE_AP_BSS) + if (wlvif->bss_type == BSS_TYPE_AP_BSS) skb = wl1271_ap_skb_dequeue(wl); else skb = wl1271_sta_skb_dequeue(wl); @@ -610,15 +627,17 @@ static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl) return skb; } -static void wl1271_skb_queue_head(struct wl1271 *wl, struct sk_buff *skb) +static void wl1271_skb_queue_head(struct wl1271 *wl, struct ieee80211_vif *vif, + struct sk_buff *skb) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); unsigned long flags; int q = wl1271_tx_get_queue(skb_get_queue_mapping(skb)); if (wl12xx_is_dummy_packet(wl, skb)) { set_bit(WL1271_FLAG_DUMMY_PACKET_PENDING, &wl->flags); - } else if (wl->bss_type == BSS_TYPE_AP_BSS) { - u8 hlid = wl1271_tx_get_hlid(wl, skb); + } else if (wlvif->bss_type == BSS_TYPE_AP_BSS) { + u8 hlid = wl1271_tx_get_hlid(wl, vif, skb); skb_queue_head(&wl->links[hlid].tx_queue[q], skb); /* make sure we dequeue the same packet next time */ @@ -639,19 +658,20 @@ static bool wl1271_tx_is_data_present(struct sk_buff *skb) return ieee80211_is_data_present(hdr->frame_control); } -void wl1271_tx_work_locked(struct wl1271 *wl) +void wl1271_tx_work_locked(struct wl1271 *wl, struct ieee80211_vif *vif) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct sk_buff *skb; u32 buf_offset = 0; bool sent_packets = false; bool had_data = false; - bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); + bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); int ret; if (unlikely(wl->state == WL1271_STATE_OFF)) return; - while ((skb = wl1271_skb_dequeue(wl))) { + while ((skb = wl1271_skb_dequeue(wl, wlvif))) { if (wl1271_tx_is_data_present(skb)) had_data = true; @@ -661,7 +681,7 @@ void wl1271_tx_work_locked(struct wl1271 *wl) * Aggregation buffer is full. * Flush buffer and try again. */ - wl1271_skb_queue_head(wl, skb); + wl1271_skb_queue_head(wl, vif, skb); wl1271_write(wl, WL1271_SLV_MEM_DATA, wl->aggr_buf, buf_offset, true); sent_packets = true; @@ -672,7 +692,7 @@ void wl1271_tx_work_locked(struct wl1271 *wl) * Firmware buffer is full. * Queue back last skb, and stop aggregating. */ - wl1271_skb_queue_head(wl, skb); + wl1271_skb_queue_head(wl, vif, skb); /* No work left, avoid scheduling redundant tx work */ set_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags); goto out_ack; @@ -726,7 +746,7 @@ void wl1271_tx_work(struct work_struct *work) if (ret < 0) goto out; - wl1271_tx_work_locked(wl); + wl1271_tx_work_locked(wl, wl->vif); wl1271_ps_elp_sleep(wl); out: @@ -888,12 +908,14 @@ void wl1271_tx_reset_link_queues(struct wl1271 *wl, u8 hlid) /* caller must hold wl->mutex and TX must be stopped */ void wl1271_tx_reset(struct wl1271 *wl, bool reset_tx_queues) { + struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int i; struct sk_buff *skb; struct ieee80211_tx_info *info; /* TX failure */ - if (wl->bss_type == BSS_TYPE_AP_BSS) { + if (wlvif->bss_type == BSS_TYPE_AP_BSS) { for (i = 0; i < AP_MAX_LINKS; i++) { wl1271_free_sta(wl, i); wl1271_tx_reset_link_queues(wl, i); diff --git a/drivers/net/wireless/wl12xx/tx.h b/drivers/net/wireless/wl12xx/tx.h index dc4f09adf088..ba9403a45404 100644 --- a/drivers/net/wireless/wl12xx/tx.h +++ b/drivers/net/wireless/wl12xx/tx.h @@ -204,7 +204,7 @@ static inline int wl1271_tx_total_queue_count(struct wl1271 *wl) } void wl1271_tx_work(struct work_struct *work); -void wl1271_tx_work_locked(struct wl1271 *wl); +void wl1271_tx_work_locked(struct wl1271 *wl, struct ieee80211_vif *vif); void wl1271_tx_complete(struct wl1271 *wl); void wl1271_tx_reset(struct wl1271 *wl, bool reset_tx_queues); void wl1271_tx_flush(struct wl1271 *wl); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 44a5daeff07e..97ed19c67695 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -400,7 +400,6 @@ struct wl1271 { s8 hw_pg_ver; u8 mac_addr[ETH_ALEN]; - u8 bss_type; u8 set_bss_type; u8 p2p; /* we are using p2p role */ u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; @@ -630,6 +629,8 @@ struct wl1271_station { }; struct wl12xx_vif { + u8 bss_type; + u32 basic_rate_set; /* -- cgit v1.2.3 From 10bcf745ae737cfbca1796386d76b0636b086770 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:46 +0200 Subject: wl12xx: remove set_bss_type field set_bss_type is no longer evaluated, so delete it. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 8 -------- drivers/net/wireless/wl12xx/wl12xx.h | 1 - 2 files changed, 9 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 5b13af0f8e8e..50ee9d40e641 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1894,11 +1894,9 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, /* fall-through */ case NL80211_IFTYPE_STATION: wlvif->bss_type = BSS_TYPE_STA_BSS; - wl->set_bss_type = BSS_TYPE_STA_BSS; break; case NL80211_IFTYPE_ADHOC: wlvif->bss_type = BSS_TYPE_IBSS; - wl->set_bss_type = BSS_TYPE_STA_BSS; break; case NL80211_IFTYPE_P2P_GO: wl->p2p = 1; @@ -2107,7 +2105,6 @@ deinit: memset(wl->ssid, 0, IEEE80211_MAX_SSID_LEN + 1); wl->ssid_len = 0; - wl->set_bss_type = MAX_BSS_TYPE; wl->p2p = 0; wl->band = IEEE80211_BAND_2GHZ; @@ -3439,10 +3436,6 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, wl1271_debug(DEBUG_ADHOC, "ad-hoc beaconing: %s", bss_conf->enable_beacon ? "enabled" : "disabled"); - if (bss_conf->enable_beacon) - wl->set_bss_type = BSS_TYPE_IBSS; - else - wl->set_bss_type = BSS_TYPE_STA_BSS; do_join = true; } @@ -4858,7 +4851,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->flags = 0; wl->sg_enabled = true; wl->hw_pg_ver = -1; - wl->set_bss_type = MAX_BSS_TYPE; wl->last_tx_hlid = 0; wl->ap_ps_map = 0; wl->ap_fw_ps_map = 0; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 97ed19c67695..0578d750528b 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -400,7 +400,6 @@ struct wl1271 { s8 hw_pg_ver; u8 mac_addr[ETH_ALEN]; - u8 set_bss_type; u8 p2p; /* we are using p2p role */ u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; u8 ssid_len; -- cgit v1.2.3 From fb0e707c838ac7d8aae7ab90ea448e5ac1e29697 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:47 +0200 Subject: wl12xx: move p2p into wlvif move p2p field into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 9 ++++----- drivers/net/wireless/wl12xx/wl12xx.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 50ee9d40e641..111a465ec541 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1827,13 +1827,13 @@ static u8 wl12xx_get_role_type(struct wl1271 *wl, struct wl12xx_vif *wlvif) { switch (wlvif->bss_type) { case BSS_TYPE_AP_BSS: - if (wl->p2p) + if (wlvif->p2p) return WL1271_ROLE_P2P_GO; else return WL1271_ROLE_AP; case BSS_TYPE_STA_BSS: - if (wl->p2p) + if (wlvif->p2p) return WL1271_ROLE_P2P_CL; else return WL1271_ROLE_STA; @@ -1890,7 +1890,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, switch (ieee80211_vif_type_p2p(vif)) { case NL80211_IFTYPE_P2P_CLIENT: - wl->p2p = 1; + wlvif->p2p = 1; /* fall-through */ case NL80211_IFTYPE_STATION: wlvif->bss_type = BSS_TYPE_STA_BSS; @@ -1899,7 +1899,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, wlvif->bss_type = BSS_TYPE_IBSS; break; case NL80211_IFTYPE_P2P_GO: - wl->p2p = 1; + wlvif->p2p = 1; /* fall-through */ case NL80211_IFTYPE_AP: wlvif->bss_type = BSS_TYPE_AP_BSS; @@ -2105,7 +2105,6 @@ deinit: memset(wl->ssid, 0, IEEE80211_MAX_SSID_LEN + 1); wl->ssid_len = 0; - wl->p2p = 0; wl->band = IEEE80211_BAND_2GHZ; wl->rx_counter = 0; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 0578d750528b..d84c0deee36a 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -400,7 +400,6 @@ struct wl1271 { s8 hw_pg_ver; u8 mac_addr[ETH_ALEN]; - u8 p2p; /* we are using p2p role */ u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; u8 ssid_len; int channel; @@ -629,6 +628,7 @@ struct wl1271_station { struct wl12xx_vif { u8 bss_type; + u8 p2p; /* we are using p2p role */ u32 basic_rate_set; -- cgit v1.2.3 From 1fe9f1616ee0852e9422d1f676630e9a4531ace3 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:48 +0200 Subject: wl12xx: move ssid and ssid_len into wlvif move ssid and ssid_len into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 14 +++++++------- drivers/net/wireless/wl12xx/main.c | 21 +++++++++++---------- drivers/net/wireless/wl12xx/wl12xx.h | 5 +++-- 3 files changed, 21 insertions(+), 19 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 096a713a8c94..1f29eab82146 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -576,8 +576,8 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->sta.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set); cmd->sta.beacon_interval = cpu_to_le16(wl->beacon_int); cmd->sta.ssid_type = WL12XX_SSID_TYPE_ANY; - cmd->sta.ssid_len = wl->ssid_len; - memcpy(cmd->sta.ssid, wl->ssid, wl->ssid_len); + cmd->sta.ssid_len = wlvif->ssid_len; + memcpy(cmd->sta.ssid, wlvif->ssid, wlvif->ssid_len); memcpy(cmd->sta.bssid, vif->bss_conf.bssid, ETH_ALEN); cmd->sta.local_rates = cpu_to_le32(wlvif->rate_set); @@ -659,7 +659,7 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) wl1271_debug(DEBUG_CMD, "cmd role start ap %d", wl->role_id); /* trying to use hidden SSID with an old hostapd version */ - if (wl->ssid_len == 0 && !bss_conf->hidden_ssid) { + if (wlvif->ssid_len == 0 && !bss_conf->hidden_ssid) { wl1271_error("got a null SSID from beacon/bss"); ret = -EINVAL; goto out; @@ -693,8 +693,8 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) if (!bss_conf->hidden_ssid) { /* take the SSID from the beacon for backward compatibility */ cmd->ap.ssid_type = WL12XX_SSID_TYPE_PUBLIC; - cmd->ap.ssid_len = wl->ssid_len; - memcpy(cmd->ap.ssid, wl->ssid, wl->ssid_len); + cmd->ap.ssid_len = wlvif->ssid_len; + memcpy(cmd->ap.ssid, wlvif->ssid, wlvif->ssid_len); } else { cmd->ap.ssid_type = WL12XX_SSID_TYPE_HIDDEN; cmd->ap.ssid_len = bss_conf->ssid_len; @@ -791,8 +791,8 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->ibss.beacon_interval = cpu_to_le16(wl->beacon_int); cmd->ibss.dtim_interval = bss_conf->dtim_period; cmd->ibss.ssid_type = WL12XX_SSID_TYPE_ANY; - cmd->ibss.ssid_len = wl->ssid_len; - memcpy(cmd->ibss.ssid, wl->ssid, wl->ssid_len); + cmd->ibss.ssid_len = wlvif->ssid_len; + memcpy(cmd->ibss.ssid, wlvif->ssid, wlvif->ssid_len); memcpy(cmd->ibss.bssid, vif->bss_conf.bssid, ETH_ALEN); cmd->sta.local_rates = cpu_to_le32(wlvif->rate_set); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 111a465ec541..0da9ddc8b6cf 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2103,8 +2103,6 @@ deinit: wl1271_tx_reset(wl, reset_tx_queues); wl1271_power_off(wl); - memset(wl->ssid, 0, IEEE80211_MAX_SSID_LEN + 1); - wl->ssid_len = 0; wl->band = IEEE80211_BAND_2GHZ; wl->rx_counter = 0; @@ -3078,9 +3076,10 @@ out: return ret; } -static int wl1271_ssid_set(struct wl1271 *wl, struct sk_buff *skb, +static int wl1271_ssid_set(struct ieee80211_vif *vif, struct sk_buff *skb, int offset) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); u8 ssid_len; const u8 *ptr = cfg80211_find_ie(WLAN_EID_SSID, skb->data + offset, skb->len - offset); @@ -3096,8 +3095,8 @@ static int wl1271_ssid_set(struct wl1271 *wl, struct sk_buff *skb, return -EINVAL; } - wl->ssid_len = ssid_len; - memcpy(wl->ssid, ptr+2, ssid_len); + wlvif->ssid_len = ssid_len; + memcpy(wlvif->ssid, ptr+2, ssid_len); return 0; } @@ -3133,17 +3132,19 @@ static void wl12xx_remove_vendor_ie(struct sk_buff *skb, } static int wl1271_ap_set_probe_resp_tmpl(struct wl1271 *wl, + struct ieee80211_vif *vif, u8 *probe_rsp_data, size_t probe_rsp_len, u32 rates) { - struct ieee80211_bss_conf *bss_conf = &wl->vif->bss_conf; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; u8 probe_rsp_templ[WL1271_CMD_TEMPL_MAX_SIZE]; int ssid_ie_offset, ie_offset, templ_len; const u8 *ptr; /* no need to change probe response if the SSID is set correctly */ - if (wl->ssid_len > 0) + if (wlvif->ssid_len > 0) return wl1271_cmd_template_set(wl, CMD_TEMPL_AP_PROBE_RESPONSE, probe_rsp_data, @@ -3256,7 +3257,7 @@ static int wl1271_bss_beacon_info_changed(struct wl1271 *wl, wl1271_debug(DEBUG_MASTER, "beacon updated"); - ret = wl1271_ssid_set(wl, beacon, ieoffset); + ret = wl1271_ssid_set(vif, beacon, ieoffset); if (ret < 0) { dev_kfree_skb(beacon); goto out; @@ -3291,7 +3292,7 @@ static int wl1271_bss_beacon_info_changed(struct wl1271 *wl, hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); if (is_ap) - ret = wl1271_ap_set_probe_resp_tmpl(wl, + ret = wl1271_ap_set_probe_resp_tmpl(wl, vif, beacon->data, beacon->len, min_rate); @@ -3528,7 +3529,7 @@ sta_not_found: wl->probereq = wl1271_cmd_build_ap_probe_req(wl, NULL); ieoffset = offsetof(struct ieee80211_mgmt, u.probe_req.variable); - wl1271_ssid_set(wl, wl->probereq, ieoffset); + wl1271_ssid_set(vif, wl->probereq, ieoffset); /* enable the connection monitoring feature */ ret = wl1271_acx_conn_monit_params(wl, true); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index d84c0deee36a..539cf40be535 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -400,8 +400,6 @@ struct wl1271 { s8 hw_pg_ver; u8 mac_addr[ETH_ALEN]; - u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; - u8 ssid_len; int channel; u8 role_id; u8 dev_role_id; @@ -630,6 +628,9 @@ struct wl12xx_vif { u8 bss_type; u8 p2p; /* we are using p2p role */ + u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; + u8 ssid_len; + u32 basic_rate_set; /* -- cgit v1.2.3 From bddb29b83a9874fda21c34abe7627cbf14fec10e Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:49 +0200 Subject: wl12xx: move probereq into wlvif move probereq into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 11 ++++++----- drivers/net/wireless/wl12xx/scan.c | 2 +- drivers/net/wireless/wl12xx/wl12xx.h | 6 +++--- 3 files changed, 10 insertions(+), 9 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 0da9ddc8b6cf..006e17458130 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -3525,11 +3525,12 @@ sta_not_found: /* * Get a template for hardware connection maintenance */ - dev_kfree_skb(wl->probereq); - wl->probereq = wl1271_cmd_build_ap_probe_req(wl, NULL); + dev_kfree_skb(wlvif->probereq); + wlvif->probereq = wl1271_cmd_build_ap_probe_req(wl, + NULL); ieoffset = offsetof(struct ieee80211_mgmt, u.probe_req.variable); - wl1271_ssid_set(vif, wl->probereq, ieoffset); + wl1271_ssid_set(vif, wlvif->probereq, ieoffset); /* enable the connection monitoring feature */ ret = wl1271_acx_conn_monit_params(wl, true); @@ -3546,8 +3547,8 @@ sta_not_found: wl->aid = 0; /* free probe-request template */ - dev_kfree_skb(wl->probereq); - wl->probereq = NULL; + dev_kfree_skb(wlvif->probereq); + wlvif->probereq = NULL; /* re-enable dynamic ps - just in case */ ieee80211_enable_dyn_ps(wl->vif); diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index 197d2c2b1e74..e3b863b895f3 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -64,7 +64,7 @@ void wl1271_scan_complete_work(struct work_struct *work) if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) { /* restore hardware connection monitoring template */ - wl1271_cmd_build_ap_probe_req(wl, wl->probereq); + wl1271_cmd_build_ap_probe_req(wl, wlvif->probereq); } /* return to ROC if needed */ diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 539cf40be535..8d100561522c 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -507,9 +507,6 @@ struct wl1271 { bool sched_scanning; - /* probe-req template for the current AP */ - struct sk_buff *probereq; - /* Our association ID */ u16 aid; @@ -641,6 +638,9 @@ struct wl12xx_vif { */ u32 basic_rate; u32 rate_set; + + /* probe-req template for the current AP */ + struct sk_buff *probereq; }; static inline struct wl12xx_vif *wl12xx_vif_to_data(struct ieee80211_vif *vif) -- cgit v1.2.3 From 6840e37aec6fd9ffa5b4cf62674af55afdb565ed Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:50 +0200 Subject: wl12xx: move aid into wlvif move aid into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 8 ++++---- drivers/net/wireless/wl12xx/wl12xx.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 006e17458130..e0a557fc3a31 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2217,7 +2217,7 @@ static int wl1271_join(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (ret < 0) goto out; - ret = wl1271_acx_aid(wl, wl->aid); + ret = wl1271_acx_aid(wl, wlvif->aid); if (ret < 0) goto out; @@ -3487,7 +3487,7 @@ sta_not_found: if (bss_conf->assoc) { u32 rates; int ieoffset; - wl->aid = bss_conf->aid; + wlvif->aid = bss_conf->aid; set_assoc = true; wl->ps_poll_failures = 0; @@ -3518,7 +3518,7 @@ sta_not_found: * updates it by itself when the first beacon is * received after a join. */ - ret = wl1271_cmd_build_ps_poll(wl, wlvif, wl->aid); + ret = wl1271_cmd_build_ps_poll(wl, wlvif, wlvif->aid); if (ret < 0) goto out; @@ -3544,7 +3544,7 @@ sta_not_found: bool was_ifup = !!test_and_clear_bit(WL1271_FLAG_STA_STATE_SENT, &wl->flags); - wl->aid = 0; + wlvif->aid = 0; /* free probe-request template */ dev_kfree_skb(wlvif->probereq); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 8d100561522c..e6d3c214acf9 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -507,9 +507,6 @@ struct wl1271 { bool sched_scanning; - /* Our association ID */ - u16 aid; - u32 bitrate_masks[IEEE80211_NUM_BANDS]; /* The current band */ @@ -641,6 +638,9 @@ struct wl12xx_vif { /* probe-req template for the current AP */ struct sk_buff *probereq; + + /* Our association ID */ + u16 aid; }; static inline struct wl12xx_vif *wl12xx_vif_to_data(struct ieee80211_vif *vif) -- cgit v1.2.3 From 0603d891c5b5153f667a79357d4652824c22b54e Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:51 +0200 Subject: wl12xx: move role_id into wlvif move role_id into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/acx.c | 124 +++++++++++++++++++--------------- drivers/net/wireless/wl12xx/acx.h | 71 +++++++++++-------- drivers/net/wireless/wl12xx/cmd.c | 33 ++++----- drivers/net/wireless/wl12xx/cmd.h | 7 +- drivers/net/wireless/wl12xx/debugfs.c | 10 ++- drivers/net/wireless/wl12xx/event.c | 13 ++-- drivers/net/wireless/wl12xx/init.c | 69 ++++++++++--------- drivers/net/wireless/wl12xx/main.c | 118 ++++++++++++++++++-------------- drivers/net/wireless/wl12xx/ps.c | 14 ++-- drivers/net/wireless/wl12xx/ps.h | 4 +- drivers/net/wireless/wl12xx/scan.c | 5 +- drivers/net/wireless/wl12xx/wl12xx.h | 2 +- 12 files changed, 270 insertions(+), 200 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/acx.c b/drivers/net/wireless/wl12xx/acx.c index 015938f94805..9b4eef61bd01 100644 --- a/drivers/net/wireless/wl12xx/acx.c +++ b/drivers/net/wireless/wl12xx/acx.c @@ -33,7 +33,7 @@ #include "reg.h" #include "ps.h" -int wl1271_acx_wake_up_conditions(struct wl1271 *wl) +int wl1271_acx_wake_up_conditions(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct acx_wake_up_condition *wake_up; int ret; @@ -46,7 +46,7 @@ int wl1271_acx_wake_up_conditions(struct wl1271 *wl) goto out; } - wake_up->role_id = wl->role_id; + wake_up->role_id = wlvif->role_id; wake_up->wake_up_event = wl->conf.conn.wake_up_event; wake_up->listen_interval = wl->conf.conn.listen_interval; @@ -84,7 +84,8 @@ out: return ret; } -int wl1271_acx_tx_power(struct wl1271 *wl, int power) +int wl1271_acx_tx_power(struct wl1271 *wl, struct wl12xx_vif *wlvif, + int power) { struct acx_current_tx_power *acx; int ret; @@ -100,7 +101,7 @@ int wl1271_acx_tx_power(struct wl1271 *wl, int power) goto out; } - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->current_tx_power = power * 10; ret = wl1271_cmd_configure(wl, DOT11_CUR_TX_PWR, acx, sizeof(*acx)); @@ -114,7 +115,7 @@ out: return ret; } -int wl1271_acx_feature_cfg(struct wl1271 *wl) +int wl1271_acx_feature_cfg(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct acx_feature_config *feature; int ret; @@ -128,7 +129,7 @@ int wl1271_acx_feature_cfg(struct wl1271 *wl) } /* DF_ENCRYPTION_DISABLE and DF_SNIFF_MODE_ENABLE are disabled */ - feature->role_id = wl->role_id; + feature->role_id = wlvif->role_id; feature->data_flow_options = 0; feature->options = 0; @@ -210,7 +211,8 @@ out: return ret; } -int wl1271_acx_slot(struct wl1271 *wl, enum acx_slot_type slot_time) +int wl1271_acx_slot(struct wl1271 *wl, struct wl12xx_vif *wlvif, + enum acx_slot_type slot_time) { struct acx_slot *slot; int ret; @@ -223,7 +225,7 @@ int wl1271_acx_slot(struct wl1271 *wl, enum acx_slot_type slot_time) goto out; } - slot->role_id = wl->role_id; + slot->role_id = wlvif->role_id; slot->wone_index = STATION_WONE_INDEX; slot->slot_time = slot_time; @@ -238,8 +240,8 @@ out: return ret; } -int wl1271_acx_group_address_tbl(struct wl1271 *wl, bool enable, - void *mc_list, u32 mc_list_len) +int wl1271_acx_group_address_tbl(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable, void *mc_list, u32 mc_list_len) { struct acx_dot11_grp_addr_tbl *acx; int ret; @@ -253,7 +255,7 @@ int wl1271_acx_group_address_tbl(struct wl1271 *wl, bool enable, } /* MAC filtering */ - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->enabled = enable; acx->num_groups = mc_list_len; memcpy(acx->mac_table, mc_list, mc_list_len * ETH_ALEN); @@ -270,7 +272,8 @@ out: return ret; } -int wl1271_acx_service_period_timeout(struct wl1271 *wl) +int wl1271_acx_service_period_timeout(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { struct acx_rx_timeout *rx_timeout; int ret; @@ -283,7 +286,7 @@ int wl1271_acx_service_period_timeout(struct wl1271 *wl) wl1271_debug(DEBUG_ACX, "acx service period timeout"); - rx_timeout->role_id = wl->role_id; + rx_timeout->role_id = wlvif->role_id; rx_timeout->ps_poll_timeout = cpu_to_le16(wl->conf.rx.ps_poll_timeout); rx_timeout->upsd_timeout = cpu_to_le16(wl->conf.rx.upsd_timeout); @@ -300,7 +303,8 @@ out: return ret; } -int wl1271_acx_rts_threshold(struct wl1271 *wl, u32 rts_threshold) +int wl1271_acx_rts_threshold(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u32 rts_threshold) { struct acx_rts_threshold *rts; int ret; @@ -320,7 +324,7 @@ int wl1271_acx_rts_threshold(struct wl1271 *wl, u32 rts_threshold) goto out; } - rts->role_id = wl->role_id; + rts->role_id = wlvif->role_id; rts->threshold = cpu_to_le16((u16)rts_threshold); ret = wl1271_cmd_configure(wl, DOT11_RTS_THRESHOLD, rts, sizeof(*rts)); @@ -363,7 +367,8 @@ out: return ret; } -int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, bool enable_filter) +int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable_filter) { struct acx_beacon_filter_option *beacon_filter = NULL; int ret = 0; @@ -380,7 +385,7 @@ int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, bool enable_filter) goto out; } - beacon_filter->role_id = wl->role_id; + beacon_filter->role_id = wlvif->role_id; beacon_filter->enable = enable_filter; /* @@ -401,7 +406,8 @@ out: return ret; } -int wl1271_acx_beacon_filter_table(struct wl1271 *wl) +int wl1271_acx_beacon_filter_table(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { struct acx_beacon_filter_ie_table *ie_table; int i, idx = 0; @@ -417,7 +423,7 @@ int wl1271_acx_beacon_filter_table(struct wl1271 *wl) } /* configure default beacon pass-through rules */ - ie_table->role_id = wl->role_id; + ie_table->role_id = wlvif->role_id; ie_table->num_ie = 0; for (i = 0; i < wl->conf.conn.bcn_filt_ie_count; i++) { struct conf_bcn_filt_rule *r = &(wl->conf.conn.bcn_filt_ie[i]); @@ -458,7 +464,8 @@ out: #define ACX_CONN_MONIT_DISABLE_VALUE 0xffffffff -int wl1271_acx_conn_monit_params(struct wl1271 *wl, bool enable) +int wl1271_acx_conn_monit_params(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable) { struct acx_conn_monit_params *acx; u32 threshold = ACX_CONN_MONIT_DISABLE_VALUE; @@ -479,7 +486,7 @@ int wl1271_acx_conn_monit_params(struct wl1271 *wl, bool enable) timeout = wl->conf.conn.bss_lose_timeout; } - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->synch_fail_thold = cpu_to_le32(threshold); acx->bss_lose_timeout = cpu_to_le32(timeout); @@ -582,7 +589,7 @@ out: return ret; } -int wl1271_acx_bcn_dtim_options(struct wl1271 *wl) +int wl1271_acx_bcn_dtim_options(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct acx_beacon_broadcast *bb; int ret; @@ -595,7 +602,7 @@ int wl1271_acx_bcn_dtim_options(struct wl1271 *wl) goto out; } - bb->role_id = wl->role_id; + bb->role_id = wlvif->role_id; bb->beacon_rx_timeout = cpu_to_le16(wl->conf.conn.beacon_rx_timeout); bb->broadcast_timeout = cpu_to_le16(wl->conf.conn.broadcast_timeout); bb->rx_broadcast_in_ps = wl->conf.conn.rx_broadcast_in_ps; @@ -612,7 +619,7 @@ out: return ret; } -int wl1271_acx_aid(struct wl1271 *wl, u16 aid) +int wl1271_acx_aid(struct wl1271 *wl, struct wl12xx_vif *wlvif, u16 aid) { struct acx_aid *acx_aid; int ret; @@ -625,7 +632,7 @@ int wl1271_acx_aid(struct wl1271 *wl, u16 aid) goto out; } - acx_aid->role_id = wl->role_id; + acx_aid->role_id = wlvif->role_id; acx_aid->aid = cpu_to_le16(aid); ret = wl1271_cmd_configure(wl, ACX_AID, acx_aid, sizeof(*acx_aid)); @@ -668,7 +675,8 @@ out: return ret; } -int wl1271_acx_set_preamble(struct wl1271 *wl, enum acx_preamble_type preamble) +int wl1271_acx_set_preamble(struct wl1271 *wl, struct wl12xx_vif *wlvif, + enum acx_preamble_type preamble) { struct acx_preamble *acx; int ret; @@ -681,7 +689,7 @@ int wl1271_acx_set_preamble(struct wl1271 *wl, enum acx_preamble_type preamble) goto out; } - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->preamble = preamble; ret = wl1271_cmd_configure(wl, ACX_PREAMBLE_TYPE, acx, sizeof(*acx)); @@ -695,7 +703,7 @@ out: return ret; } -int wl1271_acx_cts_protect(struct wl1271 *wl, +int wl1271_acx_cts_protect(struct wl1271 *wl, struct wl12xx_vif *wlvif, enum acx_ctsprotect_type ctsprotect) { struct acx_ctsprotect *acx; @@ -709,7 +717,7 @@ int wl1271_acx_cts_protect(struct wl1271 *wl, goto out; } - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->ctsprotect = ctsprotect; ret = wl1271_cmd_configure(wl, ACX_CTS_PROTECTION, acx, sizeof(*acx)); @@ -839,8 +847,8 @@ out: return ret; } -int wl1271_acx_ac_cfg(struct wl1271 *wl, u8 ac, u8 cw_min, u16 cw_max, - u8 aifsn, u16 txop) +int wl1271_acx_ac_cfg(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 ac, u8 cw_min, u16 cw_max, u8 aifsn, u16 txop) { struct acx_ac_cfg *acx; int ret = 0; @@ -855,7 +863,7 @@ int wl1271_acx_ac_cfg(struct wl1271 *wl, u8 ac, u8 cw_min, u16 cw_max, goto out; } - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->ac = ac; acx->cw_min = cw_min; acx->cw_max = cpu_to_le16(cw_max); @@ -873,7 +881,8 @@ out: return ret; } -int wl1271_acx_tid_cfg(struct wl1271 *wl, u8 queue_id, u8 channel_type, +int wl1271_acx_tid_cfg(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 queue_id, u8 channel_type, u8 tsid, u8 ps_scheme, u8 ack_policy, u32 apsd_conf0, u32 apsd_conf1) { @@ -889,7 +898,7 @@ int wl1271_acx_tid_cfg(struct wl1271 *wl, u8 queue_id, u8 channel_type, goto out; } - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->queue_id = queue_id; acx->channel_type = channel_type; acx->tsid = tsid; @@ -1098,7 +1107,8 @@ out: return ret; } -int wl1271_acx_bet_enable(struct wl1271 *wl, bool enable) +int wl1271_acx_bet_enable(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable) { struct wl1271_acx_bet_enable *acx = NULL; int ret = 0; @@ -1114,7 +1124,7 @@ int wl1271_acx_bet_enable(struct wl1271 *wl, bool enable) goto out; } - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->enable = enable ? CONF_BET_MODE_ENABLE : CONF_BET_MODE_DISABLE; acx->max_consecutive = wl->conf.conn.bet_max_consecutive; @@ -1129,7 +1139,8 @@ out: return ret; } -int wl1271_acx_arp_ip_filter(struct wl1271 *wl, u8 enable, __be32 address) +int wl1271_acx_arp_ip_filter(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 enable, __be32 address) { struct wl1271_acx_arp_filter *acx; int ret; @@ -1142,7 +1153,7 @@ int wl1271_acx_arp_ip_filter(struct wl1271 *wl, u8 enable, __be32 address) goto out; } - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->version = ACX_IPV4_VERSION; acx->enable = enable; @@ -1189,7 +1200,8 @@ out: return ret; } -int wl1271_acx_keep_alive_mode(struct wl1271 *wl, bool enable) +int wl1271_acx_keep_alive_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable) { struct wl1271_acx_keep_alive_mode *acx = NULL; int ret = 0; @@ -1202,7 +1214,7 @@ int wl1271_acx_keep_alive_mode(struct wl1271 *wl, bool enable) goto out; } - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->enabled = enable; ret = wl1271_cmd_configure(wl, ACX_KEEP_ALIVE_MODE, acx, sizeof(*acx)); @@ -1216,7 +1228,8 @@ out: return ret; } -int wl1271_acx_keep_alive_config(struct wl1271 *wl, u8 index, u8 tpl_valid) +int wl1271_acx_keep_alive_config(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 index, u8 tpl_valid) { struct wl1271_acx_keep_alive_config *acx = NULL; int ret = 0; @@ -1229,7 +1242,7 @@ int wl1271_acx_keep_alive_config(struct wl1271 *wl, u8 index, u8 tpl_valid) goto out; } - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->period = cpu_to_le32(wl->conf.conn.keep_alive_interval); acx->index = index; acx->tpl_validation = tpl_valid; @@ -1247,8 +1260,8 @@ out: return ret; } -int wl1271_acx_rssi_snr_trigger(struct wl1271 *wl, bool enable, - s16 thold, u8 hyst) +int wl1271_acx_rssi_snr_trigger(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable, s16 thold, u8 hyst) { struct wl1271_acx_rssi_snr_trigger *acx = NULL; int ret = 0; @@ -1263,7 +1276,7 @@ int wl1271_acx_rssi_snr_trigger(struct wl1271 *wl, bool enable, wl->last_rssi_event = -1; - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->pacing = cpu_to_le16(wl->conf.roam_trigger.trigger_pacing); acx->metric = WL1271_ACX_TRIG_METRIC_RSSI_BEACON; acx->type = WL1271_ACX_TRIG_TYPE_EDGE; @@ -1288,7 +1301,8 @@ out: return ret; } -int wl1271_acx_rssi_snr_avg_weights(struct wl1271 *wl) +int wl1271_acx_rssi_snr_avg_weights(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { struct wl1271_acx_rssi_snr_avg_weights *acx = NULL; struct conf_roam_trigger_settings *c = &wl->conf.roam_trigger; @@ -1302,7 +1316,7 @@ int wl1271_acx_rssi_snr_avg_weights(struct wl1271 *wl) goto out; } - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->rssi_beacon = c->avg_weight_rssi_beacon; acx->rssi_data = c->avg_weight_rssi_data; acx->snr_beacon = c->avg_weight_snr_beacon; @@ -1367,6 +1381,7 @@ out: } int wl1271_acx_set_ht_information(struct wl1271 *wl, + struct wl12xx_vif *wlvif, u16 ht_operation_mode) { struct wl1271_acx_ht_information *acx; @@ -1380,7 +1395,7 @@ int wl1271_acx_set_ht_information(struct wl1271 *wl, goto out; } - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->ht_protection = (u8)(ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION); acx->rifs_mode = 0; @@ -1402,7 +1417,8 @@ out: } /* Configure BA session initiator/receiver parameters setting in the FW. */ -int wl12xx_acx_set_ba_initiator_policy(struct wl1271 *wl) +int wl12xx_acx_set_ba_initiator_policy(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { struct wl1271_acx_ba_initiator_policy *acx; int ret; @@ -1416,7 +1432,7 @@ int wl12xx_acx_set_ba_initiator_policy(struct wl1271 *wl) } /* set for the current role */ - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->tid_bitmap = wl->conf.ht.tx_ba_tid_bitmap; acx->win_size = wl->conf.ht.tx_ba_win_size; acx->inactivity_timeout = wl->conf.ht.inactivity_timeout; @@ -1496,6 +1512,8 @@ out: int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, bool enable) { + struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct wl1271_acx_ps_rx_streaming *rx_streaming; u32 conf_queues, enable_queues; int i, ret = 0; @@ -1523,7 +1541,7 @@ int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, bool enable) if (!(conf_queues & BIT(i))) continue; - rx_streaming->role_id = wl->role_id; + rx_streaming->role_id = wlvif->role_id; rx_streaming->tid = i; rx_streaming->enable = enable_queues & BIT(i); rx_streaming->period = wl->conf.rx_streaming.interval; @@ -1542,7 +1560,7 @@ out: return ret; } -int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl) +int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct wl1271_acx_ap_max_tx_retry *acx = NULL; int ret; @@ -1553,7 +1571,7 @@ int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl) if (!acx) return -ENOMEM; - acx->role_id = wl->role_id; + acx->role_id = wlvif->role_id; acx->max_tx_retry = cpu_to_le16(wl->conf.tx.max_tx_retries); ret = wl1271_cmd_configure(wl, ACX_MAX_TX_FAILURE, acx, sizeof(*acx)); diff --git a/drivers/net/wireless/wl12xx/acx.h b/drivers/net/wireless/wl12xx/acx.h index 2678e1d505f9..7fccfcc55ca0 100644 --- a/drivers/net/wireless/wl12xx/acx.h +++ b/drivers/net/wireless/wl12xx/acx.h @@ -1234,39 +1234,49 @@ enum { }; -int wl1271_acx_wake_up_conditions(struct wl1271 *wl); +int wl1271_acx_wake_up_conditions(struct wl1271 *wl, + struct wl12xx_vif *wlvif); int wl1271_acx_sleep_auth(struct wl1271 *wl, u8 sleep_auth); -int wl1271_acx_tx_power(struct wl1271 *wl, int power); -int wl1271_acx_feature_cfg(struct wl1271 *wl); +int wl1271_acx_tx_power(struct wl1271 *wl, struct wl12xx_vif *wlvif, + int power); +int wl1271_acx_feature_cfg(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl1271_acx_mem_map(struct wl1271 *wl, struct acx_header *mem_map, size_t len); int wl1271_acx_rx_msdu_life_time(struct wl1271 *wl); int wl1271_acx_pd_threshold(struct wl1271 *wl); -int wl1271_acx_slot(struct wl1271 *wl, enum acx_slot_type slot_time); -int wl1271_acx_group_address_tbl(struct wl1271 *wl, bool enable, - void *mc_list, u32 mc_list_len); -int wl1271_acx_service_period_timeout(struct wl1271 *wl); -int wl1271_acx_rts_threshold(struct wl1271 *wl, u32 rts_threshold); +int wl1271_acx_slot(struct wl1271 *wl, struct wl12xx_vif *wlvif, + enum acx_slot_type slot_time); +int wl1271_acx_group_address_tbl(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable, void *mc_list, u32 mc_list_len); +int wl1271_acx_service_period_timeout(struct wl1271 *wl, + struct wl12xx_vif *wlvif); +int wl1271_acx_rts_threshold(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u32 rts_threshold); int wl1271_acx_dco_itrim_params(struct wl1271 *wl); -int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, bool enable_filter); -int wl1271_acx_beacon_filter_table(struct wl1271 *wl); -int wl1271_acx_conn_monit_params(struct wl1271 *wl, bool enable); +int wl1271_acx_beacon_filter_opt(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable_filter); +int wl1271_acx_beacon_filter_table(struct wl1271 *wl, + struct wl12xx_vif *wlvif); +int wl1271_acx_conn_monit_params(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable); int wl1271_acx_sg_enable(struct wl1271 *wl, bool enable); int wl12xx_acx_sg_cfg(struct wl1271 *wl); int wl1271_acx_cca_threshold(struct wl1271 *wl); -int wl1271_acx_bcn_dtim_options(struct wl1271 *wl); -int wl1271_acx_aid(struct wl1271 *wl, u16 aid); +int wl1271_acx_bcn_dtim_options(struct wl1271 *wl, struct wl12xx_vif *wlvif); +int wl1271_acx_aid(struct wl1271 *wl, struct wl12xx_vif *wlvif, u16 aid); int wl1271_acx_event_mbox_mask(struct wl1271 *wl, u32 event_mask); -int wl1271_acx_set_preamble(struct wl1271 *wl, enum acx_preamble_type preamble); -int wl1271_acx_cts_protect(struct wl1271 *wl, +int wl1271_acx_set_preamble(struct wl1271 *wl, struct wl12xx_vif *wlvif, + enum acx_preamble_type preamble); +int wl1271_acx_cts_protect(struct wl1271 *wl, struct wl12xx_vif *wlvif, enum acx_ctsprotect_type ctsprotect); int wl1271_acx_statistics(struct wl1271 *wl, struct acx_statistics *stats); int wl1271_acx_sta_rate_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl1271_acx_ap_rate_policy(struct wl1271 *wl, struct conf_tx_rate_class *c, u8 idx); -int wl1271_acx_ac_cfg(struct wl1271 *wl, u8 ac, u8 cw_min, u16 cw_max, - u8 aifsn, u16 txop); -int wl1271_acx_tid_cfg(struct wl1271 *wl, u8 queue_id, u8 channel_type, +int wl1271_acx_ac_cfg(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 ac, u8 cw_min, u16 cw_max, u8 aifsn, u16 txop); +int wl1271_acx_tid_cfg(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 queue_id, u8 channel_type, u8 tsid, u8 ps_scheme, u8 ack_policy, u32 apsd_conf0, u32 apsd_conf1); int wl1271_acx_frag_threshold(struct wl1271 *wl, u32 frag_threshold); @@ -1276,25 +1286,32 @@ int wl1271_acx_init_mem_config(struct wl1271 *wl); int wl1271_acx_host_if_cfg_bitmap(struct wl1271 *wl, u32 host_cfg_bitmap); int wl1271_acx_init_rx_interrupt(struct wl1271 *wl); int wl1271_acx_smart_reflex(struct wl1271 *wl); -int wl1271_acx_bet_enable(struct wl1271 *wl, bool enable); -int wl1271_acx_arp_ip_filter(struct wl1271 *wl, u8 enable, __be32 address); +int wl1271_acx_bet_enable(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable); +int wl1271_acx_arp_ip_filter(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 enable, __be32 address); int wl1271_acx_pm_config(struct wl1271 *wl); -int wl1271_acx_keep_alive_mode(struct wl1271 *wl, bool enable); -int wl1271_acx_keep_alive_config(struct wl1271 *wl, u8 index, u8 tpl_valid); -int wl1271_acx_rssi_snr_trigger(struct wl1271 *wl, bool enable, - s16 thold, u8 hyst); -int wl1271_acx_rssi_snr_avg_weights(struct wl1271 *wl); +int wl1271_acx_keep_alive_mode(struct wl1271 *wl, struct wl12xx_vif *vif, + bool enable); +int wl1271_acx_keep_alive_config(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 index, u8 tpl_valid); +int wl1271_acx_rssi_snr_trigger(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable, s16 thold, u8 hyst); +int wl1271_acx_rssi_snr_avg_weights(struct wl1271 *wl, + struct wl12xx_vif *wlvif); int wl1271_acx_set_ht_capabilities(struct wl1271 *wl, struct ieee80211_sta_ht_cap *ht_cap, bool allow_ht_operation, u8 hlid); int wl1271_acx_set_ht_information(struct wl1271 *wl, + struct wl12xx_vif *wlvif, u16 ht_operation_mode); -int wl12xx_acx_set_ba_initiator_policy(struct wl1271 *wl); +int wl12xx_acx_set_ba_initiator_policy(struct wl1271 *wl, + struct wl12xx_vif *wlvif); int wl12xx_acx_set_ba_receiver_session(struct wl1271 *wl, u8 tid_index, u16 ssn, bool enable, u8 peer_hlid); int wl1271_acx_tsf_info(struct wl1271 *wl, u64 *mactime); int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, bool enable); -int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl); +int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_acx_config_ps(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl1271_acx_set_inconnection_sta(struct wl1271 *wl, u8 *addr); int wl1271_acx_fm_coex(struct wl1271 *wl); diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 1f29eab82146..918faca517cf 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -567,9 +567,9 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out; } - wl1271_debug(DEBUG_CMD, "cmd role start sta %d", wl->role_id); + wl1271_debug(DEBUG_CMD, "cmd role start sta %d", wlvif->role_id); - cmd->role_id = wl->role_id; + cmd->role_id = wlvif->role_id; if (wl->band == IEEE80211_BAND_5GHZ) cmd->band = WL12XX_BAND_5GHZ; cmd->channel = wl->channel; @@ -592,7 +592,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d " "basic_rate_set: 0x%x, remote_rates: 0x%x", - wl->role_id, cmd->sta.hlid, cmd->sta.session, + wlvif->role_id, cmd->sta.hlid, cmd->sta.session, wlvif->basic_rate_set, wlvif->rate_set); ret = wl1271_cmd_send(wl, CMD_ROLE_START, cmd, sizeof(*cmd), 0); @@ -615,7 +615,7 @@ out: } /* use this function to stop ibss as well */ -int wl12xx_cmd_role_stop_sta(struct wl1271 *wl) +int wl12xx_cmd_role_stop_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct wl12xx_cmd_role_stop *cmd; int ret; @@ -629,9 +629,9 @@ int wl12xx_cmd_role_stop_sta(struct wl1271 *wl) goto out; } - wl1271_debug(DEBUG_CMD, "cmd role stop sta %d", wl->role_id); + wl1271_debug(DEBUG_CMD, "cmd role stop sta %d", wlvif->role_id); - cmd->role_id = wl->role_id; + cmd->role_id = wlvif->role_id; cmd->disc_type = DISCONNECT_IMMEDIATE; cmd->reason = cpu_to_le16(WLAN_REASON_UNSPECIFIED); @@ -656,7 +656,7 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) struct ieee80211_bss_conf *bss_conf = &wl->vif->bss_conf; int ret; - wl1271_debug(DEBUG_CMD, "cmd role start ap %d", wl->role_id); + wl1271_debug(DEBUG_CMD, "cmd role start ap %d", wlvif->role_id); /* trying to use hidden SSID with an old hostapd version */ if (wlvif->ssid_len == 0 && !bss_conf->hidden_ssid) { @@ -679,7 +679,7 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) if (ret < 0) goto out_free_global; - cmd->role_id = wl->role_id; + cmd->role_id = wlvif->role_id; cmd->ap.aging_period = cpu_to_le16(wl->conf.tx.ap_aging_period); cmd->ap.bss_index = WL1271_AP_BSS_INDEX; cmd->ap.global_hlid = wl->ap_global_hlid; @@ -737,7 +737,7 @@ out: return ret; } -int wl12xx_cmd_role_stop_ap(struct wl1271 *wl) +int wl12xx_cmd_role_stop_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct wl12xx_cmd_role_stop *cmd; int ret; @@ -748,9 +748,9 @@ int wl12xx_cmd_role_stop_ap(struct wl1271 *wl) goto out; } - wl1271_debug(DEBUG_CMD, "cmd role stop ap %d", wl->role_id); + wl1271_debug(DEBUG_CMD, "cmd role stop ap %d", wlvif->role_id); - cmd->role_id = wl->role_id; + cmd->role_id = wlvif->role_id; ret = wl1271_cmd_send(wl, CMD_ROLE_STOP, cmd, sizeof(*cmd), 0); if (ret < 0) { @@ -781,9 +781,9 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out; } - wl1271_debug(DEBUG_CMD, "cmd role start ibss %d", wl->role_id); + wl1271_debug(DEBUG_CMD, "cmd role start ibss %d", wlvif->role_id); - cmd->role_id = wl->role_id; + cmd->role_id = wlvif->role_id; if (wl->band == IEEE80211_BAND_5GHZ) cmd->band = WL12XX_BAND_5GHZ; cmd->channel = wl->channel; @@ -806,7 +806,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d " "basic_rate_set: 0x%x, remote_rates: 0x%x", - wl->role_id, cmd->sta.hlid, cmd->sta.session, + wlvif->role_id, cmd->sta.hlid, cmd->sta.session, wlvif->basic_rate_set, wlvif->rate_set); wl1271_debug(DEBUG_CMD, "vif->bss_conf.bssid = %pM", @@ -966,7 +966,8 @@ out: return ret; } -int wl1271_cmd_ps_mode(struct wl1271 *wl, u8 ps_mode) +int wl1271_cmd_ps_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 ps_mode) { struct wl1271_cmd_ps_params *ps_params = NULL; int ret = 0; @@ -979,7 +980,7 @@ int wl1271_cmd_ps_mode(struct wl1271 *wl, u8 ps_mode) goto out; } - ps_params->role_id = wl->role_id; + ps_params->role_id = wlvif->role_id; ps_params->ps_mode = ps_mode; ret = wl1271_cmd_send(wl, CMD_SET_PS_MODE, ps_params, diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index d5749f5b3bf1..bf2c45b8b911 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -42,15 +42,16 @@ int wl12xx_cmd_role_disable(struct wl1271 *wl, u8 *role_id); int wl12xx_cmd_role_start_dev(struct wl1271 *wl); int wl12xx_cmd_role_stop_dev(struct wl1271 *wl); int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif); -int wl12xx_cmd_role_stop_sta(struct wl1271 *wl); +int wl12xx_cmd_role_stop_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif); -int wl12xx_cmd_role_stop_ap(struct wl1271 *wl); +int wl12xx_cmd_role_stop_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer); int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len); int wl1271_cmd_configure(struct wl1271 *wl, u16 id, void *buf, size_t len); int wl1271_cmd_data_path(struct wl1271 *wl, bool enable); -int wl1271_cmd_ps_mode(struct wl1271 *wl, u8 ps_mode); +int wl1271_cmd_ps_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 ps_mode); int wl1271_cmd_read_memory(struct wl1271 *wl, u32 addr, void *answer, size_t len); int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id, diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 8f88ad6496f9..3309fea2e90e 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -620,11 +620,19 @@ static ssize_t beacon_filtering_write(struct file *file, size_t count, loff_t *ppos) { struct wl1271 *wl = file->private_data; + struct ieee80211_vif *vif; + struct wl12xx_vif *wlvif; char buf[10]; size_t len; unsigned long value; int ret; + if (!wl->vif) + return -EINVAL; + + vif = wl->vif; + wlvif = wl12xx_vif_to_data(vif); + len = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, len)) return -EFAULT; @@ -642,7 +650,7 @@ static ssize_t beacon_filtering_write(struct file *file, if (ret < 0) goto out; - ret = wl1271_acx_beacon_filter_opt(wl, !!value); + ret = wl1271_acx_beacon_filter_opt(wl, wlvif, !!value); wl1271_ps_elp_sleep(wl); out: diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index 072addc0bffc..28a4396fb8e4 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -64,8 +64,8 @@ void wl1271_pspoll_work(struct work_struct *work) if (ret < 0) goto out; - wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE, wlvif->basic_rate, - true); + wl1271_ps_set_mode(wl, wlvif, STATION_POWER_SAVE_MODE, + wlvif->basic_rate, true); wl1271_ps_elp_sleep(wl); out: @@ -85,7 +85,7 @@ static void wl1271_event_pspoll_delivery_fail(struct wl1271 *wl, /* force active mode receive data from the AP */ if (test_bit(WL1271_FLAG_PSM, &wl->flags)) { - ret = wl1271_ps_set_mode(wl, STATION_ACTIVE_MODE, + ret = wl1271_ps_set_mode(wl, wlvif, STATION_ACTIVE_MODE, wlvif->basic_rate, true); if (ret < 0) return; @@ -124,7 +124,8 @@ static int wl1271_event_ps_report(struct wl1271 *wl, if (wl->psm_entry_retry < total_retries) { wl->psm_entry_retry++; - ret = wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE, + ret = wl1271_ps_set_mode(wl, wlvif, + STATION_POWER_SAVE_MODE, wlvif->basic_rate, true); } else { wl1271_info("No ack to nullfunc from AP."); @@ -136,7 +137,7 @@ static int wl1271_event_ps_report(struct wl1271 *wl, wl->psm_entry_retry = 0; /* enable beacon filtering */ - ret = wl1271_acx_beacon_filter_opt(wl, true); + ret = wl1271_acx_beacon_filter_opt(wl, wlvif, true); if (ret < 0) break; @@ -146,7 +147,7 @@ static int wl1271_event_ps_report(struct wl1271 *wl, */ if (wl->band == IEEE80211_BAND_2GHZ) /* enable beacon early termination */ - ret = wl1271_acx_bet_enable(wl, true); + ret = wl1271_acx_bet_enable(wl, wlvif, true); if (wl->ps_compl) { complete(wl->ps_compl); diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index e54cc693ff69..1eaa0a3d9273 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -233,35 +233,37 @@ int wl1271_init_phy_config(struct wl1271 *wl) return 0; } -static int wl12xx_init_phy_vif_config(struct wl1271 *wl) +static int wl12xx_init_phy_vif_config(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { int ret; - ret = wl1271_acx_slot(wl, DEFAULT_SLOT_TIME); + ret = wl1271_acx_slot(wl, wlvif, DEFAULT_SLOT_TIME); if (ret < 0) return ret; - ret = wl1271_acx_service_period_timeout(wl); + ret = wl1271_acx_service_period_timeout(wl, wlvif); if (ret < 0) return ret; - ret = wl1271_acx_rts_threshold(wl, wl->hw->wiphy->rts_threshold); + ret = wl1271_acx_rts_threshold(wl, wlvif, wl->hw->wiphy->rts_threshold); if (ret < 0) return ret; return 0; } -static int wl1271_init_beacon_filter(struct wl1271 *wl) +static int wl1271_init_beacon_filter(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { int ret; /* disable beacon filtering at this stage */ - ret = wl1271_acx_beacon_filter_opt(wl, false); + ret = wl1271_acx_beacon_filter_opt(wl, wlvif, false); if (ret < 0) return ret; - ret = wl1271_acx_beacon_filter_table(wl); + ret = wl1271_acx_beacon_filter_table(wl, wlvif); if (ret < 0) return ret; @@ -294,11 +296,12 @@ int wl1271_init_energy_detection(struct wl1271 *wl) return 0; } -static int wl1271_init_beacon_broadcast(struct wl1271 *wl) +static int wl1271_init_beacon_broadcast(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { int ret; - ret = wl1271_acx_bcn_dtim_options(wl); + ret = wl1271_acx_bcn_dtim_options(wl, wlvif); if (ret < 0) return ret; @@ -352,20 +355,22 @@ static int wl1271_sta_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif) return 0; } -static int wl1271_sta_hw_init_post_mem(struct wl1271 *wl) +static int wl1271_sta_hw_init_post_mem(struct wl1271 *wl, + struct ieee80211_vif *vif) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret, i; /* disable all keep-alive templates */ for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) { - ret = wl1271_acx_keep_alive_config(wl, i, + ret = wl1271_acx_keep_alive_config(wl, wlvif, i, ACX_KEEP_ALIVE_TPL_INVALID); if (ret < 0) return ret; } /* disable the keep-alive feature */ - ret = wl1271_acx_keep_alive_mode(wl, false); + ret = wl1271_acx_keep_alive_mode(wl, wlvif, false); if (ret < 0) return ret; @@ -410,7 +415,7 @@ int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif) * when operating as AP we want to receive external beacons for * configuring ERP protection. */ - ret = wl1271_acx_beacon_filter_opt(wl, false); + ret = wl1271_acx_beacon_filter_opt(wl, wlvif, false); if (ret < 0) return ret; @@ -495,7 +500,7 @@ static int wl1271_set_ba_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif) wl->ba_support = true; /* 802.11n initiator BA session setting */ - return wl12xx_acx_set_ba_initiator_policy(wl); + return wl12xx_acx_set_ba_initiator_policy(wl, wlvif); } int wl1271_chip_specific_init(struct wl1271 *wl) @@ -519,31 +524,31 @@ out: } /* vif-specifc initialization */ -static int wl12xx_init_sta_role(struct wl1271 *wl, struct ieee80211_vif *vif) +static int wl12xx_init_sta_role(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int ret; - ret = wl1271_acx_group_address_tbl(wl, true, NULL, 0); + ret = wl1271_acx_group_address_tbl(wl, wlvif, true, NULL, 0); if (ret < 0) return ret; /* Initialize connection monitoring thresholds */ - ret = wl1271_acx_conn_monit_params(wl, false); + ret = wl1271_acx_conn_monit_params(wl, wlvif, false); if (ret < 0) return ret; /* Beacon filtering */ - ret = wl1271_init_beacon_filter(wl); + ret = wl1271_init_beacon_filter(wl, wlvif); if (ret < 0) return ret; /* Beacons and broadcast settings */ - ret = wl1271_init_beacon_broadcast(wl); + ret = wl1271_init_beacon_broadcast(wl, wlvif); if (ret < 0) return ret; /* Configure rssi/snr averaging weights */ - ret = wl1271_acx_rssi_snr_avg_weights(wl); + ret = wl1271_acx_rssi_snr_avg_weights(wl, wlvif); if (ret < 0) return ret; @@ -551,16 +556,16 @@ static int wl12xx_init_sta_role(struct wl1271 *wl, struct ieee80211_vif *vif) } /* vif-specific intialization */ -static int wl12xx_init_ap_role(struct wl1271 *wl, struct ieee80211_vif *vif) +static int wl12xx_init_ap_role(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int ret; - ret = wl1271_acx_ap_max_tx_retry(wl); + ret = wl1271_acx_ap_max_tx_retry(wl, wlvif); if (ret < 0) return ret; /* initialize Tx power */ - ret = wl1271_acx_tx_power(wl, wl->power_level); + ret = wl1271_acx_tx_power(wl, wlvif, wl->power_level); if (ret < 0) return ret; @@ -582,7 +587,7 @@ int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) if (ret < 0) return ret; - ret = wl12xx_init_ap_role(wl, vif); + ret = wl12xx_init_ap_role(wl, wlvif); if (ret < 0) return ret; } else { @@ -590,25 +595,25 @@ int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) if (ret < 0) return ret; - ret = wl12xx_init_sta_role(wl, vif); + ret = wl12xx_init_sta_role(wl, wlvif); if (ret < 0) return ret; } - wl12xx_init_phy_vif_config(wl); + wl12xx_init_phy_vif_config(wl, wlvif); /* Default TID/AC configuration */ BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count); for (i = 0; i < wl->conf.tx.tid_conf_count; i++) { conf_ac = &wl->conf.tx.ac_conf[i]; - ret = wl1271_acx_ac_cfg(wl, conf_ac->ac, conf_ac->cw_min, - conf_ac->cw_max, conf_ac->aifsn, - conf_ac->tx_op_limit); + ret = wl1271_acx_ac_cfg(wl, wlvif, conf_ac->ac, + conf_ac->cw_min, conf_ac->cw_max, + conf_ac->aifsn, conf_ac->tx_op_limit); if (ret < 0) return ret; conf_tid = &wl->conf.tx.tid_conf[i]; - ret = wl1271_acx_tid_cfg(wl, + ret = wl1271_acx_tid_cfg(wl, wlvif, conf_tid->queue_id, conf_tid->channel_type, conf_tid->tsid, @@ -621,7 +626,7 @@ int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) } /* Configure HW encryption */ - ret = wl1271_acx_feature_cfg(wl); + ret = wl1271_acx_feature_cfg(wl, wlvif); if (ret < 0) return ret; @@ -629,7 +634,7 @@ int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) if (is_ap) ret = wl1271_ap_hw_init_post_mem(wl, vif); else - ret = wl1271_sta_hw_init_post_mem(wl); + ret = wl1271_sta_hw_init_post_mem(wl, vif); if (ret < 0) return ret; diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index e0a557fc3a31..b3d4ef5b900d 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -402,7 +402,10 @@ static LIST_HEAD(wl_list); static int wl1271_check_operstate(struct wl1271 *wl, unsigned char operstate) { + struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret; + if (operstate != IF_OPER_UP) return 0; @@ -413,7 +416,7 @@ static int wl1271_check_operstate(struct wl1271 *wl, unsigned char operstate) if (ret < 0) return ret; - wl12xx_croc(wl, wl->role_id); + wl12xx_croc(wl, wlvif->role_id); wl1271_info("Association completed."); return 0; @@ -695,7 +698,7 @@ static int wl1271_plt_init(struct wl1271 *wl) goto out_free_memmap; /* Initialize connection monitoring thresholds */ - ret = wl1271_acx_conn_monit_params(wl, false); + ret = wl1271_acx_conn_monit_params(wl, NULL, false); /* TODO: fix */ if (ret < 0) goto out_free_memmap; @@ -727,14 +730,16 @@ static int wl1271_plt_init(struct wl1271 *wl) BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count); for (i = 0; i < wl->conf.tx.tid_conf_count; i++) { conf_ac = &wl->conf.tx.ac_conf[i]; - ret = wl1271_acx_ac_cfg(wl, conf_ac->ac, conf_ac->cw_min, + /* TODO: fix */ + ret = wl1271_acx_ac_cfg(wl, NULL, conf_ac->ac, conf_ac->cw_min, conf_ac->cw_max, conf_ac->aifsn, conf_ac->tx_op_limit); if (ret < 0) goto out_free_memmap; conf_tid = &wl->conf.tx.tid_conf[i]; - ret = wl1271_acx_tid_cfg(wl, conf_tid->queue_id, + /* TODO: fix */ + ret = wl1271_acx_tid_cfg(wl, NULL, conf_tid->queue_id, conf_tid->channel_type, conf_tid->tsid, conf_tid->ps_scheme, @@ -1631,7 +1636,7 @@ static int wl1271_configure_suspend_sta(struct wl1271 *wl, DECLARE_COMPLETION_ONSTACK(compl); wl->ps_compl = &compl; - ret = wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE, + ret = wl1271_ps_set_mode(wl, wlvif, STATION_POWER_SAVE_MODE, wlvif->basic_rate, true); if (ret < 0) goto out_sleep; @@ -1664,7 +1669,8 @@ out: } -static int wl1271_configure_suspend_ap(struct wl1271 *wl) +static int wl1271_configure_suspend_ap(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { int ret = 0; @@ -1677,7 +1683,7 @@ static int wl1271_configure_suspend_ap(struct wl1271 *wl) if (ret < 0) goto out_unlock; - ret = wl1271_acx_beacon_filter_opt(wl, true); + ret = wl1271_acx_beacon_filter_opt(wl, wlvif, true); wl1271_ps_elp_sleep(wl); out_unlock: @@ -1692,7 +1698,7 @@ static int wl1271_configure_suspend(struct wl1271 *wl, if (wlvif->bss_type == BSS_TYPE_STA_BSS) return wl1271_configure_suspend_sta(wl, wlvif); if (wlvif->bss_type == BSS_TYPE_AP_BSS) - return wl1271_configure_suspend_ap(wl); + return wl1271_configure_suspend_ap(wl, wlvif); return 0; } @@ -1714,10 +1720,10 @@ static void wl1271_configure_resume(struct wl1271 *wl, if (is_sta) { /* exit psm if it wasn't configured */ if (!test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags)) - wl1271_ps_set_mode(wl, STATION_ACTIVE_MODE, + wl1271_ps_set_mode(wl, wlvif, STATION_ACTIVE_MODE, wlvif->basic_rate, true); } else if (is_ap) { - wl1271_acx_beacon_filter_opt(wl, false); + wl1271_acx_beacon_filter_opt(wl, wlvif, false); } wl1271_ps_elp_sleep(wl); @@ -1850,6 +1856,7 @@ static u8 wl12xx_get_role_type(struct wl1271 *wl, struct wl12xx_vif *wlvif) static void wl12xx_init_vif_data(struct wl12xx_vif *wlvif) { wlvif->bss_type = MAX_BSS_TYPE; + wlvif->role_id = WL12XX_INVALID_ROLE_ID; wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC; wlvif->basic_rate = CONF_TX_RATE_MASK_BASIC; wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; @@ -1957,7 +1964,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, } ret = wl12xx_cmd_role_enable(wl, vif->addr, - role_type, &wl->role_id); + role_type, &wlvif->role_id); if (ret < 0) goto irq_disable; @@ -2065,7 +2072,7 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, goto deinit; } - ret = wl12xx_cmd_role_disable(wl, &wl->role_id); + ret = wl12xx_cmd_role_disable(wl, &wlvif->role_id); if (ret < 0) goto deinit; @@ -2123,7 +2130,7 @@ deinit: wl->ap_fw_ps_map = 0; wl->ap_ps_map = 0; wl->sched_scanning = false; - wl->role_id = WL12XX_INVALID_ROLE_ID; + wlvif->role_id = WL12XX_INVALID_ROLE_ID; wl->dev_role_id = WL12XX_INVALID_ROLE_ID; memset(wl->roles_map, 0, sizeof(wl->roles_map)); memset(wl->links_map, 0, sizeof(wl->links_map)); @@ -2213,11 +2220,11 @@ static int wl1271_join(struct wl1271 *wl, struct wl12xx_vif *wlvif, * the join. The acx_aid starts the keep-alive process, and the order * of the commands below is relevant. */ - ret = wl1271_acx_keep_alive_mode(wl, true); + ret = wl1271_acx_keep_alive_mode(wl, wlvif, true); if (ret < 0) goto out; - ret = wl1271_acx_aid(wl, wlvif->aid); + ret = wl1271_acx_aid(wl, wlvif, wlvif->aid); if (ret < 0) goto out; @@ -2225,7 +2232,8 @@ static int wl1271_join(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (ret < 0) goto out; - ret = wl1271_acx_keep_alive_config(wl, CMD_TEMPL_KLV_IDX_NULL_DATA, + ret = wl1271_acx_keep_alive_config(wl, wlvif, + CMD_TEMPL_KLV_IDX_NULL_DATA, ACX_KEEP_ALIVE_TPL_VALID); if (ret < 0) goto out; @@ -2234,7 +2242,7 @@ out: return ret; } -static int wl1271_unjoin(struct wl1271 *wl) +static int wl1271_unjoin(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int ret; @@ -2244,7 +2252,7 @@ static int wl1271_unjoin(struct wl1271 *wl) } /* to stop listening to a channel, we disconnect */ - ret = wl12xx_cmd_role_stop_sta(wl); + ret = wl12xx_cmd_role_stop_sta(wl, wlvif); if (ret < 0) goto out; @@ -2295,7 +2303,7 @@ static int wl1271_sta_handle_idle(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (ret < 0) goto out; ret = wl1271_acx_keep_alive_config( - wl, CMD_TEMPL_KLV_IDX_NULL_DATA, + wl, wlvif, CMD_TEMPL_KLV_IDX_NULL_DATA, ACX_KEEP_ALIVE_TPL_INVALID); if (ret < 0) goto out; @@ -2454,7 +2462,8 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) */ if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) { wl1271_debug(DEBUG_PSM, "psm enabled"); - ret = wl1271_ps_set_mode(wl, STATION_POWER_SAVE_MODE, + ret = wl1271_ps_set_mode(wl, wlvif, + STATION_POWER_SAVE_MODE, wlvif->basic_rate, true); } } else if (!(conf->flags & IEEE80211_CONF_PS) && @@ -2464,12 +2473,13 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) clear_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags); if (test_bit(WL1271_FLAG_PSM, &wl->flags)) - ret = wl1271_ps_set_mode(wl, STATION_ACTIVE_MODE, + ret = wl1271_ps_set_mode(wl, wlvif, + STATION_ACTIVE_MODE, wlvif->basic_rate, true); } if (conf->power_level != wl->power_level) { - ret = wl1271_acx_tx_power(wl, conf->power_level); + ret = wl1271_acx_tx_power(wl, wlvif, conf->power_level); if (ret < 0) goto out_sleep; @@ -2558,9 +2568,11 @@ static void wl1271_op_configure_filter(struct ieee80211_hw *hw, if (wlvif->bss_type != BSS_TYPE_AP_BSS) { if (*total & FIF_ALLMULTI) - ret = wl1271_acx_group_address_tbl(wl, false, NULL, 0); + ret = wl1271_acx_group_address_tbl(wl, wlvif, false, + NULL, 0); else if (fp) - ret = wl1271_acx_group_address_tbl(wl, fp->enabled, + ret = wl1271_acx_group_address_tbl(wl, wlvif, + fp->enabled, fp->mc_list, fp->mc_list_length); if (ret < 0) @@ -3051,6 +3063,8 @@ out: static int wl1271_op_set_rts_threshold(struct ieee80211_hw *hw, u32 value) { struct wl1271 *wl = hw->priv; + struct ieee80211_vif *vif = wl->vif; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret = 0; mutex_lock(&wl->mutex); @@ -3064,7 +3078,7 @@ static int wl1271_op_set_rts_threshold(struct ieee80211_hw *hw, u32 value) if (ret < 0) goto out; - ret = wl1271_acx_rts_threshold(wl, value); + ret = wl1271_acx_rts_threshold(wl, wlvif, value); if (ret < 0) wl1271_warning("wl1271_op_set_rts_threshold failed: %d", ret); @@ -3190,16 +3204,18 @@ static int wl1271_ap_set_probe_resp_tmpl(struct wl1271 *wl, } static int wl1271_bss_erp_info_changed(struct wl1271 *wl, + struct ieee80211_vif *vif, struct ieee80211_bss_conf *bss_conf, u32 changed) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret = 0; if (changed & BSS_CHANGED_ERP_SLOT) { if (bss_conf->use_short_slot) - ret = wl1271_acx_slot(wl, SLOT_TIME_SHORT); + ret = wl1271_acx_slot(wl, wlvif, SLOT_TIME_SHORT); else - ret = wl1271_acx_slot(wl, SLOT_TIME_LONG); + ret = wl1271_acx_slot(wl, wlvif, SLOT_TIME_LONG); if (ret < 0) { wl1271_warning("Set slot time failed %d", ret); goto out; @@ -3208,16 +3224,18 @@ static int wl1271_bss_erp_info_changed(struct wl1271 *wl, if (changed & BSS_CHANGED_ERP_PREAMBLE) { if (bss_conf->use_short_preamble) - wl1271_acx_set_preamble(wl, ACX_PREAMBLE_SHORT); + wl1271_acx_set_preamble(wl, wlvif, ACX_PREAMBLE_SHORT); else - wl1271_acx_set_preamble(wl, ACX_PREAMBLE_LONG); + wl1271_acx_set_preamble(wl, wlvif, ACX_PREAMBLE_LONG); } if (changed & BSS_CHANGED_ERP_CTS_PROT) { if (bss_conf->use_cts_prot) - ret = wl1271_acx_cts_protect(wl, CTSPROTECT_ENABLE); + ret = wl1271_acx_cts_protect(wl, wlvif, + CTSPROTECT_ENABLE); else - ret = wl1271_acx_cts_protect(wl, CTSPROTECT_DISABLE); + ret = wl1271_acx_cts_protect(wl, wlvif, + CTSPROTECT_DISABLE); if (ret < 0) { wl1271_warning("Set ctsprotect failed %d", ret); goto out; @@ -3359,7 +3377,7 @@ static void wl1271_bss_info_changed_ap(struct wl1271 *wl, } } else { if (test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) { - ret = wl12xx_cmd_role_stop_ap(wl); + ret = wl12xx_cmd_role_stop_ap(wl, wlvif); if (ret < 0) goto out; @@ -3369,14 +3387,14 @@ static void wl1271_bss_info_changed_ap(struct wl1271 *wl, } } - ret = wl1271_bss_erp_info_changed(wl, bss_conf, changed); + ret = wl1271_bss_erp_info_changed(wl, vif, bss_conf, changed); if (ret < 0) goto out; /* Handle HT information change */ if ((changed & BSS_CHANGED_HT) && (bss_conf->channel_type != NL80211_CHAN_NO_HT)) { - ret = wl1271_acx_set_ht_information(wl, + ret = wl1271_acx_set_ht_information(wl, wlvif, bss_conf->ht_operation_mode); if (ret < 0) { wl1271_warning("Set ht information failed %d", ret); @@ -3418,7 +3436,7 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, } else { if (test_and_clear_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags)) { - wl1271_unjoin(wl); + wl1271_unjoin(wl, wlvif); wl12xx_cmd_role_start_dev(wl); wl12xx_roc(wl, wl->dev_role_id); } @@ -3443,7 +3461,7 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, bool enable = false; if (bss_conf->cqm_rssi_thold) enable = true; - ret = wl1271_acx_rssi_snr_trigger(wl, enable, + ret = wl1271_acx_rssi_snr_trigger(wl, wlvif, enable, bss_conf->cqm_rssi_thold, bss_conf->cqm_rssi_hyst); if (ret < 0) @@ -3533,7 +3551,7 @@ sta_not_found: wl1271_ssid_set(vif, wlvif->probereq, ieoffset); /* enable the connection monitoring feature */ - ret = wl1271_acx_conn_monit_params(wl, true); + ret = wl1271_acx_conn_monit_params(wl, wlvif, true); if (ret < 0) goto out; } else { @@ -3563,10 +3581,10 @@ sta_not_found: goto out; /* disable connection monitor features */ - ret = wl1271_acx_conn_monit_params(wl, false); + ret = wl1271_acx_conn_monit_params(wl, wlvif, false); /* Disable the keep-alive feature */ - ret = wl1271_acx_keep_alive_mode(wl, false); + ret = wl1271_acx_keep_alive_mode(wl, wlvif, false); if (ret < 0) goto out; @@ -3578,7 +3596,7 @@ sta_not_found: * no IF_OPER_UP notification. */ if (!was_ifup) { - ret = wl12xx_croc(wl, wl->role_id); + ret = wl12xx_croc(wl, wlvif->role_id); if (ret < 0) goto out; } @@ -3593,7 +3611,7 @@ sta_not_found: goto out; } - wl1271_unjoin(wl); + wl1271_unjoin(wl, wlvif); if (!(conf_flags & IEEE80211_CONF_IDLE)) { wl12xx_cmd_role_start_dev(wl); wl12xx_roc(wl, wl->dev_role_id); @@ -3623,7 +3641,7 @@ sta_not_found: } } - ret = wl1271_bss_erp_info_changed(wl, bss_conf, changed); + ret = wl1271_bss_erp_info_changed(wl, vif, bss_conf, changed); if (ret < 0) goto out; @@ -3645,11 +3663,11 @@ sta_not_found: goto out; } - ret = wl1271_acx_arp_ip_filter(wl, + ret = wl1271_acx_arp_ip_filter(wl, wlvif, ACX_ARP_FILTER_ARP_FILTERING, addr); } else - ret = wl1271_acx_arp_ip_filter(wl, 0, addr); + ret = wl1271_acx_arp_ip_filter(wl, wlvif, 0, addr); if (ret < 0) goto out; @@ -3664,7 +3682,7 @@ sta_not_found: /* ROC until connected (after EAPOL exchange) */ if (!is_ibss) { - ret = wl12xx_roc(wl, wl->role_id); + ret = wl12xx_roc(wl, wlvif->role_id); if (ret < 0) goto out; @@ -3691,7 +3709,7 @@ sta_not_found: enum wl1271_cmd_ps_mode mode; mode = STATION_POWER_SAVE_MODE; - ret = wl1271_ps_set_mode(wl, mode, + ret = wl1271_ps_set_mode(wl, wlvif, mode, wlvif->basic_rate, true); if (ret < 0) @@ -3730,7 +3748,7 @@ sta_not_found: /* Handle HT information change. Done after join. */ if ((changed & BSS_CHANGED_HT) && (bss_conf->channel_type != NL80211_CHAN_NO_HT)) { - ret = wl1271_acx_set_ht_information(wl, + ret = wl1271_acx_set_ht_information(wl, wlvif, bss_conf->ht_operation_mode); if (ret < 0) { wl1271_warning("Set ht information failed %d", ret); @@ -3780,6 +3798,7 @@ static int wl1271_op_conf_tx(struct ieee80211_hw *hw, const struct ieee80211_tx_queue_params *params) { struct wl1271 *wl = hw->priv; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); u8 ps_scheme; int ret = 0; @@ -3826,13 +3845,13 @@ static int wl1271_op_conf_tx(struct ieee80211_hw *hw, * the txop is confed in units of 32us by the mac80211, * we need us */ - ret = wl1271_acx_ac_cfg(wl, wl1271_tx_get_queue(queue), + ret = wl1271_acx_ac_cfg(wl, wlvif, wl1271_tx_get_queue(queue), params->cw_min, params->cw_max, params->aifs, params->txop << 5); if (ret < 0) goto out_sleep; - ret = wl1271_acx_tid_cfg(wl, wl1271_tx_get_queue(queue), + ret = wl1271_acx_tid_cfg(wl, wlvif, wl1271_tx_get_queue(queue), CONF_CHANNEL_TYPE_EDCF, wl1271_tx_get_queue(queue), ps_scheme, CONF_ACK_POLICY_LEGACY, @@ -4861,7 +4880,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->tx_security_seq = 0; wl->tx_security_last_seq_lsb = 0; wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; - wl->role_id = WL12XX_INVALID_ROLE_ID; wl->system_hlid = WL12XX_SYSTEM_HLID; wl->sta_hlid = WL12XX_INVALID_LINK_ID; wl->dev_role_id = WL12XX_INVALID_ROLE_ID; diff --git a/drivers/net/wireless/wl12xx/ps.c b/drivers/net/wireless/wl12xx/ps.c index c15ebf2efd40..ac3f20716f5b 100644 --- a/drivers/net/wireless/wl12xx/ps.c +++ b/drivers/net/wireless/wl12xx/ps.c @@ -143,8 +143,8 @@ out: return 0; } -int wl1271_ps_set_mode(struct wl1271 *wl, enum wl1271_cmd_ps_mode mode, - u32 rates, bool send) +int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, + enum wl1271_cmd_ps_mode mode, u32 rates, bool send) { int ret; @@ -152,13 +152,13 @@ int wl1271_ps_set_mode(struct wl1271 *wl, enum wl1271_cmd_ps_mode mode, case STATION_POWER_SAVE_MODE: wl1271_debug(DEBUG_PSM, "entering psm"); - ret = wl1271_acx_wake_up_conditions(wl); + ret = wl1271_acx_wake_up_conditions(wl, wlvif); if (ret < 0) { wl1271_error("couldn't set wake up conditions"); return ret; } - ret = wl1271_cmd_ps_mode(wl, STATION_POWER_SAVE_MODE); + ret = wl1271_cmd_ps_mode(wl, wlvif, STATION_POWER_SAVE_MODE); if (ret < 0) return ret; @@ -170,17 +170,17 @@ int wl1271_ps_set_mode(struct wl1271 *wl, enum wl1271_cmd_ps_mode mode, /* disable beacon early termination */ if (wl->band == IEEE80211_BAND_2GHZ) { - ret = wl1271_acx_bet_enable(wl, false); + ret = wl1271_acx_bet_enable(wl, wlvif, false); if (ret < 0) return ret; } /* disable beacon filtering */ - ret = wl1271_acx_beacon_filter_opt(wl, false); + ret = wl1271_acx_beacon_filter_opt(wl, wlvif, false); if (ret < 0) return ret; - ret = wl1271_cmd_ps_mode(wl, STATION_ACTIVE_MODE); + ret = wl1271_cmd_ps_mode(wl, wlvif, STATION_ACTIVE_MODE); if (ret < 0) return ret; diff --git a/drivers/net/wireless/wl12xx/ps.h b/drivers/net/wireless/wl12xx/ps.h index 25eb9bc9b628..6ad0a0bd29bd 100644 --- a/drivers/net/wireless/wl12xx/ps.h +++ b/drivers/net/wireless/wl12xx/ps.h @@ -27,8 +27,8 @@ #include "wl12xx.h" #include "acx.h" -int wl1271_ps_set_mode(struct wl1271 *wl, enum wl1271_cmd_ps_mode mode, - u32 rates, bool send); +int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, + enum wl1271_cmd_ps_mode mode, u32 rates, bool send); void wl1271_ps_elp_sleep(struct wl1271 *wl); int wl1271_ps_elp_wakeup(struct wl1271 *wl); void wl1271_elp_work(struct work_struct *work); diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index e3b863b895f3..9d0dfb516e26 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -163,6 +163,7 @@ static int wl1271_scan_send(struct wl1271 *wl, struct ieee80211_vif *vif, enum ieee80211_band band, bool passive, u32 basic_rate) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct wl1271_cmd_scan *cmd; struct wl1271_cmd_trigger_scan_to *trigger; int ret; @@ -182,11 +183,11 @@ static int wl1271_scan_send(struct wl1271 *wl, struct ieee80211_vif *vif, if (passive) scan_options |= WL1271_SCAN_OPT_PASSIVE; - if (WARN_ON(wl->role_id == WL12XX_INVALID_ROLE_ID)) { + if (WARN_ON(wlvif->role_id == WL12XX_INVALID_ROLE_ID)) { ret = -EINVAL; goto out; } - cmd->params.role_id = wl->role_id; + cmd->params.role_id = wlvif->role_id; cmd->params.scan_options = cpu_to_le16(scan_options); cmd->params.n_ch = wl1271_get_scan_channels(wl, wl->scan.req, diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index e6d3c214acf9..e249b459f62b 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -401,7 +401,6 @@ struct wl1271 { u8 mac_addr[ETH_ALEN]; int channel; - u8 role_id; u8 dev_role_id; u8 system_hlid; u8 sta_hlid; @@ -621,6 +620,7 @@ struct wl1271_station { struct wl12xx_vif { u8 bss_type; u8 p2p; /* we are using p2p role */ + u8 role_id; u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; u8 ssid_len; -- cgit v1.2.3 From 7edebf56ca424484b9e0e51a6188c93c7fdd3a41 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:52 +0200 Subject: wl12xx: move dev_role_id into wlvif move dev_role_id into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 10 ++++---- drivers/net/wireless/wl12xx/cmd.h | 4 +-- drivers/net/wireless/wl12xx/main.c | 50 ++++++++++++++++++++---------------- drivers/net/wireless/wl12xx/scan.c | 10 +++++--- drivers/net/wireless/wl12xx/tx.c | 9 ++++--- drivers/net/wireless/wl12xx/wl12xx.h | 4 ++- 6 files changed, 49 insertions(+), 38 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 918faca517cf..36544ff6a79b 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -464,7 +464,7 @@ static int wl12xx_get_new_session_id(struct wl1271 *wl) return wl->session_counter; } -int wl12xx_cmd_role_start_dev(struct wl1271 *wl) +int wl12xx_cmd_role_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct wl12xx_cmd_role_start *cmd; int ret; @@ -475,9 +475,9 @@ int wl12xx_cmd_role_start_dev(struct wl1271 *wl) goto out; } - wl1271_debug(DEBUG_CMD, "cmd role start dev %d", wl->dev_role_id); + wl1271_debug(DEBUG_CMD, "cmd role start dev %d", wlvif->dev_role_id); - cmd->role_id = wl->dev_role_id; + cmd->role_id = wlvif->dev_role_id; if (wl->band == IEEE80211_BAND_5GHZ) cmd->band = WL12XX_BAND_5GHZ; cmd->channel = wl->channel; @@ -514,7 +514,7 @@ out: return ret; } -int wl12xx_cmd_role_stop_dev(struct wl1271 *wl) +int wl12xx_cmd_role_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct wl12xx_cmd_role_stop *cmd; int ret; @@ -530,7 +530,7 @@ int wl12xx_cmd_role_stop_dev(struct wl1271 *wl) wl1271_debug(DEBUG_CMD, "cmd role stop dev"); - cmd->role_id = wl->dev_role_id; + cmd->role_id = wlvif->dev_role_id; cmd->disc_type = DISCONNECT_IMMEDIATE; cmd->reason = cpu_to_le16(WLAN_REASON_UNSPECIFIED); diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index bf2c45b8b911..fb40556a8ad1 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -39,8 +39,8 @@ int wl1271_cmd_ext_radio_parms(struct wl1271 *wl); int wl12xx_cmd_role_enable(struct wl1271 *wl, u8 *addr, u8 role_type, u8 *role_id); int wl12xx_cmd_role_disable(struct wl1271 *wl, u8 *role_id); -int wl12xx_cmd_role_start_dev(struct wl1271 *wl); -int wl12xx_cmd_role_stop_dev(struct wl1271 *wl); +int wl12xx_cmd_role_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif); +int wl12xx_cmd_role_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_role_stop_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index b3d4ef5b900d..f4d3df15719b 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1857,6 +1857,7 @@ static void wl12xx_init_vif_data(struct wl12xx_vif *wlvif) { wlvif->bss_type = MAX_BSS_TYPE; wlvif->role_id = WL12XX_INVALID_ROLE_ID; + wlvif->dev_role_id = WL12XX_INVALID_ROLE_ID; wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC; wlvif->basic_rate = CONF_TX_RATE_MASK_BASIC; wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; @@ -1958,7 +1959,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, */ ret = wl12xx_cmd_role_enable(wl, vif->addr, WL1271_ROLE_DEVICE, - &wl->dev_role_id); + &wlvif->dev_role_id); if (ret < 0) goto irq_disable; } @@ -2067,7 +2068,7 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, goto deinit; if (wlvif->bss_type == BSS_TYPE_STA_BSS) { - ret = wl12xx_cmd_role_disable(wl, &wl->dev_role_id); + ret = wl12xx_cmd_role_disable(wl, &wlvif->dev_role_id); if (ret < 0) goto deinit; } @@ -2131,7 +2132,7 @@ deinit: wl->ap_ps_map = 0; wl->sched_scanning = false; wlvif->role_id = WL12XX_INVALID_ROLE_ID; - wl->dev_role_id = WL12XX_INVALID_ROLE_ID; + wlvif->dev_role_id = WL12XX_INVALID_ROLE_ID; memset(wl->roles_map, 0, sizeof(wl->roles_map)); memset(wl->links_map, 0, sizeof(wl->links_map)); memset(wl->roc_map, 0, sizeof(wl->roc_map)); @@ -2289,11 +2290,11 @@ static int wl1271_sta_handle_idle(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (idle) { /* no need to croc if we weren't busy (e.g. during boot) */ if (wl12xx_is_roc(wl)) { - ret = wl12xx_croc(wl, wl->dev_role_id); + ret = wl12xx_croc(wl, wlvif->dev_role_id); if (ret < 0) goto out; - ret = wl12xx_cmd_role_stop_dev(wl); + ret = wl12xx_cmd_role_stop_dev(wl, wlvif); if (ret < 0) goto out; } @@ -2315,11 +2316,11 @@ static int wl1271_sta_handle_idle(struct wl1271 *wl, struct wl12xx_vif *wlvif, ieee80211_sched_scan_stopped(wl->hw); } - ret = wl12xx_cmd_role_start_dev(wl); + ret = wl12xx_cmd_role_start_dev(wl, wlvif); if (ret < 0) goto out; - ret = wl12xx_roc(wl, wl->dev_role_id); + ret = wl12xx_roc(wl, wlvif->dev_role_id); if (ret < 0) goto out; clear_bit(WL1271_FLAG_IDLE, &wl->flags); @@ -2408,7 +2409,8 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) { if (wl12xx_is_roc(wl)) { /* roaming */ - ret = wl12xx_croc(wl, wl->dev_role_id); + ret = wl12xx_croc(wl, + wlvif->dev_role_id); if (ret < 0) goto out_sleep; } @@ -2424,11 +2426,13 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) */ if (wl12xx_is_roc(wl) && !(conf->flags & IEEE80211_CONF_IDLE)) { - ret = wl12xx_croc(wl, wl->dev_role_id); + ret = wl12xx_croc(wl, + wlvif->dev_role_id); if (ret < 0) goto out_sleep; - ret = wl12xx_roc(wl, wl->dev_role_id); + ret = wl12xx_roc(wl, + wlvif->dev_role_id); if (ret < 0) wl1271_warning("roc failed %d", ret); @@ -2891,6 +2895,8 @@ static int wl1271_op_hw_scan(struct ieee80211_hw *hw, struct cfg80211_scan_request *req) { struct wl1271 *wl = hw->priv; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + int ret; u8 *ssid = NULL; size_t len = 0; @@ -2925,8 +2931,8 @@ static int wl1271_op_hw_scan(struct ieee80211_hw *hw, ret = -EBUSY; goto out_sleep; } - wl12xx_croc(wl, wl->dev_role_id); - wl12xx_cmd_role_stop_dev(wl); + wl12xx_croc(wl, wlvif->dev_role_id); + wl12xx_cmd_role_stop_dev(wl, wlvif); } ret = wl1271_scan(hw->priv, vif, ssid, len, req); @@ -3437,8 +3443,8 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, if (test_and_clear_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags)) { wl1271_unjoin(wl, wlvif); - wl12xx_cmd_role_start_dev(wl); - wl12xx_roc(wl, wl->dev_role_id); + wl12xx_cmd_role_start_dev(wl, wlvif); + wl12xx_roc(wl, wlvif->dev_role_id); } } } @@ -3605,16 +3611,17 @@ sta_not_found: * roaming on the same channel. until we will * have a better flow...) */ - if (test_bit(wl->dev_role_id, wl->roc_map)) { - ret = wl12xx_croc(wl, wl->dev_role_id); + if (test_bit(wlvif->dev_role_id, wl->roc_map)) { + ret = wl12xx_croc(wl, + wlvif->dev_role_id); if (ret < 0) goto out; } wl1271_unjoin(wl, wlvif); if (!(conf_flags & IEEE80211_CONF_IDLE)) { - wl12xx_cmd_role_start_dev(wl); - wl12xx_roc(wl, wl->dev_role_id); + wl12xx_cmd_role_start_dev(wl, wlvif); + wl12xx_roc(wl, wlvif->dev_role_id); } } } @@ -3693,12 +3700,12 @@ sta_not_found: * stop device role if started (we might already be in * STA role). TODO: make it better. */ - if (wl->dev_role_id != WL12XX_INVALID_ROLE_ID) { - ret = wl12xx_croc(wl, wl->dev_role_id); + if (wlvif->dev_role_id != WL12XX_INVALID_ROLE_ID) { + ret = wl12xx_croc(wl, wlvif->dev_role_id); if (ret < 0) goto out; - ret = wl12xx_cmd_role_stop_dev(wl); + ret = wl12xx_cmd_role_stop_dev(wl, wlvif); if (ret < 0) goto out; } @@ -4882,7 +4889,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; wl->system_hlid = WL12XX_SYSTEM_HLID; wl->sta_hlid = WL12XX_INVALID_LINK_ID; - wl->dev_role_id = WL12XX_INVALID_ROLE_ID; wl->dev_hlid = WL12XX_INVALID_LINK_ID; wl->session_counter = 0; wl->ap_bcast_hlid = WL12XX_INVALID_LINK_ID; diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index 9d0dfb516e26..9372136b27e4 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -34,6 +34,7 @@ void wl1271_scan_complete_work(struct work_struct *work) { struct delayed_work *dwork; struct wl1271 *wl; + struct ieee80211_vif *vif; struct wl12xx_vif *wlvif; int ret; bool is_sta, is_ibss; @@ -51,7 +52,8 @@ void wl1271_scan_complete_work(struct work_struct *work) if (wl->scan.state == WL1271_SCAN_STATE_IDLE) goto out; - wlvif = wl12xx_vif_to_data(wl->scan_vif); + vif = wl->scan_vif; + wlvif = wl12xx_vif_to_data(vif); wl->scan.state = WL1271_SCAN_STATE_IDLE; memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch)); @@ -72,10 +74,10 @@ void wl1271_scan_complete_work(struct work_struct *work) is_ibss = (wlvif->bss_type == BSS_TYPE_IBSS); if (((is_sta && !test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) || (is_ibss && !test_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags))) && - !test_bit(wl->dev_role_id, wl->roc_map)) { + !test_bit(wlvif->dev_role_id, wl->roc_map)) { /* restore remain on channel */ - wl12xx_cmd_role_start_dev(wl); - wl12xx_roc(wl, wl->dev_role_id); + wl12xx_cmd_role_start_dev(wl, wlvif); + wl12xx_roc(wl, wlvif->dev_role_id); } wl1271_ps_elp_sleep(wl); diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 5561ec2d4b4f..538d8613b324 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -77,7 +77,8 @@ static void wl1271_free_tx_id(struct wl1271 *wl, int id) } static int wl1271_tx_update_filters(struct wl1271 *wl, - struct sk_buff *skb) + struct wl12xx_vif *wlvif, + struct sk_buff *skb) { struct ieee80211_hdr *hdr; int ret; @@ -97,11 +98,11 @@ static int wl1271_tx_update_filters(struct wl1271 *wl, goto out; wl1271_debug(DEBUG_CMD, "starting device role for roaming"); - ret = wl12xx_cmd_role_start_dev(wl); + ret = wl12xx_cmd_role_start_dev(wl, wlvif); if (ret < 0) goto out; - ret = wl12xx_roc(wl, wl->dev_role_id); + ret = wl12xx_roc(wl, wlvif->dev_role_id); if (ret < 0) goto out; out: @@ -192,7 +193,7 @@ static u8 wl1271_tx_get_hlid(struct wl1271 *wl, struct ieee80211_vif *vif, if (wlvif->bss_type == BSS_TYPE_AP_BSS) return wl12xx_tx_get_hlid_ap(wl, skb); - wl1271_tx_update_filters(wl, skb); + wl1271_tx_update_filters(wl, wlvif, skb); if ((test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags) || test_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags)) && diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index e249b459f62b..4c69ae1635fe 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -401,7 +401,6 @@ struct wl1271 { u8 mac_addr[ETH_ALEN]; int channel; - u8 dev_role_id; u8 system_hlid; u8 sta_hlid; u8 dev_hlid; @@ -622,6 +621,9 @@ struct wl12xx_vif { u8 p2p; /* we are using p2p role */ u8 role_id; + /* sta/ibss specific */ + u8 dev_role_id; + u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; u8 ssid_len; -- cgit v1.2.3 From 154da67c7da14ffd8da292394f8cbc81cc5ea4e3 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:53 +0200 Subject: wl12xx: move sta_hlid into wlvif move sta_hlid into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 28 +++++++++++++++------------- drivers/net/wireless/wl12xx/cmd.h | 3 ++- drivers/net/wireless/wl12xx/main.c | 18 +++++++++--------- drivers/net/wireless/wl12xx/tx.c | 4 ++-- drivers/net/wireless/wl12xx/wl12xx.h | 7 ++++++- 5 files changed, 34 insertions(+), 26 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 36544ff6a79b..2a9a4b2032e5 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -581,12 +581,12 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) memcpy(cmd->sta.bssid, vif->bss_conf.bssid, ETH_ALEN); cmd->sta.local_rates = cpu_to_le32(wlvif->rate_set); - if (wl->sta_hlid == WL12XX_INVALID_LINK_ID) { - ret = wl12xx_allocate_link(wl, &wl->sta_hlid); + if (wlvif->sta.hlid == WL12XX_INVALID_LINK_ID) { + ret = wl12xx_allocate_link(wl, &wlvif->sta.hlid); if (ret) goto out_free; } - cmd->sta.hlid = wl->sta_hlid; + cmd->sta.hlid = wlvif->sta.hlid; cmd->sta.session = wl12xx_get_new_session_id(wl); cmd->sta.remote_rates = cpu_to_le32(wlvif->rate_set); @@ -605,7 +605,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) err_hlid: /* clear links on error. */ - wl12xx_free_link(wl, &wl->sta_hlid); + wl12xx_free_link(wl, &wlvif->sta.hlid); out_free: kfree(cmd); @@ -620,7 +620,7 @@ int wl12xx_cmd_role_stop_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) struct wl12xx_cmd_role_stop *cmd; int ret; - if (WARN_ON(wl->sta_hlid == WL12XX_INVALID_LINK_ID)) + if (WARN_ON(wlvif->sta.hlid == WL12XX_INVALID_LINK_ID)) return -EINVAL; cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); @@ -641,7 +641,7 @@ int wl12xx_cmd_role_stop_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out_free; } - wl12xx_free_link(wl, &wl->sta_hlid); + wl12xx_free_link(wl, &wlvif->sta.hlid); out_free: kfree(cmd); @@ -796,12 +796,12 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) memcpy(cmd->ibss.bssid, vif->bss_conf.bssid, ETH_ALEN); cmd->sta.local_rates = cpu_to_le32(wlvif->rate_set); - if (wl->sta_hlid == WL12XX_INVALID_LINK_ID) { - ret = wl12xx_allocate_link(wl, &wl->sta_hlid); + if (wlvif->sta.hlid == WL12XX_INVALID_LINK_ID) { + ret = wl12xx_allocate_link(wl, &wlvif->sta.hlid); if (ret) goto out_free; } - cmd->ibss.hlid = wl->sta_hlid; + cmd->ibss.hlid = wlvif->sta.hlid; cmd->ibss.remote_rates = cpu_to_le32(wlvif->rate_set); wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d " @@ -822,7 +822,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) err_hlid: /* clear links on error. */ - wl12xx_free_link(wl, &wl->sta_hlid); + wl12xx_free_link(wl, &wlvif->sta.hlid); out_free: kfree(cmd); @@ -1264,15 +1264,17 @@ out: return ret; } -int wl1271_cmd_set_sta_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, +int wl1271_cmd_set_sta_key(struct wl1271 *wl, struct ieee80211_vif *vif, + u16 action, u8 id, u8 key_type, u8 key_size, const u8 *key, const u8 *addr, u32 tx_seq_32, u16 tx_seq_16) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct wl1271_cmd_set_keys *cmd; int ret = 0; /* hlid might have already been deleted */ - if (wl->sta_hlid == WL12XX_INVALID_LINK_ID) + if (wlvif->sta.hlid == WL12XX_INVALID_LINK_ID) return 0; cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); @@ -1281,7 +1283,7 @@ int wl1271_cmd_set_sta_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, goto out; } - cmd->hlid = wl->sta_hlid; + cmd->hlid = wlvif->sta.hlid; if (key_type == KEY_WEP) cmd->lid_key_type = WEP_DEFAULT_LID_TYPE; diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index fb40556a8ad1..25ab400f2ebd 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -70,7 +70,8 @@ int wl1271_build_qos_null_data(struct wl1271 *wl, struct ieee80211_vif *vif); int wl12xx_cmd_build_klv_null_data(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_set_default_wep_key(struct wl1271 *wl, u8 id, u8 hlid); -int wl1271_cmd_set_sta_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, +int wl1271_cmd_set_sta_key(struct wl1271 *wl, struct ieee80211_vif *vif, + u16 action, u8 id, u8 key_type, u8 key_size, const u8 *key, const u8 *addr, u32 tx_seq_32, u16 tx_seq_16); int wl1271_cmd_set_ap_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index f4d3df15719b..3358cfe5b019 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -412,7 +412,7 @@ static int wl1271_check_operstate(struct wl1271 *wl, unsigned char operstate) if (test_and_set_bit(WL1271_FLAG_STA_STATE_SENT, &wl->flags)) return 0; - ret = wl12xx_cmd_set_peer_state(wl, wl->sta_hlid); + ret = wl12xx_cmd_set_peer_state(wl, wlvif->sta.hlid); if (ret < 0) return ret; @@ -1858,6 +1858,7 @@ static void wl12xx_init_vif_data(struct wl12xx_vif *wlvif) wlvif->bss_type = MAX_BSS_TYPE; wlvif->role_id = WL12XX_INVALID_ROLE_ID; wlvif->dev_role_id = WL12XX_INVALID_ROLE_ID; + wlvif->sta.hlid = WL12XX_INVALID_LINK_ID; wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC; wlvif->basic_rate = CONF_TX_RATE_MASK_BASIC; wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; @@ -2081,7 +2082,7 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, } deinit: /* clear all hlids (except system_hlid) */ - wl->sta_hlid = WL12XX_INVALID_LINK_ID; + wlvif->sta.hlid = WL12XX_INVALID_LINK_ID; wl->dev_hlid = WL12XX_INVALID_LINK_ID; wl->ap_bcast_hlid = WL12XX_INVALID_LINK_ID; wl->ap_global_hlid = WL12XX_INVALID_LINK_ID; @@ -2765,10 +2766,10 @@ static int wl1271_set_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, /* don't remove key if hlid was already deleted */ if (action == KEY_REMOVE && - wl->sta_hlid == WL12XX_INVALID_LINK_ID) + wlvif->sta.hlid == WL12XX_INVALID_LINK_ID) return 0; - ret = wl1271_cmd_set_sta_key(wl, action, + ret = wl1271_cmd_set_sta_key(wl, vif, action, id, key_type, key_size, key, addr, tx_seq_32, tx_seq_16); @@ -2779,7 +2780,7 @@ static int wl1271_set_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (key_type == KEY_WEP) { ret = wl12xx_cmd_set_default_wep_key(wl, wl->default_key, - wl->sta_hlid); + wlvif->sta.hlid); if (ret < 0) return ret; } @@ -3731,7 +3732,7 @@ sta_not_found: ret = wl1271_acx_set_ht_capabilities(wl, &sta_ht_cap, true, - wl->sta_hlid); + wlvif->sta.hlid); if (ret < 0) { wl1271_warning("Set ht cap true failed %d", ret); @@ -3743,7 +3744,7 @@ sta_not_found: ret = wl1271_acx_set_ht_capabilities(wl, &sta_ht_cap, false, - wl->sta_hlid); + wlvif->sta.hlid); if (ret < 0) { wl1271_warning("Set ht cap false failed %d", ret); @@ -4080,7 +4081,7 @@ static int wl1271_op_ampdu_action(struct ieee80211_hw *hw, } if (wlvif->bss_type == BSS_TYPE_STA_BSS) { - hlid = wl->sta_hlid; + hlid = wlvif->sta.hlid; ba_bitmap = &wl->ba_rx_bitmap; } else if (wlvif->bss_type == BSS_TYPE_AP_BSS) { struct wl1271_station *wl_sta; @@ -4888,7 +4889,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->tx_security_last_seq_lsb = 0; wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; wl->system_hlid = WL12XX_SYSTEM_HLID; - wl->sta_hlid = WL12XX_INVALID_LINK_ID; wl->dev_hlid = WL12XX_INVALID_LINK_ID; wl->session_counter = 0; wl->ap_bcast_hlid = WL12XX_INVALID_LINK_ID; diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 538d8613b324..db55767d7d54 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -42,7 +42,7 @@ static int wl1271_set_default_wep_key(struct wl1271 *wl, ret = wl12xx_cmd_set_default_wep_key(wl, id, wl->ap_bcast_hlid); else - ret = wl12xx_cmd_set_default_wep_key(wl, id, wl->sta_hlid); + ret = wl12xx_cmd_set_default_wep_key(wl, id, wlvif->sta.hlid); if (ret < 0) return ret; @@ -199,7 +199,7 @@ static u8 wl1271_tx_get_hlid(struct wl1271 *wl, struct ieee80211_vif *vif, test_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags)) && !ieee80211_is_auth(hdr->frame_control) && !ieee80211_is_assoc_req(hdr->frame_control)) - return wl->sta_hlid; + return wlvif->sta.hlid; else return wl->dev_hlid; } diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 4c69ae1635fe..a1084d1466bb 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -402,7 +402,6 @@ struct wl1271 { u8 mac_addr[ETH_ALEN]; int channel; u8 system_hlid; - u8 sta_hlid; u8 dev_hlid; u8 ap_global_hlid; u8 ap_bcast_hlid; @@ -624,6 +623,12 @@ struct wl12xx_vif { /* sta/ibss specific */ u8 dev_role_id; + union { + struct { + u8 hlid; + } sta; + }; + u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; u8 ssid_len; -- cgit v1.2.3 From a8ab39a4b588e8523be2fa75671bdc9612d3467a Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:54 +0200 Subject: wl12xx: move ap_global_hlid and ap_bcast_hlid into wlvif move ap_global_hlid and ap_bcast_hlid into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 28 ++++++++++++++-------------- drivers/net/wireless/wl12xx/cmd.h | 5 +++-- drivers/net/wireless/wl12xx/main.c | 34 +++++++++++++++++++--------------- drivers/net/wireless/wl12xx/tx.c | 15 ++++++++------- drivers/net/wireless/wl12xx/tx.h | 3 ++- drivers/net/wireless/wl12xx/wl12xx.h | 6 ++++-- 6 files changed, 50 insertions(+), 41 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 2a9a4b2032e5..d0124e63dad1 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -671,19 +671,19 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out; } - ret = wl12xx_allocate_link(wl, &wl->ap_global_hlid); + ret = wl12xx_allocate_link(wl, &wlvif->ap.global_hlid); if (ret < 0) goto out_free; - ret = wl12xx_allocate_link(wl, &wl->ap_bcast_hlid); + ret = wl12xx_allocate_link(wl, &wlvif->ap.bcast_hlid); if (ret < 0) goto out_free_global; cmd->role_id = wlvif->role_id; cmd->ap.aging_period = cpu_to_le16(wl->conf.tx.ap_aging_period); cmd->ap.bss_index = WL1271_AP_BSS_INDEX; - cmd->ap.global_hlid = wl->ap_global_hlid; - cmd->ap.broadcast_hlid = wl->ap_bcast_hlid; + cmd->ap.global_hlid = wlvif->ap.global_hlid; + cmd->ap.broadcast_hlid = wlvif->ap.bcast_hlid; cmd->ap.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set); cmd->ap.beacon_interval = cpu_to_le16(wl->beacon_int); cmd->ap.dtim_interval = bss_conf->dtim_period; @@ -725,10 +725,10 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out_free; out_free_bcast: - wl12xx_free_link(wl, &wl->ap_bcast_hlid); + wl12xx_free_link(wl, &wlvif->ap.bcast_hlid); out_free_global: - wl12xx_free_link(wl, &wl->ap_global_hlid); + wl12xx_free_link(wl, &wlvif->ap.global_hlid); out_free: kfree(cmd); @@ -758,8 +758,8 @@ int wl12xx_cmd_role_stop_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out_free; } - wl12xx_free_link(wl, &wl->ap_bcast_hlid); - wl12xx_free_link(wl, &wl->ap_global_hlid); + wl12xx_free_link(wl, &wlvif->ap.bcast_hlid); + wl12xx_free_link(wl, &wlvif->ap.global_hlid); out_free: kfree(cmd); @@ -1264,12 +1264,11 @@ out: return ret; } -int wl1271_cmd_set_sta_key(struct wl1271 *wl, struct ieee80211_vif *vif, +int wl1271_cmd_set_sta_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, u16 action, u8 id, u8 key_type, u8 key_size, const u8 *key, const u8 *addr, u32 tx_seq_32, u16 tx_seq_16) { - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct wl1271_cmd_set_keys *cmd; int ret = 0; @@ -1334,9 +1333,10 @@ out: * TODO: merge with sta/ibss into 1 set_key function. * note there are slight diffs */ -int wl1271_cmd_set_ap_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, - u8 key_size, const u8 *key, u8 hlid, u32 tx_seq_32, - u16 tx_seq_16) +int wl1271_cmd_set_ap_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u16 action, u8 id, u8 key_type, + u8 key_size, const u8 *key, u8 hlid, u32 tx_seq_32, + u16 tx_seq_16) { struct wl1271_cmd_set_keys *cmd; int ret = 0; @@ -1346,7 +1346,7 @@ int wl1271_cmd_set_ap_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, if (!cmd) return -ENOMEM; - if (hlid == wl->ap_bcast_hlid) { + if (hlid == wlvif->ap.bcast_hlid) { if (key_type == KEY_WEP) lid_type = WEP_DEFAULT_LID_TYPE; else diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index 25ab400f2ebd..9624828b76e8 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -70,11 +70,12 @@ int wl1271_build_qos_null_data(struct wl1271 *wl, struct ieee80211_vif *vif); int wl12xx_cmd_build_klv_null_data(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_set_default_wep_key(struct wl1271 *wl, u8 id, u8 hlid); -int wl1271_cmd_set_sta_key(struct wl1271 *wl, struct ieee80211_vif *vif, +int wl1271_cmd_set_sta_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, u16 action, u8 id, u8 key_type, u8 key_size, const u8 *key, const u8 *addr, u32 tx_seq_32, u16 tx_seq_16); -int wl1271_cmd_set_ap_key(struct wl1271 *wl, u16 action, u8 id, u8 key_type, +int wl1271_cmd_set_ap_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u16 action, u8 id, u8 key_type, u8 key_size, const u8 *key, u8 hlid, u32 tx_seq_32, u16 tx_seq_16); int wl12xx_cmd_set_peer_state(struct wl1271 *wl, u8 hlid); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 3358cfe5b019..731e34bc275a 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1488,8 +1488,9 @@ int wl1271_plt_stop(struct wl1271 *wl) static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { struct wl1271 *wl = hw->priv; - struct ieee80211_tx_info *control = IEEE80211_SKB_CB(skb); - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(control->control.vif); + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct ieee80211_vif *vif = info->control.vif; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); unsigned long flags; int q, mapping; u8 hlid = 0; @@ -1498,7 +1499,7 @@ static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) q = wl1271_tx_get_queue(mapping); if (wlvif->bss_type == BSS_TYPE_AP_BSS) - hlid = wl12xx_tx_get_hlid_ap(wl, skb); + hlid = wl12xx_tx_get_hlid_ap(wl, wlvif, skb); spin_lock_irqsave(&wl->wl_lock, flags); @@ -1858,7 +1859,12 @@ static void wl12xx_init_vif_data(struct wl12xx_vif *wlvif) wlvif->bss_type = MAX_BSS_TYPE; wlvif->role_id = WL12XX_INVALID_ROLE_ID; wlvif->dev_role_id = WL12XX_INVALID_ROLE_ID; + + /* TODO: init union by type */ wlvif->sta.hlid = WL12XX_INVALID_LINK_ID; + wlvif->ap.bcast_hlid = WL12XX_INVALID_LINK_ID; + wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID; + wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC; wlvif->basic_rate = CONF_TX_RATE_MASK_BASIC; wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; @@ -2084,8 +2090,8 @@ deinit: /* clear all hlids (except system_hlid) */ wlvif->sta.hlid = WL12XX_INVALID_LINK_ID; wl->dev_hlid = WL12XX_INVALID_LINK_ID; - wl->ap_bcast_hlid = WL12XX_INVALID_LINK_ID; - wl->ap_global_hlid = WL12XX_INVALID_LINK_ID; + wlvif->ap.bcast_hlid = WL12XX_INVALID_LINK_ID; + wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID; /* * this must be before the cancel_work calls below, so that the work @@ -2653,7 +2659,7 @@ static void wl1271_free_ap_keys(struct wl1271 *wl) } } -static int wl1271_ap_init_hwenc(struct wl1271 *wl) +static int wl1271_ap_init_hwenc(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int i, ret = 0; struct wl1271_ap_key *key; @@ -2667,9 +2673,9 @@ static int wl1271_ap_init_hwenc(struct wl1271 *wl) key = wl->recorded_ap_keys[i]; hlid = key->hlid; if (hlid == WL12XX_INVALID_LINK_ID) - hlid = wl->ap_bcast_hlid; + hlid = wlvif->ap.bcast_hlid; - ret = wl1271_cmd_set_ap_key(wl, KEY_ADD_OR_REPLACE, + ret = wl1271_cmd_set_ap_key(wl, wlvif, KEY_ADD_OR_REPLACE, key->id, key->key_type, key->key_size, key->key, hlid, key->tx_seq_32, @@ -2683,7 +2689,7 @@ static int wl1271_ap_init_hwenc(struct wl1271 *wl) if (wep_key_added) { ret = wl12xx_cmd_set_default_wep_key(wl, wl->default_key, - wl->ap_bcast_hlid); + wlvif->ap.bcast_hlid); if (ret < 0) goto out; } @@ -2709,7 +2715,7 @@ static int wl1271_set_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, wl_sta = (struct wl1271_station *)sta->drv_priv; hlid = wl_sta->hlid; } else { - hlid = wl->ap_bcast_hlid; + hlid = wlvif->ap.bcast_hlid; } if (!test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) { @@ -2725,7 +2731,7 @@ static int wl1271_set_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, key, hlid, tx_seq_32, tx_seq_16); } else { - ret = wl1271_cmd_set_ap_key(wl, action, + ret = wl1271_cmd_set_ap_key(wl, wlvif, action, id, key_type, key_size, key, hlid, tx_seq_32, tx_seq_16); @@ -2769,7 +2775,7 @@ static int wl1271_set_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, wlvif->sta.hlid == WL12XX_INVALID_LINK_ID) return 0; - ret = wl1271_cmd_set_sta_key(wl, vif, action, + ret = wl1271_cmd_set_sta_key(wl, wlvif, action, id, key_type, key_size, key, addr, tx_seq_32, tx_seq_16); @@ -3375,7 +3381,7 @@ static void wl1271_bss_info_changed_ap(struct wl1271 *wl, if (ret < 0) goto out; - ret = wl1271_ap_init_hwenc(wl); + ret = wl1271_ap_init_hwenc(wl, wlvif); if (ret < 0) goto out; @@ -4891,8 +4897,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->system_hlid = WL12XX_SYSTEM_HLID; wl->dev_hlid = WL12XX_INVALID_LINK_ID; wl->session_counter = 0; - wl->ap_bcast_hlid = WL12XX_INVALID_LINK_ID; - wl->ap_global_hlid = WL12XX_INVALID_LINK_ID; wl->active_sta_count = 0; setup_timer(&wl->rx_streaming_timer, wl1271_rx_streaming_timer, (unsigned long) wl); diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index db55767d7d54..53c6451a8fde 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -40,7 +40,7 @@ static int wl1271_set_default_wep_key(struct wl1271 *wl, if (is_ap) ret = wl12xx_cmd_set_default_wep_key(wl, id, - wl->ap_bcast_hlid); + wlvif->ap.bcast_hlid); else ret = wl12xx_cmd_set_default_wep_key(wl, id, wlvif->sta.hlid); @@ -156,7 +156,8 @@ bool wl12xx_is_dummy_packet(struct wl1271 *wl, struct sk_buff *skb) return wl->dummy_packet == skb; } -u8 wl12xx_tx_get_hlid_ap(struct wl1271 *wl, struct sk_buff *skb) +u8 wl12xx_tx_get_hlid_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif, + struct sk_buff *skb) { struct ieee80211_tx_info *control = IEEE80211_SKB_CB(skb); @@ -174,9 +175,9 @@ u8 wl12xx_tx_get_hlid_ap(struct wl1271 *wl, struct sk_buff *skb) hdr = (struct ieee80211_hdr *)skb->data; if (ieee80211_is_mgmt(hdr->frame_control)) - return wl->ap_global_hlid; + return wlvif->ap.global_hlid; else - return wl->ap_bcast_hlid; + return wlvif->ap.bcast_hlid; } } @@ -191,7 +192,7 @@ static u8 wl1271_tx_get_hlid(struct wl1271 *wl, struct ieee80211_vif *vif, return wl->system_hlid; if (wlvif->bss_type == BSS_TYPE_AP_BSS) - return wl12xx_tx_get_hlid_ap(wl, skb); + return wl12xx_tx_get_hlid_ap(wl, wlvif, skb); wl1271_tx_update_filters(wl, wlvif, skb); @@ -341,9 +342,9 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct ieee80211_vif *vif, else rate_idx = ACX_TX_BASIC_RATE; } else { - if (hlid == wl->ap_global_hlid) + if (hlid == wlvif->ap.global_hlid) rate_idx = ACX_TX_AP_MODE_MGMT_RATE; - else if (hlid == wl->ap_bcast_hlid) + else if (hlid == wlvif->ap.bcast_hlid) rate_idx = ACX_TX_AP_MODE_BCST_RATE; else rate_idx = ac; diff --git a/drivers/net/wireless/wl12xx/tx.h b/drivers/net/wireless/wl12xx/tx.h index ba9403a45404..0964c9335316 100644 --- a/drivers/net/wireless/wl12xx/tx.h +++ b/drivers/net/wireless/wl12xx/tx.h @@ -212,7 +212,8 @@ u8 wl1271_rate_to_idx(int rate, enum ieee80211_band band); u32 wl1271_tx_enabled_rates_get(struct wl1271 *wl, u32 rate_set, enum ieee80211_band rate_band); u32 wl1271_tx_min_rate_get(struct wl1271 *wl, u32 rate_set); -u8 wl12xx_tx_get_hlid_ap(struct wl1271 *wl, struct sk_buff *skb); +u8 wl12xx_tx_get_hlid_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif, + struct sk_buff *skb); void wl1271_tx_reset_link_queues(struct wl1271 *wl, u8 hlid); void wl1271_handle_tx_low_watermark(struct wl1271 *wl); bool wl12xx_is_dummy_packet(struct wl1271 *wl, struct sk_buff *skb); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index a1084d1466bb..aa84899466a8 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -403,8 +403,6 @@ struct wl1271 { int channel; u8 system_hlid; u8 dev_hlid; - u8 ap_global_hlid; - u8 ap_bcast_hlid; unsigned long links_map[BITS_TO_LONGS(WL12XX_MAX_LINKS)]; unsigned long roles_map[BITS_TO_LONGS(WL12XX_MAX_ROLES)]; @@ -627,6 +625,10 @@ struct wl12xx_vif { struct { u8 hlid; } sta; + struct { + u8 global_hlid; + u8 bcast_hlid; + } ap; }; u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; -- cgit v1.2.3 From 98b8625301e55bd3e4340f704edc378e4707e577 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:55 +0200 Subject: wl12xx: move session_counter into wlvif move session_counter into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 15 ++++++++------- drivers/net/wireless/wl12xx/debugfs.c | 1 - drivers/net/wireless/wl12xx/main.c | 2 -- drivers/net/wireless/wl12xx/tx.c | 6 +++--- drivers/net/wireless/wl12xx/wl12xx.h | 9 +++++---- 5 files changed, 16 insertions(+), 17 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index d0124e63dad1..89d263e7b569 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -454,14 +454,15 @@ static void wl12xx_free_link(struct wl1271 *wl, u8 *hlid) *hlid = WL12XX_INVALID_LINK_ID; } -static int wl12xx_get_new_session_id(struct wl1271 *wl) +static int wl12xx_get_new_session_id(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { - if (wl->session_counter >= SESSION_COUNTER_MAX) - wl->session_counter = 0; + if (wlvif->session_counter >= SESSION_COUNTER_MAX) + wlvif->session_counter = 0; - wl->session_counter++; + wlvif->session_counter++; - return wl->session_counter; + return wlvif->session_counter; } int wl12xx_cmd_role_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) @@ -488,7 +489,7 @@ int wl12xx_cmd_role_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out_free; } cmd->device.hlid = wl->dev_hlid; - cmd->device.session = wl->session_counter; + cmd->device.session = wlvif->session_counter; wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d", cmd->role_id, cmd->device.hlid, cmd->device.session); @@ -587,7 +588,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out_free; } cmd->sta.hlid = wlvif->sta.hlid; - cmd->sta.session = wl12xx_get_new_session_id(wl); + cmd->sta.session = wl12xx_get_new_session_id(wl, wlvif); cmd->sta.remote_rates = cpu_to_le32(wlvif->rate_set); wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d " diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 3309fea2e90e..d8d856823651 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -348,7 +348,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, DRIVER_STATE_PRINT_INT(tx_blocks_freed); DRIVER_STATE_PRINT_INT(tx_security_last_seq_lsb); DRIVER_STATE_PRINT_INT(rx_counter); - DRIVER_STATE_PRINT_INT(session_counter); DRIVER_STATE_PRINT_INT(state); DRIVER_STATE_PRINT_INT(channel); DRIVER_STATE_PRINT_INT(band); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 731e34bc275a..63871b46c0c1 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2128,7 +2128,6 @@ deinit: wl->tx_results_count = 0; wl->tx_packets_count = 0; wl->time_offset = 0; - wl->session_counter = 0; wl->bitrate_masks[IEEE80211_BAND_2GHZ] = wl->conf.tx.basic_rate; wl->bitrate_masks[IEEE80211_BAND_5GHZ] = wl->conf.tx.basic_rate_5; wl->vif = NULL; @@ -4896,7 +4895,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; wl->system_hlid = WL12XX_SYSTEM_HLID; wl->dev_hlid = WL12XX_INVALID_LINK_ID; - wl->session_counter = 0; wl->active_sta_count = 0; setup_timer(&wl->rx_streaming_timer, wl1271_rx_streaming_timer, (unsigned long) wl); diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 53c6451a8fde..da8427f5d7a8 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -321,15 +321,15 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct ieee80211_vif *vif, * FW expects the dummy packet to have an invalid session id - * any session id that is different than the one set in the join */ - tx_attr = ((~wl->session_counter) << + tx_attr = (SESSION_COUNTER_INVALID << TX_HW_ATTR_OFST_SESSION_COUNTER) & TX_HW_ATTR_SESSION_COUNTER; tx_attr |= TX_HW_ATTR_TX_DUMMY_REQ; } else { /* configure the tx attributes */ - tx_attr = - wl->session_counter << TX_HW_ATTR_OFST_SESSION_COUNTER; + tx_attr = wlvif->session_counter << + TX_HW_ATTR_OFST_SESSION_COUNTER; } desc->hlid = hlid; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index aa84899466a8..9fcaa03cd737 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -429,9 +429,6 @@ struct wl1271 { /* Time-offset between host and chipset clocks */ s64 time_offset; - /* Session counter for the chipset */ - int session_counter; - /* Frames scheduled for transmission, not handled yet */ struct sk_buff_head tx_queue[NUM_TX_QUEUES]; int tx_queue_count[NUM_TX_QUEUES]; @@ -650,6 +647,9 @@ struct wl12xx_vif { /* Our association ID */ u16 aid; + + /* Session counter for the chipset */ + int session_counter; }; static inline struct wl12xx_vif *wl12xx_vif_to_data(struct ieee80211_vif *vif) @@ -671,7 +671,8 @@ size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen); #define JOIN_TIMEOUT 5000 /* 5000 milliseconds to join */ -#define SESSION_COUNTER_MAX 7 /* maximum value for the session counter */ +#define SESSION_COUNTER_MAX 6 /* maximum value for the session counter */ +#define SESSION_COUNTER_INVALID 7 /* used with dummy_packet */ #define WL1271_DEFAULT_POWER_LEVEL 0 -- cgit v1.2.3 From e936bbe0dc235458408c060deaa43f5b8b0bd705 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:56 +0200 Subject: wl12xx: move some logic into wl12xx_init_vif_data Initialize the vif data according to the vif type Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 66 +++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 26 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 63871b46c0c1..effba53eb3f4 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1854,20 +1854,52 @@ static u8 wl12xx_get_role_type(struct wl1271 *wl, struct wl12xx_vif *wlvif) return WL12XX_INVALID_ROLE_TYPE; } -static void wl12xx_init_vif_data(struct wl12xx_vif *wlvif) +static int wl12xx_init_vif_data(struct ieee80211_vif *vif) { - wlvif->bss_type = MAX_BSS_TYPE; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + + /* make sure wlvif is zeroed */ + memset(wlvif, 0, sizeof(*wlvif)); + + switch (ieee80211_vif_type_p2p(vif)) { + case NL80211_IFTYPE_P2P_CLIENT: + wlvif->p2p = 1; + /* fall-through */ + case NL80211_IFTYPE_STATION: + wlvif->bss_type = BSS_TYPE_STA_BSS; + break; + case NL80211_IFTYPE_ADHOC: + wlvif->bss_type = BSS_TYPE_IBSS; + break; + case NL80211_IFTYPE_P2P_GO: + wlvif->p2p = 1; + /* fall-through */ + case NL80211_IFTYPE_AP: + wlvif->bss_type = BSS_TYPE_AP_BSS; + break; + default: + wlvif->bss_type = MAX_BSS_TYPE; + return -EOPNOTSUPP; + } + wlvif->role_id = WL12XX_INVALID_ROLE_ID; wlvif->dev_role_id = WL12XX_INVALID_ROLE_ID; - /* TODO: init union by type */ - wlvif->sta.hlid = WL12XX_INVALID_LINK_ID; - wlvif->ap.bcast_hlid = WL12XX_INVALID_LINK_ID; - wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID; + if (wlvif->bss_type == BSS_TYPE_STA_BSS || + wlvif->bss_type == BSS_TYPE_IBSS) { + /* init sta/ibss data */ + wlvif->sta.hlid = WL12XX_INVALID_LINK_ID; + + } else { + /* init ap data */ + wlvif->ap.bcast_hlid = WL12XX_INVALID_LINK_ID; + wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID; + } wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC; wlvif->basic_rate = CONF_TX_RATE_MASK_BASIC; wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; + return 0; } static int wl1271_op_add_interface(struct ieee80211_hw *hw, @@ -1891,7 +1923,6 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, ret = -EBUSY; goto out; } - wl12xx_init_vif_data(wlvif); /* * in some very corner case HW recovery scenarios its possible to @@ -1903,26 +1934,9 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, goto out; } - switch (ieee80211_vif_type_p2p(vif)) { - case NL80211_IFTYPE_P2P_CLIENT: - wlvif->p2p = 1; - /* fall-through */ - case NL80211_IFTYPE_STATION: - wlvif->bss_type = BSS_TYPE_STA_BSS; - break; - case NL80211_IFTYPE_ADHOC: - wlvif->bss_type = BSS_TYPE_IBSS; - break; - case NL80211_IFTYPE_P2P_GO: - wlvif->p2p = 1; - /* fall-through */ - case NL80211_IFTYPE_AP: - wlvif->bss_type = BSS_TYPE_AP_BSS; - break; - default: - ret = -EOPNOTSUPP; + ret = wl12xx_init_vif_data(vif); + if (ret < 0) goto out; - } role_type = wl12xx_get_role_type(wl, wlvif); if (role_type == WL12XX_INVALID_ROLE_TYPE) { -- cgit v1.2.3 From afaf8bdb2b08bbf493b03757243821df72b26c53 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:57 +0200 Subject: wl12xx: move dev_hlid into wlvif move dev_hlid into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 14 ++++++-------- drivers/net/wireless/wl12xx/main.c | 4 ++-- drivers/net/wireless/wl12xx/tx.c | 4 ++-- drivers/net/wireless/wl12xx/wl12xx.h | 2 +- 4 files changed, 11 insertions(+), 13 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 89d263e7b569..166d984cb5af 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -483,12 +483,12 @@ int wl12xx_cmd_role_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->band = WL12XX_BAND_5GHZ; cmd->channel = wl->channel; - if (wl->dev_hlid == WL12XX_INVALID_LINK_ID) { - ret = wl12xx_allocate_link(wl, &wl->dev_hlid); + if (wlvif->dev_hlid == WL12XX_INVALID_LINK_ID) { + ret = wl12xx_allocate_link(wl, &wlvif->dev_hlid); if (ret) goto out_free; } - cmd->device.hlid = wl->dev_hlid; + cmd->device.hlid = wlvif->dev_hlid; cmd->device.session = wlvif->session_counter; wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d", @@ -504,9 +504,7 @@ int wl12xx_cmd_role_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) err_hlid: /* clear links on error */ - __clear_bit(wl->dev_hlid, wl->links_map); - wl->dev_hlid = WL12XX_INVALID_LINK_ID; - + wl12xx_free_link(wl, &wlvif->dev_hlid); out_free: kfree(cmd); @@ -520,7 +518,7 @@ int wl12xx_cmd_role_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) struct wl12xx_cmd_role_stop *cmd; int ret; - if (WARN_ON(wl->dev_hlid == WL12XX_INVALID_LINK_ID)) + if (WARN_ON(wlvif->dev_hlid == WL12XX_INVALID_LINK_ID)) return -EINVAL; cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); @@ -547,7 +545,7 @@ int wl12xx_cmd_role_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out_free; } - wl12xx_free_link(wl, &wl->dev_hlid); + wl12xx_free_link(wl, &wlvif->dev_hlid); out_free: kfree(cmd); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index effba53eb3f4..e8d73d70cedf 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1884,6 +1884,7 @@ static int wl12xx_init_vif_data(struct ieee80211_vif *vif) wlvif->role_id = WL12XX_INVALID_ROLE_ID; wlvif->dev_role_id = WL12XX_INVALID_ROLE_ID; + wlvif->dev_hlid = WL12XX_INVALID_LINK_ID; if (wlvif->bss_type == BSS_TYPE_STA_BSS || wlvif->bss_type == BSS_TYPE_IBSS) { @@ -2103,7 +2104,7 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, deinit: /* clear all hlids (except system_hlid) */ wlvif->sta.hlid = WL12XX_INVALID_LINK_ID; - wl->dev_hlid = WL12XX_INVALID_LINK_ID; + wlvif->dev_hlid = WL12XX_INVALID_LINK_ID; wlvif->ap.bcast_hlid = WL12XX_INVALID_LINK_ID; wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID; @@ -4908,7 +4909,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->tx_security_last_seq_lsb = 0; wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; wl->system_hlid = WL12XX_SYSTEM_HLID; - wl->dev_hlid = WL12XX_INVALID_LINK_ID; wl->active_sta_count = 0; setup_timer(&wl->rx_streaming_timer, wl1271_rx_streaming_timer, (unsigned long) wl); diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index da8427f5d7a8..8db68c649437 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -94,7 +94,7 @@ static int wl1271_tx_update_filters(struct wl1271 *wl, if (!ieee80211_is_auth(hdr->frame_control)) return 0; - if (wl->dev_hlid != WL12XX_INVALID_LINK_ID) + if (wlvif->dev_hlid != WL12XX_INVALID_LINK_ID) goto out; wl1271_debug(DEBUG_CMD, "starting device role for roaming"); @@ -202,7 +202,7 @@ static u8 wl1271_tx_get_hlid(struct wl1271 *wl, struct ieee80211_vif *vif, !ieee80211_is_assoc_req(hdr->frame_control)) return wlvif->sta.hlid; else - return wl->dev_hlid; + return wlvif->dev_hlid; } static unsigned int wl12xx_calc_packet_alignment(struct wl1271 *wl, diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 9fcaa03cd737..752b6b99210c 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -402,7 +402,6 @@ struct wl1271 { u8 mac_addr[ETH_ALEN]; int channel; u8 system_hlid; - u8 dev_hlid; unsigned long links_map[BITS_TO_LONGS(WL12XX_MAX_LINKS)]; unsigned long roles_map[BITS_TO_LONGS(WL12XX_MAX_ROLES)]; @@ -617,6 +616,7 @@ struct wl12xx_vif { /* sta/ibss specific */ u8 dev_role_id; + u8 dev_hlid; union { struct { -- cgit v1.2.3 From 6a8997964366f51c39d8efcfdc0e6319b2bd01fa Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:58 +0200 Subject: wl12xx: move beacon_int into wlvif move beacon_int into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 6 +++--- drivers/net/wireless/wl12xx/debugfs.c | 1 - drivers/net/wireless/wl12xx/main.c | 5 +++-- drivers/net/wireless/wl12xx/wl12xx.h | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 166d984cb5af..68375ffb4123 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -573,7 +573,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->band = WL12XX_BAND_5GHZ; cmd->channel = wl->channel; cmd->sta.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set); - cmd->sta.beacon_interval = cpu_to_le16(wl->beacon_int); + cmd->sta.beacon_interval = cpu_to_le16(wlvif->beacon_int); cmd->sta.ssid_type = WL12XX_SSID_TYPE_ANY; cmd->sta.ssid_len = wlvif->ssid_len; memcpy(cmd->sta.ssid, wlvif->ssid, wlvif->ssid_len); @@ -684,7 +684,7 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->ap.global_hlid = wlvif->ap.global_hlid; cmd->ap.broadcast_hlid = wlvif->ap.bcast_hlid; cmd->ap.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set); - cmd->ap.beacon_interval = cpu_to_le16(wl->beacon_int); + cmd->ap.beacon_interval = cpu_to_le16(wlvif->beacon_int); cmd->ap.dtim_interval = bss_conf->dtim_period; cmd->ap.beacon_expiry = WL1271_AP_DEF_BEACON_EXP; cmd->channel = wl->channel; @@ -787,7 +787,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->band = WL12XX_BAND_5GHZ; cmd->channel = wl->channel; cmd->ibss.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set); - cmd->ibss.beacon_interval = cpu_to_le16(wl->beacon_int); + cmd->ibss.beacon_interval = cpu_to_le16(wlvif->beacon_int); cmd->ibss.dtim_interval = bss_conf->dtim_period; cmd->ibss.ssid_type = WL12XX_SSID_TYPE_ANY; cmd->ibss.ssid_len = wlvif->ssid_len; diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index d8d856823651..439db1f8d277 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -351,7 +351,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, DRIVER_STATE_PRINT_INT(state); DRIVER_STATE_PRINT_INT(channel); DRIVER_STATE_PRINT_INT(band); - DRIVER_STATE_PRINT_INT(beacon_int); DRIVER_STATE_PRINT_INT(psm_entry_retry); DRIVER_STATE_PRINT_INT(ps_poll_failures); DRIVER_STATE_PRINT_INT(power_level); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index e8d73d70cedf..577266defe9e 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1900,6 +1900,8 @@ static int wl12xx_init_vif_data(struct ieee80211_vif *vif) wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC; wlvif->basic_rate = CONF_TX_RATE_MASK_BASIC; wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; + wlvif->beacon_int = WL1271_DEFAULT_BEACON_INT; + return 0; } @@ -3286,7 +3288,7 @@ static int wl1271_bss_beacon_info_changed(struct wl1271 *wl, wl1271_debug(DEBUG_MASTER, "beacon interval updated: %d", bss_conf->beacon_int); - wl->beacon_int = bss_conf->beacon_int; + wlvif->beacon_int = bss_conf->beacon_int; } if ((changed & BSS_CHANGED_BEACON)) { @@ -4889,7 +4891,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) } wl->channel = WL1271_DEFAULT_CHANNEL; - wl->beacon_int = WL1271_DEFAULT_BEACON_INT; wl->default_key = 0; wl->rx_counter = 0; wl->psm_entry_retry = 0; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 752b6b99210c..9d4b72e96c24 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -503,9 +503,6 @@ struct wl1271 { /* The current band */ enum ieee80211_band band; - /* Beaconing interval (needed for ad-hoc) */ - u32 beacon_int; - /* Default key (for WEP) */ u32 default_key; @@ -645,6 +642,9 @@ struct wl12xx_vif { /* probe-req template for the current AP */ struct sk_buff *probereq; + /* Beaconing interval (needed for ad-hoc) */ + u32 beacon_int; + /* Our association ID */ u16 aid; -- cgit v1.2.3 From f75c753f3c77b758fa5ace90c15b2ea3b7a3d46d Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:55:59 +0200 Subject: wl12xx: move default_key into wlvif move default_key into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 7 +++---- drivers/net/wireless/wl12xx/tx.c | 4 ++-- drivers/net/wireless/wl12xx/wl12xx.h | 6 +++--- 3 files changed, 8 insertions(+), 9 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 577266defe9e..09983dee4105 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2704,7 +2704,7 @@ static int wl1271_ap_init_hwenc(struct wl1271 *wl, struct wl12xx_vif *wlvif) } if (wep_key_added) { - ret = wl12xx_cmd_set_default_wep_key(wl, wl->default_key, + ret = wl12xx_cmd_set_default_wep_key(wl, wlvif->default_key, wlvif->ap.bcast_hlid); if (ret < 0) goto out; @@ -2801,8 +2801,8 @@ static int wl1271_set_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, /* the default WEP key needs to be configured at least once */ if (key_type == KEY_WEP) { ret = wl12xx_cmd_set_default_wep_key(wl, - wl->default_key, - wlvif->sta.hlid); + wlvif->default_key, + wlvif->sta.hlid); if (ret < 0) return ret; } @@ -4891,7 +4891,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) } wl->channel = WL1271_DEFAULT_CHANNEL; - wl->default_key = 0; wl->rx_counter = 0; wl->psm_entry_retry = 0; wl->power_level = WL1271_DEFAULT_POWER_LEVEL; diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 8db68c649437..509ae10f0e03 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -424,11 +424,11 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct sk_buff *skb, is_wep = (cipher == WLAN_CIPHER_SUITE_WEP40) || (cipher == WLAN_CIPHER_SUITE_WEP104); - if (unlikely(is_wep && wl->default_key != idx)) { + if (unlikely(is_wep && wlvif->default_key != idx)) { ret = wl1271_set_default_wep_key(wl, wlvif, idx); if (ret < 0) return ret; - wl->default_key = idx; + wlvif->default_key = idx; } } hlid = wl1271_tx_get_hlid(wl, vif, skb); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 9d4b72e96c24..91e6cd36bf8b 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -503,9 +503,6 @@ struct wl1271 { /* The current band */ enum ieee80211_band band; - /* Default key (for WEP) */ - u32 default_key; - /* Rx Streaming */ struct work_struct rx_streaming_enable_work; struct work_struct rx_streaming_disable_work; @@ -645,6 +642,9 @@ struct wl12xx_vif { /* Beaconing interval (needed for ad-hoc) */ u32 beacon_int; + /* Default key (for WEP) */ + u32 default_key; + /* Our association ID */ u16 aid; -- cgit v1.2.3 From 252efa4f978a2901039fffc934060fb8ccf82ac7 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:56:00 +0200 Subject: wl12xx: move pspoll_work into wlvif move pspoll_work into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/event.c | 8 ++++---- drivers/net/wireless/wl12xx/main.c | 8 +++++--- drivers/net/wireless/wl12xx/wl12xx.h | 4 +++- 3 files changed, 12 insertions(+), 8 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index 28a4396fb8e4..4e3474c11e05 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -38,9 +38,9 @@ void wl1271_pspoll_work(struct work_struct *work) int ret; dwork = container_of(work, struct delayed_work, work); - wl = container_of(dwork, struct wl1271, pspoll_work); - vif = wl->vif; /* TODO: move work into vif struct */ - wlvif = wl12xx_vif_to_data(vif); + wlvif = container_of(dwork, struct wl12xx_vif, pspoll_work); + vif = container_of((void *)wlvif, struct ieee80211_vif, drv_priv); + wl = wlvif->wl; wl1271_debug(DEBUG_EVENT, "pspoll work"); @@ -90,7 +90,7 @@ static void wl1271_event_pspoll_delivery_fail(struct wl1271 *wl, if (ret < 0) return; set_bit(WL1271_FLAG_PSPOLL_FAILURE, &wl->flags); - ieee80211_queue_delayed_work(wl->hw, &wl->pspoll_work, + ieee80211_queue_delayed_work(wl->hw, &wlvif->pspoll_work, msecs_to_jiffies(delay)); } diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 09983dee4105..76f466380667 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1766,7 +1766,7 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw, wl1271_enable_interrupts(wl); flush_work(&wl->tx_work); - flush_delayed_work(&wl->pspoll_work); + flush_delayed_work(&wlvif->pspoll_work); flush_delayed_work(&wl->elp_work); return 0; @@ -1902,6 +1902,8 @@ static int wl12xx_init_vif_data(struct ieee80211_vif *vif) wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; wlvif->beacon_int = WL1271_DEFAULT_BEACON_INT; + INIT_DELAYED_WORK(&wlvif->pspoll_work, wl1271_pspoll_work); + return 0; } @@ -1941,6 +1943,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, if (ret < 0) goto out; + wlvif->wl = wl; role_type = wl12xx_get_role_type(wl, wlvif); if (role_type == WL12XX_INVALID_ROLE_TYPE) { ret = -EINVAL; @@ -2126,7 +2129,7 @@ deinit: del_timer_sync(&wl->rx_streaming_timer); cancel_work_sync(&wl->rx_streaming_enable_work); cancel_work_sync(&wl->rx_streaming_disable_work); - cancel_delayed_work_sync(&wl->pspoll_work); + cancel_delayed_work_sync(&wlvif->pspoll_work); cancel_delayed_work_sync(&wl->elp_work); mutex_lock(&wl->mutex); @@ -4874,7 +4877,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) skb_queue_head_init(&wl->deferred_tx_queue); INIT_DELAYED_WORK(&wl->elp_work, wl1271_elp_work); - INIT_DELAYED_WORK(&wl->pspoll_work, wl1271_pspoll_work); INIT_WORK(&wl->netstack_work, wl1271_netstack_work); INIT_WORK(&wl->tx_work, wl1271_tx_work); INIT_WORK(&wl->recovery_work, wl1271_recovery_work); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 91e6cd36bf8b..d6d5a7bff315 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -511,7 +511,6 @@ struct wl1271 { struct completion *elp_compl; struct completion *ps_compl; struct delayed_work elp_work; - struct delayed_work pspoll_work; /* counter for ps-poll delivery failures */ int ps_poll_failures; @@ -604,6 +603,7 @@ struct wl1271_station { }; struct wl12xx_vif { + struct wl1271 *wl; u8 bss_type; u8 p2p; /* we are using p2p role */ u8 role_id; @@ -650,6 +650,8 @@ struct wl12xx_vif { /* Session counter for the chipset */ int session_counter; + + struct delayed_work pspoll_work; }; static inline struct wl12xx_vif *wl12xx_vif_to_data(struct ieee80211_vif *vif) -- cgit v1.2.3 From 6ec45dc282f6983d5685758c5e8993bc2c818d3c Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:56:01 +0200 Subject: wl12xx: move ps_compl into wlvif move ps_compl into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/event.c | 6 +++--- drivers/net/wireless/wl12xx/main.c | 2 +- drivers/net/wireless/wl12xx/wl12xx.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index 4e3474c11e05..7a9913a3f71c 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -149,9 +149,9 @@ static int wl1271_event_ps_report(struct wl1271 *wl, /* enable beacon early termination */ ret = wl1271_acx_bet_enable(wl, wlvif, true); - if (wl->ps_compl) { - complete(wl->ps_compl); - wl->ps_compl = NULL; + if (wlvif->ps_compl) { + complete(wlvif->ps_compl); + wlvif->ps_compl = NULL; } break; default: diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 76f466380667..cb2355354bf0 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1636,7 +1636,7 @@ static int wl1271_configure_suspend_sta(struct wl1271 *wl, if (!test_bit(WL1271_FLAG_PSM, &wl->flags)) { DECLARE_COMPLETION_ONSTACK(compl); - wl->ps_compl = &compl; + wlvif->ps_compl = &compl; ret = wl1271_ps_set_mode(wl, wlvif, STATION_POWER_SAVE_MODE, wlvif->basic_rate, true); if (ret < 0) diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index d6d5a7bff315..7166a79e00e4 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -509,7 +509,6 @@ struct wl1271 { struct timer_list rx_streaming_timer; struct completion *elp_compl; - struct completion *ps_compl; struct delayed_work elp_work; /* counter for ps-poll delivery failures */ @@ -651,6 +650,7 @@ struct wl12xx_vif { /* Session counter for the chipset */ int session_counter; + struct completion *ps_compl; struct delayed_work pspoll_work; }; -- cgit v1.2.3 From 74ec839557878007c3f97d1bc89e09fde5d0f3fa Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:56:02 +0200 Subject: wl12xx: move ps_poll_failures and psm_entry_retry into wlvif move ps_poll_failures and psm_entry_retries into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/debugfs.c | 2 -- drivers/net/wireless/wl12xx/event.c | 14 +++++++------- drivers/net/wireless/wl12xx/main.c | 4 +--- drivers/net/wireless/wl12xx/wl12xx.h | 12 ++++++------ 4 files changed, 14 insertions(+), 18 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 439db1f8d277..cd390e0da51d 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -351,8 +351,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, DRIVER_STATE_PRINT_INT(state); DRIVER_STATE_PRINT_INT(channel); DRIVER_STATE_PRINT_INT(band); - DRIVER_STATE_PRINT_INT(psm_entry_retry); - DRIVER_STATE_PRINT_INT(ps_poll_failures); DRIVER_STATE_PRINT_INT(power_level); DRIVER_STATE_PRINT_INT(rssi_thold); DRIVER_STATE_PRINT_INT(last_rssi_event); diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index 7a9913a3f71c..6c48b8c3f5bb 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -78,8 +78,8 @@ static void wl1271_event_pspoll_delivery_fail(struct wl1271 *wl, int delay = wl->conf.conn.ps_poll_recovery_period; int ret; - wl->ps_poll_failures++; - if (wl->ps_poll_failures == 1) + wlvif->ps_poll_failures++; + if (wlvif->ps_poll_failures == 1) wl1271_info("AP with dysfunctional ps-poll, " "trying to work around it."); @@ -118,23 +118,23 @@ static int wl1271_event_ps_report(struct wl1271 *wl, if (!test_bit(WL1271_FLAG_PSM, &wl->flags)) { /* remain in active mode */ - wl->psm_entry_retry = 0; + wlvif->psm_entry_retry = 0; break; } - if (wl->psm_entry_retry < total_retries) { - wl->psm_entry_retry++; + if (wlvif->psm_entry_retry < total_retries) { + wlvif->psm_entry_retry++; ret = wl1271_ps_set_mode(wl, wlvif, STATION_POWER_SAVE_MODE, wlvif->basic_rate, true); } else { wl1271_info("No ack to nullfunc from AP."); - wl->psm_entry_retry = 0; + wlvif->psm_entry_retry = 0; *beacon_loss = true; } break; case EVENT_ENTER_POWER_SAVE_SUCCESS: - wl->psm_entry_retry = 0; + wlvif->psm_entry_retry = 0; /* enable beacon filtering */ ret = wl1271_acx_beacon_filter_opt(wl, wlvif, true); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index cb2355354bf0..fd2b9f21acff 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2141,7 +2141,6 @@ deinit: wl->band = IEEE80211_BAND_2GHZ; wl->rx_counter = 0; - wl->psm_entry_retry = 0; wl->power_level = WL1271_DEFAULT_POWER_LEVEL; wl->tx_blocks_available = 0; wl->tx_allocated_blocks = 0; @@ -3540,7 +3539,7 @@ sta_not_found: wlvif->aid = bss_conf->aid; set_assoc = true; - wl->ps_poll_failures = 0; + wlvif->ps_poll_failures = 0; /* * use basic rates from AP, and determine lowest rate @@ -4894,7 +4893,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->channel = WL1271_DEFAULT_CHANNEL; wl->rx_counter = 0; - wl->psm_entry_retry = 0; wl->power_level = WL1271_DEFAULT_POWER_LEVEL; wl->band = IEEE80211_BAND_2GHZ; wl->vif = NULL; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 7166a79e00e4..9d9d3fbd14e5 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -511,12 +511,6 @@ struct wl1271 { struct completion *elp_compl; struct delayed_work elp_work; - /* counter for ps-poll delivery failures */ - int ps_poll_failures; - - /* retry counter for PSM entries */ - u8 psm_entry_retry; - /* in dBm */ int power_level; @@ -652,6 +646,12 @@ struct wl12xx_vif { struct completion *ps_compl; struct delayed_work pspoll_work; + + /* counter for ps-poll delivery failures */ + int ps_poll_failures; + + /* retry counter for PSM entries */ + u8 psm_entry_retry; }; static inline struct wl12xx_vif *wl12xx_vif_to_data(struct ieee80211_vif *vif) -- cgit v1.2.3 From 04324d99818d16da4f64e266b45cad2e5803b961 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:56:03 +0200 Subject: wl12xx: move rssi_thold and last_rssi_event into wlvif move rssi_thold and last_rssi_event into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/acx.c | 2 +- drivers/net/wireless/wl12xx/debugfs.c | 2 -- drivers/net/wireless/wl12xx/event.c | 12 +++++++----- drivers/net/wireless/wl12xx/main.c | 2 +- drivers/net/wireless/wl12xx/wl12xx.h | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/acx.c b/drivers/net/wireless/wl12xx/acx.c index 9b4eef61bd01..5b70cc19e1d4 100644 --- a/drivers/net/wireless/wl12xx/acx.c +++ b/drivers/net/wireless/wl12xx/acx.c @@ -1274,7 +1274,7 @@ int wl1271_acx_rssi_snr_trigger(struct wl1271 *wl, struct wl12xx_vif *wlvif, goto out; } - wl->last_rssi_event = -1; + wlvif->last_rssi_event = -1; acx->role_id = wlvif->role_id; acx->pacing = cpu_to_le16(wl->conf.roam_trigger.trigger_pacing); diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index cd390e0da51d..e53f96830c2f 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -352,8 +352,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, DRIVER_STATE_PRINT_INT(channel); DRIVER_STATE_PRINT_INT(band); DRIVER_STATE_PRINT_INT(power_level); - DRIVER_STATE_PRINT_INT(rssi_thold); - DRIVER_STATE_PRINT_INT(last_rssi_event); DRIVER_STATE_PRINT_INT(sg_enabled); DRIVER_STATE_PRINT_INT(enable_11a); DRIVER_STATE_PRINT_INT(noise); diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index 6c48b8c3f5bb..775ad952ac8f 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -162,21 +162,23 @@ static int wl1271_event_ps_report(struct wl1271 *wl, } static void wl1271_event_rssi_trigger(struct wl1271 *wl, + struct ieee80211_vif *vif, struct event_mailbox *mbox) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); enum nl80211_cqm_rssi_threshold_event event; s8 metric = mbox->rssi_snr_trigger_metric[0]; wl1271_debug(DEBUG_EVENT, "RSSI trigger metric: %d", metric); - if (metric <= wl->rssi_thold) + if (metric <= wlvif->rssi_thold) event = NL80211_CQM_RSSI_THRESHOLD_EVENT_LOW; else event = NL80211_CQM_RSSI_THRESHOLD_EVENT_HIGH; - if (event != wl->last_rssi_event) - ieee80211_cqm_rssi_notify(wl->vif, event, GFP_KERNEL); - wl->last_rssi_event = event; + if (event != wlvif->last_rssi_event) + ieee80211_cqm_rssi_notify(vif, event, GFP_KERNEL); + wlvif->last_rssi_event = event; } static void wl1271_stop_ba_event(struct wl1271 *wl, struct wl12xx_vif *wlvif) @@ -297,7 +299,7 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) if (vector & RSSI_SNR_TRIGGER_0_EVENT_ID) { wl1271_debug(DEBUG_EVENT, "RSSI_SNR_TRIGGER_0_EVENT"); if (wl->vif) - wl1271_event_rssi_trigger(wl, mbox); + wl1271_event_rssi_trigger(wl, vif, mbox); } if ((vector & BA_SESSION_RX_CONSTRAINT_EVENT_ID)) { diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index fd2b9f21acff..72ab25657dab 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -3497,7 +3497,7 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, bss_conf->cqm_rssi_hyst); if (ret < 0) goto out; - wl->rssi_thold = bss_conf->cqm_rssi_thold; + wlvif->rssi_thold = bss_conf->cqm_rssi_thold; } if (changed & BSS_CHANGED_BSSID) diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 9d9d3fbd14e5..5a82450d8c70 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -514,9 +514,6 @@ struct wl1271 { /* in dBm */ int power_level; - int rssi_thold; - int last_rssi_event; - struct wl1271_stats stats; __le32 buffer_32; @@ -652,6 +649,9 @@ struct wl12xx_vif { /* retry counter for PSM entries */ u8 psm_entry_retry; + + int rssi_thold; + int last_rssi_event; }; static inline struct wl12xx_vif *wl12xx_vif_to_data(struct ieee80211_vif *vif) -- cgit v1.2.3 From d0802abdf9c60b1dadb097e806022f3449b0cc6b Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:56:04 +0200 Subject: wl12xx: move ba fields into wlvif move ba_fields into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/debugfs.c | 2 -- drivers/net/wireless/wl12xx/event.c | 8 ++++---- drivers/net/wireless/wl12xx/init.c | 7 +++---- drivers/net/wireless/wl12xx/main.c | 4 ++-- drivers/net/wireless/wl12xx/tx.c | 2 +- drivers/net/wireless/wl12xx/wl12xx.h | 10 +++++----- 6 files changed, 15 insertions(+), 18 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index e53f96830c2f..ee42a43d6a66 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -357,8 +357,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, DRIVER_STATE_PRINT_INT(noise); DRIVER_STATE_PRINT_LHEX(ap_hlid_map[0]); DRIVER_STATE_PRINT_INT(last_tx_hlid); - DRIVER_STATE_PRINT_INT(ba_support); - DRIVER_STATE_PRINT_HEX(ba_rx_bitmap); DRIVER_STATE_PRINT_HEX(ap_fw_ps_map); DRIVER_STATE_PRINT_LHEX(ap_ps_map); DRIVER_STATE_PRINT_HEX(quirks); diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index 775ad952ac8f..8c31274228ea 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -184,9 +184,9 @@ static void wl1271_event_rssi_trigger(struct wl1271 *wl, static void wl1271_stop_ba_event(struct wl1271 *wl, struct wl12xx_vif *wlvif) { if (wlvif->bss_type != BSS_TYPE_AP_BSS) { - if (!wl->ba_rx_bitmap) + if (!wlvif->sta.ba_rx_bitmap) return; - ieee80211_stop_rx_ba_session(wl->vif, wl->ba_rx_bitmap, + ieee80211_stop_rx_ba_session(wl->vif, wlvif->sta.ba_rx_bitmap, wl->vif->bss_conf.bssid); } else { int i; @@ -306,9 +306,9 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) wl1271_debug(DEBUG_EVENT, "BA_SESSION_RX_CONSTRAINT_EVENT_ID. " "ba_allowed = 0x%x", mbox->rx_ba_allowed); - wl->ba_allowed = !!mbox->rx_ba_allowed; + wlvif->ba_allowed = !!mbox->rx_ba_allowed; - if (wl->vif && !wl->ba_allowed) + if (wl->vif && !wlvif->ba_allowed) wl1271_stop_ba_event(wl, wlvif); } diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index 1eaa0a3d9273..80e89e319879 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -486,18 +486,17 @@ int wl1271_init_ap_rates(struct wl1271 *wl, struct wl12xx_vif *wlvif) static int wl1271_set_ba_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif) { /* Reset the BA RX indicators */ - wl->ba_rx_bitmap = 0; - wl->ba_allowed = true; + wlvif->ba_allowed = true; wl->ba_rx_session_count = 0; /* BA is supported in STA/AP modes */ if (wlvif->bss_type != BSS_TYPE_AP_BSS && wlvif->bss_type != BSS_TYPE_STA_BSS) { - wl->ba_support = false; + wlvif->ba_support = false; return 0; } - wl->ba_support = true; + wlvif->ba_support = true; /* 802.11n initiator BA session setting */ return wl12xx_acx_set_ba_initiator_policy(wl, wlvif); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 72ab25657dab..984dae881a8d 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -4106,7 +4106,7 @@ static int wl1271_op_ampdu_action(struct ieee80211_hw *hw, if (wlvif->bss_type == BSS_TYPE_STA_BSS) { hlid = wlvif->sta.hlid; - ba_bitmap = &wl->ba_rx_bitmap; + ba_bitmap = &wlvif->sta.ba_rx_bitmap; } else if (wlvif->bss_type == BSS_TYPE_AP_BSS) { struct wl1271_station *wl_sta; @@ -4127,7 +4127,7 @@ static int wl1271_op_ampdu_action(struct ieee80211_hw *hw, switch (action) { case IEEE80211_AMPDU_RX_START: - if (!wl->ba_support || !wl->ba_allowed) { + if (!wlvif->ba_support || !wlvif->ba_allowed) { ret = -ENOTSUPP; break; } diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 509ae10f0e03..6ce61635f3bd 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -941,7 +941,7 @@ void wl1271_tx_reset(struct wl1271 *wl, bool reset_tx_queues) } } - wl->ba_rx_bitmap = 0; + wlvif->sta.ba_rx_bitmap = 0; } for (i = 0; i < NUM_TX_QUEUES; i++) diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 5a82450d8c70..fcc779147c1c 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -546,11 +546,6 @@ struct wl1271 { /* bands supported by this instance of wl12xx */ struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; - /* RX BA constraint value */ - bool ba_support; - u8 ba_rx_bitmap; - bool ba_allowed; - int tcxo_clock; /* @@ -605,6 +600,7 @@ struct wl12xx_vif { union { struct { u8 hlid; + u8 ba_rx_bitmap; } sta; struct { u8 global_hlid; @@ -652,6 +648,10 @@ struct wl12xx_vif { int rssi_thold; int last_rssi_event; + + /* RX BA constraint value */ + bool ba_support; + bool ba_allowed; }; static inline struct wl12xx_vif *wl12xx_vif_to_data(struct ieee80211_vif *vif) -- cgit v1.2.3 From c7ffb902cca655e4d6bdda4156407008573bb214 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:56:05 +0200 Subject: wl12xx: move ap_hlid_map into wlvif.ap Add wlvif->links_map bitmap to represent all the links allocated for this vif. AP vif also has a sta_hlid_map bitmap, which represents the links stations connected to it (sta_hlid_bitmap is a subset of wlvif->links_map, which itself is a subset of the global wl->links_map) Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 34 +++++++------ drivers/net/wireless/wl12xx/cmd.h | 3 ++ drivers/net/wireless/wl12xx/debugfs.c | 1 - drivers/net/wireless/wl12xx/event.c | 15 +++--- drivers/net/wireless/wl12xx/event.h | 3 -- drivers/net/wireless/wl12xx/main.c | 92 +++++++++++++++-------------------- drivers/net/wireless/wl12xx/tx.c | 35 +++++++------ drivers/net/wireless/wl12xx/tx.h | 2 +- drivers/net/wireless/wl12xx/wl12xx.h | 24 +++------ 9 files changed, 92 insertions(+), 117 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 68375ffb4123..102a8a5371e4 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -434,23 +434,25 @@ out: return ret; } -static int wl12xx_allocate_link(struct wl1271 *wl, u8 *hlid) +int wl12xx_allocate_link(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 *hlid) { u8 link = find_first_zero_bit(wl->links_map, WL12XX_MAX_LINKS); if (link >= WL12XX_MAX_LINKS) return -EBUSY; __set_bit(link, wl->links_map); + __set_bit(link, wlvif->links_map); *hlid = link; return 0; } -static void wl12xx_free_link(struct wl1271 *wl, u8 *hlid) +void wl12xx_free_link(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 *hlid) { if (*hlid == WL12XX_INVALID_LINK_ID) return; __clear_bit(*hlid, wl->links_map); + __clear_bit(*hlid, wlvif->links_map); *hlid = WL12XX_INVALID_LINK_ID; } @@ -484,7 +486,7 @@ int wl12xx_cmd_role_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->channel = wl->channel; if (wlvif->dev_hlid == WL12XX_INVALID_LINK_ID) { - ret = wl12xx_allocate_link(wl, &wlvif->dev_hlid); + ret = wl12xx_allocate_link(wl, wlvif, &wlvif->dev_hlid); if (ret) goto out_free; } @@ -504,7 +506,7 @@ int wl12xx_cmd_role_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) err_hlid: /* clear links on error */ - wl12xx_free_link(wl, &wlvif->dev_hlid); + wl12xx_free_link(wl, wlvif, &wlvif->dev_hlid); out_free: kfree(cmd); @@ -545,7 +547,7 @@ int wl12xx_cmd_role_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out_free; } - wl12xx_free_link(wl, &wlvif->dev_hlid); + wl12xx_free_link(wl, wlvif, &wlvif->dev_hlid); out_free: kfree(cmd); @@ -581,7 +583,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->sta.local_rates = cpu_to_le32(wlvif->rate_set); if (wlvif->sta.hlid == WL12XX_INVALID_LINK_ID) { - ret = wl12xx_allocate_link(wl, &wlvif->sta.hlid); + ret = wl12xx_allocate_link(wl, wlvif, &wlvif->sta.hlid); if (ret) goto out_free; } @@ -604,7 +606,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) err_hlid: /* clear links on error. */ - wl12xx_free_link(wl, &wlvif->sta.hlid); + wl12xx_free_link(wl, wlvif, &wlvif->sta.hlid); out_free: kfree(cmd); @@ -640,7 +642,7 @@ int wl12xx_cmd_role_stop_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out_free; } - wl12xx_free_link(wl, &wlvif->sta.hlid); + wl12xx_free_link(wl, wlvif, &wlvif->sta.hlid); out_free: kfree(cmd); @@ -670,11 +672,11 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out; } - ret = wl12xx_allocate_link(wl, &wlvif->ap.global_hlid); + ret = wl12xx_allocate_link(wl, wlvif, &wlvif->ap.global_hlid); if (ret < 0) goto out_free; - ret = wl12xx_allocate_link(wl, &wlvif->ap.bcast_hlid); + ret = wl12xx_allocate_link(wl, wlvif, &wlvif->ap.bcast_hlid); if (ret < 0) goto out_free_global; @@ -724,10 +726,10 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out_free; out_free_bcast: - wl12xx_free_link(wl, &wlvif->ap.bcast_hlid); + wl12xx_free_link(wl, wlvif, &wlvif->ap.bcast_hlid); out_free_global: - wl12xx_free_link(wl, &wlvif->ap.global_hlid); + wl12xx_free_link(wl, wlvif, &wlvif->ap.global_hlid); out_free: kfree(cmd); @@ -757,8 +759,8 @@ int wl12xx_cmd_role_stop_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out_free; } - wl12xx_free_link(wl, &wlvif->ap.bcast_hlid); - wl12xx_free_link(wl, &wlvif->ap.global_hlid); + wl12xx_free_link(wl, wlvif, &wlvif->ap.bcast_hlid); + wl12xx_free_link(wl, wlvif, &wlvif->ap.global_hlid); out_free: kfree(cmd); @@ -796,7 +798,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->sta.local_rates = cpu_to_le32(wlvif->rate_set); if (wlvif->sta.hlid == WL12XX_INVALID_LINK_ID) { - ret = wl12xx_allocate_link(wl, &wlvif->sta.hlid); + ret = wl12xx_allocate_link(wl, wlvif, &wlvif->sta.hlid); if (ret) goto out_free; } @@ -821,7 +823,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) err_hlid: /* clear links on error. */ - wl12xx_free_link(wl, &wlvif->sta.hlid); + wl12xx_free_link(wl, wlvif, &wlvif->sta.hlid); out_free: kfree(cmd); diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index 9624828b76e8..d2670d379b75 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -89,6 +89,9 @@ int wl12xx_cmd_stop_fwlog(struct wl1271 *wl); int wl12xx_cmd_channel_switch(struct wl1271 *wl, struct ieee80211_channel_switch *ch_switch); int wl12xx_cmd_stop_channel_switch(struct wl1271 *wl); +int wl12xx_allocate_link(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 *hlid); +void wl12xx_free_link(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 *hlid); enum wl1271_commands { CMD_INTERROGATE = 1, /*use this to read information elements*/ diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index ee42a43d6a66..f0398d037d4d 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -355,7 +355,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, DRIVER_STATE_PRINT_INT(sg_enabled); DRIVER_STATE_PRINT_INT(enable_11a); DRIVER_STATE_PRINT_INT(noise); - DRIVER_STATE_PRINT_LHEX(ap_hlid_map[0]); DRIVER_STATE_PRINT_INT(last_tx_hlid); DRIVER_STATE_PRINT_HEX(ap_fw_ps_map); DRIVER_STATE_PRINT_LHEX(ap_ps_map); diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index 8c31274228ea..486c8ee0101a 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -189,11 +189,12 @@ static void wl1271_stop_ba_event(struct wl1271 *wl, struct wl12xx_vif *wlvif) ieee80211_stop_rx_ba_session(wl->vif, wlvif->sta.ba_rx_bitmap, wl->vif->bss_conf.bssid); } else { - int i; + u8 hlid; struct wl1271_link *lnk; - for (i = WL1271_AP_STA_HLID_START; i < AP_MAX_LINKS; i++) { - lnk = &wl->links[i]; - if (!wl1271_is_active_sta(wl, i) || !lnk->ba_bitmap) + for_each_set_bit(hlid, wlvif->ap.sta_hlid_map, + WL12XX_MAX_LINKS) { + lnk = &wl->links[hlid]; + if (!lnk->ba_bitmap) continue; ieee80211_stop_rx_ba_session(wl->vif, @@ -355,10 +356,8 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) const u8 *addr; int h; - for (h = find_first_bit(&sta_bitmap, AP_MAX_LINKS); - h < AP_MAX_LINKS; - h = find_next_bit(&sta_bitmap, AP_MAX_LINKS, h+1)) { - if (!wl1271_is_active_sta(wl, h)) + for_each_set_bit(h, &sta_bitmap, WL12XX_MAX_LINKS) { + if (!test_bit(h, wlvif->ap.sta_hlid_map)) continue; addr = wl->links[h].addr; diff --git a/drivers/net/wireless/wl12xx/event.h b/drivers/net/wireless/wl12xx/event.h index 49c1a0ede5b1..1d878ba47bf4 100644 --- a/drivers/net/wireless/wl12xx/event.h +++ b/drivers/net/wireless/wl12xx/event.h @@ -132,7 +132,4 @@ void wl1271_event_mbox_config(struct wl1271 *wl); int wl1271_event_handle(struct wl1271 *wl, u8 mbox); void wl1271_pspoll_work(struct work_struct *work); -/* Functions from main.c */ -bool wl1271_is_active_sta(struct wl1271 *wl, u8 hlid); - #endif diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 984dae881a8d..f712f0fb50be 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -778,10 +778,6 @@ static void wl12xx_irq_ps_regulate_link(struct wl1271 *wl, u8 hlid, u8 tx_pkts) { bool fw_ps, single_sta; - /* only regulate station links */ - if (hlid < WL1271_AP_STA_HLID_START) - return; - fw_ps = test_bit(hlid, (unsigned long *)&wl->ap_fw_ps_map); single_sta = (wl->active_sta_count == 1); @@ -801,21 +797,11 @@ static void wl12xx_irq_ps_regulate_link(struct wl1271 *wl, u8 hlid, u8 tx_pkts) wl1271_ps_link_start(wl, hlid, true); } -bool wl1271_is_active_sta(struct wl1271 *wl, u8 hlid) -{ - int id; - - /* global/broadcast "stations" are always active */ - if (hlid < WL1271_AP_STA_HLID_START) - return true; - - id = hlid - WL1271_AP_STA_HLID_START; - return test_bit(id, wl->ap_hlid_map); -} - static void wl12xx_irq_update_links_status(struct wl1271 *wl, + struct wl12xx_vif *wlvif, struct wl12xx_fw_status *status) { + struct wl1271_link *lnk; u32 cur_fw_ps_map; u8 hlid, cnt; @@ -831,19 +817,14 @@ static void wl12xx_irq_update_links_status(struct wl1271 *wl, wl->ap_fw_ps_map = cur_fw_ps_map; } - for (hlid = WL1271_AP_STA_HLID_START; hlid < AP_MAX_LINKS; hlid++) { - if (!wl1271_is_active_sta(wl, hlid)) - continue; - - cnt = status->tx_lnk_free_pkts[hlid] - - wl->links[hlid].prev_freed_pkts; + for_each_set_bit(hlid, wlvif->ap.sta_hlid_map, WL12XX_MAX_LINKS) { + lnk = &wl->links[hlid]; + cnt = status->tx_lnk_free_pkts[hlid] - lnk->prev_freed_pkts; - wl->links[hlid].prev_freed_pkts = - status->tx_lnk_free_pkts[hlid]; - wl->links[hlid].allocated_pkts -= cnt; + lnk->prev_freed_pkts = status->tx_lnk_free_pkts[hlid]; + lnk->allocated_pkts -= cnt; - wl12xx_irq_ps_regulate_link(wl, hlid, - wl->links[hlid].allocated_pkts); + wl12xx_irq_ps_regulate_link(wl, hlid, lnk->allocated_pkts); } } @@ -907,7 +888,7 @@ static void wl12xx_fw_status(struct wl1271 *wl, /* for AP update num of allocated TX blocks per link and ps status */ if (wlvif->bss_type == BSS_TYPE_AP_BSS) - wl12xx_irq_update_links_status(wl, status); + wl12xx_irq_update_links_status(wl, wlvif, status); /* update the host-chipset time offset */ getnstimeofday(&ts); @@ -1505,7 +1486,7 @@ static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) /* queue the packet */ if (wlvif->bss_type == BSS_TYPE_AP_BSS) { - if (!wl1271_is_active_sta(wl, hlid)) { + if (!test_bit(hlid, wlvif->links_map)) { wl1271_debug(DEBUG_TX, "DROP skb hlid %d q %d", hlid, q); dev_kfree_skb(skb); @@ -2152,7 +2133,7 @@ deinit: wl->vif = NULL; wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; wl1271_free_ap_keys(wl); - memset(wl->ap_hlid_map, 0, sizeof(wl->ap_hlid_map)); + memset(wlvif->ap.sta_hlid_map, 0, sizeof(wlvif->ap.sta_hlid_map)); wl->ap_fw_ps_map = 0; wl->ap_ps_map = 0; wl->sched_scanning = false; @@ -3946,43 +3927,44 @@ static int wl1271_op_get_survey(struct ieee80211_hw *hw, int idx, } static int wl1271_allocate_sta(struct wl1271 *wl, - struct ieee80211_sta *sta, - u8 *hlid) + struct wl12xx_vif *wlvif, + struct ieee80211_sta *sta) { struct wl1271_station *wl_sta; - int id; + int ret; - id = find_first_zero_bit(wl->ap_hlid_map, AP_MAX_STATIONS); - if (id >= AP_MAX_STATIONS) { + + if (wl->active_sta_count >= AP_MAX_STATIONS) { wl1271_warning("could not allocate HLID - too much stations"); return -EBUSY; } wl_sta = (struct wl1271_station *)sta->drv_priv; - set_bit(id, wl->ap_hlid_map); - wl_sta->hlid = WL1271_AP_STA_HLID_START + id; - *hlid = wl_sta->hlid; + ret = wl12xx_allocate_link(wl, wlvif, &wl_sta->hlid); + if (ret < 0) { + wl1271_warning("could not allocate HLID - too many links"); + return -EBUSY; + } + + set_bit(wl_sta->hlid, wlvif->ap.sta_hlid_map); memcpy(wl->links[wl_sta->hlid].addr, sta->addr, ETH_ALEN); wl->active_sta_count++; return 0; } -void wl1271_free_sta(struct wl1271 *wl, u8 hlid) +/* TODO: change wl1271_tx_reset(), so we can get sta as param */ +void wl1271_free_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 hlid) { - int id = hlid - WL1271_AP_STA_HLID_START; - - if (hlid < WL1271_AP_STA_HLID_START) + if (!test_bit(hlid, wlvif->ap.sta_hlid_map)) return; - if (!test_bit(id, wl->ap_hlid_map)) - return; - - clear_bit(id, wl->ap_hlid_map); + clear_bit(hlid, wlvif->ap.sta_hlid_map); memset(wl->links[hlid].addr, 0, ETH_ALEN); wl->links[hlid].ba_bitmap = 0; wl1271_tx_reset_link_queues(wl, hlid); __clear_bit(hlid, &wl->ap_ps_map); __clear_bit(hlid, (unsigned long *)&wl->ap_fw_ps_map); + wl12xx_free_link(wl, wlvif, &hlid); wl->active_sta_count--; } @@ -3992,6 +3974,7 @@ static int wl1271_op_sta_add(struct ieee80211_hw *hw, { struct wl1271 *wl = hw->priv; struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + struct wl1271_station *wl_sta; int ret = 0; u8 hlid; @@ -4005,10 +3988,13 @@ static int wl1271_op_sta_add(struct ieee80211_hw *hw, wl1271_debug(DEBUG_MAC80211, "mac80211 add sta %d", (int)sta->aid); - ret = wl1271_allocate_sta(wl, sta, &hlid); + ret = wl1271_allocate_sta(wl, wlvif, sta); if (ret < 0) goto out; + wl_sta = (struct wl1271_station *)sta->drv_priv; + hlid = wl_sta->hlid; + ret = wl1271_ps_elp_wakeup(wl); if (ret < 0) goto out_free_sta; @@ -4030,7 +4016,7 @@ out_sleep: out_free_sta: if (ret < 0) - wl1271_free_sta(wl, hlid); + wl1271_free_sta(wl, wlvif, hlid); out: mutex_unlock(&wl->mutex); @@ -4057,8 +4043,8 @@ static int wl1271_op_sta_remove(struct ieee80211_hw *hw, wl1271_debug(DEBUG_MAC80211, "mac80211 remove sta %d", (int)sta->aid); wl_sta = (struct wl1271_station *)sta->drv_priv; - id = wl_sta->hlid - WL1271_AP_STA_HLID_START; - if (WARN_ON(!test_bit(id, wl->ap_hlid_map))) + id = wl_sta->hlid; + if (WARN_ON(!test_bit(id, wlvif->ap.sta_hlid_map))) goto out; ret = wl1271_ps_elp_wakeup(wl); @@ -4069,7 +4055,7 @@ static int wl1271_op_sta_remove(struct ieee80211_hw *hw, if (ret < 0) goto out_sleep; - wl1271_free_sta(wl, wl_sta->hlid); + wl1271_free_sta(wl, wlvif, wl_sta->hlid); out_sleep: wl1271_ps_elp_sleep(wl); @@ -4841,7 +4827,7 @@ struct ieee80211_hw *wl1271_alloc_hw(void) int i, j, ret; unsigned int order; - BUILD_BUG_ON(AP_MAX_LINKS > WL12XX_MAX_LINKS); + BUILD_BUG_ON(AP_MAX_STATIONS > WL12XX_MAX_LINKS); hw = ieee80211_alloc_hw(sizeof(*wl), &wl1271_ops); if (!hw) { @@ -4869,7 +4855,7 @@ struct ieee80211_hw *wl1271_alloc_hw(void) skb_queue_head_init(&wl->tx_queue[i]); for (i = 0; i < NUM_TX_QUEUES; i++) - for (j = 0; j < AP_MAX_LINKS; j++) + for (j = 0; j < WL12XX_MAX_LINKS; j++) skb_queue_head_init(&wl->links[j].tx_queue[i]); skb_queue_head_init(&wl->deferred_rx_queue); diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 6ce61635f3bd..1b3d8e3f35a8 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -125,18 +125,16 @@ static void wl1271_tx_ap_update_inconnection_sta(struct wl1271 *wl, wl1271_acx_set_inconnection_sta(wl, hdr->addr1); } -static void wl1271_tx_regulate_link(struct wl1271 *wl, u8 hlid) +static void wl1271_tx_regulate_link(struct wl1271 *wl, + struct wl12xx_vif *wlvif, + u8 hlid) { bool fw_ps, single_sta; u8 tx_pkts; - /* only regulate station links */ - if (hlid < WL1271_AP_STA_HLID_START) + if (WARN_ON(!test_bit(hlid, wlvif->links_map))) return; - if (WARN_ON(!wl1271_is_active_sta(wl, hlid))) - return; - fw_ps = test_bit(hlid, (unsigned long *)&wl->ap_fw_ps_map); tx_pkts = wl->links[hlid].allocated_pkts; single_sta = (wl->active_sta_count == 1); @@ -266,7 +264,7 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct ieee80211_vif *vif, wl->tx_allocated_pkts[ac]++; if (wlvif->bss_type == BSS_TYPE_AP_BSS && - hlid >= WL1271_AP_STA_HLID_START) + test_bit(hlid, wlvif->ap.sta_hlid_map)) wl->links[hlid].allocated_pkts++; ret = 0; @@ -445,7 +443,7 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct sk_buff *skb, if (wlvif->bss_type == BSS_TYPE_AP_BSS && !is_dummy) { wl1271_tx_ap_update_inconnection_sta(wl, skb); - wl1271_tx_regulate_link(wl, hlid); + wl1271_tx_regulate_link(wl, wlvif, hlid); } /* @@ -563,7 +561,8 @@ out: return skb; } -static struct sk_buff *wl1271_ap_skb_dequeue(struct wl1271 *wl) +static struct sk_buff *wl1271_ap_skb_dequeue(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { struct sk_buff *skb = NULL; unsigned long flags; @@ -571,15 +570,14 @@ static struct sk_buff *wl1271_ap_skb_dequeue(struct wl1271 *wl) struct sk_buff_head *queue; /* start from the link after the last one */ - start_hlid = (wl->last_tx_hlid + 1) % AP_MAX_LINKS; + start_hlid = (wl->last_tx_hlid + 1) % WL12XX_MAX_LINKS; /* dequeue according to AC, round robin on each link */ - for (i = 0; i < AP_MAX_LINKS; i++) { - h = (start_hlid + i) % AP_MAX_LINKS; + for (i = 0; i < WL12XX_MAX_LINKS; i++) { + h = (start_hlid + i) % WL12XX_MAX_LINKS; /* only consider connected stations */ - if (h >= WL1271_AP_STA_HLID_START && - !test_bit(h - WL1271_AP_STA_HLID_START, wl->ap_hlid_map)) + if (!test_bit(h, wlvif->links_map)) continue; queue = wl1271_select_queue(wl, wl->links[h].tx_queue); @@ -611,7 +609,7 @@ static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl, struct sk_buff *skb = NULL; if (wlvif->bss_type == BSS_TYPE_AP_BSS) - skb = wl1271_ap_skb_dequeue(wl); + skb = wl1271_ap_skb_dequeue(wl, wlvif); else skb = wl1271_sta_skb_dequeue(wl); @@ -643,7 +641,8 @@ static void wl1271_skb_queue_head(struct wl1271 *wl, struct ieee80211_vif *vif, skb_queue_head(&wl->links[hlid].tx_queue[q], skb); /* make sure we dequeue the same packet next time */ - wl->last_tx_hlid = (hlid + AP_MAX_LINKS - 1) % AP_MAX_LINKS; + wl->last_tx_hlid = (hlid + WL12XX_MAX_LINKS - 1) % + WL12XX_MAX_LINKS; } else { skb_queue_head(&wl->tx_queue[q], skb); } @@ -918,8 +917,8 @@ void wl1271_tx_reset(struct wl1271 *wl, bool reset_tx_queues) /* TX failure */ if (wlvif->bss_type == BSS_TYPE_AP_BSS) { - for (i = 0; i < AP_MAX_LINKS; i++) { - wl1271_free_sta(wl, i); + for (i = 0; i < WL12XX_MAX_LINKS; i++) { + wl1271_free_sta(wl, wlvif, i); wl1271_tx_reset_link_queues(wl, i); wl->links[i].allocated_pkts = 0; wl->links[i].prev_freed_pkts = 0; diff --git a/drivers/net/wireless/wl12xx/tx.h b/drivers/net/wireless/wl12xx/tx.h index 0964c9335316..add4402d7931 100644 --- a/drivers/net/wireless/wl12xx/tx.h +++ b/drivers/net/wireless/wl12xx/tx.h @@ -219,6 +219,6 @@ void wl1271_handle_tx_low_watermark(struct wl1271 *wl); bool wl12xx_is_dummy_packet(struct wl1271 *wl, struct sk_buff *skb); /* from main.c */ -void wl1271_free_sta(struct wl1271 *wl, u8 hlid); +void wl1271_free_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 hlid); #endif diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index fcc779147c1c..5fd3c262bc5f 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -145,12 +145,6 @@ extern u32 wl12xx_debug_level; /* Defined by FW as 0. Will not be freed or allocated. */ #define WL12XX_SYSTEM_HLID 0 -/* - * TODO: we currently don't support multirole. remove - * this constant from the code when we do. - */ -#define WL1271_AP_STA_HLID_START 3 - /* * When in AP-mode, we allow (at least) this number of packets * to be transmitted to FW for a STA in PS-mode. Only when packets are @@ -236,13 +230,6 @@ struct wl1271_stats { #define AP_MAX_STATIONS 8 -/* Broadcast and Global links + system link + links to stations */ -/* - * TODO: when WL1271_AP_STA_HLID_START is no longer constant, change all - * the places that use this. - */ -#define AP_MAX_LINKS (AP_MAX_STATIONS + WL1271_AP_STA_HLID_START) - /* FW status registers */ struct wl12xx_fw_status { __le32 intr; @@ -537,9 +524,6 @@ struct wl1271 { /* Most recently reported noise in dBm */ s8 noise; - /* map for HLIDs of associated stations - when operating in AP mode */ - unsigned long ap_hlid_map[BITS_TO_LONGS(AP_MAX_STATIONS)]; - /* recoreded keys for AP-mode - set here before AP startup */ struct wl1271_ap_key *recorded_ap_keys[MAX_NUM_KEYS]; @@ -559,7 +543,7 @@ struct wl1271 { * AP-mode - links indexed by HLID. The global and broadcast links * are always active. */ - struct wl1271_link links[AP_MAX_LINKS]; + struct wl1271_link links[WL12XX_MAX_LINKS]; /* the hlid of the link where the last transmitted skb came from */ int last_tx_hlid; @@ -605,9 +589,15 @@ struct wl12xx_vif { struct { u8 global_hlid; u8 bcast_hlid; + + /* HLIDs bitmap of associated stations */ + unsigned long sta_hlid_map[BITS_TO_LONGS( + WL12XX_MAX_LINKS)]; } ap; }; + unsigned long links_map[BITS_TO_LONGS(WL12XX_MAX_LINKS)]; + u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; u8 ssid_len; -- cgit v1.2.3 From 170d0e6732c5fb1d4103ded3da95a5630c24e5dd Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 5 Oct 2011 11:56:06 +0200 Subject: wl12xx: move recorded_ap_keys into wlvif move recorded_ap_keys into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 31 ++++++++++++++++--------------- drivers/net/wireless/wl12xx/wl12xx.h | 6 +++--- 2 files changed, 19 insertions(+), 18 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index f712f0fb50be..194d7cc366de 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -379,7 +379,7 @@ static bool bug_on_recovery; static void __wl1271_op_remove_interface(struct wl1271 *wl, struct ieee80211_vif *vif, bool reset_tx_queues); -static void wl1271_free_ap_keys(struct wl1271 *wl); +static void wl1271_free_ap_keys(struct wl1271 *wl, struct wl12xx_vif *wlvif); static void wl1271_device_release(struct device *dev) @@ -2132,7 +2132,7 @@ deinit: wl->bitrate_masks[IEEE80211_BAND_5GHZ] = wl->conf.tx.basic_rate_5; wl->vif = NULL; wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; - wl1271_free_ap_keys(wl); + wl1271_free_ap_keys(wl, wlvif); memset(wlvif->ap.sta_hlid_map, 0, sizeof(wlvif->ap.sta_hlid_map)); wl->ap_fw_ps_map = 0; wl->ap_ps_map = 0; @@ -2603,9 +2603,10 @@ out: kfree(fp); } -static int wl1271_record_ap_key(struct wl1271 *wl, u8 id, u8 key_type, - u8 key_size, const u8 *key, u8 hlid, u32 tx_seq_32, - u16 tx_seq_16) +static int wl1271_record_ap_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 id, u8 key_type, u8 key_size, + const u8 *key, u8 hlid, u32 tx_seq_32, + u16 tx_seq_16) { struct wl1271_ap_key *ap_key; int i; @@ -2620,10 +2621,10 @@ static int wl1271_record_ap_key(struct wl1271 *wl, u8 id, u8 key_type, * an existing key. */ for (i = 0; i < MAX_NUM_KEYS; i++) { - if (wl->recorded_ap_keys[i] == NULL) + if (wlvif->ap.recorded_keys[i] == NULL) break; - if (wl->recorded_ap_keys[i]->id == id) { + if (wlvif->ap.recorded_keys[i]->id == id) { wl1271_warning("trying to record key replacement"); return -EINVAL; } @@ -2644,17 +2645,17 @@ static int wl1271_record_ap_key(struct wl1271 *wl, u8 id, u8 key_type, ap_key->tx_seq_32 = tx_seq_32; ap_key->tx_seq_16 = tx_seq_16; - wl->recorded_ap_keys[i] = ap_key; + wlvif->ap.recorded_keys[i] = ap_key; return 0; } -static void wl1271_free_ap_keys(struct wl1271 *wl) +static void wl1271_free_ap_keys(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int i; for (i = 0; i < MAX_NUM_KEYS; i++) { - kfree(wl->recorded_ap_keys[i]); - wl->recorded_ap_keys[i] = NULL; + kfree(wlvif->ap.recorded_keys[i]); + wlvif->ap.recorded_keys[i] = NULL; } } @@ -2666,10 +2667,10 @@ static int wl1271_ap_init_hwenc(struct wl1271 *wl, struct wl12xx_vif *wlvif) for (i = 0; i < MAX_NUM_KEYS; i++) { u8 hlid; - if (wl->recorded_ap_keys[i] == NULL) + if (wlvif->ap.recorded_keys[i] == NULL) break; - key = wl->recorded_ap_keys[i]; + key = wlvif->ap.recorded_keys[i]; hlid = key->hlid; if (hlid == WL12XX_INVALID_LINK_ID) hlid = wlvif->ap.bcast_hlid; @@ -2694,7 +2695,7 @@ static int wl1271_ap_init_hwenc(struct wl1271 *wl, struct wl12xx_vif *wlvif) } out: - wl1271_free_ap_keys(wl); + wl1271_free_ap_keys(wl, wlvif); return ret; } @@ -2725,7 +2726,7 @@ static int wl1271_set_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (action != KEY_ADD_OR_REPLACE) return 0; - ret = wl1271_record_ap_key(wl, id, + ret = wl1271_record_ap_key(wl, wlvif, id, key_type, key_size, key, hlid, tx_seq_32, tx_seq_16); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 5fd3c262bc5f..074de4e1fb33 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -524,9 +524,6 @@ struct wl1271 { /* Most recently reported noise in dBm */ s8 noise; - /* recoreded keys for AP-mode - set here before AP startup */ - struct wl1271_ap_key *recorded_ap_keys[MAX_NUM_KEYS]; - /* bands supported by this instance of wl12xx */ struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; @@ -593,6 +590,9 @@ struct wl12xx_vif { /* HLIDs bitmap of associated stations */ unsigned long sta_hlid_map[BITS_TO_LONGS( WL12XX_MAX_LINKS)]; + + /* recoreded keys - set here before AP startup */ + struct wl1271_ap_key *recorded_keys[MAX_NUM_KEYS]; } ap; }; -- cgit v1.2.3 From 1d095475f58680af17e4a0e8dd84269b3f08ce54 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:12:49 +0200 Subject: wl12xx: refactor fw init into a new function The fw boot and initialization currently happens inside the add_interface() callback. This is wrong, as add_interface is called for each new vif. However, we due to some fw limitation (we have to know the actual mac address on boot), we can't completely move it into the start() callback. Until the fw will be fixed, refactor the fw init into a new function, and call it from add_interface() Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 171 ++++++++++++++++++++----------------- 1 file changed, 93 insertions(+), 78 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 194d7cc366de..3667acf0a031 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1888,60 +1888,12 @@ static int wl12xx_init_vif_data(struct ieee80211_vif *vif) return 0; } -static int wl1271_op_add_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif) +static bool wl12xx_init_fw(struct wl1271 *wl) { - struct wl1271 *wl = hw->priv; - struct wiphy *wiphy = hw->wiphy; - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int retries = WL1271_BOOT_RETRIES; - int ret = 0; - u8 role_type; bool booted = false; - - wl1271_debug(DEBUG_MAC80211, "mac80211 add interface type %d mac %pM", - ieee80211_vif_type_p2p(vif), vif->addr); - - mutex_lock(&wl->mutex); - if (wl->vif) { - wl1271_debug(DEBUG_MAC80211, - "multiple vifs are not supported yet"); - ret = -EBUSY; - goto out; - } - - /* - * in some very corner case HW recovery scenarios its possible to - * get here before __wl1271_op_remove_interface is complete, so - * opt out if that is the case. - */ - if (test_bit(WL1271_FLAG_IF_INITIALIZED, &wl->flags)) { - ret = -EBUSY; - goto out; - } - - ret = wl12xx_init_vif_data(vif); - if (ret < 0) - goto out; - - wlvif->wl = wl; - role_type = wl12xx_get_role_type(wl, wlvif); - if (role_type == WL12XX_INVALID_ROLE_TYPE) { - ret = -EINVAL; - goto out; - } - /* - * we still need this in order to configure the fw - * while uploading the nvs - */ - memcpy(wl->mac_addr, vif->addr, ETH_ALEN); - - if (wl->state != WL1271_STATE_OFF) { - wl1271_error("cannot start because not in off state: %d", - wl->state); - ret = -EBUSY; - goto out; - } + struct wiphy *wiphy = wl->hw->wiphy; + int ret; while (retries) { retries--; @@ -1957,30 +1909,6 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, if (ret < 0) goto irq_disable; - if (wlvif->bss_type == BSS_TYPE_STA_BSS || - wlvif->bss_type == BSS_TYPE_IBSS) { - /* - * The device role is a special role used for - * rx and tx frames prior to association (as - * the STA role can get packets only from - * its associated bssid) - */ - ret = wl12xx_cmd_role_enable(wl, vif->addr, - WL1271_ROLE_DEVICE, - &wlvif->dev_role_id); - if (ret < 0) - goto irq_disable; - } - - ret = wl12xx_cmd_role_enable(wl, vif->addr, - role_type, &wlvif->role_id); - if (ret < 0) - goto irq_disable; - - ret = wl1271_init_vif_specific(wl, vif); - if (ret < 0) - goto irq_disable; - booted = true; break; @@ -2007,9 +1935,6 @@ power_off: goto out; } - wl->vif = vif; - wl->state = WL1271_STATE_ON; - set_bit(WL1271_FLAG_IF_INITIALIZED, &wl->flags); wl1271_info("firmware booted (%s)", wl->chip.fw_ver_str); /* update hw/fw version info in wiphy struct */ @@ -2027,6 +1952,96 @@ power_off: wl1271_debug(DEBUG_MAC80211, "11a is %ssupported", wl->enable_11a ? "" : "not "); + wl->state = WL1271_STATE_ON; +out: + return booted; +} + +static int wl1271_op_add_interface(struct ieee80211_hw *hw, + struct ieee80211_vif *vif) +{ + struct wl1271 *wl = hw->priv; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + int ret = 0; + u8 role_type; + bool booted = false; + + wl1271_debug(DEBUG_MAC80211, "mac80211 add interface type %d mac %pM", + ieee80211_vif_type_p2p(vif), vif->addr); + + mutex_lock(&wl->mutex); + if (wl->vif) { + wl1271_debug(DEBUG_MAC80211, + "multiple vifs are not supported yet"); + ret = -EBUSY; + goto out; + } + + /* + * in some very corner case HW recovery scenarios its possible to + * get here before __wl1271_op_remove_interface is complete, so + * opt out if that is the case. + */ + if (test_bit(WL1271_FLAG_IF_INITIALIZED, &wl->flags)) { + ret = -EBUSY; + goto out; + } + + ret = wl12xx_init_vif_data(vif); + if (ret < 0) + goto out; + + wlvif->wl = wl; + role_type = wl12xx_get_role_type(wl, wlvif); + if (role_type == WL12XX_INVALID_ROLE_TYPE) { + ret = -EINVAL; + goto out; + } + + /* + * TODO: after the nvs issue will be solved, move this block + * to start(), and make sure here the driver is ON. + */ + if (wl->state == WL1271_STATE_OFF) { + /* + * we still need this in order to configure the fw + * while uploading the nvs + */ + memcpy(wl->mac_addr, vif->addr, ETH_ALEN); + + booted = wl12xx_init_fw(wl); + if (!booted) { + ret = -EINVAL; + goto out; + } + } + + if (wlvif->bss_type == BSS_TYPE_STA_BSS || + wlvif->bss_type == BSS_TYPE_IBSS) { + /* + * The device role is a special role used for + * rx and tx frames prior to association (as + * the STA role can get packets only from + * its associated bssid) + */ + ret = wl12xx_cmd_role_enable(wl, vif->addr, + WL1271_ROLE_DEVICE, + &wlvif->dev_role_id); + if (ret < 0) + goto out; + } + + ret = wl12xx_cmd_role_enable(wl, vif->addr, + role_type, &wlvif->role_id); + if (ret < 0) + goto out; + + ret = wl1271_init_vif_specific(wl, vif); + if (ret < 0) + goto out; + + wl->vif = vif; + set_bit(WL1271_FLAG_IF_INITIALIZED, &wl->flags); out: mutex_unlock(&wl->mutex); -- cgit v1.2.3 From 4438aca9e16901d8d32a025ca27ad8284a117e09 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:12:50 +0200 Subject: wl12xx: move last_tx_hlid into wlvif move last_tx_hlid into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/debugfs.c | 1 - drivers/net/wireless/wl12xx/main.c | 1 - drivers/net/wireless/wl12xx/tx.c | 10 +++++----- drivers/net/wireless/wl12xx/wl12xx.h | 6 +++--- 4 files changed, 8 insertions(+), 10 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index f0398d037d4d..bbc8004edf40 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -355,7 +355,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, DRIVER_STATE_PRINT_INT(sg_enabled); DRIVER_STATE_PRINT_INT(enable_11a); DRIVER_STATE_PRINT_INT(noise); - DRIVER_STATE_PRINT_INT(last_tx_hlid); DRIVER_STATE_PRINT_HEX(ap_fw_ps_map); DRIVER_STATE_PRINT_LHEX(ap_ps_map); DRIVER_STATE_PRINT_HEX(quirks); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 3667acf0a031..0606b0d8aabd 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -4901,7 +4901,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->flags = 0; wl->sg_enabled = true; wl->hw_pg_ver = -1; - wl->last_tx_hlid = 0; wl->ap_ps_map = 0; wl->ap_fw_ps_map = 0; wl->quirks = 0; diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 1b3d8e3f35a8..951ff03b7f42 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -570,7 +570,7 @@ static struct sk_buff *wl1271_ap_skb_dequeue(struct wl1271 *wl, struct sk_buff_head *queue; /* start from the link after the last one */ - start_hlid = (wl->last_tx_hlid + 1) % WL12XX_MAX_LINKS; + start_hlid = (wlvif->last_tx_hlid + 1) % WL12XX_MAX_LINKS; /* dequeue according to AC, round robin on each link */ for (i = 0; i < WL12XX_MAX_LINKS; i++) { @@ -591,12 +591,12 @@ static struct sk_buff *wl1271_ap_skb_dequeue(struct wl1271 *wl, if (skb) { int q = wl1271_tx_get_queue(skb_get_queue_mapping(skb)); - wl->last_tx_hlid = h; + wlvif->last_tx_hlid = h; spin_lock_irqsave(&wl->wl_lock, flags); wl->tx_queue_count[q]--; spin_unlock_irqrestore(&wl->wl_lock, flags); } else { - wl->last_tx_hlid = 0; + wlvif->last_tx_hlid = 0; } return skb; @@ -641,7 +641,7 @@ static void wl1271_skb_queue_head(struct wl1271 *wl, struct ieee80211_vif *vif, skb_queue_head(&wl->links[hlid].tx_queue[q], skb); /* make sure we dequeue the same packet next time */ - wl->last_tx_hlid = (hlid + WL12XX_MAX_LINKS - 1) % + wlvif->last_tx_hlid = (hlid + WL12XX_MAX_LINKS - 1) % WL12XX_MAX_LINKS; } else { skb_queue_head(&wl->tx_queue[q], skb); @@ -924,7 +924,7 @@ void wl1271_tx_reset(struct wl1271 *wl, bool reset_tx_queues) wl->links[i].prev_freed_pkts = 0; } - wl->last_tx_hlid = 0; + wlvif->last_tx_hlid = 0; } else { for (i = 0; i < NUM_TX_QUEUES; i++) { while ((skb = skb_dequeue(&wl->tx_queue[i]))) { diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 074de4e1fb33..b350f0bdd38d 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -542,9 +542,6 @@ struct wl1271 { */ struct wl1271_link links[WL12XX_MAX_LINKS]; - /* the hlid of the link where the last transmitted skb came from */ - int last_tx_hlid; - /* AP-mode - a bitmap of links currently in PS mode according to FW */ u32 ap_fw_ps_map; @@ -596,6 +593,9 @@ struct wl12xx_vif { } ap; }; + /* the hlid of the last transmitted skb */ + int last_tx_hlid; + unsigned long links_map[BITS_TO_LONGS(WL12XX_MAX_LINKS)]; u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; -- cgit v1.2.3 From d6a3cc2ef962ad4392a2401cae513a18a6d35099 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:12:51 +0200 Subject: wl12xx: unify STA and AP tx_queue mechanism Make sta use the global wl->links[hlid].tx_queue (by considering its links map) instead of wl->tx_queue, and then unify the tx and tx_reset flows for the various vifs. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 32 ++++------ drivers/net/wireless/wl12xx/tx.c | 109 +++++++++++++---------------------- drivers/net/wireless/wl12xx/tx.h | 5 +- drivers/net/wireless/wl12xx/wl12xx.h | 1 - 4 files changed, 55 insertions(+), 92 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 0606b0d8aabd..abe5ef8807ba 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1474,31 +1474,26 @@ static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); unsigned long flags; int q, mapping; - u8 hlid = 0; + u8 hlid; mapping = skb_get_queue_mapping(skb); q = wl1271_tx_get_queue(mapping); - if (wlvif->bss_type == BSS_TYPE_AP_BSS) - hlid = wl12xx_tx_get_hlid_ap(wl, wlvif, skb); + hlid = wl12xx_tx_get_hlid(wl, wlvif, skb); spin_lock_irqsave(&wl->wl_lock, flags); /* queue the packet */ - if (wlvif->bss_type == BSS_TYPE_AP_BSS) { - if (!test_bit(hlid, wlvif->links_map)) { - wl1271_debug(DEBUG_TX, "DROP skb hlid %d q %d", - hlid, q); - dev_kfree_skb(skb); - goto out; - } - - wl1271_debug(DEBUG_TX, "queue skb hlid %d q %d", hlid, q); - skb_queue_tail(&wl->links[hlid].tx_queue[q], skb); - } else { - skb_queue_tail(&wl->tx_queue[q], skb); + if (hlid == WL12XX_INVALID_LINK_ID || + !test_bit(hlid, wlvif->links_map)) { + wl1271_debug(DEBUG_TX, "DROP skb hlid %d q %d", hlid, q); + dev_kfree_skb(skb); + goto out; } + wl1271_debug(DEBUG_TX, "queue skb hlid %d q %d", hlid, q); + skb_queue_tail(&wl->links[hlid].tx_queue[q], skb); + wl->tx_queue_count[q]++; /* @@ -2131,7 +2126,8 @@ deinit: mutex_lock(&wl->mutex); /* let's notify MAC80211 about the remaining pending TX frames */ - wl1271_tx_reset(wl, reset_tx_queues); + wl12xx_tx_reset_wlvif(wl, wlvif); + wl12xx_tx_reset(wl, reset_tx_queues); wl1271_power_off(wl); wl->band = IEEE80211_BAND_2GHZ; @@ -3968,7 +3964,6 @@ static int wl1271_allocate_sta(struct wl1271 *wl, return 0; } -/* TODO: change wl1271_tx_reset(), so we can get sta as param */ void wl1271_free_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 hlid) { if (!test_bit(hlid, wlvif->ap.sta_hlid_map)) @@ -4867,9 +4862,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->hw = hw; wl->plat_dev = plat_dev; - for (i = 0; i < NUM_TX_QUEUES; i++) - skb_queue_head_init(&wl->tx_queue[i]); - for (i = 0; i < NUM_TX_QUEUES; i++) for (j = 0; j < WL12XX_MAX_LINKS; j++) skb_queue_head_init(&wl->links[j].tx_queue[i]); diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 951ff03b7f42..6c0135b27820 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -179,12 +179,10 @@ u8 wl12xx_tx_get_hlid_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif, } } -static u8 wl1271_tx_get_hlid(struct wl1271 *wl, struct ieee80211_vif *vif, - struct sk_buff *skb) +u8 wl12xx_tx_get_hlid(struct wl1271 *wl, struct wl12xx_vif *wlvif, + struct sk_buff *skb) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); - if (wl12xx_is_dummy_packet(wl, skb)) return wl->system_hlid; @@ -429,7 +427,7 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct sk_buff *skb, wlvif->default_key = idx; } } - hlid = wl1271_tx_get_hlid(wl, vif, skb); + hlid = wl12xx_tx_get_hlid(wl, wlvif, skb); if (hlid == WL12XX_INVALID_LINK_ID) { wl1271_error("invalid hlid. dropping skb 0x%p", skb); return -EINVAL; @@ -538,19 +536,18 @@ static struct sk_buff_head *wl1271_select_queue(struct wl1271 *wl, return &queues[q]; } -static struct sk_buff *wl1271_sta_skb_dequeue(struct wl1271 *wl) +static struct sk_buff *wl12xx_lnk_skb_dequeue(struct wl1271 *wl, + struct wl1271_link *lnk) { - struct sk_buff *skb = NULL; + struct sk_buff *skb; unsigned long flags; struct sk_buff_head *queue; - queue = wl1271_select_queue(wl, wl->tx_queue); + queue = wl1271_select_queue(wl, lnk->tx_queue); if (!queue) - goto out; + return NULL; skb = skb_dequeue(queue); - -out: if (skb) { int q = wl1271_tx_get_queue(skb_get_queue_mapping(skb)); spin_lock_irqsave(&wl->wl_lock, flags); @@ -561,13 +558,11 @@ out: return skb; } -static struct sk_buff *wl1271_ap_skb_dequeue(struct wl1271 *wl, - struct wl12xx_vif *wlvif) +static struct sk_buff *wl12xx_vif_skb_dequeue(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { struct sk_buff *skb = NULL; - unsigned long flags; int i, h, start_hlid; - struct sk_buff_head *queue; /* start from the link after the last one */ start_hlid = (wlvif->last_tx_hlid + 1) % WL12XX_MAX_LINKS; @@ -580,24 +575,16 @@ static struct sk_buff *wl1271_ap_skb_dequeue(struct wl1271 *wl, if (!test_bit(h, wlvif->links_map)) continue; - queue = wl1271_select_queue(wl, wl->links[h].tx_queue); - if (!queue) + skb = wl12xx_lnk_skb_dequeue(wl, &wl->links[h]); + if (!skb) continue; - skb = skb_dequeue(queue); - if (skb) - break; + wlvif->last_tx_hlid = h; + break; } - if (skb) { - int q = wl1271_tx_get_queue(skb_get_queue_mapping(skb)); - wlvif->last_tx_hlid = h; - spin_lock_irqsave(&wl->wl_lock, flags); - wl->tx_queue_count[q]--; - spin_unlock_irqrestore(&wl->wl_lock, flags); - } else { + if (!skb) wlvif->last_tx_hlid = 0; - } return skb; } @@ -608,11 +595,7 @@ static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl, unsigned long flags; struct sk_buff *skb = NULL; - if (wlvif->bss_type == BSS_TYPE_AP_BSS) - skb = wl1271_ap_skb_dequeue(wl, wlvif); - else - skb = wl1271_sta_skb_dequeue(wl); - + skb = wl12xx_vif_skb_dequeue(wl, wlvif); if (!skb && test_and_clear_bit(WL1271_FLAG_DUMMY_PACKET_PENDING, &wl->flags)) { int q; @@ -627,24 +610,21 @@ static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl, return skb; } -static void wl1271_skb_queue_head(struct wl1271 *wl, struct ieee80211_vif *vif, +static void wl1271_skb_queue_head(struct wl1271 *wl, struct wl12xx_vif *wlvif, struct sk_buff *skb) { - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); unsigned long flags; int q = wl1271_tx_get_queue(skb_get_queue_mapping(skb)); if (wl12xx_is_dummy_packet(wl, skb)) { set_bit(WL1271_FLAG_DUMMY_PACKET_PENDING, &wl->flags); - } else if (wlvif->bss_type == BSS_TYPE_AP_BSS) { - u8 hlid = wl1271_tx_get_hlid(wl, vif, skb); + } else { + u8 hlid = wl12xx_tx_get_hlid(wl, wlvif, skb); skb_queue_head(&wl->links[hlid].tx_queue[q], skb); /* make sure we dequeue the same packet next time */ wlvif->last_tx_hlid = (hlid + WL12XX_MAX_LINKS - 1) % - WL12XX_MAX_LINKS; - } else { - skb_queue_head(&wl->tx_queue[q], skb); + WL12XX_MAX_LINKS; } spin_lock_irqsave(&wl->wl_lock, flags); @@ -682,7 +662,7 @@ void wl1271_tx_work_locked(struct wl1271 *wl, struct ieee80211_vif *vif) * Aggregation buffer is full. * Flush buffer and try again. */ - wl1271_skb_queue_head(wl, vif, skb); + wl1271_skb_queue_head(wl, wlvif, skb); wl1271_write(wl, WL1271_SLV_MEM_DATA, wl->aggr_buf, buf_offset, true); sent_packets = true; @@ -693,7 +673,7 @@ void wl1271_tx_work_locked(struct wl1271 *wl, struct ieee80211_vif *vif) * Firmware buffer is full. * Queue back last skb, and stop aggregating. */ - wl1271_skb_queue_head(wl, vif, skb); + wl1271_skb_queue_head(wl, wlvif, skb); /* No work left, avoid scheduling redundant tx work */ set_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags); goto out_ack; @@ -907,41 +887,30 @@ void wl1271_tx_reset_link_queues(struct wl1271 *wl, u8 hlid) } /* caller must hold wl->mutex and TX must be stopped */ -void wl1271_tx_reset(struct wl1271 *wl, bool reset_tx_queues) +void wl12xx_tx_reset_wlvif(struct wl1271 *wl, struct wl12xx_vif *wlvif) { - struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int i; - struct sk_buff *skb; - struct ieee80211_tx_info *info; /* TX failure */ - if (wlvif->bss_type == BSS_TYPE_AP_BSS) { - for (i = 0; i < WL12XX_MAX_LINKS; i++) { + for_each_set_bit(i, wlvif->links_map, WL12XX_MAX_LINKS) { + if (wlvif->bss_type == BSS_TYPE_AP_BSS) wl1271_free_sta(wl, wlvif, i); - wl1271_tx_reset_link_queues(wl, i); - wl->links[i].allocated_pkts = 0; - wl->links[i].prev_freed_pkts = 0; - } - - wlvif->last_tx_hlid = 0; - } else { - for (i = 0; i < NUM_TX_QUEUES; i++) { - while ((skb = skb_dequeue(&wl->tx_queue[i]))) { - wl1271_debug(DEBUG_TX, "freeing skb 0x%p", - skb); - - if (!wl12xx_is_dummy_packet(wl, skb)) { - info = IEEE80211_SKB_CB(skb); - info->status.rates[0].idx = -1; - info->status.rates[0].count = 0; - ieee80211_tx_status_ni(wl->hw, skb); - } - } - } + else + wlvif->sta.ba_rx_bitmap = 0; - wlvif->sta.ba_rx_bitmap = 0; + wl1271_tx_reset_link_queues(wl, i); + wl->links[i].allocated_pkts = 0; + wl->links[i].prev_freed_pkts = 0; } + wlvif->last_tx_hlid = 0; + +} +/* caller must hold wl->mutex and TX must be stopped */ +void wl12xx_tx_reset(struct wl1271 *wl, bool reset_tx_queues) +{ + int i; + struct sk_buff *skb; + struct ieee80211_tx_info *info; for (i = 0; i < NUM_TX_QUEUES; i++) wl->tx_queue_count[i] = 0; diff --git a/drivers/net/wireless/wl12xx/tx.h b/drivers/net/wireless/wl12xx/tx.h index add4402d7931..050a04792600 100644 --- a/drivers/net/wireless/wl12xx/tx.h +++ b/drivers/net/wireless/wl12xx/tx.h @@ -206,7 +206,8 @@ static inline int wl1271_tx_total_queue_count(struct wl1271 *wl) void wl1271_tx_work(struct work_struct *work); void wl1271_tx_work_locked(struct wl1271 *wl, struct ieee80211_vif *vif); void wl1271_tx_complete(struct wl1271 *wl); -void wl1271_tx_reset(struct wl1271 *wl, bool reset_tx_queues); +void wl12xx_tx_reset_wlvif(struct wl1271 *wl, struct wl12xx_vif *wlvif); +void wl12xx_tx_reset(struct wl1271 *wl, bool reset_tx_queues); void wl1271_tx_flush(struct wl1271 *wl); u8 wl1271_rate_to_idx(int rate, enum ieee80211_band band); u32 wl1271_tx_enabled_rates_get(struct wl1271 *wl, u32 rate_set, @@ -214,6 +215,8 @@ u32 wl1271_tx_enabled_rates_get(struct wl1271 *wl, u32 rate_set, u32 wl1271_tx_min_rate_get(struct wl1271 *wl, u32 rate_set); u8 wl12xx_tx_get_hlid_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif, struct sk_buff *skb); +u8 wl12xx_tx_get_hlid(struct wl1271 *wl, struct wl12xx_vif *wlvif, + struct sk_buff *skb); void wl1271_tx_reset_link_queues(struct wl1271 *wl, u8 hlid); void wl1271_handle_tx_low_watermark(struct wl1271 *wl); bool wl12xx_is_dummy_packet(struct wl1271 *wl, struct sk_buff *skb); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index b350f0bdd38d..4802f685de63 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -416,7 +416,6 @@ struct wl1271 { s64 time_offset; /* Frames scheduled for transmission, not handled yet */ - struct sk_buff_head tx_queue[NUM_TX_QUEUES]; int tx_queue_count[NUM_TX_QUEUES]; long stopped_queues_map; -- cgit v1.2.3 From baf6277ae964b1d3830aa74b13e87ff9ba29145c Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:12:52 +0200 Subject: wl12xx: move some functions from remove_interface() to stop() Leave only vif-specific deinit stuff in remove_interface(). Move the global deinit (including power_off) to stop(). Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 157 ++++++++++++++++++++----------------- 1 file changed, 83 insertions(+), 74 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index abe5ef8807ba..e53829aab92e 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1803,7 +1803,83 @@ static int wl1271_op_start(struct ieee80211_hw *hw) static void wl1271_op_stop(struct ieee80211_hw *hw) { + struct wl1271 *wl = hw->priv; + int i; + wl1271_debug(DEBUG_MAC80211, "mac80211 stop"); + + mutex_lock(&wl_list_mutex); + list_del(&wl->list); + + /* + * this must be before the cancel_work calls below, so that the work + * functions don't perform further work. + */ + wl->state = WL1271_STATE_OFF; + mutex_unlock(&wl_list_mutex); + + wl1271_disable_interrupts(wl); + wl1271_flush_deferred_work(wl); + cancel_delayed_work_sync(&wl->scan_complete_work); + cancel_work_sync(&wl->netstack_work); + cancel_work_sync(&wl->tx_work); + del_timer_sync(&wl->rx_streaming_timer); + cancel_work_sync(&wl->rx_streaming_enable_work); + cancel_work_sync(&wl->rx_streaming_disable_work); + cancel_delayed_work_sync(&wl->elp_work); + + /* let's notify MAC80211 about the remaining pending TX frames */ + wl12xx_tx_reset(wl, true); + mutex_lock(&wl->mutex); + + wl1271_power_off(wl); + + wl->band = IEEE80211_BAND_2GHZ; + + wl->rx_counter = 0; + wl->power_level = WL1271_DEFAULT_POWER_LEVEL; + wl->tx_blocks_available = 0; + wl->tx_allocated_blocks = 0; + wl->tx_results_count = 0; + wl->tx_packets_count = 0; + wl->time_offset = 0; + wl->vif = NULL; + wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; + wl->ap_fw_ps_map = 0; + wl->ap_ps_map = 0; + wl->sched_scanning = false; + memset(wl->roles_map, 0, sizeof(wl->roles_map)); + memset(wl->links_map, 0, sizeof(wl->links_map)); + memset(wl->roc_map, 0, sizeof(wl->roc_map)); + wl->active_sta_count = 0; + + /* The system link is always allocated */ + __set_bit(WL12XX_SYSTEM_HLID, wl->links_map); + + /* + * this is performed after the cancel_work calls and the associated + * mutex_lock, so that wl1271_op_add_interface does not accidentally + * get executed before all these vars have been reset. + */ + wl->flags = 0; + + wl->tx_blocks_freed = 0; + + for (i = 0; i < NUM_TX_QUEUES; i++) { + wl->tx_pkts_freed[i] = 0; + wl->tx_allocated_pkts[i] = 0; + } + + wl1271_debugfs_reset(wl); + + kfree(wl->fw_status); + wl->fw_status = NULL; + kfree(wl->tx_res_if); + wl->tx_res_if = NULL; + kfree(wl->target_mem_map); + wl->target_mem_map = NULL; + + mutex_unlock(&wl->mutex); } static u8 wl12xx_get_role_type(struct wl1271 *wl, struct wl12xx_vif *wlvif) @@ -2053,7 +2129,7 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, bool reset_tx_queues) { struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); - int ret, i; + int ret; wl1271_debug(DEBUG_MAC80211, "mac80211 remove interface"); @@ -2063,15 +2139,12 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, wl1271_info("down"); - mutex_lock(&wl_list_mutex); - list_del(&wl->list); - mutex_unlock(&wl_list_mutex); - /* enable dyn ps just in case (if left on due to fw crash etc) */ if (wlvif->bss_type == BSS_TYPE_STA_BSS) - ieee80211_enable_dyn_ps(wl->vif); + ieee80211_enable_dyn_ps(vif); - if (wl->scan.state != WL1271_SCAN_STATE_IDLE) { + if (wl->scan.state != WL1271_SCAN_STATE_IDLE && + wl->scan_vif == vif) { wl->scan.state = WL1271_SCAN_STATE_IDLE; memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch)); wl->scan_vif = NULL; @@ -2104,82 +2177,18 @@ deinit: wlvif->ap.bcast_hlid = WL12XX_INVALID_LINK_ID; wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID; - /* - * this must be before the cancel_work calls below, so that the work - * functions don't perform further work. - */ - wl->state = WL1271_STATE_OFF; - - mutex_unlock(&wl->mutex); - - wl1271_disable_interrupts(wl); - wl1271_flush_deferred_work(wl); - cancel_delayed_work_sync(&wl->scan_complete_work); - cancel_work_sync(&wl->netstack_work); - cancel_work_sync(&wl->tx_work); - del_timer_sync(&wl->rx_streaming_timer); - cancel_work_sync(&wl->rx_streaming_enable_work); - cancel_work_sync(&wl->rx_streaming_disable_work); - cancel_delayed_work_sync(&wlvif->pspoll_work); - cancel_delayed_work_sync(&wl->elp_work); - - mutex_lock(&wl->mutex); - - /* let's notify MAC80211 about the remaining pending TX frames */ wl12xx_tx_reset_wlvif(wl, wlvif); - wl12xx_tx_reset(wl, reset_tx_queues); - wl1271_power_off(wl); - - wl->band = IEEE80211_BAND_2GHZ; - - wl->rx_counter = 0; - wl->power_level = WL1271_DEFAULT_POWER_LEVEL; - wl->tx_blocks_available = 0; - wl->tx_allocated_blocks = 0; - wl->tx_results_count = 0; - wl->tx_packets_count = 0; - wl->time_offset = 0; wl->bitrate_masks[IEEE80211_BAND_2GHZ] = wl->conf.tx.basic_rate; wl->bitrate_masks[IEEE80211_BAND_5GHZ] = wl->conf.tx.basic_rate_5; - wl->vif = NULL; - wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; wl1271_free_ap_keys(wl, wlvif); memset(wlvif->ap.sta_hlid_map, 0, sizeof(wlvif->ap.sta_hlid_map)); - wl->ap_fw_ps_map = 0; - wl->ap_ps_map = 0; - wl->sched_scanning = false; wlvif->role_id = WL12XX_INVALID_ROLE_ID; wlvif->dev_role_id = WL12XX_INVALID_ROLE_ID; - memset(wl->roles_map, 0, sizeof(wl->roles_map)); - memset(wl->links_map, 0, sizeof(wl->links_map)); - memset(wl->roc_map, 0, sizeof(wl->roc_map)); - wl->active_sta_count = 0; - /* The system link is always allocated */ - __set_bit(WL12XX_SYSTEM_HLID, wl->links_map); - - /* - * this is performed after the cancel_work calls and the associated - * mutex_lock, so that wl1271_op_add_interface does not accidentally - * get executed before all these vars have been reset. - */ - wl->flags = 0; - - wl->tx_blocks_freed = 0; - - for (i = 0; i < NUM_TX_QUEUES; i++) { - wl->tx_pkts_freed[i] = 0; - wl->tx_allocated_pkts[i] = 0; - } - - wl1271_debugfs_reset(wl); + mutex_unlock(&wl->mutex); + cancel_delayed_work_sync(&wlvif->pspoll_work); - kfree(wl->fw_status); - wl->fw_status = NULL; - kfree(wl->tx_res_if); - wl->tx_res_if = NULL; - kfree(wl->target_mem_map); - wl->target_mem_map = NULL; + mutex_lock(&wl->mutex); } static void wl1271_op_remove_interface(struct ieee80211_hw *hw, -- cgit v1.2.3 From 83587505a2b63bb434f76b26a22f48283b86a467 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:12:53 +0200 Subject: wl12xx: move bitrate_masks into wlvif move bitrate_masks into the per-interface data, rather than being global. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 13 ++++++++----- drivers/net/wireless/wl12xx/cmd.h | 3 ++- drivers/net/wireless/wl12xx/main.c | 16 ++++++++-------- drivers/net/wireless/wl12xx/scan.c | 21 +++++++++++---------- drivers/net/wireless/wl12xx/wl12xx.h | 3 +-- 5 files changed, 30 insertions(+), 26 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 102a8a5371e4..ff653e8832a8 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -1111,15 +1111,16 @@ out: return ret; } -int wl1271_cmd_build_probe_req(struct wl1271 *wl, +int wl1271_cmd_build_probe_req(struct wl1271 *wl, struct wl12xx_vif *wlvif, const u8 *ssid, size_t ssid_len, const u8 *ie, size_t ie_len, u8 band) { + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); struct sk_buff *skb; int ret; u32 rate; - skb = ieee80211_probereq_get(wl->hw, wl->vif, ssid, ssid_len, + skb = ieee80211_probereq_get(wl->hw, vif, ssid, ssid_len, ie, ie_len); if (!skb) { ret = -ENOMEM; @@ -1128,7 +1129,7 @@ int wl1271_cmd_build_probe_req(struct wl1271 *wl, wl1271_dump(DEBUG_SCAN, "PROBE REQ: ", skb->data, skb->len); - rate = wl1271_tx_min_rate_get(wl, wl->bitrate_masks[band]); + rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[band]); if (band == IEEE80211_BAND_2GHZ) ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_2_4, skb->data, skb->len, 0, rate); @@ -1142,19 +1143,21 @@ out: } struct sk_buff *wl1271_cmd_build_ap_probe_req(struct wl1271 *wl, + struct wl12xx_vif *wlvif, struct sk_buff *skb) { + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); int ret; u32 rate; if (!skb) - skb = ieee80211_ap_probereq_get(wl->hw, wl->vif); + skb = ieee80211_ap_probereq_get(wl->hw, vif); if (!skb) goto out; wl1271_dump(DEBUG_SCAN, "AP PROBE REQ: ", skb->data, skb->len); - rate = wl1271_tx_min_rate_get(wl, wl->bitrate_masks[wl->band]); + rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[wl->band]); if (wl->band == IEEE80211_BAND_2GHZ) ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_2_4, skb->data, skb->len, 0, rate); diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index d2670d379b75..8182cf1b4861 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -59,10 +59,11 @@ int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id, int wl12xx_cmd_build_null_data(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl1271_cmd_build_ps_poll(struct wl1271 *wl, struct wl12xx_vif *wlvif, u16 aid); -int wl1271_cmd_build_probe_req(struct wl1271 *wl, +int wl1271_cmd_build_probe_req(struct wl1271 *wl, struct wl12xx_vif *wlvif, const u8 *ssid, size_t ssid_len, const u8 *ie, size_t ie_len, u8 band); struct sk_buff *wl1271_cmd_build_ap_probe_req(struct wl1271 *wl, + struct wl12xx_vif *wlvif, struct sk_buff *skb); int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, struct wl12xx_vif *wlvif, __be32 ip_addr); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index e53829aab92e..acfc49743d22 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1906,7 +1906,7 @@ static u8 wl12xx_get_role_type(struct wl1271 *wl, struct wl12xx_vif *wlvif) return WL12XX_INVALID_ROLE_TYPE; } -static int wl12xx_init_vif_data(struct ieee80211_vif *vif) +static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) { struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); @@ -1949,6 +1949,8 @@ static int wl12xx_init_vif_data(struct ieee80211_vif *vif) wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID; } + wlvif->bitrate_masks[IEEE80211_BAND_2GHZ] = wl->conf.tx.basic_rate; + wlvif->bitrate_masks[IEEE80211_BAND_5GHZ] = wl->conf.tx.basic_rate_5; wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC; wlvif->basic_rate = CONF_TX_RATE_MASK_BASIC; wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; @@ -2058,7 +2060,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, goto out; } - ret = wl12xx_init_vif_data(vif); + ret = wl12xx_init_vif_data(wl, vif); if (ret < 0) goto out; @@ -2178,8 +2180,6 @@ deinit: wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID; wl12xx_tx_reset_wlvif(wl, wlvif); - wl->bitrate_masks[IEEE80211_BAND_2GHZ] = wl->conf.tx.basic_rate; - wl->bitrate_masks[IEEE80211_BAND_5GHZ] = wl->conf.tx.basic_rate_5; wl1271_free_ap_keys(wl, wlvif); memset(wlvif->ap.sta_hlid_map, 0, sizeof(wlvif->ap.sta_hlid_map)); wlvif->role_id = WL12XX_INVALID_ROLE_ID; @@ -2293,7 +2293,7 @@ out: static void wl1271_set_band_rate(struct wl1271 *wl, struct wl12xx_vif *wlvif) { - wlvif->basic_rate_set = wl->bitrate_masks[wl->band]; + wlvif->basic_rate_set = wlvif->bitrate_masks[wl->band]; wlvif->rate_set = wlvif->basic_rate_set; } @@ -3578,6 +3578,7 @@ sta_not_found: */ dev_kfree_skb(wlvif->probereq); wlvif->probereq = wl1271_cmd_build_ap_probe_req(wl, + wlvif, NULL); ieoffset = offsetof(struct ieee80211_mgmt, u.probe_req.variable); @@ -4202,6 +4203,7 @@ static int wl12xx_set_bitrate_mask(struct ieee80211_hw *hw, struct ieee80211_vif *vif, const struct cfg80211_bitrate_mask *mask) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct wl1271 *wl = hw->priv; int i; @@ -4212,7 +4214,7 @@ static int wl12xx_set_bitrate_mask(struct ieee80211_hw *hw, mutex_lock(&wl->mutex); for (i = 0; i < IEEE80211_NUM_BANDS; i++) - wl->bitrate_masks[i] = + wlvif->bitrate_masks[i] = wl1271_tx_enabled_rates_get(wl, mask->control[i].legacy, i); @@ -4931,8 +4933,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) /* Apply default driver configuration. */ wl1271_conf_init(wl); - wl->bitrate_masks[IEEE80211_BAND_2GHZ] = wl->conf.tx.basic_rate; - wl->bitrate_masks[IEEE80211_BAND_5GHZ] = wl->conf.tx.basic_rate_5; order = get_order(WL1271_AGGR_BUFFER_SIZE); wl->aggr_buf = (u8 *)__get_free_pages(GFP_KERNEL, order); diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index 9372136b27e4..e1a8ce092e39 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -66,7 +66,7 @@ void wl1271_scan_complete_work(struct work_struct *work) if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) { /* restore hardware connection monitoring template */ - wl1271_cmd_build_ap_probe_req(wl, wlvif->probereq); + wl1271_cmd_build_ap_probe_req(wl, wlvif, wlvif->probereq); } /* return to ROC if needed */ @@ -218,9 +218,9 @@ static int wl1271_scan_send(struct wl1271 *wl, struct ieee80211_vif *vif, memcpy(cmd->addr, vif->addr, ETH_ALEN); - ret = wl1271_cmd_build_probe_req(wl, wl->scan.ssid, wl->scan.ssid_len, - wl->scan.req->ie, wl->scan.req->ie_len, - band); + ret = wl1271_cmd_build_probe_req(wl, wlvif, wl->scan.ssid, + wl->scan.ssid_len, wl->scan.req->ie, + wl->scan.req->ie_len, band); if (ret < 0) { wl1271_error("PROBE request template failed"); goto out; @@ -251,6 +251,7 @@ out: void wl1271_scan_stm(struct wl1271 *wl, struct ieee80211_vif *vif) { + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret = 0; enum ieee80211_band band; u32 rate; @@ -261,7 +262,7 @@ void wl1271_scan_stm(struct wl1271 *wl, struct ieee80211_vif *vif) case WL1271_SCAN_STATE_2GHZ_ACTIVE: band = IEEE80211_BAND_2GHZ; - rate = wl1271_tx_min_rate_get(wl, wl->bitrate_masks[band]); + rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[band]); ret = wl1271_scan_send(wl, vif, band, false, rate); if (ret == WL1271_NOTHING_TO_SCAN) { wl->scan.state = WL1271_SCAN_STATE_2GHZ_PASSIVE; @@ -272,7 +273,7 @@ void wl1271_scan_stm(struct wl1271 *wl, struct ieee80211_vif *vif) case WL1271_SCAN_STATE_2GHZ_PASSIVE: band = IEEE80211_BAND_2GHZ; - rate = wl1271_tx_min_rate_get(wl, wl->bitrate_masks[band]); + rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[band]); ret = wl1271_scan_send(wl, vif, band, true, rate); if (ret == WL1271_NOTHING_TO_SCAN) { if (wl->enable_11a) @@ -286,7 +287,7 @@ void wl1271_scan_stm(struct wl1271 *wl, struct ieee80211_vif *vif) case WL1271_SCAN_STATE_5GHZ_ACTIVE: band = IEEE80211_BAND_5GHZ; - rate = wl1271_tx_min_rate_get(wl, wl->bitrate_masks[band]); + rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[band]); ret = wl1271_scan_send(wl, vif, band, false, rate); if (ret == WL1271_NOTHING_TO_SCAN) { wl->scan.state = WL1271_SCAN_STATE_5GHZ_PASSIVE; @@ -297,7 +298,7 @@ void wl1271_scan_stm(struct wl1271 *wl, struct ieee80211_vif *vif) case WL1271_SCAN_STATE_5GHZ_PASSIVE: band = IEEE80211_BAND_5GHZ; - rate = wl1271_tx_min_rate_get(wl, wl->bitrate_masks[band]); + rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[band]); ret = wl1271_scan_send(wl, vif, band, true, rate); if (ret == WL1271_NOTHING_TO_SCAN) { wl->scan.state = WL1271_SCAN_STATE_DONE; @@ -642,7 +643,7 @@ int wl1271_scan_sched_scan_config(struct wl1271 *wl, } if (!force_passive && cfg->active[0]) { - ret = wl1271_cmd_build_probe_req(wl, req->ssids[0].ssid, + ret = wl1271_cmd_build_probe_req(wl, wlvif, req->ssids[0].ssid, req->ssids[0].ssid_len, ies->ie[IEEE80211_BAND_2GHZ], ies->len[IEEE80211_BAND_2GHZ], @@ -654,7 +655,7 @@ int wl1271_scan_sched_scan_config(struct wl1271 *wl, } if (!force_passive && cfg->active[1]) { - ret = wl1271_cmd_build_probe_req(wl, req->ssids[0].ssid, + ret = wl1271_cmd_build_probe_req(wl, wlvif, req->ssids[0].ssid, req->ssids[0].ssid_len, ies->ie[IEEE80211_BAND_5GHZ], ies->len[IEEE80211_BAND_5GHZ], diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 4802f685de63..33ccdf84c432 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -484,8 +484,6 @@ struct wl1271 { bool sched_scanning; - u32 bitrate_masks[IEEE80211_NUM_BANDS]; - /* The current band */ enum ieee80211_band band; @@ -600,6 +598,7 @@ struct wl12xx_vif { u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; u8 ssid_len; + u32 bitrate_masks[IEEE80211_NUM_BANDS]; u32 basic_rate_set; /* -- cgit v1.2.3 From 87627214738fcfd44803e90193f9f2f4583ce68b Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:12:54 +0200 Subject: wl12xx: add vifs list keep a list of all the vifs associated with our hw. it will be later used in order to iterate through vifs. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 4 ++++ drivers/net/wireless/wl12xx/wl12xx.h | 6 ++++++ 2 files changed, 10 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index acfc49743d22..56d592398677 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1957,6 +1957,7 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) wlvif->beacon_int = WL1271_DEFAULT_BEACON_INT; INIT_DELAYED_WORK(&wlvif->pspoll_work, wl1271_pspoll_work); + INIT_LIST_HEAD(&wlvif->list); return 0; } @@ -2114,6 +2115,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, goto out; wl->vif = vif; + list_add(&wlvif->list, &wl->wlvif_list); set_bit(WL1271_FLAG_IF_INITIALIZED, &wl->flags); out: mutex_unlock(&wl->mutex); @@ -2181,6 +2183,7 @@ deinit: wl12xx_tx_reset_wlvif(wl, wlvif); wl1271_free_ap_keys(wl, wlvif); + list_del(&wlvif->list); memset(wlvif->ap.sta_hlid_map, 0, sizeof(wlvif->ap.sta_hlid_map)); wlvif->role_id = WL12XX_INVALID_ROLE_ID; wlvif->dev_role_id = WL12XX_INVALID_ROLE_ID; @@ -4869,6 +4872,7 @@ struct ieee80211_hw *wl1271_alloc_hw(void) memset(wl, 0, sizeof(*wl)); INIT_LIST_HEAD(&wl->list); + INIT_LIST_HEAD(&wl->wlvif_list); wl->hw = hw; wl->plat_dev = plat_dev; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 33ccdf84c432..55561c597ad9 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -394,6 +394,8 @@ struct wl1271 { unsigned long roles_map[BITS_TO_LONGS(WL12XX_MAX_ROLES)]; unsigned long roc_map[BITS_TO_LONGS(WL12XX_MAX_ROLES)]; + struct list_head wlvif_list; + struct wl1271_acx_mem_map *target_mem_map; /* Accounting for allocated / available TX blocks on HW */ @@ -564,6 +566,7 @@ struct wl1271_station { struct wl12xx_vif { struct wl1271 *wl; + struct list_head list; u8 bss_type; u8 p2p; /* we are using p2p role */ u8 role_id; @@ -653,6 +656,9 @@ struct ieee80211_vif *wl12xx_wlvif_to_vif(struct wl12xx_vif *wlvif) return container_of((void *)wlvif, struct ieee80211_vif, drv_priv); } +#define wl12xx_for_each_wlvif(wl, wlvif) \ + list_for_each_entry(wlvif, &wl->wlvif_list, list) + int wl1271_plt_start(struct wl1271 *wl); int wl1271_plt_stop(struct wl1271 *wl); int wl1271_recalc_rx_streaming(struct wl1271 *wl); -- cgit v1.2.3 From a32d0cdfcb7e5d41f210e13cbc78dc86a5a85a08 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:12:55 +0200 Subject: wl12xx: support multiple vifs in the tx path Pass the wlvif associated with each skb as param. Note that dummy packet doesn't belong to any particular vif, so we pass NULL in this case. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 6 +-- drivers/net/wireless/wl12xx/tx.c | 79 +++++++++++++++++++++++--------------- drivers/net/wireless/wl12xx/tx.h | 2 +- 3 files changed, 52 insertions(+), 35 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 56d592398677..0623f5dc02ca 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -993,7 +993,7 @@ irqreturn_t wl1271_irq(int irq, void *cookie) * In order to avoid starvation of the TX path, * call the work function directly. */ - wl1271_tx_work_locked(wl, wl->vif); + wl1271_tx_work_locked(wl); } else { spin_unlock_irqrestore(&wl->wl_lock, flags); } @@ -1537,7 +1537,7 @@ int wl1271_tx_dummy_packet(struct wl1271 *wl) /* The FW is low on RX memory blocks, so send the dummy packet asap */ if (!test_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags)) - wl1271_tx_work_locked(wl, wl->vif); + wl1271_tx_work_locked(wl); /* * If the FW TX is busy, TX work will be scheduled by the threaded @@ -2413,7 +2413,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) ((wl->band != conf->channel->band) || (wl->channel != channel))) { /* send all pending packets */ - wl1271_tx_work_locked(wl, vif); + wl1271_tx_work_locked(wl); wl->band = conf->channel->band; wl->channel = channel; diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 6c0135b27820..c7be15186c4a 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -210,17 +210,17 @@ static unsigned int wl12xx_calc_packet_alignment(struct wl1271 *wl, return ALIGN(packet_length, WL1271_TX_ALIGN_TO); } -static int wl1271_tx_allocate(struct wl1271 *wl, struct ieee80211_vif *vif, +static int wl1271_tx_allocate(struct wl1271 *wl, struct wl12xx_vif *wlvif, struct sk_buff *skb, u32 extra, u32 buf_offset, u8 hlid) { - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct wl1271_tx_hw_descr *desc; u32 total_len = skb->len + sizeof(struct wl1271_tx_hw_descr) + extra; u32 len; u32 total_blocks; int id, ret = -EBUSY, ac; u32 spare_blocks = wl->tx_spare_blocks; + bool is_dummy = false; if (buf_offset + total_len > WL1271_AGGR_BUFFER_SIZE) return -EAGAIN; @@ -235,8 +235,10 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct ieee80211_vif *vif, len = wl12xx_calc_packet_alignment(wl, total_len); /* in case of a dummy packet, use default amount of spare mem blocks */ - if (unlikely(wl12xx_is_dummy_packet(wl, skb))) + if (unlikely(wl12xx_is_dummy_packet(wl, skb))) { + is_dummy = true; spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; + } total_blocks = (len + TX_HW_BLOCK_SIZE - 1) / TX_HW_BLOCK_SIZE + spare_blocks; @@ -261,7 +263,7 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct ieee80211_vif *vif, ac = wl1271_tx_get_queue(skb_get_queue_mapping(skb)); wl->tx_allocated_pkts[ac]++; - if (wlvif->bss_type == BSS_TYPE_AP_BSS && + if (!is_dummy && wlvif->bss_type == BSS_TYPE_AP_BSS && test_bit(hlid, wlvif->ap.sta_hlid_map)) wl->links[hlid].allocated_pkts++; @@ -277,16 +279,16 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct ieee80211_vif *vif, return ret; } -static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct ieee80211_vif *vif, +static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct wl12xx_vif *wlvif, struct sk_buff *skb, u32 extra, struct ieee80211_tx_info *control, u8 hlid) { - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct timespec ts; struct wl1271_tx_hw_descr *desc; int aligned_len, ac, rate_idx; s64 hosttime; u16 tx_attr; + bool is_dummy; desc = (struct wl1271_tx_hw_descr *) skb->data; @@ -303,7 +305,8 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct ieee80211_vif *vif, hosttime = (timespec_to_ns(&ts) >> 10); desc->start_time = cpu_to_le32(hosttime - wl->time_offset); - if (wlvif->bss_type != BSS_TYPE_AP_BSS) + is_dummy = wl12xx_is_dummy_packet(wl, skb); + if (is_dummy || wlvif->bss_type != BSS_TYPE_AP_BSS) desc->life_time = cpu_to_le16(TX_HW_MGMT_PKT_LIFETIME_TU); else desc->life_time = cpu_to_le16(TX_HW_AP_MODE_PKT_LIFETIME_TU); @@ -312,7 +315,7 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct ieee80211_vif *vif, ac = wl1271_tx_get_queue(skb_get_queue_mapping(skb)); desc->tid = skb->priority; - if (wl12xx_is_dummy_packet(wl, skb)) { + if (is_dummy) { /* * FW expects the dummy packet to have an invalid session id - * any session id that is different than the one set in the join @@ -329,7 +332,9 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct ieee80211_vif *vif, } desc->hlid = hlid; - if (wlvif->bss_type != BSS_TYPE_AP_BSS) { + if (is_dummy) + rate_idx = 0; + else if (wlvif->bss_type != BSS_TYPE_AP_BSS) { /* if the packets are destined for AP (have a STA entry) send them with AP rate policies, otherwise use default basic rates */ @@ -383,12 +388,10 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct ieee80211_vif *vif, } /* caller must hold wl->mutex */ -static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct sk_buff *skb, - u32 buf_offset) +static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct wl12xx_vif *wlvif, + struct sk_buff *skb, u32 buf_offset) { struct ieee80211_tx_info *info; - struct ieee80211_vif *vif; - struct wl12xx_vif *wlvif; u32 extra = 0; int ret = 0; u32 total_len; @@ -402,11 +405,6 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct sk_buff *skb, /* TODO: handle dummy packets on multi-vifs */ is_dummy = wl12xx_is_dummy_packet(wl, skb); - if (is_dummy) - info->control.vif = wl->vif; - - vif = info->control.vif; - wlvif = wl12xx_vif_to_data(vif); if (info->control.hw_key && info->control.hw_key->cipher == WLAN_CIPHER_SUITE_TKIP) @@ -433,13 +431,13 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct sk_buff *skb, return -EINVAL; } - ret = wl1271_tx_allocate(wl, vif, skb, extra, buf_offset, hlid); + ret = wl1271_tx_allocate(wl, wlvif, skb, extra, buf_offset, hlid); if (ret < 0) return ret; - wl1271_tx_fill_hdr(wl, vif, skb, extra, info, hlid); + wl1271_tx_fill_hdr(wl, wlvif, skb, extra, info, hlid); - if (wlvif->bss_type == BSS_TYPE_AP_BSS && !is_dummy) { + if (!is_dummy && wlvif->bss_type == BSS_TYPE_AP_BSS) { wl1271_tx_ap_update_inconnection_sta(wl, skb); wl1271_tx_regulate_link(wl, wlvif, hlid); } @@ -589,13 +587,19 @@ static struct sk_buff *wl12xx_vif_skb_dequeue(struct wl1271 *wl, return skb; } -static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl, - struct wl12xx_vif *wlvif) +static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl) { unsigned long flags; + struct wl12xx_vif *wlvif; struct sk_buff *skb = NULL; - skb = wl12xx_vif_skb_dequeue(wl, wlvif); + /* TODO: rememeber last vif and consider it */ + wl12xx_for_each_wlvif(wl, wlvif) { + skb = wl12xx_vif_skb_dequeue(wl, wlvif); + if (skb) + break; + } + if (!skb && test_and_clear_bit(WL1271_FLAG_DUMMY_PACKET_PENDING, &wl->flags)) { int q; @@ -639,24 +643,35 @@ static bool wl1271_tx_is_data_present(struct sk_buff *skb) return ieee80211_is_data_present(hdr->frame_control); } -void wl1271_tx_work_locked(struct wl1271 *wl, struct ieee80211_vif *vif) +void wl1271_tx_work_locked(struct wl1271 *wl) { - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + struct wl12xx_vif *wlvif; struct sk_buff *skb; u32 buf_offset = 0; bool sent_packets = false; bool had_data = false; - bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); + /* TODO: save bitmap of relevant stations */ + bool is_sta = false; int ret; if (unlikely(wl->state == WL1271_STATE_OFF)) return; - while ((skb = wl1271_skb_dequeue(wl, wlvif))) { + while ((skb = wl1271_skb_dequeue(wl))) { + wlvif = NULL; + if (!wl12xx_is_dummy_packet(wl, skb)) { + struct ieee80211_tx_info *info; + struct ieee80211_vif *vif; + + info = IEEE80211_SKB_CB(skb); + vif = info->control.vif; + wlvif = wl12xx_vif_to_data(vif); + } + if (wl1271_tx_is_data_present(skb)) had_data = true; - ret = wl1271_prepare_tx_frame(wl, skb, buf_offset); + ret = wl1271_prepare_tx_frame(wl, wlvif, skb, buf_offset); if (ret == -EAGAIN) { /* * Aggregation buffer is full. @@ -683,6 +698,8 @@ void wl1271_tx_work_locked(struct wl1271 *wl, struct ieee80211_vif *vif) } buf_offset += ret; wl->tx_packets_count++; + if (wlvif && wlvif->bss_type == BSS_TYPE_STA_BSS) + is_sta = true; } out_ack: @@ -702,7 +719,7 @@ out_ack: wl1271_handle_tx_low_watermark(wl); } - if (!is_ap && wl->conf.rx_streaming.interval && had_data && + if (is_sta && wl->conf.rx_streaming.interval && had_data && (wl->conf.rx_streaming.always || test_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags))) { u32 timeout = wl->conf.rx_streaming.duration; @@ -727,7 +744,7 @@ void wl1271_tx_work(struct work_struct *work) if (ret < 0) goto out; - wl1271_tx_work_locked(wl, wl->vif); + wl1271_tx_work_locked(wl); wl1271_ps_elp_sleep(wl); out: diff --git a/drivers/net/wireless/wl12xx/tx.h b/drivers/net/wireless/wl12xx/tx.h index 050a04792600..fe29ff524e9a 100644 --- a/drivers/net/wireless/wl12xx/tx.h +++ b/drivers/net/wireless/wl12xx/tx.h @@ -204,7 +204,7 @@ static inline int wl1271_tx_total_queue_count(struct wl1271 *wl) } void wl1271_tx_work(struct work_struct *work); -void wl1271_tx_work_locked(struct wl1271 *wl, struct ieee80211_vif *vif); +void wl1271_tx_work_locked(struct wl1271 *wl); void wl1271_tx_complete(struct wl1271 *wl); void wl12xx_tx_reset_wlvif(struct wl1271 *wl, struct wl12xx_vif *wlvif); void wl12xx_tx_reset(struct wl1271 *wl, bool reset_tx_queues); -- cgit v1.2.3 From a4e4130dcea01f3e0dfcbfeaf0d815b971e6e515 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 11 Oct 2011 11:49:15 +0200 Subject: wl12xx: configure sleep_policy according to active roles If there is an active AP role, stay always on. Otherwise, allow chip to enter elp. (Note that this is a global configuration, so if the device is already configured according to our policy, we don't have to configure it again) Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/init.c | 29 ++++++++++++++++++----------- drivers/net/wireless/wl12xx/main.c | 10 ++++++++++ drivers/net/wireless/wl12xx/wl12xx.h | 2 ++ 3 files changed, 30 insertions(+), 11 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index 80e89e319879..4af7e2fb52fd 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -343,11 +343,6 @@ static int wl1271_sta_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif) if (ret < 0) return ret; - /* Configure for ELP power saving */ - ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP); - if (ret < 0) - return ret; - ret = wl1271_acx_sta_rate_policies(wl, wlvif); if (ret < 0) return ret; @@ -382,11 +377,6 @@ static int wl1271_ap_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int ret; - /* Configure for power always on */ - ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM); - if (ret < 0) - return ret; - ret = wl1271_init_ap_rates(wl, wlvif); if (ret < 0) return ret; @@ -577,9 +567,26 @@ int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) struct conf_tx_ac_category *conf_ac; struct conf_tx_tid *conf_tid; bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); - int ret, i; + /* + * consider all existing roles before configuring psm. + * TODO: reconfigure on interface removal. + */ + if (!wl->ap_count) { + if (is_ap) { + /* Configure for power always on */ + ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_CAM); + if (ret < 0) + return ret; + } else if (!wl->sta_count) { + /* Configure for ELP power saving */ + ret = wl1271_acx_sleep_auth(wl, WL1271_PSM_ELP); + if (ret < 0) + return ret; + } + } + /* Mode specific init */ if (is_ap) { ret = wl1271_ap_hw_init(wl, wlvif); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 0623f5dc02ca..b52deac368f4 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2117,6 +2117,11 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, wl->vif = vif; list_add(&wlvif->list, &wl->wlvif_list); set_bit(WL1271_FLAG_IF_INITIALIZED, &wl->flags); + + if (wlvif->bss_type == BSS_TYPE_AP_BSS) + wl->ap_count++; + else + wl->sta_count++; out: mutex_unlock(&wl->mutex); @@ -2188,6 +2193,11 @@ deinit: wlvif->role_id = WL12XX_INVALID_ROLE_ID; wlvif->dev_role_id = WL12XX_INVALID_ROLE_ID; + if (wlvif->bss_type == BSS_TYPE_AP_BSS) + wl->ap_count--; + else + wl->sta_count--; + mutex_unlock(&wl->mutex); cancel_delayed_work_sync(&wlvif->pspoll_work); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 55561c597ad9..fd78f8c1ebcc 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -395,6 +395,8 @@ struct wl1271 { unsigned long roc_map[BITS_TO_LONGS(WL12XX_MAX_ROLES)]; struct list_head wlvif_list; + u8 sta_count; + u8 ap_count; struct wl1271_acx_mem_map *target_mem_map; -- cgit v1.2.3 From 4b730b6a814fe52425d90ff3db3d8deefb22fb24 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:12:57 +0200 Subject: wl12xx: make event handling support multirole Some events don't indicate the role they are intended for. In these cases, iterate through all the relevant vifs, and pass the event to each one of them. This is only a workaround. future fw releases should indicate the relevant role_id for such events. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/event.c | 121 +++++++++++++++++++++++------------ drivers/net/wireless/wl12xx/wl12xx.h | 10 +++ 2 files changed, 91 insertions(+), 40 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index 486c8ee0101a..dbc40bb49bcd 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -162,10 +162,10 @@ static int wl1271_event_ps_report(struct wl1271 *wl, } static void wl1271_event_rssi_trigger(struct wl1271 *wl, - struct ieee80211_vif *vif, + struct wl12xx_vif *wlvif, struct event_mailbox *mbox) { - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); enum nl80211_cqm_rssi_threshold_event event; s8 metric = mbox->rssi_snr_trigger_metric[0]; @@ -183,11 +183,13 @@ static void wl1271_event_rssi_trigger(struct wl1271 *wl, static void wl1271_stop_ba_event(struct wl1271 *wl, struct wl12xx_vif *wlvif) { + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); + if (wlvif->bss_type != BSS_TYPE_AP_BSS) { if (!wlvif->sta.ba_rx_bitmap) return; - ieee80211_stop_rx_ba_session(wl->vif, wlvif->sta.ba_rx_bitmap, - wl->vif->bss_conf.bssid); + ieee80211_stop_rx_ba_session(vif, wlvif->sta.ba_rx_bitmap, + vif->bss_conf.bssid); } else { u8 hlid; struct wl1271_link *lnk; @@ -197,7 +199,7 @@ static void wl1271_stop_ba_event(struct wl1271 *wl, struct wl12xx_vif *wlvif) if (!lnk->ba_bitmap) continue; - ieee80211_stop_rx_ba_session(wl->vif, + ieee80211_stop_rx_ba_session(vif, lnk->ba_bitmap, lnk->addr); } @@ -207,12 +209,21 @@ static void wl1271_stop_ba_event(struct wl1271 *wl, struct wl12xx_vif *wlvif) static void wl12xx_event_soft_gemini_sense(struct wl1271 *wl, u8 enable) { + struct ieee80211_vif *vif; + struct wl12xx_vif *wlvif; + if (enable) { /* disable dynamic PS when requested by the firmware */ - ieee80211_disable_dyn_ps(wl->vif); + wl12xx_for_each_wlvif_sta(wl, wlvif) { + vif = wl12xx_wlvif_to_vif(wlvif); + ieee80211_disable_dyn_ps(vif); + } set_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags); } else { - ieee80211_enable_dyn_ps(wl->vif); + wl12xx_for_each_wlvif_sta(wl, wlvif) { + vif = wl12xx_wlvif_to_vif(wlvif); + ieee80211_enable_dyn_ps(vif); + } clear_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags); wl1271_recalc_rx_streaming(wl); } @@ -228,12 +239,11 @@ static void wl1271_event_mbox_dump(struct event_mailbox *mbox) static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) { - struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + struct ieee80211_vif *vif; + struct wl12xx_vif *wlvif; int ret; u32 vector; bool beacon_loss = false; - bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); bool disconnect_sta = false; unsigned long sta_bitmap = 0; @@ -266,8 +276,7 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) } } - if (vector & SOFT_GEMINI_SENSE_EVENT_ID && - wlvif->bss_type == BSS_TYPE_STA_BSS) + if (vector & SOFT_GEMINI_SENSE_EVENT_ID) wl12xx_event_soft_gemini_sense(wl, mbox->soft_gemini_sense_info); @@ -280,40 +289,54 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) * BSS_LOSE_EVENT, beacon loss has to be reported to the stack. * */ - if ((vector & BSS_LOSE_EVENT_ID) && !is_ap) { + if (vector & BSS_LOSE_EVENT_ID) { + /* TODO: check for multi-role */ wl1271_info("Beacon loss detected."); /* indicate to the stack, that beacons have been lost */ beacon_loss = true; } - if ((vector & PS_REPORT_EVENT_ID) && !is_ap) { + if (vector & PS_REPORT_EVENT_ID) { wl1271_debug(DEBUG_EVENT, "PS_REPORT_EVENT"); - ret = wl1271_event_ps_report(wl, wlvif, mbox, &beacon_loss); - if (ret < 0) - return ret; + wl12xx_for_each_wlvif_sta(wl, wlvif) { + ret = wl1271_event_ps_report(wl, wlvif, + mbox, &beacon_loss); + if (ret < 0) + return ret; + } } - if ((vector & PSPOLL_DELIVERY_FAILURE_EVENT_ID) && !is_ap) - wl1271_event_pspoll_delivery_fail(wl, wlvif); + if (vector & PSPOLL_DELIVERY_FAILURE_EVENT_ID) + wl12xx_for_each_wlvif_sta(wl, wlvif) { + wl1271_event_pspoll_delivery_fail(wl, wlvif); + } if (vector & RSSI_SNR_TRIGGER_0_EVENT_ID) { + /* TODO: check actual multi-role support */ wl1271_debug(DEBUG_EVENT, "RSSI_SNR_TRIGGER_0_EVENT"); - if (wl->vif) - wl1271_event_rssi_trigger(wl, vif, mbox); + wl12xx_for_each_wlvif_sta(wl, wlvif) { + wl1271_event_rssi_trigger(wl, wlvif, mbox); + } } - if ((vector & BA_SESSION_RX_CONSTRAINT_EVENT_ID)) { + if (vector & BA_SESSION_RX_CONSTRAINT_EVENT_ID) { + u8 role_id = mbox->role_id; wl1271_debug(DEBUG_EVENT, "BA_SESSION_RX_CONSTRAINT_EVENT_ID. " - "ba_allowed = 0x%x", mbox->rx_ba_allowed); + "ba_allowed = 0x%x, role_id=%d", + mbox->rx_ba_allowed, role_id); - wlvif->ba_allowed = !!mbox->rx_ba_allowed; + wl12xx_for_each_wlvif(wl, wlvif) { + if (role_id != 0xff && role_id != wlvif->role_id) + continue; - if (wl->vif && !wlvif->ba_allowed) - wl1271_stop_ba_event(wl, wlvif); + wlvif->ba_allowed = !!mbox->rx_ba_allowed; + if (!wlvif->ba_allowed) + wl1271_stop_ba_event(wl, wlvif); + } } - if ((vector & CHANNEL_SWITCH_COMPLETE_EVENT_ID) && !is_ap) { + if (vector & CHANNEL_SWITCH_COMPLETE_EVENT_ID) { wl1271_debug(DEBUG_EVENT, "CHANNEL_SWITCH_COMPLETE_EVENT_ID. " "status = 0x%x", mbox->channel_switch_status); @@ -322,48 +345,63 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) * 1) channel switch complete with status=0 * 2) channel switch failed status=1 */ - if (test_and_clear_bit(WL1271_FLAG_CS_PROGRESS, &wl->flags) && - (wl->vif)) - ieee80211_chswitch_done(wl->vif, - mbox->channel_switch_status ? false : true); + if (test_and_clear_bit(WL1271_FLAG_CS_PROGRESS, &wl->flags)) { + /* TODO: configure only the relevant vif */ + wl12xx_for_each_wlvif_sta(wl, wlvif) { + struct ieee80211_vif *vif = + wl12xx_wlvif_to_vif(wlvif); + bool success = mbox->channel_switch_status ? + false : true; + + ieee80211_chswitch_done(vif, success); + } + } } if ((vector & DUMMY_PACKET_EVENT_ID)) { wl1271_debug(DEBUG_EVENT, "DUMMY_PACKET_ID_EVENT_ID"); - if (wl->vif) - wl1271_tx_dummy_packet(wl); + wl1271_tx_dummy_packet(wl); } /* * "TX retries exceeded" has a different meaning according to mode. * In AP mode the offending station is disconnected. */ - if ((vector & MAX_TX_RETRY_EVENT_ID) && is_ap) { + if (vector & MAX_TX_RETRY_EVENT_ID) { wl1271_debug(DEBUG_EVENT, "MAX_TX_RETRY_EVENT_ID"); sta_bitmap |= le16_to_cpu(mbox->sta_tx_retry_exceeded); disconnect_sta = true; } - if ((vector & INACTIVE_STA_EVENT_ID) && is_ap) { + if (vector & INACTIVE_STA_EVENT_ID) { wl1271_debug(DEBUG_EVENT, "INACTIVE_STA_EVENT_ID"); sta_bitmap |= le16_to_cpu(mbox->sta_aging_status); disconnect_sta = true; } - if (is_ap && disconnect_sta) { + if (disconnect_sta) { u32 num_packets = wl->conf.tx.max_tx_retries; struct ieee80211_sta *sta; const u8 *addr; int h; for_each_set_bit(h, &sta_bitmap, WL12XX_MAX_LINKS) { - if (!test_bit(h, wlvif->ap.sta_hlid_map)) + bool found = false; + /* find the ap vif connected to this sta */ + wl12xx_for_each_wlvif_ap(wl, wlvif) { + if (!test_bit(h, wlvif->ap.sta_hlid_map)) + continue; + found = true; + break; + } + if (!found) continue; + vif = wl12xx_wlvif_to_vif(wlvif); addr = wl->links[h].addr; rcu_read_lock(); - sta = ieee80211_find_sta(wl->vif, addr); + sta = ieee80211_find_sta(vif, addr); if (sta) { wl1271_debug(DEBUG_EVENT, "remove sta %d", h); ieee80211_report_low_ack(sta, num_packets); @@ -372,8 +410,11 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) } } - if (wl->vif && beacon_loss) - ieee80211_connection_loss(wl->vif); + if (beacon_loss) + wl12xx_for_each_wlvif_sta(wl, wlvif) { + vif = wl12xx_wlvif_to_vif(wlvif); + ieee80211_connection_loss(vif); + } return 0; } diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index fd78f8c1ebcc..de9a2b639403 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -661,6 +661,16 @@ struct ieee80211_vif *wl12xx_wlvif_to_vif(struct wl12xx_vif *wlvif) #define wl12xx_for_each_wlvif(wl, wlvif) \ list_for_each_entry(wlvif, &wl->wlvif_list, list) +#define wl12xx_for_each_wlvif_bss_type(wl, wlvif, _bss_type) \ + wl12xx_for_each_wlvif(wl, wlvif) \ + if (wlvif->bss_type == _bss_type) + +#define wl12xx_for_each_wlvif_sta(wl, wlvif) \ + wl12xx_for_each_wlvif_bss_type(wl, wlvif, BSS_TYPE_STA_BSS) + +#define wl12xx_for_each_wlvif_ap(wl, wlvif) \ + wl12xx_for_each_wlvif_bss_type(wl, wlvif, BSS_TYPE_AP_BSS) + int wl1271_plt_start(struct wl1271 *wl); int wl1271_plt_stop(struct wl1271 *wl); int wl1271_recalc_rx_streaming(struct wl1271 *wl); -- cgit v1.2.3 From 48e93e402ad19f570bae323b07911bdf6562af8e Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:12:58 +0200 Subject: wl12xx: move tx_security_seq into wlvif The last security seq num has to be saved across reconfigs. Add a new "persistent" struct into wlvif, which won't get deleted on wl12xx_init_vif_data() Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/debugfs.c | 1 - drivers/net/wireless/wl12xx/main.c | 32 +++++++++++++++++--------------- drivers/net/wireless/wl12xx/tx.c | 12 +++++++++--- drivers/net/wireless/wl12xx/wl12xx.h | 30 +++++++++++++++++++----------- 4 files changed, 45 insertions(+), 30 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index bbc8004edf40..669b081848e8 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -346,7 +346,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, DRIVER_STATE_PRINT_INT(tx_results_count); DRIVER_STATE_PRINT_LHEX(flags); DRIVER_STATE_PRINT_INT(tx_blocks_freed); - DRIVER_STATE_PRINT_INT(tx_security_last_seq_lsb); DRIVER_STATE_PRINT_INT(rx_counter); DRIVER_STATE_PRINT_INT(state); DRIVER_STATE_PRINT_INT(channel); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index b52deac368f4..8d87df53bbec 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1206,6 +1206,7 @@ static void wl1271_recovery_work(struct work_struct *work) { struct wl1271 *wl = container_of(work, struct wl1271, recovery_work); + struct wl12xx_vif *wlvif; mutex_lock(&wl->mutex); @@ -1227,9 +1228,12 @@ static void wl1271_recovery_work(struct work_struct *work) * in the firmware during recovery. This doens't hurt if the network is * not encrypted. */ - if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags) || - test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) - wl->tx_security_seq += WL1271_TX_SQN_POST_RECOVERY_PADDING; + wl12xx_for_each_wlvif(wl, wlvif) { + if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags) || + test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) + wlvif->tx_security_seq += + WL1271_TX_SQN_POST_RECOVERY_PADDING; + } /* Prevent spurious TX during FW restart */ ieee80211_stop_queues(wl->hw); @@ -1910,8 +1914,8 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) { struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); - /* make sure wlvif is zeroed */ - memset(wlvif, 0, sizeof(*wlvif)); + /* clear everything but the persistent data */ + memset(wlvif, 0, offsetof(struct wl12xx_vif, persistent)); switch (ieee80211_vif_type_p2p(vif)) { case NL80211_IFTYPE_P2P_CLIENT: @@ -2297,8 +2301,8 @@ static int wl1271_unjoin(struct wl1271 *wl, struct wl12xx_vif *wlvif) goto out; /* reset TX security counters on a clean disconnect */ - wl->tx_security_last_seq_lsb = 0; - wl->tx_security_seq = 0; + wlvif->tx_security_last_seq_lsb = 0; + wlvif->tx_security_seq = 0; out: return ret; @@ -2870,20 +2874,20 @@ static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, key_type = KEY_TKIP; key_conf->hw_key_idx = key_conf->keyidx; - tx_seq_32 = WL1271_TX_SECURITY_HI32(wl->tx_security_seq); - tx_seq_16 = WL1271_TX_SECURITY_LO16(wl->tx_security_seq); + tx_seq_32 = WL1271_TX_SECURITY_HI32(wlvif->tx_security_seq); + tx_seq_16 = WL1271_TX_SECURITY_LO16(wlvif->tx_security_seq); break; case WLAN_CIPHER_SUITE_CCMP: key_type = KEY_AES; key_conf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; - tx_seq_32 = WL1271_TX_SECURITY_HI32(wl->tx_security_seq); - tx_seq_16 = WL1271_TX_SECURITY_LO16(wl->tx_security_seq); + tx_seq_32 = WL1271_TX_SECURITY_HI32(wlvif->tx_security_seq); + tx_seq_16 = WL1271_TX_SECURITY_LO16(wlvif->tx_security_seq); break; case WL1271_CIPHER_SUITE_GEM: key_type = KEY_GEM; - tx_seq_32 = WL1271_TX_SECURITY_HI32(wl->tx_security_seq); - tx_seq_16 = WL1271_TX_SECURITY_LO16(wl->tx_security_seq); + tx_seq_32 = WL1271_TX_SECURITY_HI32(wlvif->tx_security_seq); + tx_seq_16 = WL1271_TX_SECURITY_LO16(wlvif->tx_security_seq); break; default: wl1271_error("Unknown key algo 0x%x", key_conf->cipher); @@ -4923,8 +4927,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->quirks = 0; wl->platform_quirks = 0; wl->sched_scanning = false; - wl->tx_security_seq = 0; - wl->tx_security_last_seq_lsb = 0; wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; wl->system_hlid = WL12XX_SYSTEM_HLID; wl->active_sta_count = 0; diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index c7be15186c4a..8c35d37ba600 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -755,6 +755,8 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl, struct wl1271_tx_hw_res_descr *result) { struct ieee80211_tx_info *info; + struct ieee80211_vif *vif; + struct wl12xx_vif *wlvif; struct sk_buff *skb; int id = result->id; int rate = -1; @@ -774,6 +776,10 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl, return; } + /* info->control is valid as long as we don't update info->status */ + vif = info->control.vif; + wlvif = wl12xx_vif_to_data(vif); + /* update the TX status info */ if (result->status == TX_SUCCESS) { if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) @@ -801,14 +807,14 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl, info->control.hw_key->cipher == WLAN_CIPHER_SUITE_CCMP || info->control.hw_key->cipher == WL1271_CIPHER_SUITE_GEM)) { u8 fw_lsb = result->tx_security_sequence_number_lsb; - u8 cur_lsb = wl->tx_security_last_seq_lsb; + u8 cur_lsb = wlvif->tx_security_last_seq_lsb; /* * update security sequence number, taking care of potential * wrap-around */ - wl->tx_security_seq += (fw_lsb - cur_lsb + 256) % 256; - wl->tx_security_last_seq_lsb = fw_lsb; + wlvif->tx_security_seq += (fw_lsb - cur_lsb) & 0xff; + wlvif->tx_security_last_seq_lsb = fw_lsb; } /* remove private header from packet */ diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index de9a2b639403..d58488598d11 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -437,17 +437,6 @@ struct wl1271 { struct sk_buff *tx_frames[ACX_TX_DESCRIPTORS]; int tx_frames_cnt; - /* - * Security sequence number - * bits 0-15: lower 16 bits part of sequence number - * bits 16-47: higher 32 bits part of sequence number - * bits 48-63: not in use - */ - u64 tx_security_seq; - - /* 8 bits of the last sequence number in use */ - u8 tx_security_last_seq_lsb; - /* FW Rx counter */ u32 rx_counter; @@ -645,6 +634,25 @@ struct wl12xx_vif { /* RX BA constraint value */ bool ba_support; bool ba_allowed; + + /* + * This struct must be last! + * data that has to be saved acrossed reconfigs (e.g. recovery) + * should be declared in this struct. + */ + struct { + u8 persistent[0]; + /* + * Security sequence number + * bits 0-15: lower 16 bits part of sequence number + * bits 16-47: higher 32 bits part of sequence number + * bits 48-63: not in use + */ + u64 tx_security_seq; + + /* 8 bits of the last sequence number in use */ + u8 tx_security_last_seq_lsb; + }; }; static inline struct wl12xx_vif *wl12xx_vif_to_data(struct ieee80211_vif *vif) -- cgit v1.2.3 From 9eb599e9c62dcfd4efece1936c385381b366b684 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:12:59 +0200 Subject: wl12xx: rearm rx streaming per vif Currently, the rx streaming doesn't support multi-vif (the actual wlvif is taken from wl->vif, and the management is global). Make the rx streaming timers/works per-vif, and pass the the actual vif as param. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/acx.c | 5 ++- drivers/net/wireless/wl12xx/acx.h | 3 +- drivers/net/wireless/wl12xx/debugfs.c | 10 ++++-- drivers/net/wireless/wl12xx/event.c | 4 +-- drivers/net/wireless/wl12xx/main.c | 53 ++++++++++++++------------- drivers/net/wireless/wl12xx/rx.c | 35 +++++++----------- drivers/net/wireless/wl12xx/tx.c | 67 ++++++++++++++++++++++++----------- drivers/net/wireless/wl12xx/tx.h | 1 + drivers/net/wireless/wl12xx/wl12xx.h | 12 +++---- 9 files changed, 109 insertions(+), 81 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/acx.c b/drivers/net/wireless/wl12xx/acx.c index 5b70cc19e1d4..21e74ca4ddb2 100644 --- a/drivers/net/wireless/wl12xx/acx.c +++ b/drivers/net/wireless/wl12xx/acx.c @@ -1510,10 +1510,9 @@ out: return ret; } -int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, bool enable) +int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable) { - struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct wl1271_acx_ps_rx_streaming *rx_streaming; u32 conf_queues, enable_queues; int i, ret = 0; diff --git a/drivers/net/wireless/wl12xx/acx.h b/drivers/net/wireless/wl12xx/acx.h index 7fccfcc55ca0..c06119b053e3 100644 --- a/drivers/net/wireless/wl12xx/acx.h +++ b/drivers/net/wireless/wl12xx/acx.h @@ -1310,7 +1310,8 @@ int wl12xx_acx_set_ba_initiator_policy(struct wl1271 *wl, int wl12xx_acx_set_ba_receiver_session(struct wl1271 *wl, u8 tid_index, u16 ssn, bool enable, u8 peer_hlid); int wl1271_acx_tsf_info(struct wl1271 *wl, u64 *mactime); -int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, bool enable); +int wl1271_acx_ps_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable); int wl1271_acx_ap_max_tx_retry(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_acx_config_ps(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl1271_acx_set_inconnection_sta(struct wl1271 *wl, u8 *addr); diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 669b081848e8..4abff8274ac3 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -505,6 +505,7 @@ static ssize_t rx_streaming_interval_write(struct file *file, size_t count, loff_t *ppos) { struct wl1271 *wl = file->private_data; + struct wl12xx_vif *wlvif; unsigned long value; int ret; @@ -528,7 +529,9 @@ static ssize_t rx_streaming_interval_write(struct file *file, if (ret < 0) goto out; - wl1271_recalc_rx_streaming(wl); + wl12xx_for_each_wlvif_sta(wl, wlvif) { + wl1271_recalc_rx_streaming(wl, wlvif); + } wl1271_ps_elp_sleep(wl); out: @@ -557,6 +560,7 @@ static ssize_t rx_streaming_always_write(struct file *file, size_t count, loff_t *ppos) { struct wl1271 *wl = file->private_data; + struct wl12xx_vif *wlvif; unsigned long value; int ret; @@ -580,7 +584,9 @@ static ssize_t rx_streaming_always_write(struct file *file, if (ret < 0) goto out; - wl1271_recalc_rx_streaming(wl); + wl12xx_for_each_wlvif_sta(wl, wlvif) { + wl1271_recalc_rx_streaming(wl, wlvif); + } wl1271_ps_elp_sleep(wl); out: diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index dbc40bb49bcd..be9e1121c8f8 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -220,12 +220,12 @@ static void wl12xx_event_soft_gemini_sense(struct wl1271 *wl, } set_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags); } else { + clear_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags); wl12xx_for_each_wlvif_sta(wl, wlvif) { vif = wl12xx_wlvif_to_vif(wlvif); ieee80211_enable_dyn_ps(vif); + wl1271_recalc_rx_streaming(wl, wlvif); } - clear_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags); - wl1271_recalc_rx_streaming(wl); } } diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 8d87df53bbec..5ce01f1379a4 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -502,12 +502,13 @@ static int wl1271_reg_notify(struct wiphy *wiphy, return 0; } -static int wl1271_set_rx_streaming(struct wl1271 *wl, bool enable) +static int wl1271_set_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif, + bool enable) { int ret = 0; /* we should hold wl->mutex */ - ret = wl1271_acx_ps_rx_streaming(wl, enable); + ret = wl1271_acx_ps_rx_streaming(wl, wlvif, enable); if (ret < 0) goto out; @@ -523,7 +524,7 @@ out: * this function is being called when the rx_streaming interval * has beed changed or rx_streaming should be disabled */ -int wl1271_recalc_rx_streaming(struct wl1271 *wl) +int wl1271_recalc_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int ret = 0; int period = wl->conf.rx_streaming.interval; @@ -537,11 +538,11 @@ int wl1271_recalc_rx_streaming(struct wl1271 *wl) test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags) && (wl->conf.rx_streaming.always || test_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags))) - ret = wl1271_set_rx_streaming(wl, true); + ret = wl1271_set_rx_streaming(wl, wlvif, true); else { - ret = wl1271_set_rx_streaming(wl, false); + ret = wl1271_set_rx_streaming(wl, wlvif, false); /* don't cancel_work_sync since we might deadlock */ - del_timer_sync(&wl->rx_streaming_timer); + del_timer_sync(&wlvif->rx_streaming_timer); } out: return ret; @@ -550,8 +551,9 @@ out: static void wl1271_rx_streaming_enable_work(struct work_struct *work) { int ret; - struct wl1271 *wl = - container_of(work, struct wl1271, rx_streaming_enable_work); + struct wl12xx_vif *wlvif = container_of(work, struct wl12xx_vif, + rx_streaming_enable_work); + struct wl1271 *wl = wlvif->wl; mutex_lock(&wl->mutex); @@ -568,12 +570,12 @@ static void wl1271_rx_streaming_enable_work(struct work_struct *work) if (ret < 0) goto out; - ret = wl1271_set_rx_streaming(wl, true); + ret = wl1271_set_rx_streaming(wl, wlvif, true); if (ret < 0) goto out_sleep; /* stop it after some time of inactivity */ - mod_timer(&wl->rx_streaming_timer, + mod_timer(&wlvif->rx_streaming_timer, jiffies + msecs_to_jiffies(wl->conf.rx_streaming.duration)); out_sleep: @@ -585,8 +587,9 @@ out: static void wl1271_rx_streaming_disable_work(struct work_struct *work) { int ret; - struct wl1271 *wl = - container_of(work, struct wl1271, rx_streaming_disable_work); + struct wl12xx_vif *wlvif = container_of(work, struct wl12xx_vif, + rx_streaming_disable_work); + struct wl1271 *wl = wlvif->wl; mutex_lock(&wl->mutex); @@ -597,7 +600,7 @@ static void wl1271_rx_streaming_disable_work(struct work_struct *work) if (ret < 0) goto out; - ret = wl1271_set_rx_streaming(wl, false); + ret = wl1271_set_rx_streaming(wl, wlvif, false); if (ret) goto out_sleep; @@ -609,8 +612,9 @@ out: static void wl1271_rx_streaming_timer(unsigned long data) { - struct wl1271 *wl = (struct wl1271 *)data; - ieee80211_queue_work(wl->hw, &wl->rx_streaming_disable_work); + struct wl12xx_vif *wlvif = (struct wl12xx_vif *)data; + struct wl1271 *wl = wlvif->wl; + ieee80211_queue_work(wl->hw, &wlvif->rx_streaming_disable_work); } static void wl1271_conf_init(struct wl1271 *wl) @@ -1827,9 +1831,6 @@ static void wl1271_op_stop(struct ieee80211_hw *hw) cancel_delayed_work_sync(&wl->scan_complete_work); cancel_work_sync(&wl->netstack_work); cancel_work_sync(&wl->tx_work); - del_timer_sync(&wl->rx_streaming_timer); - cancel_work_sync(&wl->rx_streaming_enable_work); - cancel_work_sync(&wl->rx_streaming_disable_work); cancel_delayed_work_sync(&wl->elp_work); /* let's notify MAC80211 about the remaining pending TX frames */ @@ -1960,9 +1961,16 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; wlvif->beacon_int = WL1271_DEFAULT_BEACON_INT; + INIT_WORK(&wlvif->rx_streaming_enable_work, + wl1271_rx_streaming_enable_work); + INIT_WORK(&wlvif->rx_streaming_disable_work, + wl1271_rx_streaming_disable_work); INIT_DELAYED_WORK(&wlvif->pspoll_work, wl1271_pspoll_work); INIT_LIST_HEAD(&wlvif->list); + setup_timer(&wlvif->rx_streaming_timer, wl1271_rx_streaming_timer, + (unsigned long) wlvif); + return 0; } @@ -2203,6 +2211,9 @@ deinit: wl->sta_count--; mutex_unlock(&wl->mutex); + del_timer_sync(&wlvif->rx_streaming_timer); + cancel_work_sync(&wlvif->rx_streaming_enable_work); + cancel_work_sync(&wlvif->rx_streaming_disable_work); cancel_delayed_work_sync(&wlvif->pspoll_work); mutex_lock(&wl->mutex); @@ -4903,10 +4914,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) INIT_WORK(&wl->tx_work, wl1271_tx_work); INIT_WORK(&wl->recovery_work, wl1271_recovery_work); INIT_DELAYED_WORK(&wl->scan_complete_work, wl1271_scan_complete_work); - INIT_WORK(&wl->rx_streaming_enable_work, - wl1271_rx_streaming_enable_work); - INIT_WORK(&wl->rx_streaming_disable_work, - wl1271_rx_streaming_disable_work); wl->freezable_wq = create_freezable_workqueue("wl12xx_wq"); if (!wl->freezable_wq) { @@ -4930,8 +4937,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void) wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; wl->system_hlid = WL12XX_SYSTEM_HLID; wl->active_sta_count = 0; - setup_timer(&wl->rx_streaming_timer, wl1271_rx_streaming_timer, - (unsigned long) wl); wl->fwlog_size = 0; init_waitqueue_head(&wl->fwlog_waitq); diff --git a/drivers/net/wireless/wl12xx/rx.c b/drivers/net/wireless/wl12xx/rx.c index 9cfa0b25a6f8..dd2f8b714a7f 100644 --- a/drivers/net/wireless/wl12xx/rx.c +++ b/drivers/net/wireless/wl12xx/rx.c @@ -28,6 +28,7 @@ #include "acx.h" #include "reg.h" #include "rx.h" +#include "tx.h" #include "io.h" static u8 wl12xx_rx_get_mem_block(struct wl12xx_fw_status *status, @@ -96,7 +97,7 @@ static void wl1271_rx_status(struct wl1271 *wl, } static int wl1271_rx_handle_data(struct wl1271 *wl, u8 *data, u32 length, - bool unaligned) + bool unaligned, u8 *hlid) { struct wl1271_rx_descriptor *desc; struct sk_buff *skb; @@ -159,6 +160,7 @@ static int wl1271_rx_handle_data(struct wl1271 *wl, u8 *data, u32 length, * payload aligned to 4 bytes. */ memcpy(buf, data + sizeof(*desc), length - sizeof(*desc)); + *hlid = desc->hlid; hdr = (struct ieee80211_hdr *)skb->data; if (ieee80211_is_beacon(hdr->frame_control)) @@ -169,10 +171,10 @@ static int wl1271_rx_handle_data(struct wl1271 *wl, u8 *data, u32 length, wl1271_rx_status(wl, desc, IEEE80211_SKB_RXCB(skb), beacon); seq_num = (le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_SEQ) >> 4; - wl1271_debug(DEBUG_RX, "rx skb 0x%p: %d B %s seq %d", skb, + wl1271_debug(DEBUG_RX, "rx skb 0x%p: %d B %s seq %d hlid %d", skb, skb->len - desc->pad_len, beacon ? "beacon" : "", - seq_num); + seq_num, *hlid); skb_trim(skb, skb->len - desc->pad_len); @@ -185,8 +187,7 @@ static int wl1271_rx_handle_data(struct wl1271 *wl, u8 *data, u32 length, void wl12xx_rx(struct wl1271 *wl, struct wl12xx_fw_status *status) { struct wl1271_acx_mem_map *wl_mem_map = wl->target_mem_map; - struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + unsigned long active_hlids[BITS_TO_LONGS(WL12XX_MAX_LINKS)] = {0}; u32 buf_size; u32 fw_rx_counter = status->fw_rx_counter & NUM_RX_PKT_DESC_MOD_MASK; u32 drv_rx_counter = wl->rx_counter & NUM_RX_PKT_DESC_MOD_MASK; @@ -194,8 +195,7 @@ void wl12xx_rx(struct wl1271 *wl, struct wl12xx_fw_status *status) u32 mem_block; u32 pkt_length; u32 pkt_offset; - bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); - bool had_data = false; + u8 hlid; bool unaligned = false; while (drv_rx_counter != fw_rx_counter) { @@ -255,8 +255,11 @@ void wl12xx_rx(struct wl1271 *wl, struct wl12xx_fw_status *status) */ if (wl1271_rx_handle_data(wl, wl->aggr_buf + pkt_offset, - pkt_length, unaligned) == 1) - had_data = true; + pkt_length, unaligned, + &hlid) == 1) { + WARN_ON(hlid >= WL12XX_MAX_LINKS); + __set_bit(hlid, active_hlids); + } wl->rx_counter++; drv_rx_counter++; @@ -272,17 +275,5 @@ void wl12xx_rx(struct wl1271 *wl, struct wl12xx_fw_status *status) if (wl->quirks & WL12XX_QUIRK_END_OF_TRANSACTION) wl1271_write32(wl, RX_DRIVER_COUNTER_ADDRESS, wl->rx_counter); - if (!is_ap && wl->conf.rx_streaming.interval && had_data && - (wl->conf.rx_streaming.always || - test_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags))) { - u32 timeout = wl->conf.rx_streaming.duration; - - /* restart rx streaming */ - if (!test_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags)) - ieee80211_queue_work(wl->hw, - &wl->rx_streaming_enable_work); - - mod_timer(&wl->rx_streaming_timer, - jiffies + msecs_to_jiffies(timeout)); - } + wl12xx_rearm_rx_streaming(wl, active_hlids); } diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 8c35d37ba600..a06aa4e8df7b 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -643,21 +643,58 @@ static bool wl1271_tx_is_data_present(struct sk_buff *skb) return ieee80211_is_data_present(hdr->frame_control); } +void wl12xx_rearm_rx_streaming(struct wl1271 *wl, unsigned long *active_hlids) +{ + struct wl12xx_vif *wlvif; + u32 timeout; + u8 hlid; + + if (!wl->conf.rx_streaming.interval) + return; + + if (!wl->conf.rx_streaming.always && + !test_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags)) + return; + + timeout = wl->conf.rx_streaming.duration; + wl12xx_for_each_wlvif_sta(wl, wlvif) { + bool found = false; + for_each_set_bit(hlid, active_hlids, WL12XX_MAX_LINKS) { + if (test_bit(hlid, wlvif->links_map)) { + found = true; + break; + } + } + + if (!found) + continue; + + /* enable rx streaming */ + if (!test_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags)) + ieee80211_queue_work(wl->hw, + &wlvif->rx_streaming_enable_work); + + mod_timer(&wlvif->rx_streaming_timer, + jiffies + msecs_to_jiffies(timeout)); + } +} + void wl1271_tx_work_locked(struct wl1271 *wl) { struct wl12xx_vif *wlvif; struct sk_buff *skb; + struct wl1271_tx_hw_descr *desc; u32 buf_offset = 0; bool sent_packets = false; - bool had_data = false; - /* TODO: save bitmap of relevant stations */ - bool is_sta = false; + unsigned long active_hlids[BITS_TO_LONGS(WL12XX_MAX_LINKS)] = {0}; int ret; if (unlikely(wl->state == WL1271_STATE_OFF)) return; while ((skb = wl1271_skb_dequeue(wl))) { + bool has_data = false; + wlvif = NULL; if (!wl12xx_is_dummy_packet(wl, skb)) { struct ieee80211_tx_info *info; @@ -667,9 +704,7 @@ void wl1271_tx_work_locked(struct wl1271 *wl) vif = info->control.vif; wlvif = wl12xx_vif_to_data(vif); } - - if (wl1271_tx_is_data_present(skb)) - had_data = true; + has_data = wlvif && wl1271_tx_is_data_present(skb); ret = wl1271_prepare_tx_frame(wl, wlvif, skb, buf_offset); if (ret == -EAGAIN) { @@ -698,8 +733,10 @@ void wl1271_tx_work_locked(struct wl1271 *wl) } buf_offset += ret; wl->tx_packets_count++; - if (wlvif && wlvif->bss_type == BSS_TYPE_STA_BSS) - is_sta = true; + if (has_data) { + desc = (struct wl1271_tx_hw_descr *) skb->data; + __set_bit(desc->hlid, active_hlids); + } } out_ack: @@ -719,19 +756,7 @@ out_ack: wl1271_handle_tx_low_watermark(wl); } - if (is_sta && wl->conf.rx_streaming.interval && had_data && - (wl->conf.rx_streaming.always || - test_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags))) { - u32 timeout = wl->conf.rx_streaming.duration; - - /* enable rx streaming */ - if (!test_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags)) - ieee80211_queue_work(wl->hw, - &wl->rx_streaming_enable_work); - - mod_timer(&wl->rx_streaming_timer, - jiffies + msecs_to_jiffies(timeout)); - } + wl12xx_rearm_rx_streaming(wl, active_hlids); } void wl1271_tx_work(struct work_struct *work) diff --git a/drivers/net/wireless/wl12xx/tx.h b/drivers/net/wireless/wl12xx/tx.h index fe29ff524e9a..2dbb24e6d541 100644 --- a/drivers/net/wireless/wl12xx/tx.h +++ b/drivers/net/wireless/wl12xx/tx.h @@ -220,6 +220,7 @@ u8 wl12xx_tx_get_hlid(struct wl1271 *wl, struct wl12xx_vif *wlvif, void wl1271_tx_reset_link_queues(struct wl1271 *wl, u8 hlid); void wl1271_handle_tx_low_watermark(struct wl1271 *wl); bool wl12xx_is_dummy_packet(struct wl1271 *wl, struct sk_buff *skb); +void wl12xx_rearm_rx_streaming(struct wl1271 *wl, unsigned long *active_hlids); /* from main.c */ void wl1271_free_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 hlid); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index d58488598d11..52d1cd0ddb6f 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -480,11 +480,6 @@ struct wl1271 { /* The current band */ enum ieee80211_band band; - /* Rx Streaming */ - struct work_struct rx_streaming_enable_work; - struct work_struct rx_streaming_disable_work; - struct timer_list rx_streaming_timer; - struct completion *elp_compl; struct delayed_work elp_work; @@ -635,6 +630,11 @@ struct wl12xx_vif { bool ba_support; bool ba_allowed; + /* Rx Streaming */ + struct work_struct rx_streaming_enable_work; + struct work_struct rx_streaming_disable_work; + struct timer_list rx_streaming_timer; + /* * This struct must be last! * data that has to be saved acrossed reconfigs (e.g. recovery) @@ -681,7 +681,7 @@ struct ieee80211_vif *wl12xx_wlvif_to_vif(struct wl12xx_vif *wlvif) int wl1271_plt_start(struct wl1271 *wl); int wl1271_plt_stop(struct wl1271 *wl); -int wl1271_recalc_rx_streaming(struct wl1271 *wl); +int wl1271_recalc_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif); void wl12xx_queue_recovery_work(struct wl1271 *wl); size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen); -- cgit v1.2.3 From ba8447f64159927baf673d827e404605471d8f68 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:00 +0200 Subject: wl12xx: make WL1271_FLAG_STA_ASSOCIATED flag per-vif This flag should be set per-vif, rather than globally. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/event.c | 2 +- drivers/net/wireless/wl12xx/main.c | 52 +++++++++++++++++++----------------- drivers/net/wireless/wl12xx/scan.c | 4 +-- drivers/net/wireless/wl12xx/tx.c | 2 +- drivers/net/wireless/wl12xx/wl12xx.h | 6 ++++- 5 files changed, 36 insertions(+), 30 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index be9e1121c8f8..cfb2835c118c 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -52,7 +52,7 @@ void wl1271_pspoll_work(struct work_struct *work) if (!test_and_clear_bit(WL1271_FLAG_PSPOLL_FAILURE, &wl->flags)) goto out; - if (!test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) + if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) goto out; /* diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 5ce01f1379a4..d91e8bcccaaa 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -400,10 +400,9 @@ static struct platform_device wl1271_device = { static DEFINE_MUTEX(wl_list_mutex); static LIST_HEAD(wl_list); -static int wl1271_check_operstate(struct wl1271 *wl, unsigned char operstate) +static int wl1271_check_operstate(struct wl1271 *wl, struct wl12xx_vif *wlvif, + unsigned char operstate) { - struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret; if (operstate != IF_OPER_UP) @@ -430,6 +429,7 @@ static int wl1271_dev_notify(struct notifier_block *me, unsigned long what, struct ieee80211_hw *hw; struct wl1271 *wl; struct wl1271 *wl_temp; + struct wl12xx_vif *wlvif; int ret = 0; /* Check that this notification is for us. */ @@ -463,17 +463,18 @@ static int wl1271_dev_notify(struct notifier_block *me, unsigned long what, if (wl->state == WL1271_STATE_OFF) goto out; - if (!test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) - goto out; - - ret = wl1271_ps_elp_wakeup(wl); - if (ret < 0) - goto out; + wl12xx_for_each_wlvif_sta(wl, wlvif) { + if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) + continue; - wl1271_check_operstate(wl, dev->operstate); + ret = wl1271_ps_elp_wakeup(wl); + if (ret < 0) + goto out; - wl1271_ps_elp_sleep(wl); + wl1271_check_operstate(wl, wlvif, dev->operstate); + wl1271_ps_elp_sleep(wl); + } out: mutex_unlock(&wl->mutex); @@ -535,7 +536,7 @@ int wl1271_recalc_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif) /* reconfigure/disable according to new streaming_period */ if (period && - test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags) && + test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) && (wl->conf.rx_streaming.always || test_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags))) ret = wl1271_set_rx_streaming(wl, wlvif, true); @@ -558,7 +559,7 @@ static void wl1271_rx_streaming_enable_work(struct work_struct *work) mutex_lock(&wl->mutex); if (test_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags) || - !test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags) || + !test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) || (!wl->conf.rx_streaming.always && !test_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags))) goto out; @@ -1233,7 +1234,7 @@ static void wl1271_recovery_work(struct work_struct *work) * not encrypted. */ wl12xx_for_each_wlvif(wl, wlvif) { - if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags) || + if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) || test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) wlvif->tx_security_seq += WL1271_TX_SQN_POST_RECOVERY_PADDING; @@ -1609,7 +1610,7 @@ static int wl1271_configure_suspend_sta(struct wl1271 *wl, mutex_lock(&wl->mutex); - if (!test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) + if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) goto out_unlock; ret = wl1271_ps_elp_wakeup(wl); @@ -2253,11 +2254,11 @@ static int wl1271_join(struct wl1271 *wl, struct wl12xx_vif *wlvif, * Keep the below message for now, unless it starts bothering * users who really like to roam a lot :) */ - if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) + if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) wl1271_info("JOIN while associated."); if (set_assoc) - set_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags); + set_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags); if (is_ibss) ret = wl12xx_cmd_role_start_ibss(wl, wlvif); @@ -2266,7 +2267,7 @@ static int wl1271_join(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (ret < 0) goto out; - if (!test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) + if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) goto out; /* @@ -2449,7 +2450,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) * possible rate for the band as a fixed rate for * association frames and other control messages. */ - if (!test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) + if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) wl1271_set_band_rate(wl, wlvif); wlvif->basic_rate = @@ -2460,7 +2461,8 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) wl1271_warning("rate policy for channel " "failed %d", ret); - if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) { + if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, + &wlvif->flags)) { if (wl12xx_is_roc(wl)) { /* roaming */ ret = wl12xx_croc(wl, @@ -2518,7 +2520,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) * If we're not, we'll enter it when joining an SSID, * through the bss_info_changed() hook. */ - if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) { + if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) { wl1271_debug(DEBUG_PSM, "psm enabled"); ret = wl1271_ps_set_mode(wl, wlvif, STATION_POWER_SAVE_MODE, @@ -2981,7 +2983,7 @@ static int wl1271_op_hw_scan(struct ieee80211_hw *hw, /* cancel ROC before scanning */ if (wl12xx_is_roc(wl)) { - if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) { + if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) { /* don't allow scanning right now */ ret = -EBUSY; goto out_sleep; @@ -3619,8 +3621,8 @@ sta_not_found: } else { /* use defaults when not associated */ bool was_assoc = - !!test_and_clear_bit(WL1271_FLAG_STA_ASSOCIATED, - &wl->flags); + !!test_and_clear_bit(WLVIF_FLAG_STA_ASSOCIATED, + &wlvif->flags); bool was_ifup = !!test_and_clear_bit(WL1271_FLAG_STA_STATE_SENT, &wl->flags); @@ -3749,7 +3751,7 @@ sta_not_found: if (ret < 0) goto out; - wl1271_check_operstate(wl, + wl1271_check_operstate(wl, wlvif, ieee80211_get_operstate(vif)); } /* diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index e1a8ce092e39..687f59b871ef 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -64,7 +64,7 @@ void wl1271_scan_complete_work(struct work_struct *work) if (ret < 0) goto out; - if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) { + if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) { /* restore hardware connection monitoring template */ wl1271_cmd_build_ap_probe_req(wl, wlvif, wlvif->probereq); } @@ -72,7 +72,7 @@ void wl1271_scan_complete_work(struct work_struct *work) /* return to ROC if needed */ is_sta = (wlvif->bss_type == BSS_TYPE_STA_BSS); is_ibss = (wlvif->bss_type == BSS_TYPE_IBSS); - if (((is_sta && !test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) || + if (((is_sta && !test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) || (is_ibss && !test_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags))) && !test_bit(wlvif->dev_role_id, wl->roc_map)) { /* restore remain on channel */ diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index a06aa4e8df7b..bbb101b5de0c 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -192,7 +192,7 @@ u8 wl12xx_tx_get_hlid(struct wl1271 *wl, struct wl12xx_vif *wlvif, wl1271_tx_update_filters(wl, wlvif, skb); - if ((test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags) || + if ((test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) || test_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags)) && !ieee80211_is_auth(hdr->frame_control) && !ieee80211_is_assoc_req(hdr->frame_control)) diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 52d1cd0ddb6f..efb35a66fa5e 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -313,7 +313,6 @@ struct wl1271_ap_key { }; enum wl12xx_flags { - WL1271_FLAG_STA_ASSOCIATED, WL1271_FLAG_IBSS_JOINED, WL1271_FLAG_GPIO_POWER, WL1271_FLAG_TX_QUEUE_STOPPED, @@ -338,6 +337,10 @@ enum wl12xx_flags { WL1271_FLAG_CS_PROGRESS, }; +enum wl12xx_vif_flags { + WLVIF_FLAG_STA_ASSOCIATED, +}; + struct wl1271_link { /* AP-mode - TX queue per AC in link */ struct sk_buff_head tx_queue[NUM_TX_QUEUES]; @@ -553,6 +556,7 @@ struct wl1271_station { struct wl12xx_vif { struct wl1271 *wl; struct list_head list; + unsigned long flags; u8 bss_type; u8 p2p; /* we are using p2p role */ u8 role_id; -- cgit v1.2.3 From eee514e3d6cecc7abdf1b27734169004fefb0941 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:01 +0200 Subject: wl12xx: make WL1271_FLAG_IBSS_JOINED flag per-vif This flag should be set per-vif, rather than globally. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 6 +++--- drivers/net/wireless/wl12xx/scan.c | 2 +- drivers/net/wireless/wl12xx/tx.c | 2 +- drivers/net/wireless/wl12xx/wl12xx.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index d91e8bcccaaa..ac5be7323405 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -3494,11 +3494,11 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, if (changed & BSS_CHANGED_IBSS) { if (bss_conf->ibss_joined) { - set_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags); + set_bit(WLVIF_FLAG_IBSS_JOINED, &wlvif->flags); ibss_joined = true; } else { - if (test_and_clear_bit(WL1271_FLAG_IBSS_JOINED, - &wl->flags)) { + if (test_and_clear_bit(WLVIF_FLAG_IBSS_JOINED, + &wlvif->flags)) { wl1271_unjoin(wl, wlvif); wl12xx_cmd_role_start_dev(wl, wlvif); wl12xx_roc(wl, wlvif->dev_role_id); diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index 687f59b871ef..765f08ba29af 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -73,7 +73,7 @@ void wl1271_scan_complete_work(struct work_struct *work) is_sta = (wlvif->bss_type == BSS_TYPE_STA_BSS); is_ibss = (wlvif->bss_type == BSS_TYPE_IBSS); if (((is_sta && !test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) || - (is_ibss && !test_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags))) && + (is_ibss && !test_bit(WLVIF_FLAG_IBSS_JOINED, &wlvif->flags))) && !test_bit(wlvif->dev_role_id, wl->roc_map)) { /* restore remain on channel */ wl12xx_cmd_role_start_dev(wl, wlvif); diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index bbb101b5de0c..8965fd1384dd 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -193,7 +193,7 @@ u8 wl12xx_tx_get_hlid(struct wl1271 *wl, struct wl12xx_vif *wlvif, wl1271_tx_update_filters(wl, wlvif, skb); if ((test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) || - test_bit(WL1271_FLAG_IBSS_JOINED, &wl->flags)) && + test_bit(WLVIF_FLAG_IBSS_JOINED, &wlvif->flags)) && !ieee80211_is_auth(hdr->frame_control) && !ieee80211_is_assoc_req(hdr->frame_control)) return wlvif->sta.hlid; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index efb35a66fa5e..489c20555dff 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -313,7 +313,6 @@ struct wl1271_ap_key { }; enum wl12xx_flags { - WL1271_FLAG_IBSS_JOINED, WL1271_FLAG_GPIO_POWER, WL1271_FLAG_TX_QUEUE_STOPPED, WL1271_FLAG_TX_PENDING, @@ -339,6 +338,7 @@ enum wl12xx_flags { enum wl12xx_vif_flags { WLVIF_FLAG_STA_ASSOCIATED, + WLVIF_FLAG_IBSS_JOINED, }; struct wl1271_link { -- cgit v1.2.3 From 53d40d0b863e22b697f8d85e1f95cb6f9d2d95b1 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:02 +0200 Subject: wl12xx: make WL1271_FLAG_AP_STARTED flag per-vif This flag should be set per-vif, rather than globally. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 14 +++++++------- drivers/net/wireless/wl12xx/tx.c | 2 +- drivers/net/wireless/wl12xx/wl12xx.h | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index ac5be7323405..41cc5fe27d87 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1235,7 +1235,7 @@ static void wl1271_recovery_work(struct work_struct *work) */ wl12xx_for_each_wlvif(wl, wlvif) { if (test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) || - test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) + test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) wlvif->tx_security_seq += WL1271_TX_SQN_POST_RECOVERY_PADDING; } @@ -1662,7 +1662,7 @@ static int wl1271_configure_suspend_ap(struct wl1271 *wl, mutex_lock(&wl->mutex); - if (!test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) + if (!test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) goto out_unlock; ret = wl1271_ps_elp_wakeup(wl); @@ -2768,7 +2768,7 @@ static int wl1271_set_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, hlid = wlvif->ap.bcast_hlid; } - if (!test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) { + if (!test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) { /* * We do not support removing keys after AP shutdown. * Pretend we do to make mac80211 happy. @@ -3426,7 +3426,7 @@ static void wl1271_bss_info_changed_ap(struct wl1271 *wl, if ((changed & BSS_CHANGED_BEACON_ENABLED)) { if (bss_conf->enable_beacon) { - if (!test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) { + if (!test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) { ret = wl12xx_cmd_role_start_ap(wl, wlvif); if (ret < 0) goto out; @@ -3435,16 +3435,16 @@ static void wl1271_bss_info_changed_ap(struct wl1271 *wl, if (ret < 0) goto out; - set_bit(WL1271_FLAG_AP_STARTED, &wl->flags); + set_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags); wl1271_debug(DEBUG_AP, "started AP"); } } else { - if (test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) { + if (test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) { ret = wl12xx_cmd_role_stop_ap(wl, wlvif); if (ret < 0) goto out; - clear_bit(WL1271_FLAG_AP_STARTED, &wl->flags); + clear_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags); wl1271_debug(DEBUG_AP, "stopped AP"); } } diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 8965fd1384dd..a60d8feb69e4 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -168,7 +168,7 @@ u8 wl12xx_tx_get_hlid_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif, } else { struct ieee80211_hdr *hdr; - if (!test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) + if (!test_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags)) return wl->system_hlid; hdr = (struct ieee80211_hdr *)skb->data; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 489c20555dff..9b28e478930e 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -325,7 +325,6 @@ enum wl12xx_flags { WL1271_FLAG_PSPOLL_FAILURE, WL1271_FLAG_STA_STATE_SENT, WL1271_FLAG_FW_TX_BUSY, - WL1271_FLAG_AP_STARTED, WL1271_FLAG_IF_INITIALIZED, WL1271_FLAG_DUMMY_PACKET_PENDING, WL1271_FLAG_SUSPENDED, @@ -339,6 +338,7 @@ enum wl12xx_flags { enum wl12xx_vif_flags { WLVIF_FLAG_STA_ASSOCIATED, WLVIF_FLAG_IBSS_JOINED, + WLVIF_FLAG_AP_STARTED, }; struct wl1271_link { -- cgit v1.2.3 From c29bb001e448ef57e077db9f1c5ae864e3f8abab Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:03 +0200 Subject: wl12xx: make WL1271_FLAG_PSM flag per-vif move WL1271_FLAG_PSM and WL1271_FLAG_PSM_REQUESTED into per-vif flags. These flags should be set per-vif, rather than globally. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/event.c | 4 ++-- drivers/net/wireless/wl12xx/main.c | 18 +++++++++--------- drivers/net/wireless/wl12xx/ps.c | 25 +++++++++++++++++-------- drivers/net/wireless/wl12xx/wl12xx.h | 4 ++-- 4 files changed, 30 insertions(+), 21 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index cfb2835c118c..d8b183bba52b 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -84,7 +84,7 @@ static void wl1271_event_pspoll_delivery_fail(struct wl1271 *wl, "trying to work around it."); /* force active mode receive data from the AP */ - if (test_bit(WL1271_FLAG_PSM, &wl->flags)) { + if (test_bit(WLVIF_FLAG_PSM, &wlvif->flags)) { ret = wl1271_ps_set_mode(wl, wlvif, STATION_ACTIVE_MODE, wlvif->basic_rate, true); if (ret < 0) @@ -116,7 +116,7 @@ static int wl1271_event_ps_report(struct wl1271 *wl, case EVENT_ENTER_POWER_SAVE_FAIL: wl1271_debug(DEBUG_PSM, "PSM entry failed"); - if (!test_bit(WL1271_FLAG_PSM, &wl->flags)) { + if (!test_bit(WLVIF_FLAG_PSM, &wlvif->flags)) { /* remain in active mode */ wlvif->psm_entry_retry = 0; break; diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 41cc5fe27d87..2fe0ee144a9d 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1618,7 +1618,7 @@ static int wl1271_configure_suspend_sta(struct wl1271 *wl, goto out_unlock; /* enter psm if needed*/ - if (!test_bit(WL1271_FLAG_PSM, &wl->flags)) { + if (!test_bit(WLVIF_FLAG_PSM, &wlvif->flags)) { DECLARE_COMPLETION_ONSTACK(compl); wlvif->ps_compl = &compl; @@ -1705,7 +1705,7 @@ static void wl1271_configure_resume(struct wl1271 *wl, if (is_sta) { /* exit psm if it wasn't configured */ - if (!test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags)) + if (!test_bit(WLVIF_FLAG_PSM_REQUESTED, &wlvif->flags)) wl1271_ps_set_mode(wl, wlvif, STATION_ACTIVE_MODE, wlvif->basic_rate, true); } else if (is_ap) { @@ -2512,8 +2512,8 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) clear_bit(WL1271_FLAG_PSPOLL_FAILURE, &wl->flags); if (conf->flags & IEEE80211_CONF_PS && - !test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags)) { - set_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags); + !test_bit(WLVIF_FLAG_PSM_REQUESTED, &wlvif->flags)) { + set_bit(WLVIF_FLAG_PSM_REQUESTED, &wlvif->flags); /* * We enter PSM only if we're already associated. @@ -2527,12 +2527,12 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) wlvif->basic_rate, true); } } else if (!(conf->flags & IEEE80211_CONF_PS) && - test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags)) { + test_bit(WLVIF_FLAG_PSM_REQUESTED, &wlvif->flags)) { wl1271_debug(DEBUG_PSM, "psm disabled"); - clear_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags); + clear_bit(WLVIF_FLAG_PSM_REQUESTED, &wlvif->flags); - if (test_bit(WL1271_FLAG_PSM, &wl->flags)) + if (test_bit(WLVIF_FLAG_PSM, &wlvif->flags)) ret = wl1271_ps_set_mode(wl, wlvif, STATION_ACTIVE_MODE, wlvif->basic_rate, true); @@ -3769,8 +3769,8 @@ sta_not_found: } /* If we want to go in PSM but we're not there yet */ - if (test_bit(WL1271_FLAG_PSM_REQUESTED, &wl->flags) && - !test_bit(WL1271_FLAG_PSM, &wl->flags)) { + if (test_bit(WLVIF_FLAG_PSM_REQUESTED, &wlvif->flags) && + !test_bit(WLVIF_FLAG_PSM, &wlvif->flags)) { enum wl1271_cmd_ps_mode mode; mode = STATION_POWER_SAVE_MODE; diff --git a/drivers/net/wireless/wl12xx/ps.c b/drivers/net/wireless/wl12xx/ps.c index ac3f20716f5b..8cd81cec2841 100644 --- a/drivers/net/wireless/wl12xx/ps.c +++ b/drivers/net/wireless/wl12xx/ps.c @@ -32,6 +32,7 @@ void wl1271_elp_work(struct work_struct *work) { struct delayed_work *dwork; struct wl1271 *wl; + struct wl12xx_vif *wlvif; dwork = container_of(work, struct delayed_work, work); wl = container_of(dwork, struct wl1271, elp_work); @@ -47,11 +48,15 @@ void wl1271_elp_work(struct work_struct *work) if (unlikely(!test_bit(WL1271_FLAG_ELP_REQUESTED, &wl->flags))) goto out; - if (test_bit(WL1271_FLAG_IN_ELP, &wl->flags) || - (!test_bit(WL1271_FLAG_PSM, &wl->flags) && - !test_bit(WL1271_FLAG_IDLE, &wl->flags))) + if (test_bit(WL1271_FLAG_IN_ELP, &wl->flags)) goto out; + wl12xx_for_each_wlvif(wl, wlvif) { + if (!test_bit(WLVIF_FLAG_PSM, &wlvif->flags) && + !test_bit(WL1271_FLAG_IDLE, &wl->flags)) + goto out; + } + wl1271_debug(DEBUG_PSM, "chip to elp"); wl1271_raw_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_SLEEP); set_bit(WL1271_FLAG_IN_ELP, &wl->flags); @@ -65,13 +70,17 @@ out: /* Routines to toggle sleep mode while in ELP */ void wl1271_ps_elp_sleep(struct wl1271 *wl) { + struct wl12xx_vif *wlvif; + /* we shouldn't get consecutive sleep requests */ if (WARN_ON(test_and_set_bit(WL1271_FLAG_ELP_REQUESTED, &wl->flags))) return; - if (!test_bit(WL1271_FLAG_PSM, &wl->flags) && - !test_bit(WL1271_FLAG_IDLE, &wl->flags)) - return; + wl12xx_for_each_wlvif(wl, wlvif) { + if (!test_bit(WLVIF_FLAG_PSM, &wlvif->flags) && + !test_bit(WL1271_FLAG_IDLE, &wl->flags)) + return; + } ieee80211_queue_delayed_work(wl->hw, &wl->elp_work, msecs_to_jiffies(ELP_ENTRY_DELAY)); @@ -162,7 +171,7 @@ int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (ret < 0) return ret; - set_bit(WL1271_FLAG_PSM, &wl->flags); + set_bit(WLVIF_FLAG_PSM, &wlvif->flags); break; case STATION_ACTIVE_MODE: default: @@ -184,7 +193,7 @@ int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (ret < 0) return ret; - clear_bit(WL1271_FLAG_PSM, &wl->flags); + clear_bit(WLVIF_FLAG_PSM, &wlvif->flags); break; } diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 9b28e478930e..ea6b7293175a 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -318,8 +318,6 @@ enum wl12xx_flags { WL1271_FLAG_TX_PENDING, WL1271_FLAG_IN_ELP, WL1271_FLAG_ELP_REQUESTED, - WL1271_FLAG_PSM, - WL1271_FLAG_PSM_REQUESTED, WL1271_FLAG_IRQ_RUNNING, WL1271_FLAG_IDLE, WL1271_FLAG_PSPOLL_FAILURE, @@ -339,6 +337,8 @@ enum wl12xx_vif_flags { WLVIF_FLAG_STA_ASSOCIATED, WLVIF_FLAG_IBSS_JOINED, WLVIF_FLAG_AP_STARTED, + WLVIF_FLAG_PSM, + WLVIF_FLAG_PSM_REQUESTED, }; struct wl1271_link { -- cgit v1.2.3 From 8181aecce9ea3731ff5554c6f9cf16bf249a61fa Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:04 +0200 Subject: wl12xx: make WL1271_FLAG_STA_STATE_SENT flag per-vif This flag should be set per-vif, rather than globally. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 6 +++--- drivers/net/wireless/wl12xx/wl12xx.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 2fe0ee144a9d..63340ad8451d 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -408,7 +408,7 @@ static int wl1271_check_operstate(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (operstate != IF_OPER_UP) return 0; - if (test_and_set_bit(WL1271_FLAG_STA_STATE_SENT, &wl->flags)) + if (test_and_set_bit(WLVIF_FLAG_STA_STATE_SENT, &wlvif->flags)) return 0; ret = wl12xx_cmd_set_peer_state(wl, wlvif->sta.hlid); @@ -3624,8 +3624,8 @@ sta_not_found: !!test_and_clear_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags); bool was_ifup = - !!test_and_clear_bit(WL1271_FLAG_STA_STATE_SENT, - &wl->flags); + !!test_and_clear_bit(WLVIF_FLAG_STA_STATE_SENT, + &wlvif->flags); wlvif->aid = 0; /* free probe-request template */ diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index ea6b7293175a..9de57dd71c34 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -321,7 +321,6 @@ enum wl12xx_flags { WL1271_FLAG_IRQ_RUNNING, WL1271_FLAG_IDLE, WL1271_FLAG_PSPOLL_FAILURE, - WL1271_FLAG_STA_STATE_SENT, WL1271_FLAG_FW_TX_BUSY, WL1271_FLAG_IF_INITIALIZED, WL1271_FLAG_DUMMY_PACKET_PENDING, @@ -339,6 +338,7 @@ enum wl12xx_vif_flags { WLVIF_FLAG_AP_STARTED, WLVIF_FLAG_PSM, WLVIF_FLAG_PSM_REQUESTED, + WLVIF_FLAG_STA_STATE_SENT, }; struct wl1271_link { -- cgit v1.2.3 From 0744bdb60b51dce54553d5af9a6133f1fe419032 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:05 +0200 Subject: wl12xx: make WL1271_FLAG_RX_STREAMING_STARTED flag per-vif This flag should be set per-vif, rather than globally. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 10 +++++----- drivers/net/wireless/wl12xx/tx.c | 2 +- drivers/net/wireless/wl12xx/wl12xx.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 63340ad8451d..9042445e0d03 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -514,9 +514,9 @@ static int wl1271_set_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif, goto out; if (enable) - set_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags); + set_bit(WLVIF_FLAG_RX_STREAMING_STARTED, &wlvif->flags); else - clear_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags); + clear_bit(WLVIF_FLAG_RX_STREAMING_STARTED, &wlvif->flags); out: return ret; } @@ -531,7 +531,7 @@ int wl1271_recalc_rx_streaming(struct wl1271 *wl, struct wl12xx_vif *wlvif) int period = wl->conf.rx_streaming.interval; /* don't reconfigure if rx_streaming is disabled */ - if (!test_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags)) + if (!test_bit(WLVIF_FLAG_RX_STREAMING_STARTED, &wlvif->flags)) goto out; /* reconfigure/disable according to new streaming_period */ @@ -558,7 +558,7 @@ static void wl1271_rx_streaming_enable_work(struct work_struct *work) mutex_lock(&wl->mutex); - if (test_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags) || + if (test_bit(WLVIF_FLAG_RX_STREAMING_STARTED, &wlvif->flags) || !test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags) || (!wl->conf.rx_streaming.always && !test_bit(WL1271_FLAG_SOFT_GEMINI, &wl->flags))) @@ -594,7 +594,7 @@ static void wl1271_rx_streaming_disable_work(struct work_struct *work) mutex_lock(&wl->mutex); - if (!test_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags)) + if (!test_bit(WLVIF_FLAG_RX_STREAMING_STARTED, &wlvif->flags)) goto out; ret = wl1271_ps_elp_wakeup(wl); diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index a60d8feb69e4..3cf7166dab63 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -670,7 +670,7 @@ void wl12xx_rearm_rx_streaming(struct wl1271 *wl, unsigned long *active_hlids) continue; /* enable rx streaming */ - if (!test_bit(WL1271_FLAG_RX_STREAMING_STARTED, &wl->flags)) + if (!test_bit(WLVIF_FLAG_RX_STREAMING_STARTED, &wlvif->flags)) ieee80211_queue_work(wl->hw, &wlvif->rx_streaming_enable_work); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 9de57dd71c34..5b5c93093347 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -327,7 +327,6 @@ enum wl12xx_flags { WL1271_FLAG_SUSPENDED, WL1271_FLAG_PENDING_WORK, WL1271_FLAG_SOFT_GEMINI, - WL1271_FLAG_RX_STREAMING_STARTED, WL1271_FLAG_RECOVERY_IN_PROGRESS, WL1271_FLAG_CS_PROGRESS, }; @@ -339,6 +338,7 @@ enum wl12xx_vif_flags { WLVIF_FLAG_PSM, WLVIF_FLAG_PSM_REQUESTED, WLVIF_FLAG_STA_STATE_SENT, + WLVIF_FLAG_RX_STREAMING_STARTED, }; struct wl1271_link { -- cgit v1.2.3 From 10c8cd01e329b2973eddddafe67ae499eef83b19 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:06 +0200 Subject: wl12xx: make WL1271_FLAG_IF_INITIALIZED per-vif Make the initialization flag per-vif, and add some checks for it. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 32 +++++++++++++++++++++++++------- drivers/net/wireless/wl12xx/wl12xx.h | 2 +- 2 files changed, 26 insertions(+), 8 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 9042445e0d03..fb5951cb69e1 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1817,14 +1817,20 @@ static void wl1271_op_stop(struct ieee80211_hw *hw) wl1271_debug(DEBUG_MAC80211, "mac80211 stop"); - mutex_lock(&wl_list_mutex); - list_del(&wl->list); - + mutex_lock(&wl->mutex); + if (wl->state == WL1271_STATE_OFF) { + mutex_unlock(&wl->mutex); + return; + } /* * this must be before the cancel_work calls below, so that the work * functions don't perform further work. */ wl->state = WL1271_STATE_OFF; + mutex_unlock(&wl->mutex); + + mutex_lock(&wl_list_mutex); + list_del(&wl->list); mutex_unlock(&wl_list_mutex); wl1271_disable_interrupts(wl); @@ -1971,7 +1977,6 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) setup_timer(&wlvif->rx_streaming_timer, wl1271_rx_streaming_timer, (unsigned long) wlvif); - return 0; } @@ -2069,7 +2074,8 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, * get here before __wl1271_op_remove_interface is complete, so * opt out if that is the case. */ - if (test_bit(WL1271_FLAG_IF_INITIALIZED, &wl->flags)) { + if (test_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags) || + test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags)) { ret = -EBUSY; goto out; } @@ -2129,7 +2135,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, wl->vif = vif; list_add(&wlvif->list, &wl->wlvif_list); - set_bit(WL1271_FLAG_IF_INITIALIZED, &wl->flags); + set_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags); if (wlvif->bss_type == BSS_TYPE_AP_BSS) wl->ap_count++; @@ -2155,6 +2161,9 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, wl1271_debug(DEBUG_MAC80211, "mac80211 remove interface"); + if (!test_and_clear_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags)) + return; + /* because of hardware recovery, we may get here twice */ if (wl->state != WL1271_STATE_ON) return; @@ -2224,8 +2233,14 @@ static void wl1271_op_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { struct wl1271 *wl = hw->priv; + struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); mutex_lock(&wl->mutex); + + if (wl->state == WL1271_STATE_OFF || + !test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags)) + goto out; + /* * wl->vif can be null here if someone shuts down the interface * just when hardware recovery has been started. @@ -2234,7 +2249,7 @@ static void wl1271_op_remove_interface(struct ieee80211_hw *hw, WARN_ON(wl->vif != vif); __wl1271_op_remove_interface(wl, vif, true); } - +out: mutex_unlock(&wl->mutex); cancel_work_sync(&wl->recovery_work); } @@ -3843,6 +3858,9 @@ static void wl1271_op_bss_info_changed(struct ieee80211_hw *hw, if (unlikely(wl->state == WL1271_STATE_OFF)) goto out; + if (unlikely(!test_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags))) + goto out; + ret = wl1271_ps_elp_wakeup(wl); if (ret < 0) goto out; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 5b5c93093347..740a9b19cea1 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -322,7 +322,6 @@ enum wl12xx_flags { WL1271_FLAG_IDLE, WL1271_FLAG_PSPOLL_FAILURE, WL1271_FLAG_FW_TX_BUSY, - WL1271_FLAG_IF_INITIALIZED, WL1271_FLAG_DUMMY_PACKET_PENDING, WL1271_FLAG_SUSPENDED, WL1271_FLAG_PENDING_WORK, @@ -332,6 +331,7 @@ enum wl12xx_flags { }; enum wl12xx_vif_flags { + WLVIF_FLAG_INITIALIZED, WLVIF_FLAG_STA_ASSOCIATED, WLVIF_FLAG_IBSS_JOINED, WLVIF_FLAG_AP_STARTED, -- cgit v1.2.3 From 836d6600ea0e785fcf8159a3c4b7350276bcd49a Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:07 +0200 Subject: wl12xx: make WL1271_FLAG_PSPOLL_FAILURE flag per-vif This flag should be set per-vif, rather than globally. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/event.c | 4 ++-- drivers/net/wireless/wl12xx/main.c | 2 +- drivers/net/wireless/wl12xx/wl12xx.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index d8b183bba52b..1f60a1f6335e 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -49,7 +49,7 @@ void wl1271_pspoll_work(struct work_struct *work) if (unlikely(wl->state == WL1271_STATE_OFF)) goto out; - if (!test_and_clear_bit(WL1271_FLAG_PSPOLL_FAILURE, &wl->flags)) + if (!test_and_clear_bit(WLVIF_FLAG_PSPOLL_FAILURE, &wlvif->flags)) goto out; if (!test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) @@ -89,7 +89,7 @@ static void wl1271_event_pspoll_delivery_fail(struct wl1271 *wl, wlvif->basic_rate, true); if (ret < 0) return; - set_bit(WL1271_FLAG_PSPOLL_FAILURE, &wl->flags); + set_bit(WLVIF_FLAG_PSPOLL_FAILURE, &wlvif->flags); ieee80211_queue_delayed_work(wl->hw, &wlvif->pspoll_work, msecs_to_jiffies(delay)); } diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index fb5951cb69e1..73973b4fc57f 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2524,7 +2524,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) * incorrectly changed after the pspoll failure active window. */ if (changed & IEEE80211_CONF_CHANGE_PS) - clear_bit(WL1271_FLAG_PSPOLL_FAILURE, &wl->flags); + clear_bit(WLVIF_FLAG_PSPOLL_FAILURE, &wlvif->flags); if (conf->flags & IEEE80211_CONF_PS && !test_bit(WLVIF_FLAG_PSM_REQUESTED, &wlvif->flags)) { diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 740a9b19cea1..bf410f8d01cb 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -320,7 +320,6 @@ enum wl12xx_flags { WL1271_FLAG_ELP_REQUESTED, WL1271_FLAG_IRQ_RUNNING, WL1271_FLAG_IDLE, - WL1271_FLAG_PSPOLL_FAILURE, WL1271_FLAG_FW_TX_BUSY, WL1271_FLAG_DUMMY_PACKET_PENDING, WL1271_FLAG_SUSPENDED, @@ -339,6 +338,7 @@ enum wl12xx_vif_flags { WLVIF_FLAG_PSM_REQUESTED, WLVIF_FLAG_STA_STATE_SENT, WLVIF_FLAG_RX_STREAMING_STARTED, + WLVIF_FLAG_PSPOLL_FAILURE, }; struct wl1271_link { -- cgit v1.2.3 From 52630c5d89840bf09826fe89cc15f868e92223ef Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:08 +0200 Subject: wl12xx: make WL1271_FLAG_CS_PROGRESS flag per-vif This flag should be set per-vif, rather than globally. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/event.c | 22 ++++++++++++---------- drivers/net/wireless/wl12xx/main.c | 12 ++++++++---- drivers/net/wireless/wl12xx/wl12xx.h | 2 +- 3 files changed, 21 insertions(+), 15 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index 1f60a1f6335e..a47312db5a2a 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -345,16 +345,18 @@ static int wl1271_event_process(struct wl1271 *wl, struct event_mailbox *mbox) * 1) channel switch complete with status=0 * 2) channel switch failed status=1 */ - if (test_and_clear_bit(WL1271_FLAG_CS_PROGRESS, &wl->flags)) { - /* TODO: configure only the relevant vif */ - wl12xx_for_each_wlvif_sta(wl, wlvif) { - struct ieee80211_vif *vif = - wl12xx_wlvif_to_vif(wlvif); - bool success = mbox->channel_switch_status ? - false : true; - - ieee80211_chswitch_done(vif, success); - } + + /* TODO: configure only the relevant vif */ + wl12xx_for_each_wlvif_sta(wl, wlvif) { + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); + bool success; + + if (!test_and_clear_bit(WLVIF_FLAG_CS_PROGRESS, + &wl->flags)) + continue; + + success = mbox->channel_switch_status ? false : true; + ieee80211_chswitch_done(vif, success); } } diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 73973b4fc57f..0647d460b698 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2317,7 +2317,7 @@ static int wl1271_unjoin(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int ret; - if (test_and_clear_bit(WL1271_FLAG_CS_PROGRESS, &wl->flags)) { + if (test_and_clear_bit(WLVIF_FLAG_CS_PROGRESS, &wlvif->flags)) { wl12xx_cmd_stop_channel_switch(wl); ieee80211_chswitch_done(wl->vif, false); } @@ -4275,6 +4275,7 @@ static void wl12xx_op_channel_switch(struct ieee80211_hw *hw, struct ieee80211_channel_switch *ch_switch) { struct wl1271 *wl = hw->priv; + struct wl12xx_vif *wlvif; int ret; wl1271_debug(DEBUG_MAC80211, "mac80211 channel switch"); @@ -4291,10 +4292,13 @@ static void wl12xx_op_channel_switch(struct ieee80211_hw *hw, if (ret < 0) goto out; - ret = wl12xx_cmd_channel_switch(wl, ch_switch); + /* TODO: change mac80211 to pass vif as param */ + wl12xx_for_each_wlvif_sta(wl, wlvif) { + ret = wl12xx_cmd_channel_switch(wl, ch_switch); - if (!ret) - set_bit(WL1271_FLAG_CS_PROGRESS, &wl->flags); + if (!ret) + set_bit(WLVIF_FLAG_CS_PROGRESS, &wlvif->flags); + } wl1271_ps_elp_sleep(wl); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index bf410f8d01cb..fc8c9758fc0c 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -326,7 +326,6 @@ enum wl12xx_flags { WL1271_FLAG_PENDING_WORK, WL1271_FLAG_SOFT_GEMINI, WL1271_FLAG_RECOVERY_IN_PROGRESS, - WL1271_FLAG_CS_PROGRESS, }; enum wl12xx_vif_flags { @@ -339,6 +338,7 @@ enum wl12xx_vif_flags { WLVIF_FLAG_STA_STATE_SENT, WLVIF_FLAG_RX_STREAMING_STARTED, WLVIF_FLAG_PSPOLL_FAILURE, + WLVIF_FLAG_CS_PROGRESS, }; struct wl1271_link { -- cgit v1.2.3 From 1b92f15ee0e0f06222d4fd36dc36960d217243b3 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:09 +0200 Subject: wl12xx: add band field to wlvif add band field into the per-interface data. mac80211 configures some values (e.g. band, channel) globally, while we configure them per-interface. In order to make it easier to keep track of the configured value for each value while keeping sync with mac80211, save these values both globally and per-vif. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 32 +++++++++++++++++--------------- drivers/net/wireless/wl12xx/cmd.h | 5 +++-- drivers/net/wireless/wl12xx/event.c | 2 +- drivers/net/wireless/wl12xx/main.c | 32 ++++++++++++++++++++------------ drivers/net/wireless/wl12xx/ps.c | 2 +- drivers/net/wireless/wl12xx/scan.c | 2 +- drivers/net/wireless/wl12xx/tx.c | 5 +++-- drivers/net/wireless/wl12xx/wl12xx.h | 3 +++ 8 files changed, 49 insertions(+), 34 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index ff653e8832a8..6cf8cdc72b59 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -481,7 +481,7 @@ int wl12xx_cmd_role_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) wl1271_debug(DEBUG_CMD, "cmd role start dev %d", wlvif->dev_role_id); cmd->role_id = wlvif->dev_role_id; - if (wl->band == IEEE80211_BAND_5GHZ) + if (wlvif->band == IEEE80211_BAND_5GHZ) cmd->band = WL12XX_BAND_5GHZ; cmd->channel = wl->channel; @@ -571,7 +571,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) wl1271_debug(DEBUG_CMD, "cmd role start sta %d", wlvif->role_id); cmd->role_id = wlvif->role_id; - if (wl->band == IEEE80211_BAND_5GHZ) + if (wlvif->band == IEEE80211_BAND_5GHZ) cmd->band = WL12XX_BAND_5GHZ; cmd->channel = wl->channel; cmd->sta.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set); @@ -704,7 +704,7 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->ap.local_rates = cpu_to_le32(0xffffffff); - switch (wl->band) { + switch (wlvif->band) { case IEEE80211_BAND_2GHZ: cmd->band = RADIO_BAND_2_4GHZ; break; @@ -712,7 +712,7 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->band = RADIO_BAND_5GHZ; break; default: - wl1271_warning("ap start - unknown band: %d", (int)wl->band); + wl1271_warning("ap start - unknown band: %d", (int)wlvif->band); cmd->band = RADIO_BAND_2_4GHZ; break; } @@ -785,7 +785,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) wl1271_debug(DEBUG_CMD, "cmd role start ibss %d", wlvif->role_id); cmd->role_id = wlvif->role_id; - if (wl->band == IEEE80211_BAND_5GHZ) + if (wlvif->band == IEEE80211_BAND_5GHZ) cmd->band = WL12XX_BAND_5GHZ; cmd->channel = wl->channel; cmd->ibss.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set); @@ -1157,8 +1157,8 @@ struct sk_buff *wl1271_cmd_build_ap_probe_req(struct wl1271 *wl, wl1271_dump(DEBUG_SCAN, "AP PROBE REQ: ", skb->data, skb->len); - rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[wl->band]); - if (wl->band == IEEE80211_BAND_2GHZ) + rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[wlvif->band]); + if (wlvif->band == IEEE80211_BAND_2GHZ) ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_2_4, skb->data, skb->len, 0, rate); else @@ -1428,7 +1428,8 @@ out: return ret; } -int wl12xx_cmd_add_peer(struct wl1271 *wl, struct ieee80211_sta *sta, u8 hlid) +int wl12xx_cmd_add_peer(struct wl1271 *wl, struct wl12xx_vif *wlvif, + struct ieee80211_sta *sta, u8 hlid) { struct wl12xx_cmd_add_peer *cmd; int i, ret; @@ -1455,13 +1456,13 @@ int wl12xx_cmd_add_peer(struct wl1271 *wl, struct ieee80211_sta *sta, u8 hlid) else cmd->psd_type[i] = WL1271_PSD_LEGACY; - sta_rates = sta->supp_rates[wl->band]; + sta_rates = sta->supp_rates[wlvif->band]; if (sta->ht_cap.ht_supported) sta_rates |= sta->ht_cap.mcs.rx_mask[0] << HW_HT_RATES_OFFSET; cmd->supported_rates = cpu_to_le32(wl1271_tx_enabled_rates_get(wl, sta_rates, - wl->band)); + wlvif->band)); wl1271_debug(DEBUG_CMD, "new peer rates=0x%x queues=0x%x", cmd->supported_rates, sta->uapsd_queues); @@ -1601,7 +1602,8 @@ out: return ret; } -static int wl12xx_cmd_roc(struct wl1271 *wl, u8 role_id) +static int wl12xx_cmd_roc(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 role_id) { struct wl12xx_cmd_roc *cmd; int ret = 0; @@ -1619,7 +1621,7 @@ static int wl12xx_cmd_roc(struct wl1271 *wl, u8 role_id) cmd->role_id = role_id; cmd->channel = wl->channel; - switch (wl->band) { + switch (wlvif->band) { case IEEE80211_BAND_2GHZ: cmd->band = RADIO_BAND_2_4GHZ; break; @@ -1627,7 +1629,7 @@ static int wl12xx_cmd_roc(struct wl1271 *wl, u8 role_id) cmd->band = RADIO_BAND_5GHZ; break; default: - wl1271_error("roc - unknown band: %d", (int)wl->band); + wl1271_error("roc - unknown band: %d", (int)wlvif->band); ret = -EINVAL; goto out_free; } @@ -1674,14 +1676,14 @@ out: return ret; } -int wl12xx_roc(struct wl1271 *wl, u8 role_id) +int wl12xx_roc(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 role_id) { int ret = 0; if (WARN_ON(test_bit(role_id, wl->roc_map))) return 0; - ret = wl12xx_cmd_roc(wl, role_id); + ret = wl12xx_cmd_roc(wl, wlvif, role_id); if (ret < 0) goto out; diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index 8182cf1b4861..968d5bdc0b60 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -80,9 +80,10 @@ int wl1271_cmd_set_ap_key(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 key_size, const u8 *key, u8 hlid, u32 tx_seq_32, u16 tx_seq_16); int wl12xx_cmd_set_peer_state(struct wl1271 *wl, u8 hlid); -int wl12xx_roc(struct wl1271 *wl, u8 role_id); +int wl12xx_roc(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 role_id); int wl12xx_croc(struct wl1271 *wl, u8 role_id); -int wl12xx_cmd_add_peer(struct wl1271 *wl, struct ieee80211_sta *sta, u8 hlid); +int wl12xx_cmd_add_peer(struct wl1271 *wl, struct wl12xx_vif *wlvif, + struct ieee80211_sta *sta, u8 hlid); int wl12xx_cmd_remove_peer(struct wl1271 *wl, u8 hlid); int wl12xx_cmd_config_fwlog(struct wl1271 *wl); int wl12xx_cmd_start_fwlog(struct wl1271 *wl); diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index a47312db5a2a..fd2e7b2d9389 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -145,7 +145,7 @@ static int wl1271_event_ps_report(struct wl1271 *wl, * BET has only a minor effect in 5GHz and masks * channel switch IEs, so we only enable BET on 2.4GHz */ - if (wl->band == IEEE80211_BAND_2GHZ) + if (wlvif->band == IEEE80211_BAND_2GHZ) /* enable beacon early termination */ ret = wl1271_acx_bet_enable(wl, wlvif, true); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 0647d460b698..8e395f1f4b1a 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1968,6 +1968,12 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) wlvif->rate_set = CONF_TX_RATE_MASK_BASIC; wlvif->beacon_int = WL1271_DEFAULT_BEACON_INT; + /* + * mac80211 configures some values globally, while we treat them + * per-interface. thus, on init, we have to copy them from wl + */ + wlvif->band = wl->band; + INIT_WORK(&wlvif->rx_streaming_enable_work, wl1271_rx_streaming_enable_work); INIT_WORK(&wlvif->rx_streaming_disable_work, @@ -2337,7 +2343,7 @@ out: static void wl1271_set_band_rate(struct wl1271 *wl, struct wl12xx_vif *wlvif) { - wlvif->basic_rate_set = wlvif->bitrate_masks[wl->band]; + wlvif->basic_rate_set = wlvif->bitrate_masks[wlvif->band]; wlvif->rate_set = wlvif->basic_rate_set; } @@ -2390,7 +2396,7 @@ static int wl1271_sta_handle_idle(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (ret < 0) goto out; - ret = wl12xx_roc(wl, wlvif->dev_role_id); + ret = wl12xx_roc(wl, wlvif, wlvif->dev_role_id); if (ret < 0) goto out; clear_bit(WL1271_FLAG_IDLE, &wl->flags); @@ -2451,11 +2457,12 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) /* if the channel changes while joined, join again */ if (changed & IEEE80211_CONF_CHANGE_CHANNEL && - ((wl->band != conf->channel->band) || + ((wlvif->band != conf->channel->band) || (wl->channel != channel))) { /* send all pending packets */ wl1271_tx_work_locked(wl); wl->band = conf->channel->band; + wlvif->band = conf->channel->band; wl->channel = channel; if (!is_ap) { @@ -2502,7 +2509,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) if (ret < 0) goto out_sleep; - ret = wl12xx_roc(wl, + ret = wl12xx_roc(wl, wlvif, wlvif->dev_role_id); if (ret < 0) wl1271_warning("roc failed %d", @@ -3420,7 +3427,7 @@ static void wl1271_bss_info_changed_ap(struct wl1271 *wl, u32 rates = bss_conf->basic_rates; wlvif->basic_rate_set = wl1271_tx_enabled_rates_get(wl, rates, - wl->band); + wlvif->band); wlvif->basic_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); @@ -3516,7 +3523,7 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, &wlvif->flags)) { wl1271_unjoin(wl, wlvif); wl12xx_cmd_role_start_dev(wl, wlvif); - wl12xx_roc(wl, wlvif->dev_role_id); + wl12xx_roc(wl, wlvif, wlvif->dev_role_id); } } } @@ -3595,7 +3602,7 @@ sta_not_found: rates = bss_conf->basic_rates; wlvif->basic_rate_set = wl1271_tx_enabled_rates_get(wl, rates, - wl->band); + wlvif->band); wlvif->basic_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); @@ -3603,7 +3610,7 @@ sta_not_found: wlvif->rate_set = wl1271_tx_enabled_rates_get(wl, sta_rate_set, - wl->band); + wlvif->band); ret = wl1271_acx_sta_rate_policies(wl, wlvif); if (ret < 0) goto out; @@ -3694,7 +3701,8 @@ sta_not_found: wl1271_unjoin(wl, wlvif); if (!(conf_flags & IEEE80211_CONF_IDLE)) { wl12xx_cmd_role_start_dev(wl, wlvif); - wl12xx_roc(wl, wlvif->dev_role_id); + wl12xx_roc(wl, wlvif, + wlvif->dev_role_id); } } } @@ -3708,7 +3716,7 @@ sta_not_found: u32 rates = bss_conf->basic_rates; wlvif->basic_rate_set = wl1271_tx_enabled_rates_get(wl, rates, - wl->band); + wlvif->band); wlvif->basic_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); @@ -3762,7 +3770,7 @@ sta_not_found: /* ROC until connected (after EAPOL exchange) */ if (!is_ibss) { - ret = wl12xx_roc(wl, wlvif->role_id); + ret = wl12xx_roc(wl, wlvif, wlvif->role_id); if (ret < 0) goto out; @@ -4068,7 +4076,7 @@ static int wl1271_op_sta_add(struct ieee80211_hw *hw, if (ret < 0) goto out_free_sta; - ret = wl12xx_cmd_add_peer(wl, sta, hlid); + ret = wl12xx_cmd_add_peer(wl, wlvif, sta, hlid); if (ret < 0) goto out_sleep; diff --git a/drivers/net/wireless/wl12xx/ps.c b/drivers/net/wireless/wl12xx/ps.c index 8cd81cec2841..8153408233b5 100644 --- a/drivers/net/wireless/wl12xx/ps.c +++ b/drivers/net/wireless/wl12xx/ps.c @@ -178,7 +178,7 @@ int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, wl1271_debug(DEBUG_PSM, "leaving psm"); /* disable beacon early termination */ - if (wl->band == IEEE80211_BAND_2GHZ) { + if (wlvif->band == IEEE80211_BAND_2GHZ) { ret = wl1271_acx_bet_enable(wl, wlvif, false); if (ret < 0) return ret; diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index 765f08ba29af..2711438fdde3 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -77,7 +77,7 @@ void wl1271_scan_complete_work(struct work_struct *work) !test_bit(wlvif->dev_role_id, wl->roc_map)) { /* restore remain on channel */ wl12xx_cmd_role_start_dev(wl, wlvif); - wl12xx_roc(wl, wlvif->dev_role_id); + wl12xx_roc(wl, wlvif, wlvif->dev_role_id); } wl1271_ps_elp_sleep(wl); diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 3cf7166dab63..604913ff42bd 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -102,7 +102,7 @@ static int wl1271_tx_update_filters(struct wl1271 *wl, if (ret < 0) goto out; - ret = wl12xx_roc(wl, wlvif->dev_role_id); + ret = wl12xx_roc(wl, wlvif, wlvif->dev_role_id); if (ret < 0) goto out; out: @@ -809,7 +809,8 @@ static void wl1271_tx_complete_packet(struct wl1271 *wl, if (result->status == TX_SUCCESS) { if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) info->flags |= IEEE80211_TX_STAT_ACK; - rate = wl1271_rate_to_idx(result->rate_class_index, wl->band); + rate = wl1271_rate_to_idx(result->rate_class_index, + wlvif->band); retries = result->ack_failures; } else if (result->status == TX_RETRY_EXCEEDED) { wl->stats.excessive_retries++; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index fc8c9758fc0c..a689ad02a357 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -591,6 +591,9 @@ struct wl12xx_vif { u8 ssid[IEEE80211_MAX_SSID_LEN + 1]; u8 ssid_len; + /* The current band */ + enum ieee80211_band band; + u32 bitrate_masks[IEEE80211_NUM_BANDS]; u32 basic_rate_set; -- cgit v1.2.3 From 61f845f4f441a90e5328a78c6c4e0646d99fc2f0 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:10 +0200 Subject: wl12xx: add channel field to wlvif add channel into the per-interface data. mac80211 configures some values (e.g. band, channel) globally, while we configure them per-interface. In order to make it easier to keep track of the configured value for each value while keeping sync with mac80211, save these values both globally and per-vif. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 12 ++++++------ drivers/net/wireless/wl12xx/main.c | 6 ++++-- drivers/net/wireless/wl12xx/wl12xx.h | 1 + 3 files changed, 11 insertions(+), 8 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 6cf8cdc72b59..4c5c51810fda 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -483,7 +483,7 @@ int wl12xx_cmd_role_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->role_id = wlvif->dev_role_id; if (wlvif->band == IEEE80211_BAND_5GHZ) cmd->band = WL12XX_BAND_5GHZ; - cmd->channel = wl->channel; + cmd->channel = wlvif->channel; if (wlvif->dev_hlid == WL12XX_INVALID_LINK_ID) { ret = wl12xx_allocate_link(wl, wlvif, &wlvif->dev_hlid); @@ -573,7 +573,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->role_id = wlvif->role_id; if (wlvif->band == IEEE80211_BAND_5GHZ) cmd->band = WL12XX_BAND_5GHZ; - cmd->channel = wl->channel; + cmd->channel = wlvif->channel; cmd->sta.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set); cmd->sta.beacon_interval = cpu_to_le16(wlvif->beacon_int); cmd->sta.ssid_type = WL12XX_SSID_TYPE_ANY; @@ -689,7 +689,7 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->ap.beacon_interval = cpu_to_le16(wlvif->beacon_int); cmd->ap.dtim_interval = bss_conf->dtim_period; cmd->ap.beacon_expiry = WL1271_AP_DEF_BEACON_EXP; - cmd->channel = wl->channel; + cmd->channel = wlvif->channel; if (!bss_conf->hidden_ssid) { /* take the SSID from the beacon for backward compatibility */ @@ -787,7 +787,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) cmd->role_id = wlvif->role_id; if (wlvif->band == IEEE80211_BAND_5GHZ) cmd->band = WL12XX_BAND_5GHZ; - cmd->channel = wl->channel; + cmd->channel = wlvif->channel; cmd->ibss.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set); cmd->ibss.beacon_interval = cpu_to_le16(wlvif->beacon_int); cmd->ibss.dtim_interval = bss_conf->dtim_period; @@ -1608,7 +1608,7 @@ static int wl12xx_cmd_roc(struct wl1271 *wl, struct wl12xx_vif *wlvif, struct wl12xx_cmd_roc *cmd; int ret = 0; - wl1271_debug(DEBUG_CMD, "cmd roc %d (%d)", wl->channel, role_id); + wl1271_debug(DEBUG_CMD, "cmd roc %d (%d)", wlvif->channel, role_id); if (WARN_ON(role_id == WL12XX_INVALID_ROLE_ID)) return -EINVAL; @@ -1620,7 +1620,7 @@ static int wl12xx_cmd_roc(struct wl1271 *wl, struct wl12xx_vif *wlvif, } cmd->role_id = role_id; - cmd->channel = wl->channel; + cmd->channel = wlvif->channel; switch (wlvif->band) { case IEEE80211_BAND_2GHZ: cmd->band = RADIO_BAND_2_4GHZ; diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 8e395f1f4b1a..5137275d3591 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1973,6 +1973,7 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) * per-interface. thus, on init, we have to copy them from wl */ wlvif->band = wl->band; + wlvif->channel = wl->channel; INIT_WORK(&wlvif->rx_streaming_enable_work, wl1271_rx_streaming_enable_work); @@ -2458,12 +2459,13 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) /* if the channel changes while joined, join again */ if (changed & IEEE80211_CONF_CHANGE_CHANNEL && ((wlvif->band != conf->channel->band) || - (wl->channel != channel))) { + (wlvif->channel != channel))) { /* send all pending packets */ wl1271_tx_work_locked(wl); wl->band = conf->channel->band; - wlvif->band = conf->channel->band; wl->channel = channel; + wlvif->band = conf->channel->band; + wlvif->channel = channel; if (!is_ap) { /* diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index a689ad02a357..02dedd191bd4 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -593,6 +593,7 @@ struct wl12xx_vif { /* The current band */ enum ieee80211_band band; + int channel; u32 bitrate_masks[IEEE80211_NUM_BANDS]; u32 basic_rate_set; -- cgit v1.2.3 From 6bd650299046f00df6d7374c7f61c5afe6df6696 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:11 +0200 Subject: wl12xx: add power_level field to wlvif move power_level into the per-interface data. mac80211 configures some values (e.g. band, channel) globally, while we configure them per-interface. In order to make it easier to keep track of the configured value for each value while keeping sync with mac80211, save these values both globally and per-vif. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/init.c | 2 +- drivers/net/wireless/wl12xx/main.c | 4 +++- drivers/net/wireless/wl12xx/wl12xx.h | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index 4af7e2fb52fd..74f569099b53 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -554,7 +554,7 @@ static int wl12xx_init_ap_role(struct wl1271 *wl, struct wl12xx_vif *wlvif) return ret; /* initialize Tx power */ - ret = wl1271_acx_tx_power(wl, wlvif, wl->power_level); + ret = wl1271_acx_tx_power(wl, wlvif, wlvif->power_level); if (ret < 0) return ret; diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 5137275d3591..cffb40be7b5b 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1974,6 +1974,7 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) */ wlvif->band = wl->band; wlvif->channel = wl->channel; + wlvif->power_level = wl->power_level; INIT_WORK(&wlvif->rx_streaming_enable_work, wl1271_rx_streaming_enable_work); @@ -2562,12 +2563,13 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) wlvif->basic_rate, true); } - if (conf->power_level != wl->power_level) { + if (conf->power_level != wlvif->power_level) { ret = wl1271_acx_tx_power(wl, wlvif, conf->power_level); if (ret < 0) goto out_sleep; wl->power_level = conf->power_level; + wlvif->power_level = conf->power_level; } out_sleep: diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 02dedd191bd4..2689522ba4ed 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -631,6 +631,9 @@ struct wl12xx_vif { /* retry counter for PSM entries */ u8 psm_entry_retry; + /* in dBm */ + int power_level; + int rssi_thold; int last_rssi_event; -- cgit v1.2.3 From 9f259c4e5e42d5f0c25675dc1088cd96dc81a9f1 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:12 +0200 Subject: wl12xx: make op_config configure all vifs When mac80211 changes a global (hw) config, iterate through all the relevant vifs and update them. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 112 ++++++++++++++++++++----------------- 1 file changed, 61 insertions(+), 51 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index cffb40be7b5b..b2640edcc3a8 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2408,63 +2408,20 @@ out: return ret; } -static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) +static int wl12xx_config_vif(struct wl1271 *wl, struct wl12xx_vif *wlvif, + struct ieee80211_conf *conf, u32 changed) { - struct wl1271 *wl = hw->priv; - struct ieee80211_vif *vif = wl->vif; /* TODO: reconfig all vifs */ - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); - struct ieee80211_conf *conf = &hw->conf; - int channel, ret = 0; - bool is_ap; + bool is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); + int channel, ret; channel = ieee80211_frequency_to_channel(conf->channel->center_freq); - wl1271_debug(DEBUG_MAC80211, "mac80211 config ch %d psm %s power %d %s" - " changed 0x%x", - channel, - conf->flags & IEEE80211_CONF_PS ? "on" : "off", - conf->power_level, - conf->flags & IEEE80211_CONF_IDLE ? "idle" : "in use", - changed); - - /* - * mac80211 will go to idle nearly immediately after transmitting some - * frames, such as the deauth. To make sure those frames reach the air, - * wait here until the TX queue is fully flushed. - */ - if ((changed & IEEE80211_CONF_CHANGE_IDLE) && - (conf->flags & IEEE80211_CONF_IDLE)) - wl1271_tx_flush(wl); - - mutex_lock(&wl->mutex); - - if (unlikely(wl->state == WL1271_STATE_OFF)) { - /* we support configuring the channel and band while off */ - if ((changed & IEEE80211_CONF_CHANGE_CHANNEL)) { - wl->band = conf->channel->band; - wl->channel = channel; - } - - if ((changed & IEEE80211_CONF_CHANGE_POWER)) - wl->power_level = conf->power_level; - - goto out; - } - - is_ap = (wlvif->bss_type == BSS_TYPE_AP_BSS); - - ret = wl1271_ps_elp_wakeup(wl); - if (ret < 0) - goto out; - /* if the channel changes while joined, join again */ if (changed & IEEE80211_CONF_CHANGE_CHANNEL && ((wlvif->band != conf->channel->band) || (wlvif->channel != channel))) { /* send all pending packets */ wl1271_tx_work_locked(wl); - wl->band = conf->channel->band; - wl->channel = channel; wlvif->band = conf->channel->band; wlvif->channel = channel; @@ -2493,7 +2450,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) ret = wl12xx_croc(wl, wlvif->dev_role_id); if (ret < 0) - goto out_sleep; + return ret; } ret = wl1271_join(wl, wlvif, false); if (ret < 0) @@ -2510,7 +2467,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) ret = wl12xx_croc(wl, wlvif->dev_role_id); if (ret < 0) - goto out_sleep; + return ret; ret = wl12xx_roc(wl, wlvif, wlvif->dev_role_id); @@ -2566,12 +2523,65 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) if (conf->power_level != wlvif->power_level) { ret = wl1271_acx_tx_power(wl, wlvif, conf->power_level); if (ret < 0) - goto out_sleep; + return ret; - wl->power_level = conf->power_level; wlvif->power_level = conf->power_level; } + return 0; +} + +static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) +{ + struct wl1271 *wl = hw->priv; + struct wl12xx_vif *wlvif; + struct ieee80211_conf *conf = &hw->conf; + int channel, ret = 0; + + channel = ieee80211_frequency_to_channel(conf->channel->center_freq); + + wl1271_debug(DEBUG_MAC80211, "mac80211 config ch %d psm %s power %d %s" + " changed 0x%x", + channel, + conf->flags & IEEE80211_CONF_PS ? "on" : "off", + conf->power_level, + conf->flags & IEEE80211_CONF_IDLE ? "idle" : "in use", + changed); + + /* + * mac80211 will go to idle nearly immediately after transmitting some + * frames, such as the deauth. To make sure those frames reach the air, + * wait here until the TX queue is fully flushed. + */ + if ((changed & IEEE80211_CONF_CHANGE_IDLE) && + (conf->flags & IEEE80211_CONF_IDLE)) + wl1271_tx_flush(wl); + + mutex_lock(&wl->mutex); + + /* we support configuring the channel and band even while off */ + if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { + wl->band = conf->channel->band; + wl->channel = channel; + } + + if (changed & IEEE80211_CONF_CHANGE_POWER) + wl->power_level = conf->power_level; + + if (unlikely(wl->state == WL1271_STATE_OFF)) + goto out; + + ret = wl1271_ps_elp_wakeup(wl); + if (ret < 0) + goto out; + + /* configure each interface */ + wl12xx_for_each_wlvif(wl, wlvif) { + ret = wl12xx_config_vif(wl, wlvif, conf, changed); + if (ret < 0) + goto out_sleep; + } + out_sleep: wl1271_ps_elp_sleep(wl); -- cgit v1.2.3 From 6e8cd3310491b10db20d0f7eaf5713b05fa7b753 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:13 +0200 Subject: wl12xx: replace all remaining wl->vif references wl->vif is appropriate only when a single vif is being used. Instead, pass wlvif as parameter or iterate through all the vifs (e.g. when a global configuration was changed) Leave wl->vif only to determine whether a vif was already added (this check will be removed as well after both the driver and fw will support multiple vifs) Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 15 +++-- drivers/net/wireless/wl12xx/debugfs.c | 11 +--- drivers/net/wireless/wl12xx/main.c | 112 +++++++++++++++++++++------------- drivers/net/wireless/wl12xx/ps.c | 11 ++-- drivers/net/wireless/wl12xx/ps.h | 5 +- drivers/net/wireless/wl12xx/tx.c | 2 +- 6 files changed, 91 insertions(+), 65 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 4c5c51810fda..65bf9526576d 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -654,7 +654,8 @@ out: int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct wl12xx_cmd_role_start *cmd; - struct ieee80211_bss_conf *bss_conf = &wl->vif->bss_conf; + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); + struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; int ret; wl1271_debug(DEBUG_CMD, "cmd role start ap %d", wlvif->role_id); @@ -773,7 +774,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif) { struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); struct wl12xx_cmd_role_start *cmd; - struct ieee80211_bss_conf *bss_conf = &wl->vif->bss_conf; + struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; int ret; cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); @@ -1096,10 +1097,11 @@ out: int wl1271_cmd_build_ps_poll(struct wl1271 *wl, struct wl12xx_vif *wlvif, u16 aid) { + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); struct sk_buff *skb; int ret = 0; - skb = ieee80211_pspoll_get(wl->hw, wl->vif); + skb = ieee80211_pspoll_get(wl->hw, vif); if (!skb) goto out; @@ -1176,6 +1178,7 @@ int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, struct wl12xx_vif *wlvif, __be32 ip_addr) { int ret; + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); struct wl12xx_arp_rsp_template tmpl; struct ieee80211_hdr_3addr *hdr; struct arphdr *arp_hdr; @@ -1187,8 +1190,8 @@ int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, struct wl12xx_vif *wlvif, hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA | IEEE80211_FCTL_TODS); - memcpy(hdr->addr1, wl->vif->bss_conf.bssid, ETH_ALEN); - memcpy(hdr->addr2, wl->vif->addr, ETH_ALEN); + memcpy(hdr->addr1, vif->bss_conf.bssid, ETH_ALEN); + memcpy(hdr->addr2, vif->addr, ETH_ALEN); memset(hdr->addr3, 0xff, ETH_ALEN); /* llc layer */ @@ -1204,7 +1207,7 @@ int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, struct wl12xx_vif *wlvif, arp_hdr->ar_op = cpu_to_be16(ARPOP_REPLY); /* arp payload */ - memcpy(tmpl.sender_hw, wl->vif->addr, ETH_ALEN); + memcpy(tmpl.sender_hw, vif->addr, ETH_ALEN); tmpl.sender_ip = ip_addr; ret = wl1271_cmd_template_set(wl, CMD_TEMPL_ARP_RSP, diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 4abff8274ac3..d6c2d0c1b6cd 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -615,19 +615,12 @@ static ssize_t beacon_filtering_write(struct file *file, size_t count, loff_t *ppos) { struct wl1271 *wl = file->private_data; - struct ieee80211_vif *vif; struct wl12xx_vif *wlvif; char buf[10]; size_t len; unsigned long value; int ret; - if (!wl->vif) - return -EINVAL; - - vif = wl->vif; - wlvif = wl12xx_vif_to_data(vif); - len = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, len)) return -EFAULT; @@ -645,7 +638,9 @@ static ssize_t beacon_filtering_write(struct file *file, if (ret < 0) goto out; - ret = wl1271_acx_beacon_filter_opt(wl, wlvif, !!value); + wl12xx_for_each_wlvif(wl, wlvif) { + ret = wl1271_acx_beacon_filter_opt(wl, wlvif, !!value); + } wl1271_ps_elp_sleep(wl); out: diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index b2640edcc3a8..08fc9d464288 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -779,7 +779,9 @@ static int wl1271_plt_init(struct wl1271 *wl) return ret; } -static void wl12xx_irq_ps_regulate_link(struct wl1271 *wl, u8 hlid, u8 tx_pkts) +static void wl12xx_irq_ps_regulate_link(struct wl1271 *wl, + struct wl12xx_vif *wlvif, + u8 hlid, u8 tx_pkts) { bool fw_ps, single_sta; @@ -791,7 +793,7 @@ static void wl12xx_irq_ps_regulate_link(struct wl1271 *wl, u8 hlid, u8 tx_pkts) * packets in FW or if the STA is awake. */ if (!fw_ps || tx_pkts < WL1271_PS_STA_MAX_PACKETS) - wl1271_ps_link_end(wl, hlid); + wl12xx_ps_link_end(wl, wlvif, hlid); /* * Start high-level PS if the STA is asleep with enough blocks in FW. @@ -799,7 +801,7 @@ static void wl12xx_irq_ps_regulate_link(struct wl1271 *wl, u8 hlid, u8 tx_pkts) * case FW-memory congestion is not a problem. */ else if (!single_sta && fw_ps && tx_pkts >= WL1271_PS_STA_MAX_PACKETS) - wl1271_ps_link_start(wl, hlid, true); + wl12xx_ps_link_start(wl, wlvif, hlid, true); } static void wl12xx_irq_update_links_status(struct wl1271 *wl, @@ -829,15 +831,15 @@ static void wl12xx_irq_update_links_status(struct wl1271 *wl, lnk->prev_freed_pkts = status->tx_lnk_free_pkts[hlid]; lnk->allocated_pkts -= cnt; - wl12xx_irq_ps_regulate_link(wl, hlid, lnk->allocated_pkts); + wl12xx_irq_ps_regulate_link(wl, wlvif, hlid, + lnk->allocated_pkts); } } static void wl12xx_fw_status(struct wl1271 *wl, struct wl12xx_fw_status *status) { - struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + struct wl12xx_vif *wlvif; struct timespec ts; u32 old_tx_blk_count = wl->tx_blocks_available; int avail, freed_blocks; @@ -892,8 +894,9 @@ static void wl12xx_fw_status(struct wl1271 *wl, clear_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags); /* for AP update num of allocated TX blocks per link and ps status */ - if (wlvif->bss_type == BSS_TYPE_AP_BSS) + wl12xx_for_each_wlvif_ap(wl, wlvif) { wl12xx_irq_update_links_status(wl, wlvif, status); + } /* update the host-chipset time offset */ getnstimeofday(&ts); @@ -1212,6 +1215,7 @@ static void wl1271_recovery_work(struct work_struct *work) struct wl1271 *wl = container_of(work, struct wl1271, recovery_work); struct wl12xx_vif *wlvif; + struct ieee80211_vif *vif; mutex_lock(&wl->mutex); @@ -1249,7 +1253,12 @@ static void wl1271_recovery_work(struct work_struct *work) } /* reboot the chipset */ - __wl1271_op_remove_interface(wl, wl->vif, false); + while (!list_empty(&wl->wlvif_list)) { + wlvif = list_first_entry(&wl->wlvif_list, + struct wl12xx_vif, list); + vif = wl12xx_wlvif_to_vif(wlvif); + __wl1271_op_remove_interface(wl, vif, false); + } clear_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags); @@ -1721,18 +1730,19 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wow) { struct wl1271 *wl = hw->priv; - struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + struct wl12xx_vif *wlvif; int ret; wl1271_debug(DEBUG_MAC80211, "mac80211 suspend wow=%d", !!wow); WARN_ON(!wow || !wow->any); wl->wow_enabled = true; - ret = wl1271_configure_suspend(wl, wlvif); - if (ret < 0) { - wl1271_warning("couldn't prepare device to suspend"); - return ret; + wl12xx_for_each_wlvif(wl, wlvif) { + ret = wl1271_configure_suspend(wl, wlvif); + if (ret < 0) { + wl1271_warning("couldn't prepare device to suspend"); + return ret; + } } /* flush any remaining work */ wl1271_debug(DEBUG_MAC80211, "flushing remaining works"); @@ -1751,7 +1761,9 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw, wl1271_enable_interrupts(wl); flush_work(&wl->tx_work); - flush_delayed_work(&wlvif->pspoll_work); + wl12xx_for_each_wlvif(wl, wlvif) { + flush_delayed_work(&wlvif->pspoll_work); + } flush_delayed_work(&wl->elp_work); return 0; @@ -1760,8 +1772,7 @@ static int wl1271_op_suspend(struct ieee80211_hw *hw, static int wl1271_op_resume(struct ieee80211_hw *hw) { struct wl1271 *wl = hw->priv; - struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + struct wl12xx_vif *wlvif; unsigned long flags; bool run_irq_work = false; @@ -1785,7 +1796,9 @@ static int wl1271_op_resume(struct ieee80211_hw *hw) wl1271_irq(0, wl); wl1271_enable_interrupts(wl); } - wl1271_configure_resume(wl, wlvif); + wl12xx_for_each_wlvif(wl, wlvif) { + wl1271_configure_resume(wl, wlvif); + } wl->wow_enabled = false; return 0; @@ -2242,6 +2255,7 @@ static void wl1271_op_remove_interface(struct ieee80211_hw *hw, { struct wl1271 *wl = hw->priv; struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + struct wl12xx_vif *iter; mutex_lock(&wl->mutex); @@ -2253,10 +2267,14 @@ static void wl1271_op_remove_interface(struct ieee80211_hw *hw, * wl->vif can be null here if someone shuts down the interface * just when hardware recovery has been started. */ - if (wl->vif) { - WARN_ON(wl->vif != vif); + wl12xx_for_each_wlvif(wl, iter) { + if (iter != wlvif) + continue; + __wl1271_op_remove_interface(wl, vif, true); + break; } + WARN_ON(iter != wlvif); out: mutex_unlock(&wl->mutex); cancel_work_sync(&wl->recovery_work); @@ -2326,8 +2344,10 @@ static int wl1271_unjoin(struct wl1271 *wl, struct wl12xx_vif *wlvif) int ret; if (test_and_clear_bit(WLVIF_FLAG_CS_PROGRESS, &wlvif->flags)) { + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); + wl12xx_cmd_stop_channel_switch(wl); - ieee80211_chswitch_done(wl->vif, false); + ieee80211_chswitch_done(vif, false); } /* to stop listening to a channel, we disconnect */ @@ -2642,8 +2662,7 @@ static void wl1271_op_configure_filter(struct ieee80211_hw *hw, { struct wl1271_filter_params *fp = (void *)(unsigned long)multicast; struct wl1271 *wl = hw->priv; - struct ieee80211_vif *vif = wl->vif; /* TODO: get as param */ - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + struct wl12xx_vif *wlvif; int ret; @@ -2662,17 +2681,20 @@ static void wl1271_op_configure_filter(struct ieee80211_hw *hw, if (ret < 0) goto out; - if (wlvif->bss_type != BSS_TYPE_AP_BSS) { - if (*total & FIF_ALLMULTI) - ret = wl1271_acx_group_address_tbl(wl, wlvif, false, - NULL, 0); - else if (fp) - ret = wl1271_acx_group_address_tbl(wl, wlvif, - fp->enabled, - fp->mc_list, - fp->mc_list_length); - if (ret < 0) - goto out_sleep; + wl12xx_for_each_wlvif(wl, wlvif) { + if (wlvif->bss_type != BSS_TYPE_AP_BSS) { + if (*total & FIF_ALLMULTI) + ret = wl1271_acx_group_address_tbl(wl, wlvif, + false, + NULL, 0); + else if (fp) + ret = wl1271_acx_group_address_tbl(wl, wlvif, + fp->enabled, + fp->mc_list, + fp->mc_list_length); + if (ret < 0) + goto out_sleep; + } } /* @@ -3162,8 +3184,7 @@ out: static int wl1271_op_set_rts_threshold(struct ieee80211_hw *hw, u32 value) { struct wl1271 *wl = hw->priv; - struct ieee80211_vif *vif = wl->vif; - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + struct wl12xx_vif *wlvif; int ret = 0; mutex_lock(&wl->mutex); @@ -3177,10 +3198,11 @@ static int wl1271_op_set_rts_threshold(struct ieee80211_hw *hw, u32 value) if (ret < 0) goto out; - ret = wl1271_acx_rts_threshold(wl, wlvif, value); - if (ret < 0) - wl1271_warning("wl1271_op_set_rts_threshold failed: %d", ret); - + wl12xx_for_each_wlvif(wl, wlvif) { + ret = wl1271_acx_rts_threshold(wl, wlvif, value); + if (ret < 0) + wl1271_warning("set rts threshold failed: %d", ret); + } wl1271_ps_elp_sleep(wl); out: @@ -3669,7 +3691,7 @@ sta_not_found: wlvif->probereq = NULL; /* re-enable dynamic ps - just in case */ - ieee80211_enable_dyn_ps(wl->vif); + ieee80211_enable_dyn_ps(vif); /* revert back to minimum rates for the current band */ wl1271_set_band_rate(wl, wlvif); @@ -4305,9 +4327,11 @@ static void wl12xx_op_channel_switch(struct ieee80211_hw *hw, mutex_lock(&wl->mutex); if (unlikely(wl->state == WL1271_STATE_OFF)) { - mutex_unlock(&wl->mutex); - ieee80211_chswitch_done(wl->vif, false); - return; + wl12xx_for_each_wlvif_sta(wl, wlvif) { + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); + ieee80211_chswitch_done(vif, false); + } + goto out; } ret = wl1271_ps_elp_wakeup(wl); diff --git a/drivers/net/wireless/wl12xx/ps.c b/drivers/net/wireless/wl12xx/ps.c index 8153408233b5..84a1afac6f53 100644 --- a/drivers/net/wireless/wl12xx/ps.c +++ b/drivers/net/wireless/wl12xx/ps.c @@ -232,9 +232,11 @@ static void wl1271_ps_filter_frames(struct wl1271 *wl, u8 hlid) wl1271_handle_tx_low_watermark(wl); } -void wl1271_ps_link_start(struct wl1271 *wl, u8 hlid, bool clean_queues) +void wl12xx_ps_link_start(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 hlid, bool clean_queues) { struct ieee80211_sta *sta; + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); if (test_bit(hlid, &wl->ap_ps_map)) return; @@ -244,7 +246,7 @@ void wl1271_ps_link_start(struct wl1271 *wl, u8 hlid, bool clean_queues) clean_queues); rcu_read_lock(); - sta = ieee80211_find_sta(wl->vif, wl->links[hlid].addr); + sta = ieee80211_find_sta(vif, wl->links[hlid].addr); if (!sta) { wl1271_error("could not find sta %pM for starting ps", wl->links[hlid].addr); @@ -262,9 +264,10 @@ void wl1271_ps_link_start(struct wl1271 *wl, u8 hlid, bool clean_queues) __set_bit(hlid, &wl->ap_ps_map); } -void wl1271_ps_link_end(struct wl1271 *wl, u8 hlid) +void wl12xx_ps_link_end(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 hlid) { struct ieee80211_sta *sta; + struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif); if (!test_bit(hlid, &wl->ap_ps_map)) return; @@ -274,7 +277,7 @@ void wl1271_ps_link_end(struct wl1271 *wl, u8 hlid) __clear_bit(hlid, &wl->ap_ps_map); rcu_read_lock(); - sta = ieee80211_find_sta(wl->vif, wl->links[hlid].addr); + sta = ieee80211_find_sta(vif, wl->links[hlid].addr); if (!sta) { wl1271_error("could not find sta %pM for ending ps", wl->links[hlid].addr); diff --git a/drivers/net/wireless/wl12xx/ps.h b/drivers/net/wireless/wl12xx/ps.h index 6ad0a0bd29bd..a12052f02026 100644 --- a/drivers/net/wireless/wl12xx/ps.h +++ b/drivers/net/wireless/wl12xx/ps.h @@ -32,8 +32,9 @@ int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, void wl1271_ps_elp_sleep(struct wl1271 *wl); int wl1271_ps_elp_wakeup(struct wl1271 *wl); void wl1271_elp_work(struct work_struct *work); -void wl1271_ps_link_start(struct wl1271 *wl, u8 hlid, bool clean_queues); -void wl1271_ps_link_end(struct wl1271 *wl, u8 hlid); +void wl12xx_ps_link_start(struct wl1271 *wl, struct wl12xx_vif *wlvif, + u8 hlid, bool clean_queues); +void wl12xx_ps_link_end(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 hlid); #define WL1271_PS_COMPLETE_TIMEOUT 500 diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 604913ff42bd..185a65d971ff 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -146,7 +146,7 @@ static void wl1271_tx_regulate_link(struct wl1271 *wl, * case FW-memory congestion is not a problem. */ if (!single_sta && fw_ps && tx_pkts >= WL1271_PS_STA_MAX_PACKETS) - wl1271_ps_link_start(wl, hlid, true); + wl12xx_ps_link_start(wl, wlvif, hlid, true); } bool wl12xx_is_dummy_packet(struct wl1271 *wl, struct sk_buff *skb) -- cgit v1.2.3 From f02774343030c2794bb58b6150420dfefc31c39f Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:14 +0200 Subject: wl12xx: call stop() on recovery The recovery work should call stop() after it removed all the existing interfaces. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 08fc9d464288..433a06fae40b 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -379,6 +379,7 @@ static bool bug_on_recovery; static void __wl1271_op_remove_interface(struct wl1271 *wl, struct ieee80211_vif *vif, bool reset_tx_queues); +static void wl1271_op_stop(struct ieee80211_hw *hw); static void wl1271_free_ap_keys(struct wl1271 *wl, struct wl12xx_vif *wlvif); @@ -1220,7 +1221,7 @@ static void wl1271_recovery_work(struct work_struct *work) mutex_lock(&wl->mutex); if (wl->state != WL1271_STATE_ON) - goto out; + goto out_unlock; /* Avoid a recursive recovery */ set_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags); @@ -1259,6 +1260,8 @@ static void wl1271_recovery_work(struct work_struct *work) vif = wl12xx_wlvif_to_vif(wlvif); __wl1271_op_remove_interface(wl, vif, false); } + mutex_unlock(&wl->mutex); + wl1271_op_stop(wl->hw); clear_bit(WL1271_FLAG_RECOVERY_IN_PROGRESS, &wl->flags); @@ -1269,8 +1272,8 @@ static void wl1271_recovery_work(struct work_struct *work) * to restart the HW. */ ieee80211_wake_queues(wl->hw); - -out: + return; +out_unlock: mutex_unlock(&wl->mutex); } -- cgit v1.2.3 From e5a359f873f50cc123d5ca97637caa30fa095bb9 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:15 +0200 Subject: wl12xx: use dynamic rate policies allocate the rate policies dynamically, instead of using hardcoded indexes. this is needed for proper multi-role configuration. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/acx.c | 6 ++--- drivers/net/wireless/wl12xx/acx.h | 5 ---- drivers/net/wireless/wl12xx/init.c | 7 ++--- drivers/net/wireless/wl12xx/main.c | 52 ++++++++++++++++++++++++++++++++---- drivers/net/wireless/wl12xx/tx.c | 10 +++---- drivers/net/wireless/wl12xx/wl12xx.h | 13 +++++++++ 6 files changed, 72 insertions(+), 21 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/acx.c b/drivers/net/wireless/wl12xx/acx.c index 21e74ca4ddb2..e2e46705059d 100644 --- a/drivers/net/wireless/wl12xx/acx.c +++ b/drivers/net/wireless/wl12xx/acx.c @@ -766,7 +766,7 @@ int wl1271_acx_sta_rate_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif) wlvif->basic_rate, wlvif->rate_set); /* configure one basic rate class */ - acx->rate_policy_idx = cpu_to_le32(ACX_TX_BASIC_RATE); + acx->rate_policy_idx = cpu_to_le32(wlvif->sta.basic_rate_idx); acx->rate_policy.enabled_rates = cpu_to_le32(wlvif->basic_rate); acx->rate_policy.short_retry_limit = c->short_retry_limit; acx->rate_policy.long_retry_limit = c->long_retry_limit; @@ -779,7 +779,7 @@ int wl1271_acx_sta_rate_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif) } /* configure one AP supported rate class */ - acx->rate_policy_idx = cpu_to_le32(ACX_TX_AP_FULL_RATE); + acx->rate_policy_idx = cpu_to_le32(wlvif->sta.ap_rate_idx); acx->rate_policy.enabled_rates = cpu_to_le32(wlvif->rate_set); acx->rate_policy.short_retry_limit = c->short_retry_limit; acx->rate_policy.long_retry_limit = c->long_retry_limit; @@ -796,7 +796,7 @@ int wl1271_acx_sta_rate_policies(struct wl1271 *wl, struct wl12xx_vif *wlvif) * (p2p packets should always go out with OFDM rates, even * if we are currently connected to 11b AP) */ - acx->rate_policy_idx = cpu_to_le32(ACX_TX_BASIC_RATE_P2P); + acx->rate_policy_idx = cpu_to_le32(wlvif->sta.p2p_rate_idx); acx->rate_policy.enabled_rates = cpu_to_le32(CONF_TX_RATE_MASK_BASIC_P2P); acx->rate_policy.short_retry_limit = c->short_retry_limit; diff --git a/drivers/net/wireless/wl12xx/acx.h b/drivers/net/wireless/wl12xx/acx.h index c06119b053e3..b2d85bea6378 100644 --- a/drivers/net/wireless/wl12xx/acx.h +++ b/drivers/net/wireless/wl12xx/acx.h @@ -654,11 +654,6 @@ struct acx_rate_class { u8 reserved; }; -#define ACX_TX_BASIC_RATE 0 -#define ACX_TX_AP_FULL_RATE 1 -#define ACX_TX_BASIC_RATE_P2P 2 -#define ACX_TX_AP_MODE_MGMT_RATE 4 -#define ACX_TX_AP_MODE_BCST_RATE 5 struct acx_rate_policy { struct acx_header header; diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index 74f569099b53..ba286d0a74a8 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -434,7 +434,7 @@ int wl1271_init_ap_rates(struct wl1271 *wl, struct wl12xx_vif *wlvif) rc.long_retry_limit = 10; rc.short_retry_limit = 10; rc.aflags = 0; - ret = wl1271_acx_ap_rate_policy(wl, &rc, ACX_TX_AP_MODE_MGMT_RATE); + ret = wl1271_acx_ap_rate_policy(wl, &rc, wlvif->ap.mgmt_rate_idx); if (ret < 0) return ret; @@ -443,7 +443,7 @@ int wl1271_init_ap_rates(struct wl1271 *wl, struct wl12xx_vif *wlvif) rc.short_retry_limit = 10; rc.long_retry_limit = 10; rc.aflags = 0; - ret = wl1271_acx_ap_rate_policy(wl, &rc, ACX_TX_AP_MODE_BCST_RATE); + ret = wl1271_acx_ap_rate_policy(wl, &rc, wlvif->ap.bcast_rate_idx); if (ret < 0) return ret; @@ -465,7 +465,8 @@ int wl1271_init_ap_rates(struct wl1271 *wl, struct wl12xx_vif *wlvif) rc.short_retry_limit = 10; rc.long_retry_limit = 10; rc.aflags = 0; - ret = wl1271_acx_ap_rate_policy(wl, &rc, i); + ret = wl1271_acx_ap_rate_policy(wl, &rc, + wlvif->ap.ucast_rate_idx[i]); if (ret < 0) return ret; } diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 433a06fae40b..cd2722562e60 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1910,6 +1910,27 @@ static void wl1271_op_stop(struct ieee80211_hw *hw) mutex_unlock(&wl->mutex); } +static int wl12xx_allocate_rate_policy(struct wl1271 *wl, u8 *idx) +{ + u8 policy = find_first_zero_bit(wl->rate_policies_map, + WL12XX_MAX_RATE_POLICIES); + if (policy >= WL12XX_MAX_RATE_POLICIES) + return -EBUSY; + + __set_bit(policy, wl->rate_policies_map); + *idx = policy; + return 0; +} + +static void wl12xx_free_rate_policy(struct wl1271 *wl, u8 *idx) +{ + if (WARN_ON(*idx >= WL12XX_MAX_RATE_POLICIES)) + return; + + __clear_bit(*idx, wl->rate_policies_map); + *idx = WL12XX_MAX_RATE_POLICIES; +} + static u8 wl12xx_get_role_type(struct wl1271 *wl, struct wl12xx_vif *wlvif) { switch (wlvif->bss_type) { @@ -1937,6 +1958,7 @@ static u8 wl12xx_get_role_type(struct wl1271 *wl, struct wl12xx_vif *wlvif) static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) { struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + int i; /* clear everything but the persistent data */ memset(wlvif, 0, offsetof(struct wl12xx_vif, persistent)); @@ -1970,11 +1992,18 @@ static int wl12xx_init_vif_data(struct wl1271 *wl, struct ieee80211_vif *vif) wlvif->bss_type == BSS_TYPE_IBSS) { /* init sta/ibss data */ wlvif->sta.hlid = WL12XX_INVALID_LINK_ID; - + wl12xx_allocate_rate_policy(wl, &wlvif->sta.basic_rate_idx); + wl12xx_allocate_rate_policy(wl, &wlvif->sta.ap_rate_idx); + wl12xx_allocate_rate_policy(wl, &wlvif->sta.p2p_rate_idx); } else { /* init ap data */ wlvif->ap.bcast_hlid = WL12XX_INVALID_LINK_ID; wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID; + wl12xx_allocate_rate_policy(wl, &wlvif->ap.mgmt_rate_idx); + wl12xx_allocate_rate_policy(wl, &wlvif->ap.bcast_rate_idx); + for (i = 0; i < CONF_TX_MAX_AC_COUNT; i++) + wl12xx_allocate_rate_policy(wl, + &wlvif->ap.ucast_rate_idx[i]); } wlvif->bitrate_masks[IEEE80211_BAND_2GHZ] = wl->conf.tx.basic_rate; @@ -2181,7 +2210,7 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, bool reset_tx_queues) { struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); - int ret; + int i, ret; wl1271_debug(DEBUG_MAC80211, "mac80211 remove interface"); @@ -2227,10 +2256,23 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, } deinit: /* clear all hlids (except system_hlid) */ - wlvif->sta.hlid = WL12XX_INVALID_LINK_ID; wlvif->dev_hlid = WL12XX_INVALID_LINK_ID; - wlvif->ap.bcast_hlid = WL12XX_INVALID_LINK_ID; - wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID; + + if (wlvif->bss_type == BSS_TYPE_STA_BSS || + wlvif->bss_type == BSS_TYPE_IBSS) { + wlvif->sta.hlid = WL12XX_INVALID_LINK_ID; + wl12xx_free_rate_policy(wl, &wlvif->sta.basic_rate_idx); + wl12xx_free_rate_policy(wl, &wlvif->sta.ap_rate_idx); + wl12xx_free_rate_policy(wl, &wlvif->sta.p2p_rate_idx); + } else { + wlvif->ap.bcast_hlid = WL12XX_INVALID_LINK_ID; + wlvif->ap.global_hlid = WL12XX_INVALID_LINK_ID; + wl12xx_free_rate_policy(wl, &wlvif->ap.mgmt_rate_idx); + wl12xx_free_rate_policy(wl, &wlvif->ap.bcast_rate_idx); + for (i = 0; i < CONF_TX_MAX_AC_COUNT; i++) + wl12xx_free_rate_policy(wl, + &wlvif->ap.ucast_rate_idx[i]); + } wl12xx_tx_reset_wlvif(wl, wlvif); wl1271_free_ap_keys(wl, wlvif); diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 185a65d971ff..69ac03f5d54b 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -339,16 +339,16 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct wl12xx_vif *wlvif, send them with AP rate policies, otherwise use default basic rates */ if (control->control.sta) - rate_idx = ACX_TX_AP_FULL_RATE; + rate_idx = wlvif->sta.ap_rate_idx; else - rate_idx = ACX_TX_BASIC_RATE; + rate_idx = wlvif->sta.basic_rate_idx; } else { if (hlid == wlvif->ap.global_hlid) - rate_idx = ACX_TX_AP_MODE_MGMT_RATE; + rate_idx = wlvif->ap.mgmt_rate_idx; else if (hlid == wlvif->ap.bcast_hlid) - rate_idx = ACX_TX_AP_MODE_BCST_RATE; + rate_idx = wlvif->ap.bcast_rate_idx; else - rate_idx = ac; + rate_idx = wlvif->ap.ucast_rate_idx[ac]; } tx_attr |= rate_idx << TX_HW_ATTR_OFST_RATE_POLICY; diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 2689522ba4ed..d169d52f6d1c 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -142,6 +142,8 @@ extern u32 wl12xx_debug_level; #define WL12XX_INVALID_ROLE_ID 0xff #define WL12XX_INVALID_LINK_ID 0xff +#define WL12XX_MAX_RATE_POLICIES 16 + /* Defined by FW as 0. Will not be freed or allocated. */ #define WL12XX_SYSTEM_HLID 0 @@ -396,8 +398,11 @@ struct wl1271 { unsigned long links_map[BITS_TO_LONGS(WL12XX_MAX_LINKS)]; unsigned long roles_map[BITS_TO_LONGS(WL12XX_MAX_ROLES)]; unsigned long roc_map[BITS_TO_LONGS(WL12XX_MAX_ROLES)]; + unsigned long rate_policies_map[ + BITS_TO_LONGS(WL12XX_MAX_RATE_POLICIES)]; struct list_head wlvif_list; + u8 sta_count; u8 ap_count; @@ -569,6 +574,10 @@ struct wl12xx_vif { struct { u8 hlid; u8 ba_rx_bitmap; + + u8 basic_rate_idx; + u8 ap_rate_idx; + u8 p2p_rate_idx; } sta; struct { u8 global_hlid; @@ -580,6 +589,10 @@ struct wl12xx_vif { /* recoreded keys - set here before AP startup */ struct wl1271_ap_key *recorded_keys[MAX_NUM_KEYS]; + + u8 mgmt_rate_idx; + u8 bcast_rate_idx; + u8 ucast_rate_idx[CONF_TX_MAX_AC_COUNT]; } ap; }; -- cgit v1.2.3 From f750c82045d8f5d0d6d59e517eb485ffbbe014b2 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:16 +0200 Subject: wl12xx: add elp wakeup/sleep calls to add_interface add_interface might be called while the chip is in elp. add elp_wakeup/sleep calls to handle it. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index cd2722562e60..6e6ac63fb8cd 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2115,6 +2115,10 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, ieee80211_vif_type_p2p(vif), vif->addr); mutex_lock(&wl->mutex); + ret = wl1271_ps_elp_wakeup(wl); + if (ret < 0) + goto out_unlock; + if (wl->vif) { wl1271_debug(DEBUG_MAC80211, "multiple vifs are not supported yet"); @@ -2195,6 +2199,8 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw, else wl->sta_count++; out: + wl1271_ps_elp_sleep(wl); +out_unlock: mutex_unlock(&wl->mutex); mutex_lock(&wl_list_mutex); -- cgit v1.2.3 From e4120df982c2051f3cfc02f6278798c5166a72f8 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 10 Oct 2011 10:13:17 +0200 Subject: wl12xx: use round-robin policy for tx Currently, a single vif might starve all the other vifs. Save the last vif we dequeued a packet from, and continue with the following one using a round-robin policy. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 2 ++ drivers/net/wireless/wl12xx/tx.c | 26 ++++++++++++++++++++------ drivers/net/wireless/wl12xx/wl12xx.h | 6 ++++++ 3 files changed, 28 insertions(+), 6 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 6e6ac63fb8cd..f29d18daaa82 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2282,6 +2282,8 @@ deinit: wl12xx_tx_reset_wlvif(wl, wlvif); wl1271_free_ap_keys(wl, wlvif); + if (wl->last_wlvif == wlvif) + wl->last_wlvif = NULL; list_del(&wlvif->list); memset(wlvif->ap.sta_hlid_map, 0, sizeof(wlvif->ap.sta_hlid_map)); wlvif->role_id = WL12XX_INVALID_ROLE_ID; diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 69ac03f5d54b..5aeef95229eb 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -590,14 +590,28 @@ static struct sk_buff *wl12xx_vif_skb_dequeue(struct wl1271 *wl, static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl) { unsigned long flags; - struct wl12xx_vif *wlvif; + struct wl12xx_vif *wlvif = wl->last_wlvif; struct sk_buff *skb = NULL; - /* TODO: rememeber last vif and consider it */ - wl12xx_for_each_wlvif(wl, wlvif) { - skb = wl12xx_vif_skb_dequeue(wl, wlvif); - if (skb) - break; + if (wlvif) { + wl12xx_for_each_wlvif_continue(wl, wlvif) { + skb = wl12xx_vif_skb_dequeue(wl, wlvif); + if (skb) { + wl->last_wlvif = wlvif; + break; + } + } + } + + /* do another pass */ + if (!skb) { + wl12xx_for_each_wlvif(wl, wlvif) { + skb = wl12xx_vif_skb_dequeue(wl, wlvif); + if (skb) { + wl->last_wlvif = wlvif; + break; + } + } } if (!skb && diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index d169d52f6d1c..8815fd9a0f47 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -552,6 +552,9 @@ struct wl1271 { /* AP-mode - number of currently connected stations */ int active_sta_count; + + /* last wlvif we transmitted from */ + struct wl12xx_vif *last_wlvif; }; struct wl1271_station { @@ -693,6 +696,9 @@ struct ieee80211_vif *wl12xx_wlvif_to_vif(struct wl12xx_vif *wlvif) #define wl12xx_for_each_wlvif(wl, wlvif) \ list_for_each_entry(wlvif, &wl->wlvif_list, list) +#define wl12xx_for_each_wlvif_continue(wl, wlvif) \ + list_for_each_entry_continue(wlvif, &wl->wlvif_list, list) + #define wl12xx_for_each_wlvif_bss_type(wl, wlvif, _bss_type) \ wl12xx_for_each_wlvif(wl, wlvif) \ if (wlvif->bss_type == _bss_type) -- cgit v1.2.3 From c7e7c227b63836933ef736fa2d7cc526174b1563 Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Thu, 6 Oct 2011 22:59:37 +0300 Subject: wl12xx: remove sdio_test module This module has been causing more trouble than being useful. It only tests the SDIO speed by connecting to the wl12xx chip and does some throughput calculations. It is an ugly quick hack and, if we really want to have it as part of wl12xx we need to clean it up and implement it properly. A tarball of the code has been created and posted here, with some instructions: http://wireless.kernel.org/en/users/Drivers/wl12xx#SDIO_performance_test_module Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/Kconfig | 10 - drivers/net/wireless/wl12xx/Makefile | 3 - drivers/net/wireless/wl12xx/sdio_test.c | 543 -------------------------------- 3 files changed, 556 deletions(-) delete mode 100644 drivers/net/wireless/wl12xx/sdio_test.c (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/Kconfig b/drivers/net/wireless/wl12xx/Kconfig index 3fe388b87c2e..af08c8609c63 100644 --- a/drivers/net/wireless/wl12xx/Kconfig +++ b/drivers/net/wireless/wl12xx/Kconfig @@ -42,16 +42,6 @@ config WL12XX_SDIO If you choose to build a module, it'll be called wl12xx_sdio. Say N if unsure. -config WL12XX_SDIO_TEST - tristate "TI wl12xx SDIO testing support" - depends on WL12XX && MMC && WL12XX_SDIO - default n - ---help--- - This module adds support for the SDIO bus testing with the - TI wl12xx chipsets. You probably don't want this unless you are - testing a new hardware platform. Select this if you want to test the - SDIO bus which is connected to the wl12xx chip. - config WL12XX_PLATFORM_DATA bool depends on WL12XX_SDIO != n || WL1251_SDIO != n diff --git a/drivers/net/wireless/wl12xx/Makefile b/drivers/net/wireless/wl12xx/Makefile index 621b3483ca2c..fe67262ba19f 100644 --- a/drivers/net/wireless/wl12xx/Makefile +++ b/drivers/net/wireless/wl12xx/Makefile @@ -3,14 +3,11 @@ wl12xx-objs = main.o cmd.o io.o event.o tx.o rx.o ps.o acx.o \ wl12xx_spi-objs = spi.o wl12xx_sdio-objs = sdio.o -wl12xx_sdio_test-objs = sdio_test.o wl12xx-$(CONFIG_NL80211_TESTMODE) += testmode.o obj-$(CONFIG_WL12XX) += wl12xx.o obj-$(CONFIG_WL12XX_SPI) += wl12xx_spi.o obj-$(CONFIG_WL12XX_SDIO) += wl12xx_sdio.o -obj-$(CONFIG_WL12XX_SDIO_TEST) += wl12xx_sdio_test.o - # small builtin driver bit obj-$(CONFIG_WL12XX_PLATFORM_DATA) += wl12xx_platform_data.o diff --git a/drivers/net/wireless/wl12xx/sdio_test.c b/drivers/net/wireless/wl12xx/sdio_test.c deleted file mode 100644 index f25d5d9212e7..000000000000 --- a/drivers/net/wireless/wl12xx/sdio_test.c +++ /dev/null @@ -1,543 +0,0 @@ -/* - * SDIO testing driver for wl12xx - * - * Copyright (C) 2010 Nokia Corporation - * - * Contact: Roger Quadros - * - * wl12xx read/write routines taken from the main module - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA - * 02110-1301 USA - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "wl12xx.h" -#include "io.h" -#include "boot.h" - -#ifndef SDIO_VENDOR_ID_TI -#define SDIO_VENDOR_ID_TI 0x0097 -#endif - -#ifndef SDIO_DEVICE_ID_TI_WL1271 -#define SDIO_DEVICE_ID_TI_WL1271 0x4076 -#endif - -static bool rx, tx; - -module_param(rx, bool, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(rx, "Perform rx test. Default (0). " - "This test continuously reads data from the SDIO device.\n"); - -module_param(tx, bool, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(tx, "Perform tx test. Default (0). " - "This test continuously writes data to the SDIO device.\n"); - -struct wl1271_test { - struct wl1271 wl; - struct task_struct *test_task; -}; - -static const struct sdio_device_id wl1271_devices[] = { - { SDIO_DEVICE(SDIO_VENDOR_ID_TI, SDIO_DEVICE_ID_TI_WL1271) }, - {} -}; - -static inline struct sdio_func *wl_to_func(struct wl1271 *wl) -{ - return wl->if_priv; -} - -static struct device *wl1271_sdio_wl_to_dev(struct wl1271 *wl) -{ - return &(wl_to_func(wl)->dev); -} - -static void wl1271_sdio_raw_read(struct wl1271 *wl, int addr, void *buf, - size_t len, bool fixed) -{ - int ret = 0; - struct sdio_func *func = wl_to_func(wl); - - if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) { - ((u8 *)buf)[0] = sdio_f0_readb(func, addr, &ret); - wl1271_debug(DEBUG_SDIO, "sdio read 52 addr 0x%x, byte 0x%02x", - addr, ((u8 *)buf)[0]); - } else { - if (fixed) - ret = sdio_readsb(func, buf, addr, len); - else - ret = sdio_memcpy_fromio(func, buf, addr, len); - - wl1271_debug(DEBUG_SDIO, "sdio read 53 addr 0x%x, %zu bytes", - addr, len); - wl1271_dump_ascii(DEBUG_SDIO, "data: ", buf, len); - } - - if (ret) - wl1271_error("sdio read failed (%d)", ret); -} - -static void wl1271_sdio_raw_write(struct wl1271 *wl, int addr, void *buf, - size_t len, bool fixed) -{ - int ret = 0; - struct sdio_func *func = wl_to_func(wl); - - if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) { - sdio_f0_writeb(func, ((u8 *)buf)[0], addr, &ret); - wl1271_debug(DEBUG_SDIO, "sdio write 52 addr 0x%x, byte 0x%02x", - addr, ((u8 *)buf)[0]); - } else { - wl1271_debug(DEBUG_SDIO, "sdio write 53 addr 0x%x, %zu bytes", - addr, len); - wl1271_dump_ascii(DEBUG_SDIO, "data: ", buf, len); - - if (fixed) - ret = sdio_writesb(func, addr, buf, len); - else - ret = sdio_memcpy_toio(func, addr, buf, len); - } - if (ret) - wl1271_error("sdio write failed (%d)", ret); - -} - -static int wl1271_sdio_set_power(struct wl1271 *wl, bool enable) -{ - struct sdio_func *func = wl_to_func(wl); - int ret; - - /* Let the SDIO stack handle wlan_enable control, so we - * keep host claimed while wlan is in use to keep wl1271 - * alive. - */ - if (enable) { - /* Power up the card */ - ret = pm_runtime_get_sync(&func->dev); - if (ret < 0) - goto out; - - /* Runtime PM might be disabled, power up the card manually */ - ret = mmc_power_restore_host(func->card->host); - if (ret < 0) - goto out; - - sdio_claim_host(func); - sdio_enable_func(func); - } else { - sdio_disable_func(func); - sdio_release_host(func); - - /* Runtime PM might be disabled, power off the card manually */ - ret = mmc_power_save_host(func->card->host); - if (ret < 0) - goto out; - - /* Power down the card */ - ret = pm_runtime_put_sync(&func->dev); - } - -out: - return ret; -} - -static void wl1271_sdio_disable_interrupts(struct wl1271 *wl) -{ -} - -static void wl1271_sdio_enable_interrupts(struct wl1271 *wl) -{ -} - - -static struct wl1271_if_operations sdio_ops = { - .read = wl1271_sdio_raw_read, - .write = wl1271_sdio_raw_write, - .power = wl1271_sdio_set_power, - .dev = wl1271_sdio_wl_to_dev, - .enable_irq = wl1271_sdio_enable_interrupts, - .disable_irq = wl1271_sdio_disable_interrupts, -}; - -static void wl1271_fw_wakeup(struct wl1271 *wl) -{ - u32 elp_reg; - - elp_reg = ELPCTRL_WAKE_UP; - wl1271_raw_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, elp_reg); -} - -static int wl1271_fetch_firmware(struct wl1271 *wl) -{ - const struct firmware *fw; - int ret; - - if (wl->chip.id == CHIP_ID_1283_PG20) - ret = request_firmware(&fw, WL128X_FW_NAME, - wl1271_wl_to_dev(wl)); - else - ret = request_firmware(&fw, WL127X_FW_NAME, - wl1271_wl_to_dev(wl)); - - if (ret < 0) { - wl1271_error("could not get firmware: %d", ret); - return ret; - } - - if (fw->size % 4) { - wl1271_error("firmware size is not multiple of 32 bits: %zu", - fw->size); - ret = -EILSEQ; - goto out; - } - - wl->fw_len = fw->size; - wl->fw = vmalloc(wl->fw_len); - - if (!wl->fw) { - wl1271_error("could not allocate memory for the firmware"); - ret = -ENOMEM; - goto out; - } - - memcpy(wl->fw, fw->data, wl->fw_len); - - ret = 0; - -out: - release_firmware(fw); - - return ret; -} - -static int wl1271_fetch_nvs(struct wl1271 *wl) -{ - const struct firmware *fw; - int ret; - - ret = request_firmware(&fw, WL12XX_NVS_NAME, wl1271_wl_to_dev(wl)); - - if (ret < 0) { - wl1271_error("could not get nvs file: %d", ret); - return ret; - } - - wl->nvs = kmemdup(fw->data, fw->size, GFP_KERNEL); - - if (!wl->nvs) { - wl1271_error("could not allocate memory for the nvs file"); - ret = -ENOMEM; - goto out; - } - - wl->nvs_len = fw->size; - -out: - release_firmware(fw); - - return ret; -} - -static int wl1271_chip_wakeup(struct wl1271 *wl) -{ - struct wl1271_partition_set partition; - int ret; - - msleep(WL1271_PRE_POWER_ON_SLEEP); - ret = wl1271_power_on(wl); - if (ret) - return ret; - - msleep(WL1271_POWER_ON_SLEEP); - - /* We don't need a real memory partition here, because we only want - * to use the registers at this point. */ - memset(&partition, 0, sizeof(partition)); - partition.reg.start = REGISTERS_BASE; - partition.reg.size = REGISTERS_DOWN_SIZE; - wl1271_set_partition(wl, &partition); - - /* ELP module wake up */ - wl1271_fw_wakeup(wl); - - /* whal_FwCtrl_BootSm() */ - - /* 0. read chip id from CHIP_ID */ - wl->chip.id = wl1271_read32(wl, CHIP_ID_B); - - /* 1. check if chip id is valid */ - - switch (wl->chip.id) { - case CHIP_ID_1271_PG10: - wl1271_warning("chip id 0x%x (1271 PG10) support is obsolete", - wl->chip.id); - break; - case CHIP_ID_1271_PG20: - wl1271_notice("chip id 0x%x (1271 PG20)", - wl->chip.id); - break; - case CHIP_ID_1283_PG20: - wl1271_notice("chip id 0x%x (1283 PG20)", - wl->chip.id); - break; - case CHIP_ID_1283_PG10: - default: - wl1271_warning("unsupported chip id: 0x%x", wl->chip.id); - return -ENODEV; - } - - return ret; -} - -static struct wl1271_partition_set part_down = { - .mem = { - .start = 0x00000000, - .size = 0x000177c0 - }, - .reg = { - .start = REGISTERS_BASE, - .size = 0x00008800 - }, - .mem2 = { - .start = 0x00000000, - .size = 0x00000000 - }, - .mem3 = { - .start = 0x00000000, - .size = 0x00000000 - }, -}; - -static int tester(void *data) -{ - struct wl1271 *wl = data; - struct sdio_func *func = wl_to_func(wl); - struct device *pdev = &func->dev; - int ret = 0; - bool rx_started = 0; - bool tx_started = 0; - uint8_t *tx_buf, *rx_buf; - int test_size = PAGE_SIZE; - u32 addr = 0; - struct wl1271_partition_set partition; - - /* We assume chip is powered up and firmware fetched */ - - memcpy(&partition, &part_down, sizeof(partition)); - partition.mem.start = addr; - wl1271_set_partition(wl, &partition); - - tx_buf = kmalloc(test_size, GFP_KERNEL); - rx_buf = kmalloc(test_size, GFP_KERNEL); - if (!tx_buf || !rx_buf) { - dev_err(pdev, - "Could not allocate memory. Test will not run.\n"); - ret = -ENOMEM; - goto free; - } - - memset(tx_buf, 0x5a, test_size); - - /* write something in data area so we can read it back */ - wl1271_write(wl, addr, tx_buf, test_size, false); - - while (!kthread_should_stop()) { - if (rx && !rx_started) { - dev_info(pdev, "starting rx test\n"); - rx_started = 1; - } else if (!rx && rx_started) { - dev_info(pdev, "stopping rx test\n"); - rx_started = 0; - } - - if (tx && !tx_started) { - dev_info(pdev, "starting tx test\n"); - tx_started = 1; - } else if (!tx && tx_started) { - dev_info(pdev, "stopping tx test\n"); - tx_started = 0; - } - - if (rx_started) - wl1271_read(wl, addr, rx_buf, test_size, false); - - if (tx_started) - wl1271_write(wl, addr, tx_buf, test_size, false); - - if (!rx_started && !tx_started) - msleep(100); - } - -free: - kfree(tx_buf); - kfree(rx_buf); - return ret; -} - -static int __devinit wl1271_probe(struct sdio_func *func, - const struct sdio_device_id *id) -{ - const struct wl12xx_platform_data *wlan_data; - struct wl1271 *wl; - struct wl1271_test *wl_test; - int ret = 0; - - /* wl1271 has 2 sdio functions we handle just the wlan part */ - if (func->num != 0x02) - return -ENODEV; - - wl_test = kzalloc(sizeof(struct wl1271_test), GFP_KERNEL); - if (!wl_test) { - dev_err(&func->dev, "Could not allocate memory\n"); - return -ENOMEM; - } - - wl = &wl_test->wl; - - wl->if_priv = func; - wl->if_ops = &sdio_ops; - - /* Grab access to FN0 for ELP reg. */ - func->card->quirks |= MMC_QUIRK_LENIENT_FN0; - - /* Use block mode for transferring over one block size of data */ - func->card->quirks |= MMC_QUIRK_BLKSZ_FOR_BYTE_MODE; - - wlan_data = wl12xx_get_platform_data(); - if (IS_ERR(wlan_data)) { - ret = PTR_ERR(wlan_data); - dev_err(&func->dev, "missing wlan platform data: %d\n", ret); - goto out_free; - } - - wl->irq = wlan_data->irq; - wl->ref_clock = wlan_data->board_ref_clock; - wl->tcxo_clock = wlan_data->board_tcxo_clock; - - sdio_set_drvdata(func, wl_test); - - /* power up the device */ - ret = wl1271_chip_wakeup(wl); - if (ret) { - dev_err(&func->dev, "could not wake up chip\n"); - goto out_free; - } - - if (wl->fw == NULL) { - ret = wl1271_fetch_firmware(wl); - if (ret < 0) { - dev_err(&func->dev, "firmware fetch error\n"); - goto out_off; - } - } - - /* fetch NVS */ - if (wl->nvs == NULL) { - ret = wl1271_fetch_nvs(wl); - if (ret < 0) { - dev_err(&func->dev, "NVS fetch error\n"); - goto out_off; - } - } - - ret = wl1271_load_firmware(wl); - if (ret < 0) { - dev_err(&func->dev, "firmware load error: %d\n", ret); - goto out_free; - } - - dev_info(&func->dev, "initialized\n"); - - /* I/O testing will be done in the tester thread */ - - wl_test->test_task = kthread_run(tester, wl, "sdio_tester"); - if (IS_ERR(wl_test->test_task)) { - dev_err(&func->dev, "unable to create kernel thread\n"); - ret = PTR_ERR(wl_test->test_task); - goto out_free; - } - - return 0; - -out_off: - /* power off the chip */ - wl1271_power_off(wl); - -out_free: - kfree(wl_test); - return ret; -} - -static void __devexit wl1271_remove(struct sdio_func *func) -{ - struct wl1271_test *wl_test = sdio_get_drvdata(func); - - /* stop the I/O test thread */ - kthread_stop(wl_test->test_task); - - /* power off the chip */ - wl1271_power_off(&wl_test->wl); - - vfree(wl_test->wl.fw); - wl_test->wl.fw = NULL; - kfree(wl_test->wl.nvs); - wl_test->wl.nvs = NULL; - - kfree(wl_test); -} - -static struct sdio_driver wl1271_sdio_driver = { - .name = "wl12xx_sdio_test", - .id_table = wl1271_devices, - .probe = wl1271_probe, - .remove = __devexit_p(wl1271_remove), -}; - -static int __init wl1271_init(void) -{ - int ret; - - ret = sdio_register_driver(&wl1271_sdio_driver); - if (ret < 0) - pr_err("failed to register sdio driver: %d\n", ret); - - return ret; -} -module_init(wl1271_init); - -static void __exit wl1271_exit(void) -{ - sdio_unregister_driver(&wl1271_sdio_driver); -} -module_exit(wl1271_exit); - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Roger Quadros "); - -- cgit v1.2.3 From fbe936bcb59d8e6e054c325a441082b55538bf8f Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Tue, 4 Oct 2011 23:10:28 +0300 Subject: wl12xx: add an sdio glue struct to keep wl and device side-by-side In order to fully abstract the bus, we need to save the device structure *beside* wl1271, instead of inside it. This will help re-structuring the driver so that we avoid the duplicated code in the bus modules. Signed-off-by: Felipe Balbi [forward-ported and cleaned up and rephrased commit message] Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/sdio.c | 59 +++++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 16 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c index 516a8980723c..5a4268012da4 100644 --- a/drivers/net/wireless/wl12xx/sdio.c +++ b/drivers/net/wireless/wl12xx/sdio.c @@ -44,6 +44,11 @@ #define SDIO_DEVICE_ID_TI_WL1271 0x4076 #endif +struct wl12xx_sdio_glue { + struct device *dev; + struct wl1271 *wl; +}; + static const struct sdio_device_id wl1271_devices[] __devinitconst = { { SDIO_DEVICE(SDIO_VENDOR_ID_TI, SDIO_DEVICE_ID_TI_WL1271) }, {} @@ -57,14 +62,14 @@ static void wl1271_sdio_set_block_size(struct wl1271 *wl, unsigned int blksz) sdio_release_host(wl->if_priv); } -static inline struct sdio_func *wl_to_func(struct wl1271 *wl) +static inline struct wl12xx_sdio_glue *wl_to_glue(struct wl1271 *wl) { return wl->if_priv; } static struct device *wl1271_sdio_wl_to_dev(struct wl1271 *wl) { - return &(wl_to_func(wl)->dev); + return wl_to_glue(wl)->dev; } static irqreturn_t wl1271_hardirq(int irq, void *cookie) @@ -110,7 +115,8 @@ static void wl1271_sdio_raw_read(struct wl1271 *wl, int addr, void *buf, size_t len, bool fixed) { int ret; - struct sdio_func *func = wl_to_func(wl); + struct wl12xx_sdio_glue *glue = wl_to_glue(wl); + struct sdio_func *func = dev_to_sdio_func(glue->dev); if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) { ((u8 *)buf)[0] = sdio_f0_readb(func, addr, &ret); @@ -135,7 +141,8 @@ static void wl1271_sdio_raw_write(struct wl1271 *wl, int addr, void *buf, size_t len, bool fixed) { int ret; - struct sdio_func *func = wl_to_func(wl); + struct wl12xx_sdio_glue *glue = wl_to_glue(wl); + struct sdio_func *func = dev_to_sdio_func(glue->dev); if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) { sdio_f0_writeb(func, ((u8 *)buf)[0], addr, &ret); @@ -158,8 +165,9 @@ static void wl1271_sdio_raw_write(struct wl1271 *wl, int addr, void *buf, static int wl1271_sdio_power_on(struct wl1271 *wl) { - struct sdio_func *func = wl_to_func(wl); int ret; + struct wl12xx_sdio_glue *glue = wl_to_glue(wl); + struct sdio_func *func = dev_to_sdio_func(glue->dev); /* If enabled, tell runtime PM not to power off the card */ if (pm_runtime_enabled(&func->dev)) { @@ -182,8 +190,9 @@ out: static int wl1271_sdio_power_off(struct wl1271 *wl) { - struct sdio_func *func = wl_to_func(wl); int ret; + struct wl12xx_sdio_glue *glue = wl_to_glue(wl); + struct sdio_func *func = dev_to_sdio_func(glue->dev); sdio_disable_func(func); sdio_release_host(func); @@ -224,21 +233,34 @@ static int __devinit wl1271_probe(struct sdio_func *func, struct ieee80211_hw *hw; const struct wl12xx_platform_data *wlan_data; struct wl1271 *wl; + struct wl12xx_sdio_glue *glue; unsigned long irqflags; mmc_pm_flag_t mmcflags; - int ret; + int ret = -ENOMEM; /* We are only able to handle the wlan function */ if (func->num != 0x02) return -ENODEV; + glue = kzalloc(sizeof(*glue), GFP_KERNEL); + if (!glue) { + wl1271_error("can't allocate glue"); + goto out; + } + hw = wl1271_alloc_hw(); - if (IS_ERR(hw)) - return PTR_ERR(hw); + if (IS_ERR(hw)) { + wl1271_error("can't allocate hw"); + ret = PTR_ERR(hw); + goto out_free_glue; + } wl = hw->priv; - wl->if_priv = func; + glue->dev = &func->dev; + glue->wl = wl; + + wl->if_priv = glue; wl->if_ops = &sdio_ops; /* Grab access to FN0 for ELP reg. */ @@ -251,7 +273,7 @@ static int __devinit wl1271_probe(struct sdio_func *func, if (IS_ERR(wlan_data)) { ret = PTR_ERR(wlan_data); wl1271_error("missing wlan platform data: %d", ret); - goto out_free; + goto out_free_hw; } wl->irq = wlan_data->irq; @@ -269,7 +291,7 @@ static int __devinit wl1271_probe(struct sdio_func *func, DRIVER_NAME, wl); if (ret < 0) { wl1271_error("request_irq() failed: %d", ret); - goto out_free; + goto out_free_hw; } ret = enable_irq_wake(wl->irq); @@ -294,25 +316,29 @@ static int __devinit wl1271_probe(struct sdio_func *func, if (ret) goto out_irq; - sdio_set_drvdata(func, wl); + sdio_set_drvdata(func, glue); /* Tell PM core that we don't need the card to be powered now */ pm_runtime_put_noidle(&func->dev); return 0; - out_irq: +out_irq: free_irq(wl->irq, wl); - out_free: +out_free_hw: wl1271_free_hw(wl); +out_free_glue: + kfree(glue); +out: return ret; } static void __devexit wl1271_remove(struct sdio_func *func) { - struct wl1271 *wl = sdio_get_drvdata(func); + struct wl12xx_sdio_glue *glue = sdio_get_drvdata(func); + struct wl1271 *wl = glue->wl; /* Undo decrement done above in wl1271_probe */ pm_runtime_get_noresume(&func->dev); @@ -324,6 +350,7 @@ static void __devexit wl1271_remove(struct sdio_func *func) } free_irq(wl->irq, wl); wl1271_free_hw(wl); + kfree(glue); } #ifdef CONFIG_PM -- cgit v1.2.3 From b65019f661733ece3be0680be307d238d4dec68e Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Tue, 4 Oct 2011 23:36:47 +0300 Subject: wl12xx: add an spi glue struct to keep wl and device side-by-side In order to fully abstract the bus, we need to save the device structure *beside* wl1271, instead of inside it. This will help re-structuring the driver so that we avoid the duplicated code in the bus modules. Signed-off-by: Felipe Balbi [forward-ported and cleaned up and rephrased commit message] Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/spi.c | 67 +++++++++++++++++++++++++++------------ 1 file changed, 47 insertions(+), 20 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/spi.c b/drivers/net/wireless/wl12xx/spi.c index 0f9718677860..16f0c71f6d4c 100644 --- a/drivers/net/wireless/wl12xx/spi.c +++ b/drivers/net/wireless/wl12xx/spi.c @@ -69,14 +69,19 @@ #define WSPI_MAX_NUM_OF_CHUNKS (WL1271_AGGR_BUFFER_SIZE / WSPI_MAX_CHUNK_SIZE) -static inline struct spi_device *wl_to_spi(struct wl1271 *wl) +struct wl12xx_spi_glue { + struct device *dev; + struct wl1271 *wl; +}; + +static inline struct wl12xx_spi_glue *wl_to_glue(struct wl1271 *wl) { return wl->if_priv; } static struct device *wl1271_spi_wl_to_dev(struct wl1271 *wl) { - return &(wl_to_spi(wl)->dev); + return wl_to_glue(wl)->dev; } static void wl1271_spi_disable_interrupts(struct wl1271 *wl) @@ -91,6 +96,7 @@ static void wl1271_spi_enable_interrupts(struct wl1271 *wl) static void wl1271_spi_reset(struct wl1271 *wl) { + struct wl12xx_spi_glue *glue = wl_to_glue(wl); u8 *cmd; struct spi_transfer t; struct spi_message m; @@ -110,7 +116,7 @@ static void wl1271_spi_reset(struct wl1271 *wl) t.len = WSPI_INIT_CMD_LEN; spi_message_add_tail(&t, &m); - spi_sync(wl_to_spi(wl), &m); + spi_sync(to_spi_device(glue->dev), &m); wl1271_dump(DEBUG_SPI, "spi reset -> ", cmd, WSPI_INIT_CMD_LEN); kfree(cmd); @@ -118,6 +124,7 @@ static void wl1271_spi_reset(struct wl1271 *wl) static void wl1271_spi_init(struct wl1271 *wl) { + struct wl12xx_spi_glue *glue = wl_to_glue(wl); u8 crc[WSPI_INIT_CMD_CRC_LEN], *cmd; struct spi_transfer t; struct spi_message m; @@ -165,7 +172,7 @@ static void wl1271_spi_init(struct wl1271 *wl) t.len = WSPI_INIT_CMD_LEN; spi_message_add_tail(&t, &m); - spi_sync(wl_to_spi(wl), &m); + spi_sync(to_spi_device(glue->dev), &m); wl1271_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN); kfree(cmd); } @@ -174,6 +181,7 @@ static void wl1271_spi_init(struct wl1271 *wl) static int wl1271_spi_read_busy(struct wl1271 *wl) { + struct wl12xx_spi_glue *glue = wl_to_glue(wl); struct spi_transfer t[1]; struct spi_message m; u32 *busy_buf; @@ -194,7 +202,7 @@ static int wl1271_spi_read_busy(struct wl1271 *wl) t[0].len = sizeof(u32); t[0].cs_change = true; spi_message_add_tail(&t[0], &m); - spi_sync(wl_to_spi(wl), &m); + spi_sync(to_spi_device(glue->dev), &m); if (*busy_buf & 0x1) return 0; @@ -208,6 +216,7 @@ static int wl1271_spi_read_busy(struct wl1271 *wl) static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf, size_t len, bool fixed) { + struct wl12xx_spi_glue *glue = wl_to_glue(wl); struct spi_transfer t[2]; struct spi_message m; u32 *busy_buf; @@ -243,7 +252,7 @@ static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf, t[1].cs_change = true; spi_message_add_tail(&t[1], &m); - spi_sync(wl_to_spi(wl), &m); + spi_sync(to_spi_device(glue->dev), &m); if (!(busy_buf[WL1271_BUSY_WORD_CNT - 1] & 0x1) && wl1271_spi_read_busy(wl)) { @@ -259,7 +268,7 @@ static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf, t[0].cs_change = true; spi_message_add_tail(&t[0], &m); - spi_sync(wl_to_spi(wl), &m); + spi_sync(to_spi_device(glue->dev), &m); wl1271_dump(DEBUG_SPI, "spi_read cmd -> ", cmd, sizeof(*cmd)); wl1271_dump(DEBUG_SPI, "spi_read buf <- ", buf, chunk_len); @@ -274,6 +283,7 @@ static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf, static void wl1271_spi_raw_write(struct wl1271 *wl, int addr, void *buf, size_t len, bool fixed) { + struct wl12xx_spi_glue *glue = wl_to_glue(wl); struct spi_transfer t[2 * WSPI_MAX_NUM_OF_CHUNKS]; struct spi_message m; u32 commands[WSPI_MAX_NUM_OF_CHUNKS]; @@ -318,7 +328,7 @@ static void wl1271_spi_raw_write(struct wl1271 *wl, int addr, void *buf, cmd++; } - spi_sync(wl_to_spi(wl), &m); + spi_sync(to_spi_device(glue->dev), &m); } static irqreturn_t wl1271_hardirq(int irq, void *cookie) @@ -362,11 +372,12 @@ static struct wl1271_if_operations spi_ops = { static int __devinit wl1271_probe(struct spi_device *spi) { + struct wl12xx_spi_glue *glue; struct wl12xx_platform_data *pdata; struct ieee80211_hw *hw; struct wl1271 *wl; unsigned long irqflags; - int ret; + int ret = -ENOMEM; pdata = spi->dev.platform_data; if (!pdata) { @@ -374,14 +385,25 @@ static int __devinit wl1271_probe(struct spi_device *spi) return -ENODEV; } + glue = kzalloc(sizeof(*glue), GFP_KERNEL); + if (!glue) { + wl1271_error("can't allocate glue"); + goto out; + } + hw = wl1271_alloc_hw(); - if (IS_ERR(hw)) - return PTR_ERR(hw); + if (IS_ERR(hw)) { + ret = PTR_ERR(hw); + goto out_free_glue; + } wl = hw->priv; - dev_set_drvdata(&spi->dev, wl); - wl->if_priv = spi; + glue->dev = &spi->dev; + glue->wl = wl; + + spi_set_drvdata(spi, glue); + wl->if_priv = glue; wl->if_ops = &spi_ops; @@ -392,14 +414,14 @@ static int __devinit wl1271_probe(struct spi_device *spi) ret = spi_setup(spi); if (ret < 0) { wl1271_error("spi_setup failed"); - goto out_free; + goto out_free_hw; } wl->set_power = pdata->set_power; if (!wl->set_power) { wl1271_error("set power function missing in platform data"); ret = -ENODEV; - goto out_free; + goto out_free_hw; } wl->ref_clock = pdata->board_ref_clock; @@ -415,7 +437,7 @@ static int __devinit wl1271_probe(struct spi_device *spi) if (wl->irq < 0) { wl1271_error("irq missing in platform data"); ret = -ENODEV; - goto out_free; + goto out_free_hw; } ret = request_threaded_irq(wl->irq, wl1271_hardirq, wl1271_irq, @@ -423,7 +445,7 @@ static int __devinit wl1271_probe(struct spi_device *spi) DRIVER_NAME, wl); if (ret < 0) { wl1271_error("request_irq() failed: %d", ret); - goto out_free; + goto out_free_hw; } disable_irq(wl->irq); @@ -438,22 +460,27 @@ static int __devinit wl1271_probe(struct spi_device *spi) return 0; - out_irq: +out_irq: free_irq(wl->irq, wl); - out_free: +out_free_hw: wl1271_free_hw(wl); +out_free_glue: + kfree(glue); +out: return ret; } static int __devexit wl1271_remove(struct spi_device *spi) { - struct wl1271 *wl = dev_get_drvdata(&spi->dev); + struct wl12xx_spi_glue *glue = spi_get_drvdata(spi); + struct wl1271 *wl = glue->wl; wl1271_unregister_hw(wl); free_irq(wl->irq, wl); wl1271_free_hw(wl); + kfree(glue); return 0; } -- cgit v1.2.3 From 025aef8fcfbdf680376c4f7aa31b9ac85cebc700 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Wed, 5 Oct 2011 09:00:12 +0300 Subject: wl12xx: add a platform device to the sdio module The platform device will be used to match the platform driver that will be implemented by the core module. Signed-off-by: Felipe Balbi [forward-ported, cleaned-up and rephrased commit message] [call platform_device_add() instead of platform_device_register()] [store alloc'ed device platform directly in glue->core] [fixed the length of memset(res...)] Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/sdio.c | 44 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c index 5a4268012da4..e7ee5d155d34 100644 --- a/drivers/net/wireless/wl12xx/sdio.c +++ b/drivers/net/wireless/wl12xx/sdio.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -47,6 +48,7 @@ struct wl12xx_sdio_glue { struct device *dev; struct wl1271 *wl; + struct platform_device *core; }; static const struct sdio_device_id wl1271_devices[] __devinitconst = { @@ -234,6 +236,7 @@ static int __devinit wl1271_probe(struct sdio_func *func, const struct wl12xx_platform_data *wlan_data; struct wl1271 *wl; struct wl12xx_sdio_glue *glue; + struct resource res[1]; unsigned long irqflags; mmc_pm_flag_t mmcflags; int ret = -ENOMEM; @@ -321,8 +324,47 @@ static int __devinit wl1271_probe(struct sdio_func *func, /* Tell PM core that we don't need the card to be powered now */ pm_runtime_put_noidle(&func->dev); + glue->core = platform_device_alloc("wl12xx-sdio", -1); + if (!glue->core) { + wl1271_error("can't allocate platform_device"); + ret = -ENOMEM; + goto out_unreg_hw; + } + + glue->core->dev.parent = &func->dev; + + memset(res, 0x00, sizeof(res)); + + res[0].start = wlan_data->irq; + res[0].flags = IORESOURCE_IRQ; + res[0].name = "irq"; + + ret = platform_device_add_resources(glue->core, res, ARRAY_SIZE(res)); + if (ret) { + wl1271_error("can't add resources"); + goto out_dev_put; + } + + ret = platform_device_add_data(glue->core, wlan_data, + sizeof(*wlan_data)); + if (ret) { + wl1271_error("can't add platform data"); + goto out_dev_put; + } + + ret = platform_device_add(glue->core); + if (ret) { + wl1271_error("can't add platform device"); + goto out_dev_put; + } return 0; +out_dev_put: + platform_device_put(glue->core); + +out_unreg_hw: + wl1271_unregister_hw(wl); + out_irq: free_irq(wl->irq, wl); @@ -350,6 +392,8 @@ static void __devexit wl1271_remove(struct sdio_func *func) } free_irq(wl->irq, wl); wl1271_free_hw(wl); + platform_device_del(glue->core); + platform_device_put(glue->core); kfree(glue); } -- cgit v1.2.3 From 0969d6793f4899a4c5f56443d50f272068b97142 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Wed, 5 Oct 2011 09:29:13 +0300 Subject: wl12xx: add a platform device to the spi module The platform device will be used to match the platform driver that will be implemented by the core module. Signed-off-by: Felipe Balbi [forward-ported, cleaned-up and rephrased commit message] [call platform_device_add() instead of platform_device_register()] [store alloc'ed device platform directly in glue->core] [fixed the length of memset(res...)] Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/spi.c | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/spi.c b/drivers/net/wireless/wl12xx/spi.c index 16f0c71f6d4c..2dd659886a04 100644 --- a/drivers/net/wireless/wl12xx/spi.c +++ b/drivers/net/wireless/wl12xx/spi.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include "wl12xx.h" @@ -72,6 +73,7 @@ struct wl12xx_spi_glue { struct device *dev; struct wl1271 *wl; + struct platform_device *core; }; static inline struct wl12xx_spi_glue *wl_to_glue(struct wl1271 *wl) @@ -376,6 +378,7 @@ static int __devinit wl1271_probe(struct spi_device *spi) struct wl12xx_platform_data *pdata; struct ieee80211_hw *hw; struct wl1271 *wl; + struct resource res[1]; unsigned long irqflags; int ret = -ENOMEM; @@ -458,8 +461,47 @@ static int __devinit wl1271_probe(struct spi_device *spi) if (ret) goto out_irq; + glue->core = platform_device_alloc("wl12xx-spi", -1); + if (!glue->core) { + wl1271_error("can't allocate platform_device"); + ret = -ENOMEM; + goto out_unreg_hw; + } + + glue->core->dev.parent = &spi->dev; + + memset(res, 0x00, sizeof(res)); + + res[0].start = spi->irq; + res[0].flags = IORESOURCE_IRQ; + res[0].name = "irq"; + + ret = platform_device_add_resources(glue->core, res, ARRAY_SIZE(res)); + if (ret) { + wl1271_error("can't add resources"); + goto out_dev_put; + } + + ret = platform_device_add_data(glue->core, pdata, sizeof(*pdata)); + if (ret) { + wl1271_error("can't add platform data"); + goto out_dev_put; + } + + ret = platform_device_add(glue->core); + if (ret) { + wl1271_error("can't register platform device"); + goto out_dev_put; + } + return 0; +out_dev_put: + platform_device_put(glue->core); + +out_unreg_hw: + wl1271_unregister_hw(wl); + out_irq: free_irq(wl->irq, wl); @@ -480,6 +522,8 @@ static int __devexit wl1271_remove(struct spi_device *spi) wl1271_unregister_hw(wl); free_irq(wl->irq, wl); wl1271_free_hw(wl); + platform_device_del(glue->core); + platform_device_put(glue->core); kfree(glue); return 0; -- cgit v1.2.3 From ce2a217c8268906640ebf7291d7a06210a35dd2f Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Wed, 5 Oct 2011 14:12:55 +0300 Subject: wl12xx: add platform driver to the core module Nnow that we have a platform_device on both glue layers, add a platform_driver to the core driver. It's currently an empty platform_driver but more functionality will be added on later patches. Signed-off-by: Felipe Balbi [forward-ported, cleaned-up and rephrased commit message] [added platform_driver.driver initialization] Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index f29d18daaa82..3262e8a6c475 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -5200,6 +5200,45 @@ int wl1271_free_hw(struct wl1271 *wl) } EXPORT_SYMBOL_GPL(wl1271_free_hw); +static int __devinit wl12xx_probe(struct platform_device *pdev) +{ + return 0; +} + +static int __devexit wl12xx_remove(struct platform_device *pdev) +{ + return 0; +} + +static const struct platform_device_id wl12xx_id_table[] __devinitconst = { + { "wl12xx-sdio", 0 }, + { "wl12xx-spi", 0 }, + { } /* Terminating Entry */ +}; +MODULE_DEVICE_TABLE(platform, wl12xx_id_table); + +static struct platform_driver wl12xx_driver = { + .probe = wl12xx_probe, + .remove = __devexit_p(wl12xx_remove), + .id_table = wl12xx_id_table, + .driver = { + .name = "wl12xx", + .owner = THIS_MODULE, + } +}; + +static int __init wl12xx_init(void) +{ + return platform_driver_register(&wl12xx_driver); +} +module_init(wl12xx_init); + +static void __exit wl12xx_exit(void) +{ + platform_driver_unregister(&wl12xx_driver); +} +module_exit(wl12xx_exit); + u32 wl12xx_debug_level = DEBUG_NONE; EXPORT_SYMBOL_GPL(wl12xx_debug_level); module_param_named(debug_level, wl12xx_debug_level, uint, S_IRUSR | S_IWUSR); -- cgit v1.2.3 From a390e85cfe91c346ff4745bcd45ad0a7e7101aa2 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 6 Oct 2011 10:07:44 +0300 Subject: wl12xx: move common init code from bus modules to main Move all common parts from sdio.c and spi.c to main.c, since they now can be handled as part of the platform driver. Signed-off-by: Felipe Balbi [forward-ported, cleaned-up and rephrased commit message] [added a bunch of fixes and a new pdata element] [moved some new code into main.c as well] Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/io.c | 11 +- drivers/net/wireless/wl12xx/io.h | 14 +- drivers/net/wireless/wl12xx/main.c | 110 ++++++++++++- drivers/net/wireless/wl12xx/sdio.c | 174 ++++----------------- drivers/net/wireless/wl12xx/spi.c | 161 +++---------------- drivers/net/wireless/wl12xx/wl12xx.h | 17 +- drivers/net/wireless/wl12xx/wl12xx_platform_data.c | 4 +- include/linux/wl12xx.h | 5 +- 8 files changed, 184 insertions(+), 312 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/io.c b/drivers/net/wireless/wl12xx/io.c index c2da66f45046..1a7df8a7ed2d 100644 --- a/drivers/net/wireless/wl12xx/io.c +++ b/drivers/net/wireless/wl12xx/io.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "wl12xx.h" #include "wl12xx_80211.h" @@ -46,7 +47,7 @@ bool wl1271_set_block_size(struct wl1271 *wl) { if (wl->if_ops->set_block_size) { - wl->if_ops->set_block_size(wl, WL12XX_BUS_BLOCK_SIZE); + wl->if_ops->set_block_size(wl->dev, WL12XX_BUS_BLOCK_SIZE); return true; } @@ -55,12 +56,12 @@ bool wl1271_set_block_size(struct wl1271 *wl) void wl1271_disable_interrupts(struct wl1271 *wl) { - wl->if_ops->disable_irq(wl); + disable_irq(wl->irq); } void wl1271_enable_interrupts(struct wl1271 *wl) { - wl->if_ops->enable_irq(wl); + enable_irq(wl->irq); } /* Set the SPI partitions to access the chip addresses @@ -128,13 +129,13 @@ EXPORT_SYMBOL_GPL(wl1271_set_partition); void wl1271_io_reset(struct wl1271 *wl) { if (wl->if_ops->reset) - wl->if_ops->reset(wl); + wl->if_ops->reset(wl->dev); } void wl1271_io_init(struct wl1271 *wl) { if (wl->if_ops->init) - wl->if_ops->init(wl); + wl->if_ops->init(wl->dev); } void wl1271_top_reg_write(struct wl1271 *wl, int addr, u16 val) diff --git a/drivers/net/wireless/wl12xx/io.h b/drivers/net/wireless/wl12xx/io.h index e839341dfafe..e82dad19aa30 100644 --- a/drivers/net/wireless/wl12xx/io.h +++ b/drivers/net/wireless/wl12xx/io.h @@ -51,23 +51,17 @@ void wl1271_enable_interrupts(struct wl1271 *wl); void wl1271_io_reset(struct wl1271 *wl); void wl1271_io_init(struct wl1271 *wl); -static inline struct device *wl1271_wl_to_dev(struct wl1271 *wl) -{ - return wl->if_ops->dev(wl); -} - - /* Raw target IO, address is not translated */ static inline void wl1271_raw_write(struct wl1271 *wl, int addr, void *buf, size_t len, bool fixed) { - wl->if_ops->write(wl, addr, buf, len, fixed); + wl->if_ops->write(wl->dev, addr, buf, len, fixed); } static inline void wl1271_raw_read(struct wl1271 *wl, int addr, void *buf, size_t len, bool fixed) { - wl->if_ops->read(wl, addr, buf, len, fixed); + wl->if_ops->read(wl->dev, addr, buf, len, fixed); } static inline u32 wl1271_raw_read32(struct wl1271 *wl, int addr) @@ -155,13 +149,13 @@ static inline void wl1271_write32(struct wl1271 *wl, int addr, u32 val) static inline void wl1271_power_off(struct wl1271 *wl) { - wl->if_ops->power(wl, false); + wl->if_ops->power(wl->dev, false); clear_bit(WL1271_FLAG_GPIO_POWER, &wl->flags); } static inline int wl1271_power_on(struct wl1271 *wl) { - int ret = wl->if_ops->power(wl, true); + int ret = wl->if_ops->power(wl->dev, true); if (ret == 0) set_bit(WL1271_FLAG_GPIO_POWER, &wl->flags); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 3262e8a6c475..1cf987785053 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "wl12xx.h" #include "wl12xx_80211.h" @@ -1067,7 +1068,7 @@ static int wl1271_fetch_firmware(struct wl1271 *wl) wl1271_debug(DEBUG_BOOT, "booting firmware %s", fw_name); - ret = request_firmware(&fw, fw_name, wl1271_wl_to_dev(wl)); + ret = request_firmware(&fw, fw_name, wl->dev); if (ret < 0) { wl1271_error("could not get firmware: %d", ret); @@ -1105,7 +1106,7 @@ static int wl1271_fetch_nvs(struct wl1271 *wl) const struct firmware *fw; int ret; - ret = request_firmware(&fw, WL12XX_NVS_NAME, wl1271_wl_to_dev(wl)); + ret = request_firmware(&fw, WL12XX_NVS_NAME, wl->dev); if (ret < 0) { wl1271_error("could not get nvs file: %d", ret); @@ -4979,7 +4980,7 @@ int wl1271_init_ieee80211(struct wl1271 *wl) wl->hw->wiphy->reg_notifier = wl1271_reg_notify; - SET_IEEE80211_DEV(wl->hw, wl1271_wl_to_dev(wl)); + SET_IEEE80211_DEV(wl->hw, wl->dev); wl->hw->sta_data_size = sizeof(struct wl1271_station); wl->hw->vif_data_size = sizeof(struct wl12xx_vif); @@ -5200,13 +5201,116 @@ int wl1271_free_hw(struct wl1271 *wl) } EXPORT_SYMBOL_GPL(wl1271_free_hw); +static irqreturn_t wl12xx_hardirq(int irq, void *cookie) +{ + struct wl1271 *wl = cookie; + unsigned long flags; + + wl1271_debug(DEBUG_IRQ, "IRQ"); + + /* complete the ELP completion */ + spin_lock_irqsave(&wl->wl_lock, flags); + set_bit(WL1271_FLAG_IRQ_RUNNING, &wl->flags); + if (wl->elp_compl) { + complete(wl->elp_compl); + wl->elp_compl = NULL; + } + + if (test_bit(WL1271_FLAG_SUSPENDED, &wl->flags)) { + /* don't enqueue a work right now. mark it as pending */ + set_bit(WL1271_FLAG_PENDING_WORK, &wl->flags); + wl1271_debug(DEBUG_IRQ, "should not enqueue work"); + disable_irq_nosync(wl->irq); + pm_wakeup_event(wl->dev, 0); + spin_unlock_irqrestore(&wl->wl_lock, flags); + return IRQ_HANDLED; + } + spin_unlock_irqrestore(&wl->wl_lock, flags); + + return IRQ_WAKE_THREAD; +} + static int __devinit wl12xx_probe(struct platform_device *pdev) { + struct wl12xx_platform_data *pdata = pdev->dev.platform_data; + struct ieee80211_hw *hw; + struct wl1271 *wl; + unsigned long irqflags; + int ret = -ENODEV; + + hw = wl1271_alloc_hw(); + if (IS_ERR(hw)) { + wl1271_error("can't allocate hw"); + ret = PTR_ERR(hw); + goto out; + } + + wl = hw->priv; + wl->irq = platform_get_irq(pdev, 0); + wl->ref_clock = pdata->board_ref_clock; + wl->tcxo_clock = pdata->board_tcxo_clock; + wl->platform_quirks = pdata->platform_quirks; + wl->set_power = pdata->set_power; + wl->dev = &pdev->dev; + wl->if_ops = pdata->ops; + + platform_set_drvdata(pdev, wl); + + if (wl->platform_quirks & WL12XX_PLATFORM_QUIRK_EDGE_IRQ) + irqflags = IRQF_TRIGGER_RISING; + else + irqflags = IRQF_TRIGGER_HIGH | IRQF_ONESHOT; + + ret = request_threaded_irq(wl->irq, wl12xx_hardirq, wl1271_irq, + irqflags, + pdev->name, wl); + if (ret < 0) { + wl1271_error("request_irq() failed: %d", ret); + goto out_free_hw; + } + + ret = enable_irq_wake(wl->irq); + if (!ret) { + wl->irq_wake_enabled = true; + device_init_wakeup(wl->dev, 1); + if (pdata->pwr_in_suspend) + hw->wiphy->wowlan.flags = WIPHY_WOWLAN_ANY; + + } + disable_irq(wl->irq); + + ret = wl1271_init_ieee80211(wl); + if (ret) + goto out_irq; + + ret = wl1271_register_hw(wl); + if (ret) + goto out_irq; + return 0; + +out_irq: + free_irq(wl->irq, wl); + +out_free_hw: + wl1271_free_hw(wl); + +out: + return ret; } static int __devexit wl12xx_remove(struct platform_device *pdev) { + struct wl1271 *wl = platform_get_drvdata(pdev); + + if (wl->irq_wake_enabled) { + device_init_wakeup(wl->dev, 0); + disable_irq_wake(wl->irq); + } + wl1271_unregister_hw(wl); + free_irq(wl->irq, wl); + wl1271_free_hw(wl); + return 0; } diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c index e7ee5d155d34..78e5352c4037 100644 --- a/drivers/net/wireless/wl12xx/sdio.c +++ b/drivers/net/wireless/wl12xx/sdio.c @@ -47,7 +47,6 @@ struct wl12xx_sdio_glue { struct device *dev; - struct wl1271 *wl; struct platform_device *core; }; @@ -57,67 +56,22 @@ static const struct sdio_device_id wl1271_devices[] __devinitconst = { }; MODULE_DEVICE_TABLE(sdio, wl1271_devices); -static void wl1271_sdio_set_block_size(struct wl1271 *wl, unsigned int blksz) +static void wl1271_sdio_set_block_size(struct device *child, + unsigned int blksz) { - sdio_claim_host(wl->if_priv); - sdio_set_block_size(wl->if_priv, blksz); - sdio_release_host(wl->if_priv); -} - -static inline struct wl12xx_sdio_glue *wl_to_glue(struct wl1271 *wl) -{ - return wl->if_priv; -} - -static struct device *wl1271_sdio_wl_to_dev(struct wl1271 *wl) -{ - return wl_to_glue(wl)->dev; -} - -static irqreturn_t wl1271_hardirq(int irq, void *cookie) -{ - struct wl1271 *wl = cookie; - unsigned long flags; - - wl1271_debug(DEBUG_IRQ, "IRQ"); - - /* complete the ELP completion */ - spin_lock_irqsave(&wl->wl_lock, flags); - set_bit(WL1271_FLAG_IRQ_RUNNING, &wl->flags); - if (wl->elp_compl) { - complete(wl->elp_compl); - wl->elp_compl = NULL; - } - - if (test_bit(WL1271_FLAG_SUSPENDED, &wl->flags)) { - /* don't enqueue a work right now. mark it as pending */ - set_bit(WL1271_FLAG_PENDING_WORK, &wl->flags); - wl1271_debug(DEBUG_IRQ, "should not enqueue work"); - disable_irq_nosync(wl->irq); - pm_wakeup_event(wl1271_sdio_wl_to_dev(wl), 0); - spin_unlock_irqrestore(&wl->wl_lock, flags); - return IRQ_HANDLED; - } - spin_unlock_irqrestore(&wl->wl_lock, flags); - - return IRQ_WAKE_THREAD; -} - -static void wl1271_sdio_disable_interrupts(struct wl1271 *wl) -{ - disable_irq(wl->irq); -} + struct wl12xx_sdio_glue *glue = dev_get_drvdata(child->parent); + struct sdio_func *func = dev_to_sdio_func(glue->dev); -static void wl1271_sdio_enable_interrupts(struct wl1271 *wl) -{ - enable_irq(wl->irq); + sdio_claim_host(func); + sdio_set_block_size(func, blksz); + sdio_release_host(func); } -static void wl1271_sdio_raw_read(struct wl1271 *wl, int addr, void *buf, +static void wl12xx_sdio_raw_read(struct device *child, int addr, void *buf, size_t len, bool fixed) { int ret; - struct wl12xx_sdio_glue *glue = wl_to_glue(wl); + struct wl12xx_sdio_glue *glue = dev_get_drvdata(child->parent); struct sdio_func *func = dev_to_sdio_func(glue->dev); if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) { @@ -139,11 +93,11 @@ static void wl1271_sdio_raw_read(struct wl1271 *wl, int addr, void *buf, wl1271_error("sdio read failed (%d)", ret); } -static void wl1271_sdio_raw_write(struct wl1271 *wl, int addr, void *buf, +static void wl12xx_sdio_raw_write(struct device *child, int addr, void *buf, size_t len, bool fixed) { int ret; - struct wl12xx_sdio_glue *glue = wl_to_glue(wl); + struct wl12xx_sdio_glue *glue = dev_get_drvdata(child->parent); struct sdio_func *func = dev_to_sdio_func(glue->dev); if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) { @@ -165,10 +119,9 @@ static void wl1271_sdio_raw_write(struct wl1271 *wl, int addr, void *buf, wl1271_error("sdio write failed (%d)", ret); } -static int wl1271_sdio_power_on(struct wl1271 *wl) +static int wl12xx_sdio_power_on(struct wl12xx_sdio_glue *glue) { int ret; - struct wl12xx_sdio_glue *glue = wl_to_glue(wl); struct sdio_func *func = dev_to_sdio_func(glue->dev); /* If enabled, tell runtime PM not to power off the card */ @@ -190,10 +143,9 @@ out: return ret; } -static int wl1271_sdio_power_off(struct wl1271 *wl) +static int wl12xx_sdio_power_off(struct wl12xx_sdio_glue *glue) { int ret; - struct wl12xx_sdio_glue *glue = wl_to_glue(wl); struct sdio_func *func = dev_to_sdio_func(glue->dev); sdio_disable_func(func); @@ -211,33 +163,29 @@ static int wl1271_sdio_power_off(struct wl1271 *wl) return ret; } -static int wl1271_sdio_set_power(struct wl1271 *wl, bool enable) +static int wl12xx_sdio_set_power(struct device *child, bool enable) { + struct wl12xx_sdio_glue *glue = dev_get_drvdata(child->parent); + if (enable) - return wl1271_sdio_power_on(wl); + return wl12xx_sdio_power_on(glue); else - return wl1271_sdio_power_off(wl); + return wl12xx_sdio_power_off(glue); } static struct wl1271_if_operations sdio_ops = { - .read = wl1271_sdio_raw_read, - .write = wl1271_sdio_raw_write, - .power = wl1271_sdio_set_power, - .dev = wl1271_sdio_wl_to_dev, - .enable_irq = wl1271_sdio_enable_interrupts, - .disable_irq = wl1271_sdio_disable_interrupts, + .read = wl12xx_sdio_raw_read, + .write = wl12xx_sdio_raw_write, + .power = wl12xx_sdio_set_power, .set_block_size = wl1271_sdio_set_block_size, }; static int __devinit wl1271_probe(struct sdio_func *func, const struct sdio_device_id *id) { - struct ieee80211_hw *hw; - const struct wl12xx_platform_data *wlan_data; - struct wl1271 *wl; + struct wl12xx_platform_data *wlan_data; struct wl12xx_sdio_glue *glue; struct resource res[1]; - unsigned long irqflags; mmc_pm_flag_t mmcflags; int ret = -ENOMEM; @@ -251,20 +199,7 @@ static int __devinit wl1271_probe(struct sdio_func *func, goto out; } - hw = wl1271_alloc_hw(); - if (IS_ERR(hw)) { - wl1271_error("can't allocate hw"); - ret = PTR_ERR(hw); - goto out_free_glue; - } - - wl = hw->priv; - glue->dev = &func->dev; - glue->wl = wl; - - wl->if_priv = glue; - wl->if_ops = &sdio_ops; /* Grab access to FN0 for ELP reg. */ func->card->quirks |= MMC_QUIRK_LENIENT_FN0; @@ -276,48 +211,17 @@ static int __devinit wl1271_probe(struct sdio_func *func, if (IS_ERR(wlan_data)) { ret = PTR_ERR(wlan_data); wl1271_error("missing wlan platform data: %d", ret); - goto out_free_hw; - } - - wl->irq = wlan_data->irq; - wl->ref_clock = wlan_data->board_ref_clock; - wl->tcxo_clock = wlan_data->board_tcxo_clock; - wl->platform_quirks = wlan_data->platform_quirks; - - if (wl->platform_quirks & WL12XX_PLATFORM_QUIRK_EDGE_IRQ) - irqflags = IRQF_TRIGGER_RISING; - else - irqflags = IRQF_TRIGGER_HIGH | IRQF_ONESHOT; - - ret = request_threaded_irq(wl->irq, wl1271_hardirq, wl1271_irq, - irqflags, - DRIVER_NAME, wl); - if (ret < 0) { - wl1271_error("request_irq() failed: %d", ret); - goto out_free_hw; + goto out_free_glue; } - ret = enable_irq_wake(wl->irq); - if (!ret) { - wl->irq_wake_enabled = true; - device_init_wakeup(wl1271_sdio_wl_to_dev(wl), 1); + /* if sdio can keep power while host is suspended, enable wow */ + mmcflags = sdio_get_host_pm_caps(func); + wl1271_debug(DEBUG_SDIO, "sdio PM caps = 0x%x", mmcflags); - /* if sdio can keep power while host is suspended, enable wow */ - mmcflags = sdio_get_host_pm_caps(func); - wl1271_debug(DEBUG_SDIO, "sdio PM caps = 0x%x", mmcflags); + if (mmcflags & MMC_PM_KEEP_POWER) + wlan_data->pwr_in_suspend = true; - if (mmcflags & MMC_PM_KEEP_POWER) - hw->wiphy->wowlan.flags = WIPHY_WOWLAN_ANY; - } - disable_irq(wl->irq); - - ret = wl1271_init_ieee80211(wl); - if (ret) - goto out_irq; - - ret = wl1271_register_hw(wl); - if (ret) - goto out_irq; + wlan_data->ops = &sdio_ops; sdio_set_drvdata(func, glue); @@ -328,7 +232,7 @@ static int __devinit wl1271_probe(struct sdio_func *func, if (!glue->core) { wl1271_error("can't allocate platform_device"); ret = -ENOMEM; - goto out_unreg_hw; + goto out_free_glue; } glue->core->dev.parent = &func->dev; @@ -362,17 +266,9 @@ static int __devinit wl1271_probe(struct sdio_func *func, out_dev_put: platform_device_put(glue->core); -out_unreg_hw: - wl1271_unregister_hw(wl); - -out_irq: - free_irq(wl->irq, wl); - -out_free_hw: - wl1271_free_hw(wl); - out_free_glue: kfree(glue); + out: return ret; } @@ -380,18 +276,10 @@ out: static void __devexit wl1271_remove(struct sdio_func *func) { struct wl12xx_sdio_glue *glue = sdio_get_drvdata(func); - struct wl1271 *wl = glue->wl; /* Undo decrement done above in wl1271_probe */ pm_runtime_get_noresume(&func->dev); - wl1271_unregister_hw(wl); - if (wl->irq_wake_enabled) { - device_init_wakeup(wl1271_sdio_wl_to_dev(wl), 0); - disable_irq_wake(wl->irq); - } - free_irq(wl->irq, wl); - wl1271_free_hw(wl); platform_device_del(glue->core); platform_device_put(glue->core); kfree(glue); diff --git a/drivers/net/wireless/wl12xx/spi.c b/drivers/net/wireless/wl12xx/spi.c index 2dd659886a04..22c1337ba883 100644 --- a/drivers/net/wireless/wl12xx/spi.c +++ b/drivers/net/wireless/wl12xx/spi.c @@ -72,33 +72,12 @@ struct wl12xx_spi_glue { struct device *dev; - struct wl1271 *wl; struct platform_device *core; }; -static inline struct wl12xx_spi_glue *wl_to_glue(struct wl1271 *wl) +static void wl12xx_spi_reset(struct device *child) { - return wl->if_priv; -} - -static struct device *wl1271_spi_wl_to_dev(struct wl1271 *wl) -{ - return wl_to_glue(wl)->dev; -} - -static void wl1271_spi_disable_interrupts(struct wl1271 *wl) -{ - disable_irq(wl->irq); -} - -static void wl1271_spi_enable_interrupts(struct wl1271 *wl) -{ - enable_irq(wl->irq); -} - -static void wl1271_spi_reset(struct wl1271 *wl) -{ - struct wl12xx_spi_glue *glue = wl_to_glue(wl); + struct wl12xx_spi_glue *glue = dev_get_drvdata(child->parent); u8 *cmd; struct spi_transfer t; struct spi_message m; @@ -124,9 +103,9 @@ static void wl1271_spi_reset(struct wl1271 *wl) kfree(cmd); } -static void wl1271_spi_init(struct wl1271 *wl) +static void wl12xx_spi_init(struct device *child) { - struct wl12xx_spi_glue *glue = wl_to_glue(wl); + struct wl12xx_spi_glue *glue = dev_get_drvdata(child->parent); u8 crc[WSPI_INIT_CMD_CRC_LEN], *cmd; struct spi_transfer t; struct spi_message m; @@ -181,9 +160,10 @@ static void wl1271_spi_init(struct wl1271 *wl) #define WL1271_BUSY_WORD_TIMEOUT 1000 -static int wl1271_spi_read_busy(struct wl1271 *wl) +static int wl12xx_spi_read_busy(struct device *child) { - struct wl12xx_spi_glue *glue = wl_to_glue(wl); + struct wl12xx_spi_glue *glue = dev_get_drvdata(child->parent); + struct wl1271 *wl = dev_get_drvdata(child); struct spi_transfer t[1]; struct spi_message m; u32 *busy_buf; @@ -215,10 +195,11 @@ static int wl1271_spi_read_busy(struct wl1271 *wl) return -ETIMEDOUT; } -static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf, +static void wl12xx_spi_raw_read(struct device *child, int addr, void *buf, size_t len, bool fixed) { - struct wl12xx_spi_glue *glue = wl_to_glue(wl); + struct wl12xx_spi_glue *glue = dev_get_drvdata(child->parent); + struct wl1271 *wl = dev_get_drvdata(child); struct spi_transfer t[2]; struct spi_message m; u32 *busy_buf; @@ -257,7 +238,7 @@ static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf, spi_sync(to_spi_device(glue->dev), &m); if (!(busy_buf[WL1271_BUSY_WORD_CNT - 1] & 0x1) && - wl1271_spi_read_busy(wl)) { + wl12xx_spi_read_busy(child)) { memset(buf, 0, chunk_len); return; } @@ -282,10 +263,10 @@ static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf, } } -static void wl1271_spi_raw_write(struct wl1271 *wl, int addr, void *buf, - size_t len, bool fixed) +static void wl12xx_spi_raw_write(struct device *child, int addr, void *buf, + size_t len, bool fixed) { - struct wl12xx_spi_glue *glue = wl_to_glue(wl); + struct wl12xx_spi_glue *glue = dev_get_drvdata(child->parent); struct spi_transfer t[2 * WSPI_MAX_NUM_OF_CHUNKS]; struct spi_message m; u32 commands[WSPI_MAX_NUM_OF_CHUNKS]; @@ -333,42 +314,11 @@ static void wl1271_spi_raw_write(struct wl1271 *wl, int addr, void *buf, spi_sync(to_spi_device(glue->dev), &m); } -static irqreturn_t wl1271_hardirq(int irq, void *cookie) -{ - struct wl1271 *wl = cookie; - unsigned long flags; - - wl1271_debug(DEBUG_IRQ, "IRQ"); - - /* complete the ELP completion */ - spin_lock_irqsave(&wl->wl_lock, flags); - set_bit(WL1271_FLAG_IRQ_RUNNING, &wl->flags); - if (wl->elp_compl) { - complete(wl->elp_compl); - wl->elp_compl = NULL; - } - spin_unlock_irqrestore(&wl->wl_lock, flags); - - return IRQ_WAKE_THREAD; -} - -static int wl1271_spi_set_power(struct wl1271 *wl, bool enable) -{ - if (wl->set_power) - wl->set_power(enable); - - return 0; -} - static struct wl1271_if_operations spi_ops = { - .read = wl1271_spi_raw_read, - .write = wl1271_spi_raw_write, - .reset = wl1271_spi_reset, - .init = wl1271_spi_init, - .power = wl1271_spi_set_power, - .dev = wl1271_spi_wl_to_dev, - .enable_irq = wl1271_spi_enable_interrupts, - .disable_irq = wl1271_spi_disable_interrupts, + .read = wl12xx_spi_raw_read, + .write = wl12xx_spi_raw_write, + .reset = wl12xx_spi_reset, + .init = wl12xx_spi_init, .set_block_size = NULL, }; @@ -376,10 +326,7 @@ static int __devinit wl1271_probe(struct spi_device *spi) { struct wl12xx_spi_glue *glue; struct wl12xx_platform_data *pdata; - struct ieee80211_hw *hw; - struct wl1271 *wl; struct resource res[1]; - unsigned long irqflags; int ret = -ENOMEM; pdata = spi->dev.platform_data; @@ -388,27 +335,17 @@ static int __devinit wl1271_probe(struct spi_device *spi) return -ENODEV; } + pdata->ops = &spi_ops; + glue = kzalloc(sizeof(*glue), GFP_KERNEL); if (!glue) { wl1271_error("can't allocate glue"); goto out; } - hw = wl1271_alloc_hw(); - if (IS_ERR(hw)) { - ret = PTR_ERR(hw); - goto out_free_glue; - } - - wl = hw->priv; - glue->dev = &spi->dev; - glue->wl = wl; spi_set_drvdata(spi, glue); - wl->if_priv = glue; - - wl->if_ops = &spi_ops; /* This is the only SPI value that we need to set here, the rest * comes from the board-peripherals file */ @@ -417,55 +354,14 @@ static int __devinit wl1271_probe(struct spi_device *spi) ret = spi_setup(spi); if (ret < 0) { wl1271_error("spi_setup failed"); - goto out_free_hw; - } - - wl->set_power = pdata->set_power; - if (!wl->set_power) { - wl1271_error("set power function missing in platform data"); - ret = -ENODEV; - goto out_free_hw; - } - - wl->ref_clock = pdata->board_ref_clock; - wl->tcxo_clock = pdata->board_tcxo_clock; - wl->platform_quirks = pdata->platform_quirks; - - if (wl->platform_quirks & WL12XX_PLATFORM_QUIRK_EDGE_IRQ) - irqflags = IRQF_TRIGGER_RISING; - else - irqflags = IRQF_TRIGGER_HIGH | IRQF_ONESHOT; - - wl->irq = spi->irq; - if (wl->irq < 0) { - wl1271_error("irq missing in platform data"); - ret = -ENODEV; - goto out_free_hw; - } - - ret = request_threaded_irq(wl->irq, wl1271_hardirq, wl1271_irq, - irqflags, - DRIVER_NAME, wl); - if (ret < 0) { - wl1271_error("request_irq() failed: %d", ret); - goto out_free_hw; + goto out_free_glue; } - disable_irq(wl->irq); - - ret = wl1271_init_ieee80211(wl); - if (ret) - goto out_irq; - - ret = wl1271_register_hw(wl); - if (ret) - goto out_irq; - glue->core = platform_device_alloc("wl12xx-spi", -1); if (!glue->core) { wl1271_error("can't allocate platform_device"); ret = -ENOMEM; - goto out_unreg_hw; + goto out_free_glue; } glue->core->dev.parent = &spi->dev; @@ -499,15 +395,6 @@ static int __devinit wl1271_probe(struct spi_device *spi) out_dev_put: platform_device_put(glue->core); -out_unreg_hw: - wl1271_unregister_hw(wl); - -out_irq: - free_irq(wl->irq, wl); - -out_free_hw: - wl1271_free_hw(wl); - out_free_glue: kfree(glue); out: @@ -517,11 +404,7 @@ out: static int __devexit wl1271_remove(struct spi_device *spi) { struct wl12xx_spi_glue *glue = spi_get_drvdata(spi); - struct wl1271 *wl = glue->wl; - wl1271_unregister_hw(wl); - free_irq(wl->irq, wl); - wl1271_free_hw(wl); platform_device_del(glue->core); platform_device_put(glue->core); kfree(glue); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 8815fd9a0f47..d2028939eee5 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -288,17 +288,14 @@ struct wl1271_scan { }; struct wl1271_if_operations { - void (*read)(struct wl1271 *wl, int addr, void *buf, size_t len, + void (*read)(struct device *child, int addr, void *buf, size_t len, bool fixed); - void (*write)(struct wl1271 *wl, int addr, void *buf, size_t len, + void (*write)(struct device *child, int addr, void *buf, size_t len, bool fixed); - void (*reset)(struct wl1271 *wl); - void (*init)(struct wl1271 *wl); - int (*power)(struct wl1271 *wl, bool enable); - struct device* (*dev)(struct wl1271 *wl); - void (*enable_irq)(struct wl1271 *wl); - void (*disable_irq)(struct wl1271 *wl); - void (*set_block_size) (struct wl1271 *wl, unsigned int blksz); + void (*reset)(struct device *child); + void (*init)(struct device *child); + int (*power)(struct device *child, bool enable); + void (*set_block_size) (struct device *child, unsigned int blksz); }; #define MAX_NUM_KEYS 14 @@ -362,6 +359,8 @@ struct wl1271 { struct ieee80211_hw *hw; bool mac80211_registered; + struct device *dev; + void *if_priv; struct wl1271_if_operations *if_ops; diff --git a/drivers/net/wireless/wl12xx/wl12xx_platform_data.c b/drivers/net/wireless/wl12xx/wl12xx_platform_data.c index 973b11060a8f..3c96b332184e 100644 --- a/drivers/net/wireless/wl12xx/wl12xx_platform_data.c +++ b/drivers/net/wireless/wl12xx/wl12xx_platform_data.c @@ -2,7 +2,7 @@ #include #include -static const struct wl12xx_platform_data *platform_data; +static struct wl12xx_platform_data *platform_data; int __init wl12xx_set_platform_data(const struct wl12xx_platform_data *data) { @@ -18,7 +18,7 @@ int __init wl12xx_set_platform_data(const struct wl12xx_platform_data *data) return 0; } -const struct wl12xx_platform_data *wl12xx_get_platform_data(void) +struct wl12xx_platform_data *wl12xx_get_platform_data(void) { if (!platform_data) return ERR_PTR(-ENODEV); diff --git a/include/linux/wl12xx.h b/include/linux/wl12xx.h index 4b697395326e..0d6373195d32 100644 --- a/include/linux/wl12xx.h +++ b/include/linux/wl12xx.h @@ -54,6 +54,9 @@ struct wl12xx_platform_data { int board_ref_clock; int board_tcxo_clock; unsigned long platform_quirks; + bool pwr_in_suspend; + + struct wl1271_if_operations *ops; }; /* Platform does not support level trigger interrupts */ @@ -73,6 +76,6 @@ int wl12xx_set_platform_data(const struct wl12xx_platform_data *data) #endif -const struct wl12xx_platform_data *wl12xx_get_platform_data(void); +struct wl12xx_platform_data *wl12xx_get_platform_data(void); #endif -- cgit v1.2.3 From 4b32a2c9a636eaab69c797d9ebc7e086a6bd2fb7 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 6 Oct 2011 10:46:20 +0300 Subject: wl12xx: mark some symbols static after re-factoring a bunch of symbols are only used inside main.c which allows us to mark them as static. Signed-off-by: Felipe Balbi [forward-ported] Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/io.h | 9 ++------- drivers/net/wireless/wl12xx/main.c | 18 ++++++------------ 2 files changed, 8 insertions(+), 19 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/io.h b/drivers/net/wireless/wl12xx/io.h index e82dad19aa30..d398cbcea986 100644 --- a/drivers/net/wireless/wl12xx/io.h +++ b/drivers/net/wireless/wl12xx/io.h @@ -170,15 +170,10 @@ u16 wl1271_top_reg_read(struct wl1271 *wl, int addr); int wl1271_set_partition(struct wl1271 *wl, struct wl1271_partition_set *p); +bool wl1271_set_block_size(struct wl1271 *wl); + /* Functions from wl1271_main.c */ -int wl1271_register_hw(struct wl1271 *wl); -void wl1271_unregister_hw(struct wl1271 *wl); -int wl1271_init_ieee80211(struct wl1271 *wl); -struct ieee80211_hw *wl1271_alloc_hw(void); -int wl1271_free_hw(struct wl1271 *wl); -irqreturn_t wl1271_irq(int irq, void *data); -bool wl1271_set_block_size(struct wl1271 *wl); int wl1271_tx_dummy_packet(struct wl1271 *wl); #endif diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 1cf987785053..56927051f665 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -931,7 +931,7 @@ static void wl1271_netstack_work(struct work_struct *work) #define WL1271_IRQ_MAX_LOOPS 256 -irqreturn_t wl1271_irq(int irq, void *cookie) +static irqreturn_t wl1271_irq(int irq, void *cookie) { int ret; u32 intr; @@ -1053,7 +1053,6 @@ out: return IRQ_HANDLED; } -EXPORT_SYMBOL_GPL(wl1271_irq); static int wl1271_fetch_firmware(struct wl1271 *wl) { @@ -4848,7 +4847,7 @@ static struct bin_attribute fwlog_attr = { .read = wl1271_sysfs_read_fwlog, }; -int wl1271_register_hw(struct wl1271 *wl) +static int wl1271_register_hw(struct wl1271 *wl) { int ret; @@ -4889,9 +4888,8 @@ int wl1271_register_hw(struct wl1271 *wl) return 0; } -EXPORT_SYMBOL_GPL(wl1271_register_hw); -void wl1271_unregister_hw(struct wl1271 *wl) +static void wl1271_unregister_hw(struct wl1271 *wl) { if (wl->state == WL1271_STATE_PLT) __wl1271_plt_stop(wl); @@ -4901,9 +4899,8 @@ void wl1271_unregister_hw(struct wl1271 *wl) wl->mac80211_registered = false; } -EXPORT_SYMBOL_GPL(wl1271_unregister_hw); -int wl1271_init_ieee80211(struct wl1271 *wl) +static int wl1271_init_ieee80211(struct wl1271 *wl) { static const u32 cipher_suites[] = { WLAN_CIPHER_SUITE_WEP40, @@ -4989,11 +4986,10 @@ int wl1271_init_ieee80211(struct wl1271 *wl) return 0; } -EXPORT_SYMBOL_GPL(wl1271_init_ieee80211); #define WL1271_DEFAULT_CHANNEL 0 -struct ieee80211_hw *wl1271_alloc_hw(void) +static struct ieee80211_hw *wl1271_alloc_hw(void) { struct ieee80211_hw *hw; struct platform_device *plat_dev = NULL; @@ -5162,9 +5158,8 @@ err_hw_alloc: return ERR_PTR(ret); } -EXPORT_SYMBOL_GPL(wl1271_alloc_hw); -int wl1271_free_hw(struct wl1271 *wl) +static int wl1271_free_hw(struct wl1271 *wl) { /* Unblock any fwlog readers */ mutex_lock(&wl->mutex); @@ -5199,7 +5194,6 @@ int wl1271_free_hw(struct wl1271 *wl) return 0; } -EXPORT_SYMBOL_GPL(wl1271_free_hw); static irqreturn_t wl12xx_hardirq(int irq, void *cookie) { -- cgit v1.2.3 From f79f890c9ccd8d10f7e5e2f7c590b0c2e854bfb6 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Thu, 6 Oct 2011 13:05:25 +0300 Subject: wl12xx: drop unneeded plat_dev now that useless plat_dev is unnecessary, we can remove it. Signed-off-by: Felipe Balbi [forward ported and fixed sysfs file creation] Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 104 ++++++++++------------------------- drivers/net/wireless/wl12xx/wl12xx.h | 1 - 2 files changed, 30 insertions(+), 75 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 56927051f665..c72f7497db09 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -383,22 +383,6 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, static void wl1271_op_stop(struct ieee80211_hw *hw); static void wl1271_free_ap_keys(struct wl1271 *wl, struct wl12xx_vif *wlvif); - -static void wl1271_device_release(struct device *dev) -{ - -} - -static struct platform_device wl1271_device = { - .name = "wl1271", - .id = -1, - - /* device model insists to have a release function */ - .dev = { - .release = wl1271_device_release, - }, -}; - static DEFINE_MUTEX(wl_list_mutex); static LIST_HEAD(wl_list); @@ -4992,7 +4976,6 @@ static int wl1271_init_ieee80211(struct wl1271 *wl) static struct ieee80211_hw *wl1271_alloc_hw(void) { struct ieee80211_hw *hw; - struct platform_device *plat_dev = NULL; struct wl1271 *wl; int i, j, ret; unsigned int order; @@ -5006,13 +4989,6 @@ static struct ieee80211_hw *wl1271_alloc_hw(void) goto err_hw_alloc; } - plat_dev = kmemdup(&wl1271_device, sizeof(wl1271_device), GFP_KERNEL); - if (!plat_dev) { - wl1271_error("could not allocate platform_device"); - ret = -ENOMEM; - goto err_plat_alloc; - } - wl = hw->priv; memset(wl, 0, sizeof(*wl)); @@ -5020,7 +4996,6 @@ static struct ieee80211_hw *wl1271_alloc_hw(void) INIT_LIST_HEAD(&wl->wlvif_list); wl->hw = hw; - wl->plat_dev = plat_dev; for (i = 0; i < NUM_TX_QUEUES; i++) for (j = 0; j < WL12XX_MAX_LINKS; j++) @@ -5095,49 +5070,8 @@ static struct ieee80211_hw *wl1271_alloc_hw(void) goto err_dummy_packet; } - /* Register platform device */ - ret = platform_device_register(wl->plat_dev); - if (ret) { - wl1271_error("couldn't register platform device"); - goto err_fwlog; - } - dev_set_drvdata(&wl->plat_dev->dev, wl); - - /* Create sysfs file to control bt coex state */ - ret = device_create_file(&wl->plat_dev->dev, &dev_attr_bt_coex_state); - if (ret < 0) { - wl1271_error("failed to create sysfs file bt_coex_state"); - goto err_platform; - } - - /* Create sysfs file to get HW PG version */ - ret = device_create_file(&wl->plat_dev->dev, &dev_attr_hw_pg_ver); - if (ret < 0) { - wl1271_error("failed to create sysfs file hw_pg_ver"); - goto err_bt_coex_state; - } - - /* Create sysfs file for the FW log */ - ret = device_create_bin_file(&wl->plat_dev->dev, &fwlog_attr); - if (ret < 0) { - wl1271_error("failed to create sysfs file fwlog"); - goto err_hw_pg_ver; - } - return hw; -err_hw_pg_ver: - device_remove_file(&wl->plat_dev->dev, &dev_attr_hw_pg_ver); - -err_bt_coex_state: - device_remove_file(&wl->plat_dev->dev, &dev_attr_bt_coex_state); - -err_platform: - platform_device_unregister(wl->plat_dev); - -err_fwlog: - free_page((unsigned long)wl->fwlog); - err_dummy_packet: dev_kfree_skb(wl->dummy_packet); @@ -5149,9 +5083,6 @@ err_wq: err_hw: wl1271_debugfs_exit(wl); - kfree(plat_dev); - -err_plat_alloc: ieee80211_free_hw(hw); err_hw_alloc: @@ -5167,17 +5098,15 @@ static int wl1271_free_hw(struct wl1271 *wl) wake_up_interruptible_all(&wl->fwlog_waitq); mutex_unlock(&wl->mutex); - device_remove_bin_file(&wl->plat_dev->dev, &fwlog_attr); + device_remove_bin_file(wl->dev, &fwlog_attr); - device_remove_file(&wl->plat_dev->dev, &dev_attr_hw_pg_ver); + device_remove_file(wl->dev, &dev_attr_hw_pg_ver); - device_remove_file(&wl->plat_dev->dev, &dev_attr_bt_coex_state); - platform_device_unregister(wl->plat_dev); + device_remove_file(wl->dev, &dev_attr_bt_coex_state); free_page((unsigned long)wl->fwlog); dev_kfree_skb(wl->dummy_packet); free_pages((unsigned long)wl->aggr_buf, get_order(WL1271_AGGR_BUFFER_SIZE)); - kfree(wl->plat_dev); wl1271_debugfs_exit(wl); @@ -5281,8 +5210,35 @@ static int __devinit wl12xx_probe(struct platform_device *pdev) if (ret) goto out_irq; + /* Create sysfs file to control bt coex state */ + ret = device_create_file(wl->dev, &dev_attr_bt_coex_state); + if (ret < 0) { + wl1271_error("failed to create sysfs file bt_coex_state"); + goto out_irq; + } + + /* Create sysfs file to get HW PG version */ + ret = device_create_file(wl->dev, &dev_attr_hw_pg_ver); + if (ret < 0) { + wl1271_error("failed to create sysfs file hw_pg_ver"); + goto out_bt_coex_state; + } + + /* Create sysfs file for the FW log */ + ret = device_create_bin_file(wl->dev, &fwlog_attr); + if (ret < 0) { + wl1271_error("failed to create sysfs file fwlog"); + goto out_hw_pg_ver; + } + return 0; +out_hw_pg_ver: + device_remove_file(wl->dev, &dev_attr_hw_pg_ver); + +out_bt_coex_state: + device_remove_file(wl->dev, &dev_attr_bt_coex_state); + out_irq: free_irq(wl->irq, wl); diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index d2028939eee5..158714a1092f 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -355,7 +355,6 @@ struct wl1271_link { }; struct wl1271 { - struct platform_device *plat_dev; struct ieee80211_hw *hw; bool mac80211_registered; -- cgit v1.2.3 From 0f4e31222a2c0b93f25a87effd2033cb78c7a79c Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Fri, 7 Oct 2011 11:02:42 +0300 Subject: wl12xx: move debugging definitions to a separate file Separate the debugging macros and other definitions to a new debug.h file. This is be needed because the sdio and spi modules don't need to depend on the wl12xx module anymore, but still need to include wl12xx.h. Currently they do depend on it, because of the debugging global that wl12xx exports. A future patch will remove this dependency. Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/acx.c | 1 + drivers/net/wireless/wl12xx/boot.c | 1 + drivers/net/wireless/wl12xx/cmd.c | 1 + drivers/net/wireless/wl12xx/debug.h | 101 +++++++++++++++++++++++++++++++++ drivers/net/wireless/wl12xx/debugfs.c | 1 + drivers/net/wireless/wl12xx/event.c | 1 + drivers/net/wireless/wl12xx/init.c | 1 + drivers/net/wireless/wl12xx/io.c | 1 + drivers/net/wireless/wl12xx/main.c | 1 + drivers/net/wireless/wl12xx/ps.c | 1 + drivers/net/wireless/wl12xx/rx.c | 1 + drivers/net/wireless/wl12xx/scan.c | 1 + drivers/net/wireless/wl12xx/sdio.c | 1 + drivers/net/wireless/wl12xx/spi.c | 1 + drivers/net/wireless/wl12xx/testmode.c | 1 + drivers/net/wireless/wl12xx/tx.c | 1 + drivers/net/wireless/wl12xx/wl12xx.h | 70 ----------------------- 17 files changed, 116 insertions(+), 70 deletions(-) create mode 100644 drivers/net/wireless/wl12xx/debug.h (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/acx.c b/drivers/net/wireless/wl12xx/acx.c index e2e46705059d..bde1d862bdd5 100644 --- a/drivers/net/wireless/wl12xx/acx.c +++ b/drivers/net/wireless/wl12xx/acx.c @@ -29,6 +29,7 @@ #include #include "wl12xx.h" +#include "debug.h" #include "wl12xx_80211.h" #include "reg.h" #include "ps.h" diff --git a/drivers/net/wireless/wl12xx/boot.c b/drivers/net/wireless/wl12xx/boot.c index d4e628db76b0..4ce634b925cb 100644 --- a/drivers/net/wireless/wl12xx/boot.c +++ b/drivers/net/wireless/wl12xx/boot.c @@ -24,6 +24,7 @@ #include #include +#include "debug.h" #include "acx.h" #include "reg.h" #include "boot.h" diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 65bf9526576d..2413c43d0894 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -29,6 +29,7 @@ #include #include "wl12xx.h" +#include "debug.h" #include "reg.h" #include "io.h" #include "acx.h" diff --git a/drivers/net/wireless/wl12xx/debug.h b/drivers/net/wireless/wl12xx/debug.h new file mode 100644 index 000000000000..b85fd8c41e8f --- /dev/null +++ b/drivers/net/wireless/wl12xx/debug.h @@ -0,0 +1,101 @@ +/* + * This file is part of wl12xx + * + * Copyright (C) 2011 Texas Instruments. All rights reserved. + * Copyright (C) 2008-2009 Nokia Corporation + * + * Contact: Luciano Coelho + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + * + */ + +#ifndef __DEBUG_H__ +#define __DEBUG_H__ + +#include +#include + +#define DRIVER_NAME "wl12xx" +#define DRIVER_PREFIX DRIVER_NAME ": " + +enum { + DEBUG_NONE = 0, + DEBUG_IRQ = BIT(0), + DEBUG_SPI = BIT(1), + DEBUG_BOOT = BIT(2), + DEBUG_MAILBOX = BIT(3), + DEBUG_TESTMODE = BIT(4), + DEBUG_EVENT = BIT(5), + DEBUG_TX = BIT(6), + DEBUG_RX = BIT(7), + DEBUG_SCAN = BIT(8), + DEBUG_CRYPT = BIT(9), + DEBUG_PSM = BIT(10), + DEBUG_MAC80211 = BIT(11), + DEBUG_CMD = BIT(12), + DEBUG_ACX = BIT(13), + DEBUG_SDIO = BIT(14), + DEBUG_FILTERS = BIT(15), + DEBUG_ADHOC = BIT(16), + DEBUG_AP = BIT(17), + DEBUG_MASTER = (DEBUG_ADHOC | DEBUG_AP), + DEBUG_ALL = ~0, +}; + +extern u32 wl12xx_debug_level; + +#define DEBUG_DUMP_LIMIT 1024 + +#define wl1271_error(fmt, arg...) \ + pr_err(DRIVER_PREFIX "ERROR " fmt "\n", ##arg) + +#define wl1271_warning(fmt, arg...) \ + pr_warning(DRIVER_PREFIX "WARNING " fmt "\n", ##arg) + +#define wl1271_notice(fmt, arg...) \ + pr_info(DRIVER_PREFIX fmt "\n", ##arg) + +#define wl1271_info(fmt, arg...) \ + pr_info(DRIVER_PREFIX fmt "\n", ##arg) + +#define wl1271_debug(level, fmt, arg...) \ + do { \ + if (level & wl12xx_debug_level) \ + pr_debug(DRIVER_PREFIX fmt "\n", ##arg); \ + } while (0) + +/* TODO: use pr_debug_hex_dump when it becomes available */ +#define wl1271_dump(level, prefix, buf, len) \ + do { \ + if (level & wl12xx_debug_level) \ + print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \ + DUMP_PREFIX_OFFSET, 16, 1, \ + buf, \ + min_t(size_t, len, DEBUG_DUMP_LIMIT), \ + 0); \ + } while (0) + +#define wl1271_dump_ascii(level, prefix, buf, len) \ + do { \ + if (level & wl12xx_debug_level) \ + print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \ + DUMP_PREFIX_OFFSET, 16, 1, \ + buf, \ + min_t(size_t, len, DEBUG_DUMP_LIMIT), \ + true); \ + } while (0) + +#endif /* __DEBUG_H__ */ diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index d6c2d0c1b6cd..a9e0b7383bb5 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -27,6 +27,7 @@ #include #include "wl12xx.h" +#include "debug.h" #include "acx.h" #include "ps.h" #include "io.h" diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index fd2e7b2d9389..e22df6ce139a 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -22,6 +22,7 @@ */ #include "wl12xx.h" +#include "debug.h" #include "reg.h" #include "io.h" #include "event.h" diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index ba286d0a74a8..c6084f8a9c43 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -25,6 +25,7 @@ #include #include +#include "debug.h" #include "init.h" #include "wl12xx_80211.h" #include "acx.h" diff --git a/drivers/net/wireless/wl12xx/io.c b/drivers/net/wireless/wl12xx/io.c index 1a7df8a7ed2d..079ad380e8ff 100644 --- a/drivers/net/wireless/wl12xx/io.c +++ b/drivers/net/wireless/wl12xx/io.c @@ -27,6 +27,7 @@ #include #include "wl12xx.h" +#include "debug.h" #include "wl12xx_80211.h" #include "io.h" #include "tx.h" diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index c72f7497db09..44d52efedc74 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -35,6 +35,7 @@ #include #include "wl12xx.h" +#include "debug.h" #include "wl12xx_80211.h" #include "reg.h" #include "io.h" diff --git a/drivers/net/wireless/wl12xx/ps.c b/drivers/net/wireless/wl12xx/ps.c index 84a1afac6f53..9f4e8c03cc8f 100644 --- a/drivers/net/wireless/wl12xx/ps.c +++ b/drivers/net/wireless/wl12xx/ps.c @@ -25,6 +25,7 @@ #include "ps.h" #include "io.h" #include "tx.h" +#include "debug.h" #define WL1271_WAKEUP_TIMEOUT 500 diff --git a/drivers/net/wireless/wl12xx/rx.c b/drivers/net/wireless/wl12xx/rx.c index dd2f8b714a7f..8c277c0cb372 100644 --- a/drivers/net/wireless/wl12xx/rx.c +++ b/drivers/net/wireless/wl12xx/rx.c @@ -25,6 +25,7 @@ #include #include "wl12xx.h" +#include "debug.h" #include "acx.h" #include "reg.h" #include "rx.h" diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index 2711438fdde3..fb2c4319749d 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -24,6 +24,7 @@ #include #include "wl12xx.h" +#include "debug.h" #include "cmd.h" #include "scan.h" #include "acx.h" diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c index 78e5352c4037..55c63adb1d0f 100644 --- a/drivers/net/wireless/wl12xx/sdio.c +++ b/drivers/net/wireless/wl12xx/sdio.c @@ -34,6 +34,7 @@ #include #include "wl12xx.h" +#include "debug.h" #include "wl12xx_80211.h" #include "io.h" diff --git a/drivers/net/wireless/wl12xx/spi.c b/drivers/net/wireless/wl12xx/spi.c index 22c1337ba883..bcc7d7c95a22 100644 --- a/drivers/net/wireless/wl12xx/spi.c +++ b/drivers/net/wireless/wl12xx/spi.c @@ -31,6 +31,7 @@ #include #include "wl12xx.h" +#include "debug.h" #include "wl12xx_80211.h" #include "io.h" diff --git a/drivers/net/wireless/wl12xx/testmode.c b/drivers/net/wireless/wl12xx/testmode.c index 4ae8effaee22..61fff45686ad 100644 --- a/drivers/net/wireless/wl12xx/testmode.c +++ b/drivers/net/wireless/wl12xx/testmode.c @@ -26,6 +26,7 @@ #include #include "wl12xx.h" +#include "debug.h" #include "acx.h" #include "reg.h" diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 5aeef95229eb..5351f015feef 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -26,6 +26,7 @@ #include #include "wl12xx.h" +#include "debug.h" #include "io.h" #include "reg.h" #include "ps.h" diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index 158714a1092f..b7036df5939d 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -35,9 +35,6 @@ #include "conf.h" #include "ini.h" -#define DRIVER_NAME "wl1271" -#define DRIVER_PREFIX DRIVER_NAME ": " - /* * FW versions support BA 11n * versions marks x.x.x.50-60.x @@ -45,73 +42,6 @@ #define WL12XX_BA_SUPPORT_FW_COST_VER2_START 50 #define WL12XX_BA_SUPPORT_FW_COST_VER2_END 60 -enum { - DEBUG_NONE = 0, - DEBUG_IRQ = BIT(0), - DEBUG_SPI = BIT(1), - DEBUG_BOOT = BIT(2), - DEBUG_MAILBOX = BIT(3), - DEBUG_TESTMODE = BIT(4), - DEBUG_EVENT = BIT(5), - DEBUG_TX = BIT(6), - DEBUG_RX = BIT(7), - DEBUG_SCAN = BIT(8), - DEBUG_CRYPT = BIT(9), - DEBUG_PSM = BIT(10), - DEBUG_MAC80211 = BIT(11), - DEBUG_CMD = BIT(12), - DEBUG_ACX = BIT(13), - DEBUG_SDIO = BIT(14), - DEBUG_FILTERS = BIT(15), - DEBUG_ADHOC = BIT(16), - DEBUG_AP = BIT(17), - DEBUG_MASTER = (DEBUG_ADHOC | DEBUG_AP), - DEBUG_ALL = ~0, -}; - -extern u32 wl12xx_debug_level; - -#define DEBUG_DUMP_LIMIT 1024 - -#define wl1271_error(fmt, arg...) \ - pr_err(DRIVER_PREFIX "ERROR " fmt "\n", ##arg) - -#define wl1271_warning(fmt, arg...) \ - pr_warning(DRIVER_PREFIX "WARNING " fmt "\n", ##arg) - -#define wl1271_notice(fmt, arg...) \ - pr_info(DRIVER_PREFIX fmt "\n", ##arg) - -#define wl1271_info(fmt, arg...) \ - pr_info(DRIVER_PREFIX fmt "\n", ##arg) - -#define wl1271_debug(level, fmt, arg...) \ - do { \ - if (level & wl12xx_debug_level) \ - pr_debug(DRIVER_PREFIX fmt "\n", ##arg); \ - } while (0) - -/* TODO: use pr_debug_hex_dump when it will be available */ -#define wl1271_dump(level, prefix, buf, len) \ - do { \ - if (level & wl12xx_debug_level) \ - print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \ - DUMP_PREFIX_OFFSET, 16, 1, \ - buf, \ - min_t(size_t, len, DEBUG_DUMP_LIMIT), \ - 0); \ - } while (0) - -#define wl1271_dump_ascii(level, prefix, buf, len) \ - do { \ - if (level & wl12xx_debug_level) \ - print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \ - DUMP_PREFIX_OFFSET, 16, 1, \ - buf, \ - min_t(size_t, len, DEBUG_DUMP_LIMIT), \ - true); \ - } while (0) - #define WL127X_FW_NAME "ti-connectivity/wl127x-fw-3.bin" #define WL128X_FW_NAME "ti-connectivity/wl128x-fw-3.bin" -- cgit v1.2.3 From 3c4d386868dcbfb9fa51427e314fde39ee70b0ff Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Fri, 7 Oct 2011 14:14:25 +0300 Subject: wl12xx: sdio: use dev_dbg instead of wl1271_debug To prevent a useless dependency between the sdio module and the wl12xx module, we need to replace the wl1271_debug macros (and friends) for dev_dbg and other equivalents. At the same time, remove the SDIO data hexdump, since this produces way too much data and is not particularly useful. There's not print_hex_dump() equivalent for dynamic debug, so it's hard to control when the dumps are printed out. Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/sdio.c | 49 ++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 26 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c index 55c63adb1d0f..57e72b4b8d22 100644 --- a/drivers/net/wireless/wl12xx/sdio.c +++ b/drivers/net/wireless/wl12xx/sdio.c @@ -34,7 +34,6 @@ #include #include "wl12xx.h" -#include "debug.h" #include "wl12xx_80211.h" #include "io.h" @@ -77,21 +76,20 @@ static void wl12xx_sdio_raw_read(struct device *child, int addr, void *buf, if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) { ((u8 *)buf)[0] = sdio_f0_readb(func, addr, &ret); - wl1271_debug(DEBUG_SDIO, "sdio read 52 addr 0x%x, byte 0x%02x", - addr, ((u8 *)buf)[0]); + dev_dbg(child->parent, "sdio read 52 addr 0x%x, byte 0x%02x\n", + addr, ((u8 *)buf)[0]); } else { if (fixed) ret = sdio_readsb(func, buf, addr, len); else ret = sdio_memcpy_fromio(func, buf, addr, len); - wl1271_debug(DEBUG_SDIO, "sdio read 53 addr 0x%x, %zu bytes", - addr, len); - wl1271_dump_ascii(DEBUG_SDIO, "data: ", buf, len); + dev_dbg(child->parent, "sdio read 53 addr 0x%x, %zu bytes\n", + addr, len); } if (ret) - wl1271_error("sdio read failed (%d)", ret); + dev_err(child->parent, "sdio read failed (%d)\n", ret); } static void wl12xx_sdio_raw_write(struct device *child, int addr, void *buf, @@ -103,12 +101,11 @@ static void wl12xx_sdio_raw_write(struct device *child, int addr, void *buf, if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) { sdio_f0_writeb(func, ((u8 *)buf)[0], addr, &ret); - wl1271_debug(DEBUG_SDIO, "sdio write 52 addr 0x%x, byte 0x%02x", - addr, ((u8 *)buf)[0]); + dev_dbg(child->parent, "sdio write 52 addr 0x%x, byte 0x%02x\n", + addr, ((u8 *)buf)[0]); } else { - wl1271_debug(DEBUG_SDIO, "sdio write 53 addr 0x%x, %zu bytes", - addr, len); - wl1271_dump_ascii(DEBUG_SDIO, "data: ", buf, len); + dev_dbg(child->parent, "sdio write 53 addr 0x%x, %zu bytes\n", + addr, len); if (fixed) ret = sdio_writesb(func, addr, buf, len); @@ -117,7 +114,7 @@ static void wl12xx_sdio_raw_write(struct device *child, int addr, void *buf, } if (ret) - wl1271_error("sdio write failed (%d)", ret); + dev_err(child->parent, "sdio write failed (%d)\n", ret); } static int wl12xx_sdio_power_on(struct wl12xx_sdio_glue *glue) @@ -196,7 +193,7 @@ static int __devinit wl1271_probe(struct sdio_func *func, glue = kzalloc(sizeof(*glue), GFP_KERNEL); if (!glue) { - wl1271_error("can't allocate glue"); + dev_err(&func->dev, "can't allocate glue\n"); goto out; } @@ -211,13 +208,13 @@ static int __devinit wl1271_probe(struct sdio_func *func, wlan_data = wl12xx_get_platform_data(); if (IS_ERR(wlan_data)) { ret = PTR_ERR(wlan_data); - wl1271_error("missing wlan platform data: %d", ret); + dev_err(glue->dev, "missing wlan platform data: %d\n", ret); goto out_free_glue; } /* if sdio can keep power while host is suspended, enable wow */ mmcflags = sdio_get_host_pm_caps(func); - wl1271_debug(DEBUG_SDIO, "sdio PM caps = 0x%x", mmcflags); + dev_dbg(glue->dev, "sdio PM caps = 0x%x\n", mmcflags); if (mmcflags & MMC_PM_KEEP_POWER) wlan_data->pwr_in_suspend = true; @@ -231,7 +228,7 @@ static int __devinit wl1271_probe(struct sdio_func *func, glue->core = platform_device_alloc("wl12xx-sdio", -1); if (!glue->core) { - wl1271_error("can't allocate platform_device"); + dev_err(glue->dev, "can't allocate platform_device"); ret = -ENOMEM; goto out_free_glue; } @@ -246,20 +243,20 @@ static int __devinit wl1271_probe(struct sdio_func *func, ret = platform_device_add_resources(glue->core, res, ARRAY_SIZE(res)); if (ret) { - wl1271_error("can't add resources"); + dev_err(glue->dev, "can't add resources\n"); goto out_dev_put; } ret = platform_device_add_data(glue->core, wlan_data, sizeof(*wlan_data)); if (ret) { - wl1271_error("can't add platform data"); + dev_err(glue->dev, "can't add platform data\n"); goto out_dev_put; } ret = platform_device_add(glue->core); if (ret) { - wl1271_error("can't add platform device"); + dev_err(glue->dev, "can't add platform device\n"); goto out_dev_put; } return 0; @@ -296,16 +293,16 @@ static int wl1271_suspend(struct device *dev) mmc_pm_flag_t sdio_flags; int ret = 0; - wl1271_debug(DEBUG_MAC80211, "wl1271 suspend. wow_enabled: %d", - wl->wow_enabled); + dev_dbg(dev, "wl1271 suspend. wow_enabled: %d\n", + wl->wow_enabled); /* check whether sdio should keep power */ if (wl->wow_enabled) { sdio_flags = sdio_get_host_pm_caps(func); if (!(sdio_flags & MMC_PM_KEEP_POWER)) { - wl1271_error("can't keep power while host " - "is suspended"); + dev_err(dev, "can't keep power while host " + "is suspended\n"); ret = -EINVAL; goto out; } @@ -313,7 +310,7 @@ static int wl1271_suspend(struct device *dev) /* keep power while host suspended */ ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER); if (ret) { - wl1271_error("error while trying to keep power"); + dev_err(dev, "error while trying to keep power\n"); goto out; } @@ -329,7 +326,7 @@ static int wl1271_resume(struct device *dev) struct sdio_func *func = dev_to_sdio_func(dev); struct wl1271 *wl = sdio_get_drvdata(func); - wl1271_debug(DEBUG_MAC80211, "wl1271 resume"); + dev_dbg(dev, "wl1271 resume\n"); if (wl->wow_enabled) { /* claim back host */ sdio_claim_host(func); -- cgit v1.2.3 From e5d3625e8741d204e8c3f0a959f92c9e901519aa Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Fri, 7 Oct 2011 14:33:29 +0300 Subject: wl12xx: spi: use dev_err instead of wl1271_error To prevent a useless dependency between the spi module and the wl12xx module, we need to replace the wl1271_error macros with dev_err. At the same time, remove the SPI data hexdump, since this produces way too much data and is not particularly useful. There's no print_hex_dump() equivalent for dynamic debug, so it's hard to control when the dumps are printed out. Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/spi.c | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/spi.c b/drivers/net/wireless/wl12xx/spi.c index bcc7d7c95a22..976d3d556833 100644 --- a/drivers/net/wireless/wl12xx/spi.c +++ b/drivers/net/wireless/wl12xx/spi.c @@ -31,7 +31,6 @@ #include #include "wl12xx.h" -#include "debug.h" #include "wl12xx_80211.h" #include "io.h" @@ -85,7 +84,8 @@ static void wl12xx_spi_reset(struct device *child) cmd = kzalloc(WSPI_INIT_CMD_LEN, GFP_KERNEL); if (!cmd) { - wl1271_error("could not allocate cmd for spi reset"); + dev_err(child->parent, + "could not allocate cmd for spi reset\n"); return; } @@ -100,7 +100,6 @@ static void wl12xx_spi_reset(struct device *child) spi_sync(to_spi_device(glue->dev), &m); - wl1271_dump(DEBUG_SPI, "spi reset -> ", cmd, WSPI_INIT_CMD_LEN); kfree(cmd); } @@ -113,7 +112,8 @@ static void wl12xx_spi_init(struct device *child) cmd = kzalloc(WSPI_INIT_CMD_LEN, GFP_KERNEL); if (!cmd) { - wl1271_error("could not allocate cmd for spi init"); + dev_err(child->parent, + "could not allocate cmd for spi init\n"); return; } @@ -155,7 +155,6 @@ static void wl12xx_spi_init(struct device *child) spi_message_add_tail(&t, &m); spi_sync(to_spi_device(glue->dev), &m); - wl1271_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN); kfree(cmd); } @@ -192,7 +191,7 @@ static int wl12xx_spi_read_busy(struct device *child) } /* The SPI bus is unresponsive, the read failed. */ - wl1271_error("SPI read busy-word timeout!\n"); + dev_err(child->parent, "SPI read busy-word timeout!\n"); return -ETIMEDOUT; } @@ -254,9 +253,6 @@ static void wl12xx_spi_raw_read(struct device *child, int addr, void *buf, spi_sync(to_spi_device(glue->dev), &m); - wl1271_dump(DEBUG_SPI, "spi_read cmd -> ", cmd, sizeof(*cmd)); - wl1271_dump(DEBUG_SPI, "spi_read buf <- ", buf, chunk_len); - if (!fixed) addr += chunk_len; buf += chunk_len; @@ -302,9 +298,6 @@ static void wl12xx_spi_raw_write(struct device *child, int addr, void *buf, t[i].len = chunk_len; spi_message_add_tail(&t[i++], &m); - wl1271_dump(DEBUG_SPI, "spi_write cmd -> ", cmd, sizeof(*cmd)); - wl1271_dump(DEBUG_SPI, "spi_write buf -> ", buf, chunk_len); - if (!fixed) addr += chunk_len; buf += chunk_len; @@ -332,7 +325,7 @@ static int __devinit wl1271_probe(struct spi_device *spi) pdata = spi->dev.platform_data; if (!pdata) { - wl1271_error("no platform data"); + dev_err(&spi->dev, "no platform data\n"); return -ENODEV; } @@ -340,7 +333,7 @@ static int __devinit wl1271_probe(struct spi_device *spi) glue = kzalloc(sizeof(*glue), GFP_KERNEL); if (!glue) { - wl1271_error("can't allocate glue"); + dev_err(&spi->dev, "can't allocate glue\n"); goto out; } @@ -354,13 +347,13 @@ static int __devinit wl1271_probe(struct spi_device *spi) ret = spi_setup(spi); if (ret < 0) { - wl1271_error("spi_setup failed"); + dev_err(glue->dev, "spi_setup failed\n"); goto out_free_glue; } glue->core = platform_device_alloc("wl12xx-spi", -1); if (!glue->core) { - wl1271_error("can't allocate platform_device"); + dev_err(glue->dev, "can't allocate platform_device\n"); ret = -ENOMEM; goto out_free_glue; } @@ -375,19 +368,19 @@ static int __devinit wl1271_probe(struct spi_device *spi) ret = platform_device_add_resources(glue->core, res, ARRAY_SIZE(res)); if (ret) { - wl1271_error("can't add resources"); + dev_err(glue->dev, "can't add resources\n"); goto out_dev_put; } ret = platform_device_add_data(glue->core, pdata, sizeof(*pdata)); if (ret) { - wl1271_error("can't add platform data"); + dev_err(glue->dev, "can't add platform data\n"); goto out_dev_put; } ret = platform_device_add(glue->core); if (ret) { - wl1271_error("can't register platform device"); + dev_err(glue->dev, "can't register platform device\n"); goto out_dev_put; } -- cgit v1.2.3 From 48309fd477ef867babb6819f67fe082c133a5fa9 Mon Sep 17 00:00:00 2001 From: Shahar Lev Date: Fri, 7 Oct 2011 18:17:25 +0200 Subject: wl12xx: remove warning message during IBSS Tx mac80211 sets the carrier on an IBSS interface even when no network is joined. Ignore garbage frames transmitted on a disconnected IBSS interface without printing warnings. Signed-off-by: Shahar Lev [merged with wlvif changes] Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/tx.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 5351f015feef..27a45e1459c4 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -428,7 +428,15 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct wl12xx_vif *wlvif, } hlid = wl12xx_tx_get_hlid(wl, wlvif, skb); if (hlid == WL12XX_INVALID_LINK_ID) { - wl1271_error("invalid hlid. dropping skb 0x%p", skb); + if (wlvif->bss_type == BSS_TYPE_IBSS && + !test_bit(WLVIF_FLAG_IBSS_JOINED, &wlvif->flags)) { + /* It's ok to drop packets when not joined to IBSS */ + wl1271_debug(DEBUG_TX, "dropping skb while IBSS not " + " joined"); + } else { + wl1271_error("invalid hlid. dropping skb 0x%p", skb); + } + return -EINVAL; } -- cgit v1.2.3 From ccb62000d5e92772b6d5c2acce2f56263886ed89 Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Fri, 7 Oct 2011 15:54:15 +0300 Subject: wl12xx: use the same plat dev name for both SPI and SDIO There's no need to have the bus name included in the platform device name that we create. The core driver doesn't need to know about the type of bus it uses. Any differences between the buses that need to be handled differently in the core, can be passed in the platform data (as the pwr_in_suspend boolean does). Use "wl12xx" for the device name in both bus drivers. Rename the platform driver name to "wl12xx_driver", just to differentiate from the platform device names. Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 5 ++--- drivers/net/wireless/wl12xx/sdio.c | 2 +- drivers/net/wireless/wl12xx/spi.c | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 44d52efedc74..a2d16933ccb0 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -5266,8 +5266,7 @@ static int __devexit wl12xx_remove(struct platform_device *pdev) } static const struct platform_device_id wl12xx_id_table[] __devinitconst = { - { "wl12xx-sdio", 0 }, - { "wl12xx-spi", 0 }, + { "wl12xx", 0 }, { } /* Terminating Entry */ }; MODULE_DEVICE_TABLE(platform, wl12xx_id_table); @@ -5277,7 +5276,7 @@ static struct platform_driver wl12xx_driver = { .remove = __devexit_p(wl12xx_remove), .id_table = wl12xx_id_table, .driver = { - .name = "wl12xx", + .name = "wl12xx_driver", .owner = THIS_MODULE, } }; diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c index 57e72b4b8d22..ed97f9cee3f0 100644 --- a/drivers/net/wireless/wl12xx/sdio.c +++ b/drivers/net/wireless/wl12xx/sdio.c @@ -226,7 +226,7 @@ static int __devinit wl1271_probe(struct sdio_func *func, /* Tell PM core that we don't need the card to be powered now */ pm_runtime_put_noidle(&func->dev); - glue->core = platform_device_alloc("wl12xx-sdio", -1); + glue->core = platform_device_alloc("wl12xx", -1); if (!glue->core) { dev_err(glue->dev, "can't allocate platform_device"); ret = -ENOMEM; diff --git a/drivers/net/wireless/wl12xx/spi.c b/drivers/net/wireless/wl12xx/spi.c index 976d3d556833..9e6f7fa0f9a3 100644 --- a/drivers/net/wireless/wl12xx/spi.c +++ b/drivers/net/wireless/wl12xx/spi.c @@ -351,7 +351,7 @@ static int __devinit wl1271_probe(struct spi_device *spi) goto out_free_glue; } - glue->core = platform_device_alloc("wl12xx-spi", -1); + glue->core = platform_device_alloc("wl12xx", -1); if (!glue->core) { dev_err(glue->dev, "can't allocate platform_device\n"); ret = -ENOMEM; -- cgit v1.2.3 From 0f1680147ce2509383e053fa843020e0e9f3c6ce Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 11 Oct 2011 13:52:25 +0200 Subject: wl12xx: handle injected packets Injected packets are sent with no vif, causing the wl12xx to NULL-dereference in multiple places. Furthermore, injected packets are currently not sent at all, as system_hlid doesn't belong to any specific role, so wl1271_skb_dequeue() never return its packets. Handle both these problems. Reported-by: Luciano Coelho Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 7 +++++-- drivers/net/wireless/wl12xx/tx.c | 27 +++++++++++++-------------- 2 files changed, 18 insertions(+), 16 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index a2d16933ccb0..f76be5ad8ab0 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1477,11 +1477,14 @@ static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) struct wl1271 *wl = hw->priv; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); struct ieee80211_vif *vif = info->control.vif; - struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); + struct wl12xx_vif *wlvif = NULL; unsigned long flags; int q, mapping; u8 hlid; + if (vif) + wlvif = wl12xx_vif_to_data(vif); + mapping = skb_get_queue_mapping(skb); q = wl1271_tx_get_queue(mapping); @@ -1491,7 +1494,7 @@ static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) /* queue the packet */ if (hlid == WL12XX_INVALID_LINK_ID || - !test_bit(hlid, wlvif->links_map)) { + (wlvif && !test_bit(hlid, wlvif->links_map))) { wl1271_debug(DEBUG_TX, "DROP skb hlid %d q %d", hlid, q); dev_kfree_skb(skb); goto out; diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 27a45e1459c4..c7ad4f5976c5 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -185,7 +185,7 @@ u8 wl12xx_tx_get_hlid(struct wl1271 *wl, struct wl12xx_vif *wlvif, { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - if (wl12xx_is_dummy_packet(wl, skb)) + if (!wlvif || wl12xx_is_dummy_packet(wl, skb)) return wl->system_hlid; if (wlvif->bss_type == BSS_TYPE_AP_BSS) @@ -264,7 +264,8 @@ static int wl1271_tx_allocate(struct wl1271 *wl, struct wl12xx_vif *wlvif, ac = wl1271_tx_get_queue(skb_get_queue_mapping(skb)); wl->tx_allocated_pkts[ac]++; - if (!is_dummy && wlvif->bss_type == BSS_TYPE_AP_BSS && + if (!is_dummy && wlvif && + wlvif->bss_type == BSS_TYPE_AP_BSS && test_bit(hlid, wlvif->ap.sta_hlid_map)) wl->links[hlid].allocated_pkts++; @@ -307,7 +308,7 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct wl12xx_vif *wlvif, desc->start_time = cpu_to_le32(hosttime - wl->time_offset); is_dummy = wl12xx_is_dummy_packet(wl, skb); - if (is_dummy || wlvif->bss_type != BSS_TYPE_AP_BSS) + if (is_dummy || !wlvif || wlvif->bss_type != BSS_TYPE_AP_BSS) desc->life_time = cpu_to_le16(TX_HW_MGMT_PKT_LIFETIME_TU); else desc->life_time = cpu_to_le16(TX_HW_AP_MODE_PKT_LIFETIME_TU); @@ -326,14 +327,14 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct wl12xx_vif *wlvif, TX_HW_ATTR_SESSION_COUNTER; tx_attr |= TX_HW_ATTR_TX_DUMMY_REQ; - } else { + } else if (wlvif) { /* configure the tx attributes */ tx_attr = wlvif->session_counter << TX_HW_ATTR_OFST_SESSION_COUNTER; } desc->hlid = hlid; - if (is_dummy) + if (is_dummy || !wlvif) rate_idx = 0; else if (wlvif->bss_type != BSS_TYPE_AP_BSS) { /* if the packets are destined for AP (have a STA entry) @@ -446,7 +447,7 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct wl12xx_vif *wlvif, wl1271_tx_fill_hdr(wl, wlvif, skb, extra, info, hlid); - if (!is_dummy && wlvif->bss_type == BSS_TYPE_AP_BSS) { + if (!is_dummy && wlvif && wlvif->bss_type == BSS_TYPE_AP_BSS) { wl1271_tx_ap_update_inconnection_sta(wl, skb); wl1271_tx_regulate_link(wl, wlvif, hlid); } @@ -623,6 +624,9 @@ static struct sk_buff *wl1271_skb_dequeue(struct wl1271 *wl) } } + if (!skb) + skb = wl12xx_lnk_skb_dequeue(wl, &wl->links[wl->system_hlid]); + if (!skb && test_and_clear_bit(WL1271_FLAG_DUMMY_PACKET_PENDING, &wl->flags)) { int q; @@ -716,19 +720,14 @@ void wl1271_tx_work_locked(struct wl1271 *wl) return; while ((skb = wl1271_skb_dequeue(wl))) { + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); bool has_data = false; wlvif = NULL; - if (!wl12xx_is_dummy_packet(wl, skb)) { - struct ieee80211_tx_info *info; - struct ieee80211_vif *vif; + if (!wl12xx_is_dummy_packet(wl, skb) && info->control.vif) + wlvif = wl12xx_vif_to_data(info->control.vif); - info = IEEE80211_SKB_CB(skb); - vif = info->control.vif; - wlvif = wl12xx_vif_to_data(vif); - } has_data = wlvif && wl1271_tx_is_data_present(skb); - ret = wl1271_prepare_tx_frame(wl, wlvif, skb, buf_offset); if (ret == -EAGAIN) { /* -- cgit v1.2.3 From 9d9779e723a5d23b94abbe5bb7d1197921f6f3dd Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Sun, 3 Jul 2011 15:21:01 -0400 Subject: drivers/net: Add module.h to drivers who were implicitly using it The device.h header was including module.h, making it present for most of these drivers. But we want to clean that up. Call out the include of module.h in the modular network drivers. Signed-off-by: Paul Gortmaker --- drivers/net/ethernet/brocade/bna/bnad.c | 1 + drivers/net/ethernet/emulex/benet/be_main.c | 1 + drivers/net/ethernet/ethoc.c | 1 + drivers/net/ethernet/freescale/ucc_geth.c | 1 + drivers/net/ethernet/intel/e1000e/param.c | 1 + drivers/net/ethernet/mellanox/mlx4/catas.c | 1 + drivers/net/ethernet/mellanox/mlx4/fw.c | 1 + drivers/net/ethernet/neterion/vxge/vxge-main.c | 1 + drivers/net/ethernet/octeon/octeon_mgmt.c | 1 + drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 1 + drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_param.c | 1 + drivers/net/ethernet/smsc/smsc9420.c | 1 + drivers/net/ethernet/xscale/ixp4xx_eth.c | 1 + drivers/net/phy/realtek.c | 1 + drivers/net/usb/lg-vl600.c | 1 + drivers/net/veth.c | 1 + drivers/net/vmxnet3/vmxnet3_drv.c | 1 + drivers/net/wimax/i2400m/sdio.c | 1 + drivers/net/wimax/i2400m/usb.c | 1 + drivers/net/wireless/adm8211.c | 1 + drivers/net/wireless/ath/ath5k/pci.c | 1 + drivers/net/wireless/ath/ath6kl/sdio.c | 1 + drivers/net/wireless/ath/ath9k/ahb.c | 1 + drivers/net/wireless/ath/ath9k/hw.c | 1 + drivers/net/wireless/ath/ath9k/init.c | 1 + drivers/net/wireless/ath/ath9k/pci.c | 1 + drivers/net/wireless/ath/carl9170/fw.c | 1 + drivers/net/wireless/b43/pcmcia.c | 1 + drivers/net/wireless/hostap/hostap_ioctl.c | 1 + drivers/net/wireless/iwlwifi/iwl-pci.c | 1 + drivers/net/wireless/iwmc3200wifi/sdio.c | 1 + drivers/net/wireless/libertas_tf/main.c | 1 + drivers/net/wireless/mac80211_hwsim.c | 1 + drivers/net/wireless/orinoco/fw.c | 1 + drivers/net/wireless/p54/main.c | 1 + drivers/net/wireless/p54/p54pci.c | 1 + drivers/net/wireless/p54/p54usb.c | 1 + drivers/net/wireless/rtl818x/rtl8180/dev.c | 1 + drivers/net/wireless/rtl818x/rtl8187/dev.c | 1 + drivers/net/wireless/rtlwifi/base.c | 1 + drivers/net/wireless/rtlwifi/rtl8192c/main.c | 1 + drivers/net/wireless/rtlwifi/rtl8192ce/sw.c | 1 + drivers/net/wireless/rtlwifi/rtl8192cu/sw.c | 1 + drivers/net/wireless/rtlwifi/rtl8192de/sw.c | 1 + drivers/net/wireless/rtlwifi/rtl8192se/sw.c | 1 + drivers/net/wireless/zd1211rw/zd_usb.c | 1 + 46 files changed, 46 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/ethernet/brocade/bna/bnad.c b/drivers/net/ethernet/brocade/bna/bnad.c index 5d7872ecff52..7f3091e7eb42 100644 --- a/drivers/net/ethernet/brocade/bna/bnad.c +++ b/drivers/net/ethernet/brocade/bna/bnad.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "bnad.h" #include "bna.h" diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index d6a232a300ad..13ae2d71a5fb 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -16,6 +16,7 @@ */ #include +#include #include "be.h" #include "be_cmds.h" #include diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c index bdb348a5ccf6..251b635fe75a 100644 --- a/drivers/net/ethernet/ethoc.c +++ b/drivers/net/ethernet/ethoc.c @@ -22,6 +22,7 @@ #include #include #include +#include #include static int buffer_size = 0x8000; /* 32 KBytes */ diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c index 46d690a92c0b..b5dc0273a1d1 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.c +++ b/drivers/net/ethernet/freescale/ucc_geth.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/net/ethernet/intel/e1000e/param.c b/drivers/net/ethernet/intel/e1000e/param.c index 4dd9b63273f6..20e93b08e7f3 100644 --- a/drivers/net/ethernet/intel/e1000e/param.c +++ b/drivers/net/ethernet/intel/e1000e/param.c @@ -27,6 +27,7 @@ *******************************************************************************/ #include +#include #include #include "e1000.h" diff --git a/drivers/net/ethernet/mellanox/mlx4/catas.c b/drivers/net/ethernet/mellanox/mlx4/catas.c index 32f947154c33..45aea9c3ae2c 100644 --- a/drivers/net/ethernet/mellanox/mlx4/catas.c +++ b/drivers/net/ethernet/mellanox/mlx4/catas.c @@ -32,6 +32,7 @@ */ #include +#include #include "mlx4.h" diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c index ed452ddfe342..81db50ecb1d1 100644 --- a/drivers/net/ethernet/mellanox/mlx4/fw.c +++ b/drivers/net/ethernet/mellanox/mlx4/fw.c @@ -33,6 +33,7 @@ */ #include +#include #include #include "fw.h" diff --git a/drivers/net/ethernet/neterion/vxge/vxge-main.c b/drivers/net/ethernet/neterion/vxge/vxge-main.c index 671e166b5af1..a83197d757c1 100644 --- a/drivers/net/ethernet/neterion/vxge/vxge-main.c +++ b/drivers/net/ethernet/neterion/vxge/vxge-main.c @@ -55,6 +55,7 @@ #include #include #include +#include #include "vxge-main.h" #include "vxge-reg.h" diff --git a/drivers/net/ethernet/octeon/octeon_mgmt.c b/drivers/net/ethernet/octeon/octeon_mgmt.c index bc1d946b7971..212f43b308a3 100644 --- a/drivers/net/ethernet/octeon/octeon_mgmt.c +++ b/drivers/net/ethernet/octeon/octeon_mgmt.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c index b89f3a684aec..48406ca382f1 100644 --- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c @@ -20,6 +20,7 @@ #include "pch_gbe.h" #include "pch_gbe_api.h" +#include #define DRV_VERSION "1.00" const char pch_driver_version[] = DRV_VERSION; diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_param.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_param.c index 5b5d90a47e29..9c075ea2682e 100644 --- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_param.c +++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_param.c @@ -18,6 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ +#include /* for __MODULE_STRING */ #include "pch_gbe.h" #define OPTION_UNSET -1 diff --git a/drivers/net/ethernet/smsc/smsc9420.c b/drivers/net/ethernet/smsc/smsc9420.c index 4f15680849ff..edb24b0e337b 100644 --- a/drivers/net/ethernet/smsc/smsc9420.c +++ b/drivers/net/ethernet/smsc/smsc9420.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include "smsc9420.h" diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c index ec96d910e9a3..f45c85a84261 100644 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index a4eae750a414..f414ffb5b728 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -14,6 +14,7 @@ * */ #include +#include #define RTL821x_PHYSR 0x11 #define RTL821x_PHYSR_DUPLEX 0x2000 diff --git a/drivers/net/usb/lg-vl600.c b/drivers/net/usb/lg-vl600.c index 1e7221951056..d43db32f9478 100644 --- a/drivers/net/usb/lg-vl600.c +++ b/drivers/net/usb/lg-vl600.c @@ -27,6 +27,7 @@ #include #include #include +#include /* * The device has a CDC ACM port for modem control (it claims to be diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 5b23767ea817..ef883e97cee0 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -17,6 +17,7 @@ #include #include #include +#include #define DRV_NAME "veth" #define DRV_VERSION "1.0" diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c index b771ebac0f01..d96bfb1ac20b 100644 --- a/drivers/net/vmxnet3/vmxnet3_drv.c +++ b/drivers/net/vmxnet3/vmxnet3_drv.c @@ -24,6 +24,7 @@ * */ +#include #include #include "vmxnet3_int.h" diff --git a/drivers/net/wimax/i2400m/sdio.c b/drivers/net/wimax/i2400m/sdio.c index be428cae28d8..21a9edd6e75d 100644 --- a/drivers/net/wimax/i2400m/sdio.c +++ b/drivers/net/wimax/i2400m/sdio.c @@ -55,6 +55,7 @@ #include #include "i2400m-sdio.h" #include +#include #define D_SUBMODULE main #include "sdio-debug-levels.h" diff --git a/drivers/net/wimax/i2400m/usb.c b/drivers/net/wimax/i2400m/usb.c index 9a644d052f1e..2c1b8b687646 100644 --- a/drivers/net/wimax/i2400m/usb.c +++ b/drivers/net/wimax/i2400m/usb.c @@ -67,6 +67,7 @@ #include #include #include +#include #define D_SUBMODULE usb diff --git a/drivers/net/wireless/adm8211.c b/drivers/net/wireless/adm8211.c index 3b752d9fb3cd..f5ce5623da99 100644 --- a/drivers/net/wireless/adm8211.c +++ b/drivers/net/wireless/adm8211.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include "adm8211.h" diff --git a/drivers/net/wireless/ath/ath5k/pci.c b/drivers/net/wireless/ath/ath5k/pci.c index c1dff2ced044..dfa48eb7d953 100644 --- a/drivers/net/wireless/ath/ath5k/pci.c +++ b/drivers/net/wireless/ath/ath5k/pci.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "../ath.h" #include "ath5k.h" #include "debug.h" diff --git a/drivers/net/wireless/ath/ath6kl/sdio.c b/drivers/net/wireless/ath/ath6kl/sdio.c index f1dc311ee0c7..066d4f88807f 100644 --- a/drivers/net/wireless/ath/ath6kl/sdio.c +++ b/drivers/net/wireless/ath/ath6kl/sdio.c @@ -14,6 +14,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include #include #include #include diff --git a/drivers/net/wireless/ath/ath9k/ahb.c b/drivers/net/wireless/ath/ath9k/ahb.c index 85a54cd2b083..5e47ca6d16a8 100644 --- a/drivers/net/wireless/ath/ath9k/ahb.c +++ b/drivers/net/wireless/ath/ath9k/ahb.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "ath9k.h" static const struct platform_device_id ath9k_platform_id_table[] = { diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index f16d2033081f..4952ad8c4e8c 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -16,6 +16,7 @@ #include #include +#include #include #include "hw.h" diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index af1b32549531..d4c909f8e474 100644 --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "ath9k.h" diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c index edb0b4b3da3a..2dcdf63cb390 100644 --- a/drivers/net/wireless/ath/ath9k/pci.c +++ b/drivers/net/wireless/ath/ath9k/pci.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "ath9k.h" static DEFINE_PCI_DEVICE_TABLE(ath_pci_id_table) = { diff --git a/drivers/net/wireless/ath/carl9170/fw.c b/drivers/net/wireless/ath/carl9170/fw.c index f4cae1cccbff..cba9d0435dc4 100644 --- a/drivers/net/wireless/ath/carl9170/fw.c +++ b/drivers/net/wireless/ath/carl9170/fw.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "carl9170.h" #include "fwcmd.h" #include "version.h" diff --git a/drivers/net/wireless/b43/pcmcia.c b/drivers/net/wireless/b43/pcmcia.c index 12b6b4067a39..714cad649c45 100644 --- a/drivers/net/wireless/b43/pcmcia.c +++ b/drivers/net/wireless/b43/pcmcia.c @@ -25,6 +25,7 @@ #include #include +#include #include #include diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c index 12de46407c71..045a93645a3d 100644 --- a/drivers/net/wireless/hostap/hostap_ioctl.c +++ b/drivers/net/wireless/hostap/hostap_ioctl.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "hostap_wlan.h" diff --git a/drivers/net/wireless/iwlwifi/iwl-pci.c b/drivers/net/wireless/iwlwifi/iwl-pci.c index 3b6cc66365e5..f0c623ade3ff 100644 --- a/drivers/net/wireless/iwlwifi/iwl-pci.c +++ b/drivers/net/wireless/iwlwifi/iwl-pci.c @@ -60,6 +60,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ +#include #include #include diff --git a/drivers/net/wireless/iwmc3200wifi/sdio.c b/drivers/net/wireless/iwmc3200wifi/sdio.c index 56383e7be835..764b40dd24ad 100644 --- a/drivers/net/wireless/iwmc3200wifi/sdio.c +++ b/drivers/net/wireless/iwmc3200wifi/sdio.c @@ -63,6 +63,7 @@ */ #include +#include #include #include #include diff --git a/drivers/net/wireless/libertas_tf/main.c b/drivers/net/wireless/libertas_tf/main.c index acc461aa385e..ceb51b6e6702 100644 --- a/drivers/net/wireless/libertas_tf/main.c +++ b/drivers/net/wireless/libertas_tf/main.c @@ -13,6 +13,7 @@ #include #include +#include #include "libertas_tf.h" #define DRIVER_RELEASE_VERSION "004.p0" diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 68455a2307cb..523ad55a2885 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include "mac80211_hwsim.h" diff --git a/drivers/net/wireless/orinoco/fw.c b/drivers/net/wireless/orinoco/fw.c index 527cf5333db5..4df8cf64b56c 100644 --- a/drivers/net/wireless/orinoco/fw.c +++ b/drivers/net/wireless/orinoco/fw.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "hermes.h" #include "hermes_dld.h" diff --git a/drivers/net/wireless/p54/main.c b/drivers/net/wireless/p54/main.c index ad9ae04d07aa..db4d9a02f264 100644 --- a/drivers/net/wireless/p54/main.c +++ b/drivers/net/wireless/p54/main.c @@ -20,6 +20,7 @@ #include #include #include +#include #include diff --git a/drivers/net/wireless/p54/p54pci.c b/drivers/net/wireless/p54/p54pci.c index 1b753173680f..b1f51a215792 100644 --- a/drivers/net/wireless/p54/p54pci.c +++ b/drivers/net/wireless/p54/p54pci.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "p54.h" diff --git a/drivers/net/wireless/p54/p54usb.c b/drivers/net/wireless/p54/p54usb.c index a8f3bc740dfa..9b6096866427 100644 --- a/drivers/net/wireless/p54/p54usb.c +++ b/drivers/net/wireless/p54/p54usb.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "p54.h" diff --git a/drivers/net/wireless/rtl818x/rtl8180/dev.c b/drivers/net/wireless/rtl818x/rtl8180/dev.c index 0082015ff664..2f14a5fb0cbb 100644 --- a/drivers/net/wireless/rtl818x/rtl8180/dev.c +++ b/drivers/net/wireless/rtl818x/rtl8180/dev.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "rtl8180.h" diff --git a/drivers/net/wireless/rtl818x/rtl8187/dev.c b/drivers/net/wireless/rtl818x/rtl8187/dev.c index 24873b55b55c..4a78f9e39dfa 100644 --- a/drivers/net/wireless/rtl818x/rtl8187/dev.c +++ b/drivers/net/wireless/rtl818x/rtl8187/dev.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include "rtl8187.h" diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c index d4fdd2a5a739..b4ce93436d2e 100644 --- a/drivers/net/wireless/rtlwifi/base.c +++ b/drivers/net/wireless/rtlwifi/base.c @@ -30,6 +30,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include +#include #include "wifi.h" #include "rc.h" #include "base.h" diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/main.c b/drivers/net/wireless/rtlwifi/rtl8192c/main.c index 2f624fc27499..605ff191aeb7 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/main.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/main.c @@ -27,6 +27,7 @@ * *****************************************************************************/ +#include #include "../wifi.h" diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c index a48404cc2b96..f2aa33dc4d78 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c @@ -28,6 +28,7 @@ *****************************************************************************/ #include +#include #include "../wifi.h" #include "../core.h" diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c index feed1ed8d9b6..c244f2f1b83f 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/sw.c @@ -42,6 +42,7 @@ #include "led.h" #include "hw.h" #include +#include MODULE_AUTHOR("Georgia "); MODULE_AUTHOR("Ziv Huang "); diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c index 691f80092185..149493f4c25c 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/sw.c @@ -30,6 +30,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include +#include #include "../wifi.h" #include "../core.h" diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c index 3ec9a0d41baf..92f49d522c56 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/sw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/sw.c @@ -30,6 +30,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include +#include #include "../wifi.h" #include "../core.h" diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c index cf0d69dd7be5..785bdbe38f2a 100644 --- a/drivers/net/wireless/zd1211rw/zd_usb.c +++ b/drivers/net/wireless/zd1211rw/zd_usb.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include -- cgit v1.2.3 From ee40fa0656a730491765545ff7550f3c1ceb0fbc Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Fri, 27 May 2011 16:14:23 -0400 Subject: drivers/net: Add export.h to files using EXPORT_SYMBOL/THIS_MODULE These were getting the macros from an implicit module.h include via device.h, but we are planning to clean that up. Signed-off-by: Paul Gortmaker drivers/net: Add export.h to wireless/brcm80211/brcmfmac/bcmsdh.c This relatively recently added file uses EXPORT_SYMBOL and hence needs export.h included so that it is compatible with the module.h split up work. Signed-off-by: Paul Gortmaker --- drivers/net/bonding/bond_procfs.c | 1 + drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c | 1 + drivers/net/ethernet/chelsio/cxgb3/l2t.c | 1 + drivers/net/ethernet/chelsio/cxgb4/sge.c | 1 + drivers/net/ethernet/mellanox/mlx4/alloc.c | 1 + drivers/net/ethernet/mellanox/mlx4/cmd.c | 1 + drivers/net/ethernet/mellanox/mlx4/cq.c | 1 + drivers/net/ethernet/mellanox/mlx4/eq.c | 1 + drivers/net/ethernet/mellanox/mlx4/intf.c | 1 + drivers/net/ethernet/mellanox/mlx4/mcg.c | 1 + drivers/net/ethernet/mellanox/mlx4/mr.c | 1 + drivers/net/ethernet/mellanox/mlx4/pd.c | 1 + drivers/net/ethernet/mellanox/mlx4/port.c | 1 + drivers/net/ethernet/mellanox/mlx4/qp.c | 1 + drivers/net/ethernet/mellanox/mlx4/srq.c | 1 + drivers/net/wimax/i2400m/control.c | 1 + drivers/net/wimax/i2400m/debugfs.c | 1 + drivers/net/wimax/i2400m/fw.c | 1 + drivers/net/wimax/i2400m/netdev.c | 1 + drivers/net/wimax/i2400m/rx.c | 1 + drivers/net/wimax/i2400m/tx.c | 1 + drivers/net/wireless/ath/ath5k/debug.c | 1 + drivers/net/wireless/ath/ath6kl/debug.c | 1 + drivers/net/wireless/ath/ath9k/ani.c | 1 + drivers/net/wireless/ath/ath9k/ar9002_mac.c | 1 + drivers/net/wireless/ath/ath9k/ar9003_mac.c | 1 + drivers/net/wireless/ath/ath9k/ar9003_paprd.c | 1 + drivers/net/wireless/ath/ath9k/ar9003_phy.c | 1 + drivers/net/wireless/ath/ath9k/btcoex.c | 1 + drivers/net/wireless/ath/ath9k/calib.c | 1 + drivers/net/wireless/ath/ath9k/debug.c | 1 + drivers/net/wireless/ath/ath9k/mac.c | 1 + drivers/net/wireless/ath/ath9k/rc.c | 1 + drivers/net/wireless/ath/debug.c | 1 + drivers/net/wireless/ath/hw.c | 1 + drivers/net/wireless/ath/key.c | 1 + drivers/net/wireless/ath/regd.c | 1 + drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c | 1 + drivers/net/wireless/hostap/hostap_80211_rx.c | 1 + drivers/net/wireless/hostap/hostap_80211_tx.c | 1 + drivers/net/wireless/hostap/hostap_ap.c | 1 + drivers/net/wireless/hostap/hostap_info.c | 1 + drivers/net/wireless/hostap/hostap_proc.c | 1 + drivers/net/wireless/iwlegacy/iwl-debugfs.c | 1 + drivers/net/wireless/iwlegacy/iwl-rx.c | 1 + drivers/net/wireless/iwlegacy/iwl-scan.c | 1 + drivers/net/wireless/iwlegacy/iwl-sta.c | 1 + drivers/net/wireless/iwlegacy/iwl-tx.c | 1 + drivers/net/wireless/iwmc3200wifi/debugfs.c | 1 + drivers/net/wireless/libertas/cmd.c | 1 + drivers/net/wireless/libertas/debugfs.c | 1 + drivers/net/wireless/libertas/rx.c | 1 + drivers/net/wireless/libertas/tx.c | 1 + drivers/net/wireless/libertas_tf/cmd.c | 1 + drivers/net/wireless/p54/eeprom.c | 1 + drivers/net/wireless/p54/fwio.c | 1 + drivers/net/wireless/p54/txrx.c | 1 + drivers/net/wireless/rtlwifi/cam.c | 1 + drivers/net/wireless/rtlwifi/efuse.c | 1 + drivers/net/wireless/rtlwifi/pci.c | 1 + drivers/net/wireless/rtlwifi/ps.c | 1 + drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c | 1 + drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c | 1 + drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c | 1 + drivers/net/wireless/rtlwifi/usb.c | 1 + drivers/net/wireless/wl12xx/boot.c | 1 + 66 files changed, 66 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/bonding/bond_procfs.c b/drivers/net/bonding/bond_procfs.c index 95de93b90386..e1cce1ca387a 100644 --- a/drivers/net/bonding/bond_procfs.c +++ b/drivers/net/bonding/bond_procfs.c @@ -1,4 +1,5 @@ #include +#include #include #include #include "bonding.h" diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c index da5a5d9b8aff..90ff1318cc05 100644 --- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c +++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "common.h" #include "regs.h" diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.c b/drivers/net/ethernet/chelsio/cxgb3/l2t.c index 41540978a173..70fec8b1140f 100644 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.c +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include "common.h" #include "t3cdev.h" diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c index ddc16985d0f6..140254c7cba9 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include "cxgb4.h" diff --git a/drivers/net/ethernet/mellanox/mlx4/alloc.c b/drivers/net/ethernet/mellanox/mlx4/alloc.c index 116cae334dad..8be20e7ea3d1 100644 --- a/drivers/net/ethernet/mellanox/mlx4/alloc.c +++ b/drivers/net/ethernet/mellanox/mlx4/alloc.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c index 23cee7b6af91..78f5a1a0b8c8 100644 --- a/drivers/net/ethernet/mellanox/mlx4/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c @@ -34,6 +34,7 @@ #include #include +#include #include #include diff --git a/drivers/net/ethernet/mellanox/mlx4/cq.c b/drivers/net/ethernet/mellanox/mlx4/cq.c index bd8ef9f2fa71..499a5168892a 100644 --- a/drivers/net/ethernet/mellanox/mlx4/cq.c +++ b/drivers/net/ethernet/mellanox/mlx4/cq.c @@ -35,6 +35,7 @@ */ #include +#include #include #include diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet/mellanox/mlx4/eq.c index 1ad1f6029af8..58f39e2974c4 100644 --- a/drivers/net/ethernet/mellanox/mlx4/eq.c +++ b/drivers/net/ethernet/mellanox/mlx4/eq.c @@ -33,6 +33,7 @@ #include #include +#include #include #include diff --git a/drivers/net/ethernet/mellanox/mlx4/intf.c b/drivers/net/ethernet/mellanox/mlx4/intf.c index 73c94fcdfddf..ca6feb55bd94 100644 --- a/drivers/net/ethernet/mellanox/mlx4/intf.c +++ b/drivers/net/ethernet/mellanox/mlx4/intf.c @@ -32,6 +32,7 @@ */ #include +#include #include "mlx4.h" diff --git a/drivers/net/ethernet/mellanox/mlx4/mcg.c b/drivers/net/ethernet/mellanox/mlx4/mcg.c index cd1784593a3c..978688c31046 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mcg.c +++ b/drivers/net/ethernet/mellanox/mlx4/mcg.c @@ -35,6 +35,7 @@ #include #include +#include #include "mlx4.h" diff --git a/drivers/net/ethernet/mellanox/mlx4/mr.c b/drivers/net/ethernet/mellanox/mlx4/mr.c index 9c188bdd7f4f..877468298333 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mr.c +++ b/drivers/net/ethernet/mellanox/mlx4/mr.c @@ -33,6 +33,7 @@ */ #include +#include #include #include diff --git a/drivers/net/ethernet/mellanox/mlx4/pd.c b/drivers/net/ethernet/mellanox/mlx4/pd.c index 1286b886dcea..0f515928477f 100644 --- a/drivers/net/ethernet/mellanox/mlx4/pd.c +++ b/drivers/net/ethernet/mellanox/mlx4/pd.c @@ -32,6 +32,7 @@ */ #include +#include #include #include diff --git a/drivers/net/ethernet/mellanox/mlx4/port.c b/drivers/net/ethernet/mellanox/mlx4/port.c index 163a314c148f..b7c4c083dffc 100644 --- a/drivers/net/ethernet/mellanox/mlx4/port.c +++ b/drivers/net/ethernet/mellanox/mlx4/port.c @@ -32,6 +32,7 @@ #include #include +#include #include diff --git a/drivers/net/ethernet/mellanox/mlx4/qp.c b/drivers/net/ethernet/mellanox/mlx4/qp.c index ec9350e5f21a..7b6cc80d6cd3 100644 --- a/drivers/net/ethernet/mellanox/mlx4/qp.c +++ b/drivers/net/ethernet/mellanox/mlx4/qp.c @@ -34,6 +34,7 @@ */ #include +#include #include #include diff --git a/drivers/net/ethernet/mellanox/mlx4/srq.c b/drivers/net/ethernet/mellanox/mlx4/srq.c index 3b07b80a0456..f1a3adc164d6 100644 --- a/drivers/net/ethernet/mellanox/mlx4/srq.c +++ b/drivers/net/ethernet/mellanox/mlx4/srq.c @@ -32,6 +32,7 @@ */ #include +#include #include #include "mlx4.h" diff --git a/drivers/net/wimax/i2400m/control.c b/drivers/net/wimax/i2400m/control.c index 727d728649b7..ec4147a02017 100644 --- a/drivers/net/wimax/i2400m/control.c +++ b/drivers/net/wimax/i2400m/control.c @@ -78,6 +78,7 @@ #include #include #include +#include #define D_SUBMODULE control diff --git a/drivers/net/wimax/i2400m/debugfs.c b/drivers/net/wimax/i2400m/debugfs.c index 9c70b5fa3f51..129ba36bd04d 100644 --- a/drivers/net/wimax/i2400m/debugfs.c +++ b/drivers/net/wimax/i2400m/debugfs.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "i2400m.h" diff --git a/drivers/net/wimax/i2400m/fw.c b/drivers/net/wimax/i2400m/fw.c index 85dadd5bf4be..7cbd7d231e11 100644 --- a/drivers/net/wimax/i2400m/fw.c +++ b/drivers/net/wimax/i2400m/fw.c @@ -158,6 +158,7 @@ #include #include #include +#include #include "i2400m.h" diff --git a/drivers/net/wimax/i2400m/netdev.c b/drivers/net/wimax/i2400m/netdev.c index 2edd8fe1c1f3..64a110604ad3 100644 --- a/drivers/net/wimax/i2400m/netdev.c +++ b/drivers/net/wimax/i2400m/netdev.c @@ -76,6 +76,7 @@ #include #include #include +#include #include "i2400m.h" diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c index 2f94a872101f..9ed741b6a36f 100644 --- a/drivers/net/wimax/i2400m/rx.c +++ b/drivers/net/wimax/i2400m/rx.c @@ -149,6 +149,7 @@ #include #include #include +#include #include "i2400m.h" diff --git a/drivers/net/wimax/i2400m/tx.c b/drivers/net/wimax/i2400m/tx.c index 4b30ed11d785..4b9ecb20deec 100644 --- a/drivers/net/wimax/i2400m/tx.c +++ b/drivers/net/wimax/i2400m/tx.c @@ -245,6 +245,7 @@ */ #include #include +#include #include "i2400m.h" diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c index fce8c904eea9..a8a72b32328e 100644 --- a/drivers/net/wireless/ath/ath5k/debug.c +++ b/drivers/net/wireless/ath/ath5k/debug.c @@ -57,6 +57,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGES. */ +#include #include #include diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c index ba3f23d71150..7879b5314285 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.c +++ b/drivers/net/wireless/ath/ath6kl/debug.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "debug.h" #include "target.h" diff --git a/drivers/net/wireless/ath/ath9k/ani.c b/drivers/net/wireless/ath/ath9k/ani.c index 2776c3c1f506..a639b94f7643 100644 --- a/drivers/net/wireless/ath/ath9k/ani.c +++ b/drivers/net/wireless/ath/ath9k/ani.c @@ -15,6 +15,7 @@ */ #include +#include #include "hw.h" #include "hw-ops.h" diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c index f7d8e516a2a9..b5920168606d 100644 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c @@ -15,6 +15,7 @@ */ #include "hw.h" +#include #define AR_BufLen 0x00000fff diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c index b363cc06cfd9..ccde784a842f 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c @@ -13,6 +13,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include #include "hw.h" #include "ar9003_mac.h" diff --git a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c index 0c462c904cbe..a4450cba0653 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c @@ -14,6 +14,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include #include "hw.h" #include "ar9003_phy.h" diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.c b/drivers/net/wireless/ath/ath9k/ar9003_phy.c index fe96997921d3..2330e7ede199 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c @@ -14,6 +14,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include #include "hw.h" #include "ar9003_phy.h" diff --git a/drivers/net/wireless/ath/ath9k/btcoex.c b/drivers/net/wireless/ath/ath9k/btcoex.c index 6635c377dc00..012263968d64 100644 --- a/drivers/net/wireless/ath/ath9k/btcoex.c +++ b/drivers/net/wireless/ath/ath9k/btcoex.c @@ -14,6 +14,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include #include "hw.h" enum ath_bt_mode { diff --git a/drivers/net/wireless/ath/ath9k/calib.c b/drivers/net/wireless/ath/ath9k/calib.c index ebaf304f464b..99538810a312 100644 --- a/drivers/net/wireless/ath/ath9k/calib.c +++ b/drivers/net/wireless/ath/ath9k/calib.c @@ -16,6 +16,7 @@ #include "hw.h" #include "hw-ops.h" +#include /* Common calibration code */ diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c index 327aa28f6030..2741203e803f 100644 --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c @@ -16,6 +16,7 @@ #include #include +#include #include #include "ath9k.h" diff --git a/drivers/net/wireless/ath/ath9k/mac.c b/drivers/net/wireless/ath/ath9k/mac.c index 6a8fdf33a527..ecdb6fd29079 100644 --- a/drivers/net/wireless/ath/ath9k/mac.c +++ b/drivers/net/wireless/ath/ath9k/mac.c @@ -16,6 +16,7 @@ #include "hw.h" #include "hw-ops.h" +#include static void ath9k_hw_set_txq_interrupts(struct ath_hw *ah, struct ath9k_tx_queue_info *qi) diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c index 8448281dd069..888abc2be3a5 100644 --- a/drivers/net/wireless/ath/ath9k/rc.c +++ b/drivers/net/wireless/ath/ath9k/rc.c @@ -16,6 +16,7 @@ */ #include +#include #include "ath9k.h" diff --git a/drivers/net/wireless/ath/debug.c b/drivers/net/wireless/ath/debug.c index 5367b1086e09..508eccf5d982 100644 --- a/drivers/net/wireless/ath/debug.c +++ b/drivers/net/wireless/ath/debug.c @@ -14,6 +14,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include #include "ath.h" const char *ath_opmode_to_string(enum nl80211_iftype opmode) diff --git a/drivers/net/wireless/ath/hw.c b/drivers/net/wireless/ath/hw.c index 3f508e59f146..19befb331073 100644 --- a/drivers/net/wireless/ath/hw.c +++ b/drivers/net/wireless/ath/hw.c @@ -14,6 +14,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include #include #include "ath.h" diff --git a/drivers/net/wireless/ath/key.c b/drivers/net/wireless/ath/key.c index 17b0efd86f9a..4cf7c5eb4813 100644 --- a/drivers/net/wireless/ath/key.c +++ b/drivers/net/wireless/ath/key.c @@ -15,6 +15,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include #include #include diff --git a/drivers/net/wireless/ath/regd.c b/drivers/net/wireless/ath/regd.c index 028310f263c8..85fa9cc73502 100644 --- a/drivers/net/wireless/ath/regd.c +++ b/drivers/net/wireless/ath/regd.c @@ -15,6 +15,7 @@ */ #include +#include #include #include #include "regd.h" diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c index bff9dcd6fadc..89ff94da556a 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c @@ -17,6 +17,7 @@ #include #include +#include #include #include #include diff --git a/drivers/net/wireless/hostap/hostap_80211_rx.c b/drivers/net/wireless/hostap/hostap_80211_rx.c index e0b3e8d406b3..df7050abe717 100644 --- a/drivers/net/wireless/hostap/hostap_80211_rx.c +++ b/drivers/net/wireless/hostap/hostap_80211_rx.c @@ -1,5 +1,6 @@ #include #include +#include #include #include diff --git a/drivers/net/wireless/hostap/hostap_80211_tx.c b/drivers/net/wireless/hostap/hostap_80211_tx.c index c34a3b7f1292..344a981a052e 100644 --- a/drivers/net/wireless/hostap/hostap_80211_tx.c +++ b/drivers/net/wireless/hostap/hostap_80211_tx.c @@ -1,4 +1,5 @@ #include +#include #include "hostap_80211.h" #include "hostap_common.h" diff --git a/drivers/net/wireless/hostap/hostap_ap.c b/drivers/net/wireless/hostap/hostap_ap.c index 3d05dc15c6b8..f5f9c8c6edd1 100644 --- a/drivers/net/wireless/hostap/hostap_ap.c +++ b/drivers/net/wireless/hostap/hostap_ap.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "hostap_wlan.h" #include "hostap.h" diff --git a/drivers/net/wireless/hostap/hostap_info.c b/drivers/net/wireless/hostap/hostap_info.c index d737091cf6ac..47932b28aac1 100644 --- a/drivers/net/wireless/hostap/hostap_info.c +++ b/drivers/net/wireless/hostap/hostap_info.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "hostap_wlan.h" #include "hostap.h" #include "hostap_ap.h" diff --git a/drivers/net/wireless/hostap/hostap_proc.c b/drivers/net/wireless/hostap/hostap_proc.c index 005ff25a405f..75ef8f04aabe 100644 --- a/drivers/net/wireless/hostap/hostap_proc.c +++ b/drivers/net/wireless/hostap/hostap_proc.c @@ -2,6 +2,7 @@ #include #include +#include #include #include "hostap_wlan.h" diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index 996996a71657..1407dca70def 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -26,6 +26,7 @@ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 *****************************************************************************/ #include +#include #include diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c index 9b5d0abe8be9..f4d21ec22497 100644 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -29,6 +29,7 @@ #include #include +#include #include #include #include "iwl-eeprom.h" diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index a6b5222fc59e..521b73b527d3 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include "iwl-eeprom.h" diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.c b/drivers/net/wireless/iwlegacy/iwl-sta.c index 66f0fb2bbe00..f10df3e2813a 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-sta.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "iwl-dev.h" #include "iwl-core.h" diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index ef9e268bf8a0..c0dfb1a4e968 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include "iwl-eeprom.h" #include "iwl-dev.h" diff --git a/drivers/net/wireless/iwmc3200wifi/debugfs.c b/drivers/net/wireless/iwmc3200wifi/debugfs.c index 0a0cc9667cd6..87eef5773a02 100644 --- a/drivers/net/wireless/iwmc3200wifi/debugfs.c +++ b/drivers/net/wireless/iwmc3200wifi/debugfs.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "iwm.h" #include "bus.h" diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c index e08ab1de3d9d..d798bcc0d83a 100644 --- a/drivers/net/wireless/libertas/cmd.c +++ b/drivers/net/wireless/libertas/cmd.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "decl.h" #include "cfg.h" diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c index 1af182778844..d8d8f0d0899f 100644 --- a/drivers/net/wireless/libertas/debugfs.c +++ b/drivers/net/wireless/libertas/debugfs.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "decl.h" #include "cmd.h" diff --git a/drivers/net/wireless/libertas/rx.c b/drivers/net/wireless/libertas/rx.c index 62e10eeadd7e..c7366b07b568 100644 --- a/drivers/net/wireless/libertas/rx.c +++ b/drivers/net/wireless/libertas/rx.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "defs.h" diff --git a/drivers/net/wireless/libertas/tx.c b/drivers/net/wireless/libertas/tx.c index 8f127520d786..c025f9c18282 100644 --- a/drivers/net/wireless/libertas/tx.c +++ b/drivers/net/wireless/libertas/tx.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "host.h" diff --git a/drivers/net/wireless/libertas_tf/cmd.c b/drivers/net/wireless/libertas_tf/cmd.c index 13557fe0bf95..909ac3685010 100644 --- a/drivers/net/wireless/libertas_tf/cmd.c +++ b/drivers/net/wireless/libertas_tf/cmd.c @@ -11,6 +11,7 @@ #include #include +#include #include "libertas_tf.h" diff --git a/drivers/net/wireless/p54/eeprom.c b/drivers/net/wireless/p54/eeprom.c index 8b6f363b3f7d..fa8ce5104781 100644 --- a/drivers/net/wireless/p54/eeprom.c +++ b/drivers/net/wireless/p54/eeprom.c @@ -24,6 +24,7 @@ #include #include +#include #include "p54.h" #include "eeprom.h" diff --git a/drivers/net/wireless/p54/fwio.c b/drivers/net/wireless/p54/fwio.c index 53a3408931be..18e82b31afa6 100644 --- a/drivers/net/wireless/p54/fwio.c +++ b/drivers/net/wireless/p54/fwio.c @@ -20,6 +20,7 @@ #include #include #include +#include #include diff --git a/drivers/net/wireless/p54/txrx.c b/drivers/net/wireless/p54/txrx.c index f485784a60ae..6ed9c323e3cb 100644 --- a/drivers/net/wireless/p54/txrx.c +++ b/drivers/net/wireless/p54/txrx.c @@ -16,6 +16,7 @@ * published by the Free Software Foundation. */ +#include #include #include #include diff --git a/drivers/net/wireless/rtlwifi/cam.c b/drivers/net/wireless/rtlwifi/cam.c index 7babb6acd957..dc36d7461caa 100644 --- a/drivers/net/wireless/rtlwifi/cam.c +++ b/drivers/net/wireless/rtlwifi/cam.c @@ -29,6 +29,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include "wifi.h" #include "cam.h" diff --git a/drivers/net/wireless/rtlwifi/efuse.c b/drivers/net/wireless/rtlwifi/efuse.c index 3fc21f60bb04..ed1058b71587 100644 --- a/drivers/net/wireless/rtlwifi/efuse.c +++ b/drivers/net/wireless/rtlwifi/efuse.c @@ -27,6 +27,7 @@ * *****************************************************************************/ +#include #include "wifi.h" #include "efuse.h" diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c index 177a8e669241..eb61061821e4 100644 --- a/drivers/net/wireless/rtlwifi/pci.c +++ b/drivers/net/wireless/rtlwifi/pci.c @@ -27,6 +27,7 @@ * *****************************************************************************/ +#include #include "core.h" #include "wifi.h" #include "pci.h" diff --git a/drivers/net/wireless/rtlwifi/ps.c b/drivers/net/wireless/rtlwifi/ps.c index a693feffbe72..db5262844543 100644 --- a/drivers/net/wireless/rtlwifi/ps.c +++ b/drivers/net/wireless/rtlwifi/ps.c @@ -27,6 +27,7 @@ * *****************************************************************************/ +#include #include "wifi.h" #include "base.h" #include "ps.h" diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c index a00774e7090d..72a98cab6f69 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/dm_common.c @@ -27,6 +27,7 @@ * *****************************************************************************/ +#include #include "dm_common.h" #include "phy_common.h" #include "../pci.h" diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c index 49a064bdbce6..950c65a15b8a 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c @@ -30,6 +30,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include +#include #include "../wifi.h" #include "../pci.h" #include "../base.h" diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c index 3b11642d3f7d..1f07558debf2 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/phy_common.c @@ -27,6 +27,7 @@ * *****************************************************************************/ +#include #include "../wifi.h" #include "../rtl8192ce/reg.h" #include "../rtl8192ce/def.h" diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c index b42c2e2b2055..54cb8a60514d 100644 --- a/drivers/net/wireless/rtlwifi/usb.c +++ b/drivers/net/wireless/rtlwifi/usb.c @@ -28,6 +28,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include +#include #include "core.h" #include "wifi.h" #include "usb.h" diff --git a/drivers/net/wireless/wl12xx/boot.c b/drivers/net/wireless/wl12xx/boot.c index d4e628db76b0..681337914976 100644 --- a/drivers/net/wireless/wl12xx/boot.c +++ b/drivers/net/wireless/wl12xx/boot.c @@ -23,6 +23,7 @@ #include #include +#include #include "acx.h" #include "reg.h" -- cgit v1.2.3 From ac5c24e9e613df556f054f1fa811fca0c24fe500 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Tue, 30 Aug 2011 14:18:44 -0400 Subject: drivers/net: change moduleparam.h to module.h as required. Signed-off-by: Paul Gortmaker --- drivers/net/wireless/b43/main.c | 2 +- drivers/net/wireless/b43legacy/main.c | 2 +- drivers/net/wireless/libertas/if_sdio.c | 2 +- drivers/net/wireless/libertas/if_spi.c | 2 +- drivers/net/wireless/libertas/if_usb.c | 2 +- drivers/net/wireless/libertas/main.c | 2 +- drivers/net/wireless/libertas_tf/if_usb.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c index 7cf4125a1624..5634d9a9965b 100644 --- a/drivers/net/wireless/b43/main.c +++ b/drivers/net/wireless/b43/main.c @@ -34,7 +34,7 @@ #include #include -#include +#include #include #include #include diff --git a/drivers/net/wireless/b43legacy/main.c b/drivers/net/wireless/b43legacy/main.c index a3b72cd72c66..20f02437af8c 100644 --- a/drivers/net/wireless/b43legacy/main.c +++ b/drivers/net/wireless/b43legacy/main.c @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include #include diff --git a/drivers/net/wireless/libertas/if_sdio.c b/drivers/net/wireless/libertas/if_sdio.c index c962e21762dc..9804ebc892d4 100644 --- a/drivers/net/wireless/libertas/if_sdio.c +++ b/drivers/net/wireless/libertas/if_sdio.c @@ -29,7 +29,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include -#include +#include #include #include #include diff --git a/drivers/net/wireless/libertas/if_spi.c b/drivers/net/wireless/libertas/if_spi.c index 622ae6de0d8b..11b69b300dc0 100644 --- a/drivers/net/wireless/libertas/if_spi.c +++ b/drivers/net/wireless/libertas/if_spi.c @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include #include diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c index 8147f1e2a0b0..db879c364ebf 100644 --- a/drivers/net/wireless/libertas/if_usb.c +++ b/drivers/net/wireless/libertas/if_usb.c @@ -5,7 +5,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include -#include +#include #include #include #include diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c index b03779bcd547..4ae99a40dbf7 100644 --- a/drivers/net/wireless/libertas/main.c +++ b/drivers/net/wireless/libertas/main.c @@ -6,7 +6,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -#include +#include #include #include #include diff --git a/drivers/net/wireless/libertas_tf/if_usb.c b/drivers/net/wireless/libertas_tf/if_usb.c index ba7d96584cb6..68202e63873a 100644 --- a/drivers/net/wireless/libertas_tf/if_usb.c +++ b/drivers/net/wireless/libertas_tf/if_usb.c @@ -15,7 +15,7 @@ #include "if_usb.h" #include -#include +#include #include #include #include -- cgit v1.2.3 From 6eb07caf1ac5723720caea2ee93cd11b7058a0aa Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Thu, 15 Sep 2011 19:46:05 -0400 Subject: drivers/net: Add moduleparam.h to drivers as required. These files were using moduleparam infrastructure, but were not including anything for it -- which is fine when module.h is being implicitly included in all files, but that is going away. Signed-off-by: Paul Gortmaker --- drivers/net/ethernet/mellanox/mlx4/en_tx.c | 1 + drivers/net/ethernet/sfc/rx.c | 1 + drivers/net/wimax/i2400m/control.c | 1 + drivers/net/wimax/i2400m/rx.c | 1 + drivers/net/wireless/ath/ath5k/debug.c | 1 + drivers/net/wireless/ath/ath6kl/cfg80211.c | 2 ++ drivers/net/wireless/ath/ath9k/ar9002_hw.c | 1 + drivers/net/wireless/hostap/hostap_ap.c | 1 + drivers/net/wireless/iwmc3200wifi/commands.c | 1 + drivers/net/wireless/iwmc3200wifi/main.c | 1 + 10 files changed, 11 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c index 90f2cd24faac..d901b4267537 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c @@ -39,6 +39,7 @@ #include #include #include +#include #include "mlx4_en.h" diff --git a/drivers/net/ethernet/sfc/rx.c b/drivers/net/ethernet/sfc/rx.c index adbda182f159..752d521c09b1 100644 --- a/drivers/net/ethernet/sfc/rx.c +++ b/drivers/net/ethernet/sfc/rx.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include "net_driver.h" diff --git a/drivers/net/wimax/i2400m/control.c b/drivers/net/wimax/i2400m/control.c index ec4147a02017..2fea02b35b2d 100644 --- a/drivers/net/wimax/i2400m/control.c +++ b/drivers/net/wimax/i2400m/control.c @@ -79,6 +79,7 @@ #include #include #include +#include #define D_SUBMODULE control diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c index 9ed741b6a36f..37becfcc98f2 100644 --- a/drivers/net/wimax/i2400m/rx.c +++ b/drivers/net/wimax/i2400m/rx.c @@ -150,6 +150,7 @@ #include #include #include +#include #include "i2400m.h" diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c index a8a72b32328e..d2bdd905a4f7 100644 --- a/drivers/net/wireless/ath/ath5k/debug.c +++ b/drivers/net/wireless/ath/ath5k/debug.c @@ -58,6 +58,7 @@ * THE POSSIBILITY OF SUCH DAMAGES. */ #include +#include #include #include diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 3aff36bad5d3..f517eb8f7b44 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c @@ -14,6 +14,8 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include + #include "core.h" #include "cfg80211.h" #include "debug.h" diff --git a/drivers/net/wireless/ath/ath9k/ar9002_hw.c b/drivers/net/wireless/ath/ath9k/ar9002_hw.c index 626d547d2f06..11f192a1ceb7 100644 --- a/drivers/net/wireless/ath/ath9k/ar9002_hw.c +++ b/drivers/net/wireless/ath/ath9k/ar9002_hw.c @@ -14,6 +14,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include #include "hw.h" #include "ar5008_initvals.h" #include "ar9001_initvals.h" diff --git a/drivers/net/wireless/hostap/hostap_ap.c b/drivers/net/wireless/hostap/hostap_ap.c index f5f9c8c6edd1..e1f410277242 100644 --- a/drivers/net/wireless/hostap/hostap_ap.c +++ b/drivers/net/wireless/hostap/hostap_ap.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "hostap_wlan.h" #include "hostap.h" diff --git a/drivers/net/wireless/iwmc3200wifi/commands.c b/drivers/net/wireless/iwmc3200wifi/commands.c index 50dee6a0a5ca..bd75078c454b 100644 --- a/drivers/net/wireless/iwmc3200wifi/commands.c +++ b/drivers/net/wireless/iwmc3200wifi/commands.c @@ -42,6 +42,7 @@ #include #include #include +#include #include "iwm.h" #include "bus.h" diff --git a/drivers/net/wireless/iwmc3200wifi/main.c b/drivers/net/wireless/iwmc3200wifi/main.c index 362002735b12..98a179f98ea1 100644 --- a/drivers/net/wireless/iwmc3200wifi/main.c +++ b/drivers/net/wireless/iwmc3200wifi/main.c @@ -42,6 +42,7 @@ #include #include #include +#include #include "iwm.h" #include "debug.h" -- cgit v1.2.3 From d0e88ec90151c52ca9aa67adece8f2b8bd3c9f3b Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Thu, 29 Sep 2011 16:37:30 -0400 Subject: drivers/net: wireless/ath/ath5k/debug.c does not need module.h It only has module_param and EXPORT_SYMBOL, so now that export.h is in scope at the same time as the recent ath5k update, we can delete this module.h include. Reported-by: Stephen Rothwell Signed-off-by: Paul Gortmaker --- drivers/net/wireless/ath/ath5k/debug.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c index d2bdd905a4f7..8c5ce8b0c734 100644 --- a/drivers/net/wireless/ath/ath5k/debug.c +++ b/drivers/net/wireless/ath/ath5k/debug.c @@ -60,7 +60,6 @@ #include #include -#include #include #include #include "debug.h" -- cgit v1.2.3 From 452962366c11a9126fabac8cb28af49c27464408 Mon Sep 17 00:00:00 2001 From: Paul Gortmaker Date: Tue, 30 Aug 2011 17:50:46 -0400 Subject: staging: Add module.h to more drivers implicitly using it. This 2nd batch of implicit module.h users only appeared when we removed the unnecessary module.h from include/linux/miscdevice.h [The 1st batch is already present in Greg's staging tree.] Signed-off-by: Paul Gortmaker --- drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c | 1 + drivers/staging/cxt1e1/linux.c | 1 + drivers/staging/gma500/psb_drv.c | 1 + drivers/staging/iio/adc/ad7793.c | 1 + drivers/staging/iio/dac/ad5686.c | 1 + drivers/staging/iio/gyro/adis16060_core.c | 1 + drivers/staging/intel_sst/intel_sst.c | 1 + drivers/staging/usbip/usbip_common.c | 1 + drivers/staging/winbond/wbusb.c | 1 + drivers/staging/wlags49_h2/wl_cs.c | 1 + 10 files changed, 10 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c index ac8d02bd34f2..0d8a9cdf897a 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include "nicpci.h" diff --git a/drivers/staging/cxt1e1/linux.c b/drivers/staging/cxt1e1/linux.c index 24e009c0149b..911c0e4375fd 100644 --- a/drivers/staging/cxt1e1/linux.c +++ b/drivers/staging/cxt1e1/linux.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include diff --git a/drivers/staging/gma500/psb_drv.c b/drivers/staging/gma500/psb_drv.c index dc676c2ce810..986a04d16ba8 100644 --- a/drivers/staging/gma500/psb_drv.c +++ b/drivers/staging/gma500/psb_drv.c @@ -35,6 +35,7 @@ #include #include #include +#include #include static int drm_psb_trap_pagefaults; diff --git a/drivers/staging/iio/adc/ad7793.c b/drivers/staging/iio/adc/ad7793.c index a831b92cd082..999f8f746cff 100644 --- a/drivers/staging/iio/adc/ad7793.c +++ b/drivers/staging/iio/adc/ad7793.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/dac/ad5686.c b/drivers/staging/iio/dac/ad5686.c index 48389e1c19f1..974c6f5b60c4 100644 --- a/drivers/staging/iio/dac/ad5686.c +++ b/drivers/staging/iio/dac/ad5686.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "../iio.h" #include "../sysfs.h" diff --git a/drivers/staging/iio/gyro/adis16060_core.c b/drivers/staging/iio/gyro/adis16060_core.c index 38cf3f4bf726..ff1b5a82b3d6 100644 --- a/drivers/staging/iio/gyro/adis16060_core.c +++ b/drivers/staging/iio/gyro/adis16060_core.c @@ -6,6 +6,7 @@ * Licensed under the GPL-2 or later. */ +#include #include #include #include diff --git a/drivers/staging/intel_sst/intel_sst.c b/drivers/staging/intel_sst/intel_sst.c index c303d85011b0..ff9aaec0557f 100644 --- a/drivers/staging/intel_sst/intel_sst.c +++ b/drivers/staging/intel_sst/intel_sst.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include "intel_sst.h" #include "intel_sst_ioctl.h" diff --git a/drivers/staging/usbip/usbip_common.c b/drivers/staging/usbip/usbip_common.c index f4b53d103c54..3b7a847f4657 100644 --- a/drivers/staging/usbip/usbip_common.c +++ b/drivers/staging/usbip/usbip_common.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "usbip_common.h" diff --git a/drivers/staging/winbond/wbusb.c b/drivers/staging/winbond/wbusb.c index a2e8bd452ed9..f958eb4f0d81 100644 --- a/drivers/staging/winbond/wbusb.c +++ b/drivers/staging/winbond/wbusb.c @@ -11,6 +11,7 @@ */ #include #include +#include #include "core.h" #include "mds_f.h" diff --git a/drivers/staging/wlags49_h2/wl_cs.c b/drivers/staging/wlags49_h2/wl_cs.c index 321580267fed..2faee2dd4bb1 100644 --- a/drivers/staging/wlags49_h2/wl_cs.c +++ b/drivers/staging/wlags49_h2/wl_cs.c @@ -82,6 +82,7 @@ #include #include #include +#include #include #include -- cgit v1.2.3 From b9075fa968a0a4347aef35e235e2995c0e57dddd Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Mon, 31 Oct 2011 17:11:33 -0700 Subject: treewide: use __printf not __attribute__((format(printf,...))) Standardize the style for compiler based printf format verification. Standardized the location of __printf too. Done via script and a little typing. $ grep -rPl --include=*.[ch] -w "__attribute__" * | \ grep -vP "^(tools|scripts|include/linux/compiler-gcc.h)" | \ xargs perl -n -i -e 'local $/; while (<>) { s/\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf\s*,\s*(.+)\s*,\s*(.+)\s*\)\s*\)\s*\)/__printf($1, $2)/g ; print; }' [akpm@linux-foundation.org: revert arch bits] Signed-off-by: Joe Perches Cc: "Kirill A. Shutemov" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/isdn/hisax/callc.c | 4 +- drivers/isdn/hisax/hisax.h | 4 +- drivers/isdn/hisax/isdnl1.h | 2 +- drivers/isdn/hisax/isdnl3.c | 2 +- drivers/isdn/hisax/st5481_d.c | 4 +- drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 3 +- drivers/net/wireless/ath/ath.h | 5 +- drivers/net/wireless/ath/ath5k/debug.h | 4 +- drivers/net/wireless/ath/ath6kl/debug.h | 4 +- drivers/net/wireless/b43/b43.h | 12 +-- drivers/net/wireless/b43legacy/b43legacy.h | 16 ++-- drivers/staging/iio/trigger.h | 3 +- fs/ecryptfs/ecryptfs_kernel.h | 2 +- fs/ext2/ext2.h | 8 +- fs/ext4/ext4.h | 44 +++++------ fs/fat/fat.h | 9 +-- fs/gfs2/glock.h | 2 +- fs/hpfs/hpfs_fn.h | 4 +- fs/nilfs2/nilfs.h | 8 +- fs/ntfs/debug.h | 15 ++-- fs/ocfs2/super.h | 14 ++-- fs/partitions/ldm.c | 16 ++-- fs/udf/udfdecl.h | 4 +- fs/ufs/ufs.h | 9 ++- fs/xfs/xfs_message.h | 42 +++++----- include/asm-generic/bug.h | 11 +-- include/drm/drmP.h | 10 +-- include/linux/audit.h | 11 ++- include/linux/blktrace_api.h | 2 +- include/linux/device.h | 110 +++++++++++++-------------- include/linux/dynamic_debug.h | 19 +++-- include/linux/ext3_fs.h | 16 ++-- include/linux/fs.h | 4 +- include/linux/fscache-cache.h | 8 +- include/linux/gameport.h | 8 +- include/linux/kallsyms.h | 5 +- include/linux/kdb.h | 9 +-- include/linux/kernel.h | 44 +++++------ include/linux/kexec.h | 4 +- include/linux/kmod.h | 4 +- include/linux/kobject.h | 26 +++---- include/linux/kthread.h | 4 +- include/linux/libata.h | 18 ++--- include/linux/mmiotrace.h | 8 +- include/linux/netdevice.h | 34 ++++----- include/linux/printk.h | 12 +-- include/linux/quotaops.h | 2 +- include/linux/seq_file.h | 3 +- include/linux/trace_seq.h | 8 +- include/net/bluetooth/bluetooth.h | 2 +- include/net/netfilter/nf_log.h | 3 +- include/net/sock.h | 4 +- include/sound/core.h | 4 +- include/sound/info.h | 4 +- include/sound/seq_kernel.h | 4 +- include/xen/hvc-console.h | 4 +- include/xen/xenbus.h | 12 +-- net/nfc/nfc.h | 2 +- net/rds/rds.h | 8 +- net/sunrpc/svc.c | 5 +- sound/firewire/cmp.c | 2 +- 61 files changed, 324 insertions(+), 350 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/isdn/hisax/callc.c b/drivers/isdn/hisax/callc.c index 37e685eafd24..c4897e1075d8 100644 --- a/drivers/isdn/hisax/callc.c +++ b/drivers/isdn/hisax/callc.c @@ -65,7 +65,7 @@ hisax_findcard(int driverid) return (struct IsdnCardState *) 0; } -static __attribute__((format(printf, 3, 4))) void +static __printf(3, 4) void link_debug(struct Channel *chanp, int direction, char *fmt, ...) { va_list args; @@ -1068,7 +1068,7 @@ init_d_st(struct Channel *chanp) return 0; } -static __attribute__((format(printf, 2, 3))) void +static __printf(2, 3) void callc_debug(struct FsmInst *fi, char *fmt, ...) { va_list args; diff --git a/drivers/isdn/hisax/hisax.h b/drivers/isdn/hisax/hisax.h index 0a5c42a3f125..aff45a11a92d 100644 --- a/drivers/isdn/hisax/hisax.h +++ b/drivers/isdn/hisax/hisax.h @@ -1287,9 +1287,9 @@ int jiftime(char *s, long mark); int HiSax_command(isdn_ctrl * ic); int HiSax_writebuf_skb(int id, int chan, int ack, struct sk_buff *skb); -__attribute__((format(printf, 3, 4))) +__printf(3, 4) void HiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, ...); -__attribute__((format(printf, 3, 0))) +__printf(3, 0) void VHiSax_putstatus(struct IsdnCardState *cs, char *head, char *fmt, va_list args); void HiSax_reportcard(int cardnr, int sel); int QuickHex(char *txt, u_char * p, int cnt); diff --git a/drivers/isdn/hisax/isdnl1.h b/drivers/isdn/hisax/isdnl1.h index 425d86116f2b..66ddcab19bba 100644 --- a/drivers/isdn/hisax/isdnl1.h +++ b/drivers/isdn/hisax/isdnl1.h @@ -21,7 +21,7 @@ #define B_XMTBUFREADY 1 #define B_ACKPENDING 2 -__attribute__((format(printf, 2, 3))) +__printf(2, 3) void debugl1(struct IsdnCardState *cs, char *fmt, ...); void DChannel_proc_xmt(struct IsdnCardState *cs); void DChannel_proc_rcv(struct IsdnCardState *cs); diff --git a/drivers/isdn/hisax/isdnl3.c b/drivers/isdn/hisax/isdnl3.c index ad291f21b201..1c24e4457b6f 100644 --- a/drivers/isdn/hisax/isdnl3.c +++ b/drivers/isdn/hisax/isdnl3.c @@ -66,7 +66,7 @@ static char *strL3Event[] = "EV_TIMEOUT", }; -static __attribute__((format(printf, 2, 3))) void +static __printf(2, 3) void l3m_debug(struct FsmInst *fi, char *fmt, ...) { va_list args; diff --git a/drivers/isdn/hisax/st5481_d.c b/drivers/isdn/hisax/st5481_d.c index 44082637a09f..db247b79e561 100644 --- a/drivers/isdn/hisax/st5481_d.c +++ b/drivers/isdn/hisax/st5481_d.c @@ -167,7 +167,7 @@ static struct FsmNode L1FnList[] __initdata = {ST_L1_F8, EV_IND_RSY, l1_ignore}, }; -static __attribute__((format(printf, 2, 3))) +static __printf(2, 3) void l1m_debug(struct FsmInst *fi, char *fmt, ...) { va_list args; @@ -270,7 +270,7 @@ static char *strDoutEvent[] = "EV_DOUT_UNDERRUN", }; -static __attribute__((format(printf, 2, 3))) +static __printf(2, 3) void dout_debug(struct FsmInst *fi, char *fmt, ...) { va_list args; diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h index fca66165110e..8fda331c65df 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h @@ -581,8 +581,9 @@ extern const struct ethtool_ops mlx4_en_ethtool_ops; * printk / logging functions */ +__printf(3, 4) int en_print(const char *level, const struct mlx4_en_priv *priv, - const char *format, ...) __attribute__ ((format (printf, 3, 4))); + const char *format, ...); #define en_dbg(mlevel, priv, format, arg...) \ do { \ diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h index 908fdbc3e0ee..0f9ee46cfc97 100644 --- a/drivers/net/wireless/ath/ath.h +++ b/drivers/net/wireless/ath/ath.h @@ -173,8 +173,7 @@ bool ath_hw_keyreset(struct ath_common *common, u16 entry); void ath_hw_cycle_counters_update(struct ath_common *common); int32_t ath_hw_get_listen_time(struct ath_common *common); -extern __attribute__((format (printf, 2, 3))) -void ath_printk(const char *level, const char *fmt, ...); +extern __printf(2, 3) void ath_printk(const char *level, const char *fmt, ...); #define _ath_printk(level, common, fmt, ...) \ do { \ @@ -258,7 +257,7 @@ do { \ #else -static inline __attribute__((format (printf, 3, 4))) +static inline __attribute__ ((format (printf, 3, 4))) void ath_dbg(struct ath_common *common, enum ATH_DEBUG dbg_mask, const char *fmt, ...) { diff --git a/drivers/net/wireless/ath/ath5k/debug.h b/drivers/net/wireless/ath/ath5k/debug.h index 7f37df3125fd..0a3f916a1ef3 100644 --- a/drivers/net/wireless/ath/ath5k/debug.h +++ b/drivers/net/wireless/ath/ath5k/debug.h @@ -141,10 +141,10 @@ ath5k_debug_printtxbuf(struct ath5k_hw *ah, struct ath5k_buf *bf); #include -static inline void __attribute__ ((format (printf, 3, 4))) +static inline __printf(3, 4) void ATH5K_DBG(struct ath5k_hw *ah, unsigned int m, const char *fmt, ...) {} -static inline void __attribute__ ((format (printf, 3, 4))) +static inline __printf(3, 4) void ATH5K_DBG_UNLIMIT(struct ath5k_hw *ah, unsigned int m, const char *fmt, ...) {} diff --git a/drivers/net/wireless/ath/ath6kl/debug.h b/drivers/net/wireless/ath/ath6kl/debug.h index 9288a3ce1e39..7b7675f70a10 100644 --- a/drivers/net/wireless/ath/ath6kl/debug.h +++ b/drivers/net/wireless/ath/ath6kl/debug.h @@ -44,8 +44,8 @@ enum ATH6K_DEBUG_MASK { }; extern unsigned int debug_mask; -extern int ath6kl_printk(const char *level, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); +extern __printf(2, 3) +int ath6kl_printk(const char *level, const char *fmt, ...); #define ath6kl_info(fmt, ...) \ ath6kl_printk(KERN_INFO, fmt, ##__VA_ARGS__) diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h index 447a2307c9d9..37110dfd2c96 100644 --- a/drivers/net/wireless/b43/b43.h +++ b/drivers/net/wireless/b43/b43.h @@ -1011,14 +1011,10 @@ static inline bool b43_using_pio_transfers(struct b43_wldev *dev) } /* Message printing */ -void b43info(struct b43_wl *wl, const char *fmt, ...) - __attribute__ ((format(printf, 2, 3))); -void b43err(struct b43_wl *wl, const char *fmt, ...) - __attribute__ ((format(printf, 2, 3))); -void b43warn(struct b43_wl *wl, const char *fmt, ...) - __attribute__ ((format(printf, 2, 3))); -void b43dbg(struct b43_wl *wl, const char *fmt, ...) - __attribute__ ((format(printf, 2, 3))); +__printf(2, 3) void b43info(struct b43_wl *wl, const char *fmt, ...); +__printf(2, 3) void b43err(struct b43_wl *wl, const char *fmt, ...); +__printf(2, 3) void b43warn(struct b43_wl *wl, const char *fmt, ...); +__printf(2, 3) void b43dbg(struct b43_wl *wl, const char *fmt, ...); /* A WARN_ON variant that vanishes when b43 debugging is disabled. diff --git a/drivers/net/wireless/b43legacy/b43legacy.h b/drivers/net/wireless/b43legacy/b43legacy.h index 12b518251581..1d4fc9db7f5e 100644 --- a/drivers/net/wireless/b43legacy/b43legacy.h +++ b/drivers/net/wireless/b43legacy/b43legacy.h @@ -810,15 +810,15 @@ struct b43legacy_lopair *b43legacy_get_lopair(struct b43legacy_phy *phy, /* Message printing */ -void b43legacyinfo(struct b43legacy_wl *wl, const char *fmt, ...) - __attribute__((format(printf, 2, 3))); -void b43legacyerr(struct b43legacy_wl *wl, const char *fmt, ...) - __attribute__((format(printf, 2, 3))); -void b43legacywarn(struct b43legacy_wl *wl, const char *fmt, ...) - __attribute__((format(printf, 2, 3))); +__printf(2, 3) +void b43legacyinfo(struct b43legacy_wl *wl, const char *fmt, ...); +__printf(2, 3) +void b43legacyerr(struct b43legacy_wl *wl, const char *fmt, ...); +__printf(2, 3) +void b43legacywarn(struct b43legacy_wl *wl, const char *fmt, ...); #if B43legacy_DEBUG -void b43legacydbg(struct b43legacy_wl *wl, const char *fmt, ...) - __attribute__((format(printf, 2, 3))); +__printf(2, 3) +void b43legacydbg(struct b43legacy_wl *wl, const char *fmt, ...); #else /* DEBUG */ # define b43legacydbg(wl, fmt...) do { /* nothing */ } while (0) #endif /* DEBUG */ diff --git a/drivers/staging/iio/trigger.h b/drivers/staging/iio/trigger.h index 598fcb3599f9..5cc42a655c88 100644 --- a/drivers/staging/iio/trigger.h +++ b/drivers/staging/iio/trigger.h @@ -115,8 +115,7 @@ void iio_trigger_poll_chained(struct iio_trigger *trig, s64 time); irqreturn_t iio_trigger_generic_data_rdy_poll(int irq, void *private); -struct iio_trigger *iio_allocate_trigger(const char *fmt, ...) - __attribute__((format(printf, 1, 2))); +__printf(1, 2) struct iio_trigger *iio_allocate_trigger(const char *fmt, ...); void iio_free_trigger(struct iio_trigger *trig); #endif /* _IIO_TRIGGER_H_ */ diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h index b36c5572b3f3..54481a3b2c79 100644 --- a/fs/ecryptfs/ecryptfs_kernel.h +++ b/fs/ecryptfs/ecryptfs_kernel.h @@ -514,7 +514,7 @@ ecryptfs_set_dentry_lower_mnt(struct dentry *dentry, struct vfsmount *lower_mnt) #define ecryptfs_printk(type, fmt, arg...) \ __ecryptfs_printk(type "%s: " fmt, __func__, ## arg); -__attribute__ ((format(printf, 1, 2))) +__printf(1, 2) void __ecryptfs_printk(const char *fmt, ...); extern const struct file_operations ecryptfs_main_fops; diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h index af9fc89b1b2d..9a4e5e206d08 100644 --- a/fs/ext2/ext2.h +++ b/fs/ext2/ext2.h @@ -135,10 +135,10 @@ extern long ext2_compat_ioctl(struct file *, unsigned int, unsigned long); struct dentry *ext2_get_parent(struct dentry *child); /* super.c */ -extern void ext2_error (struct super_block *, const char *, const char *, ...) - __attribute__ ((format (printf, 3, 4))); -extern void ext2_msg(struct super_block *, const char *, const char *, ...) - __attribute__ ((format (printf, 3, 4))); +extern __printf(3, 4) +void ext2_error(struct super_block *, const char *, const char *, ...); +extern __printf(3, 4) +void ext2_msg(struct super_block *, const char *, const char *, ...); extern void ext2_update_dynamic_rev (struct super_block *sb); extern void ext2_write_super (struct super_block *); diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index b7d7bd0f066e..cec3145e532c 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1878,40 +1878,40 @@ extern int ext4_group_extend(struct super_block *sb, extern void *ext4_kvmalloc(size_t size, gfp_t flags); extern void *ext4_kvzalloc(size_t size, gfp_t flags); extern void ext4_kvfree(void *ptr); -extern void __ext4_error(struct super_block *, const char *, unsigned int, - const char *, ...) - __attribute__ ((format (printf, 4, 5))); +extern __printf(4, 5) +void __ext4_error(struct super_block *, const char *, unsigned int, + const char *, ...); #define ext4_error(sb, message...) __ext4_error(sb, __func__, \ __LINE__, ## message) -extern void ext4_error_inode(struct inode *, const char *, unsigned int, - ext4_fsblk_t, const char *, ...) - __attribute__ ((format (printf, 5, 6))); -extern void ext4_error_file(struct file *, const char *, unsigned int, - ext4_fsblk_t, const char *, ...) - __attribute__ ((format (printf, 5, 6))); +extern __printf(5, 6) +void ext4_error_inode(struct inode *, const char *, unsigned int, ext4_fsblk_t, + const char *, ...); +extern __printf(5, 6) +void ext4_error_file(struct file *, const char *, unsigned int, ext4_fsblk_t, + const char *, ...); extern void __ext4_std_error(struct super_block *, const char *, unsigned int, int); -extern void __ext4_abort(struct super_block *, const char *, unsigned int, - const char *, ...) - __attribute__ ((format (printf, 4, 5))); +extern __printf(4, 5) +void __ext4_abort(struct super_block *, const char *, unsigned int, + const char *, ...); #define ext4_abort(sb, message...) __ext4_abort(sb, __func__, \ __LINE__, ## message) -extern void __ext4_warning(struct super_block *, const char *, unsigned int, - const char *, ...) - __attribute__ ((format (printf, 4, 5))); +extern __printf(4, 5) +void __ext4_warning(struct super_block *, const char *, unsigned int, + const char *, ...); #define ext4_warning(sb, message...) __ext4_warning(sb, __func__, \ __LINE__, ## message) -extern void ext4_msg(struct super_block *, const char *, const char *, ...) - __attribute__ ((format (printf, 3, 4))); +extern __printf(3, 4) +void ext4_msg(struct super_block *, const char *, const char *, ...); extern void __dump_mmp_msg(struct super_block *, struct mmp_struct *mmp, const char *, unsigned int, const char *); #define dump_mmp_msg(sb, mmp, msg) __dump_mmp_msg(sb, mmp, __func__, \ __LINE__, msg) -extern void __ext4_grp_locked_error(const char *, unsigned int, \ - struct super_block *, ext4_group_t, \ - unsigned long, ext4_fsblk_t, \ - const char *, ...) - __attribute__ ((format (printf, 7, 8))); +extern __printf(7, 8) +void __ext4_grp_locked_error(const char *, unsigned int, + struct super_block *, ext4_group_t, + unsigned long, ext4_fsblk_t, + const char *, ...); #define ext4_grp_locked_error(sb, grp, message...) \ __ext4_grp_locked_error(__func__, __LINE__, (sb), (grp), ## message) extern void ext4_update_dynamic_rev(struct super_block *sb); diff --git a/fs/fat/fat.h b/fs/fat/fat.h index a5d3853822e0..1510a4d51990 100644 --- a/fs/fat/fat.h +++ b/fs/fat/fat.h @@ -326,15 +326,14 @@ extern int fat_fill_super(struct super_block *sb, void *data, int silent, extern int fat_flush_inodes(struct super_block *sb, struct inode *i1, struct inode *i2); /* fat/misc.c */ -extern void -__fat_fs_error(struct super_block *sb, int report, const char *fmt, ...) - __attribute__ ((format (printf, 3, 4))) __cold; +extern __printf(3, 4) __cold +void __fat_fs_error(struct super_block *sb, int report, const char *fmt, ...); #define fat_fs_error(sb, fmt, args...) \ __fat_fs_error(sb, 1, fmt , ## args) #define fat_fs_error_ratelimit(sb, fmt, args...) \ __fat_fs_error(sb, __ratelimit(&MSDOS_SB(sb)->ratelimit), fmt , ## args) -void fat_msg(struct super_block *sb, const char *level, const char *fmt, ...) - __attribute__ ((format (printf, 3, 4))) __cold; +__printf(3, 4) __cold +void fat_msg(struct super_block *sb, const char *level, const char *fmt, ...); extern int fat_clusters_flush(struct super_block *sb); extern int fat_chain_add(struct inode *inode, int new_dclus, int nr_cluster); extern void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec *ts, diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h index 66707118af25..2553b858a72e 100644 --- a/fs/gfs2/glock.h +++ b/fs/gfs2/glock.h @@ -201,7 +201,7 @@ int gfs2_glock_nq_m(unsigned int num_gh, struct gfs2_holder *ghs); void gfs2_glock_dq_m(unsigned int num_gh, struct gfs2_holder *ghs); void gfs2_glock_dq_uninit_m(unsigned int num_gh, struct gfs2_holder *ghs); -__attribute__ ((format(printf, 2, 3))) +__printf(2, 3) void gfs2_print_dbg(struct seq_file *seq, const char *fmt, ...); /** diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h index 331b5e234ef3..de946170ebb1 100644 --- a/fs/hpfs/hpfs_fn.h +++ b/fs/hpfs/hpfs_fn.h @@ -311,8 +311,8 @@ static inline struct hpfs_sb_info *hpfs_sb(struct super_block *sb) /* super.c */ -void hpfs_error(struct super_block *, const char *, ...) - __attribute__((format (printf, 2, 3))); +__printf(2, 3) +void hpfs_error(struct super_block *, const char *, ...); int hpfs_stop_cycles(struct super_block *, int, int *, int *, char *); unsigned hpfs_count_one_bitmap(struct super_block *, secno); diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h index 255d5e1c03b7..3777d138f895 100644 --- a/fs/nilfs2/nilfs.h +++ b/fs/nilfs2/nilfs.h @@ -276,10 +276,10 @@ int nilfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, /* super.c */ extern struct inode *nilfs_alloc_inode(struct super_block *); extern void nilfs_destroy_inode(struct inode *); -extern void nilfs_error(struct super_block *, const char *, const char *, ...) - __attribute__ ((format (printf, 3, 4))); -extern void nilfs_warning(struct super_block *, const char *, const char *, ...) - __attribute__ ((format (printf, 3, 4))); +extern __printf(3, 4) +void nilfs_error(struct super_block *, const char *, const char *, ...); +extern __printf(3, 4) +void nilfs_warning(struct super_block *, const char *, const char *, ...); extern struct nilfs_super_block * nilfs_read_super_block(struct super_block *, u64, int, struct buffer_head **); extern int nilfs_store_magic_and_option(struct super_block *, diff --git a/fs/ntfs/debug.h b/fs/ntfs/debug.h index 2142b1c68b61..53c27eaf2307 100644 --- a/fs/ntfs/debug.h +++ b/fs/ntfs/debug.h @@ -30,8 +30,9 @@ extern int debug_msgs; -extern void __ntfs_debug(const char *file, int line, const char *function, - const char *format, ...) __attribute__ ((format (printf, 4, 5))); +extern __printf(4, 5) +void __ntfs_debug(const char *file, int line, const char *function, + const char *format, ...); /** * ntfs_debug - write a debug level message to syslog * @f: a printf format string containing the message @@ -52,12 +53,14 @@ extern void ntfs_debug_dump_runlist(const runlist_element *rl); #endif /* !DEBUG */ -extern void __ntfs_warning(const char *function, const struct super_block *sb, - const char *fmt, ...) __attribute__ ((format (printf, 3, 4))); +extern __printf(3, 4) +void __ntfs_warning(const char *function, const struct super_block *sb, + const char *fmt, ...); #define ntfs_warning(sb, f, a...) __ntfs_warning(__func__, sb, f, ##a) -extern void __ntfs_error(const char *function, const struct super_block *sb, - const char *fmt, ...) __attribute__ ((format (printf, 3, 4))); +extern __printf(3, 4) +void __ntfs_error(const char *function, const struct super_block *sb, + const char *fmt, ...); #define ntfs_error(sb, f, a...) __ntfs_error(__func__, sb, f, ##a) #endif /* _LINUX_NTFS_DEBUG_H */ diff --git a/fs/ocfs2/super.h b/fs/ocfs2/super.h index 40c7de084c10..74ff74cf78fe 100644 --- a/fs/ocfs2/super.h +++ b/fs/ocfs2/super.h @@ -31,17 +31,15 @@ extern struct workqueue_struct *ocfs2_wq; int ocfs2_publish_get_mount_state(struct ocfs2_super *osb, int node_num); -void __ocfs2_error(struct super_block *sb, - const char *function, - const char *fmt, ...) - __attribute__ ((format (printf, 3, 4))); +__printf(3, 4) +void __ocfs2_error(struct super_block *sb, const char *function, + const char *fmt, ...); #define ocfs2_error(sb, fmt, args...) __ocfs2_error(sb, __PRETTY_FUNCTION__, fmt, ##args) -void __ocfs2_abort(struct super_block *sb, - const char *function, - const char *fmt, ...) - __attribute__ ((format (printf, 3, 4))); +__printf(3, 4) +void __ocfs2_abort(struct super_block *sb, const char *function, + const char *fmt, ...); #define ocfs2_abort(sb, fmt, args...) __ocfs2_abort(sb, __PRETTY_FUNCTION__, fmt, ##args) diff --git a/fs/partitions/ldm.c b/fs/partitions/ldm.c index af9fdf046769..bd8ae788f689 100644 --- a/fs/partitions/ldm.c +++ b/fs/partitions/ldm.c @@ -49,18 +49,20 @@ #define ldm_error(f, a...) _ldm_printk (KERN_ERR, __func__, f, ##a) #define ldm_info(f, a...) _ldm_printk (KERN_INFO, __func__, f, ##a) -__attribute__ ((format (printf, 3, 4))) -static void _ldm_printk (const char *level, const char *function, - const char *fmt, ...) +static __printf(3, 4) +void _ldm_printk(const char *level, const char *function, const char *fmt, ...) { - static char buf[128]; + struct va_format vaf; va_list args; va_start (args, fmt); - vsnprintf (buf, sizeof (buf), fmt, args); - va_end (args); - printk ("%s%s(): %s\n", level, function, buf); + vaf.fmt = fmt; + vaf.va = &args; + + printk("%s%s(): %pV\n", level, function, &vaf); + + va_end(args); } /** diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h index dbd52d4b5eed..dc8a8dcc5ae1 100644 --- a/fs/udf/udfdecl.h +++ b/fs/udf/udfdecl.h @@ -112,8 +112,8 @@ struct extent_position { /* super.c */ -__attribute__((format(printf, 3, 4))) -extern void udf_warning(struct super_block *, const char *, const char *, ...); +extern __printf(3, 4) void udf_warning(struct super_block *, const char *, + const char *, ...); static inline void udf_updated_lvid(struct super_block *sb) { struct buffer_head *bh = UDF_SB(sb)->s_lvid_bh; diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h index 5be2755dd715..c26f2bcec264 100644 --- a/fs/ufs/ufs.h +++ b/fs/ufs/ufs.h @@ -117,9 +117,12 @@ extern int ufs_getfrag_block (struct inode *inode, sector_t fragment, struct buf extern const struct file_operations ufs_dir_operations; /* super.c */ -extern void ufs_warning (struct super_block *, const char *, const char *, ...) __attribute__ ((format (printf, 3, 4))); -extern void ufs_error (struct super_block *, const char *, const char *, ...) __attribute__ ((format (printf, 3, 4))); -extern void ufs_panic (struct super_block *, const char *, const char *, ...) __attribute__ ((format (printf, 3, 4))); +extern __printf(3, 4) +void ufs_warning(struct super_block *, const char *, const char *, ...); +extern __printf(3, 4) +void ufs_error(struct super_block *, const char *, const char *, ...); +extern __printf(3, 4) +void ufs_panic(struct super_block *, const char *, const char *, ...); /* symlink.c */ extern const struct inode_operations ufs_fast_symlink_inode_operations; diff --git a/fs/xfs/xfs_message.h b/fs/xfs/xfs_message.h index 7fb7ea007672..56dc0c17f16a 100644 --- a/fs/xfs/xfs_message.h +++ b/fs/xfs/xfs_message.h @@ -3,31 +3,29 @@ struct xfs_mount; -extern void xfs_emerg(const struct xfs_mount *mp, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); -extern void xfs_alert(const struct xfs_mount *mp, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); -extern void xfs_alert_tag(const struct xfs_mount *mp, int tag, - const char *fmt, ...) - __attribute__ ((format (printf, 3, 4))); -extern void xfs_crit(const struct xfs_mount *mp, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); -extern void xfs_err(const struct xfs_mount *mp, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); -extern void xfs_warn(const struct xfs_mount *mp, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); -extern void xfs_notice(const struct xfs_mount *mp, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); -extern void xfs_info(const struct xfs_mount *mp, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); +extern __printf(2, 3) +void xfs_emerg(const struct xfs_mount *mp, const char *fmt, ...); +extern __printf(2, 3) +void xfs_alert(const struct xfs_mount *mp, const char *fmt, ...); +extern __printf(3, 4) +void xfs_alert_tag(const struct xfs_mount *mp, int tag, const char *fmt, ...); +extern __printf(2, 3) +void xfs_crit(const struct xfs_mount *mp, const char *fmt, ...); +extern __printf(2, 3) +void xfs_err(const struct xfs_mount *mp, const char *fmt, ...); +extern __printf(2, 3) +void xfs_warn(const struct xfs_mount *mp, const char *fmt, ...); +extern __printf(2, 3) +void xfs_notice(const struct xfs_mount *mp, const char *fmt, ...); +extern __printf(2, 3) +void xfs_info(const struct xfs_mount *mp, const char *fmt, ...); #ifdef DEBUG -extern void xfs_debug(const struct xfs_mount *mp, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); +extern __printf(2, 3) +void xfs_debug(const struct xfs_mount *mp, const char *fmt, ...); #else -static inline void -__attribute__ ((format (printf, 2, 3))) -xfs_debug(const struct xfs_mount *mp, const char *fmt, ...) +static inline __printf(2, 3) +void xfs_debug(const struct xfs_mount *mp, const char *fmt, ...) { } #endif diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index dfb0ec666c94..84458b0c38d1 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h @@ -61,11 +61,12 @@ struct bug_entry { */ #ifndef __WARN_TAINT #ifndef __ASSEMBLY__ -extern void warn_slowpath_fmt(const char *file, const int line, - const char *fmt, ...) __attribute__((format(printf, 3, 4))); -extern void warn_slowpath_fmt_taint(const char *file, const int line, - unsigned taint, const char *fmt, ...) - __attribute__((format(printf, 4, 5))); +extern __printf(3, 4) +void warn_slowpath_fmt(const char *file, const int line, + const char *fmt, ...); +extern __printf(4, 5) +void warn_slowpath_fmt_taint(const char *file, const int line, unsigned taint, + const char *fmt, ...); extern void warn_slowpath_null(const char *file, const int line); #define WANT_WARN_ON_SLOWPATH #endif diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 43538b643560..cf3b446139ea 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -122,12 +122,12 @@ struct drm_device; * using the DRM_DEBUG_KMS and DRM_DEBUG. */ -extern __attribute__((format (printf, 4, 5))) +extern __printf(4, 5) void drm_ut_debug_printk(unsigned int request_level, - const char *prefix, - const char *function_name, - const char *format, ...); -extern __attribute__((format (printf, 2, 3))) + const char *prefix, + const char *function_name, + const char *format, ...); +extern __printf(2, 3) int drm_err(const char *func, const char *format, ...); /***********************************************************************/ diff --git a/include/linux/audit.h b/include/linux/audit.h index 0c8006129fb2..2f81c6f3b630 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -584,14 +584,13 @@ extern int audit_signals; #ifdef CONFIG_AUDIT /* These are defined in audit.c */ /* Public API */ -extern void audit_log(struct audit_context *ctx, gfp_t gfp_mask, - int type, const char *fmt, ...) - __attribute__((format(printf,4,5))); +extern __printf(4, 5) +void audit_log(struct audit_context *ctx, gfp_t gfp_mask, int type, + const char *fmt, ...); extern struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, int type); -extern void audit_log_format(struct audit_buffer *ab, - const char *fmt, ...) - __attribute__((format(printf,2,3))); +extern __printf(2, 3) +void audit_log_format(struct audit_buffer *ab, const char *fmt, ...); extern void audit_log_end(struct audit_buffer *ab); extern int audit_string_contains_control(const char *string, size_t len); diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h index 8e9e4bc6d73b..4d1a0748eaf8 100644 --- a/include/linux/blktrace_api.h +++ b/include/linux/blktrace_api.h @@ -170,7 +170,7 @@ extern void blk_trace_shutdown(struct request_queue *); extern int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev, struct block_device *bdev, struct blk_user_trace_setup *buts); -extern __attribute__((format(printf, 2, 3))) +extern __printf(2, 3) void __trace_note_message(struct blk_trace *, const char *fmt, ...); /** diff --git a/include/linux/device.h b/include/linux/device.h index 85e78fc7d7fd..e88abeecfadf 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -622,8 +622,8 @@ static inline const char *dev_name(const struct device *dev) return kobject_name(&dev->kobj); } -extern int dev_set_name(struct device *dev, const char *name, ...) - __attribute__((format(printf, 2, 3))); +extern __printf(2, 3) +int dev_set_name(struct device *dev, const char *name, ...); #ifdef CONFIG_NUMA static inline int dev_to_node(struct device *dev) @@ -753,10 +753,10 @@ extern struct device *device_create_vargs(struct class *cls, void *drvdata, const char *fmt, va_list vargs); -extern struct device *device_create(struct class *cls, struct device *parent, - dev_t devt, void *drvdata, - const char *fmt, ...) - __attribute__((format(printf, 5, 6))); +extern __printf(5, 6) +struct device *device_create(struct class *cls, struct device *parent, + dev_t devt, void *drvdata, + const char *fmt, ...); extern void device_destroy(struct class *cls, dev_t devt); /* @@ -800,64 +800,56 @@ extern const char *dev_driver_string(const struct device *dev); extern int __dev_printk(const char *level, const struct device *dev, struct va_format *vaf); -extern int dev_printk(const char *level, const struct device *dev, - const char *fmt, ...) - __attribute__ ((format (printf, 3, 4))); -extern int dev_emerg(const struct device *dev, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); -extern int dev_alert(const struct device *dev, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); -extern int dev_crit(const struct device *dev, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); -extern int dev_err(const struct device *dev, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); -extern int dev_warn(const struct device *dev, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); -extern int dev_notice(const struct device *dev, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); -extern int _dev_info(const struct device *dev, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); +extern __printf(3, 4) +int dev_printk(const char *level, const struct device *dev, + const char *fmt, ...) + ; +extern __printf(2, 3) +int dev_emerg(const struct device *dev, const char *fmt, ...); +extern __printf(2, 3) +int dev_alert(const struct device *dev, const char *fmt, ...); +extern __printf(2, 3) +int dev_crit(const struct device *dev, const char *fmt, ...); +extern __printf(2, 3) +int dev_err(const struct device *dev, const char *fmt, ...); +extern __printf(2, 3) +int dev_warn(const struct device *dev, const char *fmt, ...); +extern __printf(2, 3) +int dev_notice(const struct device *dev, const char *fmt, ...); +extern __printf(2, 3) +int _dev_info(const struct device *dev, const char *fmt, ...); #else static inline int __dev_printk(const char *level, const struct device *dev, struct va_format *vaf) - { return 0; } -static inline int dev_printk(const char *level, const struct device *dev, - const char *fmt, ...) - __attribute__ ((format (printf, 3, 4))); -static inline int dev_printk(const char *level, const struct device *dev, - const char *fmt, ...) - { return 0; } - -static inline int dev_emerg(const struct device *dev, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); -static inline int dev_emerg(const struct device *dev, const char *fmt, ...) - { return 0; } -static inline int dev_crit(const struct device *dev, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); -static inline int dev_crit(const struct device *dev, const char *fmt, ...) - { return 0; } -static inline int dev_alert(const struct device *dev, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); -static inline int dev_alert(const struct device *dev, const char *fmt, ...) - { return 0; } -static inline int dev_err(const struct device *dev, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); -static inline int dev_err(const struct device *dev, const char *fmt, ...) - { return 0; } -static inline int dev_warn(const struct device *dev, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); -static inline int dev_warn(const struct device *dev, const char *fmt, ...) - { return 0; } -static inline int dev_notice(const struct device *dev, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); -static inline int dev_notice(const struct device *dev, const char *fmt, ...) - { return 0; } -static inline int _dev_info(const struct device *dev, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); -static inline int _dev_info(const struct device *dev, const char *fmt, ...) - { return 0; } +{ return 0; } +static inline __printf(3, 4) +int dev_printk(const char *level, const struct device *dev, + const char *fmt, ...) +{ return 0; } + +static inline __printf(2, 3) +int dev_emerg(const struct device *dev, const char *fmt, ...) +{ return 0; } +static inline __printf(2, 3) +int dev_crit(const struct device *dev, const char *fmt, ...) +{ return 0; } +static inline __printf(2, 3) +int dev_alert(const struct device *dev, const char *fmt, ...) +{ return 0; } +static inline __printf(2, 3) +int dev_err(const struct device *dev, const char *fmt, ...) +{ return 0; } +static inline __printf(2, 3) +int dev_warn(const struct device *dev, const char *fmt, ...) +{ return 0; } +static inline __printf(2, 3) +int dev_notice(const struct device *dev, const char *fmt, ...) +{ return 0; } +static inline __printf(2, 3) +int _dev_info(const struct device *dev, const char *fmt, ...) +{ return 0; } #endif diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 13aae8087b56..0564e3c39882 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -37,22 +37,21 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n, #if defined(CONFIG_DYNAMIC_DEBUG) extern int ddebug_remove_module(const char *mod_name); -extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); +extern __printf(2, 3) +int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...); struct device; -extern int __dynamic_dev_dbg(struct _ddebug *descriptor, - const struct device *dev, - const char *fmt, ...) - __attribute__ ((format (printf, 3, 4))); +extern __printf(3, 4) +int __dynamic_dev_dbg(struct _ddebug *descriptor, const struct device *dev, + const char *fmt, ...); struct net_device; -extern int __dynamic_netdev_dbg(struct _ddebug *descriptor, - const struct net_device *dev, - const char *fmt, ...) - __attribute__ ((format (printf, 3, 4))); +extern __printf(3, 4) +int __dynamic_netdev_dbg(struct _ddebug *descriptor, + const struct net_device *dev, + const char *fmt, ...); #define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ static struct _ddebug __used __aligned(8) \ diff --git a/include/linux/ext3_fs.h b/include/linux/ext3_fs.h index 67a803aee619..81965cce6bfa 100644 --- a/include/linux/ext3_fs.h +++ b/include/linux/ext3_fs.h @@ -937,15 +937,15 @@ extern int ext3_group_extend(struct super_block *sb, ext3_fsblk_t n_blocks_count); /* super.c */ -extern void ext3_error (struct super_block *, const char *, const char *, ...) - __attribute__ ((format (printf, 3, 4))); +extern __printf(3, 4) +void ext3_error(struct super_block *, const char *, const char *, ...); extern void __ext3_std_error (struct super_block *, const char *, int); -extern void ext3_abort (struct super_block *, const char *, const char *, ...) - __attribute__ ((format (printf, 3, 4))); -extern void ext3_warning (struct super_block *, const char *, const char *, ...) - __attribute__ ((format (printf, 3, 4))); -extern void ext3_msg(struct super_block *, const char *, const char *, ...) - __attribute__ ((format (printf, 3, 4))); +extern __printf(3, 4) +void ext3_abort(struct super_block *, const char *, const char *, ...); +extern __printf(3, 4) +void ext3_warning(struct super_block *, const char *, const char *, ...); +extern __printf(3, 4) +void ext3_msg(struct super_block *, const char *, const char *, ...); extern void ext3_update_dynamic_rev (struct super_block *sb); #define ext3_std_error(sb, errno) \ diff --git a/include/linux/fs.h b/include/linux/fs.h index 87b4c6b9692d..7a049fd2aa4c 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2635,8 +2635,8 @@ static const struct file_operations __fops = { \ .llseek = generic_file_llseek, \ }; -static inline void __attribute__((format(printf, 1, 2))) -__simple_attr_check_format(const char *fmt, ...) +static inline __printf(1, 2) +void __simple_attr_check_format(const char *fmt, ...) { /* don't do anything, just let the compiler check the arguments; */ } diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h index af095b54502e..ce31408b1e47 100644 --- a/include/linux/fscache-cache.h +++ b/include/linux/fscache-cache.h @@ -492,10 +492,10 @@ static inline void fscache_end_io(struct fscache_retrieval *op, /* * out-of-line cache backend functions */ -extern void fscache_init_cache(struct fscache_cache *cache, - const struct fscache_cache_ops *ops, - const char *idfmt, - ...) __attribute__ ((format (printf, 3, 4))); +extern __printf(3, 4) +void fscache_init_cache(struct fscache_cache *cache, + const struct fscache_cache_ops *ops, + const char *idfmt, ...); extern int fscache_add_cache(struct fscache_cache *cache, struct fscache_object *fsdef, diff --git a/include/linux/gameport.h b/include/linux/gameport.h index b65a6f472775..069ee4139105 100644 --- a/include/linux/gameport.h +++ b/include/linux/gameport.h @@ -78,8 +78,8 @@ static inline void gameport_register_port(struct gameport *gameport) void gameport_unregister_port(struct gameport *gameport); -void gameport_set_phys(struct gameport *gameport, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); +__printf(2, 3) +void gameport_set_phys(struct gameport *gameport, const char *fmt, ...); #else @@ -93,8 +93,8 @@ static inline void gameport_unregister_port(struct gameport *gameport) return; } -static inline void gameport_set_phys(struct gameport *gameport, - const char *fmt, ...) +static inline __printf(2, 3) +void gameport_set_phys(struct gameport *gameport, const char *fmt, ...) { return; } diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h index 0df513b7a9f8..387571959dd9 100644 --- a/include/linux/kallsyms.h +++ b/include/linux/kallsyms.h @@ -101,9 +101,8 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u #endif /*CONFIG_KALLSYMS*/ /* This macro allows us to keep printk typechecking */ -static void __check_printsym_format(const char *fmt, ...) -__attribute__((format(printf,1,2))); -static inline void __check_printsym_format(const char *fmt, ...) +static __printf(1, 2) +void __check_printsym_format(const char *fmt, ...) { } diff --git a/include/linux/kdb.h b/include/linux/kdb.h index 529d9a0c75a5..064725854db8 100644 --- a/include/linux/kdb.h +++ b/include/linux/kdb.h @@ -114,12 +114,9 @@ typedef enum { } kdb_reason_t; extern int kdb_trap_printk; -extern int vkdb_printf(const char *fmt, va_list args) - __attribute__ ((format (printf, 1, 0))); -extern int kdb_printf(const char *, ...) - __attribute__ ((format (printf, 1, 2))); -typedef int (*kdb_printf_t)(const char *, ...) - __attribute__ ((format (printf, 1, 2))); +extern __printf(1, 0) int vkdb_printf(const char *fmt, va_list args); +extern __printf(1, 2) int kdb_printf(const char *, ...); +typedef __printf(1, 2) int (*kdb_printf_t)(const char *, ...); extern void kdb_init(int level); diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 8eefcf7e95eb..e40c950e1d62 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -296,20 +296,18 @@ extern long long simple_strtoll(const char *,char **,unsigned int); #define strict_strtoull kstrtoull #define strict_strtoll kstrtoll -extern int sprintf(char * buf, const char * fmt, ...) - __attribute__ ((format (printf, 2, 3))); -extern int vsprintf(char *buf, const char *, va_list) - __attribute__ ((format (printf, 2, 0))); -extern int snprintf(char * buf, size_t size, const char * fmt, ...) - __attribute__ ((format (printf, 3, 4))); -extern int vsnprintf(char *buf, size_t size, const char *fmt, va_list args) - __attribute__ ((format (printf, 3, 0))); -extern int scnprintf(char * buf, size_t size, const char * fmt, ...) - __attribute__ ((format (printf, 3, 4))); -extern int vscnprintf(char *buf, size_t size, const char *fmt, va_list args) - __attribute__ ((format (printf, 3, 0))); -extern char *kasprintf(gfp_t gfp, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); +extern __printf(2, 3) int sprintf(char *buf, const char * fmt, ...); +extern __printf(2, 0) int vsprintf(char *buf, const char *, va_list); +extern __printf(3, 4) +int snprintf(char *buf, size_t size, const char *fmt, ...); +extern __printf(3, 0) +int vsnprintf(char *buf, size_t size, const char *fmt, va_list args); +extern __printf(3, 4) +int scnprintf(char *buf, size_t size, const char *fmt, ...); +extern __printf(3, 0) +int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); +extern __printf(2, 3) +char *kasprintf(gfp_t gfp, const char *fmt, ...); extern char *kvasprintf(gfp_t gfp, const char *fmt, va_list args); extern int sscanf(const char *, const char *, ...) @@ -427,8 +425,8 @@ extern void tracing_start(void); extern void tracing_stop(void); extern void ftrace_off_permanent(void); -static inline void __attribute__ ((format (printf, 1, 2))) -____trace_printk_check_format(const char *fmt, ...) +static inline __printf(1, 2) +void ____trace_printk_check_format(const char *fmt, ...) { } #define __trace_printk_check_format(fmt, args...) \ @@ -467,13 +465,11 @@ do { \ __trace_printk(_THIS_IP_, fmt, ##args); \ } while (0) -extern int -__trace_bprintk(unsigned long ip, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); +extern __printf(2, 3) +int __trace_bprintk(unsigned long ip, const char *fmt, ...); -extern int -__trace_printk(unsigned long ip, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); +extern __printf(2, 3) +int __trace_printk(unsigned long ip, const char *fmt, ...); extern void trace_dump_stack(void); @@ -502,8 +498,8 @@ __ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap); extern void ftrace_dump(enum ftrace_dump_mode oops_dump_mode); #else -static inline int -trace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); +static inline __printf(1, 2) +int trace_printk(const char *fmt, ...); static inline void tracing_start(void) { } static inline void tracing_stop(void) { } diff --git a/include/linux/kexec.h b/include/linux/kexec.h index c2478a342cd7..8944ebe7963e 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -130,8 +130,8 @@ int kexec_should_crash(struct task_struct *); void crash_save_cpu(struct pt_regs *regs, int cpu); void crash_save_vmcoreinfo(void); void arch_crash_save_vmcoreinfo(void); -void vmcoreinfo_append_str(const char *fmt, ...) - __attribute__ ((format (printf, 1, 2))); +__printf(1, 2) +void vmcoreinfo_append_str(const char *fmt, ...); unsigned long paddr_vmcoreinfo_note(void); #define VMCOREINFO_OSRELEASE(value) \ diff --git a/include/linux/kmod.h b/include/linux/kmod.h index 0da38cf7db7b..b16f65390734 100644 --- a/include/linux/kmod.h +++ b/include/linux/kmod.h @@ -32,8 +32,8 @@ extern char modprobe_path[]; /* for sysctl */ /* modprobe exit status on success, -ve on error. Return value * usually useless though. */ -extern int __request_module(bool wait, const char *name, ...) \ - __attribute__((format(printf, 2, 3))); +extern __printf(2, 3) +int __request_module(bool wait, const char *name, ...); #define request_module(mod...) __request_module(true, mod) #define request_module_nowait(mod...) __request_module(false, mod) #define try_then_request_module(x, mod...) \ diff --git a/include/linux/kobject.h b/include/linux/kobject.h index 668729cc0fe9..ad81e1c51487 100644 --- a/include/linux/kobject.h +++ b/include/linux/kobject.h @@ -72,8 +72,8 @@ struct kobject { unsigned int uevent_suppress:1; }; -extern int kobject_set_name(struct kobject *kobj, const char *name, ...) - __attribute__((format(printf, 2, 3))); +extern __printf(2, 3) +int kobject_set_name(struct kobject *kobj, const char *name, ...); extern int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, va_list vargs); @@ -83,15 +83,13 @@ static inline const char *kobject_name(const struct kobject *kobj) } extern void kobject_init(struct kobject *kobj, struct kobj_type *ktype); -extern int __must_check kobject_add(struct kobject *kobj, - struct kobject *parent, - const char *fmt, ...) - __attribute__((format(printf, 3, 4))); -extern int __must_check kobject_init_and_add(struct kobject *kobj, - struct kobj_type *ktype, - struct kobject *parent, - const char *fmt, ...) - __attribute__((format(printf, 4, 5))); +extern __printf(3, 4) __must_check +int kobject_add(struct kobject *kobj, struct kobject *parent, + const char *fmt, ...); +extern __printf(4, 5) __must_check +int kobject_init_and_add(struct kobject *kobj, + struct kobj_type *ktype, struct kobject *parent, + const char *fmt, ...); extern void kobject_del(struct kobject *kobj); @@ -212,8 +210,8 @@ int kobject_uevent(struct kobject *kobj, enum kobject_action action); int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, char *envp[]); -int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...) - __attribute__((format (printf, 2, 3))); +__printf(2, 3) +int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...); int kobject_action_type(const char *buf, size_t count, enum kobject_action *type); @@ -226,7 +224,7 @@ static inline int kobject_uevent_env(struct kobject *kobj, char *envp[]) { return 0; } -static inline __attribute__((format(printf, 2, 3))) +static inline __printf(2, 3) int add_uevent_var(struct kobj_uevent_env *env, const char *format, ...) { return 0; } diff --git a/include/linux/kthread.h b/include/linux/kthread.h index 1e923e5e88e8..5cac19b3a266 100644 --- a/include/linux/kthread.h +++ b/include/linux/kthread.h @@ -4,11 +4,11 @@ #include #include +__printf(4, 5) struct task_struct *kthread_create_on_node(int (*threadfn)(void *data), void *data, int node, - const char namefmt[], ...) - __attribute__((format(printf, 4, 5))); + const char namefmt[], ...); #define kthread_create(threadfn, data, namefmt, arg...) \ kthread_create_on_node(threadfn, data, -1, namefmt, ##arg) diff --git a/include/linux/libata.h b/include/linux/libata.h index 23fa829bf7a3..cafc09a64fe4 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -1256,13 +1256,13 @@ static inline int sata_srst_pmp(struct ata_link *link) /* * printk helpers */ -__attribute__((format (printf, 3, 4))) +__printf(3, 4) int ata_port_printk(const struct ata_port *ap, const char *level, const char *fmt, ...); -__attribute__((format (printf, 3, 4))) +__printf(3, 4) int ata_link_printk(const struct ata_link *link, const char *level, const char *fmt, ...); -__attribute__((format (printf, 3, 4))) +__printf(3, 4) int ata_dev_printk(const struct ata_device *dev, const char *level, const char *fmt, ...); @@ -1304,10 +1304,10 @@ void ata_print_version(const struct device *dev, const char *version); /* * ata_eh_info helpers */ -extern void __ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); -extern void ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); +extern __printf(2, 3) +void __ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...); +extern __printf(2, 3) +void ata_ehi_push_desc(struct ata_eh_info *ehi, const char *fmt, ...); extern void ata_ehi_clear_desc(struct ata_eh_info *ehi); static inline void ata_ehi_hotplugged(struct ata_eh_info *ehi) @@ -1321,8 +1321,8 @@ static inline void ata_ehi_hotplugged(struct ata_eh_info *ehi) /* * port description helpers */ -extern void ata_port_desc(struct ata_port *ap, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); +extern __printf(2, 3) +void ata_port_desc(struct ata_port *ap, const char *fmt, ...); #ifdef CONFIG_PCI extern void ata_port_pbar_desc(struct ata_port *ap, int bar, ssize_t offset, const char *name); diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h index 97491f78b08c..c5d52780d6a0 100644 --- a/include/linux/mmiotrace.h +++ b/include/linux/mmiotrace.h @@ -49,8 +49,7 @@ extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size, extern void mmiotrace_iounmap(volatile void __iomem *addr); /* For anyone to insert markers. Remember trailing newline. */ -extern int mmiotrace_printk(const char *fmt, ...) - __attribute__ ((format (printf, 1, 2))); +extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...); #else /* !CONFIG_MMIOTRACE: */ static inline int is_kmmio_active(void) { @@ -71,10 +70,7 @@ static inline void mmiotrace_iounmap(volatile void __iomem *addr) { } -static inline int mmiotrace_printk(const char *fmt, ...) - __attribute__ ((format (printf, 1, 0))); - -static inline int mmiotrace_printk(const char *fmt, ...) +static inline __printf(1, 2) int mmiotrace_printk(const char *fmt, ...) { return 0; } diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index df1c836e6948..cbeb5867cff7 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2622,23 +2622,23 @@ static inline const char *netdev_name(const struct net_device *dev) extern int __netdev_printk(const char *level, const struct net_device *dev, struct va_format *vaf); -extern int netdev_printk(const char *level, const struct net_device *dev, - const char *format, ...) - __attribute__ ((format (printf, 3, 4))); -extern int netdev_emerg(const struct net_device *dev, const char *format, ...) - __attribute__ ((format (printf, 2, 3))); -extern int netdev_alert(const struct net_device *dev, const char *format, ...) - __attribute__ ((format (printf, 2, 3))); -extern int netdev_crit(const struct net_device *dev, const char *format, ...) - __attribute__ ((format (printf, 2, 3))); -extern int netdev_err(const struct net_device *dev, const char *format, ...) - __attribute__ ((format (printf, 2, 3))); -extern int netdev_warn(const struct net_device *dev, const char *format, ...) - __attribute__ ((format (printf, 2, 3))); -extern int netdev_notice(const struct net_device *dev, const char *format, ...) - __attribute__ ((format (printf, 2, 3))); -extern int netdev_info(const struct net_device *dev, const char *format, ...) - __attribute__ ((format (printf, 2, 3))); +extern __printf(3, 4) +int netdev_printk(const char *level, const struct net_device *dev, + const char *format, ...); +extern __printf(2, 3) +int netdev_emerg(const struct net_device *dev, const char *format, ...); +extern __printf(2, 3) +int netdev_alert(const struct net_device *dev, const char *format, ...); +extern __printf(2, 3) +int netdev_crit(const struct net_device *dev, const char *format, ...); +extern __printf(2, 3) +int netdev_err(const struct net_device *dev, const char *format, ...); +extern __printf(2, 3) +int netdev_warn(const struct net_device *dev, const char *format, ...); +extern __printf(2, 3) +int netdev_notice(const struct net_device *dev, const char *format, ...); +extern __printf(2, 3) +int netdev_info(const struct net_device *dev, const char *format, ...); #define MODULE_ALIAS_NETDEV(device) \ MODULE_ALIAS("netdev-" device) diff --git a/include/linux/printk.h b/include/linux/printk.h index 0101d55d9651..f0e22f75143f 100644 --- a/include/linux/printk.h +++ b/include/linux/printk.h @@ -82,22 +82,22 @@ struct va_format { * Dummy printk for disabled debugging statements to use whilst maintaining * gcc's format and side-effect checking. */ -static inline __attribute__ ((format (printf, 1, 2))) +static inline __printf(1, 2) int no_printk(const char *fmt, ...) { return 0; } -extern asmlinkage __attribute__ ((format (printf, 1, 2))) +extern asmlinkage __printf(1, 2) void early_printk(const char *fmt, ...); extern int printk_needs_cpu(int cpu); extern void printk_tick(void); #ifdef CONFIG_PRINTK -asmlinkage __attribute__ ((format (printf, 1, 0))) +asmlinkage __printf(1, 0) int vprintk(const char *fmt, va_list args); -asmlinkage __attribute__ ((format (printf, 1, 2))) __cold +asmlinkage __printf(1, 2) __cold int printk(const char *fmt, ...); /* @@ -117,12 +117,12 @@ extern int kptr_restrict; void log_buf_kexec_setup(void); void __init setup_log_buf(int early); #else -static inline __attribute__ ((format (printf, 1, 0))) +static inline __printf(1, 0) int vprintk(const char *s, va_list args) { return 0; } -static inline __attribute__ ((format (printf, 1, 2))) __cold +static inline __printf(1, 2) __cold int printk(const char *s, ...) { return 0; diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h index 26f9e3612e0f..d93f95e6177c 100644 --- a/include/linux/quotaops.h +++ b/include/linux/quotaops.h @@ -31,7 +31,7 @@ static inline bool is_quota_modification(struct inode *inode, struct iattr *ia) #define quota_error(sb, fmt, args...) \ __quota_error((sb), __func__, fmt , ## args) -extern __attribute__((format (printf, 3, 4))) +extern __printf(3, 4) void __quota_error(struct super_block *sb, const char *func, const char *fmt, ...); diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h index be720cd2038d..0b69a4684216 100644 --- a/include/linux/seq_file.h +++ b/include/linux/seq_file.h @@ -84,8 +84,7 @@ int seq_putc(struct seq_file *m, char c); int seq_puts(struct seq_file *m, const char *s); int seq_write(struct seq_file *seq, const void *data, size_t len); -int seq_printf(struct seq_file *, const char *, ...) - __attribute__ ((format (printf,2,3))); +__printf(2, 3) int seq_printf(struct seq_file *, const char *, ...); int seq_path(struct seq_file *, struct path *, char *); int seq_dentry(struct seq_file *, struct dentry *, char *); diff --git a/include/linux/trace_seq.h b/include/linux/trace_seq.h index 5cf397ceb726..7dadc3df0c77 100644 --- a/include/linux/trace_seq.h +++ b/include/linux/trace_seq.h @@ -29,10 +29,10 @@ trace_seq_init(struct trace_seq *s) * Currently only defined when tracing is enabled. */ #ifdef CONFIG_TRACING -extern int trace_seq_printf(struct trace_seq *s, const char *fmt, ...) - __attribute__ ((format (printf, 2, 3))); -extern int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args) - __attribute__ ((format (printf, 2, 0))); +extern __printf(2, 3) +int trace_seq_printf(struct trace_seq *s, const char *fmt, ...); +extern __printf(2, 0) +int trace_seq_vprintf(struct trace_seq *s, const char *fmt, va_list args); extern int trace_seq_bprintf(struct trace_seq *s, const char *fmt, const u32 *binary); extern int trace_print_seq(struct seq_file *m, struct trace_seq *s); diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index e727555d4ee9..e86af08293a8 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h @@ -77,7 +77,7 @@ struct bt_power { #define BT_POWER_FORCE_ACTIVE_OFF 0 #define BT_POWER_FORCE_ACTIVE_ON 1 -__attribute__((format (printf, 2, 3))) +__printf(2, 3) int bt_printk(const char *level, const char *fmt, ...); #define BT_INFO(fmt, arg...) bt_printk(KERN_INFO, pr_fmt(fmt), ##arg) diff --git a/include/net/netfilter/nf_log.h b/include/net/netfilter/nf_log.h index 920997f1aff0..e991bd0a27af 100644 --- a/include/net/netfilter/nf_log.h +++ b/include/net/netfilter/nf_log.h @@ -53,12 +53,13 @@ int nf_log_bind_pf(u_int8_t pf, const struct nf_logger *logger); void nf_log_unbind_pf(u_int8_t pf); /* Calls the registered backend logging function */ +__printf(7, 8) void nf_log_packet(u_int8_t pf, unsigned int hooknum, const struct sk_buff *skb, const struct net_device *in, const struct net_device *out, const struct nf_loginfo *li, - const char *fmt, ...) __attribute__ ((format(printf,7,8))); + const char *fmt, ...); #endif /* _NF_LOG_H */ diff --git a/include/net/sock.h b/include/net/sock.h index 5ac682f73d63..c6658bef7f32 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -76,8 +76,8 @@ printk(KERN_DEBUG msg); } while (0) #else /* Validate arguments and do nothing */ -static inline void __attribute__ ((format (printf, 2, 3))) -SOCK_DEBUG(struct sock *sk, const char *msg, ...) +static inline __printf(2, 3) +void SOCK_DEBUG(struct sock *sk, const char *msg, ...) { } #endif diff --git a/include/sound/core.h b/include/sound/core.h index 1fa2407c966f..91d513879a78 100644 --- a/include/sound/core.h +++ b/include/sound/core.h @@ -326,9 +326,9 @@ void release_and_free_resource(struct resource *res); /* --- */ #if defined(CONFIG_SND_DEBUG) || defined(CONFIG_SND_VERBOSE_PRINTK) +__printf(4, 5) void __snd_printk(unsigned int level, const char *file, int line, - const char *format, ...) - __attribute__ ((format (printf, 4, 5))); + const char *format, ...); #else #define __snd_printk(level, file, line, format, args...) \ printk(format, ##args) diff --git a/include/sound/info.h b/include/sound/info.h index 4e94cf1ff762..5492cc40dc57 100644 --- a/include/sound/info.h +++ b/include/sound/info.h @@ -110,8 +110,8 @@ void snd_card_info_read_oss(struct snd_info_buffer *buffer); static inline void snd_card_info_read_oss(struct snd_info_buffer *buffer) {} #endif -int snd_iprintf(struct snd_info_buffer *buffer, const char *fmt, ...) \ - __attribute__ ((format (printf, 2, 3))); +__printf(2, 3) +int snd_iprintf(struct snd_info_buffer *buffer, const char *fmt, ...); int snd_info_init(void); int snd_info_done(void); diff --git a/include/sound/seq_kernel.h b/include/sound/seq_kernel.h index 3d9afb6a8c9c..f352a98ce4f4 100644 --- a/include/sound/seq_kernel.h +++ b/include/sound/seq_kernel.h @@ -75,9 +75,9 @@ struct snd_seq_port_callback { }; /* interface for kernel client */ +__printf(3, 4) int snd_seq_create_kernel_client(struct snd_card *card, int client_index, - const char *name_fmt, ...) - __attribute__ ((format (printf, 3, 4))); + const char *name_fmt, ...); int snd_seq_delete_kernel_client(int client); int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event *ev, int atomic, int hop); int snd_seq_kernel_client_dispatch(int client, struct snd_seq_event *ev, int atomic, int hop); diff --git a/include/xen/hvc-console.h b/include/xen/hvc-console.h index 901724dc528d..b62dfef15f61 100644 --- a/include/xen/hvc-console.h +++ b/include/xen/hvc-console.h @@ -6,12 +6,12 @@ extern struct console xenboot_console; #ifdef CONFIG_HVC_XEN void xen_console_resume(void); void xen_raw_console_write(const char *str); -__attribute__((format(printf, 1, 2))) +__printf(1, 2) void xen_raw_printk(const char *fmt, ...); #else static inline void xen_console_resume(void) { } static inline void xen_raw_console_write(const char *str) { } -static inline __attribute__((format(printf, 1, 2))) +static inline __printf(1, 2) void xen_raw_printk(const char *fmt, ...) { } #endif diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h index aceeca799fd7..b9f9fb5af0d8 100644 --- a/include/xen/xenbus.h +++ b/include/xen/xenbus.h @@ -156,9 +156,9 @@ int xenbus_scanf(struct xenbus_transaction t, __attribute__((format(scanf, 4, 5))); /* Single printf and write: returns -errno or 0. */ +__printf(4, 5) int xenbus_printf(struct xenbus_transaction t, - const char *dir, const char *node, const char *fmt, ...) - __attribute__((format(printf, 4, 5))); + const char *dir, const char *node, const char *fmt, ...); /* Generic read function: NULL-terminated triples of name, * sprintf-style type string, and pointer. Returns 0 or errno.*/ @@ -200,11 +200,11 @@ int xenbus_watch_path(struct xenbus_device *dev, const char *path, struct xenbus_watch *watch, void (*callback)(struct xenbus_watch *, const char **, unsigned int)); +__printf(4, 5) int xenbus_watch_pathfmt(struct xenbus_device *dev, struct xenbus_watch *watch, void (*callback)(struct xenbus_watch *, const char **, unsigned int), - const char *pathfmt, ...) - __attribute__ ((format (printf, 4, 5))); + const char *pathfmt, ...); int xenbus_switch_state(struct xenbus_device *dev, enum xenbus_state new_state); int xenbus_grant_ring(struct xenbus_device *dev, unsigned long ring_mfn); @@ -223,9 +223,9 @@ int xenbus_free_evtchn(struct xenbus_device *dev, int port); enum xenbus_state xenbus_read_driver_state(const char *path); -__attribute__((format(printf, 3, 4))) +__printf(3, 4) void xenbus_dev_error(struct xenbus_device *dev, int err, const char *fmt, ...); -__attribute__((format(printf, 3, 4))) +__printf(3, 4) void xenbus_dev_fatal(struct xenbus_device *dev, int err, const char *fmt, ...); const char *xenbus_strstate(enum xenbus_state state); diff --git a/net/nfc/nfc.h b/net/nfc/nfc.h index b6753f45624e..d86583f4831d 100644 --- a/net/nfc/nfc.h +++ b/net/nfc/nfc.h @@ -27,7 +27,7 @@ #include #include -__attribute__((format (printf, 2, 3))) +__printf(2, 3) int nfc_printk(const char *level, const char *fmt, ...); #define nfc_info(fmt, arg...) nfc_printk(KERN_INFO, fmt, ##arg) diff --git a/net/rds/rds.h b/net/rds/rds.h index da8adac2bf06..7eaba1831f0d 100644 --- a/net/rds/rds.h +++ b/net/rds/rds.h @@ -36,8 +36,8 @@ #define rdsdebug(fmt, args...) pr_debug("%s(): " fmt, __func__ , ##args) #else /* sigh, pr_debug() causes unused variable warnings */ -static inline void __attribute__ ((format (printf, 1, 2))) -rdsdebug(char *fmt, ...) +static inline __printf(1, 2) +void rdsdebug(char *fmt, ...) { } #endif @@ -625,8 +625,8 @@ void rds_for_each_conn_info(struct socket *sock, unsigned int len, struct rds_info_lengths *lens, int (*visitor)(struct rds_connection *, void *), size_t item_len); -void __rds_conn_error(struct rds_connection *conn, const char *, ...) - __attribute__ ((format (printf, 2, 3))); +__printf(2, 3) +void __rds_conn_error(struct rds_connection *conn, const char *, ...); #define rds_conn_error(conn, fmt...) \ __rds_conn_error(conn, KERN_WARNING "RDS: " fmt) diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index 30d70abb4e2c..dd5cc00ed559 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -971,9 +971,8 @@ static void svc_unregister(const struct svc_serv *serv) /* * Printk the given error with the address of the client that caused it. */ -static int -__attribute__ ((format (printf, 2, 3))) -svc_printk(struct svc_rqst *rqstp, const char *fmt, ...) +static __printf(2, 3) +int svc_printk(struct svc_rqst *rqstp, const char *fmt, ...) { va_list args; int r; diff --git a/sound/firewire/cmp.c b/sound/firewire/cmp.c index 14cacbc655dd..76294f2ae47f 100644 --- a/sound/firewire/cmp.c +++ b/sound/firewire/cmp.c @@ -32,7 +32,7 @@ enum bus_reset_handling { SUCCEED_ON_BUS_RESET, }; -static __attribute__((format(printf, 2, 3))) +static __printf(2, 3) void cmp_error(struct cmp_connection *c, const char *fmt, ...) { va_list va; -- cgit v1.2.3 From 67220a9ea3eb9cf61de7e384b6bcaaa78f680c9d Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Mon, 31 Oct 2011 17:13:00 -0700 Subject: wireless: at76c50x: follow rename pack_hex_byte to hex_byte_pack There is no functional change. Signed-off-by: Andy Shevchenko Acked-by: John W. Linville Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/net/wireless/at76c50x-usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c index 39322d4121b7..4045e5ab0555 100644 --- a/drivers/net/wireless/at76c50x-usb.c +++ b/drivers/net/wireless/at76c50x-usb.c @@ -517,7 +517,7 @@ static char *hex2str(void *buf, size_t len) goto exit; while (len--) { - obuf = pack_hex_byte(obuf, *ibuf++); + obuf = hex_byte_pack(obuf, *ibuf++); *obuf++ = '-'; } obuf--; -- cgit v1.2.3 From bad3118fcdeb4b7b5bf18cb40b2548cf891646b2 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 18 Aug 2011 20:12:50 +0100 Subject: um: a couple of missing dependencies... Signed-off-by: Al Viro Signed-off-by: Richard Weinberger --- drivers/net/wireless/ath/Kconfig | 2 +- drivers/net/wireless/rtlwifi/Kconfig | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/Kconfig b/drivers/net/wireless/ath/Kconfig index d1b23067619f..47d0de806e0d 100644 --- a/drivers/net/wireless/ath/Kconfig +++ b/drivers/net/wireless/ath/Kconfig @@ -1,6 +1,6 @@ menuconfig ATH_COMMON tristate "Atheros Wireless Cards" - depends on CFG80211 + depends on CFG80211 && (!UML || BROKEN) ---help--- This will enable the support for the Atheros wireless drivers. ath5k, ath9k, ath9k_htc and ar9170 drivers share some common code, this option diff --git a/drivers/net/wireless/rtlwifi/Kconfig b/drivers/net/wireless/rtlwifi/Kconfig index 45e14760c16e..d6c42e69bdbd 100644 --- a/drivers/net/wireless/rtlwifi/Kconfig +++ b/drivers/net/wireless/rtlwifi/Kconfig @@ -12,7 +12,7 @@ config RTL8192CE config RTL8192SE tristate "Realtek RTL8192SE/RTL8191SE PCIe Wireless Network Adapter" - depends on MAC80211 && EXPERIMENTAL + depends on MAC80211 && EXPERIMENTAL && PCI select FW_LOADER select RTLWIFI ---help--- @@ -23,7 +23,7 @@ config RTL8192SE config RTL8192DE tristate "Realtek RTL8192DE/RTL8188DE PCIe Wireless Network Adapter" - depends on MAC80211 && EXPERIMENTAL + depends on MAC80211 && EXPERIMENTAL && PCI select FW_LOADER select RTLWIFI ---help--- -- cgit v1.2.3 From 679a673414473239d189b5b41ea4014b088be7b9 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 11 Oct 2011 11:55:44 +0200 Subject: wl12xx: couple role_start_dev with roc Device role is always started along with ROC. Couple them together by introducing new wl12xx_start_dev and wl12xx_stop_dev functions. By using these functions, we solve a bug that occured during channel switch - we started the dev role on one channel, and ROCed on a different one. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 53 ++++++++++++++++++++++++++++++++++++-- drivers/net/wireless/wl12xx/cmd.h | 4 +-- drivers/net/wireless/wl12xx/main.c | 40 +++++++--------------------- drivers/net/wireless/wl12xx/scan.c | 3 +-- drivers/net/wireless/wl12xx/tx.c | 6 +---- 5 files changed, 65 insertions(+), 41 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index 2413c43d0894..afd597387e7e 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -468,7 +468,8 @@ static int wl12xx_get_new_session_id(struct wl1271 *wl, return wlvif->session_counter; } -int wl12xx_cmd_role_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) +static int wl12xx_cmd_role_start_dev(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { struct wl12xx_cmd_role_start *cmd; int ret; @@ -516,7 +517,8 @@ out: return ret; } -int wl12xx_cmd_role_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) +static int wl12xx_cmd_role_stop_dev(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { struct wl12xx_cmd_role_stop *cmd; int ret; @@ -1776,3 +1778,50 @@ out_free: out: return ret; } + +/* start dev role and roc on its channel */ +int wl12xx_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) +{ + int ret; + + if (WARN_ON(!(wlvif->bss_type == BSS_TYPE_STA_BSS || + wlvif->bss_type == BSS_TYPE_IBSS))) + return -EINVAL; + + ret = wl12xx_cmd_role_start_dev(wl, wlvif); + if (ret < 0) + goto out; + + ret = wl12xx_roc(wl, wlvif, wlvif->dev_role_id); + if (ret < 0) + goto out_stop; + + return 0; + +out_stop: + wl12xx_cmd_role_stop_dev(wl, wlvif); +out: + return ret; +} + +/* croc dev hlid, and stop the role */ +int wl12xx_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif) +{ + int ret; + + if (WARN_ON(!(wlvif->bss_type == BSS_TYPE_STA_BSS || + wlvif->bss_type == BSS_TYPE_IBSS))) + return -EINVAL; + + if (test_bit(wlvif->dev_role_id, wl->roc_map)) { + ret = wl12xx_croc(wl, wlvif->dev_role_id); + if (ret < 0) + goto out; + } + + ret = wl12xx_cmd_role_stop_dev(wl, wlvif); + if (ret < 0) + goto out; +out: + return ret; +} diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h index 968d5bdc0b60..3f7d0b93c24d 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/cmd.h @@ -39,13 +39,13 @@ int wl1271_cmd_ext_radio_parms(struct wl1271 *wl); int wl12xx_cmd_role_enable(struct wl1271 *wl, u8 *addr, u8 role_type, u8 *role_id); int wl12xx_cmd_role_disable(struct wl1271 *wl, u8 *role_id); -int wl12xx_cmd_role_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif); -int wl12xx_cmd_role_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_role_stop_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_role_stop_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif); +int wl12xx_start_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif); +int wl12xx_stop_dev(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer); int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len); int wl1271_cmd_configure(struct wl1271 *wl, u16 id, void *buf, size_t len); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index f76be5ad8ab0..44070e66cfed 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2429,11 +2429,7 @@ static int wl1271_sta_handle_idle(struct wl1271 *wl, struct wl12xx_vif *wlvif, if (idle) { /* no need to croc if we weren't busy (e.g. during boot) */ if (wl12xx_is_roc(wl)) { - ret = wl12xx_croc(wl, wlvif->dev_role_id); - if (ret < 0) - goto out; - - ret = wl12xx_cmd_role_stop_dev(wl, wlvif); + ret = wl12xx_stop_dev(wl, wlvif); if (ret < 0) goto out; } @@ -2455,11 +2451,7 @@ static int wl1271_sta_handle_idle(struct wl1271 *wl, struct wl12xx_vif *wlvif, ieee80211_sched_scan_stopped(wl->hw); } - ret = wl12xx_cmd_role_start_dev(wl, wlvif); - if (ret < 0) - goto out; - - ret = wl12xx_roc(wl, wlvif, wlvif->dev_role_id); + ret = wl12xx_start_dev(wl, wlvif); if (ret < 0) goto out; clear_bit(WL1271_FLAG_IDLE, &wl->flags); @@ -2525,16 +2517,13 @@ static int wl12xx_config_vif(struct wl1271 *wl, struct wl12xx_vif *wlvif, */ if (wl12xx_is_roc(wl) && !(conf->flags & IEEE80211_CONF_IDLE)) { - ret = wl12xx_croc(wl, - wlvif->dev_role_id); + ret = wl12xx_stop_dev(wl, wlvif); if (ret < 0) return ret; - ret = wl12xx_roc(wl, wlvif, - wlvif->dev_role_id); + ret = wl12xx_start_dev(wl, wlvif); if (ret < 0) - wl1271_warning("roc failed %d", - ret); + return ret; } } } @@ -3087,8 +3076,7 @@ static int wl1271_op_hw_scan(struct ieee80211_hw *hw, ret = -EBUSY; goto out_sleep; } - wl12xx_croc(wl, wlvif->dev_role_id); - wl12xx_cmd_role_stop_dev(wl, wlvif); + wl12xx_stop_dev(wl, wlvif); } ret = wl1271_scan(hw->priv, vif, ssid, len, req); @@ -3599,8 +3587,7 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, if (test_and_clear_bit(WLVIF_FLAG_IBSS_JOINED, &wlvif->flags)) { wl1271_unjoin(wl, wlvif); - wl12xx_cmd_role_start_dev(wl, wlvif); - wl12xx_roc(wl, wlvif, wlvif->dev_role_id); + wl12xx_start_dev(wl, wlvif); } } } @@ -3776,11 +3763,8 @@ sta_not_found: } wl1271_unjoin(wl, wlvif); - if (!(conf_flags & IEEE80211_CONF_IDLE)) { - wl12xx_cmd_role_start_dev(wl, wlvif); - wl12xx_roc(wl, wlvif, - wlvif->dev_role_id); - } + if (!(conf_flags & IEEE80211_CONF_IDLE)) + wl12xx_start_dev(wl, wlvif); } } } @@ -3859,11 +3843,7 @@ sta_not_found: * STA role). TODO: make it better. */ if (wlvif->dev_role_id != WL12XX_INVALID_ROLE_ID) { - ret = wl12xx_croc(wl, wlvif->dev_role_id); - if (ret < 0) - goto out; - - ret = wl12xx_cmd_role_stop_dev(wl, wlvif); + ret = wl12xx_stop_dev(wl, wlvif); if (ret < 0) goto out; } diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index fb2c4319749d..898d03d5b527 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -77,8 +77,7 @@ void wl1271_scan_complete_work(struct work_struct *work) (is_ibss && !test_bit(WLVIF_FLAG_IBSS_JOINED, &wlvif->flags))) && !test_bit(wlvif->dev_role_id, wl->roc_map)) { /* restore remain on channel */ - wl12xx_cmd_role_start_dev(wl, wlvif); - wl12xx_roc(wl, wlvif, wlvif->dev_role_id); + wl12xx_start_dev(wl, wlvif); } wl1271_ps_elp_sleep(wl); diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index c7ad4f5976c5..3a9d2a6b8a09 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -99,11 +99,7 @@ static int wl1271_tx_update_filters(struct wl1271 *wl, goto out; wl1271_debug(DEBUG_CMD, "starting device role for roaming"); - ret = wl12xx_cmd_role_start_dev(wl, wlvif); - if (ret < 0) - goto out; - - ret = wl12xx_roc(wl, wlvif, wlvif->dev_role_id); + ret = wl12xx_start_dev(wl, wlvif); if (ret < 0) goto out; out: -- cgit v1.2.3 From d6fa37c9ffa2a613943dd1c32f220a3e6e9eb77c Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 11 Oct 2011 11:57:39 +0200 Subject: wl12xx: reconfigure rate policies on set_bitrate_mask The rate policies are configured only after association, resulting in auth req being sent in wrong rates. Reconfigure rate policies on bitrate mask change. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 44070e66cfed..c05be03907e4 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -4318,7 +4318,7 @@ static int wl12xx_set_bitrate_mask(struct ieee80211_hw *hw, { struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct wl1271 *wl = hw->priv; - int i; + int i, ret = 0; wl1271_debug(DEBUG_MAC80211, "mac80211 set_bitrate_mask 0x%x 0x%x", mask->control[NL80211_BAND_2GHZ].legacy, @@ -4331,9 +4331,28 @@ static int wl12xx_set_bitrate_mask(struct ieee80211_hw *hw, wl1271_tx_enabled_rates_get(wl, mask->control[i].legacy, i); + + if (unlikely(wl->state == WL1271_STATE_OFF)) + goto out; + + if (wlvif->bss_type == BSS_TYPE_STA_BSS && + !test_bit(WLVIF_FLAG_STA_ASSOCIATED, &wlvif->flags)) { + + ret = wl1271_ps_elp_wakeup(wl); + if (ret < 0) + goto out; + + wl1271_set_band_rate(wl, wlvif); + wlvif->basic_rate = + wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); + ret = wl1271_acx_sta_rate_policies(wl, wlvif); + + wl1271_ps_elp_sleep(wl); + } +out: mutex_unlock(&wl->mutex); - return 0; + return ret; } static void wl12xx_op_channel_switch(struct ieee80211_hw *hw, -- cgit v1.2.3 From a693534b1a46ee934606cec52b12baeaebba0342 Mon Sep 17 00:00:00 2001 From: Arik Nemtsov Date: Mon, 24 Oct 2011 17:25:20 +0200 Subject: wl12xx: keep beacon-filtering enabled during STA operation Enable beacon filtering on STA init, and don't disable it when entering active mode. Otherwise dynamic-PS supports means we receive beacons from the current AP during any Tx/Rx performed by the driver. Signed-off-by: Arik Nemtsov Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/event.c | 5 ----- drivers/net/wireless/wl12xx/init.c | 12 ++++++------ drivers/net/wireless/wl12xx/ps.c | 5 ----- 3 files changed, 6 insertions(+), 16 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/event.c index e22df6ce139a..00ce794eebae 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/event.c @@ -137,11 +137,6 @@ static int wl1271_event_ps_report(struct wl1271 *wl, case EVENT_ENTER_POWER_SAVE_SUCCESS: wlvif->psm_entry_retry = 0; - /* enable beacon filtering */ - ret = wl1271_acx_beacon_filter_opt(wl, wlvif, true); - if (ret < 0) - break; - /* * BET has only a minor effect in 5GHz and masks * channel switch IEs, so we only enable BET on 2.4GHz diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index c6084f8a9c43..14ff01efc0b1 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -254,17 +254,17 @@ static int wl12xx_init_phy_vif_config(struct wl1271 *wl, return 0; } -static int wl1271_init_beacon_filter(struct wl1271 *wl, - struct wl12xx_vif *wlvif) +static int wl1271_init_sta_beacon_filter(struct wl1271 *wl, + struct wl12xx_vif *wlvif) { int ret; - /* disable beacon filtering at this stage */ - ret = wl1271_acx_beacon_filter_opt(wl, wlvif, false); + ret = wl1271_acx_beacon_filter_table(wl, wlvif); if (ret < 0) return ret; - ret = wl1271_acx_beacon_filter_table(wl, wlvif); + /* enable beacon filtering */ + ret = wl1271_acx_beacon_filter_opt(wl, wlvif, true); if (ret < 0) return ret; @@ -529,7 +529,7 @@ static int wl12xx_init_sta_role(struct wl1271 *wl, struct wl12xx_vif *wlvif) return ret; /* Beacon filtering */ - ret = wl1271_init_beacon_filter(wl, wlvif); + ret = wl1271_init_sta_beacon_filter(wl, wlvif); if (ret < 0) return ret; diff --git a/drivers/net/wireless/wl12xx/ps.c b/drivers/net/wireless/wl12xx/ps.c index 9f4e8c03cc8f..a7a11088dd31 100644 --- a/drivers/net/wireless/wl12xx/ps.c +++ b/drivers/net/wireless/wl12xx/ps.c @@ -185,11 +185,6 @@ int wl1271_ps_set_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif, return ret; } - /* disable beacon filtering */ - ret = wl1271_acx_beacon_filter_opt(wl, wlvif, false); - if (ret < 0) - return ret; - ret = wl1271_cmd_ps_mode(wl, wlvif, STATION_ACTIVE_MODE); if (ret < 0) return ret; -- cgit v1.2.3 From fa5e13756ad5112842bd5e765d66b6c6074b74b7 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 31 Oct 2011 12:24:49 +0200 Subject: wl12xx: add vifs_state debugfs key Add debugfs key to dump information regarding the active vifs (similar to the driver_state debugfs key) Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/debugfs.c | 110 ++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index a9e0b7383bb5..2e14b436101f 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -385,6 +385,115 @@ static const struct file_operations driver_state_ops = { .llseek = default_llseek, }; +static ssize_t vifs_state_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct wl1271 *wl = file->private_data; + struct wl12xx_vif *wlvif; + int ret, res = 0; + const int buf_size = 4096; + char *buf; + char tmp_buf[64]; + + buf = kzalloc(buf_size, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + mutex_lock(&wl->mutex); + +#define VIF_STATE_PRINT(x, fmt) \ + (res += scnprintf(buf + res, buf_size - res, \ + #x " = " fmt "\n", wlvif->x)) + +#define VIF_STATE_PRINT_LONG(x) VIF_STATE_PRINT(x, "%ld") +#define VIF_STATE_PRINT_INT(x) VIF_STATE_PRINT(x, "%d") +#define VIF_STATE_PRINT_STR(x) VIF_STATE_PRINT(x, "%s") +#define VIF_STATE_PRINT_LHEX(x) VIF_STATE_PRINT(x, "0x%lx") +#define VIF_STATE_PRINT_LLHEX(x) VIF_STATE_PRINT(x, "0x%llx") +#define VIF_STATE_PRINT_HEX(x) VIF_STATE_PRINT(x, "0x%x") + +#define VIF_STATE_PRINT_NSTR(x, len) \ + do { \ + memset(tmp_buf, 0, sizeof(tmp_buf)); \ + memcpy(tmp_buf, wlvif->x, \ + min_t(u8, len, sizeof(tmp_buf) - 1)); \ + res += scnprintf(buf + res, buf_size - res, \ + #x " = %s\n", tmp_buf); \ + } while (0) + + wl12xx_for_each_wlvif(wl, wlvif) { + VIF_STATE_PRINT_INT(role_id); + VIF_STATE_PRINT_INT(bss_type); + VIF_STATE_PRINT_LHEX(flags); + VIF_STATE_PRINT_INT(p2p); + VIF_STATE_PRINT_INT(dev_role_id); + VIF_STATE_PRINT_INT(dev_hlid); + + if (wlvif->bss_type == BSS_TYPE_STA_BSS || + wlvif->bss_type == BSS_TYPE_IBSS) { + VIF_STATE_PRINT_INT(sta.hlid); + VIF_STATE_PRINT_INT(sta.ba_rx_bitmap); + VIF_STATE_PRINT_INT(sta.basic_rate_idx); + VIF_STATE_PRINT_INT(sta.ap_rate_idx); + VIF_STATE_PRINT_INT(sta.p2p_rate_idx); + } else { + VIF_STATE_PRINT_INT(ap.global_hlid); + VIF_STATE_PRINT_INT(ap.bcast_hlid); + VIF_STATE_PRINT_LHEX(ap.sta_hlid_map[0]); + VIF_STATE_PRINT_INT(ap.mgmt_rate_idx); + VIF_STATE_PRINT_INT(ap.bcast_rate_idx); + VIF_STATE_PRINT_INT(ap.ucast_rate_idx[0]); + VIF_STATE_PRINT_INT(ap.ucast_rate_idx[1]); + VIF_STATE_PRINT_INT(ap.ucast_rate_idx[2]); + VIF_STATE_PRINT_INT(ap.ucast_rate_idx[3]); + } + VIF_STATE_PRINT_INT(last_tx_hlid); + VIF_STATE_PRINT_LHEX(links_map[0]); + VIF_STATE_PRINT_NSTR(ssid, wlvif->ssid_len); + VIF_STATE_PRINT_INT(band); + VIF_STATE_PRINT_INT(channel); + VIF_STATE_PRINT_HEX(bitrate_masks[0]); + VIF_STATE_PRINT_HEX(bitrate_masks[1]); + VIF_STATE_PRINT_HEX(basic_rate_set); + VIF_STATE_PRINT_HEX(basic_rate); + VIF_STATE_PRINT_HEX(rate_set); + VIF_STATE_PRINT_INT(beacon_int); + VIF_STATE_PRINT_INT(default_key); + VIF_STATE_PRINT_INT(aid); + VIF_STATE_PRINT_INT(session_counter); + VIF_STATE_PRINT_INT(ps_poll_failures); + VIF_STATE_PRINT_INT(psm_entry_retry); + VIF_STATE_PRINT_INT(power_level); + VIF_STATE_PRINT_INT(rssi_thold); + VIF_STATE_PRINT_INT(last_rssi_event); + VIF_STATE_PRINT_INT(ba_support); + VIF_STATE_PRINT_INT(ba_allowed); + VIF_STATE_PRINT_LLHEX(tx_security_seq); + VIF_STATE_PRINT_INT(tx_security_last_seq_lsb); + } + +#undef VIF_STATE_PRINT_INT +#undef VIF_STATE_PRINT_LONG +#undef VIF_STATE_PRINT_HEX +#undef VIF_STATE_PRINT_LHEX +#undef VIF_STATE_PRINT_LLHEX +#undef VIF_STATE_PRINT_STR +#undef VIF_STATE_PRINT_NSTR +#undef VIF_STATE_PRINT + + mutex_unlock(&wl->mutex); + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, res); + kfree(buf); + return ret; +} + +static const struct file_operations vifs_state_ops = { + .read = vifs_state_read, + .open = wl1271_open_file_generic, + .llseek = default_llseek, +}; + static ssize_t dtim_interval_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { @@ -765,6 +874,7 @@ static int wl1271_debugfs_add_files(struct wl1271 *wl, DEBUGFS_ADD(gpio_power, rootdir); DEBUGFS_ADD(start_recovery, rootdir); DEBUGFS_ADD(driver_state, rootdir); + DEBUGFS_ADD(vifs_state, rootdir); DEBUGFS_ADD(dtim_interval, rootdir); DEBUGFS_ADD(beacon_interval, rootdir); DEBUGFS_ADD(beacon_filtering, rootdir); -- cgit v1.2.3 From 2f8e81ad42cee6e1503462105f540214b1fb3e54 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 1 Nov 2011 15:12:50 +0200 Subject: wl12xx: clear wl->vif on remove_interface wl->vif should be cleared on remove_interface() (rather than on stop()) even when only a single vif is supported, because during vif mode change stop() might not get called (e.g. because of monitor interface existence) Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index c05be03907e4..51d519f93d79 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1859,7 +1859,6 @@ static void wl1271_op_stop(struct ieee80211_hw *hw) wl->tx_results_count = 0; wl->tx_packets_count = 0; wl->time_offset = 0; - wl->vif = NULL; wl->tx_spare_blocks = TX_HW_BLOCK_SPARE_DEFAULT; wl->ap_fw_ps_map = 0; wl->ap_ps_map = 0; @@ -2211,6 +2210,8 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl, if (!test_and_clear_bit(WLVIF_FLAG_INITIALIZED, &wlvif->flags)) return; + wl->vif = NULL; + /* because of hardware recovery, we may get here twice */ if (wl->state != WL1271_STATE_ON) return; -- cgit v1.2.3 From ce39defb5c6312a89a0c7be48797d6fb8fe9abad Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Thu, 3 Nov 2011 08:44:41 +0200 Subject: wl12xx: change blocksize alignment quirk to negative SDIO blocksize alignment support is now the rule, not the exception. To simplify the code in patches to come, invert the meaning of the quirk to be negative (ie. the quirk is set if the device does _not_ support blocksize alignment). Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/init.c | 2 +- drivers/net/wireless/wl12xx/main.c | 8 ++++++-- drivers/net/wireless/wl12xx/tx.c | 6 +++--- drivers/net/wireless/wl12xx/wl12xx.h | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index 14ff01efc0b1..c413abd26d1c 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -501,7 +501,7 @@ int wl1271_chip_specific_init(struct wl1271 *wl) if (wl->chip.id == CHIP_ID_1283_PG20) { u32 host_cfg_bitmap = HOST_IF_CFG_RX_FIFO_ENABLE; - if (wl->quirks & WL12XX_QUIRK_BLOCKSIZE_ALIGNMENT) + if (!(wl->quirks & WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT)) /* Enable SDIO padding */ host_cfg_bitmap |= HOST_IF_CFG_TX_PAD_TO_SDIO_BLK; diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 51d519f93d79..b9a3fe497274 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1323,7 +1323,9 @@ static int wl1271_chip_wakeup(struct wl1271 *wl) ret = wl1271_setup(wl); if (ret < 0) goto out; + wl->quirks |= WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT; break; + case CHIP_ID_1271_PG20: wl1271_debug(DEBUG_BOOT, "chip id 0x%x (1271 PG20)", wl->chip.id); @@ -1331,7 +1333,9 @@ static int wl1271_chip_wakeup(struct wl1271 *wl) ret = wl1271_setup(wl); if (ret < 0) goto out; + wl->quirks |= WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT; break; + case CHIP_ID_1283_PG20: wl1271_debug(DEBUG_BOOT, "chip id 0x%x (1283 PG20)", wl->chip.id); @@ -1340,8 +1344,8 @@ static int wl1271_chip_wakeup(struct wl1271 *wl) if (ret < 0) goto out; - if (wl1271_set_block_size(wl)) - wl->quirks |= WL12XX_QUIRK_BLOCKSIZE_ALIGNMENT; + if (!wl1271_set_block_size(wl)) + wl->quirks |= WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT; break; case CHIP_ID_1283_PG10: default: diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 3a9d2a6b8a09..a07ee8201d6d 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -201,10 +201,10 @@ u8 wl12xx_tx_get_hlid(struct wl1271 *wl, struct wl12xx_vif *wlvif, static unsigned int wl12xx_calc_packet_alignment(struct wl1271 *wl, unsigned int packet_length) { - if (wl->quirks & WL12XX_QUIRK_BLOCKSIZE_ALIGNMENT) - return ALIGN(packet_length, WL12XX_BUS_BLOCK_SIZE); - else + if (wl->quirks & WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT) return ALIGN(packet_length, WL1271_TX_ALIGN_TO); + else + return ALIGN(packet_length, WL12XX_BUS_BLOCK_SIZE); } static int wl1271_tx_allocate(struct wl1271 *wl, struct wl12xx_vif *wlvif, diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index b7036df5939d..e58e801f7aea 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -669,8 +669,8 @@ size_t wl12xx_copy_fwlog(struct wl1271 *wl, u8 *memblock, size_t maxlen); /* Each RX/TX transaction requires an end-of-transaction transfer */ #define WL12XX_QUIRK_END_OF_TRANSACTION BIT(0) -/* WL128X requires aggregated packets to be aligned to the SDIO block size */ -#define WL12XX_QUIRK_BLOCKSIZE_ALIGNMENT BIT(2) +/* wl127x and SPI don't support SDIO block size alignment */ +#define WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT BIT(2) /* Older firmwares did not implement the FW logger over bus feature */ #define WL12XX_QUIRK_FWLOG_NOT_IMPLEMENTED BIT(4) -- cgit v1.2.3 From e62c9ce4a4c0e0ffd5718e962ba4606cd5d0d600 Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Thu, 3 Nov 2011 08:44:42 +0200 Subject: wl12xx: use the same SDIO block size for all different chips The sdio driver uses a block size of 512 bytes by default. With our card, this doesn't work correctly because it sets the block size FBR in the chip too early (ie. before the chip is powered on). Thus, if we don't set it explicitly, block mode remains disabled in the chip. If we try to send more data than fits in one block, the sdio driver will split it into separate blocks before sending to the chip. This causes problems because the chip is not expecting multiple blocks. At the moment this is not a problem, because we use chunks of 512 bytes for firmware upload and the data is always sent in byte mode. In the next patch, we will change the chunk size to a bigger value, so this patch is a preparation for that. Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index b9a3fe497274..aa1c0f3ebeeb 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1313,7 +1313,16 @@ static int wl1271_chip_wakeup(struct wl1271 *wl) /* 0. read chip id from CHIP_ID */ wl->chip.id = wl1271_read32(wl, CHIP_ID_B); - /* 1. check if chip id is valid */ + /* + * For wl127x based devices we could use the default block + * size (512 bytes), but due to a bug in the sdio driver, we + * need to set it explicitly after the chip is powered on. To + * simplify the code and since the performance impact is + * negligible, we use the same block size for all different + * chip types. + */ + if (!wl1271_set_block_size(wl)) + wl->quirks |= WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT; switch (wl->chip.id) { case CHIP_ID_1271_PG10: @@ -1343,9 +1352,6 @@ static int wl1271_chip_wakeup(struct wl1271 *wl) ret = wl1271_setup(wl); if (ret < 0) goto out; - - if (!wl1271_set_block_size(wl)) - wl->quirks |= WL12XX_QUIRK_NO_BLOCKSIZE_ALIGNMENT; break; case CHIP_ID_1283_PG10: default: -- cgit v1.2.3 From 3f3fd78e33213b1684ac1e4deacbcf7ed1828e3c Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Thu, 3 Nov 2011 08:44:43 +0200 Subject: wl12xx: increase firmware upload chunk size The chunk size used during firmware upload was set to 512, which is the size of a single SDIO block (or two). This is very inneficient because we send one or two blocks only per SDIO transaction and don't get the full benefits of sdio block transfers. This patch increases the chunk size to 16K. This more than doubles the transfer speed both in wl127x and wl128x chips, with greater impact on the latter: wl127x: 512 bytes chunk -> ~132ms 16384 bytes chunk -> ~57ms wl128x: 512 bytes chunk -> ~216ms 16384 bytes chunk -> ~37ms Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/reg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/reg.h b/drivers/net/wireless/wl12xx/reg.h index 3f570f397586..df34d5977b98 100644 --- a/drivers/net/wireless/wl12xx/reg.h +++ b/drivers/net/wireless/wl12xx/reg.h @@ -408,7 +408,7 @@ /* Firmware image load chunk size */ -#define CHUNK_SIZE 512 +#define CHUNK_SIZE 16384 /* Firmware image header size */ #define FW_HDR_SIZE 8 -- cgit v1.2.3 From bfafba8a4c61841ab850887d6dfe2741ad037ab6 Mon Sep 17 00:00:00 2001 From: Guy Eilam Date: Tue, 1 Nov 2011 09:23:51 +0200 Subject: wl12xx: set scan probe requests rate according to the no_cck flag Set the TX rate of probe requests during scanning according to the no_cck flag in the scan request struct. Signed-off-by: Guy Eilam Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/conf.h | 4 ++++ drivers/net/wireless/wl12xx/scan.c | 19 +++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/conf.h b/drivers/net/wireless/wl12xx/conf.h index 04bb8fbf93f9..1bcfb017058d 100644 --- a/drivers/net/wireless/wl12xx/conf.h +++ b/drivers/net/wireless/wl12xx/conf.h @@ -440,6 +440,10 @@ struct conf_rx_settings { CONF_HW_BIT_RATE_36MBPS | CONF_HW_BIT_RATE_48MBPS | \ CONF_HW_BIT_RATE_54MBPS) +#define CONF_TX_CCK_RATES (CONF_HW_BIT_RATE_1MBPS | \ + CONF_HW_BIT_RATE_2MBPS | CONF_HW_BIT_RATE_5_5MBPS | \ + CONF_HW_BIT_RATE_11MBPS) + #define CONF_TX_OFDM_RATES (CONF_HW_BIT_RATE_6MBPS | \ CONF_HW_BIT_RATE_12MBPS | CONF_HW_BIT_RATE_24MBPS | \ CONF_HW_BIT_RATE_36MBPS | CONF_HW_BIT_RATE_48MBPS | \ diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index 898d03d5b527..a13c49e27a36 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -202,7 +202,6 @@ static int wl1271_scan_send(struct wl1271 *wl, struct ieee80211_vif *vif, cmd->params.tx_rate = cpu_to_le32(basic_rate); cmd->params.n_probe_reqs = wl->conf.scan.num_probe_reqs; - cmd->params.tx_rate = cpu_to_le32(basic_rate); cmd->params.tid_trigger = 0; cmd->params.scan_tag = WL1271_SCAN_DEFAULT_TAG; @@ -254,7 +253,7 @@ void wl1271_scan_stm(struct wl1271 *wl, struct ieee80211_vif *vif) struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); int ret = 0; enum ieee80211_band band; - u32 rate; + u32 rate, mask; switch (wl->scan.state) { case WL1271_SCAN_STATE_IDLE: @@ -262,7 +261,13 @@ void wl1271_scan_stm(struct wl1271 *wl, struct ieee80211_vif *vif) case WL1271_SCAN_STATE_2GHZ_ACTIVE: band = IEEE80211_BAND_2GHZ; - rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[band]); + mask = wlvif->bitrate_masks[band]; + if (wl->scan.req->no_cck) { + mask &= ~CONF_TX_CCK_RATES; + if (!mask) + mask = CONF_TX_RATE_MASK_BASIC_P2P; + } + rate = wl1271_tx_min_rate_get(wl, mask); ret = wl1271_scan_send(wl, vif, band, false, rate); if (ret == WL1271_NOTHING_TO_SCAN) { wl->scan.state = WL1271_SCAN_STATE_2GHZ_PASSIVE; @@ -273,7 +278,13 @@ void wl1271_scan_stm(struct wl1271 *wl, struct ieee80211_vif *vif) case WL1271_SCAN_STATE_2GHZ_PASSIVE: band = IEEE80211_BAND_2GHZ; - rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[band]); + mask = wlvif->bitrate_masks[band]; + if (wl->scan.req->no_cck) { + mask &= ~CONF_TX_CCK_RATES; + if (!mask) + mask = CONF_TX_RATE_MASK_BASIC_P2P; + } + rate = wl1271_tx_min_rate_get(wl, mask); ret = wl1271_scan_send(wl, vif, band, true, rate); if (ret == WL1271_NOTHING_TO_SCAN) { if (wl->enable_11a) -- cgit v1.2.3 From 8a0f2ee37810aa4a4f46baf08b2ad587e138eb58 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 1 Nov 2011 09:23:52 +0200 Subject: wl12xx: use p2p rate index when the skb has the NO_CCK flag If the skb contains the NO_CCK flag, use the p2p rate index (which contains only the OFDM rates) Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/tx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index a07ee8201d6d..fa518a5b7c8b 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -336,7 +336,9 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct wl12xx_vif *wlvif, /* if the packets are destined for AP (have a STA entry) send them with AP rate policies, otherwise use default basic rates */ - if (control->control.sta) + if (control->flags & IEEE80211_TX_CTL_NO_CCK_RATE) + rate_idx = wlvif->sta.p2p_rate_idx; + else if (control->control.sta) rate_idx = wlvif->sta.ap_rate_idx; else rate_idx = wlvif->sta.basic_rate_idx; -- cgit v1.2.3 From c31e494689128203ef04fb946f05a72d33eee948 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Sun, 23 Oct 2011 08:21:55 +0200 Subject: wl12xx: handle idle changes per-interface Idle changes are currently handled per hardware. However, some operations should be done only per-interface. Signed-off-by: Eliad Peller Signed-off-by: Arik Nemtsov Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index aa1c0f3ebeeb..dbb088eadf71 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2540,13 +2540,6 @@ static int wl12xx_config_vif(struct wl1271 *wl, struct wl12xx_vif *wlvif, } } - if (changed & IEEE80211_CONF_CHANGE_IDLE && !is_ap) { - ret = wl1271_sta_handle_idle(wl, wlvif, - conf->flags & IEEE80211_CONF_IDLE); - if (ret < 0) - wl1271_warning("idle mode change failed %d", ret); - } - /* * if mac80211 changes the PSM mode, make sure the mode is not * incorrectly changed after the pspoll failure active window. @@ -3617,6 +3610,12 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl, do_join = true; } + if (changed & BSS_CHANGED_IDLE) { + ret = wl1271_sta_handle_idle(wl, wlvif, bss_conf->idle); + if (ret < 0) + wl1271_warning("idle mode change failed %d", ret); + } + if ((changed & BSS_CHANGED_CQM)) { bool enable = false; if (bss_conf->cqm_rssi_thold) -- cgit v1.2.3 From b693289406f0b8ca70ab77e745be6196d5740eb0 Mon Sep 17 00:00:00 2001 From: Eyal Shapira Date: Tue, 8 Nov 2011 15:56:55 +0200 Subject: wl12xx: fix SDIO suspend/resume wl1271_suspend/resume() accessed the wrong struct and not wl1271 which caused it to think that wow was enabled when it wasn't. Signed-off-by: Eyal Shapira Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/sdio.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c index ed97f9cee3f0..468a50553fac 100644 --- a/drivers/net/wireless/wl12xx/sdio.c +++ b/drivers/net/wireless/wl12xx/sdio.c @@ -289,7 +289,8 @@ static int wl1271_suspend(struct device *dev) /* Tell MMC/SDIO core it's OK to power down the card * (if it isn't already), but not to remove it completely */ struct sdio_func *func = dev_to_sdio_func(dev); - struct wl1271 *wl = sdio_get_drvdata(func); + struct wl12xx_sdio_glue *glue = sdio_get_drvdata(func); + struct wl1271 *wl = platform_get_drvdata(glue->core); mmc_pm_flag_t sdio_flags; int ret = 0; @@ -324,7 +325,8 @@ out: static int wl1271_resume(struct device *dev) { struct sdio_func *func = dev_to_sdio_func(dev); - struct wl1271 *wl = sdio_get_drvdata(func); + struct wl12xx_sdio_glue *glue = sdio_get_drvdata(func); + struct wl1271 *wl = platform_get_drvdata(glue->core); dev_dbg(dev, "wl1271 resume\n"); if (wl->wow_enabled) { -- cgit v1.2.3 From d929bbc63069396e723a180cde9cb71adc9f76ac Mon Sep 17 00:00:00 2001 From: Steven Miao Date: Wed, 9 Nov 2011 16:30:40 +0800 Subject: wireless: libertas: fix unaligned le64 accesses use get_unaligned_le64() to get timestamp Signed-off-by: Steven Miao Acked-by: Dan Williams Signed-off-by: John W. Linville --- drivers/net/wireless/libertas/cfg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/libertas/cfg.c b/drivers/net/wireless/libertas/cfg.c index 4fcd653bddc4..a7f1ab28940d 100644 --- a/drivers/net/wireless/libertas/cfg.c +++ b/drivers/net/wireless/libertas/cfg.c @@ -634,7 +634,7 @@ static int lbs_ret_scan(struct lbs_private *priv, unsigned long dummy, if (channel && !(channel->flags & IEEE80211_CHAN_DISABLED)) cfg80211_inform_bss(wiphy, channel, - bssid, le64_to_cpu(*(__le64 *)tsfdesc), + bssid, get_unaligned_le64(tsfdesc), capa, intvl, ie, ielen, LBS_SCAN_RSSI_TO_MBM(rssi), GFP_KERNEL); -- cgit v1.2.3 From 43e58856585f8c61e6a4a0f1fd6996d78799a973 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Wed, 9 Nov 2011 16:50:50 -0800 Subject: iwlwifi: avoid a panic when unloading the module with RF Kill When HW RF kill switch is set to kill the radio, our NIC issues an interrupt after we stop the APM module. When we unload the module, the driver disables and cleans the interrupts before stopping the APM. So we have a real interrupt (inta not zero) pending. When this interrupts pops up the tasklet has already been killed and we crash. Here is a logical description of the flow: disable and clean interrupts synchronize interrupts kill the tasklet stop the APM <<== creates an RF kill interrupt free_irq <<== somehow our ISR is called here and we crash Here is the panic message: [ 201.313636] BUG: unable to handle kernel paging request at ffff8800911b7150 [ 201.314541] IP: [] tasklet_action+0x62/0x130 [ 201.315149] PGD 1c06063 PUD db37f067 PMD db408067 PTE 80000000911b7160 [ 201.316456] Oops: 0000 [#1] SMP DEBUG_PAGEALLOC [ 201.317324] CPU 1 [ 201.317495] Modules linked in: arc4 iwlwifi(-) mac80211 cfg80211 netconsole configfs binfmt_misc i915 drm_kms_helper drm uvcvideo i2c_algo_bit videodev dell_laptop dcdbas intel_agp dell_wmi intel_ips psmouse intel_gtt v4l2_compat_ioctl32 asix usbnet mii serio_raw video sparse_keymap firewire_ohci sdhci_pci sdhci firewire_core e1000e crc_itu_t [last unloaded: configfs] [ 201.323839] [ 201.324015] Pid: 2061, comm: modprobe Not tainted 3.1.0-rc9-wl #4 Dell Inc. Latitude E6410/0667CC [ 201.324736] RIP: 0010:[] [] tasklet_action+0x62/0x130 [ 201.325128] RSP: 0018:ffff88011bc43ea0 EFLAGS: 00010286 [ 201.325338] RAX: ffff88008ae70000 RBX: ffff8800911b7150 RCX: ffff88008ae70028 [ 201.325555] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff88008ae70000 [ 201.325775] RBP: ffff88011bc43ec0 R08: 0000000000000000 R09: 0000000000000000 [ 201.325994] R10: 0000000000000002 R11: 0000000000000001 R12: 0000000000000001 [ 201.326212] R13: 0000000000000006 R14: 0000000000000100 R15: ffff88008e259fd8 [ 201.326431] FS: 00007f4b90ea9700(0000) GS:ffff88011bc40000(0000) knlGS:0000000000000000 [ 201.326657] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b [ 201.326864] CR2: ffff8800911b7150 CR3: 000000008fd6d000 CR4: 00000000000006e0 [ 201.327083] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 201.327302] DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 [ 201.327521] Process modprobe (pid: 2061, threadinfo ffff88008e258000, task ffff88008ae70000) [ 201.327747] Stack: [ 201.330494] 0000000000000046 0000000000000030 0000000000000001 0000000000000006 [ 201.333870] ffff88011bc43f30 ffffffff8106cd8a ffffffff811e1016 ffff88011bc43f08 [ 201.337186] 0000000100000046 ffff88008e259fd8 0000000a10be2160 0000000000000006 [ 201.340458] Call Trace: [ 201.342994] [ 201.345656] [] __do_softirq+0xca/0x250 [ 201.348185] [] ? pde_put+0x76/0x90 [ 201.350730] [] ? do_raw_spin_unlock+0x5e/0xb0 [ 201.353261] [] ? pde_put+0x76/0x90 [ 201.355776] [] call_softirq+0x1c/0x30 [ 201.358287] [] do_softirq+0x9d/0xd0 [ 201.360823] [] irq_exit+0xd5/0xf0 [ 201.363330] [] do_IRQ+0x66/0xe0 [ 201.365819] [] common_interrupt+0x73/0x73 [ 201.368257] Cc: 3.1+ Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 33 ++++++++++++++------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index da3411057afc..ce918980e977 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -990,29 +990,16 @@ static int iwl_trans_tx_stop(struct iwl_trans *trans) return 0; } -static void iwl_trans_pcie_disable_sync_irq(struct iwl_trans *trans) +static void iwl_trans_pcie_stop_device(struct iwl_trans *trans) { unsigned long flags; - struct iwl_trans_pcie *trans_pcie = - IWL_TRANS_GET_PCIE_TRANS(trans); + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); + /* tell the device to stop sending interrupts */ spin_lock_irqsave(&trans->shrd->lock, flags); iwl_disable_interrupts(trans); spin_unlock_irqrestore(&trans->shrd->lock, flags); - /* wait to make sure we flush pending tasklet*/ - synchronize_irq(bus(trans)->irq); - tasklet_kill(&trans_pcie->irq_tasklet); -} - -static void iwl_trans_pcie_stop_device(struct iwl_trans *trans) -{ - /* stop and reset the on-board processor */ - iwl_write32(bus(trans), CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); - - /* tell the device to stop sending interrupts */ - iwl_trans_pcie_disable_sync_irq(trans); - /* device going down, Stop using ICT table */ iwl_disable_ict(trans); @@ -1039,6 +1026,20 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans) /* Stop the device, and put it in low power state */ iwl_apm_stop(priv(trans)); + + /* Upon stop, the APM issues an interrupt if HW RF kill is set. + * Clean again the interrupt here + */ + spin_lock_irqsave(&trans->shrd->lock, flags); + iwl_disable_interrupts(trans); + spin_unlock_irqrestore(&trans->shrd->lock, flags); + + /* wait to make sure we flush pending tasklet*/ + synchronize_irq(bus(trans)->irq); + tasklet_kill(&trans_pcie->irq_tasklet); + + /* stop and reset the on-board processor */ + iwl_write32(bus(trans), CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); } static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, -- cgit v1.2.3 From fada10584d3890258e59da73728510ad7e08a033 Mon Sep 17 00:00:00 2001 From: Amitkumar Karwar Date: Wed, 9 Nov 2011 21:36:21 -0800 Subject: mwifiex: fix association issue with AP configured in hidden SSID mode Firmware expects 'max_ssid_length' field in 'struct mwifiex_ie_types_wildcard_ssid_params' to be '0' for performing SSID specific scan. Currently driver updates it with an actual SSID length. Hence UUT is not able to find the AP configured in hidden SSID mode in scan results and association fails. max_ssid_length is filled with '0' to fix the issue. Signed-off-by: Amitkumar Karwar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/scan.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c index 8a3f9598ad33..8d3ab378662b 100644 --- a/drivers/net/wireless/mwifiex/scan.c +++ b/drivers/net/wireless/mwifiex/scan.c @@ -819,8 +819,10 @@ mwifiex_scan_setup_scan_config(struct mwifiex_private *priv, wildcard_ssid_tlv->header.len = cpu_to_le16( (u16) (ssid_len + sizeof(wildcard_ssid_tlv-> max_ssid_length))); - wildcard_ssid_tlv->max_ssid_length = - user_scan_in->ssid_list[ssid_idx].max_len; + + /* max_ssid_length = 0 tells firmware to perform + specific scan for the SSID filled */ + wildcard_ssid_tlv->max_ssid_length = 0; memcpy(wildcard_ssid_tlv->ssid, user_scan_in->ssid_list[ssid_idx].ssid, -- cgit v1.2.3 From fee005e5dd82a43546c1b1beb187e82415360940 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 15 Aug 2011 15:00:42 +0200 Subject: iwlegacy: remove tracing This is not useful. Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/Kconfig | 17 --- drivers/net/wireless/iwlegacy/Makefile | 3 - drivers/net/wireless/iwlegacy/iwl-4965-tx.c | 6 - drivers/net/wireless/iwlegacy/iwl-devtrace.c | 42 ------ drivers/net/wireless/iwlegacy/iwl-devtrace.h | 210 --------------------------- drivers/net/wireless/iwlegacy/iwl-io.h | 4 - drivers/net/wireless/iwlegacy/iwl-tx.c | 3 - drivers/net/wireless/iwlegacy/iwl3945-base.c | 3 - drivers/net/wireless/iwlegacy/iwl4965-base.c | 5 - 9 files changed, 293 deletions(-) delete mode 100644 drivers/net/wireless/iwlegacy/iwl-devtrace.c delete mode 100644 drivers/net/wireless/iwlegacy/iwl-devtrace.h (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/Kconfig b/drivers/net/wireless/iwlegacy/Kconfig index aef65cd47661..2a1ae109ff25 100644 --- a/drivers/net/wireless/iwlegacy/Kconfig +++ b/drivers/net/wireless/iwlegacy/Kconfig @@ -43,23 +43,6 @@ config IWLWIFI_LEGACY_DEBUGFS is a low-impact option that allows getting insight into the driver's state at runtime. -config IWLWIFI_LEGACY_DEVICE_TRACING - bool "iwlwifilegacy legacy device access tracing" - depends on IWLWIFI_LEGACY - depends on EVENT_TRACING - help - Say Y here to trace all commands, including TX frames and IO - accesses, sent to the device. If you say yes, iwlwifilegacy will - register with the ftrace framework for event tracing and dump - all this information to the ringbuffer, you may need to - increase the ringbuffer size. See the ftrace documentation - for more information. - - When tracing is not enabled, this option still has some - (though rather small) overhead. - - If unsure, say Y so we can help you better when problems - occur. endmenu config IWL4965 diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index d56aeb38c211..4f67e45f22c0 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -3,12 +3,9 @@ iwl-legacy-objs := iwl-core.o iwl-eeprom.o iwl-hcmd.o iwl-power.o iwl-legacy-objs += iwl-rx.o iwl-tx.o iwl-sta.o iwl-legacy-objs += iwl-scan.o iwl-led.o iwl-legacy-$(CONFIG_IWLWIFI_LEGACY_DEBUGFS) += iwl-debugfs.o -iwl-legacy-$(CONFIG_IWLWIFI_LEGACY_DEVICE_TRACING) += iwl-devtrace.o iwl-legacy-objs += $(iwl-legacy-m) -CFLAGS_iwl-devtrace.o := -I$(src) - # 4965 obj-$(CONFIG_IWL4965) += iwl4965.o iwl4965-objs := iwl-4965.o iwl4965-base.o iwl-4965-rs.o iwl-4965-led.o diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index 7f12e3638bae..e421fdfed8c3 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -513,12 +513,6 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) pci_dma_sync_single_for_device(priv->pci_dev, txcmd_phys, firstlen, PCI_DMA_BIDIRECTIONAL); - trace_iwlwifi_legacy_dev_tx(priv, - &((struct iwl_tfd *)txq->tfds)[txq->q.write_ptr], - sizeof(struct iwl_tfd), - &out_cmd->hdr, firstlen, - skb->data + hdr_len, secondlen); - /* Tell device the write index *just past* this latest filled TFD */ q->write_ptr = iwl_legacy_queue_inc_wrap(q->write_ptr, q->n_bd); iwl_legacy_txq_update_write_ptr(priv, txq); diff --git a/drivers/net/wireless/iwlegacy/iwl-devtrace.c b/drivers/net/wireless/iwlegacy/iwl-devtrace.c deleted file mode 100644 index acec99197ce0..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-devtrace.c +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2009 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include - -/* sparse doesn't like tracepoint macros */ -#ifndef __CHECKER__ -#include "iwl-dev.h" - -#define CREATE_TRACE_POINTS -#include "iwl-devtrace.h" - -EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_iowrite8); -EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_ioread32); -EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_iowrite32); -EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_rx); -EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_tx); -EXPORT_TRACEPOINT_SYMBOL(iwlwifi_legacy_dev_ucode_error); -#endif diff --git a/drivers/net/wireless/iwlegacy/iwl-devtrace.h b/drivers/net/wireless/iwlegacy/iwl-devtrace.h deleted file mode 100644 index a443725ba6be..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-devtrace.h +++ /dev/null @@ -1,210 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2009 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#if !defined(__IWLWIFI_LEGACY_DEVICE_TRACE) || defined(TRACE_HEADER_MULTI_READ) -#define __IWLWIFI_LEGACY_DEVICE_TRACE - -#include - -#if !defined(CONFIG_IWLWIFI_LEGACY_DEVICE_TRACING) || defined(__CHECKER__) -#undef TRACE_EVENT -#define TRACE_EVENT(name, proto, ...) \ -static inline void trace_ ## name(proto) {} -#endif - - -#define PRIV_ENTRY __field(struct iwl_priv *, priv) -#define PRIV_ASSIGN (__entry->priv = priv) - -#undef TRACE_SYSTEM -#define TRACE_SYSTEM iwlwifi_legacy_io - -TRACE_EVENT(iwlwifi_legacy_dev_ioread32, - TP_PROTO(struct iwl_priv *priv, u32 offs, u32 val), - TP_ARGS(priv, offs, val), - TP_STRUCT__entry( - PRIV_ENTRY - __field(u32, offs) - __field(u32, val) - ), - TP_fast_assign( - PRIV_ASSIGN; - __entry->offs = offs; - __entry->val = val; - ), - TP_printk("[%p] read io[%#x] = %#x", __entry->priv, - __entry->offs, __entry->val) -); - -TRACE_EVENT(iwlwifi_legacy_dev_iowrite8, - TP_PROTO(struct iwl_priv *priv, u32 offs, u8 val), - TP_ARGS(priv, offs, val), - TP_STRUCT__entry( - PRIV_ENTRY - __field(u32, offs) - __field(u8, val) - ), - TP_fast_assign( - PRIV_ASSIGN; - __entry->offs = offs; - __entry->val = val; - ), - TP_printk("[%p] write io[%#x] = %#x)", __entry->priv, - __entry->offs, __entry->val) -); - -TRACE_EVENT(iwlwifi_legacy_dev_iowrite32, - TP_PROTO(struct iwl_priv *priv, u32 offs, u32 val), - TP_ARGS(priv, offs, val), - TP_STRUCT__entry( - PRIV_ENTRY - __field(u32, offs) - __field(u32, val) - ), - TP_fast_assign( - PRIV_ASSIGN; - __entry->offs = offs; - __entry->val = val; - ), - TP_printk("[%p] write io[%#x] = %#x)", __entry->priv, - __entry->offs, __entry->val) -); - -#undef TRACE_SYSTEM -#define TRACE_SYSTEM iwlwifi_legacy_ucode - -#undef TRACE_SYSTEM -#define TRACE_SYSTEM iwlwifi - -TRACE_EVENT(iwlwifi_legacy_dev_hcmd, - TP_PROTO(struct iwl_priv *priv, void *hcmd, size_t len, u32 flags), - TP_ARGS(priv, hcmd, len, flags), - TP_STRUCT__entry( - PRIV_ENTRY - __dynamic_array(u8, hcmd, len) - __field(u32, flags) - ), - TP_fast_assign( - PRIV_ASSIGN; - memcpy(__get_dynamic_array(hcmd), hcmd, len); - __entry->flags = flags; - ), - TP_printk("[%p] hcmd %#.2x (%ssync)", - __entry->priv, ((u8 *)__get_dynamic_array(hcmd))[0], - __entry->flags & CMD_ASYNC ? "a" : "") -); - -TRACE_EVENT(iwlwifi_legacy_dev_rx, - TP_PROTO(struct iwl_priv *priv, void *rxbuf, size_t len), - TP_ARGS(priv, rxbuf, len), - TP_STRUCT__entry( - PRIV_ENTRY - __dynamic_array(u8, rxbuf, len) - ), - TP_fast_assign( - PRIV_ASSIGN; - memcpy(__get_dynamic_array(rxbuf), rxbuf, len); - ), - TP_printk("[%p] RX cmd %#.2x", - __entry->priv, ((u8 *)__get_dynamic_array(rxbuf))[4]) -); - -TRACE_EVENT(iwlwifi_legacy_dev_tx, - TP_PROTO(struct iwl_priv *priv, void *tfd, size_t tfdlen, - void *buf0, size_t buf0_len, - void *buf1, size_t buf1_len), - TP_ARGS(priv, tfd, tfdlen, buf0, buf0_len, buf1, buf1_len), - TP_STRUCT__entry( - PRIV_ENTRY - - __field(size_t, framelen) - __dynamic_array(u8, tfd, tfdlen) - - /* - * Do not insert between or below these items, - * we want to keep the frame together (except - * for the possible padding). - */ - __dynamic_array(u8, buf0, buf0_len) - __dynamic_array(u8, buf1, buf1_len) - ), - TP_fast_assign( - PRIV_ASSIGN; - __entry->framelen = buf0_len + buf1_len; - memcpy(__get_dynamic_array(tfd), tfd, tfdlen); - memcpy(__get_dynamic_array(buf0), buf0, buf0_len); - memcpy(__get_dynamic_array(buf1), buf1, buf1_len); - ), - TP_printk("[%p] TX %.2x (%zu bytes)", - __entry->priv, - ((u8 *)__get_dynamic_array(buf0))[0], - __entry->framelen) -); - -TRACE_EVENT(iwlwifi_legacy_dev_ucode_error, - TP_PROTO(struct iwl_priv *priv, u32 desc, u32 time, - u32 data1, u32 data2, u32 line, u32 blink1, - u32 blink2, u32 ilink1, u32 ilink2), - TP_ARGS(priv, desc, time, data1, data2, line, - blink1, blink2, ilink1, ilink2), - TP_STRUCT__entry( - PRIV_ENTRY - __field(u32, desc) - __field(u32, time) - __field(u32, data1) - __field(u32, data2) - __field(u32, line) - __field(u32, blink1) - __field(u32, blink2) - __field(u32, ilink1) - __field(u32, ilink2) - ), - TP_fast_assign( - PRIV_ASSIGN; - __entry->desc = desc; - __entry->time = time; - __entry->data1 = data1; - __entry->data2 = data2; - __entry->line = line; - __entry->blink1 = blink1; - __entry->blink2 = blink2; - __entry->ilink1 = ilink1; - __entry->ilink2 = ilink2; - ), - TP_printk("[%p] #%02d %010u data 0x%08X 0x%08X line %u, " - "blink 0x%05X 0x%05X ilink 0x%05X 0x%05X", - __entry->priv, __entry->desc, __entry->time, __entry->data1, - __entry->data2, __entry->line, __entry->blink1, - __entry->blink2, __entry->ilink1, __entry->ilink2) -); - -#endif /* __IWLWIFI_DEVICE_TRACE */ - -#undef TRACE_INCLUDE_PATH -#define TRACE_INCLUDE_PATH . -#undef TRACE_INCLUDE_FILE -#define TRACE_INCLUDE_FILE iwl-devtrace -#include diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h index 5cc5d342914f..868ef01e2058 100644 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ b/drivers/net/wireless/iwlegacy/iwl-io.h @@ -33,7 +33,6 @@ #include "iwl-dev.h" #include "iwl-debug.h" -#include "iwl-devtrace.h" /* * IO, register, and NIC memory access functions @@ -65,7 +64,6 @@ static inline void _iwl_legacy_write8(struct iwl_priv *priv, u32 ofs, u8 val) { - trace_iwlwifi_legacy_dev_iowrite8(priv, ofs, val); iowrite8(val, priv->hw_base + ofs); } @@ -86,7 +84,6 @@ __iwl_legacy_write8(const char *f, u32 l, struct iwl_priv *priv, static inline void _iwl_legacy_write32(struct iwl_priv *priv, u32 ofs, u32 val) { - trace_iwlwifi_legacy_dev_iowrite32(priv, ofs, val); iowrite32(val, priv->hw_base + ofs); } @@ -107,7 +104,6 @@ __iwl_legacy_write32(const char *f, u32 l, struct iwl_priv *priv, static inline u32 _iwl_legacy_read32(struct iwl_priv *priv, u32 ofs) { u32 val = ioread32(priv->hw_base + ofs); - trace_iwlwifi_legacy_dev_ioread32(priv, ofs, val); return val; } diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index ef9e268bf8a0..e1a559b8630f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -539,9 +539,6 @@ int iwl_legacy_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) dma_unmap_addr_set(out_meta, mapping, phys_addr); dma_unmap_len_set(out_meta, len, fix_size); - trace_iwlwifi_legacy_dev_hcmd(priv, &out_cmd->hdr, - fix_size, cmd->flags); - priv->cfg->ops->lib->txq_attach_buf_to_tfd(priv, txq, phys_addr, fix_size, 1, U32_PAD(cmd->len)); diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index b282d869a546..7507819a25ad 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -1246,7 +1246,6 @@ static void iwl3945_rx_handle(struct iwl_priv *priv) len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; len += sizeof(u32); /* account for status word */ - trace_iwlwifi_legacy_dev_rx(priv, pkt, len); /* Reclaim a command buffer only if this packet is a response * to a (driver-originated) command. @@ -1403,8 +1402,6 @@ void iwl3945_dump_nic_error_log(struct iwl_priv *priv) "%-13s (0x%X) %010u 0x%05X 0x%05X 0x%05X 0x%05X %u\n\n", iwl3945_desc_lookup(desc), desc, time, blink1, blink2, ilink1, ilink2, data1); - trace_iwlwifi_legacy_dev_ucode_error(priv, desc, time, data1, 0, - 0, blink1, blink2, ilink1, ilink2); } } diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index d2fba9eae153..fd2f7a40dd9a 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -679,7 +679,6 @@ void iwl4965_rx_handle(struct iwl_priv *priv) len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; len += sizeof(u32); /* account for status word */ - trace_iwlwifi_legacy_dev_rx(priv, pkt, len); /* Reclaim a command buffer only if this packet is a response * to a (driver-originated) command. @@ -1569,10 +1568,6 @@ void iwl4965_dump_nic_error_log(struct iwl_priv *priv) time = iwl_legacy_read_targ_mem(priv, base + 11 * sizeof(u32)); hcmd = iwl_legacy_read_targ_mem(priv, base + 22 * sizeof(u32)); - trace_iwlwifi_legacy_dev_ucode_error(priv, desc, - time, data1, data2, line, - blink1, blink2, ilink1, ilink2); - IWL_ERR(priv, "Desc Time " "data1 data2 line\n"); IWL_ERR(priv, "%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n", -- cgit v1.2.3 From e2ebc8337d116acdc25469ec8547ae665f50a4c1 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 24 Oct 2011 15:41:30 +0200 Subject: iwlegacy: rename iwl to il iwl_legacy prefix result in long function names, what cause that we have frequent line split and not readable code. Also iwl_foo symbols are duplicated in iwlwifi driver, what is annoying when editing kernel tree with cscope. Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c | 32 +- drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h | 12 +- drivers/net/wireless/iwlegacy/iwl-3945-fh.h | 12 +- drivers/net/wireless/iwlegacy/iwl-3945-hw.h | 46 +- drivers/net/wireless/iwlegacy/iwl-3945-led.c | 14 +- drivers/net/wireless/iwlegacy/iwl-3945-led.h | 8 +- drivers/net/wireless/iwlegacy/iwl-3945-rs.c | 468 +++--- drivers/net/wireless/iwlegacy/iwl-3945.c | 1200 ++++++++-------- drivers/net/wireless/iwlegacy/iwl-3945.h | 186 +-- drivers/net/wireless/iwlegacy/iwl-4965-calib.c | 210 +-- drivers/net/wireless/iwlegacy/iwl-4965-calib.h | 16 +- drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c | 32 +- drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h | 12 +- drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c | 26 +- drivers/net/wireless/iwlegacy/iwl-4965-hw.h | 82 +- drivers/net/wireless/iwlegacy/iwl-4965-led.c | 20 +- drivers/net/wireless/iwlegacy/iwl-4965-led.h | 10 +- drivers/net/wireless/iwlegacy/iwl-4965-lib.c | 380 ++--- drivers/net/wireless/iwlegacy/iwl-4965-rs.c | 1112 +++++++-------- drivers/net/wireless/iwlegacy/iwl-4965-rx.c | 52 +- drivers/net/wireless/iwlegacy/iwl-4965-sta.c | 258 ++-- drivers/net/wireless/iwlegacy/iwl-4965-tx.c | 442 +++--- drivers/net/wireless/iwlegacy/iwl-4965-ucode.c | 50 +- drivers/net/wireless/iwlegacy/iwl-4965.c | 846 +++++------ drivers/net/wireless/iwlegacy/iwl-4965.h | 202 +-- drivers/net/wireless/iwlegacy/iwl-commands.h | 506 +++---- drivers/net/wireless/iwlegacy/iwl-core.c | 994 ++++++------- drivers/net/wireless/iwlegacy/iwl-core.h | 434 +++--- drivers/net/wireless/iwlegacy/iwl-csr.h | 16 +- drivers/net/wireless/iwlegacy/iwl-debug.h | 194 +-- drivers/net/wireless/iwlegacy/iwl-debugfs.c | 284 ++-- drivers/net/wireless/iwlegacy/iwl-dev.h | 440 +++--- drivers/net/wireless/iwlegacy/iwl-eeprom.c | 156 +- drivers/net/wireless/iwlegacy/iwl-eeprom.h | 60 +- drivers/net/wireless/iwlegacy/iwl-fh.h | 38 +- drivers/net/wireless/iwlegacy/iwl-hcmd.c | 186 +-- drivers/net/wireless/iwlegacy/iwl-helpers.h | 66 +- drivers/net/wireless/iwlegacy/iwl-io.h | 326 ++--- drivers/net/wireless/iwlegacy/iwl-led.c | 60 +- drivers/net/wireless/iwlegacy/iwl-led.h | 34 +- drivers/net/wireless/iwlegacy/iwl-legacy-rs.h | 404 +++--- drivers/net/wireless/iwlegacy/iwl-power.c | 64 +- drivers/net/wireless/iwlegacy/iwl-power.h | 32 +- drivers/net/wireless/iwlegacy/iwl-prph.h | 18 +- drivers/net/wireless/iwlegacy/iwl-rx.c | 72 +- drivers/net/wireless/iwlegacy/iwl-scan.c | 258 ++-- drivers/net/wireless/iwlegacy/iwl-spectrum.h | 4 +- drivers/net/wireless/iwlegacy/iwl-sta.c | 376 ++--- drivers/net/wireless/iwlegacy/iwl-sta.h | 78 +- drivers/net/wireless/iwlegacy/iwl-tx.c | 200 +-- drivers/net/wireless/iwlegacy/iwl3945-base.c | 1664 +++++++++++----------- drivers/net/wireless/iwlegacy/iwl4965-base.c | 1382 +++++++++--------- 52 files changed, 7037 insertions(+), 7037 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c index cfabb38793ab..954aed4e7b34 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c @@ -29,7 +29,7 @@ #include "iwl-3945-debugfs.h" -static int iwl3945_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz) +static int il3945_statistics_flag(struct il_priv *priv, char *buf, int bufsz) { int p = 0; @@ -50,11 +50,11 @@ static int iwl3945_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz) return p; } -ssize_t iwl3945_ucode_rx_stats_read(struct file *file, +ssize_t il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0; char *buf; int bufsz = sizeof(struct iwl39_statistics_rx_phy) * 40 + @@ -66,12 +66,12 @@ ssize_t iwl3945_ucode_rx_stats_read(struct file *file, struct iwl39_statistics_rx_non_phy *general, *accum_general; struct iwl39_statistics_rx_non_phy *delta_general, *max_general; - if (!iwl_legacy_is_alive(priv)) + if (!il_is_alive(priv)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IWL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(priv, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -93,7 +93,7 @@ ssize_t iwl3945_ucode_rx_stats_read(struct file *file, max_cck = &priv->_3945.max_delta.rx.cck; max_general = &priv->_3945.max_delta.rx.general; - pos += iwl3945_statistics_flag(priv, buf, bufsz); + pos += il3945_statistics_flag(priv, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" "acumulative delta max\n", "Statistics_Rx - OFDM:"); @@ -325,23 +325,23 @@ ssize_t iwl3945_ucode_rx_stats_read(struct file *file, return ret; } -ssize_t iwl3945_ucode_tx_stats_read(struct file *file, +ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0; char *buf; int bufsz = (sizeof(struct iwl39_statistics_tx) * 48) + 250; ssize_t ret; struct iwl39_statistics_tx *tx, *accum_tx, *delta_tx, *max_tx; - if (!iwl_legacy_is_alive(priv)) + if (!il_is_alive(priv)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IWL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(priv, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -354,7 +354,7 @@ ssize_t iwl3945_ucode_tx_stats_read(struct file *file, accum_tx = &priv->_3945.accum_statistics.tx; delta_tx = &priv->_3945.delta_statistics.tx; max_tx = &priv->_3945.max_delta.tx; - pos += iwl3945_statistics_flag(priv, buf, bufsz); + pos += il3945_statistics_flag(priv, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" "acumulative delta max\n", "Statistics_Tx:"); @@ -421,11 +421,11 @@ ssize_t iwl3945_ucode_tx_stats_read(struct file *file, return ret; } -ssize_t iwl3945_ucode_general_stats_read(struct file *file, +ssize_t il3945_ucode_general_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0; char *buf; int bufsz = sizeof(struct iwl39_statistics_general) * 10 + 300; @@ -435,12 +435,12 @@ ssize_t iwl3945_ucode_general_stats_read(struct file *file, struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; struct iwl39_statistics_div *div, *accum_div, *delta_div, *max_div; - if (!iwl_legacy_is_alive(priv)) + if (!il_is_alive(priv)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IWL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(priv, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -461,7 +461,7 @@ ssize_t iwl3945_ucode_general_stats_read(struct file *file, accum_div = &priv->_3945.accum_statistics.general.div; delta_div = &priv->_3945.delta_statistics.general.div; max_div = &priv->_3945.max_delta.general.div; - pos += iwl3945_statistics_flag(priv, buf, bufsz); + pos += il3945_statistics_flag(priv, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" "acumulative delta max\n", "Statistics_General:"); diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h index 8fef4b32b447..54334ac02788 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h @@ -31,27 +31,27 @@ #include "iwl-debug.h" #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS -ssize_t iwl3945_ucode_rx_stats_read(struct file *file, char __user *user_buf, +ssize_t il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos); -ssize_t iwl3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, +ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos); -ssize_t iwl3945_ucode_general_stats_read(struct file *file, +ssize_t il3945_ucode_general_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos); #else -static ssize_t iwl3945_ucode_rx_stats_read(struct file *file, +static ssize_t il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { return 0; } -static ssize_t iwl3945_ucode_tx_stats_read(struct file *file, +static ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { return 0; } -static ssize_t iwl3945_ucode_general_stats_read(struct file *file, +static ssize_t il3945_ucode_general_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-fh.h b/drivers/net/wireless/iwlegacy/iwl-3945-fh.h index 836c9919f82e..b98cabb2ee10 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-fh.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945-fh.h @@ -60,8 +60,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ -#ifndef __iwl_3945_fh_h__ -#define __iwl_3945_fh_h__ +#ifndef __il_3945_fh_h__ +#define __il_3945_fh_h__ /************************************/ /* iwl3945 Flow Handler Definitions */ @@ -172,16 +172,16 @@ #define FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000) -struct iwl3945_tfd_tb { +struct il3945_tfd_tb { __le32 addr; __le32 len; } __packed; -struct iwl3945_tfd { +struct il3945_tfd { __le32 control_flags; - struct iwl3945_tfd_tb tbs[4]; + struct il3945_tfd_tb tbs[4]; u8 __pad[28]; } __packed; -#endif /* __iwl_3945_fh_h__ */ +#endif /* __il_3945_fh_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-hw.h b/drivers/net/wireless/iwlegacy/iwl-3945-hw.h index 5c3a68d3af12..ad0509378714 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-hw.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945-hw.h @@ -66,8 +66,8 @@ * Please use iwl-3945.h for driver implementation definitions. */ -#ifndef __iwl_3945_hw__ -#define __iwl_3945_hw__ +#ifndef __il_3945_hw__ +#define __il_3945_hw__ #include "iwl-eeprom.h" @@ -90,7 +90,7 @@ * Data copied from EEPROM. * DO NOT ALTER THIS STRUCTURE!!! */ -struct iwl3945_eeprom_txpower_sample { +struct il3945_eeprom_txpower_sample { u8 gain_index; /* index into power (gain) setup table ... */ s8 power; /* ... for this pwr level for this chnl group */ u16 v_det; /* PA output voltage */ @@ -104,8 +104,8 @@ struct iwl3945_eeprom_txpower_sample { * Data copied from EEPROM. * DO NOT ALTER THIS STRUCTURE!!! */ -struct iwl3945_eeprom_txpower_group { - struct iwl3945_eeprom_txpower_sample samples[5]; /* 5 power levels */ +struct il3945_eeprom_txpower_group { + struct il3945_eeprom_txpower_sample samples[5]; /* 5 power levels */ s32 a, b, c, d, e; /* coefficients for voltage->power * formula (signed) */ s32 Fa, Fb, Fc, Fd, Fe; /* these modify coeffs based on @@ -123,7 +123,7 @@ struct iwl3945_eeprom_txpower_group { * difference between current temperature and factory calib temperature. * Data copied from EEPROM. */ -struct iwl3945_eeprom_temperature_corr { +struct il3945_eeprom_temperature_corr { u32 Ta; u32 Tb; u32 Tc; @@ -134,7 +134,7 @@ struct iwl3945_eeprom_temperature_corr { /* * EEPROM map */ -struct iwl3945_eeprom { +struct il3945_eeprom { u8 reserved0[16]; u16 device_id; /* abs.ofs: 16 */ u8 reserved1[2]; @@ -171,7 +171,7 @@ struct iwl3945_eeprom { * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 */ u16 band_1_count; /* abs.ofs: 196 */ - struct iwl_eeprom_channel band_1_channels[14]; /* abs.ofs: 198 */ + struct il_eeprom_channel band_1_channels[14]; /* abs.ofs: 198 */ /* * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196, @@ -179,38 +179,38 @@ struct iwl3945_eeprom { * (4915-5080MHz) (none of these is ever supported) */ u16 band_2_count; /* abs.ofs: 226 */ - struct iwl_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */ + struct il_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */ /* * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 * (5170-5320MHz) */ u16 band_3_count; /* abs.ofs: 254 */ - struct iwl_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */ + struct il_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */ /* * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 * (5500-5700MHz) */ u16 band_4_count; /* abs.ofs: 280 */ - struct iwl_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */ + struct il_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */ /* * 5.7 GHz channels 145, 149, 153, 157, 161, 165 * (5725-5825MHz) */ u16 band_5_count; /* abs.ofs: 304 */ - struct iwl_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */ + struct il_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */ u8 reserved9[194]; /* * 3945 Txpower calibration data. */ -#define IWL_NUM_TX_CALIB_GROUPS 5 - struct iwl3945_eeprom_txpower_group groups[IWL_NUM_TX_CALIB_GROUPS]; +#define IL_NUM_TX_CALIB_GROUPS 5 + struct il3945_eeprom_txpower_group groups[IL_NUM_TX_CALIB_GROUPS]; /* abs.ofs: 512 */ - struct iwl3945_eeprom_temperature_corr corrections; /* abs.ofs: 832 */ + struct il3945_eeprom_temperature_corr corrections; /* abs.ofs: 832 */ u8 reserved16[172]; /* fill out to full 1024 byte block */ } __packed; @@ -225,7 +225,7 @@ struct iwl3945_eeprom { #define IWL39_NUM_QUEUES 5 #define IWL39_CMD_QUEUE_NUM 4 -#define IWL_DEFAULT_TX_RETRY 15 +#define IL_DEFAULT_TX_RETRY 15 /*********************************************/ @@ -262,29 +262,29 @@ struct iwl3945_eeprom { /* Size of uCode instruction memory in bootstrap state machine */ #define IWL39_MAX_BSM_SIZE IWL39_RTC_INST_SIZE -static inline int iwl3945_hw_valid_rtc_data_addr(u32 addr) +static inline int il3945_hw_valid_rtc_data_addr(u32 addr) { return (addr >= IWL39_RTC_DATA_LOWER_BOUND) && (addr < IWL39_RTC_DATA_UPPER_BOUND); } -/* Base physical address of iwl3945_shared is provided to FH_TSSR_CBB_BASE - * and &iwl3945_shared.rx_read_ptr[0] is provided to FH_RCSR_RPTR_ADDR(0) */ -struct iwl3945_shared { +/* Base physical address of il3945_shared is provided to FH_TSSR_CBB_BASE + * and &il3945_shared.rx_read_ptr[0] is provided to FH_RCSR_RPTR_ADDR(0) */ +struct il3945_shared { __le32 tx_base_ptr[8]; } __packed; -static inline u8 iwl3945_hw_get_rate(__le16 rate_n_flags) +static inline u8 il3945_hw_get_rate(__le16 rate_n_flags) { return le16_to_cpu(rate_n_flags) & 0xFF; } -static inline u16 iwl3945_hw_get_rate_n_flags(__le16 rate_n_flags) +static inline u16 il3945_hw_get_rate_n_flags(__le16 rate_n_flags) { return le16_to_cpu(rate_n_flags); } -static inline __le16 iwl3945_hw_set_rate_n_flags(u8 rate, u16 flags) +static inline __le16 il3945_hw_set_rate_n_flags(u8 rate, u16 flags) { return cpu_to_le16((u16)rate|flags); } diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-led.c b/drivers/net/wireless/iwlegacy/iwl-3945-led.c index 7a7f0f38c8ab..69703b07bd69 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-led.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-led.c @@ -44,20 +44,20 @@ /* Send led command */ -static int iwl3945_send_led_cmd(struct iwl_priv *priv, - struct iwl_led_cmd *led_cmd) +static int il3945_send_led_cmd(struct il_priv *priv, + struct il_led_cmd *led_cmd) { - struct iwl_host_cmd cmd = { + struct il_host_cmd cmd = { .id = REPLY_LEDS_CMD, - .len = sizeof(struct iwl_led_cmd), + .len = sizeof(struct il_led_cmd), .data = led_cmd, .flags = CMD_ASYNC, .callback = NULL, }; - return iwl_legacy_send_cmd(priv, &cmd); + return il_send_cmd(priv, &cmd); } -const struct iwl_led_ops iwl3945_led_ops = { - .cmd = iwl3945_send_led_cmd, +const struct il_led_ops il3945_led_ops = { + .cmd = il3945_send_led_cmd, }; diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-led.h b/drivers/net/wireless/iwlegacy/iwl-3945-led.h index 96716276eb0d..369c72d5cd68 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-led.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945-led.h @@ -24,9 +24,9 @@ * *****************************************************************************/ -#ifndef __iwl_3945_led_h__ -#define __iwl_3945_led_h__ +#ifndef __il_3945_led_h__ +#define __il_3945_led_h__ -extern const struct iwl_led_ops iwl3945_led_ops; +extern const struct il_led_ops il3945_led_ops; -#endif /* __iwl_3945_led_h__ */ +#endif /* __il_3945_led_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c index 8faeaf2dddec..d97f24bfc451 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c @@ -42,80 +42,80 @@ #define RS_NAME "iwl-3945-rs" -static s32 iwl3945_expected_tpt_g[IWL_RATE_COUNT_3945] = { +static s32 il3945_expected_tpt_g[IL_RATE_COUNT_3945] = { 7, 13, 35, 58, 0, 0, 76, 104, 130, 168, 191, 202 }; -static s32 iwl3945_expected_tpt_g_prot[IWL_RATE_COUNT_3945] = { +static s32 il3945_expected_tpt_g_prot[IL_RATE_COUNT_3945] = { 7, 13, 35, 58, 0, 0, 0, 80, 93, 113, 123, 125 }; -static s32 iwl3945_expected_tpt_a[IWL_RATE_COUNT_3945] = { +static s32 il3945_expected_tpt_a[IL_RATE_COUNT_3945] = { 0, 0, 0, 0, 40, 57, 72, 98, 121, 154, 177, 186 }; -static s32 iwl3945_expected_tpt_b[IWL_RATE_COUNT_3945] = { +static s32 il3945_expected_tpt_b[IL_RATE_COUNT_3945] = { 7, 13, 35, 58, 0, 0, 0, 0, 0, 0, 0, 0 }; -struct iwl3945_tpt_entry { +struct il3945_tpt_entry { s8 min_rssi; u8 index; }; -static struct iwl3945_tpt_entry iwl3945_tpt_table_a[] = { - {-60, IWL_RATE_54M_INDEX}, - {-64, IWL_RATE_48M_INDEX}, - {-72, IWL_RATE_36M_INDEX}, - {-80, IWL_RATE_24M_INDEX}, - {-84, IWL_RATE_18M_INDEX}, - {-85, IWL_RATE_12M_INDEX}, - {-87, IWL_RATE_9M_INDEX}, - {-89, IWL_RATE_6M_INDEX} +static struct il3945_tpt_entry il3945_tpt_table_a[] = { + {-60, IL_RATE_54M_INDEX}, + {-64, IL_RATE_48M_INDEX}, + {-72, IL_RATE_36M_INDEX}, + {-80, IL_RATE_24M_INDEX}, + {-84, IL_RATE_18M_INDEX}, + {-85, IL_RATE_12M_INDEX}, + {-87, IL_RATE_9M_INDEX}, + {-89, IL_RATE_6M_INDEX} }; -static struct iwl3945_tpt_entry iwl3945_tpt_table_g[] = { - {-60, IWL_RATE_54M_INDEX}, - {-64, IWL_RATE_48M_INDEX}, - {-68, IWL_RATE_36M_INDEX}, - {-80, IWL_RATE_24M_INDEX}, - {-84, IWL_RATE_18M_INDEX}, - {-85, IWL_RATE_12M_INDEX}, - {-86, IWL_RATE_11M_INDEX}, - {-88, IWL_RATE_5M_INDEX}, - {-90, IWL_RATE_2M_INDEX}, - {-92, IWL_RATE_1M_INDEX} +static struct il3945_tpt_entry il3945_tpt_table_g[] = { + {-60, IL_RATE_54M_INDEX}, + {-64, IL_RATE_48M_INDEX}, + {-68, IL_RATE_36M_INDEX}, + {-80, IL_RATE_24M_INDEX}, + {-84, IL_RATE_18M_INDEX}, + {-85, IL_RATE_12M_INDEX}, + {-86, IL_RATE_11M_INDEX}, + {-88, IL_RATE_5M_INDEX}, + {-90, IL_RATE_2M_INDEX}, + {-92, IL_RATE_1M_INDEX} }; -#define IWL_RATE_MAX_WINDOW 62 -#define IWL_RATE_FLUSH (3*HZ) -#define IWL_RATE_WIN_FLUSH (HZ/2) +#define IL_RATE_MAX_WINDOW 62 +#define IL_RATE_FLUSH (3*HZ) +#define IL_RATE_WIN_FLUSH (HZ/2) #define IWL39_RATE_HIGH_TH 11520 -#define IWL_SUCCESS_UP_TH 8960 -#define IWL_SUCCESS_DOWN_TH 10880 -#define IWL_RATE_MIN_FAILURE_TH 6 -#define IWL_RATE_MIN_SUCCESS_TH 8 -#define IWL_RATE_DECREASE_TH 1920 -#define IWL_RATE_RETRY_TH 15 - -static u8 iwl3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band) +#define IL_SUCCESS_UP_TH 8960 +#define IL_SUCCESS_DOWN_TH 10880 +#define IL_RATE_MIN_FAILURE_TH 6 +#define IL_RATE_MIN_SUCCESS_TH 8 +#define IL_RATE_DECREASE_TH 1920 +#define IL_RATE_RETRY_TH 15 + +static u8 il3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band) { u32 index = 0; u32 table_size = 0; - struct iwl3945_tpt_entry *tpt_table = NULL; + struct il3945_tpt_entry *tpt_table = NULL; - if ((rssi < IWL_MIN_RSSI_VAL) || (rssi > IWL_MAX_RSSI_VAL)) - rssi = IWL_MIN_RSSI_VAL; + if ((rssi < IL_MIN_RSSI_VAL) || (rssi > IL_MAX_RSSI_VAL)) + rssi = IL_MIN_RSSI_VAL; switch (band) { case IEEE80211_BAND_2GHZ: - tpt_table = iwl3945_tpt_table_g; - table_size = ARRAY_SIZE(iwl3945_tpt_table_g); + tpt_table = il3945_tpt_table_g; + table_size = ARRAY_SIZE(il3945_tpt_table_g); break; case IEEE80211_BAND_5GHZ: - tpt_table = iwl3945_tpt_table_a; - table_size = ARRAY_SIZE(iwl3945_tpt_table_a); + tpt_table = il3945_tpt_table_a; + table_size = ARRAY_SIZE(il3945_tpt_table_a); break; default: @@ -131,46 +131,46 @@ static u8 iwl3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band) return tpt_table[index].index; } -static void iwl3945_clear_window(struct iwl3945_rate_scale_data *window) +static void il3945_clear_window(struct il3945_rate_scale_data *window) { window->data = 0; window->success_counter = 0; window->success_ratio = -1; window->counter = 0; - window->average_tpt = IWL_INVALID_VALUE; + window->average_tpt = IL_INVALID_VALUE; window->stamp = 0; } /** - * iwl3945_rate_scale_flush_windows - flush out the rate scale windows + * il3945_rate_scale_flush_windows - flush out the rate scale windows * * Returns the number of windows that have gathered data but were * not flushed. If there were any that were not flushed, then * reschedule the rate flushing routine. */ -static int iwl3945_rate_scale_flush_windows(struct iwl3945_rs_sta *rs_sta) +static int il3945_rate_scale_flush_windows(struct il3945_rs_sta *rs_sta) { int unflushed = 0; int i; unsigned long flags; - struct iwl_priv *priv __maybe_unused = rs_sta->priv; + struct il_priv *priv __maybe_unused = rs_sta->priv; /* * For each rate, if we have collected data on that rate - * and it has been more than IWL_RATE_WIN_FLUSH + * and it has been more than IL_RATE_WIN_FLUSH * since we flushed, clear out the gathered statistics */ - for (i = 0; i < IWL_RATE_COUNT_3945; i++) { + for (i = 0; i < IL_RATE_COUNT_3945; i++) { if (!rs_sta->win[i].counter) continue; spin_lock_irqsave(&rs_sta->lock, flags); if (time_after(jiffies, rs_sta->win[i].stamp + - IWL_RATE_WIN_FLUSH)) { - IWL_DEBUG_RATE(priv, "flushing %d samples of rate " + IL_RATE_WIN_FLUSH)) { + IL_DEBUG_RATE(priv, "flushing %d samples of rate " "index %d\n", rs_sta->win[i].counter, i); - iwl3945_clear_window(&rs_sta->win[i]); + il3945_clear_window(&rs_sta->win[i]); } else unflushed++; spin_unlock_irqrestore(&rs_sta->lock, flags); @@ -179,21 +179,21 @@ static int iwl3945_rate_scale_flush_windows(struct iwl3945_rs_sta *rs_sta) return unflushed; } -#define IWL_RATE_FLUSH_MAX 5000 /* msec */ -#define IWL_RATE_FLUSH_MIN 50 /* msec */ -#define IWL_AVERAGE_PACKETS 1500 +#define IL_RATE_FLUSH_MAX 5000 /* msec */ +#define IL_RATE_FLUSH_MIN 50 /* msec */ +#define IL_AVERAGE_PACKETS 1500 -static void iwl3945_bg_rate_scale_flush(unsigned long data) +static void il3945_bg_rate_scale_flush(unsigned long data) { - struct iwl3945_rs_sta *rs_sta = (void *)data; - struct iwl_priv *priv __maybe_unused = rs_sta->priv; + struct il3945_rs_sta *rs_sta = (void *)data; + struct il_priv *priv __maybe_unused = rs_sta->priv; int unflushed = 0; unsigned long flags; u32 packet_count, duration, pps; - IWL_DEBUG_RATE(priv, "enter\n"); + IL_DEBUG_RATE(priv, "enter\n"); - unflushed = iwl3945_rate_scale_flush_windows(rs_sta); + unflushed = il3945_rate_scale_flush_windows(rs_sta); spin_lock_irqsave(&rs_sta->lock, flags); @@ -206,7 +206,7 @@ static void iwl3945_bg_rate_scale_flush(unsigned long data) duration = jiffies_to_msecs(jiffies - rs_sta->last_partial_flush); - IWL_DEBUG_RATE(priv, "Tx'd %d packets in %dms\n", + IL_DEBUG_RATE(priv, "Tx'd %d packets in %dms\n", packet_count, duration); /* Determine packets per second */ @@ -216,17 +216,17 @@ static void iwl3945_bg_rate_scale_flush(unsigned long data) pps = 0; if (pps) { - duration = (IWL_AVERAGE_PACKETS * 1000) / pps; - if (duration < IWL_RATE_FLUSH_MIN) - duration = IWL_RATE_FLUSH_MIN; - else if (duration > IWL_RATE_FLUSH_MAX) - duration = IWL_RATE_FLUSH_MAX; + duration = (IL_AVERAGE_PACKETS * 1000) / pps; + if (duration < IL_RATE_FLUSH_MIN) + duration = IL_RATE_FLUSH_MIN; + else if (duration > IL_RATE_FLUSH_MAX) + duration = IL_RATE_FLUSH_MAX; } else - duration = IWL_RATE_FLUSH_MAX; + duration = IL_RATE_FLUSH_MAX; rs_sta->flush_time = msecs_to_jiffies(duration); - IWL_DEBUG_RATE(priv, "new flush period: %d msec ave %d\n", + IL_DEBUG_RATE(priv, "new flush period: %d msec ave %d\n", duration, packet_count); mod_timer(&rs_sta->rate_scale_flush, jiffies + @@ -234,7 +234,7 @@ static void iwl3945_bg_rate_scale_flush(unsigned long data) rs_sta->last_partial_flush = jiffies; } else { - rs_sta->flush_time = IWL_RATE_FLUSH; + rs_sta->flush_time = IL_RATE_FLUSH; rs_sta->flush_pending = 0; } /* If there weren't any unflushed entries, we don't schedule the timer @@ -244,26 +244,26 @@ static void iwl3945_bg_rate_scale_flush(unsigned long data) spin_unlock_irqrestore(&rs_sta->lock, flags); - IWL_DEBUG_RATE(priv, "leave\n"); + IL_DEBUG_RATE(priv, "leave\n"); } /** - * iwl3945_collect_tx_data - Update the success/failure sliding window + * il3945_collect_tx_data - Update the success/failure sliding window * * We keep a sliding window of the last 64 packets transmitted * at this rate. window->data contains the bitmask of successful * packets. */ -static void iwl3945_collect_tx_data(struct iwl3945_rs_sta *rs_sta, - struct iwl3945_rate_scale_data *window, +static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, + struct il3945_rate_scale_data *window, int success, int retries, int index) { unsigned long flags; s32 fail_count; - struct iwl_priv *priv __maybe_unused = rs_sta->priv; + struct il_priv *priv __maybe_unused = rs_sta->priv; if (!retries) { - IWL_DEBUG_RATE(priv, "leave: retries == 0 -- should be at least 1\n"); + IL_DEBUG_RATE(priv, "leave: retries == 0 -- should be at least 1\n"); return; } @@ -278,13 +278,13 @@ static void iwl3945_collect_tx_data(struct iwl3945_rs_sta *rs_sta, * we keep these bitmaps!). * */ while (retries > 0) { - if (window->counter >= IWL_RATE_MAX_WINDOW) { + if (window->counter >= IL_RATE_MAX_WINDOW) { /* remove earliest */ - window->counter = IWL_RATE_MAX_WINDOW - 1; + window->counter = IL_RATE_MAX_WINDOW - 1; - if (window->data & (1ULL << (IWL_RATE_MAX_WINDOW - 1))) { - window->data &= ~(1ULL << (IWL_RATE_MAX_WINDOW - 1)); + if (window->data & (1ULL << (IL_RATE_MAX_WINDOW - 1))) { + window->data &= ~(1ULL << (IL_RATE_MAX_WINDOW - 1)); window->success_counter--; } } @@ -310,17 +310,17 @@ static void iwl3945_collect_tx_data(struct iwl3945_rs_sta *rs_sta, window->success_ratio = 128 * (100 * window->success_counter) / window->counter; else - window->success_ratio = IWL_INVALID_VALUE; + window->success_ratio = IL_INVALID_VALUE; fail_count = window->counter - window->success_counter; /* Calculate average throughput, if we have enough history. */ - if ((fail_count >= IWL_RATE_MIN_FAILURE_TH) || - (window->success_counter >= IWL_RATE_MIN_SUCCESS_TH)) + if ((fail_count >= IL_RATE_MIN_FAILURE_TH) || + (window->success_counter >= IL_RATE_MIN_SUCCESS_TH)) window->average_tpt = ((window->success_ratio * rs_sta->expected_tpt[index] + 64) / 128); else - window->average_tpt = IWL_INVALID_VALUE; + window->average_tpt = IL_INVALID_VALUE; /* Tag this window as having been updated */ window->stamp = jiffies; @@ -332,40 +332,40 @@ static void iwl3945_collect_tx_data(struct iwl3945_rs_sta *rs_sta, /* * Called after adding a new station to initialize rate scaling */ -void iwl3945_rs_rate_init(struct iwl_priv *priv, struct ieee80211_sta *sta, u8 sta_id) +void il3945_rs_rate_init(struct il_priv *priv, struct ieee80211_sta *sta, u8 sta_id) { struct ieee80211_hw *hw = priv->hw; struct ieee80211_conf *conf = &priv->hw->conf; - struct iwl3945_sta_priv *psta; - struct iwl3945_rs_sta *rs_sta; + struct il3945_sta_priv *psta; + struct il3945_rs_sta *rs_sta; struct ieee80211_supported_band *sband; int i; - IWL_DEBUG_INFO(priv, "enter\n"); - if (sta_id == priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id) + IL_DEBUG_INFO(priv, "enter\n"); + if (sta_id == priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id) goto out; - psta = (struct iwl3945_sta_priv *) sta->drv_priv; + psta = (struct il3945_sta_priv *) sta->drv_priv; rs_sta = &psta->rs_sta; sband = hw->wiphy->bands[conf->channel->band]; rs_sta->priv = priv; - rs_sta->start_rate = IWL_RATE_INVALID; + rs_sta->start_rate = IL_RATE_INVALID; /* default to just 802.11b */ - rs_sta->expected_tpt = iwl3945_expected_tpt_b; + rs_sta->expected_tpt = il3945_expected_tpt_b; rs_sta->last_partial_flush = jiffies; rs_sta->last_flush = jiffies; - rs_sta->flush_time = IWL_RATE_FLUSH; + rs_sta->flush_time = IL_RATE_FLUSH; rs_sta->last_tx_packets = 0; rs_sta->rate_scale_flush.data = (unsigned long)rs_sta; - rs_sta->rate_scale_flush.function = iwl3945_bg_rate_scale_flush; + rs_sta->rate_scale_flush.function = il3945_bg_rate_scale_flush; - for (i = 0; i < IWL_RATE_COUNT_3945; i++) - iwl3945_clear_window(&rs_sta->win[i]); + for (i = 0; i < IL_RATE_COUNT_3945; i++) + il3945_clear_window(&rs_sta->win[i]); /* TODO: what is a good starting rate for STA? About middle? Maybe not * the lowest or the highest rate.. Could consider using RSSI from @@ -380,56 +380,56 @@ void iwl3945_rs_rate_init(struct iwl_priv *priv, struct ieee80211_sta *sta, u8 s } priv->_3945.sta_supp_rates = sta->supp_rates[sband->band]; - /* For 5 GHz band it start at IWL_FIRST_OFDM_RATE */ + /* For 5 GHz band it start at IL_FIRST_OFDM_RATE */ if (sband->band == IEEE80211_BAND_5GHZ) { - rs_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; + rs_sta->last_txrate_idx += IL_FIRST_OFDM_RATE; priv->_3945.sta_supp_rates = priv->_3945.sta_supp_rates << - IWL_FIRST_OFDM_RATE; + IL_FIRST_OFDM_RATE; } out: - priv->stations[sta_id].used &= ~IWL_STA_UCODE_INPROGRESS; + priv->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; - IWL_DEBUG_INFO(priv, "leave\n"); + IL_DEBUG_INFO(priv, "leave\n"); } -static void *iwl3945_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) +static void *il3945_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) { return hw->priv; } /* rate scale requires free function to be implemented */ -static void iwl3945_rs_free(void *priv) +static void il3945_rs_free(void *priv) { return; } -static void *iwl3945_rs_alloc_sta(void *iwl_priv, struct ieee80211_sta *sta, gfp_t gfp) +static void *il3945_rs_alloc_sta(void *il_priv, struct ieee80211_sta *sta, gfp_t gfp) { - struct iwl3945_rs_sta *rs_sta; - struct iwl3945_sta_priv *psta = (void *) sta->drv_priv; - struct iwl_priv *priv __maybe_unused = iwl_priv; + struct il3945_rs_sta *rs_sta; + struct il3945_sta_priv *psta = (void *) sta->drv_priv; + struct il_priv *priv __maybe_unused = il_priv; - IWL_DEBUG_RATE(priv, "enter\n"); + IL_DEBUG_RATE(priv, "enter\n"); rs_sta = &psta->rs_sta; spin_lock_init(&rs_sta->lock); init_timer(&rs_sta->rate_scale_flush); - IWL_DEBUG_RATE(priv, "leave\n"); + IL_DEBUG_RATE(priv, "leave\n"); return rs_sta; } -static void iwl3945_rs_free_sta(void *iwl_priv, struct ieee80211_sta *sta, +static void il3945_rs_free_sta(void *il_priv, struct ieee80211_sta *sta, void *priv_sta) { - struct iwl3945_rs_sta *rs_sta = priv_sta; + struct il3945_rs_sta *rs_sta = priv_sta; /* - * Be careful not to use any members of iwl3945_rs_sta (like trying - * to use iwl_priv to print out debugging) since it may not be fully + * Be careful not to use any members of il3945_rs_sta (like trying + * to use il_priv to print out debugging) since it may not be fully * initialized at this point. */ del_timer_sync(&rs_sta->rate_scale_flush); @@ -437,43 +437,43 @@ static void iwl3945_rs_free_sta(void *iwl_priv, struct ieee80211_sta *sta, /** - * iwl3945_rs_tx_status - Update rate control values based on Tx results + * il3945_rs_tx_status - Update rate control values based on Tx results * - * NOTE: Uses iwl_priv->retry_rate for the # of retries attempted by + * NOTE: Uses il_priv->retry_rate for the # of retries attempted by * the hardware for each rate. */ -static void iwl3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband, +static void il3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband, struct ieee80211_sta *sta, void *priv_sta, struct sk_buff *skb) { s8 retries = 0, current_count; int scale_rate_index, first_index, last_index; unsigned long flags; - struct iwl_priv *priv = (struct iwl_priv *)priv_rate; - struct iwl3945_rs_sta *rs_sta = priv_sta; + struct il_priv *priv = (struct il_priv *)priv_rate; + struct il3945_rs_sta *rs_sta = priv_sta; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - IWL_DEBUG_RATE(priv, "enter\n"); + IL_DEBUG_RATE(priv, "enter\n"); retries = info->status.rates[0].count; /* Sanity Check for retries */ - if (retries > IWL_RATE_RETRY_TH) - retries = IWL_RATE_RETRY_TH; + if (retries > IL_RATE_RETRY_TH) + retries = IL_RATE_RETRY_TH; first_index = sband->bitrates[info->status.rates[0].idx].hw_value; - if ((first_index < 0) || (first_index >= IWL_RATE_COUNT_3945)) { - IWL_DEBUG_RATE(priv, "leave: Rate out of bounds: %d\n", first_index); + if ((first_index < 0) || (first_index >= IL_RATE_COUNT_3945)) { + IL_DEBUG_RATE(priv, "leave: Rate out of bounds: %d\n", first_index); return; } if (!priv_sta) { - IWL_DEBUG_RATE(priv, "leave: No STA priv data to update!\n"); + IL_DEBUG_RATE(priv, "leave: No STA priv data to update!\n"); return; } /* Treat uninitialized rate scaling data same as non-existing. */ if (!rs_sta->priv) { - IWL_DEBUG_RATE(priv, "leave: STA priv data uninitialized!\n"); + IL_DEBUG_RATE(priv, "leave: STA priv data uninitialized!\n"); return; } @@ -499,16 +499,16 @@ static void iwl3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_ban last_index = scale_rate_index; } else { current_count = priv->retry_rate; - last_index = iwl3945_rs_next_rate(priv, + last_index = il3945_rs_next_rate(priv, scale_rate_index); } /* Update this rate accounting for as many retries * as was used for it (per current_count) */ - iwl3945_collect_tx_data(rs_sta, + il3945_collect_tx_data(rs_sta, &rs_sta->win[scale_rate_index], 0, current_count, scale_rate_index); - IWL_DEBUG_RATE(priv, "Update rate %d for %d retries.\n", + IL_DEBUG_RATE(priv, "Update rate %d for %d retries.\n", scale_rate_index, current_count); retries -= current_count; @@ -518,11 +518,11 @@ static void iwl3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_ban /* Update the last index window with success/failure based on ACK */ - IWL_DEBUG_RATE(priv, "Update rate %d with %s.\n", + IL_DEBUG_RATE(priv, "Update rate %d with %s.\n", last_index, (info->flags & IEEE80211_TX_STAT_ACK) ? "success" : "failure"); - iwl3945_collect_tx_data(rs_sta, + il3945_collect_tx_data(rs_sta, &rs_sta->win[last_index], info->flags & IEEE80211_TX_STAT_ACK, 1, last_index); @@ -543,15 +543,15 @@ static void iwl3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_ban spin_unlock_irqrestore(&rs_sta->lock, flags); - IWL_DEBUG_RATE(priv, "leave\n"); + IL_DEBUG_RATE(priv, "leave\n"); } -static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta, +static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, u8 index, u16 rate_mask, enum ieee80211_band band) { - u8 high = IWL_RATE_INVALID; - u8 low = IWL_RATE_INVALID; - struct iwl_priv *priv __maybe_unused = rs_sta->priv; + u8 high = IL_RATE_INVALID; + u8 low = IL_RATE_INVALID; + struct il_priv *priv __maybe_unused = rs_sta->priv; /* 802.11A walks to the next literal adjacent rate in * the rate table */ @@ -570,7 +570,7 @@ static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta, /* Find the next rate that is in the rate mask */ i = index + 1; - for (mask = (1 << i); i < IWL_RATE_COUNT_3945; + for (mask = (1 << i); i < IL_RATE_COUNT_3945; i++, mask <<= 1) { if (rate_mask & mask) { high = i; @@ -582,36 +582,36 @@ static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta, } low = index; - while (low != IWL_RATE_INVALID) { + while (low != IL_RATE_INVALID) { if (rs_sta->tgg) - low = iwl3945_rates[low].prev_rs_tgg; + low = il3945_rates[low].prev_rs_tgg; else - low = iwl3945_rates[low].prev_rs; - if (low == IWL_RATE_INVALID) + low = il3945_rates[low].prev_rs; + if (low == IL_RATE_INVALID) break; if (rate_mask & (1 << low)) break; - IWL_DEBUG_RATE(priv, "Skipping masked lower rate: %d\n", low); + IL_DEBUG_RATE(priv, "Skipping masked lower rate: %d\n", low); } high = index; - while (high != IWL_RATE_INVALID) { + while (high != IL_RATE_INVALID) { if (rs_sta->tgg) - high = iwl3945_rates[high].next_rs_tgg; + high = il3945_rates[high].next_rs_tgg; else - high = iwl3945_rates[high].next_rs; - if (high == IWL_RATE_INVALID) + high = il3945_rates[high].next_rs; + if (high == IL_RATE_INVALID) break; if (rate_mask & (1 << high)) break; - IWL_DEBUG_RATE(priv, "Skipping masked higher rate: %d\n", high); + IL_DEBUG_RATE(priv, "Skipping masked higher rate: %d\n", high); } return (high << 8) | low; } /** - * iwl3945_rs_get_rate - find the rate for the requested packet + * il3945_rs_get_rate - find the rate for the requested packet * * Returns the ieee80211_rate structure allocated by the driver. * @@ -626,33 +626,33 @@ static u16 iwl3945_get_adjacent_rate(struct iwl3945_rs_sta *rs_sta, * rate table and must reference the driver allocated rate table * */ -static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, +static void il3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta, struct ieee80211_tx_rate_control *txrc) { struct ieee80211_supported_band *sband = txrc->sband; struct sk_buff *skb = txrc->skb; - u8 low = IWL_RATE_INVALID; - u8 high = IWL_RATE_INVALID; + u8 low = IL_RATE_INVALID; + u8 high = IL_RATE_INVALID; u16 high_low; int index; - struct iwl3945_rs_sta *rs_sta = priv_sta; - struct iwl3945_rate_scale_data *window = NULL; - int current_tpt = IWL_INVALID_VALUE; - int low_tpt = IWL_INVALID_VALUE; - int high_tpt = IWL_INVALID_VALUE; + struct il3945_rs_sta *rs_sta = priv_sta; + struct il3945_rate_scale_data *window = NULL; + int current_tpt = IL_INVALID_VALUE; + int low_tpt = IL_INVALID_VALUE; + int high_tpt = IL_INVALID_VALUE; u32 fail_count; s8 scale_action = 0; unsigned long flags; u16 rate_mask; s8 max_rate_idx = -1; - struct iwl_priv *priv __maybe_unused = (struct iwl_priv *)priv_r; + struct il_priv *priv __maybe_unused = (struct il_priv *)priv_r; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - IWL_DEBUG_RATE(priv, "enter\n"); + IL_DEBUG_RATE(priv, "enter\n"); /* Treat uninitialized rate scaling data same as non-existing. */ if (rs_sta && !rs_sta->priv) { - IWL_DEBUG_RATE(priv, "Rate scaling information not initialized yet.\n"); + IL_DEBUG_RATE(priv, "Rate scaling information not initialized yet.\n"); priv_sta = NULL; } @@ -664,25 +664,25 @@ static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, /* get user max rate if set */ max_rate_idx = txrc->max_rate_idx; if ((sband->band == IEEE80211_BAND_5GHZ) && (max_rate_idx != -1)) - max_rate_idx += IWL_FIRST_OFDM_RATE; - if ((max_rate_idx < 0) || (max_rate_idx >= IWL_RATE_COUNT)) + max_rate_idx += IL_FIRST_OFDM_RATE; + if ((max_rate_idx < 0) || (max_rate_idx >= IL_RATE_COUNT)) max_rate_idx = -1; - index = min(rs_sta->last_txrate_idx & 0xffff, IWL_RATE_COUNT_3945 - 1); + index = min(rs_sta->last_txrate_idx & 0xffff, IL_RATE_COUNT_3945 - 1); if (sband->band == IEEE80211_BAND_5GHZ) - rate_mask = rate_mask << IWL_FIRST_OFDM_RATE; + rate_mask = rate_mask << IL_FIRST_OFDM_RATE; spin_lock_irqsave(&rs_sta->lock, flags); /* for recent assoc, choose best rate regarding * to rssi value */ - if (rs_sta->start_rate != IWL_RATE_INVALID) { + if (rs_sta->start_rate != IL_RATE_INVALID) { if (rs_sta->start_rate < index && (rate_mask & (1 << rs_sta->start_rate))) index = rs_sta->start_rate; - rs_sta->start_rate = IWL_RATE_INVALID; + rs_sta->start_rate = IL_RATE_INVALID; } /* force user max rate if set by user */ @@ -695,11 +695,11 @@ static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, fail_count = window->counter - window->success_counter; - if (((fail_count < IWL_RATE_MIN_FAILURE_TH) && - (window->success_counter < IWL_RATE_MIN_SUCCESS_TH))) { + if (((fail_count < IL_RATE_MIN_FAILURE_TH) && + (window->success_counter < IL_RATE_MIN_SUCCESS_TH))) { spin_unlock_irqrestore(&rs_sta->lock, flags); - IWL_DEBUG_RATE(priv, "Invalid average_tpt on rate %d: " + IL_DEBUG_RATE(priv, "Invalid average_tpt on rate %d: " "counter: %d, success_counter: %d, " "expected_tpt is %sNULL\n", index, @@ -708,27 +708,27 @@ static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, rs_sta->expected_tpt ? "not " : ""); /* Can't calculate this yet; not enough history */ - window->average_tpt = IWL_INVALID_VALUE; + window->average_tpt = IL_INVALID_VALUE; goto out; } current_tpt = window->average_tpt; - high_low = iwl3945_get_adjacent_rate(rs_sta, index, rate_mask, + high_low = il3945_get_adjacent_rate(rs_sta, index, rate_mask, sband->band); low = high_low & 0xff; high = (high_low >> 8) & 0xff; /* If user set max rate, dont allow higher than user constrain */ if ((max_rate_idx != -1) && (max_rate_idx < high)) - high = IWL_RATE_INVALID; + high = IL_RATE_INVALID; /* Collect Measured throughputs of adjacent rates */ - if (low != IWL_RATE_INVALID) + if (low != IL_RATE_INVALID) low_tpt = rs_sta->win[low].average_tpt; - if (high != IWL_RATE_INVALID) + if (high != IL_RATE_INVALID) high_tpt = rs_sta->win[high].average_tpt; spin_unlock_irqrestore(&rs_sta->lock, flags); @@ -736,51 +736,51 @@ static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, scale_action = 0; /* Low success ratio , need to drop the rate */ - if ((window->success_ratio < IWL_RATE_DECREASE_TH) || !current_tpt) { - IWL_DEBUG_RATE(priv, "decrease rate because of low success_ratio\n"); + if ((window->success_ratio < IL_RATE_DECREASE_TH) || !current_tpt) { + IL_DEBUG_RATE(priv, "decrease rate because of low success_ratio\n"); scale_action = -1; /* No throughput measured yet for adjacent rates, * try increase */ - } else if ((low_tpt == IWL_INVALID_VALUE) && - (high_tpt == IWL_INVALID_VALUE)) { + } else if ((low_tpt == IL_INVALID_VALUE) && + (high_tpt == IL_INVALID_VALUE)) { - if (high != IWL_RATE_INVALID && window->success_ratio >= IWL_RATE_INCREASE_TH) + if (high != IL_RATE_INVALID && window->success_ratio >= IL_RATE_INCREASE_TH) scale_action = 1; - else if (low != IWL_RATE_INVALID) + else if (low != IL_RATE_INVALID) scale_action = 0; /* Both adjacent throughputs are measured, but neither one has * better throughput; we're using the best rate, don't change * it! */ - } else if ((low_tpt != IWL_INVALID_VALUE) && - (high_tpt != IWL_INVALID_VALUE) && + } else if ((low_tpt != IL_INVALID_VALUE) && + (high_tpt != IL_INVALID_VALUE) && (low_tpt < current_tpt) && (high_tpt < current_tpt)) { - IWL_DEBUG_RATE(priv, "No action -- low [%d] & high [%d] < " + IL_DEBUG_RATE(priv, "No action -- low [%d] & high [%d] < " "current_tpt [%d]\n", low_tpt, high_tpt, current_tpt); scale_action = 0; /* At least one of the rates has better throughput */ } else { - if (high_tpt != IWL_INVALID_VALUE) { + if (high_tpt != IL_INVALID_VALUE) { /* High rate has better throughput, Increase * rate */ if (high_tpt > current_tpt && - window->success_ratio >= IWL_RATE_INCREASE_TH) + window->success_ratio >= IL_RATE_INCREASE_TH) scale_action = 1; else { - IWL_DEBUG_RATE(priv, + IL_DEBUG_RATE(priv, "decrease rate because of high tpt\n"); scale_action = 0; } - } else if (low_tpt != IWL_INVALID_VALUE) { + } else if (low_tpt != IL_INVALID_VALUE) { if (low_tpt > current_tpt) { - IWL_DEBUG_RATE(priv, + IL_DEBUG_RATE(priv, "decrease rate because of low tpt\n"); scale_action = -1; - } else if (window->success_ratio >= IWL_RATE_INCREASE_TH) { + } else if (window->success_ratio >= IL_RATE_INCREASE_TH) { /* Lower rate has better * throughput,decrease rate */ scale_action = 1; @@ -790,8 +790,8 @@ static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, /* Sanity check; asked for decrease, but success rate or throughput * has been good at old rate. Don't change it. */ - if ((scale_action == -1) && (low != IWL_RATE_INVALID) && - ((window->success_ratio > IWL_RATE_HIGH_TH) || + if ((scale_action == -1) && (low != IL_RATE_INVALID) && + ((window->success_ratio > IL_RATE_HIGH_TH) || (current_tpt > (100 * rs_sta->expected_tpt[low])))) scale_action = 0; @@ -799,13 +799,13 @@ static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, case -1: /* Decrese rate */ - if (low != IWL_RATE_INVALID) + if (low != IL_RATE_INVALID) index = low; break; case 1: /* Increase rate */ - if (high != IWL_RATE_INVALID) + if (high != IL_RATE_INVALID) index = high; break; @@ -816,32 +816,32 @@ static void iwl3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, break; } - IWL_DEBUG_RATE(priv, "Selected %d (action %d) - low %d high %d\n", + IL_DEBUG_RATE(priv, "Selected %d (action %d) - low %d high %d\n", index, scale_action, low, high); out: if (sband->band == IEEE80211_BAND_5GHZ) { - if (WARN_ON_ONCE(index < IWL_FIRST_OFDM_RATE)) - index = IWL_FIRST_OFDM_RATE; + if (WARN_ON_ONCE(index < IL_FIRST_OFDM_RATE)) + index = IL_FIRST_OFDM_RATE; rs_sta->last_txrate_idx = index; - info->control.rates[0].idx = index - IWL_FIRST_OFDM_RATE; + info->control.rates[0].idx = index - IL_FIRST_OFDM_RATE; } else { rs_sta->last_txrate_idx = index; info->control.rates[0].idx = rs_sta->last_txrate_idx; } - IWL_DEBUG_RATE(priv, "leave: %d\n", index); + IL_DEBUG_RATE(priv, "leave: %d\n", index); } #ifdef CONFIG_MAC80211_DEBUGFS -static int iwl3945_open_file_generic(struct inode *inode, struct file *file) +static int il3945_open_file_generic(struct inode *inode, struct file *file) { file->private_data = inode->i_private; return 0; } -static ssize_t iwl3945_sta_dbgfs_stats_table_read(struct file *file, +static ssize_t il3945_sta_dbgfs_stats_table_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { @@ -849,7 +849,7 @@ static ssize_t iwl3945_sta_dbgfs_stats_table_read(struct file *file, int desc = 0; int j; ssize_t ret; - struct iwl3945_rs_sta *lq_sta = file->private_data; + struct il3945_rs_sta *lq_sta = file->private_data; buff = kmalloc(1024, GFP_KERNEL); if (!buff) @@ -860,7 +860,7 @@ static ssize_t iwl3945_sta_dbgfs_stats_table_read(struct file *file, lq_sta->tx_packets, lq_sta->last_txrate_idx, lq_sta->start_rate, jiffies_to_msecs(lq_sta->flush_time)); - for (j = 0; j < IWL_RATE_COUNT_3945; j++) { + for (j = 0; j < IL_RATE_COUNT_3945; j++) { desc += sprintf(buff+desc, "counter=%d success=%d %%=%d\n", lq_sta->win[j].counter, @@ -873,15 +873,15 @@ static ssize_t iwl3945_sta_dbgfs_stats_table_read(struct file *file, } static const struct file_operations rs_sta_dbgfs_stats_table_ops = { - .read = iwl3945_sta_dbgfs_stats_table_read, - .open = iwl3945_open_file_generic, + .read = il3945_sta_dbgfs_stats_table_read, + .open = il3945_open_file_generic, .llseek = default_llseek, }; -static void iwl3945_add_debugfs(void *priv, void *priv_sta, +static void il3945_add_debugfs(void *priv, void *priv_sta, struct dentry *dir) { - struct iwl3945_rs_sta *lq_sta = priv_sta; + struct il3945_rs_sta *lq_sta = priv_sta; lq_sta->rs_sta_dbgfs_stats_table_file = debugfs_create_file("rate_stats_table", 0600, dir, @@ -889,9 +889,9 @@ static void iwl3945_add_debugfs(void *priv, void *priv_sta, } -static void iwl3945_remove_debugfs(void *priv, void *priv_sta) +static void il3945_remove_debugfs(void *priv, void *priv_sta) { - struct iwl3945_rs_sta *lq_sta = priv_sta; + struct il3945_rs_sta *lq_sta = priv_sta; debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file); } #endif @@ -901,7 +901,7 @@ static void iwl3945_remove_debugfs(void *priv, void *priv_sta) * the station is added. Since mac80211 calls this function before a * station is added we ignore it. */ -static void iwl3945_rs_rate_init_stub(void *priv_r, +static void il3945_rs_rate_init_stub(void *priv_r, struct ieee80211_supported_band *sband, struct ieee80211_sta *sta, void *priv_sta) { @@ -910,36 +910,36 @@ static void iwl3945_rs_rate_init_stub(void *priv_r, static struct rate_control_ops rs_ops = { .module = NULL, .name = RS_NAME, - .tx_status = iwl3945_rs_tx_status, - .get_rate = iwl3945_rs_get_rate, - .rate_init = iwl3945_rs_rate_init_stub, - .alloc = iwl3945_rs_alloc, - .free = iwl3945_rs_free, - .alloc_sta = iwl3945_rs_alloc_sta, - .free_sta = iwl3945_rs_free_sta, + .tx_status = il3945_rs_tx_status, + .get_rate = il3945_rs_get_rate, + .rate_init = il3945_rs_rate_init_stub, + .alloc = il3945_rs_alloc, + .free = il3945_rs_free, + .alloc_sta = il3945_rs_alloc_sta, + .free_sta = il3945_rs_free_sta, #ifdef CONFIG_MAC80211_DEBUGFS - .add_sta_debugfs = iwl3945_add_debugfs, - .remove_sta_debugfs = iwl3945_remove_debugfs, + .add_sta_debugfs = il3945_add_debugfs, + .remove_sta_debugfs = il3945_remove_debugfs, #endif }; -void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) +void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; s32 rssi = 0; unsigned long flags; - struct iwl3945_rs_sta *rs_sta; + struct il3945_rs_sta *rs_sta; struct ieee80211_sta *sta; - struct iwl3945_sta_priv *psta; + struct il3945_sta_priv *psta; - IWL_DEBUG_RATE(priv, "enter\n"); + IL_DEBUG_RATE(priv, "enter\n"); rcu_read_lock(); - sta = ieee80211_find_sta(priv->contexts[IWL_RXON_CTX_BSS].vif, + sta = ieee80211_find_sta(priv->contexts[IL_RXON_CTX_BSS].vif, priv->stations[sta_id].sta.sta.addr); if (!sta) { - IWL_DEBUG_RATE(priv, "Unable to find station to initialize rate scaling.\n"); + IL_DEBUG_RATE(priv, "Unable to find station to initialize rate scaling.\n"); rcu_read_unlock(); return; } @@ -953,16 +953,16 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) switch (priv->band) { case IEEE80211_BAND_2GHZ: /* TODO: this always does G, not a regression */ - if (priv->contexts[IWL_RXON_CTX_BSS].active.flags & + if (priv->contexts[IL_RXON_CTX_BSS].active.flags & RXON_FLG_TGG_PROTECT_MSK) { rs_sta->tgg = 1; - rs_sta->expected_tpt = iwl3945_expected_tpt_g_prot; + rs_sta->expected_tpt = il3945_expected_tpt_g_prot; } else - rs_sta->expected_tpt = iwl3945_expected_tpt_g; + rs_sta->expected_tpt = il3945_expected_tpt_g; break; case IEEE80211_BAND_5GHZ: - rs_sta->expected_tpt = iwl3945_expected_tpt_a; + rs_sta->expected_tpt = il3945_expected_tpt_a; break; case IEEE80211_NUM_BANDS: BUG(); @@ -973,24 +973,24 @@ void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) rssi = priv->_3945.last_rx_rssi; if (rssi == 0) - rssi = IWL_MIN_RSSI_VAL; + rssi = IL_MIN_RSSI_VAL; - IWL_DEBUG_RATE(priv, "Network RSSI: %d\n", rssi); + IL_DEBUG_RATE(priv, "Network RSSI: %d\n", rssi); - rs_sta->start_rate = iwl3945_get_rate_index_by_rssi(rssi, priv->band); + rs_sta->start_rate = il3945_get_rate_index_by_rssi(rssi, priv->band); - IWL_DEBUG_RATE(priv, "leave: rssi %d assign rate index: " + IL_DEBUG_RATE(priv, "leave: rssi %d assign rate index: " "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate, - iwl3945_rates[rs_sta->start_rate].plcp); + il3945_rates[rs_sta->start_rate].plcp); rcu_read_unlock(); } -int iwl3945_rate_control_register(void) +int il3945_rate_control_register(void) { return ieee80211_rate_control_register(&rs_ops); } -void iwl3945_rate_control_unregister(void) +void il3945_rate_control_unregister(void) { ieee80211_rate_control_unregister(&rs_ops); } diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index f7c0a7438476..6d1740b051df 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -51,70 +51,70 @@ #include "iwl-3945-led.h" #include "iwl-3945-debugfs.h" -#define IWL_DECLARE_RATE_INFO(r, ip, in, rp, rn, pp, np) \ - [IWL_RATE_##r##M_INDEX] = { IWL_RATE_##r##M_PLCP, \ - IWL_RATE_##r##M_IEEE, \ - IWL_RATE_##ip##M_INDEX, \ - IWL_RATE_##in##M_INDEX, \ - IWL_RATE_##rp##M_INDEX, \ - IWL_RATE_##rn##M_INDEX, \ - IWL_RATE_##pp##M_INDEX, \ - IWL_RATE_##np##M_INDEX, \ - IWL_RATE_##r##M_INDEX_TABLE, \ - IWL_RATE_##ip##M_INDEX_TABLE } +#define IL_DECLARE_RATE_INFO(r, ip, in, rp, rn, pp, np) \ + [IL_RATE_##r##M_INDEX] = { IL_RATE_##r##M_PLCP, \ + IL_RATE_##r##M_IEEE, \ + IL_RATE_##ip##M_INDEX, \ + IL_RATE_##in##M_INDEX, \ + IL_RATE_##rp##M_INDEX, \ + IL_RATE_##rn##M_INDEX, \ + IL_RATE_##pp##M_INDEX, \ + IL_RATE_##np##M_INDEX, \ + IL_RATE_##r##M_INDEX_TABLE, \ + IL_RATE_##ip##M_INDEX_TABLE } /* * Parameter order: * rate, prev rate, next rate, prev tgg rate, next tgg rate * * If there isn't a valid next or previous rate then INV is used which - * maps to IWL_RATE_INVALID + * maps to IL_RATE_INVALID * */ -const struct iwl3945_rate_info iwl3945_rates[IWL_RATE_COUNT_3945] = { - IWL_DECLARE_RATE_INFO(1, INV, 2, INV, 2, INV, 2), /* 1mbps */ - IWL_DECLARE_RATE_INFO(2, 1, 5, 1, 5, 1, 5), /* 2mbps */ - IWL_DECLARE_RATE_INFO(5, 2, 6, 2, 11, 2, 11), /*5.5mbps */ - IWL_DECLARE_RATE_INFO(11, 9, 12, 5, 12, 5, 18), /* 11mbps */ - IWL_DECLARE_RATE_INFO(6, 5, 9, 5, 11, 5, 11), /* 6mbps */ - IWL_DECLARE_RATE_INFO(9, 6, 11, 5, 11, 5, 11), /* 9mbps */ - IWL_DECLARE_RATE_INFO(12, 11, 18, 11, 18, 11, 18), /* 12mbps */ - IWL_DECLARE_RATE_INFO(18, 12, 24, 12, 24, 11, 24), /* 18mbps */ - IWL_DECLARE_RATE_INFO(24, 18, 36, 18, 36, 18, 36), /* 24mbps */ - IWL_DECLARE_RATE_INFO(36, 24, 48, 24, 48, 24, 48), /* 36mbps */ - IWL_DECLARE_RATE_INFO(48, 36, 54, 36, 54, 36, 54), /* 48mbps */ - IWL_DECLARE_RATE_INFO(54, 48, INV, 48, INV, 48, INV),/* 54mbps */ +const struct il3945_rate_info il3945_rates[IL_RATE_COUNT_3945] = { + IL_DECLARE_RATE_INFO(1, INV, 2, INV, 2, INV, 2), /* 1mbps */ + IL_DECLARE_RATE_INFO(2, 1, 5, 1, 5, 1, 5), /* 2mbps */ + IL_DECLARE_RATE_INFO(5, 2, 6, 2, 11, 2, 11), /*5.5mbps */ + IL_DECLARE_RATE_INFO(11, 9, 12, 5, 12, 5, 18), /* 11mbps */ + IL_DECLARE_RATE_INFO(6, 5, 9, 5, 11, 5, 11), /* 6mbps */ + IL_DECLARE_RATE_INFO(9, 6, 11, 5, 11, 5, 11), /* 9mbps */ + IL_DECLARE_RATE_INFO(12, 11, 18, 11, 18, 11, 18), /* 12mbps */ + IL_DECLARE_RATE_INFO(18, 12, 24, 12, 24, 11, 24), /* 18mbps */ + IL_DECLARE_RATE_INFO(24, 18, 36, 18, 36, 18, 36), /* 24mbps */ + IL_DECLARE_RATE_INFO(36, 24, 48, 24, 48, 24, 48), /* 36mbps */ + IL_DECLARE_RATE_INFO(48, 36, 54, 36, 54, 36, 54), /* 48mbps */ + IL_DECLARE_RATE_INFO(54, 48, INV, 48, INV, 48, INV),/* 54mbps */ }; -static inline u8 iwl3945_get_prev_ieee_rate(u8 rate_index) +static inline u8 il3945_get_prev_ieee_rate(u8 rate_index) { - u8 rate = iwl3945_rates[rate_index].prev_ieee; + u8 rate = il3945_rates[rate_index].prev_ieee; - if (rate == IWL_RATE_INVALID) + if (rate == IL_RATE_INVALID) rate = rate_index; return rate; } -/* 1 = enable the iwl3945_disable_events() function */ -#define IWL_EVT_DISABLE (0) -#define IWL_EVT_DISABLE_SIZE (1532/32) +/* 1 = enable the il3945_disable_events() function */ +#define IL_EVT_DISABLE (0) +#define IL_EVT_DISABLE_SIZE (1532/32) /** - * iwl3945_disable_events - Disable selected events in uCode event log + * il3945_disable_events - Disable selected events in uCode event log * * Disable an event by writing "1"s into "disable" * bitmap in SRAM. Bit position corresponds to Event # (id/type). * Default values of 0 enable uCode events to be logged. * Use for only special debugging. This function is just a placeholder as-is, * you'll need to provide the special bits! ... - * ... and set IWL_EVT_DISABLE to 1. */ -void iwl3945_disable_events(struct iwl_priv *priv) + * ... and set IL_EVT_DISABLE to 1. */ +void il3945_disable_events(struct il_priv *priv) { int i; u32 base; /* SRAM address of event log header */ u32 disable_ptr; /* SRAM address of event-disable bitmap array */ u32 array_size; /* # of u32 entries in array */ - static const u32 evt_disable[IWL_EVT_DISABLE_SIZE] = { + static const u32 evt_disable[IL_EVT_DISABLE_SIZE] = { 0x00000000, /* 31 - 0 Event id numbers */ 0x00000000, /* 63 - 32 */ 0x00000000, /* 95 - 64 */ @@ -165,37 +165,37 @@ void iwl3945_disable_events(struct iwl_priv *priv) }; base = le32_to_cpu(priv->card_alive.log_event_table_ptr); - if (!iwl3945_hw_valid_rtc_data_addr(base)) { - IWL_ERR(priv, "Invalid event log pointer 0x%08X\n", base); + if (!il3945_hw_valid_rtc_data_addr(base)) { + IL_ERR(priv, "Invalid event log pointer 0x%08X\n", base); return; } - disable_ptr = iwl_legacy_read_targ_mem(priv, base + (4 * sizeof(u32))); - array_size = iwl_legacy_read_targ_mem(priv, base + (5 * sizeof(u32))); + disable_ptr = il_read_targ_mem(priv, base + (4 * sizeof(u32))); + array_size = il_read_targ_mem(priv, base + (5 * sizeof(u32))); - if (IWL_EVT_DISABLE && (array_size == IWL_EVT_DISABLE_SIZE)) { - IWL_DEBUG_INFO(priv, "Disabling selected uCode log events at 0x%x\n", + if (IL_EVT_DISABLE && (array_size == IL_EVT_DISABLE_SIZE)) { + IL_DEBUG_INFO(priv, "Disabling selected uCode log events at 0x%x\n", disable_ptr); - for (i = 0; i < IWL_EVT_DISABLE_SIZE; i++) - iwl_legacy_write_targ_mem(priv, + for (i = 0; i < IL_EVT_DISABLE_SIZE; i++) + il_write_targ_mem(priv, disable_ptr + (i * sizeof(u32)), evt_disable[i]); } else { - IWL_DEBUG_INFO(priv, "Selected uCode log events may be disabled\n"); - IWL_DEBUG_INFO(priv, " by writing \"1\"s into disable bitmap\n"); - IWL_DEBUG_INFO(priv, " in SRAM at 0x%x, size %d u32s\n", + IL_DEBUG_INFO(priv, "Selected uCode log events may be disabled\n"); + IL_DEBUG_INFO(priv, " by writing \"1\"s into disable bitmap\n"); + IL_DEBUG_INFO(priv, " in SRAM at 0x%x, size %d u32s\n", disable_ptr, array_size); } } -static int iwl3945_hwrate_to_plcp_idx(u8 plcp) +static int il3945_hwrate_to_plcp_idx(u8 plcp) { int idx; - for (idx = 0; idx < IWL_RATE_COUNT_3945; idx++) - if (iwl3945_rates[idx].plcp == plcp) + for (idx = 0; idx < IL_RATE_COUNT_3945; idx++) + if (il3945_rates[idx].plcp == plcp) return idx; return -1; } @@ -203,7 +203,7 @@ static int iwl3945_hwrate_to_plcp_idx(u8 plcp) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG #define TX_STATUS_ENTRY(x) case TX_3945_STATUS_FAIL_ ## x: return #x -static const char *iwl3945_get_tx_fail_reason(u32 status) +static const char *il3945_get_tx_fail_reason(u32 status) { switch (status & TX_STATUS_MSK) { case TX_3945_STATUS_SUCCESS: @@ -229,7 +229,7 @@ static const char *iwl3945_get_tx_fail_reason(u32 status) return "UNKNOWN"; } #else -static inline const char *iwl3945_get_tx_fail_reason(u32 status) +static inline const char *il3945_get_tx_fail_reason(u32 status) { return ""; } @@ -240,22 +240,22 @@ static inline const char *iwl3945_get_tx_fail_reason(u32 status) * for A and B mode we need to overright prev * value */ -int iwl3945_rs_next_rate(struct iwl_priv *priv, int rate) +int il3945_rs_next_rate(struct il_priv *priv, int rate) { - int next_rate = iwl3945_get_prev_ieee_rate(rate); + int next_rate = il3945_get_prev_ieee_rate(rate); switch (priv->band) { case IEEE80211_BAND_5GHZ: - if (rate == IWL_RATE_12M_INDEX) - next_rate = IWL_RATE_9M_INDEX; - else if (rate == IWL_RATE_6M_INDEX) - next_rate = IWL_RATE_6M_INDEX; + if (rate == IL_RATE_12M_INDEX) + next_rate = IL_RATE_9M_INDEX; + else if (rate == IL_RATE_6M_INDEX) + next_rate = IL_RATE_6M_INDEX; break; case IEEE80211_BAND_2GHZ: - if (!(priv->_3945.sta_supp_rates & IWL_OFDM_RATES_MASK) && - iwl_legacy_is_associated(priv, IWL_RXON_CTX_BSS)) { - if (rate == IWL_RATE_11M_INDEX) - next_rate = IWL_RATE_5M_INDEX; + if (!(priv->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && + il_is_associated(priv, IL_RXON_CTX_BSS)) { + if (rate == IL_RATE_11M_INDEX) + next_rate = IL_RATE_5M_INDEX; } break; @@ -268,24 +268,24 @@ int iwl3945_rs_next_rate(struct iwl_priv *priv, int rate) /** - * iwl3945_tx_queue_reclaim - Reclaim Tx queue entries already Tx'd + * il3945_tx_queue_reclaim - Reclaim Tx queue entries already Tx'd * * When FW advances 'R' index, all entries between old and new 'R' index * need to be reclaimed. As result, some free space forms. If there is * enough free space (> low mark), wake the stack that feeds us. */ -static void iwl3945_tx_queue_reclaim(struct iwl_priv *priv, +static void il3945_tx_queue_reclaim(struct il_priv *priv, int txq_id, int index) { - struct iwl_tx_queue *txq = &priv->txq[txq_id]; - struct iwl_queue *q = &txq->q; - struct iwl_tx_info *tx_info; + struct il_tx_queue *txq = &priv->txq[txq_id]; + struct il_queue *q = &txq->q; + struct il_tx_info *tx_info; BUG_ON(txq_id == IWL39_CMD_QUEUE_NUM); - for (index = iwl_legacy_queue_inc_wrap(index, q->n_bd); + for (index = il_queue_inc_wrap(index, q->n_bd); q->read_ptr != index; - q->read_ptr = iwl_legacy_queue_inc_wrap(q->read_ptr, q->n_bd)) { + q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { tx_info = &txq->txb[txq->q.read_ptr]; ieee80211_tx_status_irqsafe(priv->hw, tx_info->skb); @@ -293,31 +293,31 @@ static void iwl3945_tx_queue_reclaim(struct iwl_priv *priv, priv->cfg->ops->lib->txq_free_tfd(priv, txq); } - if (iwl_legacy_queue_space(q) > q->low_mark && (txq_id >= 0) && + if (il_queue_space(q) > q->low_mark && (txq_id >= 0) && (txq_id != IWL39_CMD_QUEUE_NUM) && priv->mac80211_registered) - iwl_legacy_wake_queue(priv, txq); + il_wake_queue(priv, txq); } /** - * iwl3945_rx_reply_tx - Handle Tx response + * il3945_rx_reply_tx - Handle Tx response */ -static void iwl3945_rx_reply_tx(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il3945_rx_reply_tx(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); int index = SEQ_TO_INDEX(sequence); - struct iwl_tx_queue *txq = &priv->txq[txq_id]; + struct il_tx_queue *txq = &priv->txq[txq_id]; struct ieee80211_tx_info *info; - struct iwl3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; + struct il3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; u32 status = le32_to_cpu(tx_resp->status); int rate_idx; int fail; - if ((index >= txq->q.n_bd) || (iwl_legacy_queue_used(&txq->q, index) == 0)) { - IWL_ERR(priv, "Read index for DMA queue txq_id (%d) index %d " + if ((index >= txq->q.n_bd) || (il_queue_used(&txq->q, index) == 0)) { + IL_ERR(priv, "Read index for DMA queue txq_id (%d) index %d " "is out of range [0-%d] %d %d\n", txq_id, index, txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr); @@ -329,9 +329,9 @@ static void iwl3945_rx_reply_tx(struct iwl_priv *priv, ieee80211_tx_info_clear_status(info); /* Fill the MRR chain with some info about on-chip retransmissions */ - rate_idx = iwl3945_hwrate_to_plcp_idx(tx_resp->rate); + rate_idx = il3945_hwrate_to_plcp_idx(tx_resp->rate); if (info->band == IEEE80211_BAND_5GHZ) - rate_idx -= IWL_FIRST_OFDM_RATE; + rate_idx -= IL_FIRST_OFDM_RATE; fail = tx_resp->failure_frame; @@ -342,15 +342,15 @@ static void iwl3945_rx_reply_tx(struct iwl_priv *priv, info->flags |= ((status & TX_STATUS_MSK) == TX_STATUS_SUCCESS) ? IEEE80211_TX_STAT_ACK : 0; - IWL_DEBUG_TX(priv, "Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", - txq_id, iwl3945_get_tx_fail_reason(status), status, + IL_DEBUG_TX(priv, "Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", + txq_id, il3945_get_tx_fail_reason(status), status, tx_resp->rate, tx_resp->failure_frame); - IWL_DEBUG_TX_REPLY(priv, "Tx queue reclaim %d\n", index); - iwl3945_tx_queue_reclaim(priv, txq_id, index); + IL_DEBUG_TX_REPLY(priv, "Tx queue reclaim %d\n", index); + il3945_tx_queue_reclaim(priv, txq_id, index); if (status & TX_ABORT_REQUIRED_MSK) - IWL_ERR(priv, "TODO: Implement Tx ABORT REQUIRED!!!\n"); + IL_ERR(priv, "TODO: Implement Tx ABORT REQUIRED!!!\n"); } @@ -363,7 +363,7 @@ static void iwl3945_rx_reply_tx(struct iwl_priv *priv, * *****************************************************************************/ #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS -static void iwl3945_accumulative_statistics(struct iwl_priv *priv, +static void il3945_accumulative_statistics(struct il_priv *priv, __le32 *stats) { int i; @@ -376,7 +376,7 @@ static void iwl3945_accumulative_statistics(struct iwl_priv *priv, delta = (u32 *)&priv->_3945.delta_statistics; max_delta = (u32 *)&priv->_3945.max_delta; - for (i = sizeof(__le32); i < sizeof(struct iwl3945_notif_statistics); + for (i = sizeof(__le32); i < sizeof(struct il3945_notif_statistics); i += sizeof(__le32), stats++, prev_stats++, delta++, max_delta++, accum_stats++) { if (le32_to_cpu(*stats) > le32_to_cpu(*prev_stats)) { @@ -396,39 +396,39 @@ static void iwl3945_accumulative_statistics(struct iwl_priv *priv, } #endif -void iwl3945_hw_rx_statistics(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +void il3945_hw_rx_statistics(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); - IWL_DEBUG_RX(priv, "Statistics notification received (%d vs %d).\n", - (int)sizeof(struct iwl3945_notif_statistics), + IL_DEBUG_RX(priv, "Statistics notification received (%d vs %d).\n", + (int)sizeof(struct il3945_notif_statistics), le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS - iwl3945_accumulative_statistics(priv, (__le32 *)&pkt->u.raw); + il3945_accumulative_statistics(priv, (__le32 *)&pkt->u.raw); #endif memcpy(&priv->_3945.statistics, pkt->u.raw, sizeof(priv->_3945.statistics)); } -void iwl3945_reply_statistics(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +void il3945_reply_statistics(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); __le32 *flag = (__le32 *)&pkt->u.raw; if (le32_to_cpu(*flag) & UCODE_STATISTICS_CLEAR_MSK) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS memset(&priv->_3945.accum_statistics, 0, - sizeof(struct iwl3945_notif_statistics)); + sizeof(struct il3945_notif_statistics)); memset(&priv->_3945.delta_statistics, 0, - sizeof(struct iwl3945_notif_statistics)); + sizeof(struct il3945_notif_statistics)); memset(&priv->_3945.max_delta, 0, - sizeof(struct iwl3945_notif_statistics)); + sizeof(struct il3945_notif_statistics)); #endif - IWL_DEBUG_RX(priv, "Statistics have been cleared\n"); + IL_DEBUG_RX(priv, "Statistics have been cleared\n"); } - iwl3945_hw_rx_statistics(priv, rxb); + il3945_hw_rx_statistics(priv, rxb); } @@ -439,7 +439,7 @@ void iwl3945_reply_statistics(struct iwl_priv *priv, ******************************************************************************/ /* This is necessary only for a number of statistics, see the caller. */ -static int iwl3945_is_network_packet(struct iwl_priv *priv, +static int il3945_is_network_packet(struct il_priv *priv, struct ieee80211_hdr *header) { /* Filter incoming packets to determine if they are targeted toward @@ -456,14 +456,14 @@ static int iwl3945_is_network_packet(struct iwl_priv *priv, } } -static void iwl3945_pass_packet_to_mac80211(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, +static void il3945_pass_packet_to_mac80211(struct il_priv *priv, + struct il_rx_mem_buffer *rxb, struct ieee80211_rx_status *stats) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)IWL_RX_DATA(pkt); - struct iwl3945_rx_frame_hdr *rx_hdr = IWL_RX_HDR(pkt); - struct iwl3945_rx_frame_end *rx_end = IWL_RX_END(pkt); + struct il_rx_packet *pkt = rxb_addr(rxb); + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)IL_RX_DATA(pkt); + struct il3945_rx_frame_hdr *rx_hdr = IL_RX_HDR(pkt); + struct il3945_rx_frame_end *rx_end = IL_RX_END(pkt); u16 len = le16_to_cpu(rx_hdr->len); struct sk_buff *skb; __le16 fc = hdr->frame_control; @@ -471,32 +471,32 @@ static void iwl3945_pass_packet_to_mac80211(struct iwl_priv *priv, /* We received data from the HW, so stop the watchdog */ if (unlikely(len + IWL39_RX_FRAME_SIZE > PAGE_SIZE << priv->hw_params.rx_page_order)) { - IWL_DEBUG_DROP(priv, "Corruption detected!\n"); + IL_DEBUG_DROP(priv, "Corruption detected!\n"); return; } /* We only process data packets if the interface is open */ if (unlikely(!priv->is_open)) { - IWL_DEBUG_DROP_LIMIT(priv, + IL_DEBUG_DROP_LIMIT(priv, "Dropping packet while interface is not open.\n"); return; } skb = dev_alloc_skb(128); if (!skb) { - IWL_ERR(priv, "dev_alloc_skb failed\n"); + IL_ERR(priv, "dev_alloc_skb failed\n"); return; } - if (!iwl3945_mod_params.sw_crypto) - iwl_legacy_set_decrypted_flag(priv, + if (!il3945_mod_params.sw_crypto) + il_set_decrypted_flag(priv, (struct ieee80211_hdr *)rxb_addr(rxb), le32_to_cpu(rx_end->status), stats); skb_add_rx_frag(skb, 0, rxb->page, (void *)rx_hdr->payload - (void *)pkt, len); - iwl_legacy_update_stats(priv, false, fc, len); + il_update_stats(priv, false, fc, len); memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats)); ieee80211_rx(priv->hw, skb); @@ -504,17 +504,17 @@ static void iwl3945_pass_packet_to_mac80211(struct iwl_priv *priv, rxb->page = NULL; } -#define IWL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6) +#define IL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6) -static void iwl3945_rx_reply_rx(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il3945_rx_reply_rx(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { struct ieee80211_hdr *header; struct ieee80211_rx_status rx_status; - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl3945_rx_frame_stats *rx_stats = IWL_RX_STATS(pkt); - struct iwl3945_rx_frame_hdr *rx_hdr = IWL_RX_HDR(pkt); - struct iwl3945_rx_frame_end *rx_end = IWL_RX_END(pkt); + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il3945_rx_frame_stats *rx_stats = IL_RX_STATS(pkt); + struct il3945_rx_frame_hdr *rx_hdr = IL_RX_HDR(pkt); + struct il3945_rx_frame_end *rx_end = IL_RX_END(pkt); u16 rx_stats_sig_avg __maybe_unused = le16_to_cpu(rx_stats->sig_avg); u16 rx_stats_noise_diff __maybe_unused = le16_to_cpu(rx_stats->noise_diff); u8 network_packet; @@ -527,9 +527,9 @@ static void iwl3945_rx_reply_rx(struct iwl_priv *priv, ieee80211_channel_to_frequency(le16_to_cpu(rx_hdr->channel), rx_status.band); - rx_status.rate_idx = iwl3945_hwrate_to_plcp_idx(rx_hdr->rate); + rx_status.rate_idx = il3945_hwrate_to_plcp_idx(rx_hdr->rate); if (rx_status.band == IEEE80211_BAND_5GHZ) - rx_status.rate_idx -= IWL_FIRST_OFDM_RATE; + rx_status.rate_idx -= IL_FIRST_OFDM_RATE; rx_status.antenna = (le16_to_cpu(rx_hdr->phy_flags) & RX_RES_PHY_FLAGS_ANTENNA_MSK) >> 4; @@ -539,14 +539,14 @@ static void iwl3945_rx_reply_rx(struct iwl_priv *priv, rx_status.flag |= RX_FLAG_SHORTPRE; if ((unlikely(rx_stats->phy_count > 20))) { - IWL_DEBUG_DROP(priv, "dsp size out of range [0,20]: %d/n", + IL_DEBUG_DROP(priv, "dsp size out of range [0,20]: %d/n", rx_stats->phy_count); return; } if (!(rx_end->status & RX_RES_STATUS_NO_CRC32_ERROR) || !(rx_end->status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { - IWL_DEBUG_RX(priv, "Bad CRC or FIFO: 0x%08X.\n", rx_end->status); + IL_DEBUG_RX(priv, "Bad CRC or FIFO: 0x%08X.\n", rx_end->status); return; } @@ -555,21 +555,21 @@ static void iwl3945_rx_reply_rx(struct iwl_priv *priv, /* Convert 3945's rssi indicator to dBm */ rx_status.signal = rx_stats->rssi - IWL39_RSSI_OFFSET; - IWL_DEBUG_STATS(priv, "Rssi %d sig_avg %d noise_diff %d\n", + IL_DEBUG_STATS(priv, "Rssi %d sig_avg %d noise_diff %d\n", rx_status.signal, rx_stats_sig_avg, rx_stats_noise_diff); - header = (struct ieee80211_hdr *)IWL_RX_DATA(pkt); + header = (struct ieee80211_hdr *)IL_RX_DATA(pkt); - network_packet = iwl3945_is_network_packet(priv, header); + network_packet = il3945_is_network_packet(priv, header); - IWL_DEBUG_STATS_LIMIT(priv, "[%c] %d RSSI:%d Signal:%u, Rate:%u\n", + IL_DEBUG_STATS_LIMIT(priv, "[%c] %d RSSI:%d Signal:%u, Rate:%u\n", network_packet ? '*' : ' ', le16_to_cpu(rx_hdr->channel), rx_status.signal, rx_status.signal, rx_status.rate_idx); - iwl_legacy_dbg_log_rx_data_frame(priv, le16_to_cpu(rx_hdr->len), + il_dbg_log_rx_data_frame(priv, le16_to_cpu(rx_hdr->len), header); if (network_packet) { @@ -579,19 +579,19 @@ static void iwl3945_rx_reply_rx(struct iwl_priv *priv, priv->_3945.last_rx_rssi = rx_status.signal; } - iwl3945_pass_packet_to_mac80211(priv, rxb, &rx_status); + il3945_pass_packet_to_mac80211(priv, rxb, &rx_status); } -int iwl3945_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, - struct iwl_tx_queue *txq, +int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *priv, + struct il_tx_queue *txq, dma_addr_t addr, u16 len, u8 reset, u8 pad) { int count; - struct iwl_queue *q; - struct iwl3945_tfd *tfd, *tfd_tmp; + struct il_queue *q; + struct il3945_tfd *tfd, *tfd_tmp; q = &txq->q; - tfd_tmp = (struct iwl3945_tfd *)txq->tfds; + tfd_tmp = (struct il3945_tfd *)txq->tfds; tfd = &tfd_tmp[q->write_ptr]; if (reset) @@ -600,7 +600,7 @@ int iwl3945_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, count = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags)); if ((count >= NUM_TFD_CHUNKS) || (count < 0)) { - IWL_ERR(priv, "Error can not send more than %d chunks\n", + IL_ERR(priv, "Error can not send more than %d chunks\n", NUM_TFD_CHUNKS); return -EINVAL; } @@ -617,15 +617,15 @@ int iwl3945_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, } /** - * iwl3945_hw_txq_free_tfd - Free one TFD, those at index [txq->q.read_ptr] + * il3945_hw_txq_free_tfd - Free one TFD, those at index [txq->q.read_ptr] * * Does NOT advance any indexes */ -void iwl3945_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq) +void il3945_hw_txq_free_tfd(struct il_priv *priv, struct il_tx_queue *txq) { - struct iwl3945_tfd *tfd_tmp = (struct iwl3945_tfd *)txq->tfds; + struct il3945_tfd *tfd_tmp = (struct il3945_tfd *)txq->tfds; int index = txq->q.read_ptr; - struct iwl3945_tfd *tfd = &tfd_tmp[index]; + struct il3945_tfd *tfd = &tfd_tmp[index]; struct pci_dev *dev = priv->pci_dev; int i; int counter; @@ -633,7 +633,7 @@ void iwl3945_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq) /* sanity check */ counter = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags)); if (counter > NUM_TFD_CHUNKS) { - IWL_ERR(priv, "Too many chunks: %i\n", counter); + IL_ERR(priv, "Too many chunks: %i\n", counter); /* @todo issue fatal error, it is quite serious situation */ return; } @@ -666,37 +666,37 @@ void iwl3945_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq) } /** - * iwl3945_hw_build_tx_cmd_rate - Add rate portion to TX_CMD: + * il3945_hw_build_tx_cmd_rate - Add rate portion to TX_CMD: * */ -void iwl3945_hw_build_tx_cmd_rate(struct iwl_priv *priv, - struct iwl_device_cmd *cmd, +void il3945_hw_build_tx_cmd_rate(struct il_priv *priv, + struct il_device_cmd *cmd, struct ieee80211_tx_info *info, struct ieee80211_hdr *hdr, int sta_id, int tx_id) { u16 hw_value = ieee80211_get_tx_rate(priv->hw, info)->hw_value; - u16 rate_index = min(hw_value & 0xffff, IWL_RATE_COUNT_3945); + u16 rate_index = min(hw_value & 0xffff, IL_RATE_COUNT_3945); u16 rate_mask; int rate; u8 rts_retry_limit; u8 data_retry_limit; __le32 tx_flags; __le16 fc = hdr->frame_control; - struct iwl3945_tx_cmd *tx_cmd = (struct iwl3945_tx_cmd *)cmd->cmd.payload; + struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; - rate = iwl3945_rates[rate_index].plcp; + rate = il3945_rates[rate_index].plcp; tx_flags = tx_cmd->tx_flags; /* We need to figure out how to get the sta->supp_rates while * in this running context */ - rate_mask = IWL_RATES_MASK_3945; + rate_mask = IL_RATES_MASK_3945; /* Set retry limit on DATA packets and Probe Responses*/ if (ieee80211_is_probe_resp(fc)) data_retry_limit = 3; else - data_retry_limit = IWL_DEFAULT_TX_RETRY; + data_retry_limit = IL_DEFAULT_TX_RETRY; tx_cmd->data_retry_limit = data_retry_limit; if (tx_id >= IWL39_CMD_QUEUE_NUM) @@ -713,24 +713,24 @@ void iwl3945_hw_build_tx_cmd_rate(struct iwl_priv *priv, /* OFDM */ tx_cmd->supp_rates[0] = - ((rate_mask & IWL_OFDM_RATES_MASK) >> IWL_FIRST_OFDM_RATE) & 0xFF; + ((rate_mask & IL_OFDM_RATES_MASK) >> IL_FIRST_OFDM_RATE) & 0xFF; /* CCK */ tx_cmd->supp_rates[1] = (rate_mask & 0xF); - IWL_DEBUG_RATE(priv, "Tx sta id: %d, rate: %d (plcp), flags: 0x%4X " + IL_DEBUG_RATE(priv, "Tx sta id: %d, rate: %d (plcp), flags: 0x%4X " "cck/ofdm mask: 0x%x/0x%x\n", sta_id, tx_cmd->rate, le32_to_cpu(tx_cmd->tx_flags), tx_cmd->supp_rates[1], tx_cmd->supp_rates[0]); } -static u8 iwl3945_sync_sta(struct iwl_priv *priv, int sta_id, u16 tx_rate) +static u8 il3945_sync_sta(struct il_priv *priv, int sta_id, u16 tx_rate) { unsigned long flags_spin; - struct iwl_station_entry *station; + struct il_station_entry *station; - if (sta_id == IWL_INVALID_STATION) - return IWL_INVALID_STATION; + if (sta_id == IL_INVALID_STATION) + return IL_INVALID_STATION; spin_lock_irqsave(&priv->sta_lock, flags_spin); station = &priv->stations[sta_id]; @@ -738,46 +738,46 @@ static u8 iwl3945_sync_sta(struct iwl_priv *priv, int sta_id, u16 tx_rate) station->sta.sta.modify_mask = STA_MODIFY_TX_RATE_MSK; station->sta.rate_n_flags = cpu_to_le16(tx_rate); station->sta.mode = STA_CONTROL_MODIFY_MSK; - iwl_legacy_send_add_sta(priv, &station->sta, CMD_ASYNC); + il_send_add_sta(priv, &station->sta, CMD_ASYNC); spin_unlock_irqrestore(&priv->sta_lock, flags_spin); - IWL_DEBUG_RATE(priv, "SCALE sync station %d to rate %d\n", + IL_DEBUG_RATE(priv, "SCALE sync station %d to rate %d\n", sta_id, tx_rate); return sta_id; } -static void iwl3945_set_pwr_vmain(struct iwl_priv *priv) +static void il3945_set_pwr_vmain(struct il_priv *priv) { /* * (for documentation purposes) * to set power to V_AUX, do if (pci_pme_capable(priv->pci_dev, PCI_D3cold)) { - iwl_legacy_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, + il_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_PWR_SRC_VAUX, ~APMG_PS_CTRL_MSK_PWR_SRC); - iwl_poll_bit(priv, CSR_GPIO_IN, + il_poll_bit(priv, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VAUX_PWR_SRC, CSR_GPIO_IN_BIT_AUX_POWER, 5000); } */ - iwl_legacy_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, + il_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, ~APMG_PS_CTRL_MSK_PWR_SRC); - iwl_poll_bit(priv, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC, + il_poll_bit(priv, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC, CSR_GPIO_IN_BIT_AUX_POWER, 5000); /* uS */ } -static int iwl3945_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq) +static int il3945_rx_init(struct il_priv *priv, struct il_rx_queue *rxq) { - iwl_legacy_write_direct32(priv, FH39_RCSR_RBD_BASE(0), rxq->bd_dma); - iwl_legacy_write_direct32(priv, FH39_RCSR_RPTR_ADDR(0), + il_write_direct32(priv, FH39_RCSR_RBD_BASE(0), rxq->bd_dma); + il_write_direct32(priv, FH39_RCSR_RPTR_ADDR(0), rxq->rb_stts_dma); - iwl_legacy_write_direct32(priv, FH39_RCSR_WPTR(0), 0); - iwl_legacy_write_direct32(priv, FH39_RCSR_CONFIG(0), + il_write_direct32(priv, FH39_RCSR_WPTR(0), 0); + il_write_direct32(priv, FH39_RCSR_CONFIG(0), FH39_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE | FH39_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE | FH39_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN | @@ -788,32 +788,32 @@ static int iwl3945_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq) FH39_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH); /* fake read to flush all prev I/O */ - iwl_legacy_read_direct32(priv, FH39_RSSR_CTRL); + il_read_direct32(priv, FH39_RSSR_CTRL); return 0; } -static int iwl3945_tx_reset(struct iwl_priv *priv) +static int il3945_tx_reset(struct il_priv *priv) { /* bypass mode */ - iwl_legacy_write_prph(priv, ALM_SCD_MODE_REG, 0x2); + il_write_prph(priv, ALM_SCD_MODE_REG, 0x2); /* RA 0 is active */ - iwl_legacy_write_prph(priv, ALM_SCD_ARASTAT_REG, 0x01); + il_write_prph(priv, ALM_SCD_ARASTAT_REG, 0x01); /* all 6 fifo are active */ - iwl_legacy_write_prph(priv, ALM_SCD_TXFACT_REG, 0x3f); + il_write_prph(priv, ALM_SCD_TXFACT_REG, 0x3f); - iwl_legacy_write_prph(priv, ALM_SCD_SBYP_MODE_1_REG, 0x010000); - iwl_legacy_write_prph(priv, ALM_SCD_SBYP_MODE_2_REG, 0x030002); - iwl_legacy_write_prph(priv, ALM_SCD_TXF4MF_REG, 0x000004); - iwl_legacy_write_prph(priv, ALM_SCD_TXF5MF_REG, 0x000005); + il_write_prph(priv, ALM_SCD_SBYP_MODE_1_REG, 0x010000); + il_write_prph(priv, ALM_SCD_SBYP_MODE_2_REG, 0x030002); + il_write_prph(priv, ALM_SCD_TXF4MF_REG, 0x000004); + il_write_prph(priv, ALM_SCD_TXF5MF_REG, 0x000005); - iwl_legacy_write_direct32(priv, FH39_TSSR_CBB_BASE, + il_write_direct32(priv, FH39_TSSR_CBB_BASE, priv->_3945.shared_phys); - iwl_legacy_write_direct32(priv, FH39_TSSR_MSG_CONFIG, + il_write_direct32(priv, FH39_TSSR_MSG_CONFIG, FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON | FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON | FH39_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B | @@ -827,24 +827,24 @@ static int iwl3945_tx_reset(struct iwl_priv *priv) } /** - * iwl3945_txq_ctx_reset - Reset TX queue context + * il3945_txq_ctx_reset - Reset TX queue context * * Destroys all DMA structures and initialize them again */ -static int iwl3945_txq_ctx_reset(struct iwl_priv *priv) +static int il3945_txq_ctx_reset(struct il_priv *priv) { int rc; int txq_id, slots_num; - iwl3945_hw_txq_ctx_free(priv); + il3945_hw_txq_ctx_free(priv); /* allocate tx queue structure */ - rc = iwl_legacy_alloc_txq_mem(priv); + rc = il_alloc_txq_mem(priv); if (rc) return rc; /* Tx CMD queue */ - rc = iwl3945_tx_reset(priv); + rc = il3945_tx_reset(priv); if (rc) goto error; @@ -852,10 +852,10 @@ static int iwl3945_txq_ctx_reset(struct iwl_priv *priv) for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { slots_num = (txq_id == IWL39_CMD_QUEUE_NUM) ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - rc = iwl_legacy_tx_queue_init(priv, &priv->txq[txq_id], + rc = il_tx_queue_init(priv, &priv->txq[txq_id], slots_num, txq_id); if (rc) { - IWL_ERR(priv, "Tx %d queue init failed\n", txq_id); + IL_ERR(priv, "Tx %d queue init failed\n", txq_id); goto error; } } @@ -863,133 +863,133 @@ static int iwl3945_txq_ctx_reset(struct iwl_priv *priv) return rc; error: - iwl3945_hw_txq_ctx_free(priv); + il3945_hw_txq_ctx_free(priv); return rc; } /* * Start up 3945's basic functionality after it has been reset - * (e.g. after platform boot, or shutdown via iwl_legacy_apm_stop()) + * (e.g. after platform boot, or shutdown via il_apm_stop()) * NOTE: This does not load uCode nor start the embedded processor */ -static int iwl3945_apm_init(struct iwl_priv *priv) +static int il3945_apm_init(struct il_priv *priv) { - int ret = iwl_legacy_apm_init(priv); + int ret = il_apm_init(priv); /* Clear APMG (NIC's internal power management) interrupts */ - iwl_legacy_write_prph(priv, APMG_RTC_INT_MSK_REG, 0x0); - iwl_legacy_write_prph(priv, APMG_RTC_INT_STT_REG, 0xFFFFFFFF); + il_write_prph(priv, APMG_RTC_INT_MSK_REG, 0x0); + il_write_prph(priv, APMG_RTC_INT_STT_REG, 0xFFFFFFFF); /* Reset radio chip */ - iwl_legacy_set_bits_prph(priv, APMG_PS_CTRL_REG, + il_set_bits_prph(priv, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_RESET_REQ); udelay(5); - iwl_legacy_clear_bits_prph(priv, APMG_PS_CTRL_REG, + il_clear_bits_prph(priv, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_RESET_REQ); return ret; } -static void iwl3945_nic_config(struct iwl_priv *priv) +static void il3945_nic_config(struct il_priv *priv) { - struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; unsigned long flags; u8 rev_id = priv->pci_dev->revision; spin_lock_irqsave(&priv->lock, flags); /* Determine HW type */ - IWL_DEBUG_INFO(priv, "HW Revision ID = 0x%X\n", rev_id); + IL_DEBUG_INFO(priv, "HW Revision ID = 0x%X\n", rev_id); if (rev_id & PCI_CFG_REV_ID_BIT_RTP) - IWL_DEBUG_INFO(priv, "RTP type\n"); + IL_DEBUG_INFO(priv, "RTP type\n"); else if (rev_id & PCI_CFG_REV_ID_BIT_BASIC_SKU) { - IWL_DEBUG_INFO(priv, "3945 RADIO-MB type\n"); - iwl_legacy_set_bit(priv, CSR_HW_IF_CONFIG_REG, + IL_DEBUG_INFO(priv, "3945 RADIO-MB type\n"); + il_set_bit(priv, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_3945_MB); } else { - IWL_DEBUG_INFO(priv, "3945 RADIO-MM type\n"); - iwl_legacy_set_bit(priv, CSR_HW_IF_CONFIG_REG, + IL_DEBUG_INFO(priv, "3945 RADIO-MM type\n"); + il_set_bit(priv, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_3945_MM); } if (EEPROM_SKU_CAP_OP_MODE_MRC == eeprom->sku_cap) { - IWL_DEBUG_INFO(priv, "SKU OP mode is mrc\n"); - iwl_legacy_set_bit(priv, CSR_HW_IF_CONFIG_REG, + IL_DEBUG_INFO(priv, "SKU OP mode is mrc\n"); + il_set_bit(priv, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_SKU_MRC); } else - IWL_DEBUG_INFO(priv, "SKU OP mode is basic\n"); + IL_DEBUG_INFO(priv, "SKU OP mode is basic\n"); if ((eeprom->board_revision & 0xF0) == 0xD0) { - IWL_DEBUG_INFO(priv, "3945ABG revision is 0x%X\n", + IL_DEBUG_INFO(priv, "3945ABG revision is 0x%X\n", eeprom->board_revision); - iwl_legacy_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(priv, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); } else { - IWL_DEBUG_INFO(priv, "3945ABG revision is 0x%X\n", + IL_DEBUG_INFO(priv, "3945ABG revision is 0x%X\n", eeprom->board_revision); - iwl_legacy_clear_bit(priv, CSR_HW_IF_CONFIG_REG, + il_clear_bit(priv, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); } if (eeprom->almgor_m_version <= 1) { - iwl_legacy_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(priv, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A); - IWL_DEBUG_INFO(priv, "Card M type A version is 0x%X\n", + IL_DEBUG_INFO(priv, "Card M type A version is 0x%X\n", eeprom->almgor_m_version); } else { - IWL_DEBUG_INFO(priv, "Card M type B version is 0x%X\n", + IL_DEBUG_INFO(priv, "Card M type B version is 0x%X\n", eeprom->almgor_m_version); - iwl_legacy_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(priv, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B); } spin_unlock_irqrestore(&priv->lock, flags); if (eeprom->sku_cap & EEPROM_SKU_CAP_SW_RF_KILL_ENABLE) - IWL_DEBUG_RF_KILL(priv, "SW RF KILL supported in EEPROM.\n"); + IL_DEBUG_RF_KILL(priv, "SW RF KILL supported in EEPROM.\n"); if (eeprom->sku_cap & EEPROM_SKU_CAP_HW_RF_KILL_ENABLE) - IWL_DEBUG_RF_KILL(priv, "HW RF KILL supported in EEPROM.\n"); + IL_DEBUG_RF_KILL(priv, "HW RF KILL supported in EEPROM.\n"); } -int iwl3945_hw_nic_init(struct iwl_priv *priv) +int il3945_hw_nic_init(struct il_priv *priv) { int rc; unsigned long flags; - struct iwl_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &priv->rxq; spin_lock_irqsave(&priv->lock, flags); priv->cfg->ops->lib->apm_ops.init(priv); spin_unlock_irqrestore(&priv->lock, flags); - iwl3945_set_pwr_vmain(priv); + il3945_set_pwr_vmain(priv); priv->cfg->ops->lib->apm_ops.config(priv); /* Allocate the RX queue, or reset if it is already allocated */ if (!rxq->bd) { - rc = iwl_legacy_rx_queue_alloc(priv); + rc = il_rx_queue_alloc(priv); if (rc) { - IWL_ERR(priv, "Unable to initialize Rx queue\n"); + IL_ERR(priv, "Unable to initialize Rx queue\n"); return -ENOMEM; } } else - iwl3945_rx_queue_reset(priv, rxq); + il3945_rx_queue_reset(priv, rxq); - iwl3945_rx_replenish(priv); + il3945_rx_replenish(priv); - iwl3945_rx_init(priv, rxq); + il3945_rx_init(priv, rxq); /* Look at using this instead: rxq->need_update = 1; - iwl_legacy_rx_queue_update_write_ptr(priv, rxq); + il_rx_queue_update_write_ptr(priv, rxq); */ - iwl_legacy_write_direct32(priv, FH39_RCSR_WPTR(0), rxq->write & ~7); + il_write_direct32(priv, FH39_RCSR_WPTR(0), rxq->write & ~7); - rc = iwl3945_txq_ctx_reset(priv); + rc = il3945_txq_ctx_reset(priv); if (rc) return rc; @@ -999,11 +999,11 @@ int iwl3945_hw_nic_init(struct iwl_priv *priv) } /** - * iwl3945_hw_txq_ctx_free - Free TXQ Context + * il3945_hw_txq_ctx_free - Free TXQ Context * * Destroy all TX DMA queues and structures */ -void iwl3945_hw_txq_ctx_free(struct iwl_priv *priv) +void il3945_hw_txq_ctx_free(struct il_priv *priv) { int txq_id; @@ -1012,73 +1012,73 @@ void iwl3945_hw_txq_ctx_free(struct iwl_priv *priv) for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) if (txq_id == IWL39_CMD_QUEUE_NUM) - iwl_legacy_cmd_queue_free(priv); + il_cmd_queue_free(priv); else - iwl_legacy_tx_queue_free(priv, txq_id); + il_tx_queue_free(priv, txq_id); /* free tx queue structure */ - iwl_legacy_txq_mem(priv); + il_txq_mem(priv); } -void iwl3945_hw_txq_ctx_stop(struct iwl_priv *priv) +void il3945_hw_txq_ctx_stop(struct il_priv *priv) { int txq_id; /* stop SCD */ - iwl_legacy_write_prph(priv, ALM_SCD_MODE_REG, 0); - iwl_legacy_write_prph(priv, ALM_SCD_TXFACT_REG, 0); + il_write_prph(priv, ALM_SCD_MODE_REG, 0); + il_write_prph(priv, ALM_SCD_TXFACT_REG, 0); /* reset TFD queues */ for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { - iwl_legacy_write_direct32(priv, FH39_TCSR_CONFIG(txq_id), 0x0); - iwl_poll_direct_bit(priv, FH39_TSSR_TX_STATUS, + il_write_direct32(priv, FH39_TCSR_CONFIG(txq_id), 0x0); + il_poll_direct_bit(priv, FH39_TSSR_TX_STATUS, FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(txq_id), 1000); } - iwl3945_hw_txq_ctx_free(priv); + il3945_hw_txq_ctx_free(priv); } /** - * iwl3945_hw_reg_adjust_power_by_temp + * il3945_hw_reg_adjust_power_by_temp * return index delta into power gain settings table */ -static int iwl3945_hw_reg_adjust_power_by_temp(int new_reading, int old_reading) +static int il3945_hw_reg_adjust_power_by_temp(int new_reading, int old_reading) { return (new_reading - old_reading) * (-11) / 100; } /** - * iwl3945_hw_reg_temp_out_of_range - Keep temperature in sane range + * il3945_hw_reg_temp_out_of_range - Keep temperature in sane range */ -static inline int iwl3945_hw_reg_temp_out_of_range(int temperature) +static inline int il3945_hw_reg_temp_out_of_range(int temperature) { return ((temperature < -260) || (temperature > 25)) ? 1 : 0; } -int iwl3945_hw_get_temperature(struct iwl_priv *priv) +int il3945_hw_get_temperature(struct il_priv *priv) { - return iwl_read32(priv, CSR_UCODE_DRV_GP2); + return il_read32(priv, CSR_UCODE_DRV_GP2); } /** - * iwl3945_hw_reg_txpower_get_temperature + * il3945_hw_reg_txpower_get_temperature * get the current temperature by reading from NIC */ -static int iwl3945_hw_reg_txpower_get_temperature(struct iwl_priv *priv) +static int il3945_hw_reg_txpower_get_temperature(struct il_priv *priv) { - struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; int temperature; - temperature = iwl3945_hw_get_temperature(priv); + temperature = il3945_hw_get_temperature(priv); /* driver's okay range is -260 to +25. * human readable okay range is 0 to +285 */ - IWL_DEBUG_INFO(priv, "Temperature: %d\n", temperature + IWL_TEMP_CONVERT); + IL_DEBUG_INFO(priv, "Temperature: %d\n", temperature + IL_TEMP_CONVERT); /* handle insane temp reading */ - if (iwl3945_hw_reg_temp_out_of_range(temperature)) { - IWL_ERR(priv, "Error bad temperature value %d\n", temperature); + if (il3945_hw_reg_temp_out_of_range(temperature)) { + IL_ERR(priv, "Error bad temperature value %d\n", temperature); /* if really really hot(?), * substitute the 3rd band/group's temp measured at factory */ @@ -1094,37 +1094,37 @@ static int iwl3945_hw_reg_txpower_get_temperature(struct iwl_priv *priv) /* Adjust Txpower only if temperature variance is greater than threshold. * * Both are lower than older versions' 9 degrees */ -#define IWL_TEMPERATURE_LIMIT_TIMER 6 +#define IL_TEMPERATURE_LIMIT_TIMER 6 /** - * iwl3945_is_temp_calib_needed - determines if new calibration is needed + * il3945_is_temp_calib_needed - determines if new calibration is needed * * records new temperature in tx_mgr->temperature. * replaces tx_mgr->last_temperature *only* if calib needed * (assumes caller will actually do the calibration!). */ -static int iwl3945_is_temp_calib_needed(struct iwl_priv *priv) +static int il3945_is_temp_calib_needed(struct il_priv *priv) { int temp_diff; - priv->temperature = iwl3945_hw_reg_txpower_get_temperature(priv); + priv->temperature = il3945_hw_reg_txpower_get_temperature(priv); temp_diff = priv->temperature - priv->last_temperature; /* get absolute value */ if (temp_diff < 0) { - IWL_DEBUG_POWER(priv, "Getting cooler, delta %d,\n", temp_diff); + IL_DEBUG_POWER(priv, "Getting cooler, delta %d,\n", temp_diff); temp_diff = -temp_diff; } else if (temp_diff == 0) - IWL_DEBUG_POWER(priv, "Same temp,\n"); + IL_DEBUG_POWER(priv, "Same temp,\n"); else - IWL_DEBUG_POWER(priv, "Getting warmer, delta %d,\n", temp_diff); + IL_DEBUG_POWER(priv, "Getting warmer, delta %d,\n", temp_diff); /* if we don't need calibration, *don't* update last_temperature */ - if (temp_diff < IWL_TEMPERATURE_LIMIT_TIMER) { - IWL_DEBUG_POWER(priv, "Timed thermal calib not needed\n"); + if (temp_diff < IL_TEMPERATURE_LIMIT_TIMER) { + IL_DEBUG_POWER(priv, "Timed thermal calib not needed\n"); return 0; } - IWL_DEBUG_POWER(priv, "Timed thermal calib needed\n"); + IL_DEBUG_POWER(priv, "Timed thermal calib needed\n"); /* assume that caller will actually do calib ... * update the "last temperature" value */ @@ -1132,13 +1132,13 @@ static int iwl3945_is_temp_calib_needed(struct iwl_priv *priv) return 1; } -#define IWL_MAX_GAIN_ENTRIES 78 -#define IWL_CCK_FROM_OFDM_POWER_DIFF -5 -#define IWL_CCK_FROM_OFDM_INDEX_DIFF (10) +#define IL_MAX_GAIN_ENTRIES 78 +#define IL_CCK_FROM_OFDM_POWER_DIFF -5 +#define IL_CCK_FROM_OFDM_INDEX_DIFF (10) /* radio and DSP power table, each step is 1/2 dB. * 1st number is for RF analog gain, 2nd number is for DSP pre-DAC gain. */ -static struct iwl3945_tx_power power_gain_table[2][IWL_MAX_GAIN_ENTRIES] = { +static struct il3945_tx_power power_gain_table[2][IL_MAX_GAIN_ENTRIES] = { { {251, 127}, /* 2.4 GHz, highest power */ {251, 127}, @@ -1299,12 +1299,12 @@ static struct iwl3945_tx_power power_gain_table[2][IWL_MAX_GAIN_ENTRIES] = { {3, 120} } /* 5.x GHz, lowest power */ }; -static inline u8 iwl3945_hw_reg_fix_power_index(int index) +static inline u8 il3945_hw_reg_fix_power_index(int index) { if (index < 0) return 0; - if (index >= IWL_MAX_GAIN_ENTRIES) - return IWL_MAX_GAIN_ENTRIES - 1; + if (index >= IL_MAX_GAIN_ENTRIES) + return IL_MAX_GAIN_ENTRIES - 1; return (u8) index; } @@ -1312,17 +1312,17 @@ static inline u8 iwl3945_hw_reg_fix_power_index(int index) #define REG_RECALIB_PERIOD (60) /** - * iwl3945_hw_reg_set_scan_power - Set Tx power for scan probe requests + * il3945_hw_reg_set_scan_power - Set Tx power for scan probe requests * * Set (in our channel info database) the direct scan Tx power for 1 Mbit (CCK) * or 6 Mbit (OFDM) rates. */ -static void iwl3945_hw_reg_set_scan_power(struct iwl_priv *priv, u32 scan_tbl_index, +static void il3945_hw_reg_set_scan_power(struct il_priv *priv, u32 scan_tbl_index, s32 rate_index, const s8 *clip_pwrs, - struct iwl_channel_info *ch_info, + struct il_channel_info *ch_info, int band_index) { - struct iwl3945_scan_power_info *scan_power_info; + struct il3945_scan_power_info *scan_power_info; s8 power; u8 power_index; @@ -1331,7 +1331,7 @@ static void iwl3945_hw_reg_set_scan_power(struct iwl_priv *priv, u32 scan_tbl_in /* use this channel group's 6Mbit clipping/saturation pwr, * but cap at regulatory scan power restriction (set during init * based on eeprom channel data) for this channel. */ - power = min(ch_info->scan_power, clip_pwrs[IWL_RATE_6M_INDEX_TABLE]); + power = min(ch_info->scan_power, clip_pwrs[IL_RATE_6M_INDEX_TABLE]); power = min(power, priv->tx_power_user_lmt); scan_power_info->requested_power = power; @@ -1343,7 +1343,7 @@ static void iwl3945_hw_reg_set_scan_power(struct iwl_priv *priv, u32 scan_tbl_in * *index*. */ power_index = ch_info->power_info[rate_index].power_table_index - (power - ch_info->power_info - [IWL_RATE_6M_INDEX_TABLE].requested_power) * 2; + [IL_RATE_6M_INDEX_TABLE].requested_power) * 2; /* store reference index that we use when adjusting *all* scan * powers. So we can accommodate user (all channel) or spectrum @@ -1355,7 +1355,7 @@ static void iwl3945_hw_reg_set_scan_power(struct iwl_priv *priv, u32 scan_tbl_in * of the table. */ /* don't exceed table bounds for "real" setting */ - power_index = iwl3945_hw_reg_fix_power_index(power_index); + power_index = il3945_hw_reg_fix_power_index(power_index); scan_power_info->power_table_index = power_index; scan_power_info->tpc.tx_gain = @@ -1365,17 +1365,17 @@ static void iwl3945_hw_reg_set_scan_power(struct iwl_priv *priv, u32 scan_tbl_in } /** - * iwl3945_send_tx_power - fill in Tx Power command with gain settings + * il3945_send_tx_power - fill in Tx Power command with gain settings * * Configures power settings for all rates for the current channel, * using values from channel info struct, and send to NIC */ -static int iwl3945_send_tx_power(struct iwl_priv *priv) +static int il3945_send_tx_power(struct il_priv *priv) { int rate_idx, i; - const struct iwl_channel_info *ch_info = NULL; - struct iwl3945_txpowertable_cmd txpower = { - .channel = priv->contexts[IWL_RXON_CTX_BSS].active.channel, + const struct il_channel_info *ch_info = NULL; + struct il3945_txpowertable_cmd txpower = { + .channel = priv->contexts[IL_RXON_CTX_BSS].active.channel, }; u16 chan; @@ -1383,32 +1383,32 @@ static int iwl3945_send_tx_power(struct iwl_priv *priv) "TX Power requested while scanning!\n")) return -EAGAIN; - chan = le16_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.channel); + chan = le16_to_cpu(priv->contexts[IL_RXON_CTX_BSS].active.channel); txpower.band = (priv->band == IEEE80211_BAND_5GHZ) ? 0 : 1; - ch_info = iwl_legacy_get_channel_info(priv, priv->band, chan); + ch_info = il_get_channel_info(priv, priv->band, chan); if (!ch_info) { - IWL_ERR(priv, + IL_ERR(priv, "Failed to get channel info for channel %d [%d]\n", chan, priv->band); return -EINVAL; } - if (!iwl_legacy_is_channel_valid(ch_info)) { - IWL_DEBUG_POWER(priv, "Not calling TX_PWR_TABLE_CMD on " + if (!il_is_channel_valid(ch_info)) { + IL_DEBUG_POWER(priv, "Not calling TX_PWR_TABLE_CMD on " "non-Tx channel.\n"); return 0; } /* fill cmd with power settings for all rates for current channel */ /* Fill OFDM rate */ - for (rate_idx = IWL_FIRST_OFDM_RATE, i = 0; + for (rate_idx = IL_FIRST_OFDM_RATE, i = 0; rate_idx <= IWL39_LAST_OFDM_RATE; rate_idx++, i++) { txpower.power[i].tpc = ch_info->power_info[i].tpc; - txpower.power[i].rate = iwl3945_rates[rate_idx].plcp; + txpower.power[i].rate = il3945_rates[rate_idx].plcp; - IWL_DEBUG_POWER(priv, "ch %d:%d rf %d dsp %3d rate code 0x%02x\n", + IL_DEBUG_POWER(priv, "ch %d:%d rf %d dsp %3d rate code 0x%02x\n", le16_to_cpu(txpower.channel), txpower.band, txpower.power[i].tpc.tx_gain, @@ -1416,12 +1416,12 @@ static int iwl3945_send_tx_power(struct iwl_priv *priv) txpower.power[i].rate); } /* Fill CCK rates */ - for (rate_idx = IWL_FIRST_CCK_RATE; - rate_idx <= IWL_LAST_CCK_RATE; rate_idx++, i++) { + for (rate_idx = IL_FIRST_CCK_RATE; + rate_idx <= IL_LAST_CCK_RATE; rate_idx++, i++) { txpower.power[i].tpc = ch_info->power_info[i].tpc; - txpower.power[i].rate = iwl3945_rates[rate_idx].plcp; + txpower.power[i].rate = il3945_rates[rate_idx].plcp; - IWL_DEBUG_POWER(priv, "ch %d:%d rf %d dsp %3d rate code 0x%02x\n", + IL_DEBUG_POWER(priv, "ch %d:%d rf %d dsp %3d rate code 0x%02x\n", le16_to_cpu(txpower.channel), txpower.band, txpower.power[i].tpc.tx_gain, @@ -1429,14 +1429,14 @@ static int iwl3945_send_tx_power(struct iwl_priv *priv) txpower.power[i].rate); } - return iwl_legacy_send_cmd_pdu(priv, REPLY_TX_PWR_TABLE_CMD, - sizeof(struct iwl3945_txpowertable_cmd), + return il_send_cmd_pdu(priv, REPLY_TX_PWR_TABLE_CMD, + sizeof(struct il3945_txpowertable_cmd), &txpower); } /** - * iwl3945_hw_reg_set_new_power - Configures power tables at new levels + * il3945_hw_reg_set_new_power - Configures power tables at new levels * @ch_info: Channel to update. Uses power_info.requested_power. * * Replace requested_power and base_power_index ch_info fields for @@ -1451,10 +1451,10 @@ static int iwl3945_send_tx_power(struct iwl_priv *priv) * properly fill out the scan powers, and actual h/w gain settings, * and send changes to NIC */ -static int iwl3945_hw_reg_set_new_power(struct iwl_priv *priv, - struct iwl_channel_info *ch_info) +static int il3945_hw_reg_set_new_power(struct il_priv *priv, + struct il_channel_info *ch_info) { - struct iwl3945_channel_power_info *power_info; + struct il3945_channel_power_info *power_info; int power_changed = 0; int i; const s8 *clip_pwrs; @@ -1467,7 +1467,7 @@ static int iwl3945_hw_reg_set_new_power(struct iwl_priv *priv, power_info = ch_info->power_info; /* update OFDM Txpower settings */ - for (i = IWL_RATE_6M_INDEX_TABLE; i <= IWL_RATE_54M_INDEX_TABLE; + for (i = IL_RATE_6M_INDEX_TABLE; i <= IL_RATE_54M_INDEX_TABLE; i++, ++power_info) { int delta_idx; @@ -1491,15 +1491,15 @@ static int iwl3945_hw_reg_set_new_power(struct iwl_priv *priv, * ... all CCK power settings for a given channel are the *same*. */ if (power_changed) { power = - ch_info->power_info[IWL_RATE_12M_INDEX_TABLE]. - requested_power + IWL_CCK_FROM_OFDM_POWER_DIFF; + ch_info->power_info[IL_RATE_12M_INDEX_TABLE]. + requested_power + IL_CCK_FROM_OFDM_POWER_DIFF; - /* do all CCK rates' iwl3945_channel_power_info structures */ - for (i = IWL_RATE_1M_INDEX_TABLE; i <= IWL_RATE_11M_INDEX_TABLE; i++) { + /* do all CCK rates' il3945_channel_power_info structures */ + for (i = IL_RATE_1M_INDEX_TABLE; i <= IL_RATE_11M_INDEX_TABLE; i++) { power_info->requested_power = power; power_info->base_power_index = - ch_info->power_info[IWL_RATE_12M_INDEX_TABLE]. - base_power_index + IWL_CCK_FROM_OFDM_INDEX_DIFF; + ch_info->power_info[IL_RATE_12M_INDEX_TABLE]. + base_power_index + IL_CCK_FROM_OFDM_INDEX_DIFF; ++power_info; } } @@ -1508,13 +1508,13 @@ static int iwl3945_hw_reg_set_new_power(struct iwl_priv *priv, } /** - * iwl3945_hw_reg_get_ch_txpower_limit - returns new power limit for channel + * il3945_hw_reg_get_ch_txpower_limit - returns new power limit for channel * * NOTE: Returned power limit may be less (but not more) than requested, * based strictly on regulatory (eeprom and spectrum mgt) limitations * (no consideration for h/w clipping limitations). */ -static int iwl3945_hw_reg_get_ch_txpower_limit(struct iwl_channel_info *ch_info) +static int il3945_hw_reg_get_ch_txpower_limit(struct il_channel_info *ch_info) { s8 max_power; @@ -1533,7 +1533,7 @@ static int iwl3945_hw_reg_get_ch_txpower_limit(struct iwl_channel_info *ch_info) } /** - * iwl3945_hw_reg_comp_txpower_temp - Compensate for temperature + * il3945_hw_reg_comp_txpower_temp - Compensate for temperature * * Compensate txpower settings of *all* channels for temperature. * This only accounts for the difference between current temperature @@ -1542,10 +1542,10 @@ static int iwl3945_hw_reg_get_ch_txpower_limit(struct iwl_channel_info *ch_info) * * If RxOn is "associated", this sends the new Txpower to NIC! */ -static int iwl3945_hw_reg_comp_txpower_temp(struct iwl_priv *priv) +static int il3945_hw_reg_comp_txpower_temp(struct il_priv *priv) { - struct iwl_channel_info *ch_info = NULL; - struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom; + struct il_channel_info *ch_info = NULL; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; int delta_index; const s8 *clip_pwrs; /* array of h/w max power levels for each rate */ u8 a_band; @@ -1563,7 +1563,7 @@ static int iwl3945_hw_reg_comp_txpower_temp(struct iwl_priv *priv) /* set up new Tx power info for each and every channel, 2.4 and 5.x */ for (i = 0; i < priv->channel_count; i++) { ch_info = &priv->channel_info[i]; - a_band = iwl_legacy_is_channel_a_band(ch_info); + a_band = il_is_channel_a_band(ch_info); /* Get this chnlgrp's factory calibration temperature */ ref_temp = (s16)eeprom->groups[ch_info->group_index]. @@ -1571,11 +1571,11 @@ static int iwl3945_hw_reg_comp_txpower_temp(struct iwl_priv *priv) /* get power index adjustment based on current and factory * temps */ - delta_index = iwl3945_hw_reg_adjust_power_by_temp(temperature, + delta_index = il3945_hw_reg_adjust_power_by_temp(temperature, ref_temp); /* set tx power value for all rates, OFDM and CCK */ - for (rate_index = 0; rate_index < IWL_RATE_COUNT_3945; + for (rate_index = 0; rate_index < IL_RATE_COUNT_3945; rate_index++) { int power_idx = ch_info->power_info[rate_index].base_power_index; @@ -1584,7 +1584,7 @@ static int iwl3945_hw_reg_comp_txpower_temp(struct iwl_priv *priv) power_idx += delta_index; /* stay within table range */ - power_idx = iwl3945_hw_reg_fix_power_index(power_idx); + power_idx = il3945_hw_reg_fix_power_index(power_idx); ch_info->power_info[rate_index]. power_table_index = (u8) power_idx; ch_info->power_info[rate_index].tpc = @@ -1596,10 +1596,10 @@ static int iwl3945_hw_reg_comp_txpower_temp(struct iwl_priv *priv) /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */ for (scan_tbl_index = 0; - scan_tbl_index < IWL_NUM_SCAN_RATES; scan_tbl_index++) { + scan_tbl_index < IL_NUM_SCAN_RATES; scan_tbl_index++) { s32 actual_index = (scan_tbl_index == 0) ? - IWL_RATE_1M_INDEX_TABLE : IWL_RATE_6M_INDEX_TABLE; - iwl3945_hw_reg_set_scan_power(priv, scan_tbl_index, + IL_RATE_1M_INDEX_TABLE : IL_RATE_6M_INDEX_TABLE; + il3945_hw_reg_set_scan_power(priv, scan_tbl_index, actual_index, clip_pwrs, ch_info, a_band); } @@ -1609,68 +1609,68 @@ static int iwl3945_hw_reg_comp_txpower_temp(struct iwl_priv *priv) return priv->cfg->ops->lib->send_tx_power(priv); } -int iwl3945_hw_reg_set_txpower(struct iwl_priv *priv, s8 power) +int il3945_hw_reg_set_txpower(struct il_priv *priv, s8 power) { - struct iwl_channel_info *ch_info; + struct il_channel_info *ch_info; s8 max_power; u8 a_band; u8 i; if (priv->tx_power_user_lmt == power) { - IWL_DEBUG_POWER(priv, "Requested Tx power same as current " + IL_DEBUG_POWER(priv, "Requested Tx power same as current " "limit: %ddBm.\n", power); return 0; } - IWL_DEBUG_POWER(priv, "Setting upper limit clamp to %ddBm.\n", power); + IL_DEBUG_POWER(priv, "Setting upper limit clamp to %ddBm.\n", power); priv->tx_power_user_lmt = power; /* set up new Tx powers for each and every channel, 2.4 and 5.x */ for (i = 0; i < priv->channel_count; i++) { ch_info = &priv->channel_info[i]; - a_band = iwl_legacy_is_channel_a_band(ch_info); + a_band = il_is_channel_a_band(ch_info); /* find minimum power of all user and regulatory constraints * (does not consider h/w clipping limitations) */ - max_power = iwl3945_hw_reg_get_ch_txpower_limit(ch_info); + max_power = il3945_hw_reg_get_ch_txpower_limit(ch_info); max_power = min(power, max_power); if (max_power != ch_info->curr_txpow) { ch_info->curr_txpow = max_power; /* this considers the h/w clipping limitations */ - iwl3945_hw_reg_set_new_power(priv, ch_info); + il3945_hw_reg_set_new_power(priv, ch_info); } } /* update txpower settings for all channels, * send to NIC if associated. */ - iwl3945_is_temp_calib_needed(priv); - iwl3945_hw_reg_comp_txpower_temp(priv); + il3945_is_temp_calib_needed(priv); + il3945_hw_reg_comp_txpower_temp(priv); return 0; } -static int iwl3945_send_rxon_assoc(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +static int il3945_send_rxon_assoc(struct il_priv *priv, + struct il_rxon_context *ctx) { int rc = 0; - struct iwl_rx_packet *pkt; - struct iwl3945_rxon_assoc_cmd rxon_assoc; - struct iwl_host_cmd cmd = { + struct il_rx_packet *pkt; + struct il3945_rxon_assoc_cmd rxon_assoc; + struct il_host_cmd cmd = { .id = REPLY_RXON_ASSOC, .len = sizeof(rxon_assoc), .flags = CMD_WANT_SKB, .data = &rxon_assoc, }; - const struct iwl_legacy_rxon_cmd *rxon1 = &ctx->staging; - const struct iwl_legacy_rxon_cmd *rxon2 = &ctx->active; + const struct il_rxon_cmd *rxon1 = &ctx->staging; + const struct il_rxon_cmd *rxon2 = &ctx->active; if ((rxon1->flags == rxon2->flags) && (rxon1->filter_flags == rxon2->filter_flags) && (rxon1->cck_basic_rates == rxon2->cck_basic_rates) && (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { - IWL_DEBUG_INFO(priv, "Using current RXON_ASSOC. Not resending.\n"); + IL_DEBUG_INFO(priv, "Using current RXON_ASSOC. Not resending.\n"); return 0; } @@ -1680,41 +1680,41 @@ static int iwl3945_send_rxon_assoc(struct iwl_priv *priv, rxon_assoc.cck_basic_rates = ctx->staging.cck_basic_rates; rxon_assoc.reserved = 0; - rc = iwl_legacy_send_cmd_sync(priv, &cmd); + rc = il_send_cmd_sync(priv, &cmd); if (rc) return rc; - pkt = (struct iwl_rx_packet *)cmd.reply_page; - if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) { - IWL_ERR(priv, "Bad return from REPLY_RXON_ASSOC command\n"); + pkt = (struct il_rx_packet *)cmd.reply_page; + if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { + IL_ERR(priv, "Bad return from REPLY_RXON_ASSOC command\n"); rc = -EIO; } - iwl_legacy_free_pages(priv, cmd.reply_page); + il_free_pages(priv, cmd.reply_page); return rc; } /** - * iwl3945_commit_rxon - commit staging_rxon to hardware + * il3945_commit_rxon - commit staging_rxon to hardware * * The RXON command in staging_rxon is committed to the hardware and * the active_rxon structure is updated with the new data. This * function correctly transitions out of the RXON_ASSOC_MSK state if * a HW tune is required based on the RXON structure changes. */ -int iwl3945_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) +int il3945_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) { /* cast away the const for active_rxon in this function */ - struct iwl3945_rxon_cmd *active_rxon = (void *)&ctx->active; - struct iwl3945_rxon_cmd *staging_rxon = (void *)&ctx->staging; + struct il3945_rxon_cmd *active_rxon = (void *)&ctx->active; + struct il3945_rxon_cmd *staging_rxon = (void *)&ctx->staging; int rc = 0; bool new_assoc = !!(staging_rxon->filter_flags & RXON_FILTER_ASSOC_MSK); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return -EINVAL; - if (!iwl_legacy_is_alive(priv)) + if (!il_is_alive(priv)) return -1; /* always get timestamp with Rx frame */ @@ -1723,23 +1723,23 @@ int iwl3945_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) /* select antenna */ staging_rxon->flags &= ~(RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_SEL_MSK); - staging_rxon->flags |= iwl3945_get_antenna_flags(priv); + staging_rxon->flags |= il3945_get_antenna_flags(priv); - rc = iwl_legacy_check_rxon_cmd(priv, ctx); + rc = il_check_rxon_cmd(priv, ctx); if (rc) { - IWL_ERR(priv, "Invalid RXON configuration. Not committing.\n"); + IL_ERR(priv, "Invalid RXON configuration. Not committing.\n"); return -EINVAL; } /* If we don't need to send a full RXON, we can use - * iwl3945_rxon_assoc_cmd which is used to reconfigure filter + * il3945_rxon_assoc_cmd which is used to reconfigure filter * and other flags for the current radio configuration. */ - if (!iwl_legacy_full_rxon_required(priv, - &priv->contexts[IWL_RXON_CTX_BSS])) { - rc = iwl_legacy_send_rxon_assoc(priv, - &priv->contexts[IWL_RXON_CTX_BSS]); + if (!il_full_rxon_required(priv, + &priv->contexts[IL_RXON_CTX_BSS])) { + rc = il_send_rxon_assoc(priv, + &priv->contexts[IL_RXON_CTX_BSS]); if (rc) { - IWL_ERR(priv, "Error setting RXON_ASSOC " + IL_ERR(priv, "Error setting RXON_ASSOC " "configuration (%d).\n", rc); return rc; } @@ -1749,7 +1749,7 @@ int iwl3945_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) * We do not commit tx power settings while channel changing, * do it now if tx power changed. */ - iwl_legacy_set_tx_power(priv, priv->tx_power_next, false); + il_set_tx_power(priv, priv->tx_power_next, false); return 0; } @@ -1757,8 +1757,8 @@ int iwl3945_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) * an RXON_ASSOC and the new config wants the associated mask enabled, * we must clear the associated from the active configuration * before we apply the new config */ - if (iwl_legacy_is_associated(priv, IWL_RXON_CTX_BSS) && new_assoc) { - IWL_DEBUG_INFO(priv, "Toggling associated bit on current RXON\n"); + if (il_is_associated(priv, IL_RXON_CTX_BSS) && new_assoc) { + IL_DEBUG_INFO(priv, "Toggling associated bit on current RXON\n"); active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; /* @@ -1767,25 +1767,25 @@ int iwl3945_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) */ active_rxon->reserved4 = 0; active_rxon->reserved5 = 0; - rc = iwl_legacy_send_cmd_pdu(priv, REPLY_RXON, - sizeof(struct iwl3945_rxon_cmd), - &priv->contexts[IWL_RXON_CTX_BSS].active); + rc = il_send_cmd_pdu(priv, REPLY_RXON, + sizeof(struct il3945_rxon_cmd), + &priv->contexts[IL_RXON_CTX_BSS].active); /* If the mask clearing failed then we set * active_rxon back to what it was previously */ if (rc) { active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK; - IWL_ERR(priv, "Error clearing ASSOC_MSK on current " + IL_ERR(priv, "Error clearing ASSOC_MSK on current " "configuration (%d).\n", rc); return rc; } - iwl_legacy_clear_ucode_stations(priv, - &priv->contexts[IWL_RXON_CTX_BSS]); - iwl_legacy_restore_stations(priv, - &priv->contexts[IWL_RXON_CTX_BSS]); + il_clear_ucode_stations(priv, + &priv->contexts[IL_RXON_CTX_BSS]); + il_restore_stations(priv, + &priv->contexts[IL_RXON_CTX_BSS]); } - IWL_DEBUG_INFO(priv, "Sending RXON\n" + IL_DEBUG_INFO(priv, "Sending RXON\n" "* with%s RXON_FILTER_ASSOC_MSK\n" "* channel = %d\n" "* bssid = %pM\n", @@ -1800,38 +1800,38 @@ int iwl3945_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) staging_rxon->reserved4 = 0; staging_rxon->reserved5 = 0; - iwl_legacy_set_rxon_hwcrypto(priv, ctx, !iwl3945_mod_params.sw_crypto); + il_set_rxon_hwcrypto(priv, ctx, !il3945_mod_params.sw_crypto); /* Apply the new configuration */ - rc = iwl_legacy_send_cmd_pdu(priv, REPLY_RXON, - sizeof(struct iwl3945_rxon_cmd), + rc = il_send_cmd_pdu(priv, REPLY_RXON, + sizeof(struct il3945_rxon_cmd), staging_rxon); if (rc) { - IWL_ERR(priv, "Error setting new configuration (%d).\n", rc); + IL_ERR(priv, "Error setting new configuration (%d).\n", rc); return rc; } memcpy(active_rxon, staging_rxon, sizeof(*active_rxon)); if (!new_assoc) { - iwl_legacy_clear_ucode_stations(priv, - &priv->contexts[IWL_RXON_CTX_BSS]); - iwl_legacy_restore_stations(priv, - &priv->contexts[IWL_RXON_CTX_BSS]); + il_clear_ucode_stations(priv, + &priv->contexts[IL_RXON_CTX_BSS]); + il_restore_stations(priv, + &priv->contexts[IL_RXON_CTX_BSS]); } /* If we issue a new RXON command which required a tune then we must * send a new TXPOWER command or we won't be able to Tx any frames */ - rc = iwl_legacy_set_tx_power(priv, priv->tx_power_next, true); + rc = il_set_tx_power(priv, priv->tx_power_next, true); if (rc) { - IWL_ERR(priv, "Error setting Tx power (%d).\n", rc); + IL_ERR(priv, "Error setting Tx power (%d).\n", rc); return rc; } /* Init the hardware's rate fallback order based on the band */ - rc = iwl3945_init_hw_rate_table(priv); + rc = il3945_init_hw_rate_table(priv); if (rc) { - IWL_ERR(priv, "Error setting HW rate table: %02X\n", rc); + IL_ERR(priv, "Error setting HW rate table: %02X\n", rc); return -EIO; } @@ -1839,7 +1839,7 @@ int iwl3945_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) } /** - * iwl3945_reg_txpower_periodic - called when time to check our temperature. + * il3945_reg_txpower_periodic - called when time to check our temperature. * * -- reset periodic timer * -- see if temp has changed enough to warrant re-calibration ... if so: @@ -1848,38 +1848,38 @@ int iwl3945_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) * -- send new set of gain settings to NIC * NOTE: This should continue working, even when we're not associated, * so we can keep our internal table of scan powers current. */ -void iwl3945_reg_txpower_periodic(struct iwl_priv *priv) +void il3945_reg_txpower_periodic(struct il_priv *priv) { /* This will kick in the "brute force" - * iwl3945_hw_reg_comp_txpower_temp() below */ - if (!iwl3945_is_temp_calib_needed(priv)) + * il3945_hw_reg_comp_txpower_temp() below */ + if (!il3945_is_temp_calib_needed(priv)) goto reschedule; /* Set up a new set of temp-adjusted TxPowers, send to NIC. * This is based *only* on current temperature, * ignoring any previous power measurements */ - iwl3945_hw_reg_comp_txpower_temp(priv); + il3945_hw_reg_comp_txpower_temp(priv); reschedule: queue_delayed_work(priv->workqueue, &priv->_3945.thermal_periodic, REG_RECALIB_PERIOD * HZ); } -static void iwl3945_bg_reg_txpower_periodic(struct work_struct *work) +static void il3945_bg_reg_txpower_periodic(struct work_struct *work) { - struct iwl_priv *priv = container_of(work, struct iwl_priv, + struct il_priv *priv = container_of(work, struct il_priv, _3945.thermal_periodic.work); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; mutex_lock(&priv->mutex); - iwl3945_reg_txpower_periodic(priv); + il3945_reg_txpower_periodic(priv); mutex_unlock(&priv->mutex); } /** - * iwl3945_hw_reg_get_ch_grp_index - find the channel-group index (0-4) + * il3945_hw_reg_get_ch_grp_index - find the channel-group index (0-4) * for the channel. * * This function is used when initializing channel-info structs. @@ -1889,17 +1889,17 @@ static void iwl3945_bg_reg_txpower_periodic(struct work_struct *work) * on A-band, EEPROM's "group frequency" entries represent the top * channel in each group 1-4. Group 5 All B/G channels are in group 0. */ -static u16 iwl3945_hw_reg_get_ch_grp_index(struct iwl_priv *priv, - const struct iwl_channel_info *ch_info) +static u16 il3945_hw_reg_get_ch_grp_index(struct il_priv *priv, + const struct il_channel_info *ch_info) { - struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom; - struct iwl3945_eeprom_txpower_group *ch_grp = &eeprom->groups[0]; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; + struct il3945_eeprom_txpower_group *ch_grp = &eeprom->groups[0]; u8 group; u16 group_index = 0; /* based on factory calib frequencies */ u8 grp_channel; /* Find the group index for the channel ... don't use index 1(?) */ - if (iwl_legacy_is_channel_a_band(ch_info)) { + if (il_is_channel_a_band(ch_info)) { for (group = 1; group < 5; group++) { grp_channel = ch_grp[group].group_channel; if (ch_info->channel <= grp_channel) { @@ -1913,27 +1913,27 @@ static u16 iwl3945_hw_reg_get_ch_grp_index(struct iwl_priv *priv, } else group_index = 0; /* 2.4 GHz, group 0 */ - IWL_DEBUG_POWER(priv, "Chnl %d mapped to grp %d\n", ch_info->channel, + IL_DEBUG_POWER(priv, "Chnl %d mapped to grp %d\n", ch_info->channel, group_index); return group_index; } /** - * iwl3945_hw_reg_get_matched_power_index - Interpolate to get nominal index + * il3945_hw_reg_get_matched_power_index - Interpolate to get nominal index * * Interpolate to get nominal (i.e. at factory calibration temperature) index * into radio/DSP gain settings table for requested power. */ -static int iwl3945_hw_reg_get_matched_power_index(struct iwl_priv *priv, +static int il3945_hw_reg_get_matched_power_index(struct il_priv *priv, s8 requested_power, s32 setting_index, s32 *new_index) { - const struct iwl3945_eeprom_txpower_group *chnl_grp = NULL; - struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom; + const struct il3945_eeprom_txpower_group *chnl_grp = NULL; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; s32 index0, index1; s32 power = 2 * requested_power; s32 i; - const struct iwl3945_eeprom_txpower_sample *samples; + const struct il3945_eeprom_txpower_sample *samples; s32 gains0, gains1; s32 res; s32 denominator; @@ -1973,23 +1973,23 @@ static int iwl3945_hw_reg_get_matched_power_index(struct iwl_priv *priv, return 0; } -static void iwl3945_hw_reg_init_channel_groups(struct iwl_priv *priv) +static void il3945_hw_reg_init_channel_groups(struct il_priv *priv) { u32 i; s32 rate_index; - struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom; - const struct iwl3945_eeprom_txpower_group *group; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; + const struct il3945_eeprom_txpower_group *group; - IWL_DEBUG_POWER(priv, "Initializing factory calib info from EEPROM\n"); + IL_DEBUG_POWER(priv, "Initializing factory calib info from EEPROM\n"); - for (i = 0; i < IWL_NUM_TX_CALIB_GROUPS; i++) { + for (i = 0; i < IL_NUM_TX_CALIB_GROUPS; i++) { s8 *clip_pwrs; /* table of power levels for each rate */ s8 satur_pwr; /* saturation power for each chnl group */ group = &eeprom->groups[i]; /* sanity check on factory saturation power value */ if (group->saturation_power < 40) { - IWL_WARN(priv, "Error: saturation power is %d, " + IL_WARN(priv, "Error: saturation power is %d, " "less than minimum expected 40\n", group->saturation_power); return; @@ -2011,21 +2011,21 @@ static void iwl3945_hw_reg_init_channel_groups(struct iwl_priv *priv) /* fill in channel group's nominal powers for each rate */ for (rate_index = 0; - rate_index < IWL_RATE_COUNT_3945; rate_index++, clip_pwrs++) { + rate_index < IL_RATE_COUNT_3945; rate_index++, clip_pwrs++) { switch (rate_index) { - case IWL_RATE_36M_INDEX_TABLE: + case IL_RATE_36M_INDEX_TABLE: if (i == 0) /* B/G */ *clip_pwrs = satur_pwr; else /* A */ *clip_pwrs = satur_pwr - 5; break; - case IWL_RATE_48M_INDEX_TABLE: + case IL_RATE_48M_INDEX_TABLE: if (i == 0) *clip_pwrs = satur_pwr - 7; else *clip_pwrs = satur_pwr - 10; break; - case IWL_RATE_54M_INDEX_TABLE: + case IL_RATE_54M_INDEX_TABLE: if (i == 0) *clip_pwrs = satur_pwr - 9; else @@ -2040,7 +2040,7 @@ static void iwl3945_hw_reg_init_channel_groups(struct iwl_priv *priv) } /** - * iwl3945_txpower_set_from_eeprom - Set channel power info based on EEPROM + * il3945_txpower_set_from_eeprom - Set channel power info based on EEPROM * * Second pass (during init) to set up priv->channel_info * @@ -2054,11 +2054,11 @@ static void iwl3945_hw_reg_init_channel_groups(struct iwl_priv *priv) * * This does *not* write values to NIC, just sets up our internal table. */ -int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv) +int il3945_txpower_set_from_eeprom(struct il_priv *priv) { - struct iwl_channel_info *ch_info = NULL; - struct iwl3945_channel_power_info *pwr_info; - struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom; + struct il_channel_info *ch_info = NULL; + struct il3945_channel_power_info *pwr_info; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; int delta_index; u8 rate_index; u8 scan_tbl_index; @@ -2071,37 +2071,37 @@ int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv) /* save temperature reference, * so we can determine next time to calibrate */ - temperature = iwl3945_hw_reg_txpower_get_temperature(priv); + temperature = il3945_hw_reg_txpower_get_temperature(priv); priv->last_temperature = temperature; - iwl3945_hw_reg_init_channel_groups(priv); + il3945_hw_reg_init_channel_groups(priv); /* initialize Tx power info for each and every channel, 2.4 and 5.x */ for (i = 0, ch_info = priv->channel_info; i < priv->channel_count; i++, ch_info++) { - a_band = iwl_legacy_is_channel_a_band(ch_info); - if (!iwl_legacy_is_channel_valid(ch_info)) + a_band = il_is_channel_a_band(ch_info); + if (!il_is_channel_valid(ch_info)) continue; /* find this channel's channel group (*not* "band") index */ ch_info->group_index = - iwl3945_hw_reg_get_ch_grp_index(priv, ch_info); + il3945_hw_reg_get_ch_grp_index(priv, ch_info); /* Get this chnlgrp's rate->max/clip-powers table */ clip_pwrs = priv->_3945.clip_groups[ch_info->group_index].clip_powers; /* calculate power index *adjustment* value according to * diff between current temperature and factory temperature */ - delta_index = iwl3945_hw_reg_adjust_power_by_temp(temperature, + delta_index = il3945_hw_reg_adjust_power_by_temp(temperature, eeprom->groups[ch_info->group_index]. temperature); - IWL_DEBUG_POWER(priv, "Delta index for channel %d: %d [%d]\n", + IL_DEBUG_POWER(priv, "Delta index for channel %d: %d [%d]\n", ch_info->channel, delta_index, temperature + - IWL_TEMP_CONVERT); + IL_TEMP_CONVERT); /* set tx power value for all OFDM rates */ - for (rate_index = 0; rate_index < IWL_OFDM_RATES; + for (rate_index = 0; rate_index < IL_OFDM_RATES; rate_index++) { s32 uninitialized_var(power_idx); int rc; @@ -2115,11 +2115,11 @@ int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv) /* get base (i.e. at factory-measured temperature) * power table index for this rate's power */ - rc = iwl3945_hw_reg_get_matched_power_index(priv, pwr, + rc = il3945_hw_reg_get_matched_power_index(priv, pwr, ch_info->group_index, &power_idx); if (rc) { - IWL_ERR(priv, "Invalid power index\n"); + IL_ERR(priv, "Invalid power index\n"); return rc; } pwr_info->base_power_index = (u8) power_idx; @@ -2128,9 +2128,9 @@ int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv) power_idx += delta_index; /* stay within range of gain table */ - power_idx = iwl3945_hw_reg_fix_power_index(power_idx); + power_idx = il3945_hw_reg_fix_power_index(power_idx); - /* fill 1 OFDM rate's iwl3945_channel_power_info struct */ + /* fill 1 OFDM rate's il3945_channel_power_info struct */ pwr_info->requested_power = pwr; pwr_info->power_table_index = (u8) power_idx; pwr_info->tpc.tx_gain = @@ -2140,25 +2140,25 @@ int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv) } /* set tx power for CCK rates, based on OFDM 12 Mbit settings*/ - pwr_info = &ch_info->power_info[IWL_RATE_12M_INDEX_TABLE]; + pwr_info = &ch_info->power_info[IL_RATE_12M_INDEX_TABLE]; power = pwr_info->requested_power + - IWL_CCK_FROM_OFDM_POWER_DIFF; + IL_CCK_FROM_OFDM_POWER_DIFF; pwr_index = pwr_info->power_table_index + - IWL_CCK_FROM_OFDM_INDEX_DIFF; + IL_CCK_FROM_OFDM_INDEX_DIFF; base_pwr_index = pwr_info->base_power_index + - IWL_CCK_FROM_OFDM_INDEX_DIFF; + IL_CCK_FROM_OFDM_INDEX_DIFF; /* stay within table range */ - pwr_index = iwl3945_hw_reg_fix_power_index(pwr_index); + pwr_index = il3945_hw_reg_fix_power_index(pwr_index); gain = power_gain_table[a_band][pwr_index].tx_gain; dsp_atten = power_gain_table[a_band][pwr_index].dsp_atten; - /* fill each CCK rate's iwl3945_channel_power_info structure + /* fill each CCK rate's il3945_channel_power_info structure * NOTE: All CCK-rate Txpwrs are the same for a given chnl! * NOTE: CCK rates start at end of OFDM rates! */ for (rate_index = 0; - rate_index < IWL_CCK_RATES; rate_index++) { - pwr_info = &ch_info->power_info[rate_index+IWL_OFDM_RATES]; + rate_index < IL_CCK_RATES; rate_index++) { + pwr_info = &ch_info->power_info[rate_index+IL_OFDM_RATES]; pwr_info->requested_power = power; pwr_info->power_table_index = pwr_index; pwr_info->base_power_index = base_pwr_index; @@ -2168,10 +2168,10 @@ int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv) /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */ for (scan_tbl_index = 0; - scan_tbl_index < IWL_NUM_SCAN_RATES; scan_tbl_index++) { + scan_tbl_index < IL_NUM_SCAN_RATES; scan_tbl_index++) { s32 actual_index = (scan_tbl_index == 0) ? - IWL_RATE_1M_INDEX_TABLE : IWL_RATE_6M_INDEX_TABLE; - iwl3945_hw_reg_set_scan_power(priv, scan_tbl_index, + IL_RATE_1M_INDEX_TABLE : IL_RATE_6M_INDEX_TABLE; + il3945_hw_reg_set_scan_power(priv, scan_tbl_index, actual_index, clip_pwrs, ch_info, a_band); } } @@ -2179,31 +2179,31 @@ int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv) return 0; } -int iwl3945_hw_rxq_stop(struct iwl_priv *priv) +int il3945_hw_rxq_stop(struct il_priv *priv) { int rc; - iwl_legacy_write_direct32(priv, FH39_RCSR_CONFIG(0), 0); - rc = iwl_poll_direct_bit(priv, FH39_RSSR_STATUS, + il_write_direct32(priv, FH39_RCSR_CONFIG(0), 0); + rc = il_poll_direct_bit(priv, FH39_RSSR_STATUS, FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); if (rc < 0) - IWL_ERR(priv, "Can't stop Rx DMA.\n"); + IL_ERR(priv, "Can't stop Rx DMA.\n"); return 0; } -int iwl3945_hw_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq) +int il3945_hw_tx_queue_init(struct il_priv *priv, struct il_tx_queue *txq) { int txq_id = txq->q.id; - struct iwl3945_shared *shared_data = priv->_3945.shared_virt; + struct il3945_shared *shared_data = priv->_3945.shared_virt; shared_data->tx_base_ptr[txq_id] = cpu_to_le32((u32)txq->q.dma_addr); - iwl_legacy_write_direct32(priv, FH39_CBCC_CTRL(txq_id), 0); - iwl_legacy_write_direct32(priv, FH39_CBCC_BASE(txq_id), 0); + il_write_direct32(priv, FH39_CBCC_CTRL(txq_id), 0); + il_write_direct32(priv, FH39_CBCC_BASE(txq_id), 0); - iwl_legacy_write_direct32(priv, FH39_TCSR_CONFIG(txq_id), + il_write_direct32(priv, FH39_TCSR_CONFIG(txq_id), FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT | FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF | FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD | @@ -2211,7 +2211,7 @@ int iwl3945_hw_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq) FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE); /* fake read to flush all prev. writes */ - iwl_read32(priv, FH39_TSSR_CBB_BASE); + il_read32(priv, FH39_TSSR_CBB_BASE); return 0; } @@ -2219,26 +2219,26 @@ int iwl3945_hw_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq) /* * HCMD utils */ -static u16 iwl3945_get_hcmd_size(u8 cmd_id, u16 len) +static u16 il3945_get_hcmd_size(u8 cmd_id, u16 len) { switch (cmd_id) { case REPLY_RXON: - return sizeof(struct iwl3945_rxon_cmd); + return sizeof(struct il3945_rxon_cmd); case POWER_TABLE_CMD: - return sizeof(struct iwl3945_powertable_cmd); + return sizeof(struct il3945_powertable_cmd); default: return len; } } -static u16 iwl3945_build_addsta_hcmd(const struct iwl_legacy_addsta_cmd *cmd, +static u16 il3945_build_addsta_hcmd(const struct il_addsta_cmd *cmd, u8 *data) { - struct iwl3945_addsta_cmd *addsta = (struct iwl3945_addsta_cmd *)data; + struct il3945_addsta_cmd *addsta = (struct il3945_addsta_cmd *)data; addsta->mode = cmd->mode; memcpy(&addsta->sta, &cmd->sta, sizeof(struct sta_id_modify)); - memcpy(&addsta->key, &cmd->key, sizeof(struct iwl4965_keyinfo)); + memcpy(&addsta->key, &cmd->key, sizeof(struct il4965_keyinfo)); addsta->station_flags = cmd->station_flags; addsta->station_flags_msk = cmd->station_flags_msk; addsta->tid_disable_tx = cpu_to_le16(0); @@ -2247,23 +2247,23 @@ static u16 iwl3945_build_addsta_hcmd(const struct iwl_legacy_addsta_cmd *cmd, addsta->remove_immediate_ba_tid = cmd->remove_immediate_ba_tid; addsta->add_immediate_ba_ssn = cmd->add_immediate_ba_ssn; - return (u16)sizeof(struct iwl3945_addsta_cmd); + return (u16)sizeof(struct il3945_addsta_cmd); } -static int iwl3945_add_bssid_station(struct iwl_priv *priv, +static int il3945_add_bssid_station(struct il_priv *priv, const u8 *addr, u8 *sta_id_r) { - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; int ret; u8 sta_id; unsigned long flags; if (sta_id_r) - *sta_id_r = IWL_INVALID_STATION; + *sta_id_r = IL_INVALID_STATION; - ret = iwl_legacy_add_station_common(priv, ctx, addr, 0, NULL, &sta_id); + ret = il_add_station_common(priv, ctx, addr, 0, NULL, &sta_id); if (ret) { - IWL_ERR(priv, "Unable to add station %pM\n", addr); + IL_ERR(priv, "Unable to add station %pM\n", addr); return ret; } @@ -2271,93 +2271,93 @@ static int iwl3945_add_bssid_station(struct iwl_priv *priv, *sta_id_r = sta_id; spin_lock_irqsave(&priv->sta_lock, flags); - priv->stations[sta_id].used |= IWL_STA_LOCAL; + priv->stations[sta_id].used |= IL_STA_LOCAL; spin_unlock_irqrestore(&priv->sta_lock, flags); return 0; } -static int iwl3945_manage_ibss_station(struct iwl_priv *priv, +static int il3945_manage_ibss_station(struct il_priv *priv, struct ieee80211_vif *vif, bool add) { - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; int ret; if (add) { - ret = iwl3945_add_bssid_station(priv, vif->bss_conf.bssid, + ret = il3945_add_bssid_station(priv, vif->bss_conf.bssid, &vif_priv->ibss_bssid_sta_id); if (ret) return ret; - iwl3945_sync_sta(priv, vif_priv->ibss_bssid_sta_id, + il3945_sync_sta(priv, vif_priv->ibss_bssid_sta_id, (priv->band == IEEE80211_BAND_5GHZ) ? - IWL_RATE_6M_PLCP : IWL_RATE_1M_PLCP); - iwl3945_rate_scale_init(priv->hw, vif_priv->ibss_bssid_sta_id); + IL_RATE_6M_PLCP : IL_RATE_1M_PLCP); + il3945_rate_scale_init(priv->hw, vif_priv->ibss_bssid_sta_id); return 0; } - return iwl_legacy_remove_station(priv, vif_priv->ibss_bssid_sta_id, + return il_remove_station(priv, vif_priv->ibss_bssid_sta_id, vif->bss_conf.bssid); } /** - * iwl3945_init_hw_rate_table - Initialize the hardware rate fallback table + * il3945_init_hw_rate_table - Initialize the hardware rate fallback table */ -int iwl3945_init_hw_rate_table(struct iwl_priv *priv) +int il3945_init_hw_rate_table(struct il_priv *priv) { int rc, i, index, prev_index; - struct iwl3945_rate_scaling_cmd rate_cmd = { + struct il3945_rate_scaling_cmd rate_cmd = { .reserved = {0, 0, 0}, }; - struct iwl3945_rate_scaling_info *table = rate_cmd.table; + struct il3945_rate_scaling_info *table = rate_cmd.table; - for (i = 0; i < ARRAY_SIZE(iwl3945_rates); i++) { - index = iwl3945_rates[i].table_rs_index; + for (i = 0; i < ARRAY_SIZE(il3945_rates); i++) { + index = il3945_rates[i].table_rs_index; table[index].rate_n_flags = - iwl3945_hw_set_rate_n_flags(iwl3945_rates[i].plcp, 0); + il3945_hw_set_rate_n_flags(il3945_rates[i].plcp, 0); table[index].try_cnt = priv->retry_rate; - prev_index = iwl3945_get_prev_ieee_rate(i); + prev_index = il3945_get_prev_ieee_rate(i); table[index].next_rate_index = - iwl3945_rates[prev_index].table_rs_index; + il3945_rates[prev_index].table_rs_index; } switch (priv->band) { case IEEE80211_BAND_5GHZ: - IWL_DEBUG_RATE(priv, "Select A mode rate scale\n"); + IL_DEBUG_RATE(priv, "Select A mode rate scale\n"); /* If one of the following CCK rates is used, * have it fall back to the 6M OFDM rate */ - for (i = IWL_RATE_1M_INDEX_TABLE; - i <= IWL_RATE_11M_INDEX_TABLE; i++) + for (i = IL_RATE_1M_INDEX_TABLE; + i <= IL_RATE_11M_INDEX_TABLE; i++) table[i].next_rate_index = - iwl3945_rates[IWL_FIRST_OFDM_RATE].table_rs_index; + il3945_rates[IL_FIRST_OFDM_RATE].table_rs_index; /* Don't fall back to CCK rates */ - table[IWL_RATE_12M_INDEX_TABLE].next_rate_index = - IWL_RATE_9M_INDEX_TABLE; + table[IL_RATE_12M_INDEX_TABLE].next_rate_index = + IL_RATE_9M_INDEX_TABLE; /* Don't drop out of OFDM rates */ - table[IWL_RATE_6M_INDEX_TABLE].next_rate_index = - iwl3945_rates[IWL_FIRST_OFDM_RATE].table_rs_index; + table[IL_RATE_6M_INDEX_TABLE].next_rate_index = + il3945_rates[IL_FIRST_OFDM_RATE].table_rs_index; break; case IEEE80211_BAND_2GHZ: - IWL_DEBUG_RATE(priv, "Select B/G mode rate scale\n"); + IL_DEBUG_RATE(priv, "Select B/G mode rate scale\n"); /* If an OFDM rate is used, have it fall back to the * 1M CCK rates */ - if (!(priv->_3945.sta_supp_rates & IWL_OFDM_RATES_MASK) && - iwl_legacy_is_associated(priv, IWL_RXON_CTX_BSS)) { + if (!(priv->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && + il_is_associated(priv, IL_RXON_CTX_BSS)) { - index = IWL_FIRST_CCK_RATE; - for (i = IWL_RATE_6M_INDEX_TABLE; - i <= IWL_RATE_54M_INDEX_TABLE; i++) + index = IL_FIRST_CCK_RATE; + for (i = IL_RATE_6M_INDEX_TABLE; + i <= IL_RATE_54M_INDEX_TABLE; i++) table[i].next_rate_index = - iwl3945_rates[index].table_rs_index; + il3945_rates[index].table_rs_index; - index = IWL_RATE_11M_INDEX_TABLE; + index = IL_RATE_11M_INDEX_TABLE; /* CCK shouldn't fall back to OFDM... */ - table[index].next_rate_index = IWL_RATE_5M_INDEX_TABLE; + table[index].next_rate_index = IL_RATE_5M_INDEX_TABLE; } break; @@ -2368,41 +2368,41 @@ int iwl3945_init_hw_rate_table(struct iwl_priv *priv) /* Update the rate scaling for control frame Tx */ rate_cmd.table_id = 0; - rc = iwl_legacy_send_cmd_pdu(priv, REPLY_RATE_SCALE, sizeof(rate_cmd), + rc = il_send_cmd_pdu(priv, REPLY_RATE_SCALE, sizeof(rate_cmd), &rate_cmd); if (rc) return rc; /* Update the rate scaling for data frame Tx */ rate_cmd.table_id = 1; - return iwl_legacy_send_cmd_pdu(priv, REPLY_RATE_SCALE, sizeof(rate_cmd), + return il_send_cmd_pdu(priv, REPLY_RATE_SCALE, sizeof(rate_cmd), &rate_cmd); } /* Called when initializing driver */ -int iwl3945_hw_set_hw_params(struct iwl_priv *priv) +int il3945_hw_set_hw_params(struct il_priv *priv) { memset((void *)&priv->hw_params, 0, - sizeof(struct iwl_hw_params)); + sizeof(struct il_hw_params)); priv->_3945.shared_virt = dma_alloc_coherent(&priv->pci_dev->dev, - sizeof(struct iwl3945_shared), + sizeof(struct il3945_shared), &priv->_3945.shared_phys, GFP_KERNEL); if (!priv->_3945.shared_virt) { - IWL_ERR(priv, "failed to allocate pci memory\n"); + IL_ERR(priv, "failed to allocate pci memory\n"); return -ENOMEM; } /* Assign number of Usable TX queues */ priv->hw_params.max_txq_num = priv->cfg->base_params->num_of_queues; - priv->hw_params.tfd_size = sizeof(struct iwl3945_tfd); - priv->hw_params.rx_page_order = get_order(IWL_RX_BUF_SIZE_3K); + priv->hw_params.tfd_size = sizeof(struct il3945_tfd); + priv->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_3K); priv->hw_params.max_rxq_size = RX_QUEUE_SIZE; priv->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; priv->hw_params.max_stations = IWL3945_STATION_COUNT; - priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWL3945_BROADCAST_ID; + priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IWL3945_BROADCAST_ID; priv->sta_key_max_num = STA_KEY_MAX_NUM; @@ -2413,20 +2413,20 @@ int iwl3945_hw_set_hw_params(struct iwl_priv *priv) return 0; } -unsigned int iwl3945_hw_get_beacon_cmd(struct iwl_priv *priv, - struct iwl3945_frame *frame, u8 rate) +unsigned int il3945_hw_get_beacon_cmd(struct il_priv *priv, + struct il3945_frame *frame, u8 rate) { - struct iwl3945_tx_beacon_cmd *tx_beacon_cmd; + struct il3945_tx_beacon_cmd *tx_beacon_cmd; unsigned int frame_size; - tx_beacon_cmd = (struct iwl3945_tx_beacon_cmd *)&frame->u; + tx_beacon_cmd = (struct il3945_tx_beacon_cmd *)&frame->u; memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); tx_beacon_cmd->tx.sta_id = - priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id; + priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id; tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; - frame_size = iwl3945_fill_beacon_frame(priv, + frame_size = il3945_fill_beacon_frame(priv, tx_beacon_cmd->frame, sizeof(frame->u) - sizeof(*tx_beacon_cmd)); @@ -2437,51 +2437,51 @@ unsigned int iwl3945_hw_get_beacon_cmd(struct iwl_priv *priv, tx_beacon_cmd->tx.tx_flags = (TX_CMD_FLG_SEQ_CTL_MSK | TX_CMD_FLG_TSF_MSK); - /* supp_rates[0] == OFDM start at IWL_FIRST_OFDM_RATE*/ + /* supp_rates[0] == OFDM start at IL_FIRST_OFDM_RATE*/ tx_beacon_cmd->tx.supp_rates[0] = - (IWL_OFDM_BASIC_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; + (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; tx_beacon_cmd->tx.supp_rates[1] = - (IWL_CCK_BASIC_RATES_MASK & 0xF); + (IL_CCK_BASIC_RATES_MASK & 0xF); - return sizeof(struct iwl3945_tx_beacon_cmd) + frame_size; + return sizeof(struct il3945_tx_beacon_cmd) + frame_size; } -void iwl3945_hw_rx_handler_setup(struct iwl_priv *priv) +void il3945_hw_rx_handler_setup(struct il_priv *priv) { - priv->rx_handlers[REPLY_TX] = iwl3945_rx_reply_tx; - priv->rx_handlers[REPLY_3945_RX] = iwl3945_rx_reply_rx; + priv->rx_handlers[REPLY_TX] = il3945_rx_reply_tx; + priv->rx_handlers[REPLY_3945_RX] = il3945_rx_reply_rx; } -void iwl3945_hw_setup_deferred_work(struct iwl_priv *priv) +void il3945_hw_setup_deferred_work(struct il_priv *priv) { INIT_DELAYED_WORK(&priv->_3945.thermal_periodic, - iwl3945_bg_reg_txpower_periodic); + il3945_bg_reg_txpower_periodic); } -void iwl3945_hw_cancel_deferred_work(struct iwl_priv *priv) +void il3945_hw_cancel_deferred_work(struct il_priv *priv) { cancel_delayed_work(&priv->_3945.thermal_periodic); } /* check contents of special bootstrap uCode SRAM */ -static int iwl3945_verify_bsm(struct iwl_priv *priv) +static int il3945_verify_bsm(struct il_priv *priv) { __le32 *image = priv->ucode_boot.v_addr; u32 len = priv->ucode_boot.len; u32 reg; u32 val; - IWL_DEBUG_INFO(priv, "Begin verify bsm\n"); + IL_DEBUG_INFO(priv, "Begin verify bsm\n"); /* verify BSM SRAM contents */ - val = iwl_legacy_read_prph(priv, BSM_WR_DWCOUNT_REG); + val = il_read_prph(priv, BSM_WR_DWCOUNT_REG); for (reg = BSM_SRAM_LOWER_BOUND; reg < BSM_SRAM_LOWER_BOUND + len; reg += sizeof(u32), image++) { - val = iwl_legacy_read_prph(priv, reg); + val = il_read_prph(priv, reg); if (val != le32_to_cpu(*image)) { - IWL_ERR(priv, "BSM uCode verification failed at " + IL_ERR(priv, "BSM uCode verification failed at " "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", BSM_SRAM_LOWER_BOUND, reg - BSM_SRAM_LOWER_BOUND, len, @@ -2490,7 +2490,7 @@ static int iwl3945_verify_bsm(struct iwl_priv *priv) } } - IWL_DEBUG_INFO(priv, "BSM bootstrap uCode image OK\n"); + IL_DEBUG_INFO(priv, "BSM bootstrap uCode image OK\n"); return 0; } @@ -2510,20 +2510,20 @@ static int iwl3945_verify_bsm(struct iwl_priv *priv) * simply claims ownership, which should be safe when this function is called * (i.e. before loading uCode!). */ -static int iwl3945_eeprom_acquire_semaphore(struct iwl_priv *priv) +static int il3945_eeprom_acquire_semaphore(struct il_priv *priv) { - _iwl_legacy_clear_bit(priv, CSR_EEPROM_GP, CSR_EEPROM_GP_IF_OWNER_MSK); + _il_clear_bit(priv, CSR_EEPROM_GP, CSR_EEPROM_GP_IF_OWNER_MSK); return 0; } -static void iwl3945_eeprom_release_semaphore(struct iwl_priv *priv) +static void il3945_eeprom_release_semaphore(struct il_priv *priv) { return; } /** - * iwl3945_load_bsm - Load bootstrap instructions + * il3945_load_bsm - Load bootstrap instructions * * BSM operation: * @@ -2554,7 +2554,7 @@ static void iwl3945_eeprom_release_semaphore(struct iwl_priv *priv) * the runtime uCode instructions and the backup data cache into SRAM, * and re-launches the runtime uCode from where it left off. */ -static int iwl3945_load_bsm(struct iwl_priv *priv) +static int il3945_load_bsm(struct il_priv *priv) { __le32 *image = priv->ucode_boot.v_addr; u32 len = priv->ucode_boot.len; @@ -2567,7 +2567,7 @@ static int iwl3945_load_bsm(struct iwl_priv *priv) u32 done; u32 reg_offset; - IWL_DEBUG_INFO(priv, "Begin load bsm\n"); + IL_DEBUG_INFO(priv, "Begin load bsm\n"); /* make sure bootstrap program is no larger than BSM's SRAM size */ if (len > IWL39_MAX_BSM_SIZE) @@ -2575,7 +2575,7 @@ static int iwl3945_load_bsm(struct iwl_priv *priv) /* Tell bootstrap uCode where to find the "Initialize" uCode * in host DRAM ... host DRAM physical address bits 31:0 for 3945. - * NOTE: iwl3945_initialize_alive_start() will replace these values, + * NOTE: il3945_initialize_alive_start() will replace these values, * after the "initialize" uCode has run, to point to * runtime/protocol instructions and backup data cache. */ pinst = priv->ucode_init.p_addr; @@ -2583,69 +2583,69 @@ static int iwl3945_load_bsm(struct iwl_priv *priv) inst_len = priv->ucode_init.len; data_len = priv->ucode_init_data.len; - iwl_legacy_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); - iwl_legacy_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); - iwl_legacy_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); - iwl_legacy_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); + il_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); + il_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); + il_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); + il_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); /* Fill BSM memory with bootstrap instructions */ for (reg_offset = BSM_SRAM_LOWER_BOUND; reg_offset < BSM_SRAM_LOWER_BOUND + len; reg_offset += sizeof(u32), image++) - _iwl_legacy_write_prph(priv, reg_offset, + _il_write_prph(priv, reg_offset, le32_to_cpu(*image)); - rc = iwl3945_verify_bsm(priv); + rc = il3945_verify_bsm(priv); if (rc) return rc; /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ - iwl_legacy_write_prph(priv, BSM_WR_MEM_SRC_REG, 0x0); - iwl_legacy_write_prph(priv, BSM_WR_MEM_DST_REG, + il_write_prph(priv, BSM_WR_MEM_SRC_REG, 0x0); + il_write_prph(priv, BSM_WR_MEM_DST_REG, IWL39_RTC_INST_LOWER_BOUND); - iwl_legacy_write_prph(priv, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); + il_write_prph(priv, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); /* Load bootstrap code into instruction SRAM now, * to prepare to load "initialize" uCode */ - iwl_legacy_write_prph(priv, BSM_WR_CTRL_REG, + il_write_prph(priv, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START); /* Wait for load of bootstrap uCode to finish */ for (i = 0; i < 100; i++) { - done = iwl_legacy_read_prph(priv, BSM_WR_CTRL_REG); + done = il_read_prph(priv, BSM_WR_CTRL_REG); if (!(done & BSM_WR_CTRL_REG_BIT_START)) break; udelay(10); } if (i < 100) - IWL_DEBUG_INFO(priv, "BSM write complete, poll %d iterations\n", i); + IL_DEBUG_INFO(priv, "BSM write complete, poll %d iterations\n", i); else { - IWL_ERR(priv, "BSM write did not complete!\n"); + IL_ERR(priv, "BSM write did not complete!\n"); return -EIO; } /* Enable future boot loads whenever power management unit triggers it * (e.g. when powering back up after power-save shutdown) */ - iwl_legacy_write_prph(priv, BSM_WR_CTRL_REG, + il_write_prph(priv, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN); return 0; } -static struct iwl_hcmd_ops iwl3945_hcmd = { - .rxon_assoc = iwl3945_send_rxon_assoc, - .commit_rxon = iwl3945_commit_rxon, +static struct il_hcmd_ops il3945_hcmd = { + .rxon_assoc = il3945_send_rxon_assoc, + .commit_rxon = il3945_commit_rxon, }; -static struct iwl_lib_ops iwl3945_lib = { - .txq_attach_buf_to_tfd = iwl3945_hw_txq_attach_buf_to_tfd, - .txq_free_tfd = iwl3945_hw_txq_free_tfd, - .txq_init = iwl3945_hw_tx_queue_init, - .load_ucode = iwl3945_load_bsm, - .dump_nic_error_log = iwl3945_dump_nic_error_log, +static struct il_lib_ops il3945_lib = { + .txq_attach_buf_to_tfd = il3945_hw_txq_attach_buf_to_tfd, + .txq_free_tfd = il3945_hw_txq_free_tfd, + .txq_init = il3945_hw_tx_queue_init, + .load_ucode = il3945_load_bsm, + .dump_nic_error_log = il3945_dump_nic_error_log, .apm_ops = { - .init = iwl3945_apm_init, - .config = iwl3945_nic_config, + .init = il3945_apm_init, + .config = il3945_nic_config, }, .eeprom_ops = { .regulatory_bands = { @@ -2657,85 +2657,85 @@ static struct iwl_lib_ops iwl3945_lib = { EEPROM_REGULATORY_BAND_NO_HT40, EEPROM_REGULATORY_BAND_NO_HT40, }, - .acquire_semaphore = iwl3945_eeprom_acquire_semaphore, - .release_semaphore = iwl3945_eeprom_release_semaphore, + .acquire_semaphore = il3945_eeprom_acquire_semaphore, + .release_semaphore = il3945_eeprom_release_semaphore, }, - .send_tx_power = iwl3945_send_tx_power, - .is_valid_rtc_data_addr = iwl3945_hw_valid_rtc_data_addr, + .send_tx_power = il3945_send_tx_power, + .is_valid_rtc_data_addr = il3945_hw_valid_rtc_data_addr, .debugfs_ops = { - .rx_stats_read = iwl3945_ucode_rx_stats_read, - .tx_stats_read = iwl3945_ucode_tx_stats_read, - .general_stats_read = iwl3945_ucode_general_stats_read, + .rx_stats_read = il3945_ucode_rx_stats_read, + .tx_stats_read = il3945_ucode_tx_stats_read, + .general_stats_read = il3945_ucode_general_stats_read, }, }; -static const struct iwl_legacy_ops iwl3945_legacy_ops = { - .post_associate = iwl3945_post_associate, - .config_ap = iwl3945_config_ap, - .manage_ibss_station = iwl3945_manage_ibss_station, +static const struct il_legacy_ops il3945_legacy_ops = { + .post_associate = il3945_post_associate, + .config_ap = il3945_config_ap, + .manage_ibss_station = il3945_manage_ibss_station, }; -static struct iwl_hcmd_utils_ops iwl3945_hcmd_utils = { - .get_hcmd_size = iwl3945_get_hcmd_size, - .build_addsta_hcmd = iwl3945_build_addsta_hcmd, - .request_scan = iwl3945_request_scan, - .post_scan = iwl3945_post_scan, +static struct il_hcmd_utils_ops il3945_hcmd_utils = { + .get_hcmd_size = il3945_get_hcmd_size, + .build_addsta_hcmd = il3945_build_addsta_hcmd, + .request_scan = il3945_request_scan, + .post_scan = il3945_post_scan, }; -static const struct iwl_ops iwl3945_ops = { - .lib = &iwl3945_lib, - .hcmd = &iwl3945_hcmd, - .utils = &iwl3945_hcmd_utils, - .led = &iwl3945_led_ops, - .legacy = &iwl3945_legacy_ops, - .ieee80211_ops = &iwl3945_hw_ops, +static const struct il_ops il3945_ops = { + .lib = &il3945_lib, + .hcmd = &il3945_hcmd, + .utils = &il3945_hcmd_utils, + .led = &il3945_led_ops, + .legacy = &il3945_legacy_ops, + .ieee80211_ops = &il3945_hw_ops, }; -static struct iwl_base_params iwl3945_base_params = { +static struct il_base_params il3945_base_params = { .eeprom_size = IWL3945_EEPROM_IMG_SIZE, .num_of_queues = IWL39_NUM_QUEUES, .pll_cfg_val = CSR39_ANA_PLL_CFG_VAL, .set_l0s = false, .use_bsm = true, .led_compensation = 64, - .wd_timeout = IWL_DEF_WD_TIMEOUT, + .wd_timeout = IL_DEF_WD_TIMEOUT, }; -static struct iwl_cfg iwl3945_bg_cfg = { +static struct il_cfg il3945_bg_cfg = { .name = "3945BG", .fw_name_pre = IWL3945_FW_PRE, .ucode_api_max = IWL3945_UCODE_API_MAX, .ucode_api_min = IWL3945_UCODE_API_MIN, - .sku = IWL_SKU_G, + .sku = IL_SKU_G, .eeprom_ver = EEPROM_3945_EEPROM_VERSION, - .ops = &iwl3945_ops, - .mod_params = &iwl3945_mod_params, - .base_params = &iwl3945_base_params, - .led_mode = IWL_LED_BLINK, + .ops = &il3945_ops, + .mod_params = &il3945_mod_params, + .base_params = &il3945_base_params, + .led_mode = IL_LED_BLINK, }; -static struct iwl_cfg iwl3945_abg_cfg = { +static struct il_cfg il3945_abg_cfg = { .name = "3945ABG", .fw_name_pre = IWL3945_FW_PRE, .ucode_api_max = IWL3945_UCODE_API_MAX, .ucode_api_min = IWL3945_UCODE_API_MIN, - .sku = IWL_SKU_A|IWL_SKU_G, + .sku = IL_SKU_A|IL_SKU_G, .eeprom_ver = EEPROM_3945_EEPROM_VERSION, - .ops = &iwl3945_ops, - .mod_params = &iwl3945_mod_params, - .base_params = &iwl3945_base_params, - .led_mode = IWL_LED_BLINK, + .ops = &il3945_ops, + .mod_params = &il3945_mod_params, + .base_params = &il3945_base_params, + .led_mode = IL_LED_BLINK, }; -DEFINE_PCI_DEVICE_TABLE(iwl3945_hw_card_ids) = { - {IWL_PCI_DEVICE(0x4222, 0x1005, iwl3945_bg_cfg)}, - {IWL_PCI_DEVICE(0x4222, 0x1034, iwl3945_bg_cfg)}, - {IWL_PCI_DEVICE(0x4222, 0x1044, iwl3945_bg_cfg)}, - {IWL_PCI_DEVICE(0x4227, 0x1014, iwl3945_bg_cfg)}, - {IWL_PCI_DEVICE(0x4222, PCI_ANY_ID, iwl3945_abg_cfg)}, - {IWL_PCI_DEVICE(0x4227, PCI_ANY_ID, iwl3945_abg_cfg)}, +DEFINE_PCI_DEVICE_TABLE(il3945_hw_card_ids) = { + {IL_PCI_DEVICE(0x4222, 0x1005, il3945_bg_cfg)}, + {IL_PCI_DEVICE(0x4222, 0x1034, il3945_bg_cfg)}, + {IL_PCI_DEVICE(0x4222, 0x1044, il3945_bg_cfg)}, + {IL_PCI_DEVICE(0x4227, 0x1014, il3945_bg_cfg)}, + {IL_PCI_DEVICE(0x4222, PCI_ANY_ID, il3945_abg_cfg)}, + {IL_PCI_DEVICE(0x4227, PCI_ANY_ID, il3945_abg_cfg)}, {0} }; -MODULE_DEVICE_TABLE(pci, iwl3945_hw_card_ids); +MODULE_DEVICE_TABLE(pci, il3945_hw_card_ids); diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.h b/drivers/net/wireless/iwlegacy/iwl-3945.h index b118b59b71de..167eedcfeb63 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945.h @@ -29,15 +29,15 @@ * Please use iwl-3945-hw.h for hardware-related definitions. */ -#ifndef __iwl_3945_h__ -#define __iwl_3945_h__ +#ifndef __il_3945_h__ +#define __il_3945_h__ #include /* for struct pci_device_id */ #include #include /* Hardware specific file defines the PCI IDs table for that hardware module */ -extern const struct pci_device_id iwl3945_hw_card_ids[]; +extern const struct pci_device_id il3945_hw_card_ids[]; #include "iwl-csr.h" #include "iwl-prph.h" @@ -69,12 +69,12 @@ extern const struct pci_device_id iwl3945_hw_card_ids[]; * noise info (e.g. averaging might be done in app); measured dBm values are * always negative ... using a negative value as the default keeps all * averages within an s8's (used in some apps) range of negative values. */ -#define IWL_NOISE_MEAS_NOT_AVAILABLE (-127) +#define IL_NOISE_MEAS_NOT_AVAILABLE (-127) /* Module parameters accessible from iwl-*.c */ -extern struct iwl_mod_params iwl3945_mod_params; +extern struct il_mod_params il3945_mod_params; -struct iwl3945_rate_scale_data { +struct il3945_rate_scale_data { u64 data; s32 success_counter; s32 success_ratio; @@ -83,9 +83,9 @@ struct iwl3945_rate_scale_data { unsigned long stamp; }; -struct iwl3945_rs_sta { +struct il3945_rs_sta { spinlock_t lock; - struct iwl_priv *priv; + struct il_priv *priv; s32 *expected_tpt; unsigned long last_partial_flush; unsigned long last_flush; @@ -96,7 +96,7 @@ struct iwl3945_rs_sta { u8 flush_pending; u8 start_rate; struct timer_list rate_scale_flush; - struct iwl3945_rate_scale_data win[IWL_RATE_COUNT_3945]; + struct il3945_rate_scale_data win[IL_RATE_COUNT_3945]; #ifdef CONFIG_MAC80211_DEBUGFS struct dentry *rs_sta_dbgfs_stats_table_file; #endif @@ -110,15 +110,15 @@ struct iwl3945_rs_sta { * The common struct MUST be first because it is shared between * 3945 and 4965! */ -struct iwl3945_sta_priv { - struct iwl_station_priv_common common; - struct iwl3945_rs_sta rs_sta; +struct il3945_sta_priv { + struct il_station_priv_common common; + struct il3945_rs_sta rs_sta; }; -enum iwl3945_antenna { - IWL_ANTENNA_DIVERSITY, - IWL_ANTENNA_MAIN, - IWL_ANTENNA_AUX +enum il3945_antenna { + IL_ANTENNA_DIVERSITY, + IL_ANTENNA_MAIN, + IL_ANTENNA_AUX }; /* @@ -138,23 +138,23 @@ enum iwl3945_antenna { #define DEFAULT_SHORT_RETRY_LIMIT 7U #define DEFAULT_LONG_RETRY_LIMIT 4U -#define IWL_TX_FIFO_AC0 0 -#define IWL_TX_FIFO_AC1 1 -#define IWL_TX_FIFO_AC2 2 -#define IWL_TX_FIFO_AC3 3 -#define IWL_TX_FIFO_HCCA_1 5 -#define IWL_TX_FIFO_HCCA_2 6 -#define IWL_TX_FIFO_NONE 7 +#define IL_TX_FIFO_AC0 0 +#define IL_TX_FIFO_AC1 1 +#define IL_TX_FIFO_AC2 2 +#define IL_TX_FIFO_AC3 3 +#define IL_TX_FIFO_HCCA_1 5 +#define IL_TX_FIFO_HCCA_2 6 +#define IL_TX_FIFO_NONE 7 #define IEEE80211_DATA_LEN 2304 #define IEEE80211_4ADDR_LEN 30 #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN) #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) -struct iwl3945_frame { +struct il3945_frame { union { struct ieee80211_hdr frame; - struct iwl3945_tx_beacon_cmd beacon; + struct il3945_tx_beacon_cmd beacon; u8 raw[IEEE80211_FRAME_LEN]; u8 cmd[360]; } u; @@ -169,19 +169,19 @@ struct iwl3945_frame { #define SUP_RATE_11B_MAX_NUM_CHANNELS 4 #define SUP_RATE_11G_MAX_NUM_CHANNELS 12 -#define IWL_SUPPORTED_RATES_IE_LEN 8 +#define IL_SUPPORTED_RATES_IE_LEN 8 #define SCAN_INTERVAL 100 #define MAX_TID_COUNT 9 -#define IWL_INVALID_RATE 0xFF -#define IWL_INVALID_VALUE -1 +#define IL_INVALID_RATE 0xFF +#define IL_INVALID_VALUE -1 #define STA_PS_STATUS_WAKE 0 #define STA_PS_STATUS_SLEEP 1 -struct iwl3945_ibss_seq { +struct il3945_ibss_seq { u8 mac[ETH_ALEN]; u16 seq_num; u16 frag_num; @@ -189,14 +189,14 @@ struct iwl3945_ibss_seq { struct list_head list; }; -#define IWL_RX_HDR(x) ((struct iwl3945_rx_frame_hdr *)(\ +#define IL_RX_HDR(x) ((struct il3945_rx_frame_hdr *)(\ x->u.rx_frame.stats.payload + \ x->u.rx_frame.stats.phy_count)) -#define IWL_RX_END(x) ((struct iwl3945_rx_frame_end *)(\ - IWL_RX_HDR(x)->payload + \ - le16_to_cpu(IWL_RX_HDR(x)->len))) -#define IWL_RX_STATS(x) (&x->u.rx_frame.stats) -#define IWL_RX_DATA(x) (IWL_RX_HDR(x)->payload) +#define IL_RX_END(x) ((struct il3945_rx_frame_end *)(\ + IL_RX_HDR(x)->payload + \ + le16_to_cpu(IL_RX_HDR(x)->len))) +#define IL_RX_STATS(x) (&x->u.rx_frame.stats) +#define IL_RX_DATA(x) (IL_RX_HDR(x)->payload) /****************************************************************************** @@ -205,14 +205,14 @@ struct iwl3945_ibss_seq { * for use by iwl-*.c * *****************************************************************************/ -extern int iwl3945_calc_db_from_ratio(int sig_ratio); -extern void iwl3945_rx_replenish(void *data); -extern void iwl3945_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq); -extern unsigned int iwl3945_fill_beacon_frame(struct iwl_priv *priv, +extern int il3945_calc_db_from_ratio(int sig_ratio); +extern void il3945_rx_replenish(void *data); +extern void il3945_rx_queue_reset(struct il_priv *priv, struct il_rx_queue *rxq); +extern unsigned int il3945_fill_beacon_frame(struct il_priv *priv, struct ieee80211_hdr *hdr, int left); -extern int iwl3945_dump_nic_event_log(struct iwl_priv *priv, bool full_log, +extern int il3945_dump_nic_event_log(struct il_priv *priv, bool full_log, char **buf, bool display); -extern void iwl3945_dump_nic_error_log(struct iwl_priv *priv); +extern void il3945_dump_nic_error_log(struct il_priv *priv); /****************************************************************************** * @@ -223,86 +223,86 @@ extern void iwl3945_dump_nic_error_log(struct iwl_priv *priv); * which is why they are in the hardware specific files (vs. iwl-base.c) * * Naming convention -- - * iwl3945_ <-- Its part of iwlwifi (should be changed to iwl3945_) - * iwl3945_hw_ <-- Hardware specific (implemented in iwl-XXXX.c by all HW) + * il3945_ <-- Its part of iwlwifi (should be changed to il3945_) + * il3945_hw_ <-- Hardware specific (implemented in iwl-XXXX.c by all HW) * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX) - * iwl3945_bg_ <-- Called from work queue context - * iwl3945_mac_ <-- mac80211 callback + * il3945_bg_ <-- Called from work queue context + * il3945_mac_ <-- mac80211 callback * ****************************************************************************/ -extern void iwl3945_hw_rx_handler_setup(struct iwl_priv *priv); -extern void iwl3945_hw_setup_deferred_work(struct iwl_priv *priv); -extern void iwl3945_hw_cancel_deferred_work(struct iwl_priv *priv); -extern int iwl3945_hw_rxq_stop(struct iwl_priv *priv); -extern int iwl3945_hw_set_hw_params(struct iwl_priv *priv); -extern int iwl3945_hw_nic_init(struct iwl_priv *priv); -extern int iwl3945_hw_nic_stop_master(struct iwl_priv *priv); -extern void iwl3945_hw_txq_ctx_free(struct iwl_priv *priv); -extern void iwl3945_hw_txq_ctx_stop(struct iwl_priv *priv); -extern int iwl3945_hw_nic_reset(struct iwl_priv *priv); -extern int iwl3945_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, - struct iwl_tx_queue *txq, +extern void il3945_hw_rx_handler_setup(struct il_priv *priv); +extern void il3945_hw_setup_deferred_work(struct il_priv *priv); +extern void il3945_hw_cancel_deferred_work(struct il_priv *priv); +extern int il3945_hw_rxq_stop(struct il_priv *priv); +extern int il3945_hw_set_hw_params(struct il_priv *priv); +extern int il3945_hw_nic_init(struct il_priv *priv); +extern int il3945_hw_nic_stop_master(struct il_priv *priv); +extern void il3945_hw_txq_ctx_free(struct il_priv *priv); +extern void il3945_hw_txq_ctx_stop(struct il_priv *priv); +extern int il3945_hw_nic_reset(struct il_priv *priv); +extern int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *priv, + struct il_tx_queue *txq, dma_addr_t addr, u16 len, u8 reset, u8 pad); -extern void iwl3945_hw_txq_free_tfd(struct iwl_priv *priv, - struct iwl_tx_queue *txq); -extern int iwl3945_hw_get_temperature(struct iwl_priv *priv); -extern int iwl3945_hw_tx_queue_init(struct iwl_priv *priv, - struct iwl_tx_queue *txq); -extern unsigned int iwl3945_hw_get_beacon_cmd(struct iwl_priv *priv, - struct iwl3945_frame *frame, u8 rate); -void iwl3945_hw_build_tx_cmd_rate(struct iwl_priv *priv, - struct iwl_device_cmd *cmd, +extern void il3945_hw_txq_free_tfd(struct il_priv *priv, + struct il_tx_queue *txq); +extern int il3945_hw_get_temperature(struct il_priv *priv); +extern int il3945_hw_tx_queue_init(struct il_priv *priv, + struct il_tx_queue *txq); +extern unsigned int il3945_hw_get_beacon_cmd(struct il_priv *priv, + struct il3945_frame *frame, u8 rate); +void il3945_hw_build_tx_cmd_rate(struct il_priv *priv, + struct il_device_cmd *cmd, struct ieee80211_tx_info *info, struct ieee80211_hdr *hdr, int sta_id, int tx_id); -extern int iwl3945_hw_reg_send_txpower(struct iwl_priv *priv); -extern int iwl3945_hw_reg_set_txpower(struct iwl_priv *priv, s8 power); -extern void iwl3945_hw_rx_statistics(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); -void iwl3945_reply_statistics(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); -extern void iwl3945_disable_events(struct iwl_priv *priv); -extern int iwl4965_get_temperature(const struct iwl_priv *priv); -extern void iwl3945_post_associate(struct iwl_priv *priv); -extern void iwl3945_config_ap(struct iwl_priv *priv); - -extern int iwl3945_commit_rxon(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); +extern int il3945_hw_reg_send_txpower(struct il_priv *priv); +extern int il3945_hw_reg_set_txpower(struct il_priv *priv, s8 power); +extern void il3945_hw_rx_statistics(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); +void il3945_reply_statistics(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); +extern void il3945_disable_events(struct il_priv *priv); +extern int il4965_get_temperature(const struct il_priv *priv); +extern void il3945_post_associate(struct il_priv *priv); +extern void il3945_config_ap(struct il_priv *priv); + +extern int il3945_commit_rxon(struct il_priv *priv, + struct il_rxon_context *ctx); /** - * iwl3945_hw_find_station - Find station id for a given BSSID + * il3945_hw_find_station - Find station id for a given BSSID * @bssid: MAC address of station ID to find * * NOTE: This should not be hardware specific but the code has * not yet been merged into a single common layer for managing the * station tables. */ -extern u8 iwl3945_hw_find_station(struct iwl_priv *priv, const u8 *bssid); +extern u8 il3945_hw_find_station(struct il_priv *priv, const u8 *bssid); -extern struct ieee80211_ops iwl3945_hw_ops; +extern struct ieee80211_ops il3945_hw_ops; /* * Forward declare iwl-3945.c functions for iwl3945-base.c */ -extern __le32 iwl3945_get_antenna_flags(const struct iwl_priv *priv); -extern int iwl3945_init_hw_rate_table(struct iwl_priv *priv); -extern void iwl3945_reg_txpower_periodic(struct iwl_priv *priv); -extern int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv); +extern __le32 il3945_get_antenna_flags(const struct il_priv *priv); +extern int il3945_init_hw_rate_table(struct il_priv *priv); +extern void il3945_reg_txpower_periodic(struct il_priv *priv); +extern int il3945_txpower_set_from_eeprom(struct il_priv *priv); -extern const struct iwl_channel_info *iwl3945_get_channel_info( - const struct iwl_priv *priv, enum ieee80211_band band, u16 channel); +extern const struct il_channel_info *il3945_get_channel_info( + const struct il_priv *priv, enum ieee80211_band band, u16 channel); -extern int iwl3945_rs_next_rate(struct iwl_priv *priv, int rate); +extern int il3945_rs_next_rate(struct il_priv *priv, int rate); /* scanning */ -int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif); -void iwl3945_post_scan(struct iwl_priv *priv); +int il3945_request_scan(struct il_priv *priv, struct ieee80211_vif *vif); +void il3945_post_scan(struct il_priv *priv); /* rates */ -extern const struct iwl3945_rate_info iwl3945_rates[IWL_RATE_COUNT_3945]; +extern const struct il3945_rate_info il3945_rates[IL_RATE_COUNT_3945]; -/* Requires full declaration of iwl_priv before including */ +/* Requires full declaration of il_priv before including */ #include "iwl-io.h" #endif diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c index 162d877e6869..115eeb3d7c39 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c @@ -80,11 +80,11 @@ struct statistics_general_data { u32 beacon_energy_c; }; -void iwl4965_calib_free_results(struct iwl_priv *priv) +void il4965_calib_free_results(struct il_priv *priv) { int i; - for (i = 0; i < IWL_CALIB_MAX; i++) { + for (i = 0; i < IL_CALIB_MAX; i++) { kfree(priv->calib_results[i].buf); priv->calib_results[i].buf = NULL; priv->calib_results[i].buf_len = 0; @@ -103,7 +103,7 @@ void iwl4965_calib_free_results(struct iwl_priv *priv) * enough to receive all of our own network traffic, but not so * high that our DSP gets too busy trying to lock onto non-network * activity/noise. */ -static int iwl4965_sens_energy_cck(struct iwl_priv *priv, +static int il4965_sens_energy_cck(struct il_priv *priv, u32 norm_fa, u32 rx_enable_time, struct statistics_general_data *rx_info) @@ -129,8 +129,8 @@ static int iwl4965_sens_energy_cck(struct iwl_priv *priv, u32 false_alarms = norm_fa * 200 * 1024; u32 max_false_alarms = MAX_FA_CCK * rx_enable_time; u32 min_false_alarms = MIN_FA_CCK * rx_enable_time; - struct iwl_sensitivity_data *data = NULL; - const struct iwl_sensitivity_ranges *ranges = priv->hw_params.sens; + struct il_sensitivity_data *data = NULL; + const struct il_sensitivity_ranges *ranges = priv->hw_params.sens; data = &(priv->sensitivity_data); @@ -160,7 +160,7 @@ static int iwl4965_sens_energy_cck(struct iwl_priv *priv, val = data->nrg_silence_rssi[i]; silence_ref = max(silence_ref, val); } - IWL_DEBUG_CALIB(priv, "silence a %u, b %u, c %u, 20-bcn max %u\n", + IL_DEBUG_CALIB(priv, "silence a %u, b %u, c %u, 20-bcn max %u\n", silence_rssi_a, silence_rssi_b, silence_rssi_c, silence_ref); @@ -184,7 +184,7 @@ static int iwl4965_sens_energy_cck(struct iwl_priv *priv, max_nrg_cck = (u32) max(max_nrg_cck, (data->nrg_value[i])); max_nrg_cck += 6; - IWL_DEBUG_CALIB(priv, "rx energy a %u, b %u, c %u, 10-bcn max/min %u\n", + IL_DEBUG_CALIB(priv, "rx energy a %u, b %u, c %u, 10-bcn max/min %u\n", rx_info->beacon_energy_a, rx_info->beacon_energy_b, rx_info->beacon_energy_c, max_nrg_cck - 6); @@ -194,16 +194,16 @@ static int iwl4965_sens_energy_cck(struct iwl_priv *priv, data->num_in_cck_no_fa++; else data->num_in_cck_no_fa = 0; - IWL_DEBUG_CALIB(priv, "consecutive bcns with few false alarms = %u\n", + IL_DEBUG_CALIB(priv, "consecutive bcns with few false alarms = %u\n", data->num_in_cck_no_fa); /* If we got too many false alarms this time, reduce sensitivity */ if ((false_alarms > max_false_alarms) && (data->auto_corr_cck > AUTO_CORR_MAX_TH_CCK)) { - IWL_DEBUG_CALIB(priv, "norm FA %u > max FA %u\n", + IL_DEBUG_CALIB(priv, "norm FA %u > max FA %u\n", false_alarms, max_false_alarms); - IWL_DEBUG_CALIB(priv, "... reducing sensitivity\n"); - data->nrg_curr_state = IWL_FA_TOO_MANY; + IL_DEBUG_CALIB(priv, "... reducing sensitivity\n"); + data->nrg_curr_state = IL_FA_TOO_MANY; /* Store for "fewer than desired" on later beacon */ data->nrg_silence_ref = silence_ref; @@ -212,14 +212,14 @@ static int iwl4965_sens_energy_cck(struct iwl_priv *priv, data->nrg_th_cck = data->nrg_th_cck - NRG_STEP_CCK; /* Else if we got fewer than desired, increase sensitivity */ } else if (false_alarms < min_false_alarms) { - data->nrg_curr_state = IWL_FA_TOO_FEW; + data->nrg_curr_state = IL_FA_TOO_FEW; /* Compare silence level with silence level for most recent * healthy number or too many false alarms */ data->nrg_auto_corr_silence_diff = (s32)data->nrg_silence_ref - (s32)silence_ref; - IWL_DEBUG_CALIB(priv, + IL_DEBUG_CALIB(priv, "norm FA %u < min FA %u, silence diff %d\n", false_alarms, min_false_alarms, data->nrg_auto_corr_silence_diff); @@ -230,23 +230,23 @@ static int iwl4965_sens_energy_cck(struct iwl_priv *priv, * from a previous beacon with too many, or healthy # FAs * OR 2) We've seen a lot of beacons (100) with too few * false alarms */ - if ((data->nrg_prev_state != IWL_FA_TOO_MANY) && + if ((data->nrg_prev_state != IL_FA_TOO_MANY) && ((data->nrg_auto_corr_silence_diff > NRG_DIFF) || (data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA))) { - IWL_DEBUG_CALIB(priv, "... increasing sensitivity\n"); + IL_DEBUG_CALIB(priv, "... increasing sensitivity\n"); /* Increase nrg value to increase sensitivity */ val = data->nrg_th_cck + NRG_STEP_CCK; data->nrg_th_cck = min((u32)ranges->min_nrg_cck, val); } else { - IWL_DEBUG_CALIB(priv, + IL_DEBUG_CALIB(priv, "... but not changing sensitivity\n"); } /* Else we got a healthy number of false alarms, keep status quo */ } else { - IWL_DEBUG_CALIB(priv, " FA in safe zone\n"); - data->nrg_curr_state = IWL_FA_GOOD_RANGE; + IL_DEBUG_CALIB(priv, " FA in safe zone\n"); + data->nrg_curr_state = IL_FA_GOOD_RANGE; /* Store for use in "fewer than desired" with later beacon */ data->nrg_silence_ref = silence_ref; @@ -254,8 +254,8 @@ static int iwl4965_sens_energy_cck(struct iwl_priv *priv, /* If previous beacon had too many false alarms, * give it some extra margin by reducing sensitivity again * (but don't go below measured energy of desired Rx) */ - if (IWL_FA_TOO_MANY == data->nrg_prev_state) { - IWL_DEBUG_CALIB(priv, "... increasing margin\n"); + if (IL_FA_TOO_MANY == data->nrg_prev_state) { + IL_DEBUG_CALIB(priv, "... increasing margin\n"); if (data->nrg_th_cck > (max_nrg_cck + NRG_MARGIN)) data->nrg_th_cck -= NRG_MARGIN; else @@ -269,7 +269,7 @@ static int iwl4965_sens_energy_cck(struct iwl_priv *priv, * Lower value is higher energy, so we use max()! */ data->nrg_th_cck = max(max_nrg_cck, data->nrg_th_cck); - IWL_DEBUG_CALIB(priv, "new nrg_th_cck %u\n", data->nrg_th_cck); + IL_DEBUG_CALIB(priv, "new nrg_th_cck %u\n", data->nrg_th_cck); data->nrg_prev_state = data->nrg_curr_state; @@ -306,7 +306,7 @@ static int iwl4965_sens_energy_cck(struct iwl_priv *priv, } -static int iwl4965_sens_auto_corr_ofdm(struct iwl_priv *priv, +static int il4965_sens_auto_corr_ofdm(struct il_priv *priv, u32 norm_fa, u32 rx_enable_time) { @@ -314,15 +314,15 @@ static int iwl4965_sens_auto_corr_ofdm(struct iwl_priv *priv, u32 false_alarms = norm_fa * 200 * 1024; u32 max_false_alarms = MAX_FA_OFDM * rx_enable_time; u32 min_false_alarms = MIN_FA_OFDM * rx_enable_time; - struct iwl_sensitivity_data *data = NULL; - const struct iwl_sensitivity_ranges *ranges = priv->hw_params.sens; + struct il_sensitivity_data *data = NULL; + const struct il_sensitivity_ranges *ranges = priv->hw_params.sens; data = &(priv->sensitivity_data); /* If we got too many false alarms this time, reduce sensitivity */ if (false_alarms > max_false_alarms) { - IWL_DEBUG_CALIB(priv, "norm FA %u > max FA %u)\n", + IL_DEBUG_CALIB(priv, "norm FA %u > max FA %u)\n", false_alarms, max_false_alarms); val = data->auto_corr_ofdm + AUTO_CORR_STEP_OFDM; @@ -345,7 +345,7 @@ static int iwl4965_sens_auto_corr_ofdm(struct iwl_priv *priv, /* Else if we got fewer than desired, increase sensitivity */ else if (false_alarms < min_false_alarms) { - IWL_DEBUG_CALIB(priv, "norm FA %u < min FA %u\n", + IL_DEBUG_CALIB(priv, "norm FA %u < min FA %u\n", false_alarms, min_false_alarms); val = data->auto_corr_ofdm - AUTO_CORR_STEP_OFDM; @@ -364,14 +364,14 @@ static int iwl4965_sens_auto_corr_ofdm(struct iwl_priv *priv, data->auto_corr_ofdm_mrc_x1 = max((u32)ranges->auto_corr_min_ofdm_mrc_x1, val); } else { - IWL_DEBUG_CALIB(priv, "min FA %u < norm FA %u < max FA %u OK\n", + IL_DEBUG_CALIB(priv, "min FA %u < norm FA %u < max FA %u OK\n", min_false_alarms, false_alarms, max_false_alarms); } return 0; } -static void iwl4965_prepare_legacy_sensitivity_tbl(struct iwl_priv *priv, - struct iwl_sensitivity_data *data, +static void il4965_prepare_legacy_sensitivity_tbl(struct il_priv *priv, + struct il_sensitivity_data *data, __le16 *tbl) { tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX] = @@ -400,24 +400,24 @@ static void iwl4965_prepare_legacy_sensitivity_tbl(struct iwl_priv *priv, tbl[HD_OFDM_ENERGY_TH_IN_INDEX] = cpu_to_le16(data->nrg_th_cca); - IWL_DEBUG_CALIB(priv, "ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n", + IL_DEBUG_CALIB(priv, "ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n", data->auto_corr_ofdm, data->auto_corr_ofdm_mrc, data->auto_corr_ofdm_x1, data->auto_corr_ofdm_mrc_x1, data->nrg_th_ofdm); - IWL_DEBUG_CALIB(priv, "cck: ac %u mrc %u thresh %u\n", + IL_DEBUG_CALIB(priv, "cck: ac %u mrc %u thresh %u\n", data->auto_corr_cck, data->auto_corr_cck_mrc, data->nrg_th_cck); } /* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */ -static int iwl4965_sensitivity_write(struct iwl_priv *priv) +static int il4965_sensitivity_write(struct il_priv *priv) { - struct iwl_sensitivity_cmd cmd; - struct iwl_sensitivity_data *data = NULL; - struct iwl_host_cmd cmd_out = { + struct il_sensitivity_cmd cmd; + struct il_sensitivity_data *data = NULL; + struct il_host_cmd cmd_out = { .id = SENSITIVITY_CMD, - .len = sizeof(struct iwl_sensitivity_cmd), + .len = sizeof(struct il_sensitivity_cmd), .flags = CMD_ASYNC, .data = &cmd, }; @@ -426,7 +426,7 @@ static int iwl4965_sensitivity_write(struct iwl_priv *priv) memset(&cmd, 0, sizeof(cmd)); - iwl4965_prepare_legacy_sensitivity_tbl(priv, data, &cmd.table[0]); + il4965_prepare_legacy_sensitivity_tbl(priv, data, &cmd.table[0]); /* Update uCode's "work" table, and copy it to DSP */ cmd.control = SENSITIVITY_CMD_CONTROL_WORK_TABLE; @@ -434,7 +434,7 @@ static int iwl4965_sensitivity_write(struct iwl_priv *priv) /* Don't send command to uCode if nothing has changed */ if (!memcmp(&cmd.table[0], &(priv->sensitivity_tbl[0]), sizeof(u16)*HD_TABLE_SIZE)) { - IWL_DEBUG_CALIB(priv, "No change in SENSITIVITY_CMD\n"); + IL_DEBUG_CALIB(priv, "No change in SENSITIVITY_CMD\n"); return 0; } @@ -442,20 +442,20 @@ static int iwl4965_sensitivity_write(struct iwl_priv *priv) memcpy(&(priv->sensitivity_tbl[0]), &(cmd.table[0]), sizeof(u16)*HD_TABLE_SIZE); - return iwl_legacy_send_cmd(priv, &cmd_out); + return il_send_cmd(priv, &cmd_out); } -void iwl4965_init_sensitivity(struct iwl_priv *priv) +void il4965_init_sensitivity(struct il_priv *priv) { int ret = 0; int i; - struct iwl_sensitivity_data *data = NULL; - const struct iwl_sensitivity_ranges *ranges = priv->hw_params.sens; + struct il_sensitivity_data *data = NULL; + const struct il_sensitivity_ranges *ranges = priv->hw_params.sens; if (priv->disable_sens_cal) return; - IWL_DEBUG_CALIB(priv, "Start iwl4965_init_sensitivity\n"); + IL_DEBUG_CALIB(priv, "Start il4965_init_sensitivity\n"); /* Clear driver's sensitivity algo data */ data = &(priv->sensitivity_data); @@ -463,11 +463,11 @@ void iwl4965_init_sensitivity(struct iwl_priv *priv) if (ranges == NULL) return; - memset(data, 0, sizeof(struct iwl_sensitivity_data)); + memset(data, 0, sizeof(struct il_sensitivity_data)); data->num_in_cck_no_fa = 0; - data->nrg_curr_state = IWL_FA_TOO_MANY; - data->nrg_prev_state = IWL_FA_TOO_MANY; + data->nrg_curr_state = IL_FA_TOO_MANY; + data->nrg_prev_state = IL_FA_TOO_MANY; data->nrg_silence_ref = 0; data->nrg_silence_idx = 0; data->nrg_energy_idx = 0; @@ -495,11 +495,11 @@ void iwl4965_init_sensitivity(struct iwl_priv *priv) data->last_bad_plcp_cnt_cck = 0; data->last_fa_cnt_cck = 0; - ret |= iwl4965_sensitivity_write(priv); - IWL_DEBUG_CALIB(priv, "<sensitivity_data); - if (!iwl_legacy_is_any_associated(priv)) { - IWL_DEBUG_CALIB(priv, "<< - not associated\n"); + if (!il_is_any_associated(priv)) { + IL_DEBUG_CALIB(priv, "<< - not associated\n"); return; } spin_lock_irqsave(&priv->lock, flags); - rx_info = &(((struct iwl_notif_statistics *)resp)->rx.general); - ofdm = &(((struct iwl_notif_statistics *)resp)->rx.ofdm); - cck = &(((struct iwl_notif_statistics *)resp)->rx.cck); + rx_info = &(((struct il_notif_statistics *)resp)->rx.general); + ofdm = &(((struct il_notif_statistics *)resp)->rx.ofdm); + cck = &(((struct il_notif_statistics *)resp)->rx.cck); if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { - IWL_DEBUG_CALIB(priv, "<< invalid data.\n"); + IL_DEBUG_CALIB(priv, "<< invalid data.\n"); spin_unlock_irqrestore(&priv->lock, flags); return; } @@ -558,10 +558,10 @@ void iwl4965_sensitivity_calibration(struct iwl_priv *priv, void *resp) spin_unlock_irqrestore(&priv->lock, flags); - IWL_DEBUG_CALIB(priv, "rx_enable_time = %u usecs\n", rx_enable_time); + IL_DEBUG_CALIB(priv, "rx_enable_time = %u usecs\n", rx_enable_time); if (!rx_enable_time) { - IWL_DEBUG_CALIB(priv, "<< RX Enable Time == 0!\n"); + IL_DEBUG_CALIB(priv, "<< RX Enable Time == 0!\n"); return; } @@ -600,17 +600,17 @@ void iwl4965_sensitivity_calibration(struct iwl_priv *priv, void *resp) norm_fa_ofdm = fa_ofdm + bad_plcp_ofdm; norm_fa_cck = fa_cck + bad_plcp_cck; - IWL_DEBUG_CALIB(priv, + IL_DEBUG_CALIB(priv, "cck: fa %u badp %u ofdm: fa %u badp %u\n", fa_cck, bad_plcp_cck, fa_ofdm, bad_plcp_ofdm); - iwl4965_sens_auto_corr_ofdm(priv, norm_fa_ofdm, rx_enable_time); - iwl4965_sens_energy_cck(priv, norm_fa_cck, rx_enable_time, &statis); + il4965_sens_auto_corr_ofdm(priv, norm_fa_ofdm, rx_enable_time); + il4965_sens_energy_cck(priv, norm_fa_cck, rx_enable_time, &statis); - iwl4965_sensitivity_write(priv); + il4965_sensitivity_write(priv); } -static inline u8 iwl4965_find_first_chain(u8 mask) +static inline u8 il4965_find_first_chain(u8 mask) { if (mask & ANT_A) return CHAIN_A; @@ -624,8 +624,8 @@ static inline u8 iwl4965_find_first_chain(u8 mask) * disconnected. */ static void -iwl4965_find_disconn_antenna(struct iwl_priv *priv, u32* average_sig, - struct iwl_chain_noise_data *data) +il4965_find_disconn_antenna(struct il_priv *priv, u32* average_sig, + struct il_chain_noise_data *data) { u32 active_chains = 0; u32 max_average_sig; @@ -657,9 +657,9 @@ iwl4965_find_disconn_antenna(struct iwl_priv *priv, u32* average_sig, active_chains = (1 << max_average_sig_antenna_i); } - IWL_DEBUG_CALIB(priv, "average_sig: a %d b %d c %d\n", + IL_DEBUG_CALIB(priv, "average_sig: a %d b %d c %d\n", average_sig[0], average_sig[1], average_sig[2]); - IWL_DEBUG_CALIB(priv, "max_average_sig = %d, antenna %d\n", + IL_DEBUG_CALIB(priv, "max_average_sig = %d, antenna %d\n", max_average_sig, max_average_sig_antenna_i); /* Compare signal strengths for all 3 receivers. */ @@ -673,7 +673,7 @@ iwl4965_find_disconn_antenna(struct iwl_priv *priv, u32* average_sig, data->disconn_array[i] = 1; else active_chains |= (1 << i); - IWL_DEBUG_CALIB(priv, "i = %d rssiDelta = %d " + IL_DEBUG_CALIB(priv, "i = %d rssiDelta = %d " "disconn_array[i] = %d\n", i, rssi_delta, data->disconn_array[i]); } @@ -710,10 +710,10 @@ iwl4965_find_disconn_antenna(struct iwl_priv *priv, u32* average_sig, * connect the first valid tx chain */ first_chain = - iwl4965_find_first_chain(priv->cfg->valid_tx_ant); + il4965_find_first_chain(priv->cfg->valid_tx_ant); data->disconn_array[first_chain] = 0; active_chains |= BIT(first_chain); - IWL_DEBUG_CALIB(priv, + IL_DEBUG_CALIB(priv, "All Tx chains are disconnected W/A - declare %d as connected\n", first_chain); break; @@ -722,25 +722,25 @@ iwl4965_find_disconn_antenna(struct iwl_priv *priv, u32* average_sig, if (active_chains != priv->hw_params.valid_rx_ant && active_chains != priv->chain_noise_data.active_chains) - IWL_DEBUG_CALIB(priv, + IL_DEBUG_CALIB(priv, "Detected that not all antennas are connected! " "Connected: %#x, valid: %#x.\n", active_chains, priv->hw_params.valid_rx_ant); /* Save for use within RXON, TX, SCAN commands, etc. */ data->active_chains = active_chains; - IWL_DEBUG_CALIB(priv, "active_chains (bitwise) = 0x%x\n", + IL_DEBUG_CALIB(priv, "active_chains (bitwise) = 0x%x\n", active_chains); } -static void iwl4965_gain_computation(struct iwl_priv *priv, +static void il4965_gain_computation(struct il_priv *priv, u32 *average_noise, u16 min_average_noise_antenna_i, u32 min_average_noise, u8 default_chain) { int i, ret; - struct iwl_chain_noise_data *data = &priv->chain_noise_data; + struct il_chain_noise_data *data = &priv->chain_noise_data; data->delta_gain_code[min_average_noise_antenna_i] = 0; @@ -762,32 +762,32 @@ static void iwl4965_gain_computation(struct iwl_priv *priv, data->delta_gain_code[i] = 0; } } - IWL_DEBUG_CALIB(priv, "delta_gain_codes: a %d b %d c %d\n", + IL_DEBUG_CALIB(priv, "delta_gain_codes: a %d b %d c %d\n", data->delta_gain_code[0], data->delta_gain_code[1], data->delta_gain_code[2]); /* Differential gain gets sent to uCode only once */ if (!data->radio_write) { - struct iwl_calib_diff_gain_cmd cmd; + struct il_calib_diff_gain_cmd cmd; data->radio_write = 1; memset(&cmd, 0, sizeof(cmd)); - cmd.hdr.op_code = IWL_PHY_CALIBRATE_DIFF_GAIN_CMD; + cmd.hdr.op_code = IL_PHY_CALIBRATE_DIFF_GAIN_CMD; cmd.diff_gain_a = data->delta_gain_code[0]; cmd.diff_gain_b = data->delta_gain_code[1]; cmd.diff_gain_c = data->delta_gain_code[2]; - ret = iwl_legacy_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD, + ret = il_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD, sizeof(cmd), &cmd); if (ret) - IWL_DEBUG_CALIB(priv, "fail sending cmd " + IL_DEBUG_CALIB(priv, "fail sending cmd " "REPLY_PHY_CALIBRATION_CMD\n"); /* TODO we might want recalculate * rx_chain in rxon cmd */ /* Mark so we run this algo only once! */ - data->state = IWL_CHAIN_NOISE_CALIBRATED; + data->state = IL_CHAIN_NOISE_CALIBRATED; } } @@ -799,9 +799,9 @@ static void iwl4965_gain_computation(struct iwl_priv *priv, * 1) Which antennas are connected. * 2) Differential rx gain settings to balance the 3 receivers. */ -void iwl4965_chain_noise_calibration(struct iwl_priv *priv, void *stat_resp) +void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp) { - struct iwl_chain_noise_data *data = NULL; + struct il_chain_noise_data *data = NULL; u32 chain_noise_a; u32 chain_noise_b; @@ -821,7 +821,7 @@ void iwl4965_chain_noise_calibration(struct iwl_priv *priv, void *stat_resp) unsigned long flags; struct statistics_rx_non_phy *rx_info; - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; if (priv->disable_chain_noise_cal) return; @@ -832,19 +832,19 @@ void iwl4965_chain_noise_calibration(struct iwl_priv *priv, void *stat_resp) * Accumulate just the first "chain_noise_num_beacons" after * the first association, then we're done forever. */ - if (data->state != IWL_CHAIN_NOISE_ACCUMULATE) { - if (data->state == IWL_CHAIN_NOISE_ALIVE) - IWL_DEBUG_CALIB(priv, "Wait for noise calib reset\n"); + if (data->state != IL_CHAIN_NOISE_ACCUMULATE) { + if (data->state == IL_CHAIN_NOISE_ALIVE) + IL_DEBUG_CALIB(priv, "Wait for noise calib reset\n"); return; } spin_lock_irqsave(&priv->lock, flags); - rx_info = &(((struct iwl_notif_statistics *)stat_resp)-> + rx_info = &(((struct il_notif_statistics *)stat_resp)-> rx.general); if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { - IWL_DEBUG_CALIB(priv, " << Interference data unavailable\n"); + IL_DEBUG_CALIB(priv, " << Interference data unavailable\n"); spin_unlock_irqrestore(&priv->lock, flags); return; } @@ -852,16 +852,16 @@ void iwl4965_chain_noise_calibration(struct iwl_priv *priv, void *stat_resp) rxon_band24 = !!(ctx->staging.flags & RXON_FLG_BAND_24G_MSK); rxon_chnum = le16_to_cpu(ctx->staging.channel); - stat_band24 = !!(((struct iwl_notif_statistics *) + stat_band24 = !!(((struct il_notif_statistics *) stat_resp)->flag & STATISTICS_REPLY_FLG_BAND_24G_MSK); - stat_chnum = le32_to_cpu(((struct iwl_notif_statistics *) + stat_chnum = le32_to_cpu(((struct il_notif_statistics *) stat_resp)->flag) >> 16; /* Make sure we accumulate data for just the associated channel * (even if scanning). */ if ((rxon_chnum != stat_chnum) || (rxon_band24 != stat_band24)) { - IWL_DEBUG_CALIB(priv, "Stats not from chan=%d, band24=%d\n", + IL_DEBUG_CALIB(priv, "Stats not from chan=%d, band24=%d\n", rxon_chnum, rxon_band24); spin_unlock_irqrestore(&priv->lock, flags); return; @@ -894,11 +894,11 @@ void iwl4965_chain_noise_calibration(struct iwl_priv *priv, void *stat_resp) data->chain_signal_b = (chain_sig_b + data->chain_signal_b); data->chain_signal_c = (chain_sig_c + data->chain_signal_c); - IWL_DEBUG_CALIB(priv, "chan=%d, band24=%d, beacon=%d\n", + IL_DEBUG_CALIB(priv, "chan=%d, band24=%d, beacon=%d\n", rxon_chnum, rxon_band24, data->beacon_count); - IWL_DEBUG_CALIB(priv, "chain_sig: a %d b %d c %d\n", + IL_DEBUG_CALIB(priv, "chain_sig: a %d b %d c %d\n", chain_sig_a, chain_sig_b, chain_sig_c); - IWL_DEBUG_CALIB(priv, "chain_noise: a %d b %d c %d\n", + IL_DEBUG_CALIB(priv, "chain_noise: a %d b %d c %d\n", chain_noise_a, chain_noise_b, chain_noise_c); /* If this is the "chain_noise_num_beacons", determine: @@ -909,7 +909,7 @@ void iwl4965_chain_noise_calibration(struct iwl_priv *priv, void *stat_resp) return; /* Analyze signal for disconnected antenna */ - iwl4965_find_disconn_antenna(priv, average_sig, data); + il4965_find_disconn_antenna(priv, average_sig, data); /* Analyze noise for rx balance */ average_noise[0] = data->chain_noise_a / @@ -929,16 +929,16 @@ void iwl4965_chain_noise_calibration(struct iwl_priv *priv, void *stat_resp) } } - IWL_DEBUG_CALIB(priv, "average_noise: a %d b %d c %d\n", + IL_DEBUG_CALIB(priv, "average_noise: a %d b %d c %d\n", average_noise[0], average_noise[1], average_noise[2]); - IWL_DEBUG_CALIB(priv, "min_average_noise = %d, antenna %d\n", + IL_DEBUG_CALIB(priv, "min_average_noise = %d, antenna %d\n", min_average_noise, min_average_noise_antenna_i); - iwl4965_gain_computation(priv, average_noise, + il4965_gain_computation(priv, average_noise, min_average_noise_antenna_i, min_average_noise, - iwl4965_find_first_chain(priv->cfg->valid_rx_ant)); + il4965_find_first_chain(priv->cfg->valid_rx_ant)); /* Some power changes may have been made during the calibration. * Update and commit the RXON @@ -946,22 +946,22 @@ void iwl4965_chain_noise_calibration(struct iwl_priv *priv, void *stat_resp) if (priv->cfg->ops->lib->update_chain_flags) priv->cfg->ops->lib->update_chain_flags(priv); - data->state = IWL_CHAIN_NOISE_DONE; - iwl_legacy_power_update_mode(priv, false); + data->state = IL_CHAIN_NOISE_DONE; + il_power_update_mode(priv, false); } -void iwl4965_reset_run_time_calib(struct iwl_priv *priv) +void il4965_reset_run_time_calib(struct il_priv *priv) { int i; memset(&(priv->sensitivity_data), 0, - sizeof(struct iwl_sensitivity_data)); + sizeof(struct il_sensitivity_data)); memset(&(priv->chain_noise_data), 0, - sizeof(struct iwl_chain_noise_data)); + sizeof(struct il_chain_noise_data)); for (i = 0; i < NUM_RX_CHAINS; i++) priv->chain_noise_data.delta_gain_code[i] = CHAIN_NOISE_DELTA_GAIN_INIT_VAL; /* Ask for statistics now, the uCode will send notification * periodically after association */ - iwl_legacy_send_statistics_request(priv, CMD_ASYNC, true); + il_send_statistics_request(priv, CMD_ASYNC, true); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.h b/drivers/net/wireless/iwlegacy/iwl-4965-calib.h index f46c80e6e005..a23081f1d03e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-calib.h @@ -59,17 +59,17 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef __iwl_4965_calib_h__ -#define __iwl_4965_calib_h__ +#ifndef __il_4965_calib_h__ +#define __il_4965_calib_h__ #include "iwl-dev.h" #include "iwl-core.h" #include "iwl-commands.h" -void iwl4965_chain_noise_calibration(struct iwl_priv *priv, void *stat_resp); -void iwl4965_sensitivity_calibration(struct iwl_priv *priv, void *resp); -void iwl4965_init_sensitivity(struct iwl_priv *priv); -void iwl4965_reset_run_time_calib(struct iwl_priv *priv); -void iwl4965_calib_free_results(struct iwl_priv *priv); +void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp); +void il4965_sensitivity_calibration(struct il_priv *priv, void *resp); +void il4965_init_sensitivity(struct il_priv *priv); +void il4965_reset_run_time_calib(struct il_priv *priv); +void il4965_calib_free_results(struct il_priv *priv); -#endif /* __iwl_4965_calib_h__ */ +#endif /* __il_4965_calib_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c index 1c93665766e4..3c2876ffadc5 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c @@ -33,7 +33,7 @@ static const char *fmt_table = " %-30s %10u %10u %10u %10u\n"; static const char *fmt_header = "%-32s current cumulative delta max\n"; -static int iwl4965_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz) +static int il4965_statistics_flag(struct il_priv *priv, char *buf, int bufsz) { int p = 0; u32 flag; @@ -54,10 +54,10 @@ static int iwl4965_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz) return p; } -ssize_t iwl4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, +ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0; char *buf; int bufsz = sizeof(struct statistics_rx_phy) * 40 + @@ -70,12 +70,12 @@ ssize_t iwl4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, struct statistics_rx_non_phy *delta_general, *max_general; struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht; - if (!iwl_legacy_is_alive(priv)) + if (!il_is_alive(priv)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IWL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(priv, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -101,7 +101,7 @@ ssize_t iwl4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, max_general = &priv->_4965.max_delta.rx.general; max_ht = &priv->_4965.max_delta.rx.ofdm_ht; - pos += iwl4965_statistics_flag(priv, buf, bufsz); + pos += il4965_statistics_flag(priv, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, fmt_header, "Statistics_Rx - OFDM:"); pos += scnprintf(buf + pos, bufsz - pos, @@ -485,23 +485,23 @@ ssize_t iwl4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, return ret; } -ssize_t iwl4965_ucode_tx_stats_read(struct file *file, +ssize_t il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0; char *buf; int bufsz = (sizeof(struct statistics_tx) * 48) + 250; ssize_t ret; struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx; - if (!iwl_legacy_is_alive(priv)) + if (!il_is_alive(priv)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IWL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(priv, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -514,7 +514,7 @@ ssize_t iwl4965_ucode_tx_stats_read(struct file *file, delta_tx = &priv->_4965.delta_statistics.tx; max_tx = &priv->_4965.max_delta.tx; - pos += iwl4965_statistics_flag(priv, buf, bufsz); + pos += il4965_statistics_flag(priv, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, fmt_header, "Statistics_Tx:"); pos += scnprintf(buf + pos, bufsz - pos, @@ -661,10 +661,10 @@ ssize_t iwl4965_ucode_tx_stats_read(struct file *file, } ssize_t -iwl4965_ucode_general_stats_read(struct file *file, char __user *user_buf, +il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0; char *buf; int bufsz = sizeof(struct statistics_general) * 10 + 300; @@ -674,12 +674,12 @@ iwl4965_ucode_general_stats_read(struct file *file, char __user *user_buf, struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; struct statistics_div *div, *accum_div, *delta_div, *max_div; - if (!iwl_legacy_is_alive(priv)) + if (!il_is_alive(priv)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IWL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(priv, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -700,7 +700,7 @@ iwl4965_ucode_general_stats_read(struct file *file, char __user *user_buf, delta_div = &priv->_4965.delta_statistics.general.common.div; max_div = &priv->_4965.max_delta.general.common.div; - pos += iwl4965_statistics_flag(priv, buf, bufsz); + pos += il4965_statistics_flag(priv, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, fmt_header, "Statistics_General:"); pos += scnprintf(buf + pos, bufsz - pos, diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h index 6c8e35361a9e..ca1cf586f07b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h @@ -31,27 +31,27 @@ #include "iwl-debug.h" #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS -ssize_t iwl4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, +ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos); -ssize_t iwl4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, +ssize_t il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos); -ssize_t iwl4965_ucode_general_stats_read(struct file *file, +ssize_t il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos); #else static ssize_t -iwl4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, +il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { return 0; } static ssize_t -iwl4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, +il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { return 0; } static ssize_t -iwl4965_ucode_general_stats_read(struct file *file, char __user *user_buf, +il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { return 0; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c index cb9baab1ff7d..e657b444cf48 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c @@ -87,23 +87,23 @@ * EEPROM chip, not a single event, so even reads could conflict if they * weren't arbitrated by the semaphore. */ -int iwl4965_eeprom_acquire_semaphore(struct iwl_priv *priv) +int il4965_eeprom_acquire_semaphore(struct il_priv *priv) { u16 count; int ret; for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) { /* Request semaphore */ - iwl_legacy_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(priv, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); /* See if we got it */ - ret = iwl_poll_bit(priv, CSR_HW_IF_CONFIG_REG, + ret = il_poll_bit(priv, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, EEPROM_SEM_TIMEOUT); if (ret >= 0) { - IWL_DEBUG_IO(priv, + IL_DEBUG_IO(priv, "Acquired semaphore after %d tries.\n", count+1); return ret; @@ -113,32 +113,32 @@ int iwl4965_eeprom_acquire_semaphore(struct iwl_priv *priv) return ret; } -void iwl4965_eeprom_release_semaphore(struct iwl_priv *priv) +void il4965_eeprom_release_semaphore(struct il_priv *priv) { - iwl_legacy_clear_bit(priv, CSR_HW_IF_CONFIG_REG, + il_clear_bit(priv, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); } -int iwl4965_eeprom_check_version(struct iwl_priv *priv) +int il4965_eeprom_check_version(struct il_priv *priv) { u16 eeprom_ver; u16 calib_ver; - eeprom_ver = iwl_legacy_eeprom_query16(priv, EEPROM_VERSION); - calib_ver = iwl_legacy_eeprom_query16(priv, + eeprom_ver = il_eeprom_query16(priv, EEPROM_VERSION); + calib_ver = il_eeprom_query16(priv, EEPROM_4965_CALIB_VERSION_OFFSET); if (eeprom_ver < priv->cfg->eeprom_ver || calib_ver < priv->cfg->eeprom_calib_ver) goto err; - IWL_INFO(priv, "device EEPROM VER=0x%x, CALIB=0x%x\n", + IL_INFO(priv, "device EEPROM VER=0x%x, CALIB=0x%x\n", eeprom_ver, calib_ver); return 0; err: - IWL_ERR(priv, "Unsupported (too old) EEPROM VER=0x%x < 0x%x " + IL_ERR(priv, "Unsupported (too old) EEPROM VER=0x%x < 0x%x " "CALIB=0x%x < 0x%x\n", eeprom_ver, priv->cfg->eeprom_ver, calib_ver, priv->cfg->eeprom_calib_ver); @@ -146,9 +146,9 @@ err: } -void iwl4965_eeprom_get_mac(const struct iwl_priv *priv, u8 *mac) +void il4965_eeprom_get_mac(const struct il_priv *priv, u8 *mac) { - const u8 *addr = iwl_legacy_eeprom_query_addr(priv, + const u8 *addr = il_eeprom_query_addr(priv, EEPROM_MAC_ADDRESS); memcpy(mac, addr, ETH_ALEN); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h index fc6fa2886d9c..b6b7fe2f5ca4 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h @@ -66,8 +66,8 @@ * Use iwl-dev.h for driver implementation definitions. */ -#ifndef __iwl_4965_hw_h__ -#define __iwl_4965_hw_h__ +#ifndef __il_4965_hw_h__ +#define __il_4965_hw_h__ #include "iwl-fh.h" @@ -100,7 +100,7 @@ /* Size of uCode instruction memory in bootstrap state machine */ #define IWL49_MAX_BSM_SIZE BSM_SRAM_SIZE -static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) +static inline int il4965_hw_valid_rtc_data_addr(u32 addr) { return (addr >= IWL49_RTC_DATA_LOWER_BOUND) && (addr < IWL49_RTC_DATA_UPPER_BOUND); @@ -118,7 +118,7 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) * real-time temperature indicator. * * uCode provides all 4 values to the driver via the "initialize alive" - * notification (see struct iwl4965_init_alive_resp). After the runtime uCode + * notification (see struct il4965_init_alive_resp). After the runtime uCode * image loads, uCode updates the R4 value via statistics notifications * (see STATISTICS_NOTIFICATION), which occur after each received beacon * when associated, or can be requested via REPLY_STATISTICS_CMD. @@ -143,12 +143,12 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) #define TEMPERATURE_CALIB_A_VAL 259 /* Limit range of calculated temperature to be between these Kelvin values */ -#define IWL_TX_POWER_TEMPERATURE_MIN (263) -#define IWL_TX_POWER_TEMPERATURE_MAX (410) +#define IL_TX_POWER_TEMPERATURE_MIN (263) +#define IL_TX_POWER_TEMPERATURE_MAX (410) -#define IWL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(t) \ - (((t) < IWL_TX_POWER_TEMPERATURE_MIN) || \ - ((t) > IWL_TX_POWER_TEMPERATURE_MAX)) +#define IL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(t) \ + (((t) < IL_TX_POWER_TEMPERATURE_MIN) || \ + ((t) > IL_TX_POWER_TEMPERATURE_MAX)) /********************* END TEMPERATURE ***************************************/ @@ -168,7 +168,7 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) * 40 MHz wide (.11n HT40) channels are listed separately from 20 MHz * (legacy) channels. * - * See struct iwl4965_eeprom_channel for format, and struct iwl4965_eeprom + * See struct il4965_eeprom_channel for format, and struct il4965_eeprom * for locations in EEPROM. * * 2) Factory txpower calibration information is provided separately for @@ -177,11 +177,11 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) * * In addition, per-band (2.4 and 5 Ghz) saturation txpowers are provided. * - * See struct iwl4965_eeprom_calib_info (and the tree of structures - * contained within it) for format, and struct iwl4965_eeprom for + * See struct il4965_eeprom_calib_info (and the tree of structures + * contained within it) for format, and struct il4965_eeprom for * locations in EEPROM. * - * "Initialization alive" notification (see struct iwl4965_init_alive_resp) + * "Initialization alive" notification (see struct il4965_init_alive_resp) * consists of: * * 1) Temperature calculation parameters. @@ -238,7 +238,7 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) * * 3) Determine (EEPROM) calibration sub band for the target channel, by * comparing against first and last channels in each sub band - * (see struct iwl4965_eeprom_calib_subband_info). + * (see struct il4965_eeprom_calib_subband_info). * * * 4) Linearly interpolate (EEPROM) factory calibration measurement sets, @@ -254,7 +254,7 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) * span of the sampled channels. * * Driver may choose the pair (for 2 Tx chains) of measurements (see - * struct iwl4965_eeprom_calib_ch_info) for which the actual measured + * struct il4965_eeprom_calib_ch_info) for which the actual measured * txpower comes closest to the desired txpower. Usually, though, * the middle set of measurements is closest to the regulatory limits, * and is therefore a good choice for all txpower calculations (this @@ -370,7 +370,7 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) * * * 11) Read gain table entries for DSP and radio gain, place into appropriate - * location(s) in command (struct iwl4965_txpowertable_cmd). + * location(s) in command (struct il4965_txpowertable_cmd). */ /** @@ -382,7 +382,7 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) * The value "6" represents number of steps in gain table to reduce power 3 dB. * Each step is 1/2 dB. */ -#define IWL_TX_POWER_MIMO_REGULATORY_COMPENSATION (6) +#define IL_TX_POWER_MIMO_REGULATORY_COMPENSATION (6) /** * CCK gain compensation. @@ -394,13 +394,13 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG, * bits [3:2], 1 = B, 2 = C. */ -#define IWL_TX_POWER_CCK_COMPENSATION_B_STEP (9) -#define IWL_TX_POWER_CCK_COMPENSATION_C_STEP (5) +#define IL_TX_POWER_CCK_COMPENSATION_B_STEP (9) +#define IL_TX_POWER_CCK_COMPENSATION_C_STEP (5) /* * 4965 power supply voltage compensation for txpower */ -#define TX_POWER_IWL_VOLTAGE_CODES_PER_03V (7) +#define TX_POWER_IL_VOLTAGE_CODES_PER_03V (7) /** * Gain tables. @@ -668,10 +668,10 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) * * Units are in half-dBm (i.e. "34" means 17 dBm). */ -#define IWL_TX_POWER_DEFAULT_REGULATORY_24 (34) -#define IWL_TX_POWER_DEFAULT_REGULATORY_52 (34) -#define IWL_TX_POWER_REGULATORY_MIN (0) -#define IWL_TX_POWER_REGULATORY_MAX (34) +#define IL_TX_POWER_DEFAULT_REGULATORY_24 (34) +#define IL_TX_POWER_DEFAULT_REGULATORY_52 (34) +#define IL_TX_POWER_REGULATORY_MIN (0) +#define IL_TX_POWER_REGULATORY_MAX (34) /** * Sanity checks and default values for EEPROM saturation levels. @@ -689,10 +689,10 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) * * Units are in half-dBm (i.e. "38" means 19 dBm). */ -#define IWL_TX_POWER_DEFAULT_SATURATION_24 (38) -#define IWL_TX_POWER_DEFAULT_SATURATION_52 (38) -#define IWL_TX_POWER_SATURATION_MIN (20) -#define IWL_TX_POWER_SATURATION_MAX (50) +#define IL_TX_POWER_DEFAULT_SATURATION_24 (38) +#define IL_TX_POWER_DEFAULT_SATURATION_52 (38) +#define IL_TX_POWER_SATURATION_MIN (20) +#define IL_TX_POWER_SATURATION_MAX (50) /** * Channel groups used for Tx Attenuation calibration (MIMO tx channel balance) @@ -709,24 +709,24 @@ static inline int iwl4965_hw_valid_rtc_data_addr(u32 addr) * Different frequency ranges require different compensation, as shown below. */ /* Group 0, 5.2 GHz ch 34-43: 4.5 degrees per 1/2 dB. */ -#define CALIB_IWL_TX_ATTEN_GR1_FCH 34 -#define CALIB_IWL_TX_ATTEN_GR1_LCH 43 +#define CALIB_IL_TX_ATTEN_GR1_FCH 34 +#define CALIB_IL_TX_ATTEN_GR1_LCH 43 /* Group 1, 5.3 GHz ch 44-70: 4.0 degrees per 1/2 dB. */ -#define CALIB_IWL_TX_ATTEN_GR2_FCH 44 -#define CALIB_IWL_TX_ATTEN_GR2_LCH 70 +#define CALIB_IL_TX_ATTEN_GR2_FCH 44 +#define CALIB_IL_TX_ATTEN_GR2_LCH 70 /* Group 2, 5.5 GHz ch 71-124: 4.0 degrees per 1/2 dB. */ -#define CALIB_IWL_TX_ATTEN_GR3_FCH 71 -#define CALIB_IWL_TX_ATTEN_GR3_LCH 124 +#define CALIB_IL_TX_ATTEN_GR3_FCH 71 +#define CALIB_IL_TX_ATTEN_GR3_LCH 124 /* Group 3, 5.7 GHz ch 125-200: 4.0 degrees per 1/2 dB. */ -#define CALIB_IWL_TX_ATTEN_GR4_FCH 125 -#define CALIB_IWL_TX_ATTEN_GR4_LCH 200 +#define CALIB_IL_TX_ATTEN_GR4_FCH 125 +#define CALIB_IL_TX_ATTEN_GR4_LCH 200 /* Group 4, 2.4 GHz all channels: 3.5 degrees per 1/2 dB. */ -#define CALIB_IWL_TX_ATTEN_GR5_FCH 1 -#define CALIB_IWL_TX_ATTEN_GR5_LCH 20 +#define CALIB_IL_TX_ATTEN_GR5_FCH 1 +#define CALIB_IL_TX_ATTEN_GR5_LCH 20 enum { CALIB_CH_GROUP_1 = 0, @@ -767,7 +767,7 @@ enum { /** - * struct iwl4965_schedq_bc_tbl + * struct il4965_schedq_bc_tbl * * Byte Count table * @@ -784,7 +784,7 @@ enum { * padding puts each byte count table on a 1024-byte boundary; * 4965 assumes tables are separated by 1024 bytes. */ -struct iwl4965_scd_bc_tbl { +struct il4965_scd_bc_tbl { __le16 tfd_offset[TFD_QUEUE_BC_SIZE]; u8 pad[1024 - (TFD_QUEUE_BC_SIZE) * sizeof(__le16)]; } __packed; @@ -808,4 +808,4 @@ struct iwl4965_scd_bc_tbl { #define IWL4965_FIRST_AMPDU_QUEUE 10 -#endif /* !__iwl_4965_hw_h__ */ +#endif /* !__il_4965_hw_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-led.c b/drivers/net/wireless/iwlegacy/iwl-4965-led.c index 6862fdcaee62..d2c8eacd6835 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-led.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-led.c @@ -44,30 +44,30 @@ /* Send led command */ static int -iwl4965_send_led_cmd(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd) +il4965_send_led_cmd(struct il_priv *priv, struct il_led_cmd *led_cmd) { - struct iwl_host_cmd cmd = { + struct il_host_cmd cmd = { .id = REPLY_LEDS_CMD, - .len = sizeof(struct iwl_led_cmd), + .len = sizeof(struct il_led_cmd), .data = led_cmd, .flags = CMD_ASYNC, .callback = NULL, }; u32 reg; - reg = iwl_read32(priv, CSR_LED_REG); + reg = il_read32(priv, CSR_LED_REG); if (reg != (reg & CSR_LED_BSM_CTRL_MSK)) - iwl_write32(priv, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK); + il_write32(priv, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK); - return iwl_legacy_send_cmd(priv, &cmd); + return il_send_cmd(priv, &cmd); } /* Set led register off */ -void iwl4965_led_enable(struct iwl_priv *priv) +void il4965_led_enable(struct il_priv *priv) { - iwl_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_ON); + il_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_ON); } -const struct iwl_led_ops iwl4965_led_ops = { - .cmd = iwl4965_send_led_cmd, +const struct il_led_ops il4965_led_ops = { + .cmd = il4965_send_led_cmd, }; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-led.h b/drivers/net/wireless/iwlegacy/iwl-4965-led.h index 5ed3615fc338..ab03dff812fd 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-led.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-led.h @@ -24,10 +24,10 @@ * *****************************************************************************/ -#ifndef __iwl_4965_led_h__ -#define __iwl_4965_led_h__ +#ifndef __il_4965_led_h__ +#define __il_4965_led_h__ -extern const struct iwl_led_ops iwl4965_led_ops; -void iwl4965_led_enable(struct iwl_priv *priv); +extern const struct il_led_ops il4965_led_ops; +void il4965_led_enable(struct il_priv *priv); -#endif /* __iwl_4965_led_h__ */ +#endif /* __il_4965_led_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index 2be6d9e3b019..25f1d4768e7b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -40,11 +40,11 @@ #include "iwl-4965.h" #include "iwl-sta.h" -void iwl4965_check_abort_status(struct iwl_priv *priv, +void il4965_check_abort_status(struct il_priv *priv, u8 frame_count, u32 status) { if (frame_count == 1 && status == TX_STATUS_FAIL_RFKILL_FLUSH) { - IWL_ERR(priv, "Tx flush command to flush out all frames\n"); + IL_ERR(priv, "Tx flush command to flush out all frames\n"); if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) queue_work(priv->workqueue, &priv->tx_flush); } @@ -53,13 +53,13 @@ void iwl4965_check_abort_status(struct iwl_priv *priv, /* * EEPROM */ -struct iwl_mod_params iwl4965_mod_params = { +struct il_mod_params il4965_mod_params = { .amsdu_size_8K = 1, .restart_fw = 1, /* the rest are 0 by default */ }; -void iwl4965_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq) +void il4965_rx_queue_reset(struct il_priv *priv, struct il_rx_queue *rxq) { unsigned long flags; int i; @@ -74,7 +74,7 @@ void iwl4965_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq) pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, PAGE_SIZE << priv->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); - __iwl_legacy_free_pages(priv, rxq->pool[i].page); + __il_free_pages(priv, rxq->pool[i].page); rxq->pool[i].page = NULL; } list_add_tail(&rxq->pool[i].list, &rxq->rx_used); @@ -91,7 +91,7 @@ void iwl4965_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq) spin_unlock_irqrestore(&rxq->lock, flags); } -int iwl4965_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq) +int il4965_rx_init(struct il_priv *priv, struct il_rx_queue *rxq) { u32 rb_size; const u32 rfdnlog = RX_QUEUE_SIZE_LOG; /* 256 RBDs */ @@ -103,17 +103,17 @@ int iwl4965_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq) rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K; /* Stop Rx DMA */ - iwl_legacy_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); + il_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); /* Reset driver's Rx queue write index */ - iwl_legacy_write_direct32(priv, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); + il_write_direct32(priv, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); /* Tell device where to find RBD circular buffer in DRAM */ - iwl_legacy_write_direct32(priv, FH_RSCSR_CHNL0_RBDCB_BASE_REG, + il_write_direct32(priv, FH_RSCSR_CHNL0_RBDCB_BASE_REG, (u32)(rxq->bd_dma >> 8)); /* Tell device where in DRAM to update its Rx status */ - iwl_legacy_write_direct32(priv, FH_RSCSR_CHNL0_STTS_WPTR_REG, + il_write_direct32(priv, FH_RSCSR_CHNL0_STTS_WPTR_REG, rxq->rb_stts_dma >> 4); /* Enable Rx DMA @@ -122,7 +122,7 @@ int iwl4965_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq) * RB timeout 0x10 * 256 RBDs */ - iwl_legacy_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, + il_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL | FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL | FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK | @@ -131,32 +131,32 @@ int iwl4965_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq) (rfdnlog << FH_RCSR_RX_CONFIG_RBDCB_SIZE_POS)); /* Set interrupt coalescing timer to default (2048 usecs) */ - iwl_write8(priv, CSR_INT_COALESCING, IWL_HOST_INT_TIMEOUT_DEF); + il_write8(priv, CSR_INT_COALESCING, IL_HOST_INT_TIMEOUT_DEF); return 0; } -static void iwl4965_set_pwr_vmain(struct iwl_priv *priv) +static void il4965_set_pwr_vmain(struct il_priv *priv) { /* * (for documentation purposes) * to set power to V_AUX, do: if (pci_pme_capable(priv->pci_dev, PCI_D3cold)) - iwl_legacy_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, + il_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_PWR_SRC_VAUX, ~APMG_PS_CTRL_MSK_PWR_SRC); */ - iwl_legacy_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, + il_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, ~APMG_PS_CTRL_MSK_PWR_SRC); } -int iwl4965_hw_nic_init(struct iwl_priv *priv) +int il4965_hw_nic_init(struct il_priv *priv) { unsigned long flags; - struct iwl_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &priv->rxq; int ret; /* nic_init */ @@ -164,42 +164,42 @@ int iwl4965_hw_nic_init(struct iwl_priv *priv) priv->cfg->ops->lib->apm_ops.init(priv); /* Set interrupt coalescing calibration timer to default (512 usecs) */ - iwl_write8(priv, CSR_INT_COALESCING, IWL_HOST_INT_CALIB_TIMEOUT_DEF); + il_write8(priv, CSR_INT_COALESCING, IL_HOST_INT_CALIB_TIMEOUT_DEF); spin_unlock_irqrestore(&priv->lock, flags); - iwl4965_set_pwr_vmain(priv); + il4965_set_pwr_vmain(priv); priv->cfg->ops->lib->apm_ops.config(priv); /* Allocate the RX queue, or reset if it is already allocated */ if (!rxq->bd) { - ret = iwl_legacy_rx_queue_alloc(priv); + ret = il_rx_queue_alloc(priv); if (ret) { - IWL_ERR(priv, "Unable to initialize Rx queue\n"); + IL_ERR(priv, "Unable to initialize Rx queue\n"); return -ENOMEM; } } else - iwl4965_rx_queue_reset(priv, rxq); + il4965_rx_queue_reset(priv, rxq); - iwl4965_rx_replenish(priv); + il4965_rx_replenish(priv); - iwl4965_rx_init(priv, rxq); + il4965_rx_init(priv, rxq); spin_lock_irqsave(&priv->lock, flags); rxq->need_update = 1; - iwl_legacy_rx_queue_update_write_ptr(priv, rxq); + il_rx_queue_update_write_ptr(priv, rxq); spin_unlock_irqrestore(&priv->lock, flags); /* Allocate or reset and init all Tx and Command queues */ if (!priv->txq) { - ret = iwl4965_txq_ctx_alloc(priv); + ret = il4965_txq_ctx_alloc(priv); if (ret) return ret; } else - iwl4965_txq_ctx_reset(priv); + il4965_txq_ctx_reset(priv); set_bit(STATUS_INIT, &priv->status); @@ -207,16 +207,16 @@ int iwl4965_hw_nic_init(struct iwl_priv *priv) } /** - * iwl4965_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr + * il4965_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr */ -static inline __le32 iwl4965_dma_addr2rbd_ptr(struct iwl_priv *priv, +static inline __le32 il4965_dma_addr2rbd_ptr(struct il_priv *priv, dma_addr_t dma_addr) { return cpu_to_le32((u32)(dma_addr >> 8)); } /** - * iwl4965_rx_queue_restock - refill RX queue from pre-allocated pool + * il4965_rx_queue_restock - refill RX queue from pre-allocated pool * * If there are slots in the RX queue that need to be restocked, * and we have free pre-allocated buffers, fill the ranks as much @@ -226,26 +226,26 @@ static inline __le32 iwl4965_dma_addr2rbd_ptr(struct iwl_priv *priv, * also updates the memory address in the firmware to reference the new * target buffer. */ -void iwl4965_rx_queue_restock(struct iwl_priv *priv) +void il4965_rx_queue_restock(struct il_priv *priv) { - struct iwl_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &priv->rxq; struct list_head *element; - struct iwl_rx_mem_buffer *rxb; + struct il_rx_mem_buffer *rxb; unsigned long flags; spin_lock_irqsave(&rxq->lock, flags); - while ((iwl_legacy_rx_queue_space(rxq) > 0) && (rxq->free_count)) { + while ((il_rx_queue_space(rxq) > 0) && (rxq->free_count)) { /* The overwritten rxb must be a used one */ rxb = rxq->queue[rxq->write]; BUG_ON(rxb && rxb->page); /* Get next free Rx buffer, remove from free list */ element = rxq->rx_free.next; - rxb = list_entry(element, struct iwl_rx_mem_buffer, list); + rxb = list_entry(element, struct il_rx_mem_buffer, list); list_del(element); /* Point to Rx buffer via next RBD in circular buffer */ - rxq->bd[rxq->write] = iwl4965_dma_addr2rbd_ptr(priv, + rxq->bd[rxq->write] = il4965_dma_addr2rbd_ptr(priv, rxb->page_dma); rxq->queue[rxq->write] = rxb; rxq->write = (rxq->write + 1) & RX_QUEUE_MASK; @@ -264,23 +264,23 @@ void iwl4965_rx_queue_restock(struct iwl_priv *priv) spin_lock_irqsave(&rxq->lock, flags); rxq->need_update = 1; spin_unlock_irqrestore(&rxq->lock, flags); - iwl_legacy_rx_queue_update_write_ptr(priv, rxq); + il_rx_queue_update_write_ptr(priv, rxq); } } /** - * iwl4965_rx_replenish - Move all used packet from rx_used to rx_free + * il4965_rx_replenish - Move all used packet from rx_used to rx_free * * When moving to rx_free an SKB is allocated for the slot. * - * Also restock the Rx queue via iwl_rx_queue_restock. + * Also restock the Rx queue via il_rx_queue_restock. * This is called as a scheduled work item (except for during initialization) */ -static void iwl4965_rx_allocate(struct iwl_priv *priv, gfp_t priority) +static void il4965_rx_allocate(struct il_priv *priv, gfp_t priority) { - struct iwl_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &priv->rxq; struct list_head *element; - struct iwl_rx_mem_buffer *rxb; + struct il_rx_mem_buffer *rxb; struct page *page; unsigned long flags; gfp_t gfp_mask = priority; @@ -303,13 +303,13 @@ static void iwl4965_rx_allocate(struct iwl_priv *priv, gfp_t priority) page = alloc_pages(gfp_mask, priv->hw_params.rx_page_order); if (!page) { if (net_ratelimit()) - IWL_DEBUG_INFO(priv, "alloc_pages failed, " + IL_DEBUG_INFO(priv, "alloc_pages failed, " "order: %d\n", priv->hw_params.rx_page_order); if ((rxq->free_count <= RX_LOW_WATERMARK) && net_ratelimit()) - IWL_CRIT(priv, + IL_CRIT(priv, "Failed to alloc_pages with %s. " "Only %u free buffers remaining.\n", priority == GFP_ATOMIC ? @@ -329,7 +329,7 @@ static void iwl4965_rx_allocate(struct iwl_priv *priv, gfp_t priority) return; } element = rxq->rx_used.next; - rxb = list_entry(element, struct iwl_rx_mem_buffer, list); + rxb = list_entry(element, struct il_rx_mem_buffer, list); list_del(element); spin_unlock_irqrestore(&rxq->lock, flags); @@ -355,22 +355,22 @@ static void iwl4965_rx_allocate(struct iwl_priv *priv, gfp_t priority) } } -void iwl4965_rx_replenish(struct iwl_priv *priv) +void il4965_rx_replenish(struct il_priv *priv) { unsigned long flags; - iwl4965_rx_allocate(priv, GFP_KERNEL); + il4965_rx_allocate(priv, GFP_KERNEL); spin_lock_irqsave(&priv->lock, flags); - iwl4965_rx_queue_restock(priv); + il4965_rx_queue_restock(priv); spin_unlock_irqrestore(&priv->lock, flags); } -void iwl4965_rx_replenish_now(struct iwl_priv *priv) +void il4965_rx_replenish_now(struct il_priv *priv) { - iwl4965_rx_allocate(priv, GFP_ATOMIC); + il4965_rx_allocate(priv, GFP_ATOMIC); - iwl4965_rx_queue_restock(priv); + il4965_rx_queue_restock(priv); } /* Assumes that the skb field of the buffers in 'pool' is kept accurate. @@ -378,7 +378,7 @@ void iwl4965_rx_replenish_now(struct iwl_priv *priv) * This free routine walks the list of POOL entries and if SKB is set to * non NULL it is unmapped and freed */ -void iwl4965_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rxq) +void il4965_rx_queue_free(struct il_priv *priv, struct il_rx_queue *rxq) { int i; for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { @@ -386,31 +386,31 @@ void iwl4965_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rxq) pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, PAGE_SIZE << priv->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); - __iwl_legacy_free_pages(priv, rxq->pool[i].page); + __il_free_pages(priv, rxq->pool[i].page); rxq->pool[i].page = NULL; } } dma_free_coherent(&priv->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, rxq->bd_dma); - dma_free_coherent(&priv->pci_dev->dev, sizeof(struct iwl_rb_status), + dma_free_coherent(&priv->pci_dev->dev, sizeof(struct il_rb_status), rxq->rb_stts, rxq->rb_stts_dma); rxq->bd = NULL; rxq->rb_stts = NULL; } -int iwl4965_rxq_stop(struct iwl_priv *priv) +int il4965_rxq_stop(struct il_priv *priv) { /* stop Rx DMA */ - iwl_legacy_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); - iwl_poll_direct_bit(priv, FH_MEM_RSSR_RX_STATUS_REG, + il_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); + il_poll_direct_bit(priv, FH_MEM_RSSR_RX_STATUS_REG, FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); return 0; } -int iwl4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) +int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) { int idx = 0; int band_offset = 0; @@ -422,8 +422,8 @@ int iwl4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) /* Legacy rate format, search for match in table */ } else { if (band == IEEE80211_BAND_5GHZ) - band_offset = IWL_FIRST_OFDM_RATE; - for (idx = band_offset; idx < IWL_RATE_COUNT_LEGACY; idx++) + band_offset = IL_FIRST_OFDM_RATE; + for (idx = band_offset; idx < IL_RATE_COUNT_LEGACY; idx++) if (iwlegacy_rates[idx].plcp == (rate_n_flags & 0xFF)) return idx - band_offset; } @@ -431,13 +431,13 @@ int iwl4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) return -1; } -static int iwl4965_calc_rssi(struct iwl_priv *priv, - struct iwl_rx_phy_res *rx_resp) +static int il4965_calc_rssi(struct il_priv *priv, + struct il_rx_phy_res *rx_resp) { /* data from PHY/DSP regarding signal strength, etc., * contents are always there, not configurable by host. */ - struct iwl4965_rx_non_cfg_phy *ncphy = - (struct iwl4965_rx_non_cfg_phy *)rx_resp->non_cfg_phy_buf; + struct il4965_rx_non_cfg_phy *ncphy = + (struct il4965_rx_non_cfg_phy *)rx_resp->non_cfg_phy_buf; u32 agc = (le16_to_cpu(ncphy->agc_info) & IWL49_AGC_DB_MASK) >> IWL49_AGC_DB_POS; @@ -456,7 +456,7 @@ static int iwl4965_calc_rssi(struct iwl_priv *priv, if (valid_antennae & (1 << i)) max_rssi = max(ncphy->rssi_info[i << 1], max_rssi); - IWL_DEBUG_STATS(priv, "Rssi In A %d B %d C %d Max %d AGC dB %d\n", + IL_DEBUG_STATS(priv, "Rssi In A %d B %d C %d Max %d AGC dB %d\n", ncphy->rssi_info[0], ncphy->rssi_info[2], ncphy->rssi_info[4], max_rssi, agc); @@ -466,7 +466,7 @@ static int iwl4965_calc_rssi(struct iwl_priv *priv, } -static u32 iwl4965_translate_rx_status(struct iwl_priv *priv, u32 decrypt_in) +static u32 il4965_translate_rx_status(struct il_priv *priv, u32 decrypt_in) { u32 decrypt_out = 0; @@ -519,17 +519,17 @@ static u32 iwl4965_translate_rx_status(struct iwl_priv *priv, u32 decrypt_in) break; } - IWL_DEBUG_RX(priv, "decrypt_in:0x%x decrypt_out = 0x%x\n", + IL_DEBUG_RX(priv, "decrypt_in:0x%x decrypt_out = 0x%x\n", decrypt_in, decrypt_out); return decrypt_out; } -static void iwl4965_pass_packet_to_mac80211(struct iwl_priv *priv, +static void il4965_pass_packet_to_mac80211(struct il_priv *priv, struct ieee80211_hdr *hdr, u16 len, u32 ampdu_status, - struct iwl_rx_mem_buffer *rxb, + struct il_rx_mem_buffer *rxb, struct ieee80211_rx_status *stats) { struct sk_buff *skb; @@ -537,25 +537,25 @@ static void iwl4965_pass_packet_to_mac80211(struct iwl_priv *priv, /* We only process data packets if the interface is open */ if (unlikely(!priv->is_open)) { - IWL_DEBUG_DROP_LIMIT(priv, + IL_DEBUG_DROP_LIMIT(priv, "Dropping packet while interface is not open.\n"); return; } /* In case of HW accelerated crypto and bad decryption, drop */ if (!priv->cfg->mod_params->sw_crypto && - iwl_legacy_set_decrypted_flag(priv, hdr, ampdu_status, stats)) + il_set_decrypted_flag(priv, hdr, ampdu_status, stats)) return; skb = dev_alloc_skb(128); if (!skb) { - IWL_ERR(priv, "dev_alloc_skb failed\n"); + IL_ERR(priv, "dev_alloc_skb failed\n"); return; } skb_add_rx_frag(skb, 0, rxb->page, (void *)hdr - rxb_addr(rxb), len); - iwl_legacy_update_stats(priv, false, fc, len); + il_update_stats(priv, false, fc, len); memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats)); ieee80211_rx(priv->hw, skb); @@ -565,15 +565,15 @@ static void iwl4965_pass_packet_to_mac80211(struct iwl_priv *priv, /* Called for REPLY_RX (legacy ABG frames), or * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */ -void iwl4965_rx_reply_rx(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +void il4965_rx_reply_rx(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { struct ieee80211_hdr *header; struct ieee80211_rx_status rx_status; - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_rx_phy_res *phy_res; + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_phy_res *phy_res; __le32 rx_pkt_status; - struct iwl_rx_mpdu_res_start *amsdu; + struct il_rx_mpdu_res_start *amsdu; u32 len; u32 ampdu_status; u32 rate_n_flags; @@ -588,7 +588,7 @@ void iwl4965_rx_reply_rx(struct iwl_priv *priv, * received. */ if (pkt->hdr.cmd == REPLY_RX) { - phy_res = (struct iwl_rx_phy_res *)pkt->u.raw; + phy_res = (struct il_rx_phy_res *)pkt->u.raw; header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*phy_res) + phy_res->cfg_phy_cnt); @@ -598,27 +598,27 @@ void iwl4965_rx_reply_rx(struct iwl_priv *priv, ampdu_status = le32_to_cpu(rx_pkt_status); } else { if (!priv->_4965.last_phy_res_valid) { - IWL_ERR(priv, "MPDU frame without cached PHY data\n"); + IL_ERR(priv, "MPDU frame without cached PHY data\n"); return; } phy_res = &priv->_4965.last_phy_res; - amsdu = (struct iwl_rx_mpdu_res_start *)pkt->u.raw; + amsdu = (struct il_rx_mpdu_res_start *)pkt->u.raw; header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*amsdu)); len = le16_to_cpu(amsdu->byte_count); rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*amsdu) + len); - ampdu_status = iwl4965_translate_rx_status(priv, + ampdu_status = il4965_translate_rx_status(priv, le32_to_cpu(rx_pkt_status)); } if ((unlikely(phy_res->cfg_phy_cnt > 20))) { - IWL_DEBUG_DROP(priv, "dsp size out of range [0,20]: %d/n", + IL_DEBUG_DROP(priv, "dsp size out of range [0,20]: %d/n", phy_res->cfg_phy_cnt); return; } if (!(rx_pkt_status & RX_RES_STATUS_NO_CRC32_ERROR) || !(rx_pkt_status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { - IWL_DEBUG_RX(priv, "Bad CRC or FIFO: 0x%08X.\n", + IL_DEBUG_RX(priv, "Bad CRC or FIFO: 0x%08X.\n", le32_to_cpu(rx_pkt_status)); return; } @@ -634,7 +634,7 @@ void iwl4965_rx_reply_rx(struct iwl_priv *priv, ieee80211_channel_to_frequency(le16_to_cpu(phy_res->channel), rx_status.band); rx_status.rate_idx = - iwl4965_hwrate_to_mac80211_idx(rate_n_flags, rx_status.band); + il4965_hwrate_to_mac80211_idx(rate_n_flags, rx_status.band); rx_status.flag = 0; /* TSF isn't reliable. In order to allow smooth user experience, @@ -644,10 +644,10 @@ void iwl4965_rx_reply_rx(struct iwl_priv *priv, priv->ucode_beacon_time = le32_to_cpu(phy_res->beacon_time_stamp); /* Find max signal strength (dBm) among 3 antenna/receiver chains */ - rx_status.signal = iwl4965_calc_rssi(priv, phy_res); + rx_status.signal = il4965_calc_rssi(priv, phy_res); - iwl_legacy_dbg_log_rx_data_frame(priv, len, header); - IWL_DEBUG_STATS_LIMIT(priv, "Rssi %d, TSF %llu\n", + il_dbg_log_rx_data_frame(priv, len, header); + IL_DEBUG_STATS_LIMIT(priv, "Rssi %d, TSF %llu\n", rx_status.signal, (unsigned long long)rx_status.mactime); /* @@ -679,41 +679,41 @@ void iwl4965_rx_reply_rx(struct iwl_priv *priv, if (rate_n_flags & RATE_MCS_SGI_MSK) rx_status.flag |= RX_FLAG_SHORT_GI; - iwl4965_pass_packet_to_mac80211(priv, header, len, ampdu_status, + il4965_pass_packet_to_mac80211(priv, header, len, ampdu_status, rxb, &rx_status); } /* Cache phy data (Rx signal strength, etc) for HT frame (REPLY_RX_PHY_CMD). - * This will be used later in iwl_rx_reply_rx() for REPLY_RX_MPDU_CMD. */ -void iwl4965_rx_reply_rx_phy(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) + * This will be used later in il_rx_reply_rx() for REPLY_RX_MPDU_CMD. */ +void il4965_rx_reply_rx_phy(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); priv->_4965.last_phy_res_valid = true; memcpy(&priv->_4965.last_phy_res, pkt->u.raw, - sizeof(struct iwl_rx_phy_res)); + sizeof(struct il_rx_phy_res)); } -static int iwl4965_get_channels_for_scan(struct iwl_priv *priv, +static int il4965_get_channels_for_scan(struct il_priv *priv, struct ieee80211_vif *vif, enum ieee80211_band band, u8 is_active, u8 n_probes, - struct iwl_scan_channel *scan_ch) + struct il_scan_channel *scan_ch) { struct ieee80211_channel *chan; const struct ieee80211_supported_band *sband; - const struct iwl_channel_info *ch_info; + const struct il_channel_info *ch_info; u16 passive_dwell = 0; u16 active_dwell = 0; int added, i; u16 channel; - sband = iwl_get_hw_mode(priv, band); + sband = il_get_hw_mode(priv, band); if (!sband) return 0; - active_dwell = iwl_legacy_get_active_dwell_time(priv, band, n_probes); - passive_dwell = iwl_legacy_get_passive_dwell_time(priv, band, vif); + active_dwell = il_get_active_dwell_time(priv, band, n_probes); + passive_dwell = il_get_passive_dwell_time(priv, band, vif); if (passive_dwell <= active_dwell) passive_dwell = active_dwell + 1; @@ -727,22 +727,22 @@ static int iwl4965_get_channels_for_scan(struct iwl_priv *priv, channel = chan->hw_value; scan_ch->channel = cpu_to_le16(channel); - ch_info = iwl_legacy_get_channel_info(priv, band, channel); - if (!iwl_legacy_is_channel_valid(ch_info)) { - IWL_DEBUG_SCAN(priv, + ch_info = il_get_channel_info(priv, band, channel); + if (!il_is_channel_valid(ch_info)) { + IL_DEBUG_SCAN(priv, "Channel %d is INVALID for this band.\n", channel); continue; } - if (!is_active || iwl_legacy_is_channel_passive(ch_info) || + if (!is_active || il_is_channel_passive(ch_info) || (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)) scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE; else scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE; if (n_probes) - scan_ch->type |= IWL_SCAN_PROBE_MASK(n_probes); + scan_ch->type |= IL_SCAN_PROBE_MASK(n_probes); scan_ch->active_dwell = cpu_to_le16(active_dwell); scan_ch->passive_dwell = cpu_to_le16(passive_dwell); @@ -759,7 +759,7 @@ static int iwl4965_get_channels_for_scan(struct iwl_priv *priv, else scan_ch->tx_gain = ((1 << 5) | (5 << 3)); - IWL_DEBUG_SCAN(priv, "Scanning ch=%d prob=0x%X [%s %d]\n", + IL_DEBUG_SCAN(priv, "Scanning ch=%d prob=0x%X [%s %d]\n", channel, le32_to_cpu(scan_ch->type), (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ? "ACTIVE" : "PASSIVE", @@ -770,19 +770,19 @@ static int iwl4965_get_channels_for_scan(struct iwl_priv *priv, added++; } - IWL_DEBUG_SCAN(priv, "total channels to scan %d\n", added); + IL_DEBUG_SCAN(priv, "total channels to scan %d\n", added); return added; } -int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) +int il4965_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) { - struct iwl_host_cmd cmd = { + struct il_host_cmd cmd = { .id = REPLY_SCAN_CMD, - .len = sizeof(struct iwl_scan_cmd), + .len = sizeof(struct il_scan_cmd), .flags = CMD_SIZE_HUGE, }; - struct iwl_scan_cmd *scan; - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_scan_cmd *scan; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; u32 rate_flags = 0; u16 cmd_len; u16 rx_chain = 0; @@ -799,30 +799,30 @@ int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) lockdep_assert_held(&priv->mutex); if (vif) - ctx = iwl_legacy_rxon_ctx_from_vif(vif); + ctx = il_rxon_ctx_from_vif(vif); if (!priv->scan_cmd) { - priv->scan_cmd = kmalloc(sizeof(struct iwl_scan_cmd) + - IWL_MAX_SCAN_SIZE, GFP_KERNEL); + priv->scan_cmd = kmalloc(sizeof(struct il_scan_cmd) + + IL_MAX_SCAN_SIZE, GFP_KERNEL); if (!priv->scan_cmd) { - IWL_DEBUG_SCAN(priv, + IL_DEBUG_SCAN(priv, "fail to allocate memory for scan\n"); return -ENOMEM; } } scan = priv->scan_cmd; - memset(scan, 0, sizeof(struct iwl_scan_cmd) + IWL_MAX_SCAN_SIZE); + memset(scan, 0, sizeof(struct il_scan_cmd) + IL_MAX_SCAN_SIZE); - scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH; - scan->quiet_time = IWL_ACTIVE_QUIET_TIME; + scan->quiet_plcp_th = IL_PLCP_QUIET_THRESH; + scan->quiet_time = IL_ACTIVE_QUIET_TIME; - if (iwl_legacy_is_any_associated(priv)) { + if (il_is_any_associated(priv)) { u16 interval; u32 extra; u32 suspend_time = 100; u32 scan_suspend_time = 100; - IWL_DEBUG_INFO(priv, "Scanning while associated...\n"); + IL_DEBUG_INFO(priv, "Scanning while associated...\n"); interval = vif->bss_conf.beacon_int; scan->suspend_time = 0; @@ -834,13 +834,13 @@ int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) scan_suspend_time = (extra | ((suspend_time % interval) * 1024)); scan->suspend_time = cpu_to_le32(scan_suspend_time); - IWL_DEBUG_SCAN(priv, "suspend_time 0x%X beacon interval %d\n", + IL_DEBUG_SCAN(priv, "suspend_time 0x%X beacon interval %d\n", scan_suspend_time, interval); } if (priv->scan_request->n_ssids) { int i, p = 0; - IWL_DEBUG_SCAN(priv, "Kicking off active scan\n"); + IL_DEBUG_SCAN(priv, "Kicking off active scan\n"); for (i = 0; i < priv->scan_request->n_ssids; i++) { /* always does wildcard anyway */ if (!priv->scan_request->ssids[i].ssid_len) @@ -856,7 +856,7 @@ int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) } is_active = true; } else - IWL_DEBUG_SCAN(priv, "Start passive scan.\n"); + IL_DEBUG_SCAN(priv, "Start passive scan.\n"); scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; scan->tx_cmd.sta_id = ctx->bcast_sta_id; @@ -866,21 +866,21 @@ int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) case IEEE80211_BAND_2GHZ: scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; chan_mod = le32_to_cpu( - priv->contexts[IWL_RXON_CTX_BSS].active.flags & + priv->contexts[IL_RXON_CTX_BSS].active.flags & RXON_FLG_CHANNEL_MODE_MSK) >> RXON_FLG_CHANNEL_MODE_POS; if (chan_mod == CHANNEL_MODE_PURE_40) { - rate = IWL_RATE_6M_PLCP; + rate = IL_RATE_6M_PLCP; } else { - rate = IWL_RATE_1M_PLCP; + rate = IL_RATE_1M_PLCP; rate_flags = RATE_MCS_CCK_MSK; } break; case IEEE80211_BAND_5GHZ: - rate = IWL_RATE_6M_PLCP; + rate = IL_RATE_6M_PLCP; break; default: - IWL_WARN(priv, "Invalid scan band\n"); + IL_WARN(priv, "Invalid scan band\n"); return -EIO; } @@ -898,22 +898,22 @@ int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) * need to receive during our dwell time on a channel before * sending out probes -- setting this to a huge value will * mean we never reach it, but at the same time work around - * the aforementioned issue. Thus use IWL_GOOD_CRC_TH_NEVER - * here instead of IWL_GOOD_CRC_TH_DISABLED. + * the aforementioned issue. Thus use IL_GOOD_CRC_TH_NEVER + * here instead of IL_GOOD_CRC_TH_DISABLED. */ - scan->good_CRC_th = is_active ? IWL_GOOD_CRC_TH_DEFAULT : - IWL_GOOD_CRC_TH_NEVER; + scan->good_CRC_th = is_active ? IL_GOOD_CRC_TH_DEFAULT : + IL_GOOD_CRC_TH_NEVER; band = priv->scan_band; if (priv->cfg->scan_rx_antennas[band]) rx_ant = priv->cfg->scan_rx_antennas[band]; - priv->scan_tx_ant[band] = iwl4965_toggle_tx_ant(priv, + priv->scan_tx_ant[band] = il4965_toggle_tx_ant(priv, priv->scan_tx_ant[band], scan_tx_antennas); - rate_flags |= iwl4965_ant_idx_to_flags(priv->scan_tx_ant[band]); - scan->tx_cmd.rate_n_flags = iwl4965_hw_set_rate_n_flags(rate, rate_flags); + rate_flags |= il4965_ant_idx_to_flags(priv->scan_tx_ant[band]); + scan->tx_cmd.rate_n_flags = il4965_hw_set_rate_n_flags(rate, rate_flags); /* In power save mode use one chain, otherwise use all chains */ if (test_bit(STATUS_POWER_PMI, &priv->status)) { @@ -923,10 +923,10 @@ int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) if (!active_chains) active_chains = rx_ant; - IWL_DEBUG_SCAN(priv, "chain_noise_data.active_chains: %u\n", + IL_DEBUG_SCAN(priv, "chain_noise_data.active_chains: %u\n", priv->chain_noise_data.active_chains); - rx_ant = iwl4965_first_antenna(active_chains); + rx_ant = il4965_first_antenna(active_chains); } /* MIMO is not used here, but value is required */ @@ -936,53 +936,53 @@ int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) rx_chain |= 0x1 << RXON_RX_CHAIN_DRIVER_FORCE_POS; scan->rx_chain = cpu_to_le16(rx_chain); - cmd_len = iwl_legacy_fill_probe_req(priv, + cmd_len = il_fill_probe_req(priv, (struct ieee80211_mgmt *)scan->data, vif->addr, priv->scan_request->ie, priv->scan_request->ie_len, - IWL_MAX_SCAN_SIZE - sizeof(*scan)); + IL_MAX_SCAN_SIZE - sizeof(*scan)); scan->tx_cmd.len = cpu_to_le16(cmd_len); scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK | RXON_FILTER_BCON_AWARE_MSK); - scan->channel_count = iwl4965_get_channels_for_scan(priv, vif, band, + scan->channel_count = il4965_get_channels_for_scan(priv, vif, band, is_active, n_probes, (void *)&scan->data[cmd_len]); if (scan->channel_count == 0) { - IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count); + IL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count); return -EIO; } cmd.len += le16_to_cpu(scan->tx_cmd.len) + - scan->channel_count * sizeof(struct iwl_scan_channel); + scan->channel_count * sizeof(struct il_scan_channel); cmd.data = scan; scan->len = cpu_to_le16(cmd.len); set_bit(STATUS_SCAN_HW, &priv->status); - ret = iwl_legacy_send_cmd_sync(priv, &cmd); + ret = il_send_cmd_sync(priv, &cmd); if (ret) clear_bit(STATUS_SCAN_HW, &priv->status); return ret; } -int iwl4965_manage_ibss_station(struct iwl_priv *priv, +int il4965_manage_ibss_station(struct il_priv *priv, struct ieee80211_vif *vif, bool add) { - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; if (add) - return iwl4965_add_bssid_station(priv, vif_priv->ctx, + return il4965_add_bssid_station(priv, vif_priv->ctx, vif->bss_conf.bssid, &vif_priv->ibss_bssid_sta_id); - return iwl_legacy_remove_station(priv, vif_priv->ibss_bssid_sta_id, + return il_remove_station(priv, vif_priv->ibss_bssid_sta_id, vif->bss_conf.bssid); } -void iwl4965_free_tfds_in_queue(struct iwl_priv *priv, +void il4965_free_tfds_in_queue(struct il_priv *priv, int sta_id, int tid, int freed) { lockdep_assert_held(&priv->sta_lock); @@ -990,25 +990,25 @@ void iwl4965_free_tfds_in_queue(struct iwl_priv *priv, if (priv->stations[sta_id].tid[tid].tfds_in_queue >= freed) priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; else { - IWL_DEBUG_TX(priv, "free more than tfds_in_queue (%u:%d)\n", + IL_DEBUG_TX(priv, "free more than tfds_in_queue (%u:%d)\n", priv->stations[sta_id].tid[tid].tfds_in_queue, freed); priv->stations[sta_id].tid[tid].tfds_in_queue = 0; } } -#define IWL_TX_QUEUE_MSK 0xfffff +#define IL_TX_QUEUE_MSK 0xfffff -static bool iwl4965_is_single_rx_stream(struct iwl_priv *priv) +static bool il4965_is_single_rx_stream(struct il_priv *priv) { return priv->current_ht_config.smps == IEEE80211_SMPS_STATIC || priv->current_ht_config.single_chain_sufficient; } -#define IWL_NUM_RX_CHAINS_MULTIPLE 3 -#define IWL_NUM_RX_CHAINS_SINGLE 2 -#define IWL_NUM_IDLE_CHAINS_DUAL 2 -#define IWL_NUM_IDLE_CHAINS_SINGLE 1 +#define IL_NUM_RX_CHAINS_MULTIPLE 3 +#define IL_NUM_RX_CHAINS_SINGLE 2 +#define IL_NUM_IDLE_CHAINS_DUAL 2 +#define IL_NUM_IDLE_CHAINS_SINGLE 1 /* * Determine how many receiver/antenna chains to use. @@ -1020,13 +1020,13 @@ static bool iwl4965_is_single_rx_stream(struct iwl_priv *priv) * MIMO (dual stream) requires at least 2, but works better with 3. * This does not determine *which* chains to use, just how many. */ -static int iwl4965_get_active_rx_chain_count(struct iwl_priv *priv) +static int il4965_get_active_rx_chain_count(struct il_priv *priv) { /* # of Rx chains to use when expecting MIMO. */ - if (iwl4965_is_single_rx_stream(priv)) - return IWL_NUM_RX_CHAINS_SINGLE; + if (il4965_is_single_rx_stream(priv)) + return IL_NUM_RX_CHAINS_SINGLE; else - return IWL_NUM_RX_CHAINS_MULTIPLE; + return IL_NUM_RX_CHAINS_MULTIPLE; } /* @@ -1034,13 +1034,13 @@ static int iwl4965_get_active_rx_chain_count(struct iwl_priv *priv) * multiplexing power save, use the active count for rx chain count. */ static int -iwl4965_get_idle_rx_chain_count(struct iwl_priv *priv, int active_cnt) +il4965_get_idle_rx_chain_count(struct il_priv *priv, int active_cnt) { /* # Rx chains when idling, depending on SMPS mode */ switch (priv->current_ht_config.smps) { case IEEE80211_SMPS_STATIC: case IEEE80211_SMPS_DYNAMIC: - return IWL_NUM_IDLE_CHAINS_SINGLE; + return IL_NUM_IDLE_CHAINS_SINGLE; case IEEE80211_SMPS_OFF: return active_cnt; default: @@ -1051,7 +1051,7 @@ iwl4965_get_idle_rx_chain_count(struct iwl_priv *priv, int active_cnt) } /* up to 4 chains */ -static u8 iwl4965_count_chain_bitmap(u32 chain_bitmap) +static u8 il4965_count_chain_bitmap(u32 chain_bitmap) { u8 res; res = (chain_bitmap & BIT(0)) >> 0; @@ -1062,14 +1062,14 @@ static u8 iwl4965_count_chain_bitmap(u32 chain_bitmap) } /** - * iwl4965_set_rxon_chain - Set up Rx chain usage in "staging" RXON image + * il4965_set_rxon_chain - Set up Rx chain usage in "staging" RXON image * * Selects how many and which Rx receivers/antennas/chains to use. * This should not be used for scan command ... it puts data in wrong place. */ -void iwl4965_set_rxon_chain(struct iwl_priv *priv, struct iwl_rxon_context *ctx) +void il4965_set_rxon_chain(struct il_priv *priv, struct il_rxon_context *ctx) { - bool is_single = iwl4965_is_single_rx_stream(priv); + bool is_single = il4965_is_single_rx_stream(priv); bool is_cam = !test_bit(STATUS_POWER_PMI, &priv->status); u8 idle_rx_cnt, active_rx_cnt, valid_rx_cnt; u32 active_chains; @@ -1077,7 +1077,7 @@ void iwl4965_set_rxon_chain(struct iwl_priv *priv, struct iwl_rxon_context *ctx) /* Tell uCode which antennas are actually connected. * Before first association, we assume all antennas are connected. - * Just after first association, iwl4965_chain_noise_calibration() + * Just after first association, il4965_chain_noise_calibration() * checks which antennas actually *are* connected. */ if (priv->chain_noise_data.active_chains) active_chains = priv->chain_noise_data.active_chains; @@ -1087,14 +1087,14 @@ void iwl4965_set_rxon_chain(struct iwl_priv *priv, struct iwl_rxon_context *ctx) rx_chain = active_chains << RXON_RX_CHAIN_VALID_POS; /* How many receivers should we use? */ - active_rx_cnt = iwl4965_get_active_rx_chain_count(priv); - idle_rx_cnt = iwl4965_get_idle_rx_chain_count(priv, active_rx_cnt); + active_rx_cnt = il4965_get_active_rx_chain_count(priv); + idle_rx_cnt = il4965_get_idle_rx_chain_count(priv, active_rx_cnt); /* correct rx chain count according hw settings * and chain noise calibration */ - valid_rx_cnt = iwl4965_count_chain_bitmap(active_chains); + valid_rx_cnt = il4965_count_chain_bitmap(active_chains); if (valid_rx_cnt < active_rx_cnt) active_rx_cnt = valid_rx_cnt; @@ -1106,12 +1106,12 @@ void iwl4965_set_rxon_chain(struct iwl_priv *priv, struct iwl_rxon_context *ctx) ctx->staging.rx_chain = cpu_to_le16(rx_chain); - if (!is_single && (active_rx_cnt >= IWL_NUM_RX_CHAINS_SINGLE) && is_cam) + if (!is_single && (active_rx_cnt >= IL_NUM_RX_CHAINS_SINGLE) && is_cam) ctx->staging.rx_chain |= RXON_RX_CHAIN_MIMO_FORCE_MSK; else ctx->staging.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK; - IWL_DEBUG_ASSOC(priv, "rx_chain=0x%X active=%d idle=%d\n", + IL_DEBUG_ASSOC(priv, "rx_chain=0x%X active=%d idle=%d\n", ctx->staging.rx_chain, active_rx_cnt, idle_rx_cnt); @@ -1119,7 +1119,7 @@ void iwl4965_set_rxon_chain(struct iwl_priv *priv, struct iwl_rxon_context *ctx) active_rx_cnt < idle_rx_cnt); } -u8 iwl4965_toggle_tx_ant(struct iwl_priv *priv, u8 ant, u8 valid) +u8 il4965_toggle_tx_ant(struct il_priv *priv, u8 ant, u8 valid) { int i; u8 ind = ant; @@ -1132,24 +1132,24 @@ u8 iwl4965_toggle_tx_ant(struct iwl_priv *priv, u8 ant, u8 valid) return ant; } -static const char *iwl4965_get_fh_string(int cmd) +static const char *il4965_get_fh_string(int cmd) { switch (cmd) { - IWL_CMD(FH_RSCSR_CHNL0_STTS_WPTR_REG); - IWL_CMD(FH_RSCSR_CHNL0_RBDCB_BASE_REG); - IWL_CMD(FH_RSCSR_CHNL0_WPTR); - IWL_CMD(FH_MEM_RCSR_CHNL0_CONFIG_REG); - IWL_CMD(FH_MEM_RSSR_SHARED_CTRL_REG); - IWL_CMD(FH_MEM_RSSR_RX_STATUS_REG); - IWL_CMD(FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV); - IWL_CMD(FH_TSSR_TX_STATUS_REG); - IWL_CMD(FH_TSSR_TX_ERROR_REG); + IL_CMD(FH_RSCSR_CHNL0_STTS_WPTR_REG); + IL_CMD(FH_RSCSR_CHNL0_RBDCB_BASE_REG); + IL_CMD(FH_RSCSR_CHNL0_WPTR); + IL_CMD(FH_MEM_RCSR_CHNL0_CONFIG_REG); + IL_CMD(FH_MEM_RSSR_SHARED_CTRL_REG); + IL_CMD(FH_MEM_RSSR_RX_STATUS_REG); + IL_CMD(FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV); + IL_CMD(FH_TSSR_TX_STATUS_REG); + IL_CMD(FH_TSSR_TX_ERROR_REG); default: return "UNKNOWN"; } } -int iwl4965_dump_fh(struct iwl_priv *priv, char **buf, bool display) +int il4965_dump_fh(struct il_priv *priv, char **buf, bool display) { int i; #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG @@ -1178,17 +1178,17 @@ int iwl4965_dump_fh(struct iwl_priv *priv, char **buf, bool display) for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { pos += scnprintf(*buf + pos, bufsz - pos, " %34s: 0X%08x\n", - iwl4965_get_fh_string(fh_tbl[i]), - iwl_legacy_read_direct32(priv, fh_tbl[i])); + il4965_get_fh_string(fh_tbl[i]), + il_read_direct32(priv, fh_tbl[i])); } return pos; } #endif - IWL_ERR(priv, "FH register values:\n"); + IL_ERR(priv, "FH register values:\n"); for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { - IWL_ERR(priv, " %34s: 0X%08x\n", - iwl4965_get_fh_string(fh_tbl[i]), - iwl_legacy_read_direct32(priv, fh_tbl[i])); + IL_ERR(priv, " %34s: 0X%08x\n", + il4965_get_fh_string(fh_tbl[i]), + il_read_direct32(priv, fh_tbl[i])); } return 0; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index 57ebe214e68c..a7298f5997a2 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -43,26 +43,26 @@ #define IWL4965_RS_NAME "iwl-4965-rs" #define NUM_TRY_BEFORE_ANT_TOGGLE 1 -#define IWL_NUMBER_TRY 1 -#define IWL_HT_NUMBER_TRY 3 +#define IL_NUMBER_TRY 1 +#define IL_HT_NUMBER_TRY 3 -#define IWL_RATE_MAX_WINDOW 62 /* # tx in history window */ -#define IWL_RATE_MIN_FAILURE_TH 6 /* min failures to calc tpt */ -#define IWL_RATE_MIN_SUCCESS_TH 8 /* min successes to calc tpt */ +#define IL_RATE_MAX_WINDOW 62 /* # tx in history window */ +#define IL_RATE_MIN_FAILURE_TH 6 /* min failures to calc tpt */ +#define IL_RATE_MIN_SUCCESS_TH 8 /* min successes to calc tpt */ /* max allowed rate miss before sync LQ cmd */ -#define IWL_MISSED_RATE_MAX 15 +#define IL_MISSED_RATE_MAX 15 /* max time to accum history 2 seconds */ -#define IWL_RATE_SCALE_FLUSH_INTVL (3*HZ) +#define IL_RATE_SCALE_FLUSH_INTVL (3*HZ) static u8 rs_ht_to_legacy[] = { - IWL_RATE_6M_INDEX, IWL_RATE_6M_INDEX, - IWL_RATE_6M_INDEX, IWL_RATE_6M_INDEX, - IWL_RATE_6M_INDEX, - IWL_RATE_6M_INDEX, IWL_RATE_9M_INDEX, - IWL_RATE_12M_INDEX, IWL_RATE_18M_INDEX, - IWL_RATE_24M_INDEX, IWL_RATE_36M_INDEX, - IWL_RATE_48M_INDEX, IWL_RATE_54M_INDEX + IL_RATE_6M_INDEX, IL_RATE_6M_INDEX, + IL_RATE_6M_INDEX, IL_RATE_6M_INDEX, + IL_RATE_6M_INDEX, + IL_RATE_6M_INDEX, IL_RATE_9M_INDEX, + IL_RATE_12M_INDEX, IL_RATE_18M_INDEX, + IL_RATE_24M_INDEX, IL_RATE_36M_INDEX, + IL_RATE_48M_INDEX, IL_RATE_54M_INDEX }; static const u8 ant_toggle_lookup[] = { @@ -76,43 +76,43 @@ static const u8 ant_toggle_lookup[] = { /*ANT_ABC -> */ ANT_ABC, }; -#define IWL_DECLARE_RATE_INFO(r, s, ip, in, rp, rn, pp, np) \ - [IWL_RATE_##r##M_INDEX] = { IWL_RATE_##r##M_PLCP, \ - IWL_RATE_SISO_##s##M_PLCP, \ - IWL_RATE_MIMO2_##s##M_PLCP,\ - IWL_RATE_##r##M_IEEE, \ - IWL_RATE_##ip##M_INDEX, \ - IWL_RATE_##in##M_INDEX, \ - IWL_RATE_##rp##M_INDEX, \ - IWL_RATE_##rn##M_INDEX, \ - IWL_RATE_##pp##M_INDEX, \ - IWL_RATE_##np##M_INDEX } +#define IL_DECLARE_RATE_INFO(r, s, ip, in, rp, rn, pp, np) \ + [IL_RATE_##r##M_INDEX] = { IL_RATE_##r##M_PLCP, \ + IL_RATE_SISO_##s##M_PLCP, \ + IL_RATE_MIMO2_##s##M_PLCP,\ + IL_RATE_##r##M_IEEE, \ + IL_RATE_##ip##M_INDEX, \ + IL_RATE_##in##M_INDEX, \ + IL_RATE_##rp##M_INDEX, \ + IL_RATE_##rn##M_INDEX, \ + IL_RATE_##pp##M_INDEX, \ + IL_RATE_##np##M_INDEX } /* * Parameter order: * rate, ht rate, prev rate, next rate, prev tgg rate, next tgg rate * * If there isn't a valid next or previous rate then INV is used which - * maps to IWL_RATE_INVALID + * maps to IL_RATE_INVALID * */ -const struct iwl_rate_info iwlegacy_rates[IWL_RATE_COUNT] = { - IWL_DECLARE_RATE_INFO(1, INV, INV, 2, INV, 2, INV, 2), /* 1mbps */ - IWL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ - IWL_DECLARE_RATE_INFO(5, INV, 2, 6, 2, 11, 2, 11), /*5.5mbps */ - IWL_DECLARE_RATE_INFO(11, INV, 9, 12, 9, 12, 5, 18), /* 11mbps */ - IWL_DECLARE_RATE_INFO(6, 6, 5, 9, 5, 11, 5, 11), /* 6mbps */ - IWL_DECLARE_RATE_INFO(9, 6, 6, 11, 6, 11, 5, 11), /* 9mbps */ - IWL_DECLARE_RATE_INFO(12, 12, 11, 18, 11, 18, 11, 18), /* 12mbps */ - IWL_DECLARE_RATE_INFO(18, 18, 12, 24, 12, 24, 11, 24), /* 18mbps */ - IWL_DECLARE_RATE_INFO(24, 24, 18, 36, 18, 36, 18, 36), /* 24mbps */ - IWL_DECLARE_RATE_INFO(36, 36, 24, 48, 24, 48, 24, 48), /* 36mbps */ - IWL_DECLARE_RATE_INFO(48, 48, 36, 54, 36, 54, 36, 54), /* 48mbps */ - IWL_DECLARE_RATE_INFO(54, 54, 48, INV, 48, INV, 48, INV),/* 54mbps */ - IWL_DECLARE_RATE_INFO(60, 60, 48, INV, 48, INV, 48, INV),/* 60mbps */ +const struct il_rate_info iwlegacy_rates[IL_RATE_COUNT] = { + IL_DECLARE_RATE_INFO(1, INV, INV, 2, INV, 2, INV, 2), /* 1mbps */ + IL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ + IL_DECLARE_RATE_INFO(5, INV, 2, 6, 2, 11, 2, 11), /*5.5mbps */ + IL_DECLARE_RATE_INFO(11, INV, 9, 12, 9, 12, 5, 18), /* 11mbps */ + IL_DECLARE_RATE_INFO(6, 6, 5, 9, 5, 11, 5, 11), /* 6mbps */ + IL_DECLARE_RATE_INFO(9, 6, 6, 11, 6, 11, 5, 11), /* 9mbps */ + IL_DECLARE_RATE_INFO(12, 12, 11, 18, 11, 18, 11, 18), /* 12mbps */ + IL_DECLARE_RATE_INFO(18, 18, 12, 24, 12, 24, 11, 24), /* 18mbps */ + IL_DECLARE_RATE_INFO(24, 24, 18, 36, 18, 36, 18, 36), /* 24mbps */ + IL_DECLARE_RATE_INFO(36, 36, 24, 48, 24, 48, 24, 48), /* 36mbps */ + IL_DECLARE_RATE_INFO(48, 48, 36, 54, 36, 54, 36, 54), /* 48mbps */ + IL_DECLARE_RATE_INFO(54, 54, 48, INV, 48, INV, 48, INV),/* 54mbps */ + IL_DECLARE_RATE_INFO(60, 60, 48, INV, 48, INV, 48, INV),/* 60mbps */ }; -static int iwl4965_hwrate_to_plcp_idx(u32 rate_n_flags) +static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags) { int idx = 0; @@ -120,14 +120,14 @@ static int iwl4965_hwrate_to_plcp_idx(u32 rate_n_flags) if (rate_n_flags & RATE_MCS_HT_MSK) { idx = (rate_n_flags & 0xff); - if (idx >= IWL_RATE_MIMO2_6M_PLCP) - idx = idx - IWL_RATE_MIMO2_6M_PLCP; + if (idx >= IL_RATE_MIMO2_6M_PLCP) + idx = idx - IL_RATE_MIMO2_6M_PLCP; - idx += IWL_FIRST_OFDM_RATE; + idx += IL_FIRST_OFDM_RATE; /* skip 9M not supported in ht*/ - if (idx >= IWL_RATE_9M_INDEX) + if (idx >= IL_RATE_9M_INDEX) idx += 1; - if ((idx >= IWL_FIRST_OFDM_RATE) && (idx <= IWL_LAST_OFDM_RATE)) + if ((idx >= IL_FIRST_OFDM_RATE) && (idx <= IL_LAST_OFDM_RATE)) return idx; /* legacy rate format, search for match in table */ @@ -140,20 +140,20 @@ static int iwl4965_hwrate_to_plcp_idx(u32 rate_n_flags) return -1; } -static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, +static void il4965_rs_rate_scale_perform(struct il_priv *priv, struct sk_buff *skb, struct ieee80211_sta *sta, - struct iwl_lq_sta *lq_sta); -static void iwl4965_rs_fill_link_cmd(struct iwl_priv *priv, - struct iwl_lq_sta *lq_sta, u32 rate_n_flags); -static void iwl4965_rs_stay_in_table(struct iwl_lq_sta *lq_sta, + struct il_lq_sta *lq_sta); +static void il4965_rs_fill_link_cmd(struct il_priv *priv, + struct il_lq_sta *lq_sta, u32 rate_n_flags); +static void il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search); #ifdef CONFIG_MAC80211_DEBUGFS -static void iwl4965_rs_dbgfs_set_mcs(struct iwl_lq_sta *lq_sta, +static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, u32 *rate_n_flags, int index); #else -static void iwl4965_rs_dbgfs_set_mcs(struct iwl_lq_sta *lq_sta, +static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, u32 *rate_n_flags, int index) {} #endif @@ -169,32 +169,32 @@ static void iwl4965_rs_dbgfs_set_mcs(struct iwl_lq_sta *lq_sta, * (2.4 GHz) band. */ -static s32 expected_tpt_legacy[IWL_RATE_COUNT] = { +static s32 expected_tpt_legacy[IL_RATE_COUNT] = { 7, 13, 35, 58, 40, 57, 72, 98, 121, 154, 177, 186, 0 }; -static s32 expected_tpt_siso20MHz[4][IWL_RATE_COUNT] = { +static s32 expected_tpt_siso20MHz[4][IL_RATE_COUNT] = { {0, 0, 0, 0, 42, 0, 76, 102, 124, 158, 183, 193, 202}, /* Norm */ {0, 0, 0, 0, 46, 0, 82, 110, 132, 167, 192, 202, 210}, /* SGI */ {0, 0, 0, 0, 48, 0, 93, 135, 176, 251, 319, 351, 381}, /* AGG */ {0, 0, 0, 0, 53, 0, 102, 149, 193, 275, 348, 381, 413}, /* AGG+SGI */ }; -static s32 expected_tpt_siso40MHz[4][IWL_RATE_COUNT] = { +static s32 expected_tpt_siso40MHz[4][IL_RATE_COUNT] = { {0, 0, 0, 0, 77, 0, 127, 160, 184, 220, 242, 250, 257}, /* Norm */ {0, 0, 0, 0, 83, 0, 135, 169, 193, 229, 250, 257, 264}, /* SGI */ {0, 0, 0, 0, 96, 0, 182, 259, 328, 451, 553, 598, 640}, /* AGG */ {0, 0, 0, 0, 106, 0, 199, 282, 357, 487, 593, 640, 683}, /* AGG+SGI */ }; -static s32 expected_tpt_mimo2_20MHz[4][IWL_RATE_COUNT] = { +static s32 expected_tpt_mimo2_20MHz[4][IL_RATE_COUNT] = { {0, 0, 0, 0, 74, 0, 123, 155, 179, 213, 235, 243, 250}, /* Norm */ {0, 0, 0, 0, 81, 0, 131, 164, 187, 221, 242, 250, 256}, /* SGI */ {0, 0, 0, 0, 92, 0, 175, 250, 317, 436, 534, 578, 619}, /* AGG */ {0, 0, 0, 0, 102, 0, 192, 273, 344, 470, 573, 619, 660}, /* AGG+SGI*/ }; -static s32 expected_tpt_mimo2_40MHz[4][IWL_RATE_COUNT] = { +static s32 expected_tpt_mimo2_40MHz[4][IL_RATE_COUNT] = { {0, 0, 0, 0, 123, 0, 182, 214, 235, 264, 279, 285, 289}, /* Norm */ {0, 0, 0, 0, 131, 0, 191, 222, 242, 270, 284, 289, 293}, /* SGI */ {0, 0, 0, 0, 180, 0, 327, 446, 545, 708, 828, 878, 922}, /* AGG */ @@ -202,7 +202,7 @@ static s32 expected_tpt_mimo2_40MHz[4][IWL_RATE_COUNT] = { }; /* mbps, mcs */ -static const struct iwl_rate_mcs_info iwl_rate_mcs[IWL_RATE_COUNT] = { +static const struct il_rate_mcs_info il_rate_mcs[IL_RATE_COUNT] = { { "1", "BPSK DSSS"}, { "2", "QPSK DSSS"}, {"5.5", "BPSK CCK"}, @@ -220,23 +220,23 @@ static const struct iwl_rate_mcs_info iwl_rate_mcs[IWL_RATE_COUNT] = { #define MCS_INDEX_PER_STREAM (8) -static inline u8 iwl4965_rs_extract_rate(u32 rate_n_flags) +static inline u8 il4965_rs_extract_rate(u32 rate_n_flags) { return (u8)(rate_n_flags & 0xFF); } static void -iwl4965_rs_rate_scale_clear_window(struct iwl_rate_scale_data *window) +il4965_rs_rate_scale_clear_window(struct il_rate_scale_data *window) { window->data = 0; window->success_counter = 0; - window->success_ratio = IWL_INVALID_VALUE; + window->success_ratio = IL_INVALID_VALUE; window->counter = 0; - window->average_tpt = IWL_INVALID_VALUE; + window->average_tpt = IL_INVALID_VALUE; window->stamp = 0; } -static inline u8 iwl4965_rs_is_valid_ant(u8 valid_antenna, u8 ant_type) +static inline u8 il4965_rs_is_valid_ant(u8 valid_antenna, u8 ant_type) { return (ant_type & valid_antenna) == ant_type; } @@ -246,7 +246,7 @@ static inline u8 iwl4965_rs_is_valid_ant(u8 valid_antenna, u8 ant_type) * TID_MAX_TIME_DIFF, will be deleted. */ static void -iwl4965_rs_tl_rm_old_stats(struct iwl_traffic_load *tl, u32 curr_time) +il4965_rs_tl_rm_old_stats(struct il_traffic_load *tl, u32 curr_time) { /* The oldest age we want to keep */ u32 oldest_time = curr_time - TID_MAX_TIME_DIFF; @@ -267,13 +267,13 @@ iwl4965_rs_tl_rm_old_stats(struct iwl_traffic_load *tl, u32 curr_time) * increment traffic load value for tid and also remove * any old values if passed the certain time period */ -static u8 iwl4965_rs_tl_add_packet(struct iwl_lq_sta *lq_data, +static u8 il4965_rs_tl_add_packet(struct il_lq_sta *lq_data, struct ieee80211_hdr *hdr) { u32 curr_time = jiffies_to_msecs(jiffies); u32 time_diff; s32 index; - struct iwl_traffic_load *tl = NULL; + struct il_traffic_load *tl = NULL; u8 tid; if (ieee80211_is_data_qos(hdr->frame_control)) { @@ -305,7 +305,7 @@ static u8 iwl4965_rs_tl_add_packet(struct iwl_lq_sta *lq_data, /* The history is too long: remove data that is older than */ /* TID_MAX_TIME_DIFF */ if (index >= TID_QUEUE_MAX_SIZE) - iwl4965_rs_tl_rm_old_stats(tl, curr_time); + il4965_rs_tl_rm_old_stats(tl, curr_time); index = (tl->head + index) % TID_QUEUE_MAX_SIZE; tl->packet_count[index] = tl->packet_count[index] + 1; @@ -320,12 +320,12 @@ static u8 iwl4965_rs_tl_add_packet(struct iwl_lq_sta *lq_data, /* get the traffic load value for tid */ -static u32 iwl4965_rs_tl_get_load(struct iwl_lq_sta *lq_data, u8 tid) +static u32 il4965_rs_tl_get_load(struct il_lq_sta *lq_data, u8 tid) { u32 curr_time = jiffies_to_msecs(jiffies); u32 time_diff; s32 index; - struct iwl_traffic_load *tl = NULL; + struct il_traffic_load *tl = NULL; if (tid >= TID_MAX_LOAD_COUNT) return 0; @@ -343,22 +343,22 @@ static u32 iwl4965_rs_tl_get_load(struct iwl_lq_sta *lq_data, u8 tid) /* The history is too long: remove data that is older than */ /* TID_MAX_TIME_DIFF */ if (index >= TID_QUEUE_MAX_SIZE) - iwl4965_rs_tl_rm_old_stats(tl, curr_time); + il4965_rs_tl_rm_old_stats(tl, curr_time); return tl->total; } -static int iwl4965_rs_tl_turn_on_agg_for_tid(struct iwl_priv *priv, - struct iwl_lq_sta *lq_data, u8 tid, +static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *priv, + struct il_lq_sta *lq_data, u8 tid, struct ieee80211_sta *sta) { int ret = -EAGAIN; u32 load; - load = iwl4965_rs_tl_get_load(lq_data, tid); + load = il4965_rs_tl_get_load(lq_data, tid); - if (load > IWL_AGG_LOAD_THRESHOLD) { - IWL_DEBUG_HT(priv, "Starting Tx agg: STA: %pM tid: %d\n", + if (load > IL_AGG_LOAD_THRESHOLD) { + IL_DEBUG_HT(priv, "Starting Tx agg: STA: %pM tid: %d\n", sta->addr, tid); ret = ieee80211_start_tx_ba_session(sta, tid, 5000); if (ret == -EAGAIN) { @@ -367,29 +367,29 @@ static int iwl4965_rs_tl_turn_on_agg_for_tid(struct iwl_priv *priv, * this might be cause by reloading firmware * stop the tx ba session here */ - IWL_ERR(priv, "Fail start Tx agg on tid: %d\n", + IL_ERR(priv, "Fail start Tx agg on tid: %d\n", tid); ieee80211_stop_tx_ba_session(sta, tid); } } else { - IWL_ERR(priv, "Aggregation not enabled for tid %d " + IL_ERR(priv, "Aggregation not enabled for tid %d " "because load = %u\n", tid, load); } return ret; } -static void iwl4965_rs_tl_turn_on_agg(struct iwl_priv *priv, u8 tid, - struct iwl_lq_sta *lq_data, +static void il4965_rs_tl_turn_on_agg(struct il_priv *priv, u8 tid, + struct il_lq_sta *lq_data, struct ieee80211_sta *sta) { if (tid < TID_MAX_LOAD_COUNT) - iwl4965_rs_tl_turn_on_agg_for_tid(priv, lq_data, tid, sta); + il4965_rs_tl_turn_on_agg_for_tid(priv, lq_data, tid, sta); else - IWL_ERR(priv, "tid exceeds max load count: %d/%d\n", + IL_ERR(priv, "tid exceeds max load count: %d/%d\n", tid, TID_MAX_LOAD_COUNT); } -static inline int iwl4965_get_iwl4965_num_of_ant_from_rate(u32 rate_n_flags) +static inline int il4965_get_il4965_num_of_ant_from_rate(u32 rate_n_flags) { return !!(rate_n_flags & RATE_MCS_ANT_A_MSK) + !!(rate_n_flags & RATE_MCS_ANT_B_MSK) + @@ -397,11 +397,11 @@ static inline int iwl4965_get_iwl4965_num_of_ant_from_rate(u32 rate_n_flags) } /* - * Static function to get the expected throughput from an iwl_scale_tbl_info + * Static function to get the expected throughput from an il_scale_tbl_info * that wraps a NULL pointer check */ static s32 -iwl4965_get_expected_tpt(struct iwl_scale_tbl_info *tbl, int rs_index) +il4965_get_expected_tpt(struct il_scale_tbl_info *tbl, int rs_index) { if (tbl->expected_tpt) return tbl->expected_tpt[rs_index]; @@ -409,27 +409,27 @@ iwl4965_get_expected_tpt(struct iwl_scale_tbl_info *tbl, int rs_index) } /** - * iwl4965_rs_collect_tx_data - Update the success/failure sliding window + * il4965_rs_collect_tx_data - Update the success/failure sliding window * * We keep a sliding window of the last 62 packets transmitted * at this rate. window->data contains the bitmask of successful * packets. */ -static int iwl4965_rs_collect_tx_data(struct iwl_scale_tbl_info *tbl, +static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, int scale_index, int attempts, int successes) { - struct iwl_rate_scale_data *window = NULL; - static const u64 mask = (((u64)1) << (IWL_RATE_MAX_WINDOW - 1)); + struct il_rate_scale_data *window = NULL; + static const u64 mask = (((u64)1) << (IL_RATE_MAX_WINDOW - 1)); s32 fail_count, tpt; - if (scale_index < 0 || scale_index >= IWL_RATE_COUNT) + if (scale_index < 0 || scale_index >= IL_RATE_COUNT) return -EINVAL; /* Select window for current tx bit rate */ window = &(tbl->win[scale_index]); /* Get expected throughput */ - tpt = iwl4965_get_expected_tpt(tbl, scale_index); + tpt = il4965_get_expected_tpt(tbl, scale_index); /* * Keep track of only the latest 62 tx frame attempts in this rate's @@ -440,10 +440,10 @@ static int iwl4965_rs_collect_tx_data(struct iwl_scale_tbl_info *tbl, * we keep these bitmaps!). */ while (attempts > 0) { - if (window->counter >= IWL_RATE_MAX_WINDOW) { + if (window->counter >= IL_RATE_MAX_WINDOW) { /* remove earliest */ - window->counter = IWL_RATE_MAX_WINDOW - 1; + window->counter = IL_RATE_MAX_WINDOW - 1; if (window->data & mask) { window->data &= ~mask; @@ -472,16 +472,16 @@ static int iwl4965_rs_collect_tx_data(struct iwl_scale_tbl_info *tbl, window->success_ratio = 128 * (100 * window->success_counter) / window->counter; else - window->success_ratio = IWL_INVALID_VALUE; + window->success_ratio = IL_INVALID_VALUE; fail_count = window->counter - window->success_counter; /* Calculate average throughput, if we have enough history. */ - if ((fail_count >= IWL_RATE_MIN_FAILURE_TH) || - (window->success_counter >= IWL_RATE_MIN_SUCCESS_TH)) + if ((fail_count >= IL_RATE_MIN_FAILURE_TH) || + (window->success_counter >= IL_RATE_MIN_SUCCESS_TH)) window->average_tpt = (window->success_ratio * tpt + 64) / 128; else - window->average_tpt = IWL_INVALID_VALUE; + window->average_tpt = IL_INVALID_VALUE; /* Tag this window as having been updated */ window->stamp = jiffies; @@ -492,21 +492,21 @@ static int iwl4965_rs_collect_tx_data(struct iwl_scale_tbl_info *tbl, /* * Fill uCode API rate_n_flags field, based on "search" or "active" table. */ -static u32 iwl4965_rate_n_flags_from_tbl(struct iwl_priv *priv, - struct iwl_scale_tbl_info *tbl, +static u32 il4965_rate_n_flags_from_tbl(struct il_priv *priv, + struct il_scale_tbl_info *tbl, int index, u8 use_green) { u32 rate_n_flags = 0; if (is_legacy(tbl->lq_type)) { rate_n_flags = iwlegacy_rates[index].plcp; - if (index >= IWL_FIRST_CCK_RATE && index <= IWL_LAST_CCK_RATE) + if (index >= IL_FIRST_CCK_RATE && index <= IL_LAST_CCK_RATE) rate_n_flags |= RATE_MCS_CCK_MSK; } else if (is_Ht(tbl->lq_type)) { - if (index > IWL_LAST_OFDM_RATE) { - IWL_ERR(priv, "Invalid HT rate index %d\n", index); - index = IWL_LAST_OFDM_RATE; + if (index > IL_LAST_OFDM_RATE) { + IL_ERR(priv, "Invalid HT rate index %d\n", index); + index = IL_LAST_OFDM_RATE; } rate_n_flags = RATE_MCS_HT_MSK; @@ -515,7 +515,7 @@ static u32 iwl4965_rate_n_flags_from_tbl(struct iwl_priv *priv, else rate_n_flags |= iwlegacy_rates[index].plcp_mimo2; } else { - IWL_ERR(priv, "Invalid tbl->lq_type %d\n", tbl->lq_type); + IL_ERR(priv, "Invalid tbl->lq_type %d\n", tbl->lq_type); } rate_n_flags |= ((tbl->ant_type << RATE_MCS_ANT_POS) & @@ -535,7 +535,7 @@ static u32 iwl4965_rate_n_flags_from_tbl(struct iwl_priv *priv, rate_n_flags |= RATE_MCS_GF_MSK; if (is_siso(tbl->lq_type) && tbl->is_SGI) { rate_n_flags &= ~RATE_MCS_SGI_MSK; - IWL_ERR(priv, "GF was set with SGI:SISO\n"); + IL_ERR(priv, "GF was set with SGI:SISO\n"); } } } @@ -546,19 +546,19 @@ static u32 iwl4965_rate_n_flags_from_tbl(struct iwl_priv *priv, * Interpret uCode API's rate_n_flags format, * fill "search" or "active" tx mode table. */ -static int iwl4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, +static int il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, enum ieee80211_band band, - struct iwl_scale_tbl_info *tbl, + struct il_scale_tbl_info *tbl, int *rate_idx) { u32 ant_msk = (rate_n_flags & RATE_MCS_ANT_ABC_MSK); - u8 iwl4965_num_of_ant = iwl4965_get_iwl4965_num_of_ant_from_rate(rate_n_flags); + u8 il4965_num_of_ant = il4965_get_il4965_num_of_ant_from_rate(rate_n_flags); u8 mcs; - memset(tbl, 0, sizeof(struct iwl_scale_tbl_info)); - *rate_idx = iwl4965_hwrate_to_plcp_idx(rate_n_flags); + memset(tbl, 0, sizeof(struct il_scale_tbl_info)); + *rate_idx = il4965_hwrate_to_plcp_idx(rate_n_flags); - if (*rate_idx == IWL_RATE_INVALID) { + if (*rate_idx == IL_RATE_INVALID) { *rate_idx = -1; return -EINVAL; } @@ -567,11 +567,11 @@ static int iwl4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, tbl->is_dup = 0; tbl->ant_type = (ant_msk >> RATE_MCS_ANT_POS); tbl->lq_type = LQ_NONE; - tbl->max_search = IWL_MAX_SEARCH; + tbl->max_search = IL_MAX_SEARCH; /* legacy rate format */ if (!(rate_n_flags & RATE_MCS_HT_MSK)) { - if (iwl4965_num_of_ant == 1) { + if (il4965_num_of_ant == 1) { if (band == IEEE80211_BAND_5GHZ) tbl->lq_type = LQ_A; else @@ -589,15 +589,15 @@ static int iwl4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, if (rate_n_flags & RATE_MCS_DUP_MSK) tbl->is_dup = 1; - mcs = iwl4965_rs_extract_rate(rate_n_flags); + mcs = il4965_rs_extract_rate(rate_n_flags); /* SISO */ - if (mcs <= IWL_RATE_SISO_60M_PLCP) { - if (iwl4965_num_of_ant == 1) + if (mcs <= IL_RATE_SISO_60M_PLCP) { + if (il4965_num_of_ant == 1) tbl->lq_type = LQ_SISO; /*else NONE*/ /* MIMO2 */ } else { - if (iwl4965_num_of_ant == 2) + if (il4965_num_of_ant == 2) tbl->lq_type = LQ_MIMO2; } } @@ -606,21 +606,21 @@ static int iwl4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, /* switch to another antenna/antennas and return 1 */ /* if no other valid antenna found, return 0 */ -static int iwl4965_rs_toggle_antenna(u32 valid_ant, u32 *rate_n_flags, - struct iwl_scale_tbl_info *tbl) +static int il4965_rs_toggle_antenna(u32 valid_ant, u32 *rate_n_flags, + struct il_scale_tbl_info *tbl) { u8 new_ant_type; if (!tbl->ant_type || tbl->ant_type > ANT_ABC) return 0; - if (!iwl4965_rs_is_valid_ant(valid_ant, tbl->ant_type)) + if (!il4965_rs_is_valid_ant(valid_ant, tbl->ant_type)) return 0; new_ant_type = ant_toggle_lookup[tbl->ant_type]; while ((new_ant_type != tbl->ant_type) && - !iwl4965_rs_is_valid_ant(valid_ant, new_ant_type)) + !il4965_rs_is_valid_ant(valid_ant, new_ant_type)) new_ant_type = ant_toggle_lookup[new_ant_type]; if (new_ant_type == tbl->ant_type) @@ -636,25 +636,25 @@ static int iwl4965_rs_toggle_antenna(u32 valid_ant, u32 *rate_n_flags, * Green-field mode is valid if the station supports it and * there are no non-GF stations present in the BSS. */ -static bool iwl4965_rs_use_green(struct ieee80211_sta *sta) +static bool il4965_rs_use_green(struct ieee80211_sta *sta) { - struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; - struct iwl_rxon_context *ctx = sta_priv->common.ctx; + struct il_station_priv *sta_priv = (void *)sta->drv_priv; + struct il_rxon_context *ctx = sta_priv->common.ctx; return (sta->ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD) && !(ctx->ht.non_gf_sta_present); } /** - * iwl4965_rs_get_supported_rates - get the available rates + * il4965_rs_get_supported_rates - get the available rates * * if management frame or broadcast frame only return * basic available rates. * */ -static u16 iwl4965_rs_get_supported_rates(struct iwl_lq_sta *lq_sta, +static u16 il4965_rs_get_supported_rates(struct il_lq_sta *lq_sta, struct ieee80211_hdr *hdr, - enum iwl_table_type rate_type) + enum il_table_type rate_type) { if (is_legacy(rate_type)) { return lq_sta->active_legacy_rate; @@ -667,11 +667,11 @@ static u16 iwl4965_rs_get_supported_rates(struct iwl_lq_sta *lq_sta, } static u16 -iwl4965_rs_get_adjacent_rate(struct iwl_priv *priv, u8 index, u16 rate_mask, +il4965_rs_get_adjacent_rate(struct il_priv *priv, u8 index, u16 rate_mask, int rate_type) { - u8 high = IWL_RATE_INVALID; - u8 low = IWL_RATE_INVALID; + u8 high = IL_RATE_INVALID; + u8 low = IL_RATE_INVALID; /* 802.11A or ht walks to the next literal adjacent rate in * the rate table */ @@ -690,7 +690,7 @@ iwl4965_rs_get_adjacent_rate(struct iwl_priv *priv, u8 index, u16 rate_mask, /* Find the next rate that is in the rate mask */ i = index + 1; - for (mask = (1 << i); i < IWL_RATE_COUNT; i++, mask <<= 1) { + for (mask = (1 << i); i < IL_RATE_COUNT; i++, mask <<= 1) { if (rate_mask & mask) { high = i; break; @@ -701,30 +701,30 @@ iwl4965_rs_get_adjacent_rate(struct iwl_priv *priv, u8 index, u16 rate_mask, } low = index; - while (low != IWL_RATE_INVALID) { + while (low != IL_RATE_INVALID) { low = iwlegacy_rates[low].prev_rs; - if (low == IWL_RATE_INVALID) + if (low == IL_RATE_INVALID) break; if (rate_mask & (1 << low)) break; - IWL_DEBUG_RATE(priv, "Skipping masked lower rate: %d\n", low); + IL_DEBUG_RATE(priv, "Skipping masked lower rate: %d\n", low); } high = index; - while (high != IWL_RATE_INVALID) { + while (high != IL_RATE_INVALID) { high = iwlegacy_rates[high].next_rs; - if (high == IWL_RATE_INVALID) + if (high == IL_RATE_INVALID) break; if (rate_mask & (1 << high)) break; - IWL_DEBUG_RATE(priv, "Skipping masked higher rate: %d\n", high); + IL_DEBUG_RATE(priv, "Skipping masked higher rate: %d\n", high); } return (high << 8) | low; } -static u32 iwl4965_rs_get_lower_rate(struct iwl_lq_sta *lq_sta, - struct iwl_scale_tbl_info *tbl, +static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, + struct il_scale_tbl_info *tbl, u8 scale_index, u8 ht_possible) { s32 low; @@ -732,7 +732,7 @@ static u32 iwl4965_rs_get_lower_rate(struct iwl_lq_sta *lq_sta, u16 high_low; u8 switch_to_legacy = 0; u8 is_green = lq_sta->is_green; - struct iwl_priv *priv = lq_sta->drv; + struct il_priv *priv = lq_sta->drv; /* check if we need to switch from HT to legacy rates. * assumption is that mandatory rates (1Mbps or 6Mbps) @@ -745,23 +745,23 @@ static u32 iwl4965_rs_get_lower_rate(struct iwl_lq_sta *lq_sta, else tbl->lq_type = LQ_G; - if (iwl4965_num_of_ant(tbl->ant_type) > 1) + if (il4965_num_of_ant(tbl->ant_type) > 1) tbl->ant_type = - iwl4965_first_antenna(priv->hw_params.valid_tx_ant); + il4965_first_antenna(priv->hw_params.valid_tx_ant); tbl->is_ht40 = 0; tbl->is_SGI = 0; - tbl->max_search = IWL_MAX_SEARCH; + tbl->max_search = IL_MAX_SEARCH; } - rate_mask = iwl4965_rs_get_supported_rates(lq_sta, NULL, tbl->lq_type); + rate_mask = il4965_rs_get_supported_rates(lq_sta, NULL, tbl->lq_type); /* Mask with station rate restriction */ if (is_legacy(tbl->lq_type)) { /* supp_rates has no CCK bits in A mode */ if (lq_sta->band == IEEE80211_BAND_5GHZ) rate_mask = (u16)(rate_mask & - (lq_sta->supp_rates << IWL_FIRST_OFDM_RATE)); + (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); else rate_mask = (u16)(rate_mask & lq_sta->supp_rates); } @@ -772,23 +772,23 @@ static u32 iwl4965_rs_get_lower_rate(struct iwl_lq_sta *lq_sta, goto out; } - high_low = iwl4965_rs_get_adjacent_rate(lq_sta->drv, + high_low = il4965_rs_get_adjacent_rate(lq_sta->drv, scale_index, rate_mask, tbl->lq_type); low = high_low & 0xff; - if (low == IWL_RATE_INVALID) + if (low == IL_RATE_INVALID) low = scale_index; out: - return iwl4965_rate_n_flags_from_tbl(lq_sta->drv, tbl, low, is_green); + return il4965_rate_n_flags_from_tbl(lq_sta->drv, tbl, low, is_green); } /* * Simple function to compare two rate scale table types */ -static bool iwl4965_table_type_matches(struct iwl_scale_tbl_info *a, - struct iwl_scale_tbl_info *b) +static bool il4965_table_type_matches(struct il_scale_tbl_info *a, + struct il_scale_tbl_info *b) { return (a->lq_type == b->lq_type) && (a->ant_type == b->ant_type) && (a->is_SGI == b->is_SGI); @@ -798,34 +798,34 @@ static bool iwl4965_table_type_matches(struct iwl_scale_tbl_info *a, * mac80211 sends us Tx status */ static void -iwl4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, +il4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, struct ieee80211_sta *sta, void *priv_sta, struct sk_buff *skb) { int legacy_success; int retries; int rs_index, mac_index, i; - struct iwl_lq_sta *lq_sta = priv_sta; - struct iwl_link_quality_cmd *table; + struct il_lq_sta *lq_sta = priv_sta; + struct il_link_quality_cmd *table; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - struct iwl_priv *priv = (struct iwl_priv *)priv_r; + struct il_priv *priv = (struct il_priv *)priv_r; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); enum mac80211_rate_control_flags mac_flags; u32 tx_rate; - struct iwl_scale_tbl_info tbl_type; - struct iwl_scale_tbl_info *curr_tbl, *other_tbl, *tmp_tbl; - struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; - struct iwl_rxon_context *ctx = sta_priv->common.ctx; + struct il_scale_tbl_info tbl_type; + struct il_scale_tbl_info *curr_tbl, *other_tbl, *tmp_tbl; + struct il_station_priv *sta_priv = (void *)sta->drv_priv; + struct il_rxon_context *ctx = sta_priv->common.ctx; - IWL_DEBUG_RATE_LIMIT(priv, + IL_DEBUG_RATE_LIMIT(priv, "get frame ack response, update rate scale window\n"); /* Treat uninitialized rate scaling data same as non-existing. */ if (!lq_sta) { - IWL_DEBUG_RATE(priv, "Station rate scaling not created yet.\n"); + IL_DEBUG_RATE(priv, "Station rate scaling not created yet.\n"); return; } else if (!lq_sta->drv) { - IWL_DEBUG_RATE(priv, "Rate scaling not initialized yet.\n"); + IL_DEBUG_RATE(priv, "Rate scaling not initialized yet.\n"); return; } @@ -848,23 +848,23 @@ iwl4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, */ table = &lq_sta->lq; tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); - iwl4965_rs_get_tbl_info_from_mcs(tx_rate, + il4965_rs_get_tbl_info_from_mcs(tx_rate, priv->band, &tbl_type, &rs_index); if (priv->band == IEEE80211_BAND_5GHZ) - rs_index -= IWL_FIRST_OFDM_RATE; + rs_index -= IL_FIRST_OFDM_RATE; mac_flags = info->status.rates[0].flags; mac_index = info->status.rates[0].idx; /* For HT packets, map MCS to PLCP */ if (mac_flags & IEEE80211_TX_RC_MCS) { mac_index &= RATE_MCS_CODE_MSK; /* Remove # of streams */ - if (mac_index >= (IWL_RATE_9M_INDEX - IWL_FIRST_OFDM_RATE)) + if (mac_index >= (IL_RATE_9M_INDEX - IL_FIRST_OFDM_RATE)) mac_index++; /* * mac80211 HT index is always zero-indexed; we need to move * HT OFDM rates after CCK rates in 2.4 GHz band */ if (priv->band == IEEE80211_BAND_2GHZ) - mac_index += IWL_FIRST_OFDM_RATE; + mac_index += IL_FIRST_OFDM_RATE; } /* Here we actually compare this rate to the latest LQ command */ if ((mac_index < 0) || @@ -880,18 +880,18 @@ iwl4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, (!!(tx_rate & RATE_MCS_GF_MSK) != !!(mac_flags & IEEE80211_TX_RC_GREEN_FIELD)) || (rs_index != mac_index)) { - IWL_DEBUG_RATE(priv, + IL_DEBUG_RATE(priv, "initial rate %d does not match %d (0x%x)\n", mac_index, rs_index, tx_rate); /* * Since rates mis-match, the last LQ command may have failed. - * After IWL_MISSED_RATE_MAX mis-matches, resync the uCode with + * After IL_MISSED_RATE_MAX mis-matches, resync the uCode with * ... driver. */ lq_sta->missed_rate_counter++; - if (lq_sta->missed_rate_counter > IWL_MISSED_RATE_MAX) { + if (lq_sta->missed_rate_counter > IL_MISSED_RATE_MAX) { lq_sta->missed_rate_counter = 0; - iwl_legacy_send_lq_cmd(priv, ctx, &lq_sta->lq, + il_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_ASYNC, false); } /* Regardless, ignore this status info for outdated rate */ @@ -901,30 +901,30 @@ iwl4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, lq_sta->missed_rate_counter = 0; /* Figure out if rate scale algorithm is in active or search table */ - if (iwl4965_table_type_matches(&tbl_type, + if (il4965_table_type_matches(&tbl_type, &(lq_sta->lq_info[lq_sta->active_tbl]))) { curr_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); other_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); - } else if (iwl4965_table_type_matches(&tbl_type, + } else if (il4965_table_type_matches(&tbl_type, &lq_sta->lq_info[1 - lq_sta->active_tbl])) { curr_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); other_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); } else { - IWL_DEBUG_RATE(priv, + IL_DEBUG_RATE(priv, "Neither active nor search matches tx rate\n"); tmp_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - IWL_DEBUG_RATE(priv, "active- lq:%x, ant:%x, SGI:%d\n", + IL_DEBUG_RATE(priv, "active- lq:%x, ant:%x, SGI:%d\n", tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); tmp_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); - IWL_DEBUG_RATE(priv, "search- lq:%x, ant:%x, SGI:%d\n", + IL_DEBUG_RATE(priv, "search- lq:%x, ant:%x, SGI:%d\n", tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); - IWL_DEBUG_RATE(priv, "actual- lq:%x, ant:%x, SGI:%d\n", + IL_DEBUG_RATE(priv, "actual- lq:%x, ant:%x, SGI:%d\n", tbl_type.lq_type, tbl_type.ant_type, tbl_type.is_SGI); /* * no matching table found, let's by-pass the data collection * and continue to perform rate scale to find the rate table */ - iwl4965_rs_stay_in_table(lq_sta, true); + il4965_rs_stay_in_table(lq_sta, true); goto done; } @@ -937,9 +937,9 @@ iwl4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, */ if (info->flags & IEEE80211_TX_STAT_AMPDU) { tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); - iwl4965_rs_get_tbl_info_from_mcs(tx_rate, priv->band, &tbl_type, + il4965_rs_get_tbl_info_from_mcs(tx_rate, priv->band, &tbl_type, &rs_index); - iwl4965_rs_collect_tx_data(curr_tbl, rs_index, + il4965_rs_collect_tx_data(curr_tbl, rs_index, info->status.ampdu_len, info->status.ampdu_ack_len); @@ -962,20 +962,20 @@ iwl4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, /* Collect data for each rate used during failed TX attempts */ for (i = 0; i <= retries; ++i) { tx_rate = le32_to_cpu(table->rs_table[i].rate_n_flags); - iwl4965_rs_get_tbl_info_from_mcs(tx_rate, priv->band, + il4965_rs_get_tbl_info_from_mcs(tx_rate, priv->band, &tbl_type, &rs_index); /* * Only collect stats if retried rate is in the same RS * table as active/search. */ - if (iwl4965_table_type_matches(&tbl_type, curr_tbl)) + if (il4965_table_type_matches(&tbl_type, curr_tbl)) tmp_tbl = curr_tbl; - else if (iwl4965_table_type_matches(&tbl_type, + else if (il4965_table_type_matches(&tbl_type, other_tbl)) tmp_tbl = other_tbl; else continue; - iwl4965_rs_collect_tx_data(tmp_tbl, rs_index, 1, + il4965_rs_collect_tx_data(tmp_tbl, rs_index, 1, i < retries ? 0 : legacy_success); } @@ -990,7 +990,7 @@ iwl4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, done: /* See if there's a better rate or modulation mode to try. */ if (sta && sta->supp_rates[sband->band]) - iwl4965_rs_rate_scale_perform(priv, skb, sta, lq_sta); + il4965_rs_rate_scale_perform(priv, skb, sta, lq_sta); } /* @@ -1001,19 +1001,19 @@ done: * These control how long we stay using same modulation mode before * searching for a new mode. */ -static void iwl4965_rs_set_stay_in_table(struct iwl_priv *priv, u8 is_legacy, - struct iwl_lq_sta *lq_sta) +static void il4965_rs_set_stay_in_table(struct il_priv *priv, u8 is_legacy, + struct il_lq_sta *lq_sta) { - IWL_DEBUG_RATE(priv, "we are staying in the same table\n"); + IL_DEBUG_RATE(priv, "we are staying in the same table\n"); lq_sta->stay_in_tbl = 1; /* only place this gets set */ if (is_legacy) { - lq_sta->table_count_limit = IWL_LEGACY_TABLE_COUNT; - lq_sta->max_failure_limit = IWL_LEGACY_FAILURE_LIMIT; - lq_sta->max_success_limit = IWL_LEGACY_SUCCESS_LIMIT; + lq_sta->table_count_limit = IL_LEGACY_TABLE_COUNT; + lq_sta->max_failure_limit = IL_LEGACY_FAILURE_LIMIT; + lq_sta->max_success_limit = IL_LEGACY_SUCCESS_LIMIT; } else { - lq_sta->table_count_limit = IWL_NONE_LEGACY_TABLE_COUNT; - lq_sta->max_failure_limit = IWL_NONE_LEGACY_FAILURE_LIMIT; - lq_sta->max_success_limit = IWL_NONE_LEGACY_SUCCESS_LIMIT; + lq_sta->table_count_limit = IL_NONE_LEGACY_TABLE_COUNT; + lq_sta->max_failure_limit = IL_NONE_LEGACY_FAILURE_LIMIT; + lq_sta->max_success_limit = IL_NONE_LEGACY_SUCCESS_LIMIT; } lq_sta->table_count = 0; lq_sta->total_failed = 0; @@ -1025,11 +1025,11 @@ static void iwl4965_rs_set_stay_in_table(struct iwl_priv *priv, u8 is_legacy, /* * Find correct throughput table for given mode of modulation */ -static void iwl4965_rs_set_expected_tpt_table(struct iwl_lq_sta *lq_sta, - struct iwl_scale_tbl_info *tbl) +static void il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, + struct il_scale_tbl_info *tbl) { /* Used to choose among HT tables */ - s32 (*ht_tbl_pointer)[IWL_RATE_COUNT]; + s32 (*ht_tbl_pointer)[IL_RATE_COUNT]; /* Check for invalid LQ type */ if (WARN_ON_ONCE(!is_legacy(tbl->lq_type) && !is_Ht(tbl->lq_type))) { @@ -1077,13 +1077,13 @@ static void iwl4965_rs_set_expected_tpt_table(struct iwl_lq_sta *lq_sta, * to decrease to match "active" throughput. When moving from MIMO to SISO, * bit rate will typically need to increase, but not if performance was bad. */ -static s32 iwl4965_rs_get_best_rate(struct iwl_priv *priv, - struct iwl_lq_sta *lq_sta, - struct iwl_scale_tbl_info *tbl, /* "search" */ +static s32 il4965_rs_get_best_rate(struct il_priv *priv, + struct il_lq_sta *lq_sta, + struct il_scale_tbl_info *tbl, /* "search" */ u16 rate_mask, s8 index) { /* "active" values */ - struct iwl_scale_tbl_info *active_tbl = + struct il_scale_tbl_info *active_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); s32 active_sr = active_tbl->win[index].success_ratio; s32 active_tpt = active_tbl->expected_tpt[index]; @@ -1095,10 +1095,10 @@ static s32 iwl4965_rs_get_best_rate(struct iwl_priv *priv, u16 high_low; s8 rate = index; - new_rate = high = low = start_hi = IWL_RATE_INVALID; + new_rate = high = low = start_hi = IL_RATE_INVALID; for (; ;) { - high_low = iwl4965_rs_get_adjacent_rate(priv, rate, rate_mask, + high_low = il4965_rs_get_adjacent_rate(priv, rate, rate_mask, tbl->lq_type); low = high_low & 0xff; @@ -1120,16 +1120,16 @@ static s32 iwl4965_rs_get_best_rate(struct iwl_priv *priv, * "active" throughput (under perfect conditions). */ if ((((100 * tpt_tbl[rate]) > lq_sta->last_tpt) && - ((active_sr > IWL_RATE_DECREASE_TH) && - (active_sr <= IWL_RATE_HIGH_TH) && + ((active_sr > IL_RATE_DECREASE_TH) && + (active_sr <= IL_RATE_HIGH_TH) && (tpt_tbl[rate] <= active_tpt))) || - ((active_sr >= IWL_RATE_SCALE_SWITCH) && + ((active_sr >= IL_RATE_SCALE_SWITCH) && (tpt_tbl[rate] > active_tpt))) { /* (2nd or later pass) * If we've already tried to raise the rate, and are * now trying to lower it, use the higher rate. */ - if (start_hi != IWL_RATE_INVALID) { + if (start_hi != IL_RATE_INVALID) { new_rate = start_hi; break; } @@ -1137,7 +1137,7 @@ static s32 iwl4965_rs_get_best_rate(struct iwl_priv *priv, new_rate = rate; /* Loop again with lower rate */ - if (low != IWL_RATE_INVALID) + if (low != IL_RATE_INVALID) rate = low; /* Lower rate not available, use the original */ @@ -1149,11 +1149,11 @@ static s32 iwl4965_rs_get_best_rate(struct iwl_priv *priv, /* (2nd or later pass) * If we've already tried to lower the rate, and are * now trying to raise it, use the lower rate. */ - if (new_rate != IWL_RATE_INVALID) + if (new_rate != IL_RATE_INVALID) break; /* Loop again with higher rate */ - else if (high != IWL_RATE_INVALID) { + else if (high != IL_RATE_INVALID) { start_hi = high; rate = high; @@ -1171,17 +1171,17 @@ static s32 iwl4965_rs_get_best_rate(struct iwl_priv *priv, /* * Set up search table for MIMO2 */ -static int iwl4965_rs_switch_to_mimo2(struct iwl_priv *priv, - struct iwl_lq_sta *lq_sta, +static int il4965_rs_switch_to_mimo2(struct il_priv *priv, + struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, - struct iwl_scale_tbl_info *tbl, int index) + struct il_scale_tbl_info *tbl, int index) { u16 rate_mask; s32 rate; s8 is_green = lq_sta->is_green; - struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; - struct iwl_rxon_context *ctx = sta_priv->common.ctx; + struct il_station_priv *sta_priv = (void *)sta->drv_priv; + struct il_rxon_context *ctx = sta_priv->common.ctx; if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) return -1; @@ -1194,35 +1194,35 @@ static int iwl4965_rs_switch_to_mimo2(struct iwl_priv *priv, if (priv->hw_params.tx_chains_num < 2) return -1; - IWL_DEBUG_RATE(priv, "LQ: try to switch to MIMO2\n"); + IL_DEBUG_RATE(priv, "LQ: try to switch to MIMO2\n"); tbl->lq_type = LQ_MIMO2; tbl->is_dup = lq_sta->is_dup; tbl->action = 0; - tbl->max_search = IWL_MAX_SEARCH; + tbl->max_search = IL_MAX_SEARCH; rate_mask = lq_sta->active_mimo2_rate; - if (iwl_legacy_is_ht40_tx_allowed(priv, ctx, &sta->ht_cap)) + if (il_is_ht40_tx_allowed(priv, ctx, &sta->ht_cap)) tbl->is_ht40 = 1; else tbl->is_ht40 = 0; - iwl4965_rs_set_expected_tpt_table(lq_sta, tbl); + il4965_rs_set_expected_tpt_table(lq_sta, tbl); - rate = iwl4965_rs_get_best_rate(priv, lq_sta, tbl, rate_mask, index); + rate = il4965_rs_get_best_rate(priv, lq_sta, tbl, rate_mask, index); - IWL_DEBUG_RATE(priv, "LQ: MIMO2 best rate %d mask %X\n", + IL_DEBUG_RATE(priv, "LQ: MIMO2 best rate %d mask %X\n", rate, rate_mask); - if ((rate == IWL_RATE_INVALID) || !((1 << rate) & rate_mask)) { - IWL_DEBUG_RATE(priv, + if ((rate == IL_RATE_INVALID) || !((1 << rate) & rate_mask)) { + IL_DEBUG_RATE(priv, "Can't switch with index %d rate mask %x\n", rate, rate_mask); return -1; } - tbl->current_rate = iwl4965_rate_n_flags_from_tbl(priv, + tbl->current_rate = il4965_rate_n_flags_from_tbl(priv, tbl, rate, is_green); - IWL_DEBUG_RATE(priv, "LQ: Switch to new mcs %X index is green %X\n", + IL_DEBUG_RATE(priv, "LQ: Switch to new mcs %X index is green %X\n", tbl->current_rate, is_green); return 0; } @@ -1230,30 +1230,30 @@ static int iwl4965_rs_switch_to_mimo2(struct iwl_priv *priv, /* * Set up search table for SISO */ -static int iwl4965_rs_switch_to_siso(struct iwl_priv *priv, - struct iwl_lq_sta *lq_sta, +static int il4965_rs_switch_to_siso(struct il_priv *priv, + struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, - struct iwl_scale_tbl_info *tbl, int index) + struct il_scale_tbl_info *tbl, int index) { u16 rate_mask; u8 is_green = lq_sta->is_green; s32 rate; - struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; - struct iwl_rxon_context *ctx = sta_priv->common.ctx; + struct il_station_priv *sta_priv = (void *)sta->drv_priv; + struct il_rxon_context *ctx = sta_priv->common.ctx; if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) return -1; - IWL_DEBUG_RATE(priv, "LQ: try to switch to SISO\n"); + IL_DEBUG_RATE(priv, "LQ: try to switch to SISO\n"); tbl->is_dup = lq_sta->is_dup; tbl->lq_type = LQ_SISO; tbl->action = 0; - tbl->max_search = IWL_MAX_SEARCH; + tbl->max_search = IL_MAX_SEARCH; rate_mask = lq_sta->active_siso_rate; - if (iwl_legacy_is_ht40_tx_allowed(priv, ctx, &sta->ht_cap)) + if (il_is_ht40_tx_allowed(priv, ctx, &sta->ht_cap)) tbl->is_ht40 = 1; else tbl->is_ht40 = 0; @@ -1261,19 +1261,19 @@ static int iwl4965_rs_switch_to_siso(struct iwl_priv *priv, if (is_green) tbl->is_SGI = 0; /*11n spec: no SGI in SISO+Greenfield*/ - iwl4965_rs_set_expected_tpt_table(lq_sta, tbl); - rate = iwl4965_rs_get_best_rate(priv, lq_sta, tbl, rate_mask, index); + il4965_rs_set_expected_tpt_table(lq_sta, tbl); + rate = il4965_rs_get_best_rate(priv, lq_sta, tbl, rate_mask, index); - IWL_DEBUG_RATE(priv, "LQ: get best rate %d mask %X\n", rate, rate_mask); - if ((rate == IWL_RATE_INVALID) || !((1 << rate) & rate_mask)) { - IWL_DEBUG_RATE(priv, + IL_DEBUG_RATE(priv, "LQ: get best rate %d mask %X\n", rate, rate_mask); + if ((rate == IL_RATE_INVALID) || !((1 << rate) & rate_mask)) { + IL_DEBUG_RATE(priv, "can not switch with index %d rate mask %x\n", rate, rate_mask); return -1; } - tbl->current_rate = iwl4965_rate_n_flags_from_tbl(priv, + tbl->current_rate = il4965_rate_n_flags_from_tbl(priv, tbl, rate, is_green); - IWL_DEBUG_RATE(priv, "LQ: Switch to new mcs %X index is green %X\n", + IL_DEBUG_RATE(priv, "LQ: Switch to new mcs %X index is green %X\n", tbl->current_rate, is_green); return 0; } @@ -1281,62 +1281,62 @@ static int iwl4965_rs_switch_to_siso(struct iwl_priv *priv, /* * Try to switch to new modulation mode from legacy */ -static int iwl4965_rs_move_legacy_other(struct iwl_priv *priv, - struct iwl_lq_sta *lq_sta, +static int il4965_rs_move_legacy_other(struct il_priv *priv, + struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, int index) { - struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - struct iwl_scale_tbl_info *search_tbl = + struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); + struct il_scale_tbl_info *search_tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - struct iwl_rate_scale_data *window = &(tbl->win[index]); - u32 sz = (sizeof(struct iwl_scale_tbl_info) - - (sizeof(struct iwl_rate_scale_data) * IWL_RATE_COUNT)); + struct il_rate_scale_data *window = &(tbl->win[index]); + u32 sz = (sizeof(struct il_scale_tbl_info) - + (sizeof(struct il_rate_scale_data) * IL_RATE_COUNT)); u8 start_action; u8 valid_tx_ant = priv->hw_params.valid_tx_ant; u8 tx_chains_num = priv->hw_params.tx_chains_num; int ret = 0; u8 update_search_tbl_counter = 0; - tbl->action = IWL_LEGACY_SWITCH_SISO; + tbl->action = IL_LEGACY_SWITCH_SISO; start_action = tbl->action; for (; ;) { lq_sta->action_counter++; switch (tbl->action) { - case IWL_LEGACY_SWITCH_ANTENNA1: - case IWL_LEGACY_SWITCH_ANTENNA2: - IWL_DEBUG_RATE(priv, "LQ: Legacy toggle Antenna\n"); + case IL_LEGACY_SWITCH_ANTENNA1: + case IL_LEGACY_SWITCH_ANTENNA2: + IL_DEBUG_RATE(priv, "LQ: Legacy toggle Antenna\n"); - if ((tbl->action == IWL_LEGACY_SWITCH_ANTENNA1 && + if ((tbl->action == IL_LEGACY_SWITCH_ANTENNA1 && tx_chains_num <= 1) || - (tbl->action == IWL_LEGACY_SWITCH_ANTENNA2 && + (tbl->action == IL_LEGACY_SWITCH_ANTENNA2 && tx_chains_num <= 2)) break; /* Don't change antenna if success has been great */ - if (window->success_ratio >= IWL_RS_GOOD_RATIO) + if (window->success_ratio >= IL_RS_GOOD_RATIO) break; /* Set up search table to try other antenna */ memcpy(search_tbl, tbl, sz); - if (iwl4965_rs_toggle_antenna(valid_tx_ant, + if (il4965_rs_toggle_antenna(valid_tx_ant, &search_tbl->current_rate, search_tbl)) { update_search_tbl_counter = 1; - iwl4965_rs_set_expected_tpt_table(lq_sta, + il4965_rs_set_expected_tpt_table(lq_sta, search_tbl); goto out; } break; - case IWL_LEGACY_SWITCH_SISO: - IWL_DEBUG_RATE(priv, "LQ: Legacy switch to SISO\n"); + case IL_LEGACY_SWITCH_SISO: + IL_DEBUG_RATE(priv, "LQ: Legacy switch to SISO\n"); /* Set up search table to try SISO */ memcpy(search_tbl, tbl, sz); search_tbl->is_SGI = 0; - ret = iwl4965_rs_switch_to_siso(priv, lq_sta, conf, sta, + ret = il4965_rs_switch_to_siso(priv, lq_sta, conf, sta, search_tbl, index); if (!ret) { lq_sta->action_counter = 0; @@ -1344,27 +1344,27 @@ static int iwl4965_rs_move_legacy_other(struct iwl_priv *priv, } break; - case IWL_LEGACY_SWITCH_MIMO2_AB: - case IWL_LEGACY_SWITCH_MIMO2_AC: - case IWL_LEGACY_SWITCH_MIMO2_BC: - IWL_DEBUG_RATE(priv, "LQ: Legacy switch to MIMO2\n"); + case IL_LEGACY_SWITCH_MIMO2_AB: + case IL_LEGACY_SWITCH_MIMO2_AC: + case IL_LEGACY_SWITCH_MIMO2_BC: + IL_DEBUG_RATE(priv, "LQ: Legacy switch to MIMO2\n"); /* Set up search table to try MIMO */ memcpy(search_tbl, tbl, sz); search_tbl->is_SGI = 0; - if (tbl->action == IWL_LEGACY_SWITCH_MIMO2_AB) + if (tbl->action == IL_LEGACY_SWITCH_MIMO2_AB) search_tbl->ant_type = ANT_AB; - else if (tbl->action == IWL_LEGACY_SWITCH_MIMO2_AC) + else if (tbl->action == IL_LEGACY_SWITCH_MIMO2_AC) search_tbl->ant_type = ANT_AC; else search_tbl->ant_type = ANT_BC; - if (!iwl4965_rs_is_valid_ant(valid_tx_ant, + if (!il4965_rs_is_valid_ant(valid_tx_ant, search_tbl->ant_type)) break; - ret = iwl4965_rs_switch_to_mimo2(priv, lq_sta, + ret = il4965_rs_switch_to_mimo2(priv, lq_sta, conf, sta, search_tbl, index); if (!ret) { @@ -1374,8 +1374,8 @@ static int iwl4965_rs_move_legacy_other(struct iwl_priv *priv, break; } tbl->action++; - if (tbl->action > IWL_LEGACY_SWITCH_MIMO2_BC) - tbl->action = IWL_LEGACY_SWITCH_ANTENNA1; + if (tbl->action > IL_LEGACY_SWITCH_MIMO2_BC) + tbl->action = IL_LEGACY_SWITCH_ANTENNA1; if (tbl->action == start_action) break; @@ -1387,8 +1387,8 @@ static int iwl4965_rs_move_legacy_other(struct iwl_priv *priv, out: lq_sta->search_better_tbl = 1; tbl->action++; - if (tbl->action > IWL_LEGACY_SWITCH_MIMO2_BC) - tbl->action = IWL_LEGACY_SWITCH_ANTENNA1; + if (tbl->action > IL_LEGACY_SWITCH_MIMO2_BC) + tbl->action = IL_LEGACY_SWITCH_ANTENNA1; if (update_search_tbl_counter) search_tbl->action = tbl->action; return 0; @@ -1398,19 +1398,19 @@ out: /* * Try to switch to new modulation mode from SISO */ -static int iwl4965_rs_move_siso_to_other(struct iwl_priv *priv, - struct iwl_lq_sta *lq_sta, +static int il4965_rs_move_siso_to_other(struct il_priv *priv, + struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, int index) { u8 is_green = lq_sta->is_green; - struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - struct iwl_scale_tbl_info *search_tbl = + struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); + struct il_scale_tbl_info *search_tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - struct iwl_rate_scale_data *window = &(tbl->win[index]); + struct il_rate_scale_data *window = &(tbl->win[index]); struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; - u32 sz = (sizeof(struct iwl_scale_tbl_info) - - (sizeof(struct iwl_rate_scale_data) * IWL_RATE_COUNT)); + u32 sz = (sizeof(struct il_scale_tbl_info) - + (sizeof(struct il_rate_scale_data) * IL_RATE_COUNT)); u8 start_action; u8 valid_tx_ant = priv->hw_params.valid_tx_ant; u8 tx_chains_num = priv->hw_params.tx_chains_num; @@ -1422,50 +1422,50 @@ static int iwl4965_rs_move_siso_to_other(struct iwl_priv *priv, for (;;) { lq_sta->action_counter++; switch (tbl->action) { - case IWL_SISO_SWITCH_ANTENNA1: - case IWL_SISO_SWITCH_ANTENNA2: - IWL_DEBUG_RATE(priv, "LQ: SISO toggle Antenna\n"); - if ((tbl->action == IWL_SISO_SWITCH_ANTENNA1 && + case IL_SISO_SWITCH_ANTENNA1: + case IL_SISO_SWITCH_ANTENNA2: + IL_DEBUG_RATE(priv, "LQ: SISO toggle Antenna\n"); + if ((tbl->action == IL_SISO_SWITCH_ANTENNA1 && tx_chains_num <= 1) || - (tbl->action == IWL_SISO_SWITCH_ANTENNA2 && + (tbl->action == IL_SISO_SWITCH_ANTENNA2 && tx_chains_num <= 2)) break; - if (window->success_ratio >= IWL_RS_GOOD_RATIO) + if (window->success_ratio >= IL_RS_GOOD_RATIO) break; memcpy(search_tbl, tbl, sz); - if (iwl4965_rs_toggle_antenna(valid_tx_ant, + if (il4965_rs_toggle_antenna(valid_tx_ant, &search_tbl->current_rate, search_tbl)) { update_search_tbl_counter = 1; goto out; } break; - case IWL_SISO_SWITCH_MIMO2_AB: - case IWL_SISO_SWITCH_MIMO2_AC: - case IWL_SISO_SWITCH_MIMO2_BC: - IWL_DEBUG_RATE(priv, "LQ: SISO switch to MIMO2\n"); + case IL_SISO_SWITCH_MIMO2_AB: + case IL_SISO_SWITCH_MIMO2_AC: + case IL_SISO_SWITCH_MIMO2_BC: + IL_DEBUG_RATE(priv, "LQ: SISO switch to MIMO2\n"); memcpy(search_tbl, tbl, sz); search_tbl->is_SGI = 0; - if (tbl->action == IWL_SISO_SWITCH_MIMO2_AB) + if (tbl->action == IL_SISO_SWITCH_MIMO2_AB) search_tbl->ant_type = ANT_AB; - else if (tbl->action == IWL_SISO_SWITCH_MIMO2_AC) + else if (tbl->action == IL_SISO_SWITCH_MIMO2_AC) search_tbl->ant_type = ANT_AC; else search_tbl->ant_type = ANT_BC; - if (!iwl4965_rs_is_valid_ant(valid_tx_ant, + if (!il4965_rs_is_valid_ant(valid_tx_ant, search_tbl->ant_type)) break; - ret = iwl4965_rs_switch_to_mimo2(priv, lq_sta, + ret = il4965_rs_switch_to_mimo2(priv, lq_sta, conf, sta, search_tbl, index); if (!ret) goto out; break; - case IWL_SISO_SWITCH_GI: + case IL_SISO_SWITCH_GI: if (!tbl->is_ht40 && !(ht_cap->cap & IEEE80211_HT_CAP_SGI_20)) break; @@ -1473,32 +1473,32 @@ static int iwl4965_rs_move_siso_to_other(struct iwl_priv *priv, IEEE80211_HT_CAP_SGI_40)) break; - IWL_DEBUG_RATE(priv, "LQ: SISO toggle SGI/NGI\n"); + IL_DEBUG_RATE(priv, "LQ: SISO toggle SGI/NGI\n"); memcpy(search_tbl, tbl, sz); if (is_green) { if (!tbl->is_SGI) break; else - IWL_ERR(priv, + IL_ERR(priv, "SGI was set in GF+SISO\n"); } search_tbl->is_SGI = !tbl->is_SGI; - iwl4965_rs_set_expected_tpt_table(lq_sta, search_tbl); + il4965_rs_set_expected_tpt_table(lq_sta, search_tbl); if (tbl->is_SGI) { s32 tpt = lq_sta->last_tpt / 100; if (tpt >= search_tbl->expected_tpt[index]) break; } search_tbl->current_rate = - iwl4965_rate_n_flags_from_tbl(priv, search_tbl, + il4965_rate_n_flags_from_tbl(priv, search_tbl, index, is_green); update_search_tbl_counter = 1; goto out; } tbl->action++; - if (tbl->action > IWL_SISO_SWITCH_GI) - tbl->action = IWL_SISO_SWITCH_ANTENNA1; + if (tbl->action > IL_SISO_SWITCH_GI) + tbl->action = IL_SISO_SWITCH_ANTENNA1; if (tbl->action == start_action) break; @@ -1509,8 +1509,8 @@ static int iwl4965_rs_move_siso_to_other(struct iwl_priv *priv, out: lq_sta->search_better_tbl = 1; tbl->action++; - if (tbl->action > IWL_SISO_SWITCH_GI) - tbl->action = IWL_SISO_SWITCH_ANTENNA1; + if (tbl->action > IL_SISO_SWITCH_GI) + tbl->action = IL_SISO_SWITCH_ANTENNA1; if (update_search_tbl_counter) search_tbl->action = tbl->action; @@ -1520,19 +1520,19 @@ static int iwl4965_rs_move_siso_to_other(struct iwl_priv *priv, /* * Try to switch to new modulation mode from MIMO2 */ -static int iwl4965_rs_move_mimo2_to_other(struct iwl_priv *priv, - struct iwl_lq_sta *lq_sta, +static int il4965_rs_move_mimo2_to_other(struct il_priv *priv, + struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, int index) { s8 is_green = lq_sta->is_green; - struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - struct iwl_scale_tbl_info *search_tbl = + struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); + struct il_scale_tbl_info *search_tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - struct iwl_rate_scale_data *window = &(tbl->win[index]); + struct il_rate_scale_data *window = &(tbl->win[index]); struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; - u32 sz = (sizeof(struct iwl_scale_tbl_info) - - (sizeof(struct iwl_rate_scale_data) * IWL_RATE_COUNT)); + u32 sz = (sizeof(struct il_scale_tbl_info) - + (sizeof(struct il_rate_scale_data) * IL_RATE_COUNT)); u8 start_action; u8 valid_tx_ant = priv->hw_params.valid_tx_ant; u8 tx_chains_num = priv->hw_params.tx_chains_num; @@ -1543,43 +1543,43 @@ static int iwl4965_rs_move_mimo2_to_other(struct iwl_priv *priv, for (;;) { lq_sta->action_counter++; switch (tbl->action) { - case IWL_MIMO2_SWITCH_ANTENNA1: - case IWL_MIMO2_SWITCH_ANTENNA2: - IWL_DEBUG_RATE(priv, "LQ: MIMO2 toggle Antennas\n"); + case IL_MIMO2_SWITCH_ANTENNA1: + case IL_MIMO2_SWITCH_ANTENNA2: + IL_DEBUG_RATE(priv, "LQ: MIMO2 toggle Antennas\n"); if (tx_chains_num <= 2) break; - if (window->success_ratio >= IWL_RS_GOOD_RATIO) + if (window->success_ratio >= IL_RS_GOOD_RATIO) break; memcpy(search_tbl, tbl, sz); - if (iwl4965_rs_toggle_antenna(valid_tx_ant, + if (il4965_rs_toggle_antenna(valid_tx_ant, &search_tbl->current_rate, search_tbl)) { update_search_tbl_counter = 1; goto out; } break; - case IWL_MIMO2_SWITCH_SISO_A: - case IWL_MIMO2_SWITCH_SISO_B: - case IWL_MIMO2_SWITCH_SISO_C: - IWL_DEBUG_RATE(priv, "LQ: MIMO2 switch to SISO\n"); + case IL_MIMO2_SWITCH_SISO_A: + case IL_MIMO2_SWITCH_SISO_B: + case IL_MIMO2_SWITCH_SISO_C: + IL_DEBUG_RATE(priv, "LQ: MIMO2 switch to SISO\n"); /* Set up new search table for SISO */ memcpy(search_tbl, tbl, sz); - if (tbl->action == IWL_MIMO2_SWITCH_SISO_A) + if (tbl->action == IL_MIMO2_SWITCH_SISO_A) search_tbl->ant_type = ANT_A; - else if (tbl->action == IWL_MIMO2_SWITCH_SISO_B) + else if (tbl->action == IL_MIMO2_SWITCH_SISO_B) search_tbl->ant_type = ANT_B; else search_tbl->ant_type = ANT_C; - if (!iwl4965_rs_is_valid_ant(valid_tx_ant, + if (!il4965_rs_is_valid_ant(valid_tx_ant, search_tbl->ant_type)) break; - ret = iwl4965_rs_switch_to_siso(priv, lq_sta, + ret = il4965_rs_switch_to_siso(priv, lq_sta, conf, sta, search_tbl, index); if (!ret) @@ -1587,7 +1587,7 @@ static int iwl4965_rs_move_mimo2_to_other(struct iwl_priv *priv, break; - case IWL_MIMO2_SWITCH_GI: + case IL_MIMO2_SWITCH_GI: if (!tbl->is_ht40 && !(ht_cap->cap & IEEE80211_HT_CAP_SGI_20)) break; @@ -1595,12 +1595,12 @@ static int iwl4965_rs_move_mimo2_to_other(struct iwl_priv *priv, IEEE80211_HT_CAP_SGI_40)) break; - IWL_DEBUG_RATE(priv, "LQ: MIMO2 toggle SGI/NGI\n"); + IL_DEBUG_RATE(priv, "LQ: MIMO2 toggle SGI/NGI\n"); /* Set up new search table for MIMO2 */ memcpy(search_tbl, tbl, sz); search_tbl->is_SGI = !tbl->is_SGI; - iwl4965_rs_set_expected_tpt_table(lq_sta, search_tbl); + il4965_rs_set_expected_tpt_table(lq_sta, search_tbl); /* * If active table already uses the fastest possible * modulation (dual stream with short guard interval), @@ -1613,15 +1613,15 @@ static int iwl4965_rs_move_mimo2_to_other(struct iwl_priv *priv, break; } search_tbl->current_rate = - iwl4965_rate_n_flags_from_tbl(priv, search_tbl, + il4965_rate_n_flags_from_tbl(priv, search_tbl, index, is_green); update_search_tbl_counter = 1; goto out; } tbl->action++; - if (tbl->action > IWL_MIMO2_SWITCH_GI) - tbl->action = IWL_MIMO2_SWITCH_ANTENNA1; + if (tbl->action > IL_MIMO2_SWITCH_GI) + tbl->action = IL_MIMO2_SWITCH_ANTENNA1; if (tbl->action == start_action) break; @@ -1631,8 +1631,8 @@ static int iwl4965_rs_move_mimo2_to_other(struct iwl_priv *priv, out: lq_sta->search_better_tbl = 1; tbl->action++; - if (tbl->action > IWL_MIMO2_SWITCH_GI) - tbl->action = IWL_MIMO2_SWITCH_ANTENNA1; + if (tbl->action > IL_MIMO2_SWITCH_GI) + tbl->action = IL_MIMO2_SWITCH_ANTENNA1; if (update_search_tbl_counter) search_tbl->action = tbl->action; @@ -1648,13 +1648,13 @@ static int iwl4965_rs_move_mimo2_to_other(struct iwl_priv *priv, * 3) elapsed time in this mode (not used, for now) */ static void -iwl4965_rs_stay_in_table(struct iwl_lq_sta *lq_sta, bool force_search) +il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) { - struct iwl_scale_tbl_info *tbl; + struct il_scale_tbl_info *tbl; int i; int active_tbl; int flush_interval_passed = 0; - struct iwl_priv *priv; + struct il_priv *priv; priv = lq_sta->drv; active_tbl = lq_sta->active_tbl; @@ -1669,7 +1669,7 @@ iwl4965_rs_stay_in_table(struct iwl_lq_sta *lq_sta, bool force_search) flush_interval_passed = time_after(jiffies, (unsigned long)(lq_sta->flush_timer + - IWL_RATE_SCALE_FLUSH_INTVL)); + IL_RATE_SCALE_FLUSH_INTVL)); /* * Check if we should allow search for new modulation mode. @@ -1684,7 +1684,7 @@ iwl4965_rs_stay_in_table(struct iwl_lq_sta *lq_sta, bool force_search) (lq_sta->total_success > lq_sta->max_success_limit) || ((!lq_sta->search_better_tbl) && (lq_sta->flush_timer) && (flush_interval_passed))) { - IWL_DEBUG_RATE(priv, "LQ: stay is expired %d %d %d\n:", + IL_DEBUG_RATE(priv, "LQ: stay is expired %d %d %d\n:", lq_sta->total_failed, lq_sta->total_success, flush_interval_passed); @@ -1707,10 +1707,10 @@ iwl4965_rs_stay_in_table(struct iwl_lq_sta *lq_sta, bool force_search) lq_sta->table_count_limit) { lq_sta->table_count = 0; - IWL_DEBUG_RATE(priv, + IL_DEBUG_RATE(priv, "LQ: stay in table clear win\n"); - for (i = 0; i < IWL_RATE_COUNT; i++) - iwl4965_rs_rate_scale_clear_window( + for (i = 0; i < IL_RATE_COUNT; i++) + il4965_rs_rate_scale_clear_window( &(tbl->win[i])); } } @@ -1719,8 +1719,8 @@ iwl4965_rs_stay_in_table(struct iwl_lq_sta *lq_sta, bool force_search) * bitmaps and stats in active table (this will become the new * "search" table). */ if (!lq_sta->stay_in_tbl) { - for (i = 0; i < IWL_RATE_COUNT; i++) - iwl4965_rs_rate_scale_clear_window( + for (i = 0; i < IL_RATE_COUNT; i++) + il4965_rs_rate_scale_clear_window( &(tbl->win[i])); } } @@ -1730,18 +1730,18 @@ iwl4965_rs_stay_in_table(struct iwl_lq_sta *lq_sta, bool force_search) * setup rate table in uCode * return rate_n_flags as used in the table */ -static u32 iwl4965_rs_update_rate_tbl(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, - struct iwl_lq_sta *lq_sta, - struct iwl_scale_tbl_info *tbl, +static u32 il4965_rs_update_rate_tbl(struct il_priv *priv, + struct il_rxon_context *ctx, + struct il_lq_sta *lq_sta, + struct il_scale_tbl_info *tbl, int index, u8 is_green) { u32 rate; /* Update uCode's rate table. */ - rate = iwl4965_rate_n_flags_from_tbl(priv, tbl, index, is_green); - iwl4965_rs_fill_link_cmd(priv, lq_sta, rate); - iwl_legacy_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_ASYNC, false); + rate = il4965_rate_n_flags_from_tbl(priv, tbl, index, is_green); + il4965_rs_fill_link_cmd(priv, lq_sta, rate); + il_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_ASYNC, false); return rate; } @@ -1749,28 +1749,28 @@ static u32 iwl4965_rs_update_rate_tbl(struct iwl_priv *priv, /* * Do rate scaling and search for new modulation mode. */ -static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, +static void il4965_rs_rate_scale_perform(struct il_priv *priv, struct sk_buff *skb, struct ieee80211_sta *sta, - struct iwl_lq_sta *lq_sta) + struct il_lq_sta *lq_sta) { struct ieee80211_hw *hw = priv->hw; struct ieee80211_conf *conf = &hw->conf; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - int low = IWL_RATE_INVALID; - int high = IWL_RATE_INVALID; + int low = IL_RATE_INVALID; + int high = IL_RATE_INVALID; int index; int i; - struct iwl_rate_scale_data *window = NULL; - int current_tpt = IWL_INVALID_VALUE; - int low_tpt = IWL_INVALID_VALUE; - int high_tpt = IWL_INVALID_VALUE; + struct il_rate_scale_data *window = NULL; + int current_tpt = IL_INVALID_VALUE; + int low_tpt = IL_INVALID_VALUE; + int high_tpt = IL_INVALID_VALUE; u32 fail_count; s8 scale_action = 0; u16 rate_mask; u8 update_lq = 0; - struct iwl_scale_tbl_info *tbl, *tbl1; + struct il_scale_tbl_info *tbl, *tbl1; u16 rate_scale_index_msk = 0; u32 rate; u8 is_green = 0; @@ -1779,11 +1779,11 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, u16 high_low; s32 sr; u8 tid = MAX_TID_COUNT; - struct iwl_tid_data *tid_data; - struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; - struct iwl_rxon_context *ctx = sta_priv->common.ctx; + struct il_tid_data *tid_data; + struct il_station_priv *sta_priv = (void *)sta->drv_priv; + struct il_rxon_context *ctx = sta_priv->common.ctx; - IWL_DEBUG_RATE(priv, "rate scale calculate new rate for skb\n"); + IL_DEBUG_RATE(priv, "rate scale calculate new rate for skb\n"); /* Send management frames and NO_ACK data using lowest rate. */ /* TODO: this could probably be improved.. */ @@ -1796,10 +1796,10 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, lq_sta->supp_rates = sta->supp_rates[lq_sta->band]; - tid = iwl4965_rs_tl_add_packet(lq_sta, hdr); + tid = il4965_rs_tl_add_packet(lq_sta, hdr); if ((tid != MAX_TID_COUNT) && (lq_sta->tx_agg_tid_en & (1 << tid))) { tid_data = &priv->stations[lq_sta->lq.sta_id].tid[tid]; - if (tid_data->agg.state == IWL_AGG_OFF) + if (tid_data->agg.state == IL_AGG_OFF) lq_sta->is_agg = 0; else lq_sta->is_agg = 1; @@ -1820,26 +1820,26 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, if (is_legacy(tbl->lq_type)) lq_sta->is_green = 0; else - lq_sta->is_green = iwl4965_rs_use_green(sta); + lq_sta->is_green = il4965_rs_use_green(sta); is_green = lq_sta->is_green; /* current tx rate */ index = lq_sta->last_txrate_idx; - IWL_DEBUG_RATE(priv, "Rate scale index %d for type %d\n", index, + IL_DEBUG_RATE(priv, "Rate scale index %d for type %d\n", index, tbl->lq_type); /* rates available for this association, and for modulation mode */ - rate_mask = iwl4965_rs_get_supported_rates(lq_sta, hdr, tbl->lq_type); + rate_mask = il4965_rs_get_supported_rates(lq_sta, hdr, tbl->lq_type); - IWL_DEBUG_RATE(priv, "mask 0x%04X\n", rate_mask); + IL_DEBUG_RATE(priv, "mask 0x%04X\n", rate_mask); /* mask with station rate restriction */ if (is_legacy(tbl->lq_type)) { if (lq_sta->band == IEEE80211_BAND_5GHZ) /* supp_rates has no CCK bits in A mode */ rate_scale_index_msk = (u16) (rate_mask & - (lq_sta->supp_rates << IWL_FIRST_OFDM_RATE)); + (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); else rate_scale_index_msk = (u16) (rate_mask & lq_sta->supp_rates); @@ -1851,15 +1851,15 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, rate_scale_index_msk = rate_mask; if (!((1 << index) & rate_scale_index_msk)) { - IWL_ERR(priv, "Current Rate is not valid\n"); + IL_ERR(priv, "Current Rate is not valid\n"); if (lq_sta->search_better_tbl) { /* revert to active table if search table is not valid*/ tbl->lq_type = LQ_NONE; lq_sta->search_better_tbl = 0; tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); /* get "active" rate info */ - index = iwl4965_hwrate_to_plcp_idx(tbl->current_rate); - rate = iwl4965_rs_update_rate_tbl(priv, ctx, lq_sta, + index = il4965_hwrate_to_plcp_idx(tbl->current_rate); + rate = il4965_rs_update_rate_tbl(priv, ctx, lq_sta, tbl, index, is_green); } return; @@ -1867,7 +1867,7 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, /* Get expected throughput table and history window for current rate */ if (!tbl->expected_tpt) { - IWL_ERR(priv, "tbl->expected_tpt is NULL\n"); + IL_ERR(priv, "tbl->expected_tpt is NULL\n"); return; } @@ -1890,18 +1890,18 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, * in current association (use new rate found above). */ fail_count = window->counter - window->success_counter; - if ((fail_count < IWL_RATE_MIN_FAILURE_TH) && - (window->success_counter < IWL_RATE_MIN_SUCCESS_TH)) { - IWL_DEBUG_RATE(priv, "LQ: still below TH. succ=%d total=%d " + if ((fail_count < IL_RATE_MIN_FAILURE_TH) && + (window->success_counter < IL_RATE_MIN_SUCCESS_TH)) { + IL_DEBUG_RATE(priv, "LQ: still below TH. succ=%d total=%d " "for index %d\n", window->success_counter, window->counter, index); /* Can't calculate this yet; not enough history */ - window->average_tpt = IWL_INVALID_VALUE; + window->average_tpt = IL_INVALID_VALUE; /* Should we stay with this modulation mode, * or search for a new one? */ - iwl4965_rs_stay_in_table(lq_sta, false); + il4965_rs_stay_in_table(lq_sta, false); goto out; } @@ -1909,7 +1909,7 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, * actual average throughput */ if (window->average_tpt != ((window->success_ratio * tbl->expected_tpt[index] + 64) / 128)) { - IWL_ERR(priv, + IL_ERR(priv, "expected_tpt should have been calculated by now\n"); window->average_tpt = ((window->success_ratio * tbl->expected_tpt[index] + 64) / 128); @@ -1922,7 +1922,7 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, * continuing to use the setup that we've been trying. */ if (window->average_tpt > lq_sta->last_tpt) { - IWL_DEBUG_RATE(priv, "LQ: SWITCHING TO NEW TABLE " + IL_DEBUG_RATE(priv, "LQ: SWITCHING TO NEW TABLE " "suc=%d cur-tpt=%d old-tpt=%d\n", window->success_ratio, window->average_tpt, @@ -1938,7 +1938,7 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, /* Else poor success; go back to mode in "active" table */ } else { - IWL_DEBUG_RATE(priv, "LQ: GOING BACK TO THE OLD TABLE " + IL_DEBUG_RATE(priv, "LQ: GOING BACK TO THE OLD TABLE " "suc=%d cur-tpt=%d old-tpt=%d\n", window->success_ratio, window->average_tpt, @@ -1952,7 +1952,7 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, tbl = &(lq_sta->lq_info[active_tbl]); /* Revert to "active" rate and throughput info */ - index = iwl4965_hwrate_to_plcp_idx(tbl->current_rate); + index = il4965_hwrate_to_plcp_idx(tbl->current_rate); current_tpt = lq_sta->last_tpt; /* Need to set up a new rate table in uCode */ @@ -1968,7 +1968,7 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, /* (Else) not in search of better modulation mode, try for better * starting rate, while staying in this mode. */ - high_low = iwl4965_rs_get_adjacent_rate(priv, index, + high_low = il4965_rs_get_adjacent_rate(priv, index, rate_scale_index_msk, tbl->lq_type); low = high_low & 0xff; @@ -1977,39 +1977,39 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, /* If user set max rate, dont allow higher than user constrain */ if ((lq_sta->max_rate_idx != -1) && (lq_sta->max_rate_idx < high)) - high = IWL_RATE_INVALID; + high = IL_RATE_INVALID; sr = window->success_ratio; /* Collect measured throughputs for current and adjacent rates */ current_tpt = window->average_tpt; - if (low != IWL_RATE_INVALID) + if (low != IL_RATE_INVALID) low_tpt = tbl->win[low].average_tpt; - if (high != IWL_RATE_INVALID) + if (high != IL_RATE_INVALID) high_tpt = tbl->win[high].average_tpt; scale_action = 0; /* Too many failures, decrease rate */ - if ((sr <= IWL_RATE_DECREASE_TH) || (current_tpt == 0)) { - IWL_DEBUG_RATE(priv, + if ((sr <= IL_RATE_DECREASE_TH) || (current_tpt == 0)) { + IL_DEBUG_RATE(priv, "decrease rate because of low success_ratio\n"); scale_action = -1; /* No throughput measured yet for adjacent rates; try increase. */ - } else if ((low_tpt == IWL_INVALID_VALUE) && - (high_tpt == IWL_INVALID_VALUE)) { + } else if ((low_tpt == IL_INVALID_VALUE) && + (high_tpt == IL_INVALID_VALUE)) { - if (high != IWL_RATE_INVALID && sr >= IWL_RATE_INCREASE_TH) + if (high != IL_RATE_INVALID && sr >= IL_RATE_INCREASE_TH) scale_action = 1; - else if (low != IWL_RATE_INVALID) + else if (low != IL_RATE_INVALID) scale_action = 0; } /* Both adjacent throughputs are measured, but neither one has better * throughput; we're using the best rate, don't change it! */ - else if ((low_tpt != IWL_INVALID_VALUE) && - (high_tpt != IWL_INVALID_VALUE) && + else if ((low_tpt != IL_INVALID_VALUE) && + (high_tpt != IL_INVALID_VALUE) && (low_tpt < current_tpt) && (high_tpt < current_tpt)) scale_action = 0; @@ -2018,23 +2018,23 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, * and may have better performance. */ else { /* Higher adjacent rate's throughput is measured */ - if (high_tpt != IWL_INVALID_VALUE) { + if (high_tpt != IL_INVALID_VALUE) { /* Higher rate has better throughput */ if (high_tpt > current_tpt && - sr >= IWL_RATE_INCREASE_TH) { + sr >= IL_RATE_INCREASE_TH) { scale_action = 1; } else { scale_action = 0; } /* Lower adjacent rate's throughput is measured */ - } else if (low_tpt != IWL_INVALID_VALUE) { + } else if (low_tpt != IL_INVALID_VALUE) { /* Lower rate has better throughput */ if (low_tpt > current_tpt) { - IWL_DEBUG_RATE(priv, + IL_DEBUG_RATE(priv, "decrease rate because of low tpt\n"); scale_action = -1; - } else if (sr >= IWL_RATE_INCREASE_TH) { + } else if (sr >= IL_RATE_INCREASE_TH) { scale_action = 1; } } @@ -2042,15 +2042,15 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, /* Sanity check; asked for decrease, but success rate or throughput * has been good at old rate. Don't change it. */ - if ((scale_action == -1) && (low != IWL_RATE_INVALID) && - ((sr > IWL_RATE_HIGH_TH) || + if ((scale_action == -1) && (low != IL_RATE_INVALID) && + ((sr > IL_RATE_HIGH_TH) || (current_tpt > (100 * tbl->expected_tpt[low])))) scale_action = 0; switch (scale_action) { case -1: /* Decrease starting rate, update uCode's rate table */ - if (low != IWL_RATE_INVALID) { + if (low != IL_RATE_INVALID) { update_lq = 1; index = low; } @@ -2058,7 +2058,7 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, break; case 1: /* Increase starting rate, update uCode's rate table */ - if (high != IWL_RATE_INVALID) { + if (high != IL_RATE_INVALID) { update_lq = 1; index = high; } @@ -2070,19 +2070,19 @@ static void iwl4965_rs_rate_scale_perform(struct iwl_priv *priv, break; } - IWL_DEBUG_RATE(priv, "choose rate scale index %d action %d low %d " + IL_DEBUG_RATE(priv, "choose rate scale index %d action %d low %d " "high %d type %d\n", index, scale_action, low, high, tbl->lq_type); lq_update: /* Replace uCode's rate table for the destination station. */ if (update_lq) - rate = iwl4965_rs_update_rate_tbl(priv, ctx, lq_sta, + rate = il4965_rs_update_rate_tbl(priv, ctx, lq_sta, tbl, index, is_green); /* Should we stay with this modulation mode, * or search for a new one? */ - iwl4965_rs_stay_in_table(lq_sta, false); + il4965_rs_stay_in_table(lq_sta, false); /* * Search for new modulation mode if we're: @@ -2098,32 +2098,32 @@ lq_update: /* Select a new "search" modulation mode to try. * If one is found, set up the new "search" table. */ if (is_legacy(tbl->lq_type)) - iwl4965_rs_move_legacy_other(priv, lq_sta, + il4965_rs_move_legacy_other(priv, lq_sta, conf, sta, index); else if (is_siso(tbl->lq_type)) - iwl4965_rs_move_siso_to_other(priv, lq_sta, + il4965_rs_move_siso_to_other(priv, lq_sta, conf, sta, index); else /* (is_mimo2(tbl->lq_type)) */ - iwl4965_rs_move_mimo2_to_other(priv, lq_sta, + il4965_rs_move_mimo2_to_other(priv, lq_sta, conf, sta, index); /* If new "search" mode was selected, set up in uCode table */ if (lq_sta->search_better_tbl) { /* Access the "search" table, clear its history. */ tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - for (i = 0; i < IWL_RATE_COUNT; i++) - iwl4965_rs_rate_scale_clear_window( + for (i = 0; i < IL_RATE_COUNT; i++) + il4965_rs_rate_scale_clear_window( &(tbl->win[i])); /* Use new "search" start rate */ - index = iwl4965_hwrate_to_plcp_idx(tbl->current_rate); + index = il4965_hwrate_to_plcp_idx(tbl->current_rate); - IWL_DEBUG_RATE(priv, + IL_DEBUG_RATE(priv, "Switch current mcs: %X index: %d\n", tbl->current_rate, index); - iwl4965_rs_fill_link_cmd(priv, lq_sta, + il4965_rs_fill_link_cmd(priv, lq_sta, tbl->current_rate); - iwl_legacy_send_lq_cmd(priv, ctx, + il_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_ASYNC, false); } else done_search = 1; @@ -2138,8 +2138,8 @@ lq_update: tbl1 = &(lq_sta->lq_info[lq_sta->active_tbl]); if (is_legacy(tbl1->lq_type) && !conf_is_ht(conf) && lq_sta->action_counter > tbl1->max_search) { - IWL_DEBUG_RATE(priv, "LQ: STAY in legacy table\n"); - iwl4965_rs_set_stay_in_table(priv, 1, lq_sta); + IL_DEBUG_RATE(priv, "LQ: STAY in legacy table\n"); + il4965_rs_set_stay_in_table(priv, 1, lq_sta); } /* If we're in an HT mode, and all 3 mode switch actions @@ -2147,32 +2147,32 @@ lq_update: * mode for a while before next round of mode comparisons. */ if (lq_sta->enable_counter && (lq_sta->action_counter >= tbl1->max_search)) { - if ((lq_sta->last_tpt > IWL_AGG_TPT_THREHOLD) && + if ((lq_sta->last_tpt > IL_AGG_TPT_THREHOLD) && (lq_sta->tx_agg_tid_en & (1 << tid)) && (tid != MAX_TID_COUNT)) { tid_data = &priv->stations[lq_sta->lq.sta_id].tid[tid]; - if (tid_data->agg.state == IWL_AGG_OFF) { - IWL_DEBUG_RATE(priv, + if (tid_data->agg.state == IL_AGG_OFF) { + IL_DEBUG_RATE(priv, "try to aggregate tid %d\n", tid); - iwl4965_rs_tl_turn_on_agg(priv, tid, + il4965_rs_tl_turn_on_agg(priv, tid, lq_sta, sta); } } - iwl4965_rs_set_stay_in_table(priv, 0, lq_sta); + il4965_rs_set_stay_in_table(priv, 0, lq_sta); } } out: - tbl->current_rate = iwl4965_rate_n_flags_from_tbl(priv, tbl, + tbl->current_rate = il4965_rate_n_flags_from_tbl(priv, tbl, index, is_green); i = index; lq_sta->last_txrate_idx = i; } /** - * iwl4965_rs_initialize_lq - Initialize a station's hardware rate table + * il4965_rs_initialize_lq - Initialize a station's hardware rate table * * The uCode's station table contains a table of fallback rates * for automatic fallback during transmission. @@ -2185,20 +2185,20 @@ out: * calling this function (which runs REPLY_TX_LINK_QUALITY_CMD, * which requires station table entry to exist). */ -static void iwl4965_rs_initialize_lq(struct iwl_priv *priv, +static void il4965_rs_initialize_lq(struct il_priv *priv, struct ieee80211_conf *conf, struct ieee80211_sta *sta, - struct iwl_lq_sta *lq_sta) + struct il_lq_sta *lq_sta) { - struct iwl_scale_tbl_info *tbl; + struct il_scale_tbl_info *tbl; int rate_idx; int i; u32 rate; - u8 use_green = iwl4965_rs_use_green(sta); + u8 use_green = il4965_rs_use_green(sta); u8 active_tbl = 0; u8 valid_tx_ant; - struct iwl_station_priv *sta_priv; - struct iwl_rxon_context *ctx; + struct il_station_priv *sta_priv; + struct il_rxon_context *ctx; if (!sta || !lq_sta) return; @@ -2217,56 +2217,56 @@ static void iwl4965_rs_initialize_lq(struct iwl_priv *priv, tbl = &(lq_sta->lq_info[active_tbl]); - if ((i < 0) || (i >= IWL_RATE_COUNT)) + if ((i < 0) || (i >= IL_RATE_COUNT)) i = 0; rate = iwlegacy_rates[i].plcp; - tbl->ant_type = iwl4965_first_antenna(valid_tx_ant); + tbl->ant_type = il4965_first_antenna(valid_tx_ant); rate |= tbl->ant_type << RATE_MCS_ANT_POS; - if (i >= IWL_FIRST_CCK_RATE && i <= IWL_LAST_CCK_RATE) + if (i >= IL_FIRST_CCK_RATE && i <= IL_LAST_CCK_RATE) rate |= RATE_MCS_CCK_MSK; - iwl4965_rs_get_tbl_info_from_mcs(rate, priv->band, tbl, &rate_idx); - if (!iwl4965_rs_is_valid_ant(valid_tx_ant, tbl->ant_type)) - iwl4965_rs_toggle_antenna(valid_tx_ant, &rate, tbl); + il4965_rs_get_tbl_info_from_mcs(rate, priv->band, tbl, &rate_idx); + if (!il4965_rs_is_valid_ant(valid_tx_ant, tbl->ant_type)) + il4965_rs_toggle_antenna(valid_tx_ant, &rate, tbl); - rate = iwl4965_rate_n_flags_from_tbl(priv, tbl, rate_idx, use_green); + rate = il4965_rate_n_flags_from_tbl(priv, tbl, rate_idx, use_green); tbl->current_rate = rate; - iwl4965_rs_set_expected_tpt_table(lq_sta, tbl); - iwl4965_rs_fill_link_cmd(NULL, lq_sta, rate); + il4965_rs_set_expected_tpt_table(lq_sta, tbl); + il4965_rs_fill_link_cmd(NULL, lq_sta, rate); priv->stations[lq_sta->lq.sta_id].lq = &lq_sta->lq; - iwl_legacy_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_SYNC, true); + il_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_SYNC, true); } static void -iwl4965_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta, +il4965_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta, struct ieee80211_tx_rate_control *txrc) { struct sk_buff *skb = txrc->skb; struct ieee80211_supported_band *sband = txrc->sband; - struct iwl_priv *priv __maybe_unused = (struct iwl_priv *)priv_r; + struct il_priv *priv __maybe_unused = (struct il_priv *)priv_r; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - struct iwl_lq_sta *lq_sta = priv_sta; + struct il_lq_sta *lq_sta = priv_sta; int rate_idx; - IWL_DEBUG_RATE_LIMIT(priv, "rate scale calculate new rate for skb\n"); + IL_DEBUG_RATE_LIMIT(priv, "rate scale calculate new rate for skb\n"); /* Get max rate if user set max rate */ if (lq_sta) { lq_sta->max_rate_idx = txrc->max_rate_idx; if ((sband->band == IEEE80211_BAND_5GHZ) && (lq_sta->max_rate_idx != -1)) - lq_sta->max_rate_idx += IWL_FIRST_OFDM_RATE; + lq_sta->max_rate_idx += IL_FIRST_OFDM_RATE; if ((lq_sta->max_rate_idx < 0) || - (lq_sta->max_rate_idx >= IWL_RATE_COUNT)) + (lq_sta->max_rate_idx >= IL_RATE_COUNT)) lq_sta->max_rate_idx = -1; } /* Treat uninitialized rate scaling data same as non-existing. */ if (lq_sta && !lq_sta->drv) { - IWL_DEBUG_RATE(priv, "Rate scaling not initialized yet.\n"); + IL_DEBUG_RATE(priv, "Rate scaling not initialized yet.\n"); priv_sta = NULL; } @@ -2280,11 +2280,11 @@ iwl4965_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta, rate_idx = lq_sta->last_txrate_idx; if (lq_sta->last_rate_n_flags & RATE_MCS_HT_MSK) { - rate_idx -= IWL_FIRST_OFDM_RATE; + rate_idx -= IL_FIRST_OFDM_RATE; /* 6M and 9M shared same MCS index */ rate_idx = (rate_idx > 0) ? (rate_idx - 1) : 0; - if (iwl4965_rs_extract_rate(lq_sta->last_rate_n_flags) >= - IWL_RATE_MIMO2_6M_PLCP) + if (il4965_rs_extract_rate(lq_sta->last_rate_n_flags) >= + IL_RATE_MIMO2_6M_PLCP) rate_idx = rate_idx + MCS_INDEX_PER_STREAM; info->control.rates[0].flags = IEEE80211_TX_RC_MCS; if (lq_sta->last_rate_n_flags & RATE_MCS_SGI_MSK) @@ -2301,29 +2301,29 @@ iwl4965_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta, IEEE80211_TX_RC_GREEN_FIELD; } else { /* Check for invalid rates */ - if ((rate_idx < 0) || (rate_idx >= IWL_RATE_COUNT_LEGACY) || + if ((rate_idx < 0) || (rate_idx >= IL_RATE_COUNT_LEGACY) || ((sband->band == IEEE80211_BAND_5GHZ) && - (rate_idx < IWL_FIRST_OFDM_RATE))) + (rate_idx < IL_FIRST_OFDM_RATE))) rate_idx = rate_lowest_index(sband, sta); /* On valid 5 GHz rate, adjust index */ else if (sband->band == IEEE80211_BAND_5GHZ) - rate_idx -= IWL_FIRST_OFDM_RATE; + rate_idx -= IL_FIRST_OFDM_RATE; info->control.rates[0].flags = 0; } info->control.rates[0].idx = rate_idx; } -static void *iwl4965_rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta, +static void *il4965_rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta, gfp_t gfp) { - struct iwl_lq_sta *lq_sta; - struct iwl_station_priv *sta_priv = - (struct iwl_station_priv *) sta->drv_priv; - struct iwl_priv *priv; + struct il_lq_sta *lq_sta; + struct il_station_priv *sta_priv = + (struct il_station_priv *) sta->drv_priv; + struct il_priv *priv; - priv = (struct iwl_priv *)priv_rate; - IWL_DEBUG_RATE(priv, "create station rate scale window\n"); + priv = (struct il_priv *)priv_rate; + IL_DEBUG_RATE(priv, "create station rate scale window\n"); lq_sta = &sta_priv->lq_sta; @@ -2334,7 +2334,7 @@ static void *iwl4965_rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta, * Called after adding a new station to initialize rate scaling */ void -iwl4965_rs_rate_init(struct iwl_priv *priv, +il4965_rs_rate_init(struct il_priv *priv, struct ieee80211_sta *sta, u8 sta_id) { @@ -2342,11 +2342,11 @@ iwl4965_rs_rate_init(struct iwl_priv *priv, struct ieee80211_hw *hw = priv->hw; struct ieee80211_conf *conf = &priv->hw->conf; struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; - struct iwl_station_priv *sta_priv; - struct iwl_lq_sta *lq_sta; + struct il_station_priv *sta_priv; + struct il_lq_sta *lq_sta; struct ieee80211_supported_band *sband; - sta_priv = (struct iwl_station_priv *) sta->drv_priv; + sta_priv = (struct il_station_priv *) sta->drv_priv; lq_sta = &sta_priv->lq_sta; sband = hw->wiphy->bands[conf->channel->band]; @@ -2354,18 +2354,18 @@ iwl4965_rs_rate_init(struct iwl_priv *priv, lq_sta->lq.sta_id = sta_id; for (j = 0; j < LQ_SIZE; j++) - for (i = 0; i < IWL_RATE_COUNT; i++) - iwl4965_rs_rate_scale_clear_window( + for (i = 0; i < IL_RATE_COUNT; i++) + il4965_rs_rate_scale_clear_window( &lq_sta->lq_info[j].win[i]); lq_sta->flush_timer = 0; lq_sta->supp_rates = sta->supp_rates[sband->band]; for (j = 0; j < LQ_SIZE; j++) - for (i = 0; i < IWL_RATE_COUNT; i++) - iwl4965_rs_rate_scale_clear_window( + for (i = 0; i < IL_RATE_COUNT; i++) + il4965_rs_rate_scale_clear_window( &lq_sta->lq_info[j].win[i]); - IWL_DEBUG_RATE(priv, "LQ:" + IL_DEBUG_RATE(priv, "LQ:" "*** rate scale station global init for station %d ***\n", sta_id); /* TODO: what is a good starting rate for STA? About middle? Maybe not @@ -2375,8 +2375,8 @@ iwl4965_rs_rate_init(struct iwl_priv *priv, lq_sta->is_dup = 0; lq_sta->max_rate_idx = -1; - lq_sta->missed_rate_counter = IWL_MISSED_RATE_MAX; - lq_sta->is_green = iwl4965_rs_use_green(sta); + lq_sta->missed_rate_counter = IL_MISSED_RATE_MAX; + lq_sta->is_green = il4965_rs_use_green(sta); lq_sta->active_legacy_rate = priv->active_rate & ~(0x1000); lq_sta->band = priv->band; /* @@ -2386,69 +2386,69 @@ iwl4965_rs_rate_init(struct iwl_priv *priv, lq_sta->active_siso_rate = ht_cap->mcs.rx_mask[0] << 1; lq_sta->active_siso_rate |= ht_cap->mcs.rx_mask[0] & 0x1; lq_sta->active_siso_rate &= ~((u16)0x2); - lq_sta->active_siso_rate <<= IWL_FIRST_OFDM_RATE; + lq_sta->active_siso_rate <<= IL_FIRST_OFDM_RATE; /* Same here */ lq_sta->active_mimo2_rate = ht_cap->mcs.rx_mask[1] << 1; lq_sta->active_mimo2_rate |= ht_cap->mcs.rx_mask[1] & 0x1; lq_sta->active_mimo2_rate &= ~((u16)0x2); - lq_sta->active_mimo2_rate <<= IWL_FIRST_OFDM_RATE; + lq_sta->active_mimo2_rate <<= IL_FIRST_OFDM_RATE; /* These values will be overridden later */ lq_sta->lq.general_params.single_stream_ant_msk = - iwl4965_first_antenna(priv->hw_params.valid_tx_ant); + il4965_first_antenna(priv->hw_params.valid_tx_ant); lq_sta->lq.general_params.dual_stream_ant_msk = priv->hw_params.valid_tx_ant & - ~iwl4965_first_antenna(priv->hw_params.valid_tx_ant); + ~il4965_first_antenna(priv->hw_params.valid_tx_ant); if (!lq_sta->lq.general_params.dual_stream_ant_msk) { lq_sta->lq.general_params.dual_stream_ant_msk = ANT_AB; - } else if (iwl4965_num_of_ant(priv->hw_params.valid_tx_ant) == 2) { + } else if (il4965_num_of_ant(priv->hw_params.valid_tx_ant) == 2) { lq_sta->lq.general_params.dual_stream_ant_msk = priv->hw_params.valid_tx_ant; } /* as default allow aggregation for all tids */ - lq_sta->tx_agg_tid_en = IWL_AGG_ALL_TID; + lq_sta->tx_agg_tid_en = IL_AGG_ALL_TID; lq_sta->drv = priv; /* Set last_txrate_idx to lowest rate */ lq_sta->last_txrate_idx = rate_lowest_index(sband, sta); if (sband->band == IEEE80211_BAND_5GHZ) - lq_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; + lq_sta->last_txrate_idx += IL_FIRST_OFDM_RATE; lq_sta->is_agg = 0; #ifdef CONFIG_MAC80211_DEBUGFS lq_sta->dbg_fixed_rate = 0; #endif - iwl4965_rs_initialize_lq(priv, conf, sta, lq_sta); + il4965_rs_initialize_lq(priv, conf, sta, lq_sta); } -static void iwl4965_rs_fill_link_cmd(struct iwl_priv *priv, - struct iwl_lq_sta *lq_sta, u32 new_rate) +static void il4965_rs_fill_link_cmd(struct il_priv *priv, + struct il_lq_sta *lq_sta, u32 new_rate) { - struct iwl_scale_tbl_info tbl_type; + struct il_scale_tbl_info tbl_type; int index = 0; int rate_idx; int repeat_rate = 0; u8 ant_toggle_cnt = 0; u8 use_ht_possible = 1; u8 valid_tx_ant = 0; - struct iwl_link_quality_cmd *lq_cmd = &lq_sta->lq; + struct il_link_quality_cmd *lq_cmd = &lq_sta->lq; /* Override starting rate (index 0) if needed for debug purposes */ - iwl4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, index); + il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, index); /* Interpret new_rate (rate_n_flags) */ - iwl4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, + il4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, &tbl_type, &rate_idx); /* How many times should we repeat the initial rate? */ if (is_legacy(tbl_type.lq_type)) { ant_toggle_cnt = 1; - repeat_rate = IWL_NUMBER_TRY; + repeat_rate = IL_NUMBER_TRY; } else { - repeat_rate = IWL_HT_NUMBER_TRY; + repeat_rate = IL_HT_NUMBER_TRY; } lq_cmd->general_params.mimo_delimiter = @@ -2457,10 +2457,10 @@ static void iwl4965_rs_fill_link_cmd(struct iwl_priv *priv, /* Fill 1st table entry (index 0) */ lq_cmd->rs_table[index].rate_n_flags = cpu_to_le32(new_rate); - if (iwl4965_num_of_ant(tbl_type.ant_type) == 1) { + if (il4965_num_of_ant(tbl_type.ant_type) == 1) { lq_cmd->general_params.single_stream_ant_msk = tbl_type.ant_type; - } else if (iwl4965_num_of_ant(tbl_type.ant_type) == 2) { + } else if (il4965_num_of_ant(tbl_type.ant_type) == 2) { lq_cmd->general_params.dual_stream_ant_msk = tbl_type.ant_type; } /* otherwise we don't modify the existing value */ @@ -2473,20 +2473,20 @@ static void iwl4965_rs_fill_link_cmd(struct iwl_priv *priv, /* Fill rest of rate table */ while (index < LINK_QUAL_MAX_RETRY_NUM) { /* Repeat initial/next rate. - * For legacy IWL_NUMBER_TRY == 1, this loop will not execute. - * For HT IWL_HT_NUMBER_TRY == 3, this executes twice. */ + * For legacy IL_NUMBER_TRY == 1, this loop will not execute. + * For HT IL_HT_NUMBER_TRY == 3, this executes twice. */ while (repeat_rate > 0 && (index < LINK_QUAL_MAX_RETRY_NUM)) { if (is_legacy(tbl_type.lq_type)) { if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE) ant_toggle_cnt++; else if (priv && - iwl4965_rs_toggle_antenna(valid_tx_ant, + il4965_rs_toggle_antenna(valid_tx_ant, &new_rate, &tbl_type)) ant_toggle_cnt = 1; } /* Override next rate if needed for debug purposes */ - iwl4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, index); + il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, index); /* Fill next table entry */ lq_cmd->rs_table[index].rate_n_flags = @@ -2495,18 +2495,18 @@ static void iwl4965_rs_fill_link_cmd(struct iwl_priv *priv, index++; } - iwl4965_rs_get_tbl_info_from_mcs(new_rate, + il4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, &tbl_type, &rate_idx); /* Indicate to uCode which entries might be MIMO. * If initial rate was MIMO, this will finally end up - * as (IWL_HT_NUMBER_TRY * 2), after 2nd pass, otherwise 0. */ + * as (IL_HT_NUMBER_TRY * 2), after 2nd pass, otherwise 0. */ if (is_mimo(tbl_type.lq_type)) lq_cmd->general_params.mimo_delimiter = index; /* Get next rate */ - new_rate = iwl4965_rs_get_lower_rate(lq_sta, + new_rate = il4965_rs_get_lower_rate(lq_sta, &tbl_type, rate_idx, use_ht_possible); @@ -2515,21 +2515,21 @@ static void iwl4965_rs_fill_link_cmd(struct iwl_priv *priv, if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE) ant_toggle_cnt++; else if (priv && - iwl4965_rs_toggle_antenna(valid_tx_ant, + il4965_rs_toggle_antenna(valid_tx_ant, &new_rate, &tbl_type)) ant_toggle_cnt = 1; - repeat_rate = IWL_NUMBER_TRY; + repeat_rate = IL_NUMBER_TRY; } else { - repeat_rate = IWL_HT_NUMBER_TRY; + repeat_rate = IL_HT_NUMBER_TRY; } /* Don't allow HT rates after next pass. - * iwl4965_rs_get_lower_rate() will change type to LQ_A or LQ_G. */ + * il4965_rs_get_lower_rate() will change type to LQ_A or LQ_G. */ use_ht_possible = 0; /* Override next rate if needed for debug purposes */ - iwl4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, index); + il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, index); /* Fill next table entry */ lq_cmd->rs_table[index].rate_n_flags = cpu_to_le32(new_rate); @@ -2546,36 +2546,36 @@ static void iwl4965_rs_fill_link_cmd(struct iwl_priv *priv, } static void -*iwl4965_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) +*il4965_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) { return hw->priv; } /* rate scale requires free function to be implemented */ -static void iwl4965_rs_free(void *priv_rate) +static void il4965_rs_free(void *priv_rate) { return; } -static void iwl4965_rs_free_sta(void *priv_r, struct ieee80211_sta *sta, +static void il4965_rs_free_sta(void *priv_r, struct ieee80211_sta *sta, void *priv_sta) { - struct iwl_priv *priv __maybe_unused = priv_r; + struct il_priv *priv __maybe_unused = priv_r; - IWL_DEBUG_RATE(priv, "enter\n"); - IWL_DEBUG_RATE(priv, "leave\n"); + IL_DEBUG_RATE(priv, "enter\n"); + IL_DEBUG_RATE(priv, "leave\n"); } #ifdef CONFIG_MAC80211_DEBUGFS -static int iwl4965_open_file_generic(struct inode *inode, struct file *file) +static int il4965_open_file_generic(struct inode *inode, struct file *file) { file->private_data = inode->i_private; return 0; } -static void iwl4965_rs_dbgfs_set_mcs(struct iwl_lq_sta *lq_sta, +static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, u32 *rate_n_flags, int index) { - struct iwl_priv *priv; + struct il_priv *priv; u8 valid_tx_ant; u8 ant_sel_tx; @@ -2587,30 +2587,30 @@ static void iwl4965_rs_dbgfs_set_mcs(struct iwl_lq_sta *lq_sta, >> RATE_MCS_ANT_POS); if ((valid_tx_ant & ant_sel_tx) == ant_sel_tx) { *rate_n_flags = lq_sta->dbg_fixed_rate; - IWL_DEBUG_RATE(priv, "Fixed rate ON\n"); + IL_DEBUG_RATE(priv, "Fixed rate ON\n"); } else { lq_sta->dbg_fixed_rate = 0; - IWL_ERR(priv, + IL_ERR(priv, "Invalid antenna selection 0x%X, Valid is 0x%X\n", ant_sel_tx, valid_tx_ant); - IWL_DEBUG_RATE(priv, "Fixed rate OFF\n"); + IL_DEBUG_RATE(priv, "Fixed rate OFF\n"); } } else { - IWL_DEBUG_RATE(priv, "Fixed rate OFF\n"); + IL_DEBUG_RATE(priv, "Fixed rate OFF\n"); } } -static ssize_t iwl4965_rs_sta_dbgfs_scale_table_write(struct file *file, +static ssize_t il4965_rs_sta_dbgfs_scale_table_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_lq_sta *lq_sta = file->private_data; - struct iwl_priv *priv; + struct il_lq_sta *lq_sta = file->private_data; + struct il_priv *priv; char buf[64]; size_t buf_size; u32 parsed_rate; - struct iwl_station_priv *sta_priv = - container_of(lq_sta, struct iwl_station_priv, lq_sta); - struct iwl_rxon_context *ctx = sta_priv->common.ctx; + struct il_station_priv *sta_priv = + container_of(lq_sta, struct il_station_priv, lq_sta); + struct il_rxon_context *ctx = sta_priv->common.ctx; priv = lq_sta->drv; memset(buf, 0, sizeof(buf)); @@ -2627,19 +2627,19 @@ static ssize_t iwl4965_rs_sta_dbgfs_scale_table_write(struct file *file, lq_sta->active_siso_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ - IWL_DEBUG_RATE(priv, "sta_id %d rate 0x%X\n", + IL_DEBUG_RATE(priv, "sta_id %d rate 0x%X\n", lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate); if (lq_sta->dbg_fixed_rate) { - iwl4965_rs_fill_link_cmd(NULL, lq_sta, lq_sta->dbg_fixed_rate); - iwl_legacy_send_lq_cmd(lq_sta->drv, ctx, &lq_sta->lq, CMD_ASYNC, + il4965_rs_fill_link_cmd(NULL, lq_sta, lq_sta->dbg_fixed_rate); + il_send_lq_cmd(lq_sta->drv, ctx, &lq_sta->lq, CMD_ASYNC, false); } return count; } -static ssize_t iwl4965_rs_sta_dbgfs_scale_table_read(struct file *file, +static ssize_t il4965_rs_sta_dbgfs_scale_table_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { char *buff; @@ -2648,9 +2648,9 @@ static ssize_t iwl4965_rs_sta_dbgfs_scale_table_read(struct file *file, int index = 0; ssize_t ret; - struct iwl_lq_sta *lq_sta = file->private_data; - struct iwl_priv *priv; - struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); + struct il_lq_sta *lq_sta = file->private_data; + struct il_priv *priv; + struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); priv = lq_sta->drv; buff = kmalloc(1024, GFP_KERNEL); @@ -2702,19 +2702,19 @@ static ssize_t iwl4965_rs_sta_dbgfs_scale_table_read(struct file *file, lq_sta->lq.general_params.start_rate_index[3]); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { - index = iwl4965_hwrate_to_plcp_idx( + index = il4965_hwrate_to_plcp_idx( le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags)); if (is_legacy(tbl->lq_type)) { desc += sprintf(buff+desc, " rate[%d] 0x%X %smbps\n", i, le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags), - iwl_rate_mcs[index].mbps); + il_rate_mcs[index].mbps); } else { desc += sprintf(buff+desc, " rate[%d] 0x%X %smbps (%s)\n", i, le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags), - iwl_rate_mcs[index].mbps, iwl_rate_mcs[index].mcs); + il_rate_mcs[index].mbps, il_rate_mcs[index].mcs); } } @@ -2724,12 +2724,12 @@ static ssize_t iwl4965_rs_sta_dbgfs_scale_table_read(struct file *file, } static const struct file_operations rs_sta_dbgfs_scale_table_ops = { - .write = iwl4965_rs_sta_dbgfs_scale_table_write, - .read = iwl4965_rs_sta_dbgfs_scale_table_read, - .open = iwl4965_open_file_generic, + .write = il4965_rs_sta_dbgfs_scale_table_write, + .read = il4965_rs_sta_dbgfs_scale_table_read, + .open = il4965_open_file_generic, .llseek = default_llseek, }; -static ssize_t iwl4965_rs_sta_dbgfs_stats_table_read(struct file *file, +static ssize_t il4965_rs_sta_dbgfs_stats_table_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { char *buff; @@ -2737,7 +2737,7 @@ static ssize_t iwl4965_rs_sta_dbgfs_stats_table_read(struct file *file, int i, j; ssize_t ret; - struct iwl_lq_sta *lq_sta = file->private_data; + struct il_lq_sta *lq_sta = file->private_data; buff = kmalloc(1024, GFP_KERNEL); if (!buff) @@ -2754,7 +2754,7 @@ static ssize_t iwl4965_rs_sta_dbgfs_stats_table_read(struct file *file, lq_sta->lq_info[i].is_dup, lq_sta->is_green, lq_sta->lq_info[i].current_rate); - for (j = 0; j < IWL_RATE_COUNT; j++) { + for (j = 0; j < IL_RATE_COUNT; j++) { desc += sprintf(buff+desc, "counter=%d success=%d %%=%d\n", lq_sta->lq_info[i].win[j].counter, @@ -2768,21 +2768,21 @@ static ssize_t iwl4965_rs_sta_dbgfs_stats_table_read(struct file *file, } static const struct file_operations rs_sta_dbgfs_stats_table_ops = { - .read = iwl4965_rs_sta_dbgfs_stats_table_read, - .open = iwl4965_open_file_generic, + .read = il4965_rs_sta_dbgfs_stats_table_read, + .open = il4965_open_file_generic, .llseek = default_llseek, }; -static ssize_t iwl4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, +static ssize_t il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { char buff[120]; int desc = 0; ssize_t ret; - struct iwl_lq_sta *lq_sta = file->private_data; - struct iwl_priv *priv; - struct iwl_scale_tbl_info *tbl = &lq_sta->lq_info[lq_sta->active_tbl]; + struct il_lq_sta *lq_sta = file->private_data; + struct il_priv *priv; + struct il_scale_tbl_info *tbl = &lq_sta->lq_info[lq_sta->active_tbl]; priv = lq_sta->drv; @@ -2800,15 +2800,15 @@ static ssize_t iwl4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, } static const struct file_operations rs_sta_dbgfs_rate_scale_data_ops = { - .read = iwl4965_rs_sta_dbgfs_rate_scale_data_read, - .open = iwl4965_open_file_generic, + .read = il4965_rs_sta_dbgfs_rate_scale_data_read, + .open = il4965_open_file_generic, .llseek = default_llseek, }; -static void iwl4965_rs_add_debugfs(void *priv, void *priv_sta, +static void il4965_rs_add_debugfs(void *priv, void *priv_sta, struct dentry *dir) { - struct iwl_lq_sta *lq_sta = priv_sta; + struct il_lq_sta *lq_sta = priv_sta; lq_sta->rs_sta_dbgfs_scale_table_file = debugfs_create_file("rate_scale_table", S_IRUSR | S_IWUSR, dir, lq_sta, &rs_sta_dbgfs_scale_table_ops); @@ -2824,9 +2824,9 @@ static void iwl4965_rs_add_debugfs(void *priv, void *priv_sta, } -static void iwl4965_rs_remove_debugfs(void *priv, void *priv_sta) +static void il4965_rs_remove_debugfs(void *priv, void *priv_sta) { - struct iwl_lq_sta *lq_sta = priv_sta; + struct il_lq_sta *lq_sta = priv_sta; debugfs_remove(lq_sta->rs_sta_dbgfs_scale_table_file); debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file); debugfs_remove(lq_sta->rs_sta_dbgfs_rate_scale_data_file); @@ -2840,32 +2840,32 @@ static void iwl4965_rs_remove_debugfs(void *priv, void *priv_sta) * station is added we ignore it. */ static void -iwl4965_rs_rate_init_stub(void *priv_r, struct ieee80211_supported_band *sband, +il4965_rs_rate_init_stub(void *priv_r, struct ieee80211_supported_band *sband, struct ieee80211_sta *sta, void *priv_sta) { } static struct rate_control_ops rs_4965_ops = { .module = NULL, .name = IWL4965_RS_NAME, - .tx_status = iwl4965_rs_tx_status, - .get_rate = iwl4965_rs_get_rate, - .rate_init = iwl4965_rs_rate_init_stub, - .alloc = iwl4965_rs_alloc, - .free = iwl4965_rs_free, - .alloc_sta = iwl4965_rs_alloc_sta, - .free_sta = iwl4965_rs_free_sta, + .tx_status = il4965_rs_tx_status, + .get_rate = il4965_rs_get_rate, + .rate_init = il4965_rs_rate_init_stub, + .alloc = il4965_rs_alloc, + .free = il4965_rs_free, + .alloc_sta = il4965_rs_alloc_sta, + .free_sta = il4965_rs_free_sta, #ifdef CONFIG_MAC80211_DEBUGFS - .add_sta_debugfs = iwl4965_rs_add_debugfs, - .remove_sta_debugfs = iwl4965_rs_remove_debugfs, + .add_sta_debugfs = il4965_rs_add_debugfs, + .remove_sta_debugfs = il4965_rs_remove_debugfs, #endif }; -int iwl4965_rate_control_register(void) +int il4965_rate_control_register(void) { return ieee80211_rate_control_register(&rs_4965_ops); } -void iwl4965_rate_control_unregister(void) +void il4965_rate_control_unregister(void) { ieee80211_rate_control_unregister(&rs_4965_ops); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c index 2b144bbfc3c5..47cbe565a530 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c @@ -41,31 +41,31 @@ #include "iwl-4965-hw.h" #include "iwl-4965.h" -void iwl4965_rx_missed_beacon_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +void il4965_rx_missed_beacon_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_missed_beacon_notif *missed_beacon; + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_missed_beacon_notif *missed_beacon; missed_beacon = &pkt->u.missed_beacon; if (le32_to_cpu(missed_beacon->consecutive_missed_beacons) > priv->missed_beacon_threshold) { - IWL_DEBUG_CALIB(priv, + IL_DEBUG_CALIB(priv, "missed bcn cnsq %d totl %d rcd %d expctd %d\n", le32_to_cpu(missed_beacon->consecutive_missed_beacons), le32_to_cpu(missed_beacon->total_missed_becons), le32_to_cpu(missed_beacon->num_recvd_beacons), le32_to_cpu(missed_beacon->num_expected_beacons)); if (!test_bit(STATUS_SCANNING, &priv->status)) - iwl4965_init_sensitivity(priv); + il4965_init_sensitivity(priv); } } /* Calculate noise level, based on measurements during network silence just * before arriving beacon. This measurement can be done only if we know * exactly when to expect beacons, therefore only when we're associated. */ -static void iwl4965_rx_calc_noise(struct iwl_priv *priv) +static void il4965_rx_calc_noise(struct il_priv *priv) { struct statistics_rx_non_phy *rx_info; int num_active_rx = 0; @@ -98,9 +98,9 @@ static void iwl4965_rx_calc_noise(struct iwl_priv *priv) if (num_active_rx) last_rx_noise = (total_silence / num_active_rx) - 107; else - last_rx_noise = IWL_NOISE_MEAS_NOT_AVAILABLE; + last_rx_noise = IL_NOISE_MEAS_NOT_AVAILABLE; - IWL_DEBUG_CALIB(priv, "inband silence a %u, b %u, c %u, dBm %d\n", + IL_DEBUG_CALIB(priv, "inband silence a %u, b %u, c %u, dBm %d\n", bcn_silence_a, bcn_silence_b, bcn_silence_c, last_rx_noise); } @@ -111,7 +111,7 @@ static void iwl4965_rx_calc_noise(struct iwl_priv *priv) * FIXME: This function is for debugging, do not deal with * the case of counters roll-over. */ -static void iwl4965_accumulative_statistics(struct iwl_priv *priv, +static void il4965_accumulative_statistics(struct il_priv *priv, __le32 *stats) { int i, size; @@ -123,7 +123,7 @@ static void iwl4965_accumulative_statistics(struct iwl_priv *priv, prev_stats = (__le32 *)&priv->_4965.statistics; accum_stats = (u32 *)&priv->_4965.accum_statistics; - size = sizeof(struct iwl_notif_statistics); + size = sizeof(struct il_notif_statistics); general = &priv->_4965.statistics.general.common; accum_general = &priv->_4965.accum_statistics.general.common; tx = &priv->_4965.statistics.tx; @@ -151,15 +151,15 @@ static void iwl4965_accumulative_statistics(struct iwl_priv *priv, #define REG_RECALIB_PERIOD (60) -void iwl4965_rx_statistics(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +void il4965_rx_statistics(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { int change; - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); - IWL_DEBUG_RX(priv, + IL_DEBUG_RX(priv, "Statistics notification received (%d vs %d).\n", - (int)sizeof(struct iwl_notif_statistics), + (int)sizeof(struct il_notif_statistics), le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK); @@ -170,7 +170,7 @@ void iwl4965_rx_statistics(struct iwl_priv *priv, (pkt->u.stats.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK))); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS - iwl4965_accumulative_statistics(priv, (__le32 *)&pkt->u.stats); + il4965_accumulative_statistics(priv, (__le32 *)&pkt->u.stats); #endif /* TODO: reading some of statistics is unneeded */ @@ -188,28 +188,28 @@ void iwl4965_rx_statistics(struct iwl_priv *priv, if (unlikely(!test_bit(STATUS_SCANNING, &priv->status)) && (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) { - iwl4965_rx_calc_noise(priv); + il4965_rx_calc_noise(priv); queue_work(priv->workqueue, &priv->run_time_calib_work); } if (priv->cfg->ops->lib->temp_ops.temperature && change) priv->cfg->ops->lib->temp_ops.temperature(priv); } -void iwl4965_reply_statistics(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +void il4965_reply_statistics(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATISTICS_CLEAR_MSK) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS memset(&priv->_4965.accum_statistics, 0, - sizeof(struct iwl_notif_statistics)); + sizeof(struct il_notif_statistics)); memset(&priv->_4965.delta_statistics, 0, - sizeof(struct iwl_notif_statistics)); + sizeof(struct il_notif_statistics)); memset(&priv->_4965.max_delta, 0, - sizeof(struct iwl_notif_statistics)); + sizeof(struct il_notif_statistics)); #endif - IWL_DEBUG_RX(priv, "Statistics have been cleared\n"); + IL_DEBUG_RX(priv, "Statistics have been cleared\n"); } - iwl4965_rx_statistics(priv, rxb); + il4965_rx_statistics(priv, rxb); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c index a262c23553d2..3ac9aef439a6 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c @@ -34,45 +34,45 @@ #include "iwl-sta.h" #include "iwl-4965.h" -static struct iwl_link_quality_cmd * -iwl4965_sta_alloc_lq(struct iwl_priv *priv, u8 sta_id) +static struct il_link_quality_cmd * +il4965_sta_alloc_lq(struct il_priv *priv, u8 sta_id) { int i, r; - struct iwl_link_quality_cmd *link_cmd; + struct il_link_quality_cmd *link_cmd; u32 rate_flags = 0; __le32 rate_n_flags; - link_cmd = kzalloc(sizeof(struct iwl_link_quality_cmd), GFP_KERNEL); + link_cmd = kzalloc(sizeof(struct il_link_quality_cmd), GFP_KERNEL); if (!link_cmd) { - IWL_ERR(priv, "Unable to allocate memory for LQ cmd.\n"); + IL_ERR(priv, "Unable to allocate memory for LQ cmd.\n"); return NULL; } /* Set up the rate scaling to start at selected rate, fall back * all the way down to 1M in IEEE order, and then spin on 1M */ if (priv->band == IEEE80211_BAND_5GHZ) - r = IWL_RATE_6M_INDEX; + r = IL_RATE_6M_INDEX; else - r = IWL_RATE_1M_INDEX; + r = IL_RATE_1M_INDEX; - if (r >= IWL_FIRST_CCK_RATE && r <= IWL_LAST_CCK_RATE) + if (r >= IL_FIRST_CCK_RATE && r <= IL_LAST_CCK_RATE) rate_flags |= RATE_MCS_CCK_MSK; - rate_flags |= iwl4965_first_antenna(priv->hw_params.valid_tx_ant) << + rate_flags |= il4965_first_antenna(priv->hw_params.valid_tx_ant) << RATE_MCS_ANT_POS; - rate_n_flags = iwl4965_hw_set_rate_n_flags(iwlegacy_rates[r].plcp, + rate_n_flags = il4965_hw_set_rate_n_flags(iwlegacy_rates[r].plcp, rate_flags); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) link_cmd->rs_table[i].rate_n_flags = rate_n_flags; link_cmd->general_params.single_stream_ant_msk = - iwl4965_first_antenna(priv->hw_params.valid_tx_ant); + il4965_first_antenna(priv->hw_params.valid_tx_ant); link_cmd->general_params.dual_stream_ant_msk = priv->hw_params.valid_tx_ant & - ~iwl4965_first_antenna(priv->hw_params.valid_tx_ant); + ~il4965_first_antenna(priv->hw_params.valid_tx_ant); if (!link_cmd->general_params.dual_stream_ant_msk) { link_cmd->general_params.dual_stream_ant_msk = ANT_AB; - } else if (iwl4965_num_of_ant(priv->hw_params.valid_tx_ant) == 2) { + } else if (il4965_num_of_ant(priv->hw_params.valid_tx_ant) == 2) { link_cmd->general_params.dual_stream_ant_msk = priv->hw_params.valid_tx_ant; } @@ -87,25 +87,25 @@ iwl4965_sta_alloc_lq(struct iwl_priv *priv, u8 sta_id) } /* - * iwl4965_add_bssid_station - Add the special IBSS BSSID station + * il4965_add_bssid_station - Add the special IBSS BSSID station * * Function sleeps. */ int -iwl4965_add_bssid_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, +il4965_add_bssid_station(struct il_priv *priv, struct il_rxon_context *ctx, const u8 *addr, u8 *sta_id_r) { int ret; u8 sta_id; - struct iwl_link_quality_cmd *link_cmd; + struct il_link_quality_cmd *link_cmd; unsigned long flags; if (sta_id_r) - *sta_id_r = IWL_INVALID_STATION; + *sta_id_r = IL_INVALID_STATION; - ret = iwl_legacy_add_station_common(priv, ctx, addr, 0, NULL, &sta_id); + ret = il_add_station_common(priv, ctx, addr, 0, NULL, &sta_id); if (ret) { - IWL_ERR(priv, "Unable to add station %pM\n", addr); + IL_ERR(priv, "Unable to add station %pM\n", addr); return ret; } @@ -113,21 +113,21 @@ iwl4965_add_bssid_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, *sta_id_r = sta_id; spin_lock_irqsave(&priv->sta_lock, flags); - priv->stations[sta_id].used |= IWL_STA_LOCAL; + priv->stations[sta_id].used |= IL_STA_LOCAL; spin_unlock_irqrestore(&priv->sta_lock, flags); /* Set up default rate scaling table in device's station table */ - link_cmd = iwl4965_sta_alloc_lq(priv, sta_id); + link_cmd = il4965_sta_alloc_lq(priv, sta_id); if (!link_cmd) { - IWL_ERR(priv, + IL_ERR(priv, "Unable to initialize rate scaling for station %pM.\n", addr); return -ENOMEM; } - ret = iwl_legacy_send_lq_cmd(priv, ctx, link_cmd, CMD_SYNC, true); + ret = il_send_lq_cmd(priv, ctx, link_cmd, CMD_SYNC, true); if (ret) - IWL_ERR(priv, "Link quality command failed (%d)\n", ret); + IL_ERR(priv, "Link quality command failed (%d)\n", ret); spin_lock_irqsave(&priv->sta_lock, flags); priv->stations[sta_id].lq = link_cmd; @@ -136,16 +136,16 @@ iwl4965_add_bssid_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, return 0; } -static int iwl4965_static_wepkey_cmd(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +static int il4965_static_wepkey_cmd(struct il_priv *priv, + struct il_rxon_context *ctx, bool send_if_empty) { int i, not_empty = 0; - u8 buff[sizeof(struct iwl_wep_cmd) + - sizeof(struct iwl_wep_key) * WEP_KEYS_MAX]; - struct iwl_wep_cmd *wep_cmd = (struct iwl_wep_cmd *)buff; - size_t cmd_size = sizeof(struct iwl_wep_cmd); - struct iwl_host_cmd cmd = { + u8 buff[sizeof(struct il_wep_cmd) + + sizeof(struct il_wep_key) * WEP_KEYS_MAX]; + struct il_wep_cmd *wep_cmd = (struct il_wep_cmd *)buff; + size_t cmd_size = sizeof(struct il_wep_cmd); + struct il_host_cmd cmd = { .id = ctx->wep_key_cmd, .data = wep_cmd, .flags = CMD_SYNC, @@ -154,7 +154,7 @@ static int iwl4965_static_wepkey_cmd(struct iwl_priv *priv, might_sleep(); memset(wep_cmd, 0, cmd_size + - (sizeof(struct iwl_wep_key) * WEP_KEYS_MAX)); + (sizeof(struct il_wep_key) * WEP_KEYS_MAX)); for (i = 0; i < WEP_KEYS_MAX ; i++) { wep_cmd->key[i].key_index = i; @@ -173,51 +173,51 @@ static int iwl4965_static_wepkey_cmd(struct iwl_priv *priv, wep_cmd->global_key_type = WEP_KEY_WEP_TYPE; wep_cmd->num_keys = WEP_KEYS_MAX; - cmd_size += sizeof(struct iwl_wep_key) * WEP_KEYS_MAX; + cmd_size += sizeof(struct il_wep_key) * WEP_KEYS_MAX; cmd.len = cmd_size; if (not_empty || send_if_empty) - return iwl_legacy_send_cmd(priv, &cmd); + return il_send_cmd(priv, &cmd); else return 0; } -int iwl4965_restore_default_wep_keys(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +int il4965_restore_default_wep_keys(struct il_priv *priv, + struct il_rxon_context *ctx) { lockdep_assert_held(&priv->mutex); - return iwl4965_static_wepkey_cmd(priv, ctx, false); + return il4965_static_wepkey_cmd(priv, ctx, false); } -int iwl4965_remove_default_wep_key(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +int il4965_remove_default_wep_key(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf) { int ret; lockdep_assert_held(&priv->mutex); - IWL_DEBUG_WEP(priv, "Removing default WEP key: idx=%d\n", + IL_DEBUG_WEP(priv, "Removing default WEP key: idx=%d\n", keyconf->keyidx); memset(&ctx->wep_keys[keyconf->keyidx], 0, sizeof(ctx->wep_keys[0])); - if (iwl_legacy_is_rfkill(priv)) { - IWL_DEBUG_WEP(priv, + if (il_is_rfkill(priv)) { + IL_DEBUG_WEP(priv, "Not sending REPLY_WEPKEY command due to RFKILL.\n"); /* but keys in device are clear anyway so return success */ return 0; } - ret = iwl4965_static_wepkey_cmd(priv, ctx, 1); - IWL_DEBUG_WEP(priv, "Remove default WEP key: idx=%d ret=%d\n", + ret = il4965_static_wepkey_cmd(priv, ctx, 1); + IL_DEBUG_WEP(priv, "Remove default WEP key: idx=%d ret=%d\n", keyconf->keyidx, ret); return ret; } -int iwl4965_set_default_wep_key(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +int il4965_set_default_wep_key(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf) { int ret; @@ -226,7 +226,7 @@ int iwl4965_set_default_wep_key(struct iwl_priv *priv, if (keyconf->keylen != WEP_KEY_LEN_128 && keyconf->keylen != WEP_KEY_LEN_64) { - IWL_DEBUG_WEP(priv, "Bad WEP key length %d\n", keyconf->keylen); + IL_DEBUG_WEP(priv, "Bad WEP key length %d\n", keyconf->keylen); return -EINVAL; } @@ -238,21 +238,21 @@ int iwl4965_set_default_wep_key(struct iwl_priv *priv, memcpy(&ctx->wep_keys[keyconf->keyidx].key, &keyconf->key, keyconf->keylen); - ret = iwl4965_static_wepkey_cmd(priv, ctx, false); - IWL_DEBUG_WEP(priv, "Set default WEP key: len=%d idx=%d ret=%d\n", + ret = il4965_static_wepkey_cmd(priv, ctx, false); + IL_DEBUG_WEP(priv, "Set default WEP key: len=%d idx=%d ret=%d\n", keyconf->keylen, keyconf->keyidx, ret); return ret; } -static int iwl4965_set_wep_dynamic_key_info(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +static int il4965_set_wep_dynamic_key_info(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, u8 sta_id) { unsigned long flags; __le16 key_flags = 0; - struct iwl_legacy_addsta_cmd sta_cmd; + struct il_addsta_cmd sta_cmd; lockdep_assert_held(&priv->mutex); @@ -283,7 +283,7 @@ static int iwl4965_set_wep_dynamic_key_info(struct iwl_priv *priv, if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) priv->stations[sta_id].sta.key.key_offset = - iwl_legacy_get_free_ucode_key_index(priv); + il_get_free_ucode_key_index(priv); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ @@ -295,20 +295,20 @@ static int iwl4965_set_wep_dynamic_key_info(struct iwl_priv *priv, priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; memcpy(&sta_cmd, &priv->stations[sta_id].sta, - sizeof(struct iwl_legacy_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&priv->sta_lock, flags); - return iwl_legacy_send_add_sta(priv, &sta_cmd, CMD_SYNC); + return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); } -static int iwl4965_set_ccmp_dynamic_key_info(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +static int il4965_set_ccmp_dynamic_key_info(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, u8 sta_id) { unsigned long flags; __le16 key_flags = 0; - struct iwl_legacy_addsta_cmd sta_cmd; + struct il_addsta_cmd sta_cmd; lockdep_assert_held(&priv->mutex); @@ -334,7 +334,7 @@ static int iwl4965_set_ccmp_dynamic_key_info(struct iwl_priv *priv, if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) priv->stations[sta_id].sta.key.key_offset = - iwl_legacy_get_free_ucode_key_index(priv); + il_get_free_ucode_key_index(priv); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ @@ -346,14 +346,14 @@ static int iwl4965_set_ccmp_dynamic_key_info(struct iwl_priv *priv, priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; memcpy(&sta_cmd, &priv->stations[sta_id].sta, - sizeof(struct iwl_legacy_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&priv->sta_lock, flags); - return iwl_legacy_send_add_sta(priv, &sta_cmd, CMD_SYNC); + return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); } -static int iwl4965_set_tkip_dynamic_key_info(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +static int il4965_set_tkip_dynamic_key_info(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, u8 sta_id) { @@ -379,7 +379,7 @@ static int iwl4965_set_tkip_dynamic_key_info(struct iwl_priv *priv, if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) priv->stations[sta_id].sta.key.key_offset = - iwl_legacy_get_free_ucode_key_index(priv); + il_get_free_ucode_key_index(priv); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ @@ -399,8 +399,8 @@ static int iwl4965_set_tkip_dynamic_key_info(struct iwl_priv *priv, return ret; } -void iwl4965_update_tkip_key(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +void il4965_update_tkip_key(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, struct ieee80211_sta *sta, u32 iv32, u16 *phase1key) { @@ -408,14 +408,14 @@ void iwl4965_update_tkip_key(struct iwl_priv *priv, unsigned long flags; int i; - if (iwl_legacy_scan_cancel(priv)) { + if (il_scan_cancel(priv)) { /* cancel scan failed, just live w/ bad key and rely briefly on SW decryption */ return; } - sta_id = iwl_legacy_sta_id_or_broadcast(priv, ctx, sta); - if (sta_id == IWL_INVALID_STATION) + sta_id = il_sta_id_or_broadcast(priv, ctx, sta); + if (sta_id == IL_INVALID_STATION) return; spin_lock_irqsave(&priv->sta_lock, flags); @@ -429,21 +429,21 @@ void iwl4965_update_tkip_key(struct iwl_priv *priv, priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - iwl_legacy_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); + il_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); spin_unlock_irqrestore(&priv->sta_lock, flags); } -int iwl4965_remove_dynamic_key(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +int il4965_remove_dynamic_key(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, u8 sta_id) { unsigned long flags; u16 key_flags; u8 keyidx; - struct iwl_legacy_addsta_cmd sta_cmd; + struct il_addsta_cmd sta_cmd; lockdep_assert_held(&priv->mutex); @@ -453,7 +453,7 @@ int iwl4965_remove_dynamic_key(struct iwl_priv *priv, key_flags = le16_to_cpu(priv->stations[sta_id].sta.key.key_flags); keyidx = (key_flags >> STA_KEY_FLG_KEYID_POS) & 0x3; - IWL_DEBUG_WEP(priv, "Remove dynamic key: idx=%d sta=%d\n", + IL_DEBUG_WEP(priv, "Remove dynamic key: idx=%d sta=%d\n", keyconf->keyidx, sta_id); if (keyconf->keyidx != keyidx) { @@ -467,7 +467,7 @@ int iwl4965_remove_dynamic_key(struct iwl_priv *priv, } if (priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET) { - IWL_WARN(priv, "Removing wrong key %d 0x%x\n", + IL_WARN(priv, "Removing wrong key %d 0x%x\n", keyconf->keyidx, key_flags); spin_unlock_irqrestore(&priv->sta_lock, flags); return 0; @@ -475,32 +475,32 @@ int iwl4965_remove_dynamic_key(struct iwl_priv *priv, if (!test_and_clear_bit(priv->stations[sta_id].sta.key.key_offset, &priv->ucode_key_table)) - IWL_ERR(priv, "index %d not used in uCode key table.\n", + IL_ERR(priv, "index %d not used in uCode key table.\n", priv->stations[sta_id].sta.key.key_offset); memset(&priv->stations[sta_id].keyinfo, 0, - sizeof(struct iwl_hw_key)); + sizeof(struct il_hw_key)); memset(&priv->stations[sta_id].sta.key, 0, - sizeof(struct iwl4965_keyinfo)); + sizeof(struct il4965_keyinfo)); priv->stations[sta_id].sta.key.key_flags = STA_KEY_FLG_NO_ENC | STA_KEY_FLG_INVALID; priv->stations[sta_id].sta.key.key_offset = WEP_INVALID_OFFSET; priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - if (iwl_legacy_is_rfkill(priv)) { - IWL_DEBUG_WEP(priv, + if (il_is_rfkill(priv)) { + IL_DEBUG_WEP(priv, "Not sending REPLY_ADD_STA command because RFKILL enabled.\n"); spin_unlock_irqrestore(&priv->sta_lock, flags); return 0; } memcpy(&sta_cmd, &priv->stations[sta_id].sta, - sizeof(struct iwl_legacy_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&priv->sta_lock, flags); - return iwl_legacy_send_add_sta(priv, &sta_cmd, CMD_SYNC); + return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); } -int iwl4965_set_dynamic_key(struct iwl_priv *priv, struct iwl_rxon_context *ctx, +int il4965_set_dynamic_key(struct il_priv *priv, struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, u8 sta_id) { int ret; @@ -512,26 +512,26 @@ int iwl4965_set_dynamic_key(struct iwl_priv *priv, struct iwl_rxon_context *ctx, switch (keyconf->cipher) { case WLAN_CIPHER_SUITE_CCMP: - ret = iwl4965_set_ccmp_dynamic_key_info(priv, ctx, + ret = il4965_set_ccmp_dynamic_key_info(priv, ctx, keyconf, sta_id); break; case WLAN_CIPHER_SUITE_TKIP: - ret = iwl4965_set_tkip_dynamic_key_info(priv, ctx, + ret = il4965_set_tkip_dynamic_key_info(priv, ctx, keyconf, sta_id); break; case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP104: - ret = iwl4965_set_wep_dynamic_key_info(priv, ctx, + ret = il4965_set_wep_dynamic_key_info(priv, ctx, keyconf, sta_id); break; default: - IWL_ERR(priv, + IL_ERR(priv, "Unknown alg: %s cipher = %x\n", __func__, keyconf->cipher); ret = -EINVAL; } - IWL_DEBUG_WEP(priv, + IL_DEBUG_WEP(priv, "Set dynamic key: cipher=%x len=%d idx=%d sta=%d ret=%d\n", keyconf->cipher, keyconf->keylen, keyconf->keyidx, sta_id, ret); @@ -540,36 +540,36 @@ int iwl4965_set_dynamic_key(struct iwl_priv *priv, struct iwl_rxon_context *ctx, } /** - * iwl4965_alloc_bcast_station - add broadcast station into driver's station table. + * il4965_alloc_bcast_station - add broadcast station into driver's station table. * * This adds the broadcast station into the driver's station table * and marks it driver active, so that it will be restored to the * device at the next best time. */ -int iwl4965_alloc_bcast_station(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +int il4965_alloc_bcast_station(struct il_priv *priv, + struct il_rxon_context *ctx) { - struct iwl_link_quality_cmd *link_cmd; + struct il_link_quality_cmd *link_cmd; unsigned long flags; u8 sta_id; spin_lock_irqsave(&priv->sta_lock, flags); - sta_id = iwl_legacy_prep_station(priv, ctx, iwlegacy_bcast_addr, + sta_id = il_prep_station(priv, ctx, iwlegacy_bcast_addr, false, NULL); - if (sta_id == IWL_INVALID_STATION) { - IWL_ERR(priv, "Unable to prepare broadcast station\n"); + if (sta_id == IL_INVALID_STATION) { + IL_ERR(priv, "Unable to prepare broadcast station\n"); spin_unlock_irqrestore(&priv->sta_lock, flags); return -EINVAL; } - priv->stations[sta_id].used |= IWL_STA_DRIVER_ACTIVE; - priv->stations[sta_id].used |= IWL_STA_BCAST; + priv->stations[sta_id].used |= IL_STA_DRIVER_ACTIVE; + priv->stations[sta_id].used |= IL_STA_BCAST; spin_unlock_irqrestore(&priv->sta_lock, flags); - link_cmd = iwl4965_sta_alloc_lq(priv, sta_id); + link_cmd = il4965_sta_alloc_lq(priv, sta_id); if (!link_cmd) { - IWL_ERR(priv, + IL_ERR(priv, "Unable to initialize rate scaling for bcast station.\n"); return -ENOMEM; } @@ -582,21 +582,21 @@ int iwl4965_alloc_bcast_station(struct iwl_priv *priv, } /** - * iwl4965_update_bcast_station - update broadcast station's LQ command + * il4965_update_bcast_station - update broadcast station's LQ command * * Only used by iwl4965. Placed here to have all bcast station management * code together. */ -static int iwl4965_update_bcast_station(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +static int il4965_update_bcast_station(struct il_priv *priv, + struct il_rxon_context *ctx) { unsigned long flags; - struct iwl_link_quality_cmd *link_cmd; + struct il_link_quality_cmd *link_cmd; u8 sta_id = ctx->bcast_sta_id; - link_cmd = iwl4965_sta_alloc_lq(priv, sta_id); + link_cmd = il4965_sta_alloc_lq(priv, sta_id); if (!link_cmd) { - IWL_ERR(priv, + IL_ERR(priv, "Unable to initialize rate scaling for bcast station.\n"); return -ENOMEM; } @@ -605,7 +605,7 @@ static int iwl4965_update_bcast_station(struct iwl_priv *priv, if (priv->stations[sta_id].lq) kfree(priv->stations[sta_id].lq); else - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "Bcast station rate scaling has not been initialized yet.\n"); priv->stations[sta_id].lq = link_cmd; spin_unlock_irqrestore(&priv->sta_lock, flags); @@ -613,13 +613,13 @@ static int iwl4965_update_bcast_station(struct iwl_priv *priv, return 0; } -int iwl4965_update_bcast_stations(struct iwl_priv *priv) +int il4965_update_bcast_stations(struct il_priv *priv) { - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; int ret = 0; for_each_context(priv, ctx) { - ret = iwl4965_update_bcast_station(priv, ctx); + ret = il4965_update_bcast_station(priv, ctx); if (ret) break; } @@ -628,12 +628,12 @@ int iwl4965_update_bcast_stations(struct iwl_priv *priv) } /** - * iwl4965_sta_tx_modify_enable_tid - Enable Tx for this TID in station table + * il4965_sta_tx_modify_enable_tid - Enable Tx for this TID in station table */ -int iwl4965_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid) +int il4965_sta_tx_modify_enable_tid(struct il_priv *priv, int sta_id, int tid) { unsigned long flags; - struct iwl_legacy_addsta_cmd sta_cmd; + struct il_addsta_cmd sta_cmd; lockdep_assert_held(&priv->mutex); @@ -643,23 +643,23 @@ int iwl4965_sta_tx_modify_enable_tid(struct iwl_priv *priv, int sta_id, int tid) priv->stations[sta_id].sta.tid_disable_tx &= cpu_to_le16(~(1 << tid)); priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; memcpy(&sta_cmd, &priv->stations[sta_id].sta, - sizeof(struct iwl_legacy_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&priv->sta_lock, flags); - return iwl_legacy_send_add_sta(priv, &sta_cmd, CMD_SYNC); + return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); } -int iwl4965_sta_rx_agg_start(struct iwl_priv *priv, struct ieee80211_sta *sta, +int il4965_sta_rx_agg_start(struct il_priv *priv, struct ieee80211_sta *sta, int tid, u16 ssn) { unsigned long flags; int sta_id; - struct iwl_legacy_addsta_cmd sta_cmd; + struct il_addsta_cmd sta_cmd; lockdep_assert_held(&priv->mutex); - sta_id = iwl_legacy_sta_id(sta); - if (sta_id == IWL_INVALID_STATION) + sta_id = il_sta_id(sta); + if (sta_id == IL_INVALID_STATION) return -ENXIO; spin_lock_irqsave(&priv->sta_lock, flags); @@ -669,24 +669,24 @@ int iwl4965_sta_rx_agg_start(struct iwl_priv *priv, struct ieee80211_sta *sta, priv->stations[sta_id].sta.add_immediate_ba_ssn = cpu_to_le16(ssn); priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; memcpy(&sta_cmd, &priv->stations[sta_id].sta, - sizeof(struct iwl_legacy_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&priv->sta_lock, flags); - return iwl_legacy_send_add_sta(priv, &sta_cmd, CMD_SYNC); + return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); } -int iwl4965_sta_rx_agg_stop(struct iwl_priv *priv, struct ieee80211_sta *sta, +int il4965_sta_rx_agg_stop(struct il_priv *priv, struct ieee80211_sta *sta, int tid) { unsigned long flags; int sta_id; - struct iwl_legacy_addsta_cmd sta_cmd; + struct il_addsta_cmd sta_cmd; lockdep_assert_held(&priv->mutex); - sta_id = iwl_legacy_sta_id(sta); - if (sta_id == IWL_INVALID_STATION) { - IWL_ERR(priv, "Invalid station for AGG tid %d\n", tid); + sta_id = il_sta_id(sta); + if (sta_id == IL_INVALID_STATION) { + IL_ERR(priv, "Invalid station for AGG tid %d\n", tid); return -ENXIO; } @@ -696,14 +696,14 @@ int iwl4965_sta_rx_agg_stop(struct iwl_priv *priv, struct ieee80211_sta *sta, priv->stations[sta_id].sta.remove_immediate_ba_tid = (u8)tid; priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; memcpy(&sta_cmd, &priv->stations[sta_id].sta, - sizeof(struct iwl_legacy_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&priv->sta_lock, flags); - return iwl_legacy_send_add_sta(priv, &sta_cmd, CMD_SYNC); + return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); } void -iwl4965_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt) +il4965_sta_modify_sleep_tx_count(struct il_priv *priv, int sta_id, int cnt) { unsigned long flags; @@ -714,7 +714,7 @@ iwl4965_sta_modify_sleep_tx_count(struct iwl_priv *priv, int sta_id, int cnt) STA_MODIFY_SLEEP_TX_COUNT_MSK; priv->stations[sta_id].sta.sleep_tx_count = cpu_to_le16(cnt); priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - iwl_legacy_send_add_sta(priv, + il_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); spin_unlock_irqrestore(&priv->sta_lock, flags); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index e421fdfed8c3..3fdb9d9201dd 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -77,7 +77,7 @@ static const u8 tid_to_ac[] = { IEEE80211_AC_VO }; -static inline int iwl4965_get_ac_from_tid(u16 tid) +static inline int il4965_get_ac_from_tid(u16 tid) { if (likely(tid < ARRAY_SIZE(tid_to_ac))) return tid_to_ac[tid]; @@ -87,7 +87,7 @@ static inline int iwl4965_get_ac_from_tid(u16 tid) } static inline int -iwl4965_get_fifo_from_tid(struct iwl_rxon_context *ctx, u16 tid) +il4965_get_fifo_from_tid(struct il_rxon_context *ctx, u16 tid) { if (likely(tid < ARRAY_SIZE(tid_to_ac))) return ctx->ac_to_fifo[tid_to_ac[tid]]; @@ -99,9 +99,9 @@ iwl4965_get_fifo_from_tid(struct iwl_rxon_context *ctx, u16 tid) /* * handle build REPLY_TX command notification. */ -static void iwl4965_tx_cmd_build_basic(struct iwl_priv *priv, +static void il4965_tx_cmd_build_basic(struct il_priv *priv, struct sk_buff *skb, - struct iwl_tx_cmd *tx_cmd, + struct il_tx_cmd *tx_cmd, struct ieee80211_tx_info *info, struct ieee80211_hdr *hdr, u8 std_id) @@ -137,7 +137,7 @@ static void iwl4965_tx_cmd_build_basic(struct iwl_priv *priv, tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; } - iwl_legacy_tx_cmd_protection(priv, info, fc, &tx_flags); + il_tx_cmd_protection(priv, info, fc, &tx_flags); tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); if (ieee80211_is_mgmt(fc)) { @@ -156,8 +156,8 @@ static void iwl4965_tx_cmd_build_basic(struct iwl_priv *priv, #define RTS_DFAULT_RETRY_LIMIT 60 -static void iwl4965_tx_cmd_build_rate(struct iwl_priv *priv, - struct iwl_tx_cmd *tx_cmd, +static void il4965_tx_cmd_build_rate(struct il_priv *priv, + struct il_tx_cmd *tx_cmd, struct ieee80211_tx_info *info, __le16 fc) { @@ -196,34 +196,34 @@ static void iwl4965_tx_cmd_build_rate(struct iwl_priv *priv, */ rate_idx = info->control.rates[0].idx; if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS || - (rate_idx < 0) || (rate_idx > IWL_RATE_COUNT_LEGACY)) + (rate_idx < 0) || (rate_idx > IL_RATE_COUNT_LEGACY)) rate_idx = rate_lowest_index(&priv->bands[info->band], info->control.sta); /* For 5 GHZ band, remap mac80211 rate indices into driver indices */ if (info->band == IEEE80211_BAND_5GHZ) - rate_idx += IWL_FIRST_OFDM_RATE; + rate_idx += IL_FIRST_OFDM_RATE; /* Get PLCP rate for tx_cmd->rate_n_flags */ rate_plcp = iwlegacy_rates[rate_idx].plcp; /* Zero out flags for this packet */ rate_flags = 0; /* Set CCK flag as needed */ - if ((rate_idx >= IWL_FIRST_CCK_RATE) && (rate_idx <= IWL_LAST_CCK_RATE)) + if ((rate_idx >= IL_FIRST_CCK_RATE) && (rate_idx <= IL_LAST_CCK_RATE)) rate_flags |= RATE_MCS_CCK_MSK; /* Set up antennas */ - priv->mgmt_tx_ant = iwl4965_toggle_tx_ant(priv, priv->mgmt_tx_ant, + priv->mgmt_tx_ant = il4965_toggle_tx_ant(priv, priv->mgmt_tx_ant, priv->hw_params.valid_tx_ant); - rate_flags |= iwl4965_ant_idx_to_flags(priv->mgmt_tx_ant); + rate_flags |= il4965_ant_idx_to_flags(priv->mgmt_tx_ant); /* Set the rate in the TX cmd */ - tx_cmd->rate_n_flags = iwl4965_hw_set_rate_n_flags(rate_plcp, rate_flags); + tx_cmd->rate_n_flags = il4965_hw_set_rate_n_flags(rate_plcp, rate_flags); } -static void iwl4965_tx_cmd_build_hwcrypto(struct iwl_priv *priv, +static void il4965_tx_cmd_build_hwcrypto(struct il_priv *priv, struct ieee80211_tx_info *info, - struct iwl_tx_cmd *tx_cmd, + struct il_tx_cmd *tx_cmd, struct sk_buff *skb_frag, int sta_id) { @@ -235,13 +235,13 @@ static void iwl4965_tx_cmd_build_hwcrypto(struct iwl_priv *priv, memcpy(tx_cmd->key, keyconf->key, keyconf->keylen); if (info->flags & IEEE80211_TX_CTL_AMPDU) tx_cmd->tx_flags |= TX_CMD_FLG_AGG_CCMP_MSK; - IWL_DEBUG_TX(priv, "tx_cmd with AES hwcrypto\n"); + IL_DEBUG_TX(priv, "tx_cmd with AES hwcrypto\n"); break; case WLAN_CIPHER_SUITE_TKIP: tx_cmd->sec_ctl = TX_CMD_SEC_TKIP; ieee80211_get_tkip_p2k(keyconf, skb_frag, tx_cmd->key); - IWL_DEBUG_TX(priv, "tx_cmd with tkip hwcrypto\n"); + IL_DEBUG_TX(priv, "tx_cmd with tkip hwcrypto\n"); break; case WLAN_CIPHER_SUITE_WEP104: @@ -253,12 +253,12 @@ static void iwl4965_tx_cmd_build_hwcrypto(struct iwl_priv *priv, memcpy(&tx_cmd->key[3], keyconf->key, keyconf->keylen); - IWL_DEBUG_TX(priv, "Configuring packet for WEP encryption " + IL_DEBUG_TX(priv, "Configuring packet for WEP encryption " "with key %d\n", keyconf->keyidx); break; default: - IWL_ERR(priv, "Unknown encode cipher %x\n", keyconf->cipher); + IL_ERR(priv, "Unknown encode cipher %x\n", keyconf->cipher); break; } } @@ -266,18 +266,18 @@ static void iwl4965_tx_cmd_build_hwcrypto(struct iwl_priv *priv, /* * start REPLY_TX command process */ -int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) +int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); struct ieee80211_sta *sta = info->control.sta; - struct iwl_station_priv *sta_priv = NULL; - struct iwl_tx_queue *txq; - struct iwl_queue *q; - struct iwl_device_cmd *out_cmd; - struct iwl_cmd_meta *out_meta; - struct iwl_tx_cmd *tx_cmd; - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_station_priv *sta_priv = NULL; + struct il_tx_queue *txq; + struct il_queue *q; + struct il_device_cmd *out_cmd; + struct il_cmd_meta *out_meta; + struct il_tx_cmd *tx_cmd; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; int txq_id; dma_addr_t phys_addr; dma_addr_t txcmd_phys; @@ -294,11 +294,11 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) bool is_agg = false; if (info->control.vif) - ctx = iwl_legacy_rxon_ctx_from_vif(info->control.vif); + ctx = il_rxon_ctx_from_vif(info->control.vif); spin_lock_irqsave(&priv->lock, flags); - if (iwl_legacy_is_rfkill(priv)) { - IWL_DEBUG_DROP(priv, "Dropping - RF KILL\n"); + if (il_is_rfkill(priv)) { + IL_DEBUG_DROP(priv, "Dropping - RF KILL\n"); goto drop_unlock; } @@ -306,11 +306,11 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG if (ieee80211_is_auth(fc)) - IWL_DEBUG_TX(priv, "Sending AUTH frame\n"); + IL_DEBUG_TX(priv, "Sending AUTH frame\n"); else if (ieee80211_is_assoc_req(fc)) - IWL_DEBUG_TX(priv, "Sending ASSOC frame\n"); + IL_DEBUG_TX(priv, "Sending ASSOC frame\n"); else if (ieee80211_is_reassoc_req(fc)) - IWL_DEBUG_TX(priv, "Sending REASSOC frame\n"); + IL_DEBUG_TX(priv, "Sending REASSOC frame\n"); #endif hdr_len = ieee80211_hdrlen(fc); @@ -320,16 +320,16 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) sta_id = ctx->bcast_sta_id; else { /* Find index into station table for destination station */ - sta_id = iwl_legacy_sta_id_or_broadcast(priv, ctx, info->control.sta); + sta_id = il_sta_id_or_broadcast(priv, ctx, info->control.sta); - if (sta_id == IWL_INVALID_STATION) { - IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", + if (sta_id == IL_INVALID_STATION) { + IL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", hdr->addr1); goto drop_unlock; } } - IWL_DEBUG_TX(priv, "station Id %d\n", sta_id); + IL_DEBUG_TX(priv, "station Id %d\n", sta_id); if (sta) sta_priv = (void *)sta->drv_priv; @@ -345,7 +345,7 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) * For now set the counter to just 1 since we do not * support uAPSD yet. */ - iwl4965_sta_modify_sleep_tx_count(priv, sta_id, 1); + il4965_sta_modify_sleep_tx_count(priv, sta_id, 1); } /* @@ -381,7 +381,7 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) seq_number += 0x10; /* aggregation is on for this */ if (info->flags & IEEE80211_TX_CTL_AMPDU && - priv->stations[sta_id].tid[tid].agg.state == IWL_AGG_ON) { + priv->stations[sta_id].tid[tid].agg.state == IL_AGG_ON) { txq_id = priv->stations[sta_id].tid[tid].agg.txq_id; is_agg = true; } @@ -390,7 +390,7 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) txq = &priv->txq[txq_id]; q = &txq->q; - if (unlikely(iwl_legacy_queue_space(q) < q->high_mark)) { + if (unlikely(il_queue_space(q) < q->high_mark)) { spin_unlock(&priv->sta_lock); goto drop_unlock; } @@ -404,7 +404,7 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) spin_unlock(&priv->sta_lock); /* Set up driver data for this TFD */ - memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct iwl_tx_info)); + memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct il_tx_info)); txq->txb[q->write_ptr].skb = skb; txq->txb[q->write_ptr].ctx = ctx; @@ -413,7 +413,7 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) out_meta = &txq->meta[q->write_ptr]; tx_cmd = &out_cmd->cmd.tx; memset(&out_cmd->hdr, 0, sizeof(out_cmd->hdr)); - memset(tx_cmd, 0, sizeof(struct iwl_tx_cmd)); + memset(tx_cmd, 0, sizeof(struct il_tx_cmd)); /* * Set up the Tx-command (not MAC!) header. @@ -434,15 +434,15 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) tx_cmd->len = cpu_to_le16(len); if (info->control.hw_key) - iwl4965_tx_cmd_build_hwcrypto(priv, info, tx_cmd, skb, sta_id); + il4965_tx_cmd_build_hwcrypto(priv, info, tx_cmd, skb, sta_id); /* TODO need this for burst mode later on */ - iwl4965_tx_cmd_build_basic(priv, skb, tx_cmd, info, hdr, sta_id); - iwl_legacy_dbg_log_tx_data_frame(priv, len, hdr); + il4965_tx_cmd_build_basic(priv, skb, tx_cmd, info, hdr, sta_id); + il_dbg_log_tx_data_frame(priv, len, hdr); - iwl4965_tx_cmd_build_rate(priv, tx_cmd, info, fc); + il4965_tx_cmd_build_rate(priv, tx_cmd, info, fc); - iwl_legacy_update_stats(priv, true, fc, len); + il_update_stats(priv, true, fc, len); /* * Use the first empty entry in this queue's command buffer array * to contain the Tx command and MAC header concatenated together @@ -452,8 +452,8 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) * of the MAC header (device reads on dword boundaries). * We'll tell device about this padding later. */ - len = sizeof(struct iwl_tx_cmd) + - sizeof(struct iwl_cmd_header) + hdr_len; + len = sizeof(struct il_tx_cmd) + + sizeof(struct il_cmd_header) + hdr_len; firstlen = (len + 3) & ~3; /* Tell NIC about any 2-byte padding after MAC header */ @@ -490,20 +490,20 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) 0, 0); } - scratch_phys = txcmd_phys + sizeof(struct iwl_cmd_header) + - offsetof(struct iwl_tx_cmd, scratch); + scratch_phys = txcmd_phys + sizeof(struct il_cmd_header) + + offsetof(struct il_tx_cmd, scratch); /* take back ownership of DMA buffer to enable update */ pci_dma_sync_single_for_cpu(priv->pci_dev, txcmd_phys, firstlen, PCI_DMA_BIDIRECTIONAL); tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys); - tx_cmd->dram_msb_ptr = iwl_legacy_get_dma_hi_addr(scratch_phys); + tx_cmd->dram_msb_ptr = il_get_dma_hi_addr(scratch_phys); - IWL_DEBUG_TX(priv, "sequence nr = 0X%x\n", + IL_DEBUG_TX(priv, "sequence nr = 0X%x\n", le16_to_cpu(out_cmd->hdr.sequence)); - IWL_DEBUG_TX(priv, "tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); - iwl_print_hex_dump(priv, IWL_DL_TX, (u8 *)tx_cmd, sizeof(*tx_cmd)); - iwl_print_hex_dump(priv, IWL_DL_TX, (u8 *)tx_cmd->hdr, hdr_len); + IL_DEBUG_TX(priv, "tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); + il_print_hex_dump(priv, IL_DL_TX, (u8 *)tx_cmd, sizeof(*tx_cmd)); + il_print_hex_dump(priv, IL_DL_TX, (u8 *)tx_cmd->hdr, hdr_len); /* Set up entry for this TFD in Tx byte-count array */ if (info->flags & IEEE80211_TX_CTL_AMPDU) @@ -514,8 +514,8 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) firstlen, PCI_DMA_BIDIRECTIONAL); /* Tell device the write index *just past* this latest filled TFD */ - q->write_ptr = iwl_legacy_queue_inc_wrap(q->write_ptr, q->n_bd); - iwl_legacy_txq_update_write_ptr(priv, txq); + q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); + il_txq_update_write_ptr(priv, txq); spin_unlock_irqrestore(&priv->lock, flags); /* @@ -535,15 +535,15 @@ int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) if (sta_priv && sta_priv->client && !is_agg) atomic_inc(&sta_priv->pending_frames); - if ((iwl_legacy_queue_space(q) < q->high_mark) && + if ((il_queue_space(q) < q->high_mark) && priv->mac80211_registered) { if (wait_write_ptr) { spin_lock_irqsave(&priv->lock, flags); txq->need_update = 1; - iwl_legacy_txq_update_write_ptr(priv, txq); + il_txq_update_write_ptr(priv, txq); spin_unlock_irqrestore(&priv->lock, flags); } else { - iwl_legacy_stop_queue(priv, txq); + il_stop_queue(priv, txq); } } @@ -554,8 +554,8 @@ drop_unlock: return -1; } -static inline int iwl4965_alloc_dma_ptr(struct iwl_priv *priv, - struct iwl_dma_ptr *ptr, size_t size) +static inline int il4965_alloc_dma_ptr(struct il_priv *priv, + struct il_dma_ptr *ptr, size_t size) { ptr->addr = dma_alloc_coherent(&priv->pci_dev->dev, size, &ptr->dma, GFP_KERNEL); @@ -565,8 +565,8 @@ static inline int iwl4965_alloc_dma_ptr(struct iwl_priv *priv, return 0; } -static inline void iwl4965_free_dma_ptr(struct iwl_priv *priv, - struct iwl_dma_ptr *ptr) +static inline void il4965_free_dma_ptr(struct il_priv *priv, + struct il_dma_ptr *ptr) { if (unlikely(!ptr->addr)) return; @@ -576,11 +576,11 @@ static inline void iwl4965_free_dma_ptr(struct iwl_priv *priv, } /** - * iwl4965_hw_txq_ctx_free - Free TXQ Context + * il4965_hw_txq_ctx_free - Free TXQ Context * * Destroy all TX DMA queues and structures */ -void iwl4965_hw_txq_ctx_free(struct iwl_priv *priv) +void il4965_hw_txq_ctx_free(struct il_priv *priv) { int txq_id; @@ -588,59 +588,59 @@ void iwl4965_hw_txq_ctx_free(struct iwl_priv *priv) if (priv->txq) { for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) if (txq_id == priv->cmd_queue) - iwl_legacy_cmd_queue_free(priv); + il_cmd_queue_free(priv); else - iwl_legacy_tx_queue_free(priv, txq_id); + il_tx_queue_free(priv, txq_id); } - iwl4965_free_dma_ptr(priv, &priv->kw); + il4965_free_dma_ptr(priv, &priv->kw); - iwl4965_free_dma_ptr(priv, &priv->scd_bc_tbls); + il4965_free_dma_ptr(priv, &priv->scd_bc_tbls); /* free tx queue structure */ - iwl_legacy_txq_mem(priv); + il_txq_mem(priv); } /** - * iwl4965_txq_ctx_alloc - allocate TX queue context + * il4965_txq_ctx_alloc - allocate TX queue context * Allocate all Tx DMA structures and initialize them * * @param priv * @return error code */ -int iwl4965_txq_ctx_alloc(struct iwl_priv *priv) +int il4965_txq_ctx_alloc(struct il_priv *priv) { int ret; int txq_id, slots_num; unsigned long flags; /* Free all tx/cmd queues and keep-warm buffer */ - iwl4965_hw_txq_ctx_free(priv); + il4965_hw_txq_ctx_free(priv); - ret = iwl4965_alloc_dma_ptr(priv, &priv->scd_bc_tbls, + ret = il4965_alloc_dma_ptr(priv, &priv->scd_bc_tbls, priv->hw_params.scd_bc_tbls_size); if (ret) { - IWL_ERR(priv, "Scheduler BC Table allocation failed\n"); + IL_ERR(priv, "Scheduler BC Table allocation failed\n"); goto error_bc_tbls; } /* Alloc keep-warm buffer */ - ret = iwl4965_alloc_dma_ptr(priv, &priv->kw, IWL_KW_SIZE); + ret = il4965_alloc_dma_ptr(priv, &priv->kw, IL_KW_SIZE); if (ret) { - IWL_ERR(priv, "Keep Warm allocation failed\n"); + IL_ERR(priv, "Keep Warm allocation failed\n"); goto error_kw; } /* allocate tx queue structure */ - ret = iwl_legacy_alloc_txq_mem(priv); + ret = il_alloc_txq_mem(priv); if (ret) goto error; spin_lock_irqsave(&priv->lock, flags); /* Turn off all Tx DMA fifos */ - iwl4965_txq_set_sched(priv, 0); + il4965_txq_set_sched(priv, 0); /* Tell NIC where to find the "keep warm" buffer */ - iwl_legacy_write_direct32(priv, FH_KW_MEM_ADDR_REG, priv->kw.dma >> 4); + il_write_direct32(priv, FH_KW_MEM_ADDR_REG, priv->kw.dma >> 4); spin_unlock_irqrestore(&priv->lock, flags); @@ -648,11 +648,11 @@ int iwl4965_txq_ctx_alloc(struct iwl_priv *priv) for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { slots_num = (txq_id == priv->cmd_queue) ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - ret = iwl_legacy_tx_queue_init(priv, + ret = il_tx_queue_init(priv, &priv->txq[txq_id], slots_num, txq_id); if (ret) { - IWL_ERR(priv, "Tx %d queue init failed\n", txq_id); + IL_ERR(priv, "Tx %d queue init failed\n", txq_id); goto error; } } @@ -660,15 +660,15 @@ int iwl4965_txq_ctx_alloc(struct iwl_priv *priv) return ret; error: - iwl4965_hw_txq_ctx_free(priv); - iwl4965_free_dma_ptr(priv, &priv->kw); + il4965_hw_txq_ctx_free(priv); + il4965_free_dma_ptr(priv, &priv->kw); error_kw: - iwl4965_free_dma_ptr(priv, &priv->scd_bc_tbls); + il4965_free_dma_ptr(priv, &priv->scd_bc_tbls); error_bc_tbls: return ret; } -void iwl4965_txq_ctx_reset(struct iwl_priv *priv) +void il4965_txq_ctx_reset(struct il_priv *priv) { int txq_id, slots_num; unsigned long flags; @@ -676,10 +676,10 @@ void iwl4965_txq_ctx_reset(struct iwl_priv *priv) spin_lock_irqsave(&priv->lock, flags); /* Turn off all Tx DMA fifos */ - iwl4965_txq_set_sched(priv, 0); + il4965_txq_set_sched(priv, 0); /* Tell NIC where to find the "keep warm" buffer */ - iwl_legacy_write_direct32(priv, FH_KW_MEM_ADDR_REG, priv->kw.dma >> 4); + il_write_direct32(priv, FH_KW_MEM_ADDR_REG, priv->kw.dma >> 4); spin_unlock_irqrestore(&priv->lock, flags); @@ -687,15 +687,15 @@ void iwl4965_txq_ctx_reset(struct iwl_priv *priv) for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { slots_num = txq_id == priv->cmd_queue ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - iwl_legacy_tx_queue_reset(priv, &priv->txq[txq_id], + il_tx_queue_reset(priv, &priv->txq[txq_id], slots_num, txq_id); } } /** - * iwl4965_txq_ctx_stop - Stop all Tx DMA channels + * il4965_txq_ctx_stop - Stop all Tx DMA channels */ -void iwl4965_txq_ctx_stop(struct iwl_priv *priv) +void il4965_txq_ctx_stop(struct il_priv *priv) { int ch, txq_id; unsigned long flags; @@ -703,18 +703,18 @@ void iwl4965_txq_ctx_stop(struct iwl_priv *priv) /* Turn off all Tx DMA fifos */ spin_lock_irqsave(&priv->lock, flags); - iwl4965_txq_set_sched(priv, 0); + il4965_txq_set_sched(priv, 0); /* Stop each Tx DMA channel, and wait for it to be idle */ for (ch = 0; ch < priv->hw_params.dma_chnl_num; ch++) { - iwl_legacy_write_direct32(priv, + il_write_direct32(priv, FH_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0); - if (iwl_poll_direct_bit(priv, FH_TSSR_TX_STATUS_REG, + if (il_poll_direct_bit(priv, FH_TSSR_TX_STATUS_REG, FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), 1000)) - IWL_ERR(priv, "Failing on timeout while stopping" + IL_ERR(priv, "Failing on timeout while stopping" " DMA channel %d [0x%08x]", ch, - iwl_legacy_read_direct32(priv, + il_read_direct32(priv, FH_TSSR_TX_STATUS_REG)); } spin_unlock_irqrestore(&priv->lock, flags); @@ -725,9 +725,9 @@ void iwl4965_txq_ctx_stop(struct iwl_priv *priv) /* Unmap DMA from host system and free skb's */ for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) if (txq_id == priv->cmd_queue) - iwl_legacy_cmd_queue_unmap(priv); + il_cmd_queue_unmap(priv); else - iwl_legacy_tx_queue_unmap(priv, txq_id); + il_tx_queue_unmap(priv, txq_id); } /* @@ -736,7 +736,7 @@ void iwl4965_txq_ctx_stop(struct iwl_priv *priv) * Should never return anything < 7, because they should already * be in use as EDCA AC (0-3), Command (4), reserved (5, 6) */ -static int iwl4965_txq_ctx_activate_free(struct iwl_priv *priv) +static int il4965_txq_ctx_activate_free(struct il_priv *priv) { int txq_id; @@ -747,53 +747,53 @@ static int iwl4965_txq_ctx_activate_free(struct iwl_priv *priv) } /** - * iwl4965_tx_queue_stop_scheduler - Stop queue, but keep configuration + * il4965_tx_queue_stop_scheduler - Stop queue, but keep configuration */ -static void iwl4965_tx_queue_stop_scheduler(struct iwl_priv *priv, +static void il4965_tx_queue_stop_scheduler(struct il_priv *priv, u16 txq_id) { /* Simply stop the queue, but don't change any configuration; * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */ - iwl_legacy_write_prph(priv, + il_write_prph(priv, IWL49_SCD_QUEUE_STATUS_BITS(txq_id), (0 << IWL49_SCD_QUEUE_STTS_REG_POS_ACTIVE)| (1 << IWL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); } /** - * iwl4965_tx_queue_set_q2ratid - Map unique receiver/tid combination to a queue + * il4965_tx_queue_set_q2ratid - Map unique receiver/tid combination to a queue */ -static int iwl4965_tx_queue_set_q2ratid(struct iwl_priv *priv, u16 ra_tid, +static int il4965_tx_queue_set_q2ratid(struct il_priv *priv, u16 ra_tid, u16 txq_id) { u32 tbl_dw_addr; u32 tbl_dw; u16 scd_q2ratid; - scd_q2ratid = ra_tid & IWL_SCD_QUEUE_RA_TID_MAP_RATID_MSK; + scd_q2ratid = ra_tid & IL_SCD_QUEUE_RA_TID_MAP_RATID_MSK; tbl_dw_addr = priv->scd_base_addr + IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id); - tbl_dw = iwl_legacy_read_targ_mem(priv, tbl_dw_addr); + tbl_dw = il_read_targ_mem(priv, tbl_dw_addr); if (txq_id & 0x1) tbl_dw = (scd_q2ratid << 16) | (tbl_dw & 0x0000FFFF); else tbl_dw = scd_q2ratid | (tbl_dw & 0xFFFF0000); - iwl_legacy_write_targ_mem(priv, tbl_dw_addr, tbl_dw); + il_write_targ_mem(priv, tbl_dw_addr, tbl_dw); return 0; } /** - * iwl4965_tx_queue_agg_enable - Set up & enable aggregation for selected queue + * il4965_tx_queue_agg_enable - Set up & enable aggregation for selected queue * * NOTE: txq_id must be greater than IWL49_FIRST_AMPDU_QUEUE, * i.e. it must be one of the higher queues used for aggregation */ -static int iwl4965_txq_agg_enable(struct iwl_priv *priv, int txq_id, +static int il4965_txq_agg_enable(struct il_priv *priv, int txq_id, int tx_fifo, int sta_id, int tid, u16 ssn_idx) { unsigned long flags; @@ -803,7 +803,7 @@ static int iwl4965_txq_agg_enable(struct iwl_priv *priv, int txq_id, if ((IWL49_FIRST_AMPDU_QUEUE > txq_id) || (IWL49_FIRST_AMPDU_QUEUE + priv->cfg->base_params->num_of_ampdu_queues <= txq_id)) { - IWL_WARN(priv, + IL_WARN(priv, "queue number out of range: %d, must be %d to %d\n", txq_id, IWL49_FIRST_AMPDU_QUEUE, IWL49_FIRST_AMPDU_QUEUE + @@ -814,42 +814,42 @@ static int iwl4965_txq_agg_enable(struct iwl_priv *priv, int txq_id, ra_tid = BUILD_RAxTID(sta_id, tid); /* Modify device's station table to Tx this TID */ - ret = iwl4965_sta_tx_modify_enable_tid(priv, sta_id, tid); + ret = il4965_sta_tx_modify_enable_tid(priv, sta_id, tid); if (ret) return ret; spin_lock_irqsave(&priv->lock, flags); /* Stop this Tx queue before configuring it */ - iwl4965_tx_queue_stop_scheduler(priv, txq_id); + il4965_tx_queue_stop_scheduler(priv, txq_id); /* Map receiver-address / traffic-ID to this queue */ - iwl4965_tx_queue_set_q2ratid(priv, ra_tid, txq_id); + il4965_tx_queue_set_q2ratid(priv, ra_tid, txq_id); /* Set this queue as a chain-building queue */ - iwl_legacy_set_bits_prph(priv, IWL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); + il_set_bits_prph(priv, IWL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); /* Place first TFD at index corresponding to start sequence number. * Assumes that ssn_idx is valid (!= 0xFFF) */ priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); - iwl4965_set_wr_ptrs(priv, txq_id, ssn_idx); + il4965_set_wr_ptrs(priv, txq_id, ssn_idx); /* Set up Tx window size and frame limit for this queue */ - iwl_legacy_write_targ_mem(priv, + il_write_targ_mem(priv, priv->scd_base_addr + IWL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id), (SCD_WIN_SIZE << IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); - iwl_legacy_write_targ_mem(priv, priv->scd_base_addr + + il_write_targ_mem(priv, priv->scd_base_addr + IWL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id) + sizeof(u32), (SCD_FRAME_LIMIT << IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) & IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); - iwl_legacy_set_bits_prph(priv, IWL49_SCD_INTERRUPT_MASK, (1 << txq_id)); + il_set_bits_prph(priv, IWL49_SCD_INTERRUPT_MASK, (1 << txq_id)); /* Set up Status area in SRAM, map to Tx DMA/FIFO, activate the queue */ - iwl4965_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 1); + il4965_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 1); spin_unlock_irqrestore(&priv->lock, flags); @@ -857,7 +857,7 @@ static int iwl4965_txq_agg_enable(struct iwl_priv *priv, int txq_id, } -int iwl4965_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif, +int il4965_tx_agg_start(struct il_priv *priv, struct ieee80211_vif *vif, struct ieee80211_sta *sta, u16 tid, u16 *ssn) { int sta_id; @@ -865,31 +865,31 @@ int iwl4965_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif, int txq_id; int ret; unsigned long flags; - struct iwl_tid_data *tid_data; + struct il_tid_data *tid_data; - tx_fifo = iwl4965_get_fifo_from_tid(iwl_legacy_rxon_ctx_from_vif(vif), tid); + tx_fifo = il4965_get_fifo_from_tid(il_rxon_ctx_from_vif(vif), tid); if (unlikely(tx_fifo < 0)) return tx_fifo; - IWL_WARN(priv, "%s on ra = %pM tid = %d\n", + IL_WARN(priv, "%s on ra = %pM tid = %d\n", __func__, sta->addr, tid); - sta_id = iwl_legacy_sta_id(sta); - if (sta_id == IWL_INVALID_STATION) { - IWL_ERR(priv, "Start AGG on invalid station\n"); + sta_id = il_sta_id(sta); + if (sta_id == IL_INVALID_STATION) { + IL_ERR(priv, "Start AGG on invalid station\n"); return -ENXIO; } if (unlikely(tid >= MAX_TID_COUNT)) return -EINVAL; - if (priv->stations[sta_id].tid[tid].agg.state != IWL_AGG_OFF) { - IWL_ERR(priv, "Start AGG when state is not IWL_AGG_OFF !\n"); + if (priv->stations[sta_id].tid[tid].agg.state != IL_AGG_OFF) { + IL_ERR(priv, "Start AGG when state is not IL_AGG_OFF !\n"); return -ENXIO; } - txq_id = iwl4965_txq_ctx_activate_free(priv); + txq_id = il4965_txq_ctx_activate_free(priv); if (txq_id == -1) { - IWL_ERR(priv, "No free aggregation queue available\n"); + IL_ERR(priv, "No free aggregation queue available\n"); return -ENXIO; } @@ -897,11 +897,11 @@ int iwl4965_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif, tid_data = &priv->stations[sta_id].tid[tid]; *ssn = SEQ_TO_SN(tid_data->seq_number); tid_data->agg.txq_id = txq_id; - iwl_legacy_set_swq_id(&priv->txq[txq_id], - iwl4965_get_ac_from_tid(tid), txq_id); + il_set_swq_id(&priv->txq[txq_id], + il4965_get_ac_from_tid(tid), txq_id); spin_unlock_irqrestore(&priv->sta_lock, flags); - ret = iwl4965_txq_agg_enable(priv, txq_id, tx_fifo, + ret = il4965_txq_agg_enable(priv, txq_id, tx_fifo, sta_id, tid, *ssn); if (ret) return ret; @@ -909,14 +909,14 @@ int iwl4965_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif, spin_lock_irqsave(&priv->sta_lock, flags); tid_data = &priv->stations[sta_id].tid[tid]; if (tid_data->tfds_in_queue == 0) { - IWL_DEBUG_HT(priv, "HW queue is empty\n"); - tid_data->agg.state = IWL_AGG_ON; + IL_DEBUG_HT(priv, "HW queue is empty\n"); + tid_data->agg.state = IL_AGG_ON; ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid); } else { - IWL_DEBUG_HT(priv, + IL_DEBUG_HT(priv, "HW queue is NOT empty: %d packets in HW queue\n", tid_data->tfds_in_queue); - tid_data->agg.state = IWL_EMPTYING_HW_QUEUE_ADDBA; + tid_data->agg.state = IL_EMPTYING_HW_QUEUE_ADDBA; } spin_unlock_irqrestore(&priv->sta_lock, flags); return ret; @@ -926,13 +926,13 @@ int iwl4965_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif, * txq_id must be greater than IWL49_FIRST_AMPDU_QUEUE * priv->lock must be held by the caller */ -static int iwl4965_txq_agg_disable(struct iwl_priv *priv, u16 txq_id, +static int il4965_txq_agg_disable(struct il_priv *priv, u16 txq_id, u16 ssn_idx, u8 tx_fifo) { if ((IWL49_FIRST_AMPDU_QUEUE > txq_id) || (IWL49_FIRST_AMPDU_QUEUE + priv->cfg->base_params->num_of_ampdu_queues <= txq_id)) { - IWL_WARN(priv, + IL_WARN(priv, "queue number out of range: %d, must be %d to %d\n", txq_id, IWL49_FIRST_AMPDU_QUEUE, IWL49_FIRST_AMPDU_QUEUE + @@ -940,40 +940,40 @@ static int iwl4965_txq_agg_disable(struct iwl_priv *priv, u16 txq_id, return -EINVAL; } - iwl4965_tx_queue_stop_scheduler(priv, txq_id); + il4965_tx_queue_stop_scheduler(priv, txq_id); - iwl_legacy_clear_bits_prph(priv, + il_clear_bits_prph(priv, IWL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); /* supposes that ssn_idx is valid (!= 0xFFF) */ - iwl4965_set_wr_ptrs(priv, txq_id, ssn_idx); + il4965_set_wr_ptrs(priv, txq_id, ssn_idx); - iwl_legacy_clear_bits_prph(priv, + il_clear_bits_prph(priv, IWL49_SCD_INTERRUPT_MASK, (1 << txq_id)); - iwl_txq_ctx_deactivate(priv, txq_id); - iwl4965_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 0); + il_txq_ctx_deactivate(priv, txq_id); + il4965_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 0); return 0; } -int iwl4965_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif, +int il4965_tx_agg_stop(struct il_priv *priv, struct ieee80211_vif *vif, struct ieee80211_sta *sta, u16 tid) { int tx_fifo_id, txq_id, sta_id, ssn; - struct iwl_tid_data *tid_data; + struct il_tid_data *tid_data; int write_ptr, read_ptr; unsigned long flags; - tx_fifo_id = iwl4965_get_fifo_from_tid(iwl_legacy_rxon_ctx_from_vif(vif), tid); + tx_fifo_id = il4965_get_fifo_from_tid(il_rxon_ctx_from_vif(vif), tid); if (unlikely(tx_fifo_id < 0)) return tx_fifo_id; - sta_id = iwl_legacy_sta_id(sta); + sta_id = il_sta_id(sta); - if (sta_id == IWL_INVALID_STATION) { - IWL_ERR(priv, "Invalid station for AGG tid %d\n", tid); + if (sta_id == IL_INVALID_STATION) { + IL_ERR(priv, "Invalid station for AGG tid %d\n", tid); return -ENXIO; } @@ -984,19 +984,19 @@ int iwl4965_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif, txq_id = tid_data->agg.txq_id; switch (priv->stations[sta_id].tid[tid].agg.state) { - case IWL_EMPTYING_HW_QUEUE_ADDBA: + case IL_EMPTYING_HW_QUEUE_ADDBA: /* * This can happen if the peer stops aggregation * again before we've had a chance to drain the * queue we selected previously, i.e. before the * session was really started completely. */ - IWL_DEBUG_HT(priv, "AGG stop before setup done\n"); + IL_DEBUG_HT(priv, "AGG stop before setup done\n"); goto turn_off; - case IWL_AGG_ON: + case IL_AGG_ON: break; default: - IWL_WARN(priv, "Stopping AGG while state not ON or starting\n"); + IL_WARN(priv, "Stopping AGG while state not ON or starting\n"); } write_ptr = priv->txq[txq_id].q.write_ptr; @@ -1004,16 +1004,16 @@ int iwl4965_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif, /* The queue is not empty */ if (write_ptr != read_ptr) { - IWL_DEBUG_HT(priv, "Stopping a non empty AGG HW QUEUE\n"); + IL_DEBUG_HT(priv, "Stopping a non empty AGG HW QUEUE\n"); priv->stations[sta_id].tid[tid].agg.state = - IWL_EMPTYING_HW_QUEUE_DELBA; + IL_EMPTYING_HW_QUEUE_DELBA; spin_unlock_irqrestore(&priv->sta_lock, flags); return 0; } - IWL_DEBUG_HT(priv, "HW queue is empty\n"); + IL_DEBUG_HT(priv, "HW queue is empty\n"); turn_off: - priv->stations[sta_id].tid[tid].agg.state = IWL_AGG_OFF; + priv->stations[sta_id].tid[tid].agg.state = IL_AGG_OFF; /* do not restore/save irqs */ spin_unlock(&priv->sta_lock); @@ -1026,7 +1026,7 @@ int iwl4965_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif, * to deactivate the uCode queue, just return "success" to allow * mac80211 to clean up it own data. */ - iwl4965_txq_agg_disable(priv, txq_id, ssn, tx_fifo_id); + il4965_txq_agg_disable(priv, txq_id, ssn, tx_fifo_id); spin_unlock_irqrestore(&priv->lock, flags); ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); @@ -1034,39 +1034,39 @@ int iwl4965_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif, return 0; } -int iwl4965_txq_check_empty(struct iwl_priv *priv, +int il4965_txq_check_empty(struct il_priv *priv, int sta_id, u8 tid, int txq_id) { - struct iwl_queue *q = &priv->txq[txq_id].q; + struct il_queue *q = &priv->txq[txq_id].q; u8 *addr = priv->stations[sta_id].sta.sta.addr; - struct iwl_tid_data *tid_data = &priv->stations[sta_id].tid[tid]; - struct iwl_rxon_context *ctx; + struct il_tid_data *tid_data = &priv->stations[sta_id].tid[tid]; + struct il_rxon_context *ctx; ctx = &priv->contexts[priv->stations[sta_id].ctxid]; lockdep_assert_held(&priv->sta_lock); switch (priv->stations[sta_id].tid[tid].agg.state) { - case IWL_EMPTYING_HW_QUEUE_DELBA: + case IL_EMPTYING_HW_QUEUE_DELBA: /* We are reclaiming the last packet of the */ /* aggregated HW queue */ if ((txq_id == tid_data->agg.txq_id) && (q->read_ptr == q->write_ptr)) { u16 ssn = SEQ_TO_SN(tid_data->seq_number); - int tx_fifo = iwl4965_get_fifo_from_tid(ctx, tid); - IWL_DEBUG_HT(priv, + int tx_fifo = il4965_get_fifo_from_tid(ctx, tid); + IL_DEBUG_HT(priv, "HW queue empty: continue DELBA flow\n"); - iwl4965_txq_agg_disable(priv, txq_id, ssn, tx_fifo); - tid_data->agg.state = IWL_AGG_OFF; + il4965_txq_agg_disable(priv, txq_id, ssn, tx_fifo); + tid_data->agg.state = IL_AGG_OFF; ieee80211_stop_tx_ba_cb_irqsafe(ctx->vif, addr, tid); } break; - case IWL_EMPTYING_HW_QUEUE_ADDBA: + case IL_EMPTYING_HW_QUEUE_ADDBA: /* We are reclaiming the last packet of the queue */ if (tid_data->tfds_in_queue == 0) { - IWL_DEBUG_HT(priv, + IL_DEBUG_HT(priv, "HW queue empty: continue ADDBA flow\n"); - tid_data->agg.state = IWL_AGG_ON; + tid_data->agg.state = IL_AGG_ON; ieee80211_start_tx_ba_cb_irqsafe(ctx->vif, addr, tid); } break; @@ -1075,12 +1075,12 @@ int iwl4965_txq_check_empty(struct iwl_priv *priv, return 0; } -static void iwl4965_non_agg_tx_status(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +static void il4965_non_agg_tx_status(struct il_priv *priv, + struct il_rxon_context *ctx, const u8 *addr1) { struct ieee80211_sta *sta; - struct iwl_station_priv *sta_priv; + struct il_station_priv *sta_priv; rcu_read_lock(); sta = ieee80211_find_sta(ctx->vif, addr1); @@ -1095,35 +1095,35 @@ static void iwl4965_non_agg_tx_status(struct iwl_priv *priv, } static void -iwl4965_tx_status(struct iwl_priv *priv, struct iwl_tx_info *tx_info, +il4965_tx_status(struct il_priv *priv, struct il_tx_info *tx_info, bool is_agg) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx_info->skb->data; if (!is_agg) - iwl4965_non_agg_tx_status(priv, tx_info->ctx, hdr->addr1); + il4965_non_agg_tx_status(priv, tx_info->ctx, hdr->addr1); ieee80211_tx_status_irqsafe(priv->hw, tx_info->skb); } -int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index) +int il4965_tx_queue_reclaim(struct il_priv *priv, int txq_id, int index) { - struct iwl_tx_queue *txq = &priv->txq[txq_id]; - struct iwl_queue *q = &txq->q; - struct iwl_tx_info *tx_info; + struct il_tx_queue *txq = &priv->txq[txq_id]; + struct il_queue *q = &txq->q; + struct il_tx_info *tx_info; int nfreed = 0; struct ieee80211_hdr *hdr; - if ((index >= q->n_bd) || (iwl_legacy_queue_used(q, index) == 0)) { - IWL_ERR(priv, "Read index for DMA queue txq id (%d), index %d, " + if ((index >= q->n_bd) || (il_queue_used(q, index) == 0)) { + IL_ERR(priv, "Read index for DMA queue txq id (%d), index %d, " "is out of range [0-%d] %d %d.\n", txq_id, index, q->n_bd, q->write_ptr, q->read_ptr); return 0; } - for (index = iwl_legacy_queue_inc_wrap(index, q->n_bd); + for (index = il_queue_inc_wrap(index, q->n_bd); q->read_ptr != index; - q->read_ptr = iwl_legacy_queue_inc_wrap(q->read_ptr, q->n_bd)) { + q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { tx_info = &txq->txb[txq->q.read_ptr]; @@ -1134,7 +1134,7 @@ int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index) if (ieee80211_is_data_qos(hdr->frame_control)) nfreed++; - iwl4965_tx_status(priv, tx_info, + il4965_tx_status(priv, tx_info, txq_id >= IWL4965_FIRST_AMPDU_QUEUE); tx_info->skb = NULL; @@ -1144,14 +1144,14 @@ int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index) } /** - * iwl4965_tx_status_reply_compressed_ba - Update tx status from block-ack + * il4965_tx_status_reply_compressed_ba - Update tx status from block-ack * * Go through block-ack's bitmap of ACK'd frames, update driver's record of * ACK vs. not. This gets sent to mac80211, then to rate scaling algo. */ -static int iwl4965_tx_status_reply_compressed_ba(struct iwl_priv *priv, - struct iwl_ht_agg *agg, - struct iwl_compressed_ba_resp *ba_resp) +static int il4965_tx_status_reply_compressed_ba(struct il_priv *priv, + struct il_ht_agg *agg, + struct il_compressed_ba_resp *ba_resp) { int i, sh, ack; @@ -1163,13 +1163,13 @@ static int iwl4965_tx_status_reply_compressed_ba(struct iwl_priv *priv, if (unlikely(!agg->wait_for_ba)) { if (unlikely(ba_resp->bitmap)) - IWL_ERR(priv, "Received BA when not expected\n"); + IL_ERR(priv, "Received BA when not expected\n"); return -EINVAL; } /* Mark that the expected block-ack response arrived */ agg->wait_for_ba = 0; - IWL_DEBUG_TX_REPLY(priv, "BA %d %d\n", agg->start_idx, + IL_DEBUG_TX_REPLY(priv, "BA %d %d\n", agg->start_idx, ba_resp->seq_ctl); /* Calculate shift to align block-ack bits with our Tx window bits */ @@ -1178,7 +1178,7 @@ static int iwl4965_tx_status_reply_compressed_ba(struct iwl_priv *priv, sh += 0x100; if (agg->frame_count > (64 - sh)) { - IWL_DEBUG_TX_REPLY(priv, "more frames than bitmap size"); + IL_DEBUG_TX_REPLY(priv, "more frames than bitmap size"); return -1; } @@ -1195,7 +1195,7 @@ static int iwl4965_tx_status_reply_compressed_ba(struct iwl_priv *priv, while (sent_bitmap) { ack = sent_bitmap & 1ULL; successes += ack; - IWL_DEBUG_TX_REPLY(priv, "%s ON i=%d idx=%d raw=%d\n", + IL_DEBUG_TX_REPLY(priv, "%s ON i=%d idx=%d raw=%d\n", ack ? "ACK" : "NACK", i, (agg->start_idx + i) & 0xff, agg->start_idx + i); @@ -1203,7 +1203,7 @@ static int iwl4965_tx_status_reply_compressed_ba(struct iwl_priv *priv, ++i; } - IWL_DEBUG_TX_REPLY(priv, "Bitmap %llx\n", + IL_DEBUG_TX_REPLY(priv, "Bitmap %llx\n", (unsigned long long)bitmap); info = IEEE80211_SKB_CB(priv->txq[scd_flow].txb[agg->start_idx].skb); @@ -1212,7 +1212,7 @@ static int iwl4965_tx_status_reply_compressed_ba(struct iwl_priv *priv, info->flags |= IEEE80211_TX_STAT_AMPDU; info->status.ampdu_ack_len = successes; info->status.ampdu_len = agg->frame_count; - iwl4965_hwrate_to_tx_control(priv, agg->rate_n_flags, info); + il4965_hwrate_to_tx_control(priv, agg->rate_n_flags, info); return 0; } @@ -1220,7 +1220,7 @@ static int iwl4965_tx_status_reply_compressed_ba(struct iwl_priv *priv, /** * translate ucode response to mac80211 tx status control values */ -void iwl4965_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags, +void il4965_hwrate_to_tx_control(struct il_priv *priv, u32 rate_n_flags, struct ieee80211_tx_info *info) { struct ieee80211_tx_rate *r = &info->control.rates[0]; @@ -1237,22 +1237,22 @@ void iwl4965_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags, r->flags |= IEEE80211_TX_RC_DUP_DATA; if (rate_n_flags & RATE_MCS_SGI_MSK) r->flags |= IEEE80211_TX_RC_SHORT_GI; - r->idx = iwl4965_hwrate_to_mac80211_idx(rate_n_flags, info->band); + r->idx = il4965_hwrate_to_mac80211_idx(rate_n_flags, info->band); } /** - * iwl4965_rx_reply_compressed_ba - Handler for REPLY_COMPRESSED_BA + * il4965_rx_reply_compressed_ba - Handler for REPLY_COMPRESSED_BA * * Handles block-acknowledge notification from device, which reports success * of frames sent via aggregation. */ -void iwl4965_rx_reply_compressed_ba(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +void il4965_rx_reply_compressed_ba(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_compressed_ba_resp *ba_resp = &pkt->u.compressed_ba; - struct iwl_tx_queue *txq = NULL; - struct iwl_ht_agg *agg; + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_compressed_ba_resp *ba_resp = &pkt->u.compressed_ba; + struct il_tx_queue *txq = NULL; + struct il_ht_agg *agg; int index; int sta_id; int tid; @@ -1266,7 +1266,7 @@ void iwl4965_rx_reply_compressed_ba(struct iwl_priv *priv, u16 ba_resp_scd_ssn = le16_to_cpu(ba_resp->scd_ssn); if (scd_flow >= priv->hw_params.max_txq_num) { - IWL_ERR(priv, + IL_ERR(priv, "BUG_ON scd_flow is bigger than number of queues\n"); return; } @@ -1282,23 +1282,23 @@ void iwl4965_rx_reply_compressed_ba(struct iwl_priv *priv, * since it is possible happen very often and in order * not to fill the syslog, don't enable the logging by default */ - IWL_DEBUG_TX_REPLY(priv, + IL_DEBUG_TX_REPLY(priv, "BA scd_flow %d does not match txq_id %d\n", scd_flow, agg->txq_id); return; } /* Find index just before block-ack window */ - index = iwl_legacy_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd); + index = il_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd); spin_lock_irqsave(&priv->sta_lock, flags); - IWL_DEBUG_TX_REPLY(priv, "REPLY_COMPRESSED_BA [%d] Received from %pM, " + IL_DEBUG_TX_REPLY(priv, "REPLY_COMPRESSED_BA [%d] Received from %pM, " "sta_id = %d\n", agg->wait_for_ba, (u8 *) &ba_resp->sta_addr_lo32, ba_resp->sta_id); - IWL_DEBUG_TX_REPLY(priv, "TID = %d, SeqCtl = %d, bitmap = 0x%llx," + IL_DEBUG_TX_REPLY(priv, "TID = %d, SeqCtl = %d, bitmap = 0x%llx," "scd_flow = " "%d, scd_ssn = %d\n", ba_resp->tid, @@ -1306,34 +1306,34 @@ void iwl4965_rx_reply_compressed_ba(struct iwl_priv *priv, (unsigned long long)le64_to_cpu(ba_resp->bitmap), ba_resp->scd_flow, ba_resp->scd_ssn); - IWL_DEBUG_TX_REPLY(priv, "DAT start_idx = %d, bitmap = 0x%llx\n", + IL_DEBUG_TX_REPLY(priv, "DAT start_idx = %d, bitmap = 0x%llx\n", agg->start_idx, (unsigned long long)agg->bitmap); /* Update driver's record of ACK vs. not for each frame in window */ - iwl4965_tx_status_reply_compressed_ba(priv, agg, ba_resp); + il4965_tx_status_reply_compressed_ba(priv, agg, ba_resp); /* Release all TFDs before the SSN, i.e. all TFDs in front of * block-ack window (we assume that they've been successfully * transmitted ... if not, it's too late anyway). */ if (txq->q.read_ptr != (ba_resp_scd_ssn & 0xff)) { /* calculate mac80211 ampdu sw queue to wake */ - int freed = iwl4965_tx_queue_reclaim(priv, scd_flow, index); - iwl4965_free_tfds_in_queue(priv, sta_id, tid, freed); + int freed = il4965_tx_queue_reclaim(priv, scd_flow, index); + il4965_free_tfds_in_queue(priv, sta_id, tid, freed); - if ((iwl_legacy_queue_space(&txq->q) > txq->q.low_mark) && + if ((il_queue_space(&txq->q) > txq->q.low_mark) && priv->mac80211_registered && - (agg->state != IWL_EMPTYING_HW_QUEUE_DELBA)) - iwl_legacy_wake_queue(priv, txq); + (agg->state != IL_EMPTYING_HW_QUEUE_DELBA)) + il_wake_queue(priv, txq); - iwl4965_txq_check_empty(priv, sta_id, tid, scd_flow); + il4965_txq_check_empty(priv, sta_id, tid, scd_flow); } spin_unlock_irqrestore(&priv->sta_lock, flags); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -const char *iwl4965_get_tx_fail_reason(u32 status) +const char *il4965_get_tx_fail_reason(u32 status) { #define TX_STATUS_FAIL(x) case TX_STATUS_FAIL_ ## x: return #x #define TX_STATUS_POSTPONE(x) case TX_STATUS_POSTPONE_ ## x: return #x diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c index 001d148feb94..3c9df1bb5afe 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c @@ -40,30 +40,30 @@ #include "iwl-4965.h" #include "iwl-4965-calib.h" -#define IWL_AC_UNSET -1 +#define IL_AC_UNSET -1 /** - * iwl_verify_inst_sparse - verify runtime uCode image in card vs. host, + * il_verify_inst_sparse - verify runtime uCode image in card vs. host, * using sample data 100 bytes apart. If these sample points are good, * it's a pretty good bet that everything between them is good, too. */ static int -iwl4965_verify_inst_sparse(struct iwl_priv *priv, __le32 *image, u32 len) +il4965_verify_inst_sparse(struct il_priv *priv, __le32 *image, u32 len) { u32 val; int ret = 0; u32 errcnt = 0; u32 i; - IWL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); + IL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log - * if IWL_DL_IO is set */ - iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_RADDR, + * if IL_DL_IO is set */ + il_write_direct32(priv, HBUS_TARG_MEM_RADDR, i + IWL4965_RTC_INST_LOWER_BOUND); - val = _iwl_legacy_read_direct32(priv, HBUS_TARG_MEM_RDAT); + val = _il_read_direct32(priv, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { ret = -EIO; errcnt++; @@ -76,10 +76,10 @@ iwl4965_verify_inst_sparse(struct iwl_priv *priv, __le32 *image, u32 len) } /** - * iwl4965_verify_inst_full - verify runtime uCode image in card vs. host, + * il4965_verify_inst_full - verify runtime uCode image in card vs. host, * looking at all data. */ -static int iwl4965_verify_inst_full(struct iwl_priv *priv, __le32 *image, +static int il4965_verify_inst_full(struct il_priv *priv, __le32 *image, u32 len) { u32 val; @@ -87,19 +87,19 @@ static int iwl4965_verify_inst_full(struct iwl_priv *priv, __le32 *image, int ret = 0; u32 errcnt; - IWL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); + IL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); - iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_RADDR, + il_write_direct32(priv, HBUS_TARG_MEM_RADDR, IWL4965_RTC_INST_LOWER_BOUND); errcnt = 0; for (; len > 0; len -= sizeof(u32), image++) { /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log - * if IWL_DL_IO is set */ - val = _iwl_legacy_read_direct32(priv, HBUS_TARG_MEM_RDAT); + * if IL_DL_IO is set */ + val = _il_read_direct32(priv, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { - IWL_ERR(priv, "uCode INST section is invalid at " + IL_ERR(priv, "uCode INST section is invalid at " "offset 0x%x, is 0x%x, s/b 0x%x\n", save_len - len, val, le32_to_cpu(*image)); ret = -EIO; @@ -110,17 +110,17 @@ static int iwl4965_verify_inst_full(struct iwl_priv *priv, __le32 *image, } if (!errcnt) - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "ucode image in INSTRUCTION memory is good\n"); return ret; } /** - * iwl4965_verify_ucode - determine which instruction image is in SRAM, + * il4965_verify_ucode - determine which instruction image is in SRAM, * and verify its contents */ -int iwl4965_verify_ucode(struct iwl_priv *priv) +int il4965_verify_ucode(struct il_priv *priv) { __le32 *image; u32 len; @@ -129,38 +129,38 @@ int iwl4965_verify_ucode(struct iwl_priv *priv) /* Try bootstrap */ image = (__le32 *)priv->ucode_boot.v_addr; len = priv->ucode_boot.len; - ret = iwl4965_verify_inst_sparse(priv, image, len); + ret = il4965_verify_inst_sparse(priv, image, len); if (!ret) { - IWL_DEBUG_INFO(priv, "Bootstrap uCode is good in inst SRAM\n"); + IL_DEBUG_INFO(priv, "Bootstrap uCode is good in inst SRAM\n"); return 0; } /* Try initialize */ image = (__le32 *)priv->ucode_init.v_addr; len = priv->ucode_init.len; - ret = iwl4965_verify_inst_sparse(priv, image, len); + ret = il4965_verify_inst_sparse(priv, image, len); if (!ret) { - IWL_DEBUG_INFO(priv, "Initialize uCode is good in inst SRAM\n"); + IL_DEBUG_INFO(priv, "Initialize uCode is good in inst SRAM\n"); return 0; } /* Try runtime/protocol */ image = (__le32 *)priv->ucode_code.v_addr; len = priv->ucode_code.len; - ret = iwl4965_verify_inst_sparse(priv, image, len); + ret = il4965_verify_inst_sparse(priv, image, len); if (!ret) { - IWL_DEBUG_INFO(priv, "Runtime uCode is good in inst SRAM\n"); + IL_DEBUG_INFO(priv, "Runtime uCode is good in inst SRAM\n"); return 0; } - IWL_ERR(priv, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); + IL_ERR(priv, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); /* Since nothing seems to match, show first several data entries in * instruction SRAM, so maybe visual inspection will give a clue. * Selection of bootstrap image (vs. other images) is arbitrary. */ image = (__le32 *)priv->ucode_boot.v_addr; len = priv->ucode_boot.len; - ret = iwl4965_verify_inst_full(priv, image, len); + ret = il4965_verify_inst_full(priv, image, len); return ret; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index 86f4fce193e4..0f2bc5f767da 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -48,8 +48,8 @@ #include "iwl-4965.h" #include "iwl-4965-debugfs.h" -static int iwl4965_send_tx_power(struct iwl_priv *priv); -static int iwl4965_hw_get_temperature(struct iwl_priv *priv); +static int il4965_send_tx_power(struct il_priv *priv); +static int il4965_hw_get_temperature(struct il_priv *priv); /* Highest firmware API version supported */ #define IWL4965_UCODE_API_MAX 2 @@ -62,23 +62,23 @@ static int iwl4965_hw_get_temperature(struct iwl_priv *priv); #define IWL4965_MODULE_FIRMWARE(api) _IWL4965_MODULE_FIRMWARE(api) /* check contents of special bootstrap uCode SRAM */ -static int iwl4965_verify_bsm(struct iwl_priv *priv) +static int il4965_verify_bsm(struct il_priv *priv) { __le32 *image = priv->ucode_boot.v_addr; u32 len = priv->ucode_boot.len; u32 reg; u32 val; - IWL_DEBUG_INFO(priv, "Begin verify bsm\n"); + IL_DEBUG_INFO(priv, "Begin verify bsm\n"); /* verify BSM SRAM contents */ - val = iwl_legacy_read_prph(priv, BSM_WR_DWCOUNT_REG); + val = il_read_prph(priv, BSM_WR_DWCOUNT_REG); for (reg = BSM_SRAM_LOWER_BOUND; reg < BSM_SRAM_LOWER_BOUND + len; reg += sizeof(u32), image++) { - val = iwl_legacy_read_prph(priv, reg); + val = il_read_prph(priv, reg); if (val != le32_to_cpu(*image)) { - IWL_ERR(priv, "BSM uCode verification failed at " + IL_ERR(priv, "BSM uCode verification failed at " "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", BSM_SRAM_LOWER_BOUND, reg - BSM_SRAM_LOWER_BOUND, len, @@ -87,13 +87,13 @@ static int iwl4965_verify_bsm(struct iwl_priv *priv) } } - IWL_DEBUG_INFO(priv, "BSM bootstrap uCode image OK\n"); + IL_DEBUG_INFO(priv, "BSM bootstrap uCode image OK\n"); return 0; } /** - * iwl4965_load_bsm - Load bootstrap instructions + * il4965_load_bsm - Load bootstrap instructions * * BSM operation: * @@ -124,7 +124,7 @@ static int iwl4965_verify_bsm(struct iwl_priv *priv) * the runtime uCode instructions and the backup data cache into SRAM, * and re-launches the runtime uCode from where it left off. */ -static int iwl4965_load_bsm(struct iwl_priv *priv) +static int il4965_load_bsm(struct il_priv *priv) { __le32 *image = priv->ucode_boot.v_addr; u32 len = priv->ucode_boot.len; @@ -137,7 +137,7 @@ static int iwl4965_load_bsm(struct iwl_priv *priv) u32 reg_offset; int ret; - IWL_DEBUG_INFO(priv, "Begin load bsm\n"); + IL_DEBUG_INFO(priv, "Begin load bsm\n"); priv->ucode_type = UCODE_RT; @@ -147,7 +147,7 @@ static int iwl4965_load_bsm(struct iwl_priv *priv) /* Tell bootstrap uCode where to find the "Initialize" uCode * in host DRAM ... host DRAM physical address bits 35:4 for 4965. - * NOTE: iwl_init_alive_start() will replace these values, + * NOTE: il_init_alive_start() will replace these values, * after the "initialize" uCode has run, to point to * runtime/protocol instructions and backup data cache. */ @@ -156,48 +156,48 @@ static int iwl4965_load_bsm(struct iwl_priv *priv) inst_len = priv->ucode_init.len; data_len = priv->ucode_init_data.len; - iwl_legacy_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); - iwl_legacy_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); - iwl_legacy_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); - iwl_legacy_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); + il_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); + il_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); + il_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); + il_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); /* Fill BSM memory with bootstrap instructions */ for (reg_offset = BSM_SRAM_LOWER_BOUND; reg_offset < BSM_SRAM_LOWER_BOUND + len; reg_offset += sizeof(u32), image++) - _iwl_legacy_write_prph(priv, reg_offset, le32_to_cpu(*image)); + _il_write_prph(priv, reg_offset, le32_to_cpu(*image)); - ret = iwl4965_verify_bsm(priv); + ret = il4965_verify_bsm(priv); if (ret) return ret; /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ - iwl_legacy_write_prph(priv, BSM_WR_MEM_SRC_REG, 0x0); - iwl_legacy_write_prph(priv, + il_write_prph(priv, BSM_WR_MEM_SRC_REG, 0x0); + il_write_prph(priv, BSM_WR_MEM_DST_REG, IWL49_RTC_INST_LOWER_BOUND); - iwl_legacy_write_prph(priv, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); + il_write_prph(priv, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); /* Load bootstrap code into instruction SRAM now, * to prepare to load "initialize" uCode */ - iwl_legacy_write_prph(priv, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START); + il_write_prph(priv, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START); /* Wait for load of bootstrap uCode to finish */ for (i = 0; i < 100; i++) { - done = iwl_legacy_read_prph(priv, BSM_WR_CTRL_REG); + done = il_read_prph(priv, BSM_WR_CTRL_REG); if (!(done & BSM_WR_CTRL_REG_BIT_START)) break; udelay(10); } if (i < 100) - IWL_DEBUG_INFO(priv, "BSM write complete, poll %d iterations\n", i); + IL_DEBUG_INFO(priv, "BSM write complete, poll %d iterations\n", i); else { - IWL_ERR(priv, "BSM write did not complete!\n"); + IL_ERR(priv, "BSM write did not complete!\n"); return -EIO; } /* Enable future boot loads whenever power management unit triggers it * (e.g. when powering back up after power-save shutdown) */ - iwl_legacy_write_prph(priv, + il_write_prph(priv, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN); @@ -205,7 +205,7 @@ static int iwl4965_load_bsm(struct iwl_priv *priv) } /** - * iwl4965_set_ucode_ptrs - Set uCode address location + * il4965_set_ucode_ptrs - Set uCode address location * * Tell initialization uCode where to find runtime uCode. * @@ -213,7 +213,7 @@ static int iwl4965_load_bsm(struct iwl_priv *priv) * We need to replace them to load runtime uCode inst and data, * and to save runtime data when powering down. */ -static int iwl4965_set_ucode_ptrs(struct iwl_priv *priv) +static int il4965_set_ucode_ptrs(struct il_priv *priv) { dma_addr_t pinst; dma_addr_t pdata; @@ -224,22 +224,22 @@ static int iwl4965_set_ucode_ptrs(struct iwl_priv *priv) pdata = priv->ucode_data_backup.p_addr >> 4; /* Tell bootstrap uCode where to find image to load */ - iwl_legacy_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); - iwl_legacy_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); - iwl_legacy_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, + il_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); + il_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); + il_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, priv->ucode_data.len); /* Inst byte count must be last to set up, bit 31 signals uCode * that all new ptr/size info is in place */ - iwl_legacy_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, + il_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, priv->ucode_code.len | BSM_DRAM_INST_LOAD); - IWL_DEBUG_INFO(priv, "Runtime uCode pointers are set.\n"); + IL_DEBUG_INFO(priv, "Runtime uCode pointers are set.\n"); return ret; } /** - * iwl4965_init_alive_start - Called after REPLY_ALIVE notification received + * il4965_init_alive_start - Called after REPLY_ALIVE notification received * * Called after REPLY_ALIVE notification received from "initialize" uCode. * @@ -249,29 +249,29 @@ static int iwl4965_set_ucode_ptrs(struct iwl_priv *priv) * * Tell "initialize" uCode to go ahead and load the runtime uCode. */ -static void iwl4965_init_alive_start(struct iwl_priv *priv) +static void il4965_init_alive_start(struct il_priv *priv) { /* Bootstrap uCode has loaded initialize uCode ... verify inst image. * This is a paranoid check, because we would not have gotten the * "initialize" alive if code weren't properly loaded. */ - if (iwl4965_verify_ucode(priv)) { + if (il4965_verify_ucode(priv)) { /* Runtime instruction load was bad; * take it all the way back down so we can try again */ - IWL_DEBUG_INFO(priv, "Bad \"initialize\" uCode load.\n"); + IL_DEBUG_INFO(priv, "Bad \"initialize\" uCode load.\n"); goto restart; } /* Calculate temperature */ - priv->temperature = iwl4965_hw_get_temperature(priv); + priv->temperature = il4965_hw_get_temperature(priv); /* Send pointers to protocol/runtime uCode image ... init code will * load and launch runtime uCode, which will send us another "Alive" * notification. */ - IWL_DEBUG_INFO(priv, "Initialization Alive received.\n"); - if (iwl4965_set_ucode_ptrs(priv)) { + IL_DEBUG_INFO(priv, "Initialization Alive received.\n"); + if (il4965_set_ucode_ptrs(priv)) { /* Runtime instruction load won't happen; * take it all the way back down so we can try again */ - IWL_DEBUG_INFO(priv, "Couldn't set up uCode pointers.\n"); + IL_DEBUG_INFO(priv, "Couldn't set up uCode pointers.\n"); goto restart; } return; @@ -288,29 +288,29 @@ static bool iw4965_is_ht40_channel(__le32 rxon_flags) (chan_mod == CHANNEL_MODE_MIXED)); } -static void iwl4965_nic_config(struct iwl_priv *priv) +static void il4965_nic_config(struct il_priv *priv) { unsigned long flags; u16 radio_cfg; spin_lock_irqsave(&priv->lock, flags); - radio_cfg = iwl_legacy_eeprom_query16(priv, EEPROM_RADIO_CONFIG); + radio_cfg = il_eeprom_query16(priv, EEPROM_RADIO_CONFIG); /* write radio config values to register */ if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) == EEPROM_4965_RF_CFG_TYPE_MAX) - iwl_legacy_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(priv, CSR_HW_IF_CONFIG_REG, EEPROM_RF_CFG_TYPE_MSK(radio_cfg) | EEPROM_RF_CFG_STEP_MSK(radio_cfg) | EEPROM_RF_CFG_DASH_MSK(radio_cfg)); /* set CSR_HW_CONFIG_REG for uCode use */ - iwl_legacy_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(priv, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | CSR_HW_IF_CONFIG_REG_BIT_MAC_SI); - priv->calib_info = (struct iwl_eeprom_calib_info *) - iwl_legacy_eeprom_query_addr(priv, + priv->calib_info = (struct il_eeprom_calib_info *) + il_eeprom_query_addr(priv, EEPROM_4965_CALIB_TXPOWER_OFFSET); spin_unlock_irqrestore(&priv->lock, flags); @@ -319,13 +319,13 @@ static void iwl4965_nic_config(struct iwl_priv *priv) /* Reset differential Rx gains in NIC to prepare for chain noise calibration. * Called after every association, but this runs only once! * ... once chain noise is calibrated the first time, it's good forever. */ -static void iwl4965_chain_noise_reset(struct iwl_priv *priv) +static void il4965_chain_noise_reset(struct il_priv *priv) { - struct iwl_chain_noise_data *data = &(priv->chain_noise_data); + struct il_chain_noise_data *data = &(priv->chain_noise_data); - if ((data->state == IWL_CHAIN_NOISE_ALIVE) && - iwl_legacy_is_any_associated(priv)) { - struct iwl_calib_diff_gain_cmd cmd; + if ((data->state == IL_CHAIN_NOISE_ALIVE) && + il_is_any_associated(priv)) { + struct il_calib_diff_gain_cmd cmd; /* clear data for chain noise calibration algorithm */ data->chain_noise_a = 0; @@ -337,20 +337,20 @@ static void iwl4965_chain_noise_reset(struct iwl_priv *priv) data->beacon_count = 0; memset(&cmd, 0, sizeof(cmd)); - cmd.hdr.op_code = IWL_PHY_CALIBRATE_DIFF_GAIN_CMD; + cmd.hdr.op_code = IL_PHY_CALIBRATE_DIFF_GAIN_CMD; cmd.diff_gain_a = 0; cmd.diff_gain_b = 0; cmd.diff_gain_c = 0; - if (iwl_legacy_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD, + if (il_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD, sizeof(cmd), &cmd)) - IWL_ERR(priv, + IL_ERR(priv, "Could not send REPLY_PHY_CALIBRATION_CMD\n"); - data->state = IWL_CHAIN_NOISE_ACCUMULATE; - IWL_DEBUG_CALIB(priv, "Run chain_noise_calibrate\n"); + data->state = IL_CHAIN_NOISE_ACCUMULATE; + IL_DEBUG_CALIB(priv, "Run chain_noise_calibrate\n"); } } -static struct iwl_sensitivity_ranges iwl4965_sensitivity = { +static struct il_sensitivity_ranges il4965_sensitivity = { .min_nrg_cck = 97, .max_nrg_cck = 0, /* not used, set to 0 */ @@ -377,7 +377,7 @@ static struct iwl_sensitivity_ranges iwl4965_sensitivity = { .nrg_th_cca = 62, }; -static void iwl4965_set_ct_threshold(struct iwl_priv *priv) +static void il4965_set_ct_threshold(struct il_priv *priv) { /* want Kelvin */ priv->hw_params.ct_kill_threshold = @@ -385,13 +385,13 @@ static void iwl4965_set_ct_threshold(struct iwl_priv *priv) } /** - * iwl4965_hw_set_hw_params + * il4965_hw_set_hw_params * * Called when initializing driver */ -static int iwl4965_hw_set_hw_params(struct iwl_priv *priv) +static int il4965_hw_set_hw_params(struct il_priv *priv) { - if (priv->cfg->mod_params->num_of_queues >= IWL_MIN_NUM_QUEUES && + if (priv->cfg->mod_params->num_of_queues >= IL_MIN_NUM_QUEUES && priv->cfg->mod_params->num_of_queues <= IWL49_NUM_QUEUES) priv->cfg->base_params->num_of_queues = priv->cfg->mod_params->num_of_queues; @@ -400,10 +400,10 @@ static int iwl4965_hw_set_hw_params(struct iwl_priv *priv) priv->hw_params.dma_chnl_num = FH49_TCSR_CHNL_NUM; priv->hw_params.scd_bc_tbls_size = priv->cfg->base_params->num_of_queues * - sizeof(struct iwl4965_scd_bc_tbl); - priv->hw_params.tfd_size = sizeof(struct iwl_tfd); + sizeof(struct il4965_scd_bc_tbl); + priv->hw_params.tfd_size = sizeof(struct il_tfd); priv->hw_params.max_stations = IWL4965_STATION_COUNT; - priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWL4965_BROADCAST_ID; + priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IWL4965_BROADCAST_ID; priv->hw_params.max_data_size = IWL49_RTC_DATA_SIZE; priv->hw_params.max_inst_size = IWL49_RTC_INST_SIZE; priv->hw_params.max_bsm_size = BSM_SRAM_SIZE; @@ -411,20 +411,20 @@ static int iwl4965_hw_set_hw_params(struct iwl_priv *priv) priv->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR; - priv->hw_params.tx_chains_num = iwl4965_num_of_ant(priv->cfg->valid_tx_ant); - priv->hw_params.rx_chains_num = iwl4965_num_of_ant(priv->cfg->valid_rx_ant); + priv->hw_params.tx_chains_num = il4965_num_of_ant(priv->cfg->valid_tx_ant); + priv->hw_params.rx_chains_num = il4965_num_of_ant(priv->cfg->valid_rx_ant); priv->hw_params.valid_tx_ant = priv->cfg->valid_tx_ant; priv->hw_params.valid_rx_ant = priv->cfg->valid_rx_ant; - iwl4965_set_ct_threshold(priv); + il4965_set_ct_threshold(priv); - priv->hw_params.sens = &iwl4965_sensitivity; + priv->hw_params.sens = &il4965_sensitivity; priv->hw_params.beacon_time_tsf_bits = IWL4965_EXT_BEACON_TIME_POS; return 0; } -static s32 iwl4965_math_div_round(s32 num, s32 denom, s32 *res) +static s32 il4965_math_div_round(s32 num, s32 denom, s32 *res) { s32 sign = 1; @@ -443,7 +443,7 @@ static s32 iwl4965_math_div_round(s32 num, s32 denom, s32 *res) } /** - * iwl4965_get_voltage_compensation - Power supply voltage comp for txpower + * il4965_get_voltage_compensation - Power supply voltage comp for txpower * * Determines power supply voltage compensation for txpower calculations. * Returns number of 1/2-dB steps to subtract from gain table index, @@ -453,17 +453,17 @@ static s32 iwl4965_math_div_round(s32 num, s32 denom, s32 *res) * Voltage indication is higher for lower voltage. * Lower voltage requires more gain (lower gain table index). */ -static s32 iwl4965_get_voltage_compensation(s32 eeprom_voltage, +static s32 il4965_get_voltage_compensation(s32 eeprom_voltage, s32 current_voltage) { s32 comp = 0; - if ((TX_POWER_IWL_ILLEGAL_VOLTAGE == eeprom_voltage) || - (TX_POWER_IWL_ILLEGAL_VOLTAGE == current_voltage)) + if ((TX_POWER_IL_ILLEGAL_VOLTAGE == eeprom_voltage) || + (TX_POWER_IL_ILLEGAL_VOLTAGE == current_voltage)) return 0; - iwl4965_math_div_round(current_voltage - eeprom_voltage, - TX_POWER_IWL_VOLTAGE_CODES_PER_03V, &comp); + il4965_math_div_round(current_voltage - eeprom_voltage, + TX_POWER_IL_VOLTAGE_CODES_PER_03V, &comp); if (current_voltage > eeprom_voltage) comp *= 2; @@ -473,32 +473,32 @@ static s32 iwl4965_get_voltage_compensation(s32 eeprom_voltage, return comp; } -static s32 iwl4965_get_tx_atten_grp(u16 channel) +static s32 il4965_get_tx_atten_grp(u16 channel) { - if (channel >= CALIB_IWL_TX_ATTEN_GR5_FCH && - channel <= CALIB_IWL_TX_ATTEN_GR5_LCH) + if (channel >= CALIB_IL_TX_ATTEN_GR5_FCH && + channel <= CALIB_IL_TX_ATTEN_GR5_LCH) return CALIB_CH_GROUP_5; - if (channel >= CALIB_IWL_TX_ATTEN_GR1_FCH && - channel <= CALIB_IWL_TX_ATTEN_GR1_LCH) + if (channel >= CALIB_IL_TX_ATTEN_GR1_FCH && + channel <= CALIB_IL_TX_ATTEN_GR1_LCH) return CALIB_CH_GROUP_1; - if (channel >= CALIB_IWL_TX_ATTEN_GR2_FCH && - channel <= CALIB_IWL_TX_ATTEN_GR2_LCH) + if (channel >= CALIB_IL_TX_ATTEN_GR2_FCH && + channel <= CALIB_IL_TX_ATTEN_GR2_LCH) return CALIB_CH_GROUP_2; - if (channel >= CALIB_IWL_TX_ATTEN_GR3_FCH && - channel <= CALIB_IWL_TX_ATTEN_GR3_LCH) + if (channel >= CALIB_IL_TX_ATTEN_GR3_FCH && + channel <= CALIB_IL_TX_ATTEN_GR3_LCH) return CALIB_CH_GROUP_3; - if (channel >= CALIB_IWL_TX_ATTEN_GR4_FCH && - channel <= CALIB_IWL_TX_ATTEN_GR4_LCH) + if (channel >= CALIB_IL_TX_ATTEN_GR4_FCH && + channel <= CALIB_IL_TX_ATTEN_GR4_LCH) return CALIB_CH_GROUP_4; return -EINVAL; } -static u32 iwl4965_get_sub_band(const struct iwl_priv *priv, u32 channel) +static u32 il4965_get_sub_band(const struct il_priv *priv, u32 channel) { s32 b = -1; @@ -514,41 +514,41 @@ static u32 iwl4965_get_sub_band(const struct iwl_priv *priv, u32 channel) return b; } -static s32 iwl4965_interpolate_value(s32 x, s32 x1, s32 y1, s32 x2, s32 y2) +static s32 il4965_interpolate_value(s32 x, s32 x1, s32 y1, s32 x2, s32 y2) { s32 val; if (x2 == x1) return y1; else { - iwl4965_math_div_round((x2 - x) * (y1 - y2), (x2 - x1), &val); + il4965_math_div_round((x2 - x) * (y1 - y2), (x2 - x1), &val); return val + y2; } } /** - * iwl4965_interpolate_chan - Interpolate factory measurements for one channel + * il4965_interpolate_chan - Interpolate factory measurements for one channel * * Interpolates factory measurements from the two sample channels within a * sub-band, to apply to channel of interest. Interpolation is proportional to * differences in channel frequencies, which is proportional to differences * in channel number. */ -static int iwl4965_interpolate_chan(struct iwl_priv *priv, u32 channel, - struct iwl_eeprom_calib_ch_info *chan_info) +static int il4965_interpolate_chan(struct il_priv *priv, u32 channel, + struct il_eeprom_calib_ch_info *chan_info) { s32 s = -1; u32 c; u32 m; - const struct iwl_eeprom_calib_measure *m1; - const struct iwl_eeprom_calib_measure *m2; - struct iwl_eeprom_calib_measure *omeas; + const struct il_eeprom_calib_measure *m1; + const struct il_eeprom_calib_measure *m2; + struct il_eeprom_calib_measure *omeas; u32 ch_i1; u32 ch_i2; - s = iwl4965_get_sub_band(priv, channel); + s = il4965_get_sub_band(priv, channel); if (s >= EEPROM_TX_POWER_BANDS) { - IWL_ERR(priv, "Tx Power can not find channel %d\n", channel); + IL_ERR(priv, "Tx Power can not find channel %d\n", channel); return -1; } @@ -556,7 +556,7 @@ static int iwl4965_interpolate_chan(struct iwl_priv *priv, u32 channel, ch_i2 = priv->calib_info->band_info[s].ch2.ch_num; chan_info->ch_num = (u8) channel; - IWL_DEBUG_TXPOWER(priv, "channel %d subband %d factory cal ch %d & %d\n", + IL_DEBUG_TXPOWER(priv, "channel %d subband %d factory cal ch %d & %d\n", channel, s, ch_i1, ch_i2); for (c = 0; c < EEPROM_TX_POWER_TX_CHAINS; c++) { @@ -568,34 +568,34 @@ static int iwl4965_interpolate_chan(struct iwl_priv *priv, u32 channel, omeas = &(chan_info->measurements[c][m]); omeas->actual_pow = - (u8) iwl4965_interpolate_value(channel, ch_i1, + (u8) il4965_interpolate_value(channel, ch_i1, m1->actual_pow, ch_i2, m2->actual_pow); omeas->gain_idx = - (u8) iwl4965_interpolate_value(channel, ch_i1, + (u8) il4965_interpolate_value(channel, ch_i1, m1->gain_idx, ch_i2, m2->gain_idx); omeas->temperature = - (u8) iwl4965_interpolate_value(channel, ch_i1, + (u8) il4965_interpolate_value(channel, ch_i1, m1->temperature, ch_i2, m2->temperature); omeas->pa_det = - (s8) iwl4965_interpolate_value(channel, ch_i1, + (s8) il4965_interpolate_value(channel, ch_i1, m1->pa_det, ch_i2, m2->pa_det); - IWL_DEBUG_TXPOWER(priv, + IL_DEBUG_TXPOWER(priv, "chain %d meas %d AP1=%d AP2=%d AP=%d\n", c, m, m1->actual_pow, m2->actual_pow, omeas->actual_pow); - IWL_DEBUG_TXPOWER(priv, + IL_DEBUG_TXPOWER(priv, "chain %d meas %d NI1=%d NI2=%d NI=%d\n", c, m, m1->gain_idx, m2->gain_idx, omeas->gain_idx); - IWL_DEBUG_TXPOWER(priv, + IL_DEBUG_TXPOWER(priv, "chain %d meas %d PA1=%d PA2=%d PA=%d\n", c, m, m1->pa_det, m2->pa_det, omeas->pa_det); - IWL_DEBUG_TXPOWER(priv, + IL_DEBUG_TXPOWER(priv, "chain %d meas %d T1=%d T2=%d T=%d\n", c, m, m1->temperature, m2->temperature, omeas->temperature); @@ -617,7 +617,7 @@ static s32 back_off_table[] = { /* Thermal compensation values for txpower for various frequency ranges ... * ratios from 3:1 to 4.5:1 of degrees (Celsius) per half-dB gain adjust */ -static struct iwl4965_txpower_comp_entry { +static struct il4965_txpower_comp_entry { s32 degrees_per_05db_a; s32 degrees_per_05db_a_denom; } tx_power_cmp_tble[CALIB_CH_GROUP_MAX] = { @@ -867,9 +867,9 @@ static const struct gain_entry gain_table[2][108] = { } }; -static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, +static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, u8 is_ht40, u8 ctrl_chan_high, - struct iwl4965_tx_power_db *tx_power_tbl) + struct il4965_tx_power_db *tx_power_tbl) { u8 saturation_power; s32 target_power; @@ -881,9 +881,9 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, s32 txatten_grp = CALIB_CH_GROUP_MAX; int i; int c; - const struct iwl_channel_info *ch_info = NULL; - struct iwl_eeprom_calib_ch_info ch_eeprom_info; - const struct iwl_eeprom_calib_measure *measurement; + const struct il_channel_info *ch_info = NULL; + struct il_eeprom_calib_ch_info ch_eeprom_info; + const struct il_eeprom_calib_measure *measurement; s16 voltage; s32 init_voltage; s32 voltage_compensation; @@ -900,24 +900,24 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, user_target_power = 2 * priv->tx_power_user_lmt; /* Get current (RXON) channel, band, width */ - IWL_DEBUG_TXPOWER(priv, "chan %d band %d is_ht40 %d\n", channel, band, + IL_DEBUG_TXPOWER(priv, "chan %d band %d is_ht40 %d\n", channel, band, is_ht40); - ch_info = iwl_legacy_get_channel_info(priv, priv->band, channel); + ch_info = il_get_channel_info(priv, priv->band, channel); - if (!iwl_legacy_is_channel_valid(ch_info)) + if (!il_is_channel_valid(ch_info)) return -EINVAL; /* get txatten group, used to select 1) thermal txpower adjustment * and 2) mimo txpower balance between Tx chains. */ - txatten_grp = iwl4965_get_tx_atten_grp(channel); + txatten_grp = il4965_get_tx_atten_grp(channel); if (txatten_grp < 0) { - IWL_ERR(priv, "Can't find txatten group for channel %d.\n", + IL_ERR(priv, "Can't find txatten group for channel %d.\n", channel); return txatten_grp; } - IWL_DEBUG_TXPOWER(priv, "channel %d belongs to txatten group %d\n", + IL_DEBUG_TXPOWER(priv, "channel %d belongs to txatten group %d\n", channel, txatten_grp); if (is_ht40) { @@ -934,12 +934,12 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, else saturation_power = priv->calib_info->saturation_power52; - if (saturation_power < IWL_TX_POWER_SATURATION_MIN || - saturation_power > IWL_TX_POWER_SATURATION_MAX) { + if (saturation_power < IL_TX_POWER_SATURATION_MIN || + saturation_power > IL_TX_POWER_SATURATION_MAX) { if (band) - saturation_power = IWL_TX_POWER_DEFAULT_SATURATION_24; + saturation_power = IL_TX_POWER_DEFAULT_SATURATION_24; else - saturation_power = IWL_TX_POWER_DEFAULT_SATURATION_52; + saturation_power = IL_TX_POWER_DEFAULT_SATURATION_52; } /* regulatory txpower limits ... reg_limit values are in half-dBm, @@ -949,31 +949,31 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, else reg_limit = ch_info->max_power_avg * 2; - if ((reg_limit < IWL_TX_POWER_REGULATORY_MIN) || - (reg_limit > IWL_TX_POWER_REGULATORY_MAX)) { + if ((reg_limit < IL_TX_POWER_REGULATORY_MIN) || + (reg_limit > IL_TX_POWER_REGULATORY_MAX)) { if (band) - reg_limit = IWL_TX_POWER_DEFAULT_REGULATORY_24; + reg_limit = IL_TX_POWER_DEFAULT_REGULATORY_24; else - reg_limit = IWL_TX_POWER_DEFAULT_REGULATORY_52; + reg_limit = IL_TX_POWER_DEFAULT_REGULATORY_52; } /* Interpolate txpower calibration values for this channel, * based on factory calibration tests on spaced channels. */ - iwl4965_interpolate_chan(priv, channel, &ch_eeprom_info); + il4965_interpolate_chan(priv, channel, &ch_eeprom_info); /* calculate tx gain adjustment based on power supply voltage */ voltage = le16_to_cpu(priv->calib_info->voltage); init_voltage = (s32)le32_to_cpu(priv->card_alive_init.voltage); voltage_compensation = - iwl4965_get_voltage_compensation(voltage, init_voltage); + il4965_get_voltage_compensation(voltage, init_voltage); - IWL_DEBUG_TXPOWER(priv, "curr volt %d eeprom volt %d volt comp %d\n", + IL_DEBUG_TXPOWER(priv, "curr volt %d eeprom volt %d volt comp %d\n", init_voltage, voltage, voltage_compensation); /* get current temperature (Celsius) */ - current_temp = max(priv->temperature, IWL_TX_POWER_TEMPERATURE_MIN); - current_temp = min(priv->temperature, IWL_TX_POWER_TEMPERATURE_MAX); + current_temp = max(priv->temperature, IL_TX_POWER_TEMPERATURE_MIN); + current_temp = min(priv->temperature, IL_TX_POWER_TEMPERATURE_MAX); current_temp = KELVIN_TO_CELSIUS(current_temp); /* select thermal txpower adjustment params, based on channel group @@ -990,7 +990,7 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, /* txgain adjustment (in half-dB steps) based on difference * between factory and current temperature */ factory_temp = measurement->temperature; - iwl4965_math_div_round((current_temp - factory_temp) * + il4965_math_div_round((current_temp - factory_temp) * degrees_per_05db_denom, degrees_per_05db_num, &temperature_comp[c]); @@ -998,13 +998,13 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, factory_gain_index[c] = measurement->gain_idx; factory_actual_pwr[c] = measurement->actual_pow; - IWL_DEBUG_TXPOWER(priv, "chain = %d\n", c); - IWL_DEBUG_TXPOWER(priv, "fctry tmp %d, " + IL_DEBUG_TXPOWER(priv, "chain = %d\n", c); + IL_DEBUG_TXPOWER(priv, "fctry tmp %d, " "curr tmp %d, comp %d steps\n", factory_temp, current_temp, temperature_comp[c]); - IWL_DEBUG_TXPOWER(priv, "fctry idx %d, fctry pwr %d\n", + IL_DEBUG_TXPOWER(priv, "fctry idx %d, fctry pwr %d\n", factory_gain_index[c], factory_actual_pwr[c]); } @@ -1012,14 +1012,14 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, /* for each of 33 bit-rates (including 1 for CCK) */ for (i = 0; i < POWER_TABLE_NUM_ENTRIES; i++) { u8 is_mimo_rate; - union iwl4965_tx_power_dual_stream tx_power; + union il4965_tx_power_dual_stream tx_power; /* for mimo, reduce each chain's txpower by half * (3dB, 6 steps), so total output power is regulatory * compliant. */ if (i & 0x8) { current_regulatory = reg_limit - - IWL_TX_POWER_MIMO_REGULATORY_COMPENSATION; + IL_TX_POWER_MIMO_REGULATORY_COMPENSATION; is_mimo_rate = 1; } else { current_regulatory = reg_limit; @@ -1037,7 +1037,7 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, if (target_power > power_limit) target_power = power_limit; - IWL_DEBUG_TXPOWER(priv, "rate %d sat %d reg %d usr %d tgt %d\n", + IL_DEBUG_TXPOWER(priv, "rate %d sat %d reg %d usr %d tgt %d\n", i, saturation_power - back_off_table[i], current_regulatory, user_target_power, target_power); @@ -1061,7 +1061,7 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, voltage_compensation + atten_value); -/* IWL_DEBUG_TXPOWER(priv, "calculated txpower index %d\n", +/* IL_DEBUG_TXPOWER(priv, "calculated txpower index %d\n", power_index); */ if (power_index < get_min_power_index(i, band)) @@ -1074,16 +1074,16 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, /* CCK, rate 32, reduce txpower for CCK */ if (i == POWER_TABLE_CCK_ENTRY) power_index += - IWL_TX_POWER_CCK_COMPENSATION_C_STEP; + IL_TX_POWER_CCK_COMPENSATION_C_STEP; /* stay within the table! */ if (power_index > 107) { - IWL_WARN(priv, "txpower index %d > 107\n", + IL_WARN(priv, "txpower index %d > 107\n", power_index); power_index = 107; } if (power_index < 0) { - IWL_WARN(priv, "txpower index %d < 0\n", + IL_WARN(priv, "txpower index %d < 0\n", power_index); power_index = 0; } @@ -1094,7 +1094,7 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, tx_power.s.dsp_predis_atten[c] = gain_table[band][power_index].dsp; - IWL_DEBUG_TXPOWER(priv, "chain %d mimo %d index %d " + IL_DEBUG_TXPOWER(priv, "chain %d mimo %d index %d " "gain 0x%02x dsp %d\n", c, atten_value, power_index, tx_power.s.radio_tx_gain[c], @@ -1109,19 +1109,19 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, } /** - * iwl4965_send_tx_power - Configure the TXPOWER level user limit + * il4965_send_tx_power - Configure the TXPOWER level user limit * * Uses the active RXON for channel, band, and characteristics (ht40, high) * The power limit is taken from priv->tx_power_user_lmt. */ -static int iwl4965_send_tx_power(struct iwl_priv *priv) +static int il4965_send_tx_power(struct il_priv *priv) { - struct iwl4965_txpowertable_cmd cmd = { 0 }; + struct il4965_txpowertable_cmd cmd = { 0 }; int ret; u8 band = 0; bool is_ht40 = false; u8 ctrl_chan_high = 0; - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &priv->status), "TX Power requested while scanning!\n")) @@ -1137,26 +1137,26 @@ static int iwl4965_send_tx_power(struct iwl_priv *priv) cmd.band = band; cmd.channel = ctx->active.channel; - ret = iwl4965_fill_txpower_tbl(priv, band, + ret = il4965_fill_txpower_tbl(priv, band, le16_to_cpu(ctx->active.channel), is_ht40, ctrl_chan_high, &cmd.tx_power); if (ret) goto out; - ret = iwl_legacy_send_cmd_pdu(priv, + ret = il_send_cmd_pdu(priv, REPLY_TX_PWR_TABLE_CMD, sizeof(cmd), &cmd); out: return ret; } -static int iwl4965_send_rxon_assoc(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +static int il4965_send_rxon_assoc(struct il_priv *priv, + struct il_rxon_context *ctx) { int ret = 0; - struct iwl4965_rxon_assoc_cmd rxon_assoc; - const struct iwl_legacy_rxon_cmd *rxon1 = &ctx->staging; - const struct iwl_legacy_rxon_cmd *rxon2 = &ctx->active; + struct il4965_rxon_assoc_cmd rxon_assoc; + const struct il_rxon_cmd *rxon1 = &ctx->staging; + const struct il_rxon_cmd *rxon2 = &ctx->active; if ((rxon1->flags == rxon2->flags) && (rxon1->filter_flags == rxon2->filter_flags) && @@ -1167,7 +1167,7 @@ static int iwl4965_send_rxon_assoc(struct iwl_priv *priv, rxon2->ofdm_ht_dual_stream_basic_rates) && (rxon1->rx_chain == rxon2->rx_chain) && (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { - IWL_DEBUG_INFO(priv, "Using current RXON_ASSOC. Not resending.\n"); + IL_DEBUG_INFO(priv, "Using current RXON_ASSOC. Not resending.\n"); return 0; } @@ -1182,21 +1182,21 @@ static int iwl4965_send_rxon_assoc(struct iwl_priv *priv, ctx->staging.ofdm_ht_dual_stream_basic_rates; rxon_assoc.rx_chain_select_flags = ctx->staging.rx_chain; - ret = iwl_legacy_send_cmd_pdu_async(priv, REPLY_RXON_ASSOC, + ret = il_send_cmd_pdu_async(priv, REPLY_RXON_ASSOC, sizeof(rxon_assoc), &rxon_assoc, NULL); return ret; } -static int iwl4965_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) +static int il4965_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) { /* cast away the const for active_rxon in this function */ - struct iwl_legacy_rxon_cmd *active_rxon = (void *)&ctx->active; + struct il_rxon_cmd *active_rxon = (void *)&ctx->active; int ret; bool new_assoc = !!(ctx->staging.filter_flags & RXON_FILTER_ASSOC_MSK); - if (!iwl_legacy_is_alive(priv)) + if (!il_is_alive(priv)) return -EBUSY; if (!ctx->is_active) @@ -1205,9 +1205,9 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *c /* always get timestamp with Rx frame */ ctx->staging.flags |= RXON_FLG_TSF2HOST_MSK; - ret = iwl_legacy_check_rxon_cmd(priv, ctx); + ret = il_check_rxon_cmd(priv, ctx); if (ret) { - IWL_ERR(priv, "Invalid RXON configuration. Not committing.\n"); + IL_ERR(priv, "Invalid RXON configuration. Not committing.\n"); return -EINVAL; } @@ -1217,28 +1217,28 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *c */ if (test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status) && (priv->switch_channel != ctx->staging.channel)) { - IWL_DEBUG_11H(priv, "abort channel switch on %d\n", + IL_DEBUG_11H(priv, "abort channel switch on %d\n", le16_to_cpu(priv->switch_channel)); - iwl_legacy_chswitch_done(priv, false); + il_chswitch_done(priv, false); } /* If we don't need to send a full RXON, we can use - * iwl_rxon_assoc_cmd which is used to reconfigure filter + * il_rxon_assoc_cmd which is used to reconfigure filter * and other flags for the current radio configuration. */ - if (!iwl_legacy_full_rxon_required(priv, ctx)) { - ret = iwl_legacy_send_rxon_assoc(priv, ctx); + if (!il_full_rxon_required(priv, ctx)) { + ret = il_send_rxon_assoc(priv, ctx); if (ret) { - IWL_ERR(priv, "Error setting RXON_ASSOC (%d)\n", ret); + IL_ERR(priv, "Error setting RXON_ASSOC (%d)\n", ret); return ret; } memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); - iwl_legacy_print_rx_config_cmd(priv, ctx); + il_print_rx_config_cmd(priv, ctx); /* * We do not commit tx power settings while channel changing, * do it now if tx power changed. */ - iwl_legacy_set_tx_power(priv, priv->tx_power_next, false); + il_set_tx_power(priv, priv->tx_power_next, false); return 0; } @@ -1246,31 +1246,31 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *c * an RXON_ASSOC and the new config wants the associated mask enabled, * we must clear the associated from the active configuration * before we apply the new config */ - if (iwl_legacy_is_associated_ctx(ctx) && new_assoc) { - IWL_DEBUG_INFO(priv, "Toggling associated bit on current RXON\n"); + if (il_is_associated_ctx(ctx) && new_assoc) { + IL_DEBUG_INFO(priv, "Toggling associated bit on current RXON\n"); active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; - ret = iwl_legacy_send_cmd_pdu(priv, ctx->rxon_cmd, - sizeof(struct iwl_legacy_rxon_cmd), + ret = il_send_cmd_pdu(priv, ctx->rxon_cmd, + sizeof(struct il_rxon_cmd), active_rxon); /* If the mask clearing failed then we set * active_rxon back to what it was previously */ if (ret) { active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK; - IWL_ERR(priv, "Error clearing ASSOC_MSK (%d)\n", ret); + IL_ERR(priv, "Error clearing ASSOC_MSK (%d)\n", ret); return ret; } - iwl_legacy_clear_ucode_stations(priv, ctx); - iwl_legacy_restore_stations(priv, ctx); - ret = iwl4965_restore_default_wep_keys(priv, ctx); + il_clear_ucode_stations(priv, ctx); + il_restore_stations(priv, ctx); + ret = il4965_restore_default_wep_keys(priv, ctx); if (ret) { - IWL_ERR(priv, "Failed to restore WEP keys (%d)\n", ret); + IL_ERR(priv, "Failed to restore WEP keys (%d)\n", ret); return ret; } } - IWL_DEBUG_INFO(priv, "Sending RXON\n" + IL_DEBUG_INFO(priv, "Sending RXON\n" "* with%s RXON_FILTER_ASSOC_MSK\n" "* channel = %d\n" "* bssid = %pM\n", @@ -1278,7 +1278,7 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *c le16_to_cpu(ctx->staging.channel), ctx->staging.bssid_addr); - iwl_legacy_set_rxon_hwcrypto(priv, ctx, + il_set_rxon_hwcrypto(priv, ctx, !priv->cfg->mod_params->sw_crypto); /* Apply the new configuration @@ -1286,19 +1286,19 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *c * stations is needed after it (the RXON command) completes */ if (!new_assoc) { - ret = iwl_legacy_send_cmd_pdu(priv, ctx->rxon_cmd, - sizeof(struct iwl_legacy_rxon_cmd), &ctx->staging); + ret = il_send_cmd_pdu(priv, ctx->rxon_cmd, + sizeof(struct il_rxon_cmd), &ctx->staging); if (ret) { - IWL_ERR(priv, "Error setting new RXON (%d)\n", ret); + IL_ERR(priv, "Error setting new RXON (%d)\n", ret); return ret; } - IWL_DEBUG_INFO(priv, "Return from !new_assoc RXON.\n"); + IL_DEBUG_INFO(priv, "Return from !new_assoc RXON.\n"); memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); - iwl_legacy_clear_ucode_stations(priv, ctx); - iwl_legacy_restore_stations(priv, ctx); - ret = iwl4965_restore_default_wep_keys(priv, ctx); + il_clear_ucode_stations(priv, ctx); + il_restore_stations(priv, ctx); + ret = il4965_restore_default_wep_keys(priv, ctx); if (ret) { - IWL_ERR(priv, "Failed to restore WEP keys (%d)\n", ret); + IL_ERR(priv, "Failed to restore WEP keys (%d)\n", ret); return ret; } } @@ -1307,39 +1307,39 @@ static int iwl4965_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *c /* Apply the new configuration * RXON assoc doesn't clear the station table in uCode, */ - ret = iwl_legacy_send_cmd_pdu(priv, ctx->rxon_cmd, - sizeof(struct iwl_legacy_rxon_cmd), &ctx->staging); + ret = il_send_cmd_pdu(priv, ctx->rxon_cmd, + sizeof(struct il_rxon_cmd), &ctx->staging); if (ret) { - IWL_ERR(priv, "Error setting new RXON (%d)\n", ret); + IL_ERR(priv, "Error setting new RXON (%d)\n", ret); return ret; } memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); } - iwl_legacy_print_rx_config_cmd(priv, ctx); + il_print_rx_config_cmd(priv, ctx); - iwl4965_init_sensitivity(priv); + il4965_init_sensitivity(priv); /* If we issue a new RXON command which required a tune then we must * send a new TXPOWER command or we won't be able to Tx any frames */ - ret = iwl_legacy_set_tx_power(priv, priv->tx_power_next, true); + ret = il_set_tx_power(priv, priv->tx_power_next, true); if (ret) { - IWL_ERR(priv, "Error sending TX power (%d)\n", ret); + IL_ERR(priv, "Error sending TX power (%d)\n", ret); return ret; } return 0; } -static int iwl4965_hw_channel_switch(struct iwl_priv *priv, +static int il4965_hw_channel_switch(struct il_priv *priv, struct ieee80211_channel_switch *ch_switch) { - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; int rc; u8 band = 0; bool is_ht40 = false; u8 ctrl_chan_high = 0; - struct iwl4965_channel_switch_cmd cmd; - const struct iwl_channel_info *ch_info; + struct il4965_channel_switch_cmd cmd; + const struct il_channel_info *ch_info; u32 switch_time_in_usec, ucode_switch_time; u16 ch; u32 tsf_low; @@ -1379,47 +1379,47 @@ static int iwl4965_hw_channel_switch(struct iwl_priv *priv, else { switch_time_in_usec = vif->bss_conf.beacon_int * switch_count * TIME_UNIT; - ucode_switch_time = iwl_legacy_usecs_to_beacons(priv, + ucode_switch_time = il_usecs_to_beacons(priv, switch_time_in_usec, beacon_interval); - cmd.switch_time = iwl_legacy_add_beacon_time(priv, + cmd.switch_time = il_add_beacon_time(priv, priv->ucode_beacon_time, ucode_switch_time, beacon_interval); } - IWL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n", + IL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n", cmd.switch_time); - ch_info = iwl_legacy_get_channel_info(priv, priv->band, ch); + ch_info = il_get_channel_info(priv, priv->band, ch); if (ch_info) - cmd.expect_beacon = iwl_legacy_is_channel_radar(ch_info); + cmd.expect_beacon = il_is_channel_radar(ch_info); else { - IWL_ERR(priv, "invalid channel switch from %u to %u\n", + IL_ERR(priv, "invalid channel switch from %u to %u\n", ctx->active.channel, ch); return -EFAULT; } - rc = iwl4965_fill_txpower_tbl(priv, band, ch, is_ht40, + rc = il4965_fill_txpower_tbl(priv, band, ch, is_ht40, ctrl_chan_high, &cmd.tx_power); if (rc) { - IWL_DEBUG_11H(priv, "error:%d fill txpower_tbl\n", rc); + IL_DEBUG_11H(priv, "error:%d fill txpower_tbl\n", rc); return rc; } - return iwl_legacy_send_cmd_pdu(priv, + return il_send_cmd_pdu(priv, REPLY_CHANNEL_SWITCH, sizeof(cmd), &cmd); } /** - * iwl4965_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array + * il4965_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array */ -static void iwl4965_txq_update_byte_cnt_tbl(struct iwl_priv *priv, - struct iwl_tx_queue *txq, +static void il4965_txq_update_byte_cnt_tbl(struct il_priv *priv, + struct il_tx_queue *txq, u16 byte_cnt) { - struct iwl4965_scd_bc_tbl *scd_bc_tbl = priv->scd_bc_tbls.addr; + struct il4965_scd_bc_tbl *scd_bc_tbl = priv->scd_bc_tbls.addr; int txq_id = txq->q.id; int write_ptr = txq->q.write_ptr; - int len = byte_cnt + IWL_TX_CRC_SIZE + IWL_TX_DELIMITER_SIZE; + int len = byte_cnt + IL_TX_CRC_SIZE + IL_TX_DELIMITER_SIZE; __le16 bc_ent; WARN_ON(len > 0xFFF || write_ptr >= TFD_QUEUE_SIZE_MAX); @@ -1435,12 +1435,12 @@ static void iwl4965_txq_update_byte_cnt_tbl(struct iwl_priv *priv, } /** - * iwl4965_hw_get_temperature - return the calibrated temperature (in Kelvin) + * il4965_hw_get_temperature - return the calibrated temperature (in Kelvin) * @statistics: Provides the temperature reading from the uCode * * A return of <0 indicates bogus data in the statistics */ -static int iwl4965_hw_get_temperature(struct iwl_priv *priv) +static int il4965_hw_get_temperature(struct il_priv *priv) { s32 temperature; s32 vt; @@ -1450,13 +1450,13 @@ static int iwl4965_hw_get_temperature(struct iwl_priv *priv) if (test_bit(STATUS_TEMPERATURE, &priv->status) && (priv->_4965.statistics.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK)) { - IWL_DEBUG_TEMP(priv, "Running HT40 temperature calibration\n"); + IL_DEBUG_TEMP(priv, "Running HT40 temperature calibration\n"); R1 = (s32)le32_to_cpu(priv->card_alive_init.therm_r1[1]); R2 = (s32)le32_to_cpu(priv->card_alive_init.therm_r2[1]); R3 = (s32)le32_to_cpu(priv->card_alive_init.therm_r3[1]); R4 = le32_to_cpu(priv->card_alive_init.therm_r4[1]); } else { - IWL_DEBUG_TEMP(priv, "Running temperature calibration\n"); + IL_DEBUG_TEMP(priv, "Running temperature calibration\n"); R1 = (s32)le32_to_cpu(priv->card_alive_init.therm_r1[0]); R2 = (s32)le32_to_cpu(priv->card_alive_init.therm_r2[0]); R3 = (s32)le32_to_cpu(priv->card_alive_init.therm_r3[0]); @@ -1476,10 +1476,10 @@ static int iwl4965_hw_get_temperature(struct iwl_priv *priv) vt = sign_extend32(le32_to_cpu(priv->_4965.statistics. general.common.temperature), 23); - IWL_DEBUG_TEMP(priv, "Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt); + IL_DEBUG_TEMP(priv, "Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt); if (R3 == R1) { - IWL_ERR(priv, "Calibration conflict R1 == R3\n"); + IL_ERR(priv, "Calibration conflict R1 == R3\n"); return -1; } @@ -1489,17 +1489,17 @@ static int iwl4965_hw_get_temperature(struct iwl_priv *priv) temperature /= (R3 - R1); temperature = (temperature * 97) / 100 + TEMPERATURE_CALIB_KELVIN_OFFSET; - IWL_DEBUG_TEMP(priv, "Calibrated temperature: %dK, %dC\n", + IL_DEBUG_TEMP(priv, "Calibrated temperature: %dK, %dC\n", temperature, KELVIN_TO_CELSIUS(temperature)); return temperature; } /* Adjust Txpower only if temperature variance is greater than threshold. */ -#define IWL_TEMPERATURE_THRESHOLD 3 +#define IL_TEMPERATURE_THRESHOLD 3 /** - * iwl4965_is_temp_calib_needed - determines if new calibration is needed + * il4965_is_temp_calib_needed - determines if new calibration is needed * * If the temperature changed has changed sufficiently, then a recalibration * is needed. @@ -1507,12 +1507,12 @@ static int iwl4965_hw_get_temperature(struct iwl_priv *priv) * Assumes caller will replace priv->last_temperature once calibration * executed. */ -static int iwl4965_is_temp_calib_needed(struct iwl_priv *priv) +static int il4965_is_temp_calib_needed(struct il_priv *priv) { int temp_diff; if (!test_bit(STATUS_STATISTICS, &priv->status)) { - IWL_DEBUG_TEMP(priv, "Temperature not updated -- no statistics.\n"); + IL_DEBUG_TEMP(priv, "Temperature not updated -- no statistics.\n"); return 0; } @@ -1520,39 +1520,39 @@ static int iwl4965_is_temp_calib_needed(struct iwl_priv *priv) /* get absolute value */ if (temp_diff < 0) { - IWL_DEBUG_POWER(priv, "Getting cooler, delta %d\n", temp_diff); + IL_DEBUG_POWER(priv, "Getting cooler, delta %d\n", temp_diff); temp_diff = -temp_diff; } else if (temp_diff == 0) - IWL_DEBUG_POWER(priv, "Temperature unchanged\n"); + IL_DEBUG_POWER(priv, "Temperature unchanged\n"); else - IWL_DEBUG_POWER(priv, "Getting warmer, delta %d\n", temp_diff); + IL_DEBUG_POWER(priv, "Getting warmer, delta %d\n", temp_diff); - if (temp_diff < IWL_TEMPERATURE_THRESHOLD) { - IWL_DEBUG_POWER(priv, " => thermal txpower calib not needed\n"); + if (temp_diff < IL_TEMPERATURE_THRESHOLD) { + IL_DEBUG_POWER(priv, " => thermal txpower calib not needed\n"); return 0; } - IWL_DEBUG_POWER(priv, " => thermal txpower calib needed\n"); + IL_DEBUG_POWER(priv, " => thermal txpower calib needed\n"); return 1; } -static void iwl4965_temperature_calib(struct iwl_priv *priv) +static void il4965_temperature_calib(struct il_priv *priv) { s32 temp; - temp = iwl4965_hw_get_temperature(priv); - if (IWL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(temp)) + temp = il4965_hw_get_temperature(priv); + if (IL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(temp)) return; if (priv->temperature != temp) { if (priv->temperature) - IWL_DEBUG_TEMP(priv, "Temperature changed " + IL_DEBUG_TEMP(priv, "Temperature changed " "from %dC to %dC\n", KELVIN_TO_CELSIUS(priv->temperature), KELVIN_TO_CELSIUS(temp)); else - IWL_DEBUG_TEMP(priv, "Temperature " + IL_DEBUG_TEMP(priv, "Temperature " "initialized to %dC\n", KELVIN_TO_CELSIUS(temp)); } @@ -1562,27 +1562,27 @@ static void iwl4965_temperature_calib(struct iwl_priv *priv) if (!priv->disable_tx_power_cal && unlikely(!test_bit(STATUS_SCANNING, &priv->status)) && - iwl4965_is_temp_calib_needed(priv)) + il4965_is_temp_calib_needed(priv)) queue_work(priv->workqueue, &priv->txpower_work); } -static u16 iwl4965_get_hcmd_size(u8 cmd_id, u16 len) +static u16 il4965_get_hcmd_size(u8 cmd_id, u16 len) { switch (cmd_id) { case REPLY_RXON: - return (u16) sizeof(struct iwl4965_rxon_cmd); + return (u16) sizeof(struct il4965_rxon_cmd); default: return len; } } -static u16 iwl4965_build_addsta_hcmd(const struct iwl_legacy_addsta_cmd *cmd, +static u16 il4965_build_addsta_hcmd(const struct il_addsta_cmd *cmd, u8 *data) { - struct iwl4965_addsta_cmd *addsta = (struct iwl4965_addsta_cmd *)data; + struct il4965_addsta_cmd *addsta = (struct il4965_addsta_cmd *)data; addsta->mode = cmd->mode; memcpy(&addsta->sta, &cmd->sta, sizeof(struct sta_id_modify)); - memcpy(&addsta->key, &cmd->key, sizeof(struct iwl4965_keyinfo)); + memcpy(&addsta->key, &cmd->key, sizeof(struct il4965_keyinfo)); addsta->station_flags = cmd->station_flags; addsta->station_flags_msk = cmd->station_flags_msk; addsta->tid_disable_tx = cmd->tid_disable_tx; @@ -1593,20 +1593,20 @@ static u16 iwl4965_build_addsta_hcmd(const struct iwl_legacy_addsta_cmd *cmd, addsta->reserved1 = cpu_to_le16(0); addsta->reserved2 = cpu_to_le16(0); - return (u16)sizeof(struct iwl4965_addsta_cmd); + return (u16)sizeof(struct il4965_addsta_cmd); } -static inline u32 iwl4965_get_scd_ssn(struct iwl4965_tx_resp *tx_resp) +static inline u32 il4965_get_scd_ssn(struct il4965_tx_resp *tx_resp) { return le32_to_cpup(&tx_resp->u.status + tx_resp->frame_count) & MAX_SN; } /** - * iwl4965_tx_status_reply_tx - Handle Tx response for frames in aggregation queue + * il4965_tx_status_reply_tx - Handle Tx response for frames in aggregation queue */ -static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, - struct iwl_ht_agg *agg, - struct iwl4965_tx_resp *tx_resp, +static int il4965_tx_status_reply_tx(struct il_priv *priv, + struct il_ht_agg *agg, + struct il4965_tx_resp *tx_resp, int txq_id, u16 start_idx) { u16 status; @@ -1617,7 +1617,7 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, int i, sh, idx; u16 seq; if (agg->wait_for_ba) - IWL_DEBUG_TX_REPLY(priv, "got tx response w/o block-ack\n"); + IL_DEBUG_TX_REPLY(priv, "got tx response w/o block-ack\n"); agg->frame_count = tx_resp->frame_count; agg->start_idx = start_idx; @@ -1630,18 +1630,18 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, status = le16_to_cpu(frame_status[0].status); idx = start_idx; - IWL_DEBUG_TX_REPLY(priv, "FrameCnt = %d, StartIdx=%d idx=%d\n", + IL_DEBUG_TX_REPLY(priv, "FrameCnt = %d, StartIdx=%d idx=%d\n", agg->frame_count, agg->start_idx, idx); info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb); info->status.rates[0].count = tx_resp->failure_frame + 1; info->flags &= ~IEEE80211_TX_CTL_AMPDU; - info->flags |= iwl4965_tx_status_to_mac80211(status); - iwl4965_hwrate_to_tx_control(priv, rate_n_flags, info); + info->flags |= il4965_tx_status_to_mac80211(status); + il4965_hwrate_to_tx_control(priv, rate_n_flags, info); - IWL_DEBUG_TX_REPLY(priv, "1 Frame 0x%x failure :%d\n", + IL_DEBUG_TX_REPLY(priv, "1 Frame 0x%x failure :%d\n", status & 0xff, tx_resp->failure_frame); - IWL_DEBUG_TX_REPLY(priv, "Rate Info rate_n_flags=%x\n", rate_n_flags); + IL_DEBUG_TX_REPLY(priv, "Rate Info rate_n_flags=%x\n", rate_n_flags); agg->wait_for_ba = 0; } else { @@ -1661,12 +1661,12 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, AGG_TX_STATE_ABORT_MSK)) continue; - IWL_DEBUG_TX_REPLY(priv, "FrameCnt = %d, txq_id=%d idx=%d\n", + IL_DEBUG_TX_REPLY(priv, "FrameCnt = %d, txq_id=%d idx=%d\n", agg->frame_count, txq_id, idx); - hdr = iwl_legacy_tx_queue_get_hdr(priv, txq_id, idx); + hdr = il_tx_queue_get_hdr(priv, txq_id, idx); if (!hdr) { - IWL_ERR(priv, + IL_ERR(priv, "BUG_ON idx doesn't point to valid skb" " idx=%d, txq_id=%d\n", idx, txq_id); return -1; @@ -1674,14 +1674,14 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, sc = le16_to_cpu(hdr->seq_ctrl); if (idx != (SEQ_TO_SN(sc) & 0xff)) { - IWL_ERR(priv, + IL_ERR(priv, "BUG_ON idx doesn't match seq control" " idx=%d, seq_idx=%d, seq=%d\n", idx, SEQ_TO_SN(sc), hdr->seq_ctrl); return -1; } - IWL_DEBUG_TX_REPLY(priv, "AGG Frame i=%d idx %d seq=%d\n", + IL_DEBUG_TX_REPLY(priv, "AGG Frame i=%d idx %d seq=%d\n", i, idx, SEQ_TO_SN(sc)); sh = idx - start; @@ -1699,13 +1699,13 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, sh = 0; } bitmap |= 1ULL << sh; - IWL_DEBUG_TX_REPLY(priv, "start=%d bitmap=0x%llx\n", + IL_DEBUG_TX_REPLY(priv, "start=%d bitmap=0x%llx\n", start, (unsigned long long)bitmap); } agg->bitmap = bitmap; agg->start_idx = start; - IWL_DEBUG_TX_REPLY(priv, "Frames %d start_idx=%d bitmap=0x%llx\n", + IL_DEBUG_TX_REPLY(priv, "Frames %d start_idx=%d bitmap=0x%llx\n", agg->frame_count, agg->start_idx, (unsigned long long)agg->bitmap); @@ -1715,18 +1715,18 @@ static int iwl4965_tx_status_reply_tx(struct iwl_priv *priv, return 0; } -static u8 iwl4965_find_station(struct iwl_priv *priv, const u8 *addr) +static u8 il4965_find_station(struct il_priv *priv, const u8 *addr) { int i; int start = 0; - int ret = IWL_INVALID_STATION; + int ret = IL_INVALID_STATION; unsigned long flags; if ((priv->iw_mode == NL80211_IFTYPE_ADHOC)) - start = IWL_STA_ID; + start = IL_STA_ID; if (is_broadcast_ether_addr(addr)) - return priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id; + return priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id; spin_lock_irqsave(&priv->sta_lock, flags); for (i = start; i < priv->hw_params.max_stations; i++) @@ -1737,7 +1737,7 @@ static u8 iwl4965_find_station(struct iwl_priv *priv, const u8 *addr) goto out; } - IWL_DEBUG_ASSOC_LIMIT(priv, "can not find STA %pM total %d\n", + IL_DEBUG_ASSOC_LIMIT(priv, "can not find STA %pM total %d\n", addr, priv->num_stations); out: @@ -1746,42 +1746,42 @@ static u8 iwl4965_find_station(struct iwl_priv *priv, const u8 *addr) * arrive before we completed processing the adding of * station */ - if (ret != IWL_INVALID_STATION && - (!(priv->stations[ret].used & IWL_STA_UCODE_ACTIVE) || - ((priv->stations[ret].used & IWL_STA_UCODE_ACTIVE) && - (priv->stations[ret].used & IWL_STA_UCODE_INPROGRESS)))) { - IWL_ERR(priv, "Requested station info for sta %d before ready.\n", + if (ret != IL_INVALID_STATION && + (!(priv->stations[ret].used & IL_STA_UCODE_ACTIVE) || + ((priv->stations[ret].used & IL_STA_UCODE_ACTIVE) && + (priv->stations[ret].used & IL_STA_UCODE_INPROGRESS)))) { + IL_ERR(priv, "Requested station info for sta %d before ready.\n", ret); - ret = IWL_INVALID_STATION; + ret = IL_INVALID_STATION; } spin_unlock_irqrestore(&priv->sta_lock, flags); return ret; } -static int iwl4965_get_ra_sta_id(struct iwl_priv *priv, struct ieee80211_hdr *hdr) +static int il4965_get_ra_sta_id(struct il_priv *priv, struct ieee80211_hdr *hdr) { if (priv->iw_mode == NL80211_IFTYPE_STATION) { - return IWL_AP_ID; + return IL_AP_ID; } else { u8 *da = ieee80211_get_DA(hdr); - return iwl4965_find_station(priv, da); + return il4965_find_station(priv, da); } } /** - * iwl4965_rx_reply_tx - Handle standard (non-aggregation) Tx response + * il4965_rx_reply_tx - Handle standard (non-aggregation) Tx response */ -static void iwl4965_rx_reply_tx(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il4965_rx_reply_tx(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); int index = SEQ_TO_INDEX(sequence); - struct iwl_tx_queue *txq = &priv->txq[txq_id]; + struct il_tx_queue *txq = &priv->txq[txq_id]; struct ieee80211_hdr *hdr; struct ieee80211_tx_info *info; - struct iwl4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; + struct il4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; u32 status = le32_to_cpu(tx_resp->u.status); int uninitialized_var(tid); int sta_id; @@ -1789,8 +1789,8 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv, u8 *qc = NULL; unsigned long flags; - if ((index >= txq->q.n_bd) || (iwl_legacy_queue_used(&txq->q, index) == 0)) { - IWL_ERR(priv, "Read index for DMA queue txq_id (%d) index %d " + if ((index >= txq->q.n_bd) || (il_queue_used(&txq->q, index) == 0)) { + IL_ERR(priv, "Read index for DMA queue txq_id (%d) index %d " "is out of range [0-%d] %d %d\n", txq_id, index, txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr); @@ -1801,88 +1801,88 @@ static void iwl4965_rx_reply_tx(struct iwl_priv *priv, info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb); memset(&info->status, 0, sizeof(info->status)); - hdr = iwl_legacy_tx_queue_get_hdr(priv, txq_id, index); + hdr = il_tx_queue_get_hdr(priv, txq_id, index); if (ieee80211_is_data_qos(hdr->frame_control)) { qc = ieee80211_get_qos_ctl(hdr); tid = qc[0] & 0xf; } - sta_id = iwl4965_get_ra_sta_id(priv, hdr); - if (txq->sched_retry && unlikely(sta_id == IWL_INVALID_STATION)) { - IWL_ERR(priv, "Station not known\n"); + sta_id = il4965_get_ra_sta_id(priv, hdr); + if (txq->sched_retry && unlikely(sta_id == IL_INVALID_STATION)) { + IL_ERR(priv, "Station not known\n"); return; } spin_lock_irqsave(&priv->sta_lock, flags); if (txq->sched_retry) { - const u32 scd_ssn = iwl4965_get_scd_ssn(tx_resp); - struct iwl_ht_agg *agg = NULL; + const u32 scd_ssn = il4965_get_scd_ssn(tx_resp); + struct il_ht_agg *agg = NULL; WARN_ON(!qc); agg = &priv->stations[sta_id].tid[tid].agg; - iwl4965_tx_status_reply_tx(priv, agg, tx_resp, txq_id, index); + il4965_tx_status_reply_tx(priv, agg, tx_resp, txq_id, index); /* check if BAR is needed */ - if ((tx_resp->frame_count == 1) && !iwl4965_is_tx_success(status)) + if ((tx_resp->frame_count == 1) && !il4965_is_tx_success(status)) info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK; if (txq->q.read_ptr != (scd_ssn & 0xff)) { - index = iwl_legacy_queue_dec_wrap(scd_ssn & 0xff, + index = il_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); - IWL_DEBUG_TX_REPLY(priv, "Retry scheduler reclaim scd_ssn " + IL_DEBUG_TX_REPLY(priv, "Retry scheduler reclaim scd_ssn " "%d index %d\n", scd_ssn , index); - freed = iwl4965_tx_queue_reclaim(priv, txq_id, index); + freed = il4965_tx_queue_reclaim(priv, txq_id, index); if (qc) - iwl4965_free_tfds_in_queue(priv, sta_id, + il4965_free_tfds_in_queue(priv, sta_id, tid, freed); if (priv->mac80211_registered && - (iwl_legacy_queue_space(&txq->q) > txq->q.low_mark) - && (agg->state != IWL_EMPTYING_HW_QUEUE_DELBA)) - iwl_legacy_wake_queue(priv, txq); + (il_queue_space(&txq->q) > txq->q.low_mark) + && (agg->state != IL_EMPTYING_HW_QUEUE_DELBA)) + il_wake_queue(priv, txq); } } else { info->status.rates[0].count = tx_resp->failure_frame + 1; - info->flags |= iwl4965_tx_status_to_mac80211(status); - iwl4965_hwrate_to_tx_control(priv, + info->flags |= il4965_tx_status_to_mac80211(status); + il4965_hwrate_to_tx_control(priv, le32_to_cpu(tx_resp->rate_n_flags), info); - IWL_DEBUG_TX_REPLY(priv, "TXQ %d status %s (0x%08x) " + IL_DEBUG_TX_REPLY(priv, "TXQ %d status %s (0x%08x) " "rate_n_flags 0x%x retries %d\n", txq_id, - iwl4965_get_tx_fail_reason(status), status, + il4965_get_tx_fail_reason(status), status, le32_to_cpu(tx_resp->rate_n_flags), tx_resp->failure_frame); - freed = iwl4965_tx_queue_reclaim(priv, txq_id, index); - if (qc && likely(sta_id != IWL_INVALID_STATION)) - iwl4965_free_tfds_in_queue(priv, sta_id, tid, freed); - else if (sta_id == IWL_INVALID_STATION) - IWL_DEBUG_TX_REPLY(priv, "Station not known\n"); + freed = il4965_tx_queue_reclaim(priv, txq_id, index); + if (qc && likely(sta_id != IL_INVALID_STATION)) + il4965_free_tfds_in_queue(priv, sta_id, tid, freed); + else if (sta_id == IL_INVALID_STATION) + IL_DEBUG_TX_REPLY(priv, "Station not known\n"); if (priv->mac80211_registered && - (iwl_legacy_queue_space(&txq->q) > txq->q.low_mark)) - iwl_legacy_wake_queue(priv, txq); + (il_queue_space(&txq->q) > txq->q.low_mark)) + il_wake_queue(priv, txq); } - if (qc && likely(sta_id != IWL_INVALID_STATION)) - iwl4965_txq_check_empty(priv, sta_id, tid, txq_id); + if (qc && likely(sta_id != IL_INVALID_STATION)) + il4965_txq_check_empty(priv, sta_id, tid, txq_id); - iwl4965_check_abort_status(priv, tx_resp->frame_count, status); + il4965_check_abort_status(priv, tx_resp->frame_count, status); spin_unlock_irqrestore(&priv->sta_lock, flags); } -static void iwl4965_rx_beacon_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il4965_rx_beacon_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl4965_beacon_notif *beacon = (void *)pkt->u.raw; + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il4965_beacon_notif *beacon = (void *)pkt->u.raw; u8 rate __maybe_unused = - iwl4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); + il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); - IWL_DEBUG_RX(priv, "beacon status %#x, retries:%d ibssmgr:%d " + IL_DEBUG_RX(priv, "beacon status %#x, retries:%d ibssmgr:%d " "tsf:0x%.8x%.8x rate:%d\n", le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, beacon->beacon_notify_hdr.failure_frame, @@ -1894,36 +1894,36 @@ static void iwl4965_rx_beacon_notif(struct iwl_priv *priv, } /* Set up 4965-specific Rx frame reply handlers */ -static void iwl4965_rx_handler_setup(struct iwl_priv *priv) +static void il4965_rx_handler_setup(struct il_priv *priv) { /* Legacy Rx frames */ - priv->rx_handlers[REPLY_RX] = iwl4965_rx_reply_rx; + priv->rx_handlers[REPLY_RX] = il4965_rx_reply_rx; /* Tx response */ - priv->rx_handlers[REPLY_TX] = iwl4965_rx_reply_tx; - priv->rx_handlers[BEACON_NOTIFICATION] = iwl4965_rx_beacon_notif; + priv->rx_handlers[REPLY_TX] = il4965_rx_reply_tx; + priv->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; } -static struct iwl_hcmd_ops iwl4965_hcmd = { - .rxon_assoc = iwl4965_send_rxon_assoc, - .commit_rxon = iwl4965_commit_rxon, - .set_rxon_chain = iwl4965_set_rxon_chain, +static struct il_hcmd_ops il4965_hcmd = { + .rxon_assoc = il4965_send_rxon_assoc, + .commit_rxon = il4965_commit_rxon, + .set_rxon_chain = il4965_set_rxon_chain, }; -static void iwl4965_post_scan(struct iwl_priv *priv) +static void il4965_post_scan(struct il_priv *priv) { - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; /* * Since setting the RXON may have been deferred while * performing the scan, fire one off if needed */ if (memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) - iwl_legacy_commit_rxon(priv, ctx); + il_commit_rxon(priv, ctx); } -static void iwl4965_post_associate(struct iwl_priv *priv) +static void il4965_post_associate(struct il_priv *priv) { - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; struct ieee80211_vif *vif = ctx->vif; struct ieee80211_conf *conf = NULL; int ret = 0; @@ -1934,28 +1934,28 @@ static void iwl4965_post_associate(struct iwl_priv *priv) if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; - iwl_legacy_scan_cancel_timeout(priv, 200); + il_scan_cancel_timeout(priv, 200); - conf = iwl_legacy_ieee80211_get_hw_conf(priv->hw); + conf = il_ieee80211_get_hw_conf(priv->hw); ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - iwl_legacy_commit_rxon(priv, ctx); + il_commit_rxon(priv, ctx); - ret = iwl_legacy_send_rxon_timing(priv, ctx); + ret = il_send_rxon_timing(priv, ctx); if (ret) - IWL_WARN(priv, "RXON timing - " + IL_WARN(priv, "RXON timing - " "Attempting to continue.\n"); ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - iwl_legacy_set_rxon_ht(priv, &priv->current_ht_config); + il_set_rxon_ht(priv, &priv->current_ht_config); if (priv->cfg->ops->hcmd->set_rxon_chain) priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); ctx->staging.assoc_id = cpu_to_le16(vif->bss_conf.aid); - IWL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n", + IL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n", vif->bss_conf.aid, vif->bss_conf.beacon_int); if (vif->bss_conf.use_short_preamble) @@ -1970,19 +1970,19 @@ static void iwl4965_post_associate(struct iwl_priv *priv) ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; } - iwl_legacy_commit_rxon(priv, ctx); + il_commit_rxon(priv, ctx); - IWL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n", + IL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n", vif->bss_conf.aid, ctx->active.bssid_addr); switch (vif->type) { case NL80211_IFTYPE_STATION: break; case NL80211_IFTYPE_ADHOC: - iwl4965_send_beacon_cmd(priv); + il4965_send_beacon_cmd(priv); break; default: - IWL_ERR(priv, "%s Should not be called in %d mode\n", + IL_ERR(priv, "%s Should not be called in %d mode\n", __func__, vif->type); break; } @@ -1990,17 +1990,17 @@ static void iwl4965_post_associate(struct iwl_priv *priv) /* the chain noise calibration will enabled PM upon completion * If chain noise has already been run, then we need to enable * power management here */ - if (priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE) - iwl_legacy_power_update_mode(priv, false); + if (priv->chain_noise_data.state == IL_CHAIN_NOISE_DONE) + il_power_update_mode(priv, false); /* Enable Rx differential gain and sensitivity calibrations */ - iwl4965_chain_noise_reset(priv); + il4965_chain_noise_reset(priv); priv->start_calib = 1; } -static void iwl4965_config_ap(struct iwl_priv *priv) +static void il4965_config_ap(struct il_priv *priv) { - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; struct ieee80211_vif *vif = ctx->vif; int ret = 0; @@ -2010,22 +2010,22 @@ static void iwl4965_config_ap(struct iwl_priv *priv) return; /* The following should be done only at AP bring up */ - if (!iwl_legacy_is_associated_ctx(ctx)) { + if (!il_is_associated_ctx(ctx)) { /* RXON - unassoc (to set timing command) */ ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - iwl_legacy_commit_rxon(priv, ctx); + il_commit_rxon(priv, ctx); /* RXON Timing */ - ret = iwl_legacy_send_rxon_timing(priv, ctx); + ret = il_send_rxon_timing(priv, ctx); if (ret) - IWL_WARN(priv, "RXON timing failed - " + IL_WARN(priv, "RXON timing failed - " "Attempting to continue.\n"); /* AP has all antennas */ priv->chain_noise_data.active_chains = priv->hw_params.valid_rx_ant; - iwl_legacy_set_rxon_ht(priv, &priv->current_ht_config); + il_set_rxon_ht(priv, &priv->current_ht_config); if (priv->cfg->ops->hcmd->set_rxon_chain) priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); @@ -2047,37 +2047,37 @@ static void iwl4965_config_ap(struct iwl_priv *priv) ~RXON_FLG_SHORT_SLOT_MSK; } /* need to send beacon cmd before committing assoc RXON! */ - iwl4965_send_beacon_cmd(priv); + il4965_send_beacon_cmd(priv); /* restore RXON assoc */ ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - iwl_legacy_commit_rxon(priv, ctx); + il_commit_rxon(priv, ctx); } - iwl4965_send_beacon_cmd(priv); + il4965_send_beacon_cmd(priv); } -static struct iwl_hcmd_utils_ops iwl4965_hcmd_utils = { - .get_hcmd_size = iwl4965_get_hcmd_size, - .build_addsta_hcmd = iwl4965_build_addsta_hcmd, - .request_scan = iwl4965_request_scan, - .post_scan = iwl4965_post_scan, +static struct il_hcmd_utils_ops il4965_hcmd_utils = { + .get_hcmd_size = il4965_get_hcmd_size, + .build_addsta_hcmd = il4965_build_addsta_hcmd, + .request_scan = il4965_request_scan, + .post_scan = il4965_post_scan, }; -static struct iwl_lib_ops iwl4965_lib = { - .set_hw_params = iwl4965_hw_set_hw_params, - .txq_update_byte_cnt_tbl = iwl4965_txq_update_byte_cnt_tbl, - .txq_attach_buf_to_tfd = iwl4965_hw_txq_attach_buf_to_tfd, - .txq_free_tfd = iwl4965_hw_txq_free_tfd, - .txq_init = iwl4965_hw_tx_queue_init, - .rx_handler_setup = iwl4965_rx_handler_setup, - .is_valid_rtc_data_addr = iwl4965_hw_valid_rtc_data_addr, - .init_alive_start = iwl4965_init_alive_start, - .load_ucode = iwl4965_load_bsm, - .dump_nic_error_log = iwl4965_dump_nic_error_log, - .dump_fh = iwl4965_dump_fh, - .set_channel_switch = iwl4965_hw_channel_switch, +static struct il_lib_ops il4965_lib = { + .set_hw_params = il4965_hw_set_hw_params, + .txq_update_byte_cnt_tbl = il4965_txq_update_byte_cnt_tbl, + .txq_attach_buf_to_tfd = il4965_hw_txq_attach_buf_to_tfd, + .txq_free_tfd = il4965_hw_txq_free_tfd, + .txq_init = il4965_hw_tx_queue_init, + .rx_handler_setup = il4965_rx_handler_setup, + .is_valid_rtc_data_addr = il4965_hw_valid_rtc_data_addr, + .init_alive_start = il4965_init_alive_start, + .load_ucode = il4965_load_bsm, + .dump_nic_error_log = il4965_dump_nic_error_log, + .dump_fh = il4965_dump_fh, + .set_channel_switch = il4965_hw_channel_switch, .apm_ops = { - .init = iwl_legacy_apm_init, - .config = iwl4965_nic_config, + .init = il_apm_init, + .config = il4965_nic_config, }, .eeprom_ops = { .regulatory_bands = { @@ -2089,60 +2089,60 @@ static struct iwl_lib_ops iwl4965_lib = { EEPROM_4965_REGULATORY_BAND_24_HT40_CHANNELS, EEPROM_4965_REGULATORY_BAND_52_HT40_CHANNELS }, - .acquire_semaphore = iwl4965_eeprom_acquire_semaphore, - .release_semaphore = iwl4965_eeprom_release_semaphore, + .acquire_semaphore = il4965_eeprom_acquire_semaphore, + .release_semaphore = il4965_eeprom_release_semaphore, }, - .send_tx_power = iwl4965_send_tx_power, - .update_chain_flags = iwl4965_update_chain_flags, + .send_tx_power = il4965_send_tx_power, + .update_chain_flags = il4965_update_chain_flags, .temp_ops = { - .temperature = iwl4965_temperature_calib, + .temperature = il4965_temperature_calib, }, .debugfs_ops = { - .rx_stats_read = iwl4965_ucode_rx_stats_read, - .tx_stats_read = iwl4965_ucode_tx_stats_read, - .general_stats_read = iwl4965_ucode_general_stats_read, + .rx_stats_read = il4965_ucode_rx_stats_read, + .tx_stats_read = il4965_ucode_tx_stats_read, + .general_stats_read = il4965_ucode_general_stats_read, }, }; -static const struct iwl_legacy_ops iwl4965_legacy_ops = { - .post_associate = iwl4965_post_associate, - .config_ap = iwl4965_config_ap, - .manage_ibss_station = iwl4965_manage_ibss_station, - .update_bcast_stations = iwl4965_update_bcast_stations, +static const struct il_legacy_ops il4965_legacy_ops = { + .post_associate = il4965_post_associate, + .config_ap = il4965_config_ap, + .manage_ibss_station = il4965_manage_ibss_station, + .update_bcast_stations = il4965_update_bcast_stations, }; -struct ieee80211_ops iwl4965_hw_ops = { - .tx = iwl4965_mac_tx, - .start = iwl4965_mac_start, - .stop = iwl4965_mac_stop, - .add_interface = iwl_legacy_mac_add_interface, - .remove_interface = iwl_legacy_mac_remove_interface, - .change_interface = iwl_legacy_mac_change_interface, - .config = iwl_legacy_mac_config, - .configure_filter = iwl4965_configure_filter, - .set_key = iwl4965_mac_set_key, - .update_tkip_key = iwl4965_mac_update_tkip_key, - .conf_tx = iwl_legacy_mac_conf_tx, - .reset_tsf = iwl_legacy_mac_reset_tsf, - .bss_info_changed = iwl_legacy_mac_bss_info_changed, - .ampdu_action = iwl4965_mac_ampdu_action, - .hw_scan = iwl_legacy_mac_hw_scan, - .sta_add = iwl4965_mac_sta_add, - .sta_remove = iwl_legacy_mac_sta_remove, - .channel_switch = iwl4965_mac_channel_switch, - .tx_last_beacon = iwl_legacy_mac_tx_last_beacon, +struct ieee80211_ops il4965_hw_ops = { + .tx = il4965_mac_tx, + .start = il4965_mac_start, + .stop = il4965_mac_stop, + .add_interface = il_mac_add_interface, + .remove_interface = il_mac_remove_interface, + .change_interface = il_mac_change_interface, + .config = il_mac_config, + .configure_filter = il4965_configure_filter, + .set_key = il4965_mac_set_key, + .update_tkip_key = il4965_mac_update_tkip_key, + .conf_tx = il_mac_conf_tx, + .reset_tsf = il_mac_reset_tsf, + .bss_info_changed = il_mac_bss_info_changed, + .ampdu_action = il4965_mac_ampdu_action, + .hw_scan = il_mac_hw_scan, + .sta_add = il4965_mac_sta_add, + .sta_remove = il_mac_sta_remove, + .channel_switch = il4965_mac_channel_switch, + .tx_last_beacon = il_mac_tx_last_beacon, }; -static const struct iwl_ops iwl4965_ops = { - .lib = &iwl4965_lib, - .hcmd = &iwl4965_hcmd, - .utils = &iwl4965_hcmd_utils, - .led = &iwl4965_led_ops, - .legacy = &iwl4965_legacy_ops, - .ieee80211_ops = &iwl4965_hw_ops, +static const struct il_ops il4965_ops = { + .lib = &il4965_lib, + .hcmd = &il4965_hcmd, + .utils = &il4965_hcmd_utils, + .led = &il4965_led_ops, + .legacy = &il4965_legacy_ops, + .ieee80211_ops = &il4965_hw_ops, }; -static struct iwl_base_params iwl4965_base_params = { +static struct il_base_params il4965_base_params = { .eeprom_size = IWL4965_EEPROM_IMG_SIZE, .num_of_queues = IWL49_NUM_QUEUES, .num_of_ampdu_queues = IWL49_NUM_AMPDU_QUEUES, @@ -2151,27 +2151,27 @@ static struct iwl_base_params iwl4965_base_params = { .use_bsm = true, .led_compensation = 61, .chain_noise_num_beacons = IWL4965_CAL_NUM_BEACONS, - .wd_timeout = IWL_DEF_WD_TIMEOUT, + .wd_timeout = IL_DEF_WD_TIMEOUT, .temperature_kelvin = true, .ucode_tracing = true, .sensitivity_calib_by_driver = true, .chain_noise_calib_by_driver = true, }; -struct iwl_cfg iwl4965_cfg = { +struct il_cfg il4965_cfg = { .name = "Intel(R) Wireless WiFi Link 4965AGN", .fw_name_pre = IWL4965_FW_PRE, .ucode_api_max = IWL4965_UCODE_API_MAX, .ucode_api_min = IWL4965_UCODE_API_MIN, - .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N, + .sku = IL_SKU_A|IL_SKU_G|IL_SKU_N, .valid_tx_ant = ANT_AB, .valid_rx_ant = ANT_ABC, .eeprom_ver = EEPROM_4965_EEPROM_VERSION, .eeprom_calib_ver = EEPROM_4965_TX_POWER_VERSION, - .ops = &iwl4965_ops, - .mod_params = &iwl4965_mod_params, - .base_params = &iwl4965_base_params, - .led_mode = IWL_LED_BLINK, + .ops = &il4965_ops, + .mod_params = &il4965_mod_params, + .base_params = &il4965_base_params, + .led_mode = IL_LED_BLINK, /* * Force use of chains B and C for scan RX on 5 GHz band * because the device has off-channel reception on chain A. diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.h b/drivers/net/wireless/iwlegacy/iwl-4965.h index 01f8163daf16..7b322168bfc5 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965.h @@ -60,92 +60,92 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef __iwl_4965_h__ -#define __iwl_4965_h__ +#ifndef __il_4965_h__ +#define __il_4965_h__ #include "iwl-dev.h" /* configuration for the _4965 devices */ -extern struct iwl_cfg iwl4965_cfg; +extern struct il_cfg il4965_cfg; -extern struct iwl_mod_params iwl4965_mod_params; +extern struct il_mod_params il4965_mod_params; -extern struct ieee80211_ops iwl4965_hw_ops; +extern struct ieee80211_ops il4965_hw_ops; /* tx queue */ -void iwl4965_free_tfds_in_queue(struct iwl_priv *priv, +void il4965_free_tfds_in_queue(struct il_priv *priv, int sta_id, int tid, int freed); /* RXON */ -void iwl4965_set_rxon_chain(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); +void il4965_set_rxon_chain(struct il_priv *priv, + struct il_rxon_context *ctx); /* uCode */ -int iwl4965_verify_ucode(struct iwl_priv *priv); +int il4965_verify_ucode(struct il_priv *priv); /* lib */ -void iwl4965_check_abort_status(struct iwl_priv *priv, +void il4965_check_abort_status(struct il_priv *priv, u8 frame_count, u32 status); -void iwl4965_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq); -int iwl4965_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq); -int iwl4965_hw_nic_init(struct iwl_priv *priv); -int iwl4965_dump_fh(struct iwl_priv *priv, char **buf, bool display); +void il4965_rx_queue_reset(struct il_priv *priv, struct il_rx_queue *rxq); +int il4965_rx_init(struct il_priv *priv, struct il_rx_queue *rxq); +int il4965_hw_nic_init(struct il_priv *priv); +int il4965_dump_fh(struct il_priv *priv, char **buf, bool display); /* rx */ -void iwl4965_rx_queue_restock(struct iwl_priv *priv); -void iwl4965_rx_replenish(struct iwl_priv *priv); -void iwl4965_rx_replenish_now(struct iwl_priv *priv); -void iwl4965_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rxq); -int iwl4965_rxq_stop(struct iwl_priv *priv); -int iwl4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); -void iwl4965_rx_reply_rx(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); -void iwl4965_rx_reply_rx_phy(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); -void iwl4965_rx_handle(struct iwl_priv *priv); +void il4965_rx_queue_restock(struct il_priv *priv); +void il4965_rx_replenish(struct il_priv *priv); +void il4965_rx_replenish_now(struct il_priv *priv); +void il4965_rx_queue_free(struct il_priv *priv, struct il_rx_queue *rxq); +int il4965_rxq_stop(struct il_priv *priv); +int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); +void il4965_rx_reply_rx(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); +void il4965_rx_reply_rx_phy(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); +void il4965_rx_handle(struct il_priv *priv); /* tx */ -void iwl4965_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq); -int iwl4965_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, - struct iwl_tx_queue *txq, +void il4965_hw_txq_free_tfd(struct il_priv *priv, struct il_tx_queue *txq); +int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *priv, + struct il_tx_queue *txq, dma_addr_t addr, u16 len, u8 reset, u8 pad); -int iwl4965_hw_tx_queue_init(struct iwl_priv *priv, - struct iwl_tx_queue *txq); -void iwl4965_hwrate_to_tx_control(struct iwl_priv *priv, u32 rate_n_flags, +int il4965_hw_tx_queue_init(struct il_priv *priv, + struct il_tx_queue *txq); +void il4965_hwrate_to_tx_control(struct il_priv *priv, u32 rate_n_flags, struct ieee80211_tx_info *info); -int iwl4965_tx_skb(struct iwl_priv *priv, struct sk_buff *skb); -int iwl4965_tx_agg_start(struct iwl_priv *priv, struct ieee80211_vif *vif, +int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb); +int il4965_tx_agg_start(struct il_priv *priv, struct ieee80211_vif *vif, struct ieee80211_sta *sta, u16 tid, u16 *ssn); -int iwl4965_tx_agg_stop(struct iwl_priv *priv, struct ieee80211_vif *vif, +int il4965_tx_agg_stop(struct il_priv *priv, struct ieee80211_vif *vif, struct ieee80211_sta *sta, u16 tid); -int iwl4965_txq_check_empty(struct iwl_priv *priv, +int il4965_txq_check_empty(struct il_priv *priv, int sta_id, u8 tid, int txq_id); -void iwl4965_rx_reply_compressed_ba(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); -int iwl4965_tx_queue_reclaim(struct iwl_priv *priv, int txq_id, int index); -void iwl4965_hw_txq_ctx_free(struct iwl_priv *priv); -int iwl4965_txq_ctx_alloc(struct iwl_priv *priv); -void iwl4965_txq_ctx_reset(struct iwl_priv *priv); -void iwl4965_txq_ctx_stop(struct iwl_priv *priv); -void iwl4965_txq_set_sched(struct iwl_priv *priv, u32 mask); +void il4965_rx_reply_compressed_ba(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); +int il4965_tx_queue_reclaim(struct il_priv *priv, int txq_id, int index); +void il4965_hw_txq_ctx_free(struct il_priv *priv); +int il4965_txq_ctx_alloc(struct il_priv *priv); +void il4965_txq_ctx_reset(struct il_priv *priv); +void il4965_txq_ctx_stop(struct il_priv *priv); +void il4965_txq_set_sched(struct il_priv *priv, u32 mask); /* * Acquire priv->lock before calling this function ! */ -void iwl4965_set_wr_ptrs(struct iwl_priv *priv, int txq_id, u32 index); +void il4965_set_wr_ptrs(struct il_priv *priv, int txq_id, u32 index); /** - * iwl4965_tx_queue_set_status - (optionally) start Tx/Cmd queue + * il4965_tx_queue_set_status - (optionally) start Tx/Cmd queue * @tx_fifo_id: Tx DMA/FIFO channel (range 0-7) that the queue will feed * @scd_retry: (1) Indicates queue will be used in aggregation mode * * NOTE: Acquire priv->lock before calling this function ! */ -void iwl4965_tx_queue_set_status(struct iwl_priv *priv, - struct iwl_tx_queue *txq, +void il4965_tx_queue_set_status(struct il_priv *priv, + struct il_tx_queue *txq, int tx_fifo_id, int scd_retry); -static inline u32 iwl4965_tx_status_to_mac80211(u32 status) +static inline u32 il4965_tx_status_to_mac80211(u32 status) { status &= TX_STATUS_MSK; @@ -160,123 +160,123 @@ static inline u32 iwl4965_tx_status_to_mac80211(u32 status) } } -static inline bool iwl4965_is_tx_success(u32 status) +static inline bool il4965_is_tx_success(u32 status) { status &= TX_STATUS_MSK; return (status == TX_STATUS_SUCCESS) || (status == TX_STATUS_DIRECT_DONE); } -u8 iwl4965_toggle_tx_ant(struct iwl_priv *priv, u8 ant_idx, u8 valid); +u8 il4965_toggle_tx_ant(struct il_priv *priv, u8 ant_idx, u8 valid); /* rx */ -void iwl4965_rx_missed_beacon_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); -bool iwl4965_good_plcp_health(struct iwl_priv *priv, - struct iwl_rx_packet *pkt); -void iwl4965_rx_statistics(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); -void iwl4965_reply_statistics(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); +void il4965_rx_missed_beacon_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); +bool il4965_good_plcp_health(struct il_priv *priv, + struct il_rx_packet *pkt); +void il4965_rx_statistics(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); +void il4965_reply_statistics(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); /* scan */ -int iwl4965_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif); +int il4965_request_scan(struct il_priv *priv, struct ieee80211_vif *vif); /* station mgmt */ -int iwl4965_manage_ibss_station(struct iwl_priv *priv, +int il4965_manage_ibss_station(struct il_priv *priv, struct ieee80211_vif *vif, bool add); /* hcmd */ -int iwl4965_send_beacon_cmd(struct iwl_priv *priv); +int il4965_send_beacon_cmd(struct il_priv *priv); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -const char *iwl4965_get_tx_fail_reason(u32 status); +const char *il4965_get_tx_fail_reason(u32 status); #else static inline const char * -iwl4965_get_tx_fail_reason(u32 status) { return ""; } +il4965_get_tx_fail_reason(u32 status) { return ""; } #endif /* station management */ -int iwl4965_alloc_bcast_station(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); -int iwl4965_add_bssid_station(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +int il4965_alloc_bcast_station(struct il_priv *priv, + struct il_rxon_context *ctx); +int il4965_add_bssid_station(struct il_priv *priv, + struct il_rxon_context *ctx, const u8 *addr, u8 *sta_id_r); -int iwl4965_remove_default_wep_key(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +int il4965_remove_default_wep_key(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_key_conf *key); -int iwl4965_set_default_wep_key(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +int il4965_set_default_wep_key(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_key_conf *key); -int iwl4965_restore_default_wep_keys(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); -int iwl4965_set_dynamic_key(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +int il4965_restore_default_wep_keys(struct il_priv *priv, + struct il_rxon_context *ctx); +int il4965_set_dynamic_key(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_key_conf *key, u8 sta_id); -int iwl4965_remove_dynamic_key(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +int il4965_remove_dynamic_key(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_key_conf *key, u8 sta_id); -void iwl4965_update_tkip_key(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +void il4965_update_tkip_key(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, struct ieee80211_sta *sta, u32 iv32, u16 *phase1key); -int iwl4965_sta_tx_modify_enable_tid(struct iwl_priv *priv, +int il4965_sta_tx_modify_enable_tid(struct il_priv *priv, int sta_id, int tid); -int iwl4965_sta_rx_agg_start(struct iwl_priv *priv, struct ieee80211_sta *sta, +int il4965_sta_rx_agg_start(struct il_priv *priv, struct ieee80211_sta *sta, int tid, u16 ssn); -int iwl4965_sta_rx_agg_stop(struct iwl_priv *priv, struct ieee80211_sta *sta, +int il4965_sta_rx_agg_stop(struct il_priv *priv, struct ieee80211_sta *sta, int tid); -void iwl4965_sta_modify_sleep_tx_count(struct iwl_priv *priv, +void il4965_sta_modify_sleep_tx_count(struct il_priv *priv, int sta_id, int cnt); -int iwl4965_update_bcast_stations(struct iwl_priv *priv); +int il4965_update_bcast_stations(struct il_priv *priv); /* rate */ -static inline u32 iwl4965_ant_idx_to_flags(u8 ant_idx) +static inline u32 il4965_ant_idx_to_flags(u8 ant_idx) { return BIT(ant_idx) << RATE_MCS_ANT_POS; } -static inline u8 iwl4965_hw_get_rate(__le32 rate_n_flags) +static inline u8 il4965_hw_get_rate(__le32 rate_n_flags) { return le32_to_cpu(rate_n_flags) & 0xFF; } -static inline __le32 iwl4965_hw_set_rate_n_flags(u8 rate, u32 flags) +static inline __le32 il4965_hw_set_rate_n_flags(u8 rate, u32 flags) { return cpu_to_le32(flags|(u32)rate); } /* eeprom */ -void iwl4965_eeprom_get_mac(const struct iwl_priv *priv, u8 *mac); -int iwl4965_eeprom_acquire_semaphore(struct iwl_priv *priv); -void iwl4965_eeprom_release_semaphore(struct iwl_priv *priv); -int iwl4965_eeprom_check_version(struct iwl_priv *priv); +void il4965_eeprom_get_mac(const struct il_priv *priv, u8 *mac); +int il4965_eeprom_acquire_semaphore(struct il_priv *priv); +void il4965_eeprom_release_semaphore(struct il_priv *priv); +int il4965_eeprom_check_version(struct il_priv *priv); /* mac80211 handlers (for 4965) */ -void iwl4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb); -int iwl4965_mac_start(struct ieee80211_hw *hw); -void iwl4965_mac_stop(struct ieee80211_hw *hw); -void iwl4965_configure_filter(struct ieee80211_hw *hw, +void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb); +int il4965_mac_start(struct ieee80211_hw *hw); +void il4965_mac_stop(struct ieee80211_hw *hw); +void il4965_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags, unsigned int *total_flags, u64 multicast); -int iwl4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, +int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, struct ieee80211_vif *vif, struct ieee80211_sta *sta, struct ieee80211_key_conf *key); -void iwl4965_mac_update_tkip_key(struct ieee80211_hw *hw, +void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_key_conf *keyconf, struct ieee80211_sta *sta, u32 iv32, u16 *phase1key); -int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw, +int il4965_mac_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, enum ieee80211_ampdu_mlme_action action, struct ieee80211_sta *sta, u16 tid, u16 *ssn, u8 buf_size); -int iwl4965_mac_sta_add(struct ieee80211_hw *hw, +int il4965_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta); -void iwl4965_mac_channel_switch(struct ieee80211_hw *hw, +void il4965_mac_channel_switch(struct ieee80211_hw *hw, struct ieee80211_channel_switch *ch_switch); -#endif /* __iwl_4965_h__ */ +#endif /* __il_4965_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h index 89904054473f..347d40284309 100644 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ b/drivers/net/wireless/iwlegacy/iwl-commands.h @@ -66,22 +66,22 @@ * Please use iwl-dev.h for driver implementation definitions. */ -#ifndef __iwl_legacy_commands_h__ -#define __iwl_legacy_commands_h__ +#ifndef __il_commands_h__ +#define __il_commands_h__ -struct iwl_priv; +struct il_priv; /* uCode version contains 4 values: Major/Minor/API/Serial */ -#define IWL_UCODE_MAJOR(ver) (((ver) & 0xFF000000) >> 24) -#define IWL_UCODE_MINOR(ver) (((ver) & 0x00FF0000) >> 16) -#define IWL_UCODE_API(ver) (((ver) & 0x0000FF00) >> 8) -#define IWL_UCODE_SERIAL(ver) ((ver) & 0x000000FF) +#define IL_UCODE_MAJOR(ver) (((ver) & 0xFF000000) >> 24) +#define IL_UCODE_MINOR(ver) (((ver) & 0x00FF0000) >> 16) +#define IL_UCODE_API(ver) (((ver) & 0x0000FF00) >> 8) +#define IL_UCODE_SERIAL(ver) ((ver) & 0x000000FF) /* Tx rates */ -#define IWL_CCK_RATES 4 -#define IWL_OFDM_RATES 8 -#define IWL_MAX_RATES (IWL_CCK_RATES + IWL_OFDM_RATES) +#define IL_CCK_RATES 4 +#define IL_OFDM_RATES 8 +#define IL_MAX_RATES (IL_CCK_RATES + IL_OFDM_RATES) enum { REPLY_ALIVE = 0x1, @@ -163,8 +163,8 @@ enum { * *****************************************************************************/ -/* iwl_cmd_header flags value */ -#define IWL_CMD_FAILED_MSK 0x40 +/* il_cmd_header flags value */ +#define IL_CMD_FAILED_MSK 0x40 #define SEQ_TO_QUEUE(s) (((s) >> 8) & 0x1f) #define QUEUE_TO_SEQ(q) (((q) & 0x1f) << 8) @@ -174,12 +174,12 @@ enum { #define SEQ_RX_FRAME cpu_to_le16(0x8000) /** - * struct iwl_cmd_header + * struct il_cmd_header * * This header format appears in the beginning of each command sent from the * driver, and each response/notification received from uCode. */ -struct iwl_cmd_header { +struct il_cmd_header { u8 cmd; /* Command ID: REPLY_RXON, etc. */ u8 flags; /* 0:5 reserved, 6 abort, 7 internal */ /* @@ -212,7 +212,7 @@ struct iwl_cmd_header { /** - * struct iwl3945_tx_power + * struct il3945_tx_power * * Used in REPLY_TX_PWR_TABLE_CMD, REPLY_SCAN_CMD, REPLY_CHANNEL_SWITCH * @@ -223,21 +223,21 @@ struct iwl_cmd_header { * 2) Radio gain. This sets the analog gain of the radio Tx path. * It is a coarser setting, and behaves in a logarithmic (dB) fashion. * - * Driver obtains values from struct iwl3945_tx_power power_gain_table[][]. + * Driver obtains values from struct il3945_tx_power power_gain_table[][]. */ -struct iwl3945_tx_power { +struct il3945_tx_power { u8 tx_gain; /* gain for analog radio */ u8 dsp_atten; /* gain for DSP */ } __packed; /** - * struct iwl3945_power_per_rate + * struct il3945_power_per_rate * * Used in REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH */ -struct iwl3945_power_per_rate { +struct il3945_power_per_rate { u8 rate; /* plcp */ - struct iwl3945_tx_power tpc; + struct il3945_tx_power tpc; u8 reserved; } __packed; @@ -330,11 +330,11 @@ struct iwl3945_power_per_rate { #define POWER_TABLE_NUM_HT_OFDM_ENTRIES 32 #define POWER_TABLE_CCK_ENTRY 32 -#define IWL_PWR_NUM_HT_OFDM_ENTRIES 24 -#define IWL_PWR_CCK_ENTRIES 2 +#define IL_PWR_NUM_HT_OFDM_ENTRIES 24 +#define IL_PWR_CCK_ENTRIES 2 /** - * union iwl4965_tx_power_dual_stream + * union il4965_tx_power_dual_stream * * Host format used for REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH * Use __le32 version (struct tx_power_dual_stream) when building command. @@ -349,7 +349,7 @@ struct iwl3945_power_per_rate { * * See more details in doc for TXPOWER in iwl-4965-hw.h. */ -union iwl4965_tx_power_dual_stream { +union il4965_tx_power_dual_stream { struct { u8 radio_tx_gain[2]; u8 dsp_predis_atten[2]; @@ -362,18 +362,18 @@ union iwl4965_tx_power_dual_stream { * * Table entries in REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH * - * Same format as iwl_tx_power_dual_stream, but __le32 + * Same format as il_tx_power_dual_stream, but __le32 */ struct tx_power_dual_stream { __le32 dw; } __packed; /** - * struct iwl4965_tx_power_db + * struct il4965_tx_power_db * * Entire table within REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH */ -struct iwl4965_tx_power_db { +struct il4965_tx_power_db { struct tx_power_dual_stream power_tbl[POWER_TABLE_NUM_ENTRIES]; } __packed; @@ -410,7 +410,7 @@ struct iwl4965_tx_power_db { * 3) Tx gain compensation to balance 4965's 2 Tx chains for MIMO operation, * for each of 5 frequency ranges. */ -struct iwl_init_alive_resp { +struct il_init_alive_resp { u8 ucode_minor; u8 ucode_major; __le16 reserved1; @@ -511,7 +511,7 @@ struct iwl_init_alive_resp { * The Linux driver can print both logs to the system log when a uCode error * occurs. */ -struct iwl_alive_resp { +struct il_alive_resp { u8 ucode_minor; u8 ucode_major; __le16 reserved1; @@ -528,7 +528,7 @@ struct iwl_alive_resp { /* * REPLY_ERROR = 0x2 (response only, not a command) */ -struct iwl_error_resp { +struct il_error_resp { __le32 error_type; u8 cmd_id; u8 reserved1; @@ -657,7 +657,7 @@ enum { * regardless of whether RXON_FILTER_ASSOC_MSK is set. */ -struct iwl3945_rxon_cmd { +struct il3945_rxon_cmd { u8 node_addr[6]; __le16 reserved1; u8 bssid_addr[6]; @@ -676,7 +676,7 @@ struct iwl3945_rxon_cmd { __le16 reserved5; } __packed; -struct iwl4965_rxon_cmd { +struct il4965_rxon_cmd { u8 node_addr[6]; __le16 reserved1; u8 bssid_addr[6]; @@ -699,7 +699,7 @@ struct iwl4965_rxon_cmd { /* Create a common rxon cmd which will be typecast into the 3945 or 4965 * specific rxon cmd, depending on where it is called from. */ -struct iwl_legacy_rxon_cmd { +struct il_rxon_cmd { u8 node_addr[6]; __le16 reserved1; u8 bssid_addr[6]; @@ -725,7 +725,7 @@ struct iwl_legacy_rxon_cmd { /* * REPLY_RXON_ASSOC = 0x11 (command, has simple generic response) */ -struct iwl3945_rxon_assoc_cmd { +struct il3945_rxon_assoc_cmd { __le32 flags; __le32 filter_flags; u8 ofdm_basic_rates; @@ -733,7 +733,7 @@ struct iwl3945_rxon_assoc_cmd { __le16 reserved; } __packed; -struct iwl4965_rxon_assoc_cmd { +struct il4965_rxon_assoc_cmd { __le32 flags; __le32 filter_flags; u8 ofdm_basic_rates; @@ -744,14 +744,14 @@ struct iwl4965_rxon_assoc_cmd { __le16 reserved; } __packed; -#define IWL_CONN_MAX_LISTEN_INTERVAL 10 -#define IWL_MAX_UCODE_BEACON_INTERVAL 4 /* 4096 */ +#define IL_CONN_MAX_LISTEN_INTERVAL 10 +#define IL_MAX_UCODE_BEACON_INTERVAL 4 /* 4096 */ #define IWL39_MAX_UCODE_BEACON_INTERVAL 1 /* 1024 */ /* * REPLY_RXON_TIMING = 0x14 (command, has simple generic response) */ -struct iwl_rxon_time_cmd { +struct il_rxon_time_cmd { __le64 timestamp; __le16 beacon_interval; __le16 atim_window; @@ -764,30 +764,30 @@ struct iwl_rxon_time_cmd { /* * REPLY_CHANNEL_SWITCH = 0x72 (command, has simple generic response) */ -struct iwl3945_channel_switch_cmd { +struct il3945_channel_switch_cmd { u8 band; u8 expect_beacon; __le16 channel; __le32 rxon_flags; __le32 rxon_filter_flags; __le32 switch_time; - struct iwl3945_power_per_rate power[IWL_MAX_RATES]; + struct il3945_power_per_rate power[IL_MAX_RATES]; } __packed; -struct iwl4965_channel_switch_cmd { +struct il4965_channel_switch_cmd { u8 band; u8 expect_beacon; __le16 channel; __le32 rxon_flags; __le32 rxon_filter_flags; __le32 switch_time; - struct iwl4965_tx_power_db tx_power; + struct il4965_tx_power_db tx_power; } __packed; /* * CHANNEL_SWITCH_NOTIFICATION = 0x73 (notification only, not a command) */ -struct iwl_csa_notification { +struct il_csa_notification { __le16 band; __le16 channel; __le32 status; /* 0 - OK, 1 - fail */ @@ -800,8 +800,8 @@ struct iwl_csa_notification { *****************************************************************************/ /** - * struct iwl_ac_qos -- QOS timing params for REPLY_QOS_PARAM - * One for each of 4 EDCA access categories in struct iwl_qosparam_cmd + * struct il_ac_qos -- QOS timing params for REPLY_QOS_PARAM + * One for each of 4 EDCA access categories in struct il_qosparam_cmd * * @cw_min: Contention window, start value in numbers of slots. * Should be a power-of-2, minus 1. Device's default is 0x0f. @@ -815,7 +815,7 @@ struct iwl_csa_notification { * transmission retry. Device uses cw_max as a bit mask, ANDed with new CW * value, to cap the CW value. */ -struct iwl_ac_qos { +struct il_ac_qos { __le16 cw_min; __le16 cw_max; u8 aifsn; @@ -837,9 +837,9 @@ struct iwl_ac_qos { * This command sets up timings for each of the 4 prioritized EDCA Tx FIFOs * 0: Background, 1: Best Effort, 2: Video, 3: Voice. */ -struct iwl_qosparam_cmd { +struct il_qosparam_cmd { __le32 qos_flags; - struct iwl_ac_qos ac[AC_NUM]; + struct il_ac_qos ac[AC_NUM]; } __packed; /****************************************************************************** @@ -852,15 +852,15 @@ struct iwl_qosparam_cmd { */ /* Special, dedicated locations within device's station table */ -#define IWL_AP_ID 0 -#define IWL_STA_ID 2 +#define IL_AP_ID 0 +#define IL_STA_ID 2 #define IWL3945_BROADCAST_ID 24 #define IWL3945_STATION_COUNT 25 #define IWL4965_BROADCAST_ID 31 #define IWL4965_STATION_COUNT 32 -#define IWL_STATION_COUNT 32 /* MAX(3945,4965)*/ -#define IWL_INVALID_STATION 255 +#define IL_STATION_COUNT 32 /* MAX(3945,4965)*/ +#define IL_INVALID_STATION 255 #define STA_FLG_TX_RATE_MSK cpu_to_le32(1 << 2) #define STA_FLG_PWR_SAVE_MSK cpu_to_le32(1 << 8) @@ -905,7 +905,7 @@ struct iwl_qosparam_cmd { * combined with Traffic ID (QOS priority), in format used by Tx Scheduler */ #define BUILD_RAxTID(sta_id, tid) (((sta_id) << 4) + (tid)) -struct iwl4965_keyinfo { +struct il4965_keyinfo { __le16 key_flags; u8 tkip_rx_tsc_byte2; /* TSC[2] for key mix ph1 detection */ u8 reserved1; @@ -923,7 +923,7 @@ struct iwl4965_keyinfo { * * Driver selects unused table index when adding new station, * or the index to a pre-existing station entry when modifying that station. - * Some indexes have special purposes (IWL_AP_ID, index 0, is for AP). + * Some indexes have special purposes (IL_AP_ID, index 0, is for AP). * * modify_mask flags select which parameters to modify vs. leave alone. */ @@ -954,19 +954,19 @@ struct sta_id_modify { * their own txpower/rate setup data). * * When getting started on a new channel, driver must set up the - * IWL_BROADCAST_ID entry (last entry in the table). For a client + * IL_BROADCAST_ID entry (last entry in the table). For a client * station in a BSS, once an AP is selected, driver sets up the AP STA - * in the IWL_AP_ID entry (1st entry in the table). BROADCAST and AP + * in the IL_AP_ID entry (1st entry in the table). BROADCAST and AP * are all that are needed for a BSS client station. If the device is * used as AP, or in an IBSS network, driver must set up station table - * entries for all STAs in network, starting with index IWL_STA_ID. + * entries for all STAs in network, starting with index IL_STA_ID. */ -struct iwl3945_addsta_cmd { +struct il3945_addsta_cmd { u8 mode; /* 1: modify existing, 0: add new station */ u8 reserved[3]; struct sta_id_modify sta; - struct iwl4965_keyinfo key; + struct il4965_keyinfo key; __le32 station_flags; /* STA_FLG_* */ __le32 station_flags_msk; /* STA_FLG_* */ @@ -990,11 +990,11 @@ struct iwl3945_addsta_cmd { __le16 add_immediate_ba_ssn; } __packed; -struct iwl4965_addsta_cmd { +struct il4965_addsta_cmd { u8 mode; /* 1: modify existing, 0: add new station */ u8 reserved[3]; struct sta_id_modify sta; - struct iwl4965_keyinfo key; + struct il4965_keyinfo key; __le32 station_flags; /* STA_FLG_* */ __le32 station_flags_msk; /* STA_FLG_* */ @@ -1028,11 +1028,11 @@ struct iwl4965_addsta_cmd { } __packed; /* Wrapper struct for 3945 and 4965 addsta_cmd structures */ -struct iwl_legacy_addsta_cmd { +struct il_addsta_cmd { u8 mode; /* 1: modify existing, 0: add new station */ u8 reserved[3]; struct sta_id_modify sta; - struct iwl4965_keyinfo key; + struct il4965_keyinfo key; __le32 station_flags; /* STA_FLG_* */ __le32 station_flags_msk; /* STA_FLG_* */ @@ -1073,7 +1073,7 @@ struct iwl_legacy_addsta_cmd { /* * REPLY_ADD_STA = 0x18 (response) */ -struct iwl_add_sta_resp { +struct il_add_sta_resp { u8 status; /* ADD_STA_* */ } __packed; @@ -1081,34 +1081,34 @@ struct iwl_add_sta_resp { /* * REPLY_REM_STA = 0x19 (response) */ -struct iwl_rem_sta_resp { +struct il_rem_sta_resp { u8 status; } __packed; /* * REPLY_REM_STA = 0x19 (command) */ -struct iwl_rem_sta_cmd { +struct il_rem_sta_cmd { u8 num_sta; /* number of removed stations */ u8 reserved[3]; u8 addr[ETH_ALEN]; /* MAC addr of the first station */ u8 reserved2[2]; } __packed; -#define IWL_TX_FIFO_BK_MSK cpu_to_le32(BIT(0)) -#define IWL_TX_FIFO_BE_MSK cpu_to_le32(BIT(1)) -#define IWL_TX_FIFO_VI_MSK cpu_to_le32(BIT(2)) -#define IWL_TX_FIFO_VO_MSK cpu_to_le32(BIT(3)) -#define IWL_AGG_TX_QUEUE_MSK cpu_to_le32(0xffc00) +#define IL_TX_FIFO_BK_MSK cpu_to_le32(BIT(0)) +#define IL_TX_FIFO_BE_MSK cpu_to_le32(BIT(1)) +#define IL_TX_FIFO_VI_MSK cpu_to_le32(BIT(2)) +#define IL_TX_FIFO_VO_MSK cpu_to_le32(BIT(3)) +#define IL_AGG_TX_QUEUE_MSK cpu_to_le32(0xffc00) -#define IWL_DROP_SINGLE 0 -#define IWL_DROP_SELECTED 1 -#define IWL_DROP_ALL 2 +#define IL_DROP_SINGLE 0 +#define IL_DROP_SELECTED 1 +#define IL_DROP_ALL 2 /* * REPLY_WEP_KEY = 0x20 */ -struct iwl_wep_key { +struct il_wep_key { u8 key_index; u8 key_offset; u8 reserved1[2]; @@ -1117,12 +1117,12 @@ struct iwl_wep_key { u8 key[16]; } __packed; -struct iwl_wep_cmd { +struct il_wep_cmd { u8 num_keys; u8 global_key_type; u8 flags; u8 reserved; - struct iwl_wep_key key[0]; + struct il_wep_key key[0]; } __packed; #define WEP_KEY_WEP_TYPE 1 @@ -1169,7 +1169,7 @@ struct iwl_wep_cmd { #define RX_MPDU_RES_STATUS_DEC_DONE_MSK (0x800) -struct iwl3945_rx_frame_stats { +struct il3945_rx_frame_stats { u8 phy_count; u8 id; u8 rssi; @@ -1179,7 +1179,7 @@ struct iwl3945_rx_frame_stats { u8 payload[0]; } __packed; -struct iwl3945_rx_frame_hdr { +struct il3945_rx_frame_hdr { __le16 channel; __le16 phy_flags; u8 reserved1; @@ -1188,7 +1188,7 @@ struct iwl3945_rx_frame_hdr { u8 payload[0]; } __packed; -struct iwl3945_rx_frame_end { +struct il3945_rx_frame_end { __le32 status; __le64 timestamp; __le32 beacon_timestamp; @@ -1202,13 +1202,13 @@ struct iwl3945_rx_frame_end { * The actual offsets of the hdr and end are dynamic based on * stats.phy_count */ -struct iwl3945_rx_frame { - struct iwl3945_rx_frame_stats stats; - struct iwl3945_rx_frame_hdr hdr; - struct iwl3945_rx_frame_end end; +struct il3945_rx_frame { + struct il3945_rx_frame_stats stats; + struct il3945_rx_frame_hdr hdr; + struct il3945_rx_frame_end end; } __packed; -#define IWL39_RX_FRAME_SIZE (4 + sizeof(struct iwl3945_rx_frame)) +#define IWL39_RX_FRAME_SIZE (4 + sizeof(struct il3945_rx_frame)) /* Fixed (non-configurable) rx data from phy */ @@ -1217,7 +1217,7 @@ struct iwl3945_rx_frame { #define IWL49_RX_PHY_FLAGS_ANTENNAE_MASK (0x70) #define IWL49_AGC_DB_MASK (0x3f80) /* MASK(7,13) */ #define IWL49_AGC_DB_POS (7) -struct iwl4965_rx_non_cfg_phy { +struct il4965_rx_non_cfg_phy { __le16 ant_selection; /* ant A bit 4, ant B bit 5, ant C bit 6 */ __le16 agc_info; /* agc code 0:6, agc dB 7:13, reserved 14:15 */ u8 rssi_info[6]; /* we use even entries, 0/2/4 for A/B/C rssi */ @@ -1229,7 +1229,7 @@ struct iwl4965_rx_non_cfg_phy { * REPLY_RX = 0xc3 (response only, not a command) * Used only for legacy (non 11n) frames. */ -struct iwl_rx_phy_res { +struct il_rx_phy_res { u8 non_cfg_phy_cnt; /* non configurable DSP phy data byte count */ u8 cfg_phy_cnt; /* configurable DSP phy data byte count */ u8 stat_id; /* configurable DSP phy data set ID */ @@ -1244,7 +1244,7 @@ struct iwl_rx_phy_res { __le16 frame_time; /* frame's time on the air */ } __packed; -struct iwl_rx_mpdu_res_start { +struct il_rx_mpdu_res_start { __le16 byte_count; __le16 reserved; } __packed; @@ -1372,7 +1372,7 @@ struct iwl_rx_mpdu_res_start { * REPLY_TX = 0x1c (command) */ -struct iwl3945_tx_cmd { +struct il3945_tx_cmd { /* * MPDU byte count: * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size, @@ -1436,7 +1436,7 @@ struct iwl3945_tx_cmd { /* * REPLY_TX = 0x1c (response) */ -struct iwl3945_tx_resp { +struct il3945_tx_resp { u8 failure_rts; u8 failure_frame; u8 bt_kill_count; @@ -1451,13 +1451,13 @@ struct iwl3945_tx_resp { * Used for managing Tx retries when expecting block-acks. * Driver should set these fields to 0. */ -struct iwl_dram_scratch { +struct il_dram_scratch { u8 try_cnt; /* Tx attempts */ u8 bt_kill_cnt; /* Tx attempts blocked by Bluetooth device */ __le16 reserved; } __packed; -struct iwl_tx_cmd { +struct il_tx_cmd { /* * MPDU byte count: * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size, @@ -1481,7 +1481,7 @@ struct iwl_tx_cmd { /* uCode may modify this field of the Tx command (in host DRAM!). * Driver must also set dram_lsb_ptr and dram_msb_ptr in this cmd. */ - struct iwl_dram_scratch scratch; + struct il_dram_scratch scratch; /* Rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is cleared. */ __le32 rate_n_flags; /* RATE_MCS_* */ @@ -1697,7 +1697,7 @@ struct agg_tx_status { __le16 sequence; } __packed; -struct iwl4965_tx_resp { +struct il4965_tx_resp { u8 frame_count; /* 1 no aggregation, >1 aggregation */ u8 bt_kill_count; /* # blocked by bluetooth (unused for agg) */ u8 failure_rts; /* # failures due to unsuccessful RTS */ @@ -1739,7 +1739,7 @@ struct iwl4965_tx_resp { * * Reports Block-Acknowledge from recipient station */ -struct iwl_compressed_ba_resp { +struct il_compressed_ba_resp { __le32 sta_addr_lo32; __le16 sta_addr_hi16; __le16 reserved; @@ -1759,23 +1759,23 @@ struct iwl_compressed_ba_resp { * See details under "TXPOWER" in iwl-4965-hw.h. */ -struct iwl3945_txpowertable_cmd { +struct il3945_txpowertable_cmd { u8 band; /* 0: 5 GHz, 1: 2.4 GHz */ u8 reserved; __le16 channel; - struct iwl3945_power_per_rate power[IWL_MAX_RATES]; + struct il3945_power_per_rate power[IL_MAX_RATES]; } __packed; -struct iwl4965_txpowertable_cmd { +struct il4965_txpowertable_cmd { u8 band; /* 0: 5 GHz, 1: 2.4 GHz */ u8 reserved; __le16 channel; - struct iwl4965_tx_power_db tx_power; + struct il4965_tx_power_db tx_power; } __packed; /** - * struct iwl3945_rate_scaling_cmd - Rate Scaling Command & Response + * struct il3945_rate_scaling_cmd - Rate Scaling Command & Response * * REPLY_RATE_SCALE = 0x47 (command, has simple generic response) * @@ -1789,16 +1789,16 @@ struct iwl4965_txpowertable_cmd { * when passed through ofdm_basic_rates on the REPLY_RXON * command would be bit 0 (1 << 0) */ -struct iwl3945_rate_scaling_info { +struct il3945_rate_scaling_info { __le16 rate_n_flags; u8 try_cnt; u8 next_rate_index; } __packed; -struct iwl3945_rate_scaling_cmd { +struct il3945_rate_scaling_cmd { u8 table_id; u8 reserved[3]; - struct iwl3945_rate_scaling_info table[IWL_MAX_RATES]; + struct il3945_rate_scaling_info table[IL_MAX_RATES]; } __packed; @@ -1818,11 +1818,11 @@ struct iwl3945_rate_scaling_cmd { /** - * struct iwl_link_qual_general_params + * struct il_link_qual_general_params * * Used in REPLY_TX_LINK_QUALITY_CMD */ -struct iwl_link_qual_general_params { +struct il_link_qual_general_params { u8 flags; /* No entries at or above this (driver chosen) index contain MIMO */ @@ -1861,11 +1861,11 @@ struct iwl_link_qual_general_params { #define LINK_QUAL_AGG_FRAME_LIMIT_MIN (0) /** - * struct iwl_link_qual_agg_params + * struct il_link_qual_agg_params * * Used in REPLY_TX_LINK_QUALITY_CMD */ -struct iwl_link_qual_agg_params { +struct il_link_qual_agg_params { /* *Maximum number of uSec in aggregation. @@ -1966,7 +1966,7 @@ struct iwl_link_qual_agg_params { * * When using block-ack (aggregation), all frames are transmitted at the same * rate, since there is no per-attempt acknowledgment from the destination - * station. The Tx response struct iwl_tx_resp indicates the Tx rate in + * station. The Tx response struct il_tx_resp indicates the Tx rate in * rate_n_flags field. After receiving a block-ack, the driver can update * history for the entire block all at once. * @@ -2079,14 +2079,14 @@ struct iwl_link_qual_agg_params { * legacy), and then repeat the search process. * */ -struct iwl_link_quality_cmd { +struct il_link_quality_cmd { /* Index of destination/recipient station in uCode's station table */ u8 sta_id; u8 reserved1; __le16 control; /* not used */ - struct iwl_link_qual_general_params general_params; - struct iwl_link_qual_agg_params agg_params; + struct il_link_qual_general_params general_params; + struct il_link_qual_agg_params agg_params; /* * Rate info; when using rate-scaling, Tx command's initial_rate_index @@ -2094,7 +2094,7 @@ struct iwl_link_quality_cmd { * 4965 devices works its way through table when retrying Tx. */ struct { - __le32 rate_n_flags; /* RATE_MCS_*, IWL_RATE_* */ + __le32 rate_n_flags; /* RATE_MCS_*, IL_RATE_* */ } rs_table[LINK_QUAL_MAX_RETRY_NUM]; __le32 reserved2; } __packed; @@ -2123,7 +2123,7 @@ struct iwl_link_quality_cmd { * same platform. Bluetooth device alerts wireless device when it will Tx; * wireless device can delay or kill its own Tx to accommodate. */ -struct iwl_bt_cmd { +struct il_bt_cmd { u8 flags; u8 lead_time; u8 max_kill; @@ -2150,18 +2150,18 @@ struct iwl_bt_cmd { RXON_FILTER_ASSOC_MSK | \ RXON_FILTER_BCON_AWARE_MSK) -struct iwl_measure_channel { +struct il_measure_channel { __le32 duration; /* measurement duration in extended beacon * format */ u8 channel; /* channel to measure */ - u8 type; /* see enum iwl_measure_type */ + u8 type; /* see enum il_measure_type */ __le16 reserved; } __packed; /* * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (command) */ -struct iwl_spectrum_cmd { +struct il_spectrum_cmd { __le16 len; /* number of bytes starting from token */ u8 token; /* token id */ u8 id; /* measurement id -- 0 or 1 */ @@ -2174,13 +2174,13 @@ struct iwl_spectrum_cmd { __le32 filter_flags; /* rxon filter flags */ __le16 channel_count; /* minimum 1, maximum 10 */ __le16 reserved3; - struct iwl_measure_channel channels[10]; + struct il_measure_channel channels[10]; } __packed; /* * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (response) */ -struct iwl_spectrum_resp { +struct il_spectrum_resp { u8 token; u8 id; /* id of the prior command replaced, or 0xff */ __le16 status; /* 0 - command will be handled @@ -2188,49 +2188,49 @@ struct iwl_spectrum_resp { * measurement) */ } __packed; -enum iwl_measurement_state { - IWL_MEASUREMENT_START = 0, - IWL_MEASUREMENT_STOP = 1, +enum il_measurement_state { + IL_MEASUREMENT_START = 0, + IL_MEASUREMENT_STOP = 1, }; -enum iwl_measurement_status { - IWL_MEASUREMENT_OK = 0, - IWL_MEASUREMENT_CONCURRENT = 1, - IWL_MEASUREMENT_CSA_CONFLICT = 2, - IWL_MEASUREMENT_TGH_CONFLICT = 3, +enum il_measurement_status { + IL_MEASUREMENT_OK = 0, + IL_MEASUREMENT_CONCURRENT = 1, + IL_MEASUREMENT_CSA_CONFLICT = 2, + IL_MEASUREMENT_TGH_CONFLICT = 3, /* 4-5 reserved */ - IWL_MEASUREMENT_STOPPED = 6, - IWL_MEASUREMENT_TIMEOUT = 7, - IWL_MEASUREMENT_PERIODIC_FAILED = 8, + IL_MEASUREMENT_STOPPED = 6, + IL_MEASUREMENT_TIMEOUT = 7, + IL_MEASUREMENT_PERIODIC_FAILED = 8, }; #define NUM_ELEMENTS_IN_HISTOGRAM 8 -struct iwl_measurement_histogram { +struct il_measurement_histogram { __le32 ofdm[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 0.8usec counts */ __le32 cck[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 1usec counts */ } __packed; /* clear channel availability counters */ -struct iwl_measurement_cca_counters { +struct il_measurement_cca_counters { __le32 ofdm; __le32 cck; } __packed; -enum iwl_measure_type { - IWL_MEASURE_BASIC = (1 << 0), - IWL_MEASURE_CHANNEL_LOAD = (1 << 1), - IWL_MEASURE_HISTOGRAM_RPI = (1 << 2), - IWL_MEASURE_HISTOGRAM_NOISE = (1 << 3), - IWL_MEASURE_FRAME = (1 << 4), +enum il_measure_type { + IL_MEASURE_BASIC = (1 << 0), + IL_MEASURE_CHANNEL_LOAD = (1 << 1), + IL_MEASURE_HISTOGRAM_RPI = (1 << 2), + IL_MEASURE_HISTOGRAM_NOISE = (1 << 3), + IL_MEASURE_FRAME = (1 << 4), /* bits 5:6 are reserved */ - IWL_MEASURE_IDLE = (1 << 7), + IL_MEASURE_IDLE = (1 << 7), }; /* * SPECTRUM_MEASURE_NOTIFICATION = 0x75 (notification only, not a command) */ -struct iwl_spectrum_notification { +struct il_spectrum_notification { u8 id; /* measurement id -- 0 or 1 */ u8 token; u8 channel_index; /* index in measurement channel list */ @@ -2238,7 +2238,7 @@ struct iwl_spectrum_notification { __le32 start_time; /* lower 32-bits of TSF */ u8 band; /* 0 - 5.2GHz, 1 - 2.4GHz */ u8 channel; - u8 type; /* see enum iwl_measurement_type */ + u8 type; /* see enum il_measurement_type */ u8 reserved1; /* NOTE: cca_ofdm, cca_cck, basic_type, and histogram are only only * valid if applicable for measurement type requested. */ @@ -2248,9 +2248,9 @@ struct iwl_spectrum_notification { u8 basic_type; /* 0 - bss, 1 - ofdm preamble, 2 - * unidentified */ u8 reserved2[3]; - struct iwl_measurement_histogram histogram; + struct il_measurement_histogram histogram; __le32 stop_time; /* lower 32-bits of TSF */ - __le32 status; /* see iwl_measurement_status */ + __le32 status; /* see il_measurement_status */ } __packed; /****************************************************************************** @@ -2260,7 +2260,7 @@ struct iwl_spectrum_notification { *****************************************************************************/ /** - * struct iwl_powertable_cmd - Power Table Command + * struct il_powertable_cmd - Power Table Command * @flags: See below: * * POWER_TABLE_CMD = 0x77 (command, has simple generic response) @@ -2294,26 +2294,26 @@ struct iwl_spectrum_notification { * ucode assume sleep over DTIM is allowed and we don't need to wake up * for every DTIM. */ -#define IWL_POWER_VEC_SIZE 5 +#define IL_POWER_VEC_SIZE 5 -#define IWL_POWER_DRIVER_ALLOW_SLEEP_MSK cpu_to_le16(BIT(0)) -#define IWL_POWER_PCI_PM_MSK cpu_to_le16(BIT(3)) +#define IL_POWER_DRIVER_ALLOW_SLEEP_MSK cpu_to_le16(BIT(0)) +#define IL_POWER_PCI_PM_MSK cpu_to_le16(BIT(3)) -struct iwl3945_powertable_cmd { +struct il3945_powertable_cmd { __le16 flags; u8 reserved[2]; __le32 rx_data_timeout; __le32 tx_data_timeout; - __le32 sleep_interval[IWL_POWER_VEC_SIZE]; + __le32 sleep_interval[IL_POWER_VEC_SIZE]; } __packed; -struct iwl_powertable_cmd { +struct il_powertable_cmd { __le16 flags; u8 keep_alive_seconds; /* 3945 reserved */ u8 debug_flags; /* 3945 reserved */ __le32 rx_data_timeout; __le32 tx_data_timeout; - __le32 sleep_interval[IWL_POWER_VEC_SIZE]; + __le32 sleep_interval[IL_POWER_VEC_SIZE]; __le32 keep_alive_beacons; } __packed; @@ -2321,7 +2321,7 @@ struct iwl_powertable_cmd { * PM_SLEEP_NOTIFICATION = 0x7A (notification only, not a command) * all devices identical. */ -struct iwl_sleep_notification { +struct il_sleep_notification { u8 pm_sleep_mode; u8 pm_wakeup_src; __le16 reserved; @@ -2332,23 +2332,23 @@ struct iwl_sleep_notification { /* Sleep states. all devices identical. */ enum { - IWL_PM_NO_SLEEP = 0, - IWL_PM_SLP_MAC = 1, - IWL_PM_SLP_FULL_MAC_UNASSOCIATE = 2, - IWL_PM_SLP_FULL_MAC_CARD_STATE = 3, - IWL_PM_SLP_PHY = 4, - IWL_PM_SLP_REPENT = 5, - IWL_PM_WAKEUP_BY_TIMER = 6, - IWL_PM_WAKEUP_BY_DRIVER = 7, - IWL_PM_WAKEUP_BY_RFKILL = 8, + IL_PM_NO_SLEEP = 0, + IL_PM_SLP_MAC = 1, + IL_PM_SLP_FULL_MAC_UNASSOCIATE = 2, + IL_PM_SLP_FULL_MAC_CARD_STATE = 3, + IL_PM_SLP_PHY = 4, + IL_PM_SLP_REPENT = 5, + IL_PM_WAKEUP_BY_TIMER = 6, + IL_PM_WAKEUP_BY_DRIVER = 7, + IL_PM_WAKEUP_BY_RFKILL = 8, /* 3 reserved */ - IWL_PM_NUM_OF_MODES = 12, + IL_PM_NUM_OF_MODES = 12, }; /* * CARD_STATE_NOTIFICATION = 0xa1 (notification only, not a command) */ -struct iwl_card_state_notif { +struct il_card_state_notif { __le32 flags; } __packed; @@ -2357,7 +2357,7 @@ struct iwl_card_state_notif { #define CT_CARD_DISABLED 0x04 #define RXON_CARD_DISABLED 0x10 -struct iwl_ct_kill_config { +struct il_ct_kill_config { __le32 reserved; __le32 critical_temperature_M; __le32 critical_temperature_R; @@ -2373,7 +2373,7 @@ struct iwl_ct_kill_config { #define SCAN_CHANNEL_TYPE_ACTIVE cpu_to_le32(1) /** - * struct iwl_scan_channel - entry in REPLY_SCAN_CMD channel table + * struct il_scan_channel - entry in REPLY_SCAN_CMD channel table * * One for each channel in the scan list. * Each channel can independently select: @@ -2383,7 +2383,7 @@ struct iwl_ct_kill_config { * quiet_plcp_th, good_CRC_th) * * To avoid uCode errors, make sure the following are true (see comments - * under struct iwl_scan_cmd about max_out_time and quiet_time): + * under struct il_scan_cmd about max_out_time and quiet_time): * 1) If using passive_dwell (i.e. passive_dwell != 0): * active_dwell <= passive_dwell (< max_out_time if max_out_time != 0) * 2) quiet_time <= active_dwell @@ -2391,7 +2391,7 @@ struct iwl_ct_kill_config { * passive_dwell < max_out_time * active_dwell < max_out_time */ -struct iwl3945_scan_channel { +struct il3945_scan_channel { /* * type is defined as: * 0:0 1 = active, 0 = passive @@ -2400,8 +2400,8 @@ struct iwl3945_scan_channel { * 5:7 reserved */ u8 type; - u8 channel; /* band is selected by iwl3945_scan_cmd "flags" field */ - struct iwl3945_tx_power tpc; + u8 channel; /* band is selected by il3945_scan_cmd "flags" field */ + struct il3945_tx_power tpc; __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */ __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */ } __packed; @@ -2409,7 +2409,7 @@ struct iwl3945_scan_channel { /* set number of direct probes u8 type */ #define IWL39_SCAN_PROBE_MASK(n) ((BIT(n) | (BIT(n) - BIT(1)))) -struct iwl_scan_channel { +struct il_scan_channel { /* * type is defined as: * 0:0 1 = active, 0 = passive @@ -2418,7 +2418,7 @@ struct iwl_scan_channel { * 21:31 reserved */ __le32 type; - __le16 channel; /* band is selected by iwl_scan_cmd "flags" field */ + __le16 channel; /* band is selected by il_scan_cmd "flags" field */ u8 tx_gain; /* gain for analog radio */ u8 dsp_atten; /* gain for DSP */ __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */ @@ -2426,17 +2426,17 @@ struct iwl_scan_channel { } __packed; /* set number of direct probes __le32 type */ -#define IWL_SCAN_PROBE_MASK(n) cpu_to_le32((BIT(n) | (BIT(n) - BIT(1)))) +#define IL_SCAN_PROBE_MASK(n) cpu_to_le32((BIT(n) | (BIT(n) - BIT(1)))) /** - * struct iwl_ssid_ie - directed scan network information element + * struct il_ssid_ie - directed scan network information element * * Up to 20 of these may appear in REPLY_SCAN_CMD (Note: Only 4 are in - * 3945 SCAN api), selected by "type" bit field in struct iwl_scan_channel; + * 3945 SCAN api), selected by "type" bit field in struct il_scan_channel; * each channel may select different ssids from among the 20 (4) entries. * SSID IEs get transmitted in reverse order of entry. */ -struct iwl_ssid_ie { +struct il_ssid_ie { u8 id; u8 len; u8 ssid[32]; @@ -2445,11 +2445,11 @@ struct iwl_ssid_ie { #define PROBE_OPTION_MAX_3945 4 #define PROBE_OPTION_MAX 20 #define TX_CMD_LIFE_TIME_INFINITE cpu_to_le32(0xFFFFFFFF) -#define IWL_GOOD_CRC_TH_DISABLED 0 -#define IWL_GOOD_CRC_TH_DEFAULT cpu_to_le16(1) -#define IWL_GOOD_CRC_TH_NEVER cpu_to_le16(0xffff) -#define IWL_MAX_SCAN_SIZE 1024 -#define IWL_MAX_CMD_SIZE 4096 +#define IL_GOOD_CRC_TH_DISABLED 0 +#define IL_GOOD_CRC_TH_DEFAULT cpu_to_le16(1) +#define IL_GOOD_CRC_TH_NEVER cpu_to_le16(0xffff) +#define IL_MAX_SCAN_SIZE 1024 +#define IL_MAX_CMD_SIZE 4096 /* * REPLY_SCAN_CMD = 0x80 (command) @@ -2501,10 +2501,10 @@ struct iwl_ssid_ie { * Driver must use separate scan commands for 2.4 vs. 5 GHz bands. * * To avoid uCode errors, see timing restrictions described under - * struct iwl_scan_channel. + * struct il_scan_channel. */ -struct iwl3945_scan_cmd { +struct il3945_scan_cmd { __le16 len; u8 reserved0; u8 channel_count; /* # channels in channel list */ @@ -2525,10 +2525,10 @@ struct iwl3945_scan_cmd { /* For active scans (set to all-0s for passive scans). * Does not include payload. Must specify Tx rate; no rate scaling. */ - struct iwl3945_tx_cmd tx_cmd; + struct il3945_tx_cmd tx_cmd; /* For directed active scans (set to all-0s otherwise) */ - struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX_3945]; + struct il_ssid_ie direct_scan[PROBE_OPTION_MAX_3945]; /* * Probe request frame, followed by channel list. @@ -2538,7 +2538,7 @@ struct iwl3945_scan_cmd { * Number of channels in list is specified by channel_count. * Each channel in list is of type: * - * struct iwl3945_scan_channel channels[0]; + * struct il3945_scan_channel channels[0]; * * NOTE: Only one band of channels can be scanned per pass. You * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait @@ -2548,7 +2548,7 @@ struct iwl3945_scan_cmd { u8 data[0]; } __packed; -struct iwl_scan_cmd { +struct il_scan_cmd { __le16 len; u8 reserved0; u8 channel_count; /* # channels in channel list */ @@ -2569,10 +2569,10 @@ struct iwl_scan_cmd { /* For active scans (set to all-0s for passive scans). * Does not include payload. Must specify Tx rate; no rate scaling. */ - struct iwl_tx_cmd tx_cmd; + struct il_tx_cmd tx_cmd; /* For directed active scans (set to all-0s otherwise) */ - struct iwl_ssid_ie direct_scan[PROBE_OPTION_MAX]; + struct il_ssid_ie direct_scan[PROBE_OPTION_MAX]; /* * Probe request frame, followed by channel list. @@ -2582,7 +2582,7 @@ struct iwl_scan_cmd { * Number of channels in list is specified by channel_count. * Each channel in list is of type: * - * struct iwl_scan_channel channels[0]; + * struct il_scan_channel channels[0]; * * NOTE: Only one band of channels can be scanned per pass. You * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait @@ -2600,14 +2600,14 @@ struct iwl_scan_cmd { /* * REPLY_SCAN_CMD = 0x80 (response) */ -struct iwl_scanreq_notification { +struct il_scanreq_notification { __le32 status; /* 1: okay, 2: cannot fulfill request */ } __packed; /* * SCAN_START_NOTIFICATION = 0x82 (notification only, not a command) */ -struct iwl_scanstart_notification { +struct il_scanstart_notification { __le32 tsf_low; __le32 tsf_high; __le32 beacon_timer; @@ -2620,17 +2620,17 @@ struct iwl_scanstart_notification { #define SCAN_OWNER_STATUS 0x1 #define MEASURE_OWNER_STATUS 0x2 -#define IWL_PROBE_STATUS_OK 0 -#define IWL_PROBE_STATUS_TX_FAILED BIT(0) +#define IL_PROBE_STATUS_OK 0 +#define IL_PROBE_STATUS_TX_FAILED BIT(0) /* error statuses combined with TX_FAILED */ -#define IWL_PROBE_STATUS_FAIL_TTL BIT(1) -#define IWL_PROBE_STATUS_FAIL_BT BIT(2) +#define IL_PROBE_STATUS_FAIL_TTL BIT(1) +#define IL_PROBE_STATUS_FAIL_BT BIT(2) #define NUMBER_OF_STATISTICS 1 /* first __le32 is good CRC */ /* * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command) */ -struct iwl_scanresults_notification { +struct il_scanresults_notification { u8 channel; u8 band; u8 probe_status; @@ -2643,7 +2643,7 @@ struct iwl_scanresults_notification { /* * SCAN_COMPLETE_NOTIFICATION = 0x84 (notification only, not a command) */ -struct iwl_scancomplete_notification { +struct il_scancomplete_notification { u8 scanned_channels; u8 status; u8 last_channel; @@ -2658,24 +2658,24 @@ struct iwl_scancomplete_notification { * *****************************************************************************/ -enum iwl_ibss_manager { - IWL_NOT_IBSS_MANAGER = 0, - IWL_IBSS_MANAGER = 1, +enum il_ibss_manager { + IL_NOT_IBSS_MANAGER = 0, + IL_IBSS_MANAGER = 1, }; /* * BEACON_NOTIFICATION = 0x90 (notification only, not a command) */ -struct iwl3945_beacon_notif { - struct iwl3945_tx_resp beacon_notify_hdr; +struct il3945_beacon_notif { + struct il3945_tx_resp beacon_notify_hdr; __le32 low_tsf; __le32 high_tsf; __le32 ibss_mgr_status; } __packed; -struct iwl4965_beacon_notif { - struct iwl4965_tx_resp beacon_notify_hdr; +struct il4965_beacon_notif { + struct il4965_tx_resp beacon_notify_hdr; __le32 low_tsf; __le32 high_tsf; __le32 ibss_mgr_status; @@ -2685,16 +2685,16 @@ struct iwl4965_beacon_notif { * REPLY_TX_BEACON = 0x91 (command, has simple generic response) */ -struct iwl3945_tx_beacon_cmd { - struct iwl3945_tx_cmd tx; +struct il3945_tx_beacon_cmd { + struct il3945_tx_cmd tx; __le16 tim_idx; u8 tim_size; u8 reserved1; struct ieee80211_hdr frame[0]; /* beacon frame */ } __packed; -struct iwl_tx_beacon_cmd { - struct iwl_tx_cmd tx; +struct il_tx_beacon_cmd { + struct il_tx_cmd tx; __le16 tim_idx; u8 tim_size; u8 reserved1; @@ -2707,7 +2707,7 @@ struct iwl_tx_beacon_cmd { * *****************************************************************************/ -#define IWL_TEMP_CONVERT 260 +#define IL_TEMP_CONVERT 260 #define SUP_RATE_11A_MAX_NUM_CHANNELS 8 #define SUP_RATE_11B_MAX_NUM_CHANNELS 4 @@ -2977,10 +2977,10 @@ struct statistics_general { * STATISTICS_NOTIFICATIONs after received beacons (see below). This flag * does not affect the response to the REPLY_STATISTICS_CMD 0x9c itself. */ -#define IWL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1) /* see above */ -#define IWL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */ -struct iwl_statistics_cmd { - __le32 configuration_flags; /* IWL_STATS_CONF_* */ +#define IL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1) /* see above */ +#define IL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */ +struct il_statistics_cmd { + __le32 configuration_flags; /* IL_STATS_CONF_* */ } __packed; /* @@ -3001,14 +3001,14 @@ struct iwl_statistics_cmd { #define STATISTICS_REPLY_FLG_BAND_24G_MSK cpu_to_le32(0x2) #define STATISTICS_REPLY_FLG_HT40_MODE_MSK cpu_to_le32(0x8) -struct iwl3945_notif_statistics { +struct il3945_notif_statistics { __le32 flag; struct iwl39_statistics_rx rx; struct iwl39_statistics_tx tx; struct iwl39_statistics_general general; } __packed; -struct iwl_notif_statistics { +struct il_notif_statistics { __le32 flag; struct statistics_rx rx; struct statistics_tx tx; @@ -3035,11 +3035,11 @@ struct iwl_notif_statistics { * */ -#define IWL_MISSED_BEACON_THRESHOLD_MIN (1) -#define IWL_MISSED_BEACON_THRESHOLD_DEF (5) -#define IWL_MISSED_BEACON_THRESHOLD_MAX IWL_MISSED_BEACON_THRESHOLD_DEF +#define IL_MISSED_BEACON_THRESHOLD_MIN (1) +#define IL_MISSED_BEACON_THRESHOLD_DEF (5) +#define IL_MISSED_BEACON_THRESHOLD_MAX IL_MISSED_BEACON_THRESHOLD_DEF -struct iwl_missed_beacon_notif { +struct il_missed_beacon_notif { __le32 consecutive_missed_beacons; __le32 total_missed_becons; __le32 num_expected_beacons; @@ -3111,7 +3111,7 @@ struct iwl_missed_beacon_notif { * * Total number of false alarms = false_alarms + plcp_errs * - * For OFDM, adjust the following table entries in struct iwl_sensitivity_cmd + * For OFDM, adjust the following table entries in struct il_sensitivity_cmd * (notice that the start points for OFDM are at or close to settings for * maximum sensitivity): * @@ -3152,7 +3152,7 @@ struct iwl_missed_beacon_notif { * Reset this to 0 at the first beacon period that falls within the * "good" range (5 to 50 false alarms per 204.8 milliseconds rx). * - * Then, adjust the following CCK table entries in struct iwl_sensitivity_cmd + * Then, adjust the following CCK table entries in struct il_sensitivity_cmd * (notice that the start points for CCK are at maximum sensitivity): * * START / MIN / MAX @@ -3217,7 +3217,7 @@ struct iwl_missed_beacon_notif { */ /* - * Table entries in SENSITIVITY_CMD (struct iwl_sensitivity_cmd) + * Table entries in SENSITIVITY_CMD (struct il_sensitivity_cmd) */ #define HD_TABLE_SIZE (11) /* number of entries */ #define HD_MIN_ENERGY_CCK_DET_INDEX (0) /* table indexes */ @@ -3232,18 +3232,18 @@ struct iwl_missed_beacon_notif { #define HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX (9) #define HD_OFDM_ENERGY_TH_IN_INDEX (10) -/* Control field in struct iwl_sensitivity_cmd */ +/* Control field in struct il_sensitivity_cmd */ #define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE cpu_to_le16(0) #define SENSITIVITY_CMD_CONTROL_WORK_TABLE cpu_to_le16(1) /** - * struct iwl_sensitivity_cmd + * struct il_sensitivity_cmd * @control: (1) updates working table, (0) updates default table * @table: energy threshold values, use HD_* as index into table * * Always use "1" in "control" to update uCode's working table and DSP. */ -struct iwl_sensitivity_cmd { +struct il_sensitivity_cmd { __le16 control; /* always use "1" */ __le16 table[HD_TABLE_SIZE]; /* use HD_* as index */ } __packed; @@ -3294,7 +3294,7 @@ struct iwl_sensitivity_cmd { * (accum_noise[i] - accum_noise[reference]) / 30 * * The "30" adjusts the dB in the 20 accumulated samples to units of 1.5 dB. - * For use in diff_gain_[abc] fields of struct iwl_calibration_cmd, the + * For use in diff_gain_[abc] fields of struct il_calibration_cmd, the * driver should limit the difference results to a range of 0-3 (0-4.5 dB), * and set bit 2 to indicate "reduce gain". The value for the reference * (weakest) chain should be "0". @@ -3306,24 +3306,24 @@ struct iwl_sensitivity_cmd { /* Phy calibration command for series */ /* The default calibrate table size if not specified by firmware */ -#define IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE 18 +#define IL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE 18 enum { - IWL_PHY_CALIBRATE_DIFF_GAIN_CMD = 7, - IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE = 19, + IL_PHY_CALIBRATE_DIFF_GAIN_CMD = 7, + IL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE = 19, }; -#define IWL_MAX_PHY_CALIBRATE_TBL_SIZE (253) +#define IL_MAX_PHY_CALIBRATE_TBL_SIZE (253) -struct iwl_calib_hdr { +struct il_calib_hdr { u8 op_code; u8 first_group; u8 groups_num; u8 data_valid; } __packed; -/* IWL_PHY_CALIBRATE_DIFF_GAIN_CMD (7) */ -struct iwl_calib_diff_gain_cmd { - struct iwl_calib_hdr hdr; +/* IL_PHY_CALIBRATE_DIFF_GAIN_CMD (7) */ +struct il_calib_diff_gain_cmd { + struct il_calib_hdr hdr; s8 diff_gain_a; /* see above */ s8 diff_gain_b; s8 diff_gain_c; @@ -3343,7 +3343,7 @@ struct iwl_calib_diff_gain_cmd { * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field), * this command turns it on or off, or sets up a periodic blinking cycle. */ -struct iwl_led_cmd { +struct il_led_cmd { __le32 interval; /* "interval" in uSec */ u8 id; /* 1: Activity, 2: Link, 3: Tech */ u8 off; /* # intervals off while blinking; @@ -3360,7 +3360,7 @@ struct iwl_led_cmd { * *****************************************************************************/ -struct iwl_rx_packet { +struct il_rx_packet { /* * The first 4 bytes of the RX frame header contain both the RX frame * size and some flags. @@ -3372,27 +3372,27 @@ struct iwl_rx_packet { * 13-00: RX frame size */ __le32 len_n_flags; - struct iwl_cmd_header hdr; + struct il_cmd_header hdr; union { - struct iwl3945_rx_frame rx_frame; - struct iwl3945_tx_resp tx_resp; - struct iwl3945_beacon_notif beacon_status; - - struct iwl_alive_resp alive_frame; - struct iwl_spectrum_notification spectrum_notif; - struct iwl_csa_notification csa_notif; - struct iwl_error_resp err_resp; - struct iwl_card_state_notif card_state_notif; - struct iwl_add_sta_resp add_sta; - struct iwl_rem_sta_resp rem_sta; - struct iwl_sleep_notification sleep_notif; - struct iwl_spectrum_resp spectrum; - struct iwl_notif_statistics stats; - struct iwl_compressed_ba_resp compressed_ba; - struct iwl_missed_beacon_notif missed_beacon; + struct il3945_rx_frame rx_frame; + struct il3945_tx_resp tx_resp; + struct il3945_beacon_notif beacon_status; + + struct il_alive_resp alive_frame; + struct il_spectrum_notification spectrum_notif; + struct il_csa_notification csa_notif; + struct il_error_resp err_resp; + struct il_card_state_notif card_state_notif; + struct il_add_sta_resp add_sta; + struct il_rem_sta_resp rem_sta; + struct il_sleep_notification sleep_notif; + struct il_spectrum_resp spectrum; + struct il_notif_statistics stats; + struct il_compressed_ba_resp compressed_ba; + struct il_missed_beacon_notif missed_beacon; __le32 status; u8 raw[0]; } u; } __packed; -#endif /* __iwl_legacy_commands_h__ */ +#endif /* __il_commands_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index 2bd5659310d7..7eae279e4c69 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -76,14 +76,14 @@ EXPORT_SYMBOL(iwlegacy_bcast_addr); /* This function both allocates and initializes hw and priv. */ -struct ieee80211_hw *iwl_legacy_alloc_all(struct iwl_cfg *cfg) +struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg) { - struct iwl_priv *priv; + struct il_priv *priv; /* mac80211 allocates memory for this device instance, including * space for this driver's private structure */ struct ieee80211_hw *hw; - hw = ieee80211_alloc_hw(sizeof(struct iwl_priv), + hw = ieee80211_alloc_hw(sizeof(struct il_priv), cfg->ops->ieee80211_ops); if (hw == NULL) { pr_err("%s: Can not allocate network device\n", @@ -97,11 +97,11 @@ struct ieee80211_hw *iwl_legacy_alloc_all(struct iwl_cfg *cfg) out: return hw; } -EXPORT_SYMBOL(iwl_legacy_alloc_all); +EXPORT_SYMBOL(il_alloc_all); #define MAX_BIT_RATE_40_MHZ 150 /* Mbps */ #define MAX_BIT_RATE_20_MHZ 72 /* Mbps */ -static void iwl_legacy_init_ht_hw_capab(const struct iwl_priv *priv, +static void il_init_ht_hw_capab(const struct il_priv *priv, struct ieee80211_sta_ht_cap *ht_info, enum ieee80211_band band) { @@ -150,11 +150,11 @@ static void iwl_legacy_init_ht_hw_capab(const struct iwl_priv *priv, } /** - * iwl_legacy_init_geos - Initialize mac80211's geo/channel info based from eeprom + * il_init_geos - Initialize mac80211's geo/channel info based from eeprom */ -int iwl_legacy_init_geos(struct iwl_priv *priv) +int il_init_geos(struct il_priv *priv) { - struct iwl_channel_info *ch; + struct il_channel_info *ch; struct ieee80211_supported_band *sband; struct ieee80211_channel *channels; struct ieee80211_channel *geo_ch; @@ -164,7 +164,7 @@ int iwl_legacy_init_geos(struct iwl_priv *priv) if (priv->bands[IEEE80211_BAND_2GHZ].n_bitrates || priv->bands[IEEE80211_BAND_5GHZ].n_bitrates) { - IWL_DEBUG_INFO(priv, "Geography modes already initialized.\n"); + IL_DEBUG_INFO(priv, "Geography modes already initialized.\n"); set_bit(STATUS_GEO_CONFIGURED, &priv->status); return 0; } @@ -174,7 +174,7 @@ int iwl_legacy_init_geos(struct iwl_priv *priv) if (!channels) return -ENOMEM; - rates = kzalloc((sizeof(struct ieee80211_rate) * IWL_RATE_COUNT_LEGACY), + rates = kzalloc((sizeof(struct ieee80211_rate) * IL_RATE_COUNT_LEGACY), GFP_KERNEL); if (!rates) { kfree(channels); @@ -185,21 +185,21 @@ int iwl_legacy_init_geos(struct iwl_priv *priv) sband = &priv->bands[IEEE80211_BAND_5GHZ]; sband->channels = &channels[ARRAY_SIZE(iwlegacy_eeprom_band_1)]; /* just OFDM */ - sband->bitrates = &rates[IWL_FIRST_OFDM_RATE]; - sband->n_bitrates = IWL_RATE_COUNT_LEGACY - IWL_FIRST_OFDM_RATE; + sband->bitrates = &rates[IL_FIRST_OFDM_RATE]; + sband->n_bitrates = IL_RATE_COUNT_LEGACY - IL_FIRST_OFDM_RATE; - if (priv->cfg->sku & IWL_SKU_N) - iwl_legacy_init_ht_hw_capab(priv, &sband->ht_cap, + if (priv->cfg->sku & IL_SKU_N) + il_init_ht_hw_capab(priv, &sband->ht_cap, IEEE80211_BAND_5GHZ); sband = &priv->bands[IEEE80211_BAND_2GHZ]; sband->channels = channels; /* OFDM & CCK */ sband->bitrates = rates; - sband->n_bitrates = IWL_RATE_COUNT_LEGACY; + sband->n_bitrates = IL_RATE_COUNT_LEGACY; - if (priv->cfg->sku & IWL_SKU_N) - iwl_legacy_init_ht_hw_capab(priv, &sband->ht_cap, + if (priv->cfg->sku & IL_SKU_N) + il_init_ht_hw_capab(priv, &sband->ht_cap, IEEE80211_BAND_2GHZ); priv->ieee_channels = channels; @@ -208,7 +208,7 @@ int iwl_legacy_init_geos(struct iwl_priv *priv) for (i = 0; i < priv->channel_count; i++) { ch = &priv->channel_info[i]; - if (!iwl_legacy_is_channel_valid(ch)) + if (!il_is_channel_valid(ch)) continue; sband = &priv->bands[ch->band]; @@ -221,7 +221,7 @@ int iwl_legacy_init_geos(struct iwl_priv *priv) geo_ch->max_antenna_gain = 0xff; geo_ch->hw_value = ch->channel; - if (iwl_legacy_is_channel_valid(ch)) { + if (il_is_channel_valid(ch)) { if (!(ch->flags & EEPROM_CHANNEL_IBSS)) geo_ch->flags |= IEEE80211_CHAN_NO_IBSS; @@ -239,9 +239,9 @@ int iwl_legacy_init_geos(struct iwl_priv *priv) geo_ch->flags |= IEEE80211_CHAN_DISABLED; } - IWL_DEBUG_INFO(priv, "Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", + IL_DEBUG_INFO(priv, "Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", ch->channel, geo_ch->center_freq, - iwl_legacy_is_channel_a_band(ch) ? "5.2" : "2.4", + il_is_channel_a_band(ch) ? "5.2" : "2.4", geo_ch->flags & IEEE80211_CHAN_DISABLED ? "restricted" : "valid", geo_ch->flags); @@ -252,15 +252,15 @@ int iwl_legacy_init_geos(struct iwl_priv *priv) priv->tx_power_next = max_tx_power; if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && - priv->cfg->sku & IWL_SKU_A) { - IWL_INFO(priv, "Incorrectly detected BG card as ABG. " + priv->cfg->sku & IL_SKU_A) { + IL_INFO(priv, "Incorrectly detected BG card as ABG. " "Please send your PCI ID 0x%04X:0x%04X to maintainer.\n", priv->pci_dev->device, priv->pci_dev->subsystem_device); - priv->cfg->sku &= ~IWL_SKU_A; + priv->cfg->sku &= ~IL_SKU_A; } - IWL_INFO(priv, "Tunable channels: %d 802.11bg, %d 802.11a channels\n", + IL_INFO(priv, "Tunable channels: %d 802.11bg, %d 802.11a channels\n", priv->bands[IEEE80211_BAND_2GHZ].n_channels, priv->bands[IEEE80211_BAND_5GHZ].n_channels); @@ -268,27 +268,27 @@ int iwl_legacy_init_geos(struct iwl_priv *priv) return 0; } -EXPORT_SYMBOL(iwl_legacy_init_geos); +EXPORT_SYMBOL(il_init_geos); /* - * iwl_legacy_free_geos - undo allocations in iwl_legacy_init_geos + * il_free_geos - undo allocations in il_init_geos */ -void iwl_legacy_free_geos(struct iwl_priv *priv) +void il_free_geos(struct il_priv *priv) { kfree(priv->ieee_channels); kfree(priv->ieee_rates); clear_bit(STATUS_GEO_CONFIGURED, &priv->status); } -EXPORT_SYMBOL(iwl_legacy_free_geos); +EXPORT_SYMBOL(il_free_geos); -static bool iwl_legacy_is_channel_extension(struct iwl_priv *priv, +static bool il_is_channel_extension(struct il_priv *priv, enum ieee80211_band band, u16 channel, u8 extension_chan_offset) { - const struct iwl_channel_info *ch_info; + const struct il_channel_info *ch_info; - ch_info = iwl_legacy_get_channel_info(priv, band, channel); - if (!iwl_legacy_is_channel_valid(ch_info)) + ch_info = il_get_channel_info(priv, band, channel); + if (!il_is_channel_valid(ch_info)) return false; if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_ABOVE) @@ -301,8 +301,8 @@ static bool iwl_legacy_is_channel_extension(struct iwl_priv *priv, return false; } -bool iwl_legacy_is_ht40_tx_allowed(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +bool il_is_ht40_tx_allowed(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_sta_ht_cap *ht_cap) { if (!ctx->ht.enabled || !ctx->ht.is_40mhz) @@ -320,13 +320,13 @@ bool iwl_legacy_is_ht40_tx_allowed(struct iwl_priv *priv, return false; #endif - return iwl_legacy_is_channel_extension(priv, priv->band, + return il_is_channel_extension(priv, priv->band, le16_to_cpu(ctx->staging.channel), ctx->ht.extension_chan_offset); } -EXPORT_SYMBOL(iwl_legacy_is_ht40_tx_allowed); +EXPORT_SYMBOL(il_is_ht40_tx_allowed); -static u16 iwl_legacy_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val) +static u16 il_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val) { u16 new_val; u16 beacon_factor; @@ -360,7 +360,7 @@ static u16 iwl_legacy_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val) } int -iwl_legacy_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx) +il_send_rxon_timing(struct il_priv *priv, struct il_rxon_context *ctx) { u64 tsf; s32 interval_tm, rem; @@ -368,11 +368,11 @@ iwl_legacy_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx) u16 beacon_int; struct ieee80211_vif *vif = ctx->vif; - conf = iwl_legacy_ieee80211_get_hw_conf(priv->hw); + conf = il_ieee80211_get_hw_conf(priv->hw); lockdep_assert_held(&priv->mutex); - memset(&ctx->timing, 0, sizeof(struct iwl_rxon_time_cmd)); + memset(&ctx->timing, 0, sizeof(struct il_rxon_time_cmd)); ctx->timing.timestamp = cpu_to_le64(priv->timestamp); ctx->timing.listen_interval = cpu_to_le16(conf->listen_interval); @@ -385,7 +385,7 @@ iwl_legacy_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx) */ ctx->timing.atim_window = 0; - beacon_int = iwl_legacy_adjust_beacon_interval(beacon_int, + beacon_int = il_adjust_beacon_interval(beacon_int, priv->hw_params.max_beacon_itrvl * TIME_UNIT); ctx->timing.beacon_interval = cpu_to_le16(beacon_int); @@ -396,23 +396,23 @@ iwl_legacy_send_rxon_timing(struct iwl_priv *priv, struct iwl_rxon_context *ctx) ctx->timing.dtim_period = vif ? (vif->bss_conf.dtim_period ?: 1) : 1; - IWL_DEBUG_ASSOC(priv, + IL_DEBUG_ASSOC(priv, "beacon interval %d beacon timer %d beacon tim %d\n", le16_to_cpu(ctx->timing.beacon_interval), le32_to_cpu(ctx->timing.beacon_init_val), le16_to_cpu(ctx->timing.atim_window)); - return iwl_legacy_send_cmd_pdu(priv, ctx->rxon_timing_cmd, + return il_send_cmd_pdu(priv, ctx->rxon_timing_cmd, sizeof(ctx->timing), &ctx->timing); } -EXPORT_SYMBOL(iwl_legacy_send_rxon_timing); +EXPORT_SYMBOL(il_send_rxon_timing); void -iwl_legacy_set_rxon_hwcrypto(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +il_set_rxon_hwcrypto(struct il_priv *priv, + struct il_rxon_context *ctx, int hw_decrypt) { - struct iwl_legacy_rxon_cmd *rxon = &ctx->staging; + struct il_rxon_cmd *rxon = &ctx->staging; if (hw_decrypt) rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK; @@ -420,112 +420,112 @@ iwl_legacy_set_rxon_hwcrypto(struct iwl_priv *priv, rxon->filter_flags |= RXON_FILTER_DIS_DECRYPT_MSK; } -EXPORT_SYMBOL(iwl_legacy_set_rxon_hwcrypto); +EXPORT_SYMBOL(il_set_rxon_hwcrypto); /* validate RXON structure is valid */ int -iwl_legacy_check_rxon_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx) +il_check_rxon_cmd(struct il_priv *priv, struct il_rxon_context *ctx) { - struct iwl_legacy_rxon_cmd *rxon = &ctx->staging; + struct il_rxon_cmd *rxon = &ctx->staging; bool error = false; if (rxon->flags & RXON_FLG_BAND_24G_MSK) { if (rxon->flags & RXON_FLG_TGJ_NARROW_BAND_MSK) { - IWL_WARN(priv, "check 2.4G: wrong narrow\n"); + IL_WARN(priv, "check 2.4G: wrong narrow\n"); error = true; } if (rxon->flags & RXON_FLG_RADAR_DETECT_MSK) { - IWL_WARN(priv, "check 2.4G: wrong radar\n"); + IL_WARN(priv, "check 2.4G: wrong radar\n"); error = true; } } else { if (!(rxon->flags & RXON_FLG_SHORT_SLOT_MSK)) { - IWL_WARN(priv, "check 5.2G: not short slot!\n"); + IL_WARN(priv, "check 5.2G: not short slot!\n"); error = true; } if (rxon->flags & RXON_FLG_CCK_MSK) { - IWL_WARN(priv, "check 5.2G: CCK!\n"); + IL_WARN(priv, "check 5.2G: CCK!\n"); error = true; } } if ((rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1) { - IWL_WARN(priv, "mac/bssid mcast!\n"); + IL_WARN(priv, "mac/bssid mcast!\n"); error = true; } /* make sure basic rates 6Mbps and 1Mbps are supported */ - if ((rxon->ofdm_basic_rates & IWL_RATE_6M_MASK) == 0 && - (rxon->cck_basic_rates & IWL_RATE_1M_MASK) == 0) { - IWL_WARN(priv, "neither 1 nor 6 are basic\n"); + if ((rxon->ofdm_basic_rates & IL_RATE_6M_MASK) == 0 && + (rxon->cck_basic_rates & IL_RATE_1M_MASK) == 0) { + IL_WARN(priv, "neither 1 nor 6 are basic\n"); error = true; } if (le16_to_cpu(rxon->assoc_id) > 2007) { - IWL_WARN(priv, "aid > 2007\n"); + IL_WARN(priv, "aid > 2007\n"); error = true; } if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) { - IWL_WARN(priv, "CCK and short slot\n"); + IL_WARN(priv, "CCK and short slot\n"); error = true; } if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) { - IWL_WARN(priv, "CCK and auto detect"); + IL_WARN(priv, "CCK and auto detect"); error = true; } if ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_TGG_PROTECT_MSK)) == RXON_FLG_TGG_PROTECT_MSK) { - IWL_WARN(priv, "TGg but no auto-detect\n"); + IL_WARN(priv, "TGg but no auto-detect\n"); error = true; } if (error) - IWL_WARN(priv, "Tuning to channel %d\n", + IL_WARN(priv, "Tuning to channel %d\n", le16_to_cpu(rxon->channel)); if (error) { - IWL_ERR(priv, "Invalid RXON\n"); + IL_ERR(priv, "Invalid RXON\n"); return -EINVAL; } return 0; } -EXPORT_SYMBOL(iwl_legacy_check_rxon_cmd); +EXPORT_SYMBOL(il_check_rxon_cmd); /** - * iwl_legacy_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed + * il_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed * @priv: staging_rxon is compared to active_rxon * * If the RXON structure is changing enough to require a new tune, * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required. */ -int iwl_legacy_full_rxon_required(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +int il_full_rxon_required(struct il_priv *priv, + struct il_rxon_context *ctx) { - const struct iwl_legacy_rxon_cmd *staging = &ctx->staging; - const struct iwl_legacy_rxon_cmd *active = &ctx->active; + const struct il_rxon_cmd *staging = &ctx->staging; + const struct il_rxon_cmd *active = &ctx->active; #define CHK(cond) \ if ((cond)) { \ - IWL_DEBUG_INFO(priv, "need full RXON - " #cond "\n"); \ + IL_DEBUG_INFO(priv, "need full RXON - " #cond "\n"); \ return 1; \ } #define CHK_NEQ(c1, c2) \ if ((c1) != (c2)) { \ - IWL_DEBUG_INFO(priv, "need full RXON - " \ + IL_DEBUG_INFO(priv, "need full RXON - " \ #c1 " != " #c2 " - %d != %d\n", \ (c1), (c2)); \ return 1; \ } /* These items are only settable from the full RXON command */ - CHK(!iwl_legacy_is_associated_ctx(ctx)); + CHK(!il_is_associated_ctx(ctx)); CHK(compare_ether_addr(staging->bssid_addr, active->bssid_addr)); CHK(compare_ether_addr(staging->node_addr, active->node_addr)); CHK(compare_ether_addr(staging->wlap_bssid_addr, @@ -556,27 +556,27 @@ int iwl_legacy_full_rxon_required(struct iwl_priv *priv, return 0; } -EXPORT_SYMBOL(iwl_legacy_full_rxon_required); +EXPORT_SYMBOL(il_full_rxon_required); -u8 iwl_legacy_get_lowest_plcp(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +u8 il_get_lowest_plcp(struct il_priv *priv, + struct il_rxon_context *ctx) { /* * Assign the lowest rate -- should really get this from * the beacon skb from mac80211. */ if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) - return IWL_RATE_1M_PLCP; + return IL_RATE_1M_PLCP; else - return IWL_RATE_6M_PLCP; + return IL_RATE_6M_PLCP; } -EXPORT_SYMBOL(iwl_legacy_get_lowest_plcp); +EXPORT_SYMBOL(il_get_lowest_plcp); -static void _iwl_legacy_set_rxon_ht(struct iwl_priv *priv, - struct iwl_ht_config *ht_conf, - struct iwl_rxon_context *ctx) +static void _il_set_rxon_ht(struct il_priv *priv, + struct il_ht_config *ht_conf, + struct il_rxon_context *ctx) { - struct iwl_legacy_rxon_cmd *rxon = &ctx->staging; + struct il_rxon_cmd *rxon = &ctx->staging; if (!ctx->ht.enabled) { rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | @@ -594,7 +594,7 @@ static void _iwl_legacy_set_rxon_ht(struct iwl_priv *priv, /* clear the HT channel mode before set the mode */ rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); - if (iwl_legacy_is_ht40_tx_allowed(priv, ctx, NULL)) { + if (il_is_ht40_tx_allowed(priv, ctx, NULL)) { /* pure ht40 */ if (ctx->ht.protection == IEEE80211_HT_OP_MODE_PROTECTION_20MHZ) { @@ -626,7 +626,7 @@ static void _iwl_legacy_set_rxon_ht(struct iwl_priv *priv, case IEEE80211_HT_PARAM_CHA_SEC_NONE: default: /* channel location only valid if in Mixed mode */ - IWL_ERR(priv, + IL_ERR(priv, "invalid extension channel offset\n"); break; } @@ -638,30 +638,30 @@ static void _iwl_legacy_set_rxon_ht(struct iwl_priv *priv, if (priv->cfg->ops->hcmd->set_rxon_chain) priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); - IWL_DEBUG_ASSOC(priv, "rxon flags 0x%X operation mode :0x%X " + IL_DEBUG_ASSOC(priv, "rxon flags 0x%X operation mode :0x%X " "extension channel offset 0x%x\n", le32_to_cpu(rxon->flags), ctx->ht.protection, ctx->ht.extension_chan_offset); } -void iwl_legacy_set_rxon_ht(struct iwl_priv *priv, struct iwl_ht_config *ht_conf) +void il_set_rxon_ht(struct il_priv *priv, struct il_ht_config *ht_conf) { - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; for_each_context(priv, ctx) - _iwl_legacy_set_rxon_ht(priv, ht_conf, ctx); + _il_set_rxon_ht(priv, ht_conf, ctx); } -EXPORT_SYMBOL(iwl_legacy_set_rxon_ht); +EXPORT_SYMBOL(il_set_rxon_ht); /* Return valid, unused, channel for a passive scan to reset the RF */ -u8 iwl_legacy_get_single_channel_number(struct iwl_priv *priv, +u8 il_get_single_channel_number(struct il_priv *priv, enum ieee80211_band band) { - const struct iwl_channel_info *ch_info; + const struct il_channel_info *ch_info; int i; u8 channel = 0; u8 min, max; - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; if (band == IEEE80211_BAND_5GHZ) { min = 14; @@ -685,25 +685,25 @@ u8 iwl_legacy_get_single_channel_number(struct iwl_priv *priv, continue; channel = priv->channel_info[i].channel; - ch_info = iwl_legacy_get_channel_info(priv, band, channel); - if (iwl_legacy_is_channel_valid(ch_info)) + ch_info = il_get_channel_info(priv, band, channel); + if (il_is_channel_valid(ch_info)) break; } return channel; } -EXPORT_SYMBOL(iwl_legacy_get_single_channel_number); +EXPORT_SYMBOL(il_get_single_channel_number); /** - * iwl_legacy_set_rxon_channel - Set the band and channel values in staging RXON + * il_set_rxon_channel - Set the band and channel values in staging RXON * @ch: requested channel as a pointer to struct ieee80211_channel * NOTE: Does not commit to the hardware; it sets appropriate bit fields * in the staging RXON flag structure based on the ch->band */ int -iwl_legacy_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch, - struct iwl_rxon_context *ctx) +il_set_rxon_channel(struct il_priv *priv, struct ieee80211_channel *ch, + struct il_rxon_context *ctx) { enum ieee80211_band band = ch->band; u16 channel = ch->hw_value; @@ -720,14 +720,14 @@ iwl_legacy_set_rxon_channel(struct iwl_priv *priv, struct ieee80211_channel *ch, priv->band = band; - IWL_DEBUG_INFO(priv, "Staging channel set to %d [%d]\n", channel, band); + IL_DEBUG_INFO(priv, "Staging channel set to %d [%d]\n", channel, band); return 0; } -EXPORT_SYMBOL(iwl_legacy_set_rxon_channel); +EXPORT_SYMBOL(il_set_rxon_channel); -void iwl_legacy_set_flags_for_band(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +void il_set_flags_for_band(struct il_priv *priv, + struct il_rxon_context *ctx, enum ieee80211_band band, struct ieee80211_vif *vif) { @@ -737,7 +737,7 @@ void iwl_legacy_set_flags_for_band(struct iwl_priv *priv, | RXON_FLG_CCK_MSK); ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; } else { - /* Copied from iwl_post_associate() */ + /* Copied from il_post_associate() */ if (vif && vif->bss_conf.use_short_slot) ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; else @@ -748,15 +748,15 @@ void iwl_legacy_set_flags_for_band(struct iwl_priv *priv, ctx->staging.flags &= ~RXON_FLG_CCK_MSK; } } -EXPORT_SYMBOL(iwl_legacy_set_flags_for_band); +EXPORT_SYMBOL(il_set_flags_for_band); /* * initialize rxon structure with default values from eeprom */ -void iwl_legacy_connection_init_rx_config(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +void il_connection_init_rx_config(struct il_priv *priv, + struct il_rxon_context *ctx) { - const struct iwl_channel_info *ch_info; + const struct il_channel_info *ch_info; memset(&ctx->staging, 0, sizeof(ctx->staging)); @@ -778,7 +778,7 @@ void iwl_legacy_connection_init_rx_config(struct iwl_priv *priv, break; default: - IWL_ERR(priv, "Unsupported interface type %d\n", + IL_ERR(priv, "Unsupported interface type %d\n", ctx->vif->type); break; } @@ -792,7 +792,7 @@ void iwl_legacy_connection_init_rx_config(struct iwl_priv *priv, ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; #endif - ch_info = iwl_legacy_get_channel_info(priv, priv->band, + ch_info = il_get_channel_info(priv, priv->band, le16_to_cpu(ctx->active.channel)); if (!ch_info) @@ -801,12 +801,12 @@ void iwl_legacy_connection_init_rx_config(struct iwl_priv *priv, ctx->staging.channel = cpu_to_le16(ch_info->channel); priv->band = ch_info->band; - iwl_legacy_set_flags_for_band(priv, ctx, priv->band, ctx->vif); + il_set_flags_for_band(priv, ctx, priv->band, ctx->vif); ctx->staging.ofdm_basic_rates = - (IWL_OFDM_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; + (IL_OFDM_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; ctx->staging.cck_basic_rates = - (IWL_CCK_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF; + (IL_CCK_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; /* clear both MIX and PURE40 mode flag */ ctx->staging.flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED | @@ -817,18 +817,18 @@ void iwl_legacy_connection_init_rx_config(struct iwl_priv *priv, ctx->staging.ofdm_ht_single_stream_basic_rates = 0xff; ctx->staging.ofdm_ht_dual_stream_basic_rates = 0xff; } -EXPORT_SYMBOL(iwl_legacy_connection_init_rx_config); +EXPORT_SYMBOL(il_connection_init_rx_config); -void iwl_legacy_set_rate(struct iwl_priv *priv) +void il_set_rate(struct il_priv *priv) { const struct ieee80211_supported_band *hw = NULL; struct ieee80211_rate *rate; - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; int i; - hw = iwl_get_hw_mode(priv, priv->band); + hw = il_get_hw_mode(priv, priv->band); if (!hw) { - IWL_ERR(priv, "Failed to set rate: unable to get hw mode\n"); + IL_ERR(priv, "Failed to set rate: unable to get hw mode\n"); return; } @@ -836,25 +836,25 @@ void iwl_legacy_set_rate(struct iwl_priv *priv) for (i = 0; i < hw->n_bitrates; i++) { rate = &(hw->bitrates[i]); - if (rate->hw_value < IWL_RATE_COUNT_LEGACY) + if (rate->hw_value < IL_RATE_COUNT_LEGACY) priv->active_rate |= (1 << rate->hw_value); } - IWL_DEBUG_RATE(priv, "Set active_rate = %0x\n", priv->active_rate); + IL_DEBUG_RATE(priv, "Set active_rate = %0x\n", priv->active_rate); for_each_context(priv, ctx) { ctx->staging.cck_basic_rates = - (IWL_CCK_BASIC_RATES_MASK >> IWL_FIRST_CCK_RATE) & 0xF; + (IL_CCK_BASIC_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; ctx->staging.ofdm_basic_rates = - (IWL_OFDM_BASIC_RATES_MASK >> IWL_FIRST_OFDM_RATE) & 0xFF; + (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; } } -EXPORT_SYMBOL(iwl_legacy_set_rate); +EXPORT_SYMBOL(il_set_rate); -void iwl_legacy_chswitch_done(struct iwl_priv *priv, bool is_success) +void il_chswitch_done(struct il_priv *priv, bool is_success) { - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; @@ -862,15 +862,15 @@ void iwl_legacy_chswitch_done(struct iwl_priv *priv, bool is_success) if (test_and_clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status)) ieee80211_chswitch_done(ctx->vif, is_success); } -EXPORT_SYMBOL(iwl_legacy_chswitch_done); +EXPORT_SYMBOL(il_chswitch_done); -void iwl_legacy_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) +void il_rx_csa(struct il_priv *priv, struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_csa_notification *csa = &(pkt->u.csa_notif); + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_csa_notification *csa = &(pkt->u.csa_notif); - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; - struct iwl_legacy_rxon_cmd *rxon = (void *)&ctx->active; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_cmd *rxon = (void *)&ctx->active; if (!test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status)) return; @@ -878,63 +878,63 @@ void iwl_legacy_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) if (!le32_to_cpu(csa->status) && csa->channel == priv->switch_channel) { rxon->channel = csa->channel; ctx->staging.channel = csa->channel; - IWL_DEBUG_11H(priv, "CSA notif: channel %d\n", + IL_DEBUG_11H(priv, "CSA notif: channel %d\n", le16_to_cpu(csa->channel)); - iwl_legacy_chswitch_done(priv, true); + il_chswitch_done(priv, true); } else { - IWL_ERR(priv, "CSA notif (fail) : channel %d\n", + IL_ERR(priv, "CSA notif (fail) : channel %d\n", le16_to_cpu(csa->channel)); - iwl_legacy_chswitch_done(priv, false); + il_chswitch_done(priv, false); } } -EXPORT_SYMBOL(iwl_legacy_rx_csa); +EXPORT_SYMBOL(il_rx_csa); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -void iwl_legacy_print_rx_config_cmd(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +void il_print_rx_config_cmd(struct il_priv *priv, + struct il_rxon_context *ctx) { - struct iwl_legacy_rxon_cmd *rxon = &ctx->staging; + struct il_rxon_cmd *rxon = &ctx->staging; - IWL_DEBUG_RADIO(priv, "RX CONFIG:\n"); - iwl_print_hex_dump(priv, IWL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); - IWL_DEBUG_RADIO(priv, "u16 channel: 0x%x\n", + IL_DEBUG_RADIO(priv, "RX CONFIG:\n"); + il_print_hex_dump(priv, IL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); + IL_DEBUG_RADIO(priv, "u16 channel: 0x%x\n", le16_to_cpu(rxon->channel)); - IWL_DEBUG_RADIO(priv, "u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags)); - IWL_DEBUG_RADIO(priv, "u32 filter_flags: 0x%08x\n", + IL_DEBUG_RADIO(priv, "u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags)); + IL_DEBUG_RADIO(priv, "u32 filter_flags: 0x%08x\n", le32_to_cpu(rxon->filter_flags)); - IWL_DEBUG_RADIO(priv, "u8 dev_type: 0x%x\n", rxon->dev_type); - IWL_DEBUG_RADIO(priv, "u8 ofdm_basic_rates: 0x%02x\n", + IL_DEBUG_RADIO(priv, "u8 dev_type: 0x%x\n", rxon->dev_type); + IL_DEBUG_RADIO(priv, "u8 ofdm_basic_rates: 0x%02x\n", rxon->ofdm_basic_rates); - IWL_DEBUG_RADIO(priv, "u8 cck_basic_rates: 0x%02x\n", + IL_DEBUG_RADIO(priv, "u8 cck_basic_rates: 0x%02x\n", rxon->cck_basic_rates); - IWL_DEBUG_RADIO(priv, "u8[6] node_addr: %pM\n", rxon->node_addr); - IWL_DEBUG_RADIO(priv, "u8[6] bssid_addr: %pM\n", rxon->bssid_addr); - IWL_DEBUG_RADIO(priv, "u16 assoc_id: 0x%x\n", + IL_DEBUG_RADIO(priv, "u8[6] node_addr: %pM\n", rxon->node_addr); + IL_DEBUG_RADIO(priv, "u8[6] bssid_addr: %pM\n", rxon->bssid_addr); + IL_DEBUG_RADIO(priv, "u16 assoc_id: 0x%x\n", le16_to_cpu(rxon->assoc_id)); } -EXPORT_SYMBOL(iwl_legacy_print_rx_config_cmd); +EXPORT_SYMBOL(il_print_rx_config_cmd); #endif /** - * iwl_legacy_irq_handle_error - called for HW or SW error interrupt from card + * il_irq_handle_error - called for HW or SW error interrupt from card */ -void iwl_legacy_irq_handle_error(struct iwl_priv *priv) +void il_irq_handle_error(struct il_priv *priv) { - /* Set the FW error flag -- cleared on iwl_down */ + /* Set the FW error flag -- cleared on il_down */ set_bit(STATUS_FW_ERROR, &priv->status); /* Cancel currently queued command. */ clear_bit(STATUS_HCMD_ACTIVE, &priv->status); - IWL_ERR(priv, "Loaded firmware version: %s\n", + IL_ERR(priv, "Loaded firmware version: %s\n", priv->hw->wiphy->fw_version); priv->cfg->ops->lib->dump_nic_error_log(priv); if (priv->cfg->ops->lib->dump_fh) priv->cfg->ops->lib->dump_fh(priv, NULL, false); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (iwl_legacy_get_debug_level(priv) & IWL_DL_FW_ERRORS) - iwl_legacy_print_rx_config_cmd(priv, - &priv->contexts[IWL_RXON_CTX_BSS]); + if (il_get_debug_level(priv) & IL_DL_FW_ERRORS) + il_print_rx_config_cmd(priv, + &priv->contexts[IL_RXON_CTX_BSS]); #endif wake_up(&priv->wait_command_queue); @@ -944,41 +944,41 @@ void iwl_legacy_irq_handle_error(struct iwl_priv *priv) clear_bit(STATUS_READY, &priv->status); if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) { - IWL_DEBUG(priv, IWL_DL_FW_ERRORS, + IL_DEBUG(priv, IL_DL_FW_ERRORS, "Restarting adapter due to uCode error.\n"); if (priv->cfg->mod_params->restart_fw) queue_work(priv->workqueue, &priv->restart); } } -EXPORT_SYMBOL(iwl_legacy_irq_handle_error); +EXPORT_SYMBOL(il_irq_handle_error); -static int iwl_legacy_apm_stop_master(struct iwl_priv *priv) +static int il_apm_stop_master(struct il_priv *priv) { int ret = 0; /* stop device's busmaster DMA activity */ - iwl_legacy_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); + il_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); - ret = iwl_poll_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, + ret = il_poll_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); if (ret) - IWL_WARN(priv, "Master Disable Timed Out, 100 usec\n"); + IL_WARN(priv, "Master Disable Timed Out, 100 usec\n"); - IWL_DEBUG_INFO(priv, "stop master\n"); + IL_DEBUG_INFO(priv, "stop master\n"); return ret; } -void iwl_legacy_apm_stop(struct iwl_priv *priv) +void il_apm_stop(struct il_priv *priv) { - IWL_DEBUG_INFO(priv, "Stop card, put in low power state\n"); + IL_DEBUG_INFO(priv, "Stop card, put in low power state\n"); /* Stop device's DMA activity */ - iwl_legacy_apm_stop_master(priv); + il_apm_stop_master(priv); /* Reset the entire device */ - iwl_legacy_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); + il_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); udelay(10); @@ -986,23 +986,23 @@ void iwl_legacy_apm_stop(struct iwl_priv *priv) * Clear "initialization complete" bit to move adapter from * D0A* (powered-up Active) --> D0U* (Uninitialized) state. */ - iwl_legacy_clear_bit(priv, CSR_GP_CNTRL, + il_clear_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); } -EXPORT_SYMBOL(iwl_legacy_apm_stop); +EXPORT_SYMBOL(il_apm_stop); /* * Start up NIC's basic functionality after it has been reset - * (e.g. after platform boot, or shutdown via iwl_legacy_apm_stop()) + * (e.g. after platform boot, or shutdown via il_apm_stop()) * NOTE: This does not load uCode nor start the embedded processor */ -int iwl_legacy_apm_init(struct iwl_priv *priv) +int il_apm_init(struct il_priv *priv) { int ret = 0; u16 lctl; - IWL_DEBUG_INFO(priv, "Init card's basic functions\n"); + IL_DEBUG_INFO(priv, "Init card's basic functions\n"); /* * Use "set_bit" below rather than "write", to preserve any hardware @@ -1010,18 +1010,18 @@ int iwl_legacy_apm_init(struct iwl_priv *priv) */ /* Disable L0S exit timer (platform NMI Work/Around) */ - iwl_legacy_set_bit(priv, CSR_GIO_CHICKEN_BITS, + il_set_bit(priv, CSR_GIO_CHICKEN_BITS, CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); /* * Disable L0s without affecting L1; * don't wait for ICH L0s (ICH bug W/A) */ - iwl_legacy_set_bit(priv, CSR_GIO_CHICKEN_BITS, + il_set_bit(priv, CSR_GIO_CHICKEN_BITS, CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX); /* Set FH wait threshold to maximum (HW error during stress W/A) */ - iwl_legacy_set_bit(priv, CSR_DBG_HPET_MEM_REG, + il_set_bit(priv, CSR_DBG_HPET_MEM_REG, CSR_DBG_HPET_MEM_REG_VAL); /* @@ -1029,7 +1029,7 @@ int iwl_legacy_apm_init(struct iwl_priv *priv) * wake device's PCI Express link L1a -> L0s * NOTE: This is no-op for 3945 (non-existent bit) */ - iwl_legacy_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(priv, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); /* @@ -1041,42 +1041,42 @@ int iwl_legacy_apm_init(struct iwl_priv *priv) * power savings, even without L1. */ if (priv->cfg->base_params->set_l0s) { - lctl = iwl_legacy_pcie_link_ctl(priv); + lctl = il_pcie_link_ctl(priv); if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) == PCI_CFG_LINK_CTRL_VAL_L1_EN) { /* L1-ASPM enabled; disable(!) L0S */ - iwl_legacy_set_bit(priv, CSR_GIO_REG, + il_set_bit(priv, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); - IWL_DEBUG_POWER(priv, "L1 Enabled; Disabling L0S\n"); + IL_DEBUG_POWER(priv, "L1 Enabled; Disabling L0S\n"); } else { /* L1-ASPM disabled; enable(!) L0S */ - iwl_legacy_clear_bit(priv, CSR_GIO_REG, + il_clear_bit(priv, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); - IWL_DEBUG_POWER(priv, "L1 Disabled; Enabling L0S\n"); + IL_DEBUG_POWER(priv, "L1 Disabled; Enabling L0S\n"); } } /* Configure analog phase-lock-loop before activating to D0A */ if (priv->cfg->base_params->pll_cfg_val) - iwl_legacy_set_bit(priv, CSR_ANA_PLL_CFG, + il_set_bit(priv, CSR_ANA_PLL_CFG, priv->cfg->base_params->pll_cfg_val); /* * Set "initialization complete" bit to move adapter from * D0U* --> D0A* (powered-up active) state. */ - iwl_legacy_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); + il_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); /* * Wait for clock stabilization; once stabilized, access to - * device-internal resources is supported, e.g. iwl_legacy_write_prph() + * device-internal resources is supported, e.g. il_write_prph() * and accesses to uCode SRAM. */ - ret = iwl_poll_bit(priv, CSR_GP_CNTRL, + ret = il_poll_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); if (ret < 0) { - IWL_DEBUG_INFO(priv, "Failed to init the card\n"); + IL_DEBUG_INFO(priv, "Failed to init the card\n"); goto out; } @@ -1089,29 +1089,29 @@ int iwl_legacy_apm_init(struct iwl_priv *priv) * set by default in "CLK_CTRL_REG" after reset. */ if (priv->cfg->base_params->use_bsm) - iwl_legacy_write_prph(priv, APMG_CLK_EN_REG, + il_write_prph(priv, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT | APMG_CLK_VAL_BSM_CLK_RQT); else - iwl_legacy_write_prph(priv, APMG_CLK_EN_REG, + il_write_prph(priv, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT); udelay(20); /* Disable L1-Active */ - iwl_legacy_set_bits_prph(priv, APMG_PCIDEV_STT_REG, + il_set_bits_prph(priv, APMG_PCIDEV_STT_REG, APMG_PCIDEV_STT_VAL_L1_ACT_DIS); out: return ret; } -EXPORT_SYMBOL(iwl_legacy_apm_init); +EXPORT_SYMBOL(il_apm_init); -int iwl_legacy_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force) +int il_set_tx_power(struct il_priv *priv, s8 tx_power, bool force) { int ret; s8 prev_tx_power; bool defer; - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; lockdep_assert_held(&priv->mutex); @@ -1123,20 +1123,20 @@ int iwl_legacy_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force) /* 0 dBm mean 1 milliwatt */ if (tx_power < 0) { - IWL_WARN(priv, + IL_WARN(priv, "Requested user TXPOWER %d below 1 mW.\n", tx_power); return -EINVAL; } if (tx_power > priv->tx_power_device_lmt) { - IWL_WARN(priv, + IL_WARN(priv, "Requested user TXPOWER %d above upper limit %d.\n", tx_power, priv->tx_power_device_lmt); return -EINVAL; } - if (!iwl_legacy_is_ready_rf(priv)) + if (!il_is_ready_rf(priv)) return -EIO; /* scan complete and commit_rxon use tx_power_next value, @@ -1147,7 +1147,7 @@ int iwl_legacy_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force) defer = test_bit(STATUS_SCANNING, &priv->status) || memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging)); if (defer && !force) { - IWL_DEBUG_INFO(priv, "Deferring tx power set\n"); + IL_DEBUG_INFO(priv, "Deferring tx power set\n"); return 0; } @@ -1163,11 +1163,11 @@ int iwl_legacy_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force) } return ret; } -EXPORT_SYMBOL(iwl_legacy_set_tx_power); +EXPORT_SYMBOL(il_set_tx_power); -void iwl_legacy_send_bt_config(struct iwl_priv *priv) +void il_send_bt_config(struct il_priv *priv) { - struct iwl_bt_cmd bt_cmd = { + struct il_bt_cmd bt_cmd = { .lead_time = BT_LEAD_TIME_DEF, .max_kill = BT_MAX_KILL_DEF, .kill_ack_mask = 0, @@ -1179,95 +1179,95 @@ void iwl_legacy_send_bt_config(struct iwl_priv *priv) else bt_cmd.flags = BT_COEX_ENABLE; - IWL_DEBUG_INFO(priv, "BT coex %s\n", + IL_DEBUG_INFO(priv, "BT coex %s\n", (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active"); - if (iwl_legacy_send_cmd_pdu(priv, REPLY_BT_CONFIG, - sizeof(struct iwl_bt_cmd), &bt_cmd)) - IWL_ERR(priv, "failed to send BT Coex Config\n"); + if (il_send_cmd_pdu(priv, REPLY_BT_CONFIG, + sizeof(struct il_bt_cmd), &bt_cmd)) + IL_ERR(priv, "failed to send BT Coex Config\n"); } -EXPORT_SYMBOL(iwl_legacy_send_bt_config); +EXPORT_SYMBOL(il_send_bt_config); -int iwl_legacy_send_statistics_request(struct iwl_priv *priv, u8 flags, bool clear) +int il_send_statistics_request(struct il_priv *priv, u8 flags, bool clear) { - struct iwl_statistics_cmd statistics_cmd = { + struct il_statistics_cmd statistics_cmd = { .configuration_flags = - clear ? IWL_STATS_CONF_CLEAR_STATS : 0, + clear ? IL_STATS_CONF_CLEAR_STATS : 0, }; if (flags & CMD_ASYNC) - return iwl_legacy_send_cmd_pdu_async(priv, REPLY_STATISTICS_CMD, - sizeof(struct iwl_statistics_cmd), + return il_send_cmd_pdu_async(priv, REPLY_STATISTICS_CMD, + sizeof(struct il_statistics_cmd), &statistics_cmd, NULL); else - return iwl_legacy_send_cmd_pdu(priv, REPLY_STATISTICS_CMD, - sizeof(struct iwl_statistics_cmd), + return il_send_cmd_pdu(priv, REPLY_STATISTICS_CMD, + sizeof(struct il_statistics_cmd), &statistics_cmd); } -EXPORT_SYMBOL(iwl_legacy_send_statistics_request); +EXPORT_SYMBOL(il_send_statistics_request); -void iwl_legacy_rx_pm_sleep_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +void il_rx_pm_sleep_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_sleep_notification *sleep = &(pkt->u.sleep_notif); - IWL_DEBUG_RX(priv, "sleep mode: %d, src: %d\n", + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_sleep_notification *sleep = &(pkt->u.sleep_notif); + IL_DEBUG_RX(priv, "sleep mode: %d, src: %d\n", sleep->pm_sleep_mode, sleep->pm_wakeup_src); #endif } -EXPORT_SYMBOL(iwl_legacy_rx_pm_sleep_notif); +EXPORT_SYMBOL(il_rx_pm_sleep_notif); -void iwl_legacy_rx_pm_debug_statistics_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +void il_rx_pm_debug_statistics_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; - IWL_DEBUG_RADIO(priv, "Dumping %d bytes of unhandled " + IL_DEBUG_RADIO(priv, "Dumping %d bytes of unhandled " "notification for %s:\n", len, - iwl_legacy_get_cmd_string(pkt->hdr.cmd)); - iwl_print_hex_dump(priv, IWL_DL_RADIO, pkt->u.raw, len); + il_get_cmd_string(pkt->hdr.cmd)); + il_print_hex_dump(priv, IL_DL_RADIO, pkt->u.raw, len); } -EXPORT_SYMBOL(iwl_legacy_rx_pm_debug_statistics_notif); +EXPORT_SYMBOL(il_rx_pm_debug_statistics_notif); -void iwl_legacy_rx_reply_error(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +void il_rx_reply_error(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); - IWL_ERR(priv, "Error Reply type 0x%08X cmd %s (0x%02X) " + IL_ERR(priv, "Error Reply type 0x%08X cmd %s (0x%02X) " "seq 0x%04X ser 0x%08X\n", le32_to_cpu(pkt->u.err_resp.error_type), - iwl_legacy_get_cmd_string(pkt->u.err_resp.cmd_id), + il_get_cmd_string(pkt->u.err_resp.cmd_id), pkt->u.err_resp.cmd_id, le16_to_cpu(pkt->u.err_resp.bad_cmd_seq_num), le32_to_cpu(pkt->u.err_resp.error_info)); } -EXPORT_SYMBOL(iwl_legacy_rx_reply_error); +EXPORT_SYMBOL(il_rx_reply_error); -void iwl_legacy_clear_isr_stats(struct iwl_priv *priv) +void il_clear_isr_stats(struct il_priv *priv) { memset(&priv->isr_stats, 0, sizeof(priv->isr_stats)); } -int iwl_legacy_mac_conf_tx(struct ieee80211_hw *hw, +int il_mac_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue, const struct ieee80211_tx_queue_params *params) { - struct iwl_priv *priv = hw->priv; - struct iwl_rxon_context *ctx; + struct il_priv *priv = hw->priv; + struct il_rxon_context *ctx; unsigned long flags; int q; - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); - if (!iwl_legacy_is_ready_rf(priv)) { - IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n"); + if (!il_is_ready_rf(priv)) { + IL_DEBUG_MAC80211(priv, "leave - RF not ready\n"); return -EIO; } if (queue >= AC_NUM) { - IWL_DEBUG_MAC80211(priv, "leave - queue >= AC_NUM %d\n", queue); + IL_DEBUG_MAC80211(priv, "leave - queue >= AC_NUM %d\n", queue); return 0; } @@ -1289,32 +1289,32 @@ int iwl_legacy_mac_conf_tx(struct ieee80211_hw *hw, spin_unlock_irqrestore(&priv->lock, flags); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); return 0; } -EXPORT_SYMBOL(iwl_legacy_mac_conf_tx); +EXPORT_SYMBOL(il_mac_conf_tx); -int iwl_legacy_mac_tx_last_beacon(struct ieee80211_hw *hw) +int il_mac_tx_last_beacon(struct ieee80211_hw *hw) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; - return priv->ibss_manager == IWL_IBSS_MANAGER; + return priv->ibss_manager == IL_IBSS_MANAGER; } -EXPORT_SYMBOL_GPL(iwl_legacy_mac_tx_last_beacon); +EXPORT_SYMBOL_GPL(il_mac_tx_last_beacon); static int -iwl_legacy_set_mode(struct iwl_priv *priv, struct iwl_rxon_context *ctx) +il_set_mode(struct il_priv *priv, struct il_rxon_context *ctx) { - iwl_legacy_connection_init_rx_config(priv, ctx); + il_connection_init_rx_config(priv, ctx); if (priv->cfg->ops->hcmd->set_rxon_chain) priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); - return iwl_legacy_commit_rxon(priv, ctx); + return il_commit_rxon(priv, ctx); } -static int iwl_legacy_setup_interface(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +static int il_setup_interface(struct il_priv *priv, + struct il_rxon_context *ctx) { struct ieee80211_vif *vif = ctx->vif; int err; @@ -1330,7 +1330,7 @@ static int iwl_legacy_setup_interface(struct iwl_priv *priv, ctx->is_active = true; - err = iwl_legacy_set_mode(priv, ctx); + err = il_set_mode(priv, ctx); if (err) { if (!ctx->always_active) ctx->is_active = false; @@ -1341,20 +1341,20 @@ static int iwl_legacy_setup_interface(struct iwl_priv *priv, } int -iwl_legacy_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) +il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { - struct iwl_priv *priv = hw->priv; - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; - struct iwl_rxon_context *tmp, *ctx = NULL; + struct il_priv *priv = hw->priv; + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; + struct il_rxon_context *tmp, *ctx = NULL; int err; - IWL_DEBUG_MAC80211(priv, "enter: type %d, addr %pM\n", + IL_DEBUG_MAC80211(priv, "enter: type %d, addr %pM\n", vif->type, vif->addr); mutex_lock(&priv->mutex); - if (!iwl_legacy_is_ready_rf(priv)) { - IWL_WARN(priv, "Try to add interface when device not ready\n"); + if (!il_is_ready_rf(priv)) { + IL_WARN(priv, "Try to add interface when device not ready\n"); err = -EINVAL; goto out; } @@ -1389,7 +1389,7 @@ iwl_legacy_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) vif_priv->ctx = ctx; ctx->vif = vif; - err = iwl_legacy_setup_interface(priv, ctx); + err = il_setup_interface(priv, ctx); if (!err) goto out; @@ -1398,95 +1398,95 @@ iwl_legacy_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) out: mutex_unlock(&priv->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); return err; } -EXPORT_SYMBOL(iwl_legacy_mac_add_interface); +EXPORT_SYMBOL(il_mac_add_interface); -static void iwl_legacy_teardown_interface(struct iwl_priv *priv, +static void il_teardown_interface(struct il_priv *priv, struct ieee80211_vif *vif, bool mode_change) { - struct iwl_rxon_context *ctx = iwl_legacy_rxon_ctx_from_vif(vif); + struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); lockdep_assert_held(&priv->mutex); if (priv->scan_vif == vif) { - iwl_legacy_scan_cancel_timeout(priv, 200); - iwl_legacy_force_scan_end(priv); + il_scan_cancel_timeout(priv, 200); + il_force_scan_end(priv); } if (!mode_change) { - iwl_legacy_set_mode(priv, ctx); + il_set_mode(priv, ctx); if (!ctx->always_active) ctx->is_active = false; } } -void iwl_legacy_mac_remove_interface(struct ieee80211_hw *hw, +void il_mac_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { - struct iwl_priv *priv = hw->priv; - struct iwl_rxon_context *ctx = iwl_legacy_rxon_ctx_from_vif(vif); + struct il_priv *priv = hw->priv; + struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); mutex_lock(&priv->mutex); WARN_ON(ctx->vif != vif); ctx->vif = NULL; - iwl_legacy_teardown_interface(priv, vif, false); + il_teardown_interface(priv, vif, false); memset(priv->bssid, 0, ETH_ALEN); mutex_unlock(&priv->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); } -EXPORT_SYMBOL(iwl_legacy_mac_remove_interface); +EXPORT_SYMBOL(il_mac_remove_interface); -int iwl_legacy_alloc_txq_mem(struct iwl_priv *priv) +int il_alloc_txq_mem(struct il_priv *priv) { if (!priv->txq) priv->txq = kzalloc( - sizeof(struct iwl_tx_queue) * + sizeof(struct il_tx_queue) * priv->cfg->base_params->num_of_queues, GFP_KERNEL); if (!priv->txq) { - IWL_ERR(priv, "Not enough memory for txq\n"); + IL_ERR(priv, "Not enough memory for txq\n"); return -ENOMEM; } return 0; } -EXPORT_SYMBOL(iwl_legacy_alloc_txq_mem); +EXPORT_SYMBOL(il_alloc_txq_mem); -void iwl_legacy_txq_mem(struct iwl_priv *priv) +void il_txq_mem(struct il_priv *priv) { kfree(priv->txq); priv->txq = NULL; } -EXPORT_SYMBOL(iwl_legacy_txq_mem); +EXPORT_SYMBOL(il_txq_mem); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS -#define IWL_TRAFFIC_DUMP_SIZE (IWL_TRAFFIC_ENTRY_SIZE * IWL_TRAFFIC_ENTRIES) +#define IL_TRAFFIC_DUMP_SIZE (IL_TRAFFIC_ENTRY_SIZE * IL_TRAFFIC_ENTRIES) -void iwl_legacy_reset_traffic_log(struct iwl_priv *priv) +void il_reset_traffic_log(struct il_priv *priv) { priv->tx_traffic_idx = 0; priv->rx_traffic_idx = 0; if (priv->tx_traffic) - memset(priv->tx_traffic, 0, IWL_TRAFFIC_DUMP_SIZE); + memset(priv->tx_traffic, 0, IL_TRAFFIC_DUMP_SIZE); if (priv->rx_traffic) - memset(priv->rx_traffic, 0, IWL_TRAFFIC_DUMP_SIZE); + memset(priv->rx_traffic, 0, IL_TRAFFIC_DUMP_SIZE); } -int iwl_legacy_alloc_traffic_mem(struct iwl_priv *priv) +int il_alloc_traffic_mem(struct il_priv *priv) { - u32 traffic_size = IWL_TRAFFIC_DUMP_SIZE; + u32 traffic_size = IL_TRAFFIC_DUMP_SIZE; - if (iwlegacy_debug_level & IWL_DL_TX) { + if (iwlegacy_debug_level & IL_DL_TX) { if (!priv->tx_traffic) { priv->tx_traffic = kzalloc(traffic_size, GFP_KERNEL); @@ -1494,7 +1494,7 @@ int iwl_legacy_alloc_traffic_mem(struct iwl_priv *priv) return -ENOMEM; } } - if (iwlegacy_debug_level & IWL_DL_RX) { + if (iwlegacy_debug_level & IL_DL_RX) { if (!priv->rx_traffic) { priv->rx_traffic = kzalloc(traffic_size, GFP_KERNEL); @@ -1502,12 +1502,12 @@ int iwl_legacy_alloc_traffic_mem(struct iwl_priv *priv) return -ENOMEM; } } - iwl_legacy_reset_traffic_log(priv); + il_reset_traffic_log(priv); return 0; } -EXPORT_SYMBOL(iwl_legacy_alloc_traffic_mem); +EXPORT_SYMBOL(il_alloc_traffic_mem); -void iwl_legacy_free_traffic_mem(struct iwl_priv *priv) +void il_free_traffic_mem(struct il_priv *priv) { kfree(priv->tx_traffic); priv->tx_traffic = NULL; @@ -1515,15 +1515,15 @@ void iwl_legacy_free_traffic_mem(struct iwl_priv *priv) kfree(priv->rx_traffic); priv->rx_traffic = NULL; } -EXPORT_SYMBOL(iwl_legacy_free_traffic_mem); +EXPORT_SYMBOL(il_free_traffic_mem); -void iwl_legacy_dbg_log_tx_data_frame(struct iwl_priv *priv, +void il_dbg_log_tx_data_frame(struct il_priv *priv, u16 length, struct ieee80211_hdr *header) { __le16 fc; u16 len; - if (likely(!(iwlegacy_debug_level & IWL_DL_TX))) + if (likely(!(iwlegacy_debug_level & IL_DL_TX))) return; if (!priv->tx_traffic) @@ -1531,24 +1531,24 @@ void iwl_legacy_dbg_log_tx_data_frame(struct iwl_priv *priv, fc = header->frame_control; if (ieee80211_is_data(fc)) { - len = (length > IWL_TRAFFIC_ENTRY_SIZE) - ? IWL_TRAFFIC_ENTRY_SIZE : length; + len = (length > IL_TRAFFIC_ENTRY_SIZE) + ? IL_TRAFFIC_ENTRY_SIZE : length; memcpy((priv->tx_traffic + - (priv->tx_traffic_idx * IWL_TRAFFIC_ENTRY_SIZE)), + (priv->tx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), header, len); priv->tx_traffic_idx = - (priv->tx_traffic_idx + 1) % IWL_TRAFFIC_ENTRIES; + (priv->tx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; } } -EXPORT_SYMBOL(iwl_legacy_dbg_log_tx_data_frame); +EXPORT_SYMBOL(il_dbg_log_tx_data_frame); -void iwl_legacy_dbg_log_rx_data_frame(struct iwl_priv *priv, +void il_dbg_log_rx_data_frame(struct il_priv *priv, u16 length, struct ieee80211_hdr *header) { __le16 fc; u16 len; - if (likely(!(iwlegacy_debug_level & IWL_DL_RX))) + if (likely(!(iwlegacy_debug_level & IL_DL_RX))) return; if (!priv->rx_traffic) @@ -1556,56 +1556,56 @@ void iwl_legacy_dbg_log_rx_data_frame(struct iwl_priv *priv, fc = header->frame_control; if (ieee80211_is_data(fc)) { - len = (length > IWL_TRAFFIC_ENTRY_SIZE) - ? IWL_TRAFFIC_ENTRY_SIZE : length; + len = (length > IL_TRAFFIC_ENTRY_SIZE) + ? IL_TRAFFIC_ENTRY_SIZE : length; memcpy((priv->rx_traffic + - (priv->rx_traffic_idx * IWL_TRAFFIC_ENTRY_SIZE)), + (priv->rx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), header, len); priv->rx_traffic_idx = - (priv->rx_traffic_idx + 1) % IWL_TRAFFIC_ENTRIES; + (priv->rx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; } } -EXPORT_SYMBOL(iwl_legacy_dbg_log_rx_data_frame); +EXPORT_SYMBOL(il_dbg_log_rx_data_frame); -const char *iwl_legacy_get_mgmt_string(int cmd) +const char *il_get_mgmt_string(int cmd) { switch (cmd) { - IWL_CMD(MANAGEMENT_ASSOC_REQ); - IWL_CMD(MANAGEMENT_ASSOC_RESP); - IWL_CMD(MANAGEMENT_REASSOC_REQ); - IWL_CMD(MANAGEMENT_REASSOC_RESP); - IWL_CMD(MANAGEMENT_PROBE_REQ); - IWL_CMD(MANAGEMENT_PROBE_RESP); - IWL_CMD(MANAGEMENT_BEACON); - IWL_CMD(MANAGEMENT_ATIM); - IWL_CMD(MANAGEMENT_DISASSOC); - IWL_CMD(MANAGEMENT_AUTH); - IWL_CMD(MANAGEMENT_DEAUTH); - IWL_CMD(MANAGEMENT_ACTION); + IL_CMD(MANAGEMENT_ASSOC_REQ); + IL_CMD(MANAGEMENT_ASSOC_RESP); + IL_CMD(MANAGEMENT_REASSOC_REQ); + IL_CMD(MANAGEMENT_REASSOC_RESP); + IL_CMD(MANAGEMENT_PROBE_REQ); + IL_CMD(MANAGEMENT_PROBE_RESP); + IL_CMD(MANAGEMENT_BEACON); + IL_CMD(MANAGEMENT_ATIM); + IL_CMD(MANAGEMENT_DISASSOC); + IL_CMD(MANAGEMENT_AUTH); + IL_CMD(MANAGEMENT_DEAUTH); + IL_CMD(MANAGEMENT_ACTION); default: return "UNKNOWN"; } } -const char *iwl_legacy_get_ctrl_string(int cmd) +const char *il_get_ctrl_string(int cmd) { switch (cmd) { - IWL_CMD(CONTROL_BACK_REQ); - IWL_CMD(CONTROL_BACK); - IWL_CMD(CONTROL_PSPOLL); - IWL_CMD(CONTROL_RTS); - IWL_CMD(CONTROL_CTS); - IWL_CMD(CONTROL_ACK); - IWL_CMD(CONTROL_CFEND); - IWL_CMD(CONTROL_CFENDACK); + IL_CMD(CONTROL_BACK_REQ); + IL_CMD(CONTROL_BACK); + IL_CMD(CONTROL_PSPOLL); + IL_CMD(CONTROL_RTS); + IL_CMD(CONTROL_CTS); + IL_CMD(CONTROL_ACK); + IL_CMD(CONTROL_CFEND); + IL_CMD(CONTROL_CFENDACK); default: return "UNKNOWN"; } } -void iwl_legacy_clear_traffic_stats(struct iwl_priv *priv) +void il_clear_traffic_stats(struct il_priv *priv) { memset(&priv->tx_stats, 0, sizeof(struct traffic_stats)); memset(&priv->rx_stats, 0, sizeof(struct traffic_stats)); @@ -1613,17 +1613,17 @@ void iwl_legacy_clear_traffic_stats(struct iwl_priv *priv) /* * if CONFIG_IWLWIFI_LEGACY_DEBUGFS defined, - * iwl_legacy_update_stats function will + * il_update_stats function will * record all the MGMT, CTRL and DATA pkt for both TX and Rx pass * Use debugFs to display the rx/rx_statistics * if CONFIG_IWLWIFI_LEGACY_DEBUGFS not being defined, then no MGMT and CTRL * information will be recorded, but DATA pkt still will be recorded - * for the reason of iwl_led.c need to control the led blinking based on + * for the reason of il_led.c need to control the led blinking based on * number of tx and rx data. * */ void -iwl_legacy_update_stats(struct iwl_priv *priv, bool is_tx, __le16 fc, u16 len) +il_update_stats(struct il_priv *priv, bool is_tx, __le16 fc, u16 len) { struct traffic_stats *stats; @@ -1704,12 +1704,12 @@ iwl_legacy_update_stats(struct iwl_priv *priv, bool is_tx, __le16 fc, u16 len) stats->data_bytes += len; } } -EXPORT_SYMBOL(iwl_legacy_update_stats); +EXPORT_SYMBOL(il_update_stats); #endif -int iwl_legacy_force_reset(struct iwl_priv *priv, bool external) +int il_force_reset(struct il_priv *priv, bool external) { - struct iwl_force_reset *force_reset; + struct il_force_reset *force_reset; if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return -EINVAL; @@ -1720,7 +1720,7 @@ int iwl_legacy_force_reset(struct iwl_priv *priv, bool external) if (force_reset->last_force_reset_jiffies && time_after(force_reset->last_force_reset_jiffies + force_reset->reset_duration, jiffies)) { - IWL_DEBUG_INFO(priv, "force reset rejected\n"); + IL_DEBUG_INFO(priv, "force reset rejected\n"); force_reset->reset_reject_count++; return -EAGAIN; } @@ -1738,14 +1738,14 @@ int iwl_legacy_force_reset(struct iwl_priv *priv, bool external) */ if (!external && !priv->cfg->mod_params->restart_fw) { - IWL_DEBUG_INFO(priv, "Cancel firmware reload based on " + IL_DEBUG_INFO(priv, "Cancel firmware reload based on " "module parameter setting\n"); return 0; } - IWL_ERR(priv, "On demand firmware reload\n"); + IL_ERR(priv, "On demand firmware reload\n"); - /* Set the FW error flag -- cleared on iwl_down */ + /* Set the FW error flag -- cleared on il_down */ set_bit(STATUS_FW_ERROR, &priv->status); wake_up(&priv->wait_command_queue); /* @@ -1759,13 +1759,13 @@ int iwl_legacy_force_reset(struct iwl_priv *priv, bool external) } int -iwl_legacy_mac_change_interface(struct ieee80211_hw *hw, +il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, enum nl80211_iftype newtype, bool newp2p) { - struct iwl_priv *priv = hw->priv; - struct iwl_rxon_context *ctx = iwl_legacy_rxon_ctx_from_vif(vif); - struct iwl_rxon_context *tmp; + struct il_priv *priv = hw->priv; + struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); + struct il_rxon_context *tmp; u32 interface_modes; int err; @@ -1773,7 +1773,7 @@ iwl_legacy_mac_change_interface(struct ieee80211_hw *hw, mutex_lock(&priv->mutex); - if (!ctx->vif || !iwl_legacy_is_ready_rf(priv)) { + if (!ctx->vif || !il_is_ready_rf(priv)) { /* * Huh? But wait ... this can maybe happen when * we're in the middle of a firmware restart! @@ -1807,10 +1807,10 @@ iwl_legacy_mac_change_interface(struct ieee80211_hw *hw, } /* success */ - iwl_legacy_teardown_interface(priv, vif, true); + il_teardown_interface(priv, vif, true); vif->type = newtype; vif->p2p = newp2p; - err = iwl_legacy_setup_interface(priv, ctx); + err = il_setup_interface(priv, ctx); WARN_ON(err); /* * We've switched internally, but submitting to the @@ -1825,16 +1825,16 @@ iwl_legacy_mac_change_interface(struct ieee80211_hw *hw, mutex_unlock(&priv->mutex); return err; } -EXPORT_SYMBOL(iwl_legacy_mac_change_interface); +EXPORT_SYMBOL(il_mac_change_interface); /* * On every watchdog tick we check (latest) time stamp. If it does not * change during timeout period and queue is not empty we reset firmware. */ -static int iwl_legacy_check_stuck_queue(struct iwl_priv *priv, int cnt) +static int il_check_stuck_queue(struct il_priv *priv, int cnt) { - struct iwl_tx_queue *txq = &priv->txq[cnt]; - struct iwl_queue *q = &txq->q; + struct il_tx_queue *txq = &priv->txq[cnt]; + struct il_queue *q = &txq->q; unsigned long timeout; int ret; @@ -1847,9 +1847,9 @@ static int iwl_legacy_check_stuck_queue(struct iwl_priv *priv, int cnt) msecs_to_jiffies(priv->cfg->base_params->wd_timeout); if (time_after(jiffies, timeout)) { - IWL_ERR(priv, "Queue %d stuck for %u ms.\n", + IL_ERR(priv, "Queue %d stuck for %u ms.\n", q->id, priv->cfg->base_params->wd_timeout); - ret = iwl_legacy_force_reset(priv, false); + ret = il_force_reset(priv, false); return (ret == -EAGAIN) ? 0 : 1; } @@ -1860,15 +1860,15 @@ static int iwl_legacy_check_stuck_queue(struct iwl_priv *priv, int cnt) * Making watchdog tick be a quarter of timeout assure we will * discover the queue hung between timeout and 1.25*timeout */ -#define IWL_WD_TICK(timeout) ((timeout) / 4) +#define IL_WD_TICK(timeout) ((timeout) / 4) /* * Watchdog timer callback, we check each tx queue for stuck, if if hung * we reset the firmware. If everything is fine just rearm the timer. */ -void iwl_legacy_bg_watchdog(unsigned long data) +void il_bg_watchdog(unsigned long data) { - struct iwl_priv *priv = (struct iwl_priv *)data; + struct il_priv *priv = (struct il_priv *)data; int cnt; unsigned long timeout; @@ -1880,36 +1880,36 @@ void iwl_legacy_bg_watchdog(unsigned long data) return; /* monitor and check for stuck cmd queue */ - if (iwl_legacy_check_stuck_queue(priv, priv->cmd_queue)) + if (il_check_stuck_queue(priv, priv->cmd_queue)) return; /* monitor and check for other stuck queues */ - if (iwl_legacy_is_any_associated(priv)) { + if (il_is_any_associated(priv)) { for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) { /* skip as we already checked the command queue */ if (cnt == priv->cmd_queue) continue; - if (iwl_legacy_check_stuck_queue(priv, cnt)) + if (il_check_stuck_queue(priv, cnt)) return; } } mod_timer(&priv->watchdog, jiffies + - msecs_to_jiffies(IWL_WD_TICK(timeout))); + msecs_to_jiffies(IL_WD_TICK(timeout))); } -EXPORT_SYMBOL(iwl_legacy_bg_watchdog); +EXPORT_SYMBOL(il_bg_watchdog); -void iwl_legacy_setup_watchdog(struct iwl_priv *priv) +void il_setup_watchdog(struct il_priv *priv) { unsigned int timeout = priv->cfg->base_params->wd_timeout; if (timeout) mod_timer(&priv->watchdog, - jiffies + msecs_to_jiffies(IWL_WD_TICK(timeout))); + jiffies + msecs_to_jiffies(IL_WD_TICK(timeout))); else del_timer(&priv->watchdog); } -EXPORT_SYMBOL(iwl_legacy_setup_watchdog); +EXPORT_SYMBOL(il_setup_watchdog); /* * extended beacon time format @@ -1918,7 +1918,7 @@ EXPORT_SYMBOL(iwl_legacy_setup_watchdog); * the internal part is the time in usec within one beacon interval */ u32 -iwl_legacy_usecs_to_beacons(struct iwl_priv *priv, +il_usecs_to_beacons(struct il_priv *priv, u32 usec, u32 beacon_interval) { u32 quot; @@ -1929,30 +1929,30 @@ iwl_legacy_usecs_to_beacons(struct iwl_priv *priv, return 0; quot = (usec / interval) & - (iwl_legacy_beacon_time_mask_high(priv, + (il_beacon_time_mask_high(priv, priv->hw_params.beacon_time_tsf_bits) >> priv->hw_params.beacon_time_tsf_bits); - rem = (usec % interval) & iwl_legacy_beacon_time_mask_low(priv, + rem = (usec % interval) & il_beacon_time_mask_low(priv, priv->hw_params.beacon_time_tsf_bits); return (quot << priv->hw_params.beacon_time_tsf_bits) + rem; } -EXPORT_SYMBOL(iwl_legacy_usecs_to_beacons); +EXPORT_SYMBOL(il_usecs_to_beacons); /* base is usually what we get from ucode with each received frame, * the same as HW timer counter counting down */ -__le32 iwl_legacy_add_beacon_time(struct iwl_priv *priv, u32 base, +__le32 il_add_beacon_time(struct il_priv *priv, u32 base, u32 addon, u32 beacon_interval) { - u32 base_low = base & iwl_legacy_beacon_time_mask_low(priv, + u32 base_low = base & il_beacon_time_mask_low(priv, priv->hw_params.beacon_time_tsf_bits); - u32 addon_low = addon & iwl_legacy_beacon_time_mask_low(priv, + u32 addon_low = addon & il_beacon_time_mask_low(priv, priv->hw_params.beacon_time_tsf_bits); u32 interval = beacon_interval * TIME_UNIT; - u32 res = (base & iwl_legacy_beacon_time_mask_high(priv, + u32 res = (base & il_beacon_time_mask_high(priv, priv->hw_params.beacon_time_tsf_bits)) + - (addon & iwl_legacy_beacon_time_mask_high(priv, + (addon & il_beacon_time_mask_high(priv, priv->hw_params.beacon_time_tsf_bits)); if (base_low > addon_low) @@ -1965,32 +1965,32 @@ __le32 iwl_legacy_add_beacon_time(struct iwl_priv *priv, u32 base, return cpu_to_le32(res); } -EXPORT_SYMBOL(iwl_legacy_add_beacon_time); +EXPORT_SYMBOL(il_add_beacon_time); #ifdef CONFIG_PM -int iwl_legacy_pci_suspend(struct device *device) +int il_pci_suspend(struct device *device) { struct pci_dev *pdev = to_pci_dev(device); - struct iwl_priv *priv = pci_get_drvdata(pdev); + struct il_priv *priv = pci_get_drvdata(pdev); /* * This function is called when system goes into suspend state - * mac80211 will call iwl_mac_stop() from the mac80211 suspend function - * first but since iwl_mac_stop() has no knowledge of who the caller is, + * mac80211 will call il_mac_stop() from the mac80211 suspend function + * first but since il_mac_stop() has no knowledge of who the caller is, * it will not call apm_ops.stop() to stop the DMA operation. * Calling apm_ops.stop here to make sure we stop the DMA. */ - iwl_legacy_apm_stop(priv); + il_apm_stop(priv); return 0; } -EXPORT_SYMBOL(iwl_legacy_pci_suspend); +EXPORT_SYMBOL(il_pci_suspend); -int iwl_legacy_pci_resume(struct device *device) +int il_pci_resume(struct device *device) { struct pci_dev *pdev = to_pci_dev(device); - struct iwl_priv *priv = pci_get_drvdata(pdev); + struct il_priv *priv = pci_get_drvdata(pdev); bool hw_rfkill = false; /* @@ -1999,9 +1999,9 @@ int iwl_legacy_pci_resume(struct device *device) */ pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); - iwl_legacy_enable_interrupts(priv); + il_enable_interrupts(priv); - if (!(iwl_read32(priv, CSR_GP_CNTRL) & + if (!(il_read32(priv, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) hw_rfkill = true; @@ -2014,22 +2014,22 @@ int iwl_legacy_pci_resume(struct device *device) return 0; } -EXPORT_SYMBOL(iwl_legacy_pci_resume); +EXPORT_SYMBOL(il_pci_resume); -const struct dev_pm_ops iwl_legacy_pm_ops = { - .suspend = iwl_legacy_pci_suspend, - .resume = iwl_legacy_pci_resume, - .freeze = iwl_legacy_pci_suspend, - .thaw = iwl_legacy_pci_resume, - .poweroff = iwl_legacy_pci_suspend, - .restore = iwl_legacy_pci_resume, +const struct dev_pm_ops il_pm_ops = { + .suspend = il_pci_suspend, + .resume = il_pci_resume, + .freeze = il_pci_suspend, + .thaw = il_pci_resume, + .poweroff = il_pci_suspend, + .restore = il_pci_resume, }; -EXPORT_SYMBOL(iwl_legacy_pm_ops); +EXPORT_SYMBOL(il_pm_ops); #endif /* CONFIG_PM */ static void -iwl_legacy_update_qos(struct iwl_priv *priv, struct iwl_rxon_context *ctx) +il_update_qos(struct il_priv *priv, struct il_rxon_context *ctx) { if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; @@ -2046,43 +2046,43 @@ iwl_legacy_update_qos(struct iwl_priv *priv, struct iwl_rxon_context *ctx) if (ctx->ht.enabled) ctx->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; - IWL_DEBUG_QOS(priv, "send QoS cmd with Qos active=%d FLAGS=0x%X\n", + IL_DEBUG_QOS(priv, "send QoS cmd with Qos active=%d FLAGS=0x%X\n", ctx->qos_data.qos_active, ctx->qos_data.def_qos_parm.qos_flags); - iwl_legacy_send_cmd_pdu_async(priv, ctx->qos_cmd, - sizeof(struct iwl_qosparam_cmd), + il_send_cmd_pdu_async(priv, ctx->qos_cmd, + sizeof(struct il_qosparam_cmd), &ctx->qos_data.def_qos_parm, NULL); } /** - * iwl_legacy_mac_config - mac80211 config callback + * il_mac_config - mac80211 config callback */ -int iwl_legacy_mac_config(struct ieee80211_hw *hw, u32 changed) +int il_mac_config(struct ieee80211_hw *hw, u32 changed) { - struct iwl_priv *priv = hw->priv; - const struct iwl_channel_info *ch_info; + struct il_priv *priv = hw->priv; + const struct il_channel_info *ch_info; struct ieee80211_conf *conf = &hw->conf; struct ieee80211_channel *channel = conf->channel; - struct iwl_ht_config *ht_conf = &priv->current_ht_config; - struct iwl_rxon_context *ctx; + struct il_ht_config *ht_conf = &priv->current_ht_config; + struct il_rxon_context *ctx; unsigned long flags = 0; int ret = 0; u16 ch; int scan_active = 0; - bool ht_changed[NUM_IWL_RXON_CTX] = {}; + bool ht_changed[NUM_IL_RXON_CTX] = {}; if (WARN_ON(!priv->cfg->ops->legacy)) return -EOPNOTSUPP; mutex_lock(&priv->mutex); - IWL_DEBUG_MAC80211(priv, "enter to channel %d changed 0x%X\n", + IL_DEBUG_MAC80211(priv, "enter to channel %d changed 0x%X\n", channel->hw_value, changed); if (unlikely(test_bit(STATUS_SCANNING, &priv->status))) { scan_active = 1; - IWL_DEBUG_MAC80211(priv, "scan active\n"); + IL_DEBUG_MAC80211(priv, "scan active\n"); } if (changed & (IEEE80211_CONF_CHANGE_SMPS | @@ -2110,16 +2110,16 @@ int iwl_legacy_mac_config(struct ieee80211_hw *hw, u32 changed) goto set_ch_out; ch = channel->hw_value; - ch_info = iwl_legacy_get_channel_info(priv, channel->band, ch); - if (!iwl_legacy_is_channel_valid(ch_info)) { - IWL_DEBUG_MAC80211(priv, "leave - invalid channel\n"); + ch_info = il_get_channel_info(priv, channel->band, ch); + if (!il_is_channel_valid(ch_info)) { + IL_DEBUG_MAC80211(priv, "leave - invalid channel\n"); ret = -EINVAL; goto set_ch_out; } if (priv->iw_mode == NL80211_IFTYPE_ADHOC && - !iwl_legacy_is_channel_ibss(ch_info)) { - IWL_DEBUG_MAC80211(priv, "leave - not IBSS channel\n"); + !il_is_channel_ibss(ch_info)) { + IL_DEBUG_MAC80211(priv, "leave - not IBSS channel\n"); ret = -EINVAL; goto set_ch_out; } @@ -2151,7 +2151,7 @@ int iwl_legacy_mac_config(struct ieee80211_hw *hw, u32 changed) /* * Default to no protection. Protection mode will - * later be set from BSS config in iwl_ht_conf + * later be set from BSS config in il_ht_conf */ ctx->ht.protection = IEEE80211_HT_OP_MODE_PROTECTION_NONE; @@ -2162,10 +2162,10 @@ int iwl_legacy_mac_config(struct ieee80211_hw *hw, u32 changed) if ((le16_to_cpu(ctx->staging.channel) != ch)) ctx->staging.flags = 0; - iwl_legacy_set_rxon_channel(priv, channel, ctx); - iwl_legacy_set_rxon_ht(priv, ht_conf); + il_set_rxon_channel(priv, channel, ctx); + il_set_rxon_ht(priv, ht_conf); - iwl_legacy_set_flags_for_band(priv, ctx, channel->band, + il_set_flags_for_band(priv, ctx, channel->band, ctx->vif); } @@ -2179,25 +2179,25 @@ int iwl_legacy_mac_config(struct ieee80211_hw *hw, u32 changed) /* The list of supported rates and rate mask can be different * for each band; since the band may have changed, reset * the rate mask to what mac80211 lists */ - iwl_legacy_set_rate(priv); + il_set_rate(priv); } if (changed & (IEEE80211_CONF_CHANGE_PS | IEEE80211_CONF_CHANGE_IDLE)) { - ret = iwl_legacy_power_update_mode(priv, false); + ret = il_power_update_mode(priv, false); if (ret) - IWL_DEBUG_MAC80211(priv, "Error setting sleep level\n"); + IL_DEBUG_MAC80211(priv, "Error setting sleep level\n"); } if (changed & IEEE80211_CONF_CHANGE_POWER) { - IWL_DEBUG_MAC80211(priv, "TX Power old=%d new=%d\n", + IL_DEBUG_MAC80211(priv, "TX Power old=%d new=%d\n", priv->tx_power_user_lmt, conf->power_level); - iwl_legacy_set_tx_power(priv, conf->power_level, false); + il_set_tx_power(priv, conf->power_level, false); } - if (!iwl_legacy_is_ready(priv)) { - IWL_DEBUG_MAC80211(priv, "leave - not ready\n"); + if (!il_is_ready(priv)) { + IL_DEBUG_MAC80211(priv, "leave - not ready\n"); goto out; } @@ -2206,37 +2206,37 @@ int iwl_legacy_mac_config(struct ieee80211_hw *hw, u32 changed) for_each_context(priv, ctx) { if (memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging))) - iwl_legacy_commit_rxon(priv, ctx); + il_commit_rxon(priv, ctx); else - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "Not re-sending same RXON configuration.\n"); if (ht_changed[ctx->ctxid]) - iwl_legacy_update_qos(priv, ctx); + il_update_qos(priv, ctx); } out: - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); mutex_unlock(&priv->mutex); return ret; } -EXPORT_SYMBOL(iwl_legacy_mac_config); +EXPORT_SYMBOL(il_mac_config); -void iwl_legacy_mac_reset_tsf(struct ieee80211_hw *hw, +void il_mac_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; unsigned long flags; - /* IBSS can only be the IWL_RXON_CTX_BSS context */ - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + /* IBSS can only be the IL_RXON_CTX_BSS context */ + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; if (WARN_ON(!priv->cfg->ops->legacy)) return; mutex_lock(&priv->mutex); - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); spin_lock_irqsave(&priv->lock, flags); - memset(&priv->current_ht_config, 0, sizeof(struct iwl_ht_config)); + memset(&priv->current_ht_config, 0, sizeof(struct il_ht_config)); spin_unlock_irqrestore(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags); @@ -2251,9 +2251,9 @@ void iwl_legacy_mac_reset_tsf(struct ieee80211_hw *hw, spin_unlock_irqrestore(&priv->lock, flags); - iwl_legacy_scan_cancel_timeout(priv, 100); - if (!iwl_legacy_is_ready_rf(priv)) { - IWL_DEBUG_MAC80211(priv, "leave - not ready\n"); + il_scan_cancel_timeout(priv, 100); + if (!il_is_ready_rf(priv)) { + IL_DEBUG_MAC80211(priv, "leave - not ready\n"); mutex_unlock(&priv->mutex); return; } @@ -2262,25 +2262,25 @@ void iwl_legacy_mac_reset_tsf(struct ieee80211_hw *hw, * clear RXON_FILTER_ASSOC_MSK bit */ ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - iwl_legacy_commit_rxon(priv, ctx); + il_commit_rxon(priv, ctx); - iwl_legacy_set_rate(priv); + il_set_rate(priv); mutex_unlock(&priv->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); } -EXPORT_SYMBOL(iwl_legacy_mac_reset_tsf); +EXPORT_SYMBOL(il_mac_reset_tsf); -static void iwl_legacy_ht_conf(struct iwl_priv *priv, +static void il_ht_conf(struct il_priv *priv, struct ieee80211_vif *vif) { - struct iwl_ht_config *ht_conf = &priv->current_ht_config; + struct il_ht_config *ht_conf = &priv->current_ht_config; struct ieee80211_sta *sta; struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; - struct iwl_rxon_context *ctx = iwl_legacy_rxon_ctx_from_vif(vif); + struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - IWL_DEBUG_ASSOC(priv, "enter:\n"); + IL_DEBUG_ASSOC(priv, "enter:\n"); if (!ctx->ht.enabled) return; @@ -2329,13 +2329,13 @@ static void iwl_legacy_ht_conf(struct iwl_priv *priv, break; } - IWL_DEBUG_ASSOC(priv, "leave\n"); + IL_DEBUG_ASSOC(priv, "leave\n"); } -static inline void iwl_legacy_set_no_assoc(struct iwl_priv *priv, +static inline void il_set_no_assoc(struct il_priv *priv, struct ieee80211_vif *vif) { - struct iwl_rxon_context *ctx = iwl_legacy_rxon_ctx_from_vif(vif); + struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); /* * inform the ucode that there is no longer an @@ -2344,13 +2344,13 @@ static inline void iwl_legacy_set_no_assoc(struct iwl_priv *priv, */ ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; ctx->staging.assoc_id = 0; - iwl_legacy_commit_rxon(priv, ctx); + il_commit_rxon(priv, ctx); } -static void iwl_legacy_beacon_update(struct ieee80211_hw *hw, +static void il_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; unsigned long flags; __le64 timestamp; struct sk_buff *skb = ieee80211_beacon_get(hw, vif); @@ -2358,12 +2358,12 @@ static void iwl_legacy_beacon_update(struct ieee80211_hw *hw, if (!skb) return; - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); lockdep_assert_held(&priv->mutex); if (!priv->beacon_ctx) { - IWL_ERR(priv, "update beacon but no beacon context!\n"); + IL_ERR(priv, "update beacon but no beacon context!\n"); dev_kfree_skb(skb); return; } @@ -2378,34 +2378,34 @@ static void iwl_legacy_beacon_update(struct ieee80211_hw *hw, timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp; priv->timestamp = le64_to_cpu(timestamp); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); spin_unlock_irqrestore(&priv->lock, flags); - if (!iwl_legacy_is_ready_rf(priv)) { - IWL_DEBUG_MAC80211(priv, "leave - RF not ready\n"); + if (!il_is_ready_rf(priv)) { + IL_DEBUG_MAC80211(priv, "leave - RF not ready\n"); return; } priv->cfg->ops->legacy->post_associate(priv); } -void iwl_legacy_mac_bss_info_changed(struct ieee80211_hw *hw, +void il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_bss_conf *bss_conf, u32 changes) { - struct iwl_priv *priv = hw->priv; - struct iwl_rxon_context *ctx = iwl_legacy_rxon_ctx_from_vif(vif); + struct il_priv *priv = hw->priv; + struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); int ret; if (WARN_ON(!priv->cfg->ops->legacy)) return; - IWL_DEBUG_MAC80211(priv, "changes = 0x%X\n", changes); + IL_DEBUG_MAC80211(priv, "changes = 0x%X\n", changes); mutex_lock(&priv->mutex); - if (!iwl_legacy_is_alive(priv)) { + if (!il_is_alive(priv)) { mutex_unlock(&priv->mutex); return; } @@ -2415,7 +2415,7 @@ void iwl_legacy_mac_bss_info_changed(struct ieee80211_hw *hw, spin_lock_irqsave(&priv->lock, flags); ctx->qos_data.qos_active = bss_conf->qos; - iwl_legacy_update_qos(priv, ctx); + il_update_qos(priv, ctx); spin_unlock_irqrestore(&priv->lock, flags); } @@ -2432,17 +2432,17 @@ void iwl_legacy_mac_bss_info_changed(struct ieee80211_hw *hw, } if (changes & BSS_CHANGED_BSSID) { - IWL_DEBUG_MAC80211(priv, "BSSID %pM\n", bss_conf->bssid); + IL_DEBUG_MAC80211(priv, "BSSID %pM\n", bss_conf->bssid); /* * If there is currently a HW scan going on in the * background then we need to cancel it else the RXON * below/in post_associate will fail. */ - if (iwl_legacy_scan_cancel_timeout(priv, 100)) { - IWL_WARN(priv, + if (il_scan_cancel_timeout(priv, 100)) { + IL_WARN(priv, "Aborted scan still in progress after 100ms\n"); - IWL_DEBUG_MAC80211(priv, + IL_DEBUG_MAC80211(priv, "leaving - scan abort failed.\n"); mutex_unlock(&priv->mutex); return; @@ -2468,10 +2468,10 @@ void iwl_legacy_mac_bss_info_changed(struct ieee80211_hw *hw, * it will invoke post_associate. */ if (vif->type == NL80211_IFTYPE_ADHOC && changes & BSS_CHANGED_BEACON) - iwl_legacy_beacon_update(hw, vif); + il_beacon_update(hw, vif); if (changes & BSS_CHANGED_ERP_PREAMBLE) { - IWL_DEBUG_MAC80211(priv, "ERP_PREAMBLE %d\n", + IL_DEBUG_MAC80211(priv, "ERP_PREAMBLE %d\n", bss_conf->use_short_preamble); if (bss_conf->use_short_preamble) ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; @@ -2480,7 +2480,7 @@ void iwl_legacy_mac_bss_info_changed(struct ieee80211_hw *hw, } if (changes & BSS_CHANGED_ERP_CTS_PROT) { - IWL_DEBUG_MAC80211(priv, + IL_DEBUG_MAC80211(priv, "ERP_CTS %d\n", bss_conf->use_cts_prot); if (bss_conf->use_cts_prot && (priv->band != IEEE80211_BAND_5GHZ)) @@ -2496,7 +2496,7 @@ void iwl_legacy_mac_bss_info_changed(struct ieee80211_hw *hw, if (changes & BSS_CHANGED_BASIC_RATES) { /* XXX use this information * - * To do that, remove code from iwl_legacy_set_rate() and put something + * To do that, remove code from il_set_rate() and put something * like this here: * if (A-band) @@ -2511,32 +2511,32 @@ void iwl_legacy_mac_bss_info_changed(struct ieee80211_hw *hw, } if (changes & BSS_CHANGED_HT) { - iwl_legacy_ht_conf(priv, vif); + il_ht_conf(priv, vif); if (priv->cfg->ops->hcmd->set_rxon_chain) priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); } if (changes & BSS_CHANGED_ASSOC) { - IWL_DEBUG_MAC80211(priv, "ASSOC %d\n", bss_conf->assoc); + IL_DEBUG_MAC80211(priv, "ASSOC %d\n", bss_conf->assoc); if (bss_conf->assoc) { priv->timestamp = bss_conf->timestamp; - if (!iwl_legacy_is_rfkill(priv)) + if (!il_is_rfkill(priv)) priv->cfg->ops->legacy->post_associate(priv); } else - iwl_legacy_set_no_assoc(priv, vif); + il_set_no_assoc(priv, vif); } - if (changes && iwl_legacy_is_associated_ctx(ctx) && bss_conf->aid) { - IWL_DEBUG_MAC80211(priv, "Changes (%#x) while associated\n", + if (changes && il_is_associated_ctx(ctx) && bss_conf->aid) { + IL_DEBUG_MAC80211(priv, "Changes (%#x) while associated\n", changes); - ret = iwl_legacy_send_rxon_assoc(priv, ctx); + ret = il_send_rxon_assoc(priv, ctx); if (!ret) { /* Sync active_rxon with latest change. */ memcpy((void *)&ctx->active, &ctx->staging, - sizeof(struct iwl_legacy_rxon_cmd)); + sizeof(struct il_rxon_cmd)); } } @@ -2547,27 +2547,27 @@ void iwl_legacy_mac_bss_info_changed(struct ieee80211_hw *hw, memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN); priv->cfg->ops->legacy->config_ap(priv); } else - iwl_legacy_set_no_assoc(priv, vif); + il_set_no_assoc(priv, vif); } if (changes & BSS_CHANGED_IBSS) { ret = priv->cfg->ops->legacy->manage_ibss_station(priv, vif, bss_conf->ibss_joined); if (ret) - IWL_ERR(priv, "failed to %s IBSS station %pM\n", + IL_ERR(priv, "failed to %s IBSS station %pM\n", bss_conf->ibss_joined ? "add" : "remove", bss_conf->bssid); } mutex_unlock(&priv->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); } -EXPORT_SYMBOL(iwl_legacy_mac_bss_info_changed); +EXPORT_SYMBOL(il_mac_bss_info_changed); -irqreturn_t iwl_legacy_isr(int irq, void *data) +irqreturn_t il_isr(int irq, void *data) { - struct iwl_priv *priv = data; + struct il_priv *priv = data; u32 inta, inta_mask; u32 inta_fh; unsigned long flags; @@ -2580,18 +2580,18 @@ irqreturn_t iwl_legacy_isr(int irq, void *data) * back-to-back ISRs and sporadic interrupts from our NIC. * If we have something to service, the tasklet will re-enable ints. * If we *don't* have something, we'll re-enable before leaving here. */ - inta_mask = iwl_read32(priv, CSR_INT_MASK); /* just for debug */ - iwl_write32(priv, CSR_INT_MASK, 0x00000000); + inta_mask = il_read32(priv, CSR_INT_MASK); /* just for debug */ + il_write32(priv, CSR_INT_MASK, 0x00000000); /* Discover which interrupts are active/pending */ - inta = iwl_read32(priv, CSR_INT); - inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS); + inta = il_read32(priv, CSR_INT); + inta_fh = il_read32(priv, CSR_FH_INT_STATUS); /* Ignore interrupt if there's nothing in NIC to service. * This may be due to IRQ shared with another device, * or due to sporadic interrupts thrown from our NIC. */ if (!inta && !inta_fh) { - IWL_DEBUG_ISR(priv, + IL_DEBUG_ISR(priv, "Ignore interrupt, inta == 0, inta_fh == 0\n"); goto none; } @@ -2599,16 +2599,16 @@ irqreturn_t iwl_legacy_isr(int irq, void *data) if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) { /* Hardware disappeared. It might have already raised * an interrupt */ - IWL_WARN(priv, "HARDWARE GONE?? INTA == 0x%08x\n", inta); + IL_WARN(priv, "HARDWARE GONE?? INTA == 0x%08x\n", inta); goto unplugged; } - IWL_DEBUG_ISR(priv, "ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", + IL_DEBUG_ISR(priv, "ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, inta_mask, inta_fh); inta &= ~CSR_INT_BIT_SCD; - /* iwl_irq_tasklet() will service interrupts and re-enable them */ + /* il_irq_tasklet() will service interrupts and re-enable them */ if (likely(inta || inta_fh)) tasklet_schedule(&priv->irq_tasklet); @@ -2620,17 +2620,17 @@ none: /* re-enable interrupts here since we don't have anything to service. */ /* only Re-enable if disabled by irq */ if (test_bit(STATUS_INT_ENABLED, &priv->status)) - iwl_legacy_enable_interrupts(priv); + il_enable_interrupts(priv); spin_unlock_irqrestore(&priv->lock, flags); return IRQ_NONE; } -EXPORT_SYMBOL(iwl_legacy_isr); +EXPORT_SYMBOL(il_isr); /* - * iwl_legacy_tx_cmd_protection: Set rts/cts. 3945 and 4965 only share this + * il_tx_cmd_protection: Set rts/cts. 3945 and 4965 only share this * function. */ -void iwl_legacy_tx_cmd_protection(struct iwl_priv *priv, +void il_tx_cmd_protection(struct il_priv *priv, struct ieee80211_tx_info *info, __le16 fc, __le32 *tx_flags) { @@ -2658,4 +2658,4 @@ void iwl_legacy_tx_cmd_protection(struct iwl_priv *priv, *tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; } } -EXPORT_SYMBOL(iwl_legacy_tx_cmd_protection); +EXPORT_SYMBOL(il_tx_cmd_protection); diff --git a/drivers/net/wireless/iwlegacy/iwl-core.h b/drivers/net/wireless/iwlegacy/iwl-core.h index d1271fe07d4b..92f37c981797 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.h +++ b/drivers/net/wireless/iwlegacy/iwl-core.h @@ -60,54 +60,54 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef __iwl_legacy_core_h__ -#define __iwl_legacy_core_h__ +#ifndef __il_core_h__ +#define __il_core_h__ /************************ * forward declarations * ************************/ -struct iwl_host_cmd; -struct iwl_cmd; +struct il_host_cmd; +struct il_cmd; #define IWLWIFI_VERSION "in-tree:" #define DRV_COPYRIGHT "Copyright(c) 2003-2011 Intel Corporation" #define DRV_AUTHOR "" -#define IWL_PCI_DEVICE(dev, subdev, cfg) \ +#define IL_PCI_DEVICE(dev, subdev, cfg) \ .vendor = PCI_VENDOR_ID_INTEL, .device = (dev), \ .subvendor = PCI_ANY_ID, .subdevice = (subdev), \ .driver_data = (kernel_ulong_t)&(cfg) #define TIME_UNIT 1024 -#define IWL_SKU_G 0x1 -#define IWL_SKU_A 0x2 -#define IWL_SKU_N 0x8 +#define IL_SKU_G 0x1 +#define IL_SKU_A 0x2 +#define IL_SKU_N 0x8 -#define IWL_CMD(x) case x: return #x +#define IL_CMD(x) case x: return #x -struct iwl_hcmd_ops { - int (*rxon_assoc)(struct iwl_priv *priv, struct iwl_rxon_context *ctx); - int (*commit_rxon)(struct iwl_priv *priv, struct iwl_rxon_context *ctx); - void (*set_rxon_chain)(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); +struct il_hcmd_ops { + int (*rxon_assoc)(struct il_priv *priv, struct il_rxon_context *ctx); + int (*commit_rxon)(struct il_priv *priv, struct il_rxon_context *ctx); + void (*set_rxon_chain)(struct il_priv *priv, + struct il_rxon_context *ctx); }; -struct iwl_hcmd_utils_ops { +struct il_hcmd_utils_ops { u16 (*get_hcmd_size)(u8 cmd_id, u16 len); - u16 (*build_addsta_hcmd)(const struct iwl_legacy_addsta_cmd *cmd, + u16 (*build_addsta_hcmd)(const struct il_addsta_cmd *cmd, u8 *data); - int (*request_scan)(struct iwl_priv *priv, struct ieee80211_vif *vif); - void (*post_scan)(struct iwl_priv *priv); + int (*request_scan)(struct il_priv *priv, struct ieee80211_vif *vif); + void (*post_scan)(struct il_priv *priv); }; -struct iwl_apm_ops { - int (*init)(struct iwl_priv *priv); - void (*config)(struct iwl_priv *priv); +struct il_apm_ops { + int (*init)(struct il_priv *priv); + void (*config)(struct il_priv *priv); }; -struct iwl_debugfs_ops { +struct il_debugfs_ops { ssize_t (*rx_stats_read)(struct file *file, char __user *user_buf, size_t count, loff_t *ppos); ssize_t (*tx_stats_read)(struct file *file, char __user *user_buf, @@ -116,79 +116,79 @@ struct iwl_debugfs_ops { size_t count, loff_t *ppos); }; -struct iwl_temp_ops { - void (*temperature)(struct iwl_priv *priv); +struct il_temp_ops { + void (*temperature)(struct il_priv *priv); }; -struct iwl_lib_ops { +struct il_lib_ops { /* set hw dependent parameters */ - int (*set_hw_params)(struct iwl_priv *priv); + int (*set_hw_params)(struct il_priv *priv); /* Handling TX */ - void (*txq_update_byte_cnt_tbl)(struct iwl_priv *priv, - struct iwl_tx_queue *txq, + void (*txq_update_byte_cnt_tbl)(struct il_priv *priv, + struct il_tx_queue *txq, u16 byte_cnt); - int (*txq_attach_buf_to_tfd)(struct iwl_priv *priv, - struct iwl_tx_queue *txq, + int (*txq_attach_buf_to_tfd)(struct il_priv *priv, + struct il_tx_queue *txq, dma_addr_t addr, u16 len, u8 reset, u8 pad); - void (*txq_free_tfd)(struct iwl_priv *priv, - struct iwl_tx_queue *txq); - int (*txq_init)(struct iwl_priv *priv, - struct iwl_tx_queue *txq); + void (*txq_free_tfd)(struct il_priv *priv, + struct il_tx_queue *txq); + int (*txq_init)(struct il_priv *priv, + struct il_tx_queue *txq); /* setup Rx handler */ - void (*rx_handler_setup)(struct iwl_priv *priv); + void (*rx_handler_setup)(struct il_priv *priv); /* alive notification after init uCode load */ - void (*init_alive_start)(struct iwl_priv *priv); + void (*init_alive_start)(struct il_priv *priv); /* check validity of rtc data address */ int (*is_valid_rtc_data_addr)(u32 addr); /* 1st ucode load */ - int (*load_ucode)(struct iwl_priv *priv); + int (*load_ucode)(struct il_priv *priv); - void (*dump_nic_error_log)(struct iwl_priv *priv); - int (*dump_fh)(struct iwl_priv *priv, char **buf, bool display); - int (*set_channel_switch)(struct iwl_priv *priv, + void (*dump_nic_error_log)(struct il_priv *priv); + int (*dump_fh)(struct il_priv *priv, char **buf, bool display); + int (*set_channel_switch)(struct il_priv *priv, struct ieee80211_channel_switch *ch_switch); /* power management */ - struct iwl_apm_ops apm_ops; + struct il_apm_ops apm_ops; /* power */ - int (*send_tx_power) (struct iwl_priv *priv); - void (*update_chain_flags)(struct iwl_priv *priv); + int (*send_tx_power) (struct il_priv *priv); + void (*update_chain_flags)(struct il_priv *priv); /* eeprom operations (as defined in iwl-eeprom.h) */ - struct iwl_eeprom_ops eeprom_ops; + struct il_eeprom_ops eeprom_ops; /* temperature */ - struct iwl_temp_ops temp_ops; + struct il_temp_ops temp_ops; - struct iwl_debugfs_ops debugfs_ops; + struct il_debugfs_ops debugfs_ops; }; -struct iwl_led_ops { - int (*cmd)(struct iwl_priv *priv, struct iwl_led_cmd *led_cmd); +struct il_led_ops { + int (*cmd)(struct il_priv *priv, struct il_led_cmd *led_cmd); }; -struct iwl_legacy_ops { - void (*post_associate)(struct iwl_priv *priv); - void (*config_ap)(struct iwl_priv *priv); +struct il_legacy_ops { + void (*post_associate)(struct il_priv *priv); + void (*config_ap)(struct il_priv *priv); /* station management */ - int (*update_bcast_stations)(struct iwl_priv *priv); - int (*manage_ibss_station)(struct iwl_priv *priv, + int (*update_bcast_stations)(struct il_priv *priv); + int (*manage_ibss_station)(struct il_priv *priv, struct ieee80211_vif *vif, bool add); }; -struct iwl_ops { - const struct iwl_lib_ops *lib; - const struct iwl_hcmd_ops *hcmd; - const struct iwl_hcmd_utils_ops *utils; - const struct iwl_led_ops *led; - const struct iwl_nic_ops *nic; - const struct iwl_legacy_ops *legacy; +struct il_ops { + const struct il_lib_ops *lib; + const struct il_hcmd_ops *hcmd; + const struct il_hcmd_utils_ops *utils; + const struct il_led_ops *led; + const struct il_nic_ops *nic; + const struct il_legacy_ops *legacy; const struct ieee80211_ops *ieee80211_ops; }; -struct iwl_mod_params { +struct il_mod_params { int sw_crypto; /* def: 0 = using hardware encryption */ int disable_hw_scan; /* def: 0 = use h/w scan */ int num_of_queues; /* def: HW dependent */ @@ -211,11 +211,11 @@ struct iwl_mod_params { * @chain_noise_calib_by_driver: driver has the capability to perform * chain noise calibration operation */ -struct iwl_base_params { +struct il_base_params { int eeprom_size; int num_of_queues; /* def: HW dependent */ int num_of_ampdu_queues;/* def: HW dependent */ - /* for iwl_legacy_apm_init() */ + /* for il_apm_init() */ u32 pll_cfg_val; bool set_l0s; bool use_bsm; @@ -230,7 +230,7 @@ struct iwl_base_params { }; /** - * struct iwl_cfg + * struct il_cfg * @fw_name_pre: Firmware filename prefix. The api version and extension * (.ucode) will be added to filename before loading from disk. The * filename is constructed as fw_name_pre.ucode. @@ -243,11 +243,11 @@ struct iwl_base_params { * driver specifies which APIs it supports (with @ucode_api_max being the * highest and @ucode_api_min the lowest). Firmware will only be loaded if * it has a supported API version. The firmware's API version will be - * stored in @iwl_priv, enabling the driver to make runtime changes based + * stored in @il_priv, enabling the driver to make runtime changes based * on firmware version used. * * For example, - * if (IWL_UCODE_API(priv->ucode_ver) >= 2) { + * if (IL_UCODE_API(priv->ucode_ver) >= 2) { * Driver interacts with Firmware API version >= 2. * } else { * Driver interacts with Firmware API version 1. @@ -255,12 +255,12 @@ struct iwl_base_params { * * The ideal usage of this infrastructure is to treat a new ucode API * release as a new hardware revision. That is, through utilizing the - * iwl_hcmd_utils_ops etc. we accommodate different command structures + * il_hcmd_utils_ops etc. we accommodate different command structures * and flows between hardware versions as well as their API * versions. * */ -struct iwl_cfg { +struct il_cfg { /* params specific to an individual device within a device family */ const char *name; const char *fw_name_pre; @@ -271,97 +271,97 @@ struct iwl_cfg { unsigned int sku; u16 eeprom_ver; u16 eeprom_calib_ver; - const struct iwl_ops *ops; + const struct il_ops *ops; /* module based parameters which can be set from modprobe cmd */ - const struct iwl_mod_params *mod_params; + const struct il_mod_params *mod_params; /* params not likely to change within a device family */ - struct iwl_base_params *base_params; + struct il_base_params *base_params; /* params likely to change within a device family */ u8 scan_rx_antennas[IEEE80211_NUM_BANDS]; - enum iwl_led_mode led_mode; + enum il_led_mode led_mode; }; /*************************** * L i b * ***************************/ -struct ieee80211_hw *iwl_legacy_alloc_all(struct iwl_cfg *cfg); -int iwl_legacy_mac_conf_tx(struct ieee80211_hw *hw, +struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg); +int il_mac_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue, const struct ieee80211_tx_queue_params *params); -int iwl_legacy_mac_tx_last_beacon(struct ieee80211_hw *hw); -void iwl_legacy_set_rxon_hwcrypto(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +int il_mac_tx_last_beacon(struct ieee80211_hw *hw); +void il_set_rxon_hwcrypto(struct il_priv *priv, + struct il_rxon_context *ctx, int hw_decrypt); -int iwl_legacy_check_rxon_cmd(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); -int iwl_legacy_full_rxon_required(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); -int iwl_legacy_set_rxon_channel(struct iwl_priv *priv, +int il_check_rxon_cmd(struct il_priv *priv, + struct il_rxon_context *ctx); +int il_full_rxon_required(struct il_priv *priv, + struct il_rxon_context *ctx); +int il_set_rxon_channel(struct il_priv *priv, struct ieee80211_channel *ch, - struct iwl_rxon_context *ctx); -void iwl_legacy_set_flags_for_band(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, + struct il_rxon_context *ctx); +void il_set_flags_for_band(struct il_priv *priv, + struct il_rxon_context *ctx, enum ieee80211_band band, struct ieee80211_vif *vif); -u8 iwl_legacy_get_single_channel_number(struct iwl_priv *priv, +u8 il_get_single_channel_number(struct il_priv *priv, enum ieee80211_band band); -void iwl_legacy_set_rxon_ht(struct iwl_priv *priv, - struct iwl_ht_config *ht_conf); -bool iwl_legacy_is_ht40_tx_allowed(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +void il_set_rxon_ht(struct il_priv *priv, + struct il_ht_config *ht_conf); +bool il_is_ht40_tx_allowed(struct il_priv *priv, + struct il_rxon_context *ctx, struct ieee80211_sta_ht_cap *ht_cap); -void iwl_legacy_connection_init_rx_config(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); -void iwl_legacy_set_rate(struct iwl_priv *priv); -int iwl_legacy_set_decrypted_flag(struct iwl_priv *priv, +void il_connection_init_rx_config(struct il_priv *priv, + struct il_rxon_context *ctx); +void il_set_rate(struct il_priv *priv); +int il_set_decrypted_flag(struct il_priv *priv, struct ieee80211_hdr *hdr, u32 decrypt_res, struct ieee80211_rx_status *stats); -void iwl_legacy_irq_handle_error(struct iwl_priv *priv); -int iwl_legacy_mac_add_interface(struct ieee80211_hw *hw, +void il_irq_handle_error(struct il_priv *priv); +int il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif); -void iwl_legacy_mac_remove_interface(struct ieee80211_hw *hw, +void il_mac_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif); -int iwl_legacy_mac_change_interface(struct ieee80211_hw *hw, +int il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, enum nl80211_iftype newtype, bool newp2p); -int iwl_legacy_alloc_txq_mem(struct iwl_priv *priv); -void iwl_legacy_txq_mem(struct iwl_priv *priv); +int il_alloc_txq_mem(struct il_priv *priv); +void il_txq_mem(struct il_priv *priv); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS -int iwl_legacy_alloc_traffic_mem(struct iwl_priv *priv); -void iwl_legacy_free_traffic_mem(struct iwl_priv *priv); -void iwl_legacy_reset_traffic_log(struct iwl_priv *priv); -void iwl_legacy_dbg_log_tx_data_frame(struct iwl_priv *priv, +int il_alloc_traffic_mem(struct il_priv *priv); +void il_free_traffic_mem(struct il_priv *priv); +void il_reset_traffic_log(struct il_priv *priv); +void il_dbg_log_tx_data_frame(struct il_priv *priv, u16 length, struct ieee80211_hdr *header); -void iwl_legacy_dbg_log_rx_data_frame(struct iwl_priv *priv, +void il_dbg_log_rx_data_frame(struct il_priv *priv, u16 length, struct ieee80211_hdr *header); -const char *iwl_legacy_get_mgmt_string(int cmd); -const char *iwl_legacy_get_ctrl_string(int cmd); -void iwl_legacy_clear_traffic_stats(struct iwl_priv *priv); -void iwl_legacy_update_stats(struct iwl_priv *priv, bool is_tx, __le16 fc, +const char *il_get_mgmt_string(int cmd); +const char *il_get_ctrl_string(int cmd); +void il_clear_traffic_stats(struct il_priv *priv); +void il_update_stats(struct il_priv *priv, bool is_tx, __le16 fc, u16 len); #else -static inline int iwl_legacy_alloc_traffic_mem(struct iwl_priv *priv) +static inline int il_alloc_traffic_mem(struct il_priv *priv) { return 0; } -static inline void iwl_legacy_free_traffic_mem(struct iwl_priv *priv) +static inline void il_free_traffic_mem(struct il_priv *priv) { } -static inline void iwl_legacy_reset_traffic_log(struct iwl_priv *priv) +static inline void il_reset_traffic_log(struct il_priv *priv) { } -static inline void iwl_legacy_dbg_log_tx_data_frame(struct iwl_priv *priv, +static inline void il_dbg_log_tx_data_frame(struct il_priv *priv, u16 length, struct ieee80211_hdr *header) { } -static inline void iwl_legacy_dbg_log_rx_data_frame(struct iwl_priv *priv, +static inline void il_dbg_log_rx_data_frame(struct il_priv *priv, u16 length, struct ieee80211_hdr *header) { } -static inline void iwl_legacy_update_stats(struct iwl_priv *priv, bool is_tx, +static inline void il_update_stats(struct il_priv *priv, bool is_tx, __le16 fc, u16 len) { } @@ -369,83 +369,83 @@ static inline void iwl_legacy_update_stats(struct iwl_priv *priv, bool is_tx, /***************************************************** * RX handlers. * **************************************************/ -void iwl_legacy_rx_pm_sleep_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); -void iwl_legacy_rx_pm_debug_statistics_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); -void iwl_legacy_rx_reply_error(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); +void il_rx_pm_sleep_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); +void il_rx_pm_debug_statistics_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); +void il_rx_reply_error(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); /***************************************************** * RX ******************************************************/ -void iwl_legacy_cmd_queue_unmap(struct iwl_priv *priv); -void iwl_legacy_cmd_queue_free(struct iwl_priv *priv); -int iwl_legacy_rx_queue_alloc(struct iwl_priv *priv); -void iwl_legacy_rx_queue_update_write_ptr(struct iwl_priv *priv, - struct iwl_rx_queue *q); -int iwl_legacy_rx_queue_space(const struct iwl_rx_queue *q); -void iwl_legacy_tx_cmd_complete(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); +void il_cmd_queue_unmap(struct il_priv *priv); +void il_cmd_queue_free(struct il_priv *priv); +int il_rx_queue_alloc(struct il_priv *priv); +void il_rx_queue_update_write_ptr(struct il_priv *priv, + struct il_rx_queue *q); +int il_rx_queue_space(const struct il_rx_queue *q); +void il_tx_cmd_complete(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); /* Handlers */ -void iwl_legacy_rx_spectrum_measure_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); -void iwl_legacy_recover_from_statistics(struct iwl_priv *priv, - struct iwl_rx_packet *pkt); -void iwl_legacy_chswitch_done(struct iwl_priv *priv, bool is_success); -void iwl_legacy_rx_csa(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb); +void il_rx_spectrum_measure_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); +void il_recover_from_statistics(struct il_priv *priv, + struct il_rx_packet *pkt); +void il_chswitch_done(struct il_priv *priv, bool is_success); +void il_rx_csa(struct il_priv *priv, struct il_rx_mem_buffer *rxb); /* TX helpers */ /***************************************************** * TX ******************************************************/ -void iwl_legacy_txq_update_write_ptr(struct iwl_priv *priv, - struct iwl_tx_queue *txq); -int iwl_legacy_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq, +void il_txq_update_write_ptr(struct il_priv *priv, + struct il_tx_queue *txq); +int il_tx_queue_init(struct il_priv *priv, struct il_tx_queue *txq, int slots_num, u32 txq_id); -void iwl_legacy_tx_queue_reset(struct iwl_priv *priv, - struct iwl_tx_queue *txq, +void il_tx_queue_reset(struct il_priv *priv, + struct il_tx_queue *txq, int slots_num, u32 txq_id); -void iwl_legacy_tx_queue_unmap(struct iwl_priv *priv, int txq_id); -void iwl_legacy_tx_queue_free(struct iwl_priv *priv, int txq_id); -void iwl_legacy_setup_watchdog(struct iwl_priv *priv); +void il_tx_queue_unmap(struct il_priv *priv, int txq_id); +void il_tx_queue_free(struct il_priv *priv, int txq_id); +void il_setup_watchdog(struct il_priv *priv); /***************************************************** * TX power ****************************************************/ -int iwl_legacy_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force); +int il_set_tx_power(struct il_priv *priv, s8 tx_power, bool force); /******************************************************************************* * Rate ******************************************************************************/ -u8 iwl_legacy_get_lowest_plcp(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); +u8 il_get_lowest_plcp(struct il_priv *priv, + struct il_rxon_context *ctx); /******************************************************************************* * Scanning ******************************************************************************/ -void iwl_legacy_init_scan_params(struct iwl_priv *priv); -int iwl_legacy_scan_cancel(struct iwl_priv *priv); -int iwl_legacy_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms); -void iwl_legacy_force_scan_end(struct iwl_priv *priv); -int iwl_legacy_mac_hw_scan(struct ieee80211_hw *hw, +void il_init_scan_params(struct il_priv *priv); +int il_scan_cancel(struct il_priv *priv); +int il_scan_cancel_timeout(struct il_priv *priv, unsigned long ms); +void il_force_scan_end(struct il_priv *priv); +int il_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct cfg80211_scan_request *req); -void iwl_legacy_internal_short_hw_scan(struct iwl_priv *priv); -int iwl_legacy_force_reset(struct iwl_priv *priv, bool external); -u16 iwl_legacy_fill_probe_req(struct iwl_priv *priv, +void il_internal_short_hw_scan(struct il_priv *priv); +int il_force_reset(struct il_priv *priv, bool external); +u16 il_fill_probe_req(struct il_priv *priv, struct ieee80211_mgmt *frame, const u8 *ta, const u8 *ie, int ie_len, int left); -void iwl_legacy_setup_rx_scan_handlers(struct iwl_priv *priv); -u16 iwl_legacy_get_active_dwell_time(struct iwl_priv *priv, +void il_setup_rx_scan_handlers(struct il_priv *priv); +u16 il_get_active_dwell_time(struct il_priv *priv, enum ieee80211_band band, u8 n_probes); -u16 iwl_legacy_get_passive_dwell_time(struct iwl_priv *priv, +u16 il_get_passive_dwell_time(struct il_priv *priv, enum ieee80211_band band, struct ieee80211_vif *vif); -void iwl_legacy_setup_scan_deferred_work(struct iwl_priv *priv); -void iwl_legacy_cancel_scan_deferred_work(struct iwl_priv *priv); +void il_setup_scan_deferred_work(struct il_priv *priv); +void il_cancel_scan_deferred_work(struct il_priv *priv); /* For faster active scanning, scan will move to the next channel if fewer than * PLCP_QUIET_THRESH packets are heard on this channel within @@ -453,35 +453,35 @@ void iwl_legacy_cancel_scan_deferred_work(struct iwl_priv *priv); * time if it's a quiet channel (nothing responded to our probe, and there's * no other traffic). * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */ -#define IWL_ACTIVE_QUIET_TIME cpu_to_le16(10) /* msec */ -#define IWL_PLCP_QUIET_THRESH cpu_to_le16(1) /* packets */ +#define IL_ACTIVE_QUIET_TIME cpu_to_le16(10) /* msec */ +#define IL_PLCP_QUIET_THRESH cpu_to_le16(1) /* packets */ -#define IWL_SCAN_CHECK_WATCHDOG (HZ * 7) +#define IL_SCAN_CHECK_WATCHDOG (HZ * 7) /***************************************************** * S e n d i n g H o s t C o m m a n d s * *****************************************************/ -const char *iwl_legacy_get_cmd_string(u8 cmd); -int __must_check iwl_legacy_send_cmd_sync(struct iwl_priv *priv, - struct iwl_host_cmd *cmd); -int iwl_legacy_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd); -int __must_check iwl_legacy_send_cmd_pdu(struct iwl_priv *priv, u8 id, +const char *il_get_cmd_string(u8 cmd); +int __must_check il_send_cmd_sync(struct il_priv *priv, + struct il_host_cmd *cmd); +int il_send_cmd(struct il_priv *priv, struct il_host_cmd *cmd); +int __must_check il_send_cmd_pdu(struct il_priv *priv, u8 id, u16 len, const void *data); -int iwl_legacy_send_cmd_pdu_async(struct iwl_priv *priv, u8 id, u16 len, +int il_send_cmd_pdu_async(struct il_priv *priv, u8 id, u16 len, const void *data, - void (*callback)(struct iwl_priv *priv, - struct iwl_device_cmd *cmd, - struct iwl_rx_packet *pkt)); + void (*callback)(struct il_priv *priv, + struct il_device_cmd *cmd, + struct il_rx_packet *pkt)); -int iwl_legacy_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd); +int il_enqueue_hcmd(struct il_priv *priv, struct il_host_cmd *cmd); /***************************************************** * PCI * *****************************************************/ -static inline u16 iwl_legacy_pcie_link_ctl(struct iwl_priv *priv) +static inline u16 il_pcie_link_ctl(struct il_priv *priv) { int pos; u16 pci_lnk_ctl; @@ -490,46 +490,46 @@ static inline u16 iwl_legacy_pcie_link_ctl(struct iwl_priv *priv) return pci_lnk_ctl; } -void iwl_legacy_bg_watchdog(unsigned long data); -u32 iwl_legacy_usecs_to_beacons(struct iwl_priv *priv, +void il_bg_watchdog(unsigned long data); +u32 il_usecs_to_beacons(struct il_priv *priv, u32 usec, u32 beacon_interval); -__le32 iwl_legacy_add_beacon_time(struct iwl_priv *priv, u32 base, +__le32 il_add_beacon_time(struct il_priv *priv, u32 base, u32 addon, u32 beacon_interval); #ifdef CONFIG_PM -int iwl_legacy_pci_suspend(struct device *device); -int iwl_legacy_pci_resume(struct device *device); -extern const struct dev_pm_ops iwl_legacy_pm_ops; +int il_pci_suspend(struct device *device); +int il_pci_resume(struct device *device); +extern const struct dev_pm_ops il_pm_ops; -#define IWL_LEGACY_PM_OPS (&iwl_legacy_pm_ops) +#define IL_LEGACY_PM_OPS (&il_pm_ops) #else /* !CONFIG_PM */ -#define IWL_LEGACY_PM_OPS NULL +#define IL_LEGACY_PM_OPS NULL #endif /* !CONFIG_PM */ /***************************************************** * Error Handling Debugging ******************************************************/ -void iwl4965_dump_nic_error_log(struct iwl_priv *priv); +void il4965_dump_nic_error_log(struct il_priv *priv); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -void iwl_legacy_print_rx_config_cmd(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); +void il_print_rx_config_cmd(struct il_priv *priv, + struct il_rxon_context *ctx); #else -static inline void iwl_legacy_print_rx_config_cmd(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +static inline void il_print_rx_config_cmd(struct il_priv *priv, + struct il_rxon_context *ctx) { } #endif -void iwl_legacy_clear_isr_stats(struct iwl_priv *priv); +void il_clear_isr_stats(struct il_priv *priv); /***************************************************** * GEOS ******************************************************/ -int iwl_legacy_init_geos(struct iwl_priv *priv); -void iwl_legacy_free_geos(struct iwl_priv *priv); +int il_init_geos(struct il_priv *priv); +void il_free_geos(struct il_priv *priv); /*************** DRIVER STATUS FUNCTIONS *****/ @@ -552,7 +552,7 @@ void iwl_legacy_free_geos(struct iwl_priv *priv); #define STATUS_FW_ERROR 17 #define STATUS_CHANNEL_SWITCH_PENDING 18 -static inline int iwl_legacy_is_ready(struct iwl_priv *priv) +static inline int il_is_ready(struct il_priv *priv) { /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are * set but EXIT_PENDING is not */ @@ -561,76 +561,76 @@ static inline int iwl_legacy_is_ready(struct iwl_priv *priv) !test_bit(STATUS_EXIT_PENDING, &priv->status); } -static inline int iwl_legacy_is_alive(struct iwl_priv *priv) +static inline int il_is_alive(struct il_priv *priv) { return test_bit(STATUS_ALIVE, &priv->status); } -static inline int iwl_legacy_is_init(struct iwl_priv *priv) +static inline int il_is_init(struct il_priv *priv) { return test_bit(STATUS_INIT, &priv->status); } -static inline int iwl_legacy_is_rfkill_hw(struct iwl_priv *priv) +static inline int il_is_rfkill_hw(struct il_priv *priv) { return test_bit(STATUS_RF_KILL_HW, &priv->status); } -static inline int iwl_legacy_is_rfkill(struct iwl_priv *priv) +static inline int il_is_rfkill(struct il_priv *priv) { - return iwl_legacy_is_rfkill_hw(priv); + return il_is_rfkill_hw(priv); } -static inline int iwl_legacy_is_ctkill(struct iwl_priv *priv) +static inline int il_is_ctkill(struct il_priv *priv) { return test_bit(STATUS_CT_KILL, &priv->status); } -static inline int iwl_legacy_is_ready_rf(struct iwl_priv *priv) +static inline int il_is_ready_rf(struct il_priv *priv) { - if (iwl_legacy_is_rfkill(priv)) + if (il_is_rfkill(priv)) return 0; - return iwl_legacy_is_ready(priv); + return il_is_ready(priv); } -extern void iwl_legacy_send_bt_config(struct iwl_priv *priv); -extern int iwl_legacy_send_statistics_request(struct iwl_priv *priv, +extern void il_send_bt_config(struct il_priv *priv); +extern int il_send_statistics_request(struct il_priv *priv, u8 flags, bool clear); -void iwl_legacy_apm_stop(struct iwl_priv *priv); -int iwl_legacy_apm_init(struct iwl_priv *priv); +void il_apm_stop(struct il_priv *priv); +int il_apm_init(struct il_priv *priv); -int iwl_legacy_send_rxon_timing(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); -static inline int iwl_legacy_send_rxon_assoc(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +int il_send_rxon_timing(struct il_priv *priv, + struct il_rxon_context *ctx); +static inline int il_send_rxon_assoc(struct il_priv *priv, + struct il_rxon_context *ctx) { return priv->cfg->ops->hcmd->rxon_assoc(priv, ctx); } -static inline int iwl_legacy_commit_rxon(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +static inline int il_commit_rxon(struct il_priv *priv, + struct il_rxon_context *ctx) { return priv->cfg->ops->hcmd->commit_rxon(priv, ctx); } -static inline const struct ieee80211_supported_band *iwl_get_hw_mode( - struct iwl_priv *priv, enum ieee80211_band band) +static inline const struct ieee80211_supported_band *il_get_hw_mode( + struct il_priv *priv, enum ieee80211_band band) { return priv->hw->wiphy->bands[band]; } /* mac80211 handlers */ -int iwl_legacy_mac_config(struct ieee80211_hw *hw, u32 changed); -void iwl_legacy_mac_reset_tsf(struct ieee80211_hw *hw, +int il_mac_config(struct ieee80211_hw *hw, u32 changed); +void il_mac_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif); -void iwl_legacy_mac_bss_info_changed(struct ieee80211_hw *hw, +void il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_bss_conf *bss_conf, u32 changes); -void iwl_legacy_tx_cmd_protection(struct iwl_priv *priv, +void il_tx_cmd_protection(struct il_priv *priv, struct ieee80211_tx_info *info, __le16 fc, __le32 *tx_flags); -irqreturn_t iwl_legacy_isr(int irq, void *data); +irqreturn_t il_isr(int irq, void *data); -#endif /* __iwl_legacy_core_h__ */ +#endif /* __il_core_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-csr.h b/drivers/net/wireless/iwlegacy/iwl-csr.h index 668a9616c269..24b71ae79040 100644 --- a/drivers/net/wireless/iwlegacy/iwl-csr.h +++ b/drivers/net/wireless/iwlegacy/iwl-csr.h @@ -60,8 +60,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ -#ifndef __iwl_legacy_csr_h__ -#define __iwl_legacy_csr_h__ +#ifndef __il_csr_h__ +#define __il_csr_h__ /* * CSR (control and status registers) * @@ -70,9 +70,9 @@ * low power states due to driver-invoked device resets * (e.g. CSR_RESET_REG_FLAG_SW_RESET) or uCode-driven power-saving modes. * - * Use iwl_write32() and iwl_read32() family to access these registers; + * Use il_write32() and il_read32() family to access these registers; * these provide simple PCI bus access, without waking up the MAC. - * Do not use iwl_legacy_write_direct32() family for these registers; + * Do not use il_write_direct32() family for these registers; * no need to "grab nic access" via CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ. * The MAC (uCode processor, etc.) does not need to be powered up for accessing * the CSR registers. @@ -91,7 +91,7 @@ #define CSR_RESET (CSR_BASE+0x020) /* busmaster enable, NMI, etc*/ #define CSR_GP_CNTRL (CSR_BASE+0x024) -/* 2nd byte of CSR_INT_COALESCING, not accessible via iwl_write32()! */ +/* 2nd byte of CSR_INT_COALESCING, not accessible via il_write32()! */ #define CSR_INT_PERIODIC_REG (CSR_BASE+0x005) /* @@ -368,13 +368,13 @@ * to indirectly access device's internal memory or registers that * may be powered-down. * - * Use iwl_legacy_write_direct32()/iwl_legacy_read_direct32() family + * Use il_write_direct32()/il_read_direct32() family * for these registers; * host must "grab nic access" via CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ * to make sure the MAC (uCode processor, etc.) is powered up for accessing * internal resources. * - * Do not use iwl_write32()/iwl_read32() family to access these registers; + * Do not use il_write32()/il_read32() family to access these registers; * these provide only simple PCI bus access, without waking up the MAC. */ #define HBUS_BASE (0x400) @@ -419,4 +419,4 @@ */ #define HBUS_TARG_WRPTR (HBUS_BASE+0x060) -#endif /* !__iwl_legacy_csr_h__ */ +#endif /* !__il_csr_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-debug.h b/drivers/net/wireless/iwlegacy/iwl-debug.h index ae13112701bf..1bbad766aac7 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debug.h +++ b/drivers/net/wireless/iwlegacy/iwl-debug.h @@ -26,65 +26,65 @@ * *****************************************************************************/ -#ifndef __iwl_legacy_debug_h__ -#define __iwl_legacy_debug_h__ +#ifndef __il_debug_h__ +#define __il_debug_h__ -struct iwl_priv; +struct il_priv; extern u32 iwlegacy_debug_level; -#define IWL_ERR(p, f, a...) dev_err(&((p)->pci_dev->dev), f, ## a) -#define IWL_WARN(p, f, a...) dev_warn(&((p)->pci_dev->dev), f, ## a) -#define IWL_INFO(p, f, a...) dev_info(&((p)->pci_dev->dev), f, ## a) -#define IWL_CRIT(p, f, a...) dev_crit(&((p)->pci_dev->dev), f, ## a) +#define IL_ERR(p, f, a...) dev_err(&((p)->pci_dev->dev), f, ## a) +#define IL_WARN(p, f, a...) dev_warn(&((p)->pci_dev->dev), f, ## a) +#define IL_INFO(p, f, a...) dev_info(&((p)->pci_dev->dev), f, ## a) +#define IL_CRIT(p, f, a...) dev_crit(&((p)->pci_dev->dev), f, ## a) -#define iwl_print_hex_error(priv, p, len) \ +#define il_print_hex_error(priv, p, len) \ do { \ print_hex_dump(KERN_ERR, "iwl data: ", \ DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ } while (0) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -#define IWL_DEBUG(__priv, level, fmt, args...) \ +#define IL_DEBUG(__priv, level, fmt, args...) \ do { \ - if (iwl_legacy_get_debug_level(__priv) & (level)) \ + if (il_get_debug_level(__priv) & (level)) \ dev_printk(KERN_ERR, &(__priv->hw->wiphy->dev), \ "%c %s " fmt, in_interrupt() ? 'I' : 'U', \ __func__ , ## args); \ } while (0) -#define IWL_DEBUG_LIMIT(__priv, level, fmt, args...) \ +#define IL_DEBUG_LIMIT(__priv, level, fmt, args...) \ do { \ - if ((iwl_legacy_get_debug_level(__priv) & (level)) && net_ratelimit()) \ + if ((il_get_debug_level(__priv) & (level)) && net_ratelimit()) \ dev_printk(KERN_ERR, &(__priv->hw->wiphy->dev), \ "%c %s " fmt, in_interrupt() ? 'I' : 'U', \ __func__ , ## args); \ } while (0) -#define iwl_print_hex_dump(priv, level, p, len) \ +#define il_print_hex_dump(priv, level, p, len) \ do { \ - if (iwl_legacy_get_debug_level(priv) & level) \ + if (il_get_debug_level(priv) & level) \ print_hex_dump(KERN_DEBUG, "iwl data: ", \ DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ } while (0) #else -#define IWL_DEBUG(__priv, level, fmt, args...) -#define IWL_DEBUG_LIMIT(__priv, level, fmt, args...) -static inline void iwl_print_hex_dump(struct iwl_priv *priv, int level, +#define IL_DEBUG(__priv, level, fmt, args...) +#define IL_DEBUG_LIMIT(__priv, level, fmt, args...) +static inline void il_print_hex_dump(struct il_priv *priv, int level, const void *p, u32 len) {} #endif /* CONFIG_IWLWIFI_LEGACY_DEBUG */ #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS -int iwl_legacy_dbgfs_register(struct iwl_priv *priv, const char *name); -void iwl_legacy_dbgfs_unregister(struct iwl_priv *priv); +int il_dbgfs_register(struct il_priv *priv, const char *name); +void il_dbgfs_unregister(struct il_priv *priv); #else static inline int -iwl_legacy_dbgfs_register(struct iwl_priv *priv, const char *name) +il_dbgfs_register(struct il_priv *priv, const char *name) { return 0; } -static inline void iwl_legacy_dbgfs_unregister(struct iwl_priv *priv) +static inline void il_dbgfs_unregister(struct il_priv *priv) { } #endif /* CONFIG_IWLWIFI_LEGACY_DEBUGFS */ @@ -95,12 +95,12 @@ static inline void iwl_legacy_dbgfs_unregister(struct iwl_priv *priv) * If you are defining a new debug classification, simply add it to the #define * list here in the form of * - * #define IWL_DL_xxxx VALUE + * #define IL_DL_xxxx VALUE * * where xxxx should be the name of the classification (for example, WEP). * - * You then need to either add a IWL_xxxx_DEBUG() macro definition for your - * classification, or use IWL_DEBUG(IWL_DL_xxxx, ...) whenever you want + * You then need to either add a IL_xxxx_DEBUG() macro definition for your + * classification, or use IL_DEBUG(IL_DL_xxxx, ...) whenever you want * to send output to that classification. * * The active debug levels can be accessed via files @@ -113,86 +113,86 @@ static inline void iwl_legacy_dbgfs_unregister(struct iwl_priv *priv) */ /* 0x0000000F - 0x00000001 */ -#define IWL_DL_INFO (1 << 0) -#define IWL_DL_MAC80211 (1 << 1) -#define IWL_DL_HCMD (1 << 2) -#define IWL_DL_STATE (1 << 3) +#define IL_DL_INFO (1 << 0) +#define IL_DL_MAC80211 (1 << 1) +#define IL_DL_HCMD (1 << 2) +#define IL_DL_STATE (1 << 3) /* 0x000000F0 - 0x00000010 */ -#define IWL_DL_MACDUMP (1 << 4) -#define IWL_DL_HCMD_DUMP (1 << 5) -#define IWL_DL_EEPROM (1 << 6) -#define IWL_DL_RADIO (1 << 7) +#define IL_DL_MACDUMP (1 << 4) +#define IL_DL_HCMD_DUMP (1 << 5) +#define IL_DL_EEPROM (1 << 6) +#define IL_DL_RADIO (1 << 7) /* 0x00000F00 - 0x00000100 */ -#define IWL_DL_POWER (1 << 8) -#define IWL_DL_TEMP (1 << 9) -#define IWL_DL_NOTIF (1 << 10) -#define IWL_DL_SCAN (1 << 11) +#define IL_DL_POWER (1 << 8) +#define IL_DL_TEMP (1 << 9) +#define IL_DL_NOTIF (1 << 10) +#define IL_DL_SCAN (1 << 11) /* 0x0000F000 - 0x00001000 */ -#define IWL_DL_ASSOC (1 << 12) -#define IWL_DL_DROP (1 << 13) -#define IWL_DL_TXPOWER (1 << 14) -#define IWL_DL_AP (1 << 15) +#define IL_DL_ASSOC (1 << 12) +#define IL_DL_DROP (1 << 13) +#define IL_DL_TXPOWER (1 << 14) +#define IL_DL_AP (1 << 15) /* 0x000F0000 - 0x00010000 */ -#define IWL_DL_FW (1 << 16) -#define IWL_DL_RF_KILL (1 << 17) -#define IWL_DL_FW_ERRORS (1 << 18) -#define IWL_DL_LED (1 << 19) +#define IL_DL_FW (1 << 16) +#define IL_DL_RF_KILL (1 << 17) +#define IL_DL_FW_ERRORS (1 << 18) +#define IL_DL_LED (1 << 19) /* 0x00F00000 - 0x00100000 */ -#define IWL_DL_RATE (1 << 20) -#define IWL_DL_CALIB (1 << 21) -#define IWL_DL_WEP (1 << 22) -#define IWL_DL_TX (1 << 23) +#define IL_DL_RATE (1 << 20) +#define IL_DL_CALIB (1 << 21) +#define IL_DL_WEP (1 << 22) +#define IL_DL_TX (1 << 23) /* 0x0F000000 - 0x01000000 */ -#define IWL_DL_RX (1 << 24) -#define IWL_DL_ISR (1 << 25) -#define IWL_DL_HT (1 << 26) -#define IWL_DL_IO (1 << 27) +#define IL_DL_RX (1 << 24) +#define IL_DL_ISR (1 << 25) +#define IL_DL_HT (1 << 26) +#define IL_DL_IO (1 << 27) /* 0xF0000000 - 0x10000000 */ -#define IWL_DL_11H (1 << 28) -#define IWL_DL_STATS (1 << 29) -#define IWL_DL_TX_REPLY (1 << 30) -#define IWL_DL_QOS (1 << 31) +#define IL_DL_11H (1 << 28) +#define IL_DL_STATS (1 << 29) +#define IL_DL_TX_REPLY (1 << 30) +#define IL_DL_QOS (1 << 31) -#define IWL_DEBUG_INFO(p, f, a...) IWL_DEBUG(p, IWL_DL_INFO, f, ## a) -#define IWL_DEBUG_MAC80211(p, f, a...) IWL_DEBUG(p, IWL_DL_MAC80211, f, ## a) -#define IWL_DEBUG_MACDUMP(p, f, a...) IWL_DEBUG(p, IWL_DL_MACDUMP, f, ## a) -#define IWL_DEBUG_TEMP(p, f, a...) IWL_DEBUG(p, IWL_DL_TEMP, f, ## a) -#define IWL_DEBUG_SCAN(p, f, a...) IWL_DEBUG(p, IWL_DL_SCAN, f, ## a) -#define IWL_DEBUG_RX(p, f, a...) IWL_DEBUG(p, IWL_DL_RX, f, ## a) -#define IWL_DEBUG_TX(p, f, a...) IWL_DEBUG(p, IWL_DL_TX, f, ## a) -#define IWL_DEBUG_ISR(p, f, a...) IWL_DEBUG(p, IWL_DL_ISR, f, ## a) -#define IWL_DEBUG_LED(p, f, a...) IWL_DEBUG(p, IWL_DL_LED, f, ## a) -#define IWL_DEBUG_WEP(p, f, a...) IWL_DEBUG(p, IWL_DL_WEP, f, ## a) -#define IWL_DEBUG_HC(p, f, a...) IWL_DEBUG(p, IWL_DL_HCMD, f, ## a) -#define IWL_DEBUG_HC_DUMP(p, f, a...) IWL_DEBUG(p, IWL_DL_HCMD_DUMP, f, ## a) -#define IWL_DEBUG_EEPROM(p, f, a...) IWL_DEBUG(p, IWL_DL_EEPROM, f, ## a) -#define IWL_DEBUG_CALIB(p, f, a...) IWL_DEBUG(p, IWL_DL_CALIB, f, ## a) -#define IWL_DEBUG_FW(p, f, a...) IWL_DEBUG(p, IWL_DL_FW, f, ## a) -#define IWL_DEBUG_RF_KILL(p, f, a...) IWL_DEBUG(p, IWL_DL_RF_KILL, f, ## a) -#define IWL_DEBUG_DROP(p, f, a...) IWL_DEBUG(p, IWL_DL_DROP, f, ## a) -#define IWL_DEBUG_DROP_LIMIT(p, f, a...) \ - IWL_DEBUG_LIMIT(p, IWL_DL_DROP, f, ## a) -#define IWL_DEBUG_AP(p, f, a...) IWL_DEBUG(p, IWL_DL_AP, f, ## a) -#define IWL_DEBUG_TXPOWER(p, f, a...) IWL_DEBUG(p, IWL_DL_TXPOWER, f, ## a) -#define IWL_DEBUG_IO(p, f, a...) IWL_DEBUG(p, IWL_DL_IO, f, ## a) -#define IWL_DEBUG_RATE(p, f, a...) IWL_DEBUG(p, IWL_DL_RATE, f, ## a) -#define IWL_DEBUG_RATE_LIMIT(p, f, a...) \ - IWL_DEBUG_LIMIT(p, IWL_DL_RATE, f, ## a) -#define IWL_DEBUG_NOTIF(p, f, a...) IWL_DEBUG(p, IWL_DL_NOTIF, f, ## a) -#define IWL_DEBUG_ASSOC(p, f, a...) \ - IWL_DEBUG(p, IWL_DL_ASSOC | IWL_DL_INFO, f, ## a) -#define IWL_DEBUG_ASSOC_LIMIT(p, f, a...) \ - IWL_DEBUG_LIMIT(p, IWL_DL_ASSOC | IWL_DL_INFO, f, ## a) -#define IWL_DEBUG_HT(p, f, a...) IWL_DEBUG(p, IWL_DL_HT, f, ## a) -#define IWL_DEBUG_STATS(p, f, a...) IWL_DEBUG(p, IWL_DL_STATS, f, ## a) -#define IWL_DEBUG_STATS_LIMIT(p, f, a...) \ - IWL_DEBUG_LIMIT(p, IWL_DL_STATS, f, ## a) -#define IWL_DEBUG_TX_REPLY(p, f, a...) IWL_DEBUG(p, IWL_DL_TX_REPLY, f, ## a) -#define IWL_DEBUG_TX_REPLY_LIMIT(p, f, a...) \ - IWL_DEBUG_LIMIT(p, IWL_DL_TX_REPLY, f, ## a) -#define IWL_DEBUG_QOS(p, f, a...) IWL_DEBUG(p, IWL_DL_QOS, f, ## a) -#define IWL_DEBUG_RADIO(p, f, a...) IWL_DEBUG(p, IWL_DL_RADIO, f, ## a) -#define IWL_DEBUG_POWER(p, f, a...) IWL_DEBUG(p, IWL_DL_POWER, f, ## a) -#define IWL_DEBUG_11H(p, f, a...) IWL_DEBUG(p, IWL_DL_11H, f, ## a) +#define IL_DEBUG_INFO(p, f, a...) IL_DEBUG(p, IL_DL_INFO, f, ## a) +#define IL_DEBUG_MAC80211(p, f, a...) IL_DEBUG(p, IL_DL_MAC80211, f, ## a) +#define IL_DEBUG_MACDUMP(p, f, a...) IL_DEBUG(p, IL_DL_MACDUMP, f, ## a) +#define IL_DEBUG_TEMP(p, f, a...) IL_DEBUG(p, IL_DL_TEMP, f, ## a) +#define IL_DEBUG_SCAN(p, f, a...) IL_DEBUG(p, IL_DL_SCAN, f, ## a) +#define IL_DEBUG_RX(p, f, a...) IL_DEBUG(p, IL_DL_RX, f, ## a) +#define IL_DEBUG_TX(p, f, a...) IL_DEBUG(p, IL_DL_TX, f, ## a) +#define IL_DEBUG_ISR(p, f, a...) IL_DEBUG(p, IL_DL_ISR, f, ## a) +#define IL_DEBUG_LED(p, f, a...) IL_DEBUG(p, IL_DL_LED, f, ## a) +#define IL_DEBUG_WEP(p, f, a...) IL_DEBUG(p, IL_DL_WEP, f, ## a) +#define IL_DEBUG_HC(p, f, a...) IL_DEBUG(p, IL_DL_HCMD, f, ## a) +#define IL_DEBUG_HC_DUMP(p, f, a...) IL_DEBUG(p, IL_DL_HCMD_DUMP, f, ## a) +#define IL_DEBUG_EEPROM(p, f, a...) IL_DEBUG(p, IL_DL_EEPROM, f, ## a) +#define IL_DEBUG_CALIB(p, f, a...) IL_DEBUG(p, IL_DL_CALIB, f, ## a) +#define IL_DEBUG_FW(p, f, a...) IL_DEBUG(p, IL_DL_FW, f, ## a) +#define IL_DEBUG_RF_KILL(p, f, a...) IL_DEBUG(p, IL_DL_RF_KILL, f, ## a) +#define IL_DEBUG_DROP(p, f, a...) IL_DEBUG(p, IL_DL_DROP, f, ## a) +#define IL_DEBUG_DROP_LIMIT(p, f, a...) \ + IL_DEBUG_LIMIT(p, IL_DL_DROP, f, ## a) +#define IL_DEBUG_AP(p, f, a...) IL_DEBUG(p, IL_DL_AP, f, ## a) +#define IL_DEBUG_TXPOWER(p, f, a...) IL_DEBUG(p, IL_DL_TXPOWER, f, ## a) +#define IL_DEBUG_IO(p, f, a...) IL_DEBUG(p, IL_DL_IO, f, ## a) +#define IL_DEBUG_RATE(p, f, a...) IL_DEBUG(p, IL_DL_RATE, f, ## a) +#define IL_DEBUG_RATE_LIMIT(p, f, a...) \ + IL_DEBUG_LIMIT(p, IL_DL_RATE, f, ## a) +#define IL_DEBUG_NOTIF(p, f, a...) IL_DEBUG(p, IL_DL_NOTIF, f, ## a) +#define IL_DEBUG_ASSOC(p, f, a...) \ + IL_DEBUG(p, IL_DL_ASSOC | IL_DL_INFO, f, ## a) +#define IL_DEBUG_ASSOC_LIMIT(p, f, a...) \ + IL_DEBUG_LIMIT(p, IL_DL_ASSOC | IL_DL_INFO, f, ## a) +#define IL_DEBUG_HT(p, f, a...) IL_DEBUG(p, IL_DL_HT, f, ## a) +#define IL_DEBUG_STATS(p, f, a...) IL_DEBUG(p, IL_DL_STATS, f, ## a) +#define IL_DEBUG_STATS_LIMIT(p, f, a...) \ + IL_DEBUG_LIMIT(p, IL_DL_STATS, f, ## a) +#define IL_DEBUG_TX_REPLY(p, f, a...) IL_DEBUG(p, IL_DL_TX_REPLY, f, ## a) +#define IL_DEBUG_TX_REPLY_LIMIT(p, f, a...) \ + IL_DEBUG_LIMIT(p, IL_DL_TX_REPLY, f, ## a) +#define IL_DEBUG_QOS(p, f, a...) IL_DEBUG(p, IL_DL_QOS, f, ## a) +#define IL_DEBUG_RADIO(p, f, a...) IL_DEBUG(p, IL_DL_RADIO, f, ## a) +#define IL_DEBUG_POWER(p, f, a...) IL_DEBUG(p, IL_DL_POWER, f, ## a) +#define IL_DEBUG_11H(p, f, a...) IL_DEBUG(p, IL_DL_11H, f, ## a) #endif diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index 996996a71657..057dec5b178c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -37,7 +37,7 @@ /* create and remove of files */ #define DEBUGFS_ADD_FILE(name, parent, mode) do { \ if (!debugfs_create_file(#name, mode, parent, priv, \ - &iwl_legacy_dbgfs_##name##_ops)) \ + &il_dbgfs_##name##_ops)) \ goto err; \ } while (0) @@ -59,18 +59,18 @@ /* file operation */ #define DEBUGFS_READ_FUNC(name) \ -static ssize_t iwl_legacy_dbgfs_##name##_read(struct file *file, \ +static ssize_t il_dbgfs_##name##_read(struct file *file, \ char __user *user_buf, \ size_t count, loff_t *ppos); #define DEBUGFS_WRITE_FUNC(name) \ -static ssize_t iwl_legacy_dbgfs_##name##_write(struct file *file, \ +static ssize_t il_dbgfs_##name##_write(struct file *file, \ const char __user *user_buf, \ size_t count, loff_t *ppos); static int -iwl_legacy_dbgfs_open_file_generic(struct inode *inode, struct file *file) +il_dbgfs_open_file_generic(struct inode *inode, struct file *file) { file->private_data = inode->i_private; return 0; @@ -78,35 +78,35 @@ iwl_legacy_dbgfs_open_file_generic(struct inode *inode, struct file *file) #define DEBUGFS_READ_FILE_OPS(name) \ DEBUGFS_READ_FUNC(name); \ -static const struct file_operations iwl_legacy_dbgfs_##name##_ops = { \ - .read = iwl_legacy_dbgfs_##name##_read, \ - .open = iwl_legacy_dbgfs_open_file_generic, \ +static const struct file_operations il_dbgfs_##name##_ops = { \ + .read = il_dbgfs_##name##_read, \ + .open = il_dbgfs_open_file_generic, \ .llseek = generic_file_llseek, \ }; #define DEBUGFS_WRITE_FILE_OPS(name) \ DEBUGFS_WRITE_FUNC(name); \ -static const struct file_operations iwl_legacy_dbgfs_##name##_ops = { \ - .write = iwl_legacy_dbgfs_##name##_write, \ - .open = iwl_legacy_dbgfs_open_file_generic, \ +static const struct file_operations il_dbgfs_##name##_ops = { \ + .write = il_dbgfs_##name##_write, \ + .open = il_dbgfs_open_file_generic, \ .llseek = generic_file_llseek, \ }; #define DEBUGFS_READ_WRITE_FILE_OPS(name) \ DEBUGFS_READ_FUNC(name); \ DEBUGFS_WRITE_FUNC(name); \ -static const struct file_operations iwl_legacy_dbgfs_##name##_ops = { \ - .write = iwl_legacy_dbgfs_##name##_write, \ - .read = iwl_legacy_dbgfs_##name##_read, \ - .open = iwl_legacy_dbgfs_open_file_generic, \ +static const struct file_operations il_dbgfs_##name##_ops = { \ + .write = il_dbgfs_##name##_write, \ + .read = il_dbgfs_##name##_read, \ + .open = il_dbgfs_open_file_generic, \ .llseek = generic_file_llseek, \ }; -static ssize_t iwl_legacy_dbgfs_tx_statistics_read(struct file *file, +static ssize_t il_dbgfs_tx_statistics_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char *buf; int pos = 0; @@ -121,14 +121,14 @@ static ssize_t iwl_legacy_dbgfs_tx_statistics_read(struct file *file, for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { pos += scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", - iwl_legacy_get_mgmt_string(cnt), + il_get_mgmt_string(cnt), priv->tx_stats.mgmt[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Control\n"); for (cnt = 0; cnt < CONTROL_MAX; cnt++) { pos += scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", - iwl_legacy_get_ctrl_string(cnt), + il_get_ctrl_string(cnt), priv->tx_stats.ctrl[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); @@ -142,11 +142,11 @@ static ssize_t iwl_legacy_dbgfs_tx_statistics_read(struct file *file, } static ssize_t -iwl_legacy_dbgfs_clear_traffic_statistics_write(struct file *file, +il_dbgfs_clear_traffic_statistics_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; u32 clear_flag; char buf[8]; int buf_size; @@ -157,16 +157,16 @@ iwl_legacy_dbgfs_clear_traffic_statistics_write(struct file *file, return -EFAULT; if (sscanf(buf, "%x", &clear_flag) != 1) return -EFAULT; - iwl_legacy_clear_traffic_stats(priv); + il_clear_traffic_stats(priv); return count; } -static ssize_t iwl_legacy_dbgfs_rx_statistics_read(struct file *file, +static ssize_t il_dbgfs_rx_statistics_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char *buf; int pos = 0; int cnt; @@ -181,14 +181,14 @@ static ssize_t iwl_legacy_dbgfs_rx_statistics_read(struct file *file, for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { pos += scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", - iwl_legacy_get_mgmt_string(cnt), + il_get_mgmt_string(cnt), priv->rx_stats.mgmt[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Control:\n"); for (cnt = 0; cnt < CONTROL_MAX; cnt++) { pos += scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", - iwl_legacy_get_ctrl_string(cnt), + il_get_ctrl_string(cnt), priv->rx_stats.ctrl[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); @@ -205,7 +205,7 @@ static ssize_t iwl_legacy_dbgfs_rx_statistics_read(struct file *file, #define BYTE1_MASK 0x000000ff; #define BYTE2_MASK 0x0000ffff; #define BYTE3_MASK 0x00ffffff; -static ssize_t iwl_legacy_dbgfs_sram_read(struct file *file, +static ssize_t il_dbgfs_sram_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { @@ -214,7 +214,7 @@ static ssize_t iwl_legacy_dbgfs_sram_read(struct file *file, ssize_t ret; int i; int pos = 0; - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; size_t bufsz; /* default is to dump the entire data segment */ @@ -234,7 +234,7 @@ static ssize_t iwl_legacy_dbgfs_sram_read(struct file *file, pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n", priv->dbgfs_sram_offset); for (i = priv->dbgfs_sram_len; i > 0; i -= 4) { - val = iwl_legacy_read_targ_mem(priv, priv->dbgfs_sram_offset + \ + val = il_read_targ_mem(priv, priv->dbgfs_sram_offset + \ priv->dbgfs_sram_len - i); if (i < 4) { switch (i) { @@ -260,11 +260,11 @@ static ssize_t iwl_legacy_dbgfs_sram_read(struct file *file, return ret; } -static ssize_t iwl_legacy_dbgfs_sram_write(struct file *file, +static ssize_t il_dbgfs_sram_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char buf[64]; int buf_size; u32 offset, len; @@ -286,11 +286,11 @@ static ssize_t iwl_legacy_dbgfs_sram_write(struct file *file, } static ssize_t -iwl_legacy_dbgfs_stations_read(struct file *file, char __user *user_buf, +il_dbgfs_stations_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; - struct iwl_station_entry *station; + struct il_priv *priv = file->private_data; + struct il_station_entry *station; int max_sta = priv->hw_params.max_stations; char *buf; int i, j, pos = 0; @@ -343,13 +343,13 @@ iwl_legacy_dbgfs_stations_read(struct file *file, char __user *user_buf, return ret; } -static ssize_t iwl_legacy_dbgfs_nvm_read(struct file *file, +static ssize_t il_dbgfs_nvm_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { ssize_t ret; - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0, ofs = 0, buf_size = 0; const u8 *ptr; char *buf; @@ -358,23 +358,23 @@ static ssize_t iwl_legacy_dbgfs_nvm_read(struct file *file, buf_size = 4 * eeprom_len + 256; if (eeprom_len % 16) { - IWL_ERR(priv, "NVM size is not multiple of 16.\n"); + IL_ERR(priv, "NVM size is not multiple of 16.\n"); return -ENODATA; } ptr = priv->eeprom; if (!ptr) { - IWL_ERR(priv, "Invalid EEPROM memory\n"); + IL_ERR(priv, "Invalid EEPROM memory\n"); return -ENOMEM; } /* 4 characters for byte 0xYY */ buf = kzalloc(buf_size, GFP_KERNEL); if (!buf) { - IWL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(priv, "Can not allocate Buffer\n"); return -ENOMEM; } - eeprom_ver = iwl_legacy_eeprom_query16(priv, EEPROM_VERSION); + eeprom_ver = il_eeprom_query16(priv, EEPROM_VERSION); pos += scnprintf(buf + pos, buf_size - pos, "EEPROM " "version: 0x%x\n", eeprom_ver); for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) { @@ -392,10 +392,10 @@ static ssize_t iwl_legacy_dbgfs_nvm_read(struct file *file, } static ssize_t -iwl_legacy_dbgfs_channels_read(struct file *file, char __user *user_buf, +il_dbgfs_channels_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; struct ieee80211_channel *channels = NULL; const struct ieee80211_supported_band *supp_band = NULL; int pos = 0, i, bufsz = PAGE_SIZE; @@ -407,11 +407,11 @@ iwl_legacy_dbgfs_channels_read(struct file *file, char __user *user_buf, buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IWL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(priv, "Can not allocate Buffer\n"); return -ENOMEM; } - supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_2GHZ); + supp_band = il_get_hw_mode(priv, IEEE80211_BAND_2GHZ); if (supp_band) { channels = supp_band->channels; @@ -434,7 +434,7 @@ iwl_legacy_dbgfs_channels_read(struct file *file, char __user *user_buf, IEEE80211_CHAN_PASSIVE_SCAN ? "passive only" : "active/passive"); } - supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ); + supp_band = il_get_hw_mode(priv, IEEE80211_BAND_5GHZ); if (supp_band) { channels = supp_band->channels; @@ -462,11 +462,11 @@ iwl_legacy_dbgfs_channels_read(struct file *file, char __user *user_buf, return ret; } -static ssize_t iwl_legacy_dbgfs_status_read(struct file *file, +static ssize_t il_dbgfs_status_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char buf[512]; int pos = 0; const size_t bufsz = sizeof(buf); @@ -506,11 +506,11 @@ static ssize_t iwl_legacy_dbgfs_status_read(struct file *file, return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t iwl_legacy_dbgfs_interrupt_read(struct file *file, +static ssize_t il_dbgfs_interrupt_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0; int cnt = 0; char *buf; @@ -519,7 +519,7 @@ static ssize_t iwl_legacy_dbgfs_interrupt_read(struct file *file, buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IWL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(priv, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -558,7 +558,7 @@ static ssize_t iwl_legacy_dbgfs_interrupt_read(struct file *file, if (priv->isr_stats.rx_handlers[cnt] > 0) pos += scnprintf(buf + pos, bufsz - pos, "\tRx handler[%36s]:\t\t %u\n", - iwl_legacy_get_cmd_string(cnt), + il_get_cmd_string(cnt), priv->isr_stats.rx_handlers[cnt]); } @@ -573,11 +573,11 @@ static ssize_t iwl_legacy_dbgfs_interrupt_read(struct file *file, return ret; } -static ssize_t iwl_legacy_dbgfs_interrupt_write(struct file *file, +static ssize_t il_dbgfs_interrupt_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char buf[8]; int buf_size; u32 reset_flag; @@ -589,19 +589,19 @@ static ssize_t iwl_legacy_dbgfs_interrupt_write(struct file *file, if (sscanf(buf, "%x", &reset_flag) != 1) return -EFAULT; if (reset_flag == 0) - iwl_legacy_clear_isr_stats(priv); + il_clear_isr_stats(priv); return count; } static ssize_t -iwl_legacy_dbgfs_qos_read(struct file *file, char __user *user_buf, +il_dbgfs_qos_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; - struct iwl_rxon_context *ctx; + struct il_priv *priv = file->private_data; + struct il_rxon_context *ctx; int pos = 0, i; - char buf[256 * NUM_IWL_RXON_CTX]; + char buf[256 * NUM_IL_RXON_CTX]; const size_t bufsz = sizeof(buf); for_each_context(priv, ctx) { @@ -622,11 +622,11 @@ iwl_legacy_dbgfs_qos_read(struct file *file, char __user *user_buf, return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t iwl_legacy_dbgfs_disable_ht40_write(struct file *file, +static ssize_t il_dbgfs_disable_ht40_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char buf[8]; int buf_size; int ht40; @@ -637,10 +637,10 @@ static ssize_t iwl_legacy_dbgfs_disable_ht40_write(struct file *file, return -EFAULT; if (sscanf(buf, "%d", &ht40) != 1) return -EFAULT; - if (!iwl_legacy_is_any_associated(priv)) + if (!il_is_any_associated(priv)) priv->disable_ht40 = ht40 ? true : false; else { - IWL_ERR(priv, "Sta associated with AP - " + IL_ERR(priv, "Sta associated with AP - " "Change to 40MHz channel support is not allowed\n"); return -EINVAL; } @@ -648,11 +648,11 @@ static ssize_t iwl_legacy_dbgfs_disable_ht40_write(struct file *file, return count; } -static ssize_t iwl_legacy_dbgfs_disable_ht40_read(struct file *file, +static ssize_t il_dbgfs_disable_ht40_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char buf[100]; int pos = 0; const size_t bufsz = sizeof(buf); @@ -672,29 +672,29 @@ DEBUGFS_READ_WRITE_FILE_OPS(interrupt); DEBUGFS_READ_FILE_OPS(qos); DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40); -static ssize_t iwl_legacy_dbgfs_traffic_log_read(struct file *file, +static ssize_t il_dbgfs_traffic_log_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0, ofs = 0; int cnt = 0, entry; - struct iwl_tx_queue *txq; - struct iwl_queue *q; - struct iwl_rx_queue *rxq = &priv->rxq; + struct il_tx_queue *txq; + struct il_queue *q; + struct il_rx_queue *rxq = &priv->rxq; char *buf; - int bufsz = ((IWL_TRAFFIC_ENTRIES * IWL_TRAFFIC_ENTRY_SIZE * 64) * 2) + + int bufsz = ((IL_TRAFFIC_ENTRIES * IL_TRAFFIC_ENTRY_SIZE * 64) * 2) + (priv->cfg->base_params->num_of_queues * 32 * 8) + 400; const u8 *ptr; ssize_t ret; if (!priv->txq) { - IWL_ERR(priv, "txq not ready\n"); + IL_ERR(priv, "txq not ready\n"); return -EAGAIN; } buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IWL_ERR(priv, "Can not allocate buffer\n"); + IL_ERR(priv, "Can not allocate buffer\n"); return -ENOMEM; } pos += scnprintf(buf + pos, bufsz - pos, "Tx Queue\n"); @@ -705,12 +705,12 @@ static ssize_t iwl_legacy_dbgfs_traffic_log_read(struct file *file, "q[%d]: read_ptr: %u, write_ptr: %u\n", cnt, q->read_ptr, q->write_ptr); } - if (priv->tx_traffic && (iwlegacy_debug_level & IWL_DL_TX)) { + if (priv->tx_traffic && (iwlegacy_debug_level & IL_DL_TX)) { ptr = priv->tx_traffic; pos += scnprintf(buf + pos, bufsz - pos, "Tx Traffic idx: %u\n", priv->tx_traffic_idx); - for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) { - for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16; + for (cnt = 0, ofs = 0; cnt < IL_TRAFFIC_ENTRIES; cnt++) { + for (entry = 0; entry < IL_TRAFFIC_ENTRY_SIZE / 16; entry++, ofs += 16) { pos += scnprintf(buf + pos, bufsz - pos, "0x%.4x ", ofs); @@ -728,12 +728,12 @@ static ssize_t iwl_legacy_dbgfs_traffic_log_read(struct file *file, "read: %u, write: %u\n", rxq->read, rxq->write); - if (priv->rx_traffic && (iwlegacy_debug_level & IWL_DL_RX)) { + if (priv->rx_traffic && (iwlegacy_debug_level & IL_DL_RX)) { ptr = priv->rx_traffic; pos += scnprintf(buf + pos, bufsz - pos, "Rx Traffic idx: %u\n", priv->rx_traffic_idx); - for (cnt = 0, ofs = 0; cnt < IWL_TRAFFIC_ENTRIES; cnt++) { - for (entry = 0; entry < IWL_TRAFFIC_ENTRY_SIZE / 16; + for (cnt = 0, ofs = 0; cnt < IL_TRAFFIC_ENTRIES; cnt++) { + for (entry = 0; entry < IL_TRAFFIC_ENTRY_SIZE / 16; entry++, ofs += 16) { pos += scnprintf(buf + pos, bufsz - pos, "0x%.4x ", ofs); @@ -751,11 +751,11 @@ static ssize_t iwl_legacy_dbgfs_traffic_log_read(struct file *file, return ret; } -static ssize_t iwl_legacy_dbgfs_traffic_log_write(struct file *file, +static ssize_t il_dbgfs_traffic_log_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char buf[8]; int buf_size; int traffic_log; @@ -767,18 +767,18 @@ static ssize_t iwl_legacy_dbgfs_traffic_log_write(struct file *file, if (sscanf(buf, "%d", &traffic_log) != 1) return -EFAULT; if (traffic_log == 0) - iwl_legacy_reset_traffic_log(priv); + il_reset_traffic_log(priv); return count; } -static ssize_t iwl_legacy_dbgfs_tx_queue_read(struct file *file, +static ssize_t il_dbgfs_tx_queue_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; - struct iwl_tx_queue *txq; - struct iwl_queue *q; + struct il_priv *priv = file->private_data; + struct il_tx_queue *txq; + struct il_queue *q; char *buf; int pos = 0; int cnt; @@ -787,7 +787,7 @@ static ssize_t iwl_legacy_dbgfs_tx_queue_read(struct file *file, priv->cfg->base_params->num_of_queues; if (!priv->txq) { - IWL_ERR(priv, "txq not ready\n"); + IL_ERR(priv, "txq not ready\n"); return -EAGAIN; } buf = kzalloc(bufsz, GFP_KERNEL); @@ -816,12 +816,12 @@ static ssize_t iwl_legacy_dbgfs_tx_queue_read(struct file *file, return ret; } -static ssize_t iwl_legacy_dbgfs_rx_queue_read(struct file *file, +static ssize_t il_dbgfs_rx_queue_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; - struct iwl_rx_queue *rxq = &priv->rxq; + struct il_priv *priv = file->private_data; + struct il_rx_queue *rxq = &priv->rxq; char buf[256]; int pos = 0; const size_t bufsz = sizeof(buf); @@ -842,49 +842,49 @@ static ssize_t iwl_legacy_dbgfs_rx_queue_read(struct file *file, return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t iwl_legacy_dbgfs_ucode_rx_stats_read(struct file *file, +static ssize_t il_dbgfs_ucode_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; return priv->cfg->ops->lib->debugfs_ops.rx_stats_read(file, user_buf, count, ppos); } -static ssize_t iwl_legacy_dbgfs_ucode_tx_stats_read(struct file *file, +static ssize_t il_dbgfs_ucode_tx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; return priv->cfg->ops->lib->debugfs_ops.tx_stats_read(file, user_buf, count, ppos); } -static ssize_t iwl_legacy_dbgfs_ucode_general_stats_read(struct file *file, +static ssize_t il_dbgfs_ucode_general_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; return priv->cfg->ops->lib->debugfs_ops.general_stats_read(file, user_buf, count, ppos); } -static ssize_t iwl_legacy_dbgfs_sensitivity_read(struct file *file, +static ssize_t il_dbgfs_sensitivity_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0; int cnt = 0; char *buf; - int bufsz = sizeof(struct iwl_sensitivity_data) * 4 + 100; + int bufsz = sizeof(struct il_sensitivity_data) * 4 + 100; ssize_t ret; - struct iwl_sensitivity_data *data; + struct il_sensitivity_data *data; data = &priv->sensitivity_data; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IWL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(priv, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -950,22 +950,22 @@ static ssize_t iwl_legacy_dbgfs_sensitivity_read(struct file *file, } -static ssize_t iwl_legacy_dbgfs_chain_noise_read(struct file *file, +static ssize_t il_dbgfs_chain_noise_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0; int cnt = 0; char *buf; - int bufsz = sizeof(struct iwl_chain_noise_data) * 4 + 100; + int bufsz = sizeof(struct il_chain_noise_data) * 4 + 100; ssize_t ret; - struct iwl_chain_noise_data *data; + struct il_chain_noise_data *data; data = &priv->chain_noise_data; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IWL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(priv, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -1008,17 +1008,17 @@ static ssize_t iwl_legacy_dbgfs_chain_noise_read(struct file *file, return ret; } -static ssize_t iwl_legacy_dbgfs_power_save_status_read(struct file *file, +static ssize_t il_dbgfs_power_save_status_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char buf[60]; int pos = 0; const size_t bufsz = sizeof(buf); u32 pwrsave_status; - pwrsave_status = iwl_read32(priv, CSR_GP_CNTRL) & + pwrsave_status = il_read32(priv, CSR_GP_CNTRL) & CSR_GP_REG_POWER_SAVE_STATUS_MSK; pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: "); @@ -1031,11 +1031,11 @@ static ssize_t iwl_legacy_dbgfs_power_save_status_read(struct file *file, return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t iwl_legacy_dbgfs_clear_ucode_statistics_write(struct file *file, +static ssize_t il_dbgfs_clear_ucode_statistics_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char buf[8]; int buf_size; int clear; @@ -1049,43 +1049,43 @@ static ssize_t iwl_legacy_dbgfs_clear_ucode_statistics_write(struct file *file, /* make request to uCode to retrieve statistics information */ mutex_lock(&priv->mutex); - iwl_legacy_send_statistics_request(priv, CMD_SYNC, true); + il_send_statistics_request(priv, CMD_SYNC, true); mutex_unlock(&priv->mutex); return count; } -static ssize_t iwl_legacy_dbgfs_rxon_flags_read(struct file *file, +static ssize_t il_dbgfs_rxon_flags_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int len = 0; char buf[20]; len = sprintf(buf, "0x%04X\n", - le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.flags)); + le32_to_cpu(priv->contexts[IL_RXON_CTX_BSS].active.flags)); return simple_read_from_buffer(user_buf, count, ppos, buf, len); } -static ssize_t iwl_legacy_dbgfs_rxon_filter_flags_read(struct file *file, +static ssize_t il_dbgfs_rxon_filter_flags_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int len = 0; char buf[20]; len = sprintf(buf, "0x%04X\n", - le32_to_cpu(priv->contexts[IWL_RXON_CTX_BSS].active.filter_flags)); + le32_to_cpu(priv->contexts[IL_RXON_CTX_BSS].active.filter_flags)); return simple_read_from_buffer(user_buf, count, ppos, buf, len); } -static ssize_t iwl_legacy_dbgfs_fh_reg_read(struct file *file, +static ssize_t il_dbgfs_fh_reg_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char *buf; int pos = 0; ssize_t ret = -EFAULT; @@ -1102,11 +1102,11 @@ static ssize_t iwl_legacy_dbgfs_fh_reg_read(struct file *file, return ret; } -static ssize_t iwl_legacy_dbgfs_missed_beacon_read(struct file *file, +static ssize_t il_dbgfs_missed_beacon_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0; char buf[12]; const size_t bufsz = sizeof(buf); @@ -1117,11 +1117,11 @@ static ssize_t iwl_legacy_dbgfs_missed_beacon_read(struct file *file, return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t iwl_legacy_dbgfs_missed_beacon_write(struct file *file, +static ssize_t il_dbgfs_missed_beacon_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char buf[8]; int buf_size; int missed; @@ -1133,25 +1133,25 @@ static ssize_t iwl_legacy_dbgfs_missed_beacon_write(struct file *file, if (sscanf(buf, "%d", &missed) != 1) return -EINVAL; - if (missed < IWL_MISSED_BEACON_THRESHOLD_MIN || - missed > IWL_MISSED_BEACON_THRESHOLD_MAX) + if (missed < IL_MISSED_BEACON_THRESHOLD_MIN || + missed > IL_MISSED_BEACON_THRESHOLD_MAX) priv->missed_beacon_threshold = - IWL_MISSED_BEACON_THRESHOLD_DEF; + IL_MISSED_BEACON_THRESHOLD_DEF; else priv->missed_beacon_threshold = missed; return count; } -static ssize_t iwl_legacy_dbgfs_force_reset_read(struct file *file, +static ssize_t il_dbgfs_force_reset_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; int pos = 0; char buf[300]; const size_t bufsz = sizeof(buf); - struct iwl_force_reset *force_reset; + struct il_force_reset *force_reset; force_reset = &priv->force_reset; @@ -1171,23 +1171,23 @@ static ssize_t iwl_legacy_dbgfs_force_reset_read(struct file *file, return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t iwl_legacy_dbgfs_force_reset_write(struct file *file, +static ssize_t il_dbgfs_force_reset_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { int ret; - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; - ret = iwl_legacy_force_reset(priv, true); + ret = il_force_reset(priv, true); return ret ? ret : count; } -static ssize_t iwl_legacy_dbgfs_wd_timeout_write(struct file *file, +static ssize_t il_dbgfs_wd_timeout_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct iwl_priv *priv = file->private_data; + struct il_priv *priv = file->private_data; char buf[8]; int buf_size; int timeout; @@ -1198,11 +1198,11 @@ static ssize_t iwl_legacy_dbgfs_wd_timeout_write(struct file *file, return -EFAULT; if (sscanf(buf, "%d", &timeout) != 1) return -EINVAL; - if (timeout < 0 || timeout > IWL_MAX_WD_TIMEOUT) - timeout = IWL_DEF_WD_TIMEOUT; + if (timeout < 0 || timeout > IL_MAX_WD_TIMEOUT) + timeout = IL_DEF_WD_TIMEOUT; priv->cfg->base_params->wd_timeout = timeout; - iwl_legacy_setup_watchdog(priv); + il_setup_watchdog(priv); return count; } @@ -1230,7 +1230,7 @@ DEBUGFS_WRITE_FILE_OPS(wd_timeout); * Create the debugfs files and directories * */ -int iwl_legacy_dbgfs_register(struct iwl_priv *priv, const char *name) +int il_dbgfs_register(struct il_priv *priv, const char *name) { struct dentry *phyd = priv->hw->wiphy->debugfsdir; struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug; @@ -1292,17 +1292,17 @@ int iwl_legacy_dbgfs_register(struct iwl_priv *priv, const char *name) return 0; err: - IWL_ERR(priv, "Can't create the debugfs directory\n"); - iwl_legacy_dbgfs_unregister(priv); + IL_ERR(priv, "Can't create the debugfs directory\n"); + il_dbgfs_unregister(priv); return -ENOMEM; } -EXPORT_SYMBOL(iwl_legacy_dbgfs_register); +EXPORT_SYMBOL(il_dbgfs_register); /** * Remove the debugfs files and directories * */ -void iwl_legacy_dbgfs_unregister(struct iwl_priv *priv) +void il_dbgfs_unregister(struct il_priv *priv) { if (!priv->debugfs_dir) return; @@ -1310,4 +1310,4 @@ void iwl_legacy_dbgfs_unregister(struct iwl_priv *priv) debugfs_remove_recursive(priv->debugfs_dir); priv->debugfs_dir = NULL; } -EXPORT_SYMBOL(iwl_legacy_dbgfs_unregister); +EXPORT_SYMBOL(il_dbgfs_unregister); diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 9c786edf56fd..20c44f36ba77 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -29,8 +29,8 @@ * Please use iwl-4965-hw.h for hardware-related definitions. */ -#ifndef __iwl_legacy_dev_h__ -#define __iwl_legacy_dev_h__ +#ifndef __il_dev_h__ +#define __il_dev_h__ #include #include /* for struct pci_device_id */ @@ -50,7 +50,7 @@ #include "iwl-power.h" #include "iwl-legacy-rs.h" -struct iwl_tx_queue; +struct il_tx_queue; /* CT-KILL constants */ #define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */ @@ -66,7 +66,7 @@ struct iwl_tx_queue; * noise info (e.g. averaging might be done in app); measured dBm values are * always negative ... using a negative value as the default keeps all * averages within an s8's (used in some apps) range of negative values. */ -#define IWL_NOISE_MEAS_NOT_AVAILABLE (-127) +#define IL_NOISE_MEAS_NOT_AVAILABLE (-127) /* * RTS threshold here is total size [2347] minus 4 FCS bytes @@ -85,7 +85,7 @@ struct iwl_tx_queue; #define DEFAULT_SHORT_RETRY_LIMIT 7U #define DEFAULT_LONG_RETRY_LIMIT 4U -struct iwl_rx_mem_buffer { +struct il_rx_mem_buffer { dma_addr_t page_dma; struct page *page; struct list_head list; @@ -94,11 +94,11 @@ struct iwl_rx_mem_buffer { #define rxb_addr(r) page_address(r->page) /* defined below */ -struct iwl_device_cmd; +struct il_device_cmd; -struct iwl_cmd_meta { +struct il_cmd_meta { /* only for SYNC commands, iff the reply skb is wanted */ - struct iwl_host_cmd *source; + struct il_host_cmd *source; /* * only for ASYNC commands * (which is somewhat stupid -- look at iwl-sta.c for instance @@ -106,9 +106,9 @@ struct iwl_cmd_meta { * invoked for SYNC commands, if it were and its result passed * through it would be simpler...) */ - void (*callback)(struct iwl_priv *priv, - struct iwl_device_cmd *cmd, - struct iwl_rx_packet *pkt); + void (*callback)(struct il_priv *priv, + struct il_device_cmd *cmd, + struct il_rx_packet *pkt); /* The CMD_SIZE_HUGE flag bit indicates that the command * structure is stored at the end of the shared queue memory. */ @@ -123,7 +123,7 @@ struct iwl_cmd_meta { * * Contains common data for Rx and Tx queues */ -struct iwl_queue { +struct il_queue { int n_bd; /* number of BDs in this queue */ int write_ptr; /* 1-st empty entry (index) host_w*/ int read_ptr; /* last used entry (index) host_r*/ @@ -138,13 +138,13 @@ struct iwl_queue { }; /* One for each TFD */ -struct iwl_tx_info { +struct il_tx_info { struct sk_buff *skb; - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; }; /** - * struct iwl_tx_queue - Tx Queue for DMA + * struct il_tx_queue - Tx Queue for DMA * @q: generic Rx/Tx queue descriptor * @bd: base of circular buffer of TFDs * @cmd: array of command/TX buffer pointers @@ -161,12 +161,12 @@ struct iwl_tx_info { #define TFD_TX_CMD_SLOTS 256 #define TFD_CMD_SLOTS 32 -struct iwl_tx_queue { - struct iwl_queue q; +struct il_tx_queue { + struct il_queue q; void *tfds; - struct iwl_device_cmd **cmd; - struct iwl_cmd_meta *meta; - struct iwl_tx_info *txb; + struct il_device_cmd **cmd; + struct il_cmd_meta *meta; + struct il_tx_info *txb; unsigned long time_stamp; u8 need_update; u8 sched_retry; @@ -174,23 +174,23 @@ struct iwl_tx_queue { u8 swq_id; }; -#define IWL_NUM_SCAN_RATES (2) +#define IL_NUM_SCAN_RATES (2) -struct iwl4965_channel_tgd_info { +struct il4965_channel_tgd_info { u8 type; s8 max_power; }; -struct iwl4965_channel_tgh_info { +struct il4965_channel_tgh_info { s64 last_radar_time; }; #define IWL4965_MAX_RATE (33) -struct iwl3945_clip_group { +struct il3945_clip_group { /* maximum power level to prevent clipping for each rate, derived by * us from this band's saturation power in EEPROM */ - const s8 clip_powers[IWL_MAX_RATES]; + const s8 clip_powers[IL_MAX_RATES]; }; /* current Tx power values to use, one for each rate for each channel. @@ -200,8 +200,8 @@ struct iwl3945_clip_group { * -- spectrum management * -- user preference (e.g. iwconfig) * when requested power is set, base power index must also be set. */ -struct iwl3945_channel_power_info { - struct iwl3945_tx_power tpc; /* actual radio and DSP gain settings */ +struct il3945_channel_power_info { + struct il3945_tx_power tpc; /* actual radio and DSP gain settings */ s8 power_table_index; /* actual (compenst'd) index into gain table */ s8 base_power_index; /* gain index for power at factory temp. */ s8 requested_power; /* power (dBm) requested for this chnl/rate */ @@ -209,8 +209,8 @@ struct iwl3945_channel_power_info { /* current scan Tx power values to use, one for each scan rate for each * channel. */ -struct iwl3945_scan_power_info { - struct iwl3945_tx_power tpc; /* actual radio and DSP gain settings */ +struct il3945_scan_power_info { + struct il3945_tx_power tpc; /* actual radio and DSP gain settings */ s8 power_table_index; /* actual (compenst'd) index into gain table */ s8 requested_power; /* scan pwr (dBm) requested for chnl/rate */ }; @@ -220,11 +220,11 @@ struct iwl3945_scan_power_info { * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant * with one another! */ -struct iwl_channel_info { - struct iwl4965_channel_tgd_info tgd; - struct iwl4965_channel_tgh_info tgh; - struct iwl_eeprom_channel eeprom; /* EEPROM regulatory limit */ - struct iwl_eeprom_channel ht40_eeprom; /* EEPROM regulatory limit for +struct il_channel_info { + struct il4965_channel_tgd_info tgd; + struct il4965_channel_tgh_info tgh; + struct il_eeprom_channel eeprom; /* EEPROM regulatory limit */ + struct il_eeprom_channel ht40_eeprom; /* EEPROM regulatory limit for * HT40 channel */ u8 channel; /* channel number */ @@ -246,34 +246,34 @@ struct iwl_channel_info { /* Radio/DSP gain settings for each "normal" data Tx rate. * These include, in addition to RF and DSP gain, a few fields for * remembering/modifying gain settings (indexes). */ - struct iwl3945_channel_power_info power_info[IWL4965_MAX_RATE]; + struct il3945_channel_power_info power_info[IWL4965_MAX_RATE]; /* Radio/DSP gain settings for each scan rate, for directed scans. */ - struct iwl3945_scan_power_info scan_pwr_info[IWL_NUM_SCAN_RATES]; + struct il3945_scan_power_info scan_pwr_info[IL_NUM_SCAN_RATES]; }; -#define IWL_TX_FIFO_BK 0 /* shared */ -#define IWL_TX_FIFO_BE 1 -#define IWL_TX_FIFO_VI 2 /* shared */ -#define IWL_TX_FIFO_VO 3 -#define IWL_TX_FIFO_UNUSED -1 +#define IL_TX_FIFO_BK 0 /* shared */ +#define IL_TX_FIFO_BE 1 +#define IL_TX_FIFO_VI 2 /* shared */ +#define IL_TX_FIFO_VO 3 +#define IL_TX_FIFO_UNUSED -1 /* Minimum number of queues. MAX_NUM is defined in hw specific files. * Set the minimum to accommodate the 4 standard TX queues, 1 command * queue, 2 (unused) HCCA queues, and 4 HT queues (one for each AC) */ -#define IWL_MIN_NUM_QUEUES 10 +#define IL_MIN_NUM_QUEUES 10 -#define IWL_DEFAULT_CMD_QUEUE_NUM 4 +#define IL_DEFAULT_CMD_QUEUE_NUM 4 #define IEEE80211_DATA_LEN 2304 #define IEEE80211_4ADDR_LEN 30 #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN) #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) -struct iwl_frame { +struct il_frame { union { struct ieee80211_hdr frame; - struct iwl_tx_beacon_cmd beacon; + struct il_tx_beacon_cmd beacon; u8 raw[IEEE80211_FRAME_LEN]; u8 cmd[360]; } u; @@ -297,33 +297,33 @@ enum { #define DEF_CMD_PAYLOAD_SIZE 320 /** - * struct iwl_device_cmd + * struct il_device_cmd * * For allocation of the command and tx queues, this establishes the overall * size of the largest command we send to uCode, except for a scan command * (which is relatively huge; space is allocated separately). */ -struct iwl_device_cmd { - struct iwl_cmd_header hdr; /* uCode API */ +struct il_device_cmd { + struct il_cmd_header hdr; /* uCode API */ union { u32 flags; u8 val8; u16 val16; u32 val32; - struct iwl_tx_cmd tx; + struct il_tx_cmd tx; u8 payload[DEF_CMD_PAYLOAD_SIZE]; } __packed cmd; } __packed; -#define TFD_MAX_PAYLOAD_SIZE (sizeof(struct iwl_device_cmd)) +#define TFD_MAX_PAYLOAD_SIZE (sizeof(struct il_device_cmd)) -struct iwl_host_cmd { +struct il_host_cmd { const void *data; unsigned long reply_page; - void (*callback)(struct iwl_priv *priv, - struct iwl_device_cmd *cmd, - struct iwl_rx_packet *pkt); + void (*callback)(struct il_priv *priv, + struct il_device_cmd *cmd, + struct il_rx_packet *pkt); u32 flags; u16 len; u8 id; @@ -334,7 +334,7 @@ struct iwl_host_cmd { #define SUP_RATE_11G_MAX_NUM_CHANNELS 12 /** - * struct iwl_rx_queue - Rx queue + * struct il_rx_queue - Rx queue * @bd: driver's pointer to buffer of receive buffer descriptors (rbd) * @bd_dma: bus address of buffer of receive buffer descriptors (rbd) * @read: Shared index to newest available Rx buffer @@ -346,13 +346,13 @@ struct iwl_host_cmd { * @rb_stts: driver's pointer to receive buffer status * @rb_stts_dma: bus address of receive buffer status * - * NOTE: rx_free and rx_used are used as a FIFO for iwl_rx_mem_buffers + * NOTE: rx_free and rx_used are used as a FIFO for il_rx_mem_buffers */ -struct iwl_rx_queue { +struct il_rx_queue { __le32 *bd; dma_addr_t bd_dma; - struct iwl_rx_mem_buffer pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS]; - struct iwl_rx_mem_buffer *queue[RX_QUEUE_SIZE]; + struct il_rx_mem_buffer pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS]; + struct il_rx_mem_buffer *queue[RX_QUEUE_SIZE]; u32 read; u32 write; u32 free_count; @@ -360,20 +360,20 @@ struct iwl_rx_queue { struct list_head rx_free; struct list_head rx_used; int need_update; - struct iwl_rb_status *rb_stts; + struct il_rb_status *rb_stts; dma_addr_t rb_stts_dma; spinlock_t lock; }; -#define IWL_SUPPORTED_RATES_IE_LEN 8 +#define IL_SUPPORTED_RATES_IE_LEN 8 #define MAX_TID_COUNT 9 -#define IWL_INVALID_RATE 0xFF -#define IWL_INVALID_VALUE -1 +#define IL_INVALID_RATE 0xFF +#define IL_INVALID_VALUE -1 /** - * struct iwl_ht_agg -- aggregation status while waiting for block-ack + * struct il_ht_agg -- aggregation status while waiting for block-ack * @txq_id: Tx queue used for Tx attempt * @frame_count: # frames attempted by Tx command * @wait_for_ba: Expect block-ack before next Tx reply @@ -386,35 +386,35 @@ struct iwl_rx_queue { * for block ack (REPLY_COMPRESSED_BA). This struct stores tx reply info * until block ack arrives. */ -struct iwl_ht_agg { +struct il_ht_agg { u16 txq_id; u16 frame_count; u16 wait_for_ba; u16 start_idx; u64 bitmap; u32 rate_n_flags; -#define IWL_AGG_OFF 0 -#define IWL_AGG_ON 1 -#define IWL_EMPTYING_HW_QUEUE_ADDBA 2 -#define IWL_EMPTYING_HW_QUEUE_DELBA 3 +#define IL_AGG_OFF 0 +#define IL_AGG_ON 1 +#define IL_EMPTYING_HW_QUEUE_ADDBA 2 +#define IL_EMPTYING_HW_QUEUE_DELBA 3 u8 state; }; -struct iwl_tid_data { +struct il_tid_data { u16 seq_number; /* 4965 only */ u16 tfds_in_queue; - struct iwl_ht_agg agg; + struct il_ht_agg agg; }; -struct iwl_hw_key { +struct il_hw_key { u32 cipher; int keylen; u8 keyidx; u8 key[32]; }; -union iwl_ht_rate_supp { +union il_ht_rate_supp { u16 rates; struct { u8 siso_rate; @@ -445,38 +445,38 @@ union iwl_ht_rate_supp { #define CFG_HT_MPDU_DENSITY_MAX CFG_HT_MPDU_DENSITY_16USEC #define CFG_HT_MPDU_DENSITY_MIN (0x1) -struct iwl_ht_config { +struct il_ht_config { bool single_chain_sufficient; enum ieee80211_smps_mode smps; /* current smps mode */ }; /* QoS structures */ -struct iwl_qos_info { +struct il_qos_info { int qos_active; - struct iwl_qosparam_cmd def_qos_parm; + struct il_qosparam_cmd def_qos_parm; }; /* * Structure should be accessed with sta_lock held. When station addition - * is in progress (IWL_STA_UCODE_INPROGRESS) it is possible to access only - * the commands (iwl_legacy_addsta_cmd and iwl_link_quality_cmd) without + * is in progress (IL_STA_UCODE_INPROGRESS) it is possible to access only + * the commands (il_addsta_cmd and il_link_quality_cmd) without * sta_lock held. */ -struct iwl_station_entry { - struct iwl_legacy_addsta_cmd sta; - struct iwl_tid_data tid[MAX_TID_COUNT]; +struct il_station_entry { + struct il_addsta_cmd sta; + struct il_tid_data tid[MAX_TID_COUNT]; u8 used, ctxid; - struct iwl_hw_key keyinfo; - struct iwl_link_quality_cmd *lq; + struct il_hw_key keyinfo; + struct il_link_quality_cmd *lq; }; -struct iwl_station_priv_common { - struct iwl_rxon_context *ctx; +struct il_station_priv_common { + struct il_rxon_context *ctx; u8 sta_id; }; /* - * iwl_station_priv: Driver's private station information + * il_station_priv: Driver's private station information * * When mac80211 creates a station it reserves some space (hw->sta_data_size) * in the structure for use by driver. This structure is places in that @@ -485,22 +485,22 @@ struct iwl_station_priv_common { * The common struct MUST be first because it is shared between * 3945 and 4965! */ -struct iwl_station_priv { - struct iwl_station_priv_common common; - struct iwl_lq_sta lq_sta; +struct il_station_priv { + struct il_station_priv_common common; + struct il_lq_sta lq_sta; atomic_t pending_frames; bool client; bool asleep; }; /** - * struct iwl_vif_priv - driver's private per-interface information + * struct il_vif_priv - driver's private per-interface information * * When mac80211 allocates a virtual interface, it can allocate * space for us to put data into. */ -struct iwl_vif_priv { - struct iwl_rxon_context *ctx; +struct il_vif_priv { + struct il_rxon_context *ctx; u8 ibss_bssid_sta_id; }; @@ -512,7 +512,7 @@ struct fw_desc { }; /* uCode file layout */ -struct iwl_ucode_header { +struct il_ucode_header { __le32 ver; /* major/minor/API/serial */ struct { __le32 inst_size; /* bytes of runtime code */ @@ -524,7 +524,7 @@ struct iwl_ucode_header { } v1; }; -struct iwl4965_ibss_seq { +struct il4965_ibss_seq { u8 mac[ETH_ALEN]; u16 seq_num; u16 frag_num; @@ -532,7 +532,7 @@ struct iwl4965_ibss_seq { struct list_head list; }; -struct iwl_sensitivity_ranges { +struct il_sensitivity_ranges { u16 min_nrg_cck; u16 max_nrg_cck; @@ -565,7 +565,7 @@ struct iwl_sensitivity_ranges { /** - * struct iwl_hw_params + * struct il_hw_params * @max_txq_num: Max # Tx queues supported * @dma_chnl_num: Number of Tx DMA/FIFO channels * @scd_bc_tbls_size: size of scheduler byte count tables @@ -583,9 +583,9 @@ struct iwl_sensitivity_ranges { * @max_xxx_size: for ucode uses * @ct_kill_threshold: temperature threshold * @beacon_time_tsf_bits: number of valid tsf bits for beacon time - * @struct iwl_sensitivity_ranges: range of sensitivity values + * @struct il_sensitivity_ranges: range of sensitivity values */ -struct iwl_hw_params { +struct il_hw_params { u8 max_txq_num; u8 dma_chnl_num; u16 scd_bc_tbls_size; @@ -606,7 +606,7 @@ struct iwl_hw_params { u32 max_bsm_size; u32 ct_kill_threshold; /* value in hw-dependent units */ u16 beacon_time_tsf_bits; - const struct iwl_sensitivity_ranges *sens; + const struct il_sensitivity_ranges *sens; }; @@ -619,16 +619,16 @@ struct iwl_hw_params { * which is why they are in the core module files. * * Naming convention -- - * iwl_ <-- Is part of iwlwifi + * il_ <-- Is part of iwlwifi * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX) - * iwl4965_bg_ <-- Called from work queue context - * iwl4965_mac_ <-- mac80211 callback + * il4965_bg_ <-- Called from work queue context + * il4965_mac_ <-- mac80211 callback * ****************************************************************************/ -extern void iwl4965_update_chain_flags(struct iwl_priv *priv); +extern void il4965_update_chain_flags(struct il_priv *priv); extern const u8 iwlegacy_bcast_addr[ETH_ALEN]; -extern int iwl_legacy_queue_space(const struct iwl_queue *q); -static inline int iwl_legacy_queue_used(const struct iwl_queue *q, int i) +extern int il_queue_space(const struct il_queue *q); +static inline int il_queue_used(const struct il_queue *q, int i) { return q->write_ptr >= q->read_ptr ? (i >= q->read_ptr && i < q->write_ptr) : @@ -636,7 +636,7 @@ static inline int iwl_legacy_queue_used(const struct iwl_queue *q, int i) } -static inline u8 iwl_legacy_get_cmd_index(struct iwl_queue *q, u32 index, +static inline u8 il_get_cmd_index(struct il_queue *q, u32 index, int is_huge) { /* @@ -652,26 +652,26 @@ static inline u8 iwl_legacy_get_cmd_index(struct iwl_queue *q, u32 index, } -struct iwl_dma_ptr { +struct il_dma_ptr { dma_addr_t dma; void *addr; size_t size; }; -#define IWL_OPERATION_MODE_AUTO 0 -#define IWL_OPERATION_MODE_HT_ONLY 1 -#define IWL_OPERATION_MODE_MIXED 2 -#define IWL_OPERATION_MODE_20MHZ 3 +#define IL_OPERATION_MODE_AUTO 0 +#define IL_OPERATION_MODE_HT_ONLY 1 +#define IL_OPERATION_MODE_MIXED 2 +#define IL_OPERATION_MODE_20MHZ 3 -#define IWL_TX_CRC_SIZE 4 -#define IWL_TX_DELIMITER_SIZE 4 +#define IL_TX_CRC_SIZE 4 +#define IL_TX_DELIMITER_SIZE 4 -#define TX_POWER_IWL_ILLEGAL_VOLTAGE -10000 +#define TX_POWER_IL_ILLEGAL_VOLTAGE -10000 /* Sensitivity and chain noise calibration */ #define INITIALIZATION_VALUE 0xFFFF #define IWL4965_CAL_NUM_BEACONS 20 -#define IWL_CAL_NUM_BEACONS 16 +#define IL_CAL_NUM_BEACONS 16 #define MAXIMUM_ALLOWED_PATHLOSS 15 #define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3 @@ -704,35 +704,35 @@ struct iwl_dma_ptr { #define NRG_NUM_PREV_STAT_L 20 #define NUM_RX_CHAINS 3 -enum iwl4965_false_alarm_state { - IWL_FA_TOO_MANY = 0, - IWL_FA_TOO_FEW = 1, - IWL_FA_GOOD_RANGE = 2, +enum il4965_false_alarm_state { + IL_FA_TOO_MANY = 0, + IL_FA_TOO_FEW = 1, + IL_FA_GOOD_RANGE = 2, }; -enum iwl4965_chain_noise_state { - IWL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */ - IWL_CHAIN_NOISE_ACCUMULATE, - IWL_CHAIN_NOISE_CALIBRATED, - IWL_CHAIN_NOISE_DONE, +enum il4965_chain_noise_state { + IL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */ + IL_CHAIN_NOISE_ACCUMULATE, + IL_CHAIN_NOISE_CALIBRATED, + IL_CHAIN_NOISE_DONE, }; -enum iwl4965_calib_enabled_state { - IWL_CALIB_DISABLED = 0, /* must be 0 */ - IWL_CALIB_ENABLED = 1, +enum il4965_calib_enabled_state { + IL_CALIB_DISABLED = 0, /* must be 0 */ + IL_CALIB_ENABLED = 1, }; /* - * enum iwl_calib + * enum il_calib * defines the order in which results of initial calibrations * should be sent to the runtime uCode */ -enum iwl_calib { - IWL_CALIB_MAX, +enum il_calib { + IL_CALIB_MAX, }; /* Opaque calibration results */ -struct iwl_calib_result { +struct il_calib_result { void *buf; size_t buf_len; }; @@ -744,7 +744,7 @@ enum ucode_type { }; /* Sensitivity calib data */ -struct iwl_sensitivity_data { +struct il_sensitivity_data { u32 auto_corr_ofdm; u32 auto_corr_ofdm_mrc; u32 auto_corr_ofdm_x1; @@ -775,7 +775,7 @@ struct iwl_sensitivity_data { }; /* Chain noise (differential Rx gain) calib data */ -struct iwl_chain_noise_data { +struct il_chain_noise_data { u32 active_chains; u32 chain_noise_a; u32 chain_noise_b; @@ -793,8 +793,8 @@ struct iwl_chain_noise_data { #define EEPROM_SEM_TIMEOUT 10 /* milliseconds */ #define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ -#define IWL_TRAFFIC_ENTRIES (256) -#define IWL_TRAFFIC_ENTRY_SIZE (64) +#define IL_TRAFFIC_ENTRIES (256) +#define IL_TRAFFIC_ENTRY_SIZE (64) enum { MEASUREMENT_READY = (1 << 0), @@ -818,7 +818,7 @@ struct isr_statistics { }; /* management statistics */ -enum iwl_mgmt_stats { +enum il_mgmt_stats { MANAGEMENT_ASSOC_REQ = 0, MANAGEMENT_ASSOC_RESP, MANAGEMENT_REASSOC_REQ, @@ -834,7 +834,7 @@ enum iwl_mgmt_stats { MANAGEMENT_MAX, }; /* control statistics */ -enum iwl_ctrl_stats { +enum il_ctrl_stats { CONTROL_BACK_REQ = 0, CONTROL_BACK, CONTROL_PSPOLL, @@ -863,21 +863,21 @@ struct traffic_stats { * default interrupt coalescing timer is 64 x 32 = 2048 usecs * default interrupt coalescing calibration timer is 16 x 32 = 512 usecs */ -#define IWL_HOST_INT_TIMEOUT_MAX (0xFF) -#define IWL_HOST_INT_TIMEOUT_DEF (0x40) -#define IWL_HOST_INT_TIMEOUT_MIN (0x0) -#define IWL_HOST_INT_CALIB_TIMEOUT_MAX (0xFF) -#define IWL_HOST_INT_CALIB_TIMEOUT_DEF (0x10) -#define IWL_HOST_INT_CALIB_TIMEOUT_MIN (0x0) +#define IL_HOST_INT_TIMEOUT_MAX (0xFF) +#define IL_HOST_INT_TIMEOUT_DEF (0x40) +#define IL_HOST_INT_TIMEOUT_MIN (0x0) +#define IL_HOST_INT_CALIB_TIMEOUT_MAX (0xFF) +#define IL_HOST_INT_CALIB_TIMEOUT_DEF (0x10) +#define IL_HOST_INT_CALIB_TIMEOUT_MIN (0x0) -#define IWL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5) +#define IL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5) /* TX queue watchdog timeouts in mSecs */ -#define IWL_DEF_WD_TIMEOUT (2000) -#define IWL_LONG_WD_TIMEOUT (10000) -#define IWL_MAX_WD_TIMEOUT (120000) +#define IL_DEF_WD_TIMEOUT (2000) +#define IL_LONG_WD_TIMEOUT (10000) +#define IL_MAX_WD_TIMEOUT (120000) -struct iwl_force_reset { +struct il_force_reset { int reset_request_count; int reset_success_count; int reset_reject_count; @@ -899,13 +899,13 @@ struct iwl_force_reset { */ #define IWL4965_EXT_BEACON_TIME_POS 22 -enum iwl_rxon_context_id { - IWL_RXON_CTX_BSS, +enum il_rxon_context_id { + IL_RXON_CTX_BSS, - NUM_IWL_RXON_CTX + NUM_IL_RXON_CTX }; -struct iwl_rxon_context { +struct il_rxon_context { struct ieee80211_vif *vif; const u8 *ac_to_fifo; @@ -921,7 +921,7 @@ struct iwl_rxon_context { bool ht_need_multiple_chains; - enum iwl_rxon_context_id ctxid; + enum il_rxon_context_id ctxid; u32 interface_modes, exclusive_interface_modes; u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype; @@ -932,12 +932,12 @@ struct iwl_rxon_context { * routines that actually update the physical * hardware. */ - const struct iwl_legacy_rxon_cmd active; - struct iwl_legacy_rxon_cmd staging; + const struct il_rxon_cmd active; + struct il_rxon_cmd staging; - struct iwl_rxon_time_cmd timing; + struct il_rxon_time_cmd timing; - struct iwl_qos_info qos_data; + struct il_qos_info qos_data; u8 bcast_sta_id, ap_sta_id; @@ -945,7 +945,7 @@ struct iwl_rxon_context { u8 qos_cmd; u8 wep_key_cmd; - struct iwl_wep_key wep_keys[WEP_KEYS_MAX]; + struct il_wep_key wep_keys[WEP_KEYS_MAX]; u8 key_mapping_keys; __le32 station_flags; @@ -958,13 +958,13 @@ struct iwl_rxon_context { } ht; }; -struct iwl_priv { +struct il_priv { /* ieee device used by generic ieee processing code */ struct ieee80211_hw *hw; struct ieee80211_channel *ieee_channels; struct ieee80211_rate *ieee_rates; - struct iwl_cfg *cfg; + struct il_cfg *cfg; /* temporary frame storage list */ struct list_head free_frames; @@ -973,13 +973,13 @@ struct iwl_priv { enum ieee80211_band band; int alloc_rxb_page; - void (*rx_handlers[REPLY_MAX])(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb); + void (*rx_handlers[REPLY_MAX])(struct il_priv *priv, + struct il_rx_mem_buffer *rxb); struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; /* spectrum measurement report caching */ - struct iwl_spectrum_notification measure_report; + struct il_spectrum_notification measure_report; u8 measurement_status; /* ucode beacon time */ @@ -990,11 +990,11 @@ struct iwl_priv { u32 ibss_manager; /* force reset */ - struct iwl_force_reset force_reset; + struct il_force_reset force_reset; - /* we allocate array of iwl_channel_info for NIC's valid channels. + /* we allocate array of il_channel_info for NIC's valid channels. * Access via channel # using indirect index array */ - struct iwl_channel_info *channel_info; /* channel info array */ + struct il_channel_info *channel_info; /* channel info array */ u8 channel_count; /* # of channels */ /* thermal calibration */ @@ -1002,7 +1002,7 @@ struct iwl_priv { s32 last_temperature; /* init calibration results */ - struct iwl_calib_result calib_results[IWL_CALIB_MAX]; + struct il_calib_result calib_results[IL_CALIB_MAX]; /* Scan related variables */ unsigned long scan_start; @@ -1044,7 +1044,7 @@ struct iwl_priv { /* uCode images, save to reload in case of failure */ int fw_index; /* firmware we're trying to load */ u32 ucode_ver; /* version of ucode, copy of - iwl_ucode.ver */ + il_ucode.ver */ struct fw_desc ucode_code; /* runtime inst */ struct fw_desc ucode_data; /* runtime data original */ struct fw_desc ucode_data_backup; /* runtime data save/restore */ @@ -1055,23 +1055,23 @@ struct iwl_priv { u8 ucode_write_complete; /* the image write is complete */ char firmware_name[25]; - struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX]; + struct il_rxon_context contexts[NUM_IL_RXON_CTX]; __le16 switch_channel; /* 1st responses from initialize and runtime uCode images. * _4965's initialize alive response contains some calibration data. */ - struct iwl_init_alive_resp card_alive_init; - struct iwl_alive_resp card_alive; + struct il_init_alive_resp card_alive_init; + struct il_alive_resp card_alive; u16 active_rate; u8 start_calib; - struct iwl_sensitivity_data sensitivity_data; - struct iwl_chain_noise_data chain_noise_data; + struct il_sensitivity_data sensitivity_data; + struct il_chain_noise_data chain_noise_data; __le16 sensitivity_tbl[HD_TABLE_SIZE]; - struct iwl_ht_config current_ht_config; + struct il_ht_config current_ht_config; /* Rate scaling data */ u8 retry_rate; @@ -1081,11 +1081,11 @@ struct iwl_priv { int activity_timer_active; /* Rx and Tx DMA processing queues */ - struct iwl_rx_queue rxq; - struct iwl_tx_queue *txq; + struct il_rx_queue rxq; + struct il_tx_queue *txq; unsigned long txq_ctx_active_msk; - struct iwl_dma_ptr kw; /* keep warm address */ - struct iwl_dma_ptr scd_bc_tbls; + struct il_dma_ptr kw; /* keep warm address */ + struct il_dma_ptr scd_bc_tbls; u32 scd_base_addr; /* scheduler sram base address */ @@ -1098,7 +1098,7 @@ struct iwl_priv { /* counts interrupts */ struct isr_statistics isr_stats; - struct iwl_power_mgr power_data; + struct il_power_mgr power_data; /* context information */ u8 bssid[ETH_ALEN]; /* used only on 3945 but filled by core */ @@ -1108,12 +1108,12 @@ struct iwl_priv { /* Note: if lock and sta_lock are needed, lock must be acquired first */ spinlock_t sta_lock; int num_stations; - struct iwl_station_entry stations[IWL_STATION_COUNT]; + struct il_station_entry stations[IL_STATION_COUNT]; unsigned long ucode_key_table; /* queue refcounts */ -#define IWL_MAX_HW_QUEUES 32 - unsigned long queue_stopped[BITS_TO_LONGS(IWL_MAX_HW_QUEUES)]; +#define IL_MAX_HW_QUEUES 32 + unsigned long queue_stopped[BITS_TO_LONGS(IL_MAX_HW_QUEUES)]; /* for each AC */ atomic_t queue_stop_count[4]; @@ -1124,7 +1124,7 @@ struct iwl_priv { /* eeprom -- this is in the card's little endian byte order */ u8 *eeprom; - struct iwl_eeprom_calib_info *calib_info; + struct il_eeprom_calib_info *calib_info; enum nl80211_iftype iw_mode; @@ -1140,11 +1140,11 @@ struct iwl_priv { struct delayed_work thermal_periodic; struct delayed_work rfkill_poll; - struct iwl3945_notif_statistics statistics; + struct il3945_notif_statistics statistics; #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS - struct iwl3945_notif_statistics accum_statistics; - struct iwl3945_notif_statistics delta_statistics; - struct iwl3945_notif_statistics max_delta; + struct il3945_notif_statistics accum_statistics; + struct il3945_notif_statistics delta_statistics; + struct il3945_notif_statistics max_delta; #endif u32 sta_supp_rates; @@ -1159,13 +1159,13 @@ struct iwl_priv { * EEPROM has a derived clip setting for * each rate. */ - const struct iwl3945_clip_group clip_groups[5]; + const struct il3945_clip_group clip_groups[5]; } _3945; #endif #if defined(CONFIG_IWL4965) || defined(CONFIG_IWL4965_MODULE) struct { - struct iwl_rx_phy_res last_phy_res; + struct il_rx_phy_res last_phy_res; bool last_phy_res_valid; struct completion firmware_loading_complete; @@ -1178,18 +1178,18 @@ struct iwl_priv { u8 phy_calib_chain_noise_reset_cmd; u8 phy_calib_chain_noise_gain_cmd; - struct iwl_notif_statistics statistics; + struct il_notif_statistics statistics; #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS - struct iwl_notif_statistics accum_statistics; - struct iwl_notif_statistics delta_statistics; - struct iwl_notif_statistics max_delta; + struct il_notif_statistics accum_statistics; + struct il_notif_statistics delta_statistics; + struct il_notif_statistics max_delta; #endif } _4965; #endif }; - struct iwl_hw_params hw_params; + struct il_hw_params hw_params; u32 inta_mask; @@ -1200,7 +1200,7 @@ struct iwl_priv { struct work_struct rx_replenish; struct work_struct abort_scan; - struct iwl_rxon_context *beacon_ctx; + struct il_rxon_context *beacon_ctx; struct sk_buff *beacon_skb; struct work_struct tx_flush; @@ -1245,27 +1245,27 @@ struct iwl_priv { struct led_classdev led; unsigned long blink_on, blink_off; bool led_registered; -}; /*iwl_priv */ +}; /*il_priv */ -static inline void iwl_txq_ctx_activate(struct iwl_priv *priv, int txq_id) +static inline void il_txq_ctx_activate(struct il_priv *priv, int txq_id) { set_bit(txq_id, &priv->txq_ctx_active_msk); } -static inline void iwl_txq_ctx_deactivate(struct iwl_priv *priv, int txq_id) +static inline void il_txq_ctx_deactivate(struct il_priv *priv, int txq_id) { clear_bit(txq_id, &priv->txq_ctx_active_msk); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG /* - * iwl_legacy_get_debug_level: Return active debug level for device + * il_get_debug_level: Return active debug level for device * * Using sysfs it is possible to set per device debug level. This debug * level will be used if set, otherwise the global debug level which can be * set via module parameter is used. */ -static inline u32 iwl_legacy_get_debug_level(struct iwl_priv *priv) +static inline u32 il_get_debug_level(struct il_priv *priv) { if (priv->debug_level) return priv->debug_level; @@ -1273,7 +1273,7 @@ static inline u32 iwl_legacy_get_debug_level(struct iwl_priv *priv) return iwlegacy_debug_level; } #else -static inline u32 iwl_legacy_get_debug_level(struct iwl_priv *priv) +static inline u32 il_get_debug_level(struct il_priv *priv) { return iwlegacy_debug_level; } @@ -1281,7 +1281,7 @@ static inline u32 iwl_legacy_get_debug_level(struct iwl_priv *priv) static inline struct ieee80211_hdr * -iwl_legacy_tx_queue_get_hdr(struct iwl_priv *priv, +il_tx_queue_get_hdr(struct il_priv *priv, int txq_id, int idx) { if (priv->txq[txq_id].txb[idx].skb) @@ -1290,75 +1290,75 @@ iwl_legacy_tx_queue_get_hdr(struct iwl_priv *priv, return NULL; } -static inline struct iwl_rxon_context * -iwl_legacy_rxon_ctx_from_vif(struct ieee80211_vif *vif) +static inline struct il_rxon_context * +il_rxon_ctx_from_vif(struct ieee80211_vif *vif) { - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; return vif_priv->ctx; } #define for_each_context(priv, ctx) \ - for (ctx = &priv->contexts[IWL_RXON_CTX_BSS]; \ - ctx < &priv->contexts[NUM_IWL_RXON_CTX]; ctx++) \ + for (ctx = &priv->contexts[IL_RXON_CTX_BSS]; \ + ctx < &priv->contexts[NUM_IL_RXON_CTX]; ctx++) \ if (priv->valid_contexts & BIT(ctx->ctxid)) -static inline int iwl_legacy_is_associated(struct iwl_priv *priv, - enum iwl_rxon_context_id ctxid) +static inline int il_is_associated(struct il_priv *priv, + enum il_rxon_context_id ctxid) { return (priv->contexts[ctxid].active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; } -static inline int iwl_legacy_is_any_associated(struct iwl_priv *priv) +static inline int il_is_any_associated(struct il_priv *priv) { - return iwl_legacy_is_associated(priv, IWL_RXON_CTX_BSS); + return il_is_associated(priv, IL_RXON_CTX_BSS); } -static inline int iwl_legacy_is_associated_ctx(struct iwl_rxon_context *ctx) +static inline int il_is_associated_ctx(struct il_rxon_context *ctx) { return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; } -static inline int iwl_legacy_is_channel_valid(const struct iwl_channel_info *ch_info) +static inline int il_is_channel_valid(const struct il_channel_info *ch_info) { if (ch_info == NULL) return 0; return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0; } -static inline int iwl_legacy_is_channel_radar(const struct iwl_channel_info *ch_info) +static inline int il_is_channel_radar(const struct il_channel_info *ch_info) { return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0; } -static inline u8 iwl_legacy_is_channel_a_band(const struct iwl_channel_info *ch_info) +static inline u8 il_is_channel_a_band(const struct il_channel_info *ch_info) { return ch_info->band == IEEE80211_BAND_5GHZ; } static inline int -iwl_legacy_is_channel_passive(const struct iwl_channel_info *ch) +il_is_channel_passive(const struct il_channel_info *ch) { return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0; } static inline int -iwl_legacy_is_channel_ibss(const struct iwl_channel_info *ch) +il_is_channel_ibss(const struct il_channel_info *ch) { return (ch->flags & EEPROM_CHANNEL_IBSS) ? 1 : 0; } static inline void -__iwl_legacy_free_pages(struct iwl_priv *priv, struct page *page) +__il_free_pages(struct il_priv *priv, struct page *page) { __free_pages(page, priv->hw_params.rx_page_order); priv->alloc_rxb_page--; } -static inline void iwl_legacy_free_pages(struct iwl_priv *priv, unsigned long page) +static inline void il_free_pages(struct il_priv *priv, unsigned long page) { free_pages(page, priv->hw_params.rx_page_order); priv->alloc_rxb_page--; } -#endif /* __iwl_legacy_dev_h__ */ +#endif /* __il_dev_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-eeprom.c index 5bf3f49b74ab..1075f1d7f016 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.c @@ -81,7 +81,7 @@ * EEPROM contents to the specific channel number supported for each * band. * - * For example, iwl_priv->eeprom.band_3_channels[4] from the band_3 + * For example, il_priv->eeprom.band_3_channels[4] from the band_3 * definition below maps to physical channel 42 in the 5.2GHz spectrum. * The specific geography and calibration information for that channel * is contained in the eeprom map itself. @@ -142,18 +142,18 @@ static const u8 iwlegacy_eeprom_band_7[] = { /* 5.2 ht40 channel */ * ******************************************************************************/ -static int iwl_legacy_eeprom_verify_signature(struct iwl_priv *priv) +static int il_eeprom_verify_signature(struct il_priv *priv) { - u32 gp = iwl_read32(priv, CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; + u32 gp = il_read32(priv, CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; int ret = 0; - IWL_DEBUG_EEPROM(priv, "EEPROM signature=0x%08x\n", gp); + IL_DEBUG_EEPROM(priv, "EEPROM signature=0x%08x\n", gp); switch (gp) { case CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K: case CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K: break; default: - IWL_ERR(priv, "bad EEPROM signature," + IL_ERR(priv, "bad EEPROM signature," "EEPROM_GP=0x%08x\n", gp); ret = -ENOENT; break; @@ -162,39 +162,39 @@ static int iwl_legacy_eeprom_verify_signature(struct iwl_priv *priv) } const u8 -*iwl_legacy_eeprom_query_addr(const struct iwl_priv *priv, size_t offset) +*il_eeprom_query_addr(const struct il_priv *priv, size_t offset) { BUG_ON(offset >= priv->cfg->base_params->eeprom_size); return &priv->eeprom[offset]; } -EXPORT_SYMBOL(iwl_legacy_eeprom_query_addr); +EXPORT_SYMBOL(il_eeprom_query_addr); -u16 iwl_legacy_eeprom_query16(const struct iwl_priv *priv, size_t offset) +u16 il_eeprom_query16(const struct il_priv *priv, size_t offset) { if (!priv->eeprom) return 0; return (u16)priv->eeprom[offset] | ((u16)priv->eeprom[offset + 1] << 8); } -EXPORT_SYMBOL(iwl_legacy_eeprom_query16); +EXPORT_SYMBOL(il_eeprom_query16); /** - * iwl_legacy_eeprom_init - read EEPROM contents + * il_eeprom_init - read EEPROM contents * * Load the EEPROM contents from adapter into priv->eeprom * * NOTE: This routine uses the non-debug IO access functions. */ -int iwl_legacy_eeprom_init(struct iwl_priv *priv) +int il_eeprom_init(struct il_priv *priv) { __le16 *e; - u32 gp = iwl_read32(priv, CSR_EEPROM_GP); + u32 gp = il_read32(priv, CSR_EEPROM_GP); int sz; int ret; u16 addr; /* allocate eeprom */ sz = priv->cfg->base_params->eeprom_size; - IWL_DEBUG_EEPROM(priv, "NVM size = %d\n", sz); + IL_DEBUG_EEPROM(priv, "NVM size = %d\n", sz); priv->eeprom = kzalloc(sz, GFP_KERNEL); if (!priv->eeprom) { ret = -ENOMEM; @@ -204,9 +204,9 @@ int iwl_legacy_eeprom_init(struct iwl_priv *priv) priv->cfg->ops->lib->apm_ops.init(priv); - ret = iwl_legacy_eeprom_verify_signature(priv); + ret = il_eeprom_verify_signature(priv); if (ret < 0) { - IWL_ERR(priv, "EEPROM not found, EEPROM_GP=0x%08x\n", gp); + IL_ERR(priv, "EEPROM not found, EEPROM_GP=0x%08x\n", gp); ret = -ENOENT; goto err; } @@ -214,7 +214,7 @@ int iwl_legacy_eeprom_init(struct iwl_priv *priv) /* Make sure driver (instead of uCode) is allowed to read EEPROM */ ret = priv->cfg->ops->lib->eeprom_ops.acquire_semaphore(priv); if (ret < 0) { - IWL_ERR(priv, "Failed to acquire EEPROM semaphore.\n"); + IL_ERR(priv, "Failed to acquire EEPROM semaphore.\n"); ret = -ENOENT; goto err; } @@ -223,25 +223,25 @@ int iwl_legacy_eeprom_init(struct iwl_priv *priv) for (addr = 0; addr < sz; addr += sizeof(u16)) { u32 r; - _iwl_legacy_write32(priv, CSR_EEPROM_REG, + _il_write32(priv, CSR_EEPROM_REG, CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); - ret = iwl_poll_bit(priv, CSR_EEPROM_REG, + ret = il_poll_bit(priv, CSR_EEPROM_REG, CSR_EEPROM_REG_READ_VALID_MSK, CSR_EEPROM_REG_READ_VALID_MSK, - IWL_EEPROM_ACCESS_TIMEOUT); + IL_EEPROM_ACCESS_TIMEOUT); if (ret < 0) { - IWL_ERR(priv, "Time out reading EEPROM[%d]\n", + IL_ERR(priv, "Time out reading EEPROM[%d]\n", addr); goto done; } - r = _iwl_legacy_read_direct32(priv, CSR_EEPROM_REG); + r = _il_read_direct32(priv, CSR_EEPROM_REG); e[addr / 2] = cpu_to_le16(r >> 16); } - IWL_DEBUG_EEPROM(priv, "NVM Type: %s, version: 0x%x\n", + IL_DEBUG_EEPROM(priv, "NVM Type: %s, version: 0x%x\n", "EEPROM", - iwl_legacy_eeprom_query16(priv, EEPROM_VERSION)); + il_eeprom_query16(priv, EEPROM_VERSION)); ret = 0; done: @@ -249,24 +249,24 @@ done: err: if (ret) - iwl_legacy_eeprom_free(priv); + il_eeprom_free(priv); /* Reset chip to save power until we load uCode during "up". */ - iwl_legacy_apm_stop(priv); + il_apm_stop(priv); alloc_err: return ret; } -EXPORT_SYMBOL(iwl_legacy_eeprom_init); +EXPORT_SYMBOL(il_eeprom_init); -void iwl_legacy_eeprom_free(struct iwl_priv *priv) +void il_eeprom_free(struct il_priv *priv) { kfree(priv->eeprom); priv->eeprom = NULL; } -EXPORT_SYMBOL(iwl_legacy_eeprom_free); +EXPORT_SYMBOL(il_eeprom_free); -static void iwl_legacy_init_band_reference(const struct iwl_priv *priv, +static void il_init_band_reference(const struct il_priv *priv, int eep_band, int *eeprom_ch_count, - const struct iwl_eeprom_channel **eeprom_ch_info, + const struct il_eeprom_channel **eeprom_ch_info, const u8 **eeprom_ch_index) { u32 offset = priv->cfg->ops->lib-> @@ -274,44 +274,44 @@ static void iwl_legacy_init_band_reference(const struct iwl_priv *priv, switch (eep_band) { case 1: /* 2.4GHz band */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_1); - *eeprom_ch_info = (struct iwl_eeprom_channel *) - iwl_legacy_eeprom_query_addr(priv, offset); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(priv, offset); *eeprom_ch_index = iwlegacy_eeprom_band_1; break; case 2: /* 4.9GHz band */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_2); - *eeprom_ch_info = (struct iwl_eeprom_channel *) - iwl_legacy_eeprom_query_addr(priv, offset); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(priv, offset); *eeprom_ch_index = iwlegacy_eeprom_band_2; break; case 3: /* 5.2GHz band */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_3); - *eeprom_ch_info = (struct iwl_eeprom_channel *) - iwl_legacy_eeprom_query_addr(priv, offset); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(priv, offset); *eeprom_ch_index = iwlegacy_eeprom_band_3; break; case 4: /* 5.5GHz band */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_4); - *eeprom_ch_info = (struct iwl_eeprom_channel *) - iwl_legacy_eeprom_query_addr(priv, offset); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(priv, offset); *eeprom_ch_index = iwlegacy_eeprom_band_4; break; case 5: /* 5.7GHz band */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_5); - *eeprom_ch_info = (struct iwl_eeprom_channel *) - iwl_legacy_eeprom_query_addr(priv, offset); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(priv, offset); *eeprom_ch_index = iwlegacy_eeprom_band_5; break; case 6: /* 2.4GHz ht40 channels */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_6); - *eeprom_ch_info = (struct iwl_eeprom_channel *) - iwl_legacy_eeprom_query_addr(priv, offset); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(priv, offset); *eeprom_ch_index = iwlegacy_eeprom_band_6; break; case 7: /* 5 GHz ht40 channels */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_7); - *eeprom_ch_info = (struct iwl_eeprom_channel *) - iwl_legacy_eeprom_query_addr(priv, offset); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(priv, offset); *eeprom_ch_index = iwlegacy_eeprom_band_7; break; default: @@ -322,27 +322,27 @@ static void iwl_legacy_init_band_reference(const struct iwl_priv *priv, #define CHECK_AND_PRINT(x) ((eeprom_ch->flags & EEPROM_CHANNEL_##x) \ ? # x " " : "") /** - * iwl_legacy_mod_ht40_chan_info - Copy ht40 channel info into driver's priv. + * il_mod_ht40_chan_info - Copy ht40 channel info into driver's priv. * * Does not set up a command, or touch hardware. */ -static int iwl_legacy_mod_ht40_chan_info(struct iwl_priv *priv, +static int il_mod_ht40_chan_info(struct il_priv *priv, enum ieee80211_band band, u16 channel, - const struct iwl_eeprom_channel *eeprom_ch, + const struct il_eeprom_channel *eeprom_ch, u8 clear_ht40_extension_channel) { - struct iwl_channel_info *ch_info; + struct il_channel_info *ch_info; - ch_info = (struct iwl_channel_info *) - iwl_legacy_get_channel_info(priv, band, channel); + ch_info = (struct il_channel_info *) + il_get_channel_info(priv, band, channel); - if (!iwl_legacy_is_channel_valid(ch_info)) + if (!il_is_channel_valid(ch_info)) return -1; - IWL_DEBUG_EEPROM(priv, "HT40 Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):" + IL_DEBUG_EEPROM(priv, "HT40 Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):" " Ad-Hoc %ssupported\n", ch_info->channel, - iwl_legacy_is_channel_a_band(ch_info) ? + il_is_channel_a_band(ch_info) ? "5.2" : "2.4", CHECK_AND_PRINT(IBSS), CHECK_AND_PRINT(ACTIVE), @@ -369,22 +369,22 @@ static int iwl_legacy_mod_ht40_chan_info(struct iwl_priv *priv, ? # x " " : "") /** - * iwl_legacy_init_channel_map - Set up driver's info for all possible channels + * il_init_channel_map - Set up driver's info for all possible channels */ -int iwl_legacy_init_channel_map(struct iwl_priv *priv) +int il_init_channel_map(struct il_priv *priv) { int eeprom_ch_count = 0; const u8 *eeprom_ch_index = NULL; - const struct iwl_eeprom_channel *eeprom_ch_info = NULL; + const struct il_eeprom_channel *eeprom_ch_info = NULL; int band, ch; - struct iwl_channel_info *ch_info; + struct il_channel_info *ch_info; if (priv->channel_count) { - IWL_DEBUG_EEPROM(priv, "Channel map already initialized.\n"); + IL_DEBUG_EEPROM(priv, "Channel map already initialized.\n"); return 0; } - IWL_DEBUG_EEPROM(priv, "Initializing regulatory info from EEPROM\n"); + IL_DEBUG_EEPROM(priv, "Initializing regulatory info from EEPROM\n"); priv->channel_count = ARRAY_SIZE(iwlegacy_eeprom_band_1) + @@ -393,13 +393,13 @@ int iwl_legacy_init_channel_map(struct iwl_priv *priv) ARRAY_SIZE(iwlegacy_eeprom_band_4) + ARRAY_SIZE(iwlegacy_eeprom_band_5); - IWL_DEBUG_EEPROM(priv, "Parsing data for %d channels.\n", + IL_DEBUG_EEPROM(priv, "Parsing data for %d channels.\n", priv->channel_count); - priv->channel_info = kzalloc(sizeof(struct iwl_channel_info) * + priv->channel_info = kzalloc(sizeof(struct il_channel_info) * priv->channel_count, GFP_KERNEL); if (!priv->channel_info) { - IWL_ERR(priv, "Could not allocate channel_info\n"); + IL_ERR(priv, "Could not allocate channel_info\n"); priv->channel_count = 0; return -ENOMEM; } @@ -411,7 +411,7 @@ int iwl_legacy_init_channel_map(struct iwl_priv *priv) * what just in the EEPROM) */ for (band = 1; band <= 5; band++) { - iwl_legacy_init_band_reference(priv, band, &eeprom_ch_count, + il_init_band_reference(priv, band, &eeprom_ch_count, &eeprom_ch_info, &eeprom_ch_index); /* Loop through each band adding each of the channels */ @@ -432,13 +432,13 @@ int iwl_legacy_init_channel_map(struct iwl_priv *priv) ch_info->ht40_extension_channel = IEEE80211_CHAN_NO_HT40; - if (!(iwl_legacy_is_channel_valid(ch_info))) { - IWL_DEBUG_EEPROM(priv, + if (!(il_is_channel_valid(ch_info))) { + IL_DEBUG_EEPROM(priv, "Ch. %d Flags %x [%sGHz] - " "No traffic\n", ch_info->channel, ch_info->flags, - iwl_legacy_is_channel_a_band(ch_info) ? + il_is_channel_a_band(ch_info) ? "5.2" : "2.4"); ch_info++; continue; @@ -450,11 +450,11 @@ int iwl_legacy_init_channel_map(struct iwl_priv *priv) ch_info->scan_power = eeprom_ch_info[ch].max_power_avg; ch_info->min_power = 0; - IWL_DEBUG_EEPROM(priv, "Ch. %d [%sGHz] " + IL_DEBUG_EEPROM(priv, "Ch. %d [%sGHz] " "%s%s%s%s%s%s(0x%02x %ddBm):" " Ad-Hoc %ssupported\n", ch_info->channel, - iwl_legacy_is_channel_a_band(ch_info) ? + il_is_channel_a_band(ch_info) ? "5.2" : "2.4", CHECK_AND_PRINT_I(VALID), CHECK_AND_PRINT_I(IBSS), @@ -485,7 +485,7 @@ int iwl_legacy_init_channel_map(struct iwl_priv *priv) for (band = 6; band <= 7; band++) { enum ieee80211_band ieeeband; - iwl_legacy_init_band_reference(priv, band, &eeprom_ch_count, + il_init_band_reference(priv, band, &eeprom_ch_count, &eeprom_ch_info, &eeprom_ch_index); /* EEPROM band 6 is 2.4, band 7 is 5 GHz */ @@ -495,13 +495,13 @@ int iwl_legacy_init_channel_map(struct iwl_priv *priv) /* Loop through each band adding each of the channels */ for (ch = 0; ch < eeprom_ch_count; ch++) { /* Set up driver's info for lower half */ - iwl_legacy_mod_ht40_chan_info(priv, ieeeband, + il_mod_ht40_chan_info(priv, ieeeband, eeprom_ch_index[ch], &eeprom_ch_info[ch], IEEE80211_CHAN_NO_HT40PLUS); /* Set up driver's info for upper half */ - iwl_legacy_mod_ht40_chan_info(priv, ieeeband, + il_mod_ht40_chan_info(priv, ieeeband, eeprom_ch_index[ch] + 4, &eeprom_ch_info[ch], IEEE80211_CHAN_NO_HT40MINUS); @@ -510,25 +510,25 @@ int iwl_legacy_init_channel_map(struct iwl_priv *priv) return 0; } -EXPORT_SYMBOL(iwl_legacy_init_channel_map); +EXPORT_SYMBOL(il_init_channel_map); /* - * iwl_legacy_free_channel_map - undo allocations in iwl_legacy_init_channel_map + * il_free_channel_map - undo allocations in il_init_channel_map */ -void iwl_legacy_free_channel_map(struct iwl_priv *priv) +void il_free_channel_map(struct il_priv *priv) { kfree(priv->channel_info); priv->channel_count = 0; } -EXPORT_SYMBOL(iwl_legacy_free_channel_map); +EXPORT_SYMBOL(il_free_channel_map); /** - * iwl_legacy_get_channel_info - Find driver's private channel info + * il_get_channel_info - Find driver's private channel info * * Based on band and channel number. */ const struct -iwl_channel_info *iwl_legacy_get_channel_info(const struct iwl_priv *priv, +il_channel_info *il_get_channel_info(const struct il_priv *priv, enum ieee80211_band band, u16 channel) { int i; @@ -550,4 +550,4 @@ iwl_channel_info *iwl_legacy_get_channel_info(const struct iwl_priv *priv, return NULL; } -EXPORT_SYMBOL(iwl_legacy_get_channel_info); +EXPORT_SYMBOL(il_get_channel_info); diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.h b/drivers/net/wireless/iwlegacy/iwl-eeprom.h index c59c81002022..9ad687161623 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.h +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.h @@ -60,12 +60,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef __iwl_legacy_eeprom_h__ -#define __iwl_legacy_eeprom_h__ +#ifndef __il_eeprom_h__ +#define __il_eeprom_h__ #include -struct iwl_priv; +struct il_priv; /* * EEPROM access time values: @@ -75,14 +75,14 @@ struct iwl_priv; * When polling, wait 10 uSec between polling loops, up to a maximum 5000 uSec. * Driver reads 16-bit value from bits 31-16 of CSR_EEPROM_REG. */ -#define IWL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */ +#define IL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */ -#define IWL_EEPROM_SEM_TIMEOUT 10 /* microseconds */ -#define IWL_EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ +#define IL_EEPROM_SEM_TIMEOUT 10 /* microseconds */ +#define IL_EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ /* - * Regulatory channel usage flags in EEPROM struct iwl4965_eeprom_channel.flags. + * Regulatory channel usage flags in EEPROM struct il4965_eeprom_channel.flags. * * IBSS and/or AP operation is allowed *only* on those channels with * (VALID && IBSS && ACTIVE && !RADAR). This restriction is in place because @@ -97,7 +97,7 @@ struct iwl_priv; * * NOTE: Using a channel inappropriately will result in a uCode error! */ -#define IWL_NUM_TX_CALIB_GROUPS 5 +#define IL_NUM_TX_CALIB_GROUPS 5 enum { EEPROM_CHANNEL_VALID = (1 << 0), /* usable for this SKU/geo */ EEPROM_CHANNEL_IBSS = (1 << 1), /* usable as an IBSS channel */ @@ -116,7 +116,7 @@ enum { /* *regulatory* channel data format in eeprom, one for each channel. * There are separate entries for HT40 (40 MHz) vs. normal (20 MHz) channels. */ -struct iwl_eeprom_channel { +struct il_eeprom_channel { u8 flags; /* EEPROM_CHANNEL_* flags copied from EEPROM */ s8 max_power_avg; /* max power (dBm) on this chnl, limit 31 */ } __packed; @@ -160,7 +160,7 @@ extern const u8 iwlegacy_eeprom_band_1[14]; * * 4) RF power amplifier detector level measurement (not used). */ -struct iwl_eeprom_calib_measure { +struct il_eeprom_calib_measure { u8 temperature; /* Device temperature (Celsius) */ u8 gain_idx; /* Index into gain table */ u8 actual_pow; /* Measured RF output power, half-dBm */ @@ -176,9 +176,9 @@ struct iwl_eeprom_calib_measure { * 2) Measurements for each of 3 power levels for each of 2 radio transmitters * (a.k.a. "tx chains") (6 measurements altogether) */ -struct iwl_eeprom_calib_ch_info { +struct il_eeprom_calib_ch_info { u8 ch_num; - struct iwl_eeprom_calib_measure + struct il_eeprom_calib_measure measurements[EEPROM_TX_POWER_TX_CHAINS] [EEPROM_TX_POWER_MEASUREMENTS]; } __packed; @@ -193,11 +193,11 @@ struct iwl_eeprom_calib_ch_info { * * 2) Sample measurement sets for 2 channels close to the range endpoints. */ -struct iwl_eeprom_calib_subband_info { +struct il_eeprom_calib_subband_info { u8 ch_from; /* channel number of lowest channel in subband */ u8 ch_to; /* channel number of highest channel in subband */ - struct iwl_eeprom_calib_ch_info ch1; - struct iwl_eeprom_calib_ch_info ch2; + struct il_eeprom_calib_ch_info ch1; + struct il_eeprom_calib_ch_info ch2; } __packed; @@ -218,14 +218,14 @@ struct iwl_eeprom_calib_subband_info { * characteristics of the analog radio circuitry vary with frequency. * * Not all sets need to be filled with data; - * struct iwl_eeprom_calib_subband_info contains range of channels + * struct il_eeprom_calib_subband_info contains range of channels * (0 if unused) for each set of data. */ -struct iwl_eeprom_calib_info { +struct il_eeprom_calib_info { u8 saturation_power24; /* half-dBm (e.g. "34" = 17 dBm) */ u8 saturation_power52; /* half-dBm */ __le16 voltage; /* signed */ - struct iwl_eeprom_calib_subband_info + struct il_eeprom_calib_subband_info band_info[EEPROM_TX_POWER_BANDS]; } __packed; @@ -323,22 +323,22 @@ struct iwl_eeprom_calib_info { #define EEPROM_REGULATORY_BAND_NO_HT40 (0) -struct iwl_eeprom_ops { +struct il_eeprom_ops { const u32 regulatory_bands[7]; - int (*acquire_semaphore) (struct iwl_priv *priv); - void (*release_semaphore) (struct iwl_priv *priv); + int (*acquire_semaphore) (struct il_priv *priv); + void (*release_semaphore) (struct il_priv *priv); }; -int iwl_legacy_eeprom_init(struct iwl_priv *priv); -void iwl_legacy_eeprom_free(struct iwl_priv *priv); -const u8 *iwl_legacy_eeprom_query_addr(const struct iwl_priv *priv, +int il_eeprom_init(struct il_priv *priv); +void il_eeprom_free(struct il_priv *priv); +const u8 *il_eeprom_query_addr(const struct il_priv *priv, size_t offset); -u16 iwl_legacy_eeprom_query16(const struct iwl_priv *priv, size_t offset); -int iwl_legacy_init_channel_map(struct iwl_priv *priv); -void iwl_legacy_free_channel_map(struct iwl_priv *priv); -const struct iwl_channel_info *iwl_legacy_get_channel_info( - const struct iwl_priv *priv, +u16 il_eeprom_query16(const struct il_priv *priv, size_t offset); +int il_init_channel_map(struct il_priv *priv); +void il_free_channel_map(struct il_priv *priv); +const struct il_channel_info *il_get_channel_info( + const struct il_priv *priv, enum ieee80211_band band, u16 channel); -#endif /* __iwl_legacy_eeprom_h__ */ +#endif /* __il_eeprom_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-fh.h b/drivers/net/wireless/iwlegacy/iwl-fh.h index 6e6091816e36..0ae36df1c293 100644 --- a/drivers/net/wireless/iwlegacy/iwl-fh.h +++ b/drivers/net/wireless/iwlegacy/iwl-fh.h @@ -60,8 +60,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *****************************************************************************/ -#ifndef __iwl_legacy_fh_h__ -#define __iwl_legacy_fh_h__ +#ifndef __il_fh_h__ +#define __il_fh_h__ /****************************/ /* Flow Handler Definitions */ @@ -99,7 +99,7 @@ * * 4965 has 16 base pointer registers, one for each of 16 host-DRAM-resident * circular buffers (CBs/queues) containing Transmit Frame Descriptors (TFDs) - * (see struct iwl_tfd_frame). These 16 pointer registers are offset by 0x04 + * (see struct il_tfd_frame). These 16 pointer registers are offset by 0x04 * bytes from one another. Each TFD circular buffer in DRAM must be 256-byte * aligned (address bits 0-7 must be 0). * @@ -146,7 +146,7 @@ * physical address [35:4] into FH_RSCSR_CHNL0_STTS_WPTR_REG [31:0]. * * Bit fields in lower dword of Rx status buffer (upper dword not used - * by driver; see struct iwl4965_shared, val0): + * by driver; see struct il4965_shared, val0): * 31-12: Not used by driver * 11- 0: Index of last filled Rx buffer descriptor * (4965 writes, driver reads this value) @@ -424,12 +424,12 @@ #define RX_LOW_WATERMARK 8 /* Size of one Rx buffer in host DRAM */ -#define IWL_RX_BUF_SIZE_3K (3 * 1000) /* 3945 only */ -#define IWL_RX_BUF_SIZE_4K (4 * 1024) -#define IWL_RX_BUF_SIZE_8K (8 * 1024) +#define IL_RX_BUF_SIZE_3K (3 * 1000) /* 3945 only */ +#define IL_RX_BUF_SIZE_4K (4 * 1024) +#define IL_RX_BUF_SIZE_8K (8 * 1024) /** - * struct iwl_rb_status - reseve buffer status + * struct il_rb_status - reseve buffer status * host memory mapped FH registers * @closed_rb_num [0:11] - Indicates the index of the RB which was closed * @closed_fr_num [0:11] - Indicates the index of the RX Frame which was closed @@ -438,7 +438,7 @@ * @finished_fr_num [0:11] - Indicates the index of the RX Frame * which was transferred */ -struct iwl_rb_status { +struct il_rb_status { __le16 closed_rb_num; __le16 closed_fr_num; __le16 finished_rb_num; @@ -450,15 +450,15 @@ struct iwl_rb_status { #define TFD_QUEUE_SIZE_MAX (256) #define TFD_QUEUE_SIZE_BC_DUP (64) #define TFD_QUEUE_BC_SIZE (TFD_QUEUE_SIZE_MAX + TFD_QUEUE_SIZE_BC_DUP) -#define IWL_TX_DMA_MASK DMA_BIT_MASK(36) -#define IWL_NUM_OF_TBS 20 +#define IL_TX_DMA_MASK DMA_BIT_MASK(36) +#define IL_NUM_OF_TBS 20 -static inline u8 iwl_legacy_get_dma_hi_addr(dma_addr_t addr) +static inline u8 il_get_dma_hi_addr(dma_addr_t addr) { return (sizeof(addr) > sizeof(u32) ? (addr >> 16) >> 16 : 0) & 0xF; } /** - * struct iwl_tfd_tb transmit buffer descriptor within transmit frame descriptor + * struct il_tfd_tb transmit buffer descriptor within transmit frame descriptor * * This structure contains dma address and length of transmission address * @@ -467,13 +467,13 @@ static inline u8 iwl_legacy_get_dma_hi_addr(dma_addr_t addr) * @hi_n_len 0-3 [35:32] portion of dma * 4-15 length of the tx buffer */ -struct iwl_tfd_tb { +struct il_tfd_tb { __le32 lo; __le16 hi_n_len; } __packed; /** - * struct iwl_tfd + * struct il_tfd * * Transmit Frame Descriptor (TFD) * @@ -500,14 +500,14 @@ struct iwl_tfd_tb { * * A maximum of 255 (not 256!) TFDs may be on a queue waiting for Tx. */ -struct iwl_tfd { +struct il_tfd { u8 __reserved1[3]; u8 num_tbs; - struct iwl_tfd_tb tbs[IWL_NUM_OF_TBS]; + struct il_tfd_tb tbs[IL_NUM_OF_TBS]; __le32 __pad; } __packed; /* Keep Warm Size */ -#define IWL_KW_SIZE 0x1000 /* 4k */ +#define IL_KW_SIZE 0x1000 /* 4k */ -#endif /* !__iwl_legacy_fh_h__ */ +#endif /* !__il_fh_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-hcmd.c b/drivers/net/wireless/iwlegacy/iwl-hcmd.c index ce1fc9feb61f..515befc28001 100644 --- a/drivers/net/wireless/iwlegacy/iwl-hcmd.c +++ b/drivers/net/wireless/iwlegacy/iwl-hcmd.c @@ -37,66 +37,66 @@ #include "iwl-core.h" -const char *iwl_legacy_get_cmd_string(u8 cmd) +const char *il_get_cmd_string(u8 cmd) { switch (cmd) { - IWL_CMD(REPLY_ALIVE); - IWL_CMD(REPLY_ERROR); - IWL_CMD(REPLY_RXON); - IWL_CMD(REPLY_RXON_ASSOC); - IWL_CMD(REPLY_QOS_PARAM); - IWL_CMD(REPLY_RXON_TIMING); - IWL_CMD(REPLY_ADD_STA); - IWL_CMD(REPLY_REMOVE_STA); - IWL_CMD(REPLY_WEPKEY); - IWL_CMD(REPLY_3945_RX); - IWL_CMD(REPLY_TX); - IWL_CMD(REPLY_RATE_SCALE); - IWL_CMD(REPLY_LEDS_CMD); - IWL_CMD(REPLY_TX_LINK_QUALITY_CMD); - IWL_CMD(REPLY_CHANNEL_SWITCH); - IWL_CMD(CHANNEL_SWITCH_NOTIFICATION); - IWL_CMD(REPLY_SPECTRUM_MEASUREMENT_CMD); - IWL_CMD(SPECTRUM_MEASURE_NOTIFICATION); - IWL_CMD(POWER_TABLE_CMD); - IWL_CMD(PM_SLEEP_NOTIFICATION); - IWL_CMD(PM_DEBUG_STATISTIC_NOTIFIC); - IWL_CMD(REPLY_SCAN_CMD); - IWL_CMD(REPLY_SCAN_ABORT_CMD); - IWL_CMD(SCAN_START_NOTIFICATION); - IWL_CMD(SCAN_RESULTS_NOTIFICATION); - IWL_CMD(SCAN_COMPLETE_NOTIFICATION); - IWL_CMD(BEACON_NOTIFICATION); - IWL_CMD(REPLY_TX_BEACON); - IWL_CMD(REPLY_TX_PWR_TABLE_CMD); - IWL_CMD(REPLY_BT_CONFIG); - IWL_CMD(REPLY_STATISTICS_CMD); - IWL_CMD(STATISTICS_NOTIFICATION); - IWL_CMD(CARD_STATE_NOTIFICATION); - IWL_CMD(MISSED_BEACONS_NOTIFICATION); - IWL_CMD(REPLY_CT_KILL_CONFIG_CMD); - IWL_CMD(SENSITIVITY_CMD); - IWL_CMD(REPLY_PHY_CALIBRATION_CMD); - IWL_CMD(REPLY_RX_PHY_CMD); - IWL_CMD(REPLY_RX_MPDU_CMD); - IWL_CMD(REPLY_RX); - IWL_CMD(REPLY_COMPRESSED_BA); + IL_CMD(REPLY_ALIVE); + IL_CMD(REPLY_ERROR); + IL_CMD(REPLY_RXON); + IL_CMD(REPLY_RXON_ASSOC); + IL_CMD(REPLY_QOS_PARAM); + IL_CMD(REPLY_RXON_TIMING); + IL_CMD(REPLY_ADD_STA); + IL_CMD(REPLY_REMOVE_STA); + IL_CMD(REPLY_WEPKEY); + IL_CMD(REPLY_3945_RX); + IL_CMD(REPLY_TX); + IL_CMD(REPLY_RATE_SCALE); + IL_CMD(REPLY_LEDS_CMD); + IL_CMD(REPLY_TX_LINK_QUALITY_CMD); + IL_CMD(REPLY_CHANNEL_SWITCH); + IL_CMD(CHANNEL_SWITCH_NOTIFICATION); + IL_CMD(REPLY_SPECTRUM_MEASUREMENT_CMD); + IL_CMD(SPECTRUM_MEASURE_NOTIFICATION); + IL_CMD(POWER_TABLE_CMD); + IL_CMD(PM_SLEEP_NOTIFICATION); + IL_CMD(PM_DEBUG_STATISTIC_NOTIFIC); + IL_CMD(REPLY_SCAN_CMD); + IL_CMD(REPLY_SCAN_ABORT_CMD); + IL_CMD(SCAN_START_NOTIFICATION); + IL_CMD(SCAN_RESULTS_NOTIFICATION); + IL_CMD(SCAN_COMPLETE_NOTIFICATION); + IL_CMD(BEACON_NOTIFICATION); + IL_CMD(REPLY_TX_BEACON); + IL_CMD(REPLY_TX_PWR_TABLE_CMD); + IL_CMD(REPLY_BT_CONFIG); + IL_CMD(REPLY_STATISTICS_CMD); + IL_CMD(STATISTICS_NOTIFICATION); + IL_CMD(CARD_STATE_NOTIFICATION); + IL_CMD(MISSED_BEACONS_NOTIFICATION); + IL_CMD(REPLY_CT_KILL_CONFIG_CMD); + IL_CMD(SENSITIVITY_CMD); + IL_CMD(REPLY_PHY_CALIBRATION_CMD); + IL_CMD(REPLY_RX_PHY_CMD); + IL_CMD(REPLY_RX_MPDU_CMD); + IL_CMD(REPLY_RX); + IL_CMD(REPLY_COMPRESSED_BA); default: return "UNKNOWN"; } } -EXPORT_SYMBOL(iwl_legacy_get_cmd_string); +EXPORT_SYMBOL(il_get_cmd_string); #define HOST_COMPLETE_TIMEOUT (HZ / 2) -static void iwl_legacy_generic_cmd_callback(struct iwl_priv *priv, - struct iwl_device_cmd *cmd, - struct iwl_rx_packet *pkt) +static void il_generic_cmd_callback(struct il_priv *priv, + struct il_device_cmd *cmd, + struct il_rx_packet *pkt) { - if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) { - IWL_ERR(priv, "Bad return from %s (0x%08X)\n", - iwl_legacy_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); + if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { + IL_ERR(priv, "Bad return from %s (0x%08X)\n", + il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); return; } @@ -104,18 +104,18 @@ static void iwl_legacy_generic_cmd_callback(struct iwl_priv *priv, switch (cmd->hdr.cmd) { case REPLY_TX_LINK_QUALITY_CMD: case SENSITIVITY_CMD: - IWL_DEBUG_HC_DUMP(priv, "back from %s (0x%08X)\n", - iwl_legacy_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); + IL_DEBUG_HC_DUMP(priv, "back from %s (0x%08X)\n", + il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); break; default: - IWL_DEBUG_HC(priv, "back from %s (0x%08X)\n", - iwl_legacy_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); + IL_DEBUG_HC(priv, "back from %s (0x%08X)\n", + il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); } #endif } static int -iwl_legacy_send_cmd_async(struct iwl_priv *priv, struct iwl_host_cmd *cmd) +il_send_cmd_async(struct il_priv *priv, struct il_host_cmd *cmd) { int ret; @@ -126,21 +126,21 @@ iwl_legacy_send_cmd_async(struct iwl_priv *priv, struct iwl_host_cmd *cmd) /* Assign a generic callback if one is not provided */ if (!cmd->callback) - cmd->callback = iwl_legacy_generic_cmd_callback; + cmd->callback = il_generic_cmd_callback; if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return -EBUSY; - ret = iwl_legacy_enqueue_hcmd(priv, cmd); + ret = il_enqueue_hcmd(priv, cmd); if (ret < 0) { - IWL_ERR(priv, "Error sending %s: enqueue_hcmd failed: %d\n", - iwl_legacy_get_cmd_string(cmd->id), ret); + IL_ERR(priv, "Error sending %s: enqueue_hcmd failed: %d\n", + il_get_cmd_string(cmd->id), ret); return ret; } return 0; } -int iwl_legacy_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd) +int il_send_cmd_sync(struct il_priv *priv, struct il_host_cmd *cmd) { int cmd_idx; int ret; @@ -152,18 +152,18 @@ int iwl_legacy_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd) /* A synchronous command can not have a callback set. */ BUG_ON(cmd->callback); - IWL_DEBUG_INFO(priv, "Attempting to send sync command %s\n", - iwl_legacy_get_cmd_string(cmd->id)); + IL_DEBUG_INFO(priv, "Attempting to send sync command %s\n", + il_get_cmd_string(cmd->id)); set_bit(STATUS_HCMD_ACTIVE, &priv->status); - IWL_DEBUG_INFO(priv, "Setting HCMD_ACTIVE for command %s\n", - iwl_legacy_get_cmd_string(cmd->id)); + IL_DEBUG_INFO(priv, "Setting HCMD_ACTIVE for command %s\n", + il_get_cmd_string(cmd->id)); - cmd_idx = iwl_legacy_enqueue_hcmd(priv, cmd); + cmd_idx = il_enqueue_hcmd(priv, cmd); if (cmd_idx < 0) { ret = cmd_idx; - IWL_ERR(priv, "Error sending %s: enqueue_hcmd failed: %d\n", - iwl_legacy_get_cmd_string(cmd->id), ret); + IL_ERR(priv, "Error sending %s: enqueue_hcmd failed: %d\n", + il_get_cmd_string(cmd->id), ret); goto out; } @@ -172,35 +172,35 @@ int iwl_legacy_send_cmd_sync(struct iwl_priv *priv, struct iwl_host_cmd *cmd) HOST_COMPLETE_TIMEOUT); if (!ret) { if (test_bit(STATUS_HCMD_ACTIVE, &priv->status)) { - IWL_ERR(priv, + IL_ERR(priv, "Error sending %s: time out after %dms.\n", - iwl_legacy_get_cmd_string(cmd->id), + il_get_cmd_string(cmd->id), jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); clear_bit(STATUS_HCMD_ACTIVE, &priv->status); - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "Clearing HCMD_ACTIVE for command %s\n", - iwl_legacy_get_cmd_string(cmd->id)); + il_get_cmd_string(cmd->id)); ret = -ETIMEDOUT; goto cancel; } } if (test_bit(STATUS_RF_KILL_HW, &priv->status)) { - IWL_ERR(priv, "Command %s aborted: RF KILL Switch\n", - iwl_legacy_get_cmd_string(cmd->id)); + IL_ERR(priv, "Command %s aborted: RF KILL Switch\n", + il_get_cmd_string(cmd->id)); ret = -ECANCELED; goto fail; } if (test_bit(STATUS_FW_ERROR, &priv->status)) { - IWL_ERR(priv, "Command %s failed: FW Error\n", - iwl_legacy_get_cmd_string(cmd->id)); + IL_ERR(priv, "Command %s failed: FW Error\n", + il_get_cmd_string(cmd->id)); ret = -EIO; goto fail; } if ((cmd->flags & CMD_WANT_SKB) && !cmd->reply_page) { - IWL_ERR(priv, "Error: Response NULL in '%s'\n", - iwl_legacy_get_cmd_string(cmd->id)); + IL_ERR(priv, "Error: Response NULL in '%s'\n", + il_get_cmd_string(cmd->id)); ret = -EIO; goto cancel; } @@ -221,43 +221,43 @@ cancel: } fail: if (cmd->reply_page) { - iwl_legacy_free_pages(priv, cmd->reply_page); + il_free_pages(priv, cmd->reply_page); cmd->reply_page = 0; } out: return ret; } -EXPORT_SYMBOL(iwl_legacy_send_cmd_sync); +EXPORT_SYMBOL(il_send_cmd_sync); -int iwl_legacy_send_cmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) +int il_send_cmd(struct il_priv *priv, struct il_host_cmd *cmd) { if (cmd->flags & CMD_ASYNC) - return iwl_legacy_send_cmd_async(priv, cmd); + return il_send_cmd_async(priv, cmd); - return iwl_legacy_send_cmd_sync(priv, cmd); + return il_send_cmd_sync(priv, cmd); } -EXPORT_SYMBOL(iwl_legacy_send_cmd); +EXPORT_SYMBOL(il_send_cmd); int -iwl_legacy_send_cmd_pdu(struct iwl_priv *priv, u8 id, u16 len, const void *data) +il_send_cmd_pdu(struct il_priv *priv, u8 id, u16 len, const void *data) { - struct iwl_host_cmd cmd = { + struct il_host_cmd cmd = { .id = id, .len = len, .data = data, }; - return iwl_legacy_send_cmd_sync(priv, &cmd); + return il_send_cmd_sync(priv, &cmd); } -EXPORT_SYMBOL(iwl_legacy_send_cmd_pdu); +EXPORT_SYMBOL(il_send_cmd_pdu); -int iwl_legacy_send_cmd_pdu_async(struct iwl_priv *priv, +int il_send_cmd_pdu_async(struct il_priv *priv, u8 id, u16 len, const void *data, - void (*callback)(struct iwl_priv *priv, - struct iwl_device_cmd *cmd, - struct iwl_rx_packet *pkt)) + void (*callback)(struct il_priv *priv, + struct il_device_cmd *cmd, + struct il_rx_packet *pkt)) { - struct iwl_host_cmd cmd = { + struct il_host_cmd cmd = { .id = id, .len = len, .data = data, @@ -266,6 +266,6 @@ int iwl_legacy_send_cmd_pdu_async(struct iwl_priv *priv, cmd.flags |= CMD_ASYNC; cmd.callback = callback; - return iwl_legacy_send_cmd_async(priv, &cmd); + return il_send_cmd_async(priv, &cmd); } -EXPORT_SYMBOL(iwl_legacy_send_cmd_pdu_async); +EXPORT_SYMBOL(il_send_cmd_pdu_async); diff --git a/drivers/net/wireless/iwlegacy/iwl-helpers.h b/drivers/net/wireless/iwlegacy/iwl-helpers.h index 5cf23eaecbbb..e4e63b570f57 100644 --- a/drivers/net/wireless/iwlegacy/iwl-helpers.h +++ b/drivers/net/wireless/iwlegacy/iwl-helpers.h @@ -27,45 +27,45 @@ * *****************************************************************************/ -#ifndef __iwl_legacy_helpers_h__ -#define __iwl_legacy_helpers_h__ +#ifndef __il_helpers_h__ +#define __il_helpers_h__ #include #include #include "iwl-io.h" -#define IWL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) +#define IL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) -static inline struct ieee80211_conf *iwl_legacy_ieee80211_get_hw_conf( +static inline struct ieee80211_conf *il_ieee80211_get_hw_conf( struct ieee80211_hw *hw) { return &hw->conf; } /** - * iwl_legacy_queue_inc_wrap - increment queue index, wrap back to beginning + * il_queue_inc_wrap - increment queue index, wrap back to beginning * @index -- current index * @n_bd -- total number of entries in queue (must be power of 2) */ -static inline int iwl_legacy_queue_inc_wrap(int index, int n_bd) +static inline int il_queue_inc_wrap(int index, int n_bd) { return ++index & (n_bd - 1); } /** - * iwl_legacy_queue_dec_wrap - decrement queue index, wrap back to end + * il_queue_dec_wrap - decrement queue index, wrap back to end * @index -- current index * @n_bd -- total number of entries in queue (must be power of 2) */ -static inline int iwl_legacy_queue_dec_wrap(int index, int n_bd) +static inline int il_queue_dec_wrap(int index, int n_bd) { return --index & (n_bd - 1); } /* TODO: Move fw_desc functions to iwl-pci.ko */ -static inline void iwl_legacy_free_fw_desc(struct pci_dev *pci_dev, +static inline void il_free_fw_desc(struct pci_dev *pci_dev, struct fw_desc *desc) { if (desc->v_addr) @@ -75,7 +75,7 @@ static inline void iwl_legacy_free_fw_desc(struct pci_dev *pci_dev, desc->len = 0; } -static inline int iwl_legacy_alloc_fw_desc(struct pci_dev *pci_dev, +static inline int il_alloc_fw_desc(struct pci_dev *pci_dev, struct fw_desc *desc) { if (!desc->len) { @@ -100,7 +100,7 @@ static inline int iwl_legacy_alloc_fw_desc(struct pci_dev *pci_dev, * +---------------------- unused */ static inline void -iwl_legacy_set_swq_id(struct iwl_tx_queue *txq, u8 ac, u8 hwq) +il_set_swq_id(struct il_tx_queue *txq, u8 ac, u8 hwq) { BUG_ON(ac > 3); /* only have 2 bits */ BUG_ON(hwq > 31); /* only use 5 bits */ @@ -108,8 +108,8 @@ iwl_legacy_set_swq_id(struct iwl_tx_queue *txq, u8 ac, u8 hwq) txq->swq_id = (hwq << 2) | ac; } -static inline void iwl_legacy_wake_queue(struct iwl_priv *priv, - struct iwl_tx_queue *txq) +static inline void il_wake_queue(struct il_priv *priv, + struct il_tx_queue *txq) { u8 queue = txq->swq_id; u8 ac = queue & 3; @@ -120,8 +120,8 @@ static inline void iwl_legacy_wake_queue(struct iwl_priv *priv, ieee80211_wake_queue(priv->hw, ac); } -static inline void iwl_legacy_stop_queue(struct iwl_priv *priv, - struct iwl_tx_queue *txq) +static inline void il_stop_queue(struct il_priv *priv, + struct il_tx_queue *txq) { u8 queue = txq->swq_id; u8 ac = queue & 3; @@ -144,53 +144,53 @@ static inline void iwl_legacy_stop_queue(struct iwl_priv *priv, #define ieee80211_wake_queue DO_NOT_USE_ieee80211_wake_queue -static inline void iwl_legacy_disable_interrupts(struct iwl_priv *priv) +static inline void il_disable_interrupts(struct il_priv *priv) { clear_bit(STATUS_INT_ENABLED, &priv->status); /* disable interrupts from uCode/NIC to host */ - iwl_write32(priv, CSR_INT_MASK, 0x00000000); + il_write32(priv, CSR_INT_MASK, 0x00000000); /* acknowledge/clear/reset any interrupts still pending * from uCode or flow handler (Rx/Tx DMA) */ - iwl_write32(priv, CSR_INT, 0xffffffff); - iwl_write32(priv, CSR_FH_INT_STATUS, 0xffffffff); - IWL_DEBUG_ISR(priv, "Disabled interrupts\n"); + il_write32(priv, CSR_INT, 0xffffffff); + il_write32(priv, CSR_FH_INT_STATUS, 0xffffffff); + IL_DEBUG_ISR(priv, "Disabled interrupts\n"); } -static inline void iwl_legacy_enable_rfkill_int(struct iwl_priv *priv) +static inline void il_enable_rfkill_int(struct il_priv *priv) { - IWL_DEBUG_ISR(priv, "Enabling rfkill interrupt\n"); - iwl_write32(priv, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); + IL_DEBUG_ISR(priv, "Enabling rfkill interrupt\n"); + il_write32(priv, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); } -static inline void iwl_legacy_enable_interrupts(struct iwl_priv *priv) +static inline void il_enable_interrupts(struct il_priv *priv) { - IWL_DEBUG_ISR(priv, "Enabling interrupts\n"); + IL_DEBUG_ISR(priv, "Enabling interrupts\n"); set_bit(STATUS_INT_ENABLED, &priv->status); - iwl_write32(priv, CSR_INT_MASK, priv->inta_mask); + il_write32(priv, CSR_INT_MASK, priv->inta_mask); } /** - * iwl_legacy_beacon_time_mask_low - mask of lower 32 bit of beacon time - * @priv -- pointer to iwl_priv data structure + * il_beacon_time_mask_low - mask of lower 32 bit of beacon time + * @priv -- pointer to il_priv data structure * @tsf_bits -- number of bits need to shift for masking) */ -static inline u32 iwl_legacy_beacon_time_mask_low(struct iwl_priv *priv, +static inline u32 il_beacon_time_mask_low(struct il_priv *priv, u16 tsf_bits) { return (1 << tsf_bits) - 1; } /** - * iwl_legacy_beacon_time_mask_high - mask of higher 32 bit of beacon time - * @priv -- pointer to iwl_priv data structure + * il_beacon_time_mask_high - mask of higher 32 bit of beacon time + * @priv -- pointer to il_priv data structure * @tsf_bits -- number of bits need to shift for masking) */ -static inline u32 iwl_legacy_beacon_time_mask_high(struct iwl_priv *priv, +static inline u32 il_beacon_time_mask_high(struct il_priv *priv, u16 tsf_bits) { return ((1 << (32 - tsf_bits)) - 1) << tsf_bits; } -#endif /* __iwl_legacy_helpers_h__ */ +#endif /* __il_helpers_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h index 868ef01e2058..ebeb6e2aa6e7 100644 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ b/drivers/net/wireless/iwlegacy/iwl-io.h @@ -26,8 +26,8 @@ * *****************************************************************************/ -#ifndef __iwl_legacy_io_h__ -#define __iwl_legacy_io_h__ +#ifndef __il_io_h__ +#define __il_io_h__ #include @@ -52,8 +52,8 @@ * * If you wish to call the function without any debug or state checking, * you should use the single _ prefix version (as is used by dependent IO - * routines, for example _iwl_legacy_read_direct32 calls the non-check version of - * _iwl_legacy_read32.) + * routines, for example _il_read_direct32 calls the non-check version of + * _il_read32.) * * These declarations are *extremely* useful in quickly isolating code deltas * which result in misconfiguration of the hardware I/O. In combination with @@ -62,46 +62,46 @@ * */ -static inline void _iwl_legacy_write8(struct iwl_priv *priv, u32 ofs, u8 val) +static inline void _il_write8(struct il_priv *priv, u32 ofs, u8 val) { iowrite8(val, priv->hw_base + ofs); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline void -__iwl_legacy_write8(const char *f, u32 l, struct iwl_priv *priv, +__il_write8(const char *f, u32 l, struct il_priv *priv, u32 ofs, u8 val) { - IWL_DEBUG_IO(priv, "write8(0x%08X, 0x%02X) - %s %d\n", ofs, val, f, l); - _iwl_legacy_write8(priv, ofs, val); + IL_DEBUG_IO(priv, "write8(0x%08X, 0x%02X) - %s %d\n", ofs, val, f, l); + _il_write8(priv, ofs, val); } -#define iwl_write8(priv, ofs, val) \ - __iwl_legacy_write8(__FILE__, __LINE__, priv, ofs, val) +#define il_write8(priv, ofs, val) \ + __il_write8(__FILE__, __LINE__, priv, ofs, val) #else -#define iwl_write8(priv, ofs, val) _iwl_legacy_write8(priv, ofs, val) +#define il_write8(priv, ofs, val) _il_write8(priv, ofs, val) #endif -static inline void _iwl_legacy_write32(struct iwl_priv *priv, u32 ofs, u32 val) +static inline void _il_write32(struct il_priv *priv, u32 ofs, u32 val) { iowrite32(val, priv->hw_base + ofs); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline void -__iwl_legacy_write32(const char *f, u32 l, struct iwl_priv *priv, +__il_write32(const char *f, u32 l, struct il_priv *priv, u32 ofs, u32 val) { - IWL_DEBUG_IO(priv, "write32(0x%08X, 0x%08X) - %s %d\n", ofs, val, f, l); - _iwl_legacy_write32(priv, ofs, val); + IL_DEBUG_IO(priv, "write32(0x%08X, 0x%08X) - %s %d\n", ofs, val, f, l); + _il_write32(priv, ofs, val); } -#define iwl_write32(priv, ofs, val) \ - __iwl_legacy_write32(__FILE__, __LINE__, priv, ofs, val) +#define il_write32(priv, ofs, val) \ + __il_write32(__FILE__, __LINE__, priv, ofs, val) #else -#define iwl_write32(priv, ofs, val) _iwl_legacy_write32(priv, ofs, val) +#define il_write32(priv, ofs, val) _il_write32(priv, ofs, val) #endif -static inline u32 _iwl_legacy_read32(struct iwl_priv *priv, u32 ofs) +static inline u32 _il_read32(struct il_priv *priv, u32 ofs) { u32 val = ioread32(priv->hw_base + ofs); return val; @@ -109,122 +109,122 @@ static inline u32 _iwl_legacy_read32(struct iwl_priv *priv, u32 ofs) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline u32 -__iwl_legacy_read32(char *f, u32 l, struct iwl_priv *priv, u32 ofs) +__il_read32(char *f, u32 l, struct il_priv *priv, u32 ofs) { - IWL_DEBUG_IO(priv, "read_direct32(0x%08X) - %s %d\n", ofs, f, l); - return _iwl_legacy_read32(priv, ofs); + IL_DEBUG_IO(priv, "read_direct32(0x%08X) - %s %d\n", ofs, f, l); + return _il_read32(priv, ofs); } -#define iwl_read32(priv, ofs) __iwl_legacy_read32(__FILE__, __LINE__, priv, ofs) +#define il_read32(priv, ofs) __il_read32(__FILE__, __LINE__, priv, ofs) #else -#define iwl_read32(p, o) _iwl_legacy_read32(p, o) +#define il_read32(p, o) _il_read32(p, o) #endif -#define IWL_POLL_INTERVAL 10 /* microseconds */ +#define IL_POLL_INTERVAL 10 /* microseconds */ static inline int -_iwl_legacy_poll_bit(struct iwl_priv *priv, u32 addr, +_il_poll_bit(struct il_priv *priv, u32 addr, u32 bits, u32 mask, int timeout) { int t = 0; do { - if ((_iwl_legacy_read32(priv, addr) & mask) == (bits & mask)) + if ((_il_read32(priv, addr) & mask) == (bits & mask)) return t; - udelay(IWL_POLL_INTERVAL); - t += IWL_POLL_INTERVAL; + udelay(IL_POLL_INTERVAL); + t += IL_POLL_INTERVAL; } while (t < timeout); return -ETIMEDOUT; } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline int __iwl_legacy_poll_bit(const char *f, u32 l, - struct iwl_priv *priv, u32 addr, +static inline int __il_poll_bit(const char *f, u32 l, + struct il_priv *priv, u32 addr, u32 bits, u32 mask, int timeout) { - int ret = _iwl_legacy_poll_bit(priv, addr, bits, mask, timeout); - IWL_DEBUG_IO(priv, "poll_bit(0x%08X, 0x%08X, 0x%08X) - %s- %s %d\n", + int ret = _il_poll_bit(priv, addr, bits, mask, timeout); + IL_DEBUG_IO(priv, "poll_bit(0x%08X, 0x%08X, 0x%08X) - %s- %s %d\n", addr, bits, mask, unlikely(ret == -ETIMEDOUT) ? "timeout" : "", f, l); return ret; } -#define iwl_poll_bit(priv, addr, bits, mask, timeout) \ - __iwl_legacy_poll_bit(__FILE__, __LINE__, priv, addr, \ +#define il_poll_bit(priv, addr, bits, mask, timeout) \ + __il_poll_bit(__FILE__, __LINE__, priv, addr, \ bits, mask, timeout) #else -#define iwl_poll_bit(p, a, b, m, t) _iwl_legacy_poll_bit(p, a, b, m, t) +#define il_poll_bit(p, a, b, m, t) _il_poll_bit(p, a, b, m, t) #endif -static inline void _iwl_legacy_set_bit(struct iwl_priv *priv, u32 reg, u32 mask) +static inline void _il_set_bit(struct il_priv *priv, u32 reg, u32 mask) { - _iwl_legacy_write32(priv, reg, _iwl_legacy_read32(priv, reg) | mask); + _il_write32(priv, reg, _il_read32(priv, reg) | mask); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline void __iwl_legacy_set_bit(const char *f, u32 l, - struct iwl_priv *priv, u32 reg, u32 mask) +static inline void __il_set_bit(const char *f, u32 l, + struct il_priv *priv, u32 reg, u32 mask) { - u32 val = _iwl_legacy_read32(priv, reg) | mask; - IWL_DEBUG_IO(priv, "set_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, + u32 val = _il_read32(priv, reg) | mask; + IL_DEBUG_IO(priv, "set_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val); - _iwl_legacy_write32(priv, reg, val); + _il_write32(priv, reg, val); } -static inline void iwl_legacy_set_bit(struct iwl_priv *p, u32 r, u32 m) +static inline void il_set_bit(struct il_priv *p, u32 r, u32 m) { unsigned long reg_flags; spin_lock_irqsave(&p->reg_lock, reg_flags); - __iwl_legacy_set_bit(__FILE__, __LINE__, p, r, m); + __il_set_bit(__FILE__, __LINE__, p, r, m); spin_unlock_irqrestore(&p->reg_lock, reg_flags); } #else -static inline void iwl_legacy_set_bit(struct iwl_priv *p, u32 r, u32 m) +static inline void il_set_bit(struct il_priv *p, u32 r, u32 m) { unsigned long reg_flags; spin_lock_irqsave(&p->reg_lock, reg_flags); - _iwl_legacy_set_bit(p, r, m); + _il_set_bit(p, r, m); spin_unlock_irqrestore(&p->reg_lock, reg_flags); } #endif static inline void -_iwl_legacy_clear_bit(struct iwl_priv *priv, u32 reg, u32 mask) +_il_clear_bit(struct il_priv *priv, u32 reg, u32 mask) { - _iwl_legacy_write32(priv, reg, _iwl_legacy_read32(priv, reg) & ~mask); + _il_write32(priv, reg, _il_read32(priv, reg) & ~mask); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline void -__iwl_legacy_clear_bit(const char *f, u32 l, - struct iwl_priv *priv, u32 reg, u32 mask) +__il_clear_bit(const char *f, u32 l, + struct il_priv *priv, u32 reg, u32 mask) { - u32 val = _iwl_legacy_read32(priv, reg) & ~mask; - IWL_DEBUG_IO(priv, "clear_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val); - _iwl_legacy_write32(priv, reg, val); + u32 val = _il_read32(priv, reg) & ~mask; + IL_DEBUG_IO(priv, "clear_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val); + _il_write32(priv, reg, val); } -static inline void iwl_legacy_clear_bit(struct iwl_priv *p, u32 r, u32 m) +static inline void il_clear_bit(struct il_priv *p, u32 r, u32 m) { unsigned long reg_flags; spin_lock_irqsave(&p->reg_lock, reg_flags); - __iwl_legacy_clear_bit(__FILE__, __LINE__, p, r, m); + __il_clear_bit(__FILE__, __LINE__, p, r, m); spin_unlock_irqrestore(&p->reg_lock, reg_flags); } #else -static inline void iwl_legacy_clear_bit(struct iwl_priv *p, u32 r, u32 m) +static inline void il_clear_bit(struct il_priv *p, u32 r, u32 m) { unsigned long reg_flags; spin_lock_irqsave(&p->reg_lock, reg_flags); - _iwl_legacy_clear_bit(p, r, m); + _il_clear_bit(p, r, m); spin_unlock_irqrestore(&p->reg_lock, reg_flags); } #endif -static inline int _iwl_legacy_grab_nic_access(struct iwl_priv *priv) +static inline int _il_grab_nic_access(struct il_priv *priv) { int ret; u32 val; /* this bit wakes up the NIC */ - _iwl_legacy_set_bit(priv, CSR_GP_CNTRL, + _il_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); /* @@ -244,15 +244,15 @@ static inline int _iwl_legacy_grab_nic_access(struct iwl_priv *priv) * good idea before accessing 3945/4965 SRAM (e.g. reading Event Log). * */ - ret = _iwl_legacy_poll_bit(priv, CSR_GP_CNTRL, + ret = _il_poll_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN, (CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY | CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 15000); if (ret < 0) { - val = _iwl_legacy_read32(priv, CSR_GP_CNTRL); - IWL_ERR(priv, + val = _il_read32(priv, CSR_GP_CNTRL); + IL_ERR(priv, "MAC is in deep sleep!. CSR_GP_CNTRL = 0x%08X\n", val); - _iwl_legacy_write32(priv, CSR_RESET, + _il_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_FORCE_NMI); return -EIO; } @@ -261,280 +261,280 @@ static inline int _iwl_legacy_grab_nic_access(struct iwl_priv *priv) } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline int __iwl_legacy_grab_nic_access(const char *f, u32 l, - struct iwl_priv *priv) +static inline int __il_grab_nic_access(const char *f, u32 l, + struct il_priv *priv) { - IWL_DEBUG_IO(priv, "grabbing nic access - %s %d\n", f, l); - return _iwl_legacy_grab_nic_access(priv); + IL_DEBUG_IO(priv, "grabbing nic access - %s %d\n", f, l); + return _il_grab_nic_access(priv); } -#define iwl_grab_nic_access(priv) \ - __iwl_legacy_grab_nic_access(__FILE__, __LINE__, priv) +#define il_grab_nic_access(priv) \ + __il_grab_nic_access(__FILE__, __LINE__, priv) #else -#define iwl_grab_nic_access(priv) \ - _iwl_legacy_grab_nic_access(priv) +#define il_grab_nic_access(priv) \ + _il_grab_nic_access(priv) #endif -static inline void _iwl_legacy_release_nic_access(struct iwl_priv *priv) +static inline void _il_release_nic_access(struct il_priv *priv) { - _iwl_legacy_clear_bit(priv, CSR_GP_CNTRL, + _il_clear_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline void __iwl_legacy_release_nic_access(const char *f, u32 l, - struct iwl_priv *priv) +static inline void __il_release_nic_access(const char *f, u32 l, + struct il_priv *priv) { - IWL_DEBUG_IO(priv, "releasing nic access - %s %d\n", f, l); - _iwl_legacy_release_nic_access(priv); + IL_DEBUG_IO(priv, "releasing nic access - %s %d\n", f, l); + _il_release_nic_access(priv); } -#define iwl_release_nic_access(priv) \ - __iwl_legacy_release_nic_access(__FILE__, __LINE__, priv) +#define il_release_nic_access(priv) \ + __il_release_nic_access(__FILE__, __LINE__, priv) #else -#define iwl_release_nic_access(priv) \ - _iwl_legacy_release_nic_access(priv) +#define il_release_nic_access(priv) \ + _il_release_nic_access(priv) #endif -static inline u32 _iwl_legacy_read_direct32(struct iwl_priv *priv, u32 reg) +static inline u32 _il_read_direct32(struct il_priv *priv, u32 reg) { - return _iwl_legacy_read32(priv, reg); + return _il_read32(priv, reg); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline u32 __iwl_legacy_read_direct32(const char *f, u32 l, - struct iwl_priv *priv, u32 reg) +static inline u32 __il_read_direct32(const char *f, u32 l, + struct il_priv *priv, u32 reg) { - u32 value = _iwl_legacy_read_direct32(priv, reg); - IWL_DEBUG_IO(priv, + u32 value = _il_read_direct32(priv, reg); + IL_DEBUG_IO(priv, "read_direct32(0x%4X) = 0x%08x - %s %d\n", reg, value, f, l); return value; } -static inline u32 iwl_legacy_read_direct32(struct iwl_priv *priv, u32 reg) +static inline u32 il_read_direct32(struct il_priv *priv, u32 reg) { u32 value; unsigned long reg_flags; spin_lock_irqsave(&priv->reg_lock, reg_flags); - iwl_grab_nic_access(priv); - value = __iwl_legacy_read_direct32(__FILE__, __LINE__, priv, reg); - iwl_release_nic_access(priv); + il_grab_nic_access(priv); + value = __il_read_direct32(__FILE__, __LINE__, priv, reg); + il_release_nic_access(priv); spin_unlock_irqrestore(&priv->reg_lock, reg_flags); return value; } #else -static inline u32 iwl_legacy_read_direct32(struct iwl_priv *priv, u32 reg) +static inline u32 il_read_direct32(struct il_priv *priv, u32 reg) { u32 value; unsigned long reg_flags; spin_lock_irqsave(&priv->reg_lock, reg_flags); - iwl_grab_nic_access(priv); - value = _iwl_legacy_read_direct32(priv, reg); - iwl_release_nic_access(priv); + il_grab_nic_access(priv); + value = _il_read_direct32(priv, reg); + il_release_nic_access(priv); spin_unlock_irqrestore(&priv->reg_lock, reg_flags); return value; } #endif -static inline void _iwl_legacy_write_direct32(struct iwl_priv *priv, +static inline void _il_write_direct32(struct il_priv *priv, u32 reg, u32 value) { - _iwl_legacy_write32(priv, reg, value); + _il_write32(priv, reg, value); } static inline void -iwl_legacy_write_direct32(struct iwl_priv *priv, u32 reg, u32 value) +il_write_direct32(struct il_priv *priv, u32 reg, u32 value) { unsigned long reg_flags; spin_lock_irqsave(&priv->reg_lock, reg_flags); - if (!iwl_grab_nic_access(priv)) { - _iwl_legacy_write_direct32(priv, reg, value); - iwl_release_nic_access(priv); + if (!il_grab_nic_access(priv)) { + _il_write_direct32(priv, reg, value); + il_release_nic_access(priv); } spin_unlock_irqrestore(&priv->reg_lock, reg_flags); } -static inline void iwl_legacy_write_reg_buf(struct iwl_priv *priv, +static inline void il_write_reg_buf(struct il_priv *priv, u32 reg, u32 len, u32 *values) { u32 count = sizeof(u32); if ((priv != NULL) && (values != NULL)) { for (; 0 < len; len -= count, reg += count, values++) - iwl_legacy_write_direct32(priv, reg, *values); + il_write_direct32(priv, reg, *values); } } -static inline int _iwl_legacy_poll_direct_bit(struct iwl_priv *priv, u32 addr, +static inline int _il_poll_direct_bit(struct il_priv *priv, u32 addr, u32 mask, int timeout) { int t = 0; do { - if ((iwl_legacy_read_direct32(priv, addr) & mask) == mask) + if ((il_read_direct32(priv, addr) & mask) == mask) return t; - udelay(IWL_POLL_INTERVAL); - t += IWL_POLL_INTERVAL; + udelay(IL_POLL_INTERVAL); + t += IL_POLL_INTERVAL; } while (t < timeout); return -ETIMEDOUT; } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline int __iwl_legacy_poll_direct_bit(const char *f, u32 l, - struct iwl_priv *priv, +static inline int __il_poll_direct_bit(const char *f, u32 l, + struct il_priv *priv, u32 addr, u32 mask, int timeout) { - int ret = _iwl_legacy_poll_direct_bit(priv, addr, mask, timeout); + int ret = _il_poll_direct_bit(priv, addr, mask, timeout); if (unlikely(ret == -ETIMEDOUT)) - IWL_DEBUG_IO(priv, "poll_direct_bit(0x%08X, 0x%08X) - " + IL_DEBUG_IO(priv, "poll_direct_bit(0x%08X, 0x%08X) - " "timedout - %s %d\n", addr, mask, f, l); else - IWL_DEBUG_IO(priv, "poll_direct_bit(0x%08X, 0x%08X) = 0x%08X " + IL_DEBUG_IO(priv, "poll_direct_bit(0x%08X, 0x%08X) = 0x%08X " "- %s %d\n", addr, mask, ret, f, l); return ret; } -#define iwl_poll_direct_bit(priv, addr, mask, timeout) \ -__iwl_legacy_poll_direct_bit(__FILE__, __LINE__, priv, addr, mask, timeout) +#define il_poll_direct_bit(priv, addr, mask, timeout) \ +__il_poll_direct_bit(__FILE__, __LINE__, priv, addr, mask, timeout) #else -#define iwl_poll_direct_bit _iwl_legacy_poll_direct_bit +#define il_poll_direct_bit _il_poll_direct_bit #endif -static inline u32 _iwl_legacy_read_prph(struct iwl_priv *priv, u32 reg) +static inline u32 _il_read_prph(struct il_priv *priv, u32 reg) { - _iwl_legacy_write_direct32(priv, HBUS_TARG_PRPH_RADDR, reg | (3 << 24)); + _il_write_direct32(priv, HBUS_TARG_PRPH_RADDR, reg | (3 << 24)); rmb(); - return _iwl_legacy_read_direct32(priv, HBUS_TARG_PRPH_RDAT); + return _il_read_direct32(priv, HBUS_TARG_PRPH_RDAT); } -static inline u32 iwl_legacy_read_prph(struct iwl_priv *priv, u32 reg) +static inline u32 il_read_prph(struct il_priv *priv, u32 reg) { unsigned long reg_flags; u32 val; spin_lock_irqsave(&priv->reg_lock, reg_flags); - iwl_grab_nic_access(priv); - val = _iwl_legacy_read_prph(priv, reg); - iwl_release_nic_access(priv); + il_grab_nic_access(priv); + val = _il_read_prph(priv, reg); + il_release_nic_access(priv); spin_unlock_irqrestore(&priv->reg_lock, reg_flags); return val; } -static inline void _iwl_legacy_write_prph(struct iwl_priv *priv, +static inline void _il_write_prph(struct il_priv *priv, u32 addr, u32 val) { - _iwl_legacy_write_direct32(priv, HBUS_TARG_PRPH_WADDR, + _il_write_direct32(priv, HBUS_TARG_PRPH_WADDR, ((addr & 0x0000FFFF) | (3 << 24))); wmb(); - _iwl_legacy_write_direct32(priv, HBUS_TARG_PRPH_WDAT, val); + _il_write_direct32(priv, HBUS_TARG_PRPH_WDAT, val); } static inline void -iwl_legacy_write_prph(struct iwl_priv *priv, u32 addr, u32 val) +il_write_prph(struct il_priv *priv, u32 addr, u32 val) { unsigned long reg_flags; spin_lock_irqsave(&priv->reg_lock, reg_flags); - if (!iwl_grab_nic_access(priv)) { - _iwl_legacy_write_prph(priv, addr, val); - iwl_release_nic_access(priv); + if (!il_grab_nic_access(priv)) { + _il_write_prph(priv, addr, val); + il_release_nic_access(priv); } spin_unlock_irqrestore(&priv->reg_lock, reg_flags); } -#define _iwl_legacy_set_bits_prph(priv, reg, mask) \ -_iwl_legacy_write_prph(priv, reg, (_iwl_legacy_read_prph(priv, reg) | mask)) +#define _il_set_bits_prph(priv, reg, mask) \ +_il_write_prph(priv, reg, (_il_read_prph(priv, reg) | mask)) static inline void -iwl_legacy_set_bits_prph(struct iwl_priv *priv, u32 reg, u32 mask) +il_set_bits_prph(struct il_priv *priv, u32 reg, u32 mask) { unsigned long reg_flags; spin_lock_irqsave(&priv->reg_lock, reg_flags); - iwl_grab_nic_access(priv); - _iwl_legacy_set_bits_prph(priv, reg, mask); - iwl_release_nic_access(priv); + il_grab_nic_access(priv); + _il_set_bits_prph(priv, reg, mask); + il_release_nic_access(priv); spin_unlock_irqrestore(&priv->reg_lock, reg_flags); } -#define _iwl_legacy_set_bits_mask_prph(priv, reg, bits, mask) \ -_iwl_legacy_write_prph(priv, reg, \ - ((_iwl_legacy_read_prph(priv, reg) & mask) | bits)) +#define _il_set_bits_mask_prph(priv, reg, bits, mask) \ +_il_write_prph(priv, reg, \ + ((_il_read_prph(priv, reg) & mask) | bits)) -static inline void iwl_legacy_set_bits_mask_prph(struct iwl_priv *priv, u32 reg, +static inline void il_set_bits_mask_prph(struct il_priv *priv, u32 reg, u32 bits, u32 mask) { unsigned long reg_flags; spin_lock_irqsave(&priv->reg_lock, reg_flags); - iwl_grab_nic_access(priv); - _iwl_legacy_set_bits_mask_prph(priv, reg, bits, mask); - iwl_release_nic_access(priv); + il_grab_nic_access(priv); + _il_set_bits_mask_prph(priv, reg, bits, mask); + il_release_nic_access(priv); spin_unlock_irqrestore(&priv->reg_lock, reg_flags); } -static inline void iwl_legacy_clear_bits_prph(struct iwl_priv +static inline void il_clear_bits_prph(struct il_priv *priv, u32 reg, u32 mask) { unsigned long reg_flags; u32 val; spin_lock_irqsave(&priv->reg_lock, reg_flags); - iwl_grab_nic_access(priv); - val = _iwl_legacy_read_prph(priv, reg); - _iwl_legacy_write_prph(priv, reg, (val & ~mask)); - iwl_release_nic_access(priv); + il_grab_nic_access(priv); + val = _il_read_prph(priv, reg); + _il_write_prph(priv, reg, (val & ~mask)); + il_release_nic_access(priv); spin_unlock_irqrestore(&priv->reg_lock, reg_flags); } -static inline u32 iwl_legacy_read_targ_mem(struct iwl_priv *priv, u32 addr) +static inline u32 il_read_targ_mem(struct il_priv *priv, u32 addr) { unsigned long reg_flags; u32 value; spin_lock_irqsave(&priv->reg_lock, reg_flags); - iwl_grab_nic_access(priv); + il_grab_nic_access(priv); - _iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_RADDR, addr); + _il_write_direct32(priv, HBUS_TARG_MEM_RADDR, addr); rmb(); - value = _iwl_legacy_read_direct32(priv, HBUS_TARG_MEM_RDAT); + value = _il_read_direct32(priv, HBUS_TARG_MEM_RDAT); - iwl_release_nic_access(priv); + il_release_nic_access(priv); spin_unlock_irqrestore(&priv->reg_lock, reg_flags); return value; } static inline void -iwl_legacy_write_targ_mem(struct iwl_priv *priv, u32 addr, u32 val) +il_write_targ_mem(struct il_priv *priv, u32 addr, u32 val) { unsigned long reg_flags; spin_lock_irqsave(&priv->reg_lock, reg_flags); - if (!iwl_grab_nic_access(priv)) { - _iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr); + if (!il_grab_nic_access(priv)) { + _il_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr); wmb(); - _iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_WDAT, val); - iwl_release_nic_access(priv); + _il_write_direct32(priv, HBUS_TARG_MEM_WDAT, val); + il_release_nic_access(priv); } spin_unlock_irqrestore(&priv->reg_lock, reg_flags); } static inline void -iwl_legacy_write_targ_mem_buf(struct iwl_priv *priv, u32 addr, +il_write_targ_mem_buf(struct il_priv *priv, u32 addr, u32 len, u32 *values) { unsigned long reg_flags; spin_lock_irqsave(&priv->reg_lock, reg_flags); - if (!iwl_grab_nic_access(priv)) { - _iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr); + if (!il_grab_nic_access(priv)) { + _il_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr); wmb(); for (; 0 < len; len -= sizeof(u32), values++) - _iwl_legacy_write_direct32(priv, + _il_write_direct32(priv, HBUS_TARG_MEM_WDAT, *values); - iwl_release_nic_access(priv); + il_release_nic_access(priv); } spin_unlock_irqrestore(&priv->reg_lock, reg_flags); } diff --git a/drivers/net/wireless/iwlegacy/iwl-led.c b/drivers/net/wireless/iwlegacy/iwl-led.c index dc568a474c5d..490b183b1347 100644 --- a/drivers/net/wireless/iwlegacy/iwl-led.c +++ b/drivers/net/wireless/iwlegacy/iwl-led.c @@ -41,7 +41,7 @@ #include "iwl-core.h" #include "iwl-io.h" -/* default: IWL_LED_BLINK(0) using blinking index table */ +/* default: IL_LED_BLINK(0) using blinking index table */ static int led_mode; module_param(led_mode, int, S_IRUGO); MODULE_PARM_DESC(led_mode, "0=system default, " @@ -60,7 +60,7 @@ MODULE_PARM_DESC(led_mode, "0=system default, " * >0 to 1 167 167 * <=0 SOLID ON */ -static const struct ieee80211_tpt_blink iwl_blink[] = { +static const struct ieee80211_tpt_blink il_blink[] = { { .throughput = 0, .blink_time = 334 }, { .throughput = 1 * 1024 - 1, .blink_time = 260 }, { .throughput = 5 * 1024 - 1, .blink_time = 220 }, @@ -84,11 +84,11 @@ static const struct ieee80211_tpt_blink iwl_blink[] = { * compensation = (100 - averageDeviation) * 64 / 100 * NewBlinkTime = (compensation * BlinkTime) / 64 */ -static inline u8 iwl_legacy_blink_compensation(struct iwl_priv *priv, +static inline u8 il_blink_compensation(struct il_priv *priv, u8 time, u16 compensation) { if (!compensation) { - IWL_ERR(priv, "undefined blink compensation: " + IL_ERR(priv, "undefined blink compensation: " "use pre-defined blinking time\n"); return time; } @@ -97,13 +97,13 @@ static inline u8 iwl_legacy_blink_compensation(struct iwl_priv *priv, } /* Set led pattern command */ -static int iwl_legacy_led_cmd(struct iwl_priv *priv, +static int il_led_cmd(struct il_priv *priv, unsigned long on, unsigned long off) { - struct iwl_led_cmd led_cmd = { - .id = IWL_LED_LINK, - .interval = IWL_DEF_LED_INTRVL + struct il_led_cmd led_cmd = { + .id = IL_LED_LINK, + .interval = IL_DEF_LED_INTRVL }; int ret; @@ -115,14 +115,14 @@ static int iwl_legacy_led_cmd(struct iwl_priv *priv, if (off == 0) { /* led is SOLID_ON */ - on = IWL_LED_SOLID; + on = IL_LED_SOLID; } - IWL_DEBUG_LED(priv, "Led blink time compensation=%u\n", + IL_DEBUG_LED(priv, "Led blink time compensation=%u\n", priv->cfg->base_params->led_compensation); - led_cmd.on = iwl_legacy_blink_compensation(priv, on, + led_cmd.on = il_blink_compensation(priv, on, priv->cfg->base_params->led_compensation); - led_cmd.off = iwl_legacy_blink_compensation(priv, off, + led_cmd.off = il_blink_compensation(priv, off, priv->cfg->base_params->led_compensation); ret = priv->cfg->ops->led->cmd(priv, &led_cmd); @@ -133,52 +133,52 @@ static int iwl_legacy_led_cmd(struct iwl_priv *priv, return ret; } -static void iwl_legacy_led_brightness_set(struct led_classdev *led_cdev, +static void il_led_brightness_set(struct led_classdev *led_cdev, enum led_brightness brightness) { - struct iwl_priv *priv = container_of(led_cdev, struct iwl_priv, led); + struct il_priv *priv = container_of(led_cdev, struct il_priv, led); unsigned long on = 0; if (brightness > 0) - on = IWL_LED_SOLID; + on = IL_LED_SOLID; - iwl_legacy_led_cmd(priv, on, 0); + il_led_cmd(priv, on, 0); } -static int iwl_legacy_led_blink_set(struct led_classdev *led_cdev, +static int il_led_blink_set(struct led_classdev *led_cdev, unsigned long *delay_on, unsigned long *delay_off) { - struct iwl_priv *priv = container_of(led_cdev, struct iwl_priv, led); + struct il_priv *priv = container_of(led_cdev, struct il_priv, led); - return iwl_legacy_led_cmd(priv, *delay_on, *delay_off); + return il_led_cmd(priv, *delay_on, *delay_off); } -void iwl_legacy_leds_init(struct iwl_priv *priv) +void il_leds_init(struct il_priv *priv) { int mode = led_mode; int ret; - if (mode == IWL_LED_DEFAULT) + if (mode == IL_LED_DEFAULT) mode = priv->cfg->led_mode; priv->led.name = kasprintf(GFP_KERNEL, "%s-led", wiphy_name(priv->hw->wiphy)); - priv->led.brightness_set = iwl_legacy_led_brightness_set; - priv->led.blink_set = iwl_legacy_led_blink_set; + priv->led.brightness_set = il_led_brightness_set; + priv->led.blink_set = il_led_blink_set; priv->led.max_brightness = 1; switch (mode) { - case IWL_LED_DEFAULT: + case IL_LED_DEFAULT: WARN_ON(1); break; - case IWL_LED_BLINK: + case IL_LED_BLINK: priv->led.default_trigger = ieee80211_create_tpt_led_trigger(priv->hw, IEEE80211_TPT_LEDTRIG_FL_CONNECTED, - iwl_blink, ARRAY_SIZE(iwl_blink)); + il_blink, ARRAY_SIZE(il_blink)); break; - case IWL_LED_RF_STATE: + case IL_LED_RF_STATE: priv->led.default_trigger = ieee80211_get_radio_led_name(priv->hw); break; @@ -192,9 +192,9 @@ void iwl_legacy_leds_init(struct iwl_priv *priv) priv->led_registered = true; } -EXPORT_SYMBOL(iwl_legacy_leds_init); +EXPORT_SYMBOL(il_leds_init); -void iwl_legacy_leds_exit(struct iwl_priv *priv) +void il_leds_exit(struct il_priv *priv) { if (!priv->led_registered) return; @@ -202,4 +202,4 @@ void iwl_legacy_leds_exit(struct iwl_priv *priv) led_classdev_unregister(&priv->led); kfree(priv->led.name); } -EXPORT_SYMBOL(iwl_legacy_leds_exit); +EXPORT_SYMBOL(il_leds_exit); diff --git a/drivers/net/wireless/iwlegacy/iwl-led.h b/drivers/net/wireless/iwlegacy/iwl-led.h index f0791f70f79d..ea7a8ea23a15 100644 --- a/drivers/net/wireless/iwlegacy/iwl-led.h +++ b/drivers/net/wireless/iwlegacy/iwl-led.h @@ -24,33 +24,33 @@ * *****************************************************************************/ -#ifndef __iwl_legacy_leds_h__ -#define __iwl_legacy_leds_h__ +#ifndef __il_leds_h__ +#define __il_leds_h__ -struct iwl_priv; +struct il_priv; -#define IWL_LED_SOLID 11 -#define IWL_DEF_LED_INTRVL cpu_to_le32(1000) +#define IL_LED_SOLID 11 +#define IL_DEF_LED_INTRVL cpu_to_le32(1000) -#define IWL_LED_ACTIVITY (0<<1) -#define IWL_LED_LINK (1<<1) +#define IL_LED_ACTIVITY (0<<1) +#define IL_LED_LINK (1<<1) /* * LED mode - * IWL_LED_DEFAULT: use device default - * IWL_LED_RF_STATE: turn LED on/off based on RF state + * IL_LED_DEFAULT: use device default + * IL_LED_RF_STATE: turn LED on/off based on RF state * LED ON = RF ON * LED OFF = RF OFF - * IWL_LED_BLINK: adjust led blink rate based on blink table + * IL_LED_BLINK: adjust led blink rate based on blink table */ -enum iwl_led_mode { - IWL_LED_DEFAULT, - IWL_LED_RF_STATE, - IWL_LED_BLINK, +enum il_led_mode { + IL_LED_DEFAULT, + IL_LED_RF_STATE, + IL_LED_BLINK, }; -void iwl_legacy_leds_init(struct iwl_priv *priv); -void iwl_legacy_leds_exit(struct iwl_priv *priv); +void il_leds_init(struct il_priv *priv); +void il_leds_exit(struct il_priv *priv); -#endif /* __iwl_legacy_leds_h__ */ +#endif /* __il_leds_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h index 38647e481eb0..72ef91e9a799 100644 --- a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h +++ b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h @@ -24,14 +24,14 @@ * *****************************************************************************/ -#ifndef __iwl_legacy_rs_h__ -#define __iwl_legacy_rs_h__ - -struct iwl_rate_info { - u8 plcp; /* uCode API: IWL_RATE_6M_PLCP, etc. */ - u8 plcp_siso; /* uCode API: IWL_RATE_SISO_6M_PLCP, etc. */ - u8 plcp_mimo2; /* uCode API: IWL_RATE_MIMO2_6M_PLCP, etc. */ - u8 ieee; /* MAC header: IWL_RATE_6M_IEEE, etc. */ +#ifndef __il_rs_h__ +#define __il_rs_h__ + +struct il_rate_info { + u8 plcp; /* uCode API: IL_RATE_6M_PLCP, etc. */ + u8 plcp_siso; /* uCode API: IL_RATE_SISO_6M_PLCP, etc. */ + u8 plcp_mimo2; /* uCode API: IL_RATE_MIMO2_6M_PLCP, etc. */ + u8 ieee; /* MAC header: IL_RATE_6M_IEEE, etc. */ u8 prev_ieee; /* previous rate in IEEE speeds */ u8 next_ieee; /* next rate in IEEE speeds */ u8 prev_rs; /* previous rate used in rs algo */ @@ -40,9 +40,9 @@ struct iwl_rate_info { u8 next_rs_tgg; /* next rate used in TGG rs algo */ }; -struct iwl3945_rate_info { - u8 plcp; /* uCode API: IWL_RATE_6M_PLCP, etc. */ - u8 ieee; /* MAC header: IWL_RATE_6M_IEEE, etc. */ +struct il3945_rate_info { + u8 plcp; /* uCode API: IL_RATE_6M_PLCP, etc. */ + u8 ieee; /* MAC header: IL_RATE_6M_IEEE, etc. */ u8 prev_ieee; /* previous rate in IEEE speeds */ u8 next_ieee; /* next rate in IEEE speeds */ u8 prev_rs; /* previous rate used in rs algo */ @@ -56,210 +56,210 @@ struct iwl3945_rate_info { /* * These serve as indexes into - * struct iwl_rate_info iwlegacy_rates[IWL_RATE_COUNT]; + * struct il_rate_info iwlegacy_rates[IL_RATE_COUNT]; */ enum { - IWL_RATE_1M_INDEX = 0, - IWL_RATE_2M_INDEX, - IWL_RATE_5M_INDEX, - IWL_RATE_11M_INDEX, - IWL_RATE_6M_INDEX, - IWL_RATE_9M_INDEX, - IWL_RATE_12M_INDEX, - IWL_RATE_18M_INDEX, - IWL_RATE_24M_INDEX, - IWL_RATE_36M_INDEX, - IWL_RATE_48M_INDEX, - IWL_RATE_54M_INDEX, - IWL_RATE_60M_INDEX, - IWL_RATE_COUNT, - IWL_RATE_COUNT_LEGACY = IWL_RATE_COUNT - 1, /* Excluding 60M */ - IWL_RATE_COUNT_3945 = IWL_RATE_COUNT - 1, - IWL_RATE_INVM_INDEX = IWL_RATE_COUNT, - IWL_RATE_INVALID = IWL_RATE_COUNT, + IL_RATE_1M_INDEX = 0, + IL_RATE_2M_INDEX, + IL_RATE_5M_INDEX, + IL_RATE_11M_INDEX, + IL_RATE_6M_INDEX, + IL_RATE_9M_INDEX, + IL_RATE_12M_INDEX, + IL_RATE_18M_INDEX, + IL_RATE_24M_INDEX, + IL_RATE_36M_INDEX, + IL_RATE_48M_INDEX, + IL_RATE_54M_INDEX, + IL_RATE_60M_INDEX, + IL_RATE_COUNT, + IL_RATE_COUNT_LEGACY = IL_RATE_COUNT - 1, /* Excluding 60M */ + IL_RATE_COUNT_3945 = IL_RATE_COUNT - 1, + IL_RATE_INVM_INDEX = IL_RATE_COUNT, + IL_RATE_INVALID = IL_RATE_COUNT, }; enum { - IWL_RATE_6M_INDEX_TABLE = 0, - IWL_RATE_9M_INDEX_TABLE, - IWL_RATE_12M_INDEX_TABLE, - IWL_RATE_18M_INDEX_TABLE, - IWL_RATE_24M_INDEX_TABLE, - IWL_RATE_36M_INDEX_TABLE, - IWL_RATE_48M_INDEX_TABLE, - IWL_RATE_54M_INDEX_TABLE, - IWL_RATE_1M_INDEX_TABLE, - IWL_RATE_2M_INDEX_TABLE, - IWL_RATE_5M_INDEX_TABLE, - IWL_RATE_11M_INDEX_TABLE, - IWL_RATE_INVM_INDEX_TABLE = IWL_RATE_INVM_INDEX - 1, + IL_RATE_6M_INDEX_TABLE = 0, + IL_RATE_9M_INDEX_TABLE, + IL_RATE_12M_INDEX_TABLE, + IL_RATE_18M_INDEX_TABLE, + IL_RATE_24M_INDEX_TABLE, + IL_RATE_36M_INDEX_TABLE, + IL_RATE_48M_INDEX_TABLE, + IL_RATE_54M_INDEX_TABLE, + IL_RATE_1M_INDEX_TABLE, + IL_RATE_2M_INDEX_TABLE, + IL_RATE_5M_INDEX_TABLE, + IL_RATE_11M_INDEX_TABLE, + IL_RATE_INVM_INDEX_TABLE = IL_RATE_INVM_INDEX - 1, }; enum { - IWL_FIRST_OFDM_RATE = IWL_RATE_6M_INDEX, - IWL39_LAST_OFDM_RATE = IWL_RATE_54M_INDEX, - IWL_LAST_OFDM_RATE = IWL_RATE_60M_INDEX, - IWL_FIRST_CCK_RATE = IWL_RATE_1M_INDEX, - IWL_LAST_CCK_RATE = IWL_RATE_11M_INDEX, + IL_FIRST_OFDM_RATE = IL_RATE_6M_INDEX, + IWL39_LAST_OFDM_RATE = IL_RATE_54M_INDEX, + IL_LAST_OFDM_RATE = IL_RATE_60M_INDEX, + IL_FIRST_CCK_RATE = IL_RATE_1M_INDEX, + IL_LAST_CCK_RATE = IL_RATE_11M_INDEX, }; /* #define vs. enum to keep from defaulting to 'large integer' */ -#define IWL_RATE_6M_MASK (1 << IWL_RATE_6M_INDEX) -#define IWL_RATE_9M_MASK (1 << IWL_RATE_9M_INDEX) -#define IWL_RATE_12M_MASK (1 << IWL_RATE_12M_INDEX) -#define IWL_RATE_18M_MASK (1 << IWL_RATE_18M_INDEX) -#define IWL_RATE_24M_MASK (1 << IWL_RATE_24M_INDEX) -#define IWL_RATE_36M_MASK (1 << IWL_RATE_36M_INDEX) -#define IWL_RATE_48M_MASK (1 << IWL_RATE_48M_INDEX) -#define IWL_RATE_54M_MASK (1 << IWL_RATE_54M_INDEX) -#define IWL_RATE_60M_MASK (1 << IWL_RATE_60M_INDEX) -#define IWL_RATE_1M_MASK (1 << IWL_RATE_1M_INDEX) -#define IWL_RATE_2M_MASK (1 << IWL_RATE_2M_INDEX) -#define IWL_RATE_5M_MASK (1 << IWL_RATE_5M_INDEX) -#define IWL_RATE_11M_MASK (1 << IWL_RATE_11M_INDEX) +#define IL_RATE_6M_MASK (1 << IL_RATE_6M_INDEX) +#define IL_RATE_9M_MASK (1 << IL_RATE_9M_INDEX) +#define IL_RATE_12M_MASK (1 << IL_RATE_12M_INDEX) +#define IL_RATE_18M_MASK (1 << IL_RATE_18M_INDEX) +#define IL_RATE_24M_MASK (1 << IL_RATE_24M_INDEX) +#define IL_RATE_36M_MASK (1 << IL_RATE_36M_INDEX) +#define IL_RATE_48M_MASK (1 << IL_RATE_48M_INDEX) +#define IL_RATE_54M_MASK (1 << IL_RATE_54M_INDEX) +#define IL_RATE_60M_MASK (1 << IL_RATE_60M_INDEX) +#define IL_RATE_1M_MASK (1 << IL_RATE_1M_INDEX) +#define IL_RATE_2M_MASK (1 << IL_RATE_2M_INDEX) +#define IL_RATE_5M_MASK (1 << IL_RATE_5M_INDEX) +#define IL_RATE_11M_MASK (1 << IL_RATE_11M_INDEX) /* uCode API values for legacy bit rates, both OFDM and CCK */ enum { - IWL_RATE_6M_PLCP = 13, - IWL_RATE_9M_PLCP = 15, - IWL_RATE_12M_PLCP = 5, - IWL_RATE_18M_PLCP = 7, - IWL_RATE_24M_PLCP = 9, - IWL_RATE_36M_PLCP = 11, - IWL_RATE_48M_PLCP = 1, - IWL_RATE_54M_PLCP = 3, - IWL_RATE_60M_PLCP = 3,/*FIXME:RS:should be removed*/ - IWL_RATE_1M_PLCP = 10, - IWL_RATE_2M_PLCP = 20, - IWL_RATE_5M_PLCP = 55, - IWL_RATE_11M_PLCP = 110, - /*FIXME:RS:add IWL_RATE_LEGACY_INVM_PLCP = 0,*/ + IL_RATE_6M_PLCP = 13, + IL_RATE_9M_PLCP = 15, + IL_RATE_12M_PLCP = 5, + IL_RATE_18M_PLCP = 7, + IL_RATE_24M_PLCP = 9, + IL_RATE_36M_PLCP = 11, + IL_RATE_48M_PLCP = 1, + IL_RATE_54M_PLCP = 3, + IL_RATE_60M_PLCP = 3,/*FIXME:RS:should be removed*/ + IL_RATE_1M_PLCP = 10, + IL_RATE_2M_PLCP = 20, + IL_RATE_5M_PLCP = 55, + IL_RATE_11M_PLCP = 110, + /*FIXME:RS:add IL_RATE_LEGACY_INVM_PLCP = 0,*/ }; /* uCode API values for OFDM high-throughput (HT) bit rates */ enum { - IWL_RATE_SISO_6M_PLCP = 0, - IWL_RATE_SISO_12M_PLCP = 1, - IWL_RATE_SISO_18M_PLCP = 2, - IWL_RATE_SISO_24M_PLCP = 3, - IWL_RATE_SISO_36M_PLCP = 4, - IWL_RATE_SISO_48M_PLCP = 5, - IWL_RATE_SISO_54M_PLCP = 6, - IWL_RATE_SISO_60M_PLCP = 7, - IWL_RATE_MIMO2_6M_PLCP = 0x8, - IWL_RATE_MIMO2_12M_PLCP = 0x9, - IWL_RATE_MIMO2_18M_PLCP = 0xa, - IWL_RATE_MIMO2_24M_PLCP = 0xb, - IWL_RATE_MIMO2_36M_PLCP = 0xc, - IWL_RATE_MIMO2_48M_PLCP = 0xd, - IWL_RATE_MIMO2_54M_PLCP = 0xe, - IWL_RATE_MIMO2_60M_PLCP = 0xf, - IWL_RATE_SISO_INVM_PLCP, - IWL_RATE_MIMO2_INVM_PLCP = IWL_RATE_SISO_INVM_PLCP, + IL_RATE_SISO_6M_PLCP = 0, + IL_RATE_SISO_12M_PLCP = 1, + IL_RATE_SISO_18M_PLCP = 2, + IL_RATE_SISO_24M_PLCP = 3, + IL_RATE_SISO_36M_PLCP = 4, + IL_RATE_SISO_48M_PLCP = 5, + IL_RATE_SISO_54M_PLCP = 6, + IL_RATE_SISO_60M_PLCP = 7, + IL_RATE_MIMO2_6M_PLCP = 0x8, + IL_RATE_MIMO2_12M_PLCP = 0x9, + IL_RATE_MIMO2_18M_PLCP = 0xa, + IL_RATE_MIMO2_24M_PLCP = 0xb, + IL_RATE_MIMO2_36M_PLCP = 0xc, + IL_RATE_MIMO2_48M_PLCP = 0xd, + IL_RATE_MIMO2_54M_PLCP = 0xe, + IL_RATE_MIMO2_60M_PLCP = 0xf, + IL_RATE_SISO_INVM_PLCP, + IL_RATE_MIMO2_INVM_PLCP = IL_RATE_SISO_INVM_PLCP, }; /* MAC header values for bit rates */ enum { - IWL_RATE_6M_IEEE = 12, - IWL_RATE_9M_IEEE = 18, - IWL_RATE_12M_IEEE = 24, - IWL_RATE_18M_IEEE = 36, - IWL_RATE_24M_IEEE = 48, - IWL_RATE_36M_IEEE = 72, - IWL_RATE_48M_IEEE = 96, - IWL_RATE_54M_IEEE = 108, - IWL_RATE_60M_IEEE = 120, - IWL_RATE_1M_IEEE = 2, - IWL_RATE_2M_IEEE = 4, - IWL_RATE_5M_IEEE = 11, - IWL_RATE_11M_IEEE = 22, + IL_RATE_6M_IEEE = 12, + IL_RATE_9M_IEEE = 18, + IL_RATE_12M_IEEE = 24, + IL_RATE_18M_IEEE = 36, + IL_RATE_24M_IEEE = 48, + IL_RATE_36M_IEEE = 72, + IL_RATE_48M_IEEE = 96, + IL_RATE_54M_IEEE = 108, + IL_RATE_60M_IEEE = 120, + IL_RATE_1M_IEEE = 2, + IL_RATE_2M_IEEE = 4, + IL_RATE_5M_IEEE = 11, + IL_RATE_11M_IEEE = 22, }; -#define IWL_CCK_BASIC_RATES_MASK \ - (IWL_RATE_1M_MASK | \ - IWL_RATE_2M_MASK) +#define IL_CCK_BASIC_RATES_MASK \ + (IL_RATE_1M_MASK | \ + IL_RATE_2M_MASK) -#define IWL_CCK_RATES_MASK \ - (IWL_CCK_BASIC_RATES_MASK | \ - IWL_RATE_5M_MASK | \ - IWL_RATE_11M_MASK) +#define IL_CCK_RATES_MASK \ + (IL_CCK_BASIC_RATES_MASK | \ + IL_RATE_5M_MASK | \ + IL_RATE_11M_MASK) -#define IWL_OFDM_BASIC_RATES_MASK \ - (IWL_RATE_6M_MASK | \ - IWL_RATE_12M_MASK | \ - IWL_RATE_24M_MASK) +#define IL_OFDM_BASIC_RATES_MASK \ + (IL_RATE_6M_MASK | \ + IL_RATE_12M_MASK | \ + IL_RATE_24M_MASK) -#define IWL_OFDM_RATES_MASK \ - (IWL_OFDM_BASIC_RATES_MASK | \ - IWL_RATE_9M_MASK | \ - IWL_RATE_18M_MASK | \ - IWL_RATE_36M_MASK | \ - IWL_RATE_48M_MASK | \ - IWL_RATE_54M_MASK) +#define IL_OFDM_RATES_MASK \ + (IL_OFDM_BASIC_RATES_MASK | \ + IL_RATE_9M_MASK | \ + IL_RATE_18M_MASK | \ + IL_RATE_36M_MASK | \ + IL_RATE_48M_MASK | \ + IL_RATE_54M_MASK) -#define IWL_BASIC_RATES_MASK \ - (IWL_OFDM_BASIC_RATES_MASK | \ - IWL_CCK_BASIC_RATES_MASK) +#define IL_BASIC_RATES_MASK \ + (IL_OFDM_BASIC_RATES_MASK | \ + IL_CCK_BASIC_RATES_MASK) -#define IWL_RATES_MASK ((1 << IWL_RATE_COUNT) - 1) -#define IWL_RATES_MASK_3945 ((1 << IWL_RATE_COUNT_3945) - 1) +#define IL_RATES_MASK ((1 << IL_RATE_COUNT) - 1) +#define IL_RATES_MASK_3945 ((1 << IL_RATE_COUNT_3945) - 1) -#define IWL_INVALID_VALUE -1 +#define IL_INVALID_VALUE -1 -#define IWL_MIN_RSSI_VAL -100 -#define IWL_MAX_RSSI_VAL 0 +#define IL_MIN_RSSI_VAL -100 +#define IL_MAX_RSSI_VAL 0 /* These values specify how many Tx frame attempts before * searching for a new modulation mode */ -#define IWL_LEGACY_FAILURE_LIMIT 160 -#define IWL_LEGACY_SUCCESS_LIMIT 480 -#define IWL_LEGACY_TABLE_COUNT 160 +#define IL_LEGACY_FAILURE_LIMIT 160 +#define IL_LEGACY_SUCCESS_LIMIT 480 +#define IL_LEGACY_TABLE_COUNT 160 -#define IWL_NONE_LEGACY_FAILURE_LIMIT 400 -#define IWL_NONE_LEGACY_SUCCESS_LIMIT 4500 -#define IWL_NONE_LEGACY_TABLE_COUNT 1500 +#define IL_NONE_LEGACY_FAILURE_LIMIT 400 +#define IL_NONE_LEGACY_SUCCESS_LIMIT 4500 +#define IL_NONE_LEGACY_TABLE_COUNT 1500 /* Success ratio (ACKed / attempted tx frames) values (perfect is 128 * 100) */ -#define IWL_RS_GOOD_RATIO 12800 /* 100% */ -#define IWL_RATE_SCALE_SWITCH 10880 /* 85% */ -#define IWL_RATE_HIGH_TH 10880 /* 85% */ -#define IWL_RATE_INCREASE_TH 6400 /* 50% */ -#define IWL_RATE_DECREASE_TH 1920 /* 15% */ +#define IL_RS_GOOD_RATIO 12800 /* 100% */ +#define IL_RATE_SCALE_SWITCH 10880 /* 85% */ +#define IL_RATE_HIGH_TH 10880 /* 85% */ +#define IL_RATE_INCREASE_TH 6400 /* 50% */ +#define IL_RATE_DECREASE_TH 1920 /* 15% */ /* possible actions when in legacy mode */ -#define IWL_LEGACY_SWITCH_ANTENNA1 0 -#define IWL_LEGACY_SWITCH_ANTENNA2 1 -#define IWL_LEGACY_SWITCH_SISO 2 -#define IWL_LEGACY_SWITCH_MIMO2_AB 3 -#define IWL_LEGACY_SWITCH_MIMO2_AC 4 -#define IWL_LEGACY_SWITCH_MIMO2_BC 5 +#define IL_LEGACY_SWITCH_ANTENNA1 0 +#define IL_LEGACY_SWITCH_ANTENNA2 1 +#define IL_LEGACY_SWITCH_SISO 2 +#define IL_LEGACY_SWITCH_MIMO2_AB 3 +#define IL_LEGACY_SWITCH_MIMO2_AC 4 +#define IL_LEGACY_SWITCH_MIMO2_BC 5 /* possible actions when in siso mode */ -#define IWL_SISO_SWITCH_ANTENNA1 0 -#define IWL_SISO_SWITCH_ANTENNA2 1 -#define IWL_SISO_SWITCH_MIMO2_AB 2 -#define IWL_SISO_SWITCH_MIMO2_AC 3 -#define IWL_SISO_SWITCH_MIMO2_BC 4 -#define IWL_SISO_SWITCH_GI 5 +#define IL_SISO_SWITCH_ANTENNA1 0 +#define IL_SISO_SWITCH_ANTENNA2 1 +#define IL_SISO_SWITCH_MIMO2_AB 2 +#define IL_SISO_SWITCH_MIMO2_AC 3 +#define IL_SISO_SWITCH_MIMO2_BC 4 +#define IL_SISO_SWITCH_GI 5 /* possible actions when in mimo mode */ -#define IWL_MIMO2_SWITCH_ANTENNA1 0 -#define IWL_MIMO2_SWITCH_ANTENNA2 1 -#define IWL_MIMO2_SWITCH_SISO_A 2 -#define IWL_MIMO2_SWITCH_SISO_B 3 -#define IWL_MIMO2_SWITCH_SISO_C 4 -#define IWL_MIMO2_SWITCH_GI 5 +#define IL_MIMO2_SWITCH_ANTENNA1 0 +#define IL_MIMO2_SWITCH_ANTENNA2 1 +#define IL_MIMO2_SWITCH_SISO_A 2 +#define IL_MIMO2_SWITCH_SISO_B 3 +#define IL_MIMO2_SWITCH_SISO_C 4 +#define IL_MIMO2_SWITCH_GI 5 -#define IWL_MAX_SEARCH IWL_MIMO2_SWITCH_GI +#define IL_MAX_SEARCH IL_MIMO2_SWITCH_GI -#define IWL_ACTION_LIMIT 3 /* # possible actions */ +#define IL_ACTION_LIMIT 3 /* # possible actions */ #define LQ_SIZE 2 /* 2 mode tables: "Active" and "Search" */ /* load per tid defines for A-MPDU activation */ -#define IWL_AGG_TPT_THREHOLD 0 -#define IWL_AGG_LOAD_THRESHOLD 10 -#define IWL_AGG_ALL_TID 0xff +#define IL_AGG_TPT_THREHOLD 0 +#define IL_AGG_LOAD_THRESHOLD 10 +#define IL_AGG_ALL_TID 0xff #define TID_QUEUE_CELL_SPACING 50 /*mS */ #define TID_QUEUE_MAX_SIZE 20 #define TID_ROUND_VALUE 5 /* mS */ @@ -268,9 +268,9 @@ enum { #define TID_MAX_TIME_DIFF ((TID_QUEUE_MAX_SIZE - 1) * TID_QUEUE_CELL_SPACING) #define TIME_WRAP_AROUND(x, y) (((y) > (x)) ? (y) - (x) : (0-(x)) + (y)) -extern const struct iwl_rate_info iwlegacy_rates[IWL_RATE_COUNT]; +extern const struct il_rate_info iwlegacy_rates[IL_RATE_COUNT]; -enum iwl_table_type { +enum il_table_type { LQ_NONE, LQ_G, /* legacy types */ LQ_A, @@ -296,17 +296,17 @@ enum iwl_table_type { #define ANT_BC (ANT_B | ANT_C) #define ANT_ABC (ANT_AB | ANT_C) -#define IWL_MAX_MCS_DISPLAY_SIZE 12 +#define IL_MAX_MCS_DISPLAY_SIZE 12 -struct iwl_rate_mcs_info { - char mbps[IWL_MAX_MCS_DISPLAY_SIZE]; - char mcs[IWL_MAX_MCS_DISPLAY_SIZE]; +struct il_rate_mcs_info { + char mbps[IL_MAX_MCS_DISPLAY_SIZE]; + char mcs[IL_MAX_MCS_DISPLAY_SIZE]; }; /** - * struct iwl_rate_scale_data -- tx success history for one rate + * struct il_rate_scale_data -- tx success history for one rate */ -struct iwl_rate_scale_data { +struct il_rate_scale_data { u64 data; /* bitmap of successful frames */ s32 success_counter; /* number of frames successful */ s32 success_ratio; /* per-cent * 128 */ @@ -316,25 +316,25 @@ struct iwl_rate_scale_data { }; /** - * struct iwl_scale_tbl_info -- tx params and success history for all rates + * struct il_scale_tbl_info -- tx params and success history for all rates * - * There are two of these in struct iwl_lq_sta, + * There are two of these in struct il_lq_sta, * one for "active", and one for "search". */ -struct iwl_scale_tbl_info { - enum iwl_table_type lq_type; +struct il_scale_tbl_info { + enum il_table_type lq_type; u8 ant_type; u8 is_SGI; /* 1 = short guard interval */ u8 is_ht40; /* 1 = 40 MHz channel width */ u8 is_dup; /* 1 = duplicated data streams */ - u8 action; /* change modulation; IWL_[LEGACY/SISO/MIMO]_SWITCH_* */ + u8 action; /* change modulation; IL_[LEGACY/SISO/MIMO]_SWITCH_* */ u8 max_search; /* maximun number of tables we can search */ s32 *expected_tpt; /* throughput metrics; expected_tpt_G, etc. */ u32 current_rate; /* rate_n_flags, uCode API format */ - struct iwl_rate_scale_data win[IWL_RATE_COUNT]; /* rate histories */ + struct il_rate_scale_data win[IL_RATE_COUNT]; /* rate histories */ }; -struct iwl_traffic_load { +struct il_traffic_load { unsigned long time_stamp; /* age of the oldest statistics */ u32 packet_count[TID_QUEUE_MAX_SIZE]; /* packet count in this time * slice */ @@ -346,11 +346,11 @@ struct iwl_traffic_load { }; /** - * struct iwl_lq_sta -- driver's rate scaling private structure + * struct il_lq_sta -- driver's rate scaling private structure * * Pointer to this gets passed back and forth between driver and mac80211. */ -struct iwl_lq_sta { +struct il_lq_sta { u8 active_tbl; /* index of active table, range 0-1 */ u8 enable_counter; /* indicates HT mode */ u8 stay_in_tbl; /* 1: disallow, 0: allow search for new mode */ @@ -371,7 +371,7 @@ struct iwl_lq_sta { u8 is_dup; enum ieee80211_band band; - /* The following are bitmaps of rates; IWL_RATE_6M_MASK, etc. */ + /* The following are bitmaps of rates; IL_RATE_6M_MASK, etc. */ u32 supp_rates; u16 active_legacy_rate; u16 active_siso_rate; @@ -379,9 +379,9 @@ struct iwl_lq_sta { s8 max_rate_idx; /* Max rate set by user */ u8 missed_rate_counter; - struct iwl_link_quality_cmd lq; - struct iwl_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */ - struct iwl_traffic_load load[TID_MAX_LOAD_COUNT]; + struct il_link_quality_cmd lq; + struct il_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */ + struct il_traffic_load load[TID_MAX_LOAD_COUNT]; u8 tx_agg_tid_en; #ifdef CONFIG_MAC80211_DEBUGFS struct dentry *rs_sta_dbgfs_scale_table_file; @@ -390,7 +390,7 @@ struct iwl_lq_sta { struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file; u32 dbg_fixed_rate; #endif - struct iwl_priv *drv; + struct il_priv *drv; /* used to be in sta_info */ int last_txrate_idx; @@ -400,14 +400,14 @@ struct iwl_lq_sta { u8 is_agg; }; -static inline u8 iwl4965_num_of_ant(u8 mask) +static inline u8 il4965_num_of_ant(u8 mask) { return !!((mask) & ANT_A) + !!((mask) & ANT_B) + !!((mask) & ANT_C); } -static inline u8 iwl4965_first_antenna(u8 mask) +static inline u8 il4965_first_antenna(u8 mask) { if (mask & ANT_A) return ANT_A; @@ -418,39 +418,39 @@ static inline u8 iwl4965_first_antenna(u8 mask) /** - * iwl3945_rate_scale_init - Initialize the rate scale table based on assoc info + * il3945_rate_scale_init - Initialize the rate scale table based on assoc info * * The specific throughput table used is based on the type of network * the associated with, including A, B, G, and G w/ TGG protection */ -extern void iwl3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id); +extern void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id); /* Initialize station's rate scaling information after adding station */ -extern void iwl4965_rs_rate_init(struct iwl_priv *priv, +extern void il4965_rs_rate_init(struct il_priv *priv, struct ieee80211_sta *sta, u8 sta_id); -extern void iwl3945_rs_rate_init(struct iwl_priv *priv, +extern void il3945_rs_rate_init(struct il_priv *priv, struct ieee80211_sta *sta, u8 sta_id); /** - * iwl_rate_control_register - Register the rate control algorithm callbacks + * il_rate_control_register - Register the rate control algorithm callbacks * * Since the rate control algorithm is hardware specific, there is no need * or reason to place it as a stand alone module. The driver can call - * iwl_rate_control_register in order to register the rate control callbacks + * il_rate_control_register in order to register the rate control callbacks * with the mac80211 subsystem. This should be performed prior to calling * ieee80211_register_hw * */ -extern int iwl4965_rate_control_register(void); -extern int iwl3945_rate_control_register(void); +extern int il4965_rate_control_register(void); +extern int il3945_rate_control_register(void); /** - * iwl_rate_control_unregister - Unregister the rate control callbacks + * il_rate_control_unregister - Unregister the rate control callbacks * * This should be called after calling ieee80211_unregister_hw, but before * the driver is unloaded. */ -extern void iwl4965_rate_control_unregister(void); -extern void iwl3945_rate_control_unregister(void); +extern void il4965_rate_control_unregister(void); +extern void il3945_rate_control_unregister(void); -#endif /* __iwl_legacy_rs__ */ +#endif /* __il_rs__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-power.c b/drivers/net/wireless/iwlegacy/iwl-power.c index 903ef0d6d6cb..7ccff257736e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-power.c +++ b/drivers/net/wireless/iwlegacy/iwl-power.c @@ -55,32 +55,32 @@ * (level 1) and for thermal throttle (levels 3 through 5) */ -struct iwl_power_vec_entry { - struct iwl_powertable_cmd cmd; +struct il_power_vec_entry { + struct il_powertable_cmd cmd; u8 no_dtim; /* number of skip dtim */ }; -static void iwl_legacy_power_sleep_cam_cmd(struct iwl_priv *priv, - struct iwl_powertable_cmd *cmd) +static void il_power_sleep_cam_cmd(struct il_priv *priv, + struct il_powertable_cmd *cmd) { memset(cmd, 0, sizeof(*cmd)); if (priv->power_data.pci_pm) - cmd->flags |= IWL_POWER_PCI_PM_MSK; + cmd->flags |= IL_POWER_PCI_PM_MSK; - IWL_DEBUG_POWER(priv, "Sleep command for CAM\n"); + IL_DEBUG_POWER(priv, "Sleep command for CAM\n"); } static int -iwl_legacy_set_power(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd) +il_set_power(struct il_priv *priv, struct il_powertable_cmd *cmd) { - IWL_DEBUG_POWER(priv, "Sending power/sleep command\n"); - IWL_DEBUG_POWER(priv, "Flags value = 0x%08X\n", cmd->flags); - IWL_DEBUG_POWER(priv, "Tx timeout = %u\n", + IL_DEBUG_POWER(priv, "Sending power/sleep command\n"); + IL_DEBUG_POWER(priv, "Flags value = 0x%08X\n", cmd->flags); + IL_DEBUG_POWER(priv, "Tx timeout = %u\n", le32_to_cpu(cmd->tx_data_timeout)); - IWL_DEBUG_POWER(priv, "Rx timeout = %u\n", + IL_DEBUG_POWER(priv, "Rx timeout = %u\n", le32_to_cpu(cmd->rx_data_timeout)); - IWL_DEBUG_POWER(priv, + IL_DEBUG_POWER(priv, "Sleep interval vector = { %d , %d , %d , %d , %d }\n", le32_to_cpu(cmd->sleep_interval[0]), le32_to_cpu(cmd->sleep_interval[1]), @@ -88,12 +88,12 @@ iwl_legacy_set_power(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd) le32_to_cpu(cmd->sleep_interval[3]), le32_to_cpu(cmd->sleep_interval[4])); - return iwl_legacy_send_cmd_pdu(priv, POWER_TABLE_CMD, - sizeof(struct iwl_powertable_cmd), cmd); + return il_send_cmd_pdu(priv, POWER_TABLE_CMD, + sizeof(struct il_powertable_cmd), cmd); } int -iwl_legacy_power_set_mode(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd, +il_power_set_mode(struct il_priv *priv, struct il_powertable_cmd *cmd, bool force) { int ret; @@ -102,58 +102,58 @@ iwl_legacy_power_set_mode(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd, lockdep_assert_held(&priv->mutex); /* Don't update the RX chain when chain noise calibration is running */ - update_chains = priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE || - priv->chain_noise_data.state == IWL_CHAIN_NOISE_ALIVE; + update_chains = priv->chain_noise_data.state == IL_CHAIN_NOISE_DONE || + priv->chain_noise_data.state == IL_CHAIN_NOISE_ALIVE; if (!memcmp(&priv->power_data.sleep_cmd, cmd, sizeof(*cmd)) && !force) return 0; - if (!iwl_legacy_is_ready_rf(priv)) + if (!il_is_ready_rf(priv)) return -EIO; /* scan complete use sleep_power_next, need to be updated */ memcpy(&priv->power_data.sleep_cmd_next, cmd, sizeof(*cmd)); if (test_bit(STATUS_SCANNING, &priv->status) && !force) { - IWL_DEBUG_INFO(priv, "Defer power set mode while scanning\n"); + IL_DEBUG_INFO(priv, "Defer power set mode while scanning\n"); return 0; } - if (cmd->flags & IWL_POWER_DRIVER_ALLOW_SLEEP_MSK) + if (cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK) set_bit(STATUS_POWER_PMI, &priv->status); - ret = iwl_legacy_set_power(priv, cmd); + ret = il_set_power(priv, cmd); if (!ret) { - if (!(cmd->flags & IWL_POWER_DRIVER_ALLOW_SLEEP_MSK)) + if (!(cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK)) clear_bit(STATUS_POWER_PMI, &priv->status); if (priv->cfg->ops->lib->update_chain_flags && update_chains) priv->cfg->ops->lib->update_chain_flags(priv); else if (priv->cfg->ops->lib->update_chain_flags) - IWL_DEBUG_POWER(priv, + IL_DEBUG_POWER(priv, "Cannot update the power, chain noise " "calibration running: %d\n", priv->chain_noise_data.state); memcpy(&priv->power_data.sleep_cmd, cmd, sizeof(*cmd)); } else - IWL_ERR(priv, "set power fail, ret = %d", ret); + IL_ERR(priv, "set power fail, ret = %d", ret); return ret; } -int iwl_legacy_power_update_mode(struct iwl_priv *priv, bool force) +int il_power_update_mode(struct il_priv *priv, bool force) { - struct iwl_powertable_cmd cmd; + struct il_powertable_cmd cmd; - iwl_legacy_power_sleep_cam_cmd(priv, &cmd); - return iwl_legacy_power_set_mode(priv, &cmd, force); + il_power_sleep_cam_cmd(priv, &cmd); + return il_power_set_mode(priv, &cmd, force); } -EXPORT_SYMBOL(iwl_legacy_power_update_mode); +EXPORT_SYMBOL(il_power_update_mode); /* initialize to default */ -void iwl_legacy_power_initialize(struct iwl_priv *priv) +void il_power_initialize(struct il_priv *priv) { - u16 lctl = iwl_legacy_pcie_link_ctl(priv); + u16 lctl = il_pcie_link_ctl(priv); priv->power_data.pci_pm = !(lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN); @@ -162,4 +162,4 @@ void iwl_legacy_power_initialize(struct iwl_priv *priv) memset(&priv->power_data.sleep_cmd, 0, sizeof(priv->power_data.sleep_cmd)); } -EXPORT_SYMBOL(iwl_legacy_power_initialize); +EXPORT_SYMBOL(il_power_initialize); diff --git a/drivers/net/wireless/iwlegacy/iwl-power.h b/drivers/net/wireless/iwlegacy/iwl-power.h index d30b36acdc4a..dba4ca9d30eb 100644 --- a/drivers/net/wireless/iwlegacy/iwl-power.h +++ b/drivers/net/wireless/iwlegacy/iwl-power.h @@ -25,31 +25,31 @@ * Intel Linux Wireless * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 *****************************************************************************/ -#ifndef __iwl_legacy_power_setting_h__ -#define __iwl_legacy_power_setting_h__ +#ifndef __il_power_setting_h__ +#define __il_power_setting_h__ #include "iwl-commands.h" -enum iwl_power_level { - IWL_POWER_INDEX_1, - IWL_POWER_INDEX_2, - IWL_POWER_INDEX_3, - IWL_POWER_INDEX_4, - IWL_POWER_INDEX_5, - IWL_POWER_NUM +enum il_power_level { + IL_POWER_INDEX_1, + IL_POWER_INDEX_2, + IL_POWER_INDEX_3, + IL_POWER_INDEX_4, + IL_POWER_INDEX_5, + IL_POWER_NUM }; -struct iwl_power_mgr { - struct iwl_powertable_cmd sleep_cmd; - struct iwl_powertable_cmd sleep_cmd_next; +struct il_power_mgr { + struct il_powertable_cmd sleep_cmd; + struct il_powertable_cmd sleep_cmd_next; int debug_sleep_level_override; bool pci_pm; }; int -iwl_legacy_power_set_mode(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd, +il_power_set_mode(struct il_priv *priv, struct il_powertable_cmd *cmd, bool force); -int iwl_legacy_power_update_mode(struct iwl_priv *priv, bool force); -void iwl_legacy_power_initialize(struct iwl_priv *priv); +int il_power_update_mode(struct il_priv *priv, bool force); +void il_power_initialize(struct il_priv *priv); -#endif /* __iwl_legacy_power_setting_h__ */ +#endif /* __il_power_setting_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-prph.h b/drivers/net/wireless/iwlegacy/iwl-prph.h index 30a493003ab0..96788a128a61 100644 --- a/drivers/net/wireless/iwlegacy/iwl-prph.h +++ b/drivers/net/wireless/iwlegacy/iwl-prph.h @@ -60,8 +60,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ -#ifndef __iwl_legacy_prph_h__ -#define __iwl_legacy_prph_h__ +#ifndef __il_prph_h__ +#define __il_prph_h__ /* * Registers in this file are internal, not PCI bus memory mapped. @@ -120,13 +120,13 @@ * * 1) Initialization -- performs hardware calibration and sets up some * internal data, then notifies host via "initialize alive" notification - * (struct iwl_init_alive_resp) that it has completed all of its work. + * (struct il_init_alive_resp) that it has completed all of its work. * After signal from host, it then loads and starts the runtime program. * The initialization program must be used when initially setting up the * NIC after loading the driver. * * 2) Runtime/Protocol -- performs all normal runtime operations. This - * notifies host via "alive" notification (struct iwl_alive_resp) that it + * notifies host via "alive" notification (struct il_alive_resp) that it * is ready to be used. * * When initializing the NIC, the host driver does the following procedure: @@ -287,7 +287,7 @@ * Tx completion may end up being out-of-order). * * The driver must maintain the queue's Byte Count table in host DRAM - * (struct iwl4965_sched_queue_byte_cnt_tbl) for this mode. + * (struct il4965_sched_queue_byte_cnt_tbl) for this mode. * This mode does not support fragmentation. * * 2) FIFO (a.k.a. non-Scheduler-ACK), in which each TFD is processed in order. @@ -514,10 +514,10 @@ #define IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \ ((IWL49_SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffffffc) -#define IWL_SCD_TXFIFO_POS_TID (0) -#define IWL_SCD_TXFIFO_POS_RA (4) -#define IWL_SCD_QUEUE_RA_TID_MAP_RATID_MSK (0x01FF) +#define IL_SCD_TXFIFO_POS_TID (0) +#define IL_SCD_TXFIFO_POS_RA (4) +#define IL_SCD_QUEUE_RA_TID_MAP_RATID_MSK (0x01FF) /*********************** END TX SCHEDULER *************************************/ -#endif /* __iwl_legacy_prph_h__ */ +#endif /* __il_prph_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c index 9b5d0abe8be9..9a2714c7f3e8 100644 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -73,7 +73,7 @@ * + A list of pre-allocated SKBs is stored in iwl->rxq->rx_free. When * iwl->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled * to replenish the iwl->rxq->rx_free. - * + In iwl_rx_replenish (scheduled) if 'processed' != 'read' then the + * + In il_rx_replenish (scheduled) if 'processed' != 'read' then the * iwl->rxq is replenished and the READ INDEX is updated (updating the * 'processed' and 'read' driver indexes as well) * + A received packet is processed and handed to the kernel network stack, @@ -86,28 +86,28 @@ * * Driver sequence: * - * iwl_legacy_rx_queue_alloc() Allocates rx_free - * iwl_rx_replenish() Replenishes rx_free list from rx_used, and calls - * iwl_rx_queue_restock - * iwl_rx_queue_restock() Moves available buffers from rx_free into Rx + * il_rx_queue_alloc() Allocates rx_free + * il_rx_replenish() Replenishes rx_free list from rx_used, and calls + * il_rx_queue_restock + * il_rx_queue_restock() Moves available buffers from rx_free into Rx * queue, updates firmware pointers, and updates * the WRITE index. If insufficient rx_free buffers - * are available, schedules iwl_rx_replenish + * are available, schedules il_rx_replenish * * -- enable interrupts -- - * ISR - iwl_rx() Detach iwl_rx_mem_buffers from pool up to the + * ISR - il_rx() Detach il_rx_mem_buffers from pool up to the * READ INDEX, detaching the SKB from the pool. * Moves the packet buffer from queue to rx_used. - * Calls iwl_rx_queue_restock to refill any empty + * Calls il_rx_queue_restock to refill any empty * slots. * ... * */ /** - * iwl_legacy_rx_queue_space - Return number of free slots available in queue. + * il_rx_queue_space - Return number of free slots available in queue. */ -int iwl_legacy_rx_queue_space(const struct iwl_rx_queue *q) +int il_rx_queue_space(const struct il_rx_queue *q) { int s = q->read - q->write; if (s <= 0) @@ -118,14 +118,14 @@ int iwl_legacy_rx_queue_space(const struct iwl_rx_queue *q) s = 0; return s; } -EXPORT_SYMBOL(iwl_legacy_rx_queue_space); +EXPORT_SYMBOL(il_rx_queue_space); /** - * iwl_legacy_rx_queue_update_write_ptr - Update the write pointer for the RX queue + * il_rx_queue_update_write_ptr - Update the write pointer for the RX queue */ void -iwl_legacy_rx_queue_update_write_ptr(struct iwl_priv *priv, - struct iwl_rx_queue *q) +il_rx_queue_update_write_ptr(struct il_priv *priv, + struct il_rx_queue *q) { unsigned long flags; u32 rx_wrt_ptr_reg = priv->hw_params.rx_wrt_ptr_reg; @@ -138,26 +138,26 @@ iwl_legacy_rx_queue_update_write_ptr(struct iwl_priv *priv, /* If power-saving is in use, make sure device is awake */ if (test_bit(STATUS_POWER_PMI, &priv->status)) { - reg = iwl_read32(priv, CSR_UCODE_DRV_GP1); + reg = il_read32(priv, CSR_UCODE_DRV_GP1); if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "Rx queue requesting wakeup," " GP1 = 0x%x\n", reg); - iwl_legacy_set_bit(priv, CSR_GP_CNTRL, + il_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); goto exit_unlock; } q->write_actual = (q->write & ~0x7); - iwl_legacy_write_direct32(priv, rx_wrt_ptr_reg, + il_write_direct32(priv, rx_wrt_ptr_reg, q->write_actual); /* Else device is assumed to be awake */ } else { /* Device expects a multiple of 8 */ q->write_actual = (q->write & ~0x7); - iwl_legacy_write_direct32(priv, rx_wrt_ptr_reg, + il_write_direct32(priv, rx_wrt_ptr_reg, q->write_actual); } @@ -166,11 +166,11 @@ iwl_legacy_rx_queue_update_write_ptr(struct iwl_priv *priv, exit_unlock: spin_unlock_irqrestore(&q->lock, flags); } -EXPORT_SYMBOL(iwl_legacy_rx_queue_update_write_ptr); +EXPORT_SYMBOL(il_rx_queue_update_write_ptr); -int iwl_legacy_rx_queue_alloc(struct iwl_priv *priv) +int il_rx_queue_alloc(struct il_priv *priv) { - struct iwl_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &priv->rxq; struct device *dev = &priv->pci_dev->dev; int i; @@ -184,7 +184,7 @@ int iwl_legacy_rx_queue_alloc(struct iwl_priv *priv) if (!rxq->bd) goto err_bd; - rxq->rb_stts = dma_alloc_coherent(dev, sizeof(struct iwl_rb_status), + rxq->rb_stts = dma_alloc_coherent(dev, sizeof(struct il_rb_status), &rxq->rb_stts_dma, GFP_KERNEL); if (!rxq->rb_stts) goto err_rb; @@ -207,17 +207,17 @@ err_rb: err_bd: return -ENOMEM; } -EXPORT_SYMBOL(iwl_legacy_rx_queue_alloc); +EXPORT_SYMBOL(il_rx_queue_alloc); -void iwl_legacy_rx_spectrum_measure_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +void il_rx_spectrum_measure_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_spectrum_notification *report = &(pkt->u.spectrum_notif); + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_spectrum_notification *report = &(pkt->u.spectrum_notif); if (!report->state) { - IWL_DEBUG_11H(priv, + IL_DEBUG_11H(priv, "Spectrum Measure Notification: Start\n"); return; } @@ -225,12 +225,12 @@ void iwl_legacy_rx_spectrum_measure_notif(struct iwl_priv *priv, memcpy(&priv->measure_report, report, sizeof(*report)); priv->measurement_status |= MEASUREMENT_READY; } -EXPORT_SYMBOL(iwl_legacy_rx_spectrum_measure_notif); +EXPORT_SYMBOL(il_rx_spectrum_measure_notif); /* * returns non-zero if packet should be dropped */ -int iwl_legacy_set_decrypted_flag(struct iwl_priv *priv, +int il_set_decrypted_flag(struct il_priv *priv, struct ieee80211_hdr *hdr, u32 decrypt_res, struct ieee80211_rx_status *stats) @@ -241,14 +241,14 @@ int iwl_legacy_set_decrypted_flag(struct iwl_priv *priv, * All contexts have the same setting here due to it being * a module parameter, so OK to check any context. */ - if (priv->contexts[IWL_RXON_CTX_BSS].active.filter_flags & + if (priv->contexts[IL_RXON_CTX_BSS].active.filter_flags & RXON_FILTER_DIS_DECRYPT_MSK) return 0; if (!(fc & IEEE80211_FCTL_PROTECTED)) return 0; - IWL_DEBUG_RX(priv, "decrypt_res:0x%x\n", decrypt_res); + IL_DEBUG_RX(priv, "decrypt_res:0x%x\n", decrypt_res); switch (decrypt_res & RX_RES_STATUS_SEC_TYPE_MSK) { case RX_RES_STATUS_SEC_TYPE_TKIP: /* The uCode has got a bad phase 1 Key, pushes the packet. @@ -262,13 +262,13 @@ int iwl_legacy_set_decrypted_flag(struct iwl_priv *priv, RX_RES_STATUS_BAD_ICV_MIC) { /* bad ICV, the packet is destroyed since the * decryption is inplace, drop it */ - IWL_DEBUG_RX(priv, "Packet destroyed\n"); + IL_DEBUG_RX(priv, "Packet destroyed\n"); return -1; } case RX_RES_STATUS_SEC_TYPE_CCMP: if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) == RX_RES_STATUS_DECRYPT_OK) { - IWL_DEBUG_RX(priv, "hw decrypt successfully!!!\n"); + IL_DEBUG_RX(priv, "hw decrypt successfully!!!\n"); stats->flag |= RX_FLAG_DECRYPTED; } break; @@ -278,4 +278,4 @@ int iwl_legacy_set_decrypted_flag(struct iwl_priv *priv, } return 0; } -EXPORT_SYMBOL(iwl_legacy_set_decrypted_flag); +EXPORT_SYMBOL(il_set_decrypted_flag); diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index a6b5222fc59e..93e939cc9bc6 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -40,25 +40,25 @@ /* For active scan, listen ACTIVE_DWELL_TIME (msec) on each channel after * sending probe req. This should be set long enough to hear probe responses * from more than one AP. */ -#define IWL_ACTIVE_DWELL_TIME_24 (30) /* all times in msec */ -#define IWL_ACTIVE_DWELL_TIME_52 (20) +#define IL_ACTIVE_DWELL_TIME_24 (30) /* all times in msec */ +#define IL_ACTIVE_DWELL_TIME_52 (20) -#define IWL_ACTIVE_DWELL_FACTOR_24GHZ (3) -#define IWL_ACTIVE_DWELL_FACTOR_52GHZ (2) +#define IL_ACTIVE_DWELL_FACTOR_24GHZ (3) +#define IL_ACTIVE_DWELL_FACTOR_52GHZ (2) /* For passive scan, listen PASSIVE_DWELL_TIME (msec) on each channel. * Must be set longer than active dwell time. * For the most reliable scan, set > AP beacon interval (typically 100msec). */ -#define IWL_PASSIVE_DWELL_TIME_24 (20) /* all times in msec */ -#define IWL_PASSIVE_DWELL_TIME_52 (10) -#define IWL_PASSIVE_DWELL_BASE (100) -#define IWL_CHANNEL_TUNE_TIME 5 +#define IL_PASSIVE_DWELL_TIME_24 (20) /* all times in msec */ +#define IL_PASSIVE_DWELL_TIME_52 (10) +#define IL_PASSIVE_DWELL_BASE (100) +#define IL_CHANNEL_TUNE_TIME 5 -static int iwl_legacy_send_scan_abort(struct iwl_priv *priv) +static int il_send_scan_abort(struct il_priv *priv) { int ret; - struct iwl_rx_packet *pkt; - struct iwl_host_cmd cmd = { + struct il_rx_packet *pkt; + struct il_host_cmd cmd = { .id = REPLY_SCAN_ABORT_CMD, .flags = CMD_WANT_SKB, }; @@ -73,11 +73,11 @@ static int iwl_legacy_send_scan_abort(struct iwl_priv *priv) test_bit(STATUS_EXIT_PENDING, &priv->status)) return -EIO; - ret = iwl_legacy_send_cmd_sync(priv, &cmd); + ret = il_send_cmd_sync(priv, &cmd); if (ret) return ret; - pkt = (struct iwl_rx_packet *)cmd.reply_page; + pkt = (struct il_rx_packet *)cmd.reply_page; if (pkt->u.status != CAN_ABORT_STATUS) { /* The scan abort will return 1 for success or * 2 for "failure". A failure condition can be @@ -85,19 +85,19 @@ static int iwl_legacy_send_scan_abort(struct iwl_priv *priv) * can occur if we send the scan abort before we * the microcode has notified us that a scan is * completed. */ - IWL_DEBUG_SCAN(priv, "SCAN_ABORT ret %d.\n", pkt->u.status); + IL_DEBUG_SCAN(priv, "SCAN_ABORT ret %d.\n", pkt->u.status); ret = -EIO; } - iwl_legacy_free_pages(priv, cmd.reply_page); + il_free_pages(priv, cmd.reply_page); return ret; } -static void iwl_legacy_complete_scan(struct iwl_priv *priv, bool aborted) +static void il_complete_scan(struct il_priv *priv, bool aborted) { /* check if scan was requested from mac80211 */ if (priv->scan_request) { - IWL_DEBUG_SCAN(priv, "Complete scan in mac80211\n"); + IL_DEBUG_SCAN(priv, "Complete scan in mac80211\n"); ieee80211_scan_completed(priv->hw, aborted); } @@ -105,71 +105,71 @@ static void iwl_legacy_complete_scan(struct iwl_priv *priv, bool aborted) priv->scan_request = NULL; } -void iwl_legacy_force_scan_end(struct iwl_priv *priv) +void il_force_scan_end(struct il_priv *priv) { lockdep_assert_held(&priv->mutex); if (!test_bit(STATUS_SCANNING, &priv->status)) { - IWL_DEBUG_SCAN(priv, "Forcing scan end while not scanning\n"); + IL_DEBUG_SCAN(priv, "Forcing scan end while not scanning\n"); return; } - IWL_DEBUG_SCAN(priv, "Forcing scan end\n"); + IL_DEBUG_SCAN(priv, "Forcing scan end\n"); clear_bit(STATUS_SCANNING, &priv->status); clear_bit(STATUS_SCAN_HW, &priv->status); clear_bit(STATUS_SCAN_ABORTING, &priv->status); - iwl_legacy_complete_scan(priv, true); + il_complete_scan(priv, true); } -static void iwl_legacy_do_scan_abort(struct iwl_priv *priv) +static void il_do_scan_abort(struct il_priv *priv) { int ret; lockdep_assert_held(&priv->mutex); if (!test_bit(STATUS_SCANNING, &priv->status)) { - IWL_DEBUG_SCAN(priv, "Not performing scan to abort\n"); + IL_DEBUG_SCAN(priv, "Not performing scan to abort\n"); return; } if (test_and_set_bit(STATUS_SCAN_ABORTING, &priv->status)) { - IWL_DEBUG_SCAN(priv, "Scan abort in progress\n"); + IL_DEBUG_SCAN(priv, "Scan abort in progress\n"); return; } - ret = iwl_legacy_send_scan_abort(priv); + ret = il_send_scan_abort(priv); if (ret) { - IWL_DEBUG_SCAN(priv, "Send scan abort failed %d\n", ret); - iwl_legacy_force_scan_end(priv); + IL_DEBUG_SCAN(priv, "Send scan abort failed %d\n", ret); + il_force_scan_end(priv); } else - IWL_DEBUG_SCAN(priv, "Successfully send scan abort\n"); + IL_DEBUG_SCAN(priv, "Successfully send scan abort\n"); } /** - * iwl_scan_cancel - Cancel any currently executing HW scan + * il_scan_cancel - Cancel any currently executing HW scan */ -int iwl_legacy_scan_cancel(struct iwl_priv *priv) +int il_scan_cancel(struct il_priv *priv) { - IWL_DEBUG_SCAN(priv, "Queuing abort scan\n"); + IL_DEBUG_SCAN(priv, "Queuing abort scan\n"); queue_work(priv->workqueue, &priv->abort_scan); return 0; } -EXPORT_SYMBOL(iwl_legacy_scan_cancel); +EXPORT_SYMBOL(il_scan_cancel); /** - * iwl_legacy_scan_cancel_timeout - Cancel any currently executing HW scan + * il_scan_cancel_timeout - Cancel any currently executing HW scan * @ms: amount of time to wait (in milliseconds) for scan to abort * */ -int iwl_legacy_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms) +int il_scan_cancel_timeout(struct il_priv *priv, unsigned long ms) { unsigned long timeout = jiffies + msecs_to_jiffies(ms); lockdep_assert_held(&priv->mutex); - IWL_DEBUG_SCAN(priv, "Scan cancel timeout\n"); + IL_DEBUG_SCAN(priv, "Scan cancel timeout\n"); - iwl_legacy_do_scan_abort(priv); + il_do_scan_abort(priv); while (time_before_eq(jiffies, timeout)) { if (!test_bit(STATUS_SCAN_HW, &priv->status)) @@ -179,30 +179,30 @@ int iwl_legacy_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms) return test_bit(STATUS_SCAN_HW, &priv->status); } -EXPORT_SYMBOL(iwl_legacy_scan_cancel_timeout); +EXPORT_SYMBOL(il_scan_cancel_timeout); /* Service response to REPLY_SCAN_CMD (0x80) */ -static void iwl_legacy_rx_reply_scan(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il_rx_reply_scan(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_scanreq_notification *notif = - (struct iwl_scanreq_notification *)pkt->u.raw; + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_scanreq_notification *notif = + (struct il_scanreq_notification *)pkt->u.raw; - IWL_DEBUG_SCAN(priv, "Scan request status = 0x%x\n", notif->status); + IL_DEBUG_SCAN(priv, "Scan request status = 0x%x\n", notif->status); #endif } /* Service SCAN_START_NOTIFICATION (0x82) */ -static void iwl_legacy_rx_scan_start_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il_rx_scan_start_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_scanstart_notification *notif = - (struct iwl_scanstart_notification *)pkt->u.raw; + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_scanstart_notification *notif = + (struct il_scanstart_notification *)pkt->u.raw; priv->scan_start_tsf = le32_to_cpu(notif->tsf_low); - IWL_DEBUG_SCAN(priv, "Scan start: " + IL_DEBUG_SCAN(priv, "Scan start: " "%d [802.11%s] " "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n", notif->channel, @@ -213,15 +213,15 @@ static void iwl_legacy_rx_scan_start_notif(struct iwl_priv *priv, } /* Service SCAN_RESULTS_NOTIFICATION (0x83) */ -static void iwl_legacy_rx_scan_results_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il_rx_scan_results_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_scanresults_notification *notif = - (struct iwl_scanresults_notification *)pkt->u.raw; + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_scanresults_notification *notif = + (struct il_scanresults_notification *)pkt->u.raw; - IWL_DEBUG_SCAN(priv, "Scan ch.res: " + IL_DEBUG_SCAN(priv, "Scan ch.res: " "%d [802.11%s] " "(TSF: 0x%08X:%08X) - %d " "elapsed=%lu usec\n", @@ -235,16 +235,16 @@ static void iwl_legacy_rx_scan_results_notif(struct iwl_priv *priv, } /* Service SCAN_COMPLETE_NOTIFICATION (0x84) */ -static void iwl_legacy_rx_scan_complete_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il_rx_scan_complete_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_scancomplete_notification *scan_notif = (void *)pkt->u.raw; + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_scancomplete_notification *scan_notif = (void *)pkt->u.raw; #endif - IWL_DEBUG_SCAN(priv, + IL_DEBUG_SCAN(priv, "Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n", scan_notif->scanned_channels, scan_notif->tsf_low, @@ -253,49 +253,49 @@ static void iwl_legacy_rx_scan_complete_notif(struct iwl_priv *priv, /* The HW is no longer scanning */ clear_bit(STATUS_SCAN_HW, &priv->status); - IWL_DEBUG_SCAN(priv, "Scan on %sGHz took %dms\n", + IL_DEBUG_SCAN(priv, "Scan on %sGHz took %dms\n", (priv->scan_band == IEEE80211_BAND_2GHZ) ? "2.4" : "5.2", jiffies_to_msecs(jiffies - priv->scan_start)); queue_work(priv->workqueue, &priv->scan_completed); } -void iwl_legacy_setup_rx_scan_handlers(struct iwl_priv *priv) +void il_setup_rx_scan_handlers(struct il_priv *priv) { /* scan handlers */ - priv->rx_handlers[REPLY_SCAN_CMD] = iwl_legacy_rx_reply_scan; + priv->rx_handlers[REPLY_SCAN_CMD] = il_rx_reply_scan; priv->rx_handlers[SCAN_START_NOTIFICATION] = - iwl_legacy_rx_scan_start_notif; + il_rx_scan_start_notif; priv->rx_handlers[SCAN_RESULTS_NOTIFICATION] = - iwl_legacy_rx_scan_results_notif; + il_rx_scan_results_notif; priv->rx_handlers[SCAN_COMPLETE_NOTIFICATION] = - iwl_legacy_rx_scan_complete_notif; + il_rx_scan_complete_notif; } -EXPORT_SYMBOL(iwl_legacy_setup_rx_scan_handlers); +EXPORT_SYMBOL(il_setup_rx_scan_handlers); -inline u16 iwl_legacy_get_active_dwell_time(struct iwl_priv *priv, +inline u16 il_get_active_dwell_time(struct il_priv *priv, enum ieee80211_band band, u8 n_probes) { if (band == IEEE80211_BAND_5GHZ) - return IWL_ACTIVE_DWELL_TIME_52 + - IWL_ACTIVE_DWELL_FACTOR_52GHZ * (n_probes + 1); + return IL_ACTIVE_DWELL_TIME_52 + + IL_ACTIVE_DWELL_FACTOR_52GHZ * (n_probes + 1); else - return IWL_ACTIVE_DWELL_TIME_24 + - IWL_ACTIVE_DWELL_FACTOR_24GHZ * (n_probes + 1); + return IL_ACTIVE_DWELL_TIME_24 + + IL_ACTIVE_DWELL_FACTOR_24GHZ * (n_probes + 1); } -EXPORT_SYMBOL(iwl_legacy_get_active_dwell_time); +EXPORT_SYMBOL(il_get_active_dwell_time); -u16 iwl_legacy_get_passive_dwell_time(struct iwl_priv *priv, +u16 il_get_passive_dwell_time(struct il_priv *priv, enum ieee80211_band band, struct ieee80211_vif *vif) { - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; u16 passive = (band == IEEE80211_BAND_2GHZ) ? - IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_24 : - IWL_PASSIVE_DWELL_BASE + IWL_PASSIVE_DWELL_TIME_52; + IL_PASSIVE_DWELL_BASE + IL_PASSIVE_DWELL_TIME_24 : + IL_PASSIVE_DWELL_BASE + IL_PASSIVE_DWELL_TIME_52; - if (iwl_legacy_is_any_associated(priv)) { + if (il_is_any_associated(priv)) { /* * If we're associated, we clamp the maximum passive * dwell time to be 98% of the smallest beacon interval @@ -304,21 +304,21 @@ u16 iwl_legacy_get_passive_dwell_time(struct iwl_priv *priv, for_each_context(priv, ctx) { u16 value; - if (!iwl_legacy_is_associated_ctx(ctx)) + if (!il_is_associated_ctx(ctx)) continue; value = ctx->vif ? ctx->vif->bss_conf.beacon_int : 0; - if ((value > IWL_PASSIVE_DWELL_BASE) || !value) - value = IWL_PASSIVE_DWELL_BASE; - value = (value * 98) / 100 - IWL_CHANNEL_TUNE_TIME * 2; + if ((value > IL_PASSIVE_DWELL_BASE) || !value) + value = IL_PASSIVE_DWELL_BASE; + value = (value * 98) / 100 - IL_CHANNEL_TUNE_TIME * 2; passive = min(value, passive); } } return passive; } -EXPORT_SYMBOL(iwl_legacy_get_passive_dwell_time); +EXPORT_SYMBOL(il_get_passive_dwell_time); -void iwl_legacy_init_scan_params(struct iwl_priv *priv) +void il_init_scan_params(struct il_priv *priv) { u8 ant_idx = fls(priv->hw_params.valid_tx_ant) - 1; if (!priv->scan_tx_ant[IEEE80211_BAND_5GHZ]) @@ -326,9 +326,9 @@ void iwl_legacy_init_scan_params(struct iwl_priv *priv) if (!priv->scan_tx_ant[IEEE80211_BAND_2GHZ]) priv->scan_tx_ant[IEEE80211_BAND_2GHZ] = ant_idx; } -EXPORT_SYMBOL(iwl_legacy_init_scan_params); +EXPORT_SYMBOL(il_init_scan_params); -static int iwl_legacy_scan_initiate(struct iwl_priv *priv, +static int il_scan_initiate(struct il_priv *priv, struct ieee80211_vif *vif) { int ret; @@ -340,23 +340,23 @@ static int iwl_legacy_scan_initiate(struct iwl_priv *priv, cancel_delayed_work(&priv->scan_check); - if (!iwl_legacy_is_ready_rf(priv)) { - IWL_WARN(priv, "Request scan called when driver not ready.\n"); + if (!il_is_ready_rf(priv)) { + IL_WARN(priv, "Request scan called when driver not ready.\n"); return -EIO; } if (test_bit(STATUS_SCAN_HW, &priv->status)) { - IWL_DEBUG_SCAN(priv, + IL_DEBUG_SCAN(priv, "Multiple concurrent scan requests in parallel.\n"); return -EBUSY; } if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { - IWL_DEBUG_SCAN(priv, "Scan request while abort pending.\n"); + IL_DEBUG_SCAN(priv, "Scan request while abort pending.\n"); return -EBUSY; } - IWL_DEBUG_SCAN(priv, "Starting scan...\n"); + IL_DEBUG_SCAN(priv, "Starting scan...\n"); set_bit(STATUS_SCANNING, &priv->status); priv->scan_start = jiffies; @@ -368,19 +368,19 @@ static int iwl_legacy_scan_initiate(struct iwl_priv *priv, } queue_delayed_work(priv->workqueue, &priv->scan_check, - IWL_SCAN_CHECK_WATCHDOG); + IL_SCAN_CHECK_WATCHDOG); return 0; } -int iwl_legacy_mac_hw_scan(struct ieee80211_hw *hw, +int il_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct cfg80211_scan_request *req) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; int ret; - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); if (req->n_channels == 0) return -EINVAL; @@ -388,7 +388,7 @@ int iwl_legacy_mac_hw_scan(struct ieee80211_hw *hw, mutex_lock(&priv->mutex); if (test_bit(STATUS_SCANNING, &priv->status)) { - IWL_DEBUG_SCAN(priv, "Scan already in progress.\n"); + IL_DEBUG_SCAN(priv, "Scan already in progress.\n"); ret = -EAGAIN; goto out_unlock; } @@ -398,38 +398,38 @@ int iwl_legacy_mac_hw_scan(struct ieee80211_hw *hw, priv->scan_vif = vif; priv->scan_band = req->channels[0]->band; - ret = iwl_legacy_scan_initiate(priv, vif); + ret = il_scan_initiate(priv, vif); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); out_unlock: mutex_unlock(&priv->mutex); return ret; } -EXPORT_SYMBOL(iwl_legacy_mac_hw_scan); +EXPORT_SYMBOL(il_mac_hw_scan); -static void iwl_legacy_bg_scan_check(struct work_struct *data) +static void il_bg_scan_check(struct work_struct *data) { - struct iwl_priv *priv = - container_of(data, struct iwl_priv, scan_check.work); + struct il_priv *priv = + container_of(data, struct il_priv, scan_check.work); - IWL_DEBUG_SCAN(priv, "Scan check work\n"); + IL_DEBUG_SCAN(priv, "Scan check work\n"); /* Since we are here firmware does not finish scan and * most likely is in bad shape, so we don't bother to * send abort command, just force scan complete to mac80211 */ mutex_lock(&priv->mutex); - iwl_legacy_force_scan_end(priv); + il_force_scan_end(priv); mutex_unlock(&priv->mutex); } /** - * iwl_legacy_fill_probe_req - fill in all required fields and IE for probe request + * il_fill_probe_req - fill in all required fields and IE for probe request */ u16 -iwl_legacy_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame, +il_fill_probe_req(struct il_priv *priv, struct ieee80211_mgmt *frame, const u8 *ta, const u8 *ies, int ie_len, int left) { int len = 0; @@ -471,28 +471,28 @@ iwl_legacy_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame, return (u16)len; } -EXPORT_SYMBOL(iwl_legacy_fill_probe_req); +EXPORT_SYMBOL(il_fill_probe_req); -static void iwl_legacy_bg_abort_scan(struct work_struct *work) +static void il_bg_abort_scan(struct work_struct *work) { - struct iwl_priv *priv = container_of(work, struct iwl_priv, abort_scan); + struct il_priv *priv = container_of(work, struct il_priv, abort_scan); - IWL_DEBUG_SCAN(priv, "Abort scan work\n"); + IL_DEBUG_SCAN(priv, "Abort scan work\n"); /* We keep scan_check work queued in case when firmware will not * report back scan completed notification */ mutex_lock(&priv->mutex); - iwl_legacy_scan_cancel_timeout(priv, 200); + il_scan_cancel_timeout(priv, 200); mutex_unlock(&priv->mutex); } -static void iwl_legacy_bg_scan_completed(struct work_struct *work) +static void il_bg_scan_completed(struct work_struct *work) { - struct iwl_priv *priv = - container_of(work, struct iwl_priv, scan_completed); + struct il_priv *priv = + container_of(work, struct il_priv, scan_completed); bool aborted; - IWL_DEBUG_SCAN(priv, "Completed scan.\n"); + IL_DEBUG_SCAN(priv, "Completed scan.\n"); cancel_delayed_work(&priv->scan_check); @@ -500,26 +500,26 @@ static void iwl_legacy_bg_scan_completed(struct work_struct *work) aborted = test_and_clear_bit(STATUS_SCAN_ABORTING, &priv->status); if (aborted) - IWL_DEBUG_SCAN(priv, "Aborted scan completed.\n"); + IL_DEBUG_SCAN(priv, "Aborted scan completed.\n"); if (!test_and_clear_bit(STATUS_SCANNING, &priv->status)) { - IWL_DEBUG_SCAN(priv, "Scan already completed.\n"); + IL_DEBUG_SCAN(priv, "Scan already completed.\n"); goto out_settings; } - iwl_legacy_complete_scan(priv, aborted); + il_complete_scan(priv, aborted); out_settings: /* Can we still talk to firmware ? */ - if (!iwl_legacy_is_ready_rf(priv)) + if (!il_is_ready_rf(priv)) goto out; /* * We do not commit power settings while scan is pending, * do it now if the settings changed. */ - iwl_legacy_power_set_mode(priv, &priv->power_data.sleep_cmd_next, false); - iwl_legacy_set_tx_power(priv, priv->tx_power_next, false); + il_power_set_mode(priv, &priv->power_data.sleep_cmd_next, false); + il_set_tx_power(priv, priv->tx_power_next, false); priv->cfg->ops->utils->post_scan(priv); @@ -527,23 +527,23 @@ out: mutex_unlock(&priv->mutex); } -void iwl_legacy_setup_scan_deferred_work(struct iwl_priv *priv) +void il_setup_scan_deferred_work(struct il_priv *priv) { - INIT_WORK(&priv->scan_completed, iwl_legacy_bg_scan_completed); - INIT_WORK(&priv->abort_scan, iwl_legacy_bg_abort_scan); - INIT_DELAYED_WORK(&priv->scan_check, iwl_legacy_bg_scan_check); + INIT_WORK(&priv->scan_completed, il_bg_scan_completed); + INIT_WORK(&priv->abort_scan, il_bg_abort_scan); + INIT_DELAYED_WORK(&priv->scan_check, il_bg_scan_check); } -EXPORT_SYMBOL(iwl_legacy_setup_scan_deferred_work); +EXPORT_SYMBOL(il_setup_scan_deferred_work); -void iwl_legacy_cancel_scan_deferred_work(struct iwl_priv *priv) +void il_cancel_scan_deferred_work(struct il_priv *priv) { cancel_work_sync(&priv->abort_scan); cancel_work_sync(&priv->scan_completed); if (cancel_delayed_work_sync(&priv->scan_check)) { mutex_lock(&priv->mutex); - iwl_legacy_force_scan_end(priv); + il_force_scan_end(priv); mutex_unlock(&priv->mutex); } } -EXPORT_SYMBOL(iwl_legacy_cancel_scan_deferred_work); +EXPORT_SYMBOL(il_cancel_scan_deferred_work); diff --git a/drivers/net/wireless/iwlegacy/iwl-spectrum.h b/drivers/net/wireless/iwlegacy/iwl-spectrum.h index 9f70a4723103..85fe48e520f9 100644 --- a/drivers/net/wireless/iwlegacy/iwl-spectrum.h +++ b/drivers/net/wireless/iwlegacy/iwl-spectrum.h @@ -26,8 +26,8 @@ * *****************************************************************************/ -#ifndef __iwl_legacy_spectrum_h__ -#define __iwl_legacy_spectrum_h__ +#ifndef __il_spectrum_h__ +#define __il_spectrum_h__ enum { /* ieee80211_basic_report.map */ IEEE80211_BASIC_MAP_BSS = (1 << 0), IEEE80211_BASIC_MAP_OFDM = (1 << 1), diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.c b/drivers/net/wireless/iwlegacy/iwl-sta.c index 66f0fb2bbe00..3773f7d64d2a 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-sta.c @@ -37,72 +37,72 @@ #include "iwl-sta.h" /* priv->sta_lock must be held */ -static void iwl_legacy_sta_ucode_activate(struct iwl_priv *priv, u8 sta_id) +static void il_sta_ucode_activate(struct il_priv *priv, u8 sta_id) { - if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) - IWL_ERR(priv, + if (!(priv->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) + IL_ERR(priv, "ACTIVATE a non DRIVER active station id %u addr %pM\n", sta_id, priv->stations[sta_id].sta.sta.addr); - if (priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE) { - IWL_DEBUG_ASSOC(priv, + if (priv->stations[sta_id].used & IL_STA_UCODE_ACTIVE) { + IL_DEBUG_ASSOC(priv, "STA id %u addr %pM already present" " in uCode (according to driver)\n", sta_id, priv->stations[sta_id].sta.sta.addr); } else { - priv->stations[sta_id].used |= IWL_STA_UCODE_ACTIVE; - IWL_DEBUG_ASSOC(priv, "Added STA id %u addr %pM to uCode\n", + priv->stations[sta_id].used |= IL_STA_UCODE_ACTIVE; + IL_DEBUG_ASSOC(priv, "Added STA id %u addr %pM to uCode\n", sta_id, priv->stations[sta_id].sta.sta.addr); } } -static int iwl_legacy_process_add_sta_resp(struct iwl_priv *priv, - struct iwl_legacy_addsta_cmd *addsta, - struct iwl_rx_packet *pkt, +static int il_process_add_sta_resp(struct il_priv *priv, + struct il_addsta_cmd *addsta, + struct il_rx_packet *pkt, bool sync) { u8 sta_id = addsta->sta.sta_id; unsigned long flags; int ret = -EIO; - if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) { - IWL_ERR(priv, "Bad return from REPLY_ADD_STA (0x%08X)\n", + if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { + IL_ERR(priv, "Bad return from REPLY_ADD_STA (0x%08X)\n", pkt->hdr.flags); return ret; } - IWL_DEBUG_INFO(priv, "Processing response for adding station %u\n", + IL_DEBUG_INFO(priv, "Processing response for adding station %u\n", sta_id); spin_lock_irqsave(&priv->sta_lock, flags); switch (pkt->u.add_sta.status) { case ADD_STA_SUCCESS_MSK: - IWL_DEBUG_INFO(priv, "REPLY_ADD_STA PASSED\n"); - iwl_legacy_sta_ucode_activate(priv, sta_id); + IL_DEBUG_INFO(priv, "REPLY_ADD_STA PASSED\n"); + il_sta_ucode_activate(priv, sta_id); ret = 0; break; case ADD_STA_NO_ROOM_IN_TABLE: - IWL_ERR(priv, "Adding station %d failed, no room in table.\n", + IL_ERR(priv, "Adding station %d failed, no room in table.\n", sta_id); break; case ADD_STA_NO_BLOCK_ACK_RESOURCE: - IWL_ERR(priv, + IL_ERR(priv, "Adding station %d failed, no block ack resource.\n", sta_id); break; case ADD_STA_MODIFY_NON_EXIST_STA: - IWL_ERR(priv, "Attempting to modify non-existing station %d\n", + IL_ERR(priv, "Attempting to modify non-existing station %d\n", sta_id); break; default: - IWL_DEBUG_ASSOC(priv, "Received REPLY_ADD_STA:(0x%08X)\n", + IL_DEBUG_ASSOC(priv, "Received REPLY_ADD_STA:(0x%08X)\n", pkt->u.add_sta.status); break; } - IWL_DEBUG_INFO(priv, "%s station id %u addr %pM\n", + IL_DEBUG_INFO(priv, "%s station id %u addr %pM\n", priv->stations[sta_id].sta.mode == STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", sta_id, priv->stations[sta_id].sta.sta.addr); @@ -115,7 +115,7 @@ static int iwl_legacy_process_add_sta_resp(struct iwl_priv *priv, * issue has not yet been resolved and this debugging is left to * observe the problem. */ - IWL_DEBUG_INFO(priv, "%s station according to cmd buffer %pM\n", + IL_DEBUG_INFO(priv, "%s station according to cmd buffer %pM\n", priv->stations[sta_id].sta.mode == STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", addsta->sta.addr); @@ -124,59 +124,59 @@ static int iwl_legacy_process_add_sta_resp(struct iwl_priv *priv, return ret; } -static void iwl_legacy_add_sta_callback(struct iwl_priv *priv, - struct iwl_device_cmd *cmd, - struct iwl_rx_packet *pkt) +static void il_add_sta_callback(struct il_priv *priv, + struct il_device_cmd *cmd, + struct il_rx_packet *pkt) { - struct iwl_legacy_addsta_cmd *addsta = - (struct iwl_legacy_addsta_cmd *)cmd->cmd.payload; + struct il_addsta_cmd *addsta = + (struct il_addsta_cmd *)cmd->cmd.payload; - iwl_legacy_process_add_sta_resp(priv, addsta, pkt, false); + il_process_add_sta_resp(priv, addsta, pkt, false); } -int iwl_legacy_send_add_sta(struct iwl_priv *priv, - struct iwl_legacy_addsta_cmd *sta, u8 flags) +int il_send_add_sta(struct il_priv *priv, + struct il_addsta_cmd *sta, u8 flags) { - struct iwl_rx_packet *pkt = NULL; + struct il_rx_packet *pkt = NULL; int ret = 0; u8 data[sizeof(*sta)]; - struct iwl_host_cmd cmd = { + struct il_host_cmd cmd = { .id = REPLY_ADD_STA, .flags = flags, .data = data, }; u8 sta_id __maybe_unused = sta->sta.sta_id; - IWL_DEBUG_INFO(priv, "Adding sta %u (%pM) %ssynchronously\n", + IL_DEBUG_INFO(priv, "Adding sta %u (%pM) %ssynchronously\n", sta_id, sta->sta.addr, flags & CMD_ASYNC ? "a" : ""); if (flags & CMD_ASYNC) - cmd.callback = iwl_legacy_add_sta_callback; + cmd.callback = il_add_sta_callback; else { cmd.flags |= CMD_WANT_SKB; might_sleep(); } cmd.len = priv->cfg->ops->utils->build_addsta_hcmd(sta, data); - ret = iwl_legacy_send_cmd(priv, &cmd); + ret = il_send_cmd(priv, &cmd); if (ret || (flags & CMD_ASYNC)) return ret; if (ret == 0) { - pkt = (struct iwl_rx_packet *)cmd.reply_page; - ret = iwl_legacy_process_add_sta_resp(priv, sta, pkt, true); + pkt = (struct il_rx_packet *)cmd.reply_page; + ret = il_process_add_sta_resp(priv, sta, pkt, true); } - iwl_legacy_free_pages(priv, cmd.reply_page); + il_free_pages(priv, cmd.reply_page); return ret; } -EXPORT_SYMBOL(iwl_legacy_send_add_sta); +EXPORT_SYMBOL(il_send_add_sta); -static void iwl_legacy_set_ht_add_station(struct iwl_priv *priv, u8 index, +static void il_set_ht_add_station(struct il_priv *priv, u8 index, struct ieee80211_sta *sta, - struct iwl_rxon_context *ctx) + struct il_rxon_context *ctx) { struct ieee80211_sta_ht_cap *sta_ht_inf = &sta->ht_cap; __le32 sta_flags; @@ -186,7 +186,7 @@ static void iwl_legacy_set_ht_add_station(struct iwl_priv *priv, u8 index, goto done; mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_SM_PS) >> 2; - IWL_DEBUG_ASSOC(priv, "spatial multiplexing power save mode: %s\n", + IL_DEBUG_ASSOC(priv, "spatial multiplexing power save mode: %s\n", (mimo_ps_mode == WLAN_HT_CAP_SM_PS_STATIC) ? "static" : (mimo_ps_mode == WLAN_HT_CAP_SM_PS_DYNAMIC) ? @@ -206,7 +206,7 @@ static void iwl_legacy_set_ht_add_station(struct iwl_priv *priv, u8 index, case WLAN_HT_CAP_SM_PS_DISABLED: break; default: - IWL_WARN(priv, "Invalid MIMO PS mode %d\n", mimo_ps_mode); + IL_WARN(priv, "Invalid MIMO PS mode %d\n", mimo_ps_mode); break; } @@ -216,7 +216,7 @@ static void iwl_legacy_set_ht_add_station(struct iwl_priv *priv, u8 index, sta_flags |= cpu_to_le32( (u32)sta_ht_inf->ampdu_density << STA_FLG_AGG_MPDU_DENSITY_POS); - if (iwl_legacy_is_ht40_tx_allowed(priv, ctx, &sta->ht_cap)) + if (il_is_ht40_tx_allowed(priv, ctx, &sta->ht_cap)) sta_flags |= STA_FLG_HT40_EN_MSK; else sta_flags &= ~STA_FLG_HT40_EN_MSK; @@ -227,16 +227,16 @@ static void iwl_legacy_set_ht_add_station(struct iwl_priv *priv, u8 index, } /** - * iwl_legacy_prep_station - Prepare station information for addition + * il_prep_station - Prepare station information for addition * * should be called with sta_lock held */ -u8 iwl_legacy_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, +u8 il_prep_station(struct il_priv *priv, struct il_rxon_context *ctx, const u8 *addr, bool is_ap, struct ieee80211_sta *sta) { - struct iwl_station_entry *station; + struct il_station_entry *station; int i; - u8 sta_id = IWL_INVALID_STATION; + u8 sta_id = IL_INVALID_STATION; u16 rate; if (is_ap) @@ -244,7 +244,7 @@ u8 iwl_legacy_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, else if (is_broadcast_ether_addr(addr)) sta_id = ctx->bcast_sta_id; else - for (i = IWL_STA_ID; i < priv->hw_params.max_stations; i++) { + for (i = IL_STA_ID; i < priv->hw_params.max_stations; i++) { if (!compare_ether_addr(priv->stations[i].sta.sta.addr, addr)) { sta_id = i; @@ -252,7 +252,7 @@ u8 iwl_legacy_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, } if (!priv->stations[i].used && - sta_id == IWL_INVALID_STATION) + sta_id == IL_INVALID_STATION) sta_id = i; } @@ -260,7 +260,7 @@ u8 iwl_legacy_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, * These two conditions have the same outcome, but keep them * separate */ - if (unlikely(sta_id == IWL_INVALID_STATION)) + if (unlikely(sta_id == IL_INVALID_STATION)) return sta_id; /* @@ -268,30 +268,30 @@ u8 iwl_legacy_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, * station. Keep track if one is in progress so that we do not send * another. */ - if (priv->stations[sta_id].used & IWL_STA_UCODE_INPROGRESS) { - IWL_DEBUG_INFO(priv, + if (priv->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { + IL_DEBUG_INFO(priv, "STA %d already in process of being added.\n", sta_id); return sta_id; } - if ((priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE) && - (priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE) && + if ((priv->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && + (priv->stations[sta_id].used & IL_STA_UCODE_ACTIVE) && !compare_ether_addr(priv->stations[sta_id].sta.sta.addr, addr)) { - IWL_DEBUG_ASSOC(priv, + IL_DEBUG_ASSOC(priv, "STA %d (%pM) already added, not adding again.\n", sta_id, addr); return sta_id; } station = &priv->stations[sta_id]; - station->used = IWL_STA_DRIVER_ACTIVE; - IWL_DEBUG_ASSOC(priv, "Add STA to driver ID %d: %pM\n", + station->used = IL_STA_DRIVER_ACTIVE; + IL_DEBUG_ASSOC(priv, "Add STA to driver ID %d: %pM\n", sta_id, addr); priv->num_stations++; /* Set up the REPLY_ADD_STA command to send to device */ - memset(&station->sta, 0, sizeof(struct iwl_legacy_addsta_cmd)); + memset(&station->sta, 0, sizeof(struct il_addsta_cmd)); memcpy(station->sta.sta.addr, addr, ETH_ALEN); station->sta.mode = 0; station->sta.sta.sta_id = sta_id; @@ -299,7 +299,7 @@ u8 iwl_legacy_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, station->ctxid = ctx->ctxid; if (sta) { - struct iwl_station_priv_common *sta_priv; + struct il_station_priv_common *sta_priv; sta_priv = (void *)sta->drv_priv; sta_priv->ctx = ctx; @@ -310,40 +310,40 @@ u8 iwl_legacy_prep_station(struct iwl_priv *priv, struct iwl_rxon_context *ctx, * STA and broadcast STA) pass in a NULL sta, and mac80211 * doesn't allow HT IBSS. */ - iwl_legacy_set_ht_add_station(priv, sta_id, sta, ctx); + il_set_ht_add_station(priv, sta_id, sta, ctx); /* 3945 only */ rate = (priv->band == IEEE80211_BAND_5GHZ) ? - IWL_RATE_6M_PLCP : IWL_RATE_1M_PLCP; + IL_RATE_6M_PLCP : IL_RATE_1M_PLCP; /* Turn on both antennas for the station... */ station->sta.rate_n_flags = cpu_to_le16(rate | RATE_MCS_ANT_AB_MSK); return sta_id; } -EXPORT_SYMBOL_GPL(iwl_legacy_prep_station); +EXPORT_SYMBOL_GPL(il_prep_station); #define STA_WAIT_TIMEOUT (HZ/2) /** - * iwl_legacy_add_station_common - + * il_add_station_common - */ int -iwl_legacy_add_station_common(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +il_add_station_common(struct il_priv *priv, + struct il_rxon_context *ctx, const u8 *addr, bool is_ap, struct ieee80211_sta *sta, u8 *sta_id_r) { unsigned long flags_spin; int ret = 0; u8 sta_id; - struct iwl_legacy_addsta_cmd sta_cmd; + struct il_addsta_cmd sta_cmd; *sta_id_r = 0; spin_lock_irqsave(&priv->sta_lock, flags_spin); - sta_id = iwl_legacy_prep_station(priv, ctx, addr, is_ap, sta); - if (sta_id == IWL_INVALID_STATION) { - IWL_ERR(priv, "Unable to prepare station %pM for addition\n", + sta_id = il_prep_station(priv, ctx, addr, is_ap, sta); + if (sta_id == IL_INVALID_STATION) { + IL_ERR(priv, "Unable to prepare station %pM for addition\n", addr); spin_unlock_irqrestore(&priv->sta_lock, flags_spin); return -EINVAL; @@ -354,75 +354,75 @@ iwl_legacy_add_station_common(struct iwl_priv *priv, * station. Keep track if one is in progress so that we do not send * another. */ - if (priv->stations[sta_id].used & IWL_STA_UCODE_INPROGRESS) { - IWL_DEBUG_INFO(priv, + if (priv->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { + IL_DEBUG_INFO(priv, "STA %d already in process of being added.\n", sta_id); spin_unlock_irqrestore(&priv->sta_lock, flags_spin); return -EEXIST; } - if ((priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE) && - (priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE)) { - IWL_DEBUG_ASSOC(priv, + if ((priv->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && + (priv->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { + IL_DEBUG_ASSOC(priv, "STA %d (%pM) already added, not adding again.\n", sta_id, addr); spin_unlock_irqrestore(&priv->sta_lock, flags_spin); return -EEXIST; } - priv->stations[sta_id].used |= IWL_STA_UCODE_INPROGRESS; + priv->stations[sta_id].used |= IL_STA_UCODE_INPROGRESS; memcpy(&sta_cmd, &priv->stations[sta_id].sta, - sizeof(struct iwl_legacy_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&priv->sta_lock, flags_spin); /* Add station to device's station table */ - ret = iwl_legacy_send_add_sta(priv, &sta_cmd, CMD_SYNC); + ret = il_send_add_sta(priv, &sta_cmd, CMD_SYNC); if (ret) { spin_lock_irqsave(&priv->sta_lock, flags_spin); - IWL_ERR(priv, "Adding station %pM failed.\n", + IL_ERR(priv, "Adding station %pM failed.\n", priv->stations[sta_id].sta.sta.addr); - priv->stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE; - priv->stations[sta_id].used &= ~IWL_STA_UCODE_INPROGRESS; + priv->stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE; + priv->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; spin_unlock_irqrestore(&priv->sta_lock, flags_spin); } *sta_id_r = sta_id; return ret; } -EXPORT_SYMBOL(iwl_legacy_add_station_common); +EXPORT_SYMBOL(il_add_station_common); /** - * iwl_legacy_sta_ucode_deactivate - deactivate ucode status for a station + * il_sta_ucode_deactivate - deactivate ucode status for a station * * priv->sta_lock must be held */ -static void iwl_legacy_sta_ucode_deactivate(struct iwl_priv *priv, u8 sta_id) +static void il_sta_ucode_deactivate(struct il_priv *priv, u8 sta_id) { /* Ucode must be active and driver must be non active */ if ((priv->stations[sta_id].used & - (IWL_STA_UCODE_ACTIVE | IWL_STA_DRIVER_ACTIVE)) != - IWL_STA_UCODE_ACTIVE) - IWL_ERR(priv, "removed non active STA %u\n", sta_id); + (IL_STA_UCODE_ACTIVE | IL_STA_DRIVER_ACTIVE)) != + IL_STA_UCODE_ACTIVE) + IL_ERR(priv, "removed non active STA %u\n", sta_id); - priv->stations[sta_id].used &= ~IWL_STA_UCODE_ACTIVE; + priv->stations[sta_id].used &= ~IL_STA_UCODE_ACTIVE; - memset(&priv->stations[sta_id], 0, sizeof(struct iwl_station_entry)); - IWL_DEBUG_ASSOC(priv, "Removed STA %u\n", sta_id); + memset(&priv->stations[sta_id], 0, sizeof(struct il_station_entry)); + IL_DEBUG_ASSOC(priv, "Removed STA %u\n", sta_id); } -static int iwl_legacy_send_remove_station(struct iwl_priv *priv, +static int il_send_remove_station(struct il_priv *priv, const u8 *addr, int sta_id, bool temporary) { - struct iwl_rx_packet *pkt; + struct il_rx_packet *pkt; int ret; unsigned long flags_spin; - struct iwl_rem_sta_cmd rm_sta_cmd; + struct il_rem_sta_cmd rm_sta_cmd; - struct iwl_host_cmd cmd = { + struct il_host_cmd cmd = { .id = REPLY_REMOVE_STA, - .len = sizeof(struct iwl_rem_sta_cmd), + .len = sizeof(struct il_rem_sta_cmd), .flags = CMD_SYNC, .data = &rm_sta_cmd, }; @@ -433,14 +433,14 @@ static int iwl_legacy_send_remove_station(struct iwl_priv *priv, cmd.flags |= CMD_WANT_SKB; - ret = iwl_legacy_send_cmd(priv, &cmd); + ret = il_send_cmd(priv, &cmd); if (ret) return ret; - pkt = (struct iwl_rx_packet *)cmd.reply_page; - if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) { - IWL_ERR(priv, "Bad return from REPLY_REMOVE_STA (0x%08X)\n", + pkt = (struct il_rx_packet *)cmd.reply_page; + if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { + IL_ERR(priv, "Bad return from REPLY_REMOVE_STA (0x%08X)\n", pkt->hdr.flags); ret = -EIO; } @@ -450,33 +450,33 @@ static int iwl_legacy_send_remove_station(struct iwl_priv *priv, case REM_STA_SUCCESS_MSK: if (!temporary) { spin_lock_irqsave(&priv->sta_lock, flags_spin); - iwl_legacy_sta_ucode_deactivate(priv, sta_id); + il_sta_ucode_deactivate(priv, sta_id); spin_unlock_irqrestore(&priv->sta_lock, flags_spin); } - IWL_DEBUG_ASSOC(priv, "REPLY_REMOVE_STA PASSED\n"); + IL_DEBUG_ASSOC(priv, "REPLY_REMOVE_STA PASSED\n"); break; default: ret = -EIO; - IWL_ERR(priv, "REPLY_REMOVE_STA failed\n"); + IL_ERR(priv, "REPLY_REMOVE_STA failed\n"); break; } } - iwl_legacy_free_pages(priv, cmd.reply_page); + il_free_pages(priv, cmd.reply_page); return ret; } /** - * iwl_legacy_remove_station - Remove driver's knowledge of station. + * il_remove_station - Remove driver's knowledge of station. */ -int iwl_legacy_remove_station(struct iwl_priv *priv, const u8 sta_id, +int il_remove_station(struct il_priv *priv, const u8 sta_id, const u8 *addr) { unsigned long flags; - if (!iwl_legacy_is_ready(priv)) { - IWL_DEBUG_INFO(priv, + if (!il_is_ready(priv)) { + IL_DEBUG_INFO(priv, "Unable to remove station %pM, device not ready.\n", addr); /* @@ -487,32 +487,32 @@ int iwl_legacy_remove_station(struct iwl_priv *priv, const u8 sta_id, return 0; } - IWL_DEBUG_ASSOC(priv, "Removing STA from driver:%d %pM\n", + IL_DEBUG_ASSOC(priv, "Removing STA from driver:%d %pM\n", sta_id, addr); - if (WARN_ON(sta_id == IWL_INVALID_STATION)) + if (WARN_ON(sta_id == IL_INVALID_STATION)) return -EINVAL; spin_lock_irqsave(&priv->sta_lock, flags); - if (!(priv->stations[sta_id].used & IWL_STA_DRIVER_ACTIVE)) { - IWL_DEBUG_INFO(priv, "Removing %pM but non DRIVER active\n", + if (!(priv->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) { + IL_DEBUG_INFO(priv, "Removing %pM but non DRIVER active\n", addr); goto out_err; } - if (!(priv->stations[sta_id].used & IWL_STA_UCODE_ACTIVE)) { - IWL_DEBUG_INFO(priv, "Removing %pM but non UCODE active\n", + if (!(priv->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { + IL_DEBUG_INFO(priv, "Removing %pM but non UCODE active\n", addr); goto out_err; } - if (priv->stations[sta_id].used & IWL_STA_LOCAL) { + if (priv->stations[sta_id].used & IL_STA_LOCAL) { kfree(priv->stations[sta_id].lq); priv->stations[sta_id].lq = NULL; } - priv->stations[sta_id].used &= ~IWL_STA_DRIVER_ACTIVE; + priv->stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE; priv->num_stations--; @@ -520,52 +520,52 @@ int iwl_legacy_remove_station(struct iwl_priv *priv, const u8 sta_id, spin_unlock_irqrestore(&priv->sta_lock, flags); - return iwl_legacy_send_remove_station(priv, addr, sta_id, false); + return il_send_remove_station(priv, addr, sta_id, false); out_err: spin_unlock_irqrestore(&priv->sta_lock, flags); return -EINVAL; } -EXPORT_SYMBOL_GPL(iwl_legacy_remove_station); +EXPORT_SYMBOL_GPL(il_remove_station); /** - * iwl_legacy_clear_ucode_stations - clear ucode station table bits + * il_clear_ucode_stations - clear ucode station table bits * * This function clears all the bits in the driver indicating * which stations are active in the ucode. Call when something * other than explicit station management would cause this in * the ucode, e.g. unassociated RXON. */ -void iwl_legacy_clear_ucode_stations(struct iwl_priv *priv, - struct iwl_rxon_context *ctx) +void il_clear_ucode_stations(struct il_priv *priv, + struct il_rxon_context *ctx) { int i; unsigned long flags_spin; bool cleared = false; - IWL_DEBUG_INFO(priv, "Clearing ucode stations in driver\n"); + IL_DEBUG_INFO(priv, "Clearing ucode stations in driver\n"); spin_lock_irqsave(&priv->sta_lock, flags_spin); for (i = 0; i < priv->hw_params.max_stations; i++) { if (ctx && ctx->ctxid != priv->stations[i].ctxid) continue; - if (priv->stations[i].used & IWL_STA_UCODE_ACTIVE) { - IWL_DEBUG_INFO(priv, + if (priv->stations[i].used & IL_STA_UCODE_ACTIVE) { + IL_DEBUG_INFO(priv, "Clearing ucode active for station %d\n", i); - priv->stations[i].used &= ~IWL_STA_UCODE_ACTIVE; + priv->stations[i].used &= ~IL_STA_UCODE_ACTIVE; cleared = true; } } spin_unlock_irqrestore(&priv->sta_lock, flags_spin); if (!cleared) - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "No active stations found to be cleared\n"); } -EXPORT_SYMBOL(iwl_legacy_clear_ucode_stations); +EXPORT_SYMBOL(il_clear_ucode_stations); /** - * iwl_legacy_restore_stations() - Restore driver known stations to device + * il_restore_stations() - Restore driver known stations to device * * All stations considered active by driver, but not present in ucode, is * restored. @@ -573,57 +573,57 @@ EXPORT_SYMBOL(iwl_legacy_clear_ucode_stations); * Function sleeps. */ void -iwl_legacy_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx) +il_restore_stations(struct il_priv *priv, struct il_rxon_context *ctx) { - struct iwl_legacy_addsta_cmd sta_cmd; - struct iwl_link_quality_cmd lq; + struct il_addsta_cmd sta_cmd; + struct il_link_quality_cmd lq; unsigned long flags_spin; int i; bool found = false; int ret; bool send_lq; - if (!iwl_legacy_is_ready(priv)) { - IWL_DEBUG_INFO(priv, + if (!il_is_ready(priv)) { + IL_DEBUG_INFO(priv, "Not ready yet, not restoring any stations.\n"); return; } - IWL_DEBUG_ASSOC(priv, "Restoring all known stations ... start.\n"); + IL_DEBUG_ASSOC(priv, "Restoring all known stations ... start.\n"); spin_lock_irqsave(&priv->sta_lock, flags_spin); for (i = 0; i < priv->hw_params.max_stations; i++) { if (ctx->ctxid != priv->stations[i].ctxid) continue; - if ((priv->stations[i].used & IWL_STA_DRIVER_ACTIVE) && - !(priv->stations[i].used & IWL_STA_UCODE_ACTIVE)) { - IWL_DEBUG_ASSOC(priv, "Restoring sta %pM\n", + if ((priv->stations[i].used & IL_STA_DRIVER_ACTIVE) && + !(priv->stations[i].used & IL_STA_UCODE_ACTIVE)) { + IL_DEBUG_ASSOC(priv, "Restoring sta %pM\n", priv->stations[i].sta.sta.addr); priv->stations[i].sta.mode = 0; - priv->stations[i].used |= IWL_STA_UCODE_INPROGRESS; + priv->stations[i].used |= IL_STA_UCODE_INPROGRESS; found = true; } } for (i = 0; i < priv->hw_params.max_stations; i++) { - if ((priv->stations[i].used & IWL_STA_UCODE_INPROGRESS)) { + if ((priv->stations[i].used & IL_STA_UCODE_INPROGRESS)) { memcpy(&sta_cmd, &priv->stations[i].sta, - sizeof(struct iwl_legacy_addsta_cmd)); + sizeof(struct il_addsta_cmd)); send_lq = false; if (priv->stations[i].lq) { memcpy(&lq, priv->stations[i].lq, - sizeof(struct iwl_link_quality_cmd)); + sizeof(struct il_link_quality_cmd)); send_lq = true; } spin_unlock_irqrestore(&priv->sta_lock, flags_spin); - ret = iwl_legacy_send_add_sta(priv, &sta_cmd, CMD_SYNC); + ret = il_send_add_sta(priv, &sta_cmd, CMD_SYNC); if (ret) { spin_lock_irqsave(&priv->sta_lock, flags_spin); - IWL_ERR(priv, "Adding station %pM failed.\n", + IL_ERR(priv, "Adding station %pM failed.\n", priv->stations[i].sta.sta.addr); priv->stations[i].used &= - ~IWL_STA_DRIVER_ACTIVE; + ~IL_STA_DRIVER_ACTIVE; priv->stations[i].used &= - ~IWL_STA_UCODE_INPROGRESS; + ~IL_STA_UCODE_INPROGRESS; spin_unlock_irqrestore(&priv->sta_lock, flags_spin); } @@ -632,24 +632,24 @@ iwl_legacy_restore_stations(struct iwl_priv *priv, struct iwl_rxon_context *ctx) * current LQ command */ if (send_lq) - iwl_legacy_send_lq_cmd(priv, ctx, &lq, + il_send_lq_cmd(priv, ctx, &lq, CMD_SYNC, true); spin_lock_irqsave(&priv->sta_lock, flags_spin); - priv->stations[i].used &= ~IWL_STA_UCODE_INPROGRESS; + priv->stations[i].used &= ~IL_STA_UCODE_INPROGRESS; } } spin_unlock_irqrestore(&priv->sta_lock, flags_spin); if (!found) - IWL_DEBUG_INFO(priv, "Restoring all known stations" + IL_DEBUG_INFO(priv, "Restoring all known stations" " .... no stations to be restored.\n"); else - IWL_DEBUG_INFO(priv, "Restoring all known stations" + IL_DEBUG_INFO(priv, "Restoring all known stations" " .... complete.\n"); } -EXPORT_SYMBOL(iwl_legacy_restore_stations); +EXPORT_SYMBOL(il_restore_stations); -int iwl_legacy_get_free_ucode_key_index(struct iwl_priv *priv) +int il_get_free_ucode_key_index(struct il_priv *priv) { int i; @@ -659,19 +659,19 @@ int iwl_legacy_get_free_ucode_key_index(struct iwl_priv *priv) return WEP_INVALID_OFFSET; } -EXPORT_SYMBOL(iwl_legacy_get_free_ucode_key_index); +EXPORT_SYMBOL(il_get_free_ucode_key_index); -void iwl_legacy_dealloc_bcast_stations(struct iwl_priv *priv) +void il_dealloc_bcast_stations(struct il_priv *priv) { unsigned long flags; int i; spin_lock_irqsave(&priv->sta_lock, flags); for (i = 0; i < priv->hw_params.max_stations; i++) { - if (!(priv->stations[i].used & IWL_STA_BCAST)) + if (!(priv->stations[i].used & IL_STA_BCAST)) continue; - priv->stations[i].used &= ~IWL_STA_UCODE_ACTIVE; + priv->stations[i].used &= ~IL_STA_UCODE_ACTIVE; priv->num_stations--; BUG_ON(priv->num_stations < 0); kfree(priv->stations[i].lq); @@ -679,31 +679,31 @@ void iwl_legacy_dealloc_bcast_stations(struct iwl_priv *priv) } spin_unlock_irqrestore(&priv->sta_lock, flags); } -EXPORT_SYMBOL_GPL(iwl_legacy_dealloc_bcast_stations); +EXPORT_SYMBOL_GPL(il_dealloc_bcast_stations); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static void iwl_legacy_dump_lq_cmd(struct iwl_priv *priv, - struct iwl_link_quality_cmd *lq) +static void il_dump_lq_cmd(struct il_priv *priv, + struct il_link_quality_cmd *lq) { int i; - IWL_DEBUG_RATE(priv, "lq station id 0x%x\n", lq->sta_id); - IWL_DEBUG_RATE(priv, "lq ant 0x%X 0x%X\n", + IL_DEBUG_RATE(priv, "lq station id 0x%x\n", lq->sta_id); + IL_DEBUG_RATE(priv, "lq ant 0x%X 0x%X\n", lq->general_params.single_stream_ant_msk, lq->general_params.dual_stream_ant_msk); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) - IWL_DEBUG_RATE(priv, "lq index %d 0x%X\n", + IL_DEBUG_RATE(priv, "lq index %d 0x%X\n", i, lq->rs_table[i].rate_n_flags); } #else -static inline void iwl_legacy_dump_lq_cmd(struct iwl_priv *priv, - struct iwl_link_quality_cmd *lq) +static inline void il_dump_lq_cmd(struct il_priv *priv, + struct il_link_quality_cmd *lq) { } #endif /** - * iwl_legacy_is_lq_table_valid() - Test one aspect of LQ cmd for validity + * il_is_lq_table_valid() - Test one aspect of LQ cmd for validity * * It sometimes happens when a HT rate has been in use and we * loose connectivity with AP then mac80211 will first tell us that the @@ -713,21 +713,21 @@ static inline void iwl_legacy_dump_lq_cmd(struct iwl_priv *priv, * Test for this to prevent driver from sending LQ command between the time * RXON flags are updated and when LQ command is updated. */ -static bool iwl_legacy_is_lq_table_valid(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, - struct iwl_link_quality_cmd *lq) +static bool il_is_lq_table_valid(struct il_priv *priv, + struct il_rxon_context *ctx, + struct il_link_quality_cmd *lq) { int i; if (ctx->ht.enabled) return true; - IWL_DEBUG_INFO(priv, "Channel %u is not an HT channel\n", + IL_DEBUG_INFO(priv, "Channel %u is not an HT channel\n", ctx->active.channel); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { if (le32_to_cpu(lq->rs_table[i].rate_n_flags) & RATE_MCS_HT_MSK) { - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "index %d of LQ expects HT channel\n", i); return false; @@ -737,7 +737,7 @@ static bool iwl_legacy_is_lq_table_valid(struct iwl_priv *priv, } /** - * iwl_legacy_send_lq_cmd() - Send link quality command + * il_send_lq_cmd() - Send link quality command * @init: This command is sent as part of station initialization right * after station has been added. * @@ -746,35 +746,35 @@ static bool iwl_legacy_is_lq_table_valid(struct iwl_priv *priv, * this case to clear the state indicating that station creation is in * progress. */ -int iwl_legacy_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx, - struct iwl_link_quality_cmd *lq, u8 flags, bool init) +int il_send_lq_cmd(struct il_priv *priv, struct il_rxon_context *ctx, + struct il_link_quality_cmd *lq, u8 flags, bool init) { int ret = 0; unsigned long flags_spin; - struct iwl_host_cmd cmd = { + struct il_host_cmd cmd = { .id = REPLY_TX_LINK_QUALITY_CMD, - .len = sizeof(struct iwl_link_quality_cmd), + .len = sizeof(struct il_link_quality_cmd), .flags = flags, .data = lq, }; - if (WARN_ON(lq->sta_id == IWL_INVALID_STATION)) + if (WARN_ON(lq->sta_id == IL_INVALID_STATION)) return -EINVAL; spin_lock_irqsave(&priv->sta_lock, flags_spin); - if (!(priv->stations[lq->sta_id].used & IWL_STA_DRIVER_ACTIVE)) { + if (!(priv->stations[lq->sta_id].used & IL_STA_DRIVER_ACTIVE)) { spin_unlock_irqrestore(&priv->sta_lock, flags_spin); return -EINVAL; } spin_unlock_irqrestore(&priv->sta_lock, flags_spin); - iwl_legacy_dump_lq_cmd(priv, lq); + il_dump_lq_cmd(priv, lq); BUG_ON(init && (cmd.flags & CMD_ASYNC)); - if (iwl_legacy_is_lq_table_valid(priv, ctx, lq)) - ret = iwl_legacy_send_cmd(priv, &cmd); + if (il_is_lq_table_valid(priv, ctx, lq)) + ret = il_send_cmd(priv, &cmd); else ret = -EINVAL; @@ -782,35 +782,35 @@ int iwl_legacy_send_lq_cmd(struct iwl_priv *priv, struct iwl_rxon_context *ctx, return ret; if (init) { - IWL_DEBUG_INFO(priv, "init LQ command complete," + IL_DEBUG_INFO(priv, "init LQ command complete," " clearing sta addition status for sta %d\n", lq->sta_id); spin_lock_irqsave(&priv->sta_lock, flags_spin); - priv->stations[lq->sta_id].used &= ~IWL_STA_UCODE_INPROGRESS; + priv->stations[lq->sta_id].used &= ~IL_STA_UCODE_INPROGRESS; spin_unlock_irqrestore(&priv->sta_lock, flags_spin); } return ret; } -EXPORT_SYMBOL(iwl_legacy_send_lq_cmd); +EXPORT_SYMBOL(il_send_lq_cmd); -int iwl_legacy_mac_sta_remove(struct ieee80211_hw *hw, +int il_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta) { - struct iwl_priv *priv = hw->priv; - struct iwl_station_priv_common *sta_common = (void *)sta->drv_priv; + struct il_priv *priv = hw->priv; + struct il_station_priv_common *sta_common = (void *)sta->drv_priv; int ret; - IWL_DEBUG_INFO(priv, "received request to remove station %pM\n", + IL_DEBUG_INFO(priv, "received request to remove station %pM\n", sta->addr); mutex_lock(&priv->mutex); - IWL_DEBUG_INFO(priv, "proceeding to remove station %pM\n", + IL_DEBUG_INFO(priv, "proceeding to remove station %pM\n", sta->addr); - ret = iwl_legacy_remove_station(priv, sta_common->sta_id, sta->addr); + ret = il_remove_station(priv, sta_common->sta_id, sta->addr); if (ret) - IWL_ERR(priv, "Error removing station %pM\n", + IL_ERR(priv, "Error removing station %pM\n", sta->addr); mutex_unlock(&priv->mutex); return ret; } -EXPORT_SYMBOL(iwl_legacy_mac_sta_remove); +EXPORT_SYMBOL(il_mac_sta_remove); diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.h b/drivers/net/wireless/iwlegacy/iwl-sta.h index 67bd75fe01a1..555b0602cea0 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.h +++ b/drivers/net/wireless/iwlegacy/iwl-sta.h @@ -26,65 +26,65 @@ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 * *****************************************************************************/ -#ifndef __iwl_legacy_sta_h__ -#define __iwl_legacy_sta_h__ +#ifndef __il_sta_h__ +#define __il_sta_h__ #include "iwl-dev.h" #define HW_KEY_DYNAMIC 0 #define HW_KEY_DEFAULT 1 -#define IWL_STA_DRIVER_ACTIVE BIT(0) /* driver entry is active */ -#define IWL_STA_UCODE_ACTIVE BIT(1) /* ucode entry is active */ -#define IWL_STA_UCODE_INPROGRESS BIT(2) /* ucode entry is in process of +#define IL_STA_DRIVER_ACTIVE BIT(0) /* driver entry is active */ +#define IL_STA_UCODE_ACTIVE BIT(1) /* ucode entry is active */ +#define IL_STA_UCODE_INPROGRESS BIT(2) /* ucode entry is in process of being activated */ -#define IWL_STA_LOCAL BIT(3) /* station state not directed by mac80211; +#define IL_STA_LOCAL BIT(3) /* station state not directed by mac80211; (this is for the IBSS BSSID stations) */ -#define IWL_STA_BCAST BIT(4) /* this station is the special bcast station */ - - -void iwl_legacy_restore_stations(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); -void iwl_legacy_clear_ucode_stations(struct iwl_priv *priv, - struct iwl_rxon_context *ctx); -void iwl_legacy_dealloc_bcast_stations(struct iwl_priv *priv); -int iwl_legacy_get_free_ucode_key_index(struct iwl_priv *priv); -int iwl_legacy_send_add_sta(struct iwl_priv *priv, - struct iwl_legacy_addsta_cmd *sta, u8 flags); -int iwl_legacy_add_station_common(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +#define IL_STA_BCAST BIT(4) /* this station is the special bcast station */ + + +void il_restore_stations(struct il_priv *priv, + struct il_rxon_context *ctx); +void il_clear_ucode_stations(struct il_priv *priv, + struct il_rxon_context *ctx); +void il_dealloc_bcast_stations(struct il_priv *priv); +int il_get_free_ucode_key_index(struct il_priv *priv); +int il_send_add_sta(struct il_priv *priv, + struct il_addsta_cmd *sta, u8 flags); +int il_add_station_common(struct il_priv *priv, + struct il_rxon_context *ctx, const u8 *addr, bool is_ap, struct ieee80211_sta *sta, u8 *sta_id_r); -int iwl_legacy_remove_station(struct iwl_priv *priv, +int il_remove_station(struct il_priv *priv, const u8 sta_id, const u8 *addr); -int iwl_legacy_mac_sta_remove(struct ieee80211_hw *hw, +int il_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta); -u8 iwl_legacy_prep_station(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, +u8 il_prep_station(struct il_priv *priv, + struct il_rxon_context *ctx, const u8 *addr, bool is_ap, struct ieee80211_sta *sta); -int iwl_legacy_send_lq_cmd(struct iwl_priv *priv, - struct iwl_rxon_context *ctx, - struct iwl_link_quality_cmd *lq, +int il_send_lq_cmd(struct il_priv *priv, + struct il_rxon_context *ctx, + struct il_link_quality_cmd *lq, u8 flags, bool init); /** - * iwl_legacy_clear_driver_stations - clear knowledge of all stations from driver + * il_clear_driver_stations - clear knowledge of all stations from driver * @priv: iwl priv struct * - * This is called during iwl_down() to make sure that in the case + * This is called during il_down() to make sure that in the case * we're coming there from a hardware restart mac80211 will be * able to reconfigure stations -- if we're getting there in the * normal down flow then the stations will already be cleared. */ -static inline void iwl_legacy_clear_driver_stations(struct iwl_priv *priv) +static inline void il_clear_driver_stations(struct il_priv *priv) { unsigned long flags; - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; spin_lock_irqsave(&priv->sta_lock, flags); memset(priv->stations, 0, sizeof(priv->stations)); @@ -107,16 +107,16 @@ static inline void iwl_legacy_clear_driver_stations(struct iwl_priv *priv) spin_unlock_irqrestore(&priv->sta_lock, flags); } -static inline int iwl_legacy_sta_id(struct ieee80211_sta *sta) +static inline int il_sta_id(struct ieee80211_sta *sta) { if (WARN_ON(!sta)) - return IWL_INVALID_STATION; + return IL_INVALID_STATION; - return ((struct iwl_station_priv_common *)sta->drv_priv)->sta_id; + return ((struct il_station_priv_common *)sta->drv_priv)->sta_id; } /** - * iwl_legacy_sta_id_or_broadcast - return sta_id or broadcast sta + * il_sta_id_or_broadcast - return sta_id or broadcast sta * @priv: iwl priv * @context: the current context * @sta: mac80211 station @@ -126,8 +126,8 @@ static inline int iwl_legacy_sta_id(struct ieee80211_sta *sta) * that case, we need to use the broadcast station, so this * inline wraps that pattern. */ -static inline int iwl_legacy_sta_id_or_broadcast(struct iwl_priv *priv, - struct iwl_rxon_context *context, +static inline int il_sta_id_or_broadcast(struct il_priv *priv, + struct il_rxon_context *context, struct ieee80211_sta *sta) { int sta_id; @@ -135,14 +135,14 @@ static inline int iwl_legacy_sta_id_or_broadcast(struct iwl_priv *priv, if (!sta) return context->bcast_sta_id; - sta_id = iwl_legacy_sta_id(sta); + sta_id = il_sta_id(sta); /* * mac80211 should not be passing a partially * initialised station! */ - WARN_ON(sta_id == IWL_INVALID_STATION); + WARN_ON(sta_id == IL_INVALID_STATION); return sta_id; } -#endif /* __iwl_legacy_sta_h__ */ +#endif /* __il_sta_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index e1a559b8630f..1c27c60c753a 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -39,10 +39,10 @@ #include "iwl-helpers.h" /** - * iwl_legacy_txq_update_write_ptr - Send new write index to hardware + * il_txq_update_write_ptr - Send new write index to hardware */ void -iwl_legacy_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq) +il_txq_update_write_ptr(struct il_priv *priv, struct il_tx_queue *txq) { u32 reg = 0; int txq_id = txq->q.id; @@ -55,18 +55,18 @@ iwl_legacy_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq) /* wake up nic if it's powered down ... * uCode will wake up, and interrupt us again, so next * time we'll skip this part. */ - reg = iwl_read32(priv, CSR_UCODE_DRV_GP1); + reg = il_read32(priv, CSR_UCODE_DRV_GP1); if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "Tx queue %d requesting wakeup," " GP1 = 0x%x\n", txq_id, reg); - iwl_legacy_set_bit(priv, CSR_GP_CNTRL, + il_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); return; } - iwl_legacy_write_direct32(priv, HBUS_TARG_WRPTR, + il_write_direct32(priv, HBUS_TARG_WRPTR, txq->q.write_ptr | (txq_id << 8)); /* @@ -75,45 +75,45 @@ iwl_legacy_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq) * trying to tx (during RFKILL, we're not trying to tx). */ } else - iwl_write32(priv, HBUS_TARG_WRPTR, + il_write32(priv, HBUS_TARG_WRPTR, txq->q.write_ptr | (txq_id << 8)); txq->need_update = 0; } -EXPORT_SYMBOL(iwl_legacy_txq_update_write_ptr); +EXPORT_SYMBOL(il_txq_update_write_ptr); /** - * iwl_legacy_tx_queue_unmap - Unmap any remaining DMA mappings and free skb's + * il_tx_queue_unmap - Unmap any remaining DMA mappings and free skb's */ -void iwl_legacy_tx_queue_unmap(struct iwl_priv *priv, int txq_id) +void il_tx_queue_unmap(struct il_priv *priv, int txq_id) { - struct iwl_tx_queue *txq = &priv->txq[txq_id]; - struct iwl_queue *q = &txq->q; + struct il_tx_queue *txq = &priv->txq[txq_id]; + struct il_queue *q = &txq->q; if (q->n_bd == 0) return; while (q->write_ptr != q->read_ptr) { priv->cfg->ops->lib->txq_free_tfd(priv, txq); - q->read_ptr = iwl_legacy_queue_inc_wrap(q->read_ptr, q->n_bd); + q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); } } -EXPORT_SYMBOL(iwl_legacy_tx_queue_unmap); +EXPORT_SYMBOL(il_tx_queue_unmap); /** - * iwl_legacy_tx_queue_free - Deallocate DMA queue. + * il_tx_queue_free - Deallocate DMA queue. * @txq: Transmit queue to deallocate. * * Empty queue by removing and destroying all BD's. * Free all buffers. * 0-fill, but do not free "txq" descriptor structure. */ -void iwl_legacy_tx_queue_free(struct iwl_priv *priv, int txq_id) +void il_tx_queue_free(struct il_priv *priv, int txq_id) { - struct iwl_tx_queue *txq = &priv->txq[txq_id]; + struct il_tx_queue *txq = &priv->txq[txq_id]; struct device *dev = &priv->pci_dev->dev; int i; - iwl_legacy_tx_queue_unmap(priv, txq_id); + il_tx_queue_unmap(priv, txq_id); /* De-alloc array of command/tx buffers */ for (i = 0; i < TFD_TX_CMD_SLOTS; i++) @@ -137,22 +137,22 @@ void iwl_legacy_tx_queue_free(struct iwl_priv *priv, int txq_id) /* 0-fill queue descriptor structure */ memset(txq, 0, sizeof(*txq)); } -EXPORT_SYMBOL(iwl_legacy_tx_queue_free); +EXPORT_SYMBOL(il_tx_queue_free); /** - * iwl_cmd_queue_unmap - Unmap any remaining DMA mappings from command queue + * il_cmd_queue_unmap - Unmap any remaining DMA mappings from command queue */ -void iwl_legacy_cmd_queue_unmap(struct iwl_priv *priv) +void il_cmd_queue_unmap(struct il_priv *priv) { - struct iwl_tx_queue *txq = &priv->txq[priv->cmd_queue]; - struct iwl_queue *q = &txq->q; + struct il_tx_queue *txq = &priv->txq[priv->cmd_queue]; + struct il_queue *q = &txq->q; int i; if (q->n_bd == 0) return; while (q->read_ptr != q->write_ptr) { - i = iwl_legacy_get_cmd_index(q, q->read_ptr, 0); + i = il_get_cmd_index(q, q->read_ptr, 0); if (txq->meta[i].flags & CMD_MAPPED) { pci_unmap_single(priv->pci_dev, @@ -162,7 +162,7 @@ void iwl_legacy_cmd_queue_unmap(struct iwl_priv *priv) txq->meta[i].flags = 0; } - q->read_ptr = iwl_legacy_queue_inc_wrap(q->read_ptr, q->n_bd); + q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); } i = q->n_window; @@ -174,23 +174,23 @@ void iwl_legacy_cmd_queue_unmap(struct iwl_priv *priv) txq->meta[i].flags = 0; } } -EXPORT_SYMBOL(iwl_legacy_cmd_queue_unmap); +EXPORT_SYMBOL(il_cmd_queue_unmap); /** - * iwl_legacy_cmd_queue_free - Deallocate DMA queue. + * il_cmd_queue_free - Deallocate DMA queue. * @txq: Transmit queue to deallocate. * * Empty queue by removing and destroying all BD's. * Free all buffers. * 0-fill, but do not free "txq" descriptor structure. */ -void iwl_legacy_cmd_queue_free(struct iwl_priv *priv) +void il_cmd_queue_free(struct il_priv *priv) { - struct iwl_tx_queue *txq = &priv->txq[priv->cmd_queue]; + struct il_tx_queue *txq = &priv->txq[priv->cmd_queue]; struct device *dev = &priv->pci_dev->dev; int i; - iwl_legacy_cmd_queue_unmap(priv); + il_cmd_queue_unmap(priv); /* De-alloc array of command/tx buffers */ for (i = 0; i <= TFD_CMD_SLOTS; i++) @@ -210,7 +210,7 @@ void iwl_legacy_cmd_queue_free(struct iwl_priv *priv) /* 0-fill queue descriptor structure */ memset(txq, 0, sizeof(*txq)); } -EXPORT_SYMBOL(iwl_legacy_cmd_queue_free); +EXPORT_SYMBOL(il_cmd_queue_free); /*************** DMA-QUEUE-GENERAL-FUNCTIONS ***** * DMA services @@ -235,7 +235,7 @@ EXPORT_SYMBOL(iwl_legacy_cmd_queue_free); * See more detailed info in iwl-4965-hw.h. ***************************************************/ -int iwl_legacy_queue_space(const struct iwl_queue *q) +int il_queue_space(const struct il_queue *q) { int s = q->read_ptr - q->write_ptr; @@ -250,25 +250,25 @@ int iwl_legacy_queue_space(const struct iwl_queue *q) s = 0; return s; } -EXPORT_SYMBOL(iwl_legacy_queue_space); +EXPORT_SYMBOL(il_queue_space); /** - * iwl_legacy_queue_init - Initialize queue's high/low-water and read/write indexes + * il_queue_init - Initialize queue's high/low-water and read/write indexes */ -static int iwl_legacy_queue_init(struct iwl_priv *priv, struct iwl_queue *q, +static int il_queue_init(struct il_priv *priv, struct il_queue *q, int count, int slots_num, u32 id) { q->n_bd = count; q->n_window = slots_num; q->id = id; - /* count must be power-of-two size, otherwise iwl_legacy_queue_inc_wrap - * and iwl_legacy_queue_dec_wrap are broken. */ + /* count must be power-of-two size, otherwise il_queue_inc_wrap + * and il_queue_dec_wrap are broken. */ BUG_ON(!is_power_of_2(count)); /* slots_num must be power-of-two size, otherwise - * iwl_legacy_get_cmd_index is broken. */ + * il_get_cmd_index is broken. */ BUG_ON(!is_power_of_2(slots_num)); q->low_mark = q->n_window / 4; @@ -285,10 +285,10 @@ static int iwl_legacy_queue_init(struct iwl_priv *priv, struct iwl_queue *q, } /** - * iwl_legacy_tx_queue_alloc - Alloc driver data and TFD CB for one Tx/cmd queue + * il_tx_queue_alloc - Alloc driver data and TFD CB for one Tx/cmd queue */ -static int iwl_legacy_tx_queue_alloc(struct iwl_priv *priv, - struct iwl_tx_queue *txq, u32 id) +static int il_tx_queue_alloc(struct il_priv *priv, + struct il_tx_queue *txq, u32 id) { struct device *dev = &priv->pci_dev->dev; size_t tfd_sz = priv->hw_params.tfd_size * TFD_QUEUE_SIZE_MAX; @@ -299,7 +299,7 @@ static int iwl_legacy_tx_queue_alloc(struct iwl_priv *priv, txq->txb = kzalloc(sizeof(txq->txb[0]) * TFD_QUEUE_SIZE_MAX, GFP_KERNEL); if (!txq->txb) { - IWL_ERR(priv, "kmalloc for auxiliary BD " + IL_ERR(priv, "kmalloc for auxiliary BD " "structures failed\n"); goto error; } @@ -312,7 +312,7 @@ static int iwl_legacy_tx_queue_alloc(struct iwl_priv *priv, txq->tfds = dma_alloc_coherent(dev, tfd_sz, &txq->q.dma_addr, GFP_KERNEL); if (!txq->tfds) { - IWL_ERR(priv, "pci_alloc_consistent(%zd) failed\n", tfd_sz); + IL_ERR(priv, "pci_alloc_consistent(%zd) failed\n", tfd_sz); goto error; } txq->q.id = id; @@ -327,9 +327,9 @@ static int iwl_legacy_tx_queue_alloc(struct iwl_priv *priv, } /** - * iwl_legacy_tx_queue_init - Allocate and initialize one tx/cmd queue + * il_tx_queue_init - Allocate and initialize one tx/cmd queue */ -int iwl_legacy_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq, +int il_tx_queue_init(struct il_priv *priv, struct il_tx_queue *txq, int slots_num, u32 txq_id) { int i, len; @@ -347,19 +347,19 @@ int iwl_legacy_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq, if (txq_id == priv->cmd_queue) actual_slots++; - txq->meta = kzalloc(sizeof(struct iwl_cmd_meta) * actual_slots, + txq->meta = kzalloc(sizeof(struct il_cmd_meta) * actual_slots, GFP_KERNEL); - txq->cmd = kzalloc(sizeof(struct iwl_device_cmd *) * actual_slots, + txq->cmd = kzalloc(sizeof(struct il_device_cmd *) * actual_slots, GFP_KERNEL); if (!txq->meta || !txq->cmd) goto out_free_arrays; - len = sizeof(struct iwl_device_cmd); + len = sizeof(struct il_device_cmd); for (i = 0; i < actual_slots; i++) { /* only happens for cmd queue */ if (i == slots_num) - len = IWL_MAX_CMD_SIZE; + len = IL_MAX_CMD_SIZE; txq->cmd[i] = kmalloc(len, GFP_KERNEL); if (!txq->cmd[i]) @@ -367,7 +367,7 @@ int iwl_legacy_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq, } /* Alloc driver data array and TFD circular buffer */ - ret = iwl_legacy_tx_queue_alloc(priv, txq, txq_id); + ret = il_tx_queue_alloc(priv, txq, txq_id); if (ret) goto err; @@ -379,14 +379,14 @@ int iwl_legacy_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq, * (if they need one at all). */ if (txq_id < 4) - iwl_legacy_set_swq_id(txq, txq_id, txq_id); + il_set_swq_id(txq, txq_id, txq_id); /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise - * iwl_legacy_queue_inc_wrap and iwl_legacy_queue_dec_wrap are broken. */ + * il_queue_inc_wrap and il_queue_dec_wrap are broken. */ BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); /* Initialize queue's high/low-water marks, and head/tail indexes */ - iwl_legacy_queue_init(priv, &txq->q, + il_queue_init(priv, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); /* Tell device where to find queue */ @@ -402,9 +402,9 @@ out_free_arrays: return -ENOMEM; } -EXPORT_SYMBOL(iwl_legacy_tx_queue_init); +EXPORT_SYMBOL(il_tx_queue_init); -void iwl_legacy_tx_queue_reset(struct iwl_priv *priv, struct iwl_tx_queue *txq, +void il_tx_queue_reset(struct il_priv *priv, struct il_tx_queue *txq, int slots_num, u32 txq_id) { int actual_slots = slots_num; @@ -412,23 +412,23 @@ void iwl_legacy_tx_queue_reset(struct iwl_priv *priv, struct iwl_tx_queue *txq, if (txq_id == priv->cmd_queue) actual_slots++; - memset(txq->meta, 0, sizeof(struct iwl_cmd_meta) * actual_slots); + memset(txq->meta, 0, sizeof(struct il_cmd_meta) * actual_slots); txq->need_update = 0; /* Initialize queue's high/low-water marks, and head/tail indexes */ - iwl_legacy_queue_init(priv, &txq->q, + il_queue_init(priv, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); /* Tell device where to find queue */ priv->cfg->ops->lib->txq_init(priv, txq); } -EXPORT_SYMBOL(iwl_legacy_tx_queue_reset); +EXPORT_SYMBOL(il_tx_queue_reset); /*************** HOST COMMAND QUEUE FUNCTIONS *****/ /** - * iwl_legacy_enqueue_hcmd - enqueue a uCode command + * il_enqueue_hcmd - enqueue a uCode command * @priv: device private data point * @cmd: a point to the ucode command structure * @@ -436,12 +436,12 @@ EXPORT_SYMBOL(iwl_legacy_tx_queue_reset); * failed. On success, it turns the index (> 0) of command in the * command queue. */ -int iwl_legacy_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) +int il_enqueue_hcmd(struct il_priv *priv, struct il_host_cmd *cmd) { - struct iwl_tx_queue *txq = &priv->txq[priv->cmd_queue]; - struct iwl_queue *q = &txq->q; - struct iwl_device_cmd *out_cmd; - struct iwl_cmd_meta *out_meta; + struct il_tx_queue *txq = &priv->txq[priv->cmd_queue]; + struct il_queue *q = &txq->q; + struct il_device_cmd *out_cmd; + struct il_cmd_meta *out_meta; dma_addr_t phys_addr; unsigned long flags; int len; @@ -458,25 +458,25 @@ int iwl_legacy_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) * of device_cmd and max_cmd_size. */ BUG_ON((fix_size > TFD_MAX_PAYLOAD_SIZE) && !(cmd->flags & CMD_SIZE_HUGE)); - BUG_ON(fix_size > IWL_MAX_CMD_SIZE); + BUG_ON(fix_size > IL_MAX_CMD_SIZE); - if (iwl_legacy_is_rfkill(priv) || iwl_legacy_is_ctkill(priv)) { - IWL_WARN(priv, "Not sending command - %s KILL\n", - iwl_legacy_is_rfkill(priv) ? "RF" : "CT"); + if (il_is_rfkill(priv) || il_is_ctkill(priv)) { + IL_WARN(priv, "Not sending command - %s KILL\n", + il_is_rfkill(priv) ? "RF" : "CT"); return -EIO; } spin_lock_irqsave(&priv->hcmd_lock, flags); - if (iwl_legacy_queue_space(q) < ((cmd->flags & CMD_ASYNC) ? 2 : 1)) { + if (il_queue_space(q) < ((cmd->flags & CMD_ASYNC) ? 2 : 1)) { spin_unlock_irqrestore(&priv->hcmd_lock, flags); - IWL_ERR(priv, "Restarting adapter due to command queue full\n"); + IL_ERR(priv, "Restarting adapter due to command queue full\n"); queue_work(priv->workqueue, &priv->restart); return -ENOSPC; } - idx = iwl_legacy_get_cmd_index(q, q->write_ptr, cmd->flags & CMD_SIZE_HUGE); + idx = il_get_cmd_index(q, q->write_ptr, cmd->flags & CMD_SIZE_HUGE); out_cmd = txq->cmd[idx]; out_meta = &txq->meta[idx]; @@ -503,26 +503,26 @@ int iwl_legacy_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) INDEX_TO_SEQ(q->write_ptr)); if (cmd->flags & CMD_SIZE_HUGE) out_cmd->hdr.sequence |= SEQ_HUGE_FRAME; - len = sizeof(struct iwl_device_cmd); + len = sizeof(struct il_device_cmd); if (idx == TFD_CMD_SLOTS) - len = IWL_MAX_CMD_SIZE; + len = IL_MAX_CMD_SIZE; #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG switch (out_cmd->hdr.cmd) { case REPLY_TX_LINK_QUALITY_CMD: case SENSITIVITY_CMD: - IWL_DEBUG_HC_DUMP(priv, + IL_DEBUG_HC_DUMP(priv, "Sending command %s (#%x), seq: 0x%04X, " "%d bytes at %d[%d]:%d\n", - iwl_legacy_get_cmd_string(out_cmd->hdr.cmd), + il_get_cmd_string(out_cmd->hdr.cmd), out_cmd->hdr.cmd, le16_to_cpu(out_cmd->hdr.sequence), fix_size, q->write_ptr, idx, priv->cmd_queue); break; default: - IWL_DEBUG_HC(priv, "Sending command %s (#%x), seq: 0x%04X, " + IL_DEBUG_HC(priv, "Sending command %s (#%x), seq: 0x%04X, " "%d bytes at %d[%d]:%d\n", - iwl_legacy_get_cmd_string(out_cmd->hdr.cmd), + il_get_cmd_string(out_cmd->hdr.cmd), out_cmd->hdr.cmd, le16_to_cpu(out_cmd->hdr.sequence), fix_size, q->write_ptr, idx, priv->cmd_queue); @@ -544,39 +544,39 @@ int iwl_legacy_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd) U32_PAD(cmd->len)); /* Increment and update queue's write index */ - q->write_ptr = iwl_legacy_queue_inc_wrap(q->write_ptr, q->n_bd); - iwl_legacy_txq_update_write_ptr(priv, txq); + q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); + il_txq_update_write_ptr(priv, txq); spin_unlock_irqrestore(&priv->hcmd_lock, flags); return idx; } /** - * iwl_legacy_hcmd_queue_reclaim - Reclaim TX command queue entries already Tx'd + * il_hcmd_queue_reclaim - Reclaim TX command queue entries already Tx'd * * When FW advances 'R' index, all entries between old and new 'R' index * need to be reclaimed. As result, some free space forms. If there is * enough free space (> low mark), wake the stack that feeds us. */ -static void iwl_legacy_hcmd_queue_reclaim(struct iwl_priv *priv, int txq_id, +static void il_hcmd_queue_reclaim(struct il_priv *priv, int txq_id, int idx, int cmd_idx) { - struct iwl_tx_queue *txq = &priv->txq[txq_id]; - struct iwl_queue *q = &txq->q; + struct il_tx_queue *txq = &priv->txq[txq_id]; + struct il_queue *q = &txq->q; int nfreed = 0; - if ((idx >= q->n_bd) || (iwl_legacy_queue_used(q, idx) == 0)) { - IWL_ERR(priv, "Read index for DMA queue txq id (%d), index %d, " + if ((idx >= q->n_bd) || (il_queue_used(q, idx) == 0)) { + IL_ERR(priv, "Read index for DMA queue txq id (%d), index %d, " "is out of range [0-%d] %d %d.\n", txq_id, idx, q->n_bd, q->write_ptr, q->read_ptr); return; } - for (idx = iwl_legacy_queue_inc_wrap(idx, q->n_bd); q->read_ptr != idx; - q->read_ptr = iwl_legacy_queue_inc_wrap(q->read_ptr, q->n_bd)) { + for (idx = il_queue_inc_wrap(idx, q->n_bd); q->read_ptr != idx; + q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { if (nfreed++ > 0) { - IWL_ERR(priv, "HCMD skipped: index (%d) %d %d\n", idx, + IL_ERR(priv, "HCMD skipped: index (%d) %d %d\n", idx, q->write_ptr, q->read_ptr); queue_work(priv->workqueue, &priv->restart); } @@ -585,7 +585,7 @@ static void iwl_legacy_hcmd_queue_reclaim(struct iwl_priv *priv, int txq_id, } /** - * iwl_legacy_tx_cmd_complete - Pull unused buffers off the queue and reclaim them + * il_tx_cmd_complete - Pull unused buffers off the queue and reclaim them * @rxb: Rx buffer to reclaim * * If an Rx buffer has an async callback associated with it the callback @@ -593,17 +593,17 @@ static void iwl_legacy_hcmd_queue_reclaim(struct iwl_priv *priv, int txq_id, * if the callback returns 1 */ void -iwl_legacy_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) +il_tx_cmd_complete(struct il_priv *priv, struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); int index = SEQ_TO_INDEX(sequence); int cmd_index; bool huge = !!(pkt->hdr.sequence & SEQ_HUGE_FRAME); - struct iwl_device_cmd *cmd; - struct iwl_cmd_meta *meta; - struct iwl_tx_queue *txq = &priv->txq[priv->cmd_queue]; + struct il_device_cmd *cmd; + struct il_cmd_meta *meta; + struct il_tx_queue *txq = &priv->txq[priv->cmd_queue]; unsigned long flags; /* If a Tx command is being handled and it isn't in the actual @@ -614,11 +614,11 @@ iwl_legacy_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) txq_id, priv->cmd_queue, sequence, priv->txq[priv->cmd_queue].q.read_ptr, priv->txq[priv->cmd_queue].q.write_ptr)) { - iwl_print_hex_error(priv, pkt, 32); + il_print_hex_error(priv, pkt, 32); return; } - cmd_index = iwl_legacy_get_cmd_index(&txq->q, index, huge); + cmd_index = il_get_cmd_index(&txq->q, index, huge); cmd = txq->cmd[cmd_index]; meta = &txq->meta[cmd_index]; @@ -638,12 +638,12 @@ iwl_legacy_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) spin_lock_irqsave(&priv->hcmd_lock, flags); - iwl_legacy_hcmd_queue_reclaim(priv, txq_id, index, cmd_index); + il_hcmd_queue_reclaim(priv, txq_id, index, cmd_index); if (!(meta->flags & CMD_ASYNC)) { clear_bit(STATUS_HCMD_ACTIVE, &priv->status); - IWL_DEBUG_INFO(priv, "Clearing HCMD_ACTIVE for command %s\n", - iwl_legacy_get_cmd_string(cmd->hdr.cmd)); + IL_DEBUG_INFO(priv, "Clearing HCMD_ACTIVE for command %s\n", + il_get_cmd_string(cmd->hdr.cmd)); wake_up(&priv->wait_command_queue); } @@ -652,4 +652,4 @@ iwl_legacy_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) spin_unlock_irqrestore(&priv->hcmd_lock, flags); } -EXPORT_SYMBOL(iwl_legacy_tx_cmd_complete); +EXPORT_SYMBOL(il_tx_cmd_complete); diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 7507819a25ad..d24937a0014a 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -89,7 +89,7 @@ MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); MODULE_LICENSE("GPL"); /* module parameters */ -struct iwl_mod_params iwl3945_mod_params = { +struct il_mod_params il3945_mod_params = { .sw_crypto = 1, .restart_fw = 1, .disable_hw_scan = 1, @@ -97,43 +97,43 @@ struct iwl_mod_params iwl3945_mod_params = { }; /** - * iwl3945_get_antenna_flags - Get antenna flags for RXON command + * il3945_get_antenna_flags - Get antenna flags for RXON command * @priv: eeprom and antenna fields are used to determine antenna flags * * priv->eeprom39 is used to determine if antenna AUX/MAIN are reversed - * iwl3945_mod_params.antenna specifies the antenna diversity mode: + * il3945_mod_params.antenna specifies the antenna diversity mode: * - * IWL_ANTENNA_DIVERSITY - NIC selects best antenna by itself - * IWL_ANTENNA_MAIN - Force MAIN antenna - * IWL_ANTENNA_AUX - Force AUX antenna + * IL_ANTENNA_DIVERSITY - NIC selects best antenna by itself + * IL_ANTENNA_MAIN - Force MAIN antenna + * IL_ANTENNA_AUX - Force AUX antenna */ -__le32 iwl3945_get_antenna_flags(const struct iwl_priv *priv) +__le32 il3945_get_antenna_flags(const struct il_priv *priv) { - struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; - switch (iwl3945_mod_params.antenna) { - case IWL_ANTENNA_DIVERSITY: + switch (il3945_mod_params.antenna) { + case IL_ANTENNA_DIVERSITY: return 0; - case IWL_ANTENNA_MAIN: + case IL_ANTENNA_MAIN: if (eeprom->antenna_switch_type) return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_B_MSK; return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_A_MSK; - case IWL_ANTENNA_AUX: + case IL_ANTENNA_AUX: if (eeprom->antenna_switch_type) return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_A_MSK; return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_B_MSK; } /* bad antenna selector value */ - IWL_ERR(priv, "Bad antenna selector value (0x%x)\n", - iwl3945_mod_params.antenna); + IL_ERR(priv, "Bad antenna selector value (0x%x)\n", + il3945_mod_params.antenna); return 0; /* "diversity" is default if error */ } -static int iwl3945_set_ccmp_dynamic_key_info(struct iwl_priv *priv, +static int il3945_set_ccmp_dynamic_key_info(struct il_priv *priv, struct ieee80211_key_conf *keyconf, u8 sta_id) { @@ -144,7 +144,7 @@ static int iwl3945_set_ccmp_dynamic_key_info(struct iwl_priv *priv, key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK); key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); - if (sta_id == priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id) + if (sta_id == priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id) key_flags |= STA_KEY_MULTICAST_MSK; keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; @@ -163,7 +163,7 @@ static int iwl3945_set_ccmp_dynamic_key_info(struct iwl_priv *priv, if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) priv->stations[sta_id].sta.key.key_offset = - iwl_legacy_get_free_ucode_key_index(priv); + il_get_free_ucode_key_index(priv); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ @@ -174,9 +174,9 @@ static int iwl3945_set_ccmp_dynamic_key_info(struct iwl_priv *priv, priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - IWL_DEBUG_INFO(priv, "hwcrypto: modify ucode station key info\n"); + IL_DEBUG_INFO(priv, "hwcrypto: modify ucode station key info\n"); - ret = iwl_legacy_send_add_sta(priv, + ret = il_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); spin_unlock_irqrestore(&priv->sta_lock, flags); @@ -184,40 +184,40 @@ static int iwl3945_set_ccmp_dynamic_key_info(struct iwl_priv *priv, return ret; } -static int iwl3945_set_tkip_dynamic_key_info(struct iwl_priv *priv, +static int il3945_set_tkip_dynamic_key_info(struct il_priv *priv, struct ieee80211_key_conf *keyconf, u8 sta_id) { return -EOPNOTSUPP; } -static int iwl3945_set_wep_dynamic_key_info(struct iwl_priv *priv, +static int il3945_set_wep_dynamic_key_info(struct il_priv *priv, struct ieee80211_key_conf *keyconf, u8 sta_id) { return -EOPNOTSUPP; } -static int iwl3945_clear_sta_key_info(struct iwl_priv *priv, u8 sta_id) +static int il3945_clear_sta_key_info(struct il_priv *priv, u8 sta_id) { unsigned long flags; - struct iwl_legacy_addsta_cmd sta_cmd; + struct il_addsta_cmd sta_cmd; spin_lock_irqsave(&priv->sta_lock, flags); - memset(&priv->stations[sta_id].keyinfo, 0, sizeof(struct iwl_hw_key)); + memset(&priv->stations[sta_id].keyinfo, 0, sizeof(struct il_hw_key)); memset(&priv->stations[sta_id].sta.key, 0, - sizeof(struct iwl4965_keyinfo)); + sizeof(struct il4965_keyinfo)); priv->stations[sta_id].sta.key.key_flags = STA_KEY_FLG_NO_ENC; priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(struct iwl_legacy_addsta_cmd)); + memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&priv->sta_lock, flags); - IWL_DEBUG_INFO(priv, "hwcrypto: clear ucode station key info\n"); - return iwl_legacy_send_add_sta(priv, &sta_cmd, CMD_SYNC); + IL_DEBUG_INFO(priv, "hwcrypto: clear ucode station key info\n"); + return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); } -static int iwl3945_set_dynamic_key(struct iwl_priv *priv, +static int il3945_set_dynamic_key(struct il_priv *priv, struct ieee80211_key_conf *keyconf, u8 sta_id) { int ret = 0; @@ -226,75 +226,75 @@ static int iwl3945_set_dynamic_key(struct iwl_priv *priv, switch (keyconf->cipher) { case WLAN_CIPHER_SUITE_CCMP: - ret = iwl3945_set_ccmp_dynamic_key_info(priv, keyconf, sta_id); + ret = il3945_set_ccmp_dynamic_key_info(priv, keyconf, sta_id); break; case WLAN_CIPHER_SUITE_TKIP: - ret = iwl3945_set_tkip_dynamic_key_info(priv, keyconf, sta_id); + ret = il3945_set_tkip_dynamic_key_info(priv, keyconf, sta_id); break; case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP104: - ret = iwl3945_set_wep_dynamic_key_info(priv, keyconf, sta_id); + ret = il3945_set_wep_dynamic_key_info(priv, keyconf, sta_id); break; default: - IWL_ERR(priv, "Unknown alg: %s alg=%x\n", __func__, + IL_ERR(priv, "Unknown alg: %s alg=%x\n", __func__, keyconf->cipher); ret = -EINVAL; } - IWL_DEBUG_WEP(priv, "Set dynamic key: alg=%x len=%d idx=%d sta=%d ret=%d\n", + IL_DEBUG_WEP(priv, "Set dynamic key: alg=%x len=%d idx=%d sta=%d ret=%d\n", keyconf->cipher, keyconf->keylen, keyconf->keyidx, sta_id, ret); return ret; } -static int iwl3945_remove_static_key(struct iwl_priv *priv) +static int il3945_remove_static_key(struct il_priv *priv) { int ret = -EOPNOTSUPP; return ret; } -static int iwl3945_set_static_key(struct iwl_priv *priv, +static int il3945_set_static_key(struct il_priv *priv, struct ieee80211_key_conf *key) { if (key->cipher == WLAN_CIPHER_SUITE_WEP40 || key->cipher == WLAN_CIPHER_SUITE_WEP104) return -EOPNOTSUPP; - IWL_ERR(priv, "Static key invalid: cipher %x\n", key->cipher); + IL_ERR(priv, "Static key invalid: cipher %x\n", key->cipher); return -EINVAL; } -static void iwl3945_clear_free_frames(struct iwl_priv *priv) +static void il3945_clear_free_frames(struct il_priv *priv) { struct list_head *element; - IWL_DEBUG_INFO(priv, "%d frames on pre-allocated heap on clear.\n", + IL_DEBUG_INFO(priv, "%d frames on pre-allocated heap on clear.\n", priv->frames_count); while (!list_empty(&priv->free_frames)) { element = priv->free_frames.next; list_del(element); - kfree(list_entry(element, struct iwl3945_frame, list)); + kfree(list_entry(element, struct il3945_frame, list)); priv->frames_count--; } if (priv->frames_count) { - IWL_WARN(priv, "%d frames still in use. Did we lose one?\n", + IL_WARN(priv, "%d frames still in use. Did we lose one?\n", priv->frames_count); priv->frames_count = 0; } } -static struct iwl3945_frame *iwl3945_get_free_frame(struct iwl_priv *priv) +static struct il3945_frame *il3945_get_free_frame(struct il_priv *priv) { - struct iwl3945_frame *frame; + struct il3945_frame *frame; struct list_head *element; if (list_empty(&priv->free_frames)) { frame = kzalloc(sizeof(*frame), GFP_KERNEL); if (!frame) { - IWL_ERR(priv, "Could not allocate frame!\n"); + IL_ERR(priv, "Could not allocate frame!\n"); return NULL; } @@ -304,21 +304,21 @@ static struct iwl3945_frame *iwl3945_get_free_frame(struct iwl_priv *priv) element = priv->free_frames.next; list_del(element); - return list_entry(element, struct iwl3945_frame, list); + return list_entry(element, struct il3945_frame, list); } -static void iwl3945_free_frame(struct iwl_priv *priv, struct iwl3945_frame *frame) +static void il3945_free_frame(struct il_priv *priv, struct il3945_frame *frame) { memset(frame, 0, sizeof(*frame)); list_add(&frame->list, &priv->free_frames); } -unsigned int iwl3945_fill_beacon_frame(struct iwl_priv *priv, +unsigned int il3945_fill_beacon_frame(struct il_priv *priv, struct ieee80211_hdr *hdr, int left) { - if (!iwl_legacy_is_associated(priv, IWL_RXON_CTX_BSS) || !priv->beacon_skb) + if (!il_is_associated(priv, IL_RXON_CTX_BSS) || !priv->beacon_skb) return 0; if (priv->beacon_skb->len > left) @@ -329,51 +329,51 @@ unsigned int iwl3945_fill_beacon_frame(struct iwl_priv *priv, return priv->beacon_skb->len; } -static int iwl3945_send_beacon_cmd(struct iwl_priv *priv) +static int il3945_send_beacon_cmd(struct il_priv *priv) { - struct iwl3945_frame *frame; + struct il3945_frame *frame; unsigned int frame_size; int rc; u8 rate; - frame = iwl3945_get_free_frame(priv); + frame = il3945_get_free_frame(priv); if (!frame) { - IWL_ERR(priv, "Could not obtain free frame buffer for beacon " + IL_ERR(priv, "Could not obtain free frame buffer for beacon " "command.\n"); return -ENOMEM; } - rate = iwl_legacy_get_lowest_plcp(priv, - &priv->contexts[IWL_RXON_CTX_BSS]); + rate = il_get_lowest_plcp(priv, + &priv->contexts[IL_RXON_CTX_BSS]); - frame_size = iwl3945_hw_get_beacon_cmd(priv, frame, rate); + frame_size = il3945_hw_get_beacon_cmd(priv, frame, rate); - rc = iwl_legacy_send_cmd_pdu(priv, REPLY_TX_BEACON, frame_size, + rc = il_send_cmd_pdu(priv, REPLY_TX_BEACON, frame_size, &frame->u.cmd[0]); - iwl3945_free_frame(priv, frame); + il3945_free_frame(priv, frame); return rc; } -static void iwl3945_unset_hw_params(struct iwl_priv *priv) +static void il3945_unset_hw_params(struct il_priv *priv) { if (priv->_3945.shared_virt) dma_free_coherent(&priv->pci_dev->dev, - sizeof(struct iwl3945_shared), + sizeof(struct il3945_shared), priv->_3945.shared_virt, priv->_3945.shared_phys); } -static void iwl3945_build_tx_cmd_hwcrypto(struct iwl_priv *priv, +static void il3945_build_tx_cmd_hwcrypto(struct il_priv *priv, struct ieee80211_tx_info *info, - struct iwl_device_cmd *cmd, + struct il_device_cmd *cmd, struct sk_buff *skb_frag, int sta_id) { - struct iwl3945_tx_cmd *tx_cmd = (struct iwl3945_tx_cmd *)cmd->cmd.payload; - struct iwl_hw_key *keyinfo = &priv->stations[sta_id].keyinfo; + struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; + struct il_hw_key *keyinfo = &priv->stations[sta_id].keyinfo; tx_cmd->sec_ctl = 0; @@ -381,7 +381,7 @@ static void iwl3945_build_tx_cmd_hwcrypto(struct iwl_priv *priv, case WLAN_CIPHER_SUITE_CCMP: tx_cmd->sec_ctl = TX_CMD_SEC_CCM; memcpy(tx_cmd->key, keyinfo->key, keyinfo->keylen); - IWL_DEBUG_TX(priv, "tx_cmd with AES hwcrypto\n"); + IL_DEBUG_TX(priv, "tx_cmd with AES hwcrypto\n"); break; case WLAN_CIPHER_SUITE_TKIP: @@ -396,12 +396,12 @@ static void iwl3945_build_tx_cmd_hwcrypto(struct iwl_priv *priv, memcpy(&tx_cmd->key[3], keyinfo->key, keyinfo->keylen); - IWL_DEBUG_TX(priv, "Configuring packet for WEP encryption " + IL_DEBUG_TX(priv, "Configuring packet for WEP encryption " "with key %d\n", info->control.hw_key->hw_key_idx); break; default: - IWL_ERR(priv, "Unknown encode cipher %x\n", keyinfo->cipher); + IL_ERR(priv, "Unknown encode cipher %x\n", keyinfo->cipher); break; } } @@ -409,12 +409,12 @@ static void iwl3945_build_tx_cmd_hwcrypto(struct iwl_priv *priv, /* * handle build REPLY_TX command notification. */ -static void iwl3945_build_tx_cmd_basic(struct iwl_priv *priv, - struct iwl_device_cmd *cmd, +static void il3945_build_tx_cmd_basic(struct il_priv *priv, + struct il_device_cmd *cmd, struct ieee80211_tx_info *info, struct ieee80211_hdr *hdr, u8 std_id) { - struct iwl3945_tx_cmd *tx_cmd = (struct iwl3945_tx_cmd *)cmd->cmd.payload; + struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; __le32 tx_flags = tx_cmd->tx_flags; __le16 fc = hdr->frame_control; @@ -443,7 +443,7 @@ static void iwl3945_build_tx_cmd_basic(struct iwl_priv *priv, tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; } - iwl_legacy_tx_cmd_protection(priv, info, fc, &tx_flags); + il_tx_cmd_protection(priv, info, fc, &tx_flags); tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); if (ieee80211_is_mgmt(fc)) { @@ -463,15 +463,15 @@ static void iwl3945_build_tx_cmd_basic(struct iwl_priv *priv, /* * start REPLY_TX command process */ -static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) +static int il3945_tx_skb(struct il_priv *priv, struct sk_buff *skb) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - struct iwl3945_tx_cmd *tx_cmd; - struct iwl_tx_queue *txq = NULL; - struct iwl_queue *q = NULL; - struct iwl_device_cmd *out_cmd; - struct iwl_cmd_meta *out_meta; + struct il3945_tx_cmd *tx_cmd; + struct il_tx_queue *txq = NULL; + struct il_queue *q = NULL; + struct il_device_cmd *out_cmd; + struct il_cmd_meta *out_meta; dma_addr_t phys_addr; dma_addr_t txcmd_phys; int txq_id = skb_get_queue_mapping(skb); @@ -485,13 +485,13 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) unsigned long flags; spin_lock_irqsave(&priv->lock, flags); - if (iwl_legacy_is_rfkill(priv)) { - IWL_DEBUG_DROP(priv, "Dropping - RF KILL\n"); + if (il_is_rfkill(priv)) { + IL_DEBUG_DROP(priv, "Dropping - RF KILL\n"); goto drop_unlock; } - if ((ieee80211_get_tx_rate(priv->hw, info)->hw_value & 0xFF) == IWL_INVALID_RATE) { - IWL_ERR(priv, "ERROR: No TX rate available.\n"); + if ((ieee80211_get_tx_rate(priv->hw, info)->hw_value & 0xFF) == IL_INVALID_RATE) { + IL_ERR(priv, "ERROR: No TX rate available.\n"); goto drop_unlock; } @@ -502,11 +502,11 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG if (ieee80211_is_auth(fc)) - IWL_DEBUG_TX(priv, "Sending AUTH frame\n"); + IL_DEBUG_TX(priv, "Sending AUTH frame\n"); else if (ieee80211_is_assoc_req(fc)) - IWL_DEBUG_TX(priv, "Sending ASSOC frame\n"); + IL_DEBUG_TX(priv, "Sending ASSOC frame\n"); else if (ieee80211_is_reassoc_req(fc)) - IWL_DEBUG_TX(priv, "Sending REASSOC frame\n"); + IL_DEBUG_TX(priv, "Sending REASSOC frame\n"); #endif spin_unlock_irqrestore(&priv->lock, flags); @@ -514,16 +514,16 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) hdr_len = ieee80211_hdrlen(fc); /* Find index into station table for destination station */ - sta_id = iwl_legacy_sta_id_or_broadcast( - priv, &priv->contexts[IWL_RXON_CTX_BSS], + sta_id = il_sta_id_or_broadcast( + priv, &priv->contexts[IL_RXON_CTX_BSS], info->control.sta); - if (sta_id == IWL_INVALID_STATION) { - IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", + if (sta_id == IL_INVALID_STATION) { + IL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", hdr->addr1); goto drop; } - IWL_DEBUG_RATE(priv, "station Id %d\n", sta_id); + IL_DEBUG_RATE(priv, "station Id %d\n", sta_id); if (ieee80211_is_data_qos(fc)) { u8 *qc = ieee80211_get_qos_ctl(hdr); @@ -536,22 +536,22 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) txq = &priv->txq[txq_id]; q = &txq->q; - if ((iwl_legacy_queue_space(q) < q->high_mark)) + if ((il_queue_space(q) < q->high_mark)) goto drop; spin_lock_irqsave(&priv->lock, flags); - idx = iwl_legacy_get_cmd_index(q, q->write_ptr, 0); + idx = il_get_cmd_index(q, q->write_ptr, 0); /* Set up driver data for this TFD */ - memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct iwl_tx_info)); + memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct il_tx_info)); txq->txb[q->write_ptr].skb = skb; - txq->txb[q->write_ptr].ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + txq->txb[q->write_ptr].ctx = &priv->contexts[IL_RXON_CTX_BSS]; /* Init first empty entry in queue's array of Tx/cmd buffers */ out_cmd = txq->cmd[idx]; out_meta = &txq->meta[idx]; - tx_cmd = (struct iwl3945_tx_cmd *)out_cmd->cmd.payload; + tx_cmd = (struct il3945_tx_cmd *)out_cmd->cmd.payload; memset(&out_cmd->hdr, 0, sizeof(out_cmd->hdr)); memset(tx_cmd, 0, sizeof(*tx_cmd)); @@ -570,20 +570,20 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) if (info->control.hw_key) - iwl3945_build_tx_cmd_hwcrypto(priv, info, out_cmd, skb, sta_id); + il3945_build_tx_cmd_hwcrypto(priv, info, out_cmd, skb, sta_id); /* TODO need this for burst mode later on */ - iwl3945_build_tx_cmd_basic(priv, out_cmd, info, hdr, sta_id); + il3945_build_tx_cmd_basic(priv, out_cmd, info, hdr, sta_id); /* set is_hcca to 0; it probably will never be implemented */ - iwl3945_hw_build_tx_cmd_rate(priv, out_cmd, info, hdr, sta_id, 0); + il3945_hw_build_tx_cmd_rate(priv, out_cmd, info, hdr, sta_id, 0); /* Total # bytes to be transmitted */ len = (u16)skb->len; tx_cmd->len = cpu_to_le16(len); - iwl_legacy_dbg_log_tx_data_frame(priv, len, hdr); - iwl_legacy_update_stats(priv, true, fc, len); + il_dbg_log_tx_data_frame(priv, len, hdr); + il_update_stats(priv, true, fc, len); tx_cmd->tx_flags &= ~TX_CMD_FLG_ANT_A_MSK; tx_cmd->tx_flags &= ~TX_CMD_FLG_ANT_B_MSK; @@ -594,11 +594,11 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) txq->need_update = 0; } - IWL_DEBUG_TX(priv, "sequence nr = 0X%x\n", + IL_DEBUG_TX(priv, "sequence nr = 0X%x\n", le16_to_cpu(out_cmd->hdr.sequence)); - IWL_DEBUG_TX(priv, "tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); - iwl_print_hex_dump(priv, IWL_DL_TX, tx_cmd, sizeof(*tx_cmd)); - iwl_print_hex_dump(priv, IWL_DL_TX, (u8 *)tx_cmd->hdr, + IL_DEBUG_TX(priv, "tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); + il_print_hex_dump(priv, IL_DL_TX, tx_cmd, sizeof(*tx_cmd)); + il_print_hex_dump(priv, IL_DL_TX, (u8 *)tx_cmd->hdr, ieee80211_hdrlen(fc)); /* @@ -610,8 +610,8 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) * of the MAC header (device reads on dword boundaries). * We'll tell device about this padding later. */ - len = sizeof(struct iwl3945_tx_cmd) + - sizeof(struct iwl_cmd_header) + hdr_len; + len = sizeof(struct il3945_tx_cmd) + + sizeof(struct il_cmd_header) + hdr_len; len = (len + 3) & ~3; /* Physical address of this Tx command's header (not MAC header!), @@ -642,20 +642,20 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) /* Tell device the write index *just past* this latest filled TFD */ - q->write_ptr = iwl_legacy_queue_inc_wrap(q->write_ptr, q->n_bd); - iwl_legacy_txq_update_write_ptr(priv, txq); + q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); + il_txq_update_write_ptr(priv, txq); spin_unlock_irqrestore(&priv->lock, flags); - if ((iwl_legacy_queue_space(q) < q->high_mark) + if ((il_queue_space(q) < q->high_mark) && priv->mac80211_registered) { if (wait_write_ptr) { spin_lock_irqsave(&priv->lock, flags); txq->need_update = 1; - iwl_legacy_txq_update_write_ptr(priv, txq); + il_txq_update_write_ptr(priv, txq); spin_unlock_irqrestore(&priv->lock, flags); } - iwl_legacy_stop_queue(priv, txq); + il_stop_queue(priv, txq); } return 0; @@ -666,13 +666,13 @@ drop: return -1; } -static int iwl3945_get_measurement(struct iwl_priv *priv, +static int il3945_get_measurement(struct il_priv *priv, struct ieee80211_measurement_params *params, u8 type) { - struct iwl_spectrum_cmd spectrum; - struct iwl_rx_packet *pkt; - struct iwl_host_cmd cmd = { + struct il_spectrum_cmd spectrum; + struct il_rx_packet *pkt; + struct il_host_cmd cmd = { .id = REPLY_SPECTRUM_MEASUREMENT_CMD, .data = (void *)&spectrum, .flags = CMD_WANT_SKB, @@ -681,10 +681,10 @@ static int iwl3945_get_measurement(struct iwl_priv *priv, int rc; int spectrum_resp_status; int duration = le16_to_cpu(params->duration); - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; - if (iwl_legacy_is_associated(priv, IWL_RXON_CTX_BSS)) - add_time = iwl_legacy_usecs_to_beacons(priv, + if (il_is_associated(priv, IL_RXON_CTX_BSS)) + add_time = il_usecs_to_beacons(priv, le64_to_cpu(params->start_time) - priv->_3945.last_tsf, le16_to_cpu(ctx->timing.beacon_interval)); @@ -697,9 +697,9 @@ static int iwl3945_get_measurement(struct iwl_priv *priv, cmd.len = sizeof(spectrum); spectrum.len = cpu_to_le16(cmd.len - sizeof(spectrum.len)); - if (iwl_legacy_is_associated(priv, IWL_RXON_CTX_BSS)) + if (il_is_associated(priv, IL_RXON_CTX_BSS)) spectrum.start_time = - iwl_legacy_add_beacon_time(priv, + il_add_beacon_time(priv, priv->_3945.last_beacon_time, add_time, le16_to_cpu(ctx->timing.beacon_interval)); else @@ -712,13 +712,13 @@ static int iwl3945_get_measurement(struct iwl_priv *priv, spectrum.flags |= RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_TGG_PROTECT_MSK; - rc = iwl_legacy_send_cmd_sync(priv, &cmd); + rc = il_send_cmd_sync(priv, &cmd); if (rc) return rc; - pkt = (struct iwl_rx_packet *)cmd.reply_page; - if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) { - IWL_ERR(priv, "Bad return from REPLY_RX_ON_ASSOC command\n"); + pkt = (struct il_rx_packet *)cmd.reply_page; + if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { + IL_ERR(priv, "Bad return from REPLY_RX_ON_ASSOC command\n"); rc = -EIO; } @@ -726,7 +726,7 @@ static int iwl3945_get_measurement(struct iwl_priv *priv, switch (spectrum_resp_status) { case 0: /* Command will be handled */ if (pkt->u.spectrum.id != 0xff) { - IWL_DEBUG_INFO(priv, "Replaced existing measurement: %d\n", + IL_DEBUG_INFO(priv, "Replaced existing measurement: %d\n", pkt->u.spectrum.id); priv->measurement_status &= ~MEASUREMENT_READY; } @@ -739,36 +739,36 @@ static int iwl3945_get_measurement(struct iwl_priv *priv, break; } - iwl_legacy_free_pages(priv, cmd.reply_page); + il_free_pages(priv, cmd.reply_page); return rc; } -static void iwl3945_rx_reply_alive(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il3945_rx_reply_alive(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_alive_resp *palive; + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_alive_resp *palive; struct delayed_work *pwork; palive = &pkt->u.alive_frame; - IWL_DEBUG_INFO(priv, "Alive ucode status 0x%08X revision " + IL_DEBUG_INFO(priv, "Alive ucode status 0x%08X revision " "0x%01X 0x%01X\n", palive->is_valid, palive->ver_type, palive->ver_subtype); if (palive->ver_subtype == INITIALIZE_SUBTYPE) { - IWL_DEBUG_INFO(priv, "Initialization Alive received.\n"); + IL_DEBUG_INFO(priv, "Initialization Alive received.\n"); memcpy(&priv->card_alive_init, &pkt->u.alive_frame, - sizeof(struct iwl_alive_resp)); + sizeof(struct il_alive_resp)); pwork = &priv->init_alive_start; } else { - IWL_DEBUG_INFO(priv, "Runtime Alive received.\n"); + IL_DEBUG_INFO(priv, "Runtime Alive received.\n"); memcpy(&priv->card_alive, &pkt->u.alive_frame, - sizeof(struct iwl_alive_resp)); + sizeof(struct il_alive_resp)); pwork = &priv->alive_start; - iwl3945_disable_events(priv); + il3945_disable_events(priv); } /* We delay the ALIVE response by 5ms to @@ -777,28 +777,28 @@ static void iwl3945_rx_reply_alive(struct iwl_priv *priv, queue_delayed_work(priv->workqueue, pwork, msecs_to_jiffies(5)); else - IWL_WARN(priv, "uCode did not respond OK.\n"); + IL_WARN(priv, "uCode did not respond OK.\n"); } -static void iwl3945_rx_reply_add_sta(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il3945_rx_reply_add_sta(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); #endif - IWL_DEBUG_RX(priv, "Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); + IL_DEBUG_RX(priv, "Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); } -static void iwl3945_rx_beacon_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il3945_rx_beacon_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl3945_beacon_notif *beacon = &(pkt->u.beacon_status); + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il3945_beacon_notif *beacon = &(pkt->u.beacon_status); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG u8 rate = beacon->beacon_notify_hdr.rate; - IWL_DEBUG_RX(priv, "beacon status %x retries %d iss %d " + IL_DEBUG_RX(priv, "beacon status %x retries %d iss %d " "tsf %d %d rate %d\n", le32_to_cpu(beacon->beacon_notify_hdr.status) & TX_STATUS_MSK, beacon->beacon_notify_hdr.failure_frame, @@ -813,18 +813,18 @@ static void iwl3945_rx_beacon_notif(struct iwl_priv *priv, /* Handle notification from uCode that card's power state is changing * due to software, hardware, or critical temperature RFKILL */ -static void iwl3945_rx_card_state_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il3945_rx_card_state_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); unsigned long status = priv->status; - IWL_WARN(priv, "Card state received: HW:%s SW:%s\n", + IL_WARN(priv, "Card state received: HW:%s SW:%s\n", (flags & HW_CARD_DISABLED) ? "Kill" : "On", (flags & SW_CARD_DISABLED) ? "Kill" : "On"); - iwl_write32(priv, CSR_UCODE_DRV_GP1_SET, + il_write32(priv, CSR_UCODE_DRV_GP1_SET, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); if (flags & HW_CARD_DISABLED) @@ -833,7 +833,7 @@ static void iwl3945_rx_card_state_notif(struct iwl_priv *priv, clear_bit(STATUS_RF_KILL_HW, &priv->status); - iwl_legacy_scan_cancel(priv); + il_scan_cancel(priv); if ((test_bit(STATUS_RF_KILL_HW, &status) != test_bit(STATUS_RF_KILL_HW, &priv->status))) @@ -844,7 +844,7 @@ static void iwl3945_rx_card_state_notif(struct iwl_priv *priv, } /** - * iwl3945_setup_rx_handlers - Initialize Rx handler callbacks + * il3945_setup_rx_handlers - Initialize Rx handler callbacks * * Setup the RX handlers for each of the reply types sent from the uCode * to the host. @@ -852,32 +852,32 @@ static void iwl3945_rx_card_state_notif(struct iwl_priv *priv, * This function chains into the hardware specific files for them to setup * any hardware specific handlers as well. */ -static void iwl3945_setup_rx_handlers(struct iwl_priv *priv) +static void il3945_setup_rx_handlers(struct il_priv *priv) { - priv->rx_handlers[REPLY_ALIVE] = iwl3945_rx_reply_alive; - priv->rx_handlers[REPLY_ADD_STA] = iwl3945_rx_reply_add_sta; - priv->rx_handlers[REPLY_ERROR] = iwl_legacy_rx_reply_error; - priv->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = iwl_legacy_rx_csa; + priv->rx_handlers[REPLY_ALIVE] = il3945_rx_reply_alive; + priv->rx_handlers[REPLY_ADD_STA] = il3945_rx_reply_add_sta; + priv->rx_handlers[REPLY_ERROR] = il_rx_reply_error; + priv->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa; priv->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = - iwl_legacy_rx_spectrum_measure_notif; - priv->rx_handlers[PM_SLEEP_NOTIFICATION] = iwl_legacy_rx_pm_sleep_notif; + il_rx_spectrum_measure_notif; + priv->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; priv->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = - iwl_legacy_rx_pm_debug_statistics_notif; - priv->rx_handlers[BEACON_NOTIFICATION] = iwl3945_rx_beacon_notif; + il_rx_pm_debug_statistics_notif; + priv->rx_handlers[BEACON_NOTIFICATION] = il3945_rx_beacon_notif; /* * The same handler is used for both the REPLY to a discrete * statistics request from the host as well as for the periodic * statistics notifications (after received beacons) from the uCode. */ - priv->rx_handlers[REPLY_STATISTICS_CMD] = iwl3945_reply_statistics; - priv->rx_handlers[STATISTICS_NOTIFICATION] = iwl3945_hw_rx_statistics; + priv->rx_handlers[REPLY_STATISTICS_CMD] = il3945_reply_statistics; + priv->rx_handlers[STATISTICS_NOTIFICATION] = il3945_hw_rx_statistics; - iwl_legacy_setup_rx_scan_handlers(priv); - priv->rx_handlers[CARD_STATE_NOTIFICATION] = iwl3945_rx_card_state_notif; + il_setup_rx_scan_handlers(priv); + priv->rx_handlers[CARD_STATE_NOTIFICATION] = il3945_rx_card_state_notif; /* Set up hardware specific Rx handlers */ - iwl3945_hw_rx_handler_setup(priv); + il3945_hw_rx_handler_setup(priv); } /************************** RX-FUNCTIONS ****************************/ @@ -885,7 +885,7 @@ static void iwl3945_setup_rx_handlers(struct iwl_priv *priv) * Rx theory of operation * * The host allocates 32 DMA target addresses and passes the host address - * to the firmware at register IWL_RFDS_TABLE_LOWER + N * RFD_SIZE where N is + * to the firmware at register IL_RFDS_TABLE_LOWER + N * RFD_SIZE where N is * 0 to 31 * * Rx Queue Indexes @@ -914,7 +914,7 @@ static void iwl3945_setup_rx_handlers(struct iwl_priv *priv) * + A list of pre-allocated SKBs is stored in iwl->rxq->rx_free. When * iwl->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled * to replenish the iwl->rxq->rx_free. - * + In iwl3945_rx_replenish (scheduled) if 'processed' != 'read' then the + * + In il3945_rx_replenish (scheduled) if 'processed' != 'read' then the * iwl->rxq is replenished and the READ INDEX is updated (updating the * 'processed' and 'read' driver indexes as well) * + A received packet is processed and handed to the kernel network stack, @@ -927,34 +927,34 @@ static void iwl3945_setup_rx_handlers(struct iwl_priv *priv) * * Driver sequence: * - * iwl3945_rx_replenish() Replenishes rx_free list from rx_used, and calls - * iwl3945_rx_queue_restock - * iwl3945_rx_queue_restock() Moves available buffers from rx_free into Rx + * il3945_rx_replenish() Replenishes rx_free list from rx_used, and calls + * il3945_rx_queue_restock + * il3945_rx_queue_restock() Moves available buffers from rx_free into Rx * queue, updates firmware pointers, and updates * the WRITE index. If insufficient rx_free buffers - * are available, schedules iwl3945_rx_replenish + * are available, schedules il3945_rx_replenish * * -- enable interrupts -- - * ISR - iwl3945_rx() Detach iwl_rx_mem_buffers from pool up to the + * ISR - il3945_rx() Detach il_rx_mem_buffers from pool up to the * READ INDEX, detaching the SKB from the pool. * Moves the packet buffer from queue to rx_used. - * Calls iwl3945_rx_queue_restock to refill any empty + * Calls il3945_rx_queue_restock to refill any empty * slots. * ... * */ /** - * iwl3945_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr + * il3945_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr */ -static inline __le32 iwl3945_dma_addr2rbd_ptr(struct iwl_priv *priv, +static inline __le32 il3945_dma_addr2rbd_ptr(struct il_priv *priv, dma_addr_t dma_addr) { return cpu_to_le32((u32)dma_addr); } /** - * iwl3945_rx_queue_restock - refill RX queue from pre-allocated pool + * il3945_rx_queue_restock - refill RX queue from pre-allocated pool * * If there are slots in the RX queue that need to be restocked, * and we have free pre-allocated buffers, fill the ranks as much @@ -964,24 +964,24 @@ static inline __le32 iwl3945_dma_addr2rbd_ptr(struct iwl_priv *priv, * also updates the memory address in the firmware to reference the new * target buffer. */ -static void iwl3945_rx_queue_restock(struct iwl_priv *priv) +static void il3945_rx_queue_restock(struct il_priv *priv) { - struct iwl_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &priv->rxq; struct list_head *element; - struct iwl_rx_mem_buffer *rxb; + struct il_rx_mem_buffer *rxb; unsigned long flags; int write; spin_lock_irqsave(&rxq->lock, flags); write = rxq->write & ~0x7; - while ((iwl_legacy_rx_queue_space(rxq) > 0) && (rxq->free_count)) { + while ((il_rx_queue_space(rxq) > 0) && (rxq->free_count)) { /* Get next free Rx buffer, remove from free list */ element = rxq->rx_free.next; - rxb = list_entry(element, struct iwl_rx_mem_buffer, list); + rxb = list_entry(element, struct il_rx_mem_buffer, list); list_del(element); /* Point to Rx buffer via next RBD in circular buffer */ - rxq->bd[rxq->write] = iwl3945_dma_addr2rbd_ptr(priv, rxb->page_dma); + rxq->bd[rxq->write] = il3945_dma_addr2rbd_ptr(priv, rxb->page_dma); rxq->queue[rxq->write] = rxb; rxq->write = (rxq->write + 1) & RX_QUEUE_MASK; rxq->free_count--; @@ -1000,23 +1000,23 @@ static void iwl3945_rx_queue_restock(struct iwl_priv *priv) spin_lock_irqsave(&rxq->lock, flags); rxq->need_update = 1; spin_unlock_irqrestore(&rxq->lock, flags); - iwl_legacy_rx_queue_update_write_ptr(priv, rxq); + il_rx_queue_update_write_ptr(priv, rxq); } } /** - * iwl3945_rx_replenish - Move all used packet from rx_used to rx_free + * il3945_rx_replenish - Move all used packet from rx_used to rx_free * * When moving to rx_free an SKB is allocated for the slot. * - * Also restock the Rx queue via iwl3945_rx_queue_restock. + * Also restock the Rx queue via il3945_rx_queue_restock. * This is called as a scheduled work item (except for during initialization) */ -static void iwl3945_rx_allocate(struct iwl_priv *priv, gfp_t priority) +static void il3945_rx_allocate(struct il_priv *priv, gfp_t priority) { - struct iwl_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &priv->rxq; struct list_head *element; - struct iwl_rx_mem_buffer *rxb; + struct il_rx_mem_buffer *rxb; struct page *page; unsigned long flags; gfp_t gfp_mask = priority; @@ -1040,10 +1040,10 @@ static void iwl3945_rx_allocate(struct iwl_priv *priv, gfp_t priority) page = alloc_pages(gfp_mask, priv->hw_params.rx_page_order); if (!page) { if (net_ratelimit()) - IWL_DEBUG_INFO(priv, "Failed to allocate SKB buffer.\n"); + IL_DEBUG_INFO(priv, "Failed to allocate SKB buffer.\n"); if ((rxq->free_count <= RX_LOW_WATERMARK) && net_ratelimit()) - IWL_CRIT(priv, "Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", + IL_CRIT(priv, "Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", priority == GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL", rxq->free_count); /* We don't reschedule replenish work here -- we will @@ -1059,7 +1059,7 @@ static void iwl3945_rx_allocate(struct iwl_priv *priv, gfp_t priority) return; } element = rxq->rx_used.next; - rxb = list_entry(element, struct iwl_rx_mem_buffer, list); + rxb = list_entry(element, struct il_rx_mem_buffer, list); list_del(element); spin_unlock_irqrestore(&rxq->lock, flags); @@ -1079,7 +1079,7 @@ static void iwl3945_rx_allocate(struct iwl_priv *priv, gfp_t priority) } } -void iwl3945_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq) +void il3945_rx_queue_reset(struct il_priv *priv, struct il_rx_queue *rxq) { unsigned long flags; int i; @@ -1094,7 +1094,7 @@ void iwl3945_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq) pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, PAGE_SIZE << priv->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); - __iwl_legacy_free_pages(priv, rxq->pool[i].page); + __il_free_pages(priv, rxq->pool[i].page); rxq->pool[i].page = NULL; } list_add_tail(&rxq->pool[i].list, &rxq->rx_used); @@ -1108,23 +1108,23 @@ void iwl3945_rx_queue_reset(struct iwl_priv *priv, struct iwl_rx_queue *rxq) spin_unlock_irqrestore(&rxq->lock, flags); } -void iwl3945_rx_replenish(void *data) +void il3945_rx_replenish(void *data) { - struct iwl_priv *priv = data; + struct il_priv *priv = data; unsigned long flags; - iwl3945_rx_allocate(priv, GFP_KERNEL); + il3945_rx_allocate(priv, GFP_KERNEL); spin_lock_irqsave(&priv->lock, flags); - iwl3945_rx_queue_restock(priv); + il3945_rx_queue_restock(priv); spin_unlock_irqrestore(&priv->lock, flags); } -static void iwl3945_rx_replenish_now(struct iwl_priv *priv) +static void il3945_rx_replenish_now(struct il_priv *priv) { - iwl3945_rx_allocate(priv, GFP_ATOMIC); + il3945_rx_allocate(priv, GFP_ATOMIC); - iwl3945_rx_queue_restock(priv); + il3945_rx_queue_restock(priv); } @@ -1133,7 +1133,7 @@ static void iwl3945_rx_replenish_now(struct iwl_priv *priv) * This free routine walks the list of POOL entries and if SKB is set to * non NULL it is unmapped and freed */ -static void iwl3945_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rxq) +static void il3945_rx_queue_free(struct il_priv *priv, struct il_rx_queue *rxq) { int i; for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { @@ -1141,14 +1141,14 @@ static void iwl3945_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rx pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, PAGE_SIZE << priv->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); - __iwl_legacy_free_pages(priv, rxq->pool[i].page); + __il_free_pages(priv, rxq->pool[i].page); rxq->pool[i].page = NULL; } } dma_free_coherent(&priv->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, rxq->bd_dma); - dma_free_coherent(&priv->pci_dev->dev, sizeof(struct iwl_rb_status), + dma_free_coherent(&priv->pci_dev->dev, sizeof(struct il_rb_status), rxq->rb_stts, rxq->rb_stts_dma); rxq->bd = NULL; rxq->rb_stts = NULL; @@ -1173,7 +1173,7 @@ static u8 ratio2dB[100] = { /* Calculates a relative dB value from a ratio of linear * (i.e. not dB) signal levels. * Conversion assumes that levels are voltages (20*log), not powers (10*log). */ -int iwl3945_calc_db_from_ratio(int sig_ratio) +int il3945_calc_db_from_ratio(int sig_ratio) { /* 1000:1 or higher just report as 60 dB */ if (sig_ratio >= 1000) @@ -1193,17 +1193,17 @@ int iwl3945_calc_db_from_ratio(int sig_ratio) } /** - * iwl3945_rx_handle - Main entry function for receiving responses from uCode + * il3945_rx_handle - Main entry function for receiving responses from uCode * * Uses the priv->rx_handlers callback function array to invoke * the appropriate handlers, including command responses, * frame-received notifications, and other notifications. */ -static void iwl3945_rx_handle(struct iwl_priv *priv) +static void il3945_rx_handle(struct il_priv *priv) { - struct iwl_rx_mem_buffer *rxb; - struct iwl_rx_packet *pkt; - struct iwl_rx_queue *rxq = &priv->rxq; + struct il_rx_mem_buffer *rxb; + struct il_rx_packet *pkt; + struct il_rx_queue *rxq = &priv->rxq; u32 r, i; int reclaim; unsigned long flags; @@ -1225,7 +1225,7 @@ static void iwl3945_rx_handle(struct iwl_priv *priv) fill_rx = 1; /* Rx interrupt, but nothing sent from uCode */ if (i == r) - IWL_DEBUG_RX(priv, "r = %d, i = %d\n", r, i); + IL_DEBUG_RX(priv, "r = %d, i = %d\n", r, i); while (i != r) { int len; @@ -1259,17 +1259,17 @@ static void iwl3945_rx_handle(struct iwl_priv *priv) /* Based on type of command response or notification, * handle those that need handling via function in - * rx_handlers table. See iwl3945_setup_rx_handlers() */ + * rx_handlers table. See il3945_setup_rx_handlers() */ if (priv->rx_handlers[pkt->hdr.cmd]) { - IWL_DEBUG_RX(priv, "r = %d, i = %d, %s, 0x%02x\n", r, i, - iwl_legacy_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); + IL_DEBUG_RX(priv, "r = %d, i = %d, %s, 0x%02x\n", r, i, + il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); priv->isr_stats.rx_handlers[pkt->hdr.cmd]++; priv->rx_handlers[pkt->hdr.cmd] (priv, rxb); } else { /* No handling needed */ - IWL_DEBUG_RX(priv, + IL_DEBUG_RX(priv, "r %d i %d No handler needed for %s, 0x%02x\n", - r, i, iwl_legacy_get_cmd_string(pkt->hdr.cmd), + r, i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); } @@ -1282,12 +1282,12 @@ static void iwl3945_rx_handle(struct iwl_priv *priv) if (reclaim) { /* Invoke any callbacks, transfer the buffer to caller, - * and fire off the (possibly) blocking iwl_legacy_send_cmd() + * and fire off the (possibly) blocking il_send_cmd() * as we reclaim the driver command queue */ if (rxb->page) - iwl_legacy_tx_cmd_complete(priv, rxb); + il_tx_cmd_complete(priv, rxb); else - IWL_WARN(priv, "Claim null rxb?\n"); + IL_WARN(priv, "Claim null rxb?\n"); } /* Reuse the page if possible. For notification packets and @@ -1312,7 +1312,7 @@ static void iwl3945_rx_handle(struct iwl_priv *priv) count++; if (count >= 8) { rxq->read = i; - iwl3945_rx_replenish_now(priv); + il3945_rx_replenish_now(priv); count = 0; } } @@ -1321,20 +1321,20 @@ static void iwl3945_rx_handle(struct iwl_priv *priv) /* Backtrack one entry */ rxq->read = i; if (fill_rx) - iwl3945_rx_replenish_now(priv); + il3945_rx_replenish_now(priv); else - iwl3945_rx_queue_restock(priv); + il3945_rx_queue_restock(priv); } /* call this function to flush any scheduled tasklet */ -static inline void iwl3945_synchronize_irq(struct iwl_priv *priv) +static inline void il3945_synchronize_irq(struct il_priv *priv) { /* wait to make sure we flush pending tasklet*/ synchronize_irq(priv->pci_dev->irq); tasklet_kill(&priv->irq_tasklet); } -static const char *iwl3945_desc_lookup(int i) +static const char *il3945_desc_lookup(int i) { switch (i) { case 1: @@ -1357,7 +1357,7 @@ static const char *iwl3945_desc_lookup(int i) #define ERROR_START_OFFSET (1 * sizeof(u32)) #define ERROR_ELEM_SIZE (7 * sizeof(u32)) -void iwl3945_dump_nic_error_log(struct iwl_priv *priv) +void il3945_dump_nic_error_log(struct il_priv *priv) { u32 i; u32 desc, time, count, base, data1; @@ -1365,47 +1365,47 @@ void iwl3945_dump_nic_error_log(struct iwl_priv *priv) base = le32_to_cpu(priv->card_alive.error_event_table_ptr); - if (!iwl3945_hw_valid_rtc_data_addr(base)) { - IWL_ERR(priv, "Not valid error log pointer 0x%08X\n", base); + if (!il3945_hw_valid_rtc_data_addr(base)) { + IL_ERR(priv, "Not valid error log pointer 0x%08X\n", base); return; } - count = iwl_legacy_read_targ_mem(priv, base); + count = il_read_targ_mem(priv, base); if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { - IWL_ERR(priv, "Start IWL Error Log Dump:\n"); - IWL_ERR(priv, "Status: 0x%08lX, count: %d\n", + IL_ERR(priv, "Start IWL Error Log Dump:\n"); + IL_ERR(priv, "Status: 0x%08lX, count: %d\n", priv->status, count); } - IWL_ERR(priv, "Desc Time asrtPC blink2 " + IL_ERR(priv, "Desc Time asrtPC blink2 " "ilink1 nmiPC Line\n"); for (i = ERROR_START_OFFSET; i < (count * ERROR_ELEM_SIZE) + ERROR_START_OFFSET; i += ERROR_ELEM_SIZE) { - desc = iwl_legacy_read_targ_mem(priv, base + i); + desc = il_read_targ_mem(priv, base + i); time = - iwl_legacy_read_targ_mem(priv, base + i + 1 * sizeof(u32)); + il_read_targ_mem(priv, base + i + 1 * sizeof(u32)); blink1 = - iwl_legacy_read_targ_mem(priv, base + i + 2 * sizeof(u32)); + il_read_targ_mem(priv, base + i + 2 * sizeof(u32)); blink2 = - iwl_legacy_read_targ_mem(priv, base + i + 3 * sizeof(u32)); + il_read_targ_mem(priv, base + i + 3 * sizeof(u32)); ilink1 = - iwl_legacy_read_targ_mem(priv, base + i + 4 * sizeof(u32)); + il_read_targ_mem(priv, base + i + 4 * sizeof(u32)); ilink2 = - iwl_legacy_read_targ_mem(priv, base + i + 5 * sizeof(u32)); + il_read_targ_mem(priv, base + i + 5 * sizeof(u32)); data1 = - iwl_legacy_read_targ_mem(priv, base + i + 6 * sizeof(u32)); + il_read_targ_mem(priv, base + i + 6 * sizeof(u32)); - IWL_ERR(priv, + IL_ERR(priv, "%-13s (0x%X) %010u 0x%05X 0x%05X 0x%05X 0x%05X %u\n\n", - iwl3945_desc_lookup(desc), desc, time, blink1, blink2, + il3945_desc_lookup(desc), desc, time, blink1, blink2, ilink1, ilink2, data1); } } -static void iwl3945_irq_tasklet(struct iwl_priv *priv) +static void il3945_irq_tasklet(struct il_priv *priv) { u32 inta, handled = 0; u32 inta_fh; @@ -1419,20 +1419,20 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv) /* Ack/clear/reset pending uCode interrupts. * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS, * and will clear only when CSR_FH_INT_STATUS gets cleared. */ - inta = iwl_read32(priv, CSR_INT); - iwl_write32(priv, CSR_INT, inta); + inta = il_read32(priv, CSR_INT); + il_write32(priv, CSR_INT, inta); /* Ack/clear/reset pending flow-handler (DMA) interrupts. * Any new interrupts that happen after this, either while we're * in this tasklet, or later, will show up in next ISR/tasklet. */ - inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS); - iwl_write32(priv, CSR_FH_INT_STATUS, inta_fh); + inta_fh = il_read32(priv, CSR_FH_INT_STATUS); + il_write32(priv, CSR_FH_INT_STATUS, inta_fh); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (iwl_legacy_get_debug_level(priv) & IWL_DL_ISR) { + if (il_get_debug_level(priv) & IL_DL_ISR) { /* just for debug */ - inta_mask = iwl_read32(priv, CSR_INT_MASK); - IWL_DEBUG_ISR(priv, "inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", + inta_mask = il_read32(priv, CSR_INT_MASK); + IL_DEBUG_ISR(priv, "inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, inta_mask, inta_fh); } #endif @@ -1450,13 +1450,13 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv) /* Now service all interrupt bits discovered above. */ if (inta & CSR_INT_BIT_HW_ERR) { - IWL_ERR(priv, "Hardware error detected. Restarting.\n"); + IL_ERR(priv, "Hardware error detected. Restarting.\n"); /* Tell the device to stop sending interrupts */ - iwl_legacy_disable_interrupts(priv); + il_disable_interrupts(priv); priv->isr_stats.hw++; - iwl_legacy_irq_handle_error(priv); + il_irq_handle_error(priv); handled |= CSR_INT_BIT_HW_ERR; @@ -1464,17 +1464,17 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv) } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (iwl_legacy_get_debug_level(priv) & (IWL_DL_ISR)) { + if (il_get_debug_level(priv) & (IL_DL_ISR)) { /* NIC fires this, but we don't use it, redundant with WAKEUP */ if (inta & CSR_INT_BIT_SCD) { - IWL_DEBUG_ISR(priv, "Scheduler finished to transmit " + IL_DEBUG_ISR(priv, "Scheduler finished to transmit " "the frame/frames.\n"); priv->isr_stats.sch++; } /* Alive notification via Rx interrupt will do the real work */ if (inta & CSR_INT_BIT_ALIVE) { - IWL_DEBUG_ISR(priv, "Alive interrupt\n"); + IL_DEBUG_ISR(priv, "Alive interrupt\n"); priv->isr_stats.alive++; } } @@ -1484,23 +1484,23 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv) /* Error detected by uCode */ if (inta & CSR_INT_BIT_SW_ERR) { - IWL_ERR(priv, "Microcode SW error detected. " + IL_ERR(priv, "Microcode SW error detected. " "Restarting 0x%X.\n", inta); priv->isr_stats.sw++; - iwl_legacy_irq_handle_error(priv); + il_irq_handle_error(priv); handled |= CSR_INT_BIT_SW_ERR; } /* uCode wakes up after power-down sleep */ if (inta & CSR_INT_BIT_WAKEUP) { - IWL_DEBUG_ISR(priv, "Wakeup interrupt\n"); - iwl_legacy_rx_queue_update_write_ptr(priv, &priv->rxq); - iwl_legacy_txq_update_write_ptr(priv, &priv->txq[0]); - iwl_legacy_txq_update_write_ptr(priv, &priv->txq[1]); - iwl_legacy_txq_update_write_ptr(priv, &priv->txq[2]); - iwl_legacy_txq_update_write_ptr(priv, &priv->txq[3]); - iwl_legacy_txq_update_write_ptr(priv, &priv->txq[4]); - iwl_legacy_txq_update_write_ptr(priv, &priv->txq[5]); + IL_DEBUG_ISR(priv, "Wakeup interrupt\n"); + il_rx_queue_update_write_ptr(priv, &priv->rxq); + il_txq_update_write_ptr(priv, &priv->txq[0]); + il_txq_update_write_ptr(priv, &priv->txq[1]); + il_txq_update_write_ptr(priv, &priv->txq[2]); + il_txq_update_write_ptr(priv, &priv->txq[3]); + il_txq_update_write_ptr(priv, &priv->txq[4]); + il_txq_update_write_ptr(priv, &priv->txq[5]); priv->isr_stats.wakeup++; handled |= CSR_INT_BIT_WAKEUP; @@ -1510,67 +1510,67 @@ static void iwl3945_irq_tasklet(struct iwl_priv *priv) * Rx "responses" (frame-received notification), and other * notifications from uCode come through here*/ if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) { - iwl3945_rx_handle(priv); + il3945_rx_handle(priv); priv->isr_stats.rx++; handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX); } if (inta & CSR_INT_BIT_FH_TX) { - IWL_DEBUG_ISR(priv, "Tx interrupt\n"); + IL_DEBUG_ISR(priv, "Tx interrupt\n"); priv->isr_stats.tx++; - iwl_write32(priv, CSR_FH_INT_STATUS, (1 << 6)); - iwl_legacy_write_direct32(priv, FH39_TCSR_CREDIT + il_write32(priv, CSR_FH_INT_STATUS, (1 << 6)); + il_write_direct32(priv, FH39_TCSR_CREDIT (FH39_SRVC_CHNL), 0x0); handled |= CSR_INT_BIT_FH_TX; } if (inta & ~handled) { - IWL_ERR(priv, "Unhandled INTA bits 0x%08x\n", inta & ~handled); + IL_ERR(priv, "Unhandled INTA bits 0x%08x\n", inta & ~handled); priv->isr_stats.unhandled++; } if (inta & ~priv->inta_mask) { - IWL_WARN(priv, "Disabled INTA bits 0x%08x were pending\n", + IL_WARN(priv, "Disabled INTA bits 0x%08x were pending\n", inta & ~priv->inta_mask); - IWL_WARN(priv, " with FH_INT = 0x%08x\n", inta_fh); + IL_WARN(priv, " with FH_INT = 0x%08x\n", inta_fh); } /* Re-enable all interrupts */ /* only Re-enable if disabled by irq */ if (test_bit(STATUS_INT_ENABLED, &priv->status)) - iwl_legacy_enable_interrupts(priv); + il_enable_interrupts(priv); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (iwl_legacy_get_debug_level(priv) & (IWL_DL_ISR)) { - inta = iwl_read32(priv, CSR_INT); - inta_mask = iwl_read32(priv, CSR_INT_MASK); - inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS); - IWL_DEBUG_ISR(priv, "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " + if (il_get_debug_level(priv) & (IL_DL_ISR)) { + inta = il_read32(priv, CSR_INT); + inta_mask = il_read32(priv, CSR_INT_MASK); + inta_fh = il_read32(priv, CSR_FH_INT_STATUS); + IL_DEBUG_ISR(priv, "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); } #endif } -static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, +static int il3945_get_channels_for_scan(struct il_priv *priv, enum ieee80211_band band, u8 is_active, u8 n_probes, - struct iwl3945_scan_channel *scan_ch, + struct il3945_scan_channel *scan_ch, struct ieee80211_vif *vif) { struct ieee80211_channel *chan; const struct ieee80211_supported_band *sband; - const struct iwl_channel_info *ch_info; + const struct il_channel_info *ch_info; u16 passive_dwell = 0; u16 active_dwell = 0; int added, i; - sband = iwl_get_hw_mode(priv, band); + sband = il_get_hw_mode(priv, band); if (!sband) return 0; - active_dwell = iwl_legacy_get_active_dwell_time(priv, band, n_probes); - passive_dwell = iwl_legacy_get_passive_dwell_time(priv, band, vif); + active_dwell = il_get_active_dwell_time(priv, band, n_probes); + passive_dwell = il_get_passive_dwell_time(priv, band, vif); if (passive_dwell <= active_dwell) passive_dwell = active_dwell + 1; @@ -1583,10 +1583,10 @@ static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, scan_ch->channel = chan->hw_value; - ch_info = iwl_legacy_get_channel_info(priv, band, + ch_info = il_get_channel_info(priv, band, scan_ch->channel); - if (!iwl_legacy_is_channel_valid(ch_info)) { - IWL_DEBUG_SCAN(priv, + if (!il_is_channel_valid(ch_info)) { + IL_DEBUG_SCAN(priv, "Channel %d is INVALID for this band.\n", scan_ch->channel); continue; @@ -1597,10 +1597,10 @@ static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, /* If passive , set up for auto-switch * and use long active_dwell time. */ - if (!is_active || iwl_legacy_is_channel_passive(ch_info) || + if (!is_active || il_is_channel_passive(ch_info) || (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)) { scan_ch->type = 0; /* passive */ - if (IWL_UCODE_API(priv->ucode_ver) == 1) + if (IL_UCODE_API(priv->ucode_ver) == 1) scan_ch->active_dwell = cpu_to_le16(passive_dwell - 1); } else { scan_ch->type = 1; /* active */ @@ -1610,7 +1610,7 @@ static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, * scan channels (probes gets sent right away), * or for passive channels (probes get se sent only after * hearing clear Rx packet).*/ - if (IWL_UCODE_API(priv->ucode_ver) >= 2) { + if (IL_UCODE_API(priv->ucode_ver) >= 2) { if (n_probes) scan_ch->type |= IWL39_SCAN_PROBE_MASK(n_probes); } else { @@ -1635,7 +1635,7 @@ static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, */ } - IWL_DEBUG_SCAN(priv, "Scanning %d [%s %d]\n", + IL_DEBUG_SCAN(priv, "Scanning %d [%s %d]\n", scan_ch->channel, (scan_ch->type & 1) ? "ACTIVE" : "PASSIVE", (scan_ch->type & 1) ? @@ -1645,25 +1645,25 @@ static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, added++; } - IWL_DEBUG_SCAN(priv, "total channels to scan %d\n", added); + IL_DEBUG_SCAN(priv, "total channels to scan %d\n", added); return added; } -static void iwl3945_init_hw_rates(struct iwl_priv *priv, +static void il3945_init_hw_rates(struct il_priv *priv, struct ieee80211_rate *rates) { int i; - for (i = 0; i < IWL_RATE_COUNT_LEGACY; i++) { - rates[i].bitrate = iwl3945_rates[i].ieee * 5; + for (i = 0; i < IL_RATE_COUNT_LEGACY; i++) { + rates[i].bitrate = il3945_rates[i].ieee * 5; rates[i].hw_value = i; /* Rate scaling will work on indexes */ rates[i].hw_value_short = i; rates[i].flags = 0; - if ((i > IWL39_LAST_OFDM_RATE) || (i < IWL_FIRST_OFDM_RATE)) { + if ((i > IWL39_LAST_OFDM_RATE) || (i < IL_FIRST_OFDM_RATE)) { /* * If CCK != 1M then set short preamble rate flag. */ - rates[i].flags |= (iwl3945_rates[i].plcp == 10) ? + rates[i].flags |= (il3945_rates[i].plcp == 10) ? 0 : IEEE80211_RATE_SHORT_PREAMBLE; } } @@ -1675,40 +1675,40 @@ static void iwl3945_init_hw_rates(struct iwl_priv *priv, * ******************************************************************************/ -static void iwl3945_dealloc_ucode_pci(struct iwl_priv *priv) +static void il3945_dealloc_ucode_pci(struct il_priv *priv) { - iwl_legacy_free_fw_desc(priv->pci_dev, &priv->ucode_code); - iwl_legacy_free_fw_desc(priv->pci_dev, &priv->ucode_data); - iwl_legacy_free_fw_desc(priv->pci_dev, &priv->ucode_data_backup); - iwl_legacy_free_fw_desc(priv->pci_dev, &priv->ucode_init); - iwl_legacy_free_fw_desc(priv->pci_dev, &priv->ucode_init_data); - iwl_legacy_free_fw_desc(priv->pci_dev, &priv->ucode_boot); + il_free_fw_desc(priv->pci_dev, &priv->ucode_code); + il_free_fw_desc(priv->pci_dev, &priv->ucode_data); + il_free_fw_desc(priv->pci_dev, &priv->ucode_data_backup); + il_free_fw_desc(priv->pci_dev, &priv->ucode_init); + il_free_fw_desc(priv->pci_dev, &priv->ucode_init_data); + il_free_fw_desc(priv->pci_dev, &priv->ucode_boot); } /** - * iwl3945_verify_inst_full - verify runtime uCode image in card vs. host, + * il3945_verify_inst_full - verify runtime uCode image in card vs. host, * looking at all data. */ -static int iwl3945_verify_inst_full(struct iwl_priv *priv, __le32 *image, u32 len) +static int il3945_verify_inst_full(struct il_priv *priv, __le32 *image, u32 len) { u32 val; u32 save_len = len; int rc = 0; u32 errcnt; - IWL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); + IL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); - iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_RADDR, + il_write_direct32(priv, HBUS_TARG_MEM_RADDR, IWL39_RTC_INST_LOWER_BOUND); errcnt = 0; for (; len > 0; len -= sizeof(u32), image++) { /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log - * if IWL_DL_IO is set */ - val = _iwl_legacy_read_direct32(priv, HBUS_TARG_MEM_RDAT); + * if IL_DL_IO is set */ + val = _il_read_direct32(priv, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { - IWL_ERR(priv, "uCode INST section is invalid at " + IL_ERR(priv, "uCode INST section is invalid at " "offset 0x%x, is 0x%x, s/b 0x%x\n", save_len - len, val, le32_to_cpu(*image)); rc = -EIO; @@ -1720,7 +1720,7 @@ static int iwl3945_verify_inst_full(struct iwl_priv *priv, __le32 *image, u32 le if (!errcnt) - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "ucode image in INSTRUCTION memory is good\n"); return rc; @@ -1728,29 +1728,29 @@ static int iwl3945_verify_inst_full(struct iwl_priv *priv, __le32 *image, u32 le /** - * iwl3945_verify_inst_sparse - verify runtime uCode image in card vs. host, + * il3945_verify_inst_sparse - verify runtime uCode image in card vs. host, * using sample data 100 bytes apart. If these sample points are good, * it's a pretty good bet that everything between them is good, too. */ -static int iwl3945_verify_inst_sparse(struct iwl_priv *priv, __le32 *image, u32 len) +static int il3945_verify_inst_sparse(struct il_priv *priv, __le32 *image, u32 len) { u32 val; int rc = 0; u32 errcnt = 0; u32 i; - IWL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); + IL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log - * if IWL_DL_IO is set */ - iwl_legacy_write_direct32(priv, HBUS_TARG_MEM_RADDR, + * if IL_DL_IO is set */ + il_write_direct32(priv, HBUS_TARG_MEM_RADDR, i + IWL39_RTC_INST_LOWER_BOUND); - val = _iwl_legacy_read_direct32(priv, HBUS_TARG_MEM_RDAT); + val = _il_read_direct32(priv, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { #if 0 /* Enable this if you want to see details */ - IWL_ERR(priv, "uCode INST section is invalid at " + IL_ERR(priv, "uCode INST section is invalid at " "offset 0x%x, is 0x%x, s/b 0x%x\n", i, val, *image); #endif @@ -1766,10 +1766,10 @@ static int iwl3945_verify_inst_sparse(struct iwl_priv *priv, __le32 *image, u32 /** - * iwl3945_verify_ucode - determine which instruction image is in SRAM, + * il3945_verify_ucode - determine which instruction image is in SRAM, * and verify its contents */ -static int iwl3945_verify_ucode(struct iwl_priv *priv) +static int il3945_verify_ucode(struct il_priv *priv) { __le32 *image; u32 len; @@ -1778,60 +1778,60 @@ static int iwl3945_verify_ucode(struct iwl_priv *priv) /* Try bootstrap */ image = (__le32 *)priv->ucode_boot.v_addr; len = priv->ucode_boot.len; - rc = iwl3945_verify_inst_sparse(priv, image, len); + rc = il3945_verify_inst_sparse(priv, image, len); if (rc == 0) { - IWL_DEBUG_INFO(priv, "Bootstrap uCode is good in inst SRAM\n"); + IL_DEBUG_INFO(priv, "Bootstrap uCode is good in inst SRAM\n"); return 0; } /* Try initialize */ image = (__le32 *)priv->ucode_init.v_addr; len = priv->ucode_init.len; - rc = iwl3945_verify_inst_sparse(priv, image, len); + rc = il3945_verify_inst_sparse(priv, image, len); if (rc == 0) { - IWL_DEBUG_INFO(priv, "Initialize uCode is good in inst SRAM\n"); + IL_DEBUG_INFO(priv, "Initialize uCode is good in inst SRAM\n"); return 0; } /* Try runtime/protocol */ image = (__le32 *)priv->ucode_code.v_addr; len = priv->ucode_code.len; - rc = iwl3945_verify_inst_sparse(priv, image, len); + rc = il3945_verify_inst_sparse(priv, image, len); if (rc == 0) { - IWL_DEBUG_INFO(priv, "Runtime uCode is good in inst SRAM\n"); + IL_DEBUG_INFO(priv, "Runtime uCode is good in inst SRAM\n"); return 0; } - IWL_ERR(priv, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); + IL_ERR(priv, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); /* Since nothing seems to match, show first several data entries in * instruction SRAM, so maybe visual inspection will give a clue. * Selection of bootstrap image (vs. other images) is arbitrary. */ image = (__le32 *)priv->ucode_boot.v_addr; len = priv->ucode_boot.len; - rc = iwl3945_verify_inst_full(priv, image, len); + rc = il3945_verify_inst_full(priv, image, len); return rc; } -static void iwl3945_nic_start(struct iwl_priv *priv) +static void il3945_nic_start(struct il_priv *priv) { /* Remove all resets to allow NIC to operate */ - iwl_write32(priv, CSR_RESET, 0); + il_write32(priv, CSR_RESET, 0); } #define IWL3945_UCODE_GET(item) \ -static u32 iwl3945_ucode_get_##item(const struct iwl_ucode_header *ucode)\ +static u32 il3945_ucode_get_##item(const struct il_ucode_header *ucode)\ { \ return le32_to_cpu(ucode->v1.item); \ } -static u32 iwl3945_ucode_get_header_size(u32 api_ver) +static u32 il3945_ucode_get_header_size(u32 api_ver) { return 24; } -static u8 *iwl3945_ucode_get_data(const struct iwl_ucode_header *ucode) +static u8 *il3945_ucode_get_data(const struct il_ucode_header *ucode) { return (u8 *) ucode->v1.data; } @@ -1843,13 +1843,13 @@ IWL3945_UCODE_GET(init_data_size); IWL3945_UCODE_GET(boot_size); /** - * iwl3945_read_ucode - Read uCode images from disk file. + * il3945_read_ucode - Read uCode images from disk file. * * Copy into buffers for card to fetch via bus-mastering */ -static int iwl3945_read_ucode(struct iwl_priv *priv) +static int il3945_read_ucode(struct il_priv *priv) { - const struct iwl_ucode_header *ucode; + const struct il_ucode_header *ucode; int ret = -EINVAL, index; const struct firmware *ucode_raw; /* firmware file name contains uCode/driver compatibility version */ @@ -1867,7 +1867,7 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) sprintf(buf, "%s%u%s", name_pre, index, ".ucode"); ret = request_firmware(&ucode_raw, buf, &priv->pci_dev->dev); if (ret < 0) { - IWL_ERR(priv, "%s firmware file req failed: %d\n", + IL_ERR(priv, "%s firmware file req failed: %d\n", buf, ret); if (ret == -ENOENT) continue; @@ -1875,11 +1875,11 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) goto error; } else { if (index < api_max) - IWL_ERR(priv, "Loaded firmware %s, " + IL_ERR(priv, "Loaded firmware %s, " "which is deprecated. " " Please use API v%u instead.\n", buf, api_max); - IWL_DEBUG_INFO(priv, "Got firmware '%s' file " + IL_DEBUG_INFO(priv, "Got firmware '%s' file " "(%zd bytes) from disk\n", buf, ucode_raw->size); break; @@ -1890,30 +1890,30 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) goto error; /* Make sure that we got at least our header! */ - if (ucode_raw->size < iwl3945_ucode_get_header_size(1)) { - IWL_ERR(priv, "File size way too small!\n"); + if (ucode_raw->size < il3945_ucode_get_header_size(1)) { + IL_ERR(priv, "File size way too small!\n"); ret = -EINVAL; goto err_release; } /* Data from ucode file: header followed by uCode images */ - ucode = (struct iwl_ucode_header *)ucode_raw->data; + ucode = (struct il_ucode_header *)ucode_raw->data; priv->ucode_ver = le32_to_cpu(ucode->ver); - api_ver = IWL_UCODE_API(priv->ucode_ver); - inst_size = iwl3945_ucode_get_inst_size(ucode); - data_size = iwl3945_ucode_get_data_size(ucode); - init_size = iwl3945_ucode_get_init_size(ucode); - init_data_size = iwl3945_ucode_get_init_data_size(ucode); - boot_size = iwl3945_ucode_get_boot_size(ucode); - src = iwl3945_ucode_get_data(ucode); + api_ver = IL_UCODE_API(priv->ucode_ver); + inst_size = il3945_ucode_get_inst_size(ucode); + data_size = il3945_ucode_get_data_size(ucode); + init_size = il3945_ucode_get_init_size(ucode); + init_data_size = il3945_ucode_get_init_data_size(ucode); + boot_size = il3945_ucode_get_boot_size(ucode); + src = il3945_ucode_get_data(ucode); /* api_ver should match the api version forming part of the * firmware filename ... but we don't check for that and only rely * on the API version read from firmware header from here on forward */ if (api_ver < api_min || api_ver > api_max) { - IWL_ERR(priv, "Driver unable to support your firmware API. " + IL_ERR(priv, "Driver unable to support your firmware API. " "Driver supports v%u, firmware is v%u.\n", api_max, api_ver); priv->ucode_ver = 0; @@ -1921,45 +1921,45 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) goto err_release; } if (api_ver != api_max) - IWL_ERR(priv, "Firmware has old API version. Expected %u, " + IL_ERR(priv, "Firmware has old API version. Expected %u, " "got %u. New firmware can be obtained " "from http://www.intellinuxwireless.org.\n", api_max, api_ver); - IWL_INFO(priv, "loaded firmware version %u.%u.%u.%u\n", - IWL_UCODE_MAJOR(priv->ucode_ver), - IWL_UCODE_MINOR(priv->ucode_ver), - IWL_UCODE_API(priv->ucode_ver), - IWL_UCODE_SERIAL(priv->ucode_ver)); + IL_INFO(priv, "loaded firmware version %u.%u.%u.%u\n", + IL_UCODE_MAJOR(priv->ucode_ver), + IL_UCODE_MINOR(priv->ucode_ver), + IL_UCODE_API(priv->ucode_ver), + IL_UCODE_SERIAL(priv->ucode_ver)); snprintf(priv->hw->wiphy->fw_version, sizeof(priv->hw->wiphy->fw_version), "%u.%u.%u.%u", - IWL_UCODE_MAJOR(priv->ucode_ver), - IWL_UCODE_MINOR(priv->ucode_ver), - IWL_UCODE_API(priv->ucode_ver), - IWL_UCODE_SERIAL(priv->ucode_ver)); + IL_UCODE_MAJOR(priv->ucode_ver), + IL_UCODE_MINOR(priv->ucode_ver), + IL_UCODE_API(priv->ucode_ver), + IL_UCODE_SERIAL(priv->ucode_ver)); - IWL_DEBUG_INFO(priv, "f/w package hdr ucode version raw = 0x%x\n", + IL_DEBUG_INFO(priv, "f/w package hdr ucode version raw = 0x%x\n", priv->ucode_ver); - IWL_DEBUG_INFO(priv, "f/w package hdr runtime inst size = %u\n", + IL_DEBUG_INFO(priv, "f/w package hdr runtime inst size = %u\n", inst_size); - IWL_DEBUG_INFO(priv, "f/w package hdr runtime data size = %u\n", + IL_DEBUG_INFO(priv, "f/w package hdr runtime data size = %u\n", data_size); - IWL_DEBUG_INFO(priv, "f/w package hdr init inst size = %u\n", + IL_DEBUG_INFO(priv, "f/w package hdr init inst size = %u\n", init_size); - IWL_DEBUG_INFO(priv, "f/w package hdr init data size = %u\n", + IL_DEBUG_INFO(priv, "f/w package hdr init data size = %u\n", init_data_size); - IWL_DEBUG_INFO(priv, "f/w package hdr boot inst size = %u\n", + IL_DEBUG_INFO(priv, "f/w package hdr boot inst size = %u\n", boot_size); /* Verify size of file vs. image size info in file's header */ - if (ucode_raw->size != iwl3945_ucode_get_header_size(api_ver) + + if (ucode_raw->size != il3945_ucode_get_header_size(api_ver) + inst_size + data_size + init_size + init_data_size + boot_size) { - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "uCode file size %zd does not match expected size\n", ucode_raw->size); ret = -EINVAL; @@ -1968,34 +1968,34 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) /* Verify that uCode images will fit in card's SRAM */ if (inst_size > IWL39_MAX_INST_SIZE) { - IWL_DEBUG_INFO(priv, "uCode instr len %d too large to fit in\n", + IL_DEBUG_INFO(priv, "uCode instr len %d too large to fit in\n", inst_size); ret = -EINVAL; goto err_release; } if (data_size > IWL39_MAX_DATA_SIZE) { - IWL_DEBUG_INFO(priv, "uCode data len %d too large to fit in\n", + IL_DEBUG_INFO(priv, "uCode data len %d too large to fit in\n", data_size); ret = -EINVAL; goto err_release; } if (init_size > IWL39_MAX_INST_SIZE) { - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "uCode init instr len %d too large to fit in\n", init_size); ret = -EINVAL; goto err_release; } if (init_data_size > IWL39_MAX_DATA_SIZE) { - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "uCode init data len %d too large to fit in\n", init_data_size); ret = -EINVAL; goto err_release; } if (boot_size > IWL39_MAX_BSM_SIZE) { - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "uCode boot instr len %d too large to fit in\n", boot_size); ret = -EINVAL; @@ -2008,13 +2008,13 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) * 1) unmodified from disk * 2) backup cache for save/restore during power-downs */ priv->ucode_code.len = inst_size; - iwl_legacy_alloc_fw_desc(priv->pci_dev, &priv->ucode_code); + il_alloc_fw_desc(priv->pci_dev, &priv->ucode_code); priv->ucode_data.len = data_size; - iwl_legacy_alloc_fw_desc(priv->pci_dev, &priv->ucode_data); + il_alloc_fw_desc(priv->pci_dev, &priv->ucode_data); priv->ucode_data_backup.len = data_size; - iwl_legacy_alloc_fw_desc(priv->pci_dev, &priv->ucode_data_backup); + il_alloc_fw_desc(priv->pci_dev, &priv->ucode_data_backup); if (!priv->ucode_code.v_addr || !priv->ucode_data.v_addr || !priv->ucode_data_backup.v_addr) @@ -2023,10 +2023,10 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) /* Initialization instructions and data */ if (init_size && init_data_size) { priv->ucode_init.len = init_size; - iwl_legacy_alloc_fw_desc(priv->pci_dev, &priv->ucode_init); + il_alloc_fw_desc(priv->pci_dev, &priv->ucode_init); priv->ucode_init_data.len = init_data_size; - iwl_legacy_alloc_fw_desc(priv->pci_dev, &priv->ucode_init_data); + il_alloc_fw_desc(priv->pci_dev, &priv->ucode_init_data); if (!priv->ucode_init.v_addr || !priv->ucode_init_data.v_addr) goto err_pci_alloc; @@ -2035,7 +2035,7 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) /* Bootstrap (instructions only, no data) */ if (boot_size) { priv->ucode_boot.len = boot_size; - iwl_legacy_alloc_fw_desc(priv->pci_dev, &priv->ucode_boot); + il_alloc_fw_desc(priv->pci_dev, &priv->ucode_boot); if (!priv->ucode_boot.v_addr) goto err_pci_alloc; @@ -2045,18 +2045,18 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) /* Runtime instructions (first block of data in file) */ len = inst_size; - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "Copying (but not loading) uCode instr len %zd\n", len); memcpy(priv->ucode_code.v_addr, src, len); src += len; - IWL_DEBUG_INFO(priv, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", + IL_DEBUG_INFO(priv, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", priv->ucode_code.v_addr, (u32)priv->ucode_code.p_addr); /* Runtime data (2nd block) - * NOTE: Copy into backup buffer will be done in iwl3945_up() */ + * NOTE: Copy into backup buffer will be done in il3945_up() */ len = data_size; - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "Copying (but not loading) uCode data len %zd\n", len); memcpy(priv->ucode_data.v_addr, src, len); memcpy(priv->ucode_data_backup.v_addr, src, len); @@ -2065,7 +2065,7 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) /* Initialization instructions (3rd block) */ if (init_size) { len = init_size; - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "Copying (but not loading) init instr len %zd\n", len); memcpy(priv->ucode_init.v_addr, src, len); src += len; @@ -2074,7 +2074,7 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) /* Initialization data (4th block) */ if (init_data_size) { len = init_data_size; - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "Copying (but not loading) init data len %zd\n", len); memcpy(priv->ucode_init_data.v_addr, src, len); src += len; @@ -2082,7 +2082,7 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) /* Bootstrap instructions (5th block) */ len = boot_size; - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "Copying (but not loading) boot instr len %zd\n", len); memcpy(priv->ucode_boot.v_addr, src, len); @@ -2091,9 +2091,9 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) return 0; err_pci_alloc: - IWL_ERR(priv, "failed to allocate pci memory\n"); + IL_ERR(priv, "failed to allocate pci memory\n"); ret = -ENOMEM; - iwl3945_dealloc_ucode_pci(priv); + il3945_dealloc_ucode_pci(priv); err_release: release_firmware(ucode_raw); @@ -2104,7 +2104,7 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) /** - * iwl3945_set_ucode_ptrs - Set uCode address location + * il3945_set_ucode_ptrs - Set uCode address location * * Tell initialization uCode where to find runtime uCode. * @@ -2112,7 +2112,7 @@ static int iwl3945_read_ucode(struct iwl_priv *priv) * We need to replace them to load runtime uCode inst and data, * and to save runtime data when powering down. */ -static int iwl3945_set_ucode_ptrs(struct iwl_priv *priv) +static int il3945_set_ucode_ptrs(struct il_priv *priv) { dma_addr_t pinst; dma_addr_t pdata; @@ -2122,56 +2122,56 @@ static int iwl3945_set_ucode_ptrs(struct iwl_priv *priv) pdata = priv->ucode_data_backup.p_addr; /* Tell bootstrap uCode where to find image to load */ - iwl_legacy_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); - iwl_legacy_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); - iwl_legacy_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, + il_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); + il_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); + il_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, priv->ucode_data.len); /* Inst byte count must be last to set up, bit 31 signals uCode * that all new ptr/size info is in place */ - iwl_legacy_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, + il_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, priv->ucode_code.len | BSM_DRAM_INST_LOAD); - IWL_DEBUG_INFO(priv, "Runtime uCode pointers are set.\n"); + IL_DEBUG_INFO(priv, "Runtime uCode pointers are set.\n"); return 0; } /** - * iwl3945_init_alive_start - Called after REPLY_ALIVE notification received + * il3945_init_alive_start - Called after REPLY_ALIVE notification received * * Called after REPLY_ALIVE notification received from "initialize" uCode. * * Tell "initialize" uCode to go ahead and load the runtime uCode. */ -static void iwl3945_init_alive_start(struct iwl_priv *priv) +static void il3945_init_alive_start(struct il_priv *priv) { /* Check alive response for "valid" sign from uCode */ if (priv->card_alive_init.is_valid != UCODE_VALID_OK) { /* We had an error bringing up the hardware, so take it * all the way back down so we can try again */ - IWL_DEBUG_INFO(priv, "Initialize Alive failed.\n"); + IL_DEBUG_INFO(priv, "Initialize Alive failed.\n"); goto restart; } /* Bootstrap uCode has loaded initialize uCode ... verify inst image. * This is a paranoid check, because we would not have gotten the * "initialize" alive if code weren't properly loaded. */ - if (iwl3945_verify_ucode(priv)) { + if (il3945_verify_ucode(priv)) { /* Runtime instruction load was bad; * take it all the way back down so we can try again */ - IWL_DEBUG_INFO(priv, "Bad \"initialize\" uCode load.\n"); + IL_DEBUG_INFO(priv, "Bad \"initialize\" uCode load.\n"); goto restart; } /* Send pointers to protocol/runtime uCode image ... init code will * load and launch runtime uCode, which will send us another "Alive" * notification. */ - IWL_DEBUG_INFO(priv, "Initialization Alive received.\n"); - if (iwl3945_set_ucode_ptrs(priv)) { + IL_DEBUG_INFO(priv, "Initialization Alive received.\n"); + if (il3945_set_ucode_ptrs(priv)) { /* Runtime instruction load won't happen; * take it all the way back down so we can try again */ - IWL_DEBUG_INFO(priv, "Couldn't set up uCode pointers.\n"); + IL_DEBUG_INFO(priv, "Couldn't set up uCode pointers.\n"); goto restart; } return; @@ -2181,49 +2181,49 @@ static void iwl3945_init_alive_start(struct iwl_priv *priv) } /** - * iwl3945_alive_start - called after REPLY_ALIVE notification received + * il3945_alive_start - called after REPLY_ALIVE notification received * from protocol/runtime uCode (initialization uCode's - * Alive gets handled by iwl3945_init_alive_start()). + * Alive gets handled by il3945_init_alive_start()). */ -static void iwl3945_alive_start(struct iwl_priv *priv) +static void il3945_alive_start(struct il_priv *priv) { int thermal_spin = 0; u32 rfkill; - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; - IWL_DEBUG_INFO(priv, "Runtime Alive received.\n"); + IL_DEBUG_INFO(priv, "Runtime Alive received.\n"); if (priv->card_alive.is_valid != UCODE_VALID_OK) { /* We had an error bringing up the hardware, so take it * all the way back down so we can try again */ - IWL_DEBUG_INFO(priv, "Alive failed.\n"); + IL_DEBUG_INFO(priv, "Alive failed.\n"); goto restart; } /* Initialize uCode has loaded Runtime uCode ... verify inst image. * This is a paranoid check, because we would not have gotten the * "runtime" alive if code weren't properly loaded. */ - if (iwl3945_verify_ucode(priv)) { + if (il3945_verify_ucode(priv)) { /* Runtime instruction load was bad; * take it all the way back down so we can try again */ - IWL_DEBUG_INFO(priv, "Bad runtime uCode load.\n"); + IL_DEBUG_INFO(priv, "Bad runtime uCode load.\n"); goto restart; } - rfkill = iwl_legacy_read_prph(priv, APMG_RFKILL_REG); - IWL_DEBUG_INFO(priv, "RFKILL status: 0x%x\n", rfkill); + rfkill = il_read_prph(priv, APMG_RFKILL_REG); + IL_DEBUG_INFO(priv, "RFKILL status: 0x%x\n", rfkill); if (rfkill & 0x1) { clear_bit(STATUS_RF_KILL_HW, &priv->status); /* if RFKILL is not on, then wait for thermal * sensor in adapter to kick in */ - while (iwl3945_hw_get_temperature(priv) == 0) { + while (il3945_hw_get_temperature(priv) == 0) { thermal_spin++; udelay(10); } if (thermal_spin) - IWL_DEBUG_INFO(priv, "Thermal calibration took %dus\n", + IL_DEBUG_INFO(priv, "Thermal calibration took %dus\n", thermal_spin * 10); } else set_bit(STATUS_RF_KILL_HW, &priv->status); @@ -2232,39 +2232,39 @@ static void iwl3945_alive_start(struct iwl_priv *priv) set_bit(STATUS_ALIVE, &priv->status); /* Enable watchdog to monitor the driver tx queues */ - iwl_legacy_setup_watchdog(priv); + il_setup_watchdog(priv); - if (iwl_legacy_is_rfkill(priv)) + if (il_is_rfkill(priv)) return; ieee80211_wake_queues(priv->hw); - priv->active_rate = IWL_RATES_MASK_3945; + priv->active_rate = IL_RATES_MASK_3945; - iwl_legacy_power_update_mode(priv, true); + il_power_update_mode(priv, true); - if (iwl_legacy_is_associated(priv, IWL_RXON_CTX_BSS)) { - struct iwl3945_rxon_cmd *active_rxon = - (struct iwl3945_rxon_cmd *)(&ctx->active); + if (il_is_associated(priv, IL_RXON_CTX_BSS)) { + struct il3945_rxon_cmd *active_rxon = + (struct il3945_rxon_cmd *)(&ctx->active); ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; } else { /* Initialize our rx_config data */ - iwl_legacy_connection_init_rx_config(priv, ctx); + il_connection_init_rx_config(priv, ctx); } /* Configure Bluetooth device coexistence support */ - iwl_legacy_send_bt_config(priv); + il_send_bt_config(priv); set_bit(STATUS_READY, &priv->status); /* Configure the adapter for unassociated operation */ - iwl3945_commit_rxon(priv, ctx); + il3945_commit_rxon(priv, ctx); - iwl3945_reg_txpower_periodic(priv); + il3945_reg_txpower_periodic(priv); - IWL_DEBUG_INFO(priv, "ALIVE processing complete.\n"); + IL_DEBUG_INFO(priv, "ALIVE processing complete.\n"); wake_up(&priv->wait_command_queue); return; @@ -2273,16 +2273,16 @@ static void iwl3945_alive_start(struct iwl_priv *priv) queue_work(priv->workqueue, &priv->restart); } -static void iwl3945_cancel_deferred_work(struct iwl_priv *priv); +static void il3945_cancel_deferred_work(struct il_priv *priv); -static void __iwl3945_down(struct iwl_priv *priv) +static void __il3945_down(struct il_priv *priv) { unsigned long flags; int exit_pending; - IWL_DEBUG_INFO(priv, DRV_NAME " is going down\n"); + IL_DEBUG_INFO(priv, DRV_NAME " is going down\n"); - iwl_legacy_scan_cancel_timeout(priv, 200); + il_scan_cancel_timeout(priv, 200); exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &priv->status); @@ -2291,9 +2291,9 @@ static void __iwl3945_down(struct iwl_priv *priv) del_timer_sync(&priv->watchdog); /* Station information will now be cleared in device */ - iwl_legacy_clear_ucode_stations(priv, NULL); - iwl_legacy_dealloc_bcast_stations(priv); - iwl_legacy_clear_driver_stations(priv); + il_clear_ucode_stations(priv, NULL); + il_dealloc_bcast_stations(priv); + il_clear_driver_stations(priv); /* Unblock any waiting calls */ wake_up_all(&priv->wait_command_queue); @@ -2304,20 +2304,20 @@ static void __iwl3945_down(struct iwl_priv *priv) clear_bit(STATUS_EXIT_PENDING, &priv->status); /* stop and reset the on-board processor */ - iwl_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + il_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); /* tell the device to stop sending interrupts */ spin_lock_irqsave(&priv->lock, flags); - iwl_legacy_disable_interrupts(priv); + il_disable_interrupts(priv); spin_unlock_irqrestore(&priv->lock, flags); - iwl3945_synchronize_irq(priv); + il3945_synchronize_irq(priv); if (priv->mac80211_registered) ieee80211_stop_queues(priv->hw); - /* If we have not previously called iwl3945_init() then + /* If we have not previously called il3945_init() then * clear all bits but the RF Kill bits and return */ - if (!iwl_legacy_is_init(priv)) { + if (!il_is_init(priv)) { priv->status = test_bit(STATUS_RF_KILL_HW, &priv->status) << STATUS_RF_KILL_HW | test_bit(STATUS_GEO_CONFIGURED, &priv->status) << @@ -2338,109 +2338,109 @@ static void __iwl3945_down(struct iwl_priv *priv) test_bit(STATUS_EXIT_PENDING, &priv->status) << STATUS_EXIT_PENDING; - iwl3945_hw_txq_ctx_stop(priv); - iwl3945_hw_rxq_stop(priv); + il3945_hw_txq_ctx_stop(priv); + il3945_hw_rxq_stop(priv); /* Power-down device's busmaster DMA clocks */ - iwl_legacy_write_prph(priv, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); + il_write_prph(priv, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); udelay(5); /* Stop the device, and put it in low power state */ - iwl_legacy_apm_stop(priv); + il_apm_stop(priv); exit: - memset(&priv->card_alive, 0, sizeof(struct iwl_alive_resp)); + memset(&priv->card_alive, 0, sizeof(struct il_alive_resp)); if (priv->beacon_skb) dev_kfree_skb(priv->beacon_skb); priv->beacon_skb = NULL; /* clear out any free frames */ - iwl3945_clear_free_frames(priv); + il3945_clear_free_frames(priv); } -static void iwl3945_down(struct iwl_priv *priv) +static void il3945_down(struct il_priv *priv) { mutex_lock(&priv->mutex); - __iwl3945_down(priv); + __il3945_down(priv); mutex_unlock(&priv->mutex); - iwl3945_cancel_deferred_work(priv); + il3945_cancel_deferred_work(priv); } #define MAX_HW_RESTARTS 5 -static int iwl3945_alloc_bcast_station(struct iwl_priv *priv) +static int il3945_alloc_bcast_station(struct il_priv *priv) { - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; unsigned long flags; u8 sta_id; spin_lock_irqsave(&priv->sta_lock, flags); - sta_id = iwl_legacy_prep_station(priv, ctx, + sta_id = il_prep_station(priv, ctx, iwlegacy_bcast_addr, false, NULL); - if (sta_id == IWL_INVALID_STATION) { - IWL_ERR(priv, "Unable to prepare broadcast station\n"); + if (sta_id == IL_INVALID_STATION) { + IL_ERR(priv, "Unable to prepare broadcast station\n"); spin_unlock_irqrestore(&priv->sta_lock, flags); return -EINVAL; } - priv->stations[sta_id].used |= IWL_STA_DRIVER_ACTIVE; - priv->stations[sta_id].used |= IWL_STA_BCAST; + priv->stations[sta_id].used |= IL_STA_DRIVER_ACTIVE; + priv->stations[sta_id].used |= IL_STA_BCAST; spin_unlock_irqrestore(&priv->sta_lock, flags); return 0; } -static int __iwl3945_up(struct iwl_priv *priv) +static int __il3945_up(struct il_priv *priv) { int rc, i; - rc = iwl3945_alloc_bcast_station(priv); + rc = il3945_alloc_bcast_station(priv); if (rc) return rc; if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { - IWL_WARN(priv, "Exit pending; will not bring the NIC up\n"); + IL_WARN(priv, "Exit pending; will not bring the NIC up\n"); return -EIO; } if (!priv->ucode_data_backup.v_addr || !priv->ucode_data.v_addr) { - IWL_ERR(priv, "ucode not available for device bring up\n"); + IL_ERR(priv, "ucode not available for device bring up\n"); return -EIO; } /* If platform's RF_KILL switch is NOT set to KILL */ - if (iwl_read32(priv, CSR_GP_CNTRL) & + if (il_read32(priv, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) clear_bit(STATUS_RF_KILL_HW, &priv->status); else { set_bit(STATUS_RF_KILL_HW, &priv->status); - IWL_WARN(priv, "Radio disabled by HW RF Kill switch\n"); + IL_WARN(priv, "Radio disabled by HW RF Kill switch\n"); return -ENODEV; } - iwl_write32(priv, CSR_INT, 0xFFFFFFFF); + il_write32(priv, CSR_INT, 0xFFFFFFFF); - rc = iwl3945_hw_nic_init(priv); + rc = il3945_hw_nic_init(priv); if (rc) { - IWL_ERR(priv, "Unable to int nic\n"); + IL_ERR(priv, "Unable to int nic\n"); return rc; } /* make sure rfkill handshake bits are cleared */ - iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, + il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); /* clear (again), then enable host interrupts */ - iwl_write32(priv, CSR_INT, 0xFFFFFFFF); - iwl_legacy_enable_interrupts(priv); + il_write32(priv, CSR_INT, 0xFFFFFFFF); + il_enable_interrupts(priv); /* really make sure rfkill handshake bits are cleared */ - iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); /* Copy original ucode data image from disk into backup cache. * This will be used to initialize the on-board processor's @@ -2460,26 +2460,26 @@ static int __iwl3945_up(struct iwl_priv *priv) rc = priv->cfg->ops->lib->load_ucode(priv); if (rc) { - IWL_ERR(priv, + IL_ERR(priv, "Unable to set up bootstrap uCode: %d\n", rc); continue; } /* start card; "initialize" will load runtime ucode */ - iwl3945_nic_start(priv); + il3945_nic_start(priv); - IWL_DEBUG_INFO(priv, DRV_NAME " is coming up\n"); + IL_DEBUG_INFO(priv, DRV_NAME " is coming up\n"); return 0; } set_bit(STATUS_EXIT_PENDING, &priv->status); - __iwl3945_down(priv); + __il3945_down(priv); clear_bit(STATUS_EXIT_PENDING, &priv->status); /* tried to restart and config the device for as long as our * patience could withstand */ - IWL_ERR(priv, "Unable to initialize device after %d attempts.\n", i); + IL_ERR(priv, "Unable to initialize device after %d attempts.\n", i); return -EIO; } @@ -2490,30 +2490,30 @@ static int __iwl3945_up(struct iwl_priv *priv) * *****************************************************************************/ -static void iwl3945_bg_init_alive_start(struct work_struct *data) +static void il3945_bg_init_alive_start(struct work_struct *data) { - struct iwl_priv *priv = - container_of(data, struct iwl_priv, init_alive_start.work); + struct il_priv *priv = + container_of(data, struct il_priv, init_alive_start.work); mutex_lock(&priv->mutex); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) goto out; - iwl3945_init_alive_start(priv); + il3945_init_alive_start(priv); out: mutex_unlock(&priv->mutex); } -static void iwl3945_bg_alive_start(struct work_struct *data) +static void il3945_bg_alive_start(struct work_struct *data) { - struct iwl_priv *priv = - container_of(data, struct iwl_priv, alive_start.work); + struct il_priv *priv = + container_of(data, struct il_priv, alive_start.work); mutex_lock(&priv->mutex); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) goto out; - iwl3945_alive_start(priv); + il3945_alive_start(priv); out: mutex_unlock(&priv->mutex); } @@ -2524,12 +2524,12 @@ out: * *is* readable even when device has been SW_RESET into low power mode * (e.g. during RF KILL). */ -static void iwl3945_rfkill_poll(struct work_struct *data) +static void il3945_rfkill_poll(struct work_struct *data) { - struct iwl_priv *priv = - container_of(data, struct iwl_priv, _3945.rfkill_poll.work); + struct il_priv *priv = + container_of(data, struct il_priv, _3945.rfkill_poll.work); bool old_rfkill = test_bit(STATUS_RF_KILL_HW, &priv->status); - bool new_rfkill = !(iwl_read32(priv, CSR_GP_CNTRL) + bool new_rfkill = !(il_read32(priv, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW); if (new_rfkill != old_rfkill) { @@ -2540,7 +2540,7 @@ static void iwl3945_rfkill_poll(struct work_struct *data) wiphy_rfkill_set_hw_state(priv->hw->wiphy, new_rfkill); - IWL_DEBUG_RF_KILL(priv, "RF_KILL bit toggled to %s.\n", + IL_DEBUG_RF_KILL(priv, "RF_KILL bit toggled to %s.\n", new_rfkill ? "disable radio" : "enable radio"); } @@ -2551,14 +2551,14 @@ static void iwl3945_rfkill_poll(struct work_struct *data) } -int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) +int il3945_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) { - struct iwl_host_cmd cmd = { + struct il_host_cmd cmd = { .id = REPLY_SCAN_CMD, - .len = sizeof(struct iwl3945_scan_cmd), + .len = sizeof(struct il3945_scan_cmd), .flags = CMD_SIZE_HUGE, }; - struct iwl3945_scan_cmd *scan; + struct il3945_scan_cmd *scan; u8 n_probes = 0; enum ieee80211_band band; bool is_active = false; @@ -2568,26 +2568,26 @@ int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) lockdep_assert_held(&priv->mutex); if (!priv->scan_cmd) { - priv->scan_cmd = kmalloc(sizeof(struct iwl3945_scan_cmd) + - IWL_MAX_SCAN_SIZE, GFP_KERNEL); + priv->scan_cmd = kmalloc(sizeof(struct il3945_scan_cmd) + + IL_MAX_SCAN_SIZE, GFP_KERNEL); if (!priv->scan_cmd) { - IWL_DEBUG_SCAN(priv, "Fail to allocate scan memory\n"); + IL_DEBUG_SCAN(priv, "Fail to allocate scan memory\n"); return -ENOMEM; } } scan = priv->scan_cmd; - memset(scan, 0, sizeof(struct iwl3945_scan_cmd) + IWL_MAX_SCAN_SIZE); + memset(scan, 0, sizeof(struct il3945_scan_cmd) + IL_MAX_SCAN_SIZE); - scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH; - scan->quiet_time = IWL_ACTIVE_QUIET_TIME; + scan->quiet_plcp_th = IL_PLCP_QUIET_THRESH; + scan->quiet_time = IL_ACTIVE_QUIET_TIME; - if (iwl_legacy_is_associated(priv, IWL_RXON_CTX_BSS)) { + if (il_is_associated(priv, IL_RXON_CTX_BSS)) { u16 interval; u32 extra; u32 suspend_time = 100; u32 scan_suspend_time = 100; - IWL_DEBUG_INFO(priv, "Scanning while associated...\n"); + IL_DEBUG_INFO(priv, "Scanning while associated...\n"); interval = vif->bss_conf.beacon_int; @@ -2607,13 +2607,13 @@ int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) (extra | ((suspend_time % interval) * 1024)); scan->suspend_time = cpu_to_le32(scan_suspend_time); - IWL_DEBUG_SCAN(priv, "suspend_time 0x%X beacon interval %d\n", + IL_DEBUG_SCAN(priv, "suspend_time 0x%X beacon interval %d\n", scan_suspend_time, interval); } if (priv->scan_request->n_ssids) { int i, p = 0; - IWL_DEBUG_SCAN(priv, "Kicking off active scan\n"); + IL_DEBUG_SCAN(priv, "Kicking off active scan\n"); for (i = 0; i < priv->scan_request->n_ssids; i++) { /* always does wildcard anyway */ if (!priv->scan_request->ssids[i].ssid_len) @@ -2629,12 +2629,12 @@ int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) } is_active = true; } else - IWL_DEBUG_SCAN(priv, "Kicking off passive scan.\n"); + IL_DEBUG_SCAN(priv, "Kicking off passive scan.\n"); /* We don't build a direct scan probe request; the uCode will do * that based on the direct_mask added to each channel entry */ scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; - scan->tx_cmd.sta_id = priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id; + scan->tx_cmd.sta_id = priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id; scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; /* flags + rate selection */ @@ -2642,15 +2642,15 @@ int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) switch (priv->scan_band) { case IEEE80211_BAND_2GHZ: scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; - scan->tx_cmd.rate = IWL_RATE_1M_PLCP; + scan->tx_cmd.rate = IL_RATE_1M_PLCP; band = IEEE80211_BAND_2GHZ; break; case IEEE80211_BAND_5GHZ: - scan->tx_cmd.rate = IWL_RATE_6M_PLCP; + scan->tx_cmd.rate = IL_RATE_6M_PLCP; band = IEEE80211_BAND_5GHZ; break; default: - IWL_WARN(priv, "Invalid scan band\n"); + IL_WARN(priv, "Invalid scan band\n"); return -EIO; } @@ -2659,67 +2659,67 @@ int iwl3945_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif) * is marked passive, we can do active scanning if we * detect transmissions. */ - scan->good_CRC_th = is_active ? IWL_GOOD_CRC_TH_DEFAULT : - IWL_GOOD_CRC_TH_DISABLED; + scan->good_CRC_th = is_active ? IL_GOOD_CRC_TH_DEFAULT : + IL_GOOD_CRC_TH_DISABLED; - len = iwl_legacy_fill_probe_req(priv, (struct ieee80211_mgmt *)scan->data, + len = il_fill_probe_req(priv, (struct ieee80211_mgmt *)scan->data, vif->addr, priv->scan_request->ie, priv->scan_request->ie_len, - IWL_MAX_SCAN_SIZE - sizeof(*scan)); + IL_MAX_SCAN_SIZE - sizeof(*scan)); scan->tx_cmd.len = cpu_to_le16(len); /* select Rx antennas */ - scan->flags |= iwl3945_get_antenna_flags(priv); + scan->flags |= il3945_get_antenna_flags(priv); - scan->channel_count = iwl3945_get_channels_for_scan(priv, band, is_active, n_probes, + scan->channel_count = il3945_get_channels_for_scan(priv, band, is_active, n_probes, (void *)&scan->data[len], vif); if (scan->channel_count == 0) { - IWL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count); + IL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count); return -EIO; } cmd.len += le16_to_cpu(scan->tx_cmd.len) + - scan->channel_count * sizeof(struct iwl3945_scan_channel); + scan->channel_count * sizeof(struct il3945_scan_channel); cmd.data = scan; scan->len = cpu_to_le16(cmd.len); set_bit(STATUS_SCAN_HW, &priv->status); - ret = iwl_legacy_send_cmd_sync(priv, &cmd); + ret = il_send_cmd_sync(priv, &cmd); if (ret) clear_bit(STATUS_SCAN_HW, &priv->status); return ret; } -void iwl3945_post_scan(struct iwl_priv *priv) +void il3945_post_scan(struct il_priv *priv) { - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; /* * Since setting the RXON may have been deferred while * performing the scan, fire one off if needed */ if (memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) - iwl3945_commit_rxon(priv, ctx); + il3945_commit_rxon(priv, ctx); } -static void iwl3945_bg_restart(struct work_struct *data) +static void il3945_bg_restart(struct work_struct *data) { - struct iwl_priv *priv = container_of(data, struct iwl_priv, restart); + struct il_priv *priv = container_of(data, struct il_priv, restart); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; if (test_and_clear_bit(STATUS_FW_ERROR, &priv->status)) { - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; mutex_lock(&priv->mutex); for_each_context(priv, ctx) ctx->vif = NULL; priv->is_open = 0; mutex_unlock(&priv->mutex); - iwl3945_down(priv); + il3945_down(priv); ieee80211_restart_hw(priv->hw); } else { - iwl3945_down(priv); + il3945_down(priv); mutex_lock(&priv->mutex); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { @@ -2727,57 +2727,57 @@ static void iwl3945_bg_restart(struct work_struct *data) return; } - __iwl3945_up(priv); + __il3945_up(priv); mutex_unlock(&priv->mutex); } } -static void iwl3945_bg_rx_replenish(struct work_struct *data) +static void il3945_bg_rx_replenish(struct work_struct *data) { - struct iwl_priv *priv = - container_of(data, struct iwl_priv, rx_replenish); + struct il_priv *priv = + container_of(data, struct il_priv, rx_replenish); mutex_lock(&priv->mutex); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) goto out; - iwl3945_rx_replenish(priv); + il3945_rx_replenish(priv); out: mutex_unlock(&priv->mutex); } -void iwl3945_post_associate(struct iwl_priv *priv) +void il3945_post_associate(struct il_priv *priv) { int rc = 0; struct ieee80211_conf *conf = NULL; - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; if (!ctx->vif || !priv->is_open) return; - IWL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n", + IL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n", ctx->vif->bss_conf.aid, ctx->active.bssid_addr); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; - iwl_legacy_scan_cancel_timeout(priv, 200); + il_scan_cancel_timeout(priv, 200); - conf = iwl_legacy_ieee80211_get_hw_conf(priv->hw); + conf = il_ieee80211_get_hw_conf(priv->hw); ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - iwl3945_commit_rxon(priv, ctx); + il3945_commit_rxon(priv, ctx); - rc = iwl_legacy_send_rxon_timing(priv, ctx); + rc = il_send_rxon_timing(priv, ctx); if (rc) - IWL_WARN(priv, "REPLY_RXON_TIMING failed - " + IL_WARN(priv, "REPLY_RXON_TIMING failed - " "Attempting to continue.\n"); ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; ctx->staging.assoc_id = cpu_to_le16(ctx->vif->bss_conf.aid); - IWL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n", + IL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n", ctx->vif->bss_conf.aid, ctx->vif->bss_conf.beacon_int); if (ctx->vif->bss_conf.use_short_preamble) @@ -2792,17 +2792,17 @@ void iwl3945_post_associate(struct iwl_priv *priv) ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; } - iwl3945_commit_rxon(priv, ctx); + il3945_commit_rxon(priv, ctx); switch (ctx->vif->type) { case NL80211_IFTYPE_STATION: - iwl3945_rate_scale_init(priv->hw, IWL_AP_ID); + il3945_rate_scale_init(priv->hw, IL_AP_ID); break; case NL80211_IFTYPE_ADHOC: - iwl3945_send_beacon_cmd(priv); + il3945_send_beacon_cmd(priv); break; default: - IWL_ERR(priv, "%s Should not be called in %d mode\n", + IL_ERR(priv, "%s Should not be called in %d mode\n", __func__, ctx->vif->type); break; } @@ -2816,12 +2816,12 @@ void iwl3945_post_associate(struct iwl_priv *priv) #define UCODE_READY_TIMEOUT (2 * HZ) -static int iwl3945_mac_start(struct ieee80211_hw *hw) +static int il3945_mac_start(struct ieee80211_hw *hw) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; int ret; - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); /* we should be verifying the device is ready to be opened */ mutex_lock(&priv->mutex); @@ -2830,22 +2830,22 @@ static int iwl3945_mac_start(struct ieee80211_hw *hw) * ucode filename and max sizes are card-specific. */ if (!priv->ucode_code.len) { - ret = iwl3945_read_ucode(priv); + ret = il3945_read_ucode(priv); if (ret) { - IWL_ERR(priv, "Could not read microcode: %d\n", ret); + IL_ERR(priv, "Could not read microcode: %d\n", ret); mutex_unlock(&priv->mutex); goto out_release_irq; } } - ret = __iwl3945_up(priv); + ret = __il3945_up(priv); mutex_unlock(&priv->mutex); if (ret) goto out_release_irq; - IWL_DEBUG_INFO(priv, "Start UP work.\n"); + IL_DEBUG_INFO(priv, "Start UP work.\n"); /* Wait for START_ALIVE from ucode. Otherwise callbacks from * mac80211 will not be run successfully. */ @@ -2854,7 +2854,7 @@ static int iwl3945_mac_start(struct ieee80211_hw *hw) UCODE_READY_TIMEOUT); if (!ret) { if (!test_bit(STATUS_READY, &priv->status)) { - IWL_ERR(priv, + IL_ERR(priv, "Wait for START_ALIVE timeout after %dms.\n", jiffies_to_msecs(UCODE_READY_TIMEOUT)); ret = -ETIMEDOUT; @@ -2867,29 +2867,29 @@ static int iwl3945_mac_start(struct ieee80211_hw *hw) cancel_delayed_work(&priv->_3945.rfkill_poll); priv->is_open = 1; - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); return 0; out_release_irq: priv->is_open = 0; - IWL_DEBUG_MAC80211(priv, "leave - failed\n"); + IL_DEBUG_MAC80211(priv, "leave - failed\n"); return ret; } -static void iwl3945_mac_stop(struct ieee80211_hw *hw) +static void il3945_mac_stop(struct ieee80211_hw *hw) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); if (!priv->is_open) { - IWL_DEBUG_MAC80211(priv, "leave - skip\n"); + IL_DEBUG_MAC80211(priv, "leave - skip\n"); return; } priv->is_open = 0; - iwl3945_down(priv); + il3945_down(priv); flush_workqueue(priv->workqueue); @@ -2897,27 +2897,27 @@ static void iwl3945_mac_stop(struct ieee80211_hw *hw) queue_delayed_work(priv->workqueue, &priv->_3945.rfkill_poll, round_jiffies_relative(2 * HZ)); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); } -static void iwl3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) +static void il3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); - IWL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, + IL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); - if (iwl3945_tx_skb(priv, skb)) + if (il3945_tx_skb(priv, skb)) dev_kfree_skb_any(skb); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); } -void iwl3945_config_ap(struct iwl_priv *priv) +void il3945_config_ap(struct il_priv *priv) { - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; struct ieee80211_vif *vif = ctx->vif; int rc = 0; @@ -2925,16 +2925,16 @@ void iwl3945_config_ap(struct iwl_priv *priv) return; /* The following should be done only at AP bring up */ - if (!(iwl_legacy_is_associated(priv, IWL_RXON_CTX_BSS))) { + if (!(il_is_associated(priv, IL_RXON_CTX_BSS))) { /* RXON - unassoc (to set timing command) */ ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - iwl3945_commit_rxon(priv, ctx); + il3945_commit_rxon(priv, ctx); /* RXON Timing */ - rc = iwl_legacy_send_rxon_timing(priv, ctx); + rc = il_send_rxon_timing(priv, ctx); if (rc) - IWL_WARN(priv, "REPLY_RXON_TIMING failed - " + IL_WARN(priv, "REPLY_RXON_TIMING failed - " "Attempting to continue.\n"); ctx->staging.assoc_id = 0; @@ -2956,25 +2956,25 @@ void iwl3945_config_ap(struct iwl_priv *priv) } /* restore RXON assoc */ ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - iwl3945_commit_rxon(priv, ctx); + il3945_commit_rxon(priv, ctx); } - iwl3945_send_beacon_cmd(priv); + il3945_send_beacon_cmd(priv); } -static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, +static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, struct ieee80211_vif *vif, struct ieee80211_sta *sta, struct ieee80211_key_conf *key) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; int ret = 0; - u8 sta_id = IWL_INVALID_STATION; + u8 sta_id = IL_INVALID_STATION; u8 static_key; - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); - if (iwl3945_mod_params.sw_crypto) { - IWL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n"); + if (il3945_mod_params.sw_crypto) { + IL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n"); return -EOPNOTSUPP; } @@ -2986,66 +2986,66 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) return -EOPNOTSUPP; - static_key = !iwl_legacy_is_associated(priv, IWL_RXON_CTX_BSS); + static_key = !il_is_associated(priv, IL_RXON_CTX_BSS); if (!static_key) { - sta_id = iwl_legacy_sta_id_or_broadcast( - priv, &priv->contexts[IWL_RXON_CTX_BSS], sta); - if (sta_id == IWL_INVALID_STATION) + sta_id = il_sta_id_or_broadcast( + priv, &priv->contexts[IL_RXON_CTX_BSS], sta); + if (sta_id == IL_INVALID_STATION) return -EINVAL; } mutex_lock(&priv->mutex); - iwl_legacy_scan_cancel_timeout(priv, 100); + il_scan_cancel_timeout(priv, 100); switch (cmd) { case SET_KEY: if (static_key) - ret = iwl3945_set_static_key(priv, key); + ret = il3945_set_static_key(priv, key); else - ret = iwl3945_set_dynamic_key(priv, key, sta_id); - IWL_DEBUG_MAC80211(priv, "enable hwcrypto key\n"); + ret = il3945_set_dynamic_key(priv, key, sta_id); + IL_DEBUG_MAC80211(priv, "enable hwcrypto key\n"); break; case DISABLE_KEY: if (static_key) - ret = iwl3945_remove_static_key(priv); + ret = il3945_remove_static_key(priv); else - ret = iwl3945_clear_sta_key_info(priv, sta_id); - IWL_DEBUG_MAC80211(priv, "disable hwcrypto key\n"); + ret = il3945_clear_sta_key_info(priv, sta_id); + IL_DEBUG_MAC80211(priv, "disable hwcrypto key\n"); break; default: ret = -EINVAL; } mutex_unlock(&priv->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); return ret; } -static int iwl3945_mac_sta_add(struct ieee80211_hw *hw, +static int il3945_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta) { - struct iwl_priv *priv = hw->priv; - struct iwl3945_sta_priv *sta_priv = (void *)sta->drv_priv; + struct il_priv *priv = hw->priv; + struct il3945_sta_priv *sta_priv = (void *)sta->drv_priv; int ret; bool is_ap = vif->type == NL80211_IFTYPE_STATION; u8 sta_id; - IWL_DEBUG_INFO(priv, "received request to add station %pM\n", + IL_DEBUG_INFO(priv, "received request to add station %pM\n", sta->addr); mutex_lock(&priv->mutex); - IWL_DEBUG_INFO(priv, "proceeding to add station %pM\n", + IL_DEBUG_INFO(priv, "proceeding to add station %pM\n", sta->addr); - sta_priv->common.sta_id = IWL_INVALID_STATION; + sta_priv->common.sta_id = IL_INVALID_STATION; - ret = iwl_legacy_add_station_common(priv, - &priv->contexts[IWL_RXON_CTX_BSS], + ret = il_add_station_common(priv, + &priv->contexts[IL_RXON_CTX_BSS], sta->addr, is_ap, sta, &sta_id); if (ret) { - IWL_ERR(priv, "Unable to add station %pM (%d)\n", + IL_ERR(priv, "Unable to add station %pM (%d)\n", sta->addr, ret); /* Should we return success if return code is EEXIST ? */ mutex_unlock(&priv->mutex); @@ -3055,22 +3055,22 @@ static int iwl3945_mac_sta_add(struct ieee80211_hw *hw, sta_priv->common.sta_id = sta_id; /* Initialize rate scaling */ - IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n", + IL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n", sta->addr); - iwl3945_rs_rate_init(priv, sta, sta_id); + il3945_rs_rate_init(priv, sta, sta_id); mutex_unlock(&priv->mutex); return 0; } -static void iwl3945_configure_filter(struct ieee80211_hw *hw, +static void il3945_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags, unsigned int *total_flags, u64 multicast) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; __le32 filter_or = 0, filter_nand = 0; - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; #define CHK(test, flag) do { \ if (*total_flags & (test)) \ @@ -3079,7 +3079,7 @@ static void iwl3945_configure_filter(struct ieee80211_hw *hw, filter_nand |= (flag); \ } while (0) - IWL_DEBUG_MAC80211(priv, "Enter: changed: 0x%x, total: 0x%x\n", + IL_DEBUG_MAC80211(priv, "Enter: changed: 0x%x, total: 0x%x\n", changed_flags, *total_flags); CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); @@ -3103,7 +3103,7 @@ static void iwl3945_configure_filter(struct ieee80211_hw *hw, /* * Receiving all multicast frames is always enabled by the - * default flags setup in iwl_legacy_connection_init_rx_config() + * default flags setup in il_connection_init_rx_config() * since we currently do not support programming multicast * filters into the device. */ @@ -3131,103 +3131,103 @@ static void iwl3945_configure_filter(struct ieee80211_hw *hw, * level that is used instead of the global debug level if it (the per * device debug level) is set. */ -static ssize_t iwl3945_show_debug_level(struct device *d, +static ssize_t il3945_show_debug_level(struct device *d, struct device_attribute *attr, char *buf) { - struct iwl_priv *priv = dev_get_drvdata(d); - return sprintf(buf, "0x%08X\n", iwl_legacy_get_debug_level(priv)); + struct il_priv *priv = dev_get_drvdata(d); + return sprintf(buf, "0x%08X\n", il_get_debug_level(priv)); } -static ssize_t iwl3945_store_debug_level(struct device *d, +static ssize_t il3945_store_debug_level(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); unsigned long val; int ret; ret = strict_strtoul(buf, 0, &val); if (ret) - IWL_INFO(priv, "%s is not in hex or decimal form.\n", buf); + IL_INFO(priv, "%s is not in hex or decimal form.\n", buf); else { priv->debug_level = val; - if (iwl_legacy_alloc_traffic_mem(priv)) - IWL_ERR(priv, + if (il_alloc_traffic_mem(priv)) + IL_ERR(priv, "Not enough memory to generate traffic log\n"); } return strnlen(buf, count); } static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, - iwl3945_show_debug_level, iwl3945_store_debug_level); + il3945_show_debug_level, il3945_store_debug_level); #endif /* CONFIG_IWLWIFI_LEGACY_DEBUG */ -static ssize_t iwl3945_show_temperature(struct device *d, +static ssize_t il3945_show_temperature(struct device *d, struct device_attribute *attr, char *buf) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); - if (!iwl_legacy_is_alive(priv)) + if (!il_is_alive(priv)) return -EAGAIN; - return sprintf(buf, "%d\n", iwl3945_hw_get_temperature(priv)); + return sprintf(buf, "%d\n", il3945_hw_get_temperature(priv)); } -static DEVICE_ATTR(temperature, S_IRUGO, iwl3945_show_temperature, NULL); +static DEVICE_ATTR(temperature, S_IRUGO, il3945_show_temperature, NULL); -static ssize_t iwl3945_show_tx_power(struct device *d, +static ssize_t il3945_show_tx_power(struct device *d, struct device_attribute *attr, char *buf) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); return sprintf(buf, "%d\n", priv->tx_power_user_lmt); } -static ssize_t iwl3945_store_tx_power(struct device *d, +static ssize_t il3945_store_tx_power(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); char *p = (char *)buf; u32 val; val = simple_strtoul(p, &p, 10); if (p == buf) - IWL_INFO(priv, ": %s is not in decimal form.\n", buf); + IL_INFO(priv, ": %s is not in decimal form.\n", buf); else - iwl3945_hw_reg_set_txpower(priv, val); + il3945_hw_reg_set_txpower(priv, val); return count; } -static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, iwl3945_show_tx_power, iwl3945_store_tx_power); +static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, il3945_show_tx_power, il3945_store_tx_power); -static ssize_t iwl3945_show_flags(struct device *d, +static ssize_t il3945_show_flags(struct device *d, struct device_attribute *attr, char *buf) { - struct iwl_priv *priv = dev_get_drvdata(d); - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_priv *priv = dev_get_drvdata(d); + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; return sprintf(buf, "0x%04X\n", ctx->active.flags); } -static ssize_t iwl3945_store_flags(struct device *d, +static ssize_t il3945_store_flags(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); u32 flags = simple_strtoul(buf, NULL, 0); - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; mutex_lock(&priv->mutex); if (le32_to_cpu(ctx->staging.flags) != flags) { /* Cancel any currently running scans... */ - if (iwl_legacy_scan_cancel_timeout(priv, 100)) - IWL_WARN(priv, "Could not cancel scan.\n"); + if (il_scan_cancel_timeout(priv, 100)) + IL_WARN(priv, "Could not cancel scan.\n"); else { - IWL_DEBUG_INFO(priv, "Committing rxon.flags = 0x%04X\n", + IL_DEBUG_INFO(priv, "Committing rxon.flags = 0x%04X\n", flags); ctx->staging.flags = cpu_to_le32(flags); - iwl3945_commit_rxon(priv, ctx); + il3945_commit_rxon(priv, ctx); } } mutex_unlock(&priv->mutex); @@ -3235,37 +3235,37 @@ static ssize_t iwl3945_store_flags(struct device *d, return count; } -static DEVICE_ATTR(flags, S_IWUSR | S_IRUGO, iwl3945_show_flags, iwl3945_store_flags); +static DEVICE_ATTR(flags, S_IWUSR | S_IRUGO, il3945_show_flags, il3945_store_flags); -static ssize_t iwl3945_show_filter_flags(struct device *d, +static ssize_t il3945_show_filter_flags(struct device *d, struct device_attribute *attr, char *buf) { - struct iwl_priv *priv = dev_get_drvdata(d); - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_priv *priv = dev_get_drvdata(d); + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; return sprintf(buf, "0x%04X\n", le32_to_cpu(ctx->active.filter_flags)); } -static ssize_t iwl3945_store_filter_flags(struct device *d, +static ssize_t il3945_store_filter_flags(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct iwl_priv *priv = dev_get_drvdata(d); - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_priv *priv = dev_get_drvdata(d); + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; u32 filter_flags = simple_strtoul(buf, NULL, 0); mutex_lock(&priv->mutex); if (le32_to_cpu(ctx->staging.filter_flags) != filter_flags) { /* Cancel any currently running scans... */ - if (iwl_legacy_scan_cancel_timeout(priv, 100)) - IWL_WARN(priv, "Could not cancel scan.\n"); + if (il_scan_cancel_timeout(priv, 100)) + IL_WARN(priv, "Could not cancel scan.\n"); else { - IWL_DEBUG_INFO(priv, "Committing rxon.filter_flags = " + IL_DEBUG_INFO(priv, "Committing rxon.filter_flags = " "0x%04X\n", filter_flags); ctx->staging.filter_flags = cpu_to_le32(filter_flags); - iwl3945_commit_rxon(priv, ctx); + il3945_commit_rxon(priv, ctx); } } mutex_unlock(&priv->mutex); @@ -3273,14 +3273,14 @@ static ssize_t iwl3945_store_filter_flags(struct device *d, return count; } -static DEVICE_ATTR(filter_flags, S_IWUSR | S_IRUGO, iwl3945_show_filter_flags, - iwl3945_store_filter_flags); +static DEVICE_ATTR(filter_flags, S_IWUSR | S_IRUGO, il3945_show_filter_flags, + il3945_store_filter_flags); -static ssize_t iwl3945_show_measurement(struct device *d, +static ssize_t il3945_show_measurement(struct device *d, struct device_attribute *attr, char *buf) { - struct iwl_priv *priv = dev_get_drvdata(d); - struct iwl_spectrum_notification measure_report; + struct il_priv *priv = dev_get_drvdata(d); + struct il_spectrum_notification measure_report; u32 size = sizeof(measure_report), len = 0, ofs = 0; u8 *data = (u8 *)&measure_report; unsigned long flags; @@ -3308,18 +3308,18 @@ static ssize_t iwl3945_show_measurement(struct device *d, return len; } -static ssize_t iwl3945_store_measurement(struct device *d, +static ssize_t il3945_store_measurement(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct iwl_priv *priv = dev_get_drvdata(d); - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_priv *priv = dev_get_drvdata(d); + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; struct ieee80211_measurement_params params = { .channel = le16_to_cpu(ctx->active.channel), .start_time = cpu_to_le64(priv->_3945.last_tsf), .duration = cpu_to_le16(1), }; - u8 type = IWL_MEASURE_BASIC; + u8 type = IL_MEASURE_BASIC; u8 buffer[32]; u8 channel; @@ -3337,21 +3337,21 @@ static ssize_t iwl3945_store_measurement(struct device *d, type = simple_strtoul(p + 1, NULL, 0); } - IWL_DEBUG_INFO(priv, "Invoking measurement of type %d on " + IL_DEBUG_INFO(priv, "Invoking measurement of type %d on " "channel %d (for '%s')\n", type, params.channel, buf); - iwl3945_get_measurement(priv, ¶ms, type); + il3945_get_measurement(priv, ¶ms, type); return count; } static DEVICE_ATTR(measurement, S_IRUSR | S_IWUSR, - iwl3945_show_measurement, iwl3945_store_measurement); + il3945_show_measurement, il3945_store_measurement); -static ssize_t iwl3945_store_retry_rate(struct device *d, +static ssize_t il3945_store_retry_rate(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); priv->retry_rate = simple_strtoul(buf, NULL, 0); if (priv->retry_rate <= 0) @@ -3360,89 +3360,89 @@ static ssize_t iwl3945_store_retry_rate(struct device *d, return count; } -static ssize_t iwl3945_show_retry_rate(struct device *d, +static ssize_t il3945_show_retry_rate(struct device *d, struct device_attribute *attr, char *buf) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); return sprintf(buf, "%d", priv->retry_rate); } -static DEVICE_ATTR(retry_rate, S_IWUSR | S_IRUSR, iwl3945_show_retry_rate, - iwl3945_store_retry_rate); +static DEVICE_ATTR(retry_rate, S_IWUSR | S_IRUSR, il3945_show_retry_rate, + il3945_store_retry_rate); -static ssize_t iwl3945_show_channels(struct device *d, +static ssize_t il3945_show_channels(struct device *d, struct device_attribute *attr, char *buf) { /* all this shit doesn't belong into sysfs anyway */ return 0; } -static DEVICE_ATTR(channels, S_IRUSR, iwl3945_show_channels, NULL); +static DEVICE_ATTR(channels, S_IRUSR, il3945_show_channels, NULL); -static ssize_t iwl3945_show_antenna(struct device *d, +static ssize_t il3945_show_antenna(struct device *d, struct device_attribute *attr, char *buf) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); - if (!iwl_legacy_is_alive(priv)) + if (!il_is_alive(priv)) return -EAGAIN; - return sprintf(buf, "%d\n", iwl3945_mod_params.antenna); + return sprintf(buf, "%d\n", il3945_mod_params.antenna); } -static ssize_t iwl3945_store_antenna(struct device *d, +static ssize_t il3945_store_antenna(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct iwl_priv *priv __maybe_unused = dev_get_drvdata(d); + struct il_priv *priv __maybe_unused = dev_get_drvdata(d); int ant; if (count == 0) return 0; if (sscanf(buf, "%1i", &ant) != 1) { - IWL_DEBUG_INFO(priv, "not in hex or decimal form.\n"); + IL_DEBUG_INFO(priv, "not in hex or decimal form.\n"); return count; } if ((ant >= 0) && (ant <= 2)) { - IWL_DEBUG_INFO(priv, "Setting antenna select to %d.\n", ant); - iwl3945_mod_params.antenna = (enum iwl3945_antenna)ant; + IL_DEBUG_INFO(priv, "Setting antenna select to %d.\n", ant); + il3945_mod_params.antenna = (enum il3945_antenna)ant; } else - IWL_DEBUG_INFO(priv, "Bad antenna select value %d.\n", ant); + IL_DEBUG_INFO(priv, "Bad antenna select value %d.\n", ant); return count; } -static DEVICE_ATTR(antenna, S_IWUSR | S_IRUGO, iwl3945_show_antenna, iwl3945_store_antenna); +static DEVICE_ATTR(antenna, S_IWUSR | S_IRUGO, il3945_show_antenna, il3945_store_antenna); -static ssize_t iwl3945_show_status(struct device *d, +static ssize_t il3945_show_status(struct device *d, struct device_attribute *attr, char *buf) { - struct iwl_priv *priv = dev_get_drvdata(d); - if (!iwl_legacy_is_alive(priv)) + struct il_priv *priv = dev_get_drvdata(d); + if (!il_is_alive(priv)) return -EAGAIN; return sprintf(buf, "0x%08x\n", (int)priv->status); } -static DEVICE_ATTR(status, S_IRUGO, iwl3945_show_status, NULL); +static DEVICE_ATTR(status, S_IRUGO, il3945_show_status, NULL); -static ssize_t iwl3945_dump_error_log(struct device *d, +static ssize_t il3945_dump_error_log(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); char *p = (char *)buf; if (p[0] == '1') - iwl3945_dump_nic_error_log(priv); + il3945_dump_nic_error_log(priv); return strnlen(buf, count); } -static DEVICE_ATTR(dump_errors, S_IWUSR, NULL, iwl3945_dump_error_log); +static DEVICE_ATTR(dump_errors, S_IWUSR, NULL, il3945_dump_error_log); /***************************************************************************** * @@ -3450,41 +3450,41 @@ static DEVICE_ATTR(dump_errors, S_IWUSR, NULL, iwl3945_dump_error_log); * *****************************************************************************/ -static void iwl3945_setup_deferred_work(struct iwl_priv *priv) +static void il3945_setup_deferred_work(struct il_priv *priv) { priv->workqueue = create_singlethread_workqueue(DRV_NAME); init_waitqueue_head(&priv->wait_command_queue); - INIT_WORK(&priv->restart, iwl3945_bg_restart); - INIT_WORK(&priv->rx_replenish, iwl3945_bg_rx_replenish); - INIT_DELAYED_WORK(&priv->init_alive_start, iwl3945_bg_init_alive_start); - INIT_DELAYED_WORK(&priv->alive_start, iwl3945_bg_alive_start); - INIT_DELAYED_WORK(&priv->_3945.rfkill_poll, iwl3945_rfkill_poll); + INIT_WORK(&priv->restart, il3945_bg_restart); + INIT_WORK(&priv->rx_replenish, il3945_bg_rx_replenish); + INIT_DELAYED_WORK(&priv->init_alive_start, il3945_bg_init_alive_start); + INIT_DELAYED_WORK(&priv->alive_start, il3945_bg_alive_start); + INIT_DELAYED_WORK(&priv->_3945.rfkill_poll, il3945_rfkill_poll); - iwl_legacy_setup_scan_deferred_work(priv); + il_setup_scan_deferred_work(priv); - iwl3945_hw_setup_deferred_work(priv); + il3945_hw_setup_deferred_work(priv); init_timer(&priv->watchdog); priv->watchdog.data = (unsigned long)priv; - priv->watchdog.function = iwl_legacy_bg_watchdog; + priv->watchdog.function = il_bg_watchdog; tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) - iwl3945_irq_tasklet, (unsigned long)priv); + il3945_irq_tasklet, (unsigned long)priv); } -static void iwl3945_cancel_deferred_work(struct iwl_priv *priv) +static void il3945_cancel_deferred_work(struct il_priv *priv) { - iwl3945_hw_cancel_deferred_work(priv); + il3945_hw_cancel_deferred_work(priv); cancel_delayed_work_sync(&priv->init_alive_start); cancel_delayed_work(&priv->alive_start); - iwl_legacy_cancel_scan_deferred_work(priv); + il_cancel_scan_deferred_work(priv); } -static struct attribute *iwl3945_sysfs_entries[] = { +static struct attribute *il3945_sysfs_entries[] = { &dev_attr_antenna.attr, &dev_attr_channels.attr, &dev_attr_dump_errors.attr, @@ -3501,34 +3501,34 @@ static struct attribute *iwl3945_sysfs_entries[] = { NULL }; -static struct attribute_group iwl3945_attribute_group = { +static struct attribute_group il3945_attribute_group = { .name = NULL, /* put in device directory */ - .attrs = iwl3945_sysfs_entries, + .attrs = il3945_sysfs_entries, }; -struct ieee80211_ops iwl3945_hw_ops = { - .tx = iwl3945_mac_tx, - .start = iwl3945_mac_start, - .stop = iwl3945_mac_stop, - .add_interface = iwl_legacy_mac_add_interface, - .remove_interface = iwl_legacy_mac_remove_interface, - .change_interface = iwl_legacy_mac_change_interface, - .config = iwl_legacy_mac_config, - .configure_filter = iwl3945_configure_filter, - .set_key = iwl3945_mac_set_key, - .conf_tx = iwl_legacy_mac_conf_tx, - .reset_tsf = iwl_legacy_mac_reset_tsf, - .bss_info_changed = iwl_legacy_mac_bss_info_changed, - .hw_scan = iwl_legacy_mac_hw_scan, - .sta_add = iwl3945_mac_sta_add, - .sta_remove = iwl_legacy_mac_sta_remove, - .tx_last_beacon = iwl_legacy_mac_tx_last_beacon, +struct ieee80211_ops il3945_hw_ops = { + .tx = il3945_mac_tx, + .start = il3945_mac_start, + .stop = il3945_mac_stop, + .add_interface = il_mac_add_interface, + .remove_interface = il_mac_remove_interface, + .change_interface = il_mac_change_interface, + .config = il_mac_config, + .configure_filter = il3945_configure_filter, + .set_key = il3945_mac_set_key, + .conf_tx = il_mac_conf_tx, + .reset_tsf = il_mac_reset_tsf, + .bss_info_changed = il_mac_bss_info_changed, + .hw_scan = il_mac_hw_scan, + .sta_add = il3945_mac_sta_add, + .sta_remove = il_mac_sta_remove, + .tx_last_beacon = il_mac_tx_last_beacon, }; -static int iwl3945_init_drv(struct iwl_priv *priv) +static int il3945_init_drv(struct il_priv *priv) { int ret; - struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; priv->retry_rate = 1; priv->beacon_skb = NULL; @@ -3545,61 +3545,61 @@ static int iwl3945_init_drv(struct iwl_priv *priv) priv->band = IEEE80211_BAND_2GHZ; priv->iw_mode = NL80211_IFTYPE_STATION; - priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF; + priv->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; /* initialize force reset */ - priv->force_reset.reset_duration = IWL_DELAY_NEXT_FORCE_FW_RELOAD; + priv->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; if (eeprom->version < EEPROM_3945_EEPROM_VERSION) { - IWL_WARN(priv, "Unsupported EEPROM version: 0x%04X\n", + IL_WARN(priv, "Unsupported EEPROM version: 0x%04X\n", eeprom->version); ret = -EINVAL; goto err; } - ret = iwl_legacy_init_channel_map(priv); + ret = il_init_channel_map(priv); if (ret) { - IWL_ERR(priv, "initializing regulatory failed: %d\n", ret); + IL_ERR(priv, "initializing regulatory failed: %d\n", ret); goto err; } /* Set up txpower settings in driver for all channels */ - if (iwl3945_txpower_set_from_eeprom(priv)) { + if (il3945_txpower_set_from_eeprom(priv)) { ret = -EIO; goto err_free_channel_map; } - ret = iwl_legacy_init_geos(priv); + ret = il_init_geos(priv); if (ret) { - IWL_ERR(priv, "initializing geos failed: %d\n", ret); + IL_ERR(priv, "initializing geos failed: %d\n", ret); goto err_free_channel_map; } - iwl3945_init_hw_rates(priv, priv->ieee_rates); + il3945_init_hw_rates(priv, priv->ieee_rates); return 0; err_free_channel_map: - iwl_legacy_free_channel_map(priv); + il_free_channel_map(priv); err: return ret; } #define IWL3945_MAX_PROBE_REQUEST 200 -static int iwl3945_setup_mac(struct iwl_priv *priv) +static int il3945_setup_mac(struct il_priv *priv) { int ret; struct ieee80211_hw *hw = priv->hw; hw->rate_control_algorithm = "iwl-3945-rs"; - hw->sta_data_size = sizeof(struct iwl3945_sta_priv); - hw->vif_data_size = sizeof(struct iwl_vif_priv); + hw->sta_data_size = sizeof(struct il3945_sta_priv); + hw->vif_data_size = sizeof(struct il_vif_priv); /* Tell mac80211 our characteristics */ hw->flags = IEEE80211_HW_SIGNAL_DBM | IEEE80211_HW_SPECTRUM_MGMT; hw->wiphy->interface_modes = - priv->contexts[IWL_RXON_CTX_BSS].interface_modes; + priv->contexts[IL_RXON_CTX_BSS].interface_modes; hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | WIPHY_FLAG_DISABLE_BEACON_HINTS | @@ -3620,11 +3620,11 @@ static int iwl3945_setup_mac(struct iwl_priv *priv) priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = &priv->bands[IEEE80211_BAND_5GHZ]; - iwl_legacy_leds_init(priv); + il_leds_init(priv); ret = ieee80211_register_hw(priv->hw); if (ret) { - IWL_ERR(priv, "Failed to register hw (error %d)\n", ret); + IL_ERR(priv, "Failed to register hw (error %d)\n", ret); return ret; } priv->mac80211_registered = 1; @@ -3632,13 +3632,13 @@ static int iwl3945_setup_mac(struct iwl_priv *priv) return 0; } -static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) +static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { int err = 0, i; - struct iwl_priv *priv; + struct il_priv *priv; struct ieee80211_hw *hw; - struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data); - struct iwl3945_eeprom *eeprom; + struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data); + struct il3945_eeprom *eeprom; unsigned long flags; /*********************** @@ -3647,7 +3647,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e /* mac80211 allocates memory for this device instance, including * space for this driver's private structure */ - hw = iwl_legacy_alloc_all(cfg); + hw = il_alloc_all(cfg); if (hw == NULL) { pr_err("Can not allocate network device\n"); err = -ENOMEM; @@ -3659,40 +3659,40 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e priv->cmd_queue = IWL39_CMD_QUEUE_NUM; /* 3945 has only one valid context */ - priv->valid_contexts = BIT(IWL_RXON_CTX_BSS); + priv->valid_contexts = BIT(IL_RXON_CTX_BSS); - for (i = 0; i < NUM_IWL_RXON_CTX; i++) + for (i = 0; i < NUM_IL_RXON_CTX; i++) priv->contexts[i].ctxid = i; - priv->contexts[IWL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON; - priv->contexts[IWL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING; - priv->contexts[IWL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC; - priv->contexts[IWL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM; - priv->contexts[IWL_RXON_CTX_BSS].ap_sta_id = IWL_AP_ID; - priv->contexts[IWL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY; - priv->contexts[IWL_RXON_CTX_BSS].interface_modes = + priv->contexts[IL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON; + priv->contexts[IL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING; + priv->contexts[IL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC; + priv->contexts[IL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM; + priv->contexts[IL_RXON_CTX_BSS].ap_sta_id = IL_AP_ID; + priv->contexts[IL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY; + priv->contexts[IL_RXON_CTX_BSS].interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC); - priv->contexts[IWL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS; - priv->contexts[IWL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS; - priv->contexts[IWL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS; + priv->contexts[IL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS; + priv->contexts[IL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS; + priv->contexts[IL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS; /* * Disabling hardware scan means that mac80211 will perform scans * "the hard way", rather than using device's scan. */ - if (iwl3945_mod_params.disable_hw_scan) { - IWL_DEBUG_INFO(priv, "Disabling hw_scan\n"); - iwl3945_hw_ops.hw_scan = NULL; + if (il3945_mod_params.disable_hw_scan) { + IL_DEBUG_INFO(priv, "Disabling hw_scan\n"); + il3945_hw_ops.hw_scan = NULL; } - IWL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n"); + IL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n"); priv->cfg = cfg; priv->pci_dev = pdev; priv->inta_mask = CSR_INI_SET_MASK; - if (iwl_legacy_alloc_traffic_mem(priv)) - IWL_ERR(priv, "Not enough memory to generate traffic log\n"); + if (il_alloc_traffic_mem(priv)) + IL_ERR(priv, "Not enough memory to generate traffic log\n"); /*************************** * 2. Initializing PCI bus @@ -3711,7 +3711,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e if (!err) err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); if (err) { - IWL_WARN(priv, "No suitable DMA available.\n"); + IL_WARN(priv, "No suitable DMA available.\n"); goto out_pci_disable_device; } @@ -3729,9 +3729,9 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e goto out_pci_release_regions; } - IWL_DEBUG_INFO(priv, "pci_resource_len = 0x%08llx\n", + IL_DEBUG_INFO(priv, "pci_resource_len = 0x%08llx\n", (unsigned long long) pci_resource_len(pdev, 0)); - IWL_DEBUG_INFO(priv, "pci_resource_base = %p\n", priv->hw_base); + IL_DEBUG_INFO(priv, "pci_resource_base = %p\n", priv->hw_base); /* We disable the RETRY_TIMEOUT register (0x41) to keep * PCI Tx retries from interfering with C3 CPU state */ @@ -3748,29 +3748,29 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e * strange state ... like being left stranded by a primary kernel * and this is now the kdump kernel trying to start up */ - iwl_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + il_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); /*********************** * 4. Read EEPROM * ********************/ /* Read the EEPROM */ - err = iwl_legacy_eeprom_init(priv); + err = il_eeprom_init(priv); if (err) { - IWL_ERR(priv, "Unable to init EEPROM\n"); + IL_ERR(priv, "Unable to init EEPROM\n"); goto out_iounmap; } /* MAC Address location in EEPROM same for 3945/4965 */ - eeprom = (struct iwl3945_eeprom *)priv->eeprom; - IWL_DEBUG_INFO(priv, "MAC address: %pM\n", eeprom->mac_address); + eeprom = (struct il3945_eeprom *)priv->eeprom; + IL_DEBUG_INFO(priv, "MAC address: %pM\n", eeprom->mac_address); SET_IEEE80211_PERM_ADDR(priv->hw, eeprom->mac_address); /*********************** * 5. Setup HW Constants * ********************/ /* Device-specific setup */ - if (iwl3945_hw_set_hw_params(priv)) { - IWL_ERR(priv, "failed to set hw settings\n"); + if (il3945_hw_set_hw_params(priv)) { + IL_ERR(priv, "failed to set hw settings\n"); goto out_eeprom_free; } @@ -3778,13 +3778,13 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e * 6. Setup priv * ********************/ - err = iwl3945_init_drv(priv); + err = il3945_init_drv(priv); if (err) { - IWL_ERR(priv, "initializing driver failed\n"); + IL_ERR(priv, "initializing driver failed\n"); goto out_unset_hw_params; } - IWL_INFO(priv, "Detected Intel Wireless WiFi Link %s\n", + IL_INFO(priv, "Detected Intel Wireless WiFi Link %s\n", priv->cfg->name); /*********************** @@ -3792,44 +3792,44 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e * ********************/ spin_lock_irqsave(&priv->lock, flags); - iwl_legacy_disable_interrupts(priv); + il_disable_interrupts(priv); spin_unlock_irqrestore(&priv->lock, flags); pci_enable_msi(priv->pci_dev); - err = request_irq(priv->pci_dev->irq, iwl_legacy_isr, + err = request_irq(priv->pci_dev->irq, il_isr, IRQF_SHARED, DRV_NAME, priv); if (err) { - IWL_ERR(priv, "Error allocating IRQ %d\n", priv->pci_dev->irq); + IL_ERR(priv, "Error allocating IRQ %d\n", priv->pci_dev->irq); goto out_disable_msi; } - err = sysfs_create_group(&pdev->dev.kobj, &iwl3945_attribute_group); + err = sysfs_create_group(&pdev->dev.kobj, &il3945_attribute_group); if (err) { - IWL_ERR(priv, "failed to create sysfs device attributes\n"); + IL_ERR(priv, "failed to create sysfs device attributes\n"); goto out_release_irq; } - iwl_legacy_set_rxon_channel(priv, + il_set_rxon_channel(priv, &priv->bands[IEEE80211_BAND_2GHZ].channels[5], - &priv->contexts[IWL_RXON_CTX_BSS]); - iwl3945_setup_deferred_work(priv); - iwl3945_setup_rx_handlers(priv); - iwl_legacy_power_initialize(priv); + &priv->contexts[IL_RXON_CTX_BSS]); + il3945_setup_deferred_work(priv); + il3945_setup_rx_handlers(priv); + il_power_initialize(priv); /********************************* * 8. Setup and Register mac80211 * *******************************/ - iwl_legacy_enable_interrupts(priv); + il_enable_interrupts(priv); - err = iwl3945_setup_mac(priv); + err = il3945_setup_mac(priv); if (err) goto out_remove_sysfs; - err = iwl_legacy_dbgfs_register(priv, DRV_NAME); + err = il_dbgfs_register(priv, DRV_NAME); if (err) - IWL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err); + IL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err); /* Start monitoring the killswitch */ queue_delayed_work(priv->workqueue, &priv->_3945.rfkill_poll, @@ -3840,17 +3840,17 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e out_remove_sysfs: destroy_workqueue(priv->workqueue); priv->workqueue = NULL; - sysfs_remove_group(&pdev->dev.kobj, &iwl3945_attribute_group); + sysfs_remove_group(&pdev->dev.kobj, &il3945_attribute_group); out_release_irq: free_irq(priv->pci_dev->irq, priv); out_disable_msi: pci_disable_msi(priv->pci_dev); - iwl_legacy_free_geos(priv); - iwl_legacy_free_channel_map(priv); + il_free_geos(priv); + il_free_channel_map(priv); out_unset_hw_params: - iwl3945_unset_hw_params(priv); + il3945_unset_hw_params(priv); out_eeprom_free: - iwl_legacy_eeprom_free(priv); + il_eeprom_free(priv); out_iounmap: pci_iounmap(pdev, priv->hw_base); out_pci_release_regions: @@ -3859,74 +3859,74 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e pci_set_drvdata(pdev, NULL); pci_disable_device(pdev); out_ieee80211_free_hw: - iwl_legacy_free_traffic_mem(priv); + il_free_traffic_mem(priv); ieee80211_free_hw(priv->hw); out: return err; } -static void __devexit iwl3945_pci_remove(struct pci_dev *pdev) +static void __devexit il3945_pci_remove(struct pci_dev *pdev) { - struct iwl_priv *priv = pci_get_drvdata(pdev); + struct il_priv *priv = pci_get_drvdata(pdev); unsigned long flags; if (!priv) return; - IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n"); + IL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n"); - iwl_legacy_dbgfs_unregister(priv); + il_dbgfs_unregister(priv); set_bit(STATUS_EXIT_PENDING, &priv->status); - iwl_legacy_leds_exit(priv); + il_leds_exit(priv); if (priv->mac80211_registered) { ieee80211_unregister_hw(priv->hw); priv->mac80211_registered = 0; } else { - iwl3945_down(priv); + il3945_down(priv); } /* * Make sure device is reset to low power before unloading driver. - * This may be redundant with iwl_down(), but there are paths to - * run iwl_down() without calling apm_ops.stop(), and there are - * paths to avoid running iwl_down() at all before leaving driver. + * This may be redundant with il_down(), but there are paths to + * run il_down() without calling apm_ops.stop(), and there are + * paths to avoid running il_down() at all before leaving driver. * This (inexpensive) call *makes sure* device is reset. */ - iwl_legacy_apm_stop(priv); + il_apm_stop(priv); /* make sure we flush any pending irq or * tasklet for the driver */ spin_lock_irqsave(&priv->lock, flags); - iwl_legacy_disable_interrupts(priv); + il_disable_interrupts(priv); spin_unlock_irqrestore(&priv->lock, flags); - iwl3945_synchronize_irq(priv); + il3945_synchronize_irq(priv); - sysfs_remove_group(&pdev->dev.kobj, &iwl3945_attribute_group); + sysfs_remove_group(&pdev->dev.kobj, &il3945_attribute_group); cancel_delayed_work_sync(&priv->_3945.rfkill_poll); - iwl3945_dealloc_ucode_pci(priv); + il3945_dealloc_ucode_pci(priv); if (priv->rxq.bd) - iwl3945_rx_queue_free(priv, &priv->rxq); - iwl3945_hw_txq_ctx_free(priv); + il3945_rx_queue_free(priv, &priv->rxq); + il3945_hw_txq_ctx_free(priv); - iwl3945_unset_hw_params(priv); + il3945_unset_hw_params(priv); /*netif_stop_queue(dev); */ flush_workqueue(priv->workqueue); - /* ieee80211_unregister_hw calls iwl3945_mac_stop, which flushes + /* ieee80211_unregister_hw calls il3945_mac_stop, which flushes * priv->workqueue... so we can't take down the workqueue * until now... */ destroy_workqueue(priv->workqueue); priv->workqueue = NULL; - iwl_legacy_free_traffic_mem(priv); + il_free_traffic_mem(priv); free_irq(pdev->irq, priv); pci_disable_msi(pdev); @@ -3936,8 +3936,8 @@ static void __devexit iwl3945_pci_remove(struct pci_dev *pdev) pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); - iwl_legacy_free_channel_map(priv); - iwl_legacy_free_geos(priv); + il_free_channel_map(priv); + il_free_geos(priv); kfree(priv->scan_cmd); if (priv->beacon_skb) dev_kfree_skb(priv->beacon_skb); @@ -3952,28 +3952,28 @@ static void __devexit iwl3945_pci_remove(struct pci_dev *pdev) * *****************************************************************************/ -static struct pci_driver iwl3945_driver = { +static struct pci_driver il3945_driver = { .name = DRV_NAME, - .id_table = iwl3945_hw_card_ids, - .probe = iwl3945_pci_probe, - .remove = __devexit_p(iwl3945_pci_remove), - .driver.pm = IWL_LEGACY_PM_OPS, + .id_table = il3945_hw_card_ids, + .probe = il3945_pci_probe, + .remove = __devexit_p(il3945_pci_remove), + .driver.pm = IL_LEGACY_PM_OPS, }; -static int __init iwl3945_init(void) +static int __init il3945_init(void) { int ret; pr_info(DRV_DESCRIPTION ", " DRV_VERSION "\n"); pr_info(DRV_COPYRIGHT "\n"); - ret = iwl3945_rate_control_register(); + ret = il3945_rate_control_register(); if (ret) { pr_err("Unable to register rate control algorithm: %d\n", ret); return ret; } - ret = pci_register_driver(&iwl3945_driver); + ret = pci_register_driver(&il3945_driver); if (ret) { pr_err("Unable to initialize PCI module\n"); goto error_register; @@ -3982,32 +3982,32 @@ static int __init iwl3945_init(void) return ret; error_register: - iwl3945_rate_control_unregister(); + il3945_rate_control_unregister(); return ret; } -static void __exit iwl3945_exit(void) +static void __exit il3945_exit(void) { - pci_unregister_driver(&iwl3945_driver); - iwl3945_rate_control_unregister(); + pci_unregister_driver(&il3945_driver); + il3945_rate_control_unregister(); } MODULE_FIRMWARE(IWL3945_MODULE_FIRMWARE(IWL3945_UCODE_API_MAX)); -module_param_named(antenna, iwl3945_mod_params.antenna, int, S_IRUGO); +module_param_named(antenna, il3945_mod_params.antenna, int, S_IRUGO); MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])"); -module_param_named(swcrypto, iwl3945_mod_params.sw_crypto, int, S_IRUGO); +module_param_named(swcrypto, il3945_mod_params.sw_crypto, int, S_IRUGO); MODULE_PARM_DESC(swcrypto, "using software crypto (default 1 [software])"); -module_param_named(disable_hw_scan, iwl3945_mod_params.disable_hw_scan, +module_param_named(disable_hw_scan, il3945_mod_params.disable_hw_scan, int, S_IRUGO); MODULE_PARM_DESC(disable_hw_scan, "disable hardware scanning (default 1)"); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG module_param_named(debug, iwlegacy_debug_level, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(debug, "debug output mask"); #endif -module_param_named(fw_restart, iwl3945_mod_params.restart_fw, int, S_IRUGO); +module_param_named(fw_restart, il3945_mod_params.restart_fw, int, S_IRUGO); MODULE_PARM_DESC(fw_restart, "restart firmware in case of error"); -module_exit(iwl3945_exit); -module_init(iwl3945_init); +module_exit(il3945_exit); +module_init(il3945_init); diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index fd2f7a40dd9a..bd37c9226e65 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -87,48 +87,48 @@ MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); MODULE_LICENSE("GPL"); MODULE_ALIAS("iwl4965"); -void iwl4965_update_chain_flags(struct iwl_priv *priv) +void il4965_update_chain_flags(struct il_priv *priv) { - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; if (priv->cfg->ops->hcmd->set_rxon_chain) { for_each_context(priv, ctx) { priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); if (ctx->active.rx_chain != ctx->staging.rx_chain) - iwl_legacy_commit_rxon(priv, ctx); + il_commit_rxon(priv, ctx); } } } -static void iwl4965_clear_free_frames(struct iwl_priv *priv) +static void il4965_clear_free_frames(struct il_priv *priv) { struct list_head *element; - IWL_DEBUG_INFO(priv, "%d frames on pre-allocated heap on clear.\n", + IL_DEBUG_INFO(priv, "%d frames on pre-allocated heap on clear.\n", priv->frames_count); while (!list_empty(&priv->free_frames)) { element = priv->free_frames.next; list_del(element); - kfree(list_entry(element, struct iwl_frame, list)); + kfree(list_entry(element, struct il_frame, list)); priv->frames_count--; } if (priv->frames_count) { - IWL_WARN(priv, "%d frames still in use. Did we lose one?\n", + IL_WARN(priv, "%d frames still in use. Did we lose one?\n", priv->frames_count); priv->frames_count = 0; } } -static struct iwl_frame *iwl4965_get_free_frame(struct iwl_priv *priv) +static struct il_frame *il4965_get_free_frame(struct il_priv *priv) { - struct iwl_frame *frame; + struct il_frame *frame; struct list_head *element; if (list_empty(&priv->free_frames)) { frame = kzalloc(sizeof(*frame), GFP_KERNEL); if (!frame) { - IWL_ERR(priv, "Could not allocate frame!\n"); + IL_ERR(priv, "Could not allocate frame!\n"); return NULL; } @@ -138,16 +138,16 @@ static struct iwl_frame *iwl4965_get_free_frame(struct iwl_priv *priv) element = priv->free_frames.next; list_del(element); - return list_entry(element, struct iwl_frame, list); + return list_entry(element, struct il_frame, list); } -static void iwl4965_free_frame(struct iwl_priv *priv, struct iwl_frame *frame) +static void il4965_free_frame(struct il_priv *priv, struct il_frame *frame) { memset(frame, 0, sizeof(*frame)); list_add(&frame->list, &priv->free_frames); } -static u32 iwl4965_fill_beacon_frame(struct iwl_priv *priv, +static u32 il4965_fill_beacon_frame(struct il_priv *priv, struct ieee80211_hdr *hdr, int left) { @@ -165,8 +165,8 @@ static u32 iwl4965_fill_beacon_frame(struct iwl_priv *priv, } /* Parse the beacon frame to find the TIM element and set tim_idx & tim_size */ -static void iwl4965_set_beacon_tim(struct iwl_priv *priv, - struct iwl_tx_beacon_cmd *tx_beacon_cmd, +static void il4965_set_beacon_tim(struct il_priv *priv, + struct il_tx_beacon_cmd *tx_beacon_cmd, u8 *beacon, u32 frame_size) { u16 tim_idx; @@ -188,13 +188,13 @@ static void iwl4965_set_beacon_tim(struct iwl_priv *priv, tx_beacon_cmd->tim_idx = cpu_to_le16(tim_idx); tx_beacon_cmd->tim_size = beacon[tim_idx+1]; } else - IWL_WARN(priv, "Unable to find TIM Element in beacon\n"); + IL_WARN(priv, "Unable to find TIM Element in beacon\n"); } -static unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv, - struct iwl_frame *frame) +static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *priv, + struct il_frame *frame) { - struct iwl_tx_beacon_cmd *tx_beacon_cmd; + struct il_tx_beacon_cmd *tx_beacon_cmd; u32 frame_size; u32 rate_flags; u32 rate; @@ -206,7 +206,7 @@ static unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv, lockdep_assert_held(&priv->mutex); if (!priv->beacon_ctx) { - IWL_ERR(priv, "trying to build beacon w/o beacon context!\n"); + IL_ERR(priv, "trying to build beacon w/o beacon context!\n"); return 0; } @@ -215,7 +215,7 @@ static unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv, memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); /* Set up TX beacon contents */ - frame_size = iwl4965_fill_beacon_frame(priv, tx_beacon_cmd->frame, + frame_size = il4965_fill_beacon_frame(priv, tx_beacon_cmd->frame, sizeof(frame->u) - sizeof(*tx_beacon_cmd)); if (WARN_ON_ONCE(frame_size > MAX_MPDU_SIZE)) return 0; @@ -230,53 +230,53 @@ static unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv, TX_CMD_FLG_TSF_MSK | TX_CMD_FLG_STA_RATE_MSK; /* Set up TX beacon command fields */ - iwl4965_set_beacon_tim(priv, tx_beacon_cmd, (u8 *)tx_beacon_cmd->frame, + il4965_set_beacon_tim(priv, tx_beacon_cmd, (u8 *)tx_beacon_cmd->frame, frame_size); /* Set up packet rate and flags */ - rate = iwl_legacy_get_lowest_plcp(priv, priv->beacon_ctx); - priv->mgmt_tx_ant = iwl4965_toggle_tx_ant(priv, priv->mgmt_tx_ant, + rate = il_get_lowest_plcp(priv, priv->beacon_ctx); + priv->mgmt_tx_ant = il4965_toggle_tx_ant(priv, priv->mgmt_tx_ant, priv->hw_params.valid_tx_ant); - rate_flags = iwl4965_ant_idx_to_flags(priv->mgmt_tx_ant); - if ((rate >= IWL_FIRST_CCK_RATE) && (rate <= IWL_LAST_CCK_RATE)) + rate_flags = il4965_ant_idx_to_flags(priv->mgmt_tx_ant); + if ((rate >= IL_FIRST_CCK_RATE) && (rate <= IL_LAST_CCK_RATE)) rate_flags |= RATE_MCS_CCK_MSK; - tx_beacon_cmd->tx.rate_n_flags = iwl4965_hw_set_rate_n_flags(rate, + tx_beacon_cmd->tx.rate_n_flags = il4965_hw_set_rate_n_flags(rate, rate_flags); return sizeof(*tx_beacon_cmd) + frame_size; } -int iwl4965_send_beacon_cmd(struct iwl_priv *priv) +int il4965_send_beacon_cmd(struct il_priv *priv) { - struct iwl_frame *frame; + struct il_frame *frame; unsigned int frame_size; int rc; - frame = iwl4965_get_free_frame(priv); + frame = il4965_get_free_frame(priv); if (!frame) { - IWL_ERR(priv, "Could not obtain free frame buffer for beacon " + IL_ERR(priv, "Could not obtain free frame buffer for beacon " "command.\n"); return -ENOMEM; } - frame_size = iwl4965_hw_get_beacon_cmd(priv, frame); + frame_size = il4965_hw_get_beacon_cmd(priv, frame); if (!frame_size) { - IWL_ERR(priv, "Error configuring the beacon command\n"); - iwl4965_free_frame(priv, frame); + IL_ERR(priv, "Error configuring the beacon command\n"); + il4965_free_frame(priv, frame); return -EINVAL; } - rc = iwl_legacy_send_cmd_pdu(priv, REPLY_TX_BEACON, frame_size, + rc = il_send_cmd_pdu(priv, REPLY_TX_BEACON, frame_size, &frame->u.cmd[0]); - iwl4965_free_frame(priv, frame); + il4965_free_frame(priv, frame); return rc; } -static inline dma_addr_t iwl4965_tfd_tb_get_addr(struct iwl_tfd *tfd, u8 idx) +static inline dma_addr_t il4965_tfd_tb_get_addr(struct il_tfd *tfd, u8 idx) { - struct iwl_tfd_tb *tb = &tfd->tbs[idx]; + struct il_tfd_tb *tb = &tfd->tbs[idx]; dma_addr_t addr = get_unaligned_le32(&tb->lo); if (sizeof(dma_addr_t) > sizeof(u32)) @@ -286,17 +286,17 @@ static inline dma_addr_t iwl4965_tfd_tb_get_addr(struct iwl_tfd *tfd, u8 idx) return addr; } -static inline u16 iwl4965_tfd_tb_get_len(struct iwl_tfd *tfd, u8 idx) +static inline u16 il4965_tfd_tb_get_len(struct il_tfd *tfd, u8 idx) { - struct iwl_tfd_tb *tb = &tfd->tbs[idx]; + struct il_tfd_tb *tb = &tfd->tbs[idx]; return le16_to_cpu(tb->hi_n_len) >> 4; } -static inline void iwl4965_tfd_set_tb(struct iwl_tfd *tfd, u8 idx, +static inline void il4965_tfd_set_tb(struct il_tfd *tfd, u8 idx, dma_addr_t addr, u16 len) { - struct iwl_tfd_tb *tb = &tfd->tbs[idx]; + struct il_tfd_tb *tb = &tfd->tbs[idx]; u16 hi_n_len = len << 4; put_unaligned_le32(addr, &tb->lo); @@ -308,23 +308,23 @@ static inline void iwl4965_tfd_set_tb(struct iwl_tfd *tfd, u8 idx, tfd->num_tbs = idx + 1; } -static inline u8 iwl4965_tfd_get_num_tbs(struct iwl_tfd *tfd) +static inline u8 il4965_tfd_get_num_tbs(struct il_tfd *tfd) { return tfd->num_tbs & 0x1f; } /** - * iwl4965_hw_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr] + * il4965_hw_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr] * @priv - driver private data * @txq - tx queue * * Does NOT advance any TFD circular buffer read/write indexes * Does NOT free the TFD itself (which is within circular buffer) */ -void iwl4965_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq) +void il4965_hw_txq_free_tfd(struct il_priv *priv, struct il_tx_queue *txq) { - struct iwl_tfd *tfd_tmp = (struct iwl_tfd *)txq->tfds; - struct iwl_tfd *tfd; + struct il_tfd *tfd_tmp = (struct il_tfd *)txq->tfds; + struct il_tfd *tfd; struct pci_dev *dev = priv->pci_dev; int index = txq->q.read_ptr; int i; @@ -333,10 +333,10 @@ void iwl4965_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq) tfd = &tfd_tmp[index]; /* Sanity check on number of chunks */ - num_tbs = iwl4965_tfd_get_num_tbs(tfd); + num_tbs = il4965_tfd_get_num_tbs(tfd); - if (num_tbs >= IWL_NUM_OF_TBS) { - IWL_ERR(priv, "Too many chunks: %i\n", num_tbs); + if (num_tbs >= IL_NUM_OF_TBS) { + IL_ERR(priv, "Too many chunks: %i\n", num_tbs); /* @todo issue fatal error, it is quite serious situation */ return; } @@ -350,8 +350,8 @@ void iwl4965_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq) /* Unmap chunks, if any. */ for (i = 1; i < num_tbs; i++) - pci_unmap_single(dev, iwl4965_tfd_tb_get_addr(tfd, i), - iwl4965_tfd_tb_get_len(tfd, i), + pci_unmap_single(dev, il4965_tfd_tb_get_addr(tfd, i), + il4965_tfd_tb_get_len(tfd, i), PCI_DMA_TODEVICE); /* free SKB */ @@ -368,37 +368,37 @@ void iwl4965_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq) } } -int iwl4965_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, - struct iwl_tx_queue *txq, +int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *priv, + struct il_tx_queue *txq, dma_addr_t addr, u16 len, u8 reset, u8 pad) { - struct iwl_queue *q; - struct iwl_tfd *tfd, *tfd_tmp; + struct il_queue *q; + struct il_tfd *tfd, *tfd_tmp; u32 num_tbs; q = &txq->q; - tfd_tmp = (struct iwl_tfd *)txq->tfds; + tfd_tmp = (struct il_tfd *)txq->tfds; tfd = &tfd_tmp[q->write_ptr]; if (reset) memset(tfd, 0, sizeof(*tfd)); - num_tbs = iwl4965_tfd_get_num_tbs(tfd); + num_tbs = il4965_tfd_get_num_tbs(tfd); /* Each TFD can point to a maximum 20 Tx buffers */ - if (num_tbs >= IWL_NUM_OF_TBS) { - IWL_ERR(priv, "Error can not send more than %d chunks\n", - IWL_NUM_OF_TBS); + if (num_tbs >= IL_NUM_OF_TBS) { + IL_ERR(priv, "Error can not send more than %d chunks\n", + IL_NUM_OF_TBS); return -EINVAL; } BUG_ON(addr & ~DMA_BIT_MASK(36)); - if (unlikely(addr & ~IWL_TX_DMA_MASK)) - IWL_ERR(priv, "Unaligned address = %llx\n", + if (unlikely(addr & ~IL_TX_DMA_MASK)) + IL_ERR(priv, "Unaligned address = %llx\n", (unsigned long long)addr); - iwl4965_tfd_set_tb(tfd, num_tbs, addr, len); + il4965_tfd_set_tb(tfd, num_tbs, addr, len); return 0; } @@ -410,13 +410,13 @@ int iwl4965_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, * 4965 supports up to 16 Tx queues in DRAM, mapped to up to 8 Tx DMA * channels supported in hardware. */ -int iwl4965_hw_tx_queue_init(struct iwl_priv *priv, - struct iwl_tx_queue *txq) +int il4965_hw_tx_queue_init(struct il_priv *priv, + struct il_tx_queue *txq) { int txq_id = txq->q.id; /* Circular buffer (TFD queue in DRAM) physical base address */ - iwl_legacy_write_direct32(priv, FH_MEM_CBBC_QUEUE(txq_id), + il_write_direct32(priv, FH_MEM_CBBC_QUEUE(txq_id), txq->q.dma_addr >> 8); return 0; @@ -427,30 +427,30 @@ int iwl4965_hw_tx_queue_init(struct iwl_priv *priv, * Generic RX handler implementations * ******************************************************************************/ -static void iwl4965_rx_reply_alive(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il4965_rx_reply_alive(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_alive_resp *palive; + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_alive_resp *palive; struct delayed_work *pwork; palive = &pkt->u.alive_frame; - IWL_DEBUG_INFO(priv, "Alive ucode status 0x%08X revision " + IL_DEBUG_INFO(priv, "Alive ucode status 0x%08X revision " "0x%01X 0x%01X\n", palive->is_valid, palive->ver_type, palive->ver_subtype); if (palive->ver_subtype == INITIALIZE_SUBTYPE) { - IWL_DEBUG_INFO(priv, "Initialization Alive received.\n"); + IL_DEBUG_INFO(priv, "Initialization Alive received.\n"); memcpy(&priv->card_alive_init, &pkt->u.alive_frame, - sizeof(struct iwl_init_alive_resp)); + sizeof(struct il_init_alive_resp)); pwork = &priv->init_alive_start; } else { - IWL_DEBUG_INFO(priv, "Runtime Alive received.\n"); + IL_DEBUG_INFO(priv, "Runtime Alive received.\n"); memcpy(&priv->card_alive, &pkt->u.alive_frame, - sizeof(struct iwl_alive_resp)); + sizeof(struct il_alive_resp)); pwork = &priv->alive_start; } @@ -460,11 +460,11 @@ static void iwl4965_rx_reply_alive(struct iwl_priv *priv, queue_delayed_work(priv->workqueue, pwork, msecs_to_jiffies(5)); else - IWL_WARN(priv, "uCode did not respond OK.\n"); + IL_WARN(priv, "uCode did not respond OK.\n"); } /** - * iwl4965_bg_statistics_periodic - Timer callback to queue statistics + * il4965_bg_statistics_periodic - Timer callback to queue statistics * * This callback is provided in order to send a statistics request. * @@ -473,30 +473,30 @@ static void iwl4965_rx_reply_alive(struct iwl_priv *priv, * was received. We need to ensure we receive the statistics in order * to update the temperature used for calibrating the TXPOWER. */ -static void iwl4965_bg_statistics_periodic(unsigned long data) +static void il4965_bg_statistics_periodic(unsigned long data) { - struct iwl_priv *priv = (struct iwl_priv *)data; + struct il_priv *priv = (struct il_priv *)data; if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; /* dont send host command if rf-kill is on */ - if (!iwl_legacy_is_ready_rf(priv)) + if (!il_is_ready_rf(priv)) return; - iwl_legacy_send_statistics_request(priv, CMD_ASYNC, false); + il_send_statistics_request(priv, CMD_ASYNC, false); } -static void iwl4965_rx_beacon_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il4965_rx_beacon_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl4965_beacon_notif *beacon = - (struct iwl4965_beacon_notif *)pkt->u.raw; + struct il_rx_packet *pkt = rxb_addr(rxb); + struct il4965_beacon_notif *beacon = + (struct il4965_beacon_notif *)pkt->u.raw; #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - u8 rate = iwl4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); + u8 rate = il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); - IWL_DEBUG_RX(priv, "beacon status %x retries %d iss %d " + IL_DEBUG_RX(priv, "beacon status %x retries %d iss %d " "tsf %d %d rate %d\n", le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, beacon->beacon_notify_hdr.failure_frame, @@ -508,35 +508,35 @@ static void iwl4965_rx_beacon_notif(struct iwl_priv *priv, priv->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); } -static void iwl4965_perform_ct_kill_task(struct iwl_priv *priv) +static void il4965_perform_ct_kill_task(struct il_priv *priv) { unsigned long flags; - IWL_DEBUG_POWER(priv, "Stop all queues\n"); + IL_DEBUG_POWER(priv, "Stop all queues\n"); if (priv->mac80211_registered) ieee80211_stop_queues(priv->hw); - iwl_write32(priv, CSR_UCODE_DRV_GP1_SET, + il_write32(priv, CSR_UCODE_DRV_GP1_SET, CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); - iwl_read32(priv, CSR_UCODE_DRV_GP1); + il_read32(priv, CSR_UCODE_DRV_GP1); spin_lock_irqsave(&priv->reg_lock, flags); - if (!iwl_grab_nic_access(priv)) - iwl_release_nic_access(priv); + if (!il_grab_nic_access(priv)) + il_release_nic_access(priv); spin_unlock_irqrestore(&priv->reg_lock, flags); } /* Handle notification from uCode that card's power state is changing * due to software, hardware, or critical temperature RFKILL */ -static void iwl4965_rx_card_state_notif(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) +static void il4965_rx_card_state_notif(struct il_priv *priv, + struct il_rx_mem_buffer *rxb) { - struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_packet *pkt = rxb_addr(rxb); u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); unsigned long status = priv->status; - IWL_DEBUG_RF_KILL(priv, "Card state received: HW:%s SW:%s CT:%s\n", + IL_DEBUG_RF_KILL(priv, "Card state received: HW:%s SW:%s CT:%s\n", (flags & HW_CARD_DISABLED) ? "Kill" : "On", (flags & SW_CARD_DISABLED) ? "Kill" : "On", (flags & CT_CARD_DISABLED) ? @@ -545,22 +545,22 @@ static void iwl4965_rx_card_state_notif(struct iwl_priv *priv, if (flags & (SW_CARD_DISABLED | HW_CARD_DISABLED | CT_CARD_DISABLED)) { - iwl_write32(priv, CSR_UCODE_DRV_GP1_SET, + il_write32(priv, CSR_UCODE_DRV_GP1_SET, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - iwl_legacy_write_direct32(priv, HBUS_TARG_MBX_C, + il_write_direct32(priv, HBUS_TARG_MBX_C, HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); if (!(flags & RXON_CARD_DISABLED)) { - iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, + il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - iwl_legacy_write_direct32(priv, HBUS_TARG_MBX_C, + il_write_direct32(priv, HBUS_TARG_MBX_C, HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); } } if (flags & CT_CARD_DISABLED) - iwl4965_perform_ct_kill_task(priv); + il4965_perform_ct_kill_task(priv); if (flags & HW_CARD_DISABLED) set_bit(STATUS_RF_KILL_HW, &priv->status); @@ -568,7 +568,7 @@ static void iwl4965_rx_card_state_notif(struct iwl_priv *priv, clear_bit(STATUS_RF_KILL_HW, &priv->status); if (!(flags & RXON_CARD_DISABLED)) - iwl_legacy_scan_cancel(priv); + il_scan_cancel(priv); if ((test_bit(STATUS_RF_KILL_HW, &status) != test_bit(STATUS_RF_KILL_HW, &priv->status))) @@ -579,7 +579,7 @@ static void iwl4965_rx_card_state_notif(struct iwl_priv *priv, } /** - * iwl4965_setup_rx_handlers - Initialize Rx handler callbacks + * il4965_setup_rx_handlers - Initialize Rx handler callbacks * * Setup the RX handlers for each of the reply types sent from the uCode * to the host. @@ -587,55 +587,55 @@ static void iwl4965_rx_card_state_notif(struct iwl_priv *priv, * This function chains into the hardware specific files for them to setup * any hardware specific handlers as well. */ -static void iwl4965_setup_rx_handlers(struct iwl_priv *priv) +static void il4965_setup_rx_handlers(struct il_priv *priv) { - priv->rx_handlers[REPLY_ALIVE] = iwl4965_rx_reply_alive; - priv->rx_handlers[REPLY_ERROR] = iwl_legacy_rx_reply_error; - priv->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = iwl_legacy_rx_csa; + priv->rx_handlers[REPLY_ALIVE] = il4965_rx_reply_alive; + priv->rx_handlers[REPLY_ERROR] = il_rx_reply_error; + priv->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa; priv->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = - iwl_legacy_rx_spectrum_measure_notif; - priv->rx_handlers[PM_SLEEP_NOTIFICATION] = iwl_legacy_rx_pm_sleep_notif; + il_rx_spectrum_measure_notif; + priv->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; priv->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = - iwl_legacy_rx_pm_debug_statistics_notif; - priv->rx_handlers[BEACON_NOTIFICATION] = iwl4965_rx_beacon_notif; + il_rx_pm_debug_statistics_notif; + priv->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; /* * The same handler is used for both the REPLY to a discrete * statistics request from the host as well as for the periodic * statistics notifications (after received beacons) from the uCode. */ - priv->rx_handlers[REPLY_STATISTICS_CMD] = iwl4965_reply_statistics; - priv->rx_handlers[STATISTICS_NOTIFICATION] = iwl4965_rx_statistics; + priv->rx_handlers[REPLY_STATISTICS_CMD] = il4965_reply_statistics; + priv->rx_handlers[STATISTICS_NOTIFICATION] = il4965_rx_statistics; - iwl_legacy_setup_rx_scan_handlers(priv); + il_setup_rx_scan_handlers(priv); /* status change handler */ priv->rx_handlers[CARD_STATE_NOTIFICATION] = - iwl4965_rx_card_state_notif; + il4965_rx_card_state_notif; priv->rx_handlers[MISSED_BEACONS_NOTIFICATION] = - iwl4965_rx_missed_beacon_notif; + il4965_rx_missed_beacon_notif; /* Rx handlers */ - priv->rx_handlers[REPLY_RX_PHY_CMD] = iwl4965_rx_reply_rx_phy; - priv->rx_handlers[REPLY_RX_MPDU_CMD] = iwl4965_rx_reply_rx; + priv->rx_handlers[REPLY_RX_PHY_CMD] = il4965_rx_reply_rx_phy; + priv->rx_handlers[REPLY_RX_MPDU_CMD] = il4965_rx_reply_rx; /* block ack */ - priv->rx_handlers[REPLY_COMPRESSED_BA] = iwl4965_rx_reply_compressed_ba; + priv->rx_handlers[REPLY_COMPRESSED_BA] = il4965_rx_reply_compressed_ba; /* Set up hardware specific Rx handlers */ priv->cfg->ops->lib->rx_handler_setup(priv); } /** - * iwl4965_rx_handle - Main entry function for receiving responses from uCode + * il4965_rx_handle - Main entry function for receiving responses from uCode * * Uses the priv->rx_handlers callback function array to invoke * the appropriate handlers, including command responses, * frame-received notifications, and other notifications. */ -void iwl4965_rx_handle(struct iwl_priv *priv) +void il4965_rx_handle(struct il_priv *priv) { - struct iwl_rx_mem_buffer *rxb; - struct iwl_rx_packet *pkt; - struct iwl_rx_queue *rxq = &priv->rxq; + struct il_rx_mem_buffer *rxb; + struct il_rx_packet *pkt; + struct il_rx_queue *rxq = &priv->rxq; u32 r, i; int reclaim; unsigned long flags; @@ -650,7 +650,7 @@ void iwl4965_rx_handle(struct iwl_priv *priv) /* Rx interrupt, but nothing sent from uCode */ if (i == r) - IWL_DEBUG_RX(priv, "r = %d, i = %d\n", r, i); + IL_DEBUG_RX(priv, "r = %d, i = %d\n", r, i); /* calculate total frames need to be restock after handling RX */ total_empty = r - rxq->write_actual; @@ -696,18 +696,18 @@ void iwl4965_rx_handle(struct iwl_priv *priv) /* Based on type of command response or notification, * handle those that need handling via function in - * rx_handlers table. See iwl4965_setup_rx_handlers() */ + * rx_handlers table. See il4965_setup_rx_handlers() */ if (priv->rx_handlers[pkt->hdr.cmd]) { - IWL_DEBUG_RX(priv, "r = %d, i = %d, %s, 0x%02x\n", r, - i, iwl_legacy_get_cmd_string(pkt->hdr.cmd), + IL_DEBUG_RX(priv, "r = %d, i = %d, %s, 0x%02x\n", r, + i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); priv->isr_stats.rx_handlers[pkt->hdr.cmd]++; priv->rx_handlers[pkt->hdr.cmd] (priv, rxb); } else { /* No handling needed */ - IWL_DEBUG_RX(priv, + IL_DEBUG_RX(priv, "r %d i %d No handler needed for %s, 0x%02x\n", - r, i, iwl_legacy_get_cmd_string(pkt->hdr.cmd), + r, i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); } @@ -720,12 +720,12 @@ void iwl4965_rx_handle(struct iwl_priv *priv) if (reclaim) { /* Invoke any callbacks, transfer the buffer to caller, - * and fire off the (possibly) blocking iwl_legacy_send_cmd() + * and fire off the (possibly) blocking il_send_cmd() * as we reclaim the driver command queue */ if (rxb->page) - iwl_legacy_tx_cmd_complete(priv, rxb); + il_tx_cmd_complete(priv, rxb); else - IWL_WARN(priv, "Claim null rxb?\n"); + IL_WARN(priv, "Claim null rxb?\n"); } /* Reuse the page if possible. For notification packets and @@ -750,7 +750,7 @@ void iwl4965_rx_handle(struct iwl_priv *priv) count++; if (count >= 8) { rxq->read = i; - iwl4965_rx_replenish_now(priv); + il4965_rx_replenish_now(priv); count = 0; } } @@ -759,20 +759,20 @@ void iwl4965_rx_handle(struct iwl_priv *priv) /* Backtrack one entry */ rxq->read = i; if (fill_rx) - iwl4965_rx_replenish_now(priv); + il4965_rx_replenish_now(priv); else - iwl4965_rx_queue_restock(priv); + il4965_rx_queue_restock(priv); } /* call this function to flush any scheduled tasklet */ -static inline void iwl4965_synchronize_irq(struct iwl_priv *priv) +static inline void il4965_synchronize_irq(struct il_priv *priv) { /* wait to make sure we flush pending tasklet*/ synchronize_irq(priv->pci_dev->irq); tasklet_kill(&priv->irq_tasklet); } -static void iwl4965_irq_tasklet(struct iwl_priv *priv) +static void il4965_irq_tasklet(struct il_priv *priv) { u32 inta, handled = 0; u32 inta_fh; @@ -787,20 +787,20 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) /* Ack/clear/reset pending uCode interrupts. * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS, * and will clear only when CSR_FH_INT_STATUS gets cleared. */ - inta = iwl_read32(priv, CSR_INT); - iwl_write32(priv, CSR_INT, inta); + inta = il_read32(priv, CSR_INT); + il_write32(priv, CSR_INT, inta); /* Ack/clear/reset pending flow-handler (DMA) interrupts. * Any new interrupts that happen after this, either while we're * in this tasklet, or later, will show up in next ISR/tasklet. */ - inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS); - iwl_write32(priv, CSR_FH_INT_STATUS, inta_fh); + inta_fh = il_read32(priv, CSR_FH_INT_STATUS); + il_write32(priv, CSR_FH_INT_STATUS, inta_fh); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (iwl_legacy_get_debug_level(priv) & IWL_DL_ISR) { + if (il_get_debug_level(priv) & IL_DL_ISR) { /* just for debug */ - inta_mask = iwl_read32(priv, CSR_INT_MASK); - IWL_DEBUG_ISR(priv, "inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", + inta_mask = il_read32(priv, CSR_INT_MASK); + IL_DEBUG_ISR(priv, "inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, inta_mask, inta_fh); } #endif @@ -818,13 +818,13 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) /* Now service all interrupt bits discovered above. */ if (inta & CSR_INT_BIT_HW_ERR) { - IWL_ERR(priv, "Hardware error detected. Restarting.\n"); + IL_ERR(priv, "Hardware error detected. Restarting.\n"); /* Tell the device to stop sending interrupts */ - iwl_legacy_disable_interrupts(priv); + il_disable_interrupts(priv); priv->isr_stats.hw++; - iwl_legacy_irq_handle_error(priv); + il_irq_handle_error(priv); handled |= CSR_INT_BIT_HW_ERR; @@ -832,17 +832,17 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (iwl_legacy_get_debug_level(priv) & (IWL_DL_ISR)) { + if (il_get_debug_level(priv) & (IL_DL_ISR)) { /* NIC fires this, but we don't use it, redundant with WAKEUP */ if (inta & CSR_INT_BIT_SCD) { - IWL_DEBUG_ISR(priv, "Scheduler finished to transmit " + IL_DEBUG_ISR(priv, "Scheduler finished to transmit " "the frame/frames.\n"); priv->isr_stats.sch++; } /* Alive notification via Rx interrupt will do the real work */ if (inta & CSR_INT_BIT_ALIVE) { - IWL_DEBUG_ISR(priv, "Alive interrupt\n"); + IL_DEBUG_ISR(priv, "Alive interrupt\n"); priv->isr_stats.alive++; } } @@ -853,11 +853,11 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) /* HW RF KILL switch toggled */ if (inta & CSR_INT_BIT_RF_KILL) { int hw_rf_kill = 0; - if (!(iwl_read32(priv, CSR_GP_CNTRL) & + if (!(il_read32(priv, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) hw_rf_kill = 1; - IWL_WARN(priv, "RF_KILL bit toggled to %s.\n", + IL_WARN(priv, "RF_KILL bit toggled to %s.\n", hw_rf_kill ? "disable radio" : "enable radio"); priv->isr_stats.rfkill++; @@ -880,17 +880,17 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) /* Chip got too hot and stopped itself */ if (inta & CSR_INT_BIT_CT_KILL) { - IWL_ERR(priv, "Microcode CT kill error detected.\n"); + IL_ERR(priv, "Microcode CT kill error detected.\n"); priv->isr_stats.ctkill++; handled |= CSR_INT_BIT_CT_KILL; } /* Error detected by uCode */ if (inta & CSR_INT_BIT_SW_ERR) { - IWL_ERR(priv, "Microcode SW error detected. " + IL_ERR(priv, "Microcode SW error detected. " " Restarting 0x%X.\n", inta); priv->isr_stats.sw++; - iwl_legacy_irq_handle_error(priv); + il_irq_handle_error(priv); handled |= CSR_INT_BIT_SW_ERR; } @@ -900,10 +900,10 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) * and about any Rx buffers made available while asleep. */ if (inta & CSR_INT_BIT_WAKEUP) { - IWL_DEBUG_ISR(priv, "Wakeup interrupt\n"); - iwl_legacy_rx_queue_update_write_ptr(priv, &priv->rxq); + IL_DEBUG_ISR(priv, "Wakeup interrupt\n"); + il_rx_queue_update_write_ptr(priv, &priv->rxq); for (i = 0; i < priv->hw_params.max_txq_num; i++) - iwl_legacy_txq_update_write_ptr(priv, &priv->txq[i]); + il_txq_update_write_ptr(priv, &priv->txq[i]); priv->isr_stats.wakeup++; handled |= CSR_INT_BIT_WAKEUP; } @@ -912,14 +912,14 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) * Rx "responses" (frame-received notification), and other * notifications from uCode come through here*/ if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) { - iwl4965_rx_handle(priv); + il4965_rx_handle(priv); priv->isr_stats.rx++; handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX); } /* This "Tx" DMA channel is used only for loading uCode */ if (inta & CSR_INT_BIT_FH_TX) { - IWL_DEBUG_ISR(priv, "uCode load interrupt\n"); + IL_DEBUG_ISR(priv, "uCode load interrupt\n"); priv->isr_stats.tx++; handled |= CSR_INT_BIT_FH_TX; /* Wake up uCode load routine, now that load is complete */ @@ -928,30 +928,30 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) } if (inta & ~handled) { - IWL_ERR(priv, "Unhandled INTA bits 0x%08x\n", inta & ~handled); + IL_ERR(priv, "Unhandled INTA bits 0x%08x\n", inta & ~handled); priv->isr_stats.unhandled++; } if (inta & ~(priv->inta_mask)) { - IWL_WARN(priv, "Disabled INTA bits 0x%08x were pending\n", + IL_WARN(priv, "Disabled INTA bits 0x%08x were pending\n", inta & ~priv->inta_mask); - IWL_WARN(priv, " with FH_INT = 0x%08x\n", inta_fh); + IL_WARN(priv, " with FH_INT = 0x%08x\n", inta_fh); } /* Re-enable all interrupts */ /* only Re-enable if disabled by irq */ if (test_bit(STATUS_INT_ENABLED, &priv->status)) - iwl_legacy_enable_interrupts(priv); + il_enable_interrupts(priv); /* Re-enable RF_KILL if it occurred */ else if (handled & CSR_INT_BIT_RF_KILL) - iwl_legacy_enable_rfkill_int(priv); + il_enable_rfkill_int(priv); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (iwl_legacy_get_debug_level(priv) & (IWL_DL_ISR)) { - inta = iwl_read32(priv, CSR_INT); - inta_mask = iwl_read32(priv, CSR_INT_MASK); - inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS); - IWL_DEBUG_ISR(priv, + if (il_get_debug_level(priv) & (IL_DL_ISR)) { + inta = il_read32(priv, CSR_INT); + inta_mask = il_read32(priv, CSR_INT_MASK); + inta_fh = il_read32(priv, CSR_FH_INT_STATUS); + IL_DEBUG_ISR(priv, "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); } @@ -977,78 +977,78 @@ static void iwl4965_irq_tasklet(struct iwl_priv *priv) * level that is used instead of the global debug level if it (the per * device debug level) is set. */ -static ssize_t iwl4965_show_debug_level(struct device *d, +static ssize_t il4965_show_debug_level(struct device *d, struct device_attribute *attr, char *buf) { - struct iwl_priv *priv = dev_get_drvdata(d); - return sprintf(buf, "0x%08X\n", iwl_legacy_get_debug_level(priv)); + struct il_priv *priv = dev_get_drvdata(d); + return sprintf(buf, "0x%08X\n", il_get_debug_level(priv)); } -static ssize_t iwl4965_store_debug_level(struct device *d, +static ssize_t il4965_store_debug_level(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); unsigned long val; int ret; ret = strict_strtoul(buf, 0, &val); if (ret) - IWL_ERR(priv, "%s is not in hex or decimal form.\n", buf); + IL_ERR(priv, "%s is not in hex or decimal form.\n", buf); else { priv->debug_level = val; - if (iwl_legacy_alloc_traffic_mem(priv)) - IWL_ERR(priv, + if (il_alloc_traffic_mem(priv)) + IL_ERR(priv, "Not enough memory to generate traffic log\n"); } return strnlen(buf, count); } static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, - iwl4965_show_debug_level, iwl4965_store_debug_level); + il4965_show_debug_level, il4965_store_debug_level); #endif /* CONFIG_IWLWIFI_LEGACY_DEBUG */ -static ssize_t iwl4965_show_temperature(struct device *d, +static ssize_t il4965_show_temperature(struct device *d, struct device_attribute *attr, char *buf) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); - if (!iwl_legacy_is_alive(priv)) + if (!il_is_alive(priv)) return -EAGAIN; return sprintf(buf, "%d\n", priv->temperature); } -static DEVICE_ATTR(temperature, S_IRUGO, iwl4965_show_temperature, NULL); +static DEVICE_ATTR(temperature, S_IRUGO, il4965_show_temperature, NULL); -static ssize_t iwl4965_show_tx_power(struct device *d, +static ssize_t il4965_show_tx_power(struct device *d, struct device_attribute *attr, char *buf) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); - if (!iwl_legacy_is_ready_rf(priv)) + if (!il_is_ready_rf(priv)) return sprintf(buf, "off\n"); else return sprintf(buf, "%d\n", priv->tx_power_user_lmt); } -static ssize_t iwl4965_store_tx_power(struct device *d, +static ssize_t il4965_store_tx_power(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct iwl_priv *priv = dev_get_drvdata(d); + struct il_priv *priv = dev_get_drvdata(d); unsigned long val; int ret; ret = strict_strtoul(buf, 10, &val); if (ret) - IWL_INFO(priv, "%s is not in decimal form.\n", buf); + IL_INFO(priv, "%s is not in decimal form.\n", buf); else { - ret = iwl_legacy_set_tx_power(priv, val, false); + ret = il_set_tx_power(priv, val, false); if (ret) - IWL_ERR(priv, "failed setting tx power (0x%d).\n", + IL_ERR(priv, "failed setting tx power (0x%d).\n", ret); else ret = count; @@ -1057,9 +1057,9 @@ static ssize_t iwl4965_store_tx_power(struct device *d, } static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, - iwl4965_show_tx_power, iwl4965_store_tx_power); + il4965_show_tx_power, il4965_store_tx_power); -static struct attribute *iwl_sysfs_entries[] = { +static struct attribute *il_sysfs_entries[] = { &dev_attr_temperature.attr, &dev_attr_tx_power.attr, #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG @@ -1068,9 +1068,9 @@ static struct attribute *iwl_sysfs_entries[] = { NULL }; -static struct attribute_group iwl_attribute_group = { +static struct attribute_group il_attribute_group = { .name = NULL, /* put in device directory */ - .attrs = iwl_sysfs_entries, + .attrs = il_sysfs_entries, }; /****************************************************************************** @@ -1079,28 +1079,28 @@ static struct attribute_group iwl_attribute_group = { * ******************************************************************************/ -static void iwl4965_dealloc_ucode_pci(struct iwl_priv *priv) +static void il4965_dealloc_ucode_pci(struct il_priv *priv) { - iwl_legacy_free_fw_desc(priv->pci_dev, &priv->ucode_code); - iwl_legacy_free_fw_desc(priv->pci_dev, &priv->ucode_data); - iwl_legacy_free_fw_desc(priv->pci_dev, &priv->ucode_data_backup); - iwl_legacy_free_fw_desc(priv->pci_dev, &priv->ucode_init); - iwl_legacy_free_fw_desc(priv->pci_dev, &priv->ucode_init_data); - iwl_legacy_free_fw_desc(priv->pci_dev, &priv->ucode_boot); + il_free_fw_desc(priv->pci_dev, &priv->ucode_code); + il_free_fw_desc(priv->pci_dev, &priv->ucode_data); + il_free_fw_desc(priv->pci_dev, &priv->ucode_data_backup); + il_free_fw_desc(priv->pci_dev, &priv->ucode_init); + il_free_fw_desc(priv->pci_dev, &priv->ucode_init_data); + il_free_fw_desc(priv->pci_dev, &priv->ucode_boot); } -static void iwl4965_nic_start(struct iwl_priv *priv) +static void il4965_nic_start(struct il_priv *priv) { /* Remove all resets to allow NIC to operate */ - iwl_write32(priv, CSR_RESET, 0); + il_write32(priv, CSR_RESET, 0); } -static void iwl4965_ucode_callback(const struct firmware *ucode_raw, +static void il4965_ucode_callback(const struct firmware *ucode_raw, void *context); -static int iwl4965_mac_setup_register(struct iwl_priv *priv, +static int il4965_mac_setup_register(struct il_priv *priv, u32 max_probe_length); -static int __must_check iwl4965_request_firmware(struct iwl_priv *priv, bool first) +static int __must_check il4965_request_firmware(struct il_priv *priv, bool first) { const char *name_pre = priv->cfg->fw_name_pre; char tag[8]; @@ -1114,35 +1114,35 @@ static int __must_check iwl4965_request_firmware(struct iwl_priv *priv, bool fir } if (priv->fw_index < priv->cfg->ucode_api_min) { - IWL_ERR(priv, "no suitable firmware found!\n"); + IL_ERR(priv, "no suitable firmware found!\n"); return -ENOENT; } sprintf(priv->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); - IWL_DEBUG_INFO(priv, "attempting to load firmware '%s'\n", + IL_DEBUG_INFO(priv, "attempting to load firmware '%s'\n", priv->firmware_name); return request_firmware_nowait(THIS_MODULE, 1, priv->firmware_name, &priv->pci_dev->dev, GFP_KERNEL, priv, - iwl4965_ucode_callback); + il4965_ucode_callback); } -struct iwl4965_firmware_pieces { +struct il4965_firmware_pieces { const void *inst, *data, *init, *init_data, *boot; size_t inst_size, data_size, init_size, init_data_size, boot_size; }; -static int iwl4965_load_firmware(struct iwl_priv *priv, +static int il4965_load_firmware(struct il_priv *priv, const struct firmware *ucode_raw, - struct iwl4965_firmware_pieces *pieces) + struct il4965_firmware_pieces *pieces) { - struct iwl_ucode_header *ucode = (void *)ucode_raw->data; + struct il_ucode_header *ucode = (void *)ucode_raw->data; u32 api_ver, hdr_size; const u8 *src; priv->ucode_ver = le32_to_cpu(ucode->ver); - api_ver = IWL_UCODE_API(priv->ucode_ver); + api_ver = IL_UCODE_API(priv->ucode_ver); switch (api_ver) { default: @@ -1151,7 +1151,7 @@ static int iwl4965_load_firmware(struct iwl_priv *priv, case 2: hdr_size = 24; if (ucode_raw->size < hdr_size) { - IWL_ERR(priv, "File size too small!\n"); + IL_ERR(priv, "File size too small!\n"); return -EINVAL; } pieces->inst_size = le32_to_cpu(ucode->v1.inst_size); @@ -1169,7 +1169,7 @@ static int iwl4965_load_firmware(struct iwl_priv *priv, pieces->data_size + pieces->init_size + pieces->init_data_size + pieces->boot_size) { - IWL_ERR(priv, + IL_ERR(priv, "uCode file size %d does not match expected size\n", (int)ucode_raw->size); return -EINVAL; @@ -1190,54 +1190,54 @@ static int iwl4965_load_firmware(struct iwl_priv *priv, } /** - * iwl4965_ucode_callback - callback when firmware was loaded + * il4965_ucode_callback - callback when firmware was loaded * * If loaded successfully, copies the firmware into buffers * for the card to fetch (via DMA). */ static void -iwl4965_ucode_callback(const struct firmware *ucode_raw, void *context) +il4965_ucode_callback(const struct firmware *ucode_raw, void *context) { - struct iwl_priv *priv = context; - struct iwl_ucode_header *ucode; + struct il_priv *priv = context; + struct il_ucode_header *ucode; int err; - struct iwl4965_firmware_pieces pieces; + struct il4965_firmware_pieces pieces; const unsigned int api_max = priv->cfg->ucode_api_max; const unsigned int api_min = priv->cfg->ucode_api_min; u32 api_ver; u32 max_probe_length = 200; u32 standard_phy_calibration_size = - IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE; + IL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE; memset(&pieces, 0, sizeof(pieces)); if (!ucode_raw) { if (priv->fw_index <= priv->cfg->ucode_api_max) - IWL_ERR(priv, + IL_ERR(priv, "request for firmware file '%s' failed.\n", priv->firmware_name); goto try_again; } - IWL_DEBUG_INFO(priv, "Loaded firmware file '%s' (%zd bytes).\n", + IL_DEBUG_INFO(priv, "Loaded firmware file '%s' (%zd bytes).\n", priv->firmware_name, ucode_raw->size); /* Make sure that we got at least the API version number */ if (ucode_raw->size < 4) { - IWL_ERR(priv, "File size way too small!\n"); + IL_ERR(priv, "File size way too small!\n"); goto try_again; } /* Data from ucode file: header followed by uCode images */ - ucode = (struct iwl_ucode_header *)ucode_raw->data; + ucode = (struct il_ucode_header *)ucode_raw->data; - err = iwl4965_load_firmware(priv, ucode_raw, &pieces); + err = il4965_load_firmware(priv, ucode_raw, &pieces); if (err) goto try_again; - api_ver = IWL_UCODE_API(priv->ucode_ver); + api_ver = IL_UCODE_API(priv->ucode_ver); /* * api_ver should match the api version forming part of the @@ -1245,7 +1245,7 @@ iwl4965_ucode_callback(const struct firmware *ucode_raw, void *context) * on the API version read from firmware header from here on forward */ if (api_ver < api_min || api_ver > api_max) { - IWL_ERR(priv, + IL_ERR(priv, "Driver unable to support your firmware API. " "Driver supports v%u, firmware is v%u.\n", api_max, api_ver); @@ -1253,25 +1253,25 @@ iwl4965_ucode_callback(const struct firmware *ucode_raw, void *context) } if (api_ver != api_max) - IWL_ERR(priv, + IL_ERR(priv, "Firmware has old API version. Expected v%u, " "got v%u. New firmware can be obtained " "from http://www.intellinuxwireless.org.\n", api_max, api_ver); - IWL_INFO(priv, "loaded firmware version %u.%u.%u.%u\n", - IWL_UCODE_MAJOR(priv->ucode_ver), - IWL_UCODE_MINOR(priv->ucode_ver), - IWL_UCODE_API(priv->ucode_ver), - IWL_UCODE_SERIAL(priv->ucode_ver)); + IL_INFO(priv, "loaded firmware version %u.%u.%u.%u\n", + IL_UCODE_MAJOR(priv->ucode_ver), + IL_UCODE_MINOR(priv->ucode_ver), + IL_UCODE_API(priv->ucode_ver), + IL_UCODE_SERIAL(priv->ucode_ver)); snprintf(priv->hw->wiphy->fw_version, sizeof(priv->hw->wiphy->fw_version), "%u.%u.%u.%u", - IWL_UCODE_MAJOR(priv->ucode_ver), - IWL_UCODE_MINOR(priv->ucode_ver), - IWL_UCODE_API(priv->ucode_ver), - IWL_UCODE_SERIAL(priv->ucode_ver)); + IL_UCODE_MAJOR(priv->ucode_ver), + IL_UCODE_MINOR(priv->ucode_ver), + IL_UCODE_API(priv->ucode_ver), + IL_UCODE_SERIAL(priv->ucode_ver)); /* * For any of the failures below (before allocating pci memory) @@ -1279,46 +1279,46 @@ iwl4965_ucode_callback(const struct firmware *ucode_raw, void *context) * user just got a corrupted version of the latest API. */ - IWL_DEBUG_INFO(priv, "f/w package hdr ucode version raw = 0x%x\n", + IL_DEBUG_INFO(priv, "f/w package hdr ucode version raw = 0x%x\n", priv->ucode_ver); - IWL_DEBUG_INFO(priv, "f/w package hdr runtime inst size = %Zd\n", + IL_DEBUG_INFO(priv, "f/w package hdr runtime inst size = %Zd\n", pieces.inst_size); - IWL_DEBUG_INFO(priv, "f/w package hdr runtime data size = %Zd\n", + IL_DEBUG_INFO(priv, "f/w package hdr runtime data size = %Zd\n", pieces.data_size); - IWL_DEBUG_INFO(priv, "f/w package hdr init inst size = %Zd\n", + IL_DEBUG_INFO(priv, "f/w package hdr init inst size = %Zd\n", pieces.init_size); - IWL_DEBUG_INFO(priv, "f/w package hdr init data size = %Zd\n", + IL_DEBUG_INFO(priv, "f/w package hdr init data size = %Zd\n", pieces.init_data_size); - IWL_DEBUG_INFO(priv, "f/w package hdr boot inst size = %Zd\n", + IL_DEBUG_INFO(priv, "f/w package hdr boot inst size = %Zd\n", pieces.boot_size); /* Verify that uCode images will fit in card's SRAM */ if (pieces.inst_size > priv->hw_params.max_inst_size) { - IWL_ERR(priv, "uCode instr len %Zd too large to fit in\n", + IL_ERR(priv, "uCode instr len %Zd too large to fit in\n", pieces.inst_size); goto try_again; } if (pieces.data_size > priv->hw_params.max_data_size) { - IWL_ERR(priv, "uCode data len %Zd too large to fit in\n", + IL_ERR(priv, "uCode data len %Zd too large to fit in\n", pieces.data_size); goto try_again; } if (pieces.init_size > priv->hw_params.max_inst_size) { - IWL_ERR(priv, "uCode init instr len %Zd too large to fit in\n", + IL_ERR(priv, "uCode init instr len %Zd too large to fit in\n", pieces.init_size); goto try_again; } if (pieces.init_data_size > priv->hw_params.max_data_size) { - IWL_ERR(priv, "uCode init data len %Zd too large to fit in\n", + IL_ERR(priv, "uCode init data len %Zd too large to fit in\n", pieces.init_data_size); goto try_again; } if (pieces.boot_size > priv->hw_params.max_bsm_size) { - IWL_ERR(priv, "uCode boot instr len %Zd too large to fit in\n", + IL_ERR(priv, "uCode boot instr len %Zd too large to fit in\n", pieces.boot_size); goto try_again; } @@ -1329,13 +1329,13 @@ iwl4965_ucode_callback(const struct firmware *ucode_raw, void *context) * 1) unmodified from disk * 2) backup cache for save/restore during power-downs */ priv->ucode_code.len = pieces.inst_size; - iwl_legacy_alloc_fw_desc(priv->pci_dev, &priv->ucode_code); + il_alloc_fw_desc(priv->pci_dev, &priv->ucode_code); priv->ucode_data.len = pieces.data_size; - iwl_legacy_alloc_fw_desc(priv->pci_dev, &priv->ucode_data); + il_alloc_fw_desc(priv->pci_dev, &priv->ucode_data); priv->ucode_data_backup.len = pieces.data_size; - iwl_legacy_alloc_fw_desc(priv->pci_dev, &priv->ucode_data_backup); + il_alloc_fw_desc(priv->pci_dev, &priv->ucode_data_backup); if (!priv->ucode_code.v_addr || !priv->ucode_data.v_addr || !priv->ucode_data_backup.v_addr) @@ -1344,10 +1344,10 @@ iwl4965_ucode_callback(const struct firmware *ucode_raw, void *context) /* Initialization instructions and data */ if (pieces.init_size && pieces.init_data_size) { priv->ucode_init.len = pieces.init_size; - iwl_legacy_alloc_fw_desc(priv->pci_dev, &priv->ucode_init); + il_alloc_fw_desc(priv->pci_dev, &priv->ucode_init); priv->ucode_init_data.len = pieces.init_data_size; - iwl_legacy_alloc_fw_desc(priv->pci_dev, &priv->ucode_init_data); + il_alloc_fw_desc(priv->pci_dev, &priv->ucode_init_data); if (!priv->ucode_init.v_addr || !priv->ucode_init_data.v_addr) goto err_pci_alloc; @@ -1356,7 +1356,7 @@ iwl4965_ucode_callback(const struct firmware *ucode_raw, void *context) /* Bootstrap (instructions only, no data) */ if (pieces.boot_size) { priv->ucode_boot.len = pieces.boot_size; - iwl_legacy_alloc_fw_desc(priv->pci_dev, &priv->ucode_boot); + il_alloc_fw_desc(priv->pci_dev, &priv->ucode_boot); if (!priv->ucode_boot.v_addr) goto err_pci_alloc; @@ -1369,25 +1369,25 @@ iwl4965_ucode_callback(const struct firmware *ucode_raw, void *context) /* Copy images into buffers for card's bus-master reads ... */ /* Runtime instructions (first block of data in file) */ - IWL_DEBUG_INFO(priv, "Copying (but not loading) uCode instr len %Zd\n", + IL_DEBUG_INFO(priv, "Copying (but not loading) uCode instr len %Zd\n", pieces.inst_size); memcpy(priv->ucode_code.v_addr, pieces.inst, pieces.inst_size); - IWL_DEBUG_INFO(priv, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", + IL_DEBUG_INFO(priv, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", priv->ucode_code.v_addr, (u32)priv->ucode_code.p_addr); /* * Runtime data - * NOTE: Copy into backup buffer will be done in iwl_up() + * NOTE: Copy into backup buffer will be done in il_up() */ - IWL_DEBUG_INFO(priv, "Copying (but not loading) uCode data len %Zd\n", + IL_DEBUG_INFO(priv, "Copying (but not loading) uCode data len %Zd\n", pieces.data_size); memcpy(priv->ucode_data.v_addr, pieces.data, pieces.data_size); memcpy(priv->ucode_data_backup.v_addr, pieces.data, pieces.data_size); /* Initialization instructions */ if (pieces.init_size) { - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "Copying (but not loading) init instr len %Zd\n", pieces.init_size); memcpy(priv->ucode_init.v_addr, pieces.init, pieces.init_size); @@ -1395,7 +1395,7 @@ iwl4965_ucode_callback(const struct firmware *ucode_raw, void *context) /* Initialization data */ if (pieces.init_data_size) { - IWL_DEBUG_INFO(priv, + IL_DEBUG_INFO(priv, "Copying (but not loading) init data len %Zd\n", pieces.init_data_size); memcpy(priv->ucode_init_data.v_addr, pieces.init_data, @@ -1403,7 +1403,7 @@ iwl4965_ucode_callback(const struct firmware *ucode_raw, void *context) } /* Bootstrap instructions */ - IWL_DEBUG_INFO(priv, "Copying (but not loading) boot instr len %Zd\n", + IL_DEBUG_INFO(priv, "Copying (but not loading) boot instr len %Zd\n", pieces.boot_size); memcpy(priv->ucode_boot.v_addr, pieces.boot, pieces.boot_size); @@ -1421,19 +1421,19 @@ iwl4965_ucode_callback(const struct firmware *ucode_raw, void *context) * * 9. Setup and register with mac80211 and debugfs **************************************************/ - err = iwl4965_mac_setup_register(priv, max_probe_length); + err = il4965_mac_setup_register(priv, max_probe_length); if (err) goto out_unbind; - err = iwl_legacy_dbgfs_register(priv, DRV_NAME); + err = il_dbgfs_register(priv, DRV_NAME); if (err) - IWL_ERR(priv, + IL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err); err = sysfs_create_group(&priv->pci_dev->dev.kobj, - &iwl_attribute_group); + &il_attribute_group); if (err) { - IWL_ERR(priv, "failed to create sysfs device attributes\n"); + IL_ERR(priv, "failed to create sysfs device attributes\n"); goto out_unbind; } @@ -1444,14 +1444,14 @@ iwl4965_ucode_callback(const struct firmware *ucode_raw, void *context) try_again: /* try next, if any */ - if (iwl4965_request_firmware(priv, false)) + if (il4965_request_firmware(priv, false)) goto out_unbind; release_firmware(ucode_raw); return; err_pci_alloc: - IWL_ERR(priv, "failed to allocate pci memory\n"); - iwl4965_dealloc_ucode_pci(priv); + IL_ERR(priv, "failed to allocate pci memory\n"); + il4965_dealloc_ucode_pci(priv); out_unbind: complete(&priv->_4965.firmware_loading_complete); device_release_driver(&priv->pci_dev->dev); @@ -1508,7 +1508,7 @@ static struct { char *name; u8 num; } advanced_lookup[] = { { "ADVANCED_SYSASSERT", 0 }, }; -static const char *iwl4965_desc_lookup(u32 num) +static const char *il4965_desc_lookup(u32 num) { int i; int max = ARRAY_SIZE(desc_lookup_text); @@ -1527,7 +1527,7 @@ static const char *iwl4965_desc_lookup(u32 num) #define ERROR_START_OFFSET (1 * sizeof(u32)) #define ERROR_ELEM_SIZE (7 * sizeof(u32)) -void iwl4965_dump_nic_error_log(struct iwl_priv *priv) +void il4965_dump_nic_error_log(struct il_priv *priv) { u32 data2, line; u32 desc, time, count, base, data1; @@ -1541,78 +1541,78 @@ void iwl4965_dump_nic_error_log(struct iwl_priv *priv) } if (!priv->cfg->ops->lib->is_valid_rtc_data_addr(base)) { - IWL_ERR(priv, + IL_ERR(priv, "Not valid error log pointer 0x%08X for %s uCode\n", base, (priv->ucode_type == UCODE_INIT) ? "Init" : "RT"); return; } - count = iwl_legacy_read_targ_mem(priv, base); + count = il_read_targ_mem(priv, base); if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { - IWL_ERR(priv, "Start IWL Error Log Dump:\n"); - IWL_ERR(priv, "Status: 0x%08lX, count: %d\n", + IL_ERR(priv, "Start IWL Error Log Dump:\n"); + IL_ERR(priv, "Status: 0x%08lX, count: %d\n", priv->status, count); } - desc = iwl_legacy_read_targ_mem(priv, base + 1 * sizeof(u32)); + desc = il_read_targ_mem(priv, base + 1 * sizeof(u32)); priv->isr_stats.err_code = desc; - pc = iwl_legacy_read_targ_mem(priv, base + 2 * sizeof(u32)); - blink1 = iwl_legacy_read_targ_mem(priv, base + 3 * sizeof(u32)); - blink2 = iwl_legacy_read_targ_mem(priv, base + 4 * sizeof(u32)); - ilink1 = iwl_legacy_read_targ_mem(priv, base + 5 * sizeof(u32)); - ilink2 = iwl_legacy_read_targ_mem(priv, base + 6 * sizeof(u32)); - data1 = iwl_legacy_read_targ_mem(priv, base + 7 * sizeof(u32)); - data2 = iwl_legacy_read_targ_mem(priv, base + 8 * sizeof(u32)); - line = iwl_legacy_read_targ_mem(priv, base + 9 * sizeof(u32)); - time = iwl_legacy_read_targ_mem(priv, base + 11 * sizeof(u32)); - hcmd = iwl_legacy_read_targ_mem(priv, base + 22 * sizeof(u32)); - - IWL_ERR(priv, "Desc Time " + pc = il_read_targ_mem(priv, base + 2 * sizeof(u32)); + blink1 = il_read_targ_mem(priv, base + 3 * sizeof(u32)); + blink2 = il_read_targ_mem(priv, base + 4 * sizeof(u32)); + ilink1 = il_read_targ_mem(priv, base + 5 * sizeof(u32)); + ilink2 = il_read_targ_mem(priv, base + 6 * sizeof(u32)); + data1 = il_read_targ_mem(priv, base + 7 * sizeof(u32)); + data2 = il_read_targ_mem(priv, base + 8 * sizeof(u32)); + line = il_read_targ_mem(priv, base + 9 * sizeof(u32)); + time = il_read_targ_mem(priv, base + 11 * sizeof(u32)); + hcmd = il_read_targ_mem(priv, base + 22 * sizeof(u32)); + + IL_ERR(priv, "Desc Time " "data1 data2 line\n"); - IWL_ERR(priv, "%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n", - iwl4965_desc_lookup(desc), desc, time, data1, data2, line); - IWL_ERR(priv, "pc blink1 blink2 ilink1 ilink2 hcmd\n"); - IWL_ERR(priv, "0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n", + IL_ERR(priv, "%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n", + il4965_desc_lookup(desc), desc, time, data1, data2, line); + IL_ERR(priv, "pc blink1 blink2 ilink1 ilink2 hcmd\n"); + IL_ERR(priv, "0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n", pc, blink1, blink2, ilink1, ilink2, hcmd); } -static void iwl4965_rf_kill_ct_config(struct iwl_priv *priv) +static void il4965_rf_kill_ct_config(struct il_priv *priv) { - struct iwl_ct_kill_config cmd; + struct il_ct_kill_config cmd; unsigned long flags; int ret = 0; spin_lock_irqsave(&priv->lock, flags); - iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, + il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); spin_unlock_irqrestore(&priv->lock, flags); cmd.critical_temperature_R = cpu_to_le32(priv->hw_params.ct_kill_threshold); - ret = iwl_legacy_send_cmd_pdu(priv, REPLY_CT_KILL_CONFIG_CMD, + ret = il_send_cmd_pdu(priv, REPLY_CT_KILL_CONFIG_CMD, sizeof(cmd), &cmd); if (ret) - IWL_ERR(priv, "REPLY_CT_KILL_CONFIG_CMD failed\n"); + IL_ERR(priv, "REPLY_CT_KILL_CONFIG_CMD failed\n"); else - IWL_DEBUG_INFO(priv, "REPLY_CT_KILL_CONFIG_CMD " + IL_DEBUG_INFO(priv, "REPLY_CT_KILL_CONFIG_CMD " "succeeded, " "critical temperature is %d\n", priv->hw_params.ct_kill_threshold); } static const s8 default_queue_to_tx_fifo[] = { - IWL_TX_FIFO_VO, - IWL_TX_FIFO_VI, - IWL_TX_FIFO_BE, - IWL_TX_FIFO_BK, + IL_TX_FIFO_VO, + IL_TX_FIFO_VI, + IL_TX_FIFO_BE, + IL_TX_FIFO_BK, IWL49_CMD_FIFO_NUM, - IWL_TX_FIFO_UNUSED, - IWL_TX_FIFO_UNUSED, + IL_TX_FIFO_UNUSED, + IL_TX_FIFO_UNUSED, }; -static int iwl4965_alive_notify(struct iwl_priv *priv) +static int il4965_alive_notify(struct il_priv *priv) { u32 a; unsigned long flags; @@ -1622,52 +1622,52 @@ static int iwl4965_alive_notify(struct iwl_priv *priv) spin_lock_irqsave(&priv->lock, flags); /* Clear 4965's internal Tx Scheduler data base */ - priv->scd_base_addr = iwl_legacy_read_prph(priv, + priv->scd_base_addr = il_read_prph(priv, IWL49_SCD_SRAM_BASE_ADDR); a = priv->scd_base_addr + IWL49_SCD_CONTEXT_DATA_OFFSET; for (; a < priv->scd_base_addr + IWL49_SCD_TX_STTS_BITMAP_OFFSET; a += 4) - iwl_legacy_write_targ_mem(priv, a, 0); + il_write_targ_mem(priv, a, 0); for (; a < priv->scd_base_addr + IWL49_SCD_TRANSLATE_TBL_OFFSET; a += 4) - iwl_legacy_write_targ_mem(priv, a, 0); + il_write_targ_mem(priv, a, 0); for (; a < priv->scd_base_addr + IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(priv->hw_params.max_txq_num); a += 4) - iwl_legacy_write_targ_mem(priv, a, 0); + il_write_targ_mem(priv, a, 0); /* Tel 4965 where to find Tx byte count tables */ - iwl_legacy_write_prph(priv, IWL49_SCD_DRAM_BASE_ADDR, + il_write_prph(priv, IWL49_SCD_DRAM_BASE_ADDR, priv->scd_bc_tbls.dma >> 10); /* Enable DMA channel */ for (chan = 0; chan < FH49_TCSR_CHNL_NUM ; chan++) - iwl_legacy_write_direct32(priv, + il_write_direct32(priv, FH_TCSR_CHNL_TX_CONFIG_REG(chan), FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE); /* Update FH chicken bits */ - reg_val = iwl_legacy_read_direct32(priv, FH_TX_CHICKEN_BITS_REG); - iwl_legacy_write_direct32(priv, FH_TX_CHICKEN_BITS_REG, + reg_val = il_read_direct32(priv, FH_TX_CHICKEN_BITS_REG); + il_write_direct32(priv, FH_TX_CHICKEN_BITS_REG, reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); /* Disable chain mode for all queues */ - iwl_legacy_write_prph(priv, IWL49_SCD_QUEUECHAIN_SEL, 0); + il_write_prph(priv, IWL49_SCD_QUEUECHAIN_SEL, 0); /* Initialize each Tx queue (including the command queue) */ for (i = 0; i < priv->hw_params.max_txq_num; i++) { /* TFD circular buffer read/write indexes */ - iwl_legacy_write_prph(priv, IWL49_SCD_QUEUE_RDPTR(i), 0); - iwl_legacy_write_direct32(priv, HBUS_TARG_WRPTR, 0 | (i << 8)); + il_write_prph(priv, IWL49_SCD_QUEUE_RDPTR(i), 0); + il_write_direct32(priv, HBUS_TARG_WRPTR, 0 | (i << 8)); /* Max Tx Window size for Scheduler-ACK mode */ - iwl_legacy_write_targ_mem(priv, priv->scd_base_addr + + il_write_targ_mem(priv, priv->scd_base_addr + IWL49_SCD_CONTEXT_QUEUE_OFFSET(i), (SCD_WIN_SIZE << IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); /* Frame limit */ - iwl_legacy_write_targ_mem(priv, priv->scd_base_addr + + il_write_targ_mem(priv, priv->scd_base_addr + IWL49_SCD_CONTEXT_QUEUE_OFFSET(i) + sizeof(u32), (SCD_FRAME_LIMIT << @@ -1675,13 +1675,13 @@ static int iwl4965_alive_notify(struct iwl_priv *priv) IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); } - iwl_legacy_write_prph(priv, IWL49_SCD_INTERRUPT_MASK, + il_write_prph(priv, IWL49_SCD_INTERRUPT_MASK, (1 << priv->hw_params.max_txq_num) - 1); /* Activate all Tx DMA/FIFO channels */ - iwl4965_txq_set_sched(priv, IWL_MASK(0, 6)); + il4965_txq_set_sched(priv, IL_MASK(0, 6)); - iwl4965_set_wr_ptrs(priv, IWL_DEFAULT_CMD_QUEUE_NUM, 0); + il4965_set_wr_ptrs(priv, IL_DEFAULT_CMD_QUEUE_NUM, 0); /* make sure all queue are not stopped */ memset(&priv->queue_stopped[0], 0, sizeof(priv->queue_stopped)); @@ -1696,12 +1696,12 @@ static int iwl4965_alive_notify(struct iwl_priv *priv) for (i = 0; i < ARRAY_SIZE(default_queue_to_tx_fifo); i++) { int ac = default_queue_to_tx_fifo[i]; - iwl_txq_ctx_activate(priv, i); + il_txq_ctx_activate(priv, i); - if (ac == IWL_TX_FIFO_UNUSED) + if (ac == IL_TX_FIFO_UNUSED) continue; - iwl4965_tx_queue_set_status(priv, &priv->txq[i], ac, 0); + il4965_tx_queue_set_status(priv, &priv->txq[i], ac, 0); } spin_unlock_irqrestore(&priv->lock, flags); @@ -1710,37 +1710,37 @@ static int iwl4965_alive_notify(struct iwl_priv *priv) } /** - * iwl4965_alive_start - called after REPLY_ALIVE notification received + * il4965_alive_start - called after REPLY_ALIVE notification received * from protocol/runtime uCode (initialization uCode's - * Alive gets handled by iwl_init_alive_start()). + * Alive gets handled by il_init_alive_start()). */ -static void iwl4965_alive_start(struct iwl_priv *priv) +static void il4965_alive_start(struct il_priv *priv) { int ret = 0; - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; - IWL_DEBUG_INFO(priv, "Runtime Alive received.\n"); + IL_DEBUG_INFO(priv, "Runtime Alive received.\n"); if (priv->card_alive.is_valid != UCODE_VALID_OK) { /* We had an error bringing up the hardware, so take it * all the way back down so we can try again */ - IWL_DEBUG_INFO(priv, "Alive failed.\n"); + IL_DEBUG_INFO(priv, "Alive failed.\n"); goto restart; } /* Initialize uCode has loaded Runtime uCode ... verify inst image. * This is a paranoid check, because we would not have gotten the * "runtime" alive if code weren't properly loaded. */ - if (iwl4965_verify_ucode(priv)) { + if (il4965_verify_ucode(priv)) { /* Runtime instruction load was bad; * take it all the way back down so we can try again */ - IWL_DEBUG_INFO(priv, "Bad runtime uCode load.\n"); + IL_DEBUG_INFO(priv, "Bad runtime uCode load.\n"); goto restart; } - ret = iwl4965_alive_notify(priv); + ret = il4965_alive_notify(priv); if (ret) { - IWL_WARN(priv, + IL_WARN(priv, "Could not complete ALIVE transition [ntf]: %d\n", ret); goto restart; } @@ -1750,49 +1750,49 @@ static void iwl4965_alive_start(struct iwl_priv *priv) set_bit(STATUS_ALIVE, &priv->status); /* Enable watchdog to monitor the driver tx queues */ - iwl_legacy_setup_watchdog(priv); + il_setup_watchdog(priv); - if (iwl_legacy_is_rfkill(priv)) + if (il_is_rfkill(priv)) return; ieee80211_wake_queues(priv->hw); - priv->active_rate = IWL_RATES_MASK; + priv->active_rate = IL_RATES_MASK; - if (iwl_legacy_is_associated_ctx(ctx)) { - struct iwl_legacy_rxon_cmd *active_rxon = - (struct iwl_legacy_rxon_cmd *)&ctx->active; + if (il_is_associated_ctx(ctx)) { + struct il_rxon_cmd *active_rxon = + (struct il_rxon_cmd *)&ctx->active; /* apply any changes in staging */ ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; } else { - struct iwl_rxon_context *tmp; + struct il_rxon_context *tmp; /* Initialize our rx_config data */ for_each_context(priv, tmp) - iwl_legacy_connection_init_rx_config(priv, tmp); + il_connection_init_rx_config(priv, tmp); if (priv->cfg->ops->hcmd->set_rxon_chain) priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); } /* Configure bluetooth coexistence if enabled */ - iwl_legacy_send_bt_config(priv); + il_send_bt_config(priv); - iwl4965_reset_run_time_calib(priv); + il4965_reset_run_time_calib(priv); set_bit(STATUS_READY, &priv->status); /* Configure the adapter for unassociated operation */ - iwl_legacy_commit_rxon(priv, ctx); + il_commit_rxon(priv, ctx); /* At this point, the NIC is initialized and operational */ - iwl4965_rf_kill_ct_config(priv); + il4965_rf_kill_ct_config(priv); - IWL_DEBUG_INFO(priv, "ALIVE processing complete.\n"); + IL_DEBUG_INFO(priv, "ALIVE processing complete.\n"); wake_up(&priv->wait_command_queue); - iwl_legacy_power_update_mode(priv, true); - IWL_DEBUG_INFO(priv, "Updated power mode\n"); + il_power_update_mode(priv, true); + IL_DEBUG_INFO(priv, "Updated power mode\n"); return; @@ -1800,16 +1800,16 @@ static void iwl4965_alive_start(struct iwl_priv *priv) queue_work(priv->workqueue, &priv->restart); } -static void iwl4965_cancel_deferred_work(struct iwl_priv *priv); +static void il4965_cancel_deferred_work(struct il_priv *priv); -static void __iwl4965_down(struct iwl_priv *priv) +static void __il4965_down(struct il_priv *priv) { unsigned long flags; int exit_pending; - IWL_DEBUG_INFO(priv, DRV_NAME " is going down\n"); + IL_DEBUG_INFO(priv, DRV_NAME " is going down\n"); - iwl_legacy_scan_cancel_timeout(priv, 200); + il_scan_cancel_timeout(priv, 200); exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &priv->status); @@ -1817,9 +1817,9 @@ static void __iwl4965_down(struct iwl_priv *priv) * to prevent rearm timer */ del_timer_sync(&priv->watchdog); - iwl_legacy_clear_ucode_stations(priv, NULL); - iwl_legacy_dealloc_bcast_stations(priv); - iwl_legacy_clear_driver_stations(priv); + il_clear_ucode_stations(priv, NULL); + il_dealloc_bcast_stations(priv); + il_clear_driver_stations(priv); /* Unblock any waiting calls */ wake_up_all(&priv->wait_command_queue); @@ -1830,20 +1830,20 @@ static void __iwl4965_down(struct iwl_priv *priv) clear_bit(STATUS_EXIT_PENDING, &priv->status); /* stop and reset the on-board processor */ - iwl_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + il_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); /* tell the device to stop sending interrupts */ spin_lock_irqsave(&priv->lock, flags); - iwl_legacy_disable_interrupts(priv); + il_disable_interrupts(priv); spin_unlock_irqrestore(&priv->lock, flags); - iwl4965_synchronize_irq(priv); + il4965_synchronize_irq(priv); if (priv->mac80211_registered) ieee80211_stop_queues(priv->hw); - /* If we have not previously called iwl_init() then + /* If we have not previously called il_init() then * clear all bits but the RF Kill bit and return */ - if (!iwl_legacy_is_init(priv)) { + if (!il_is_init(priv)) { priv->status = test_bit(STATUS_RF_KILL_HW, &priv->status) << STATUS_RF_KILL_HW | test_bit(STATUS_GEO_CONFIGURED, &priv->status) << @@ -1864,50 +1864,50 @@ static void __iwl4965_down(struct iwl_priv *priv) test_bit(STATUS_EXIT_PENDING, &priv->status) << STATUS_EXIT_PENDING; - iwl4965_txq_ctx_stop(priv); - iwl4965_rxq_stop(priv); + il4965_txq_ctx_stop(priv); + il4965_rxq_stop(priv); /* Power-down device's busmaster DMA clocks */ - iwl_legacy_write_prph(priv, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); + il_write_prph(priv, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); udelay(5); /* Make sure (redundant) we've released our request to stay awake */ - iwl_legacy_clear_bit(priv, CSR_GP_CNTRL, + il_clear_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); /* Stop the device, and put it in low power state */ - iwl_legacy_apm_stop(priv); + il_apm_stop(priv); exit: - memset(&priv->card_alive, 0, sizeof(struct iwl_alive_resp)); + memset(&priv->card_alive, 0, sizeof(struct il_alive_resp)); dev_kfree_skb(priv->beacon_skb); priv->beacon_skb = NULL; /* clear out any free frames */ - iwl4965_clear_free_frames(priv); + il4965_clear_free_frames(priv); } -static void iwl4965_down(struct iwl_priv *priv) +static void il4965_down(struct il_priv *priv) { mutex_lock(&priv->mutex); - __iwl4965_down(priv); + __il4965_down(priv); mutex_unlock(&priv->mutex); - iwl4965_cancel_deferred_work(priv); + il4965_cancel_deferred_work(priv); } #define HW_READY_TIMEOUT (50) -static int iwl4965_set_hw_ready(struct iwl_priv *priv) +static int il4965_set_hw_ready(struct il_priv *priv) { int ret = 0; - iwl_legacy_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(priv, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_NIC_READY); /* See if we got it */ - ret = iwl_poll_bit(priv, CSR_HW_IF_CONFIG_REG, + ret = il_poll_bit(priv, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, HW_READY_TIMEOUT); @@ -1916,107 +1916,107 @@ static int iwl4965_set_hw_ready(struct iwl_priv *priv) else priv->hw_ready = false; - IWL_DEBUG_INFO(priv, "hardware %s\n", + IL_DEBUG_INFO(priv, "hardware %s\n", (priv->hw_ready == 1) ? "ready" : "not ready"); return ret; } -static int iwl4965_prepare_card_hw(struct iwl_priv *priv) +static int il4965_prepare_card_hw(struct il_priv *priv) { int ret = 0; - IWL_DEBUG_INFO(priv, "iwl4965_prepare_card_hw enter\n"); + IL_DEBUG_INFO(priv, "il4965_prepare_card_hw enter\n"); - ret = iwl4965_set_hw_ready(priv); + ret = il4965_set_hw_ready(priv); if (priv->hw_ready) return ret; /* If HW is not ready, prepare the conditions to check again */ - iwl_legacy_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(priv, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_PREPARE); - ret = iwl_poll_bit(priv, CSR_HW_IF_CONFIG_REG, + ret = il_poll_bit(priv, CSR_HW_IF_CONFIG_REG, ~CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, 150000); /* HW should be ready by now, check again. */ if (ret != -ETIMEDOUT) - iwl4965_set_hw_ready(priv); + il4965_set_hw_ready(priv); return ret; } #define MAX_HW_RESTARTS 5 -static int __iwl4965_up(struct iwl_priv *priv) +static int __il4965_up(struct il_priv *priv) { - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; int i; int ret; if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { - IWL_WARN(priv, "Exit pending; will not bring the NIC up\n"); + IL_WARN(priv, "Exit pending; will not bring the NIC up\n"); return -EIO; } if (!priv->ucode_data_backup.v_addr || !priv->ucode_data.v_addr) { - IWL_ERR(priv, "ucode not available for device bringup\n"); + IL_ERR(priv, "ucode not available for device bringup\n"); return -EIO; } for_each_context(priv, ctx) { - ret = iwl4965_alloc_bcast_station(priv, ctx); + ret = il4965_alloc_bcast_station(priv, ctx); if (ret) { - iwl_legacy_dealloc_bcast_stations(priv); + il_dealloc_bcast_stations(priv); return ret; } } - iwl4965_prepare_card_hw(priv); + il4965_prepare_card_hw(priv); if (!priv->hw_ready) { - IWL_WARN(priv, "Exit HW not ready\n"); + IL_WARN(priv, "Exit HW not ready\n"); return -EIO; } /* If platform's RF_KILL switch is NOT set to KILL */ - if (iwl_read32(priv, + if (il_read32(priv, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) clear_bit(STATUS_RF_KILL_HW, &priv->status); else set_bit(STATUS_RF_KILL_HW, &priv->status); - if (iwl_legacy_is_rfkill(priv)) { + if (il_is_rfkill(priv)) { wiphy_rfkill_set_hw_state(priv->hw->wiphy, true); - iwl_legacy_enable_interrupts(priv); - IWL_WARN(priv, "Radio disabled by HW RF Kill switch\n"); + il_enable_interrupts(priv); + IL_WARN(priv, "Radio disabled by HW RF Kill switch\n"); return 0; } - iwl_write32(priv, CSR_INT, 0xFFFFFFFF); + il_write32(priv, CSR_INT, 0xFFFFFFFF); - /* must be initialised before iwl_hw_nic_init */ - priv->cmd_queue = IWL_DEFAULT_CMD_QUEUE_NUM; + /* must be initialised before il_hw_nic_init */ + priv->cmd_queue = IL_DEFAULT_CMD_QUEUE_NUM; - ret = iwl4965_hw_nic_init(priv); + ret = il4965_hw_nic_init(priv); if (ret) { - IWL_ERR(priv, "Unable to init nic\n"); + IL_ERR(priv, "Unable to init nic\n"); return ret; } /* make sure rfkill handshake bits are cleared */ - iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, + il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); /* clear (again), then enable host interrupts */ - iwl_write32(priv, CSR_INT, 0xFFFFFFFF); - iwl_legacy_enable_interrupts(priv); + il_write32(priv, CSR_INT, 0xFFFFFFFF); + il_enable_interrupts(priv); /* really make sure rfkill handshake bits are cleared */ - iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); /* Copy original ucode data image from disk into backup cache. * This will be used to initialize the on-board processor's @@ -2032,26 +2032,26 @@ static int __iwl4965_up(struct iwl_priv *priv) ret = priv->cfg->ops->lib->load_ucode(priv); if (ret) { - IWL_ERR(priv, "Unable to set up bootstrap uCode: %d\n", + IL_ERR(priv, "Unable to set up bootstrap uCode: %d\n", ret); continue; } /* start card; "initialize" will load runtime ucode */ - iwl4965_nic_start(priv); + il4965_nic_start(priv); - IWL_DEBUG_INFO(priv, DRV_NAME " is coming up\n"); + IL_DEBUG_INFO(priv, DRV_NAME " is coming up\n"); return 0; } set_bit(STATUS_EXIT_PENDING, &priv->status); - __iwl4965_down(priv); + __il4965_down(priv); clear_bit(STATUS_EXIT_PENDING, &priv->status); /* tried to restart and config the device for as long as our * patience could withstand */ - IWL_ERR(priv, "Unable to initialize device after %d attempts.\n", i); + IL_ERR(priv, "Unable to initialize device after %d attempts.\n", i); return -EIO; } @@ -2062,10 +2062,10 @@ static int __iwl4965_up(struct iwl_priv *priv) * *****************************************************************************/ -static void iwl4965_bg_init_alive_start(struct work_struct *data) +static void il4965_bg_init_alive_start(struct work_struct *data) { - struct iwl_priv *priv = - container_of(data, struct iwl_priv, init_alive_start.work); + struct il_priv *priv = + container_of(data, struct il_priv, init_alive_start.work); mutex_lock(&priv->mutex); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) @@ -2076,23 +2076,23 @@ out: mutex_unlock(&priv->mutex); } -static void iwl4965_bg_alive_start(struct work_struct *data) +static void il4965_bg_alive_start(struct work_struct *data) { - struct iwl_priv *priv = - container_of(data, struct iwl_priv, alive_start.work); + struct il_priv *priv = + container_of(data, struct il_priv, alive_start.work); mutex_lock(&priv->mutex); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) goto out; - iwl4965_alive_start(priv); + il4965_alive_start(priv); out: mutex_unlock(&priv->mutex); } -static void iwl4965_bg_run_time_calib_work(struct work_struct *work) +static void il4965_bg_run_time_calib_work(struct work_struct *work) { - struct iwl_priv *priv = container_of(work, struct iwl_priv, + struct il_priv *priv = container_of(work, struct il_priv, run_time_calib_work); mutex_lock(&priv->mutex); @@ -2104,37 +2104,37 @@ static void iwl4965_bg_run_time_calib_work(struct work_struct *work) } if (priv->start_calib) { - iwl4965_chain_noise_calibration(priv, + il4965_chain_noise_calibration(priv, (void *)&priv->_4965.statistics); - iwl4965_sensitivity_calibration(priv, + il4965_sensitivity_calibration(priv, (void *)&priv->_4965.statistics); } mutex_unlock(&priv->mutex); } -static void iwl4965_bg_restart(struct work_struct *data) +static void il4965_bg_restart(struct work_struct *data) { - struct iwl_priv *priv = container_of(data, struct iwl_priv, restart); + struct il_priv *priv = container_of(data, struct il_priv, restart); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; if (test_and_clear_bit(STATUS_FW_ERROR, &priv->status)) { - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; mutex_lock(&priv->mutex); for_each_context(priv, ctx) ctx->vif = NULL; priv->is_open = 0; - __iwl4965_down(priv); + __il4965_down(priv); mutex_unlock(&priv->mutex); - iwl4965_cancel_deferred_work(priv); + il4965_cancel_deferred_work(priv); ieee80211_restart_hw(priv->hw); } else { - iwl4965_down(priv); + il4965_down(priv); mutex_lock(&priv->mutex); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { @@ -2142,21 +2142,21 @@ static void iwl4965_bg_restart(struct work_struct *data) return; } - __iwl4965_up(priv); + __il4965_up(priv); mutex_unlock(&priv->mutex); } } -static void iwl4965_bg_rx_replenish(struct work_struct *data) +static void il4965_bg_rx_replenish(struct work_struct *data) { - struct iwl_priv *priv = - container_of(data, struct iwl_priv, rx_replenish); + struct il_priv *priv = + container_of(data, struct il_priv, rx_replenish); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) return; mutex_lock(&priv->mutex); - iwl4965_rx_replenish(priv); + il4965_rx_replenish(priv); mutex_unlock(&priv->mutex); } @@ -2172,12 +2172,12 @@ static void iwl4965_bg_rx_replenish(struct work_struct *data) * Not a mac80211 entry point function, but it fits in with all the * other mac80211 functions grouped here. */ -static int iwl4965_mac_setup_register(struct iwl_priv *priv, +static int il4965_mac_setup_register(struct il_priv *priv, u32 max_probe_length) { int ret; struct ieee80211_hw *hw = priv->hw; - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; hw->rate_control_algorithm = "iwl-4965-rs"; @@ -2188,12 +2188,12 @@ static int iwl4965_mac_setup_register(struct iwl_priv *priv, IEEE80211_HW_SPECTRUM_MGMT | IEEE80211_HW_REPORTS_TX_ACK_STATUS; - if (priv->cfg->sku & IWL_SKU_N) + if (priv->cfg->sku & IL_SKU_N) hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | IEEE80211_HW_SUPPORTS_STATIC_SMPS; - hw->sta_data_size = sizeof(struct iwl_station_priv); - hw->vif_data_size = sizeof(struct iwl_vif_priv); + hw->sta_data_size = sizeof(struct il_station_priv); + hw->vif_data_size = sizeof(struct il_vif_priv); for_each_context(priv, ctx) { hw->wiphy->interface_modes |= ctx->interface_modes; @@ -2216,7 +2216,7 @@ static int iwl4965_mac_setup_register(struct iwl_priv *priv, /* Default value; 4 EDCA QOS priorities */ hw->queues = 4; - hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL; + hw->max_listen_interval = IL_CONN_MAX_LISTEN_INTERVAL; if (priv->bands[IEEE80211_BAND_2GHZ].n_channels) priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = @@ -2225,11 +2225,11 @@ static int iwl4965_mac_setup_register(struct iwl_priv *priv, priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = &priv->bands[IEEE80211_BAND_5GHZ]; - iwl_legacy_leds_init(priv); + il_leds_init(priv); ret = ieee80211_register_hw(priv->hw); if (ret) { - IWL_ERR(priv, "Failed to register hw (error %d)\n", ret); + IL_ERR(priv, "Failed to register hw (error %d)\n", ret); return ret; } priv->mac80211_registered = 1; @@ -2238,25 +2238,25 @@ static int iwl4965_mac_setup_register(struct iwl_priv *priv, } -int iwl4965_mac_start(struct ieee80211_hw *hw) +int il4965_mac_start(struct ieee80211_hw *hw) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; int ret; - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); /* we should be verifying the device is ready to be opened */ mutex_lock(&priv->mutex); - ret = __iwl4965_up(priv); + ret = __il4965_up(priv); mutex_unlock(&priv->mutex); if (ret) return ret; - if (iwl_legacy_is_rfkill(priv)) + if (il_is_rfkill(priv)) goto out; - IWL_DEBUG_INFO(priv, "Start UP work done.\n"); + IL_DEBUG_INFO(priv, "Start UP work done.\n"); /* Wait for START_ALIVE from Run Time ucode. Otherwise callbacks from * mac80211 will not be run successfully. */ @@ -2265,99 +2265,99 @@ int iwl4965_mac_start(struct ieee80211_hw *hw) UCODE_READY_TIMEOUT); if (!ret) { if (!test_bit(STATUS_READY, &priv->status)) { - IWL_ERR(priv, "START_ALIVE timeout after %dms.\n", + IL_ERR(priv, "START_ALIVE timeout after %dms.\n", jiffies_to_msecs(UCODE_READY_TIMEOUT)); return -ETIMEDOUT; } } - iwl4965_led_enable(priv); + il4965_led_enable(priv); out: priv->is_open = 1; - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); return 0; } -void iwl4965_mac_stop(struct ieee80211_hw *hw) +void il4965_mac_stop(struct ieee80211_hw *hw) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); if (!priv->is_open) return; priv->is_open = 0; - iwl4965_down(priv); + il4965_down(priv); flush_workqueue(priv->workqueue); /* User space software may expect getting rfkill changes * even if interface is down */ - iwl_write32(priv, CSR_INT, 0xFFFFFFFF); - iwl_legacy_enable_rfkill_int(priv); + il_write32(priv, CSR_INT, 0xFFFFFFFF); + il_enable_rfkill_int(priv); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); } -void iwl4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) +void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; - IWL_DEBUG_MACDUMP(priv, "enter\n"); + IL_DEBUG_MACDUMP(priv, "enter\n"); - IWL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, + IL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); - if (iwl4965_tx_skb(priv, skb)) + if (il4965_tx_skb(priv, skb)) dev_kfree_skb_any(skb); - IWL_DEBUG_MACDUMP(priv, "leave\n"); + IL_DEBUG_MACDUMP(priv, "leave\n"); } -void iwl4965_mac_update_tkip_key(struct ieee80211_hw *hw, +void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_key_conf *keyconf, struct ieee80211_sta *sta, u32 iv32, u16 *phase1key) { - struct iwl_priv *priv = hw->priv; - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; + struct il_priv *priv = hw->priv; + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); - iwl4965_update_tkip_key(priv, vif_priv->ctx, keyconf, sta, + il4965_update_tkip_key(priv, vif_priv->ctx, keyconf, sta, iv32, phase1key); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); } -int iwl4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, +int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, struct ieee80211_vif *vif, struct ieee80211_sta *sta, struct ieee80211_key_conf *key) { - struct iwl_priv *priv = hw->priv; - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; - struct iwl_rxon_context *ctx = vif_priv->ctx; + struct il_priv *priv = hw->priv; + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; + struct il_rxon_context *ctx = vif_priv->ctx; int ret; u8 sta_id; bool is_default_wep_key = false; - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); if (priv->cfg->mod_params->sw_crypto) { - IWL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n"); + IL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n"); return -EOPNOTSUPP; } - sta_id = iwl_legacy_sta_id_or_broadcast(priv, vif_priv->ctx, sta); - if (sta_id == IWL_INVALID_STATION) + sta_id = il_sta_id_or_broadcast(priv, vif_priv->ctx, sta); + if (sta_id == IL_INVALID_STATION) return -EINVAL; mutex_lock(&priv->mutex); - iwl_legacy_scan_cancel_timeout(priv, 100); + il_scan_cancel_timeout(priv, 100); /* * If we are getting WEP group key and we didn't receive any key mapping @@ -2378,68 +2378,68 @@ int iwl4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, switch (cmd) { case SET_KEY: if (is_default_wep_key) - ret = iwl4965_set_default_wep_key(priv, + ret = il4965_set_default_wep_key(priv, vif_priv->ctx, key); else - ret = iwl4965_set_dynamic_key(priv, vif_priv->ctx, + ret = il4965_set_dynamic_key(priv, vif_priv->ctx, key, sta_id); - IWL_DEBUG_MAC80211(priv, "enable hwcrypto key\n"); + IL_DEBUG_MAC80211(priv, "enable hwcrypto key\n"); break; case DISABLE_KEY: if (is_default_wep_key) - ret = iwl4965_remove_default_wep_key(priv, ctx, key); + ret = il4965_remove_default_wep_key(priv, ctx, key); else - ret = iwl4965_remove_dynamic_key(priv, ctx, + ret = il4965_remove_dynamic_key(priv, ctx, key, sta_id); - IWL_DEBUG_MAC80211(priv, "disable hwcrypto key\n"); + IL_DEBUG_MAC80211(priv, "disable hwcrypto key\n"); break; default: ret = -EINVAL; } mutex_unlock(&priv->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); return ret; } -int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw, +int il4965_mac_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, enum ieee80211_ampdu_mlme_action action, struct ieee80211_sta *sta, u16 tid, u16 *ssn, u8 buf_size) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; int ret = -EINVAL; - IWL_DEBUG_HT(priv, "A-MPDU action on addr %pM tid %d\n", + IL_DEBUG_HT(priv, "A-MPDU action on addr %pM tid %d\n", sta->addr, tid); - if (!(priv->cfg->sku & IWL_SKU_N)) + if (!(priv->cfg->sku & IL_SKU_N)) return -EACCES; mutex_lock(&priv->mutex); switch (action) { case IEEE80211_AMPDU_RX_START: - IWL_DEBUG_HT(priv, "start Rx\n"); - ret = iwl4965_sta_rx_agg_start(priv, sta, tid, *ssn); + IL_DEBUG_HT(priv, "start Rx\n"); + ret = il4965_sta_rx_agg_start(priv, sta, tid, *ssn); break; case IEEE80211_AMPDU_RX_STOP: - IWL_DEBUG_HT(priv, "stop Rx\n"); - ret = iwl4965_sta_rx_agg_stop(priv, sta, tid); + IL_DEBUG_HT(priv, "stop Rx\n"); + ret = il4965_sta_rx_agg_stop(priv, sta, tid); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) ret = 0; break; case IEEE80211_AMPDU_TX_START: - IWL_DEBUG_HT(priv, "start Tx\n"); - ret = iwl4965_tx_agg_start(priv, vif, sta, tid, ssn); + IL_DEBUG_HT(priv, "start Tx\n"); + ret = il4965_tx_agg_start(priv, vif, sta, tid, ssn); break; case IEEE80211_AMPDU_TX_STOP: - IWL_DEBUG_HT(priv, "stop Tx\n"); - ret = iwl4965_tx_agg_stop(priv, vif, sta, tid); + IL_DEBUG_HT(priv, "stop Tx\n"); + ret = il4965_tx_agg_stop(priv, vif, sta, tid); if (test_bit(STATUS_EXIT_PENDING, &priv->status)) ret = 0; break; @@ -2452,30 +2452,30 @@ int iwl4965_mac_ampdu_action(struct ieee80211_hw *hw, return ret; } -int iwl4965_mac_sta_add(struct ieee80211_hw *hw, +int il4965_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta) { - struct iwl_priv *priv = hw->priv; - struct iwl_station_priv *sta_priv = (void *)sta->drv_priv; - struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; + struct il_priv *priv = hw->priv; + struct il_station_priv *sta_priv = (void *)sta->drv_priv; + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; bool is_ap = vif->type == NL80211_IFTYPE_STATION; int ret; u8 sta_id; - IWL_DEBUG_INFO(priv, "received request to add station %pM\n", + IL_DEBUG_INFO(priv, "received request to add station %pM\n", sta->addr); mutex_lock(&priv->mutex); - IWL_DEBUG_INFO(priv, "proceeding to add station %pM\n", + IL_DEBUG_INFO(priv, "proceeding to add station %pM\n", sta->addr); - sta_priv->common.sta_id = IWL_INVALID_STATION; + sta_priv->common.sta_id = IL_INVALID_STATION; atomic_set(&sta_priv->pending_frames, 0); - ret = iwl_legacy_add_station_common(priv, vif_priv->ctx, sta->addr, + ret = il_add_station_common(priv, vif_priv->ctx, sta->addr, is_ap, sta, &sta_id); if (ret) { - IWL_ERR(priv, "Unable to add station %pM (%d)\n", + IL_ERR(priv, "Unable to add station %pM (%d)\n", sta->addr, ret); /* Should we return success if return code is EEXIST ? */ mutex_unlock(&priv->mutex); @@ -2485,31 +2485,31 @@ int iwl4965_mac_sta_add(struct ieee80211_hw *hw, sta_priv->common.sta_id = sta_id; /* Initialize rate scaling */ - IWL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n", + IL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n", sta->addr); - iwl4965_rs_rate_init(priv, sta, sta_id); + il4965_rs_rate_init(priv, sta, sta_id); mutex_unlock(&priv->mutex); return 0; } -void iwl4965_mac_channel_switch(struct ieee80211_hw *hw, +void il4965_mac_channel_switch(struct ieee80211_hw *hw, struct ieee80211_channel_switch *ch_switch) { - struct iwl_priv *priv = hw->priv; - const struct iwl_channel_info *ch_info; + struct il_priv *priv = hw->priv; + const struct il_channel_info *ch_info; struct ieee80211_conf *conf = &hw->conf; struct ieee80211_channel *channel = ch_switch->channel; - struct iwl_ht_config *ht_conf = &priv->current_ht_config; + struct il_ht_config *ht_conf = &priv->current_ht_config; - struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; u16 ch; - IWL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(priv, "enter\n"); mutex_lock(&priv->mutex); - if (iwl_legacy_is_rfkill(priv)) + if (il_is_rfkill(priv)) goto out; if (test_bit(STATUS_EXIT_PENDING, &priv->status) || @@ -2517,7 +2517,7 @@ void iwl4965_mac_channel_switch(struct ieee80211_hw *hw, test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status)) goto out; - if (!iwl_legacy_is_associated_ctx(ctx)) + if (!il_is_associated_ctx(ctx)) goto out; if (!priv->cfg->ops->lib->set_channel_switch) @@ -2527,9 +2527,9 @@ void iwl4965_mac_channel_switch(struct ieee80211_hw *hw, if (le16_to_cpu(ctx->active.channel) == ch) goto out; - ch_info = iwl_legacy_get_channel_info(priv, channel->band, ch); - if (!iwl_legacy_is_channel_valid(ch_info)) { - IWL_DEBUG_MAC80211(priv, "invalid channel\n"); + ch_info = il_get_channel_info(priv, channel->band, ch); + if (!il_is_channel_valid(ch_info)) { + IL_DEBUG_MAC80211(priv, "invalid channel\n"); goto out; } @@ -2559,13 +2559,13 @@ void iwl4965_mac_channel_switch(struct ieee80211_hw *hw, if ((le16_to_cpu(ctx->staging.channel) != ch)) ctx->staging.flags = 0; - iwl_legacy_set_rxon_channel(priv, channel, ctx); - iwl_legacy_set_rxon_ht(priv, ht_conf); - iwl_legacy_set_flags_for_band(priv, ctx, channel->band, ctx->vif); + il_set_rxon_channel(priv, channel, ctx); + il_set_rxon_ht(priv, ht_conf); + il_set_flags_for_band(priv, ctx, channel->band, ctx->vif); spin_unlock_irq(&priv->lock); - iwl_legacy_set_rate(priv); + il_set_rate(priv); /* * at this point, staging_rxon has the * configuration for channel switch @@ -2580,17 +2580,17 @@ void iwl4965_mac_channel_switch(struct ieee80211_hw *hw, out: mutex_unlock(&priv->mutex); - IWL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(priv, "leave\n"); } -void iwl4965_configure_filter(struct ieee80211_hw *hw, +void il4965_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags, unsigned int *total_flags, u64 multicast) { - struct iwl_priv *priv = hw->priv; + struct il_priv *priv = hw->priv; __le32 filter_or = 0, filter_nand = 0; - struct iwl_rxon_context *ctx; + struct il_rxon_context *ctx; #define CHK(test, flag) do { \ if (*total_flags & (test)) \ @@ -2599,7 +2599,7 @@ void iwl4965_configure_filter(struct ieee80211_hw *hw, filter_nand |= (flag); \ } while (0) - IWL_DEBUG_MAC80211(priv, "Enter: changed: 0x%x, total: 0x%x\n", + IL_DEBUG_MAC80211(priv, "Enter: changed: 0x%x, total: 0x%x\n", changed_flags, *total_flags); CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); @@ -2625,7 +2625,7 @@ void iwl4965_configure_filter(struct ieee80211_hw *hw, /* * Receiving all multicast frames is always enabled by the - * default flags setup in iwl_legacy_connection_init_rx_config() + * default flags setup in il_connection_init_rx_config() * since we currently do not support programming multicast * filters into the device. */ @@ -2639,9 +2639,9 @@ void iwl4965_configure_filter(struct ieee80211_hw *hw, * *****************************************************************************/ -static void iwl4965_bg_txpower_work(struct work_struct *work) +static void il4965_bg_txpower_work(struct work_struct *work) { - struct iwl_priv *priv = container_of(work, struct iwl_priv, + struct il_priv *priv = container_of(work, struct il_priv, txpower_work); mutex_lock(&priv->mutex); @@ -2666,62 +2666,62 @@ out: mutex_unlock(&priv->mutex); } -static void iwl4965_setup_deferred_work(struct iwl_priv *priv) +static void il4965_setup_deferred_work(struct il_priv *priv) { priv->workqueue = create_singlethread_workqueue(DRV_NAME); init_waitqueue_head(&priv->wait_command_queue); - INIT_WORK(&priv->restart, iwl4965_bg_restart); - INIT_WORK(&priv->rx_replenish, iwl4965_bg_rx_replenish); - INIT_WORK(&priv->run_time_calib_work, iwl4965_bg_run_time_calib_work); - INIT_DELAYED_WORK(&priv->init_alive_start, iwl4965_bg_init_alive_start); - INIT_DELAYED_WORK(&priv->alive_start, iwl4965_bg_alive_start); + INIT_WORK(&priv->restart, il4965_bg_restart); + INIT_WORK(&priv->rx_replenish, il4965_bg_rx_replenish); + INIT_WORK(&priv->run_time_calib_work, il4965_bg_run_time_calib_work); + INIT_DELAYED_WORK(&priv->init_alive_start, il4965_bg_init_alive_start); + INIT_DELAYED_WORK(&priv->alive_start, il4965_bg_alive_start); - iwl_legacy_setup_scan_deferred_work(priv); + il_setup_scan_deferred_work(priv); - INIT_WORK(&priv->txpower_work, iwl4965_bg_txpower_work); + INIT_WORK(&priv->txpower_work, il4965_bg_txpower_work); init_timer(&priv->statistics_periodic); priv->statistics_periodic.data = (unsigned long)priv; - priv->statistics_periodic.function = iwl4965_bg_statistics_periodic; + priv->statistics_periodic.function = il4965_bg_statistics_periodic; init_timer(&priv->watchdog); priv->watchdog.data = (unsigned long)priv; - priv->watchdog.function = iwl_legacy_bg_watchdog; + priv->watchdog.function = il_bg_watchdog; tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) - iwl4965_irq_tasklet, (unsigned long)priv); + il4965_irq_tasklet, (unsigned long)priv); } -static void iwl4965_cancel_deferred_work(struct iwl_priv *priv) +static void il4965_cancel_deferred_work(struct il_priv *priv) { cancel_work_sync(&priv->txpower_work); cancel_delayed_work_sync(&priv->init_alive_start); cancel_delayed_work(&priv->alive_start); cancel_work_sync(&priv->run_time_calib_work); - iwl_legacy_cancel_scan_deferred_work(priv); + il_cancel_scan_deferred_work(priv); del_timer_sync(&priv->statistics_periodic); } -static void iwl4965_init_hw_rates(struct iwl_priv *priv, +static void il4965_init_hw_rates(struct il_priv *priv, struct ieee80211_rate *rates) { int i; - for (i = 0; i < IWL_RATE_COUNT_LEGACY; i++) { + for (i = 0; i < IL_RATE_COUNT_LEGACY; i++) { rates[i].bitrate = iwlegacy_rates[i].ieee * 5; rates[i].hw_value = i; /* Rate scaling will work on indexes */ rates[i].hw_value_short = i; rates[i].flags = 0; - if ((i >= IWL_FIRST_CCK_RATE) && (i <= IWL_LAST_CCK_RATE)) { + if ((i >= IL_FIRST_CCK_RATE) && (i <= IL_LAST_CCK_RATE)) { /* * If CCK != 1M then set short preamble rate flag. */ rates[i].flags |= - (iwlegacy_rates[i].plcp == IWL_RATE_1M_PLCP) ? + (iwlegacy_rates[i].plcp == IL_RATE_1M_PLCP) ? 0 : IEEE80211_RATE_SHORT_PREAMBLE; } } @@ -2729,15 +2729,15 @@ static void iwl4965_init_hw_rates(struct iwl_priv *priv, /* * Acquire priv->lock before calling this function ! */ -void iwl4965_set_wr_ptrs(struct iwl_priv *priv, int txq_id, u32 index) +void il4965_set_wr_ptrs(struct il_priv *priv, int txq_id, u32 index) { - iwl_legacy_write_direct32(priv, HBUS_TARG_WRPTR, + il_write_direct32(priv, HBUS_TARG_WRPTR, (index & 0xff) | (txq_id << 8)); - iwl_legacy_write_prph(priv, IWL49_SCD_QUEUE_RDPTR(txq_id), index); + il_write_prph(priv, IWL49_SCD_QUEUE_RDPTR(txq_id), index); } -void iwl4965_tx_queue_set_status(struct iwl_priv *priv, - struct iwl_tx_queue *txq, +void il4965_tx_queue_set_status(struct il_priv *priv, + struct il_tx_queue *txq, int tx_fifo_id, int scd_retry) { int txq_id = txq->q.id; @@ -2746,7 +2746,7 @@ void iwl4965_tx_queue_set_status(struct iwl_priv *priv, int active = test_bit(txq_id, &priv->txq_ctx_active_msk) ? 1 : 0; /* Set up and activate */ - iwl_legacy_write_prph(priv, IWL49_SCD_QUEUE_STATUS_BITS(txq_id), + il_write_prph(priv, IWL49_SCD_QUEUE_STATUS_BITS(txq_id), (active << IWL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | (tx_fifo_id << IWL49_SCD_QUEUE_STTS_REG_POS_TXF) | (scd_retry << IWL49_SCD_QUEUE_STTS_REG_POS_WSL) | @@ -2755,13 +2755,13 @@ void iwl4965_tx_queue_set_status(struct iwl_priv *priv, txq->sched_retry = scd_retry; - IWL_DEBUG_INFO(priv, "%s %s Queue %d on AC %d\n", + IL_DEBUG_INFO(priv, "%s %s Queue %d on AC %d\n", active ? "Activate" : "Deactivate", scd_retry ? "BA" : "AC", txq_id, tx_fifo_id); } -static int iwl4965_init_drv(struct iwl_priv *priv) +static int il4965_init_drv(struct il_priv *priv) { int ret; @@ -2778,91 +2778,91 @@ static int iwl4965_init_drv(struct iwl_priv *priv) priv->iw_mode = NL80211_IFTYPE_STATION; priv->current_ht_config.smps = IEEE80211_SMPS_STATIC; - priv->missed_beacon_threshold = IWL_MISSED_BEACON_THRESHOLD_DEF; + priv->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; /* initialize force reset */ - priv->force_reset.reset_duration = IWL_DELAY_NEXT_FORCE_FW_RELOAD; + priv->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; /* Choose which receivers/antennas to use */ if (priv->cfg->ops->hcmd->set_rxon_chain) priv->cfg->ops->hcmd->set_rxon_chain(priv, - &priv->contexts[IWL_RXON_CTX_BSS]); + &priv->contexts[IL_RXON_CTX_BSS]); - iwl_legacy_init_scan_params(priv); + il_init_scan_params(priv); - ret = iwl_legacy_init_channel_map(priv); + ret = il_init_channel_map(priv); if (ret) { - IWL_ERR(priv, "initializing regulatory failed: %d\n", ret); + IL_ERR(priv, "initializing regulatory failed: %d\n", ret); goto err; } - ret = iwl_legacy_init_geos(priv); + ret = il_init_geos(priv); if (ret) { - IWL_ERR(priv, "initializing geos failed: %d\n", ret); + IL_ERR(priv, "initializing geos failed: %d\n", ret); goto err_free_channel_map; } - iwl4965_init_hw_rates(priv, priv->ieee_rates); + il4965_init_hw_rates(priv, priv->ieee_rates); return 0; err_free_channel_map: - iwl_legacy_free_channel_map(priv); + il_free_channel_map(priv); err: return ret; } -static void iwl4965_uninit_drv(struct iwl_priv *priv) +static void il4965_uninit_drv(struct il_priv *priv) { - iwl4965_calib_free_results(priv); - iwl_legacy_free_geos(priv); - iwl_legacy_free_channel_map(priv); + il4965_calib_free_results(priv); + il_free_geos(priv); + il_free_channel_map(priv); kfree(priv->scan_cmd); } -static void iwl4965_hw_detect(struct iwl_priv *priv) +static void il4965_hw_detect(struct il_priv *priv) { - priv->hw_rev = _iwl_legacy_read32(priv, CSR_HW_REV); - priv->hw_wa_rev = _iwl_legacy_read32(priv, CSR_HW_REV_WA_REG); + priv->hw_rev = _il_read32(priv, CSR_HW_REV); + priv->hw_wa_rev = _il_read32(priv, CSR_HW_REV_WA_REG); priv->rev_id = priv->pci_dev->revision; - IWL_DEBUG_INFO(priv, "HW Revision ID = 0x%X\n", priv->rev_id); + IL_DEBUG_INFO(priv, "HW Revision ID = 0x%X\n", priv->rev_id); } -static int iwl4965_set_hw_params(struct iwl_priv *priv) +static int il4965_set_hw_params(struct il_priv *priv) { priv->hw_params.max_rxq_size = RX_QUEUE_SIZE; priv->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; if (priv->cfg->mod_params->amsdu_size_8K) - priv->hw_params.rx_page_order = get_order(IWL_RX_BUF_SIZE_8K); + priv->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_8K); else - priv->hw_params.rx_page_order = get_order(IWL_RX_BUF_SIZE_4K); + priv->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_4K); - priv->hw_params.max_beacon_itrvl = IWL_MAX_UCODE_BEACON_INTERVAL; + priv->hw_params.max_beacon_itrvl = IL_MAX_UCODE_BEACON_INTERVAL; if (priv->cfg->mod_params->disable_11n) - priv->cfg->sku &= ~IWL_SKU_N; + priv->cfg->sku &= ~IL_SKU_N; /* Device-specific setup */ return priv->cfg->ops->lib->set_hw_params(priv); } -static const u8 iwl4965_bss_ac_to_fifo[] = { - IWL_TX_FIFO_VO, - IWL_TX_FIFO_VI, - IWL_TX_FIFO_BE, - IWL_TX_FIFO_BK, +static const u8 il4965_bss_ac_to_fifo[] = { + IL_TX_FIFO_VO, + IL_TX_FIFO_VI, + IL_TX_FIFO_BE, + IL_TX_FIFO_BK, }; -static const u8 iwl4965_bss_ac_to_queue[] = { +static const u8 il4965_bss_ac_to_queue[] = { 0, 1, 2, 3, }; static int -iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) +il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { int err = 0, i; - struct iwl_priv *priv; + struct il_priv *priv; struct ieee80211_hw *hw; - struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data); + struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data); unsigned long flags; u16 pci_cmd; @@ -2870,7 +2870,7 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) * 1. Allocating HW data ************************/ - hw = iwl_legacy_alloc_all(cfg); + hw = il_alloc_all(cfg); if (!hw) { err = -ENOMEM; goto out; @@ -2883,41 +2883,41 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) * more may be discovered when firmware * is loaded. */ - priv->valid_contexts = BIT(IWL_RXON_CTX_BSS); + priv->valid_contexts = BIT(IL_RXON_CTX_BSS); - for (i = 0; i < NUM_IWL_RXON_CTX; i++) + for (i = 0; i < NUM_IL_RXON_CTX; i++) priv->contexts[i].ctxid = i; - priv->contexts[IWL_RXON_CTX_BSS].always_active = true; - priv->contexts[IWL_RXON_CTX_BSS].is_active = true; - priv->contexts[IWL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON; - priv->contexts[IWL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING; - priv->contexts[IWL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC; - priv->contexts[IWL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM; - priv->contexts[IWL_RXON_CTX_BSS].ap_sta_id = IWL_AP_ID; - priv->contexts[IWL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY; - priv->contexts[IWL_RXON_CTX_BSS].ac_to_fifo = iwl4965_bss_ac_to_fifo; - priv->contexts[IWL_RXON_CTX_BSS].ac_to_queue = iwl4965_bss_ac_to_queue; - priv->contexts[IWL_RXON_CTX_BSS].exclusive_interface_modes = + priv->contexts[IL_RXON_CTX_BSS].always_active = true; + priv->contexts[IL_RXON_CTX_BSS].is_active = true; + priv->contexts[IL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON; + priv->contexts[IL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING; + priv->contexts[IL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC; + priv->contexts[IL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM; + priv->contexts[IL_RXON_CTX_BSS].ap_sta_id = IL_AP_ID; + priv->contexts[IL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY; + priv->contexts[IL_RXON_CTX_BSS].ac_to_fifo = il4965_bss_ac_to_fifo; + priv->contexts[IL_RXON_CTX_BSS].ac_to_queue = il4965_bss_ac_to_queue; + priv->contexts[IL_RXON_CTX_BSS].exclusive_interface_modes = BIT(NL80211_IFTYPE_ADHOC); - priv->contexts[IWL_RXON_CTX_BSS].interface_modes = + priv->contexts[IL_RXON_CTX_BSS].interface_modes = BIT(NL80211_IFTYPE_STATION); - priv->contexts[IWL_RXON_CTX_BSS].ap_devtype = RXON_DEV_TYPE_AP; - priv->contexts[IWL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS; - priv->contexts[IWL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS; - priv->contexts[IWL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS; + priv->contexts[IL_RXON_CTX_BSS].ap_devtype = RXON_DEV_TYPE_AP; + priv->contexts[IL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS; + priv->contexts[IL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS; + priv->contexts[IL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS; - BUILD_BUG_ON(NUM_IWL_RXON_CTX != 1); + BUILD_BUG_ON(NUM_IL_RXON_CTX != 1); SET_IEEE80211_DEV(hw, &pdev->dev); - IWL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n"); + IL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n"); priv->cfg = cfg; priv->pci_dev = pdev; priv->inta_mask = CSR_INI_SET_MASK; - if (iwl_legacy_alloc_traffic_mem(priv)) - IWL_ERR(priv, "Not enough memory to generate traffic log\n"); + if (il_alloc_traffic_mem(priv)) + IL_ERR(priv, "Not enough memory to generate traffic log\n"); /************************** * 2. Initializing PCI bus @@ -2942,7 +2942,7 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) DMA_BIT_MASK(32)); /* both attempts failed: */ if (err) { - IWL_WARN(priv, "No suitable DMA available.\n"); + IL_WARN(priv, "No suitable DMA available.\n"); goto out_pci_disable_device; } } @@ -2963,9 +2963,9 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto out_pci_release_regions; } - IWL_DEBUG_INFO(priv, "pci_resource_len = 0x%08llx\n", + IL_DEBUG_INFO(priv, "pci_resource_len = 0x%08llx\n", (unsigned long long) pci_resource_len(pdev, 0)); - IWL_DEBUG_INFO(priv, "pci_resource_base = %p\n", priv->hw_base); + IL_DEBUG_INFO(priv, "pci_resource_base = %p\n", priv->hw_base); /* these spin locks will be used in apm_ops.init and EEPROM access * we should init now @@ -2978,19 +2978,19 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) * strange state ... like being left stranded by a primary kernel * and this is now the kdump kernel trying to start up */ - iwl_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + il_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); - iwl4965_hw_detect(priv); - IWL_INFO(priv, "Detected %s, REV=0x%X\n", + il4965_hw_detect(priv); + IL_INFO(priv, "Detected %s, REV=0x%X\n", priv->cfg->name, priv->hw_rev); /* We disable the RETRY_TIMEOUT register (0x41) to keep * PCI Tx retries from interfering with C3 CPU state */ pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); - iwl4965_prepare_card_hw(priv); + il4965_prepare_card_hw(priv); if (!priv->hw_ready) { - IWL_WARN(priv, "Failed, HW not ready\n"); + IL_WARN(priv, "Failed, HW not ready\n"); goto out_iounmap; } @@ -2998,12 +2998,12 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) * 4. Read EEPROM *****************/ /* Read the EEPROM */ - err = iwl_legacy_eeprom_init(priv); + err = il_eeprom_init(priv); if (err) { - IWL_ERR(priv, "Unable to init EEPROM\n"); + IL_ERR(priv, "Unable to init EEPROM\n"); goto out_iounmap; } - err = iwl4965_eeprom_check_version(priv); + err = il4965_eeprom_check_version(priv); if (err) goto out_free_eeprom; @@ -3011,16 +3011,16 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto out_free_eeprom; /* extract MAC Address */ - iwl4965_eeprom_get_mac(priv, priv->addresses[0].addr); - IWL_DEBUG_INFO(priv, "MAC address: %pM\n", priv->addresses[0].addr); + il4965_eeprom_get_mac(priv, priv->addresses[0].addr); + IL_DEBUG_INFO(priv, "MAC address: %pM\n", priv->addresses[0].addr); priv->hw->wiphy->addresses = priv->addresses; priv->hw->wiphy->n_addresses = 1; /************************ * 5. Setup HW constants ************************/ - if (iwl4965_set_hw_params(priv)) { - IWL_ERR(priv, "failed to set hw parameters\n"); + if (il4965_set_hw_params(priv)) { + IL_ERR(priv, "failed to set hw parameters\n"); goto out_free_eeprom; } @@ -3028,7 +3028,7 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) * 6. Setup priv *******************/ - err = iwl4965_init_drv(priv); + err = il4965_init_drv(priv); if (err) goto out_free_eeprom; /* At this point both hw and priv are initialized. */ @@ -3037,20 +3037,20 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) * 7. Setup services ********************/ spin_lock_irqsave(&priv->lock, flags); - iwl_legacy_disable_interrupts(priv); + il_disable_interrupts(priv); spin_unlock_irqrestore(&priv->lock, flags); pci_enable_msi(priv->pci_dev); - err = request_irq(priv->pci_dev->irq, iwl_legacy_isr, + err = request_irq(priv->pci_dev->irq, il_isr, IRQF_SHARED, DRV_NAME, priv); if (err) { - IWL_ERR(priv, "Error allocating IRQ %d\n", priv->pci_dev->irq); + IL_ERR(priv, "Error allocating IRQ %d\n", priv->pci_dev->irq); goto out_disable_msi; } - iwl4965_setup_deferred_work(priv); - iwl4965_setup_rx_handlers(priv); + il4965_setup_deferred_work(priv); + il4965_setup_rx_handlers(priv); /********************************************* * 8. Enable interrupts and read RFKILL state @@ -3063,10 +3063,10 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) pci_write_config_word(priv->pci_dev, PCI_COMMAND, pci_cmd); } - iwl_legacy_enable_rfkill_int(priv); + il_enable_rfkill_int(priv); /* If platform's RF_KILL switch is NOT set to KILL */ - if (iwl_read32(priv, CSR_GP_CNTRL) & + if (il_read32(priv, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) clear_bit(STATUS_RF_KILL_HW, &priv->status); else @@ -3075,11 +3075,11 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) wiphy_rfkill_set_hw_state(priv->hw->wiphy, test_bit(STATUS_RF_KILL_HW, &priv->status)); - iwl_legacy_power_initialize(priv); + il_power_initialize(priv); init_completion(&priv->_4965.firmware_loading_complete); - err = iwl4965_request_firmware(priv, true); + err = il4965_request_firmware(priv, true); if (err) goto out_destroy_workqueue; @@ -3091,9 +3091,9 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) free_irq(priv->pci_dev->irq, priv); out_disable_msi: pci_disable_msi(priv->pci_dev); - iwl4965_uninit_drv(priv); + il4965_uninit_drv(priv); out_free_eeprom: - iwl_legacy_eeprom_free(priv); + il_eeprom_free(priv); out_iounmap: pci_iounmap(pdev, priv->hw_base); out_pci_release_regions: @@ -3102,15 +3102,15 @@ iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) out_pci_disable_device: pci_disable_device(pdev); out_ieee80211_free_hw: - iwl_legacy_free_traffic_mem(priv); + il_free_traffic_mem(priv); ieee80211_free_hw(priv->hw); out: return err; } -static void __devexit iwl4965_pci_remove(struct pci_dev *pdev) +static void __devexit il4965_pci_remove(struct pci_dev *pdev) { - struct iwl_priv *priv = pci_get_drvdata(pdev); + struct il_priv *priv = pci_get_drvdata(pdev); unsigned long flags; if (!priv) @@ -3118,62 +3118,62 @@ static void __devexit iwl4965_pci_remove(struct pci_dev *pdev) wait_for_completion(&priv->_4965.firmware_loading_complete); - IWL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n"); + IL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n"); - iwl_legacy_dbgfs_unregister(priv); - sysfs_remove_group(&pdev->dev.kobj, &iwl_attribute_group); + il_dbgfs_unregister(priv); + sysfs_remove_group(&pdev->dev.kobj, &il_attribute_group); - /* ieee80211_unregister_hw call wil cause iwl_mac_stop to - * to be called and iwl4965_down since we are removing the device + /* ieee80211_unregister_hw call wil cause il_mac_stop to + * to be called and il4965_down since we are removing the device * we need to set STATUS_EXIT_PENDING bit. */ set_bit(STATUS_EXIT_PENDING, &priv->status); - iwl_legacy_leds_exit(priv); + il_leds_exit(priv); if (priv->mac80211_registered) { ieee80211_unregister_hw(priv->hw); priv->mac80211_registered = 0; } else { - iwl4965_down(priv); + il4965_down(priv); } /* * Make sure device is reset to low power before unloading driver. - * This may be redundant with iwl4965_down(), but there are paths to - * run iwl4965_down() without calling apm_ops.stop(), and there are - * paths to avoid running iwl4965_down() at all before leaving driver. + * This may be redundant with il4965_down(), but there are paths to + * run il4965_down() without calling apm_ops.stop(), and there are + * paths to avoid running il4965_down() at all before leaving driver. * This (inexpensive) call *makes sure* device is reset. */ - iwl_legacy_apm_stop(priv); + il_apm_stop(priv); /* make sure we flush any pending irq or * tasklet for the driver */ spin_lock_irqsave(&priv->lock, flags); - iwl_legacy_disable_interrupts(priv); + il_disable_interrupts(priv); spin_unlock_irqrestore(&priv->lock, flags); - iwl4965_synchronize_irq(priv); + il4965_synchronize_irq(priv); - iwl4965_dealloc_ucode_pci(priv); + il4965_dealloc_ucode_pci(priv); if (priv->rxq.bd) - iwl4965_rx_queue_free(priv, &priv->rxq); - iwl4965_hw_txq_ctx_free(priv); + il4965_rx_queue_free(priv, &priv->rxq); + il4965_hw_txq_ctx_free(priv); - iwl_legacy_eeprom_free(priv); + il_eeprom_free(priv); /*netif_stop_queue(dev); */ flush_workqueue(priv->workqueue); - /* ieee80211_unregister_hw calls iwl_mac_stop, which flushes + /* ieee80211_unregister_hw calls il_mac_stop, which flushes * priv->workqueue... so we can't take down the workqueue * until now... */ destroy_workqueue(priv->workqueue); priv->workqueue = NULL; - iwl_legacy_free_traffic_mem(priv); + il_free_traffic_mem(priv); free_irq(priv->pci_dev->irq, priv); pci_disable_msi(priv->pci_dev); @@ -3182,7 +3182,7 @@ static void __devexit iwl4965_pci_remove(struct pci_dev *pdev) pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); - iwl4965_uninit_drv(priv); + il4965_uninit_drv(priv); dev_kfree_skb(priv->beacon_skb); @@ -3193,9 +3193,9 @@ static void __devexit iwl4965_pci_remove(struct pci_dev *pdev) * Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask * must be called under priv->lock and mac access */ -void iwl4965_txq_set_sched(struct iwl_priv *priv, u32 mask) +void il4965_txq_set_sched(struct il_priv *priv, u32 mask) { - iwl_legacy_write_prph(priv, IWL49_SCD_TXFACT, mask); + il_write_prph(priv, IWL49_SCD_TXFACT, mask); } /***************************************************************************** @@ -3205,38 +3205,38 @@ void iwl4965_txq_set_sched(struct iwl_priv *priv, u32 mask) *****************************************************************************/ /* Hardware specific file defines the PCI IDs table for that hardware module */ -static DEFINE_PCI_DEVICE_TABLE(iwl4965_hw_card_ids) = { +static DEFINE_PCI_DEVICE_TABLE(il4965_hw_card_ids) = { #if defined(CONFIG_IWL4965_MODULE) || defined(CONFIG_IWL4965) - {IWL_PCI_DEVICE(0x4229, PCI_ANY_ID, iwl4965_cfg)}, - {IWL_PCI_DEVICE(0x4230, PCI_ANY_ID, iwl4965_cfg)}, + {IL_PCI_DEVICE(0x4229, PCI_ANY_ID, il4965_cfg)}, + {IL_PCI_DEVICE(0x4230, PCI_ANY_ID, il4965_cfg)}, #endif /* CONFIG_IWL4965 */ {0} }; -MODULE_DEVICE_TABLE(pci, iwl4965_hw_card_ids); +MODULE_DEVICE_TABLE(pci, il4965_hw_card_ids); -static struct pci_driver iwl4965_driver = { +static struct pci_driver il4965_driver = { .name = DRV_NAME, - .id_table = iwl4965_hw_card_ids, - .probe = iwl4965_pci_probe, - .remove = __devexit_p(iwl4965_pci_remove), - .driver.pm = IWL_LEGACY_PM_OPS, + .id_table = il4965_hw_card_ids, + .probe = il4965_pci_probe, + .remove = __devexit_p(il4965_pci_remove), + .driver.pm = IL_LEGACY_PM_OPS, }; -static int __init iwl4965_init(void) +static int __init il4965_init(void) { int ret; pr_info(DRV_DESCRIPTION ", " DRV_VERSION "\n"); pr_info(DRV_COPYRIGHT "\n"); - ret = iwl4965_rate_control_register(); + ret = il4965_rate_control_register(); if (ret) { pr_err("Unable to register rate control algorithm: %d\n", ret); return ret; } - ret = pci_register_driver(&iwl4965_driver); + ret = pci_register_driver(&il4965_driver); if (ret) { pr_err("Unable to initialize PCI module\n"); goto error_register; @@ -3245,32 +3245,32 @@ static int __init iwl4965_init(void) return ret; error_register: - iwl4965_rate_control_unregister(); + il4965_rate_control_unregister(); return ret; } -static void __exit iwl4965_exit(void) +static void __exit il4965_exit(void) { - pci_unregister_driver(&iwl4965_driver); - iwl4965_rate_control_unregister(); + pci_unregister_driver(&il4965_driver); + il4965_rate_control_unregister(); } -module_exit(iwl4965_exit); -module_init(iwl4965_init); +module_exit(il4965_exit); +module_init(il4965_init); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG module_param_named(debug, iwlegacy_debug_level, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(debug, "debug output mask"); #endif -module_param_named(swcrypto, iwl4965_mod_params.sw_crypto, int, S_IRUGO); +module_param_named(swcrypto, il4965_mod_params.sw_crypto, int, S_IRUGO); MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])"); -module_param_named(queues_num, iwl4965_mod_params.num_of_queues, int, S_IRUGO); +module_param_named(queues_num, il4965_mod_params.num_of_queues, int, S_IRUGO); MODULE_PARM_DESC(queues_num, "number of hw queues."); -module_param_named(11n_disable, iwl4965_mod_params.disable_11n, int, S_IRUGO); +module_param_named(11n_disable, il4965_mod_params.disable_11n, int, S_IRUGO); MODULE_PARM_DESC(11n_disable, "disable 11n functionality"); -module_param_named(amsdu_size_8K, iwl4965_mod_params.amsdu_size_8K, +module_param_named(amsdu_size_8K, il4965_mod_params.amsdu_size_8K, int, S_IRUGO); MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size"); -module_param_named(fw_restart, iwl4965_mod_params.restart_fw, int, S_IRUGO); +module_param_named(fw_restart, il4965_mod_params.restart_fw, int, S_IRUGO); MODULE_PARM_DESC(fw_restart, "restart firmware in case of error"); -- cgit v1.2.3 From 46bc8d4b0e73ac75de323646d75a2333f47b84c3 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 24 Oct 2011 16:49:25 +0200 Subject: iwlegacy: rename priv to il Make code shorter. Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c | 90 +- drivers/net/wireless/iwlegacy/iwl-3945-led.c | 4 +- drivers/net/wireless/iwlegacy/iwl-3945-rs.c | 156 +- drivers/net/wireless/iwlegacy/iwl-3945.c | 786 ++++----- drivers/net/wireless/iwlegacy/iwl-3945.h | 78 +- drivers/net/wireless/iwlegacy/iwl-4965-calib.c | 220 +-- drivers/net/wireless/iwlegacy/iwl-4965-calib.h | 10 +- drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c | 92 +- drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c | 34 +- drivers/net/wireless/iwlegacy/iwl-4965-led.c | 12 +- drivers/net/wireless/iwlegacy/iwl-4965-led.h | 2 +- drivers/net/wireless/iwlegacy/iwl-4965-lib.c | 378 ++--- drivers/net/wireless/iwlegacy/iwl-4965-rs.c | 372 ++--- drivers/net/wireless/iwlegacy/iwl-4965-rx.c | 74 +- drivers/net/wireless/iwlegacy/iwl-4965-sta.c | 390 ++--- drivers/net/wireless/iwlegacy/iwl-4965-tx.c | 472 +++--- drivers/net/wireless/iwlegacy/iwl-4965-ucode.c | 54 +- drivers/net/wireless/iwlegacy/iwl-4965.c | 680 ++++---- drivers/net/wireless/iwlegacy/iwl-4965.h | 120 +- drivers/net/wireless/iwlegacy/iwl-core.c | 1016 ++++++------ drivers/net/wireless/iwlegacy/iwl-core.h | 264 +-- drivers/net/wireless/iwlegacy/iwl-debug.h | 16 +- drivers/net/wireless/iwlegacy/iwl-debugfs.c | 338 ++-- drivers/net/wireless/iwlegacy/iwl-dev.h | 62 +- drivers/net/wireless/iwlegacy/iwl-eeprom.c | 158 +- drivers/net/wireless/iwlegacy/iwl-eeprom.h | 18 +- drivers/net/wireless/iwlegacy/iwl-hcmd.c | 72 +- drivers/net/wireless/iwlegacy/iwl-helpers.h | 50 +- drivers/net/wireless/iwlegacy/iwl-io.h | 324 ++-- drivers/net/wireless/iwlegacy/iwl-led.c | 72 +- drivers/net/wireless/iwlegacy/iwl-led.h | 4 +- drivers/net/wireless/iwlegacy/iwl-legacy-rs.h | 12 +- drivers/net/wireless/iwlegacy/iwl-power.c | 76 +- drivers/net/wireless/iwlegacy/iwl-power.h | 6 +- drivers/net/wireless/iwlegacy/iwl-rx.c | 42 +- drivers/net/wireless/iwlegacy/iwl-scan.c | 272 ++-- drivers/net/wireless/iwlegacy/iwl-sta.c | 388 ++--- drivers/net/wireless/iwlegacy/iwl-sta.h | 38 +- drivers/net/wireless/iwlegacy/iwl-tx.c | 168 +- drivers/net/wireless/iwlegacy/iwl3945-base.c | 1868 +++++++++++----------- drivers/net/wireless/iwlegacy/iwl4965-base.c | 1750 ++++++++++---------- 41 files changed, 5518 insertions(+), 5520 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c index 954aed4e7b34..b767979c5dbb 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c @@ -29,22 +29,22 @@ #include "iwl-3945-debugfs.h" -static int il3945_statistics_flag(struct il_priv *priv, char *buf, int bufsz) +static int il3945_statistics_flag(struct il_priv *il, char *buf, int bufsz) { int p = 0; p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", - le32_to_cpu(priv->_3945.statistics.flag)); - if (le32_to_cpu(priv->_3945.statistics.flag) & + le32_to_cpu(il->_3945.statistics.flag)); + if (le32_to_cpu(il->_3945.statistics.flag) & UCODE_STATISTICS_CLEAR_MSK) p += scnprintf(buf + p, bufsz - p, "\tStatistics have been cleared\n"); p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n", - (le32_to_cpu(priv->_3945.statistics.flag) & + (le32_to_cpu(il->_3945.statistics.flag) & UCODE_STATISTICS_FREQUENCY_MSK) ? "2.4 GHz" : "5.2 GHz"); p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n", - (le32_to_cpu(priv->_3945.statistics.flag) & + (le32_to_cpu(il->_3945.statistics.flag) & UCODE_STATISTICS_NARROW_BAND_MSK) ? "enabled" : "disabled"); return p; @@ -54,7 +54,7 @@ ssize_t il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0; char *buf; int bufsz = sizeof(struct iwl39_statistics_rx_phy) * 40 + @@ -66,12 +66,12 @@ ssize_t il3945_ucode_rx_stats_read(struct file *file, struct iwl39_statistics_rx_non_phy *general, *accum_general; struct iwl39_statistics_rx_non_phy *delta_general, *max_general; - if (!il_is_alive(priv)) + if (!il_is_alive(il)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(il, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -80,20 +80,20 @@ ssize_t il3945_ucode_rx_stats_read(struct file *file, * the last statistics notification from uCode * might not reflect the current uCode activity */ - ofdm = &priv->_3945.statistics.rx.ofdm; - cck = &priv->_3945.statistics.rx.cck; - general = &priv->_3945.statistics.rx.general; - accum_ofdm = &priv->_3945.accum_statistics.rx.ofdm; - accum_cck = &priv->_3945.accum_statistics.rx.cck; - accum_general = &priv->_3945.accum_statistics.rx.general; - delta_ofdm = &priv->_3945.delta_statistics.rx.ofdm; - delta_cck = &priv->_3945.delta_statistics.rx.cck; - delta_general = &priv->_3945.delta_statistics.rx.general; - max_ofdm = &priv->_3945.max_delta.rx.ofdm; - max_cck = &priv->_3945.max_delta.rx.cck; - max_general = &priv->_3945.max_delta.rx.general; + ofdm = &il->_3945.statistics.rx.ofdm; + cck = &il->_3945.statistics.rx.cck; + general = &il->_3945.statistics.rx.general; + accum_ofdm = &il->_3945.accum_statistics.rx.ofdm; + accum_cck = &il->_3945.accum_statistics.rx.cck; + accum_general = &il->_3945.accum_statistics.rx.general; + delta_ofdm = &il->_3945.delta_statistics.rx.ofdm; + delta_cck = &il->_3945.delta_statistics.rx.cck; + delta_general = &il->_3945.delta_statistics.rx.general; + max_ofdm = &il->_3945.max_delta.rx.ofdm; + max_cck = &il->_3945.max_delta.rx.cck; + max_general = &il->_3945.max_delta.rx.general; - pos += il3945_statistics_flag(priv, buf, bufsz); + pos += il3945_statistics_flag(il, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" "acumulative delta max\n", "Statistics_Rx - OFDM:"); @@ -329,19 +329,19 @@ ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0; char *buf; int bufsz = (sizeof(struct iwl39_statistics_tx) * 48) + 250; ssize_t ret; struct iwl39_statistics_tx *tx, *accum_tx, *delta_tx, *max_tx; - if (!il_is_alive(priv)) + if (!il_is_alive(il)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(il, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -350,11 +350,11 @@ ssize_t il3945_ucode_tx_stats_read(struct file *file, * the last statistics notification from uCode * might not reflect the current uCode activity */ - tx = &priv->_3945.statistics.tx; - accum_tx = &priv->_3945.accum_statistics.tx; - delta_tx = &priv->_3945.delta_statistics.tx; - max_tx = &priv->_3945.max_delta.tx; - pos += il3945_statistics_flag(priv, buf, bufsz); + tx = &il->_3945.statistics.tx; + accum_tx = &il->_3945.accum_statistics.tx; + delta_tx = &il->_3945.delta_statistics.tx; + max_tx = &il->_3945.max_delta.tx; + pos += il3945_statistics_flag(il, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" "acumulative delta max\n", "Statistics_Tx:"); @@ -425,7 +425,7 @@ ssize_t il3945_ucode_general_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0; char *buf; int bufsz = sizeof(struct iwl39_statistics_general) * 10 + 300; @@ -435,12 +435,12 @@ ssize_t il3945_ucode_general_stats_read(struct file *file, struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; struct iwl39_statistics_div *div, *accum_div, *delta_div, *max_div; - if (!il_is_alive(priv)) + if (!il_is_alive(il)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(il, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -449,19 +449,19 @@ ssize_t il3945_ucode_general_stats_read(struct file *file, * the last statistics notification from uCode * might not reflect the current uCode activity */ - general = &priv->_3945.statistics.general; - dbg = &priv->_3945.statistics.general.dbg; - div = &priv->_3945.statistics.general.div; - accum_general = &priv->_3945.accum_statistics.general; - delta_general = &priv->_3945.delta_statistics.general; - max_general = &priv->_3945.max_delta.general; - accum_dbg = &priv->_3945.accum_statistics.general.dbg; - delta_dbg = &priv->_3945.delta_statistics.general.dbg; - max_dbg = &priv->_3945.max_delta.general.dbg; - accum_div = &priv->_3945.accum_statistics.general.div; - delta_div = &priv->_3945.delta_statistics.general.div; - max_div = &priv->_3945.max_delta.general.div; - pos += il3945_statistics_flag(priv, buf, bufsz); + general = &il->_3945.statistics.general; + dbg = &il->_3945.statistics.general.dbg; + div = &il->_3945.statistics.general.div; + accum_general = &il->_3945.accum_statistics.general; + delta_general = &il->_3945.delta_statistics.general; + max_general = &il->_3945.max_delta.general; + accum_dbg = &il->_3945.accum_statistics.general.dbg; + delta_dbg = &il->_3945.delta_statistics.general.dbg; + max_dbg = &il->_3945.max_delta.general.dbg; + accum_div = &il->_3945.accum_statistics.general.div; + delta_div = &il->_3945.delta_statistics.general.div; + max_div = &il->_3945.max_delta.general.div; + pos += il3945_statistics_flag(il, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" "acumulative delta max\n", "Statistics_General:"); diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-led.c b/drivers/net/wireless/iwlegacy/iwl-3945-led.c index 69703b07bd69..53ec4637015e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-led.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-led.c @@ -44,7 +44,7 @@ /* Send led command */ -static int il3945_send_led_cmd(struct il_priv *priv, +static int il3945_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd) { struct il_host_cmd cmd = { @@ -55,7 +55,7 @@ static int il3945_send_led_cmd(struct il_priv *priv, .callback = NULL, }; - return il_send_cmd(priv, &cmd); + return il_send_cmd(il, &cmd); } const struct il_led_ops il3945_led_ops = { diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c index d97f24bfc451..38f1b825af10 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c @@ -153,7 +153,7 @@ static int il3945_rate_scale_flush_windows(struct il3945_rs_sta *rs_sta) int unflushed = 0; int i; unsigned long flags; - struct il_priv *priv __maybe_unused = rs_sta->priv; + struct il_priv *il __maybe_unused = rs_sta->il; /* * For each rate, if we have collected data on that rate @@ -167,7 +167,7 @@ static int il3945_rate_scale_flush_windows(struct il3945_rs_sta *rs_sta) spin_lock_irqsave(&rs_sta->lock, flags); if (time_after(jiffies, rs_sta->win[i].stamp + IL_RATE_WIN_FLUSH)) { - IL_DEBUG_RATE(priv, "flushing %d samples of rate " + IL_DEBUG_RATE(il, "flushing %d samples of rate " "index %d\n", rs_sta->win[i].counter, i); il3945_clear_window(&rs_sta->win[i]); @@ -186,12 +186,12 @@ static int il3945_rate_scale_flush_windows(struct il3945_rs_sta *rs_sta) static void il3945_bg_rate_scale_flush(unsigned long data) { struct il3945_rs_sta *rs_sta = (void *)data; - struct il_priv *priv __maybe_unused = rs_sta->priv; + struct il_priv *il __maybe_unused = rs_sta->il; int unflushed = 0; unsigned long flags; u32 packet_count, duration, pps; - IL_DEBUG_RATE(priv, "enter\n"); + IL_DEBUG_RATE(il, "enter\n"); unflushed = il3945_rate_scale_flush_windows(rs_sta); @@ -206,7 +206,7 @@ static void il3945_bg_rate_scale_flush(unsigned long data) duration = jiffies_to_msecs(jiffies - rs_sta->last_partial_flush); - IL_DEBUG_RATE(priv, "Tx'd %d packets in %dms\n", + IL_DEBUG_RATE(il, "Tx'd %d packets in %dms\n", packet_count, duration); /* Determine packets per second */ @@ -226,7 +226,7 @@ static void il3945_bg_rate_scale_flush(unsigned long data) rs_sta->flush_time = msecs_to_jiffies(duration); - IL_DEBUG_RATE(priv, "new flush period: %d msec ave %d\n", + IL_DEBUG_RATE(il, "new flush period: %d msec ave %d\n", duration, packet_count); mod_timer(&rs_sta->rate_scale_flush, jiffies + @@ -244,7 +244,7 @@ static void il3945_bg_rate_scale_flush(unsigned long data) spin_unlock_irqrestore(&rs_sta->lock, flags); - IL_DEBUG_RATE(priv, "leave\n"); + IL_DEBUG_RATE(il, "leave\n"); } /** @@ -260,10 +260,10 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, { unsigned long flags; s32 fail_count; - struct il_priv *priv __maybe_unused = rs_sta->priv; + struct il_priv *il __maybe_unused = rs_sta->il; if (!retries) { - IL_DEBUG_RATE(priv, "leave: retries == 0 -- should be at least 1\n"); + IL_DEBUG_RATE(il, "leave: retries == 0 -- should be at least 1\n"); return; } @@ -332,24 +332,24 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, /* * Called after adding a new station to initialize rate scaling */ -void il3945_rs_rate_init(struct il_priv *priv, struct ieee80211_sta *sta, u8 sta_id) +void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_id) { - struct ieee80211_hw *hw = priv->hw; - struct ieee80211_conf *conf = &priv->hw->conf; + struct ieee80211_hw *hw = il->hw; + struct ieee80211_conf *conf = &il->hw->conf; struct il3945_sta_priv *psta; struct il3945_rs_sta *rs_sta; struct ieee80211_supported_band *sband; int i; - IL_DEBUG_INFO(priv, "enter\n"); - if (sta_id == priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id) + IL_DEBUG_INFO(il, "enter\n"); + if (sta_id == il->contexts[IL_RXON_CTX_BSS].bcast_sta_id) goto out; psta = (struct il3945_sta_priv *) sta->drv_priv; rs_sta = &psta->rs_sta; sband = hw->wiphy->bands[conf->channel->band]; - rs_sta->priv = priv; + rs_sta->il = il; rs_sta->start_rate = IL_RATE_INVALID; @@ -379,18 +379,18 @@ void il3945_rs_rate_init(struct il_priv *priv, struct ieee80211_sta *sta, u8 sta } } - priv->_3945.sta_supp_rates = sta->supp_rates[sband->band]; + il->_3945.sta_supp_rates = sta->supp_rates[sband->band]; /* For 5 GHz band it start at IL_FIRST_OFDM_RATE */ if (sband->band == IEEE80211_BAND_5GHZ) { rs_sta->last_txrate_idx += IL_FIRST_OFDM_RATE; - priv->_3945.sta_supp_rates = priv->_3945.sta_supp_rates << + il->_3945.sta_supp_rates = il->_3945.sta_supp_rates << IL_FIRST_OFDM_RATE; } out: - priv->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; + il->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; - IL_DEBUG_INFO(priv, "leave\n"); + IL_DEBUG_INFO(il, "leave\n"); } static void *il3945_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) @@ -399,7 +399,7 @@ static void *il3945_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) } /* rate scale requires free function to be implemented */ -static void il3945_rs_free(void *priv) +static void il3945_rs_free(void *il) { return; } @@ -408,24 +408,24 @@ static void *il3945_rs_alloc_sta(void *il_priv, struct ieee80211_sta *sta, gfp_t { struct il3945_rs_sta *rs_sta; struct il3945_sta_priv *psta = (void *) sta->drv_priv; - struct il_priv *priv __maybe_unused = il_priv; + struct il_priv *il __maybe_unused = il_priv; - IL_DEBUG_RATE(priv, "enter\n"); + IL_DEBUG_RATE(il, "enter\n"); rs_sta = &psta->rs_sta; spin_lock_init(&rs_sta->lock); init_timer(&rs_sta->rate_scale_flush); - IL_DEBUG_RATE(priv, "leave\n"); + IL_DEBUG_RATE(il, "leave\n"); return rs_sta; } static void il3945_rs_free_sta(void *il_priv, struct ieee80211_sta *sta, - void *priv_sta) + void *il_sta) { - struct il3945_rs_sta *rs_sta = priv_sta; + struct il3945_rs_sta *rs_sta = il_sta; /* * Be careful not to use any members of il3945_rs_sta (like trying @@ -442,18 +442,18 @@ static void il3945_rs_free_sta(void *il_priv, struct ieee80211_sta *sta, * NOTE: Uses il_priv->retry_rate for the # of retries attempted by * the hardware for each rate. */ -static void il3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, void *priv_sta, +static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band *sband, + struct ieee80211_sta *sta, void *il_sta, struct sk_buff *skb) { s8 retries = 0, current_count; int scale_rate_index, first_index, last_index; unsigned long flags; - struct il_priv *priv = (struct il_priv *)priv_rate; - struct il3945_rs_sta *rs_sta = priv_sta; + struct il_priv *il = (struct il_priv *)il_rate; + struct il3945_rs_sta *rs_sta = il_sta; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - IL_DEBUG_RATE(priv, "enter\n"); + IL_DEBUG_RATE(il, "enter\n"); retries = info->status.rates[0].count; /* Sanity Check for retries */ @@ -462,18 +462,18 @@ static void il3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_band first_index = sband->bitrates[info->status.rates[0].idx].hw_value; if ((first_index < 0) || (first_index >= IL_RATE_COUNT_3945)) { - IL_DEBUG_RATE(priv, "leave: Rate out of bounds: %d\n", first_index); + IL_DEBUG_RATE(il, "leave: Rate out of bounds: %d\n", first_index); return; } - if (!priv_sta) { - IL_DEBUG_RATE(priv, "leave: No STA priv data to update!\n"); + if (!il_sta) { + IL_DEBUG_RATE(il, "leave: No STA il data to update!\n"); return; } /* Treat uninitialized rate scaling data same as non-existing. */ - if (!rs_sta->priv) { - IL_DEBUG_RATE(priv, "leave: STA priv data uninitialized!\n"); + if (!rs_sta->il) { + IL_DEBUG_RATE(il, "leave: STA il data uninitialized!\n"); return; } @@ -487,19 +487,19 @@ static void il3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_band * Update the window for each rate. We determine which rates * were Tx'd based on the total number of retries vs. the number * of retries configured for each rate -- currently set to the - * priv value 'retry_rate' vs. rate specific + * il value 'retry_rate' vs. rate specific * * On exit from this while loop last_index indicates the rate * at which the frame was finally transmitted (or failed if no * ACK) */ while (retries > 1) { - if ((retries - 1) < priv->retry_rate) { + if ((retries - 1) < il->retry_rate) { current_count = (retries - 1); last_index = scale_rate_index; } else { - current_count = priv->retry_rate; - last_index = il3945_rs_next_rate(priv, + current_count = il->retry_rate; + last_index = il3945_rs_next_rate(il, scale_rate_index); } @@ -508,7 +508,7 @@ static void il3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_band il3945_collect_tx_data(rs_sta, &rs_sta->win[scale_rate_index], 0, current_count, scale_rate_index); - IL_DEBUG_RATE(priv, "Update rate %d for %d retries.\n", + IL_DEBUG_RATE(il, "Update rate %d for %d retries.\n", scale_rate_index, current_count); retries -= current_count; @@ -518,7 +518,7 @@ static void il3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_band /* Update the last index window with success/failure based on ACK */ - IL_DEBUG_RATE(priv, "Update rate %d with %s.\n", + IL_DEBUG_RATE(il, "Update rate %d with %s.\n", last_index, (info->flags & IEEE80211_TX_STAT_ACK) ? "success" : "failure"); @@ -543,7 +543,7 @@ static void il3945_rs_tx_status(void *priv_rate, struct ieee80211_supported_band spin_unlock_irqrestore(&rs_sta->lock, flags); - IL_DEBUG_RATE(priv, "leave\n"); + IL_DEBUG_RATE(il, "leave\n"); } static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, @@ -551,7 +551,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, { u8 high = IL_RATE_INVALID; u8 low = IL_RATE_INVALID; - struct il_priv *priv __maybe_unused = rs_sta->priv; + struct il_priv *il __maybe_unused = rs_sta->il; /* 802.11A walks to the next literal adjacent rate in * the rate table */ @@ -591,7 +591,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, break; if (rate_mask & (1 << low)) break; - IL_DEBUG_RATE(priv, "Skipping masked lower rate: %d\n", low); + IL_DEBUG_RATE(il, "Skipping masked lower rate: %d\n", low); } high = index; @@ -604,7 +604,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, break; if (rate_mask & (1 << high)) break; - IL_DEBUG_RATE(priv, "Skipping masked higher rate: %d\n", high); + IL_DEBUG_RATE(il, "Skipping masked higher rate: %d\n", high); } return (high << 8) | low; @@ -626,8 +626,8 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, * rate table and must reference the driver allocated rate table * */ -static void il3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, - void *priv_sta, struct ieee80211_tx_rate_control *txrc) +static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, + void *il_sta, struct ieee80211_tx_rate_control *txrc) { struct ieee80211_supported_band *sband = txrc->sband; struct sk_buff *skb = txrc->skb; @@ -635,7 +635,7 @@ static void il3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, u8 high = IL_RATE_INVALID; u16 high_low; int index; - struct il3945_rs_sta *rs_sta = priv_sta; + struct il3945_rs_sta *rs_sta = il_sta; struct il3945_rate_scale_data *window = NULL; int current_tpt = IL_INVALID_VALUE; int low_tpt = IL_INVALID_VALUE; @@ -645,18 +645,18 @@ static void il3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, unsigned long flags; u16 rate_mask; s8 max_rate_idx = -1; - struct il_priv *priv __maybe_unused = (struct il_priv *)priv_r; + struct il_priv *il __maybe_unused = (struct il_priv *)il_r; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - IL_DEBUG_RATE(priv, "enter\n"); + IL_DEBUG_RATE(il, "enter\n"); /* Treat uninitialized rate scaling data same as non-existing. */ - if (rs_sta && !rs_sta->priv) { - IL_DEBUG_RATE(priv, "Rate scaling information not initialized yet.\n"); - priv_sta = NULL; + if (rs_sta && !rs_sta->il) { + IL_DEBUG_RATE(il, "Rate scaling information not initialized yet.\n"); + il_sta = NULL; } - if (rate_control_send_low(sta, priv_sta, txrc)) + if (rate_control_send_low(sta, il_sta, txrc)) return; rate_mask = sta->supp_rates[sband->band]; @@ -699,7 +699,7 @@ static void il3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, (window->success_counter < IL_RATE_MIN_SUCCESS_TH))) { spin_unlock_irqrestore(&rs_sta->lock, flags); - IL_DEBUG_RATE(priv, "Invalid average_tpt on rate %d: " + IL_DEBUG_RATE(il, "Invalid average_tpt on rate %d: " "counter: %d, success_counter: %d, " "expected_tpt is %sNULL\n", index, @@ -737,7 +737,7 @@ static void il3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, /* Low success ratio , need to drop the rate */ if ((window->success_ratio < IL_RATE_DECREASE_TH) || !current_tpt) { - IL_DEBUG_RATE(priv, "decrease rate because of low success_ratio\n"); + IL_DEBUG_RATE(il, "decrease rate because of low success_ratio\n"); scale_action = -1; /* No throughput measured yet for adjacent rates, * try increase */ @@ -756,7 +756,7 @@ static void il3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, (high_tpt != IL_INVALID_VALUE) && (low_tpt < current_tpt) && (high_tpt < current_tpt)) { - IL_DEBUG_RATE(priv, "No action -- low [%d] & high [%d] < " + IL_DEBUG_RATE(il, "No action -- low [%d] & high [%d] < " "current_tpt [%d]\n", low_tpt, high_tpt, current_tpt); scale_action = 0; @@ -771,13 +771,13 @@ static void il3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, window->success_ratio >= IL_RATE_INCREASE_TH) scale_action = 1; else { - IL_DEBUG_RATE(priv, + IL_DEBUG_RATE(il, "decrease rate because of high tpt\n"); scale_action = 0; } } else if (low_tpt != IL_INVALID_VALUE) { if (low_tpt > current_tpt) { - IL_DEBUG_RATE(priv, + IL_DEBUG_RATE(il, "decrease rate because of low tpt\n"); scale_action = -1; } else if (window->success_ratio >= IL_RATE_INCREASE_TH) { @@ -816,7 +816,7 @@ static void il3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, break; } - IL_DEBUG_RATE(priv, "Selected %d (action %d) - low %d high %d\n", + IL_DEBUG_RATE(il, "Selected %d (action %d) - low %d high %d\n", index, scale_action, low, high); out: @@ -831,7 +831,7 @@ static void il3945_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, info->control.rates[0].idx = rs_sta->last_txrate_idx; } - IL_DEBUG_RATE(priv, "leave: %d\n", index); + IL_DEBUG_RATE(il, "leave: %d\n", index); } #ifdef CONFIG_MAC80211_DEBUGFS @@ -878,10 +878,10 @@ static const struct file_operations rs_sta_dbgfs_stats_table_ops = { .llseek = default_llseek, }; -static void il3945_add_debugfs(void *priv, void *priv_sta, +static void il3945_add_debugfs(void *il, void *il_sta, struct dentry *dir) { - struct il3945_rs_sta *lq_sta = priv_sta; + struct il3945_rs_sta *lq_sta = il_sta; lq_sta->rs_sta_dbgfs_stats_table_file = debugfs_create_file("rate_stats_table", 0600, dir, @@ -889,9 +889,9 @@ static void il3945_add_debugfs(void *priv, void *priv_sta, } -static void il3945_remove_debugfs(void *priv, void *priv_sta) +static void il3945_remove_debugfs(void *il, void *il_sta) { - struct il3945_rs_sta *lq_sta = priv_sta; + struct il3945_rs_sta *lq_sta = il_sta; debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file); } #endif @@ -901,9 +901,9 @@ static void il3945_remove_debugfs(void *priv, void *priv_sta) * the station is added. Since mac80211 calls this function before a * station is added we ignore it. */ -static void il3945_rs_rate_init_stub(void *priv_r, +static void il3945_rs_rate_init_stub(void *il_r, struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, void *priv_sta) + struct ieee80211_sta *sta, void *il_sta) { } @@ -925,21 +925,21 @@ static struct rate_control_ops rs_ops = { }; void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; s32 rssi = 0; unsigned long flags; struct il3945_rs_sta *rs_sta; struct ieee80211_sta *sta; struct il3945_sta_priv *psta; - IL_DEBUG_RATE(priv, "enter\n"); + IL_DEBUG_RATE(il, "enter\n"); rcu_read_lock(); - sta = ieee80211_find_sta(priv->contexts[IL_RXON_CTX_BSS].vif, - priv->stations[sta_id].sta.sta.addr); + sta = ieee80211_find_sta(il->contexts[IL_RXON_CTX_BSS].vif, + il->stations[sta_id].sta.sta.addr); if (!sta) { - IL_DEBUG_RATE(priv, "Unable to find station to initialize rate scaling.\n"); + IL_DEBUG_RATE(il, "Unable to find station to initialize rate scaling.\n"); rcu_read_unlock(); return; } @@ -950,10 +950,10 @@ void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) spin_lock_irqsave(&rs_sta->lock, flags); rs_sta->tgg = 0; - switch (priv->band) { + switch (il->band) { case IEEE80211_BAND_2GHZ: /* TODO: this always does G, not a regression */ - if (priv->contexts[IL_RXON_CTX_BSS].active.flags & + if (il->contexts[IL_RXON_CTX_BSS].active.flags & RXON_FLG_TGG_PROTECT_MSK) { rs_sta->tgg = 1; rs_sta->expected_tpt = il3945_expected_tpt_g_prot; @@ -971,15 +971,15 @@ void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) spin_unlock_irqrestore(&rs_sta->lock, flags); - rssi = priv->_3945.last_rx_rssi; + rssi = il->_3945.last_rx_rssi; if (rssi == 0) rssi = IL_MIN_RSSI_VAL; - IL_DEBUG_RATE(priv, "Network RSSI: %d\n", rssi); + IL_DEBUG_RATE(il, "Network RSSI: %d\n", rssi); - rs_sta->start_rate = il3945_get_rate_index_by_rssi(rssi, priv->band); + rs_sta->start_rate = il3945_get_rate_index_by_rssi(rssi, il->band); - IL_DEBUG_RATE(priv, "leave: rssi %d assign rate index: " + IL_DEBUG_RATE(il, "leave: rssi %d assign rate index: " "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate, il3945_rates[rs_sta->start_rate].plcp); rcu_read_unlock(); diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index 6d1740b051df..c9b5dcf446b4 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -108,7 +108,7 @@ static inline u8 il3945_get_prev_ieee_rate(u8 rate_index) * Use for only special debugging. This function is just a placeholder as-is, * you'll need to provide the special bits! ... * ... and set IL_EVT_DISABLE to 1. */ -void il3945_disable_events(struct il_priv *priv) +void il3945_disable_events(struct il_priv *il) { int i; u32 base; /* SRAM address of event log header */ @@ -164,27 +164,27 @@ void il3945_disable_events(struct il_priv *priv) 0x00000000, /* 1503 - 1472 */ }; - base = le32_to_cpu(priv->card_alive.log_event_table_ptr); + base = le32_to_cpu(il->card_alive.log_event_table_ptr); if (!il3945_hw_valid_rtc_data_addr(base)) { - IL_ERR(priv, "Invalid event log pointer 0x%08X\n", base); + IL_ERR(il, "Invalid event log pointer 0x%08X\n", base); return; } - disable_ptr = il_read_targ_mem(priv, base + (4 * sizeof(u32))); - array_size = il_read_targ_mem(priv, base + (5 * sizeof(u32))); + disable_ptr = il_read_targ_mem(il, base + (4 * sizeof(u32))); + array_size = il_read_targ_mem(il, base + (5 * sizeof(u32))); if (IL_EVT_DISABLE && (array_size == IL_EVT_DISABLE_SIZE)) { - IL_DEBUG_INFO(priv, "Disabling selected uCode log events at 0x%x\n", + IL_DEBUG_INFO(il, "Disabling selected uCode log events at 0x%x\n", disable_ptr); for (i = 0; i < IL_EVT_DISABLE_SIZE; i++) - il_write_targ_mem(priv, + il_write_targ_mem(il, disable_ptr + (i * sizeof(u32)), evt_disable[i]); } else { - IL_DEBUG_INFO(priv, "Selected uCode log events may be disabled\n"); - IL_DEBUG_INFO(priv, " by writing \"1\"s into disable bitmap\n"); - IL_DEBUG_INFO(priv, " in SRAM at 0x%x, size %d u32s\n", + IL_DEBUG_INFO(il, "Selected uCode log events may be disabled\n"); + IL_DEBUG_INFO(il, " by writing \"1\"s into disable bitmap\n"); + IL_DEBUG_INFO(il, " in SRAM at 0x%x, size %d u32s\n", disable_ptr, array_size); } @@ -240,11 +240,11 @@ static inline const char *il3945_get_tx_fail_reason(u32 status) * for A and B mode we need to overright prev * value */ -int il3945_rs_next_rate(struct il_priv *priv, int rate) +int il3945_rs_next_rate(struct il_priv *il, int rate) { int next_rate = il3945_get_prev_ieee_rate(rate); - switch (priv->band) { + switch (il->band) { case IEEE80211_BAND_5GHZ: if (rate == IL_RATE_12M_INDEX) next_rate = IL_RATE_9M_INDEX; @@ -252,8 +252,8 @@ int il3945_rs_next_rate(struct il_priv *priv, int rate) next_rate = IL_RATE_6M_INDEX; break; case IEEE80211_BAND_2GHZ: - if (!(priv->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && - il_is_associated(priv, IL_RXON_CTX_BSS)) { + if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && + il_is_associated(il, IL_RXON_CTX_BSS)) { if (rate == IL_RATE_11M_INDEX) next_rate = IL_RATE_5M_INDEX; } @@ -274,10 +274,10 @@ int il3945_rs_next_rate(struct il_priv *priv, int rate) * need to be reclaimed. As result, some free space forms. If there is * enough free space (> low mark), wake the stack that feeds us. */ -static void il3945_tx_queue_reclaim(struct il_priv *priv, +static void il3945_tx_queue_reclaim(struct il_priv *il, int txq_id, int index) { - struct il_tx_queue *txq = &priv->txq[txq_id]; + struct il_tx_queue *txq = &il->txq[txq_id]; struct il_queue *q = &txq->q; struct il_tx_info *tx_info; @@ -288,28 +288,28 @@ static void il3945_tx_queue_reclaim(struct il_priv *priv, q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { tx_info = &txq->txb[txq->q.read_ptr]; - ieee80211_tx_status_irqsafe(priv->hw, tx_info->skb); + ieee80211_tx_status_irqsafe(il->hw, tx_info->skb); tx_info->skb = NULL; - priv->cfg->ops->lib->txq_free_tfd(priv, txq); + il->cfg->ops->lib->txq_free_tfd(il, txq); } if (il_queue_space(q) > q->low_mark && (txq_id >= 0) && (txq_id != IWL39_CMD_QUEUE_NUM) && - priv->mac80211_registered) - il_wake_queue(priv, txq); + il->mac80211_registered) + il_wake_queue(il, txq); } /** * il3945_rx_reply_tx - Handle Tx response */ -static void il3945_rx_reply_tx(struct il_priv *priv, +static void il3945_rx_reply_tx(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); int index = SEQ_TO_INDEX(sequence); - struct il_tx_queue *txq = &priv->txq[txq_id]; + struct il_tx_queue *txq = &il->txq[txq_id]; struct ieee80211_tx_info *info; struct il3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; u32 status = le32_to_cpu(tx_resp->status); @@ -317,7 +317,7 @@ static void il3945_rx_reply_tx(struct il_priv *priv, int fail; if ((index >= txq->q.n_bd) || (il_queue_used(&txq->q, index) == 0)) { - IL_ERR(priv, "Read index for DMA queue txq_id (%d) index %d " + IL_ERR(il, "Read index for DMA queue txq_id (%d) index %d " "is out of range [0-%d] %d %d\n", txq_id, index, txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr); @@ -342,15 +342,15 @@ static void il3945_rx_reply_tx(struct il_priv *priv, info->flags |= ((status & TX_STATUS_MSK) == TX_STATUS_SUCCESS) ? IEEE80211_TX_STAT_ACK : 0; - IL_DEBUG_TX(priv, "Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", + IL_DEBUG_TX(il, "Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", txq_id, il3945_get_tx_fail_reason(status), status, tx_resp->rate, tx_resp->failure_frame); - IL_DEBUG_TX_REPLY(priv, "Tx queue reclaim %d\n", index); - il3945_tx_queue_reclaim(priv, txq_id, index); + IL_DEBUG_TX_REPLY(il, "Tx queue reclaim %d\n", index); + il3945_tx_queue_reclaim(il, txq_id, index); if (status & TX_ABORT_REQUIRED_MSK) - IL_ERR(priv, "TODO: Implement Tx ABORT REQUIRED!!!\n"); + IL_ERR(il, "TODO: Implement Tx ABORT REQUIRED!!!\n"); } @@ -363,7 +363,7 @@ static void il3945_rx_reply_tx(struct il_priv *priv, * *****************************************************************************/ #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS -static void il3945_accumulative_statistics(struct il_priv *priv, +static void il3945_accumulative_statistics(struct il_priv *il, __le32 *stats) { int i; @@ -371,10 +371,10 @@ static void il3945_accumulative_statistics(struct il_priv *priv, u32 *accum_stats; u32 *delta, *max_delta; - prev_stats = (__le32 *)&priv->_3945.statistics; - accum_stats = (u32 *)&priv->_3945.accum_statistics; - delta = (u32 *)&priv->_3945.delta_statistics; - max_delta = (u32 *)&priv->_3945.max_delta; + prev_stats = (__le32 *)&il->_3945.statistics; + accum_stats = (u32 *)&il->_3945.accum_statistics; + delta = (u32 *)&il->_3945.delta_statistics; + max_delta = (u32 *)&il->_3945.max_delta; for (i = sizeof(__le32); i < sizeof(struct il3945_notif_statistics); i += sizeof(__le32), stats++, prev_stats++, delta++, @@ -389,29 +389,29 @@ static void il3945_accumulative_statistics(struct il_priv *priv, } /* reset accumulative statistics for "no-counter" type statistics */ - priv->_3945.accum_statistics.general.temperature = - priv->_3945.statistics.general.temperature; - priv->_3945.accum_statistics.general.ttl_timestamp = - priv->_3945.statistics.general.ttl_timestamp; + il->_3945.accum_statistics.general.temperature = + il->_3945.statistics.general.temperature; + il->_3945.accum_statistics.general.ttl_timestamp = + il->_3945.statistics.general.ttl_timestamp; } #endif -void il3945_hw_rx_statistics(struct il_priv *priv, +void il3945_hw_rx_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); - IL_DEBUG_RX(priv, "Statistics notification received (%d vs %d).\n", + IL_DEBUG_RX(il, "Statistics notification received (%d vs %d).\n", (int)sizeof(struct il3945_notif_statistics), le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS - il3945_accumulative_statistics(priv, (__le32 *)&pkt->u.raw); + il3945_accumulative_statistics(il, (__le32 *)&pkt->u.raw); #endif - memcpy(&priv->_3945.statistics, pkt->u.raw, sizeof(priv->_3945.statistics)); + memcpy(&il->_3945.statistics, pkt->u.raw, sizeof(il->_3945.statistics)); } -void il3945_reply_statistics(struct il_priv *priv, +void il3945_reply_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); @@ -419,16 +419,16 @@ void il3945_reply_statistics(struct il_priv *priv, if (le32_to_cpu(*flag) & UCODE_STATISTICS_CLEAR_MSK) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS - memset(&priv->_3945.accum_statistics, 0, + memset(&il->_3945.accum_statistics, 0, sizeof(struct il3945_notif_statistics)); - memset(&priv->_3945.delta_statistics, 0, + memset(&il->_3945.delta_statistics, 0, sizeof(struct il3945_notif_statistics)); - memset(&priv->_3945.max_delta, 0, + memset(&il->_3945.max_delta, 0, sizeof(struct il3945_notif_statistics)); #endif - IL_DEBUG_RX(priv, "Statistics have been cleared\n"); + IL_DEBUG_RX(il, "Statistics have been cleared\n"); } - il3945_hw_rx_statistics(priv, rxb); + il3945_hw_rx_statistics(il, rxb); } @@ -439,24 +439,24 @@ void il3945_reply_statistics(struct il_priv *priv, ******************************************************************************/ /* This is necessary only for a number of statistics, see the caller. */ -static int il3945_is_network_packet(struct il_priv *priv, +static int il3945_is_network_packet(struct il_priv *il, struct ieee80211_hdr *header) { /* Filter incoming packets to determine if they are targeted toward * this network, discarding packets coming from ourselves */ - switch (priv->iw_mode) { + switch (il->iw_mode) { case NL80211_IFTYPE_ADHOC: /* Header: Dest. | Source | BSSID */ /* packets to our IBSS update information */ - return !compare_ether_addr(header->addr3, priv->bssid); + return !compare_ether_addr(header->addr3, il->bssid); case NL80211_IFTYPE_STATION: /* Header: Dest. | AP{BSSID} | Source */ /* packets to our IBSS update information */ - return !compare_ether_addr(header->addr2, priv->bssid); + return !compare_ether_addr(header->addr2, il->bssid); default: return 1; } } -static void il3945_pass_packet_to_mac80211(struct il_priv *priv, +static void il3945_pass_packet_to_mac80211(struct il_priv *il, struct il_rx_mem_buffer *rxb, struct ieee80211_rx_status *stats) { @@ -470,43 +470,43 @@ static void il3945_pass_packet_to_mac80211(struct il_priv *priv, /* We received data from the HW, so stop the watchdog */ if (unlikely(len + IWL39_RX_FRAME_SIZE > - PAGE_SIZE << priv->hw_params.rx_page_order)) { - IL_DEBUG_DROP(priv, "Corruption detected!\n"); + PAGE_SIZE << il->hw_params.rx_page_order)) { + IL_DEBUG_DROP(il, "Corruption detected!\n"); return; } /* We only process data packets if the interface is open */ - if (unlikely(!priv->is_open)) { - IL_DEBUG_DROP_LIMIT(priv, + if (unlikely(!il->is_open)) { + IL_DEBUG_DROP_LIMIT(il, "Dropping packet while interface is not open.\n"); return; } skb = dev_alloc_skb(128); if (!skb) { - IL_ERR(priv, "dev_alloc_skb failed\n"); + IL_ERR(il, "dev_alloc_skb failed\n"); return; } if (!il3945_mod_params.sw_crypto) - il_set_decrypted_flag(priv, + il_set_decrypted_flag(il, (struct ieee80211_hdr *)rxb_addr(rxb), le32_to_cpu(rx_end->status), stats); skb_add_rx_frag(skb, 0, rxb->page, (void *)rx_hdr->payload - (void *)pkt, len); - il_update_stats(priv, false, fc, len); + il_update_stats(il, false, fc, len); memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats)); - ieee80211_rx(priv->hw, skb); - priv->alloc_rxb_page--; + ieee80211_rx(il->hw, skb); + il->alloc_rxb_page--; rxb->page = NULL; } #define IL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6) -static void il3945_rx_reply_rx(struct il_priv *priv, +static void il3945_rx_reply_rx(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct ieee80211_hdr *header; @@ -539,14 +539,14 @@ static void il3945_rx_reply_rx(struct il_priv *priv, rx_status.flag |= RX_FLAG_SHORTPRE; if ((unlikely(rx_stats->phy_count > 20))) { - IL_DEBUG_DROP(priv, "dsp size out of range [0,20]: %d/n", + IL_DEBUG_DROP(il, "dsp size out of range [0,20]: %d/n", rx_stats->phy_count); return; } if (!(rx_end->status & RX_RES_STATUS_NO_CRC32_ERROR) || !(rx_end->status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { - IL_DEBUG_RX(priv, "Bad CRC or FIFO: 0x%08X.\n", rx_end->status); + IL_DEBUG_RX(il, "Bad CRC or FIFO: 0x%08X.\n", rx_end->status); return; } @@ -555,34 +555,34 @@ static void il3945_rx_reply_rx(struct il_priv *priv, /* Convert 3945's rssi indicator to dBm */ rx_status.signal = rx_stats->rssi - IWL39_RSSI_OFFSET; - IL_DEBUG_STATS(priv, "Rssi %d sig_avg %d noise_diff %d\n", + IL_DEBUG_STATS(il, "Rssi %d sig_avg %d noise_diff %d\n", rx_status.signal, rx_stats_sig_avg, rx_stats_noise_diff); header = (struct ieee80211_hdr *)IL_RX_DATA(pkt); - network_packet = il3945_is_network_packet(priv, header); + network_packet = il3945_is_network_packet(il, header); - IL_DEBUG_STATS_LIMIT(priv, "[%c] %d RSSI:%d Signal:%u, Rate:%u\n", + IL_DEBUG_STATS_LIMIT(il, "[%c] %d RSSI:%d Signal:%u, Rate:%u\n", network_packet ? '*' : ' ', le16_to_cpu(rx_hdr->channel), rx_status.signal, rx_status.signal, rx_status.rate_idx); - il_dbg_log_rx_data_frame(priv, le16_to_cpu(rx_hdr->len), + il_dbg_log_rx_data_frame(il, le16_to_cpu(rx_hdr->len), header); if (network_packet) { - priv->_3945.last_beacon_time = + il->_3945.last_beacon_time = le32_to_cpu(rx_end->beacon_timestamp); - priv->_3945.last_tsf = le64_to_cpu(rx_end->timestamp); - priv->_3945.last_rx_rssi = rx_status.signal; + il->_3945.last_tsf = le64_to_cpu(rx_end->timestamp); + il->_3945.last_rx_rssi = rx_status.signal; } - il3945_pass_packet_to_mac80211(priv, rxb, &rx_status); + il3945_pass_packet_to_mac80211(il, rxb, &rx_status); } -int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *priv, +int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, struct il_tx_queue *txq, dma_addr_t addr, u16 len, u8 reset, u8 pad) { @@ -600,7 +600,7 @@ int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *priv, count = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags)); if ((count >= NUM_TFD_CHUNKS) || (count < 0)) { - IL_ERR(priv, "Error can not send more than %d chunks\n", + IL_ERR(il, "Error can not send more than %d chunks\n", NUM_TFD_CHUNKS); return -EINVAL; } @@ -621,19 +621,19 @@ int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *priv, * * Does NOT advance any indexes */ -void il3945_hw_txq_free_tfd(struct il_priv *priv, struct il_tx_queue *txq) +void il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) { struct il3945_tfd *tfd_tmp = (struct il3945_tfd *)txq->tfds; int index = txq->q.read_ptr; struct il3945_tfd *tfd = &tfd_tmp[index]; - struct pci_dev *dev = priv->pci_dev; + struct pci_dev *dev = il->pci_dev; int i; int counter; /* sanity check */ counter = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags)); if (counter > NUM_TFD_CHUNKS) { - IL_ERR(priv, "Too many chunks: %i\n", counter); + IL_ERR(il, "Too many chunks: %i\n", counter); /* @todo issue fatal error, it is quite serious situation */ return; } @@ -669,13 +669,13 @@ void il3945_hw_txq_free_tfd(struct il_priv *priv, struct il_tx_queue *txq) * il3945_hw_build_tx_cmd_rate - Add rate portion to TX_CMD: * */ -void il3945_hw_build_tx_cmd_rate(struct il_priv *priv, +void il3945_hw_build_tx_cmd_rate(struct il_priv *il, struct il_device_cmd *cmd, struct ieee80211_tx_info *info, struct ieee80211_hdr *hdr, int sta_id, int tx_id) { - u16 hw_value = ieee80211_get_tx_rate(priv->hw, info)->hw_value; + u16 hw_value = ieee80211_get_tx_rate(il->hw, info)->hw_value; u16 rate_index = min(hw_value & 0xffff, IL_RATE_COUNT_3945); u16 rate_mask; int rate; @@ -718,13 +718,13 @@ void il3945_hw_build_tx_cmd_rate(struct il_priv *priv, /* CCK */ tx_cmd->supp_rates[1] = (rate_mask & 0xF); - IL_DEBUG_RATE(priv, "Tx sta id: %d, rate: %d (plcp), flags: 0x%4X " + IL_DEBUG_RATE(il, "Tx sta id: %d, rate: %d (plcp), flags: 0x%4X " "cck/ofdm mask: 0x%x/0x%x\n", sta_id, tx_cmd->rate, le32_to_cpu(tx_cmd->tx_flags), tx_cmd->supp_rates[1], tx_cmd->supp_rates[0]); } -static u8 il3945_sync_sta(struct il_priv *priv, int sta_id, u16 tx_rate) +static u8 il3945_sync_sta(struct il_priv *il, int sta_id, u16 tx_rate) { unsigned long flags_spin; struct il_station_entry *station; @@ -732,52 +732,52 @@ static u8 il3945_sync_sta(struct il_priv *priv, int sta_id, u16 tx_rate) if (sta_id == IL_INVALID_STATION) return IL_INVALID_STATION; - spin_lock_irqsave(&priv->sta_lock, flags_spin); - station = &priv->stations[sta_id]; + spin_lock_irqsave(&il->sta_lock, flags_spin); + station = &il->stations[sta_id]; station->sta.sta.modify_mask = STA_MODIFY_TX_RATE_MSK; station->sta.rate_n_flags = cpu_to_le16(tx_rate); station->sta.mode = STA_CONTROL_MODIFY_MSK; - il_send_add_sta(priv, &station->sta, CMD_ASYNC); - spin_unlock_irqrestore(&priv->sta_lock, flags_spin); + il_send_add_sta(il, &station->sta, CMD_ASYNC); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); - IL_DEBUG_RATE(priv, "SCALE sync station %d to rate %d\n", + IL_DEBUG_RATE(il, "SCALE sync station %d to rate %d\n", sta_id, tx_rate); return sta_id; } -static void il3945_set_pwr_vmain(struct il_priv *priv) +static void il3945_set_pwr_vmain(struct il_priv *il) { /* * (for documentation purposes) * to set power to V_AUX, do - if (pci_pme_capable(priv->pci_dev, PCI_D3cold)) { - il_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, + if (pci_pme_capable(il->pci_dev, PCI_D3cold)) { + il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_PWR_SRC_VAUX, ~APMG_PS_CTRL_MSK_PWR_SRC); - il_poll_bit(priv, CSR_GPIO_IN, + il_poll_bit(il, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VAUX_PWR_SRC, CSR_GPIO_IN_BIT_AUX_POWER, 5000); } */ - il_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, + il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, ~APMG_PS_CTRL_MSK_PWR_SRC); - il_poll_bit(priv, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC, + il_poll_bit(il, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC, CSR_GPIO_IN_BIT_AUX_POWER, 5000); /* uS */ } -static int il3945_rx_init(struct il_priv *priv, struct il_rx_queue *rxq) +static int il3945_rx_init(struct il_priv *il, struct il_rx_queue *rxq) { - il_write_direct32(priv, FH39_RCSR_RBD_BASE(0), rxq->bd_dma); - il_write_direct32(priv, FH39_RCSR_RPTR_ADDR(0), + il_write_direct32(il, FH39_RCSR_RBD_BASE(0), rxq->bd_dma); + il_write_direct32(il, FH39_RCSR_RPTR_ADDR(0), rxq->rb_stts_dma); - il_write_direct32(priv, FH39_RCSR_WPTR(0), 0); - il_write_direct32(priv, FH39_RCSR_CONFIG(0), + il_write_direct32(il, FH39_RCSR_WPTR(0), 0); + il_write_direct32(il, FH39_RCSR_CONFIG(0), FH39_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE | FH39_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE | FH39_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN | @@ -788,32 +788,32 @@ static int il3945_rx_init(struct il_priv *priv, struct il_rx_queue *rxq) FH39_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH); /* fake read to flush all prev I/O */ - il_read_direct32(priv, FH39_RSSR_CTRL); + il_read_direct32(il, FH39_RSSR_CTRL); return 0; } -static int il3945_tx_reset(struct il_priv *priv) +static int il3945_tx_reset(struct il_priv *il) { /* bypass mode */ - il_write_prph(priv, ALM_SCD_MODE_REG, 0x2); + il_write_prph(il, ALM_SCD_MODE_REG, 0x2); /* RA 0 is active */ - il_write_prph(priv, ALM_SCD_ARASTAT_REG, 0x01); + il_write_prph(il, ALM_SCD_ARASTAT_REG, 0x01); /* all 6 fifo are active */ - il_write_prph(priv, ALM_SCD_TXFACT_REG, 0x3f); + il_write_prph(il, ALM_SCD_TXFACT_REG, 0x3f); - il_write_prph(priv, ALM_SCD_SBYP_MODE_1_REG, 0x010000); - il_write_prph(priv, ALM_SCD_SBYP_MODE_2_REG, 0x030002); - il_write_prph(priv, ALM_SCD_TXF4MF_REG, 0x000004); - il_write_prph(priv, ALM_SCD_TXF5MF_REG, 0x000005); + il_write_prph(il, ALM_SCD_SBYP_MODE_1_REG, 0x010000); + il_write_prph(il, ALM_SCD_SBYP_MODE_2_REG, 0x030002); + il_write_prph(il, ALM_SCD_TXF4MF_REG, 0x000004); + il_write_prph(il, ALM_SCD_TXF5MF_REG, 0x000005); - il_write_direct32(priv, FH39_TSSR_CBB_BASE, - priv->_3945.shared_phys); + il_write_direct32(il, FH39_TSSR_CBB_BASE, + il->_3945.shared_phys); - il_write_direct32(priv, FH39_TSSR_MSG_CONFIG, + il_write_direct32(il, FH39_TSSR_MSG_CONFIG, FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON | FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON | FH39_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B | @@ -831,31 +831,31 @@ static int il3945_tx_reset(struct il_priv *priv) * * Destroys all DMA structures and initialize them again */ -static int il3945_txq_ctx_reset(struct il_priv *priv) +static int il3945_txq_ctx_reset(struct il_priv *il) { int rc; int txq_id, slots_num; - il3945_hw_txq_ctx_free(priv); + il3945_hw_txq_ctx_free(il); /* allocate tx queue structure */ - rc = il_alloc_txq_mem(priv); + rc = il_alloc_txq_mem(il); if (rc) return rc; /* Tx CMD queue */ - rc = il3945_tx_reset(priv); + rc = il3945_tx_reset(il); if (rc) goto error; /* Tx queue(s) */ - for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { slots_num = (txq_id == IWL39_CMD_QUEUE_NUM) ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - rc = il_tx_queue_init(priv, &priv->txq[txq_id], + rc = il_tx_queue_init(il, &il->txq[txq_id], slots_num, txq_id); if (rc) { - IL_ERR(priv, "Tx %d queue init failed\n", txq_id); + IL_ERR(il, "Tx %d queue init failed\n", txq_id); goto error; } } @@ -863,7 +863,7 @@ static int il3945_txq_ctx_reset(struct il_priv *priv) return rc; error: - il3945_hw_txq_ctx_free(priv); + il3945_hw_txq_ctx_free(il); return rc; } @@ -873,127 +873,127 @@ static int il3945_txq_ctx_reset(struct il_priv *priv) * (e.g. after platform boot, or shutdown via il_apm_stop()) * NOTE: This does not load uCode nor start the embedded processor */ -static int il3945_apm_init(struct il_priv *priv) +static int il3945_apm_init(struct il_priv *il) { - int ret = il_apm_init(priv); + int ret = il_apm_init(il); /* Clear APMG (NIC's internal power management) interrupts */ - il_write_prph(priv, APMG_RTC_INT_MSK_REG, 0x0); - il_write_prph(priv, APMG_RTC_INT_STT_REG, 0xFFFFFFFF); + il_write_prph(il, APMG_RTC_INT_MSK_REG, 0x0); + il_write_prph(il, APMG_RTC_INT_STT_REG, 0xFFFFFFFF); /* Reset radio chip */ - il_set_bits_prph(priv, APMG_PS_CTRL_REG, + il_set_bits_prph(il, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_RESET_REQ); udelay(5); - il_clear_bits_prph(priv, APMG_PS_CTRL_REG, + il_clear_bits_prph(il, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_RESET_REQ); return ret; } -static void il3945_nic_config(struct il_priv *priv) +static void il3945_nic_config(struct il_priv *il) { - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; unsigned long flags; - u8 rev_id = priv->pci_dev->revision; + u8 rev_id = il->pci_dev->revision; - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); /* Determine HW type */ - IL_DEBUG_INFO(priv, "HW Revision ID = 0x%X\n", rev_id); + IL_DEBUG_INFO(il, "HW Revision ID = 0x%X\n", rev_id); if (rev_id & PCI_CFG_REV_ID_BIT_RTP) - IL_DEBUG_INFO(priv, "RTP type\n"); + IL_DEBUG_INFO(il, "RTP type\n"); else if (rev_id & PCI_CFG_REV_ID_BIT_BASIC_SKU) { - IL_DEBUG_INFO(priv, "3945 RADIO-MB type\n"); - il_set_bit(priv, CSR_HW_IF_CONFIG_REG, + IL_DEBUG_INFO(il, "3945 RADIO-MB type\n"); + il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_3945_MB); } else { - IL_DEBUG_INFO(priv, "3945 RADIO-MM type\n"); - il_set_bit(priv, CSR_HW_IF_CONFIG_REG, + IL_DEBUG_INFO(il, "3945 RADIO-MM type\n"); + il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_3945_MM); } if (EEPROM_SKU_CAP_OP_MODE_MRC == eeprom->sku_cap) { - IL_DEBUG_INFO(priv, "SKU OP mode is mrc\n"); - il_set_bit(priv, CSR_HW_IF_CONFIG_REG, + IL_DEBUG_INFO(il, "SKU OP mode is mrc\n"); + il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_SKU_MRC); } else - IL_DEBUG_INFO(priv, "SKU OP mode is basic\n"); + IL_DEBUG_INFO(il, "SKU OP mode is basic\n"); if ((eeprom->board_revision & 0xF0) == 0xD0) { - IL_DEBUG_INFO(priv, "3945ABG revision is 0x%X\n", + IL_DEBUG_INFO(il, "3945ABG revision is 0x%X\n", eeprom->board_revision); - il_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); } else { - IL_DEBUG_INFO(priv, "3945ABG revision is 0x%X\n", + IL_DEBUG_INFO(il, "3945ABG revision is 0x%X\n", eeprom->board_revision); - il_clear_bit(priv, CSR_HW_IF_CONFIG_REG, + il_clear_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); } if (eeprom->almgor_m_version <= 1) { - il_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A); - IL_DEBUG_INFO(priv, "Card M type A version is 0x%X\n", + IL_DEBUG_INFO(il, "Card M type A version is 0x%X\n", eeprom->almgor_m_version); } else { - IL_DEBUG_INFO(priv, "Card M type B version is 0x%X\n", + IL_DEBUG_INFO(il, "Card M type B version is 0x%X\n", eeprom->almgor_m_version); - il_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B); } - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); if (eeprom->sku_cap & EEPROM_SKU_CAP_SW_RF_KILL_ENABLE) - IL_DEBUG_RF_KILL(priv, "SW RF KILL supported in EEPROM.\n"); + IL_DEBUG_RF_KILL(il, "SW RF KILL supported in EEPROM.\n"); if (eeprom->sku_cap & EEPROM_SKU_CAP_HW_RF_KILL_ENABLE) - IL_DEBUG_RF_KILL(priv, "HW RF KILL supported in EEPROM.\n"); + IL_DEBUG_RF_KILL(il, "HW RF KILL supported in EEPROM.\n"); } -int il3945_hw_nic_init(struct il_priv *priv) +int il3945_hw_nic_init(struct il_priv *il) { int rc; unsigned long flags; - struct il_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &il->rxq; - spin_lock_irqsave(&priv->lock, flags); - priv->cfg->ops->lib->apm_ops.init(priv); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); + il->cfg->ops->lib->apm_ops.init(il); + spin_unlock_irqrestore(&il->lock, flags); - il3945_set_pwr_vmain(priv); + il3945_set_pwr_vmain(il); - priv->cfg->ops->lib->apm_ops.config(priv); + il->cfg->ops->lib->apm_ops.config(il); /* Allocate the RX queue, or reset if it is already allocated */ if (!rxq->bd) { - rc = il_rx_queue_alloc(priv); + rc = il_rx_queue_alloc(il); if (rc) { - IL_ERR(priv, "Unable to initialize Rx queue\n"); + IL_ERR(il, "Unable to initialize Rx queue\n"); return -ENOMEM; } } else - il3945_rx_queue_reset(priv, rxq); + il3945_rx_queue_reset(il, rxq); - il3945_rx_replenish(priv); + il3945_rx_replenish(il); - il3945_rx_init(priv, rxq); + il3945_rx_init(il, rxq); /* Look at using this instead: rxq->need_update = 1; - il_rx_queue_update_write_ptr(priv, rxq); + il_rx_queue_update_write_ptr(il, rxq); */ - il_write_direct32(priv, FH39_RCSR_WPTR(0), rxq->write & ~7); + il_write_direct32(il, FH39_RCSR_WPTR(0), rxq->write & ~7); - rc = il3945_txq_ctx_reset(priv); + rc = il3945_txq_ctx_reset(il); if (rc) return rc; - set_bit(STATUS_INIT, &priv->status); + set_bit(STATUS_INIT, &il->status); return 0; } @@ -1003,40 +1003,40 @@ int il3945_hw_nic_init(struct il_priv *priv) * * Destroy all TX DMA queues and structures */ -void il3945_hw_txq_ctx_free(struct il_priv *priv) +void il3945_hw_txq_ctx_free(struct il_priv *il) { int txq_id; /* Tx queues */ - if (priv->txq) - for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; + if (il->txq) + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) if (txq_id == IWL39_CMD_QUEUE_NUM) - il_cmd_queue_free(priv); + il_cmd_queue_free(il); else - il_tx_queue_free(priv, txq_id); + il_tx_queue_free(il, txq_id); /* free tx queue structure */ - il_txq_mem(priv); + il_txq_mem(il); } -void il3945_hw_txq_ctx_stop(struct il_priv *priv) +void il3945_hw_txq_ctx_stop(struct il_priv *il) { int txq_id; /* stop SCD */ - il_write_prph(priv, ALM_SCD_MODE_REG, 0); - il_write_prph(priv, ALM_SCD_TXFACT_REG, 0); + il_write_prph(il, ALM_SCD_MODE_REG, 0); + il_write_prph(il, ALM_SCD_TXFACT_REG, 0); /* reset TFD queues */ - for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { - il_write_direct32(priv, FH39_TCSR_CONFIG(txq_id), 0x0); - il_poll_direct_bit(priv, FH39_TSSR_TX_STATUS, + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { + il_write_direct32(il, FH39_TCSR_CONFIG(txq_id), 0x0); + il_poll_direct_bit(il, FH39_TSSR_TX_STATUS, FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(txq_id), 1000); } - il3945_hw_txq_ctx_free(priv); + il3945_hw_txq_ctx_free(il); } /** @@ -1056,36 +1056,36 @@ static inline int il3945_hw_reg_temp_out_of_range(int temperature) return ((temperature < -260) || (temperature > 25)) ? 1 : 0; } -int il3945_hw_get_temperature(struct il_priv *priv) +int il3945_hw_get_temperature(struct il_priv *il) { - return il_read32(priv, CSR_UCODE_DRV_GP2); + return il_read32(il, CSR_UCODE_DRV_GP2); } /** * il3945_hw_reg_txpower_get_temperature * get the current temperature by reading from NIC */ -static int il3945_hw_reg_txpower_get_temperature(struct il_priv *priv) +static int il3945_hw_reg_txpower_get_temperature(struct il_priv *il) { - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; int temperature; - temperature = il3945_hw_get_temperature(priv); + temperature = il3945_hw_get_temperature(il); /* driver's okay range is -260 to +25. * human readable okay range is 0 to +285 */ - IL_DEBUG_INFO(priv, "Temperature: %d\n", temperature + IL_TEMP_CONVERT); + IL_DEBUG_INFO(il, "Temperature: %d\n", temperature + IL_TEMP_CONVERT); /* handle insane temp reading */ if (il3945_hw_reg_temp_out_of_range(temperature)) { - IL_ERR(priv, "Error bad temperature value %d\n", temperature); + IL_ERR(il, "Error bad temperature value %d\n", temperature); /* if really really hot(?), * substitute the 3rd band/group's temp measured at factory */ - if (priv->last_temperature > 100) + if (il->last_temperature > 100) temperature = eeprom->groups[2].temperature; else /* else use most recent "sane" value from driver */ - temperature = priv->last_temperature; + temperature = il->last_temperature; } return temperature; /* raw, not "human readable" */ @@ -1102,33 +1102,33 @@ static int il3945_hw_reg_txpower_get_temperature(struct il_priv *priv) * records new temperature in tx_mgr->temperature. * replaces tx_mgr->last_temperature *only* if calib needed * (assumes caller will actually do the calibration!). */ -static int il3945_is_temp_calib_needed(struct il_priv *priv) +static int il3945_is_temp_calib_needed(struct il_priv *il) { int temp_diff; - priv->temperature = il3945_hw_reg_txpower_get_temperature(priv); - temp_diff = priv->temperature - priv->last_temperature; + il->temperature = il3945_hw_reg_txpower_get_temperature(il); + temp_diff = il->temperature - il->last_temperature; /* get absolute value */ if (temp_diff < 0) { - IL_DEBUG_POWER(priv, "Getting cooler, delta %d,\n", temp_diff); + IL_DEBUG_POWER(il, "Getting cooler, delta %d,\n", temp_diff); temp_diff = -temp_diff; } else if (temp_diff == 0) - IL_DEBUG_POWER(priv, "Same temp,\n"); + IL_DEBUG_POWER(il, "Same temp,\n"); else - IL_DEBUG_POWER(priv, "Getting warmer, delta %d,\n", temp_diff); + IL_DEBUG_POWER(il, "Getting warmer, delta %d,\n", temp_diff); /* if we don't need calibration, *don't* update last_temperature */ if (temp_diff < IL_TEMPERATURE_LIMIT_TIMER) { - IL_DEBUG_POWER(priv, "Timed thermal calib not needed\n"); + IL_DEBUG_POWER(il, "Timed thermal calib not needed\n"); return 0; } - IL_DEBUG_POWER(priv, "Timed thermal calib needed\n"); + IL_DEBUG_POWER(il, "Timed thermal calib needed\n"); /* assume that caller will actually do calib ... * update the "last temperature" value */ - priv->last_temperature = priv->temperature; + il->last_temperature = il->temperature; return 1; } @@ -1317,7 +1317,7 @@ static inline u8 il3945_hw_reg_fix_power_index(int index) * Set (in our channel info database) the direct scan Tx power for 1 Mbit (CCK) * or 6 Mbit (OFDM) rates. */ -static void il3945_hw_reg_set_scan_power(struct il_priv *priv, u32 scan_tbl_index, +static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_index, s32 rate_index, const s8 *clip_pwrs, struct il_channel_info *ch_info, int band_index) @@ -1333,7 +1333,7 @@ static void il3945_hw_reg_set_scan_power(struct il_priv *priv, u32 scan_tbl_inde * based on eeprom channel data) for this channel. */ power = min(ch_info->scan_power, clip_pwrs[IL_RATE_6M_INDEX_TABLE]); - power = min(power, priv->tx_power_user_lmt); + power = min(power, il->tx_power_user_lmt); scan_power_info->requested_power = power; /* find difference between new scan *power* and current "normal" @@ -1370,32 +1370,32 @@ static void il3945_hw_reg_set_scan_power(struct il_priv *priv, u32 scan_tbl_inde * Configures power settings for all rates for the current channel, * using values from channel info struct, and send to NIC */ -static int il3945_send_tx_power(struct il_priv *priv) +static int il3945_send_tx_power(struct il_priv *il) { int rate_idx, i; const struct il_channel_info *ch_info = NULL; struct il3945_txpowertable_cmd txpower = { - .channel = priv->contexts[IL_RXON_CTX_BSS].active.channel, + .channel = il->contexts[IL_RXON_CTX_BSS].active.channel, }; u16 chan; - if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &priv->status), + if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &il->status), "TX Power requested while scanning!\n")) return -EAGAIN; - chan = le16_to_cpu(priv->contexts[IL_RXON_CTX_BSS].active.channel); + chan = le16_to_cpu(il->contexts[IL_RXON_CTX_BSS].active.channel); - txpower.band = (priv->band == IEEE80211_BAND_5GHZ) ? 0 : 1; - ch_info = il_get_channel_info(priv, priv->band, chan); + txpower.band = (il->band == IEEE80211_BAND_5GHZ) ? 0 : 1; + ch_info = il_get_channel_info(il, il->band, chan); if (!ch_info) { - IL_ERR(priv, + IL_ERR(il, "Failed to get channel info for channel %d [%d]\n", - chan, priv->band); + chan, il->band); return -EINVAL; } if (!il_is_channel_valid(ch_info)) { - IL_DEBUG_POWER(priv, "Not calling TX_PWR_TABLE_CMD on " + IL_DEBUG_POWER(il, "Not calling TX_PWR_TABLE_CMD on " "non-Tx channel.\n"); return 0; } @@ -1408,7 +1408,7 @@ static int il3945_send_tx_power(struct il_priv *priv) txpower.power[i].tpc = ch_info->power_info[i].tpc; txpower.power[i].rate = il3945_rates[rate_idx].plcp; - IL_DEBUG_POWER(priv, "ch %d:%d rf %d dsp %3d rate code 0x%02x\n", + IL_DEBUG_POWER(il, "ch %d:%d rf %d dsp %3d rate code 0x%02x\n", le16_to_cpu(txpower.channel), txpower.band, txpower.power[i].tpc.tx_gain, @@ -1421,7 +1421,7 @@ static int il3945_send_tx_power(struct il_priv *priv) txpower.power[i].tpc = ch_info->power_info[i].tpc; txpower.power[i].rate = il3945_rates[rate_idx].plcp; - IL_DEBUG_POWER(priv, "ch %d:%d rf %d dsp %3d rate code 0x%02x\n", + IL_DEBUG_POWER(il, "ch %d:%d rf %d dsp %3d rate code 0x%02x\n", le16_to_cpu(txpower.channel), txpower.band, txpower.power[i].tpc.tx_gain, @@ -1429,7 +1429,7 @@ static int il3945_send_tx_power(struct il_priv *priv) txpower.power[i].rate); } - return il_send_cmd_pdu(priv, REPLY_TX_PWR_TABLE_CMD, + return il_send_cmd_pdu(il, REPLY_TX_PWR_TABLE_CMD, sizeof(struct il3945_txpowertable_cmd), &txpower); @@ -1451,7 +1451,7 @@ static int il3945_send_tx_power(struct il_priv *priv) * properly fill out the scan powers, and actual h/w gain settings, * and send changes to NIC */ -static int il3945_hw_reg_set_new_power(struct il_priv *priv, +static int il3945_hw_reg_set_new_power(struct il_priv *il, struct il_channel_info *ch_info) { struct il3945_channel_power_info *power_info; @@ -1461,7 +1461,7 @@ static int il3945_hw_reg_set_new_power(struct il_priv *priv, int power; /* Get this chnlgrp's rate-to-max/clip-powers table */ - clip_pwrs = priv->_3945.clip_groups[ch_info->group_index].clip_powers; + clip_pwrs = il->_3945.clip_groups[ch_info->group_index].clip_powers; /* Get this channel's rate-to-current-power settings table */ power_info = ch_info->power_info; @@ -1542,10 +1542,10 @@ static int il3945_hw_reg_get_ch_txpower_limit(struct il_channel_info *ch_info) * * If RxOn is "associated", this sends the new Txpower to NIC! */ -static int il3945_hw_reg_comp_txpower_temp(struct il_priv *priv) +static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) { struct il_channel_info *ch_info = NULL; - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; int delta_index; const s8 *clip_pwrs; /* array of h/w max power levels for each rate */ u8 a_band; @@ -1553,16 +1553,16 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *priv) u8 scan_tbl_index; u8 i; int ref_temp; - int temperature = priv->temperature; + int temperature = il->temperature; - if (priv->disable_tx_power_cal || - test_bit(STATUS_SCANNING, &priv->status)) { + if (il->disable_tx_power_cal || + test_bit(STATUS_SCANNING, &il->status)) { /* do not perform tx power calibration */ return 0; } /* set up new Tx power info for each and every channel, 2.4 and 5.x */ - for (i = 0; i < priv->channel_count; i++) { - ch_info = &priv->channel_info[i]; + for (i = 0; i < il->channel_count; i++) { + ch_info = &il->channel_info[i]; a_band = il_is_channel_a_band(ch_info); /* Get this chnlgrp's factory calibration temperature */ @@ -1592,43 +1592,43 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *priv) } /* Get this chnlgrp's rate-to-max/clip-powers table */ - clip_pwrs = priv->_3945.clip_groups[ch_info->group_index].clip_powers; + clip_pwrs = il->_3945.clip_groups[ch_info->group_index].clip_powers; /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */ for (scan_tbl_index = 0; scan_tbl_index < IL_NUM_SCAN_RATES; scan_tbl_index++) { s32 actual_index = (scan_tbl_index == 0) ? IL_RATE_1M_INDEX_TABLE : IL_RATE_6M_INDEX_TABLE; - il3945_hw_reg_set_scan_power(priv, scan_tbl_index, + il3945_hw_reg_set_scan_power(il, scan_tbl_index, actual_index, clip_pwrs, ch_info, a_band); } } /* send Txpower command for current channel to ucode */ - return priv->cfg->ops->lib->send_tx_power(priv); + return il->cfg->ops->lib->send_tx_power(il); } -int il3945_hw_reg_set_txpower(struct il_priv *priv, s8 power) +int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power) { struct il_channel_info *ch_info; s8 max_power; u8 a_band; u8 i; - if (priv->tx_power_user_lmt == power) { - IL_DEBUG_POWER(priv, "Requested Tx power same as current " + if (il->tx_power_user_lmt == power) { + IL_DEBUG_POWER(il, "Requested Tx power same as current " "limit: %ddBm.\n", power); return 0; } - IL_DEBUG_POWER(priv, "Setting upper limit clamp to %ddBm.\n", power); - priv->tx_power_user_lmt = power; + IL_DEBUG_POWER(il, "Setting upper limit clamp to %ddBm.\n", power); + il->tx_power_user_lmt = power; /* set up new Tx powers for each and every channel, 2.4 and 5.x */ - for (i = 0; i < priv->channel_count; i++) { - ch_info = &priv->channel_info[i]; + for (i = 0; i < il->channel_count; i++) { + ch_info = &il->channel_info[i]; a_band = il_is_channel_a_band(ch_info); /* find minimum power of all user and regulatory constraints @@ -1639,19 +1639,19 @@ int il3945_hw_reg_set_txpower(struct il_priv *priv, s8 power) ch_info->curr_txpow = max_power; /* this considers the h/w clipping limitations */ - il3945_hw_reg_set_new_power(priv, ch_info); + il3945_hw_reg_set_new_power(il, ch_info); } } /* update txpower settings for all channels, * send to NIC if associated. */ - il3945_is_temp_calib_needed(priv); - il3945_hw_reg_comp_txpower_temp(priv); + il3945_is_temp_calib_needed(il); + il3945_hw_reg_comp_txpower_temp(il); return 0; } -static int il3945_send_rxon_assoc(struct il_priv *priv, +static int il3945_send_rxon_assoc(struct il_priv *il, struct il_rxon_context *ctx) { int rc = 0; @@ -1670,7 +1670,7 @@ static int il3945_send_rxon_assoc(struct il_priv *priv, (rxon1->filter_flags == rxon2->filter_flags) && (rxon1->cck_basic_rates == rxon2->cck_basic_rates) && (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { - IL_DEBUG_INFO(priv, "Using current RXON_ASSOC. Not resending.\n"); + IL_DEBUG_INFO(il, "Using current RXON_ASSOC. Not resending.\n"); return 0; } @@ -1680,17 +1680,17 @@ static int il3945_send_rxon_assoc(struct il_priv *priv, rxon_assoc.cck_basic_rates = ctx->staging.cck_basic_rates; rxon_assoc.reserved = 0; - rc = il_send_cmd_sync(priv, &cmd); + rc = il_send_cmd_sync(il, &cmd); if (rc) return rc; pkt = (struct il_rx_packet *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR(priv, "Bad return from REPLY_RXON_ASSOC command\n"); + IL_ERR(il, "Bad return from REPLY_RXON_ASSOC command\n"); rc = -EIO; } - il_free_pages(priv, cmd.reply_page); + il_free_pages(il, cmd.reply_page); return rc; } @@ -1703,7 +1703,7 @@ static int il3945_send_rxon_assoc(struct il_priv *priv, * function correctly transitions out of the RXON_ASSOC_MSK state if * a HW tune is required based on the RXON structure changes. */ -int il3945_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) +int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) { /* cast away the const for active_rxon in this function */ struct il3945_rxon_cmd *active_rxon = (void *)&ctx->active; @@ -1711,10 +1711,10 @@ int il3945_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) int rc = 0; bool new_assoc = !!(staging_rxon->filter_flags & RXON_FILTER_ASSOC_MSK); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return -EINVAL; - if (!il_is_alive(priv)) + if (!il_is_alive(il)) return -1; /* always get timestamp with Rx frame */ @@ -1723,23 +1723,23 @@ int il3945_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) /* select antenna */ staging_rxon->flags &= ~(RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_SEL_MSK); - staging_rxon->flags |= il3945_get_antenna_flags(priv); + staging_rxon->flags |= il3945_get_antenna_flags(il); - rc = il_check_rxon_cmd(priv, ctx); + rc = il_check_rxon_cmd(il, ctx); if (rc) { - IL_ERR(priv, "Invalid RXON configuration. Not committing.\n"); + IL_ERR(il, "Invalid RXON configuration. Not committing.\n"); return -EINVAL; } /* If we don't need to send a full RXON, we can use * il3945_rxon_assoc_cmd which is used to reconfigure filter * and other flags for the current radio configuration. */ - if (!il_full_rxon_required(priv, - &priv->contexts[IL_RXON_CTX_BSS])) { - rc = il_send_rxon_assoc(priv, - &priv->contexts[IL_RXON_CTX_BSS]); + if (!il_full_rxon_required(il, + &il->contexts[IL_RXON_CTX_BSS])) { + rc = il_send_rxon_assoc(il, + &il->contexts[IL_RXON_CTX_BSS]); if (rc) { - IL_ERR(priv, "Error setting RXON_ASSOC " + IL_ERR(il, "Error setting RXON_ASSOC " "configuration (%d).\n", rc); return rc; } @@ -1749,7 +1749,7 @@ int il3945_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) * We do not commit tx power settings while channel changing, * do it now if tx power changed. */ - il_set_tx_power(priv, priv->tx_power_next, false); + il_set_tx_power(il, il->tx_power_next, false); return 0; } @@ -1757,8 +1757,8 @@ int il3945_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) * an RXON_ASSOC and the new config wants the associated mask enabled, * we must clear the associated from the active configuration * before we apply the new config */ - if (il_is_associated(priv, IL_RXON_CTX_BSS) && new_assoc) { - IL_DEBUG_INFO(priv, "Toggling associated bit on current RXON\n"); + if (il_is_associated(il, IL_RXON_CTX_BSS) && new_assoc) { + IL_DEBUG_INFO(il, "Toggling associated bit on current RXON\n"); active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; /* @@ -1767,25 +1767,25 @@ int il3945_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) */ active_rxon->reserved4 = 0; active_rxon->reserved5 = 0; - rc = il_send_cmd_pdu(priv, REPLY_RXON, + rc = il_send_cmd_pdu(il, REPLY_RXON, sizeof(struct il3945_rxon_cmd), - &priv->contexts[IL_RXON_CTX_BSS].active); + &il->contexts[IL_RXON_CTX_BSS].active); /* If the mask clearing failed then we set * active_rxon back to what it was previously */ if (rc) { active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK; - IL_ERR(priv, "Error clearing ASSOC_MSK on current " + IL_ERR(il, "Error clearing ASSOC_MSK on current " "configuration (%d).\n", rc); return rc; } - il_clear_ucode_stations(priv, - &priv->contexts[IL_RXON_CTX_BSS]); - il_restore_stations(priv, - &priv->contexts[IL_RXON_CTX_BSS]); + il_clear_ucode_stations(il, + &il->contexts[IL_RXON_CTX_BSS]); + il_restore_stations(il, + &il->contexts[IL_RXON_CTX_BSS]); } - IL_DEBUG_INFO(priv, "Sending RXON\n" + IL_DEBUG_INFO(il, "Sending RXON\n" "* with%s RXON_FILTER_ASSOC_MSK\n" "* channel = %d\n" "* bssid = %pM\n", @@ -1800,38 +1800,38 @@ int il3945_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) staging_rxon->reserved4 = 0; staging_rxon->reserved5 = 0; - il_set_rxon_hwcrypto(priv, ctx, !il3945_mod_params.sw_crypto); + il_set_rxon_hwcrypto(il, ctx, !il3945_mod_params.sw_crypto); /* Apply the new configuration */ - rc = il_send_cmd_pdu(priv, REPLY_RXON, + rc = il_send_cmd_pdu(il, REPLY_RXON, sizeof(struct il3945_rxon_cmd), staging_rxon); if (rc) { - IL_ERR(priv, "Error setting new configuration (%d).\n", rc); + IL_ERR(il, "Error setting new configuration (%d).\n", rc); return rc; } memcpy(active_rxon, staging_rxon, sizeof(*active_rxon)); if (!new_assoc) { - il_clear_ucode_stations(priv, - &priv->contexts[IL_RXON_CTX_BSS]); - il_restore_stations(priv, - &priv->contexts[IL_RXON_CTX_BSS]); + il_clear_ucode_stations(il, + &il->contexts[IL_RXON_CTX_BSS]); + il_restore_stations(il, + &il->contexts[IL_RXON_CTX_BSS]); } /* If we issue a new RXON command which required a tune then we must * send a new TXPOWER command or we won't be able to Tx any frames */ - rc = il_set_tx_power(priv, priv->tx_power_next, true); + rc = il_set_tx_power(il, il->tx_power_next, true); if (rc) { - IL_ERR(priv, "Error setting Tx power (%d).\n", rc); + IL_ERR(il, "Error setting Tx power (%d).\n", rc); return rc; } /* Init the hardware's rate fallback order based on the band */ - rc = il3945_init_hw_rate_table(priv); + rc = il3945_init_hw_rate_table(il); if (rc) { - IL_ERR(priv, "Error setting HW rate table: %02X\n", rc); + IL_ERR(il, "Error setting HW rate table: %02X\n", rc); return -EIO; } @@ -1848,34 +1848,34 @@ int il3945_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) * -- send new set of gain settings to NIC * NOTE: This should continue working, even when we're not associated, * so we can keep our internal table of scan powers current. */ -void il3945_reg_txpower_periodic(struct il_priv *priv) +void il3945_reg_txpower_periodic(struct il_priv *il) { /* This will kick in the "brute force" * il3945_hw_reg_comp_txpower_temp() below */ - if (!il3945_is_temp_calib_needed(priv)) + if (!il3945_is_temp_calib_needed(il)) goto reschedule; /* Set up a new set of temp-adjusted TxPowers, send to NIC. * This is based *only* on current temperature, * ignoring any previous power measurements */ - il3945_hw_reg_comp_txpower_temp(priv); + il3945_hw_reg_comp_txpower_temp(il); reschedule: - queue_delayed_work(priv->workqueue, - &priv->_3945.thermal_periodic, REG_RECALIB_PERIOD * HZ); + queue_delayed_work(il->workqueue, + &il->_3945.thermal_periodic, REG_RECALIB_PERIOD * HZ); } static void il3945_bg_reg_txpower_periodic(struct work_struct *work) { - struct il_priv *priv = container_of(work, struct il_priv, + struct il_priv *il = container_of(work, struct il_priv, _3945.thermal_periodic.work); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; - mutex_lock(&priv->mutex); - il3945_reg_txpower_periodic(priv); - mutex_unlock(&priv->mutex); + mutex_lock(&il->mutex); + il3945_reg_txpower_periodic(il); + mutex_unlock(&il->mutex); } /** @@ -1889,10 +1889,10 @@ static void il3945_bg_reg_txpower_periodic(struct work_struct *work) * on A-band, EEPROM's "group frequency" entries represent the top * channel in each group 1-4. Group 5 All B/G channels are in group 0. */ -static u16 il3945_hw_reg_get_ch_grp_index(struct il_priv *priv, +static u16 il3945_hw_reg_get_ch_grp_index(struct il_priv *il, const struct il_channel_info *ch_info) { - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; struct il3945_eeprom_txpower_group *ch_grp = &eeprom->groups[0]; u8 group; u16 group_index = 0; /* based on factory calib frequencies */ @@ -1913,7 +1913,7 @@ static u16 il3945_hw_reg_get_ch_grp_index(struct il_priv *priv, } else group_index = 0; /* 2.4 GHz, group 0 */ - IL_DEBUG_POWER(priv, "Chnl %d mapped to grp %d\n", ch_info->channel, + IL_DEBUG_POWER(il, "Chnl %d mapped to grp %d\n", ch_info->channel, group_index); return group_index; } @@ -1924,12 +1924,12 @@ static u16 il3945_hw_reg_get_ch_grp_index(struct il_priv *priv, * Interpolate to get nominal (i.e. at factory calibration temperature) index * into radio/DSP gain settings table for requested power. */ -static int il3945_hw_reg_get_matched_power_index(struct il_priv *priv, +static int il3945_hw_reg_get_matched_power_index(struct il_priv *il, s8 requested_power, s32 setting_index, s32 *new_index) { const struct il3945_eeprom_txpower_group *chnl_grp = NULL; - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; s32 index0, index1; s32 power = 2 * requested_power; s32 i; @@ -1973,14 +1973,14 @@ static int il3945_hw_reg_get_matched_power_index(struct il_priv *priv, return 0; } -static void il3945_hw_reg_init_channel_groups(struct il_priv *priv) +static void il3945_hw_reg_init_channel_groups(struct il_priv *il) { u32 i; s32 rate_index; - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; const struct il3945_eeprom_txpower_group *group; - IL_DEBUG_POWER(priv, "Initializing factory calib info from EEPROM\n"); + IL_DEBUG_POWER(il, "Initializing factory calib info from EEPROM\n"); for (i = 0; i < IL_NUM_TX_CALIB_GROUPS; i++) { s8 *clip_pwrs; /* table of power levels for each rate */ @@ -1989,7 +1989,7 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *priv) /* sanity check on factory saturation power value */ if (group->saturation_power < 40) { - IL_WARN(priv, "Error: saturation power is %d, " + IL_WARN(il, "Error: saturation power is %d, " "less than minimum expected 40\n", group->saturation_power); return; @@ -2004,7 +2004,7 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *priv) * power peaks, without too much distortion (clipping). */ /* we'll fill in this array with h/w max power levels */ - clip_pwrs = (s8 *) priv->_3945.clip_groups[i].clip_powers; + clip_pwrs = (s8 *) il->_3945.clip_groups[i].clip_powers; /* divide factory saturation power by 2 to find -3dB level */ satur_pwr = (s8) (group->saturation_power >> 1); @@ -2042,7 +2042,7 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *priv) /** * il3945_txpower_set_from_eeprom - Set channel power info based on EEPROM * - * Second pass (during init) to set up priv->channel_info + * Second pass (during init) to set up il->channel_info * * Set up Tx-power settings in our channel info database for each VALID * (for this geo/SKU) channel, at all Tx data rates, based on eeprom values @@ -2054,11 +2054,11 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *priv) * * This does *not* write values to NIC, just sets up our internal table. */ -int il3945_txpower_set_from_eeprom(struct il_priv *priv) +int il3945_txpower_set_from_eeprom(struct il_priv *il) { struct il_channel_info *ch_info = NULL; struct il3945_channel_power_info *pwr_info; - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; int delta_index; u8 rate_index; u8 scan_tbl_index; @@ -2071,13 +2071,13 @@ int il3945_txpower_set_from_eeprom(struct il_priv *priv) /* save temperature reference, * so we can determine next time to calibrate */ - temperature = il3945_hw_reg_txpower_get_temperature(priv); - priv->last_temperature = temperature; + temperature = il3945_hw_reg_txpower_get_temperature(il); + il->last_temperature = temperature; - il3945_hw_reg_init_channel_groups(priv); + il3945_hw_reg_init_channel_groups(il); /* initialize Tx power info for each and every channel, 2.4 and 5.x */ - for (i = 0, ch_info = priv->channel_info; i < priv->channel_count; + for (i = 0, ch_info = il->channel_info; i < il->channel_count; i++, ch_info++) { a_band = il_is_channel_a_band(ch_info); if (!il_is_channel_valid(ch_info)) @@ -2085,10 +2085,10 @@ int il3945_txpower_set_from_eeprom(struct il_priv *priv) /* find this channel's channel group (*not* "band") index */ ch_info->group_index = - il3945_hw_reg_get_ch_grp_index(priv, ch_info); + il3945_hw_reg_get_ch_grp_index(il, ch_info); /* Get this chnlgrp's rate->max/clip-powers table */ - clip_pwrs = priv->_3945.clip_groups[ch_info->group_index].clip_powers; + clip_pwrs = il->_3945.clip_groups[ch_info->group_index].clip_powers; /* calculate power index *adjustment* value according to * diff between current temperature and factory temperature */ @@ -2096,7 +2096,7 @@ int il3945_txpower_set_from_eeprom(struct il_priv *priv) eeprom->groups[ch_info->group_index]. temperature); - IL_DEBUG_POWER(priv, "Delta index for channel %d: %d [%d]\n", + IL_DEBUG_POWER(il, "Delta index for channel %d: %d [%d]\n", ch_info->channel, delta_index, temperature + IL_TEMP_CONVERT); @@ -2115,11 +2115,11 @@ int il3945_txpower_set_from_eeprom(struct il_priv *priv) /* get base (i.e. at factory-measured temperature) * power table index for this rate's power */ - rc = il3945_hw_reg_get_matched_power_index(priv, pwr, + rc = il3945_hw_reg_get_matched_power_index(il, pwr, ch_info->group_index, &power_idx); if (rc) { - IL_ERR(priv, "Invalid power index\n"); + IL_ERR(il, "Invalid power index\n"); return rc; } pwr_info->base_power_index = (u8) power_idx; @@ -2171,7 +2171,7 @@ int il3945_txpower_set_from_eeprom(struct il_priv *priv) scan_tbl_index < IL_NUM_SCAN_RATES; scan_tbl_index++) { s32 actual_index = (scan_tbl_index == 0) ? IL_RATE_1M_INDEX_TABLE : IL_RATE_6M_INDEX_TABLE; - il3945_hw_reg_set_scan_power(priv, scan_tbl_index, + il3945_hw_reg_set_scan_power(il, scan_tbl_index, actual_index, clip_pwrs, ch_info, a_band); } } @@ -2179,31 +2179,31 @@ int il3945_txpower_set_from_eeprom(struct il_priv *priv) return 0; } -int il3945_hw_rxq_stop(struct il_priv *priv) +int il3945_hw_rxq_stop(struct il_priv *il) { int rc; - il_write_direct32(priv, FH39_RCSR_CONFIG(0), 0); - rc = il_poll_direct_bit(priv, FH39_RSSR_STATUS, + il_write_direct32(il, FH39_RCSR_CONFIG(0), 0); + rc = il_poll_direct_bit(il, FH39_RSSR_STATUS, FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); if (rc < 0) - IL_ERR(priv, "Can't stop Rx DMA.\n"); + IL_ERR(il, "Can't stop Rx DMA.\n"); return 0; } -int il3945_hw_tx_queue_init(struct il_priv *priv, struct il_tx_queue *txq) +int il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq) { int txq_id = txq->q.id; - struct il3945_shared *shared_data = priv->_3945.shared_virt; + struct il3945_shared *shared_data = il->_3945.shared_virt; shared_data->tx_base_ptr[txq_id] = cpu_to_le32((u32)txq->q.dma_addr); - il_write_direct32(priv, FH39_CBCC_CTRL(txq_id), 0); - il_write_direct32(priv, FH39_CBCC_BASE(txq_id), 0); + il_write_direct32(il, FH39_CBCC_CTRL(txq_id), 0); + il_write_direct32(il, FH39_CBCC_BASE(txq_id), 0); - il_write_direct32(priv, FH39_TCSR_CONFIG(txq_id), + il_write_direct32(il, FH39_TCSR_CONFIG(txq_id), FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT | FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF | FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD | @@ -2211,7 +2211,7 @@ int il3945_hw_tx_queue_init(struct il_priv *priv, struct il_tx_queue *txq) FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE); /* fake read to flush all prev. writes */ - il_read32(priv, FH39_TSSR_CBB_BASE); + il_read32(il, FH39_TSSR_CBB_BASE); return 0; } @@ -2250,10 +2250,10 @@ static u16 il3945_build_addsta_hcmd(const struct il_addsta_cmd *cmd, return (u16)sizeof(struct il3945_addsta_cmd); } -static int il3945_add_bssid_station(struct il_priv *priv, +static int il3945_add_bssid_station(struct il_priv *il, const u8 *addr, u8 *sta_id_r) { - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; int ret; u8 sta_id; unsigned long flags; @@ -2261,49 +2261,49 @@ static int il3945_add_bssid_station(struct il_priv *priv, if (sta_id_r) *sta_id_r = IL_INVALID_STATION; - ret = il_add_station_common(priv, ctx, addr, 0, NULL, &sta_id); + ret = il_add_station_common(il, ctx, addr, 0, NULL, &sta_id); if (ret) { - IL_ERR(priv, "Unable to add station %pM\n", addr); + IL_ERR(il, "Unable to add station %pM\n", addr); return ret; } if (sta_id_r) *sta_id_r = sta_id; - spin_lock_irqsave(&priv->sta_lock, flags); - priv->stations[sta_id].used |= IL_STA_LOCAL; - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].used |= IL_STA_LOCAL; + spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } -static int il3945_manage_ibss_station(struct il_priv *priv, +static int il3945_manage_ibss_station(struct il_priv *il, struct ieee80211_vif *vif, bool add) { struct il_vif_priv *vif_priv = (void *)vif->drv_priv; int ret; if (add) { - ret = il3945_add_bssid_station(priv, vif->bss_conf.bssid, + ret = il3945_add_bssid_station(il, vif->bss_conf.bssid, &vif_priv->ibss_bssid_sta_id); if (ret) return ret; - il3945_sync_sta(priv, vif_priv->ibss_bssid_sta_id, - (priv->band == IEEE80211_BAND_5GHZ) ? + il3945_sync_sta(il, vif_priv->ibss_bssid_sta_id, + (il->band == IEEE80211_BAND_5GHZ) ? IL_RATE_6M_PLCP : IL_RATE_1M_PLCP); - il3945_rate_scale_init(priv->hw, vif_priv->ibss_bssid_sta_id); + il3945_rate_scale_init(il->hw, vif_priv->ibss_bssid_sta_id); return 0; } - return il_remove_station(priv, vif_priv->ibss_bssid_sta_id, + return il_remove_station(il, vif_priv->ibss_bssid_sta_id, vif->bss_conf.bssid); } /** * il3945_init_hw_rate_table - Initialize the hardware rate fallback table */ -int il3945_init_hw_rate_table(struct il_priv *priv) +int il3945_init_hw_rate_table(struct il_priv *il) { int rc, i, index, prev_index; struct il3945_rate_scaling_cmd rate_cmd = { @@ -2316,15 +2316,15 @@ int il3945_init_hw_rate_table(struct il_priv *priv) table[index].rate_n_flags = il3945_hw_set_rate_n_flags(il3945_rates[i].plcp, 0); - table[index].try_cnt = priv->retry_rate; + table[index].try_cnt = il->retry_rate; prev_index = il3945_get_prev_ieee_rate(i); table[index].next_rate_index = il3945_rates[prev_index].table_rs_index; } - switch (priv->band) { + switch (il->band) { case IEEE80211_BAND_5GHZ: - IL_DEBUG_RATE(priv, "Select A mode rate scale\n"); + IL_DEBUG_RATE(il, "Select A mode rate scale\n"); /* If one of the following CCK rates is used, * have it fall back to the 6M OFDM rate */ for (i = IL_RATE_1M_INDEX_TABLE; @@ -2342,12 +2342,12 @@ int il3945_init_hw_rate_table(struct il_priv *priv) break; case IEEE80211_BAND_2GHZ: - IL_DEBUG_RATE(priv, "Select B/G mode rate scale\n"); + IL_DEBUG_RATE(il, "Select B/G mode rate scale\n"); /* If an OFDM rate is used, have it fall back to the * 1M CCK rates */ - if (!(priv->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && - il_is_associated(priv, IL_RXON_CTX_BSS)) { + if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && + il_is_associated(il, IL_RXON_CTX_BSS)) { index = IL_FIRST_CCK_RATE; for (i = IL_RATE_6M_INDEX_TABLE; @@ -2368,52 +2368,52 @@ int il3945_init_hw_rate_table(struct il_priv *priv) /* Update the rate scaling for control frame Tx */ rate_cmd.table_id = 0; - rc = il_send_cmd_pdu(priv, REPLY_RATE_SCALE, sizeof(rate_cmd), + rc = il_send_cmd_pdu(il, REPLY_RATE_SCALE, sizeof(rate_cmd), &rate_cmd); if (rc) return rc; /* Update the rate scaling for data frame Tx */ rate_cmd.table_id = 1; - return il_send_cmd_pdu(priv, REPLY_RATE_SCALE, sizeof(rate_cmd), + return il_send_cmd_pdu(il, REPLY_RATE_SCALE, sizeof(rate_cmd), &rate_cmd); } /* Called when initializing driver */ -int il3945_hw_set_hw_params(struct il_priv *priv) +int il3945_hw_set_hw_params(struct il_priv *il) { - memset((void *)&priv->hw_params, 0, + memset((void *)&il->hw_params, 0, sizeof(struct il_hw_params)); - priv->_3945.shared_virt = - dma_alloc_coherent(&priv->pci_dev->dev, + il->_3945.shared_virt = + dma_alloc_coherent(&il->pci_dev->dev, sizeof(struct il3945_shared), - &priv->_3945.shared_phys, GFP_KERNEL); - if (!priv->_3945.shared_virt) { - IL_ERR(priv, "failed to allocate pci memory\n"); + &il->_3945.shared_phys, GFP_KERNEL); + if (!il->_3945.shared_virt) { + IL_ERR(il, "failed to allocate pci memory\n"); return -ENOMEM; } /* Assign number of Usable TX queues */ - priv->hw_params.max_txq_num = priv->cfg->base_params->num_of_queues; + il->hw_params.max_txq_num = il->cfg->base_params->num_of_queues; - priv->hw_params.tfd_size = sizeof(struct il3945_tfd); - priv->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_3K); - priv->hw_params.max_rxq_size = RX_QUEUE_SIZE; - priv->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; - priv->hw_params.max_stations = IWL3945_STATION_COUNT; - priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IWL3945_BROADCAST_ID; + il->hw_params.tfd_size = sizeof(struct il3945_tfd); + il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_3K); + il->hw_params.max_rxq_size = RX_QUEUE_SIZE; + il->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; + il->hw_params.max_stations = IWL3945_STATION_COUNT; + il->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IWL3945_BROADCAST_ID; - priv->sta_key_max_num = STA_KEY_MAX_NUM; + il->sta_key_max_num = STA_KEY_MAX_NUM; - priv->hw_params.rx_wrt_ptr_reg = FH39_RSCSR_CHNL0_WPTR; - priv->hw_params.max_beacon_itrvl = IWL39_MAX_UCODE_BEACON_INTERVAL; - priv->hw_params.beacon_time_tsf_bits = IWL3945_EXT_BEACON_TIME_POS; + il->hw_params.rx_wrt_ptr_reg = FH39_RSCSR_CHNL0_WPTR; + il->hw_params.max_beacon_itrvl = IWL39_MAX_UCODE_BEACON_INTERVAL; + il->hw_params.beacon_time_tsf_bits = IWL3945_EXT_BEACON_TIME_POS; return 0; } -unsigned int il3945_hw_get_beacon_cmd(struct il_priv *priv, +unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, struct il3945_frame *frame, u8 rate) { struct il3945_tx_beacon_cmd *tx_beacon_cmd; @@ -2423,10 +2423,10 @@ unsigned int il3945_hw_get_beacon_cmd(struct il_priv *priv, memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); tx_beacon_cmd->tx.sta_id = - priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id; + il->contexts[IL_RXON_CTX_BSS].bcast_sta_id; tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; - frame_size = il3945_fill_beacon_frame(priv, + frame_size = il3945_fill_beacon_frame(il, tx_beacon_cmd->frame, sizeof(frame->u) - sizeof(*tx_beacon_cmd)); @@ -2447,41 +2447,41 @@ unsigned int il3945_hw_get_beacon_cmd(struct il_priv *priv, return sizeof(struct il3945_tx_beacon_cmd) + frame_size; } -void il3945_hw_rx_handler_setup(struct il_priv *priv) +void il3945_hw_rx_handler_setup(struct il_priv *il) { - priv->rx_handlers[REPLY_TX] = il3945_rx_reply_tx; - priv->rx_handlers[REPLY_3945_RX] = il3945_rx_reply_rx; + il->rx_handlers[REPLY_TX] = il3945_rx_reply_tx; + il->rx_handlers[REPLY_3945_RX] = il3945_rx_reply_rx; } -void il3945_hw_setup_deferred_work(struct il_priv *priv) +void il3945_hw_setup_deferred_work(struct il_priv *il) { - INIT_DELAYED_WORK(&priv->_3945.thermal_periodic, + INIT_DELAYED_WORK(&il->_3945.thermal_periodic, il3945_bg_reg_txpower_periodic); } -void il3945_hw_cancel_deferred_work(struct il_priv *priv) +void il3945_hw_cancel_deferred_work(struct il_priv *il) { - cancel_delayed_work(&priv->_3945.thermal_periodic); + cancel_delayed_work(&il->_3945.thermal_periodic); } /* check contents of special bootstrap uCode SRAM */ -static int il3945_verify_bsm(struct il_priv *priv) +static int il3945_verify_bsm(struct il_priv *il) { - __le32 *image = priv->ucode_boot.v_addr; - u32 len = priv->ucode_boot.len; + __le32 *image = il->ucode_boot.v_addr; + u32 len = il->ucode_boot.len; u32 reg; u32 val; - IL_DEBUG_INFO(priv, "Begin verify bsm\n"); + IL_DEBUG_INFO(il, "Begin verify bsm\n"); /* verify BSM SRAM contents */ - val = il_read_prph(priv, BSM_WR_DWCOUNT_REG); + val = il_read_prph(il, BSM_WR_DWCOUNT_REG); for (reg = BSM_SRAM_LOWER_BOUND; reg < BSM_SRAM_LOWER_BOUND + len; reg += sizeof(u32), image++) { - val = il_read_prph(priv, reg); + val = il_read_prph(il, reg); if (val != le32_to_cpu(*image)) { - IL_ERR(priv, "BSM uCode verification failed at " + IL_ERR(il, "BSM uCode verification failed at " "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", BSM_SRAM_LOWER_BOUND, reg - BSM_SRAM_LOWER_BOUND, len, @@ -2490,7 +2490,7 @@ static int il3945_verify_bsm(struct il_priv *priv) } } - IL_DEBUG_INFO(priv, "BSM bootstrap uCode image OK\n"); + IL_DEBUG_INFO(il, "BSM bootstrap uCode image OK\n"); return 0; } @@ -2510,14 +2510,14 @@ static int il3945_verify_bsm(struct il_priv *priv) * simply claims ownership, which should be safe when this function is called * (i.e. before loading uCode!). */ -static int il3945_eeprom_acquire_semaphore(struct il_priv *priv) +static int il3945_eeprom_acquire_semaphore(struct il_priv *il) { - _il_clear_bit(priv, CSR_EEPROM_GP, CSR_EEPROM_GP_IF_OWNER_MSK); + _il_clear_bit(il, CSR_EEPROM_GP, CSR_EEPROM_GP_IF_OWNER_MSK); return 0; } -static void il3945_eeprom_release_semaphore(struct il_priv *priv) +static void il3945_eeprom_release_semaphore(struct il_priv *il) { return; } @@ -2554,10 +2554,10 @@ static void il3945_eeprom_release_semaphore(struct il_priv *priv) * the runtime uCode instructions and the backup data cache into SRAM, * and re-launches the runtime uCode from where it left off. */ -static int il3945_load_bsm(struct il_priv *priv) +static int il3945_load_bsm(struct il_priv *il) { - __le32 *image = priv->ucode_boot.v_addr; - u32 len = priv->ucode_boot.len; + __le32 *image = il->ucode_boot.v_addr; + u32 len = il->ucode_boot.len; dma_addr_t pinst; dma_addr_t pdata; u32 inst_len; @@ -2567,7 +2567,7 @@ static int il3945_load_bsm(struct il_priv *priv) u32 done; u32 reg_offset; - IL_DEBUG_INFO(priv, "Begin load bsm\n"); + IL_DEBUG_INFO(il, "Begin load bsm\n"); /* make sure bootstrap program is no larger than BSM's SRAM size */ if (len > IWL39_MAX_BSM_SIZE) @@ -2578,55 +2578,55 @@ static int il3945_load_bsm(struct il_priv *priv) * NOTE: il3945_initialize_alive_start() will replace these values, * after the "initialize" uCode has run, to point to * runtime/protocol instructions and backup data cache. */ - pinst = priv->ucode_init.p_addr; - pdata = priv->ucode_init_data.p_addr; - inst_len = priv->ucode_init.len; - data_len = priv->ucode_init_data.len; + pinst = il->ucode_init.p_addr; + pdata = il->ucode_init_data.p_addr; + inst_len = il->ucode_init.len; + data_len = il->ucode_init_data.len; - il_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); - il_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); - il_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); - il_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); + il_write_prph(il, BSM_DRAM_INST_PTR_REG, pinst); + il_write_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); + il_write_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); + il_write_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); /* Fill BSM memory with bootstrap instructions */ for (reg_offset = BSM_SRAM_LOWER_BOUND; reg_offset < BSM_SRAM_LOWER_BOUND + len; reg_offset += sizeof(u32), image++) - _il_write_prph(priv, reg_offset, + _il_write_prph(il, reg_offset, le32_to_cpu(*image)); - rc = il3945_verify_bsm(priv); + rc = il3945_verify_bsm(il); if (rc) return rc; /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ - il_write_prph(priv, BSM_WR_MEM_SRC_REG, 0x0); - il_write_prph(priv, BSM_WR_MEM_DST_REG, + il_write_prph(il, BSM_WR_MEM_SRC_REG, 0x0); + il_write_prph(il, BSM_WR_MEM_DST_REG, IWL39_RTC_INST_LOWER_BOUND); - il_write_prph(priv, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); + il_write_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); /* Load bootstrap code into instruction SRAM now, * to prepare to load "initialize" uCode */ - il_write_prph(priv, BSM_WR_CTRL_REG, + il_write_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START); /* Wait for load of bootstrap uCode to finish */ for (i = 0; i < 100; i++) { - done = il_read_prph(priv, BSM_WR_CTRL_REG); + done = il_read_prph(il, BSM_WR_CTRL_REG); if (!(done & BSM_WR_CTRL_REG_BIT_START)) break; udelay(10); } if (i < 100) - IL_DEBUG_INFO(priv, "BSM write complete, poll %d iterations\n", i); + IL_DEBUG_INFO(il, "BSM write complete, poll %d iterations\n", i); else { - IL_ERR(priv, "BSM write did not complete!\n"); + IL_ERR(il, "BSM write did not complete!\n"); return -EIO; } /* Enable future boot loads whenever power management unit triggers it * (e.g. when powering back up after power-save shutdown) */ - il_write_prph(priv, BSM_WR_CTRL_REG, + il_write_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN); return 0; diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.h b/drivers/net/wireless/iwlegacy/iwl-3945.h index 167eedcfeb63..abe778b1b424 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945.h @@ -85,7 +85,7 @@ struct il3945_rate_scale_data { struct il3945_rs_sta { spinlock_t lock; - struct il_priv *priv; + struct il_priv *il; s32 *expected_tpt; unsigned long last_partial_flush; unsigned long last_flush; @@ -207,12 +207,12 @@ struct il3945_ibss_seq { *****************************************************************************/ extern int il3945_calc_db_from_ratio(int sig_ratio); extern void il3945_rx_replenish(void *data); -extern void il3945_rx_queue_reset(struct il_priv *priv, struct il_rx_queue *rxq); -extern unsigned int il3945_fill_beacon_frame(struct il_priv *priv, +extern void il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq); +extern unsigned int il3945_fill_beacon_frame(struct il_priv *il, struct ieee80211_hdr *hdr, int left); -extern int il3945_dump_nic_event_log(struct il_priv *priv, bool full_log, +extern int il3945_dump_nic_event_log(struct il_priv *il, bool full_log, char **buf, bool display); -extern void il3945_dump_nic_error_log(struct il_priv *priv); +extern void il3945_dump_nic_error_log(struct il_priv *il); /****************************************************************************** * @@ -230,44 +230,44 @@ extern void il3945_dump_nic_error_log(struct il_priv *priv); * il3945_mac_ <-- mac80211 callback * ****************************************************************************/ -extern void il3945_hw_rx_handler_setup(struct il_priv *priv); -extern void il3945_hw_setup_deferred_work(struct il_priv *priv); -extern void il3945_hw_cancel_deferred_work(struct il_priv *priv); -extern int il3945_hw_rxq_stop(struct il_priv *priv); -extern int il3945_hw_set_hw_params(struct il_priv *priv); -extern int il3945_hw_nic_init(struct il_priv *priv); -extern int il3945_hw_nic_stop_master(struct il_priv *priv); -extern void il3945_hw_txq_ctx_free(struct il_priv *priv); -extern void il3945_hw_txq_ctx_stop(struct il_priv *priv); -extern int il3945_hw_nic_reset(struct il_priv *priv); -extern int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *priv, +extern void il3945_hw_rx_handler_setup(struct il_priv *il); +extern void il3945_hw_setup_deferred_work(struct il_priv *il); +extern void il3945_hw_cancel_deferred_work(struct il_priv *il); +extern int il3945_hw_rxq_stop(struct il_priv *il); +extern int il3945_hw_set_hw_params(struct il_priv *il); +extern int il3945_hw_nic_init(struct il_priv *il); +extern int il3945_hw_nic_stop_master(struct il_priv *il); +extern void il3945_hw_txq_ctx_free(struct il_priv *il); +extern void il3945_hw_txq_ctx_stop(struct il_priv *il); +extern int il3945_hw_nic_reset(struct il_priv *il); +extern int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, struct il_tx_queue *txq, dma_addr_t addr, u16 len, u8 reset, u8 pad); -extern void il3945_hw_txq_free_tfd(struct il_priv *priv, +extern void il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq); -extern int il3945_hw_get_temperature(struct il_priv *priv); -extern int il3945_hw_tx_queue_init(struct il_priv *priv, +extern int il3945_hw_get_temperature(struct il_priv *il); +extern int il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq); -extern unsigned int il3945_hw_get_beacon_cmd(struct il_priv *priv, +extern unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, struct il3945_frame *frame, u8 rate); -void il3945_hw_build_tx_cmd_rate(struct il_priv *priv, +void il3945_hw_build_tx_cmd_rate(struct il_priv *il, struct il_device_cmd *cmd, struct ieee80211_tx_info *info, struct ieee80211_hdr *hdr, int sta_id, int tx_id); -extern int il3945_hw_reg_send_txpower(struct il_priv *priv); -extern int il3945_hw_reg_set_txpower(struct il_priv *priv, s8 power); -extern void il3945_hw_rx_statistics(struct il_priv *priv, +extern int il3945_hw_reg_send_txpower(struct il_priv *il); +extern int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power); +extern void il3945_hw_rx_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb); -void il3945_reply_statistics(struct il_priv *priv, +void il3945_reply_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb); -extern void il3945_disable_events(struct il_priv *priv); -extern int il4965_get_temperature(const struct il_priv *priv); -extern void il3945_post_associate(struct il_priv *priv); -extern void il3945_config_ap(struct il_priv *priv); +extern void il3945_disable_events(struct il_priv *il); +extern int il4965_get_temperature(const struct il_priv *il); +extern void il3945_post_associate(struct il_priv *il); +extern void il3945_config_ap(struct il_priv *il); -extern int il3945_commit_rxon(struct il_priv *priv, +extern int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx); /** @@ -278,26 +278,26 @@ extern int il3945_commit_rxon(struct il_priv *priv, * not yet been merged into a single common layer for managing the * station tables. */ -extern u8 il3945_hw_find_station(struct il_priv *priv, const u8 *bssid); +extern u8 il3945_hw_find_station(struct il_priv *il, const u8 *bssid); extern struct ieee80211_ops il3945_hw_ops; /* * Forward declare iwl-3945.c functions for iwl3945-base.c */ -extern __le32 il3945_get_antenna_flags(const struct il_priv *priv); -extern int il3945_init_hw_rate_table(struct il_priv *priv); -extern void il3945_reg_txpower_periodic(struct il_priv *priv); -extern int il3945_txpower_set_from_eeprom(struct il_priv *priv); +extern __le32 il3945_get_antenna_flags(const struct il_priv *il); +extern int il3945_init_hw_rate_table(struct il_priv *il); +extern void il3945_reg_txpower_periodic(struct il_priv *il); +extern int il3945_txpower_set_from_eeprom(struct il_priv *il); extern const struct il_channel_info *il3945_get_channel_info( - const struct il_priv *priv, enum ieee80211_band band, u16 channel); + const struct il_priv *il, enum ieee80211_band band, u16 channel); -extern int il3945_rs_next_rate(struct il_priv *priv, int rate); +extern int il3945_rs_next_rate(struct il_priv *il, int rate); /* scanning */ -int il3945_request_scan(struct il_priv *priv, struct ieee80211_vif *vif); -void il3945_post_scan(struct il_priv *priv); +int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif); +void il3945_post_scan(struct il_priv *il); /* rates */ extern const struct il3945_rate_info il3945_rates[IL_RATE_COUNT_3945]; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c index 115eeb3d7c39..7807dc59e9c5 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c @@ -80,14 +80,14 @@ struct statistics_general_data { u32 beacon_energy_c; }; -void il4965_calib_free_results(struct il_priv *priv) +void il4965_calib_free_results(struct il_priv *il) { int i; for (i = 0; i < IL_CALIB_MAX; i++) { - kfree(priv->calib_results[i].buf); - priv->calib_results[i].buf = NULL; - priv->calib_results[i].buf_len = 0; + kfree(il->calib_results[i].buf); + il->calib_results[i].buf = NULL; + il->calib_results[i].buf_len = 0; } } @@ -103,7 +103,7 @@ void il4965_calib_free_results(struct il_priv *priv) * enough to receive all of our own network traffic, but not so * high that our DSP gets too busy trying to lock onto non-network * activity/noise. */ -static int il4965_sens_energy_cck(struct il_priv *priv, +static int il4965_sens_energy_cck(struct il_priv *il, u32 norm_fa, u32 rx_enable_time, struct statistics_general_data *rx_info) @@ -130,9 +130,9 @@ static int il4965_sens_energy_cck(struct il_priv *priv, u32 max_false_alarms = MAX_FA_CCK * rx_enable_time; u32 min_false_alarms = MIN_FA_CCK * rx_enable_time; struct il_sensitivity_data *data = NULL; - const struct il_sensitivity_ranges *ranges = priv->hw_params.sens; + const struct il_sensitivity_ranges *ranges = il->hw_params.sens; - data = &(priv->sensitivity_data); + data = &(il->sensitivity_data); data->nrg_auto_corr_silence_diff = 0; @@ -160,7 +160,7 @@ static int il4965_sens_energy_cck(struct il_priv *priv, val = data->nrg_silence_rssi[i]; silence_ref = max(silence_ref, val); } - IL_DEBUG_CALIB(priv, "silence a %u, b %u, c %u, 20-bcn max %u\n", + IL_DEBUG_CALIB(il, "silence a %u, b %u, c %u, 20-bcn max %u\n", silence_rssi_a, silence_rssi_b, silence_rssi_c, silence_ref); @@ -184,7 +184,7 @@ static int il4965_sens_energy_cck(struct il_priv *priv, max_nrg_cck = (u32) max(max_nrg_cck, (data->nrg_value[i])); max_nrg_cck += 6; - IL_DEBUG_CALIB(priv, "rx energy a %u, b %u, c %u, 10-bcn max/min %u\n", + IL_DEBUG_CALIB(il, "rx energy a %u, b %u, c %u, 10-bcn max/min %u\n", rx_info->beacon_energy_a, rx_info->beacon_energy_b, rx_info->beacon_energy_c, max_nrg_cck - 6); @@ -194,15 +194,15 @@ static int il4965_sens_energy_cck(struct il_priv *priv, data->num_in_cck_no_fa++; else data->num_in_cck_no_fa = 0; - IL_DEBUG_CALIB(priv, "consecutive bcns with few false alarms = %u\n", + IL_DEBUG_CALIB(il, "consecutive bcns with few false alarms = %u\n", data->num_in_cck_no_fa); /* If we got too many false alarms this time, reduce sensitivity */ if ((false_alarms > max_false_alarms) && (data->auto_corr_cck > AUTO_CORR_MAX_TH_CCK)) { - IL_DEBUG_CALIB(priv, "norm FA %u > max FA %u\n", + IL_DEBUG_CALIB(il, "norm FA %u > max FA %u\n", false_alarms, max_false_alarms); - IL_DEBUG_CALIB(priv, "... reducing sensitivity\n"); + IL_DEBUG_CALIB(il, "... reducing sensitivity\n"); data->nrg_curr_state = IL_FA_TOO_MANY; /* Store for "fewer than desired" on later beacon */ data->nrg_silence_ref = silence_ref; @@ -219,7 +219,7 @@ static int il4965_sens_energy_cck(struct il_priv *priv, data->nrg_auto_corr_silence_diff = (s32)data->nrg_silence_ref - (s32)silence_ref; - IL_DEBUG_CALIB(priv, + IL_DEBUG_CALIB(il, "norm FA %u < min FA %u, silence diff %d\n", false_alarms, min_false_alarms, data->nrg_auto_corr_silence_diff); @@ -234,18 +234,18 @@ static int il4965_sens_energy_cck(struct il_priv *priv, ((data->nrg_auto_corr_silence_diff > NRG_DIFF) || (data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA))) { - IL_DEBUG_CALIB(priv, "... increasing sensitivity\n"); + IL_DEBUG_CALIB(il, "... increasing sensitivity\n"); /* Increase nrg value to increase sensitivity */ val = data->nrg_th_cck + NRG_STEP_CCK; data->nrg_th_cck = min((u32)ranges->min_nrg_cck, val); } else { - IL_DEBUG_CALIB(priv, + IL_DEBUG_CALIB(il, "... but not changing sensitivity\n"); } /* Else we got a healthy number of false alarms, keep status quo */ } else { - IL_DEBUG_CALIB(priv, " FA in safe zone\n"); + IL_DEBUG_CALIB(il, " FA in safe zone\n"); data->nrg_curr_state = IL_FA_GOOD_RANGE; /* Store for use in "fewer than desired" with later beacon */ @@ -255,7 +255,7 @@ static int il4965_sens_energy_cck(struct il_priv *priv, * give it some extra margin by reducing sensitivity again * (but don't go below measured energy of desired Rx) */ if (IL_FA_TOO_MANY == data->nrg_prev_state) { - IL_DEBUG_CALIB(priv, "... increasing margin\n"); + IL_DEBUG_CALIB(il, "... increasing margin\n"); if (data->nrg_th_cck > (max_nrg_cck + NRG_MARGIN)) data->nrg_th_cck -= NRG_MARGIN; else @@ -269,7 +269,7 @@ static int il4965_sens_energy_cck(struct il_priv *priv, * Lower value is higher energy, so we use max()! */ data->nrg_th_cck = max(max_nrg_cck, data->nrg_th_cck); - IL_DEBUG_CALIB(priv, "new nrg_th_cck %u\n", data->nrg_th_cck); + IL_DEBUG_CALIB(il, "new nrg_th_cck %u\n", data->nrg_th_cck); data->nrg_prev_state = data->nrg_curr_state; @@ -306,7 +306,7 @@ static int il4965_sens_energy_cck(struct il_priv *priv, } -static int il4965_sens_auto_corr_ofdm(struct il_priv *priv, +static int il4965_sens_auto_corr_ofdm(struct il_priv *il, u32 norm_fa, u32 rx_enable_time) { @@ -315,14 +315,14 @@ static int il4965_sens_auto_corr_ofdm(struct il_priv *priv, u32 max_false_alarms = MAX_FA_OFDM * rx_enable_time; u32 min_false_alarms = MIN_FA_OFDM * rx_enable_time; struct il_sensitivity_data *data = NULL; - const struct il_sensitivity_ranges *ranges = priv->hw_params.sens; + const struct il_sensitivity_ranges *ranges = il->hw_params.sens; - data = &(priv->sensitivity_data); + data = &(il->sensitivity_data); /* If we got too many false alarms this time, reduce sensitivity */ if (false_alarms > max_false_alarms) { - IL_DEBUG_CALIB(priv, "norm FA %u > max FA %u)\n", + IL_DEBUG_CALIB(il, "norm FA %u > max FA %u)\n", false_alarms, max_false_alarms); val = data->auto_corr_ofdm + AUTO_CORR_STEP_OFDM; @@ -345,7 +345,7 @@ static int il4965_sens_auto_corr_ofdm(struct il_priv *priv, /* Else if we got fewer than desired, increase sensitivity */ else if (false_alarms < min_false_alarms) { - IL_DEBUG_CALIB(priv, "norm FA %u < min FA %u\n", + IL_DEBUG_CALIB(il, "norm FA %u < min FA %u\n", false_alarms, min_false_alarms); val = data->auto_corr_ofdm - AUTO_CORR_STEP_OFDM; @@ -364,13 +364,13 @@ static int il4965_sens_auto_corr_ofdm(struct il_priv *priv, data->auto_corr_ofdm_mrc_x1 = max((u32)ranges->auto_corr_min_ofdm_mrc_x1, val); } else { - IL_DEBUG_CALIB(priv, "min FA %u < norm FA %u < max FA %u OK\n", + IL_DEBUG_CALIB(il, "min FA %u < norm FA %u < max FA %u OK\n", min_false_alarms, false_alarms, max_false_alarms); } return 0; } -static void il4965_prepare_legacy_sensitivity_tbl(struct il_priv *priv, +static void il4965_prepare_legacy_sensitivity_tbl(struct il_priv *il, struct il_sensitivity_data *data, __le16 *tbl) { @@ -400,18 +400,18 @@ static void il4965_prepare_legacy_sensitivity_tbl(struct il_priv *priv, tbl[HD_OFDM_ENERGY_TH_IN_INDEX] = cpu_to_le16(data->nrg_th_cca); - IL_DEBUG_CALIB(priv, "ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n", + IL_DEBUG_CALIB(il, "ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n", data->auto_corr_ofdm, data->auto_corr_ofdm_mrc, data->auto_corr_ofdm_x1, data->auto_corr_ofdm_mrc_x1, data->nrg_th_ofdm); - IL_DEBUG_CALIB(priv, "cck: ac %u mrc %u thresh %u\n", + IL_DEBUG_CALIB(il, "cck: ac %u mrc %u thresh %u\n", data->auto_corr_cck, data->auto_corr_cck_mrc, data->nrg_th_cck); } /* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */ -static int il4965_sensitivity_write(struct il_priv *priv) +static int il4965_sensitivity_write(struct il_priv *il) { struct il_sensitivity_cmd cmd; struct il_sensitivity_data *data = NULL; @@ -422,43 +422,43 @@ static int il4965_sensitivity_write(struct il_priv *priv) .data = &cmd, }; - data = &(priv->sensitivity_data); + data = &(il->sensitivity_data); memset(&cmd, 0, sizeof(cmd)); - il4965_prepare_legacy_sensitivity_tbl(priv, data, &cmd.table[0]); + il4965_prepare_legacy_sensitivity_tbl(il, data, &cmd.table[0]); /* Update uCode's "work" table, and copy it to DSP */ cmd.control = SENSITIVITY_CMD_CONTROL_WORK_TABLE; /* Don't send command to uCode if nothing has changed */ - if (!memcmp(&cmd.table[0], &(priv->sensitivity_tbl[0]), + if (!memcmp(&cmd.table[0], &(il->sensitivity_tbl[0]), sizeof(u16)*HD_TABLE_SIZE)) { - IL_DEBUG_CALIB(priv, "No change in SENSITIVITY_CMD\n"); + IL_DEBUG_CALIB(il, "No change in SENSITIVITY_CMD\n"); return 0; } /* Copy table for comparison next time */ - memcpy(&(priv->sensitivity_tbl[0]), &(cmd.table[0]), + memcpy(&(il->sensitivity_tbl[0]), &(cmd.table[0]), sizeof(u16)*HD_TABLE_SIZE); - return il_send_cmd(priv, &cmd_out); + return il_send_cmd(il, &cmd_out); } -void il4965_init_sensitivity(struct il_priv *priv) +void il4965_init_sensitivity(struct il_priv *il) { int ret = 0; int i; struct il_sensitivity_data *data = NULL; - const struct il_sensitivity_ranges *ranges = priv->hw_params.sens; + const struct il_sensitivity_ranges *ranges = il->hw_params.sens; - if (priv->disable_sens_cal) + if (il->disable_sens_cal) return; - IL_DEBUG_CALIB(priv, "Start il4965_init_sensitivity\n"); + IL_DEBUG_CALIB(il, "Start il4965_init_sensitivity\n"); /* Clear driver's sensitivity algo data */ - data = &(priv->sensitivity_data); + data = &(il->sensitivity_data); if (ranges == NULL) return; @@ -495,11 +495,11 @@ void il4965_init_sensitivity(struct il_priv *priv) data->last_bad_plcp_cnt_cck = 0; data->last_fa_cnt_cck = 0; - ret |= il4965_sensitivity_write(priv); - IL_DEBUG_CALIB(priv, "<disable_sens_cal) + if (il->disable_sens_cal) return; - data = &(priv->sensitivity_data); + data = &(il->sensitivity_data); - if (!il_is_any_associated(priv)) { - IL_DEBUG_CALIB(priv, "<< - not associated\n"); + if (!il_is_any_associated(il)) { + IL_DEBUG_CALIB(il, "<< - not associated\n"); return; } - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); rx_info = &(((struct il_notif_statistics *)resp)->rx.general); ofdm = &(((struct il_notif_statistics *)resp)->rx.ofdm); cck = &(((struct il_notif_statistics *)resp)->rx.cck); if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { - IL_DEBUG_CALIB(priv, "<< invalid data.\n"); - spin_unlock_irqrestore(&priv->lock, flags); + IL_DEBUG_CALIB(il, "<< invalid data.\n"); + spin_unlock_irqrestore(&il->lock, flags); return; } @@ -556,12 +556,12 @@ void il4965_sensitivity_calibration(struct il_priv *priv, void *resp) statis.beacon_energy_c = le32_to_cpu(rx_info->beacon_energy_c); - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); - IL_DEBUG_CALIB(priv, "rx_enable_time = %u usecs\n", rx_enable_time); + IL_DEBUG_CALIB(il, "rx_enable_time = %u usecs\n", rx_enable_time); if (!rx_enable_time) { - IL_DEBUG_CALIB(priv, "<< RX Enable Time == 0!\n"); + IL_DEBUG_CALIB(il, "<< RX Enable Time == 0!\n"); return; } @@ -600,14 +600,14 @@ void il4965_sensitivity_calibration(struct il_priv *priv, void *resp) norm_fa_ofdm = fa_ofdm + bad_plcp_ofdm; norm_fa_cck = fa_cck + bad_plcp_cck; - IL_DEBUG_CALIB(priv, + IL_DEBUG_CALIB(il, "cck: fa %u badp %u ofdm: fa %u badp %u\n", fa_cck, bad_plcp_cck, fa_ofdm, bad_plcp_ofdm); - il4965_sens_auto_corr_ofdm(priv, norm_fa_ofdm, rx_enable_time); - il4965_sens_energy_cck(priv, norm_fa_cck, rx_enable_time, &statis); + il4965_sens_auto_corr_ofdm(il, norm_fa_ofdm, rx_enable_time); + il4965_sens_energy_cck(il, norm_fa_cck, rx_enable_time, &statis); - il4965_sensitivity_write(priv); + il4965_sensitivity_write(il); } static inline u8 il4965_find_first_chain(u8 mask) @@ -624,7 +624,7 @@ static inline u8 il4965_find_first_chain(u8 mask) * disconnected. */ static void -il4965_find_disconn_antenna(struct il_priv *priv, u32* average_sig, +il4965_find_disconn_antenna(struct il_priv *il, u32* average_sig, struct il_chain_noise_data *data) { u32 active_chains = 0; @@ -635,11 +635,11 @@ il4965_find_disconn_antenna(struct il_priv *priv, u32* average_sig, u16 i = 0; average_sig[0] = data->chain_signal_a / - priv->cfg->base_params->chain_noise_num_beacons; + il->cfg->base_params->chain_noise_num_beacons; average_sig[1] = data->chain_signal_b / - priv->cfg->base_params->chain_noise_num_beacons; + il->cfg->base_params->chain_noise_num_beacons; average_sig[2] = data->chain_signal_c / - priv->cfg->base_params->chain_noise_num_beacons; + il->cfg->base_params->chain_noise_num_beacons; if (average_sig[0] >= average_sig[1]) { max_average_sig = average_sig[0]; @@ -657,9 +657,9 @@ il4965_find_disconn_antenna(struct il_priv *priv, u32* average_sig, active_chains = (1 << max_average_sig_antenna_i); } - IL_DEBUG_CALIB(priv, "average_sig: a %d b %d c %d\n", + IL_DEBUG_CALIB(il, "average_sig: a %d b %d c %d\n", average_sig[0], average_sig[1], average_sig[2]); - IL_DEBUG_CALIB(priv, "max_average_sig = %d, antenna %d\n", + IL_DEBUG_CALIB(il, "max_average_sig = %d, antenna %d\n", max_average_sig, max_average_sig_antenna_i); /* Compare signal strengths for all 3 receivers. */ @@ -673,7 +673,7 @@ il4965_find_disconn_antenna(struct il_priv *priv, u32* average_sig, data->disconn_array[i] = 1; else active_chains |= (1 << i); - IL_DEBUG_CALIB(priv, "i = %d rssiDelta = %d " + IL_DEBUG_CALIB(il, "i = %d rssiDelta = %d " "disconn_array[i] = %d\n", i, rssi_delta, data->disconn_array[i]); } @@ -689,58 +689,58 @@ il4965_find_disconn_antenna(struct il_priv *priv, u32* average_sig, * To be safe, simply mask out any chains that we know * are not on the device. */ - active_chains &= priv->hw_params.valid_rx_ant; + active_chains &= il->hw_params.valid_rx_ant; num_tx_chains = 0; for (i = 0; i < NUM_RX_CHAINS; i++) { /* loops on all the bits of - * priv->hw_setting.valid_tx_ant */ + * il->hw_setting.valid_tx_ant */ u8 ant_msk = (1 << i); - if (!(priv->hw_params.valid_tx_ant & ant_msk)) + if (!(il->hw_params.valid_tx_ant & ant_msk)) continue; num_tx_chains++; if (data->disconn_array[i] == 0) /* there is a Tx antenna connected */ break; - if (num_tx_chains == priv->hw_params.tx_chains_num && + if (num_tx_chains == il->hw_params.tx_chains_num && data->disconn_array[i]) { /* * If all chains are disconnected * connect the first valid tx chain */ first_chain = - il4965_find_first_chain(priv->cfg->valid_tx_ant); + il4965_find_first_chain(il->cfg->valid_tx_ant); data->disconn_array[first_chain] = 0; active_chains |= BIT(first_chain); - IL_DEBUG_CALIB(priv, + IL_DEBUG_CALIB(il, "All Tx chains are disconnected W/A - declare %d as connected\n", first_chain); break; } } - if (active_chains != priv->hw_params.valid_rx_ant && - active_chains != priv->chain_noise_data.active_chains) - IL_DEBUG_CALIB(priv, + if (active_chains != il->hw_params.valid_rx_ant && + active_chains != il->chain_noise_data.active_chains) + IL_DEBUG_CALIB(il, "Detected that not all antennas are connected! " "Connected: %#x, valid: %#x.\n", - active_chains, priv->hw_params.valid_rx_ant); + active_chains, il->hw_params.valid_rx_ant); /* Save for use within RXON, TX, SCAN commands, etc. */ data->active_chains = active_chains; - IL_DEBUG_CALIB(priv, "active_chains (bitwise) = 0x%x\n", + IL_DEBUG_CALIB(il, "active_chains (bitwise) = 0x%x\n", active_chains); } -static void il4965_gain_computation(struct il_priv *priv, +static void il4965_gain_computation(struct il_priv *il, u32 *average_noise, u16 min_average_noise_antenna_i, u32 min_average_noise, u8 default_chain) { int i, ret; - struct il_chain_noise_data *data = &priv->chain_noise_data; + struct il_chain_noise_data *data = &il->chain_noise_data; data->delta_gain_code[min_average_noise_antenna_i] = 0; @@ -762,7 +762,7 @@ static void il4965_gain_computation(struct il_priv *priv, data->delta_gain_code[i] = 0; } } - IL_DEBUG_CALIB(priv, "delta_gain_codes: a %d b %d c %d\n", + IL_DEBUG_CALIB(il, "delta_gain_codes: a %d b %d c %d\n", data->delta_gain_code[0], data->delta_gain_code[1], data->delta_gain_code[2]); @@ -777,10 +777,10 @@ static void il4965_gain_computation(struct il_priv *priv, cmd.diff_gain_a = data->delta_gain_code[0]; cmd.diff_gain_b = data->delta_gain_code[1]; cmd.diff_gain_c = data->delta_gain_code[2]; - ret = il_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD, + ret = il_send_cmd_pdu(il, REPLY_PHY_CALIBRATION_CMD, sizeof(cmd), &cmd); if (ret) - IL_DEBUG_CALIB(priv, "fail sending cmd " + IL_DEBUG_CALIB(il, "fail sending cmd " "REPLY_PHY_CALIBRATION_CMD\n"); /* TODO we might want recalculate @@ -799,7 +799,7 @@ static void il4965_gain_computation(struct il_priv *priv, * 1) Which antennas are connected. * 2) Differential rx gain settings to balance the 3 receivers. */ -void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp) +void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) { struct il_chain_noise_data *data = NULL; @@ -821,12 +821,12 @@ void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp) unsigned long flags; struct statistics_rx_non_phy *rx_info; - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; - if (priv->disable_chain_noise_cal) + if (il->disable_chain_noise_cal) return; - data = &(priv->chain_noise_data); + data = &(il->chain_noise_data); /* * Accumulate just the first "chain_noise_num_beacons" after @@ -834,18 +834,18 @@ void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp) */ if (data->state != IL_CHAIN_NOISE_ACCUMULATE) { if (data->state == IL_CHAIN_NOISE_ALIVE) - IL_DEBUG_CALIB(priv, "Wait for noise calib reset\n"); + IL_DEBUG_CALIB(il, "Wait for noise calib reset\n"); return; } - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); rx_info = &(((struct il_notif_statistics *)stat_resp)-> rx.general); if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { - IL_DEBUG_CALIB(priv, " << Interference data unavailable\n"); - spin_unlock_irqrestore(&priv->lock, flags); + IL_DEBUG_CALIB(il, " << Interference data unavailable\n"); + spin_unlock_irqrestore(&il->lock, flags); return; } @@ -861,9 +861,9 @@ void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp) /* Make sure we accumulate data for just the associated channel * (even if scanning). */ if ((rxon_chnum != stat_chnum) || (rxon_band24 != stat_band24)) { - IL_DEBUG_CALIB(priv, "Stats not from chan=%d, band24=%d\n", + IL_DEBUG_CALIB(il, "Stats not from chan=%d, band24=%d\n", rxon_chnum, rxon_band24); - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); return; } @@ -882,7 +882,7 @@ void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp) chain_sig_b = le32_to_cpu(rx_info->beacon_rssi_b) & IN_BAND_FILTER; chain_sig_c = le32_to_cpu(rx_info->beacon_rssi_c) & IN_BAND_FILTER; - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); data->beacon_count++; @@ -894,30 +894,30 @@ void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp) data->chain_signal_b = (chain_sig_b + data->chain_signal_b); data->chain_signal_c = (chain_sig_c + data->chain_signal_c); - IL_DEBUG_CALIB(priv, "chan=%d, band24=%d, beacon=%d\n", + IL_DEBUG_CALIB(il, "chan=%d, band24=%d, beacon=%d\n", rxon_chnum, rxon_band24, data->beacon_count); - IL_DEBUG_CALIB(priv, "chain_sig: a %d b %d c %d\n", + IL_DEBUG_CALIB(il, "chain_sig: a %d b %d c %d\n", chain_sig_a, chain_sig_b, chain_sig_c); - IL_DEBUG_CALIB(priv, "chain_noise: a %d b %d c %d\n", + IL_DEBUG_CALIB(il, "chain_noise: a %d b %d c %d\n", chain_noise_a, chain_noise_b, chain_noise_c); /* If this is the "chain_noise_num_beacons", determine: * 1) Disconnected antennas (using signal strengths) * 2) Differential gain (using silence noise) to balance receivers */ if (data->beacon_count != - priv->cfg->base_params->chain_noise_num_beacons) + il->cfg->base_params->chain_noise_num_beacons) return; /* Analyze signal for disconnected antenna */ - il4965_find_disconn_antenna(priv, average_sig, data); + il4965_find_disconn_antenna(il, average_sig, data); /* Analyze noise for rx balance */ average_noise[0] = data->chain_noise_a / - priv->cfg->base_params->chain_noise_num_beacons; + il->cfg->base_params->chain_noise_num_beacons; average_noise[1] = data->chain_noise_b / - priv->cfg->base_params->chain_noise_num_beacons; + il->cfg->base_params->chain_noise_num_beacons; average_noise[2] = data->chain_noise_c / - priv->cfg->base_params->chain_noise_num_beacons; + il->cfg->base_params->chain_noise_num_beacons; for (i = 0; i < NUM_RX_CHAINS; i++) { if (!(data->disconn_array[i]) && @@ -929,39 +929,39 @@ void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp) } } - IL_DEBUG_CALIB(priv, "average_noise: a %d b %d c %d\n", + IL_DEBUG_CALIB(il, "average_noise: a %d b %d c %d\n", average_noise[0], average_noise[1], average_noise[2]); - IL_DEBUG_CALIB(priv, "min_average_noise = %d, antenna %d\n", + IL_DEBUG_CALIB(il, "min_average_noise = %d, antenna %d\n", min_average_noise, min_average_noise_antenna_i); - il4965_gain_computation(priv, average_noise, + il4965_gain_computation(il, average_noise, min_average_noise_antenna_i, min_average_noise, - il4965_find_first_chain(priv->cfg->valid_rx_ant)); + il4965_find_first_chain(il->cfg->valid_rx_ant)); /* Some power changes may have been made during the calibration. * Update and commit the RXON */ - if (priv->cfg->ops->lib->update_chain_flags) - priv->cfg->ops->lib->update_chain_flags(priv); + if (il->cfg->ops->lib->update_chain_flags) + il->cfg->ops->lib->update_chain_flags(il); data->state = IL_CHAIN_NOISE_DONE; - il_power_update_mode(priv, false); + il_power_update_mode(il, false); } -void il4965_reset_run_time_calib(struct il_priv *priv) +void il4965_reset_run_time_calib(struct il_priv *il) { int i; - memset(&(priv->sensitivity_data), 0, + memset(&(il->sensitivity_data), 0, sizeof(struct il_sensitivity_data)); - memset(&(priv->chain_noise_data), 0, + memset(&(il->chain_noise_data), 0, sizeof(struct il_chain_noise_data)); for (i = 0; i < NUM_RX_CHAINS; i++) - priv->chain_noise_data.delta_gain_code[i] = + il->chain_noise_data.delta_gain_code[i] = CHAIN_NOISE_DELTA_GAIN_INIT_VAL; /* Ask for statistics now, the uCode will send notification * periodically after association */ - il_send_statistics_request(priv, CMD_ASYNC, true); + il_send_statistics_request(il, CMD_ASYNC, true); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.h b/drivers/net/wireless/iwlegacy/iwl-4965-calib.h index a23081f1d03e..0e30ea7ff12e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-calib.h @@ -66,10 +66,10 @@ #include "iwl-core.h" #include "iwl-commands.h" -void il4965_chain_noise_calibration(struct il_priv *priv, void *stat_resp); -void il4965_sensitivity_calibration(struct il_priv *priv, void *resp); -void il4965_init_sensitivity(struct il_priv *priv); -void il4965_reset_run_time_calib(struct il_priv *priv); -void il4965_calib_free_results(struct il_priv *priv); +void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp); +void il4965_sensitivity_calibration(struct il_priv *il, void *resp); +void il4965_init_sensitivity(struct il_priv *il); +void il4965_reset_run_time_calib(struct il_priv *il); +void il4965_calib_free_results(struct il_priv *il); #endif /* __il_4965_calib_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c index 3c2876ffadc5..8ea0ac205f7f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c @@ -33,12 +33,12 @@ static const char *fmt_table = " %-30s %10u %10u %10u %10u\n"; static const char *fmt_header = "%-32s current cumulative delta max\n"; -static int il4965_statistics_flag(struct il_priv *priv, char *buf, int bufsz) +static int il4965_statistics_flag(struct il_priv *il, char *buf, int bufsz) { int p = 0; u32 flag; - flag = le32_to_cpu(priv->_4965.statistics.flag); + flag = le32_to_cpu(il->_4965.statistics.flag); p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag); if (flag & UCODE_STATISTICS_CLEAR_MSK) @@ -57,7 +57,7 @@ static int il4965_statistics_flag(struct il_priv *priv, char *buf, int bufsz) ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0; char *buf; int bufsz = sizeof(struct statistics_rx_phy) * 40 + @@ -70,12 +70,12 @@ ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, struct statistics_rx_non_phy *delta_general, *max_general; struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht; - if (!il_is_alive(priv)) + if (!il_is_alive(il)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(il, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -84,24 +84,24 @@ ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, * the last statistics notification from uCode * might not reflect the current uCode activity */ - ofdm = &priv->_4965.statistics.rx.ofdm; - cck = &priv->_4965.statistics.rx.cck; - general = &priv->_4965.statistics.rx.general; - ht = &priv->_4965.statistics.rx.ofdm_ht; - accum_ofdm = &priv->_4965.accum_statistics.rx.ofdm; - accum_cck = &priv->_4965.accum_statistics.rx.cck; - accum_general = &priv->_4965.accum_statistics.rx.general; - accum_ht = &priv->_4965.accum_statistics.rx.ofdm_ht; - delta_ofdm = &priv->_4965.delta_statistics.rx.ofdm; - delta_cck = &priv->_4965.delta_statistics.rx.cck; - delta_general = &priv->_4965.delta_statistics.rx.general; - delta_ht = &priv->_4965.delta_statistics.rx.ofdm_ht; - max_ofdm = &priv->_4965.max_delta.rx.ofdm; - max_cck = &priv->_4965.max_delta.rx.cck; - max_general = &priv->_4965.max_delta.rx.general; - max_ht = &priv->_4965.max_delta.rx.ofdm_ht; + ofdm = &il->_4965.statistics.rx.ofdm; + cck = &il->_4965.statistics.rx.cck; + general = &il->_4965.statistics.rx.general; + ht = &il->_4965.statistics.rx.ofdm_ht; + accum_ofdm = &il->_4965.accum_statistics.rx.ofdm; + accum_cck = &il->_4965.accum_statistics.rx.cck; + accum_general = &il->_4965.accum_statistics.rx.general; + accum_ht = &il->_4965.accum_statistics.rx.ofdm_ht; + delta_ofdm = &il->_4965.delta_statistics.rx.ofdm; + delta_cck = &il->_4965.delta_statistics.rx.cck; + delta_general = &il->_4965.delta_statistics.rx.general; + delta_ht = &il->_4965.delta_statistics.rx.ofdm_ht; + max_ofdm = &il->_4965.max_delta.rx.ofdm; + max_cck = &il->_4965.max_delta.rx.cck; + max_general = &il->_4965.max_delta.rx.general; + max_ht = &il->_4965.max_delta.rx.ofdm_ht; - pos += il4965_statistics_flag(priv, buf, bufsz); + pos += il4965_statistics_flag(il, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, fmt_header, "Statistics_Rx - OFDM:"); pos += scnprintf(buf + pos, bufsz - pos, @@ -489,19 +489,19 @@ ssize_t il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0; char *buf; int bufsz = (sizeof(struct statistics_tx) * 48) + 250; ssize_t ret; struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx; - if (!il_is_alive(priv)) + if (!il_is_alive(il)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(il, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -509,12 +509,12 @@ ssize_t il4965_ucode_tx_stats_read(struct file *file, * the last statistics notification from uCode * might not reflect the current uCode activity */ - tx = &priv->_4965.statistics.tx; - accum_tx = &priv->_4965.accum_statistics.tx; - delta_tx = &priv->_4965.delta_statistics.tx; - max_tx = &priv->_4965.max_delta.tx; + tx = &il->_4965.statistics.tx; + accum_tx = &il->_4965.accum_statistics.tx; + delta_tx = &il->_4965.delta_statistics.tx; + max_tx = &il->_4965.max_delta.tx; - pos += il4965_statistics_flag(priv, buf, bufsz); + pos += il4965_statistics_flag(il, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, fmt_header, "Statistics_Tx:"); pos += scnprintf(buf + pos, bufsz - pos, @@ -664,7 +664,7 @@ ssize_t il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0; char *buf; int bufsz = sizeof(struct statistics_general) * 10 + 300; @@ -674,12 +674,12 @@ il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; struct statistics_div *div, *accum_div, *delta_div, *max_div; - if (!il_is_alive(priv)) + if (!il_is_alive(il)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(il, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -687,20 +687,20 @@ il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, * the last statistics notification from uCode * might not reflect the current uCode activity */ - general = &priv->_4965.statistics.general.common; - dbg = &priv->_4965.statistics.general.common.dbg; - div = &priv->_4965.statistics.general.common.div; - accum_general = &priv->_4965.accum_statistics.general.common; - accum_dbg = &priv->_4965.accum_statistics.general.common.dbg; - accum_div = &priv->_4965.accum_statistics.general.common.div; - delta_general = &priv->_4965.delta_statistics.general.common; - max_general = &priv->_4965.max_delta.general.common; - delta_dbg = &priv->_4965.delta_statistics.general.common.dbg; - max_dbg = &priv->_4965.max_delta.general.common.dbg; - delta_div = &priv->_4965.delta_statistics.general.common.div; - max_div = &priv->_4965.max_delta.general.common.div; + general = &il->_4965.statistics.general.common; + dbg = &il->_4965.statistics.general.common.dbg; + div = &il->_4965.statistics.general.common.div; + accum_general = &il->_4965.accum_statistics.general.common; + accum_dbg = &il->_4965.accum_statistics.general.common.dbg; + accum_div = &il->_4965.accum_statistics.general.common.div; + delta_general = &il->_4965.delta_statistics.general.common; + max_general = &il->_4965.max_delta.general.common; + delta_dbg = &il->_4965.delta_statistics.general.common.dbg; + max_dbg = &il->_4965.max_delta.general.common.dbg; + delta_div = &il->_4965.delta_statistics.general.common.div; + max_div = &il->_4965.max_delta.general.common.div; - pos += il4965_statistics_flag(priv, buf, bufsz); + pos += il4965_statistics_flag(il, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, fmt_header, "Statistics_General:"); pos += scnprintf(buf + pos, bufsz - pos, diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c index e657b444cf48..947475ea3cef 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c @@ -87,23 +87,23 @@ * EEPROM chip, not a single event, so even reads could conflict if they * weren't arbitrated by the semaphore. */ -int il4965_eeprom_acquire_semaphore(struct il_priv *priv) +int il4965_eeprom_acquire_semaphore(struct il_priv *il) { u16 count; int ret; for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) { /* Request semaphore */ - il_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); /* See if we got it */ - ret = il_poll_bit(priv, CSR_HW_IF_CONFIG_REG, + ret = il_poll_bit(il, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, EEPROM_SEM_TIMEOUT); if (ret >= 0) { - IL_DEBUG_IO(priv, + IL_DEBUG_IO(il, "Acquired semaphore after %d tries.\n", count+1); return ret; @@ -113,42 +113,42 @@ int il4965_eeprom_acquire_semaphore(struct il_priv *priv) return ret; } -void il4965_eeprom_release_semaphore(struct il_priv *priv) +void il4965_eeprom_release_semaphore(struct il_priv *il) { - il_clear_bit(priv, CSR_HW_IF_CONFIG_REG, + il_clear_bit(il, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); } -int il4965_eeprom_check_version(struct il_priv *priv) +int il4965_eeprom_check_version(struct il_priv *il) { u16 eeprom_ver; u16 calib_ver; - eeprom_ver = il_eeprom_query16(priv, EEPROM_VERSION); - calib_ver = il_eeprom_query16(priv, + eeprom_ver = il_eeprom_query16(il, EEPROM_VERSION); + calib_ver = il_eeprom_query16(il, EEPROM_4965_CALIB_VERSION_OFFSET); - if (eeprom_ver < priv->cfg->eeprom_ver || - calib_ver < priv->cfg->eeprom_calib_ver) + if (eeprom_ver < il->cfg->eeprom_ver || + calib_ver < il->cfg->eeprom_calib_ver) goto err; - IL_INFO(priv, "device EEPROM VER=0x%x, CALIB=0x%x\n", + IL_INFO(il, "device EEPROM VER=0x%x, CALIB=0x%x\n", eeprom_ver, calib_ver); return 0; err: - IL_ERR(priv, "Unsupported (too old) EEPROM VER=0x%x < 0x%x " + IL_ERR(il, "Unsupported (too old) EEPROM VER=0x%x < 0x%x " "CALIB=0x%x < 0x%x\n", - eeprom_ver, priv->cfg->eeprom_ver, - calib_ver, priv->cfg->eeprom_calib_ver); + eeprom_ver, il->cfg->eeprom_ver, + calib_ver, il->cfg->eeprom_calib_ver); return -EINVAL; } -void il4965_eeprom_get_mac(const struct il_priv *priv, u8 *mac) +void il4965_eeprom_get_mac(const struct il_priv *il, u8 *mac) { - const u8 *addr = il_eeprom_query_addr(priv, + const u8 *addr = il_eeprom_query_addr(il, EEPROM_MAC_ADDRESS); memcpy(mac, addr, ETH_ALEN); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-led.c b/drivers/net/wireless/iwlegacy/iwl-4965-led.c index d2c8eacd6835..1436a1b7ebf6 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-led.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-led.c @@ -44,7 +44,7 @@ /* Send led command */ static int -il4965_send_led_cmd(struct il_priv *priv, struct il_led_cmd *led_cmd) +il4965_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd) { struct il_host_cmd cmd = { .id = REPLY_LEDS_CMD, @@ -55,17 +55,17 @@ il4965_send_led_cmd(struct il_priv *priv, struct il_led_cmd *led_cmd) }; u32 reg; - reg = il_read32(priv, CSR_LED_REG); + reg = il_read32(il, CSR_LED_REG); if (reg != (reg & CSR_LED_BSM_CTRL_MSK)) - il_write32(priv, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK); + il_write32(il, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK); - return il_send_cmd(priv, &cmd); + return il_send_cmd(il, &cmd); } /* Set led register off */ -void il4965_led_enable(struct il_priv *priv) +void il4965_led_enable(struct il_priv *il) { - il_write32(priv, CSR_LED_REG, CSR_LED_REG_TRUN_ON); + il_write32(il, CSR_LED_REG, CSR_LED_REG_TRUN_ON); } const struct il_led_ops il4965_led_ops = { diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-led.h b/drivers/net/wireless/iwlegacy/iwl-4965-led.h index ab03dff812fd..e804fe16caef 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-led.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-led.h @@ -28,6 +28,6 @@ #define __il_4965_led_h__ extern const struct il_led_ops il4965_led_ops; -void il4965_led_enable(struct il_priv *priv); +void il4965_led_enable(struct il_priv *il); #endif /* __il_4965_led_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index 25f1d4768e7b..4d25590b0339 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -40,13 +40,13 @@ #include "iwl-4965.h" #include "iwl-sta.h" -void il4965_check_abort_status(struct il_priv *priv, +void il4965_check_abort_status(struct il_priv *il, u8 frame_count, u32 status) { if (frame_count == 1 && status == TX_STATUS_FAIL_RFKILL_FLUSH) { - IL_ERR(priv, "Tx flush command to flush out all frames\n"); - if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) - queue_work(priv->workqueue, &priv->tx_flush); + IL_ERR(il, "Tx flush command to flush out all frames\n"); + if (!test_bit(STATUS_EXIT_PENDING, &il->status)) + queue_work(il->workqueue, &il->tx_flush); } } @@ -59,7 +59,7 @@ struct il_mod_params il4965_mod_params = { /* the rest are 0 by default */ }; -void il4965_rx_queue_reset(struct il_priv *priv, struct il_rx_queue *rxq) +void il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) { unsigned long flags; int i; @@ -71,10 +71,10 @@ void il4965_rx_queue_reset(struct il_priv *priv, struct il_rx_queue *rxq) /* In the reset function, these buffers may have been allocated * to an SKB, so we need to unmap and free potential storage */ if (rxq->pool[i].page != NULL) { - pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, - PAGE_SIZE << priv->hw_params.rx_page_order, + pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, + PAGE_SIZE << il->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); - __il_free_pages(priv, rxq->pool[i].page); + __il_free_pages(il, rxq->pool[i].page); rxq->pool[i].page = NULL; } list_add_tail(&rxq->pool[i].list, &rxq->rx_used); @@ -91,29 +91,29 @@ void il4965_rx_queue_reset(struct il_priv *priv, struct il_rx_queue *rxq) spin_unlock_irqrestore(&rxq->lock, flags); } -int il4965_rx_init(struct il_priv *priv, struct il_rx_queue *rxq) +int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) { u32 rb_size; const u32 rfdnlog = RX_QUEUE_SIZE_LOG; /* 256 RBDs */ u32 rb_timeout = 0; - if (priv->cfg->mod_params->amsdu_size_8K) + if (il->cfg->mod_params->amsdu_size_8K) rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K; else rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K; /* Stop Rx DMA */ - il_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); + il_write_direct32(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); /* Reset driver's Rx queue write index */ - il_write_direct32(priv, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); + il_write_direct32(il, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); /* Tell device where to find RBD circular buffer in DRAM */ - il_write_direct32(priv, FH_RSCSR_CHNL0_RBDCB_BASE_REG, + il_write_direct32(il, FH_RSCSR_CHNL0_RBDCB_BASE_REG, (u32)(rxq->bd_dma >> 8)); /* Tell device where in DRAM to update its Rx status */ - il_write_direct32(priv, FH_RSCSR_CHNL0_STTS_WPTR_REG, + il_write_direct32(il, FH_RSCSR_CHNL0_STTS_WPTR_REG, rxq->rb_stts_dma >> 4); /* Enable Rx DMA @@ -122,7 +122,7 @@ int il4965_rx_init(struct il_priv *priv, struct il_rx_queue *rxq) * RB timeout 0x10 * 256 RBDs */ - il_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, + il_write_direct32(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL | FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL | FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK | @@ -131,77 +131,77 @@ int il4965_rx_init(struct il_priv *priv, struct il_rx_queue *rxq) (rfdnlog << FH_RCSR_RX_CONFIG_RBDCB_SIZE_POS)); /* Set interrupt coalescing timer to default (2048 usecs) */ - il_write8(priv, CSR_INT_COALESCING, IL_HOST_INT_TIMEOUT_DEF); + il_write8(il, CSR_INT_COALESCING, IL_HOST_INT_TIMEOUT_DEF); return 0; } -static void il4965_set_pwr_vmain(struct il_priv *priv) +static void il4965_set_pwr_vmain(struct il_priv *il) { /* * (for documentation purposes) * to set power to V_AUX, do: - if (pci_pme_capable(priv->pci_dev, PCI_D3cold)) - il_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, + if (pci_pme_capable(il->pci_dev, PCI_D3cold)) + il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_PWR_SRC_VAUX, ~APMG_PS_CTRL_MSK_PWR_SRC); */ - il_set_bits_mask_prph(priv, APMG_PS_CTRL_REG, + il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, ~APMG_PS_CTRL_MSK_PWR_SRC); } -int il4965_hw_nic_init(struct il_priv *priv) +int il4965_hw_nic_init(struct il_priv *il) { unsigned long flags; - struct il_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &il->rxq; int ret; /* nic_init */ - spin_lock_irqsave(&priv->lock, flags); - priv->cfg->ops->lib->apm_ops.init(priv); + spin_lock_irqsave(&il->lock, flags); + il->cfg->ops->lib->apm_ops.init(il); /* Set interrupt coalescing calibration timer to default (512 usecs) */ - il_write8(priv, CSR_INT_COALESCING, IL_HOST_INT_CALIB_TIMEOUT_DEF); + il_write8(il, CSR_INT_COALESCING, IL_HOST_INT_CALIB_TIMEOUT_DEF); - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); - il4965_set_pwr_vmain(priv); + il4965_set_pwr_vmain(il); - priv->cfg->ops->lib->apm_ops.config(priv); + il->cfg->ops->lib->apm_ops.config(il); /* Allocate the RX queue, or reset if it is already allocated */ if (!rxq->bd) { - ret = il_rx_queue_alloc(priv); + ret = il_rx_queue_alloc(il); if (ret) { - IL_ERR(priv, "Unable to initialize Rx queue\n"); + IL_ERR(il, "Unable to initialize Rx queue\n"); return -ENOMEM; } } else - il4965_rx_queue_reset(priv, rxq); + il4965_rx_queue_reset(il, rxq); - il4965_rx_replenish(priv); + il4965_rx_replenish(il); - il4965_rx_init(priv, rxq); + il4965_rx_init(il, rxq); - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); rxq->need_update = 1; - il_rx_queue_update_write_ptr(priv, rxq); + il_rx_queue_update_write_ptr(il, rxq); - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); /* Allocate or reset and init all Tx and Command queues */ - if (!priv->txq) { - ret = il4965_txq_ctx_alloc(priv); + if (!il->txq) { + ret = il4965_txq_ctx_alloc(il); if (ret) return ret; } else - il4965_txq_ctx_reset(priv); + il4965_txq_ctx_reset(il); - set_bit(STATUS_INIT, &priv->status); + set_bit(STATUS_INIT, &il->status); return 0; } @@ -209,7 +209,7 @@ int il4965_hw_nic_init(struct il_priv *priv) /** * il4965_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr */ -static inline __le32 il4965_dma_addr2rbd_ptr(struct il_priv *priv, +static inline __le32 il4965_dma_addr2rbd_ptr(struct il_priv *il, dma_addr_t dma_addr) { return cpu_to_le32((u32)(dma_addr >> 8)); @@ -226,9 +226,9 @@ static inline __le32 il4965_dma_addr2rbd_ptr(struct il_priv *priv, * also updates the memory address in the firmware to reference the new * target buffer. */ -void il4965_rx_queue_restock(struct il_priv *priv) +void il4965_rx_queue_restock(struct il_priv *il) { - struct il_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &il->rxq; struct list_head *element; struct il_rx_mem_buffer *rxb; unsigned long flags; @@ -245,7 +245,7 @@ void il4965_rx_queue_restock(struct il_priv *priv) list_del(element); /* Point to Rx buffer via next RBD in circular buffer */ - rxq->bd[rxq->write] = il4965_dma_addr2rbd_ptr(priv, + rxq->bd[rxq->write] = il4965_dma_addr2rbd_ptr(il, rxb->page_dma); rxq->queue[rxq->write] = rxb; rxq->write = (rxq->write + 1) & RX_QUEUE_MASK; @@ -255,7 +255,7 @@ void il4965_rx_queue_restock(struct il_priv *priv) /* If the pre-allocated buffer pool is dropping low, schedule to * refill it */ if (rxq->free_count <= RX_LOW_WATERMARK) - queue_work(priv->workqueue, &priv->rx_replenish); + queue_work(il->workqueue, &il->rx_replenish); /* If we've added more space for the firmware to place data, tell it. @@ -264,7 +264,7 @@ void il4965_rx_queue_restock(struct il_priv *priv) spin_lock_irqsave(&rxq->lock, flags); rxq->need_update = 1; spin_unlock_irqrestore(&rxq->lock, flags); - il_rx_queue_update_write_ptr(priv, rxq); + il_rx_queue_update_write_ptr(il, rxq); } } @@ -276,9 +276,9 @@ void il4965_rx_queue_restock(struct il_priv *priv) * Also restock the Rx queue via il_rx_queue_restock. * This is called as a scheduled work item (except for during initialization) */ -static void il4965_rx_allocate(struct il_priv *priv, gfp_t priority) +static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) { - struct il_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &il->rxq; struct list_head *element; struct il_rx_mem_buffer *rxb; struct page *page; @@ -296,20 +296,20 @@ static void il4965_rx_allocate(struct il_priv *priv, gfp_t priority) if (rxq->free_count > RX_LOW_WATERMARK) gfp_mask |= __GFP_NOWARN; - if (priv->hw_params.rx_page_order > 0) + if (il->hw_params.rx_page_order > 0) gfp_mask |= __GFP_COMP; /* Alloc a new receive buffer */ - page = alloc_pages(gfp_mask, priv->hw_params.rx_page_order); + page = alloc_pages(gfp_mask, il->hw_params.rx_page_order); if (!page) { if (net_ratelimit()) - IL_DEBUG_INFO(priv, "alloc_pages failed, " + IL_DEBUG_INFO(il, "alloc_pages failed, " "order: %d\n", - priv->hw_params.rx_page_order); + il->hw_params.rx_page_order); if ((rxq->free_count <= RX_LOW_WATERMARK) && net_ratelimit()) - IL_CRIT(priv, + IL_CRIT(il, "Failed to alloc_pages with %s. " "Only %u free buffers remaining.\n", priority == GFP_ATOMIC ? @@ -325,7 +325,7 @@ static void il4965_rx_allocate(struct il_priv *priv, gfp_t priority) if (list_empty(&rxq->rx_used)) { spin_unlock_irqrestore(&rxq->lock, flags); - __free_pages(page, priv->hw_params.rx_page_order); + __free_pages(page, il->hw_params.rx_page_order); return; } element = rxq->rx_used.next; @@ -337,8 +337,8 @@ static void il4965_rx_allocate(struct il_priv *priv, gfp_t priority) BUG_ON(rxb->page); rxb->page = page; /* Get physical address of the RB */ - rxb->page_dma = pci_map_page(priv->pci_dev, page, 0, - PAGE_SIZE << priv->hw_params.rx_page_order, + rxb->page_dma = pci_map_page(il->pci_dev, page, 0, + PAGE_SIZE << il->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); /* dma address must be no more than 36 bits */ BUG_ON(rxb->page_dma & ~DMA_BIT_MASK(36)); @@ -349,28 +349,28 @@ static void il4965_rx_allocate(struct il_priv *priv, gfp_t priority) list_add_tail(&rxb->list, &rxq->rx_free); rxq->free_count++; - priv->alloc_rxb_page++; + il->alloc_rxb_page++; spin_unlock_irqrestore(&rxq->lock, flags); } } -void il4965_rx_replenish(struct il_priv *priv) +void il4965_rx_replenish(struct il_priv *il) { unsigned long flags; - il4965_rx_allocate(priv, GFP_KERNEL); + il4965_rx_allocate(il, GFP_KERNEL); - spin_lock_irqsave(&priv->lock, flags); - il4965_rx_queue_restock(priv); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); + il4965_rx_queue_restock(il); + spin_unlock_irqrestore(&il->lock, flags); } -void il4965_rx_replenish_now(struct il_priv *priv) +void il4965_rx_replenish_now(struct il_priv *il) { - il4965_rx_allocate(priv, GFP_ATOMIC); + il4965_rx_allocate(il, GFP_ATOMIC); - il4965_rx_queue_restock(priv); + il4965_rx_queue_restock(il); } /* Assumes that the skb field of the buffers in 'pool' is kept accurate. @@ -378,33 +378,33 @@ void il4965_rx_replenish_now(struct il_priv *priv) * This free routine walks the list of POOL entries and if SKB is set to * non NULL it is unmapped and freed */ -void il4965_rx_queue_free(struct il_priv *priv, struct il_rx_queue *rxq) +void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq) { int i; for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { if (rxq->pool[i].page != NULL) { - pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, - PAGE_SIZE << priv->hw_params.rx_page_order, + pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, + PAGE_SIZE << il->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); - __il_free_pages(priv, rxq->pool[i].page); + __il_free_pages(il, rxq->pool[i].page); rxq->pool[i].page = NULL; } } - dma_free_coherent(&priv->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, + dma_free_coherent(&il->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, rxq->bd_dma); - dma_free_coherent(&priv->pci_dev->dev, sizeof(struct il_rb_status), + dma_free_coherent(&il->pci_dev->dev, sizeof(struct il_rb_status), rxq->rb_stts, rxq->rb_stts_dma); rxq->bd = NULL; rxq->rb_stts = NULL; } -int il4965_rxq_stop(struct il_priv *priv) +int il4965_rxq_stop(struct il_priv *il) { /* stop Rx DMA */ - il_write_direct32(priv, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); - il_poll_direct_bit(priv, FH_MEM_RSSR_RX_STATUS_REG, + il_write_direct32(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); + il_poll_direct_bit(il, FH_MEM_RSSR_RX_STATUS_REG, FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); return 0; @@ -431,7 +431,7 @@ int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) return -1; } -static int il4965_calc_rssi(struct il_priv *priv, +static int il4965_calc_rssi(struct il_priv *il, struct il_rx_phy_res *rx_resp) { /* data from PHY/DSP regarding signal strength, etc., @@ -456,7 +456,7 @@ static int il4965_calc_rssi(struct il_priv *priv, if (valid_antennae & (1 << i)) max_rssi = max(ncphy->rssi_info[i << 1], max_rssi); - IL_DEBUG_STATS(priv, "Rssi In A %d B %d C %d Max %d AGC dB %d\n", + IL_DEBUG_STATS(il, "Rssi In A %d B %d C %d Max %d AGC dB %d\n", ncphy->rssi_info[0], ncphy->rssi_info[2], ncphy->rssi_info[4], max_rssi, agc); @@ -466,7 +466,7 @@ static int il4965_calc_rssi(struct il_priv *priv, } -static u32 il4965_translate_rx_status(struct il_priv *priv, u32 decrypt_in) +static u32 il4965_translate_rx_status(struct il_priv *il, u32 decrypt_in) { u32 decrypt_out = 0; @@ -519,13 +519,13 @@ static u32 il4965_translate_rx_status(struct il_priv *priv, u32 decrypt_in) break; } - IL_DEBUG_RX(priv, "decrypt_in:0x%x decrypt_out = 0x%x\n", + IL_DEBUG_RX(il, "decrypt_in:0x%x decrypt_out = 0x%x\n", decrypt_in, decrypt_out); return decrypt_out; } -static void il4965_pass_packet_to_mac80211(struct il_priv *priv, +static void il4965_pass_packet_to_mac80211(struct il_priv *il, struct ieee80211_hdr *hdr, u16 len, u32 ampdu_status, @@ -536,36 +536,36 @@ static void il4965_pass_packet_to_mac80211(struct il_priv *priv, __le16 fc = hdr->frame_control; /* We only process data packets if the interface is open */ - if (unlikely(!priv->is_open)) { - IL_DEBUG_DROP_LIMIT(priv, + if (unlikely(!il->is_open)) { + IL_DEBUG_DROP_LIMIT(il, "Dropping packet while interface is not open.\n"); return; } /* In case of HW accelerated crypto and bad decryption, drop */ - if (!priv->cfg->mod_params->sw_crypto && - il_set_decrypted_flag(priv, hdr, ampdu_status, stats)) + if (!il->cfg->mod_params->sw_crypto && + il_set_decrypted_flag(il, hdr, ampdu_status, stats)) return; skb = dev_alloc_skb(128); if (!skb) { - IL_ERR(priv, "dev_alloc_skb failed\n"); + IL_ERR(il, "dev_alloc_skb failed\n"); return; } skb_add_rx_frag(skb, 0, rxb->page, (void *)hdr - rxb_addr(rxb), len); - il_update_stats(priv, false, fc, len); + il_update_stats(il, false, fc, len); memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats)); - ieee80211_rx(priv->hw, skb); - priv->alloc_rxb_page--; + ieee80211_rx(il->hw, skb); + il->alloc_rxb_page--; rxb->page = NULL; } /* Called for REPLY_RX (legacy ABG frames), or * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */ -void il4965_rx_reply_rx(struct il_priv *priv, +void il4965_rx_reply_rx(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct ieee80211_hdr *header; @@ -582,7 +582,7 @@ void il4965_rx_reply_rx(struct il_priv *priv, * REPLY_RX and REPLY_RX_MPDU_CMD are handled differently. * REPLY_RX: physical layer info is in this buffer * REPLY_RX_MPDU_CMD: physical layer info was sent in separate - * command and cached in priv->last_phy_res + * command and cached in il->last_phy_res * * Here we set up local variables depending on which command is * received. @@ -597,28 +597,28 @@ void il4965_rx_reply_rx(struct il_priv *priv, phy_res->cfg_phy_cnt + len); ampdu_status = le32_to_cpu(rx_pkt_status); } else { - if (!priv->_4965.last_phy_res_valid) { - IL_ERR(priv, "MPDU frame without cached PHY data\n"); + if (!il->_4965.last_phy_res_valid) { + IL_ERR(il, "MPDU frame without cached PHY data\n"); return; } - phy_res = &priv->_4965.last_phy_res; + phy_res = &il->_4965.last_phy_res; amsdu = (struct il_rx_mpdu_res_start *)pkt->u.raw; header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*amsdu)); len = le16_to_cpu(amsdu->byte_count); rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*amsdu) + len); - ampdu_status = il4965_translate_rx_status(priv, + ampdu_status = il4965_translate_rx_status(il, le32_to_cpu(rx_pkt_status)); } if ((unlikely(phy_res->cfg_phy_cnt > 20))) { - IL_DEBUG_DROP(priv, "dsp size out of range [0,20]: %d/n", + IL_DEBUG_DROP(il, "dsp size out of range [0,20]: %d/n", phy_res->cfg_phy_cnt); return; } if (!(rx_pkt_status & RX_RES_STATUS_NO_CRC32_ERROR) || !(rx_pkt_status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { - IL_DEBUG_RX(priv, "Bad CRC or FIFO: 0x%08X.\n", + IL_DEBUG_RX(il, "Bad CRC or FIFO: 0x%08X.\n", le32_to_cpu(rx_pkt_status)); return; } @@ -641,13 +641,13 @@ void il4965_rx_reply_rx(struct il_priv *priv, * this W/A doesn't propagate it to the mac80211 */ /*rx_status.flag |= RX_FLAG_MACTIME_MPDU;*/ - priv->ucode_beacon_time = le32_to_cpu(phy_res->beacon_time_stamp); + il->ucode_beacon_time = le32_to_cpu(phy_res->beacon_time_stamp); /* Find max signal strength (dBm) among 3 antenna/receiver chains */ - rx_status.signal = il4965_calc_rssi(priv, phy_res); + rx_status.signal = il4965_calc_rssi(il, phy_res); - il_dbg_log_rx_data_frame(priv, len, header); - IL_DEBUG_STATS_LIMIT(priv, "Rssi %d, TSF %llu\n", + il_dbg_log_rx_data_frame(il, len, header); + IL_DEBUG_STATS_LIMIT(il, "Rssi %d, TSF %llu\n", rx_status.signal, (unsigned long long)rx_status.mactime); /* @@ -679,22 +679,22 @@ void il4965_rx_reply_rx(struct il_priv *priv, if (rate_n_flags & RATE_MCS_SGI_MSK) rx_status.flag |= RX_FLAG_SHORT_GI; - il4965_pass_packet_to_mac80211(priv, header, len, ampdu_status, + il4965_pass_packet_to_mac80211(il, header, len, ampdu_status, rxb, &rx_status); } /* Cache phy data (Rx signal strength, etc) for HT frame (REPLY_RX_PHY_CMD). * This will be used later in il_rx_reply_rx() for REPLY_RX_MPDU_CMD. */ -void il4965_rx_reply_rx_phy(struct il_priv *priv, +void il4965_rx_reply_rx_phy(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); - priv->_4965.last_phy_res_valid = true; - memcpy(&priv->_4965.last_phy_res, pkt->u.raw, + il->_4965.last_phy_res_valid = true; + memcpy(&il->_4965.last_phy_res, pkt->u.raw, sizeof(struct il_rx_phy_res)); } -static int il4965_get_channels_for_scan(struct il_priv *priv, +static int il4965_get_channels_for_scan(struct il_priv *il, struct ieee80211_vif *vif, enum ieee80211_band band, u8 is_active, u8 n_probes, @@ -708,18 +708,18 @@ static int il4965_get_channels_for_scan(struct il_priv *priv, int added, i; u16 channel; - sband = il_get_hw_mode(priv, band); + sband = il_get_hw_mode(il, band); if (!sband) return 0; - active_dwell = il_get_active_dwell_time(priv, band, n_probes); - passive_dwell = il_get_passive_dwell_time(priv, band, vif); + active_dwell = il_get_active_dwell_time(il, band, n_probes); + passive_dwell = il_get_passive_dwell_time(il, band, vif); if (passive_dwell <= active_dwell) passive_dwell = active_dwell + 1; - for (i = 0, added = 0; i < priv->scan_request->n_channels; i++) { - chan = priv->scan_request->channels[i]; + for (i = 0, added = 0; i < il->scan_request->n_channels; i++) { + chan = il->scan_request->channels[i]; if (chan->band != band) continue; @@ -727,9 +727,9 @@ static int il4965_get_channels_for_scan(struct il_priv *priv, channel = chan->hw_value; scan_ch->channel = cpu_to_le16(channel); - ch_info = il_get_channel_info(priv, band, channel); + ch_info = il_get_channel_info(il, band, channel); if (!il_is_channel_valid(ch_info)) { - IL_DEBUG_SCAN(priv, + IL_DEBUG_SCAN(il, "Channel %d is INVALID for this band.\n", channel); continue; @@ -759,7 +759,7 @@ static int il4965_get_channels_for_scan(struct il_priv *priv, else scan_ch->tx_gain = ((1 << 5) | (5 << 3)); - IL_DEBUG_SCAN(priv, "Scanning ch=%d prob=0x%X [%s %d]\n", + IL_DEBUG_SCAN(il, "Scanning ch=%d prob=0x%X [%s %d]\n", channel, le32_to_cpu(scan_ch->type), (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ? "ACTIVE" : "PASSIVE", @@ -770,11 +770,11 @@ static int il4965_get_channels_for_scan(struct il_priv *priv, added++; } - IL_DEBUG_SCAN(priv, "total channels to scan %d\n", added); + IL_DEBUG_SCAN(il, "total channels to scan %d\n", added); return added; } -int il4965_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) +int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) { struct il_host_cmd cmd = { .id = REPLY_SCAN_CMD, @@ -782,47 +782,47 @@ int il4965_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) .flags = CMD_SIZE_HUGE, }; struct il_scan_cmd *scan; - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; u32 rate_flags = 0; u16 cmd_len; u16 rx_chain = 0; enum ieee80211_band band; u8 n_probes = 0; - u8 rx_ant = priv->hw_params.valid_rx_ant; + u8 rx_ant = il->hw_params.valid_rx_ant; u8 rate; bool is_active = false; int chan_mod; u8 active_chains; - u8 scan_tx_antennas = priv->hw_params.valid_tx_ant; + u8 scan_tx_antennas = il->hw_params.valid_tx_ant; int ret; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); if (vif) ctx = il_rxon_ctx_from_vif(vif); - if (!priv->scan_cmd) { - priv->scan_cmd = kmalloc(sizeof(struct il_scan_cmd) + + if (!il->scan_cmd) { + il->scan_cmd = kmalloc(sizeof(struct il_scan_cmd) + IL_MAX_SCAN_SIZE, GFP_KERNEL); - if (!priv->scan_cmd) { - IL_DEBUG_SCAN(priv, + if (!il->scan_cmd) { + IL_DEBUG_SCAN(il, "fail to allocate memory for scan\n"); return -ENOMEM; } } - scan = priv->scan_cmd; + scan = il->scan_cmd; memset(scan, 0, sizeof(struct il_scan_cmd) + IL_MAX_SCAN_SIZE); scan->quiet_plcp_th = IL_PLCP_QUIET_THRESH; scan->quiet_time = IL_ACTIVE_QUIET_TIME; - if (il_is_any_associated(priv)) { + if (il_is_any_associated(il)) { u16 interval; u32 extra; u32 suspend_time = 100; u32 scan_suspend_time = 100; - IL_DEBUG_INFO(priv, "Scanning while associated...\n"); + IL_DEBUG_INFO(il, "Scanning while associated...\n"); interval = vif->bss_conf.beacon_int; scan->suspend_time = 0; @@ -834,39 +834,39 @@ int il4965_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) scan_suspend_time = (extra | ((suspend_time % interval) * 1024)); scan->suspend_time = cpu_to_le32(scan_suspend_time); - IL_DEBUG_SCAN(priv, "suspend_time 0x%X beacon interval %d\n", + IL_DEBUG_SCAN(il, "suspend_time 0x%X beacon interval %d\n", scan_suspend_time, interval); } - if (priv->scan_request->n_ssids) { + if (il->scan_request->n_ssids) { int i, p = 0; - IL_DEBUG_SCAN(priv, "Kicking off active scan\n"); - for (i = 0; i < priv->scan_request->n_ssids; i++) { + IL_DEBUG_SCAN(il, "Kicking off active scan\n"); + for (i = 0; i < il->scan_request->n_ssids; i++) { /* always does wildcard anyway */ - if (!priv->scan_request->ssids[i].ssid_len) + if (!il->scan_request->ssids[i].ssid_len) continue; scan->direct_scan[p].id = WLAN_EID_SSID; scan->direct_scan[p].len = - priv->scan_request->ssids[i].ssid_len; + il->scan_request->ssids[i].ssid_len; memcpy(scan->direct_scan[p].ssid, - priv->scan_request->ssids[i].ssid, - priv->scan_request->ssids[i].ssid_len); + il->scan_request->ssids[i].ssid, + il->scan_request->ssids[i].ssid_len); n_probes++; p++; } is_active = true; } else - IL_DEBUG_SCAN(priv, "Start passive scan.\n"); + IL_DEBUG_SCAN(il, "Start passive scan.\n"); scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; scan->tx_cmd.sta_id = ctx->bcast_sta_id; scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; - switch (priv->scan_band) { + switch (il->scan_band) { case IEEE80211_BAND_2GHZ: scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; chan_mod = le32_to_cpu( - priv->contexts[IL_RXON_CTX_BSS].active.flags & + il->contexts[IL_RXON_CTX_BSS].active.flags & RXON_FLG_CHANNEL_MODE_MSK) >> RXON_FLG_CHANNEL_MODE_POS; if (chan_mod == CHANNEL_MODE_PURE_40) { @@ -880,7 +880,7 @@ int il4965_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) rate = IL_RATE_6M_PLCP; break; default: - IL_WARN(priv, "Invalid scan band\n"); + IL_WARN(il, "Invalid scan band\n"); return -EIO; } @@ -904,54 +904,54 @@ int il4965_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) scan->good_CRC_th = is_active ? IL_GOOD_CRC_TH_DEFAULT : IL_GOOD_CRC_TH_NEVER; - band = priv->scan_band; + band = il->scan_band; - if (priv->cfg->scan_rx_antennas[band]) - rx_ant = priv->cfg->scan_rx_antennas[band]; + if (il->cfg->scan_rx_antennas[band]) + rx_ant = il->cfg->scan_rx_antennas[band]; - priv->scan_tx_ant[band] = il4965_toggle_tx_ant(priv, - priv->scan_tx_ant[band], + il->scan_tx_ant[band] = il4965_toggle_tx_ant(il, + il->scan_tx_ant[band], scan_tx_antennas); - rate_flags |= il4965_ant_idx_to_flags(priv->scan_tx_ant[band]); + rate_flags |= il4965_ant_idx_to_flags(il->scan_tx_ant[band]); scan->tx_cmd.rate_n_flags = il4965_hw_set_rate_n_flags(rate, rate_flags); /* In power save mode use one chain, otherwise use all chains */ - if (test_bit(STATUS_POWER_PMI, &priv->status)) { + if (test_bit(STATUS_POWER_PMI, &il->status)) { /* rx_ant has been set to all valid chains previously */ active_chains = rx_ant & - ((u8)(priv->chain_noise_data.active_chains)); + ((u8)(il->chain_noise_data.active_chains)); if (!active_chains) active_chains = rx_ant; - IL_DEBUG_SCAN(priv, "chain_noise_data.active_chains: %u\n", - priv->chain_noise_data.active_chains); + IL_DEBUG_SCAN(il, "chain_noise_data.active_chains: %u\n", + il->chain_noise_data.active_chains); rx_ant = il4965_first_antenna(active_chains); } /* MIMO is not used here, but value is required */ - rx_chain |= priv->hw_params.valid_rx_ant << RXON_RX_CHAIN_VALID_POS; + rx_chain |= il->hw_params.valid_rx_ant << RXON_RX_CHAIN_VALID_POS; rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS; rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_SEL_POS; rx_chain |= 0x1 << RXON_RX_CHAIN_DRIVER_FORCE_POS; scan->rx_chain = cpu_to_le16(rx_chain); - cmd_len = il_fill_probe_req(priv, + cmd_len = il_fill_probe_req(il, (struct ieee80211_mgmt *)scan->data, vif->addr, - priv->scan_request->ie, - priv->scan_request->ie_len, + il->scan_request->ie, + il->scan_request->ie_len, IL_MAX_SCAN_SIZE - sizeof(*scan)); scan->tx_cmd.len = cpu_to_le16(cmd_len); scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK | RXON_FILTER_BCON_AWARE_MSK); - scan->channel_count = il4965_get_channels_for_scan(priv, vif, band, + scan->channel_count = il4965_get_channels_for_scan(il, vif, band, is_active, n_probes, (void *)&scan->data[cmd_len]); if (scan->channel_count == 0) { - IL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count); + IL_DEBUG_SCAN(il, "channel count %d\n", scan->channel_count); return -EIO; } @@ -960,49 +960,49 @@ int il4965_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) cmd.data = scan; scan->len = cpu_to_le16(cmd.len); - set_bit(STATUS_SCAN_HW, &priv->status); + set_bit(STATUS_SCAN_HW, &il->status); - ret = il_send_cmd_sync(priv, &cmd); + ret = il_send_cmd_sync(il, &cmd); if (ret) - clear_bit(STATUS_SCAN_HW, &priv->status); + clear_bit(STATUS_SCAN_HW, &il->status); return ret; } -int il4965_manage_ibss_station(struct il_priv *priv, +int il4965_manage_ibss_station(struct il_priv *il, struct ieee80211_vif *vif, bool add) { struct il_vif_priv *vif_priv = (void *)vif->drv_priv; if (add) - return il4965_add_bssid_station(priv, vif_priv->ctx, + return il4965_add_bssid_station(il, vif_priv->ctx, vif->bss_conf.bssid, &vif_priv->ibss_bssid_sta_id); - return il_remove_station(priv, vif_priv->ibss_bssid_sta_id, + return il_remove_station(il, vif_priv->ibss_bssid_sta_id, vif->bss_conf.bssid); } -void il4965_free_tfds_in_queue(struct il_priv *priv, +void il4965_free_tfds_in_queue(struct il_priv *il, int sta_id, int tid, int freed) { - lockdep_assert_held(&priv->sta_lock); + lockdep_assert_held(&il->sta_lock); - if (priv->stations[sta_id].tid[tid].tfds_in_queue >= freed) - priv->stations[sta_id].tid[tid].tfds_in_queue -= freed; + if (il->stations[sta_id].tid[tid].tfds_in_queue >= freed) + il->stations[sta_id].tid[tid].tfds_in_queue -= freed; else { - IL_DEBUG_TX(priv, "free more than tfds_in_queue (%u:%d)\n", - priv->stations[sta_id].tid[tid].tfds_in_queue, + IL_DEBUG_TX(il, "free more than tfds_in_queue (%u:%d)\n", + il->stations[sta_id].tid[tid].tfds_in_queue, freed); - priv->stations[sta_id].tid[tid].tfds_in_queue = 0; + il->stations[sta_id].tid[tid].tfds_in_queue = 0; } } #define IL_TX_QUEUE_MSK 0xfffff -static bool il4965_is_single_rx_stream(struct il_priv *priv) +static bool il4965_is_single_rx_stream(struct il_priv *il) { - return priv->current_ht_config.smps == IEEE80211_SMPS_STATIC || - priv->current_ht_config.single_chain_sufficient; + return il->current_ht_config.smps == IEEE80211_SMPS_STATIC || + il->current_ht_config.single_chain_sufficient; } #define IL_NUM_RX_CHAINS_MULTIPLE 3 @@ -1020,10 +1020,10 @@ static bool il4965_is_single_rx_stream(struct il_priv *priv) * MIMO (dual stream) requires at least 2, but works better with 3. * This does not determine *which* chains to use, just how many. */ -static int il4965_get_active_rx_chain_count(struct il_priv *priv) +static int il4965_get_active_rx_chain_count(struct il_priv *il) { /* # of Rx chains to use when expecting MIMO. */ - if (il4965_is_single_rx_stream(priv)) + if (il4965_is_single_rx_stream(il)) return IL_NUM_RX_CHAINS_SINGLE; else return IL_NUM_RX_CHAINS_MULTIPLE; @@ -1034,10 +1034,10 @@ static int il4965_get_active_rx_chain_count(struct il_priv *priv) * multiplexing power save, use the active count for rx chain count. */ static int -il4965_get_idle_rx_chain_count(struct il_priv *priv, int active_cnt) +il4965_get_idle_rx_chain_count(struct il_priv *il, int active_cnt) { /* # Rx chains when idling, depending on SMPS mode */ - switch (priv->current_ht_config.smps) { + switch (il->current_ht_config.smps) { case IEEE80211_SMPS_STATIC: case IEEE80211_SMPS_DYNAMIC: return IL_NUM_IDLE_CHAINS_SINGLE; @@ -1045,7 +1045,7 @@ il4965_get_idle_rx_chain_count(struct il_priv *priv, int active_cnt) return active_cnt; default: WARN(1, "invalid SMPS mode %d", - priv->current_ht_config.smps); + il->current_ht_config.smps); return active_cnt; } } @@ -1067,10 +1067,10 @@ static u8 il4965_count_chain_bitmap(u32 chain_bitmap) * Selects how many and which Rx receivers/antennas/chains to use. * This should not be used for scan command ... it puts data in wrong place. */ -void il4965_set_rxon_chain(struct il_priv *priv, struct il_rxon_context *ctx) +void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx) { - bool is_single = il4965_is_single_rx_stream(priv); - bool is_cam = !test_bit(STATUS_POWER_PMI, &priv->status); + bool is_single = il4965_is_single_rx_stream(il); + bool is_cam = !test_bit(STATUS_POWER_PMI, &il->status); u8 idle_rx_cnt, active_rx_cnt, valid_rx_cnt; u32 active_chains; u16 rx_chain; @@ -1079,16 +1079,16 @@ void il4965_set_rxon_chain(struct il_priv *priv, struct il_rxon_context *ctx) * Before first association, we assume all antennas are connected. * Just after first association, il4965_chain_noise_calibration() * checks which antennas actually *are* connected. */ - if (priv->chain_noise_data.active_chains) - active_chains = priv->chain_noise_data.active_chains; + if (il->chain_noise_data.active_chains) + active_chains = il->chain_noise_data.active_chains; else - active_chains = priv->hw_params.valid_rx_ant; + active_chains = il->hw_params.valid_rx_ant; rx_chain = active_chains << RXON_RX_CHAIN_VALID_POS; /* How many receivers should we use? */ - active_rx_cnt = il4965_get_active_rx_chain_count(priv); - idle_rx_cnt = il4965_get_idle_rx_chain_count(priv, active_rx_cnt); + active_rx_cnt = il4965_get_active_rx_chain_count(il); + idle_rx_cnt = il4965_get_idle_rx_chain_count(il, active_rx_cnt); /* correct rx chain count according hw settings @@ -1111,7 +1111,7 @@ void il4965_set_rxon_chain(struct il_priv *priv, struct il_rxon_context *ctx) else ctx->staging.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK; - IL_DEBUG_ASSOC(priv, "rx_chain=0x%X active=%d idle=%d\n", + IL_DEBUG_ASSOC(il, "rx_chain=0x%X active=%d idle=%d\n", ctx->staging.rx_chain, active_rx_cnt, idle_rx_cnt); @@ -1119,7 +1119,7 @@ void il4965_set_rxon_chain(struct il_priv *priv, struct il_rxon_context *ctx) active_rx_cnt < idle_rx_cnt); } -u8 il4965_toggle_tx_ant(struct il_priv *priv, u8 ant, u8 valid) +u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant, u8 valid) { int i; u8 ind = ant; @@ -1149,7 +1149,7 @@ static const char *il4965_get_fh_string(int cmd) } } -int il4965_dump_fh(struct il_priv *priv, char **buf, bool display) +int il4965_dump_fh(struct il_priv *il, char **buf, bool display) { int i; #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG @@ -1179,16 +1179,16 @@ int il4965_dump_fh(struct il_priv *priv, char **buf, bool display) pos += scnprintf(*buf + pos, bufsz - pos, " %34s: 0X%08x\n", il4965_get_fh_string(fh_tbl[i]), - il_read_direct32(priv, fh_tbl[i])); + il_read_direct32(il, fh_tbl[i])); } return pos; } #endif - IL_ERR(priv, "FH register values:\n"); + IL_ERR(il, "FH register values:\n"); for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { - IL_ERR(priv, " %34s: 0X%08x\n", + IL_ERR(il, " %34s: 0X%08x\n", il4965_get_fh_string(fh_tbl[i]), - il_read_direct32(priv, fh_tbl[i])); + il_read_direct32(il, fh_tbl[i])); } return 0; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index a7298f5997a2..e53ed1a5d5db 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -140,11 +140,11 @@ static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags) return -1; } -static void il4965_rs_rate_scale_perform(struct il_priv *priv, +static void il4965_rs_rate_scale_perform(struct il_priv *il, struct sk_buff *skb, struct ieee80211_sta *sta, struct il_lq_sta *lq_sta); -static void il4965_rs_fill_link_cmd(struct il_priv *priv, +static void il4965_rs_fill_link_cmd(struct il_priv *il, struct il_lq_sta *lq_sta, u32 rate_n_flags); static void il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search); @@ -348,7 +348,7 @@ static u32 il4965_rs_tl_get_load(struct il_lq_sta *lq_data, u8 tid) return tl->total; } -static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *priv, +static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *il, struct il_lq_sta *lq_data, u8 tid, struct ieee80211_sta *sta) { @@ -358,7 +358,7 @@ static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *priv, load = il4965_rs_tl_get_load(lq_data, tid); if (load > IL_AGG_LOAD_THRESHOLD) { - IL_DEBUG_HT(priv, "Starting Tx agg: STA: %pM tid: %d\n", + IL_DEBUG_HT(il, "Starting Tx agg: STA: %pM tid: %d\n", sta->addr, tid); ret = ieee80211_start_tx_ba_session(sta, tid, 5000); if (ret == -EAGAIN) { @@ -367,25 +367,25 @@ static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *priv, * this might be cause by reloading firmware * stop the tx ba session here */ - IL_ERR(priv, "Fail start Tx agg on tid: %d\n", + IL_ERR(il, "Fail start Tx agg on tid: %d\n", tid); ieee80211_stop_tx_ba_session(sta, tid); } } else { - IL_ERR(priv, "Aggregation not enabled for tid %d " + IL_ERR(il, "Aggregation not enabled for tid %d " "because load = %u\n", tid, load); } return ret; } -static void il4965_rs_tl_turn_on_agg(struct il_priv *priv, u8 tid, +static void il4965_rs_tl_turn_on_agg(struct il_priv *il, u8 tid, struct il_lq_sta *lq_data, struct ieee80211_sta *sta) { if (tid < TID_MAX_LOAD_COUNT) - il4965_rs_tl_turn_on_agg_for_tid(priv, lq_data, tid, sta); + il4965_rs_tl_turn_on_agg_for_tid(il, lq_data, tid, sta); else - IL_ERR(priv, "tid exceeds max load count: %d/%d\n", + IL_ERR(il, "tid exceeds max load count: %d/%d\n", tid, TID_MAX_LOAD_COUNT); } @@ -492,7 +492,7 @@ static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, /* * Fill uCode API rate_n_flags field, based on "search" or "active" table. */ -static u32 il4965_rate_n_flags_from_tbl(struct il_priv *priv, +static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, struct il_scale_tbl_info *tbl, int index, u8 use_green) { @@ -505,7 +505,7 @@ static u32 il4965_rate_n_flags_from_tbl(struct il_priv *priv, } else if (is_Ht(tbl->lq_type)) { if (index > IL_LAST_OFDM_RATE) { - IL_ERR(priv, "Invalid HT rate index %d\n", index); + IL_ERR(il, "Invalid HT rate index %d\n", index); index = IL_LAST_OFDM_RATE; } rate_n_flags = RATE_MCS_HT_MSK; @@ -515,7 +515,7 @@ static u32 il4965_rate_n_flags_from_tbl(struct il_priv *priv, else rate_n_flags |= iwlegacy_rates[index].plcp_mimo2; } else { - IL_ERR(priv, "Invalid tbl->lq_type %d\n", tbl->lq_type); + IL_ERR(il, "Invalid tbl->lq_type %d\n", tbl->lq_type); } rate_n_flags |= ((tbl->ant_type << RATE_MCS_ANT_POS) & @@ -535,7 +535,7 @@ static u32 il4965_rate_n_flags_from_tbl(struct il_priv *priv, rate_n_flags |= RATE_MCS_GF_MSK; if (is_siso(tbl->lq_type) && tbl->is_SGI) { rate_n_flags &= ~RATE_MCS_SGI_MSK; - IL_ERR(priv, "GF was set with SGI:SISO\n"); + IL_ERR(il, "GF was set with SGI:SISO\n"); } } } @@ -667,7 +667,7 @@ static u16 il4965_rs_get_supported_rates(struct il_lq_sta *lq_sta, } static u16 -il4965_rs_get_adjacent_rate(struct il_priv *priv, u8 index, u16 rate_mask, +il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, int rate_type) { u8 high = IL_RATE_INVALID; @@ -707,7 +707,7 @@ il4965_rs_get_adjacent_rate(struct il_priv *priv, u8 index, u16 rate_mask, break; if (rate_mask & (1 << low)) break; - IL_DEBUG_RATE(priv, "Skipping masked lower rate: %d\n", low); + IL_DEBUG_RATE(il, "Skipping masked lower rate: %d\n", low); } high = index; @@ -717,7 +717,7 @@ il4965_rs_get_adjacent_rate(struct il_priv *priv, u8 index, u16 rate_mask, break; if (rate_mask & (1 << high)) break; - IL_DEBUG_RATE(priv, "Skipping masked higher rate: %d\n", high); + IL_DEBUG_RATE(il, "Skipping masked higher rate: %d\n", high); } return (high << 8) | low; @@ -732,7 +732,7 @@ static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, u16 high_low; u8 switch_to_legacy = 0; u8 is_green = lq_sta->is_green; - struct il_priv *priv = lq_sta->drv; + struct il_priv *il = lq_sta->drv; /* check if we need to switch from HT to legacy rates. * assumption is that mandatory rates (1Mbps or 6Mbps) @@ -747,7 +747,7 @@ static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, if (il4965_num_of_ant(tbl->ant_type) > 1) tbl->ant_type = - il4965_first_antenna(priv->hw_params.valid_tx_ant); + il4965_first_antenna(il->hw_params.valid_tx_ant); tbl->is_ht40 = 0; tbl->is_SGI = 0; @@ -798,17 +798,17 @@ static bool il4965_table_type_matches(struct il_scale_tbl_info *a, * mac80211 sends us Tx status */ static void -il4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, void *priv_sta, +il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, + struct ieee80211_sta *sta, void *il_sta, struct sk_buff *skb) { int legacy_success; int retries; int rs_index, mac_index, i; - struct il_lq_sta *lq_sta = priv_sta; + struct il_lq_sta *lq_sta = il_sta; struct il_link_quality_cmd *table; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - struct il_priv *priv = (struct il_priv *)priv_r; + struct il_priv *il = (struct il_priv *)il_r; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); enum mac80211_rate_control_flags mac_flags; u32 tx_rate; @@ -817,15 +817,15 @@ il4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, struct il_station_priv *sta_priv = (void *)sta->drv_priv; struct il_rxon_context *ctx = sta_priv->common.ctx; - IL_DEBUG_RATE_LIMIT(priv, + IL_DEBUG_RATE_LIMIT(il, "get frame ack response, update rate scale window\n"); /* Treat uninitialized rate scaling data same as non-existing. */ if (!lq_sta) { - IL_DEBUG_RATE(priv, "Station rate scaling not created yet.\n"); + IL_DEBUG_RATE(il, "Station rate scaling not created yet.\n"); return; } else if (!lq_sta->drv) { - IL_DEBUG_RATE(priv, "Rate scaling not initialized yet.\n"); + IL_DEBUG_RATE(il, "Rate scaling not initialized yet.\n"); return; } @@ -849,8 +849,8 @@ il4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, table = &lq_sta->lq; tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); il4965_rs_get_tbl_info_from_mcs(tx_rate, - priv->band, &tbl_type, &rs_index); - if (priv->band == IEEE80211_BAND_5GHZ) + il->band, &tbl_type, &rs_index); + if (il->band == IEEE80211_BAND_5GHZ) rs_index -= IL_FIRST_OFDM_RATE; mac_flags = info->status.rates[0].flags; mac_index = info->status.rates[0].idx; @@ -863,7 +863,7 @@ il4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, * mac80211 HT index is always zero-indexed; we need to move * HT OFDM rates after CCK rates in 2.4 GHz band */ - if (priv->band == IEEE80211_BAND_2GHZ) + if (il->band == IEEE80211_BAND_2GHZ) mac_index += IL_FIRST_OFDM_RATE; } /* Here we actually compare this rate to the latest LQ command */ @@ -880,7 +880,7 @@ il4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, (!!(tx_rate & RATE_MCS_GF_MSK) != !!(mac_flags & IEEE80211_TX_RC_GREEN_FIELD)) || (rs_index != mac_index)) { - IL_DEBUG_RATE(priv, + IL_DEBUG_RATE(il, "initial rate %d does not match %d (0x%x)\n", mac_index, rs_index, tx_rate); /* @@ -891,7 +891,7 @@ il4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, lq_sta->missed_rate_counter++; if (lq_sta->missed_rate_counter > IL_MISSED_RATE_MAX) { lq_sta->missed_rate_counter = 0; - il_send_lq_cmd(priv, ctx, &lq_sta->lq, + il_send_lq_cmd(il, ctx, &lq_sta->lq, CMD_ASYNC, false); } /* Regardless, ignore this status info for outdated rate */ @@ -910,15 +910,15 @@ il4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, curr_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); other_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); } else { - IL_DEBUG_RATE(priv, + IL_DEBUG_RATE(il, "Neither active nor search matches tx rate\n"); tmp_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - IL_DEBUG_RATE(priv, "active- lq:%x, ant:%x, SGI:%d\n", + IL_DEBUG_RATE(il, "active- lq:%x, ant:%x, SGI:%d\n", tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); tmp_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); - IL_DEBUG_RATE(priv, "search- lq:%x, ant:%x, SGI:%d\n", + IL_DEBUG_RATE(il, "search- lq:%x, ant:%x, SGI:%d\n", tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); - IL_DEBUG_RATE(priv, "actual- lq:%x, ant:%x, SGI:%d\n", + IL_DEBUG_RATE(il, "actual- lq:%x, ant:%x, SGI:%d\n", tbl_type.lq_type, tbl_type.ant_type, tbl_type.is_SGI); /* * no matching table found, let's by-pass the data collection @@ -937,7 +937,7 @@ il4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, */ if (info->flags & IEEE80211_TX_STAT_AMPDU) { tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); - il4965_rs_get_tbl_info_from_mcs(tx_rate, priv->band, &tbl_type, + il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, &tbl_type, &rs_index); il4965_rs_collect_tx_data(curr_tbl, rs_index, info->status.ampdu_len, @@ -962,7 +962,7 @@ il4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, /* Collect data for each rate used during failed TX attempts */ for (i = 0; i <= retries; ++i) { tx_rate = le32_to_cpu(table->rs_table[i].rate_n_flags); - il4965_rs_get_tbl_info_from_mcs(tx_rate, priv->band, + il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, &tbl_type, &rs_index); /* * Only collect stats if retried rate is in the same RS @@ -990,7 +990,7 @@ il4965_rs_tx_status(void *priv_r, struct ieee80211_supported_band *sband, done: /* See if there's a better rate or modulation mode to try. */ if (sta && sta->supp_rates[sband->band]) - il4965_rs_rate_scale_perform(priv, skb, sta, lq_sta); + il4965_rs_rate_scale_perform(il, skb, sta, lq_sta); } /* @@ -1001,10 +1001,10 @@ done: * These control how long we stay using same modulation mode before * searching for a new mode. */ -static void il4965_rs_set_stay_in_table(struct il_priv *priv, u8 is_legacy, +static void il4965_rs_set_stay_in_table(struct il_priv *il, u8 is_legacy, struct il_lq_sta *lq_sta) { - IL_DEBUG_RATE(priv, "we are staying in the same table\n"); + IL_DEBUG_RATE(il, "we are staying in the same table\n"); lq_sta->stay_in_tbl = 1; /* only place this gets set */ if (is_legacy) { lq_sta->table_count_limit = IL_LEGACY_TABLE_COUNT; @@ -1077,7 +1077,7 @@ static void il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, * to decrease to match "active" throughput. When moving from MIMO to SISO, * bit rate will typically need to increase, but not if performance was bad. */ -static s32 il4965_rs_get_best_rate(struct il_priv *priv, +static s32 il4965_rs_get_best_rate(struct il_priv *il, struct il_lq_sta *lq_sta, struct il_scale_tbl_info *tbl, /* "search" */ u16 rate_mask, s8 index) @@ -1098,7 +1098,7 @@ static s32 il4965_rs_get_best_rate(struct il_priv *priv, new_rate = high = low = start_hi = IL_RATE_INVALID; for (; ;) { - high_low = il4965_rs_get_adjacent_rate(priv, rate, rate_mask, + high_low = il4965_rs_get_adjacent_rate(il, rate, rate_mask, tbl->lq_type); low = high_low & 0xff; @@ -1171,7 +1171,7 @@ static s32 il4965_rs_get_best_rate(struct il_priv *priv, /* * Set up search table for MIMO2 */ -static int il4965_rs_switch_to_mimo2(struct il_priv *priv, +static int il4965_rs_switch_to_mimo2(struct il_priv *il, struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, @@ -1191,10 +1191,10 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *priv, return -1; /* Need both Tx chains/antennas to support MIMO */ - if (priv->hw_params.tx_chains_num < 2) + if (il->hw_params.tx_chains_num < 2) return -1; - IL_DEBUG_RATE(priv, "LQ: try to switch to MIMO2\n"); + IL_DEBUG_RATE(il, "LQ: try to switch to MIMO2\n"); tbl->lq_type = LQ_MIMO2; tbl->is_dup = lq_sta->is_dup; @@ -1202,27 +1202,27 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *priv, tbl->max_search = IL_MAX_SEARCH; rate_mask = lq_sta->active_mimo2_rate; - if (il_is_ht40_tx_allowed(priv, ctx, &sta->ht_cap)) + if (il_is_ht40_tx_allowed(il, ctx, &sta->ht_cap)) tbl->is_ht40 = 1; else tbl->is_ht40 = 0; il4965_rs_set_expected_tpt_table(lq_sta, tbl); - rate = il4965_rs_get_best_rate(priv, lq_sta, tbl, rate_mask, index); + rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, index); - IL_DEBUG_RATE(priv, "LQ: MIMO2 best rate %d mask %X\n", + IL_DEBUG_RATE(il, "LQ: MIMO2 best rate %d mask %X\n", rate, rate_mask); if ((rate == IL_RATE_INVALID) || !((1 << rate) & rate_mask)) { - IL_DEBUG_RATE(priv, + IL_DEBUG_RATE(il, "Can't switch with index %d rate mask %x\n", rate, rate_mask); return -1; } - tbl->current_rate = il4965_rate_n_flags_from_tbl(priv, + tbl->current_rate = il4965_rate_n_flags_from_tbl(il, tbl, rate, is_green); - IL_DEBUG_RATE(priv, "LQ: Switch to new mcs %X index is green %X\n", + IL_DEBUG_RATE(il, "LQ: Switch to new mcs %X index is green %X\n", tbl->current_rate, is_green); return 0; } @@ -1230,7 +1230,7 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *priv, /* * Set up search table for SISO */ -static int il4965_rs_switch_to_siso(struct il_priv *priv, +static int il4965_rs_switch_to_siso(struct il_priv *il, struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, @@ -1245,7 +1245,7 @@ static int il4965_rs_switch_to_siso(struct il_priv *priv, if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) return -1; - IL_DEBUG_RATE(priv, "LQ: try to switch to SISO\n"); + IL_DEBUG_RATE(il, "LQ: try to switch to SISO\n"); tbl->is_dup = lq_sta->is_dup; tbl->lq_type = LQ_SISO; @@ -1253,7 +1253,7 @@ static int il4965_rs_switch_to_siso(struct il_priv *priv, tbl->max_search = IL_MAX_SEARCH; rate_mask = lq_sta->active_siso_rate; - if (il_is_ht40_tx_allowed(priv, ctx, &sta->ht_cap)) + if (il_is_ht40_tx_allowed(il, ctx, &sta->ht_cap)) tbl->is_ht40 = 1; else tbl->is_ht40 = 0; @@ -1262,18 +1262,18 @@ static int il4965_rs_switch_to_siso(struct il_priv *priv, tbl->is_SGI = 0; /*11n spec: no SGI in SISO+Greenfield*/ il4965_rs_set_expected_tpt_table(lq_sta, tbl); - rate = il4965_rs_get_best_rate(priv, lq_sta, tbl, rate_mask, index); + rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, index); - IL_DEBUG_RATE(priv, "LQ: get best rate %d mask %X\n", rate, rate_mask); + IL_DEBUG_RATE(il, "LQ: get best rate %d mask %X\n", rate, rate_mask); if ((rate == IL_RATE_INVALID) || !((1 << rate) & rate_mask)) { - IL_DEBUG_RATE(priv, + IL_DEBUG_RATE(il, "can not switch with index %d rate mask %x\n", rate, rate_mask); return -1; } - tbl->current_rate = il4965_rate_n_flags_from_tbl(priv, + tbl->current_rate = il4965_rate_n_flags_from_tbl(il, tbl, rate, is_green); - IL_DEBUG_RATE(priv, "LQ: Switch to new mcs %X index is green %X\n", + IL_DEBUG_RATE(il, "LQ: Switch to new mcs %X index is green %X\n", tbl->current_rate, is_green); return 0; } @@ -1281,7 +1281,7 @@ static int il4965_rs_switch_to_siso(struct il_priv *priv, /* * Try to switch to new modulation mode from legacy */ -static int il4965_rs_move_legacy_other(struct il_priv *priv, +static int il4965_rs_move_legacy_other(struct il_priv *il, struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, @@ -1294,8 +1294,8 @@ static int il4965_rs_move_legacy_other(struct il_priv *priv, u32 sz = (sizeof(struct il_scale_tbl_info) - (sizeof(struct il_rate_scale_data) * IL_RATE_COUNT)); u8 start_action; - u8 valid_tx_ant = priv->hw_params.valid_tx_ant; - u8 tx_chains_num = priv->hw_params.tx_chains_num; + u8 valid_tx_ant = il->hw_params.valid_tx_ant; + u8 tx_chains_num = il->hw_params.tx_chains_num; int ret = 0; u8 update_search_tbl_counter = 0; @@ -1307,7 +1307,7 @@ static int il4965_rs_move_legacy_other(struct il_priv *priv, switch (tbl->action) { case IL_LEGACY_SWITCH_ANTENNA1: case IL_LEGACY_SWITCH_ANTENNA2: - IL_DEBUG_RATE(priv, "LQ: Legacy toggle Antenna\n"); + IL_DEBUG_RATE(il, "LQ: Legacy toggle Antenna\n"); if ((tbl->action == IL_LEGACY_SWITCH_ANTENNA1 && tx_chains_num <= 1) || @@ -1331,12 +1331,12 @@ static int il4965_rs_move_legacy_other(struct il_priv *priv, } break; case IL_LEGACY_SWITCH_SISO: - IL_DEBUG_RATE(priv, "LQ: Legacy switch to SISO\n"); + IL_DEBUG_RATE(il, "LQ: Legacy switch to SISO\n"); /* Set up search table to try SISO */ memcpy(search_tbl, tbl, sz); search_tbl->is_SGI = 0; - ret = il4965_rs_switch_to_siso(priv, lq_sta, conf, sta, + ret = il4965_rs_switch_to_siso(il, lq_sta, conf, sta, search_tbl, index); if (!ret) { lq_sta->action_counter = 0; @@ -1347,7 +1347,7 @@ static int il4965_rs_move_legacy_other(struct il_priv *priv, case IL_LEGACY_SWITCH_MIMO2_AB: case IL_LEGACY_SWITCH_MIMO2_AC: case IL_LEGACY_SWITCH_MIMO2_BC: - IL_DEBUG_RATE(priv, "LQ: Legacy switch to MIMO2\n"); + IL_DEBUG_RATE(il, "LQ: Legacy switch to MIMO2\n"); /* Set up search table to try MIMO */ memcpy(search_tbl, tbl, sz); @@ -1364,7 +1364,7 @@ static int il4965_rs_move_legacy_other(struct il_priv *priv, search_tbl->ant_type)) break; - ret = il4965_rs_switch_to_mimo2(priv, lq_sta, + ret = il4965_rs_switch_to_mimo2(il, lq_sta, conf, sta, search_tbl, index); if (!ret) { @@ -1398,7 +1398,7 @@ out: /* * Try to switch to new modulation mode from SISO */ -static int il4965_rs_move_siso_to_other(struct il_priv *priv, +static int il4965_rs_move_siso_to_other(struct il_priv *il, struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, int index) @@ -1412,8 +1412,8 @@ static int il4965_rs_move_siso_to_other(struct il_priv *priv, u32 sz = (sizeof(struct il_scale_tbl_info) - (sizeof(struct il_rate_scale_data) * IL_RATE_COUNT)); u8 start_action; - u8 valid_tx_ant = priv->hw_params.valid_tx_ant; - u8 tx_chains_num = priv->hw_params.tx_chains_num; + u8 valid_tx_ant = il->hw_params.valid_tx_ant; + u8 tx_chains_num = il->hw_params.tx_chains_num; u8 update_search_tbl_counter = 0; int ret; @@ -1424,7 +1424,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *priv, switch (tbl->action) { case IL_SISO_SWITCH_ANTENNA1: case IL_SISO_SWITCH_ANTENNA2: - IL_DEBUG_RATE(priv, "LQ: SISO toggle Antenna\n"); + IL_DEBUG_RATE(il, "LQ: SISO toggle Antenna\n"); if ((tbl->action == IL_SISO_SWITCH_ANTENNA1 && tx_chains_num <= 1) || (tbl->action == IL_SISO_SWITCH_ANTENNA2 && @@ -1444,7 +1444,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *priv, case IL_SISO_SWITCH_MIMO2_AB: case IL_SISO_SWITCH_MIMO2_AC: case IL_SISO_SWITCH_MIMO2_BC: - IL_DEBUG_RATE(priv, "LQ: SISO switch to MIMO2\n"); + IL_DEBUG_RATE(il, "LQ: SISO switch to MIMO2\n"); memcpy(search_tbl, tbl, sz); search_tbl->is_SGI = 0; @@ -1459,7 +1459,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *priv, search_tbl->ant_type)) break; - ret = il4965_rs_switch_to_mimo2(priv, lq_sta, + ret = il4965_rs_switch_to_mimo2(il, lq_sta, conf, sta, search_tbl, index); if (!ret) @@ -1473,14 +1473,14 @@ static int il4965_rs_move_siso_to_other(struct il_priv *priv, IEEE80211_HT_CAP_SGI_40)) break; - IL_DEBUG_RATE(priv, "LQ: SISO toggle SGI/NGI\n"); + IL_DEBUG_RATE(il, "LQ: SISO toggle SGI/NGI\n"); memcpy(search_tbl, tbl, sz); if (is_green) { if (!tbl->is_SGI) break; else - IL_ERR(priv, + IL_ERR(il, "SGI was set in GF+SISO\n"); } search_tbl->is_SGI = !tbl->is_SGI; @@ -1491,7 +1491,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *priv, break; } search_tbl->current_rate = - il4965_rate_n_flags_from_tbl(priv, search_tbl, + il4965_rate_n_flags_from_tbl(il, search_tbl, index, is_green); update_search_tbl_counter = 1; goto out; @@ -1520,7 +1520,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *priv, /* * Try to switch to new modulation mode from MIMO2 */ -static int il4965_rs_move_mimo2_to_other(struct il_priv *priv, +static int il4965_rs_move_mimo2_to_other(struct il_priv *il, struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, int index) @@ -1534,8 +1534,8 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *priv, u32 sz = (sizeof(struct il_scale_tbl_info) - (sizeof(struct il_rate_scale_data) * IL_RATE_COUNT)); u8 start_action; - u8 valid_tx_ant = priv->hw_params.valid_tx_ant; - u8 tx_chains_num = priv->hw_params.tx_chains_num; + u8 valid_tx_ant = il->hw_params.valid_tx_ant; + u8 tx_chains_num = il->hw_params.tx_chains_num; u8 update_search_tbl_counter = 0; int ret; @@ -1545,7 +1545,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *priv, switch (tbl->action) { case IL_MIMO2_SWITCH_ANTENNA1: case IL_MIMO2_SWITCH_ANTENNA2: - IL_DEBUG_RATE(priv, "LQ: MIMO2 toggle Antennas\n"); + IL_DEBUG_RATE(il, "LQ: MIMO2 toggle Antennas\n"); if (tx_chains_num <= 2) break; @@ -1563,7 +1563,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *priv, case IL_MIMO2_SWITCH_SISO_A: case IL_MIMO2_SWITCH_SISO_B: case IL_MIMO2_SWITCH_SISO_C: - IL_DEBUG_RATE(priv, "LQ: MIMO2 switch to SISO\n"); + IL_DEBUG_RATE(il, "LQ: MIMO2 switch to SISO\n"); /* Set up new search table for SISO */ memcpy(search_tbl, tbl, sz); @@ -1579,7 +1579,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *priv, search_tbl->ant_type)) break; - ret = il4965_rs_switch_to_siso(priv, lq_sta, + ret = il4965_rs_switch_to_siso(il, lq_sta, conf, sta, search_tbl, index); if (!ret) @@ -1595,7 +1595,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *priv, IEEE80211_HT_CAP_SGI_40)) break; - IL_DEBUG_RATE(priv, "LQ: MIMO2 toggle SGI/NGI\n"); + IL_DEBUG_RATE(il, "LQ: MIMO2 toggle SGI/NGI\n"); /* Set up new search table for MIMO2 */ memcpy(search_tbl, tbl, sz); @@ -1613,7 +1613,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *priv, break; } search_tbl->current_rate = - il4965_rate_n_flags_from_tbl(priv, search_tbl, + il4965_rate_n_flags_from_tbl(il, search_tbl, index, is_green); update_search_tbl_counter = 1; goto out; @@ -1654,9 +1654,9 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) int i; int active_tbl; int flush_interval_passed = 0; - struct il_priv *priv; + struct il_priv *il; - priv = lq_sta->drv; + il = lq_sta->drv; active_tbl = lq_sta->active_tbl; tbl = &(lq_sta->lq_info[active_tbl]); @@ -1684,7 +1684,7 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) (lq_sta->total_success > lq_sta->max_success_limit) || ((!lq_sta->search_better_tbl) && (lq_sta->flush_timer) && (flush_interval_passed))) { - IL_DEBUG_RATE(priv, "LQ: stay is expired %d %d %d\n:", + IL_DEBUG_RATE(il, "LQ: stay is expired %d %d %d\n:", lq_sta->total_failed, lq_sta->total_success, flush_interval_passed); @@ -1707,7 +1707,7 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) lq_sta->table_count_limit) { lq_sta->table_count = 0; - IL_DEBUG_RATE(priv, + IL_DEBUG_RATE(il, "LQ: stay in table clear win\n"); for (i = 0; i < IL_RATE_COUNT; i++) il4965_rs_rate_scale_clear_window( @@ -1730,7 +1730,7 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) * setup rate table in uCode * return rate_n_flags as used in the table */ -static u32 il4965_rs_update_rate_tbl(struct il_priv *priv, +static u32 il4965_rs_update_rate_tbl(struct il_priv *il, struct il_rxon_context *ctx, struct il_lq_sta *lq_sta, struct il_scale_tbl_info *tbl, @@ -1739,9 +1739,9 @@ static u32 il4965_rs_update_rate_tbl(struct il_priv *priv, u32 rate; /* Update uCode's rate table. */ - rate = il4965_rate_n_flags_from_tbl(priv, tbl, index, is_green); - il4965_rs_fill_link_cmd(priv, lq_sta, rate); - il_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_ASYNC, false); + rate = il4965_rate_n_flags_from_tbl(il, tbl, index, is_green); + il4965_rs_fill_link_cmd(il, lq_sta, rate); + il_send_lq_cmd(il, ctx, &lq_sta->lq, CMD_ASYNC, false); return rate; } @@ -1749,12 +1749,12 @@ static u32 il4965_rs_update_rate_tbl(struct il_priv *priv, /* * Do rate scaling and search for new modulation mode. */ -static void il4965_rs_rate_scale_perform(struct il_priv *priv, +static void il4965_rs_rate_scale_perform(struct il_priv *il, struct sk_buff *skb, struct ieee80211_sta *sta, struct il_lq_sta *lq_sta) { - struct ieee80211_hw *hw = priv->hw; + struct ieee80211_hw *hw = il->hw; struct ieee80211_conf *conf = &hw->conf; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; @@ -1783,7 +1783,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, struct il_station_priv *sta_priv = (void *)sta->drv_priv; struct il_rxon_context *ctx = sta_priv->common.ctx; - IL_DEBUG_RATE(priv, "rate scale calculate new rate for skb\n"); + IL_DEBUG_RATE(il, "rate scale calculate new rate for skb\n"); /* Send management frames and NO_ACK data using lowest rate. */ /* TODO: this could probably be improved.. */ @@ -1798,7 +1798,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, tid = il4965_rs_tl_add_packet(lq_sta, hdr); if ((tid != MAX_TID_COUNT) && (lq_sta->tx_agg_tid_en & (1 << tid))) { - tid_data = &priv->stations[lq_sta->lq.sta_id].tid[tid]; + tid_data = &il->stations[lq_sta->lq.sta_id].tid[tid]; if (tid_data->agg.state == IL_AGG_OFF) lq_sta->is_agg = 0; else @@ -1826,13 +1826,13 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, /* current tx rate */ index = lq_sta->last_txrate_idx; - IL_DEBUG_RATE(priv, "Rate scale index %d for type %d\n", index, + IL_DEBUG_RATE(il, "Rate scale index %d for type %d\n", index, tbl->lq_type); /* rates available for this association, and for modulation mode */ rate_mask = il4965_rs_get_supported_rates(lq_sta, hdr, tbl->lq_type); - IL_DEBUG_RATE(priv, "mask 0x%04X\n", rate_mask); + IL_DEBUG_RATE(il, "mask 0x%04X\n", rate_mask); /* mask with station rate restriction */ if (is_legacy(tbl->lq_type)) { @@ -1851,7 +1851,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, rate_scale_index_msk = rate_mask; if (!((1 << index) & rate_scale_index_msk)) { - IL_ERR(priv, "Current Rate is not valid\n"); + IL_ERR(il, "Current Rate is not valid\n"); if (lq_sta->search_better_tbl) { /* revert to active table if search table is not valid*/ tbl->lq_type = LQ_NONE; @@ -1859,7 +1859,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); /* get "active" rate info */ index = il4965_hwrate_to_plcp_idx(tbl->current_rate); - rate = il4965_rs_update_rate_tbl(priv, ctx, lq_sta, + rate = il4965_rs_update_rate_tbl(il, ctx, lq_sta, tbl, index, is_green); } return; @@ -1867,7 +1867,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, /* Get expected throughput table and history window for current rate */ if (!tbl->expected_tpt) { - IL_ERR(priv, "tbl->expected_tpt is NULL\n"); + IL_ERR(il, "tbl->expected_tpt is NULL\n"); return; } @@ -1892,7 +1892,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, fail_count = window->counter - window->success_counter; if ((fail_count < IL_RATE_MIN_FAILURE_TH) && (window->success_counter < IL_RATE_MIN_SUCCESS_TH)) { - IL_DEBUG_RATE(priv, "LQ: still below TH. succ=%d total=%d " + IL_DEBUG_RATE(il, "LQ: still below TH. succ=%d total=%d " "for index %d\n", window->success_counter, window->counter, index); @@ -1909,7 +1909,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, * actual average throughput */ if (window->average_tpt != ((window->success_ratio * tbl->expected_tpt[index] + 64) / 128)) { - IL_ERR(priv, + IL_ERR(il, "expected_tpt should have been calculated by now\n"); window->average_tpt = ((window->success_ratio * tbl->expected_tpt[index] + 64) / 128); @@ -1922,7 +1922,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, * continuing to use the setup that we've been trying. */ if (window->average_tpt > lq_sta->last_tpt) { - IL_DEBUG_RATE(priv, "LQ: SWITCHING TO NEW TABLE " + IL_DEBUG_RATE(il, "LQ: SWITCHING TO NEW TABLE " "suc=%d cur-tpt=%d old-tpt=%d\n", window->success_ratio, window->average_tpt, @@ -1938,7 +1938,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, /* Else poor success; go back to mode in "active" table */ } else { - IL_DEBUG_RATE(priv, "LQ: GOING BACK TO THE OLD TABLE " + IL_DEBUG_RATE(il, "LQ: GOING BACK TO THE OLD TABLE " "suc=%d cur-tpt=%d old-tpt=%d\n", window->success_ratio, window->average_tpt, @@ -1968,7 +1968,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, /* (Else) not in search of better modulation mode, try for better * starting rate, while staying in this mode. */ - high_low = il4965_rs_get_adjacent_rate(priv, index, + high_low = il4965_rs_get_adjacent_rate(il, index, rate_scale_index_msk, tbl->lq_type); low = high_low & 0xff; @@ -1992,7 +1992,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, /* Too many failures, decrease rate */ if ((sr <= IL_RATE_DECREASE_TH) || (current_tpt == 0)) { - IL_DEBUG_RATE(priv, + IL_DEBUG_RATE(il, "decrease rate because of low success_ratio\n"); scale_action = -1; @@ -2031,7 +2031,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, } else if (low_tpt != IL_INVALID_VALUE) { /* Lower rate has better throughput */ if (low_tpt > current_tpt) { - IL_DEBUG_RATE(priv, + IL_DEBUG_RATE(il, "decrease rate because of low tpt\n"); scale_action = -1; } else if (sr >= IL_RATE_INCREASE_TH) { @@ -2070,14 +2070,14 @@ static void il4965_rs_rate_scale_perform(struct il_priv *priv, break; } - IL_DEBUG_RATE(priv, "choose rate scale index %d action %d low %d " + IL_DEBUG_RATE(il, "choose rate scale index %d action %d low %d " "high %d type %d\n", index, scale_action, low, high, tbl->lq_type); lq_update: /* Replace uCode's rate table for the destination station. */ if (update_lq) - rate = il4965_rs_update_rate_tbl(priv, ctx, lq_sta, + rate = il4965_rs_update_rate_tbl(il, ctx, lq_sta, tbl, index, is_green); /* Should we stay with this modulation mode, @@ -2098,13 +2098,13 @@ lq_update: /* Select a new "search" modulation mode to try. * If one is found, set up the new "search" table. */ if (is_legacy(tbl->lq_type)) - il4965_rs_move_legacy_other(priv, lq_sta, + il4965_rs_move_legacy_other(il, lq_sta, conf, sta, index); else if (is_siso(tbl->lq_type)) - il4965_rs_move_siso_to_other(priv, lq_sta, + il4965_rs_move_siso_to_other(il, lq_sta, conf, sta, index); else /* (is_mimo2(tbl->lq_type)) */ - il4965_rs_move_mimo2_to_other(priv, lq_sta, + il4965_rs_move_mimo2_to_other(il, lq_sta, conf, sta, index); /* If new "search" mode was selected, set up in uCode table */ @@ -2118,12 +2118,12 @@ lq_update: /* Use new "search" start rate */ index = il4965_hwrate_to_plcp_idx(tbl->current_rate); - IL_DEBUG_RATE(priv, + IL_DEBUG_RATE(il, "Switch current mcs: %X index: %d\n", tbl->current_rate, index); - il4965_rs_fill_link_cmd(priv, lq_sta, + il4965_rs_fill_link_cmd(il, lq_sta, tbl->current_rate); - il_send_lq_cmd(priv, ctx, + il_send_lq_cmd(il, ctx, &lq_sta->lq, CMD_ASYNC, false); } else done_search = 1; @@ -2138,8 +2138,8 @@ lq_update: tbl1 = &(lq_sta->lq_info[lq_sta->active_tbl]); if (is_legacy(tbl1->lq_type) && !conf_is_ht(conf) && lq_sta->action_counter > tbl1->max_search) { - IL_DEBUG_RATE(priv, "LQ: STAY in legacy table\n"); - il4965_rs_set_stay_in_table(priv, 1, lq_sta); + IL_DEBUG_RATE(il, "LQ: STAY in legacy table\n"); + il4965_rs_set_stay_in_table(il, 1, lq_sta); } /* If we're in an HT mode, and all 3 mode switch actions @@ -2151,21 +2151,21 @@ lq_update: (lq_sta->tx_agg_tid_en & (1 << tid)) && (tid != MAX_TID_COUNT)) { tid_data = - &priv->stations[lq_sta->lq.sta_id].tid[tid]; + &il->stations[lq_sta->lq.sta_id].tid[tid]; if (tid_data->agg.state == IL_AGG_OFF) { - IL_DEBUG_RATE(priv, + IL_DEBUG_RATE(il, "try to aggregate tid %d\n", tid); - il4965_rs_tl_turn_on_agg(priv, tid, + il4965_rs_tl_turn_on_agg(il, tid, lq_sta, sta); } } - il4965_rs_set_stay_in_table(priv, 0, lq_sta); + il4965_rs_set_stay_in_table(il, 0, lq_sta); } } out: - tbl->current_rate = il4965_rate_n_flags_from_tbl(priv, tbl, + tbl->current_rate = il4965_rate_n_flags_from_tbl(il, tbl, index, is_green); i = index; lq_sta->last_txrate_idx = i; @@ -2185,7 +2185,7 @@ out: * calling this function (which runs REPLY_TX_LINK_QUALITY_CMD, * which requires station table entry to exist). */ -static void il4965_rs_initialize_lq(struct il_priv *priv, +static void il4965_rs_initialize_lq(struct il_priv *il, struct ieee80211_conf *conf, struct ieee80211_sta *sta, struct il_lq_sta *lq_sta) @@ -2208,7 +2208,7 @@ static void il4965_rs_initialize_lq(struct il_priv *priv, i = lq_sta->last_txrate_idx; - valid_tx_ant = priv->hw_params.valid_tx_ant; + valid_tx_ant = il->hw_params.valid_tx_ant; if (!lq_sta->search_better_tbl) active_tbl = lq_sta->active_tbl; @@ -2227,31 +2227,31 @@ static void il4965_rs_initialize_lq(struct il_priv *priv, if (i >= IL_FIRST_CCK_RATE && i <= IL_LAST_CCK_RATE) rate |= RATE_MCS_CCK_MSK; - il4965_rs_get_tbl_info_from_mcs(rate, priv->band, tbl, &rate_idx); + il4965_rs_get_tbl_info_from_mcs(rate, il->band, tbl, &rate_idx); if (!il4965_rs_is_valid_ant(valid_tx_ant, tbl->ant_type)) il4965_rs_toggle_antenna(valid_tx_ant, &rate, tbl); - rate = il4965_rate_n_flags_from_tbl(priv, tbl, rate_idx, use_green); + rate = il4965_rate_n_flags_from_tbl(il, tbl, rate_idx, use_green); tbl->current_rate = rate; il4965_rs_set_expected_tpt_table(lq_sta, tbl); il4965_rs_fill_link_cmd(NULL, lq_sta, rate); - priv->stations[lq_sta->lq.sta_id].lq = &lq_sta->lq; - il_send_lq_cmd(priv, ctx, &lq_sta->lq, CMD_SYNC, true); + il->stations[lq_sta->lq.sta_id].lq = &lq_sta->lq; + il_send_lq_cmd(il, ctx, &lq_sta->lq, CMD_SYNC, true); } static void -il4965_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta, +il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, struct ieee80211_tx_rate_control *txrc) { struct sk_buff *skb = txrc->skb; struct ieee80211_supported_band *sband = txrc->sband; - struct il_priv *priv __maybe_unused = (struct il_priv *)priv_r; + struct il_priv *il __maybe_unused = (struct il_priv *)il_r; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - struct il_lq_sta *lq_sta = priv_sta; + struct il_lq_sta *lq_sta = il_sta; int rate_idx; - IL_DEBUG_RATE_LIMIT(priv, "rate scale calculate new rate for skb\n"); + IL_DEBUG_RATE_LIMIT(il, "rate scale calculate new rate for skb\n"); /* Get max rate if user set max rate */ if (lq_sta) { @@ -2266,12 +2266,12 @@ il4965_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta, /* Treat uninitialized rate scaling data same as non-existing. */ if (lq_sta && !lq_sta->drv) { - IL_DEBUG_RATE(priv, "Rate scaling not initialized yet.\n"); - priv_sta = NULL; + IL_DEBUG_RATE(il, "Rate scaling not initialized yet.\n"); + il_sta = NULL; } /* Send management frames and NO_ACK data using lowest rate. */ - if (rate_control_send_low(sta, priv_sta, txrc)) + if (rate_control_send_low(sta, il_sta, txrc)) return; if (!lq_sta) @@ -2314,16 +2314,16 @@ il4965_rs_get_rate(void *priv_r, struct ieee80211_sta *sta, void *priv_sta, } -static void *il4965_rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta, +static void *il4965_rs_alloc_sta(void *il_rate, struct ieee80211_sta *sta, gfp_t gfp) { struct il_lq_sta *lq_sta; struct il_station_priv *sta_priv = (struct il_station_priv *) sta->drv_priv; - struct il_priv *priv; + struct il_priv *il; - priv = (struct il_priv *)priv_rate; - IL_DEBUG_RATE(priv, "create station rate scale window\n"); + il = (struct il_priv *)il_rate; + IL_DEBUG_RATE(il, "create station rate scale window\n"); lq_sta = &sta_priv->lq_sta; @@ -2334,13 +2334,13 @@ static void *il4965_rs_alloc_sta(void *priv_rate, struct ieee80211_sta *sta, * Called after adding a new station to initialize rate scaling */ void -il4965_rs_rate_init(struct il_priv *priv, +il4965_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_id) { int i, j; - struct ieee80211_hw *hw = priv->hw; - struct ieee80211_conf *conf = &priv->hw->conf; + struct ieee80211_hw *hw = il->hw; + struct ieee80211_conf *conf = &il->hw->conf; struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; struct il_station_priv *sta_priv; struct il_lq_sta *lq_sta; @@ -2365,7 +2365,7 @@ il4965_rs_rate_init(struct il_priv *priv, il4965_rs_rate_scale_clear_window( &lq_sta->lq_info[j].win[i]); - IL_DEBUG_RATE(priv, "LQ:" + IL_DEBUG_RATE(il, "LQ:" "*** rate scale station global init for station %d ***\n", sta_id); /* TODO: what is a good starting rate for STA? About middle? Maybe not @@ -2377,8 +2377,8 @@ il4965_rs_rate_init(struct il_priv *priv, lq_sta->max_rate_idx = -1; lq_sta->missed_rate_counter = IL_MISSED_RATE_MAX; lq_sta->is_green = il4965_rs_use_green(sta); - lq_sta->active_legacy_rate = priv->active_rate & ~(0x1000); - lq_sta->band = priv->band; + lq_sta->active_legacy_rate = il->active_rate & ~(0x1000); + lq_sta->band = il->band; /* * active_siso_rate mask includes 9 MBits (bit 5), and CCK (bits 0-3), * supp_rates[] does not; shift to convert format, force 9 MBits off. @@ -2396,20 +2396,20 @@ il4965_rs_rate_init(struct il_priv *priv, /* These values will be overridden later */ lq_sta->lq.general_params.single_stream_ant_msk = - il4965_first_antenna(priv->hw_params.valid_tx_ant); + il4965_first_antenna(il->hw_params.valid_tx_ant); lq_sta->lq.general_params.dual_stream_ant_msk = - priv->hw_params.valid_tx_ant & - ~il4965_first_antenna(priv->hw_params.valid_tx_ant); + il->hw_params.valid_tx_ant & + ~il4965_first_antenna(il->hw_params.valid_tx_ant); if (!lq_sta->lq.general_params.dual_stream_ant_msk) { lq_sta->lq.general_params.dual_stream_ant_msk = ANT_AB; - } else if (il4965_num_of_ant(priv->hw_params.valid_tx_ant) == 2) { + } else if (il4965_num_of_ant(il->hw_params.valid_tx_ant) == 2) { lq_sta->lq.general_params.dual_stream_ant_msk = - priv->hw_params.valid_tx_ant; + il->hw_params.valid_tx_ant; } /* as default allow aggregation for all tids */ lq_sta->tx_agg_tid_en = IL_AGG_ALL_TID; - lq_sta->drv = priv; + lq_sta->drv = il; /* Set last_txrate_idx to lowest rate */ lq_sta->last_txrate_idx = rate_lowest_index(sband, sta); @@ -2421,10 +2421,10 @@ il4965_rs_rate_init(struct il_priv *priv, lq_sta->dbg_fixed_rate = 0; #endif - il4965_rs_initialize_lq(priv, conf, sta, lq_sta); + il4965_rs_initialize_lq(il, conf, sta, lq_sta); } -static void il4965_rs_fill_link_cmd(struct il_priv *priv, +static void il4965_rs_fill_link_cmd(struct il_priv *il, struct il_lq_sta *lq_sta, u32 new_rate) { struct il_scale_tbl_info tbl_type; @@ -2467,8 +2467,8 @@ static void il4965_rs_fill_link_cmd(struct il_priv *priv, index++; repeat_rate--; - if (priv) - valid_tx_ant = priv->hw_params.valid_tx_ant; + if (il) + valid_tx_ant = il->hw_params.valid_tx_ant; /* Fill rest of rate table */ while (index < LINK_QUAL_MAX_RETRY_NUM) { @@ -2479,7 +2479,7 @@ static void il4965_rs_fill_link_cmd(struct il_priv *priv, if (is_legacy(tbl_type.lq_type)) { if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE) ant_toggle_cnt++; - else if (priv && + else if (il && il4965_rs_toggle_antenna(valid_tx_ant, &new_rate, &tbl_type)) ant_toggle_cnt = 1; @@ -2514,7 +2514,7 @@ static void il4965_rs_fill_link_cmd(struct il_priv *priv, if (is_legacy(tbl_type.lq_type)) { if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE) ant_toggle_cnt++; - else if (priv && + else if (il && il4965_rs_toggle_antenna(valid_tx_ant, &new_rate, &tbl_type)) ant_toggle_cnt = 1; @@ -2551,18 +2551,18 @@ static void return hw->priv; } /* rate scale requires free function to be implemented */ -static void il4965_rs_free(void *priv_rate) +static void il4965_rs_free(void *il_rate) { return; } -static void il4965_rs_free_sta(void *priv_r, struct ieee80211_sta *sta, - void *priv_sta) +static void il4965_rs_free_sta(void *il_r, struct ieee80211_sta *sta, + void *il_sta) { - struct il_priv *priv __maybe_unused = priv_r; + struct il_priv *il __maybe_unused = il_r; - IL_DEBUG_RATE(priv, "enter\n"); - IL_DEBUG_RATE(priv, "leave\n"); + IL_DEBUG_RATE(il, "enter\n"); + IL_DEBUG_RATE(il, "leave\n"); } @@ -2575,28 +2575,28 @@ static int il4965_open_file_generic(struct inode *inode, struct file *file) static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, u32 *rate_n_flags, int index) { - struct il_priv *priv; + struct il_priv *il; u8 valid_tx_ant; u8 ant_sel_tx; - priv = lq_sta->drv; - valid_tx_ant = priv->hw_params.valid_tx_ant; + il = lq_sta->drv; + valid_tx_ant = il->hw_params.valid_tx_ant; if (lq_sta->dbg_fixed_rate) { ant_sel_tx = ((lq_sta->dbg_fixed_rate & RATE_MCS_ANT_ABC_MSK) >> RATE_MCS_ANT_POS); if ((valid_tx_ant & ant_sel_tx) == ant_sel_tx) { *rate_n_flags = lq_sta->dbg_fixed_rate; - IL_DEBUG_RATE(priv, "Fixed rate ON\n"); + IL_DEBUG_RATE(il, "Fixed rate ON\n"); } else { lq_sta->dbg_fixed_rate = 0; - IL_ERR(priv, + IL_ERR(il, "Invalid antenna selection 0x%X, Valid is 0x%X\n", ant_sel_tx, valid_tx_ant); - IL_DEBUG_RATE(priv, "Fixed rate OFF\n"); + IL_DEBUG_RATE(il, "Fixed rate OFF\n"); } } else { - IL_DEBUG_RATE(priv, "Fixed rate OFF\n"); + IL_DEBUG_RATE(il, "Fixed rate OFF\n"); } } @@ -2604,7 +2604,7 @@ static ssize_t il4965_rs_sta_dbgfs_scale_table_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { struct il_lq_sta *lq_sta = file->private_data; - struct il_priv *priv; + struct il_priv *il; char buf[64]; size_t buf_size; u32 parsed_rate; @@ -2612,7 +2612,7 @@ static ssize_t il4965_rs_sta_dbgfs_scale_table_write(struct file *file, container_of(lq_sta, struct il_station_priv, lq_sta); struct il_rxon_context *ctx = sta_priv->common.ctx; - priv = lq_sta->drv; + il = lq_sta->drv; memset(buf, 0, sizeof(buf)); buf_size = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, buf_size)) @@ -2627,7 +2627,7 @@ static ssize_t il4965_rs_sta_dbgfs_scale_table_write(struct file *file, lq_sta->active_siso_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ - IL_DEBUG_RATE(priv, "sta_id %d rate 0x%X\n", + IL_DEBUG_RATE(il, "sta_id %d rate 0x%X\n", lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate); if (lq_sta->dbg_fixed_rate) { @@ -2649,10 +2649,10 @@ static ssize_t il4965_rs_sta_dbgfs_scale_table_read(struct file *file, ssize_t ret; struct il_lq_sta *lq_sta = file->private_data; - struct il_priv *priv; + struct il_priv *il; struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - priv = lq_sta->drv; + il = lq_sta->drv; buff = kmalloc(1024, GFP_KERNEL); if (!buff) return -ENOMEM; @@ -2664,9 +2664,9 @@ static ssize_t il4965_rs_sta_dbgfs_scale_table_read(struct file *file, desc += sprintf(buff+desc, "fixed rate 0x%X\n", lq_sta->dbg_fixed_rate); desc += sprintf(buff+desc, "valid_tx_ant %s%s%s\n", - (priv->hw_params.valid_tx_ant & ANT_A) ? "ANT_A," : "", - (priv->hw_params.valid_tx_ant & ANT_B) ? "ANT_B," : "", - (priv->hw_params.valid_tx_ant & ANT_C) ? "ANT_C" : ""); + (il->hw_params.valid_tx_ant & ANT_A) ? "ANT_A," : "", + (il->hw_params.valid_tx_ant & ANT_B) ? "ANT_B," : "", + (il->hw_params.valid_tx_ant & ANT_C) ? "ANT_C" : ""); desc += sprintf(buff+desc, "lq type %s\n", (is_legacy(tbl->lq_type)) ? "legacy" : "HT"); if (is_Ht(tbl->lq_type)) { @@ -2781,10 +2781,10 @@ static ssize_t il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, ssize_t ret; struct il_lq_sta *lq_sta = file->private_data; - struct il_priv *priv; + struct il_priv *il; struct il_scale_tbl_info *tbl = &lq_sta->lq_info[lq_sta->active_tbl]; - priv = lq_sta->drv; + il = lq_sta->drv; if (is_Ht(tbl->lq_type)) desc += sprintf(buff+desc, @@ -2805,10 +2805,10 @@ static const struct file_operations rs_sta_dbgfs_rate_scale_data_ops = { .llseek = default_llseek, }; -static void il4965_rs_add_debugfs(void *priv, void *priv_sta, +static void il4965_rs_add_debugfs(void *il, void *il_sta, struct dentry *dir) { - struct il_lq_sta *lq_sta = priv_sta; + struct il_lq_sta *lq_sta = il_sta; lq_sta->rs_sta_dbgfs_scale_table_file = debugfs_create_file("rate_scale_table", S_IRUSR | S_IWUSR, dir, lq_sta, &rs_sta_dbgfs_scale_table_ops); @@ -2824,9 +2824,9 @@ static void il4965_rs_add_debugfs(void *priv, void *priv_sta, } -static void il4965_rs_remove_debugfs(void *priv, void *priv_sta) +static void il4965_rs_remove_debugfs(void *il, void *il_sta) { - struct il_lq_sta *lq_sta = priv_sta; + struct il_lq_sta *lq_sta = il_sta; debugfs_remove(lq_sta->rs_sta_dbgfs_scale_table_file); debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file); debugfs_remove(lq_sta->rs_sta_dbgfs_rate_scale_data_file); @@ -2840,8 +2840,8 @@ static void il4965_rs_remove_debugfs(void *priv, void *priv_sta) * station is added we ignore it. */ static void -il4965_rs_rate_init_stub(void *priv_r, struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, void *priv_sta) +il4965_rs_rate_init_stub(void *il_r, struct ieee80211_supported_band *sband, + struct ieee80211_sta *sta, void *il_sta) { } static struct rate_control_ops rs_4965_ops = { diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c index 47cbe565a530..c987c80a37cf 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c @@ -41,7 +41,7 @@ #include "iwl-4965-hw.h" #include "iwl-4965.h" -void il4965_rx_missed_beacon_notif(struct il_priv *priv, +void il4965_rx_missed_beacon_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { @@ -50,22 +50,22 @@ void il4965_rx_missed_beacon_notif(struct il_priv *priv, missed_beacon = &pkt->u.missed_beacon; if (le32_to_cpu(missed_beacon->consecutive_missed_beacons) > - priv->missed_beacon_threshold) { - IL_DEBUG_CALIB(priv, + il->missed_beacon_threshold) { + IL_DEBUG_CALIB(il, "missed bcn cnsq %d totl %d rcd %d expctd %d\n", le32_to_cpu(missed_beacon->consecutive_missed_beacons), le32_to_cpu(missed_beacon->total_missed_becons), le32_to_cpu(missed_beacon->num_recvd_beacons), le32_to_cpu(missed_beacon->num_expected_beacons)); - if (!test_bit(STATUS_SCANNING, &priv->status)) - il4965_init_sensitivity(priv); + if (!test_bit(STATUS_SCANNING, &il->status)) + il4965_init_sensitivity(il); } } /* Calculate noise level, based on measurements during network silence just * before arriving beacon. This measurement can be done only if we know * exactly when to expect beacons, therefore only when we're associated. */ -static void il4965_rx_calc_noise(struct il_priv *priv) +static void il4965_rx_calc_noise(struct il_priv *il) { struct statistics_rx_non_phy *rx_info; int num_active_rx = 0; @@ -73,7 +73,7 @@ static void il4965_rx_calc_noise(struct il_priv *priv) int bcn_silence_a, bcn_silence_b, bcn_silence_c; int last_rx_noise; - rx_info = &(priv->_4965.statistics.rx.general); + rx_info = &(il->_4965.statistics.rx.general); bcn_silence_a = le32_to_cpu(rx_info->beacon_silence_rssi_a) & IN_BAND_FILTER; bcn_silence_b = @@ -100,7 +100,7 @@ static void il4965_rx_calc_noise(struct il_priv *priv) else last_rx_noise = IL_NOISE_MEAS_NOT_AVAILABLE; - IL_DEBUG_CALIB(priv, "inband silence a %u, b %u, c %u, dBm %d\n", + IL_DEBUG_CALIB(il, "inband silence a %u, b %u, c %u, dBm %d\n", bcn_silence_a, bcn_silence_b, bcn_silence_c, last_rx_noise); } @@ -111,7 +111,7 @@ static void il4965_rx_calc_noise(struct il_priv *priv) * FIXME: This function is for debugging, do not deal with * the case of counters roll-over. */ -static void il4965_accumulative_statistics(struct il_priv *priv, +static void il4965_accumulative_statistics(struct il_priv *il, __le32 *stats) { int i, size; @@ -121,15 +121,15 @@ static void il4965_accumulative_statistics(struct il_priv *priv, struct statistics_general_common *general, *accum_general; struct statistics_tx *tx, *accum_tx; - prev_stats = (__le32 *)&priv->_4965.statistics; - accum_stats = (u32 *)&priv->_4965.accum_statistics; + prev_stats = (__le32 *)&il->_4965.statistics; + accum_stats = (u32 *)&il->_4965.accum_statistics; size = sizeof(struct il_notif_statistics); - general = &priv->_4965.statistics.general.common; - accum_general = &priv->_4965.accum_statistics.general.common; - tx = &priv->_4965.statistics.tx; - accum_tx = &priv->_4965.accum_statistics.tx; - delta = (u32 *)&priv->_4965.delta_statistics; - max_delta = (u32 *)&priv->_4965.max_delta; + general = &il->_4965.statistics.general.common; + accum_general = &il->_4965.accum_statistics.general.common; + tx = &il->_4965.statistics.tx; + accum_tx = &il->_4965.accum_statistics.tx; + delta = (u32 *)&il->_4965.delta_statistics; + max_delta = (u32 *)&il->_4965.max_delta; for (i = sizeof(__le32); i < size; i += sizeof(__le32), stats++, prev_stats++, delta++, @@ -151,65 +151,65 @@ static void il4965_accumulative_statistics(struct il_priv *priv, #define REG_RECALIB_PERIOD (60) -void il4965_rx_statistics(struct il_priv *priv, +void il4965_rx_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb) { int change; struct il_rx_packet *pkt = rxb_addr(rxb); - IL_DEBUG_RX(priv, + IL_DEBUG_RX(il, "Statistics notification received (%d vs %d).\n", (int)sizeof(struct il_notif_statistics), le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK); - change = ((priv->_4965.statistics.general.common.temperature != + change = ((il->_4965.statistics.general.common.temperature != pkt->u.stats.general.common.temperature) || - ((priv->_4965.statistics.flag & + ((il->_4965.statistics.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK) != (pkt->u.stats.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK))); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS - il4965_accumulative_statistics(priv, (__le32 *)&pkt->u.stats); + il4965_accumulative_statistics(il, (__le32 *)&pkt->u.stats); #endif /* TODO: reading some of statistics is unneeded */ - memcpy(&priv->_4965.statistics, &pkt->u.stats, - sizeof(priv->_4965.statistics)); + memcpy(&il->_4965.statistics, &pkt->u.stats, + sizeof(il->_4965.statistics)); - set_bit(STATUS_STATISTICS, &priv->status); + set_bit(STATUS_STATISTICS, &il->status); /* Reschedule the statistics timer to occur in * REG_RECALIB_PERIOD seconds to ensure we get a * thermal update even if the uCode doesn't give * us one */ - mod_timer(&priv->statistics_periodic, jiffies + + mod_timer(&il->statistics_periodic, jiffies + msecs_to_jiffies(REG_RECALIB_PERIOD * 1000)); - if (unlikely(!test_bit(STATUS_SCANNING, &priv->status)) && + if (unlikely(!test_bit(STATUS_SCANNING, &il->status)) && (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) { - il4965_rx_calc_noise(priv); - queue_work(priv->workqueue, &priv->run_time_calib_work); + il4965_rx_calc_noise(il); + queue_work(il->workqueue, &il->run_time_calib_work); } - if (priv->cfg->ops->lib->temp_ops.temperature && change) - priv->cfg->ops->lib->temp_ops.temperature(priv); + if (il->cfg->ops->lib->temp_ops.temperature && change) + il->cfg->ops->lib->temp_ops.temperature(il); } -void il4965_reply_statistics(struct il_priv *priv, +void il4965_reply_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATISTICS_CLEAR_MSK) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS - memset(&priv->_4965.accum_statistics, 0, + memset(&il->_4965.accum_statistics, 0, sizeof(struct il_notif_statistics)); - memset(&priv->_4965.delta_statistics, 0, + memset(&il->_4965.delta_statistics, 0, sizeof(struct il_notif_statistics)); - memset(&priv->_4965.max_delta, 0, + memset(&il->_4965.max_delta, 0, sizeof(struct il_notif_statistics)); #endif - IL_DEBUG_RX(priv, "Statistics have been cleared\n"); + IL_DEBUG_RX(il, "Statistics have been cleared\n"); } - il4965_rx_statistics(priv, rxb); + il4965_rx_statistics(il, rxb); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c index 3ac9aef439a6..20290d24fd62 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c @@ -35,7 +35,7 @@ #include "iwl-4965.h" static struct il_link_quality_cmd * -il4965_sta_alloc_lq(struct il_priv *priv, u8 sta_id) +il4965_sta_alloc_lq(struct il_priv *il, u8 sta_id) { int i, r; struct il_link_quality_cmd *link_cmd; @@ -44,12 +44,12 @@ il4965_sta_alloc_lq(struct il_priv *priv, u8 sta_id) link_cmd = kzalloc(sizeof(struct il_link_quality_cmd), GFP_KERNEL); if (!link_cmd) { - IL_ERR(priv, "Unable to allocate memory for LQ cmd.\n"); + IL_ERR(il, "Unable to allocate memory for LQ cmd.\n"); return NULL; } /* Set up the rate scaling to start at selected rate, fall back * all the way down to 1M in IEEE order, and then spin on 1M */ - if (priv->band == IEEE80211_BAND_5GHZ) + if (il->band == IEEE80211_BAND_5GHZ) r = IL_RATE_6M_INDEX; else r = IL_RATE_1M_INDEX; @@ -57,7 +57,7 @@ il4965_sta_alloc_lq(struct il_priv *priv, u8 sta_id) if (r >= IL_FIRST_CCK_RATE && r <= IL_LAST_CCK_RATE) rate_flags |= RATE_MCS_CCK_MSK; - rate_flags |= il4965_first_antenna(priv->hw_params.valid_tx_ant) << + rate_flags |= il4965_first_antenna(il->hw_params.valid_tx_ant) << RATE_MCS_ANT_POS; rate_n_flags = il4965_hw_set_rate_n_flags(iwlegacy_rates[r].plcp, rate_flags); @@ -65,16 +65,16 @@ il4965_sta_alloc_lq(struct il_priv *priv, u8 sta_id) link_cmd->rs_table[i].rate_n_flags = rate_n_flags; link_cmd->general_params.single_stream_ant_msk = - il4965_first_antenna(priv->hw_params.valid_tx_ant); + il4965_first_antenna(il->hw_params.valid_tx_ant); link_cmd->general_params.dual_stream_ant_msk = - priv->hw_params.valid_tx_ant & - ~il4965_first_antenna(priv->hw_params.valid_tx_ant); + il->hw_params.valid_tx_ant & + ~il4965_first_antenna(il->hw_params.valid_tx_ant); if (!link_cmd->general_params.dual_stream_ant_msk) { link_cmd->general_params.dual_stream_ant_msk = ANT_AB; - } else if (il4965_num_of_ant(priv->hw_params.valid_tx_ant) == 2) { + } else if (il4965_num_of_ant(il->hw_params.valid_tx_ant) == 2) { link_cmd->general_params.dual_stream_ant_msk = - priv->hw_params.valid_tx_ant; + il->hw_params.valid_tx_ant; } link_cmd->agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF; @@ -92,7 +92,7 @@ il4965_sta_alloc_lq(struct il_priv *priv, u8 sta_id) * Function sleeps. */ int -il4965_add_bssid_station(struct il_priv *priv, struct il_rxon_context *ctx, +il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, const u8 *addr, u8 *sta_id_r) { int ret; @@ -103,40 +103,40 @@ il4965_add_bssid_station(struct il_priv *priv, struct il_rxon_context *ctx, if (sta_id_r) *sta_id_r = IL_INVALID_STATION; - ret = il_add_station_common(priv, ctx, addr, 0, NULL, &sta_id); + ret = il_add_station_common(il, ctx, addr, 0, NULL, &sta_id); if (ret) { - IL_ERR(priv, "Unable to add station %pM\n", addr); + IL_ERR(il, "Unable to add station %pM\n", addr); return ret; } if (sta_id_r) *sta_id_r = sta_id; - spin_lock_irqsave(&priv->sta_lock, flags); - priv->stations[sta_id].used |= IL_STA_LOCAL; - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].used |= IL_STA_LOCAL; + spin_unlock_irqrestore(&il->sta_lock, flags); /* Set up default rate scaling table in device's station table */ - link_cmd = il4965_sta_alloc_lq(priv, sta_id); + link_cmd = il4965_sta_alloc_lq(il, sta_id); if (!link_cmd) { - IL_ERR(priv, + IL_ERR(il, "Unable to initialize rate scaling for station %pM.\n", addr); return -ENOMEM; } - ret = il_send_lq_cmd(priv, ctx, link_cmd, CMD_SYNC, true); + ret = il_send_lq_cmd(il, ctx, link_cmd, CMD_SYNC, true); if (ret) - IL_ERR(priv, "Link quality command failed (%d)\n", ret); + IL_ERR(il, "Link quality command failed (%d)\n", ret); - spin_lock_irqsave(&priv->sta_lock, flags); - priv->stations[sta_id].lq = link_cmd; - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].lq = link_cmd; + spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } -static int il4965_static_wepkey_cmd(struct il_priv *priv, +static int il4965_static_wepkey_cmd(struct il_priv *il, struct il_rxon_context *ctx, bool send_if_empty) { @@ -178,74 +178,74 @@ static int il4965_static_wepkey_cmd(struct il_priv *priv, cmd.len = cmd_size; if (not_empty || send_if_empty) - return il_send_cmd(priv, &cmd); + return il_send_cmd(il, &cmd); else return 0; } -int il4965_restore_default_wep_keys(struct il_priv *priv, +int il4965_restore_default_wep_keys(struct il_priv *il, struct il_rxon_context *ctx) { - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - return il4965_static_wepkey_cmd(priv, ctx, false); + return il4965_static_wepkey_cmd(il, ctx, false); } -int il4965_remove_default_wep_key(struct il_priv *priv, +int il4965_remove_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf) { int ret; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - IL_DEBUG_WEP(priv, "Removing default WEP key: idx=%d\n", + IL_DEBUG_WEP(il, "Removing default WEP key: idx=%d\n", keyconf->keyidx); memset(&ctx->wep_keys[keyconf->keyidx], 0, sizeof(ctx->wep_keys[0])); - if (il_is_rfkill(priv)) { - IL_DEBUG_WEP(priv, + if (il_is_rfkill(il)) { + IL_DEBUG_WEP(il, "Not sending REPLY_WEPKEY command due to RFKILL.\n"); /* but keys in device are clear anyway so return success */ return 0; } - ret = il4965_static_wepkey_cmd(priv, ctx, 1); - IL_DEBUG_WEP(priv, "Remove default WEP key: idx=%d ret=%d\n", + ret = il4965_static_wepkey_cmd(il, ctx, 1); + IL_DEBUG_WEP(il, "Remove default WEP key: idx=%d ret=%d\n", keyconf->keyidx, ret); return ret; } -int il4965_set_default_wep_key(struct il_priv *priv, +int il4965_set_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf) { int ret; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); if (keyconf->keylen != WEP_KEY_LEN_128 && keyconf->keylen != WEP_KEY_LEN_64) { - IL_DEBUG_WEP(priv, "Bad WEP key length %d\n", keyconf->keylen); + IL_DEBUG_WEP(il, "Bad WEP key length %d\n", keyconf->keylen); return -EINVAL; } keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV; keyconf->hw_key_idx = HW_KEY_DEFAULT; - priv->stations[ctx->ap_sta_id].keyinfo.cipher = keyconf->cipher; + il->stations[ctx->ap_sta_id].keyinfo.cipher = keyconf->cipher; ctx->wep_keys[keyconf->keyidx].key_size = keyconf->keylen; memcpy(&ctx->wep_keys[keyconf->keyidx].key, &keyconf->key, keyconf->keylen); - ret = il4965_static_wepkey_cmd(priv, ctx, false); - IL_DEBUG_WEP(priv, "Set default WEP key: len=%d idx=%d ret=%d\n", + ret = il4965_static_wepkey_cmd(il, ctx, false); + IL_DEBUG_WEP(il, "Set default WEP key: len=%d idx=%d ret=%d\n", keyconf->keylen, keyconf->keyidx, ret); return ret; } -static int il4965_set_wep_dynamic_key_info(struct il_priv *priv, +static int il4965_set_wep_dynamic_key_info(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, u8 sta_id) @@ -254,7 +254,7 @@ static int il4965_set_wep_dynamic_key_info(struct il_priv *priv, __le16 key_flags = 0; struct il_addsta_cmd sta_cmd; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV; @@ -268,40 +268,40 @@ static int il4965_set_wep_dynamic_key_info(struct il_priv *priv, if (sta_id == ctx->bcast_sta_id) key_flags |= STA_KEY_MULTICAST_MSK; - spin_lock_irqsave(&priv->sta_lock, flags); + spin_lock_irqsave(&il->sta_lock, flags); - priv->stations[sta_id].keyinfo.cipher = keyconf->cipher; - priv->stations[sta_id].keyinfo.keylen = keyconf->keylen; - priv->stations[sta_id].keyinfo.keyidx = keyconf->keyidx; + il->stations[sta_id].keyinfo.cipher = keyconf->cipher; + il->stations[sta_id].keyinfo.keylen = keyconf->keylen; + il->stations[sta_id].keyinfo.keyidx = keyconf->keyidx; - memcpy(priv->stations[sta_id].keyinfo.key, + memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, keyconf->keylen); - memcpy(&priv->stations[sta_id].sta.key.key[3], + memcpy(&il->stations[sta_id].sta.key.key[3], keyconf->key, keyconf->keylen); - if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) + if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) - priv->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_index(priv); + il->stations[sta_id].sta.key.key_offset = + il_get_free_ucode_key_index(il); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ - WARN(priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, + WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, "no space for a new key"); - priv->stations[sta_id].sta.key.key_flags = key_flags; - priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; - priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + il->stations[sta_id].sta.key.key_flags = key_flags; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - memcpy(&sta_cmd, &priv->stations[sta_id].sta, + memcpy(&sta_cmd, &il->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); - return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } -static int il4965_set_ccmp_dynamic_key_info(struct il_priv *priv, +static int il4965_set_ccmp_dynamic_key_info(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, u8 sta_id) @@ -310,7 +310,7 @@ static int il4965_set_ccmp_dynamic_key_info(struct il_priv *priv, __le16 key_flags = 0; struct il_addsta_cmd sta_cmd; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK); key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); @@ -321,38 +321,38 @@ static int il4965_set_ccmp_dynamic_key_info(struct il_priv *priv, keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; - spin_lock_irqsave(&priv->sta_lock, flags); - priv->stations[sta_id].keyinfo.cipher = keyconf->cipher; - priv->stations[sta_id].keyinfo.keylen = keyconf->keylen; + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].keyinfo.cipher = keyconf->cipher; + il->stations[sta_id].keyinfo.keylen = keyconf->keylen; - memcpy(priv->stations[sta_id].keyinfo.key, keyconf->key, + memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, keyconf->keylen); - memcpy(priv->stations[sta_id].sta.key.key, keyconf->key, + memcpy(il->stations[sta_id].sta.key.key, keyconf->key, keyconf->keylen); - if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) + if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) - priv->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_index(priv); + il->stations[sta_id].sta.key.key_offset = + il_get_free_ucode_key_index(il); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ - WARN(priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, + WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, "no space for a new key"); - priv->stations[sta_id].sta.key.key_flags = key_flags; - priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; - priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + il->stations[sta_id].sta.key.key_flags = key_flags; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - memcpy(&sta_cmd, &priv->stations[sta_id].sta, + memcpy(&sta_cmd, &il->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); - return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } -static int il4965_set_tkip_dynamic_key_info(struct il_priv *priv, +static int il4965_set_tkip_dynamic_key_info(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, u8 sta_id) @@ -371,35 +371,35 @@ static int il4965_set_tkip_dynamic_key_info(struct il_priv *priv, keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; - spin_lock_irqsave(&priv->sta_lock, flags); + spin_lock_irqsave(&il->sta_lock, flags); - priv->stations[sta_id].keyinfo.cipher = keyconf->cipher; - priv->stations[sta_id].keyinfo.keylen = 16; + il->stations[sta_id].keyinfo.cipher = keyconf->cipher; + il->stations[sta_id].keyinfo.keylen = 16; - if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) + if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) - priv->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_index(priv); + il->stations[sta_id].sta.key.key_offset = + il_get_free_ucode_key_index(il); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ - WARN(priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, + WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, "no space for a new key"); - priv->stations[sta_id].sta.key.key_flags = key_flags; + il->stations[sta_id].sta.key.key_flags = key_flags; /* This copy is acutally not needed: we get the key with each TX */ - memcpy(priv->stations[sta_id].keyinfo.key, keyconf->key, 16); + memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, 16); - memcpy(priv->stations[sta_id].sta.key.key, keyconf->key, 16); + memcpy(il->stations[sta_id].sta.key.key, keyconf->key, 16); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); return ret; } -void il4965_update_tkip_key(struct il_priv *priv, +void il4965_update_tkip_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, struct ieee80211_sta *sta, u32 iv32, u16 *phase1key) @@ -408,34 +408,34 @@ void il4965_update_tkip_key(struct il_priv *priv, unsigned long flags; int i; - if (il_scan_cancel(priv)) { + if (il_scan_cancel(il)) { /* cancel scan failed, just live w/ bad key and rely briefly on SW decryption */ return; } - sta_id = il_sta_id_or_broadcast(priv, ctx, sta); + sta_id = il_sta_id_or_broadcast(il, ctx, sta); if (sta_id == IL_INVALID_STATION) return; - spin_lock_irqsave(&priv->sta_lock, flags); + spin_lock_irqsave(&il->sta_lock, flags); - priv->stations[sta_id].sta.key.tkip_rx_tsc_byte2 = (u8) iv32; + il->stations[sta_id].sta.key.tkip_rx_tsc_byte2 = (u8) iv32; for (i = 0; i < 5; i++) - priv->stations[sta_id].sta.key.tkip_rx_ttak[i] = + il->stations[sta_id].sta.key.tkip_rx_ttak[i] = cpu_to_le16(phase1key[i]); - priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; - priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - il_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); + il_send_add_sta(il, &il->stations[sta_id].sta, CMD_ASYNC); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); } -int il4965_remove_dynamic_key(struct il_priv *priv, +int il4965_remove_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, u8 sta_id) @@ -445,15 +445,15 @@ int il4965_remove_dynamic_key(struct il_priv *priv, u8 keyidx; struct il_addsta_cmd sta_cmd; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); ctx->key_mapping_keys--; - spin_lock_irqsave(&priv->sta_lock, flags); - key_flags = le16_to_cpu(priv->stations[sta_id].sta.key.key_flags); + spin_lock_irqsave(&il->sta_lock, flags); + key_flags = le16_to_cpu(il->stations[sta_id].sta.key.key_flags); keyidx = (key_flags >> STA_KEY_FLG_KEYID_POS) & 0x3; - IL_DEBUG_WEP(priv, "Remove dynamic key: idx=%d sta=%d\n", + IL_DEBUG_WEP(il, "Remove dynamic key: idx=%d sta=%d\n", keyconf->keyidx, sta_id); if (keyconf->keyidx != keyidx) { @@ -462,76 +462,76 @@ int il4965_remove_dynamic_key(struct il_priv *priv, * been replaced by another one with different index. * Don't do anything and return ok */ - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } - if (priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET) { - IL_WARN(priv, "Removing wrong key %d 0x%x\n", + if (il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET) { + IL_WARN(il, "Removing wrong key %d 0x%x\n", keyconf->keyidx, key_flags); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } - if (!test_and_clear_bit(priv->stations[sta_id].sta.key.key_offset, - &priv->ucode_key_table)) - IL_ERR(priv, "index %d not used in uCode key table.\n", - priv->stations[sta_id].sta.key.key_offset); - memset(&priv->stations[sta_id].keyinfo, 0, + if (!test_and_clear_bit(il->stations[sta_id].sta.key.key_offset, + &il->ucode_key_table)) + IL_ERR(il, "index %d not used in uCode key table.\n", + il->stations[sta_id].sta.key.key_offset); + memset(&il->stations[sta_id].keyinfo, 0, sizeof(struct il_hw_key)); - memset(&priv->stations[sta_id].sta.key, 0, + memset(&il->stations[sta_id].sta.key, 0, sizeof(struct il4965_keyinfo)); - priv->stations[sta_id].sta.key.key_flags = + il->stations[sta_id].sta.key.key_flags = STA_KEY_FLG_NO_ENC | STA_KEY_FLG_INVALID; - priv->stations[sta_id].sta.key.key_offset = WEP_INVALID_OFFSET; - priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; - priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + il->stations[sta_id].sta.key.key_offset = WEP_INVALID_OFFSET; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - if (il_is_rfkill(priv)) { - IL_DEBUG_WEP(priv, + if (il_is_rfkill(il)) { + IL_DEBUG_WEP(il, "Not sending REPLY_ADD_STA command because RFKILL enabled.\n"); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } - memcpy(&sta_cmd, &priv->stations[sta_id].sta, + memcpy(&sta_cmd, &il->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); - return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } -int il4965_set_dynamic_key(struct il_priv *priv, struct il_rxon_context *ctx, +int il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, u8 sta_id) { int ret; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); ctx->key_mapping_keys++; keyconf->hw_key_idx = HW_KEY_DYNAMIC; switch (keyconf->cipher) { case WLAN_CIPHER_SUITE_CCMP: - ret = il4965_set_ccmp_dynamic_key_info(priv, ctx, + ret = il4965_set_ccmp_dynamic_key_info(il, ctx, keyconf, sta_id); break; case WLAN_CIPHER_SUITE_TKIP: - ret = il4965_set_tkip_dynamic_key_info(priv, ctx, + ret = il4965_set_tkip_dynamic_key_info(il, ctx, keyconf, sta_id); break; case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP104: - ret = il4965_set_wep_dynamic_key_info(priv, ctx, + ret = il4965_set_wep_dynamic_key_info(il, ctx, keyconf, sta_id); break; default: - IL_ERR(priv, + IL_ERR(il, "Unknown alg: %s cipher = %x\n", __func__, keyconf->cipher); ret = -EINVAL; } - IL_DEBUG_WEP(priv, + IL_DEBUG_WEP(il, "Set dynamic key: cipher=%x len=%d idx=%d sta=%d ret=%d\n", keyconf->cipher, keyconf->keylen, keyconf->keyidx, sta_id, ret); @@ -546,37 +546,37 @@ int il4965_set_dynamic_key(struct il_priv *priv, struct il_rxon_context *ctx, * and marks it driver active, so that it will be restored to the * device at the next best time. */ -int il4965_alloc_bcast_station(struct il_priv *priv, +int il4965_alloc_bcast_station(struct il_priv *il, struct il_rxon_context *ctx) { struct il_link_quality_cmd *link_cmd; unsigned long flags; u8 sta_id; - spin_lock_irqsave(&priv->sta_lock, flags); - sta_id = il_prep_station(priv, ctx, iwlegacy_bcast_addr, + spin_lock_irqsave(&il->sta_lock, flags); + sta_id = il_prep_station(il, ctx, iwlegacy_bcast_addr, false, NULL); if (sta_id == IL_INVALID_STATION) { - IL_ERR(priv, "Unable to prepare broadcast station\n"); - spin_unlock_irqrestore(&priv->sta_lock, flags); + IL_ERR(il, "Unable to prepare broadcast station\n"); + spin_unlock_irqrestore(&il->sta_lock, flags); return -EINVAL; } - priv->stations[sta_id].used |= IL_STA_DRIVER_ACTIVE; - priv->stations[sta_id].used |= IL_STA_BCAST; - spin_unlock_irqrestore(&priv->sta_lock, flags); + il->stations[sta_id].used |= IL_STA_DRIVER_ACTIVE; + il->stations[sta_id].used |= IL_STA_BCAST; + spin_unlock_irqrestore(&il->sta_lock, flags); - link_cmd = il4965_sta_alloc_lq(priv, sta_id); + link_cmd = il4965_sta_alloc_lq(il, sta_id); if (!link_cmd) { - IL_ERR(priv, + IL_ERR(il, "Unable to initialize rate scaling for bcast station.\n"); return -ENOMEM; } - spin_lock_irqsave(&priv->sta_lock, flags); - priv->stations[sta_id].lq = link_cmd; - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].lq = link_cmd; + spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } @@ -587,39 +587,39 @@ int il4965_alloc_bcast_station(struct il_priv *priv, * Only used by iwl4965. Placed here to have all bcast station management * code together. */ -static int il4965_update_bcast_station(struct il_priv *priv, +static int il4965_update_bcast_station(struct il_priv *il, struct il_rxon_context *ctx) { unsigned long flags; struct il_link_quality_cmd *link_cmd; u8 sta_id = ctx->bcast_sta_id; - link_cmd = il4965_sta_alloc_lq(priv, sta_id); + link_cmd = il4965_sta_alloc_lq(il, sta_id); if (!link_cmd) { - IL_ERR(priv, + IL_ERR(il, "Unable to initialize rate scaling for bcast station.\n"); return -ENOMEM; } - spin_lock_irqsave(&priv->sta_lock, flags); - if (priv->stations[sta_id].lq) - kfree(priv->stations[sta_id].lq); + spin_lock_irqsave(&il->sta_lock, flags); + if (il->stations[sta_id].lq) + kfree(il->stations[sta_id].lq); else - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "Bcast station rate scaling has not been initialized yet.\n"); - priv->stations[sta_id].lq = link_cmd; - spin_unlock_irqrestore(&priv->sta_lock, flags); + il->stations[sta_id].lq = link_cmd; + spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } -int il4965_update_bcast_stations(struct il_priv *priv) +int il4965_update_bcast_stations(struct il_priv *il) { struct il_rxon_context *ctx; int ret = 0; - for_each_context(priv, ctx) { - ret = il4965_update_bcast_station(priv, ctx); + for_each_context(il, ctx) { + ret = il4965_update_bcast_station(il, ctx); if (ret) break; } @@ -630,92 +630,92 @@ int il4965_update_bcast_stations(struct il_priv *priv) /** * il4965_sta_tx_modify_enable_tid - Enable Tx for this TID in station table */ -int il4965_sta_tx_modify_enable_tid(struct il_priv *priv, int sta_id, int tid) +int il4965_sta_tx_modify_enable_tid(struct il_priv *il, int sta_id, int tid) { unsigned long flags; struct il_addsta_cmd sta_cmd; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); /* Remove "disable" flag, to enable Tx for this TID */ - spin_lock_irqsave(&priv->sta_lock, flags); - priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_TID_DISABLE_TX; - priv->stations[sta_id].sta.tid_disable_tx &= cpu_to_le16(~(1 << tid)); - priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - memcpy(&sta_cmd, &priv->stations[sta_id].sta, + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_TID_DISABLE_TX; + il->stations[sta_id].sta.tid_disable_tx &= cpu_to_le16(~(1 << tid)); + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + memcpy(&sta_cmd, &il->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); - return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } -int il4965_sta_rx_agg_start(struct il_priv *priv, struct ieee80211_sta *sta, +int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta, int tid, u16 ssn) { unsigned long flags; int sta_id; struct il_addsta_cmd sta_cmd; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); sta_id = il_sta_id(sta); if (sta_id == IL_INVALID_STATION) return -ENXIO; - spin_lock_irqsave(&priv->sta_lock, flags); - priv->stations[sta_id].sta.station_flags_msk = 0; - priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_ADDBA_TID_MSK; - priv->stations[sta_id].sta.add_immediate_ba_tid = (u8)tid; - priv->stations[sta_id].sta.add_immediate_ba_ssn = cpu_to_le16(ssn); - priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - memcpy(&sta_cmd, &priv->stations[sta_id].sta, + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].sta.station_flags_msk = 0; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_ADDBA_TID_MSK; + il->stations[sta_id].sta.add_immediate_ba_tid = (u8)tid; + il->stations[sta_id].sta.add_immediate_ba_ssn = cpu_to_le16(ssn); + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + memcpy(&sta_cmd, &il->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); - return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } -int il4965_sta_rx_agg_stop(struct il_priv *priv, struct ieee80211_sta *sta, +int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta, int tid) { unsigned long flags; int sta_id; struct il_addsta_cmd sta_cmd; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); sta_id = il_sta_id(sta); if (sta_id == IL_INVALID_STATION) { - IL_ERR(priv, "Invalid station for AGG tid %d\n", tid); + IL_ERR(il, "Invalid station for AGG tid %d\n", tid); return -ENXIO; } - spin_lock_irqsave(&priv->sta_lock, flags); - priv->stations[sta_id].sta.station_flags_msk = 0; - priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_DELBA_TID_MSK; - priv->stations[sta_id].sta.remove_immediate_ba_tid = (u8)tid; - priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - memcpy(&sta_cmd, &priv->stations[sta_id].sta, + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].sta.station_flags_msk = 0; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_DELBA_TID_MSK; + il->stations[sta_id].sta.remove_immediate_ba_tid = (u8)tid; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + memcpy(&sta_cmd, &il->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); - return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } void -il4965_sta_modify_sleep_tx_count(struct il_priv *priv, int sta_id, int cnt) +il4965_sta_modify_sleep_tx_count(struct il_priv *il, int sta_id, int cnt) { unsigned long flags; - spin_lock_irqsave(&priv->sta_lock, flags); - priv->stations[sta_id].sta.station_flags |= STA_FLG_PWR_SAVE_MSK; - priv->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK; - priv->stations[sta_id].sta.sta.modify_mask = + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].sta.station_flags |= STA_FLG_PWR_SAVE_MSK; + il->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_SLEEP_TX_COUNT_MSK; - priv->stations[sta_id].sta.sleep_tx_count = cpu_to_le16(cnt); - priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - il_send_add_sta(priv, - &priv->stations[sta_id].sta, CMD_ASYNC); - spin_unlock_irqrestore(&priv->sta_lock, flags); + il->stations[sta_id].sta.sleep_tx_count = cpu_to_le16(cnt); + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + il_send_add_sta(il, + &il->stations[sta_id].sta, CMD_ASYNC); + spin_unlock_irqrestore(&il->sta_lock, flags); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index 3fdb9d9201dd..59d737496b5c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -99,7 +99,7 @@ il4965_get_fifo_from_tid(struct il_rxon_context *ctx, u16 tid) /* * handle build REPLY_TX command notification. */ -static void il4965_tx_cmd_build_basic(struct il_priv *priv, +static void il4965_tx_cmd_build_basic(struct il_priv *il, struct sk_buff *skb, struct il_tx_cmd *tx_cmd, struct ieee80211_tx_info *info, @@ -137,7 +137,7 @@ static void il4965_tx_cmd_build_basic(struct il_priv *priv, tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; } - il_tx_cmd_protection(priv, info, fc, &tx_flags); + il_tx_cmd_protection(il, info, fc, &tx_flags); tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); if (ieee80211_is_mgmt(fc)) { @@ -156,7 +156,7 @@ static void il4965_tx_cmd_build_basic(struct il_priv *priv, #define RTS_DFAULT_RETRY_LIMIT 60 -static void il4965_tx_cmd_build_rate(struct il_priv *priv, +static void il4965_tx_cmd_build_rate(struct il_priv *il, struct il_tx_cmd *tx_cmd, struct ieee80211_tx_info *info, __le16 fc) @@ -197,7 +197,7 @@ static void il4965_tx_cmd_build_rate(struct il_priv *priv, rate_idx = info->control.rates[0].idx; if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS || (rate_idx < 0) || (rate_idx > IL_RATE_COUNT_LEGACY)) - rate_idx = rate_lowest_index(&priv->bands[info->band], + rate_idx = rate_lowest_index(&il->bands[info->band], info->control.sta); /* For 5 GHZ band, remap mac80211 rate indices into driver indices */ if (info->band == IEEE80211_BAND_5GHZ) @@ -212,16 +212,16 @@ static void il4965_tx_cmd_build_rate(struct il_priv *priv, rate_flags |= RATE_MCS_CCK_MSK; /* Set up antennas */ - priv->mgmt_tx_ant = il4965_toggle_tx_ant(priv, priv->mgmt_tx_ant, - priv->hw_params.valid_tx_ant); + il->mgmt_tx_ant = il4965_toggle_tx_ant(il, il->mgmt_tx_ant, + il->hw_params.valid_tx_ant); - rate_flags |= il4965_ant_idx_to_flags(priv->mgmt_tx_ant); + rate_flags |= il4965_ant_idx_to_flags(il->mgmt_tx_ant); /* Set the rate in the TX cmd */ tx_cmd->rate_n_flags = il4965_hw_set_rate_n_flags(rate_plcp, rate_flags); } -static void il4965_tx_cmd_build_hwcrypto(struct il_priv *priv, +static void il4965_tx_cmd_build_hwcrypto(struct il_priv *il, struct ieee80211_tx_info *info, struct il_tx_cmd *tx_cmd, struct sk_buff *skb_frag, @@ -235,13 +235,13 @@ static void il4965_tx_cmd_build_hwcrypto(struct il_priv *priv, memcpy(tx_cmd->key, keyconf->key, keyconf->keylen); if (info->flags & IEEE80211_TX_CTL_AMPDU) tx_cmd->tx_flags |= TX_CMD_FLG_AGG_CCMP_MSK; - IL_DEBUG_TX(priv, "tx_cmd with AES hwcrypto\n"); + IL_DEBUG_TX(il, "tx_cmd with AES hwcrypto\n"); break; case WLAN_CIPHER_SUITE_TKIP: tx_cmd->sec_ctl = TX_CMD_SEC_TKIP; ieee80211_get_tkip_p2k(keyconf, skb_frag, tx_cmd->key); - IL_DEBUG_TX(priv, "tx_cmd with tkip hwcrypto\n"); + IL_DEBUG_TX(il, "tx_cmd with tkip hwcrypto\n"); break; case WLAN_CIPHER_SUITE_WEP104: @@ -253,12 +253,12 @@ static void il4965_tx_cmd_build_hwcrypto(struct il_priv *priv, memcpy(&tx_cmd->key[3], keyconf->key, keyconf->keylen); - IL_DEBUG_TX(priv, "Configuring packet for WEP encryption " + IL_DEBUG_TX(il, "Configuring packet for WEP encryption " "with key %d\n", keyconf->keyidx); break; default: - IL_ERR(priv, "Unknown encode cipher %x\n", keyconf->cipher); + IL_ERR(il, "Unknown encode cipher %x\n", keyconf->cipher); break; } } @@ -266,7 +266,7 @@ static void il4965_tx_cmd_build_hwcrypto(struct il_priv *priv, /* * start REPLY_TX command process */ -int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) +int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); @@ -277,7 +277,7 @@ int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) struct il_device_cmd *out_cmd; struct il_cmd_meta *out_meta; struct il_tx_cmd *tx_cmd; - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; int txq_id; dma_addr_t phys_addr; dma_addr_t txcmd_phys; @@ -296,9 +296,9 @@ int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) if (info->control.vif) ctx = il_rxon_ctx_from_vif(info->control.vif); - spin_lock_irqsave(&priv->lock, flags); - if (il_is_rfkill(priv)) { - IL_DEBUG_DROP(priv, "Dropping - RF KILL\n"); + spin_lock_irqsave(&il->lock, flags); + if (il_is_rfkill(il)) { + IL_DEBUG_DROP(il, "Dropping - RF KILL\n"); goto drop_unlock; } @@ -306,11 +306,11 @@ int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG if (ieee80211_is_auth(fc)) - IL_DEBUG_TX(priv, "Sending AUTH frame\n"); + IL_DEBUG_TX(il, "Sending AUTH frame\n"); else if (ieee80211_is_assoc_req(fc)) - IL_DEBUG_TX(priv, "Sending ASSOC frame\n"); + IL_DEBUG_TX(il, "Sending ASSOC frame\n"); else if (ieee80211_is_reassoc_req(fc)) - IL_DEBUG_TX(priv, "Sending REASSOC frame\n"); + IL_DEBUG_TX(il, "Sending REASSOC frame\n"); #endif hdr_len = ieee80211_hdrlen(fc); @@ -320,16 +320,16 @@ int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) sta_id = ctx->bcast_sta_id; else { /* Find index into station table for destination station */ - sta_id = il_sta_id_or_broadcast(priv, ctx, info->control.sta); + sta_id = il_sta_id_or_broadcast(il, ctx, info->control.sta); if (sta_id == IL_INVALID_STATION) { - IL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", + IL_DEBUG_DROP(il, "Dropping - INVALID STATION: %pM\n", hdr->addr1); goto drop_unlock; } } - IL_DEBUG_TX(priv, "station Id %d\n", sta_id); + IL_DEBUG_TX(il, "station Id %d\n", sta_id); if (sta) sta_priv = (void *)sta->drv_priv; @@ -345,7 +345,7 @@ int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) * For now set the counter to just 1 since we do not * support uAPSD yet. */ - il4965_sta_modify_sleep_tx_count(priv, sta_id, 1); + il4965_sta_modify_sleep_tx_count(il, sta_id, 1); } /* @@ -363,17 +363,17 @@ int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) } else txq_id = ctx->ac_to_queue[skb_get_queue_mapping(skb)]; - /* irqs already disabled/saved above when locking priv->lock */ - spin_lock(&priv->sta_lock); + /* irqs already disabled/saved above when locking il->lock */ + spin_lock(&il->sta_lock); if (ieee80211_is_data_qos(fc)) { qc = ieee80211_get_qos_ctl(hdr); tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK; if (WARN_ON_ONCE(tid >= MAX_TID_COUNT)) { - spin_unlock(&priv->sta_lock); + spin_unlock(&il->sta_lock); goto drop_unlock; } - seq_number = priv->stations[sta_id].tid[tid].seq_number; + seq_number = il->stations[sta_id].tid[tid].seq_number; seq_number &= IEEE80211_SCTL_SEQ; hdr->seq_ctrl = hdr->seq_ctrl & cpu_to_le16(IEEE80211_SCTL_FRAG); @@ -381,27 +381,27 @@ int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) seq_number += 0x10; /* aggregation is on for this */ if (info->flags & IEEE80211_TX_CTL_AMPDU && - priv->stations[sta_id].tid[tid].agg.state == IL_AGG_ON) { - txq_id = priv->stations[sta_id].tid[tid].agg.txq_id; + il->stations[sta_id].tid[tid].agg.state == IL_AGG_ON) { + txq_id = il->stations[sta_id].tid[tid].agg.txq_id; is_agg = true; } } - txq = &priv->txq[txq_id]; + txq = &il->txq[txq_id]; q = &txq->q; if (unlikely(il_queue_space(q) < q->high_mark)) { - spin_unlock(&priv->sta_lock); + spin_unlock(&il->sta_lock); goto drop_unlock; } if (ieee80211_is_data_qos(fc)) { - priv->stations[sta_id].tid[tid].tfds_in_queue++; + il->stations[sta_id].tid[tid].tfds_in_queue++; if (!ieee80211_has_morefrags(fc)) - priv->stations[sta_id].tid[tid].seq_number = seq_number; + il->stations[sta_id].tid[tid].seq_number = seq_number; } - spin_unlock(&priv->sta_lock); + spin_unlock(&il->sta_lock); /* Set up driver data for this TFD */ memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct il_tx_info)); @@ -434,15 +434,15 @@ int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) tx_cmd->len = cpu_to_le16(len); if (info->control.hw_key) - il4965_tx_cmd_build_hwcrypto(priv, info, tx_cmd, skb, sta_id); + il4965_tx_cmd_build_hwcrypto(il, info, tx_cmd, skb, sta_id); /* TODO need this for burst mode later on */ - il4965_tx_cmd_build_basic(priv, skb, tx_cmd, info, hdr, sta_id); - il_dbg_log_tx_data_frame(priv, len, hdr); + il4965_tx_cmd_build_basic(il, skb, tx_cmd, info, hdr, sta_id); + il_dbg_log_tx_data_frame(il, len, hdr); - il4965_tx_cmd_build_rate(priv, tx_cmd, info, fc); + il4965_tx_cmd_build_rate(il, tx_cmd, info, fc); - il_update_stats(priv, true, fc, len); + il_update_stats(il, true, fc, len); /* * Use the first empty entry in this queue's command buffer array * to contain the Tx command and MAC header concatenated together @@ -462,14 +462,14 @@ int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) /* Physical address of this Tx command's header (not MAC header!), * within command buffer array. */ - txcmd_phys = pci_map_single(priv->pci_dev, + txcmd_phys = pci_map_single(il->pci_dev, &out_cmd->hdr, firstlen, PCI_DMA_BIDIRECTIONAL); dma_unmap_addr_set(out_meta, mapping, txcmd_phys); dma_unmap_len_set(out_meta, len, firstlen); /* Add buffer containing Tx command and MAC(!) header to TFD's * first entry */ - priv->cfg->ops->lib->txq_attach_buf_to_tfd(priv, txq, + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, txcmd_phys, firstlen, 1, 0); if (!ieee80211_has_morefrags(hdr->frame_control)) { @@ -483,9 +483,9 @@ int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) * if any (802.11 null frames have no payload). */ secondlen = skb->len - hdr_len; if (secondlen > 0) { - phys_addr = pci_map_single(priv->pci_dev, skb->data + hdr_len, + phys_addr = pci_map_single(il->pci_dev, skb->data + hdr_len, secondlen, PCI_DMA_TODEVICE); - priv->cfg->ops->lib->txq_attach_buf_to_tfd(priv, txq, + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr, secondlen, 0, 0); } @@ -494,29 +494,29 @@ int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) offsetof(struct il_tx_cmd, scratch); /* take back ownership of DMA buffer to enable update */ - pci_dma_sync_single_for_cpu(priv->pci_dev, txcmd_phys, + pci_dma_sync_single_for_cpu(il->pci_dev, txcmd_phys, firstlen, PCI_DMA_BIDIRECTIONAL); tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys); tx_cmd->dram_msb_ptr = il_get_dma_hi_addr(scratch_phys); - IL_DEBUG_TX(priv, "sequence nr = 0X%x\n", + IL_DEBUG_TX(il, "sequence nr = 0X%x\n", le16_to_cpu(out_cmd->hdr.sequence)); - IL_DEBUG_TX(priv, "tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); - il_print_hex_dump(priv, IL_DL_TX, (u8 *)tx_cmd, sizeof(*tx_cmd)); - il_print_hex_dump(priv, IL_DL_TX, (u8 *)tx_cmd->hdr, hdr_len); + IL_DEBUG_TX(il, "tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); + il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd, sizeof(*tx_cmd)); + il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd->hdr, hdr_len); /* Set up entry for this TFD in Tx byte-count array */ if (info->flags & IEEE80211_TX_CTL_AMPDU) - priv->cfg->ops->lib->txq_update_byte_cnt_tbl(priv, txq, + il->cfg->ops->lib->txq_update_byte_cnt_tbl(il, txq, le16_to_cpu(tx_cmd->len)); - pci_dma_sync_single_for_device(priv->pci_dev, txcmd_phys, + pci_dma_sync_single_for_device(il->pci_dev, txcmd_phys, firstlen, PCI_DMA_BIDIRECTIONAL); /* Tell device the write index *just past* this latest filled TFD */ q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); - il_txq_update_write_ptr(priv, txq); - spin_unlock_irqrestore(&priv->lock, flags); + il_txq_update_write_ptr(il, txq); + spin_unlock_irqrestore(&il->lock, flags); /* * At this point the frame is "transmitted" successfully @@ -536,28 +536,28 @@ int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb) atomic_inc(&sta_priv->pending_frames); if ((il_queue_space(q) < q->high_mark) && - priv->mac80211_registered) { + il->mac80211_registered) { if (wait_write_ptr) { - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); txq->need_update = 1; - il_txq_update_write_ptr(priv, txq); - spin_unlock_irqrestore(&priv->lock, flags); + il_txq_update_write_ptr(il, txq); + spin_unlock_irqrestore(&il->lock, flags); } else { - il_stop_queue(priv, txq); + il_stop_queue(il, txq); } } return 0; drop_unlock: - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); return -1; } -static inline int il4965_alloc_dma_ptr(struct il_priv *priv, +static inline int il4965_alloc_dma_ptr(struct il_priv *il, struct il_dma_ptr *ptr, size_t size) { - ptr->addr = dma_alloc_coherent(&priv->pci_dev->dev, size, &ptr->dma, + ptr->addr = dma_alloc_coherent(&il->pci_dev->dev, size, &ptr->dma, GFP_KERNEL); if (!ptr->addr) return -ENOMEM; @@ -565,13 +565,13 @@ static inline int il4965_alloc_dma_ptr(struct il_priv *priv, return 0; } -static inline void il4965_free_dma_ptr(struct il_priv *priv, +static inline void il4965_free_dma_ptr(struct il_priv *il, struct il_dma_ptr *ptr) { if (unlikely(!ptr->addr)) return; - dma_free_coherent(&priv->pci_dev->dev, ptr->size, ptr->addr, ptr->dma); + dma_free_coherent(&il->pci_dev->dev, ptr->size, ptr->addr, ptr->dma); memset(ptr, 0, sizeof(*ptr)); } @@ -580,79 +580,79 @@ static inline void il4965_free_dma_ptr(struct il_priv *priv, * * Destroy all TX DMA queues and structures */ -void il4965_hw_txq_ctx_free(struct il_priv *priv) +void il4965_hw_txq_ctx_free(struct il_priv *il) { int txq_id; /* Tx queues */ - if (priv->txq) { - for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) - if (txq_id == priv->cmd_queue) - il_cmd_queue_free(priv); + if (il->txq) { + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) + if (txq_id == il->cmd_queue) + il_cmd_queue_free(il); else - il_tx_queue_free(priv, txq_id); + il_tx_queue_free(il, txq_id); } - il4965_free_dma_ptr(priv, &priv->kw); + il4965_free_dma_ptr(il, &il->kw); - il4965_free_dma_ptr(priv, &priv->scd_bc_tbls); + il4965_free_dma_ptr(il, &il->scd_bc_tbls); /* free tx queue structure */ - il_txq_mem(priv); + il_txq_mem(il); } /** * il4965_txq_ctx_alloc - allocate TX queue context * Allocate all Tx DMA structures and initialize them * - * @param priv + * @param il * @return error code */ -int il4965_txq_ctx_alloc(struct il_priv *priv) +int il4965_txq_ctx_alloc(struct il_priv *il) { int ret; int txq_id, slots_num; unsigned long flags; /* Free all tx/cmd queues and keep-warm buffer */ - il4965_hw_txq_ctx_free(priv); + il4965_hw_txq_ctx_free(il); - ret = il4965_alloc_dma_ptr(priv, &priv->scd_bc_tbls, - priv->hw_params.scd_bc_tbls_size); + ret = il4965_alloc_dma_ptr(il, &il->scd_bc_tbls, + il->hw_params.scd_bc_tbls_size); if (ret) { - IL_ERR(priv, "Scheduler BC Table allocation failed\n"); + IL_ERR(il, "Scheduler BC Table allocation failed\n"); goto error_bc_tbls; } /* Alloc keep-warm buffer */ - ret = il4965_alloc_dma_ptr(priv, &priv->kw, IL_KW_SIZE); + ret = il4965_alloc_dma_ptr(il, &il->kw, IL_KW_SIZE); if (ret) { - IL_ERR(priv, "Keep Warm allocation failed\n"); + IL_ERR(il, "Keep Warm allocation failed\n"); goto error_kw; } /* allocate tx queue structure */ - ret = il_alloc_txq_mem(priv); + ret = il_alloc_txq_mem(il); if (ret) goto error; - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); /* Turn off all Tx DMA fifos */ - il4965_txq_set_sched(priv, 0); + il4965_txq_set_sched(il, 0); /* Tell NIC where to find the "keep warm" buffer */ - il_write_direct32(priv, FH_KW_MEM_ADDR_REG, priv->kw.dma >> 4); + il_write_direct32(il, FH_KW_MEM_ADDR_REG, il->kw.dma >> 4); - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); /* Alloc and init all Tx queues, including the command queue (#4/#9) */ - for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { - slots_num = (txq_id == priv->cmd_queue) ? + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { + slots_num = (txq_id == il->cmd_queue) ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - ret = il_tx_queue_init(priv, - &priv->txq[txq_id], slots_num, + ret = il_tx_queue_init(il, + &il->txq[txq_id], slots_num, txq_id); if (ret) { - IL_ERR(priv, "Tx %d queue init failed\n", txq_id); + IL_ERR(il, "Tx %d queue init failed\n", txq_id); goto error; } } @@ -660,34 +660,34 @@ int il4965_txq_ctx_alloc(struct il_priv *priv) return ret; error: - il4965_hw_txq_ctx_free(priv); - il4965_free_dma_ptr(priv, &priv->kw); + il4965_hw_txq_ctx_free(il); + il4965_free_dma_ptr(il, &il->kw); error_kw: - il4965_free_dma_ptr(priv, &priv->scd_bc_tbls); + il4965_free_dma_ptr(il, &il->scd_bc_tbls); error_bc_tbls: return ret; } -void il4965_txq_ctx_reset(struct il_priv *priv) +void il4965_txq_ctx_reset(struct il_priv *il) { int txq_id, slots_num; unsigned long flags; - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); /* Turn off all Tx DMA fifos */ - il4965_txq_set_sched(priv, 0); + il4965_txq_set_sched(il, 0); /* Tell NIC where to find the "keep warm" buffer */ - il_write_direct32(priv, FH_KW_MEM_ADDR_REG, priv->kw.dma >> 4); + il_write_direct32(il, FH_KW_MEM_ADDR_REG, il->kw.dma >> 4); - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); /* Alloc and init all Tx queues, including the command queue (#4) */ - for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) { - slots_num = txq_id == priv->cmd_queue ? + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { + slots_num = txq_id == il->cmd_queue ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - il_tx_queue_reset(priv, &priv->txq[txq_id], + il_tx_queue_reset(il, &il->txq[txq_id], slots_num, txq_id); } } @@ -695,39 +695,39 @@ void il4965_txq_ctx_reset(struct il_priv *priv) /** * il4965_txq_ctx_stop - Stop all Tx DMA channels */ -void il4965_txq_ctx_stop(struct il_priv *priv) +void il4965_txq_ctx_stop(struct il_priv *il) { int ch, txq_id; unsigned long flags; /* Turn off all Tx DMA fifos */ - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); - il4965_txq_set_sched(priv, 0); + il4965_txq_set_sched(il, 0); /* Stop each Tx DMA channel, and wait for it to be idle */ - for (ch = 0; ch < priv->hw_params.dma_chnl_num; ch++) { - il_write_direct32(priv, + for (ch = 0; ch < il->hw_params.dma_chnl_num; ch++) { + il_write_direct32(il, FH_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0); - if (il_poll_direct_bit(priv, FH_TSSR_TX_STATUS_REG, + if (il_poll_direct_bit(il, FH_TSSR_TX_STATUS_REG, FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), 1000)) - IL_ERR(priv, "Failing on timeout while stopping" + IL_ERR(il, "Failing on timeout while stopping" " DMA channel %d [0x%08x]", ch, - il_read_direct32(priv, + il_read_direct32(il, FH_TSSR_TX_STATUS_REG)); } - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); - if (!priv->txq) + if (!il->txq) return; /* Unmap DMA from host system and free skb's */ - for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) - if (txq_id == priv->cmd_queue) - il_cmd_queue_unmap(priv); + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) + if (txq_id == il->cmd_queue) + il_cmd_queue_unmap(il); else - il_tx_queue_unmap(priv, txq_id); + il_tx_queue_unmap(il, txq_id); } /* @@ -736,12 +736,12 @@ void il4965_txq_ctx_stop(struct il_priv *priv) * Should never return anything < 7, because they should already * be in use as EDCA AC (0-3), Command (4), reserved (5, 6) */ -static int il4965_txq_ctx_activate_free(struct il_priv *priv) +static int il4965_txq_ctx_activate_free(struct il_priv *il) { int txq_id; - for (txq_id = 0; txq_id < priv->hw_params.max_txq_num; txq_id++) - if (!test_and_set_bit(txq_id, &priv->txq_ctx_active_msk)) + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) + if (!test_and_set_bit(txq_id, &il->txq_ctx_active_msk)) return txq_id; return -1; } @@ -749,12 +749,12 @@ static int il4965_txq_ctx_activate_free(struct il_priv *priv) /** * il4965_tx_queue_stop_scheduler - Stop queue, but keep configuration */ -static void il4965_tx_queue_stop_scheduler(struct il_priv *priv, +static void il4965_tx_queue_stop_scheduler(struct il_priv *il, u16 txq_id) { /* Simply stop the queue, but don't change any configuration; * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */ - il_write_prph(priv, + il_write_prph(il, IWL49_SCD_QUEUE_STATUS_BITS(txq_id), (0 << IWL49_SCD_QUEUE_STTS_REG_POS_ACTIVE)| (1 << IWL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); @@ -763,7 +763,7 @@ static void il4965_tx_queue_stop_scheduler(struct il_priv *priv, /** * il4965_tx_queue_set_q2ratid - Map unique receiver/tid combination to a queue */ -static int il4965_tx_queue_set_q2ratid(struct il_priv *priv, u16 ra_tid, +static int il4965_tx_queue_set_q2ratid(struct il_priv *il, u16 ra_tid, u16 txq_id) { u32 tbl_dw_addr; @@ -772,17 +772,17 @@ static int il4965_tx_queue_set_q2ratid(struct il_priv *priv, u16 ra_tid, scd_q2ratid = ra_tid & IL_SCD_QUEUE_RA_TID_MAP_RATID_MSK; - tbl_dw_addr = priv->scd_base_addr + + tbl_dw_addr = il->scd_base_addr + IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id); - tbl_dw = il_read_targ_mem(priv, tbl_dw_addr); + tbl_dw = il_read_targ_mem(il, tbl_dw_addr); if (txq_id & 0x1) tbl_dw = (scd_q2ratid << 16) | (tbl_dw & 0x0000FFFF); else tbl_dw = scd_q2ratid | (tbl_dw & 0xFFFF0000); - il_write_targ_mem(priv, tbl_dw_addr, tbl_dw); + il_write_targ_mem(il, tbl_dw_addr, tbl_dw); return 0; } @@ -793,7 +793,7 @@ static int il4965_tx_queue_set_q2ratid(struct il_priv *priv, u16 ra_tid, * NOTE: txq_id must be greater than IWL49_FIRST_AMPDU_QUEUE, * i.e. it must be one of the higher queues used for aggregation */ -static int il4965_txq_agg_enable(struct il_priv *priv, int txq_id, +static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, int tx_fifo, int sta_id, int tid, u16 ssn_idx) { unsigned long flags; @@ -802,62 +802,62 @@ static int il4965_txq_agg_enable(struct il_priv *priv, int txq_id, if ((IWL49_FIRST_AMPDU_QUEUE > txq_id) || (IWL49_FIRST_AMPDU_QUEUE + - priv->cfg->base_params->num_of_ampdu_queues <= txq_id)) { - IL_WARN(priv, + il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { + IL_WARN(il, "queue number out of range: %d, must be %d to %d\n", txq_id, IWL49_FIRST_AMPDU_QUEUE, IWL49_FIRST_AMPDU_QUEUE + - priv->cfg->base_params->num_of_ampdu_queues - 1); + il->cfg->base_params->num_of_ampdu_queues - 1); return -EINVAL; } ra_tid = BUILD_RAxTID(sta_id, tid); /* Modify device's station table to Tx this TID */ - ret = il4965_sta_tx_modify_enable_tid(priv, sta_id, tid); + ret = il4965_sta_tx_modify_enable_tid(il, sta_id, tid); if (ret) return ret; - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); /* Stop this Tx queue before configuring it */ - il4965_tx_queue_stop_scheduler(priv, txq_id); + il4965_tx_queue_stop_scheduler(il, txq_id); /* Map receiver-address / traffic-ID to this queue */ - il4965_tx_queue_set_q2ratid(priv, ra_tid, txq_id); + il4965_tx_queue_set_q2ratid(il, ra_tid, txq_id); /* Set this queue as a chain-building queue */ - il_set_bits_prph(priv, IWL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); + il_set_bits_prph(il, IWL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); /* Place first TFD at index corresponding to start sequence number. * Assumes that ssn_idx is valid (!= 0xFFF) */ - priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); - priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); - il4965_set_wr_ptrs(priv, txq_id, ssn_idx); + il->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); + il->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); + il4965_set_wr_ptrs(il, txq_id, ssn_idx); /* Set up Tx window size and frame limit for this queue */ - il_write_targ_mem(priv, - priv->scd_base_addr + IWL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id), + il_write_targ_mem(il, + il->scd_base_addr + IWL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id), (SCD_WIN_SIZE << IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); - il_write_targ_mem(priv, priv->scd_base_addr + + il_write_targ_mem(il, il->scd_base_addr + IWL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id) + sizeof(u32), (SCD_FRAME_LIMIT << IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) & IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); - il_set_bits_prph(priv, IWL49_SCD_INTERRUPT_MASK, (1 << txq_id)); + il_set_bits_prph(il, IWL49_SCD_INTERRUPT_MASK, (1 << txq_id)); /* Set up Status area in SRAM, map to Tx DMA/FIFO, activate the queue */ - il4965_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 1); + il4965_tx_queue_set_status(il, &il->txq[txq_id], tx_fifo, 1); - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); return 0; } -int il4965_tx_agg_start(struct il_priv *priv, struct ieee80211_vif *vif, +int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, struct ieee80211_sta *sta, u16 tid, u16 *ssn) { int sta_id; @@ -871,94 +871,94 @@ int il4965_tx_agg_start(struct il_priv *priv, struct ieee80211_vif *vif, if (unlikely(tx_fifo < 0)) return tx_fifo; - IL_WARN(priv, "%s on ra = %pM tid = %d\n", + IL_WARN(il, "%s on ra = %pM tid = %d\n", __func__, sta->addr, tid); sta_id = il_sta_id(sta); if (sta_id == IL_INVALID_STATION) { - IL_ERR(priv, "Start AGG on invalid station\n"); + IL_ERR(il, "Start AGG on invalid station\n"); return -ENXIO; } if (unlikely(tid >= MAX_TID_COUNT)) return -EINVAL; - if (priv->stations[sta_id].tid[tid].agg.state != IL_AGG_OFF) { - IL_ERR(priv, "Start AGG when state is not IL_AGG_OFF !\n"); + if (il->stations[sta_id].tid[tid].agg.state != IL_AGG_OFF) { + IL_ERR(il, "Start AGG when state is not IL_AGG_OFF !\n"); return -ENXIO; } - txq_id = il4965_txq_ctx_activate_free(priv); + txq_id = il4965_txq_ctx_activate_free(il); if (txq_id == -1) { - IL_ERR(priv, "No free aggregation queue available\n"); + IL_ERR(il, "No free aggregation queue available\n"); return -ENXIO; } - spin_lock_irqsave(&priv->sta_lock, flags); - tid_data = &priv->stations[sta_id].tid[tid]; + spin_lock_irqsave(&il->sta_lock, flags); + tid_data = &il->stations[sta_id].tid[tid]; *ssn = SEQ_TO_SN(tid_data->seq_number); tid_data->agg.txq_id = txq_id; - il_set_swq_id(&priv->txq[txq_id], + il_set_swq_id(&il->txq[txq_id], il4965_get_ac_from_tid(tid), txq_id); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); - ret = il4965_txq_agg_enable(priv, txq_id, tx_fifo, + ret = il4965_txq_agg_enable(il, txq_id, tx_fifo, sta_id, tid, *ssn); if (ret) return ret; - spin_lock_irqsave(&priv->sta_lock, flags); - tid_data = &priv->stations[sta_id].tid[tid]; + spin_lock_irqsave(&il->sta_lock, flags); + tid_data = &il->stations[sta_id].tid[tid]; if (tid_data->tfds_in_queue == 0) { - IL_DEBUG_HT(priv, "HW queue is empty\n"); + IL_DEBUG_HT(il, "HW queue is empty\n"); tid_data->agg.state = IL_AGG_ON; ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid); } else { - IL_DEBUG_HT(priv, + IL_DEBUG_HT(il, "HW queue is NOT empty: %d packets in HW queue\n", tid_data->tfds_in_queue); tid_data->agg.state = IL_EMPTYING_HW_QUEUE_ADDBA; } - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); return ret; } /** * txq_id must be greater than IWL49_FIRST_AMPDU_QUEUE - * priv->lock must be held by the caller + * il->lock must be held by the caller */ -static int il4965_txq_agg_disable(struct il_priv *priv, u16 txq_id, +static int il4965_txq_agg_disable(struct il_priv *il, u16 txq_id, u16 ssn_idx, u8 tx_fifo) { if ((IWL49_FIRST_AMPDU_QUEUE > txq_id) || (IWL49_FIRST_AMPDU_QUEUE + - priv->cfg->base_params->num_of_ampdu_queues <= txq_id)) { - IL_WARN(priv, + il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { + IL_WARN(il, "queue number out of range: %d, must be %d to %d\n", txq_id, IWL49_FIRST_AMPDU_QUEUE, IWL49_FIRST_AMPDU_QUEUE + - priv->cfg->base_params->num_of_ampdu_queues - 1); + il->cfg->base_params->num_of_ampdu_queues - 1); return -EINVAL; } - il4965_tx_queue_stop_scheduler(priv, txq_id); + il4965_tx_queue_stop_scheduler(il, txq_id); - il_clear_bits_prph(priv, + il_clear_bits_prph(il, IWL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); - priv->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); - priv->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); + il->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); + il->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); /* supposes that ssn_idx is valid (!= 0xFFF) */ - il4965_set_wr_ptrs(priv, txq_id, ssn_idx); + il4965_set_wr_ptrs(il, txq_id, ssn_idx); - il_clear_bits_prph(priv, + il_clear_bits_prph(il, IWL49_SCD_INTERRUPT_MASK, (1 << txq_id)); - il_txq_ctx_deactivate(priv, txq_id); - il4965_tx_queue_set_status(priv, &priv->txq[txq_id], tx_fifo, 0); + il_txq_ctx_deactivate(il, txq_id); + il4965_tx_queue_set_status(il, &il->txq[txq_id], tx_fifo, 0); return 0; } -int il4965_tx_agg_stop(struct il_priv *priv, struct ieee80211_vif *vif, +int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, struct ieee80211_sta *sta, u16 tid) { int tx_fifo_id, txq_id, sta_id, ssn; @@ -973,17 +973,17 @@ int il4965_tx_agg_stop(struct il_priv *priv, struct ieee80211_vif *vif, sta_id = il_sta_id(sta); if (sta_id == IL_INVALID_STATION) { - IL_ERR(priv, "Invalid station for AGG tid %d\n", tid); + IL_ERR(il, "Invalid station for AGG tid %d\n", tid); return -ENXIO; } - spin_lock_irqsave(&priv->sta_lock, flags); + spin_lock_irqsave(&il->sta_lock, flags); - tid_data = &priv->stations[sta_id].tid[tid]; + tid_data = &il->stations[sta_id].tid[tid]; ssn = (tid_data->seq_number & IEEE80211_SCTL_SEQ) >> 4; txq_id = tid_data->agg.txq_id; - switch (priv->stations[sta_id].tid[tid].agg.state) { + switch (il->stations[sta_id].tid[tid].agg.state) { case IL_EMPTYING_HW_QUEUE_ADDBA: /* * This can happen if the peer stops aggregation @@ -991,33 +991,33 @@ int il4965_tx_agg_stop(struct il_priv *priv, struct ieee80211_vif *vif, * queue we selected previously, i.e. before the * session was really started completely. */ - IL_DEBUG_HT(priv, "AGG stop before setup done\n"); + IL_DEBUG_HT(il, "AGG stop before setup done\n"); goto turn_off; case IL_AGG_ON: break; default: - IL_WARN(priv, "Stopping AGG while state not ON or starting\n"); + IL_WARN(il, "Stopping AGG while state not ON or starting\n"); } - write_ptr = priv->txq[txq_id].q.write_ptr; - read_ptr = priv->txq[txq_id].q.read_ptr; + write_ptr = il->txq[txq_id].q.write_ptr; + read_ptr = il->txq[txq_id].q.read_ptr; /* The queue is not empty */ if (write_ptr != read_ptr) { - IL_DEBUG_HT(priv, "Stopping a non empty AGG HW QUEUE\n"); - priv->stations[sta_id].tid[tid].agg.state = + IL_DEBUG_HT(il, "Stopping a non empty AGG HW QUEUE\n"); + il->stations[sta_id].tid[tid].agg.state = IL_EMPTYING_HW_QUEUE_DELBA; - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } - IL_DEBUG_HT(priv, "HW queue is empty\n"); + IL_DEBUG_HT(il, "HW queue is empty\n"); turn_off: - priv->stations[sta_id].tid[tid].agg.state = IL_AGG_OFF; + il->stations[sta_id].tid[tid].agg.state = IL_AGG_OFF; /* do not restore/save irqs */ - spin_unlock(&priv->sta_lock); - spin_lock(&priv->lock); + spin_unlock(&il->sta_lock); + spin_lock(&il->lock); /* * the only reason this call can fail is queue number out of range, @@ -1026,27 +1026,27 @@ int il4965_tx_agg_stop(struct il_priv *priv, struct ieee80211_vif *vif, * to deactivate the uCode queue, just return "success" to allow * mac80211 to clean up it own data. */ - il4965_txq_agg_disable(priv, txq_id, ssn, tx_fifo_id); - spin_unlock_irqrestore(&priv->lock, flags); + il4965_txq_agg_disable(il, txq_id, ssn, tx_fifo_id); + spin_unlock_irqrestore(&il->lock, flags); ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); return 0; } -int il4965_txq_check_empty(struct il_priv *priv, +int il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id) { - struct il_queue *q = &priv->txq[txq_id].q; - u8 *addr = priv->stations[sta_id].sta.sta.addr; - struct il_tid_data *tid_data = &priv->stations[sta_id].tid[tid]; + struct il_queue *q = &il->txq[txq_id].q; + u8 *addr = il->stations[sta_id].sta.sta.addr; + struct il_tid_data *tid_data = &il->stations[sta_id].tid[tid]; struct il_rxon_context *ctx; - ctx = &priv->contexts[priv->stations[sta_id].ctxid]; + ctx = &il->contexts[il->stations[sta_id].ctxid]; - lockdep_assert_held(&priv->sta_lock); + lockdep_assert_held(&il->sta_lock); - switch (priv->stations[sta_id].tid[tid].agg.state) { + switch (il->stations[sta_id].tid[tid].agg.state) { case IL_EMPTYING_HW_QUEUE_DELBA: /* We are reclaiming the last packet of the */ /* aggregated HW queue */ @@ -1054,9 +1054,9 @@ int il4965_txq_check_empty(struct il_priv *priv, (q->read_ptr == q->write_ptr)) { u16 ssn = SEQ_TO_SN(tid_data->seq_number); int tx_fifo = il4965_get_fifo_from_tid(ctx, tid); - IL_DEBUG_HT(priv, + IL_DEBUG_HT(il, "HW queue empty: continue DELBA flow\n"); - il4965_txq_agg_disable(priv, txq_id, ssn, tx_fifo); + il4965_txq_agg_disable(il, txq_id, ssn, tx_fifo); tid_data->agg.state = IL_AGG_OFF; ieee80211_stop_tx_ba_cb_irqsafe(ctx->vif, addr, tid); } @@ -1064,7 +1064,7 @@ int il4965_txq_check_empty(struct il_priv *priv, case IL_EMPTYING_HW_QUEUE_ADDBA: /* We are reclaiming the last packet of the queue */ if (tid_data->tfds_in_queue == 0) { - IL_DEBUG_HT(priv, + IL_DEBUG_HT(il, "HW queue empty: continue ADDBA flow\n"); tid_data->agg.state = IL_AGG_ON; ieee80211_start_tx_ba_cb_irqsafe(ctx->vif, addr, tid); @@ -1075,7 +1075,7 @@ int il4965_txq_check_empty(struct il_priv *priv, return 0; } -static void il4965_non_agg_tx_status(struct il_priv *priv, +static void il4965_non_agg_tx_status(struct il_priv *il, struct il_rxon_context *ctx, const u8 *addr1) { @@ -1089,33 +1089,33 @@ static void il4965_non_agg_tx_status(struct il_priv *priv, /* avoid atomic ops if this isn't a client */ if (sta_priv->client && atomic_dec_return(&sta_priv->pending_frames) == 0) - ieee80211_sta_block_awake(priv->hw, sta, false); + ieee80211_sta_block_awake(il->hw, sta, false); } rcu_read_unlock(); } static void -il4965_tx_status(struct il_priv *priv, struct il_tx_info *tx_info, +il4965_tx_status(struct il_priv *il, struct il_tx_info *tx_info, bool is_agg) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx_info->skb->data; if (!is_agg) - il4965_non_agg_tx_status(priv, tx_info->ctx, hdr->addr1); + il4965_non_agg_tx_status(il, tx_info->ctx, hdr->addr1); - ieee80211_tx_status_irqsafe(priv->hw, tx_info->skb); + ieee80211_tx_status_irqsafe(il->hw, tx_info->skb); } -int il4965_tx_queue_reclaim(struct il_priv *priv, int txq_id, int index) +int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int index) { - struct il_tx_queue *txq = &priv->txq[txq_id]; + struct il_tx_queue *txq = &il->txq[txq_id]; struct il_queue *q = &txq->q; struct il_tx_info *tx_info; int nfreed = 0; struct ieee80211_hdr *hdr; if ((index >= q->n_bd) || (il_queue_used(q, index) == 0)) { - IL_ERR(priv, "Read index for DMA queue txq id (%d), index %d, " + IL_ERR(il, "Read index for DMA queue txq id (%d), index %d, " "is out of range [0-%d] %d %d.\n", txq_id, index, q->n_bd, q->write_ptr, q->read_ptr); return 0; @@ -1134,11 +1134,11 @@ int il4965_tx_queue_reclaim(struct il_priv *priv, int txq_id, int index) if (ieee80211_is_data_qos(hdr->frame_control)) nfreed++; - il4965_tx_status(priv, tx_info, + il4965_tx_status(il, tx_info, txq_id >= IWL4965_FIRST_AMPDU_QUEUE); tx_info->skb = NULL; - priv->cfg->ops->lib->txq_free_tfd(priv, txq); + il->cfg->ops->lib->txq_free_tfd(il, txq); } return nfreed; } @@ -1149,7 +1149,7 @@ int il4965_tx_queue_reclaim(struct il_priv *priv, int txq_id, int index) * Go through block-ack's bitmap of ACK'd frames, update driver's record of * ACK vs. not. This gets sent to mac80211, then to rate scaling algo. */ -static int il4965_tx_status_reply_compressed_ba(struct il_priv *priv, +static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, struct il_ht_agg *agg, struct il_compressed_ba_resp *ba_resp) @@ -1163,13 +1163,13 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *priv, if (unlikely(!agg->wait_for_ba)) { if (unlikely(ba_resp->bitmap)) - IL_ERR(priv, "Received BA when not expected\n"); + IL_ERR(il, "Received BA when not expected\n"); return -EINVAL; } /* Mark that the expected block-ack response arrived */ agg->wait_for_ba = 0; - IL_DEBUG_TX_REPLY(priv, "BA %d %d\n", agg->start_idx, + IL_DEBUG_TX_REPLY(il, "BA %d %d\n", agg->start_idx, ba_resp->seq_ctl); /* Calculate shift to align block-ack bits with our Tx window bits */ @@ -1178,7 +1178,7 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *priv, sh += 0x100; if (agg->frame_count > (64 - sh)) { - IL_DEBUG_TX_REPLY(priv, "more frames than bitmap size"); + IL_DEBUG_TX_REPLY(il, "more frames than bitmap size"); return -1; } @@ -1195,7 +1195,7 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *priv, while (sent_bitmap) { ack = sent_bitmap & 1ULL; successes += ack; - IL_DEBUG_TX_REPLY(priv, "%s ON i=%d idx=%d raw=%d\n", + IL_DEBUG_TX_REPLY(il, "%s ON i=%d idx=%d raw=%d\n", ack ? "ACK" : "NACK", i, (agg->start_idx + i) & 0xff, agg->start_idx + i); @@ -1203,16 +1203,16 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *priv, ++i; } - IL_DEBUG_TX_REPLY(priv, "Bitmap %llx\n", + IL_DEBUG_TX_REPLY(il, "Bitmap %llx\n", (unsigned long long)bitmap); - info = IEEE80211_SKB_CB(priv->txq[scd_flow].txb[agg->start_idx].skb); + info = IEEE80211_SKB_CB(il->txq[scd_flow].txb[agg->start_idx].skb); memset(&info->status, 0, sizeof(info->status)); info->flags |= IEEE80211_TX_STAT_ACK; info->flags |= IEEE80211_TX_STAT_AMPDU; info->status.ampdu_ack_len = successes; info->status.ampdu_len = agg->frame_count; - il4965_hwrate_to_tx_control(priv, agg->rate_n_flags, info); + il4965_hwrate_to_tx_control(il, agg->rate_n_flags, info); return 0; } @@ -1220,7 +1220,7 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *priv, /** * translate ucode response to mac80211 tx status control values */ -void il4965_hwrate_to_tx_control(struct il_priv *priv, u32 rate_n_flags, +void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, struct ieee80211_tx_info *info) { struct ieee80211_tx_rate *r = &info->control.rates[0]; @@ -1246,7 +1246,7 @@ void il4965_hwrate_to_tx_control(struct il_priv *priv, u32 rate_n_flags, * Handles block-acknowledge notification from device, which reports success * of frames sent via aggregation. */ -void il4965_rx_reply_compressed_ba(struct il_priv *priv, +void il4965_rx_reply_compressed_ba(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); @@ -1265,16 +1265,16 @@ void il4965_rx_reply_compressed_ba(struct il_priv *priv, * (in Tx queue's circular buffer) of first TFD/frame in window */ u16 ba_resp_scd_ssn = le16_to_cpu(ba_resp->scd_ssn); - if (scd_flow >= priv->hw_params.max_txq_num) { - IL_ERR(priv, + if (scd_flow >= il->hw_params.max_txq_num) { + IL_ERR(il, "BUG_ON scd_flow is bigger than number of queues\n"); return; } - txq = &priv->txq[scd_flow]; + txq = &il->txq[scd_flow]; sta_id = ba_resp->sta_id; tid = ba_resp->tid; - agg = &priv->stations[sta_id].tid[tid].agg; + agg = &il->stations[sta_id].tid[tid].agg; if (unlikely(agg->txq_id != scd_flow)) { /* * FIXME: this is a uCode bug which need to be addressed, @@ -1282,7 +1282,7 @@ void il4965_rx_reply_compressed_ba(struct il_priv *priv, * since it is possible happen very often and in order * not to fill the syslog, don't enable the logging by default */ - IL_DEBUG_TX_REPLY(priv, + IL_DEBUG_TX_REPLY(il, "BA scd_flow %d does not match txq_id %d\n", scd_flow, agg->txq_id); return; @@ -1291,14 +1291,14 @@ void il4965_rx_reply_compressed_ba(struct il_priv *priv, /* Find index just before block-ack window */ index = il_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd); - spin_lock_irqsave(&priv->sta_lock, flags); + spin_lock_irqsave(&il->sta_lock, flags); - IL_DEBUG_TX_REPLY(priv, "REPLY_COMPRESSED_BA [%d] Received from %pM, " + IL_DEBUG_TX_REPLY(il, "REPLY_COMPRESSED_BA [%d] Received from %pM, " "sta_id = %d\n", agg->wait_for_ba, (u8 *) &ba_resp->sta_addr_lo32, ba_resp->sta_id); - IL_DEBUG_TX_REPLY(priv, "TID = %d, SeqCtl = %d, bitmap = 0x%llx," + IL_DEBUG_TX_REPLY(il, "TID = %d, SeqCtl = %d, bitmap = 0x%llx," "scd_flow = " "%d, scd_ssn = %d\n", ba_resp->tid, @@ -1306,30 +1306,30 @@ void il4965_rx_reply_compressed_ba(struct il_priv *priv, (unsigned long long)le64_to_cpu(ba_resp->bitmap), ba_resp->scd_flow, ba_resp->scd_ssn); - IL_DEBUG_TX_REPLY(priv, "DAT start_idx = %d, bitmap = 0x%llx\n", + IL_DEBUG_TX_REPLY(il, "DAT start_idx = %d, bitmap = 0x%llx\n", agg->start_idx, (unsigned long long)agg->bitmap); /* Update driver's record of ACK vs. not for each frame in window */ - il4965_tx_status_reply_compressed_ba(priv, agg, ba_resp); + il4965_tx_status_reply_compressed_ba(il, agg, ba_resp); /* Release all TFDs before the SSN, i.e. all TFDs in front of * block-ack window (we assume that they've been successfully * transmitted ... if not, it's too late anyway). */ if (txq->q.read_ptr != (ba_resp_scd_ssn & 0xff)) { /* calculate mac80211 ampdu sw queue to wake */ - int freed = il4965_tx_queue_reclaim(priv, scd_flow, index); - il4965_free_tfds_in_queue(priv, sta_id, tid, freed); + int freed = il4965_tx_queue_reclaim(il, scd_flow, index); + il4965_free_tfds_in_queue(il, sta_id, tid, freed); if ((il_queue_space(&txq->q) > txq->q.low_mark) && - priv->mac80211_registered && + il->mac80211_registered && (agg->state != IL_EMPTYING_HW_QUEUE_DELBA)) - il_wake_queue(priv, txq); + il_wake_queue(il, txq); - il4965_txq_check_empty(priv, sta_id, tid, scd_flow); + il4965_txq_check_empty(il, sta_id, tid, scd_flow); } - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c index 3c9df1bb5afe..d4dc597452ea 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c @@ -48,22 +48,22 @@ * it's a pretty good bet that everything between them is good, too. */ static int -il4965_verify_inst_sparse(struct il_priv *priv, __le32 *image, u32 len) +il4965_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) { u32 val; int ret = 0; u32 errcnt = 0; u32 i; - IL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); + IL_DEBUG_INFO(il, "ucode inst image size is %u\n", len); for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log * if IL_DL_IO is set */ - il_write_direct32(priv, HBUS_TARG_MEM_RADDR, + il_write_direct32(il, HBUS_TARG_MEM_RADDR, i + IWL4965_RTC_INST_LOWER_BOUND); - val = _il_read_direct32(priv, HBUS_TARG_MEM_RDAT); + val = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { ret = -EIO; errcnt++; @@ -79,7 +79,7 @@ il4965_verify_inst_sparse(struct il_priv *priv, __le32 *image, u32 len) * il4965_verify_inst_full - verify runtime uCode image in card vs. host, * looking at all data. */ -static int il4965_verify_inst_full(struct il_priv *priv, __le32 *image, +static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) { u32 val; @@ -87,9 +87,9 @@ static int il4965_verify_inst_full(struct il_priv *priv, __le32 *image, int ret = 0; u32 errcnt; - IL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); + IL_DEBUG_INFO(il, "ucode inst image size is %u\n", len); - il_write_direct32(priv, HBUS_TARG_MEM_RADDR, + il_write_direct32(il, HBUS_TARG_MEM_RADDR, IWL4965_RTC_INST_LOWER_BOUND); errcnt = 0; @@ -97,9 +97,9 @@ static int il4965_verify_inst_full(struct il_priv *priv, __le32 *image, /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log * if IL_DL_IO is set */ - val = _il_read_direct32(priv, HBUS_TARG_MEM_RDAT); + val = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { - IL_ERR(priv, "uCode INST section is invalid at " + IL_ERR(il, "uCode INST section is invalid at " "offset 0x%x, is 0x%x, s/b 0x%x\n", save_len - len, val, le32_to_cpu(*image)); ret = -EIO; @@ -110,7 +110,7 @@ static int il4965_verify_inst_full(struct il_priv *priv, __le32 *image, } if (!errcnt) - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "ucode image in INSTRUCTION memory is good\n"); return ret; @@ -120,47 +120,47 @@ static int il4965_verify_inst_full(struct il_priv *priv, __le32 *image, * il4965_verify_ucode - determine which instruction image is in SRAM, * and verify its contents */ -int il4965_verify_ucode(struct il_priv *priv) +int il4965_verify_ucode(struct il_priv *il) { __le32 *image; u32 len; int ret; /* Try bootstrap */ - image = (__le32 *)priv->ucode_boot.v_addr; - len = priv->ucode_boot.len; - ret = il4965_verify_inst_sparse(priv, image, len); + image = (__le32 *)il->ucode_boot.v_addr; + len = il->ucode_boot.len; + ret = il4965_verify_inst_sparse(il, image, len); if (!ret) { - IL_DEBUG_INFO(priv, "Bootstrap uCode is good in inst SRAM\n"); + IL_DEBUG_INFO(il, "Bootstrap uCode is good in inst SRAM\n"); return 0; } /* Try initialize */ - image = (__le32 *)priv->ucode_init.v_addr; - len = priv->ucode_init.len; - ret = il4965_verify_inst_sparse(priv, image, len); + image = (__le32 *)il->ucode_init.v_addr; + len = il->ucode_init.len; + ret = il4965_verify_inst_sparse(il, image, len); if (!ret) { - IL_DEBUG_INFO(priv, "Initialize uCode is good in inst SRAM\n"); + IL_DEBUG_INFO(il, "Initialize uCode is good in inst SRAM\n"); return 0; } /* Try runtime/protocol */ - image = (__le32 *)priv->ucode_code.v_addr; - len = priv->ucode_code.len; - ret = il4965_verify_inst_sparse(priv, image, len); + image = (__le32 *)il->ucode_code.v_addr; + len = il->ucode_code.len; + ret = il4965_verify_inst_sparse(il, image, len); if (!ret) { - IL_DEBUG_INFO(priv, "Runtime uCode is good in inst SRAM\n"); + IL_DEBUG_INFO(il, "Runtime uCode is good in inst SRAM\n"); return 0; } - IL_ERR(priv, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); + IL_ERR(il, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); /* Since nothing seems to match, show first several data entries in * instruction SRAM, so maybe visual inspection will give a clue. * Selection of bootstrap image (vs. other images) is arbitrary. */ - image = (__le32 *)priv->ucode_boot.v_addr; - len = priv->ucode_boot.len; - ret = il4965_verify_inst_full(priv, image, len); + image = (__le32 *)il->ucode_boot.v_addr; + len = il->ucode_boot.len; + ret = il4965_verify_inst_full(il, image, len); return ret; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index 0f2bc5f767da..d3c818354ca5 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -48,8 +48,8 @@ #include "iwl-4965.h" #include "iwl-4965-debugfs.h" -static int il4965_send_tx_power(struct il_priv *priv); -static int il4965_hw_get_temperature(struct il_priv *priv); +static int il4965_send_tx_power(struct il_priv *il); +static int il4965_hw_get_temperature(struct il_priv *il); /* Highest firmware API version supported */ #define IWL4965_UCODE_API_MAX 2 @@ -62,23 +62,23 @@ static int il4965_hw_get_temperature(struct il_priv *priv); #define IWL4965_MODULE_FIRMWARE(api) _IWL4965_MODULE_FIRMWARE(api) /* check contents of special bootstrap uCode SRAM */ -static int il4965_verify_bsm(struct il_priv *priv) +static int il4965_verify_bsm(struct il_priv *il) { - __le32 *image = priv->ucode_boot.v_addr; - u32 len = priv->ucode_boot.len; + __le32 *image = il->ucode_boot.v_addr; + u32 len = il->ucode_boot.len; u32 reg; u32 val; - IL_DEBUG_INFO(priv, "Begin verify bsm\n"); + IL_DEBUG_INFO(il, "Begin verify bsm\n"); /* verify BSM SRAM contents */ - val = il_read_prph(priv, BSM_WR_DWCOUNT_REG); + val = il_read_prph(il, BSM_WR_DWCOUNT_REG); for (reg = BSM_SRAM_LOWER_BOUND; reg < BSM_SRAM_LOWER_BOUND + len; reg += sizeof(u32), image++) { - val = il_read_prph(priv, reg); + val = il_read_prph(il, reg); if (val != le32_to_cpu(*image)) { - IL_ERR(priv, "BSM uCode verification failed at " + IL_ERR(il, "BSM uCode verification failed at " "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", BSM_SRAM_LOWER_BOUND, reg - BSM_SRAM_LOWER_BOUND, len, @@ -87,7 +87,7 @@ static int il4965_verify_bsm(struct il_priv *priv) } } - IL_DEBUG_INFO(priv, "BSM bootstrap uCode image OK\n"); + IL_DEBUG_INFO(il, "BSM bootstrap uCode image OK\n"); return 0; } @@ -124,10 +124,10 @@ static int il4965_verify_bsm(struct il_priv *priv) * the runtime uCode instructions and the backup data cache into SRAM, * and re-launches the runtime uCode from where it left off. */ -static int il4965_load_bsm(struct il_priv *priv) +static int il4965_load_bsm(struct il_priv *il) { - __le32 *image = priv->ucode_boot.v_addr; - u32 len = priv->ucode_boot.len; + __le32 *image = il->ucode_boot.v_addr; + u32 len = il->ucode_boot.len; dma_addr_t pinst; dma_addr_t pdata; u32 inst_len; @@ -137,9 +137,9 @@ static int il4965_load_bsm(struct il_priv *priv) u32 reg_offset; int ret; - IL_DEBUG_INFO(priv, "Begin load bsm\n"); + IL_DEBUG_INFO(il, "Begin load bsm\n"); - priv->ucode_type = UCODE_RT; + il->ucode_type = UCODE_RT; /* make sure bootstrap program is no larger than BSM's SRAM size */ if (len > IWL49_MAX_BSM_SIZE) @@ -151,53 +151,53 @@ static int il4965_load_bsm(struct il_priv *priv) * after the "initialize" uCode has run, to point to * runtime/protocol instructions and backup data cache. */ - pinst = priv->ucode_init.p_addr >> 4; - pdata = priv->ucode_init_data.p_addr >> 4; - inst_len = priv->ucode_init.len; - data_len = priv->ucode_init_data.len; + pinst = il->ucode_init.p_addr >> 4; + pdata = il->ucode_init_data.p_addr >> 4; + inst_len = il->ucode_init.len; + data_len = il->ucode_init_data.len; - il_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); - il_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); - il_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); - il_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); + il_write_prph(il, BSM_DRAM_INST_PTR_REG, pinst); + il_write_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); + il_write_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); + il_write_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); /* Fill BSM memory with bootstrap instructions */ for (reg_offset = BSM_SRAM_LOWER_BOUND; reg_offset < BSM_SRAM_LOWER_BOUND + len; reg_offset += sizeof(u32), image++) - _il_write_prph(priv, reg_offset, le32_to_cpu(*image)); + _il_write_prph(il, reg_offset, le32_to_cpu(*image)); - ret = il4965_verify_bsm(priv); + ret = il4965_verify_bsm(il); if (ret) return ret; /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ - il_write_prph(priv, BSM_WR_MEM_SRC_REG, 0x0); - il_write_prph(priv, + il_write_prph(il, BSM_WR_MEM_SRC_REG, 0x0); + il_write_prph(il, BSM_WR_MEM_DST_REG, IWL49_RTC_INST_LOWER_BOUND); - il_write_prph(priv, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); + il_write_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); /* Load bootstrap code into instruction SRAM now, * to prepare to load "initialize" uCode */ - il_write_prph(priv, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START); + il_write_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START); /* Wait for load of bootstrap uCode to finish */ for (i = 0; i < 100; i++) { - done = il_read_prph(priv, BSM_WR_CTRL_REG); + done = il_read_prph(il, BSM_WR_CTRL_REG); if (!(done & BSM_WR_CTRL_REG_BIT_START)) break; udelay(10); } if (i < 100) - IL_DEBUG_INFO(priv, "BSM write complete, poll %d iterations\n", i); + IL_DEBUG_INFO(il, "BSM write complete, poll %d iterations\n", i); else { - IL_ERR(priv, "BSM write did not complete!\n"); + IL_ERR(il, "BSM write did not complete!\n"); return -EIO; } /* Enable future boot loads whenever power management unit triggers it * (e.g. when powering back up after power-save shutdown) */ - il_write_prph(priv, + il_write_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN); @@ -213,27 +213,27 @@ static int il4965_load_bsm(struct il_priv *priv) * We need to replace them to load runtime uCode inst and data, * and to save runtime data when powering down. */ -static int il4965_set_ucode_ptrs(struct il_priv *priv) +static int il4965_set_ucode_ptrs(struct il_priv *il) { dma_addr_t pinst; dma_addr_t pdata; int ret = 0; /* bits 35:4 for 4965 */ - pinst = priv->ucode_code.p_addr >> 4; - pdata = priv->ucode_data_backup.p_addr >> 4; + pinst = il->ucode_code.p_addr >> 4; + pdata = il->ucode_data_backup.p_addr >> 4; /* Tell bootstrap uCode where to find image to load */ - il_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); - il_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); - il_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, - priv->ucode_data.len); + il_write_prph(il, BSM_DRAM_INST_PTR_REG, pinst); + il_write_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); + il_write_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, + il->ucode_data.len); /* Inst byte count must be last to set up, bit 31 signals uCode * that all new ptr/size info is in place */ - il_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, - priv->ucode_code.len | BSM_DRAM_INST_LOAD); - IL_DEBUG_INFO(priv, "Runtime uCode pointers are set.\n"); + il_write_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, + il->ucode_code.len | BSM_DRAM_INST_LOAD); + IL_DEBUG_INFO(il, "Runtime uCode pointers are set.\n"); return ret; } @@ -244,40 +244,40 @@ static int il4965_set_ucode_ptrs(struct il_priv *priv) * Called after REPLY_ALIVE notification received from "initialize" uCode. * * The 4965 "initialize" ALIVE reply contains calibration data for: - * Voltage, temperature, and MIMO tx gain correction, now stored in priv + * Voltage, temperature, and MIMO tx gain correction, now stored in il * (3945 does not contain this data). * * Tell "initialize" uCode to go ahead and load the runtime uCode. */ -static void il4965_init_alive_start(struct il_priv *priv) +static void il4965_init_alive_start(struct il_priv *il) { /* Bootstrap uCode has loaded initialize uCode ... verify inst image. * This is a paranoid check, because we would not have gotten the * "initialize" alive if code weren't properly loaded. */ - if (il4965_verify_ucode(priv)) { + if (il4965_verify_ucode(il)) { /* Runtime instruction load was bad; * take it all the way back down so we can try again */ - IL_DEBUG_INFO(priv, "Bad \"initialize\" uCode load.\n"); + IL_DEBUG_INFO(il, "Bad \"initialize\" uCode load.\n"); goto restart; } /* Calculate temperature */ - priv->temperature = il4965_hw_get_temperature(priv); + il->temperature = il4965_hw_get_temperature(il); /* Send pointers to protocol/runtime uCode image ... init code will * load and launch runtime uCode, which will send us another "Alive" * notification. */ - IL_DEBUG_INFO(priv, "Initialization Alive received.\n"); - if (il4965_set_ucode_ptrs(priv)) { + IL_DEBUG_INFO(il, "Initialization Alive received.\n"); + if (il4965_set_ucode_ptrs(il)) { /* Runtime instruction load won't happen; * take it all the way back down so we can try again */ - IL_DEBUG_INFO(priv, "Couldn't set up uCode pointers.\n"); + IL_DEBUG_INFO(il, "Couldn't set up uCode pointers.\n"); goto restart; } return; restart: - queue_work(priv->workqueue, &priv->restart); + queue_work(il->workqueue, &il->restart); } static bool iw4965_is_ht40_channel(__le32 rxon_flags) @@ -288,43 +288,43 @@ static bool iw4965_is_ht40_channel(__le32 rxon_flags) (chan_mod == CHANNEL_MODE_MIXED)); } -static void il4965_nic_config(struct il_priv *priv) +static void il4965_nic_config(struct il_priv *il) { unsigned long flags; u16 radio_cfg; - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); - radio_cfg = il_eeprom_query16(priv, EEPROM_RADIO_CONFIG); + radio_cfg = il_eeprom_query16(il, EEPROM_RADIO_CONFIG); /* write radio config values to register */ if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) == EEPROM_4965_RF_CFG_TYPE_MAX) - il_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(il, CSR_HW_IF_CONFIG_REG, EEPROM_RF_CFG_TYPE_MSK(radio_cfg) | EEPROM_RF_CFG_STEP_MSK(radio_cfg) | EEPROM_RF_CFG_DASH_MSK(radio_cfg)); /* set CSR_HW_CONFIG_REG for uCode use */ - il_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | CSR_HW_IF_CONFIG_REG_BIT_MAC_SI); - priv->calib_info = (struct il_eeprom_calib_info *) - il_eeprom_query_addr(priv, + il->calib_info = (struct il_eeprom_calib_info *) + il_eeprom_query_addr(il, EEPROM_4965_CALIB_TXPOWER_OFFSET); - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); } /* Reset differential Rx gains in NIC to prepare for chain noise calibration. * Called after every association, but this runs only once! * ... once chain noise is calibrated the first time, it's good forever. */ -static void il4965_chain_noise_reset(struct il_priv *priv) +static void il4965_chain_noise_reset(struct il_priv *il) { - struct il_chain_noise_data *data = &(priv->chain_noise_data); + struct il_chain_noise_data *data = &(il->chain_noise_data); if ((data->state == IL_CHAIN_NOISE_ALIVE) && - il_is_any_associated(priv)) { + il_is_any_associated(il)) { struct il_calib_diff_gain_cmd cmd; /* clear data for chain noise calibration algorithm */ @@ -341,12 +341,12 @@ static void il4965_chain_noise_reset(struct il_priv *priv) cmd.diff_gain_a = 0; cmd.diff_gain_b = 0; cmd.diff_gain_c = 0; - if (il_send_cmd_pdu(priv, REPLY_PHY_CALIBRATION_CMD, + if (il_send_cmd_pdu(il, REPLY_PHY_CALIBRATION_CMD, sizeof(cmd), &cmd)) - IL_ERR(priv, + IL_ERR(il, "Could not send REPLY_PHY_CALIBRATION_CMD\n"); data->state = IL_CHAIN_NOISE_ACCUMULATE; - IL_DEBUG_CALIB(priv, "Run chain_noise_calibrate\n"); + IL_DEBUG_CALIB(il, "Run chain_noise_calibrate\n"); } } @@ -377,10 +377,10 @@ static struct il_sensitivity_ranges il4965_sensitivity = { .nrg_th_cca = 62, }; -static void il4965_set_ct_threshold(struct il_priv *priv) +static void il4965_set_ct_threshold(struct il_priv *il) { /* want Kelvin */ - priv->hw_params.ct_kill_threshold = + il->hw_params.ct_kill_threshold = CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY); } @@ -389,37 +389,37 @@ static void il4965_set_ct_threshold(struct il_priv *priv) * * Called when initializing driver */ -static int il4965_hw_set_hw_params(struct il_priv *priv) +static int il4965_hw_set_hw_params(struct il_priv *il) { - if (priv->cfg->mod_params->num_of_queues >= IL_MIN_NUM_QUEUES && - priv->cfg->mod_params->num_of_queues <= IWL49_NUM_QUEUES) - priv->cfg->base_params->num_of_queues = - priv->cfg->mod_params->num_of_queues; - - priv->hw_params.max_txq_num = priv->cfg->base_params->num_of_queues; - priv->hw_params.dma_chnl_num = FH49_TCSR_CHNL_NUM; - priv->hw_params.scd_bc_tbls_size = - priv->cfg->base_params->num_of_queues * + if (il->cfg->mod_params->num_of_queues >= IL_MIN_NUM_QUEUES && + il->cfg->mod_params->num_of_queues <= IWL49_NUM_QUEUES) + il->cfg->base_params->num_of_queues = + il->cfg->mod_params->num_of_queues; + + il->hw_params.max_txq_num = il->cfg->base_params->num_of_queues; + il->hw_params.dma_chnl_num = FH49_TCSR_CHNL_NUM; + il->hw_params.scd_bc_tbls_size = + il->cfg->base_params->num_of_queues * sizeof(struct il4965_scd_bc_tbl); - priv->hw_params.tfd_size = sizeof(struct il_tfd); - priv->hw_params.max_stations = IWL4965_STATION_COUNT; - priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IWL4965_BROADCAST_ID; - priv->hw_params.max_data_size = IWL49_RTC_DATA_SIZE; - priv->hw_params.max_inst_size = IWL49_RTC_INST_SIZE; - priv->hw_params.max_bsm_size = BSM_SRAM_SIZE; - priv->hw_params.ht40_channel = BIT(IEEE80211_BAND_5GHZ); + il->hw_params.tfd_size = sizeof(struct il_tfd); + il->hw_params.max_stations = IWL4965_STATION_COUNT; + il->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IWL4965_BROADCAST_ID; + il->hw_params.max_data_size = IWL49_RTC_DATA_SIZE; + il->hw_params.max_inst_size = IWL49_RTC_INST_SIZE; + il->hw_params.max_bsm_size = BSM_SRAM_SIZE; + il->hw_params.ht40_channel = BIT(IEEE80211_BAND_5GHZ); - priv->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR; + il->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR; - priv->hw_params.tx_chains_num = il4965_num_of_ant(priv->cfg->valid_tx_ant); - priv->hw_params.rx_chains_num = il4965_num_of_ant(priv->cfg->valid_rx_ant); - priv->hw_params.valid_tx_ant = priv->cfg->valid_tx_ant; - priv->hw_params.valid_rx_ant = priv->cfg->valid_rx_ant; + il->hw_params.tx_chains_num = il4965_num_of_ant(il->cfg->valid_tx_ant); + il->hw_params.rx_chains_num = il4965_num_of_ant(il->cfg->valid_rx_ant); + il->hw_params.valid_tx_ant = il->cfg->valid_tx_ant; + il->hw_params.valid_rx_ant = il->cfg->valid_rx_ant; - il4965_set_ct_threshold(priv); + il4965_set_ct_threshold(il); - priv->hw_params.sens = &il4965_sensitivity; - priv->hw_params.beacon_time_tsf_bits = IWL4965_EXT_BEACON_TIME_POS; + il->hw_params.sens = &il4965_sensitivity; + il->hw_params.beacon_time_tsf_bits = IWL4965_EXT_BEACON_TIME_POS; return 0; } @@ -498,16 +498,16 @@ static s32 il4965_get_tx_atten_grp(u16 channel) return -EINVAL; } -static u32 il4965_get_sub_band(const struct il_priv *priv, u32 channel) +static u32 il4965_get_sub_band(const struct il_priv *il, u32 channel) { s32 b = -1; for (b = 0; b < EEPROM_TX_POWER_BANDS; b++) { - if (priv->calib_info->band_info[b].ch_from == 0) + if (il->calib_info->band_info[b].ch_from == 0) continue; - if ((channel >= priv->calib_info->band_info[b].ch_from) - && (channel <= priv->calib_info->band_info[b].ch_to)) + if ((channel >= il->calib_info->band_info[b].ch_from) + && (channel <= il->calib_info->band_info[b].ch_to)) break; } @@ -534,7 +534,7 @@ static s32 il4965_interpolate_value(s32 x, s32 x1, s32 y1, s32 x2, s32 y2) * differences in channel frequencies, which is proportional to differences * in channel number. */ -static int il4965_interpolate_chan(struct il_priv *priv, u32 channel, +static int il4965_interpolate_chan(struct il_priv *il, u32 channel, struct il_eeprom_calib_ch_info *chan_info) { s32 s = -1; @@ -546,24 +546,24 @@ static int il4965_interpolate_chan(struct il_priv *priv, u32 channel, u32 ch_i1; u32 ch_i2; - s = il4965_get_sub_band(priv, channel); + s = il4965_get_sub_band(il, channel); if (s >= EEPROM_TX_POWER_BANDS) { - IL_ERR(priv, "Tx Power can not find channel %d\n", channel); + IL_ERR(il, "Tx Power can not find channel %d\n", channel); return -1; } - ch_i1 = priv->calib_info->band_info[s].ch1.ch_num; - ch_i2 = priv->calib_info->band_info[s].ch2.ch_num; + ch_i1 = il->calib_info->band_info[s].ch1.ch_num; + ch_i2 = il->calib_info->band_info[s].ch2.ch_num; chan_info->ch_num = (u8) channel; - IL_DEBUG_TXPOWER(priv, "channel %d subband %d factory cal ch %d & %d\n", + IL_DEBUG_TXPOWER(il, "channel %d subband %d factory cal ch %d & %d\n", channel, s, ch_i1, ch_i2); for (c = 0; c < EEPROM_TX_POWER_TX_CHAINS; c++) { for (m = 0; m < EEPROM_TX_POWER_MEASUREMENTS; m++) { - m1 = &(priv->calib_info->band_info[s].ch1. + m1 = &(il->calib_info->band_info[s].ch1. measurements[c][m]); - m2 = &(priv->calib_info->band_info[s].ch2. + m2 = &(il->calib_info->band_info[s].ch2. measurements[c][m]); omeas = &(chan_info->measurements[c][m]); @@ -586,16 +586,16 @@ static int il4965_interpolate_chan(struct il_priv *priv, u32 channel, m1->pa_det, ch_i2, m2->pa_det); - IL_DEBUG_TXPOWER(priv, + IL_DEBUG_TXPOWER(il, "chain %d meas %d AP1=%d AP2=%d AP=%d\n", c, m, m1->actual_pow, m2->actual_pow, omeas->actual_pow); - IL_DEBUG_TXPOWER(priv, + IL_DEBUG_TXPOWER(il, "chain %d meas %d NI1=%d NI2=%d NI=%d\n", c, m, m1->gain_idx, m2->gain_idx, omeas->gain_idx); - IL_DEBUG_TXPOWER(priv, + IL_DEBUG_TXPOWER(il, "chain %d meas %d PA1=%d PA2=%d PA=%d\n", c, m, m1->pa_det, m2->pa_det, omeas->pa_det); - IL_DEBUG_TXPOWER(priv, + IL_DEBUG_TXPOWER(il, "chain %d meas %d T1=%d T2=%d T=%d\n", c, m, m1->temperature, m2->temperature, omeas->temperature); @@ -867,7 +867,7 @@ static const struct gain_entry gain_table[2][108] = { } }; -static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, +static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, u8 is_ht40, u8 ctrl_chan_high, struct il4965_tx_power_db *tx_power_tbl) { @@ -897,13 +897,13 @@ static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, /* tx_power_user_lmt is in dBm, convert to half-dBm (half-dB units * are used for indexing into txpower table) */ - user_target_power = 2 * priv->tx_power_user_lmt; + user_target_power = 2 * il->tx_power_user_lmt; /* Get current (RXON) channel, band, width */ - IL_DEBUG_TXPOWER(priv, "chan %d band %d is_ht40 %d\n", channel, band, + IL_DEBUG_TXPOWER(il, "chan %d band %d is_ht40 %d\n", channel, band, is_ht40); - ch_info = il_get_channel_info(priv, priv->band, channel); + ch_info = il_get_channel_info(il, il->band, channel); if (!il_is_channel_valid(ch_info)) return -EINVAL; @@ -912,12 +912,12 @@ static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, * and 2) mimo txpower balance between Tx chains. */ txatten_grp = il4965_get_tx_atten_grp(channel); if (txatten_grp < 0) { - IL_ERR(priv, "Can't find txatten group for channel %d.\n", + IL_ERR(il, "Can't find txatten group for channel %d.\n", channel); return txatten_grp; } - IL_DEBUG_TXPOWER(priv, "channel %d belongs to txatten group %d\n", + IL_DEBUG_TXPOWER(il, "channel %d belongs to txatten group %d\n", channel, txatten_grp); if (is_ht40) { @@ -930,9 +930,9 @@ static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, /* hardware txpower limits ... * saturation (clipping distortion) txpowers are in half-dBm */ if (band) - saturation_power = priv->calib_info->saturation_power24; + saturation_power = il->calib_info->saturation_power24; else - saturation_power = priv->calib_info->saturation_power52; + saturation_power = il->calib_info->saturation_power52; if (saturation_power < IL_TX_POWER_SATURATION_MIN || saturation_power > IL_TX_POWER_SATURATION_MAX) { @@ -959,21 +959,21 @@ static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, /* Interpolate txpower calibration values for this channel, * based on factory calibration tests on spaced channels. */ - il4965_interpolate_chan(priv, channel, &ch_eeprom_info); + il4965_interpolate_chan(il, channel, &ch_eeprom_info); /* calculate tx gain adjustment based on power supply voltage */ - voltage = le16_to_cpu(priv->calib_info->voltage); - init_voltage = (s32)le32_to_cpu(priv->card_alive_init.voltage); + voltage = le16_to_cpu(il->calib_info->voltage); + init_voltage = (s32)le32_to_cpu(il->card_alive_init.voltage); voltage_compensation = il4965_get_voltage_compensation(voltage, init_voltage); - IL_DEBUG_TXPOWER(priv, "curr volt %d eeprom volt %d volt comp %d\n", + IL_DEBUG_TXPOWER(il, "curr volt %d eeprom volt %d volt comp %d\n", init_voltage, voltage, voltage_compensation); /* get current temperature (Celsius) */ - current_temp = max(priv->temperature, IL_TX_POWER_TEMPERATURE_MIN); - current_temp = min(priv->temperature, IL_TX_POWER_TEMPERATURE_MAX); + current_temp = max(il->temperature, IL_TX_POWER_TEMPERATURE_MIN); + current_temp = min(il->temperature, IL_TX_POWER_TEMPERATURE_MAX); current_temp = KELVIN_TO_CELSIUS(current_temp); /* select thermal txpower adjustment params, based on channel group @@ -998,13 +998,13 @@ static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, factory_gain_index[c] = measurement->gain_idx; factory_actual_pwr[c] = measurement->actual_pow; - IL_DEBUG_TXPOWER(priv, "chain = %d\n", c); - IL_DEBUG_TXPOWER(priv, "fctry tmp %d, " + IL_DEBUG_TXPOWER(il, "chain = %d\n", c); + IL_DEBUG_TXPOWER(il, "fctry tmp %d, " "curr tmp %d, comp %d steps\n", factory_temp, current_temp, temperature_comp[c]); - IL_DEBUG_TXPOWER(priv, "fctry idx %d, fctry pwr %d\n", + IL_DEBUG_TXPOWER(il, "fctry idx %d, fctry pwr %d\n", factory_gain_index[c], factory_actual_pwr[c]); } @@ -1037,7 +1037,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, if (target_power > power_limit) target_power = power_limit; - IL_DEBUG_TXPOWER(priv, "rate %d sat %d reg %d usr %d tgt %d\n", + IL_DEBUG_TXPOWER(il, "rate %d sat %d reg %d usr %d tgt %d\n", i, saturation_power - back_off_table[i], current_regulatory, user_target_power, target_power); @@ -1048,7 +1048,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, if (is_mimo_rate) atten_value = - (s32)le32_to_cpu(priv->card_alive_init. + (s32)le32_to_cpu(il->card_alive_init. tx_atten[txatten_grp][c]); else atten_value = 0; @@ -1061,7 +1061,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, voltage_compensation + atten_value); -/* IL_DEBUG_TXPOWER(priv, "calculated txpower index %d\n", +/* IL_DEBUG_TXPOWER(il, "calculated txpower index %d\n", power_index); */ if (power_index < get_min_power_index(i, band)) @@ -1078,12 +1078,12 @@ static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, /* stay within the table! */ if (power_index > 107) { - IL_WARN(priv, "txpower index %d > 107\n", + IL_WARN(il, "txpower index %d > 107\n", power_index); power_index = 107; } if (power_index < 0) { - IL_WARN(priv, "txpower index %d < 0\n", + IL_WARN(il, "txpower index %d < 0\n", power_index); power_index = 0; } @@ -1094,7 +1094,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, tx_power.s.dsp_predis_atten[c] = gain_table[band][power_index].dsp; - IL_DEBUG_TXPOWER(priv, "chain %d mimo %d index %d " + IL_DEBUG_TXPOWER(il, "chain %d mimo %d index %d " "gain 0x%02x dsp %d\n", c, atten_value, power_index, tx_power.s.radio_tx_gain[c], @@ -1112,22 +1112,22 @@ static int il4965_fill_txpower_tbl(struct il_priv *priv, u8 band, u16 channel, * il4965_send_tx_power - Configure the TXPOWER level user limit * * Uses the active RXON for channel, band, and characteristics (ht40, high) - * The power limit is taken from priv->tx_power_user_lmt. + * The power limit is taken from il->tx_power_user_lmt. */ -static int il4965_send_tx_power(struct il_priv *priv) +static int il4965_send_tx_power(struct il_priv *il) { struct il4965_txpowertable_cmd cmd = { 0 }; int ret; u8 band = 0; bool is_ht40 = false; u8 ctrl_chan_high = 0; - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; - if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &priv->status), + if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &il->status), "TX Power requested while scanning!\n")) return -EAGAIN; - band = priv->band == IEEE80211_BAND_2GHZ; + band = il->band == IEEE80211_BAND_2GHZ; is_ht40 = iw4965_is_ht40_channel(ctx->active.flags); @@ -1137,20 +1137,20 @@ static int il4965_send_tx_power(struct il_priv *priv) cmd.band = band; cmd.channel = ctx->active.channel; - ret = il4965_fill_txpower_tbl(priv, band, + ret = il4965_fill_txpower_tbl(il, band, le16_to_cpu(ctx->active.channel), is_ht40, ctrl_chan_high, &cmd.tx_power); if (ret) goto out; - ret = il_send_cmd_pdu(priv, + ret = il_send_cmd_pdu(il, REPLY_TX_PWR_TABLE_CMD, sizeof(cmd), &cmd); out: return ret; } -static int il4965_send_rxon_assoc(struct il_priv *priv, +static int il4965_send_rxon_assoc(struct il_priv *il, struct il_rxon_context *ctx) { int ret = 0; @@ -1167,7 +1167,7 @@ static int il4965_send_rxon_assoc(struct il_priv *priv, rxon2->ofdm_ht_dual_stream_basic_rates) && (rxon1->rx_chain == rxon2->rx_chain) && (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { - IL_DEBUG_INFO(priv, "Using current RXON_ASSOC. Not resending.\n"); + IL_DEBUG_INFO(il, "Using current RXON_ASSOC. Not resending.\n"); return 0; } @@ -1182,13 +1182,13 @@ static int il4965_send_rxon_assoc(struct il_priv *priv, ctx->staging.ofdm_ht_dual_stream_basic_rates; rxon_assoc.rx_chain_select_flags = ctx->staging.rx_chain; - ret = il_send_cmd_pdu_async(priv, REPLY_RXON_ASSOC, + ret = il_send_cmd_pdu_async(il, REPLY_RXON_ASSOC, sizeof(rxon_assoc), &rxon_assoc, NULL); return ret; } -static int il4965_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) +static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) { /* cast away the const for active_rxon in this function */ struct il_rxon_cmd *active_rxon = (void *)&ctx->active; @@ -1196,7 +1196,7 @@ static int il4965_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) bool new_assoc = !!(ctx->staging.filter_flags & RXON_FILTER_ASSOC_MSK); - if (!il_is_alive(priv)) + if (!il_is_alive(il)) return -EBUSY; if (!ctx->is_active) @@ -1205,9 +1205,9 @@ static int il4965_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) /* always get timestamp with Rx frame */ ctx->staging.flags |= RXON_FLG_TSF2HOST_MSK; - ret = il_check_rxon_cmd(priv, ctx); + ret = il_check_rxon_cmd(il, ctx); if (ret) { - IL_ERR(priv, "Invalid RXON configuration. Not committing.\n"); + IL_ERR(il, "Invalid RXON configuration. Not committing.\n"); return -EINVAL; } @@ -1215,30 +1215,30 @@ static int il4965_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) * receive commit_rxon request * abort any previous channel switch if still in process */ - if (test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status) && - (priv->switch_channel != ctx->staging.channel)) { - IL_DEBUG_11H(priv, "abort channel switch on %d\n", - le16_to_cpu(priv->switch_channel)); - il_chswitch_done(priv, false); + if (test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status) && + (il->switch_channel != ctx->staging.channel)) { + IL_DEBUG_11H(il, "abort channel switch on %d\n", + le16_to_cpu(il->switch_channel)); + il_chswitch_done(il, false); } /* If we don't need to send a full RXON, we can use * il_rxon_assoc_cmd which is used to reconfigure filter * and other flags for the current radio configuration. */ - if (!il_full_rxon_required(priv, ctx)) { - ret = il_send_rxon_assoc(priv, ctx); + if (!il_full_rxon_required(il, ctx)) { + ret = il_send_rxon_assoc(il, ctx); if (ret) { - IL_ERR(priv, "Error setting RXON_ASSOC (%d)\n", ret); + IL_ERR(il, "Error setting RXON_ASSOC (%d)\n", ret); return ret; } memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); - il_print_rx_config_cmd(priv, ctx); + il_print_rx_config_cmd(il, ctx); /* * We do not commit tx power settings while channel changing, * do it now if tx power changed. */ - il_set_tx_power(priv, priv->tx_power_next, false); + il_set_tx_power(il, il->tx_power_next, false); return 0; } @@ -1247,10 +1247,10 @@ static int il4965_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) * we must clear the associated from the active configuration * before we apply the new config */ if (il_is_associated_ctx(ctx) && new_assoc) { - IL_DEBUG_INFO(priv, "Toggling associated bit on current RXON\n"); + IL_DEBUG_INFO(il, "Toggling associated bit on current RXON\n"); active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; - ret = il_send_cmd_pdu(priv, ctx->rxon_cmd, + ret = il_send_cmd_pdu(il, ctx->rxon_cmd, sizeof(struct il_rxon_cmd), active_rxon); @@ -1258,19 +1258,19 @@ static int il4965_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) * active_rxon back to what it was previously */ if (ret) { active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK; - IL_ERR(priv, "Error clearing ASSOC_MSK (%d)\n", ret); + IL_ERR(il, "Error clearing ASSOC_MSK (%d)\n", ret); return ret; } - il_clear_ucode_stations(priv, ctx); - il_restore_stations(priv, ctx); - ret = il4965_restore_default_wep_keys(priv, ctx); + il_clear_ucode_stations(il, ctx); + il_restore_stations(il, ctx); + ret = il4965_restore_default_wep_keys(il, ctx); if (ret) { - IL_ERR(priv, "Failed to restore WEP keys (%d)\n", ret); + IL_ERR(il, "Failed to restore WEP keys (%d)\n", ret); return ret; } } - IL_DEBUG_INFO(priv, "Sending RXON\n" + IL_DEBUG_INFO(il, "Sending RXON\n" "* with%s RXON_FILTER_ASSOC_MSK\n" "* channel = %d\n" "* bssid = %pM\n", @@ -1278,62 +1278,62 @@ static int il4965_commit_rxon(struct il_priv *priv, struct il_rxon_context *ctx) le16_to_cpu(ctx->staging.channel), ctx->staging.bssid_addr); - il_set_rxon_hwcrypto(priv, ctx, - !priv->cfg->mod_params->sw_crypto); + il_set_rxon_hwcrypto(il, ctx, + !il->cfg->mod_params->sw_crypto); /* Apply the new configuration * RXON unassoc clears the station table in uCode so restoration of * stations is needed after it (the RXON command) completes */ if (!new_assoc) { - ret = il_send_cmd_pdu(priv, ctx->rxon_cmd, + ret = il_send_cmd_pdu(il, ctx->rxon_cmd, sizeof(struct il_rxon_cmd), &ctx->staging); if (ret) { - IL_ERR(priv, "Error setting new RXON (%d)\n", ret); + IL_ERR(il, "Error setting new RXON (%d)\n", ret); return ret; } - IL_DEBUG_INFO(priv, "Return from !new_assoc RXON.\n"); + IL_DEBUG_INFO(il, "Return from !new_assoc RXON.\n"); memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); - il_clear_ucode_stations(priv, ctx); - il_restore_stations(priv, ctx); - ret = il4965_restore_default_wep_keys(priv, ctx); + il_clear_ucode_stations(il, ctx); + il_restore_stations(il, ctx); + ret = il4965_restore_default_wep_keys(il, ctx); if (ret) { - IL_ERR(priv, "Failed to restore WEP keys (%d)\n", ret); + IL_ERR(il, "Failed to restore WEP keys (%d)\n", ret); return ret; } } if (new_assoc) { - priv->start_calib = 0; + il->start_calib = 0; /* Apply the new configuration * RXON assoc doesn't clear the station table in uCode, */ - ret = il_send_cmd_pdu(priv, ctx->rxon_cmd, + ret = il_send_cmd_pdu(il, ctx->rxon_cmd, sizeof(struct il_rxon_cmd), &ctx->staging); if (ret) { - IL_ERR(priv, "Error setting new RXON (%d)\n", ret); + IL_ERR(il, "Error setting new RXON (%d)\n", ret); return ret; } memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); } - il_print_rx_config_cmd(priv, ctx); + il_print_rx_config_cmd(il, ctx); - il4965_init_sensitivity(priv); + il4965_init_sensitivity(il); /* If we issue a new RXON command which required a tune then we must * send a new TXPOWER command or we won't be able to Tx any frames */ - ret = il_set_tx_power(priv, priv->tx_power_next, true); + ret = il_set_tx_power(il, il->tx_power_next, true); if (ret) { - IL_ERR(priv, "Error sending TX power (%d)\n", ret); + IL_ERR(il, "Error sending TX power (%d)\n", ret); return ret; } return 0; } -static int il4965_hw_channel_switch(struct il_priv *priv, +static int il4965_hw_channel_switch(struct il_priv *il, struct ieee80211_channel_switch *ch_switch) { - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; int rc; u8 band = 0; bool is_ht40 = false; @@ -1346,7 +1346,7 @@ static int il4965_hw_channel_switch(struct il_priv *priv, u8 switch_count; u16 beacon_interval = le16_to_cpu(ctx->timing.beacon_interval); struct ieee80211_vif *vif = ctx->vif; - band = priv->band == IEEE80211_BAND_2GHZ; + band = il->band == IEEE80211_BAND_2GHZ; is_ht40 = iw4965_is_ht40_channel(ctx->staging.flags); @@ -1366,57 +1366,57 @@ static int il4965_hw_channel_switch(struct il_priv *priv, * calculate the ucode channel switch time * adding TSF as one of the factor for when to switch */ - if ((priv->ucode_beacon_time > tsf_low) && beacon_interval) { - if (switch_count > ((priv->ucode_beacon_time - tsf_low) / + if ((il->ucode_beacon_time > tsf_low) && beacon_interval) { + if (switch_count > ((il->ucode_beacon_time - tsf_low) / beacon_interval)) { - switch_count -= (priv->ucode_beacon_time - + switch_count -= (il->ucode_beacon_time - tsf_low) / beacon_interval; } else switch_count = 0; } if (switch_count <= 1) - cmd.switch_time = cpu_to_le32(priv->ucode_beacon_time); + cmd.switch_time = cpu_to_le32(il->ucode_beacon_time); else { switch_time_in_usec = vif->bss_conf.beacon_int * switch_count * TIME_UNIT; - ucode_switch_time = il_usecs_to_beacons(priv, + ucode_switch_time = il_usecs_to_beacons(il, switch_time_in_usec, beacon_interval); - cmd.switch_time = il_add_beacon_time(priv, - priv->ucode_beacon_time, + cmd.switch_time = il_add_beacon_time(il, + il->ucode_beacon_time, ucode_switch_time, beacon_interval); } - IL_DEBUG_11H(priv, "uCode time for the switch is 0x%x\n", + IL_DEBUG_11H(il, "uCode time for the switch is 0x%x\n", cmd.switch_time); - ch_info = il_get_channel_info(priv, priv->band, ch); + ch_info = il_get_channel_info(il, il->band, ch); if (ch_info) cmd.expect_beacon = il_is_channel_radar(ch_info); else { - IL_ERR(priv, "invalid channel switch from %u to %u\n", + IL_ERR(il, "invalid channel switch from %u to %u\n", ctx->active.channel, ch); return -EFAULT; } - rc = il4965_fill_txpower_tbl(priv, band, ch, is_ht40, + rc = il4965_fill_txpower_tbl(il, band, ch, is_ht40, ctrl_chan_high, &cmd.tx_power); if (rc) { - IL_DEBUG_11H(priv, "error:%d fill txpower_tbl\n", rc); + IL_DEBUG_11H(il, "error:%d fill txpower_tbl\n", rc); return rc; } - return il_send_cmd_pdu(priv, + return il_send_cmd_pdu(il, REPLY_CHANNEL_SWITCH, sizeof(cmd), &cmd); } /** * il4965_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array */ -static void il4965_txq_update_byte_cnt_tbl(struct il_priv *priv, +static void il4965_txq_update_byte_cnt_tbl(struct il_priv *il, struct il_tx_queue *txq, u16 byte_cnt) { - struct il4965_scd_bc_tbl *scd_bc_tbl = priv->scd_bc_tbls.addr; + struct il4965_scd_bc_tbl *scd_bc_tbl = il->scd_bc_tbls.addr; int txq_id = txq->q.id; int write_ptr = txq->q.write_ptr; int len = byte_cnt + IL_TX_CRC_SIZE + IL_TX_DELIMITER_SIZE; @@ -1440,27 +1440,27 @@ static void il4965_txq_update_byte_cnt_tbl(struct il_priv *priv, * * A return of <0 indicates bogus data in the statistics */ -static int il4965_hw_get_temperature(struct il_priv *priv) +static int il4965_hw_get_temperature(struct il_priv *il) { s32 temperature; s32 vt; s32 R1, R2, R3; u32 R4; - if (test_bit(STATUS_TEMPERATURE, &priv->status) && - (priv->_4965.statistics.flag & + if (test_bit(STATUS_TEMPERATURE, &il->status) && + (il->_4965.statistics.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK)) { - IL_DEBUG_TEMP(priv, "Running HT40 temperature calibration\n"); - R1 = (s32)le32_to_cpu(priv->card_alive_init.therm_r1[1]); - R2 = (s32)le32_to_cpu(priv->card_alive_init.therm_r2[1]); - R3 = (s32)le32_to_cpu(priv->card_alive_init.therm_r3[1]); - R4 = le32_to_cpu(priv->card_alive_init.therm_r4[1]); + IL_DEBUG_TEMP(il, "Running HT40 temperature calibration\n"); + R1 = (s32)le32_to_cpu(il->card_alive_init.therm_r1[1]); + R2 = (s32)le32_to_cpu(il->card_alive_init.therm_r2[1]); + R3 = (s32)le32_to_cpu(il->card_alive_init.therm_r3[1]); + R4 = le32_to_cpu(il->card_alive_init.therm_r4[1]); } else { - IL_DEBUG_TEMP(priv, "Running temperature calibration\n"); - R1 = (s32)le32_to_cpu(priv->card_alive_init.therm_r1[0]); - R2 = (s32)le32_to_cpu(priv->card_alive_init.therm_r2[0]); - R3 = (s32)le32_to_cpu(priv->card_alive_init.therm_r3[0]); - R4 = le32_to_cpu(priv->card_alive_init.therm_r4[0]); + IL_DEBUG_TEMP(il, "Running temperature calibration\n"); + R1 = (s32)le32_to_cpu(il->card_alive_init.therm_r1[0]); + R2 = (s32)le32_to_cpu(il->card_alive_init.therm_r2[0]); + R3 = (s32)le32_to_cpu(il->card_alive_init.therm_r3[0]); + R4 = le32_to_cpu(il->card_alive_init.therm_r4[0]); } /* @@ -1470,16 +1470,16 @@ static int il4965_hw_get_temperature(struct il_priv *priv) * with an updated temperature, use R4 provided to us in the * "initialize" ALIVE response. */ - if (!test_bit(STATUS_TEMPERATURE, &priv->status)) + if (!test_bit(STATUS_TEMPERATURE, &il->status)) vt = sign_extend32(R4, 23); else - vt = sign_extend32(le32_to_cpu(priv->_4965.statistics. + vt = sign_extend32(le32_to_cpu(il->_4965.statistics. general.common.temperature), 23); - IL_DEBUG_TEMP(priv, "Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt); + IL_DEBUG_TEMP(il, "Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt); if (R3 == R1) { - IL_ERR(priv, "Calibration conflict R1 == R3\n"); + IL_ERR(il, "Calibration conflict R1 == R3\n"); return -1; } @@ -1489,7 +1489,7 @@ static int il4965_hw_get_temperature(struct il_priv *priv) temperature /= (R3 - R1); temperature = (temperature * 97) / 100 + TEMPERATURE_CALIB_KELVIN_OFFSET; - IL_DEBUG_TEMP(priv, "Calibrated temperature: %dK, %dC\n", + IL_DEBUG_TEMP(il, "Calibrated temperature: %dK, %dC\n", temperature, KELVIN_TO_CELSIUS(temperature)); return temperature; @@ -1504,66 +1504,66 @@ static int il4965_hw_get_temperature(struct il_priv *priv) * If the temperature changed has changed sufficiently, then a recalibration * is needed. * - * Assumes caller will replace priv->last_temperature once calibration + * Assumes caller will replace il->last_temperature once calibration * executed. */ -static int il4965_is_temp_calib_needed(struct il_priv *priv) +static int il4965_is_temp_calib_needed(struct il_priv *il) { int temp_diff; - if (!test_bit(STATUS_STATISTICS, &priv->status)) { - IL_DEBUG_TEMP(priv, "Temperature not updated -- no statistics.\n"); + if (!test_bit(STATUS_STATISTICS, &il->status)) { + IL_DEBUG_TEMP(il, "Temperature not updated -- no statistics.\n"); return 0; } - temp_diff = priv->temperature - priv->last_temperature; + temp_diff = il->temperature - il->last_temperature; /* get absolute value */ if (temp_diff < 0) { - IL_DEBUG_POWER(priv, "Getting cooler, delta %d\n", temp_diff); + IL_DEBUG_POWER(il, "Getting cooler, delta %d\n", temp_diff); temp_diff = -temp_diff; } else if (temp_diff == 0) - IL_DEBUG_POWER(priv, "Temperature unchanged\n"); + IL_DEBUG_POWER(il, "Temperature unchanged\n"); else - IL_DEBUG_POWER(priv, "Getting warmer, delta %d\n", temp_diff); + IL_DEBUG_POWER(il, "Getting warmer, delta %d\n", temp_diff); if (temp_diff < IL_TEMPERATURE_THRESHOLD) { - IL_DEBUG_POWER(priv, " => thermal txpower calib not needed\n"); + IL_DEBUG_POWER(il, " => thermal txpower calib not needed\n"); return 0; } - IL_DEBUG_POWER(priv, " => thermal txpower calib needed\n"); + IL_DEBUG_POWER(il, " => thermal txpower calib needed\n"); return 1; } -static void il4965_temperature_calib(struct il_priv *priv) +static void il4965_temperature_calib(struct il_priv *il) { s32 temp; - temp = il4965_hw_get_temperature(priv); + temp = il4965_hw_get_temperature(il); if (IL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(temp)) return; - if (priv->temperature != temp) { - if (priv->temperature) - IL_DEBUG_TEMP(priv, "Temperature changed " + if (il->temperature != temp) { + if (il->temperature) + IL_DEBUG_TEMP(il, "Temperature changed " "from %dC to %dC\n", - KELVIN_TO_CELSIUS(priv->temperature), + KELVIN_TO_CELSIUS(il->temperature), KELVIN_TO_CELSIUS(temp)); else - IL_DEBUG_TEMP(priv, "Temperature " + IL_DEBUG_TEMP(il, "Temperature " "initialized to %dC\n", KELVIN_TO_CELSIUS(temp)); } - priv->temperature = temp; - set_bit(STATUS_TEMPERATURE, &priv->status); + il->temperature = temp; + set_bit(STATUS_TEMPERATURE, &il->status); - if (!priv->disable_tx_power_cal && - unlikely(!test_bit(STATUS_SCANNING, &priv->status)) && - il4965_is_temp_calib_needed(priv)) - queue_work(priv->workqueue, &priv->txpower_work); + if (!il->disable_tx_power_cal && + unlikely(!test_bit(STATUS_SCANNING, &il->status)) && + il4965_is_temp_calib_needed(il)) + queue_work(il->workqueue, &il->txpower_work); } static u16 il4965_get_hcmd_size(u8 cmd_id, u16 len) @@ -1604,7 +1604,7 @@ static inline u32 il4965_get_scd_ssn(struct il4965_tx_resp *tx_resp) /** * il4965_tx_status_reply_tx - Handle Tx response for frames in aggregation queue */ -static int il4965_tx_status_reply_tx(struct il_priv *priv, +static int il4965_tx_status_reply_tx(struct il_priv *il, struct il_ht_agg *agg, struct il4965_tx_resp *tx_resp, int txq_id, u16 start_idx) @@ -1617,7 +1617,7 @@ static int il4965_tx_status_reply_tx(struct il_priv *priv, int i, sh, idx; u16 seq; if (agg->wait_for_ba) - IL_DEBUG_TX_REPLY(priv, "got tx response w/o block-ack\n"); + IL_DEBUG_TX_REPLY(il, "got tx response w/o block-ack\n"); agg->frame_count = tx_resp->frame_count; agg->start_idx = start_idx; @@ -1630,18 +1630,18 @@ static int il4965_tx_status_reply_tx(struct il_priv *priv, status = le16_to_cpu(frame_status[0].status); idx = start_idx; - IL_DEBUG_TX_REPLY(priv, "FrameCnt = %d, StartIdx=%d idx=%d\n", + IL_DEBUG_TX_REPLY(il, "FrameCnt = %d, StartIdx=%d idx=%d\n", agg->frame_count, agg->start_idx, idx); - info = IEEE80211_SKB_CB(priv->txq[txq_id].txb[idx].skb); + info = IEEE80211_SKB_CB(il->txq[txq_id].txb[idx].skb); info->status.rates[0].count = tx_resp->failure_frame + 1; info->flags &= ~IEEE80211_TX_CTL_AMPDU; info->flags |= il4965_tx_status_to_mac80211(status); - il4965_hwrate_to_tx_control(priv, rate_n_flags, info); + il4965_hwrate_to_tx_control(il, rate_n_flags, info); - IL_DEBUG_TX_REPLY(priv, "1 Frame 0x%x failure :%d\n", + IL_DEBUG_TX_REPLY(il, "1 Frame 0x%x failure :%d\n", status & 0xff, tx_resp->failure_frame); - IL_DEBUG_TX_REPLY(priv, "Rate Info rate_n_flags=%x\n", rate_n_flags); + IL_DEBUG_TX_REPLY(il, "Rate Info rate_n_flags=%x\n", rate_n_flags); agg->wait_for_ba = 0; } else { @@ -1661,12 +1661,12 @@ static int il4965_tx_status_reply_tx(struct il_priv *priv, AGG_TX_STATE_ABORT_MSK)) continue; - IL_DEBUG_TX_REPLY(priv, "FrameCnt = %d, txq_id=%d idx=%d\n", + IL_DEBUG_TX_REPLY(il, "FrameCnt = %d, txq_id=%d idx=%d\n", agg->frame_count, txq_id, idx); - hdr = il_tx_queue_get_hdr(priv, txq_id, idx); + hdr = il_tx_queue_get_hdr(il, txq_id, idx); if (!hdr) { - IL_ERR(priv, + IL_ERR(il, "BUG_ON idx doesn't point to valid skb" " idx=%d, txq_id=%d\n", idx, txq_id); return -1; @@ -1674,14 +1674,14 @@ static int il4965_tx_status_reply_tx(struct il_priv *priv, sc = le16_to_cpu(hdr->seq_ctrl); if (idx != (SEQ_TO_SN(sc) & 0xff)) { - IL_ERR(priv, + IL_ERR(il, "BUG_ON idx doesn't match seq control" " idx=%d, seq_idx=%d, seq=%d\n", idx, SEQ_TO_SN(sc), hdr->seq_ctrl); return -1; } - IL_DEBUG_TX_REPLY(priv, "AGG Frame i=%d idx %d seq=%d\n", + IL_DEBUG_TX_REPLY(il, "AGG Frame i=%d idx %d seq=%d\n", i, idx, SEQ_TO_SN(sc)); sh = idx - start; @@ -1699,13 +1699,13 @@ static int il4965_tx_status_reply_tx(struct il_priv *priv, sh = 0; } bitmap |= 1ULL << sh; - IL_DEBUG_TX_REPLY(priv, "start=%d bitmap=0x%llx\n", + IL_DEBUG_TX_REPLY(il, "start=%d bitmap=0x%llx\n", start, (unsigned long long)bitmap); } agg->bitmap = bitmap; agg->start_idx = start; - IL_DEBUG_TX_REPLY(priv, "Frames %d start_idx=%d bitmap=0x%llx\n", + IL_DEBUG_TX_REPLY(il, "Frames %d start_idx=%d bitmap=0x%llx\n", agg->frame_count, agg->start_idx, (unsigned long long)agg->bitmap); @@ -1715,30 +1715,30 @@ static int il4965_tx_status_reply_tx(struct il_priv *priv, return 0; } -static u8 il4965_find_station(struct il_priv *priv, const u8 *addr) +static u8 il4965_find_station(struct il_priv *il, const u8 *addr) { int i; int start = 0; int ret = IL_INVALID_STATION; unsigned long flags; - if ((priv->iw_mode == NL80211_IFTYPE_ADHOC)) + if ((il->iw_mode == NL80211_IFTYPE_ADHOC)) start = IL_STA_ID; if (is_broadcast_ether_addr(addr)) - return priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id; + return il->contexts[IL_RXON_CTX_BSS].bcast_sta_id; - spin_lock_irqsave(&priv->sta_lock, flags); - for (i = start; i < priv->hw_params.max_stations; i++) - if (priv->stations[i].used && - (!compare_ether_addr(priv->stations[i].sta.sta.addr, + spin_lock_irqsave(&il->sta_lock, flags); + for (i = start; i < il->hw_params.max_stations; i++) + if (il->stations[i].used && + (!compare_ether_addr(il->stations[i].sta.sta.addr, addr))) { ret = i; goto out; } - IL_DEBUG_ASSOC_LIMIT(priv, "can not find STA %pM total %d\n", - addr, priv->num_stations); + IL_DEBUG_ASSOC_LIMIT(il, "can not find STA %pM total %d\n", + addr, il->num_stations); out: /* @@ -1747,38 +1747,38 @@ static u8 il4965_find_station(struct il_priv *priv, const u8 *addr) * station */ if (ret != IL_INVALID_STATION && - (!(priv->stations[ret].used & IL_STA_UCODE_ACTIVE) || - ((priv->stations[ret].used & IL_STA_UCODE_ACTIVE) && - (priv->stations[ret].used & IL_STA_UCODE_INPROGRESS)))) { - IL_ERR(priv, "Requested station info for sta %d before ready.\n", + (!(il->stations[ret].used & IL_STA_UCODE_ACTIVE) || + ((il->stations[ret].used & IL_STA_UCODE_ACTIVE) && + (il->stations[ret].used & IL_STA_UCODE_INPROGRESS)))) { + IL_ERR(il, "Requested station info for sta %d before ready.\n", ret); ret = IL_INVALID_STATION; } - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); return ret; } -static int il4965_get_ra_sta_id(struct il_priv *priv, struct ieee80211_hdr *hdr) +static int il4965_get_ra_sta_id(struct il_priv *il, struct ieee80211_hdr *hdr) { - if (priv->iw_mode == NL80211_IFTYPE_STATION) { + if (il->iw_mode == NL80211_IFTYPE_STATION) { return IL_AP_ID; } else { u8 *da = ieee80211_get_DA(hdr); - return il4965_find_station(priv, da); + return il4965_find_station(il, da); } } /** * il4965_rx_reply_tx - Handle standard (non-aggregation) Tx response */ -static void il4965_rx_reply_tx(struct il_priv *priv, +static void il4965_rx_reply_tx(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); int index = SEQ_TO_INDEX(sequence); - struct il_tx_queue *txq = &priv->txq[txq_id]; + struct il_tx_queue *txq = &il->txq[txq_id]; struct ieee80211_hdr *hdr; struct ieee80211_tx_info *info; struct il4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; @@ -1790,7 +1790,7 @@ static void il4965_rx_reply_tx(struct il_priv *priv, unsigned long flags; if ((index >= txq->q.n_bd) || (il_queue_used(&txq->q, index) == 0)) { - IL_ERR(priv, "Read index for DMA queue txq_id (%d) index %d " + IL_ERR(il, "Read index for DMA queue txq_id (%d) index %d " "is out of range [0-%d] %d %d\n", txq_id, index, txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr); @@ -1801,27 +1801,27 @@ static void il4965_rx_reply_tx(struct il_priv *priv, info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb); memset(&info->status, 0, sizeof(info->status)); - hdr = il_tx_queue_get_hdr(priv, txq_id, index); + hdr = il_tx_queue_get_hdr(il, txq_id, index); if (ieee80211_is_data_qos(hdr->frame_control)) { qc = ieee80211_get_qos_ctl(hdr); tid = qc[0] & 0xf; } - sta_id = il4965_get_ra_sta_id(priv, hdr); + sta_id = il4965_get_ra_sta_id(il, hdr); if (txq->sched_retry && unlikely(sta_id == IL_INVALID_STATION)) { - IL_ERR(priv, "Station not known\n"); + IL_ERR(il, "Station not known\n"); return; } - spin_lock_irqsave(&priv->sta_lock, flags); + spin_lock_irqsave(&il->sta_lock, flags); if (txq->sched_retry) { const u32 scd_ssn = il4965_get_scd_ssn(tx_resp); struct il_ht_agg *agg = NULL; WARN_ON(!qc); - agg = &priv->stations[sta_id].tid[tid].agg; + agg = &il->stations[sta_id].tid[tid].agg; - il4965_tx_status_reply_tx(priv, agg, tx_resp, txq_id, index); + il4965_tx_status_reply_tx(il, agg, tx_resp, txq_id, index); /* check if BAR is needed */ if ((tx_resp->frame_count == 1) && !il4965_is_tx_success(status)) @@ -1830,51 +1830,51 @@ static void il4965_rx_reply_tx(struct il_priv *priv, if (txq->q.read_ptr != (scd_ssn & 0xff)) { index = il_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); - IL_DEBUG_TX_REPLY(priv, "Retry scheduler reclaim scd_ssn " + IL_DEBUG_TX_REPLY(il, "Retry scheduler reclaim scd_ssn " "%d index %d\n", scd_ssn , index); - freed = il4965_tx_queue_reclaim(priv, txq_id, index); + freed = il4965_tx_queue_reclaim(il, txq_id, index); if (qc) - il4965_free_tfds_in_queue(priv, sta_id, + il4965_free_tfds_in_queue(il, sta_id, tid, freed); - if (priv->mac80211_registered && + if (il->mac80211_registered && (il_queue_space(&txq->q) > txq->q.low_mark) && (agg->state != IL_EMPTYING_HW_QUEUE_DELBA)) - il_wake_queue(priv, txq); + il_wake_queue(il, txq); } } else { info->status.rates[0].count = tx_resp->failure_frame + 1; info->flags |= il4965_tx_status_to_mac80211(status); - il4965_hwrate_to_tx_control(priv, + il4965_hwrate_to_tx_control(il, le32_to_cpu(tx_resp->rate_n_flags), info); - IL_DEBUG_TX_REPLY(priv, "TXQ %d status %s (0x%08x) " + IL_DEBUG_TX_REPLY(il, "TXQ %d status %s (0x%08x) " "rate_n_flags 0x%x retries %d\n", txq_id, il4965_get_tx_fail_reason(status), status, le32_to_cpu(tx_resp->rate_n_flags), tx_resp->failure_frame); - freed = il4965_tx_queue_reclaim(priv, txq_id, index); + freed = il4965_tx_queue_reclaim(il, txq_id, index); if (qc && likely(sta_id != IL_INVALID_STATION)) - il4965_free_tfds_in_queue(priv, sta_id, tid, freed); + il4965_free_tfds_in_queue(il, sta_id, tid, freed); else if (sta_id == IL_INVALID_STATION) - IL_DEBUG_TX_REPLY(priv, "Station not known\n"); + IL_DEBUG_TX_REPLY(il, "Station not known\n"); - if (priv->mac80211_registered && + if (il->mac80211_registered && (il_queue_space(&txq->q) > txq->q.low_mark)) - il_wake_queue(priv, txq); + il_wake_queue(il, txq); } if (qc && likely(sta_id != IL_INVALID_STATION)) - il4965_txq_check_empty(priv, sta_id, tid, txq_id); + il4965_txq_check_empty(il, sta_id, tid, txq_id); - il4965_check_abort_status(priv, tx_resp->frame_count, status); + il4965_check_abort_status(il, tx_resp->frame_count, status); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); } -static void il4965_rx_beacon_notif(struct il_priv *priv, +static void il4965_rx_beacon_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); @@ -1882,7 +1882,7 @@ static void il4965_rx_beacon_notif(struct il_priv *priv, u8 rate __maybe_unused = il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); - IL_DEBUG_RX(priv, "beacon status %#x, retries:%d ibssmgr:%d " + IL_DEBUG_RX(il, "beacon status %#x, retries:%d ibssmgr:%d " "tsf:0x%.8x%.8x rate:%d\n", le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, beacon->beacon_notify_hdr.failure_frame, @@ -1890,17 +1890,17 @@ static void il4965_rx_beacon_notif(struct il_priv *priv, le32_to_cpu(beacon->high_tsf), le32_to_cpu(beacon->low_tsf), rate); - priv->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); + il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); } /* Set up 4965-specific Rx frame reply handlers */ -static void il4965_rx_handler_setup(struct il_priv *priv) +static void il4965_rx_handler_setup(struct il_priv *il) { /* Legacy Rx frames */ - priv->rx_handlers[REPLY_RX] = il4965_rx_reply_rx; + il->rx_handlers[REPLY_RX] = il4965_rx_reply_rx; /* Tx response */ - priv->rx_handlers[REPLY_TX] = il4965_rx_reply_tx; - priv->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; + il->rx_handlers[REPLY_TX] = il4965_rx_reply_tx; + il->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; } static struct il_hcmd_ops il4965_hcmd = { @@ -1909,53 +1909,53 @@ static struct il_hcmd_ops il4965_hcmd = { .set_rxon_chain = il4965_set_rxon_chain, }; -static void il4965_post_scan(struct il_priv *priv) +static void il4965_post_scan(struct il_priv *il) { - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; /* * Since setting the RXON may have been deferred while * performing the scan, fire one off if needed */ if (memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) - il_commit_rxon(priv, ctx); + il_commit_rxon(il, ctx); } -static void il4965_post_associate(struct il_priv *priv) +static void il4965_post_associate(struct il_priv *il) { - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; struct ieee80211_vif *vif = ctx->vif; struct ieee80211_conf *conf = NULL; int ret = 0; - if (!vif || !priv->is_open) + if (!vif || !il->is_open) return; - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; - il_scan_cancel_timeout(priv, 200); + il_scan_cancel_timeout(il, 200); - conf = il_ieee80211_get_hw_conf(priv->hw); + conf = il_ieee80211_get_hw_conf(il->hw); ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - il_commit_rxon(priv, ctx); + il_commit_rxon(il, ctx); - ret = il_send_rxon_timing(priv, ctx); + ret = il_send_rxon_timing(il, ctx); if (ret) - IL_WARN(priv, "RXON timing - " + IL_WARN(il, "RXON timing - " "Attempting to continue.\n"); ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - il_set_rxon_ht(priv, &priv->current_ht_config); + il_set_rxon_ht(il, &il->current_ht_config); - if (priv->cfg->ops->hcmd->set_rxon_chain) - priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); ctx->staging.assoc_id = cpu_to_le16(vif->bss_conf.aid); - IL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n", + IL_DEBUG_ASSOC(il, "assoc id %d beacon interval %d\n", vif->bss_conf.aid, vif->bss_conf.beacon_int); if (vif->bss_conf.use_short_preamble) @@ -1970,19 +1970,19 @@ static void il4965_post_associate(struct il_priv *priv) ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; } - il_commit_rxon(priv, ctx); + il_commit_rxon(il, ctx); - IL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n", + IL_DEBUG_ASSOC(il, "Associated as %d to: %pM\n", vif->bss_conf.aid, ctx->active.bssid_addr); switch (vif->type) { case NL80211_IFTYPE_STATION: break; case NL80211_IFTYPE_ADHOC: - il4965_send_beacon_cmd(priv); + il4965_send_beacon_cmd(il); break; default: - IL_ERR(priv, "%s Should not be called in %d mode\n", + IL_ERR(il, "%s Should not be called in %d mode\n", __func__, vif->type); break; } @@ -1990,23 +1990,23 @@ static void il4965_post_associate(struct il_priv *priv) /* the chain noise calibration will enabled PM upon completion * If chain noise has already been run, then we need to enable * power management here */ - if (priv->chain_noise_data.state == IL_CHAIN_NOISE_DONE) - il_power_update_mode(priv, false); + if (il->chain_noise_data.state == IL_CHAIN_NOISE_DONE) + il_power_update_mode(il, false); /* Enable Rx differential gain and sensitivity calibrations */ - il4965_chain_noise_reset(priv); - priv->start_calib = 1; + il4965_chain_noise_reset(il); + il->start_calib = 1; } -static void il4965_config_ap(struct il_priv *priv) +static void il4965_config_ap(struct il_priv *il) { - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; struct ieee80211_vif *vif = ctx->vif; int ret = 0; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; /* The following should be done only at AP bring up */ @@ -2014,20 +2014,20 @@ static void il4965_config_ap(struct il_priv *priv) /* RXON - unassoc (to set timing command) */ ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - il_commit_rxon(priv, ctx); + il_commit_rxon(il, ctx); /* RXON Timing */ - ret = il_send_rxon_timing(priv, ctx); + ret = il_send_rxon_timing(il, ctx); if (ret) - IL_WARN(priv, "RXON timing failed - " + IL_WARN(il, "RXON timing failed - " "Attempting to continue.\n"); /* AP has all antennas */ - priv->chain_noise_data.active_chains = - priv->hw_params.valid_rx_ant; - il_set_rxon_ht(priv, &priv->current_ht_config); - if (priv->cfg->ops->hcmd->set_rxon_chain) - priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); + il->chain_noise_data.active_chains = + il->hw_params.valid_rx_ant; + il_set_rxon_ht(il, &il->current_ht_config); + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); ctx->staging.assoc_id = 0; @@ -2047,12 +2047,12 @@ static void il4965_config_ap(struct il_priv *priv) ~RXON_FLG_SHORT_SLOT_MSK; } /* need to send beacon cmd before committing assoc RXON! */ - il4965_send_beacon_cmd(priv); + il4965_send_beacon_cmd(il); /* restore RXON assoc */ ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - il_commit_rxon(priv, ctx); + il_commit_rxon(il, ctx); } - il4965_send_beacon_cmd(priv); + il4965_send_beacon_cmd(il); } static struct il_hcmd_utils_ops il4965_hcmd_utils = { diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.h b/drivers/net/wireless/iwlegacy/iwl-4965.h index 7b322168bfc5..ea2a98e3a4a2 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965.h @@ -73,75 +73,75 @@ extern struct il_mod_params il4965_mod_params; extern struct ieee80211_ops il4965_hw_ops; /* tx queue */ -void il4965_free_tfds_in_queue(struct il_priv *priv, +void il4965_free_tfds_in_queue(struct il_priv *il, int sta_id, int tid, int freed); /* RXON */ -void il4965_set_rxon_chain(struct il_priv *priv, +void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx); /* uCode */ -int il4965_verify_ucode(struct il_priv *priv); +int il4965_verify_ucode(struct il_priv *il); /* lib */ -void il4965_check_abort_status(struct il_priv *priv, +void il4965_check_abort_status(struct il_priv *il, u8 frame_count, u32 status); -void il4965_rx_queue_reset(struct il_priv *priv, struct il_rx_queue *rxq); -int il4965_rx_init(struct il_priv *priv, struct il_rx_queue *rxq); -int il4965_hw_nic_init(struct il_priv *priv); -int il4965_dump_fh(struct il_priv *priv, char **buf, bool display); +void il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq); +int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq); +int il4965_hw_nic_init(struct il_priv *il); +int il4965_dump_fh(struct il_priv *il, char **buf, bool display); /* rx */ -void il4965_rx_queue_restock(struct il_priv *priv); -void il4965_rx_replenish(struct il_priv *priv); -void il4965_rx_replenish_now(struct il_priv *priv); -void il4965_rx_queue_free(struct il_priv *priv, struct il_rx_queue *rxq); -int il4965_rxq_stop(struct il_priv *priv); +void il4965_rx_queue_restock(struct il_priv *il); +void il4965_rx_replenish(struct il_priv *il); +void il4965_rx_replenish_now(struct il_priv *il); +void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq); +int il4965_rxq_stop(struct il_priv *il); int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); -void il4965_rx_reply_rx(struct il_priv *priv, +void il4965_rx_reply_rx(struct il_priv *il, struct il_rx_mem_buffer *rxb); -void il4965_rx_reply_rx_phy(struct il_priv *priv, +void il4965_rx_reply_rx_phy(struct il_priv *il, struct il_rx_mem_buffer *rxb); -void il4965_rx_handle(struct il_priv *priv); +void il4965_rx_handle(struct il_priv *il); /* tx */ -void il4965_hw_txq_free_tfd(struct il_priv *priv, struct il_tx_queue *txq); -int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *priv, +void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq); +int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, struct il_tx_queue *txq, dma_addr_t addr, u16 len, u8 reset, u8 pad); -int il4965_hw_tx_queue_init(struct il_priv *priv, +int il4965_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq); -void il4965_hwrate_to_tx_control(struct il_priv *priv, u32 rate_n_flags, +void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, struct ieee80211_tx_info *info); -int il4965_tx_skb(struct il_priv *priv, struct sk_buff *skb); -int il4965_tx_agg_start(struct il_priv *priv, struct ieee80211_vif *vif, +int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb); +int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, struct ieee80211_sta *sta, u16 tid, u16 *ssn); -int il4965_tx_agg_stop(struct il_priv *priv, struct ieee80211_vif *vif, +int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, struct ieee80211_sta *sta, u16 tid); -int il4965_txq_check_empty(struct il_priv *priv, +int il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id); -void il4965_rx_reply_compressed_ba(struct il_priv *priv, +void il4965_rx_reply_compressed_ba(struct il_priv *il, struct il_rx_mem_buffer *rxb); -int il4965_tx_queue_reclaim(struct il_priv *priv, int txq_id, int index); -void il4965_hw_txq_ctx_free(struct il_priv *priv); -int il4965_txq_ctx_alloc(struct il_priv *priv); -void il4965_txq_ctx_reset(struct il_priv *priv); -void il4965_txq_ctx_stop(struct il_priv *priv); -void il4965_txq_set_sched(struct il_priv *priv, u32 mask); +int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int index); +void il4965_hw_txq_ctx_free(struct il_priv *il); +int il4965_txq_ctx_alloc(struct il_priv *il); +void il4965_txq_ctx_reset(struct il_priv *il); +void il4965_txq_ctx_stop(struct il_priv *il); +void il4965_txq_set_sched(struct il_priv *il, u32 mask); /* - * Acquire priv->lock before calling this function ! + * Acquire il->lock before calling this function ! */ -void il4965_set_wr_ptrs(struct il_priv *priv, int txq_id, u32 index); +void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 index); /** * il4965_tx_queue_set_status - (optionally) start Tx/Cmd queue * @tx_fifo_id: Tx DMA/FIFO channel (range 0-7) that the queue will feed * @scd_retry: (1) Indicates queue will be used in aggregation mode * - * NOTE: Acquire priv->lock before calling this function ! + * NOTE: Acquire il->lock before calling this function ! */ -void il4965_tx_queue_set_status(struct il_priv *priv, +void il4965_tx_queue_set_status(struct il_priv *il, struct il_tx_queue *txq, int tx_fifo_id, int scd_retry); @@ -167,27 +167,27 @@ static inline bool il4965_is_tx_success(u32 status) (status == TX_STATUS_DIRECT_DONE); } -u8 il4965_toggle_tx_ant(struct il_priv *priv, u8 ant_idx, u8 valid); +u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant_idx, u8 valid); /* rx */ -void il4965_rx_missed_beacon_notif(struct il_priv *priv, +void il4965_rx_missed_beacon_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb); -bool il4965_good_plcp_health(struct il_priv *priv, +bool il4965_good_plcp_health(struct il_priv *il, struct il_rx_packet *pkt); -void il4965_rx_statistics(struct il_priv *priv, +void il4965_rx_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb); -void il4965_reply_statistics(struct il_priv *priv, +void il4965_reply_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb); /* scan */ -int il4965_request_scan(struct il_priv *priv, struct ieee80211_vif *vif); +int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif); /* station mgmt */ -int il4965_manage_ibss_station(struct il_priv *priv, +int il4965_manage_ibss_station(struct il_priv *il, struct ieee80211_vif *vif, bool add); /* hcmd */ -int il4965_send_beacon_cmd(struct il_priv *priv); +int il4965_send_beacon_cmd(struct il_priv *il); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG const char *il4965_get_tx_fail_reason(u32 status); @@ -197,38 +197,38 @@ il4965_get_tx_fail_reason(u32 status) { return ""; } #endif /* station management */ -int il4965_alloc_bcast_station(struct il_priv *priv, +int il4965_alloc_bcast_station(struct il_priv *il, struct il_rxon_context *ctx); -int il4965_add_bssid_station(struct il_priv *priv, +int il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, const u8 *addr, u8 *sta_id_r); -int il4965_remove_default_wep_key(struct il_priv *priv, +int il4965_remove_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *key); -int il4965_set_default_wep_key(struct il_priv *priv, +int il4965_set_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *key); -int il4965_restore_default_wep_keys(struct il_priv *priv, +int il4965_restore_default_wep_keys(struct il_priv *il, struct il_rxon_context *ctx); -int il4965_set_dynamic_key(struct il_priv *priv, +int il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *key, u8 sta_id); -int il4965_remove_dynamic_key(struct il_priv *priv, +int il4965_remove_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *key, u8 sta_id); -void il4965_update_tkip_key(struct il_priv *priv, +void il4965_update_tkip_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, struct ieee80211_sta *sta, u32 iv32, u16 *phase1key); -int il4965_sta_tx_modify_enable_tid(struct il_priv *priv, +int il4965_sta_tx_modify_enable_tid(struct il_priv *il, int sta_id, int tid); -int il4965_sta_rx_agg_start(struct il_priv *priv, struct ieee80211_sta *sta, +int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta, int tid, u16 ssn); -int il4965_sta_rx_agg_stop(struct il_priv *priv, struct ieee80211_sta *sta, +int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta, int tid); -void il4965_sta_modify_sleep_tx_count(struct il_priv *priv, +void il4965_sta_modify_sleep_tx_count(struct il_priv *il, int sta_id, int cnt); -int il4965_update_bcast_stations(struct il_priv *priv); +int il4965_update_bcast_stations(struct il_priv *il); /* rate */ static inline u32 il4965_ant_idx_to_flags(u8 ant_idx) @@ -247,10 +247,10 @@ static inline __le32 il4965_hw_set_rate_n_flags(u8 rate, u32 flags) } /* eeprom */ -void il4965_eeprom_get_mac(const struct il_priv *priv, u8 *mac); -int il4965_eeprom_acquire_semaphore(struct il_priv *priv); -void il4965_eeprom_release_semaphore(struct il_priv *priv); -int il4965_eeprom_check_version(struct il_priv *priv); +void il4965_eeprom_get_mac(const struct il_priv *il, u8 *mac); +int il4965_eeprom_acquire_semaphore(struct il_priv *il); +void il4965_eeprom_release_semaphore(struct il_priv *il); +int il4965_eeprom_check_version(struct il_priv *il); /* mac80211 handlers (for 4965) */ void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb); diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index 7eae279e4c69..80ec543dd894 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -75,12 +75,12 @@ const u8 iwlegacy_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; EXPORT_SYMBOL(iwlegacy_bcast_addr); -/* This function both allocates and initializes hw and priv. */ +/* This function both allocates and initializes hw and il. */ struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg) { - struct il_priv *priv; + struct il_priv *il; /* mac80211 allocates memory for this device instance, including - * space for this driver's private structure */ + * space for this driver's ilate structure */ struct ieee80211_hw *hw; hw = ieee80211_alloc_hw(sizeof(struct il_priv), @@ -91,8 +91,8 @@ struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg) goto out; } - priv = hw->priv; - priv->hw = hw; + il = hw->priv; + il->hw = hw; out: return hw; @@ -101,13 +101,13 @@ EXPORT_SYMBOL(il_alloc_all); #define MAX_BIT_RATE_40_MHZ 150 /* Mbps */ #define MAX_BIT_RATE_20_MHZ 72 /* Mbps */ -static void il_init_ht_hw_capab(const struct il_priv *priv, +static void il_init_ht_hw_capab(const struct il_priv *il, struct ieee80211_sta_ht_cap *ht_info, enum ieee80211_band band) { u16 max_bit_rate = 0; - u8 rx_chains_num = priv->hw_params.rx_chains_num; - u8 tx_chains_num = priv->hw_params.tx_chains_num; + u8 rx_chains_num = il->hw_params.rx_chains_num; + u8 tx_chains_num = il->hw_params.tx_chains_num; ht_info->cap = 0; memset(&ht_info->mcs, 0, sizeof(ht_info->mcs)); @@ -116,14 +116,14 @@ static void il_init_ht_hw_capab(const struct il_priv *priv, ht_info->cap |= IEEE80211_HT_CAP_SGI_20; max_bit_rate = MAX_BIT_RATE_20_MHZ; - if (priv->hw_params.ht40_channel & BIT(band)) { + if (il->hw_params.ht40_channel & BIT(band)) { ht_info->cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40; ht_info->cap |= IEEE80211_HT_CAP_SGI_40; ht_info->mcs.rx_mask[4] = 0x01; max_bit_rate = MAX_BIT_RATE_40_MHZ; } - if (priv->cfg->mod_params->amsdu_size_8K) + if (il->cfg->mod_params->amsdu_size_8K) ht_info->cap |= IEEE80211_HT_CAP_MAX_AMSDU; ht_info->ampdu_factor = CFG_HT_RX_AMPDU_FACTOR_DEF; @@ -152,7 +152,7 @@ static void il_init_ht_hw_capab(const struct il_priv *priv, /** * il_init_geos - Initialize mac80211's geo/channel info based from eeprom */ -int il_init_geos(struct il_priv *priv) +int il_init_geos(struct il_priv *il) { struct il_channel_info *ch; struct ieee80211_supported_band *sband; @@ -162,15 +162,15 @@ int il_init_geos(struct il_priv *priv) int i = 0; s8 max_tx_power = 0; - if (priv->bands[IEEE80211_BAND_2GHZ].n_bitrates || - priv->bands[IEEE80211_BAND_5GHZ].n_bitrates) { - IL_DEBUG_INFO(priv, "Geography modes already initialized.\n"); - set_bit(STATUS_GEO_CONFIGURED, &priv->status); + if (il->bands[IEEE80211_BAND_2GHZ].n_bitrates || + il->bands[IEEE80211_BAND_5GHZ].n_bitrates) { + IL_DEBUG_INFO(il, "Geography modes already initialized.\n"); + set_bit(STATUS_GEO_CONFIGURED, &il->status); return 0; } channels = kzalloc(sizeof(struct ieee80211_channel) * - priv->channel_count, GFP_KERNEL); + il->channel_count, GFP_KERNEL); if (!channels) return -ENOMEM; @@ -182,36 +182,36 @@ int il_init_geos(struct il_priv *priv) } /* 5.2GHz channels start after the 2.4GHz channels */ - sband = &priv->bands[IEEE80211_BAND_5GHZ]; + sband = &il->bands[IEEE80211_BAND_5GHZ]; sband->channels = &channels[ARRAY_SIZE(iwlegacy_eeprom_band_1)]; /* just OFDM */ sband->bitrates = &rates[IL_FIRST_OFDM_RATE]; sband->n_bitrates = IL_RATE_COUNT_LEGACY - IL_FIRST_OFDM_RATE; - if (priv->cfg->sku & IL_SKU_N) - il_init_ht_hw_capab(priv, &sband->ht_cap, + if (il->cfg->sku & IL_SKU_N) + il_init_ht_hw_capab(il, &sband->ht_cap, IEEE80211_BAND_5GHZ); - sband = &priv->bands[IEEE80211_BAND_2GHZ]; + sband = &il->bands[IEEE80211_BAND_2GHZ]; sband->channels = channels; /* OFDM & CCK */ sband->bitrates = rates; sband->n_bitrates = IL_RATE_COUNT_LEGACY; - if (priv->cfg->sku & IL_SKU_N) - il_init_ht_hw_capab(priv, &sband->ht_cap, + if (il->cfg->sku & IL_SKU_N) + il_init_ht_hw_capab(il, &sband->ht_cap, IEEE80211_BAND_2GHZ); - priv->ieee_channels = channels; - priv->ieee_rates = rates; + il->ieee_channels = channels; + il->ieee_rates = rates; - for (i = 0; i < priv->channel_count; i++) { - ch = &priv->channel_info[i]; + for (i = 0; i < il->channel_count; i++) { + ch = &il->channel_info[i]; if (!il_is_channel_valid(ch)) continue; - sband = &priv->bands[ch->band]; + sband = &il->bands[ch->band]; geo_ch = &sband->channels[sband->n_channels++]; @@ -239,7 +239,7 @@ int il_init_geos(struct il_priv *priv) geo_ch->flags |= IEEE80211_CHAN_DISABLED; } - IL_DEBUG_INFO(priv, "Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", + IL_DEBUG_INFO(il, "Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", ch->channel, geo_ch->center_freq, il_is_channel_a_band(ch) ? "5.2" : "2.4", geo_ch->flags & IEEE80211_CHAN_DISABLED ? @@ -247,24 +247,24 @@ int il_init_geos(struct il_priv *priv) geo_ch->flags); } - priv->tx_power_device_lmt = max_tx_power; - priv->tx_power_user_lmt = max_tx_power; - priv->tx_power_next = max_tx_power; + il->tx_power_device_lmt = max_tx_power; + il->tx_power_user_lmt = max_tx_power; + il->tx_power_next = max_tx_power; - if ((priv->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && - priv->cfg->sku & IL_SKU_A) { - IL_INFO(priv, "Incorrectly detected BG card as ABG. " + if ((il->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && + il->cfg->sku & IL_SKU_A) { + IL_INFO(il, "Incorrectly detected BG card as ABG. " "Please send your PCI ID 0x%04X:0x%04X to maintainer.\n", - priv->pci_dev->device, - priv->pci_dev->subsystem_device); - priv->cfg->sku &= ~IL_SKU_A; + il->pci_dev->device, + il->pci_dev->subsystem_device); + il->cfg->sku &= ~IL_SKU_A; } - IL_INFO(priv, "Tunable channels: %d 802.11bg, %d 802.11a channels\n", - priv->bands[IEEE80211_BAND_2GHZ].n_channels, - priv->bands[IEEE80211_BAND_5GHZ].n_channels); + IL_INFO(il, "Tunable channels: %d 802.11bg, %d 802.11a channels\n", + il->bands[IEEE80211_BAND_2GHZ].n_channels, + il->bands[IEEE80211_BAND_5GHZ].n_channels); - set_bit(STATUS_GEO_CONFIGURED, &priv->status); + set_bit(STATUS_GEO_CONFIGURED, &il->status); return 0; } @@ -273,21 +273,21 @@ EXPORT_SYMBOL(il_init_geos); /* * il_free_geos - undo allocations in il_init_geos */ -void il_free_geos(struct il_priv *priv) +void il_free_geos(struct il_priv *il) { - kfree(priv->ieee_channels); - kfree(priv->ieee_rates); - clear_bit(STATUS_GEO_CONFIGURED, &priv->status); + kfree(il->ieee_channels); + kfree(il->ieee_rates); + clear_bit(STATUS_GEO_CONFIGURED, &il->status); } EXPORT_SYMBOL(il_free_geos); -static bool il_is_channel_extension(struct il_priv *priv, +static bool il_is_channel_extension(struct il_priv *il, enum ieee80211_band band, u16 channel, u8 extension_chan_offset) { const struct il_channel_info *ch_info; - ch_info = il_get_channel_info(priv, band, channel); + ch_info = il_get_channel_info(il, band, channel); if (!il_is_channel_valid(ch_info)) return false; @@ -301,7 +301,7 @@ static bool il_is_channel_extension(struct il_priv *priv, return false; } -bool il_is_ht40_tx_allowed(struct il_priv *priv, +bool il_is_ht40_tx_allowed(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_sta_ht_cap *ht_cap) { @@ -316,11 +316,11 @@ bool il_is_ht40_tx_allowed(struct il_priv *priv, return false; #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS - if (priv->disable_ht40) + if (il->disable_ht40) return false; #endif - return il_is_channel_extension(priv, priv->band, + return il_is_channel_extension(il, il->band, le16_to_cpu(ctx->staging.channel), ctx->ht.extension_chan_offset); } @@ -360,7 +360,7 @@ static u16 il_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val) } int -il_send_rxon_timing(struct il_priv *priv, struct il_rxon_context *ctx) +il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx) { u64 tsf; s32 interval_tm, rem; @@ -368,13 +368,13 @@ il_send_rxon_timing(struct il_priv *priv, struct il_rxon_context *ctx) u16 beacon_int; struct ieee80211_vif *vif = ctx->vif; - conf = il_ieee80211_get_hw_conf(priv->hw); + conf = il_ieee80211_get_hw_conf(il->hw); - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); memset(&ctx->timing, 0, sizeof(struct il_rxon_time_cmd)); - ctx->timing.timestamp = cpu_to_le64(priv->timestamp); + ctx->timing.timestamp = cpu_to_le64(il->timestamp); ctx->timing.listen_interval = cpu_to_le16(conf->listen_interval); beacon_int = vif ? vif->bss_conf.beacon_int : 0; @@ -386,29 +386,29 @@ il_send_rxon_timing(struct il_priv *priv, struct il_rxon_context *ctx) ctx->timing.atim_window = 0; beacon_int = il_adjust_beacon_interval(beacon_int, - priv->hw_params.max_beacon_itrvl * TIME_UNIT); + il->hw_params.max_beacon_itrvl * TIME_UNIT); ctx->timing.beacon_interval = cpu_to_le16(beacon_int); - tsf = priv->timestamp; /* tsf is modifed by do_div: copy it */ + tsf = il->timestamp; /* tsf is modifed by do_div: copy it */ interval_tm = beacon_int * TIME_UNIT; rem = do_div(tsf, interval_tm); ctx->timing.beacon_init_val = cpu_to_le32(interval_tm - rem); ctx->timing.dtim_period = vif ? (vif->bss_conf.dtim_period ?: 1) : 1; - IL_DEBUG_ASSOC(priv, + IL_DEBUG_ASSOC(il, "beacon interval %d beacon timer %d beacon tim %d\n", le16_to_cpu(ctx->timing.beacon_interval), le32_to_cpu(ctx->timing.beacon_init_val), le16_to_cpu(ctx->timing.atim_window)); - return il_send_cmd_pdu(priv, ctx->rxon_timing_cmd, + return il_send_cmd_pdu(il, ctx->rxon_timing_cmd, sizeof(ctx->timing), &ctx->timing); } EXPORT_SYMBOL(il_send_rxon_timing); void -il_set_rxon_hwcrypto(struct il_priv *priv, +il_set_rxon_hwcrypto(struct il_priv *il, struct il_rxon_context *ctx, int hw_decrypt) { @@ -424,72 +424,72 @@ EXPORT_SYMBOL(il_set_rxon_hwcrypto); /* validate RXON structure is valid */ int -il_check_rxon_cmd(struct il_priv *priv, struct il_rxon_context *ctx) +il_check_rxon_cmd(struct il_priv *il, struct il_rxon_context *ctx) { struct il_rxon_cmd *rxon = &ctx->staging; bool error = false; if (rxon->flags & RXON_FLG_BAND_24G_MSK) { if (rxon->flags & RXON_FLG_TGJ_NARROW_BAND_MSK) { - IL_WARN(priv, "check 2.4G: wrong narrow\n"); + IL_WARN(il, "check 2.4G: wrong narrow\n"); error = true; } if (rxon->flags & RXON_FLG_RADAR_DETECT_MSK) { - IL_WARN(priv, "check 2.4G: wrong radar\n"); + IL_WARN(il, "check 2.4G: wrong radar\n"); error = true; } } else { if (!(rxon->flags & RXON_FLG_SHORT_SLOT_MSK)) { - IL_WARN(priv, "check 5.2G: not short slot!\n"); + IL_WARN(il, "check 5.2G: not short slot!\n"); error = true; } if (rxon->flags & RXON_FLG_CCK_MSK) { - IL_WARN(priv, "check 5.2G: CCK!\n"); + IL_WARN(il, "check 5.2G: CCK!\n"); error = true; } } if ((rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1) { - IL_WARN(priv, "mac/bssid mcast!\n"); + IL_WARN(il, "mac/bssid mcast!\n"); error = true; } /* make sure basic rates 6Mbps and 1Mbps are supported */ if ((rxon->ofdm_basic_rates & IL_RATE_6M_MASK) == 0 && (rxon->cck_basic_rates & IL_RATE_1M_MASK) == 0) { - IL_WARN(priv, "neither 1 nor 6 are basic\n"); + IL_WARN(il, "neither 1 nor 6 are basic\n"); error = true; } if (le16_to_cpu(rxon->assoc_id) > 2007) { - IL_WARN(priv, "aid > 2007\n"); + IL_WARN(il, "aid > 2007\n"); error = true; } if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) { - IL_WARN(priv, "CCK and short slot\n"); + IL_WARN(il, "CCK and short slot\n"); error = true; } if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) { - IL_WARN(priv, "CCK and auto detect"); + IL_WARN(il, "CCK and auto detect"); error = true; } if ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_TGG_PROTECT_MSK)) == RXON_FLG_TGG_PROTECT_MSK) { - IL_WARN(priv, "TGg but no auto-detect\n"); + IL_WARN(il, "TGg but no auto-detect\n"); error = true; } if (error) - IL_WARN(priv, "Tuning to channel %d\n", + IL_WARN(il, "Tuning to channel %d\n", le16_to_cpu(rxon->channel)); if (error) { - IL_ERR(priv, "Invalid RXON\n"); + IL_ERR(il, "Invalid RXON\n"); return -EINVAL; } return 0; @@ -498,13 +498,13 @@ EXPORT_SYMBOL(il_check_rxon_cmd); /** * il_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed - * @priv: staging_rxon is compared to active_rxon + * @il: staging_rxon is compared to active_rxon * * If the RXON structure is changing enough to require a new tune, * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required. */ -int il_full_rxon_required(struct il_priv *priv, +int il_full_rxon_required(struct il_priv *il, struct il_rxon_context *ctx) { const struct il_rxon_cmd *staging = &ctx->staging; @@ -512,13 +512,13 @@ int il_full_rxon_required(struct il_priv *priv, #define CHK(cond) \ if ((cond)) { \ - IL_DEBUG_INFO(priv, "need full RXON - " #cond "\n"); \ + IL_DEBUG_INFO(il, "need full RXON - " #cond "\n"); \ return 1; \ } #define CHK_NEQ(c1, c2) \ if ((c1) != (c2)) { \ - IL_DEBUG_INFO(priv, "need full RXON - " \ + IL_DEBUG_INFO(il, "need full RXON - " \ #c1 " != " #c2 " - %d != %d\n", \ (c1), (c2)); \ return 1; \ @@ -558,7 +558,7 @@ int il_full_rxon_required(struct il_priv *priv, } EXPORT_SYMBOL(il_full_rxon_required); -u8 il_get_lowest_plcp(struct il_priv *priv, +u8 il_get_lowest_plcp(struct il_priv *il, struct il_rxon_context *ctx) { /* @@ -572,7 +572,7 @@ u8 il_get_lowest_plcp(struct il_priv *priv, } EXPORT_SYMBOL(il_get_lowest_plcp); -static void _il_set_rxon_ht(struct il_priv *priv, +static void _il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf, struct il_rxon_context *ctx) { @@ -594,7 +594,7 @@ static void _il_set_rxon_ht(struct il_priv *priv, /* clear the HT channel mode before set the mode */ rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); - if (il_is_ht40_tx_allowed(priv, ctx, NULL)) { + if (il_is_ht40_tx_allowed(il, ctx, NULL)) { /* pure ht40 */ if (ctx->ht.protection == IEEE80211_HT_OP_MODE_PROTECTION_20MHZ) { @@ -626,7 +626,7 @@ static void _il_set_rxon_ht(struct il_priv *priv, case IEEE80211_HT_PARAM_CHA_SEC_NONE: default: /* channel location only valid if in Mixed mode */ - IL_ERR(priv, + IL_ERR(il, "invalid extension channel offset\n"); break; } @@ -635,26 +635,26 @@ static void _il_set_rxon_ht(struct il_priv *priv, rxon->flags |= RXON_FLG_CHANNEL_MODE_LEGACY; } - if (priv->cfg->ops->hcmd->set_rxon_chain) - priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); - IL_DEBUG_ASSOC(priv, "rxon flags 0x%X operation mode :0x%X " + IL_DEBUG_ASSOC(il, "rxon flags 0x%X operation mode :0x%X " "extension channel offset 0x%x\n", le32_to_cpu(rxon->flags), ctx->ht.protection, ctx->ht.extension_chan_offset); } -void il_set_rxon_ht(struct il_priv *priv, struct il_ht_config *ht_conf) +void il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf) { struct il_rxon_context *ctx; - for_each_context(priv, ctx) - _il_set_rxon_ht(priv, ht_conf, ctx); + for_each_context(il, ctx) + _il_set_rxon_ht(il, ht_conf, ctx); } EXPORT_SYMBOL(il_set_rxon_ht); /* Return valid, unused, channel for a passive scan to reset the RF */ -u8 il_get_single_channel_number(struct il_priv *priv, +u8 il_get_single_channel_number(struct il_priv *il, enum ieee80211_band band) { const struct il_channel_info *ch_info; @@ -665,7 +665,7 @@ u8 il_get_single_channel_number(struct il_priv *priv, if (band == IEEE80211_BAND_5GHZ) { min = 14; - max = priv->channel_count; + max = il->channel_count; } else { min = 0; max = 14; @@ -674,8 +674,8 @@ u8 il_get_single_channel_number(struct il_priv *priv, for (i = min; i < max; i++) { bool busy = false; - for_each_context(priv, ctx) { - busy = priv->channel_info[i].channel == + for_each_context(il, ctx) { + busy = il->channel_info[i].channel == le16_to_cpu(ctx->staging.channel); if (busy) break; @@ -684,8 +684,8 @@ u8 il_get_single_channel_number(struct il_priv *priv, if (busy) continue; - channel = priv->channel_info[i].channel; - ch_info = il_get_channel_info(priv, band, channel); + channel = il->channel_info[i].channel; + ch_info = il_get_channel_info(il, band, channel); if (il_is_channel_valid(ch_info)) break; } @@ -702,14 +702,14 @@ EXPORT_SYMBOL(il_get_single_channel_number); * in the staging RXON flag structure based on the ch->band */ int -il_set_rxon_channel(struct il_priv *priv, struct ieee80211_channel *ch, +il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch, struct il_rxon_context *ctx) { enum ieee80211_band band = ch->band; u16 channel = ch->hw_value; if ((le16_to_cpu(ctx->staging.channel) == channel) && - (priv->band == band)) + (il->band == band)) return 0; ctx->staging.channel = cpu_to_le16(channel); @@ -718,15 +718,15 @@ il_set_rxon_channel(struct il_priv *priv, struct ieee80211_channel *ch, else ctx->staging.flags |= RXON_FLG_BAND_24G_MSK; - priv->band = band; + il->band = band; - IL_DEBUG_INFO(priv, "Staging channel set to %d [%d]\n", channel, band); + IL_DEBUG_INFO(il, "Staging channel set to %d [%d]\n", channel, band); return 0; } EXPORT_SYMBOL(il_set_rxon_channel); -void il_set_flags_for_band(struct il_priv *priv, +void il_set_flags_for_band(struct il_priv *il, struct il_rxon_context *ctx, enum ieee80211_band band, struct ieee80211_vif *vif) @@ -753,7 +753,7 @@ EXPORT_SYMBOL(il_set_flags_for_band); /* * initialize rxon structure with default values from eeprom */ -void il_connection_init_rx_config(struct il_priv *priv, +void il_connection_init_rx_config(struct il_priv *il, struct il_rxon_context *ctx) { const struct il_channel_info *ch_info; @@ -778,7 +778,7 @@ void il_connection_init_rx_config(struct il_priv *priv, break; default: - IL_ERR(priv, "Unsupported interface type %d\n", + IL_ERR(il, "Unsupported interface type %d\n", ctx->vif->type); break; } @@ -786,22 +786,22 @@ void il_connection_init_rx_config(struct il_priv *priv, #if 0 /* TODO: Figure out when short_preamble would be set and cache from * that */ - if (!hw_to_local(priv->hw)->short_preamble) + if (!hw_to_local(il->hw)->short_preamble) ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; else ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; #endif - ch_info = il_get_channel_info(priv, priv->band, + ch_info = il_get_channel_info(il, il->band, le16_to_cpu(ctx->active.channel)); if (!ch_info) - ch_info = &priv->channel_info[0]; + ch_info = &il->channel_info[0]; ctx->staging.channel = cpu_to_le16(ch_info->channel); - priv->band = ch_info->band; + il->band = ch_info->band; - il_set_flags_for_band(priv, ctx, priv->band, ctx->vif); + il_set_flags_for_band(il, ctx, il->band, ctx->vif); ctx->staging.ofdm_basic_rates = (IL_OFDM_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; @@ -819,30 +819,30 @@ void il_connection_init_rx_config(struct il_priv *priv, } EXPORT_SYMBOL(il_connection_init_rx_config); -void il_set_rate(struct il_priv *priv) +void il_set_rate(struct il_priv *il) { const struct ieee80211_supported_band *hw = NULL; struct ieee80211_rate *rate; struct il_rxon_context *ctx; int i; - hw = il_get_hw_mode(priv, priv->band); + hw = il_get_hw_mode(il, il->band); if (!hw) { - IL_ERR(priv, "Failed to set rate: unable to get hw mode\n"); + IL_ERR(il, "Failed to set rate: unable to get hw mode\n"); return; } - priv->active_rate = 0; + il->active_rate = 0; for (i = 0; i < hw->n_bitrates; i++) { rate = &(hw->bitrates[i]); if (rate->hw_value < IL_RATE_COUNT_LEGACY) - priv->active_rate |= (1 << rate->hw_value); + il->active_rate |= (1 << rate->hw_value); } - IL_DEBUG_RATE(priv, "Set active_rate = %0x\n", priv->active_rate); + IL_DEBUG_RATE(il, "Set active_rate = %0x\n", il->active_rate); - for_each_context(priv, ctx) { + for_each_context(il, ctx) { ctx->staging.cck_basic_rates = (IL_CCK_BASIC_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; @@ -852,64 +852,64 @@ void il_set_rate(struct il_priv *priv) } EXPORT_SYMBOL(il_set_rate); -void il_chswitch_done(struct il_priv *priv, bool is_success) +void il_chswitch_done(struct il_priv *il, bool is_success) { - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; - if (test_and_clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status)) + if (test_and_clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status)) ieee80211_chswitch_done(ctx->vif, is_success); } EXPORT_SYMBOL(il_chswitch_done); -void il_rx_csa(struct il_priv *priv, struct il_rx_mem_buffer *rxb) +void il_rx_csa(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); struct il_csa_notification *csa = &(pkt->u.csa_notif); - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; struct il_rxon_cmd *rxon = (void *)&ctx->active; - if (!test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status)) + if (!test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status)) return; - if (!le32_to_cpu(csa->status) && csa->channel == priv->switch_channel) { + if (!le32_to_cpu(csa->status) && csa->channel == il->switch_channel) { rxon->channel = csa->channel; ctx->staging.channel = csa->channel; - IL_DEBUG_11H(priv, "CSA notif: channel %d\n", + IL_DEBUG_11H(il, "CSA notif: channel %d\n", le16_to_cpu(csa->channel)); - il_chswitch_done(priv, true); + il_chswitch_done(il, true); } else { - IL_ERR(priv, "CSA notif (fail) : channel %d\n", + IL_ERR(il, "CSA notif (fail) : channel %d\n", le16_to_cpu(csa->channel)); - il_chswitch_done(priv, false); + il_chswitch_done(il, false); } } EXPORT_SYMBOL(il_rx_csa); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -void il_print_rx_config_cmd(struct il_priv *priv, +void il_print_rx_config_cmd(struct il_priv *il, struct il_rxon_context *ctx) { struct il_rxon_cmd *rxon = &ctx->staging; - IL_DEBUG_RADIO(priv, "RX CONFIG:\n"); - il_print_hex_dump(priv, IL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); - IL_DEBUG_RADIO(priv, "u16 channel: 0x%x\n", + IL_DEBUG_RADIO(il, "RX CONFIG:\n"); + il_print_hex_dump(il, IL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); + IL_DEBUG_RADIO(il, "u16 channel: 0x%x\n", le16_to_cpu(rxon->channel)); - IL_DEBUG_RADIO(priv, "u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags)); - IL_DEBUG_RADIO(priv, "u32 filter_flags: 0x%08x\n", + IL_DEBUG_RADIO(il, "u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags)); + IL_DEBUG_RADIO(il, "u32 filter_flags: 0x%08x\n", le32_to_cpu(rxon->filter_flags)); - IL_DEBUG_RADIO(priv, "u8 dev_type: 0x%x\n", rxon->dev_type); - IL_DEBUG_RADIO(priv, "u8 ofdm_basic_rates: 0x%02x\n", + IL_DEBUG_RADIO(il, "u8 dev_type: 0x%x\n", rxon->dev_type); + IL_DEBUG_RADIO(il, "u8 ofdm_basic_rates: 0x%02x\n", rxon->ofdm_basic_rates); - IL_DEBUG_RADIO(priv, "u8 cck_basic_rates: 0x%02x\n", + IL_DEBUG_RADIO(il, "u8 cck_basic_rates: 0x%02x\n", rxon->cck_basic_rates); - IL_DEBUG_RADIO(priv, "u8[6] node_addr: %pM\n", rxon->node_addr); - IL_DEBUG_RADIO(priv, "u8[6] bssid_addr: %pM\n", rxon->bssid_addr); - IL_DEBUG_RADIO(priv, "u16 assoc_id: 0x%x\n", + IL_DEBUG_RADIO(il, "u8[6] node_addr: %pM\n", rxon->node_addr); + IL_DEBUG_RADIO(il, "u8[6] bssid_addr: %pM\n", rxon->bssid_addr); + IL_DEBUG_RADIO(il, "u16 assoc_id: 0x%x\n", le16_to_cpu(rxon->assoc_id)); } EXPORT_SYMBOL(il_print_rx_config_cmd); @@ -917,68 +917,68 @@ EXPORT_SYMBOL(il_print_rx_config_cmd); /** * il_irq_handle_error - called for HW or SW error interrupt from card */ -void il_irq_handle_error(struct il_priv *priv) +void il_irq_handle_error(struct il_priv *il) { /* Set the FW error flag -- cleared on il_down */ - set_bit(STATUS_FW_ERROR, &priv->status); + set_bit(STATUS_FW_ERROR, &il->status); /* Cancel currently queued command. */ - clear_bit(STATUS_HCMD_ACTIVE, &priv->status); + clear_bit(STATUS_HCMD_ACTIVE, &il->status); - IL_ERR(priv, "Loaded firmware version: %s\n", - priv->hw->wiphy->fw_version); + IL_ERR(il, "Loaded firmware version: %s\n", + il->hw->wiphy->fw_version); - priv->cfg->ops->lib->dump_nic_error_log(priv); - if (priv->cfg->ops->lib->dump_fh) - priv->cfg->ops->lib->dump_fh(priv, NULL, false); + il->cfg->ops->lib->dump_nic_error_log(il); + if (il->cfg->ops->lib->dump_fh) + il->cfg->ops->lib->dump_fh(il, NULL, false); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (il_get_debug_level(priv) & IL_DL_FW_ERRORS) - il_print_rx_config_cmd(priv, - &priv->contexts[IL_RXON_CTX_BSS]); + if (il_get_debug_level(il) & IL_DL_FW_ERRORS) + il_print_rx_config_cmd(il, + &il->contexts[IL_RXON_CTX_BSS]); #endif - wake_up(&priv->wait_command_queue); + wake_up(&il->wait_command_queue); /* Keep the restart process from trying to send host * commands by clearing the INIT status bit */ - clear_bit(STATUS_READY, &priv->status); + clear_bit(STATUS_READY, &il->status); - if (!test_bit(STATUS_EXIT_PENDING, &priv->status)) { - IL_DEBUG(priv, IL_DL_FW_ERRORS, + if (!test_bit(STATUS_EXIT_PENDING, &il->status)) { + IL_DEBUG(il, IL_DL_FW_ERRORS, "Restarting adapter due to uCode error.\n"); - if (priv->cfg->mod_params->restart_fw) - queue_work(priv->workqueue, &priv->restart); + if (il->cfg->mod_params->restart_fw) + queue_work(il->workqueue, &il->restart); } } EXPORT_SYMBOL(il_irq_handle_error); -static int il_apm_stop_master(struct il_priv *priv) +static int il_apm_stop_master(struct il_priv *il) { int ret = 0; /* stop device's busmaster DMA activity */ - il_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); + il_set_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); - ret = il_poll_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, + ret = il_poll_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); if (ret) - IL_WARN(priv, "Master Disable Timed Out, 100 usec\n"); + IL_WARN(il, "Master Disable Timed Out, 100 usec\n"); - IL_DEBUG_INFO(priv, "stop master\n"); + IL_DEBUG_INFO(il, "stop master\n"); return ret; } -void il_apm_stop(struct il_priv *priv) +void il_apm_stop(struct il_priv *il) { - IL_DEBUG_INFO(priv, "Stop card, put in low power state\n"); + IL_DEBUG_INFO(il, "Stop card, put in low power state\n"); /* Stop device's DMA activity */ - il_apm_stop_master(priv); + il_apm_stop_master(il); /* Reset the entire device */ - il_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); + il_set_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); udelay(10); @@ -986,7 +986,7 @@ void il_apm_stop(struct il_priv *priv) * Clear "initialization complete" bit to move adapter from * D0A* (powered-up Active) --> D0U* (Uninitialized) state. */ - il_clear_bit(priv, CSR_GP_CNTRL, + il_clear_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); } EXPORT_SYMBOL(il_apm_stop); @@ -997,12 +997,12 @@ EXPORT_SYMBOL(il_apm_stop); * (e.g. after platform boot, or shutdown via il_apm_stop()) * NOTE: This does not load uCode nor start the embedded processor */ -int il_apm_init(struct il_priv *priv) +int il_apm_init(struct il_priv *il) { int ret = 0; u16 lctl; - IL_DEBUG_INFO(priv, "Init card's basic functions\n"); + IL_DEBUG_INFO(il, "Init card's basic functions\n"); /* * Use "set_bit" below rather than "write", to preserve any hardware @@ -1010,18 +1010,18 @@ int il_apm_init(struct il_priv *priv) */ /* Disable L0S exit timer (platform NMI Work/Around) */ - il_set_bit(priv, CSR_GIO_CHICKEN_BITS, + il_set_bit(il, CSR_GIO_CHICKEN_BITS, CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); /* * Disable L0s without affecting L1; * don't wait for ICH L0s (ICH bug W/A) */ - il_set_bit(priv, CSR_GIO_CHICKEN_BITS, + il_set_bit(il, CSR_GIO_CHICKEN_BITS, CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX); /* Set FH wait threshold to maximum (HW error during stress W/A) */ - il_set_bit(priv, CSR_DBG_HPET_MEM_REG, + il_set_bit(il, CSR_DBG_HPET_MEM_REG, CSR_DBG_HPET_MEM_REG_VAL); /* @@ -1029,7 +1029,7 @@ int il_apm_init(struct il_priv *priv) * wake device's PCI Express link L1a -> L0s * NOTE: This is no-op for 3945 (non-existent bit) */ - il_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); /* @@ -1040,43 +1040,43 @@ int il_apm_init(struct il_priv *priv) * If not (unlikely), enable L0S, so there is at least some * power savings, even without L1. */ - if (priv->cfg->base_params->set_l0s) { - lctl = il_pcie_link_ctl(priv); + if (il->cfg->base_params->set_l0s) { + lctl = il_pcie_link_ctl(il); if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) == PCI_CFG_LINK_CTRL_VAL_L1_EN) { /* L1-ASPM enabled; disable(!) L0S */ - il_set_bit(priv, CSR_GIO_REG, + il_set_bit(il, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); - IL_DEBUG_POWER(priv, "L1 Enabled; Disabling L0S\n"); + IL_DEBUG_POWER(il, "L1 Enabled; Disabling L0S\n"); } else { /* L1-ASPM disabled; enable(!) L0S */ - il_clear_bit(priv, CSR_GIO_REG, + il_clear_bit(il, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); - IL_DEBUG_POWER(priv, "L1 Disabled; Enabling L0S\n"); + IL_DEBUG_POWER(il, "L1 Disabled; Enabling L0S\n"); } } /* Configure analog phase-lock-loop before activating to D0A */ - if (priv->cfg->base_params->pll_cfg_val) - il_set_bit(priv, CSR_ANA_PLL_CFG, - priv->cfg->base_params->pll_cfg_val); + if (il->cfg->base_params->pll_cfg_val) + il_set_bit(il, CSR_ANA_PLL_CFG, + il->cfg->base_params->pll_cfg_val); /* * Set "initialization complete" bit to move adapter from * D0U* --> D0A* (powered-up active) state. */ - il_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); + il_set_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); /* * Wait for clock stabilization; once stabilized, access to * device-internal resources is supported, e.g. il_write_prph() * and accesses to uCode SRAM. */ - ret = il_poll_bit(priv, CSR_GP_CNTRL, + ret = il_poll_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); if (ret < 0) { - IL_DEBUG_INFO(priv, "Failed to init the card\n"); + IL_DEBUG_INFO(il, "Failed to init the card\n"); goto out; } @@ -1088,16 +1088,16 @@ int il_apm_init(struct il_priv *priv) * do not disable clocks. This preserves any hardware bits already * set by default in "CLK_CTRL_REG" after reset. */ - if (priv->cfg->base_params->use_bsm) - il_write_prph(priv, APMG_CLK_EN_REG, + if (il->cfg->base_params->use_bsm) + il_write_prph(il, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT | APMG_CLK_VAL_BSM_CLK_RQT); else - il_write_prph(priv, APMG_CLK_EN_REG, + il_write_prph(il, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT); udelay(20); /* Disable L1-Active */ - il_set_bits_prph(priv, APMG_PCIDEV_STT_REG, + il_set_bits_prph(il, APMG_PCIDEV_STT_REG, APMG_PCIDEV_STT_VAL_L1_ACT_DIS); out: @@ -1106,66 +1106,66 @@ out: EXPORT_SYMBOL(il_apm_init); -int il_set_tx_power(struct il_priv *priv, s8 tx_power, bool force) +int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) { int ret; s8 prev_tx_power; bool defer; - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - if (priv->tx_power_user_lmt == tx_power && !force) + if (il->tx_power_user_lmt == tx_power && !force) return 0; - if (!priv->cfg->ops->lib->send_tx_power) + if (!il->cfg->ops->lib->send_tx_power) return -EOPNOTSUPP; /* 0 dBm mean 1 milliwatt */ if (tx_power < 0) { - IL_WARN(priv, + IL_WARN(il, "Requested user TXPOWER %d below 1 mW.\n", tx_power); return -EINVAL; } - if (tx_power > priv->tx_power_device_lmt) { - IL_WARN(priv, + if (tx_power > il->tx_power_device_lmt) { + IL_WARN(il, "Requested user TXPOWER %d above upper limit %d.\n", - tx_power, priv->tx_power_device_lmt); + tx_power, il->tx_power_device_lmt); return -EINVAL; } - if (!il_is_ready_rf(priv)) + if (!il_is_ready_rf(il)) return -EIO; /* scan complete and commit_rxon use tx_power_next value, * it always need to be updated for newest request */ - priv->tx_power_next = tx_power; + il->tx_power_next = tx_power; /* do not set tx power when scanning or channel changing */ - defer = test_bit(STATUS_SCANNING, &priv->status) || + defer = test_bit(STATUS_SCANNING, &il->status) || memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging)); if (defer && !force) { - IL_DEBUG_INFO(priv, "Deferring tx power set\n"); + IL_DEBUG_INFO(il, "Deferring tx power set\n"); return 0; } - prev_tx_power = priv->tx_power_user_lmt; - priv->tx_power_user_lmt = tx_power; + prev_tx_power = il->tx_power_user_lmt; + il->tx_power_user_lmt = tx_power; - ret = priv->cfg->ops->lib->send_tx_power(priv); + ret = il->cfg->ops->lib->send_tx_power(il); /* if fail to set tx_power, restore the orig. tx power */ if (ret) { - priv->tx_power_user_lmt = prev_tx_power; - priv->tx_power_next = prev_tx_power; + il->tx_power_user_lmt = prev_tx_power; + il->tx_power_next = prev_tx_power; } return ret; } EXPORT_SYMBOL(il_set_tx_power); -void il_send_bt_config(struct il_priv *priv) +void il_send_bt_config(struct il_priv *il) { struct il_bt_cmd bt_cmd = { .lead_time = BT_LEAD_TIME_DEF, @@ -1179,16 +1179,16 @@ void il_send_bt_config(struct il_priv *priv) else bt_cmd.flags = BT_COEX_ENABLE; - IL_DEBUG_INFO(priv, "BT coex %s\n", + IL_DEBUG_INFO(il, "BT coex %s\n", (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active"); - if (il_send_cmd_pdu(priv, REPLY_BT_CONFIG, + if (il_send_cmd_pdu(il, REPLY_BT_CONFIG, sizeof(struct il_bt_cmd), &bt_cmd)) - IL_ERR(priv, "failed to send BT Coex Config\n"); + IL_ERR(il, "failed to send BT Coex Config\n"); } EXPORT_SYMBOL(il_send_bt_config); -int il_send_statistics_request(struct il_priv *priv, u8 flags, bool clear) +int il_send_statistics_request(struct il_priv *il, u8 flags, bool clear) { struct il_statistics_cmd statistics_cmd = { .configuration_flags = @@ -1196,46 +1196,46 @@ int il_send_statistics_request(struct il_priv *priv, u8 flags, bool clear) }; if (flags & CMD_ASYNC) - return il_send_cmd_pdu_async(priv, REPLY_STATISTICS_CMD, + return il_send_cmd_pdu_async(il, REPLY_STATISTICS_CMD, sizeof(struct il_statistics_cmd), &statistics_cmd, NULL); else - return il_send_cmd_pdu(priv, REPLY_STATISTICS_CMD, + return il_send_cmd_pdu(il, REPLY_STATISTICS_CMD, sizeof(struct il_statistics_cmd), &statistics_cmd); } EXPORT_SYMBOL(il_send_statistics_request); -void il_rx_pm_sleep_notif(struct il_priv *priv, +void il_rx_pm_sleep_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG struct il_rx_packet *pkt = rxb_addr(rxb); struct il_sleep_notification *sleep = &(pkt->u.sleep_notif); - IL_DEBUG_RX(priv, "sleep mode: %d, src: %d\n", + IL_DEBUG_RX(il, "sleep mode: %d, src: %d\n", sleep->pm_sleep_mode, sleep->pm_wakeup_src); #endif } EXPORT_SYMBOL(il_rx_pm_sleep_notif); -void il_rx_pm_debug_statistics_notif(struct il_priv *priv, +void il_rx_pm_debug_statistics_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; - IL_DEBUG_RADIO(priv, "Dumping %d bytes of unhandled " + IL_DEBUG_RADIO(il, "Dumping %d bytes of unhandled " "notification for %s:\n", len, il_get_cmd_string(pkt->hdr.cmd)); - il_print_hex_dump(priv, IL_DL_RADIO, pkt->u.raw, len); + il_print_hex_dump(il, IL_DL_RADIO, pkt->u.raw, len); } EXPORT_SYMBOL(il_rx_pm_debug_statistics_notif); -void il_rx_reply_error(struct il_priv *priv, +void il_rx_reply_error(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); - IL_ERR(priv, "Error Reply type 0x%08X cmd %s (0x%02X) " + IL_ERR(il, "Error Reply type 0x%08X cmd %s (0x%02X) " "seq 0x%04X ser 0x%08X\n", le32_to_cpu(pkt->u.err_resp.error_type), il_get_cmd_string(pkt->u.err_resp.cmd_id), @@ -1245,37 +1245,37 @@ void il_rx_reply_error(struct il_priv *priv, } EXPORT_SYMBOL(il_rx_reply_error); -void il_clear_isr_stats(struct il_priv *priv) +void il_clear_isr_stats(struct il_priv *il) { - memset(&priv->isr_stats, 0, sizeof(priv->isr_stats)); + memset(&il->isr_stats, 0, sizeof(il->isr_stats)); } int il_mac_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue, const struct ieee80211_tx_queue_params *params) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; struct il_rxon_context *ctx; unsigned long flags; int q; - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); - if (!il_is_ready_rf(priv)) { - IL_DEBUG_MAC80211(priv, "leave - RF not ready\n"); + if (!il_is_ready_rf(il)) { + IL_DEBUG_MAC80211(il, "leave - RF not ready\n"); return -EIO; } if (queue >= AC_NUM) { - IL_DEBUG_MAC80211(priv, "leave - queue >= AC_NUM %d\n", queue); + IL_DEBUG_MAC80211(il, "leave - queue >= AC_NUM %d\n", queue); return 0; } q = AC_NUM - 1 - queue; - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); - for_each_context(priv, ctx) { + for_each_context(il, ctx) { ctx->qos_data.def_qos_parm.ac[q].cw_min = cpu_to_le16(params->cw_min); ctx->qos_data.def_qos_parm.ac[q].cw_max = @@ -1287,50 +1287,50 @@ int il_mac_conf_tx(struct ieee80211_hw *hw, ctx->qos_data.def_qos_parm.ac[q].reserved1 = 0; } - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); - IL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(il, "leave\n"); return 0; } EXPORT_SYMBOL(il_mac_conf_tx); int il_mac_tx_last_beacon(struct ieee80211_hw *hw) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; - return priv->ibss_manager == IL_IBSS_MANAGER; + return il->ibss_manager == IL_IBSS_MANAGER; } EXPORT_SYMBOL_GPL(il_mac_tx_last_beacon); static int -il_set_mode(struct il_priv *priv, struct il_rxon_context *ctx) +il_set_mode(struct il_priv *il, struct il_rxon_context *ctx) { - il_connection_init_rx_config(priv, ctx); + il_connection_init_rx_config(il, ctx); - if (priv->cfg->ops->hcmd->set_rxon_chain) - priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); - return il_commit_rxon(priv, ctx); + return il_commit_rxon(il, ctx); } -static int il_setup_interface(struct il_priv *priv, +static int il_setup_interface(struct il_priv *il, struct il_rxon_context *ctx) { struct ieee80211_vif *vif = ctx->vif; int err; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); /* * This variable will be correct only when there's just * a single context, but all code using it is for hardware * that supports only one context. */ - priv->iw_mode = vif->type; + il->iw_mode = vif->type; ctx->is_active = true; - err = il_set_mode(priv, ctx); + err = il_set_mode(il, ctx); if (err) { if (!ctx->always_active) ctx->is_active = false; @@ -1343,23 +1343,23 @@ static int il_setup_interface(struct il_priv *priv, int il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; struct il_vif_priv *vif_priv = (void *)vif->drv_priv; struct il_rxon_context *tmp, *ctx = NULL; int err; - IL_DEBUG_MAC80211(priv, "enter: type %d, addr %pM\n", + IL_DEBUG_MAC80211(il, "enter: type %d, addr %pM\n", vif->type, vif->addr); - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); - if (!il_is_ready_rf(priv)) { - IL_WARN(priv, "Try to add interface when device not ready\n"); + if (!il_is_ready_rf(il)) { + IL_WARN(il, "Try to add interface when device not ready\n"); err = -EINVAL; goto out; } - for_each_context(priv, tmp) { + for_each_context(il, tmp) { u32 possible_modes = tmp->interface_modes | tmp->exclusive_interface_modes; @@ -1389,35 +1389,35 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) vif_priv->ctx = ctx; ctx->vif = vif; - err = il_setup_interface(priv, ctx); + err = il_setup_interface(il, ctx); if (!err) goto out; ctx->vif = NULL; - priv->iw_mode = NL80211_IFTYPE_STATION; + il->iw_mode = NL80211_IFTYPE_STATION; out: - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); - IL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(il, "leave\n"); return err; } EXPORT_SYMBOL(il_mac_add_interface); -static void il_teardown_interface(struct il_priv *priv, +static void il_teardown_interface(struct il_priv *il, struct ieee80211_vif *vif, bool mode_change) { struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - if (priv->scan_vif == vif) { - il_scan_cancel_timeout(priv, 200); - il_force_scan_end(priv); + if (il->scan_vif == vif) { + il_scan_cancel_timeout(il, 200); + il_force_scan_end(il); } if (!mode_change) { - il_set_mode(priv, ctx); + il_set_mode(il, ctx); if (!ctx->always_active) ctx->is_active = false; } @@ -1426,45 +1426,45 @@ static void il_teardown_interface(struct il_priv *priv, void il_mac_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); WARN_ON(ctx->vif != vif); ctx->vif = NULL; - il_teardown_interface(priv, vif, false); + il_teardown_interface(il, vif, false); - memset(priv->bssid, 0, ETH_ALEN); - mutex_unlock(&priv->mutex); + memset(il->bssid, 0, ETH_ALEN); + mutex_unlock(&il->mutex); - IL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(il, "leave\n"); } EXPORT_SYMBOL(il_mac_remove_interface); -int il_alloc_txq_mem(struct il_priv *priv) +int il_alloc_txq_mem(struct il_priv *il) { - if (!priv->txq) - priv->txq = kzalloc( + if (!il->txq) + il->txq = kzalloc( sizeof(struct il_tx_queue) * - priv->cfg->base_params->num_of_queues, + il->cfg->base_params->num_of_queues, GFP_KERNEL); - if (!priv->txq) { - IL_ERR(priv, "Not enough memory for txq\n"); + if (!il->txq) { + IL_ERR(il, "Not enough memory for txq\n"); return -ENOMEM; } return 0; } EXPORT_SYMBOL(il_alloc_txq_mem); -void il_txq_mem(struct il_priv *priv) +void il_txq_mem(struct il_priv *il) { - kfree(priv->txq); - priv->txq = NULL; + kfree(il->txq); + il->txq = NULL; } EXPORT_SYMBOL(il_txq_mem); @@ -1472,52 +1472,52 @@ EXPORT_SYMBOL(il_txq_mem); #define IL_TRAFFIC_DUMP_SIZE (IL_TRAFFIC_ENTRY_SIZE * IL_TRAFFIC_ENTRIES) -void il_reset_traffic_log(struct il_priv *priv) +void il_reset_traffic_log(struct il_priv *il) { - priv->tx_traffic_idx = 0; - priv->rx_traffic_idx = 0; - if (priv->tx_traffic) - memset(priv->tx_traffic, 0, IL_TRAFFIC_DUMP_SIZE); - if (priv->rx_traffic) - memset(priv->rx_traffic, 0, IL_TRAFFIC_DUMP_SIZE); + il->tx_traffic_idx = 0; + il->rx_traffic_idx = 0; + if (il->tx_traffic) + memset(il->tx_traffic, 0, IL_TRAFFIC_DUMP_SIZE); + if (il->rx_traffic) + memset(il->rx_traffic, 0, IL_TRAFFIC_DUMP_SIZE); } -int il_alloc_traffic_mem(struct il_priv *priv) +int il_alloc_traffic_mem(struct il_priv *il) { u32 traffic_size = IL_TRAFFIC_DUMP_SIZE; if (iwlegacy_debug_level & IL_DL_TX) { - if (!priv->tx_traffic) { - priv->tx_traffic = + if (!il->tx_traffic) { + il->tx_traffic = kzalloc(traffic_size, GFP_KERNEL); - if (!priv->tx_traffic) + if (!il->tx_traffic) return -ENOMEM; } } if (iwlegacy_debug_level & IL_DL_RX) { - if (!priv->rx_traffic) { - priv->rx_traffic = + if (!il->rx_traffic) { + il->rx_traffic = kzalloc(traffic_size, GFP_KERNEL); - if (!priv->rx_traffic) + if (!il->rx_traffic) return -ENOMEM; } } - il_reset_traffic_log(priv); + il_reset_traffic_log(il); return 0; } EXPORT_SYMBOL(il_alloc_traffic_mem); -void il_free_traffic_mem(struct il_priv *priv) +void il_free_traffic_mem(struct il_priv *il) { - kfree(priv->tx_traffic); - priv->tx_traffic = NULL; + kfree(il->tx_traffic); + il->tx_traffic = NULL; - kfree(priv->rx_traffic); - priv->rx_traffic = NULL; + kfree(il->rx_traffic); + il->rx_traffic = NULL; } EXPORT_SYMBOL(il_free_traffic_mem); -void il_dbg_log_tx_data_frame(struct il_priv *priv, +void il_dbg_log_tx_data_frame(struct il_priv *il, u16 length, struct ieee80211_hdr *header) { __le16 fc; @@ -1526,23 +1526,23 @@ void il_dbg_log_tx_data_frame(struct il_priv *priv, if (likely(!(iwlegacy_debug_level & IL_DL_TX))) return; - if (!priv->tx_traffic) + if (!il->tx_traffic) return; fc = header->frame_control; if (ieee80211_is_data(fc)) { len = (length > IL_TRAFFIC_ENTRY_SIZE) ? IL_TRAFFIC_ENTRY_SIZE : length; - memcpy((priv->tx_traffic + - (priv->tx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), + memcpy((il->tx_traffic + + (il->tx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), header, len); - priv->tx_traffic_idx = - (priv->tx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; + il->tx_traffic_idx = + (il->tx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; } } EXPORT_SYMBOL(il_dbg_log_tx_data_frame); -void il_dbg_log_rx_data_frame(struct il_priv *priv, +void il_dbg_log_rx_data_frame(struct il_priv *il, u16 length, struct ieee80211_hdr *header) { __le16 fc; @@ -1551,18 +1551,18 @@ void il_dbg_log_rx_data_frame(struct il_priv *priv, if (likely(!(iwlegacy_debug_level & IL_DL_RX))) return; - if (!priv->rx_traffic) + if (!il->rx_traffic) return; fc = header->frame_control; if (ieee80211_is_data(fc)) { len = (length > IL_TRAFFIC_ENTRY_SIZE) ? IL_TRAFFIC_ENTRY_SIZE : length; - memcpy((priv->rx_traffic + - (priv->rx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), + memcpy((il->rx_traffic + + (il->rx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), header, len); - priv->rx_traffic_idx = - (priv->rx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; + il->rx_traffic_idx = + (il->rx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; } } EXPORT_SYMBOL(il_dbg_log_rx_data_frame); @@ -1605,10 +1605,10 @@ const char *il_get_ctrl_string(int cmd) } } -void il_clear_traffic_stats(struct il_priv *priv) +void il_clear_traffic_stats(struct il_priv *il) { - memset(&priv->tx_stats, 0, sizeof(struct traffic_stats)); - memset(&priv->rx_stats, 0, sizeof(struct traffic_stats)); + memset(&il->tx_stats, 0, sizeof(struct traffic_stats)); + memset(&il->rx_stats, 0, sizeof(struct traffic_stats)); } /* @@ -1623,14 +1623,14 @@ void il_clear_traffic_stats(struct il_priv *priv) * */ void -il_update_stats(struct il_priv *priv, bool is_tx, __le16 fc, u16 len) +il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, u16 len) { struct traffic_stats *stats; if (is_tx) - stats = &priv->tx_stats; + stats = &il->tx_stats; else - stats = &priv->rx_stats; + stats = &il->rx_stats; if (ieee80211_is_mgmt(fc)) { switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) { @@ -1707,20 +1707,20 @@ il_update_stats(struct il_priv *priv, bool is_tx, __le16 fc, u16 len) EXPORT_SYMBOL(il_update_stats); #endif -int il_force_reset(struct il_priv *priv, bool external) +int il_force_reset(struct il_priv *il, bool external) { struct il_force_reset *force_reset; - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return -EINVAL; - force_reset = &priv->force_reset; + force_reset = &il->force_reset; force_reset->reset_request_count++; if (!external) { if (force_reset->last_force_reset_jiffies && time_after(force_reset->last_force_reset_jiffies + force_reset->reset_duration, jiffies)) { - IL_DEBUG_INFO(priv, "force reset rejected\n"); + IL_DEBUG_INFO(il, "force reset rejected\n"); force_reset->reset_reject_count++; return -EAGAIN; } @@ -1737,23 +1737,23 @@ int il_force_reset(struct il_priv *priv, bool external) * need to be check before performing firmware reload */ - if (!external && !priv->cfg->mod_params->restart_fw) { - IL_DEBUG_INFO(priv, "Cancel firmware reload based on " + if (!external && !il->cfg->mod_params->restart_fw) { + IL_DEBUG_INFO(il, "Cancel firmware reload based on " "module parameter setting\n"); return 0; } - IL_ERR(priv, "On demand firmware reload\n"); + IL_ERR(il, "On demand firmware reload\n"); /* Set the FW error flag -- cleared on il_down */ - set_bit(STATUS_FW_ERROR, &priv->status); - wake_up(&priv->wait_command_queue); + set_bit(STATUS_FW_ERROR, &il->status); + wake_up(&il->wait_command_queue); /* * Keep the restart process from trying to send host * commands by clearing the INIT status bit */ - clear_bit(STATUS_READY, &priv->status); - queue_work(priv->workqueue, &priv->restart); + clear_bit(STATUS_READY, &il->status); + queue_work(il->workqueue, &il->restart); return 0; } @@ -1763,7 +1763,7 @@ il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, enum nl80211_iftype newtype, bool newp2p) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); struct il_rxon_context *tmp; u32 interface_modes; @@ -1771,9 +1771,9 @@ il_mac_change_interface(struct ieee80211_hw *hw, newtype = ieee80211_iftype_p2p(newtype, newp2p); - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); - if (!ctx->vif || !il_is_ready_rf(priv)) { + if (!ctx->vif || !il_is_ready_rf(il)) { /* * Huh? But wait ... this can maybe happen when * we're in the middle of a firmware restart! @@ -1790,7 +1790,7 @@ il_mac_change_interface(struct ieee80211_hw *hw, } if (ctx->exclusive_interface_modes & BIT(newtype)) { - for_each_context(priv, tmp) { + for_each_context(il, tmp) { if (ctx == tmp) continue; @@ -1807,10 +1807,10 @@ il_mac_change_interface(struct ieee80211_hw *hw, } /* success */ - il_teardown_interface(priv, vif, true); + il_teardown_interface(il, vif, true); vif->type = newtype; vif->p2p = newp2p; - err = il_setup_interface(priv, ctx); + err = il_setup_interface(il, ctx); WARN_ON(err); /* * We've switched internally, but submitting to the @@ -1822,7 +1822,7 @@ il_mac_change_interface(struct ieee80211_hw *hw, err = 0; out: - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); return err; } EXPORT_SYMBOL(il_mac_change_interface); @@ -1831,9 +1831,9 @@ EXPORT_SYMBOL(il_mac_change_interface); * On every watchdog tick we check (latest) time stamp. If it does not * change during timeout period and queue is not empty we reset firmware. */ -static int il_check_stuck_queue(struct il_priv *priv, int cnt) +static int il_check_stuck_queue(struct il_priv *il, int cnt) { - struct il_tx_queue *txq = &priv->txq[cnt]; + struct il_tx_queue *txq = &il->txq[cnt]; struct il_queue *q = &txq->q; unsigned long timeout; int ret; @@ -1844,12 +1844,12 @@ static int il_check_stuck_queue(struct il_priv *priv, int cnt) } timeout = txq->time_stamp + - msecs_to_jiffies(priv->cfg->base_params->wd_timeout); + msecs_to_jiffies(il->cfg->base_params->wd_timeout); if (time_after(jiffies, timeout)) { - IL_ERR(priv, "Queue %d stuck for %u ms.\n", - q->id, priv->cfg->base_params->wd_timeout); - ret = il_force_reset(priv, false); + IL_ERR(il, "Queue %d stuck for %u ms.\n", + q->id, il->cfg->base_params->wd_timeout); + ret = il_force_reset(il, false); return (ret == -EAGAIN) ? 0 : 1; } @@ -1868,46 +1868,46 @@ static int il_check_stuck_queue(struct il_priv *priv, int cnt) */ void il_bg_watchdog(unsigned long data) { - struct il_priv *priv = (struct il_priv *)data; + struct il_priv *il = (struct il_priv *)data; int cnt; unsigned long timeout; - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; - timeout = priv->cfg->base_params->wd_timeout; + timeout = il->cfg->base_params->wd_timeout; if (timeout == 0) return; /* monitor and check for stuck cmd queue */ - if (il_check_stuck_queue(priv, priv->cmd_queue)) + if (il_check_stuck_queue(il, il->cmd_queue)) return; /* monitor and check for other stuck queues */ - if (il_is_any_associated(priv)) { - for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) { + if (il_is_any_associated(il)) { + for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { /* skip as we already checked the command queue */ - if (cnt == priv->cmd_queue) + if (cnt == il->cmd_queue) continue; - if (il_check_stuck_queue(priv, cnt)) + if (il_check_stuck_queue(il, cnt)) return; } } - mod_timer(&priv->watchdog, jiffies + + mod_timer(&il->watchdog, jiffies + msecs_to_jiffies(IL_WD_TICK(timeout))); } EXPORT_SYMBOL(il_bg_watchdog); -void il_setup_watchdog(struct il_priv *priv) +void il_setup_watchdog(struct il_priv *il) { - unsigned int timeout = priv->cfg->base_params->wd_timeout; + unsigned int timeout = il->cfg->base_params->wd_timeout; if (timeout) - mod_timer(&priv->watchdog, + mod_timer(&il->watchdog, jiffies + msecs_to_jiffies(IL_WD_TICK(timeout))); else - del_timer(&priv->watchdog); + del_timer(&il->watchdog); } EXPORT_SYMBOL(il_setup_watchdog); @@ -1918,7 +1918,7 @@ EXPORT_SYMBOL(il_setup_watchdog); * the internal part is the time in usec within one beacon interval */ u32 -il_usecs_to_beacons(struct il_priv *priv, +il_usecs_to_beacons(struct il_priv *il, u32 usec, u32 beacon_interval) { u32 quot; @@ -1929,39 +1929,39 @@ il_usecs_to_beacons(struct il_priv *priv, return 0; quot = (usec / interval) & - (il_beacon_time_mask_high(priv, - priv->hw_params.beacon_time_tsf_bits) >> - priv->hw_params.beacon_time_tsf_bits); - rem = (usec % interval) & il_beacon_time_mask_low(priv, - priv->hw_params.beacon_time_tsf_bits); + (il_beacon_time_mask_high(il, + il->hw_params.beacon_time_tsf_bits) >> + il->hw_params.beacon_time_tsf_bits); + rem = (usec % interval) & il_beacon_time_mask_low(il, + il->hw_params.beacon_time_tsf_bits); - return (quot << priv->hw_params.beacon_time_tsf_bits) + rem; + return (quot << il->hw_params.beacon_time_tsf_bits) + rem; } EXPORT_SYMBOL(il_usecs_to_beacons); /* base is usually what we get from ucode with each received frame, * the same as HW timer counter counting down */ -__le32 il_add_beacon_time(struct il_priv *priv, u32 base, +__le32 il_add_beacon_time(struct il_priv *il, u32 base, u32 addon, u32 beacon_interval) { - u32 base_low = base & il_beacon_time_mask_low(priv, - priv->hw_params.beacon_time_tsf_bits); - u32 addon_low = addon & il_beacon_time_mask_low(priv, - priv->hw_params.beacon_time_tsf_bits); + u32 base_low = base & il_beacon_time_mask_low(il, + il->hw_params.beacon_time_tsf_bits); + u32 addon_low = addon & il_beacon_time_mask_low(il, + il->hw_params.beacon_time_tsf_bits); u32 interval = beacon_interval * TIME_UNIT; - u32 res = (base & il_beacon_time_mask_high(priv, - priv->hw_params.beacon_time_tsf_bits)) + - (addon & il_beacon_time_mask_high(priv, - priv->hw_params.beacon_time_tsf_bits)); + u32 res = (base & il_beacon_time_mask_high(il, + il->hw_params.beacon_time_tsf_bits)) + + (addon & il_beacon_time_mask_high(il, + il->hw_params.beacon_time_tsf_bits)); if (base_low > addon_low) res += base_low - addon_low; else if (base_low < addon_low) { res += interval + base_low - addon_low; - res += (1 << priv->hw_params.beacon_time_tsf_bits); + res += (1 << il->hw_params.beacon_time_tsf_bits); } else - res += (1 << priv->hw_params.beacon_time_tsf_bits); + res += (1 << il->hw_params.beacon_time_tsf_bits); return cpu_to_le32(res); } @@ -1972,7 +1972,7 @@ EXPORT_SYMBOL(il_add_beacon_time); int il_pci_suspend(struct device *device) { struct pci_dev *pdev = to_pci_dev(device); - struct il_priv *priv = pci_get_drvdata(pdev); + struct il_priv *il = pci_get_drvdata(pdev); /* * This function is called when system goes into suspend state @@ -1981,7 +1981,7 @@ int il_pci_suspend(struct device *device) * it will not call apm_ops.stop() to stop the DMA operation. * Calling apm_ops.stop here to make sure we stop the DMA. */ - il_apm_stop(priv); + il_apm_stop(il); return 0; } @@ -1990,7 +1990,7 @@ EXPORT_SYMBOL(il_pci_suspend); int il_pci_resume(struct device *device) { struct pci_dev *pdev = to_pci_dev(device); - struct il_priv *priv = pci_get_drvdata(pdev); + struct il_priv *il = pci_get_drvdata(pdev); bool hw_rfkill = false; /* @@ -1999,18 +1999,18 @@ int il_pci_resume(struct device *device) */ pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); - il_enable_interrupts(priv); + il_enable_interrupts(il); - if (!(il_read32(priv, CSR_GP_CNTRL) & + if (!(il_read32(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) hw_rfkill = true; if (hw_rfkill) - set_bit(STATUS_RF_KILL_HW, &priv->status); + set_bit(STATUS_RF_KILL_HW, &il->status); else - clear_bit(STATUS_RF_KILL_HW, &priv->status); + clear_bit(STATUS_RF_KILL_HW, &il->status); - wiphy_rfkill_set_hw_state(priv->hw->wiphy, hw_rfkill); + wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rfkill); return 0; } @@ -2029,9 +2029,9 @@ EXPORT_SYMBOL(il_pm_ops); #endif /* CONFIG_PM */ static void -il_update_qos(struct il_priv *priv, struct il_rxon_context *ctx) +il_update_qos(struct il_priv *il, struct il_rxon_context *ctx) { - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; if (!ctx->is_active) @@ -2046,11 +2046,11 @@ il_update_qos(struct il_priv *priv, struct il_rxon_context *ctx) if (ctx->ht.enabled) ctx->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; - IL_DEBUG_QOS(priv, "send QoS cmd with Qos active=%d FLAGS=0x%X\n", + IL_DEBUG_QOS(il, "send QoS cmd with Qos active=%d FLAGS=0x%X\n", ctx->qos_data.qos_active, ctx->qos_data.def_qos_parm.qos_flags); - il_send_cmd_pdu_async(priv, ctx->qos_cmd, + il_send_cmd_pdu_async(il, ctx->qos_cmd, sizeof(struct il_qosparam_cmd), &ctx->qos_data.def_qos_parm, NULL); } @@ -2060,11 +2060,11 @@ il_update_qos(struct il_priv *priv, struct il_rxon_context *ctx) */ int il_mac_config(struct ieee80211_hw *hw, u32 changed) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; const struct il_channel_info *ch_info; struct ieee80211_conf *conf = &hw->conf; struct ieee80211_channel *channel = conf->channel; - struct il_ht_config *ht_conf = &priv->current_ht_config; + struct il_ht_config *ht_conf = &il->current_ht_config; struct il_rxon_context *ctx; unsigned long flags = 0; int ret = 0; @@ -2072,23 +2072,23 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) int scan_active = 0; bool ht_changed[NUM_IL_RXON_CTX] = {}; - if (WARN_ON(!priv->cfg->ops->legacy)) + if (WARN_ON(!il->cfg->ops->legacy)) return -EOPNOTSUPP; - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); - IL_DEBUG_MAC80211(priv, "enter to channel %d changed 0x%X\n", + IL_DEBUG_MAC80211(il, "enter to channel %d changed 0x%X\n", channel->hw_value, changed); - if (unlikely(test_bit(STATUS_SCANNING, &priv->status))) { + if (unlikely(test_bit(STATUS_SCANNING, &il->status))) { scan_active = 1; - IL_DEBUG_MAC80211(priv, "scan active\n"); + IL_DEBUG_MAC80211(il, "scan active\n"); } if (changed & (IEEE80211_CONF_CHANGE_SMPS | IEEE80211_CONF_CHANGE_CHANNEL)) { /* mac80211 uses static for non-HT which is what we want */ - priv->current_ht_config.smps = conf->smps_mode; + il->current_ht_config.smps = conf->smps_mode; /* * Recalculate chain counts. @@ -2097,9 +2097,9 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) * set up the SM PS mode to OFF if an HT channel is * configured. */ - if (priv->cfg->ops->hcmd->set_rxon_chain) - for_each_context(priv, ctx) - priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); + if (il->cfg->ops->hcmd->set_rxon_chain) + for_each_context(il, ctx) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); } /* during scanning mac80211 will delay channel setting until @@ -2110,23 +2110,23 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) goto set_ch_out; ch = channel->hw_value; - ch_info = il_get_channel_info(priv, channel->band, ch); + ch_info = il_get_channel_info(il, channel->band, ch); if (!il_is_channel_valid(ch_info)) { - IL_DEBUG_MAC80211(priv, "leave - invalid channel\n"); + IL_DEBUG_MAC80211(il, "leave - invalid channel\n"); ret = -EINVAL; goto set_ch_out; } - if (priv->iw_mode == NL80211_IFTYPE_ADHOC && + if (il->iw_mode == NL80211_IFTYPE_ADHOC && !il_is_channel_ibss(ch_info)) { - IL_DEBUG_MAC80211(priv, "leave - not IBSS channel\n"); + IL_DEBUG_MAC80211(il, "leave - not IBSS channel\n"); ret = -EINVAL; goto set_ch_out; } - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); - for_each_context(priv, ctx) { + for_each_context(il, ctx) { /* Configure HT40 channels */ if (ctx->ht.enabled != conf_is_ht(conf)) { ctx->ht.enabled = conf_is_ht(conf); @@ -2162,61 +2162,61 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) if ((le16_to_cpu(ctx->staging.channel) != ch)) ctx->staging.flags = 0; - il_set_rxon_channel(priv, channel, ctx); - il_set_rxon_ht(priv, ht_conf); + il_set_rxon_channel(il, channel, ctx); + il_set_rxon_ht(il, ht_conf); - il_set_flags_for_band(priv, ctx, channel->band, + il_set_flags_for_band(il, ctx, channel->band, ctx->vif); } - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); - if (priv->cfg->ops->legacy->update_bcast_stations) + if (il->cfg->ops->legacy->update_bcast_stations) ret = - priv->cfg->ops->legacy->update_bcast_stations(priv); + il->cfg->ops->legacy->update_bcast_stations(il); set_ch_out: /* The list of supported rates and rate mask can be different * for each band; since the band may have changed, reset * the rate mask to what mac80211 lists */ - il_set_rate(priv); + il_set_rate(il); } if (changed & (IEEE80211_CONF_CHANGE_PS | IEEE80211_CONF_CHANGE_IDLE)) { - ret = il_power_update_mode(priv, false); + ret = il_power_update_mode(il, false); if (ret) - IL_DEBUG_MAC80211(priv, "Error setting sleep level\n"); + IL_DEBUG_MAC80211(il, "Error setting sleep level\n"); } if (changed & IEEE80211_CONF_CHANGE_POWER) { - IL_DEBUG_MAC80211(priv, "TX Power old=%d new=%d\n", - priv->tx_power_user_lmt, conf->power_level); + IL_DEBUG_MAC80211(il, "TX Power old=%d new=%d\n", + il->tx_power_user_lmt, conf->power_level); - il_set_tx_power(priv, conf->power_level, false); + il_set_tx_power(il, conf->power_level, false); } - if (!il_is_ready(priv)) { - IL_DEBUG_MAC80211(priv, "leave - not ready\n"); + if (!il_is_ready(il)) { + IL_DEBUG_MAC80211(il, "leave - not ready\n"); goto out; } if (scan_active) goto out; - for_each_context(priv, ctx) { + for_each_context(il, ctx) { if (memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging))) - il_commit_rxon(priv, ctx); + il_commit_rxon(il, ctx); else - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "Not re-sending same RXON configuration.\n"); if (ht_changed[ctx->ctxid]) - il_update_qos(priv, ctx); + il_update_qos(il, ctx); } out: - IL_DEBUG_MAC80211(priv, "leave\n"); - mutex_unlock(&priv->mutex); + IL_DEBUG_MAC80211(il, "leave\n"); + mutex_unlock(&il->mutex); return ret; } EXPORT_SYMBOL(il_mac_config); @@ -2224,37 +2224,37 @@ EXPORT_SYMBOL(il_mac_config); void il_mac_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; unsigned long flags; /* IBSS can only be the IL_RXON_CTX_BSS context */ - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; - if (WARN_ON(!priv->cfg->ops->legacy)) + if (WARN_ON(!il->cfg->ops->legacy)) return; - mutex_lock(&priv->mutex); - IL_DEBUG_MAC80211(priv, "enter\n"); + mutex_lock(&il->mutex); + IL_DEBUG_MAC80211(il, "enter\n"); - spin_lock_irqsave(&priv->lock, flags); - memset(&priv->current_ht_config, 0, sizeof(struct il_ht_config)); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); + memset(&il->current_ht_config, 0, sizeof(struct il_ht_config)); + spin_unlock_irqrestore(&il->lock, flags); - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); /* new association get rid of ibss beacon skb */ - if (priv->beacon_skb) - dev_kfree_skb(priv->beacon_skb); + if (il->beacon_skb) + dev_kfree_skb(il->beacon_skb); - priv->beacon_skb = NULL; + il->beacon_skb = NULL; - priv->timestamp = 0; + il->timestamp = 0; - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); - il_scan_cancel_timeout(priv, 100); - if (!il_is_ready_rf(priv)) { - IL_DEBUG_MAC80211(priv, "leave - not ready\n"); - mutex_unlock(&priv->mutex); + il_scan_cancel_timeout(il, 100); + if (!il_is_ready_rf(il)) { + IL_DEBUG_MAC80211(il, "leave - not ready\n"); + mutex_unlock(&il->mutex); return; } @@ -2262,25 +2262,25 @@ void il_mac_reset_tsf(struct ieee80211_hw *hw, * clear RXON_FILTER_ASSOC_MSK bit */ ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - il_commit_rxon(priv, ctx); + il_commit_rxon(il, ctx); - il_set_rate(priv); + il_set_rate(il); - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); - IL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(il, "leave\n"); } EXPORT_SYMBOL(il_mac_reset_tsf); -static void il_ht_conf(struct il_priv *priv, +static void il_ht_conf(struct il_priv *il, struct ieee80211_vif *vif) { - struct il_ht_config *ht_conf = &priv->current_ht_config; + struct il_ht_config *ht_conf = &il->current_ht_config; struct ieee80211_sta *sta; struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - IL_DEBUG_ASSOC(priv, "enter:\n"); + IL_DEBUG_ASSOC(il, "enter:\n"); if (!ctx->ht.enabled) return; @@ -2329,10 +2329,10 @@ static void il_ht_conf(struct il_priv *priv, break; } - IL_DEBUG_ASSOC(priv, "leave\n"); + IL_DEBUG_ASSOC(il, "leave\n"); } -static inline void il_set_no_assoc(struct il_priv *priv, +static inline void il_set_no_assoc(struct il_priv *il, struct ieee80211_vif *vif) { struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); @@ -2344,13 +2344,13 @@ static inline void il_set_no_assoc(struct il_priv *priv, */ ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; ctx->staging.assoc_id = 0; - il_commit_rxon(priv, ctx); + il_commit_rxon(il, ctx); } static void il_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; unsigned long flags; __le64 timestamp; struct sk_buff *skb = ieee80211_beacon_get(hw, vif); @@ -2358,35 +2358,35 @@ static void il_beacon_update(struct ieee80211_hw *hw, if (!skb) return; - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - if (!priv->beacon_ctx) { - IL_ERR(priv, "update beacon but no beacon context!\n"); + if (!il->beacon_ctx) { + IL_ERR(il, "update beacon but no beacon context!\n"); dev_kfree_skb(skb); return; } - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); - if (priv->beacon_skb) - dev_kfree_skb(priv->beacon_skb); + if (il->beacon_skb) + dev_kfree_skb(il->beacon_skb); - priv->beacon_skb = skb; + il->beacon_skb = skb; timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp; - priv->timestamp = le64_to_cpu(timestamp); + il->timestamp = le64_to_cpu(timestamp); - IL_DEBUG_MAC80211(priv, "leave\n"); - spin_unlock_irqrestore(&priv->lock, flags); + IL_DEBUG_MAC80211(il, "leave\n"); + spin_unlock_irqrestore(&il->lock, flags); - if (!il_is_ready_rf(priv)) { - IL_DEBUG_MAC80211(priv, "leave - RF not ready\n"); + if (!il_is_ready_rf(il)) { + IL_DEBUG_MAC80211(il, "leave - RF not ready\n"); return; } - priv->cfg->ops->legacy->post_associate(priv); + il->cfg->ops->legacy->post_associate(il); } void il_mac_bss_info_changed(struct ieee80211_hw *hw, @@ -2394,29 +2394,29 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_bss_conf *bss_conf, u32 changes) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); int ret; - if (WARN_ON(!priv->cfg->ops->legacy)) + if (WARN_ON(!il->cfg->ops->legacy)) return; - IL_DEBUG_MAC80211(priv, "changes = 0x%X\n", changes); + IL_DEBUG_MAC80211(il, "changes = 0x%X\n", changes); - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); - if (!il_is_alive(priv)) { - mutex_unlock(&priv->mutex); + if (!il_is_alive(il)) { + mutex_unlock(&il->mutex); return; } if (changes & BSS_CHANGED_QOS) { unsigned long flags; - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); ctx->qos_data.qos_active = bss_conf->qos; - il_update_qos(priv, ctx); - spin_unlock_irqrestore(&priv->lock, flags); + il_update_qos(il, ctx); + spin_unlock_irqrestore(&il->lock, flags); } if (changes & BSS_CHANGED_BEACON_ENABLED) { @@ -2426,25 +2426,25 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, * any time. */ if (vif->bss_conf.enable_beacon) - priv->beacon_ctx = ctx; + il->beacon_ctx = ctx; else - priv->beacon_ctx = NULL; + il->beacon_ctx = NULL; } if (changes & BSS_CHANGED_BSSID) { - IL_DEBUG_MAC80211(priv, "BSSID %pM\n", bss_conf->bssid); + IL_DEBUG_MAC80211(il, "BSSID %pM\n", bss_conf->bssid); /* * If there is currently a HW scan going on in the * background then we need to cancel it else the RXON * below/in post_associate will fail. */ - if (il_scan_cancel_timeout(priv, 100)) { - IL_WARN(priv, + if (il_scan_cancel_timeout(il, 100)) { + IL_WARN(il, "Aborted scan still in progress after 100ms\n"); - IL_DEBUG_MAC80211(priv, + IL_DEBUG_MAC80211(il, "leaving - scan abort failed.\n"); - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); return; } @@ -2454,7 +2454,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, bss_conf->bssid, ETH_ALEN); /* currently needed in a few places */ - memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN); + memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); } else { ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; @@ -2471,7 +2471,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, il_beacon_update(hw, vif); if (changes & BSS_CHANGED_ERP_PREAMBLE) { - IL_DEBUG_MAC80211(priv, "ERP_PREAMBLE %d\n", + IL_DEBUG_MAC80211(il, "ERP_PREAMBLE %d\n", bss_conf->use_short_preamble); if (bss_conf->use_short_preamble) ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; @@ -2480,10 +2480,10 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, } if (changes & BSS_CHANGED_ERP_CTS_PROT) { - IL_DEBUG_MAC80211(priv, + IL_DEBUG_MAC80211(il, "ERP_CTS %d\n", bss_conf->use_cts_prot); if (bss_conf->use_cts_prot && - (priv->band != IEEE80211_BAND_5GHZ)) + (il->band != IEEE80211_BAND_5GHZ)) ctx->staging.flags |= RXON_FLG_TGG_PROTECT_MSK; else ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK; @@ -2511,27 +2511,27 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, } if (changes & BSS_CHANGED_HT) { - il_ht_conf(priv, vif); + il_ht_conf(il, vif); - if (priv->cfg->ops->hcmd->set_rxon_chain) - priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); } if (changes & BSS_CHANGED_ASSOC) { - IL_DEBUG_MAC80211(priv, "ASSOC %d\n", bss_conf->assoc); + IL_DEBUG_MAC80211(il, "ASSOC %d\n", bss_conf->assoc); if (bss_conf->assoc) { - priv->timestamp = bss_conf->timestamp; + il->timestamp = bss_conf->timestamp; - if (!il_is_rfkill(priv)) - priv->cfg->ops->legacy->post_associate(priv); + if (!il_is_rfkill(il)) + il->cfg->ops->legacy->post_associate(il); } else - il_set_no_assoc(priv, vif); + il_set_no_assoc(il, vif); } if (changes && il_is_associated_ctx(ctx) && bss_conf->aid) { - IL_DEBUG_MAC80211(priv, "Changes (%#x) while associated\n", + IL_DEBUG_MAC80211(il, "Changes (%#x) while associated\n", changes); - ret = il_send_rxon_assoc(priv, ctx); + ret = il_send_rxon_assoc(il, ctx); if (!ret) { /* Sync active_rxon with latest change. */ memcpy((void *)&ctx->active, @@ -2544,54 +2544,54 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, if (vif->bss_conf.enable_beacon) { memcpy(ctx->staging.bssid_addr, bss_conf->bssid, ETH_ALEN); - memcpy(priv->bssid, bss_conf->bssid, ETH_ALEN); - priv->cfg->ops->legacy->config_ap(priv); + memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); + il->cfg->ops->legacy->config_ap(il); } else - il_set_no_assoc(priv, vif); + il_set_no_assoc(il, vif); } if (changes & BSS_CHANGED_IBSS) { - ret = priv->cfg->ops->legacy->manage_ibss_station(priv, vif, + ret = il->cfg->ops->legacy->manage_ibss_station(il, vif, bss_conf->ibss_joined); if (ret) - IL_ERR(priv, "failed to %s IBSS station %pM\n", + IL_ERR(il, "failed to %s IBSS station %pM\n", bss_conf->ibss_joined ? "add" : "remove", bss_conf->bssid); } - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); - IL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(il, "leave\n"); } EXPORT_SYMBOL(il_mac_bss_info_changed); irqreturn_t il_isr(int irq, void *data) { - struct il_priv *priv = data; + struct il_priv *il = data; u32 inta, inta_mask; u32 inta_fh; unsigned long flags; - if (!priv) + if (!il) return IRQ_NONE; - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); /* Disable (but don't clear!) interrupts here to avoid * back-to-back ISRs and sporadic interrupts from our NIC. * If we have something to service, the tasklet will re-enable ints. * If we *don't* have something, we'll re-enable before leaving here. */ - inta_mask = il_read32(priv, CSR_INT_MASK); /* just for debug */ - il_write32(priv, CSR_INT_MASK, 0x00000000); + inta_mask = il_read32(il, CSR_INT_MASK); /* just for debug */ + il_write32(il, CSR_INT_MASK, 0x00000000); /* Discover which interrupts are active/pending */ - inta = il_read32(priv, CSR_INT); - inta_fh = il_read32(priv, CSR_FH_INT_STATUS); + inta = il_read32(il, CSR_INT); + inta_fh = il_read32(il, CSR_FH_INT_STATUS); /* Ignore interrupt if there's nothing in NIC to service. * This may be due to IRQ shared with another device, * or due to sporadic interrupts thrown from our NIC. */ if (!inta && !inta_fh) { - IL_DEBUG_ISR(priv, + IL_DEBUG_ISR(il, "Ignore interrupt, inta == 0, inta_fh == 0\n"); goto none; } @@ -2599,29 +2599,29 @@ irqreturn_t il_isr(int irq, void *data) if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) { /* Hardware disappeared. It might have already raised * an interrupt */ - IL_WARN(priv, "HARDWARE GONE?? INTA == 0x%08x\n", inta); + IL_WARN(il, "HARDWARE GONE?? INTA == 0x%08x\n", inta); goto unplugged; } - IL_DEBUG_ISR(priv, "ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", + IL_DEBUG_ISR(il, "ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, inta_mask, inta_fh); inta &= ~CSR_INT_BIT_SCD; /* il_irq_tasklet() will service interrupts and re-enable them */ if (likely(inta || inta_fh)) - tasklet_schedule(&priv->irq_tasklet); + tasklet_schedule(&il->irq_tasklet); unplugged: - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); return IRQ_HANDLED; none: /* re-enable interrupts here since we don't have anything to service. */ /* only Re-enable if disabled by irq */ - if (test_bit(STATUS_INT_ENABLED, &priv->status)) - il_enable_interrupts(priv); - spin_unlock_irqrestore(&priv->lock, flags); + if (test_bit(STATUS_INT_ENABLED, &il->status)) + il_enable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); return IRQ_NONE; } EXPORT_SYMBOL(il_isr); @@ -2630,7 +2630,7 @@ EXPORT_SYMBOL(il_isr); * il_tx_cmd_protection: Set rts/cts. 3945 and 4965 only share this * function. */ -void il_tx_cmd_protection(struct il_priv *priv, +void il_tx_cmd_protection(struct il_priv *il, struct ieee80211_tx_info *info, __le16 fc, __le32 *tx_flags) { diff --git a/drivers/net/wireless/iwlegacy/iwl-core.h b/drivers/net/wireless/iwlegacy/iwl-core.h index 92f37c981797..1803954cbc5a 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.h +++ b/drivers/net/wireless/iwlegacy/iwl-core.h @@ -88,9 +88,9 @@ struct il_cmd; #define IL_CMD(x) case x: return #x struct il_hcmd_ops { - int (*rxon_assoc)(struct il_priv *priv, struct il_rxon_context *ctx); - int (*commit_rxon)(struct il_priv *priv, struct il_rxon_context *ctx); - void (*set_rxon_chain)(struct il_priv *priv, + int (*rxon_assoc)(struct il_priv *il, struct il_rxon_context *ctx); + int (*commit_rxon)(struct il_priv *il, struct il_rxon_context *ctx); + void (*set_rxon_chain)(struct il_priv *il, struct il_rxon_context *ctx); }; @@ -98,13 +98,13 @@ struct il_hcmd_utils_ops { u16 (*get_hcmd_size)(u8 cmd_id, u16 len); u16 (*build_addsta_hcmd)(const struct il_addsta_cmd *cmd, u8 *data); - int (*request_scan)(struct il_priv *priv, struct ieee80211_vif *vif); - void (*post_scan)(struct il_priv *priv); + int (*request_scan)(struct il_priv *il, struct ieee80211_vif *vif); + void (*post_scan)(struct il_priv *il); }; struct il_apm_ops { - int (*init)(struct il_priv *priv); - void (*config)(struct il_priv *priv); + int (*init)(struct il_priv *il); + void (*config)(struct il_priv *il); }; struct il_debugfs_ops { @@ -117,43 +117,43 @@ struct il_debugfs_ops { }; struct il_temp_ops { - void (*temperature)(struct il_priv *priv); + void (*temperature)(struct il_priv *il); }; struct il_lib_ops { /* set hw dependent parameters */ - int (*set_hw_params)(struct il_priv *priv); + int (*set_hw_params)(struct il_priv *il); /* Handling TX */ - void (*txq_update_byte_cnt_tbl)(struct il_priv *priv, + void (*txq_update_byte_cnt_tbl)(struct il_priv *il, struct il_tx_queue *txq, u16 byte_cnt); - int (*txq_attach_buf_to_tfd)(struct il_priv *priv, + int (*txq_attach_buf_to_tfd)(struct il_priv *il, struct il_tx_queue *txq, dma_addr_t addr, u16 len, u8 reset, u8 pad); - void (*txq_free_tfd)(struct il_priv *priv, + void (*txq_free_tfd)(struct il_priv *il, struct il_tx_queue *txq); - int (*txq_init)(struct il_priv *priv, + int (*txq_init)(struct il_priv *il, struct il_tx_queue *txq); /* setup Rx handler */ - void (*rx_handler_setup)(struct il_priv *priv); + void (*rx_handler_setup)(struct il_priv *il); /* alive notification after init uCode load */ - void (*init_alive_start)(struct il_priv *priv); + void (*init_alive_start)(struct il_priv *il); /* check validity of rtc data address */ int (*is_valid_rtc_data_addr)(u32 addr); /* 1st ucode load */ - int (*load_ucode)(struct il_priv *priv); + int (*load_ucode)(struct il_priv *il); - void (*dump_nic_error_log)(struct il_priv *priv); - int (*dump_fh)(struct il_priv *priv, char **buf, bool display); - int (*set_channel_switch)(struct il_priv *priv, + void (*dump_nic_error_log)(struct il_priv *il); + int (*dump_fh)(struct il_priv *il, char **buf, bool display); + int (*set_channel_switch)(struct il_priv *il, struct ieee80211_channel_switch *ch_switch); /* power management */ struct il_apm_ops apm_ops; /* power */ - int (*send_tx_power) (struct il_priv *priv); - void (*update_chain_flags)(struct il_priv *priv); + int (*send_tx_power) (struct il_priv *il); + void (*update_chain_flags)(struct il_priv *il); /* eeprom operations (as defined in iwl-eeprom.h) */ struct il_eeprom_ops eeprom_ops; @@ -166,15 +166,15 @@ struct il_lib_ops { }; struct il_led_ops { - int (*cmd)(struct il_priv *priv, struct il_led_cmd *led_cmd); + int (*cmd)(struct il_priv *il, struct il_led_cmd *led_cmd); }; struct il_legacy_ops { - void (*post_associate)(struct il_priv *priv); - void (*config_ap)(struct il_priv *priv); + void (*post_associate)(struct il_priv *il); + void (*config_ap)(struct il_priv *il); /* station management */ - int (*update_bcast_stations)(struct il_priv *priv); - int (*manage_ibss_station)(struct il_priv *priv, + int (*update_bcast_stations)(struct il_priv *il); + int (*manage_ibss_station)(struct il_priv *il, struct ieee80211_vif *vif, bool add); }; @@ -247,7 +247,7 @@ struct il_base_params { * on firmware version used. * * For example, - * if (IL_UCODE_API(priv->ucode_ver) >= 2) { + * if (IL_UCODE_API(il->ucode_ver) >= 2) { * Driver interacts with Firmware API version >= 2. * } else { * Driver interacts with Firmware API version 1. @@ -290,35 +290,35 @@ int il_mac_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue, const struct ieee80211_tx_queue_params *params); int il_mac_tx_last_beacon(struct ieee80211_hw *hw); -void il_set_rxon_hwcrypto(struct il_priv *priv, +void il_set_rxon_hwcrypto(struct il_priv *il, struct il_rxon_context *ctx, int hw_decrypt); -int il_check_rxon_cmd(struct il_priv *priv, +int il_check_rxon_cmd(struct il_priv *il, struct il_rxon_context *ctx); -int il_full_rxon_required(struct il_priv *priv, +int il_full_rxon_required(struct il_priv *il, struct il_rxon_context *ctx); -int il_set_rxon_channel(struct il_priv *priv, +int il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch, struct il_rxon_context *ctx); -void il_set_flags_for_band(struct il_priv *priv, +void il_set_flags_for_band(struct il_priv *il, struct il_rxon_context *ctx, enum ieee80211_band band, struct ieee80211_vif *vif); -u8 il_get_single_channel_number(struct il_priv *priv, +u8 il_get_single_channel_number(struct il_priv *il, enum ieee80211_band band); -void il_set_rxon_ht(struct il_priv *priv, +void il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf); -bool il_is_ht40_tx_allowed(struct il_priv *priv, +bool il_is_ht40_tx_allowed(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_sta_ht_cap *ht_cap); -void il_connection_init_rx_config(struct il_priv *priv, +void il_connection_init_rx_config(struct il_priv *il, struct il_rxon_context *ctx); -void il_set_rate(struct il_priv *priv); -int il_set_decrypted_flag(struct il_priv *priv, +void il_set_rate(struct il_priv *il); +int il_set_decrypted_flag(struct il_priv *il, struct ieee80211_hdr *hdr, u32 decrypt_res, struct ieee80211_rx_status *stats); -void il_irq_handle_error(struct il_priv *priv); +void il_irq_handle_error(struct il_priv *il); int il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif); void il_mac_remove_interface(struct ieee80211_hw *hw, @@ -326,42 +326,42 @@ void il_mac_remove_interface(struct ieee80211_hw *hw, int il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, enum nl80211_iftype newtype, bool newp2p); -int il_alloc_txq_mem(struct il_priv *priv); -void il_txq_mem(struct il_priv *priv); +int il_alloc_txq_mem(struct il_priv *il); +void il_txq_mem(struct il_priv *il); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS -int il_alloc_traffic_mem(struct il_priv *priv); -void il_free_traffic_mem(struct il_priv *priv); -void il_reset_traffic_log(struct il_priv *priv); -void il_dbg_log_tx_data_frame(struct il_priv *priv, +int il_alloc_traffic_mem(struct il_priv *il); +void il_free_traffic_mem(struct il_priv *il); +void il_reset_traffic_log(struct il_priv *il); +void il_dbg_log_tx_data_frame(struct il_priv *il, u16 length, struct ieee80211_hdr *header); -void il_dbg_log_rx_data_frame(struct il_priv *priv, +void il_dbg_log_rx_data_frame(struct il_priv *il, u16 length, struct ieee80211_hdr *header); const char *il_get_mgmt_string(int cmd); const char *il_get_ctrl_string(int cmd); -void il_clear_traffic_stats(struct il_priv *priv); -void il_update_stats(struct il_priv *priv, bool is_tx, __le16 fc, +void il_clear_traffic_stats(struct il_priv *il); +void il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, u16 len); #else -static inline int il_alloc_traffic_mem(struct il_priv *priv) +static inline int il_alloc_traffic_mem(struct il_priv *il) { return 0; } -static inline void il_free_traffic_mem(struct il_priv *priv) +static inline void il_free_traffic_mem(struct il_priv *il) { } -static inline void il_reset_traffic_log(struct il_priv *priv) +static inline void il_reset_traffic_log(struct il_priv *il) { } -static inline void il_dbg_log_tx_data_frame(struct il_priv *priv, +static inline void il_dbg_log_tx_data_frame(struct il_priv *il, u16 length, struct ieee80211_hdr *header) { } -static inline void il_dbg_log_rx_data_frame(struct il_priv *priv, +static inline void il_dbg_log_rx_data_frame(struct il_priv *il, u16 length, struct ieee80211_hdr *header) { } -static inline void il_update_stats(struct il_priv *priv, bool is_tx, +static inline void il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, u16 len) { } @@ -369,83 +369,83 @@ static inline void il_update_stats(struct il_priv *priv, bool is_tx, /***************************************************** * RX handlers. * **************************************************/ -void il_rx_pm_sleep_notif(struct il_priv *priv, +void il_rx_pm_sleep_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb); -void il_rx_pm_debug_statistics_notif(struct il_priv *priv, +void il_rx_pm_debug_statistics_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb); -void il_rx_reply_error(struct il_priv *priv, +void il_rx_reply_error(struct il_priv *il, struct il_rx_mem_buffer *rxb); /***************************************************** * RX ******************************************************/ -void il_cmd_queue_unmap(struct il_priv *priv); -void il_cmd_queue_free(struct il_priv *priv); -int il_rx_queue_alloc(struct il_priv *priv); -void il_rx_queue_update_write_ptr(struct il_priv *priv, +void il_cmd_queue_unmap(struct il_priv *il); +void il_cmd_queue_free(struct il_priv *il); +int il_rx_queue_alloc(struct il_priv *il); +void il_rx_queue_update_write_ptr(struct il_priv *il, struct il_rx_queue *q); int il_rx_queue_space(const struct il_rx_queue *q); -void il_tx_cmd_complete(struct il_priv *priv, +void il_tx_cmd_complete(struct il_priv *il, struct il_rx_mem_buffer *rxb); /* Handlers */ -void il_rx_spectrum_measure_notif(struct il_priv *priv, +void il_rx_spectrum_measure_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb); -void il_recover_from_statistics(struct il_priv *priv, +void il_recover_from_statistics(struct il_priv *il, struct il_rx_packet *pkt); -void il_chswitch_done(struct il_priv *priv, bool is_success); -void il_rx_csa(struct il_priv *priv, struct il_rx_mem_buffer *rxb); +void il_chswitch_done(struct il_priv *il, bool is_success); +void il_rx_csa(struct il_priv *il, struct il_rx_mem_buffer *rxb); /* TX helpers */ /***************************************************** * TX ******************************************************/ -void il_txq_update_write_ptr(struct il_priv *priv, +void il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq); -int il_tx_queue_init(struct il_priv *priv, struct il_tx_queue *txq, +int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num, u32 txq_id); -void il_tx_queue_reset(struct il_priv *priv, +void il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, int slots_num, u32 txq_id); -void il_tx_queue_unmap(struct il_priv *priv, int txq_id); -void il_tx_queue_free(struct il_priv *priv, int txq_id); -void il_setup_watchdog(struct il_priv *priv); +void il_tx_queue_unmap(struct il_priv *il, int txq_id); +void il_tx_queue_free(struct il_priv *il, int txq_id); +void il_setup_watchdog(struct il_priv *il); /***************************************************** * TX power ****************************************************/ -int il_set_tx_power(struct il_priv *priv, s8 tx_power, bool force); +int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force); /******************************************************************************* * Rate ******************************************************************************/ -u8 il_get_lowest_plcp(struct il_priv *priv, +u8 il_get_lowest_plcp(struct il_priv *il, struct il_rxon_context *ctx); /******************************************************************************* * Scanning ******************************************************************************/ -void il_init_scan_params(struct il_priv *priv); -int il_scan_cancel(struct il_priv *priv); -int il_scan_cancel_timeout(struct il_priv *priv, unsigned long ms); -void il_force_scan_end(struct il_priv *priv); +void il_init_scan_params(struct il_priv *il); +int il_scan_cancel(struct il_priv *il); +int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms); +void il_force_scan_end(struct il_priv *il); int il_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct cfg80211_scan_request *req); -void il_internal_short_hw_scan(struct il_priv *priv); -int il_force_reset(struct il_priv *priv, bool external); -u16 il_fill_probe_req(struct il_priv *priv, +void il_internal_short_hw_scan(struct il_priv *il); +int il_force_reset(struct il_priv *il, bool external); +u16 il_fill_probe_req(struct il_priv *il, struct ieee80211_mgmt *frame, const u8 *ta, const u8 *ie, int ie_len, int left); -void il_setup_rx_scan_handlers(struct il_priv *priv); -u16 il_get_active_dwell_time(struct il_priv *priv, +void il_setup_rx_scan_handlers(struct il_priv *il); +u16 il_get_active_dwell_time(struct il_priv *il, enum ieee80211_band band, u8 n_probes); -u16 il_get_passive_dwell_time(struct il_priv *priv, +u16 il_get_passive_dwell_time(struct il_priv *il, enum ieee80211_band band, struct ieee80211_vif *vif); -void il_setup_scan_deferred_work(struct il_priv *priv); -void il_cancel_scan_deferred_work(struct il_priv *priv); +void il_setup_scan_deferred_work(struct il_priv *il); +void il_cancel_scan_deferred_work(struct il_priv *il); /* For faster active scanning, scan will move to the next channel if fewer than * PLCP_QUIET_THRESH packets are heard on this channel within @@ -463,37 +463,37 @@ void il_cancel_scan_deferred_work(struct il_priv *priv); *****************************************************/ const char *il_get_cmd_string(u8 cmd); -int __must_check il_send_cmd_sync(struct il_priv *priv, +int __must_check il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd); -int il_send_cmd(struct il_priv *priv, struct il_host_cmd *cmd); -int __must_check il_send_cmd_pdu(struct il_priv *priv, u8 id, +int il_send_cmd(struct il_priv *il, struct il_host_cmd *cmd); +int __must_check il_send_cmd_pdu(struct il_priv *il, u8 id, u16 len, const void *data); -int il_send_cmd_pdu_async(struct il_priv *priv, u8 id, u16 len, +int il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, const void *data, - void (*callback)(struct il_priv *priv, + void (*callback)(struct il_priv *il, struct il_device_cmd *cmd, struct il_rx_packet *pkt)); -int il_enqueue_hcmd(struct il_priv *priv, struct il_host_cmd *cmd); +int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd); /***************************************************** * PCI * *****************************************************/ -static inline u16 il_pcie_link_ctl(struct il_priv *priv) +static inline u16 il_pcie_link_ctl(struct il_priv *il) { int pos; u16 pci_lnk_ctl; - pos = pci_pcie_cap(priv->pci_dev); - pci_read_config_word(priv->pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl); + pos = pci_pcie_cap(il->pci_dev); + pci_read_config_word(il->pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl); return pci_lnk_ctl; } void il_bg_watchdog(unsigned long data); -u32 il_usecs_to_beacons(struct il_priv *priv, +u32 il_usecs_to_beacons(struct il_priv *il, u32 usec, u32 beacon_interval); -__le32 il_add_beacon_time(struct il_priv *priv, u32 base, +__le32 il_add_beacon_time(struct il_priv *il, u32 base, u32 addon, u32 beacon_interval); #ifdef CONFIG_PM @@ -512,24 +512,24 @@ extern const struct dev_pm_ops il_pm_ops; /***************************************************** * Error Handling Debugging ******************************************************/ -void il4965_dump_nic_error_log(struct il_priv *priv); +void il4965_dump_nic_error_log(struct il_priv *il); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -void il_print_rx_config_cmd(struct il_priv *priv, +void il_print_rx_config_cmd(struct il_priv *il, struct il_rxon_context *ctx); #else -static inline void il_print_rx_config_cmd(struct il_priv *priv, +static inline void il_print_rx_config_cmd(struct il_priv *il, struct il_rxon_context *ctx) { } #endif -void il_clear_isr_stats(struct il_priv *priv); +void il_clear_isr_stats(struct il_priv *il); /***************************************************** * GEOS ******************************************************/ -int il_init_geos(struct il_priv *priv); -void il_free_geos(struct il_priv *priv); +int il_init_geos(struct il_priv *il); +void il_free_geos(struct il_priv *il); /*************** DRIVER STATUS FUNCTIONS *****/ @@ -552,71 +552,71 @@ void il_free_geos(struct il_priv *priv); #define STATUS_FW_ERROR 17 #define STATUS_CHANNEL_SWITCH_PENDING 18 -static inline int il_is_ready(struct il_priv *priv) +static inline int il_is_ready(struct il_priv *il) { /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are * set but EXIT_PENDING is not */ - return test_bit(STATUS_READY, &priv->status) && - test_bit(STATUS_GEO_CONFIGURED, &priv->status) && - !test_bit(STATUS_EXIT_PENDING, &priv->status); + return test_bit(STATUS_READY, &il->status) && + test_bit(STATUS_GEO_CONFIGURED, &il->status) && + !test_bit(STATUS_EXIT_PENDING, &il->status); } -static inline int il_is_alive(struct il_priv *priv) +static inline int il_is_alive(struct il_priv *il) { - return test_bit(STATUS_ALIVE, &priv->status); + return test_bit(STATUS_ALIVE, &il->status); } -static inline int il_is_init(struct il_priv *priv) +static inline int il_is_init(struct il_priv *il) { - return test_bit(STATUS_INIT, &priv->status); + return test_bit(STATUS_INIT, &il->status); } -static inline int il_is_rfkill_hw(struct il_priv *priv) +static inline int il_is_rfkill_hw(struct il_priv *il) { - return test_bit(STATUS_RF_KILL_HW, &priv->status); + return test_bit(STATUS_RF_KILL_HW, &il->status); } -static inline int il_is_rfkill(struct il_priv *priv) +static inline int il_is_rfkill(struct il_priv *il) { - return il_is_rfkill_hw(priv); + return il_is_rfkill_hw(il); } -static inline int il_is_ctkill(struct il_priv *priv) +static inline int il_is_ctkill(struct il_priv *il) { - return test_bit(STATUS_CT_KILL, &priv->status); + return test_bit(STATUS_CT_KILL, &il->status); } -static inline int il_is_ready_rf(struct il_priv *priv) +static inline int il_is_ready_rf(struct il_priv *il) { - if (il_is_rfkill(priv)) + if (il_is_rfkill(il)) return 0; - return il_is_ready(priv); + return il_is_ready(il); } -extern void il_send_bt_config(struct il_priv *priv); -extern int il_send_statistics_request(struct il_priv *priv, +extern void il_send_bt_config(struct il_priv *il); +extern int il_send_statistics_request(struct il_priv *il, u8 flags, bool clear); -void il_apm_stop(struct il_priv *priv); -int il_apm_init(struct il_priv *priv); +void il_apm_stop(struct il_priv *il); +int il_apm_init(struct il_priv *il); -int il_send_rxon_timing(struct il_priv *priv, +int il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx); -static inline int il_send_rxon_assoc(struct il_priv *priv, +static inline int il_send_rxon_assoc(struct il_priv *il, struct il_rxon_context *ctx) { - return priv->cfg->ops->hcmd->rxon_assoc(priv, ctx); + return il->cfg->ops->hcmd->rxon_assoc(il, ctx); } -static inline int il_commit_rxon(struct il_priv *priv, +static inline int il_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) { - return priv->cfg->ops->hcmd->commit_rxon(priv, ctx); + return il->cfg->ops->hcmd->commit_rxon(il, ctx); } static inline const struct ieee80211_supported_band *il_get_hw_mode( - struct il_priv *priv, enum ieee80211_band band) + struct il_priv *il, enum ieee80211_band band) { - return priv->hw->wiphy->bands[band]; + return il->hw->wiphy->bands[band]; } /* mac80211 handlers */ @@ -627,7 +627,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_bss_conf *bss_conf, u32 changes); -void il_tx_cmd_protection(struct il_priv *priv, +void il_tx_cmd_protection(struct il_priv *il, struct ieee80211_tx_info *info, __le16 fc, __le32 *tx_flags); diff --git a/drivers/net/wireless/iwlegacy/iwl-debug.h b/drivers/net/wireless/iwlegacy/iwl-debug.h index 1bbad766aac7..657da25a2354 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debug.h +++ b/drivers/net/wireless/iwlegacy/iwl-debug.h @@ -37,7 +37,7 @@ extern u32 iwlegacy_debug_level; #define IL_INFO(p, f, a...) dev_info(&((p)->pci_dev->dev), f, ## a) #define IL_CRIT(p, f, a...) dev_crit(&((p)->pci_dev->dev), f, ## a) -#define il_print_hex_error(priv, p, len) \ +#define il_print_hex_error(il, p, len) \ do { \ print_hex_dump(KERN_ERR, "iwl data: ", \ DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ @@ -60,9 +60,9 @@ do { \ __func__ , ## args); \ } while (0) -#define il_print_hex_dump(priv, level, p, len) \ +#define il_print_hex_dump(il, level, p, len) \ do { \ - if (il_get_debug_level(priv) & level) \ + if (il_get_debug_level(il) & level) \ print_hex_dump(KERN_DEBUG, "iwl data: ", \ DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ } while (0) @@ -70,21 +70,21 @@ do { \ #else #define IL_DEBUG(__priv, level, fmt, args...) #define IL_DEBUG_LIMIT(__priv, level, fmt, args...) -static inline void il_print_hex_dump(struct il_priv *priv, int level, +static inline void il_print_hex_dump(struct il_priv *il, int level, const void *p, u32 len) {} #endif /* CONFIG_IWLWIFI_LEGACY_DEBUG */ #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS -int il_dbgfs_register(struct il_priv *priv, const char *name); -void il_dbgfs_unregister(struct il_priv *priv); +int il_dbgfs_register(struct il_priv *il, const char *name); +void il_dbgfs_unregister(struct il_priv *il); #else static inline int -il_dbgfs_register(struct il_priv *priv, const char *name) +il_dbgfs_register(struct il_priv *il, const char *name) { return 0; } -static inline void il_dbgfs_unregister(struct il_priv *priv) +static inline void il_dbgfs_unregister(struct il_priv *il) { } #endif /* CONFIG_IWLWIFI_LEGACY_DEBUGFS */ diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index 057dec5b178c..f2f2eba7d3ea 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -36,7 +36,7 @@ /* create and remove of files */ #define DEBUGFS_ADD_FILE(name, parent, mode) do { \ - if (!debugfs_create_file(#name, mode, parent, priv, \ + if (!debugfs_create_file(#name, mode, parent, il, \ &il_dbgfs_##name##_ops)) \ goto err; \ } while (0) @@ -106,7 +106,7 @@ static ssize_t il_dbgfs_tx_statistics_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char *buf; int pos = 0; @@ -122,20 +122,20 @@ static ssize_t il_dbgfs_tx_statistics_read(struct file *file, pos += scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", il_get_mgmt_string(cnt), - priv->tx_stats.mgmt[cnt]); + il->tx_stats.mgmt[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Control\n"); for (cnt = 0; cnt < CONTROL_MAX; cnt++) { pos += scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", il_get_ctrl_string(cnt), - priv->tx_stats.ctrl[cnt]); + il->tx_stats.ctrl[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", - priv->tx_stats.data_cnt); + il->tx_stats.data_cnt); pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", - priv->tx_stats.data_bytes); + il->tx_stats.data_bytes); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; @@ -146,7 +146,7 @@ il_dbgfs_clear_traffic_statistics_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; u32 clear_flag; char buf[8]; int buf_size; @@ -157,7 +157,7 @@ il_dbgfs_clear_traffic_statistics_write(struct file *file, return -EFAULT; if (sscanf(buf, "%x", &clear_flag) != 1) return -EFAULT; - il_clear_traffic_stats(priv); + il_clear_traffic_stats(il); return count; } @@ -166,7 +166,7 @@ static ssize_t il_dbgfs_rx_statistics_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char *buf; int pos = 0; int cnt; @@ -182,20 +182,20 @@ static ssize_t il_dbgfs_rx_statistics_read(struct file *file, pos += scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", il_get_mgmt_string(cnt), - priv->rx_stats.mgmt[cnt]); + il->rx_stats.mgmt[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Control:\n"); for (cnt = 0; cnt < CONTROL_MAX; cnt++) { pos += scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", il_get_ctrl_string(cnt), - priv->rx_stats.ctrl[cnt]); + il->rx_stats.ctrl[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", - priv->rx_stats.data_cnt); + il->rx_stats.data_cnt); pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", - priv->rx_stats.data_bytes); + il->rx_stats.data_bytes); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); @@ -214,28 +214,28 @@ static ssize_t il_dbgfs_sram_read(struct file *file, ssize_t ret; int i; int pos = 0; - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; size_t bufsz; /* default is to dump the entire data segment */ - if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) { - priv->dbgfs_sram_offset = 0x800000; - if (priv->ucode_type == UCODE_INIT) - priv->dbgfs_sram_len = priv->ucode_init_data.len; + if (!il->dbgfs_sram_offset && !il->dbgfs_sram_len) { + il->dbgfs_sram_offset = 0x800000; + if (il->ucode_type == UCODE_INIT) + il->dbgfs_sram_len = il->ucode_init_data.len; else - priv->dbgfs_sram_len = priv->ucode_data.len; + il->dbgfs_sram_len = il->ucode_data.len; } - bufsz = 30 + priv->dbgfs_sram_len * sizeof(char) * 10; + bufsz = 30 + il->dbgfs_sram_len * sizeof(char) * 10; buf = kmalloc(bufsz, GFP_KERNEL); if (!buf) return -ENOMEM; pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n", - priv->dbgfs_sram_len); + il->dbgfs_sram_len); pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n", - priv->dbgfs_sram_offset); - for (i = priv->dbgfs_sram_len; i > 0; i -= 4) { - val = il_read_targ_mem(priv, priv->dbgfs_sram_offset + \ - priv->dbgfs_sram_len - i); + il->dbgfs_sram_offset); + for (i = il->dbgfs_sram_len; i > 0; i -= 4) { + val = il_read_targ_mem(il, il->dbgfs_sram_offset + \ + il->dbgfs_sram_len - i); if (i < 4) { switch (i) { case 1: @@ -264,7 +264,7 @@ static ssize_t il_dbgfs_sram_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char buf[64]; int buf_size; u32 offset, len; @@ -275,11 +275,11 @@ static ssize_t il_dbgfs_sram_write(struct file *file, return -EFAULT; if (sscanf(buf, "%x,%x", &offset, &len) == 2) { - priv->dbgfs_sram_offset = offset; - priv->dbgfs_sram_len = len; + il->dbgfs_sram_offset = offset; + il->dbgfs_sram_len = len; } else { - priv->dbgfs_sram_offset = 0; - priv->dbgfs_sram_len = 0; + il->dbgfs_sram_offset = 0; + il->dbgfs_sram_len = 0; } return count; @@ -289,24 +289,24 @@ static ssize_t il_dbgfs_stations_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; struct il_station_entry *station; - int max_sta = priv->hw_params.max_stations; + int max_sta = il->hw_params.max_stations; char *buf; int i, j, pos = 0; ssize_t ret; /* Add 30 for initial string */ - const size_t bufsz = 30 + sizeof(char) * 500 * (priv->num_stations); + const size_t bufsz = 30 + sizeof(char) * 500 * (il->num_stations); buf = kmalloc(bufsz, GFP_KERNEL); if (!buf) return -ENOMEM; pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n", - priv->num_stations); + il->num_stations); for (i = 0; i < max_sta; i++) { - station = &priv->stations[i]; + station = &il->stations[i]; if (!station->used) continue; pos += scnprintf(buf + pos, bufsz - pos, @@ -349,32 +349,32 @@ static ssize_t il_dbgfs_nvm_read(struct file *file, loff_t *ppos) { ssize_t ret; - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0, ofs = 0, buf_size = 0; const u8 *ptr; char *buf; u16 eeprom_ver; - size_t eeprom_len = priv->cfg->base_params->eeprom_size; + size_t eeprom_len = il->cfg->base_params->eeprom_size; buf_size = 4 * eeprom_len + 256; if (eeprom_len % 16) { - IL_ERR(priv, "NVM size is not multiple of 16.\n"); + IL_ERR(il, "NVM size is not multiple of 16.\n"); return -ENODATA; } - ptr = priv->eeprom; + ptr = il->eeprom; if (!ptr) { - IL_ERR(priv, "Invalid EEPROM memory\n"); + IL_ERR(il, "Invalid EEPROM memory\n"); return -ENOMEM; } /* 4 characters for byte 0xYY */ buf = kzalloc(buf_size, GFP_KERNEL); if (!buf) { - IL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(il, "Can not allocate Buffer\n"); return -ENOMEM; } - eeprom_ver = il_eeprom_query16(priv, EEPROM_VERSION); + eeprom_ver = il_eeprom_query16(il, EEPROM_VERSION); pos += scnprintf(buf + pos, buf_size - pos, "EEPROM " "version: 0x%x\n", eeprom_ver); for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) { @@ -395,23 +395,23 @@ static ssize_t il_dbgfs_channels_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; struct ieee80211_channel *channels = NULL; const struct ieee80211_supported_band *supp_band = NULL; int pos = 0, i, bufsz = PAGE_SIZE; char *buf; ssize_t ret; - if (!test_bit(STATUS_GEO_CONFIGURED, &priv->status)) + if (!test_bit(STATUS_GEO_CONFIGURED, &il->status)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(il, "Can not allocate Buffer\n"); return -ENOMEM; } - supp_band = il_get_hw_mode(priv, IEEE80211_BAND_2GHZ); + supp_band = il_get_hw_mode(il, IEEE80211_BAND_2GHZ); if (supp_band) { channels = supp_band->channels; @@ -434,7 +434,7 @@ il_dbgfs_channels_read(struct file *file, char __user *user_buf, IEEE80211_CHAN_PASSIVE_SCAN ? "passive only" : "active/passive"); } - supp_band = il_get_hw_mode(priv, IEEE80211_BAND_5GHZ); + supp_band = il_get_hw_mode(il, IEEE80211_BAND_5GHZ); if (supp_band) { channels = supp_band->channels; @@ -466,43 +466,43 @@ static ssize_t il_dbgfs_status_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char buf[512]; int pos = 0; const size_t bufsz = sizeof(buf); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_ACTIVE:\t %d\n", - test_bit(STATUS_HCMD_ACTIVE, &priv->status)); + test_bit(STATUS_HCMD_ACTIVE, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INT_ENABLED:\t %d\n", - test_bit(STATUS_INT_ENABLED, &priv->status)); + test_bit(STATUS_INT_ENABLED, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n", - test_bit(STATUS_RF_KILL_HW, &priv->status)); + test_bit(STATUS_RF_KILL_HW, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n", - test_bit(STATUS_CT_KILL, &priv->status)); + test_bit(STATUS_CT_KILL, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INIT:\t\t %d\n", - test_bit(STATUS_INIT, &priv->status)); + test_bit(STATUS_INIT, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n", - test_bit(STATUS_ALIVE, &priv->status)); + test_bit(STATUS_ALIVE, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n", - test_bit(STATUS_READY, &priv->status)); + test_bit(STATUS_READY, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_TEMPERATURE:\t %d\n", - test_bit(STATUS_TEMPERATURE, &priv->status)); + test_bit(STATUS_TEMPERATURE, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_GEO_CONFIGURED:\t %d\n", - test_bit(STATUS_GEO_CONFIGURED, &priv->status)); + test_bit(STATUS_GEO_CONFIGURED, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n", - test_bit(STATUS_EXIT_PENDING, &priv->status)); + test_bit(STATUS_EXIT_PENDING, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n", - test_bit(STATUS_STATISTICS, &priv->status)); + test_bit(STATUS_STATISTICS, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n", - test_bit(STATUS_SCANNING, &priv->status)); + test_bit(STATUS_SCANNING, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n", - test_bit(STATUS_SCAN_ABORTING, &priv->status)); + test_bit(STATUS_SCAN_ABORTING, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n", - test_bit(STATUS_SCAN_HW, &priv->status)); + test_bit(STATUS_SCAN_HW, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n", - test_bit(STATUS_POWER_PMI, &priv->status)); + test_bit(STATUS_POWER_PMI, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n", - test_bit(STATUS_FW_ERROR, &priv->status)); + test_bit(STATUS_FW_ERROR, &il->status)); return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } @@ -510,7 +510,7 @@ static ssize_t il_dbgfs_interrupt_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0; int cnt = 0; char *buf; @@ -519,7 +519,7 @@ static ssize_t il_dbgfs_interrupt_read(struct file *file, buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(il, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -527,46 +527,46 @@ static ssize_t il_dbgfs_interrupt_read(struct file *file, "Interrupt Statistics Report:\n"); pos += scnprintf(buf + pos, bufsz - pos, "HW Error:\t\t\t %u\n", - priv->isr_stats.hw); + il->isr_stats.hw); pos += scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n", - priv->isr_stats.sw); - if (priv->isr_stats.sw || priv->isr_stats.hw) { + il->isr_stats.sw); + if (il->isr_stats.sw || il->isr_stats.hw) { pos += scnprintf(buf + pos, bufsz - pos, "\tLast Restarting Code: 0x%X\n", - priv->isr_stats.err_code); + il->isr_stats.err_code); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG pos += scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n", - priv->isr_stats.sch); + il->isr_stats.sch); pos += scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n", - priv->isr_stats.alive); + il->isr_stats.alive); #endif pos += scnprintf(buf + pos, bufsz - pos, "HW RF KILL switch toggled:\t %u\n", - priv->isr_stats.rfkill); + il->isr_stats.rfkill); pos += scnprintf(buf + pos, bufsz - pos, "CT KILL:\t\t\t %u\n", - priv->isr_stats.ctkill); + il->isr_stats.ctkill); pos += scnprintf(buf + pos, bufsz - pos, "Wakeup Interrupt:\t\t %u\n", - priv->isr_stats.wakeup); + il->isr_stats.wakeup); pos += scnprintf(buf + pos, bufsz - pos, "Rx command responses:\t\t %u\n", - priv->isr_stats.rx); + il->isr_stats.rx); for (cnt = 0; cnt < REPLY_MAX; cnt++) { - if (priv->isr_stats.rx_handlers[cnt] > 0) + if (il->isr_stats.rx_handlers[cnt] > 0) pos += scnprintf(buf + pos, bufsz - pos, "\tRx handler[%36s]:\t\t %u\n", il_get_cmd_string(cnt), - priv->isr_stats.rx_handlers[cnt]); + il->isr_stats.rx_handlers[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n", - priv->isr_stats.tx); + il->isr_stats.tx); pos += scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n", - priv->isr_stats.unhandled); + il->isr_stats.unhandled); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); @@ -577,7 +577,7 @@ static ssize_t il_dbgfs_interrupt_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char buf[8]; int buf_size; u32 reset_flag; @@ -589,7 +589,7 @@ static ssize_t il_dbgfs_interrupt_write(struct file *file, if (sscanf(buf, "%x", &reset_flag) != 1) return -EFAULT; if (reset_flag == 0) - il_clear_isr_stats(priv); + il_clear_isr_stats(il); return count; } @@ -598,13 +598,13 @@ static ssize_t il_dbgfs_qos_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; struct il_rxon_context *ctx; int pos = 0, i; char buf[256 * NUM_IL_RXON_CTX]; const size_t bufsz = sizeof(buf); - for_each_context(priv, ctx) { + for_each_context(il, ctx) { pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n", ctx->ctxid); for (i = 0; i < AC_NUM; i++) { @@ -626,7 +626,7 @@ static ssize_t il_dbgfs_disable_ht40_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char buf[8]; int buf_size; int ht40; @@ -637,10 +637,10 @@ static ssize_t il_dbgfs_disable_ht40_write(struct file *file, return -EFAULT; if (sscanf(buf, "%d", &ht40) != 1) return -EFAULT; - if (!il_is_any_associated(priv)) - priv->disable_ht40 = ht40 ? true : false; + if (!il_is_any_associated(il)) + il->disable_ht40 = ht40 ? true : false; else { - IL_ERR(priv, "Sta associated with AP - " + IL_ERR(il, "Sta associated with AP - " "Change to 40MHz channel support is not allowed\n"); return -EINVAL; } @@ -652,14 +652,14 @@ static ssize_t il_dbgfs_disable_ht40_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char buf[100]; int pos = 0; const size_t bufsz = sizeof(buf); pos += scnprintf(buf + pos, bufsz - pos, "11n 40MHz Mode: %s\n", - priv->disable_ht40 ? "Disabled" : "Enabled"); + il->disable_ht40 ? "Disabled" : "Enabled"); return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } @@ -676,39 +676,39 @@ static ssize_t il_dbgfs_traffic_log_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0, ofs = 0; int cnt = 0, entry; struct il_tx_queue *txq; struct il_queue *q; - struct il_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &il->rxq; char *buf; int bufsz = ((IL_TRAFFIC_ENTRIES * IL_TRAFFIC_ENTRY_SIZE * 64) * 2) + - (priv->cfg->base_params->num_of_queues * 32 * 8) + 400; + (il->cfg->base_params->num_of_queues * 32 * 8) + 400; const u8 *ptr; ssize_t ret; - if (!priv->txq) { - IL_ERR(priv, "txq not ready\n"); + if (!il->txq) { + IL_ERR(il, "txq not ready\n"); return -EAGAIN; } buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(priv, "Can not allocate buffer\n"); + IL_ERR(il, "Can not allocate buffer\n"); return -ENOMEM; } pos += scnprintf(buf + pos, bufsz - pos, "Tx Queue\n"); - for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) { - txq = &priv->txq[cnt]; + for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { + txq = &il->txq[cnt]; q = &txq->q; pos += scnprintf(buf + pos, bufsz - pos, "q[%d]: read_ptr: %u, write_ptr: %u\n", cnt, q->read_ptr, q->write_ptr); } - if (priv->tx_traffic && (iwlegacy_debug_level & IL_DL_TX)) { - ptr = priv->tx_traffic; + if (il->tx_traffic && (iwlegacy_debug_level & IL_DL_TX)) { + ptr = il->tx_traffic; pos += scnprintf(buf + pos, bufsz - pos, - "Tx Traffic idx: %u\n", priv->tx_traffic_idx); + "Tx Traffic idx: %u\n", il->tx_traffic_idx); for (cnt = 0, ofs = 0; cnt < IL_TRAFFIC_ENTRIES; cnt++) { for (entry = 0; entry < IL_TRAFFIC_ENTRY_SIZE / 16; entry++, ofs += 16) { @@ -728,10 +728,10 @@ static ssize_t il_dbgfs_traffic_log_read(struct file *file, "read: %u, write: %u\n", rxq->read, rxq->write); - if (priv->rx_traffic && (iwlegacy_debug_level & IL_DL_RX)) { - ptr = priv->rx_traffic; + if (il->rx_traffic && (iwlegacy_debug_level & IL_DL_RX)) { + ptr = il->rx_traffic; pos += scnprintf(buf + pos, bufsz - pos, - "Rx Traffic idx: %u\n", priv->rx_traffic_idx); + "Rx Traffic idx: %u\n", il->rx_traffic_idx); for (cnt = 0, ofs = 0; cnt < IL_TRAFFIC_ENTRIES; cnt++) { for (entry = 0; entry < IL_TRAFFIC_ENTRY_SIZE / 16; entry++, ofs += 16) { @@ -755,7 +755,7 @@ static ssize_t il_dbgfs_traffic_log_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char buf[8]; int buf_size; int traffic_log; @@ -767,7 +767,7 @@ static ssize_t il_dbgfs_traffic_log_write(struct file *file, if (sscanf(buf, "%d", &traffic_log) != 1) return -EFAULT; if (traffic_log == 0) - il_reset_traffic_log(priv); + il_reset_traffic_log(il); return count; } @@ -776,7 +776,7 @@ static ssize_t il_dbgfs_tx_queue_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; struct il_tx_queue *txq; struct il_queue *q; char *buf; @@ -784,24 +784,24 @@ static ssize_t il_dbgfs_tx_queue_read(struct file *file, int cnt; int ret; const size_t bufsz = sizeof(char) * 64 * - priv->cfg->base_params->num_of_queues; + il->cfg->base_params->num_of_queues; - if (!priv->txq) { - IL_ERR(priv, "txq not ready\n"); + if (!il->txq) { + IL_ERR(il, "txq not ready\n"); return -EAGAIN; } buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) return -ENOMEM; - for (cnt = 0; cnt < priv->hw_params.max_txq_num; cnt++) { - txq = &priv->txq[cnt]; + for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { + txq = &il->txq[cnt]; q = &txq->q; pos += scnprintf(buf + pos, bufsz - pos, "hwq %.2d: read=%u write=%u stop=%d" " swq_id=%#.2x (ac %d/hwq %d)\n", cnt, q->read_ptr, q->write_ptr, - !!test_bit(cnt, priv->queue_stopped), + !!test_bit(cnt, il->queue_stopped), txq->swq_id, txq->swq_id & 3, (txq->swq_id >> 2) & 0x1f); if (cnt >= 4) @@ -809,7 +809,7 @@ static ssize_t il_dbgfs_tx_queue_read(struct file *file, /* for the ACs, display the stop count too */ pos += scnprintf(buf + pos, bufsz - pos, " stop-count: %d\n", - atomic_read(&priv->queue_stop_count[cnt])); + atomic_read(&il->queue_stop_count[cnt])); } ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); @@ -820,8 +820,8 @@ static ssize_t il_dbgfs_rx_queue_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; - struct il_rx_queue *rxq = &priv->rxq; + struct il_priv *il = file->private_data; + struct il_rx_queue *rxq = &il->rxq; char buf[256]; int pos = 0; const size_t bufsz = sizeof(buf); @@ -846,8 +846,8 @@ static ssize_t il_dbgfs_ucode_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; - return priv->cfg->ops->lib->debugfs_ops.rx_stats_read(file, + struct il_priv *il = file->private_data; + return il->cfg->ops->lib->debugfs_ops.rx_stats_read(file, user_buf, count, ppos); } @@ -855,8 +855,8 @@ static ssize_t il_dbgfs_ucode_tx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; - return priv->cfg->ops->lib->debugfs_ops.tx_stats_read(file, + struct il_priv *il = file->private_data; + return il->cfg->ops->lib->debugfs_ops.tx_stats_read(file, user_buf, count, ppos); } @@ -864,8 +864,8 @@ static ssize_t il_dbgfs_ucode_general_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; - return priv->cfg->ops->lib->debugfs_ops.general_stats_read(file, + struct il_priv *il = file->private_data; + return il->cfg->ops->lib->debugfs_ops.general_stats_read(file, user_buf, count, ppos); } @@ -873,7 +873,7 @@ static ssize_t il_dbgfs_sensitivity_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0; int cnt = 0; char *buf; @@ -881,10 +881,10 @@ static ssize_t il_dbgfs_sensitivity_read(struct file *file, ssize_t ret; struct il_sensitivity_data *data; - data = &priv->sensitivity_data; + data = &il->sensitivity_data; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(il, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -954,7 +954,7 @@ static ssize_t il_dbgfs_chain_noise_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0; int cnt = 0; char *buf; @@ -962,10 +962,10 @@ static ssize_t il_dbgfs_chain_noise_read(struct file *file, ssize_t ret; struct il_chain_noise_data *data; - data = &priv->chain_noise_data; + data = &il->chain_noise_data; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(priv, "Can not allocate Buffer\n"); + IL_ERR(il, "Can not allocate Buffer\n"); return -ENOMEM; } @@ -1012,13 +1012,13 @@ static ssize_t il_dbgfs_power_save_status_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char buf[60]; int pos = 0; const size_t bufsz = sizeof(buf); u32 pwrsave_status; - pwrsave_status = il_read32(priv, CSR_GP_CNTRL) & + pwrsave_status = il_read32(il, CSR_GP_CNTRL) & CSR_GP_REG_POWER_SAVE_STATUS_MSK; pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: "); @@ -1035,7 +1035,7 @@ static ssize_t il_dbgfs_clear_ucode_statistics_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char buf[8]; int buf_size; int clear; @@ -1048,9 +1048,9 @@ static ssize_t il_dbgfs_clear_ucode_statistics_write(struct file *file, return -EFAULT; /* make request to uCode to retrieve statistics information */ - mutex_lock(&priv->mutex); - il_send_statistics_request(priv, CMD_SYNC, true); - mutex_unlock(&priv->mutex); + mutex_lock(&il->mutex); + il_send_statistics_request(il, CMD_SYNC, true); + mutex_unlock(&il->mutex); return count; } @@ -1059,12 +1059,12 @@ static ssize_t il_dbgfs_rxon_flags_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int len = 0; char buf[20]; len = sprintf(buf, "0x%04X\n", - le32_to_cpu(priv->contexts[IL_RXON_CTX_BSS].active.flags)); + le32_to_cpu(il->contexts[IL_RXON_CTX_BSS].active.flags)); return simple_read_from_buffer(user_buf, count, ppos, buf, len); } @@ -1072,12 +1072,12 @@ static ssize_t il_dbgfs_rxon_filter_flags_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int len = 0; char buf[20]; len = sprintf(buf, "0x%04X\n", - le32_to_cpu(priv->contexts[IL_RXON_CTX_BSS].active.filter_flags)); + le32_to_cpu(il->contexts[IL_RXON_CTX_BSS].active.filter_flags)); return simple_read_from_buffer(user_buf, count, ppos, buf, len); } @@ -1085,13 +1085,13 @@ static ssize_t il_dbgfs_fh_reg_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char *buf; int pos = 0; ssize_t ret = -EFAULT; - if (priv->cfg->ops->lib->dump_fh) { - ret = pos = priv->cfg->ops->lib->dump_fh(priv, &buf, true); + if (il->cfg->ops->lib->dump_fh) { + ret = pos = il->cfg->ops->lib->dump_fh(il, &buf, true); if (buf) { ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); @@ -1106,13 +1106,13 @@ static ssize_t il_dbgfs_missed_beacon_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0; char buf[12]; const size_t bufsz = sizeof(buf); pos += scnprintf(buf + pos, bufsz - pos, "%d\n", - priv->missed_beacon_threshold); + il->missed_beacon_threshold); return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } @@ -1121,7 +1121,7 @@ static ssize_t il_dbgfs_missed_beacon_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char buf[8]; int buf_size; int missed; @@ -1135,10 +1135,10 @@ static ssize_t il_dbgfs_missed_beacon_write(struct file *file, if (missed < IL_MISSED_BEACON_THRESHOLD_MIN || missed > IL_MISSED_BEACON_THRESHOLD_MAX) - priv->missed_beacon_threshold = + il->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; else - priv->missed_beacon_threshold = missed; + il->missed_beacon_threshold = missed; return count; } @@ -1147,13 +1147,13 @@ static ssize_t il_dbgfs_force_reset_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; int pos = 0; char buf[300]; const size_t bufsz = sizeof(buf); struct il_force_reset *force_reset; - force_reset = &priv->force_reset; + force_reset = &il->force_reset; pos += scnprintf(buf + pos, bufsz - pos, "\tnumber of reset request: %d\n", @@ -1176,9 +1176,9 @@ static ssize_t il_dbgfs_force_reset_write(struct file *file, size_t count, loff_t *ppos) { int ret; - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; - ret = il_force_reset(priv, true); + ret = il_force_reset(il, true); return ret ? ret : count; } @@ -1187,7 +1187,7 @@ static ssize_t il_dbgfs_wd_timeout_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { - struct il_priv *priv = file->private_data; + struct il_priv *il = file->private_data; char buf[8]; int buf_size; int timeout; @@ -1201,8 +1201,8 @@ static ssize_t il_dbgfs_wd_timeout_write(struct file *file, if (timeout < 0 || timeout > IL_MAX_WD_TIMEOUT) timeout = IL_DEF_WD_TIMEOUT; - priv->cfg->base_params->wd_timeout = timeout; - il_setup_watchdog(priv); + il->cfg->base_params->wd_timeout = timeout; + il_setup_watchdog(il); return count; } @@ -1230,16 +1230,16 @@ DEBUGFS_WRITE_FILE_OPS(wd_timeout); * Create the debugfs files and directories * */ -int il_dbgfs_register(struct il_priv *priv, const char *name) +int il_dbgfs_register(struct il_priv *il, const char *name) { - struct dentry *phyd = priv->hw->wiphy->debugfsdir; + struct dentry *phyd = il->hw->wiphy->debugfsdir; struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug; dir_drv = debugfs_create_dir(name, phyd); if (!dir_drv) return -ENOMEM; - priv->debugfs_dir = dir_drv; + il->debugfs_dir = dir_drv; dir_data = debugfs_create_dir("data", dir_drv); if (!dir_data) @@ -1274,26 +1274,26 @@ int il_dbgfs_register(struct il_priv *priv, const char *name) DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR); DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR); - if (priv->cfg->base_params->sensitivity_calib_by_driver) + if (il->cfg->base_params->sensitivity_calib_by_driver) DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR); - if (priv->cfg->base_params->chain_noise_calib_by_driver) + if (il->cfg->base_params->chain_noise_calib_by_driver) DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR); DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR); DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR); DEBUGFS_ADD_FILE(wd_timeout, dir_debug, S_IWUSR); - if (priv->cfg->base_params->sensitivity_calib_by_driver) + if (il->cfg->base_params->sensitivity_calib_by_driver) DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf, - &priv->disable_sens_cal); - if (priv->cfg->base_params->chain_noise_calib_by_driver) + &il->disable_sens_cal); + if (il->cfg->base_params->chain_noise_calib_by_driver) DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf, - &priv->disable_chain_noise_cal); + &il->disable_chain_noise_cal); DEBUGFS_ADD_BOOL(disable_tx_power, dir_rf, - &priv->disable_tx_power_cal); + &il->disable_tx_power_cal); return 0; err: - IL_ERR(priv, "Can't create the debugfs directory\n"); - il_dbgfs_unregister(priv); + IL_ERR(il, "Can't create the debugfs directory\n"); + il_dbgfs_unregister(il); return -ENOMEM; } EXPORT_SYMBOL(il_dbgfs_register); @@ -1302,12 +1302,12 @@ EXPORT_SYMBOL(il_dbgfs_register); * Remove the debugfs files and directories * */ -void il_dbgfs_unregister(struct il_priv *priv) +void il_dbgfs_unregister(struct il_priv *il) { - if (!priv->debugfs_dir) + if (!il->debugfs_dir) return; - debugfs_remove_recursive(priv->debugfs_dir); - priv->debugfs_dir = NULL; + debugfs_remove_recursive(il->debugfs_dir); + il->debugfs_dir = NULL; } EXPORT_SYMBOL(il_dbgfs_unregister); diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 20c44f36ba77..824d1934a7a1 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -106,7 +106,7 @@ struct il_cmd_meta { * invoked for SYNC commands, if it were and its result passed * through it would be simpler...) */ - void (*callback)(struct il_priv *priv, + void (*callback)(struct il_priv *il, struct il_device_cmd *cmd, struct il_rx_packet *pkt); @@ -321,7 +321,7 @@ struct il_device_cmd { struct il_host_cmd { const void *data; unsigned long reply_page; - void (*callback)(struct il_priv *priv, + void (*callback)(struct il_priv *il, struct il_device_cmd *cmd, struct il_rx_packet *pkt); u32 flags; @@ -476,7 +476,7 @@ struct il_station_priv_common { }; /* - * il_station_priv: Driver's private station information + * il_station_priv: Driver's ilate station information * * When mac80211 creates a station it reserves some space (hw->sta_data_size) * in the structure for use by driver. This structure is places in that @@ -494,7 +494,7 @@ struct il_station_priv { }; /** - * struct il_vif_priv - driver's private per-interface information + * struct il_vif_priv - driver's ilate per-interface information * * When mac80211 allocates a virtual interface, it can allocate * space for us to put data into. @@ -625,7 +625,7 @@ struct il_hw_params { * il4965_mac_ <-- mac80211 callback * ****************************************************************************/ -extern void il4965_update_chain_flags(struct il_priv *priv); +extern void il4965_update_chain_flags(struct il_priv *il); extern const u8 iwlegacy_bcast_addr[ETH_ALEN]; extern int il_queue_space(const struct il_queue *q); static inline int il_queue_used(const struct il_queue *q, int i) @@ -973,7 +973,7 @@ struct il_priv { enum ieee80211_band band; int alloc_rxb_page; - void (*rx_handlers[REPLY_MAX])(struct il_priv *priv, + void (*rx_handlers[REPLY_MAX])(struct il_priv *il, struct il_rx_mem_buffer *rxb); struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; @@ -1247,14 +1247,14 @@ struct il_priv { bool led_registered; }; /*il_priv */ -static inline void il_txq_ctx_activate(struct il_priv *priv, int txq_id) +static inline void il_txq_ctx_activate(struct il_priv *il, int txq_id) { - set_bit(txq_id, &priv->txq_ctx_active_msk); + set_bit(txq_id, &il->txq_ctx_active_msk); } -static inline void il_txq_ctx_deactivate(struct il_priv *priv, int txq_id) +static inline void il_txq_ctx_deactivate(struct il_priv *il, int txq_id) { - clear_bit(txq_id, &priv->txq_ctx_active_msk); + clear_bit(txq_id, &il->txq_ctx_active_msk); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG @@ -1265,15 +1265,15 @@ static inline void il_txq_ctx_deactivate(struct il_priv *priv, int txq_id) * level will be used if set, otherwise the global debug level which can be * set via module parameter is used. */ -static inline u32 il_get_debug_level(struct il_priv *priv) +static inline u32 il_get_debug_level(struct il_priv *il) { - if (priv->debug_level) - return priv->debug_level; + if (il->debug_level) + return il->debug_level; else return iwlegacy_debug_level; } #else -static inline u32 il_get_debug_level(struct il_priv *priv) +static inline u32 il_get_debug_level(struct il_priv *il) { return iwlegacy_debug_level; } @@ -1281,11 +1281,11 @@ static inline u32 il_get_debug_level(struct il_priv *priv) static inline struct ieee80211_hdr * -il_tx_queue_get_hdr(struct il_priv *priv, +il_tx_queue_get_hdr(struct il_priv *il, int txq_id, int idx) { - if (priv->txq[txq_id].txb[idx].skb) - return (struct ieee80211_hdr *)priv->txq[txq_id]. + if (il->txq[txq_id].txb[idx].skb) + return (struct ieee80211_hdr *)il->txq[txq_id]. txb[idx].skb->data; return NULL; } @@ -1298,21 +1298,21 @@ il_rxon_ctx_from_vif(struct ieee80211_vif *vif) return vif_priv->ctx; } -#define for_each_context(priv, ctx) \ - for (ctx = &priv->contexts[IL_RXON_CTX_BSS]; \ - ctx < &priv->contexts[NUM_IL_RXON_CTX]; ctx++) \ - if (priv->valid_contexts & BIT(ctx->ctxid)) +#define for_each_context(il, ctx) \ + for (ctx = &il->contexts[IL_RXON_CTX_BSS]; \ + ctx < &il->contexts[NUM_IL_RXON_CTX]; ctx++) \ + if (il->valid_contexts & BIT(ctx->ctxid)) -static inline int il_is_associated(struct il_priv *priv, +static inline int il_is_associated(struct il_priv *il, enum il_rxon_context_id ctxid) { - return (priv->contexts[ctxid].active.filter_flags & + return (il->contexts[ctxid].active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; } -static inline int il_is_any_associated(struct il_priv *priv) +static inline int il_is_any_associated(struct il_priv *il) { - return il_is_associated(priv, IL_RXON_CTX_BSS); + return il_is_associated(il, IL_RXON_CTX_BSS); } static inline int il_is_associated_ctx(struct il_rxon_context *ctx) @@ -1350,15 +1350,15 @@ il_is_channel_ibss(const struct il_channel_info *ch) } static inline void -__il_free_pages(struct il_priv *priv, struct page *page) +__il_free_pages(struct il_priv *il, struct page *page) { - __free_pages(page, priv->hw_params.rx_page_order); - priv->alloc_rxb_page--; + __free_pages(page, il->hw_params.rx_page_order); + il->alloc_rxb_page--; } -static inline void il_free_pages(struct il_priv *priv, unsigned long page) +static inline void il_free_pages(struct il_priv *il, unsigned long page) { - free_pages(page, priv->hw_params.rx_page_order); - priv->alloc_rxb_page--; + free_pages(page, il->hw_params.rx_page_order); + il->alloc_rxb_page--; } #endif /* __il_dev_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-eeprom.c index 1075f1d7f016..5edec73a505e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.c @@ -87,7 +87,7 @@ * is contained in the eeprom map itself. * * During init, we copy the eeprom information and channel map - * information into priv->channel_info_24/52 and priv->channel_map_24/52 + * information into il->channel_info_24/52 and il->channel_map_24/52 * * channel_map_24/52 provides the index in the channel_info array for a * given channel. We have to have two separate maps as there is channel @@ -142,18 +142,18 @@ static const u8 iwlegacy_eeprom_band_7[] = { /* 5.2 ht40 channel */ * ******************************************************************************/ -static int il_eeprom_verify_signature(struct il_priv *priv) +static int il_eeprom_verify_signature(struct il_priv *il) { - u32 gp = il_read32(priv, CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; + u32 gp = il_read32(il, CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; int ret = 0; - IL_DEBUG_EEPROM(priv, "EEPROM signature=0x%08x\n", gp); + IL_DEBUG_EEPROM(il, "EEPROM signature=0x%08x\n", gp); switch (gp) { case CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K: case CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K: break; default: - IL_ERR(priv, "bad EEPROM signature," + IL_ERR(il, "bad EEPROM signature," "EEPROM_GP=0x%08x\n", gp); ret = -ENOENT; break; @@ -162,59 +162,59 @@ static int il_eeprom_verify_signature(struct il_priv *priv) } const u8 -*il_eeprom_query_addr(const struct il_priv *priv, size_t offset) +*il_eeprom_query_addr(const struct il_priv *il, size_t offset) { - BUG_ON(offset >= priv->cfg->base_params->eeprom_size); - return &priv->eeprom[offset]; + BUG_ON(offset >= il->cfg->base_params->eeprom_size); + return &il->eeprom[offset]; } EXPORT_SYMBOL(il_eeprom_query_addr); -u16 il_eeprom_query16(const struct il_priv *priv, size_t offset) +u16 il_eeprom_query16(const struct il_priv *il, size_t offset) { - if (!priv->eeprom) + if (!il->eeprom) return 0; - return (u16)priv->eeprom[offset] | ((u16)priv->eeprom[offset + 1] << 8); + return (u16)il->eeprom[offset] | ((u16)il->eeprom[offset + 1] << 8); } EXPORT_SYMBOL(il_eeprom_query16); /** * il_eeprom_init - read EEPROM contents * - * Load the EEPROM contents from adapter into priv->eeprom + * Load the EEPROM contents from adapter into il->eeprom * * NOTE: This routine uses the non-debug IO access functions. */ -int il_eeprom_init(struct il_priv *priv) +int il_eeprom_init(struct il_priv *il) { __le16 *e; - u32 gp = il_read32(priv, CSR_EEPROM_GP); + u32 gp = il_read32(il, CSR_EEPROM_GP); int sz; int ret; u16 addr; /* allocate eeprom */ - sz = priv->cfg->base_params->eeprom_size; - IL_DEBUG_EEPROM(priv, "NVM size = %d\n", sz); - priv->eeprom = kzalloc(sz, GFP_KERNEL); - if (!priv->eeprom) { + sz = il->cfg->base_params->eeprom_size; + IL_DEBUG_EEPROM(il, "NVM size = %d\n", sz); + il->eeprom = kzalloc(sz, GFP_KERNEL); + if (!il->eeprom) { ret = -ENOMEM; goto alloc_err; } - e = (__le16 *)priv->eeprom; + e = (__le16 *)il->eeprom; - priv->cfg->ops->lib->apm_ops.init(priv); + il->cfg->ops->lib->apm_ops.init(il); - ret = il_eeprom_verify_signature(priv); + ret = il_eeprom_verify_signature(il); if (ret < 0) { - IL_ERR(priv, "EEPROM not found, EEPROM_GP=0x%08x\n", gp); + IL_ERR(il, "EEPROM not found, EEPROM_GP=0x%08x\n", gp); ret = -ENOENT; goto err; } /* Make sure driver (instead of uCode) is allowed to read EEPROM */ - ret = priv->cfg->ops->lib->eeprom_ops.acquire_semaphore(priv); + ret = il->cfg->ops->lib->eeprom_ops.acquire_semaphore(il); if (ret < 0) { - IL_ERR(priv, "Failed to acquire EEPROM semaphore.\n"); + IL_ERR(il, "Failed to acquire EEPROM semaphore.\n"); ret = -ENOENT; goto err; } @@ -223,95 +223,95 @@ int il_eeprom_init(struct il_priv *priv) for (addr = 0; addr < sz; addr += sizeof(u16)) { u32 r; - _il_write32(priv, CSR_EEPROM_REG, + _il_write32(il, CSR_EEPROM_REG, CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); - ret = il_poll_bit(priv, CSR_EEPROM_REG, + ret = il_poll_bit(il, CSR_EEPROM_REG, CSR_EEPROM_REG_READ_VALID_MSK, CSR_EEPROM_REG_READ_VALID_MSK, IL_EEPROM_ACCESS_TIMEOUT); if (ret < 0) { - IL_ERR(priv, "Time out reading EEPROM[%d]\n", + IL_ERR(il, "Time out reading EEPROM[%d]\n", addr); goto done; } - r = _il_read_direct32(priv, CSR_EEPROM_REG); + r = _il_read_direct32(il, CSR_EEPROM_REG); e[addr / 2] = cpu_to_le16(r >> 16); } - IL_DEBUG_EEPROM(priv, "NVM Type: %s, version: 0x%x\n", + IL_DEBUG_EEPROM(il, "NVM Type: %s, version: 0x%x\n", "EEPROM", - il_eeprom_query16(priv, EEPROM_VERSION)); + il_eeprom_query16(il, EEPROM_VERSION)); ret = 0; done: - priv->cfg->ops->lib->eeprom_ops.release_semaphore(priv); + il->cfg->ops->lib->eeprom_ops.release_semaphore(il); err: if (ret) - il_eeprom_free(priv); + il_eeprom_free(il); /* Reset chip to save power until we load uCode during "up". */ - il_apm_stop(priv); + il_apm_stop(il); alloc_err: return ret; } EXPORT_SYMBOL(il_eeprom_init); -void il_eeprom_free(struct il_priv *priv) +void il_eeprom_free(struct il_priv *il) { - kfree(priv->eeprom); - priv->eeprom = NULL; + kfree(il->eeprom); + il->eeprom = NULL; } EXPORT_SYMBOL(il_eeprom_free); -static void il_init_band_reference(const struct il_priv *priv, +static void il_init_band_reference(const struct il_priv *il, int eep_band, int *eeprom_ch_count, const struct il_eeprom_channel **eeprom_ch_info, const u8 **eeprom_ch_index) { - u32 offset = priv->cfg->ops->lib-> + u32 offset = il->cfg->ops->lib-> eeprom_ops.regulatory_bands[eep_band - 1]; switch (eep_band) { case 1: /* 2.4GHz band */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_1); *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(priv, offset); + il_eeprom_query_addr(il, offset); *eeprom_ch_index = iwlegacy_eeprom_band_1; break; case 2: /* 4.9GHz band */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_2); *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(priv, offset); + il_eeprom_query_addr(il, offset); *eeprom_ch_index = iwlegacy_eeprom_band_2; break; case 3: /* 5.2GHz band */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_3); *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(priv, offset); + il_eeprom_query_addr(il, offset); *eeprom_ch_index = iwlegacy_eeprom_band_3; break; case 4: /* 5.5GHz band */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_4); *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(priv, offset); + il_eeprom_query_addr(il, offset); *eeprom_ch_index = iwlegacy_eeprom_band_4; break; case 5: /* 5.7GHz band */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_5); *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(priv, offset); + il_eeprom_query_addr(il, offset); *eeprom_ch_index = iwlegacy_eeprom_band_5; break; case 6: /* 2.4GHz ht40 channels */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_6); *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(priv, offset); + il_eeprom_query_addr(il, offset); *eeprom_ch_index = iwlegacy_eeprom_band_6; break; case 7: /* 5 GHz ht40 channels */ *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_7); *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(priv, offset); + il_eeprom_query_addr(il, offset); *eeprom_ch_index = iwlegacy_eeprom_band_7; break; default: @@ -322,11 +322,11 @@ static void il_init_band_reference(const struct il_priv *priv, #define CHECK_AND_PRINT(x) ((eeprom_ch->flags & EEPROM_CHANNEL_##x) \ ? # x " " : "") /** - * il_mod_ht40_chan_info - Copy ht40 channel info into driver's priv. + * il_mod_ht40_chan_info - Copy ht40 channel info into driver's il. * * Does not set up a command, or touch hardware. */ -static int il_mod_ht40_chan_info(struct il_priv *priv, +static int il_mod_ht40_chan_info(struct il_priv *il, enum ieee80211_band band, u16 channel, const struct il_eeprom_channel *eeprom_ch, u8 clear_ht40_extension_channel) @@ -334,12 +334,12 @@ static int il_mod_ht40_chan_info(struct il_priv *priv, struct il_channel_info *ch_info; ch_info = (struct il_channel_info *) - il_get_channel_info(priv, band, channel); + il_get_channel_info(il, band, channel); if (!il_is_channel_valid(ch_info)) return -1; - IL_DEBUG_EEPROM(priv, "HT40 Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):" + IL_DEBUG_EEPROM(il, "HT40 Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):" " Ad-Hoc %ssupported\n", ch_info->channel, il_is_channel_a_band(ch_info) ? @@ -371,7 +371,7 @@ static int il_mod_ht40_chan_info(struct il_priv *priv, /** * il_init_channel_map - Set up driver's info for all possible channels */ -int il_init_channel_map(struct il_priv *priv) +int il_init_channel_map(struct il_priv *il) { int eeprom_ch_count = 0; const u8 *eeprom_ch_index = NULL; @@ -379,39 +379,39 @@ int il_init_channel_map(struct il_priv *priv) int band, ch; struct il_channel_info *ch_info; - if (priv->channel_count) { - IL_DEBUG_EEPROM(priv, "Channel map already initialized.\n"); + if (il->channel_count) { + IL_DEBUG_EEPROM(il, "Channel map already initialized.\n"); return 0; } - IL_DEBUG_EEPROM(priv, "Initializing regulatory info from EEPROM\n"); + IL_DEBUG_EEPROM(il, "Initializing regulatory info from EEPROM\n"); - priv->channel_count = + il->channel_count = ARRAY_SIZE(iwlegacy_eeprom_band_1) + ARRAY_SIZE(iwlegacy_eeprom_band_2) + ARRAY_SIZE(iwlegacy_eeprom_band_3) + ARRAY_SIZE(iwlegacy_eeprom_band_4) + ARRAY_SIZE(iwlegacy_eeprom_band_5); - IL_DEBUG_EEPROM(priv, "Parsing data for %d channels.\n", - priv->channel_count); + IL_DEBUG_EEPROM(il, "Parsing data for %d channels.\n", + il->channel_count); - priv->channel_info = kzalloc(sizeof(struct il_channel_info) * - priv->channel_count, GFP_KERNEL); - if (!priv->channel_info) { - IL_ERR(priv, "Could not allocate channel_info\n"); - priv->channel_count = 0; + il->channel_info = kzalloc(sizeof(struct il_channel_info) * + il->channel_count, GFP_KERNEL); + if (!il->channel_info) { + IL_ERR(il, "Could not allocate channel_info\n"); + il->channel_count = 0; return -ENOMEM; } - ch_info = priv->channel_info; + ch_info = il->channel_info; /* Loop through the 5 EEPROM bands adding them in order to the * channel map we maintain (that contains additional information than * what just in the EEPROM) */ for (band = 1; band <= 5; band++) { - il_init_band_reference(priv, band, &eeprom_ch_count, + il_init_band_reference(il, band, &eeprom_ch_count, &eeprom_ch_info, &eeprom_ch_index); /* Loop through each band adding each of the channels */ @@ -433,7 +433,7 @@ int il_init_channel_map(struct il_priv *priv) IEEE80211_CHAN_NO_HT40; if (!(il_is_channel_valid(ch_info))) { - IL_DEBUG_EEPROM(priv, + IL_DEBUG_EEPROM(il, "Ch. %d Flags %x [%sGHz] - " "No traffic\n", ch_info->channel, @@ -450,7 +450,7 @@ int il_init_channel_map(struct il_priv *priv) ch_info->scan_power = eeprom_ch_info[ch].max_power_avg; ch_info->min_power = 0; - IL_DEBUG_EEPROM(priv, "Ch. %d [%sGHz] " + IL_DEBUG_EEPROM(il, "Ch. %d [%sGHz] " "%s%s%s%s%s%s(0x%02x %ddBm):" " Ad-Hoc %ssupported\n", ch_info->channel, @@ -475,9 +475,9 @@ int il_init_channel_map(struct il_priv *priv) } /* Check if we do have HT40 channels */ - if (priv->cfg->ops->lib->eeprom_ops.regulatory_bands[5] == + if (il->cfg->ops->lib->eeprom_ops.regulatory_bands[5] == EEPROM_REGULATORY_BAND_NO_HT40 && - priv->cfg->ops->lib->eeprom_ops.regulatory_bands[6] == + il->cfg->ops->lib->eeprom_ops.regulatory_bands[6] == EEPROM_REGULATORY_BAND_NO_HT40) return 0; @@ -485,7 +485,7 @@ int il_init_channel_map(struct il_priv *priv) for (band = 6; band <= 7; band++) { enum ieee80211_band ieeeband; - il_init_band_reference(priv, band, &eeprom_ch_count, + il_init_band_reference(il, band, &eeprom_ch_count, &eeprom_ch_info, &eeprom_ch_index); /* EEPROM band 6 is 2.4, band 7 is 5 GHz */ @@ -495,13 +495,13 @@ int il_init_channel_map(struct il_priv *priv) /* Loop through each band adding each of the channels */ for (ch = 0; ch < eeprom_ch_count; ch++) { /* Set up driver's info for lower half */ - il_mod_ht40_chan_info(priv, ieeeband, + il_mod_ht40_chan_info(il, ieeeband, eeprom_ch_index[ch], &eeprom_ch_info[ch], IEEE80211_CHAN_NO_HT40PLUS); /* Set up driver's info for upper half */ - il_mod_ht40_chan_info(priv, ieeeband, + il_mod_ht40_chan_info(il, ieeeband, eeprom_ch_index[ch] + 4, &eeprom_ch_info[ch], IEEE80211_CHAN_NO_HT40MINUS); @@ -515,34 +515,34 @@ EXPORT_SYMBOL(il_init_channel_map); /* * il_free_channel_map - undo allocations in il_init_channel_map */ -void il_free_channel_map(struct il_priv *priv) +void il_free_channel_map(struct il_priv *il) { - kfree(priv->channel_info); - priv->channel_count = 0; + kfree(il->channel_info); + il->channel_count = 0; } EXPORT_SYMBOL(il_free_channel_map); /** - * il_get_channel_info - Find driver's private channel info + * il_get_channel_info - Find driver's ilate channel info * * Based on band and channel number. */ const struct -il_channel_info *il_get_channel_info(const struct il_priv *priv, +il_channel_info *il_get_channel_info(const struct il_priv *il, enum ieee80211_band band, u16 channel) { int i; switch (band) { case IEEE80211_BAND_5GHZ: - for (i = 14; i < priv->channel_count; i++) { - if (priv->channel_info[i].channel == channel) - return &priv->channel_info[i]; + for (i = 14; i < il->channel_count; i++) { + if (il->channel_info[i].channel == channel) + return &il->channel_info[i]; } break; case IEEE80211_BAND_2GHZ: if (channel >= 1 && channel <= 14) - return &priv->channel_info[channel - 1]; + return &il->channel_info[channel - 1]; break; default: BUG(); diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.h b/drivers/net/wireless/iwlegacy/iwl-eeprom.h index 9ad687161623..acb5ec17d70d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.h +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.h @@ -325,20 +325,20 @@ struct il_eeprom_calib_info { struct il_eeprom_ops { const u32 regulatory_bands[7]; - int (*acquire_semaphore) (struct il_priv *priv); - void (*release_semaphore) (struct il_priv *priv); + int (*acquire_semaphore) (struct il_priv *il); + void (*release_semaphore) (struct il_priv *il); }; -int il_eeprom_init(struct il_priv *priv); -void il_eeprom_free(struct il_priv *priv); -const u8 *il_eeprom_query_addr(const struct il_priv *priv, +int il_eeprom_init(struct il_priv *il); +void il_eeprom_free(struct il_priv *il); +const u8 *il_eeprom_query_addr(const struct il_priv *il, size_t offset); -u16 il_eeprom_query16(const struct il_priv *priv, size_t offset); -int il_init_channel_map(struct il_priv *priv); -void il_free_channel_map(struct il_priv *priv); +u16 il_eeprom_query16(const struct il_priv *il, size_t offset); +int il_init_channel_map(struct il_priv *il); +void il_free_channel_map(struct il_priv *il); const struct il_channel_info *il_get_channel_info( - const struct il_priv *priv, + const struct il_priv *il, enum ieee80211_band band, u16 channel); #endif /* __il_eeprom_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-hcmd.c b/drivers/net/wireless/iwlegacy/iwl-hcmd.c index 515befc28001..f16e31109e06 100644 --- a/drivers/net/wireless/iwlegacy/iwl-hcmd.c +++ b/drivers/net/wireless/iwlegacy/iwl-hcmd.c @@ -90,12 +90,12 @@ EXPORT_SYMBOL(il_get_cmd_string); #define HOST_COMPLETE_TIMEOUT (HZ / 2) -static void il_generic_cmd_callback(struct il_priv *priv, +static void il_generic_cmd_callback(struct il_priv *il, struct il_device_cmd *cmd, struct il_rx_packet *pkt) { if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR(priv, "Bad return from %s (0x%08X)\n", + IL_ERR(il, "Bad return from %s (0x%08X)\n", il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); return; } @@ -104,18 +104,18 @@ static void il_generic_cmd_callback(struct il_priv *priv, switch (cmd->hdr.cmd) { case REPLY_TX_LINK_QUALITY_CMD: case SENSITIVITY_CMD: - IL_DEBUG_HC_DUMP(priv, "back from %s (0x%08X)\n", + IL_DEBUG_HC_DUMP(il, "back from %s (0x%08X)\n", il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); break; default: - IL_DEBUG_HC(priv, "back from %s (0x%08X)\n", + IL_DEBUG_HC(il, "back from %s (0x%08X)\n", il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); } #endif } static int -il_send_cmd_async(struct il_priv *priv, struct il_host_cmd *cmd) +il_send_cmd_async(struct il_priv *il, struct il_host_cmd *cmd) { int ret; @@ -128,57 +128,57 @@ il_send_cmd_async(struct il_priv *priv, struct il_host_cmd *cmd) if (!cmd->callback) cmd->callback = il_generic_cmd_callback; - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return -EBUSY; - ret = il_enqueue_hcmd(priv, cmd); + ret = il_enqueue_hcmd(il, cmd); if (ret < 0) { - IL_ERR(priv, "Error sending %s: enqueue_hcmd failed: %d\n", + IL_ERR(il, "Error sending %s: enqueue_hcmd failed: %d\n", il_get_cmd_string(cmd->id), ret); return ret; } return 0; } -int il_send_cmd_sync(struct il_priv *priv, struct il_host_cmd *cmd) +int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) { int cmd_idx; int ret; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); BUG_ON(cmd->flags & CMD_ASYNC); /* A synchronous command can not have a callback set. */ BUG_ON(cmd->callback); - IL_DEBUG_INFO(priv, "Attempting to send sync command %s\n", + IL_DEBUG_INFO(il, "Attempting to send sync command %s\n", il_get_cmd_string(cmd->id)); - set_bit(STATUS_HCMD_ACTIVE, &priv->status); - IL_DEBUG_INFO(priv, "Setting HCMD_ACTIVE for command %s\n", + set_bit(STATUS_HCMD_ACTIVE, &il->status); + IL_DEBUG_INFO(il, "Setting HCMD_ACTIVE for command %s\n", il_get_cmd_string(cmd->id)); - cmd_idx = il_enqueue_hcmd(priv, cmd); + cmd_idx = il_enqueue_hcmd(il, cmd); if (cmd_idx < 0) { ret = cmd_idx; - IL_ERR(priv, "Error sending %s: enqueue_hcmd failed: %d\n", + IL_ERR(il, "Error sending %s: enqueue_hcmd failed: %d\n", il_get_cmd_string(cmd->id), ret); goto out; } - ret = wait_event_timeout(priv->wait_command_queue, - !test_bit(STATUS_HCMD_ACTIVE, &priv->status), + ret = wait_event_timeout(il->wait_command_queue, + !test_bit(STATUS_HCMD_ACTIVE, &il->status), HOST_COMPLETE_TIMEOUT); if (!ret) { - if (test_bit(STATUS_HCMD_ACTIVE, &priv->status)) { - IL_ERR(priv, + if (test_bit(STATUS_HCMD_ACTIVE, &il->status)) { + IL_ERR(il, "Error sending %s: time out after %dms.\n", il_get_cmd_string(cmd->id), jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); - clear_bit(STATUS_HCMD_ACTIVE, &priv->status); - IL_DEBUG_INFO(priv, + clear_bit(STATUS_HCMD_ACTIVE, &il->status); + IL_DEBUG_INFO(il, "Clearing HCMD_ACTIVE for command %s\n", il_get_cmd_string(cmd->id)); ret = -ETIMEDOUT; @@ -186,20 +186,20 @@ int il_send_cmd_sync(struct il_priv *priv, struct il_host_cmd *cmd) } } - if (test_bit(STATUS_RF_KILL_HW, &priv->status)) { - IL_ERR(priv, "Command %s aborted: RF KILL Switch\n", + if (test_bit(STATUS_RF_KILL_HW, &il->status)) { + IL_ERR(il, "Command %s aborted: RF KILL Switch\n", il_get_cmd_string(cmd->id)); ret = -ECANCELED; goto fail; } - if (test_bit(STATUS_FW_ERROR, &priv->status)) { - IL_ERR(priv, "Command %s failed: FW Error\n", + if (test_bit(STATUS_FW_ERROR, &il->status)) { + IL_ERR(il, "Command %s failed: FW Error\n", il_get_cmd_string(cmd->id)); ret = -EIO; goto fail; } if ((cmd->flags & CMD_WANT_SKB) && !cmd->reply_page) { - IL_ERR(priv, "Error: Response NULL in '%s'\n", + IL_ERR(il, "Error: Response NULL in '%s'\n", il_get_cmd_string(cmd->id)); ret = -EIO; goto cancel; @@ -216,12 +216,12 @@ cancel: * in later, it will possibly set an invalid * address (cmd->meta.source). */ - priv->txq[priv->cmd_queue].meta[cmd_idx].flags &= + il->txq[il->cmd_queue].meta[cmd_idx].flags &= ~CMD_WANT_SKB; } fail: if (cmd->reply_page) { - il_free_pages(priv, cmd->reply_page); + il_free_pages(il, cmd->reply_page); cmd->reply_page = 0; } out: @@ -229,17 +229,17 @@ out: } EXPORT_SYMBOL(il_send_cmd_sync); -int il_send_cmd(struct il_priv *priv, struct il_host_cmd *cmd) +int il_send_cmd(struct il_priv *il, struct il_host_cmd *cmd) { if (cmd->flags & CMD_ASYNC) - return il_send_cmd_async(priv, cmd); + return il_send_cmd_async(il, cmd); - return il_send_cmd_sync(priv, cmd); + return il_send_cmd_sync(il, cmd); } EXPORT_SYMBOL(il_send_cmd); int -il_send_cmd_pdu(struct il_priv *priv, u8 id, u16 len, const void *data) +il_send_cmd_pdu(struct il_priv *il, u8 id, u16 len, const void *data) { struct il_host_cmd cmd = { .id = id, @@ -247,13 +247,13 @@ il_send_cmd_pdu(struct il_priv *priv, u8 id, u16 len, const void *data) .data = data, }; - return il_send_cmd_sync(priv, &cmd); + return il_send_cmd_sync(il, &cmd); } EXPORT_SYMBOL(il_send_cmd_pdu); -int il_send_cmd_pdu_async(struct il_priv *priv, +int il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, const void *data, - void (*callback)(struct il_priv *priv, + void (*callback)(struct il_priv *il, struct il_device_cmd *cmd, struct il_rx_packet *pkt)) { @@ -266,6 +266,6 @@ int il_send_cmd_pdu_async(struct il_priv *priv, cmd.flags |= CMD_ASYNC; cmd.callback = callback; - return il_send_cmd_async(priv, &cmd); + return il_send_cmd_async(il, &cmd); } EXPORT_SYMBOL(il_send_cmd_pdu_async); diff --git a/drivers/net/wireless/iwlegacy/iwl-helpers.h b/drivers/net/wireless/iwlegacy/iwl-helpers.h index e4e63b570f57..e55f2ef1c57b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-helpers.h +++ b/drivers/net/wireless/iwlegacy/iwl-helpers.h @@ -108,28 +108,28 @@ il_set_swq_id(struct il_tx_queue *txq, u8 ac, u8 hwq) txq->swq_id = (hwq << 2) | ac; } -static inline void il_wake_queue(struct il_priv *priv, +static inline void il_wake_queue(struct il_priv *il, struct il_tx_queue *txq) { u8 queue = txq->swq_id; u8 ac = queue & 3; u8 hwq = (queue >> 2) & 0x1f; - if (test_and_clear_bit(hwq, priv->queue_stopped)) - if (atomic_dec_return(&priv->queue_stop_count[ac]) <= 0) - ieee80211_wake_queue(priv->hw, ac); + if (test_and_clear_bit(hwq, il->queue_stopped)) + if (atomic_dec_return(&il->queue_stop_count[ac]) <= 0) + ieee80211_wake_queue(il->hw, ac); } -static inline void il_stop_queue(struct il_priv *priv, +static inline void il_stop_queue(struct il_priv *il, struct il_tx_queue *txq) { u8 queue = txq->swq_id; u8 ac = queue & 3; u8 hwq = (queue >> 2) & 0x1f; - if (!test_and_set_bit(hwq, priv->queue_stopped)) - if (atomic_inc_return(&priv->queue_stop_count[ac]) > 0) - ieee80211_stop_queue(priv->hw, ac); + if (!test_and_set_bit(hwq, il->queue_stopped)) + if (atomic_inc_return(&il->queue_stop_count[ac]) > 0) + ieee80211_stop_queue(il->hw, ac); } #ifdef ieee80211_stop_queue @@ -144,39 +144,39 @@ static inline void il_stop_queue(struct il_priv *priv, #define ieee80211_wake_queue DO_NOT_USE_ieee80211_wake_queue -static inline void il_disable_interrupts(struct il_priv *priv) +static inline void il_disable_interrupts(struct il_priv *il) { - clear_bit(STATUS_INT_ENABLED, &priv->status); + clear_bit(STATUS_INT_ENABLED, &il->status); /* disable interrupts from uCode/NIC to host */ - il_write32(priv, CSR_INT_MASK, 0x00000000); + il_write32(il, CSR_INT_MASK, 0x00000000); /* acknowledge/clear/reset any interrupts still pending * from uCode or flow handler (Rx/Tx DMA) */ - il_write32(priv, CSR_INT, 0xffffffff); - il_write32(priv, CSR_FH_INT_STATUS, 0xffffffff); - IL_DEBUG_ISR(priv, "Disabled interrupts\n"); + il_write32(il, CSR_INT, 0xffffffff); + il_write32(il, CSR_FH_INT_STATUS, 0xffffffff); + IL_DEBUG_ISR(il, "Disabled interrupts\n"); } -static inline void il_enable_rfkill_int(struct il_priv *priv) +static inline void il_enable_rfkill_int(struct il_priv *il) { - IL_DEBUG_ISR(priv, "Enabling rfkill interrupt\n"); - il_write32(priv, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); + IL_DEBUG_ISR(il, "Enabling rfkill interrupt\n"); + il_write32(il, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); } -static inline void il_enable_interrupts(struct il_priv *priv) +static inline void il_enable_interrupts(struct il_priv *il) { - IL_DEBUG_ISR(priv, "Enabling interrupts\n"); - set_bit(STATUS_INT_ENABLED, &priv->status); - il_write32(priv, CSR_INT_MASK, priv->inta_mask); + IL_DEBUG_ISR(il, "Enabling interrupts\n"); + set_bit(STATUS_INT_ENABLED, &il->status); + il_write32(il, CSR_INT_MASK, il->inta_mask); } /** * il_beacon_time_mask_low - mask of lower 32 bit of beacon time - * @priv -- pointer to il_priv data structure + * @il -- pointer to il_priv data structure * @tsf_bits -- number of bits need to shift for masking) */ -static inline u32 il_beacon_time_mask_low(struct il_priv *priv, +static inline u32 il_beacon_time_mask_low(struct il_priv *il, u16 tsf_bits) { return (1 << tsf_bits) - 1; @@ -184,10 +184,10 @@ static inline u32 il_beacon_time_mask_low(struct il_priv *priv, /** * il_beacon_time_mask_high - mask of higher 32 bit of beacon time - * @priv -- pointer to il_priv data structure + * @il -- pointer to il_priv data structure * @tsf_bits -- number of bits need to shift for masking) */ -static inline u32 il_beacon_time_mask_high(struct il_priv *priv, +static inline u32 il_beacon_time_mask_high(struct il_priv *il, u16 tsf_bits) { return ((1 << (32 - tsf_bits)) - 1) << tsf_bits; diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h index ebeb6e2aa6e7..42d241fd6ac9 100644 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ b/drivers/net/wireless/iwlegacy/iwl-io.h @@ -62,72 +62,72 @@ * */ -static inline void _il_write8(struct il_priv *priv, u32 ofs, u8 val) +static inline void _il_write8(struct il_priv *il, u32 ofs, u8 val) { - iowrite8(val, priv->hw_base + ofs); + iowrite8(val, il->hw_base + ofs); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline void -__il_write8(const char *f, u32 l, struct il_priv *priv, +__il_write8(const char *f, u32 l, struct il_priv *il, u32 ofs, u8 val) { - IL_DEBUG_IO(priv, "write8(0x%08X, 0x%02X) - %s %d\n", ofs, val, f, l); - _il_write8(priv, ofs, val); + IL_DEBUG_IO(il, "write8(0x%08X, 0x%02X) - %s %d\n", ofs, val, f, l); + _il_write8(il, ofs, val); } -#define il_write8(priv, ofs, val) \ - __il_write8(__FILE__, __LINE__, priv, ofs, val) +#define il_write8(il, ofs, val) \ + __il_write8(__FILE__, __LINE__, il, ofs, val) #else -#define il_write8(priv, ofs, val) _il_write8(priv, ofs, val) +#define il_write8(il, ofs, val) _il_write8(il, ofs, val) #endif -static inline void _il_write32(struct il_priv *priv, u32 ofs, u32 val) +static inline void _il_write32(struct il_priv *il, u32 ofs, u32 val) { - iowrite32(val, priv->hw_base + ofs); + iowrite32(val, il->hw_base + ofs); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline void -__il_write32(const char *f, u32 l, struct il_priv *priv, +__il_write32(const char *f, u32 l, struct il_priv *il, u32 ofs, u32 val) { - IL_DEBUG_IO(priv, "write32(0x%08X, 0x%08X) - %s %d\n", ofs, val, f, l); - _il_write32(priv, ofs, val); + IL_DEBUG_IO(il, "write32(0x%08X, 0x%08X) - %s %d\n", ofs, val, f, l); + _il_write32(il, ofs, val); } -#define il_write32(priv, ofs, val) \ - __il_write32(__FILE__, __LINE__, priv, ofs, val) +#define il_write32(il, ofs, val) \ + __il_write32(__FILE__, __LINE__, il, ofs, val) #else -#define il_write32(priv, ofs, val) _il_write32(priv, ofs, val) +#define il_write32(il, ofs, val) _il_write32(il, ofs, val) #endif -static inline u32 _il_read32(struct il_priv *priv, u32 ofs) +static inline u32 _il_read32(struct il_priv *il, u32 ofs) { - u32 val = ioread32(priv->hw_base + ofs); + u32 val = ioread32(il->hw_base + ofs); return val; } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline u32 -__il_read32(char *f, u32 l, struct il_priv *priv, u32 ofs) +__il_read32(char *f, u32 l, struct il_priv *il, u32 ofs) { - IL_DEBUG_IO(priv, "read_direct32(0x%08X) - %s %d\n", ofs, f, l); - return _il_read32(priv, ofs); + IL_DEBUG_IO(il, "read_direct32(0x%08X) - %s %d\n", ofs, f, l); + return _il_read32(il, ofs); } -#define il_read32(priv, ofs) __il_read32(__FILE__, __LINE__, priv, ofs) +#define il_read32(il, ofs) __il_read32(__FILE__, __LINE__, il, ofs) #else #define il_read32(p, o) _il_read32(p, o) #endif #define IL_POLL_INTERVAL 10 /* microseconds */ static inline int -_il_poll_bit(struct il_priv *priv, u32 addr, +_il_poll_bit(struct il_priv *il, u32 addr, u32 bits, u32 mask, int timeout) { int t = 0; do { - if ((_il_read32(priv, addr) & mask) == (bits & mask)) + if ((_il_read32(il, addr) & mask) == (bits & mask)) return t; udelay(IL_POLL_INTERVAL); t += IL_POLL_INTERVAL; @@ -137,34 +137,34 @@ _il_poll_bit(struct il_priv *priv, u32 addr, } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline int __il_poll_bit(const char *f, u32 l, - struct il_priv *priv, u32 addr, + struct il_priv *il, u32 addr, u32 bits, u32 mask, int timeout) { - int ret = _il_poll_bit(priv, addr, bits, mask, timeout); - IL_DEBUG_IO(priv, "poll_bit(0x%08X, 0x%08X, 0x%08X) - %s- %s %d\n", + int ret = _il_poll_bit(il, addr, bits, mask, timeout); + IL_DEBUG_IO(il, "poll_bit(0x%08X, 0x%08X, 0x%08X) - %s- %s %d\n", addr, bits, mask, unlikely(ret == -ETIMEDOUT) ? "timeout" : "", f, l); return ret; } -#define il_poll_bit(priv, addr, bits, mask, timeout) \ - __il_poll_bit(__FILE__, __LINE__, priv, addr, \ +#define il_poll_bit(il, addr, bits, mask, timeout) \ + __il_poll_bit(__FILE__, __LINE__, il, addr, \ bits, mask, timeout) #else #define il_poll_bit(p, a, b, m, t) _il_poll_bit(p, a, b, m, t) #endif -static inline void _il_set_bit(struct il_priv *priv, u32 reg, u32 mask) +static inline void _il_set_bit(struct il_priv *il, u32 reg, u32 mask) { - _il_write32(priv, reg, _il_read32(priv, reg) | mask); + _il_write32(il, reg, _il_read32(il, reg) | mask); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline void __il_set_bit(const char *f, u32 l, - struct il_priv *priv, u32 reg, u32 mask) + struct il_priv *il, u32 reg, u32 mask) { - u32 val = _il_read32(priv, reg) | mask; - IL_DEBUG_IO(priv, "set_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, + u32 val = _il_read32(il, reg) | mask; + IL_DEBUG_IO(il, "set_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val); - _il_write32(priv, reg, val); + _il_write32(il, reg, val); } static inline void il_set_bit(struct il_priv *p, u32 r, u32 m) { @@ -186,18 +186,18 @@ static inline void il_set_bit(struct il_priv *p, u32 r, u32 m) #endif static inline void -_il_clear_bit(struct il_priv *priv, u32 reg, u32 mask) +_il_clear_bit(struct il_priv *il, u32 reg, u32 mask) { - _il_write32(priv, reg, _il_read32(priv, reg) & ~mask); + _il_write32(il, reg, _il_read32(il, reg) & ~mask); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline void __il_clear_bit(const char *f, u32 l, - struct il_priv *priv, u32 reg, u32 mask) + struct il_priv *il, u32 reg, u32 mask) { - u32 val = _il_read32(priv, reg) & ~mask; - IL_DEBUG_IO(priv, "clear_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val); - _il_write32(priv, reg, val); + u32 val = _il_read32(il, reg) & ~mask; + IL_DEBUG_IO(il, "clear_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val); + _il_write32(il, reg, val); } static inline void il_clear_bit(struct il_priv *p, u32 r, u32 m) { @@ -218,13 +218,13 @@ static inline void il_clear_bit(struct il_priv *p, u32 r, u32 m) } #endif -static inline int _il_grab_nic_access(struct il_priv *priv) +static inline int _il_grab_nic_access(struct il_priv *il) { int ret; u32 val; /* this bit wakes up the NIC */ - _il_set_bit(priv, CSR_GP_CNTRL, + _il_set_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); /* @@ -244,15 +244,15 @@ static inline int _il_grab_nic_access(struct il_priv *priv) * good idea before accessing 3945/4965 SRAM (e.g. reading Event Log). * */ - ret = _il_poll_bit(priv, CSR_GP_CNTRL, + ret = _il_poll_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN, (CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY | CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 15000); if (ret < 0) { - val = _il_read32(priv, CSR_GP_CNTRL); - IL_ERR(priv, + val = _il_read32(il, CSR_GP_CNTRL); + IL_ERR(il, "MAC is in deep sleep!. CSR_GP_CNTRL = 0x%08X\n", val); - _il_write32(priv, CSR_RESET, + _il_write32(il, CSR_RESET, CSR_RESET_REG_FLAG_FORCE_NMI); return -EIO; } @@ -262,117 +262,117 @@ static inline int _il_grab_nic_access(struct il_priv *priv) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline int __il_grab_nic_access(const char *f, u32 l, - struct il_priv *priv) + struct il_priv *il) { - IL_DEBUG_IO(priv, "grabbing nic access - %s %d\n", f, l); - return _il_grab_nic_access(priv); + IL_DEBUG_IO(il, "grabbing nic access - %s %d\n", f, l); + return _il_grab_nic_access(il); } -#define il_grab_nic_access(priv) \ - __il_grab_nic_access(__FILE__, __LINE__, priv) +#define il_grab_nic_access(il) \ + __il_grab_nic_access(__FILE__, __LINE__, il) #else -#define il_grab_nic_access(priv) \ - _il_grab_nic_access(priv) +#define il_grab_nic_access(il) \ + _il_grab_nic_access(il) #endif -static inline void _il_release_nic_access(struct il_priv *priv) +static inline void _il_release_nic_access(struct il_priv *il) { - _il_clear_bit(priv, CSR_GP_CNTRL, + _il_clear_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline void __il_release_nic_access(const char *f, u32 l, - struct il_priv *priv) + struct il_priv *il) { - IL_DEBUG_IO(priv, "releasing nic access - %s %d\n", f, l); - _il_release_nic_access(priv); + IL_DEBUG_IO(il, "releasing nic access - %s %d\n", f, l); + _il_release_nic_access(il); } -#define il_release_nic_access(priv) \ - __il_release_nic_access(__FILE__, __LINE__, priv) +#define il_release_nic_access(il) \ + __il_release_nic_access(__FILE__, __LINE__, il) #else -#define il_release_nic_access(priv) \ - _il_release_nic_access(priv) +#define il_release_nic_access(il) \ + _il_release_nic_access(il) #endif -static inline u32 _il_read_direct32(struct il_priv *priv, u32 reg) +static inline u32 _il_read_direct32(struct il_priv *il, u32 reg) { - return _il_read32(priv, reg); + return _il_read32(il, reg); } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline u32 __il_read_direct32(const char *f, u32 l, - struct il_priv *priv, u32 reg) + struct il_priv *il, u32 reg) { - u32 value = _il_read_direct32(priv, reg); - IL_DEBUG_IO(priv, + u32 value = _il_read_direct32(il, reg); + IL_DEBUG_IO(il, "read_direct32(0x%4X) = 0x%08x - %s %d\n", reg, value, f, l); return value; } -static inline u32 il_read_direct32(struct il_priv *priv, u32 reg) +static inline u32 il_read_direct32(struct il_priv *il, u32 reg) { u32 value; unsigned long reg_flags; - spin_lock_irqsave(&priv->reg_lock, reg_flags); - il_grab_nic_access(priv); - value = __il_read_direct32(__FILE__, __LINE__, priv, reg); - il_release_nic_access(priv); - spin_unlock_irqrestore(&priv->reg_lock, reg_flags); + spin_lock_irqsave(&il->reg_lock, reg_flags); + il_grab_nic_access(il); + value = __il_read_direct32(__FILE__, __LINE__, il, reg); + il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); return value; } #else -static inline u32 il_read_direct32(struct il_priv *priv, u32 reg) +static inline u32 il_read_direct32(struct il_priv *il, u32 reg) { u32 value; unsigned long reg_flags; - spin_lock_irqsave(&priv->reg_lock, reg_flags); - il_grab_nic_access(priv); - value = _il_read_direct32(priv, reg); - il_release_nic_access(priv); - spin_unlock_irqrestore(&priv->reg_lock, reg_flags); + spin_lock_irqsave(&il->reg_lock, reg_flags); + il_grab_nic_access(il); + value = _il_read_direct32(il, reg); + il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); return value; } #endif -static inline void _il_write_direct32(struct il_priv *priv, +static inline void _il_write_direct32(struct il_priv *il, u32 reg, u32 value) { - _il_write32(priv, reg, value); + _il_write32(il, reg, value); } static inline void -il_write_direct32(struct il_priv *priv, u32 reg, u32 value) +il_write_direct32(struct il_priv *il, u32 reg, u32 value) { unsigned long reg_flags; - spin_lock_irqsave(&priv->reg_lock, reg_flags); - if (!il_grab_nic_access(priv)) { - _il_write_direct32(priv, reg, value); - il_release_nic_access(priv); + spin_lock_irqsave(&il->reg_lock, reg_flags); + if (!il_grab_nic_access(il)) { + _il_write_direct32(il, reg, value); + il_release_nic_access(il); } - spin_unlock_irqrestore(&priv->reg_lock, reg_flags); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); } -static inline void il_write_reg_buf(struct il_priv *priv, +static inline void il_write_reg_buf(struct il_priv *il, u32 reg, u32 len, u32 *values) { u32 count = sizeof(u32); - if ((priv != NULL) && (values != NULL)) { + if ((il != NULL) && (values != NULL)) { for (; 0 < len; len -= count, reg += count, values++) - il_write_direct32(priv, reg, *values); + il_write_direct32(il, reg, *values); } } -static inline int _il_poll_direct_bit(struct il_priv *priv, u32 addr, +static inline int _il_poll_direct_bit(struct il_priv *il, u32 addr, u32 mask, int timeout) { int t = 0; do { - if ((il_read_direct32(priv, addr) & mask) == mask) + if ((il_read_direct32(il, addr) & mask) == mask) return t; udelay(IL_POLL_INTERVAL); t += IL_POLL_INTERVAL; @@ -383,159 +383,159 @@ static inline int _il_poll_direct_bit(struct il_priv *priv, u32 addr, #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG static inline int __il_poll_direct_bit(const char *f, u32 l, - struct il_priv *priv, + struct il_priv *il, u32 addr, u32 mask, int timeout) { - int ret = _il_poll_direct_bit(priv, addr, mask, timeout); + int ret = _il_poll_direct_bit(il, addr, mask, timeout); if (unlikely(ret == -ETIMEDOUT)) - IL_DEBUG_IO(priv, "poll_direct_bit(0x%08X, 0x%08X) - " + IL_DEBUG_IO(il, "poll_direct_bit(0x%08X, 0x%08X) - " "timedout - %s %d\n", addr, mask, f, l); else - IL_DEBUG_IO(priv, "poll_direct_bit(0x%08X, 0x%08X) = 0x%08X " + IL_DEBUG_IO(il, "poll_direct_bit(0x%08X, 0x%08X) = 0x%08X " "- %s %d\n", addr, mask, ret, f, l); return ret; } -#define il_poll_direct_bit(priv, addr, mask, timeout) \ -__il_poll_direct_bit(__FILE__, __LINE__, priv, addr, mask, timeout) +#define il_poll_direct_bit(il, addr, mask, timeout) \ +__il_poll_direct_bit(__FILE__, __LINE__, il, addr, mask, timeout) #else #define il_poll_direct_bit _il_poll_direct_bit #endif -static inline u32 _il_read_prph(struct il_priv *priv, u32 reg) +static inline u32 _il_read_prph(struct il_priv *il, u32 reg) { - _il_write_direct32(priv, HBUS_TARG_PRPH_RADDR, reg | (3 << 24)); + _il_write_direct32(il, HBUS_TARG_PRPH_RADDR, reg | (3 << 24)); rmb(); - return _il_read_direct32(priv, HBUS_TARG_PRPH_RDAT); + return _il_read_direct32(il, HBUS_TARG_PRPH_RDAT); } -static inline u32 il_read_prph(struct il_priv *priv, u32 reg) +static inline u32 il_read_prph(struct il_priv *il, u32 reg) { unsigned long reg_flags; u32 val; - spin_lock_irqsave(&priv->reg_lock, reg_flags); - il_grab_nic_access(priv); - val = _il_read_prph(priv, reg); - il_release_nic_access(priv); - spin_unlock_irqrestore(&priv->reg_lock, reg_flags); + spin_lock_irqsave(&il->reg_lock, reg_flags); + il_grab_nic_access(il); + val = _il_read_prph(il, reg); + il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); return val; } -static inline void _il_write_prph(struct il_priv *priv, +static inline void _il_write_prph(struct il_priv *il, u32 addr, u32 val) { - _il_write_direct32(priv, HBUS_TARG_PRPH_WADDR, + _il_write_direct32(il, HBUS_TARG_PRPH_WADDR, ((addr & 0x0000FFFF) | (3 << 24))); wmb(); - _il_write_direct32(priv, HBUS_TARG_PRPH_WDAT, val); + _il_write_direct32(il, HBUS_TARG_PRPH_WDAT, val); } static inline void -il_write_prph(struct il_priv *priv, u32 addr, u32 val) +il_write_prph(struct il_priv *il, u32 addr, u32 val) { unsigned long reg_flags; - spin_lock_irqsave(&priv->reg_lock, reg_flags); - if (!il_grab_nic_access(priv)) { - _il_write_prph(priv, addr, val); - il_release_nic_access(priv); + spin_lock_irqsave(&il->reg_lock, reg_flags); + if (!il_grab_nic_access(il)) { + _il_write_prph(il, addr, val); + il_release_nic_access(il); } - spin_unlock_irqrestore(&priv->reg_lock, reg_flags); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); } -#define _il_set_bits_prph(priv, reg, mask) \ -_il_write_prph(priv, reg, (_il_read_prph(priv, reg) | mask)) +#define _il_set_bits_prph(il, reg, mask) \ +_il_write_prph(il, reg, (_il_read_prph(il, reg) | mask)) static inline void -il_set_bits_prph(struct il_priv *priv, u32 reg, u32 mask) +il_set_bits_prph(struct il_priv *il, u32 reg, u32 mask) { unsigned long reg_flags; - spin_lock_irqsave(&priv->reg_lock, reg_flags); - il_grab_nic_access(priv); - _il_set_bits_prph(priv, reg, mask); - il_release_nic_access(priv); - spin_unlock_irqrestore(&priv->reg_lock, reg_flags); + spin_lock_irqsave(&il->reg_lock, reg_flags); + il_grab_nic_access(il); + _il_set_bits_prph(il, reg, mask); + il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); } -#define _il_set_bits_mask_prph(priv, reg, bits, mask) \ -_il_write_prph(priv, reg, \ - ((_il_read_prph(priv, reg) & mask) | bits)) +#define _il_set_bits_mask_prph(il, reg, bits, mask) \ +_il_write_prph(il, reg, \ + ((_il_read_prph(il, reg) & mask) | bits)) -static inline void il_set_bits_mask_prph(struct il_priv *priv, u32 reg, +static inline void il_set_bits_mask_prph(struct il_priv *il, u32 reg, u32 bits, u32 mask) { unsigned long reg_flags; - spin_lock_irqsave(&priv->reg_lock, reg_flags); - il_grab_nic_access(priv); - _il_set_bits_mask_prph(priv, reg, bits, mask); - il_release_nic_access(priv); - spin_unlock_irqrestore(&priv->reg_lock, reg_flags); + spin_lock_irqsave(&il->reg_lock, reg_flags); + il_grab_nic_access(il); + _il_set_bits_mask_prph(il, reg, bits, mask); + il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); } static inline void il_clear_bits_prph(struct il_priv - *priv, u32 reg, u32 mask) + *il, u32 reg, u32 mask) { unsigned long reg_flags; u32 val; - spin_lock_irqsave(&priv->reg_lock, reg_flags); - il_grab_nic_access(priv); - val = _il_read_prph(priv, reg); - _il_write_prph(priv, reg, (val & ~mask)); - il_release_nic_access(priv); - spin_unlock_irqrestore(&priv->reg_lock, reg_flags); + spin_lock_irqsave(&il->reg_lock, reg_flags); + il_grab_nic_access(il); + val = _il_read_prph(il, reg); + _il_write_prph(il, reg, (val & ~mask)); + il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); } -static inline u32 il_read_targ_mem(struct il_priv *priv, u32 addr) +static inline u32 il_read_targ_mem(struct il_priv *il, u32 addr) { unsigned long reg_flags; u32 value; - spin_lock_irqsave(&priv->reg_lock, reg_flags); - il_grab_nic_access(priv); + spin_lock_irqsave(&il->reg_lock, reg_flags); + il_grab_nic_access(il); - _il_write_direct32(priv, HBUS_TARG_MEM_RADDR, addr); + _il_write_direct32(il, HBUS_TARG_MEM_RADDR, addr); rmb(); - value = _il_read_direct32(priv, HBUS_TARG_MEM_RDAT); + value = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); - il_release_nic_access(priv); - spin_unlock_irqrestore(&priv->reg_lock, reg_flags); + il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); return value; } static inline void -il_write_targ_mem(struct il_priv *priv, u32 addr, u32 val) +il_write_targ_mem(struct il_priv *il, u32 addr, u32 val) { unsigned long reg_flags; - spin_lock_irqsave(&priv->reg_lock, reg_flags); - if (!il_grab_nic_access(priv)) { - _il_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr); + spin_lock_irqsave(&il->reg_lock, reg_flags); + if (!il_grab_nic_access(il)) { + _il_write_direct32(il, HBUS_TARG_MEM_WADDR, addr); wmb(); - _il_write_direct32(priv, HBUS_TARG_MEM_WDAT, val); - il_release_nic_access(priv); + _il_write_direct32(il, HBUS_TARG_MEM_WDAT, val); + il_release_nic_access(il); } - spin_unlock_irqrestore(&priv->reg_lock, reg_flags); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); } static inline void -il_write_targ_mem_buf(struct il_priv *priv, u32 addr, +il_write_targ_mem_buf(struct il_priv *il, u32 addr, u32 len, u32 *values) { unsigned long reg_flags; - spin_lock_irqsave(&priv->reg_lock, reg_flags); - if (!il_grab_nic_access(priv)) { - _il_write_direct32(priv, HBUS_TARG_MEM_WADDR, addr); + spin_lock_irqsave(&il->reg_lock, reg_flags); + if (!il_grab_nic_access(il)) { + _il_write_direct32(il, HBUS_TARG_MEM_WADDR, addr); wmb(); for (; 0 < len; len -= sizeof(u32), values++) - _il_write_direct32(priv, + _il_write_direct32(il, HBUS_TARG_MEM_WDAT, *values); - il_release_nic_access(priv); + il_release_nic_access(il); } - spin_unlock_irqrestore(&priv->reg_lock, reg_flags); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); } #endif diff --git a/drivers/net/wireless/iwlegacy/iwl-led.c b/drivers/net/wireless/iwlegacy/iwl-led.c index 490b183b1347..13add43987b6 100644 --- a/drivers/net/wireless/iwlegacy/iwl-led.c +++ b/drivers/net/wireless/iwlegacy/iwl-led.c @@ -84,11 +84,11 @@ static const struct ieee80211_tpt_blink il_blink[] = { * compensation = (100 - averageDeviation) * 64 / 100 * NewBlinkTime = (compensation * BlinkTime) / 64 */ -static inline u8 il_blink_compensation(struct il_priv *priv, +static inline u8 il_blink_compensation(struct il_priv *il, u8 time, u16 compensation) { if (!compensation) { - IL_ERR(priv, "undefined blink compensation: " + IL_ERR(il, "undefined blink compensation: " "use pre-defined blinking time\n"); return time; } @@ -97,7 +97,7 @@ static inline u8 il_blink_compensation(struct il_priv *priv, } /* Set led pattern command */ -static int il_led_cmd(struct il_priv *priv, +static int il_led_cmd(struct il_priv *il, unsigned long on, unsigned long off) { @@ -107,10 +107,10 @@ static int il_led_cmd(struct il_priv *priv, }; int ret; - if (!test_bit(STATUS_READY, &priv->status)) + if (!test_bit(STATUS_READY, &il->status)) return -EBUSY; - if (priv->blink_on == on && priv->blink_off == off) + if (il->blink_on == on && il->blink_off == off) return 0; if (off == 0) { @@ -118,17 +118,17 @@ static int il_led_cmd(struct il_priv *priv, on = IL_LED_SOLID; } - IL_DEBUG_LED(priv, "Led blink time compensation=%u\n", - priv->cfg->base_params->led_compensation); - led_cmd.on = il_blink_compensation(priv, on, - priv->cfg->base_params->led_compensation); - led_cmd.off = il_blink_compensation(priv, off, - priv->cfg->base_params->led_compensation); + IL_DEBUG_LED(il, "Led blink time compensation=%u\n", + il->cfg->base_params->led_compensation); + led_cmd.on = il_blink_compensation(il, on, + il->cfg->base_params->led_compensation); + led_cmd.off = il_blink_compensation(il, off, + il->cfg->base_params->led_compensation); - ret = priv->cfg->ops->led->cmd(priv, &led_cmd); + ret = il->cfg->ops->led->cmd(il, &led_cmd); if (!ret) { - priv->blink_on = on; - priv->blink_off = off; + il->blink_on = on; + il->blink_off = off; } return ret; } @@ -136,70 +136,70 @@ static int il_led_cmd(struct il_priv *priv, static void il_led_brightness_set(struct led_classdev *led_cdev, enum led_brightness brightness) { - struct il_priv *priv = container_of(led_cdev, struct il_priv, led); + struct il_priv *il = container_of(led_cdev, struct il_priv, led); unsigned long on = 0; if (brightness > 0) on = IL_LED_SOLID; - il_led_cmd(priv, on, 0); + il_led_cmd(il, on, 0); } static int il_led_blink_set(struct led_classdev *led_cdev, unsigned long *delay_on, unsigned long *delay_off) { - struct il_priv *priv = container_of(led_cdev, struct il_priv, led); + struct il_priv *il = container_of(led_cdev, struct il_priv, led); - return il_led_cmd(priv, *delay_on, *delay_off); + return il_led_cmd(il, *delay_on, *delay_off); } -void il_leds_init(struct il_priv *priv) +void il_leds_init(struct il_priv *il) { int mode = led_mode; int ret; if (mode == IL_LED_DEFAULT) - mode = priv->cfg->led_mode; + mode = il->cfg->led_mode; - priv->led.name = kasprintf(GFP_KERNEL, "%s-led", - wiphy_name(priv->hw->wiphy)); - priv->led.brightness_set = il_led_brightness_set; - priv->led.blink_set = il_led_blink_set; - priv->led.max_brightness = 1; + il->led.name = kasprintf(GFP_KERNEL, "%s-led", + wiphy_name(il->hw->wiphy)); + il->led.brightness_set = il_led_brightness_set; + il->led.blink_set = il_led_blink_set; + il->led.max_brightness = 1; switch (mode) { case IL_LED_DEFAULT: WARN_ON(1); break; case IL_LED_BLINK: - priv->led.default_trigger = - ieee80211_create_tpt_led_trigger(priv->hw, + il->led.default_trigger = + ieee80211_create_tpt_led_trigger(il->hw, IEEE80211_TPT_LEDTRIG_FL_CONNECTED, il_blink, ARRAY_SIZE(il_blink)); break; case IL_LED_RF_STATE: - priv->led.default_trigger = - ieee80211_get_radio_led_name(priv->hw); + il->led.default_trigger = + ieee80211_get_radio_led_name(il->hw); break; } - ret = led_classdev_register(&priv->pci_dev->dev, &priv->led); + ret = led_classdev_register(&il->pci_dev->dev, &il->led); if (ret) { - kfree(priv->led.name); + kfree(il->led.name); return; } - priv->led_registered = true; + il->led_registered = true; } EXPORT_SYMBOL(il_leds_init); -void il_leds_exit(struct il_priv *priv) +void il_leds_exit(struct il_priv *il) { - if (!priv->led_registered) + if (!il->led_registered) return; - led_classdev_unregister(&priv->led); - kfree(priv->led.name); + led_classdev_unregister(&il->led); + kfree(il->led.name); } EXPORT_SYMBOL(il_leds_exit); diff --git a/drivers/net/wireless/iwlegacy/iwl-led.h b/drivers/net/wireless/iwlegacy/iwl-led.h index ea7a8ea23a15..d3aba57feba7 100644 --- a/drivers/net/wireless/iwlegacy/iwl-led.h +++ b/drivers/net/wireless/iwlegacy/iwl-led.h @@ -50,7 +50,7 @@ enum il_led_mode { IL_LED_BLINK, }; -void il_leds_init(struct il_priv *priv); -void il_leds_exit(struct il_priv *priv); +void il_leds_init(struct il_priv *il); +void il_leds_exit(struct il_priv *il); #endif /* __il_leds_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h index 72ef91e9a799..4282ed553b92 100644 --- a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h +++ b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h @@ -346,7 +346,7 @@ struct il_traffic_load { }; /** - * struct il_lq_sta -- driver's rate scaling private structure + * struct il_lq_sta -- driver's rate scaling ilate structure * * Pointer to this gets passed back and forth between driver and mac80211. */ @@ -400,11 +400,9 @@ struct il_lq_sta { u8 is_agg; }; -static inline u8 il4965_num_of_ant(u8 mask) +static inline u8 il4965_num_of_ant(u8 m) { - return !!((mask) & ANT_A) + - !!((mask) & ANT_B) + - !!((mask) & ANT_C); + return !!(m & ANT_A) + !!(m & ANT_B) + !!(m & ANT_C); } static inline u8 il4965_first_antenna(u8 mask) @@ -426,9 +424,9 @@ static inline u8 il4965_first_antenna(u8 mask) extern void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id); /* Initialize station's rate scaling information after adding station */ -extern void il4965_rs_rate_init(struct il_priv *priv, +extern void il4965_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_id); -extern void il3945_rs_rate_init(struct il_priv *priv, +extern void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_id); /** diff --git a/drivers/net/wireless/iwlegacy/iwl-power.c b/drivers/net/wireless/iwlegacy/iwl-power.c index 7ccff257736e..63862464fcdb 100644 --- a/drivers/net/wireless/iwlegacy/iwl-power.c +++ b/drivers/net/wireless/iwlegacy/iwl-power.c @@ -60,27 +60,27 @@ struct il_power_vec_entry { u8 no_dtim; /* number of skip dtim */ }; -static void il_power_sleep_cam_cmd(struct il_priv *priv, +static void il_power_sleep_cam_cmd(struct il_priv *il, struct il_powertable_cmd *cmd) { memset(cmd, 0, sizeof(*cmd)); - if (priv->power_data.pci_pm) + if (il->power_data.pci_pm) cmd->flags |= IL_POWER_PCI_PM_MSK; - IL_DEBUG_POWER(priv, "Sleep command for CAM\n"); + IL_DEBUG_POWER(il, "Sleep command for CAM\n"); } static int -il_set_power(struct il_priv *priv, struct il_powertable_cmd *cmd) +il_set_power(struct il_priv *il, struct il_powertable_cmd *cmd) { - IL_DEBUG_POWER(priv, "Sending power/sleep command\n"); - IL_DEBUG_POWER(priv, "Flags value = 0x%08X\n", cmd->flags); - IL_DEBUG_POWER(priv, "Tx timeout = %u\n", + IL_DEBUG_POWER(il, "Sending power/sleep command\n"); + IL_DEBUG_POWER(il, "Flags value = 0x%08X\n", cmd->flags); + IL_DEBUG_POWER(il, "Tx timeout = %u\n", le32_to_cpu(cmd->tx_data_timeout)); - IL_DEBUG_POWER(priv, "Rx timeout = %u\n", + IL_DEBUG_POWER(il, "Rx timeout = %u\n", le32_to_cpu(cmd->rx_data_timeout)); - IL_DEBUG_POWER(priv, + IL_DEBUG_POWER(il, "Sleep interval vector = { %d , %d , %d , %d , %d }\n", le32_to_cpu(cmd->sleep_interval[0]), le32_to_cpu(cmd->sleep_interval[1]), @@ -88,78 +88,78 @@ il_set_power(struct il_priv *priv, struct il_powertable_cmd *cmd) le32_to_cpu(cmd->sleep_interval[3]), le32_to_cpu(cmd->sleep_interval[4])); - return il_send_cmd_pdu(priv, POWER_TABLE_CMD, + return il_send_cmd_pdu(il, POWER_TABLE_CMD, sizeof(struct il_powertable_cmd), cmd); } int -il_power_set_mode(struct il_priv *priv, struct il_powertable_cmd *cmd, +il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, bool force) { int ret; bool update_chains; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); /* Don't update the RX chain when chain noise calibration is running */ - update_chains = priv->chain_noise_data.state == IL_CHAIN_NOISE_DONE || - priv->chain_noise_data.state == IL_CHAIN_NOISE_ALIVE; + update_chains = il->chain_noise_data.state == IL_CHAIN_NOISE_DONE || + il->chain_noise_data.state == IL_CHAIN_NOISE_ALIVE; - if (!memcmp(&priv->power_data.sleep_cmd, cmd, sizeof(*cmd)) && !force) + if (!memcmp(&il->power_data.sleep_cmd, cmd, sizeof(*cmd)) && !force) return 0; - if (!il_is_ready_rf(priv)) + if (!il_is_ready_rf(il)) return -EIO; /* scan complete use sleep_power_next, need to be updated */ - memcpy(&priv->power_data.sleep_cmd_next, cmd, sizeof(*cmd)); - if (test_bit(STATUS_SCANNING, &priv->status) && !force) { - IL_DEBUG_INFO(priv, "Defer power set mode while scanning\n"); + memcpy(&il->power_data.sleep_cmd_next, cmd, sizeof(*cmd)); + if (test_bit(STATUS_SCANNING, &il->status) && !force) { + IL_DEBUG_INFO(il, "Defer power set mode while scanning\n"); return 0; } if (cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK) - set_bit(STATUS_POWER_PMI, &priv->status); + set_bit(STATUS_POWER_PMI, &il->status); - ret = il_set_power(priv, cmd); + ret = il_set_power(il, cmd); if (!ret) { if (!(cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK)) - clear_bit(STATUS_POWER_PMI, &priv->status); + clear_bit(STATUS_POWER_PMI, &il->status); - if (priv->cfg->ops->lib->update_chain_flags && update_chains) - priv->cfg->ops->lib->update_chain_flags(priv); - else if (priv->cfg->ops->lib->update_chain_flags) - IL_DEBUG_POWER(priv, + if (il->cfg->ops->lib->update_chain_flags && update_chains) + il->cfg->ops->lib->update_chain_flags(il); + else if (il->cfg->ops->lib->update_chain_flags) + IL_DEBUG_POWER(il, "Cannot update the power, chain noise " "calibration running: %d\n", - priv->chain_noise_data.state); + il->chain_noise_data.state); - memcpy(&priv->power_data.sleep_cmd, cmd, sizeof(*cmd)); + memcpy(&il->power_data.sleep_cmd, cmd, sizeof(*cmd)); } else - IL_ERR(priv, "set power fail, ret = %d", ret); + IL_ERR(il, "set power fail, ret = %d", ret); return ret; } -int il_power_update_mode(struct il_priv *priv, bool force) +int il_power_update_mode(struct il_priv *il, bool force) { struct il_powertable_cmd cmd; - il_power_sleep_cam_cmd(priv, &cmd); - return il_power_set_mode(priv, &cmd, force); + il_power_sleep_cam_cmd(il, &cmd); + return il_power_set_mode(il, &cmd, force); } EXPORT_SYMBOL(il_power_update_mode); /* initialize to default */ -void il_power_initialize(struct il_priv *priv) +void il_power_initialize(struct il_priv *il) { - u16 lctl = il_pcie_link_ctl(priv); + u16 lctl = il_pcie_link_ctl(il); - priv->power_data.pci_pm = !(lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN); + il->power_data.pci_pm = !(lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN); - priv->power_data.debug_sleep_level_override = -1; + il->power_data.debug_sleep_level_override = -1; - memset(&priv->power_data.sleep_cmd, 0, - sizeof(priv->power_data.sleep_cmd)); + memset(&il->power_data.sleep_cmd, 0, + sizeof(il->power_data.sleep_cmd)); } EXPORT_SYMBOL(il_power_initialize); diff --git a/drivers/net/wireless/iwlegacy/iwl-power.h b/drivers/net/wireless/iwlegacy/iwl-power.h index dba4ca9d30eb..e149f789063f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-power.h +++ b/drivers/net/wireless/iwlegacy/iwl-power.h @@ -47,9 +47,9 @@ struct il_power_mgr { }; int -il_power_set_mode(struct il_priv *priv, struct il_powertable_cmd *cmd, +il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, bool force); -int il_power_update_mode(struct il_priv *priv, bool force); -void il_power_initialize(struct il_priv *priv); +int il_power_update_mode(struct il_priv *il, bool force); +void il_power_initialize(struct il_priv *il); #endif /* __il_power_setting_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c index 9a2714c7f3e8..b6c5dd09bd8b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -124,11 +124,11 @@ EXPORT_SYMBOL(il_rx_queue_space); * il_rx_queue_update_write_ptr - Update the write pointer for the RX queue */ void -il_rx_queue_update_write_ptr(struct il_priv *priv, +il_rx_queue_update_write_ptr(struct il_priv *il, struct il_rx_queue *q) { unsigned long flags; - u32 rx_wrt_ptr_reg = priv->hw_params.rx_wrt_ptr_reg; + u32 rx_wrt_ptr_reg = il->hw_params.rx_wrt_ptr_reg; u32 reg; spin_lock_irqsave(&q->lock, flags); @@ -137,27 +137,27 @@ il_rx_queue_update_write_ptr(struct il_priv *priv, goto exit_unlock; /* If power-saving is in use, make sure device is awake */ - if (test_bit(STATUS_POWER_PMI, &priv->status)) { - reg = il_read32(priv, CSR_UCODE_DRV_GP1); + if (test_bit(STATUS_POWER_PMI, &il->status)) { + reg = il_read32(il, CSR_UCODE_DRV_GP1); if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "Rx queue requesting wakeup," " GP1 = 0x%x\n", reg); - il_set_bit(priv, CSR_GP_CNTRL, + il_set_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); goto exit_unlock; } q->write_actual = (q->write & ~0x7); - il_write_direct32(priv, rx_wrt_ptr_reg, + il_write_direct32(il, rx_wrt_ptr_reg, q->write_actual); /* Else device is assumed to be awake */ } else { /* Device expects a multiple of 8 */ q->write_actual = (q->write & ~0x7); - il_write_direct32(priv, rx_wrt_ptr_reg, + il_write_direct32(il, rx_wrt_ptr_reg, q->write_actual); } @@ -168,10 +168,10 @@ il_rx_queue_update_write_ptr(struct il_priv *priv, } EXPORT_SYMBOL(il_rx_queue_update_write_ptr); -int il_rx_queue_alloc(struct il_priv *priv) +int il_rx_queue_alloc(struct il_priv *il) { - struct il_rx_queue *rxq = &priv->rxq; - struct device *dev = &priv->pci_dev->dev; + struct il_rx_queue *rxq = &il->rxq; + struct device *dev = &il->pci_dev->dev; int i; spin_lock_init(&rxq->lock); @@ -202,7 +202,7 @@ int il_rx_queue_alloc(struct il_priv *priv) return 0; err_rb: - dma_free_coherent(&priv->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, + dma_free_coherent(&il->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, rxq->bd_dma); err_bd: return -ENOMEM; @@ -210,27 +210,27 @@ err_bd: EXPORT_SYMBOL(il_rx_queue_alloc); -void il_rx_spectrum_measure_notif(struct il_priv *priv, +void il_rx_spectrum_measure_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); struct il_spectrum_notification *report = &(pkt->u.spectrum_notif); if (!report->state) { - IL_DEBUG_11H(priv, + IL_DEBUG_11H(il, "Spectrum Measure Notification: Start\n"); return; } - memcpy(&priv->measure_report, report, sizeof(*report)); - priv->measurement_status |= MEASUREMENT_READY; + memcpy(&il->measure_report, report, sizeof(*report)); + il->measurement_status |= MEASUREMENT_READY; } EXPORT_SYMBOL(il_rx_spectrum_measure_notif); /* * returns non-zero if packet should be dropped */ -int il_set_decrypted_flag(struct il_priv *priv, +int il_set_decrypted_flag(struct il_priv *il, struct ieee80211_hdr *hdr, u32 decrypt_res, struct ieee80211_rx_status *stats) @@ -241,14 +241,14 @@ int il_set_decrypted_flag(struct il_priv *priv, * All contexts have the same setting here due to it being * a module parameter, so OK to check any context. */ - if (priv->contexts[IL_RXON_CTX_BSS].active.filter_flags & + if (il->contexts[IL_RXON_CTX_BSS].active.filter_flags & RXON_FILTER_DIS_DECRYPT_MSK) return 0; if (!(fc & IEEE80211_FCTL_PROTECTED)) return 0; - IL_DEBUG_RX(priv, "decrypt_res:0x%x\n", decrypt_res); + IL_DEBUG_RX(il, "decrypt_res:0x%x\n", decrypt_res); switch (decrypt_res & RX_RES_STATUS_SEC_TYPE_MSK) { case RX_RES_STATUS_SEC_TYPE_TKIP: /* The uCode has got a bad phase 1 Key, pushes the packet. @@ -262,13 +262,13 @@ int il_set_decrypted_flag(struct il_priv *priv, RX_RES_STATUS_BAD_ICV_MIC) { /* bad ICV, the packet is destroyed since the * decryption is inplace, drop it */ - IL_DEBUG_RX(priv, "Packet destroyed\n"); + IL_DEBUG_RX(il, "Packet destroyed\n"); return -1; } case RX_RES_STATUS_SEC_TYPE_CCMP: if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) == RX_RES_STATUS_DECRYPT_OK) { - IL_DEBUG_RX(priv, "hw decrypt successfully!!!\n"); + IL_DEBUG_RX(il, "hw decrypt successfully!!!\n"); stats->flag |= RX_FLAG_DECRYPTED; } break; diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index 93e939cc9bc6..0184d5bf04e2 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -54,7 +54,7 @@ #define IL_PASSIVE_DWELL_BASE (100) #define IL_CHANNEL_TUNE_TIME 5 -static int il_send_scan_abort(struct il_priv *priv) +static int il_send_scan_abort(struct il_priv *il) { int ret; struct il_rx_packet *pkt; @@ -66,14 +66,14 @@ static int il_send_scan_abort(struct il_priv *priv) /* Exit instantly with error when device is not ready * to receive scan abort command or it does not perform * hardware scan currently */ - if (!test_bit(STATUS_READY, &priv->status) || - !test_bit(STATUS_GEO_CONFIGURED, &priv->status) || - !test_bit(STATUS_SCAN_HW, &priv->status) || - test_bit(STATUS_FW_ERROR, &priv->status) || - test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (!test_bit(STATUS_READY, &il->status) || + !test_bit(STATUS_GEO_CONFIGURED, &il->status) || + !test_bit(STATUS_SCAN_HW, &il->status) || + test_bit(STATUS_FW_ERROR, &il->status) || + test_bit(STATUS_EXIT_PENDING, &il->status)) return -EIO; - ret = il_send_cmd_sync(priv, &cmd); + ret = il_send_cmd_sync(il, &cmd); if (ret) return ret; @@ -85,73 +85,73 @@ static int il_send_scan_abort(struct il_priv *priv) * can occur if we send the scan abort before we * the microcode has notified us that a scan is * completed. */ - IL_DEBUG_SCAN(priv, "SCAN_ABORT ret %d.\n", pkt->u.status); + IL_DEBUG_SCAN(il, "SCAN_ABORT ret %d.\n", pkt->u.status); ret = -EIO; } - il_free_pages(priv, cmd.reply_page); + il_free_pages(il, cmd.reply_page); return ret; } -static void il_complete_scan(struct il_priv *priv, bool aborted) +static void il_complete_scan(struct il_priv *il, bool aborted) { /* check if scan was requested from mac80211 */ - if (priv->scan_request) { - IL_DEBUG_SCAN(priv, "Complete scan in mac80211\n"); - ieee80211_scan_completed(priv->hw, aborted); + if (il->scan_request) { + IL_DEBUG_SCAN(il, "Complete scan in mac80211\n"); + ieee80211_scan_completed(il->hw, aborted); } - priv->scan_vif = NULL; - priv->scan_request = NULL; + il->scan_vif = NULL; + il->scan_request = NULL; } -void il_force_scan_end(struct il_priv *priv) +void il_force_scan_end(struct il_priv *il) { - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - if (!test_bit(STATUS_SCANNING, &priv->status)) { - IL_DEBUG_SCAN(priv, "Forcing scan end while not scanning\n"); + if (!test_bit(STATUS_SCANNING, &il->status)) { + IL_DEBUG_SCAN(il, "Forcing scan end while not scanning\n"); return; } - IL_DEBUG_SCAN(priv, "Forcing scan end\n"); - clear_bit(STATUS_SCANNING, &priv->status); - clear_bit(STATUS_SCAN_HW, &priv->status); - clear_bit(STATUS_SCAN_ABORTING, &priv->status); - il_complete_scan(priv, true); + IL_DEBUG_SCAN(il, "Forcing scan end\n"); + clear_bit(STATUS_SCANNING, &il->status); + clear_bit(STATUS_SCAN_HW, &il->status); + clear_bit(STATUS_SCAN_ABORTING, &il->status); + il_complete_scan(il, true); } -static void il_do_scan_abort(struct il_priv *priv) +static void il_do_scan_abort(struct il_priv *il) { int ret; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - if (!test_bit(STATUS_SCANNING, &priv->status)) { - IL_DEBUG_SCAN(priv, "Not performing scan to abort\n"); + if (!test_bit(STATUS_SCANNING, &il->status)) { + IL_DEBUG_SCAN(il, "Not performing scan to abort\n"); return; } - if (test_and_set_bit(STATUS_SCAN_ABORTING, &priv->status)) { - IL_DEBUG_SCAN(priv, "Scan abort in progress\n"); + if (test_and_set_bit(STATUS_SCAN_ABORTING, &il->status)) { + IL_DEBUG_SCAN(il, "Scan abort in progress\n"); return; } - ret = il_send_scan_abort(priv); + ret = il_send_scan_abort(il); if (ret) { - IL_DEBUG_SCAN(priv, "Send scan abort failed %d\n", ret); - il_force_scan_end(priv); + IL_DEBUG_SCAN(il, "Send scan abort failed %d\n", ret); + il_force_scan_end(il); } else - IL_DEBUG_SCAN(priv, "Successfully send scan abort\n"); + IL_DEBUG_SCAN(il, "Successfully send scan abort\n"); } /** * il_scan_cancel - Cancel any currently executing HW scan */ -int il_scan_cancel(struct il_priv *priv) +int il_scan_cancel(struct il_priv *il) { - IL_DEBUG_SCAN(priv, "Queuing abort scan\n"); - queue_work(priv->workqueue, &priv->abort_scan); + IL_DEBUG_SCAN(il, "Queuing abort scan\n"); + queue_work(il->workqueue, &il->abort_scan); return 0; } EXPORT_SYMBOL(il_scan_cancel); @@ -161,28 +161,28 @@ EXPORT_SYMBOL(il_scan_cancel); * @ms: amount of time to wait (in milliseconds) for scan to abort * */ -int il_scan_cancel_timeout(struct il_priv *priv, unsigned long ms) +int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms) { unsigned long timeout = jiffies + msecs_to_jiffies(ms); - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - IL_DEBUG_SCAN(priv, "Scan cancel timeout\n"); + IL_DEBUG_SCAN(il, "Scan cancel timeout\n"); - il_do_scan_abort(priv); + il_do_scan_abort(il); while (time_before_eq(jiffies, timeout)) { - if (!test_bit(STATUS_SCAN_HW, &priv->status)) + if (!test_bit(STATUS_SCAN_HW, &il->status)) break; msleep(20); } - return test_bit(STATUS_SCAN_HW, &priv->status); + return test_bit(STATUS_SCAN_HW, &il->status); } EXPORT_SYMBOL(il_scan_cancel_timeout); /* Service response to REPLY_SCAN_CMD (0x80) */ -static void il_rx_reply_scan(struct il_priv *priv, +static void il_rx_reply_scan(struct il_priv *il, struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG @@ -190,19 +190,19 @@ static void il_rx_reply_scan(struct il_priv *priv, struct il_scanreq_notification *notif = (struct il_scanreq_notification *)pkt->u.raw; - IL_DEBUG_SCAN(priv, "Scan request status = 0x%x\n", notif->status); + IL_DEBUG_SCAN(il, "Scan request status = 0x%x\n", notif->status); #endif } /* Service SCAN_START_NOTIFICATION (0x82) */ -static void il_rx_scan_start_notif(struct il_priv *priv, +static void il_rx_scan_start_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); struct il_scanstart_notification *notif = (struct il_scanstart_notification *)pkt->u.raw; - priv->scan_start_tsf = le32_to_cpu(notif->tsf_low); - IL_DEBUG_SCAN(priv, "Scan start: " + il->scan_start_tsf = le32_to_cpu(notif->tsf_low); + IL_DEBUG_SCAN(il, "Scan start: " "%d [802.11%s] " "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n", notif->channel, @@ -213,7 +213,7 @@ static void il_rx_scan_start_notif(struct il_priv *priv, } /* Service SCAN_RESULTS_NOTIFICATION (0x83) */ -static void il_rx_scan_results_notif(struct il_priv *priv, +static void il_rx_scan_results_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG @@ -221,7 +221,7 @@ static void il_rx_scan_results_notif(struct il_priv *priv, struct il_scanresults_notification *notif = (struct il_scanresults_notification *)pkt->u.raw; - IL_DEBUG_SCAN(priv, "Scan ch.res: " + IL_DEBUG_SCAN(il, "Scan ch.res: " "%d [802.11%s] " "(TSF: 0x%08X:%08X) - %d " "elapsed=%lu usec\n", @@ -230,12 +230,12 @@ static void il_rx_scan_results_notif(struct il_priv *priv, le32_to_cpu(notif->tsf_high), le32_to_cpu(notif->tsf_low), le32_to_cpu(notif->statistics[0]), - le32_to_cpu(notif->tsf_low) - priv->scan_start_tsf); + le32_to_cpu(notif->tsf_low) - il->scan_start_tsf); #endif } /* Service SCAN_COMPLETE_NOTIFICATION (0x84) */ -static void il_rx_scan_complete_notif(struct il_priv *priv, +static void il_rx_scan_complete_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { @@ -244,36 +244,36 @@ static void il_rx_scan_complete_notif(struct il_priv *priv, struct il_scancomplete_notification *scan_notif = (void *)pkt->u.raw; #endif - IL_DEBUG_SCAN(priv, + IL_DEBUG_SCAN(il, "Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n", scan_notif->scanned_channels, scan_notif->tsf_low, scan_notif->tsf_high, scan_notif->status); /* The HW is no longer scanning */ - clear_bit(STATUS_SCAN_HW, &priv->status); + clear_bit(STATUS_SCAN_HW, &il->status); - IL_DEBUG_SCAN(priv, "Scan on %sGHz took %dms\n", - (priv->scan_band == IEEE80211_BAND_2GHZ) ? "2.4" : "5.2", - jiffies_to_msecs(jiffies - priv->scan_start)); + IL_DEBUG_SCAN(il, "Scan on %sGHz took %dms\n", + (il->scan_band == IEEE80211_BAND_2GHZ) ? "2.4" : "5.2", + jiffies_to_msecs(jiffies - il->scan_start)); - queue_work(priv->workqueue, &priv->scan_completed); + queue_work(il->workqueue, &il->scan_completed); } -void il_setup_rx_scan_handlers(struct il_priv *priv) +void il_setup_rx_scan_handlers(struct il_priv *il) { /* scan handlers */ - priv->rx_handlers[REPLY_SCAN_CMD] = il_rx_reply_scan; - priv->rx_handlers[SCAN_START_NOTIFICATION] = + il->rx_handlers[REPLY_SCAN_CMD] = il_rx_reply_scan; + il->rx_handlers[SCAN_START_NOTIFICATION] = il_rx_scan_start_notif; - priv->rx_handlers[SCAN_RESULTS_NOTIFICATION] = + il->rx_handlers[SCAN_RESULTS_NOTIFICATION] = il_rx_scan_results_notif; - priv->rx_handlers[SCAN_COMPLETE_NOTIFICATION] = + il->rx_handlers[SCAN_COMPLETE_NOTIFICATION] = il_rx_scan_complete_notif; } EXPORT_SYMBOL(il_setup_rx_scan_handlers); -inline u16 il_get_active_dwell_time(struct il_priv *priv, +inline u16 il_get_active_dwell_time(struct il_priv *il, enum ieee80211_band band, u8 n_probes) { @@ -286,7 +286,7 @@ inline u16 il_get_active_dwell_time(struct il_priv *priv, } EXPORT_SYMBOL(il_get_active_dwell_time); -u16 il_get_passive_dwell_time(struct il_priv *priv, +u16 il_get_passive_dwell_time(struct il_priv *il, enum ieee80211_band band, struct ieee80211_vif *vif) { @@ -295,13 +295,13 @@ u16 il_get_passive_dwell_time(struct il_priv *priv, IL_PASSIVE_DWELL_BASE + IL_PASSIVE_DWELL_TIME_24 : IL_PASSIVE_DWELL_BASE + IL_PASSIVE_DWELL_TIME_52; - if (il_is_any_associated(priv)) { + if (il_is_any_associated(il)) { /* * If we're associated, we clamp the maximum passive * dwell time to be 98% of the smallest beacon interval * (minus 2 * channel tune time) */ - for_each_context(priv, ctx) { + for_each_context(il, ctx) { u16 value; if (!il_is_associated_ctx(ctx)) @@ -318,56 +318,56 @@ u16 il_get_passive_dwell_time(struct il_priv *priv, } EXPORT_SYMBOL(il_get_passive_dwell_time); -void il_init_scan_params(struct il_priv *priv) +void il_init_scan_params(struct il_priv *il) { - u8 ant_idx = fls(priv->hw_params.valid_tx_ant) - 1; - if (!priv->scan_tx_ant[IEEE80211_BAND_5GHZ]) - priv->scan_tx_ant[IEEE80211_BAND_5GHZ] = ant_idx; - if (!priv->scan_tx_ant[IEEE80211_BAND_2GHZ]) - priv->scan_tx_ant[IEEE80211_BAND_2GHZ] = ant_idx; + u8 ant_idx = fls(il->hw_params.valid_tx_ant) - 1; + if (!il->scan_tx_ant[IEEE80211_BAND_5GHZ]) + il->scan_tx_ant[IEEE80211_BAND_5GHZ] = ant_idx; + if (!il->scan_tx_ant[IEEE80211_BAND_2GHZ]) + il->scan_tx_ant[IEEE80211_BAND_2GHZ] = ant_idx; } EXPORT_SYMBOL(il_init_scan_params); -static int il_scan_initiate(struct il_priv *priv, +static int il_scan_initiate(struct il_priv *il, struct ieee80211_vif *vif) { int ret; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - if (WARN_ON(!priv->cfg->ops->utils->request_scan)) + if (WARN_ON(!il->cfg->ops->utils->request_scan)) return -EOPNOTSUPP; - cancel_delayed_work(&priv->scan_check); + cancel_delayed_work(&il->scan_check); - if (!il_is_ready_rf(priv)) { - IL_WARN(priv, "Request scan called when driver not ready.\n"); + if (!il_is_ready_rf(il)) { + IL_WARN(il, "Request scan called when driver not ready.\n"); return -EIO; } - if (test_bit(STATUS_SCAN_HW, &priv->status)) { - IL_DEBUG_SCAN(priv, + if (test_bit(STATUS_SCAN_HW, &il->status)) { + IL_DEBUG_SCAN(il, "Multiple concurrent scan requests in parallel.\n"); return -EBUSY; } - if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { - IL_DEBUG_SCAN(priv, "Scan request while abort pending.\n"); + if (test_bit(STATUS_SCAN_ABORTING, &il->status)) { + IL_DEBUG_SCAN(il, "Scan request while abort pending.\n"); return -EBUSY; } - IL_DEBUG_SCAN(priv, "Starting scan...\n"); + IL_DEBUG_SCAN(il, "Starting scan...\n"); - set_bit(STATUS_SCANNING, &priv->status); - priv->scan_start = jiffies; + set_bit(STATUS_SCANNING, &il->status); + il->scan_start = jiffies; - ret = priv->cfg->ops->utils->request_scan(priv, vif); + ret = il->cfg->ops->utils->request_scan(il, vif); if (ret) { - clear_bit(STATUS_SCANNING, &priv->status); + clear_bit(STATUS_SCANNING, &il->status); return ret; } - queue_delayed_work(priv->workqueue, &priv->scan_check, + queue_delayed_work(il->workqueue, &il->scan_check, IL_SCAN_CHECK_WATCHDOG); return 0; @@ -377,33 +377,33 @@ int il_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct cfg80211_scan_request *req) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; int ret; - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); if (req->n_channels == 0) return -EINVAL; - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); - if (test_bit(STATUS_SCANNING, &priv->status)) { - IL_DEBUG_SCAN(priv, "Scan already in progress.\n"); + if (test_bit(STATUS_SCANNING, &il->status)) { + IL_DEBUG_SCAN(il, "Scan already in progress.\n"); ret = -EAGAIN; goto out_unlock; } /* mac80211 will only ask for one band at a time */ - priv->scan_request = req; - priv->scan_vif = vif; - priv->scan_band = req->channels[0]->band; + il->scan_request = req; + il->scan_vif = vif; + il->scan_band = req->channels[0]->band; - ret = il_scan_initiate(priv, vif); + ret = il_scan_initiate(il, vif); - IL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(il, "leave\n"); out_unlock: - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); return ret; } @@ -411,17 +411,17 @@ EXPORT_SYMBOL(il_mac_hw_scan); static void il_bg_scan_check(struct work_struct *data) { - struct il_priv *priv = + struct il_priv *il = container_of(data, struct il_priv, scan_check.work); - IL_DEBUG_SCAN(priv, "Scan check work\n"); + IL_DEBUG_SCAN(il, "Scan check work\n"); /* Since we are here firmware does not finish scan and * most likely is in bad shape, so we don't bother to * send abort command, just force scan complete to mac80211 */ - mutex_lock(&priv->mutex); - il_force_scan_end(priv); - mutex_unlock(&priv->mutex); + mutex_lock(&il->mutex); + il_force_scan_end(il); + mutex_unlock(&il->mutex); } /** @@ -429,7 +429,7 @@ static void il_bg_scan_check(struct work_struct *data) */ u16 -il_fill_probe_req(struct il_priv *priv, struct ieee80211_mgmt *frame, +il_fill_probe_req(struct il_priv *il, struct ieee80211_mgmt *frame, const u8 *ta, const u8 *ies, int ie_len, int left) { int len = 0; @@ -475,75 +475,75 @@ EXPORT_SYMBOL(il_fill_probe_req); static void il_bg_abort_scan(struct work_struct *work) { - struct il_priv *priv = container_of(work, struct il_priv, abort_scan); + struct il_priv *il = container_of(work, struct il_priv, abort_scan); - IL_DEBUG_SCAN(priv, "Abort scan work\n"); + IL_DEBUG_SCAN(il, "Abort scan work\n"); /* We keep scan_check work queued in case when firmware will not * report back scan completed notification */ - mutex_lock(&priv->mutex); - il_scan_cancel_timeout(priv, 200); - mutex_unlock(&priv->mutex); + mutex_lock(&il->mutex); + il_scan_cancel_timeout(il, 200); + mutex_unlock(&il->mutex); } static void il_bg_scan_completed(struct work_struct *work) { - struct il_priv *priv = + struct il_priv *il = container_of(work, struct il_priv, scan_completed); bool aborted; - IL_DEBUG_SCAN(priv, "Completed scan.\n"); + IL_DEBUG_SCAN(il, "Completed scan.\n"); - cancel_delayed_work(&priv->scan_check); + cancel_delayed_work(&il->scan_check); - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); - aborted = test_and_clear_bit(STATUS_SCAN_ABORTING, &priv->status); + aborted = test_and_clear_bit(STATUS_SCAN_ABORTING, &il->status); if (aborted) - IL_DEBUG_SCAN(priv, "Aborted scan completed.\n"); + IL_DEBUG_SCAN(il, "Aborted scan completed.\n"); - if (!test_and_clear_bit(STATUS_SCANNING, &priv->status)) { - IL_DEBUG_SCAN(priv, "Scan already completed.\n"); + if (!test_and_clear_bit(STATUS_SCANNING, &il->status)) { + IL_DEBUG_SCAN(il, "Scan already completed.\n"); goto out_settings; } - il_complete_scan(priv, aborted); + il_complete_scan(il, aborted); out_settings: /* Can we still talk to firmware ? */ - if (!il_is_ready_rf(priv)) + if (!il_is_ready_rf(il)) goto out; /* * We do not commit power settings while scan is pending, * do it now if the settings changed. */ - il_power_set_mode(priv, &priv->power_data.sleep_cmd_next, false); - il_set_tx_power(priv, priv->tx_power_next, false); + il_power_set_mode(il, &il->power_data.sleep_cmd_next, false); + il_set_tx_power(il, il->tx_power_next, false); - priv->cfg->ops->utils->post_scan(priv); + il->cfg->ops->utils->post_scan(il); out: - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); } -void il_setup_scan_deferred_work(struct il_priv *priv) +void il_setup_scan_deferred_work(struct il_priv *il) { - INIT_WORK(&priv->scan_completed, il_bg_scan_completed); - INIT_WORK(&priv->abort_scan, il_bg_abort_scan); - INIT_DELAYED_WORK(&priv->scan_check, il_bg_scan_check); + INIT_WORK(&il->scan_completed, il_bg_scan_completed); + INIT_WORK(&il->abort_scan, il_bg_abort_scan); + INIT_DELAYED_WORK(&il->scan_check, il_bg_scan_check); } EXPORT_SYMBOL(il_setup_scan_deferred_work); -void il_cancel_scan_deferred_work(struct il_priv *priv) +void il_cancel_scan_deferred_work(struct il_priv *il) { - cancel_work_sync(&priv->abort_scan); - cancel_work_sync(&priv->scan_completed); + cancel_work_sync(&il->abort_scan); + cancel_work_sync(&il->scan_completed); - if (cancel_delayed_work_sync(&priv->scan_check)) { - mutex_lock(&priv->mutex); - il_force_scan_end(priv); - mutex_unlock(&priv->mutex); + if (cancel_delayed_work_sync(&il->scan_check)) { + mutex_lock(&il->mutex); + il_force_scan_end(il); + mutex_unlock(&il->mutex); } } EXPORT_SYMBOL(il_cancel_scan_deferred_work); diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.c b/drivers/net/wireless/iwlegacy/iwl-sta.c index 3773f7d64d2a..7d66e79f5d3e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-sta.c @@ -36,28 +36,28 @@ #include "iwl-core.h" #include "iwl-sta.h" -/* priv->sta_lock must be held */ -static void il_sta_ucode_activate(struct il_priv *priv, u8 sta_id) +/* il->sta_lock must be held */ +static void il_sta_ucode_activate(struct il_priv *il, u8 sta_id) { - if (!(priv->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) - IL_ERR(priv, + if (!(il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) + IL_ERR(il, "ACTIVATE a non DRIVER active station id %u addr %pM\n", - sta_id, priv->stations[sta_id].sta.sta.addr); + sta_id, il->stations[sta_id].sta.sta.addr); - if (priv->stations[sta_id].used & IL_STA_UCODE_ACTIVE) { - IL_DEBUG_ASSOC(priv, + if (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE) { + IL_DEBUG_ASSOC(il, "STA id %u addr %pM already present" " in uCode (according to driver)\n", - sta_id, priv->stations[sta_id].sta.sta.addr); + sta_id, il->stations[sta_id].sta.sta.addr); } else { - priv->stations[sta_id].used |= IL_STA_UCODE_ACTIVE; - IL_DEBUG_ASSOC(priv, "Added STA id %u addr %pM to uCode\n", - sta_id, priv->stations[sta_id].sta.sta.addr); + il->stations[sta_id].used |= IL_STA_UCODE_ACTIVE; + IL_DEBUG_ASSOC(il, "Added STA id %u addr %pM to uCode\n", + sta_id, il->stations[sta_id].sta.sta.addr); } } -static int il_process_add_sta_resp(struct il_priv *priv, +static int il_process_add_sta_resp(struct il_priv *il, struct il_addsta_cmd *addsta, struct il_rx_packet *pkt, bool sync) @@ -67,45 +67,45 @@ static int il_process_add_sta_resp(struct il_priv *priv, int ret = -EIO; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR(priv, "Bad return from REPLY_ADD_STA (0x%08X)\n", + IL_ERR(il, "Bad return from REPLY_ADD_STA (0x%08X)\n", pkt->hdr.flags); return ret; } - IL_DEBUG_INFO(priv, "Processing response for adding station %u\n", + IL_DEBUG_INFO(il, "Processing response for adding station %u\n", sta_id); - spin_lock_irqsave(&priv->sta_lock, flags); + spin_lock_irqsave(&il->sta_lock, flags); switch (pkt->u.add_sta.status) { case ADD_STA_SUCCESS_MSK: - IL_DEBUG_INFO(priv, "REPLY_ADD_STA PASSED\n"); - il_sta_ucode_activate(priv, sta_id); + IL_DEBUG_INFO(il, "REPLY_ADD_STA PASSED\n"); + il_sta_ucode_activate(il, sta_id); ret = 0; break; case ADD_STA_NO_ROOM_IN_TABLE: - IL_ERR(priv, "Adding station %d failed, no room in table.\n", + IL_ERR(il, "Adding station %d failed, no room in table.\n", sta_id); break; case ADD_STA_NO_BLOCK_ACK_RESOURCE: - IL_ERR(priv, + IL_ERR(il, "Adding station %d failed, no block ack resource.\n", sta_id); break; case ADD_STA_MODIFY_NON_EXIST_STA: - IL_ERR(priv, "Attempting to modify non-existing station %d\n", + IL_ERR(il, "Attempting to modify non-existing station %d\n", sta_id); break; default: - IL_DEBUG_ASSOC(priv, "Received REPLY_ADD_STA:(0x%08X)\n", + IL_DEBUG_ASSOC(il, "Received REPLY_ADD_STA:(0x%08X)\n", pkt->u.add_sta.status); break; } - IL_DEBUG_INFO(priv, "%s station id %u addr %pM\n", - priv->stations[sta_id].sta.mode == + IL_DEBUG_INFO(il, "%s station id %u addr %pM\n", + il->stations[sta_id].sta.mode == STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", - sta_id, priv->stations[sta_id].sta.sta.addr); + sta_id, il->stations[sta_id].sta.sta.addr); /* * XXX: The MAC address in the command buffer is often changed from @@ -115,27 +115,27 @@ static int il_process_add_sta_resp(struct il_priv *priv, * issue has not yet been resolved and this debugging is left to * observe the problem. */ - IL_DEBUG_INFO(priv, "%s station according to cmd buffer %pM\n", - priv->stations[sta_id].sta.mode == + IL_DEBUG_INFO(il, "%s station according to cmd buffer %pM\n", + il->stations[sta_id].sta.mode == STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", addsta->sta.addr); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); return ret; } -static void il_add_sta_callback(struct il_priv *priv, +static void il_add_sta_callback(struct il_priv *il, struct il_device_cmd *cmd, struct il_rx_packet *pkt) { struct il_addsta_cmd *addsta = (struct il_addsta_cmd *)cmd->cmd.payload; - il_process_add_sta_resp(priv, addsta, pkt, false); + il_process_add_sta_resp(il, addsta, pkt, false); } -int il_send_add_sta(struct il_priv *priv, +int il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags) { struct il_rx_packet *pkt = NULL; @@ -148,7 +148,7 @@ int il_send_add_sta(struct il_priv *priv, }; u8 sta_id __maybe_unused = sta->sta.sta_id; - IL_DEBUG_INFO(priv, "Adding sta %u (%pM) %ssynchronously\n", + IL_DEBUG_INFO(il, "Adding sta %u (%pM) %ssynchronously\n", sta_id, sta->sta.addr, flags & CMD_ASYNC ? "a" : ""); if (flags & CMD_ASYNC) @@ -158,23 +158,23 @@ int il_send_add_sta(struct il_priv *priv, might_sleep(); } - cmd.len = priv->cfg->ops->utils->build_addsta_hcmd(sta, data); - ret = il_send_cmd(priv, &cmd); + cmd.len = il->cfg->ops->utils->build_addsta_hcmd(sta, data); + ret = il_send_cmd(il, &cmd); if (ret || (flags & CMD_ASYNC)) return ret; if (ret == 0) { pkt = (struct il_rx_packet *)cmd.reply_page; - ret = il_process_add_sta_resp(priv, sta, pkt, true); + ret = il_process_add_sta_resp(il, sta, pkt, true); } - il_free_pages(priv, cmd.reply_page); + il_free_pages(il, cmd.reply_page); return ret; } EXPORT_SYMBOL(il_send_add_sta); -static void il_set_ht_add_station(struct il_priv *priv, u8 index, +static void il_set_ht_add_station(struct il_priv *il, u8 index, struct ieee80211_sta *sta, struct il_rxon_context *ctx) { @@ -186,13 +186,13 @@ static void il_set_ht_add_station(struct il_priv *priv, u8 index, goto done; mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_SM_PS) >> 2; - IL_DEBUG_ASSOC(priv, "spatial multiplexing power save mode: %s\n", + IL_DEBUG_ASSOC(il, "spatial multiplexing power save mode: %s\n", (mimo_ps_mode == WLAN_HT_CAP_SM_PS_STATIC) ? "static" : (mimo_ps_mode == WLAN_HT_CAP_SM_PS_DYNAMIC) ? "dynamic" : "disabled"); - sta_flags = priv->stations[index].sta.station_flags; + sta_flags = il->stations[index].sta.station_flags; sta_flags &= ~(STA_FLG_RTS_MIMO_PROT_MSK | STA_FLG_MIMO_DIS_MSK); @@ -206,7 +206,7 @@ static void il_set_ht_add_station(struct il_priv *priv, u8 index, case WLAN_HT_CAP_SM_PS_DISABLED: break; default: - IL_WARN(priv, "Invalid MIMO PS mode %d\n", mimo_ps_mode); + IL_WARN(il, "Invalid MIMO PS mode %d\n", mimo_ps_mode); break; } @@ -216,12 +216,12 @@ static void il_set_ht_add_station(struct il_priv *priv, u8 index, sta_flags |= cpu_to_le32( (u32)sta_ht_inf->ampdu_density << STA_FLG_AGG_MPDU_DENSITY_POS); - if (il_is_ht40_tx_allowed(priv, ctx, &sta->ht_cap)) + if (il_is_ht40_tx_allowed(il, ctx, &sta->ht_cap)) sta_flags |= STA_FLG_HT40_EN_MSK; else sta_flags &= ~STA_FLG_HT40_EN_MSK; - priv->stations[index].sta.station_flags = sta_flags; + il->stations[index].sta.station_flags = sta_flags; done: return; } @@ -231,7 +231,7 @@ static void il_set_ht_add_station(struct il_priv *priv, u8 index, * * should be called with sta_lock held */ -u8 il_prep_station(struct il_priv *priv, struct il_rxon_context *ctx, +u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, const u8 *addr, bool is_ap, struct ieee80211_sta *sta) { struct il_station_entry *station; @@ -244,14 +244,14 @@ u8 il_prep_station(struct il_priv *priv, struct il_rxon_context *ctx, else if (is_broadcast_ether_addr(addr)) sta_id = ctx->bcast_sta_id; else - for (i = IL_STA_ID; i < priv->hw_params.max_stations; i++) { - if (!compare_ether_addr(priv->stations[i].sta.sta.addr, + for (i = IL_STA_ID; i < il->hw_params.max_stations; i++) { + if (!compare_ether_addr(il->stations[i].sta.sta.addr, addr)) { sta_id = i; break; } - if (!priv->stations[i].used && + if (!il->stations[i].used && sta_id == IL_INVALID_STATION) sta_id = i; } @@ -268,27 +268,27 @@ u8 il_prep_station(struct il_priv *priv, struct il_rxon_context *ctx, * station. Keep track if one is in progress so that we do not send * another. */ - if (priv->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { - IL_DEBUG_INFO(priv, + if (il->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { + IL_DEBUG_INFO(il, "STA %d already in process of being added.\n", sta_id); return sta_id; } - if ((priv->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && - (priv->stations[sta_id].used & IL_STA_UCODE_ACTIVE) && - !compare_ether_addr(priv->stations[sta_id].sta.sta.addr, addr)) { - IL_DEBUG_ASSOC(priv, + if ((il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && + (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE) && + !compare_ether_addr(il->stations[sta_id].sta.sta.addr, addr)) { + IL_DEBUG_ASSOC(il, "STA %d (%pM) already added, not adding again.\n", sta_id, addr); return sta_id; } - station = &priv->stations[sta_id]; + station = &il->stations[sta_id]; station->used = IL_STA_DRIVER_ACTIVE; - IL_DEBUG_ASSOC(priv, "Add STA to driver ID %d: %pM\n", + IL_DEBUG_ASSOC(il, "Add STA to driver ID %d: %pM\n", sta_id, addr); - priv->num_stations++; + il->num_stations++; /* Set up the REPLY_ADD_STA command to send to device */ memset(&station->sta, 0, sizeof(struct il_addsta_cmd)); @@ -310,10 +310,10 @@ u8 il_prep_station(struct il_priv *priv, struct il_rxon_context *ctx, * STA and broadcast STA) pass in a NULL sta, and mac80211 * doesn't allow HT IBSS. */ - il_set_ht_add_station(priv, sta_id, sta, ctx); + il_set_ht_add_station(il, sta_id, sta, ctx); /* 3945 only */ - rate = (priv->band == IEEE80211_BAND_5GHZ) ? + rate = (il->band == IEEE80211_BAND_5GHZ) ? IL_RATE_6M_PLCP : IL_RATE_1M_PLCP; /* Turn on both antennas for the station... */ station->sta.rate_n_flags = cpu_to_le16(rate | RATE_MCS_ANT_AB_MSK); @@ -329,7 +329,7 @@ EXPORT_SYMBOL_GPL(il_prep_station); * il_add_station_common - */ int -il_add_station_common(struct il_priv *priv, +il_add_station_common(struct il_priv *il, struct il_rxon_context *ctx, const u8 *addr, bool is_ap, struct ieee80211_sta *sta, u8 *sta_id_r) @@ -340,12 +340,12 @@ il_add_station_common(struct il_priv *priv, struct il_addsta_cmd sta_cmd; *sta_id_r = 0; - spin_lock_irqsave(&priv->sta_lock, flags_spin); - sta_id = il_prep_station(priv, ctx, addr, is_ap, sta); + spin_lock_irqsave(&il->sta_lock, flags_spin); + sta_id = il_prep_station(il, ctx, addr, is_ap, sta); if (sta_id == IL_INVALID_STATION) { - IL_ERR(priv, "Unable to prepare station %pM for addition\n", + IL_ERR(il, "Unable to prepare station %pM for addition\n", addr); - spin_unlock_irqrestore(&priv->sta_lock, flags_spin); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); return -EINVAL; } @@ -354,37 +354,37 @@ il_add_station_common(struct il_priv *priv, * station. Keep track if one is in progress so that we do not send * another. */ - if (priv->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { - IL_DEBUG_INFO(priv, + if (il->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { + IL_DEBUG_INFO(il, "STA %d already in process of being added.\n", sta_id); - spin_unlock_irqrestore(&priv->sta_lock, flags_spin); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); return -EEXIST; } - if ((priv->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && - (priv->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { - IL_DEBUG_ASSOC(priv, + if ((il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && + (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { + IL_DEBUG_ASSOC(il, "STA %d (%pM) already added, not adding again.\n", sta_id, addr); - spin_unlock_irqrestore(&priv->sta_lock, flags_spin); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); return -EEXIST; } - priv->stations[sta_id].used |= IL_STA_UCODE_INPROGRESS; - memcpy(&sta_cmd, &priv->stations[sta_id].sta, + il->stations[sta_id].used |= IL_STA_UCODE_INPROGRESS; + memcpy(&sta_cmd, &il->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&priv->sta_lock, flags_spin); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); /* Add station to device's station table */ - ret = il_send_add_sta(priv, &sta_cmd, CMD_SYNC); + ret = il_send_add_sta(il, &sta_cmd, CMD_SYNC); if (ret) { - spin_lock_irqsave(&priv->sta_lock, flags_spin); - IL_ERR(priv, "Adding station %pM failed.\n", - priv->stations[sta_id].sta.sta.addr); - priv->stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE; - priv->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; - spin_unlock_irqrestore(&priv->sta_lock, flags_spin); + spin_lock_irqsave(&il->sta_lock, flags_spin); + IL_ERR(il, "Adding station %pM failed.\n", + il->stations[sta_id].sta.sta.addr); + il->stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE; + il->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; + spin_unlock_irqrestore(&il->sta_lock, flags_spin); } *sta_id_r = sta_id; return ret; @@ -394,23 +394,23 @@ EXPORT_SYMBOL(il_add_station_common); /** * il_sta_ucode_deactivate - deactivate ucode status for a station * - * priv->sta_lock must be held + * il->sta_lock must be held */ -static void il_sta_ucode_deactivate(struct il_priv *priv, u8 sta_id) +static void il_sta_ucode_deactivate(struct il_priv *il, u8 sta_id) { /* Ucode must be active and driver must be non active */ - if ((priv->stations[sta_id].used & + if ((il->stations[sta_id].used & (IL_STA_UCODE_ACTIVE | IL_STA_DRIVER_ACTIVE)) != IL_STA_UCODE_ACTIVE) - IL_ERR(priv, "removed non active STA %u\n", sta_id); + IL_ERR(il, "removed non active STA %u\n", sta_id); - priv->stations[sta_id].used &= ~IL_STA_UCODE_ACTIVE; + il->stations[sta_id].used &= ~IL_STA_UCODE_ACTIVE; - memset(&priv->stations[sta_id], 0, sizeof(struct il_station_entry)); - IL_DEBUG_ASSOC(priv, "Removed STA %u\n", sta_id); + memset(&il->stations[sta_id], 0, sizeof(struct il_station_entry)); + IL_DEBUG_ASSOC(il, "Removed STA %u\n", sta_id); } -static int il_send_remove_station(struct il_priv *priv, +static int il_send_remove_station(struct il_priv *il, const u8 *addr, int sta_id, bool temporary) { @@ -433,14 +433,14 @@ static int il_send_remove_station(struct il_priv *priv, cmd.flags |= CMD_WANT_SKB; - ret = il_send_cmd(priv, &cmd); + ret = il_send_cmd(il, &cmd); if (ret) return ret; pkt = (struct il_rx_packet *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR(priv, "Bad return from REPLY_REMOVE_STA (0x%08X)\n", + IL_ERR(il, "Bad return from REPLY_REMOVE_STA (0x%08X)\n", pkt->hdr.flags); ret = -EIO; } @@ -449,20 +449,20 @@ static int il_send_remove_station(struct il_priv *priv, switch (pkt->u.rem_sta.status) { case REM_STA_SUCCESS_MSK: if (!temporary) { - spin_lock_irqsave(&priv->sta_lock, flags_spin); - il_sta_ucode_deactivate(priv, sta_id); - spin_unlock_irqrestore(&priv->sta_lock, + spin_lock_irqsave(&il->sta_lock, flags_spin); + il_sta_ucode_deactivate(il, sta_id); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); } - IL_DEBUG_ASSOC(priv, "REPLY_REMOVE_STA PASSED\n"); + IL_DEBUG_ASSOC(il, "REPLY_REMOVE_STA PASSED\n"); break; default: ret = -EIO; - IL_ERR(priv, "REPLY_REMOVE_STA failed\n"); + IL_ERR(il, "REPLY_REMOVE_STA failed\n"); break; } } - il_free_pages(priv, cmd.reply_page); + il_free_pages(il, cmd.reply_page); return ret; } @@ -470,13 +470,13 @@ static int il_send_remove_station(struct il_priv *priv, /** * il_remove_station - Remove driver's knowledge of station. */ -int il_remove_station(struct il_priv *priv, const u8 sta_id, +int il_remove_station(struct il_priv *il, const u8 sta_id, const u8 *addr) { unsigned long flags; - if (!il_is_ready(priv)) { - IL_DEBUG_INFO(priv, + if (!il_is_ready(il)) { + IL_DEBUG_INFO(il, "Unable to remove station %pM, device not ready.\n", addr); /* @@ -487,42 +487,42 @@ int il_remove_station(struct il_priv *priv, const u8 sta_id, return 0; } - IL_DEBUG_ASSOC(priv, "Removing STA from driver:%d %pM\n", + IL_DEBUG_ASSOC(il, "Removing STA from driver:%d %pM\n", sta_id, addr); if (WARN_ON(sta_id == IL_INVALID_STATION)) return -EINVAL; - spin_lock_irqsave(&priv->sta_lock, flags); + spin_lock_irqsave(&il->sta_lock, flags); - if (!(priv->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) { - IL_DEBUG_INFO(priv, "Removing %pM but non DRIVER active\n", + if (!(il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) { + IL_DEBUG_INFO(il, "Removing %pM but non DRIVER active\n", addr); goto out_err; } - if (!(priv->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { - IL_DEBUG_INFO(priv, "Removing %pM but non UCODE active\n", + if (!(il->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { + IL_DEBUG_INFO(il, "Removing %pM but non UCODE active\n", addr); goto out_err; } - if (priv->stations[sta_id].used & IL_STA_LOCAL) { - kfree(priv->stations[sta_id].lq); - priv->stations[sta_id].lq = NULL; + if (il->stations[sta_id].used & IL_STA_LOCAL) { + kfree(il->stations[sta_id].lq); + il->stations[sta_id].lq = NULL; } - priv->stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE; + il->stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE; - priv->num_stations--; + il->num_stations--; - BUG_ON(priv->num_stations < 0); + BUG_ON(il->num_stations < 0); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); - return il_send_remove_station(priv, addr, sta_id, false); + return il_send_remove_station(il, addr, sta_id, false); out_err: - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); return -EINVAL; } EXPORT_SYMBOL_GPL(il_remove_station); @@ -535,31 +535,31 @@ EXPORT_SYMBOL_GPL(il_remove_station); * other than explicit station management would cause this in * the ucode, e.g. unassociated RXON. */ -void il_clear_ucode_stations(struct il_priv *priv, +void il_clear_ucode_stations(struct il_priv *il, struct il_rxon_context *ctx) { int i; unsigned long flags_spin; bool cleared = false; - IL_DEBUG_INFO(priv, "Clearing ucode stations in driver\n"); + IL_DEBUG_INFO(il, "Clearing ucode stations in driver\n"); - spin_lock_irqsave(&priv->sta_lock, flags_spin); - for (i = 0; i < priv->hw_params.max_stations; i++) { - if (ctx && ctx->ctxid != priv->stations[i].ctxid) + spin_lock_irqsave(&il->sta_lock, flags_spin); + for (i = 0; i < il->hw_params.max_stations; i++) { + if (ctx && ctx->ctxid != il->stations[i].ctxid) continue; - if (priv->stations[i].used & IL_STA_UCODE_ACTIVE) { - IL_DEBUG_INFO(priv, + if (il->stations[i].used & IL_STA_UCODE_ACTIVE) { + IL_DEBUG_INFO(il, "Clearing ucode active for station %d\n", i); - priv->stations[i].used &= ~IL_STA_UCODE_ACTIVE; + il->stations[i].used &= ~IL_STA_UCODE_ACTIVE; cleared = true; } } - spin_unlock_irqrestore(&priv->sta_lock, flags_spin); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); if (!cleared) - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "No active stations found to be cleared\n"); } EXPORT_SYMBOL(il_clear_ucode_stations); @@ -573,7 +573,7 @@ EXPORT_SYMBOL(il_clear_ucode_stations); * Function sleeps. */ void -il_restore_stations(struct il_priv *priv, struct il_rxon_context *ctx) +il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) { struct il_addsta_cmd sta_cmd; struct il_link_quality_cmd lq; @@ -583,48 +583,48 @@ il_restore_stations(struct il_priv *priv, struct il_rxon_context *ctx) int ret; bool send_lq; - if (!il_is_ready(priv)) { - IL_DEBUG_INFO(priv, + if (!il_is_ready(il)) { + IL_DEBUG_INFO(il, "Not ready yet, not restoring any stations.\n"); return; } - IL_DEBUG_ASSOC(priv, "Restoring all known stations ... start.\n"); - spin_lock_irqsave(&priv->sta_lock, flags_spin); - for (i = 0; i < priv->hw_params.max_stations; i++) { - if (ctx->ctxid != priv->stations[i].ctxid) + IL_DEBUG_ASSOC(il, "Restoring all known stations ... start.\n"); + spin_lock_irqsave(&il->sta_lock, flags_spin); + for (i = 0; i < il->hw_params.max_stations; i++) { + if (ctx->ctxid != il->stations[i].ctxid) continue; - if ((priv->stations[i].used & IL_STA_DRIVER_ACTIVE) && - !(priv->stations[i].used & IL_STA_UCODE_ACTIVE)) { - IL_DEBUG_ASSOC(priv, "Restoring sta %pM\n", - priv->stations[i].sta.sta.addr); - priv->stations[i].sta.mode = 0; - priv->stations[i].used |= IL_STA_UCODE_INPROGRESS; + if ((il->stations[i].used & IL_STA_DRIVER_ACTIVE) && + !(il->stations[i].used & IL_STA_UCODE_ACTIVE)) { + IL_DEBUG_ASSOC(il, "Restoring sta %pM\n", + il->stations[i].sta.sta.addr); + il->stations[i].sta.mode = 0; + il->stations[i].used |= IL_STA_UCODE_INPROGRESS; found = true; } } - for (i = 0; i < priv->hw_params.max_stations; i++) { - if ((priv->stations[i].used & IL_STA_UCODE_INPROGRESS)) { - memcpy(&sta_cmd, &priv->stations[i].sta, + for (i = 0; i < il->hw_params.max_stations; i++) { + if ((il->stations[i].used & IL_STA_UCODE_INPROGRESS)) { + memcpy(&sta_cmd, &il->stations[i].sta, sizeof(struct il_addsta_cmd)); send_lq = false; - if (priv->stations[i].lq) { - memcpy(&lq, priv->stations[i].lq, + if (il->stations[i].lq) { + memcpy(&lq, il->stations[i].lq, sizeof(struct il_link_quality_cmd)); send_lq = true; } - spin_unlock_irqrestore(&priv->sta_lock, flags_spin); - ret = il_send_add_sta(priv, &sta_cmd, CMD_SYNC); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + ret = il_send_add_sta(il, &sta_cmd, CMD_SYNC); if (ret) { - spin_lock_irqsave(&priv->sta_lock, flags_spin); - IL_ERR(priv, "Adding station %pM failed.\n", - priv->stations[i].sta.sta.addr); - priv->stations[i].used &= + spin_lock_irqsave(&il->sta_lock, flags_spin); + IL_ERR(il, "Adding station %pM failed.\n", + il->stations[i].sta.sta.addr); + il->stations[i].used &= ~IL_STA_DRIVER_ACTIVE; - priv->stations[i].used &= + il->stations[i].used &= ~IL_STA_UCODE_INPROGRESS; - spin_unlock_irqrestore(&priv->sta_lock, + spin_unlock_irqrestore(&il->sta_lock, flags_spin); } /* @@ -632,71 +632,71 @@ il_restore_stations(struct il_priv *priv, struct il_rxon_context *ctx) * current LQ command */ if (send_lq) - il_send_lq_cmd(priv, ctx, &lq, + il_send_lq_cmd(il, ctx, &lq, CMD_SYNC, true); - spin_lock_irqsave(&priv->sta_lock, flags_spin); - priv->stations[i].used &= ~IL_STA_UCODE_INPROGRESS; + spin_lock_irqsave(&il->sta_lock, flags_spin); + il->stations[i].used &= ~IL_STA_UCODE_INPROGRESS; } } - spin_unlock_irqrestore(&priv->sta_lock, flags_spin); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); if (!found) - IL_DEBUG_INFO(priv, "Restoring all known stations" + IL_DEBUG_INFO(il, "Restoring all known stations" " .... no stations to be restored.\n"); else - IL_DEBUG_INFO(priv, "Restoring all known stations" + IL_DEBUG_INFO(il, "Restoring all known stations" " .... complete.\n"); } EXPORT_SYMBOL(il_restore_stations); -int il_get_free_ucode_key_index(struct il_priv *priv) +int il_get_free_ucode_key_index(struct il_priv *il) { int i; - for (i = 0; i < priv->sta_key_max_num; i++) - if (!test_and_set_bit(i, &priv->ucode_key_table)) + for (i = 0; i < il->sta_key_max_num; i++) + if (!test_and_set_bit(i, &il->ucode_key_table)) return i; return WEP_INVALID_OFFSET; } EXPORT_SYMBOL(il_get_free_ucode_key_index); -void il_dealloc_bcast_stations(struct il_priv *priv) +void il_dealloc_bcast_stations(struct il_priv *il) { unsigned long flags; int i; - spin_lock_irqsave(&priv->sta_lock, flags); - for (i = 0; i < priv->hw_params.max_stations; i++) { - if (!(priv->stations[i].used & IL_STA_BCAST)) + spin_lock_irqsave(&il->sta_lock, flags); + for (i = 0; i < il->hw_params.max_stations; i++) { + if (!(il->stations[i].used & IL_STA_BCAST)) continue; - priv->stations[i].used &= ~IL_STA_UCODE_ACTIVE; - priv->num_stations--; - BUG_ON(priv->num_stations < 0); - kfree(priv->stations[i].lq); - priv->stations[i].lq = NULL; + il->stations[i].used &= ~IL_STA_UCODE_ACTIVE; + il->num_stations--; + BUG_ON(il->num_stations < 0); + kfree(il->stations[i].lq); + il->stations[i].lq = NULL; } - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); } EXPORT_SYMBOL_GPL(il_dealloc_bcast_stations); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static void il_dump_lq_cmd(struct il_priv *priv, +static void il_dump_lq_cmd(struct il_priv *il, struct il_link_quality_cmd *lq) { int i; - IL_DEBUG_RATE(priv, "lq station id 0x%x\n", lq->sta_id); - IL_DEBUG_RATE(priv, "lq ant 0x%X 0x%X\n", + IL_DEBUG_RATE(il, "lq station id 0x%x\n", lq->sta_id); + IL_DEBUG_RATE(il, "lq ant 0x%X 0x%X\n", lq->general_params.single_stream_ant_msk, lq->general_params.dual_stream_ant_msk); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) - IL_DEBUG_RATE(priv, "lq index %d 0x%X\n", + IL_DEBUG_RATE(il, "lq index %d 0x%X\n", i, lq->rs_table[i].rate_n_flags); } #else -static inline void il_dump_lq_cmd(struct il_priv *priv, +static inline void il_dump_lq_cmd(struct il_priv *il, struct il_link_quality_cmd *lq) { } @@ -713,7 +713,7 @@ static inline void il_dump_lq_cmd(struct il_priv *priv, * Test for this to prevent driver from sending LQ command between the time * RXON flags are updated and when LQ command is updated. */ -static bool il_is_lq_table_valid(struct il_priv *priv, +static bool il_is_lq_table_valid(struct il_priv *il, struct il_rxon_context *ctx, struct il_link_quality_cmd *lq) { @@ -722,12 +722,12 @@ static bool il_is_lq_table_valid(struct il_priv *priv, if (ctx->ht.enabled) return true; - IL_DEBUG_INFO(priv, "Channel %u is not an HT channel\n", + IL_DEBUG_INFO(il, "Channel %u is not an HT channel\n", ctx->active.channel); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { if (le32_to_cpu(lq->rs_table[i].rate_n_flags) & RATE_MCS_HT_MSK) { - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "index %d of LQ expects HT channel\n", i); return false; @@ -746,7 +746,7 @@ static bool il_is_lq_table_valid(struct il_priv *priv, * this case to clear the state indicating that station creation is in * progress. */ -int il_send_lq_cmd(struct il_priv *priv, struct il_rxon_context *ctx, +int il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, struct il_link_quality_cmd *lq, u8 flags, bool init) { int ret = 0; @@ -763,18 +763,18 @@ int il_send_lq_cmd(struct il_priv *priv, struct il_rxon_context *ctx, return -EINVAL; - spin_lock_irqsave(&priv->sta_lock, flags_spin); - if (!(priv->stations[lq->sta_id].used & IL_STA_DRIVER_ACTIVE)) { - spin_unlock_irqrestore(&priv->sta_lock, flags_spin); + spin_lock_irqsave(&il->sta_lock, flags_spin); + if (!(il->stations[lq->sta_id].used & IL_STA_DRIVER_ACTIVE)) { + spin_unlock_irqrestore(&il->sta_lock, flags_spin); return -EINVAL; } - spin_unlock_irqrestore(&priv->sta_lock, flags_spin); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); - il_dump_lq_cmd(priv, lq); + il_dump_lq_cmd(il, lq); BUG_ON(init && (cmd.flags & CMD_ASYNC)); - if (il_is_lq_table_valid(priv, ctx, lq)) - ret = il_send_cmd(priv, &cmd); + if (il_is_lq_table_valid(il, ctx, lq)) + ret = il_send_cmd(il, &cmd); else ret = -EINVAL; @@ -782,12 +782,12 @@ int il_send_lq_cmd(struct il_priv *priv, struct il_rxon_context *ctx, return ret; if (init) { - IL_DEBUG_INFO(priv, "init LQ command complete," + IL_DEBUG_INFO(il, "init LQ command complete," " clearing sta addition status for sta %d\n", lq->sta_id); - spin_lock_irqsave(&priv->sta_lock, flags_spin); - priv->stations[lq->sta_id].used &= ~IL_STA_UCODE_INPROGRESS; - spin_unlock_irqrestore(&priv->sta_lock, flags_spin); + spin_lock_irqsave(&il->sta_lock, flags_spin); + il->stations[lq->sta_id].used &= ~IL_STA_UCODE_INPROGRESS; + spin_unlock_irqrestore(&il->sta_lock, flags_spin); } return ret; } @@ -797,20 +797,20 @@ int il_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; struct il_station_priv_common *sta_common = (void *)sta->drv_priv; int ret; - IL_DEBUG_INFO(priv, "received request to remove station %pM\n", + IL_DEBUG_INFO(il, "received request to remove station %pM\n", sta->addr); - mutex_lock(&priv->mutex); - IL_DEBUG_INFO(priv, "proceeding to remove station %pM\n", + mutex_lock(&il->mutex); + IL_DEBUG_INFO(il, "proceeding to remove station %pM\n", sta->addr); - ret = il_remove_station(priv, sta_common->sta_id, sta->addr); + ret = il_remove_station(il, sta_common->sta_id, sta->addr); if (ret) - IL_ERR(priv, "Error removing station %pM\n", + IL_ERR(il, "Error removing station %pM\n", sta->addr); - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); return ret; } EXPORT_SYMBOL(il_mac_sta_remove); diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.h b/drivers/net/wireless/iwlegacy/iwl-sta.h index 555b0602cea0..77cdfd4a6674 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.h +++ b/drivers/net/wireless/iwlegacy/iwl-sta.h @@ -43,56 +43,56 @@ #define IL_STA_BCAST BIT(4) /* this station is the special bcast station */ -void il_restore_stations(struct il_priv *priv, +void il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx); -void il_clear_ucode_stations(struct il_priv *priv, +void il_clear_ucode_stations(struct il_priv *il, struct il_rxon_context *ctx); -void il_dealloc_bcast_stations(struct il_priv *priv); -int il_get_free_ucode_key_index(struct il_priv *priv); -int il_send_add_sta(struct il_priv *priv, +void il_dealloc_bcast_stations(struct il_priv *il); +int il_get_free_ucode_key_index(struct il_priv *il); +int il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags); -int il_add_station_common(struct il_priv *priv, +int il_add_station_common(struct il_priv *il, struct il_rxon_context *ctx, const u8 *addr, bool is_ap, struct ieee80211_sta *sta, u8 *sta_id_r); -int il_remove_station(struct il_priv *priv, +int il_remove_station(struct il_priv *il, const u8 sta_id, const u8 *addr); int il_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta); -u8 il_prep_station(struct il_priv *priv, +u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, const u8 *addr, bool is_ap, struct ieee80211_sta *sta); -int il_send_lq_cmd(struct il_priv *priv, +int il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, struct il_link_quality_cmd *lq, u8 flags, bool init); /** * il_clear_driver_stations - clear knowledge of all stations from driver - * @priv: iwl priv struct + * @il: iwl il struct * * This is called during il_down() to make sure that in the case * we're coming there from a hardware restart mac80211 will be * able to reconfigure stations -- if we're getting there in the * normal down flow then the stations will already be cleared. */ -static inline void il_clear_driver_stations(struct il_priv *priv) +static inline void il_clear_driver_stations(struct il_priv *il) { unsigned long flags; struct il_rxon_context *ctx; - spin_lock_irqsave(&priv->sta_lock, flags); - memset(priv->stations, 0, sizeof(priv->stations)); - priv->num_stations = 0; + spin_lock_irqsave(&il->sta_lock, flags); + memset(il->stations, 0, sizeof(il->stations)); + il->num_stations = 0; - priv->ucode_key_table = 0; + il->ucode_key_table = 0; - for_each_context(priv, ctx) { + for_each_context(il, ctx) { /* * Remove all key information that is not stored as part * of station information since mac80211 may not have had @@ -104,7 +104,7 @@ static inline void il_clear_driver_stations(struct il_priv *priv) ctx->key_mapping_keys = 0; } - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); } static inline int il_sta_id(struct ieee80211_sta *sta) @@ -117,7 +117,7 @@ static inline int il_sta_id(struct ieee80211_sta *sta) /** * il_sta_id_or_broadcast - return sta_id or broadcast sta - * @priv: iwl priv + * @il: iwl il * @context: the current context * @sta: mac80211 station * @@ -126,7 +126,7 @@ static inline int il_sta_id(struct ieee80211_sta *sta) * that case, we need to use the broadcast station, so this * inline wraps that pattern. */ -static inline int il_sta_id_or_broadcast(struct il_priv *priv, +static inline int il_sta_id_or_broadcast(struct il_priv *il, struct il_rxon_context *context, struct ieee80211_sta *sta) { diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index 1c27c60c753a..af6ac4fe2670 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -42,7 +42,7 @@ * il_txq_update_write_ptr - Send new write index to hardware */ void -il_txq_update_write_ptr(struct il_priv *priv, struct il_tx_queue *txq) +il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq) { u32 reg = 0; int txq_id = txq->q.id; @@ -51,22 +51,22 @@ il_txq_update_write_ptr(struct il_priv *priv, struct il_tx_queue *txq) return; /* if we're trying to save power */ - if (test_bit(STATUS_POWER_PMI, &priv->status)) { + if (test_bit(STATUS_POWER_PMI, &il->status)) { /* wake up nic if it's powered down ... * uCode will wake up, and interrupt us again, so next * time we'll skip this part. */ - reg = il_read32(priv, CSR_UCODE_DRV_GP1); + reg = il_read32(il, CSR_UCODE_DRV_GP1); if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "Tx queue %d requesting wakeup," " GP1 = 0x%x\n", txq_id, reg); - il_set_bit(priv, CSR_GP_CNTRL, + il_set_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); return; } - il_write_direct32(priv, HBUS_TARG_WRPTR, + il_write_direct32(il, HBUS_TARG_WRPTR, txq->q.write_ptr | (txq_id << 8)); /* @@ -75,7 +75,7 @@ il_txq_update_write_ptr(struct il_priv *priv, struct il_tx_queue *txq) * trying to tx (during RFKILL, we're not trying to tx). */ } else - il_write32(priv, HBUS_TARG_WRPTR, + il_write32(il, HBUS_TARG_WRPTR, txq->q.write_ptr | (txq_id << 8)); txq->need_update = 0; } @@ -84,16 +84,16 @@ EXPORT_SYMBOL(il_txq_update_write_ptr); /** * il_tx_queue_unmap - Unmap any remaining DMA mappings and free skb's */ -void il_tx_queue_unmap(struct il_priv *priv, int txq_id) +void il_tx_queue_unmap(struct il_priv *il, int txq_id) { - struct il_tx_queue *txq = &priv->txq[txq_id]; + struct il_tx_queue *txq = &il->txq[txq_id]; struct il_queue *q = &txq->q; if (q->n_bd == 0) return; while (q->write_ptr != q->read_ptr) { - priv->cfg->ops->lib->txq_free_tfd(priv, txq); + il->cfg->ops->lib->txq_free_tfd(il, txq); q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); } } @@ -107,13 +107,13 @@ EXPORT_SYMBOL(il_tx_queue_unmap); * Free all buffers. * 0-fill, but do not free "txq" descriptor structure. */ -void il_tx_queue_free(struct il_priv *priv, int txq_id) +void il_tx_queue_free(struct il_priv *il, int txq_id) { - struct il_tx_queue *txq = &priv->txq[txq_id]; - struct device *dev = &priv->pci_dev->dev; + struct il_tx_queue *txq = &il->txq[txq_id]; + struct device *dev = &il->pci_dev->dev; int i; - il_tx_queue_unmap(priv, txq_id); + il_tx_queue_unmap(il, txq_id); /* De-alloc array of command/tx buffers */ for (i = 0; i < TFD_TX_CMD_SLOTS; i++) @@ -121,7 +121,7 @@ void il_tx_queue_free(struct il_priv *priv, int txq_id) /* De-alloc circular buffer of TFDs */ if (txq->q.n_bd) - dma_free_coherent(dev, priv->hw_params.tfd_size * + dma_free_coherent(dev, il->hw_params.tfd_size * txq->q.n_bd, txq->tfds, txq->q.dma_addr); /* De-alloc array of per-TFD driver data */ @@ -142,9 +142,9 @@ EXPORT_SYMBOL(il_tx_queue_free); /** * il_cmd_queue_unmap - Unmap any remaining DMA mappings from command queue */ -void il_cmd_queue_unmap(struct il_priv *priv) +void il_cmd_queue_unmap(struct il_priv *il) { - struct il_tx_queue *txq = &priv->txq[priv->cmd_queue]; + struct il_tx_queue *txq = &il->txq[il->cmd_queue]; struct il_queue *q = &txq->q; int i; @@ -155,7 +155,7 @@ void il_cmd_queue_unmap(struct il_priv *priv) i = il_get_cmd_index(q, q->read_ptr, 0); if (txq->meta[i].flags & CMD_MAPPED) { - pci_unmap_single(priv->pci_dev, + pci_unmap_single(il->pci_dev, dma_unmap_addr(&txq->meta[i], mapping), dma_unmap_len(&txq->meta[i], len), PCI_DMA_BIDIRECTIONAL); @@ -167,7 +167,7 @@ void il_cmd_queue_unmap(struct il_priv *priv) i = q->n_window; if (txq->meta[i].flags & CMD_MAPPED) { - pci_unmap_single(priv->pci_dev, + pci_unmap_single(il->pci_dev, dma_unmap_addr(&txq->meta[i], mapping), dma_unmap_len(&txq->meta[i], len), PCI_DMA_BIDIRECTIONAL); @@ -184,13 +184,13 @@ EXPORT_SYMBOL(il_cmd_queue_unmap); * Free all buffers. * 0-fill, but do not free "txq" descriptor structure. */ -void il_cmd_queue_free(struct il_priv *priv) +void il_cmd_queue_free(struct il_priv *il) { - struct il_tx_queue *txq = &priv->txq[priv->cmd_queue]; - struct device *dev = &priv->pci_dev->dev; + struct il_tx_queue *txq = &il->txq[il->cmd_queue]; + struct device *dev = &il->pci_dev->dev; int i; - il_cmd_queue_unmap(priv); + il_cmd_queue_unmap(il); /* De-alloc array of command/tx buffers */ for (i = 0; i <= TFD_CMD_SLOTS; i++) @@ -198,7 +198,7 @@ void il_cmd_queue_free(struct il_priv *priv) /* De-alloc circular buffer of TFDs */ if (txq->q.n_bd) - dma_free_coherent(dev, priv->hw_params.tfd_size * txq->q.n_bd, + dma_free_coherent(dev, il->hw_params.tfd_size * txq->q.n_bd, txq->tfds, txq->q.dma_addr); /* deallocate arrays */ @@ -256,7 +256,7 @@ EXPORT_SYMBOL(il_queue_space); /** * il_queue_init - Initialize queue's high/low-water and read/write indexes */ -static int il_queue_init(struct il_priv *priv, struct il_queue *q, +static int il_queue_init(struct il_priv *il, struct il_queue *q, int count, int slots_num, u32 id) { q->n_bd = count; @@ -287,19 +287,19 @@ static int il_queue_init(struct il_priv *priv, struct il_queue *q, /** * il_tx_queue_alloc - Alloc driver data and TFD CB for one Tx/cmd queue */ -static int il_tx_queue_alloc(struct il_priv *priv, +static int il_tx_queue_alloc(struct il_priv *il, struct il_tx_queue *txq, u32 id) { - struct device *dev = &priv->pci_dev->dev; - size_t tfd_sz = priv->hw_params.tfd_size * TFD_QUEUE_SIZE_MAX; + struct device *dev = &il->pci_dev->dev; + size_t tfd_sz = il->hw_params.tfd_size * TFD_QUEUE_SIZE_MAX; - /* Driver private data, only for Tx (not command) queues, + /* Driver ilate data, only for Tx (not command) queues, * not shared with device. */ - if (id != priv->cmd_queue) { + if (id != il->cmd_queue) { txq->txb = kzalloc(sizeof(txq->txb[0]) * TFD_QUEUE_SIZE_MAX, GFP_KERNEL); if (!txq->txb) { - IL_ERR(priv, "kmalloc for auxiliary BD " + IL_ERR(il, "kmalloc for auxiliary BD " "structures failed\n"); goto error; } @@ -312,7 +312,7 @@ static int il_tx_queue_alloc(struct il_priv *priv, txq->tfds = dma_alloc_coherent(dev, tfd_sz, &txq->q.dma_addr, GFP_KERNEL); if (!txq->tfds) { - IL_ERR(priv, "pci_alloc_consistent(%zd) failed\n", tfd_sz); + IL_ERR(il, "pci_alloc_consistent(%zd) failed\n", tfd_sz); goto error; } txq->q.id = id; @@ -329,7 +329,7 @@ static int il_tx_queue_alloc(struct il_priv *priv, /** * il_tx_queue_init - Allocate and initialize one tx/cmd queue */ -int il_tx_queue_init(struct il_priv *priv, struct il_tx_queue *txq, +int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num, u32 txq_id) { int i, len; @@ -344,7 +344,7 @@ int il_tx_queue_init(struct il_priv *priv, struct il_tx_queue *txq, * For normal Tx queues (all other queues), no super-size command * space is needed. */ - if (txq_id == priv->cmd_queue) + if (txq_id == il->cmd_queue) actual_slots++; txq->meta = kzalloc(sizeof(struct il_cmd_meta) * actual_slots, @@ -367,7 +367,7 @@ int il_tx_queue_init(struct il_priv *priv, struct il_tx_queue *txq, } /* Alloc driver data array and TFD circular buffer */ - ret = il_tx_queue_alloc(priv, txq, txq_id); + ret = il_tx_queue_alloc(il, txq, txq_id); if (ret) goto err; @@ -386,11 +386,11 @@ int il_tx_queue_init(struct il_priv *priv, struct il_tx_queue *txq, BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); /* Initialize queue's high/low-water marks, and head/tail indexes */ - il_queue_init(priv, &txq->q, + il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); /* Tell device where to find queue */ - priv->cfg->ops->lib->txq_init(priv, txq); + il->cfg->ops->lib->txq_init(il, txq); return 0; err: @@ -404,12 +404,12 @@ out_free_arrays: } EXPORT_SYMBOL(il_tx_queue_init); -void il_tx_queue_reset(struct il_priv *priv, struct il_tx_queue *txq, +void il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, int slots_num, u32 txq_id) { int actual_slots = slots_num; - if (txq_id == priv->cmd_queue) + if (txq_id == il->cmd_queue) actual_slots++; memset(txq->meta, 0, sizeof(struct il_cmd_meta) * actual_slots); @@ -417,11 +417,11 @@ void il_tx_queue_reset(struct il_priv *priv, struct il_tx_queue *txq, txq->need_update = 0; /* Initialize queue's high/low-water marks, and head/tail indexes */ - il_queue_init(priv, &txq->q, + il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); /* Tell device where to find queue */ - priv->cfg->ops->lib->txq_init(priv, txq); + il->cfg->ops->lib->txq_init(il, txq); } EXPORT_SYMBOL(il_tx_queue_reset); @@ -429,16 +429,16 @@ EXPORT_SYMBOL(il_tx_queue_reset); /** * il_enqueue_hcmd - enqueue a uCode command - * @priv: device private data point + * @il: device ilate data point * @cmd: a point to the ucode command structure * * The function returns < 0 values to indicate the operation is * failed. On success, it turns the index (> 0) of command in the * command queue. */ -int il_enqueue_hcmd(struct il_priv *priv, struct il_host_cmd *cmd) +int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) { - struct il_tx_queue *txq = &priv->txq[priv->cmd_queue]; + struct il_tx_queue *txq = &il->txq[il->cmd_queue]; struct il_queue *q = &txq->q; struct il_device_cmd *out_cmd; struct il_cmd_meta *out_meta; @@ -448,7 +448,7 @@ int il_enqueue_hcmd(struct il_priv *priv, struct il_host_cmd *cmd) u32 idx; u16 fix_size; - cmd->len = priv->cfg->ops->utils->get_hcmd_size(cmd->id, cmd->len); + cmd->len = il->cfg->ops->utils->get_hcmd_size(cmd->id, cmd->len); fix_size = (u16)(cmd->len + sizeof(out_cmd->hdr)); /* If any of the command structures end up being larger than @@ -460,19 +460,19 @@ int il_enqueue_hcmd(struct il_priv *priv, struct il_host_cmd *cmd) !(cmd->flags & CMD_SIZE_HUGE)); BUG_ON(fix_size > IL_MAX_CMD_SIZE); - if (il_is_rfkill(priv) || il_is_ctkill(priv)) { - IL_WARN(priv, "Not sending command - %s KILL\n", - il_is_rfkill(priv) ? "RF" : "CT"); + if (il_is_rfkill(il) || il_is_ctkill(il)) { + IL_WARN(il, "Not sending command - %s KILL\n", + il_is_rfkill(il) ? "RF" : "CT"); return -EIO; } - spin_lock_irqsave(&priv->hcmd_lock, flags); + spin_lock_irqsave(&il->hcmd_lock, flags); if (il_queue_space(q) < ((cmd->flags & CMD_ASYNC) ? 2 : 1)) { - spin_unlock_irqrestore(&priv->hcmd_lock, flags); + spin_unlock_irqrestore(&il->hcmd_lock, flags); - IL_ERR(priv, "Restarting adapter due to command queue full\n"); - queue_work(priv->workqueue, &priv->restart); + IL_ERR(il, "Restarting adapter due to command queue full\n"); + queue_work(il->workqueue, &il->restart); return -ENOSPC; } @@ -481,7 +481,7 @@ int il_enqueue_hcmd(struct il_priv *priv, struct il_host_cmd *cmd) out_meta = &txq->meta[idx]; if (WARN_ON(out_meta->flags & CMD_MAPPED)) { - spin_unlock_irqrestore(&priv->hcmd_lock, flags); + spin_unlock_irqrestore(&il->hcmd_lock, flags); return -ENOSPC; } @@ -499,7 +499,7 @@ int il_enqueue_hcmd(struct il_priv *priv, struct il_host_cmd *cmd) * information */ out_cmd->hdr.flags = 0; - out_cmd->hdr.sequence = cpu_to_le16(QUEUE_TO_SEQ(priv->cmd_queue) | + out_cmd->hdr.sequence = cpu_to_le16(QUEUE_TO_SEQ(il->cmd_queue) | INDEX_TO_SEQ(q->write_ptr)); if (cmd->flags & CMD_SIZE_HUGE) out_cmd->hdr.sequence |= SEQ_HUGE_FRAME; @@ -511,43 +511,43 @@ int il_enqueue_hcmd(struct il_priv *priv, struct il_host_cmd *cmd) switch (out_cmd->hdr.cmd) { case REPLY_TX_LINK_QUALITY_CMD: case SENSITIVITY_CMD: - IL_DEBUG_HC_DUMP(priv, + IL_DEBUG_HC_DUMP(il, "Sending command %s (#%x), seq: 0x%04X, " "%d bytes at %d[%d]:%d\n", il_get_cmd_string(out_cmd->hdr.cmd), out_cmd->hdr.cmd, le16_to_cpu(out_cmd->hdr.sequence), fix_size, - q->write_ptr, idx, priv->cmd_queue); + q->write_ptr, idx, il->cmd_queue); break; default: - IL_DEBUG_HC(priv, "Sending command %s (#%x), seq: 0x%04X, " + IL_DEBUG_HC(il, "Sending command %s (#%x), seq: 0x%04X, " "%d bytes at %d[%d]:%d\n", il_get_cmd_string(out_cmd->hdr.cmd), out_cmd->hdr.cmd, le16_to_cpu(out_cmd->hdr.sequence), fix_size, - q->write_ptr, idx, priv->cmd_queue); + q->write_ptr, idx, il->cmd_queue); } #endif txq->need_update = 1; - if (priv->cfg->ops->lib->txq_update_byte_cnt_tbl) + if (il->cfg->ops->lib->txq_update_byte_cnt_tbl) /* Set up entry in queue's byte count circular buffer */ - priv->cfg->ops->lib->txq_update_byte_cnt_tbl(priv, txq, 0); + il->cfg->ops->lib->txq_update_byte_cnt_tbl(il, txq, 0); - phys_addr = pci_map_single(priv->pci_dev, &out_cmd->hdr, + phys_addr = pci_map_single(il->pci_dev, &out_cmd->hdr, fix_size, PCI_DMA_BIDIRECTIONAL); dma_unmap_addr_set(out_meta, mapping, phys_addr); dma_unmap_len_set(out_meta, len, fix_size); - priv->cfg->ops->lib->txq_attach_buf_to_tfd(priv, txq, + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr, fix_size, 1, U32_PAD(cmd->len)); /* Increment and update queue's write index */ q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); - il_txq_update_write_ptr(priv, txq); + il_txq_update_write_ptr(il, txq); - spin_unlock_irqrestore(&priv->hcmd_lock, flags); + spin_unlock_irqrestore(&il->hcmd_lock, flags); return idx; } @@ -558,15 +558,15 @@ int il_enqueue_hcmd(struct il_priv *priv, struct il_host_cmd *cmd) * need to be reclaimed. As result, some free space forms. If there is * enough free space (> low mark), wake the stack that feeds us. */ -static void il_hcmd_queue_reclaim(struct il_priv *priv, int txq_id, +static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, int idx, int cmd_idx) { - struct il_tx_queue *txq = &priv->txq[txq_id]; + struct il_tx_queue *txq = &il->txq[txq_id]; struct il_queue *q = &txq->q; int nfreed = 0; if ((idx >= q->n_bd) || (il_queue_used(q, idx) == 0)) { - IL_ERR(priv, "Read index for DMA queue txq id (%d), index %d, " + IL_ERR(il, "Read index for DMA queue txq id (%d), index %d, " "is out of range [0-%d] %d %d.\n", txq_id, idx, q->n_bd, q->write_ptr, q->read_ptr); return; @@ -576,9 +576,9 @@ static void il_hcmd_queue_reclaim(struct il_priv *priv, int txq_id, q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { if (nfreed++ > 0) { - IL_ERR(priv, "HCMD skipped: index (%d) %d %d\n", idx, + IL_ERR(il, "HCMD skipped: index (%d) %d %d\n", idx, q->write_ptr, q->read_ptr); - queue_work(priv->workqueue, &priv->restart); + queue_work(il->workqueue, &il->restart); } } @@ -593,7 +593,7 @@ static void il_hcmd_queue_reclaim(struct il_priv *priv, int txq_id, * if the callback returns 1 */ void -il_tx_cmd_complete(struct il_priv *priv, struct il_rx_mem_buffer *rxb) +il_tx_cmd_complete(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); @@ -603,18 +603,18 @@ il_tx_cmd_complete(struct il_priv *priv, struct il_rx_mem_buffer *rxb) bool huge = !!(pkt->hdr.sequence & SEQ_HUGE_FRAME); struct il_device_cmd *cmd; struct il_cmd_meta *meta; - struct il_tx_queue *txq = &priv->txq[priv->cmd_queue]; + struct il_tx_queue *txq = &il->txq[il->cmd_queue]; unsigned long flags; /* If a Tx command is being handled and it isn't in the actual * command queue then there a command routing bug has been introduced * in the queue management code. */ - if (WARN(txq_id != priv->cmd_queue, + if (WARN(txq_id != il->cmd_queue, "wrong command queue %d (should be %d), sequence 0x%X readp=%d writep=%d\n", - txq_id, priv->cmd_queue, sequence, - priv->txq[priv->cmd_queue].q.read_ptr, - priv->txq[priv->cmd_queue].q.write_ptr)) { - il_print_hex_error(priv, pkt, 32); + txq_id, il->cmd_queue, sequence, + il->txq[il->cmd_queue].q.read_ptr, + il->txq[il->cmd_queue].q.write_ptr)) { + il_print_hex_error(il, pkt, 32); return; } @@ -624,7 +624,7 @@ il_tx_cmd_complete(struct il_priv *priv, struct il_rx_mem_buffer *rxb) txq->time_stamp = jiffies; - pci_unmap_single(priv->pci_dev, + pci_unmap_single(il->pci_dev, dma_unmap_addr(meta, mapping), dma_unmap_len(meta, len), PCI_DMA_BIDIRECTIONAL); @@ -634,22 +634,22 @@ il_tx_cmd_complete(struct il_priv *priv, struct il_rx_mem_buffer *rxb) meta->source->reply_page = (unsigned long)rxb_addr(rxb); rxb->page = NULL; } else if (meta->callback) - meta->callback(priv, cmd, pkt); + meta->callback(il, cmd, pkt); - spin_lock_irqsave(&priv->hcmd_lock, flags); + spin_lock_irqsave(&il->hcmd_lock, flags); - il_hcmd_queue_reclaim(priv, txq_id, index, cmd_index); + il_hcmd_queue_reclaim(il, txq_id, index, cmd_index); if (!(meta->flags & CMD_ASYNC)) { - clear_bit(STATUS_HCMD_ACTIVE, &priv->status); - IL_DEBUG_INFO(priv, "Clearing HCMD_ACTIVE for command %s\n", + clear_bit(STATUS_HCMD_ACTIVE, &il->status); + IL_DEBUG_INFO(il, "Clearing HCMD_ACTIVE for command %s\n", il_get_cmd_string(cmd->hdr.cmd)); - wake_up(&priv->wait_command_queue); + wake_up(&il->wait_command_queue); } /* Mark as unmapped */ meta->flags = 0; - spin_unlock_irqrestore(&priv->hcmd_lock, flags); + spin_unlock_irqrestore(&il->hcmd_lock, flags); } EXPORT_SYMBOL(il_tx_cmd_complete); diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index d24937a0014a..2c336a701dc5 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -98,18 +98,18 @@ struct il_mod_params il3945_mod_params = { /** * il3945_get_antenna_flags - Get antenna flags for RXON command - * @priv: eeprom and antenna fields are used to determine antenna flags + * @il: eeprom and antenna fields are used to determine antenna flags * - * priv->eeprom39 is used to determine if antenna AUX/MAIN are reversed + * il->eeprom39 is used to determine if antenna AUX/MAIN are reversed * il3945_mod_params.antenna specifies the antenna diversity mode: * * IL_ANTENNA_DIVERSITY - NIC selects best antenna by itself * IL_ANTENNA_MAIN - Force MAIN antenna * IL_ANTENNA_AUX - Force AUX antenna */ -__le32 il3945_get_antenna_flags(const struct il_priv *priv) +__le32 il3945_get_antenna_flags(const struct il_priv *il) { - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; switch (il3945_mod_params.antenna) { case IL_ANTENNA_DIVERSITY: @@ -127,13 +127,13 @@ __le32 il3945_get_antenna_flags(const struct il_priv *priv) } /* bad antenna selector value */ - IL_ERR(priv, "Bad antenna selector value (0x%x)\n", + IL_ERR(il, "Bad antenna selector value (0x%x)\n", il3945_mod_params.antenna); return 0; /* "diversity" is default if error */ } -static int il3945_set_ccmp_dynamic_key_info(struct il_priv *priv, +static int il3945_set_ccmp_dynamic_key_info(struct il_priv *il, struct ieee80211_key_conf *keyconf, u8 sta_id) { @@ -144,80 +144,80 @@ static int il3945_set_ccmp_dynamic_key_info(struct il_priv *priv, key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK); key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); - if (sta_id == priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id) + if (sta_id == il->contexts[IL_RXON_CTX_BSS].bcast_sta_id) key_flags |= STA_KEY_MULTICAST_MSK; keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; keyconf->hw_key_idx = keyconf->keyidx; key_flags &= ~STA_KEY_FLG_INVALID; - spin_lock_irqsave(&priv->sta_lock, flags); - priv->stations[sta_id].keyinfo.cipher = keyconf->cipher; - priv->stations[sta_id].keyinfo.keylen = keyconf->keylen; - memcpy(priv->stations[sta_id].keyinfo.key, keyconf->key, + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].keyinfo.cipher = keyconf->cipher; + il->stations[sta_id].keyinfo.keylen = keyconf->keylen; + memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, keyconf->keylen); - memcpy(priv->stations[sta_id].sta.key.key, keyconf->key, + memcpy(il->stations[sta_id].sta.key.key, keyconf->key, keyconf->keylen); - if ((priv->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) + if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) - priv->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_index(priv); + il->stations[sta_id].sta.key.key_offset = + il_get_free_ucode_key_index(il); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ - WARN(priv->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, + WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, "no space for a new key"); - priv->stations[sta_id].sta.key.key_flags = key_flags; - priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; - priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + il->stations[sta_id].sta.key.key_flags = key_flags; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - IL_DEBUG_INFO(priv, "hwcrypto: modify ucode station key info\n"); + IL_DEBUG_INFO(il, "hwcrypto: modify ucode station key info\n"); - ret = il_send_add_sta(priv, - &priv->stations[sta_id].sta, CMD_ASYNC); + ret = il_send_add_sta(il, + &il->stations[sta_id].sta, CMD_ASYNC); - spin_unlock_irqrestore(&priv->sta_lock, flags); + spin_unlock_irqrestore(&il->sta_lock, flags); return ret; } -static int il3945_set_tkip_dynamic_key_info(struct il_priv *priv, +static int il3945_set_tkip_dynamic_key_info(struct il_priv *il, struct ieee80211_key_conf *keyconf, u8 sta_id) { return -EOPNOTSUPP; } -static int il3945_set_wep_dynamic_key_info(struct il_priv *priv, +static int il3945_set_wep_dynamic_key_info(struct il_priv *il, struct ieee80211_key_conf *keyconf, u8 sta_id) { return -EOPNOTSUPP; } -static int il3945_clear_sta_key_info(struct il_priv *priv, u8 sta_id) +static int il3945_clear_sta_key_info(struct il_priv *il, u8 sta_id) { unsigned long flags; struct il_addsta_cmd sta_cmd; - spin_lock_irqsave(&priv->sta_lock, flags); - memset(&priv->stations[sta_id].keyinfo, 0, sizeof(struct il_hw_key)); - memset(&priv->stations[sta_id].sta.key, 0, + spin_lock_irqsave(&il->sta_lock, flags); + memset(&il->stations[sta_id].keyinfo, 0, sizeof(struct il_hw_key)); + memset(&il->stations[sta_id].sta.key, 0, sizeof(struct il4965_keyinfo)); - priv->stations[sta_id].sta.key.key_flags = STA_KEY_FLG_NO_ENC; - priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; - priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - memcpy(&sta_cmd, &priv->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&priv->sta_lock, flags); + il->stations[sta_id].sta.key.key_flags = STA_KEY_FLG_NO_ENC; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + memcpy(&sta_cmd, &il->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); + spin_unlock_irqrestore(&il->sta_lock, flags); - IL_DEBUG_INFO(priv, "hwcrypto: clear ucode station key info\n"); - return il_send_add_sta(priv, &sta_cmd, CMD_SYNC); + IL_DEBUG_INFO(il, "hwcrypto: clear ucode station key info\n"); + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } -static int il3945_set_dynamic_key(struct il_priv *priv, +static int il3945_set_dynamic_key(struct il_priv *il, struct ieee80211_key_conf *keyconf, u8 sta_id) { int ret = 0; @@ -226,154 +226,154 @@ static int il3945_set_dynamic_key(struct il_priv *priv, switch (keyconf->cipher) { case WLAN_CIPHER_SUITE_CCMP: - ret = il3945_set_ccmp_dynamic_key_info(priv, keyconf, sta_id); + ret = il3945_set_ccmp_dynamic_key_info(il, keyconf, sta_id); break; case WLAN_CIPHER_SUITE_TKIP: - ret = il3945_set_tkip_dynamic_key_info(priv, keyconf, sta_id); + ret = il3945_set_tkip_dynamic_key_info(il, keyconf, sta_id); break; case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP104: - ret = il3945_set_wep_dynamic_key_info(priv, keyconf, sta_id); + ret = il3945_set_wep_dynamic_key_info(il, keyconf, sta_id); break; default: - IL_ERR(priv, "Unknown alg: %s alg=%x\n", __func__, + IL_ERR(il, "Unknown alg: %s alg=%x\n", __func__, keyconf->cipher); ret = -EINVAL; } - IL_DEBUG_WEP(priv, "Set dynamic key: alg=%x len=%d idx=%d sta=%d ret=%d\n", + IL_DEBUG_WEP(il, "Set dynamic key: alg=%x len=%d idx=%d sta=%d ret=%d\n", keyconf->cipher, keyconf->keylen, keyconf->keyidx, sta_id, ret); return ret; } -static int il3945_remove_static_key(struct il_priv *priv) +static int il3945_remove_static_key(struct il_priv *il) { int ret = -EOPNOTSUPP; return ret; } -static int il3945_set_static_key(struct il_priv *priv, +static int il3945_set_static_key(struct il_priv *il, struct ieee80211_key_conf *key) { if (key->cipher == WLAN_CIPHER_SUITE_WEP40 || key->cipher == WLAN_CIPHER_SUITE_WEP104) return -EOPNOTSUPP; - IL_ERR(priv, "Static key invalid: cipher %x\n", key->cipher); + IL_ERR(il, "Static key invalid: cipher %x\n", key->cipher); return -EINVAL; } -static void il3945_clear_free_frames(struct il_priv *priv) +static void il3945_clear_free_frames(struct il_priv *il) { struct list_head *element; - IL_DEBUG_INFO(priv, "%d frames on pre-allocated heap on clear.\n", - priv->frames_count); + IL_DEBUG_INFO(il, "%d frames on pre-allocated heap on clear.\n", + il->frames_count); - while (!list_empty(&priv->free_frames)) { - element = priv->free_frames.next; + while (!list_empty(&il->free_frames)) { + element = il->free_frames.next; list_del(element); kfree(list_entry(element, struct il3945_frame, list)); - priv->frames_count--; + il->frames_count--; } - if (priv->frames_count) { - IL_WARN(priv, "%d frames still in use. Did we lose one?\n", - priv->frames_count); - priv->frames_count = 0; + if (il->frames_count) { + IL_WARN(il, "%d frames still in use. Did we lose one?\n", + il->frames_count); + il->frames_count = 0; } } -static struct il3945_frame *il3945_get_free_frame(struct il_priv *priv) +static struct il3945_frame *il3945_get_free_frame(struct il_priv *il) { struct il3945_frame *frame; struct list_head *element; - if (list_empty(&priv->free_frames)) { + if (list_empty(&il->free_frames)) { frame = kzalloc(sizeof(*frame), GFP_KERNEL); if (!frame) { - IL_ERR(priv, "Could not allocate frame!\n"); + IL_ERR(il, "Could not allocate frame!\n"); return NULL; } - priv->frames_count++; + il->frames_count++; return frame; } - element = priv->free_frames.next; + element = il->free_frames.next; list_del(element); return list_entry(element, struct il3945_frame, list); } -static void il3945_free_frame(struct il_priv *priv, struct il3945_frame *frame) +static void il3945_free_frame(struct il_priv *il, struct il3945_frame *frame) { memset(frame, 0, sizeof(*frame)); - list_add(&frame->list, &priv->free_frames); + list_add(&frame->list, &il->free_frames); } -unsigned int il3945_fill_beacon_frame(struct il_priv *priv, +unsigned int il3945_fill_beacon_frame(struct il_priv *il, struct ieee80211_hdr *hdr, int left) { - if (!il_is_associated(priv, IL_RXON_CTX_BSS) || !priv->beacon_skb) + if (!il_is_associated(il, IL_RXON_CTX_BSS) || !il->beacon_skb) return 0; - if (priv->beacon_skb->len > left) + if (il->beacon_skb->len > left) return 0; - memcpy(hdr, priv->beacon_skb->data, priv->beacon_skb->len); + memcpy(hdr, il->beacon_skb->data, il->beacon_skb->len); - return priv->beacon_skb->len; + return il->beacon_skb->len; } -static int il3945_send_beacon_cmd(struct il_priv *priv) +static int il3945_send_beacon_cmd(struct il_priv *il) { struct il3945_frame *frame; unsigned int frame_size; int rc; u8 rate; - frame = il3945_get_free_frame(priv); + frame = il3945_get_free_frame(il); if (!frame) { - IL_ERR(priv, "Could not obtain free frame buffer for beacon " + IL_ERR(il, "Could not obtain free frame buffer for beacon " "command.\n"); return -ENOMEM; } - rate = il_get_lowest_plcp(priv, - &priv->contexts[IL_RXON_CTX_BSS]); + rate = il_get_lowest_plcp(il, + &il->contexts[IL_RXON_CTX_BSS]); - frame_size = il3945_hw_get_beacon_cmd(priv, frame, rate); + frame_size = il3945_hw_get_beacon_cmd(il, frame, rate); - rc = il_send_cmd_pdu(priv, REPLY_TX_BEACON, frame_size, + rc = il_send_cmd_pdu(il, REPLY_TX_BEACON, frame_size, &frame->u.cmd[0]); - il3945_free_frame(priv, frame); + il3945_free_frame(il, frame); return rc; } -static void il3945_unset_hw_params(struct il_priv *priv) +static void il3945_unset_hw_params(struct il_priv *il) { - if (priv->_3945.shared_virt) - dma_free_coherent(&priv->pci_dev->dev, + if (il->_3945.shared_virt) + dma_free_coherent(&il->pci_dev->dev, sizeof(struct il3945_shared), - priv->_3945.shared_virt, - priv->_3945.shared_phys); + il->_3945.shared_virt, + il->_3945.shared_phys); } -static void il3945_build_tx_cmd_hwcrypto(struct il_priv *priv, +static void il3945_build_tx_cmd_hwcrypto(struct il_priv *il, struct ieee80211_tx_info *info, struct il_device_cmd *cmd, struct sk_buff *skb_frag, int sta_id) { struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; - struct il_hw_key *keyinfo = &priv->stations[sta_id].keyinfo; + struct il_hw_key *keyinfo = &il->stations[sta_id].keyinfo; tx_cmd->sec_ctl = 0; @@ -381,7 +381,7 @@ static void il3945_build_tx_cmd_hwcrypto(struct il_priv *priv, case WLAN_CIPHER_SUITE_CCMP: tx_cmd->sec_ctl = TX_CMD_SEC_CCM; memcpy(tx_cmd->key, keyinfo->key, keyinfo->keylen); - IL_DEBUG_TX(priv, "tx_cmd with AES hwcrypto\n"); + IL_DEBUG_TX(il, "tx_cmd with AES hwcrypto\n"); break; case WLAN_CIPHER_SUITE_TKIP: @@ -396,12 +396,12 @@ static void il3945_build_tx_cmd_hwcrypto(struct il_priv *priv, memcpy(&tx_cmd->key[3], keyinfo->key, keyinfo->keylen); - IL_DEBUG_TX(priv, "Configuring packet for WEP encryption " + IL_DEBUG_TX(il, "Configuring packet for WEP encryption " "with key %d\n", info->control.hw_key->hw_key_idx); break; default: - IL_ERR(priv, "Unknown encode cipher %x\n", keyinfo->cipher); + IL_ERR(il, "Unknown encode cipher %x\n", keyinfo->cipher); break; } } @@ -409,7 +409,7 @@ static void il3945_build_tx_cmd_hwcrypto(struct il_priv *priv, /* * handle build REPLY_TX command notification. */ -static void il3945_build_tx_cmd_basic(struct il_priv *priv, +static void il3945_build_tx_cmd_basic(struct il_priv *il, struct il_device_cmd *cmd, struct ieee80211_tx_info *info, struct ieee80211_hdr *hdr, u8 std_id) @@ -443,7 +443,7 @@ static void il3945_build_tx_cmd_basic(struct il_priv *priv, tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; } - il_tx_cmd_protection(priv, info, fc, &tx_flags); + il_tx_cmd_protection(il, info, fc, &tx_flags); tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); if (ieee80211_is_mgmt(fc)) { @@ -463,7 +463,7 @@ static void il3945_build_tx_cmd_basic(struct il_priv *priv, /* * start REPLY_TX command process */ -static int il3945_tx_skb(struct il_priv *priv, struct sk_buff *skb) +static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); @@ -484,14 +484,14 @@ static int il3945_tx_skb(struct il_priv *priv, struct sk_buff *skb) u8 wait_write_ptr = 0; unsigned long flags; - spin_lock_irqsave(&priv->lock, flags); - if (il_is_rfkill(priv)) { - IL_DEBUG_DROP(priv, "Dropping - RF KILL\n"); + spin_lock_irqsave(&il->lock, flags); + if (il_is_rfkill(il)) { + IL_DEBUG_DROP(il, "Dropping - RF KILL\n"); goto drop_unlock; } - if ((ieee80211_get_tx_rate(priv->hw, info)->hw_value & 0xFF) == IL_INVALID_RATE) { - IL_ERR(priv, "ERROR: No TX rate available.\n"); + if ((ieee80211_get_tx_rate(il->hw, info)->hw_value & 0xFF) == IL_INVALID_RATE) { + IL_ERR(il, "ERROR: No TX rate available.\n"); goto drop_unlock; } @@ -502,28 +502,28 @@ static int il3945_tx_skb(struct il_priv *priv, struct sk_buff *skb) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG if (ieee80211_is_auth(fc)) - IL_DEBUG_TX(priv, "Sending AUTH frame\n"); + IL_DEBUG_TX(il, "Sending AUTH frame\n"); else if (ieee80211_is_assoc_req(fc)) - IL_DEBUG_TX(priv, "Sending ASSOC frame\n"); + IL_DEBUG_TX(il, "Sending ASSOC frame\n"); else if (ieee80211_is_reassoc_req(fc)) - IL_DEBUG_TX(priv, "Sending REASSOC frame\n"); + IL_DEBUG_TX(il, "Sending REASSOC frame\n"); #endif - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); hdr_len = ieee80211_hdrlen(fc); /* Find index into station table for destination station */ sta_id = il_sta_id_or_broadcast( - priv, &priv->contexts[IL_RXON_CTX_BSS], + il, &il->contexts[IL_RXON_CTX_BSS], info->control.sta); if (sta_id == IL_INVALID_STATION) { - IL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", + IL_DEBUG_DROP(il, "Dropping - INVALID STATION: %pM\n", hdr->addr1); goto drop; } - IL_DEBUG_RATE(priv, "station Id %d\n", sta_id); + IL_DEBUG_RATE(il, "station Id %d\n", sta_id); if (ieee80211_is_data_qos(fc)) { u8 *qc = ieee80211_get_qos_ctl(hdr); @@ -533,20 +533,20 @@ static int il3945_tx_skb(struct il_priv *priv, struct sk_buff *skb) } /* Descriptor for chosen Tx queue */ - txq = &priv->txq[txq_id]; + txq = &il->txq[txq_id]; q = &txq->q; if ((il_queue_space(q) < q->high_mark)) goto drop; - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); idx = il_get_cmd_index(q, q->write_ptr, 0); /* Set up driver data for this TFD */ memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct il_tx_info)); txq->txb[q->write_ptr].skb = skb; - txq->txb[q->write_ptr].ctx = &priv->contexts[IL_RXON_CTX_BSS]; + txq->txb[q->write_ptr].ctx = &il->contexts[IL_RXON_CTX_BSS]; /* Init first empty entry in queue's array of Tx/cmd buffers */ out_cmd = txq->cmd[idx]; @@ -570,20 +570,20 @@ static int il3945_tx_skb(struct il_priv *priv, struct sk_buff *skb) if (info->control.hw_key) - il3945_build_tx_cmd_hwcrypto(priv, info, out_cmd, skb, sta_id); + il3945_build_tx_cmd_hwcrypto(il, info, out_cmd, skb, sta_id); /* TODO need this for burst mode later on */ - il3945_build_tx_cmd_basic(priv, out_cmd, info, hdr, sta_id); + il3945_build_tx_cmd_basic(il, out_cmd, info, hdr, sta_id); /* set is_hcca to 0; it probably will never be implemented */ - il3945_hw_build_tx_cmd_rate(priv, out_cmd, info, hdr, sta_id, 0); + il3945_hw_build_tx_cmd_rate(il, out_cmd, info, hdr, sta_id, 0); /* Total # bytes to be transmitted */ len = (u16)skb->len; tx_cmd->len = cpu_to_le16(len); - il_dbg_log_tx_data_frame(priv, len, hdr); - il_update_stats(priv, true, fc, len); + il_dbg_log_tx_data_frame(il, len, hdr); + il_update_stats(il, true, fc, len); tx_cmd->tx_flags &= ~TX_CMD_FLG_ANT_A_MSK; tx_cmd->tx_flags &= ~TX_CMD_FLG_ANT_B_MSK; @@ -594,11 +594,11 @@ static int il3945_tx_skb(struct il_priv *priv, struct sk_buff *skb) txq->need_update = 0; } - IL_DEBUG_TX(priv, "sequence nr = 0X%x\n", + IL_DEBUG_TX(il, "sequence nr = 0X%x\n", le16_to_cpu(out_cmd->hdr.sequence)); - IL_DEBUG_TX(priv, "tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); - il_print_hex_dump(priv, IL_DL_TX, tx_cmd, sizeof(*tx_cmd)); - il_print_hex_dump(priv, IL_DL_TX, (u8 *)tx_cmd->hdr, + IL_DEBUG_TX(il, "tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); + il_print_hex_dump(il, IL_DL_TX, tx_cmd, sizeof(*tx_cmd)); + il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd->hdr, ieee80211_hdrlen(fc)); /* @@ -616,7 +616,7 @@ static int il3945_tx_skb(struct il_priv *priv, struct sk_buff *skb) /* Physical address of this Tx command's header (not MAC header!), * within command buffer array. */ - txcmd_phys = pci_map_single(priv->pci_dev, &out_cmd->hdr, + txcmd_phys = pci_map_single(il->pci_dev, &out_cmd->hdr, len, PCI_DMA_TODEVICE); /* we do not map meta data ... so we can safely access address to * provide to unmap command*/ @@ -625,7 +625,7 @@ static int il3945_tx_skb(struct il_priv *priv, struct sk_buff *skb) /* Add buffer containing Tx command and MAC(!) header to TFD's * first entry */ - priv->cfg->ops->lib->txq_attach_buf_to_tfd(priv, txq, + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, txcmd_phys, len, 1, 0); @@ -633,9 +633,9 @@ static int il3945_tx_skb(struct il_priv *priv, struct sk_buff *skb) * if any (802.11 null frames have no payload). */ len = skb->len - hdr_len; if (len) { - phys_addr = pci_map_single(priv->pci_dev, skb->data + hdr_len, + phys_addr = pci_map_single(il->pci_dev, skb->data + hdr_len, len, PCI_DMA_TODEVICE); - priv->cfg->ops->lib->txq_attach_buf_to_tfd(priv, txq, + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr, len, 0, U32_PAD(len)); } @@ -643,30 +643,30 @@ static int il3945_tx_skb(struct il_priv *priv, struct sk_buff *skb) /* Tell device the write index *just past* this latest filled TFD */ q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); - il_txq_update_write_ptr(priv, txq); - spin_unlock_irqrestore(&priv->lock, flags); + il_txq_update_write_ptr(il, txq); + spin_unlock_irqrestore(&il->lock, flags); if ((il_queue_space(q) < q->high_mark) - && priv->mac80211_registered) { + && il->mac80211_registered) { if (wait_write_ptr) { - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); txq->need_update = 1; - il_txq_update_write_ptr(priv, txq); - spin_unlock_irqrestore(&priv->lock, flags); + il_txq_update_write_ptr(il, txq); + spin_unlock_irqrestore(&il->lock, flags); } - il_stop_queue(priv, txq); + il_stop_queue(il, txq); } return 0; drop_unlock: - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); drop: return -1; } -static int il3945_get_measurement(struct il_priv *priv, +static int il3945_get_measurement(struct il_priv *il, struct ieee80211_measurement_params *params, u8 type) { @@ -681,11 +681,11 @@ static int il3945_get_measurement(struct il_priv *priv, int rc; int spectrum_resp_status; int duration = le16_to_cpu(params->duration); - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; - if (il_is_associated(priv, IL_RXON_CTX_BSS)) - add_time = il_usecs_to_beacons(priv, - le64_to_cpu(params->start_time) - priv->_3945.last_tsf, + if (il_is_associated(il, IL_RXON_CTX_BSS)) + add_time = il_usecs_to_beacons(il, + le64_to_cpu(params->start_time) - il->_3945.last_tsf, le16_to_cpu(ctx->timing.beacon_interval)); memset(&spectrum, 0, sizeof(spectrum)); @@ -697,10 +697,10 @@ static int il3945_get_measurement(struct il_priv *priv, cmd.len = sizeof(spectrum); spectrum.len = cpu_to_le16(cmd.len - sizeof(spectrum.len)); - if (il_is_associated(priv, IL_RXON_CTX_BSS)) + if (il_is_associated(il, IL_RXON_CTX_BSS)) spectrum.start_time = - il_add_beacon_time(priv, - priv->_3945.last_beacon_time, add_time, + il_add_beacon_time(il, + il->_3945.last_beacon_time, add_time, le16_to_cpu(ctx->timing.beacon_interval)); else spectrum.start_time = 0; @@ -712,13 +712,13 @@ static int il3945_get_measurement(struct il_priv *priv, spectrum.flags |= RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_TGG_PROTECT_MSK; - rc = il_send_cmd_sync(priv, &cmd); + rc = il_send_cmd_sync(il, &cmd); if (rc) return rc; pkt = (struct il_rx_packet *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR(priv, "Bad return from REPLY_RX_ON_ASSOC command\n"); + IL_ERR(il, "Bad return from REPLY_RX_ON_ASSOC command\n"); rc = -EIO; } @@ -726,11 +726,11 @@ static int il3945_get_measurement(struct il_priv *priv, switch (spectrum_resp_status) { case 0: /* Command will be handled */ if (pkt->u.spectrum.id != 0xff) { - IL_DEBUG_INFO(priv, "Replaced existing measurement: %d\n", + IL_DEBUG_INFO(il, "Replaced existing measurement: %d\n", pkt->u.spectrum.id); - priv->measurement_status &= ~MEASUREMENT_READY; + il->measurement_status &= ~MEASUREMENT_READY; } - priv->measurement_status |= MEASUREMENT_ACTIVE; + il->measurement_status |= MEASUREMENT_ACTIVE; rc = 0; break; @@ -739,12 +739,12 @@ static int il3945_get_measurement(struct il_priv *priv, break; } - il_free_pages(priv, cmd.reply_page); + il_free_pages(il, cmd.reply_page); return rc; } -static void il3945_rx_reply_alive(struct il_priv *priv, +static void il3945_rx_reply_alive(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); @@ -753,44 +753,44 @@ static void il3945_rx_reply_alive(struct il_priv *priv, palive = &pkt->u.alive_frame; - IL_DEBUG_INFO(priv, "Alive ucode status 0x%08X revision " + IL_DEBUG_INFO(il, "Alive ucode status 0x%08X revision " "0x%01X 0x%01X\n", palive->is_valid, palive->ver_type, palive->ver_subtype); if (palive->ver_subtype == INITIALIZE_SUBTYPE) { - IL_DEBUG_INFO(priv, "Initialization Alive received.\n"); - memcpy(&priv->card_alive_init, &pkt->u.alive_frame, + IL_DEBUG_INFO(il, "Initialization Alive received.\n"); + memcpy(&il->card_alive_init, &pkt->u.alive_frame, sizeof(struct il_alive_resp)); - pwork = &priv->init_alive_start; + pwork = &il->init_alive_start; } else { - IL_DEBUG_INFO(priv, "Runtime Alive received.\n"); - memcpy(&priv->card_alive, &pkt->u.alive_frame, + IL_DEBUG_INFO(il, "Runtime Alive received.\n"); + memcpy(&il->card_alive, &pkt->u.alive_frame, sizeof(struct il_alive_resp)); - pwork = &priv->alive_start; - il3945_disable_events(priv); + pwork = &il->alive_start; + il3945_disable_events(il); } /* We delay the ALIVE response by 5ms to * give the HW RF Kill time to activate... */ if (palive->is_valid == UCODE_VALID_OK) - queue_delayed_work(priv->workqueue, pwork, + queue_delayed_work(il->workqueue, pwork, msecs_to_jiffies(5)); else - IL_WARN(priv, "uCode did not respond OK.\n"); + IL_WARN(il, "uCode did not respond OK.\n"); } -static void il3945_rx_reply_add_sta(struct il_priv *priv, +static void il3945_rx_reply_add_sta(struct il_priv *il, struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG struct il_rx_packet *pkt = rxb_addr(rxb); #endif - IL_DEBUG_RX(priv, "Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); + IL_DEBUG_RX(il, "Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); } -static void il3945_rx_beacon_notif(struct il_priv *priv, +static void il3945_rx_beacon_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); @@ -798,7 +798,7 @@ static void il3945_rx_beacon_notif(struct il_priv *priv, #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG u8 rate = beacon->beacon_notify_hdr.rate; - IL_DEBUG_RX(priv, "beacon status %x retries %d iss %d " + IL_DEBUG_RX(il, "beacon status %x retries %d iss %d " "tsf %d %d rate %d\n", le32_to_cpu(beacon->beacon_notify_hdr.status) & TX_STATUS_MSK, beacon->beacon_notify_hdr.failure_frame, @@ -807,40 +807,40 @@ static void il3945_rx_beacon_notif(struct il_priv *priv, le32_to_cpu(beacon->low_tsf), rate); #endif - priv->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); + il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); } /* Handle notification from uCode that card's power state is changing * due to software, hardware, or critical temperature RFKILL */ -static void il3945_rx_card_state_notif(struct il_priv *priv, +static void il3945_rx_card_state_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); - unsigned long status = priv->status; + unsigned long status = il->status; - IL_WARN(priv, "Card state received: HW:%s SW:%s\n", + IL_WARN(il, "Card state received: HW:%s SW:%s\n", (flags & HW_CARD_DISABLED) ? "Kill" : "On", (flags & SW_CARD_DISABLED) ? "Kill" : "On"); - il_write32(priv, CSR_UCODE_DRV_GP1_SET, + il_write32(il, CSR_UCODE_DRV_GP1_SET, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); if (flags & HW_CARD_DISABLED) - set_bit(STATUS_RF_KILL_HW, &priv->status); + set_bit(STATUS_RF_KILL_HW, &il->status); else - clear_bit(STATUS_RF_KILL_HW, &priv->status); + clear_bit(STATUS_RF_KILL_HW, &il->status); - il_scan_cancel(priv); + il_scan_cancel(il); if ((test_bit(STATUS_RF_KILL_HW, &status) != - test_bit(STATUS_RF_KILL_HW, &priv->status))) - wiphy_rfkill_set_hw_state(priv->hw->wiphy, - test_bit(STATUS_RF_KILL_HW, &priv->status)); + test_bit(STATUS_RF_KILL_HW, &il->status))) + wiphy_rfkill_set_hw_state(il->hw->wiphy, + test_bit(STATUS_RF_KILL_HW, &il->status)); else - wake_up(&priv->wait_command_queue); + wake_up(&il->wait_command_queue); } /** @@ -852,32 +852,32 @@ static void il3945_rx_card_state_notif(struct il_priv *priv, * This function chains into the hardware specific files for them to setup * any hardware specific handlers as well. */ -static void il3945_setup_rx_handlers(struct il_priv *priv) +static void il3945_setup_rx_handlers(struct il_priv *il) { - priv->rx_handlers[REPLY_ALIVE] = il3945_rx_reply_alive; - priv->rx_handlers[REPLY_ADD_STA] = il3945_rx_reply_add_sta; - priv->rx_handlers[REPLY_ERROR] = il_rx_reply_error; - priv->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa; - priv->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = + il->rx_handlers[REPLY_ALIVE] = il3945_rx_reply_alive; + il->rx_handlers[REPLY_ADD_STA] = il3945_rx_reply_add_sta; + il->rx_handlers[REPLY_ERROR] = il_rx_reply_error; + il->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa; + il->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = il_rx_spectrum_measure_notif; - priv->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; - priv->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = + il->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; + il->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = il_rx_pm_debug_statistics_notif; - priv->rx_handlers[BEACON_NOTIFICATION] = il3945_rx_beacon_notif; + il->rx_handlers[BEACON_NOTIFICATION] = il3945_rx_beacon_notif; /* * The same handler is used for both the REPLY to a discrete * statistics request from the host as well as for the periodic * statistics notifications (after received beacons) from the uCode. */ - priv->rx_handlers[REPLY_STATISTICS_CMD] = il3945_reply_statistics; - priv->rx_handlers[STATISTICS_NOTIFICATION] = il3945_hw_rx_statistics; + il->rx_handlers[REPLY_STATISTICS_CMD] = il3945_reply_statistics; + il->rx_handlers[STATISTICS_NOTIFICATION] = il3945_hw_rx_statistics; - il_setup_rx_scan_handlers(priv); - priv->rx_handlers[CARD_STATE_NOTIFICATION] = il3945_rx_card_state_notif; + il_setup_rx_scan_handlers(il); + il->rx_handlers[CARD_STATE_NOTIFICATION] = il3945_rx_card_state_notif; /* Set up hardware specific Rx handlers */ - il3945_hw_rx_handler_setup(priv); + il3945_hw_rx_handler_setup(il); } /************************** RX-FUNCTIONS ****************************/ @@ -947,7 +947,7 @@ static void il3945_setup_rx_handlers(struct il_priv *priv) /** * il3945_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr */ -static inline __le32 il3945_dma_addr2rbd_ptr(struct il_priv *priv, +static inline __le32 il3945_dma_addr2rbd_ptr(struct il_priv *il, dma_addr_t dma_addr) { return cpu_to_le32((u32)dma_addr); @@ -964,9 +964,9 @@ static inline __le32 il3945_dma_addr2rbd_ptr(struct il_priv *priv, * also updates the memory address in the firmware to reference the new * target buffer. */ -static void il3945_rx_queue_restock(struct il_priv *priv) +static void il3945_rx_queue_restock(struct il_priv *il) { - struct il_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &il->rxq; struct list_head *element; struct il_rx_mem_buffer *rxb; unsigned long flags; @@ -981,7 +981,7 @@ static void il3945_rx_queue_restock(struct il_priv *priv) list_del(element); /* Point to Rx buffer via next RBD in circular buffer */ - rxq->bd[rxq->write] = il3945_dma_addr2rbd_ptr(priv, rxb->page_dma); + rxq->bd[rxq->write] = il3945_dma_addr2rbd_ptr(il, rxb->page_dma); rxq->queue[rxq->write] = rxb; rxq->write = (rxq->write + 1) & RX_QUEUE_MASK; rxq->free_count--; @@ -990,7 +990,7 @@ static void il3945_rx_queue_restock(struct il_priv *priv) /* If the pre-allocated buffer pool is dropping low, schedule to * refill it */ if (rxq->free_count <= RX_LOW_WATERMARK) - queue_work(priv->workqueue, &priv->rx_replenish); + queue_work(il->workqueue, &il->rx_replenish); /* If we've added more space for the firmware to place data, tell it. @@ -1000,7 +1000,7 @@ static void il3945_rx_queue_restock(struct il_priv *priv) spin_lock_irqsave(&rxq->lock, flags); rxq->need_update = 1; spin_unlock_irqrestore(&rxq->lock, flags); - il_rx_queue_update_write_ptr(priv, rxq); + il_rx_queue_update_write_ptr(il, rxq); } } @@ -1012,9 +1012,9 @@ static void il3945_rx_queue_restock(struct il_priv *priv) * Also restock the Rx queue via il3945_rx_queue_restock. * This is called as a scheduled work item (except for during initialization) */ -static void il3945_rx_allocate(struct il_priv *priv, gfp_t priority) +static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) { - struct il_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &il->rxq; struct list_head *element; struct il_rx_mem_buffer *rxb; struct page *page; @@ -1033,17 +1033,17 @@ static void il3945_rx_allocate(struct il_priv *priv, gfp_t priority) if (rxq->free_count > RX_LOW_WATERMARK) gfp_mask |= __GFP_NOWARN; - if (priv->hw_params.rx_page_order > 0) + if (il->hw_params.rx_page_order > 0) gfp_mask |= __GFP_COMP; /* Alloc a new receive buffer */ - page = alloc_pages(gfp_mask, priv->hw_params.rx_page_order); + page = alloc_pages(gfp_mask, il->hw_params.rx_page_order); if (!page) { if (net_ratelimit()) - IL_DEBUG_INFO(priv, "Failed to allocate SKB buffer.\n"); + IL_DEBUG_INFO(il, "Failed to allocate SKB buffer.\n"); if ((rxq->free_count <= RX_LOW_WATERMARK) && net_ratelimit()) - IL_CRIT(priv, "Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", + IL_CRIT(il, "Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", priority == GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL", rxq->free_count); /* We don't reschedule replenish work here -- we will @@ -1055,7 +1055,7 @@ static void il3945_rx_allocate(struct il_priv *priv, gfp_t priority) spin_lock_irqsave(&rxq->lock, flags); if (list_empty(&rxq->rx_used)) { spin_unlock_irqrestore(&rxq->lock, flags); - __free_pages(page, priv->hw_params.rx_page_order); + __free_pages(page, il->hw_params.rx_page_order); return; } element = rxq->rx_used.next; @@ -1065,21 +1065,21 @@ static void il3945_rx_allocate(struct il_priv *priv, gfp_t priority) rxb->page = page; /* Get physical address of RB/SKB */ - rxb->page_dma = pci_map_page(priv->pci_dev, page, 0, - PAGE_SIZE << priv->hw_params.rx_page_order, + rxb->page_dma = pci_map_page(il->pci_dev, page, 0, + PAGE_SIZE << il->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); spin_lock_irqsave(&rxq->lock, flags); list_add_tail(&rxb->list, &rxq->rx_free); rxq->free_count++; - priv->alloc_rxb_page++; + il->alloc_rxb_page++; spin_unlock_irqrestore(&rxq->lock, flags); } } -void il3945_rx_queue_reset(struct il_priv *priv, struct il_rx_queue *rxq) +void il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) { unsigned long flags; int i; @@ -1091,10 +1091,10 @@ void il3945_rx_queue_reset(struct il_priv *priv, struct il_rx_queue *rxq) /* In the reset function, these buffers may have been allocated * to an SKB, so we need to unmap and free potential storage */ if (rxq->pool[i].page != NULL) { - pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, - PAGE_SIZE << priv->hw_params.rx_page_order, + pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, + PAGE_SIZE << il->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); - __il_free_pages(priv, rxq->pool[i].page); + __il_free_pages(il, rxq->pool[i].page); rxq->pool[i].page = NULL; } list_add_tail(&rxq->pool[i].list, &rxq->rx_used); @@ -1110,21 +1110,21 @@ void il3945_rx_queue_reset(struct il_priv *priv, struct il_rx_queue *rxq) void il3945_rx_replenish(void *data) { - struct il_priv *priv = data; + struct il_priv *il = data; unsigned long flags; - il3945_rx_allocate(priv, GFP_KERNEL); + il3945_rx_allocate(il, GFP_KERNEL); - spin_lock_irqsave(&priv->lock, flags); - il3945_rx_queue_restock(priv); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); + il3945_rx_queue_restock(il); + spin_unlock_irqrestore(&il->lock, flags); } -static void il3945_rx_replenish_now(struct il_priv *priv) +static void il3945_rx_replenish_now(struct il_priv *il) { - il3945_rx_allocate(priv, GFP_ATOMIC); + il3945_rx_allocate(il, GFP_ATOMIC); - il3945_rx_queue_restock(priv); + il3945_rx_queue_restock(il); } @@ -1133,22 +1133,22 @@ static void il3945_rx_replenish_now(struct il_priv *priv) * This free routine walks the list of POOL entries and if SKB is set to * non NULL it is unmapped and freed */ -static void il3945_rx_queue_free(struct il_priv *priv, struct il_rx_queue *rxq) +static void il3945_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq) { int i; for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { if (rxq->pool[i].page != NULL) { - pci_unmap_page(priv->pci_dev, rxq->pool[i].page_dma, - PAGE_SIZE << priv->hw_params.rx_page_order, + pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, + PAGE_SIZE << il->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); - __il_free_pages(priv, rxq->pool[i].page); + __il_free_pages(il, rxq->pool[i].page); rxq->pool[i].page = NULL; } } - dma_free_coherent(&priv->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, + dma_free_coherent(&il->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, rxq->bd_dma); - dma_free_coherent(&priv->pci_dev->dev, sizeof(struct il_rb_status), + dma_free_coherent(&il->pci_dev->dev, sizeof(struct il_rb_status), rxq->rb_stts, rxq->rb_stts_dma); rxq->bd = NULL; rxq->rb_stts = NULL; @@ -1195,15 +1195,15 @@ int il3945_calc_db_from_ratio(int sig_ratio) /** * il3945_rx_handle - Main entry function for receiving responses from uCode * - * Uses the priv->rx_handlers callback function array to invoke + * Uses the il->rx_handlers callback function array to invoke * the appropriate handlers, including command responses, * frame-received notifications, and other notifications. */ -static void il3945_rx_handle(struct il_priv *priv) +static void il3945_rx_handle(struct il_priv *il) { struct il_rx_mem_buffer *rxb; struct il_rx_packet *pkt; - struct il_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &il->rxq; u32 r, i; int reclaim; unsigned long flags; @@ -1225,7 +1225,7 @@ static void il3945_rx_handle(struct il_priv *priv) fill_rx = 1; /* Rx interrupt, but nothing sent from uCode */ if (i == r) - IL_DEBUG_RX(priv, "r = %d, i = %d\n", r, i); + IL_DEBUG_RX(il, "r = %d, i = %d\n", r, i); while (i != r) { int len; @@ -1239,8 +1239,8 @@ static void il3945_rx_handle(struct il_priv *priv) rxq->queue[i] = NULL; - pci_unmap_page(priv->pci_dev, rxb->page_dma, - PAGE_SIZE << priv->hw_params.rx_page_order, + pci_unmap_page(il->pci_dev, rxb->page_dma, + PAGE_SIZE << il->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); pkt = rxb_addr(rxb); @@ -1260,14 +1260,14 @@ static void il3945_rx_handle(struct il_priv *priv) /* Based on type of command response or notification, * handle those that need handling via function in * rx_handlers table. See il3945_setup_rx_handlers() */ - if (priv->rx_handlers[pkt->hdr.cmd]) { - IL_DEBUG_RX(priv, "r = %d, i = %d, %s, 0x%02x\n", r, i, + if (il->rx_handlers[pkt->hdr.cmd]) { + IL_DEBUG_RX(il, "r = %d, i = %d, %s, 0x%02x\n", r, i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); - priv->isr_stats.rx_handlers[pkt->hdr.cmd]++; - priv->rx_handlers[pkt->hdr.cmd] (priv, rxb); + il->isr_stats.rx_handlers[pkt->hdr.cmd]++; + il->rx_handlers[pkt->hdr.cmd] (il, rxb); } else { /* No handling needed */ - IL_DEBUG_RX(priv, + IL_DEBUG_RX(il, "r %d i %d No handler needed for %s, 0x%02x\n", r, i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); @@ -1285,9 +1285,9 @@ static void il3945_rx_handle(struct il_priv *priv) * and fire off the (possibly) blocking il_send_cmd() * as we reclaim the driver command queue */ if (rxb->page) - il_tx_cmd_complete(priv, rxb); + il_tx_cmd_complete(il, rxb); else - IL_WARN(priv, "Claim null rxb?\n"); + IL_WARN(il, "Claim null rxb?\n"); } /* Reuse the page if possible. For notification packets and @@ -1295,8 +1295,8 @@ static void il3945_rx_handle(struct il_priv *priv) * rx_free list for reuse later. */ spin_lock_irqsave(&rxq->lock, flags); if (rxb->page != NULL) { - rxb->page_dma = pci_map_page(priv->pci_dev, rxb->page, - 0, PAGE_SIZE << priv->hw_params.rx_page_order, + rxb->page_dma = pci_map_page(il->pci_dev, rxb->page, + 0, PAGE_SIZE << il->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); list_add_tail(&rxb->list, &rxq->rx_free); rxq->free_count++; @@ -1312,7 +1312,7 @@ static void il3945_rx_handle(struct il_priv *priv) count++; if (count >= 8) { rxq->read = i; - il3945_rx_replenish_now(priv); + il3945_rx_replenish_now(il); count = 0; } } @@ -1321,17 +1321,17 @@ static void il3945_rx_handle(struct il_priv *priv) /* Backtrack one entry */ rxq->read = i; if (fill_rx) - il3945_rx_replenish_now(priv); + il3945_rx_replenish_now(il); else - il3945_rx_queue_restock(priv); + il3945_rx_queue_restock(il); } /* call this function to flush any scheduled tasklet */ -static inline void il3945_synchronize_irq(struct il_priv *priv) +static inline void il3945_synchronize_irq(struct il_priv *il) { /* wait to make sure we flush pending tasklet*/ - synchronize_irq(priv->pci_dev->irq); - tasklet_kill(&priv->irq_tasklet); + synchronize_irq(il->pci_dev->irq); + tasklet_kill(&il->irq_tasklet); } static const char *il3945_desc_lookup(int i) @@ -1357,55 +1357,55 @@ static const char *il3945_desc_lookup(int i) #define ERROR_START_OFFSET (1 * sizeof(u32)) #define ERROR_ELEM_SIZE (7 * sizeof(u32)) -void il3945_dump_nic_error_log(struct il_priv *priv) +void il3945_dump_nic_error_log(struct il_priv *il) { u32 i; u32 desc, time, count, base, data1; u32 blink1, blink2, ilink1, ilink2; - base = le32_to_cpu(priv->card_alive.error_event_table_ptr); + base = le32_to_cpu(il->card_alive.error_event_table_ptr); if (!il3945_hw_valid_rtc_data_addr(base)) { - IL_ERR(priv, "Not valid error log pointer 0x%08X\n", base); + IL_ERR(il, "Not valid error log pointer 0x%08X\n", base); return; } - count = il_read_targ_mem(priv, base); + count = il_read_targ_mem(il, base); if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { - IL_ERR(priv, "Start IWL Error Log Dump:\n"); - IL_ERR(priv, "Status: 0x%08lX, count: %d\n", - priv->status, count); + IL_ERR(il, "Start IWL Error Log Dump:\n"); + IL_ERR(il, "Status: 0x%08lX, count: %d\n", + il->status, count); } - IL_ERR(priv, "Desc Time asrtPC blink2 " + IL_ERR(il, "Desc Time asrtPC blink2 " "ilink1 nmiPC Line\n"); for (i = ERROR_START_OFFSET; i < (count * ERROR_ELEM_SIZE) + ERROR_START_OFFSET; i += ERROR_ELEM_SIZE) { - desc = il_read_targ_mem(priv, base + i); + desc = il_read_targ_mem(il, base + i); time = - il_read_targ_mem(priv, base + i + 1 * sizeof(u32)); + il_read_targ_mem(il, base + i + 1 * sizeof(u32)); blink1 = - il_read_targ_mem(priv, base + i + 2 * sizeof(u32)); + il_read_targ_mem(il, base + i + 2 * sizeof(u32)); blink2 = - il_read_targ_mem(priv, base + i + 3 * sizeof(u32)); + il_read_targ_mem(il, base + i + 3 * sizeof(u32)); ilink1 = - il_read_targ_mem(priv, base + i + 4 * sizeof(u32)); + il_read_targ_mem(il, base + i + 4 * sizeof(u32)); ilink2 = - il_read_targ_mem(priv, base + i + 5 * sizeof(u32)); + il_read_targ_mem(il, base + i + 5 * sizeof(u32)); data1 = - il_read_targ_mem(priv, base + i + 6 * sizeof(u32)); + il_read_targ_mem(il, base + i + 6 * sizeof(u32)); - IL_ERR(priv, + IL_ERR(il, "%-13s (0x%X) %010u 0x%05X 0x%05X 0x%05X 0x%05X %u\n\n", il3945_desc_lookup(desc), desc, time, blink1, blink2, ilink1, ilink2, data1); } } -static void il3945_irq_tasklet(struct il_priv *priv) +static void il3945_irq_tasklet(struct il_priv *il) { u32 inta, handled = 0; u32 inta_fh; @@ -1414,30 +1414,30 @@ static void il3945_irq_tasklet(struct il_priv *priv) u32 inta_mask; #endif - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); /* Ack/clear/reset pending uCode interrupts. * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS, * and will clear only when CSR_FH_INT_STATUS gets cleared. */ - inta = il_read32(priv, CSR_INT); - il_write32(priv, CSR_INT, inta); + inta = il_read32(il, CSR_INT); + il_write32(il, CSR_INT, inta); /* Ack/clear/reset pending flow-handler (DMA) interrupts. * Any new interrupts that happen after this, either while we're * in this tasklet, or later, will show up in next ISR/tasklet. */ - inta_fh = il_read32(priv, CSR_FH_INT_STATUS); - il_write32(priv, CSR_FH_INT_STATUS, inta_fh); + inta_fh = il_read32(il, CSR_FH_INT_STATUS); + il_write32(il, CSR_FH_INT_STATUS, inta_fh); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (il_get_debug_level(priv) & IL_DL_ISR) { + if (il_get_debug_level(il) & IL_DL_ISR) { /* just for debug */ - inta_mask = il_read32(priv, CSR_INT_MASK); - IL_DEBUG_ISR(priv, "inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", + inta_mask = il_read32(il, CSR_INT_MASK); + IL_DEBUG_ISR(il, "inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, inta_mask, inta_fh); } #endif - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); /* Since CSR_INT and CSR_FH_INT_STATUS reads and clears are not * atomic, make sure that inta covers all the interrupts that @@ -1450,13 +1450,13 @@ static void il3945_irq_tasklet(struct il_priv *priv) /* Now service all interrupt bits discovered above. */ if (inta & CSR_INT_BIT_HW_ERR) { - IL_ERR(priv, "Hardware error detected. Restarting.\n"); + IL_ERR(il, "Hardware error detected. Restarting.\n"); /* Tell the device to stop sending interrupts */ - il_disable_interrupts(priv); + il_disable_interrupts(il); - priv->isr_stats.hw++; - il_irq_handle_error(priv); + il->isr_stats.hw++; + il_irq_handle_error(il); handled |= CSR_INT_BIT_HW_ERR; @@ -1464,18 +1464,18 @@ static void il3945_irq_tasklet(struct il_priv *priv) } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (il_get_debug_level(priv) & (IL_DL_ISR)) { + if (il_get_debug_level(il) & (IL_DL_ISR)) { /* NIC fires this, but we don't use it, redundant with WAKEUP */ if (inta & CSR_INT_BIT_SCD) { - IL_DEBUG_ISR(priv, "Scheduler finished to transmit " + IL_DEBUG_ISR(il, "Scheduler finished to transmit " "the frame/frames.\n"); - priv->isr_stats.sch++; + il->isr_stats.sch++; } /* Alive notification via Rx interrupt will do the real work */ if (inta & CSR_INT_BIT_ALIVE) { - IL_DEBUG_ISR(priv, "Alive interrupt\n"); - priv->isr_stats.alive++; + IL_DEBUG_ISR(il, "Alive interrupt\n"); + il->isr_stats.alive++; } } #endif @@ -1484,25 +1484,25 @@ static void il3945_irq_tasklet(struct il_priv *priv) /* Error detected by uCode */ if (inta & CSR_INT_BIT_SW_ERR) { - IL_ERR(priv, "Microcode SW error detected. " + IL_ERR(il, "Microcode SW error detected. " "Restarting 0x%X.\n", inta); - priv->isr_stats.sw++; - il_irq_handle_error(priv); + il->isr_stats.sw++; + il_irq_handle_error(il); handled |= CSR_INT_BIT_SW_ERR; } /* uCode wakes up after power-down sleep */ if (inta & CSR_INT_BIT_WAKEUP) { - IL_DEBUG_ISR(priv, "Wakeup interrupt\n"); - il_rx_queue_update_write_ptr(priv, &priv->rxq); - il_txq_update_write_ptr(priv, &priv->txq[0]); - il_txq_update_write_ptr(priv, &priv->txq[1]); - il_txq_update_write_ptr(priv, &priv->txq[2]); - il_txq_update_write_ptr(priv, &priv->txq[3]); - il_txq_update_write_ptr(priv, &priv->txq[4]); - il_txq_update_write_ptr(priv, &priv->txq[5]); - - priv->isr_stats.wakeup++; + IL_DEBUG_ISR(il, "Wakeup interrupt\n"); + il_rx_queue_update_write_ptr(il, &il->rxq); + il_txq_update_write_ptr(il, &il->txq[0]); + il_txq_update_write_ptr(il, &il->txq[1]); + il_txq_update_write_ptr(il, &il->txq[2]); + il_txq_update_write_ptr(il, &il->txq[3]); + il_txq_update_write_ptr(il, &il->txq[4]); + il_txq_update_write_ptr(il, &il->txq[5]); + + il->isr_stats.wakeup++; handled |= CSR_INT_BIT_WAKEUP; } @@ -1510,49 +1510,49 @@ static void il3945_irq_tasklet(struct il_priv *priv) * Rx "responses" (frame-received notification), and other * notifications from uCode come through here*/ if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) { - il3945_rx_handle(priv); - priv->isr_stats.rx++; + il3945_rx_handle(il); + il->isr_stats.rx++; handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX); } if (inta & CSR_INT_BIT_FH_TX) { - IL_DEBUG_ISR(priv, "Tx interrupt\n"); - priv->isr_stats.tx++; + IL_DEBUG_ISR(il, "Tx interrupt\n"); + il->isr_stats.tx++; - il_write32(priv, CSR_FH_INT_STATUS, (1 << 6)); - il_write_direct32(priv, FH39_TCSR_CREDIT + il_write32(il, CSR_FH_INT_STATUS, (1 << 6)); + il_write_direct32(il, FH39_TCSR_CREDIT (FH39_SRVC_CHNL), 0x0); handled |= CSR_INT_BIT_FH_TX; } if (inta & ~handled) { - IL_ERR(priv, "Unhandled INTA bits 0x%08x\n", inta & ~handled); - priv->isr_stats.unhandled++; + IL_ERR(il, "Unhandled INTA bits 0x%08x\n", inta & ~handled); + il->isr_stats.unhandled++; } - if (inta & ~priv->inta_mask) { - IL_WARN(priv, "Disabled INTA bits 0x%08x were pending\n", - inta & ~priv->inta_mask); - IL_WARN(priv, " with FH_INT = 0x%08x\n", inta_fh); + if (inta & ~il->inta_mask) { + IL_WARN(il, "Disabled INTA bits 0x%08x were pending\n", + inta & ~il->inta_mask); + IL_WARN(il, " with FH_INT = 0x%08x\n", inta_fh); } /* Re-enable all interrupts */ /* only Re-enable if disabled by irq */ - if (test_bit(STATUS_INT_ENABLED, &priv->status)) - il_enable_interrupts(priv); + if (test_bit(STATUS_INT_ENABLED, &il->status)) + il_enable_interrupts(il); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (il_get_debug_level(priv) & (IL_DL_ISR)) { - inta = il_read32(priv, CSR_INT); - inta_mask = il_read32(priv, CSR_INT_MASK); - inta_fh = il_read32(priv, CSR_FH_INT_STATUS); - IL_DEBUG_ISR(priv, "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " + if (il_get_debug_level(il) & (IL_DL_ISR)) { + inta = il_read32(il, CSR_INT); + inta_mask = il_read32(il, CSR_INT_MASK); + inta_fh = il_read32(il, CSR_FH_INT_STATUS); + IL_DEBUG_ISR(il, "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); } #endif } -static int il3945_get_channels_for_scan(struct il_priv *priv, +static int il3945_get_channels_for_scan(struct il_priv *il, enum ieee80211_band band, u8 is_active, u8 n_probes, struct il3945_scan_channel *scan_ch, @@ -1565,28 +1565,28 @@ static int il3945_get_channels_for_scan(struct il_priv *priv, u16 active_dwell = 0; int added, i; - sband = il_get_hw_mode(priv, band); + sband = il_get_hw_mode(il, band); if (!sband) return 0; - active_dwell = il_get_active_dwell_time(priv, band, n_probes); - passive_dwell = il_get_passive_dwell_time(priv, band, vif); + active_dwell = il_get_active_dwell_time(il, band, n_probes); + passive_dwell = il_get_passive_dwell_time(il, band, vif); if (passive_dwell <= active_dwell) passive_dwell = active_dwell + 1; - for (i = 0, added = 0; i < priv->scan_request->n_channels; i++) { - chan = priv->scan_request->channels[i]; + for (i = 0, added = 0; i < il->scan_request->n_channels; i++) { + chan = il->scan_request->channels[i]; if (chan->band != band) continue; scan_ch->channel = chan->hw_value; - ch_info = il_get_channel_info(priv, band, + ch_info = il_get_channel_info(il, band, scan_ch->channel); if (!il_is_channel_valid(ch_info)) { - IL_DEBUG_SCAN(priv, + IL_DEBUG_SCAN(il, "Channel %d is INVALID for this band.\n", scan_ch->channel); continue; @@ -1600,7 +1600,7 @@ static int il3945_get_channels_for_scan(struct il_priv *priv, if (!is_active || il_is_channel_passive(ch_info) || (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)) { scan_ch->type = 0; /* passive */ - if (IL_UCODE_API(priv->ucode_ver) == 1) + if (IL_UCODE_API(il->ucode_ver) == 1) scan_ch->active_dwell = cpu_to_le16(passive_dwell - 1); } else { scan_ch->type = 1; /* active */ @@ -1610,7 +1610,7 @@ static int il3945_get_channels_for_scan(struct il_priv *priv, * scan channels (probes gets sent right away), * or for passive channels (probes get se sent only after * hearing clear Rx packet).*/ - if (IL_UCODE_API(priv->ucode_ver) >= 2) { + if (IL_UCODE_API(il->ucode_ver) >= 2) { if (n_probes) scan_ch->type |= IWL39_SCAN_PROBE_MASK(n_probes); } else { @@ -1635,7 +1635,7 @@ static int il3945_get_channels_for_scan(struct il_priv *priv, */ } - IL_DEBUG_SCAN(priv, "Scanning %d [%s %d]\n", + IL_DEBUG_SCAN(il, "Scanning %d [%s %d]\n", scan_ch->channel, (scan_ch->type & 1) ? "ACTIVE" : "PASSIVE", (scan_ch->type & 1) ? @@ -1645,11 +1645,11 @@ static int il3945_get_channels_for_scan(struct il_priv *priv, added++; } - IL_DEBUG_SCAN(priv, "total channels to scan %d\n", added); + IL_DEBUG_SCAN(il, "total channels to scan %d\n", added); return added; } -static void il3945_init_hw_rates(struct il_priv *priv, +static void il3945_init_hw_rates(struct il_priv *il, struct ieee80211_rate *rates) { int i; @@ -1675,30 +1675,30 @@ static void il3945_init_hw_rates(struct il_priv *priv, * ******************************************************************************/ -static void il3945_dealloc_ucode_pci(struct il_priv *priv) +static void il3945_dealloc_ucode_pci(struct il_priv *il) { - il_free_fw_desc(priv->pci_dev, &priv->ucode_code); - il_free_fw_desc(priv->pci_dev, &priv->ucode_data); - il_free_fw_desc(priv->pci_dev, &priv->ucode_data_backup); - il_free_fw_desc(priv->pci_dev, &priv->ucode_init); - il_free_fw_desc(priv->pci_dev, &priv->ucode_init_data); - il_free_fw_desc(priv->pci_dev, &priv->ucode_boot); + il_free_fw_desc(il->pci_dev, &il->ucode_code); + il_free_fw_desc(il->pci_dev, &il->ucode_data); + il_free_fw_desc(il->pci_dev, &il->ucode_data_backup); + il_free_fw_desc(il->pci_dev, &il->ucode_init); + il_free_fw_desc(il->pci_dev, &il->ucode_init_data); + il_free_fw_desc(il->pci_dev, &il->ucode_boot); } /** * il3945_verify_inst_full - verify runtime uCode image in card vs. host, * looking at all data. */ -static int il3945_verify_inst_full(struct il_priv *priv, __le32 *image, u32 len) +static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) { u32 val; u32 save_len = len; int rc = 0; u32 errcnt; - IL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); + IL_DEBUG_INFO(il, "ucode inst image size is %u\n", len); - il_write_direct32(priv, HBUS_TARG_MEM_RADDR, + il_write_direct32(il, HBUS_TARG_MEM_RADDR, IWL39_RTC_INST_LOWER_BOUND); errcnt = 0; @@ -1706,9 +1706,9 @@ static int il3945_verify_inst_full(struct il_priv *priv, __le32 *image, u32 len) /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log * if IL_DL_IO is set */ - val = _il_read_direct32(priv, HBUS_TARG_MEM_RDAT); + val = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { - IL_ERR(priv, "uCode INST section is invalid at " + IL_ERR(il, "uCode INST section is invalid at " "offset 0x%x, is 0x%x, s/b 0x%x\n", save_len - len, val, le32_to_cpu(*image)); rc = -EIO; @@ -1720,7 +1720,7 @@ static int il3945_verify_inst_full(struct il_priv *priv, __le32 *image, u32 len) if (!errcnt) - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "ucode image in INSTRUCTION memory is good\n"); return rc; @@ -1732,25 +1732,25 @@ static int il3945_verify_inst_full(struct il_priv *priv, __le32 *image, u32 len) * using sample data 100 bytes apart. If these sample points are good, * it's a pretty good bet that everything between them is good, too. */ -static int il3945_verify_inst_sparse(struct il_priv *priv, __le32 *image, u32 len) +static int il3945_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) { u32 val; int rc = 0; u32 errcnt = 0; u32 i; - IL_DEBUG_INFO(priv, "ucode inst image size is %u\n", len); + IL_DEBUG_INFO(il, "ucode inst image size is %u\n", len); for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log * if IL_DL_IO is set */ - il_write_direct32(priv, HBUS_TARG_MEM_RADDR, + il_write_direct32(il, HBUS_TARG_MEM_RADDR, i + IWL39_RTC_INST_LOWER_BOUND); - val = _il_read_direct32(priv, HBUS_TARG_MEM_RDAT); + val = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { #if 0 /* Enable this if you want to see details */ - IL_ERR(priv, "uCode INST section is invalid at " + IL_ERR(il, "uCode INST section is invalid at " "offset 0x%x, is 0x%x, s/b 0x%x\n", i, val, *image); #endif @@ -1769,55 +1769,55 @@ static int il3945_verify_inst_sparse(struct il_priv *priv, __le32 *image, u32 le * il3945_verify_ucode - determine which instruction image is in SRAM, * and verify its contents */ -static int il3945_verify_ucode(struct il_priv *priv) +static int il3945_verify_ucode(struct il_priv *il) { __le32 *image; u32 len; int rc = 0; /* Try bootstrap */ - image = (__le32 *)priv->ucode_boot.v_addr; - len = priv->ucode_boot.len; - rc = il3945_verify_inst_sparse(priv, image, len); + image = (__le32 *)il->ucode_boot.v_addr; + len = il->ucode_boot.len; + rc = il3945_verify_inst_sparse(il, image, len); if (rc == 0) { - IL_DEBUG_INFO(priv, "Bootstrap uCode is good in inst SRAM\n"); + IL_DEBUG_INFO(il, "Bootstrap uCode is good in inst SRAM\n"); return 0; } /* Try initialize */ - image = (__le32 *)priv->ucode_init.v_addr; - len = priv->ucode_init.len; - rc = il3945_verify_inst_sparse(priv, image, len); + image = (__le32 *)il->ucode_init.v_addr; + len = il->ucode_init.len; + rc = il3945_verify_inst_sparse(il, image, len); if (rc == 0) { - IL_DEBUG_INFO(priv, "Initialize uCode is good in inst SRAM\n"); + IL_DEBUG_INFO(il, "Initialize uCode is good in inst SRAM\n"); return 0; } /* Try runtime/protocol */ - image = (__le32 *)priv->ucode_code.v_addr; - len = priv->ucode_code.len; - rc = il3945_verify_inst_sparse(priv, image, len); + image = (__le32 *)il->ucode_code.v_addr; + len = il->ucode_code.len; + rc = il3945_verify_inst_sparse(il, image, len); if (rc == 0) { - IL_DEBUG_INFO(priv, "Runtime uCode is good in inst SRAM\n"); + IL_DEBUG_INFO(il, "Runtime uCode is good in inst SRAM\n"); return 0; } - IL_ERR(priv, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); + IL_ERR(il, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); /* Since nothing seems to match, show first several data entries in * instruction SRAM, so maybe visual inspection will give a clue. * Selection of bootstrap image (vs. other images) is arbitrary. */ - image = (__le32 *)priv->ucode_boot.v_addr; - len = priv->ucode_boot.len; - rc = il3945_verify_inst_full(priv, image, len); + image = (__le32 *)il->ucode_boot.v_addr; + len = il->ucode_boot.len; + rc = il3945_verify_inst_full(il, image, len); return rc; } -static void il3945_nic_start(struct il_priv *priv) +static void il3945_nic_start(struct il_priv *il) { /* Remove all resets to allow NIC to operate */ - il_write32(priv, CSR_RESET, 0); + il_write32(il, CSR_RESET, 0); } #define IWL3945_UCODE_GET(item) \ @@ -1847,15 +1847,15 @@ IWL3945_UCODE_GET(boot_size); * * Copy into buffers for card to fetch via bus-mastering */ -static int il3945_read_ucode(struct il_priv *priv) +static int il3945_read_ucode(struct il_priv *il) { const struct il_ucode_header *ucode; int ret = -EINVAL, index; const struct firmware *ucode_raw; /* firmware file name contains uCode/driver compatibility version */ - const char *name_pre = priv->cfg->fw_name_pre; - const unsigned int api_max = priv->cfg->ucode_api_max; - const unsigned int api_min = priv->cfg->ucode_api_min; + const char *name_pre = il->cfg->fw_name_pre; + const unsigned int api_max = il->cfg->ucode_api_max; + const unsigned int api_min = il->cfg->ucode_api_min; char buf[25]; u8 *src; size_t len; @@ -1865,9 +1865,9 @@ static int il3945_read_ucode(struct il_priv *priv) * request_firmware() is synchronous, file is in memory on return. */ for (index = api_max; index >= api_min; index--) { sprintf(buf, "%s%u%s", name_pre, index, ".ucode"); - ret = request_firmware(&ucode_raw, buf, &priv->pci_dev->dev); + ret = request_firmware(&ucode_raw, buf, &il->pci_dev->dev); if (ret < 0) { - IL_ERR(priv, "%s firmware file req failed: %d\n", + IL_ERR(il, "%s firmware file req failed: %d\n", buf, ret); if (ret == -ENOENT) continue; @@ -1875,11 +1875,11 @@ static int il3945_read_ucode(struct il_priv *priv) goto error; } else { if (index < api_max) - IL_ERR(priv, "Loaded firmware %s, " + IL_ERR(il, "Loaded firmware %s, " "which is deprecated. " " Please use API v%u instead.\n", buf, api_max); - IL_DEBUG_INFO(priv, "Got firmware '%s' file " + IL_DEBUG_INFO(il, "Got firmware '%s' file " "(%zd bytes) from disk\n", buf, ucode_raw->size); break; @@ -1891,7 +1891,7 @@ static int il3945_read_ucode(struct il_priv *priv) /* Make sure that we got at least our header! */ if (ucode_raw->size < il3945_ucode_get_header_size(1)) { - IL_ERR(priv, "File size way too small!\n"); + IL_ERR(il, "File size way too small!\n"); ret = -EINVAL; goto err_release; } @@ -1899,8 +1899,8 @@ static int il3945_read_ucode(struct il_priv *priv) /* Data from ucode file: header followed by uCode images */ ucode = (struct il_ucode_header *)ucode_raw->data; - priv->ucode_ver = le32_to_cpu(ucode->ver); - api_ver = IL_UCODE_API(priv->ucode_ver); + il->ucode_ver = le32_to_cpu(ucode->ver); + api_ver = IL_UCODE_API(il->ucode_ver); inst_size = il3945_ucode_get_inst_size(ucode); data_size = il3945_ucode_get_data_size(ucode); init_size = il3945_ucode_get_init_size(ucode); @@ -1913,44 +1913,44 @@ static int il3945_read_ucode(struct il_priv *priv) * on the API version read from firmware header from here on forward */ if (api_ver < api_min || api_ver > api_max) { - IL_ERR(priv, "Driver unable to support your firmware API. " + IL_ERR(il, "Driver unable to support your firmware API. " "Driver supports v%u, firmware is v%u.\n", api_max, api_ver); - priv->ucode_ver = 0; + il->ucode_ver = 0; ret = -EINVAL; goto err_release; } if (api_ver != api_max) - IL_ERR(priv, "Firmware has old API version. Expected %u, " + IL_ERR(il, "Firmware has old API version. Expected %u, " "got %u. New firmware can be obtained " "from http://www.intellinuxwireless.org.\n", api_max, api_ver); - IL_INFO(priv, "loaded firmware version %u.%u.%u.%u\n", - IL_UCODE_MAJOR(priv->ucode_ver), - IL_UCODE_MINOR(priv->ucode_ver), - IL_UCODE_API(priv->ucode_ver), - IL_UCODE_SERIAL(priv->ucode_ver)); + IL_INFO(il, "loaded firmware version %u.%u.%u.%u\n", + IL_UCODE_MAJOR(il->ucode_ver), + IL_UCODE_MINOR(il->ucode_ver), + IL_UCODE_API(il->ucode_ver), + IL_UCODE_SERIAL(il->ucode_ver)); - snprintf(priv->hw->wiphy->fw_version, - sizeof(priv->hw->wiphy->fw_version), + snprintf(il->hw->wiphy->fw_version, + sizeof(il->hw->wiphy->fw_version), "%u.%u.%u.%u", - IL_UCODE_MAJOR(priv->ucode_ver), - IL_UCODE_MINOR(priv->ucode_ver), - IL_UCODE_API(priv->ucode_ver), - IL_UCODE_SERIAL(priv->ucode_ver)); - - IL_DEBUG_INFO(priv, "f/w package hdr ucode version raw = 0x%x\n", - priv->ucode_ver); - IL_DEBUG_INFO(priv, "f/w package hdr runtime inst size = %u\n", + IL_UCODE_MAJOR(il->ucode_ver), + IL_UCODE_MINOR(il->ucode_ver), + IL_UCODE_API(il->ucode_ver), + IL_UCODE_SERIAL(il->ucode_ver)); + + IL_DEBUG_INFO(il, "f/w package hdr ucode version raw = 0x%x\n", + il->ucode_ver); + IL_DEBUG_INFO(il, "f/w package hdr runtime inst size = %u\n", inst_size); - IL_DEBUG_INFO(priv, "f/w package hdr runtime data size = %u\n", + IL_DEBUG_INFO(il, "f/w package hdr runtime data size = %u\n", data_size); - IL_DEBUG_INFO(priv, "f/w package hdr init inst size = %u\n", + IL_DEBUG_INFO(il, "f/w package hdr init inst size = %u\n", init_size); - IL_DEBUG_INFO(priv, "f/w package hdr init data size = %u\n", + IL_DEBUG_INFO(il, "f/w package hdr init data size = %u\n", init_data_size); - IL_DEBUG_INFO(priv, "f/w package hdr boot inst size = %u\n", + IL_DEBUG_INFO(il, "f/w package hdr boot inst size = %u\n", boot_size); @@ -1959,7 +1959,7 @@ static int il3945_read_ucode(struct il_priv *priv) inst_size + data_size + init_size + init_data_size + boot_size) { - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "uCode file size %zd does not match expected size\n", ucode_raw->size); ret = -EINVAL; @@ -1968,34 +1968,34 @@ static int il3945_read_ucode(struct il_priv *priv) /* Verify that uCode images will fit in card's SRAM */ if (inst_size > IWL39_MAX_INST_SIZE) { - IL_DEBUG_INFO(priv, "uCode instr len %d too large to fit in\n", + IL_DEBUG_INFO(il, "uCode instr len %d too large to fit in\n", inst_size); ret = -EINVAL; goto err_release; } if (data_size > IWL39_MAX_DATA_SIZE) { - IL_DEBUG_INFO(priv, "uCode data len %d too large to fit in\n", + IL_DEBUG_INFO(il, "uCode data len %d too large to fit in\n", data_size); ret = -EINVAL; goto err_release; } if (init_size > IWL39_MAX_INST_SIZE) { - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "uCode init instr len %d too large to fit in\n", init_size); ret = -EINVAL; goto err_release; } if (init_data_size > IWL39_MAX_DATA_SIZE) { - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "uCode init data len %d too large to fit in\n", init_data_size); ret = -EINVAL; goto err_release; } if (boot_size > IWL39_MAX_BSM_SIZE) { - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "uCode boot instr len %d too large to fit in\n", boot_size); ret = -EINVAL; @@ -2007,37 +2007,37 @@ static int il3945_read_ucode(struct il_priv *priv) /* Runtime instructions and 2 copies of data: * 1) unmodified from disk * 2) backup cache for save/restore during power-downs */ - priv->ucode_code.len = inst_size; - il_alloc_fw_desc(priv->pci_dev, &priv->ucode_code); + il->ucode_code.len = inst_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_code); - priv->ucode_data.len = data_size; - il_alloc_fw_desc(priv->pci_dev, &priv->ucode_data); + il->ucode_data.len = data_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_data); - priv->ucode_data_backup.len = data_size; - il_alloc_fw_desc(priv->pci_dev, &priv->ucode_data_backup); + il->ucode_data_backup.len = data_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_data_backup); - if (!priv->ucode_code.v_addr || !priv->ucode_data.v_addr || - !priv->ucode_data_backup.v_addr) + if (!il->ucode_code.v_addr || !il->ucode_data.v_addr || + !il->ucode_data_backup.v_addr) goto err_pci_alloc; /* Initialization instructions and data */ if (init_size && init_data_size) { - priv->ucode_init.len = init_size; - il_alloc_fw_desc(priv->pci_dev, &priv->ucode_init); + il->ucode_init.len = init_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_init); - priv->ucode_init_data.len = init_data_size; - il_alloc_fw_desc(priv->pci_dev, &priv->ucode_init_data); + il->ucode_init_data.len = init_data_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_init_data); - if (!priv->ucode_init.v_addr || !priv->ucode_init_data.v_addr) + if (!il->ucode_init.v_addr || !il->ucode_init_data.v_addr) goto err_pci_alloc; } /* Bootstrap (instructions only, no data) */ if (boot_size) { - priv->ucode_boot.len = boot_size; - il_alloc_fw_desc(priv->pci_dev, &priv->ucode_boot); + il->ucode_boot.len = boot_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_boot); - if (!priv->ucode_boot.v_addr) + if (!il->ucode_boot.v_addr) goto err_pci_alloc; } @@ -2045,55 +2045,55 @@ static int il3945_read_ucode(struct il_priv *priv) /* Runtime instructions (first block of data in file) */ len = inst_size; - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "Copying (but not loading) uCode instr len %zd\n", len); - memcpy(priv->ucode_code.v_addr, src, len); + memcpy(il->ucode_code.v_addr, src, len); src += len; - IL_DEBUG_INFO(priv, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", - priv->ucode_code.v_addr, (u32)priv->ucode_code.p_addr); + IL_DEBUG_INFO(il, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", + il->ucode_code.v_addr, (u32)il->ucode_code.p_addr); /* Runtime data (2nd block) * NOTE: Copy into backup buffer will be done in il3945_up() */ len = data_size; - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "Copying (but not loading) uCode data len %zd\n", len); - memcpy(priv->ucode_data.v_addr, src, len); - memcpy(priv->ucode_data_backup.v_addr, src, len); + memcpy(il->ucode_data.v_addr, src, len); + memcpy(il->ucode_data_backup.v_addr, src, len); src += len; /* Initialization instructions (3rd block) */ if (init_size) { len = init_size; - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "Copying (but not loading) init instr len %zd\n", len); - memcpy(priv->ucode_init.v_addr, src, len); + memcpy(il->ucode_init.v_addr, src, len); src += len; } /* Initialization data (4th block) */ if (init_data_size) { len = init_data_size; - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "Copying (but not loading) init data len %zd\n", len); - memcpy(priv->ucode_init_data.v_addr, src, len); + memcpy(il->ucode_init_data.v_addr, src, len); src += len; } /* Bootstrap instructions (5th block) */ len = boot_size; - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "Copying (but not loading) boot instr len %zd\n", len); - memcpy(priv->ucode_boot.v_addr, src, len); + memcpy(il->ucode_boot.v_addr, src, len); /* We have our copies now, allow OS release its copies */ release_firmware(ucode_raw); return 0; err_pci_alloc: - IL_ERR(priv, "failed to allocate pci memory\n"); + IL_ERR(il, "failed to allocate pci memory\n"); ret = -ENOMEM; - il3945_dealloc_ucode_pci(priv); + il3945_dealloc_ucode_pci(il); err_release: release_firmware(ucode_raw); @@ -2112,27 +2112,27 @@ static int il3945_read_ucode(struct il_priv *priv) * We need to replace them to load runtime uCode inst and data, * and to save runtime data when powering down. */ -static int il3945_set_ucode_ptrs(struct il_priv *priv) +static int il3945_set_ucode_ptrs(struct il_priv *il) { dma_addr_t pinst; dma_addr_t pdata; /* bits 31:0 for 3945 */ - pinst = priv->ucode_code.p_addr; - pdata = priv->ucode_data_backup.p_addr; + pinst = il->ucode_code.p_addr; + pdata = il->ucode_data_backup.p_addr; /* Tell bootstrap uCode where to find image to load */ - il_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); - il_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); - il_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, - priv->ucode_data.len); + il_write_prph(il, BSM_DRAM_INST_PTR_REG, pinst); + il_write_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); + il_write_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, + il->ucode_data.len); /* Inst byte count must be last to set up, bit 31 signals uCode * that all new ptr/size info is in place */ - il_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, - priv->ucode_code.len | BSM_DRAM_INST_LOAD); + il_write_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, + il->ucode_code.len | BSM_DRAM_INST_LOAD); - IL_DEBUG_INFO(priv, "Runtime uCode pointers are set.\n"); + IL_DEBUG_INFO(il, "Runtime uCode pointers are set.\n"); return 0; } @@ -2144,40 +2144,40 @@ static int il3945_set_ucode_ptrs(struct il_priv *priv) * * Tell "initialize" uCode to go ahead and load the runtime uCode. */ -static void il3945_init_alive_start(struct il_priv *priv) +static void il3945_init_alive_start(struct il_priv *il) { /* Check alive response for "valid" sign from uCode */ - if (priv->card_alive_init.is_valid != UCODE_VALID_OK) { + if (il->card_alive_init.is_valid != UCODE_VALID_OK) { /* We had an error bringing up the hardware, so take it * all the way back down so we can try again */ - IL_DEBUG_INFO(priv, "Initialize Alive failed.\n"); + IL_DEBUG_INFO(il, "Initialize Alive failed.\n"); goto restart; } /* Bootstrap uCode has loaded initialize uCode ... verify inst image. * This is a paranoid check, because we would not have gotten the * "initialize" alive if code weren't properly loaded. */ - if (il3945_verify_ucode(priv)) { + if (il3945_verify_ucode(il)) { /* Runtime instruction load was bad; * take it all the way back down so we can try again */ - IL_DEBUG_INFO(priv, "Bad \"initialize\" uCode load.\n"); + IL_DEBUG_INFO(il, "Bad \"initialize\" uCode load.\n"); goto restart; } /* Send pointers to protocol/runtime uCode image ... init code will * load and launch runtime uCode, which will send us another "Alive" * notification. */ - IL_DEBUG_INFO(priv, "Initialization Alive received.\n"); - if (il3945_set_ucode_ptrs(priv)) { + IL_DEBUG_INFO(il, "Initialization Alive received.\n"); + if (il3945_set_ucode_ptrs(il)) { /* Runtime instruction load won't happen; * take it all the way back down so we can try again */ - IL_DEBUG_INFO(priv, "Couldn't set up uCode pointers.\n"); + IL_DEBUG_INFO(il, "Couldn't set up uCode pointers.\n"); goto restart; } return; restart: - queue_work(priv->workqueue, &priv->restart); + queue_work(il->workqueue, &il->restart); } /** @@ -2185,65 +2185,65 @@ static void il3945_init_alive_start(struct il_priv *priv) * from protocol/runtime uCode (initialization uCode's * Alive gets handled by il3945_init_alive_start()). */ -static void il3945_alive_start(struct il_priv *priv) +static void il3945_alive_start(struct il_priv *il) { int thermal_spin = 0; u32 rfkill; - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; - IL_DEBUG_INFO(priv, "Runtime Alive received.\n"); + IL_DEBUG_INFO(il, "Runtime Alive received.\n"); - if (priv->card_alive.is_valid != UCODE_VALID_OK) { + if (il->card_alive.is_valid != UCODE_VALID_OK) { /* We had an error bringing up the hardware, so take it * all the way back down so we can try again */ - IL_DEBUG_INFO(priv, "Alive failed.\n"); + IL_DEBUG_INFO(il, "Alive failed.\n"); goto restart; } /* Initialize uCode has loaded Runtime uCode ... verify inst image. * This is a paranoid check, because we would not have gotten the * "runtime" alive if code weren't properly loaded. */ - if (il3945_verify_ucode(priv)) { + if (il3945_verify_ucode(il)) { /* Runtime instruction load was bad; * take it all the way back down so we can try again */ - IL_DEBUG_INFO(priv, "Bad runtime uCode load.\n"); + IL_DEBUG_INFO(il, "Bad runtime uCode load.\n"); goto restart; } - rfkill = il_read_prph(priv, APMG_RFKILL_REG); - IL_DEBUG_INFO(priv, "RFKILL status: 0x%x\n", rfkill); + rfkill = il_read_prph(il, APMG_RFKILL_REG); + IL_DEBUG_INFO(il, "RFKILL status: 0x%x\n", rfkill); if (rfkill & 0x1) { - clear_bit(STATUS_RF_KILL_HW, &priv->status); + clear_bit(STATUS_RF_KILL_HW, &il->status); /* if RFKILL is not on, then wait for thermal * sensor in adapter to kick in */ - while (il3945_hw_get_temperature(priv) == 0) { + while (il3945_hw_get_temperature(il) == 0) { thermal_spin++; udelay(10); } if (thermal_spin) - IL_DEBUG_INFO(priv, "Thermal calibration took %dus\n", + IL_DEBUG_INFO(il, "Thermal calibration took %dus\n", thermal_spin * 10); } else - set_bit(STATUS_RF_KILL_HW, &priv->status); + set_bit(STATUS_RF_KILL_HW, &il->status); /* After the ALIVE response, we can send commands to 3945 uCode */ - set_bit(STATUS_ALIVE, &priv->status); + set_bit(STATUS_ALIVE, &il->status); /* Enable watchdog to monitor the driver tx queues */ - il_setup_watchdog(priv); + il_setup_watchdog(il); - if (il_is_rfkill(priv)) + if (il_is_rfkill(il)) return; - ieee80211_wake_queues(priv->hw); + ieee80211_wake_queues(il->hw); - priv->active_rate = IL_RATES_MASK_3945; + il->active_rate = IL_RATES_MASK_3945; - il_power_update_mode(priv, true); + il_power_update_mode(il, true); - if (il_is_associated(priv, IL_RXON_CTX_BSS)) { + if (il_is_associated(il, IL_RXON_CTX_BSS)) { struct il3945_rxon_cmd *active_rxon = (struct il3945_rxon_cmd *)(&ctx->active); @@ -2251,205 +2251,205 @@ static void il3945_alive_start(struct il_priv *priv) active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; } else { /* Initialize our rx_config data */ - il_connection_init_rx_config(priv, ctx); + il_connection_init_rx_config(il, ctx); } /* Configure Bluetooth device coexistence support */ - il_send_bt_config(priv); + il_send_bt_config(il); - set_bit(STATUS_READY, &priv->status); + set_bit(STATUS_READY, &il->status); /* Configure the adapter for unassociated operation */ - il3945_commit_rxon(priv, ctx); + il3945_commit_rxon(il, ctx); - il3945_reg_txpower_periodic(priv); + il3945_reg_txpower_periodic(il); - IL_DEBUG_INFO(priv, "ALIVE processing complete.\n"); - wake_up(&priv->wait_command_queue); + IL_DEBUG_INFO(il, "ALIVE processing complete.\n"); + wake_up(&il->wait_command_queue); return; restart: - queue_work(priv->workqueue, &priv->restart); + queue_work(il->workqueue, &il->restart); } -static void il3945_cancel_deferred_work(struct il_priv *priv); +static void il3945_cancel_deferred_work(struct il_priv *il); -static void __il3945_down(struct il_priv *priv) +static void __il3945_down(struct il_priv *il) { unsigned long flags; int exit_pending; - IL_DEBUG_INFO(priv, DRV_NAME " is going down\n"); + IL_DEBUG_INFO(il, DRV_NAME " is going down\n"); - il_scan_cancel_timeout(priv, 200); + il_scan_cancel_timeout(il, 200); - exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &priv->status); + exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &il->status); /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set * to prevent rearm timer */ - del_timer_sync(&priv->watchdog); + del_timer_sync(&il->watchdog); /* Station information will now be cleared in device */ - il_clear_ucode_stations(priv, NULL); - il_dealloc_bcast_stations(priv); - il_clear_driver_stations(priv); + il_clear_ucode_stations(il, NULL); + il_dealloc_bcast_stations(il); + il_clear_driver_stations(il); /* Unblock any waiting calls */ - wake_up_all(&priv->wait_command_queue); + wake_up_all(&il->wait_command_queue); /* Wipe out the EXIT_PENDING status bit if we are not actually * exiting the module */ if (!exit_pending) - clear_bit(STATUS_EXIT_PENDING, &priv->status); + clear_bit(STATUS_EXIT_PENDING, &il->status); /* stop and reset the on-board processor */ - il_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + il_write32(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); /* tell the device to stop sending interrupts */ - spin_lock_irqsave(&priv->lock, flags); - il_disable_interrupts(priv); - spin_unlock_irqrestore(&priv->lock, flags); - il3945_synchronize_irq(priv); + spin_lock_irqsave(&il->lock, flags); + il_disable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); + il3945_synchronize_irq(il); - if (priv->mac80211_registered) - ieee80211_stop_queues(priv->hw); + if (il->mac80211_registered) + ieee80211_stop_queues(il->hw); /* If we have not previously called il3945_init() then * clear all bits but the RF Kill bits and return */ - if (!il_is_init(priv)) { - priv->status = test_bit(STATUS_RF_KILL_HW, &priv->status) << + if (!il_is_init(il)) { + il->status = test_bit(STATUS_RF_KILL_HW, &il->status) << STATUS_RF_KILL_HW | - test_bit(STATUS_GEO_CONFIGURED, &priv->status) << + test_bit(STATUS_GEO_CONFIGURED, &il->status) << STATUS_GEO_CONFIGURED | - test_bit(STATUS_EXIT_PENDING, &priv->status) << + test_bit(STATUS_EXIT_PENDING, &il->status) << STATUS_EXIT_PENDING; goto exit; } /* ...otherwise clear out all the status bits but the RF Kill * bit and continue taking the NIC down. */ - priv->status &= test_bit(STATUS_RF_KILL_HW, &priv->status) << + il->status &= test_bit(STATUS_RF_KILL_HW, &il->status) << STATUS_RF_KILL_HW | - test_bit(STATUS_GEO_CONFIGURED, &priv->status) << + test_bit(STATUS_GEO_CONFIGURED, &il->status) << STATUS_GEO_CONFIGURED | - test_bit(STATUS_FW_ERROR, &priv->status) << + test_bit(STATUS_FW_ERROR, &il->status) << STATUS_FW_ERROR | - test_bit(STATUS_EXIT_PENDING, &priv->status) << + test_bit(STATUS_EXIT_PENDING, &il->status) << STATUS_EXIT_PENDING; - il3945_hw_txq_ctx_stop(priv); - il3945_hw_rxq_stop(priv); + il3945_hw_txq_ctx_stop(il); + il3945_hw_rxq_stop(il); /* Power-down device's busmaster DMA clocks */ - il_write_prph(priv, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); + il_write_prph(il, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); udelay(5); /* Stop the device, and put it in low power state */ - il_apm_stop(priv); + il_apm_stop(il); exit: - memset(&priv->card_alive, 0, sizeof(struct il_alive_resp)); + memset(&il->card_alive, 0, sizeof(struct il_alive_resp)); - if (priv->beacon_skb) - dev_kfree_skb(priv->beacon_skb); - priv->beacon_skb = NULL; + if (il->beacon_skb) + dev_kfree_skb(il->beacon_skb); + il->beacon_skb = NULL; /* clear out any free frames */ - il3945_clear_free_frames(priv); + il3945_clear_free_frames(il); } -static void il3945_down(struct il_priv *priv) +static void il3945_down(struct il_priv *il) { - mutex_lock(&priv->mutex); - __il3945_down(priv); - mutex_unlock(&priv->mutex); + mutex_lock(&il->mutex); + __il3945_down(il); + mutex_unlock(&il->mutex); - il3945_cancel_deferred_work(priv); + il3945_cancel_deferred_work(il); } #define MAX_HW_RESTARTS 5 -static int il3945_alloc_bcast_station(struct il_priv *priv) +static int il3945_alloc_bcast_station(struct il_priv *il) { - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; unsigned long flags; u8 sta_id; - spin_lock_irqsave(&priv->sta_lock, flags); - sta_id = il_prep_station(priv, ctx, + spin_lock_irqsave(&il->sta_lock, flags); + sta_id = il_prep_station(il, ctx, iwlegacy_bcast_addr, false, NULL); if (sta_id == IL_INVALID_STATION) { - IL_ERR(priv, "Unable to prepare broadcast station\n"); - spin_unlock_irqrestore(&priv->sta_lock, flags); + IL_ERR(il, "Unable to prepare broadcast station\n"); + spin_unlock_irqrestore(&il->sta_lock, flags); return -EINVAL; } - priv->stations[sta_id].used |= IL_STA_DRIVER_ACTIVE; - priv->stations[sta_id].used |= IL_STA_BCAST; - spin_unlock_irqrestore(&priv->sta_lock, flags); + il->stations[sta_id].used |= IL_STA_DRIVER_ACTIVE; + il->stations[sta_id].used |= IL_STA_BCAST; + spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } -static int __il3945_up(struct il_priv *priv) +static int __il3945_up(struct il_priv *il) { int rc, i; - rc = il3945_alloc_bcast_station(priv); + rc = il3945_alloc_bcast_station(il); if (rc) return rc; - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { - IL_WARN(priv, "Exit pending; will not bring the NIC up\n"); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) { + IL_WARN(il, "Exit pending; will not bring the NIC up\n"); return -EIO; } - if (!priv->ucode_data_backup.v_addr || !priv->ucode_data.v_addr) { - IL_ERR(priv, "ucode not available for device bring up\n"); + if (!il->ucode_data_backup.v_addr || !il->ucode_data.v_addr) { + IL_ERR(il, "ucode not available for device bring up\n"); return -EIO; } /* If platform's RF_KILL switch is NOT set to KILL */ - if (il_read32(priv, CSR_GP_CNTRL) & + if (il_read32(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) - clear_bit(STATUS_RF_KILL_HW, &priv->status); + clear_bit(STATUS_RF_KILL_HW, &il->status); else { - set_bit(STATUS_RF_KILL_HW, &priv->status); - IL_WARN(priv, "Radio disabled by HW RF Kill switch\n"); + set_bit(STATUS_RF_KILL_HW, &il->status); + IL_WARN(il, "Radio disabled by HW RF Kill switch\n"); return -ENODEV; } - il_write32(priv, CSR_INT, 0xFFFFFFFF); + il_write32(il, CSR_INT, 0xFFFFFFFF); - rc = il3945_hw_nic_init(priv); + rc = il3945_hw_nic_init(il); if (rc) { - IL_ERR(priv, "Unable to int nic\n"); + IL_ERR(il, "Unable to int nic\n"); return rc; } /* make sure rfkill handshake bits are cleared */ - il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - il_write32(priv, CSR_UCODE_DRV_GP1_CLR, + il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); /* clear (again), then enable host interrupts */ - il_write32(priv, CSR_INT, 0xFFFFFFFF); - il_enable_interrupts(priv); + il_write32(il, CSR_INT, 0xFFFFFFFF); + il_enable_interrupts(il); /* really make sure rfkill handshake bits are cleared */ - il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); /* Copy original ucode data image from disk into backup cache. * This will be used to initialize the on-board processor's * data SRAM for a clean start when the runtime program first loads. */ - memcpy(priv->ucode_data_backup.v_addr, priv->ucode_data.v_addr, - priv->ucode_data.len); + memcpy(il->ucode_data_backup.v_addr, il->ucode_data.v_addr, + il->ucode_data.len); /* We return success when we resume from suspend and rf_kill is on. */ - if (test_bit(STATUS_RF_KILL_HW, &priv->status)) + if (test_bit(STATUS_RF_KILL_HW, &il->status)) return 0; for (i = 0; i < MAX_HW_RESTARTS; i++) { @@ -2457,29 +2457,29 @@ static int __il3945_up(struct il_priv *priv) /* load bootstrap state machine, * load bootstrap program into processor's memory, * prepare to load the "initialize" uCode */ - rc = priv->cfg->ops->lib->load_ucode(priv); + rc = il->cfg->ops->lib->load_ucode(il); if (rc) { - IL_ERR(priv, + IL_ERR(il, "Unable to set up bootstrap uCode: %d\n", rc); continue; } /* start card; "initialize" will load runtime ucode */ - il3945_nic_start(priv); + il3945_nic_start(il); - IL_DEBUG_INFO(priv, DRV_NAME " is coming up\n"); + IL_DEBUG_INFO(il, DRV_NAME " is coming up\n"); return 0; } - set_bit(STATUS_EXIT_PENDING, &priv->status); - __il3945_down(priv); - clear_bit(STATUS_EXIT_PENDING, &priv->status); + set_bit(STATUS_EXIT_PENDING, &il->status); + __il3945_down(il); + clear_bit(STATUS_EXIT_PENDING, &il->status); /* tried to restart and config the device for as long as our * patience could withstand */ - IL_ERR(priv, "Unable to initialize device after %d attempts.\n", i); + IL_ERR(il, "Unable to initialize device after %d attempts.\n", i); return -EIO; } @@ -2492,30 +2492,30 @@ static int __il3945_up(struct il_priv *priv) static void il3945_bg_init_alive_start(struct work_struct *data) { - struct il_priv *priv = + struct il_priv *il = container_of(data, struct il_priv, init_alive_start.work); - mutex_lock(&priv->mutex); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) goto out; - il3945_init_alive_start(priv); + il3945_init_alive_start(il); out: - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); } static void il3945_bg_alive_start(struct work_struct *data) { - struct il_priv *priv = + struct il_priv *il = container_of(data, struct il_priv, alive_start.work); - mutex_lock(&priv->mutex); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) goto out; - il3945_alive_start(priv); + il3945_alive_start(il); out: - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); } /* @@ -2526,32 +2526,32 @@ out: */ static void il3945_rfkill_poll(struct work_struct *data) { - struct il_priv *priv = + struct il_priv *il = container_of(data, struct il_priv, _3945.rfkill_poll.work); - bool old_rfkill = test_bit(STATUS_RF_KILL_HW, &priv->status); - bool new_rfkill = !(il_read32(priv, CSR_GP_CNTRL) + bool old_rfkill = test_bit(STATUS_RF_KILL_HW, &il->status); + bool new_rfkill = !(il_read32(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW); if (new_rfkill != old_rfkill) { if (new_rfkill) - set_bit(STATUS_RF_KILL_HW, &priv->status); + set_bit(STATUS_RF_KILL_HW, &il->status); else - clear_bit(STATUS_RF_KILL_HW, &priv->status); + clear_bit(STATUS_RF_KILL_HW, &il->status); - wiphy_rfkill_set_hw_state(priv->hw->wiphy, new_rfkill); + wiphy_rfkill_set_hw_state(il->hw->wiphy, new_rfkill); - IL_DEBUG_RF_KILL(priv, "RF_KILL bit toggled to %s.\n", + IL_DEBUG_RF_KILL(il, "RF_KILL bit toggled to %s.\n", new_rfkill ? "disable radio" : "enable radio"); } /* Keep this running, even if radio now enabled. This will be * cancelled in mac_start() if system decides to start again */ - queue_delayed_work(priv->workqueue, &priv->_3945.rfkill_poll, + queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, round_jiffies_relative(2 * HZ)); } -int il3945_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) +int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) { struct il_host_cmd cmd = { .id = REPLY_SCAN_CMD, @@ -2565,29 +2565,29 @@ int il3945_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) int ret; u16 len; - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - if (!priv->scan_cmd) { - priv->scan_cmd = kmalloc(sizeof(struct il3945_scan_cmd) + + if (!il->scan_cmd) { + il->scan_cmd = kmalloc(sizeof(struct il3945_scan_cmd) + IL_MAX_SCAN_SIZE, GFP_KERNEL); - if (!priv->scan_cmd) { - IL_DEBUG_SCAN(priv, "Fail to allocate scan memory\n"); + if (!il->scan_cmd) { + IL_DEBUG_SCAN(il, "Fail to allocate scan memory\n"); return -ENOMEM; } } - scan = priv->scan_cmd; + scan = il->scan_cmd; memset(scan, 0, sizeof(struct il3945_scan_cmd) + IL_MAX_SCAN_SIZE); scan->quiet_plcp_th = IL_PLCP_QUIET_THRESH; scan->quiet_time = IL_ACTIVE_QUIET_TIME; - if (il_is_associated(priv, IL_RXON_CTX_BSS)) { + if (il_is_associated(il, IL_RXON_CTX_BSS)) { u16 interval; u32 extra; u32 suspend_time = 100; u32 scan_suspend_time = 100; - IL_DEBUG_INFO(priv, "Scanning while associated...\n"); + IL_DEBUG_INFO(il, "Scanning while associated...\n"); interval = vif->bss_conf.beacon_int; @@ -2607,39 +2607,39 @@ int il3945_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) (extra | ((suspend_time % interval) * 1024)); scan->suspend_time = cpu_to_le32(scan_suspend_time); - IL_DEBUG_SCAN(priv, "suspend_time 0x%X beacon interval %d\n", + IL_DEBUG_SCAN(il, "suspend_time 0x%X beacon interval %d\n", scan_suspend_time, interval); } - if (priv->scan_request->n_ssids) { + if (il->scan_request->n_ssids) { int i, p = 0; - IL_DEBUG_SCAN(priv, "Kicking off active scan\n"); - for (i = 0; i < priv->scan_request->n_ssids; i++) { + IL_DEBUG_SCAN(il, "Kicking off active scan\n"); + for (i = 0; i < il->scan_request->n_ssids; i++) { /* always does wildcard anyway */ - if (!priv->scan_request->ssids[i].ssid_len) + if (!il->scan_request->ssids[i].ssid_len) continue; scan->direct_scan[p].id = WLAN_EID_SSID; scan->direct_scan[p].len = - priv->scan_request->ssids[i].ssid_len; + il->scan_request->ssids[i].ssid_len; memcpy(scan->direct_scan[p].ssid, - priv->scan_request->ssids[i].ssid, - priv->scan_request->ssids[i].ssid_len); + il->scan_request->ssids[i].ssid, + il->scan_request->ssids[i].ssid_len); n_probes++; p++; } is_active = true; } else - IL_DEBUG_SCAN(priv, "Kicking off passive scan.\n"); + IL_DEBUG_SCAN(il, "Kicking off passive scan.\n"); /* We don't build a direct scan probe request; the uCode will do * that based on the direct_mask added to each channel entry */ scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; - scan->tx_cmd.sta_id = priv->contexts[IL_RXON_CTX_BSS].bcast_sta_id; + scan->tx_cmd.sta_id = il->contexts[IL_RXON_CTX_BSS].bcast_sta_id; scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; /* flags + rate selection */ - switch (priv->scan_band) { + switch (il->scan_band) { case IEEE80211_BAND_2GHZ: scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; scan->tx_cmd.rate = IL_RATE_1M_PLCP; @@ -2650,7 +2650,7 @@ int il3945_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) band = IEEE80211_BAND_5GHZ; break; default: - IL_WARN(priv, "Invalid scan band\n"); + IL_WARN(il, "Invalid scan band\n"); return -EIO; } @@ -2662,19 +2662,19 @@ int il3945_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) scan->good_CRC_th = is_active ? IL_GOOD_CRC_TH_DEFAULT : IL_GOOD_CRC_TH_DISABLED; - len = il_fill_probe_req(priv, (struct ieee80211_mgmt *)scan->data, - vif->addr, priv->scan_request->ie, - priv->scan_request->ie_len, + len = il_fill_probe_req(il, (struct ieee80211_mgmt *)scan->data, + vif->addr, il->scan_request->ie, + il->scan_request->ie_len, IL_MAX_SCAN_SIZE - sizeof(*scan)); scan->tx_cmd.len = cpu_to_le16(len); /* select Rx antennas */ - scan->flags |= il3945_get_antenna_flags(priv); + scan->flags |= il3945_get_antenna_flags(il); - scan->channel_count = il3945_get_channels_for_scan(priv, band, is_active, n_probes, + scan->channel_count = il3945_get_channels_for_scan(il, band, is_active, n_probes, (void *)&scan->data[len], vif); if (scan->channel_count == 0) { - IL_DEBUG_SCAN(priv, "channel count %d\n", scan->channel_count); + IL_DEBUG_SCAN(il, "channel count %d\n", scan->channel_count); return -EIO; } @@ -2683,101 +2683,101 @@ int il3945_request_scan(struct il_priv *priv, struct ieee80211_vif *vif) cmd.data = scan; scan->len = cpu_to_le16(cmd.len); - set_bit(STATUS_SCAN_HW, &priv->status); - ret = il_send_cmd_sync(priv, &cmd); + set_bit(STATUS_SCAN_HW, &il->status); + ret = il_send_cmd_sync(il, &cmd); if (ret) - clear_bit(STATUS_SCAN_HW, &priv->status); + clear_bit(STATUS_SCAN_HW, &il->status); return ret; } -void il3945_post_scan(struct il_priv *priv) +void il3945_post_scan(struct il_priv *il) { - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; /* * Since setting the RXON may have been deferred while * performing the scan, fire one off if needed */ if (memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) - il3945_commit_rxon(priv, ctx); + il3945_commit_rxon(il, ctx); } static void il3945_bg_restart(struct work_struct *data) { - struct il_priv *priv = container_of(data, struct il_priv, restart); + struct il_priv *il = container_of(data, struct il_priv, restart); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; - if (test_and_clear_bit(STATUS_FW_ERROR, &priv->status)) { + if (test_and_clear_bit(STATUS_FW_ERROR, &il->status)) { struct il_rxon_context *ctx; - mutex_lock(&priv->mutex); - for_each_context(priv, ctx) + mutex_lock(&il->mutex); + for_each_context(il, ctx) ctx->vif = NULL; - priv->is_open = 0; - mutex_unlock(&priv->mutex); - il3945_down(priv); - ieee80211_restart_hw(priv->hw); + il->is_open = 0; + mutex_unlock(&il->mutex); + il3945_down(il); + ieee80211_restart_hw(il->hw); } else { - il3945_down(priv); + il3945_down(il); - mutex_lock(&priv->mutex); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { - mutex_unlock(&priv->mutex); + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) { + mutex_unlock(&il->mutex); return; } - __il3945_up(priv); - mutex_unlock(&priv->mutex); + __il3945_up(il); + mutex_unlock(&il->mutex); } } static void il3945_bg_rx_replenish(struct work_struct *data) { - struct il_priv *priv = + struct il_priv *il = container_of(data, struct il_priv, rx_replenish); - mutex_lock(&priv->mutex); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) goto out; - il3945_rx_replenish(priv); + il3945_rx_replenish(il); out: - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); } -void il3945_post_associate(struct il_priv *priv) +void il3945_post_associate(struct il_priv *il) { int rc = 0; struct ieee80211_conf *conf = NULL; - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; - if (!ctx->vif || !priv->is_open) + if (!ctx->vif || !il->is_open) return; - IL_DEBUG_ASSOC(priv, "Associated as %d to: %pM\n", + IL_DEBUG_ASSOC(il, "Associated as %d to: %pM\n", ctx->vif->bss_conf.aid, ctx->active.bssid_addr); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; - il_scan_cancel_timeout(priv, 200); + il_scan_cancel_timeout(il, 200); - conf = il_ieee80211_get_hw_conf(priv->hw); + conf = il_ieee80211_get_hw_conf(il->hw); ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - il3945_commit_rxon(priv, ctx); + il3945_commit_rxon(il, ctx); - rc = il_send_rxon_timing(priv, ctx); + rc = il_send_rxon_timing(il, ctx); if (rc) - IL_WARN(priv, "REPLY_RXON_TIMING failed - " + IL_WARN(il, "REPLY_RXON_TIMING failed - " "Attempting to continue.\n"); ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; ctx->staging.assoc_id = cpu_to_le16(ctx->vif->bss_conf.aid); - IL_DEBUG_ASSOC(priv, "assoc id %d beacon interval %d\n", + IL_DEBUG_ASSOC(il, "assoc id %d beacon interval %d\n", ctx->vif->bss_conf.aid, ctx->vif->bss_conf.beacon_int); if (ctx->vif->bss_conf.use_short_preamble) @@ -2792,17 +2792,17 @@ void il3945_post_associate(struct il_priv *priv) ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; } - il3945_commit_rxon(priv, ctx); + il3945_commit_rxon(il, ctx); switch (ctx->vif->type) { case NL80211_IFTYPE_STATION: - il3945_rate_scale_init(priv->hw, IL_AP_ID); + il3945_rate_scale_init(il->hw, IL_AP_ID); break; case NL80211_IFTYPE_ADHOC: - il3945_send_beacon_cmd(priv); + il3945_send_beacon_cmd(il); break; default: - IL_ERR(priv, "%s Should not be called in %d mode\n", + IL_ERR(il, "%s Should not be called in %d mode\n", __func__, ctx->vif->type); break; } @@ -2818,43 +2818,43 @@ void il3945_post_associate(struct il_priv *priv) static int il3945_mac_start(struct ieee80211_hw *hw) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; int ret; - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); /* we should be verifying the device is ready to be opened */ - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); /* fetch ucode file from disk, alloc and copy to bus-master buffers ... * ucode filename and max sizes are card-specific. */ - if (!priv->ucode_code.len) { - ret = il3945_read_ucode(priv); + if (!il->ucode_code.len) { + ret = il3945_read_ucode(il); if (ret) { - IL_ERR(priv, "Could not read microcode: %d\n", ret); - mutex_unlock(&priv->mutex); + IL_ERR(il, "Could not read microcode: %d\n", ret); + mutex_unlock(&il->mutex); goto out_release_irq; } } - ret = __il3945_up(priv); + ret = __il3945_up(il); - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); if (ret) goto out_release_irq; - IL_DEBUG_INFO(priv, "Start UP work.\n"); + IL_DEBUG_INFO(il, "Start UP work.\n"); /* Wait for START_ALIVE from ucode. Otherwise callbacks from * mac80211 will not be run successfully. */ - ret = wait_event_timeout(priv->wait_command_queue, - test_bit(STATUS_READY, &priv->status), + ret = wait_event_timeout(il->wait_command_queue, + test_bit(STATUS_READY, &il->status), UCODE_READY_TIMEOUT); if (!ret) { - if (!test_bit(STATUS_READY, &priv->status)) { - IL_ERR(priv, + if (!test_bit(STATUS_READY, &il->status)) { + IL_ERR(il, "Wait for START_ALIVE timeout after %dms.\n", jiffies_to_msecs(UCODE_READY_TIMEOUT)); ret = -ETIMEDOUT; @@ -2864,77 +2864,77 @@ static int il3945_mac_start(struct ieee80211_hw *hw) /* ucode is running and will send rfkill notifications, * no need to poll the killswitch state anymore */ - cancel_delayed_work(&priv->_3945.rfkill_poll); + cancel_delayed_work(&il->_3945.rfkill_poll); - priv->is_open = 1; - IL_DEBUG_MAC80211(priv, "leave\n"); + il->is_open = 1; + IL_DEBUG_MAC80211(il, "leave\n"); return 0; out_release_irq: - priv->is_open = 0; - IL_DEBUG_MAC80211(priv, "leave - failed\n"); + il->is_open = 0; + IL_DEBUG_MAC80211(il, "leave - failed\n"); return ret; } static void il3945_mac_stop(struct ieee80211_hw *hw) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); - if (!priv->is_open) { - IL_DEBUG_MAC80211(priv, "leave - skip\n"); + if (!il->is_open) { + IL_DEBUG_MAC80211(il, "leave - skip\n"); return; } - priv->is_open = 0; + il->is_open = 0; - il3945_down(priv); + il3945_down(il); - flush_workqueue(priv->workqueue); + flush_workqueue(il->workqueue); /* start polling the killswitch state again */ - queue_delayed_work(priv->workqueue, &priv->_3945.rfkill_poll, + queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, round_jiffies_relative(2 * HZ)); - IL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(il, "leave\n"); } static void il3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); - IL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, + IL_DEBUG_TX(il, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); - if (il3945_tx_skb(priv, skb)) + if (il3945_tx_skb(il, skb)) dev_kfree_skb_any(skb); - IL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(il, "leave\n"); } -void il3945_config_ap(struct il_priv *priv) +void il3945_config_ap(struct il_priv *il) { - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; struct ieee80211_vif *vif = ctx->vif; int rc = 0; - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; /* The following should be done only at AP bring up */ - if (!(il_is_associated(priv, IL_RXON_CTX_BSS))) { + if (!(il_is_associated(il, IL_RXON_CTX_BSS))) { /* RXON - unassoc (to set timing command) */ ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - il3945_commit_rxon(priv, ctx); + il3945_commit_rxon(il, ctx); /* RXON Timing */ - rc = il_send_rxon_timing(priv, ctx); + rc = il_send_rxon_timing(il, ctx); if (rc) - IL_WARN(priv, "REPLY_RXON_TIMING failed - " + IL_WARN(il, "REPLY_RXON_TIMING failed - " "Attempting to continue.\n"); ctx->staging.assoc_id = 0; @@ -2956,9 +2956,9 @@ void il3945_config_ap(struct il_priv *priv) } /* restore RXON assoc */ ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - il3945_commit_rxon(priv, ctx); + il3945_commit_rxon(il, ctx); } - il3945_send_beacon_cmd(priv); + il3945_send_beacon_cmd(il); } static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, @@ -2966,15 +2966,15 @@ static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, struct ieee80211_sta *sta, struct ieee80211_key_conf *key) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; int ret = 0; u8 sta_id = IL_INVALID_STATION; u8 static_key; - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); if (il3945_mod_params.sw_crypto) { - IL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n"); + IL_DEBUG_MAC80211(il, "leave - hwcrypto disabled\n"); return -EOPNOTSUPP; } @@ -2986,39 +2986,39 @@ static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) return -EOPNOTSUPP; - static_key = !il_is_associated(priv, IL_RXON_CTX_BSS); + static_key = !il_is_associated(il, IL_RXON_CTX_BSS); if (!static_key) { sta_id = il_sta_id_or_broadcast( - priv, &priv->contexts[IL_RXON_CTX_BSS], sta); + il, &il->contexts[IL_RXON_CTX_BSS], sta); if (sta_id == IL_INVALID_STATION) return -EINVAL; } - mutex_lock(&priv->mutex); - il_scan_cancel_timeout(priv, 100); + mutex_lock(&il->mutex); + il_scan_cancel_timeout(il, 100); switch (cmd) { case SET_KEY: if (static_key) - ret = il3945_set_static_key(priv, key); + ret = il3945_set_static_key(il, key); else - ret = il3945_set_dynamic_key(priv, key, sta_id); - IL_DEBUG_MAC80211(priv, "enable hwcrypto key\n"); + ret = il3945_set_dynamic_key(il, key, sta_id); + IL_DEBUG_MAC80211(il, "enable hwcrypto key\n"); break; case DISABLE_KEY: if (static_key) - ret = il3945_remove_static_key(priv); + ret = il3945_remove_static_key(il); else - ret = il3945_clear_sta_key_info(priv, sta_id); - IL_DEBUG_MAC80211(priv, "disable hwcrypto key\n"); + ret = il3945_clear_sta_key_info(il, sta_id); + IL_DEBUG_MAC80211(il, "disable hwcrypto key\n"); break; default: ret = -EINVAL; } - mutex_unlock(&priv->mutex); - IL_DEBUG_MAC80211(priv, "leave\n"); + mutex_unlock(&il->mutex); + IL_DEBUG_MAC80211(il, "leave\n"); return ret; } @@ -3027,38 +3027,38 @@ static int il3945_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; struct il3945_sta_priv *sta_priv = (void *)sta->drv_priv; int ret; bool is_ap = vif->type == NL80211_IFTYPE_STATION; u8 sta_id; - IL_DEBUG_INFO(priv, "received request to add station %pM\n", + IL_DEBUG_INFO(il, "received request to add station %pM\n", sta->addr); - mutex_lock(&priv->mutex); - IL_DEBUG_INFO(priv, "proceeding to add station %pM\n", + mutex_lock(&il->mutex); + IL_DEBUG_INFO(il, "proceeding to add station %pM\n", sta->addr); sta_priv->common.sta_id = IL_INVALID_STATION; - ret = il_add_station_common(priv, - &priv->contexts[IL_RXON_CTX_BSS], + ret = il_add_station_common(il, + &il->contexts[IL_RXON_CTX_BSS], sta->addr, is_ap, sta, &sta_id); if (ret) { - IL_ERR(priv, "Unable to add station %pM (%d)\n", + IL_ERR(il, "Unable to add station %pM (%d)\n", sta->addr, ret); /* Should we return success if return code is EEXIST ? */ - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); return ret; } sta_priv->common.sta_id = sta_id; /* Initialize rate scaling */ - IL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n", + IL_DEBUG_INFO(il, "Initializing rate scaling for station %pM\n", sta->addr); - il3945_rs_rate_init(priv, sta, sta_id); - mutex_unlock(&priv->mutex); + il3945_rs_rate_init(il, sta, sta_id); + mutex_unlock(&il->mutex); return 0; } @@ -3068,9 +3068,9 @@ static void il3945_configure_filter(struct ieee80211_hw *hw, unsigned int *total_flags, u64 multicast) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; __le32 filter_or = 0, filter_nand = 0; - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; #define CHK(test, flag) do { \ if (*total_flags & (test)) \ @@ -3079,7 +3079,7 @@ static void il3945_configure_filter(struct ieee80211_hw *hw, filter_nand |= (flag); \ } while (0) - IL_DEBUG_MAC80211(priv, "Enter: changed: 0x%x, total: 0x%x\n", + IL_DEBUG_MAC80211(il, "Enter: changed: 0x%x, total: 0x%x\n", changed_flags, *total_flags); CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); @@ -3088,7 +3088,7 @@ static void il3945_configure_filter(struct ieee80211_hw *hw, #undef CHK - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); ctx->staging.filter_flags &= ~filter_nand; ctx->staging.filter_flags |= filter_or; @@ -3099,7 +3099,7 @@ static void il3945_configure_filter(struct ieee80211_hw *hw, * we'll eventually commit the filter flags change anyway. */ - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); /* * Receiving all multicast frames is always enabled by the @@ -3134,24 +3134,24 @@ static void il3945_configure_filter(struct ieee80211_hw *hw, static ssize_t il3945_show_debug_level(struct device *d, struct device_attribute *attr, char *buf) { - struct il_priv *priv = dev_get_drvdata(d); - return sprintf(buf, "0x%08X\n", il_get_debug_level(priv)); + struct il_priv *il = dev_get_drvdata(d); + return sprintf(buf, "0x%08X\n", il_get_debug_level(il)); } static ssize_t il3945_store_debug_level(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct il_priv *priv = dev_get_drvdata(d); + struct il_priv *il = dev_get_drvdata(d); unsigned long val; int ret; ret = strict_strtoul(buf, 0, &val); if (ret) - IL_INFO(priv, "%s is not in hex or decimal form.\n", buf); + IL_INFO(il, "%s is not in hex or decimal form.\n", buf); else { - priv->debug_level = val; - if (il_alloc_traffic_mem(priv)) - IL_ERR(priv, + il->debug_level = val; + if (il_alloc_traffic_mem(il)) + IL_ERR(il, "Not enough memory to generate traffic log\n"); } return strnlen(buf, count); @@ -3165,12 +3165,12 @@ static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, static ssize_t il3945_show_temperature(struct device *d, struct device_attribute *attr, char *buf) { - struct il_priv *priv = dev_get_drvdata(d); + struct il_priv *il = dev_get_drvdata(d); - if (!il_is_alive(priv)) + if (!il_is_alive(il)) return -EAGAIN; - return sprintf(buf, "%d\n", il3945_hw_get_temperature(priv)); + return sprintf(buf, "%d\n", il3945_hw_get_temperature(il)); } static DEVICE_ATTR(temperature, S_IRUGO, il3945_show_temperature, NULL); @@ -3178,23 +3178,23 @@ static DEVICE_ATTR(temperature, S_IRUGO, il3945_show_temperature, NULL); static ssize_t il3945_show_tx_power(struct device *d, struct device_attribute *attr, char *buf) { - struct il_priv *priv = dev_get_drvdata(d); - return sprintf(buf, "%d\n", priv->tx_power_user_lmt); + struct il_priv *il = dev_get_drvdata(d); + return sprintf(buf, "%d\n", il->tx_power_user_lmt); } static ssize_t il3945_store_tx_power(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct il_priv *priv = dev_get_drvdata(d); + struct il_priv *il = dev_get_drvdata(d); char *p = (char *)buf; u32 val; val = simple_strtoul(p, &p, 10); if (p == buf) - IL_INFO(priv, ": %s is not in decimal form.\n", buf); + IL_INFO(il, ": %s is not in decimal form.\n", buf); else - il3945_hw_reg_set_txpower(priv, val); + il3945_hw_reg_set_txpower(il, val); return count; } @@ -3204,8 +3204,8 @@ static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, il3945_show_tx_power, il3945_sto static ssize_t il3945_show_flags(struct device *d, struct device_attribute *attr, char *buf) { - struct il_priv *priv = dev_get_drvdata(d); - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_priv *il = dev_get_drvdata(d); + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; return sprintf(buf, "0x%04X\n", ctx->active.flags); } @@ -3214,23 +3214,23 @@ static ssize_t il3945_store_flags(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct il_priv *priv = dev_get_drvdata(d); + struct il_priv *il = dev_get_drvdata(d); u32 flags = simple_strtoul(buf, NULL, 0); - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); if (le32_to_cpu(ctx->staging.flags) != flags) { /* Cancel any currently running scans... */ - if (il_scan_cancel_timeout(priv, 100)) - IL_WARN(priv, "Could not cancel scan.\n"); + if (il_scan_cancel_timeout(il, 100)) + IL_WARN(il, "Could not cancel scan.\n"); else { - IL_DEBUG_INFO(priv, "Committing rxon.flags = 0x%04X\n", + IL_DEBUG_INFO(il, "Committing rxon.flags = 0x%04X\n", flags); ctx->staging.flags = cpu_to_le32(flags); - il3945_commit_rxon(priv, ctx); + il3945_commit_rxon(il, ctx); } } - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); return count; } @@ -3240,8 +3240,8 @@ static DEVICE_ATTR(flags, S_IWUSR | S_IRUGO, il3945_show_flags, il3945_store_fla static ssize_t il3945_show_filter_flags(struct device *d, struct device_attribute *attr, char *buf) { - struct il_priv *priv = dev_get_drvdata(d); - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_priv *il = dev_get_drvdata(d); + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; return sprintf(buf, "0x%04X\n", le32_to_cpu(ctx->active.filter_flags)); @@ -3251,24 +3251,24 @@ static ssize_t il3945_store_filter_flags(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct il_priv *priv = dev_get_drvdata(d); - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_priv *il = dev_get_drvdata(d); + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; u32 filter_flags = simple_strtoul(buf, NULL, 0); - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); if (le32_to_cpu(ctx->staging.filter_flags) != filter_flags) { /* Cancel any currently running scans... */ - if (il_scan_cancel_timeout(priv, 100)) - IL_WARN(priv, "Could not cancel scan.\n"); + if (il_scan_cancel_timeout(il, 100)) + IL_WARN(il, "Could not cancel scan.\n"); else { - IL_DEBUG_INFO(priv, "Committing rxon.filter_flags = " + IL_DEBUG_INFO(il, "Committing rxon.filter_flags = " "0x%04X\n", filter_flags); ctx->staging.filter_flags = cpu_to_le32(filter_flags); - il3945_commit_rxon(priv, ctx); + il3945_commit_rxon(il, ctx); } } - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); return count; } @@ -3279,20 +3279,20 @@ static DEVICE_ATTR(filter_flags, S_IWUSR | S_IRUGO, il3945_show_filter_flags, static ssize_t il3945_show_measurement(struct device *d, struct device_attribute *attr, char *buf) { - struct il_priv *priv = dev_get_drvdata(d); + struct il_priv *il = dev_get_drvdata(d); struct il_spectrum_notification measure_report; u32 size = sizeof(measure_report), len = 0, ofs = 0; u8 *data = (u8 *)&measure_report; unsigned long flags; - spin_lock_irqsave(&priv->lock, flags); - if (!(priv->measurement_status & MEASUREMENT_READY)) { - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); + if (!(il->measurement_status & MEASUREMENT_READY)) { + spin_unlock_irqrestore(&il->lock, flags); return 0; } - memcpy(&measure_report, &priv->measure_report, size); - priv->measurement_status = 0; - spin_unlock_irqrestore(&priv->lock, flags); + memcpy(&measure_report, &il->measure_report, size); + il->measurement_status = 0; + spin_unlock_irqrestore(&il->lock, flags); while (size && (PAGE_SIZE - len)) { hex_dump_to_buffer(data + ofs, size, 16, 1, buf + len, @@ -3312,11 +3312,11 @@ static ssize_t il3945_store_measurement(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct il_priv *priv = dev_get_drvdata(d); - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_priv *il = dev_get_drvdata(d); + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; struct ieee80211_measurement_params params = { .channel = le16_to_cpu(ctx->active.channel), - .start_time = cpu_to_le64(priv->_3945.last_tsf), + .start_time = cpu_to_le64(il->_3945.last_tsf), .duration = cpu_to_le16(1), }; u8 type = IL_MEASURE_BASIC; @@ -3337,9 +3337,9 @@ static ssize_t il3945_store_measurement(struct device *d, type = simple_strtoul(p + 1, NULL, 0); } - IL_DEBUG_INFO(priv, "Invoking measurement of type %d on " + IL_DEBUG_INFO(il, "Invoking measurement of type %d on " "channel %d (for '%s')\n", type, params.channel, buf); - il3945_get_measurement(priv, ¶ms, type); + il3945_get_measurement(il, ¶ms, type); return count; } @@ -3351,11 +3351,11 @@ static ssize_t il3945_store_retry_rate(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct il_priv *priv = dev_get_drvdata(d); + struct il_priv *il = dev_get_drvdata(d); - priv->retry_rate = simple_strtoul(buf, NULL, 0); - if (priv->retry_rate <= 0) - priv->retry_rate = 1; + il->retry_rate = simple_strtoul(buf, NULL, 0); + if (il->retry_rate <= 0) + il->retry_rate = 1; return count; } @@ -3363,8 +3363,8 @@ static ssize_t il3945_store_retry_rate(struct device *d, static ssize_t il3945_show_retry_rate(struct device *d, struct device_attribute *attr, char *buf) { - struct il_priv *priv = dev_get_drvdata(d); - return sprintf(buf, "%d", priv->retry_rate); + struct il_priv *il = dev_get_drvdata(d); + return sprintf(buf, "%d", il->retry_rate); } static DEVICE_ATTR(retry_rate, S_IWUSR | S_IRUSR, il3945_show_retry_rate, @@ -3383,9 +3383,9 @@ static DEVICE_ATTR(channels, S_IRUSR, il3945_show_channels, NULL); static ssize_t il3945_show_antenna(struct device *d, struct device_attribute *attr, char *buf) { - struct il_priv *priv = dev_get_drvdata(d); + struct il_priv *il = dev_get_drvdata(d); - if (!il_is_alive(priv)) + if (!il_is_alive(il)) return -EAGAIN; return sprintf(buf, "%d\n", il3945_mod_params.antenna); @@ -3395,22 +3395,22 @@ static ssize_t il3945_store_antenna(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct il_priv *priv __maybe_unused = dev_get_drvdata(d); + struct il_priv *il __maybe_unused = dev_get_drvdata(d); int ant; if (count == 0) return 0; if (sscanf(buf, "%1i", &ant) != 1) { - IL_DEBUG_INFO(priv, "not in hex or decimal form.\n"); + IL_DEBUG_INFO(il, "not in hex or decimal form.\n"); return count; } if ((ant >= 0) && (ant <= 2)) { - IL_DEBUG_INFO(priv, "Setting antenna select to %d.\n", ant); + IL_DEBUG_INFO(il, "Setting antenna select to %d.\n", ant); il3945_mod_params.antenna = (enum il3945_antenna)ant; } else - IL_DEBUG_INFO(priv, "Bad antenna select value %d.\n", ant); + IL_DEBUG_INFO(il, "Bad antenna select value %d.\n", ant); return count; @@ -3421,10 +3421,10 @@ static DEVICE_ATTR(antenna, S_IWUSR | S_IRUGO, il3945_show_antenna, il3945_store static ssize_t il3945_show_status(struct device *d, struct device_attribute *attr, char *buf) { - struct il_priv *priv = dev_get_drvdata(d); - if (!il_is_alive(priv)) + struct il_priv *il = dev_get_drvdata(d); + if (!il_is_alive(il)) return -EAGAIN; - return sprintf(buf, "0x%08x\n", (int)priv->status); + return sprintf(buf, "0x%08x\n", (int)il->status); } static DEVICE_ATTR(status, S_IRUGO, il3945_show_status, NULL); @@ -3433,11 +3433,11 @@ static ssize_t il3945_dump_error_log(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct il_priv *priv = dev_get_drvdata(d); + struct il_priv *il = dev_get_drvdata(d); char *p = (char *)buf; if (p[0] == '1') - il3945_dump_nic_error_log(priv); + il3945_dump_nic_error_log(il); return strnlen(buf, count); } @@ -3450,38 +3450,38 @@ static DEVICE_ATTR(dump_errors, S_IWUSR, NULL, il3945_dump_error_log); * *****************************************************************************/ -static void il3945_setup_deferred_work(struct il_priv *priv) +static void il3945_setup_deferred_work(struct il_priv *il) { - priv->workqueue = create_singlethread_workqueue(DRV_NAME); + il->workqueue = create_singlethread_workqueue(DRV_NAME); - init_waitqueue_head(&priv->wait_command_queue); + init_waitqueue_head(&il->wait_command_queue); - INIT_WORK(&priv->restart, il3945_bg_restart); - INIT_WORK(&priv->rx_replenish, il3945_bg_rx_replenish); - INIT_DELAYED_WORK(&priv->init_alive_start, il3945_bg_init_alive_start); - INIT_DELAYED_WORK(&priv->alive_start, il3945_bg_alive_start); - INIT_DELAYED_WORK(&priv->_3945.rfkill_poll, il3945_rfkill_poll); + INIT_WORK(&il->restart, il3945_bg_restart); + INIT_WORK(&il->rx_replenish, il3945_bg_rx_replenish); + INIT_DELAYED_WORK(&il->init_alive_start, il3945_bg_init_alive_start); + INIT_DELAYED_WORK(&il->alive_start, il3945_bg_alive_start); + INIT_DELAYED_WORK(&il->_3945.rfkill_poll, il3945_rfkill_poll); - il_setup_scan_deferred_work(priv); + il_setup_scan_deferred_work(il); - il3945_hw_setup_deferred_work(priv); + il3945_hw_setup_deferred_work(il); - init_timer(&priv->watchdog); - priv->watchdog.data = (unsigned long)priv; - priv->watchdog.function = il_bg_watchdog; + init_timer(&il->watchdog); + il->watchdog.data = (unsigned long)il; + il->watchdog.function = il_bg_watchdog; - tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) - il3945_irq_tasklet, (unsigned long)priv); + tasklet_init(&il->irq_tasklet, (void (*)(unsigned long)) + il3945_irq_tasklet, (unsigned long)il); } -static void il3945_cancel_deferred_work(struct il_priv *priv) +static void il3945_cancel_deferred_work(struct il_priv *il) { - il3945_hw_cancel_deferred_work(priv); + il3945_hw_cancel_deferred_work(il); - cancel_delayed_work_sync(&priv->init_alive_start); - cancel_delayed_work(&priv->alive_start); + cancel_delayed_work_sync(&il->init_alive_start); + cancel_delayed_work(&il->alive_start); - il_cancel_scan_deferred_work(priv); + il_cancel_scan_deferred_work(il); } static struct attribute *il3945_sysfs_entries[] = { @@ -3525,70 +3525,70 @@ struct ieee80211_ops il3945_hw_ops = { .tx_last_beacon = il_mac_tx_last_beacon, }; -static int il3945_init_drv(struct il_priv *priv) +static int il3945_init_drv(struct il_priv *il) { int ret; - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)priv->eeprom; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - priv->retry_rate = 1; - priv->beacon_skb = NULL; + il->retry_rate = 1; + il->beacon_skb = NULL; - spin_lock_init(&priv->sta_lock); - spin_lock_init(&priv->hcmd_lock); + spin_lock_init(&il->sta_lock); + spin_lock_init(&il->hcmd_lock); - INIT_LIST_HEAD(&priv->free_frames); + INIT_LIST_HEAD(&il->free_frames); - mutex_init(&priv->mutex); + mutex_init(&il->mutex); - priv->ieee_channels = NULL; - priv->ieee_rates = NULL; - priv->band = IEEE80211_BAND_2GHZ; + il->ieee_channels = NULL; + il->ieee_rates = NULL; + il->band = IEEE80211_BAND_2GHZ; - priv->iw_mode = NL80211_IFTYPE_STATION; - priv->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; + il->iw_mode = NL80211_IFTYPE_STATION; + il->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; /* initialize force reset */ - priv->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; + il->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; if (eeprom->version < EEPROM_3945_EEPROM_VERSION) { - IL_WARN(priv, "Unsupported EEPROM version: 0x%04X\n", + IL_WARN(il, "Unsupported EEPROM version: 0x%04X\n", eeprom->version); ret = -EINVAL; goto err; } - ret = il_init_channel_map(priv); + ret = il_init_channel_map(il); if (ret) { - IL_ERR(priv, "initializing regulatory failed: %d\n", ret); + IL_ERR(il, "initializing regulatory failed: %d\n", ret); goto err; } /* Set up txpower settings in driver for all channels */ - if (il3945_txpower_set_from_eeprom(priv)) { + if (il3945_txpower_set_from_eeprom(il)) { ret = -EIO; goto err_free_channel_map; } - ret = il_init_geos(priv); + ret = il_init_geos(il); if (ret) { - IL_ERR(priv, "initializing geos failed: %d\n", ret); + IL_ERR(il, "initializing geos failed: %d\n", ret); goto err_free_channel_map; } - il3945_init_hw_rates(priv, priv->ieee_rates); + il3945_init_hw_rates(il, il->ieee_rates); return 0; err_free_channel_map: - il_free_channel_map(priv); + il_free_channel_map(il); err: return ret; } #define IWL3945_MAX_PROBE_REQUEST 200 -static int il3945_setup_mac(struct il_priv *priv) +static int il3945_setup_mac(struct il_priv *il) { int ret; - struct ieee80211_hw *hw = priv->hw; + struct ieee80211_hw *hw = il->hw; hw->rate_control_algorithm = "iwl-3945-rs"; hw->sta_data_size = sizeof(struct il3945_sta_priv); @@ -3599,7 +3599,7 @@ static int il3945_setup_mac(struct il_priv *priv) IEEE80211_HW_SPECTRUM_MGMT; hw->wiphy->interface_modes = - priv->contexts[IL_RXON_CTX_BSS].interface_modes; + il->contexts[IL_RXON_CTX_BSS].interface_modes; hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | WIPHY_FLAG_DISABLE_BEACON_HINTS | @@ -3612,22 +3612,22 @@ static int il3945_setup_mac(struct il_priv *priv) /* Default value; 4 EDCA QOS priorities */ hw->queues = 4; - if (priv->bands[IEEE80211_BAND_2GHZ].n_channels) - priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = - &priv->bands[IEEE80211_BAND_2GHZ]; + if (il->bands[IEEE80211_BAND_2GHZ].n_channels) + il->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = + &il->bands[IEEE80211_BAND_2GHZ]; - if (priv->bands[IEEE80211_BAND_5GHZ].n_channels) - priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = - &priv->bands[IEEE80211_BAND_5GHZ]; + if (il->bands[IEEE80211_BAND_5GHZ].n_channels) + il->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = + &il->bands[IEEE80211_BAND_5GHZ]; - il_leds_init(priv); + il_leds_init(il); - ret = ieee80211_register_hw(priv->hw); + ret = ieee80211_register_hw(il->hw); if (ret) { - IL_ERR(priv, "Failed to register hw (error %d)\n", ret); + IL_ERR(il, "Failed to register hw (error %d)\n", ret); return ret; } - priv->mac80211_registered = 1; + il->mac80211_registered = 1; return 0; } @@ -3635,7 +3635,7 @@ static int il3945_setup_mac(struct il_priv *priv) static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { int err = 0, i; - struct il_priv *priv; + struct il_priv *il; struct ieee80211_hw *hw; struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data); struct il3945_eeprom *eeprom; @@ -3646,53 +3646,53 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en * ********************/ /* mac80211 allocates memory for this device instance, including - * space for this driver's private structure */ + * space for this driver's ilate structure */ hw = il_alloc_all(cfg); if (hw == NULL) { pr_err("Can not allocate network device\n"); err = -ENOMEM; goto out; } - priv = hw->priv; + il = hw->priv; SET_IEEE80211_DEV(hw, &pdev->dev); - priv->cmd_queue = IWL39_CMD_QUEUE_NUM; + il->cmd_queue = IWL39_CMD_QUEUE_NUM; /* 3945 has only one valid context */ - priv->valid_contexts = BIT(IL_RXON_CTX_BSS); + il->valid_contexts = BIT(IL_RXON_CTX_BSS); for (i = 0; i < NUM_IL_RXON_CTX; i++) - priv->contexts[i].ctxid = i; - - priv->contexts[IL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON; - priv->contexts[IL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING; - priv->contexts[IL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC; - priv->contexts[IL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM; - priv->contexts[IL_RXON_CTX_BSS].ap_sta_id = IL_AP_ID; - priv->contexts[IL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY; - priv->contexts[IL_RXON_CTX_BSS].interface_modes = + il->contexts[i].ctxid = i; + + il->contexts[IL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON; + il->contexts[IL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING; + il->contexts[IL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC; + il->contexts[IL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM; + il->contexts[IL_RXON_CTX_BSS].ap_sta_id = IL_AP_ID; + il->contexts[IL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY; + il->contexts[IL_RXON_CTX_BSS].interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC); - priv->contexts[IL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS; - priv->contexts[IL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS; - priv->contexts[IL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS; + il->contexts[IL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS; + il->contexts[IL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS; + il->contexts[IL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS; /* * Disabling hardware scan means that mac80211 will perform scans * "the hard way", rather than using device's scan. */ if (il3945_mod_params.disable_hw_scan) { - IL_DEBUG_INFO(priv, "Disabling hw_scan\n"); + IL_DEBUG_INFO(il, "Disabling hw_scan\n"); il3945_hw_ops.hw_scan = NULL; } - IL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n"); - priv->cfg = cfg; - priv->pci_dev = pdev; - priv->inta_mask = CSR_INI_SET_MASK; + IL_DEBUG_INFO(il, "*** LOAD DRIVER ***\n"); + il->cfg = cfg; + il->pci_dev = pdev; + il->inta_mask = CSR_INI_SET_MASK; - if (il_alloc_traffic_mem(priv)) - IL_ERR(priv, "Not enough memory to generate traffic log\n"); + if (il_alloc_traffic_mem(il)) + IL_ERR(il, "Not enough memory to generate traffic log\n"); /*************************** * 2. Initializing PCI bus @@ -3711,11 +3711,11 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en if (!err) err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); if (err) { - IL_WARN(priv, "No suitable DMA available.\n"); + IL_WARN(il, "No suitable DMA available.\n"); goto out_pci_disable_device; } - pci_set_drvdata(pdev, priv); + pci_set_drvdata(pdev, il); err = pci_request_regions(pdev, DRV_NAME); if (err) goto out_pci_disable_device; @@ -3723,15 +3723,15 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en /*********************** * 3. Read REV Register * ********************/ - priv->hw_base = pci_iomap(pdev, 0, 0); - if (!priv->hw_base) { + il->hw_base = pci_iomap(pdev, 0, 0); + if (!il->hw_base) { err = -ENODEV; goto out_pci_release_regions; } - IL_DEBUG_INFO(priv, "pci_resource_len = 0x%08llx\n", + IL_DEBUG_INFO(il, "pci_resource_len = 0x%08llx\n", (unsigned long long) pci_resource_len(pdev, 0)); - IL_DEBUG_INFO(priv, "pci_resource_base = %p\n", priv->hw_base); + IL_DEBUG_INFO(il, "pci_resource_base = %p\n", il->hw_base); /* We disable the RETRY_TIMEOUT register (0x41) to keep * PCI Tx retries from interfering with C3 CPU state */ @@ -3740,152 +3740,152 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en /* these spin locks will be used in apm_ops.init and EEPROM access * we should init now */ - spin_lock_init(&priv->reg_lock); - spin_lock_init(&priv->lock); + spin_lock_init(&il->reg_lock); + spin_lock_init(&il->lock); /* * stop and reset the on-board processor just in case it is in a * strange state ... like being left stranded by a primary kernel * and this is now the kdump kernel trying to start up */ - il_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + il_write32(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); /*********************** * 4. Read EEPROM * ********************/ /* Read the EEPROM */ - err = il_eeprom_init(priv); + err = il_eeprom_init(il); if (err) { - IL_ERR(priv, "Unable to init EEPROM\n"); + IL_ERR(il, "Unable to init EEPROM\n"); goto out_iounmap; } /* MAC Address location in EEPROM same for 3945/4965 */ - eeprom = (struct il3945_eeprom *)priv->eeprom; - IL_DEBUG_INFO(priv, "MAC address: %pM\n", eeprom->mac_address); - SET_IEEE80211_PERM_ADDR(priv->hw, eeprom->mac_address); + eeprom = (struct il3945_eeprom *)il->eeprom; + IL_DEBUG_INFO(il, "MAC address: %pM\n", eeprom->mac_address); + SET_IEEE80211_PERM_ADDR(il->hw, eeprom->mac_address); /*********************** * 5. Setup HW Constants * ********************/ /* Device-specific setup */ - if (il3945_hw_set_hw_params(priv)) { - IL_ERR(priv, "failed to set hw settings\n"); + if (il3945_hw_set_hw_params(il)) { + IL_ERR(il, "failed to set hw settings\n"); goto out_eeprom_free; } /*********************** - * 6. Setup priv + * 6. Setup il * ********************/ - err = il3945_init_drv(priv); + err = il3945_init_drv(il); if (err) { - IL_ERR(priv, "initializing driver failed\n"); + IL_ERR(il, "initializing driver failed\n"); goto out_unset_hw_params; } - IL_INFO(priv, "Detected Intel Wireless WiFi Link %s\n", - priv->cfg->name); + IL_INFO(il, "Detected Intel Wireless WiFi Link %s\n", + il->cfg->name); /*********************** * 7. Setup Services * ********************/ - spin_lock_irqsave(&priv->lock, flags); - il_disable_interrupts(priv); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); + il_disable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); - pci_enable_msi(priv->pci_dev); + pci_enable_msi(il->pci_dev); - err = request_irq(priv->pci_dev->irq, il_isr, - IRQF_SHARED, DRV_NAME, priv); + err = request_irq(il->pci_dev->irq, il_isr, + IRQF_SHARED, DRV_NAME, il); if (err) { - IL_ERR(priv, "Error allocating IRQ %d\n", priv->pci_dev->irq); + IL_ERR(il, "Error allocating IRQ %d\n", il->pci_dev->irq); goto out_disable_msi; } err = sysfs_create_group(&pdev->dev.kobj, &il3945_attribute_group); if (err) { - IL_ERR(priv, "failed to create sysfs device attributes\n"); + IL_ERR(il, "failed to create sysfs device attributes\n"); goto out_release_irq; } - il_set_rxon_channel(priv, - &priv->bands[IEEE80211_BAND_2GHZ].channels[5], - &priv->contexts[IL_RXON_CTX_BSS]); - il3945_setup_deferred_work(priv); - il3945_setup_rx_handlers(priv); - il_power_initialize(priv); + il_set_rxon_channel(il, + &il->bands[IEEE80211_BAND_2GHZ].channels[5], + &il->contexts[IL_RXON_CTX_BSS]); + il3945_setup_deferred_work(il); + il3945_setup_rx_handlers(il); + il_power_initialize(il); /********************************* * 8. Setup and Register mac80211 * *******************************/ - il_enable_interrupts(priv); + il_enable_interrupts(il); - err = il3945_setup_mac(priv); + err = il3945_setup_mac(il); if (err) goto out_remove_sysfs; - err = il_dbgfs_register(priv, DRV_NAME); + err = il_dbgfs_register(il, DRV_NAME); if (err) - IL_ERR(priv, "failed to create debugfs files. Ignoring error: %d\n", err); + IL_ERR(il, "failed to create debugfs files. Ignoring error: %d\n", err); /* Start monitoring the killswitch */ - queue_delayed_work(priv->workqueue, &priv->_3945.rfkill_poll, + queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, 2 * HZ); return 0; out_remove_sysfs: - destroy_workqueue(priv->workqueue); - priv->workqueue = NULL; + destroy_workqueue(il->workqueue); + il->workqueue = NULL; sysfs_remove_group(&pdev->dev.kobj, &il3945_attribute_group); out_release_irq: - free_irq(priv->pci_dev->irq, priv); + free_irq(il->pci_dev->irq, il); out_disable_msi: - pci_disable_msi(priv->pci_dev); - il_free_geos(priv); - il_free_channel_map(priv); + pci_disable_msi(il->pci_dev); + il_free_geos(il); + il_free_channel_map(il); out_unset_hw_params: - il3945_unset_hw_params(priv); + il3945_unset_hw_params(il); out_eeprom_free: - il_eeprom_free(priv); + il_eeprom_free(il); out_iounmap: - pci_iounmap(pdev, priv->hw_base); + pci_iounmap(pdev, il->hw_base); out_pci_release_regions: pci_release_regions(pdev); out_pci_disable_device: pci_set_drvdata(pdev, NULL); pci_disable_device(pdev); out_ieee80211_free_hw: - il_free_traffic_mem(priv); - ieee80211_free_hw(priv->hw); + il_free_traffic_mem(il); + ieee80211_free_hw(il->hw); out: return err; } static void __devexit il3945_pci_remove(struct pci_dev *pdev) { - struct il_priv *priv = pci_get_drvdata(pdev); + struct il_priv *il = pci_get_drvdata(pdev); unsigned long flags; - if (!priv) + if (!il) return; - IL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n"); + IL_DEBUG_INFO(il, "*** UNLOAD DRIVER ***\n"); - il_dbgfs_unregister(priv); + il_dbgfs_unregister(il); - set_bit(STATUS_EXIT_PENDING, &priv->status); + set_bit(STATUS_EXIT_PENDING, &il->status); - il_leds_exit(priv); + il_leds_exit(il); - if (priv->mac80211_registered) { - ieee80211_unregister_hw(priv->hw); - priv->mac80211_registered = 0; + if (il->mac80211_registered) { + ieee80211_unregister_hw(il->hw); + il->mac80211_registered = 0; } else { - il3945_down(priv); + il3945_down(il); } /* @@ -3895,54 +3895,54 @@ static void __devexit il3945_pci_remove(struct pci_dev *pdev) * paths to avoid running il_down() at all before leaving driver. * This (inexpensive) call *makes sure* device is reset. */ - il_apm_stop(priv); + il_apm_stop(il); /* make sure we flush any pending irq or * tasklet for the driver */ - spin_lock_irqsave(&priv->lock, flags); - il_disable_interrupts(priv); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); + il_disable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); - il3945_synchronize_irq(priv); + il3945_synchronize_irq(il); sysfs_remove_group(&pdev->dev.kobj, &il3945_attribute_group); - cancel_delayed_work_sync(&priv->_3945.rfkill_poll); + cancel_delayed_work_sync(&il->_3945.rfkill_poll); - il3945_dealloc_ucode_pci(priv); + il3945_dealloc_ucode_pci(il); - if (priv->rxq.bd) - il3945_rx_queue_free(priv, &priv->rxq); - il3945_hw_txq_ctx_free(priv); + if (il->rxq.bd) + il3945_rx_queue_free(il, &il->rxq); + il3945_hw_txq_ctx_free(il); - il3945_unset_hw_params(priv); + il3945_unset_hw_params(il); /*netif_stop_queue(dev); */ - flush_workqueue(priv->workqueue); + flush_workqueue(il->workqueue); /* ieee80211_unregister_hw calls il3945_mac_stop, which flushes - * priv->workqueue... so we can't take down the workqueue + * il->workqueue... so we can't take down the workqueue * until now... */ - destroy_workqueue(priv->workqueue); - priv->workqueue = NULL; - il_free_traffic_mem(priv); + destroy_workqueue(il->workqueue); + il->workqueue = NULL; + il_free_traffic_mem(il); - free_irq(pdev->irq, priv); + free_irq(pdev->irq, il); pci_disable_msi(pdev); - pci_iounmap(pdev, priv->hw_base); + pci_iounmap(pdev, il->hw_base); pci_release_regions(pdev); pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); - il_free_channel_map(priv); - il_free_geos(priv); - kfree(priv->scan_cmd); - if (priv->beacon_skb) - dev_kfree_skb(priv->beacon_skb); + il_free_channel_map(il); + il_free_geos(il); + kfree(il->scan_cmd); + if (il->beacon_skb) + dev_kfree_skb(il->beacon_skb); - ieee80211_free_hw(priv->hw); + ieee80211_free_hw(il->hw); } diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index bd37c9226e65..ae8a93751561 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -87,85 +87,85 @@ MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); MODULE_LICENSE("GPL"); MODULE_ALIAS("iwl4965"); -void il4965_update_chain_flags(struct il_priv *priv) +void il4965_update_chain_flags(struct il_priv *il) { struct il_rxon_context *ctx; - if (priv->cfg->ops->hcmd->set_rxon_chain) { - for_each_context(priv, ctx) { - priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); + if (il->cfg->ops->hcmd->set_rxon_chain) { + for_each_context(il, ctx) { + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); if (ctx->active.rx_chain != ctx->staging.rx_chain) - il_commit_rxon(priv, ctx); + il_commit_rxon(il, ctx); } } } -static void il4965_clear_free_frames(struct il_priv *priv) +static void il4965_clear_free_frames(struct il_priv *il) { struct list_head *element; - IL_DEBUG_INFO(priv, "%d frames on pre-allocated heap on clear.\n", - priv->frames_count); + IL_DEBUG_INFO(il, "%d frames on pre-allocated heap on clear.\n", + il->frames_count); - while (!list_empty(&priv->free_frames)) { - element = priv->free_frames.next; + while (!list_empty(&il->free_frames)) { + element = il->free_frames.next; list_del(element); kfree(list_entry(element, struct il_frame, list)); - priv->frames_count--; + il->frames_count--; } - if (priv->frames_count) { - IL_WARN(priv, "%d frames still in use. Did we lose one?\n", - priv->frames_count); - priv->frames_count = 0; + if (il->frames_count) { + IL_WARN(il, "%d frames still in use. Did we lose one?\n", + il->frames_count); + il->frames_count = 0; } } -static struct il_frame *il4965_get_free_frame(struct il_priv *priv) +static struct il_frame *il4965_get_free_frame(struct il_priv *il) { struct il_frame *frame; struct list_head *element; - if (list_empty(&priv->free_frames)) { + if (list_empty(&il->free_frames)) { frame = kzalloc(sizeof(*frame), GFP_KERNEL); if (!frame) { - IL_ERR(priv, "Could not allocate frame!\n"); + IL_ERR(il, "Could not allocate frame!\n"); return NULL; } - priv->frames_count++; + il->frames_count++; return frame; } - element = priv->free_frames.next; + element = il->free_frames.next; list_del(element); return list_entry(element, struct il_frame, list); } -static void il4965_free_frame(struct il_priv *priv, struct il_frame *frame) +static void il4965_free_frame(struct il_priv *il, struct il_frame *frame) { memset(frame, 0, sizeof(*frame)); - list_add(&frame->list, &priv->free_frames); + list_add(&frame->list, &il->free_frames); } -static u32 il4965_fill_beacon_frame(struct il_priv *priv, +static u32 il4965_fill_beacon_frame(struct il_priv *il, struct ieee80211_hdr *hdr, int left) { - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - if (!priv->beacon_skb) + if (!il->beacon_skb) return 0; - if (priv->beacon_skb->len > left) + if (il->beacon_skb->len > left) return 0; - memcpy(hdr, priv->beacon_skb->data, priv->beacon_skb->len); + memcpy(hdr, il->beacon_skb->data, il->beacon_skb->len); - return priv->beacon_skb->len; + return il->beacon_skb->len; } /* Parse the beacon frame to find the TIM element and set tim_idx & tim_size */ -static void il4965_set_beacon_tim(struct il_priv *priv, +static void il4965_set_beacon_tim(struct il_priv *il, struct il_tx_beacon_cmd *tx_beacon_cmd, u8 *beacon, u32 frame_size) { @@ -188,10 +188,10 @@ static void il4965_set_beacon_tim(struct il_priv *priv, tx_beacon_cmd->tim_idx = cpu_to_le16(tim_idx); tx_beacon_cmd->tim_size = beacon[tim_idx+1]; } else - IL_WARN(priv, "Unable to find TIM Element in beacon\n"); + IL_WARN(il, "Unable to find TIM Element in beacon\n"); } -static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *priv, +static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *il, struct il_frame *frame) { struct il_tx_beacon_cmd *tx_beacon_cmd; @@ -203,10 +203,10 @@ static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *priv, * beacon contents. */ - lockdep_assert_held(&priv->mutex); + lockdep_assert_held(&il->mutex); - if (!priv->beacon_ctx) { - IL_ERR(priv, "trying to build beacon w/o beacon context!\n"); + if (!il->beacon_ctx) { + IL_ERR(il, "trying to build beacon w/o beacon context!\n"); return 0; } @@ -215,7 +215,7 @@ static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *priv, memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); /* Set up TX beacon contents */ - frame_size = il4965_fill_beacon_frame(priv, tx_beacon_cmd->frame, + frame_size = il4965_fill_beacon_frame(il, tx_beacon_cmd->frame, sizeof(frame->u) - sizeof(*tx_beacon_cmd)); if (WARN_ON_ONCE(frame_size > MAX_MPDU_SIZE)) return 0; @@ -224,20 +224,20 @@ static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *priv, /* Set up TX command fields */ tx_beacon_cmd->tx.len = cpu_to_le16((u16)frame_size); - tx_beacon_cmd->tx.sta_id = priv->beacon_ctx->bcast_sta_id; + tx_beacon_cmd->tx.sta_id = il->beacon_ctx->bcast_sta_id; tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; tx_beacon_cmd->tx.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK | TX_CMD_FLG_TSF_MSK | TX_CMD_FLG_STA_RATE_MSK; /* Set up TX beacon command fields */ - il4965_set_beacon_tim(priv, tx_beacon_cmd, (u8 *)tx_beacon_cmd->frame, + il4965_set_beacon_tim(il, tx_beacon_cmd, (u8 *)tx_beacon_cmd->frame, frame_size); /* Set up packet rate and flags */ - rate = il_get_lowest_plcp(priv, priv->beacon_ctx); - priv->mgmt_tx_ant = il4965_toggle_tx_ant(priv, priv->mgmt_tx_ant, - priv->hw_params.valid_tx_ant); - rate_flags = il4965_ant_idx_to_flags(priv->mgmt_tx_ant); + rate = il_get_lowest_plcp(il, il->beacon_ctx); + il->mgmt_tx_ant = il4965_toggle_tx_ant(il, il->mgmt_tx_ant, + il->hw_params.valid_tx_ant); + rate_flags = il4965_ant_idx_to_flags(il->mgmt_tx_ant); if ((rate >= IL_FIRST_CCK_RATE) && (rate <= IL_LAST_CCK_RATE)) rate_flags |= RATE_MCS_CCK_MSK; tx_beacon_cmd->tx.rate_n_flags = il4965_hw_set_rate_n_flags(rate, @@ -246,30 +246,30 @@ static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *priv, return sizeof(*tx_beacon_cmd) + frame_size; } -int il4965_send_beacon_cmd(struct il_priv *priv) +int il4965_send_beacon_cmd(struct il_priv *il) { struct il_frame *frame; unsigned int frame_size; int rc; - frame = il4965_get_free_frame(priv); + frame = il4965_get_free_frame(il); if (!frame) { - IL_ERR(priv, "Could not obtain free frame buffer for beacon " + IL_ERR(il, "Could not obtain free frame buffer for beacon " "command.\n"); return -ENOMEM; } - frame_size = il4965_hw_get_beacon_cmd(priv, frame); + frame_size = il4965_hw_get_beacon_cmd(il, frame); if (!frame_size) { - IL_ERR(priv, "Error configuring the beacon command\n"); - il4965_free_frame(priv, frame); + IL_ERR(il, "Error configuring the beacon command\n"); + il4965_free_frame(il, frame); return -EINVAL; } - rc = il_send_cmd_pdu(priv, REPLY_TX_BEACON, frame_size, + rc = il_send_cmd_pdu(il, REPLY_TX_BEACON, frame_size, &frame->u.cmd[0]); - il4965_free_frame(priv, frame); + il4965_free_frame(il, frame); return rc; } @@ -315,17 +315,17 @@ static inline u8 il4965_tfd_get_num_tbs(struct il_tfd *tfd) /** * il4965_hw_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr] - * @priv - driver private data + * @il - driver ilate data * @txq - tx queue * * Does NOT advance any TFD circular buffer read/write indexes * Does NOT free the TFD itself (which is within circular buffer) */ -void il4965_hw_txq_free_tfd(struct il_priv *priv, struct il_tx_queue *txq) +void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) { struct il_tfd *tfd_tmp = (struct il_tfd *)txq->tfds; struct il_tfd *tfd; - struct pci_dev *dev = priv->pci_dev; + struct pci_dev *dev = il->pci_dev; int index = txq->q.read_ptr; int i; int num_tbs; @@ -336,7 +336,7 @@ void il4965_hw_txq_free_tfd(struct il_priv *priv, struct il_tx_queue *txq) num_tbs = il4965_tfd_get_num_tbs(tfd); if (num_tbs >= IL_NUM_OF_TBS) { - IL_ERR(priv, "Too many chunks: %i\n", num_tbs); + IL_ERR(il, "Too many chunks: %i\n", num_tbs); /* @todo issue fatal error, it is quite serious situation */ return; } @@ -368,7 +368,7 @@ void il4965_hw_txq_free_tfd(struct il_priv *priv, struct il_tx_queue *txq) } } -int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *priv, +int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, struct il_tx_queue *txq, dma_addr_t addr, u16 len, u8 reset, u8 pad) @@ -388,14 +388,14 @@ int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *priv, /* Each TFD can point to a maximum 20 Tx buffers */ if (num_tbs >= IL_NUM_OF_TBS) { - IL_ERR(priv, "Error can not send more than %d chunks\n", + IL_ERR(il, "Error can not send more than %d chunks\n", IL_NUM_OF_TBS); return -EINVAL; } BUG_ON(addr & ~DMA_BIT_MASK(36)); if (unlikely(addr & ~IL_TX_DMA_MASK)) - IL_ERR(priv, "Unaligned address = %llx\n", + IL_ERR(il, "Unaligned address = %llx\n", (unsigned long long)addr); il4965_tfd_set_tb(tfd, num_tbs, addr, len); @@ -410,13 +410,13 @@ int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *priv, * 4965 supports up to 16 Tx queues in DRAM, mapped to up to 8 Tx DMA * channels supported in hardware. */ -int il4965_hw_tx_queue_init(struct il_priv *priv, +int il4965_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq) { int txq_id = txq->q.id; /* Circular buffer (TFD queue in DRAM) physical base address */ - il_write_direct32(priv, FH_MEM_CBBC_QUEUE(txq_id), + il_write_direct32(il, FH_MEM_CBBC_QUEUE(txq_id), txq->q.dma_addr >> 8); return 0; @@ -427,7 +427,7 @@ int il4965_hw_tx_queue_init(struct il_priv *priv, * Generic RX handler implementations * ******************************************************************************/ -static void il4965_rx_reply_alive(struct il_priv *priv, +static void il4965_rx_reply_alive(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); @@ -436,31 +436,31 @@ static void il4965_rx_reply_alive(struct il_priv *priv, palive = &pkt->u.alive_frame; - IL_DEBUG_INFO(priv, "Alive ucode status 0x%08X revision " + IL_DEBUG_INFO(il, "Alive ucode status 0x%08X revision " "0x%01X 0x%01X\n", palive->is_valid, palive->ver_type, palive->ver_subtype); if (palive->ver_subtype == INITIALIZE_SUBTYPE) { - IL_DEBUG_INFO(priv, "Initialization Alive received.\n"); - memcpy(&priv->card_alive_init, + IL_DEBUG_INFO(il, "Initialization Alive received.\n"); + memcpy(&il->card_alive_init, &pkt->u.alive_frame, sizeof(struct il_init_alive_resp)); - pwork = &priv->init_alive_start; + pwork = &il->init_alive_start; } else { - IL_DEBUG_INFO(priv, "Runtime Alive received.\n"); - memcpy(&priv->card_alive, &pkt->u.alive_frame, + IL_DEBUG_INFO(il, "Runtime Alive received.\n"); + memcpy(&il->card_alive, &pkt->u.alive_frame, sizeof(struct il_alive_resp)); - pwork = &priv->alive_start; + pwork = &il->alive_start; } /* We delay the ALIVE response by 5ms to * give the HW RF Kill time to activate... */ if (palive->is_valid == UCODE_VALID_OK) - queue_delayed_work(priv->workqueue, pwork, + queue_delayed_work(il->workqueue, pwork, msecs_to_jiffies(5)); else - IL_WARN(priv, "uCode did not respond OK.\n"); + IL_WARN(il, "uCode did not respond OK.\n"); } /** @@ -475,19 +475,19 @@ static void il4965_rx_reply_alive(struct il_priv *priv, */ static void il4965_bg_statistics_periodic(unsigned long data) { - struct il_priv *priv = (struct il_priv *)data; + struct il_priv *il = (struct il_priv *)data; - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; /* dont send host command if rf-kill is on */ - if (!il_is_ready_rf(priv)) + if (!il_is_ready_rf(il)) return; - il_send_statistics_request(priv, CMD_ASYNC, false); + il_send_statistics_request(il, CMD_ASYNC, false); } -static void il4965_rx_beacon_notif(struct il_priv *priv, +static void il4965_rx_beacon_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); @@ -496,7 +496,7 @@ static void il4965_rx_beacon_notif(struct il_priv *priv, #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG u8 rate = il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); - IL_DEBUG_RX(priv, "beacon status %x retries %d iss %d " + IL_DEBUG_RX(il, "beacon status %x retries %d iss %d " "tsf %d %d rate %d\n", le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, beacon->beacon_notify_hdr.failure_frame, @@ -505,38 +505,38 @@ static void il4965_rx_beacon_notif(struct il_priv *priv, le32_to_cpu(beacon->low_tsf), rate); #endif - priv->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); + il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); } -static void il4965_perform_ct_kill_task(struct il_priv *priv) +static void il4965_perform_ct_kill_task(struct il_priv *il) { unsigned long flags; - IL_DEBUG_POWER(priv, "Stop all queues\n"); + IL_DEBUG_POWER(il, "Stop all queues\n"); - if (priv->mac80211_registered) - ieee80211_stop_queues(priv->hw); + if (il->mac80211_registered) + ieee80211_stop_queues(il->hw); - il_write32(priv, CSR_UCODE_DRV_GP1_SET, + il_write32(il, CSR_UCODE_DRV_GP1_SET, CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); - il_read32(priv, CSR_UCODE_DRV_GP1); + il_read32(il, CSR_UCODE_DRV_GP1); - spin_lock_irqsave(&priv->reg_lock, flags); - if (!il_grab_nic_access(priv)) - il_release_nic_access(priv); - spin_unlock_irqrestore(&priv->reg_lock, flags); + spin_lock_irqsave(&il->reg_lock, flags); + if (!il_grab_nic_access(il)) + il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, flags); } /* Handle notification from uCode that card's power state is changing * due to software, hardware, or critical temperature RFKILL */ -static void il4965_rx_card_state_notif(struct il_priv *priv, +static void il4965_rx_card_state_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { struct il_rx_packet *pkt = rxb_addr(rxb); u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); - unsigned long status = priv->status; + unsigned long status = il->status; - IL_DEBUG_RF_KILL(priv, "Card state received: HW:%s SW:%s CT:%s\n", + IL_DEBUG_RF_KILL(il, "Card state received: HW:%s SW:%s CT:%s\n", (flags & HW_CARD_DISABLED) ? "Kill" : "On", (flags & SW_CARD_DISABLED) ? "Kill" : "On", (flags & CT_CARD_DISABLED) ? @@ -545,37 +545,37 @@ static void il4965_rx_card_state_notif(struct il_priv *priv, if (flags & (SW_CARD_DISABLED | HW_CARD_DISABLED | CT_CARD_DISABLED)) { - il_write32(priv, CSR_UCODE_DRV_GP1_SET, + il_write32(il, CSR_UCODE_DRV_GP1_SET, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - il_write_direct32(priv, HBUS_TARG_MBX_C, + il_write_direct32(il, HBUS_TARG_MBX_C, HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); if (!(flags & RXON_CARD_DISABLED)) { - il_write32(priv, CSR_UCODE_DRV_GP1_CLR, + il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - il_write_direct32(priv, HBUS_TARG_MBX_C, + il_write_direct32(il, HBUS_TARG_MBX_C, HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); } } if (flags & CT_CARD_DISABLED) - il4965_perform_ct_kill_task(priv); + il4965_perform_ct_kill_task(il); if (flags & HW_CARD_DISABLED) - set_bit(STATUS_RF_KILL_HW, &priv->status); + set_bit(STATUS_RF_KILL_HW, &il->status); else - clear_bit(STATUS_RF_KILL_HW, &priv->status); + clear_bit(STATUS_RF_KILL_HW, &il->status); if (!(flags & RXON_CARD_DISABLED)) - il_scan_cancel(priv); + il_scan_cancel(il); if ((test_bit(STATUS_RF_KILL_HW, &status) != - test_bit(STATUS_RF_KILL_HW, &priv->status))) - wiphy_rfkill_set_hw_state(priv->hw->wiphy, - test_bit(STATUS_RF_KILL_HW, &priv->status)); + test_bit(STATUS_RF_KILL_HW, &il->status))) + wiphy_rfkill_set_hw_state(il->hw->wiphy, + test_bit(STATUS_RF_KILL_HW, &il->status)); else - wake_up(&priv->wait_command_queue); + wake_up(&il->wait_command_queue); } /** @@ -587,55 +587,55 @@ static void il4965_rx_card_state_notif(struct il_priv *priv, * This function chains into the hardware specific files for them to setup * any hardware specific handlers as well. */ -static void il4965_setup_rx_handlers(struct il_priv *priv) +static void il4965_setup_rx_handlers(struct il_priv *il) { - priv->rx_handlers[REPLY_ALIVE] = il4965_rx_reply_alive; - priv->rx_handlers[REPLY_ERROR] = il_rx_reply_error; - priv->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa; - priv->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = + il->rx_handlers[REPLY_ALIVE] = il4965_rx_reply_alive; + il->rx_handlers[REPLY_ERROR] = il_rx_reply_error; + il->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa; + il->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = il_rx_spectrum_measure_notif; - priv->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; - priv->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = + il->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; + il->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = il_rx_pm_debug_statistics_notif; - priv->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; + il->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; /* * The same handler is used for both the REPLY to a discrete * statistics request from the host as well as for the periodic * statistics notifications (after received beacons) from the uCode. */ - priv->rx_handlers[REPLY_STATISTICS_CMD] = il4965_reply_statistics; - priv->rx_handlers[STATISTICS_NOTIFICATION] = il4965_rx_statistics; + il->rx_handlers[REPLY_STATISTICS_CMD] = il4965_reply_statistics; + il->rx_handlers[STATISTICS_NOTIFICATION] = il4965_rx_statistics; - il_setup_rx_scan_handlers(priv); + il_setup_rx_scan_handlers(il); /* status change handler */ - priv->rx_handlers[CARD_STATE_NOTIFICATION] = + il->rx_handlers[CARD_STATE_NOTIFICATION] = il4965_rx_card_state_notif; - priv->rx_handlers[MISSED_BEACONS_NOTIFICATION] = + il->rx_handlers[MISSED_BEACONS_NOTIFICATION] = il4965_rx_missed_beacon_notif; /* Rx handlers */ - priv->rx_handlers[REPLY_RX_PHY_CMD] = il4965_rx_reply_rx_phy; - priv->rx_handlers[REPLY_RX_MPDU_CMD] = il4965_rx_reply_rx; + il->rx_handlers[REPLY_RX_PHY_CMD] = il4965_rx_reply_rx_phy; + il->rx_handlers[REPLY_RX_MPDU_CMD] = il4965_rx_reply_rx; /* block ack */ - priv->rx_handlers[REPLY_COMPRESSED_BA] = il4965_rx_reply_compressed_ba; + il->rx_handlers[REPLY_COMPRESSED_BA] = il4965_rx_reply_compressed_ba; /* Set up hardware specific Rx handlers */ - priv->cfg->ops->lib->rx_handler_setup(priv); + il->cfg->ops->lib->rx_handler_setup(il); } /** * il4965_rx_handle - Main entry function for receiving responses from uCode * - * Uses the priv->rx_handlers callback function array to invoke + * Uses the il->rx_handlers callback function array to invoke * the appropriate handlers, including command responses, * frame-received notifications, and other notifications. */ -void il4965_rx_handle(struct il_priv *priv) +void il4965_rx_handle(struct il_priv *il) { struct il_rx_mem_buffer *rxb; struct il_rx_packet *pkt; - struct il_rx_queue *rxq = &priv->rxq; + struct il_rx_queue *rxq = &il->rxq; u32 r, i; int reclaim; unsigned long flags; @@ -650,7 +650,7 @@ void il4965_rx_handle(struct il_priv *priv) /* Rx interrupt, but nothing sent from uCode */ if (i == r) - IL_DEBUG_RX(priv, "r = %d, i = %d\n", r, i); + IL_DEBUG_RX(il, "r = %d, i = %d\n", r, i); /* calculate total frames need to be restock after handling RX */ total_empty = r - rxq->write_actual; @@ -672,8 +672,8 @@ void il4965_rx_handle(struct il_priv *priv) rxq->queue[i] = NULL; - pci_unmap_page(priv->pci_dev, rxb->page_dma, - PAGE_SIZE << priv->hw_params.rx_page_order, + pci_unmap_page(il->pci_dev, rxb->page_dma, + PAGE_SIZE << il->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); pkt = rxb_addr(rxb); @@ -697,15 +697,15 @@ void il4965_rx_handle(struct il_priv *priv) /* Based on type of command response or notification, * handle those that need handling via function in * rx_handlers table. See il4965_setup_rx_handlers() */ - if (priv->rx_handlers[pkt->hdr.cmd]) { - IL_DEBUG_RX(priv, "r = %d, i = %d, %s, 0x%02x\n", r, + if (il->rx_handlers[pkt->hdr.cmd]) { + IL_DEBUG_RX(il, "r = %d, i = %d, %s, 0x%02x\n", r, i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); - priv->isr_stats.rx_handlers[pkt->hdr.cmd]++; - priv->rx_handlers[pkt->hdr.cmd] (priv, rxb); + il->isr_stats.rx_handlers[pkt->hdr.cmd]++; + il->rx_handlers[pkt->hdr.cmd] (il, rxb); } else { /* No handling needed */ - IL_DEBUG_RX(priv, + IL_DEBUG_RX(il, "r %d i %d No handler needed for %s, 0x%02x\n", r, i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); @@ -723,9 +723,9 @@ void il4965_rx_handle(struct il_priv *priv) * and fire off the (possibly) blocking il_send_cmd() * as we reclaim the driver command queue */ if (rxb->page) - il_tx_cmd_complete(priv, rxb); + il_tx_cmd_complete(il, rxb); else - IL_WARN(priv, "Claim null rxb?\n"); + IL_WARN(il, "Claim null rxb?\n"); } /* Reuse the page if possible. For notification packets and @@ -733,8 +733,8 @@ void il4965_rx_handle(struct il_priv *priv) * rx_free list for reuse later. */ spin_lock_irqsave(&rxq->lock, flags); if (rxb->page != NULL) { - rxb->page_dma = pci_map_page(priv->pci_dev, rxb->page, - 0, PAGE_SIZE << priv->hw_params.rx_page_order, + rxb->page_dma = pci_map_page(il->pci_dev, rxb->page, + 0, PAGE_SIZE << il->hw_params.rx_page_order, PCI_DMA_FROMDEVICE); list_add_tail(&rxb->list, &rxq->rx_free); rxq->free_count++; @@ -750,7 +750,7 @@ void il4965_rx_handle(struct il_priv *priv) count++; if (count >= 8) { rxq->read = i; - il4965_rx_replenish_now(priv); + il4965_rx_replenish_now(il); count = 0; } } @@ -759,20 +759,20 @@ void il4965_rx_handle(struct il_priv *priv) /* Backtrack one entry */ rxq->read = i; if (fill_rx) - il4965_rx_replenish_now(priv); + il4965_rx_replenish_now(il); else - il4965_rx_queue_restock(priv); + il4965_rx_queue_restock(il); } /* call this function to flush any scheduled tasklet */ -static inline void il4965_synchronize_irq(struct il_priv *priv) +static inline void il4965_synchronize_irq(struct il_priv *il) { /* wait to make sure we flush pending tasklet*/ - synchronize_irq(priv->pci_dev->irq); - tasklet_kill(&priv->irq_tasklet); + synchronize_irq(il->pci_dev->irq); + tasklet_kill(&il->irq_tasklet); } -static void il4965_irq_tasklet(struct il_priv *priv) +static void il4965_irq_tasklet(struct il_priv *il) { u32 inta, handled = 0; u32 inta_fh; @@ -782,30 +782,30 @@ static void il4965_irq_tasklet(struct il_priv *priv) u32 inta_mask; #endif - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); /* Ack/clear/reset pending uCode interrupts. * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS, * and will clear only when CSR_FH_INT_STATUS gets cleared. */ - inta = il_read32(priv, CSR_INT); - il_write32(priv, CSR_INT, inta); + inta = il_read32(il, CSR_INT); + il_write32(il, CSR_INT, inta); /* Ack/clear/reset pending flow-handler (DMA) interrupts. * Any new interrupts that happen after this, either while we're * in this tasklet, or later, will show up in next ISR/tasklet. */ - inta_fh = il_read32(priv, CSR_FH_INT_STATUS); - il_write32(priv, CSR_FH_INT_STATUS, inta_fh); + inta_fh = il_read32(il, CSR_FH_INT_STATUS); + il_write32(il, CSR_FH_INT_STATUS, inta_fh); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (il_get_debug_level(priv) & IL_DL_ISR) { + if (il_get_debug_level(il) & IL_DL_ISR) { /* just for debug */ - inta_mask = il_read32(priv, CSR_INT_MASK); - IL_DEBUG_ISR(priv, "inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", + inta_mask = il_read32(il, CSR_INT_MASK); + IL_DEBUG_ISR(il, "inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, inta_mask, inta_fh); } #endif - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); /* Since CSR_INT and CSR_FH_INT_STATUS reads and clears are not * atomic, make sure that inta covers all the interrupts that @@ -818,13 +818,13 @@ static void il4965_irq_tasklet(struct il_priv *priv) /* Now service all interrupt bits discovered above. */ if (inta & CSR_INT_BIT_HW_ERR) { - IL_ERR(priv, "Hardware error detected. Restarting.\n"); + IL_ERR(il, "Hardware error detected. Restarting.\n"); /* Tell the device to stop sending interrupts */ - il_disable_interrupts(priv); + il_disable_interrupts(il); - priv->isr_stats.hw++; - il_irq_handle_error(priv); + il->isr_stats.hw++; + il_irq_handle_error(il); handled |= CSR_INT_BIT_HW_ERR; @@ -832,18 +832,18 @@ static void il4965_irq_tasklet(struct il_priv *priv) } #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (il_get_debug_level(priv) & (IL_DL_ISR)) { + if (il_get_debug_level(il) & (IL_DL_ISR)) { /* NIC fires this, but we don't use it, redundant with WAKEUP */ if (inta & CSR_INT_BIT_SCD) { - IL_DEBUG_ISR(priv, "Scheduler finished to transmit " + IL_DEBUG_ISR(il, "Scheduler finished to transmit " "the frame/frames.\n"); - priv->isr_stats.sch++; + il->isr_stats.sch++; } /* Alive notification via Rx interrupt will do the real work */ if (inta & CSR_INT_BIT_ALIVE) { - IL_DEBUG_ISR(priv, "Alive interrupt\n"); - priv->isr_stats.alive++; + IL_DEBUG_ISR(il, "Alive interrupt\n"); + il->isr_stats.alive++; } } #endif @@ -853,26 +853,26 @@ static void il4965_irq_tasklet(struct il_priv *priv) /* HW RF KILL switch toggled */ if (inta & CSR_INT_BIT_RF_KILL) { int hw_rf_kill = 0; - if (!(il_read32(priv, CSR_GP_CNTRL) & + if (!(il_read32(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) hw_rf_kill = 1; - IL_WARN(priv, "RF_KILL bit toggled to %s.\n", + IL_WARN(il, "RF_KILL bit toggled to %s.\n", hw_rf_kill ? "disable radio" : "enable radio"); - priv->isr_stats.rfkill++; + il->isr_stats.rfkill++; /* driver only loads ucode once setting the interface up. * the driver allows loading the ucode even if the radio * is killed. Hence update the killswitch state here. The * rfkill handler will care about restarting if needed. */ - if (!test_bit(STATUS_ALIVE, &priv->status)) { + if (!test_bit(STATUS_ALIVE, &il->status)) { if (hw_rf_kill) - set_bit(STATUS_RF_KILL_HW, &priv->status); + set_bit(STATUS_RF_KILL_HW, &il->status); else - clear_bit(STATUS_RF_KILL_HW, &priv->status); - wiphy_rfkill_set_hw_state(priv->hw->wiphy, hw_rf_kill); + clear_bit(STATUS_RF_KILL_HW, &il->status); + wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rf_kill); } handled |= CSR_INT_BIT_RF_KILL; @@ -880,17 +880,17 @@ static void il4965_irq_tasklet(struct il_priv *priv) /* Chip got too hot and stopped itself */ if (inta & CSR_INT_BIT_CT_KILL) { - IL_ERR(priv, "Microcode CT kill error detected.\n"); - priv->isr_stats.ctkill++; + IL_ERR(il, "Microcode CT kill error detected.\n"); + il->isr_stats.ctkill++; handled |= CSR_INT_BIT_CT_KILL; } /* Error detected by uCode */ if (inta & CSR_INT_BIT_SW_ERR) { - IL_ERR(priv, "Microcode SW error detected. " + IL_ERR(il, "Microcode SW error detected. " " Restarting 0x%X.\n", inta); - priv->isr_stats.sw++; - il_irq_handle_error(priv); + il->isr_stats.sw++; + il_irq_handle_error(il); handled |= CSR_INT_BIT_SW_ERR; } @@ -900,11 +900,11 @@ static void il4965_irq_tasklet(struct il_priv *priv) * and about any Rx buffers made available while asleep. */ if (inta & CSR_INT_BIT_WAKEUP) { - IL_DEBUG_ISR(priv, "Wakeup interrupt\n"); - il_rx_queue_update_write_ptr(priv, &priv->rxq); - for (i = 0; i < priv->hw_params.max_txq_num; i++) - il_txq_update_write_ptr(priv, &priv->txq[i]); - priv->isr_stats.wakeup++; + IL_DEBUG_ISR(il, "Wakeup interrupt\n"); + il_rx_queue_update_write_ptr(il, &il->rxq); + for (i = 0; i < il->hw_params.max_txq_num; i++) + il_txq_update_write_ptr(il, &il->txq[i]); + il->isr_stats.wakeup++; handled |= CSR_INT_BIT_WAKEUP; } @@ -912,46 +912,46 @@ static void il4965_irq_tasklet(struct il_priv *priv) * Rx "responses" (frame-received notification), and other * notifications from uCode come through here*/ if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) { - il4965_rx_handle(priv); - priv->isr_stats.rx++; + il4965_rx_handle(il); + il->isr_stats.rx++; handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX); } /* This "Tx" DMA channel is used only for loading uCode */ if (inta & CSR_INT_BIT_FH_TX) { - IL_DEBUG_ISR(priv, "uCode load interrupt\n"); - priv->isr_stats.tx++; + IL_DEBUG_ISR(il, "uCode load interrupt\n"); + il->isr_stats.tx++; handled |= CSR_INT_BIT_FH_TX; /* Wake up uCode load routine, now that load is complete */ - priv->ucode_write_complete = 1; - wake_up(&priv->wait_command_queue); + il->ucode_write_complete = 1; + wake_up(&il->wait_command_queue); } if (inta & ~handled) { - IL_ERR(priv, "Unhandled INTA bits 0x%08x\n", inta & ~handled); - priv->isr_stats.unhandled++; + IL_ERR(il, "Unhandled INTA bits 0x%08x\n", inta & ~handled); + il->isr_stats.unhandled++; } - if (inta & ~(priv->inta_mask)) { - IL_WARN(priv, "Disabled INTA bits 0x%08x were pending\n", - inta & ~priv->inta_mask); - IL_WARN(priv, " with FH_INT = 0x%08x\n", inta_fh); + if (inta & ~(il->inta_mask)) { + IL_WARN(il, "Disabled INTA bits 0x%08x were pending\n", + inta & ~il->inta_mask); + IL_WARN(il, " with FH_INT = 0x%08x\n", inta_fh); } /* Re-enable all interrupts */ /* only Re-enable if disabled by irq */ - if (test_bit(STATUS_INT_ENABLED, &priv->status)) - il_enable_interrupts(priv); + if (test_bit(STATUS_INT_ENABLED, &il->status)) + il_enable_interrupts(il); /* Re-enable RF_KILL if it occurred */ else if (handled & CSR_INT_BIT_RF_KILL) - il_enable_rfkill_int(priv); + il_enable_rfkill_int(il); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG - if (il_get_debug_level(priv) & (IL_DL_ISR)) { - inta = il_read32(priv, CSR_INT); - inta_mask = il_read32(priv, CSR_INT_MASK); - inta_fh = il_read32(priv, CSR_FH_INT_STATUS); - IL_DEBUG_ISR(priv, + if (il_get_debug_level(il) & (IL_DL_ISR)) { + inta = il_read32(il, CSR_INT); + inta_mask = il_read32(il, CSR_INT_MASK); + inta_fh = il_read32(il, CSR_FH_INT_STATUS); + IL_DEBUG_ISR(il, "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); } @@ -980,24 +980,24 @@ static void il4965_irq_tasklet(struct il_priv *priv) static ssize_t il4965_show_debug_level(struct device *d, struct device_attribute *attr, char *buf) { - struct il_priv *priv = dev_get_drvdata(d); - return sprintf(buf, "0x%08X\n", il_get_debug_level(priv)); + struct il_priv *il = dev_get_drvdata(d); + return sprintf(buf, "0x%08X\n", il_get_debug_level(il)); } static ssize_t il4965_store_debug_level(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct il_priv *priv = dev_get_drvdata(d); + struct il_priv *il = dev_get_drvdata(d); unsigned long val; int ret; ret = strict_strtoul(buf, 0, &val); if (ret) - IL_ERR(priv, "%s is not in hex or decimal form.\n", buf); + IL_ERR(il, "%s is not in hex or decimal form.\n", buf); else { - priv->debug_level = val; - if (il_alloc_traffic_mem(priv)) - IL_ERR(priv, + il->debug_level = val; + if (il_alloc_traffic_mem(il)) + IL_ERR(il, "Not enough memory to generate traffic log\n"); } return strnlen(buf, count); @@ -1013,12 +1013,12 @@ static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, static ssize_t il4965_show_temperature(struct device *d, struct device_attribute *attr, char *buf) { - struct il_priv *priv = dev_get_drvdata(d); + struct il_priv *il = dev_get_drvdata(d); - if (!il_is_alive(priv)) + if (!il_is_alive(il)) return -EAGAIN; - return sprintf(buf, "%d\n", priv->temperature); + return sprintf(buf, "%d\n", il->temperature); } static DEVICE_ATTR(temperature, S_IRUGO, il4965_show_temperature, NULL); @@ -1026,29 +1026,29 @@ static DEVICE_ATTR(temperature, S_IRUGO, il4965_show_temperature, NULL); static ssize_t il4965_show_tx_power(struct device *d, struct device_attribute *attr, char *buf) { - struct il_priv *priv = dev_get_drvdata(d); + struct il_priv *il = dev_get_drvdata(d); - if (!il_is_ready_rf(priv)) + if (!il_is_ready_rf(il)) return sprintf(buf, "off\n"); else - return sprintf(buf, "%d\n", priv->tx_power_user_lmt); + return sprintf(buf, "%d\n", il->tx_power_user_lmt); } static ssize_t il4965_store_tx_power(struct device *d, struct device_attribute *attr, const char *buf, size_t count) { - struct il_priv *priv = dev_get_drvdata(d); + struct il_priv *il = dev_get_drvdata(d); unsigned long val; int ret; ret = strict_strtoul(buf, 10, &val); if (ret) - IL_INFO(priv, "%s is not in decimal form.\n", buf); + IL_INFO(il, "%s is not in decimal form.\n", buf); else { - ret = il_set_tx_power(priv, val, false); + ret = il_set_tx_power(il, val, false); if (ret) - IL_ERR(priv, "failed setting tx power (0x%d).\n", + IL_ERR(il, "failed setting tx power (0x%d).\n", ret); else ret = count; @@ -1079,52 +1079,52 @@ static struct attribute_group il_attribute_group = { * ******************************************************************************/ -static void il4965_dealloc_ucode_pci(struct il_priv *priv) +static void il4965_dealloc_ucode_pci(struct il_priv *il) { - il_free_fw_desc(priv->pci_dev, &priv->ucode_code); - il_free_fw_desc(priv->pci_dev, &priv->ucode_data); - il_free_fw_desc(priv->pci_dev, &priv->ucode_data_backup); - il_free_fw_desc(priv->pci_dev, &priv->ucode_init); - il_free_fw_desc(priv->pci_dev, &priv->ucode_init_data); - il_free_fw_desc(priv->pci_dev, &priv->ucode_boot); + il_free_fw_desc(il->pci_dev, &il->ucode_code); + il_free_fw_desc(il->pci_dev, &il->ucode_data); + il_free_fw_desc(il->pci_dev, &il->ucode_data_backup); + il_free_fw_desc(il->pci_dev, &il->ucode_init); + il_free_fw_desc(il->pci_dev, &il->ucode_init_data); + il_free_fw_desc(il->pci_dev, &il->ucode_boot); } -static void il4965_nic_start(struct il_priv *priv) +static void il4965_nic_start(struct il_priv *il) { /* Remove all resets to allow NIC to operate */ - il_write32(priv, CSR_RESET, 0); + il_write32(il, CSR_RESET, 0); } static void il4965_ucode_callback(const struct firmware *ucode_raw, void *context); -static int il4965_mac_setup_register(struct il_priv *priv, +static int il4965_mac_setup_register(struct il_priv *il, u32 max_probe_length); -static int __must_check il4965_request_firmware(struct il_priv *priv, bool first) +static int __must_check il4965_request_firmware(struct il_priv *il, bool first) { - const char *name_pre = priv->cfg->fw_name_pre; + const char *name_pre = il->cfg->fw_name_pre; char tag[8]; if (first) { - priv->fw_index = priv->cfg->ucode_api_max; - sprintf(tag, "%d", priv->fw_index); + il->fw_index = il->cfg->ucode_api_max; + sprintf(tag, "%d", il->fw_index); } else { - priv->fw_index--; - sprintf(tag, "%d", priv->fw_index); + il->fw_index--; + sprintf(tag, "%d", il->fw_index); } - if (priv->fw_index < priv->cfg->ucode_api_min) { - IL_ERR(priv, "no suitable firmware found!\n"); + if (il->fw_index < il->cfg->ucode_api_min) { + IL_ERR(il, "no suitable firmware found!\n"); return -ENOENT; } - sprintf(priv->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); + sprintf(il->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); - IL_DEBUG_INFO(priv, "attempting to load firmware '%s'\n", - priv->firmware_name); + IL_DEBUG_INFO(il, "attempting to load firmware '%s'\n", + il->firmware_name); - return request_firmware_nowait(THIS_MODULE, 1, priv->firmware_name, - &priv->pci_dev->dev, GFP_KERNEL, priv, + return request_firmware_nowait(THIS_MODULE, 1, il->firmware_name, + &il->pci_dev->dev, GFP_KERNEL, il, il4965_ucode_callback); } @@ -1133,7 +1133,7 @@ struct il4965_firmware_pieces { size_t inst_size, data_size, init_size, init_data_size, boot_size; }; -static int il4965_load_firmware(struct il_priv *priv, +static int il4965_load_firmware(struct il_priv *il, const struct firmware *ucode_raw, struct il4965_firmware_pieces *pieces) { @@ -1141,8 +1141,8 @@ static int il4965_load_firmware(struct il_priv *priv, u32 api_ver, hdr_size; const u8 *src; - priv->ucode_ver = le32_to_cpu(ucode->ver); - api_ver = IL_UCODE_API(priv->ucode_ver); + il->ucode_ver = le32_to_cpu(ucode->ver); + api_ver = IL_UCODE_API(il->ucode_ver); switch (api_ver) { default: @@ -1151,7 +1151,7 @@ static int il4965_load_firmware(struct il_priv *priv, case 2: hdr_size = 24; if (ucode_raw->size < hdr_size) { - IL_ERR(priv, "File size too small!\n"); + IL_ERR(il, "File size too small!\n"); return -EINVAL; } pieces->inst_size = le32_to_cpu(ucode->v1.inst_size); @@ -1169,7 +1169,7 @@ static int il4965_load_firmware(struct il_priv *priv, pieces->data_size + pieces->init_size + pieces->init_data_size + pieces->boot_size) { - IL_ERR(priv, + IL_ERR(il, "uCode file size %d does not match expected size\n", (int)ucode_raw->size); return -EINVAL; @@ -1198,12 +1198,12 @@ static int il4965_load_firmware(struct il_priv *priv, static void il4965_ucode_callback(const struct firmware *ucode_raw, void *context) { - struct il_priv *priv = context; + struct il_priv *il = context; struct il_ucode_header *ucode; int err; struct il4965_firmware_pieces pieces; - const unsigned int api_max = priv->cfg->ucode_api_max; - const unsigned int api_min = priv->cfg->ucode_api_min; + const unsigned int api_max = il->cfg->ucode_api_max; + const unsigned int api_min = il->cfg->ucode_api_min; u32 api_ver; u32 max_probe_length = 200; @@ -1213,31 +1213,31 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) memset(&pieces, 0, sizeof(pieces)); if (!ucode_raw) { - if (priv->fw_index <= priv->cfg->ucode_api_max) - IL_ERR(priv, + if (il->fw_index <= il->cfg->ucode_api_max) + IL_ERR(il, "request for firmware file '%s' failed.\n", - priv->firmware_name); + il->firmware_name); goto try_again; } - IL_DEBUG_INFO(priv, "Loaded firmware file '%s' (%zd bytes).\n", - priv->firmware_name, ucode_raw->size); + IL_DEBUG_INFO(il, "Loaded firmware file '%s' (%zd bytes).\n", + il->firmware_name, ucode_raw->size); /* Make sure that we got at least the API version number */ if (ucode_raw->size < 4) { - IL_ERR(priv, "File size way too small!\n"); + IL_ERR(il, "File size way too small!\n"); goto try_again; } /* Data from ucode file: header followed by uCode images */ ucode = (struct il_ucode_header *)ucode_raw->data; - err = il4965_load_firmware(priv, ucode_raw, &pieces); + err = il4965_load_firmware(il, ucode_raw, &pieces); if (err) goto try_again; - api_ver = IL_UCODE_API(priv->ucode_ver); + api_ver = IL_UCODE_API(il->ucode_ver); /* * api_ver should match the api version forming part of the @@ -1245,7 +1245,7 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) * on the API version read from firmware header from here on forward */ if (api_ver < api_min || api_ver > api_max) { - IL_ERR(priv, + IL_ERR(il, "Driver unable to support your firmware API. " "Driver supports v%u, firmware is v%u.\n", api_max, api_ver); @@ -1253,25 +1253,25 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) } if (api_ver != api_max) - IL_ERR(priv, + IL_ERR(il, "Firmware has old API version. Expected v%u, " "got v%u. New firmware can be obtained " "from http://www.intellinuxwireless.org.\n", api_max, api_ver); - IL_INFO(priv, "loaded firmware version %u.%u.%u.%u\n", - IL_UCODE_MAJOR(priv->ucode_ver), - IL_UCODE_MINOR(priv->ucode_ver), - IL_UCODE_API(priv->ucode_ver), - IL_UCODE_SERIAL(priv->ucode_ver)); + IL_INFO(il, "loaded firmware version %u.%u.%u.%u\n", + IL_UCODE_MAJOR(il->ucode_ver), + IL_UCODE_MINOR(il->ucode_ver), + IL_UCODE_API(il->ucode_ver), + IL_UCODE_SERIAL(il->ucode_ver)); - snprintf(priv->hw->wiphy->fw_version, - sizeof(priv->hw->wiphy->fw_version), + snprintf(il->hw->wiphy->fw_version, + sizeof(il->hw->wiphy->fw_version), "%u.%u.%u.%u", - IL_UCODE_MAJOR(priv->ucode_ver), - IL_UCODE_MINOR(priv->ucode_ver), - IL_UCODE_API(priv->ucode_ver), - IL_UCODE_SERIAL(priv->ucode_ver)); + IL_UCODE_MAJOR(il->ucode_ver), + IL_UCODE_MINOR(il->ucode_ver), + IL_UCODE_API(il->ucode_ver), + IL_UCODE_SERIAL(il->ucode_ver)); /* * For any of the failures below (before allocating pci memory) @@ -1279,46 +1279,46 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) * user just got a corrupted version of the latest API. */ - IL_DEBUG_INFO(priv, "f/w package hdr ucode version raw = 0x%x\n", - priv->ucode_ver); - IL_DEBUG_INFO(priv, "f/w package hdr runtime inst size = %Zd\n", + IL_DEBUG_INFO(il, "f/w package hdr ucode version raw = 0x%x\n", + il->ucode_ver); + IL_DEBUG_INFO(il, "f/w package hdr runtime inst size = %Zd\n", pieces.inst_size); - IL_DEBUG_INFO(priv, "f/w package hdr runtime data size = %Zd\n", + IL_DEBUG_INFO(il, "f/w package hdr runtime data size = %Zd\n", pieces.data_size); - IL_DEBUG_INFO(priv, "f/w package hdr init inst size = %Zd\n", + IL_DEBUG_INFO(il, "f/w package hdr init inst size = %Zd\n", pieces.init_size); - IL_DEBUG_INFO(priv, "f/w package hdr init data size = %Zd\n", + IL_DEBUG_INFO(il, "f/w package hdr init data size = %Zd\n", pieces.init_data_size); - IL_DEBUG_INFO(priv, "f/w package hdr boot inst size = %Zd\n", + IL_DEBUG_INFO(il, "f/w package hdr boot inst size = %Zd\n", pieces.boot_size); /* Verify that uCode images will fit in card's SRAM */ - if (pieces.inst_size > priv->hw_params.max_inst_size) { - IL_ERR(priv, "uCode instr len %Zd too large to fit in\n", + if (pieces.inst_size > il->hw_params.max_inst_size) { + IL_ERR(il, "uCode instr len %Zd too large to fit in\n", pieces.inst_size); goto try_again; } - if (pieces.data_size > priv->hw_params.max_data_size) { - IL_ERR(priv, "uCode data len %Zd too large to fit in\n", + if (pieces.data_size > il->hw_params.max_data_size) { + IL_ERR(il, "uCode data len %Zd too large to fit in\n", pieces.data_size); goto try_again; } - if (pieces.init_size > priv->hw_params.max_inst_size) { - IL_ERR(priv, "uCode init instr len %Zd too large to fit in\n", + if (pieces.init_size > il->hw_params.max_inst_size) { + IL_ERR(il, "uCode init instr len %Zd too large to fit in\n", pieces.init_size); goto try_again; } - if (pieces.init_data_size > priv->hw_params.max_data_size) { - IL_ERR(priv, "uCode init data len %Zd too large to fit in\n", + if (pieces.init_data_size > il->hw_params.max_data_size) { + IL_ERR(il, "uCode init data len %Zd too large to fit in\n", pieces.init_data_size); goto try_again; } - if (pieces.boot_size > priv->hw_params.max_bsm_size) { - IL_ERR(priv, "uCode boot instr len %Zd too large to fit in\n", + if (pieces.boot_size > il->hw_params.max_bsm_size) { + IL_ERR(il, "uCode boot instr len %Zd too large to fit in\n", pieces.boot_size); goto try_again; } @@ -1328,92 +1328,92 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) /* Runtime instructions and 2 copies of data: * 1) unmodified from disk * 2) backup cache for save/restore during power-downs */ - priv->ucode_code.len = pieces.inst_size; - il_alloc_fw_desc(priv->pci_dev, &priv->ucode_code); + il->ucode_code.len = pieces.inst_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_code); - priv->ucode_data.len = pieces.data_size; - il_alloc_fw_desc(priv->pci_dev, &priv->ucode_data); + il->ucode_data.len = pieces.data_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_data); - priv->ucode_data_backup.len = pieces.data_size; - il_alloc_fw_desc(priv->pci_dev, &priv->ucode_data_backup); + il->ucode_data_backup.len = pieces.data_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_data_backup); - if (!priv->ucode_code.v_addr || !priv->ucode_data.v_addr || - !priv->ucode_data_backup.v_addr) + if (!il->ucode_code.v_addr || !il->ucode_data.v_addr || + !il->ucode_data_backup.v_addr) goto err_pci_alloc; /* Initialization instructions and data */ if (pieces.init_size && pieces.init_data_size) { - priv->ucode_init.len = pieces.init_size; - il_alloc_fw_desc(priv->pci_dev, &priv->ucode_init); + il->ucode_init.len = pieces.init_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_init); - priv->ucode_init_data.len = pieces.init_data_size; - il_alloc_fw_desc(priv->pci_dev, &priv->ucode_init_data); + il->ucode_init_data.len = pieces.init_data_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_init_data); - if (!priv->ucode_init.v_addr || !priv->ucode_init_data.v_addr) + if (!il->ucode_init.v_addr || !il->ucode_init_data.v_addr) goto err_pci_alloc; } /* Bootstrap (instructions only, no data) */ if (pieces.boot_size) { - priv->ucode_boot.len = pieces.boot_size; - il_alloc_fw_desc(priv->pci_dev, &priv->ucode_boot); + il->ucode_boot.len = pieces.boot_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_boot); - if (!priv->ucode_boot.v_addr) + if (!il->ucode_boot.v_addr) goto err_pci_alloc; } /* Now that we can no longer fail, copy information */ - priv->sta_key_max_num = STA_KEY_MAX_NUM; + il->sta_key_max_num = STA_KEY_MAX_NUM; /* Copy images into buffers for card's bus-master reads ... */ /* Runtime instructions (first block of data in file) */ - IL_DEBUG_INFO(priv, "Copying (but not loading) uCode instr len %Zd\n", + IL_DEBUG_INFO(il, "Copying (but not loading) uCode instr len %Zd\n", pieces.inst_size); - memcpy(priv->ucode_code.v_addr, pieces.inst, pieces.inst_size); + memcpy(il->ucode_code.v_addr, pieces.inst, pieces.inst_size); - IL_DEBUG_INFO(priv, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", - priv->ucode_code.v_addr, (u32)priv->ucode_code.p_addr); + IL_DEBUG_INFO(il, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", + il->ucode_code.v_addr, (u32)il->ucode_code.p_addr); /* * Runtime data * NOTE: Copy into backup buffer will be done in il_up() */ - IL_DEBUG_INFO(priv, "Copying (but not loading) uCode data len %Zd\n", + IL_DEBUG_INFO(il, "Copying (but not loading) uCode data len %Zd\n", pieces.data_size); - memcpy(priv->ucode_data.v_addr, pieces.data, pieces.data_size); - memcpy(priv->ucode_data_backup.v_addr, pieces.data, pieces.data_size); + memcpy(il->ucode_data.v_addr, pieces.data, pieces.data_size); + memcpy(il->ucode_data_backup.v_addr, pieces.data, pieces.data_size); /* Initialization instructions */ if (pieces.init_size) { - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "Copying (but not loading) init instr len %Zd\n", pieces.init_size); - memcpy(priv->ucode_init.v_addr, pieces.init, pieces.init_size); + memcpy(il->ucode_init.v_addr, pieces.init, pieces.init_size); } /* Initialization data */ if (pieces.init_data_size) { - IL_DEBUG_INFO(priv, + IL_DEBUG_INFO(il, "Copying (but not loading) init data len %Zd\n", pieces.init_data_size); - memcpy(priv->ucode_init_data.v_addr, pieces.init_data, + memcpy(il->ucode_init_data.v_addr, pieces.init_data, pieces.init_data_size); } /* Bootstrap instructions */ - IL_DEBUG_INFO(priv, "Copying (but not loading) boot instr len %Zd\n", + IL_DEBUG_INFO(il, "Copying (but not loading) boot instr len %Zd\n", pieces.boot_size); - memcpy(priv->ucode_boot.v_addr, pieces.boot, pieces.boot_size); + memcpy(il->ucode_boot.v_addr, pieces.boot, pieces.boot_size); /* * figure out the offset of chain noise reset and gain commands * base on the size of standard phy calibration commands table size */ - priv->_4965.phy_calib_chain_noise_reset_cmd = + il->_4965.phy_calib_chain_noise_reset_cmd = standard_phy_calibration_size; - priv->_4965.phy_calib_chain_noise_gain_cmd = + il->_4965.phy_calib_chain_noise_gain_cmd = standard_phy_calibration_size + 1; /************************************************** @@ -1421,40 +1421,40 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) * * 9. Setup and register with mac80211 and debugfs **************************************************/ - err = il4965_mac_setup_register(priv, max_probe_length); + err = il4965_mac_setup_register(il, max_probe_length); if (err) goto out_unbind; - err = il_dbgfs_register(priv, DRV_NAME); + err = il_dbgfs_register(il, DRV_NAME); if (err) - IL_ERR(priv, + IL_ERR(il, "failed to create debugfs files. Ignoring error: %d\n", err); - err = sysfs_create_group(&priv->pci_dev->dev.kobj, + err = sysfs_create_group(&il->pci_dev->dev.kobj, &il_attribute_group); if (err) { - IL_ERR(priv, "failed to create sysfs device attributes\n"); + IL_ERR(il, "failed to create sysfs device attributes\n"); goto out_unbind; } /* We have our copies now, allow OS release its copies */ release_firmware(ucode_raw); - complete(&priv->_4965.firmware_loading_complete); + complete(&il->_4965.firmware_loading_complete); return; try_again: /* try next, if any */ - if (il4965_request_firmware(priv, false)) + if (il4965_request_firmware(il, false)) goto out_unbind; release_firmware(ucode_raw); return; err_pci_alloc: - IL_ERR(priv, "failed to allocate pci memory\n"); - il4965_dealloc_ucode_pci(priv); + IL_ERR(il, "failed to allocate pci memory\n"); + il4965_dealloc_ucode_pci(il); out_unbind: - complete(&priv->_4965.firmware_loading_complete); - device_release_driver(&priv->pci_dev->dev); + complete(&il->_4965.firmware_loading_complete); + device_release_driver(&il->pci_dev->dev); release_firmware(ucode_raw); } @@ -1527,79 +1527,79 @@ static const char *il4965_desc_lookup(u32 num) #define ERROR_START_OFFSET (1 * sizeof(u32)) #define ERROR_ELEM_SIZE (7 * sizeof(u32)) -void il4965_dump_nic_error_log(struct il_priv *priv) +void il4965_dump_nic_error_log(struct il_priv *il) { u32 data2, line; u32 desc, time, count, base, data1; u32 blink1, blink2, ilink1, ilink2; u32 pc, hcmd; - if (priv->ucode_type == UCODE_INIT) { - base = le32_to_cpu(priv->card_alive_init.error_event_table_ptr); + if (il->ucode_type == UCODE_INIT) { + base = le32_to_cpu(il->card_alive_init.error_event_table_ptr); } else { - base = le32_to_cpu(priv->card_alive.error_event_table_ptr); + base = le32_to_cpu(il->card_alive.error_event_table_ptr); } - if (!priv->cfg->ops->lib->is_valid_rtc_data_addr(base)) { - IL_ERR(priv, + if (!il->cfg->ops->lib->is_valid_rtc_data_addr(base)) { + IL_ERR(il, "Not valid error log pointer 0x%08X for %s uCode\n", - base, (priv->ucode_type == UCODE_INIT) ? "Init" : "RT"); + base, (il->ucode_type == UCODE_INIT) ? "Init" : "RT"); return; } - count = il_read_targ_mem(priv, base); + count = il_read_targ_mem(il, base); if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { - IL_ERR(priv, "Start IWL Error Log Dump:\n"); - IL_ERR(priv, "Status: 0x%08lX, count: %d\n", - priv->status, count); - } - - desc = il_read_targ_mem(priv, base + 1 * sizeof(u32)); - priv->isr_stats.err_code = desc; - pc = il_read_targ_mem(priv, base + 2 * sizeof(u32)); - blink1 = il_read_targ_mem(priv, base + 3 * sizeof(u32)); - blink2 = il_read_targ_mem(priv, base + 4 * sizeof(u32)); - ilink1 = il_read_targ_mem(priv, base + 5 * sizeof(u32)); - ilink2 = il_read_targ_mem(priv, base + 6 * sizeof(u32)); - data1 = il_read_targ_mem(priv, base + 7 * sizeof(u32)); - data2 = il_read_targ_mem(priv, base + 8 * sizeof(u32)); - line = il_read_targ_mem(priv, base + 9 * sizeof(u32)); - time = il_read_targ_mem(priv, base + 11 * sizeof(u32)); - hcmd = il_read_targ_mem(priv, base + 22 * sizeof(u32)); - - IL_ERR(priv, "Desc Time " + IL_ERR(il, "Start IWL Error Log Dump:\n"); + IL_ERR(il, "Status: 0x%08lX, count: %d\n", + il->status, count); + } + + desc = il_read_targ_mem(il, base + 1 * sizeof(u32)); + il->isr_stats.err_code = desc; + pc = il_read_targ_mem(il, base + 2 * sizeof(u32)); + blink1 = il_read_targ_mem(il, base + 3 * sizeof(u32)); + blink2 = il_read_targ_mem(il, base + 4 * sizeof(u32)); + ilink1 = il_read_targ_mem(il, base + 5 * sizeof(u32)); + ilink2 = il_read_targ_mem(il, base + 6 * sizeof(u32)); + data1 = il_read_targ_mem(il, base + 7 * sizeof(u32)); + data2 = il_read_targ_mem(il, base + 8 * sizeof(u32)); + line = il_read_targ_mem(il, base + 9 * sizeof(u32)); + time = il_read_targ_mem(il, base + 11 * sizeof(u32)); + hcmd = il_read_targ_mem(il, base + 22 * sizeof(u32)); + + IL_ERR(il, "Desc Time " "data1 data2 line\n"); - IL_ERR(priv, "%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n", + IL_ERR(il, "%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n", il4965_desc_lookup(desc), desc, time, data1, data2, line); - IL_ERR(priv, "pc blink1 blink2 ilink1 ilink2 hcmd\n"); - IL_ERR(priv, "0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n", + IL_ERR(il, "pc blink1 blink2 ilink1 ilink2 hcmd\n"); + IL_ERR(il, "0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n", pc, blink1, blink2, ilink1, ilink2, hcmd); } -static void il4965_rf_kill_ct_config(struct il_priv *priv) +static void il4965_rf_kill_ct_config(struct il_priv *il) { struct il_ct_kill_config cmd; unsigned long flags; int ret = 0; - spin_lock_irqsave(&priv->lock, flags); - il_write32(priv, CSR_UCODE_DRV_GP1_CLR, + spin_lock_irqsave(&il->lock, flags); + il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); cmd.critical_temperature_R = - cpu_to_le32(priv->hw_params.ct_kill_threshold); + cpu_to_le32(il->hw_params.ct_kill_threshold); - ret = il_send_cmd_pdu(priv, REPLY_CT_KILL_CONFIG_CMD, + ret = il_send_cmd_pdu(il, REPLY_CT_KILL_CONFIG_CMD, sizeof(cmd), &cmd); if (ret) - IL_ERR(priv, "REPLY_CT_KILL_CONFIG_CMD failed\n"); + IL_ERR(il, "REPLY_CT_KILL_CONFIG_CMD failed\n"); else - IL_DEBUG_INFO(priv, "REPLY_CT_KILL_CONFIG_CMD " + IL_DEBUG_INFO(il, "REPLY_CT_KILL_CONFIG_CMD " "succeeded, " "critical temperature is %d\n", - priv->hw_params.ct_kill_threshold); + il->hw_params.ct_kill_threshold); } static const s8 default_queue_to_tx_fifo[] = { @@ -1612,62 +1612,62 @@ static const s8 default_queue_to_tx_fifo[] = { IL_TX_FIFO_UNUSED, }; -static int il4965_alive_notify(struct il_priv *priv) +static int il4965_alive_notify(struct il_priv *il) { u32 a; unsigned long flags; int i, chan; u32 reg_val; - spin_lock_irqsave(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); /* Clear 4965's internal Tx Scheduler data base */ - priv->scd_base_addr = il_read_prph(priv, + il->scd_base_addr = il_read_prph(il, IWL49_SCD_SRAM_BASE_ADDR); - a = priv->scd_base_addr + IWL49_SCD_CONTEXT_DATA_OFFSET; - for (; a < priv->scd_base_addr + IWL49_SCD_TX_STTS_BITMAP_OFFSET; a += 4) - il_write_targ_mem(priv, a, 0); - for (; a < priv->scd_base_addr + IWL49_SCD_TRANSLATE_TBL_OFFSET; a += 4) - il_write_targ_mem(priv, a, 0); - for (; a < priv->scd_base_addr + - IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(priv->hw_params.max_txq_num); a += 4) - il_write_targ_mem(priv, a, 0); + a = il->scd_base_addr + IWL49_SCD_CONTEXT_DATA_OFFSET; + for (; a < il->scd_base_addr + IWL49_SCD_TX_STTS_BITMAP_OFFSET; a += 4) + il_write_targ_mem(il, a, 0); + for (; a < il->scd_base_addr + IWL49_SCD_TRANSLATE_TBL_OFFSET; a += 4) + il_write_targ_mem(il, a, 0); + for (; a < il->scd_base_addr + + IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(il->hw_params.max_txq_num); a += 4) + il_write_targ_mem(il, a, 0); /* Tel 4965 where to find Tx byte count tables */ - il_write_prph(priv, IWL49_SCD_DRAM_BASE_ADDR, - priv->scd_bc_tbls.dma >> 10); + il_write_prph(il, IWL49_SCD_DRAM_BASE_ADDR, + il->scd_bc_tbls.dma >> 10); /* Enable DMA channel */ for (chan = 0; chan < FH49_TCSR_CHNL_NUM ; chan++) - il_write_direct32(priv, + il_write_direct32(il, FH_TCSR_CHNL_TX_CONFIG_REG(chan), FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE); /* Update FH chicken bits */ - reg_val = il_read_direct32(priv, FH_TX_CHICKEN_BITS_REG); - il_write_direct32(priv, FH_TX_CHICKEN_BITS_REG, + reg_val = il_read_direct32(il, FH_TX_CHICKEN_BITS_REG); + il_write_direct32(il, FH_TX_CHICKEN_BITS_REG, reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); /* Disable chain mode for all queues */ - il_write_prph(priv, IWL49_SCD_QUEUECHAIN_SEL, 0); + il_write_prph(il, IWL49_SCD_QUEUECHAIN_SEL, 0); /* Initialize each Tx queue (including the command queue) */ - for (i = 0; i < priv->hw_params.max_txq_num; i++) { + for (i = 0; i < il->hw_params.max_txq_num; i++) { /* TFD circular buffer read/write indexes */ - il_write_prph(priv, IWL49_SCD_QUEUE_RDPTR(i), 0); - il_write_direct32(priv, HBUS_TARG_WRPTR, 0 | (i << 8)); + il_write_prph(il, IWL49_SCD_QUEUE_RDPTR(i), 0); + il_write_direct32(il, HBUS_TARG_WRPTR, 0 | (i << 8)); /* Max Tx Window size for Scheduler-ACK mode */ - il_write_targ_mem(priv, priv->scd_base_addr + + il_write_targ_mem(il, il->scd_base_addr + IWL49_SCD_CONTEXT_QUEUE_OFFSET(i), (SCD_WIN_SIZE << IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); /* Frame limit */ - il_write_targ_mem(priv, priv->scd_base_addr + + il_write_targ_mem(il, il->scd_base_addr + IWL49_SCD_CONTEXT_QUEUE_OFFSET(i) + sizeof(u32), (SCD_FRAME_LIMIT << @@ -1675,36 +1675,36 @@ static int il4965_alive_notify(struct il_priv *priv) IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); } - il_write_prph(priv, IWL49_SCD_INTERRUPT_MASK, - (1 << priv->hw_params.max_txq_num) - 1); + il_write_prph(il, IWL49_SCD_INTERRUPT_MASK, + (1 << il->hw_params.max_txq_num) - 1); /* Activate all Tx DMA/FIFO channels */ - il4965_txq_set_sched(priv, IL_MASK(0, 6)); + il4965_txq_set_sched(il, IL_MASK(0, 6)); - il4965_set_wr_ptrs(priv, IL_DEFAULT_CMD_QUEUE_NUM, 0); + il4965_set_wr_ptrs(il, IL_DEFAULT_CMD_QUEUE_NUM, 0); /* make sure all queue are not stopped */ - memset(&priv->queue_stopped[0], 0, sizeof(priv->queue_stopped)); + memset(&il->queue_stopped[0], 0, sizeof(il->queue_stopped)); for (i = 0; i < 4; i++) - atomic_set(&priv->queue_stop_count[i], 0); + atomic_set(&il->queue_stop_count[i], 0); /* reset to 0 to enable all the queue first */ - priv->txq_ctx_active_msk = 0; + il->txq_ctx_active_msk = 0; /* Map each Tx/cmd queue to its corresponding fifo */ BUILD_BUG_ON(ARRAY_SIZE(default_queue_to_tx_fifo) != 7); for (i = 0; i < ARRAY_SIZE(default_queue_to_tx_fifo); i++) { int ac = default_queue_to_tx_fifo[i]; - il_txq_ctx_activate(priv, i); + il_txq_ctx_activate(il, i); if (ac == IL_TX_FIFO_UNUSED) continue; - il4965_tx_queue_set_status(priv, &priv->txq[i], ac, 0); + il4965_tx_queue_set_status(il, &il->txq[i], ac, 0); } - spin_unlock_irqrestore(&priv->lock, flags); + spin_unlock_irqrestore(&il->lock, flags); return 0; } @@ -1714,50 +1714,50 @@ static int il4965_alive_notify(struct il_priv *priv) * from protocol/runtime uCode (initialization uCode's * Alive gets handled by il_init_alive_start()). */ -static void il4965_alive_start(struct il_priv *priv) +static void il4965_alive_start(struct il_priv *il) { int ret = 0; - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; - IL_DEBUG_INFO(priv, "Runtime Alive received.\n"); + IL_DEBUG_INFO(il, "Runtime Alive received.\n"); - if (priv->card_alive.is_valid != UCODE_VALID_OK) { + if (il->card_alive.is_valid != UCODE_VALID_OK) { /* We had an error bringing up the hardware, so take it * all the way back down so we can try again */ - IL_DEBUG_INFO(priv, "Alive failed.\n"); + IL_DEBUG_INFO(il, "Alive failed.\n"); goto restart; } /* Initialize uCode has loaded Runtime uCode ... verify inst image. * This is a paranoid check, because we would not have gotten the * "runtime" alive if code weren't properly loaded. */ - if (il4965_verify_ucode(priv)) { + if (il4965_verify_ucode(il)) { /* Runtime instruction load was bad; * take it all the way back down so we can try again */ - IL_DEBUG_INFO(priv, "Bad runtime uCode load.\n"); + IL_DEBUG_INFO(il, "Bad runtime uCode load.\n"); goto restart; } - ret = il4965_alive_notify(priv); + ret = il4965_alive_notify(il); if (ret) { - IL_WARN(priv, + IL_WARN(il, "Could not complete ALIVE transition [ntf]: %d\n", ret); goto restart; } /* After the ALIVE response, we can send host commands to the uCode */ - set_bit(STATUS_ALIVE, &priv->status); + set_bit(STATUS_ALIVE, &il->status); /* Enable watchdog to monitor the driver tx queues */ - il_setup_watchdog(priv); + il_setup_watchdog(il); - if (il_is_rfkill(priv)) + if (il_is_rfkill(il)) return; - ieee80211_wake_queues(priv->hw); + ieee80211_wake_queues(il->hw); - priv->active_rate = IL_RATES_MASK; + il->active_rate = IL_RATES_MASK; if (il_is_associated_ctx(ctx)) { struct il_rxon_cmd *active_rxon = @@ -1768,290 +1768,290 @@ static void il4965_alive_start(struct il_priv *priv) } else { struct il_rxon_context *tmp; /* Initialize our rx_config data */ - for_each_context(priv, tmp) - il_connection_init_rx_config(priv, tmp); + for_each_context(il, tmp) + il_connection_init_rx_config(il, tmp); - if (priv->cfg->ops->hcmd->set_rxon_chain) - priv->cfg->ops->hcmd->set_rxon_chain(priv, ctx); + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); } /* Configure bluetooth coexistence if enabled */ - il_send_bt_config(priv); + il_send_bt_config(il); - il4965_reset_run_time_calib(priv); + il4965_reset_run_time_calib(il); - set_bit(STATUS_READY, &priv->status); + set_bit(STATUS_READY, &il->status); /* Configure the adapter for unassociated operation */ - il_commit_rxon(priv, ctx); + il_commit_rxon(il, ctx); /* At this point, the NIC is initialized and operational */ - il4965_rf_kill_ct_config(priv); + il4965_rf_kill_ct_config(il); - IL_DEBUG_INFO(priv, "ALIVE processing complete.\n"); - wake_up(&priv->wait_command_queue); + IL_DEBUG_INFO(il, "ALIVE processing complete.\n"); + wake_up(&il->wait_command_queue); - il_power_update_mode(priv, true); - IL_DEBUG_INFO(priv, "Updated power mode\n"); + il_power_update_mode(il, true); + IL_DEBUG_INFO(il, "Updated power mode\n"); return; restart: - queue_work(priv->workqueue, &priv->restart); + queue_work(il->workqueue, &il->restart); } -static void il4965_cancel_deferred_work(struct il_priv *priv); +static void il4965_cancel_deferred_work(struct il_priv *il); -static void __il4965_down(struct il_priv *priv) +static void __il4965_down(struct il_priv *il) { unsigned long flags; int exit_pending; - IL_DEBUG_INFO(priv, DRV_NAME " is going down\n"); + IL_DEBUG_INFO(il, DRV_NAME " is going down\n"); - il_scan_cancel_timeout(priv, 200); + il_scan_cancel_timeout(il, 200); - exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &priv->status); + exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &il->status); /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set * to prevent rearm timer */ - del_timer_sync(&priv->watchdog); + del_timer_sync(&il->watchdog); - il_clear_ucode_stations(priv, NULL); - il_dealloc_bcast_stations(priv); - il_clear_driver_stations(priv); + il_clear_ucode_stations(il, NULL); + il_dealloc_bcast_stations(il); + il_clear_driver_stations(il); /* Unblock any waiting calls */ - wake_up_all(&priv->wait_command_queue); + wake_up_all(&il->wait_command_queue); /* Wipe out the EXIT_PENDING status bit if we are not actually * exiting the module */ if (!exit_pending) - clear_bit(STATUS_EXIT_PENDING, &priv->status); + clear_bit(STATUS_EXIT_PENDING, &il->status); /* stop and reset the on-board processor */ - il_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + il_write32(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); /* tell the device to stop sending interrupts */ - spin_lock_irqsave(&priv->lock, flags); - il_disable_interrupts(priv); - spin_unlock_irqrestore(&priv->lock, flags); - il4965_synchronize_irq(priv); + spin_lock_irqsave(&il->lock, flags); + il_disable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); + il4965_synchronize_irq(il); - if (priv->mac80211_registered) - ieee80211_stop_queues(priv->hw); + if (il->mac80211_registered) + ieee80211_stop_queues(il->hw); /* If we have not previously called il_init() then * clear all bits but the RF Kill bit and return */ - if (!il_is_init(priv)) { - priv->status = test_bit(STATUS_RF_KILL_HW, &priv->status) << + if (!il_is_init(il)) { + il->status = test_bit(STATUS_RF_KILL_HW, &il->status) << STATUS_RF_KILL_HW | - test_bit(STATUS_GEO_CONFIGURED, &priv->status) << + test_bit(STATUS_GEO_CONFIGURED, &il->status) << STATUS_GEO_CONFIGURED | - test_bit(STATUS_EXIT_PENDING, &priv->status) << + test_bit(STATUS_EXIT_PENDING, &il->status) << STATUS_EXIT_PENDING; goto exit; } /* ...otherwise clear out all the status bits but the RF Kill * bit and continue taking the NIC down. */ - priv->status &= test_bit(STATUS_RF_KILL_HW, &priv->status) << + il->status &= test_bit(STATUS_RF_KILL_HW, &il->status) << STATUS_RF_KILL_HW | - test_bit(STATUS_GEO_CONFIGURED, &priv->status) << + test_bit(STATUS_GEO_CONFIGURED, &il->status) << STATUS_GEO_CONFIGURED | - test_bit(STATUS_FW_ERROR, &priv->status) << + test_bit(STATUS_FW_ERROR, &il->status) << STATUS_FW_ERROR | - test_bit(STATUS_EXIT_PENDING, &priv->status) << + test_bit(STATUS_EXIT_PENDING, &il->status) << STATUS_EXIT_PENDING; - il4965_txq_ctx_stop(priv); - il4965_rxq_stop(priv); + il4965_txq_ctx_stop(il); + il4965_rxq_stop(il); /* Power-down device's busmaster DMA clocks */ - il_write_prph(priv, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); + il_write_prph(il, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); udelay(5); /* Make sure (redundant) we've released our request to stay awake */ - il_clear_bit(priv, CSR_GP_CNTRL, + il_clear_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); /* Stop the device, and put it in low power state */ - il_apm_stop(priv); + il_apm_stop(il); exit: - memset(&priv->card_alive, 0, sizeof(struct il_alive_resp)); + memset(&il->card_alive, 0, sizeof(struct il_alive_resp)); - dev_kfree_skb(priv->beacon_skb); - priv->beacon_skb = NULL; + dev_kfree_skb(il->beacon_skb); + il->beacon_skb = NULL; /* clear out any free frames */ - il4965_clear_free_frames(priv); + il4965_clear_free_frames(il); } -static void il4965_down(struct il_priv *priv) +static void il4965_down(struct il_priv *il) { - mutex_lock(&priv->mutex); - __il4965_down(priv); - mutex_unlock(&priv->mutex); + mutex_lock(&il->mutex); + __il4965_down(il); + mutex_unlock(&il->mutex); - il4965_cancel_deferred_work(priv); + il4965_cancel_deferred_work(il); } #define HW_READY_TIMEOUT (50) -static int il4965_set_hw_ready(struct il_priv *priv) +static int il4965_set_hw_ready(struct il_priv *il) { int ret = 0; - il_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_NIC_READY); /* See if we got it */ - ret = il_poll_bit(priv, CSR_HW_IF_CONFIG_REG, + ret = il_poll_bit(il, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, HW_READY_TIMEOUT); if (ret != -ETIMEDOUT) - priv->hw_ready = true; + il->hw_ready = true; else - priv->hw_ready = false; + il->hw_ready = false; - IL_DEBUG_INFO(priv, "hardware %s\n", - (priv->hw_ready == 1) ? "ready" : "not ready"); + IL_DEBUG_INFO(il, "hardware %s\n", + (il->hw_ready == 1) ? "ready" : "not ready"); return ret; } -static int il4965_prepare_card_hw(struct il_priv *priv) +static int il4965_prepare_card_hw(struct il_priv *il) { int ret = 0; - IL_DEBUG_INFO(priv, "il4965_prepare_card_hw enter\n"); + IL_DEBUG_INFO(il, "il4965_prepare_card_hw enter\n"); - ret = il4965_set_hw_ready(priv); - if (priv->hw_ready) + ret = il4965_set_hw_ready(il); + if (il->hw_ready) return ret; /* If HW is not ready, prepare the conditions to check again */ - il_set_bit(priv, CSR_HW_IF_CONFIG_REG, + il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_PREPARE); - ret = il_poll_bit(priv, CSR_HW_IF_CONFIG_REG, + ret = il_poll_bit(il, CSR_HW_IF_CONFIG_REG, ~CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, 150000); /* HW should be ready by now, check again. */ if (ret != -ETIMEDOUT) - il4965_set_hw_ready(priv); + il4965_set_hw_ready(il); return ret; } #define MAX_HW_RESTARTS 5 -static int __il4965_up(struct il_priv *priv) +static int __il4965_up(struct il_priv *il) { struct il_rxon_context *ctx; int i; int ret; - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { - IL_WARN(priv, "Exit pending; will not bring the NIC up\n"); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) { + IL_WARN(il, "Exit pending; will not bring the NIC up\n"); return -EIO; } - if (!priv->ucode_data_backup.v_addr || !priv->ucode_data.v_addr) { - IL_ERR(priv, "ucode not available for device bringup\n"); + if (!il->ucode_data_backup.v_addr || !il->ucode_data.v_addr) { + IL_ERR(il, "ucode not available for device bringup\n"); return -EIO; } - for_each_context(priv, ctx) { - ret = il4965_alloc_bcast_station(priv, ctx); + for_each_context(il, ctx) { + ret = il4965_alloc_bcast_station(il, ctx); if (ret) { - il_dealloc_bcast_stations(priv); + il_dealloc_bcast_stations(il); return ret; } } - il4965_prepare_card_hw(priv); + il4965_prepare_card_hw(il); - if (!priv->hw_ready) { - IL_WARN(priv, "Exit HW not ready\n"); + if (!il->hw_ready) { + IL_WARN(il, "Exit HW not ready\n"); return -EIO; } /* If platform's RF_KILL switch is NOT set to KILL */ - if (il_read32(priv, + if (il_read32(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) - clear_bit(STATUS_RF_KILL_HW, &priv->status); + clear_bit(STATUS_RF_KILL_HW, &il->status); else - set_bit(STATUS_RF_KILL_HW, &priv->status); + set_bit(STATUS_RF_KILL_HW, &il->status); - if (il_is_rfkill(priv)) { - wiphy_rfkill_set_hw_state(priv->hw->wiphy, true); + if (il_is_rfkill(il)) { + wiphy_rfkill_set_hw_state(il->hw->wiphy, true); - il_enable_interrupts(priv); - IL_WARN(priv, "Radio disabled by HW RF Kill switch\n"); + il_enable_interrupts(il); + IL_WARN(il, "Radio disabled by HW RF Kill switch\n"); return 0; } - il_write32(priv, CSR_INT, 0xFFFFFFFF); + il_write32(il, CSR_INT, 0xFFFFFFFF); /* must be initialised before il_hw_nic_init */ - priv->cmd_queue = IL_DEFAULT_CMD_QUEUE_NUM; + il->cmd_queue = IL_DEFAULT_CMD_QUEUE_NUM; - ret = il4965_hw_nic_init(priv); + ret = il4965_hw_nic_init(il); if (ret) { - IL_ERR(priv, "Unable to init nic\n"); + IL_ERR(il, "Unable to init nic\n"); return ret; } /* make sure rfkill handshake bits are cleared */ - il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - il_write32(priv, CSR_UCODE_DRV_GP1_CLR, + il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); /* clear (again), then enable host interrupts */ - il_write32(priv, CSR_INT, 0xFFFFFFFF); - il_enable_interrupts(priv); + il_write32(il, CSR_INT, 0xFFFFFFFF); + il_enable_interrupts(il); /* really make sure rfkill handshake bits are cleared */ - il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - il_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); /* Copy original ucode data image from disk into backup cache. * This will be used to initialize the on-board processor's * data SRAM for a clean start when the runtime program first loads. */ - memcpy(priv->ucode_data_backup.v_addr, priv->ucode_data.v_addr, - priv->ucode_data.len); + memcpy(il->ucode_data_backup.v_addr, il->ucode_data.v_addr, + il->ucode_data.len); for (i = 0; i < MAX_HW_RESTARTS; i++) { /* load bootstrap state machine, * load bootstrap program into processor's memory, * prepare to load the "initialize" uCode */ - ret = priv->cfg->ops->lib->load_ucode(priv); + ret = il->cfg->ops->lib->load_ucode(il); if (ret) { - IL_ERR(priv, "Unable to set up bootstrap uCode: %d\n", + IL_ERR(il, "Unable to set up bootstrap uCode: %d\n", ret); continue; } /* start card; "initialize" will load runtime ucode */ - il4965_nic_start(priv); + il4965_nic_start(il); - IL_DEBUG_INFO(priv, DRV_NAME " is coming up\n"); + IL_DEBUG_INFO(il, DRV_NAME " is coming up\n"); return 0; } - set_bit(STATUS_EXIT_PENDING, &priv->status); - __il4965_down(priv); - clear_bit(STATUS_EXIT_PENDING, &priv->status); + set_bit(STATUS_EXIT_PENDING, &il->status); + __il4965_down(il); + clear_bit(STATUS_EXIT_PENDING, &il->status); /* tried to restart and config the device for as long as our * patience could withstand */ - IL_ERR(priv, "Unable to initialize device after %d attempts.\n", i); + IL_ERR(il, "Unable to initialize device after %d attempts.\n", i); return -EIO; } @@ -2064,100 +2064,100 @@ static int __il4965_up(struct il_priv *priv) static void il4965_bg_init_alive_start(struct work_struct *data) { - struct il_priv *priv = + struct il_priv *il = container_of(data, struct il_priv, init_alive_start.work); - mutex_lock(&priv->mutex); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) goto out; - priv->cfg->ops->lib->init_alive_start(priv); + il->cfg->ops->lib->init_alive_start(il); out: - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); } static void il4965_bg_alive_start(struct work_struct *data) { - struct il_priv *priv = + struct il_priv *il = container_of(data, struct il_priv, alive_start.work); - mutex_lock(&priv->mutex); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) goto out; - il4965_alive_start(priv); + il4965_alive_start(il); out: - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); } static void il4965_bg_run_time_calib_work(struct work_struct *work) { - struct il_priv *priv = container_of(work, struct il_priv, + struct il_priv *il = container_of(work, struct il_priv, run_time_calib_work); - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &priv->status) || - test_bit(STATUS_SCANNING, &priv->status)) { - mutex_unlock(&priv->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status) || + test_bit(STATUS_SCANNING, &il->status)) { + mutex_unlock(&il->mutex); return; } - if (priv->start_calib) { - il4965_chain_noise_calibration(priv, - (void *)&priv->_4965.statistics); - il4965_sensitivity_calibration(priv, - (void *)&priv->_4965.statistics); + if (il->start_calib) { + il4965_chain_noise_calibration(il, + (void *)&il->_4965.statistics); + il4965_sensitivity_calibration(il, + (void *)&il->_4965.statistics); } - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); } static void il4965_bg_restart(struct work_struct *data) { - struct il_priv *priv = container_of(data, struct il_priv, restart); + struct il_priv *il = container_of(data, struct il_priv, restart); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; - if (test_and_clear_bit(STATUS_FW_ERROR, &priv->status)) { + if (test_and_clear_bit(STATUS_FW_ERROR, &il->status)) { struct il_rxon_context *ctx; - mutex_lock(&priv->mutex); - for_each_context(priv, ctx) + mutex_lock(&il->mutex); + for_each_context(il, ctx) ctx->vif = NULL; - priv->is_open = 0; + il->is_open = 0; - __il4965_down(priv); + __il4965_down(il); - mutex_unlock(&priv->mutex); - il4965_cancel_deferred_work(priv); - ieee80211_restart_hw(priv->hw); + mutex_unlock(&il->mutex); + il4965_cancel_deferred_work(il); + ieee80211_restart_hw(il->hw); } else { - il4965_down(priv); + il4965_down(il); - mutex_lock(&priv->mutex); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) { - mutex_unlock(&priv->mutex); + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) { + mutex_unlock(&il->mutex); return; } - __il4965_up(priv); - mutex_unlock(&priv->mutex); + __il4965_up(il); + mutex_unlock(&il->mutex); } } static void il4965_bg_rx_replenish(struct work_struct *data) { - struct il_priv *priv = + struct il_priv *il = container_of(data, struct il_priv, rx_replenish); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; - mutex_lock(&priv->mutex); - il4965_rx_replenish(priv); - mutex_unlock(&priv->mutex); + mutex_lock(&il->mutex); + il4965_rx_replenish(il); + mutex_unlock(&il->mutex); } /***************************************************************************** @@ -2172,11 +2172,11 @@ static void il4965_bg_rx_replenish(struct work_struct *data) * Not a mac80211 entry point function, but it fits in with all the * other mac80211 functions grouped here. */ -static int il4965_mac_setup_register(struct il_priv *priv, +static int il4965_mac_setup_register(struct il_priv *il, u32 max_probe_length) { int ret; - struct ieee80211_hw *hw = priv->hw; + struct ieee80211_hw *hw = il->hw; struct il_rxon_context *ctx; hw->rate_control_algorithm = "iwl-4965-rs"; @@ -2188,14 +2188,14 @@ static int il4965_mac_setup_register(struct il_priv *priv, IEEE80211_HW_SPECTRUM_MGMT | IEEE80211_HW_REPORTS_TX_ACK_STATUS; - if (priv->cfg->sku & IL_SKU_N) + if (il->cfg->sku & IL_SKU_N) hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | IEEE80211_HW_SUPPORTS_STATIC_SMPS; hw->sta_data_size = sizeof(struct il_station_priv); hw->vif_data_size = sizeof(struct il_vif_priv); - for_each_context(priv, ctx) { + for_each_context(il, ctx) { hw->wiphy->interface_modes |= ctx->interface_modes; hw->wiphy->interface_modes |= ctx->exclusive_interface_modes; } @@ -2218,21 +2218,21 @@ static int il4965_mac_setup_register(struct il_priv *priv, hw->max_listen_interval = IL_CONN_MAX_LISTEN_INTERVAL; - if (priv->bands[IEEE80211_BAND_2GHZ].n_channels) - priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = - &priv->bands[IEEE80211_BAND_2GHZ]; - if (priv->bands[IEEE80211_BAND_5GHZ].n_channels) - priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = - &priv->bands[IEEE80211_BAND_5GHZ]; + if (il->bands[IEEE80211_BAND_2GHZ].n_channels) + il->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = + &il->bands[IEEE80211_BAND_2GHZ]; + if (il->bands[IEEE80211_BAND_5GHZ].n_channels) + il->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = + &il->bands[IEEE80211_BAND_5GHZ]; - il_leds_init(priv); + il_leds_init(il); - ret = ieee80211_register_hw(priv->hw); + ret = ieee80211_register_hw(il->hw); if (ret) { - IL_ERR(priv, "Failed to register hw (error %d)\n", ret); + IL_ERR(il, "Failed to register hw (error %d)\n", ret); return ret; } - priv->mac80211_registered = 1; + il->mac80211_registered = 1; return 0; } @@ -2240,81 +2240,81 @@ static int il4965_mac_setup_register(struct il_priv *priv, int il4965_mac_start(struct ieee80211_hw *hw) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; int ret; - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); /* we should be verifying the device is ready to be opened */ - mutex_lock(&priv->mutex); - ret = __il4965_up(priv); - mutex_unlock(&priv->mutex); + mutex_lock(&il->mutex); + ret = __il4965_up(il); + mutex_unlock(&il->mutex); if (ret) return ret; - if (il_is_rfkill(priv)) + if (il_is_rfkill(il)) goto out; - IL_DEBUG_INFO(priv, "Start UP work done.\n"); + IL_DEBUG_INFO(il, "Start UP work done.\n"); /* Wait for START_ALIVE from Run Time ucode. Otherwise callbacks from * mac80211 will not be run successfully. */ - ret = wait_event_timeout(priv->wait_command_queue, - test_bit(STATUS_READY, &priv->status), + ret = wait_event_timeout(il->wait_command_queue, + test_bit(STATUS_READY, &il->status), UCODE_READY_TIMEOUT); if (!ret) { - if (!test_bit(STATUS_READY, &priv->status)) { - IL_ERR(priv, "START_ALIVE timeout after %dms.\n", + if (!test_bit(STATUS_READY, &il->status)) { + IL_ERR(il, "START_ALIVE timeout after %dms.\n", jiffies_to_msecs(UCODE_READY_TIMEOUT)); return -ETIMEDOUT; } } - il4965_led_enable(priv); + il4965_led_enable(il); out: - priv->is_open = 1; - IL_DEBUG_MAC80211(priv, "leave\n"); + il->is_open = 1; + IL_DEBUG_MAC80211(il, "leave\n"); return 0; } void il4965_mac_stop(struct ieee80211_hw *hw) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); - if (!priv->is_open) + if (!il->is_open) return; - priv->is_open = 0; + il->is_open = 0; - il4965_down(priv); + il4965_down(il); - flush_workqueue(priv->workqueue); + flush_workqueue(il->workqueue); /* User space software may expect getting rfkill changes * even if interface is down */ - il_write32(priv, CSR_INT, 0xFFFFFFFF); - il_enable_rfkill_int(priv); + il_write32(il, CSR_INT, 0xFFFFFFFF); + il_enable_rfkill_int(il); - IL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(il, "leave\n"); } void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; - IL_DEBUG_MACDUMP(priv, "enter\n"); + IL_DEBUG_MACDUMP(il, "enter\n"); - IL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, + IL_DEBUG_TX(il, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); - if (il4965_tx_skb(priv, skb)) + if (il4965_tx_skb(il, skb)) dev_kfree_skb_any(skb); - IL_DEBUG_MACDUMP(priv, "leave\n"); + IL_DEBUG_MACDUMP(il, "leave\n"); } void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, @@ -2323,41 +2323,41 @@ void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, struct ieee80211_sta *sta, u32 iv32, u16 *phase1key) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; struct il_vif_priv *vif_priv = (void *)vif->drv_priv; - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); - il4965_update_tkip_key(priv, vif_priv->ctx, keyconf, sta, + il4965_update_tkip_key(il, vif_priv->ctx, keyconf, sta, iv32, phase1key); - IL_DEBUG_MAC80211(priv, "leave\n"); + IL_DEBUG_MAC80211(il, "leave\n"); } int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, struct ieee80211_vif *vif, struct ieee80211_sta *sta, struct ieee80211_key_conf *key) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; struct il_vif_priv *vif_priv = (void *)vif->drv_priv; struct il_rxon_context *ctx = vif_priv->ctx; int ret; u8 sta_id; bool is_default_wep_key = false; - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); - if (priv->cfg->mod_params->sw_crypto) { - IL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n"); + if (il->cfg->mod_params->sw_crypto) { + IL_DEBUG_MAC80211(il, "leave - hwcrypto disabled\n"); return -EOPNOTSUPP; } - sta_id = il_sta_id_or_broadcast(priv, vif_priv->ctx, sta); + sta_id = il_sta_id_or_broadcast(il, vif_priv->ctx, sta); if (sta_id == IL_INVALID_STATION) return -EINVAL; - mutex_lock(&priv->mutex); - il_scan_cancel_timeout(priv, 100); + mutex_lock(&il->mutex); + il_scan_cancel_timeout(il, 100); /* * If we are getting WEP group key and we didn't receive any key mapping @@ -2378,29 +2378,29 @@ int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, switch (cmd) { case SET_KEY: if (is_default_wep_key) - ret = il4965_set_default_wep_key(priv, + ret = il4965_set_default_wep_key(il, vif_priv->ctx, key); else - ret = il4965_set_dynamic_key(priv, vif_priv->ctx, + ret = il4965_set_dynamic_key(il, vif_priv->ctx, key, sta_id); - IL_DEBUG_MAC80211(priv, "enable hwcrypto key\n"); + IL_DEBUG_MAC80211(il, "enable hwcrypto key\n"); break; case DISABLE_KEY: if (is_default_wep_key) - ret = il4965_remove_default_wep_key(priv, ctx, key); + ret = il4965_remove_default_wep_key(il, ctx, key); else - ret = il4965_remove_dynamic_key(priv, ctx, + ret = il4965_remove_dynamic_key(il, ctx, key, sta_id); - IL_DEBUG_MAC80211(priv, "disable hwcrypto key\n"); + IL_DEBUG_MAC80211(il, "disable hwcrypto key\n"); break; default: ret = -EINVAL; } - mutex_unlock(&priv->mutex); - IL_DEBUG_MAC80211(priv, "leave\n"); + mutex_unlock(&il->mutex); + IL_DEBUG_MAC80211(il, "leave\n"); return ret; } @@ -2411,43 +2411,43 @@ int il4965_mac_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_sta *sta, u16 tid, u16 *ssn, u8 buf_size) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; int ret = -EINVAL; - IL_DEBUG_HT(priv, "A-MPDU action on addr %pM tid %d\n", + IL_DEBUG_HT(il, "A-MPDU action on addr %pM tid %d\n", sta->addr, tid); - if (!(priv->cfg->sku & IL_SKU_N)) + if (!(il->cfg->sku & IL_SKU_N)) return -EACCES; - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); switch (action) { case IEEE80211_AMPDU_RX_START: - IL_DEBUG_HT(priv, "start Rx\n"); - ret = il4965_sta_rx_agg_start(priv, sta, tid, *ssn); + IL_DEBUG_HT(il, "start Rx\n"); + ret = il4965_sta_rx_agg_start(il, sta, tid, *ssn); break; case IEEE80211_AMPDU_RX_STOP: - IL_DEBUG_HT(priv, "stop Rx\n"); - ret = il4965_sta_rx_agg_stop(priv, sta, tid); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + IL_DEBUG_HT(il, "stop Rx\n"); + ret = il4965_sta_rx_agg_stop(il, sta, tid); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) ret = 0; break; case IEEE80211_AMPDU_TX_START: - IL_DEBUG_HT(priv, "start Tx\n"); - ret = il4965_tx_agg_start(priv, vif, sta, tid, ssn); + IL_DEBUG_HT(il, "start Tx\n"); + ret = il4965_tx_agg_start(il, vif, sta, tid, ssn); break; case IEEE80211_AMPDU_TX_STOP: - IL_DEBUG_HT(priv, "stop Tx\n"); - ret = il4965_tx_agg_stop(priv, vif, sta, tid); - if (test_bit(STATUS_EXIT_PENDING, &priv->status)) + IL_DEBUG_HT(il, "stop Tx\n"); + ret = il4965_tx_agg_stop(il, vif, sta, tid); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) ret = 0; break; case IEEE80211_AMPDU_TX_OPERATIONAL: ret = 0; break; } - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); return ret; } @@ -2456,39 +2456,39 @@ int il4965_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; struct il_station_priv *sta_priv = (void *)sta->drv_priv; struct il_vif_priv *vif_priv = (void *)vif->drv_priv; bool is_ap = vif->type == NL80211_IFTYPE_STATION; int ret; u8 sta_id; - IL_DEBUG_INFO(priv, "received request to add station %pM\n", + IL_DEBUG_INFO(il, "received request to add station %pM\n", sta->addr); - mutex_lock(&priv->mutex); - IL_DEBUG_INFO(priv, "proceeding to add station %pM\n", + mutex_lock(&il->mutex); + IL_DEBUG_INFO(il, "proceeding to add station %pM\n", sta->addr); sta_priv->common.sta_id = IL_INVALID_STATION; atomic_set(&sta_priv->pending_frames, 0); - ret = il_add_station_common(priv, vif_priv->ctx, sta->addr, + ret = il_add_station_common(il, vif_priv->ctx, sta->addr, is_ap, sta, &sta_id); if (ret) { - IL_ERR(priv, "Unable to add station %pM (%d)\n", + IL_ERR(il, "Unable to add station %pM (%d)\n", sta->addr, ret); /* Should we return success if return code is EEXIST ? */ - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); return ret; } sta_priv->common.sta_id = sta_id; /* Initialize rate scaling */ - IL_DEBUG_INFO(priv, "Initializing rate scaling for station %pM\n", + IL_DEBUG_INFO(il, "Initializing rate scaling for station %pM\n", sta->addr); - il4965_rs_rate_init(priv, sta, sta_id); - mutex_unlock(&priv->mutex); + il4965_rs_rate_init(il, sta, sta_id); + mutex_unlock(&il->mutex); return 0; } @@ -2496,46 +2496,46 @@ int il4965_mac_sta_add(struct ieee80211_hw *hw, void il4965_mac_channel_switch(struct ieee80211_hw *hw, struct ieee80211_channel_switch *ch_switch) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; const struct il_channel_info *ch_info; struct ieee80211_conf *conf = &hw->conf; struct ieee80211_channel *channel = ch_switch->channel; - struct il_ht_config *ht_conf = &priv->current_ht_config; + struct il_ht_config *ht_conf = &il->current_ht_config; - struct il_rxon_context *ctx = &priv->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; u16 ch; - IL_DEBUG_MAC80211(priv, "enter\n"); + IL_DEBUG_MAC80211(il, "enter\n"); - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); - if (il_is_rfkill(priv)) + if (il_is_rfkill(il)) goto out; - if (test_bit(STATUS_EXIT_PENDING, &priv->status) || - test_bit(STATUS_SCANNING, &priv->status) || - test_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status) || + test_bit(STATUS_SCANNING, &il->status) || + test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status)) goto out; if (!il_is_associated_ctx(ctx)) goto out; - if (!priv->cfg->ops->lib->set_channel_switch) + if (!il->cfg->ops->lib->set_channel_switch) goto out; ch = channel->hw_value; if (le16_to_cpu(ctx->active.channel) == ch) goto out; - ch_info = il_get_channel_info(priv, channel->band, ch); + ch_info = il_get_channel_info(il, channel->band, ch); if (!il_is_channel_valid(ch_info)) { - IL_DEBUG_MAC80211(priv, "invalid channel\n"); + IL_DEBUG_MAC80211(il, "invalid channel\n"); goto out; } - spin_lock_irq(&priv->lock); + spin_lock_irq(&il->lock); - priv->current_ht_config.smps = conf->smps_mode; + il->current_ht_config.smps = conf->smps_mode; /* Configure HT40 channels */ ctx->ht.enabled = conf_is_ht(conf); @@ -2559,28 +2559,28 @@ void il4965_mac_channel_switch(struct ieee80211_hw *hw, if ((le16_to_cpu(ctx->staging.channel) != ch)) ctx->staging.flags = 0; - il_set_rxon_channel(priv, channel, ctx); - il_set_rxon_ht(priv, ht_conf); - il_set_flags_for_band(priv, ctx, channel->band, ctx->vif); + il_set_rxon_channel(il, channel, ctx); + il_set_rxon_ht(il, ht_conf); + il_set_flags_for_band(il, ctx, channel->band, ctx->vif); - spin_unlock_irq(&priv->lock); + spin_unlock_irq(&il->lock); - il_set_rate(priv); + il_set_rate(il); /* * at this point, staging_rxon has the * configuration for channel switch */ - set_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status); - priv->switch_channel = cpu_to_le16(ch); - if (priv->cfg->ops->lib->set_channel_switch(priv, ch_switch)) { - clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &priv->status); - priv->switch_channel = 0; + set_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status); + il->switch_channel = cpu_to_le16(ch); + if (il->cfg->ops->lib->set_channel_switch(il, ch_switch)) { + clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status); + il->switch_channel = 0; ieee80211_chswitch_done(ctx->vif, false); } out: - mutex_unlock(&priv->mutex); - IL_DEBUG_MAC80211(priv, "leave\n"); + mutex_unlock(&il->mutex); + IL_DEBUG_MAC80211(il, "leave\n"); } void il4965_configure_filter(struct ieee80211_hw *hw, @@ -2588,7 +2588,7 @@ void il4965_configure_filter(struct ieee80211_hw *hw, unsigned int *total_flags, u64 multicast) { - struct il_priv *priv = hw->priv; + struct il_priv *il = hw->priv; __le32 filter_or = 0, filter_nand = 0; struct il_rxon_context *ctx; @@ -2599,7 +2599,7 @@ void il4965_configure_filter(struct ieee80211_hw *hw, filter_nand |= (flag); \ } while (0) - IL_DEBUG_MAC80211(priv, "Enter: changed: 0x%x, total: 0x%x\n", + IL_DEBUG_MAC80211(il, "Enter: changed: 0x%x, total: 0x%x\n", changed_flags, *total_flags); CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); @@ -2609,9 +2609,9 @@ void il4965_configure_filter(struct ieee80211_hw *hw, #undef CHK - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); - for_each_context(priv, ctx) { + for_each_context(il, ctx) { ctx->staging.filter_flags &= ~filter_nand; ctx->staging.filter_flags |= filter_or; @@ -2621,7 +2621,7 @@ void il4965_configure_filter(struct ieee80211_hw *hw, */ } - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); /* * Receiving all multicast frames is always enabled by the @@ -2641,72 +2641,72 @@ void il4965_configure_filter(struct ieee80211_hw *hw, static void il4965_bg_txpower_work(struct work_struct *work) { - struct il_priv *priv = container_of(work, struct il_priv, + struct il_priv *il = container_of(work, struct il_priv, txpower_work); - mutex_lock(&priv->mutex); + mutex_lock(&il->mutex); /* If a scan happened to start before we got here * then just return; the statistics notification will * kick off another scheduled work to compensate for * any temperature delta we missed here. */ - if (test_bit(STATUS_EXIT_PENDING, &priv->status) || - test_bit(STATUS_SCANNING, &priv->status)) + if (test_bit(STATUS_EXIT_PENDING, &il->status) || + test_bit(STATUS_SCANNING, &il->status)) goto out; /* Regardless of if we are associated, we must reconfigure the * TX power since frames can be sent on non-radar channels while * not associated */ - priv->cfg->ops->lib->send_tx_power(priv); + il->cfg->ops->lib->send_tx_power(il); /* Update last_temperature to keep is_calib_needed from running * when it isn't needed... */ - priv->last_temperature = priv->temperature; + il->last_temperature = il->temperature; out: - mutex_unlock(&priv->mutex); + mutex_unlock(&il->mutex); } -static void il4965_setup_deferred_work(struct il_priv *priv) +static void il4965_setup_deferred_work(struct il_priv *il) { - priv->workqueue = create_singlethread_workqueue(DRV_NAME); + il->workqueue = create_singlethread_workqueue(DRV_NAME); - init_waitqueue_head(&priv->wait_command_queue); + init_waitqueue_head(&il->wait_command_queue); - INIT_WORK(&priv->restart, il4965_bg_restart); - INIT_WORK(&priv->rx_replenish, il4965_bg_rx_replenish); - INIT_WORK(&priv->run_time_calib_work, il4965_bg_run_time_calib_work); - INIT_DELAYED_WORK(&priv->init_alive_start, il4965_bg_init_alive_start); - INIT_DELAYED_WORK(&priv->alive_start, il4965_bg_alive_start); + INIT_WORK(&il->restart, il4965_bg_restart); + INIT_WORK(&il->rx_replenish, il4965_bg_rx_replenish); + INIT_WORK(&il->run_time_calib_work, il4965_bg_run_time_calib_work); + INIT_DELAYED_WORK(&il->init_alive_start, il4965_bg_init_alive_start); + INIT_DELAYED_WORK(&il->alive_start, il4965_bg_alive_start); - il_setup_scan_deferred_work(priv); + il_setup_scan_deferred_work(il); - INIT_WORK(&priv->txpower_work, il4965_bg_txpower_work); + INIT_WORK(&il->txpower_work, il4965_bg_txpower_work); - init_timer(&priv->statistics_periodic); - priv->statistics_periodic.data = (unsigned long)priv; - priv->statistics_periodic.function = il4965_bg_statistics_periodic; + init_timer(&il->statistics_periodic); + il->statistics_periodic.data = (unsigned long)il; + il->statistics_periodic.function = il4965_bg_statistics_periodic; - init_timer(&priv->watchdog); - priv->watchdog.data = (unsigned long)priv; - priv->watchdog.function = il_bg_watchdog; + init_timer(&il->watchdog); + il->watchdog.data = (unsigned long)il; + il->watchdog.function = il_bg_watchdog; - tasklet_init(&priv->irq_tasklet, (void (*)(unsigned long)) - il4965_irq_tasklet, (unsigned long)priv); + tasklet_init(&il->irq_tasklet, (void (*)(unsigned long)) + il4965_irq_tasklet, (unsigned long)il); } -static void il4965_cancel_deferred_work(struct il_priv *priv) +static void il4965_cancel_deferred_work(struct il_priv *il) { - cancel_work_sync(&priv->txpower_work); - cancel_delayed_work_sync(&priv->init_alive_start); - cancel_delayed_work(&priv->alive_start); - cancel_work_sync(&priv->run_time_calib_work); + cancel_work_sync(&il->txpower_work); + cancel_delayed_work_sync(&il->init_alive_start); + cancel_delayed_work(&il->alive_start); + cancel_work_sync(&il->run_time_calib_work); - il_cancel_scan_deferred_work(priv); + il_cancel_scan_deferred_work(il); - del_timer_sync(&priv->statistics_periodic); + del_timer_sync(&il->statistics_periodic); } -static void il4965_init_hw_rates(struct il_priv *priv, +static void il4965_init_hw_rates(struct il_priv *il, struct ieee80211_rate *rates) { int i; @@ -2727,26 +2727,26 @@ static void il4965_init_hw_rates(struct il_priv *priv, } } /* - * Acquire priv->lock before calling this function ! + * Acquire il->lock before calling this function ! */ -void il4965_set_wr_ptrs(struct il_priv *priv, int txq_id, u32 index) +void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 index) { - il_write_direct32(priv, HBUS_TARG_WRPTR, + il_write_direct32(il, HBUS_TARG_WRPTR, (index & 0xff) | (txq_id << 8)); - il_write_prph(priv, IWL49_SCD_QUEUE_RDPTR(txq_id), index); + il_write_prph(il, IWL49_SCD_QUEUE_RDPTR(txq_id), index); } -void il4965_tx_queue_set_status(struct il_priv *priv, +void il4965_tx_queue_set_status(struct il_priv *il, struct il_tx_queue *txq, int tx_fifo_id, int scd_retry) { int txq_id = txq->q.id; /* Find out whether to activate Tx queue */ - int active = test_bit(txq_id, &priv->txq_ctx_active_msk) ? 1 : 0; + int active = test_bit(txq_id, &il->txq_ctx_active_msk) ? 1 : 0; /* Set up and activate */ - il_write_prph(priv, IWL49_SCD_QUEUE_STATUS_BITS(txq_id), + il_write_prph(il, IWL49_SCD_QUEUE_STATUS_BITS(txq_id), (active << IWL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | (tx_fifo_id << IWL49_SCD_QUEUE_STTS_REG_POS_TXF) | (scd_retry << IWL49_SCD_QUEUE_STTS_REG_POS_WSL) | @@ -2755,94 +2755,94 @@ void il4965_tx_queue_set_status(struct il_priv *priv, txq->sched_retry = scd_retry; - IL_DEBUG_INFO(priv, "%s %s Queue %d on AC %d\n", + IL_DEBUG_INFO(il, "%s %s Queue %d on AC %d\n", active ? "Activate" : "Deactivate", scd_retry ? "BA" : "AC", txq_id, tx_fifo_id); } -static int il4965_init_drv(struct il_priv *priv) +static int il4965_init_drv(struct il_priv *il) { int ret; - spin_lock_init(&priv->sta_lock); - spin_lock_init(&priv->hcmd_lock); + spin_lock_init(&il->sta_lock); + spin_lock_init(&il->hcmd_lock); - INIT_LIST_HEAD(&priv->free_frames); + INIT_LIST_HEAD(&il->free_frames); - mutex_init(&priv->mutex); + mutex_init(&il->mutex); - priv->ieee_channels = NULL; - priv->ieee_rates = NULL; - priv->band = IEEE80211_BAND_2GHZ; + il->ieee_channels = NULL; + il->ieee_rates = NULL; + il->band = IEEE80211_BAND_2GHZ; - priv->iw_mode = NL80211_IFTYPE_STATION; - priv->current_ht_config.smps = IEEE80211_SMPS_STATIC; - priv->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; + il->iw_mode = NL80211_IFTYPE_STATION; + il->current_ht_config.smps = IEEE80211_SMPS_STATIC; + il->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; /* initialize force reset */ - priv->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; + il->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; /* Choose which receivers/antennas to use */ - if (priv->cfg->ops->hcmd->set_rxon_chain) - priv->cfg->ops->hcmd->set_rxon_chain(priv, - &priv->contexts[IL_RXON_CTX_BSS]); + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, + &il->contexts[IL_RXON_CTX_BSS]); - il_init_scan_params(priv); + il_init_scan_params(il); - ret = il_init_channel_map(priv); + ret = il_init_channel_map(il); if (ret) { - IL_ERR(priv, "initializing regulatory failed: %d\n", ret); + IL_ERR(il, "initializing regulatory failed: %d\n", ret); goto err; } - ret = il_init_geos(priv); + ret = il_init_geos(il); if (ret) { - IL_ERR(priv, "initializing geos failed: %d\n", ret); + IL_ERR(il, "initializing geos failed: %d\n", ret); goto err_free_channel_map; } - il4965_init_hw_rates(priv, priv->ieee_rates); + il4965_init_hw_rates(il, il->ieee_rates); return 0; err_free_channel_map: - il_free_channel_map(priv); + il_free_channel_map(il); err: return ret; } -static void il4965_uninit_drv(struct il_priv *priv) +static void il4965_uninit_drv(struct il_priv *il) { - il4965_calib_free_results(priv); - il_free_geos(priv); - il_free_channel_map(priv); - kfree(priv->scan_cmd); + il4965_calib_free_results(il); + il_free_geos(il); + il_free_channel_map(il); + kfree(il->scan_cmd); } -static void il4965_hw_detect(struct il_priv *priv) +static void il4965_hw_detect(struct il_priv *il) { - priv->hw_rev = _il_read32(priv, CSR_HW_REV); - priv->hw_wa_rev = _il_read32(priv, CSR_HW_REV_WA_REG); - priv->rev_id = priv->pci_dev->revision; - IL_DEBUG_INFO(priv, "HW Revision ID = 0x%X\n", priv->rev_id); + il->hw_rev = _il_read32(il, CSR_HW_REV); + il->hw_wa_rev = _il_read32(il, CSR_HW_REV_WA_REG); + il->rev_id = il->pci_dev->revision; + IL_DEBUG_INFO(il, "HW Revision ID = 0x%X\n", il->rev_id); } -static int il4965_set_hw_params(struct il_priv *priv) +static int il4965_set_hw_params(struct il_priv *il) { - priv->hw_params.max_rxq_size = RX_QUEUE_SIZE; - priv->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; - if (priv->cfg->mod_params->amsdu_size_8K) - priv->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_8K); + il->hw_params.max_rxq_size = RX_QUEUE_SIZE; + il->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; + if (il->cfg->mod_params->amsdu_size_8K) + il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_8K); else - priv->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_4K); + il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_4K); - priv->hw_params.max_beacon_itrvl = IL_MAX_UCODE_BEACON_INTERVAL; + il->hw_params.max_beacon_itrvl = IL_MAX_UCODE_BEACON_INTERVAL; - if (priv->cfg->mod_params->disable_11n) - priv->cfg->sku &= ~IL_SKU_N; + if (il->cfg->mod_params->disable_11n) + il->cfg->sku &= ~IL_SKU_N; /* Device-specific setup */ - return priv->cfg->ops->lib->set_hw_params(priv); + return il->cfg->ops->lib->set_hw_params(il); } static const u8 il4965_bss_ac_to_fifo[] = { @@ -2860,7 +2860,7 @@ static int il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { int err = 0, i; - struct il_priv *priv; + struct il_priv *il; struct ieee80211_hw *hw; struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data); unsigned long flags; @@ -2875,49 +2875,49 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err = -ENOMEM; goto out; } - priv = hw->priv; - /* At this point both hw and priv are allocated. */ + il = hw->priv; + /* At this point both hw and il are allocated. */ /* * The default context is always valid, * more may be discovered when firmware * is loaded. */ - priv->valid_contexts = BIT(IL_RXON_CTX_BSS); + il->valid_contexts = BIT(IL_RXON_CTX_BSS); for (i = 0; i < NUM_IL_RXON_CTX; i++) - priv->contexts[i].ctxid = i; - - priv->contexts[IL_RXON_CTX_BSS].always_active = true; - priv->contexts[IL_RXON_CTX_BSS].is_active = true; - priv->contexts[IL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON; - priv->contexts[IL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING; - priv->contexts[IL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC; - priv->contexts[IL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM; - priv->contexts[IL_RXON_CTX_BSS].ap_sta_id = IL_AP_ID; - priv->contexts[IL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY; - priv->contexts[IL_RXON_CTX_BSS].ac_to_fifo = il4965_bss_ac_to_fifo; - priv->contexts[IL_RXON_CTX_BSS].ac_to_queue = il4965_bss_ac_to_queue; - priv->contexts[IL_RXON_CTX_BSS].exclusive_interface_modes = + il->contexts[i].ctxid = i; + + il->contexts[IL_RXON_CTX_BSS].always_active = true; + il->contexts[IL_RXON_CTX_BSS].is_active = true; + il->contexts[IL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON; + il->contexts[IL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING; + il->contexts[IL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC; + il->contexts[IL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM; + il->contexts[IL_RXON_CTX_BSS].ap_sta_id = IL_AP_ID; + il->contexts[IL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY; + il->contexts[IL_RXON_CTX_BSS].ac_to_fifo = il4965_bss_ac_to_fifo; + il->contexts[IL_RXON_CTX_BSS].ac_to_queue = il4965_bss_ac_to_queue; + il->contexts[IL_RXON_CTX_BSS].exclusive_interface_modes = BIT(NL80211_IFTYPE_ADHOC); - priv->contexts[IL_RXON_CTX_BSS].interface_modes = + il->contexts[IL_RXON_CTX_BSS].interface_modes = BIT(NL80211_IFTYPE_STATION); - priv->contexts[IL_RXON_CTX_BSS].ap_devtype = RXON_DEV_TYPE_AP; - priv->contexts[IL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS; - priv->contexts[IL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS; - priv->contexts[IL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS; + il->contexts[IL_RXON_CTX_BSS].ap_devtype = RXON_DEV_TYPE_AP; + il->contexts[IL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS; + il->contexts[IL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS; + il->contexts[IL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS; BUILD_BUG_ON(NUM_IL_RXON_CTX != 1); SET_IEEE80211_DEV(hw, &pdev->dev); - IL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n"); - priv->cfg = cfg; - priv->pci_dev = pdev; - priv->inta_mask = CSR_INI_SET_MASK; + IL_DEBUG_INFO(il, "*** LOAD DRIVER ***\n"); + il->cfg = cfg; + il->pci_dev = pdev; + il->inta_mask = CSR_INI_SET_MASK; - if (il_alloc_traffic_mem(priv)) - IL_ERR(priv, "Not enough memory to generate traffic log\n"); + if (il_alloc_traffic_mem(il)) + IL_ERR(il, "Not enough memory to generate traffic log\n"); /************************** * 2. Initializing PCI bus @@ -2942,7 +2942,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) DMA_BIT_MASK(32)); /* both attempts failed: */ if (err) { - IL_WARN(priv, "No suitable DMA available.\n"); + IL_WARN(il, "No suitable DMA available.\n"); goto out_pci_disable_device; } } @@ -2951,46 +2951,46 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (err) goto out_pci_disable_device; - pci_set_drvdata(pdev, priv); + pci_set_drvdata(pdev, il); /*********************** * 3. Read REV register ***********************/ - priv->hw_base = pci_iomap(pdev, 0, 0); - if (!priv->hw_base) { + il->hw_base = pci_iomap(pdev, 0, 0); + if (!il->hw_base) { err = -ENODEV; goto out_pci_release_regions; } - IL_DEBUG_INFO(priv, "pci_resource_len = 0x%08llx\n", + IL_DEBUG_INFO(il, "pci_resource_len = 0x%08llx\n", (unsigned long long) pci_resource_len(pdev, 0)); - IL_DEBUG_INFO(priv, "pci_resource_base = %p\n", priv->hw_base); + IL_DEBUG_INFO(il, "pci_resource_base = %p\n", il->hw_base); /* these spin locks will be used in apm_ops.init and EEPROM access * we should init now */ - spin_lock_init(&priv->reg_lock); - spin_lock_init(&priv->lock); + spin_lock_init(&il->reg_lock); + spin_lock_init(&il->lock); /* * stop and reset the on-board processor just in case it is in a * strange state ... like being left stranded by a primary kernel * and this is now the kdump kernel trying to start up */ - il_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + il_write32(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); - il4965_hw_detect(priv); - IL_INFO(priv, "Detected %s, REV=0x%X\n", - priv->cfg->name, priv->hw_rev); + il4965_hw_detect(il); + IL_INFO(il, "Detected %s, REV=0x%X\n", + il->cfg->name, il->hw_rev); /* We disable the RETRY_TIMEOUT register (0x41) to keep * PCI Tx retries from interfering with C3 CPU state */ pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); - il4965_prepare_card_hw(priv); - if (!priv->hw_ready) { - IL_WARN(priv, "Failed, HW not ready\n"); + il4965_prepare_card_hw(il); + if (!il->hw_ready) { + IL_WARN(il, "Failed, HW not ready\n"); goto out_iounmap; } @@ -2998,12 +2998,12 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) * 4. Read EEPROM *****************/ /* Read the EEPROM */ - err = il_eeprom_init(priv); + err = il_eeprom_init(il); if (err) { - IL_ERR(priv, "Unable to init EEPROM\n"); + IL_ERR(il, "Unable to init EEPROM\n"); goto out_iounmap; } - err = il4965_eeprom_check_version(priv); + err = il4965_eeprom_check_version(il); if (err) goto out_free_eeprom; @@ -3011,131 +3011,131 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto out_free_eeprom; /* extract MAC Address */ - il4965_eeprom_get_mac(priv, priv->addresses[0].addr); - IL_DEBUG_INFO(priv, "MAC address: %pM\n", priv->addresses[0].addr); - priv->hw->wiphy->addresses = priv->addresses; - priv->hw->wiphy->n_addresses = 1; + il4965_eeprom_get_mac(il, il->addresses[0].addr); + IL_DEBUG_INFO(il, "MAC address: %pM\n", il->addresses[0].addr); + il->hw->wiphy->addresses = il->addresses; + il->hw->wiphy->n_addresses = 1; /************************ * 5. Setup HW constants ************************/ - if (il4965_set_hw_params(priv)) { - IL_ERR(priv, "failed to set hw parameters\n"); + if (il4965_set_hw_params(il)) { + IL_ERR(il, "failed to set hw parameters\n"); goto out_free_eeprom; } /******************* - * 6. Setup priv + * 6. Setup il *******************/ - err = il4965_init_drv(priv); + err = il4965_init_drv(il); if (err) goto out_free_eeprom; - /* At this point both hw and priv are initialized. */ + /* At this point both hw and il are initialized. */ /******************** * 7. Setup services ********************/ - spin_lock_irqsave(&priv->lock, flags); - il_disable_interrupts(priv); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); + il_disable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); - pci_enable_msi(priv->pci_dev); + pci_enable_msi(il->pci_dev); - err = request_irq(priv->pci_dev->irq, il_isr, - IRQF_SHARED, DRV_NAME, priv); + err = request_irq(il->pci_dev->irq, il_isr, + IRQF_SHARED, DRV_NAME, il); if (err) { - IL_ERR(priv, "Error allocating IRQ %d\n", priv->pci_dev->irq); + IL_ERR(il, "Error allocating IRQ %d\n", il->pci_dev->irq); goto out_disable_msi; } - il4965_setup_deferred_work(priv); - il4965_setup_rx_handlers(priv); + il4965_setup_deferred_work(il); + il4965_setup_rx_handlers(il); /********************************************* * 8. Enable interrupts and read RFKILL state *********************************************/ /* enable rfkill interrupt: hw bug w/a */ - pci_read_config_word(priv->pci_dev, PCI_COMMAND, &pci_cmd); + pci_read_config_word(il->pci_dev, PCI_COMMAND, &pci_cmd); if (pci_cmd & PCI_COMMAND_INTX_DISABLE) { pci_cmd &= ~PCI_COMMAND_INTX_DISABLE; - pci_write_config_word(priv->pci_dev, PCI_COMMAND, pci_cmd); + pci_write_config_word(il->pci_dev, PCI_COMMAND, pci_cmd); } - il_enable_rfkill_int(priv); + il_enable_rfkill_int(il); /* If platform's RF_KILL switch is NOT set to KILL */ - if (il_read32(priv, CSR_GP_CNTRL) & + if (il_read32(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) - clear_bit(STATUS_RF_KILL_HW, &priv->status); + clear_bit(STATUS_RF_KILL_HW, &il->status); else - set_bit(STATUS_RF_KILL_HW, &priv->status); + set_bit(STATUS_RF_KILL_HW, &il->status); - wiphy_rfkill_set_hw_state(priv->hw->wiphy, - test_bit(STATUS_RF_KILL_HW, &priv->status)); + wiphy_rfkill_set_hw_state(il->hw->wiphy, + test_bit(STATUS_RF_KILL_HW, &il->status)); - il_power_initialize(priv); + il_power_initialize(il); - init_completion(&priv->_4965.firmware_loading_complete); + init_completion(&il->_4965.firmware_loading_complete); - err = il4965_request_firmware(priv, true); + err = il4965_request_firmware(il, true); if (err) goto out_destroy_workqueue; return 0; out_destroy_workqueue: - destroy_workqueue(priv->workqueue); - priv->workqueue = NULL; - free_irq(priv->pci_dev->irq, priv); + destroy_workqueue(il->workqueue); + il->workqueue = NULL; + free_irq(il->pci_dev->irq, il); out_disable_msi: - pci_disable_msi(priv->pci_dev); - il4965_uninit_drv(priv); + pci_disable_msi(il->pci_dev); + il4965_uninit_drv(il); out_free_eeprom: - il_eeprom_free(priv); + il_eeprom_free(il); out_iounmap: - pci_iounmap(pdev, priv->hw_base); + pci_iounmap(pdev, il->hw_base); out_pci_release_regions: pci_set_drvdata(pdev, NULL); pci_release_regions(pdev); out_pci_disable_device: pci_disable_device(pdev); out_ieee80211_free_hw: - il_free_traffic_mem(priv); - ieee80211_free_hw(priv->hw); + il_free_traffic_mem(il); + ieee80211_free_hw(il->hw); out: return err; } static void __devexit il4965_pci_remove(struct pci_dev *pdev) { - struct il_priv *priv = pci_get_drvdata(pdev); + struct il_priv *il = pci_get_drvdata(pdev); unsigned long flags; - if (!priv) + if (!il) return; - wait_for_completion(&priv->_4965.firmware_loading_complete); + wait_for_completion(&il->_4965.firmware_loading_complete); - IL_DEBUG_INFO(priv, "*** UNLOAD DRIVER ***\n"); + IL_DEBUG_INFO(il, "*** UNLOAD DRIVER ***\n"); - il_dbgfs_unregister(priv); + il_dbgfs_unregister(il); sysfs_remove_group(&pdev->dev.kobj, &il_attribute_group); /* ieee80211_unregister_hw call wil cause il_mac_stop to * to be called and il4965_down since we are removing the device * we need to set STATUS_EXIT_PENDING bit. */ - set_bit(STATUS_EXIT_PENDING, &priv->status); + set_bit(STATUS_EXIT_PENDING, &il->status); - il_leds_exit(priv); + il_leds_exit(il); - if (priv->mac80211_registered) { - ieee80211_unregister_hw(priv->hw); - priv->mac80211_registered = 0; + if (il->mac80211_registered) { + ieee80211_unregister_hw(il->hw); + il->mac80211_registered = 0; } else { - il4965_down(priv); + il4965_down(il); } /* @@ -3145,57 +3145,57 @@ static void __devexit il4965_pci_remove(struct pci_dev *pdev) * paths to avoid running il4965_down() at all before leaving driver. * This (inexpensive) call *makes sure* device is reset. */ - il_apm_stop(priv); + il_apm_stop(il); /* make sure we flush any pending irq or * tasklet for the driver */ - spin_lock_irqsave(&priv->lock, flags); - il_disable_interrupts(priv); - spin_unlock_irqrestore(&priv->lock, flags); + spin_lock_irqsave(&il->lock, flags); + il_disable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); - il4965_synchronize_irq(priv); + il4965_synchronize_irq(il); - il4965_dealloc_ucode_pci(priv); + il4965_dealloc_ucode_pci(il); - if (priv->rxq.bd) - il4965_rx_queue_free(priv, &priv->rxq); - il4965_hw_txq_ctx_free(priv); + if (il->rxq.bd) + il4965_rx_queue_free(il, &il->rxq); + il4965_hw_txq_ctx_free(il); - il_eeprom_free(priv); + il_eeprom_free(il); /*netif_stop_queue(dev); */ - flush_workqueue(priv->workqueue); + flush_workqueue(il->workqueue); /* ieee80211_unregister_hw calls il_mac_stop, which flushes - * priv->workqueue... so we can't take down the workqueue + * il->workqueue... so we can't take down the workqueue * until now... */ - destroy_workqueue(priv->workqueue); - priv->workqueue = NULL; - il_free_traffic_mem(priv); + destroy_workqueue(il->workqueue); + il->workqueue = NULL; + il_free_traffic_mem(il); - free_irq(priv->pci_dev->irq, priv); - pci_disable_msi(priv->pci_dev); - pci_iounmap(pdev, priv->hw_base); + free_irq(il->pci_dev->irq, il); + pci_disable_msi(il->pci_dev); + pci_iounmap(pdev, il->hw_base); pci_release_regions(pdev); pci_disable_device(pdev); pci_set_drvdata(pdev, NULL); - il4965_uninit_drv(priv); + il4965_uninit_drv(il); - dev_kfree_skb(priv->beacon_skb); + dev_kfree_skb(il->beacon_skb); - ieee80211_free_hw(priv->hw); + ieee80211_free_hw(il->hw); } /* * Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask - * must be called under priv->lock and mac access + * must be called under il->lock and mac access */ -void il4965_txq_set_sched(struct il_priv *priv, u32 mask) +void il4965_txq_set_sched(struct il_priv *il, u32 mask) { - il_write_prph(priv, IWL49_SCD_TXFACT, mask); + il_write_prph(il, IWL49_SCD_TXFACT, mask); } /***************************************************************************** -- cgit v1.2.3 From d2ddf621aa45ac4cf4cce6359bfac6b49a8c6b34 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 16 Aug 2011 14:17:04 +0200 Subject: iwlegacy: rename iwlegacy to il More renaming to make code shorter. Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-4965-lib.c | 2 +- drivers/net/wireless/iwlegacy/iwl-4965-rs.c | 20 +++++----- drivers/net/wireless/iwlegacy/iwl-4965-sta.c | 4 +- drivers/net/wireless/iwlegacy/iwl-4965-tx.c | 2 +- drivers/net/wireless/iwlegacy/iwl-core.c | 18 ++++----- drivers/net/wireless/iwlegacy/iwl-debug.h | 2 +- drivers/net/wireless/iwlegacy/iwl-debugfs.c | 4 +- drivers/net/wireless/iwlegacy/iwl-dev.h | 8 ++-- drivers/net/wireless/iwlegacy/iwl-eeprom.c | 54 +++++++++++++-------------- drivers/net/wireless/iwlegacy/iwl-eeprom.h | 2 +- drivers/net/wireless/iwlegacy/iwl-legacy-rs.h | 4 +- drivers/net/wireless/iwlegacy/iwl-scan.c | 4 +- drivers/net/wireless/iwlegacy/iwl3945-base.c | 4 +- drivers/net/wireless/iwlegacy/iwl4965-base.c | 6 +-- 14 files changed, 67 insertions(+), 67 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index 4d25590b0339..647399ed0a0c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -424,7 +424,7 @@ int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) if (band == IEEE80211_BAND_5GHZ) band_offset = IL_FIRST_OFDM_RATE; for (idx = band_offset; idx < IL_RATE_COUNT_LEGACY; idx++) - if (iwlegacy_rates[idx].plcp == (rate_n_flags & 0xFF)) + if (il_rates[idx].plcp == (rate_n_flags & 0xFF)) return idx - band_offset; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index e53ed1a5d5db..60ff0cdff9c0 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -96,7 +96,7 @@ static const u8 ant_toggle_lookup[] = { * maps to IL_RATE_INVALID * */ -const struct il_rate_info iwlegacy_rates[IL_RATE_COUNT] = { +const struct il_rate_info il_rates[IL_RATE_COUNT] = { IL_DECLARE_RATE_INFO(1, INV, INV, 2, INV, 2, INV, 2), /* 1mbps */ IL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ IL_DECLARE_RATE_INFO(5, INV, 2, 6, 2, 11, 2, 11), /*5.5mbps */ @@ -132,8 +132,8 @@ static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags) /* legacy rate format, search for match in table */ } else { - for (idx = 0; idx < ARRAY_SIZE(iwlegacy_rates); idx++) - if (iwlegacy_rates[idx].plcp == (rate_n_flags & 0xFF)) + for (idx = 0; idx < ARRAY_SIZE(il_rates); idx++) + if (il_rates[idx].plcp == (rate_n_flags & 0xFF)) return idx; } @@ -499,7 +499,7 @@ static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, u32 rate_n_flags = 0; if (is_legacy(tbl->lq_type)) { - rate_n_flags = iwlegacy_rates[index].plcp; + rate_n_flags = il_rates[index].plcp; if (index >= IL_FIRST_CCK_RATE && index <= IL_LAST_CCK_RATE) rate_n_flags |= RATE_MCS_CCK_MSK; @@ -511,9 +511,9 @@ static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, rate_n_flags = RATE_MCS_HT_MSK; if (is_siso(tbl->lq_type)) - rate_n_flags |= iwlegacy_rates[index].plcp_siso; + rate_n_flags |= il_rates[index].plcp_siso; else - rate_n_flags |= iwlegacy_rates[index].plcp_mimo2; + rate_n_flags |= il_rates[index].plcp_mimo2; } else { IL_ERR(il, "Invalid tbl->lq_type %d\n", tbl->lq_type); } @@ -702,7 +702,7 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, low = index; while (low != IL_RATE_INVALID) { - low = iwlegacy_rates[low].prev_rs; + low = il_rates[low].prev_rs; if (low == IL_RATE_INVALID) break; if (rate_mask & (1 << low)) @@ -712,7 +712,7 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, high = index; while (high != IL_RATE_INVALID) { - high = iwlegacy_rates[high].next_rs; + high = il_rates[high].next_rs; if (high == IL_RATE_INVALID) break; if (rate_mask & (1 << high)) @@ -2220,7 +2220,7 @@ static void il4965_rs_initialize_lq(struct il_priv *il, if ((i < 0) || (i >= IL_RATE_COUNT)) i = 0; - rate = iwlegacy_rates[i].plcp; + rate = il_rates[i].plcp; tbl->ant_type = il4965_first_antenna(valid_tx_ant); rate |= tbl->ant_type << RATE_MCS_ANT_POS; @@ -2793,7 +2793,7 @@ static ssize_t il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, else desc += sprintf(buff+desc, "Bit Rate= %d Mb/s\n", - iwlegacy_rates[lq_sta->last_txrate_idx].ieee >> 1); + il_rates[lq_sta->last_txrate_idx].ieee >> 1); ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); return ret; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c index 20290d24fd62..0fbc991fe66c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c @@ -59,7 +59,7 @@ il4965_sta_alloc_lq(struct il_priv *il, u8 sta_id) rate_flags |= il4965_first_antenna(il->hw_params.valid_tx_ant) << RATE_MCS_ANT_POS; - rate_n_flags = il4965_hw_set_rate_n_flags(iwlegacy_rates[r].plcp, + rate_n_flags = il4965_hw_set_rate_n_flags(il_rates[r].plcp, rate_flags); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) link_cmd->rs_table[i].rate_n_flags = rate_n_flags; @@ -554,7 +554,7 @@ int il4965_alloc_bcast_station(struct il_priv *il, u8 sta_id; spin_lock_irqsave(&il->sta_lock, flags); - sta_id = il_prep_station(il, ctx, iwlegacy_bcast_addr, + sta_id = il_prep_station(il, ctx, il_bcast_addr, false, NULL); if (sta_id == IL_INVALID_STATION) { IL_ERR(il, "Unable to prepare broadcast station\n"); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index 59d737496b5c..fcc938e1cf6c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -203,7 +203,7 @@ static void il4965_tx_cmd_build_rate(struct il_priv *il, if (info->band == IEEE80211_BAND_5GHZ) rate_idx += IL_FIRST_OFDM_RATE; /* Get PLCP rate for tx_cmd->rate_n_flags */ - rate_plcp = iwlegacy_rates[rate_idx].plcp; + rate_plcp = il_rates[rate_idx].plcp; /* Zero out flags for this packet */ rate_flags = 0; diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index 80ec543dd894..a768e78bf897 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -68,11 +68,11 @@ static bool bt_coex_active = true; module_param(bt_coex_active, bool, S_IRUGO); MODULE_PARM_DESC(bt_coex_active, "enable wifi/bluetooth co-exist"); -u32 iwlegacy_debug_level; -EXPORT_SYMBOL(iwlegacy_debug_level); +u32 il_debug_level; +EXPORT_SYMBOL(il_debug_level); -const u8 iwlegacy_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; -EXPORT_SYMBOL(iwlegacy_bcast_addr); +const u8 il_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; +EXPORT_SYMBOL(il_bcast_addr); /* This function both allocates and initializes hw and il. */ @@ -183,7 +183,7 @@ int il_init_geos(struct il_priv *il) /* 5.2GHz channels start after the 2.4GHz channels */ sband = &il->bands[IEEE80211_BAND_5GHZ]; - sband->channels = &channels[ARRAY_SIZE(iwlegacy_eeprom_band_1)]; + sband->channels = &channels[ARRAY_SIZE(il_eeprom_band_1)]; /* just OFDM */ sband->bitrates = &rates[IL_FIRST_OFDM_RATE]; sband->n_bitrates = IL_RATE_COUNT_LEGACY - IL_FIRST_OFDM_RATE; @@ -1486,7 +1486,7 @@ int il_alloc_traffic_mem(struct il_priv *il) { u32 traffic_size = IL_TRAFFIC_DUMP_SIZE; - if (iwlegacy_debug_level & IL_DL_TX) { + if (il_debug_level & IL_DL_TX) { if (!il->tx_traffic) { il->tx_traffic = kzalloc(traffic_size, GFP_KERNEL); @@ -1494,7 +1494,7 @@ int il_alloc_traffic_mem(struct il_priv *il) return -ENOMEM; } } - if (iwlegacy_debug_level & IL_DL_RX) { + if (il_debug_level & IL_DL_RX) { if (!il->rx_traffic) { il->rx_traffic = kzalloc(traffic_size, GFP_KERNEL); @@ -1523,7 +1523,7 @@ void il_dbg_log_tx_data_frame(struct il_priv *il, __le16 fc; u16 len; - if (likely(!(iwlegacy_debug_level & IL_DL_TX))) + if (likely(!(il_debug_level & IL_DL_TX))) return; if (!il->tx_traffic) @@ -1548,7 +1548,7 @@ void il_dbg_log_rx_data_frame(struct il_priv *il, __le16 fc; u16 len; - if (likely(!(iwlegacy_debug_level & IL_DL_RX))) + if (likely(!(il_debug_level & IL_DL_RX))) return; if (!il->rx_traffic) diff --git a/drivers/net/wireless/iwlegacy/iwl-debug.h b/drivers/net/wireless/iwlegacy/iwl-debug.h index 657da25a2354..05a7933011b6 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debug.h +++ b/drivers/net/wireless/iwlegacy/iwl-debug.h @@ -30,7 +30,7 @@ #define __il_debug_h__ struct il_priv; -extern u32 iwlegacy_debug_level; +extern u32 il_debug_level; #define IL_ERR(p, f, a...) dev_err(&((p)->pci_dev->dev), f, ## a) #define IL_WARN(p, f, a...) dev_warn(&((p)->pci_dev->dev), f, ## a) diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index f2f2eba7d3ea..a811c17e9c62 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -705,7 +705,7 @@ static ssize_t il_dbgfs_traffic_log_read(struct file *file, "q[%d]: read_ptr: %u, write_ptr: %u\n", cnt, q->read_ptr, q->write_ptr); } - if (il->tx_traffic && (iwlegacy_debug_level & IL_DL_TX)) { + if (il->tx_traffic && (il_debug_level & IL_DL_TX)) { ptr = il->tx_traffic; pos += scnprintf(buf + pos, bufsz - pos, "Tx Traffic idx: %u\n", il->tx_traffic_idx); @@ -728,7 +728,7 @@ static ssize_t il_dbgfs_traffic_log_read(struct file *file, "read: %u, write: %u\n", rxq->read, rxq->write); - if (il->rx_traffic && (iwlegacy_debug_level & IL_DL_RX)) { + if (il->rx_traffic && (il_debug_level & IL_DL_RX)) { ptr = il->rx_traffic; pos += scnprintf(buf + pos, bufsz - pos, "Rx Traffic idx: %u\n", il->rx_traffic_idx); diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 824d1934a7a1..2e2e3f3f66f7 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -626,7 +626,7 @@ struct il_hw_params { * ****************************************************************************/ extern void il4965_update_chain_flags(struct il_priv *il); -extern const u8 iwlegacy_bcast_addr[ETH_ALEN]; +extern const u8 il_bcast_addr[ETH_ALEN]; extern int il_queue_space(const struct il_queue *q); static inline int il_queue_used(const struct il_queue *q, int i) { @@ -1220,7 +1220,7 @@ struct il_priv { #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG /* debugging info */ u32 debug_level; /* per device debugging will override global - iwlegacy_debug_level if set */ + il_debug_level if set */ #endif /* CONFIG_IWLWIFI_LEGACY_DEBUG */ #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS /* debugfs */ @@ -1270,12 +1270,12 @@ static inline u32 il_get_debug_level(struct il_priv *il) if (il->debug_level) return il->debug_level; else - return iwlegacy_debug_level; + return il_debug_level; } #else static inline u32 il_get_debug_level(struct il_priv *il) { - return iwlegacy_debug_level; + return il_debug_level; } #endif diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-eeprom.c index 5edec73a505e..f6b9d6d28d9e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.c @@ -77,7 +77,7 @@ /************************** EEPROM BANDS **************************** * - * The iwlegacy_eeprom_band definitions below provide the mapping from the + * The il_eeprom_band definitions below provide the mapping from the * EEPROM contents to the specific channel number supported for each * band. * @@ -107,32 +107,32 @@ *********************************************************************/ /* 2.4 GHz */ -const u8 iwlegacy_eeprom_band_1[14] = { +const u8 il_eeprom_band_1[14] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 }; /* 5.2 GHz bands */ -static const u8 iwlegacy_eeprom_band_2[] = { /* 4915-5080MHz */ +static const u8 il_eeprom_band_2[] = { /* 4915-5080MHz */ 183, 184, 185, 187, 188, 189, 192, 196, 7, 8, 11, 12, 16 }; -static const u8 iwlegacy_eeprom_band_3[] = { /* 5170-5320MHz */ +static const u8 il_eeprom_band_3[] = { /* 5170-5320MHz */ 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 }; -static const u8 iwlegacy_eeprom_band_4[] = { /* 5500-5700MHz */ +static const u8 il_eeprom_band_4[] = { /* 5500-5700MHz */ 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 }; -static const u8 iwlegacy_eeprom_band_5[] = { /* 5725-5825MHz */ +static const u8 il_eeprom_band_5[] = { /* 5725-5825MHz */ 145, 149, 153, 157, 161, 165 }; -static const u8 iwlegacy_eeprom_band_6[] = { /* 2.4 ht40 channel */ +static const u8 il_eeprom_band_6[] = { /* 2.4 ht40 channel */ 1, 2, 3, 4, 5, 6, 7 }; -static const u8 iwlegacy_eeprom_band_7[] = { /* 5.2 ht40 channel */ +static const u8 il_eeprom_band_7[] = { /* 5.2 ht40 channel */ 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157 }; @@ -273,46 +273,46 @@ static void il_init_band_reference(const struct il_priv *il, eeprom_ops.regulatory_bands[eep_band - 1]; switch (eep_band) { case 1: /* 2.4GHz band */ - *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_1); + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_1); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = iwlegacy_eeprom_band_1; + *eeprom_ch_index = il_eeprom_band_1; break; case 2: /* 4.9GHz band */ - *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_2); + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_2); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = iwlegacy_eeprom_band_2; + *eeprom_ch_index = il_eeprom_band_2; break; case 3: /* 5.2GHz band */ - *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_3); + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_3); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = iwlegacy_eeprom_band_3; + *eeprom_ch_index = il_eeprom_band_3; break; case 4: /* 5.5GHz band */ - *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_4); + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_4); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = iwlegacy_eeprom_band_4; + *eeprom_ch_index = il_eeprom_band_4; break; case 5: /* 5.7GHz band */ - *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_5); + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_5); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = iwlegacy_eeprom_band_5; + *eeprom_ch_index = il_eeprom_band_5; break; case 6: /* 2.4GHz ht40 channels */ - *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_6); + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_6); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = iwlegacy_eeprom_band_6; + *eeprom_ch_index = il_eeprom_band_6; break; case 7: /* 5 GHz ht40 channels */ - *eeprom_ch_count = ARRAY_SIZE(iwlegacy_eeprom_band_7); + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_7); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = iwlegacy_eeprom_band_7; + *eeprom_ch_index = il_eeprom_band_7; break; default: BUG(); @@ -387,11 +387,11 @@ int il_init_channel_map(struct il_priv *il) IL_DEBUG_EEPROM(il, "Initializing regulatory info from EEPROM\n"); il->channel_count = - ARRAY_SIZE(iwlegacy_eeprom_band_1) + - ARRAY_SIZE(iwlegacy_eeprom_band_2) + - ARRAY_SIZE(iwlegacy_eeprom_band_3) + - ARRAY_SIZE(iwlegacy_eeprom_band_4) + - ARRAY_SIZE(iwlegacy_eeprom_band_5); + ARRAY_SIZE(il_eeprom_band_1) + + ARRAY_SIZE(il_eeprom_band_2) + + ARRAY_SIZE(il_eeprom_band_3) + + ARRAY_SIZE(il_eeprom_band_4) + + ARRAY_SIZE(il_eeprom_band_5); IL_DEBUG_EEPROM(il, "Parsing data for %d channels.\n", il->channel_count); diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.h b/drivers/net/wireless/iwlegacy/iwl-eeprom.h index acb5ec17d70d..b97c83735c76 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.h +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.h @@ -144,7 +144,7 @@ struct il_eeprom_channel { #define EEPROM_4965_BOARD_PBA (2*0x56+1) /* 9 bytes */ /* 2.4 GHz */ -extern const u8 iwlegacy_eeprom_band_1[14]; +extern const u8 il_eeprom_band_1[14]; /* * factory calibration data for one txpower level, on one channel, diff --git a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h index 4282ed553b92..744829a66284 100644 --- a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h +++ b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h @@ -56,7 +56,7 @@ struct il3945_rate_info { /* * These serve as indexes into - * struct il_rate_info iwlegacy_rates[IL_RATE_COUNT]; + * struct il_rate_info il_rates[IL_RATE_COUNT]; */ enum { IL_RATE_1M_INDEX = 0, @@ -268,7 +268,7 @@ enum { #define TID_MAX_TIME_DIFF ((TID_QUEUE_MAX_SIZE - 1) * TID_QUEUE_CELL_SPACING) #define TIME_WRAP_AROUND(x, y) (((y) > (x)) ? (y) - (x) : (0-(x)) + (y)) -extern const struct il_rate_info iwlegacy_rates[IL_RATE_COUNT]; +extern const struct il_rate_info il_rates[IL_RATE_COUNT]; enum il_table_type { LQ_NONE, diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index 0184d5bf04e2..5a967d2b15d1 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -442,9 +442,9 @@ il_fill_probe_req(struct il_priv *il, struct ieee80211_mgmt *frame, return 0; frame->frame_control = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); - memcpy(frame->da, iwlegacy_bcast_addr, ETH_ALEN); + memcpy(frame->da, il_bcast_addr, ETH_ALEN); memcpy(frame->sa, ta, ETH_ALEN); - memcpy(frame->bssid, iwlegacy_bcast_addr, ETH_ALEN); + memcpy(frame->bssid, il_bcast_addr, ETH_ALEN); frame->seq_ctrl = 0; len += 24; diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 2c336a701dc5..af3f1945e17d 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -2378,7 +2378,7 @@ static int il3945_alloc_bcast_station(struct il_priv *il) spin_lock_irqsave(&il->sta_lock, flags); sta_id = il_prep_station(il, ctx, - iwlegacy_bcast_addr, false, NULL); + il_bcast_addr, false, NULL); if (sta_id == IL_INVALID_STATION) { IL_ERR(il, "Unable to prepare broadcast station\n"); spin_unlock_irqrestore(&il->sta_lock, flags); @@ -4003,7 +4003,7 @@ module_param_named(disable_hw_scan, il3945_mod_params.disable_hw_scan, int, S_IRUGO); MODULE_PARM_DESC(disable_hw_scan, "disable hardware scanning (default 1)"); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -module_param_named(debug, iwlegacy_debug_level, uint, S_IRUGO | S_IWUSR); +module_param_named(debug, il_debug_level, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(debug, "debug output mask"); #endif module_param_named(fw_restart, il3945_mod_params.restart_fw, int, S_IRUGO); diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index ae8a93751561..d4eacc3cbe7f 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -2712,7 +2712,7 @@ static void il4965_init_hw_rates(struct il_priv *il, int i; for (i = 0; i < IL_RATE_COUNT_LEGACY; i++) { - rates[i].bitrate = iwlegacy_rates[i].ieee * 5; + rates[i].bitrate = il_rates[i].ieee * 5; rates[i].hw_value = i; /* Rate scaling will work on indexes */ rates[i].hw_value_short = i; rates[i].flags = 0; @@ -2721,7 +2721,7 @@ static void il4965_init_hw_rates(struct il_priv *il, * If CCK != 1M then set short preamble rate flag. */ rates[i].flags |= - (iwlegacy_rates[i].plcp == IL_RATE_1M_PLCP) ? + (il_rates[i].plcp == IL_RATE_1M_PLCP) ? 0 : IEEE80211_RATE_SHORT_PREAMBLE; } } @@ -3259,7 +3259,7 @@ module_exit(il4965_exit); module_init(il4965_init); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -module_param_named(debug, iwlegacy_debug_level, uint, S_IRUGO | S_IWUSR); +module_param_named(debug, il_debug_level, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(debug, "debug output mask"); #endif -- cgit v1.2.3 From 46f16c492e5ca905c2170c11177fb90a58074eab Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 16 Aug 2011 15:00:23 +0200 Subject: iwlegacy: remove DEBUG_IO Nothing useful at present. Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c | 6 +- drivers/net/wireless/iwlegacy/iwl-debug.h | 2 - drivers/net/wireless/iwlegacy/iwl-io.h | 192 +----------------------- 3 files changed, 3 insertions(+), 197 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c index 947475ea3cef..ef8b0d5f2e07 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c @@ -102,12 +102,8 @@ int il4965_eeprom_acquire_semaphore(struct il_priv *il) CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, EEPROM_SEM_TIMEOUT); - if (ret >= 0) { - IL_DEBUG_IO(il, - "Acquired semaphore after %d tries.\n", - count+1); + if (ret >= 0) return ret; - } } return ret; diff --git a/drivers/net/wireless/iwlegacy/iwl-debug.h b/drivers/net/wireless/iwlegacy/iwl-debug.h index 05a7933011b6..a825051d5f2d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debug.h +++ b/drivers/net/wireless/iwlegacy/iwl-debug.h @@ -146,7 +146,6 @@ static inline void il_dbgfs_unregister(struct il_priv *il) #define IL_DL_RX (1 << 24) #define IL_DL_ISR (1 << 25) #define IL_DL_HT (1 << 26) -#define IL_DL_IO (1 << 27) /* 0xF0000000 - 0x10000000 */ #define IL_DL_11H (1 << 28) #define IL_DL_STATS (1 << 29) @@ -174,7 +173,6 @@ static inline void il_dbgfs_unregister(struct il_priv *il) IL_DEBUG_LIMIT(p, IL_DL_DROP, f, ## a) #define IL_DEBUG_AP(p, f, a...) IL_DEBUG(p, IL_DL_AP, f, ## a) #define IL_DEBUG_TXPOWER(p, f, a...) IL_DEBUG(p, IL_DL_TXPOWER, f, ## a) -#define IL_DEBUG_IO(p, f, a...) IL_DEBUG(p, IL_DL_IO, f, ## a) #define IL_DEBUG_RATE(p, f, a...) IL_DEBUG(p, IL_DL_RATE, f, ## a) #define IL_DEBUG_RATE_LIMIT(p, f, a...) \ IL_DEBUG_LIMIT(p, IL_DL_RATE, f, ## a) diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h index 42d241fd6ac9..d6aae8daf3f0 100644 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ b/drivers/net/wireless/iwlegacy/iwl-io.h @@ -34,90 +34,24 @@ #include "iwl-dev.h" #include "iwl-debug.h" -/* - * IO, register, and NIC memory access functions - * - * NOTE on naming convention and macro usage for these - * - * A single _ prefix before a an access function means that no state - * check or debug information is printed when that function is called. - * - * A double __ prefix before an access function means that state is checked - * and the current line number and caller function name are printed in addition - * to any other debug output. - * - * The non-prefixed name is the #define that maps the caller into a - * #define that provides the caller's name and __LINE__ to the double - * prefix version. - * - * If you wish to call the function without any debug or state checking, - * you should use the single _ prefix version (as is used by dependent IO - * routines, for example _il_read_direct32 calls the non-check version of - * _il_read32.) - * - * These declarations are *extremely* useful in quickly isolating code deltas - * which result in misconfiguration of the hardware I/O. In combination with - * git-bisect and the IO debug level you can quickly determine the specific - * commit which breaks the IO sequence to the hardware. - * - */ - static inline void _il_write8(struct il_priv *il, u32 ofs, u8 val) { iowrite8(val, il->hw_base + ofs); } - -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline void -__il_write8(const char *f, u32 l, struct il_priv *il, - u32 ofs, u8 val) -{ - IL_DEBUG_IO(il, "write8(0x%08X, 0x%02X) - %s %d\n", ofs, val, f, l); - _il_write8(il, ofs, val); -} -#define il_write8(il, ofs, val) \ - __il_write8(__FILE__, __LINE__, il, ofs, val) -#else #define il_write8(il, ofs, val) _il_write8(il, ofs, val) -#endif - static inline void _il_write32(struct il_priv *il, u32 ofs, u32 val) { iowrite32(val, il->hw_base + ofs); } - -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline void -__il_write32(const char *f, u32 l, struct il_priv *il, - u32 ofs, u32 val) -{ - IL_DEBUG_IO(il, "write32(0x%08X, 0x%08X) - %s %d\n", ofs, val, f, l); - _il_write32(il, ofs, val); -} -#define il_write32(il, ofs, val) \ - __il_write32(__FILE__, __LINE__, il, ofs, val) -#else #define il_write32(il, ofs, val) _il_write32(il, ofs, val) -#endif static inline u32 _il_read32(struct il_priv *il, u32 ofs) { u32 val = ioread32(il->hw_base + ofs); return val; } - -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline u32 -__il_read32(char *f, u32 l, struct il_priv *il, u32 ofs) -{ - IL_DEBUG_IO(il, "read_direct32(0x%08X) - %s %d\n", ofs, f, l); - return _il_read32(il, ofs); -} -#define il_read32(il, ofs) __il_read32(__FILE__, __LINE__, il, ofs) -#else #define il_read32(p, o) _il_read32(p, o) -#endif #define IL_POLL_INTERVAL 10 /* microseconds */ static inline int @@ -135,46 +69,13 @@ _il_poll_bit(struct il_priv *il, u32 addr, return -ETIMEDOUT; } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline int __il_poll_bit(const char *f, u32 l, - struct il_priv *il, u32 addr, - u32 bits, u32 mask, int timeout) -{ - int ret = _il_poll_bit(il, addr, bits, mask, timeout); - IL_DEBUG_IO(il, "poll_bit(0x%08X, 0x%08X, 0x%08X) - %s- %s %d\n", - addr, bits, mask, - unlikely(ret == -ETIMEDOUT) ? "timeout" : "", f, l); - return ret; -} -#define il_poll_bit(il, addr, bits, mask, timeout) \ - __il_poll_bit(__FILE__, __LINE__, il, addr, \ - bits, mask, timeout) -#else #define il_poll_bit(p, a, b, m, t) _il_poll_bit(p, a, b, m, t) -#endif static inline void _il_set_bit(struct il_priv *il, u32 reg, u32 mask) { _il_write32(il, reg, _il_read32(il, reg) | mask); } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline void __il_set_bit(const char *f, u32 l, - struct il_priv *il, u32 reg, u32 mask) -{ - u32 val = _il_read32(il, reg) | mask; - IL_DEBUG_IO(il, "set_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, - mask, val); - _il_write32(il, reg, val); -} -static inline void il_set_bit(struct il_priv *p, u32 r, u32 m) -{ - unsigned long reg_flags; - spin_lock_irqsave(&p->reg_lock, reg_flags); - __il_set_bit(__FILE__, __LINE__, p, r, m); - spin_unlock_irqrestore(&p->reg_lock, reg_flags); -} -#else static inline void il_set_bit(struct il_priv *p, u32 r, u32 m) { unsigned long reg_flags; @@ -183,31 +84,13 @@ static inline void il_set_bit(struct il_priv *p, u32 r, u32 m) _il_set_bit(p, r, m); spin_unlock_irqrestore(&p->reg_lock, reg_flags); } -#endif static inline void _il_clear_bit(struct il_priv *il, u32 reg, u32 mask) { _il_write32(il, reg, _il_read32(il, reg) & ~mask); } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline void -__il_clear_bit(const char *f, u32 l, - struct il_priv *il, u32 reg, u32 mask) -{ - u32 val = _il_read32(il, reg) & ~mask; - IL_DEBUG_IO(il, "clear_bit(0x%08X, 0x%08X) = 0x%08X\n", reg, mask, val); - _il_write32(il, reg, val); -} -static inline void il_clear_bit(struct il_priv *p, u32 r, u32 m) -{ - unsigned long reg_flags; - spin_lock_irqsave(&p->reg_lock, reg_flags); - __il_clear_bit(__FILE__, __LINE__, p, r, m); - spin_unlock_irqrestore(&p->reg_lock, reg_flags); -} -#else static inline void il_clear_bit(struct il_priv *p, u32 r, u32 m) { unsigned long reg_flags; @@ -216,7 +99,6 @@ static inline void il_clear_bit(struct il_priv *p, u32 r, u32 m) _il_clear_bit(p, r, m); spin_unlock_irqrestore(&p->reg_lock, reg_flags); } -#endif static inline int _il_grab_nic_access(struct il_priv *il) { @@ -259,69 +141,20 @@ static inline int _il_grab_nic_access(struct il_priv *il) return 0; } - -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline int __il_grab_nic_access(const char *f, u32 l, - struct il_priv *il) -{ - IL_DEBUG_IO(il, "grabbing nic access - %s %d\n", f, l); - return _il_grab_nic_access(il); -} -#define il_grab_nic_access(il) \ - __il_grab_nic_access(__FILE__, __LINE__, il) -#else -#define il_grab_nic_access(il) \ - _il_grab_nic_access(il) -#endif +#define il_grab_nic_access(il) _il_grab_nic_access(il) static inline void _il_release_nic_access(struct il_priv *il) { _il_clear_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline void __il_release_nic_access(const char *f, u32 l, - struct il_priv *il) -{ - - IL_DEBUG_IO(il, "releasing nic access - %s %d\n", f, l); - _il_release_nic_access(il); -} -#define il_release_nic_access(il) \ - __il_release_nic_access(__FILE__, __LINE__, il) -#else -#define il_release_nic_access(il) \ - _il_release_nic_access(il) -#endif +#define il_release_nic_access(il) _il_release_nic_access(il) static inline u32 _il_read_direct32(struct il_priv *il, u32 reg) { return _il_read32(il, reg); } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline u32 __il_read_direct32(const char *f, u32 l, - struct il_priv *il, u32 reg) -{ - u32 value = _il_read_direct32(il, reg); - IL_DEBUG_IO(il, - "read_direct32(0x%4X) = 0x%08x - %s %d\n", reg, value, - f, l); - return value; -} -static inline u32 il_read_direct32(struct il_priv *il, u32 reg) -{ - u32 value; - unsigned long reg_flags; - - spin_lock_irqsave(&il->reg_lock, reg_flags); - il_grab_nic_access(il); - value = __il_read_direct32(__FILE__, __LINE__, il, reg); - il_release_nic_access(il); - spin_unlock_irqrestore(&il->reg_lock, reg_flags); - return value; -} -#else static inline u32 il_read_direct32(struct il_priv *il, u32 reg) { u32 value; @@ -335,7 +168,6 @@ static inline u32 il_read_direct32(struct il_priv *il, u32 reg) return value; } -#endif static inline void _il_write_direct32(struct il_priv *il, u32 reg, u32 value) @@ -380,27 +212,7 @@ static inline int _il_poll_direct_bit(struct il_priv *il, u32 addr, return -ETIMEDOUT; } - -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -static inline int __il_poll_direct_bit(const char *f, u32 l, - struct il_priv *il, - u32 addr, u32 mask, int timeout) -{ - int ret = _il_poll_direct_bit(il, addr, mask, timeout); - - if (unlikely(ret == -ETIMEDOUT)) - IL_DEBUG_IO(il, "poll_direct_bit(0x%08X, 0x%08X) - " - "timedout - %s %d\n", addr, mask, f, l); - else - IL_DEBUG_IO(il, "poll_direct_bit(0x%08X, 0x%08X) = 0x%08X " - "- %s %d\n", addr, mask, ret, f, l); - return ret; -} -#define il_poll_direct_bit(il, addr, mask, timeout) \ -__il_poll_direct_bit(__FILE__, __LINE__, il, addr, mask, timeout) -#else #define il_poll_direct_bit _il_poll_direct_bit -#endif static inline u32 _il_read_prph(struct il_priv *il, u32 reg) { -- cgit v1.2.3 From 2d27c5dbd696e7e3a162bba7b948486a9856abca Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 16 Aug 2011 15:36:33 +0200 Subject: iwlegacy: remove DEBUG_LIMIT Even if messages are generating fast we want to see all of them when debugging. Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-3945.c | 4 ++-- drivers/net/wireless/iwlegacy/iwl-4965-lib.c | 4 ++-- drivers/net/wireless/iwlegacy/iwl-4965-rs.c | 4 ++-- drivers/net/wireless/iwlegacy/iwl-4965.c | 2 +- drivers/net/wireless/iwlegacy/iwl-debug.h | 22 +--------------------- 5 files changed, 8 insertions(+), 28 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index c9b5dcf446b4..628adf59ce7b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -477,7 +477,7 @@ static void il3945_pass_packet_to_mac80211(struct il_priv *il, /* We only process data packets if the interface is open */ if (unlikely(!il->is_open)) { - IL_DEBUG_DROP_LIMIT(il, + IL_DEBUG_DROP(il, "Dropping packet while interface is not open.\n"); return; } @@ -563,7 +563,7 @@ static void il3945_rx_reply_rx(struct il_priv *il, network_packet = il3945_is_network_packet(il, header); - IL_DEBUG_STATS_LIMIT(il, "[%c] %d RSSI:%d Signal:%u, Rate:%u\n", + IL_DEBUG_STATS(il, "[%c] %d RSSI:%d Signal:%u, Rate:%u\n", network_packet ? '*' : ' ', le16_to_cpu(rx_hdr->channel), rx_status.signal, rx_status.signal, diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index 647399ed0a0c..156462973e6b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -537,7 +537,7 @@ static void il4965_pass_packet_to_mac80211(struct il_priv *il, /* We only process data packets if the interface is open */ if (unlikely(!il->is_open)) { - IL_DEBUG_DROP_LIMIT(il, + IL_DEBUG_DROP(il, "Dropping packet while interface is not open.\n"); return; } @@ -647,7 +647,7 @@ void il4965_rx_reply_rx(struct il_priv *il, rx_status.signal = il4965_calc_rssi(il, phy_res); il_dbg_log_rx_data_frame(il, len, header); - IL_DEBUG_STATS_LIMIT(il, "Rssi %d, TSF %llu\n", + IL_DEBUG_STATS(il, "Rssi %d, TSF %llu\n", rx_status.signal, (unsigned long long)rx_status.mactime); /* diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index 60ff0cdff9c0..782ec77715f5 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -817,7 +817,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, struct il_station_priv *sta_priv = (void *)sta->drv_priv; struct il_rxon_context *ctx = sta_priv->common.ctx; - IL_DEBUG_RATE_LIMIT(il, + IL_DEBUG_RATE(il, "get frame ack response, update rate scale window\n"); /* Treat uninitialized rate scaling data same as non-existing. */ @@ -2251,7 +2251,7 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, struct il_lq_sta *lq_sta = il_sta; int rate_idx; - IL_DEBUG_RATE_LIMIT(il, "rate scale calculate new rate for skb\n"); + IL_DEBUG_RATE(il, "rate scale calculate new rate for skb\n"); /* Get max rate if user set max rate */ if (lq_sta) { diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index d3c818354ca5..01fa6c8d0304 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -1737,7 +1737,7 @@ static u8 il4965_find_station(struct il_priv *il, const u8 *addr) goto out; } - IL_DEBUG_ASSOC_LIMIT(il, "can not find STA %pM total %d\n", + IL_DEBUG_ASSOC(il, "can not find STA %pM total %d\n", addr, il->num_stations); out: diff --git a/drivers/net/wireless/iwlegacy/iwl-debug.h b/drivers/net/wireless/iwlegacy/iwl-debug.h index a825051d5f2d..c6dcbf3a2ffc 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debug.h +++ b/drivers/net/wireless/iwlegacy/iwl-debug.h @@ -52,14 +52,6 @@ do { \ __func__ , ## args); \ } while (0) -#define IL_DEBUG_LIMIT(__priv, level, fmt, args...) \ -do { \ - if ((il_get_debug_level(__priv) & (level)) && net_ratelimit()) \ - dev_printk(KERN_ERR, &(__priv->hw->wiphy->dev), \ - "%c %s " fmt, in_interrupt() ? 'I' : 'U', \ - __func__ , ## args); \ -} while (0) - #define il_print_hex_dump(il, level, p, len) \ do { \ if (il_get_debug_level(il) & level) \ @@ -69,7 +61,6 @@ do { \ #else #define IL_DEBUG(__priv, level, fmt, args...) -#define IL_DEBUG_LIMIT(__priv, level, fmt, args...) static inline void il_print_hex_dump(struct il_priv *il, int level, const void *p, u32 len) {} @@ -169,25 +160,14 @@ static inline void il_dbgfs_unregister(struct il_priv *il) #define IL_DEBUG_FW(p, f, a...) IL_DEBUG(p, IL_DL_FW, f, ## a) #define IL_DEBUG_RF_KILL(p, f, a...) IL_DEBUG(p, IL_DL_RF_KILL, f, ## a) #define IL_DEBUG_DROP(p, f, a...) IL_DEBUG(p, IL_DL_DROP, f, ## a) -#define IL_DEBUG_DROP_LIMIT(p, f, a...) \ - IL_DEBUG_LIMIT(p, IL_DL_DROP, f, ## a) #define IL_DEBUG_AP(p, f, a...) IL_DEBUG(p, IL_DL_AP, f, ## a) #define IL_DEBUG_TXPOWER(p, f, a...) IL_DEBUG(p, IL_DL_TXPOWER, f, ## a) #define IL_DEBUG_RATE(p, f, a...) IL_DEBUG(p, IL_DL_RATE, f, ## a) -#define IL_DEBUG_RATE_LIMIT(p, f, a...) \ - IL_DEBUG_LIMIT(p, IL_DL_RATE, f, ## a) #define IL_DEBUG_NOTIF(p, f, a...) IL_DEBUG(p, IL_DL_NOTIF, f, ## a) -#define IL_DEBUG_ASSOC(p, f, a...) \ - IL_DEBUG(p, IL_DL_ASSOC | IL_DL_INFO, f, ## a) -#define IL_DEBUG_ASSOC_LIMIT(p, f, a...) \ - IL_DEBUG_LIMIT(p, IL_DL_ASSOC | IL_DL_INFO, f, ## a) +#define IL_DEBUG_ASSOC(p, f, a...) IL_DEBUG(p, IL_DL_ASSOC, f, ## a) #define IL_DEBUG_HT(p, f, a...) IL_DEBUG(p, IL_DL_HT, f, ## a) #define IL_DEBUG_STATS(p, f, a...) IL_DEBUG(p, IL_DL_STATS, f, ## a) -#define IL_DEBUG_STATS_LIMIT(p, f, a...) \ - IL_DEBUG_LIMIT(p, IL_DL_STATS, f, ## a) #define IL_DEBUG_TX_REPLY(p, f, a...) IL_DEBUG(p, IL_DL_TX_REPLY, f, ## a) -#define IL_DEBUG_TX_REPLY_LIMIT(p, f, a...) \ - IL_DEBUG_LIMIT(p, IL_DL_TX_REPLY, f, ## a) #define IL_DEBUG_QOS(p, f, a...) IL_DEBUG(p, IL_DL_QOS, f, ## a) #define IL_DEBUG_RADIO(p, f, a...) IL_DEBUG(p, IL_DL_RADIO, f, ## a) #define IL_DEBUG_POWER(p, f, a...) IL_DEBUG(p, IL_DL_POWER, f, ## a) -- cgit v1.2.3 From 58de00a464f1e7cf0b108341dc6cc49276d19d7a Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 11:21:01 +0100 Subject: iwlegacy: rename IL_DEBUG_ to D_ Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-3945-rs.c | 64 +++---- drivers/net/wireless/iwlegacy/iwl-3945.c | 102 ++++++------ drivers/net/wireless/iwlegacy/iwl-4965-calib.c | 80 ++++----- drivers/net/wireless/iwlegacy/iwl-4965-lib.c | 38 ++--- drivers/net/wireless/iwlegacy/iwl-4965-rs.c | 106 ++++++------ drivers/net/wireless/iwlegacy/iwl-4965-rx.c | 8 +- drivers/net/wireless/iwlegacy/iwl-4965-sta.c | 18 +- drivers/net/wireless/iwlegacy/iwl-4965-tx.c | 52 +++--- drivers/net/wireless/iwlegacy/iwl-4965-ucode.c | 12 +- drivers/net/wireless/iwlegacy/iwl-4965.c | 114 ++++++------- drivers/net/wireless/iwlegacy/iwl-core.c | 136 +++++++-------- drivers/net/wireless/iwlegacy/iwl-debug.h | 76 ++++----- drivers/net/wireless/iwlegacy/iwl-eeprom.c | 18 +- drivers/net/wireless/iwlegacy/iwl-hcmd.c | 10 +- drivers/net/wireless/iwlegacy/iwl-helpers.h | 6 +- drivers/net/wireless/iwlegacy/iwl-led.c | 2 +- drivers/net/wireless/iwlegacy/iwl-power.c | 16 +- drivers/net/wireless/iwlegacy/iwl-rx.c | 10 +- drivers/net/wireless/iwlegacy/iwl-scan.c | 52 +++--- drivers/net/wireless/iwlegacy/iwl-sta.c | 72 ++++---- drivers/net/wireless/iwlegacy/iwl-tx.c | 8 +- drivers/net/wireless/iwlegacy/iwl3945-base.c | 222 ++++++++++++------------- drivers/net/wireless/iwlegacy/iwl4965-base.c | 148 ++++++++--------- 23 files changed, 685 insertions(+), 685 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c index 38f1b825af10..d05da7a46c41 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c @@ -167,7 +167,7 @@ static int il3945_rate_scale_flush_windows(struct il3945_rs_sta *rs_sta) spin_lock_irqsave(&rs_sta->lock, flags); if (time_after(jiffies, rs_sta->win[i].stamp + IL_RATE_WIN_FLUSH)) { - IL_DEBUG_RATE(il, "flushing %d samples of rate " + D_RATE("flushing %d samples of rate " "index %d\n", rs_sta->win[i].counter, i); il3945_clear_window(&rs_sta->win[i]); @@ -191,7 +191,7 @@ static void il3945_bg_rate_scale_flush(unsigned long data) unsigned long flags; u32 packet_count, duration, pps; - IL_DEBUG_RATE(il, "enter\n"); + D_RATE("enter\n"); unflushed = il3945_rate_scale_flush_windows(rs_sta); @@ -206,7 +206,7 @@ static void il3945_bg_rate_scale_flush(unsigned long data) duration = jiffies_to_msecs(jiffies - rs_sta->last_partial_flush); - IL_DEBUG_RATE(il, "Tx'd %d packets in %dms\n", + D_RATE("Tx'd %d packets in %dms\n", packet_count, duration); /* Determine packets per second */ @@ -226,7 +226,7 @@ static void il3945_bg_rate_scale_flush(unsigned long data) rs_sta->flush_time = msecs_to_jiffies(duration); - IL_DEBUG_RATE(il, "new flush period: %d msec ave %d\n", + D_RATE("new flush period: %d msec ave %d\n", duration, packet_count); mod_timer(&rs_sta->rate_scale_flush, jiffies + @@ -244,7 +244,7 @@ static void il3945_bg_rate_scale_flush(unsigned long data) spin_unlock_irqrestore(&rs_sta->lock, flags); - IL_DEBUG_RATE(il, "leave\n"); + D_RATE("leave\n"); } /** @@ -263,7 +263,7 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, struct il_priv *il __maybe_unused = rs_sta->il; if (!retries) { - IL_DEBUG_RATE(il, "leave: retries == 0 -- should be at least 1\n"); + D_RATE("leave: retries == 0 -- should be at least 1\n"); return; } @@ -341,7 +341,7 @@ void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_i struct ieee80211_supported_band *sband; int i; - IL_DEBUG_INFO(il, "enter\n"); + D_INFO("enter\n"); if (sta_id == il->contexts[IL_RXON_CTX_BSS].bcast_sta_id) goto out; @@ -390,7 +390,7 @@ void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_i out: il->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; - IL_DEBUG_INFO(il, "leave\n"); + D_INFO("leave\n"); } static void *il3945_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) @@ -410,14 +410,14 @@ static void *il3945_rs_alloc_sta(void *il_priv, struct ieee80211_sta *sta, gfp_t struct il3945_sta_priv *psta = (void *) sta->drv_priv; struct il_priv *il __maybe_unused = il_priv; - IL_DEBUG_RATE(il, "enter\n"); + D_RATE("enter\n"); rs_sta = &psta->rs_sta; spin_lock_init(&rs_sta->lock); init_timer(&rs_sta->rate_scale_flush); - IL_DEBUG_RATE(il, "leave\n"); + D_RATE("leave\n"); return rs_sta; } @@ -453,7 +453,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * struct il3945_rs_sta *rs_sta = il_sta; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - IL_DEBUG_RATE(il, "enter\n"); + D_RATE("enter\n"); retries = info->status.rates[0].count; /* Sanity Check for retries */ @@ -462,18 +462,18 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * first_index = sband->bitrates[info->status.rates[0].idx].hw_value; if ((first_index < 0) || (first_index >= IL_RATE_COUNT_3945)) { - IL_DEBUG_RATE(il, "leave: Rate out of bounds: %d\n", first_index); + D_RATE("leave: Rate out of bounds: %d\n", first_index); return; } if (!il_sta) { - IL_DEBUG_RATE(il, "leave: No STA il data to update!\n"); + D_RATE("leave: No STA il data to update!\n"); return; } /* Treat uninitialized rate scaling data same as non-existing. */ if (!rs_sta->il) { - IL_DEBUG_RATE(il, "leave: STA il data uninitialized!\n"); + D_RATE("leave: STA il data uninitialized!\n"); return; } @@ -508,7 +508,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * il3945_collect_tx_data(rs_sta, &rs_sta->win[scale_rate_index], 0, current_count, scale_rate_index); - IL_DEBUG_RATE(il, "Update rate %d for %d retries.\n", + D_RATE("Update rate %d for %d retries.\n", scale_rate_index, current_count); retries -= current_count; @@ -518,7 +518,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * /* Update the last index window with success/failure based on ACK */ - IL_DEBUG_RATE(il, "Update rate %d with %s.\n", + D_RATE("Update rate %d with %s.\n", last_index, (info->flags & IEEE80211_TX_STAT_ACK) ? "success" : "failure"); @@ -543,7 +543,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * spin_unlock_irqrestore(&rs_sta->lock, flags); - IL_DEBUG_RATE(il, "leave\n"); + D_RATE("leave\n"); } static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, @@ -591,7 +591,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, break; if (rate_mask & (1 << low)) break; - IL_DEBUG_RATE(il, "Skipping masked lower rate: %d\n", low); + D_RATE("Skipping masked lower rate: %d\n", low); } high = index; @@ -604,7 +604,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, break; if (rate_mask & (1 << high)) break; - IL_DEBUG_RATE(il, "Skipping masked higher rate: %d\n", high); + D_RATE("Skipping masked higher rate: %d\n", high); } return (high << 8) | low; @@ -648,11 +648,11 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, struct il_priv *il __maybe_unused = (struct il_priv *)il_r; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - IL_DEBUG_RATE(il, "enter\n"); + D_RATE("enter\n"); /* Treat uninitialized rate scaling data same as non-existing. */ if (rs_sta && !rs_sta->il) { - IL_DEBUG_RATE(il, "Rate scaling information not initialized yet.\n"); + D_RATE("Rate scaling information not initialized yet.\n"); il_sta = NULL; } @@ -699,7 +699,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, (window->success_counter < IL_RATE_MIN_SUCCESS_TH))) { spin_unlock_irqrestore(&rs_sta->lock, flags); - IL_DEBUG_RATE(il, "Invalid average_tpt on rate %d: " + D_RATE("Invalid average_tpt on rate %d: " "counter: %d, success_counter: %d, " "expected_tpt is %sNULL\n", index, @@ -737,7 +737,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, /* Low success ratio , need to drop the rate */ if ((window->success_ratio < IL_RATE_DECREASE_TH) || !current_tpt) { - IL_DEBUG_RATE(il, "decrease rate because of low success_ratio\n"); + D_RATE("decrease rate because of low success_ratio\n"); scale_action = -1; /* No throughput measured yet for adjacent rates, * try increase */ @@ -756,7 +756,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, (high_tpt != IL_INVALID_VALUE) && (low_tpt < current_tpt) && (high_tpt < current_tpt)) { - IL_DEBUG_RATE(il, "No action -- low [%d] & high [%d] < " + D_RATE("No action -- low [%d] & high [%d] < " "current_tpt [%d]\n", low_tpt, high_tpt, current_tpt); scale_action = 0; @@ -771,13 +771,13 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, window->success_ratio >= IL_RATE_INCREASE_TH) scale_action = 1; else { - IL_DEBUG_RATE(il, + D_RATE( "decrease rate because of high tpt\n"); scale_action = 0; } } else if (low_tpt != IL_INVALID_VALUE) { if (low_tpt > current_tpt) { - IL_DEBUG_RATE(il, + D_RATE( "decrease rate because of low tpt\n"); scale_action = -1; } else if (window->success_ratio >= IL_RATE_INCREASE_TH) { @@ -816,7 +816,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, break; } - IL_DEBUG_RATE(il, "Selected %d (action %d) - low %d high %d\n", + D_RATE("Selected %d (action %d) - low %d high %d\n", index, scale_action, low, high); out: @@ -831,7 +831,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, info->control.rates[0].idx = rs_sta->last_txrate_idx; } - IL_DEBUG_RATE(il, "leave: %d\n", index); + D_RATE("leave: %d\n", index); } #ifdef CONFIG_MAC80211_DEBUGFS @@ -932,14 +932,14 @@ void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) struct ieee80211_sta *sta; struct il3945_sta_priv *psta; - IL_DEBUG_RATE(il, "enter\n"); + D_RATE("enter\n"); rcu_read_lock(); sta = ieee80211_find_sta(il->contexts[IL_RXON_CTX_BSS].vif, il->stations[sta_id].sta.sta.addr); if (!sta) { - IL_DEBUG_RATE(il, "Unable to find station to initialize rate scaling.\n"); + D_RATE("Unable to find station to initialize rate scaling.\n"); rcu_read_unlock(); return; } @@ -975,11 +975,11 @@ void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) if (rssi == 0) rssi = IL_MIN_RSSI_VAL; - IL_DEBUG_RATE(il, "Network RSSI: %d\n", rssi); + D_RATE("Network RSSI: %d\n", rssi); rs_sta->start_rate = il3945_get_rate_index_by_rssi(rssi, il->band); - IL_DEBUG_RATE(il, "leave: rssi %d assign rate index: " + D_RATE("leave: rssi %d assign rate index: " "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate, il3945_rates[rs_sta->start_rate].plcp); rcu_read_unlock(); diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index 628adf59ce7b..a1e2a4218968 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -174,7 +174,7 @@ void il3945_disable_events(struct il_priv *il) array_size = il_read_targ_mem(il, base + (5 * sizeof(u32))); if (IL_EVT_DISABLE && (array_size == IL_EVT_DISABLE_SIZE)) { - IL_DEBUG_INFO(il, "Disabling selected uCode log events at 0x%x\n", + D_INFO("Disabling selected uCode log events at 0x%x\n", disable_ptr); for (i = 0; i < IL_EVT_DISABLE_SIZE; i++) il_write_targ_mem(il, @@ -182,9 +182,9 @@ void il3945_disable_events(struct il_priv *il) evt_disable[i]); } else { - IL_DEBUG_INFO(il, "Selected uCode log events may be disabled\n"); - IL_DEBUG_INFO(il, " by writing \"1\"s into disable bitmap\n"); - IL_DEBUG_INFO(il, " in SRAM at 0x%x, size %d u32s\n", + D_INFO("Selected uCode log events may be disabled\n"); + D_INFO(" by writing \"1\"s into disable bitmap\n"); + D_INFO(" in SRAM at 0x%x, size %d u32s\n", disable_ptr, array_size); } @@ -342,11 +342,11 @@ static void il3945_rx_reply_tx(struct il_priv *il, info->flags |= ((status & TX_STATUS_MSK) == TX_STATUS_SUCCESS) ? IEEE80211_TX_STAT_ACK : 0; - IL_DEBUG_TX(il, "Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", + D_TX("Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", txq_id, il3945_get_tx_fail_reason(status), status, tx_resp->rate, tx_resp->failure_frame); - IL_DEBUG_TX_REPLY(il, "Tx queue reclaim %d\n", index); + D_TX_REPLY("Tx queue reclaim %d\n", index); il3945_tx_queue_reclaim(il, txq_id, index); if (status & TX_ABORT_REQUIRED_MSK) @@ -401,7 +401,7 @@ void il3945_hw_rx_statistics(struct il_priv *il, { struct il_rx_packet *pkt = rxb_addr(rxb); - IL_DEBUG_RX(il, "Statistics notification received (%d vs %d).\n", + D_RX("Statistics notification received (%d vs %d).\n", (int)sizeof(struct il3945_notif_statistics), le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS @@ -426,7 +426,7 @@ void il3945_reply_statistics(struct il_priv *il, memset(&il->_3945.max_delta, 0, sizeof(struct il3945_notif_statistics)); #endif - IL_DEBUG_RX(il, "Statistics have been cleared\n"); + D_RX("Statistics have been cleared\n"); } il3945_hw_rx_statistics(il, rxb); } @@ -471,13 +471,13 @@ static void il3945_pass_packet_to_mac80211(struct il_priv *il, /* We received data from the HW, so stop the watchdog */ if (unlikely(len + IWL39_RX_FRAME_SIZE > PAGE_SIZE << il->hw_params.rx_page_order)) { - IL_DEBUG_DROP(il, "Corruption detected!\n"); + D_DROP("Corruption detected!\n"); return; } /* We only process data packets if the interface is open */ if (unlikely(!il->is_open)) { - IL_DEBUG_DROP(il, + D_DROP( "Dropping packet while interface is not open.\n"); return; } @@ -539,14 +539,14 @@ static void il3945_rx_reply_rx(struct il_priv *il, rx_status.flag |= RX_FLAG_SHORTPRE; if ((unlikely(rx_stats->phy_count > 20))) { - IL_DEBUG_DROP(il, "dsp size out of range [0,20]: %d/n", + D_DROP("dsp size out of range [0,20]: %d/n", rx_stats->phy_count); return; } if (!(rx_end->status & RX_RES_STATUS_NO_CRC32_ERROR) || !(rx_end->status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { - IL_DEBUG_RX(il, "Bad CRC or FIFO: 0x%08X.\n", rx_end->status); + D_RX("Bad CRC or FIFO: 0x%08X.\n", rx_end->status); return; } @@ -555,7 +555,7 @@ static void il3945_rx_reply_rx(struct il_priv *il, /* Convert 3945's rssi indicator to dBm */ rx_status.signal = rx_stats->rssi - IWL39_RSSI_OFFSET; - IL_DEBUG_STATS(il, "Rssi %d sig_avg %d noise_diff %d\n", + D_STATS("Rssi %d sig_avg %d noise_diff %d\n", rx_status.signal, rx_stats_sig_avg, rx_stats_noise_diff); @@ -563,7 +563,7 @@ static void il3945_rx_reply_rx(struct il_priv *il, network_packet = il3945_is_network_packet(il, header); - IL_DEBUG_STATS(il, "[%c] %d RSSI:%d Signal:%u, Rate:%u\n", + D_STATS("[%c] %d RSSI:%d Signal:%u, Rate:%u\n", network_packet ? '*' : ' ', le16_to_cpu(rx_hdr->channel), rx_status.signal, rx_status.signal, @@ -718,7 +718,7 @@ void il3945_hw_build_tx_cmd_rate(struct il_priv *il, /* CCK */ tx_cmd->supp_rates[1] = (rate_mask & 0xF); - IL_DEBUG_RATE(il, "Tx sta id: %d, rate: %d (plcp), flags: 0x%4X " + D_RATE("Tx sta id: %d, rate: %d (plcp), flags: 0x%4X " "cck/ofdm mask: 0x%x/0x%x\n", sta_id, tx_cmd->rate, le32_to_cpu(tx_cmd->tx_flags), tx_cmd->supp_rates[1], tx_cmd->supp_rates[0]); @@ -741,7 +741,7 @@ static u8 il3945_sync_sta(struct il_priv *il, int sta_id, u16 tx_rate) il_send_add_sta(il, &station->sta, CMD_ASYNC); spin_unlock_irqrestore(&il->sta_lock, flags_spin); - IL_DEBUG_RATE(il, "SCALE sync station %d to rate %d\n", + D_RATE("SCALE sync station %d to rate %d\n", sta_id, tx_rate); return sta_id; } @@ -900,34 +900,34 @@ static void il3945_nic_config(struct il_priv *il) spin_lock_irqsave(&il->lock, flags); /* Determine HW type */ - IL_DEBUG_INFO(il, "HW Revision ID = 0x%X\n", rev_id); + D_INFO("HW Revision ID = 0x%X\n", rev_id); if (rev_id & PCI_CFG_REV_ID_BIT_RTP) - IL_DEBUG_INFO(il, "RTP type\n"); + D_INFO("RTP type\n"); else if (rev_id & PCI_CFG_REV_ID_BIT_BASIC_SKU) { - IL_DEBUG_INFO(il, "3945 RADIO-MB type\n"); + D_INFO("3945 RADIO-MB type\n"); il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_3945_MB); } else { - IL_DEBUG_INFO(il, "3945 RADIO-MM type\n"); + D_INFO("3945 RADIO-MM type\n"); il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_3945_MM); } if (EEPROM_SKU_CAP_OP_MODE_MRC == eeprom->sku_cap) { - IL_DEBUG_INFO(il, "SKU OP mode is mrc\n"); + D_INFO("SKU OP mode is mrc\n"); il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_SKU_MRC); } else - IL_DEBUG_INFO(il, "SKU OP mode is basic\n"); + D_INFO("SKU OP mode is basic\n"); if ((eeprom->board_revision & 0xF0) == 0xD0) { - IL_DEBUG_INFO(il, "3945ABG revision is 0x%X\n", + D_INFO("3945ABG revision is 0x%X\n", eeprom->board_revision); il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); } else { - IL_DEBUG_INFO(il, "3945ABG revision is 0x%X\n", + D_INFO("3945ABG revision is 0x%X\n", eeprom->board_revision); il_clear_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); @@ -936,10 +936,10 @@ static void il3945_nic_config(struct il_priv *il) if (eeprom->almgor_m_version <= 1) { il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A); - IL_DEBUG_INFO(il, "Card M type A version is 0x%X\n", + D_INFO("Card M type A version is 0x%X\n", eeprom->almgor_m_version); } else { - IL_DEBUG_INFO(il, "Card M type B version is 0x%X\n", + D_INFO("Card M type B version is 0x%X\n", eeprom->almgor_m_version); il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B); @@ -947,10 +947,10 @@ static void il3945_nic_config(struct il_priv *il) spin_unlock_irqrestore(&il->lock, flags); if (eeprom->sku_cap & EEPROM_SKU_CAP_SW_RF_KILL_ENABLE) - IL_DEBUG_RF_KILL(il, "SW RF KILL supported in EEPROM.\n"); + D_RF_KILL("SW RF KILL supported in EEPROM.\n"); if (eeprom->sku_cap & EEPROM_SKU_CAP_HW_RF_KILL_ENABLE) - IL_DEBUG_RF_KILL(il, "HW RF KILL supported in EEPROM.\n"); + D_RF_KILL("HW RF KILL supported in EEPROM.\n"); } int il3945_hw_nic_init(struct il_priv *il) @@ -1074,7 +1074,7 @@ static int il3945_hw_reg_txpower_get_temperature(struct il_priv *il) /* driver's okay range is -260 to +25. * human readable okay range is 0 to +285 */ - IL_DEBUG_INFO(il, "Temperature: %d\n", temperature + IL_TEMP_CONVERT); + D_INFO("Temperature: %d\n", temperature + IL_TEMP_CONVERT); /* handle insane temp reading */ if (il3945_hw_reg_temp_out_of_range(temperature)) { @@ -1111,20 +1111,20 @@ static int il3945_is_temp_calib_needed(struct il_priv *il) /* get absolute value */ if (temp_diff < 0) { - IL_DEBUG_POWER(il, "Getting cooler, delta %d,\n", temp_diff); + D_POWER("Getting cooler, delta %d,\n", temp_diff); temp_diff = -temp_diff; } else if (temp_diff == 0) - IL_DEBUG_POWER(il, "Same temp,\n"); + D_POWER("Same temp,\n"); else - IL_DEBUG_POWER(il, "Getting warmer, delta %d,\n", temp_diff); + D_POWER("Getting warmer, delta %d,\n", temp_diff); /* if we don't need calibration, *don't* update last_temperature */ if (temp_diff < IL_TEMPERATURE_LIMIT_TIMER) { - IL_DEBUG_POWER(il, "Timed thermal calib not needed\n"); + D_POWER("Timed thermal calib not needed\n"); return 0; } - IL_DEBUG_POWER(il, "Timed thermal calib needed\n"); + D_POWER("Timed thermal calib needed\n"); /* assume that caller will actually do calib ... * update the "last temperature" value */ @@ -1395,7 +1395,7 @@ static int il3945_send_tx_power(struct il_priv *il) } if (!il_is_channel_valid(ch_info)) { - IL_DEBUG_POWER(il, "Not calling TX_PWR_TABLE_CMD on " + D_POWER("Not calling TX_PWR_TABLE_CMD on " "non-Tx channel.\n"); return 0; } @@ -1408,7 +1408,7 @@ static int il3945_send_tx_power(struct il_priv *il) txpower.power[i].tpc = ch_info->power_info[i].tpc; txpower.power[i].rate = il3945_rates[rate_idx].plcp; - IL_DEBUG_POWER(il, "ch %d:%d rf %d dsp %3d rate code 0x%02x\n", + D_POWER("ch %d:%d rf %d dsp %3d rate code 0x%02x\n", le16_to_cpu(txpower.channel), txpower.band, txpower.power[i].tpc.tx_gain, @@ -1421,7 +1421,7 @@ static int il3945_send_tx_power(struct il_priv *il) txpower.power[i].tpc = ch_info->power_info[i].tpc; txpower.power[i].rate = il3945_rates[rate_idx].plcp; - IL_DEBUG_POWER(il, "ch %d:%d rf %d dsp %3d rate code 0x%02x\n", + D_POWER("ch %d:%d rf %d dsp %3d rate code 0x%02x\n", le16_to_cpu(txpower.channel), txpower.band, txpower.power[i].tpc.tx_gain, @@ -1617,12 +1617,12 @@ int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power) u8 i; if (il->tx_power_user_lmt == power) { - IL_DEBUG_POWER(il, "Requested Tx power same as current " + D_POWER("Requested Tx power same as current " "limit: %ddBm.\n", power); return 0; } - IL_DEBUG_POWER(il, "Setting upper limit clamp to %ddBm.\n", power); + D_POWER("Setting upper limit clamp to %ddBm.\n", power); il->tx_power_user_lmt = power; /* set up new Tx powers for each and every channel, 2.4 and 5.x */ @@ -1670,7 +1670,7 @@ static int il3945_send_rxon_assoc(struct il_priv *il, (rxon1->filter_flags == rxon2->filter_flags) && (rxon1->cck_basic_rates == rxon2->cck_basic_rates) && (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { - IL_DEBUG_INFO(il, "Using current RXON_ASSOC. Not resending.\n"); + D_INFO("Using current RXON_ASSOC. Not resending.\n"); return 0; } @@ -1758,7 +1758,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) * we must clear the associated from the active configuration * before we apply the new config */ if (il_is_associated(il, IL_RXON_CTX_BSS) && new_assoc) { - IL_DEBUG_INFO(il, "Toggling associated bit on current RXON\n"); + D_INFO("Toggling associated bit on current RXON\n"); active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; /* @@ -1785,7 +1785,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) &il->contexts[IL_RXON_CTX_BSS]); } - IL_DEBUG_INFO(il, "Sending RXON\n" + D_INFO("Sending RXON\n" "* with%s RXON_FILTER_ASSOC_MSK\n" "* channel = %d\n" "* bssid = %pM\n", @@ -1913,7 +1913,7 @@ static u16 il3945_hw_reg_get_ch_grp_index(struct il_priv *il, } else group_index = 0; /* 2.4 GHz, group 0 */ - IL_DEBUG_POWER(il, "Chnl %d mapped to grp %d\n", ch_info->channel, + D_POWER("Chnl %d mapped to grp %d\n", ch_info->channel, group_index); return group_index; } @@ -1980,7 +1980,7 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *il) struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; const struct il3945_eeprom_txpower_group *group; - IL_DEBUG_POWER(il, "Initializing factory calib info from EEPROM\n"); + D_POWER("Initializing factory calib info from EEPROM\n"); for (i = 0; i < IL_NUM_TX_CALIB_GROUPS; i++) { s8 *clip_pwrs; /* table of power levels for each rate */ @@ -2096,7 +2096,7 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) eeprom->groups[ch_info->group_index]. temperature); - IL_DEBUG_POWER(il, "Delta index for channel %d: %d [%d]\n", + D_POWER("Delta index for channel %d: %d [%d]\n", ch_info->channel, delta_index, temperature + IL_TEMP_CONVERT); @@ -2324,7 +2324,7 @@ int il3945_init_hw_rate_table(struct il_priv *il) switch (il->band) { case IEEE80211_BAND_5GHZ: - IL_DEBUG_RATE(il, "Select A mode rate scale\n"); + D_RATE("Select A mode rate scale\n"); /* If one of the following CCK rates is used, * have it fall back to the 6M OFDM rate */ for (i = IL_RATE_1M_INDEX_TABLE; @@ -2342,7 +2342,7 @@ int il3945_init_hw_rate_table(struct il_priv *il) break; case IEEE80211_BAND_2GHZ: - IL_DEBUG_RATE(il, "Select B/G mode rate scale\n"); + D_RATE("Select B/G mode rate scale\n"); /* If an OFDM rate is used, have it fall back to the * 1M CCK rates */ @@ -2472,7 +2472,7 @@ static int il3945_verify_bsm(struct il_priv *il) u32 reg; u32 val; - IL_DEBUG_INFO(il, "Begin verify bsm\n"); + D_INFO("Begin verify bsm\n"); /* verify BSM SRAM contents */ val = il_read_prph(il, BSM_WR_DWCOUNT_REG); @@ -2490,7 +2490,7 @@ static int il3945_verify_bsm(struct il_priv *il) } } - IL_DEBUG_INFO(il, "BSM bootstrap uCode image OK\n"); + D_INFO("BSM bootstrap uCode image OK\n"); return 0; } @@ -2567,7 +2567,7 @@ static int il3945_load_bsm(struct il_priv *il) u32 done; u32 reg_offset; - IL_DEBUG_INFO(il, "Begin load bsm\n"); + D_INFO("Begin load bsm\n"); /* make sure bootstrap program is no larger than BSM's SRAM size */ if (len > IWL39_MAX_BSM_SIZE) @@ -2618,7 +2618,7 @@ static int il3945_load_bsm(struct il_priv *il) udelay(10); } if (i < 100) - IL_DEBUG_INFO(il, "BSM write complete, poll %d iterations\n", i); + D_INFO("BSM write complete, poll %d iterations\n", i); else { IL_ERR(il, "BSM write did not complete!\n"); return -EIO; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c index 7807dc59e9c5..7f858344b920 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c @@ -160,7 +160,7 @@ static int il4965_sens_energy_cck(struct il_priv *il, val = data->nrg_silence_rssi[i]; silence_ref = max(silence_ref, val); } - IL_DEBUG_CALIB(il, "silence a %u, b %u, c %u, 20-bcn max %u\n", + D_CALIB("silence a %u, b %u, c %u, 20-bcn max %u\n", silence_rssi_a, silence_rssi_b, silence_rssi_c, silence_ref); @@ -184,7 +184,7 @@ static int il4965_sens_energy_cck(struct il_priv *il, max_nrg_cck = (u32) max(max_nrg_cck, (data->nrg_value[i])); max_nrg_cck += 6; - IL_DEBUG_CALIB(il, "rx energy a %u, b %u, c %u, 10-bcn max/min %u\n", + D_CALIB("rx energy a %u, b %u, c %u, 10-bcn max/min %u\n", rx_info->beacon_energy_a, rx_info->beacon_energy_b, rx_info->beacon_energy_c, max_nrg_cck - 6); @@ -194,15 +194,15 @@ static int il4965_sens_energy_cck(struct il_priv *il, data->num_in_cck_no_fa++; else data->num_in_cck_no_fa = 0; - IL_DEBUG_CALIB(il, "consecutive bcns with few false alarms = %u\n", + D_CALIB("consecutive bcns with few false alarms = %u\n", data->num_in_cck_no_fa); /* If we got too many false alarms this time, reduce sensitivity */ if ((false_alarms > max_false_alarms) && (data->auto_corr_cck > AUTO_CORR_MAX_TH_CCK)) { - IL_DEBUG_CALIB(il, "norm FA %u > max FA %u\n", + D_CALIB("norm FA %u > max FA %u\n", false_alarms, max_false_alarms); - IL_DEBUG_CALIB(il, "... reducing sensitivity\n"); + D_CALIB("... reducing sensitivity\n"); data->nrg_curr_state = IL_FA_TOO_MANY; /* Store for "fewer than desired" on later beacon */ data->nrg_silence_ref = silence_ref; @@ -219,7 +219,7 @@ static int il4965_sens_energy_cck(struct il_priv *il, data->nrg_auto_corr_silence_diff = (s32)data->nrg_silence_ref - (s32)silence_ref; - IL_DEBUG_CALIB(il, + D_CALIB( "norm FA %u < min FA %u, silence diff %d\n", false_alarms, min_false_alarms, data->nrg_auto_corr_silence_diff); @@ -234,18 +234,18 @@ static int il4965_sens_energy_cck(struct il_priv *il, ((data->nrg_auto_corr_silence_diff > NRG_DIFF) || (data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA))) { - IL_DEBUG_CALIB(il, "... increasing sensitivity\n"); + D_CALIB("... increasing sensitivity\n"); /* Increase nrg value to increase sensitivity */ val = data->nrg_th_cck + NRG_STEP_CCK; data->nrg_th_cck = min((u32)ranges->min_nrg_cck, val); } else { - IL_DEBUG_CALIB(il, + D_CALIB( "... but not changing sensitivity\n"); } /* Else we got a healthy number of false alarms, keep status quo */ } else { - IL_DEBUG_CALIB(il, " FA in safe zone\n"); + D_CALIB(" FA in safe zone\n"); data->nrg_curr_state = IL_FA_GOOD_RANGE; /* Store for use in "fewer than desired" with later beacon */ @@ -255,7 +255,7 @@ static int il4965_sens_energy_cck(struct il_priv *il, * give it some extra margin by reducing sensitivity again * (but don't go below measured energy of desired Rx) */ if (IL_FA_TOO_MANY == data->nrg_prev_state) { - IL_DEBUG_CALIB(il, "... increasing margin\n"); + D_CALIB("... increasing margin\n"); if (data->nrg_th_cck > (max_nrg_cck + NRG_MARGIN)) data->nrg_th_cck -= NRG_MARGIN; else @@ -269,7 +269,7 @@ static int il4965_sens_energy_cck(struct il_priv *il, * Lower value is higher energy, so we use max()! */ data->nrg_th_cck = max(max_nrg_cck, data->nrg_th_cck); - IL_DEBUG_CALIB(il, "new nrg_th_cck %u\n", data->nrg_th_cck); + D_CALIB("new nrg_th_cck %u\n", data->nrg_th_cck); data->nrg_prev_state = data->nrg_curr_state; @@ -322,7 +322,7 @@ static int il4965_sens_auto_corr_ofdm(struct il_priv *il, /* If we got too many false alarms this time, reduce sensitivity */ if (false_alarms > max_false_alarms) { - IL_DEBUG_CALIB(il, "norm FA %u > max FA %u)\n", + D_CALIB("norm FA %u > max FA %u)\n", false_alarms, max_false_alarms); val = data->auto_corr_ofdm + AUTO_CORR_STEP_OFDM; @@ -345,7 +345,7 @@ static int il4965_sens_auto_corr_ofdm(struct il_priv *il, /* Else if we got fewer than desired, increase sensitivity */ else if (false_alarms < min_false_alarms) { - IL_DEBUG_CALIB(il, "norm FA %u < min FA %u\n", + D_CALIB("norm FA %u < min FA %u\n", false_alarms, min_false_alarms); val = data->auto_corr_ofdm - AUTO_CORR_STEP_OFDM; @@ -364,7 +364,7 @@ static int il4965_sens_auto_corr_ofdm(struct il_priv *il, data->auto_corr_ofdm_mrc_x1 = max((u32)ranges->auto_corr_min_ofdm_mrc_x1, val); } else { - IL_DEBUG_CALIB(il, "min FA %u < norm FA %u < max FA %u OK\n", + D_CALIB("min FA %u < norm FA %u < max FA %u OK\n", min_false_alarms, false_alarms, max_false_alarms); } return 0; @@ -400,12 +400,12 @@ static void il4965_prepare_legacy_sensitivity_tbl(struct il_priv *il, tbl[HD_OFDM_ENERGY_TH_IN_INDEX] = cpu_to_le16(data->nrg_th_cca); - IL_DEBUG_CALIB(il, "ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n", + D_CALIB("ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n", data->auto_corr_ofdm, data->auto_corr_ofdm_mrc, data->auto_corr_ofdm_x1, data->auto_corr_ofdm_mrc_x1, data->nrg_th_ofdm); - IL_DEBUG_CALIB(il, "cck: ac %u mrc %u thresh %u\n", + D_CALIB("cck: ac %u mrc %u thresh %u\n", data->auto_corr_cck, data->auto_corr_cck_mrc, data->nrg_th_cck); } @@ -434,7 +434,7 @@ static int il4965_sensitivity_write(struct il_priv *il) /* Don't send command to uCode if nothing has changed */ if (!memcmp(&cmd.table[0], &(il->sensitivity_tbl[0]), sizeof(u16)*HD_TABLE_SIZE)) { - IL_DEBUG_CALIB(il, "No change in SENSITIVITY_CMD\n"); + D_CALIB("No change in SENSITIVITY_CMD\n"); return 0; } @@ -455,7 +455,7 @@ void il4965_init_sensitivity(struct il_priv *il) if (il->disable_sens_cal) return; - IL_DEBUG_CALIB(il, "Start il4965_init_sensitivity\n"); + D_CALIB("Start il4965_init_sensitivity\n"); /* Clear driver's sensitivity algo data */ data = &(il->sensitivity_data); @@ -496,7 +496,7 @@ void il4965_init_sensitivity(struct il_priv *il) data->last_fa_cnt_cck = 0; ret |= il4965_sensitivity_write(il); - IL_DEBUG_CALIB(il, "<sensitivity_data); if (!il_is_any_associated(il)) { - IL_DEBUG_CALIB(il, "<< - not associated\n"); + D_CALIB("<< - not associated\n"); return; } @@ -531,7 +531,7 @@ void il4965_sensitivity_calibration(struct il_priv *il, void *resp) cck = &(((struct il_notif_statistics *)resp)->rx.cck); if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { - IL_DEBUG_CALIB(il, "<< invalid data.\n"); + D_CALIB("<< invalid data.\n"); spin_unlock_irqrestore(&il->lock, flags); return; } @@ -558,10 +558,10 @@ void il4965_sensitivity_calibration(struct il_priv *il, void *resp) spin_unlock_irqrestore(&il->lock, flags); - IL_DEBUG_CALIB(il, "rx_enable_time = %u usecs\n", rx_enable_time); + D_CALIB("rx_enable_time = %u usecs\n", rx_enable_time); if (!rx_enable_time) { - IL_DEBUG_CALIB(il, "<< RX Enable Time == 0!\n"); + D_CALIB("<< RX Enable Time == 0!\n"); return; } @@ -600,7 +600,7 @@ void il4965_sensitivity_calibration(struct il_priv *il, void *resp) norm_fa_ofdm = fa_ofdm + bad_plcp_ofdm; norm_fa_cck = fa_cck + bad_plcp_cck; - IL_DEBUG_CALIB(il, + D_CALIB( "cck: fa %u badp %u ofdm: fa %u badp %u\n", fa_cck, bad_plcp_cck, fa_ofdm, bad_plcp_ofdm); @@ -657,9 +657,9 @@ il4965_find_disconn_antenna(struct il_priv *il, u32* average_sig, active_chains = (1 << max_average_sig_antenna_i); } - IL_DEBUG_CALIB(il, "average_sig: a %d b %d c %d\n", + D_CALIB("average_sig: a %d b %d c %d\n", average_sig[0], average_sig[1], average_sig[2]); - IL_DEBUG_CALIB(il, "max_average_sig = %d, antenna %d\n", + D_CALIB("max_average_sig = %d, antenna %d\n", max_average_sig, max_average_sig_antenna_i); /* Compare signal strengths for all 3 receivers. */ @@ -673,7 +673,7 @@ il4965_find_disconn_antenna(struct il_priv *il, u32* average_sig, data->disconn_array[i] = 1; else active_chains |= (1 << i); - IL_DEBUG_CALIB(il, "i = %d rssiDelta = %d " + D_CALIB("i = %d rssiDelta = %d " "disconn_array[i] = %d\n", i, rssi_delta, data->disconn_array[i]); } @@ -713,7 +713,7 @@ il4965_find_disconn_antenna(struct il_priv *il, u32* average_sig, il4965_find_first_chain(il->cfg->valid_tx_ant); data->disconn_array[first_chain] = 0; active_chains |= BIT(first_chain); - IL_DEBUG_CALIB(il, + D_CALIB( "All Tx chains are disconnected W/A - declare %d as connected\n", first_chain); break; @@ -722,14 +722,14 @@ il4965_find_disconn_antenna(struct il_priv *il, u32* average_sig, if (active_chains != il->hw_params.valid_rx_ant && active_chains != il->chain_noise_data.active_chains) - IL_DEBUG_CALIB(il, + D_CALIB( "Detected that not all antennas are connected! " "Connected: %#x, valid: %#x.\n", active_chains, il->hw_params.valid_rx_ant); /* Save for use within RXON, TX, SCAN commands, etc. */ data->active_chains = active_chains; - IL_DEBUG_CALIB(il, "active_chains (bitwise) = 0x%x\n", + D_CALIB("active_chains (bitwise) = 0x%x\n", active_chains); } @@ -762,7 +762,7 @@ static void il4965_gain_computation(struct il_priv *il, data->delta_gain_code[i] = 0; } } - IL_DEBUG_CALIB(il, "delta_gain_codes: a %d b %d c %d\n", + D_CALIB("delta_gain_codes: a %d b %d c %d\n", data->delta_gain_code[0], data->delta_gain_code[1], data->delta_gain_code[2]); @@ -780,7 +780,7 @@ static void il4965_gain_computation(struct il_priv *il, ret = il_send_cmd_pdu(il, REPLY_PHY_CALIBRATION_CMD, sizeof(cmd), &cmd); if (ret) - IL_DEBUG_CALIB(il, "fail sending cmd " + D_CALIB("fail sending cmd " "REPLY_PHY_CALIBRATION_CMD\n"); /* TODO we might want recalculate @@ -834,7 +834,7 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) */ if (data->state != IL_CHAIN_NOISE_ACCUMULATE) { if (data->state == IL_CHAIN_NOISE_ALIVE) - IL_DEBUG_CALIB(il, "Wait for noise calib reset\n"); + D_CALIB("Wait for noise calib reset\n"); return; } @@ -844,7 +844,7 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) rx.general); if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { - IL_DEBUG_CALIB(il, " << Interference data unavailable\n"); + D_CALIB(" << Interference data unavailable\n"); spin_unlock_irqrestore(&il->lock, flags); return; } @@ -861,7 +861,7 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) /* Make sure we accumulate data for just the associated channel * (even if scanning). */ if ((rxon_chnum != stat_chnum) || (rxon_band24 != stat_band24)) { - IL_DEBUG_CALIB(il, "Stats not from chan=%d, band24=%d\n", + D_CALIB("Stats not from chan=%d, band24=%d\n", rxon_chnum, rxon_band24); spin_unlock_irqrestore(&il->lock, flags); return; @@ -894,11 +894,11 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) data->chain_signal_b = (chain_sig_b + data->chain_signal_b); data->chain_signal_c = (chain_sig_c + data->chain_signal_c); - IL_DEBUG_CALIB(il, "chan=%d, band24=%d, beacon=%d\n", + D_CALIB("chan=%d, band24=%d, beacon=%d\n", rxon_chnum, rxon_band24, data->beacon_count); - IL_DEBUG_CALIB(il, "chain_sig: a %d b %d c %d\n", + D_CALIB("chain_sig: a %d b %d c %d\n", chain_sig_a, chain_sig_b, chain_sig_c); - IL_DEBUG_CALIB(il, "chain_noise: a %d b %d c %d\n", + D_CALIB("chain_noise: a %d b %d c %d\n", chain_noise_a, chain_noise_b, chain_noise_c); /* If this is the "chain_noise_num_beacons", determine: @@ -929,11 +929,11 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) } } - IL_DEBUG_CALIB(il, "average_noise: a %d b %d c %d\n", + D_CALIB("average_noise: a %d b %d c %d\n", average_noise[0], average_noise[1], average_noise[2]); - IL_DEBUG_CALIB(il, "min_average_noise = %d, antenna %d\n", + D_CALIB("min_average_noise = %d, antenna %d\n", min_average_noise, min_average_noise_antenna_i); il4965_gain_computation(il, average_noise, diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index 156462973e6b..b51ae3d63b79 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -303,7 +303,7 @@ static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) page = alloc_pages(gfp_mask, il->hw_params.rx_page_order); if (!page) { if (net_ratelimit()) - IL_DEBUG_INFO(il, "alloc_pages failed, " + D_INFO("alloc_pages failed, " "order: %d\n", il->hw_params.rx_page_order); @@ -456,7 +456,7 @@ static int il4965_calc_rssi(struct il_priv *il, if (valid_antennae & (1 << i)) max_rssi = max(ncphy->rssi_info[i << 1], max_rssi); - IL_DEBUG_STATS(il, "Rssi In A %d B %d C %d Max %d AGC dB %d\n", + D_STATS("Rssi In A %d B %d C %d Max %d AGC dB %d\n", ncphy->rssi_info[0], ncphy->rssi_info[2], ncphy->rssi_info[4], max_rssi, agc); @@ -519,7 +519,7 @@ static u32 il4965_translate_rx_status(struct il_priv *il, u32 decrypt_in) break; } - IL_DEBUG_RX(il, "decrypt_in:0x%x decrypt_out = 0x%x\n", + D_RX("decrypt_in:0x%x decrypt_out = 0x%x\n", decrypt_in, decrypt_out); return decrypt_out; @@ -537,7 +537,7 @@ static void il4965_pass_packet_to_mac80211(struct il_priv *il, /* We only process data packets if the interface is open */ if (unlikely(!il->is_open)) { - IL_DEBUG_DROP(il, + D_DROP( "Dropping packet while interface is not open.\n"); return; } @@ -611,14 +611,14 @@ void il4965_rx_reply_rx(struct il_priv *il, } if ((unlikely(phy_res->cfg_phy_cnt > 20))) { - IL_DEBUG_DROP(il, "dsp size out of range [0,20]: %d/n", + D_DROP("dsp size out of range [0,20]: %d/n", phy_res->cfg_phy_cnt); return; } if (!(rx_pkt_status & RX_RES_STATUS_NO_CRC32_ERROR) || !(rx_pkt_status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { - IL_DEBUG_RX(il, "Bad CRC or FIFO: 0x%08X.\n", + D_RX("Bad CRC or FIFO: 0x%08X.\n", le32_to_cpu(rx_pkt_status)); return; } @@ -647,7 +647,7 @@ void il4965_rx_reply_rx(struct il_priv *il, rx_status.signal = il4965_calc_rssi(il, phy_res); il_dbg_log_rx_data_frame(il, len, header); - IL_DEBUG_STATS(il, "Rssi %d, TSF %llu\n", + D_STATS("Rssi %d, TSF %llu\n", rx_status.signal, (unsigned long long)rx_status.mactime); /* @@ -729,7 +729,7 @@ static int il4965_get_channels_for_scan(struct il_priv *il, ch_info = il_get_channel_info(il, band, channel); if (!il_is_channel_valid(ch_info)) { - IL_DEBUG_SCAN(il, + D_SCAN( "Channel %d is INVALID for this band.\n", channel); continue; @@ -759,7 +759,7 @@ static int il4965_get_channels_for_scan(struct il_priv *il, else scan_ch->tx_gain = ((1 << 5) | (5 << 3)); - IL_DEBUG_SCAN(il, "Scanning ch=%d prob=0x%X [%s %d]\n", + D_SCAN("Scanning ch=%d prob=0x%X [%s %d]\n", channel, le32_to_cpu(scan_ch->type), (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ? "ACTIVE" : "PASSIVE", @@ -770,7 +770,7 @@ static int il4965_get_channels_for_scan(struct il_priv *il, added++; } - IL_DEBUG_SCAN(il, "total channels to scan %d\n", added); + D_SCAN("total channels to scan %d\n", added); return added; } @@ -805,7 +805,7 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) il->scan_cmd = kmalloc(sizeof(struct il_scan_cmd) + IL_MAX_SCAN_SIZE, GFP_KERNEL); if (!il->scan_cmd) { - IL_DEBUG_SCAN(il, + D_SCAN( "fail to allocate memory for scan\n"); return -ENOMEM; } @@ -822,7 +822,7 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) u32 suspend_time = 100; u32 scan_suspend_time = 100; - IL_DEBUG_INFO(il, "Scanning while associated...\n"); + D_INFO("Scanning while associated...\n"); interval = vif->bss_conf.beacon_int; scan->suspend_time = 0; @@ -834,13 +834,13 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) scan_suspend_time = (extra | ((suspend_time % interval) * 1024)); scan->suspend_time = cpu_to_le32(scan_suspend_time); - IL_DEBUG_SCAN(il, "suspend_time 0x%X beacon interval %d\n", + D_SCAN("suspend_time 0x%X beacon interval %d\n", scan_suspend_time, interval); } if (il->scan_request->n_ssids) { int i, p = 0; - IL_DEBUG_SCAN(il, "Kicking off active scan\n"); + D_SCAN("Kicking off active scan\n"); for (i = 0; i < il->scan_request->n_ssids; i++) { /* always does wildcard anyway */ if (!il->scan_request->ssids[i].ssid_len) @@ -856,7 +856,7 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) } is_active = true; } else - IL_DEBUG_SCAN(il, "Start passive scan.\n"); + D_SCAN("Start passive scan.\n"); scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; scan->tx_cmd.sta_id = ctx->bcast_sta_id; @@ -923,7 +923,7 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) if (!active_chains) active_chains = rx_ant; - IL_DEBUG_SCAN(il, "chain_noise_data.active_chains: %u\n", + D_SCAN("chain_noise_data.active_chains: %u\n", il->chain_noise_data.active_chains); rx_ant = il4965_first_antenna(active_chains); @@ -951,7 +951,7 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) is_active, n_probes, (void *)&scan->data[cmd_len]); if (scan->channel_count == 0) { - IL_DEBUG_SCAN(il, "channel count %d\n", scan->channel_count); + D_SCAN("channel count %d\n", scan->channel_count); return -EIO; } @@ -990,7 +990,7 @@ void il4965_free_tfds_in_queue(struct il_priv *il, if (il->stations[sta_id].tid[tid].tfds_in_queue >= freed) il->stations[sta_id].tid[tid].tfds_in_queue -= freed; else { - IL_DEBUG_TX(il, "free more than tfds_in_queue (%u:%d)\n", + D_TX("free more than tfds_in_queue (%u:%d)\n", il->stations[sta_id].tid[tid].tfds_in_queue, freed); il->stations[sta_id].tid[tid].tfds_in_queue = 0; @@ -1111,7 +1111,7 @@ void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx) else ctx->staging.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK; - IL_DEBUG_ASSOC(il, "rx_chain=0x%X active=%d idle=%d\n", + D_ASSOC("rx_chain=0x%X active=%d idle=%d\n", ctx->staging.rx_chain, active_rx_cnt, idle_rx_cnt); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index 782ec77715f5..b53cf1b70c30 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -358,7 +358,7 @@ static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *il, load = il4965_rs_tl_get_load(lq_data, tid); if (load > IL_AGG_LOAD_THRESHOLD) { - IL_DEBUG_HT(il, "Starting Tx agg: STA: %pM tid: %d\n", + D_HT("Starting Tx agg: STA: %pM tid: %d\n", sta->addr, tid); ret = ieee80211_start_tx_ba_session(sta, tid, 5000); if (ret == -EAGAIN) { @@ -707,7 +707,7 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, break; if (rate_mask & (1 << low)) break; - IL_DEBUG_RATE(il, "Skipping masked lower rate: %d\n", low); + D_RATE("Skipping masked lower rate: %d\n", low); } high = index; @@ -717,7 +717,7 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, break; if (rate_mask & (1 << high)) break; - IL_DEBUG_RATE(il, "Skipping masked higher rate: %d\n", high); + D_RATE("Skipping masked higher rate: %d\n", high); } return (high << 8) | low; @@ -817,15 +817,15 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, struct il_station_priv *sta_priv = (void *)sta->drv_priv; struct il_rxon_context *ctx = sta_priv->common.ctx; - IL_DEBUG_RATE(il, + D_RATE( "get frame ack response, update rate scale window\n"); /* Treat uninitialized rate scaling data same as non-existing. */ if (!lq_sta) { - IL_DEBUG_RATE(il, "Station rate scaling not created yet.\n"); + D_RATE("Station rate scaling not created yet.\n"); return; } else if (!lq_sta->drv) { - IL_DEBUG_RATE(il, "Rate scaling not initialized yet.\n"); + D_RATE("Rate scaling not initialized yet.\n"); return; } @@ -880,7 +880,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, (!!(tx_rate & RATE_MCS_GF_MSK) != !!(mac_flags & IEEE80211_TX_RC_GREEN_FIELD)) || (rs_index != mac_index)) { - IL_DEBUG_RATE(il, + D_RATE( "initial rate %d does not match %d (0x%x)\n", mac_index, rs_index, tx_rate); /* @@ -910,15 +910,15 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, curr_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); other_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); } else { - IL_DEBUG_RATE(il, + D_RATE( "Neither active nor search matches tx rate\n"); tmp_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - IL_DEBUG_RATE(il, "active- lq:%x, ant:%x, SGI:%d\n", + D_RATE("active- lq:%x, ant:%x, SGI:%d\n", tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); tmp_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); - IL_DEBUG_RATE(il, "search- lq:%x, ant:%x, SGI:%d\n", + D_RATE("search- lq:%x, ant:%x, SGI:%d\n", tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); - IL_DEBUG_RATE(il, "actual- lq:%x, ant:%x, SGI:%d\n", + D_RATE("actual- lq:%x, ant:%x, SGI:%d\n", tbl_type.lq_type, tbl_type.ant_type, tbl_type.is_SGI); /* * no matching table found, let's by-pass the data collection @@ -1004,7 +1004,7 @@ done: static void il4965_rs_set_stay_in_table(struct il_priv *il, u8 is_legacy, struct il_lq_sta *lq_sta) { - IL_DEBUG_RATE(il, "we are staying in the same table\n"); + D_RATE("we are staying in the same table\n"); lq_sta->stay_in_tbl = 1; /* only place this gets set */ if (is_legacy) { lq_sta->table_count_limit = IL_LEGACY_TABLE_COUNT; @@ -1194,7 +1194,7 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *il, if (il->hw_params.tx_chains_num < 2) return -1; - IL_DEBUG_RATE(il, "LQ: try to switch to MIMO2\n"); + D_RATE("LQ: try to switch to MIMO2\n"); tbl->lq_type = LQ_MIMO2; tbl->is_dup = lq_sta->is_dup; @@ -1211,10 +1211,10 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *il, rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, index); - IL_DEBUG_RATE(il, "LQ: MIMO2 best rate %d mask %X\n", + D_RATE("LQ: MIMO2 best rate %d mask %X\n", rate, rate_mask); if ((rate == IL_RATE_INVALID) || !((1 << rate) & rate_mask)) { - IL_DEBUG_RATE(il, + D_RATE( "Can't switch with index %d rate mask %x\n", rate, rate_mask); return -1; @@ -1222,7 +1222,7 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *il, tbl->current_rate = il4965_rate_n_flags_from_tbl(il, tbl, rate, is_green); - IL_DEBUG_RATE(il, "LQ: Switch to new mcs %X index is green %X\n", + D_RATE("LQ: Switch to new mcs %X index is green %X\n", tbl->current_rate, is_green); return 0; } @@ -1245,7 +1245,7 @@ static int il4965_rs_switch_to_siso(struct il_priv *il, if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) return -1; - IL_DEBUG_RATE(il, "LQ: try to switch to SISO\n"); + D_RATE("LQ: try to switch to SISO\n"); tbl->is_dup = lq_sta->is_dup; tbl->lq_type = LQ_SISO; @@ -1264,16 +1264,16 @@ static int il4965_rs_switch_to_siso(struct il_priv *il, il4965_rs_set_expected_tpt_table(lq_sta, tbl); rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, index); - IL_DEBUG_RATE(il, "LQ: get best rate %d mask %X\n", rate, rate_mask); + D_RATE("LQ: get best rate %d mask %X\n", rate, rate_mask); if ((rate == IL_RATE_INVALID) || !((1 << rate) & rate_mask)) { - IL_DEBUG_RATE(il, + D_RATE( "can not switch with index %d rate mask %x\n", rate, rate_mask); return -1; } tbl->current_rate = il4965_rate_n_flags_from_tbl(il, tbl, rate, is_green); - IL_DEBUG_RATE(il, "LQ: Switch to new mcs %X index is green %X\n", + D_RATE("LQ: Switch to new mcs %X index is green %X\n", tbl->current_rate, is_green); return 0; } @@ -1307,7 +1307,7 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, switch (tbl->action) { case IL_LEGACY_SWITCH_ANTENNA1: case IL_LEGACY_SWITCH_ANTENNA2: - IL_DEBUG_RATE(il, "LQ: Legacy toggle Antenna\n"); + D_RATE("LQ: Legacy toggle Antenna\n"); if ((tbl->action == IL_LEGACY_SWITCH_ANTENNA1 && tx_chains_num <= 1) || @@ -1331,7 +1331,7 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, } break; case IL_LEGACY_SWITCH_SISO: - IL_DEBUG_RATE(il, "LQ: Legacy switch to SISO\n"); + D_RATE("LQ: Legacy switch to SISO\n"); /* Set up search table to try SISO */ memcpy(search_tbl, tbl, sz); @@ -1347,7 +1347,7 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, case IL_LEGACY_SWITCH_MIMO2_AB: case IL_LEGACY_SWITCH_MIMO2_AC: case IL_LEGACY_SWITCH_MIMO2_BC: - IL_DEBUG_RATE(il, "LQ: Legacy switch to MIMO2\n"); + D_RATE("LQ: Legacy switch to MIMO2\n"); /* Set up search table to try MIMO */ memcpy(search_tbl, tbl, sz); @@ -1424,7 +1424,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, switch (tbl->action) { case IL_SISO_SWITCH_ANTENNA1: case IL_SISO_SWITCH_ANTENNA2: - IL_DEBUG_RATE(il, "LQ: SISO toggle Antenna\n"); + D_RATE("LQ: SISO toggle Antenna\n"); if ((tbl->action == IL_SISO_SWITCH_ANTENNA1 && tx_chains_num <= 1) || (tbl->action == IL_SISO_SWITCH_ANTENNA2 && @@ -1444,7 +1444,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, case IL_SISO_SWITCH_MIMO2_AB: case IL_SISO_SWITCH_MIMO2_AC: case IL_SISO_SWITCH_MIMO2_BC: - IL_DEBUG_RATE(il, "LQ: SISO switch to MIMO2\n"); + D_RATE("LQ: SISO switch to MIMO2\n"); memcpy(search_tbl, tbl, sz); search_tbl->is_SGI = 0; @@ -1473,7 +1473,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, IEEE80211_HT_CAP_SGI_40)) break; - IL_DEBUG_RATE(il, "LQ: SISO toggle SGI/NGI\n"); + D_RATE("LQ: SISO toggle SGI/NGI\n"); memcpy(search_tbl, tbl, sz); if (is_green) { @@ -1545,7 +1545,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, switch (tbl->action) { case IL_MIMO2_SWITCH_ANTENNA1: case IL_MIMO2_SWITCH_ANTENNA2: - IL_DEBUG_RATE(il, "LQ: MIMO2 toggle Antennas\n"); + D_RATE("LQ: MIMO2 toggle Antennas\n"); if (tx_chains_num <= 2) break; @@ -1563,7 +1563,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, case IL_MIMO2_SWITCH_SISO_A: case IL_MIMO2_SWITCH_SISO_B: case IL_MIMO2_SWITCH_SISO_C: - IL_DEBUG_RATE(il, "LQ: MIMO2 switch to SISO\n"); + D_RATE("LQ: MIMO2 switch to SISO\n"); /* Set up new search table for SISO */ memcpy(search_tbl, tbl, sz); @@ -1595,7 +1595,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, IEEE80211_HT_CAP_SGI_40)) break; - IL_DEBUG_RATE(il, "LQ: MIMO2 toggle SGI/NGI\n"); + D_RATE("LQ: MIMO2 toggle SGI/NGI\n"); /* Set up new search table for MIMO2 */ memcpy(search_tbl, tbl, sz); @@ -1684,7 +1684,7 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) (lq_sta->total_success > lq_sta->max_success_limit) || ((!lq_sta->search_better_tbl) && (lq_sta->flush_timer) && (flush_interval_passed))) { - IL_DEBUG_RATE(il, "LQ: stay is expired %d %d %d\n:", + D_RATE("LQ: stay is expired %d %d %d\n:", lq_sta->total_failed, lq_sta->total_success, flush_interval_passed); @@ -1707,7 +1707,7 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) lq_sta->table_count_limit) { lq_sta->table_count = 0; - IL_DEBUG_RATE(il, + D_RATE( "LQ: stay in table clear win\n"); for (i = 0; i < IL_RATE_COUNT; i++) il4965_rs_rate_scale_clear_window( @@ -1783,7 +1783,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, struct il_station_priv *sta_priv = (void *)sta->drv_priv; struct il_rxon_context *ctx = sta_priv->common.ctx; - IL_DEBUG_RATE(il, "rate scale calculate new rate for skb\n"); + D_RATE("rate scale calculate new rate for skb\n"); /* Send management frames and NO_ACK data using lowest rate. */ /* TODO: this could probably be improved.. */ @@ -1826,13 +1826,13 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* current tx rate */ index = lq_sta->last_txrate_idx; - IL_DEBUG_RATE(il, "Rate scale index %d for type %d\n", index, + D_RATE("Rate scale index %d for type %d\n", index, tbl->lq_type); /* rates available for this association, and for modulation mode */ rate_mask = il4965_rs_get_supported_rates(lq_sta, hdr, tbl->lq_type); - IL_DEBUG_RATE(il, "mask 0x%04X\n", rate_mask); + D_RATE("mask 0x%04X\n", rate_mask); /* mask with station rate restriction */ if (is_legacy(tbl->lq_type)) { @@ -1892,7 +1892,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, fail_count = window->counter - window->success_counter; if ((fail_count < IL_RATE_MIN_FAILURE_TH) && (window->success_counter < IL_RATE_MIN_SUCCESS_TH)) { - IL_DEBUG_RATE(il, "LQ: still below TH. succ=%d total=%d " + D_RATE("LQ: still below TH. succ=%d total=%d " "for index %d\n", window->success_counter, window->counter, index); @@ -1922,7 +1922,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, * continuing to use the setup that we've been trying. */ if (window->average_tpt > lq_sta->last_tpt) { - IL_DEBUG_RATE(il, "LQ: SWITCHING TO NEW TABLE " + D_RATE("LQ: SWITCHING TO NEW TABLE " "suc=%d cur-tpt=%d old-tpt=%d\n", window->success_ratio, window->average_tpt, @@ -1938,7 +1938,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Else poor success; go back to mode in "active" table */ } else { - IL_DEBUG_RATE(il, "LQ: GOING BACK TO THE OLD TABLE " + D_RATE("LQ: GOING BACK TO THE OLD TABLE " "suc=%d cur-tpt=%d old-tpt=%d\n", window->success_ratio, window->average_tpt, @@ -1992,7 +1992,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Too many failures, decrease rate */ if ((sr <= IL_RATE_DECREASE_TH) || (current_tpt == 0)) { - IL_DEBUG_RATE(il, + D_RATE( "decrease rate because of low success_ratio\n"); scale_action = -1; @@ -2031,7 +2031,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, } else if (low_tpt != IL_INVALID_VALUE) { /* Lower rate has better throughput */ if (low_tpt > current_tpt) { - IL_DEBUG_RATE(il, + D_RATE( "decrease rate because of low tpt\n"); scale_action = -1; } else if (sr >= IL_RATE_INCREASE_TH) { @@ -2070,7 +2070,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, break; } - IL_DEBUG_RATE(il, "choose rate scale index %d action %d low %d " + D_RATE("choose rate scale index %d action %d low %d " "high %d type %d\n", index, scale_action, low, high, tbl->lq_type); @@ -2118,7 +2118,7 @@ lq_update: /* Use new "search" start rate */ index = il4965_hwrate_to_plcp_idx(tbl->current_rate); - IL_DEBUG_RATE(il, + D_RATE( "Switch current mcs: %X index: %d\n", tbl->current_rate, index); il4965_rs_fill_link_cmd(il, lq_sta, @@ -2138,7 +2138,7 @@ lq_update: tbl1 = &(lq_sta->lq_info[lq_sta->active_tbl]); if (is_legacy(tbl1->lq_type) && !conf_is_ht(conf) && lq_sta->action_counter > tbl1->max_search) { - IL_DEBUG_RATE(il, "LQ: STAY in legacy table\n"); + D_RATE("LQ: STAY in legacy table\n"); il4965_rs_set_stay_in_table(il, 1, lq_sta); } @@ -2153,7 +2153,7 @@ lq_update: tid_data = &il->stations[lq_sta->lq.sta_id].tid[tid]; if (tid_data->agg.state == IL_AGG_OFF) { - IL_DEBUG_RATE(il, + D_RATE( "try to aggregate tid %d\n", tid); il4965_rs_tl_turn_on_agg(il, tid, @@ -2251,7 +2251,7 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, struct il_lq_sta *lq_sta = il_sta; int rate_idx; - IL_DEBUG_RATE(il, "rate scale calculate new rate for skb\n"); + D_RATE("rate scale calculate new rate for skb\n"); /* Get max rate if user set max rate */ if (lq_sta) { @@ -2266,7 +2266,7 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, /* Treat uninitialized rate scaling data same as non-existing. */ if (lq_sta && !lq_sta->drv) { - IL_DEBUG_RATE(il, "Rate scaling not initialized yet.\n"); + D_RATE("Rate scaling not initialized yet.\n"); il_sta = NULL; } @@ -2323,7 +2323,7 @@ static void *il4965_rs_alloc_sta(void *il_rate, struct ieee80211_sta *sta, struct il_priv *il; il = (struct il_priv *)il_rate; - IL_DEBUG_RATE(il, "create station rate scale window\n"); + D_RATE("create station rate scale window\n"); lq_sta = &sta_priv->lq_sta; @@ -2365,7 +2365,7 @@ il4965_rs_rate_init(struct il_priv *il, il4965_rs_rate_scale_clear_window( &lq_sta->lq_info[j].win[i]); - IL_DEBUG_RATE(il, "LQ:" + D_RATE("LQ:" "*** rate scale station global init for station %d ***\n", sta_id); /* TODO: what is a good starting rate for STA? About middle? Maybe not @@ -2561,8 +2561,8 @@ static void il4965_rs_free_sta(void *il_r, struct ieee80211_sta *sta, { struct il_priv *il __maybe_unused = il_r; - IL_DEBUG_RATE(il, "enter\n"); - IL_DEBUG_RATE(il, "leave\n"); + D_RATE("enter\n"); + D_RATE("leave\n"); } @@ -2587,16 +2587,16 @@ static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, >> RATE_MCS_ANT_POS); if ((valid_tx_ant & ant_sel_tx) == ant_sel_tx) { *rate_n_flags = lq_sta->dbg_fixed_rate; - IL_DEBUG_RATE(il, "Fixed rate ON\n"); + D_RATE("Fixed rate ON\n"); } else { lq_sta->dbg_fixed_rate = 0; IL_ERR(il, "Invalid antenna selection 0x%X, Valid is 0x%X\n", ant_sel_tx, valid_tx_ant); - IL_DEBUG_RATE(il, "Fixed rate OFF\n"); + D_RATE("Fixed rate OFF\n"); } } else { - IL_DEBUG_RATE(il, "Fixed rate OFF\n"); + D_RATE("Fixed rate OFF\n"); } } @@ -2627,7 +2627,7 @@ static ssize_t il4965_rs_sta_dbgfs_scale_table_write(struct file *file, lq_sta->active_siso_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ - IL_DEBUG_RATE(il, "sta_id %d rate 0x%X\n", + D_RATE("sta_id %d rate 0x%X\n", lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate); if (lq_sta->dbg_fixed_rate) { diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c index c987c80a37cf..45e8a24c938d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c @@ -51,7 +51,7 @@ void il4965_rx_missed_beacon_notif(struct il_priv *il, missed_beacon = &pkt->u.missed_beacon; if (le32_to_cpu(missed_beacon->consecutive_missed_beacons) > il->missed_beacon_threshold) { - IL_DEBUG_CALIB(il, + D_CALIB( "missed bcn cnsq %d totl %d rcd %d expctd %d\n", le32_to_cpu(missed_beacon->consecutive_missed_beacons), le32_to_cpu(missed_beacon->total_missed_becons), @@ -100,7 +100,7 @@ static void il4965_rx_calc_noise(struct il_priv *il) else last_rx_noise = IL_NOISE_MEAS_NOT_AVAILABLE; - IL_DEBUG_CALIB(il, "inband silence a %u, b %u, c %u, dBm %d\n", + D_CALIB("inband silence a %u, b %u, c %u, dBm %d\n", bcn_silence_a, bcn_silence_b, bcn_silence_c, last_rx_noise); } @@ -157,7 +157,7 @@ void il4965_rx_statistics(struct il_priv *il, int change; struct il_rx_packet *pkt = rxb_addr(rxb); - IL_DEBUG_RX(il, + D_RX( "Statistics notification received (%d vs %d).\n", (int)sizeof(struct il_notif_statistics), le32_to_cpu(pkt->len_n_flags) & @@ -209,7 +209,7 @@ void il4965_reply_statistics(struct il_priv *il, memset(&il->_4965.max_delta, 0, sizeof(struct il_notif_statistics)); #endif - IL_DEBUG_RX(il, "Statistics have been cleared\n"); + D_RX("Statistics have been cleared\n"); } il4965_rx_statistics(il, rxb); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c index 0fbc991fe66c..3019bafc2352 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c @@ -199,18 +199,18 @@ int il4965_remove_default_wep_key(struct il_priv *il, lockdep_assert_held(&il->mutex); - IL_DEBUG_WEP(il, "Removing default WEP key: idx=%d\n", + D_WEP("Removing default WEP key: idx=%d\n", keyconf->keyidx); memset(&ctx->wep_keys[keyconf->keyidx], 0, sizeof(ctx->wep_keys[0])); if (il_is_rfkill(il)) { - IL_DEBUG_WEP(il, + D_WEP( "Not sending REPLY_WEPKEY command due to RFKILL.\n"); /* but keys in device are clear anyway so return success */ return 0; } ret = il4965_static_wepkey_cmd(il, ctx, 1); - IL_DEBUG_WEP(il, "Remove default WEP key: idx=%d ret=%d\n", + D_WEP("Remove default WEP key: idx=%d ret=%d\n", keyconf->keyidx, ret); return ret; @@ -226,7 +226,7 @@ int il4965_set_default_wep_key(struct il_priv *il, if (keyconf->keylen != WEP_KEY_LEN_128 && keyconf->keylen != WEP_KEY_LEN_64) { - IL_DEBUG_WEP(il, "Bad WEP key length %d\n", keyconf->keylen); + D_WEP("Bad WEP key length %d\n", keyconf->keylen); return -EINVAL; } @@ -239,7 +239,7 @@ int il4965_set_default_wep_key(struct il_priv *il, keyconf->keylen); ret = il4965_static_wepkey_cmd(il, ctx, false); - IL_DEBUG_WEP(il, "Set default WEP key: len=%d idx=%d ret=%d\n", + D_WEP("Set default WEP key: len=%d idx=%d ret=%d\n", keyconf->keylen, keyconf->keyidx, ret); return ret; @@ -453,7 +453,7 @@ int il4965_remove_dynamic_key(struct il_priv *il, key_flags = le16_to_cpu(il->stations[sta_id].sta.key.key_flags); keyidx = (key_flags >> STA_KEY_FLG_KEYID_POS) & 0x3; - IL_DEBUG_WEP(il, "Remove dynamic key: idx=%d sta=%d\n", + D_WEP("Remove dynamic key: idx=%d sta=%d\n", keyconf->keyidx, sta_id); if (keyconf->keyidx != keyidx) { @@ -488,7 +488,7 @@ int il4965_remove_dynamic_key(struct il_priv *il, il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; if (il_is_rfkill(il)) { - IL_DEBUG_WEP(il, + D_WEP( "Not sending REPLY_ADD_STA command because RFKILL enabled.\n"); spin_unlock_irqrestore(&il->sta_lock, flags); return 0; @@ -531,7 +531,7 @@ int il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, ret = -EINVAL; } - IL_DEBUG_WEP(il, + D_WEP( "Set dynamic key: cipher=%x len=%d idx=%d sta=%d ret=%d\n", keyconf->cipher, keyconf->keylen, keyconf->keyidx, sta_id, ret); @@ -605,7 +605,7 @@ static int il4965_update_bcast_station(struct il_priv *il, if (il->stations[sta_id].lq) kfree(il->stations[sta_id].lq); else - IL_DEBUG_INFO(il, + D_INFO( "Bcast station rate scaling has not been initialized yet.\n"); il->stations[sta_id].lq = link_cmd; spin_unlock_irqrestore(&il->sta_lock, flags); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index fcc938e1cf6c..efc21be8a940 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -235,13 +235,13 @@ static void il4965_tx_cmd_build_hwcrypto(struct il_priv *il, memcpy(tx_cmd->key, keyconf->key, keyconf->keylen); if (info->flags & IEEE80211_TX_CTL_AMPDU) tx_cmd->tx_flags |= TX_CMD_FLG_AGG_CCMP_MSK; - IL_DEBUG_TX(il, "tx_cmd with AES hwcrypto\n"); + D_TX("tx_cmd with AES hwcrypto\n"); break; case WLAN_CIPHER_SUITE_TKIP: tx_cmd->sec_ctl = TX_CMD_SEC_TKIP; ieee80211_get_tkip_p2k(keyconf, skb_frag, tx_cmd->key); - IL_DEBUG_TX(il, "tx_cmd with tkip hwcrypto\n"); + D_TX("tx_cmd with tkip hwcrypto\n"); break; case WLAN_CIPHER_SUITE_WEP104: @@ -253,7 +253,7 @@ static void il4965_tx_cmd_build_hwcrypto(struct il_priv *il, memcpy(&tx_cmd->key[3], keyconf->key, keyconf->keylen); - IL_DEBUG_TX(il, "Configuring packet for WEP encryption " + D_TX("Configuring packet for WEP encryption " "with key %d\n", keyconf->keyidx); break; @@ -298,7 +298,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) spin_lock_irqsave(&il->lock, flags); if (il_is_rfkill(il)) { - IL_DEBUG_DROP(il, "Dropping - RF KILL\n"); + D_DROP("Dropping - RF KILL\n"); goto drop_unlock; } @@ -306,11 +306,11 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG if (ieee80211_is_auth(fc)) - IL_DEBUG_TX(il, "Sending AUTH frame\n"); + D_TX("Sending AUTH frame\n"); else if (ieee80211_is_assoc_req(fc)) - IL_DEBUG_TX(il, "Sending ASSOC frame\n"); + D_TX("Sending ASSOC frame\n"); else if (ieee80211_is_reassoc_req(fc)) - IL_DEBUG_TX(il, "Sending REASSOC frame\n"); + D_TX("Sending REASSOC frame\n"); #endif hdr_len = ieee80211_hdrlen(fc); @@ -323,13 +323,13 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) sta_id = il_sta_id_or_broadcast(il, ctx, info->control.sta); if (sta_id == IL_INVALID_STATION) { - IL_DEBUG_DROP(il, "Dropping - INVALID STATION: %pM\n", + D_DROP("Dropping - INVALID STATION: %pM\n", hdr->addr1); goto drop_unlock; } } - IL_DEBUG_TX(il, "station Id %d\n", sta_id); + D_TX("station Id %d\n", sta_id); if (sta) sta_priv = (void *)sta->drv_priv; @@ -499,9 +499,9 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys); tx_cmd->dram_msb_ptr = il_get_dma_hi_addr(scratch_phys); - IL_DEBUG_TX(il, "sequence nr = 0X%x\n", + D_TX("sequence nr = 0X%x\n", le16_to_cpu(out_cmd->hdr.sequence)); - IL_DEBUG_TX(il, "tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); + D_TX("tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd, sizeof(*tx_cmd)); il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd->hdr, hdr_len); @@ -909,11 +909,11 @@ int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, spin_lock_irqsave(&il->sta_lock, flags); tid_data = &il->stations[sta_id].tid[tid]; if (tid_data->tfds_in_queue == 0) { - IL_DEBUG_HT(il, "HW queue is empty\n"); + D_HT("HW queue is empty\n"); tid_data->agg.state = IL_AGG_ON; ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid); } else { - IL_DEBUG_HT(il, + D_HT( "HW queue is NOT empty: %d packets in HW queue\n", tid_data->tfds_in_queue); tid_data->agg.state = IL_EMPTYING_HW_QUEUE_ADDBA; @@ -991,7 +991,7 @@ int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, * queue we selected previously, i.e. before the * session was really started completely. */ - IL_DEBUG_HT(il, "AGG stop before setup done\n"); + D_HT("AGG stop before setup done\n"); goto turn_off; case IL_AGG_ON: break; @@ -1004,14 +1004,14 @@ int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, /* The queue is not empty */ if (write_ptr != read_ptr) { - IL_DEBUG_HT(il, "Stopping a non empty AGG HW QUEUE\n"); + D_HT("Stopping a non empty AGG HW QUEUE\n"); il->stations[sta_id].tid[tid].agg.state = IL_EMPTYING_HW_QUEUE_DELBA; spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } - IL_DEBUG_HT(il, "HW queue is empty\n"); + D_HT("HW queue is empty\n"); turn_off: il->stations[sta_id].tid[tid].agg.state = IL_AGG_OFF; @@ -1054,7 +1054,7 @@ int il4965_txq_check_empty(struct il_priv *il, (q->read_ptr == q->write_ptr)) { u16 ssn = SEQ_TO_SN(tid_data->seq_number); int tx_fifo = il4965_get_fifo_from_tid(ctx, tid); - IL_DEBUG_HT(il, + D_HT( "HW queue empty: continue DELBA flow\n"); il4965_txq_agg_disable(il, txq_id, ssn, tx_fifo); tid_data->agg.state = IL_AGG_OFF; @@ -1064,7 +1064,7 @@ int il4965_txq_check_empty(struct il_priv *il, case IL_EMPTYING_HW_QUEUE_ADDBA: /* We are reclaiming the last packet of the queue */ if (tid_data->tfds_in_queue == 0) { - IL_DEBUG_HT(il, + D_HT( "HW queue empty: continue ADDBA flow\n"); tid_data->agg.state = IL_AGG_ON; ieee80211_start_tx_ba_cb_irqsafe(ctx->vif, addr, tid); @@ -1169,7 +1169,7 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, /* Mark that the expected block-ack response arrived */ agg->wait_for_ba = 0; - IL_DEBUG_TX_REPLY(il, "BA %d %d\n", agg->start_idx, + D_TX_REPLY("BA %d %d\n", agg->start_idx, ba_resp->seq_ctl); /* Calculate shift to align block-ack bits with our Tx window bits */ @@ -1178,7 +1178,7 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, sh += 0x100; if (agg->frame_count > (64 - sh)) { - IL_DEBUG_TX_REPLY(il, "more frames than bitmap size"); + D_TX_REPLY("more frames than bitmap size"); return -1; } @@ -1195,7 +1195,7 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, while (sent_bitmap) { ack = sent_bitmap & 1ULL; successes += ack; - IL_DEBUG_TX_REPLY(il, "%s ON i=%d idx=%d raw=%d\n", + D_TX_REPLY("%s ON i=%d idx=%d raw=%d\n", ack ? "ACK" : "NACK", i, (agg->start_idx + i) & 0xff, agg->start_idx + i); @@ -1203,7 +1203,7 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, ++i; } - IL_DEBUG_TX_REPLY(il, "Bitmap %llx\n", + D_TX_REPLY("Bitmap %llx\n", (unsigned long long)bitmap); info = IEEE80211_SKB_CB(il->txq[scd_flow].txb[agg->start_idx].skb); @@ -1282,7 +1282,7 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, * since it is possible happen very often and in order * not to fill the syslog, don't enable the logging by default */ - IL_DEBUG_TX_REPLY(il, + D_TX_REPLY( "BA scd_flow %d does not match txq_id %d\n", scd_flow, agg->txq_id); return; @@ -1293,12 +1293,12 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, spin_lock_irqsave(&il->sta_lock, flags); - IL_DEBUG_TX_REPLY(il, "REPLY_COMPRESSED_BA [%d] Received from %pM, " + D_TX_REPLY("REPLY_COMPRESSED_BA [%d] Received from %pM, " "sta_id = %d\n", agg->wait_for_ba, (u8 *) &ba_resp->sta_addr_lo32, ba_resp->sta_id); - IL_DEBUG_TX_REPLY(il, "TID = %d, SeqCtl = %d, bitmap = 0x%llx," + D_TX_REPLY("TID = %d, SeqCtl = %d, bitmap = 0x%llx," "scd_flow = " "%d, scd_ssn = %d\n", ba_resp->tid, @@ -1306,7 +1306,7 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, (unsigned long long)le64_to_cpu(ba_resp->bitmap), ba_resp->scd_flow, ba_resp->scd_ssn); - IL_DEBUG_TX_REPLY(il, "DAT start_idx = %d, bitmap = 0x%llx\n", + D_TX_REPLY("DAT start_idx = %d, bitmap = 0x%llx\n", agg->start_idx, (unsigned long long)agg->bitmap); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c index d4dc597452ea..d1e1775aa01b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c @@ -55,7 +55,7 @@ il4965_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) u32 errcnt = 0; u32 i; - IL_DEBUG_INFO(il, "ucode inst image size is %u\n", len); + D_INFO("ucode inst image size is %u\n", len); for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { /* read data comes through single port, auto-incr addr */ @@ -87,7 +87,7 @@ static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, int ret = 0; u32 errcnt; - IL_DEBUG_INFO(il, "ucode inst image size is %u\n", len); + D_INFO("ucode inst image size is %u\n", len); il_write_direct32(il, HBUS_TARG_MEM_RADDR, IWL4965_RTC_INST_LOWER_BOUND); @@ -110,7 +110,7 @@ static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, } if (!errcnt) - IL_DEBUG_INFO(il, + D_INFO( "ucode image in INSTRUCTION memory is good\n"); return ret; @@ -131,7 +131,7 @@ int il4965_verify_ucode(struct il_priv *il) len = il->ucode_boot.len; ret = il4965_verify_inst_sparse(il, image, len); if (!ret) { - IL_DEBUG_INFO(il, "Bootstrap uCode is good in inst SRAM\n"); + D_INFO("Bootstrap uCode is good in inst SRAM\n"); return 0; } @@ -140,7 +140,7 @@ int il4965_verify_ucode(struct il_priv *il) len = il->ucode_init.len; ret = il4965_verify_inst_sparse(il, image, len); if (!ret) { - IL_DEBUG_INFO(il, "Initialize uCode is good in inst SRAM\n"); + D_INFO("Initialize uCode is good in inst SRAM\n"); return 0; } @@ -149,7 +149,7 @@ int il4965_verify_ucode(struct il_priv *il) len = il->ucode_code.len; ret = il4965_verify_inst_sparse(il, image, len); if (!ret) { - IL_DEBUG_INFO(il, "Runtime uCode is good in inst SRAM\n"); + D_INFO("Runtime uCode is good in inst SRAM\n"); return 0; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index 01fa6c8d0304..cc28e0e084e4 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -69,7 +69,7 @@ static int il4965_verify_bsm(struct il_priv *il) u32 reg; u32 val; - IL_DEBUG_INFO(il, "Begin verify bsm\n"); + D_INFO("Begin verify bsm\n"); /* verify BSM SRAM contents */ val = il_read_prph(il, BSM_WR_DWCOUNT_REG); @@ -87,7 +87,7 @@ static int il4965_verify_bsm(struct il_priv *il) } } - IL_DEBUG_INFO(il, "BSM bootstrap uCode image OK\n"); + D_INFO("BSM bootstrap uCode image OK\n"); return 0; } @@ -137,7 +137,7 @@ static int il4965_load_bsm(struct il_priv *il) u32 reg_offset; int ret; - IL_DEBUG_INFO(il, "Begin load bsm\n"); + D_INFO("Begin load bsm\n"); il->ucode_type = UCODE_RT; @@ -189,7 +189,7 @@ static int il4965_load_bsm(struct il_priv *il) udelay(10); } if (i < 100) - IL_DEBUG_INFO(il, "BSM write complete, poll %d iterations\n", i); + D_INFO("BSM write complete, poll %d iterations\n", i); else { IL_ERR(il, "BSM write did not complete!\n"); return -EIO; @@ -233,7 +233,7 @@ static int il4965_set_ucode_ptrs(struct il_priv *il) * that all new ptr/size info is in place */ il_write_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, il->ucode_code.len | BSM_DRAM_INST_LOAD); - IL_DEBUG_INFO(il, "Runtime uCode pointers are set.\n"); + D_INFO("Runtime uCode pointers are set.\n"); return ret; } @@ -257,7 +257,7 @@ static void il4965_init_alive_start(struct il_priv *il) if (il4965_verify_ucode(il)) { /* Runtime instruction load was bad; * take it all the way back down so we can try again */ - IL_DEBUG_INFO(il, "Bad \"initialize\" uCode load.\n"); + D_INFO("Bad \"initialize\" uCode load.\n"); goto restart; } @@ -267,11 +267,11 @@ static void il4965_init_alive_start(struct il_priv *il) /* Send pointers to protocol/runtime uCode image ... init code will * load and launch runtime uCode, which will send us another "Alive" * notification. */ - IL_DEBUG_INFO(il, "Initialization Alive received.\n"); + D_INFO("Initialization Alive received.\n"); if (il4965_set_ucode_ptrs(il)) { /* Runtime instruction load won't happen; * take it all the way back down so we can try again */ - IL_DEBUG_INFO(il, "Couldn't set up uCode pointers.\n"); + D_INFO("Couldn't set up uCode pointers.\n"); goto restart; } return; @@ -346,7 +346,7 @@ static void il4965_chain_noise_reset(struct il_priv *il) IL_ERR(il, "Could not send REPLY_PHY_CALIBRATION_CMD\n"); data->state = IL_CHAIN_NOISE_ACCUMULATE; - IL_DEBUG_CALIB(il, "Run chain_noise_calibrate\n"); + D_CALIB("Run chain_noise_calibrate\n"); } } @@ -556,7 +556,7 @@ static int il4965_interpolate_chan(struct il_priv *il, u32 channel, ch_i2 = il->calib_info->band_info[s].ch2.ch_num; chan_info->ch_num = (u8) channel; - IL_DEBUG_TXPOWER(il, "channel %d subband %d factory cal ch %d & %d\n", + D_TXPOWER("channel %d subband %d factory cal ch %d & %d\n", channel, s, ch_i1, ch_i2); for (c = 0; c < EEPROM_TX_POWER_TX_CHAINS; c++) { @@ -586,16 +586,16 @@ static int il4965_interpolate_chan(struct il_priv *il, u32 channel, m1->pa_det, ch_i2, m2->pa_det); - IL_DEBUG_TXPOWER(il, + D_TXPOWER( "chain %d meas %d AP1=%d AP2=%d AP=%d\n", c, m, m1->actual_pow, m2->actual_pow, omeas->actual_pow); - IL_DEBUG_TXPOWER(il, + D_TXPOWER( "chain %d meas %d NI1=%d NI2=%d NI=%d\n", c, m, m1->gain_idx, m2->gain_idx, omeas->gain_idx); - IL_DEBUG_TXPOWER(il, + D_TXPOWER( "chain %d meas %d PA1=%d PA2=%d PA=%d\n", c, m, m1->pa_det, m2->pa_det, omeas->pa_det); - IL_DEBUG_TXPOWER(il, + D_TXPOWER( "chain %d meas %d T1=%d T2=%d T=%d\n", c, m, m1->temperature, m2->temperature, omeas->temperature); @@ -900,7 +900,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, user_target_power = 2 * il->tx_power_user_lmt; /* Get current (RXON) channel, band, width */ - IL_DEBUG_TXPOWER(il, "chan %d band %d is_ht40 %d\n", channel, band, + D_TXPOWER("chan %d band %d is_ht40 %d\n", channel, band, is_ht40); ch_info = il_get_channel_info(il, il->band, channel); @@ -917,7 +917,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, return txatten_grp; } - IL_DEBUG_TXPOWER(il, "channel %d belongs to txatten group %d\n", + D_TXPOWER("channel %d belongs to txatten group %d\n", channel, txatten_grp); if (is_ht40) { @@ -967,7 +967,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, voltage_compensation = il4965_get_voltage_compensation(voltage, init_voltage); - IL_DEBUG_TXPOWER(il, "curr volt %d eeprom volt %d volt comp %d\n", + D_TXPOWER("curr volt %d eeprom volt %d volt comp %d\n", init_voltage, voltage, voltage_compensation); @@ -998,13 +998,13 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, factory_gain_index[c] = measurement->gain_idx; factory_actual_pwr[c] = measurement->actual_pow; - IL_DEBUG_TXPOWER(il, "chain = %d\n", c); - IL_DEBUG_TXPOWER(il, "fctry tmp %d, " + D_TXPOWER("chain = %d\n", c); + D_TXPOWER("fctry tmp %d, " "curr tmp %d, comp %d steps\n", factory_temp, current_temp, temperature_comp[c]); - IL_DEBUG_TXPOWER(il, "fctry idx %d, fctry pwr %d\n", + D_TXPOWER("fctry idx %d, fctry pwr %d\n", factory_gain_index[c], factory_actual_pwr[c]); } @@ -1037,7 +1037,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, if (target_power > power_limit) target_power = power_limit; - IL_DEBUG_TXPOWER(il, "rate %d sat %d reg %d usr %d tgt %d\n", + D_TXPOWER("rate %d sat %d reg %d usr %d tgt %d\n", i, saturation_power - back_off_table[i], current_regulatory, user_target_power, target_power); @@ -1061,7 +1061,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, voltage_compensation + atten_value); -/* IL_DEBUG_TXPOWER(il, "calculated txpower index %d\n", +/* D_TXPOWER("calculated txpower index %d\n", power_index); */ if (power_index < get_min_power_index(i, band)) @@ -1094,7 +1094,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, tx_power.s.dsp_predis_atten[c] = gain_table[band][power_index].dsp; - IL_DEBUG_TXPOWER(il, "chain %d mimo %d index %d " + D_TXPOWER("chain %d mimo %d index %d " "gain 0x%02x dsp %d\n", c, atten_value, power_index, tx_power.s.radio_tx_gain[c], @@ -1167,7 +1167,7 @@ static int il4965_send_rxon_assoc(struct il_priv *il, rxon2->ofdm_ht_dual_stream_basic_rates) && (rxon1->rx_chain == rxon2->rx_chain) && (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { - IL_DEBUG_INFO(il, "Using current RXON_ASSOC. Not resending.\n"); + D_INFO("Using current RXON_ASSOC. Not resending.\n"); return 0; } @@ -1217,7 +1217,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) */ if (test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status) && (il->switch_channel != ctx->staging.channel)) { - IL_DEBUG_11H(il, "abort channel switch on %d\n", + D_11H("abort channel switch on %d\n", le16_to_cpu(il->switch_channel)); il_chswitch_done(il, false); } @@ -1247,7 +1247,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) * we must clear the associated from the active configuration * before we apply the new config */ if (il_is_associated_ctx(ctx) && new_assoc) { - IL_DEBUG_INFO(il, "Toggling associated bit on current RXON\n"); + D_INFO("Toggling associated bit on current RXON\n"); active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; ret = il_send_cmd_pdu(il, ctx->rxon_cmd, @@ -1270,7 +1270,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) } } - IL_DEBUG_INFO(il, "Sending RXON\n" + D_INFO("Sending RXON\n" "* with%s RXON_FILTER_ASSOC_MSK\n" "* channel = %d\n" "* bssid = %pM\n", @@ -1292,7 +1292,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) IL_ERR(il, "Error setting new RXON (%d)\n", ret); return ret; } - IL_DEBUG_INFO(il, "Return from !new_assoc RXON.\n"); + D_INFO("Return from !new_assoc RXON.\n"); memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); il_clear_ucode_stations(il, ctx); il_restore_stations(il, ctx); @@ -1387,7 +1387,7 @@ static int il4965_hw_channel_switch(struct il_priv *il, ucode_switch_time, beacon_interval); } - IL_DEBUG_11H(il, "uCode time for the switch is 0x%x\n", + D_11H("uCode time for the switch is 0x%x\n", cmd.switch_time); ch_info = il_get_channel_info(il, il->band, ch); if (ch_info) @@ -1401,7 +1401,7 @@ static int il4965_hw_channel_switch(struct il_priv *il, rc = il4965_fill_txpower_tbl(il, band, ch, is_ht40, ctrl_chan_high, &cmd.tx_power); if (rc) { - IL_DEBUG_11H(il, "error:%d fill txpower_tbl\n", rc); + D_11H("error:%d fill txpower_tbl\n", rc); return rc; } @@ -1450,13 +1450,13 @@ static int il4965_hw_get_temperature(struct il_priv *il) if (test_bit(STATUS_TEMPERATURE, &il->status) && (il->_4965.statistics.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK)) { - IL_DEBUG_TEMP(il, "Running HT40 temperature calibration\n"); + D_TEMP("Running HT40 temperature calibration\n"); R1 = (s32)le32_to_cpu(il->card_alive_init.therm_r1[1]); R2 = (s32)le32_to_cpu(il->card_alive_init.therm_r2[1]); R3 = (s32)le32_to_cpu(il->card_alive_init.therm_r3[1]); R4 = le32_to_cpu(il->card_alive_init.therm_r4[1]); } else { - IL_DEBUG_TEMP(il, "Running temperature calibration\n"); + D_TEMP("Running temperature calibration\n"); R1 = (s32)le32_to_cpu(il->card_alive_init.therm_r1[0]); R2 = (s32)le32_to_cpu(il->card_alive_init.therm_r2[0]); R3 = (s32)le32_to_cpu(il->card_alive_init.therm_r3[0]); @@ -1476,7 +1476,7 @@ static int il4965_hw_get_temperature(struct il_priv *il) vt = sign_extend32(le32_to_cpu(il->_4965.statistics. general.common.temperature), 23); - IL_DEBUG_TEMP(il, "Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt); + D_TEMP("Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt); if (R3 == R1) { IL_ERR(il, "Calibration conflict R1 == R3\n"); @@ -1489,7 +1489,7 @@ static int il4965_hw_get_temperature(struct il_priv *il) temperature /= (R3 - R1); temperature = (temperature * 97) / 100 + TEMPERATURE_CALIB_KELVIN_OFFSET; - IL_DEBUG_TEMP(il, "Calibrated temperature: %dK, %dC\n", + D_TEMP("Calibrated temperature: %dK, %dC\n", temperature, KELVIN_TO_CELSIUS(temperature)); return temperature; @@ -1512,7 +1512,7 @@ static int il4965_is_temp_calib_needed(struct il_priv *il) int temp_diff; if (!test_bit(STATUS_STATISTICS, &il->status)) { - IL_DEBUG_TEMP(il, "Temperature not updated -- no statistics.\n"); + D_TEMP("Temperature not updated -- no statistics.\n"); return 0; } @@ -1520,19 +1520,19 @@ static int il4965_is_temp_calib_needed(struct il_priv *il) /* get absolute value */ if (temp_diff < 0) { - IL_DEBUG_POWER(il, "Getting cooler, delta %d\n", temp_diff); + D_POWER("Getting cooler, delta %d\n", temp_diff); temp_diff = -temp_diff; } else if (temp_diff == 0) - IL_DEBUG_POWER(il, "Temperature unchanged\n"); + D_POWER("Temperature unchanged\n"); else - IL_DEBUG_POWER(il, "Getting warmer, delta %d\n", temp_diff); + D_POWER("Getting warmer, delta %d\n", temp_diff); if (temp_diff < IL_TEMPERATURE_THRESHOLD) { - IL_DEBUG_POWER(il, " => thermal txpower calib not needed\n"); + D_POWER(" => thermal txpower calib not needed\n"); return 0; } - IL_DEBUG_POWER(il, " => thermal txpower calib needed\n"); + D_POWER(" => thermal txpower calib needed\n"); return 1; } @@ -1547,12 +1547,12 @@ static void il4965_temperature_calib(struct il_priv *il) if (il->temperature != temp) { if (il->temperature) - IL_DEBUG_TEMP(il, "Temperature changed " + D_TEMP("Temperature changed " "from %dC to %dC\n", KELVIN_TO_CELSIUS(il->temperature), KELVIN_TO_CELSIUS(temp)); else - IL_DEBUG_TEMP(il, "Temperature " + D_TEMP("Temperature " "initialized to %dC\n", KELVIN_TO_CELSIUS(temp)); } @@ -1617,7 +1617,7 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, int i, sh, idx; u16 seq; if (agg->wait_for_ba) - IL_DEBUG_TX_REPLY(il, "got tx response w/o block-ack\n"); + D_TX_REPLY("got tx response w/o block-ack\n"); agg->frame_count = tx_resp->frame_count; agg->start_idx = start_idx; @@ -1630,7 +1630,7 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, status = le16_to_cpu(frame_status[0].status); idx = start_idx; - IL_DEBUG_TX_REPLY(il, "FrameCnt = %d, StartIdx=%d idx=%d\n", + D_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n", agg->frame_count, agg->start_idx, idx); info = IEEE80211_SKB_CB(il->txq[txq_id].txb[idx].skb); @@ -1639,9 +1639,9 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, info->flags |= il4965_tx_status_to_mac80211(status); il4965_hwrate_to_tx_control(il, rate_n_flags, info); - IL_DEBUG_TX_REPLY(il, "1 Frame 0x%x failure :%d\n", + D_TX_REPLY("1 Frame 0x%x failure :%d\n", status & 0xff, tx_resp->failure_frame); - IL_DEBUG_TX_REPLY(il, "Rate Info rate_n_flags=%x\n", rate_n_flags); + D_TX_REPLY("Rate Info rate_n_flags=%x\n", rate_n_flags); agg->wait_for_ba = 0; } else { @@ -1661,7 +1661,7 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, AGG_TX_STATE_ABORT_MSK)) continue; - IL_DEBUG_TX_REPLY(il, "FrameCnt = %d, txq_id=%d idx=%d\n", + D_TX_REPLY("FrameCnt = %d, txq_id=%d idx=%d\n", agg->frame_count, txq_id, idx); hdr = il_tx_queue_get_hdr(il, txq_id, idx); @@ -1681,7 +1681,7 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, return -1; } - IL_DEBUG_TX_REPLY(il, "AGG Frame i=%d idx %d seq=%d\n", + D_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n", i, idx, SEQ_TO_SN(sc)); sh = idx - start; @@ -1699,13 +1699,13 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, sh = 0; } bitmap |= 1ULL << sh; - IL_DEBUG_TX_REPLY(il, "start=%d bitmap=0x%llx\n", + D_TX_REPLY("start=%d bitmap=0x%llx\n", start, (unsigned long long)bitmap); } agg->bitmap = bitmap; agg->start_idx = start; - IL_DEBUG_TX_REPLY(il, "Frames %d start_idx=%d bitmap=0x%llx\n", + D_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n", agg->frame_count, agg->start_idx, (unsigned long long)agg->bitmap); @@ -1737,7 +1737,7 @@ static u8 il4965_find_station(struct il_priv *il, const u8 *addr) goto out; } - IL_DEBUG_ASSOC(il, "can not find STA %pM total %d\n", + D_ASSOC("can not find STA %pM total %d\n", addr, il->num_stations); out: @@ -1830,7 +1830,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, if (txq->q.read_ptr != (scd_ssn & 0xff)) { index = il_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); - IL_DEBUG_TX_REPLY(il, "Retry scheduler reclaim scd_ssn " + D_TX_REPLY("Retry scheduler reclaim scd_ssn " "%d index %d\n", scd_ssn , index); freed = il4965_tx_queue_reclaim(il, txq_id, index); if (qc) @@ -1849,7 +1849,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, le32_to_cpu(tx_resp->rate_n_flags), info); - IL_DEBUG_TX_REPLY(il, "TXQ %d status %s (0x%08x) " + D_TX_REPLY("TXQ %d status %s (0x%08x) " "rate_n_flags 0x%x retries %d\n", txq_id, il4965_get_tx_fail_reason(status), status, @@ -1860,7 +1860,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, if (qc && likely(sta_id != IL_INVALID_STATION)) il4965_free_tfds_in_queue(il, sta_id, tid, freed); else if (sta_id == IL_INVALID_STATION) - IL_DEBUG_TX_REPLY(il, "Station not known\n"); + D_TX_REPLY("Station not known\n"); if (il->mac80211_registered && (il_queue_space(&txq->q) > txq->q.low_mark)) @@ -1882,7 +1882,7 @@ static void il4965_rx_beacon_notif(struct il_priv *il, u8 rate __maybe_unused = il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); - IL_DEBUG_RX(il, "beacon status %#x, retries:%d ibssmgr:%d " + D_RX("beacon status %#x, retries:%d ibssmgr:%d " "tsf:0x%.8x%.8x rate:%d\n", le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, beacon->beacon_notify_hdr.failure_frame, @@ -1955,7 +1955,7 @@ static void il4965_post_associate(struct il_priv *il) ctx->staging.assoc_id = cpu_to_le16(vif->bss_conf.aid); - IL_DEBUG_ASSOC(il, "assoc id %d beacon interval %d\n", + D_ASSOC("assoc id %d beacon interval %d\n", vif->bss_conf.aid, vif->bss_conf.beacon_int); if (vif->bss_conf.use_short_preamble) @@ -1972,7 +1972,7 @@ static void il4965_post_associate(struct il_priv *il) il_commit_rxon(il, ctx); - IL_DEBUG_ASSOC(il, "Associated as %d to: %pM\n", + D_ASSOC("Associated as %d to: %pM\n", vif->bss_conf.aid, ctx->active.bssid_addr); switch (vif->type) { diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index a768e78bf897..e6c7e9d87a61 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -164,7 +164,7 @@ int il_init_geos(struct il_priv *il) if (il->bands[IEEE80211_BAND_2GHZ].n_bitrates || il->bands[IEEE80211_BAND_5GHZ].n_bitrates) { - IL_DEBUG_INFO(il, "Geography modes already initialized.\n"); + D_INFO("Geography modes already initialized.\n"); set_bit(STATUS_GEO_CONFIGURED, &il->status); return 0; } @@ -239,7 +239,7 @@ int il_init_geos(struct il_priv *il) geo_ch->flags |= IEEE80211_CHAN_DISABLED; } - IL_DEBUG_INFO(il, "Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", + D_INFO("Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", ch->channel, geo_ch->center_freq, il_is_channel_a_band(ch) ? "5.2" : "2.4", geo_ch->flags & IEEE80211_CHAN_DISABLED ? @@ -396,7 +396,7 @@ il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx) ctx->timing.dtim_period = vif ? (vif->bss_conf.dtim_period ?: 1) : 1; - IL_DEBUG_ASSOC(il, + D_ASSOC( "beacon interval %d beacon timer %d beacon tim %d\n", le16_to_cpu(ctx->timing.beacon_interval), le32_to_cpu(ctx->timing.beacon_init_val), @@ -512,13 +512,13 @@ int il_full_rxon_required(struct il_priv *il, #define CHK(cond) \ if ((cond)) { \ - IL_DEBUG_INFO(il, "need full RXON - " #cond "\n"); \ + D_INFO("need full RXON - " #cond "\n"); \ return 1; \ } #define CHK_NEQ(c1, c2) \ if ((c1) != (c2)) { \ - IL_DEBUG_INFO(il, "need full RXON - " \ + D_INFO("need full RXON - " \ #c1 " != " #c2 " - %d != %d\n", \ (c1), (c2)); \ return 1; \ @@ -638,7 +638,7 @@ static void _il_set_rxon_ht(struct il_priv *il, if (il->cfg->ops->hcmd->set_rxon_chain) il->cfg->ops->hcmd->set_rxon_chain(il, ctx); - IL_DEBUG_ASSOC(il, "rxon flags 0x%X operation mode :0x%X " + D_ASSOC("rxon flags 0x%X operation mode :0x%X " "extension channel offset 0x%x\n", le32_to_cpu(rxon->flags), ctx->ht.protection, ctx->ht.extension_chan_offset); @@ -720,7 +720,7 @@ il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch, il->band = band; - IL_DEBUG_INFO(il, "Staging channel set to %d [%d]\n", channel, band); + D_INFO("Staging channel set to %d [%d]\n", channel, band); return 0; } @@ -840,7 +840,7 @@ void il_set_rate(struct il_priv *il) il->active_rate |= (1 << rate->hw_value); } - IL_DEBUG_RATE(il, "Set active_rate = %0x\n", il->active_rate); + D_RATE("Set active_rate = %0x\n", il->active_rate); for_each_context(il, ctx) { ctx->staging.cck_basic_rates = @@ -878,7 +878,7 @@ void il_rx_csa(struct il_priv *il, struct il_rx_mem_buffer *rxb) if (!le32_to_cpu(csa->status) && csa->channel == il->switch_channel) { rxon->channel = csa->channel; ctx->staging.channel = csa->channel; - IL_DEBUG_11H(il, "CSA notif: channel %d\n", + D_11H("CSA notif: channel %d\n", le16_to_cpu(csa->channel)); il_chswitch_done(il, true); } else { @@ -895,21 +895,21 @@ void il_print_rx_config_cmd(struct il_priv *il, { struct il_rxon_cmd *rxon = &ctx->staging; - IL_DEBUG_RADIO(il, "RX CONFIG:\n"); + D_RADIO("RX CONFIG:\n"); il_print_hex_dump(il, IL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); - IL_DEBUG_RADIO(il, "u16 channel: 0x%x\n", + D_RADIO("u16 channel: 0x%x\n", le16_to_cpu(rxon->channel)); - IL_DEBUG_RADIO(il, "u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags)); - IL_DEBUG_RADIO(il, "u32 filter_flags: 0x%08x\n", + D_RADIO("u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags)); + D_RADIO("u32 filter_flags: 0x%08x\n", le32_to_cpu(rxon->filter_flags)); - IL_DEBUG_RADIO(il, "u8 dev_type: 0x%x\n", rxon->dev_type); - IL_DEBUG_RADIO(il, "u8 ofdm_basic_rates: 0x%02x\n", + D_RADIO("u8 dev_type: 0x%x\n", rxon->dev_type); + D_RADIO("u8 ofdm_basic_rates: 0x%02x\n", rxon->ofdm_basic_rates); - IL_DEBUG_RADIO(il, "u8 cck_basic_rates: 0x%02x\n", + D_RADIO("u8 cck_basic_rates: 0x%02x\n", rxon->cck_basic_rates); - IL_DEBUG_RADIO(il, "u8[6] node_addr: %pM\n", rxon->node_addr); - IL_DEBUG_RADIO(il, "u8[6] bssid_addr: %pM\n", rxon->bssid_addr); - IL_DEBUG_RADIO(il, "u16 assoc_id: 0x%x\n", + D_RADIO("u8[6] node_addr: %pM\n", rxon->node_addr); + D_RADIO("u8[6] bssid_addr: %pM\n", rxon->bssid_addr); + D_RADIO("u16 assoc_id: 0x%x\n", le16_to_cpu(rxon->assoc_id)); } EXPORT_SYMBOL(il_print_rx_config_cmd); @@ -944,7 +944,7 @@ void il_irq_handle_error(struct il_priv *il) clear_bit(STATUS_READY, &il->status); if (!test_bit(STATUS_EXIT_PENDING, &il->status)) { - IL_DEBUG(il, IL_DL_FW_ERRORS, + IL_DBG(IL_DL_FW_ERRORS, "Restarting adapter due to uCode error.\n"); if (il->cfg->mod_params->restart_fw) @@ -965,14 +965,14 @@ static int il_apm_stop_master(struct il_priv *il) if (ret) IL_WARN(il, "Master Disable Timed Out, 100 usec\n"); - IL_DEBUG_INFO(il, "stop master\n"); + D_INFO("stop master\n"); return ret; } void il_apm_stop(struct il_priv *il) { - IL_DEBUG_INFO(il, "Stop card, put in low power state\n"); + D_INFO("Stop card, put in low power state\n"); /* Stop device's DMA activity */ il_apm_stop_master(il); @@ -1002,7 +1002,7 @@ int il_apm_init(struct il_priv *il) int ret = 0; u16 lctl; - IL_DEBUG_INFO(il, "Init card's basic functions\n"); + D_INFO("Init card's basic functions\n"); /* * Use "set_bit" below rather than "write", to preserve any hardware @@ -1047,12 +1047,12 @@ int il_apm_init(struct il_priv *il) /* L1-ASPM enabled; disable(!) L0S */ il_set_bit(il, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); - IL_DEBUG_POWER(il, "L1 Enabled; Disabling L0S\n"); + D_POWER("L1 Enabled; Disabling L0S\n"); } else { /* L1-ASPM disabled; enable(!) L0S */ il_clear_bit(il, CSR_GIO_REG, CSR_GIO_REG_VAL_L0S_ENABLED); - IL_DEBUG_POWER(il, "L1 Disabled; Enabling L0S\n"); + D_POWER("L1 Disabled; Enabling L0S\n"); } } @@ -1076,7 +1076,7 @@ int il_apm_init(struct il_priv *il) CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); if (ret < 0) { - IL_DEBUG_INFO(il, "Failed to init the card\n"); + D_INFO("Failed to init the card\n"); goto out; } @@ -1147,7 +1147,7 @@ int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) defer = test_bit(STATUS_SCANNING, &il->status) || memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging)); if (defer && !force) { - IL_DEBUG_INFO(il, "Deferring tx power set\n"); + D_INFO("Deferring tx power set\n"); return 0; } @@ -1179,7 +1179,7 @@ void il_send_bt_config(struct il_priv *il) else bt_cmd.flags = BT_COEX_ENABLE; - IL_DEBUG_INFO(il, "BT coex %s\n", + D_INFO("BT coex %s\n", (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active"); if (il_send_cmd_pdu(il, REPLY_BT_CONFIG, @@ -1212,7 +1212,7 @@ void il_rx_pm_sleep_notif(struct il_priv *il, #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG struct il_rx_packet *pkt = rxb_addr(rxb); struct il_sleep_notification *sleep = &(pkt->u.sleep_notif); - IL_DEBUG_RX(il, "sleep mode: %d, src: %d\n", + D_RX("sleep mode: %d, src: %d\n", sleep->pm_sleep_mode, sleep->pm_wakeup_src); #endif } @@ -1223,7 +1223,7 @@ void il_rx_pm_debug_statistics_notif(struct il_priv *il, { struct il_rx_packet *pkt = rxb_addr(rxb); u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; - IL_DEBUG_RADIO(il, "Dumping %d bytes of unhandled " + D_RADIO("Dumping %d bytes of unhandled " "notification for %s:\n", len, il_get_cmd_string(pkt->hdr.cmd)); il_print_hex_dump(il, IL_DL_RADIO, pkt->u.raw, len); @@ -1259,15 +1259,15 @@ int il_mac_conf_tx(struct ieee80211_hw *hw, unsigned long flags; int q; - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); if (!il_is_ready_rf(il)) { - IL_DEBUG_MAC80211(il, "leave - RF not ready\n"); + D_MAC80211("leave - RF not ready\n"); return -EIO; } if (queue >= AC_NUM) { - IL_DEBUG_MAC80211(il, "leave - queue >= AC_NUM %d\n", queue); + D_MAC80211("leave - queue >= AC_NUM %d\n", queue); return 0; } @@ -1289,7 +1289,7 @@ int il_mac_conf_tx(struct ieee80211_hw *hw, spin_unlock_irqrestore(&il->lock, flags); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); return 0; } EXPORT_SYMBOL(il_mac_conf_tx); @@ -1348,7 +1348,7 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) struct il_rxon_context *tmp, *ctx = NULL; int err; - IL_DEBUG_MAC80211(il, "enter: type %d, addr %pM\n", + D_MAC80211("enter: type %d, addr %pM\n", vif->type, vif->addr); mutex_lock(&il->mutex); @@ -1398,7 +1398,7 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) out: mutex_unlock(&il->mutex); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); return err; } EXPORT_SYMBOL(il_mac_add_interface); @@ -1429,7 +1429,7 @@ void il_mac_remove_interface(struct ieee80211_hw *hw, struct il_priv *il = hw->priv; struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); mutex_lock(&il->mutex); @@ -1441,7 +1441,7 @@ void il_mac_remove_interface(struct ieee80211_hw *hw, memset(il->bssid, 0, ETH_ALEN); mutex_unlock(&il->mutex); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); } EXPORT_SYMBOL(il_mac_remove_interface); @@ -1720,7 +1720,7 @@ int il_force_reset(struct il_priv *il, bool external) if (force_reset->last_force_reset_jiffies && time_after(force_reset->last_force_reset_jiffies + force_reset->reset_duration, jiffies)) { - IL_DEBUG_INFO(il, "force reset rejected\n"); + D_INFO("force reset rejected\n"); force_reset->reset_reject_count++; return -EAGAIN; } @@ -1738,7 +1738,7 @@ int il_force_reset(struct il_priv *il, bool external) */ if (!external && !il->cfg->mod_params->restart_fw) { - IL_DEBUG_INFO(il, "Cancel firmware reload based on " + D_INFO("Cancel firmware reload based on " "module parameter setting\n"); return 0; } @@ -2046,7 +2046,7 @@ il_update_qos(struct il_priv *il, struct il_rxon_context *ctx) if (ctx->ht.enabled) ctx->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; - IL_DEBUG_QOS(il, "send QoS cmd with Qos active=%d FLAGS=0x%X\n", + D_QOS("send QoS cmd with Qos active=%d FLAGS=0x%X\n", ctx->qos_data.qos_active, ctx->qos_data.def_qos_parm.qos_flags); @@ -2077,12 +2077,12 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) mutex_lock(&il->mutex); - IL_DEBUG_MAC80211(il, "enter to channel %d changed 0x%X\n", + D_MAC80211("enter to channel %d changed 0x%X\n", channel->hw_value, changed); if (unlikely(test_bit(STATUS_SCANNING, &il->status))) { scan_active = 1; - IL_DEBUG_MAC80211(il, "scan active\n"); + D_MAC80211("scan active\n"); } if (changed & (IEEE80211_CONF_CHANGE_SMPS | @@ -2112,14 +2112,14 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) ch = channel->hw_value; ch_info = il_get_channel_info(il, channel->band, ch); if (!il_is_channel_valid(ch_info)) { - IL_DEBUG_MAC80211(il, "leave - invalid channel\n"); + D_MAC80211("leave - invalid channel\n"); ret = -EINVAL; goto set_ch_out; } if (il->iw_mode == NL80211_IFTYPE_ADHOC && !il_is_channel_ibss(ch_info)) { - IL_DEBUG_MAC80211(il, "leave - not IBSS channel\n"); + D_MAC80211("leave - not IBSS channel\n"); ret = -EINVAL; goto set_ch_out; } @@ -2186,18 +2186,18 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) IEEE80211_CONF_CHANGE_IDLE)) { ret = il_power_update_mode(il, false); if (ret) - IL_DEBUG_MAC80211(il, "Error setting sleep level\n"); + D_MAC80211("Error setting sleep level\n"); } if (changed & IEEE80211_CONF_CHANGE_POWER) { - IL_DEBUG_MAC80211(il, "TX Power old=%d new=%d\n", + D_MAC80211("TX Power old=%d new=%d\n", il->tx_power_user_lmt, conf->power_level); il_set_tx_power(il, conf->power_level, false); } if (!il_is_ready(il)) { - IL_DEBUG_MAC80211(il, "leave - not ready\n"); + D_MAC80211("leave - not ready\n"); goto out; } @@ -2208,14 +2208,14 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) if (memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging))) il_commit_rxon(il, ctx); else - IL_DEBUG_INFO(il, + D_INFO( "Not re-sending same RXON configuration.\n"); if (ht_changed[ctx->ctxid]) il_update_qos(il, ctx); } out: - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); mutex_unlock(&il->mutex); return ret; } @@ -2233,7 +2233,7 @@ void il_mac_reset_tsf(struct ieee80211_hw *hw, return; mutex_lock(&il->mutex); - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); spin_lock_irqsave(&il->lock, flags); memset(&il->current_ht_config, 0, sizeof(struct il_ht_config)); @@ -2253,7 +2253,7 @@ void il_mac_reset_tsf(struct ieee80211_hw *hw, il_scan_cancel_timeout(il, 100); if (!il_is_ready_rf(il)) { - IL_DEBUG_MAC80211(il, "leave - not ready\n"); + D_MAC80211("leave - not ready\n"); mutex_unlock(&il->mutex); return; } @@ -2268,7 +2268,7 @@ void il_mac_reset_tsf(struct ieee80211_hw *hw, mutex_unlock(&il->mutex); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); } EXPORT_SYMBOL(il_mac_reset_tsf); @@ -2280,7 +2280,7 @@ static void il_ht_conf(struct il_priv *il, struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - IL_DEBUG_ASSOC(il, "enter:\n"); + D_ASSOC("enter:\n"); if (!ctx->ht.enabled) return; @@ -2329,7 +2329,7 @@ static void il_ht_conf(struct il_priv *il, break; } - IL_DEBUG_ASSOC(il, "leave\n"); + D_ASSOC("leave\n"); } static inline void il_set_no_assoc(struct il_priv *il, @@ -2358,7 +2358,7 @@ static void il_beacon_update(struct ieee80211_hw *hw, if (!skb) return; - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); lockdep_assert_held(&il->mutex); @@ -2378,11 +2378,11 @@ static void il_beacon_update(struct ieee80211_hw *hw, timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp; il->timestamp = le64_to_cpu(timestamp); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); spin_unlock_irqrestore(&il->lock, flags); if (!il_is_ready_rf(il)) { - IL_DEBUG_MAC80211(il, "leave - RF not ready\n"); + D_MAC80211("leave - RF not ready\n"); return; } @@ -2401,7 +2401,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, if (WARN_ON(!il->cfg->ops->legacy)) return; - IL_DEBUG_MAC80211(il, "changes = 0x%X\n", changes); + D_MAC80211("changes = 0x%X\n", changes); mutex_lock(&il->mutex); @@ -2432,7 +2432,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, } if (changes & BSS_CHANGED_BSSID) { - IL_DEBUG_MAC80211(il, "BSSID %pM\n", bss_conf->bssid); + D_MAC80211("BSSID %pM\n", bss_conf->bssid); /* * If there is currently a HW scan going on in the @@ -2442,7 +2442,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, if (il_scan_cancel_timeout(il, 100)) { IL_WARN(il, "Aborted scan still in progress after 100ms\n"); - IL_DEBUG_MAC80211(il, + D_MAC80211( "leaving - scan abort failed.\n"); mutex_unlock(&il->mutex); return; @@ -2471,7 +2471,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, il_beacon_update(hw, vif); if (changes & BSS_CHANGED_ERP_PREAMBLE) { - IL_DEBUG_MAC80211(il, "ERP_PREAMBLE %d\n", + D_MAC80211("ERP_PREAMBLE %d\n", bss_conf->use_short_preamble); if (bss_conf->use_short_preamble) ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; @@ -2480,7 +2480,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, } if (changes & BSS_CHANGED_ERP_CTS_PROT) { - IL_DEBUG_MAC80211(il, + D_MAC80211( "ERP_CTS %d\n", bss_conf->use_cts_prot); if (bss_conf->use_cts_prot && (il->band != IEEE80211_BAND_5GHZ)) @@ -2518,7 +2518,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, } if (changes & BSS_CHANGED_ASSOC) { - IL_DEBUG_MAC80211(il, "ASSOC %d\n", bss_conf->assoc); + D_MAC80211("ASSOC %d\n", bss_conf->assoc); if (bss_conf->assoc) { il->timestamp = bss_conf->timestamp; @@ -2529,7 +2529,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, } if (changes && il_is_associated_ctx(ctx) && bss_conf->aid) { - IL_DEBUG_MAC80211(il, "Changes (%#x) while associated\n", + D_MAC80211("Changes (%#x) while associated\n", changes); ret = il_send_rxon_assoc(il, ctx); if (!ret) { @@ -2561,7 +2561,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, mutex_unlock(&il->mutex); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); } EXPORT_SYMBOL(il_mac_bss_info_changed); @@ -2591,7 +2591,7 @@ irqreturn_t il_isr(int irq, void *data) * This may be due to IRQ shared with another device, * or due to sporadic interrupts thrown from our NIC. */ if (!inta && !inta_fh) { - IL_DEBUG_ISR(il, + D_ISR( "Ignore interrupt, inta == 0, inta_fh == 0\n"); goto none; } @@ -2603,7 +2603,7 @@ irqreturn_t il_isr(int irq, void *data) goto unplugged; } - IL_DEBUG_ISR(il, "ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", + D_ISR("ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, inta_mask, inta_fh); inta &= ~CSR_INT_BIT_SCD; diff --git a/drivers/net/wireless/iwlegacy/iwl-debug.h b/drivers/net/wireless/iwlegacy/iwl-debug.h index c6dcbf3a2ffc..2c5c42fa4bb6 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debug.h +++ b/drivers/net/wireless/iwlegacy/iwl-debug.h @@ -37,17 +37,17 @@ extern u32 il_debug_level; #define IL_INFO(p, f, a...) dev_info(&((p)->pci_dev->dev), f, ## a) #define IL_CRIT(p, f, a...) dev_crit(&((p)->pci_dev->dev), f, ## a) -#define il_print_hex_error(il, p, len) \ +#define il_print_hex_error(il, p, len) \ do { \ print_hex_dump(KERN_ERR, "iwl data: ", \ DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ } while (0) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG -#define IL_DEBUG(__priv, level, fmt, args...) \ +#define IL_DBG(level, fmt, args...) \ do { \ - if (il_get_debug_level(__priv) & (level)) \ - dev_printk(KERN_ERR, &(__priv->hw->wiphy->dev), \ + if (il_get_debug_level(il) & level) \ + dev_printk(KERN_ERR, &il->hw->wiphy->dev, \ "%c %s " fmt, in_interrupt() ? 'I' : 'U', \ __func__ , ## args); \ } while (0) @@ -60,7 +60,7 @@ do { \ } while (0) #else -#define IL_DEBUG(__priv, level, fmt, args...) +#define IL_DBG(level, fmt, args...) static inline void il_print_hex_dump(struct il_priv *il, int level, const void *p, u32 len) {} @@ -91,12 +91,12 @@ static inline void il_dbgfs_unregister(struct il_priv *il) * where xxxx should be the name of the classification (for example, WEP). * * You then need to either add a IL_xxxx_DEBUG() macro definition for your - * classification, or use IL_DEBUG(IL_DL_xxxx, ...) whenever you want + * classification, or use IL_DBG(IL_DL_xxxx, ...) whenever you want * to send output to that classification. * * The active debug levels can be accessed via files * - * /sys/module/iwl4965/parameters/debug{50} + * /sys/module/iwl4965/parameters/debug * /sys/module/iwl3945/parameters/debug * /sys/class/net/wlan0/device/debug_level * @@ -110,7 +110,7 @@ static inline void il_dbgfs_unregister(struct il_priv *il) #define IL_DL_STATE (1 << 3) /* 0x000000F0 - 0x00000010 */ #define IL_DL_MACDUMP (1 << 4) -#define IL_DL_HCMD_DUMP (1 << 5) +#define IL_DL_HCMD_DUMP (1 << 5) #define IL_DL_EEPROM (1 << 6) #define IL_DL_RADIO (1 << 7) /* 0x00000F00 - 0x00000100 */ @@ -126,7 +126,7 @@ static inline void il_dbgfs_unregister(struct il_priv *il) /* 0x000F0000 - 0x00010000 */ #define IL_DL_FW (1 << 16) #define IL_DL_RF_KILL (1 << 17) -#define IL_DL_FW_ERRORS (1 << 18) +#define IL_DL_FW_ERRORS (1 << 18) #define IL_DL_LED (1 << 19) /* 0x00F00000 - 0x00100000 */ #define IL_DL_RATE (1 << 20) @@ -143,34 +143,34 @@ static inline void il_dbgfs_unregister(struct il_priv *il) #define IL_DL_TX_REPLY (1 << 30) #define IL_DL_QOS (1 << 31) -#define IL_DEBUG_INFO(p, f, a...) IL_DEBUG(p, IL_DL_INFO, f, ## a) -#define IL_DEBUG_MAC80211(p, f, a...) IL_DEBUG(p, IL_DL_MAC80211, f, ## a) -#define IL_DEBUG_MACDUMP(p, f, a...) IL_DEBUG(p, IL_DL_MACDUMP, f, ## a) -#define IL_DEBUG_TEMP(p, f, a...) IL_DEBUG(p, IL_DL_TEMP, f, ## a) -#define IL_DEBUG_SCAN(p, f, a...) IL_DEBUG(p, IL_DL_SCAN, f, ## a) -#define IL_DEBUG_RX(p, f, a...) IL_DEBUG(p, IL_DL_RX, f, ## a) -#define IL_DEBUG_TX(p, f, a...) IL_DEBUG(p, IL_DL_TX, f, ## a) -#define IL_DEBUG_ISR(p, f, a...) IL_DEBUG(p, IL_DL_ISR, f, ## a) -#define IL_DEBUG_LED(p, f, a...) IL_DEBUG(p, IL_DL_LED, f, ## a) -#define IL_DEBUG_WEP(p, f, a...) IL_DEBUG(p, IL_DL_WEP, f, ## a) -#define IL_DEBUG_HC(p, f, a...) IL_DEBUG(p, IL_DL_HCMD, f, ## a) -#define IL_DEBUG_HC_DUMP(p, f, a...) IL_DEBUG(p, IL_DL_HCMD_DUMP, f, ## a) -#define IL_DEBUG_EEPROM(p, f, a...) IL_DEBUG(p, IL_DL_EEPROM, f, ## a) -#define IL_DEBUG_CALIB(p, f, a...) IL_DEBUG(p, IL_DL_CALIB, f, ## a) -#define IL_DEBUG_FW(p, f, a...) IL_DEBUG(p, IL_DL_FW, f, ## a) -#define IL_DEBUG_RF_KILL(p, f, a...) IL_DEBUG(p, IL_DL_RF_KILL, f, ## a) -#define IL_DEBUG_DROP(p, f, a...) IL_DEBUG(p, IL_DL_DROP, f, ## a) -#define IL_DEBUG_AP(p, f, a...) IL_DEBUG(p, IL_DL_AP, f, ## a) -#define IL_DEBUG_TXPOWER(p, f, a...) IL_DEBUG(p, IL_DL_TXPOWER, f, ## a) -#define IL_DEBUG_RATE(p, f, a...) IL_DEBUG(p, IL_DL_RATE, f, ## a) -#define IL_DEBUG_NOTIF(p, f, a...) IL_DEBUG(p, IL_DL_NOTIF, f, ## a) -#define IL_DEBUG_ASSOC(p, f, a...) IL_DEBUG(p, IL_DL_ASSOC, f, ## a) -#define IL_DEBUG_HT(p, f, a...) IL_DEBUG(p, IL_DL_HT, f, ## a) -#define IL_DEBUG_STATS(p, f, a...) IL_DEBUG(p, IL_DL_STATS, f, ## a) -#define IL_DEBUG_TX_REPLY(p, f, a...) IL_DEBUG(p, IL_DL_TX_REPLY, f, ## a) -#define IL_DEBUG_QOS(p, f, a...) IL_DEBUG(p, IL_DL_QOS, f, ## a) -#define IL_DEBUG_RADIO(p, f, a...) IL_DEBUG(p, IL_DL_RADIO, f, ## a) -#define IL_DEBUG_POWER(p, f, a...) IL_DEBUG(p, IL_DL_POWER, f, ## a) -#define IL_DEBUG_11H(p, f, a...) IL_DEBUG(p, IL_DL_11H, f, ## a) +#define D_INFO(f, a...) IL_DBG(IL_DL_INFO, f, ## a) +#define D_MAC80211(f, a...) IL_DBG(IL_DL_MAC80211, f, ## a) +#define D_MACDUMP(f, a...) IL_DBG(IL_DL_MACDUMP, f, ## a) +#define D_TEMP(f, a...) IL_DBG(IL_DL_TEMP, f, ## a) +#define D_SCAN(f, a...) IL_DBG(IL_DL_SCAN, f, ## a) +#define D_RX(f, a...) IL_DBG(IL_DL_RX, f, ## a) +#define D_TX(f, a...) IL_DBG(IL_DL_TX, f, ## a) +#define D_ISR(f, a...) IL_DBG(IL_DL_ISR, f, ## a) +#define D_LED(f, a...) IL_DBG(IL_DL_LED, f, ## a) +#define D_WEP(f, a...) IL_DBG(IL_DL_WEP, f, ## a) +#define D_HC(f, a...) IL_DBG(IL_DL_HCMD, f, ## a) +#define D_HC_DUMP(f, a...) IL_DBG(IL_DL_HCMD_DUMP, f, ## a) +#define D_EEPROM(f, a...) IL_DBG(IL_DL_EEPROM, f, ## a) +#define D_CALIB(f, a...) IL_DBG(IL_DL_CALIB, f, ## a) +#define D_FW(f, a...) IL_DBG(IL_DL_FW, f, ## a) +#define D_RF_KILL(f, a...) IL_DBG(IL_DL_RF_KILL, f, ## a) +#define D_DROP(f, a...) IL_DBG(IL_DL_DROP, f, ## a) +#define D_AP(f, a...) IL_DBG(IL_DL_AP, f, ## a) +#define D_TXPOWER(f, a...) IL_DBG(IL_DL_TXPOWER, f, ## a) +#define D_RATE(f, a...) IL_DBG(IL_DL_RATE, f, ## a) +#define D_NOTIF(f, a...) IL_DBG(IL_DL_NOTIF, f, ## a) +#define D_ASSOC(f, a...) IL_DBG(IL_DL_ASSOC, f, ## a) +#define D_HT(f, a...) IL_DBG(IL_DL_HT, f, ## a) +#define D_STATS(f, a...) IL_DBG(IL_DL_STATS, f, ## a) +#define D_TX_REPLY(f, a...) IL_DBG(IL_DL_TX_REPLY, f, ## a) +#define D_QOS(f, a...) IL_DBG(IL_DL_QOS, f, ## a) +#define D_RADIO(f, a...) IL_DBG(IL_DL_RADIO, f, ## a) +#define D_POWER(f, a...) IL_DBG(IL_DL_POWER, f, ## a) +#define D_11H(f, a...) IL_DBG(IL_DL_11H, f, ## a) #endif diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-eeprom.c index f6b9d6d28d9e..33fe5989e820 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.c @@ -147,7 +147,7 @@ static int il_eeprom_verify_signature(struct il_priv *il) u32 gp = il_read32(il, CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; int ret = 0; - IL_DEBUG_EEPROM(il, "EEPROM signature=0x%08x\n", gp); + D_EEPROM("EEPROM signature=0x%08x\n", gp); switch (gp) { case CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K: case CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K: @@ -194,7 +194,7 @@ int il_eeprom_init(struct il_priv *il) /* allocate eeprom */ sz = il->cfg->base_params->eeprom_size; - IL_DEBUG_EEPROM(il, "NVM size = %d\n", sz); + D_EEPROM("NVM size = %d\n", sz); il->eeprom = kzalloc(sz, GFP_KERNEL); if (!il->eeprom) { ret = -ENOMEM; @@ -239,7 +239,7 @@ int il_eeprom_init(struct il_priv *il) e[addr / 2] = cpu_to_le16(r >> 16); } - IL_DEBUG_EEPROM(il, "NVM Type: %s, version: 0x%x\n", + D_EEPROM("NVM Type: %s, version: 0x%x\n", "EEPROM", il_eeprom_query16(il, EEPROM_VERSION)); @@ -339,7 +339,7 @@ static int il_mod_ht40_chan_info(struct il_priv *il, if (!il_is_channel_valid(ch_info)) return -1; - IL_DEBUG_EEPROM(il, "HT40 Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):" + D_EEPROM("HT40 Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):" " Ad-Hoc %ssupported\n", ch_info->channel, il_is_channel_a_band(ch_info) ? @@ -380,11 +380,11 @@ int il_init_channel_map(struct il_priv *il) struct il_channel_info *ch_info; if (il->channel_count) { - IL_DEBUG_EEPROM(il, "Channel map already initialized.\n"); + D_EEPROM("Channel map already initialized.\n"); return 0; } - IL_DEBUG_EEPROM(il, "Initializing regulatory info from EEPROM\n"); + D_EEPROM("Initializing regulatory info from EEPROM\n"); il->channel_count = ARRAY_SIZE(il_eeprom_band_1) + @@ -393,7 +393,7 @@ int il_init_channel_map(struct il_priv *il) ARRAY_SIZE(il_eeprom_band_4) + ARRAY_SIZE(il_eeprom_band_5); - IL_DEBUG_EEPROM(il, "Parsing data for %d channels.\n", + D_EEPROM("Parsing data for %d channels.\n", il->channel_count); il->channel_info = kzalloc(sizeof(struct il_channel_info) * @@ -433,7 +433,7 @@ int il_init_channel_map(struct il_priv *il) IEEE80211_CHAN_NO_HT40; if (!(il_is_channel_valid(ch_info))) { - IL_DEBUG_EEPROM(il, + D_EEPROM( "Ch. %d Flags %x [%sGHz] - " "No traffic\n", ch_info->channel, @@ -450,7 +450,7 @@ int il_init_channel_map(struct il_priv *il) ch_info->scan_power = eeprom_ch_info[ch].max_power_avg; ch_info->min_power = 0; - IL_DEBUG_EEPROM(il, "Ch. %d [%sGHz] " + D_EEPROM("Ch. %d [%sGHz] " "%s%s%s%s%s%s(0x%02x %ddBm):" " Ad-Hoc %ssupported\n", ch_info->channel, diff --git a/drivers/net/wireless/iwlegacy/iwl-hcmd.c b/drivers/net/wireless/iwlegacy/iwl-hcmd.c index f16e31109e06..61cf0d83af57 100644 --- a/drivers/net/wireless/iwlegacy/iwl-hcmd.c +++ b/drivers/net/wireless/iwlegacy/iwl-hcmd.c @@ -104,11 +104,11 @@ static void il_generic_cmd_callback(struct il_priv *il, switch (cmd->hdr.cmd) { case REPLY_TX_LINK_QUALITY_CMD: case SENSITIVITY_CMD: - IL_DEBUG_HC_DUMP(il, "back from %s (0x%08X)\n", + D_HC_DUMP("back from %s (0x%08X)\n", il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); break; default: - IL_DEBUG_HC(il, "back from %s (0x%08X)\n", + D_HC("back from %s (0x%08X)\n", il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); } #endif @@ -152,11 +152,11 @@ int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) /* A synchronous command can not have a callback set. */ BUG_ON(cmd->callback); - IL_DEBUG_INFO(il, "Attempting to send sync command %s\n", + D_INFO("Attempting to send sync command %s\n", il_get_cmd_string(cmd->id)); set_bit(STATUS_HCMD_ACTIVE, &il->status); - IL_DEBUG_INFO(il, "Setting HCMD_ACTIVE for command %s\n", + D_INFO("Setting HCMD_ACTIVE for command %s\n", il_get_cmd_string(cmd->id)); cmd_idx = il_enqueue_hcmd(il, cmd); @@ -178,7 +178,7 @@ int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); clear_bit(STATUS_HCMD_ACTIVE, &il->status); - IL_DEBUG_INFO(il, + D_INFO( "Clearing HCMD_ACTIVE for command %s\n", il_get_cmd_string(cmd->id)); ret = -ETIMEDOUT; diff --git a/drivers/net/wireless/iwlegacy/iwl-helpers.h b/drivers/net/wireless/iwlegacy/iwl-helpers.h index e55f2ef1c57b..a0a84b295253 100644 --- a/drivers/net/wireless/iwlegacy/iwl-helpers.h +++ b/drivers/net/wireless/iwlegacy/iwl-helpers.h @@ -155,18 +155,18 @@ static inline void il_disable_interrupts(struct il_priv *il) * from uCode or flow handler (Rx/Tx DMA) */ il_write32(il, CSR_INT, 0xffffffff); il_write32(il, CSR_FH_INT_STATUS, 0xffffffff); - IL_DEBUG_ISR(il, "Disabled interrupts\n"); + D_ISR("Disabled interrupts\n"); } static inline void il_enable_rfkill_int(struct il_priv *il) { - IL_DEBUG_ISR(il, "Enabling rfkill interrupt\n"); + D_ISR("Enabling rfkill interrupt\n"); il_write32(il, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); } static inline void il_enable_interrupts(struct il_priv *il) { - IL_DEBUG_ISR(il, "Enabling interrupts\n"); + D_ISR("Enabling interrupts\n"); set_bit(STATUS_INT_ENABLED, &il->status); il_write32(il, CSR_INT_MASK, il->inta_mask); } diff --git a/drivers/net/wireless/iwlegacy/iwl-led.c b/drivers/net/wireless/iwlegacy/iwl-led.c index 13add43987b6..b4d71cf7e398 100644 --- a/drivers/net/wireless/iwlegacy/iwl-led.c +++ b/drivers/net/wireless/iwlegacy/iwl-led.c @@ -118,7 +118,7 @@ static int il_led_cmd(struct il_priv *il, on = IL_LED_SOLID; } - IL_DEBUG_LED(il, "Led blink time compensation=%u\n", + D_LED("Led blink time compensation=%u\n", il->cfg->base_params->led_compensation); led_cmd.on = il_blink_compensation(il, on, il->cfg->base_params->led_compensation); diff --git a/drivers/net/wireless/iwlegacy/iwl-power.c b/drivers/net/wireless/iwlegacy/iwl-power.c index 63862464fcdb..33aec397247c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-power.c +++ b/drivers/net/wireless/iwlegacy/iwl-power.c @@ -68,19 +68,19 @@ static void il_power_sleep_cam_cmd(struct il_priv *il, if (il->power_data.pci_pm) cmd->flags |= IL_POWER_PCI_PM_MSK; - IL_DEBUG_POWER(il, "Sleep command for CAM\n"); + D_POWER("Sleep command for CAM\n"); } static int il_set_power(struct il_priv *il, struct il_powertable_cmd *cmd) { - IL_DEBUG_POWER(il, "Sending power/sleep command\n"); - IL_DEBUG_POWER(il, "Flags value = 0x%08X\n", cmd->flags); - IL_DEBUG_POWER(il, "Tx timeout = %u\n", + D_POWER("Sending power/sleep command\n"); + D_POWER("Flags value = 0x%08X\n", cmd->flags); + D_POWER("Tx timeout = %u\n", le32_to_cpu(cmd->tx_data_timeout)); - IL_DEBUG_POWER(il, "Rx timeout = %u\n", + D_POWER("Rx timeout = %u\n", le32_to_cpu(cmd->rx_data_timeout)); - IL_DEBUG_POWER(il, + D_POWER( "Sleep interval vector = { %d , %d , %d , %d , %d }\n", le32_to_cpu(cmd->sleep_interval[0]), le32_to_cpu(cmd->sleep_interval[1]), @@ -114,7 +114,7 @@ il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, /* scan complete use sleep_power_next, need to be updated */ memcpy(&il->power_data.sleep_cmd_next, cmd, sizeof(*cmd)); if (test_bit(STATUS_SCANNING, &il->status) && !force) { - IL_DEBUG_INFO(il, "Defer power set mode while scanning\n"); + D_INFO("Defer power set mode while scanning\n"); return 0; } @@ -129,7 +129,7 @@ il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, if (il->cfg->ops->lib->update_chain_flags && update_chains) il->cfg->ops->lib->update_chain_flags(il); else if (il->cfg->ops->lib->update_chain_flags) - IL_DEBUG_POWER(il, + D_POWER( "Cannot update the power, chain noise " "calibration running: %d\n", il->chain_noise_data.state); diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c index b6c5dd09bd8b..183acdc69a25 100644 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -141,7 +141,7 @@ il_rx_queue_update_write_ptr(struct il_priv *il, reg = il_read32(il, CSR_UCODE_DRV_GP1); if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { - IL_DEBUG_INFO(il, + D_INFO( "Rx queue requesting wakeup," " GP1 = 0x%x\n", reg); il_set_bit(il, CSR_GP_CNTRL, @@ -217,7 +217,7 @@ void il_rx_spectrum_measure_notif(struct il_priv *il, struct il_spectrum_notification *report = &(pkt->u.spectrum_notif); if (!report->state) { - IL_DEBUG_11H(il, + D_11H( "Spectrum Measure Notification: Start\n"); return; } @@ -248,7 +248,7 @@ int il_set_decrypted_flag(struct il_priv *il, if (!(fc & IEEE80211_FCTL_PROTECTED)) return 0; - IL_DEBUG_RX(il, "decrypt_res:0x%x\n", decrypt_res); + D_RX("decrypt_res:0x%x\n", decrypt_res); switch (decrypt_res & RX_RES_STATUS_SEC_TYPE_MSK) { case RX_RES_STATUS_SEC_TYPE_TKIP: /* The uCode has got a bad phase 1 Key, pushes the packet. @@ -262,13 +262,13 @@ int il_set_decrypted_flag(struct il_priv *il, RX_RES_STATUS_BAD_ICV_MIC) { /* bad ICV, the packet is destroyed since the * decryption is inplace, drop it */ - IL_DEBUG_RX(il, "Packet destroyed\n"); + D_RX("Packet destroyed\n"); return -1; } case RX_RES_STATUS_SEC_TYPE_CCMP: if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) == RX_RES_STATUS_DECRYPT_OK) { - IL_DEBUG_RX(il, "hw decrypt successfully!!!\n"); + D_RX("hw decrypt successfully!!!\n"); stats->flag |= RX_FLAG_DECRYPTED; } break; diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index 5a967d2b15d1..c534dcef4a71 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -85,7 +85,7 @@ static int il_send_scan_abort(struct il_priv *il) * can occur if we send the scan abort before we * the microcode has notified us that a scan is * completed. */ - IL_DEBUG_SCAN(il, "SCAN_ABORT ret %d.\n", pkt->u.status); + D_SCAN("SCAN_ABORT ret %d.\n", pkt->u.status); ret = -EIO; } @@ -97,7 +97,7 @@ static void il_complete_scan(struct il_priv *il, bool aborted) { /* check if scan was requested from mac80211 */ if (il->scan_request) { - IL_DEBUG_SCAN(il, "Complete scan in mac80211\n"); + D_SCAN("Complete scan in mac80211\n"); ieee80211_scan_completed(il->hw, aborted); } @@ -110,11 +110,11 @@ void il_force_scan_end(struct il_priv *il) lockdep_assert_held(&il->mutex); if (!test_bit(STATUS_SCANNING, &il->status)) { - IL_DEBUG_SCAN(il, "Forcing scan end while not scanning\n"); + D_SCAN("Forcing scan end while not scanning\n"); return; } - IL_DEBUG_SCAN(il, "Forcing scan end\n"); + D_SCAN("Forcing scan end\n"); clear_bit(STATUS_SCANNING, &il->status); clear_bit(STATUS_SCAN_HW, &il->status); clear_bit(STATUS_SCAN_ABORTING, &il->status); @@ -128,21 +128,21 @@ static void il_do_scan_abort(struct il_priv *il) lockdep_assert_held(&il->mutex); if (!test_bit(STATUS_SCANNING, &il->status)) { - IL_DEBUG_SCAN(il, "Not performing scan to abort\n"); + D_SCAN("Not performing scan to abort\n"); return; } if (test_and_set_bit(STATUS_SCAN_ABORTING, &il->status)) { - IL_DEBUG_SCAN(il, "Scan abort in progress\n"); + D_SCAN("Scan abort in progress\n"); return; } ret = il_send_scan_abort(il); if (ret) { - IL_DEBUG_SCAN(il, "Send scan abort failed %d\n", ret); + D_SCAN("Send scan abort failed %d\n", ret); il_force_scan_end(il); } else - IL_DEBUG_SCAN(il, "Successfully send scan abort\n"); + D_SCAN("Successfully send scan abort\n"); } /** @@ -150,7 +150,7 @@ static void il_do_scan_abort(struct il_priv *il) */ int il_scan_cancel(struct il_priv *il) { - IL_DEBUG_SCAN(il, "Queuing abort scan\n"); + D_SCAN("Queuing abort scan\n"); queue_work(il->workqueue, &il->abort_scan); return 0; } @@ -167,7 +167,7 @@ int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms) lockdep_assert_held(&il->mutex); - IL_DEBUG_SCAN(il, "Scan cancel timeout\n"); + D_SCAN("Scan cancel timeout\n"); il_do_scan_abort(il); @@ -190,7 +190,7 @@ static void il_rx_reply_scan(struct il_priv *il, struct il_scanreq_notification *notif = (struct il_scanreq_notification *)pkt->u.raw; - IL_DEBUG_SCAN(il, "Scan request status = 0x%x\n", notif->status); + D_SCAN("Scan request status = 0x%x\n", notif->status); #endif } @@ -202,7 +202,7 @@ static void il_rx_scan_start_notif(struct il_priv *il, struct il_scanstart_notification *notif = (struct il_scanstart_notification *)pkt->u.raw; il->scan_start_tsf = le32_to_cpu(notif->tsf_low); - IL_DEBUG_SCAN(il, "Scan start: " + D_SCAN("Scan start: " "%d [802.11%s] " "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n", notif->channel, @@ -221,7 +221,7 @@ static void il_rx_scan_results_notif(struct il_priv *il, struct il_scanresults_notification *notif = (struct il_scanresults_notification *)pkt->u.raw; - IL_DEBUG_SCAN(il, "Scan ch.res: " + D_SCAN("Scan ch.res: " "%d [802.11%s] " "(TSF: 0x%08X:%08X) - %d " "elapsed=%lu usec\n", @@ -244,7 +244,7 @@ static void il_rx_scan_complete_notif(struct il_priv *il, struct il_scancomplete_notification *scan_notif = (void *)pkt->u.raw; #endif - IL_DEBUG_SCAN(il, + D_SCAN( "Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n", scan_notif->scanned_channels, scan_notif->tsf_low, @@ -253,7 +253,7 @@ static void il_rx_scan_complete_notif(struct il_priv *il, /* The HW is no longer scanning */ clear_bit(STATUS_SCAN_HW, &il->status); - IL_DEBUG_SCAN(il, "Scan on %sGHz took %dms\n", + D_SCAN("Scan on %sGHz took %dms\n", (il->scan_band == IEEE80211_BAND_2GHZ) ? "2.4" : "5.2", jiffies_to_msecs(jiffies - il->scan_start)); @@ -346,17 +346,17 @@ static int il_scan_initiate(struct il_priv *il, } if (test_bit(STATUS_SCAN_HW, &il->status)) { - IL_DEBUG_SCAN(il, + D_SCAN( "Multiple concurrent scan requests in parallel.\n"); return -EBUSY; } if (test_bit(STATUS_SCAN_ABORTING, &il->status)) { - IL_DEBUG_SCAN(il, "Scan request while abort pending.\n"); + D_SCAN("Scan request while abort pending.\n"); return -EBUSY; } - IL_DEBUG_SCAN(il, "Starting scan...\n"); + D_SCAN("Starting scan...\n"); set_bit(STATUS_SCANNING, &il->status); il->scan_start = jiffies; @@ -380,7 +380,7 @@ int il_mac_hw_scan(struct ieee80211_hw *hw, struct il_priv *il = hw->priv; int ret; - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); if (req->n_channels == 0) return -EINVAL; @@ -388,7 +388,7 @@ int il_mac_hw_scan(struct ieee80211_hw *hw, mutex_lock(&il->mutex); if (test_bit(STATUS_SCANNING, &il->status)) { - IL_DEBUG_SCAN(il, "Scan already in progress.\n"); + D_SCAN("Scan already in progress.\n"); ret = -EAGAIN; goto out_unlock; } @@ -400,7 +400,7 @@ int il_mac_hw_scan(struct ieee80211_hw *hw, ret = il_scan_initiate(il, vif); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); out_unlock: mutex_unlock(&il->mutex); @@ -414,7 +414,7 @@ static void il_bg_scan_check(struct work_struct *data) struct il_priv *il = container_of(data, struct il_priv, scan_check.work); - IL_DEBUG_SCAN(il, "Scan check work\n"); + D_SCAN("Scan check work\n"); /* Since we are here firmware does not finish scan and * most likely is in bad shape, so we don't bother to @@ -477,7 +477,7 @@ static void il_bg_abort_scan(struct work_struct *work) { struct il_priv *il = container_of(work, struct il_priv, abort_scan); - IL_DEBUG_SCAN(il, "Abort scan work\n"); + D_SCAN("Abort scan work\n"); /* We keep scan_check work queued in case when firmware will not * report back scan completed notification */ @@ -492,7 +492,7 @@ static void il_bg_scan_completed(struct work_struct *work) container_of(work, struct il_priv, scan_completed); bool aborted; - IL_DEBUG_SCAN(il, "Completed scan.\n"); + D_SCAN("Completed scan.\n"); cancel_delayed_work(&il->scan_check); @@ -500,10 +500,10 @@ static void il_bg_scan_completed(struct work_struct *work) aborted = test_and_clear_bit(STATUS_SCAN_ABORTING, &il->status); if (aborted) - IL_DEBUG_SCAN(il, "Aborted scan completed.\n"); + D_SCAN("Aborted scan completed.\n"); if (!test_and_clear_bit(STATUS_SCANNING, &il->status)) { - IL_DEBUG_SCAN(il, "Scan already completed.\n"); + D_SCAN("Scan already completed.\n"); goto out_settings; } diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.c b/drivers/net/wireless/iwlegacy/iwl-sta.c index 7d66e79f5d3e..a48af855dc01 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-sta.c @@ -46,13 +46,13 @@ static void il_sta_ucode_activate(struct il_priv *il, u8 sta_id) sta_id, il->stations[sta_id].sta.sta.addr); if (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE) { - IL_DEBUG_ASSOC(il, + D_ASSOC( "STA id %u addr %pM already present" " in uCode (according to driver)\n", sta_id, il->stations[sta_id].sta.sta.addr); } else { il->stations[sta_id].used |= IL_STA_UCODE_ACTIVE; - IL_DEBUG_ASSOC(il, "Added STA id %u addr %pM to uCode\n", + D_ASSOC("Added STA id %u addr %pM to uCode\n", sta_id, il->stations[sta_id].sta.sta.addr); } } @@ -72,14 +72,14 @@ static int il_process_add_sta_resp(struct il_priv *il, return ret; } - IL_DEBUG_INFO(il, "Processing response for adding station %u\n", + D_INFO("Processing response for adding station %u\n", sta_id); spin_lock_irqsave(&il->sta_lock, flags); switch (pkt->u.add_sta.status) { case ADD_STA_SUCCESS_MSK: - IL_DEBUG_INFO(il, "REPLY_ADD_STA PASSED\n"); + D_INFO("REPLY_ADD_STA PASSED\n"); il_sta_ucode_activate(il, sta_id); ret = 0; break; @@ -97,12 +97,12 @@ static int il_process_add_sta_resp(struct il_priv *il, sta_id); break; default: - IL_DEBUG_ASSOC(il, "Received REPLY_ADD_STA:(0x%08X)\n", + D_ASSOC("Received REPLY_ADD_STA:(0x%08X)\n", pkt->u.add_sta.status); break; } - IL_DEBUG_INFO(il, "%s station id %u addr %pM\n", + D_INFO("%s station id %u addr %pM\n", il->stations[sta_id].sta.mode == STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", sta_id, il->stations[sta_id].sta.sta.addr); @@ -115,7 +115,7 @@ static int il_process_add_sta_resp(struct il_priv *il, * issue has not yet been resolved and this debugging is left to * observe the problem. */ - IL_DEBUG_INFO(il, "%s station according to cmd buffer %pM\n", + D_INFO("%s station according to cmd buffer %pM\n", il->stations[sta_id].sta.mode == STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", addsta->sta.addr); @@ -148,7 +148,7 @@ int il_send_add_sta(struct il_priv *il, }; u8 sta_id __maybe_unused = sta->sta.sta_id; - IL_DEBUG_INFO(il, "Adding sta %u (%pM) %ssynchronously\n", + D_INFO("Adding sta %u (%pM) %ssynchronously\n", sta_id, sta->sta.addr, flags & CMD_ASYNC ? "a" : ""); if (flags & CMD_ASYNC) @@ -186,7 +186,7 @@ static void il_set_ht_add_station(struct il_priv *il, u8 index, goto done; mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_SM_PS) >> 2; - IL_DEBUG_ASSOC(il, "spatial multiplexing power save mode: %s\n", + D_ASSOC("spatial multiplexing power save mode: %s\n", (mimo_ps_mode == WLAN_HT_CAP_SM_PS_STATIC) ? "static" : (mimo_ps_mode == WLAN_HT_CAP_SM_PS_DYNAMIC) ? @@ -269,7 +269,7 @@ u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, * another. */ if (il->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { - IL_DEBUG_INFO(il, + D_INFO( "STA %d already in process of being added.\n", sta_id); return sta_id; @@ -278,7 +278,7 @@ u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, if ((il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE) && !compare_ether_addr(il->stations[sta_id].sta.sta.addr, addr)) { - IL_DEBUG_ASSOC(il, + D_ASSOC( "STA %d (%pM) already added, not adding again.\n", sta_id, addr); return sta_id; @@ -286,7 +286,7 @@ u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, station = &il->stations[sta_id]; station->used = IL_STA_DRIVER_ACTIVE; - IL_DEBUG_ASSOC(il, "Add STA to driver ID %d: %pM\n", + D_ASSOC("Add STA to driver ID %d: %pM\n", sta_id, addr); il->num_stations++; @@ -355,7 +355,7 @@ il_add_station_common(struct il_priv *il, * another. */ if (il->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { - IL_DEBUG_INFO(il, + D_INFO( "STA %d already in process of being added.\n", sta_id); spin_unlock_irqrestore(&il->sta_lock, flags_spin); @@ -364,7 +364,7 @@ il_add_station_common(struct il_priv *il, if ((il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { - IL_DEBUG_ASSOC(il, + D_ASSOC( "STA %d (%pM) already added, not adding again.\n", sta_id, addr); spin_unlock_irqrestore(&il->sta_lock, flags_spin); @@ -407,7 +407,7 @@ static void il_sta_ucode_deactivate(struct il_priv *il, u8 sta_id) il->stations[sta_id].used &= ~IL_STA_UCODE_ACTIVE; memset(&il->stations[sta_id], 0, sizeof(struct il_station_entry)); - IL_DEBUG_ASSOC(il, "Removed STA %u\n", sta_id); + D_ASSOC("Removed STA %u\n", sta_id); } static int il_send_remove_station(struct il_priv *il, @@ -454,7 +454,7 @@ static int il_send_remove_station(struct il_priv *il, spin_unlock_irqrestore(&il->sta_lock, flags_spin); } - IL_DEBUG_ASSOC(il, "REPLY_REMOVE_STA PASSED\n"); + D_ASSOC("REPLY_REMOVE_STA PASSED\n"); break; default: ret = -EIO; @@ -476,7 +476,7 @@ int il_remove_station(struct il_priv *il, const u8 sta_id, unsigned long flags; if (!il_is_ready(il)) { - IL_DEBUG_INFO(il, + D_INFO( "Unable to remove station %pM, device not ready.\n", addr); /* @@ -487,7 +487,7 @@ int il_remove_station(struct il_priv *il, const u8 sta_id, return 0; } - IL_DEBUG_ASSOC(il, "Removing STA from driver:%d %pM\n", + D_ASSOC("Removing STA from driver:%d %pM\n", sta_id, addr); if (WARN_ON(sta_id == IL_INVALID_STATION)) @@ -496,13 +496,13 @@ int il_remove_station(struct il_priv *il, const u8 sta_id, spin_lock_irqsave(&il->sta_lock, flags); if (!(il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) { - IL_DEBUG_INFO(il, "Removing %pM but non DRIVER active\n", + D_INFO("Removing %pM but non DRIVER active\n", addr); goto out_err; } if (!(il->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { - IL_DEBUG_INFO(il, "Removing %pM but non UCODE active\n", + D_INFO("Removing %pM but non UCODE active\n", addr); goto out_err; } @@ -542,7 +542,7 @@ void il_clear_ucode_stations(struct il_priv *il, unsigned long flags_spin; bool cleared = false; - IL_DEBUG_INFO(il, "Clearing ucode stations in driver\n"); + D_INFO("Clearing ucode stations in driver\n"); spin_lock_irqsave(&il->sta_lock, flags_spin); for (i = 0; i < il->hw_params.max_stations; i++) { @@ -550,7 +550,7 @@ void il_clear_ucode_stations(struct il_priv *il, continue; if (il->stations[i].used & IL_STA_UCODE_ACTIVE) { - IL_DEBUG_INFO(il, + D_INFO( "Clearing ucode active for station %d\n", i); il->stations[i].used &= ~IL_STA_UCODE_ACTIVE; cleared = true; @@ -559,7 +559,7 @@ void il_clear_ucode_stations(struct il_priv *il, spin_unlock_irqrestore(&il->sta_lock, flags_spin); if (!cleared) - IL_DEBUG_INFO(il, + D_INFO( "No active stations found to be cleared\n"); } EXPORT_SYMBOL(il_clear_ucode_stations); @@ -584,19 +584,19 @@ il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) bool send_lq; if (!il_is_ready(il)) { - IL_DEBUG_INFO(il, + D_INFO( "Not ready yet, not restoring any stations.\n"); return; } - IL_DEBUG_ASSOC(il, "Restoring all known stations ... start.\n"); + D_ASSOC("Restoring all known stations ... start.\n"); spin_lock_irqsave(&il->sta_lock, flags_spin); for (i = 0; i < il->hw_params.max_stations; i++) { if (ctx->ctxid != il->stations[i].ctxid) continue; if ((il->stations[i].used & IL_STA_DRIVER_ACTIVE) && !(il->stations[i].used & IL_STA_UCODE_ACTIVE)) { - IL_DEBUG_ASSOC(il, "Restoring sta %pM\n", + D_ASSOC("Restoring sta %pM\n", il->stations[i].sta.sta.addr); il->stations[i].sta.mode = 0; il->stations[i].used |= IL_STA_UCODE_INPROGRESS; @@ -641,10 +641,10 @@ il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) spin_unlock_irqrestore(&il->sta_lock, flags_spin); if (!found) - IL_DEBUG_INFO(il, "Restoring all known stations" + D_INFO("Restoring all known stations" " .... no stations to be restored.\n"); else - IL_DEBUG_INFO(il, "Restoring all known stations" + D_INFO("Restoring all known stations" " .... complete.\n"); } EXPORT_SYMBOL(il_restore_stations); @@ -686,13 +686,13 @@ static void il_dump_lq_cmd(struct il_priv *il, struct il_link_quality_cmd *lq) { int i; - IL_DEBUG_RATE(il, "lq station id 0x%x\n", lq->sta_id); - IL_DEBUG_RATE(il, "lq ant 0x%X 0x%X\n", + D_RATE("lq station id 0x%x\n", lq->sta_id); + D_RATE("lq ant 0x%X 0x%X\n", lq->general_params.single_stream_ant_msk, lq->general_params.dual_stream_ant_msk); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) - IL_DEBUG_RATE(il, "lq index %d 0x%X\n", + D_RATE("lq index %d 0x%X\n", i, lq->rs_table[i].rate_n_flags); } #else @@ -722,12 +722,12 @@ static bool il_is_lq_table_valid(struct il_priv *il, if (ctx->ht.enabled) return true; - IL_DEBUG_INFO(il, "Channel %u is not an HT channel\n", + D_INFO("Channel %u is not an HT channel\n", ctx->active.channel); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { if (le32_to_cpu(lq->rs_table[i].rate_n_flags) & RATE_MCS_HT_MSK) { - IL_DEBUG_INFO(il, + D_INFO( "index %d of LQ expects HT channel\n", i); return false; @@ -782,7 +782,7 @@ int il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, return ret; if (init) { - IL_DEBUG_INFO(il, "init LQ command complete," + D_INFO("init LQ command complete," " clearing sta addition status for sta %d\n", lq->sta_id); spin_lock_irqsave(&il->sta_lock, flags_spin); @@ -801,10 +801,10 @@ int il_mac_sta_remove(struct ieee80211_hw *hw, struct il_station_priv_common *sta_common = (void *)sta->drv_priv; int ret; - IL_DEBUG_INFO(il, "received request to remove station %pM\n", + D_INFO("received request to remove station %pM\n", sta->addr); mutex_lock(&il->mutex); - IL_DEBUG_INFO(il, "proceeding to remove station %pM\n", + D_INFO("proceeding to remove station %pM\n", sta->addr); ret = il_remove_station(il, sta_common->sta_id, sta->addr); if (ret) diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index af6ac4fe2670..22617c47fc77 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -58,7 +58,7 @@ il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq) reg = il_read32(il, CSR_UCODE_DRV_GP1); if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { - IL_DEBUG_INFO(il, + D_INFO( "Tx queue %d requesting wakeup," " GP1 = 0x%x\n", txq_id, reg); il_set_bit(il, CSR_GP_CNTRL, @@ -511,7 +511,7 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) switch (out_cmd->hdr.cmd) { case REPLY_TX_LINK_QUALITY_CMD: case SENSITIVITY_CMD: - IL_DEBUG_HC_DUMP(il, + D_HC_DUMP( "Sending command %s (#%x), seq: 0x%04X, " "%d bytes at %d[%d]:%d\n", il_get_cmd_string(out_cmd->hdr.cmd), @@ -520,7 +520,7 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) q->write_ptr, idx, il->cmd_queue); break; default: - IL_DEBUG_HC(il, "Sending command %s (#%x), seq: 0x%04X, " + D_HC("Sending command %s (#%x), seq: 0x%04X, " "%d bytes at %d[%d]:%d\n", il_get_cmd_string(out_cmd->hdr.cmd), out_cmd->hdr.cmd, @@ -642,7 +642,7 @@ il_tx_cmd_complete(struct il_priv *il, struct il_rx_mem_buffer *rxb) if (!(meta->flags & CMD_ASYNC)) { clear_bit(STATUS_HCMD_ACTIVE, &il->status); - IL_DEBUG_INFO(il, "Clearing HCMD_ACTIVE for command %s\n", + D_INFO("Clearing HCMD_ACTIVE for command %s\n", il_get_cmd_string(cmd->hdr.cmd)); wake_up(&il->wait_command_queue); } diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index af3f1945e17d..8aa22a01ae68 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -174,7 +174,7 @@ static int il3945_set_ccmp_dynamic_key_info(struct il_priv *il, il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - IL_DEBUG_INFO(il, "hwcrypto: modify ucode station key info\n"); + D_INFO("hwcrypto: modify ucode station key info\n"); ret = il_send_add_sta(il, &il->stations[sta_id].sta, CMD_ASYNC); @@ -213,7 +213,7 @@ static int il3945_clear_sta_key_info(struct il_priv *il, u8 sta_id) memcpy(&sta_cmd, &il->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&il->sta_lock, flags); - IL_DEBUG_INFO(il, "hwcrypto: clear ucode station key info\n"); + D_INFO("hwcrypto: clear ucode station key info\n"); return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } @@ -241,7 +241,7 @@ static int il3945_set_dynamic_key(struct il_priv *il, ret = -EINVAL; } - IL_DEBUG_WEP(il, "Set dynamic key: alg=%x len=%d idx=%d sta=%d ret=%d\n", + D_WEP("Set dynamic key: alg=%x len=%d idx=%d sta=%d ret=%d\n", keyconf->cipher, keyconf->keylen, keyconf->keyidx, sta_id, ret); @@ -270,7 +270,7 @@ static void il3945_clear_free_frames(struct il_priv *il) { struct list_head *element; - IL_DEBUG_INFO(il, "%d frames on pre-allocated heap on clear.\n", + D_INFO("%d frames on pre-allocated heap on clear.\n", il->frames_count); while (!list_empty(&il->free_frames)) { @@ -381,7 +381,7 @@ static void il3945_build_tx_cmd_hwcrypto(struct il_priv *il, case WLAN_CIPHER_SUITE_CCMP: tx_cmd->sec_ctl = TX_CMD_SEC_CCM; memcpy(tx_cmd->key, keyinfo->key, keyinfo->keylen); - IL_DEBUG_TX(il, "tx_cmd with AES hwcrypto\n"); + D_TX("tx_cmd with AES hwcrypto\n"); break; case WLAN_CIPHER_SUITE_TKIP: @@ -396,7 +396,7 @@ static void il3945_build_tx_cmd_hwcrypto(struct il_priv *il, memcpy(&tx_cmd->key[3], keyinfo->key, keyinfo->keylen); - IL_DEBUG_TX(il, "Configuring packet for WEP encryption " + D_TX("Configuring packet for WEP encryption " "with key %d\n", info->control.hw_key->hw_key_idx); break; @@ -486,7 +486,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) spin_lock_irqsave(&il->lock, flags); if (il_is_rfkill(il)) { - IL_DEBUG_DROP(il, "Dropping - RF KILL\n"); + D_DROP("Dropping - RF KILL\n"); goto drop_unlock; } @@ -502,11 +502,11 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG if (ieee80211_is_auth(fc)) - IL_DEBUG_TX(il, "Sending AUTH frame\n"); + D_TX("Sending AUTH frame\n"); else if (ieee80211_is_assoc_req(fc)) - IL_DEBUG_TX(il, "Sending ASSOC frame\n"); + D_TX("Sending ASSOC frame\n"); else if (ieee80211_is_reassoc_req(fc)) - IL_DEBUG_TX(il, "Sending REASSOC frame\n"); + D_TX("Sending REASSOC frame\n"); #endif spin_unlock_irqrestore(&il->lock, flags); @@ -518,12 +518,12 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) il, &il->contexts[IL_RXON_CTX_BSS], info->control.sta); if (sta_id == IL_INVALID_STATION) { - IL_DEBUG_DROP(il, "Dropping - INVALID STATION: %pM\n", + D_DROP("Dropping - INVALID STATION: %pM\n", hdr->addr1); goto drop; } - IL_DEBUG_RATE(il, "station Id %d\n", sta_id); + D_RATE("station Id %d\n", sta_id); if (ieee80211_is_data_qos(fc)) { u8 *qc = ieee80211_get_qos_ctl(hdr); @@ -594,9 +594,9 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) txq->need_update = 0; } - IL_DEBUG_TX(il, "sequence nr = 0X%x\n", + D_TX("sequence nr = 0X%x\n", le16_to_cpu(out_cmd->hdr.sequence)); - IL_DEBUG_TX(il, "tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); + D_TX("tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); il_print_hex_dump(il, IL_DL_TX, tx_cmd, sizeof(*tx_cmd)); il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd->hdr, ieee80211_hdrlen(fc)); @@ -726,7 +726,7 @@ static int il3945_get_measurement(struct il_priv *il, switch (spectrum_resp_status) { case 0: /* Command will be handled */ if (pkt->u.spectrum.id != 0xff) { - IL_DEBUG_INFO(il, "Replaced existing measurement: %d\n", + D_INFO("Replaced existing measurement: %d\n", pkt->u.spectrum.id); il->measurement_status &= ~MEASUREMENT_READY; } @@ -753,18 +753,18 @@ static void il3945_rx_reply_alive(struct il_priv *il, palive = &pkt->u.alive_frame; - IL_DEBUG_INFO(il, "Alive ucode status 0x%08X revision " + D_INFO("Alive ucode status 0x%08X revision " "0x%01X 0x%01X\n", palive->is_valid, palive->ver_type, palive->ver_subtype); if (palive->ver_subtype == INITIALIZE_SUBTYPE) { - IL_DEBUG_INFO(il, "Initialization Alive received.\n"); + D_INFO("Initialization Alive received.\n"); memcpy(&il->card_alive_init, &pkt->u.alive_frame, sizeof(struct il_alive_resp)); pwork = &il->init_alive_start; } else { - IL_DEBUG_INFO(il, "Runtime Alive received.\n"); + D_INFO("Runtime Alive received.\n"); memcpy(&il->card_alive, &pkt->u.alive_frame, sizeof(struct il_alive_resp)); pwork = &il->alive_start; @@ -787,7 +787,7 @@ static void il3945_rx_reply_add_sta(struct il_priv *il, struct il_rx_packet *pkt = rxb_addr(rxb); #endif - IL_DEBUG_RX(il, "Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); + D_RX("Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); } static void il3945_rx_beacon_notif(struct il_priv *il, @@ -798,7 +798,7 @@ static void il3945_rx_beacon_notif(struct il_priv *il, #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG u8 rate = beacon->beacon_notify_hdr.rate; - IL_DEBUG_RX(il, "beacon status %x retries %d iss %d " + D_RX("beacon status %x retries %d iss %d " "tsf %d %d rate %d\n", le32_to_cpu(beacon->beacon_notify_hdr.status) & TX_STATUS_MSK, beacon->beacon_notify_hdr.failure_frame, @@ -1040,7 +1040,7 @@ static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) page = alloc_pages(gfp_mask, il->hw_params.rx_page_order); if (!page) { if (net_ratelimit()) - IL_DEBUG_INFO(il, "Failed to allocate SKB buffer.\n"); + D_INFO("Failed to allocate SKB buffer.\n"); if ((rxq->free_count <= RX_LOW_WATERMARK) && net_ratelimit()) IL_CRIT(il, "Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", @@ -1225,7 +1225,7 @@ static void il3945_rx_handle(struct il_priv *il) fill_rx = 1; /* Rx interrupt, but nothing sent from uCode */ if (i == r) - IL_DEBUG_RX(il, "r = %d, i = %d\n", r, i); + D_RX("r = %d, i = %d\n", r, i); while (i != r) { int len; @@ -1261,13 +1261,13 @@ static void il3945_rx_handle(struct il_priv *il) * handle those that need handling via function in * rx_handlers table. See il3945_setup_rx_handlers() */ if (il->rx_handlers[pkt->hdr.cmd]) { - IL_DEBUG_RX(il, "r = %d, i = %d, %s, 0x%02x\n", r, i, + D_RX("r = %d, i = %d, %s, 0x%02x\n", r, i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); il->isr_stats.rx_handlers[pkt->hdr.cmd]++; il->rx_handlers[pkt->hdr.cmd] (il, rxb); } else { /* No handling needed */ - IL_DEBUG_RX(il, + D_RX( "r %d i %d No handler needed for %s, 0x%02x\n", r, i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); @@ -1432,7 +1432,7 @@ static void il3945_irq_tasklet(struct il_priv *il) if (il_get_debug_level(il) & IL_DL_ISR) { /* just for debug */ inta_mask = il_read32(il, CSR_INT_MASK); - IL_DEBUG_ISR(il, "inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", + D_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, inta_mask, inta_fh); } #endif @@ -1467,14 +1467,14 @@ static void il3945_irq_tasklet(struct il_priv *il) if (il_get_debug_level(il) & (IL_DL_ISR)) { /* NIC fires this, but we don't use it, redundant with WAKEUP */ if (inta & CSR_INT_BIT_SCD) { - IL_DEBUG_ISR(il, "Scheduler finished to transmit " + D_ISR("Scheduler finished to transmit " "the frame/frames.\n"); il->isr_stats.sch++; } /* Alive notification via Rx interrupt will do the real work */ if (inta & CSR_INT_BIT_ALIVE) { - IL_DEBUG_ISR(il, "Alive interrupt\n"); + D_ISR("Alive interrupt\n"); il->isr_stats.alive++; } } @@ -1493,7 +1493,7 @@ static void il3945_irq_tasklet(struct il_priv *il) /* uCode wakes up after power-down sleep */ if (inta & CSR_INT_BIT_WAKEUP) { - IL_DEBUG_ISR(il, "Wakeup interrupt\n"); + D_ISR("Wakeup interrupt\n"); il_rx_queue_update_write_ptr(il, &il->rxq); il_txq_update_write_ptr(il, &il->txq[0]); il_txq_update_write_ptr(il, &il->txq[1]); @@ -1516,7 +1516,7 @@ static void il3945_irq_tasklet(struct il_priv *il) } if (inta & CSR_INT_BIT_FH_TX) { - IL_DEBUG_ISR(il, "Tx interrupt\n"); + D_ISR("Tx interrupt\n"); il->isr_stats.tx++; il_write32(il, CSR_FH_INT_STATUS, (1 << 6)); @@ -1546,7 +1546,7 @@ static void il3945_irq_tasklet(struct il_priv *il) inta = il_read32(il, CSR_INT); inta_mask = il_read32(il, CSR_INT_MASK); inta_fh = il_read32(il, CSR_FH_INT_STATUS); - IL_DEBUG_ISR(il, "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " + D_ISR("End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); } #endif @@ -1586,7 +1586,7 @@ static int il3945_get_channels_for_scan(struct il_priv *il, ch_info = il_get_channel_info(il, band, scan_ch->channel); if (!il_is_channel_valid(ch_info)) { - IL_DEBUG_SCAN(il, + D_SCAN( "Channel %d is INVALID for this band.\n", scan_ch->channel); continue; @@ -1635,7 +1635,7 @@ static int il3945_get_channels_for_scan(struct il_priv *il, */ } - IL_DEBUG_SCAN(il, "Scanning %d [%s %d]\n", + D_SCAN("Scanning %d [%s %d]\n", scan_ch->channel, (scan_ch->type & 1) ? "ACTIVE" : "PASSIVE", (scan_ch->type & 1) ? @@ -1645,7 +1645,7 @@ static int il3945_get_channels_for_scan(struct il_priv *il, added++; } - IL_DEBUG_SCAN(il, "total channels to scan %d\n", added); + D_SCAN("total channels to scan %d\n", added); return added; } @@ -1696,7 +1696,7 @@ static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) int rc = 0; u32 errcnt; - IL_DEBUG_INFO(il, "ucode inst image size is %u\n", len); + D_INFO("ucode inst image size is %u\n", len); il_write_direct32(il, HBUS_TARG_MEM_RADDR, IWL39_RTC_INST_LOWER_BOUND); @@ -1720,7 +1720,7 @@ static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) if (!errcnt) - IL_DEBUG_INFO(il, + D_INFO( "ucode image in INSTRUCTION memory is good\n"); return rc; @@ -1739,7 +1739,7 @@ static int il3945_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) u32 errcnt = 0; u32 i; - IL_DEBUG_INFO(il, "ucode inst image size is %u\n", len); + D_INFO("ucode inst image size is %u\n", len); for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { /* read data comes through single port, auto-incr addr */ @@ -1780,7 +1780,7 @@ static int il3945_verify_ucode(struct il_priv *il) len = il->ucode_boot.len; rc = il3945_verify_inst_sparse(il, image, len); if (rc == 0) { - IL_DEBUG_INFO(il, "Bootstrap uCode is good in inst SRAM\n"); + D_INFO("Bootstrap uCode is good in inst SRAM\n"); return 0; } @@ -1789,7 +1789,7 @@ static int il3945_verify_ucode(struct il_priv *il) len = il->ucode_init.len; rc = il3945_verify_inst_sparse(il, image, len); if (rc == 0) { - IL_DEBUG_INFO(il, "Initialize uCode is good in inst SRAM\n"); + D_INFO("Initialize uCode is good in inst SRAM\n"); return 0; } @@ -1798,7 +1798,7 @@ static int il3945_verify_ucode(struct il_priv *il) len = il->ucode_code.len; rc = il3945_verify_inst_sparse(il, image, len); if (rc == 0) { - IL_DEBUG_INFO(il, "Runtime uCode is good in inst SRAM\n"); + D_INFO("Runtime uCode is good in inst SRAM\n"); return 0; } @@ -1879,7 +1879,7 @@ static int il3945_read_ucode(struct il_priv *il) "which is deprecated. " " Please use API v%u instead.\n", buf, api_max); - IL_DEBUG_INFO(il, "Got firmware '%s' file " + D_INFO("Got firmware '%s' file " "(%zd bytes) from disk\n", buf, ucode_raw->size); break; @@ -1940,17 +1940,17 @@ static int il3945_read_ucode(struct il_priv *il) IL_UCODE_API(il->ucode_ver), IL_UCODE_SERIAL(il->ucode_ver)); - IL_DEBUG_INFO(il, "f/w package hdr ucode version raw = 0x%x\n", + D_INFO("f/w package hdr ucode version raw = 0x%x\n", il->ucode_ver); - IL_DEBUG_INFO(il, "f/w package hdr runtime inst size = %u\n", + D_INFO("f/w package hdr runtime inst size = %u\n", inst_size); - IL_DEBUG_INFO(il, "f/w package hdr runtime data size = %u\n", + D_INFO("f/w package hdr runtime data size = %u\n", data_size); - IL_DEBUG_INFO(il, "f/w package hdr init inst size = %u\n", + D_INFO("f/w package hdr init inst size = %u\n", init_size); - IL_DEBUG_INFO(il, "f/w package hdr init data size = %u\n", + D_INFO("f/w package hdr init data size = %u\n", init_data_size); - IL_DEBUG_INFO(il, "f/w package hdr boot inst size = %u\n", + D_INFO("f/w package hdr boot inst size = %u\n", boot_size); @@ -1959,7 +1959,7 @@ static int il3945_read_ucode(struct il_priv *il) inst_size + data_size + init_size + init_data_size + boot_size) { - IL_DEBUG_INFO(il, + D_INFO( "uCode file size %zd does not match expected size\n", ucode_raw->size); ret = -EINVAL; @@ -1968,34 +1968,34 @@ static int il3945_read_ucode(struct il_priv *il) /* Verify that uCode images will fit in card's SRAM */ if (inst_size > IWL39_MAX_INST_SIZE) { - IL_DEBUG_INFO(il, "uCode instr len %d too large to fit in\n", + D_INFO("uCode instr len %d too large to fit in\n", inst_size); ret = -EINVAL; goto err_release; } if (data_size > IWL39_MAX_DATA_SIZE) { - IL_DEBUG_INFO(il, "uCode data len %d too large to fit in\n", + D_INFO("uCode data len %d too large to fit in\n", data_size); ret = -EINVAL; goto err_release; } if (init_size > IWL39_MAX_INST_SIZE) { - IL_DEBUG_INFO(il, + D_INFO( "uCode init instr len %d too large to fit in\n", init_size); ret = -EINVAL; goto err_release; } if (init_data_size > IWL39_MAX_DATA_SIZE) { - IL_DEBUG_INFO(il, + D_INFO( "uCode init data len %d too large to fit in\n", init_data_size); ret = -EINVAL; goto err_release; } if (boot_size > IWL39_MAX_BSM_SIZE) { - IL_DEBUG_INFO(il, + D_INFO( "uCode boot instr len %d too large to fit in\n", boot_size); ret = -EINVAL; @@ -2045,18 +2045,18 @@ static int il3945_read_ucode(struct il_priv *il) /* Runtime instructions (first block of data in file) */ len = inst_size; - IL_DEBUG_INFO(il, + D_INFO( "Copying (but not loading) uCode instr len %zd\n", len); memcpy(il->ucode_code.v_addr, src, len); src += len; - IL_DEBUG_INFO(il, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", + D_INFO("uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", il->ucode_code.v_addr, (u32)il->ucode_code.p_addr); /* Runtime data (2nd block) * NOTE: Copy into backup buffer will be done in il3945_up() */ len = data_size; - IL_DEBUG_INFO(il, + D_INFO( "Copying (but not loading) uCode data len %zd\n", len); memcpy(il->ucode_data.v_addr, src, len); memcpy(il->ucode_data_backup.v_addr, src, len); @@ -2065,7 +2065,7 @@ static int il3945_read_ucode(struct il_priv *il) /* Initialization instructions (3rd block) */ if (init_size) { len = init_size; - IL_DEBUG_INFO(il, + D_INFO( "Copying (but not loading) init instr len %zd\n", len); memcpy(il->ucode_init.v_addr, src, len); src += len; @@ -2074,7 +2074,7 @@ static int il3945_read_ucode(struct il_priv *il) /* Initialization data (4th block) */ if (init_data_size) { len = init_data_size; - IL_DEBUG_INFO(il, + D_INFO( "Copying (but not loading) init data len %zd\n", len); memcpy(il->ucode_init_data.v_addr, src, len); src += len; @@ -2082,7 +2082,7 @@ static int il3945_read_ucode(struct il_priv *il) /* Bootstrap instructions (5th block) */ len = boot_size; - IL_DEBUG_INFO(il, + D_INFO( "Copying (but not loading) boot instr len %zd\n", len); memcpy(il->ucode_boot.v_addr, src, len); @@ -2132,7 +2132,7 @@ static int il3945_set_ucode_ptrs(struct il_priv *il) il_write_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, il->ucode_code.len | BSM_DRAM_INST_LOAD); - IL_DEBUG_INFO(il, "Runtime uCode pointers are set.\n"); + D_INFO("Runtime uCode pointers are set.\n"); return 0; } @@ -2150,7 +2150,7 @@ static void il3945_init_alive_start(struct il_priv *il) if (il->card_alive_init.is_valid != UCODE_VALID_OK) { /* We had an error bringing up the hardware, so take it * all the way back down so we can try again */ - IL_DEBUG_INFO(il, "Initialize Alive failed.\n"); + D_INFO("Initialize Alive failed.\n"); goto restart; } @@ -2160,18 +2160,18 @@ static void il3945_init_alive_start(struct il_priv *il) if (il3945_verify_ucode(il)) { /* Runtime instruction load was bad; * take it all the way back down so we can try again */ - IL_DEBUG_INFO(il, "Bad \"initialize\" uCode load.\n"); + D_INFO("Bad \"initialize\" uCode load.\n"); goto restart; } /* Send pointers to protocol/runtime uCode image ... init code will * load and launch runtime uCode, which will send us another "Alive" * notification. */ - IL_DEBUG_INFO(il, "Initialization Alive received.\n"); + D_INFO("Initialization Alive received.\n"); if (il3945_set_ucode_ptrs(il)) { /* Runtime instruction load won't happen; * take it all the way back down so we can try again */ - IL_DEBUG_INFO(il, "Couldn't set up uCode pointers.\n"); + D_INFO("Couldn't set up uCode pointers.\n"); goto restart; } return; @@ -2191,12 +2191,12 @@ static void il3945_alive_start(struct il_priv *il) u32 rfkill; struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; - IL_DEBUG_INFO(il, "Runtime Alive received.\n"); + D_INFO("Runtime Alive received.\n"); if (il->card_alive.is_valid != UCODE_VALID_OK) { /* We had an error bringing up the hardware, so take it * all the way back down so we can try again */ - IL_DEBUG_INFO(il, "Alive failed.\n"); + D_INFO("Alive failed.\n"); goto restart; } @@ -2206,12 +2206,12 @@ static void il3945_alive_start(struct il_priv *il) if (il3945_verify_ucode(il)) { /* Runtime instruction load was bad; * take it all the way back down so we can try again */ - IL_DEBUG_INFO(il, "Bad runtime uCode load.\n"); + D_INFO("Bad runtime uCode load.\n"); goto restart; } rfkill = il_read_prph(il, APMG_RFKILL_REG); - IL_DEBUG_INFO(il, "RFKILL status: 0x%x\n", rfkill); + D_INFO("RFKILL status: 0x%x\n", rfkill); if (rfkill & 0x1) { clear_bit(STATUS_RF_KILL_HW, &il->status); @@ -2223,7 +2223,7 @@ static void il3945_alive_start(struct il_priv *il) } if (thermal_spin) - IL_DEBUG_INFO(il, "Thermal calibration took %dus\n", + D_INFO("Thermal calibration took %dus\n", thermal_spin * 10); } else set_bit(STATUS_RF_KILL_HW, &il->status); @@ -2264,7 +2264,7 @@ static void il3945_alive_start(struct il_priv *il) il3945_reg_txpower_periodic(il); - IL_DEBUG_INFO(il, "ALIVE processing complete.\n"); + D_INFO("ALIVE processing complete.\n"); wake_up(&il->wait_command_queue); return; @@ -2280,7 +2280,7 @@ static void __il3945_down(struct il_priv *il) unsigned long flags; int exit_pending; - IL_DEBUG_INFO(il, DRV_NAME " is going down\n"); + D_INFO(DRV_NAME " is going down\n"); il_scan_cancel_timeout(il, 200); @@ -2468,7 +2468,7 @@ static int __il3945_up(struct il_priv *il) /* start card; "initialize" will load runtime ucode */ il3945_nic_start(il); - IL_DEBUG_INFO(il, DRV_NAME " is coming up\n"); + D_INFO(DRV_NAME " is coming up\n"); return 0; } @@ -2540,7 +2540,7 @@ static void il3945_rfkill_poll(struct work_struct *data) wiphy_rfkill_set_hw_state(il->hw->wiphy, new_rfkill); - IL_DEBUG_RF_KILL(il, "RF_KILL bit toggled to %s.\n", + D_RF_KILL("RF_KILL bit toggled to %s.\n", new_rfkill ? "disable radio" : "enable radio"); } @@ -2571,7 +2571,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) il->scan_cmd = kmalloc(sizeof(struct il3945_scan_cmd) + IL_MAX_SCAN_SIZE, GFP_KERNEL); if (!il->scan_cmd) { - IL_DEBUG_SCAN(il, "Fail to allocate scan memory\n"); + D_SCAN("Fail to allocate scan memory\n"); return -ENOMEM; } } @@ -2587,7 +2587,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) u32 suspend_time = 100; u32 scan_suspend_time = 100; - IL_DEBUG_INFO(il, "Scanning while associated...\n"); + D_INFO("Scanning while associated...\n"); interval = vif->bss_conf.beacon_int; @@ -2607,13 +2607,13 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) (extra | ((suspend_time % interval) * 1024)); scan->suspend_time = cpu_to_le32(scan_suspend_time); - IL_DEBUG_SCAN(il, "suspend_time 0x%X beacon interval %d\n", + D_SCAN("suspend_time 0x%X beacon interval %d\n", scan_suspend_time, interval); } if (il->scan_request->n_ssids) { int i, p = 0; - IL_DEBUG_SCAN(il, "Kicking off active scan\n"); + D_SCAN("Kicking off active scan\n"); for (i = 0; i < il->scan_request->n_ssids; i++) { /* always does wildcard anyway */ if (!il->scan_request->ssids[i].ssid_len) @@ -2629,7 +2629,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) } is_active = true; } else - IL_DEBUG_SCAN(il, "Kicking off passive scan.\n"); + D_SCAN("Kicking off passive scan.\n"); /* We don't build a direct scan probe request; the uCode will do * that based on the direct_mask added to each channel entry */ @@ -2674,7 +2674,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) scan->channel_count = il3945_get_channels_for_scan(il, band, is_active, n_probes, (void *)&scan->data[len], vif); if (scan->channel_count == 0) { - IL_DEBUG_SCAN(il, "channel count %d\n", scan->channel_count); + D_SCAN("channel count %d\n", scan->channel_count); return -EIO; } @@ -2755,7 +2755,7 @@ void il3945_post_associate(struct il_priv *il) if (!ctx->vif || !il->is_open) return; - IL_DEBUG_ASSOC(il, "Associated as %d to: %pM\n", + D_ASSOC("Associated as %d to: %pM\n", ctx->vif->bss_conf.aid, ctx->active.bssid_addr); if (test_bit(STATUS_EXIT_PENDING, &il->status)) @@ -2777,7 +2777,7 @@ void il3945_post_associate(struct il_priv *il) ctx->staging.assoc_id = cpu_to_le16(ctx->vif->bss_conf.aid); - IL_DEBUG_ASSOC(il, "assoc id %d beacon interval %d\n", + D_ASSOC("assoc id %d beacon interval %d\n", ctx->vif->bss_conf.aid, ctx->vif->bss_conf.beacon_int); if (ctx->vif->bss_conf.use_short_preamble) @@ -2821,7 +2821,7 @@ static int il3945_mac_start(struct ieee80211_hw *hw) struct il_priv *il = hw->priv; int ret; - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); /* we should be verifying the device is ready to be opened */ mutex_lock(&il->mutex); @@ -2845,7 +2845,7 @@ static int il3945_mac_start(struct ieee80211_hw *hw) if (ret) goto out_release_irq; - IL_DEBUG_INFO(il, "Start UP work.\n"); + D_INFO("Start UP work.\n"); /* Wait for START_ALIVE from ucode. Otherwise callbacks from * mac80211 will not be run successfully. */ @@ -2867,12 +2867,12 @@ static int il3945_mac_start(struct ieee80211_hw *hw) cancel_delayed_work(&il->_3945.rfkill_poll); il->is_open = 1; - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); return 0; out_release_irq: il->is_open = 0; - IL_DEBUG_MAC80211(il, "leave - failed\n"); + D_MAC80211("leave - failed\n"); return ret; } @@ -2880,10 +2880,10 @@ static void il3945_mac_stop(struct ieee80211_hw *hw) { struct il_priv *il = hw->priv; - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); if (!il->is_open) { - IL_DEBUG_MAC80211(il, "leave - skip\n"); + D_MAC80211("leave - skip\n"); return; } @@ -2897,22 +2897,22 @@ static void il3945_mac_stop(struct ieee80211_hw *hw) queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, round_jiffies_relative(2 * HZ)); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); } static void il3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { struct il_priv *il = hw->priv; - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); - IL_DEBUG_TX(il, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, + D_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); if (il3945_tx_skb(il, skb)) dev_kfree_skb_any(skb); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); } void il3945_config_ap(struct il_priv *il) @@ -2971,10 +2971,10 @@ static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, u8 sta_id = IL_INVALID_STATION; u8 static_key; - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); if (il3945_mod_params.sw_crypto) { - IL_DEBUG_MAC80211(il, "leave - hwcrypto disabled\n"); + D_MAC80211("leave - hwcrypto disabled\n"); return -EOPNOTSUPP; } @@ -3004,21 +3004,21 @@ static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ret = il3945_set_static_key(il, key); else ret = il3945_set_dynamic_key(il, key, sta_id); - IL_DEBUG_MAC80211(il, "enable hwcrypto key\n"); + D_MAC80211("enable hwcrypto key\n"); break; case DISABLE_KEY: if (static_key) ret = il3945_remove_static_key(il); else ret = il3945_clear_sta_key_info(il, sta_id); - IL_DEBUG_MAC80211(il, "disable hwcrypto key\n"); + D_MAC80211("disable hwcrypto key\n"); break; default: ret = -EINVAL; } mutex_unlock(&il->mutex); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); return ret; } @@ -3033,10 +3033,10 @@ static int il3945_mac_sta_add(struct ieee80211_hw *hw, bool is_ap = vif->type == NL80211_IFTYPE_STATION; u8 sta_id; - IL_DEBUG_INFO(il, "received request to add station %pM\n", + D_INFO("received request to add station %pM\n", sta->addr); mutex_lock(&il->mutex); - IL_DEBUG_INFO(il, "proceeding to add station %pM\n", + D_INFO("proceeding to add station %pM\n", sta->addr); sta_priv->common.sta_id = IL_INVALID_STATION; @@ -3055,7 +3055,7 @@ static int il3945_mac_sta_add(struct ieee80211_hw *hw, sta_priv->common.sta_id = sta_id; /* Initialize rate scaling */ - IL_DEBUG_INFO(il, "Initializing rate scaling for station %pM\n", + D_INFO("Initializing rate scaling for station %pM\n", sta->addr); il3945_rs_rate_init(il, sta, sta_id); mutex_unlock(&il->mutex); @@ -3079,7 +3079,7 @@ static void il3945_configure_filter(struct ieee80211_hw *hw, filter_nand |= (flag); \ } while (0) - IL_DEBUG_MAC80211(il, "Enter: changed: 0x%x, total: 0x%x\n", + D_MAC80211("Enter: changed: 0x%x, total: 0x%x\n", changed_flags, *total_flags); CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); @@ -3224,7 +3224,7 @@ static ssize_t il3945_store_flags(struct device *d, if (il_scan_cancel_timeout(il, 100)) IL_WARN(il, "Could not cancel scan.\n"); else { - IL_DEBUG_INFO(il, "Committing rxon.flags = 0x%04X\n", + D_INFO("Committing rxon.flags = 0x%04X\n", flags); ctx->staging.flags = cpu_to_le32(flags); il3945_commit_rxon(il, ctx); @@ -3261,7 +3261,7 @@ static ssize_t il3945_store_filter_flags(struct device *d, if (il_scan_cancel_timeout(il, 100)) IL_WARN(il, "Could not cancel scan.\n"); else { - IL_DEBUG_INFO(il, "Committing rxon.filter_flags = " + D_INFO("Committing rxon.filter_flags = " "0x%04X\n", filter_flags); ctx->staging.filter_flags = cpu_to_le32(filter_flags); @@ -3337,7 +3337,7 @@ static ssize_t il3945_store_measurement(struct device *d, type = simple_strtoul(p + 1, NULL, 0); } - IL_DEBUG_INFO(il, "Invoking measurement of type %d on " + D_INFO("Invoking measurement of type %d on " "channel %d (for '%s')\n", type, params.channel, buf); il3945_get_measurement(il, ¶ms, type); @@ -3402,15 +3402,15 @@ static ssize_t il3945_store_antenna(struct device *d, return 0; if (sscanf(buf, "%1i", &ant) != 1) { - IL_DEBUG_INFO(il, "not in hex or decimal form.\n"); + D_INFO("not in hex or decimal form.\n"); return count; } if ((ant >= 0) && (ant <= 2)) { - IL_DEBUG_INFO(il, "Setting antenna select to %d.\n", ant); + D_INFO("Setting antenna select to %d.\n", ant); il3945_mod_params.antenna = (enum il3945_antenna)ant; } else - IL_DEBUG_INFO(il, "Bad antenna select value %d.\n", ant); + D_INFO("Bad antenna select value %d.\n", ant); return count; @@ -3682,11 +3682,11 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en * "the hard way", rather than using device's scan. */ if (il3945_mod_params.disable_hw_scan) { - IL_DEBUG_INFO(il, "Disabling hw_scan\n"); + D_INFO("Disabling hw_scan\n"); il3945_hw_ops.hw_scan = NULL; } - IL_DEBUG_INFO(il, "*** LOAD DRIVER ***\n"); + D_INFO("*** LOAD DRIVER ***\n"); il->cfg = cfg; il->pci_dev = pdev; il->inta_mask = CSR_INI_SET_MASK; @@ -3729,9 +3729,9 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en goto out_pci_release_regions; } - IL_DEBUG_INFO(il, "pci_resource_len = 0x%08llx\n", + D_INFO("pci_resource_len = 0x%08llx\n", (unsigned long long) pci_resource_len(pdev, 0)); - IL_DEBUG_INFO(il, "pci_resource_base = %p\n", il->hw_base); + D_INFO("pci_resource_base = %p\n", il->hw_base); /* We disable the RETRY_TIMEOUT register (0x41) to keep * PCI Tx retries from interfering with C3 CPU state */ @@ -3762,7 +3762,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en } /* MAC Address location in EEPROM same for 3945/4965 */ eeprom = (struct il3945_eeprom *)il->eeprom; - IL_DEBUG_INFO(il, "MAC address: %pM\n", eeprom->mac_address); + D_INFO("MAC address: %pM\n", eeprom->mac_address); SET_IEEE80211_PERM_ADDR(il->hw, eeprom->mac_address); /*********************** @@ -3873,7 +3873,7 @@ static void __devexit il3945_pci_remove(struct pci_dev *pdev) if (!il) return; - IL_DEBUG_INFO(il, "*** UNLOAD DRIVER ***\n"); + D_INFO("*** UNLOAD DRIVER ***\n"); il_dbgfs_unregister(il); diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index d4eacc3cbe7f..88dc8db3d661 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -104,7 +104,7 @@ static void il4965_clear_free_frames(struct il_priv *il) { struct list_head *element; - IL_DEBUG_INFO(il, "%d frames on pre-allocated heap on clear.\n", + D_INFO("%d frames on pre-allocated heap on clear.\n", il->frames_count); while (!list_empty(&il->free_frames)) { @@ -436,19 +436,19 @@ static void il4965_rx_reply_alive(struct il_priv *il, palive = &pkt->u.alive_frame; - IL_DEBUG_INFO(il, "Alive ucode status 0x%08X revision " + D_INFO("Alive ucode status 0x%08X revision " "0x%01X 0x%01X\n", palive->is_valid, palive->ver_type, palive->ver_subtype); if (palive->ver_subtype == INITIALIZE_SUBTYPE) { - IL_DEBUG_INFO(il, "Initialization Alive received.\n"); + D_INFO("Initialization Alive received.\n"); memcpy(&il->card_alive_init, &pkt->u.alive_frame, sizeof(struct il_init_alive_resp)); pwork = &il->init_alive_start; } else { - IL_DEBUG_INFO(il, "Runtime Alive received.\n"); + D_INFO("Runtime Alive received.\n"); memcpy(&il->card_alive, &pkt->u.alive_frame, sizeof(struct il_alive_resp)); pwork = &il->alive_start; @@ -496,7 +496,7 @@ static void il4965_rx_beacon_notif(struct il_priv *il, #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG u8 rate = il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); - IL_DEBUG_RX(il, "beacon status %x retries %d iss %d " + D_RX("beacon status %x retries %d iss %d " "tsf %d %d rate %d\n", le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, beacon->beacon_notify_hdr.failure_frame, @@ -512,7 +512,7 @@ static void il4965_perform_ct_kill_task(struct il_priv *il) { unsigned long flags; - IL_DEBUG_POWER(il, "Stop all queues\n"); + D_POWER("Stop all queues\n"); if (il->mac80211_registered) ieee80211_stop_queues(il->hw); @@ -536,7 +536,7 @@ static void il4965_rx_card_state_notif(struct il_priv *il, u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); unsigned long status = il->status; - IL_DEBUG_RF_KILL(il, "Card state received: HW:%s SW:%s CT:%s\n", + D_RF_KILL("Card state received: HW:%s SW:%s CT:%s\n", (flags & HW_CARD_DISABLED) ? "Kill" : "On", (flags & SW_CARD_DISABLED) ? "Kill" : "On", (flags & CT_CARD_DISABLED) ? @@ -650,7 +650,7 @@ void il4965_rx_handle(struct il_priv *il) /* Rx interrupt, but nothing sent from uCode */ if (i == r) - IL_DEBUG_RX(il, "r = %d, i = %d\n", r, i); + D_RX("r = %d, i = %d\n", r, i); /* calculate total frames need to be restock after handling RX */ total_empty = r - rxq->write_actual; @@ -698,14 +698,14 @@ void il4965_rx_handle(struct il_priv *il) * handle those that need handling via function in * rx_handlers table. See il4965_setup_rx_handlers() */ if (il->rx_handlers[pkt->hdr.cmd]) { - IL_DEBUG_RX(il, "r = %d, i = %d, %s, 0x%02x\n", r, + D_RX("r = %d, i = %d, %s, 0x%02x\n", r, i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); il->isr_stats.rx_handlers[pkt->hdr.cmd]++; il->rx_handlers[pkt->hdr.cmd] (il, rxb); } else { /* No handling needed */ - IL_DEBUG_RX(il, + D_RX( "r %d i %d No handler needed for %s, 0x%02x\n", r, i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); @@ -800,7 +800,7 @@ static void il4965_irq_tasklet(struct il_priv *il) if (il_get_debug_level(il) & IL_DL_ISR) { /* just for debug */ inta_mask = il_read32(il, CSR_INT_MASK); - IL_DEBUG_ISR(il, "inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", + D_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, inta_mask, inta_fh); } #endif @@ -835,14 +835,14 @@ static void il4965_irq_tasklet(struct il_priv *il) if (il_get_debug_level(il) & (IL_DL_ISR)) { /* NIC fires this, but we don't use it, redundant with WAKEUP */ if (inta & CSR_INT_BIT_SCD) { - IL_DEBUG_ISR(il, "Scheduler finished to transmit " + D_ISR("Scheduler finished to transmit " "the frame/frames.\n"); il->isr_stats.sch++; } /* Alive notification via Rx interrupt will do the real work */ if (inta & CSR_INT_BIT_ALIVE) { - IL_DEBUG_ISR(il, "Alive interrupt\n"); + D_ISR("Alive interrupt\n"); il->isr_stats.alive++; } } @@ -900,7 +900,7 @@ static void il4965_irq_tasklet(struct il_priv *il) * and about any Rx buffers made available while asleep. */ if (inta & CSR_INT_BIT_WAKEUP) { - IL_DEBUG_ISR(il, "Wakeup interrupt\n"); + D_ISR("Wakeup interrupt\n"); il_rx_queue_update_write_ptr(il, &il->rxq); for (i = 0; i < il->hw_params.max_txq_num; i++) il_txq_update_write_ptr(il, &il->txq[i]); @@ -919,7 +919,7 @@ static void il4965_irq_tasklet(struct il_priv *il) /* This "Tx" DMA channel is used only for loading uCode */ if (inta & CSR_INT_BIT_FH_TX) { - IL_DEBUG_ISR(il, "uCode load interrupt\n"); + D_ISR("uCode load interrupt\n"); il->isr_stats.tx++; handled |= CSR_INT_BIT_FH_TX; /* Wake up uCode load routine, now that load is complete */ @@ -951,7 +951,7 @@ static void il4965_irq_tasklet(struct il_priv *il) inta = il_read32(il, CSR_INT); inta_mask = il_read32(il, CSR_INT_MASK); inta_fh = il_read32(il, CSR_FH_INT_STATUS); - IL_DEBUG_ISR(il, + D_ISR( "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); } @@ -1120,7 +1120,7 @@ static int __must_check il4965_request_firmware(struct il_priv *il, bool first) sprintf(il->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); - IL_DEBUG_INFO(il, "attempting to load firmware '%s'\n", + D_INFO("attempting to load firmware '%s'\n", il->firmware_name); return request_firmware_nowait(THIS_MODULE, 1, il->firmware_name, @@ -1220,7 +1220,7 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) goto try_again; } - IL_DEBUG_INFO(il, "Loaded firmware file '%s' (%zd bytes).\n", + D_INFO("Loaded firmware file '%s' (%zd bytes).\n", il->firmware_name, ucode_raw->size); /* Make sure that we got at least the API version number */ @@ -1279,17 +1279,17 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) * user just got a corrupted version of the latest API. */ - IL_DEBUG_INFO(il, "f/w package hdr ucode version raw = 0x%x\n", + D_INFO("f/w package hdr ucode version raw = 0x%x\n", il->ucode_ver); - IL_DEBUG_INFO(il, "f/w package hdr runtime inst size = %Zd\n", + D_INFO("f/w package hdr runtime inst size = %Zd\n", pieces.inst_size); - IL_DEBUG_INFO(il, "f/w package hdr runtime data size = %Zd\n", + D_INFO("f/w package hdr runtime data size = %Zd\n", pieces.data_size); - IL_DEBUG_INFO(il, "f/w package hdr init inst size = %Zd\n", + D_INFO("f/w package hdr init inst size = %Zd\n", pieces.init_size); - IL_DEBUG_INFO(il, "f/w package hdr init data size = %Zd\n", + D_INFO("f/w package hdr init data size = %Zd\n", pieces.init_data_size); - IL_DEBUG_INFO(il, "f/w package hdr boot inst size = %Zd\n", + D_INFO("f/w package hdr boot inst size = %Zd\n", pieces.boot_size); /* Verify that uCode images will fit in card's SRAM */ @@ -1369,25 +1369,25 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) /* Copy images into buffers for card's bus-master reads ... */ /* Runtime instructions (first block of data in file) */ - IL_DEBUG_INFO(il, "Copying (but not loading) uCode instr len %Zd\n", + D_INFO("Copying (but not loading) uCode instr len %Zd\n", pieces.inst_size); memcpy(il->ucode_code.v_addr, pieces.inst, pieces.inst_size); - IL_DEBUG_INFO(il, "uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", + D_INFO("uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", il->ucode_code.v_addr, (u32)il->ucode_code.p_addr); /* * Runtime data * NOTE: Copy into backup buffer will be done in il_up() */ - IL_DEBUG_INFO(il, "Copying (but not loading) uCode data len %Zd\n", + D_INFO("Copying (but not loading) uCode data len %Zd\n", pieces.data_size); memcpy(il->ucode_data.v_addr, pieces.data, pieces.data_size); memcpy(il->ucode_data_backup.v_addr, pieces.data, pieces.data_size); /* Initialization instructions */ if (pieces.init_size) { - IL_DEBUG_INFO(il, + D_INFO( "Copying (but not loading) init instr len %Zd\n", pieces.init_size); memcpy(il->ucode_init.v_addr, pieces.init, pieces.init_size); @@ -1395,7 +1395,7 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) /* Initialization data */ if (pieces.init_data_size) { - IL_DEBUG_INFO(il, + D_INFO( "Copying (but not loading) init data len %Zd\n", pieces.init_data_size); memcpy(il->ucode_init_data.v_addr, pieces.init_data, @@ -1403,7 +1403,7 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) } /* Bootstrap instructions */ - IL_DEBUG_INFO(il, "Copying (but not loading) boot instr len %Zd\n", + D_INFO("Copying (but not loading) boot instr len %Zd\n", pieces.boot_size); memcpy(il->ucode_boot.v_addr, pieces.boot, pieces.boot_size); @@ -1596,7 +1596,7 @@ static void il4965_rf_kill_ct_config(struct il_priv *il) if (ret) IL_ERR(il, "REPLY_CT_KILL_CONFIG_CMD failed\n"); else - IL_DEBUG_INFO(il, "REPLY_CT_KILL_CONFIG_CMD " + D_INFO("REPLY_CT_KILL_CONFIG_CMD " "succeeded, " "critical temperature is %d\n", il->hw_params.ct_kill_threshold); @@ -1719,12 +1719,12 @@ static void il4965_alive_start(struct il_priv *il) int ret = 0; struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; - IL_DEBUG_INFO(il, "Runtime Alive received.\n"); + D_INFO("Runtime Alive received.\n"); if (il->card_alive.is_valid != UCODE_VALID_OK) { /* We had an error bringing up the hardware, so take it * all the way back down so we can try again */ - IL_DEBUG_INFO(il, "Alive failed.\n"); + D_INFO("Alive failed.\n"); goto restart; } @@ -1734,7 +1734,7 @@ static void il4965_alive_start(struct il_priv *il) if (il4965_verify_ucode(il)) { /* Runtime instruction load was bad; * take it all the way back down so we can try again */ - IL_DEBUG_INFO(il, "Bad runtime uCode load.\n"); + D_INFO("Bad runtime uCode load.\n"); goto restart; } @@ -1788,11 +1788,11 @@ static void il4965_alive_start(struct il_priv *il) /* At this point, the NIC is initialized and operational */ il4965_rf_kill_ct_config(il); - IL_DEBUG_INFO(il, "ALIVE processing complete.\n"); + D_INFO("ALIVE processing complete.\n"); wake_up(&il->wait_command_queue); il_power_update_mode(il, true); - IL_DEBUG_INFO(il, "Updated power mode\n"); + D_INFO("Updated power mode\n"); return; @@ -1807,7 +1807,7 @@ static void __il4965_down(struct il_priv *il) unsigned long flags; int exit_pending; - IL_DEBUG_INFO(il, DRV_NAME " is going down\n"); + D_INFO(DRV_NAME " is going down\n"); il_scan_cancel_timeout(il, 200); @@ -1916,7 +1916,7 @@ static int il4965_set_hw_ready(struct il_priv *il) else il->hw_ready = false; - IL_DEBUG_INFO(il, "hardware %s\n", + D_INFO("hardware %s\n", (il->hw_ready == 1) ? "ready" : "not ready"); return ret; } @@ -1925,7 +1925,7 @@ static int il4965_prepare_card_hw(struct il_priv *il) { int ret = 0; - IL_DEBUG_INFO(il, "il4965_prepare_card_hw enter\n"); + D_INFO("il4965_prepare_card_hw enter\n"); ret = il4965_set_hw_ready(il); if (il->hw_ready) @@ -2040,7 +2040,7 @@ static int __il4965_up(struct il_priv *il) /* start card; "initialize" will load runtime ucode */ il4965_nic_start(il); - IL_DEBUG_INFO(il, DRV_NAME " is coming up\n"); + D_INFO(DRV_NAME " is coming up\n"); return 0; } @@ -2243,7 +2243,7 @@ int il4965_mac_start(struct ieee80211_hw *hw) struct il_priv *il = hw->priv; int ret; - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); /* we should be verifying the device is ready to be opened */ mutex_lock(&il->mutex); @@ -2256,7 +2256,7 @@ int il4965_mac_start(struct ieee80211_hw *hw) if (il_is_rfkill(il)) goto out; - IL_DEBUG_INFO(il, "Start UP work done.\n"); + D_INFO("Start UP work done.\n"); /* Wait for START_ALIVE from Run Time ucode. Otherwise callbacks from * mac80211 will not be run successfully. */ @@ -2275,7 +2275,7 @@ int il4965_mac_start(struct ieee80211_hw *hw) out: il->is_open = 1; - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); return 0; } @@ -2283,7 +2283,7 @@ void il4965_mac_stop(struct ieee80211_hw *hw) { struct il_priv *il = hw->priv; - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); if (!il->is_open) return; @@ -2299,22 +2299,22 @@ void il4965_mac_stop(struct ieee80211_hw *hw) il_write32(il, CSR_INT, 0xFFFFFFFF); il_enable_rfkill_int(il); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); } void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { struct il_priv *il = hw->priv; - IL_DEBUG_MACDUMP(il, "enter\n"); + D_MACDUMP("enter\n"); - IL_DEBUG_TX(il, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, + D_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); if (il4965_tx_skb(il, skb)) dev_kfree_skb_any(skb); - IL_DEBUG_MACDUMP(il, "leave\n"); + D_MACDUMP("leave\n"); } void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, @@ -2326,12 +2326,12 @@ void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, struct il_priv *il = hw->priv; struct il_vif_priv *vif_priv = (void *)vif->drv_priv; - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); il4965_update_tkip_key(il, vif_priv->ctx, keyconf, sta, iv32, phase1key); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); } int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, @@ -2345,10 +2345,10 @@ int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, u8 sta_id; bool is_default_wep_key = false; - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); if (il->cfg->mod_params->sw_crypto) { - IL_DEBUG_MAC80211(il, "leave - hwcrypto disabled\n"); + D_MAC80211("leave - hwcrypto disabled\n"); return -EOPNOTSUPP; } @@ -2384,7 +2384,7 @@ int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ret = il4965_set_dynamic_key(il, vif_priv->ctx, key, sta_id); - IL_DEBUG_MAC80211(il, "enable hwcrypto key\n"); + D_MAC80211("enable hwcrypto key\n"); break; case DISABLE_KEY: if (is_default_wep_key) @@ -2393,14 +2393,14 @@ int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ret = il4965_remove_dynamic_key(il, ctx, key, sta_id); - IL_DEBUG_MAC80211(il, "disable hwcrypto key\n"); + D_MAC80211("disable hwcrypto key\n"); break; default: ret = -EINVAL; } mutex_unlock(&il->mutex); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); return ret; } @@ -2414,7 +2414,7 @@ int il4965_mac_ampdu_action(struct ieee80211_hw *hw, struct il_priv *il = hw->priv; int ret = -EINVAL; - IL_DEBUG_HT(il, "A-MPDU action on addr %pM tid %d\n", + D_HT("A-MPDU action on addr %pM tid %d\n", sta->addr, tid); if (!(il->cfg->sku & IL_SKU_N)) @@ -2424,21 +2424,21 @@ int il4965_mac_ampdu_action(struct ieee80211_hw *hw, switch (action) { case IEEE80211_AMPDU_RX_START: - IL_DEBUG_HT(il, "start Rx\n"); + D_HT("start Rx\n"); ret = il4965_sta_rx_agg_start(il, sta, tid, *ssn); break; case IEEE80211_AMPDU_RX_STOP: - IL_DEBUG_HT(il, "stop Rx\n"); + D_HT("stop Rx\n"); ret = il4965_sta_rx_agg_stop(il, sta, tid); if (test_bit(STATUS_EXIT_PENDING, &il->status)) ret = 0; break; case IEEE80211_AMPDU_TX_START: - IL_DEBUG_HT(il, "start Tx\n"); + D_HT("start Tx\n"); ret = il4965_tx_agg_start(il, vif, sta, tid, ssn); break; case IEEE80211_AMPDU_TX_STOP: - IL_DEBUG_HT(il, "stop Tx\n"); + D_HT("stop Tx\n"); ret = il4965_tx_agg_stop(il, vif, sta, tid); if (test_bit(STATUS_EXIT_PENDING, &il->status)) ret = 0; @@ -2463,10 +2463,10 @@ int il4965_mac_sta_add(struct ieee80211_hw *hw, int ret; u8 sta_id; - IL_DEBUG_INFO(il, "received request to add station %pM\n", + D_INFO("received request to add station %pM\n", sta->addr); mutex_lock(&il->mutex); - IL_DEBUG_INFO(il, "proceeding to add station %pM\n", + D_INFO("proceeding to add station %pM\n", sta->addr); sta_priv->common.sta_id = IL_INVALID_STATION; @@ -2485,7 +2485,7 @@ int il4965_mac_sta_add(struct ieee80211_hw *hw, sta_priv->common.sta_id = sta_id; /* Initialize rate scaling */ - IL_DEBUG_INFO(il, "Initializing rate scaling for station %pM\n", + D_INFO("Initializing rate scaling for station %pM\n", sta->addr); il4965_rs_rate_init(il, sta, sta_id); mutex_unlock(&il->mutex); @@ -2505,7 +2505,7 @@ void il4965_mac_channel_switch(struct ieee80211_hw *hw, struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; u16 ch; - IL_DEBUG_MAC80211(il, "enter\n"); + D_MAC80211("enter\n"); mutex_lock(&il->mutex); @@ -2529,7 +2529,7 @@ void il4965_mac_channel_switch(struct ieee80211_hw *hw, ch_info = il_get_channel_info(il, channel->band, ch); if (!il_is_channel_valid(ch_info)) { - IL_DEBUG_MAC80211(il, "invalid channel\n"); + D_MAC80211("invalid channel\n"); goto out; } @@ -2580,7 +2580,7 @@ void il4965_mac_channel_switch(struct ieee80211_hw *hw, out: mutex_unlock(&il->mutex); - IL_DEBUG_MAC80211(il, "leave\n"); + D_MAC80211("leave\n"); } void il4965_configure_filter(struct ieee80211_hw *hw, @@ -2599,7 +2599,7 @@ void il4965_configure_filter(struct ieee80211_hw *hw, filter_nand |= (flag); \ } while (0) - IL_DEBUG_MAC80211(il, "Enter: changed: 0x%x, total: 0x%x\n", + D_MAC80211("Enter: changed: 0x%x, total: 0x%x\n", changed_flags, *total_flags); CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); @@ -2755,7 +2755,7 @@ void il4965_tx_queue_set_status(struct il_priv *il, txq->sched_retry = scd_retry; - IL_DEBUG_INFO(il, "%s %s Queue %d on AC %d\n", + D_INFO("%s %s Queue %d on AC %d\n", active ? "Activate" : "Deactivate", scd_retry ? "BA" : "AC", txq_id, tx_fifo_id); } @@ -2824,7 +2824,7 @@ static void il4965_hw_detect(struct il_priv *il) il->hw_rev = _il_read32(il, CSR_HW_REV); il->hw_wa_rev = _il_read32(il, CSR_HW_REV_WA_REG); il->rev_id = il->pci_dev->revision; - IL_DEBUG_INFO(il, "HW Revision ID = 0x%X\n", il->rev_id); + D_INFO("HW Revision ID = 0x%X\n", il->rev_id); } static int il4965_set_hw_params(struct il_priv *il) @@ -2911,7 +2911,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) SET_IEEE80211_DEV(hw, &pdev->dev); - IL_DEBUG_INFO(il, "*** LOAD DRIVER ***\n"); + D_INFO("*** LOAD DRIVER ***\n"); il->cfg = cfg; il->pci_dev = pdev; il->inta_mask = CSR_INI_SET_MASK; @@ -2963,9 +2963,9 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto out_pci_release_regions; } - IL_DEBUG_INFO(il, "pci_resource_len = 0x%08llx\n", + D_INFO("pci_resource_len = 0x%08llx\n", (unsigned long long) pci_resource_len(pdev, 0)); - IL_DEBUG_INFO(il, "pci_resource_base = %p\n", il->hw_base); + D_INFO("pci_resource_base = %p\n", il->hw_base); /* these spin locks will be used in apm_ops.init and EEPROM access * we should init now @@ -3012,7 +3012,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) /* extract MAC Address */ il4965_eeprom_get_mac(il, il->addresses[0].addr); - IL_DEBUG_INFO(il, "MAC address: %pM\n", il->addresses[0].addr); + D_INFO("MAC address: %pM\n", il->addresses[0].addr); il->hw->wiphy->addresses = il->addresses; il->hw->wiphy->n_addresses = 1; @@ -3118,7 +3118,7 @@ static void __devexit il4965_pci_remove(struct pci_dev *pdev) wait_for_completion(&il->_4965.firmware_loading_complete); - IL_DEBUG_INFO(il, "*** UNLOAD DRIVER ***\n"); + D_INFO("*** UNLOAD DRIVER ***\n"); il_dbgfs_unregister(il); sysfs_remove_group(&pdev->dev.kobj, &il_attribute_group); -- cgit v1.2.3 From 9406f79775a5374b932ac45ae9e84a71032a9d33 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Thu, 18 Aug 2011 22:07:57 +0200 Subject: iwlegacy: remove il argument from IWL_ERR/INFO/WARN/CRIT Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c | 6 +- drivers/net/wireless/iwlegacy/iwl-3945.c | 48 ++++----- drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c | 6 +- drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c | 4 +- drivers/net/wireless/iwlegacy/iwl-4965-lib.c | 16 +-- drivers/net/wireless/iwlegacy/iwl-4965-rs.c | 22 ++-- drivers/net/wireless/iwlegacy/iwl-4965-sta.c | 22 ++-- drivers/net/wireless/iwlegacy/iwl-4965-tx.c | 32 +++--- drivers/net/wireless/iwlegacy/iwl-4965-ucode.c | 4 +- drivers/net/wireless/iwlegacy/iwl-4965.c | 50 ++++----- drivers/net/wireless/iwlegacy/iwl-core.c | 64 +++++------ drivers/net/wireless/iwlegacy/iwl-debug.h | 8 +- drivers/net/wireless/iwlegacy/iwl-debugfs.c | 24 ++--- drivers/net/wireless/iwlegacy/iwl-eeprom.c | 10 +- drivers/net/wireless/iwlegacy/iwl-hcmd.c | 14 +-- drivers/net/wireless/iwlegacy/iwl-io.h | 2 +- drivers/net/wireless/iwlegacy/iwl-led.c | 2 +- drivers/net/wireless/iwlegacy/iwl-power.c | 2 +- drivers/net/wireless/iwlegacy/iwl-scan.c | 2 +- drivers/net/wireless/iwlegacy/iwl-sta.c | 26 ++--- drivers/net/wireless/iwlegacy/iwl-tx.c | 12 +-- drivers/net/wireless/iwlegacy/iwl3945-base.c | 130 +++++++++++----------- drivers/net/wireless/iwlegacy/iwl4965-base.c | 132 +++++++++++------------ 23 files changed, 319 insertions(+), 319 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c index b767979c5dbb..40e3a7065f23 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c @@ -71,7 +71,7 @@ ssize_t il3945_ucode_rx_stats_read(struct file *file, buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(il, "Can not allocate Buffer\n"); + IL_ERR("Can not allocate Buffer\n"); return -ENOMEM; } @@ -341,7 +341,7 @@ ssize_t il3945_ucode_tx_stats_read(struct file *file, buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(il, "Can not allocate Buffer\n"); + IL_ERR("Can not allocate Buffer\n"); return -ENOMEM; } @@ -440,7 +440,7 @@ ssize_t il3945_ucode_general_stats_read(struct file *file, buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(il, "Can not allocate Buffer\n"); + IL_ERR("Can not allocate Buffer\n"); return -ENOMEM; } diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index a1e2a4218968..cf47fdb28aa1 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -166,7 +166,7 @@ void il3945_disable_events(struct il_priv *il) base = le32_to_cpu(il->card_alive.log_event_table_ptr); if (!il3945_hw_valid_rtc_data_addr(base)) { - IL_ERR(il, "Invalid event log pointer 0x%08X\n", base); + IL_ERR("Invalid event log pointer 0x%08X\n", base); return; } @@ -317,7 +317,7 @@ static void il3945_rx_reply_tx(struct il_priv *il, int fail; if ((index >= txq->q.n_bd) || (il_queue_used(&txq->q, index) == 0)) { - IL_ERR(il, "Read index for DMA queue txq_id (%d) index %d " + IL_ERR("Read index for DMA queue txq_id (%d) index %d " "is out of range [0-%d] %d %d\n", txq_id, index, txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr); @@ -350,7 +350,7 @@ static void il3945_rx_reply_tx(struct il_priv *il, il3945_tx_queue_reclaim(il, txq_id, index); if (status & TX_ABORT_REQUIRED_MSK) - IL_ERR(il, "TODO: Implement Tx ABORT REQUIRED!!!\n"); + IL_ERR("TODO: Implement Tx ABORT REQUIRED!!!\n"); } @@ -484,7 +484,7 @@ static void il3945_pass_packet_to_mac80211(struct il_priv *il, skb = dev_alloc_skb(128); if (!skb) { - IL_ERR(il, "dev_alloc_skb failed\n"); + IL_ERR("dev_alloc_skb failed\n"); return; } @@ -600,7 +600,7 @@ int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, count = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags)); if ((count >= NUM_TFD_CHUNKS) || (count < 0)) { - IL_ERR(il, "Error can not send more than %d chunks\n", + IL_ERR("Error can not send more than %d chunks\n", NUM_TFD_CHUNKS); return -EINVAL; } @@ -633,7 +633,7 @@ void il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) /* sanity check */ counter = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags)); if (counter > NUM_TFD_CHUNKS) { - IL_ERR(il, "Too many chunks: %i\n", counter); + IL_ERR("Too many chunks: %i\n", counter); /* @todo issue fatal error, it is quite serious situation */ return; } @@ -855,7 +855,7 @@ static int il3945_txq_ctx_reset(struct il_priv *il) rc = il_tx_queue_init(il, &il->txq[txq_id], slots_num, txq_id); if (rc) { - IL_ERR(il, "Tx %d queue init failed\n", txq_id); + IL_ERR("Tx %d queue init failed\n", txq_id); goto error; } } @@ -971,7 +971,7 @@ int il3945_hw_nic_init(struct il_priv *il) if (!rxq->bd) { rc = il_rx_queue_alloc(il); if (rc) { - IL_ERR(il, "Unable to initialize Rx queue\n"); + IL_ERR("Unable to initialize Rx queue\n"); return -ENOMEM; } } else @@ -1078,7 +1078,7 @@ static int il3945_hw_reg_txpower_get_temperature(struct il_priv *il) /* handle insane temp reading */ if (il3945_hw_reg_temp_out_of_range(temperature)) { - IL_ERR(il, "Error bad temperature value %d\n", temperature); + IL_ERR("Error bad temperature value %d\n", temperature); /* if really really hot(?), * substitute the 3rd band/group's temp measured at factory */ @@ -1388,7 +1388,7 @@ static int il3945_send_tx_power(struct il_priv *il) txpower.band = (il->band == IEEE80211_BAND_5GHZ) ? 0 : 1; ch_info = il_get_channel_info(il, il->band, chan); if (!ch_info) { - IL_ERR(il, + IL_ERR( "Failed to get channel info for channel %d [%d]\n", chan, il->band); return -EINVAL; @@ -1686,7 +1686,7 @@ static int il3945_send_rxon_assoc(struct il_priv *il, pkt = (struct il_rx_packet *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR(il, "Bad return from REPLY_RXON_ASSOC command\n"); + IL_ERR("Bad return from REPLY_RXON_ASSOC command\n"); rc = -EIO; } @@ -1727,7 +1727,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) rc = il_check_rxon_cmd(il, ctx); if (rc) { - IL_ERR(il, "Invalid RXON configuration. Not committing.\n"); + IL_ERR("Invalid RXON configuration. Not committing.\n"); return -EINVAL; } @@ -1739,7 +1739,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) rc = il_send_rxon_assoc(il, &il->contexts[IL_RXON_CTX_BSS]); if (rc) { - IL_ERR(il, "Error setting RXON_ASSOC " + IL_ERR("Error setting RXON_ASSOC " "configuration (%d).\n", rc); return rc; } @@ -1775,7 +1775,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) * active_rxon back to what it was previously */ if (rc) { active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK; - IL_ERR(il, "Error clearing ASSOC_MSK on current " + IL_ERR("Error clearing ASSOC_MSK on current " "configuration (%d).\n", rc); return rc; } @@ -1807,7 +1807,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) sizeof(struct il3945_rxon_cmd), staging_rxon); if (rc) { - IL_ERR(il, "Error setting new configuration (%d).\n", rc); + IL_ERR("Error setting new configuration (%d).\n", rc); return rc; } @@ -1824,14 +1824,14 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) * send a new TXPOWER command or we won't be able to Tx any frames */ rc = il_set_tx_power(il, il->tx_power_next, true); if (rc) { - IL_ERR(il, "Error setting Tx power (%d).\n", rc); + IL_ERR("Error setting Tx power (%d).\n", rc); return rc; } /* Init the hardware's rate fallback order based on the band */ rc = il3945_init_hw_rate_table(il); if (rc) { - IL_ERR(il, "Error setting HW rate table: %02X\n", rc); + IL_ERR("Error setting HW rate table: %02X\n", rc); return -EIO; } @@ -1989,7 +1989,7 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *il) /* sanity check on factory saturation power value */ if (group->saturation_power < 40) { - IL_WARN(il, "Error: saturation power is %d, " + IL_WARN("Error: saturation power is %d, " "less than minimum expected 40\n", group->saturation_power); return; @@ -2119,7 +2119,7 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) ch_info->group_index, &power_idx); if (rc) { - IL_ERR(il, "Invalid power index\n"); + IL_ERR("Invalid power index\n"); return rc; } pwr_info->base_power_index = (u8) power_idx; @@ -2187,7 +2187,7 @@ int il3945_hw_rxq_stop(struct il_priv *il) rc = il_poll_direct_bit(il, FH39_RSSR_STATUS, FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); if (rc < 0) - IL_ERR(il, "Can't stop Rx DMA.\n"); + IL_ERR("Can't stop Rx DMA.\n"); return 0; } @@ -2263,7 +2263,7 @@ static int il3945_add_bssid_station(struct il_priv *il, ret = il_add_station_common(il, ctx, addr, 0, NULL, &sta_id); if (ret) { - IL_ERR(il, "Unable to add station %pM\n", addr); + IL_ERR("Unable to add station %pM\n", addr); return ret; } @@ -2390,7 +2390,7 @@ int il3945_hw_set_hw_params(struct il_priv *il) sizeof(struct il3945_shared), &il->_3945.shared_phys, GFP_KERNEL); if (!il->_3945.shared_virt) { - IL_ERR(il, "failed to allocate pci memory\n"); + IL_ERR("failed to allocate pci memory\n"); return -ENOMEM; } @@ -2481,7 +2481,7 @@ static int il3945_verify_bsm(struct il_priv *il) reg += sizeof(u32), image++) { val = il_read_prph(il, reg); if (val != le32_to_cpu(*image)) { - IL_ERR(il, "BSM uCode verification failed at " + IL_ERR("BSM uCode verification failed at " "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", BSM_SRAM_LOWER_BOUND, reg - BSM_SRAM_LOWER_BOUND, len, @@ -2620,7 +2620,7 @@ static int il3945_load_bsm(struct il_priv *il) if (i < 100) D_INFO("BSM write complete, poll %d iterations\n", i); else { - IL_ERR(il, "BSM write did not complete!\n"); + IL_ERR("BSM write did not complete!\n"); return -EIO; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c index 8ea0ac205f7f..ebb71a685101 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c @@ -75,7 +75,7 @@ ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(il, "Can not allocate Buffer\n"); + IL_ERR("Can not allocate Buffer\n"); return -ENOMEM; } @@ -501,7 +501,7 @@ ssize_t il4965_ucode_tx_stats_read(struct file *file, buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(il, "Can not allocate Buffer\n"); + IL_ERR("Can not allocate Buffer\n"); return -ENOMEM; } @@ -679,7 +679,7 @@ il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(il, "Can not allocate Buffer\n"); + IL_ERR("Can not allocate Buffer\n"); return -ENOMEM; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c index ef8b0d5f2e07..016472dadf3a 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c @@ -129,12 +129,12 @@ int il4965_eeprom_check_version(struct il_priv *il) calib_ver < il->cfg->eeprom_calib_ver) goto err; - IL_INFO(il, "device EEPROM VER=0x%x, CALIB=0x%x\n", + IL_INFO("device EEPROM VER=0x%x, CALIB=0x%x\n", eeprom_ver, calib_ver); return 0; err: - IL_ERR(il, "Unsupported (too old) EEPROM VER=0x%x < 0x%x " + IL_ERR("Unsupported (too old) EEPROM VER=0x%x < 0x%x " "CALIB=0x%x < 0x%x\n", eeprom_ver, il->cfg->eeprom_ver, calib_ver, il->cfg->eeprom_calib_ver); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index b51ae3d63b79..f4df28d5973c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -44,7 +44,7 @@ void il4965_check_abort_status(struct il_priv *il, u8 frame_count, u32 status) { if (frame_count == 1 && status == TX_STATUS_FAIL_RFKILL_FLUSH) { - IL_ERR(il, "Tx flush command to flush out all frames\n"); + IL_ERR("Tx flush command to flush out all frames\n"); if (!test_bit(STATUS_EXIT_PENDING, &il->status)) queue_work(il->workqueue, &il->tx_flush); } @@ -176,7 +176,7 @@ int il4965_hw_nic_init(struct il_priv *il) if (!rxq->bd) { ret = il_rx_queue_alloc(il); if (ret) { - IL_ERR(il, "Unable to initialize Rx queue\n"); + IL_ERR("Unable to initialize Rx queue\n"); return -ENOMEM; } } else @@ -309,7 +309,7 @@ static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) if ((rxq->free_count <= RX_LOW_WATERMARK) && net_ratelimit()) - IL_CRIT(il, + IL_CRIT( "Failed to alloc_pages with %s. " "Only %u free buffers remaining.\n", priority == GFP_ATOMIC ? @@ -549,7 +549,7 @@ static void il4965_pass_packet_to_mac80211(struct il_priv *il, skb = dev_alloc_skb(128); if (!skb) { - IL_ERR(il, "dev_alloc_skb failed\n"); + IL_ERR("dev_alloc_skb failed\n"); return; } @@ -598,7 +598,7 @@ void il4965_rx_reply_rx(struct il_priv *il, ampdu_status = le32_to_cpu(rx_pkt_status); } else { if (!il->_4965.last_phy_res_valid) { - IL_ERR(il, "MPDU frame without cached PHY data\n"); + IL_ERR("MPDU frame without cached PHY data\n"); return; } phy_res = &il->_4965.last_phy_res; @@ -880,7 +880,7 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) rate = IL_RATE_6M_PLCP; break; default: - IL_WARN(il, "Invalid scan band\n"); + IL_WARN("Invalid scan band\n"); return -EIO; } @@ -1184,9 +1184,9 @@ int il4965_dump_fh(struct il_priv *il, char **buf, bool display) return pos; } #endif - IL_ERR(il, "FH register values:\n"); + IL_ERR("FH register values:\n"); for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { - IL_ERR(il, " %34s: 0X%08x\n", + IL_ERR(" %34s: 0X%08x\n", il4965_get_fh_string(fh_tbl[i]), il_read_direct32(il, fh_tbl[i])); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index b53cf1b70c30..93bb31d628b6 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -367,12 +367,12 @@ static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *il, * this might be cause by reloading firmware * stop the tx ba session here */ - IL_ERR(il, "Fail start Tx agg on tid: %d\n", + IL_ERR("Fail start Tx agg on tid: %d\n", tid); ieee80211_stop_tx_ba_session(sta, tid); } } else { - IL_ERR(il, "Aggregation not enabled for tid %d " + IL_ERR("Aggregation not enabled for tid %d " "because load = %u\n", tid, load); } return ret; @@ -385,7 +385,7 @@ static void il4965_rs_tl_turn_on_agg(struct il_priv *il, u8 tid, if (tid < TID_MAX_LOAD_COUNT) il4965_rs_tl_turn_on_agg_for_tid(il, lq_data, tid, sta); else - IL_ERR(il, "tid exceeds max load count: %d/%d\n", + IL_ERR("tid exceeds max load count: %d/%d\n", tid, TID_MAX_LOAD_COUNT); } @@ -505,7 +505,7 @@ static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, } else if (is_Ht(tbl->lq_type)) { if (index > IL_LAST_OFDM_RATE) { - IL_ERR(il, "Invalid HT rate index %d\n", index); + IL_ERR("Invalid HT rate index %d\n", index); index = IL_LAST_OFDM_RATE; } rate_n_flags = RATE_MCS_HT_MSK; @@ -515,7 +515,7 @@ static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, else rate_n_flags |= il_rates[index].plcp_mimo2; } else { - IL_ERR(il, "Invalid tbl->lq_type %d\n", tbl->lq_type); + IL_ERR("Invalid tbl->lq_type %d\n", tbl->lq_type); } rate_n_flags |= ((tbl->ant_type << RATE_MCS_ANT_POS) & @@ -535,7 +535,7 @@ static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, rate_n_flags |= RATE_MCS_GF_MSK; if (is_siso(tbl->lq_type) && tbl->is_SGI) { rate_n_flags &= ~RATE_MCS_SGI_MSK; - IL_ERR(il, "GF was set with SGI:SISO\n"); + IL_ERR("GF was set with SGI:SISO\n"); } } } @@ -1480,7 +1480,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, if (!tbl->is_SGI) break; else - IL_ERR(il, + IL_ERR( "SGI was set in GF+SISO\n"); } search_tbl->is_SGI = !tbl->is_SGI; @@ -1851,7 +1851,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, rate_scale_index_msk = rate_mask; if (!((1 << index) & rate_scale_index_msk)) { - IL_ERR(il, "Current Rate is not valid\n"); + IL_ERR("Current Rate is not valid\n"); if (lq_sta->search_better_tbl) { /* revert to active table if search table is not valid*/ tbl->lq_type = LQ_NONE; @@ -1867,7 +1867,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Get expected throughput table and history window for current rate */ if (!tbl->expected_tpt) { - IL_ERR(il, "tbl->expected_tpt is NULL\n"); + IL_ERR("tbl->expected_tpt is NULL\n"); return; } @@ -1909,7 +1909,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, * actual average throughput */ if (window->average_tpt != ((window->success_ratio * tbl->expected_tpt[index] + 64) / 128)) { - IL_ERR(il, + IL_ERR( "expected_tpt should have been calculated by now\n"); window->average_tpt = ((window->success_ratio * tbl->expected_tpt[index] + 64) / 128); @@ -2590,7 +2590,7 @@ static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, D_RATE("Fixed rate ON\n"); } else { lq_sta->dbg_fixed_rate = 0; - IL_ERR(il, + IL_ERR( "Invalid antenna selection 0x%X, Valid is 0x%X\n", ant_sel_tx, valid_tx_ant); D_RATE("Fixed rate OFF\n"); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c index 3019bafc2352..a82d44489a6c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c @@ -44,7 +44,7 @@ il4965_sta_alloc_lq(struct il_priv *il, u8 sta_id) link_cmd = kzalloc(sizeof(struct il_link_quality_cmd), GFP_KERNEL); if (!link_cmd) { - IL_ERR(il, "Unable to allocate memory for LQ cmd.\n"); + IL_ERR("Unable to allocate memory for LQ cmd.\n"); return NULL; } /* Set up the rate scaling to start at selected rate, fall back @@ -105,7 +105,7 @@ il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, ret = il_add_station_common(il, ctx, addr, 0, NULL, &sta_id); if (ret) { - IL_ERR(il, "Unable to add station %pM\n", addr); + IL_ERR("Unable to add station %pM\n", addr); return ret; } @@ -119,7 +119,7 @@ il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, /* Set up default rate scaling table in device's station table */ link_cmd = il4965_sta_alloc_lq(il, sta_id); if (!link_cmd) { - IL_ERR(il, + IL_ERR( "Unable to initialize rate scaling for station %pM.\n", addr); return -ENOMEM; @@ -127,7 +127,7 @@ il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, ret = il_send_lq_cmd(il, ctx, link_cmd, CMD_SYNC, true); if (ret) - IL_ERR(il, "Link quality command failed (%d)\n", ret); + IL_ERR("Link quality command failed (%d)\n", ret); spin_lock_irqsave(&il->sta_lock, flags); il->stations[sta_id].lq = link_cmd; @@ -467,7 +467,7 @@ int il4965_remove_dynamic_key(struct il_priv *il, } if (il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET) { - IL_WARN(il, "Removing wrong key %d 0x%x\n", + IL_WARN("Removing wrong key %d 0x%x\n", keyconf->keyidx, key_flags); spin_unlock_irqrestore(&il->sta_lock, flags); return 0; @@ -475,7 +475,7 @@ int il4965_remove_dynamic_key(struct il_priv *il, if (!test_and_clear_bit(il->stations[sta_id].sta.key.key_offset, &il->ucode_key_table)) - IL_ERR(il, "index %d not used in uCode key table.\n", + IL_ERR("index %d not used in uCode key table.\n", il->stations[sta_id].sta.key.key_offset); memset(&il->stations[sta_id].keyinfo, 0, sizeof(struct il_hw_key)); @@ -525,7 +525,7 @@ int il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, keyconf, sta_id); break; default: - IL_ERR(il, + IL_ERR( "Unknown alg: %s cipher = %x\n", __func__, keyconf->cipher); ret = -EINVAL; @@ -557,7 +557,7 @@ int il4965_alloc_bcast_station(struct il_priv *il, sta_id = il_prep_station(il, ctx, il_bcast_addr, false, NULL); if (sta_id == IL_INVALID_STATION) { - IL_ERR(il, "Unable to prepare broadcast station\n"); + IL_ERR("Unable to prepare broadcast station\n"); spin_unlock_irqrestore(&il->sta_lock, flags); return -EINVAL; @@ -569,7 +569,7 @@ int il4965_alloc_bcast_station(struct il_priv *il, link_cmd = il4965_sta_alloc_lq(il, sta_id); if (!link_cmd) { - IL_ERR(il, + IL_ERR( "Unable to initialize rate scaling for bcast station.\n"); return -ENOMEM; } @@ -596,7 +596,7 @@ static int il4965_update_bcast_station(struct il_priv *il, link_cmd = il4965_sta_alloc_lq(il, sta_id); if (!link_cmd) { - IL_ERR(il, + IL_ERR( "Unable to initialize rate scaling for bcast station.\n"); return -ENOMEM; } @@ -686,7 +686,7 @@ int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta, sta_id = il_sta_id(sta); if (sta_id == IL_INVALID_STATION) { - IL_ERR(il, "Invalid station for AGG tid %d\n", tid); + IL_ERR("Invalid station for AGG tid %d\n", tid); return -ENXIO; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index efc21be8a940..66dd172fed60 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -258,7 +258,7 @@ static void il4965_tx_cmd_build_hwcrypto(struct il_priv *il, break; default: - IL_ERR(il, "Unknown encode cipher %x\n", keyconf->cipher); + IL_ERR("Unknown encode cipher %x\n", keyconf->cipher); break; } } @@ -619,13 +619,13 @@ int il4965_txq_ctx_alloc(struct il_priv *il) ret = il4965_alloc_dma_ptr(il, &il->scd_bc_tbls, il->hw_params.scd_bc_tbls_size); if (ret) { - IL_ERR(il, "Scheduler BC Table allocation failed\n"); + IL_ERR("Scheduler BC Table allocation failed\n"); goto error_bc_tbls; } /* Alloc keep-warm buffer */ ret = il4965_alloc_dma_ptr(il, &il->kw, IL_KW_SIZE); if (ret) { - IL_ERR(il, "Keep Warm allocation failed\n"); + IL_ERR("Keep Warm allocation failed\n"); goto error_kw; } @@ -652,7 +652,7 @@ int il4965_txq_ctx_alloc(struct il_priv *il) &il->txq[txq_id], slots_num, txq_id); if (ret) { - IL_ERR(il, "Tx %d queue init failed\n", txq_id); + IL_ERR("Tx %d queue init failed\n", txq_id); goto error; } } @@ -712,7 +712,7 @@ void il4965_txq_ctx_stop(struct il_priv *il) if (il_poll_direct_bit(il, FH_TSSR_TX_STATUS_REG, FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), 1000)) - IL_ERR(il, "Failing on timeout while stopping" + IL_ERR("Failing on timeout while stopping" " DMA channel %d [0x%08x]", ch, il_read_direct32(il, FH_TSSR_TX_STATUS_REG)); @@ -803,7 +803,7 @@ static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, if ((IWL49_FIRST_AMPDU_QUEUE > txq_id) || (IWL49_FIRST_AMPDU_QUEUE + il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { - IL_WARN(il, + IL_WARN( "queue number out of range: %d, must be %d to %d\n", txq_id, IWL49_FIRST_AMPDU_QUEUE, IWL49_FIRST_AMPDU_QUEUE + @@ -871,25 +871,25 @@ int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, if (unlikely(tx_fifo < 0)) return tx_fifo; - IL_WARN(il, "%s on ra = %pM tid = %d\n", + IL_WARN("%s on ra = %pM tid = %d\n", __func__, sta->addr, tid); sta_id = il_sta_id(sta); if (sta_id == IL_INVALID_STATION) { - IL_ERR(il, "Start AGG on invalid station\n"); + IL_ERR("Start AGG on invalid station\n"); return -ENXIO; } if (unlikely(tid >= MAX_TID_COUNT)) return -EINVAL; if (il->stations[sta_id].tid[tid].agg.state != IL_AGG_OFF) { - IL_ERR(il, "Start AGG when state is not IL_AGG_OFF !\n"); + IL_ERR("Start AGG when state is not IL_AGG_OFF !\n"); return -ENXIO; } txq_id = il4965_txq_ctx_activate_free(il); if (txq_id == -1) { - IL_ERR(il, "No free aggregation queue available\n"); + IL_ERR("No free aggregation queue available\n"); return -ENXIO; } @@ -932,7 +932,7 @@ static int il4965_txq_agg_disable(struct il_priv *il, u16 txq_id, if ((IWL49_FIRST_AMPDU_QUEUE > txq_id) || (IWL49_FIRST_AMPDU_QUEUE + il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { - IL_WARN(il, + IL_WARN( "queue number out of range: %d, must be %d to %d\n", txq_id, IWL49_FIRST_AMPDU_QUEUE, IWL49_FIRST_AMPDU_QUEUE + @@ -973,7 +973,7 @@ int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, sta_id = il_sta_id(sta); if (sta_id == IL_INVALID_STATION) { - IL_ERR(il, "Invalid station for AGG tid %d\n", tid); + IL_ERR("Invalid station for AGG tid %d\n", tid); return -ENXIO; } @@ -996,7 +996,7 @@ int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, case IL_AGG_ON: break; default: - IL_WARN(il, "Stopping AGG while state not ON or starting\n"); + IL_WARN("Stopping AGG while state not ON or starting\n"); } write_ptr = il->txq[txq_id].q.write_ptr; @@ -1115,7 +1115,7 @@ int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int index) struct ieee80211_hdr *hdr; if ((index >= q->n_bd) || (il_queue_used(q, index) == 0)) { - IL_ERR(il, "Read index for DMA queue txq id (%d), index %d, " + IL_ERR("Read index for DMA queue txq id (%d), index %d, " "is out of range [0-%d] %d %d.\n", txq_id, index, q->n_bd, q->write_ptr, q->read_ptr); return 0; @@ -1163,7 +1163,7 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, if (unlikely(!agg->wait_for_ba)) { if (unlikely(ba_resp->bitmap)) - IL_ERR(il, "Received BA when not expected\n"); + IL_ERR("Received BA when not expected\n"); return -EINVAL; } @@ -1266,7 +1266,7 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, u16 ba_resp_scd_ssn = le16_to_cpu(ba_resp->scd_ssn); if (scd_flow >= il->hw_params.max_txq_num) { - IL_ERR(il, + IL_ERR( "BUG_ON scd_flow is bigger than number of queues\n"); return; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c index d1e1775aa01b..3fa939e490cf 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c @@ -99,7 +99,7 @@ static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, * if IL_DL_IO is set */ val = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { - IL_ERR(il, "uCode INST section is invalid at " + IL_ERR("uCode INST section is invalid at " "offset 0x%x, is 0x%x, s/b 0x%x\n", save_len - len, val, le32_to_cpu(*image)); ret = -EIO; @@ -153,7 +153,7 @@ int il4965_verify_ucode(struct il_priv *il) return 0; } - IL_ERR(il, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); + IL_ERR("NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); /* Since nothing seems to match, show first several data entries in * instruction SRAM, so maybe visual inspection will give a clue. diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index cc28e0e084e4..7b422f2346ae 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -78,7 +78,7 @@ static int il4965_verify_bsm(struct il_priv *il) reg += sizeof(u32), image++) { val = il_read_prph(il, reg); if (val != le32_to_cpu(*image)) { - IL_ERR(il, "BSM uCode verification failed at " + IL_ERR("BSM uCode verification failed at " "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", BSM_SRAM_LOWER_BOUND, reg - BSM_SRAM_LOWER_BOUND, len, @@ -191,7 +191,7 @@ static int il4965_load_bsm(struct il_priv *il) if (i < 100) D_INFO("BSM write complete, poll %d iterations\n", i); else { - IL_ERR(il, "BSM write did not complete!\n"); + IL_ERR("BSM write did not complete!\n"); return -EIO; } @@ -343,7 +343,7 @@ static void il4965_chain_noise_reset(struct il_priv *il) cmd.diff_gain_c = 0; if (il_send_cmd_pdu(il, REPLY_PHY_CALIBRATION_CMD, sizeof(cmd), &cmd)) - IL_ERR(il, + IL_ERR( "Could not send REPLY_PHY_CALIBRATION_CMD\n"); data->state = IL_CHAIN_NOISE_ACCUMULATE; D_CALIB("Run chain_noise_calibrate\n"); @@ -548,7 +548,7 @@ static int il4965_interpolate_chan(struct il_priv *il, u32 channel, s = il4965_get_sub_band(il, channel); if (s >= EEPROM_TX_POWER_BANDS) { - IL_ERR(il, "Tx Power can not find channel %d\n", channel); + IL_ERR("Tx Power can not find channel %d\n", channel); return -1; } @@ -912,7 +912,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, * and 2) mimo txpower balance between Tx chains. */ txatten_grp = il4965_get_tx_atten_grp(channel); if (txatten_grp < 0) { - IL_ERR(il, "Can't find txatten group for channel %d.\n", + IL_ERR("Can't find txatten group for channel %d.\n", channel); return txatten_grp; } @@ -1078,12 +1078,12 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, /* stay within the table! */ if (power_index > 107) { - IL_WARN(il, "txpower index %d > 107\n", + IL_WARN("txpower index %d > 107\n", power_index); power_index = 107; } if (power_index < 0) { - IL_WARN(il, "txpower index %d < 0\n", + IL_WARN("txpower index %d < 0\n", power_index); power_index = 0; } @@ -1207,7 +1207,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) ret = il_check_rxon_cmd(il, ctx); if (ret) { - IL_ERR(il, "Invalid RXON configuration. Not committing.\n"); + IL_ERR("Invalid RXON configuration. Not committing.\n"); return -EINVAL; } @@ -1228,7 +1228,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) if (!il_full_rxon_required(il, ctx)) { ret = il_send_rxon_assoc(il, ctx); if (ret) { - IL_ERR(il, "Error setting RXON_ASSOC (%d)\n", ret); + IL_ERR("Error setting RXON_ASSOC (%d)\n", ret); return ret; } @@ -1258,14 +1258,14 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) * active_rxon back to what it was previously */ if (ret) { active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK; - IL_ERR(il, "Error clearing ASSOC_MSK (%d)\n", ret); + IL_ERR("Error clearing ASSOC_MSK (%d)\n", ret); return ret; } il_clear_ucode_stations(il, ctx); il_restore_stations(il, ctx); ret = il4965_restore_default_wep_keys(il, ctx); if (ret) { - IL_ERR(il, "Failed to restore WEP keys (%d)\n", ret); + IL_ERR("Failed to restore WEP keys (%d)\n", ret); return ret; } } @@ -1289,7 +1289,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) ret = il_send_cmd_pdu(il, ctx->rxon_cmd, sizeof(struct il_rxon_cmd), &ctx->staging); if (ret) { - IL_ERR(il, "Error setting new RXON (%d)\n", ret); + IL_ERR("Error setting new RXON (%d)\n", ret); return ret; } D_INFO("Return from !new_assoc RXON.\n"); @@ -1298,7 +1298,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) il_restore_stations(il, ctx); ret = il4965_restore_default_wep_keys(il, ctx); if (ret) { - IL_ERR(il, "Failed to restore WEP keys (%d)\n", ret); + IL_ERR("Failed to restore WEP keys (%d)\n", ret); return ret; } } @@ -1310,7 +1310,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) ret = il_send_cmd_pdu(il, ctx->rxon_cmd, sizeof(struct il_rxon_cmd), &ctx->staging); if (ret) { - IL_ERR(il, "Error setting new RXON (%d)\n", ret); + IL_ERR("Error setting new RXON (%d)\n", ret); return ret; } memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); @@ -1323,7 +1323,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) * send a new TXPOWER command or we won't be able to Tx any frames */ ret = il_set_tx_power(il, il->tx_power_next, true); if (ret) { - IL_ERR(il, "Error sending TX power (%d)\n", ret); + IL_ERR("Error sending TX power (%d)\n", ret); return ret; } @@ -1393,7 +1393,7 @@ static int il4965_hw_channel_switch(struct il_priv *il, if (ch_info) cmd.expect_beacon = il_is_channel_radar(ch_info); else { - IL_ERR(il, "invalid channel switch from %u to %u\n", + IL_ERR("invalid channel switch from %u to %u\n", ctx->active.channel, ch); return -EFAULT; } @@ -1479,7 +1479,7 @@ static int il4965_hw_get_temperature(struct il_priv *il) D_TEMP("Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt); if (R3 == R1) { - IL_ERR(il, "Calibration conflict R1 == R3\n"); + IL_ERR("Calibration conflict R1 == R3\n"); return -1; } @@ -1666,7 +1666,7 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, hdr = il_tx_queue_get_hdr(il, txq_id, idx); if (!hdr) { - IL_ERR(il, + IL_ERR( "BUG_ON idx doesn't point to valid skb" " idx=%d, txq_id=%d\n", idx, txq_id); return -1; @@ -1674,7 +1674,7 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, sc = le16_to_cpu(hdr->seq_ctrl); if (idx != (SEQ_TO_SN(sc) & 0xff)) { - IL_ERR(il, + IL_ERR( "BUG_ON idx doesn't match seq control" " idx=%d, seq_idx=%d, seq=%d\n", idx, SEQ_TO_SN(sc), hdr->seq_ctrl); @@ -1750,7 +1750,7 @@ static u8 il4965_find_station(struct il_priv *il, const u8 *addr) (!(il->stations[ret].used & IL_STA_UCODE_ACTIVE) || ((il->stations[ret].used & IL_STA_UCODE_ACTIVE) && (il->stations[ret].used & IL_STA_UCODE_INPROGRESS)))) { - IL_ERR(il, "Requested station info for sta %d before ready.\n", + IL_ERR("Requested station info for sta %d before ready.\n", ret); ret = IL_INVALID_STATION; } @@ -1790,7 +1790,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, unsigned long flags; if ((index >= txq->q.n_bd) || (il_queue_used(&txq->q, index) == 0)) { - IL_ERR(il, "Read index for DMA queue txq_id (%d) index %d " + IL_ERR("Read index for DMA queue txq_id (%d) index %d " "is out of range [0-%d] %d %d\n", txq_id, index, txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr); @@ -1809,7 +1809,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, sta_id = il4965_get_ra_sta_id(il, hdr); if (txq->sched_retry && unlikely(sta_id == IL_INVALID_STATION)) { - IL_ERR(il, "Station not known\n"); + IL_ERR("Station not known\n"); return; } @@ -1943,7 +1943,7 @@ static void il4965_post_associate(struct il_priv *il) ret = il_send_rxon_timing(il, ctx); if (ret) - IL_WARN(il, "RXON timing - " + IL_WARN("RXON timing - " "Attempting to continue.\n"); ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; @@ -1982,7 +1982,7 @@ static void il4965_post_associate(struct il_priv *il) il4965_send_beacon_cmd(il); break; default: - IL_ERR(il, "%s Should not be called in %d mode\n", + IL_ERR("%s Should not be called in %d mode\n", __func__, vif->type); break; } @@ -2019,7 +2019,7 @@ static void il4965_config_ap(struct il_priv *il) /* RXON Timing */ ret = il_send_rxon_timing(il, ctx); if (ret) - IL_WARN(il, "RXON timing failed - " + IL_WARN("RXON timing failed - " "Attempting to continue.\n"); /* AP has all antennas */ diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index e6c7e9d87a61..42be833bdc75 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -253,14 +253,14 @@ int il_init_geos(struct il_priv *il) if ((il->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && il->cfg->sku & IL_SKU_A) { - IL_INFO(il, "Incorrectly detected BG card as ABG. " + IL_INFO("Incorrectly detected BG card as ABG. " "Please send your PCI ID 0x%04X:0x%04X to maintainer.\n", il->pci_dev->device, il->pci_dev->subsystem_device); il->cfg->sku &= ~IL_SKU_A; } - IL_INFO(il, "Tunable channels: %d 802.11bg, %d 802.11a channels\n", + IL_INFO("Tunable channels: %d 802.11bg, %d 802.11a channels\n", il->bands[IEEE80211_BAND_2GHZ].n_channels, il->bands[IEEE80211_BAND_5GHZ].n_channels); @@ -431,65 +431,65 @@ il_check_rxon_cmd(struct il_priv *il, struct il_rxon_context *ctx) if (rxon->flags & RXON_FLG_BAND_24G_MSK) { if (rxon->flags & RXON_FLG_TGJ_NARROW_BAND_MSK) { - IL_WARN(il, "check 2.4G: wrong narrow\n"); + IL_WARN("check 2.4G: wrong narrow\n"); error = true; } if (rxon->flags & RXON_FLG_RADAR_DETECT_MSK) { - IL_WARN(il, "check 2.4G: wrong radar\n"); + IL_WARN("check 2.4G: wrong radar\n"); error = true; } } else { if (!(rxon->flags & RXON_FLG_SHORT_SLOT_MSK)) { - IL_WARN(il, "check 5.2G: not short slot!\n"); + IL_WARN("check 5.2G: not short slot!\n"); error = true; } if (rxon->flags & RXON_FLG_CCK_MSK) { - IL_WARN(il, "check 5.2G: CCK!\n"); + IL_WARN("check 5.2G: CCK!\n"); error = true; } } if ((rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1) { - IL_WARN(il, "mac/bssid mcast!\n"); + IL_WARN("mac/bssid mcast!\n"); error = true; } /* make sure basic rates 6Mbps and 1Mbps are supported */ if ((rxon->ofdm_basic_rates & IL_RATE_6M_MASK) == 0 && (rxon->cck_basic_rates & IL_RATE_1M_MASK) == 0) { - IL_WARN(il, "neither 1 nor 6 are basic\n"); + IL_WARN("neither 1 nor 6 are basic\n"); error = true; } if (le16_to_cpu(rxon->assoc_id) > 2007) { - IL_WARN(il, "aid > 2007\n"); + IL_WARN("aid > 2007\n"); error = true; } if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) { - IL_WARN(il, "CCK and short slot\n"); + IL_WARN("CCK and short slot\n"); error = true; } if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) { - IL_WARN(il, "CCK and auto detect"); + IL_WARN("CCK and auto detect"); error = true; } if ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_TGG_PROTECT_MSK)) == RXON_FLG_TGG_PROTECT_MSK) { - IL_WARN(il, "TGg but no auto-detect\n"); + IL_WARN("TGg but no auto-detect\n"); error = true; } if (error) - IL_WARN(il, "Tuning to channel %d\n", + IL_WARN("Tuning to channel %d\n", le16_to_cpu(rxon->channel)); if (error) { - IL_ERR(il, "Invalid RXON\n"); + IL_ERR("Invalid RXON\n"); return -EINVAL; } return 0; @@ -626,7 +626,7 @@ static void _il_set_rxon_ht(struct il_priv *il, case IEEE80211_HT_PARAM_CHA_SEC_NONE: default: /* channel location only valid if in Mixed mode */ - IL_ERR(il, + IL_ERR( "invalid extension channel offset\n"); break; } @@ -778,7 +778,7 @@ void il_connection_init_rx_config(struct il_priv *il, break; default: - IL_ERR(il, "Unsupported interface type %d\n", + IL_ERR("Unsupported interface type %d\n", ctx->vif->type); break; } @@ -828,7 +828,7 @@ void il_set_rate(struct il_priv *il) hw = il_get_hw_mode(il, il->band); if (!hw) { - IL_ERR(il, "Failed to set rate: unable to get hw mode\n"); + IL_ERR("Failed to set rate: unable to get hw mode\n"); return; } @@ -882,7 +882,7 @@ void il_rx_csa(struct il_priv *il, struct il_rx_mem_buffer *rxb) le16_to_cpu(csa->channel)); il_chswitch_done(il, true); } else { - IL_ERR(il, "CSA notif (fail) : channel %d\n", + IL_ERR("CSA notif (fail) : channel %d\n", le16_to_cpu(csa->channel)); il_chswitch_done(il, false); } @@ -925,7 +925,7 @@ void il_irq_handle_error(struct il_priv *il) /* Cancel currently queued command. */ clear_bit(STATUS_HCMD_ACTIVE, &il->status); - IL_ERR(il, "Loaded firmware version: %s\n", + IL_ERR("Loaded firmware version: %s\n", il->hw->wiphy->fw_version); il->cfg->ops->lib->dump_nic_error_log(il); @@ -963,7 +963,7 @@ static int il_apm_stop_master(struct il_priv *il) ret = il_poll_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); if (ret) - IL_WARN(il, "Master Disable Timed Out, 100 usec\n"); + IL_WARN("Master Disable Timed Out, 100 usec\n"); D_INFO("stop master\n"); @@ -1123,14 +1123,14 @@ int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) /* 0 dBm mean 1 milliwatt */ if (tx_power < 0) { - IL_WARN(il, + IL_WARN( "Requested user TXPOWER %d below 1 mW.\n", tx_power); return -EINVAL; } if (tx_power > il->tx_power_device_lmt) { - IL_WARN(il, + IL_WARN( "Requested user TXPOWER %d above upper limit %d.\n", tx_power, il->tx_power_device_lmt); return -EINVAL; @@ -1184,7 +1184,7 @@ void il_send_bt_config(struct il_priv *il) if (il_send_cmd_pdu(il, REPLY_BT_CONFIG, sizeof(struct il_bt_cmd), &bt_cmd)) - IL_ERR(il, "failed to send BT Coex Config\n"); + IL_ERR("failed to send BT Coex Config\n"); } EXPORT_SYMBOL(il_send_bt_config); @@ -1235,7 +1235,7 @@ void il_rx_reply_error(struct il_priv *il, { struct il_rx_packet *pkt = rxb_addr(rxb); - IL_ERR(il, "Error Reply type 0x%08X cmd %s (0x%02X) " + IL_ERR("Error Reply type 0x%08X cmd %s (0x%02X) " "seq 0x%04X ser 0x%08X\n", le32_to_cpu(pkt->u.err_resp.error_type), il_get_cmd_string(pkt->u.err_resp.cmd_id), @@ -1354,7 +1354,7 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) mutex_lock(&il->mutex); if (!il_is_ready_rf(il)) { - IL_WARN(il, "Try to add interface when device not ready\n"); + IL_WARN("Try to add interface when device not ready\n"); err = -EINVAL; goto out; } @@ -1454,7 +1454,7 @@ int il_alloc_txq_mem(struct il_priv *il) il->cfg->base_params->num_of_queues, GFP_KERNEL); if (!il->txq) { - IL_ERR(il, "Not enough memory for txq\n"); + IL_ERR("Not enough memory for txq\n"); return -ENOMEM; } return 0; @@ -1743,7 +1743,7 @@ int il_force_reset(struct il_priv *il, bool external) return 0; } - IL_ERR(il, "On demand firmware reload\n"); + IL_ERR("On demand firmware reload\n"); /* Set the FW error flag -- cleared on il_down */ set_bit(STATUS_FW_ERROR, &il->status); @@ -1847,7 +1847,7 @@ static int il_check_stuck_queue(struct il_priv *il, int cnt) msecs_to_jiffies(il->cfg->base_params->wd_timeout); if (time_after(jiffies, timeout)) { - IL_ERR(il, "Queue %d stuck for %u ms.\n", + IL_ERR("Queue %d stuck for %u ms.\n", q->id, il->cfg->base_params->wd_timeout); ret = il_force_reset(il, false); return (ret == -EAGAIN) ? 0 : 1; @@ -2363,7 +2363,7 @@ static void il_beacon_update(struct ieee80211_hw *hw, lockdep_assert_held(&il->mutex); if (!il->beacon_ctx) { - IL_ERR(il, "update beacon but no beacon context!\n"); + IL_ERR("update beacon but no beacon context!\n"); dev_kfree_skb(skb); return; } @@ -2440,7 +2440,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, * below/in post_associate will fail. */ if (il_scan_cancel_timeout(il, 100)) { - IL_WARN(il, + IL_WARN( "Aborted scan still in progress after 100ms\n"); D_MAC80211( "leaving - scan abort failed.\n"); @@ -2554,7 +2554,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, ret = il->cfg->ops->legacy->manage_ibss_station(il, vif, bss_conf->ibss_joined); if (ret) - IL_ERR(il, "failed to %s IBSS station %pM\n", + IL_ERR("failed to %s IBSS station %pM\n", bss_conf->ibss_joined ? "add" : "remove", bss_conf->bssid); } @@ -2599,7 +2599,7 @@ irqreturn_t il_isr(int irq, void *data) if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) { /* Hardware disappeared. It might have already raised * an interrupt */ - IL_WARN(il, "HARDWARE GONE?? INTA == 0x%08x\n", inta); + IL_WARN("HARDWARE GONE?? INTA == 0x%08x\n", inta); goto unplugged; } diff --git a/drivers/net/wireless/iwlegacy/iwl-debug.h b/drivers/net/wireless/iwlegacy/iwl-debug.h index 2c5c42fa4bb6..373188df7cc8 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debug.h +++ b/drivers/net/wireless/iwlegacy/iwl-debug.h @@ -32,10 +32,10 @@ struct il_priv; extern u32 il_debug_level; -#define IL_ERR(p, f, a...) dev_err(&((p)->pci_dev->dev), f, ## a) -#define IL_WARN(p, f, a...) dev_warn(&((p)->pci_dev->dev), f, ## a) -#define IL_INFO(p, f, a...) dev_info(&((p)->pci_dev->dev), f, ## a) -#define IL_CRIT(p, f, a...) dev_crit(&((p)->pci_dev->dev), f, ## a) +#define IL_ERR(f, a...) dev_err(&il->pci_dev->dev, f, ## a) +#define IL_WARN(f, a...) dev_warn(&il->pci_dev->dev, f, ## a) +#define IL_INFO(f, a...) dev_info(&il->pci_dev->dev, f, ## a) +#define IL_CRIT(f, a...) dev_crit(&il->pci_dev->dev, f, ## a) #define il_print_hex_error(il, p, len) \ do { \ diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index a811c17e9c62..45b71a8b9af5 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -358,20 +358,20 @@ static ssize_t il_dbgfs_nvm_read(struct file *file, buf_size = 4 * eeprom_len + 256; if (eeprom_len % 16) { - IL_ERR(il, "NVM size is not multiple of 16.\n"); + IL_ERR("NVM size is not multiple of 16.\n"); return -ENODATA; } ptr = il->eeprom; if (!ptr) { - IL_ERR(il, "Invalid EEPROM memory\n"); + IL_ERR("Invalid EEPROM memory\n"); return -ENOMEM; } /* 4 characters for byte 0xYY */ buf = kzalloc(buf_size, GFP_KERNEL); if (!buf) { - IL_ERR(il, "Can not allocate Buffer\n"); + IL_ERR("Can not allocate Buffer\n"); return -ENOMEM; } eeprom_ver = il_eeprom_query16(il, EEPROM_VERSION); @@ -407,7 +407,7 @@ il_dbgfs_channels_read(struct file *file, char __user *user_buf, buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(il, "Can not allocate Buffer\n"); + IL_ERR("Can not allocate Buffer\n"); return -ENOMEM; } @@ -519,7 +519,7 @@ static ssize_t il_dbgfs_interrupt_read(struct file *file, buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(il, "Can not allocate Buffer\n"); + IL_ERR("Can not allocate Buffer\n"); return -ENOMEM; } @@ -640,7 +640,7 @@ static ssize_t il_dbgfs_disable_ht40_write(struct file *file, if (!il_is_any_associated(il)) il->disable_ht40 = ht40 ? true : false; else { - IL_ERR(il, "Sta associated with AP - " + IL_ERR("Sta associated with AP - " "Change to 40MHz channel support is not allowed\n"); return -EINVAL; } @@ -689,12 +689,12 @@ static ssize_t il_dbgfs_traffic_log_read(struct file *file, ssize_t ret; if (!il->txq) { - IL_ERR(il, "txq not ready\n"); + IL_ERR("txq not ready\n"); return -EAGAIN; } buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(il, "Can not allocate buffer\n"); + IL_ERR("Can not allocate buffer\n"); return -ENOMEM; } pos += scnprintf(buf + pos, bufsz - pos, "Tx Queue\n"); @@ -787,7 +787,7 @@ static ssize_t il_dbgfs_tx_queue_read(struct file *file, il->cfg->base_params->num_of_queues; if (!il->txq) { - IL_ERR(il, "txq not ready\n"); + IL_ERR("txq not ready\n"); return -EAGAIN; } buf = kzalloc(bufsz, GFP_KERNEL); @@ -884,7 +884,7 @@ static ssize_t il_dbgfs_sensitivity_read(struct file *file, data = &il->sensitivity_data; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(il, "Can not allocate Buffer\n"); + IL_ERR("Can not allocate Buffer\n"); return -ENOMEM; } @@ -965,7 +965,7 @@ static ssize_t il_dbgfs_chain_noise_read(struct file *file, data = &il->chain_noise_data; buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) { - IL_ERR(il, "Can not allocate Buffer\n"); + IL_ERR("Can not allocate Buffer\n"); return -ENOMEM; } @@ -1292,7 +1292,7 @@ int il_dbgfs_register(struct il_priv *il, const char *name) return 0; err: - IL_ERR(il, "Can't create the debugfs directory\n"); + IL_ERR("Can't create the debugfs directory\n"); il_dbgfs_unregister(il); return -ENOMEM; } diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-eeprom.c index 33fe5989e820..5f0fd2afedfe 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.c @@ -153,7 +153,7 @@ static int il_eeprom_verify_signature(struct il_priv *il) case CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K: break; default: - IL_ERR(il, "bad EEPROM signature," + IL_ERR("bad EEPROM signature," "EEPROM_GP=0x%08x\n", gp); ret = -ENOENT; break; @@ -206,7 +206,7 @@ int il_eeprom_init(struct il_priv *il) ret = il_eeprom_verify_signature(il); if (ret < 0) { - IL_ERR(il, "EEPROM not found, EEPROM_GP=0x%08x\n", gp); + IL_ERR("EEPROM not found, EEPROM_GP=0x%08x\n", gp); ret = -ENOENT; goto err; } @@ -214,7 +214,7 @@ int il_eeprom_init(struct il_priv *il) /* Make sure driver (instead of uCode) is allowed to read EEPROM */ ret = il->cfg->ops->lib->eeprom_ops.acquire_semaphore(il); if (ret < 0) { - IL_ERR(il, "Failed to acquire EEPROM semaphore.\n"); + IL_ERR("Failed to acquire EEPROM semaphore.\n"); ret = -ENOENT; goto err; } @@ -231,7 +231,7 @@ int il_eeprom_init(struct il_priv *il) CSR_EEPROM_REG_READ_VALID_MSK, IL_EEPROM_ACCESS_TIMEOUT); if (ret < 0) { - IL_ERR(il, "Time out reading EEPROM[%d]\n", + IL_ERR("Time out reading EEPROM[%d]\n", addr); goto done; } @@ -399,7 +399,7 @@ int il_init_channel_map(struct il_priv *il) il->channel_info = kzalloc(sizeof(struct il_channel_info) * il->channel_count, GFP_KERNEL); if (!il->channel_info) { - IL_ERR(il, "Could not allocate channel_info\n"); + IL_ERR("Could not allocate channel_info\n"); il->channel_count = 0; return -ENOMEM; } diff --git a/drivers/net/wireless/iwlegacy/iwl-hcmd.c b/drivers/net/wireless/iwlegacy/iwl-hcmd.c index 61cf0d83af57..8f87bd87f63d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-hcmd.c +++ b/drivers/net/wireless/iwlegacy/iwl-hcmd.c @@ -95,7 +95,7 @@ static void il_generic_cmd_callback(struct il_priv *il, struct il_rx_packet *pkt) { if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR(il, "Bad return from %s (0x%08X)\n", + IL_ERR("Bad return from %s (0x%08X)\n", il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); return; } @@ -133,7 +133,7 @@ il_send_cmd_async(struct il_priv *il, struct il_host_cmd *cmd) ret = il_enqueue_hcmd(il, cmd); if (ret < 0) { - IL_ERR(il, "Error sending %s: enqueue_hcmd failed: %d\n", + IL_ERR("Error sending %s: enqueue_hcmd failed: %d\n", il_get_cmd_string(cmd->id), ret); return ret; } @@ -162,7 +162,7 @@ int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) cmd_idx = il_enqueue_hcmd(il, cmd); if (cmd_idx < 0) { ret = cmd_idx; - IL_ERR(il, "Error sending %s: enqueue_hcmd failed: %d\n", + IL_ERR("Error sending %s: enqueue_hcmd failed: %d\n", il_get_cmd_string(cmd->id), ret); goto out; } @@ -172,7 +172,7 @@ int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) HOST_COMPLETE_TIMEOUT); if (!ret) { if (test_bit(STATUS_HCMD_ACTIVE, &il->status)) { - IL_ERR(il, + IL_ERR( "Error sending %s: time out after %dms.\n", il_get_cmd_string(cmd->id), jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); @@ -187,19 +187,19 @@ int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) } if (test_bit(STATUS_RF_KILL_HW, &il->status)) { - IL_ERR(il, "Command %s aborted: RF KILL Switch\n", + IL_ERR("Command %s aborted: RF KILL Switch\n", il_get_cmd_string(cmd->id)); ret = -ECANCELED; goto fail; } if (test_bit(STATUS_FW_ERROR, &il->status)) { - IL_ERR(il, "Command %s failed: FW Error\n", + IL_ERR("Command %s failed: FW Error\n", il_get_cmd_string(cmd->id)); ret = -EIO; goto fail; } if ((cmd->flags & CMD_WANT_SKB) && !cmd->reply_page) { - IL_ERR(il, "Error: Response NULL in '%s'\n", + IL_ERR("Error: Response NULL in '%s'\n", il_get_cmd_string(cmd->id)); ret = -EIO; goto cancel; diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h index d6aae8daf3f0..1afd5c04d538 100644 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ b/drivers/net/wireless/iwlegacy/iwl-io.h @@ -132,7 +132,7 @@ static inline int _il_grab_nic_access(struct il_priv *il) CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 15000); if (ret < 0) { val = _il_read32(il, CSR_GP_CNTRL); - IL_ERR(il, + IL_ERR( "MAC is in deep sleep!. CSR_GP_CNTRL = 0x%08X\n", val); _il_write32(il, CSR_RESET, CSR_RESET_REG_FLAG_FORCE_NMI); diff --git a/drivers/net/wireless/iwlegacy/iwl-led.c b/drivers/net/wireless/iwlegacy/iwl-led.c index b4d71cf7e398..a283804da10d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-led.c +++ b/drivers/net/wireless/iwlegacy/iwl-led.c @@ -88,7 +88,7 @@ static inline u8 il_blink_compensation(struct il_priv *il, u8 time, u16 compensation) { if (!compensation) { - IL_ERR(il, "undefined blink compensation: " + IL_ERR("undefined blink compensation: " "use pre-defined blinking time\n"); return time; } diff --git a/drivers/net/wireless/iwlegacy/iwl-power.c b/drivers/net/wireless/iwlegacy/iwl-power.c index 33aec397247c..6c6e5e70c96f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-power.c +++ b/drivers/net/wireless/iwlegacy/iwl-power.c @@ -136,7 +136,7 @@ il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, memcpy(&il->power_data.sleep_cmd, cmd, sizeof(*cmd)); } else - IL_ERR(il, "set power fail, ret = %d", ret); + IL_ERR("set power fail, ret = %d", ret); return ret; } diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index c534dcef4a71..36871041cec0 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -341,7 +341,7 @@ static int il_scan_initiate(struct il_priv *il, cancel_delayed_work(&il->scan_check); if (!il_is_ready_rf(il)) { - IL_WARN(il, "Request scan called when driver not ready.\n"); + IL_WARN("Request scan called when driver not ready.\n"); return -EIO; } diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.c b/drivers/net/wireless/iwlegacy/iwl-sta.c index a48af855dc01..42033d2ef6d4 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-sta.c @@ -41,7 +41,7 @@ static void il_sta_ucode_activate(struct il_priv *il, u8 sta_id) { if (!(il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) - IL_ERR(il, + IL_ERR( "ACTIVATE a non DRIVER active station id %u addr %pM\n", sta_id, il->stations[sta_id].sta.sta.addr); @@ -67,7 +67,7 @@ static int il_process_add_sta_resp(struct il_priv *il, int ret = -EIO; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR(il, "Bad return from REPLY_ADD_STA (0x%08X)\n", + IL_ERR("Bad return from REPLY_ADD_STA (0x%08X)\n", pkt->hdr.flags); return ret; } @@ -84,16 +84,16 @@ static int il_process_add_sta_resp(struct il_priv *il, ret = 0; break; case ADD_STA_NO_ROOM_IN_TABLE: - IL_ERR(il, "Adding station %d failed, no room in table.\n", + IL_ERR("Adding station %d failed, no room in table.\n", sta_id); break; case ADD_STA_NO_BLOCK_ACK_RESOURCE: - IL_ERR(il, + IL_ERR( "Adding station %d failed, no block ack resource.\n", sta_id); break; case ADD_STA_MODIFY_NON_EXIST_STA: - IL_ERR(il, "Attempting to modify non-existing station %d\n", + IL_ERR("Attempting to modify non-existing station %d\n", sta_id); break; default: @@ -206,7 +206,7 @@ static void il_set_ht_add_station(struct il_priv *il, u8 index, case WLAN_HT_CAP_SM_PS_DISABLED: break; default: - IL_WARN(il, "Invalid MIMO PS mode %d\n", mimo_ps_mode); + IL_WARN("Invalid MIMO PS mode %d\n", mimo_ps_mode); break; } @@ -343,7 +343,7 @@ il_add_station_common(struct il_priv *il, spin_lock_irqsave(&il->sta_lock, flags_spin); sta_id = il_prep_station(il, ctx, addr, is_ap, sta); if (sta_id == IL_INVALID_STATION) { - IL_ERR(il, "Unable to prepare station %pM for addition\n", + IL_ERR("Unable to prepare station %pM for addition\n", addr); spin_unlock_irqrestore(&il->sta_lock, flags_spin); return -EINVAL; @@ -380,7 +380,7 @@ il_add_station_common(struct il_priv *il, ret = il_send_add_sta(il, &sta_cmd, CMD_SYNC); if (ret) { spin_lock_irqsave(&il->sta_lock, flags_spin); - IL_ERR(il, "Adding station %pM failed.\n", + IL_ERR("Adding station %pM failed.\n", il->stations[sta_id].sta.sta.addr); il->stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE; il->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; @@ -402,7 +402,7 @@ static void il_sta_ucode_deactivate(struct il_priv *il, u8 sta_id) if ((il->stations[sta_id].used & (IL_STA_UCODE_ACTIVE | IL_STA_DRIVER_ACTIVE)) != IL_STA_UCODE_ACTIVE) - IL_ERR(il, "removed non active STA %u\n", sta_id); + IL_ERR("removed non active STA %u\n", sta_id); il->stations[sta_id].used &= ~IL_STA_UCODE_ACTIVE; @@ -440,7 +440,7 @@ static int il_send_remove_station(struct il_priv *il, pkt = (struct il_rx_packet *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR(il, "Bad return from REPLY_REMOVE_STA (0x%08X)\n", + IL_ERR("Bad return from REPLY_REMOVE_STA (0x%08X)\n", pkt->hdr.flags); ret = -EIO; } @@ -458,7 +458,7 @@ static int il_send_remove_station(struct il_priv *il, break; default: ret = -EIO; - IL_ERR(il, "REPLY_REMOVE_STA failed\n"); + IL_ERR("REPLY_REMOVE_STA failed\n"); break; } } @@ -618,7 +618,7 @@ il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) ret = il_send_add_sta(il, &sta_cmd, CMD_SYNC); if (ret) { spin_lock_irqsave(&il->sta_lock, flags_spin); - IL_ERR(il, "Adding station %pM failed.\n", + IL_ERR("Adding station %pM failed.\n", il->stations[i].sta.sta.addr); il->stations[i].used &= ~IL_STA_DRIVER_ACTIVE; @@ -808,7 +808,7 @@ int il_mac_sta_remove(struct ieee80211_hw *hw, sta->addr); ret = il_remove_station(il, sta_common->sta_id, sta->addr); if (ret) - IL_ERR(il, "Error removing station %pM\n", + IL_ERR("Error removing station %pM\n", sta->addr); mutex_unlock(&il->mutex); return ret; diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index 22617c47fc77..cfc015ae203b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -299,7 +299,7 @@ static int il_tx_queue_alloc(struct il_priv *il, txq->txb = kzalloc(sizeof(txq->txb[0]) * TFD_QUEUE_SIZE_MAX, GFP_KERNEL); if (!txq->txb) { - IL_ERR(il, "kmalloc for auxiliary BD " + IL_ERR("kmalloc for auxiliary BD " "structures failed\n"); goto error; } @@ -312,7 +312,7 @@ static int il_tx_queue_alloc(struct il_priv *il, txq->tfds = dma_alloc_coherent(dev, tfd_sz, &txq->q.dma_addr, GFP_KERNEL); if (!txq->tfds) { - IL_ERR(il, "pci_alloc_consistent(%zd) failed\n", tfd_sz); + IL_ERR("pci_alloc_consistent(%zd) failed\n", tfd_sz); goto error; } txq->q.id = id; @@ -461,7 +461,7 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) BUG_ON(fix_size > IL_MAX_CMD_SIZE); if (il_is_rfkill(il) || il_is_ctkill(il)) { - IL_WARN(il, "Not sending command - %s KILL\n", + IL_WARN("Not sending command - %s KILL\n", il_is_rfkill(il) ? "RF" : "CT"); return -EIO; } @@ -471,7 +471,7 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) if (il_queue_space(q) < ((cmd->flags & CMD_ASYNC) ? 2 : 1)) { spin_unlock_irqrestore(&il->hcmd_lock, flags); - IL_ERR(il, "Restarting adapter due to command queue full\n"); + IL_ERR("Restarting adapter due to command queue full\n"); queue_work(il->workqueue, &il->restart); return -ENOSPC; } @@ -566,7 +566,7 @@ static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, int nfreed = 0; if ((idx >= q->n_bd) || (il_queue_used(q, idx) == 0)) { - IL_ERR(il, "Read index for DMA queue txq id (%d), index %d, " + IL_ERR("Read index for DMA queue txq id (%d), index %d, " "is out of range [0-%d] %d %d.\n", txq_id, idx, q->n_bd, q->write_ptr, q->read_ptr); return; @@ -576,7 +576,7 @@ static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { if (nfreed++ > 0) { - IL_ERR(il, "HCMD skipped: index (%d) %d %d\n", idx, + IL_ERR("HCMD skipped: index (%d) %d %d\n", idx, q->write_ptr, q->read_ptr); queue_work(il->workqueue, &il->restart); } diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 8aa22a01ae68..8a6b1937336c 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -127,7 +127,7 @@ __le32 il3945_get_antenna_flags(const struct il_priv *il) } /* bad antenna selector value */ - IL_ERR(il, "Bad antenna selector value (0x%x)\n", + IL_ERR("Bad antenna selector value (0x%x)\n", il3945_mod_params.antenna); return 0; /* "diversity" is default if error */ @@ -236,7 +236,7 @@ static int il3945_set_dynamic_key(struct il_priv *il, ret = il3945_set_wep_dynamic_key_info(il, keyconf, sta_id); break; default: - IL_ERR(il, "Unknown alg: %s alg=%x\n", __func__, + IL_ERR("Unknown alg: %s alg=%x\n", __func__, keyconf->cipher); ret = -EINVAL; } @@ -262,7 +262,7 @@ static int il3945_set_static_key(struct il_priv *il, key->cipher == WLAN_CIPHER_SUITE_WEP104) return -EOPNOTSUPP; - IL_ERR(il, "Static key invalid: cipher %x\n", key->cipher); + IL_ERR("Static key invalid: cipher %x\n", key->cipher); return -EINVAL; } @@ -281,7 +281,7 @@ static void il3945_clear_free_frames(struct il_priv *il) } if (il->frames_count) { - IL_WARN(il, "%d frames still in use. Did we lose one?\n", + IL_WARN("%d frames still in use. Did we lose one?\n", il->frames_count); il->frames_count = 0; } @@ -294,7 +294,7 @@ static struct il3945_frame *il3945_get_free_frame(struct il_priv *il) if (list_empty(&il->free_frames)) { frame = kzalloc(sizeof(*frame), GFP_KERNEL); if (!frame) { - IL_ERR(il, "Could not allocate frame!\n"); + IL_ERR("Could not allocate frame!\n"); return NULL; } @@ -339,7 +339,7 @@ static int il3945_send_beacon_cmd(struct il_priv *il) frame = il3945_get_free_frame(il); if (!frame) { - IL_ERR(il, "Could not obtain free frame buffer for beacon " + IL_ERR("Could not obtain free frame buffer for beacon " "command.\n"); return -ENOMEM; } @@ -401,7 +401,7 @@ static void il3945_build_tx_cmd_hwcrypto(struct il_priv *il, break; default: - IL_ERR(il, "Unknown encode cipher %x\n", keyinfo->cipher); + IL_ERR("Unknown encode cipher %x\n", keyinfo->cipher); break; } } @@ -491,7 +491,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) } if ((ieee80211_get_tx_rate(il->hw, info)->hw_value & 0xFF) == IL_INVALID_RATE) { - IL_ERR(il, "ERROR: No TX rate available.\n"); + IL_ERR("ERROR: No TX rate available.\n"); goto drop_unlock; } @@ -718,7 +718,7 @@ static int il3945_get_measurement(struct il_priv *il, pkt = (struct il_rx_packet *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR(il, "Bad return from REPLY_RX_ON_ASSOC command\n"); + IL_ERR("Bad return from REPLY_RX_ON_ASSOC command\n"); rc = -EIO; } @@ -777,7 +777,7 @@ static void il3945_rx_reply_alive(struct il_priv *il, queue_delayed_work(il->workqueue, pwork, msecs_to_jiffies(5)); else - IL_WARN(il, "uCode did not respond OK.\n"); + IL_WARN("uCode did not respond OK.\n"); } static void il3945_rx_reply_add_sta(struct il_priv *il, @@ -820,7 +820,7 @@ static void il3945_rx_card_state_notif(struct il_priv *il, u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); unsigned long status = il->status; - IL_WARN(il, "Card state received: HW:%s SW:%s\n", + IL_WARN("Card state received: HW:%s SW:%s\n", (flags & HW_CARD_DISABLED) ? "Kill" : "On", (flags & SW_CARD_DISABLED) ? "Kill" : "On"); @@ -1043,7 +1043,7 @@ static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) D_INFO("Failed to allocate SKB buffer.\n"); if ((rxq->free_count <= RX_LOW_WATERMARK) && net_ratelimit()) - IL_CRIT(il, "Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", + IL_CRIT("Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", priority == GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL", rxq->free_count); /* We don't reschedule replenish work here -- we will @@ -1287,7 +1287,7 @@ static void il3945_rx_handle(struct il_priv *il) if (rxb->page) il_tx_cmd_complete(il, rxb); else - IL_WARN(il, "Claim null rxb?\n"); + IL_WARN("Claim null rxb?\n"); } /* Reuse the page if possible. For notification packets and @@ -1366,7 +1366,7 @@ void il3945_dump_nic_error_log(struct il_priv *il) base = le32_to_cpu(il->card_alive.error_event_table_ptr); if (!il3945_hw_valid_rtc_data_addr(base)) { - IL_ERR(il, "Not valid error log pointer 0x%08X\n", base); + IL_ERR("Not valid error log pointer 0x%08X\n", base); return; } @@ -1374,12 +1374,12 @@ void il3945_dump_nic_error_log(struct il_priv *il) count = il_read_targ_mem(il, base); if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { - IL_ERR(il, "Start IWL Error Log Dump:\n"); - IL_ERR(il, "Status: 0x%08lX, count: %d\n", + IL_ERR("Start IWL Error Log Dump:\n"); + IL_ERR("Status: 0x%08lX, count: %d\n", il->status, count); } - IL_ERR(il, "Desc Time asrtPC blink2 " + IL_ERR("Desc Time asrtPC blink2 " "ilink1 nmiPC Line\n"); for (i = ERROR_START_OFFSET; i < (count * ERROR_ELEM_SIZE) + ERROR_START_OFFSET; @@ -1398,7 +1398,7 @@ void il3945_dump_nic_error_log(struct il_priv *il) data1 = il_read_targ_mem(il, base + i + 6 * sizeof(u32)); - IL_ERR(il, + IL_ERR( "%-13s (0x%X) %010u 0x%05X 0x%05X 0x%05X 0x%05X %u\n\n", il3945_desc_lookup(desc), desc, time, blink1, blink2, ilink1, ilink2, data1); @@ -1450,7 +1450,7 @@ static void il3945_irq_tasklet(struct il_priv *il) /* Now service all interrupt bits discovered above. */ if (inta & CSR_INT_BIT_HW_ERR) { - IL_ERR(il, "Hardware error detected. Restarting.\n"); + IL_ERR("Hardware error detected. Restarting.\n"); /* Tell the device to stop sending interrupts */ il_disable_interrupts(il); @@ -1484,7 +1484,7 @@ static void il3945_irq_tasklet(struct il_priv *il) /* Error detected by uCode */ if (inta & CSR_INT_BIT_SW_ERR) { - IL_ERR(il, "Microcode SW error detected. " + IL_ERR("Microcode SW error detected. " "Restarting 0x%X.\n", inta); il->isr_stats.sw++; il_irq_handle_error(il); @@ -1526,14 +1526,14 @@ static void il3945_irq_tasklet(struct il_priv *il) } if (inta & ~handled) { - IL_ERR(il, "Unhandled INTA bits 0x%08x\n", inta & ~handled); + IL_ERR("Unhandled INTA bits 0x%08x\n", inta & ~handled); il->isr_stats.unhandled++; } if (inta & ~il->inta_mask) { - IL_WARN(il, "Disabled INTA bits 0x%08x were pending\n", + IL_WARN("Disabled INTA bits 0x%08x were pending\n", inta & ~il->inta_mask); - IL_WARN(il, " with FH_INT = 0x%08x\n", inta_fh); + IL_WARN(" with FH_INT = 0x%08x\n", inta_fh); } /* Re-enable all interrupts */ @@ -1708,7 +1708,7 @@ static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) * if IL_DL_IO is set */ val = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { - IL_ERR(il, "uCode INST section is invalid at " + IL_ERR("uCode INST section is invalid at " "offset 0x%x, is 0x%x, s/b 0x%x\n", save_len - len, val, le32_to_cpu(*image)); rc = -EIO; @@ -1750,7 +1750,7 @@ static int il3945_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) val = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { #if 0 /* Enable this if you want to see details */ - IL_ERR(il, "uCode INST section is invalid at " + IL_ERR("uCode INST section is invalid at " "offset 0x%x, is 0x%x, s/b 0x%x\n", i, val, *image); #endif @@ -1802,7 +1802,7 @@ static int il3945_verify_ucode(struct il_priv *il) return 0; } - IL_ERR(il, "NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); + IL_ERR("NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); /* Since nothing seems to match, show first several data entries in * instruction SRAM, so maybe visual inspection will give a clue. @@ -1867,7 +1867,7 @@ static int il3945_read_ucode(struct il_priv *il) sprintf(buf, "%s%u%s", name_pre, index, ".ucode"); ret = request_firmware(&ucode_raw, buf, &il->pci_dev->dev); if (ret < 0) { - IL_ERR(il, "%s firmware file req failed: %d\n", + IL_ERR("%s firmware file req failed: %d\n", buf, ret); if (ret == -ENOENT) continue; @@ -1875,7 +1875,7 @@ static int il3945_read_ucode(struct il_priv *il) goto error; } else { if (index < api_max) - IL_ERR(il, "Loaded firmware %s, " + IL_ERR("Loaded firmware %s, " "which is deprecated. " " Please use API v%u instead.\n", buf, api_max); @@ -1891,7 +1891,7 @@ static int il3945_read_ucode(struct il_priv *il) /* Make sure that we got at least our header! */ if (ucode_raw->size < il3945_ucode_get_header_size(1)) { - IL_ERR(il, "File size way too small!\n"); + IL_ERR("File size way too small!\n"); ret = -EINVAL; goto err_release; } @@ -1913,7 +1913,7 @@ static int il3945_read_ucode(struct il_priv *il) * on the API version read from firmware header from here on forward */ if (api_ver < api_min || api_ver > api_max) { - IL_ERR(il, "Driver unable to support your firmware API. " + IL_ERR("Driver unable to support your firmware API. " "Driver supports v%u, firmware is v%u.\n", api_max, api_ver); il->ucode_ver = 0; @@ -1921,12 +1921,12 @@ static int il3945_read_ucode(struct il_priv *il) goto err_release; } if (api_ver != api_max) - IL_ERR(il, "Firmware has old API version. Expected %u, " + IL_ERR("Firmware has old API version. Expected %u, " "got %u. New firmware can be obtained " "from http://www.intellinuxwireless.org.\n", api_max, api_ver); - IL_INFO(il, "loaded firmware version %u.%u.%u.%u\n", + IL_INFO("loaded firmware version %u.%u.%u.%u\n", IL_UCODE_MAJOR(il->ucode_ver), IL_UCODE_MINOR(il->ucode_ver), IL_UCODE_API(il->ucode_ver), @@ -2091,7 +2091,7 @@ static int il3945_read_ucode(struct il_priv *il) return 0; err_pci_alloc: - IL_ERR(il, "failed to allocate pci memory\n"); + IL_ERR("failed to allocate pci memory\n"); ret = -ENOMEM; il3945_dealloc_ucode_pci(il); @@ -2380,7 +2380,7 @@ static int il3945_alloc_bcast_station(struct il_priv *il) sta_id = il_prep_station(il, ctx, il_bcast_addr, false, NULL); if (sta_id == IL_INVALID_STATION) { - IL_ERR(il, "Unable to prepare broadcast station\n"); + IL_ERR("Unable to prepare broadcast station\n"); spin_unlock_irqrestore(&il->sta_lock, flags); return -EINVAL; @@ -2402,12 +2402,12 @@ static int __il3945_up(struct il_priv *il) return rc; if (test_bit(STATUS_EXIT_PENDING, &il->status)) { - IL_WARN(il, "Exit pending; will not bring the NIC up\n"); + IL_WARN("Exit pending; will not bring the NIC up\n"); return -EIO; } if (!il->ucode_data_backup.v_addr || !il->ucode_data.v_addr) { - IL_ERR(il, "ucode not available for device bring up\n"); + IL_ERR("ucode not available for device bring up\n"); return -EIO; } @@ -2417,7 +2417,7 @@ static int __il3945_up(struct il_priv *il) clear_bit(STATUS_RF_KILL_HW, &il->status); else { set_bit(STATUS_RF_KILL_HW, &il->status); - IL_WARN(il, "Radio disabled by HW RF Kill switch\n"); + IL_WARN("Radio disabled by HW RF Kill switch\n"); return -ENODEV; } @@ -2425,7 +2425,7 @@ static int __il3945_up(struct il_priv *il) rc = il3945_hw_nic_init(il); if (rc) { - IL_ERR(il, "Unable to int nic\n"); + IL_ERR("Unable to int nic\n"); return rc; } @@ -2460,7 +2460,7 @@ static int __il3945_up(struct il_priv *il) rc = il->cfg->ops->lib->load_ucode(il); if (rc) { - IL_ERR(il, + IL_ERR( "Unable to set up bootstrap uCode: %d\n", rc); continue; } @@ -2479,7 +2479,7 @@ static int __il3945_up(struct il_priv *il) /* tried to restart and config the device for as long as our * patience could withstand */ - IL_ERR(il, "Unable to initialize device after %d attempts.\n", i); + IL_ERR("Unable to initialize device after %d attempts.\n", i); return -EIO; } @@ -2650,7 +2650,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) band = IEEE80211_BAND_5GHZ; break; default: - IL_WARN(il, "Invalid scan band\n"); + IL_WARN("Invalid scan band\n"); return -EIO; } @@ -2770,7 +2770,7 @@ void il3945_post_associate(struct il_priv *il) rc = il_send_rxon_timing(il, ctx); if (rc) - IL_WARN(il, "REPLY_RXON_TIMING failed - " + IL_WARN("REPLY_RXON_TIMING failed - " "Attempting to continue.\n"); ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; @@ -2802,7 +2802,7 @@ void il3945_post_associate(struct il_priv *il) il3945_send_beacon_cmd(il); break; default: - IL_ERR(il, "%s Should not be called in %d mode\n", + IL_ERR("%s Should not be called in %d mode\n", __func__, ctx->vif->type); break; } @@ -2832,7 +2832,7 @@ static int il3945_mac_start(struct ieee80211_hw *hw) if (!il->ucode_code.len) { ret = il3945_read_ucode(il); if (ret) { - IL_ERR(il, "Could not read microcode: %d\n", ret); + IL_ERR("Could not read microcode: %d\n", ret); mutex_unlock(&il->mutex); goto out_release_irq; } @@ -2854,7 +2854,7 @@ static int il3945_mac_start(struct ieee80211_hw *hw) UCODE_READY_TIMEOUT); if (!ret) { if (!test_bit(STATUS_READY, &il->status)) { - IL_ERR(il, + IL_ERR( "Wait for START_ALIVE timeout after %dms.\n", jiffies_to_msecs(UCODE_READY_TIMEOUT)); ret = -ETIMEDOUT; @@ -2934,7 +2934,7 @@ void il3945_config_ap(struct il_priv *il) /* RXON Timing */ rc = il_send_rxon_timing(il, ctx); if (rc) - IL_WARN(il, "REPLY_RXON_TIMING failed - " + IL_WARN("REPLY_RXON_TIMING failed - " "Attempting to continue.\n"); ctx->staging.assoc_id = 0; @@ -3045,7 +3045,7 @@ static int il3945_mac_sta_add(struct ieee80211_hw *hw, &il->contexts[IL_RXON_CTX_BSS], sta->addr, is_ap, sta, &sta_id); if (ret) { - IL_ERR(il, "Unable to add station %pM (%d)\n", + IL_ERR("Unable to add station %pM (%d)\n", sta->addr, ret); /* Should we return success if return code is EEXIST ? */ mutex_unlock(&il->mutex); @@ -3147,11 +3147,11 @@ static ssize_t il3945_store_debug_level(struct device *d, ret = strict_strtoul(buf, 0, &val); if (ret) - IL_INFO(il, "%s is not in hex or decimal form.\n", buf); + IL_INFO("%s is not in hex or decimal form.\n", buf); else { il->debug_level = val; if (il_alloc_traffic_mem(il)) - IL_ERR(il, + IL_ERR( "Not enough memory to generate traffic log\n"); } return strnlen(buf, count); @@ -3192,7 +3192,7 @@ static ssize_t il3945_store_tx_power(struct device *d, val = simple_strtoul(p, &p, 10); if (p == buf) - IL_INFO(il, ": %s is not in decimal form.\n", buf); + IL_INFO(": %s is not in decimal form.\n", buf); else il3945_hw_reg_set_txpower(il, val); @@ -3222,7 +3222,7 @@ static ssize_t il3945_store_flags(struct device *d, if (le32_to_cpu(ctx->staging.flags) != flags) { /* Cancel any currently running scans... */ if (il_scan_cancel_timeout(il, 100)) - IL_WARN(il, "Could not cancel scan.\n"); + IL_WARN("Could not cancel scan.\n"); else { D_INFO("Committing rxon.flags = 0x%04X\n", flags); @@ -3259,7 +3259,7 @@ static ssize_t il3945_store_filter_flags(struct device *d, if (le32_to_cpu(ctx->staging.filter_flags) != filter_flags) { /* Cancel any currently running scans... */ if (il_scan_cancel_timeout(il, 100)) - IL_WARN(il, "Could not cancel scan.\n"); + IL_WARN("Could not cancel scan.\n"); else { D_INFO("Committing rxon.filter_flags = " "0x%04X\n", filter_flags); @@ -3551,14 +3551,14 @@ static int il3945_init_drv(struct il_priv *il) il->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; if (eeprom->version < EEPROM_3945_EEPROM_VERSION) { - IL_WARN(il, "Unsupported EEPROM version: 0x%04X\n", + IL_WARN("Unsupported EEPROM version: 0x%04X\n", eeprom->version); ret = -EINVAL; goto err; } ret = il_init_channel_map(il); if (ret) { - IL_ERR(il, "initializing regulatory failed: %d\n", ret); + IL_ERR("initializing regulatory failed: %d\n", ret); goto err; } @@ -3570,7 +3570,7 @@ static int il3945_init_drv(struct il_priv *il) ret = il_init_geos(il); if (ret) { - IL_ERR(il, "initializing geos failed: %d\n", ret); + IL_ERR("initializing geos failed: %d\n", ret); goto err_free_channel_map; } il3945_init_hw_rates(il, il->ieee_rates); @@ -3624,7 +3624,7 @@ static int il3945_setup_mac(struct il_priv *il) ret = ieee80211_register_hw(il->hw); if (ret) { - IL_ERR(il, "Failed to register hw (error %d)\n", ret); + IL_ERR("Failed to register hw (error %d)\n", ret); return ret; } il->mac80211_registered = 1; @@ -3692,7 +3692,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en il->inta_mask = CSR_INI_SET_MASK; if (il_alloc_traffic_mem(il)) - IL_ERR(il, "Not enough memory to generate traffic log\n"); + IL_ERR("Not enough memory to generate traffic log\n"); /*************************** * 2. Initializing PCI bus @@ -3711,7 +3711,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en if (!err) err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); if (err) { - IL_WARN(il, "No suitable DMA available.\n"); + IL_WARN("No suitable DMA available.\n"); goto out_pci_disable_device; } @@ -3757,7 +3757,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en /* Read the EEPROM */ err = il_eeprom_init(il); if (err) { - IL_ERR(il, "Unable to init EEPROM\n"); + IL_ERR("Unable to init EEPROM\n"); goto out_iounmap; } /* MAC Address location in EEPROM same for 3945/4965 */ @@ -3770,7 +3770,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en * ********************/ /* Device-specific setup */ if (il3945_hw_set_hw_params(il)) { - IL_ERR(il, "failed to set hw settings\n"); + IL_ERR("failed to set hw settings\n"); goto out_eeprom_free; } @@ -3780,11 +3780,11 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en err = il3945_init_drv(il); if (err) { - IL_ERR(il, "initializing driver failed\n"); + IL_ERR("initializing driver failed\n"); goto out_unset_hw_params; } - IL_INFO(il, "Detected Intel Wireless WiFi Link %s\n", + IL_INFO("Detected Intel Wireless WiFi Link %s\n", il->cfg->name); /*********************** @@ -3800,13 +3800,13 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en err = request_irq(il->pci_dev->irq, il_isr, IRQF_SHARED, DRV_NAME, il); if (err) { - IL_ERR(il, "Error allocating IRQ %d\n", il->pci_dev->irq); + IL_ERR("Error allocating IRQ %d\n", il->pci_dev->irq); goto out_disable_msi; } err = sysfs_create_group(&pdev->dev.kobj, &il3945_attribute_group); if (err) { - IL_ERR(il, "failed to create sysfs device attributes\n"); + IL_ERR("failed to create sysfs device attributes\n"); goto out_release_irq; } @@ -3829,7 +3829,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en err = il_dbgfs_register(il, DRV_NAME); if (err) - IL_ERR(il, "failed to create debugfs files. Ignoring error: %d\n", err); + IL_ERR("failed to create debugfs files. Ignoring error: %d\n", err); /* Start monitoring the killswitch */ queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index 88dc8db3d661..df7e0a484dfe 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -115,7 +115,7 @@ static void il4965_clear_free_frames(struct il_priv *il) } if (il->frames_count) { - IL_WARN(il, "%d frames still in use. Did we lose one?\n", + IL_WARN("%d frames still in use. Did we lose one?\n", il->frames_count); il->frames_count = 0; } @@ -128,7 +128,7 @@ static struct il_frame *il4965_get_free_frame(struct il_priv *il) if (list_empty(&il->free_frames)) { frame = kzalloc(sizeof(*frame), GFP_KERNEL); if (!frame) { - IL_ERR(il, "Could not allocate frame!\n"); + IL_ERR("Could not allocate frame!\n"); return NULL; } @@ -188,7 +188,7 @@ static void il4965_set_beacon_tim(struct il_priv *il, tx_beacon_cmd->tim_idx = cpu_to_le16(tim_idx); tx_beacon_cmd->tim_size = beacon[tim_idx+1]; } else - IL_WARN(il, "Unable to find TIM Element in beacon\n"); + IL_WARN("Unable to find TIM Element in beacon\n"); } static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *il, @@ -206,7 +206,7 @@ static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *il, lockdep_assert_held(&il->mutex); if (!il->beacon_ctx) { - IL_ERR(il, "trying to build beacon w/o beacon context!\n"); + IL_ERR("trying to build beacon w/o beacon context!\n"); return 0; } @@ -254,14 +254,14 @@ int il4965_send_beacon_cmd(struct il_priv *il) frame = il4965_get_free_frame(il); if (!frame) { - IL_ERR(il, "Could not obtain free frame buffer for beacon " + IL_ERR("Could not obtain free frame buffer for beacon " "command.\n"); return -ENOMEM; } frame_size = il4965_hw_get_beacon_cmd(il, frame); if (!frame_size) { - IL_ERR(il, "Error configuring the beacon command\n"); + IL_ERR("Error configuring the beacon command\n"); il4965_free_frame(il, frame); return -EINVAL; } @@ -336,7 +336,7 @@ void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) num_tbs = il4965_tfd_get_num_tbs(tfd); if (num_tbs >= IL_NUM_OF_TBS) { - IL_ERR(il, "Too many chunks: %i\n", num_tbs); + IL_ERR("Too many chunks: %i\n", num_tbs); /* @todo issue fatal error, it is quite serious situation */ return; } @@ -388,14 +388,14 @@ int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, /* Each TFD can point to a maximum 20 Tx buffers */ if (num_tbs >= IL_NUM_OF_TBS) { - IL_ERR(il, "Error can not send more than %d chunks\n", + IL_ERR("Error can not send more than %d chunks\n", IL_NUM_OF_TBS); return -EINVAL; } BUG_ON(addr & ~DMA_BIT_MASK(36)); if (unlikely(addr & ~IL_TX_DMA_MASK)) - IL_ERR(il, "Unaligned address = %llx\n", + IL_ERR("Unaligned address = %llx\n", (unsigned long long)addr); il4965_tfd_set_tb(tfd, num_tbs, addr, len); @@ -460,7 +460,7 @@ static void il4965_rx_reply_alive(struct il_priv *il, queue_delayed_work(il->workqueue, pwork, msecs_to_jiffies(5)); else - IL_WARN(il, "uCode did not respond OK.\n"); + IL_WARN("uCode did not respond OK.\n"); } /** @@ -725,7 +725,7 @@ void il4965_rx_handle(struct il_priv *il) if (rxb->page) il_tx_cmd_complete(il, rxb); else - IL_WARN(il, "Claim null rxb?\n"); + IL_WARN("Claim null rxb?\n"); } /* Reuse the page if possible. For notification packets and @@ -818,7 +818,7 @@ static void il4965_irq_tasklet(struct il_priv *il) /* Now service all interrupt bits discovered above. */ if (inta & CSR_INT_BIT_HW_ERR) { - IL_ERR(il, "Hardware error detected. Restarting.\n"); + IL_ERR("Hardware error detected. Restarting.\n"); /* Tell the device to stop sending interrupts */ il_disable_interrupts(il); @@ -857,7 +857,7 @@ static void il4965_irq_tasklet(struct il_priv *il) CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) hw_rf_kill = 1; - IL_WARN(il, "RF_KILL bit toggled to %s.\n", + IL_WARN("RF_KILL bit toggled to %s.\n", hw_rf_kill ? "disable radio" : "enable radio"); il->isr_stats.rfkill++; @@ -880,14 +880,14 @@ static void il4965_irq_tasklet(struct il_priv *il) /* Chip got too hot and stopped itself */ if (inta & CSR_INT_BIT_CT_KILL) { - IL_ERR(il, "Microcode CT kill error detected.\n"); + IL_ERR("Microcode CT kill error detected.\n"); il->isr_stats.ctkill++; handled |= CSR_INT_BIT_CT_KILL; } /* Error detected by uCode */ if (inta & CSR_INT_BIT_SW_ERR) { - IL_ERR(il, "Microcode SW error detected. " + IL_ERR("Microcode SW error detected. " " Restarting 0x%X.\n", inta); il->isr_stats.sw++; il_irq_handle_error(il); @@ -928,14 +928,14 @@ static void il4965_irq_tasklet(struct il_priv *il) } if (inta & ~handled) { - IL_ERR(il, "Unhandled INTA bits 0x%08x\n", inta & ~handled); + IL_ERR("Unhandled INTA bits 0x%08x\n", inta & ~handled); il->isr_stats.unhandled++; } if (inta & ~(il->inta_mask)) { - IL_WARN(il, "Disabled INTA bits 0x%08x were pending\n", + IL_WARN("Disabled INTA bits 0x%08x were pending\n", inta & ~il->inta_mask); - IL_WARN(il, " with FH_INT = 0x%08x\n", inta_fh); + IL_WARN(" with FH_INT = 0x%08x\n", inta_fh); } /* Re-enable all interrupts */ @@ -993,11 +993,11 @@ static ssize_t il4965_store_debug_level(struct device *d, ret = strict_strtoul(buf, 0, &val); if (ret) - IL_ERR(il, "%s is not in hex or decimal form.\n", buf); + IL_ERR("%s is not in hex or decimal form.\n", buf); else { il->debug_level = val; if (il_alloc_traffic_mem(il)) - IL_ERR(il, + IL_ERR( "Not enough memory to generate traffic log\n"); } return strnlen(buf, count); @@ -1044,11 +1044,11 @@ static ssize_t il4965_store_tx_power(struct device *d, ret = strict_strtoul(buf, 10, &val); if (ret) - IL_INFO(il, "%s is not in decimal form.\n", buf); + IL_INFO("%s is not in decimal form.\n", buf); else { ret = il_set_tx_power(il, val, false); if (ret) - IL_ERR(il, "failed setting tx power (0x%d).\n", + IL_ERR("failed setting tx power (0x%d).\n", ret); else ret = count; @@ -1114,7 +1114,7 @@ static int __must_check il4965_request_firmware(struct il_priv *il, bool first) } if (il->fw_index < il->cfg->ucode_api_min) { - IL_ERR(il, "no suitable firmware found!\n"); + IL_ERR("no suitable firmware found!\n"); return -ENOENT; } @@ -1151,7 +1151,7 @@ static int il4965_load_firmware(struct il_priv *il, case 2: hdr_size = 24; if (ucode_raw->size < hdr_size) { - IL_ERR(il, "File size too small!\n"); + IL_ERR("File size too small!\n"); return -EINVAL; } pieces->inst_size = le32_to_cpu(ucode->v1.inst_size); @@ -1169,7 +1169,7 @@ static int il4965_load_firmware(struct il_priv *il, pieces->data_size + pieces->init_size + pieces->init_data_size + pieces->boot_size) { - IL_ERR(il, + IL_ERR( "uCode file size %d does not match expected size\n", (int)ucode_raw->size); return -EINVAL; @@ -1214,7 +1214,7 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) if (!ucode_raw) { if (il->fw_index <= il->cfg->ucode_api_max) - IL_ERR(il, + IL_ERR( "request for firmware file '%s' failed.\n", il->firmware_name); goto try_again; @@ -1225,7 +1225,7 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) /* Make sure that we got at least the API version number */ if (ucode_raw->size < 4) { - IL_ERR(il, "File size way too small!\n"); + IL_ERR("File size way too small!\n"); goto try_again; } @@ -1245,7 +1245,7 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) * on the API version read from firmware header from here on forward */ if (api_ver < api_min || api_ver > api_max) { - IL_ERR(il, + IL_ERR( "Driver unable to support your firmware API. " "Driver supports v%u, firmware is v%u.\n", api_max, api_ver); @@ -1253,13 +1253,13 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) } if (api_ver != api_max) - IL_ERR(il, + IL_ERR( "Firmware has old API version. Expected v%u, " "got v%u. New firmware can be obtained " "from http://www.intellinuxwireless.org.\n", api_max, api_ver); - IL_INFO(il, "loaded firmware version %u.%u.%u.%u\n", + IL_INFO("loaded firmware version %u.%u.%u.%u\n", IL_UCODE_MAJOR(il->ucode_ver), IL_UCODE_MINOR(il->ucode_ver), IL_UCODE_API(il->ucode_ver), @@ -1294,31 +1294,31 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) /* Verify that uCode images will fit in card's SRAM */ if (pieces.inst_size > il->hw_params.max_inst_size) { - IL_ERR(il, "uCode instr len %Zd too large to fit in\n", + IL_ERR("uCode instr len %Zd too large to fit in\n", pieces.inst_size); goto try_again; } if (pieces.data_size > il->hw_params.max_data_size) { - IL_ERR(il, "uCode data len %Zd too large to fit in\n", + IL_ERR("uCode data len %Zd too large to fit in\n", pieces.data_size); goto try_again; } if (pieces.init_size > il->hw_params.max_inst_size) { - IL_ERR(il, "uCode init instr len %Zd too large to fit in\n", + IL_ERR("uCode init instr len %Zd too large to fit in\n", pieces.init_size); goto try_again; } if (pieces.init_data_size > il->hw_params.max_data_size) { - IL_ERR(il, "uCode init data len %Zd too large to fit in\n", + IL_ERR("uCode init data len %Zd too large to fit in\n", pieces.init_data_size); goto try_again; } if (pieces.boot_size > il->hw_params.max_bsm_size) { - IL_ERR(il, "uCode boot instr len %Zd too large to fit in\n", + IL_ERR("uCode boot instr len %Zd too large to fit in\n", pieces.boot_size); goto try_again; } @@ -1427,13 +1427,13 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) err = il_dbgfs_register(il, DRV_NAME); if (err) - IL_ERR(il, + IL_ERR( "failed to create debugfs files. Ignoring error: %d\n", err); err = sysfs_create_group(&il->pci_dev->dev.kobj, &il_attribute_group); if (err) { - IL_ERR(il, "failed to create sysfs device attributes\n"); + IL_ERR("failed to create sysfs device attributes\n"); goto out_unbind; } @@ -1450,7 +1450,7 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) return; err_pci_alloc: - IL_ERR(il, "failed to allocate pci memory\n"); + IL_ERR("failed to allocate pci memory\n"); il4965_dealloc_ucode_pci(il); out_unbind: complete(&il->_4965.firmware_loading_complete); @@ -1541,7 +1541,7 @@ void il4965_dump_nic_error_log(struct il_priv *il) } if (!il->cfg->ops->lib->is_valid_rtc_data_addr(base)) { - IL_ERR(il, + IL_ERR( "Not valid error log pointer 0x%08X for %s uCode\n", base, (il->ucode_type == UCODE_INIT) ? "Init" : "RT"); return; @@ -1550,8 +1550,8 @@ void il4965_dump_nic_error_log(struct il_priv *il) count = il_read_targ_mem(il, base); if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { - IL_ERR(il, "Start IWL Error Log Dump:\n"); - IL_ERR(il, "Status: 0x%08lX, count: %d\n", + IL_ERR("Start IWL Error Log Dump:\n"); + IL_ERR("Status: 0x%08lX, count: %d\n", il->status, count); } @@ -1568,12 +1568,12 @@ void il4965_dump_nic_error_log(struct il_priv *il) time = il_read_targ_mem(il, base + 11 * sizeof(u32)); hcmd = il_read_targ_mem(il, base + 22 * sizeof(u32)); - IL_ERR(il, "Desc Time " + IL_ERR("Desc Time " "data1 data2 line\n"); - IL_ERR(il, "%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n", + IL_ERR("%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n", il4965_desc_lookup(desc), desc, time, data1, data2, line); - IL_ERR(il, "pc blink1 blink2 ilink1 ilink2 hcmd\n"); - IL_ERR(il, "0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n", + IL_ERR("pc blink1 blink2 ilink1 ilink2 hcmd\n"); + IL_ERR("0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n", pc, blink1, blink2, ilink1, ilink2, hcmd); } @@ -1594,7 +1594,7 @@ static void il4965_rf_kill_ct_config(struct il_priv *il) ret = il_send_cmd_pdu(il, REPLY_CT_KILL_CONFIG_CMD, sizeof(cmd), &cmd); if (ret) - IL_ERR(il, "REPLY_CT_KILL_CONFIG_CMD failed\n"); + IL_ERR("REPLY_CT_KILL_CONFIG_CMD failed\n"); else D_INFO("REPLY_CT_KILL_CONFIG_CMD " "succeeded, " @@ -1740,7 +1740,7 @@ static void il4965_alive_start(struct il_priv *il) ret = il4965_alive_notify(il); if (ret) { - IL_WARN(il, + IL_WARN( "Could not complete ALIVE transition [ntf]: %d\n", ret); goto restart; } @@ -1955,12 +1955,12 @@ static int __il4965_up(struct il_priv *il) int ret; if (test_bit(STATUS_EXIT_PENDING, &il->status)) { - IL_WARN(il, "Exit pending; will not bring the NIC up\n"); + IL_WARN("Exit pending; will not bring the NIC up\n"); return -EIO; } if (!il->ucode_data_backup.v_addr || !il->ucode_data.v_addr) { - IL_ERR(il, "ucode not available for device bringup\n"); + IL_ERR("ucode not available for device bringup\n"); return -EIO; } @@ -1975,7 +1975,7 @@ static int __il4965_up(struct il_priv *il) il4965_prepare_card_hw(il); if (!il->hw_ready) { - IL_WARN(il, "Exit HW not ready\n"); + IL_WARN("Exit HW not ready\n"); return -EIO; } @@ -1990,7 +1990,7 @@ static int __il4965_up(struct il_priv *il) wiphy_rfkill_set_hw_state(il->hw->wiphy, true); il_enable_interrupts(il); - IL_WARN(il, "Radio disabled by HW RF Kill switch\n"); + IL_WARN("Radio disabled by HW RF Kill switch\n"); return 0; } @@ -2001,7 +2001,7 @@ static int __il4965_up(struct il_priv *il) ret = il4965_hw_nic_init(il); if (ret) { - IL_ERR(il, "Unable to init nic\n"); + IL_ERR("Unable to init nic\n"); return ret; } @@ -2032,7 +2032,7 @@ static int __il4965_up(struct il_priv *il) ret = il->cfg->ops->lib->load_ucode(il); if (ret) { - IL_ERR(il, "Unable to set up bootstrap uCode: %d\n", + IL_ERR("Unable to set up bootstrap uCode: %d\n", ret); continue; } @@ -2051,7 +2051,7 @@ static int __il4965_up(struct il_priv *il) /* tried to restart and config the device for as long as our * patience could withstand */ - IL_ERR(il, "Unable to initialize device after %d attempts.\n", i); + IL_ERR("Unable to initialize device after %d attempts.\n", i); return -EIO; } @@ -2229,7 +2229,7 @@ static int il4965_mac_setup_register(struct il_priv *il, ret = ieee80211_register_hw(il->hw); if (ret) { - IL_ERR(il, "Failed to register hw (error %d)\n", ret); + IL_ERR("Failed to register hw (error %d)\n", ret); return ret; } il->mac80211_registered = 1; @@ -2265,7 +2265,7 @@ int il4965_mac_start(struct ieee80211_hw *hw) UCODE_READY_TIMEOUT); if (!ret) { if (!test_bit(STATUS_READY, &il->status)) { - IL_ERR(il, "START_ALIVE timeout after %dms.\n", + IL_ERR("START_ALIVE timeout after %dms.\n", jiffies_to_msecs(UCODE_READY_TIMEOUT)); return -ETIMEDOUT; } @@ -2475,7 +2475,7 @@ int il4965_mac_sta_add(struct ieee80211_hw *hw, ret = il_add_station_common(il, vif_priv->ctx, sta->addr, is_ap, sta, &sta_id); if (ret) { - IL_ERR(il, "Unable to add station %pM (%d)\n", + IL_ERR("Unable to add station %pM (%d)\n", sta->addr, ret); /* Should we return success if return code is EEXIST ? */ mutex_unlock(&il->mutex); @@ -2792,13 +2792,13 @@ static int il4965_init_drv(struct il_priv *il) ret = il_init_channel_map(il); if (ret) { - IL_ERR(il, "initializing regulatory failed: %d\n", ret); + IL_ERR("initializing regulatory failed: %d\n", ret); goto err; } ret = il_init_geos(il); if (ret) { - IL_ERR(il, "initializing geos failed: %d\n", ret); + IL_ERR("initializing geos failed: %d\n", ret); goto err_free_channel_map; } il4965_init_hw_rates(il, il->ieee_rates); @@ -2917,7 +2917,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) il->inta_mask = CSR_INI_SET_MASK; if (il_alloc_traffic_mem(il)) - IL_ERR(il, "Not enough memory to generate traffic log\n"); + IL_ERR("Not enough memory to generate traffic log\n"); /************************** * 2. Initializing PCI bus @@ -2942,7 +2942,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) DMA_BIT_MASK(32)); /* both attempts failed: */ if (err) { - IL_WARN(il, "No suitable DMA available.\n"); + IL_WARN("No suitable DMA available.\n"); goto out_pci_disable_device; } } @@ -2981,7 +2981,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) il_write32(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); il4965_hw_detect(il); - IL_INFO(il, "Detected %s, REV=0x%X\n", + IL_INFO("Detected %s, REV=0x%X\n", il->cfg->name, il->hw_rev); /* We disable the RETRY_TIMEOUT register (0x41) to keep @@ -2990,7 +2990,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) il4965_prepare_card_hw(il); if (!il->hw_ready) { - IL_WARN(il, "Failed, HW not ready\n"); + IL_WARN("Failed, HW not ready\n"); goto out_iounmap; } @@ -3000,7 +3000,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) /* Read the EEPROM */ err = il_eeprom_init(il); if (err) { - IL_ERR(il, "Unable to init EEPROM\n"); + IL_ERR("Unable to init EEPROM\n"); goto out_iounmap; } err = il4965_eeprom_check_version(il); @@ -3020,7 +3020,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) * 5. Setup HW constants ************************/ if (il4965_set_hw_params(il)) { - IL_ERR(il, "failed to set hw parameters\n"); + IL_ERR("failed to set hw parameters\n"); goto out_free_eeprom; } @@ -3045,7 +3045,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err = request_irq(il->pci_dev->irq, il_isr, IRQF_SHARED, DRV_NAME, il); if (err) { - IL_ERR(il, "Error allocating IRQ %d\n", il->pci_dev->irq); + IL_ERR("Error allocating IRQ %d\n", il->pci_dev->irq); goto out_disable_msi; } -- cgit v1.2.3 From b6297cd2aa4ec318b3634e6c1ca4cf063a0042c9 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Thu, 18 Aug 2011 22:27:04 +0200 Subject: iwlegacy: remove IL_CRIT Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-4965-lib.c | 2 +- drivers/net/wireless/iwlegacy/iwl-debug.h | 1 - drivers/net/wireless/iwlegacy/iwl3945-base.c | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index f4df28d5973c..6503b8faf08b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -309,7 +309,7 @@ static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) if ((rxq->free_count <= RX_LOW_WATERMARK) && net_ratelimit()) - IL_CRIT( + IL_ERR( "Failed to alloc_pages with %s. " "Only %u free buffers remaining.\n", priority == GFP_ATOMIC ? diff --git a/drivers/net/wireless/iwlegacy/iwl-debug.h b/drivers/net/wireless/iwlegacy/iwl-debug.h index 373188df7cc8..77467de7e028 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debug.h +++ b/drivers/net/wireless/iwlegacy/iwl-debug.h @@ -35,7 +35,6 @@ extern u32 il_debug_level; #define IL_ERR(f, a...) dev_err(&il->pci_dev->dev, f, ## a) #define IL_WARN(f, a...) dev_warn(&il->pci_dev->dev, f, ## a) #define IL_INFO(f, a...) dev_info(&il->pci_dev->dev, f, ## a) -#define IL_CRIT(f, a...) dev_crit(&il->pci_dev->dev, f, ## a) #define il_print_hex_error(il, p, len) \ do { \ diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 8a6b1937336c..66aa8505f4fe 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -1043,7 +1043,7 @@ static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) D_INFO("Failed to allocate SKB buffer.\n"); if ((rxq->free_count <= RX_LOW_WATERMARK) && net_ratelimit()) - IL_CRIT("Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", + IL_ERR("Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", priority == GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL", rxq->free_count); /* We don't reschedule replenish work here -- we will -- cgit v1.2.3 From 841b2ccac3251fdbf7a0bc26724874cdc35df96c Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 24 Aug 2011 15:14:03 +0200 Subject: iwlegacy: rename il_{read,write}32 to _il_{rd,wr} Introduce rule that underscore at the beginning mean unlocked I/O method. Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-3945.c | 4 +- drivers/net/wireless/iwlegacy/iwl-4965-led.c | 6 +-- drivers/net/wireless/iwlegacy/iwl-core.c | 10 ++--- drivers/net/wireless/iwlegacy/iwl-csr.h | 6 +-- drivers/net/wireless/iwlegacy/iwl-debugfs.c | 2 +- drivers/net/wireless/iwlegacy/iwl-eeprom.c | 6 +-- drivers/net/wireless/iwlegacy/iwl-helpers.h | 10 ++--- drivers/net/wireless/iwlegacy/iwl-io.h | 23 +++++------- drivers/net/wireless/iwlegacy/iwl-rx.c | 2 +- drivers/net/wireless/iwlegacy/iwl-tx.c | 4 +- drivers/net/wireless/iwlegacy/iwl3945-base.c | 42 ++++++++++----------- drivers/net/wireless/iwlegacy/iwl4965-base.c | 56 ++++++++++++++-------------- 12 files changed, 84 insertions(+), 87 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index cf47fdb28aa1..6e2e71acbef6 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -1058,7 +1058,7 @@ static inline int il3945_hw_reg_temp_out_of_range(int temperature) int il3945_hw_get_temperature(struct il_priv *il) { - return il_read32(il, CSR_UCODE_DRV_GP2); + return _il_rd(il, CSR_UCODE_DRV_GP2); } /** @@ -2211,7 +2211,7 @@ int il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq) FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE); /* fake read to flush all prev. writes */ - il_read32(il, FH39_TSSR_CBB_BASE); + _il_rd(il, FH39_TSSR_CBB_BASE); return 0; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-led.c b/drivers/net/wireless/iwlegacy/iwl-4965-led.c index 1436a1b7ebf6..48541577202a 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-led.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-led.c @@ -55,9 +55,9 @@ il4965_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd) }; u32 reg; - reg = il_read32(il, CSR_LED_REG); + reg = _il_rd(il, CSR_LED_REG); if (reg != (reg & CSR_LED_BSM_CTRL_MSK)) - il_write32(il, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK); + _il_wr(il, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK); return il_send_cmd(il, &cmd); } @@ -65,7 +65,7 @@ il4965_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd) /* Set led register off */ void il4965_led_enable(struct il_priv *il) { - il_write32(il, CSR_LED_REG, CSR_LED_REG_TRUN_ON); + _il_wr(il, CSR_LED_REG, CSR_LED_REG_TRUN_ON); } const struct il_led_ops il4965_led_ops = { diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index 42be833bdc75..c5ffd91af5d0 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -2001,7 +2001,7 @@ int il_pci_resume(struct device *device) il_enable_interrupts(il); - if (!(il_read32(il, CSR_GP_CNTRL) & + if (!(_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) hw_rfkill = true; @@ -2580,12 +2580,12 @@ irqreturn_t il_isr(int irq, void *data) * back-to-back ISRs and sporadic interrupts from our NIC. * If we have something to service, the tasklet will re-enable ints. * If we *don't* have something, we'll re-enable before leaving here. */ - inta_mask = il_read32(il, CSR_INT_MASK); /* just for debug */ - il_write32(il, CSR_INT_MASK, 0x00000000); + inta_mask = _il_rd(il, CSR_INT_MASK); /* just for debug */ + _il_wr(il, CSR_INT_MASK, 0x00000000); /* Discover which interrupts are active/pending */ - inta = il_read32(il, CSR_INT); - inta_fh = il_read32(il, CSR_FH_INT_STATUS); + inta = _il_rd(il, CSR_INT); + inta_fh = _il_rd(il, CSR_FH_INT_STATUS); /* Ignore interrupt if there's nothing in NIC to service. * This may be due to IRQ shared with another device, diff --git a/drivers/net/wireless/iwlegacy/iwl-csr.h b/drivers/net/wireless/iwlegacy/iwl-csr.h index 24b71ae79040..faffb8e180b4 100644 --- a/drivers/net/wireless/iwlegacy/iwl-csr.h +++ b/drivers/net/wireless/iwlegacy/iwl-csr.h @@ -70,7 +70,7 @@ * low power states due to driver-invoked device resets * (e.g. CSR_RESET_REG_FLAG_SW_RESET) or uCode-driven power-saving modes. * - * Use il_write32() and il_read32() family to access these registers; + * Use _il_wr() and _il_rd() family to access these registers; * these provide simple PCI bus access, without waking up the MAC. * Do not use il_write_direct32() family for these registers; * no need to "grab nic access" via CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ. @@ -91,7 +91,7 @@ #define CSR_RESET (CSR_BASE+0x020) /* busmaster enable, NMI, etc*/ #define CSR_GP_CNTRL (CSR_BASE+0x024) -/* 2nd byte of CSR_INT_COALESCING, not accessible via il_write32()! */ +/* 2nd byte of CSR_INT_COALESCING, not accessible via _il_wr()! */ #define CSR_INT_PERIODIC_REG (CSR_BASE+0x005) /* @@ -374,7 +374,7 @@ * to make sure the MAC (uCode processor, etc.) is powered up for accessing * internal resources. * - * Do not use il_write32()/il_read32() family to access these registers; + * Do not use _il_wr()/_il_rd() family to access these registers; * these provide only simple PCI bus access, without waking up the MAC. */ #define HBUS_BASE (0x400) diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index 45b71a8b9af5..cd15e67c94d3 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -1018,7 +1018,7 @@ static ssize_t il_dbgfs_power_save_status_read(struct file *file, const size_t bufsz = sizeof(buf); u32 pwrsave_status; - pwrsave_status = il_read32(il, CSR_GP_CNTRL) & + pwrsave_status = _il_rd(il, CSR_GP_CNTRL) & CSR_GP_REG_POWER_SAVE_STATUS_MSK; pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: "); diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-eeprom.c index 5f0fd2afedfe..26cf50699efc 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.c @@ -144,7 +144,7 @@ static const u8 il_eeprom_band_7[] = { /* 5.2 ht40 channel */ static int il_eeprom_verify_signature(struct il_priv *il) { - u32 gp = il_read32(il, CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; + u32 gp = _il_rd(il, CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; int ret = 0; D_EEPROM("EEPROM signature=0x%08x\n", gp); @@ -187,7 +187,7 @@ EXPORT_SYMBOL(il_eeprom_query16); int il_eeprom_init(struct il_priv *il) { __le16 *e; - u32 gp = il_read32(il, CSR_EEPROM_GP); + u32 gp = _il_rd(il, CSR_EEPROM_GP); int sz; int ret; u16 addr; @@ -223,7 +223,7 @@ int il_eeprom_init(struct il_priv *il) for (addr = 0; addr < sz; addr += sizeof(u16)) { u32 r; - _il_write32(il, CSR_EEPROM_REG, + _il_wr(il, CSR_EEPROM_REG, CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); ret = il_poll_bit(il, CSR_EEPROM_REG, diff --git a/drivers/net/wireless/iwlegacy/iwl-helpers.h b/drivers/net/wireless/iwlegacy/iwl-helpers.h index a0a84b295253..a9d87023e69f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-helpers.h +++ b/drivers/net/wireless/iwlegacy/iwl-helpers.h @@ -149,26 +149,26 @@ static inline void il_disable_interrupts(struct il_priv *il) clear_bit(STATUS_INT_ENABLED, &il->status); /* disable interrupts from uCode/NIC to host */ - il_write32(il, CSR_INT_MASK, 0x00000000); + _il_wr(il, CSR_INT_MASK, 0x00000000); /* acknowledge/clear/reset any interrupts still pending * from uCode or flow handler (Rx/Tx DMA) */ - il_write32(il, CSR_INT, 0xffffffff); - il_write32(il, CSR_FH_INT_STATUS, 0xffffffff); + _il_wr(il, CSR_INT, 0xffffffff); + _il_wr(il, CSR_FH_INT_STATUS, 0xffffffff); D_ISR("Disabled interrupts\n"); } static inline void il_enable_rfkill_int(struct il_priv *il) { D_ISR("Enabling rfkill interrupt\n"); - il_write32(il, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); + _il_wr(il, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); } static inline void il_enable_interrupts(struct il_priv *il) { D_ISR("Enabling interrupts\n"); set_bit(STATUS_INT_ENABLED, &il->status); - il_write32(il, CSR_INT_MASK, il->inta_mask); + _il_wr(il, CSR_INT_MASK, il->inta_mask); } /** diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h index 1afd5c04d538..cdbcfde20123 100644 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ b/drivers/net/wireless/iwlegacy/iwl-io.h @@ -40,18 +40,15 @@ static inline void _il_write8(struct il_priv *il, u32 ofs, u8 val) } #define il_write8(il, ofs, val) _il_write8(il, ofs, val) -static inline void _il_write32(struct il_priv *il, u32 ofs, u32 val) +static inline void _il_wr(struct il_priv *il, u32 ofs, u32 val) { iowrite32(val, il->hw_base + ofs); } -#define il_write32(il, ofs, val) _il_write32(il, ofs, val) -static inline u32 _il_read32(struct il_priv *il, u32 ofs) +static inline u32 _il_rd(struct il_priv *il, u32 ofs) { - u32 val = ioread32(il->hw_base + ofs); - return val; + return ioread32(il->hw_base + ofs); } -#define il_read32(p, o) _il_read32(p, o) #define IL_POLL_INTERVAL 10 /* microseconds */ static inline int @@ -61,7 +58,7 @@ _il_poll_bit(struct il_priv *il, u32 addr, int t = 0; do { - if ((_il_read32(il, addr) & mask) == (bits & mask)) + if ((_il_rd(il, addr) & mask) == (bits & mask)) return t; udelay(IL_POLL_INTERVAL); t += IL_POLL_INTERVAL; @@ -73,7 +70,7 @@ _il_poll_bit(struct il_priv *il, u32 addr, static inline void _il_set_bit(struct il_priv *il, u32 reg, u32 mask) { - _il_write32(il, reg, _il_read32(il, reg) | mask); + _il_wr(il, reg, _il_rd(il, reg) | mask); } static inline void il_set_bit(struct il_priv *p, u32 r, u32 m) @@ -88,7 +85,7 @@ static inline void il_set_bit(struct il_priv *p, u32 r, u32 m) static inline void _il_clear_bit(struct il_priv *il, u32 reg, u32 mask) { - _il_write32(il, reg, _il_read32(il, reg) & ~mask); + _il_wr(il, reg, _il_rd(il, reg) & ~mask); } static inline void il_clear_bit(struct il_priv *p, u32 r, u32 m) @@ -131,10 +128,10 @@ static inline int _il_grab_nic_access(struct il_priv *il) (CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY | CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 15000); if (ret < 0) { - val = _il_read32(il, CSR_GP_CNTRL); + val = _il_rd(il, CSR_GP_CNTRL); IL_ERR( "MAC is in deep sleep!. CSR_GP_CNTRL = 0x%08X\n", val); - _il_write32(il, CSR_RESET, + _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_FORCE_NMI); return -EIO; } @@ -152,7 +149,7 @@ static inline void _il_release_nic_access(struct il_priv *il) static inline u32 _il_read_direct32(struct il_priv *il, u32 reg) { - return _il_read32(il, reg); + return _il_rd(il, reg); } static inline u32 il_read_direct32(struct il_priv *il, u32 reg) @@ -172,7 +169,7 @@ static inline u32 il_read_direct32(struct il_priv *il, u32 reg) static inline void _il_write_direct32(struct il_priv *il, u32 reg, u32 value) { - _il_write32(il, reg, value); + _il_wr(il, reg, value); } static inline void il_write_direct32(struct il_priv *il, u32 reg, u32 value) diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c index 183acdc69a25..e481ca8c0cc9 100644 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -138,7 +138,7 @@ il_rx_queue_update_write_ptr(struct il_priv *il, /* If power-saving is in use, make sure device is awake */ if (test_bit(STATUS_POWER_PMI, &il->status)) { - reg = il_read32(il, CSR_UCODE_DRV_GP1); + reg = _il_rd(il, CSR_UCODE_DRV_GP1); if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { D_INFO( diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index cfc015ae203b..6b5e652c4fc3 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -55,7 +55,7 @@ il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq) /* wake up nic if it's powered down ... * uCode will wake up, and interrupt us again, so next * time we'll skip this part. */ - reg = il_read32(il, CSR_UCODE_DRV_GP1); + reg = _il_rd(il, CSR_UCODE_DRV_GP1); if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { D_INFO( @@ -75,7 +75,7 @@ il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq) * trying to tx (during RFKILL, we're not trying to tx). */ } else - il_write32(il, HBUS_TARG_WRPTR, + _il_wr(il, HBUS_TARG_WRPTR, txq->q.write_ptr | (txq_id << 8)); txq->need_update = 0; } diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 66aa8505f4fe..def314073ce8 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -824,7 +824,7 @@ static void il3945_rx_card_state_notif(struct il_priv *il, (flags & HW_CARD_DISABLED) ? "Kill" : "On", (flags & SW_CARD_DISABLED) ? "Kill" : "On"); - il_write32(il, CSR_UCODE_DRV_GP1_SET, + _il_wr(il, CSR_UCODE_DRV_GP1_SET, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); if (flags & HW_CARD_DISABLED) @@ -1419,19 +1419,19 @@ static void il3945_irq_tasklet(struct il_priv *il) /* Ack/clear/reset pending uCode interrupts. * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS, * and will clear only when CSR_FH_INT_STATUS gets cleared. */ - inta = il_read32(il, CSR_INT); - il_write32(il, CSR_INT, inta); + inta = _il_rd(il, CSR_INT); + _il_wr(il, CSR_INT, inta); /* Ack/clear/reset pending flow-handler (DMA) interrupts. * Any new interrupts that happen after this, either while we're * in this tasklet, or later, will show up in next ISR/tasklet. */ - inta_fh = il_read32(il, CSR_FH_INT_STATUS); - il_write32(il, CSR_FH_INT_STATUS, inta_fh); + inta_fh = _il_rd(il, CSR_FH_INT_STATUS); + _il_wr(il, CSR_FH_INT_STATUS, inta_fh); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG if (il_get_debug_level(il) & IL_DL_ISR) { /* just for debug */ - inta_mask = il_read32(il, CSR_INT_MASK); + inta_mask = _il_rd(il, CSR_INT_MASK); D_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, inta_mask, inta_fh); } @@ -1519,7 +1519,7 @@ static void il3945_irq_tasklet(struct il_priv *il) D_ISR("Tx interrupt\n"); il->isr_stats.tx++; - il_write32(il, CSR_FH_INT_STATUS, (1 << 6)); + _il_wr(il, CSR_FH_INT_STATUS, (1 << 6)); il_write_direct32(il, FH39_TCSR_CREDIT (FH39_SRVC_CHNL), 0x0); handled |= CSR_INT_BIT_FH_TX; @@ -1543,9 +1543,9 @@ static void il3945_irq_tasklet(struct il_priv *il) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG if (il_get_debug_level(il) & (IL_DL_ISR)) { - inta = il_read32(il, CSR_INT); - inta_mask = il_read32(il, CSR_INT_MASK); - inta_fh = il_read32(il, CSR_FH_INT_STATUS); + inta = _il_rd(il, CSR_INT); + inta_mask = _il_rd(il, CSR_INT_MASK); + inta_fh = _il_rd(il, CSR_FH_INT_STATUS); D_ISR("End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); } @@ -1817,7 +1817,7 @@ static int il3945_verify_ucode(struct il_priv *il) static void il3945_nic_start(struct il_priv *il) { /* Remove all resets to allow NIC to operate */ - il_write32(il, CSR_RESET, 0); + _il_wr(il, CSR_RESET, 0); } #define IWL3945_UCODE_GET(item) \ @@ -2304,7 +2304,7 @@ static void __il3945_down(struct il_priv *il) clear_bit(STATUS_EXIT_PENDING, &il->status); /* stop and reset the on-board processor */ - il_write32(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); /* tell the device to stop sending interrupts */ spin_lock_irqsave(&il->lock, flags); @@ -2412,7 +2412,7 @@ static int __il3945_up(struct il_priv *il) } /* If platform's RF_KILL switch is NOT set to KILL */ - if (il_read32(il, CSR_GP_CNTRL) & + if (_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) clear_bit(STATUS_RF_KILL_HW, &il->status); else { @@ -2421,7 +2421,7 @@ static int __il3945_up(struct il_priv *il) return -ENODEV; } - il_write32(il, CSR_INT, 0xFFFFFFFF); + _il_wr(il, CSR_INT, 0xFFFFFFFF); rc = il3945_hw_nic_init(il); if (rc) { @@ -2430,17 +2430,17 @@ static int __il3945_up(struct il_priv *il) } /* make sure rfkill handshake bits are cleared */ - il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - il_write32(il, CSR_UCODE_DRV_GP1_CLR, + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); /* clear (again), then enable host interrupts */ - il_write32(il, CSR_INT, 0xFFFFFFFF); + _il_wr(il, CSR_INT, 0xFFFFFFFF); il_enable_interrupts(il); /* really make sure rfkill handshake bits are cleared */ - il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); /* Copy original ucode data image from disk into backup cache. * This will be used to initialize the on-board processor's @@ -2529,7 +2529,7 @@ static void il3945_rfkill_poll(struct work_struct *data) struct il_priv *il = container_of(data, struct il_priv, _3945.rfkill_poll.work); bool old_rfkill = test_bit(STATUS_RF_KILL_HW, &il->status); - bool new_rfkill = !(il_read32(il, CSR_GP_CNTRL) + bool new_rfkill = !(_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW); if (new_rfkill != old_rfkill) { @@ -3748,7 +3748,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en * strange state ... like being left stranded by a primary kernel * and this is now the kdump kernel trying to start up */ - il_write32(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); /*********************** * 4. Read EEPROM diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index df7e0a484dfe..a7743732a6b6 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -517,9 +517,9 @@ static void il4965_perform_ct_kill_task(struct il_priv *il) if (il->mac80211_registered) ieee80211_stop_queues(il->hw); - il_write32(il, CSR_UCODE_DRV_GP1_SET, + _il_wr(il, CSR_UCODE_DRV_GP1_SET, CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); - il_read32(il, CSR_UCODE_DRV_GP1); + _il_rd(il, CSR_UCODE_DRV_GP1); spin_lock_irqsave(&il->reg_lock, flags); if (!il_grab_nic_access(il)) @@ -545,14 +545,14 @@ static void il4965_rx_card_state_notif(struct il_priv *il, if (flags & (SW_CARD_DISABLED | HW_CARD_DISABLED | CT_CARD_DISABLED)) { - il_write32(il, CSR_UCODE_DRV_GP1_SET, + _il_wr(il, CSR_UCODE_DRV_GP1_SET, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); il_write_direct32(il, HBUS_TARG_MBX_C, HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); if (!(flags & RXON_CARD_DISABLED)) { - il_write32(il, CSR_UCODE_DRV_GP1_CLR, + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); il_write_direct32(il, HBUS_TARG_MBX_C, HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); @@ -787,19 +787,19 @@ static void il4965_irq_tasklet(struct il_priv *il) /* Ack/clear/reset pending uCode interrupts. * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS, * and will clear only when CSR_FH_INT_STATUS gets cleared. */ - inta = il_read32(il, CSR_INT); - il_write32(il, CSR_INT, inta); + inta = _il_rd(il, CSR_INT); + _il_wr(il, CSR_INT, inta); /* Ack/clear/reset pending flow-handler (DMA) interrupts. * Any new interrupts that happen after this, either while we're * in this tasklet, or later, will show up in next ISR/tasklet. */ - inta_fh = il_read32(il, CSR_FH_INT_STATUS); - il_write32(il, CSR_FH_INT_STATUS, inta_fh); + inta_fh = _il_rd(il, CSR_FH_INT_STATUS); + _il_wr(il, CSR_FH_INT_STATUS, inta_fh); #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG if (il_get_debug_level(il) & IL_DL_ISR) { /* just for debug */ - inta_mask = il_read32(il, CSR_INT_MASK); + inta_mask = _il_rd(il, CSR_INT_MASK); D_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, inta_mask, inta_fh); } @@ -853,7 +853,7 @@ static void il4965_irq_tasklet(struct il_priv *il) /* HW RF KILL switch toggled */ if (inta & CSR_INT_BIT_RF_KILL) { int hw_rf_kill = 0; - if (!(il_read32(il, CSR_GP_CNTRL) & + if (!(_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) hw_rf_kill = 1; @@ -948,9 +948,9 @@ static void il4965_irq_tasklet(struct il_priv *il) #ifdef CONFIG_IWLWIFI_LEGACY_DEBUG if (il_get_debug_level(il) & (IL_DL_ISR)) { - inta = il_read32(il, CSR_INT); - inta_mask = il_read32(il, CSR_INT_MASK); - inta_fh = il_read32(il, CSR_FH_INT_STATUS); + inta = _il_rd(il, CSR_INT); + inta_mask = _il_rd(il, CSR_INT_MASK); + inta_fh = _il_rd(il, CSR_FH_INT_STATUS); D_ISR( "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); @@ -1092,7 +1092,7 @@ static void il4965_dealloc_ucode_pci(struct il_priv *il) static void il4965_nic_start(struct il_priv *il) { /* Remove all resets to allow NIC to operate */ - il_write32(il, CSR_RESET, 0); + _il_wr(il, CSR_RESET, 0); } static void il4965_ucode_callback(const struct firmware *ucode_raw, @@ -1584,7 +1584,7 @@ static void il4965_rf_kill_ct_config(struct il_priv *il) int ret = 0; spin_lock_irqsave(&il->lock, flags); - il_write32(il, CSR_UCODE_DRV_GP1_CLR, + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); spin_unlock_irqrestore(&il->lock, flags); @@ -1830,7 +1830,7 @@ static void __il4965_down(struct il_priv *il) clear_bit(STATUS_EXIT_PENDING, &il->status); /* stop and reset the on-board processor */ - il_write32(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); /* tell the device to stop sending interrupts */ spin_lock_irqsave(&il->lock, flags); @@ -1980,7 +1980,7 @@ static int __il4965_up(struct il_priv *il) } /* If platform's RF_KILL switch is NOT set to KILL */ - if (il_read32(il, + if (_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) clear_bit(STATUS_RF_KILL_HW, &il->status); else @@ -1994,7 +1994,7 @@ static int __il4965_up(struct il_priv *il) return 0; } - il_write32(il, CSR_INT, 0xFFFFFFFF); + _il_wr(il, CSR_INT, 0xFFFFFFFF); /* must be initialised before il_hw_nic_init */ il->cmd_queue = IL_DEFAULT_CMD_QUEUE_NUM; @@ -2006,17 +2006,17 @@ static int __il4965_up(struct il_priv *il) } /* make sure rfkill handshake bits are cleared */ - il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - il_write32(il, CSR_UCODE_DRV_GP1_CLR, + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); /* clear (again), then enable host interrupts */ - il_write32(il, CSR_INT, 0xFFFFFFFF); + _il_wr(il, CSR_INT, 0xFFFFFFFF); il_enable_interrupts(il); /* really make sure rfkill handshake bits are cleared */ - il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - il_write32(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); /* Copy original ucode data image from disk into backup cache. * This will be used to initialize the on-board processor's @@ -2296,7 +2296,7 @@ void il4965_mac_stop(struct ieee80211_hw *hw) /* User space software may expect getting rfkill changes * even if interface is down */ - il_write32(il, CSR_INT, 0xFFFFFFFF); + _il_wr(il, CSR_INT, 0xFFFFFFFF); il_enable_rfkill_int(il); D_MAC80211("leave\n"); @@ -2821,8 +2821,8 @@ static void il4965_uninit_drv(struct il_priv *il) static void il4965_hw_detect(struct il_priv *il) { - il->hw_rev = _il_read32(il, CSR_HW_REV); - il->hw_wa_rev = _il_read32(il, CSR_HW_REV_WA_REG); + il->hw_rev = _il_rd(il, CSR_HW_REV); + il->hw_wa_rev = _il_rd(il, CSR_HW_REV_WA_REG); il->rev_id = il->pci_dev->revision; D_INFO("HW Revision ID = 0x%X\n", il->rev_id); } @@ -2978,7 +2978,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) * strange state ... like being left stranded by a primary kernel * and this is now the kdump kernel trying to start up */ - il_write32(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); il4965_hw_detect(il); IL_INFO("Detected %s, REV=0x%X\n", @@ -3066,7 +3066,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) il_enable_rfkill_int(il); /* If platform's RF_KILL switch is NOT set to KILL */ - if (il_read32(il, CSR_GP_CNTRL) & + if (_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) clear_bit(STATUS_RF_KILL_HW, &il->status); else -- cgit v1.2.3 From 142b343f6eb4898289c402afb6237def8e252a3e Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 24 Aug 2011 15:22:57 +0200 Subject: iwlegacy: mark poll bit as unlocked function We do not take reg_lock during poll bit, so mark it such using underscore. Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-3945.c | 4 ++-- drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c | 2 +- drivers/net/wireless/iwlegacy/iwl-core.c | 4 ++-- drivers/net/wireless/iwlegacy/iwl-eeprom.c | 2 +- drivers/net/wireless/iwlegacy/iwl-io.h | 1 - drivers/net/wireless/iwlegacy/iwl4965-base.c | 4 ++-- 6 files changed, 8 insertions(+), 9 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index 6e2e71acbef6..8c3ae39b0738 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -757,7 +757,7 @@ static void il3945_set_pwr_vmain(struct il_priv *il) APMG_PS_CTRL_VAL_PWR_SRC_VAUX, ~APMG_PS_CTRL_MSK_PWR_SRC); - il_poll_bit(il, CSR_GPIO_IN, + _il_poll_bit(il, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VAUX_PWR_SRC, CSR_GPIO_IN_BIT_AUX_POWER, 5000); } @@ -767,7 +767,7 @@ static void il3945_set_pwr_vmain(struct il_priv *il) APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, ~APMG_PS_CTRL_MSK_PWR_SRC); - il_poll_bit(il, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC, + _il_poll_bit(il, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC, CSR_GPIO_IN_BIT_AUX_POWER, 5000); /* uS */ } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c index 016472dadf3a..a5192570d093 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c @@ -98,7 +98,7 @@ int il4965_eeprom_acquire_semaphore(struct il_priv *il) CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); /* See if we got it */ - ret = il_poll_bit(il, CSR_HW_IF_CONFIG_REG, + ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, EEPROM_SEM_TIMEOUT); diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index c5ffd91af5d0..d2534fb01448 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -960,7 +960,7 @@ static int il_apm_stop_master(struct il_priv *il) /* stop device's busmaster DMA activity */ il_set_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); - ret = il_poll_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, + ret = _il_poll_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); if (ret) IL_WARN("Master Disable Timed Out, 100 usec\n"); @@ -1072,7 +1072,7 @@ int il_apm_init(struct il_priv *il) * device-internal resources is supported, e.g. il_write_prph() * and accesses to uCode SRAM. */ - ret = il_poll_bit(il, CSR_GP_CNTRL, + ret = _il_poll_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); if (ret < 0) { diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-eeprom.c index 26cf50699efc..ba2be7b9e379 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.c @@ -226,7 +226,7 @@ int il_eeprom_init(struct il_priv *il) _il_wr(il, CSR_EEPROM_REG, CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); - ret = il_poll_bit(il, CSR_EEPROM_REG, + ret = _il_poll_bit(il, CSR_EEPROM_REG, CSR_EEPROM_REG_READ_VALID_MSK, CSR_EEPROM_REG_READ_VALID_MSK, IL_EEPROM_ACCESS_TIMEOUT); diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h index cdbcfde20123..7ad262e9add5 100644 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ b/drivers/net/wireless/iwlegacy/iwl-io.h @@ -66,7 +66,6 @@ _il_poll_bit(struct il_priv *il, u32 addr, return -ETIMEDOUT; } -#define il_poll_bit(p, a, b, m, t) _il_poll_bit(p, a, b, m, t) static inline void _il_set_bit(struct il_priv *il, u32 reg, u32 mask) { diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index a7743732a6b6..f3ec8bba7ff8 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -1907,7 +1907,7 @@ static int il4965_set_hw_ready(struct il_priv *il) CSR_HW_IF_CONFIG_REG_BIT_NIC_READY); /* See if we got it */ - ret = il_poll_bit(il, CSR_HW_IF_CONFIG_REG, + ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, HW_READY_TIMEOUT); @@ -1935,7 +1935,7 @@ static int il4965_prepare_card_hw(struct il_priv *il) il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_PREPARE); - ret = il_poll_bit(il, CSR_HW_IF_CONFIG_REG, + ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, ~CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, 150000); -- cgit v1.2.3 From 138822698fc16bd4c5b509da28a9b08faac4367b Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 24 Aug 2011 15:39:23 +0200 Subject: iwlegacy: mark il_{grab,release}_nic_access as unlocked Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-io.h | 42 +++++++++++++--------------- drivers/net/wireless/iwlegacy/iwl4965-base.c | 4 +-- 2 files changed, 22 insertions(+), 24 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h index 7ad262e9add5..c2e32ed27349 100644 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ b/drivers/net/wireless/iwlegacy/iwl-io.h @@ -137,14 +137,12 @@ static inline int _il_grab_nic_access(struct il_priv *il) return 0; } -#define il_grab_nic_access(il) _il_grab_nic_access(il) static inline void _il_release_nic_access(struct il_priv *il) { _il_clear_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); } -#define il_release_nic_access(il) _il_release_nic_access(il) static inline u32 _il_read_direct32(struct il_priv *il, u32 reg) { @@ -157,9 +155,9 @@ static inline u32 il_read_direct32(struct il_priv *il, u32 reg) unsigned long reg_flags; spin_lock_irqsave(&il->reg_lock, reg_flags); - il_grab_nic_access(il); + _il_grab_nic_access(il); value = _il_read_direct32(il, reg); - il_release_nic_access(il); + _il_release_nic_access(il); spin_unlock_irqrestore(&il->reg_lock, reg_flags); return value; @@ -176,9 +174,9 @@ il_write_direct32(struct il_priv *il, u32 reg, u32 value) unsigned long reg_flags; spin_lock_irqsave(&il->reg_lock, reg_flags); - if (!il_grab_nic_access(il)) { + if (!_il_grab_nic_access(il)) { _il_write_direct32(il, reg, value); - il_release_nic_access(il); + _il_release_nic_access(il); } spin_unlock_irqrestore(&il->reg_lock, reg_flags); } @@ -222,9 +220,9 @@ static inline u32 il_read_prph(struct il_priv *il, u32 reg) u32 val; spin_lock_irqsave(&il->reg_lock, reg_flags); - il_grab_nic_access(il); + _il_grab_nic_access(il); val = _il_read_prph(il, reg); - il_release_nic_access(il); + _il_release_nic_access(il); spin_unlock_irqrestore(&il->reg_lock, reg_flags); return val; } @@ -244,9 +242,9 @@ il_write_prph(struct il_priv *il, u32 addr, u32 val) unsigned long reg_flags; spin_lock_irqsave(&il->reg_lock, reg_flags); - if (!il_grab_nic_access(il)) { + if (!_il_grab_nic_access(il)) { _il_write_prph(il, addr, val); - il_release_nic_access(il); + _il_release_nic_access(il); } spin_unlock_irqrestore(&il->reg_lock, reg_flags); } @@ -260,9 +258,9 @@ il_set_bits_prph(struct il_priv *il, u32 reg, u32 mask) unsigned long reg_flags; spin_lock_irqsave(&il->reg_lock, reg_flags); - il_grab_nic_access(il); + _il_grab_nic_access(il); _il_set_bits_prph(il, reg, mask); - il_release_nic_access(il); + _il_release_nic_access(il); spin_unlock_irqrestore(&il->reg_lock, reg_flags); } @@ -276,9 +274,9 @@ static inline void il_set_bits_mask_prph(struct il_priv *il, u32 reg, unsigned long reg_flags; spin_lock_irqsave(&il->reg_lock, reg_flags); - il_grab_nic_access(il); + _il_grab_nic_access(il); _il_set_bits_mask_prph(il, reg, bits, mask); - il_release_nic_access(il); + _il_release_nic_access(il); spin_unlock_irqrestore(&il->reg_lock, reg_flags); } @@ -289,10 +287,10 @@ static inline void il_clear_bits_prph(struct il_priv u32 val; spin_lock_irqsave(&il->reg_lock, reg_flags); - il_grab_nic_access(il); + _il_grab_nic_access(il); val = _il_read_prph(il, reg); _il_write_prph(il, reg, (val & ~mask)); - il_release_nic_access(il); + _il_release_nic_access(il); spin_unlock_irqrestore(&il->reg_lock, reg_flags); } @@ -302,13 +300,13 @@ static inline u32 il_read_targ_mem(struct il_priv *il, u32 addr) u32 value; spin_lock_irqsave(&il->reg_lock, reg_flags); - il_grab_nic_access(il); + _il_grab_nic_access(il); _il_write_direct32(il, HBUS_TARG_MEM_RADDR, addr); rmb(); value = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); - il_release_nic_access(il); + _il_release_nic_access(il); spin_unlock_irqrestore(&il->reg_lock, reg_flags); return value; } @@ -319,11 +317,11 @@ il_write_targ_mem(struct il_priv *il, u32 addr, u32 val) unsigned long reg_flags; spin_lock_irqsave(&il->reg_lock, reg_flags); - if (!il_grab_nic_access(il)) { + if (!_il_grab_nic_access(il)) { _il_write_direct32(il, HBUS_TARG_MEM_WADDR, addr); wmb(); _il_write_direct32(il, HBUS_TARG_MEM_WDAT, val); - il_release_nic_access(il); + _il_release_nic_access(il); } spin_unlock_irqrestore(&il->reg_lock, reg_flags); } @@ -335,14 +333,14 @@ il_write_targ_mem_buf(struct il_priv *il, u32 addr, unsigned long reg_flags; spin_lock_irqsave(&il->reg_lock, reg_flags); - if (!il_grab_nic_access(il)) { + if (!_il_grab_nic_access(il)) { _il_write_direct32(il, HBUS_TARG_MEM_WADDR, addr); wmb(); for (; 0 < len; len -= sizeof(u32), values++) _il_write_direct32(il, HBUS_TARG_MEM_WDAT, *values); - il_release_nic_access(il); + _il_release_nic_access(il); } spin_unlock_irqrestore(&il->reg_lock, reg_flags); } diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index f3ec8bba7ff8..f4eb037f563b 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -522,8 +522,8 @@ static void il4965_perform_ct_kill_task(struct il_priv *il) _il_rd(il, CSR_UCODE_DRV_GP1); spin_lock_irqsave(&il->reg_lock, flags); - if (!il_grab_nic_access(il)) - il_release_nic_access(il); + if (!_il_grab_nic_access(il)) + _il_release_nic_access(il); spin_unlock_irqrestore(&il->reg_lock, flags); } -- cgit v1.2.3 From 1c8cae575b14ffad6af9c80927a08aa783f0ed78 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 24 Aug 2011 15:46:03 +0200 Subject: iwlegacy: remove _il_{read,write}_direct32 Use _il_{rd,wr} instead of another name of these operations. Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-4965-ucode.c | 4 +-- drivers/net/wireless/iwlegacy/iwl-eeprom.c | 2 +- drivers/net/wireless/iwlegacy/iwl-io.h | 34 +++++++++----------------- drivers/net/wireless/iwlegacy/iwl3945-base.c | 4 +-- 4 files changed, 17 insertions(+), 27 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c index 3fa939e490cf..4f0e6fe5be50 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c @@ -63,7 +63,7 @@ il4965_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) * if IL_DL_IO is set */ il_write_direct32(il, HBUS_TARG_MEM_RADDR, i + IWL4965_RTC_INST_LOWER_BOUND); - val = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); + val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { ret = -EIO; errcnt++; @@ -97,7 +97,7 @@ static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log * if IL_DL_IO is set */ - val = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); + val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { IL_ERR("uCode INST section is invalid at " "offset 0x%x, is 0x%x, s/b 0x%x\n", diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-eeprom.c index ba2be7b9e379..5786abd7c0bb 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.c @@ -235,7 +235,7 @@ int il_eeprom_init(struct il_priv *il) addr); goto done; } - r = _il_read_direct32(il, CSR_EEPROM_REG); + r = _il_rd(il, CSR_EEPROM_REG); e[addr / 2] = cpu_to_le16(r >> 16); } diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h index c2e32ed27349..ecf799d9d22b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ b/drivers/net/wireless/iwlegacy/iwl-io.h @@ -144,11 +144,6 @@ static inline void _il_release_nic_access(struct il_priv *il) CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); } -static inline u32 _il_read_direct32(struct il_priv *il, u32 reg) -{ - return _il_rd(il, reg); -} - static inline u32 il_read_direct32(struct il_priv *il, u32 reg) { u32 value; @@ -156,18 +151,13 @@ static inline u32 il_read_direct32(struct il_priv *il, u32 reg) spin_lock_irqsave(&il->reg_lock, reg_flags); _il_grab_nic_access(il); - value = _il_read_direct32(il, reg); + value = _il_rd(il, reg); _il_release_nic_access(il); spin_unlock_irqrestore(&il->reg_lock, reg_flags); return value; } -static inline void _il_write_direct32(struct il_priv *il, - u32 reg, u32 value) -{ - _il_wr(il, reg, value); -} static inline void il_write_direct32(struct il_priv *il, u32 reg, u32 value) { @@ -175,7 +165,7 @@ il_write_direct32(struct il_priv *il, u32 reg, u32 value) spin_lock_irqsave(&il->reg_lock, reg_flags); if (!_il_grab_nic_access(il)) { - _il_write_direct32(il, reg, value); + _il_wr(il, reg, value); _il_release_nic_access(il); } spin_unlock_irqrestore(&il->reg_lock, reg_flags); @@ -210,9 +200,9 @@ static inline int _il_poll_direct_bit(struct il_priv *il, u32 addr, static inline u32 _il_read_prph(struct il_priv *il, u32 reg) { - _il_write_direct32(il, HBUS_TARG_PRPH_RADDR, reg | (3 << 24)); + _il_wr(il, HBUS_TARG_PRPH_RADDR, reg | (3 << 24)); rmb(); - return _il_read_direct32(il, HBUS_TARG_PRPH_RDAT); + return _il_rd(il, HBUS_TARG_PRPH_RDAT); } static inline u32 il_read_prph(struct il_priv *il, u32 reg) { @@ -230,10 +220,10 @@ static inline u32 il_read_prph(struct il_priv *il, u32 reg) static inline void _il_write_prph(struct il_priv *il, u32 addr, u32 val) { - _il_write_direct32(il, HBUS_TARG_PRPH_WADDR, + _il_wr(il, HBUS_TARG_PRPH_WADDR, ((addr & 0x0000FFFF) | (3 << 24))); wmb(); - _il_write_direct32(il, HBUS_TARG_PRPH_WDAT, val); + _il_wr(il, HBUS_TARG_PRPH_WDAT, val); } static inline void @@ -302,9 +292,9 @@ static inline u32 il_read_targ_mem(struct il_priv *il, u32 addr) spin_lock_irqsave(&il->reg_lock, reg_flags); _il_grab_nic_access(il); - _il_write_direct32(il, HBUS_TARG_MEM_RADDR, addr); + _il_wr(il, HBUS_TARG_MEM_RADDR, addr); rmb(); - value = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); + value = _il_rd(il, HBUS_TARG_MEM_RDAT); _il_release_nic_access(il); spin_unlock_irqrestore(&il->reg_lock, reg_flags); @@ -318,9 +308,9 @@ il_write_targ_mem(struct il_priv *il, u32 addr, u32 val) spin_lock_irqsave(&il->reg_lock, reg_flags); if (!_il_grab_nic_access(il)) { - _il_write_direct32(il, HBUS_TARG_MEM_WADDR, addr); + _il_wr(il, HBUS_TARG_MEM_WADDR, addr); wmb(); - _il_write_direct32(il, HBUS_TARG_MEM_WDAT, val); + _il_wr(il, HBUS_TARG_MEM_WDAT, val); _il_release_nic_access(il); } spin_unlock_irqrestore(&il->reg_lock, reg_flags); @@ -334,10 +324,10 @@ il_write_targ_mem_buf(struct il_priv *il, u32 addr, spin_lock_irqsave(&il->reg_lock, reg_flags); if (!_il_grab_nic_access(il)) { - _il_write_direct32(il, HBUS_TARG_MEM_WADDR, addr); + _il_wr(il, HBUS_TARG_MEM_WADDR, addr); wmb(); for (; 0 < len; len -= sizeof(u32), values++) - _il_write_direct32(il, + _il_wr(il, HBUS_TARG_MEM_WDAT, *values); _il_release_nic_access(il); diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index def314073ce8..d45e9f532dcc 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -1706,7 +1706,7 @@ static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log * if IL_DL_IO is set */ - val = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); + val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { IL_ERR("uCode INST section is invalid at " "offset 0x%x, is 0x%x, s/b 0x%x\n", @@ -1747,7 +1747,7 @@ static int il3945_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) * if IL_DL_IO is set */ il_write_direct32(il, HBUS_TARG_MEM_RADDR, i + IWL39_RTC_INST_LOWER_BOUND); - val = _il_read_direct32(il, HBUS_TARG_MEM_RDAT); + val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { #if 0 /* Enable this if you want to see details */ IL_ERR("uCode INST section is invalid at " -- cgit v1.2.3 From 0c1a94e299eed7ea11ebc407d1e08a26c594abe5 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 24 Aug 2011 17:37:16 +0200 Subject: iwlegacy: rename i/o direct methods Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-3945.c | 30 +++++++++++++------------- drivers/net/wireless/iwlegacy/iwl-4965-lib.c | 18 ++++++++-------- drivers/net/wireless/iwlegacy/iwl-4965-tx.c | 10 ++++----- drivers/net/wireless/iwlegacy/iwl-4965-ucode.c | 4 ++-- drivers/net/wireless/iwlegacy/iwl-csr.h | 4 ++-- drivers/net/wireless/iwlegacy/iwl-io.h | 11 +++++----- drivers/net/wireless/iwlegacy/iwl-rx.c | 4 ++-- drivers/net/wireless/iwlegacy/iwl-tx.c | 2 +- drivers/net/wireless/iwlegacy/iwl3945-base.c | 6 +++--- drivers/net/wireless/iwlegacy/iwl4965-base.c | 16 +++++++------- 10 files changed, 52 insertions(+), 53 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index 8c3ae39b0738..fc8ddb68c7c4 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -773,11 +773,11 @@ static void il3945_set_pwr_vmain(struct il_priv *il) static int il3945_rx_init(struct il_priv *il, struct il_rx_queue *rxq) { - il_write_direct32(il, FH39_RCSR_RBD_BASE(0), rxq->bd_dma); - il_write_direct32(il, FH39_RCSR_RPTR_ADDR(0), + il_wr(il, FH39_RCSR_RBD_BASE(0), rxq->bd_dma); + il_wr(il, FH39_RCSR_RPTR_ADDR(0), rxq->rb_stts_dma); - il_write_direct32(il, FH39_RCSR_WPTR(0), 0); - il_write_direct32(il, FH39_RCSR_CONFIG(0), + il_wr(il, FH39_RCSR_WPTR(0), 0); + il_wr(il, FH39_RCSR_CONFIG(0), FH39_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE | FH39_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE | FH39_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN | @@ -788,7 +788,7 @@ static int il3945_rx_init(struct il_priv *il, struct il_rx_queue *rxq) FH39_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH); /* fake read to flush all prev I/O */ - il_read_direct32(il, FH39_RSSR_CTRL); + il_rd(il, FH39_RSSR_CTRL); return 0; } @@ -810,10 +810,10 @@ static int il3945_tx_reset(struct il_priv *il) il_write_prph(il, ALM_SCD_TXF4MF_REG, 0x000004); il_write_prph(il, ALM_SCD_TXF5MF_REG, 0x000005); - il_write_direct32(il, FH39_TSSR_CBB_BASE, + il_wr(il, FH39_TSSR_CBB_BASE, il->_3945.shared_phys); - il_write_direct32(il, FH39_TSSR_MSG_CONFIG, + il_wr(il, FH39_TSSR_MSG_CONFIG, FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON | FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON | FH39_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B | @@ -987,7 +987,7 @@ int il3945_hw_nic_init(struct il_priv *il) il_rx_queue_update_write_ptr(il, rxq); */ - il_write_direct32(il, FH39_RCSR_WPTR(0), rxq->write & ~7); + il_wr(il, FH39_RCSR_WPTR(0), rxq->write & ~7); rc = il3945_txq_ctx_reset(il); if (rc) @@ -1030,8 +1030,8 @@ void il3945_hw_txq_ctx_stop(struct il_priv *il) /* reset TFD queues */ for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { - il_write_direct32(il, FH39_TCSR_CONFIG(txq_id), 0x0); - il_poll_direct_bit(il, FH39_TSSR_TX_STATUS, + il_wr(il, FH39_TCSR_CONFIG(txq_id), 0x0); + il_poll_bit(il, FH39_TSSR_TX_STATUS, FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(txq_id), 1000); } @@ -2183,8 +2183,8 @@ int il3945_hw_rxq_stop(struct il_priv *il) { int rc; - il_write_direct32(il, FH39_RCSR_CONFIG(0), 0); - rc = il_poll_direct_bit(il, FH39_RSSR_STATUS, + il_wr(il, FH39_RCSR_CONFIG(0), 0); + rc = il_poll_bit(il, FH39_RSSR_STATUS, FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); if (rc < 0) IL_ERR("Can't stop Rx DMA.\n"); @@ -2200,10 +2200,10 @@ int il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq) shared_data->tx_base_ptr[txq_id] = cpu_to_le32((u32)txq->q.dma_addr); - il_write_direct32(il, FH39_CBCC_CTRL(txq_id), 0); - il_write_direct32(il, FH39_CBCC_BASE(txq_id), 0); + il_wr(il, FH39_CBCC_CTRL(txq_id), 0); + il_wr(il, FH39_CBCC_BASE(txq_id), 0); - il_write_direct32(il, FH39_TCSR_CONFIG(txq_id), + il_wr(il, FH39_TCSR_CONFIG(txq_id), FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT | FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF | FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD | diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index 6503b8faf08b..8fafd201717c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -103,17 +103,17 @@ int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K; /* Stop Rx DMA */ - il_write_direct32(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); + il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); /* Reset driver's Rx queue write index */ - il_write_direct32(il, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); + il_wr(il, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); /* Tell device where to find RBD circular buffer in DRAM */ - il_write_direct32(il, FH_RSCSR_CHNL0_RBDCB_BASE_REG, + il_wr(il, FH_RSCSR_CHNL0_RBDCB_BASE_REG, (u32)(rxq->bd_dma >> 8)); /* Tell device where in DRAM to update its Rx status */ - il_write_direct32(il, FH_RSCSR_CHNL0_STTS_WPTR_REG, + il_wr(il, FH_RSCSR_CHNL0_STTS_WPTR_REG, rxq->rb_stts_dma >> 4); /* Enable Rx DMA @@ -122,7 +122,7 @@ int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) * RB timeout 0x10 * 256 RBDs */ - il_write_direct32(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, + il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL | FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL | FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK | @@ -403,8 +403,8 @@ int il4965_rxq_stop(struct il_priv *il) { /* stop Rx DMA */ - il_write_direct32(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); - il_poll_direct_bit(il, FH_MEM_RSSR_RX_STATUS_REG, + il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); + il_poll_bit(il, FH_MEM_RSSR_RX_STATUS_REG, FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); return 0; @@ -1179,7 +1179,7 @@ int il4965_dump_fh(struct il_priv *il, char **buf, bool display) pos += scnprintf(*buf + pos, bufsz - pos, " %34s: 0X%08x\n", il4965_get_fh_string(fh_tbl[i]), - il_read_direct32(il, fh_tbl[i])); + il_rd(il, fh_tbl[i])); } return pos; } @@ -1188,7 +1188,7 @@ int il4965_dump_fh(struct il_priv *il, char **buf, bool display) for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { IL_ERR(" %34s: 0X%08x\n", il4965_get_fh_string(fh_tbl[i]), - il_read_direct32(il, fh_tbl[i])); + il_rd(il, fh_tbl[i])); } return 0; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index 66dd172fed60..25c9b7192d9a 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -640,7 +640,7 @@ int il4965_txq_ctx_alloc(struct il_priv *il) il4965_txq_set_sched(il, 0); /* Tell NIC where to find the "keep warm" buffer */ - il_write_direct32(il, FH_KW_MEM_ADDR_REG, il->kw.dma >> 4); + il_wr(il, FH_KW_MEM_ADDR_REG, il->kw.dma >> 4); spin_unlock_irqrestore(&il->lock, flags); @@ -679,7 +679,7 @@ void il4965_txq_ctx_reset(struct il_priv *il) il4965_txq_set_sched(il, 0); /* Tell NIC where to find the "keep warm" buffer */ - il_write_direct32(il, FH_KW_MEM_ADDR_REG, il->kw.dma >> 4); + il_wr(il, FH_KW_MEM_ADDR_REG, il->kw.dma >> 4); spin_unlock_irqrestore(&il->lock, flags); @@ -707,14 +707,14 @@ void il4965_txq_ctx_stop(struct il_priv *il) /* Stop each Tx DMA channel, and wait for it to be idle */ for (ch = 0; ch < il->hw_params.dma_chnl_num; ch++) { - il_write_direct32(il, + il_wr(il, FH_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0); - if (il_poll_direct_bit(il, FH_TSSR_TX_STATUS_REG, + if (il_poll_bit(il, FH_TSSR_TX_STATUS_REG, FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), 1000)) IL_ERR("Failing on timeout while stopping" " DMA channel %d [0x%08x]", ch, - il_read_direct32(il, + il_rd(il, FH_TSSR_TX_STATUS_REG)); } spin_unlock_irqrestore(&il->lock, flags); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c index 4f0e6fe5be50..bb0b7f5cb5ee 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c @@ -61,7 +61,7 @@ il4965_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log * if IL_DL_IO is set */ - il_write_direct32(il, HBUS_TARG_MEM_RADDR, + il_wr(il, HBUS_TARG_MEM_RADDR, i + IWL4965_RTC_INST_LOWER_BOUND); val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { @@ -89,7 +89,7 @@ static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, D_INFO("ucode inst image size is %u\n", len); - il_write_direct32(il, HBUS_TARG_MEM_RADDR, + il_wr(il, HBUS_TARG_MEM_RADDR, IWL4965_RTC_INST_LOWER_BOUND); errcnt = 0; diff --git a/drivers/net/wireless/iwlegacy/iwl-csr.h b/drivers/net/wireless/iwlegacy/iwl-csr.h index faffb8e180b4..c00ec353f556 100644 --- a/drivers/net/wireless/iwlegacy/iwl-csr.h +++ b/drivers/net/wireless/iwlegacy/iwl-csr.h @@ -72,7 +72,7 @@ * * Use _il_wr() and _il_rd() family to access these registers; * these provide simple PCI bus access, without waking up the MAC. - * Do not use il_write_direct32() family for these registers; + * Do not use il_wr() family for these registers; * no need to "grab nic access" via CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ. * The MAC (uCode processor, etc.) does not need to be powered up for accessing * the CSR registers. @@ -368,7 +368,7 @@ * to indirectly access device's internal memory or registers that * may be powered-down. * - * Use il_write_direct32()/il_read_direct32() family + * Use il_wr()/il_rd() family * for these registers; * host must "grab nic access" via CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ * to make sure the MAC (uCode processor, etc.) is powered up for accessing diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h index ecf799d9d22b..f435942ab458 100644 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ b/drivers/net/wireless/iwlegacy/iwl-io.h @@ -144,7 +144,7 @@ static inline void _il_release_nic_access(struct il_priv *il) CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); } -static inline u32 il_read_direct32(struct il_priv *il, u32 reg) +static inline u32 il_rd(struct il_priv *il, u32 reg) { u32 value; unsigned long reg_flags; @@ -159,7 +159,7 @@ static inline u32 il_read_direct32(struct il_priv *il, u32 reg) } static inline void -il_write_direct32(struct il_priv *il, u32 reg, u32 value) +il_wr(struct il_priv *il, u32 reg, u32 value) { unsigned long reg_flags; @@ -178,17 +178,17 @@ static inline void il_write_reg_buf(struct il_priv *il, if ((il != NULL) && (values != NULL)) { for (; 0 < len; len -= count, reg += count, values++) - il_write_direct32(il, reg, *values); + il_wr(il, reg, *values); } } -static inline int _il_poll_direct_bit(struct il_priv *il, u32 addr, +static inline int il_poll_bit(struct il_priv *il, u32 addr, u32 mask, int timeout) { int t = 0; do { - if ((il_read_direct32(il, addr) & mask) == mask) + if ((il_rd(il, addr) & mask) == mask) return t; udelay(IL_POLL_INTERVAL); t += IL_POLL_INTERVAL; @@ -196,7 +196,6 @@ static inline int _il_poll_direct_bit(struct il_priv *il, u32 addr, return -ETIMEDOUT; } -#define il_poll_direct_bit _il_poll_direct_bit static inline u32 _il_read_prph(struct il_priv *il, u32 reg) { diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c index e481ca8c0cc9..b2ec2a214caa 100644 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -150,14 +150,14 @@ il_rx_queue_update_write_ptr(struct il_priv *il, } q->write_actual = (q->write & ~0x7); - il_write_direct32(il, rx_wrt_ptr_reg, + il_wr(il, rx_wrt_ptr_reg, q->write_actual); /* Else device is assumed to be awake */ } else { /* Device expects a multiple of 8 */ q->write_actual = (q->write & ~0x7); - il_write_direct32(il, rx_wrt_ptr_reg, + il_wr(il, rx_wrt_ptr_reg, q->write_actual); } diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index 6b5e652c4fc3..fa23c983ef91 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -66,7 +66,7 @@ il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq) return; } - il_write_direct32(il, HBUS_TARG_WRPTR, + il_wr(il, HBUS_TARG_WRPTR, txq->q.write_ptr | (txq_id << 8)); /* diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index d45e9f532dcc..a0b5a74972a9 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -1520,7 +1520,7 @@ static void il3945_irq_tasklet(struct il_priv *il) il->isr_stats.tx++; _il_wr(il, CSR_FH_INT_STATUS, (1 << 6)); - il_write_direct32(il, FH39_TCSR_CREDIT + il_wr(il, FH39_TCSR_CREDIT (FH39_SRVC_CHNL), 0x0); handled |= CSR_INT_BIT_FH_TX; } @@ -1698,7 +1698,7 @@ static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) D_INFO("ucode inst image size is %u\n", len); - il_write_direct32(il, HBUS_TARG_MEM_RADDR, + il_wr(il, HBUS_TARG_MEM_RADDR, IWL39_RTC_INST_LOWER_BOUND); errcnt = 0; @@ -1745,7 +1745,7 @@ static int il3945_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log * if IL_DL_IO is set */ - il_write_direct32(il, HBUS_TARG_MEM_RADDR, + il_wr(il, HBUS_TARG_MEM_RADDR, i + IWL39_RTC_INST_LOWER_BOUND); val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index f4eb037f563b..b0668ea9b104 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -416,7 +416,7 @@ int il4965_hw_tx_queue_init(struct il_priv *il, int txq_id = txq->q.id; /* Circular buffer (TFD queue in DRAM) physical base address */ - il_write_direct32(il, FH_MEM_CBBC_QUEUE(txq_id), + il_wr(il, FH_MEM_CBBC_QUEUE(txq_id), txq->q.dma_addr >> 8); return 0; @@ -548,13 +548,13 @@ static void il4965_rx_card_state_notif(struct il_priv *il, _il_wr(il, CSR_UCODE_DRV_GP1_SET, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - il_write_direct32(il, HBUS_TARG_MBX_C, + il_wr(il, HBUS_TARG_MBX_C, HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); if (!(flags & RXON_CARD_DISABLED)) { _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - il_write_direct32(il, HBUS_TARG_MBX_C, + il_wr(il, HBUS_TARG_MBX_C, HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); } } @@ -1639,14 +1639,14 @@ static int il4965_alive_notify(struct il_priv *il) /* Enable DMA channel */ for (chan = 0; chan < FH49_TCSR_CHNL_NUM ; chan++) - il_write_direct32(il, + il_wr(il, FH_TCSR_CHNL_TX_CONFIG_REG(chan), FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE); /* Update FH chicken bits */ - reg_val = il_read_direct32(il, FH_TX_CHICKEN_BITS_REG); - il_write_direct32(il, FH_TX_CHICKEN_BITS_REG, + reg_val = il_rd(il, FH_TX_CHICKEN_BITS_REG); + il_wr(il, FH_TX_CHICKEN_BITS_REG, reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); /* Disable chain mode for all queues */ @@ -1657,7 +1657,7 @@ static int il4965_alive_notify(struct il_priv *il) /* TFD circular buffer read/write indexes */ il_write_prph(il, IWL49_SCD_QUEUE_RDPTR(i), 0); - il_write_direct32(il, HBUS_TARG_WRPTR, 0 | (i << 8)); + il_wr(il, HBUS_TARG_WRPTR, 0 | (i << 8)); /* Max Tx Window size for Scheduler-ACK mode */ il_write_targ_mem(il, il->scd_base_addr + @@ -2731,7 +2731,7 @@ static void il4965_init_hw_rates(struct il_priv *il, */ void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 index) { - il_write_direct32(il, HBUS_TARG_WRPTR, + il_wr(il, HBUS_TARG_WRPTR, (index & 0xff) | (txq_id << 8)); il_write_prph(il, IWL49_SCD_QUEUE_RDPTR(txq_id), index); } -- cgit v1.2.3 From db54eb57ce5edeebd621b12e23f3e1cdea7fe3ee Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 24 Aug 2011 21:06:33 +0200 Subject: iwlegacy: rename il_{read,write}_prph Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-3945.c | 48 ++++++++++++++-------------- drivers/net/wireless/iwlegacy/iwl-4965-tx.c | 2 +- drivers/net/wireless/iwlegacy/iwl-4965.c | 34 ++++++++++---------- drivers/net/wireless/iwlegacy/iwl-core.c | 6 ++-- drivers/net/wireless/iwlegacy/iwl-io.h | 23 ++++++------- drivers/net/wireless/iwlegacy/iwl3945-base.c | 12 +++---- drivers/net/wireless/iwlegacy/iwl4965-base.c | 18 +++++------ 7 files changed, 72 insertions(+), 71 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index fc8ddb68c7c4..cdea5b036480 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -797,18 +797,18 @@ static int il3945_tx_reset(struct il_priv *il) { /* bypass mode */ - il_write_prph(il, ALM_SCD_MODE_REG, 0x2); + il_wr_prph(il, ALM_SCD_MODE_REG, 0x2); /* RA 0 is active */ - il_write_prph(il, ALM_SCD_ARASTAT_REG, 0x01); + il_wr_prph(il, ALM_SCD_ARASTAT_REG, 0x01); /* all 6 fifo are active */ - il_write_prph(il, ALM_SCD_TXFACT_REG, 0x3f); + il_wr_prph(il, ALM_SCD_TXFACT_REG, 0x3f); - il_write_prph(il, ALM_SCD_SBYP_MODE_1_REG, 0x010000); - il_write_prph(il, ALM_SCD_SBYP_MODE_2_REG, 0x030002); - il_write_prph(il, ALM_SCD_TXF4MF_REG, 0x000004); - il_write_prph(il, ALM_SCD_TXF5MF_REG, 0x000005); + il_wr_prph(il, ALM_SCD_SBYP_MODE_1_REG, 0x010000); + il_wr_prph(il, ALM_SCD_SBYP_MODE_2_REG, 0x030002); + il_wr_prph(il, ALM_SCD_TXF4MF_REG, 0x000004); + il_wr_prph(il, ALM_SCD_TXF5MF_REG, 0x000005); il_wr(il, FH39_TSSR_CBB_BASE, il->_3945.shared_phys); @@ -878,8 +878,8 @@ static int il3945_apm_init(struct il_priv *il) int ret = il_apm_init(il); /* Clear APMG (NIC's internal power management) interrupts */ - il_write_prph(il, APMG_RTC_INT_MSK_REG, 0x0); - il_write_prph(il, APMG_RTC_INT_STT_REG, 0xFFFFFFFF); + il_wr_prph(il, APMG_RTC_INT_MSK_REG, 0x0); + il_wr_prph(il, APMG_RTC_INT_STT_REG, 0xFFFFFFFF); /* Reset radio chip */ il_set_bits_prph(il, APMG_PS_CTRL_REG, @@ -1025,8 +1025,8 @@ void il3945_hw_txq_ctx_stop(struct il_priv *il) int txq_id; /* stop SCD */ - il_write_prph(il, ALM_SCD_MODE_REG, 0); - il_write_prph(il, ALM_SCD_TXFACT_REG, 0); + il_wr_prph(il, ALM_SCD_MODE_REG, 0); + il_wr_prph(il, ALM_SCD_TXFACT_REG, 0); /* reset TFD queues */ for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { @@ -2475,11 +2475,11 @@ static int il3945_verify_bsm(struct il_priv *il) D_INFO("Begin verify bsm\n"); /* verify BSM SRAM contents */ - val = il_read_prph(il, BSM_WR_DWCOUNT_REG); + val = il_rd_prph(il, BSM_WR_DWCOUNT_REG); for (reg = BSM_SRAM_LOWER_BOUND; reg < BSM_SRAM_LOWER_BOUND + len; reg += sizeof(u32), image++) { - val = il_read_prph(il, reg); + val = il_rd_prph(il, reg); if (val != le32_to_cpu(*image)) { IL_ERR("BSM uCode verification failed at " "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", @@ -2583,16 +2583,16 @@ static int il3945_load_bsm(struct il_priv *il) inst_len = il->ucode_init.len; data_len = il->ucode_init_data.len; - il_write_prph(il, BSM_DRAM_INST_PTR_REG, pinst); - il_write_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); - il_write_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); - il_write_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); + il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); + il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); + il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); + il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); /* Fill BSM memory with bootstrap instructions */ for (reg_offset = BSM_SRAM_LOWER_BOUND; reg_offset < BSM_SRAM_LOWER_BOUND + len; reg_offset += sizeof(u32), image++) - _il_write_prph(il, reg_offset, + _il_wr_prph(il, reg_offset, le32_to_cpu(*image)); rc = il3945_verify_bsm(il); @@ -2600,19 +2600,19 @@ static int il3945_load_bsm(struct il_priv *il) return rc; /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ - il_write_prph(il, BSM_WR_MEM_SRC_REG, 0x0); - il_write_prph(il, BSM_WR_MEM_DST_REG, + il_wr_prph(il, BSM_WR_MEM_SRC_REG, 0x0); + il_wr_prph(il, BSM_WR_MEM_DST_REG, IWL39_RTC_INST_LOWER_BOUND); - il_write_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); + il_wr_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); /* Load bootstrap code into instruction SRAM now, * to prepare to load "initialize" uCode */ - il_write_prph(il, BSM_WR_CTRL_REG, + il_wr_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START); /* Wait for load of bootstrap uCode to finish */ for (i = 0; i < 100; i++) { - done = il_read_prph(il, BSM_WR_CTRL_REG); + done = il_rd_prph(il, BSM_WR_CTRL_REG); if (!(done & BSM_WR_CTRL_REG_BIT_START)) break; udelay(10); @@ -2626,7 +2626,7 @@ static int il3945_load_bsm(struct il_priv *il) /* Enable future boot loads whenever power management unit triggers it * (e.g. when powering back up after power-save shutdown) */ - il_write_prph(il, BSM_WR_CTRL_REG, + il_wr_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN); return 0; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index 25c9b7192d9a..f86a3b90fc42 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -754,7 +754,7 @@ static void il4965_tx_queue_stop_scheduler(struct il_priv *il, { /* Simply stop the queue, but don't change any configuration; * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */ - il_write_prph(il, + il_wr_prph(il, IWL49_SCD_QUEUE_STATUS_BITS(txq_id), (0 << IWL49_SCD_QUEUE_STTS_REG_POS_ACTIVE)| (1 << IWL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index 7b422f2346ae..a7450323a668 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -72,11 +72,11 @@ static int il4965_verify_bsm(struct il_priv *il) D_INFO("Begin verify bsm\n"); /* verify BSM SRAM contents */ - val = il_read_prph(il, BSM_WR_DWCOUNT_REG); + val = il_rd_prph(il, BSM_WR_DWCOUNT_REG); for (reg = BSM_SRAM_LOWER_BOUND; reg < BSM_SRAM_LOWER_BOUND + len; reg += sizeof(u32), image++) { - val = il_read_prph(il, reg); + val = il_rd_prph(il, reg); if (val != le32_to_cpu(*image)) { IL_ERR("BSM uCode verification failed at " "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", @@ -156,34 +156,34 @@ static int il4965_load_bsm(struct il_priv *il) inst_len = il->ucode_init.len; data_len = il->ucode_init_data.len; - il_write_prph(il, BSM_DRAM_INST_PTR_REG, pinst); - il_write_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); - il_write_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); - il_write_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); + il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); + il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); + il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); + il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); /* Fill BSM memory with bootstrap instructions */ for (reg_offset = BSM_SRAM_LOWER_BOUND; reg_offset < BSM_SRAM_LOWER_BOUND + len; reg_offset += sizeof(u32), image++) - _il_write_prph(il, reg_offset, le32_to_cpu(*image)); + _il_wr_prph(il, reg_offset, le32_to_cpu(*image)); ret = il4965_verify_bsm(il); if (ret) return ret; /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ - il_write_prph(il, BSM_WR_MEM_SRC_REG, 0x0); - il_write_prph(il, + il_wr_prph(il, BSM_WR_MEM_SRC_REG, 0x0); + il_wr_prph(il, BSM_WR_MEM_DST_REG, IWL49_RTC_INST_LOWER_BOUND); - il_write_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); + il_wr_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); /* Load bootstrap code into instruction SRAM now, * to prepare to load "initialize" uCode */ - il_write_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START); + il_wr_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START); /* Wait for load of bootstrap uCode to finish */ for (i = 0; i < 100; i++) { - done = il_read_prph(il, BSM_WR_CTRL_REG); + done = il_rd_prph(il, BSM_WR_CTRL_REG); if (!(done & BSM_WR_CTRL_REG_BIT_START)) break; udelay(10); @@ -197,7 +197,7 @@ static int il4965_load_bsm(struct il_priv *il) /* Enable future boot loads whenever power management unit triggers it * (e.g. when powering back up after power-save shutdown) */ - il_write_prph(il, + il_wr_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN); @@ -224,14 +224,14 @@ static int il4965_set_ucode_ptrs(struct il_priv *il) pdata = il->ucode_data_backup.p_addr >> 4; /* Tell bootstrap uCode where to find image to load */ - il_write_prph(il, BSM_DRAM_INST_PTR_REG, pinst); - il_write_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); - il_write_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, + il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); + il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); + il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, il->ucode_data.len); /* Inst byte count must be last to set up, bit 31 signals uCode * that all new ptr/size info is in place */ - il_write_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, + il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, il->ucode_code.len | BSM_DRAM_INST_LOAD); D_INFO("Runtime uCode pointers are set.\n"); diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index d2534fb01448..ed4415988e97 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -1069,7 +1069,7 @@ int il_apm_init(struct il_priv *il) /* * Wait for clock stabilization; once stabilized, access to - * device-internal resources is supported, e.g. il_write_prph() + * device-internal resources is supported, e.g. il_wr_prph() * and accesses to uCode SRAM. */ ret = _il_poll_bit(il, CSR_GP_CNTRL, @@ -1089,10 +1089,10 @@ int il_apm_init(struct il_priv *il) * set by default in "CLK_CTRL_REG" after reset. */ if (il->cfg->base_params->use_bsm) - il_write_prph(il, APMG_CLK_EN_REG, + il_wr_prph(il, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT | APMG_CLK_VAL_BSM_CLK_RQT); else - il_write_prph(il, APMG_CLK_EN_REG, + il_wr_prph(il, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT); udelay(20); diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h index f435942ab458..8cb924d1e264 100644 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ b/drivers/net/wireless/iwlegacy/iwl-io.h @@ -197,26 +197,27 @@ static inline int il_poll_bit(struct il_priv *il, u32 addr, return -ETIMEDOUT; } -static inline u32 _il_read_prph(struct il_priv *il, u32 reg) +static inline u32 _il_rd_prph(struct il_priv *il, u32 reg) { _il_wr(il, HBUS_TARG_PRPH_RADDR, reg | (3 << 24)); rmb(); return _il_rd(il, HBUS_TARG_PRPH_RDAT); } -static inline u32 il_read_prph(struct il_priv *il, u32 reg) + +static inline u32 il_rd_prph(struct il_priv *il, u32 reg) { unsigned long reg_flags; u32 val; spin_lock_irqsave(&il->reg_lock, reg_flags); _il_grab_nic_access(il); - val = _il_read_prph(il, reg); + val = _il_rd_prph(il, reg); _il_release_nic_access(il); spin_unlock_irqrestore(&il->reg_lock, reg_flags); return val; } -static inline void _il_write_prph(struct il_priv *il, +static inline void _il_wr_prph(struct il_priv *il, u32 addr, u32 val) { _il_wr(il, HBUS_TARG_PRPH_WADDR, @@ -226,20 +227,20 @@ static inline void _il_write_prph(struct il_priv *il, } static inline void -il_write_prph(struct il_priv *il, u32 addr, u32 val) +il_wr_prph(struct il_priv *il, u32 addr, u32 val) { unsigned long reg_flags; spin_lock_irqsave(&il->reg_lock, reg_flags); if (!_il_grab_nic_access(il)) { - _il_write_prph(il, addr, val); + _il_wr_prph(il, addr, val); _il_release_nic_access(il); } spin_unlock_irqrestore(&il->reg_lock, reg_flags); } #define _il_set_bits_prph(il, reg, mask) \ -_il_write_prph(il, reg, (_il_read_prph(il, reg) | mask)) +_il_wr_prph(il, reg, (_il_rd_prph(il, reg) | mask)) static inline void il_set_bits_prph(struct il_priv *il, u32 reg, u32 mask) @@ -254,8 +255,8 @@ il_set_bits_prph(struct il_priv *il, u32 reg, u32 mask) } #define _il_set_bits_mask_prph(il, reg, bits, mask) \ -_il_write_prph(il, reg, \ - ((_il_read_prph(il, reg) & mask) | bits)) +_il_wr_prph(il, reg, \ + ((_il_rd_prph(il, reg) & mask) | bits)) static inline void il_set_bits_mask_prph(struct il_priv *il, u32 reg, u32 bits, u32 mask) @@ -277,8 +278,8 @@ static inline void il_clear_bits_prph(struct il_priv spin_lock_irqsave(&il->reg_lock, reg_flags); _il_grab_nic_access(il); - val = _il_read_prph(il, reg); - _il_write_prph(il, reg, (val & ~mask)); + val = _il_rd_prph(il, reg); + _il_wr_prph(il, reg, (val & ~mask)); _il_release_nic_access(il); spin_unlock_irqrestore(&il->reg_lock, reg_flags); } diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index a0b5a74972a9..5037216041ca 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -2122,14 +2122,14 @@ static int il3945_set_ucode_ptrs(struct il_priv *il) pdata = il->ucode_data_backup.p_addr; /* Tell bootstrap uCode where to find image to load */ - il_write_prph(il, BSM_DRAM_INST_PTR_REG, pinst); - il_write_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); - il_write_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, + il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); + il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); + il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, il->ucode_data.len); /* Inst byte count must be last to set up, bit 31 signals uCode * that all new ptr/size info is in place */ - il_write_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, + il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, il->ucode_code.len | BSM_DRAM_INST_LOAD); D_INFO("Runtime uCode pointers are set.\n"); @@ -2210,7 +2210,7 @@ static void il3945_alive_start(struct il_priv *il) goto restart; } - rfkill = il_read_prph(il, APMG_RFKILL_REG); + rfkill = il_rd_prph(il, APMG_RFKILL_REG); D_INFO("RFKILL status: 0x%x\n", rfkill); if (rfkill & 0x1) { @@ -2342,7 +2342,7 @@ static void __il3945_down(struct il_priv *il) il3945_hw_rxq_stop(il); /* Power-down device's busmaster DMA clocks */ - il_write_prph(il, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); + il_wr_prph(il, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); udelay(5); /* Stop the device, and put it in low power state */ diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index b0668ea9b104..0f7d44c95f08 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -1622,7 +1622,7 @@ static int il4965_alive_notify(struct il_priv *il) spin_lock_irqsave(&il->lock, flags); /* Clear 4965's internal Tx Scheduler data base */ - il->scd_base_addr = il_read_prph(il, + il->scd_base_addr = il_rd_prph(il, IWL49_SCD_SRAM_BASE_ADDR); a = il->scd_base_addr + IWL49_SCD_CONTEXT_DATA_OFFSET; for (; a < il->scd_base_addr + IWL49_SCD_TX_STTS_BITMAP_OFFSET; a += 4) @@ -1634,7 +1634,7 @@ static int il4965_alive_notify(struct il_priv *il) il_write_targ_mem(il, a, 0); /* Tel 4965 where to find Tx byte count tables */ - il_write_prph(il, IWL49_SCD_DRAM_BASE_ADDR, + il_wr_prph(il, IWL49_SCD_DRAM_BASE_ADDR, il->scd_bc_tbls.dma >> 10); /* Enable DMA channel */ @@ -1650,13 +1650,13 @@ static int il4965_alive_notify(struct il_priv *il) reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); /* Disable chain mode for all queues */ - il_write_prph(il, IWL49_SCD_QUEUECHAIN_SEL, 0); + il_wr_prph(il, IWL49_SCD_QUEUECHAIN_SEL, 0); /* Initialize each Tx queue (including the command queue) */ for (i = 0; i < il->hw_params.max_txq_num; i++) { /* TFD circular buffer read/write indexes */ - il_write_prph(il, IWL49_SCD_QUEUE_RDPTR(i), 0); + il_wr_prph(il, IWL49_SCD_QUEUE_RDPTR(i), 0); il_wr(il, HBUS_TARG_WRPTR, 0 | (i << 8)); /* Max Tx Window size for Scheduler-ACK mode */ @@ -1675,7 +1675,7 @@ static int il4965_alive_notify(struct il_priv *il) IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); } - il_write_prph(il, IWL49_SCD_INTERRUPT_MASK, + il_wr_prph(il, IWL49_SCD_INTERRUPT_MASK, (1 << il->hw_params.max_txq_num) - 1); /* Activate all Tx DMA/FIFO channels */ @@ -1868,7 +1868,7 @@ static void __il4965_down(struct il_priv *il) il4965_rxq_stop(il); /* Power-down device's busmaster DMA clocks */ - il_write_prph(il, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); + il_wr_prph(il, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); udelay(5); /* Make sure (redundant) we've released our request to stay awake */ @@ -2733,7 +2733,7 @@ void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 index) { il_wr(il, HBUS_TARG_WRPTR, (index & 0xff) | (txq_id << 8)); - il_write_prph(il, IWL49_SCD_QUEUE_RDPTR(txq_id), index); + il_wr_prph(il, IWL49_SCD_QUEUE_RDPTR(txq_id), index); } void il4965_tx_queue_set_status(struct il_priv *il, @@ -2746,7 +2746,7 @@ void il4965_tx_queue_set_status(struct il_priv *il, int active = test_bit(txq_id, &il->txq_ctx_active_msk) ? 1 : 0; /* Set up and activate */ - il_write_prph(il, IWL49_SCD_QUEUE_STATUS_BITS(txq_id), + il_wr_prph(il, IWL49_SCD_QUEUE_STATUS_BITS(txq_id), (active << IWL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | (tx_fifo_id << IWL49_SCD_QUEUE_STTS_REG_POS_TXF) | (scd_retry << IWL49_SCD_QUEUE_STTS_REG_POS_WSL) | @@ -3195,7 +3195,7 @@ static void __devexit il4965_pci_remove(struct pci_dev *pdev) */ void il4965_txq_set_sched(struct il_priv *il, u32 mask) { - il_write_prph(il, IWL49_SCD_TXFACT, mask); + il_wr_prph(il, IWL49_SCD_TXFACT, mask); } /***************************************************************************** -- cgit v1.2.3 From 232913b51e6f6e7105184b23a436dfc6b942491b Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 26 Aug 2011 10:45:16 +0200 Subject: iwlegacy: remove not needed parentheses Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-3945-hw.h | 4 +- drivers/net/wireless/iwlegacy/iwl-3945-rs.c | 40 ++++---- drivers/net/wireless/iwlegacy/iwl-3945.c | 25 +++-- drivers/net/wireless/iwlegacy/iwl-4965-calib.c | 27 +++--- drivers/net/wireless/iwlegacy/iwl-4965-hw.h | 8 +- drivers/net/wireless/iwlegacy/iwl-4965-lib.c | 6 +- drivers/net/wireless/iwlegacy/iwl-4965-rs.c | 125 ++++++++++++------------- drivers/net/wireless/iwlegacy/iwl-4965-tx.c | 19 ++-- drivers/net/wireless/iwlegacy/iwl-4965.c | 44 ++++----- drivers/net/wireless/iwlegacy/iwl-4965.h | 4 +- drivers/net/wireless/iwlegacy/iwl-core.c | 18 ++-- drivers/net/wireless/iwlegacy/iwl-io.h | 2 +- drivers/net/wireless/iwlegacy/iwl-legacy-rs.h | 2 +- drivers/net/wireless/iwlegacy/iwl-scan.c | 2 +- drivers/net/wireless/iwlegacy/iwl-sta.c | 2 +- drivers/net/wireless/iwlegacy/iwl-tx.c | 2 +- drivers/net/wireless/iwlegacy/iwl3945-base.c | 20 ++-- 17 files changed, 168 insertions(+), 182 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-hw.h b/drivers/net/wireless/iwlegacy/iwl-3945-hw.h index ad0509378714..67650ffa2d58 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-hw.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945-hw.h @@ -264,8 +264,8 @@ struct il3945_eeprom { static inline int il3945_hw_valid_rtc_data_addr(u32 addr) { - return (addr >= IWL39_RTC_DATA_LOWER_BOUND) && - (addr < IWL39_RTC_DATA_UPPER_BOUND); + return (addr >= IWL39_RTC_DATA_LOWER_BOUND && + addr < IWL39_RTC_DATA_UPPER_BOUND); } /* Base physical address of il3945_shared is provided to FH_TSSR_CBB_BASE diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c index d05da7a46c41..afa6be81f9a5 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c @@ -104,7 +104,7 @@ static u8 il3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band) u32 table_size = 0; struct il3945_tpt_entry *tpt_table = NULL; - if ((rssi < IL_MIN_RSSI_VAL) || (rssi > IL_MAX_RSSI_VAL)) + if (rssi < IL_MIN_RSSI_VAL || rssi > IL_MAX_RSSI_VAL) rssi = IL_MIN_RSSI_VAL; switch (band) { @@ -123,7 +123,7 @@ static u8 il3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band) break; } - while ((index < table_size) && (rssi < tpt_table[index].min_rssi)) + while (index < table_size && rssi < tpt_table[index].min_rssi) index++; index = min(index, (table_size - 1)); @@ -315,8 +315,8 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, fail_count = window->counter - window->success_counter; /* Calculate average throughput, if we have enough history. */ - if ((fail_count >= IL_RATE_MIN_FAILURE_TH) || - (window->success_counter >= IL_RATE_MIN_SUCCESS_TH)) + if (fail_count >= IL_RATE_MIN_FAILURE_TH || + window->success_counter >= IL_RATE_MIN_SUCCESS_TH) window->average_tpt = ((window->success_ratio * rs_sta->expected_tpt[index] + 64) / 128); else @@ -461,7 +461,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * retries = IL_RATE_RETRY_TH; first_index = sband->bitrates[info->status.rates[0].idx].hw_value; - if ((first_index < 0) || (first_index >= IL_RATE_COUNT_3945)) { + if (first_index < 0 || first_index >= IL_RATE_COUNT_3945) { D_RATE("leave: Rate out of bounds: %d\n", first_index); return; } @@ -663,9 +663,9 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, /* get user max rate if set */ max_rate_idx = txrc->max_rate_idx; - if ((sband->band == IEEE80211_BAND_5GHZ) && (max_rate_idx != -1)) + if (sband->band == IEEE80211_BAND_5GHZ && max_rate_idx != -1) max_rate_idx += IL_FIRST_OFDM_RATE; - if ((max_rate_idx < 0) || (max_rate_idx >= IL_RATE_COUNT)) + if (max_rate_idx < 0 || max_rate_idx >= IL_RATE_COUNT) max_rate_idx = -1; index = min(rs_sta->last_txrate_idx & 0xffff, IL_RATE_COUNT_3945 - 1); @@ -686,7 +686,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, } /* force user max rate if set by user */ - if ((max_rate_idx != -1) && (max_rate_idx < index)) { + if (max_rate_idx != -1 && max_rate_idx < index) { if (rate_mask & (1 << max_rate_idx)) index = max_rate_idx; } @@ -695,8 +695,8 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, fail_count = window->counter - window->success_counter; - if (((fail_count < IL_RATE_MIN_FAILURE_TH) && - (window->success_counter < IL_RATE_MIN_SUCCESS_TH))) { + if (fail_count < IL_RATE_MIN_FAILURE_TH && + window->success_counter < IL_RATE_MIN_SUCCESS_TH) { spin_unlock_irqrestore(&rs_sta->lock, flags); D_RATE("Invalid average_tpt on rate %d: " @@ -721,7 +721,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, high = (high_low >> 8) & 0xff; /* If user set max rate, dont allow higher than user constrain */ - if ((max_rate_idx != -1) && (max_rate_idx < high)) + if (max_rate_idx != -1 && max_rate_idx < high) high = IL_RATE_INVALID; /* Collect Measured throughputs of adjacent rates */ @@ -736,13 +736,13 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, scale_action = 0; /* Low success ratio , need to drop the rate */ - if ((window->success_ratio < IL_RATE_DECREASE_TH) || !current_tpt) { + if (window->success_ratio < IL_RATE_DECREASE_TH || !current_tpt) { D_RATE("decrease rate because of low success_ratio\n"); scale_action = -1; /* No throughput measured yet for adjacent rates, * try increase */ - } else if ((low_tpt == IL_INVALID_VALUE) && - (high_tpt == IL_INVALID_VALUE)) { + } else if (low_tpt == IL_INVALID_VALUE && + high_tpt == IL_INVALID_VALUE) { if (high != IL_RATE_INVALID && window->success_ratio >= IL_RATE_INCREASE_TH) scale_action = 1; @@ -752,9 +752,9 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, /* Both adjacent throughputs are measured, but neither one has * better throughput; we're using the best rate, don't change * it! */ - } else if ((low_tpt != IL_INVALID_VALUE) && - (high_tpt != IL_INVALID_VALUE) && - (low_tpt < current_tpt) && (high_tpt < current_tpt)) { + } else if (low_tpt != IL_INVALID_VALUE && + high_tpt != IL_INVALID_VALUE && + low_tpt < current_tpt && high_tpt < current_tpt) { D_RATE("No action -- low [%d] & high [%d] < " "current_tpt [%d]\n", @@ -790,9 +790,9 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, /* Sanity check; asked for decrease, but success rate or throughput * has been good at old rate. Don't change it. */ - if ((scale_action == -1) && (low != IL_RATE_INVALID) && - ((window->success_ratio > IL_RATE_HIGH_TH) || - (current_tpt > (100 * rs_sta->expected_tpt[low])))) + if (scale_action == -1 && low != IL_RATE_INVALID && + (window->success_ratio > IL_RATE_HIGH_TH || + current_tpt > 100 * rs_sta->expected_tpt[low])) scale_action = 0; switch (scale_action) { diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index cdea5b036480..fb69b745f8a7 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -173,7 +173,7 @@ void il3945_disable_events(struct il_priv *il) disable_ptr = il_read_targ_mem(il, base + (4 * sizeof(u32))); array_size = il_read_targ_mem(il, base + (5 * sizeof(u32))); - if (IL_EVT_DISABLE && (array_size == IL_EVT_DISABLE_SIZE)) { + if (IL_EVT_DISABLE && array_size == IL_EVT_DISABLE_SIZE) { D_INFO("Disabling selected uCode log events at 0x%x\n", disable_ptr); for (i = 0; i < IL_EVT_DISABLE_SIZE; i++) @@ -293,9 +293,8 @@ static void il3945_tx_queue_reclaim(struct il_priv *il, il->cfg->ops->lib->txq_free_tfd(il, txq); } - if (il_queue_space(q) > q->low_mark && (txq_id >= 0) && - (txq_id != IWL39_CMD_QUEUE_NUM) && - il->mac80211_registered) + if (il_queue_space(q) > q->low_mark && txq_id >= 0 && + txq_id != IWL39_CMD_QUEUE_NUM && il->mac80211_registered) il_wake_queue(il, txq); } @@ -316,7 +315,7 @@ static void il3945_rx_reply_tx(struct il_priv *il, int rate_idx; int fail; - if ((index >= txq->q.n_bd) || (il_queue_used(&txq->q, index) == 0)) { + if (index >= txq->q.n_bd || il_queue_used(&txq->q, index) == 0) { IL_ERR("Read index for DMA queue txq_id (%d) index %d " "is out of range [0-%d] %d %d\n", txq_id, index, txq->q.n_bd, txq->q.write_ptr, @@ -544,8 +543,8 @@ static void il3945_rx_reply_rx(struct il_priv *il, return; } - if (!(rx_end->status & RX_RES_STATUS_NO_CRC32_ERROR) - || !(rx_end->status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { + if (!(rx_end->status & RX_RES_STATUS_NO_CRC32_ERROR) || + !(rx_end->status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { D_RX("Bad CRC or FIFO: 0x%08X.\n", rx_end->status); return; } @@ -599,7 +598,7 @@ int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, count = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags)); - if ((count >= NUM_TFD_CHUNKS) || (count < 0)) { + if (count >= NUM_TFD_CHUNKS || count < 0) { IL_ERR("Error can not send more than %d chunks\n", NUM_TFD_CHUNKS); return -EINVAL; @@ -1053,7 +1052,7 @@ static int il3945_hw_reg_adjust_power_by_temp(int new_reading, int old_reading) */ static inline int il3945_hw_reg_temp_out_of_range(int temperature) { - return ((temperature < -260) || (temperature > 25)) ? 1 : 0; + return (temperature < -260 || temperature > 25) ? 1 : 0; } int il3945_hw_get_temperature(struct il_priv *il) @@ -1666,10 +1665,10 @@ static int il3945_send_rxon_assoc(struct il_priv *il, const struct il_rxon_cmd *rxon1 = &ctx->staging; const struct il_rxon_cmd *rxon2 = &ctx->active; - if ((rxon1->flags == rxon2->flags) && - (rxon1->filter_flags == rxon2->filter_flags) && - (rxon1->cck_basic_rates == rxon2->cck_basic_rates) && - (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { + if (rxon1->flags == rxon2->flags && + rxon1->filter_flags == rxon2->filter_flags && + rxon1->cck_basic_rates == rxon2->cck_basic_rates && + rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates) { D_INFO("Using current RXON_ASSOC. Not resending.\n"); return 0; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c index 7f858344b920..c055a153f7df 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c @@ -198,8 +198,8 @@ static int il4965_sens_energy_cck(struct il_priv *il, data->num_in_cck_no_fa); /* If we got too many false alarms this time, reduce sensitivity */ - if ((false_alarms > max_false_alarms) && - (data->auto_corr_cck > AUTO_CORR_MAX_TH_CCK)) { + if (false_alarms > max_false_alarms && + data->auto_corr_cck > AUTO_CORR_MAX_TH_CCK) { D_CALIB("norm FA %u > max FA %u\n", false_alarms, max_false_alarms); D_CALIB("... reducing sensitivity\n"); @@ -230,9 +230,9 @@ static int il4965_sens_energy_cck(struct il_priv *il, * from a previous beacon with too many, or healthy # FAs * OR 2) We've seen a lot of beacons (100) with too few * false alarms */ - if ((data->nrg_prev_state != IL_FA_TOO_MANY) && - ((data->nrg_auto_corr_silence_diff > NRG_DIFF) || - (data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA))) { + if (data->nrg_prev_state != IL_FA_TOO_MANY && + (data->nrg_auto_corr_silence_diff > NRG_DIFF || + data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA)) { D_CALIB("... increasing sensitivity\n"); /* Increase nrg value to increase sensitivity */ @@ -289,9 +289,9 @@ static int il4965_sens_energy_cck(struct il_priv *il, val = data->auto_corr_cck_mrc + AUTO_CORR_STEP_CCK; data->auto_corr_cck_mrc = min((u32)ranges->auto_corr_max_cck_mrc, val); - } else if ((false_alarms < min_false_alarms) && - ((data->nrg_auto_corr_silence_diff > NRG_DIFF) || - (data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA))) { + } else if (false_alarms < min_false_alarms && + (data->nrg_auto_corr_silence_diff > NRG_DIFF || + data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA)) { /* Decrease auto_corr values to increase sensitivity */ val = data->auto_corr_cck - AUTO_CORR_STEP_CCK; @@ -747,9 +747,8 @@ static void il4965_gain_computation(struct il_priv *il, for (i = default_chain; i < NUM_RX_CHAINS; i++) { s32 delta_g = 0; - if (!(data->disconn_array[i]) && - (data->delta_gain_code[i] == - CHAIN_NOISE_DELTA_GAIN_INIT_VAL)) { + if (!data->disconn_array[i] && + data->delta_gain_code[i] == CHAIN_NOISE_DELTA_GAIN_INIT_VAL) { delta_g = average_noise[i] - min_average_noise; data->delta_gain_code[i] = (u8)((delta_g * 10) / 15); data->delta_gain_code[i] = @@ -860,7 +859,7 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) /* Make sure we accumulate data for just the associated channel * (even if scanning). */ - if ((rxon_chnum != stat_chnum) || (rxon_band24 != stat_band24)) { + if (rxon_chnum != stat_chnum || rxon_band24 != stat_band24) { D_CALIB("Stats not from chan=%d, band24=%d\n", rxon_chnum, rxon_band24); spin_unlock_irqrestore(&il->lock, flags); @@ -920,8 +919,8 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) il->cfg->base_params->chain_noise_num_beacons; for (i = 0; i < NUM_RX_CHAINS; i++) { - if (!(data->disconn_array[i]) && - (average_noise[i] <= min_average_noise)) { + if (!data->disconn_array[i] && + average_noise[i] <= min_average_noise) { /* This means that chain i is active and has * lower noise values so far: */ min_average_noise = average_noise[i]; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h index b6b7fe2f5ca4..b21c0040c20a 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h @@ -102,8 +102,8 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) { - return (addr >= IWL49_RTC_DATA_LOWER_BOUND) && - (addr < IWL49_RTC_DATA_UPPER_BOUND); + return (addr >= IWL49_RTC_DATA_LOWER_BOUND && + addr < IWL49_RTC_DATA_UPPER_BOUND); } /********************* START TEMPERATURE *************************************/ @@ -147,8 +147,8 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) #define IL_TX_POWER_TEMPERATURE_MAX (410) #define IL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(t) \ - (((t) < IL_TX_POWER_TEMPERATURE_MIN) || \ - ((t) > IL_TX_POWER_TEMPERATURE_MAX)) + ((t) < IL_TX_POWER_TEMPERATURE_MIN || \ + (t) > IL_TX_POWER_TEMPERATURE_MAX) /********************* END TEMPERATURE ***************************************/ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index 8fafd201717c..8bb2b6280d72 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -234,7 +234,7 @@ void il4965_rx_queue_restock(struct il_priv *il) unsigned long flags; spin_lock_irqsave(&rxq->lock, flags); - while ((il_rx_queue_space(rxq) > 0) && (rxq->free_count)) { + while (il_rx_queue_space(rxq) > 0 && rxq->free_count) { /* The overwritten rxb must be a used one */ rxb = rxq->queue[rxq->write]; BUG_ON(rxb && rxb->page); @@ -307,7 +307,7 @@ static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) "order: %d\n", il->hw_params.rx_page_order); - if ((rxq->free_count <= RX_LOW_WATERMARK) && + if (rxq->free_count <= RX_LOW_WATERMARK && net_ratelimit()) IL_ERR( "Failed to alloc_pages with %s. " @@ -1106,7 +1106,7 @@ void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx) ctx->staging.rx_chain = cpu_to_le16(rx_chain); - if (!is_single && (active_rx_cnt >= IL_NUM_RX_CHAINS_SINGLE) && is_cam) + if (!is_single && active_rx_cnt >= IL_NUM_RX_CHAINS_SINGLE && is_cam) ctx->staging.rx_chain |= RXON_RX_CHAIN_MIMO_FORCE_MSK; else ctx->staging.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index 93bb31d628b6..c2f42301014d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -127,7 +127,7 @@ static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags) /* skip 9M not supported in ht*/ if (idx >= IL_RATE_9M_INDEX) idx += 1; - if ((idx >= IL_FIRST_OFDM_RATE) && (idx <= IL_LAST_OFDM_RATE)) + if (idx >= IL_FIRST_OFDM_RATE && idx <= IL_LAST_OFDM_RATE) return idx; /* legacy rate format, search for match in table */ @@ -251,8 +251,7 @@ il4965_rs_tl_rm_old_stats(struct il_traffic_load *tl, u32 curr_time) /* The oldest age we want to keep */ u32 oldest_time = curr_time - TID_MAX_TIME_DIFF; - while (tl->queue_count && - (tl->time_stamp < oldest_time)) { + while (tl->queue_count && tl->time_stamp < oldest_time) { tl->total -= tl->packet_count[tl->head]; tl->packet_count[tl->head] = 0; tl->time_stamp += TID_QUEUE_CELL_SPACING; @@ -477,8 +476,8 @@ static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, fail_count = window->counter - window->success_counter; /* Calculate average throughput, if we have enough history. */ - if ((fail_count >= IL_RATE_MIN_FAILURE_TH) || - (window->success_counter >= IL_RATE_MIN_SUCCESS_TH)) + if (fail_count >= IL_RATE_MIN_FAILURE_TH || + window->success_counter >= IL_RATE_MIN_SUCCESS_TH) window->average_tpt = (window->success_ratio * tpt + 64) / 128; else window->average_tpt = IL_INVALID_VALUE; @@ -619,7 +618,7 @@ static int il4965_rs_toggle_antenna(u32 valid_ant, u32 *rate_n_flags, new_ant_type = ant_toggle_lookup[tbl->ant_type]; - while ((new_ant_type != tbl->ant_type) && + while (new_ant_type != tbl->ant_type && !il4965_rs_is_valid_ant(valid_ant, new_ant_type)) new_ant_type = ant_toggle_lookup[new_ant_type]; @@ -790,8 +789,8 @@ out: static bool il4965_table_type_matches(struct il_scale_tbl_info *a, struct il_scale_tbl_info *b) { - return (a->lq_type == b->lq_type) && (a->ant_type == b->ant_type) && - (a->is_SGI == b->is_SGI); + return (a->lq_type == b->lq_type && a->ant_type == b->ant_type && + a->is_SGI == b->is_SGI); } /* @@ -830,7 +829,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, } if (!ieee80211_is_data(hdr->frame_control) || - info->flags & IEEE80211_TX_CTL_NO_ACK) + (info->flags & IEEE80211_TX_CTL_NO_ACK)) return; /* This packet was aggregated but doesn't carry status info */ @@ -867,19 +866,14 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, mac_index += IL_FIRST_OFDM_RATE; } /* Here we actually compare this rate to the latest LQ command */ - if ((mac_index < 0) || - (tbl_type.is_SGI != - !!(mac_flags & IEEE80211_TX_RC_SHORT_GI)) || - (tbl_type.is_ht40 != - !!(mac_flags & IEEE80211_TX_RC_40_MHZ_WIDTH)) || - (tbl_type.is_dup != - !!(mac_flags & IEEE80211_TX_RC_DUP_DATA)) || - (tbl_type.ant_type != info->antenna_sel_tx) || - (!!(tx_rate & RATE_MCS_HT_MSK) != - !!(mac_flags & IEEE80211_TX_RC_MCS)) || - (!!(tx_rate & RATE_MCS_GF_MSK) != - !!(mac_flags & IEEE80211_TX_RC_GREEN_FIELD)) || - (rs_index != mac_index)) { + if (mac_index < 0 || + tbl_type.is_SGI != !!(mac_flags & IEEE80211_TX_RC_SHORT_GI) || + tbl_type.is_ht40 != !!(mac_flags & IEEE80211_TX_RC_40_MHZ_WIDTH) || + tbl_type.is_dup != !!(mac_flags & IEEE80211_TX_RC_DUP_DATA) || + tbl_type.ant_type != info->antenna_sel_tx || + !!(tx_rate & RATE_MCS_HT_MSK) != !!(mac_flags & IEEE80211_TX_RC_MCS) || + !!(tx_rate & RATE_MCS_GF_MSK) != !!(mac_flags & IEEE80211_TX_RC_GREEN_FIELD) || + rs_index != mac_index) { D_RATE( "initial rate %d does not match %d (0x%x)\n", mac_index, rs_index, tx_rate); @@ -1119,12 +1113,12 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il, * conditions) at candidate rate is above expected * "active" throughput (under perfect conditions). */ - if ((((100 * tpt_tbl[rate]) > lq_sta->last_tpt) && - ((active_sr > IL_RATE_DECREASE_TH) && - (active_sr <= IL_RATE_HIGH_TH) && - (tpt_tbl[rate] <= active_tpt))) || - ((active_sr >= IL_RATE_SCALE_SWITCH) && - (tpt_tbl[rate] > active_tpt))) { + if ((100 * tpt_tbl[rate] > lq_sta->last_tpt && + (active_sr > IL_RATE_DECREASE_TH && + active_sr <= IL_RATE_HIGH_TH && + tpt_tbl[rate] <= active_tpt)) || + (active_sr >= IL_RATE_SCALE_SWITCH && + tpt_tbl[rate] > active_tpt)) { /* (2nd or later pass) * If we've already tried to raise the rate, and are @@ -1213,7 +1207,7 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *il, D_RATE("LQ: MIMO2 best rate %d mask %X\n", rate, rate_mask); - if ((rate == IL_RATE_INVALID) || !((1 << rate) & rate_mask)) { + if (rate == IL_RATE_INVALID || !((1 << rate) & rate_mask)) { D_RATE( "Can't switch with index %d rate mask %x\n", rate, rate_mask); @@ -1265,7 +1259,7 @@ static int il4965_rs_switch_to_siso(struct il_priv *il, rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, index); D_RATE("LQ: get best rate %d mask %X\n", rate, rate_mask); - if ((rate == IL_RATE_INVALID) || !((1 << rate) & rate_mask)) { + if (rate == IL_RATE_INVALID || !((1 << rate) & rate_mask)) { D_RATE( "can not switch with index %d rate mask %x\n", rate, rate_mask); @@ -1680,10 +1674,10 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) * stats in active history. */ if (force_search || - (lq_sta->total_failed > lq_sta->max_failure_limit) || - (lq_sta->total_success > lq_sta->max_success_limit) || - ((!lq_sta->search_better_tbl) && (lq_sta->flush_timer) - && (flush_interval_passed))) { + lq_sta->total_failed > lq_sta->max_failure_limit || + lq_sta->total_success > lq_sta->max_success_limit || + (!lq_sta->search_better_tbl && lq_sta->flush_timer && + flush_interval_passed)) { D_RATE("LQ: stay is expired %d %d %d\n:", lq_sta->total_failed, lq_sta->total_success, @@ -1788,7 +1782,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Send management frames and NO_ACK data using lowest rate. */ /* TODO: this could probably be improved.. */ if (!ieee80211_is_data(hdr->frame_control) || - info->flags & IEEE80211_TX_CTL_NO_ACK) + (info->flags & IEEE80211_TX_CTL_NO_ACK)) return; if (!sta || !lq_sta) @@ -1797,7 +1791,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, lq_sta->supp_rates = sta->supp_rates[lq_sta->band]; tid = il4965_rs_tl_add_packet(lq_sta, hdr); - if ((tid != MAX_TID_COUNT) && (lq_sta->tx_agg_tid_en & (1 << tid))) { + if (tid != MAX_TID_COUNT && (lq_sta->tx_agg_tid_en & (1 << tid))) { tid_data = &il->stations[lq_sta->lq.sta_id].tid[tid]; if (tid_data->agg.state == IL_AGG_OFF) lq_sta->is_agg = 0; @@ -1872,8 +1866,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, } /* force user max rate if set by user */ - if ((lq_sta->max_rate_idx != -1) && - (lq_sta->max_rate_idx < index)) { + if (lq_sta->max_rate_idx != -1 && + lq_sta->max_rate_idx < index) { index = lq_sta->max_rate_idx; update_lq = 1; window = &(tbl->win[index]); @@ -1890,8 +1884,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, * in current association (use new rate found above). */ fail_count = window->counter - window->success_counter; - if ((fail_count < IL_RATE_MIN_FAILURE_TH) && - (window->success_counter < IL_RATE_MIN_SUCCESS_TH)) { + if (fail_count < IL_RATE_MIN_FAILURE_TH && + window->success_counter < IL_RATE_MIN_SUCCESS_TH) { D_RATE("LQ: still below TH. succ=%d total=%d " "for index %d\n", window->success_counter, window->counter, index); @@ -1975,8 +1969,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, high = (high_low >> 8) & 0xff; /* If user set max rate, dont allow higher than user constrain */ - if ((lq_sta->max_rate_idx != -1) && - (lq_sta->max_rate_idx < high)) + if (lq_sta->max_rate_idx != -1 && + lq_sta->max_rate_idx < high) high = IL_RATE_INVALID; sr = window->success_ratio; @@ -1991,14 +1985,14 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, scale_action = 0; /* Too many failures, decrease rate */ - if ((sr <= IL_RATE_DECREASE_TH) || (current_tpt == 0)) { + if (sr <= IL_RATE_DECREASE_TH || current_tpt == 0) { D_RATE( "decrease rate because of low success_ratio\n"); scale_action = -1; /* No throughput measured yet for adjacent rates; try increase. */ - } else if ((low_tpt == IL_INVALID_VALUE) && - (high_tpt == IL_INVALID_VALUE)) { + } else if (low_tpt == IL_INVALID_VALUE && + high_tpt == IL_INVALID_VALUE) { if (high != IL_RATE_INVALID && sr >= IL_RATE_INCREASE_TH) scale_action = 1; @@ -2008,10 +2002,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Both adjacent throughputs are measured, but neither one has better * throughput; we're using the best rate, don't change it! */ - else if ((low_tpt != IL_INVALID_VALUE) && - (high_tpt != IL_INVALID_VALUE) && - (low_tpt < current_tpt) && - (high_tpt < current_tpt)) + else if (low_tpt != IL_INVALID_VALUE && high_tpt != IL_INVALID_VALUE && + low_tpt < current_tpt && high_tpt < current_tpt) scale_action = 0; /* At least one adjacent rate's throughput is measured, @@ -2021,7 +2013,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, if (high_tpt != IL_INVALID_VALUE) { /* Higher rate has better throughput */ if (high_tpt > current_tpt && - sr >= IL_RATE_INCREASE_TH) { + sr >= IL_RATE_INCREASE_TH) { scale_action = 1; } else { scale_action = 0; @@ -2042,9 +2034,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Sanity check; asked for decrease, but success rate or throughput * has been good at old rate. Don't change it. */ - if ((scale_action == -1) && (low != IL_RATE_INVALID) && - ((sr > IL_RATE_HIGH_TH) || - (current_tpt > (100 * tbl->expected_tpt[low])))) + if (scale_action == -1 && low != IL_RATE_INVALID && + (sr > IL_RATE_HIGH_TH || current_tpt > 100 * tbl->expected_tpt[low])) scale_action = 0; switch (scale_action) { @@ -2090,8 +2081,8 @@ lq_update: * 2) Not just finishing up a search * 3) Allowing a new search */ - if (!update_lq && !done_search && - !lq_sta->stay_in_tbl && window->counter) { + if (!update_lq && !done_search && !lq_sta->stay_in_tbl && + window->counter) { /* Save current throughput to compare with "search" throughput*/ lq_sta->last_tpt = current_tpt; @@ -2146,10 +2137,10 @@ lq_update: * have been tried and compared, stay in this best modulation * mode for a while before next round of mode comparisons. */ if (lq_sta->enable_counter && - (lq_sta->action_counter >= tbl1->max_search)) { - if ((lq_sta->last_tpt > IL_AGG_TPT_THREHOLD) && + lq_sta->action_counter >= tbl1->max_search) { + if (lq_sta->last_tpt > IL_AGG_TPT_THREHOLD && (lq_sta->tx_agg_tid_en & (1 << tid)) && - (tid != MAX_TID_COUNT)) { + tid != MAX_TID_COUNT) { tid_data = &il->stations[lq_sta->lq.sta_id].tid[tid]; if (tid_data->agg.state == IL_AGG_OFF) { @@ -2217,7 +2208,7 @@ static void il4965_rs_initialize_lq(struct il_priv *il, tbl = &(lq_sta->lq_info[active_tbl]); - if ((i < 0) || (i >= IL_RATE_COUNT)) + if (i < 0 || i >= IL_RATE_COUNT) i = 0; rate = il_rates[i].plcp; @@ -2256,11 +2247,11 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, /* Get max rate if user set max rate */ if (lq_sta) { lq_sta->max_rate_idx = txrc->max_rate_idx; - if ((sband->band == IEEE80211_BAND_5GHZ) && - (lq_sta->max_rate_idx != -1)) + if (sband->band == IEEE80211_BAND_5GHZ && + lq_sta->max_rate_idx != -1) lq_sta->max_rate_idx += IL_FIRST_OFDM_RATE; - if ((lq_sta->max_rate_idx < 0) || - (lq_sta->max_rate_idx >= IL_RATE_COUNT)) + if (lq_sta->max_rate_idx < 0 || + lq_sta->max_rate_idx >= IL_RATE_COUNT) lq_sta->max_rate_idx = -1; } @@ -2301,9 +2292,9 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, IEEE80211_TX_RC_GREEN_FIELD; } else { /* Check for invalid rates */ - if ((rate_idx < 0) || (rate_idx >= IL_RATE_COUNT_LEGACY) || - ((sband->band == IEEE80211_BAND_5GHZ) && - (rate_idx < IL_FIRST_OFDM_RATE))) + if (rate_idx < 0 || rate_idx >= IL_RATE_COUNT_LEGACY || + (sband->band == IEEE80211_BAND_5GHZ && + rate_idx < IL_FIRST_OFDM_RATE)) rate_idx = rate_lowest_index(sband, sta); /* On valid 5 GHz rate, adjust index */ else if (sband->band == IEEE80211_BAND_5GHZ) @@ -2475,7 +2466,7 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, /* Repeat initial/next rate. * For legacy IL_NUMBER_TRY == 1, this loop will not execute. * For HT IL_HT_NUMBER_TRY == 3, this executes twice. */ - while (repeat_rate > 0 && (index < LINK_QUAL_MAX_RETRY_NUM)) { + while (repeat_rate > 0 && index < LINK_QUAL_MAX_RETRY_NUM) { if (is_legacy(tbl_type.lq_type)) { if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE) ant_toggle_cnt++; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index f86a3b90fc42..a32a4f32b97d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -195,8 +195,8 @@ static void il4965_tx_cmd_build_rate(struct il_priv *il, * index is invalid. */ rate_idx = info->control.rates[0].idx; - if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS || - (rate_idx < 0) || (rate_idx > IL_RATE_COUNT_LEGACY)) + if ((info->control.rates[0].flags & IEEE80211_TX_RC_MCS) || + rate_idx < 0 || rate_idx > IL_RATE_COUNT_LEGACY) rate_idx = rate_lowest_index(&il->bands[info->band], info->control.sta); /* For 5 GHZ band, remap mac80211 rate indices into driver indices */ @@ -208,7 +208,7 @@ static void il4965_tx_cmd_build_rate(struct il_priv *il, rate_flags = 0; /* Set CCK flag as needed */ - if ((rate_idx >= IL_FIRST_CCK_RATE) && (rate_idx <= IL_LAST_CCK_RATE)) + if (rate_idx >= IL_FIRST_CCK_RATE && rate_idx <= IL_LAST_CCK_RATE) rate_flags |= RATE_MCS_CCK_MSK; /* Set up antennas */ @@ -535,8 +535,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) if (sta_priv && sta_priv->client && !is_agg) atomic_inc(&sta_priv->pending_frames); - if ((il_queue_space(q) < q->high_mark) && - il->mac80211_registered) { + if (il_queue_space(q) < q->high_mark && il->mac80211_registered) { if (wait_write_ptr) { spin_lock_irqsave(&il->lock, flags); txq->need_update = 1; @@ -1050,8 +1049,8 @@ int il4965_txq_check_empty(struct il_priv *il, case IL_EMPTYING_HW_QUEUE_DELBA: /* We are reclaiming the last packet of the */ /* aggregated HW queue */ - if ((txq_id == tid_data->agg.txq_id) && - (q->read_ptr == q->write_ptr)) { + if (txq_id == tid_data->agg.txq_id && + q->read_ptr == q->write_ptr) { u16 ssn = SEQ_TO_SN(tid_data->seq_number); int tx_fifo = il4965_get_fifo_from_tid(ctx, tid); D_HT( @@ -1114,7 +1113,7 @@ int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int index) int nfreed = 0; struct ieee80211_hdr *hdr; - if ((index >= q->n_bd) || (il_queue_used(q, index) == 0)) { + if (index >= q->n_bd || il_queue_used(q, index) == 0) { IL_ERR("Read index for DMA queue txq id (%d), index %d, " "is out of range [0-%d] %d %d.\n", txq_id, index, q->n_bd, q->write_ptr, q->read_ptr); @@ -1321,9 +1320,9 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, int freed = il4965_tx_queue_reclaim(il, scd_flow, index); il4965_free_tfds_in_queue(il, sta_id, tid, freed); - if ((il_queue_space(&txq->q) > txq->q.low_mark) && + if (il_queue_space(&txq->q) > txq->q.low_mark && il->mac80211_registered && - (agg->state != IL_EMPTYING_HW_QUEUE_DELBA)) + agg->state != IL_EMPTYING_HW_QUEUE_DELBA) il_wake_queue(il, txq); il4965_txq_check_empty(il, sta_id, tid, scd_flow); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index a7450323a668..3706e47ce274 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -284,8 +284,8 @@ static bool iw4965_is_ht40_channel(__le32 rxon_flags) { int chan_mod = le32_to_cpu(rxon_flags & RXON_FLG_CHANNEL_MODE_MSK) >> RXON_FLG_CHANNEL_MODE_POS; - return ((chan_mod == CHANNEL_MODE_PURE_40) || - (chan_mod == CHANNEL_MODE_MIXED)); + return (chan_mod == CHANNEL_MODE_PURE_40 || + chan_mod == CHANNEL_MODE_MIXED); } static void il4965_nic_config(struct il_priv *il) @@ -323,7 +323,7 @@ static void il4965_chain_noise_reset(struct il_priv *il) { struct il_chain_noise_data *data = &(il->chain_noise_data); - if ((data->state == IL_CHAIN_NOISE_ALIVE) && + if (data->state == IL_CHAIN_NOISE_ALIVE && il_is_any_associated(il)) { struct il_calib_diff_gain_cmd cmd; @@ -458,8 +458,8 @@ static s32 il4965_get_voltage_compensation(s32 eeprom_voltage, { s32 comp = 0; - if ((TX_POWER_IL_ILLEGAL_VOLTAGE == eeprom_voltage) || - (TX_POWER_IL_ILLEGAL_VOLTAGE == current_voltage)) + if (TX_POWER_IL_ILLEGAL_VOLTAGE == eeprom_voltage || + TX_POWER_IL_ILLEGAL_VOLTAGE == current_voltage) return 0; il4965_math_div_round(current_voltage - eeprom_voltage, @@ -506,8 +506,8 @@ static u32 il4965_get_sub_band(const struct il_priv *il, u32 channel) if (il->calib_info->band_info[b].ch_from == 0) continue; - if ((channel >= il->calib_info->band_info[b].ch_from) - && (channel <= il->calib_info->band_info[b].ch_to)) + if (channel >= il->calib_info->band_info[b].ch_from && + channel <= il->calib_info->band_info[b].ch_to) break; } @@ -1158,15 +1158,15 @@ static int il4965_send_rxon_assoc(struct il_priv *il, const struct il_rxon_cmd *rxon1 = &ctx->staging; const struct il_rxon_cmd *rxon2 = &ctx->active; - if ((rxon1->flags == rxon2->flags) && - (rxon1->filter_flags == rxon2->filter_flags) && - (rxon1->cck_basic_rates == rxon2->cck_basic_rates) && - (rxon1->ofdm_ht_single_stream_basic_rates == - rxon2->ofdm_ht_single_stream_basic_rates) && - (rxon1->ofdm_ht_dual_stream_basic_rates == - rxon2->ofdm_ht_dual_stream_basic_rates) && - (rxon1->rx_chain == rxon2->rx_chain) && - (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { + if (rxon1->flags == rxon2->flags && + rxon1->filter_flags == rxon2->filter_flags && + rxon1->cck_basic_rates == rxon2->cck_basic_rates && + rxon1->ofdm_ht_single_stream_basic_rates == + rxon2->ofdm_ht_single_stream_basic_rates && + rxon1->ofdm_ht_dual_stream_basic_rates == + rxon2->ofdm_ht_dual_stream_basic_rates && + rxon1->rx_chain == rxon2->rx_chain && + rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates) { D_INFO("Using current RXON_ASSOC. Not resending.\n"); return 0; } @@ -1216,7 +1216,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) * abort any previous channel switch if still in process */ if (test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status) && - (il->switch_channel != ctx->staging.channel)) { + il->switch_channel != ctx->staging.channel) { D_11H("abort channel switch on %d\n", le16_to_cpu(il->switch_channel)); il_chswitch_done(il, false); @@ -1366,7 +1366,7 @@ static int il4965_hw_channel_switch(struct il_priv *il, * calculate the ucode channel switch time * adding TSF as one of the factor for when to switch */ - if ((il->ucode_beacon_time > tsf_low) && beacon_interval) { + if (il->ucode_beacon_time > tsf_low && beacon_interval) { if (switch_count > ((il->ucode_beacon_time - tsf_low) / beacon_interval)) { switch_count -= (il->ucode_beacon_time - @@ -1789,7 +1789,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, u8 *qc = NULL; unsigned long flags; - if ((index >= txq->q.n_bd) || (il_queue_used(&txq->q, index) == 0)) { + if (index >= txq->q.n_bd || il_queue_used(&txq->q, index) == 0) { IL_ERR("Read index for DMA queue txq_id (%d) index %d " "is out of range [0-%d] %d %d\n", txq_id, index, txq->q.n_bd, txq->q.write_ptr, @@ -1838,8 +1838,8 @@ static void il4965_rx_reply_tx(struct il_priv *il, tid, freed); if (il->mac80211_registered && - (il_queue_space(&txq->q) > txq->q.low_mark) - && (agg->state != IL_EMPTYING_HW_QUEUE_DELBA)) + il_queue_space(&txq->q) > txq->q.low_mark && + agg->state != IL_EMPTYING_HW_QUEUE_DELBA) il_wake_queue(il, txq); } } else { @@ -1863,7 +1863,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, D_TX_REPLY("Station not known\n"); if (il->mac80211_registered && - (il_queue_space(&txq->q) > txq->q.low_mark)) + il_queue_space(&txq->q) > txq->q.low_mark) il_wake_queue(il, txq); } if (qc && likely(sta_id != IL_INVALID_STATION)) diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.h b/drivers/net/wireless/iwlegacy/iwl-4965.h index ea2a98e3a4a2..56bfdb016040 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965.h @@ -163,8 +163,8 @@ static inline u32 il4965_tx_status_to_mac80211(u32 status) static inline bool il4965_is_tx_success(u32 status) { status &= TX_STATUS_MSK; - return (status == TX_STATUS_SUCCESS) || - (status == TX_STATUS_DIRECT_DONE); + return (status == TX_STATUS_SUCCESS || + status == TX_STATUS_DIRECT_DONE); } u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant_idx, u8 valid); diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index ed4415988e97..acbd5a899565 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -251,8 +251,8 @@ int il_init_geos(struct il_priv *il) il->tx_power_user_lmt = max_tx_power; il->tx_power_next = max_tx_power; - if ((il->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && - il->cfg->sku & IL_SKU_A) { + if (il->bands[IEEE80211_BAND_5GHZ].n_channels == 0 && + (il->cfg->sku & IL_SKU_A)) { IL_INFO("Incorrectly detected BG card as ABG. " "Please send your PCI ID 0x%04X:0x%04X to maintainer.\n", il->pci_dev->device, @@ -708,8 +708,7 @@ il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch, enum ieee80211_band band = ch->band; u16 channel = ch->hw_value; - if ((le16_to_cpu(ctx->staging.channel) == channel) && - (il->band == band)) + if (le16_to_cpu(ctx->staging.channel) == channel && il->band == band) return 0; ctx->staging.channel = cpu_to_le16(channel); @@ -2306,8 +2305,8 @@ static void il_ht_conf(struct il_priv *il, >> IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT; maxstreams += 1; - if ((ht_cap->mcs.rx_mask[1] == 0) && - (ht_cap->mcs.rx_mask[2] == 0)) + if (ht_cap->mcs.rx_mask[1] == 0 && + ht_cap->mcs.rx_mask[2] == 0) ht_conf->single_chain_sufficient = true; if (maxstreams <= 1) ht_conf->single_chain_sufficient = true; @@ -2467,7 +2466,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, * mac80211 decides to do both changes at once because * it will invoke post_associate. */ - if (vif->type == NL80211_IFTYPE_ADHOC && changes & BSS_CHANGED_BEACON) + if (vif->type == NL80211_IFTYPE_ADHOC && (changes & BSS_CHANGED_BEACON)) il_beacon_update(hw, vif); if (changes & BSS_CHANGED_ERP_PREAMBLE) { @@ -2482,8 +2481,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, if (changes & BSS_CHANGED_ERP_CTS_PROT) { D_MAC80211( "ERP_CTS %d\n", bss_conf->use_cts_prot); - if (bss_conf->use_cts_prot && - (il->band != IEEE80211_BAND_5GHZ)) + if (bss_conf->use_cts_prot && il->band != IEEE80211_BAND_5GHZ) ctx->staging.flags |= RXON_FLG_TGG_PROTECT_MSK; else ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK; @@ -2596,7 +2594,7 @@ irqreturn_t il_isr(int irq, void *data) goto none; } - if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) { + if (inta == 0xFFFFFFFF || (inta & 0xFFFFFFF0) == 0xa5a5a5a0) { /* Hardware disappeared. It might have already raised * an interrupt */ IL_WARN("HARDWARE GONE?? INTA == 0x%08x\n", inta); diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h index 8cb924d1e264..9d33da82a79f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ b/drivers/net/wireless/iwlegacy/iwl-io.h @@ -176,7 +176,7 @@ static inline void il_write_reg_buf(struct il_priv *il, { u32 count = sizeof(u32); - if ((il != NULL) && (values != NULL)) { + if (il != NULL && values != NULL) { for (; 0 < len; len -= count, reg += count, values++) il_wr(il, reg, *values); } diff --git a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h index 744829a66284..5da7d415170c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h +++ b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h @@ -279,7 +279,7 @@ enum il_table_type { LQ_MAX, }; -#define is_legacy(tbl) (((tbl) == LQ_G) || ((tbl) == LQ_A)) +#define is_legacy(tbl) ((tbl) == LQ_G || (tbl) == LQ_A) #define is_siso(tbl) ((tbl) == LQ_SISO) #define is_mimo2(tbl) ((tbl) == LQ_MIMO2) #define is_mimo(tbl) (is_mimo2(tbl)) diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index 36871041cec0..e352a185a96e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -307,7 +307,7 @@ u16 il_get_passive_dwell_time(struct il_priv *il, if (!il_is_associated_ctx(ctx)) continue; value = ctx->vif ? ctx->vif->bss_conf.beacon_int : 0; - if ((value > IL_PASSIVE_DWELL_BASE) || !value) + if (value > IL_PASSIVE_DWELL_BASE || !value) value = IL_PASSIVE_DWELL_BASE; value = (value * 98) / 100 - IL_CHANNEL_TUNE_TIME * 2; passive = min(value, passive); diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.c b/drivers/net/wireless/iwlegacy/iwl-sta.c index 42033d2ef6d4..cca467c26c0d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-sta.c @@ -595,7 +595,7 @@ il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) if (ctx->ctxid != il->stations[i].ctxid) continue; if ((il->stations[i].used & IL_STA_DRIVER_ACTIVE) && - !(il->stations[i].used & IL_STA_UCODE_ACTIVE)) { + !(il->stations[i].used & IL_STA_UCODE_ACTIVE)) { D_ASSOC("Restoring sta %pM\n", il->stations[i].sta.sta.addr); il->stations[i].sta.mode = 0; diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index fa23c983ef91..0d3515d21bfc 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -565,7 +565,7 @@ static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, struct il_queue *q = &txq->q; int nfreed = 0; - if ((idx >= q->n_bd) || (il_queue_used(q, idx) == 0)) { + if (idx >= q->n_bd || il_queue_used(q, idx) == 0) { IL_ERR("Read index for DMA queue txq id (%d), index %d, " "is out of range [0-%d] %d %d.\n", txq_id, idx, q->n_bd, q->write_ptr, q->read_ptr); diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 5037216041ca..ec9a93c9cb8f 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -646,7 +646,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) il_txq_update_write_ptr(il, txq); spin_unlock_irqrestore(&il->lock, flags); - if ((il_queue_space(q) < q->high_mark) + if (il_queue_space(q) < q->high_mark && il->mac80211_registered) { if (wait_write_ptr) { spin_lock_irqsave(&il->lock, flags); @@ -974,7 +974,7 @@ static void il3945_rx_queue_restock(struct il_priv *il) spin_lock_irqsave(&rxq->lock, flags); write = rxq->write & ~0x7; - while ((il_rx_queue_space(rxq) > 0) && (rxq->free_count)) { + while (il_rx_queue_space(rxq) > 0 && rxq->free_count) { /* Get next free Rx buffer, remove from free list */ element = rxq->rx_free.next; rxb = list_entry(element, struct il_rx_mem_buffer, list); @@ -995,8 +995,8 @@ static void il3945_rx_queue_restock(struct il_priv *il) /* If we've added more space for the firmware to place data, tell it. * Increment device's write pointer in multiples of 8. */ - if ((rxq->write_actual != (rxq->write & ~0x7)) - || (abs(rxq->write - rxq->read) > 7)) { + if (rxq->write_actual != (rxq->write & ~0x7) || + abs(rxq->write - rxq->read) > 7) { spin_lock_irqsave(&rxq->lock, flags); rxq->need_update = 1; spin_unlock_irqrestore(&rxq->lock, flags); @@ -1041,7 +1041,7 @@ static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) if (!page) { if (net_ratelimit()) D_INFO("Failed to allocate SKB buffer.\n"); - if ((rxq->free_count <= RX_LOW_WATERMARK) && + if (rxq->free_count <= RX_LOW_WATERMARK && net_ratelimit()) IL_ERR("Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", priority == GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL", @@ -1254,8 +1254,8 @@ static void il3945_rx_handle(struct il_priv *il) * Ucode should set SEQ_RX_FRAME bit if ucode-originated, * but apparently a few don't get set; catch them here. */ reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) && - (pkt->hdr.cmd != STATISTICS_NOTIFICATION) && - (pkt->hdr.cmd != REPLY_TX); + pkt->hdr.cmd != STATISTICS_NOTIFICATION && + pkt->hdr.cmd != REPLY_TX; /* Based on type of command response or notification, * handle those that need handling via function in @@ -1659,7 +1659,7 @@ static void il3945_init_hw_rates(struct il_priv *il, rates[i].hw_value = i; /* Rate scaling will work on indexes */ rates[i].hw_value_short = i; rates[i].flags = 0; - if ((i > IWL39_LAST_OFDM_RATE) || (i < IL_FIRST_OFDM_RATE)) { + if (i > IWL39_LAST_OFDM_RATE || i < IL_FIRST_OFDM_RATE) { /* * If CCK != 1M then set short preamble rate flag. */ @@ -3294,7 +3294,7 @@ static ssize_t il3945_show_measurement(struct device *d, il->measurement_status = 0; spin_unlock_irqrestore(&il->lock, flags); - while (size && (PAGE_SIZE - len)) { + while (size && PAGE_SIZE - len) { hex_dump_to_buffer(data + ofs, size, 16, 1, buf + len, PAGE_SIZE - len, 1); len = strlen(buf); @@ -3406,7 +3406,7 @@ static ssize_t il3945_store_antenna(struct device *d, return count; } - if ((ant >= 0) && (ant <= 2)) { + if (ant >= 0 && ant <= 2) { D_INFO("Setting antenna select to %d.\n", ant); il3945_mod_params.antenna = (enum il3945_antenna)ant; } else -- cgit v1.2.3 From d31751679897441d89e6ae59da98f1424b3f7dfe Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 11:25:42 +0100 Subject: iwlegacy: rename remaining IWLs to ILs Also rename config names IWLWIFI_LEGACY to IWLEGACY Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/Makefile | 2 +- drivers/net/wireless/iwlegacy/Kconfig | 26 ++++----- drivers/net/wireless/iwlegacy/Makefile | 8 +-- drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h | 2 +- drivers/net/wireless/iwlegacy/iwl-3945-hw.h | 34 ++++++------ drivers/net/wireless/iwlegacy/iwl-3945-rs.c | 2 +- drivers/net/wireless/iwlegacy/iwl-3945.c | 52 ++++++++--------- drivers/net/wireless/iwlegacy/iwl-3945.h | 10 ++-- drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h | 2 +- drivers/net/wireless/iwlegacy/iwl-4965-hw.h | 46 +++++++-------- drivers/net/wireless/iwlegacy/iwl-4965-lib.c | 14 ++--- drivers/net/wireless/iwlegacy/iwl-4965-rs.c | 4 +- drivers/net/wireless/iwlegacy/iwl-4965-rx.c | 6 +- drivers/net/wireless/iwlegacy/iwl-4965-tx.c | 58 +++++++++---------- drivers/net/wireless/iwlegacy/iwl-4965-ucode.c | 4 +- drivers/net/wireless/iwlegacy/iwl-4965.c | 42 +++++++------- drivers/net/wireless/iwlegacy/iwl-4965.h | 2 +- drivers/net/wireless/iwlegacy/iwl-commands.h | 24 ++++---- drivers/net/wireless/iwlegacy/iwl-core.c | 14 ++--- drivers/net/wireless/iwlegacy/iwl-core.h | 4 +- drivers/net/wireless/iwlegacy/iwl-debug.h | 10 ++-- drivers/net/wireless/iwlegacy/iwl-debugfs.c | 2 +- drivers/net/wireless/iwlegacy/iwl-dev.h | 26 ++++----- drivers/net/wireless/iwlegacy/iwl-hcmd.c | 2 +- drivers/net/wireless/iwlegacy/iwl-legacy-rs.h | 2 +- drivers/net/wireless/iwlegacy/iwl-prph.h | 58 +++++++++---------- drivers/net/wireless/iwlegacy/iwl-scan.c | 6 +- drivers/net/wireless/iwlegacy/iwl-sta.c | 2 +- drivers/net/wireless/iwlegacy/iwl-tx.c | 2 +- drivers/net/wireless/iwlegacy/iwl3945-base.c | 64 ++++++++++----------- drivers/net/wireless/iwlegacy/iwl4965-base.c | 71 ++++++++++++------------ 31 files changed, 299 insertions(+), 302 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/Makefile b/drivers/net/wireless/Makefile index c1c0678b1fb6..98db76196b59 100644 --- a/drivers/net/wireless/Makefile +++ b/drivers/net/wireless/Makefile @@ -42,7 +42,7 @@ obj-$(CONFIG_ADM8211) += adm8211.o obj-$(CONFIG_MWL8K) += mwl8k.o obj-$(CONFIG_IWLWIFI) += iwlwifi/ -obj-$(CONFIG_IWLWIFI_LEGACY) += iwlegacy/ +obj-$(CONFIG_IWLEGACY) += iwlegacy/ obj-$(CONFIG_RT2X00) += rt2x00/ obj-$(CONFIG_P54_COMMON) += p54/ diff --git a/drivers/net/wireless/iwlegacy/Kconfig b/drivers/net/wireless/iwlegacy/Kconfig index 2a1ae109ff25..b4be3b44f0a0 100644 --- a/drivers/net/wireless/iwlegacy/Kconfig +++ b/drivers/net/wireless/iwlegacy/Kconfig @@ -1,4 +1,4 @@ -config IWLWIFI_LEGACY +config IWLEGACY tristate select FW_LOADER select NEW_LEDS @@ -7,13 +7,13 @@ config IWLWIFI_LEGACY select MAC80211_LEDS menu "Debugging Options" - depends on IWLWIFI_LEGACY + depends on IWLEGACY -config IWLWIFI_LEGACY_DEBUG - bool "Enable full debugging output in 4965 and 3945 drivers" - depends on IWLWIFI_LEGACY +config IWLEGACY_DEBUG + bool "Enable full debugging output in iwlegacy (iwl 3945/4965) drivers" + depends on IWLEGACY ---help--- - This option will enable debug tracing output for the iwlwifilegacy + This option will enable debug tracing output for the iwlegacy drivers. This will result in the kernel module being ~100k larger. You can @@ -29,17 +29,17 @@ config IWLWIFI_LEGACY_DEBUG % echo 0x43fff > /sys/class/net/wlan0/device/debug_level You can find the list of debug mask values in: - drivers/net/wireless/iwlwifilegacy/iwl-debug.h + drivers/net/wireless/iwlegacy/iwl-debug.h If this is your first time using this driver, you should say Y here as the debug information can assist others in helping you resolve any problems you may encounter. -config IWLWIFI_LEGACY_DEBUGFS - bool "4965 and 3945 debugfs support" - depends on IWLWIFI_LEGACY && MAC80211_DEBUGFS +config IWLEGACY_DEBUGFS + bool "iwlegacy (iwl 3945/4965) debugfs support" + depends on IWLEGACY && MAC80211_DEBUGFS ---help--- - Enable creation of debugfs files for the iwlwifilegacy drivers. This + Enable creation of debugfs files for the iwlegacy drivers. This is a low-impact option that allows getting insight into the driver's state at runtime. @@ -48,7 +48,7 @@ endmenu config IWL4965 tristate "Intel Wireless WiFi 4965AGN (iwl4965)" depends on PCI && MAC80211 - select IWLWIFI_LEGACY + select IWLEGACY ---help--- This option enables support for @@ -76,7 +76,7 @@ config IWL4965 config IWL3945 tristate "Intel PRO/Wireless 3945ABG/BG Network Connection (iwl3945)" depends on PCI && MAC80211 - select IWLWIFI_LEGACY + select IWLEGACY ---help--- Select to build the driver supporting the: diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index 4f67e45f22c0..49c4b36383cd 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -1,8 +1,8 @@ -obj-$(CONFIG_IWLWIFI_LEGACY) += iwl-legacy.o +obj-$(CONFIG_IWLEGACY) += iwl-legacy.o iwl-legacy-objs := iwl-core.o iwl-eeprom.o iwl-hcmd.o iwl-power.o iwl-legacy-objs += iwl-rx.o iwl-tx.o iwl-sta.o iwl-legacy-objs += iwl-scan.o iwl-led.o -iwl-legacy-$(CONFIG_IWLWIFI_LEGACY_DEBUGFS) += iwl-debugfs.o +iwl-legacy-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-debugfs.o iwl-legacy-objs += $(iwl-legacy-m) @@ -12,11 +12,11 @@ iwl4965-objs := iwl-4965.o iwl4965-base.o iwl-4965-rs.o iwl-4965-led.o iwl4965-objs += iwl-4965-ucode.o iwl-4965-tx.o iwl4965-objs += iwl-4965-lib.o iwl-4965-rx.o iwl-4965-calib.o iwl4965-objs += iwl-4965-sta.o iwl-4965-eeprom.o -iwl4965-$(CONFIG_IWLWIFI_LEGACY_DEBUGFS) += iwl-4965-debugfs.o +iwl4965-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-4965-debugfs.o # 3945 obj-$(CONFIG_IWL3945) += iwl3945.o iwl3945-objs := iwl3945-base.o iwl-3945.o iwl-3945-rs.o iwl-3945-led.o -iwl3945-$(CONFIG_IWLWIFI_LEGACY_DEBUGFS) += iwl-3945-debugfs.o +iwl3945-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-3945-debugfs.o ccflags-y += -D__CHECK_ENDIAN__ diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h index 54334ac02788..9d1a4a041b18 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h @@ -30,7 +30,7 @@ #include "iwl-core.h" #include "iwl-debug.h" -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS ssize_t il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos); ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-hw.h b/drivers/net/wireless/iwlegacy/iwl-3945-hw.h index 67650ffa2d58..fcb466a2f065 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-hw.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945-hw.h @@ -72,7 +72,7 @@ #include "iwl-eeprom.h" /* RSSI to dBm */ -#define IWL39_RSSI_OFFSET 95 +#define IL39_RSSI_OFFSET 95 /* * EEPROM related constants, enums, and structures. @@ -214,7 +214,7 @@ struct il3945_eeprom { u8 reserved16[172]; /* fill out to full 1024 byte block */ } __packed; -#define IWL3945_EEPROM_IMG_SIZE 1024 +#define IL3945_EEPROM_IMG_SIZE 1024 /* End of EEPROM */ @@ -222,8 +222,8 @@ struct il3945_eeprom { #define PCI_CFG_REV_ID_BIT_RTP (0x80) /* bit 7 */ /* 4 DATA + 1 CMD. There are 2 HCCA queues that are not used. */ -#define IWL39_NUM_QUEUES 5 -#define IWL39_CMD_QUEUE_NUM 4 +#define IL39_NUM_QUEUES 5 +#define IL39_CMD_QUEUE_NUM 4 #define IL_DEFAULT_TX_RETRY 15 @@ -245,27 +245,27 @@ struct il3945_eeprom { /* Sizes and addresses for instruction and data memory (SRAM) in * 3945's embedded processor. Driver access is via HBUS_TARG_MEM_* regs. */ -#define IWL39_RTC_INST_LOWER_BOUND (0x000000) -#define IWL39_RTC_INST_UPPER_BOUND (0x014000) +#define IL39_RTC_INST_LOWER_BOUND (0x000000) +#define IL39_RTC_INST_UPPER_BOUND (0x014000) -#define IWL39_RTC_DATA_LOWER_BOUND (0x800000) -#define IWL39_RTC_DATA_UPPER_BOUND (0x808000) +#define IL39_RTC_DATA_LOWER_BOUND (0x800000) +#define IL39_RTC_DATA_UPPER_BOUND (0x808000) -#define IWL39_RTC_INST_SIZE (IWL39_RTC_INST_UPPER_BOUND - \ - IWL39_RTC_INST_LOWER_BOUND) -#define IWL39_RTC_DATA_SIZE (IWL39_RTC_DATA_UPPER_BOUND - \ - IWL39_RTC_DATA_LOWER_BOUND) +#define IL39_RTC_INST_SIZE (IL39_RTC_INST_UPPER_BOUND - \ + IL39_RTC_INST_LOWER_BOUND) +#define IL39_RTC_DATA_SIZE (IL39_RTC_DATA_UPPER_BOUND - \ + IL39_RTC_DATA_LOWER_BOUND) -#define IWL39_MAX_INST_SIZE IWL39_RTC_INST_SIZE -#define IWL39_MAX_DATA_SIZE IWL39_RTC_DATA_SIZE +#define IL39_MAX_INST_SIZE IL39_RTC_INST_SIZE +#define IL39_MAX_DATA_SIZE IL39_RTC_DATA_SIZE /* Size of uCode instruction memory in bootstrap state machine */ -#define IWL39_MAX_BSM_SIZE IWL39_RTC_INST_SIZE +#define IL39_MAX_BSM_SIZE IL39_RTC_INST_SIZE static inline int il3945_hw_valid_rtc_data_addr(u32 addr) { - return (addr >= IWL39_RTC_DATA_LOWER_BOUND && - addr < IWL39_RTC_DATA_UPPER_BOUND); + return (addr >= IL39_RTC_DATA_LOWER_BOUND && + addr < IL39_RTC_DATA_UPPER_BOUND); } /* Base physical address of il3945_shared is provided to FH_TSSR_CBB_BASE diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c index afa6be81f9a5..345beb7d3e83 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c @@ -90,7 +90,7 @@ static struct il3945_tpt_entry il3945_tpt_table_g[] = { #define IL_RATE_MAX_WINDOW 62 #define IL_RATE_FLUSH (3*HZ) #define IL_RATE_WIN_FLUSH (HZ/2) -#define IWL39_RATE_HIGH_TH 11520 +#define IL39_RATE_HIGH_TH 11520 #define IL_SUCCESS_UP_TH 8960 #define IL_SUCCESS_DOWN_TH 10880 #define IL_RATE_MIN_FAILURE_TH 6 diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index fb69b745f8a7..78e81b632280 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -200,7 +200,7 @@ static int il3945_hwrate_to_plcp_idx(u8 plcp) return -1; } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG #define TX_STATUS_ENTRY(x) case TX_3945_STATUS_FAIL_ ## x: return #x static const char *il3945_get_tx_fail_reason(u32 status) @@ -281,7 +281,7 @@ static void il3945_tx_queue_reclaim(struct il_priv *il, struct il_queue *q = &txq->q; struct il_tx_info *tx_info; - BUG_ON(txq_id == IWL39_CMD_QUEUE_NUM); + BUG_ON(txq_id == IL39_CMD_QUEUE_NUM); for (index = il_queue_inc_wrap(index, q->n_bd); q->read_ptr != index; @@ -294,7 +294,7 @@ static void il3945_tx_queue_reclaim(struct il_priv *il, } if (il_queue_space(q) > q->low_mark && txq_id >= 0 && - txq_id != IWL39_CMD_QUEUE_NUM && il->mac80211_registered) + txq_id != IL39_CMD_QUEUE_NUM && il->mac80211_registered) il_wake_queue(il, txq); } @@ -361,7 +361,7 @@ static void il3945_rx_reply_tx(struct il_priv *il, * RX handler implementations * *****************************************************************************/ -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS static void il3945_accumulative_statistics(struct il_priv *il, __le32 *stats) { @@ -403,7 +403,7 @@ void il3945_hw_rx_statistics(struct il_priv *il, D_RX("Statistics notification received (%d vs %d).\n", (int)sizeof(struct il3945_notif_statistics), le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS il3945_accumulative_statistics(il, (__le32 *)&pkt->u.raw); #endif @@ -417,7 +417,7 @@ void il3945_reply_statistics(struct il_priv *il, __le32 *flag = (__le32 *)&pkt->u.raw; if (le32_to_cpu(*flag) & UCODE_STATISTICS_CLEAR_MSK) { -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS memset(&il->_3945.accum_statistics, 0, sizeof(struct il3945_notif_statistics)); memset(&il->_3945.delta_statistics, 0, @@ -468,7 +468,7 @@ static void il3945_pass_packet_to_mac80211(struct il_priv *il, __le16 fc = hdr->frame_control; /* We received data from the HW, so stop the watchdog */ - if (unlikely(len + IWL39_RX_FRAME_SIZE > + if (unlikely(len + IL39_RX_FRAME_SIZE > PAGE_SIZE << il->hw_params.rx_page_order)) { D_DROP("Corruption detected!\n"); return; @@ -552,7 +552,7 @@ static void il3945_rx_reply_rx(struct il_priv *il, /* Convert 3945's rssi indicator to dBm */ - rx_status.signal = rx_stats->rssi - IWL39_RSSI_OFFSET; + rx_status.signal = rx_stats->rssi - IL39_RSSI_OFFSET; D_STATS("Rssi %d sig_avg %d noise_diff %d\n", rx_status.signal, rx_stats_sig_avg, @@ -698,7 +698,7 @@ void il3945_hw_build_tx_cmd_rate(struct il_priv *il, data_retry_limit = IL_DEFAULT_TX_RETRY; tx_cmd->data_retry_limit = data_retry_limit; - if (tx_id >= IWL39_CMD_QUEUE_NUM) + if (tx_id >= IL39_CMD_QUEUE_NUM) rts_retry_limit = 3; else rts_retry_limit = 7; @@ -849,7 +849,7 @@ static int il3945_txq_ctx_reset(struct il_priv *il) /* Tx queue(s) */ for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { - slots_num = (txq_id == IWL39_CMD_QUEUE_NUM) ? + slots_num = (txq_id == IL39_CMD_QUEUE_NUM) ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; rc = il_tx_queue_init(il, &il->txq[txq_id], slots_num, txq_id); @@ -1010,7 +1010,7 @@ void il3945_hw_txq_ctx_free(struct il_priv *il) if (il->txq) for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) - if (txq_id == IWL39_CMD_QUEUE_NUM) + if (txq_id == IL39_CMD_QUEUE_NUM) il_cmd_queue_free(il); else il_tx_queue_free(il, txq_id); @@ -1402,7 +1402,7 @@ static int il3945_send_tx_power(struct il_priv *il) /* fill cmd with power settings for all rates for current channel */ /* Fill OFDM rate */ for (rate_idx = IL_FIRST_OFDM_RATE, i = 0; - rate_idx <= IWL39_LAST_OFDM_RATE; rate_idx++, i++) { + rate_idx <= IL39_LAST_OFDM_RATE; rate_idx++, i++) { txpower.power[i].tpc = ch_info->power_info[i].tpc; txpower.power[i].rate = il3945_rates[rate_idx].plcp; @@ -2400,14 +2400,14 @@ int il3945_hw_set_hw_params(struct il_priv *il) il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_3K); il->hw_params.max_rxq_size = RX_QUEUE_SIZE; il->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; - il->hw_params.max_stations = IWL3945_STATION_COUNT; - il->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IWL3945_BROADCAST_ID; + il->hw_params.max_stations = IL3945_STATION_COUNT; + il->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IL3945_BROADCAST_ID; il->sta_key_max_num = STA_KEY_MAX_NUM; il->hw_params.rx_wrt_ptr_reg = FH39_RSCSR_CHNL0_WPTR; - il->hw_params.max_beacon_itrvl = IWL39_MAX_UCODE_BEACON_INTERVAL; - il->hw_params.beacon_time_tsf_bits = IWL3945_EXT_BEACON_TIME_POS; + il->hw_params.max_beacon_itrvl = IL39_MAX_UCODE_BEACON_INTERVAL; + il->hw_params.beacon_time_tsf_bits = IL3945_EXT_BEACON_TIME_POS; return 0; } @@ -2569,7 +2569,7 @@ static int il3945_load_bsm(struct il_priv *il) D_INFO("Begin load bsm\n"); /* make sure bootstrap program is no larger than BSM's SRAM size */ - if (len > IWL39_MAX_BSM_SIZE) + if (len > IL39_MAX_BSM_SIZE) return -EINVAL; /* Tell bootstrap uCode where to find the "Initialize" uCode @@ -2601,7 +2601,7 @@ static int il3945_load_bsm(struct il_priv *il) /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ il_wr_prph(il, BSM_WR_MEM_SRC_REG, 0x0); il_wr_prph(il, BSM_WR_MEM_DST_REG, - IWL39_RTC_INST_LOWER_BOUND); + IL39_RTC_INST_LOWER_BOUND); il_wr_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); /* Load bootstrap code into instruction SRAM now, @@ -2692,8 +2692,8 @@ static const struct il_ops il3945_ops = { }; static struct il_base_params il3945_base_params = { - .eeprom_size = IWL3945_EEPROM_IMG_SIZE, - .num_of_queues = IWL39_NUM_QUEUES, + .eeprom_size = IL3945_EEPROM_IMG_SIZE, + .num_of_queues = IL39_NUM_QUEUES, .pll_cfg_val = CSR39_ANA_PLL_CFG_VAL, .set_l0s = false, .use_bsm = true, @@ -2703,9 +2703,9 @@ static struct il_base_params il3945_base_params = { static struct il_cfg il3945_bg_cfg = { .name = "3945BG", - .fw_name_pre = IWL3945_FW_PRE, - .ucode_api_max = IWL3945_UCODE_API_MAX, - .ucode_api_min = IWL3945_UCODE_API_MIN, + .fw_name_pre = IL3945_FW_PRE, + .ucode_api_max = IL3945_UCODE_API_MAX, + .ucode_api_min = IL3945_UCODE_API_MIN, .sku = IL_SKU_G, .eeprom_ver = EEPROM_3945_EEPROM_VERSION, .ops = &il3945_ops, @@ -2716,9 +2716,9 @@ static struct il_cfg il3945_bg_cfg = { static struct il_cfg il3945_abg_cfg = { .name = "3945ABG", - .fw_name_pre = IWL3945_FW_PRE, - .ucode_api_max = IWL3945_UCODE_API_MAX, - .ucode_api_min = IWL3945_UCODE_API_MIN, + .fw_name_pre = IL3945_FW_PRE, + .ucode_api_max = IL3945_UCODE_API_MAX, + .ucode_api_min = IL3945_UCODE_API_MIN, .sku = IL_SKU_A|IL_SKU_G, .eeprom_ver = EEPROM_3945_EEPROM_VERSION, .ops = &il3945_ops, diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.h b/drivers/net/wireless/iwlegacy/iwl-3945.h index abe778b1b424..6c68f597f32f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945.h @@ -49,14 +49,14 @@ extern const struct pci_device_id il3945_hw_card_ids[]; #include "iwl-led.h" /* Highest firmware API version supported */ -#define IWL3945_UCODE_API_MAX 2 +#define IL3945_UCODE_API_MAX 2 /* Lowest firmware API version supported */ -#define IWL3945_UCODE_API_MIN 1 +#define IL3945_UCODE_API_MIN 1 -#define IWL3945_FW_PRE "iwlwifi-3945-" -#define _IWL3945_MODULE_FIRMWARE(api) IWL3945_FW_PRE #api ".ucode" -#define IWL3945_MODULE_FIRMWARE(api) _IWL3945_MODULE_FIRMWARE(api) +#define IL3945_FW_PRE "iwlwifi-3945-" +#define _IL3945_MODULE_FIRMWARE(api) IL3945_FW_PRE #api ".ucode" +#define IL3945_MODULE_FIRMWARE(api) _IL3945_MODULE_FIRMWARE(api) /* Default noise level to report when noise measurement is not available. * This may be because we're: diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h index ca1cf586f07b..284604c49440 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h @@ -30,7 +30,7 @@ #include "iwl-core.h" #include "iwl-debug.h" -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos); ssize_t il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h index b21c0040c20a..ecebc6923125 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h @@ -72,38 +72,38 @@ #include "iwl-fh.h" /* EEPROM */ -#define IWL4965_EEPROM_IMG_SIZE 1024 +#define IL4965_EEPROM_IMG_SIZE 1024 /* * uCode queue management definitions ... * The first queue used for block-ack aggregation is #7 (4965 only). * All block-ack aggregation queues should map to Tx DMA/FIFO channel 7. */ -#define IWL49_FIRST_AMPDU_QUEUE 7 +#define IL49_FIRST_AMPDU_QUEUE 7 /* Sizes and addresses for instruction and data memory (SRAM) in * 4965's embedded processor. Driver access is via HBUS_TARG_MEM_* regs. */ -#define IWL49_RTC_INST_LOWER_BOUND (0x000000) -#define IWL49_RTC_INST_UPPER_BOUND (0x018000) +#define IL49_RTC_INST_LOWER_BOUND (0x000000) +#define IL49_RTC_INST_UPPER_BOUND (0x018000) -#define IWL49_RTC_DATA_LOWER_BOUND (0x800000) -#define IWL49_RTC_DATA_UPPER_BOUND (0x80A000) +#define IL49_RTC_DATA_LOWER_BOUND (0x800000) +#define IL49_RTC_DATA_UPPER_BOUND (0x80A000) -#define IWL49_RTC_INST_SIZE (IWL49_RTC_INST_UPPER_BOUND - \ - IWL49_RTC_INST_LOWER_BOUND) -#define IWL49_RTC_DATA_SIZE (IWL49_RTC_DATA_UPPER_BOUND - \ - IWL49_RTC_DATA_LOWER_BOUND) +#define IL49_RTC_INST_SIZE (IL49_RTC_INST_UPPER_BOUND - \ + IL49_RTC_INST_LOWER_BOUND) +#define IL49_RTC_DATA_SIZE (IL49_RTC_DATA_UPPER_BOUND - \ + IL49_RTC_DATA_LOWER_BOUND) -#define IWL49_MAX_INST_SIZE IWL49_RTC_INST_SIZE -#define IWL49_MAX_DATA_SIZE IWL49_RTC_DATA_SIZE +#define IL49_MAX_INST_SIZE IL49_RTC_INST_SIZE +#define IL49_MAX_DATA_SIZE IL49_RTC_DATA_SIZE /* Size of uCode instruction memory in bootstrap state machine */ -#define IWL49_MAX_BSM_SIZE BSM_SRAM_SIZE +#define IL49_MAX_BSM_SIZE BSM_SRAM_SIZE static inline int il4965_hw_valid_rtc_data_addr(u32 addr) { - return (addr >= IWL49_RTC_DATA_LOWER_BOUND && - addr < IWL49_RTC_DATA_UPPER_BOUND); + return (addr >= IL49_RTC_DATA_LOWER_BOUND && + addr < IL49_RTC_DATA_UPPER_BOUND); } /********************* START TEMPERATURE *************************************/ @@ -760,10 +760,10 @@ enum { * up to 7 DMA channels (FIFOs). Each Tx queue is supported by a circular array * in DRAM containing 256 Transmit Frame Descriptors (TFDs). */ -#define IWL49_NUM_FIFOS 7 -#define IWL49_CMD_FIFO_NUM 4 -#define IWL49_NUM_QUEUES 16 -#define IWL49_NUM_AMPDU_QUEUES 8 +#define IL49_NUM_FIFOS 7 +#define IL49_CMD_FIFO_NUM 4 +#define IL49_NUM_QUEUES 16 +#define IL49_NUM_AMPDU_QUEUES 8 /** @@ -790,10 +790,10 @@ struct il4965_scd_bc_tbl { } __packed; -#define IWL4965_RTC_INST_LOWER_BOUND (0x000000) +#define IL4965_RTC_INST_LOWER_BOUND (0x000000) /* RSSI to dBm */ -#define IWL4965_RSSI_OFFSET 44 +#define IL4965_RSSI_OFFSET 44 /* PCI registers */ #define PCI_CFG_RETRY_TIMEOUT 0x041 @@ -802,10 +802,10 @@ struct il4965_scd_bc_tbl { #define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01 #define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02 -#define IWL4965_DEFAULT_TX_RETRY 15 +#define IL4965_DEFAULT_TX_RETRY 15 /* EEPROM */ -#define IWL4965_FIRST_AMPDU_QUEUE 10 +#define IL4965_FIRST_AMPDU_QUEUE 10 #endif /* !__il_4965_hw_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index 8bb2b6280d72..964d9bb314b7 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -438,12 +438,12 @@ static int il4965_calc_rssi(struct il_priv *il, * contents are always there, not configurable by host. */ struct il4965_rx_non_cfg_phy *ncphy = (struct il4965_rx_non_cfg_phy *)rx_resp->non_cfg_phy_buf; - u32 agc = (le16_to_cpu(ncphy->agc_info) & IWL49_AGC_DB_MASK) - >> IWL49_AGC_DB_POS; + u32 agc = (le16_to_cpu(ncphy->agc_info) & IL49_AGC_DB_MASK) + >> IL49_AGC_DB_POS; u32 valid_antennae = - (le16_to_cpu(rx_resp->phy_flags) & IWL49_RX_PHY_FLAGS_ANTENNAE_MASK) - >> IWL49_RX_PHY_FLAGS_ANTENNAE_OFFSET; + (le16_to_cpu(rx_resp->phy_flags) & IL49_RX_PHY_FLAGS_ANTENNAE_MASK) + >> IL49_RX_PHY_FLAGS_ANTENNAE_OFFSET; u8 max_rssi = 0; u32 i; @@ -462,7 +462,7 @@ static int il4965_calc_rssi(struct il_priv *il, /* dBm = max_rssi dB - agc dB - constant. * Higher AGC (higher radio gain) means lower signal. */ - return max_rssi - agc - IWL4965_RSSI_OFFSET; + return max_rssi - agc - IL4965_RSSI_OFFSET; } @@ -1152,7 +1152,7 @@ static const char *il4965_get_fh_string(int cmd) int il4965_dump_fh(struct il_priv *il, char **buf, bool display) { int i; -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG int pos = 0; size_t bufsz = 0; #endif @@ -1167,7 +1167,7 @@ int il4965_dump_fh(struct il_priv *il, char **buf, bool display) FH_TSSR_TX_STATUS_REG, FH_TSSR_TX_ERROR_REG }; -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG if (display) { bufsz = ARRAY_SIZE(fh_tbl) * 48 + 40; *buf = kmalloc(bufsz, GFP_KERNEL); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index c2f42301014d..9c8cc320832e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -40,7 +40,7 @@ #include "iwl-core.h" #include "iwl-4965.h" -#define IWL4965_RS_NAME "iwl-4965-rs" +#define IL4965_RS_NAME "iwl-4965-rs" #define NUM_TRY_BEFORE_ANT_TOGGLE 1 #define IL_NUMBER_TRY 1 @@ -2837,7 +2837,7 @@ il4965_rs_rate_init_stub(void *il_r, struct ieee80211_supported_band *sband, } static struct rate_control_ops rs_4965_ops = { .module = NULL, - .name = IWL4965_RS_NAME, + .name = IL4965_RS_NAME, .tx_status = il4965_rs_tx_status, .get_rate = il4965_rs_get_rate, .rate_init = il4965_rs_rate_init_stub, diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c index 45e8a24c938d..2181ec071cd4 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c @@ -105,7 +105,7 @@ static void il4965_rx_calc_noise(struct il_priv *il) last_rx_noise); } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS /* * based on the assumption of all statistics counter are in DWORD * FIXME: This function is for debugging, do not deal with @@ -169,7 +169,7 @@ void il4965_rx_statistics(struct il_priv *il, STATISTICS_REPLY_FLG_HT40_MODE_MSK) != (pkt->u.stats.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK))); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS il4965_accumulative_statistics(il, (__le32 *)&pkt->u.stats); #endif @@ -201,7 +201,7 @@ void il4965_reply_statistics(struct il_priv *il, struct il_rx_packet *pkt = rxb_addr(rxb); if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATISTICS_CLEAR_MSK) { -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS memset(&il->_4965.accum_statistics, 0, sizeof(struct il_notif_statistics)); memset(&il->_4965.delta_statistics, 0, diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index a32a4f32b97d..5f6a4ba9cb1c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -171,7 +171,7 @@ static void il4965_tx_cmd_build_rate(struct il_priv *il, if (ieee80211_is_probe_resp(fc)) data_retry_limit = 3; else - data_retry_limit = IWL4965_DEFAULT_TX_RETRY; + data_retry_limit = IL4965_DEFAULT_TX_RETRY; tx_cmd->data_retry_limit = data_retry_limit; /* Set retry limit on RTS packets */ @@ -304,7 +304,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) fc = hdr->frame_control; -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG if (ieee80211_is_auth(fc)) D_TX("Sending AUTH frame\n"); else if (ieee80211_is_assoc_req(fc)) @@ -754,9 +754,9 @@ static void il4965_tx_queue_stop_scheduler(struct il_priv *il, /* Simply stop the queue, but don't change any configuration; * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */ il_wr_prph(il, - IWL49_SCD_QUEUE_STATUS_BITS(txq_id), - (0 << IWL49_SCD_QUEUE_STTS_REG_POS_ACTIVE)| - (1 << IWL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); + IL49_SCD_QUEUE_STATUS_BITS(txq_id), + (0 << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE)| + (1 << IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); } /** @@ -772,7 +772,7 @@ static int il4965_tx_queue_set_q2ratid(struct il_priv *il, u16 ra_tid, scd_q2ratid = ra_tid & IL_SCD_QUEUE_RA_TID_MAP_RATID_MSK; tbl_dw_addr = il->scd_base_addr + - IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id); + IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id); tbl_dw = il_read_targ_mem(il, tbl_dw_addr); @@ -789,7 +789,7 @@ static int il4965_tx_queue_set_q2ratid(struct il_priv *il, u16 ra_tid, /** * il4965_tx_queue_agg_enable - Set up & enable aggregation for selected queue * - * NOTE: txq_id must be greater than IWL49_FIRST_AMPDU_QUEUE, + * NOTE: txq_id must be greater than IL49_FIRST_AMPDU_QUEUE, * i.e. it must be one of the higher queues used for aggregation */ static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, @@ -799,13 +799,13 @@ static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, u16 ra_tid; int ret; - if ((IWL49_FIRST_AMPDU_QUEUE > txq_id) || - (IWL49_FIRST_AMPDU_QUEUE + + if ((IL49_FIRST_AMPDU_QUEUE > txq_id) || + (IL49_FIRST_AMPDU_QUEUE + il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { IL_WARN( "queue number out of range: %d, must be %d to %d\n", - txq_id, IWL49_FIRST_AMPDU_QUEUE, - IWL49_FIRST_AMPDU_QUEUE + + txq_id, IL49_FIRST_AMPDU_QUEUE, + IL49_FIRST_AMPDU_QUEUE + il->cfg->base_params->num_of_ampdu_queues - 1); return -EINVAL; } @@ -826,7 +826,7 @@ static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, il4965_tx_queue_set_q2ratid(il, ra_tid, txq_id); /* Set this queue as a chain-building queue */ - il_set_bits_prph(il, IWL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); + il_set_bits_prph(il, IL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); /* Place first TFD at index corresponding to start sequence number. * Assumes that ssn_idx is valid (!= 0xFFF) */ @@ -836,16 +836,16 @@ static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, /* Set up Tx window size and frame limit for this queue */ il_write_targ_mem(il, - il->scd_base_addr + IWL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id), - (SCD_WIN_SIZE << IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & - IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); + il->scd_base_addr + IL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id), + (SCD_WIN_SIZE << IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & + IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); il_write_targ_mem(il, il->scd_base_addr + - IWL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id) + sizeof(u32), - (SCD_FRAME_LIMIT << IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) - & IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); + IL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id) + sizeof(u32), + (SCD_FRAME_LIMIT << IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) + & IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); - il_set_bits_prph(il, IWL49_SCD_INTERRUPT_MASK, (1 << txq_id)); + il_set_bits_prph(il, IL49_SCD_INTERRUPT_MASK, (1 << txq_id)); /* Set up Status area in SRAM, map to Tx DMA/FIFO, activate the queue */ il4965_tx_queue_set_status(il, &il->txq[txq_id], tx_fifo, 1); @@ -922,19 +922,19 @@ int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, } /** - * txq_id must be greater than IWL49_FIRST_AMPDU_QUEUE + * txq_id must be greater than IL49_FIRST_AMPDU_QUEUE * il->lock must be held by the caller */ static int il4965_txq_agg_disable(struct il_priv *il, u16 txq_id, u16 ssn_idx, u8 tx_fifo) { - if ((IWL49_FIRST_AMPDU_QUEUE > txq_id) || - (IWL49_FIRST_AMPDU_QUEUE + + if ((IL49_FIRST_AMPDU_QUEUE > txq_id) || + (IL49_FIRST_AMPDU_QUEUE + il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { IL_WARN( "queue number out of range: %d, must be %d to %d\n", - txq_id, IWL49_FIRST_AMPDU_QUEUE, - IWL49_FIRST_AMPDU_QUEUE + + txq_id, IL49_FIRST_AMPDU_QUEUE, + IL49_FIRST_AMPDU_QUEUE + il->cfg->base_params->num_of_ampdu_queues - 1); return -EINVAL; } @@ -942,7 +942,7 @@ static int il4965_txq_agg_disable(struct il_priv *il, u16 txq_id, il4965_tx_queue_stop_scheduler(il, txq_id); il_clear_bits_prph(il, - IWL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); + IL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); il->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); il->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); @@ -950,7 +950,7 @@ static int il4965_txq_agg_disable(struct il_priv *il, u16 txq_id, il4965_set_wr_ptrs(il, txq_id, ssn_idx); il_clear_bits_prph(il, - IWL49_SCD_INTERRUPT_MASK, (1 << txq_id)); + IL49_SCD_INTERRUPT_MASK, (1 << txq_id)); il_txq_ctx_deactivate(il, txq_id); il4965_tx_queue_set_status(il, &il->txq[txq_id], tx_fifo, 0); @@ -1134,7 +1134,7 @@ int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int index) nfreed++; il4965_tx_status(il, tx_info, - txq_id >= IWL4965_FIRST_AMPDU_QUEUE); + txq_id >= IL4965_FIRST_AMPDU_QUEUE); tx_info->skb = NULL; il->cfg->ops->lib->txq_free_tfd(il, txq); @@ -1331,7 +1331,7 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, spin_unlock_irqrestore(&il->sta_lock, flags); } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG const char *il4965_get_tx_fail_reason(u32 status) { #define TX_STATUS_FAIL(x) case TX_STATUS_FAIL_ ## x: return #x @@ -1368,4 +1368,4 @@ const char *il4965_get_tx_fail_reason(u32 status) #undef TX_STATUS_FAIL #undef TX_STATUS_POSTPONE } -#endif /* CONFIG_IWLWIFI_LEGACY_DEBUG */ +#endif /* CONFIG_IWLEGACY_DEBUG */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c index bb0b7f5cb5ee..633caf5f60fc 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c @@ -62,7 +62,7 @@ il4965_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) /* NOTE: Use the debugless read so we don't flood kernel log * if IL_DL_IO is set */ il_wr(il, HBUS_TARG_MEM_RADDR, - i + IWL4965_RTC_INST_LOWER_BOUND); + i + IL4965_RTC_INST_LOWER_BOUND); val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { ret = -EIO; @@ -90,7 +90,7 @@ static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, D_INFO("ucode inst image size is %u\n", len); il_wr(il, HBUS_TARG_MEM_RADDR, - IWL4965_RTC_INST_LOWER_BOUND); + IL4965_RTC_INST_LOWER_BOUND); errcnt = 0; for (; len > 0; len -= sizeof(u32), image++) { diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index 3706e47ce274..f3451714249b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -52,14 +52,14 @@ static int il4965_send_tx_power(struct il_priv *il); static int il4965_hw_get_temperature(struct il_priv *il); /* Highest firmware API version supported */ -#define IWL4965_UCODE_API_MAX 2 +#define IL4965_UCODE_API_MAX 2 /* Lowest firmware API version supported */ -#define IWL4965_UCODE_API_MIN 2 +#define IL4965_UCODE_API_MIN 2 -#define IWL4965_FW_PRE "iwlwifi-4965-" -#define _IWL4965_MODULE_FIRMWARE(api) IWL4965_FW_PRE #api ".ucode" -#define IWL4965_MODULE_FIRMWARE(api) _IWL4965_MODULE_FIRMWARE(api) +#define IL4965_FW_PRE "iwlwifi-4965-" +#define _IL4965_MODULE_FIRMWARE(api) IL4965_FW_PRE #api ".ucode" +#define IL4965_MODULE_FIRMWARE(api) _IL4965_MODULE_FIRMWARE(api) /* check contents of special bootstrap uCode SRAM */ static int il4965_verify_bsm(struct il_priv *il) @@ -142,7 +142,7 @@ static int il4965_load_bsm(struct il_priv *il) il->ucode_type = UCODE_RT; /* make sure bootstrap program is no larger than BSM's SRAM size */ - if (len > IWL49_MAX_BSM_SIZE) + if (len > IL49_MAX_BSM_SIZE) return -EINVAL; /* Tell bootstrap uCode where to find the "Initialize" uCode @@ -174,7 +174,7 @@ static int il4965_load_bsm(struct il_priv *il) /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ il_wr_prph(il, BSM_WR_MEM_SRC_REG, 0x0); il_wr_prph(il, - BSM_WR_MEM_DST_REG, IWL49_RTC_INST_LOWER_BOUND); + BSM_WR_MEM_DST_REG, IL49_RTC_INST_LOWER_BOUND); il_wr_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); /* Load bootstrap code into instruction SRAM now, @@ -392,7 +392,7 @@ static void il4965_set_ct_threshold(struct il_priv *il) static int il4965_hw_set_hw_params(struct il_priv *il) { if (il->cfg->mod_params->num_of_queues >= IL_MIN_NUM_QUEUES && - il->cfg->mod_params->num_of_queues <= IWL49_NUM_QUEUES) + il->cfg->mod_params->num_of_queues <= IL49_NUM_QUEUES) il->cfg->base_params->num_of_queues = il->cfg->mod_params->num_of_queues; @@ -402,10 +402,10 @@ static int il4965_hw_set_hw_params(struct il_priv *il) il->cfg->base_params->num_of_queues * sizeof(struct il4965_scd_bc_tbl); il->hw_params.tfd_size = sizeof(struct il_tfd); - il->hw_params.max_stations = IWL4965_STATION_COUNT; - il->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IWL4965_BROADCAST_ID; - il->hw_params.max_data_size = IWL49_RTC_DATA_SIZE; - il->hw_params.max_inst_size = IWL49_RTC_INST_SIZE; + il->hw_params.max_stations = IL4965_STATION_COUNT; + il->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IL4965_BROADCAST_ID; + il->hw_params.max_data_size = IL49_RTC_DATA_SIZE; + il->hw_params.max_inst_size = IL49_RTC_INST_SIZE; il->hw_params.max_bsm_size = BSM_SRAM_SIZE; il->hw_params.ht40_channel = BIT(IEEE80211_BAND_5GHZ); @@ -419,7 +419,7 @@ static int il4965_hw_set_hw_params(struct il_priv *il) il4965_set_ct_threshold(il); il->hw_params.sens = &il4965_sensitivity; - il->hw_params.beacon_time_tsf_bits = IWL4965_EXT_BEACON_TIME_POS; + il->hw_params.beacon_time_tsf_bits = IL4965_EXT_BEACON_TIME_POS; return 0; } @@ -2143,14 +2143,14 @@ static const struct il_ops il4965_ops = { }; static struct il_base_params il4965_base_params = { - .eeprom_size = IWL4965_EEPROM_IMG_SIZE, - .num_of_queues = IWL49_NUM_QUEUES, - .num_of_ampdu_queues = IWL49_NUM_AMPDU_QUEUES, + .eeprom_size = IL4965_EEPROM_IMG_SIZE, + .num_of_queues = IL49_NUM_QUEUES, + .num_of_ampdu_queues = IL49_NUM_AMPDU_QUEUES, .pll_cfg_val = 0, .set_l0s = true, .use_bsm = true, .led_compensation = 61, - .chain_noise_num_beacons = IWL4965_CAL_NUM_BEACONS, + .chain_noise_num_beacons = IL4965_CAL_NUM_BEACONS, .wd_timeout = IL_DEF_WD_TIMEOUT, .temperature_kelvin = true, .ucode_tracing = true, @@ -2160,9 +2160,9 @@ static struct il_base_params il4965_base_params = { struct il_cfg il4965_cfg = { .name = "Intel(R) Wireless WiFi Link 4965AGN", - .fw_name_pre = IWL4965_FW_PRE, - .ucode_api_max = IWL4965_UCODE_API_MAX, - .ucode_api_min = IWL4965_UCODE_API_MIN, + .fw_name_pre = IL4965_FW_PRE, + .ucode_api_max = IL4965_UCODE_API_MAX, + .ucode_api_min = IL4965_UCODE_API_MIN, .sku = IL_SKU_A|IL_SKU_G|IL_SKU_N, .valid_tx_ant = ANT_AB, .valid_rx_ant = ANT_ABC, @@ -2180,4 +2180,4 @@ struct il_cfg il4965_cfg = { }; /* Module firmware */ -MODULE_FIRMWARE(IWL4965_MODULE_FIRMWARE(IWL4965_UCODE_API_MAX)); +MODULE_FIRMWARE(IL4965_MODULE_FIRMWARE(IL4965_UCODE_API_MAX)); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.h b/drivers/net/wireless/iwlegacy/iwl-4965.h index 56bfdb016040..0b92c28a8f2a 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965.h @@ -189,7 +189,7 @@ int il4965_manage_ibss_station(struct il_priv *il, /* hcmd */ int il4965_send_beacon_cmd(struct il_priv *il); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG const char *il4965_get_tx_fail_reason(u32 status); #else static inline const char * diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h index 347d40284309..61acafbaab31 100644 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ b/drivers/net/wireless/iwlegacy/iwl-commands.h @@ -746,7 +746,7 @@ struct il4965_rxon_assoc_cmd { #define IL_CONN_MAX_LISTEN_INTERVAL 10 #define IL_MAX_UCODE_BEACON_INTERVAL 4 /* 4096 */ -#define IWL39_MAX_UCODE_BEACON_INTERVAL 1 /* 1024 */ +#define IL39_MAX_UCODE_BEACON_INTERVAL 1 /* 1024 */ /* * REPLY_RXON_TIMING = 0x14 (command, has simple generic response) @@ -854,10 +854,10 @@ struct il_qosparam_cmd { /* Special, dedicated locations within device's station table */ #define IL_AP_ID 0 #define IL_STA_ID 2 -#define IWL3945_BROADCAST_ID 24 -#define IWL3945_STATION_COUNT 25 -#define IWL4965_BROADCAST_ID 31 -#define IWL4965_STATION_COUNT 32 +#define IL3945_BROADCAST_ID 24 +#define IL3945_STATION_COUNT 25 +#define IL4965_BROADCAST_ID 31 +#define IL4965_STATION_COUNT 32 #define IL_STATION_COUNT 32 /* MAX(3945,4965)*/ #define IL_INVALID_STATION 255 @@ -1208,15 +1208,15 @@ struct il3945_rx_frame { struct il3945_rx_frame_end end; } __packed; -#define IWL39_RX_FRAME_SIZE (4 + sizeof(struct il3945_rx_frame)) +#define IL39_RX_FRAME_SIZE (4 + sizeof(struct il3945_rx_frame)) /* Fixed (non-configurable) rx data from phy */ -#define IWL49_RX_RES_PHY_CNT 14 -#define IWL49_RX_PHY_FLAGS_ANTENNAE_OFFSET (4) -#define IWL49_RX_PHY_FLAGS_ANTENNAE_MASK (0x70) -#define IWL49_AGC_DB_MASK (0x3f80) /* MASK(7,13) */ -#define IWL49_AGC_DB_POS (7) +#define IL49_RX_RES_PHY_CNT 14 +#define IL49_RX_PHY_FLAGS_ANTENNAE_OFFSET (4) +#define IL49_RX_PHY_FLAGS_ANTENNAE_MASK (0x70) +#define IL49_AGC_DB_MASK (0x3f80) /* MASK(7,13) */ +#define IL49_AGC_DB_POS (7) struct il4965_rx_non_cfg_phy { __le16 ant_selection; /* ant A bit 4, ant B bit 5, ant C bit 6 */ __le16 agc_info; /* agc code 0:6, agc dB 7:13, reserved 14:15 */ @@ -2407,7 +2407,7 @@ struct il3945_scan_channel { } __packed; /* set number of direct probes u8 type */ -#define IWL39_SCAN_PROBE_MASK(n) ((BIT(n) | (BIT(n) - BIT(1)))) +#define IL39_SCAN_PROBE_MASK(n) ((BIT(n) | (BIT(n) - BIT(1)))) struct il_scan_channel { /* diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index acbd5a899565..395918e2d726 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -315,7 +315,7 @@ bool il_is_ht40_tx_allowed(struct il_priv *il, if (ht_cap && !ht_cap->ht_supported) return false; -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS if (il->disable_ht40) return false; #endif @@ -888,7 +888,7 @@ void il_rx_csa(struct il_priv *il, struct il_rx_mem_buffer *rxb) } EXPORT_SYMBOL(il_rx_csa); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG void il_print_rx_config_cmd(struct il_priv *il, struct il_rxon_context *ctx) { @@ -930,7 +930,7 @@ void il_irq_handle_error(struct il_priv *il) il->cfg->ops->lib->dump_nic_error_log(il); if (il->cfg->ops->lib->dump_fh) il->cfg->ops->lib->dump_fh(il, NULL, false); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG if (il_get_debug_level(il) & IL_DL_FW_ERRORS) il_print_rx_config_cmd(il, &il->contexts[IL_RXON_CTX_BSS]); @@ -1208,7 +1208,7 @@ EXPORT_SYMBOL(il_send_statistics_request); void il_rx_pm_sleep_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_packet *pkt = rxb_addr(rxb); struct il_sleep_notification *sleep = &(pkt->u.sleep_notif); D_RX("sleep mode: %d, src: %d\n", @@ -1467,7 +1467,7 @@ void il_txq_mem(struct il_priv *il) } EXPORT_SYMBOL(il_txq_mem); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS #define IL_TRAFFIC_DUMP_SIZE (IL_TRAFFIC_ENTRY_SIZE * IL_TRAFFIC_ENTRIES) @@ -1611,11 +1611,11 @@ void il_clear_traffic_stats(struct il_priv *il) } /* - * if CONFIG_IWLWIFI_LEGACY_DEBUGFS defined, + * if CONFIG_IWLEGACY_DEBUGFS defined, * il_update_stats function will * record all the MGMT, CTRL and DATA pkt for both TX and Rx pass * Use debugFs to display the rx/rx_statistics - * if CONFIG_IWLWIFI_LEGACY_DEBUGFS not being defined, then no MGMT and CTRL + * if CONFIG_IWLEGACY_DEBUGFS not being defined, then no MGMT and CTRL * information will be recorded, but DATA pkt still will be recorded * for the reason of il_led.c need to control the led blinking based on * number of tx and rx data. diff --git a/drivers/net/wireless/iwlegacy/iwl-core.h b/drivers/net/wireless/iwlegacy/iwl-core.h index 1803954cbc5a..487cebfb6ed0 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.h +++ b/drivers/net/wireless/iwlegacy/iwl-core.h @@ -329,7 +329,7 @@ int il_mac_change_interface(struct ieee80211_hw *hw, int il_alloc_txq_mem(struct il_priv *il); void il_txq_mem(struct il_priv *il); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS int il_alloc_traffic_mem(struct il_priv *il); void il_free_traffic_mem(struct il_priv *il); void il_reset_traffic_log(struct il_priv *il); @@ -513,7 +513,7 @@ extern const struct dev_pm_ops il_pm_ops; * Error Handling Debugging ******************************************************/ void il4965_dump_nic_error_log(struct il_priv *il); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG void il_print_rx_config_cmd(struct il_priv *il, struct il_rxon_context *ctx); #else diff --git a/drivers/net/wireless/iwlegacy/iwl-debug.h b/drivers/net/wireless/iwlegacy/iwl-debug.h index 77467de7e028..c58003aa8185 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debug.h +++ b/drivers/net/wireless/iwlegacy/iwl-debug.h @@ -42,7 +42,7 @@ do { \ DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ } while (0) -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG #define IL_DBG(level, fmt, args...) \ do { \ if (il_get_debug_level(il) & level) \ @@ -63,9 +63,9 @@ do { \ static inline void il_print_hex_dump(struct il_priv *il, int level, const void *p, u32 len) {} -#endif /* CONFIG_IWLWIFI_LEGACY_DEBUG */ +#endif /* CONFIG_IWLEGACY_DEBUG */ -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS int il_dbgfs_register(struct il_priv *il, const char *name); void il_dbgfs_unregister(struct il_priv *il); #else @@ -77,7 +77,7 @@ il_dbgfs_register(struct il_priv *il, const char *name) static inline void il_dbgfs_unregister(struct il_priv *il) { } -#endif /* CONFIG_IWLWIFI_LEGACY_DEBUGFS */ +#endif /* CONFIG_IWLEGACY_DEBUGFS */ /* * To use the debug system: @@ -99,7 +99,7 @@ static inline void il_dbgfs_unregister(struct il_priv *il) * /sys/module/iwl3945/parameters/debug * /sys/class/net/wlan0/device/debug_level * - * when CONFIG_IWLWIFI_LEGACY_DEBUG=y. + * when CONFIG_IWLEGACY_DEBUG=y. */ /* 0x0000000F - 0x00000001 */ diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index cd15e67c94d3..736b00bc7bfb 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -535,7 +535,7 @@ static ssize_t il_dbgfs_interrupt_read(struct file *file, "\tLast Restarting Code: 0x%X\n", il->isr_stats.err_code); } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG pos += scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n", il->isr_stats.sch); pos += scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n", diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 2e2e3f3f66f7..0aa4a120e87c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -185,7 +185,7 @@ struct il4965_channel_tgh_info { s64 last_radar_time; }; -#define IWL4965_MAX_RATE (33) +#define IL4965_MAX_RATE (33) struct il3945_clip_group { /* maximum power level to prevent clipping for each rate, derived by @@ -246,7 +246,7 @@ struct il_channel_info { /* Radio/DSP gain settings for each "normal" data Tx rate. * These include, in addition to RF and DSP gain, a few fields for * remembering/modifying gain settings (indexes). */ - struct il3945_channel_power_info power_info[IWL4965_MAX_RATE]; + struct il3945_channel_power_info power_info[IL4965_MAX_RATE]; /* Radio/DSP gain settings for each scan rate, for directed scans. */ struct il3945_scan_power_info scan_pwr_info[IL_NUM_SCAN_RATES]; @@ -670,7 +670,7 @@ struct il_dma_ptr { /* Sensitivity and chain noise calibration */ #define INITIALIZATION_VALUE 0xFFFF -#define IWL4965_CAL_NUM_BEACONS 20 +#define IL4965_CAL_NUM_BEACONS 20 #define IL_CAL_NUM_BEACONS 16 #define MAXIMUM_ALLOWED_PATHLOSS 15 @@ -847,7 +847,7 @@ enum il_ctrl_stats { }; struct traffic_stats { -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS u32 mgmt[MANAGEMENT_MAX]; u32 ctrl[CONTROL_MAX]; u32 data_cnt; @@ -891,13 +891,13 @@ struct il_force_reset { * bits 31:24 - extended * bits 23:0 - interval */ -#define IWL3945_EXT_BEACON_TIME_POS 24 +#define IL3945_EXT_BEACON_TIME_POS 24 /* * for _4965 devices * bits 31:22 - extended * bits 21:0 - interval */ -#define IWL4965_EXT_BEACON_TIME_POS 22 +#define IL4965_EXT_BEACON_TIME_POS 22 enum il_rxon_context_id { IL_RXON_CTX_BSS, @@ -1141,7 +1141,7 @@ struct il_priv { struct delayed_work rfkill_poll; struct il3945_notif_statistics statistics; -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS struct il3945_notif_statistics accum_statistics; struct il3945_notif_statistics delta_statistics; struct il3945_notif_statistics max_delta; @@ -1179,7 +1179,7 @@ struct il_priv { u8 phy_calib_chain_noise_gain_cmd; struct il_notif_statistics statistics; -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#ifdef CONFIG_IWLEGACY_DEBUGFS struct il_notif_statistics accum_statistics; struct il_notif_statistics delta_statistics; struct il_notif_statistics max_delta; @@ -1217,12 +1217,12 @@ struct il_priv { s8 tx_power_next; -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG /* debugging info */ u32 debug_level; /* per device debugging will override global il_debug_level if set */ -#endif /* CONFIG_IWLWIFI_LEGACY_DEBUG */ -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUGFS +#endif /* CONFIG_IWLEGACY_DEBUG */ +#ifdef CONFIG_IWLEGACY_DEBUGFS /* debugfs */ u16 tx_traffic_idx; u16 rx_traffic_idx; @@ -1231,7 +1231,7 @@ struct il_priv { struct dentry *debugfs_dir; u32 dbgfs_sram_offset, dbgfs_sram_len; bool disable_ht40; -#endif /* CONFIG_IWLWIFI_LEGACY_DEBUGFS */ +#endif /* CONFIG_IWLEGACY_DEBUGFS */ struct work_struct txpower_work; u32 disable_sens_cal; @@ -1257,7 +1257,7 @@ static inline void il_txq_ctx_deactivate(struct il_priv *il, int txq_id) clear_bit(txq_id, &il->txq_ctx_active_msk); } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG /* * il_get_debug_level: Return active debug level for device * diff --git a/drivers/net/wireless/iwlegacy/iwl-hcmd.c b/drivers/net/wireless/iwlegacy/iwl-hcmd.c index 8f87bd87f63d..6ccd37fc42c1 100644 --- a/drivers/net/wireless/iwlegacy/iwl-hcmd.c +++ b/drivers/net/wireless/iwlegacy/iwl-hcmd.c @@ -100,7 +100,7 @@ static void il_generic_cmd_callback(struct il_priv *il, return; } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG switch (cmd->hdr.cmd) { case REPLY_TX_LINK_QUALITY_CMD: case SENSITIVITY_CMD: diff --git a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h index 5da7d415170c..f24b6b847fb4 100644 --- a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h +++ b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h @@ -97,7 +97,7 @@ enum { enum { IL_FIRST_OFDM_RATE = IL_RATE_6M_INDEX, - IWL39_LAST_OFDM_RATE = IL_RATE_54M_INDEX, + IL39_LAST_OFDM_RATE = IL_RATE_54M_INDEX, IL_LAST_OFDM_RATE = IL_RATE_60M_INDEX, IL_FIRST_CCK_RATE = IL_RATE_1M_INDEX, IL_LAST_CCK_RATE = IL_RATE_11M_INDEX, diff --git a/drivers/net/wireless/iwlegacy/iwl-prph.h b/drivers/net/wireless/iwlegacy/iwl-prph.h index 96788a128a61..caa383726787 100644 --- a/drivers/net/wireless/iwlegacy/iwl-prph.h +++ b/drivers/net/wireless/iwlegacy/iwl-prph.h @@ -320,19 +320,19 @@ * can keep track of at one time when creating block-ack chains of frames. * Note that "64" matches the number of ack bits in a block-ack packet. * Driver should use SCD_WIN_SIZE and SCD_FRAME_LIMIT values to initialize - * IWL49_SCD_CONTEXT_QUEUE_OFFSET(x) values. + * IL49_SCD_CONTEXT_QUEUE_OFFSET(x) values. */ #define SCD_WIN_SIZE 64 #define SCD_FRAME_LIMIT 64 /* SCD registers are internal, must be accessed via HBUS_TARG_PRPH regs */ -#define IWL49_SCD_START_OFFSET 0xa02c00 +#define IL49_SCD_START_OFFSET 0xa02c00 /* * 4965 tells driver SRAM address for internal scheduler structs via this reg. * Value is valid only after "Alive" response from uCode. */ -#define IWL49_SCD_SRAM_BASE_ADDR (IWL49_SCD_START_OFFSET + 0x0) +#define IL49_SCD_SRAM_BASE_ADDR (IL49_SCD_START_OFFSET + 0x0) /* * Driver may need to update queue-empty bits after changing queue's @@ -343,7 +343,7 @@ * 15-00: Empty state, one for each queue -- 1: empty, 0: non-empty * NOTE: This register is not used by Linux driver. */ -#define IWL49_SCD_EMPTY_BITS (IWL49_SCD_START_OFFSET + 0x4) +#define IL49_SCD_EMPTY_BITS (IL49_SCD_START_OFFSET + 0x4) /* * Physical base address of array of byte count (BC) circular buffers (CBs). @@ -355,7 +355,7 @@ * Bit fields: * 25-00: Byte Count CB physical address [35:10], must be 1024-byte aligned. */ -#define IWL49_SCD_DRAM_BASE_ADDR (IWL49_SCD_START_OFFSET + 0x10) +#define IL49_SCD_DRAM_BASE_ADDR (IL49_SCD_START_OFFSET + 0x10) /* * Enables any/all Tx DMA/FIFO channels. @@ -364,7 +364,7 @@ * Bit fields: * 7- 0: Enable (1), disable (0), one bit for each channel 0-7 */ -#define IWL49_SCD_TXFACT (IWL49_SCD_START_OFFSET + 0x1c) +#define IL49_SCD_TXFACT (IL49_SCD_START_OFFSET + 0x1c) /* * Queue (x) Write Pointers (indexes, really!), one for each Tx queue. * Initialized and updated by driver as new TFDs are added to queue. @@ -372,7 +372,7 @@ * Start Sequence Number; index = (SSN & 0xff) * NOTE: Alternative to HBUS_TARG_WRPTR, which is what Linux driver uses? */ -#define IWL49_SCD_QUEUE_WRPTR(x) (IWL49_SCD_START_OFFSET + 0x24 + (x) * 4) +#define IL49_SCD_QUEUE_WRPTR(x) (IL49_SCD_START_OFFSET + 0x24 + (x) * 4) /* * Queue (x) Read Pointers (indexes, really!), one for each Tx queue. @@ -380,7 +380,7 @@ * For Scheduler-ACK mode, index indicates first frame in Tx window. * Initialized by driver, updated by scheduler. */ -#define IWL49_SCD_QUEUE_RDPTR(x) (IWL49_SCD_START_OFFSET + 0x64 + (x) * 4) +#define IL49_SCD_QUEUE_RDPTR(x) (IL49_SCD_START_OFFSET + 0x64 + (x) * 4) /* * Select which queues work in chain mode (1) vs. not (0). @@ -391,7 +391,7 @@ * NOTE: If driver sets up queue for chain mode, it should be also set up * Scheduler-ACK mode as well, via SCD_QUEUE_STATUS_BITS(x). */ -#define IWL49_SCD_QUEUECHAIN_SEL (IWL49_SCD_START_OFFSET + 0xd0) +#define IL49_SCD_QUEUECHAIN_SEL (IL49_SCD_START_OFFSET + 0xd0) /* * Select which queues interrupt driver when scheduler increments @@ -402,7 +402,7 @@ * NOTE: This functionality is apparently a no-op; driver relies on interrupts * from Rx queue to read Tx command responses and update Tx queues. */ -#define IWL49_SCD_INTERRUPT_MASK (IWL49_SCD_START_OFFSET + 0xe4) +#define IL49_SCD_INTERRUPT_MASK (IL49_SCD_START_OFFSET + 0xe4) /* * Queue search status registers. One for each queue. @@ -423,18 +423,18 @@ * NOTE: If enabling Scheduler-ACK mode, chain mode should also be enabled * via SCD_QUEUECHAIN_SEL. */ -#define IWL49_SCD_QUEUE_STATUS_BITS(x)\ - (IWL49_SCD_START_OFFSET + 0x104 + (x) * 4) +#define IL49_SCD_QUEUE_STATUS_BITS(x)\ + (IL49_SCD_START_OFFSET + 0x104 + (x) * 4) /* Bit field positions */ -#define IWL49_SCD_QUEUE_STTS_REG_POS_ACTIVE (0) -#define IWL49_SCD_QUEUE_STTS_REG_POS_TXF (1) -#define IWL49_SCD_QUEUE_STTS_REG_POS_WSL (5) -#define IWL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK (8) +#define IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE (0) +#define IL49_SCD_QUEUE_STTS_REG_POS_TXF (1) +#define IL49_SCD_QUEUE_STTS_REG_POS_WSL (5) +#define IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK (8) /* Write masks */ -#define IWL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN (10) -#define IWL49_SCD_QUEUE_STTS_REG_MSK (0x0007FC00) +#define IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN (10) +#define IL49_SCD_QUEUE_STTS_REG_MSK (0x0007FC00) /** * 4965 internal SRAM structures for scheduler, shared with driver ... @@ -470,14 +470,14 @@ * Init must be done after driver receives "Alive" response from 4965 uCode, * and when setting up queue for aggregation. */ -#define IWL49_SCD_CONTEXT_DATA_OFFSET 0x380 -#define IWL49_SCD_CONTEXT_QUEUE_OFFSET(x) \ - (IWL49_SCD_CONTEXT_DATA_OFFSET + ((x) * 8)) +#define IL49_SCD_CONTEXT_DATA_OFFSET 0x380 +#define IL49_SCD_CONTEXT_QUEUE_OFFSET(x) \ + (IL49_SCD_CONTEXT_DATA_OFFSET + ((x) * 8)) -#define IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS (0) -#define IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK (0x0000007F) -#define IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS (16) -#define IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK (0x007F0000) +#define IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS (0) +#define IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK (0x0000007F) +#define IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS (16) +#define IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK (0x007F0000) /* * Tx Status Bitmap @@ -486,7 +486,7 @@ * "Alive" notification from uCode. Area is used only by device itself; * no other support (besides clearing) is required from driver. */ -#define IWL49_SCD_TX_STTS_BITMAP_OFFSET 0x400 +#define IL49_SCD_TX_STTS_BITMAP_OFFSET 0x400 /* * RAxTID to queue translation mapping. @@ -508,11 +508,11 @@ * must read a dword-aligned value from device SRAM, replace the 16-bit map * value of interest, and write the dword value back into device SRAM. */ -#define IWL49_SCD_TRANSLATE_TBL_OFFSET 0x500 +#define IL49_SCD_TRANSLATE_TBL_OFFSET 0x500 /* Find translation table dword to read/write for given queue */ -#define IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \ - ((IWL49_SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffffffc) +#define IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \ + ((IL49_SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffffffc) #define IL_SCD_TXFIFO_POS_TID (0) #define IL_SCD_TXFIFO_POS_RA (4) diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index e352a185a96e..e4e5fbb2c644 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -185,7 +185,7 @@ EXPORT_SYMBOL(il_scan_cancel_timeout); static void il_rx_reply_scan(struct il_priv *il, struct il_rx_mem_buffer *rxb) { -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_packet *pkt = rxb_addr(rxb); struct il_scanreq_notification *notif = (struct il_scanreq_notification *)pkt->u.raw; @@ -216,7 +216,7 @@ static void il_rx_scan_start_notif(struct il_priv *il, static void il_rx_scan_results_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_packet *pkt = rxb_addr(rxb); struct il_scanresults_notification *notif = (struct il_scanresults_notification *)pkt->u.raw; @@ -239,7 +239,7 @@ static void il_rx_scan_complete_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_packet *pkt = rxb_addr(rxb); struct il_scancomplete_notification *scan_notif = (void *)pkt->u.raw; #endif diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.c b/drivers/net/wireless/iwlegacy/iwl-sta.c index cca467c26c0d..68c43b08b2c1 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-sta.c @@ -681,7 +681,7 @@ void il_dealloc_bcast_stations(struct il_priv *il) } EXPORT_SYMBOL_GPL(il_dealloc_bcast_stations); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG static void il_dump_lq_cmd(struct il_priv *il, struct il_link_quality_cmd *lq) { diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index 0d3515d21bfc..531205942f44 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -507,7 +507,7 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) if (idx == TFD_CMD_SLOTS) len = IL_MAX_CMD_SIZE; -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG switch (out_cmd->hdr.cmd) { case REPLY_TX_LINK_QUALITY_CMD: case SENSITIVITY_CMD: diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index ec9a93c9cb8f..2d1f22a53365 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -68,7 +68,7 @@ #define DRV_DESCRIPTION \ "Intel(R) PRO/Wireless 3945ABG/BG Network Connection driver for Linux" -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG #define VD "d" #else #define VD @@ -500,7 +500,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) fc = hdr->frame_control; -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG if (ieee80211_is_auth(fc)) D_TX("Sending AUTH frame\n"); else if (ieee80211_is_assoc_req(fc)) @@ -783,7 +783,7 @@ static void il3945_rx_reply_alive(struct il_priv *il, static void il3945_rx_reply_add_sta(struct il_priv *il, struct il_rx_mem_buffer *rxb) { -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_packet *pkt = rxb_addr(rxb); #endif @@ -795,7 +795,7 @@ static void il3945_rx_beacon_notif(struct il_priv *il, { struct il_rx_packet *pkt = rxb_addr(rxb); struct il3945_beacon_notif *beacon = &(pkt->u.beacon_status); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG u8 rate = beacon->beacon_notify_hdr.rate; D_RX("beacon status %x retries %d iss %d " @@ -1410,7 +1410,7 @@ static void il3945_irq_tasklet(struct il_priv *il) u32 inta, handled = 0; u32 inta_fh; unsigned long flags; -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG u32 inta_mask; #endif @@ -1428,7 +1428,7 @@ static void il3945_irq_tasklet(struct il_priv *il) inta_fh = _il_rd(il, CSR_FH_INT_STATUS); _il_wr(il, CSR_FH_INT_STATUS, inta_fh); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG if (il_get_debug_level(il) & IL_DL_ISR) { /* just for debug */ inta_mask = _il_rd(il, CSR_INT_MASK); @@ -1463,7 +1463,7 @@ static void il3945_irq_tasklet(struct il_priv *il) return; } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG if (il_get_debug_level(il) & (IL_DL_ISR)) { /* NIC fires this, but we don't use it, redundant with WAKEUP */ if (inta & CSR_INT_BIT_SCD) { @@ -1541,7 +1541,7 @@ static void il3945_irq_tasklet(struct il_priv *il) if (test_bit(STATUS_INT_ENABLED, &il->status)) il_enable_interrupts(il); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG if (il_get_debug_level(il) & (IL_DL_ISR)) { inta = _il_rd(il, CSR_INT); inta_mask = _il_rd(il, CSR_INT_MASK); @@ -1612,12 +1612,12 @@ static int il3945_get_channels_for_scan(struct il_priv *il, * hearing clear Rx packet).*/ if (IL_UCODE_API(il->ucode_ver) >= 2) { if (n_probes) - scan_ch->type |= IWL39_SCAN_PROBE_MASK(n_probes); + scan_ch->type |= IL39_SCAN_PROBE_MASK(n_probes); } else { /* uCode v1 does not allow setting direct probe bits on * passive channel. */ if ((scan_ch->type & 1) && n_probes) - scan_ch->type |= IWL39_SCAN_PROBE_MASK(n_probes); + scan_ch->type |= IL39_SCAN_PROBE_MASK(n_probes); } /* Set txpower levels to defaults */ @@ -1659,7 +1659,7 @@ static void il3945_init_hw_rates(struct il_priv *il, rates[i].hw_value = i; /* Rate scaling will work on indexes */ rates[i].hw_value_short = i; rates[i].flags = 0; - if (i > IWL39_LAST_OFDM_RATE || i < IL_FIRST_OFDM_RATE) { + if (i > IL39_LAST_OFDM_RATE || i < IL_FIRST_OFDM_RATE) { /* * If CCK != 1M then set short preamble rate flag. */ @@ -1699,7 +1699,7 @@ static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) D_INFO("ucode inst image size is %u\n", len); il_wr(il, HBUS_TARG_MEM_RADDR, - IWL39_RTC_INST_LOWER_BOUND); + IL39_RTC_INST_LOWER_BOUND); errcnt = 0; for (; len > 0; len -= sizeof(u32), image++) { @@ -1746,7 +1746,7 @@ static int il3945_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) /* NOTE: Use the debugless read so we don't flood kernel log * if IL_DL_IO is set */ il_wr(il, HBUS_TARG_MEM_RADDR, - i + IWL39_RTC_INST_LOWER_BOUND); + i + IL39_RTC_INST_LOWER_BOUND); val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { #if 0 /* Enable this if you want to see details */ @@ -1820,7 +1820,7 @@ static void il3945_nic_start(struct il_priv *il) _il_wr(il, CSR_RESET, 0); } -#define IWL3945_UCODE_GET(item) \ +#define IL3945_UCODE_GET(item) \ static u32 il3945_ucode_get_##item(const struct il_ucode_header *ucode)\ { \ return le32_to_cpu(ucode->v1.item); \ @@ -1836,11 +1836,11 @@ static u8 *il3945_ucode_get_data(const struct il_ucode_header *ucode) return (u8 *) ucode->v1.data; } -IWL3945_UCODE_GET(inst_size); -IWL3945_UCODE_GET(data_size); -IWL3945_UCODE_GET(init_size); -IWL3945_UCODE_GET(init_data_size); -IWL3945_UCODE_GET(boot_size); +IL3945_UCODE_GET(inst_size); +IL3945_UCODE_GET(data_size); +IL3945_UCODE_GET(init_size); +IL3945_UCODE_GET(init_data_size); +IL3945_UCODE_GET(boot_size); /** * il3945_read_ucode - Read uCode images from disk file. @@ -1967,34 +1967,34 @@ static int il3945_read_ucode(struct il_priv *il) } /* Verify that uCode images will fit in card's SRAM */ - if (inst_size > IWL39_MAX_INST_SIZE) { + if (inst_size > IL39_MAX_INST_SIZE) { D_INFO("uCode instr len %d too large to fit in\n", inst_size); ret = -EINVAL; goto err_release; } - if (data_size > IWL39_MAX_DATA_SIZE) { + if (data_size > IL39_MAX_DATA_SIZE) { D_INFO("uCode data len %d too large to fit in\n", data_size); ret = -EINVAL; goto err_release; } - if (init_size > IWL39_MAX_INST_SIZE) { + if (init_size > IL39_MAX_INST_SIZE) { D_INFO( "uCode init instr len %d too large to fit in\n", init_size); ret = -EINVAL; goto err_release; } - if (init_data_size > IWL39_MAX_DATA_SIZE) { + if (init_data_size > IL39_MAX_DATA_SIZE) { D_INFO( "uCode init data len %d too large to fit in\n", init_data_size); ret = -EINVAL; goto err_release; } - if (boot_size > IWL39_MAX_BSM_SIZE) { + if (boot_size > IL39_MAX_BSM_SIZE) { D_INFO( "uCode boot instr len %d too large to fit in\n", boot_size); @@ -3118,7 +3118,7 @@ static void il3945_configure_filter(struct ieee80211_hw *hw, * *****************************************************************************/ -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG /* * The following adds a new attribute to the sysfs representation @@ -3160,7 +3160,7 @@ static ssize_t il3945_store_debug_level(struct device *d, static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, il3945_show_debug_level, il3945_store_debug_level); -#endif /* CONFIG_IWLWIFI_LEGACY_DEBUG */ +#endif /* CONFIG_IWLEGACY_DEBUG */ static ssize_t il3945_show_temperature(struct device *d, struct device_attribute *attr, char *buf) @@ -3495,7 +3495,7 @@ static struct attribute *il3945_sysfs_entries[] = { &dev_attr_status.attr, &dev_attr_temperature.attr, &dev_attr_tx_power.attr, -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG &dev_attr_debug_level.attr, #endif NULL @@ -3583,7 +3583,7 @@ err: return ret; } -#define IWL3945_MAX_PROBE_REQUEST 200 +#define IL3945_MAX_PROBE_REQUEST 200 static int il3945_setup_mac(struct il_priv *il) { @@ -3607,7 +3607,7 @@ static int il3945_setup_mac(struct il_priv *il) hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX_3945; /* we create the 802.11 header and a zero-length SSID element */ - hw->wiphy->max_scan_ie_len = IWL3945_MAX_PROBE_REQUEST - 24 - 2; + hw->wiphy->max_scan_ie_len = IL3945_MAX_PROBE_REQUEST - 24 - 2; /* Default value; 4 EDCA QOS priorities */ hw->queues = 4; @@ -3656,7 +3656,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en il = hw->priv; SET_IEEE80211_DEV(hw, &pdev->dev); - il->cmd_queue = IWL39_CMD_QUEUE_NUM; + il->cmd_queue = IL39_CMD_QUEUE_NUM; /* 3945 has only one valid context */ il->valid_contexts = BIT(IL_RXON_CTX_BSS); @@ -3992,7 +3992,7 @@ static void __exit il3945_exit(void) il3945_rate_control_unregister(); } -MODULE_FIRMWARE(IWL3945_MODULE_FIRMWARE(IWL3945_UCODE_API_MAX)); +MODULE_FIRMWARE(IL3945_MODULE_FIRMWARE(IL3945_UCODE_API_MAX)); module_param_named(antenna, il3945_mod_params.antenna, int, S_IRUGO); MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])"); @@ -4002,7 +4002,7 @@ MODULE_PARM_DESC(swcrypto, module_param_named(disable_hw_scan, il3945_mod_params.disable_hw_scan, int, S_IRUGO); MODULE_PARM_DESC(disable_hw_scan, "disable hardware scanning (default 1)"); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG module_param_named(debug, il_debug_level, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(debug, "debug output mask"); #endif diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index 0f7d44c95f08..ddf4200a95cf 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -72,7 +72,7 @@ */ #define DRV_DESCRIPTION "Intel(R) Wireless WiFi 4965 driver for Linux" -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG #define VD "d" #else #define VD @@ -493,7 +493,7 @@ static void il4965_rx_beacon_notif(struct il_priv *il, struct il_rx_packet *pkt = rxb_addr(rxb); struct il4965_beacon_notif *beacon = (struct il4965_beacon_notif *)pkt->u.raw; -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG u8 rate = il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); D_RX("beacon status %x retries %d iss %d " @@ -778,7 +778,7 @@ static void il4965_irq_tasklet(struct il_priv *il) u32 inta_fh; unsigned long flags; u32 i; -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG u32 inta_mask; #endif @@ -796,7 +796,7 @@ static void il4965_irq_tasklet(struct il_priv *il) inta_fh = _il_rd(il, CSR_FH_INT_STATUS); _il_wr(il, CSR_FH_INT_STATUS, inta_fh); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG if (il_get_debug_level(il) & IL_DL_ISR) { /* just for debug */ inta_mask = _il_rd(il, CSR_INT_MASK); @@ -831,7 +831,7 @@ static void il4965_irq_tasklet(struct il_priv *il) return; } -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG if (il_get_debug_level(il) & (IL_DL_ISR)) { /* NIC fires this, but we don't use it, redundant with WAKEUP */ if (inta & CSR_INT_BIT_SCD) { @@ -946,7 +946,7 @@ static void il4965_irq_tasklet(struct il_priv *il) else if (handled & CSR_INT_BIT_RF_KILL) il_enable_rfkill_int(il); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG if (il_get_debug_level(il) & (IL_DL_ISR)) { inta = _il_rd(il, CSR_INT); inta_mask = _il_rd(il, CSR_INT_MASK); @@ -964,7 +964,7 @@ static void il4965_irq_tasklet(struct il_priv *il) * *****************************************************************************/ -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG /* * The following adds a new attribute to the sysfs representation @@ -1007,7 +1007,7 @@ static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, il4965_show_debug_level, il4965_store_debug_level); -#endif /* CONFIG_IWLWIFI_LEGACY_DEBUG */ +#endif /* CONFIG_IWLEGACY_DEBUG */ static ssize_t il4965_show_temperature(struct device *d, @@ -1062,7 +1062,7 @@ static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, static struct attribute *il_sysfs_entries[] = { &dev_attr_temperature.attr, &dev_attr_tx_power.attr, -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG &dev_attr_debug_level.attr, #endif NULL @@ -1607,7 +1607,7 @@ static const s8 default_queue_to_tx_fifo[] = { IL_TX_FIFO_VI, IL_TX_FIFO_BE, IL_TX_FIFO_BK, - IWL49_CMD_FIFO_NUM, + IL49_CMD_FIFO_NUM, IL_TX_FIFO_UNUSED, IL_TX_FIFO_UNUSED, }; @@ -1623,18 +1623,18 @@ static int il4965_alive_notify(struct il_priv *il) /* Clear 4965's internal Tx Scheduler data base */ il->scd_base_addr = il_rd_prph(il, - IWL49_SCD_SRAM_BASE_ADDR); - a = il->scd_base_addr + IWL49_SCD_CONTEXT_DATA_OFFSET; - for (; a < il->scd_base_addr + IWL49_SCD_TX_STTS_BITMAP_OFFSET; a += 4) + IL49_SCD_SRAM_BASE_ADDR); + a = il->scd_base_addr + IL49_SCD_CONTEXT_DATA_OFFSET; + for (; a < il->scd_base_addr + IL49_SCD_TX_STTS_BITMAP_OFFSET; a += 4) il_write_targ_mem(il, a, 0); - for (; a < il->scd_base_addr + IWL49_SCD_TRANSLATE_TBL_OFFSET; a += 4) + for (; a < il->scd_base_addr + IL49_SCD_TRANSLATE_TBL_OFFSET; a += 4) il_write_targ_mem(il, a, 0); for (; a < il->scd_base_addr + - IWL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(il->hw_params.max_txq_num); a += 4) + IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(il->hw_params.max_txq_num); a += 4) il_write_targ_mem(il, a, 0); /* Tel 4965 where to find Tx byte count tables */ - il_wr_prph(il, IWL49_SCD_DRAM_BASE_ADDR, + il_wr_prph(il, IL49_SCD_DRAM_BASE_ADDR, il->scd_bc_tbls.dma >> 10); /* Enable DMA channel */ @@ -1650,32 +1650,32 @@ static int il4965_alive_notify(struct il_priv *il) reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); /* Disable chain mode for all queues */ - il_wr_prph(il, IWL49_SCD_QUEUECHAIN_SEL, 0); + il_wr_prph(il, IL49_SCD_QUEUECHAIN_SEL, 0); /* Initialize each Tx queue (including the command queue) */ for (i = 0; i < il->hw_params.max_txq_num; i++) { /* TFD circular buffer read/write indexes */ - il_wr_prph(il, IWL49_SCD_QUEUE_RDPTR(i), 0); + il_wr_prph(il, IL49_SCD_QUEUE_RDPTR(i), 0); il_wr(il, HBUS_TARG_WRPTR, 0 | (i << 8)); /* Max Tx Window size for Scheduler-ACK mode */ il_write_targ_mem(il, il->scd_base_addr + - IWL49_SCD_CONTEXT_QUEUE_OFFSET(i), + IL49_SCD_CONTEXT_QUEUE_OFFSET(i), (SCD_WIN_SIZE << - IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & - IWL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); + IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & + IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); /* Frame limit */ il_write_targ_mem(il, il->scd_base_addr + - IWL49_SCD_CONTEXT_QUEUE_OFFSET(i) + + IL49_SCD_CONTEXT_QUEUE_OFFSET(i) + sizeof(u32), (SCD_FRAME_LIMIT << - IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) & - IWL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); + IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) & + IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); } - il_wr_prph(il, IWL49_SCD_INTERRUPT_MASK, + il_wr_prph(il, IL49_SCD_INTERRUPT_MASK, (1 << il->hw_params.max_txq_num) - 1); /* Activate all Tx DMA/FIFO channels */ @@ -2733,7 +2733,7 @@ void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 index) { il_wr(il, HBUS_TARG_WRPTR, (index & 0xff) | (txq_id << 8)); - il_wr_prph(il, IWL49_SCD_QUEUE_RDPTR(txq_id), index); + il_wr_prph(il, IL49_SCD_QUEUE_RDPTR(txq_id), index); } void il4965_tx_queue_set_status(struct il_priv *il, @@ -2746,12 +2746,12 @@ void il4965_tx_queue_set_status(struct il_priv *il, int active = test_bit(txq_id, &il->txq_ctx_active_msk) ? 1 : 0; /* Set up and activate */ - il_wr_prph(il, IWL49_SCD_QUEUE_STATUS_BITS(txq_id), - (active << IWL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | - (tx_fifo_id << IWL49_SCD_QUEUE_STTS_REG_POS_TXF) | - (scd_retry << IWL49_SCD_QUEUE_STTS_REG_POS_WSL) | - (scd_retry << IWL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK) | - IWL49_SCD_QUEUE_STTS_REG_MSK); + il_wr_prph(il, IL49_SCD_QUEUE_STATUS_BITS(txq_id), + (active << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | + (tx_fifo_id << IL49_SCD_QUEUE_STTS_REG_POS_TXF) | + (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_WSL) | + (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK) | + IL49_SCD_QUEUE_STTS_REG_MSK); txq->sched_retry = scd_retry; @@ -3195,7 +3195,7 @@ static void __devexit il4965_pci_remove(struct pci_dev *pdev) */ void il4965_txq_set_sched(struct il_priv *il, u32 mask) { - il_wr_prph(il, IWL49_SCD_TXFACT, mask); + il_wr_prph(il, IL49_SCD_TXFACT, mask); } /***************************************************************************** @@ -3206,11 +3206,8 @@ void il4965_txq_set_sched(struct il_priv *il, u32 mask) /* Hardware specific file defines the PCI IDs table for that hardware module */ static DEFINE_PCI_DEVICE_TABLE(il4965_hw_card_ids) = { -#if defined(CONFIG_IWL4965_MODULE) || defined(CONFIG_IWL4965) {IL_PCI_DEVICE(0x4229, PCI_ANY_ID, il4965_cfg)}, {IL_PCI_DEVICE(0x4230, PCI_ANY_ID, il4965_cfg)}, -#endif /* CONFIG_IWL4965 */ - {0} }; MODULE_DEVICE_TABLE(pci, il4965_hw_card_ids); @@ -3258,7 +3255,7 @@ static void __exit il4965_exit(void) module_exit(il4965_exit); module_init(il4965_init); -#ifdef CONFIG_IWLWIFI_LEGACY_DEBUG +#ifdef CONFIG_IWLEGACY_DEBUG module_param_named(debug, il_debug_level, uint, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(debug, "debug output mask"); #endif -- cgit v1.2.3 From dcae1c641a4d7b7a00b1a566355ffaa517588aa6 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 26 Aug 2011 14:36:21 +0200 Subject: iwlegacy: s/iwl_rx_packet/iwl_rx_pkt/ Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-3945.c | 14 +++++++------- drivers/net/wireless/iwlegacy/iwl-4965-lib.c | 4 ++-- drivers/net/wireless/iwlegacy/iwl-4965-rx.c | 6 +++--- drivers/net/wireless/iwlegacy/iwl-4965-tx.c | 2 +- drivers/net/wireless/iwlegacy/iwl-4965.c | 4 ++-- drivers/net/wireless/iwlegacy/iwl-4965.h | 2 +- drivers/net/wireless/iwlegacy/iwl-commands.h | 2 +- drivers/net/wireless/iwlegacy/iwl-core.c | 8 ++++---- drivers/net/wireless/iwlegacy/iwl-core.h | 4 ++-- drivers/net/wireless/iwlegacy/iwl-dev.h | 4 ++-- drivers/net/wireless/iwlegacy/iwl-hcmd.c | 4 ++-- drivers/net/wireless/iwlegacy/iwl-rx.c | 2 +- drivers/net/wireless/iwlegacy/iwl-scan.c | 12 ++++++------ drivers/net/wireless/iwlegacy/iwl-sta.c | 12 ++++++------ drivers/net/wireless/iwlegacy/iwl-tx.c | 2 +- drivers/net/wireless/iwlegacy/iwl3945-base.c | 14 +++++++------- drivers/net/wireless/iwlegacy/iwl4965-base.c | 8 ++++---- 17 files changed, 52 insertions(+), 52 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index 78e81b632280..98c74e09510c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -304,7 +304,7 @@ static void il3945_tx_queue_reclaim(struct il_priv *il, static void il3945_rx_reply_tx(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); int index = SEQ_TO_INDEX(sequence); @@ -398,7 +398,7 @@ static void il3945_accumulative_statistics(struct il_priv *il, void il3945_hw_rx_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); D_RX("Statistics notification received (%d vs %d).\n", (int)sizeof(struct il3945_notif_statistics), @@ -413,7 +413,7 @@ void il3945_hw_rx_statistics(struct il_priv *il, void il3945_reply_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); __le32 *flag = (__le32 *)&pkt->u.raw; if (le32_to_cpu(*flag) & UCODE_STATISTICS_CLEAR_MSK) { @@ -459,7 +459,7 @@ static void il3945_pass_packet_to_mac80211(struct il_priv *il, struct il_rx_mem_buffer *rxb, struct ieee80211_rx_status *stats) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)IL_RX_DATA(pkt); struct il3945_rx_frame_hdr *rx_hdr = IL_RX_HDR(pkt); struct il3945_rx_frame_end *rx_end = IL_RX_END(pkt); @@ -510,7 +510,7 @@ static void il3945_rx_reply_rx(struct il_priv *il, { struct ieee80211_hdr *header; struct ieee80211_rx_status rx_status; - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il3945_rx_frame_stats *rx_stats = IL_RX_STATS(pkt); struct il3945_rx_frame_hdr *rx_hdr = IL_RX_HDR(pkt); struct il3945_rx_frame_end *rx_end = IL_RX_END(pkt); @@ -1654,7 +1654,7 @@ static int il3945_send_rxon_assoc(struct il_priv *il, struct il_rxon_context *ctx) { int rc = 0; - struct il_rx_packet *pkt; + struct il_rx_pkt *pkt; struct il3945_rxon_assoc_cmd rxon_assoc; struct il_host_cmd cmd = { .id = REPLY_RXON_ASSOC, @@ -1683,7 +1683,7 @@ static int il3945_send_rxon_assoc(struct il_priv *il, if (rc) return rc; - pkt = (struct il_rx_packet *)cmd.reply_page; + pkt = (struct il_rx_pkt *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { IL_ERR("Bad return from REPLY_RXON_ASSOC command\n"); rc = -EIO; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index 964d9bb314b7..da4ea244ca21 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -570,7 +570,7 @@ void il4965_rx_reply_rx(struct il_priv *il, { struct ieee80211_hdr *header; struct ieee80211_rx_status rx_status; - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_rx_phy_res *phy_res; __le32 rx_pkt_status; struct il_rx_mpdu_res_start *amsdu; @@ -688,7 +688,7 @@ void il4965_rx_reply_rx(struct il_priv *il, void il4965_rx_reply_rx_phy(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); il->_4965.last_phy_res_valid = true; memcpy(&il->_4965.last_phy_res, pkt->u.raw, sizeof(struct il_rx_phy_res)); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c index 2181ec071cd4..95b7b13ea0c8 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c @@ -45,7 +45,7 @@ void il4965_rx_missed_beacon_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_missed_beacon_notif *missed_beacon; missed_beacon = &pkt->u.missed_beacon; @@ -155,7 +155,7 @@ void il4965_rx_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb) { int change; - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); D_RX( "Statistics notification received (%d vs %d).\n", @@ -198,7 +198,7 @@ void il4965_rx_statistics(struct il_priv *il, void il4965_reply_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATISTICS_CLEAR_MSK) { #ifdef CONFIG_IWLEGACY_DEBUGFS diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index 5f6a4ba9cb1c..cbc6febd6582 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -1248,7 +1248,7 @@ void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, void il4965_rx_reply_compressed_ba(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_compressed_ba_resp *ba_resp = &pkt->u.compressed_ba; struct il_tx_queue *txq = NULL; struct il_ht_agg *agg; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index f3451714249b..4917b0de92db 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -1774,7 +1774,7 @@ static int il4965_get_ra_sta_id(struct il_priv *il, struct ieee80211_hdr *hdr) static void il4965_rx_reply_tx(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); int index = SEQ_TO_INDEX(sequence); @@ -1877,7 +1877,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, static void il4965_rx_beacon_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il4965_beacon_notif *beacon = (void *)pkt->u.raw; u8 rate __maybe_unused = il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.h b/drivers/net/wireless/iwlegacy/iwl-4965.h index 0b92c28a8f2a..4427462f29d2 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965.h @@ -173,7 +173,7 @@ u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant_idx, u8 valid); void il4965_rx_missed_beacon_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb); bool il4965_good_plcp_health(struct il_priv *il, - struct il_rx_packet *pkt); + struct il_rx_pkt *pkt); void il4965_rx_statistics(struct il_priv *il, struct il_rx_mem_buffer *rxb); void il4965_reply_statistics(struct il_priv *il, diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h index 61acafbaab31..d9873cbfa80d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ b/drivers/net/wireless/iwlegacy/iwl-commands.h @@ -3360,7 +3360,7 @@ struct il_led_cmd { * *****************************************************************************/ -struct il_rx_packet { +struct il_rx_pkt { /* * The first 4 bytes of the RX frame header contain both the RX frame * size and some flags. diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index 395918e2d726..e9ca265a4bb6 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -865,7 +865,7 @@ EXPORT_SYMBOL(il_chswitch_done); void il_rx_csa(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_csa_notification *csa = &(pkt->u.csa_notif); struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; @@ -1209,7 +1209,7 @@ void il_rx_pm_sleep_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_sleep_notification *sleep = &(pkt->u.sleep_notif); D_RX("sleep mode: %d, src: %d\n", sleep->pm_sleep_mode, sleep->pm_wakeup_src); @@ -1220,7 +1220,7 @@ EXPORT_SYMBOL(il_rx_pm_sleep_notif); void il_rx_pm_debug_statistics_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; D_RADIO("Dumping %d bytes of unhandled " "notification for %s:\n", len, @@ -1232,7 +1232,7 @@ EXPORT_SYMBOL(il_rx_pm_debug_statistics_notif); void il_rx_reply_error(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); IL_ERR("Error Reply type 0x%08X cmd %s (0x%02X) " "seq 0x%04X ser 0x%08X\n", diff --git a/drivers/net/wireless/iwlegacy/iwl-core.h b/drivers/net/wireless/iwlegacy/iwl-core.h index 487cebfb6ed0..f805ccf3ecd8 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.h +++ b/drivers/net/wireless/iwlegacy/iwl-core.h @@ -391,7 +391,7 @@ void il_tx_cmd_complete(struct il_priv *il, void il_rx_spectrum_measure_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb); void il_recover_from_statistics(struct il_priv *il, - struct il_rx_packet *pkt); + struct il_rx_pkt *pkt); void il_chswitch_done(struct il_priv *il, bool is_success); void il_rx_csa(struct il_priv *il, struct il_rx_mem_buffer *rxb); @@ -472,7 +472,7 @@ int il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, const void *data, void (*callback)(struct il_priv *il, struct il_device_cmd *cmd, - struct il_rx_packet *pkt)); + struct il_rx_pkt *pkt)); int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd); diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 0aa4a120e87c..4c7ccd589a1f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -108,7 +108,7 @@ struct il_cmd_meta { */ void (*callback)(struct il_priv *il, struct il_device_cmd *cmd, - struct il_rx_packet *pkt); + struct il_rx_pkt *pkt); /* The CMD_SIZE_HUGE flag bit indicates that the command * structure is stored at the end of the shared queue memory. */ @@ -323,7 +323,7 @@ struct il_host_cmd { unsigned long reply_page; void (*callback)(struct il_priv *il, struct il_device_cmd *cmd, - struct il_rx_packet *pkt); + struct il_rx_pkt *pkt); u32 flags; u16 len; u8 id; diff --git a/drivers/net/wireless/iwlegacy/iwl-hcmd.c b/drivers/net/wireless/iwlegacy/iwl-hcmd.c index 6ccd37fc42c1..e63777b2f6e9 100644 --- a/drivers/net/wireless/iwlegacy/iwl-hcmd.c +++ b/drivers/net/wireless/iwlegacy/iwl-hcmd.c @@ -92,7 +92,7 @@ EXPORT_SYMBOL(il_get_cmd_string); static void il_generic_cmd_callback(struct il_priv *il, struct il_device_cmd *cmd, - struct il_rx_packet *pkt) + struct il_rx_pkt *pkt) { if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { IL_ERR("Bad return from %s (0x%08X)\n", @@ -255,7 +255,7 @@ int il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, const void *data, void (*callback)(struct il_priv *il, struct il_device_cmd *cmd, - struct il_rx_packet *pkt)) + struct il_rx_pkt *pkt)) { struct il_host_cmd cmd = { .id = id, diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c index b2ec2a214caa..746b5a7e4e07 100644 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -213,7 +213,7 @@ EXPORT_SYMBOL(il_rx_queue_alloc); void il_rx_spectrum_measure_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_spectrum_notification *report = &(pkt->u.spectrum_notif); if (!report->state) { diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index e4e5fbb2c644..96c90e7d5c9f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -57,7 +57,7 @@ static int il_send_scan_abort(struct il_priv *il) { int ret; - struct il_rx_packet *pkt; + struct il_rx_pkt *pkt; struct il_host_cmd cmd = { .id = REPLY_SCAN_ABORT_CMD, .flags = CMD_WANT_SKB, @@ -77,7 +77,7 @@ static int il_send_scan_abort(struct il_priv *il) if (ret) return ret; - pkt = (struct il_rx_packet *)cmd.reply_page; + pkt = (struct il_rx_pkt *)cmd.reply_page; if (pkt->u.status != CAN_ABORT_STATUS) { /* The scan abort will return 1 for success or * 2 for "failure". A failure condition can be @@ -186,7 +186,7 @@ static void il_rx_reply_scan(struct il_priv *il, struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_scanreq_notification *notif = (struct il_scanreq_notification *)pkt->u.raw; @@ -198,7 +198,7 @@ static void il_rx_reply_scan(struct il_priv *il, static void il_rx_scan_start_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_scanstart_notification *notif = (struct il_scanstart_notification *)pkt->u.raw; il->scan_start_tsf = le32_to_cpu(notif->tsf_low); @@ -217,7 +217,7 @@ static void il_rx_scan_results_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_scanresults_notification *notif = (struct il_scanresults_notification *)pkt->u.raw; @@ -240,7 +240,7 @@ static void il_rx_scan_complete_notif(struct il_priv *il, { #ifdef CONFIG_IWLEGACY_DEBUG - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_scancomplete_notification *scan_notif = (void *)pkt->u.raw; #endif diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.c b/drivers/net/wireless/iwlegacy/iwl-sta.c index 68c43b08b2c1..3c354a8952ec 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-sta.c @@ -59,7 +59,7 @@ static void il_sta_ucode_activate(struct il_priv *il, u8 sta_id) static int il_process_add_sta_resp(struct il_priv *il, struct il_addsta_cmd *addsta, - struct il_rx_packet *pkt, + struct il_rx_pkt *pkt, bool sync) { u8 sta_id = addsta->sta.sta_id; @@ -126,7 +126,7 @@ static int il_process_add_sta_resp(struct il_priv *il, static void il_add_sta_callback(struct il_priv *il, struct il_device_cmd *cmd, - struct il_rx_packet *pkt) + struct il_rx_pkt *pkt) { struct il_addsta_cmd *addsta = (struct il_addsta_cmd *)cmd->cmd.payload; @@ -138,7 +138,7 @@ static void il_add_sta_callback(struct il_priv *il, int il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags) { - struct il_rx_packet *pkt = NULL; + struct il_rx_pkt *pkt = NULL; int ret = 0; u8 data[sizeof(*sta)]; struct il_host_cmd cmd = { @@ -165,7 +165,7 @@ int il_send_add_sta(struct il_priv *il, return ret; if (ret == 0) { - pkt = (struct il_rx_packet *)cmd.reply_page; + pkt = (struct il_rx_pkt *)cmd.reply_page; ret = il_process_add_sta_resp(il, sta, pkt, true); } il_free_pages(il, cmd.reply_page); @@ -414,7 +414,7 @@ static int il_send_remove_station(struct il_priv *il, const u8 *addr, int sta_id, bool temporary) { - struct il_rx_packet *pkt; + struct il_rx_pkt *pkt; int ret; unsigned long flags_spin; @@ -438,7 +438,7 @@ static int il_send_remove_station(struct il_priv *il, if (ret) return ret; - pkt = (struct il_rx_packet *)cmd.reply_page; + pkt = (struct il_rx_pkt *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { IL_ERR("Bad return from REPLY_REMOVE_STA (0x%08X)\n", pkt->hdr.flags); diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index 531205942f44..0e900a4acead 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -595,7 +595,7 @@ static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, void il_tx_cmd_complete(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); int index = SEQ_TO_INDEX(sequence); diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 2d1f22a53365..216c86fb0929 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -671,7 +671,7 @@ static int il3945_get_measurement(struct il_priv *il, u8 type) { struct il_spectrum_cmd spectrum; - struct il_rx_packet *pkt; + struct il_rx_pkt *pkt; struct il_host_cmd cmd = { .id = REPLY_SPECTRUM_MEASUREMENT_CMD, .data = (void *)&spectrum, @@ -716,7 +716,7 @@ static int il3945_get_measurement(struct il_priv *il, if (rc) return rc; - pkt = (struct il_rx_packet *)cmd.reply_page; + pkt = (struct il_rx_pkt *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { IL_ERR("Bad return from REPLY_RX_ON_ASSOC command\n"); rc = -EIO; @@ -747,7 +747,7 @@ static int il3945_get_measurement(struct il_priv *il, static void il3945_rx_reply_alive(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_alive_resp *palive; struct delayed_work *pwork; @@ -784,7 +784,7 @@ static void il3945_rx_reply_add_sta(struct il_priv *il, struct il_rx_mem_buffer *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); #endif D_RX("Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); @@ -793,7 +793,7 @@ static void il3945_rx_reply_add_sta(struct il_priv *il, static void il3945_rx_beacon_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il3945_beacon_notif *beacon = &(pkt->u.beacon_status); #ifdef CONFIG_IWLEGACY_DEBUG u8 rate = beacon->beacon_notify_hdr.rate; @@ -816,7 +816,7 @@ static void il3945_rx_beacon_notif(struct il_priv *il, static void il3945_rx_card_state_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); unsigned long status = il->status; @@ -1202,7 +1202,7 @@ int il3945_calc_db_from_ratio(int sig_ratio) static void il3945_rx_handle(struct il_priv *il) { struct il_rx_mem_buffer *rxb; - struct il_rx_packet *pkt; + struct il_rx_pkt *pkt; struct il_rx_queue *rxq = &il->rxq; u32 r, i; int reclaim; diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index ddf4200a95cf..d5f91800d32b 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -430,7 +430,7 @@ int il4965_hw_tx_queue_init(struct il_priv *il, static void il4965_rx_reply_alive(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_alive_resp *palive; struct delayed_work *pwork; @@ -490,7 +490,7 @@ static void il4965_bg_statistics_periodic(unsigned long data) static void il4965_rx_beacon_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); struct il4965_beacon_notif *beacon = (struct il4965_beacon_notif *)pkt->u.raw; #ifdef CONFIG_IWLEGACY_DEBUG @@ -532,7 +532,7 @@ static void il4965_perform_ct_kill_task(struct il_priv *il) static void il4965_rx_card_state_notif(struct il_priv *il, struct il_rx_mem_buffer *rxb) { - struct il_rx_packet *pkt = rxb_addr(rxb); + struct il_rx_pkt *pkt = rxb_addr(rxb); u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); unsigned long status = il->status; @@ -634,7 +634,7 @@ static void il4965_setup_rx_handlers(struct il_priv *il) void il4965_rx_handle(struct il_priv *il) { struct il_rx_mem_buffer *rxb; - struct il_rx_packet *pkt; + struct il_rx_pkt *pkt; struct il_rx_queue *rxq = &il->rxq; u32 r, i; int reclaim; -- cgit v1.2.3 From 7c2cde2ef278cb833581fe599c6654fc28b11a7e Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 11:29:04 +0100 Subject: iwlegacy: partial rxon context cleanup Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-3945-rs.c | 6 +- drivers/net/wireless/iwlegacy/iwl-3945.c | 30 ++++----- drivers/net/wireless/iwlegacy/iwl-4965-calib.c | 2 +- drivers/net/wireless/iwlegacy/iwl-4965-lib.c | 4 +- drivers/net/wireless/iwlegacy/iwl-4965-tx.c | 4 +- drivers/net/wireless/iwlegacy/iwl-4965.c | 14 ++--- drivers/net/wireless/iwlegacy/iwl-core.c | 17 +++--- drivers/net/wireless/iwlegacy/iwl-debugfs.c | 6 +- drivers/net/wireless/iwlegacy/iwl-dev.h | 27 +++------ drivers/net/wireless/iwlegacy/iwl-rx.c | 2 +- drivers/net/wireless/iwlegacy/iwl3945-base.c | 84 ++++++++++++-------------- drivers/net/wireless/iwlegacy/iwl4965-base.c | 54 +++++++---------- 12 files changed, 111 insertions(+), 139 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c index 345beb7d3e83..070730183c9c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c @@ -342,7 +342,7 @@ void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_i int i; D_INFO("enter\n"); - if (sta_id == il->contexts[IL_RXON_CTX_BSS].bcast_sta_id) + if (sta_id == il->ctx.bcast_sta_id) goto out; psta = (struct il3945_sta_priv *) sta->drv_priv; @@ -936,7 +936,7 @@ void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) rcu_read_lock(); - sta = ieee80211_find_sta(il->contexts[IL_RXON_CTX_BSS].vif, + sta = ieee80211_find_sta(il->ctx.vif, il->stations[sta_id].sta.sta.addr); if (!sta) { D_RATE("Unable to find station to initialize rate scaling.\n"); @@ -953,7 +953,7 @@ void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) switch (il->band) { case IEEE80211_BAND_2GHZ: /* TODO: this always does G, not a regression */ - if (il->contexts[IL_RXON_CTX_BSS].active.flags & + if (il->ctx.active.flags & RXON_FLG_TGG_PROTECT_MSK) { rs_sta->tgg = 1; rs_sta->expected_tpt = il3945_expected_tpt_g_prot; diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index 98c74e09510c..ff006e7ba6a5 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -253,7 +253,7 @@ int il3945_rs_next_rate(struct il_priv *il, int rate) break; case IEEE80211_BAND_2GHZ: if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && - il_is_associated(il, IL_RXON_CTX_BSS)) { + il_is_associated(il)) { if (rate == IL_RATE_11M_INDEX) next_rate = IL_RATE_5M_INDEX; } @@ -1374,7 +1374,7 @@ static int il3945_send_tx_power(struct il_priv *il) int rate_idx, i; const struct il_channel_info *ch_info = NULL; struct il3945_txpowertable_cmd txpower = { - .channel = il->contexts[IL_RXON_CTX_BSS].active.channel, + .channel = il->ctx.active.channel, }; u16 chan; @@ -1382,7 +1382,7 @@ static int il3945_send_tx_power(struct il_priv *il) "TX Power requested while scanning!\n")) return -EAGAIN; - chan = le16_to_cpu(il->contexts[IL_RXON_CTX_BSS].active.channel); + chan = le16_to_cpu(il->ctx.active.channel); txpower.band = (il->band == IEEE80211_BAND_5GHZ) ? 0 : 1; ch_info = il_get_channel_info(il, il->band, chan); @@ -1734,9 +1734,9 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) * il3945_rxon_assoc_cmd which is used to reconfigure filter * and other flags for the current radio configuration. */ if (!il_full_rxon_required(il, - &il->contexts[IL_RXON_CTX_BSS])) { + &il->ctx)) { rc = il_send_rxon_assoc(il, - &il->contexts[IL_RXON_CTX_BSS]); + &il->ctx); if (rc) { IL_ERR("Error setting RXON_ASSOC " "configuration (%d).\n", rc); @@ -1756,7 +1756,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) * an RXON_ASSOC and the new config wants the associated mask enabled, * we must clear the associated from the active configuration * before we apply the new config */ - if (il_is_associated(il, IL_RXON_CTX_BSS) && new_assoc) { + if (il_is_associated(il) && new_assoc) { D_INFO("Toggling associated bit on current RXON\n"); active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; @@ -1768,7 +1768,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) active_rxon->reserved5 = 0; rc = il_send_cmd_pdu(il, REPLY_RXON, sizeof(struct il3945_rxon_cmd), - &il->contexts[IL_RXON_CTX_BSS].active); + &il->ctx.active); /* If the mask clearing failed then we set * active_rxon back to what it was previously */ @@ -1779,9 +1779,9 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) return rc; } il_clear_ucode_stations(il, - &il->contexts[IL_RXON_CTX_BSS]); + &il->ctx); il_restore_stations(il, - &il->contexts[IL_RXON_CTX_BSS]); + &il->ctx); } D_INFO("Sending RXON\n" @@ -1814,9 +1814,9 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) if (!new_assoc) { il_clear_ucode_stations(il, - &il->contexts[IL_RXON_CTX_BSS]); + &il->ctx); il_restore_stations(il, - &il->contexts[IL_RXON_CTX_BSS]); + &il->ctx); } /* If we issue a new RXON command which required a tune then we must @@ -2252,7 +2252,7 @@ static u16 il3945_build_addsta_hcmd(const struct il_addsta_cmd *cmd, static int il3945_add_bssid_station(struct il_priv *il, const u8 *addr, u8 *sta_id_r) { - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; int ret; u8 sta_id; unsigned long flags; @@ -2346,7 +2346,7 @@ int il3945_init_hw_rate_table(struct il_priv *il) * 1M CCK rates */ if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && - il_is_associated(il, IL_RXON_CTX_BSS)) { + il_is_associated(il)) { index = IL_FIRST_CCK_RATE; for (i = IL_RATE_6M_INDEX_TABLE; @@ -2401,7 +2401,7 @@ int il3945_hw_set_hw_params(struct il_priv *il) il->hw_params.max_rxq_size = RX_QUEUE_SIZE; il->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; il->hw_params.max_stations = IL3945_STATION_COUNT; - il->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IL3945_BROADCAST_ID; + il->ctx.bcast_sta_id = IL3945_BROADCAST_ID; il->sta_key_max_num = STA_KEY_MAX_NUM; @@ -2422,7 +2422,7 @@ unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); tx_beacon_cmd->tx.sta_id = - il->contexts[IL_RXON_CTX_BSS].bcast_sta_id; + il->ctx.bcast_sta_id; tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; frame_size = il3945_fill_beacon_frame(il, diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c index c055a153f7df..4c2b491b4c27 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c @@ -820,7 +820,7 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) unsigned long flags; struct statistics_rx_non_phy *rx_info; - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; if (il->disable_chain_noise_cal) return; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index da4ea244ca21..1182bc0f54b7 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -782,7 +782,7 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) .flags = CMD_SIZE_HUGE, }; struct il_scan_cmd *scan; - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; u32 rate_flags = 0; u16 cmd_len; u16 rx_chain = 0; @@ -866,7 +866,7 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) case IEEE80211_BAND_2GHZ: scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; chan_mod = le32_to_cpu( - il->contexts[IL_RXON_CTX_BSS].active.flags & + il->ctx.active.flags & RXON_FLG_CHANNEL_MODE_MSK) >> RXON_FLG_CHANNEL_MODE_POS; if (chan_mod == CHANNEL_MODE_PURE_40) { diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index cbc6febd6582..94d77e2003ae 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -277,7 +277,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) struct il_device_cmd *out_cmd; struct il_cmd_meta *out_meta; struct il_tx_cmd *tx_cmd; - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; int txq_id; dma_addr_t phys_addr; dma_addr_t txcmd_phys; @@ -1041,7 +1041,7 @@ int il4965_txq_check_empty(struct il_priv *il, struct il_tid_data *tid_data = &il->stations[sta_id].tid[tid]; struct il_rxon_context *ctx; - ctx = &il->contexts[il->stations[sta_id].ctxid]; + ctx = &il->ctx; lockdep_assert_held(&il->sta_lock); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index 4917b0de92db..457aa4077120 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -403,7 +403,7 @@ static int il4965_hw_set_hw_params(struct il_priv *il) sizeof(struct il4965_scd_bc_tbl); il->hw_params.tfd_size = sizeof(struct il_tfd); il->hw_params.max_stations = IL4965_STATION_COUNT; - il->contexts[IL_RXON_CTX_BSS].bcast_sta_id = IL4965_BROADCAST_ID; + il->ctx.bcast_sta_id = IL4965_BROADCAST_ID; il->hw_params.max_data_size = IL49_RTC_DATA_SIZE; il->hw_params.max_inst_size = IL49_RTC_INST_SIZE; il->hw_params.max_bsm_size = BSM_SRAM_SIZE; @@ -1121,7 +1121,7 @@ static int il4965_send_tx_power(struct il_priv *il) u8 band = 0; bool is_ht40 = false; u8 ctrl_chan_high = 0; - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &il->status), "TX Power requested while scanning!\n")) @@ -1333,7 +1333,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) static int il4965_hw_channel_switch(struct il_priv *il, struct ieee80211_channel_switch *ch_switch) { - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; int rc; u8 band = 0; bool is_ht40 = false; @@ -1726,7 +1726,7 @@ static u8 il4965_find_station(struct il_priv *il, const u8 *addr) start = IL_STA_ID; if (is_broadcast_ether_addr(addr)) - return il->contexts[IL_RXON_CTX_BSS].bcast_sta_id; + return il->ctx.bcast_sta_id; spin_lock_irqsave(&il->sta_lock, flags); for (i = start; i < il->hw_params.max_stations; i++) @@ -1911,7 +1911,7 @@ static struct il_hcmd_ops il4965_hcmd = { static void il4965_post_scan(struct il_priv *il) { - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; /* * Since setting the RXON may have been deferred while @@ -1923,7 +1923,7 @@ static void il4965_post_scan(struct il_priv *il) static void il4965_post_associate(struct il_priv *il) { - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; struct ieee80211_vif *vif = ctx->vif; struct ieee80211_conf *conf = NULL; int ret = 0; @@ -2000,7 +2000,7 @@ static void il4965_post_associate(struct il_priv *il) static void il4965_config_ap(struct il_priv *il) { - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; struct ieee80211_vif *vif = ctx->vif; int ret = 0; diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index e9ca265a4bb6..7afdd802b33f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -853,7 +853,7 @@ EXPORT_SYMBOL(il_set_rate); void il_chswitch_done(struct il_priv *il, bool is_success) { - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; if (test_bit(STATUS_EXIT_PENDING, &il->status)) return; @@ -868,7 +868,7 @@ void il_rx_csa(struct il_priv *il, struct il_rx_mem_buffer *rxb) struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_csa_notification *csa = &(pkt->u.csa_notif); - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; struct il_rxon_cmd *rxon = (void *)&ctx->active; if (!test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status)) @@ -933,7 +933,7 @@ void il_irq_handle_error(struct il_priv *il) #ifdef CONFIG_IWLEGACY_DEBUG if (il_get_debug_level(il) & IL_DL_FW_ERRORS) il_print_rx_config_cmd(il, - &il->contexts[IL_RXON_CTX_BSS]); + &il->ctx); #endif wake_up(&il->wait_command_queue); @@ -1110,7 +1110,7 @@ int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) int ret; s8 prev_tx_power; bool defer; - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; lockdep_assert_held(&il->mutex); @@ -2069,7 +2069,7 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) int ret = 0; u16 ch; int scan_active = 0; - bool ht_changed[NUM_IL_RXON_CTX] = {}; + bool ht_changed = false; if (WARN_ON(!il->cfg->ops->legacy)) return -EOPNOTSUPP; @@ -2129,7 +2129,7 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) /* Configure HT40 channels */ if (ctx->ht.enabled != conf_is_ht(conf)) { ctx->ht.enabled = conf_is_ht(conf); - ht_changed[ctx->ctxid] = true; + ht_changed = true; } if (ctx->ht.enabled) { if (conf_is_ht40_minus(conf)) { @@ -2209,7 +2209,7 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) else D_INFO( "Not re-sending same RXON configuration.\n"); - if (ht_changed[ctx->ctxid]) + if (ht_changed) il_update_qos(il, ctx); } @@ -2225,8 +2225,7 @@ void il_mac_reset_tsf(struct ieee80211_hw *hw, { struct il_priv *il = hw->priv; unsigned long flags; - /* IBSS can only be the IL_RXON_CTX_BSS context */ - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; if (WARN_ON(!il->cfg->ops->legacy)) return; diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index 736b00bc7bfb..a4b1f37f48e5 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -601,7 +601,7 @@ il_dbgfs_qos_read(struct file *file, char __user *user_buf, struct il_priv *il = file->private_data; struct il_rxon_context *ctx; int pos = 0, i; - char buf[256 * NUM_IL_RXON_CTX]; + char buf[256]; const size_t bufsz = sizeof(buf); for_each_context(il, ctx) { @@ -1064,7 +1064,7 @@ static ssize_t il_dbgfs_rxon_flags_read(struct file *file, char buf[20]; len = sprintf(buf, "0x%04X\n", - le32_to_cpu(il->contexts[IL_RXON_CTX_BSS].active.flags)); + le32_to_cpu(il->ctx.active.flags)); return simple_read_from_buffer(user_buf, count, ppos, buf, len); } @@ -1077,7 +1077,7 @@ static ssize_t il_dbgfs_rxon_filter_flags_read(struct file *file, char buf[20]; len = sprintf(buf, "0x%04X\n", - le32_to_cpu(il->contexts[IL_RXON_CTX_BSS].active.filter_flags)); + le32_to_cpu(il->ctx.active.filter_flags)); return simple_read_from_buffer(user_buf, count, ppos, buf, len); } diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 4c7ccd589a1f..d15dcbd40086 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -899,12 +899,6 @@ struct il_force_reset { */ #define IL4965_EXT_BEACON_TIME_POS 22 -enum il_rxon_context_id { - IL_RXON_CTX_BSS, - - NUM_IL_RXON_CTX -}; - struct il_rxon_context { struct ieee80211_vif *vif; @@ -921,7 +915,7 @@ struct il_rxon_context { bool ht_need_multiple_chains; - enum il_rxon_context_id ctxid; + int ctxid; u32 interface_modes, exclusive_interface_modes; u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype; @@ -1029,9 +1023,6 @@ struct il_priv { u32 hw_wa_rev; u8 rev_id; - /* microcode/device supports multiple contexts */ - u8 valid_contexts; - /* command queue number */ u8 cmd_queue; @@ -1055,7 +1046,7 @@ struct il_priv { u8 ucode_write_complete; /* the image write is complete */ char firmware_name[25]; - struct il_rxon_context contexts[NUM_IL_RXON_CTX]; + struct il_rxon_context ctx; __le16 switch_channel; @@ -1298,21 +1289,17 @@ il_rxon_ctx_from_vif(struct ieee80211_vif *vif) return vif_priv->ctx; } -#define for_each_context(il, ctx) \ - for (ctx = &il->contexts[IL_RXON_CTX_BSS]; \ - ctx < &il->contexts[NUM_IL_RXON_CTX]; ctx++) \ - if (il->valid_contexts & BIT(ctx->ctxid)) +#define for_each_context(il, _ctx) \ + for (_ctx = &il->ctx; _ctx == &il->ctx; _ctx++) -static inline int il_is_associated(struct il_priv *il, - enum il_rxon_context_id ctxid) +static inline int il_is_associated(struct il_priv *il) { - return (il->contexts[ctxid].active.filter_flags & - RXON_FILTER_ASSOC_MSK) ? 1 : 0; + return (il->ctx.active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; } static inline int il_is_any_associated(struct il_priv *il) { - return il_is_associated(il, IL_RXON_CTX_BSS); + return il_is_associated(il); } static inline int il_is_associated_ctx(struct il_rxon_context *ctx) diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c index 746b5a7e4e07..2e7c87f6104f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -241,7 +241,7 @@ int il_set_decrypted_flag(struct il_priv *il, * All contexts have the same setting here due to it being * a module parameter, so OK to check any context. */ - if (il->contexts[IL_RXON_CTX_BSS].active.filter_flags & + if (il->ctx.active.filter_flags & RXON_FILTER_DIS_DECRYPT_MSK) return 0; diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 216c86fb0929..dd8ce29ce84b 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -144,7 +144,7 @@ static int il3945_set_ccmp_dynamic_key_info(struct il_priv *il, key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK); key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); - if (sta_id == il->contexts[IL_RXON_CTX_BSS].bcast_sta_id) + if (sta_id == il->ctx.bcast_sta_id) key_flags |= STA_KEY_MULTICAST_MSK; keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; @@ -318,7 +318,7 @@ unsigned int il3945_fill_beacon_frame(struct il_priv *il, int left) { - if (!il_is_associated(il, IL_RXON_CTX_BSS) || !il->beacon_skb) + if (!il_is_associated(il) || !il->beacon_skb) return 0; if (il->beacon_skb->len > left) @@ -345,7 +345,7 @@ static int il3945_send_beacon_cmd(struct il_priv *il) } rate = il_get_lowest_plcp(il, - &il->contexts[IL_RXON_CTX_BSS]); + &il->ctx); frame_size = il3945_hw_get_beacon_cmd(il, frame, rate); @@ -515,7 +515,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) /* Find index into station table for destination station */ sta_id = il_sta_id_or_broadcast( - il, &il->contexts[IL_RXON_CTX_BSS], + il, &il->ctx, info->control.sta); if (sta_id == IL_INVALID_STATION) { D_DROP("Dropping - INVALID STATION: %pM\n", @@ -546,7 +546,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) /* Set up driver data for this TFD */ memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct il_tx_info)); txq->txb[q->write_ptr].skb = skb; - txq->txb[q->write_ptr].ctx = &il->contexts[IL_RXON_CTX_BSS]; + txq->txb[q->write_ptr].ctx = &il->ctx; /* Init first empty entry in queue's array of Tx/cmd buffers */ out_cmd = txq->cmd[idx]; @@ -681,9 +681,9 @@ static int il3945_get_measurement(struct il_priv *il, int rc; int spectrum_resp_status; int duration = le16_to_cpu(params->duration); - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; - if (il_is_associated(il, IL_RXON_CTX_BSS)) + if (il_is_associated(il)) add_time = il_usecs_to_beacons(il, le64_to_cpu(params->start_time) - il->_3945.last_tsf, le16_to_cpu(ctx->timing.beacon_interval)); @@ -697,7 +697,7 @@ static int il3945_get_measurement(struct il_priv *il, cmd.len = sizeof(spectrum); spectrum.len = cpu_to_le16(cmd.len - sizeof(spectrum.len)); - if (il_is_associated(il, IL_RXON_CTX_BSS)) + if (il_is_associated(il)) spectrum.start_time = il_add_beacon_time(il, il->_3945.last_beacon_time, add_time, @@ -2189,7 +2189,7 @@ static void il3945_alive_start(struct il_priv *il) { int thermal_spin = 0; u32 rfkill; - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; D_INFO("Runtime Alive received.\n"); @@ -2243,7 +2243,7 @@ static void il3945_alive_start(struct il_priv *il) il_power_update_mode(il, true); - if (il_is_associated(il, IL_RXON_CTX_BSS)) { + if (il_is_associated(il)) { struct il3945_rxon_cmd *active_rxon = (struct il3945_rxon_cmd *)(&ctx->active); @@ -2372,7 +2372,7 @@ static void il3945_down(struct il_priv *il) static int il3945_alloc_bcast_station(struct il_priv *il) { - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; unsigned long flags; u8 sta_id; @@ -2581,7 +2581,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) scan->quiet_plcp_th = IL_PLCP_QUIET_THRESH; scan->quiet_time = IL_ACTIVE_QUIET_TIME; - if (il_is_associated(il, IL_RXON_CTX_BSS)) { + if (il_is_associated(il)) { u16 interval; u32 extra; u32 suspend_time = 100; @@ -2634,7 +2634,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) /* We don't build a direct scan probe request; the uCode will do * that based on the direct_mask added to each channel entry */ scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; - scan->tx_cmd.sta_id = il->contexts[IL_RXON_CTX_BSS].bcast_sta_id; + scan->tx_cmd.sta_id = il->ctx.bcast_sta_id; scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; /* flags + rate selection */ @@ -2692,7 +2692,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) void il3945_post_scan(struct il_priv *il) { - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; /* * Since setting the RXON may have been deferred while @@ -2750,7 +2750,7 @@ void il3945_post_associate(struct il_priv *il) { int rc = 0; struct ieee80211_conf *conf = NULL; - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; if (!ctx->vif || !il->is_open) return; @@ -2917,7 +2917,7 @@ static void il3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) void il3945_config_ap(struct il_priv *il) { - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; struct ieee80211_vif *vif = ctx->vif; int rc = 0; @@ -2925,7 +2925,7 @@ void il3945_config_ap(struct il_priv *il) return; /* The following should be done only at AP bring up */ - if (!(il_is_associated(il, IL_RXON_CTX_BSS))) { + if (!(il_is_associated(il))) { /* RXON - unassoc (to set timing command) */ ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; @@ -2986,11 +2986,11 @@ static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) return -EOPNOTSUPP; - static_key = !il_is_associated(il, IL_RXON_CTX_BSS); + static_key = !il_is_associated(il); if (!static_key) { sta_id = il_sta_id_or_broadcast( - il, &il->contexts[IL_RXON_CTX_BSS], sta); + il, &il->ctx, sta); if (sta_id == IL_INVALID_STATION) return -EINVAL; } @@ -3042,7 +3042,7 @@ static int il3945_mac_sta_add(struct ieee80211_hw *hw, ret = il_add_station_common(il, - &il->contexts[IL_RXON_CTX_BSS], + &il->ctx, sta->addr, is_ap, sta, &sta_id); if (ret) { IL_ERR("Unable to add station %pM (%d)\n", @@ -3070,7 +3070,7 @@ static void il3945_configure_filter(struct ieee80211_hw *hw, { struct il_priv *il = hw->priv; __le32 filter_or = 0, filter_nand = 0; - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; #define CHK(test, flag) do { \ if (*total_flags & (test)) \ @@ -3205,7 +3205,7 @@ static ssize_t il3945_show_flags(struct device *d, struct device_attribute *attr, char *buf) { struct il_priv *il = dev_get_drvdata(d); - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; return sprintf(buf, "0x%04X\n", ctx->active.flags); } @@ -3216,7 +3216,7 @@ static ssize_t il3945_store_flags(struct device *d, { struct il_priv *il = dev_get_drvdata(d); u32 flags = simple_strtoul(buf, NULL, 0); - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; mutex_lock(&il->mutex); if (le32_to_cpu(ctx->staging.flags) != flags) { @@ -3241,7 +3241,7 @@ static ssize_t il3945_show_filter_flags(struct device *d, struct device_attribute *attr, char *buf) { struct il_priv *il = dev_get_drvdata(d); - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; return sprintf(buf, "0x%04X\n", le32_to_cpu(ctx->active.filter_flags)); @@ -3252,7 +3252,7 @@ static ssize_t il3945_store_filter_flags(struct device *d, const char *buf, size_t count) { struct il_priv *il = dev_get_drvdata(d); - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; u32 filter_flags = simple_strtoul(buf, NULL, 0); mutex_lock(&il->mutex); @@ -3313,7 +3313,7 @@ static ssize_t il3945_store_measurement(struct device *d, const char *buf, size_t count) { struct il_priv *il = dev_get_drvdata(d); - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; struct ieee80211_measurement_params params = { .channel = le16_to_cpu(ctx->active.channel), .start_time = cpu_to_le64(il->_3945.last_tsf), @@ -3599,7 +3599,7 @@ static int il3945_setup_mac(struct il_priv *il) IEEE80211_HW_SPECTRUM_MGMT; hw->wiphy->interface_modes = - il->contexts[IL_RXON_CTX_BSS].interface_modes; + il->ctx.interface_modes; hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | WIPHY_FLAG_DISABLE_BEACON_HINTS | @@ -3634,7 +3634,7 @@ static int il3945_setup_mac(struct il_priv *il) static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { - int err = 0, i; + int err = 0; struct il_priv *il; struct ieee80211_hw *hw; struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data); @@ -3658,24 +3658,20 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en il->cmd_queue = IL39_CMD_QUEUE_NUM; - /* 3945 has only one valid context */ - il->valid_contexts = BIT(IL_RXON_CTX_BSS); + il->ctx.ctxid = 0; - for (i = 0; i < NUM_IL_RXON_CTX; i++) - il->contexts[i].ctxid = i; - - il->contexts[IL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON; - il->contexts[IL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING; - il->contexts[IL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC; - il->contexts[IL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM; - il->contexts[IL_RXON_CTX_BSS].ap_sta_id = IL_AP_ID; - il->contexts[IL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY; - il->contexts[IL_RXON_CTX_BSS].interface_modes = + il->ctx.rxon_cmd = REPLY_RXON; + il->ctx.rxon_timing_cmd = REPLY_RXON_TIMING; + il->ctx.rxon_assoc_cmd = REPLY_RXON_ASSOC; + il->ctx.qos_cmd = REPLY_QOS_PARAM; + il->ctx.ap_sta_id = IL_AP_ID; + il->ctx.wep_key_cmd = REPLY_WEPKEY; + il->ctx.interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC); - il->contexts[IL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS; - il->contexts[IL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS; - il->contexts[IL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS; + il->ctx.ibss_devtype = RXON_DEV_TYPE_IBSS; + il->ctx.station_devtype = RXON_DEV_TYPE_ESS; + il->ctx.unused_devtype = RXON_DEV_TYPE_ESS; /* * Disabling hardware scan means that mac80211 will perform scans @@ -3812,7 +3808,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en il_set_rxon_channel(il, &il->bands[IEEE80211_BAND_2GHZ].channels[5], - &il->contexts[IL_RXON_CTX_BSS]); + &il->ctx); il3945_setup_deferred_work(il); il3945_setup_rx_handlers(il); il_power_initialize(il); diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index d5f91800d32b..131d6e920195 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -1717,7 +1717,7 @@ static int il4965_alive_notify(struct il_priv *il) static void il4965_alive_start(struct il_priv *il) { int ret = 0; - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; D_INFO("Runtime Alive received.\n"); @@ -2502,7 +2502,7 @@ void il4965_mac_channel_switch(struct ieee80211_hw *hw, struct ieee80211_channel *channel = ch_switch->channel; struct il_ht_config *ht_conf = &il->current_ht_config; - struct il_rxon_context *ctx = &il->contexts[IL_RXON_CTX_BSS]; + struct il_rxon_context *ctx = &il->ctx; u16 ch; D_MAC80211("enter\n"); @@ -2786,7 +2786,7 @@ static int il4965_init_drv(struct il_priv *il) /* Choose which receivers/antennas to use */ if (il->cfg->ops->hcmd->set_rxon_chain) il->cfg->ops->hcmd->set_rxon_chain(il, - &il->contexts[IL_RXON_CTX_BSS]); + &il->ctx); il_init_scan_params(il); @@ -2859,7 +2859,7 @@ static const u8 il4965_bss_ac_to_queue[] = { static int il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { - int err = 0, i; + int err = 0; struct il_priv *il; struct ieee80211_hw *hw; struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data); @@ -2878,36 +2878,26 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) il = hw->priv; /* At this point both hw and il are allocated. */ - /* - * The default context is always valid, - * more may be discovered when firmware - * is loaded. - */ - il->valid_contexts = BIT(IL_RXON_CTX_BSS); - - for (i = 0; i < NUM_IL_RXON_CTX; i++) - il->contexts[i].ctxid = i; - - il->contexts[IL_RXON_CTX_BSS].always_active = true; - il->contexts[IL_RXON_CTX_BSS].is_active = true; - il->contexts[IL_RXON_CTX_BSS].rxon_cmd = REPLY_RXON; - il->contexts[IL_RXON_CTX_BSS].rxon_timing_cmd = REPLY_RXON_TIMING; - il->contexts[IL_RXON_CTX_BSS].rxon_assoc_cmd = REPLY_RXON_ASSOC; - il->contexts[IL_RXON_CTX_BSS].qos_cmd = REPLY_QOS_PARAM; - il->contexts[IL_RXON_CTX_BSS].ap_sta_id = IL_AP_ID; - il->contexts[IL_RXON_CTX_BSS].wep_key_cmd = REPLY_WEPKEY; - il->contexts[IL_RXON_CTX_BSS].ac_to_fifo = il4965_bss_ac_to_fifo; - il->contexts[IL_RXON_CTX_BSS].ac_to_queue = il4965_bss_ac_to_queue; - il->contexts[IL_RXON_CTX_BSS].exclusive_interface_modes = + il->ctx.ctxid = 0; + + il->ctx.always_active = true; + il->ctx.is_active = true; + il->ctx.rxon_cmd = REPLY_RXON; + il->ctx.rxon_timing_cmd = REPLY_RXON_TIMING; + il->ctx.rxon_assoc_cmd = REPLY_RXON_ASSOC; + il->ctx.qos_cmd = REPLY_QOS_PARAM; + il->ctx.ap_sta_id = IL_AP_ID; + il->ctx.wep_key_cmd = REPLY_WEPKEY; + il->ctx.ac_to_fifo = il4965_bss_ac_to_fifo; + il->ctx.ac_to_queue = il4965_bss_ac_to_queue; + il->ctx.exclusive_interface_modes = BIT(NL80211_IFTYPE_ADHOC); - il->contexts[IL_RXON_CTX_BSS].interface_modes = + il->ctx.interface_modes = BIT(NL80211_IFTYPE_STATION); - il->contexts[IL_RXON_CTX_BSS].ap_devtype = RXON_DEV_TYPE_AP; - il->contexts[IL_RXON_CTX_BSS].ibss_devtype = RXON_DEV_TYPE_IBSS; - il->contexts[IL_RXON_CTX_BSS].station_devtype = RXON_DEV_TYPE_ESS; - il->contexts[IL_RXON_CTX_BSS].unused_devtype = RXON_DEV_TYPE_ESS; - - BUILD_BUG_ON(NUM_IL_RXON_CTX != 1); + il->ctx.ap_devtype = RXON_DEV_TYPE_AP; + il->ctx.ibss_devtype = RXON_DEV_TYPE_IBSS; + il->ctx.station_devtype = RXON_DEV_TYPE_ESS; + il->ctx.unused_devtype = RXON_DEV_TYPE_ESS; SET_IEEE80211_DEV(hw, &pdev->dev); -- cgit v1.2.3 From b73bb5f13bb60735a846b73125e297ab6e3eece5 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 26 Aug 2011 14:37:54 +0200 Subject: iwlegacy: s/il_rx_mem_buffer/il_rx_buf/ Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-3945.c | 10 +++++----- drivers/net/wireless/iwlegacy/iwl-3945.h | 4 ++-- drivers/net/wireless/iwlegacy/iwl-4965-lib.c | 14 +++++++------- drivers/net/wireless/iwlegacy/iwl-4965-rx.c | 6 +++--- drivers/net/wireless/iwlegacy/iwl-4965-tx.c | 2 +- drivers/net/wireless/iwlegacy/iwl-4965.c | 4 ++-- drivers/net/wireless/iwlegacy/iwl-4965.h | 12 ++++++------ drivers/net/wireless/iwlegacy/iwl-core.c | 8 ++++---- drivers/net/wireless/iwlegacy/iwl-core.h | 12 ++++++------ drivers/net/wireless/iwlegacy/iwl-dev.h | 10 +++++----- drivers/net/wireless/iwlegacy/iwl-rx.c | 4 ++-- drivers/net/wireless/iwlegacy/iwl-scan.c | 8 ++++---- drivers/net/wireless/iwlegacy/iwl-tx.c | 2 +- drivers/net/wireless/iwlegacy/iwl3945-base.c | 20 ++++++++++---------- drivers/net/wireless/iwlegacy/iwl4965-base.c | 8 ++++---- 15 files changed, 62 insertions(+), 62 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index ff006e7ba6a5..ad78d3fb76f0 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -302,7 +302,7 @@ static void il3945_tx_queue_reclaim(struct il_priv *il, * il3945_rx_reply_tx - Handle Tx response */ static void il3945_rx_reply_tx(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); @@ -396,7 +396,7 @@ static void il3945_accumulative_statistics(struct il_priv *il, #endif void il3945_hw_rx_statistics(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -411,7 +411,7 @@ void il3945_hw_rx_statistics(struct il_priv *il, } void il3945_reply_statistics(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); __le32 *flag = (__le32 *)&pkt->u.raw; @@ -456,7 +456,7 @@ static int il3945_is_network_packet(struct il_priv *il, } static void il3945_pass_packet_to_mac80211(struct il_priv *il, - struct il_rx_mem_buffer *rxb, + struct il_rx_buf *rxb, struct ieee80211_rx_status *stats) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -506,7 +506,7 @@ static void il3945_pass_packet_to_mac80211(struct il_priv *il, #define IL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6) static void il3945_rx_reply_rx(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct ieee80211_hdr *header; struct ieee80211_rx_status rx_status; diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.h b/drivers/net/wireless/iwlegacy/iwl-3945.h index 6c68f597f32f..8a294ca5d07a 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945.h @@ -259,9 +259,9 @@ void il3945_hw_build_tx_cmd_rate(struct il_priv *il, extern int il3945_hw_reg_send_txpower(struct il_priv *il); extern int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power); extern void il3945_hw_rx_statistics(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); void il3945_reply_statistics(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); extern void il3945_disable_events(struct il_priv *il); extern int il4965_get_temperature(const struct il_priv *il); extern void il3945_post_associate(struct il_priv *il); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index 1182bc0f54b7..57fc190ce675 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -230,7 +230,7 @@ void il4965_rx_queue_restock(struct il_priv *il) { struct il_rx_queue *rxq = &il->rxq; struct list_head *element; - struct il_rx_mem_buffer *rxb; + struct il_rx_buf *rxb; unsigned long flags; spin_lock_irqsave(&rxq->lock, flags); @@ -241,7 +241,7 @@ void il4965_rx_queue_restock(struct il_priv *il) /* Get next free Rx buffer, remove from free list */ element = rxq->rx_free.next; - rxb = list_entry(element, struct il_rx_mem_buffer, list); + rxb = list_entry(element, struct il_rx_buf, list); list_del(element); /* Point to Rx buffer via next RBD in circular buffer */ @@ -280,7 +280,7 @@ static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) { struct il_rx_queue *rxq = &il->rxq; struct list_head *element; - struct il_rx_mem_buffer *rxb; + struct il_rx_buf *rxb; struct page *page; unsigned long flags; gfp_t gfp_mask = priority; @@ -329,7 +329,7 @@ static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) return; } element = rxq->rx_used.next; - rxb = list_entry(element, struct il_rx_mem_buffer, list); + rxb = list_entry(element, struct il_rx_buf, list); list_del(element); spin_unlock_irqrestore(&rxq->lock, flags); @@ -529,7 +529,7 @@ static void il4965_pass_packet_to_mac80211(struct il_priv *il, struct ieee80211_hdr *hdr, u16 len, u32 ampdu_status, - struct il_rx_mem_buffer *rxb, + struct il_rx_buf *rxb, struct ieee80211_rx_status *stats) { struct sk_buff *skb; @@ -566,7 +566,7 @@ static void il4965_pass_packet_to_mac80211(struct il_priv *il, /* Called for REPLY_RX (legacy ABG frames), or * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */ void il4965_rx_reply_rx(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct ieee80211_hdr *header; struct ieee80211_rx_status rx_status; @@ -686,7 +686,7 @@ void il4965_rx_reply_rx(struct il_priv *il, /* Cache phy data (Rx signal strength, etc) for HT frame (REPLY_RX_PHY_CMD). * This will be used later in il_rx_reply_rx() for REPLY_RX_MPDU_CMD. */ void il4965_rx_reply_rx_phy(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); il->_4965.last_phy_res_valid = true; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c index 95b7b13ea0c8..9ccec09c32be 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c @@ -42,7 +42,7 @@ #include "iwl-4965.h" void il4965_rx_missed_beacon_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -152,7 +152,7 @@ static void il4965_accumulative_statistics(struct il_priv *il, #define REG_RECALIB_PERIOD (60) void il4965_rx_statistics(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { int change; struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -196,7 +196,7 @@ void il4965_rx_statistics(struct il_priv *il, } void il4965_reply_statistics(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index 94d77e2003ae..dff48e89862e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -1246,7 +1246,7 @@ void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, * of frames sent via aggregation. */ void il4965_rx_reply_compressed_ba(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_compressed_ba_resp *ba_resp = &pkt->u.compressed_ba; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index 457aa4077120..5dd963e88643 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -1772,7 +1772,7 @@ static int il4965_get_ra_sta_id(struct il_priv *il, struct ieee80211_hdr *hdr) * il4965_rx_reply_tx - Handle standard (non-aggregation) Tx response */ static void il4965_rx_reply_tx(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); @@ -1875,7 +1875,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, } static void il4965_rx_beacon_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il4965_beacon_notif *beacon = (void *)pkt->u.raw; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.h b/drivers/net/wireless/iwlegacy/iwl-4965.h index 4427462f29d2..b5b27f45e99b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965.h @@ -100,9 +100,9 @@ void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq); int il4965_rxq_stop(struct il_priv *il); int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); void il4965_rx_reply_rx(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); void il4965_rx_reply_rx_phy(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); void il4965_rx_handle(struct il_priv *il); /* tx */ @@ -122,7 +122,7 @@ int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, int il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id); void il4965_rx_reply_compressed_ba(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int index); void il4965_hw_txq_ctx_free(struct il_priv *il); int il4965_txq_ctx_alloc(struct il_priv *il); @@ -171,13 +171,13 @@ u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant_idx, u8 valid); /* rx */ void il4965_rx_missed_beacon_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); bool il4965_good_plcp_health(struct il_priv *il, struct il_rx_pkt *pkt); void il4965_rx_statistics(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); void il4965_reply_statistics(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); /* scan */ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif); diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index 7afdd802b33f..8feb2dde09b5 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -863,7 +863,7 @@ void il_chswitch_done(struct il_priv *il, bool is_success) } EXPORT_SYMBOL(il_chswitch_done); -void il_rx_csa(struct il_priv *il, struct il_rx_mem_buffer *rxb) +void il_rx_csa(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_csa_notification *csa = &(pkt->u.csa_notif); @@ -1206,7 +1206,7 @@ int il_send_statistics_request(struct il_priv *il, u8 flags, bool clear) EXPORT_SYMBOL(il_send_statistics_request); void il_rx_pm_sleep_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -1218,7 +1218,7 @@ void il_rx_pm_sleep_notif(struct il_priv *il, EXPORT_SYMBOL(il_rx_pm_sleep_notif); void il_rx_pm_debug_statistics_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; @@ -1230,7 +1230,7 @@ void il_rx_pm_debug_statistics_notif(struct il_priv *il, EXPORT_SYMBOL(il_rx_pm_debug_statistics_notif); void il_rx_reply_error(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); diff --git a/drivers/net/wireless/iwlegacy/iwl-core.h b/drivers/net/wireless/iwlegacy/iwl-core.h index f805ccf3ecd8..bc2ae06bf4a6 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.h +++ b/drivers/net/wireless/iwlegacy/iwl-core.h @@ -370,11 +370,11 @@ static inline void il_update_stats(struct il_priv *il, bool is_tx, * RX handlers. * **************************************************/ void il_rx_pm_sleep_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); void il_rx_pm_debug_statistics_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); void il_rx_reply_error(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); /***************************************************** * RX @@ -386,14 +386,14 @@ void il_rx_queue_update_write_ptr(struct il_priv *il, struct il_rx_queue *q); int il_rx_queue_space(const struct il_rx_queue *q); void il_tx_cmd_complete(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); /* Handlers */ void il_rx_spectrum_measure_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); void il_recover_from_statistics(struct il_priv *il, struct il_rx_pkt *pkt); void il_chswitch_done(struct il_priv *il, bool is_success); -void il_rx_csa(struct il_priv *il, struct il_rx_mem_buffer *rxb); +void il_rx_csa(struct il_priv *il, struct il_rx_buf *rxb); /* TX helpers */ diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index d15dcbd40086..ad72d3986147 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -85,7 +85,7 @@ struct il_tx_queue; #define DEFAULT_SHORT_RETRY_LIMIT 7U #define DEFAULT_LONG_RETRY_LIMIT 4U -struct il_rx_mem_buffer { +struct il_rx_buf { dma_addr_t page_dma; struct page *page; struct list_head list; @@ -346,13 +346,13 @@ struct il_host_cmd { * @rb_stts: driver's pointer to receive buffer status * @rb_stts_dma: bus address of receive buffer status * - * NOTE: rx_free and rx_used are used as a FIFO for il_rx_mem_buffers + * NOTE: rx_free and rx_used are used as a FIFO for il_rx_bufs */ struct il_rx_queue { __le32 *bd; dma_addr_t bd_dma; - struct il_rx_mem_buffer pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS]; - struct il_rx_mem_buffer *queue[RX_QUEUE_SIZE]; + struct il_rx_buf pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS]; + struct il_rx_buf *queue[RX_QUEUE_SIZE]; u32 read; u32 write; u32 free_count; @@ -968,7 +968,7 @@ struct il_priv { int alloc_rxb_page; void (*rx_handlers[REPLY_MAX])(struct il_priv *il, - struct il_rx_mem_buffer *rxb); + struct il_rx_buf *rxb); struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c index 2e7c87f6104f..a6bee8432798 100644 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -95,7 +95,7 @@ * are available, schedules il_rx_replenish * * -- enable interrupts -- - * ISR - il_rx() Detach il_rx_mem_buffers from pool up to the + * ISR - il_rx() Detach il_rx_bufs from pool up to the * READ INDEX, detaching the SKB from the pool. * Moves the packet buffer from queue to rx_used. * Calls il_rx_queue_restock to refill any empty @@ -211,7 +211,7 @@ EXPORT_SYMBOL(il_rx_queue_alloc); void il_rx_spectrum_measure_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_spectrum_notification *report = &(pkt->u.spectrum_notif); diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index 96c90e7d5c9f..dfc1431072b3 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -183,7 +183,7 @@ EXPORT_SYMBOL(il_scan_cancel_timeout); /* Service response to REPLY_SCAN_CMD (0x80) */ static void il_rx_reply_scan(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -196,7 +196,7 @@ static void il_rx_reply_scan(struct il_priv *il, /* Service SCAN_START_NOTIFICATION (0x82) */ static void il_rx_scan_start_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_scanstart_notification *notif = @@ -214,7 +214,7 @@ static void il_rx_scan_start_notif(struct il_priv *il, /* Service SCAN_RESULTS_NOTIFICATION (0x83) */ static void il_rx_scan_results_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -236,7 +236,7 @@ static void il_rx_scan_results_notif(struct il_priv *il, /* Service SCAN_COMPLETE_NOTIFICATION (0x84) */ static void il_rx_scan_complete_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index 0e900a4acead..2e95b7885c6d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -593,7 +593,7 @@ static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, * if the callback returns 1 */ void -il_tx_cmd_complete(struct il_priv *il, struct il_rx_mem_buffer *rxb) +il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index dd8ce29ce84b..446bdb5f8624 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -745,7 +745,7 @@ static int il3945_get_measurement(struct il_priv *il, } static void il3945_rx_reply_alive(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_alive_resp *palive; @@ -781,7 +781,7 @@ static void il3945_rx_reply_alive(struct il_priv *il, } static void il3945_rx_reply_add_sta(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -791,7 +791,7 @@ static void il3945_rx_reply_add_sta(struct il_priv *il, } static void il3945_rx_beacon_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il3945_beacon_notif *beacon = &(pkt->u.beacon_status); @@ -814,7 +814,7 @@ static void il3945_rx_beacon_notif(struct il_priv *il, /* Handle notification from uCode that card's power state is changing * due to software, hardware, or critical temperature RFKILL */ static void il3945_rx_card_state_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); @@ -935,7 +935,7 @@ static void il3945_setup_rx_handlers(struct il_priv *il) * are available, schedules il3945_rx_replenish * * -- enable interrupts -- - * ISR - il3945_rx() Detach il_rx_mem_buffers from pool up to the + * ISR - il3945_rx() Detach il_rx_bufs from pool up to the * READ INDEX, detaching the SKB from the pool. * Moves the packet buffer from queue to rx_used. * Calls il3945_rx_queue_restock to refill any empty @@ -968,7 +968,7 @@ static void il3945_rx_queue_restock(struct il_priv *il) { struct il_rx_queue *rxq = &il->rxq; struct list_head *element; - struct il_rx_mem_buffer *rxb; + struct il_rx_buf *rxb; unsigned long flags; int write; @@ -977,7 +977,7 @@ static void il3945_rx_queue_restock(struct il_priv *il) while (il_rx_queue_space(rxq) > 0 && rxq->free_count) { /* Get next free Rx buffer, remove from free list */ element = rxq->rx_free.next; - rxb = list_entry(element, struct il_rx_mem_buffer, list); + rxb = list_entry(element, struct il_rx_buf, list); list_del(element); /* Point to Rx buffer via next RBD in circular buffer */ @@ -1016,7 +1016,7 @@ static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) { struct il_rx_queue *rxq = &il->rxq; struct list_head *element; - struct il_rx_mem_buffer *rxb; + struct il_rx_buf *rxb; struct page *page; unsigned long flags; gfp_t gfp_mask = priority; @@ -1059,7 +1059,7 @@ static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) return; } element = rxq->rx_used.next; - rxb = list_entry(element, struct il_rx_mem_buffer, list); + rxb = list_entry(element, struct il_rx_buf, list); list_del(element); spin_unlock_irqrestore(&rxq->lock, flags); @@ -1201,7 +1201,7 @@ int il3945_calc_db_from_ratio(int sig_ratio) */ static void il3945_rx_handle(struct il_priv *il) { - struct il_rx_mem_buffer *rxb; + struct il_rx_buf *rxb; struct il_rx_pkt *pkt; struct il_rx_queue *rxq = &il->rxq; u32 r, i; diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index 131d6e920195..81613ed20449 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -428,7 +428,7 @@ int il4965_hw_tx_queue_init(struct il_priv *il, * ******************************************************************************/ static void il4965_rx_reply_alive(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_alive_resp *palive; @@ -488,7 +488,7 @@ static void il4965_bg_statistics_periodic(unsigned long data) } static void il4965_rx_beacon_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il4965_beacon_notif *beacon = @@ -530,7 +530,7 @@ static void il4965_perform_ct_kill_task(struct il_priv *il) /* Handle notification from uCode that card's power state is changing * due to software, hardware, or critical temperature RFKILL */ static void il4965_rx_card_state_notif(struct il_priv *il, - struct il_rx_mem_buffer *rxb) + struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); @@ -633,7 +633,7 @@ static void il4965_setup_rx_handlers(struct il_priv *il) */ void il4965_rx_handle(struct il_priv *il) { - struct il_rx_mem_buffer *rxb; + struct il_rx_buf *rxb; struct il_rx_pkt *pkt; struct il_rx_queue *rxq = &il->rxq; u32 r, i; -- cgit v1.2.3 From ebf0d90d12cf013019005a8ee7d1bc8599935356 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 26 Aug 2011 15:43:47 +0200 Subject: iwlegacy: s/statistics/stats/ Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c | 90 +++++++++--------- drivers/net/wireless/iwlegacy/iwl-3945-rs.c | 2 +- drivers/net/wireless/iwlegacy/iwl-3945.c | 44 ++++----- drivers/net/wireless/iwlegacy/iwl-3945.h | 6 +- drivers/net/wireless/iwlegacy/iwl-4965-calib.c | 36 ++++---- drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c | 94 +++++++++---------- drivers/net/wireless/iwlegacy/iwl-4965-hw.h | 4 +- drivers/net/wireless/iwlegacy/iwl-4965-rs.c | 4 +- drivers/net/wireless/iwlegacy/iwl-4965-rx.c | 66 ++++++------- drivers/net/wireless/iwlegacy/iwl-4965.c | 12 +-- drivers/net/wireless/iwlegacy/iwl-4965.h | 4 +- drivers/net/wireless/iwlegacy/iwl-commands.h | 112 +++++++++++------------ drivers/net/wireless/iwlegacy/iwl-core.c | 20 ++-- drivers/net/wireless/iwlegacy/iwl-core.h | 6 +- drivers/net/wireless/iwlegacy/iwl-debugfs.c | 28 +++--- drivers/net/wireless/iwlegacy/iwl-dev.h | 32 +++---- drivers/net/wireless/iwlegacy/iwl-legacy-rs.h | 2 +- drivers/net/wireless/iwlegacy/iwl-scan.c | 2 +- drivers/net/wireless/iwlegacy/iwl3945-base.c | 10 +- drivers/net/wireless/iwlegacy/iwl4965-base.c | 34 +++---- 20 files changed, 304 insertions(+), 304 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c index 40e3a7065f23..88b3d8fc38f8 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c @@ -29,22 +29,22 @@ #include "iwl-3945-debugfs.h" -static int il3945_statistics_flag(struct il_priv *il, char *buf, int bufsz) +static int il3945_stats_flag(struct il_priv *il, char *buf, int bufsz) { int p = 0; p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", - le32_to_cpu(il->_3945.statistics.flag)); - if (le32_to_cpu(il->_3945.statistics.flag) & + le32_to_cpu(il->_3945.stats.flag)); + if (le32_to_cpu(il->_3945.stats.flag) & UCODE_STATISTICS_CLEAR_MSK) p += scnprintf(buf + p, bufsz - p, "\tStatistics have been cleared\n"); p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n", - (le32_to_cpu(il->_3945.statistics.flag) & + (le32_to_cpu(il->_3945.stats.flag) & UCODE_STATISTICS_FREQUENCY_MSK) ? "2.4 GHz" : "5.2 GHz"); p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n", - (le32_to_cpu(il->_3945.statistics.flag) & + (le32_to_cpu(il->_3945.stats.flag) & UCODE_STATISTICS_NARROW_BAND_MSK) ? "enabled" : "disabled"); return p; @@ -57,14 +57,14 @@ ssize_t il3945_ucode_rx_stats_read(struct file *file, struct il_priv *il = file->private_data; int pos = 0; char *buf; - int bufsz = sizeof(struct iwl39_statistics_rx_phy) * 40 + - sizeof(struct iwl39_statistics_rx_non_phy) * 40 + 400; + int bufsz = sizeof(struct iwl39_stats_rx_phy) * 40 + + sizeof(struct iwl39_stats_rx_non_phy) * 40 + 400; ssize_t ret; - struct iwl39_statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, + struct iwl39_stats_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm; - struct iwl39_statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck; - struct iwl39_statistics_rx_non_phy *general, *accum_general; - struct iwl39_statistics_rx_non_phy *delta_general, *max_general; + struct iwl39_stats_rx_phy *cck, *accum_cck, *delta_cck, *max_cck; + struct iwl39_stats_rx_non_phy *general, *accum_general; + struct iwl39_stats_rx_non_phy *delta_general, *max_general; if (!il_is_alive(il)) return -EAGAIN; @@ -77,23 +77,23 @@ ssize_t il3945_ucode_rx_stats_read(struct file *file, /* * The statistic information display here is based on - * the last statistics notification from uCode + * the last stats notification from uCode * might not reflect the current uCode activity */ - ofdm = &il->_3945.statistics.rx.ofdm; - cck = &il->_3945.statistics.rx.cck; - general = &il->_3945.statistics.rx.general; - accum_ofdm = &il->_3945.accum_statistics.rx.ofdm; - accum_cck = &il->_3945.accum_statistics.rx.cck; - accum_general = &il->_3945.accum_statistics.rx.general; - delta_ofdm = &il->_3945.delta_statistics.rx.ofdm; - delta_cck = &il->_3945.delta_statistics.rx.cck; - delta_general = &il->_3945.delta_statistics.rx.general; + ofdm = &il->_3945.stats.rx.ofdm; + cck = &il->_3945.stats.rx.cck; + general = &il->_3945.stats.rx.general; + accum_ofdm = &il->_3945.accum_stats.rx.ofdm; + accum_cck = &il->_3945.accum_stats.rx.cck; + accum_general = &il->_3945.accum_stats.rx.general; + delta_ofdm = &il->_3945.delta_stats.rx.ofdm; + delta_cck = &il->_3945.delta_stats.rx.cck; + delta_general = &il->_3945.delta_stats.rx.general; max_ofdm = &il->_3945.max_delta.rx.ofdm; max_cck = &il->_3945.max_delta.rx.cck; max_general = &il->_3945.max_delta.rx.general; - pos += il3945_statistics_flag(il, buf, bufsz); + pos += il3945_stats_flag(il, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" "acumulative delta max\n", "Statistics_Rx - OFDM:"); @@ -332,9 +332,9 @@ ssize_t il3945_ucode_tx_stats_read(struct file *file, struct il_priv *il = file->private_data; int pos = 0; char *buf; - int bufsz = (sizeof(struct iwl39_statistics_tx) * 48) + 250; + int bufsz = (sizeof(struct iwl39_stats_tx) * 48) + 250; ssize_t ret; - struct iwl39_statistics_tx *tx, *accum_tx, *delta_tx, *max_tx; + struct iwl39_stats_tx *tx, *accum_tx, *delta_tx, *max_tx; if (!il_is_alive(il)) return -EAGAIN; @@ -347,14 +347,14 @@ ssize_t il3945_ucode_tx_stats_read(struct file *file, /* * The statistic information display here is based on - * the last statistics notification from uCode + * the last stats notification from uCode * might not reflect the current uCode activity */ - tx = &il->_3945.statistics.tx; - accum_tx = &il->_3945.accum_statistics.tx; - delta_tx = &il->_3945.delta_statistics.tx; + tx = &il->_3945.stats.tx; + accum_tx = &il->_3945.accum_stats.tx; + delta_tx = &il->_3945.delta_stats.tx; max_tx = &il->_3945.max_delta.tx; - pos += il3945_statistics_flag(il, buf, bufsz); + pos += il3945_stats_flag(il, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" "acumulative delta max\n", "Statistics_Tx:"); @@ -428,12 +428,12 @@ ssize_t il3945_ucode_general_stats_read(struct file *file, struct il_priv *il = file->private_data; int pos = 0; char *buf; - int bufsz = sizeof(struct iwl39_statistics_general) * 10 + 300; + int bufsz = sizeof(struct iwl39_stats_general) * 10 + 300; ssize_t ret; - struct iwl39_statistics_general *general, *accum_general; - struct iwl39_statistics_general *delta_general, *max_general; - struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; - struct iwl39_statistics_div *div, *accum_div, *delta_div, *max_div; + struct iwl39_stats_general *general, *accum_general; + struct iwl39_stats_general *delta_general, *max_general; + struct stats_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; + struct iwl39_stats_div *div, *accum_div, *delta_div, *max_div; if (!il_is_alive(il)) return -EAGAIN; @@ -446,22 +446,22 @@ ssize_t il3945_ucode_general_stats_read(struct file *file, /* * The statistic information display here is based on - * the last statistics notification from uCode + * the last stats notification from uCode * might not reflect the current uCode activity */ - general = &il->_3945.statistics.general; - dbg = &il->_3945.statistics.general.dbg; - div = &il->_3945.statistics.general.div; - accum_general = &il->_3945.accum_statistics.general; - delta_general = &il->_3945.delta_statistics.general; + general = &il->_3945.stats.general; + dbg = &il->_3945.stats.general.dbg; + div = &il->_3945.stats.general.div; + accum_general = &il->_3945.accum_stats.general; + delta_general = &il->_3945.delta_stats.general; max_general = &il->_3945.max_delta.general; - accum_dbg = &il->_3945.accum_statistics.general.dbg; - delta_dbg = &il->_3945.delta_statistics.general.dbg; + accum_dbg = &il->_3945.accum_stats.general.dbg; + delta_dbg = &il->_3945.delta_stats.general.dbg; max_dbg = &il->_3945.max_delta.general.dbg; - accum_div = &il->_3945.accum_statistics.general.div; - delta_div = &il->_3945.delta_statistics.general.div; + accum_div = &il->_3945.accum_stats.general.div; + delta_div = &il->_3945.delta_stats.general.div; max_div = &il->_3945.max_delta.general.div; - pos += il3945_statistics_flag(il, buf, bufsz); + pos += il3945_stats_flag(il, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" "acumulative delta max\n", "Statistics_General:"); diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c index 070730183c9c..ebee6c350dbe 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c @@ -158,7 +158,7 @@ static int il3945_rate_scale_flush_windows(struct il3945_rs_sta *rs_sta) /* * For each rate, if we have collected data on that rate * and it has been more than IL_RATE_WIN_FLUSH - * since we flushed, clear out the gathered statistics + * since we flushed, clear out the gathered stats */ for (i = 0; i < IL_RATE_COUNT_3945; i++) { if (!rs_sta->win[i].counter) diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index ad78d3fb76f0..fa4c33a36f22 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -362,7 +362,7 @@ static void il3945_rx_reply_tx(struct il_priv *il, * *****************************************************************************/ #ifdef CONFIG_IWLEGACY_DEBUGFS -static void il3945_accumulative_statistics(struct il_priv *il, +static void il3945_accumulative_stats(struct il_priv *il, __le32 *stats) { int i; @@ -370,12 +370,12 @@ static void il3945_accumulative_statistics(struct il_priv *il, u32 *accum_stats; u32 *delta, *max_delta; - prev_stats = (__le32 *)&il->_3945.statistics; - accum_stats = (u32 *)&il->_3945.accum_statistics; - delta = (u32 *)&il->_3945.delta_statistics; + prev_stats = (__le32 *)&il->_3945.stats; + accum_stats = (u32 *)&il->_3945.accum_stats; + delta = (u32 *)&il->_3945.delta_stats; max_delta = (u32 *)&il->_3945.max_delta; - for (i = sizeof(__le32); i < sizeof(struct il3945_notif_statistics); + for (i = sizeof(__le32); i < sizeof(struct il3945_notif_stats); i += sizeof(__le32), stats++, prev_stats++, delta++, max_delta++, accum_stats++) { if (le32_to_cpu(*stats) > le32_to_cpu(*prev_stats)) { @@ -387,30 +387,30 @@ static void il3945_accumulative_statistics(struct il_priv *il, } } - /* reset accumulative statistics for "no-counter" type statistics */ - il->_3945.accum_statistics.general.temperature = - il->_3945.statistics.general.temperature; - il->_3945.accum_statistics.general.ttl_timestamp = - il->_3945.statistics.general.ttl_timestamp; + /* reset accumulative stats for "no-counter" type stats */ + il->_3945.accum_stats.general.temperature = + il->_3945.stats.general.temperature; + il->_3945.accum_stats.general.ttl_timestamp = + il->_3945.stats.general.ttl_timestamp; } #endif -void il3945_hw_rx_statistics(struct il_priv *il, +void il3945_hw_rx_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); D_RX("Statistics notification received (%d vs %d).\n", - (int)sizeof(struct il3945_notif_statistics), + (int)sizeof(struct il3945_notif_stats), le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK); #ifdef CONFIG_IWLEGACY_DEBUGFS - il3945_accumulative_statistics(il, (__le32 *)&pkt->u.raw); + il3945_accumulative_stats(il, (__le32 *)&pkt->u.raw); #endif - memcpy(&il->_3945.statistics, pkt->u.raw, sizeof(il->_3945.statistics)); + memcpy(&il->_3945.stats, pkt->u.raw, sizeof(il->_3945.stats)); } -void il3945_reply_statistics(struct il_priv *il, +void il3945_reply_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -418,16 +418,16 @@ void il3945_reply_statistics(struct il_priv *il, if (le32_to_cpu(*flag) & UCODE_STATISTICS_CLEAR_MSK) { #ifdef CONFIG_IWLEGACY_DEBUGFS - memset(&il->_3945.accum_statistics, 0, - sizeof(struct il3945_notif_statistics)); - memset(&il->_3945.delta_statistics, 0, - sizeof(struct il3945_notif_statistics)); + memset(&il->_3945.accum_stats, 0, + sizeof(struct il3945_notif_stats)); + memset(&il->_3945.delta_stats, 0, + sizeof(struct il3945_notif_stats)); memset(&il->_3945.max_delta, 0, - sizeof(struct il3945_notif_statistics)); + sizeof(struct il3945_notif_stats)); #endif D_RX("Statistics have been cleared\n"); } - il3945_hw_rx_statistics(il, rxb); + il3945_hw_rx_stats(il, rxb); } @@ -437,7 +437,7 @@ void il3945_reply_statistics(struct il_priv *il, * ******************************************************************************/ -/* This is necessary only for a number of statistics, see the caller. */ +/* This is necessary only for a number of stats, see the caller. */ static int il3945_is_network_packet(struct il_priv *il, struct ieee80211_hdr *header) { diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.h b/drivers/net/wireless/iwlegacy/iwl-3945.h index 8a294ca5d07a..967e73357e9c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945.h @@ -60,7 +60,7 @@ extern const struct pci_device_id il3945_hw_card_ids[]; /* Default noise level to report when noise measurement is not available. * This may be because we're: - * 1) Not associated (4965, no beacon statistics being sent to driver) + * 1) Not associated (4965, no beacon stats being sent to driver) * 2) Scanning (noise measurement does not apply to associated channel) * 3) Receiving CCK (3945 delivers noise info only for OFDM frames) * Use default noise value of -127 ... this is below the range of measurable @@ -258,9 +258,9 @@ void il3945_hw_build_tx_cmd_rate(struct il_priv *il, int sta_id, int tx_id); extern int il3945_hw_reg_send_txpower(struct il_priv *il); extern int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power); -extern void il3945_hw_rx_statistics(struct il_priv *il, +extern void il3945_hw_rx_stats(struct il_priv *il, struct il_rx_buf *rxb); -void il3945_reply_statistics(struct il_priv *il, +void il3945_reply_stats(struct il_priv *il, struct il_rx_buf *rxb); extern void il3945_disable_events(struct il_priv *il); extern int il4965_get_temperature(const struct il_priv *il); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c index 4c2b491b4c27..bb3bc15c3a36 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c @@ -71,7 +71,7 @@ * INIT calibrations framework *****************************************************************************/ -struct statistics_general_data { +struct stats_general_data { u32 beacon_silence_rssi_a; u32 beacon_silence_rssi_b; u32 beacon_silence_rssi_c; @@ -106,7 +106,7 @@ void il4965_calib_free_results(struct il_priv *il) static int il4965_sens_energy_cck(struct il_priv *il, u32 norm_fa, u32 rx_enable_time, - struct statistics_general_data *rx_info) + struct stats_general_data *rx_info) { u32 max_nrg_cck = 0; int i = 0; @@ -509,10 +509,10 @@ void il4965_sensitivity_calibration(struct il_priv *il, void *resp) u32 norm_fa_ofdm; u32 norm_fa_cck; struct il_sensitivity_data *data = NULL; - struct statistics_rx_non_phy *rx_info; - struct statistics_rx_phy *ofdm, *cck; + struct stats_rx_non_phy *rx_info; + struct stats_rx_phy *ofdm, *cck; unsigned long flags; - struct statistics_general_data statis; + struct stats_general_data statis; if (il->disable_sens_cal) return; @@ -526,9 +526,9 @@ void il4965_sensitivity_calibration(struct il_priv *il, void *resp) spin_lock_irqsave(&il->lock, flags); - rx_info = &(((struct il_notif_statistics *)resp)->rx.general); - ofdm = &(((struct il_notif_statistics *)resp)->rx.ofdm); - cck = &(((struct il_notif_statistics *)resp)->rx.cck); + rx_info = &(((struct il_notif_stats *)resp)->rx.general); + ofdm = &(((struct il_notif_stats *)resp)->rx.ofdm); + cck = &(((struct il_notif_stats *)resp)->rx.cck); if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { D_CALIB("<< invalid data.\n"); @@ -565,9 +565,9 @@ void il4965_sensitivity_calibration(struct il_priv *il, void *resp) return; } - /* These statistics increase monotonically, and do not reset + /* These stats increase monotonically, and do not reset * at each beacon. Calculate difference from last value, or just - * use the new statistics value if it has reset or wrapped around. */ + * use the new stats value if it has reset or wrapped around. */ if (data->last_bad_plcp_cnt_cck > bad_plcp_cck) data->last_bad_plcp_cnt_cck = bad_plcp_cck; else { @@ -793,7 +793,7 @@ static void il4965_gain_computation(struct il_priv *il, /* - * Accumulate 16 beacons of signal and noise statistics for each of + * Accumulate 16 beacons of signal and noise stats for each of * 3 receivers/antennas/rx-chains, then figure out: * 1) Which antennas are connected. * 2) Differential rx gain settings to balance the 3 receivers. @@ -818,7 +818,7 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) u8 rxon_band24; u8 stat_band24; unsigned long flags; - struct statistics_rx_non_phy *rx_info; + struct stats_rx_non_phy *rx_info; struct il_rxon_context *ctx = &il->ctx; @@ -839,7 +839,7 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) spin_lock_irqsave(&il->lock, flags); - rx_info = &(((struct il_notif_statistics *)stat_resp)-> + rx_info = &(((struct il_notif_stats *)stat_resp)-> rx.general); if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { @@ -851,10 +851,10 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) rxon_band24 = !!(ctx->staging.flags & RXON_FLG_BAND_24G_MSK); rxon_chnum = le16_to_cpu(ctx->staging.channel); - stat_band24 = !!(((struct il_notif_statistics *) + stat_band24 = !!(((struct il_notif_stats *) stat_resp)->flag & STATISTICS_REPLY_FLG_BAND_24G_MSK); - stat_chnum = le32_to_cpu(((struct il_notif_statistics *) + stat_chnum = le32_to_cpu(((struct il_notif_stats *) stat_resp)->flag) >> 16; /* Make sure we accumulate data for just the associated channel @@ -867,7 +867,7 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) } /* - * Accumulate beacon statistics values across + * Accumulate beacon stats values across * "chain_noise_num_beacons" */ chain_noise_a = le32_to_cpu(rx_info->beacon_silence_rssi_a) & @@ -960,7 +960,7 @@ void il4965_reset_run_time_calib(struct il_priv *il) il->chain_noise_data.delta_gain_code[i] = CHAIN_NOISE_DELTA_GAIN_INIT_VAL; - /* Ask for statistics now, the uCode will send notification + /* Ask for stats now, the uCode will send notification * periodically after association */ - il_send_statistics_request(il, CMD_ASYNC, true); + il_send_stats_request(il, CMD_ASYNC, true); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c index ebb71a685101..89e5828ce383 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c @@ -33,12 +33,12 @@ static const char *fmt_table = " %-30s %10u %10u %10u %10u\n"; static const char *fmt_header = "%-32s current cumulative delta max\n"; -static int il4965_statistics_flag(struct il_priv *il, char *buf, int bufsz) +static int il4965_stats_flag(struct il_priv *il, char *buf, int bufsz) { int p = 0; u32 flag; - flag = le32_to_cpu(il->_4965.statistics.flag); + flag = le32_to_cpu(il->_4965.stats.flag); p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag); if (flag & UCODE_STATISTICS_CLEAR_MSK) @@ -60,15 +60,15 @@ ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, struct il_priv *il = file->private_data; int pos = 0; char *buf; - int bufsz = sizeof(struct statistics_rx_phy) * 40 + - sizeof(struct statistics_rx_non_phy) * 40 + - sizeof(struct statistics_rx_ht_phy) * 40 + 400; + int bufsz = sizeof(struct stats_rx_phy) * 40 + + sizeof(struct stats_rx_non_phy) * 40 + + sizeof(struct stats_rx_ht_phy) * 40 + 400; ssize_t ret; - struct statistics_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm; - struct statistics_rx_phy *cck, *accum_cck, *delta_cck, *max_cck; - struct statistics_rx_non_phy *general, *accum_general; - struct statistics_rx_non_phy *delta_general, *max_general; - struct statistics_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht; + struct stats_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm; + struct stats_rx_phy *cck, *accum_cck, *delta_cck, *max_cck; + struct stats_rx_non_phy *general, *accum_general; + struct stats_rx_non_phy *delta_general, *max_general; + struct stats_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht; if (!il_is_alive(il)) return -EAGAIN; @@ -81,27 +81,27 @@ ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, /* * the statistic information display here is based on - * the last statistics notification from uCode + * the last stats notification from uCode * might not reflect the current uCode activity */ - ofdm = &il->_4965.statistics.rx.ofdm; - cck = &il->_4965.statistics.rx.cck; - general = &il->_4965.statistics.rx.general; - ht = &il->_4965.statistics.rx.ofdm_ht; - accum_ofdm = &il->_4965.accum_statistics.rx.ofdm; - accum_cck = &il->_4965.accum_statistics.rx.cck; - accum_general = &il->_4965.accum_statistics.rx.general; - accum_ht = &il->_4965.accum_statistics.rx.ofdm_ht; - delta_ofdm = &il->_4965.delta_statistics.rx.ofdm; - delta_cck = &il->_4965.delta_statistics.rx.cck; - delta_general = &il->_4965.delta_statistics.rx.general; - delta_ht = &il->_4965.delta_statistics.rx.ofdm_ht; + ofdm = &il->_4965.stats.rx.ofdm; + cck = &il->_4965.stats.rx.cck; + general = &il->_4965.stats.rx.general; + ht = &il->_4965.stats.rx.ofdm_ht; + accum_ofdm = &il->_4965.accum_stats.rx.ofdm; + accum_cck = &il->_4965.accum_stats.rx.cck; + accum_general = &il->_4965.accum_stats.rx.general; + accum_ht = &il->_4965.accum_stats.rx.ofdm_ht; + delta_ofdm = &il->_4965.delta_stats.rx.ofdm; + delta_cck = &il->_4965.delta_stats.rx.cck; + delta_general = &il->_4965.delta_stats.rx.general; + delta_ht = &il->_4965.delta_stats.rx.ofdm_ht; max_ofdm = &il->_4965.max_delta.rx.ofdm; max_cck = &il->_4965.max_delta.rx.cck; max_general = &il->_4965.max_delta.rx.general; max_ht = &il->_4965.max_delta.rx.ofdm_ht; - pos += il4965_statistics_flag(il, buf, bufsz); + pos += il4965_stats_flag(il, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, fmt_header, "Statistics_Rx - OFDM:"); pos += scnprintf(buf + pos, bufsz - pos, @@ -492,9 +492,9 @@ ssize_t il4965_ucode_tx_stats_read(struct file *file, struct il_priv *il = file->private_data; int pos = 0; char *buf; - int bufsz = (sizeof(struct statistics_tx) * 48) + 250; + int bufsz = (sizeof(struct stats_tx) * 48) + 250; ssize_t ret; - struct statistics_tx *tx, *accum_tx, *delta_tx, *max_tx; + struct stats_tx *tx, *accum_tx, *delta_tx, *max_tx; if (!il_is_alive(il)) return -EAGAIN; @@ -506,15 +506,15 @@ ssize_t il4965_ucode_tx_stats_read(struct file *file, } /* the statistic information display here is based on - * the last statistics notification from uCode + * the last stats notification from uCode * might not reflect the current uCode activity */ - tx = &il->_4965.statistics.tx; - accum_tx = &il->_4965.accum_statistics.tx; - delta_tx = &il->_4965.delta_statistics.tx; + tx = &il->_4965.stats.tx; + accum_tx = &il->_4965.accum_stats.tx; + delta_tx = &il->_4965.delta_stats.tx; max_tx = &il->_4965.max_delta.tx; - pos += il4965_statistics_flag(il, buf, bufsz); + pos += il4965_stats_flag(il, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, fmt_header, "Statistics_Tx:"); pos += scnprintf(buf + pos, bufsz - pos, @@ -667,12 +667,12 @@ il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, struct il_priv *il = file->private_data; int pos = 0; char *buf; - int bufsz = sizeof(struct statistics_general) * 10 + 300; + int bufsz = sizeof(struct stats_general) * 10 + 300; ssize_t ret; - struct statistics_general_common *general, *accum_general; - struct statistics_general_common *delta_general, *max_general; - struct statistics_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; - struct statistics_div *div, *accum_div, *delta_div, *max_div; + struct stats_general_common *general, *accum_general; + struct stats_general_common *delta_general, *max_general; + struct stats_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; + struct stats_div *div, *accum_div, *delta_div, *max_div; if (!il_is_alive(il)) return -EAGAIN; @@ -684,23 +684,23 @@ il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, } /* the statistic information display here is based on - * the last statistics notification from uCode + * the last stats notification from uCode * might not reflect the current uCode activity */ - general = &il->_4965.statistics.general.common; - dbg = &il->_4965.statistics.general.common.dbg; - div = &il->_4965.statistics.general.common.div; - accum_general = &il->_4965.accum_statistics.general.common; - accum_dbg = &il->_4965.accum_statistics.general.common.dbg; - accum_div = &il->_4965.accum_statistics.general.common.div; - delta_general = &il->_4965.delta_statistics.general.common; + general = &il->_4965.stats.general.common; + dbg = &il->_4965.stats.general.common.dbg; + div = &il->_4965.stats.general.common.div; + accum_general = &il->_4965.accum_stats.general.common; + accum_dbg = &il->_4965.accum_stats.general.common.dbg; + accum_div = &il->_4965.accum_stats.general.common.div; + delta_general = &il->_4965.delta_stats.general.common; max_general = &il->_4965.max_delta.general.common; - delta_dbg = &il->_4965.delta_statistics.general.common.dbg; + delta_dbg = &il->_4965.delta_stats.general.common.dbg; max_dbg = &il->_4965.max_delta.general.common.dbg; - delta_div = &il->_4965.delta_statistics.general.common.div; + delta_div = &il->_4965.delta_stats.general.common.div; max_div = &il->_4965.max_delta.general.common.div; - pos += il4965_statistics_flag(il, buf, bufsz); + pos += il4965_stats_flag(il, buf, bufsz); pos += scnprintf(buf + pos, bufsz - pos, fmt_header, "Statistics_General:"); pos += scnprintf(buf + pos, bufsz - pos, diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h index ecebc6923125..21ff694421a9 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h @@ -119,7 +119,7 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * * uCode provides all 4 values to the driver via the "initialize alive" * notification (see struct il4965_init_alive_resp). After the runtime uCode - * image loads, uCode updates the R4 value via statistics notifications + * image loads, uCode updates the R4 value via stats notifications * (see STATISTICS_NOTIFICATION), which occur after each received beacon * when associated, or can be requested via REPLY_STATISTICS_CMD. * @@ -159,7 +159,7 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * * 1) EEPROM * 2) "initialize" alive notification - * 3) statistics notifications + * 3) stats notifications * * EEPROM data consists of: * diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index 9c8cc320832e..e99a20c8891d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -242,7 +242,7 @@ static inline u8 il4965_rs_is_valid_ant(u8 valid_antenna, u8 ant_type) } /* - * removes the old data from the statistics. All data that is older than + * removes the old data from the stats. All data that is older than * TID_MAX_TIME_DIFF, will be deleted. */ static void @@ -991,7 +991,7 @@ done: * Begin a period of staying with a selected modulation mode. * Set "stay_in_tbl" flag to prevent any mode switches. * Set frame tx success limits according to legacy vs. high-throughput, - * and reset overall (spanning all rates) tx success history statistics. + * and reset overall (spanning all rates) tx success history stats. * These control how long we stay using same modulation mode before * searching for a new mode. */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c index 9ccec09c32be..b32295747851 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c @@ -67,13 +67,13 @@ void il4965_rx_missed_beacon_notif(struct il_priv *il, * exactly when to expect beacons, therefore only when we're associated. */ static void il4965_rx_calc_noise(struct il_priv *il) { - struct statistics_rx_non_phy *rx_info; + struct stats_rx_non_phy *rx_info; int num_active_rx = 0; int total_silence = 0; int bcn_silence_a, bcn_silence_b, bcn_silence_c; int last_rx_noise; - rx_info = &(il->_4965.statistics.rx.general); + rx_info = &(il->_4965.stats.rx.general); bcn_silence_a = le32_to_cpu(rx_info->beacon_silence_rssi_a) & IN_BAND_FILTER; bcn_silence_b = @@ -107,28 +107,28 @@ static void il4965_rx_calc_noise(struct il_priv *il) #ifdef CONFIG_IWLEGACY_DEBUGFS /* - * based on the assumption of all statistics counter are in DWORD + * based on the assumption of all stats counter are in DWORD * FIXME: This function is for debugging, do not deal with * the case of counters roll-over. */ -static void il4965_accumulative_statistics(struct il_priv *il, +static void il4965_accumulative_stats(struct il_priv *il, __le32 *stats) { int i, size; __le32 *prev_stats; u32 *accum_stats; u32 *delta, *max_delta; - struct statistics_general_common *general, *accum_general; - struct statistics_tx *tx, *accum_tx; - - prev_stats = (__le32 *)&il->_4965.statistics; - accum_stats = (u32 *)&il->_4965.accum_statistics; - size = sizeof(struct il_notif_statistics); - general = &il->_4965.statistics.general.common; - accum_general = &il->_4965.accum_statistics.general.common; - tx = &il->_4965.statistics.tx; - accum_tx = &il->_4965.accum_statistics.tx; - delta = (u32 *)&il->_4965.delta_statistics; + struct stats_general_common *general, *accum_general; + struct stats_tx *tx, *accum_tx; + + prev_stats = (__le32 *)&il->_4965.stats; + accum_stats = (u32 *)&il->_4965.accum_stats; + size = sizeof(struct il_notif_stats); + general = &il->_4965.stats.general.common; + accum_general = &il->_4965.accum_stats.general.common; + tx = &il->_4965.stats.tx; + accum_tx = &il->_4965.accum_stats.tx; + delta = (u32 *)&il->_4965.delta_stats; max_delta = (u32 *)&il->_4965.max_delta; for (i = sizeof(__le32); i < size; @@ -143,7 +143,7 @@ static void il4965_accumulative_statistics(struct il_priv *il, } } - /* reset accumulative statistics for "no-counter" type statistics */ + /* reset accumulative stats for "no-counter" type stats */ accum_general->temperature = general->temperature; accum_general->ttl_timestamp = general->ttl_timestamp; } @@ -151,7 +151,7 @@ static void il4965_accumulative_statistics(struct il_priv *il, #define REG_RECALIB_PERIOD (60) -void il4965_rx_statistics(struct il_priv *il, +void il4965_rx_stats(struct il_priv *il, struct il_rx_buf *rxb) { int change; @@ -159,31 +159,31 @@ void il4965_rx_statistics(struct il_priv *il, D_RX( "Statistics notification received (%d vs %d).\n", - (int)sizeof(struct il_notif_statistics), + (int)sizeof(struct il_notif_stats), le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK); - change = ((il->_4965.statistics.general.common.temperature != + change = ((il->_4965.stats.general.common.temperature != pkt->u.stats.general.common.temperature) || - ((il->_4965.statistics.flag & + ((il->_4965.stats.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK) != (pkt->u.stats.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK))); #ifdef CONFIG_IWLEGACY_DEBUGFS - il4965_accumulative_statistics(il, (__le32 *)&pkt->u.stats); + il4965_accumulative_stats(il, (__le32 *)&pkt->u.stats); #endif - /* TODO: reading some of statistics is unneeded */ - memcpy(&il->_4965.statistics, &pkt->u.stats, - sizeof(il->_4965.statistics)); + /* TODO: reading some of stats is unneeded */ + memcpy(&il->_4965.stats, &pkt->u.stats, + sizeof(il->_4965.stats)); set_bit(STATUS_STATISTICS, &il->status); - /* Reschedule the statistics timer to occur in + /* Reschedule the stats timer to occur in * REG_RECALIB_PERIOD seconds to ensure we get a * thermal update even if the uCode doesn't give * us one */ - mod_timer(&il->statistics_periodic, jiffies + + mod_timer(&il->stats_periodic, jiffies + msecs_to_jiffies(REG_RECALIB_PERIOD * 1000)); if (unlikely(!test_bit(STATUS_SCANNING, &il->status)) && @@ -195,21 +195,21 @@ void il4965_rx_statistics(struct il_priv *il, il->cfg->ops->lib->temp_ops.temperature(il); } -void il4965_reply_statistics(struct il_priv *il, +void il4965_reply_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATISTICS_CLEAR_MSK) { #ifdef CONFIG_IWLEGACY_DEBUGFS - memset(&il->_4965.accum_statistics, 0, - sizeof(struct il_notif_statistics)); - memset(&il->_4965.delta_statistics, 0, - sizeof(struct il_notif_statistics)); + memset(&il->_4965.accum_stats, 0, + sizeof(struct il_notif_stats)); + memset(&il->_4965.delta_stats, 0, + sizeof(struct il_notif_stats)); memset(&il->_4965.max_delta, 0, - sizeof(struct il_notif_statistics)); + sizeof(struct il_notif_stats)); #endif D_RX("Statistics have been cleared\n"); } - il4965_rx_statistics(il, rxb); + il4965_rx_stats(il, rxb); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index 5dd963e88643..9cfc14001d3d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -1436,9 +1436,9 @@ static void il4965_txq_update_byte_cnt_tbl(struct il_priv *il, /** * il4965_hw_get_temperature - return the calibrated temperature (in Kelvin) - * @statistics: Provides the temperature reading from the uCode + * @stats: Provides the temperature reading from the uCode * - * A return of <0 indicates bogus data in the statistics + * A return of <0 indicates bogus data in the stats */ static int il4965_hw_get_temperature(struct il_priv *il) { @@ -1448,7 +1448,7 @@ static int il4965_hw_get_temperature(struct il_priv *il) u32 R4; if (test_bit(STATUS_TEMPERATURE, &il->status) && - (il->_4965.statistics.flag & + (il->_4965.stats.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK)) { D_TEMP("Running HT40 temperature calibration\n"); R1 = (s32)le32_to_cpu(il->card_alive_init.therm_r1[1]); @@ -1466,14 +1466,14 @@ static int il4965_hw_get_temperature(struct il_priv *il) /* * Temperature is only 23 bits, so sign extend out to 32. * - * NOTE If we haven't received a statistics notification yet + * NOTE If we haven't received a stats notification yet * with an updated temperature, use R4 provided to us in the * "initialize" ALIVE response. */ if (!test_bit(STATUS_TEMPERATURE, &il->status)) vt = sign_extend32(R4, 23); else - vt = sign_extend32(le32_to_cpu(il->_4965.statistics. + vt = sign_extend32(le32_to_cpu(il->_4965.stats. general.common.temperature), 23); D_TEMP("Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt); @@ -1512,7 +1512,7 @@ static int il4965_is_temp_calib_needed(struct il_priv *il) int temp_diff; if (!test_bit(STATUS_STATISTICS, &il->status)) { - D_TEMP("Temperature not updated -- no statistics.\n"); + D_TEMP("Temperature not updated -- no stats.\n"); return 0; } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.h b/drivers/net/wireless/iwlegacy/iwl-4965.h index b5b27f45e99b..a75b62cd61f7 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965.h @@ -174,9 +174,9 @@ void il4965_rx_missed_beacon_notif(struct il_priv *il, struct il_rx_buf *rxb); bool il4965_good_plcp_health(struct il_priv *il, struct il_rx_pkt *pkt); -void il4965_rx_statistics(struct il_priv *il, +void il4965_rx_stats(struct il_priv *il, struct il_rx_buf *rxb); -void il4965_reply_statistics(struct il_priv *il, +void il4965_reply_stats(struct il_priv *il, struct il_rx_buf *rxb); /* scan */ diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h index d9873cbfa80d..ea6c0f50ecf7 100644 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ b/drivers/net/wireless/iwlegacy/iwl-commands.h @@ -2016,7 +2016,7 @@ struct il_link_qual_agg_params { * good performance; higher rate is sure to have poorer success. * * 6) Re-evaluate the rate after each tx frame. If working with block- - * acknowledge, history and statistics may be calculated for the entire + * acknowledge, history and stats may be calculated for the entire * block (including prior history that fits within the history windows), * before re-evaluation. * @@ -2637,7 +2637,7 @@ struct il_scanresults_notification { u8 num_probe_not_sent; /* not enough time to send */ __le32 tsf_low; __le32 tsf_high; - __le32 statistics[NUMBER_OF_STATISTICS]; + __le32 stats[NUMBER_OF_STATISTICS]; } __packed; /* @@ -2727,9 +2727,9 @@ struct rate_histogram { } failed; } __packed; -/* statistics command response */ +/* stats command response */ -struct iwl39_statistics_rx_phy { +struct iwl39_stats_rx_phy { __le32 ina_cnt; __le32 fina_cnt; __le32 plcp_err; @@ -2747,7 +2747,7 @@ struct iwl39_statistics_rx_phy { __le32 sent_cts_cnt; } __packed; -struct iwl39_statistics_rx_non_phy { +struct iwl39_stats_rx_non_phy { __le32 bogus_cts; /* CTS received when not expecting CTS */ __le32 bogus_ack; /* ACK received when not expecting ACK */ __le32 non_bssid_frames; /* number of frames with BSSID that @@ -2758,13 +2758,13 @@ struct iwl39_statistics_rx_non_phy { * our serving channel */ } __packed; -struct iwl39_statistics_rx { - struct iwl39_statistics_rx_phy ofdm; - struct iwl39_statistics_rx_phy cck; - struct iwl39_statistics_rx_non_phy general; +struct iwl39_stats_rx { + struct iwl39_stats_rx_phy ofdm; + struct iwl39_stats_rx_phy cck; + struct iwl39_stats_rx_non_phy general; } __packed; -struct iwl39_statistics_tx { +struct iwl39_stats_tx { __le32 preamble_cnt; __le32 rx_detected_cnt; __le32 bt_prio_defer_cnt; @@ -2776,31 +2776,31 @@ struct iwl39_statistics_tx { __le32 actual_ack_cnt; } __packed; -struct statistics_dbg { +struct stats_dbg { __le32 burst_check; __le32 burst_count; __le32 wait_for_silence_timeout_cnt; __le32 reserved[3]; } __packed; -struct iwl39_statistics_div { +struct iwl39_stats_div { __le32 tx_on_a; __le32 tx_on_b; __le32 exec_time; __le32 probe_time; } __packed; -struct iwl39_statistics_general { +struct iwl39_stats_general { __le32 temperature; - struct statistics_dbg dbg; + struct stats_dbg dbg; __le32 sleep_time; __le32 slots_out; __le32 slots_idle; __le32 ttl_timestamp; - struct iwl39_statistics_div div; + struct iwl39_stats_div div; } __packed; -struct statistics_rx_phy { +struct stats_rx_phy { __le32 ina_cnt; __le32 fina_cnt; __le32 plcp_err; @@ -2823,7 +2823,7 @@ struct statistics_rx_phy { __le32 reserved3; } __packed; -struct statistics_rx_ht_phy { +struct stats_rx_ht_phy { __le32 plcp_err; __le32 overrun_err; __le32 early_overrun_err; @@ -2838,7 +2838,7 @@ struct statistics_rx_ht_phy { #define INTERFERENCE_DATA_AVAILABLE cpu_to_le32(1) -struct statistics_rx_non_phy { +struct stats_rx_non_phy { __le32 bogus_cts; /* CTS received when not expecting CTS */ __le32 bogus_ack; /* ACK received when not expecting ACK */ __le32 non_bssid_frames; /* number of frames with BSSID that @@ -2871,28 +2871,28 @@ struct statistics_rx_non_phy { __le32 beacon_energy_c; } __packed; -struct statistics_rx { - struct statistics_rx_phy ofdm; - struct statistics_rx_phy cck; - struct statistics_rx_non_phy general; - struct statistics_rx_ht_phy ofdm_ht; +struct stats_rx { + struct stats_rx_phy ofdm; + struct stats_rx_phy cck; + struct stats_rx_non_phy general; + struct stats_rx_ht_phy ofdm_ht; } __packed; /** - * struct statistics_tx_power - current tx power + * struct stats_tx_power - current tx power * * @ant_a: current tx power on chain a in 1/2 dB step * @ant_b: current tx power on chain b in 1/2 dB step * @ant_c: current tx power on chain c in 1/2 dB step */ -struct statistics_tx_power { +struct stats_tx_power { u8 ant_a; u8 ant_b; u8 ant_c; u8 reserved; } __packed; -struct statistics_tx_non_phy_agg { +struct stats_tx_non_phy_agg { __le32 ba_timeout; __le32 ba_reschedule_frames; __le32 scd_query_agg_frame_cnt; @@ -2905,7 +2905,7 @@ struct statistics_tx_non_phy_agg { __le32 rx_ba_rsp_cnt; } __packed; -struct statistics_tx { +struct stats_tx { __le32 preamble_cnt; __le32 rx_detected_cnt; __le32 bt_prio_defer_cnt; @@ -2920,13 +2920,13 @@ struct statistics_tx { __le32 burst_abort_missing_next_frame_cnt; __le32 cts_timeout_collision; __le32 ack_or_ba_timeout_collision; - struct statistics_tx_non_phy_agg agg; + struct stats_tx_non_phy_agg agg; __le32 reserved1; } __packed; -struct statistics_div { +struct stats_div { __le32 tx_on_a; __le32 tx_on_b; __le32 exec_time; @@ -2935,14 +2935,14 @@ struct statistics_div { __le32 reserved2; } __packed; -struct statistics_general_common { +struct stats_general_common { __le32 temperature; /* radio temperature */ - struct statistics_dbg dbg; + struct stats_dbg dbg; __le32 sleep_time; __le32 slots_out; __le32 slots_idle; __le32 ttl_timestamp; - struct statistics_div div; + struct stats_div div; __le32 rx_enable_counter; /* * num_of_sos_states: @@ -2952,8 +2952,8 @@ struct statistics_general_common { __le32 num_of_sos_states; } __packed; -struct statistics_general { - struct statistics_general_common common; +struct stats_general { + struct stats_general_common common; __le32 reserved2; __le32 reserved3; } __packed; @@ -2966,11 +2966,11 @@ struct statistics_general { * REPLY_STATISTICS_CMD = 0x9c, * all devices identical. * - * This command triggers an immediate response containing uCode statistics. + * This command triggers an immediate response containing uCode stats. * The response is in the same format as STATISTICS_NOTIFICATION 0x9d, below. * * If the CLEAR_STATS configuration flag is set, uCode will clear its - * internal copy of the statistics (counters) after issuing the response. + * internal copy of the stats (counters) after issuing the response. * This flag does not affect STATISTICS_NOTIFICATIONs after beacons (see below). * * If the DISABLE_NOTIF configuration flag is set, uCode will not issue @@ -2979,7 +2979,7 @@ struct statistics_general { */ #define IL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1) /* see above */ #define IL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */ -struct il_statistics_cmd { +struct il_stats_cmd { __le32 configuration_flags; /* IL_STATS_CONF_* */ } __packed; @@ -2994,25 +2994,25 @@ struct il_statistics_cmd { * cleared when changing channels or when driver issues REPLY_STATISTICS_CMD * 0x9c with CLEAR_STATS bit set (see above). * - * uCode also issues this notification during scans. uCode clears statistics - * appropriately so that each notification contains statistics for only the + * uCode also issues this notification during scans. uCode clears stats + * appropriately so that each notification contains stats for only the * one channel that has just been scanned. */ #define STATISTICS_REPLY_FLG_BAND_24G_MSK cpu_to_le32(0x2) #define STATISTICS_REPLY_FLG_HT40_MODE_MSK cpu_to_le32(0x8) -struct il3945_notif_statistics { +struct il3945_notif_stats { __le32 flag; - struct iwl39_statistics_rx rx; - struct iwl39_statistics_tx tx; - struct iwl39_statistics_general general; + struct iwl39_stats_rx rx; + struct iwl39_stats_tx tx; + struct iwl39_stats_general general; } __packed; -struct il_notif_statistics { +struct il_notif_stats { __le32 flag; - struct statistics_rx rx; - struct statistics_tx tx; - struct statistics_general general; + struct stats_rx rx; + struct stats_tx tx; + struct stats_general general; } __packed; /* @@ -3078,10 +3078,10 @@ struct il_missed_beacon_notif { * * While associated, uCode delivers STATISTICS_NOTIFICATIONs after each * received beacon. These provide information to the driver to analyze the - * sensitivity. Don't analyze statistics that come in from scanning, or any - * other non-associated-network source. Pertinent statistics include: + * sensitivity. Don't analyze stats that come in from scanning, or any + * other non-associated-network source. Pertinent stats include: * - * From "general" statistics (struct statistics_rx_non_phy): + * From "general" stats (struct stats_rx_non_phy): * * (beacon_energy_[abc] & 0x0FF00) >> 8 (unsigned, higher value is lower level) * Measure of energy of desired signal. Used for establishing a level @@ -3094,7 +3094,7 @@ struct il_missed_beacon_notif { * uSecs of actual Rx time during beacon period (varies according to * how much time was spent transmitting). * - * From "cck" and "ofdm" statistics (struct statistics_rx_phy), separately: + * From "cck" and "ofdm" stats (struct stats_rx_phy), separately: * * false_alarm_cnt * Signal locks abandoned early (before phy-level header). @@ -3255,8 +3255,8 @@ struct il_sensitivity_cmd { * This command sets the relative gains of 4965 device's 3 radio receiver chains. * * After the first association, driver should accumulate signal and noise - * statistics from the STATISTICS_NOTIFICATIONs that follow the first 20 - * beacons from the associated network (don't collect statistics that come + * stats from the STATISTICS_NOTIFICATIONs that follow the first 20 + * beacons from the associated network (don't collect stats that come * in from scanning, or any other non-network source). * * DISCONNECTED ANTENNA: @@ -3264,7 +3264,7 @@ struct il_sensitivity_cmd { * Driver should determine which antennas are actually connected, by comparing * average beacon signal levels for the 3 Rx chains. Accumulate (add) the * following values over 20 beacons, one accumulator for each of the chains - * a/b/c, from struct statistics_rx_non_phy: + * a/b/c, from struct stats_rx_non_phy: * * beacon_rssi_[abc] & 0x0FF (unsigned, units in dB) * @@ -3283,7 +3283,7 @@ struct il_sensitivity_cmd { * to antennas, see above) for gain, by comparing the average signal levels * detected during the silence after each beacon (background noise). * Accumulate (add) the following values over 20 beacons, one accumulator for - * each of the chains a/b/c, from struct statistics_rx_non_phy: + * each of the chains a/b/c, from struct stats_rx_non_phy: * * beacon_silence_rssi_[abc] & 0x0FF (unsigned, units in dB) * @@ -3387,7 +3387,7 @@ struct il_rx_pkt { struct il_rem_sta_resp rem_sta; struct il_sleep_notification sleep_notif; struct il_spectrum_resp spectrum; - struct il_notif_statistics stats; + struct il_notif_stats stats; struct il_compressed_ba_resp compressed_ba; struct il_missed_beacon_notif missed_beacon; __le32 status; diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index 8feb2dde09b5..475bcac7aa9e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -1187,23 +1187,23 @@ void il_send_bt_config(struct il_priv *il) } EXPORT_SYMBOL(il_send_bt_config); -int il_send_statistics_request(struct il_priv *il, u8 flags, bool clear) +int il_send_stats_request(struct il_priv *il, u8 flags, bool clear) { - struct il_statistics_cmd statistics_cmd = { + struct il_stats_cmd stats_cmd = { .configuration_flags = clear ? IL_STATS_CONF_CLEAR_STATS : 0, }; if (flags & CMD_ASYNC) return il_send_cmd_pdu_async(il, REPLY_STATISTICS_CMD, - sizeof(struct il_statistics_cmd), - &statistics_cmd, NULL); + sizeof(struct il_stats_cmd), + &stats_cmd, NULL); else return il_send_cmd_pdu(il, REPLY_STATISTICS_CMD, - sizeof(struct il_statistics_cmd), - &statistics_cmd); + sizeof(struct il_stats_cmd), + &stats_cmd); } -EXPORT_SYMBOL(il_send_statistics_request); +EXPORT_SYMBOL(il_send_stats_request); void il_rx_pm_sleep_notif(struct il_priv *il, struct il_rx_buf *rxb) @@ -1217,7 +1217,7 @@ void il_rx_pm_sleep_notif(struct il_priv *il, } EXPORT_SYMBOL(il_rx_pm_sleep_notif); -void il_rx_pm_debug_statistics_notif(struct il_priv *il, +void il_rx_pm_debug_stats_notif(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -1227,7 +1227,7 @@ void il_rx_pm_debug_statistics_notif(struct il_priv *il, il_get_cmd_string(pkt->hdr.cmd)); il_print_hex_dump(il, IL_DL_RADIO, pkt->u.raw, len); } -EXPORT_SYMBOL(il_rx_pm_debug_statistics_notif); +EXPORT_SYMBOL(il_rx_pm_debug_stats_notif); void il_rx_reply_error(struct il_priv *il, struct il_rx_buf *rxb) @@ -1614,7 +1614,7 @@ void il_clear_traffic_stats(struct il_priv *il) * if CONFIG_IWLEGACY_DEBUGFS defined, * il_update_stats function will * record all the MGMT, CTRL and DATA pkt for both TX and Rx pass - * Use debugFs to display the rx/rx_statistics + * Use debugFs to display the rx/rx_stats * if CONFIG_IWLEGACY_DEBUGFS not being defined, then no MGMT and CTRL * information will be recorded, but DATA pkt still will be recorded * for the reason of il_led.c need to control the led blinking based on diff --git a/drivers/net/wireless/iwlegacy/iwl-core.h b/drivers/net/wireless/iwlegacy/iwl-core.h index bc2ae06bf4a6..833376171207 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.h +++ b/drivers/net/wireless/iwlegacy/iwl-core.h @@ -371,7 +371,7 @@ static inline void il_update_stats(struct il_priv *il, bool is_tx, * **************************************************/ void il_rx_pm_sleep_notif(struct il_priv *il, struct il_rx_buf *rxb); -void il_rx_pm_debug_statistics_notif(struct il_priv *il, +void il_rx_pm_debug_stats_notif(struct il_priv *il, struct il_rx_buf *rxb); void il_rx_reply_error(struct il_priv *il, struct il_rx_buf *rxb); @@ -390,7 +390,7 @@ void il_tx_cmd_complete(struct il_priv *il, /* Handlers */ void il_rx_spectrum_measure_notif(struct il_priv *il, struct il_rx_buf *rxb); -void il_recover_from_statistics(struct il_priv *il, +void il_recover_from_stats(struct il_priv *il, struct il_rx_pkt *pkt); void il_chswitch_done(struct il_priv *il, bool is_success); void il_rx_csa(struct il_priv *il, struct il_rx_buf *rxb); @@ -596,7 +596,7 @@ static inline int il_is_ready_rf(struct il_priv *il) } extern void il_send_bt_config(struct il_priv *il); -extern int il_send_statistics_request(struct il_priv *il, +extern int il_send_stats_request(struct il_priv *il, u8 flags, bool clear); void il_apm_stop(struct il_priv *il); int il_apm_init(struct il_priv *il); diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index a4b1f37f48e5..e8153b0dc5b7 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -102,7 +102,7 @@ static const struct file_operations il_dbgfs_##name##_ops = { \ .llseek = generic_file_llseek, \ }; -static ssize_t il_dbgfs_tx_statistics_read(struct file *file, +static ssize_t il_dbgfs_tx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { @@ -142,7 +142,7 @@ static ssize_t il_dbgfs_tx_statistics_read(struct file *file, } static ssize_t -il_dbgfs_clear_traffic_statistics_write(struct file *file, +il_dbgfs_clear_traffic_stats_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { @@ -162,7 +162,7 @@ il_dbgfs_clear_traffic_statistics_write(struct file *file, return count; } -static ssize_t il_dbgfs_rx_statistics_read(struct file *file, +static ssize_t il_dbgfs_rx_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { @@ -1031,7 +1031,7 @@ static ssize_t il_dbgfs_power_save_status_read(struct file *file, return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t il_dbgfs_clear_ucode_statistics_write(struct file *file, +static ssize_t il_dbgfs_clear_ucode_stats_write(struct file *file, const char __user *user_buf, size_t count, loff_t *ppos) { @@ -1047,9 +1047,9 @@ static ssize_t il_dbgfs_clear_ucode_statistics_write(struct file *file, if (sscanf(buf, "%d", &clear) != 1) return -EFAULT; - /* make request to uCode to retrieve statistics information */ + /* make request to uCode to retrieve stats information */ mutex_lock(&il->mutex); - il_send_statistics_request(il, CMD_SYNC, true); + il_send_stats_request(il, CMD_SYNC, true); mutex_unlock(&il->mutex); return count; @@ -1206,8 +1206,8 @@ static ssize_t il_dbgfs_wd_timeout_write(struct file *file, return count; } -DEBUGFS_READ_FILE_OPS(rx_statistics); -DEBUGFS_READ_FILE_OPS(tx_statistics); +DEBUGFS_READ_FILE_OPS(rx_stats); +DEBUGFS_READ_FILE_OPS(tx_stats); DEBUGFS_READ_WRITE_FILE_OPS(traffic_log); DEBUGFS_READ_FILE_OPS(rx_queue); DEBUGFS_READ_FILE_OPS(tx_queue); @@ -1217,8 +1217,8 @@ DEBUGFS_READ_FILE_OPS(ucode_general_stats); DEBUGFS_READ_FILE_OPS(sensitivity); DEBUGFS_READ_FILE_OPS(chain_noise); DEBUGFS_READ_FILE_OPS(power_save_status); -DEBUGFS_WRITE_FILE_OPS(clear_ucode_statistics); -DEBUGFS_WRITE_FILE_OPS(clear_traffic_statistics); +DEBUGFS_WRITE_FILE_OPS(clear_ucode_stats); +DEBUGFS_WRITE_FILE_OPS(clear_traffic_stats); DEBUGFS_READ_FILE_OPS(fh_reg); DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon); DEBUGFS_READ_WRITE_FILE_OPS(force_reset); @@ -1259,14 +1259,14 @@ int il_dbgfs_register(struct il_priv *il, const char *name) DEBUGFS_ADD_FILE(interrupt, dir_data, S_IWUSR | S_IRUSR); DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR); DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR); - DEBUGFS_ADD_FILE(rx_statistics, dir_debug, S_IRUSR); - DEBUGFS_ADD_FILE(tx_statistics, dir_debug, S_IRUSR); + DEBUGFS_ADD_FILE(rx_stats, dir_debug, S_IRUSR); + DEBUGFS_ADD_FILE(tx_stats, dir_debug, S_IRUSR); DEBUGFS_ADD_FILE(traffic_log, dir_debug, S_IWUSR | S_IRUSR); DEBUGFS_ADD_FILE(rx_queue, dir_debug, S_IRUSR); DEBUGFS_ADD_FILE(tx_queue, dir_debug, S_IRUSR); DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR); - DEBUGFS_ADD_FILE(clear_ucode_statistics, dir_debug, S_IWUSR); - DEBUGFS_ADD_FILE(clear_traffic_statistics, dir_debug, S_IWUSR); + DEBUGFS_ADD_FILE(clear_ucode_stats, dir_debug, S_IWUSR); + DEBUGFS_ADD_FILE(clear_traffic_stats, dir_debug, S_IWUSR); DEBUGFS_ADD_FILE(fh_reg, dir_debug, S_IRUSR); DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR); DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR); diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index ad72d3986147..4388538b9de8 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -57,7 +57,7 @@ struct il_tx_queue; /* Default noise level to report when noise measurement is not available. * This may be because we're: - * 1) Not associated (4965, no beacon statistics being sent to driver) + * 1) Not associated (4965, no beacon stats being sent to driver) * 2) Scanning (noise measurement does not apply to associated channel) * 3) Receiving CCK (3945 delivers noise info only for OFDM frames) * Use default noise value of -127 ... this is below the range of measurable @@ -801,8 +801,8 @@ enum { MEASUREMENT_ACTIVE = (1 << 1), }; -/* interrupt statistics */ -struct isr_statistics { +/* interrupt stats */ +struct isr_stats { u32 hw; u32 sw; u32 err_code; @@ -817,7 +817,7 @@ struct isr_statistics { u32 unhandled; }; -/* management statistics */ +/* management stats */ enum il_mgmt_stats { MANAGEMENT_ASSOC_REQ = 0, MANAGEMENT_ASSOC_RESP, @@ -833,7 +833,7 @@ enum il_mgmt_stats { MANAGEMENT_ACTION, MANAGEMENT_MAX, }; -/* control statistics */ +/* control stats */ enum il_ctrl_stats { CONTROL_BACK_REQ = 0, CONTROL_BACK, @@ -1087,7 +1087,7 @@ struct il_priv { struct traffic_stats rx_stats; /* counts interrupts */ - struct isr_statistics isr_stats; + struct isr_stats isr_stats; struct il_power_mgr power_data; @@ -1131,15 +1131,15 @@ struct il_priv { struct delayed_work thermal_periodic; struct delayed_work rfkill_poll; - struct il3945_notif_statistics statistics; + struct il3945_notif_stats stats; #ifdef CONFIG_IWLEGACY_DEBUGFS - struct il3945_notif_statistics accum_statistics; - struct il3945_notif_statistics delta_statistics; - struct il3945_notif_statistics max_delta; + struct il3945_notif_stats accum_stats; + struct il3945_notif_stats delta_stats; + struct il3945_notif_stats max_delta; #endif u32 sta_supp_rates; - int last_rx_rssi; /* From Rx packet statistics */ + int last_rx_rssi; /* From Rx packet stats */ /* Rx'd packet timing information */ u32 last_beacon_time; @@ -1169,11 +1169,11 @@ struct il_priv { u8 phy_calib_chain_noise_reset_cmd; u8 phy_calib_chain_noise_gain_cmd; - struct il_notif_statistics statistics; + struct il_notif_stats stats; #ifdef CONFIG_IWLEGACY_DEBUGFS - struct il_notif_statistics accum_statistics; - struct il_notif_statistics delta_statistics; - struct il_notif_statistics max_delta; + struct il_notif_stats accum_stats; + struct il_notif_stats delta_stats; + struct il_notif_stats max_delta; #endif } _4965; @@ -1229,7 +1229,7 @@ struct il_priv { u32 disable_chain_noise_cal; u32 disable_tx_power_cal; struct work_struct run_time_calib_work; - struct timer_list statistics_periodic; + struct timer_list stats_periodic; struct timer_list watchdog; bool hw_ready; diff --git a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h index f24b6b847fb4..19fa92d0e29f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h +++ b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h @@ -335,7 +335,7 @@ struct il_scale_tbl_info { }; struct il_traffic_load { - unsigned long time_stamp; /* age of the oldest statistics */ + unsigned long time_stamp; /* age of the oldest stats */ u32 packet_count[TID_QUEUE_MAX_SIZE]; /* packet count in this time * slice */ u32 total; /* total num of packets during the diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index dfc1431072b3..71b2fac1b5d3 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -229,7 +229,7 @@ static void il_rx_scan_results_notif(struct il_priv *il, notif->band ? "bg" : "a", le32_to_cpu(notif->tsf_high), le32_to_cpu(notif->tsf_low), - le32_to_cpu(notif->statistics[0]), + le32_to_cpu(notif->stats[0]), le32_to_cpu(notif->tsf_low) - il->scan_start_tsf); #endif } diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 446bdb5f8624..c602570a3408 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -862,16 +862,16 @@ static void il3945_setup_rx_handlers(struct il_priv *il) il_rx_spectrum_measure_notif; il->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; il->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = - il_rx_pm_debug_statistics_notif; + il_rx_pm_debug_stats_notif; il->rx_handlers[BEACON_NOTIFICATION] = il3945_rx_beacon_notif; /* * The same handler is used for both the REPLY to a discrete - * statistics request from the host as well as for the periodic - * statistics notifications (after received beacons) from the uCode. + * stats request from the host as well as for the periodic + * stats notifications (after received beacons) from the uCode. */ - il->rx_handlers[REPLY_STATISTICS_CMD] = il3945_reply_statistics; - il->rx_handlers[STATISTICS_NOTIFICATION] = il3945_hw_rx_statistics; + il->rx_handlers[REPLY_STATISTICS_CMD] = il3945_reply_stats; + il->rx_handlers[STATISTICS_NOTIFICATION] = il3945_hw_rx_stats; il_setup_rx_scan_handlers(il); il->rx_handlers[CARD_STATE_NOTIFICATION] = il3945_rx_card_state_notif; diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index 81613ed20449..736c2f540b16 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -464,16 +464,16 @@ static void il4965_rx_reply_alive(struct il_priv *il, } /** - * il4965_bg_statistics_periodic - Timer callback to queue statistics + * il4965_bg_stats_periodic - Timer callback to queue stats * - * This callback is provided in order to send a statistics request. + * This callback is provided in order to send a stats request. * * This timer function is continually reset to execute within * REG_RECALIB_PERIOD seconds since the last STATISTICS_NOTIFICATION - * was received. We need to ensure we receive the statistics in order + * was received. We need to ensure we receive the stats in order * to update the temperature used for calibrating the TXPOWER. */ -static void il4965_bg_statistics_periodic(unsigned long data) +static void il4965_bg_stats_periodic(unsigned long data) { struct il_priv *il = (struct il_priv *)data; @@ -484,7 +484,7 @@ static void il4965_bg_statistics_periodic(unsigned long data) if (!il_is_ready_rf(il)) return; - il_send_statistics_request(il, CMD_ASYNC, false); + il_send_stats_request(il, CMD_ASYNC, false); } static void il4965_rx_beacon_notif(struct il_priv *il, @@ -596,16 +596,16 @@ static void il4965_setup_rx_handlers(struct il_priv *il) il_rx_spectrum_measure_notif; il->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; il->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = - il_rx_pm_debug_statistics_notif; + il_rx_pm_debug_stats_notif; il->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; /* * The same handler is used for both the REPLY to a discrete - * statistics request from the host as well as for the periodic - * statistics notifications (after received beacons) from the uCode. + * stats request from the host as well as for the periodic + * stats notifications (after received beacons) from the uCode. */ - il->rx_handlers[REPLY_STATISTICS_CMD] = il4965_reply_statistics; - il->rx_handlers[STATISTICS_NOTIFICATION] = il4965_rx_statistics; + il->rx_handlers[REPLY_STATISTICS_CMD] = il4965_reply_stats; + il->rx_handlers[STATISTICS_NOTIFICATION] = il4965_rx_stats; il_setup_rx_scan_handlers(il); @@ -2105,9 +2105,9 @@ static void il4965_bg_run_time_calib_work(struct work_struct *work) if (il->start_calib) { il4965_chain_noise_calibration(il, - (void *)&il->_4965.statistics); + (void *)&il->_4965.stats); il4965_sensitivity_calibration(il, - (void *)&il->_4965.statistics); + (void *)&il->_4965.stats); } mutex_unlock(&il->mutex); @@ -2647,7 +2647,7 @@ static void il4965_bg_txpower_work(struct work_struct *work) mutex_lock(&il->mutex); /* If a scan happened to start before we got here - * then just return; the statistics notification will + * then just return; the stats notification will * kick off another scheduled work to compensate for * any temperature delta we missed here. */ if (test_bit(STATUS_EXIT_PENDING, &il->status) || @@ -2682,9 +2682,9 @@ static void il4965_setup_deferred_work(struct il_priv *il) INIT_WORK(&il->txpower_work, il4965_bg_txpower_work); - init_timer(&il->statistics_periodic); - il->statistics_periodic.data = (unsigned long)il; - il->statistics_periodic.function = il4965_bg_statistics_periodic; + init_timer(&il->stats_periodic); + il->stats_periodic.data = (unsigned long)il; + il->stats_periodic.function = il4965_bg_stats_periodic; init_timer(&il->watchdog); il->watchdog.data = (unsigned long)il; @@ -2703,7 +2703,7 @@ static void il4965_cancel_deferred_work(struct il_priv *il) il_cancel_scan_deferred_work(il); - del_timer_sync(&il->statistics_periodic); + del_timer_sync(&il->stats_periodic); } static void il4965_init_hw_rates(struct il_priv *il, -- cgit v1.2.3 From 6ce1dc45304eece672a36241cda587ba056d2b1f Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 26 Aug 2011 15:49:28 +0200 Subject: iwlegacy: s/window/win/ Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-3945-rs.c | 108 ++++++++++----------- drivers/net/wireless/iwlegacy/iwl-4965-hw.h | 4 +- drivers/net/wireless/iwlegacy/iwl-4965-rs.c | 134 +++++++++++++-------------- drivers/net/wireless/iwlegacy/iwl-4965-tx.c | 14 +-- drivers/net/wireless/iwlegacy/iwl-4965.c | 2 +- drivers/net/wireless/iwlegacy/iwl-commands.h | 16 ++-- drivers/net/wireless/iwlegacy/iwl-core.c | 6 +- drivers/net/wireless/iwlegacy/iwl-dev.h | 12 +-- drivers/net/wireless/iwlegacy/iwl-prph.h | 12 +-- drivers/net/wireless/iwlegacy/iwl-tx.c | 10 +- 10 files changed, 159 insertions(+), 159 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c index ebee6c350dbe..5c855e88b95e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c @@ -131,24 +131,24 @@ static u8 il3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band) return tpt_table[index].index; } -static void il3945_clear_window(struct il3945_rate_scale_data *window) +static void il3945_clear_win(struct il3945_rate_scale_data *win) { - window->data = 0; - window->success_counter = 0; - window->success_ratio = -1; - window->counter = 0; - window->average_tpt = IL_INVALID_VALUE; - window->stamp = 0; + win->data = 0; + win->success_counter = 0; + win->success_ratio = -1; + win->counter = 0; + win->average_tpt = IL_INVALID_VALUE; + win->stamp = 0; } /** - * il3945_rate_scale_flush_windows - flush out the rate scale windows + * il3945_rate_scale_flush_wins - flush out the rate scale wins * - * Returns the number of windows that have gathered data but were + * Returns the number of wins that have gathered data but were * not flushed. If there were any that were not flushed, then * reschedule the rate flushing routine. */ -static int il3945_rate_scale_flush_windows(struct il3945_rs_sta *rs_sta) +static int il3945_rate_scale_flush_wins(struct il3945_rs_sta *rs_sta) { int unflushed = 0; int i; @@ -170,7 +170,7 @@ static int il3945_rate_scale_flush_windows(struct il3945_rs_sta *rs_sta) D_RATE("flushing %d samples of rate " "index %d\n", rs_sta->win[i].counter, i); - il3945_clear_window(&rs_sta->win[i]); + il3945_clear_win(&rs_sta->win[i]); } else unflushed++; spin_unlock_irqrestore(&rs_sta->lock, flags); @@ -193,7 +193,7 @@ static void il3945_bg_rate_scale_flush(unsigned long data) D_RATE("enter\n"); - unflushed = il3945_rate_scale_flush_windows(rs_sta); + unflushed = il3945_rate_scale_flush_wins(rs_sta); spin_lock_irqsave(&rs_sta->lock, flags); @@ -248,14 +248,14 @@ static void il3945_bg_rate_scale_flush(unsigned long data) } /** - * il3945_collect_tx_data - Update the success/failure sliding window + * il3945_collect_tx_data - Update the success/failure sliding win * - * We keep a sliding window of the last 64 packets transmitted - * at this rate. window->data contains the bitmask of successful + * We keep a sliding win of the last 64 packets transmitted + * at this rate. win->data contains the bitmask of successful * packets. */ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, - struct il3945_rate_scale_data *window, + struct il3945_rate_scale_data *win, int success, int retries, int index) { unsigned long flags; @@ -271,34 +271,34 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, /* * Keep track of only the latest 62 tx frame attempts in this rate's - * history window; anything older isn't really relevant any more. - * If we have filled up the sliding window, drop the oldest attempt; + * history win; anything older isn't really relevant any more. + * If we have filled up the sliding win, drop the oldest attempt; * if the oldest attempt (highest bit in bitmap) shows "success", * subtract "1" from the success counter (this is the main reason * we keep these bitmaps!). * */ while (retries > 0) { - if (window->counter >= IL_RATE_MAX_WINDOW) { + if (win->counter >= IL_RATE_MAX_WINDOW) { /* remove earliest */ - window->counter = IL_RATE_MAX_WINDOW - 1; + win->counter = IL_RATE_MAX_WINDOW - 1; - if (window->data & (1ULL << (IL_RATE_MAX_WINDOW - 1))) { - window->data &= ~(1ULL << (IL_RATE_MAX_WINDOW - 1)); - window->success_counter--; + if (win->data & (1ULL << (IL_RATE_MAX_WINDOW - 1))) { + win->data &= ~(1ULL << (IL_RATE_MAX_WINDOW - 1)); + win->success_counter--; } } /* Increment frames-attempted counter */ - window->counter++; + win->counter++; /* Shift bitmap by one frame (throw away oldest history), * OR in "1", and increment "success" if this * frame was successful. */ - window->data <<= 1; + win->data <<= 1; if (success > 0) { - window->success_counter++; - window->data |= 0x1; + win->success_counter++; + win->data |= 0x1; success--; } @@ -306,24 +306,24 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, } /* Calculate current success ratio, avoid divide-by-0! */ - if (window->counter > 0) - window->success_ratio = 128 * (100 * window->success_counter) - / window->counter; + if (win->counter > 0) + win->success_ratio = 128 * (100 * win->success_counter) + / win->counter; else - window->success_ratio = IL_INVALID_VALUE; + win->success_ratio = IL_INVALID_VALUE; - fail_count = window->counter - window->success_counter; + fail_count = win->counter - win->success_counter; /* Calculate average throughput, if we have enough history. */ if (fail_count >= IL_RATE_MIN_FAILURE_TH || - window->success_counter >= IL_RATE_MIN_SUCCESS_TH) - window->average_tpt = ((window->success_ratio * + win->success_counter >= IL_RATE_MIN_SUCCESS_TH) + win->average_tpt = ((win->success_ratio * rs_sta->expected_tpt[index] + 64) / 128); else - window->average_tpt = IL_INVALID_VALUE; + win->average_tpt = IL_INVALID_VALUE; - /* Tag this window as having been updated */ - window->stamp = jiffies; + /* Tag this win as having been updated */ + win->stamp = jiffies; spin_unlock_irqrestore(&rs_sta->lock, flags); @@ -365,7 +365,7 @@ void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_i rs_sta->rate_scale_flush.function = il3945_bg_rate_scale_flush; for (i = 0; i < IL_RATE_COUNT_3945; i++) - il3945_clear_window(&rs_sta->win[i]); + il3945_clear_win(&rs_sta->win[i]); /* TODO: what is a good starting rate for STA? About middle? Maybe not * the lowest or the highest rate.. Could consider using RSSI from @@ -484,7 +484,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * last_index = first_index; /* - * Update the window for each rate. We determine which rates + * Update the win for each rate. We determine which rates * were Tx'd based on the total number of retries vs. the number * of retries configured for each rate -- currently set to the * il value 'retry_rate' vs. rate specific @@ -517,7 +517,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * } - /* Update the last index window with success/failure based on ACK */ + /* Update the last index win with success/failure based on ACK */ D_RATE("Update rate %d with %s.\n", last_index, (info->flags & IEEE80211_TX_STAT_ACK) ? @@ -526,7 +526,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * &rs_sta->win[last_index], info->flags & IEEE80211_TX_STAT_ACK, 1, last_index); - /* We updated the rate scale window -- if its been more than + /* We updated the rate scale win -- if its been more than * flush_time since the last run, schedule the flush * again */ spin_lock_irqsave(&rs_sta->lock, flags); @@ -636,7 +636,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, u16 high_low; int index; struct il3945_rs_sta *rs_sta = il_sta; - struct il3945_rate_scale_data *window = NULL; + struct il3945_rate_scale_data *win = NULL; int current_tpt = IL_INVALID_VALUE; int low_tpt = IL_INVALID_VALUE; int high_tpt = IL_INVALID_VALUE; @@ -691,29 +691,29 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, index = max_rate_idx; } - window = &(rs_sta->win[index]); + win = &(rs_sta->win[index]); - fail_count = window->counter - window->success_counter; + fail_count = win->counter - win->success_counter; if (fail_count < IL_RATE_MIN_FAILURE_TH && - window->success_counter < IL_RATE_MIN_SUCCESS_TH) { + win->success_counter < IL_RATE_MIN_SUCCESS_TH) { spin_unlock_irqrestore(&rs_sta->lock, flags); D_RATE("Invalid average_tpt on rate %d: " "counter: %d, success_counter: %d, " "expected_tpt is %sNULL\n", index, - window->counter, - window->success_counter, + win->counter, + win->success_counter, rs_sta->expected_tpt ? "not " : ""); /* Can't calculate this yet; not enough history */ - window->average_tpt = IL_INVALID_VALUE; + win->average_tpt = IL_INVALID_VALUE; goto out; } - current_tpt = window->average_tpt; + current_tpt = win->average_tpt; high_low = il3945_get_adjacent_rate(rs_sta, index, rate_mask, sband->band); @@ -736,7 +736,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, scale_action = 0; /* Low success ratio , need to drop the rate */ - if (window->success_ratio < IL_RATE_DECREASE_TH || !current_tpt) { + if (win->success_ratio < IL_RATE_DECREASE_TH || !current_tpt) { D_RATE("decrease rate because of low success_ratio\n"); scale_action = -1; /* No throughput measured yet for adjacent rates, @@ -744,7 +744,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, } else if (low_tpt == IL_INVALID_VALUE && high_tpt == IL_INVALID_VALUE) { - if (high != IL_RATE_INVALID && window->success_ratio >= IL_RATE_INCREASE_TH) + if (high != IL_RATE_INVALID && win->success_ratio >= IL_RATE_INCREASE_TH) scale_action = 1; else if (low != IL_RATE_INVALID) scale_action = 0; @@ -768,7 +768,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, /* High rate has better throughput, Increase * rate */ if (high_tpt > current_tpt && - window->success_ratio >= IL_RATE_INCREASE_TH) + win->success_ratio >= IL_RATE_INCREASE_TH) scale_action = 1; else { D_RATE( @@ -780,7 +780,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, D_RATE( "decrease rate because of low tpt\n"); scale_action = -1; - } else if (window->success_ratio >= IL_RATE_INCREASE_TH) { + } else if (win->success_ratio >= IL_RATE_INCREASE_TH) { /* Lower rate has better * throughput,decrease rate */ scale_action = 1; @@ -791,7 +791,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, /* Sanity check; asked for decrease, but success rate or throughput * has been good at old rate. Don't change it. */ if (scale_action == -1 && low != IL_RATE_INVALID && - (window->success_ratio > IL_RATE_HIGH_TH || + (win->success_ratio > IL_RATE_HIGH_TH || current_tpt > 100 * rs_sta->expected_tpt[low])) scale_action = 0; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h index 21ff694421a9..83748c7ae93f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h @@ -773,8 +773,8 @@ enum { * * Each Tx queue uses a byte-count table containing 320 entries: * one 16-bit entry for each of 256 TFDs, plus an additional 64 entries that - * duplicate the first 64 entries (to avoid wrap-around within a Tx window; - * max Tx window is 64 TFDs). + * duplicate the first 64 entries (to avoid wrap-around within a Tx win; + * max Tx win is 64 TFDs). * * When driver sets up a new TFD, it must also enter the total byte count * of the frame to be transmitted into the corresponding entry in the byte diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index e99a20c8891d..5d88a452e1a3 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -46,7 +46,7 @@ #define IL_NUMBER_TRY 1 #define IL_HT_NUMBER_TRY 3 -#define IL_RATE_MAX_WINDOW 62 /* # tx in history window */ +#define IL_RATE_MAX_WINDOW 62 /* # tx in history win */ #define IL_RATE_MIN_FAILURE_TH 6 /* min failures to calc tpt */ #define IL_RATE_MIN_SUCCESS_TH 8 /* min successes to calc tpt */ @@ -226,14 +226,14 @@ static inline u8 il4965_rs_extract_rate(u32 rate_n_flags) } static void -il4965_rs_rate_scale_clear_window(struct il_rate_scale_data *window) +il4965_rs_rate_scale_clear_win(struct il_rate_scale_data *win) { - window->data = 0; - window->success_counter = 0; - window->success_ratio = IL_INVALID_VALUE; - window->counter = 0; - window->average_tpt = IL_INVALID_VALUE; - window->stamp = 0; + win->data = 0; + win->success_counter = 0; + win->success_ratio = IL_INVALID_VALUE; + win->counter = 0; + win->average_tpt = IL_INVALID_VALUE; + win->stamp = 0; } static inline u8 il4965_rs_is_valid_ant(u8 valid_antenna, u8 ant_type) @@ -408,58 +408,58 @@ il4965_get_expected_tpt(struct il_scale_tbl_info *tbl, int rs_index) } /** - * il4965_rs_collect_tx_data - Update the success/failure sliding window + * il4965_rs_collect_tx_data - Update the success/failure sliding win * - * We keep a sliding window of the last 62 packets transmitted - * at this rate. window->data contains the bitmask of successful + * We keep a sliding win of the last 62 packets transmitted + * at this rate. win->data contains the bitmask of successful * packets. */ static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, int scale_index, int attempts, int successes) { - struct il_rate_scale_data *window = NULL; + struct il_rate_scale_data *win = NULL; static const u64 mask = (((u64)1) << (IL_RATE_MAX_WINDOW - 1)); s32 fail_count, tpt; if (scale_index < 0 || scale_index >= IL_RATE_COUNT) return -EINVAL; - /* Select window for current tx bit rate */ - window = &(tbl->win[scale_index]); + /* Select win for current tx bit rate */ + win = &(tbl->win[scale_index]); /* Get expected throughput */ tpt = il4965_get_expected_tpt(tbl, scale_index); /* * Keep track of only the latest 62 tx frame attempts in this rate's - * history window; anything older isn't really relevant any more. - * If we have filled up the sliding window, drop the oldest attempt; + * history win; anything older isn't really relevant any more. + * If we have filled up the sliding win, drop the oldest attempt; * if the oldest attempt (highest bit in bitmap) shows "success", * subtract "1" from the success counter (this is the main reason * we keep these bitmaps!). */ while (attempts > 0) { - if (window->counter >= IL_RATE_MAX_WINDOW) { + if (win->counter >= IL_RATE_MAX_WINDOW) { /* remove earliest */ - window->counter = IL_RATE_MAX_WINDOW - 1; + win->counter = IL_RATE_MAX_WINDOW - 1; - if (window->data & mask) { - window->data &= ~mask; - window->success_counter--; + if (win->data & mask) { + win->data &= ~mask; + win->success_counter--; } } /* Increment frames-attempted counter */ - window->counter++; + win->counter++; /* Shift bitmap by one frame to throw away oldest history */ - window->data <<= 1; + win->data <<= 1; /* Mark the most recent #successes attempts as successful */ if (successes > 0) { - window->success_counter++; - window->data |= 0x1; + win->success_counter++; + win->data |= 0x1; successes--; } @@ -467,23 +467,23 @@ static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, } /* Calculate current success ratio, avoid divide-by-0! */ - if (window->counter > 0) - window->success_ratio = 128 * (100 * window->success_counter) - / window->counter; + if (win->counter > 0) + win->success_ratio = 128 * (100 * win->success_counter) + / win->counter; else - window->success_ratio = IL_INVALID_VALUE; + win->success_ratio = IL_INVALID_VALUE; - fail_count = window->counter - window->success_counter; + fail_count = win->counter - win->success_counter; /* Calculate average throughput, if we have enough history. */ if (fail_count >= IL_RATE_MIN_FAILURE_TH || - window->success_counter >= IL_RATE_MIN_SUCCESS_TH) - window->average_tpt = (window->success_ratio * tpt + 64) / 128; + win->success_counter >= IL_RATE_MIN_SUCCESS_TH) + win->average_tpt = (win->success_ratio * tpt + 64) / 128; else - window->average_tpt = IL_INVALID_VALUE; + win->average_tpt = IL_INVALID_VALUE; - /* Tag this window as having been updated */ - window->stamp = jiffies; + /* Tag this win as having been updated */ + win->stamp = jiffies; return 0; } @@ -817,7 +817,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, struct il_rxon_context *ctx = sta_priv->common.ctx; D_RATE( - "get frame ack response, update rate scale window\n"); + "get frame ack response, update rate scale win\n"); /* Treat uninitialized rate scaling data same as non-existing. */ if (!lq_sta) { @@ -1284,7 +1284,7 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); struct il_scale_tbl_info *search_tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - struct il_rate_scale_data *window = &(tbl->win[index]); + struct il_rate_scale_data *win = &(tbl->win[index]); u32 sz = (sizeof(struct il_scale_tbl_info) - (sizeof(struct il_rate_scale_data) * IL_RATE_COUNT)); u8 start_action; @@ -1310,7 +1310,7 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, break; /* Don't change antenna if success has been great */ - if (window->success_ratio >= IL_RS_GOOD_RATIO) + if (win->success_ratio >= IL_RS_GOOD_RATIO) break; /* Set up search table to try other antenna */ @@ -1401,7 +1401,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); struct il_scale_tbl_info *search_tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - struct il_rate_scale_data *window = &(tbl->win[index]); + struct il_rate_scale_data *win = &(tbl->win[index]); struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; u32 sz = (sizeof(struct il_scale_tbl_info) - (sizeof(struct il_rate_scale_data) * IL_RATE_COUNT)); @@ -1425,7 +1425,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, tx_chains_num <= 2)) break; - if (window->success_ratio >= IL_RS_GOOD_RATIO) + if (win->success_ratio >= IL_RS_GOOD_RATIO) break; memcpy(search_tbl, tbl, sz); @@ -1523,7 +1523,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); struct il_scale_tbl_info *search_tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - struct il_rate_scale_data *window = &(tbl->win[index]); + struct il_rate_scale_data *win = &(tbl->win[index]); struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; u32 sz = (sizeof(struct il_scale_tbl_info) - (sizeof(struct il_rate_scale_data) * IL_RATE_COUNT)); @@ -1544,7 +1544,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, if (tx_chains_num <= 2) break; - if (window->success_ratio >= IL_RS_GOOD_RATIO) + if (win->success_ratio >= IL_RS_GOOD_RATIO) break; memcpy(search_tbl, tbl, sz); @@ -1704,7 +1704,7 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) D_RATE( "LQ: stay in table clear win\n"); for (i = 0; i < IL_RATE_COUNT; i++) - il4965_rs_rate_scale_clear_window( + il4965_rs_rate_scale_clear_win( &(tbl->win[i])); } } @@ -1714,7 +1714,7 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) * "search" table). */ if (!lq_sta->stay_in_tbl) { for (i = 0; i < IL_RATE_COUNT; i++) - il4965_rs_rate_scale_clear_window( + il4965_rs_rate_scale_clear_win( &(tbl->win[i])); } } @@ -1756,7 +1756,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, int high = IL_RATE_INVALID; int index; int i; - struct il_rate_scale_data *window = NULL; + struct il_rate_scale_data *win = NULL; int current_tpt = IL_INVALID_VALUE; int low_tpt = IL_INVALID_VALUE; int high_tpt = IL_INVALID_VALUE; @@ -1859,7 +1859,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, return; } - /* Get expected throughput table and history window for current rate */ + /* Get expected throughput table and history win for current rate */ if (!tbl->expected_tpt) { IL_ERR("tbl->expected_tpt is NULL\n"); return; @@ -1870,11 +1870,11 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, lq_sta->max_rate_idx < index) { index = lq_sta->max_rate_idx; update_lq = 1; - window = &(tbl->win[index]); + win = &(tbl->win[index]); goto lq_update; } - window = &(tbl->win[index]); + win = &(tbl->win[index]); /* * If there is not enough history to calculate actual average @@ -1883,15 +1883,15 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, * Set up new rate table in uCode only if old rate is not supported * in current association (use new rate found above). */ - fail_count = window->counter - window->success_counter; + fail_count = win->counter - win->success_counter; if (fail_count < IL_RATE_MIN_FAILURE_TH && - window->success_counter < IL_RATE_MIN_SUCCESS_TH) { + win->success_counter < IL_RATE_MIN_SUCCESS_TH) { D_RATE("LQ: still below TH. succ=%d total=%d " "for index %d\n", - window->success_counter, window->counter, index); + win->success_counter, win->counter, index); /* Can't calculate this yet; not enough history */ - window->average_tpt = IL_INVALID_VALUE; + win->average_tpt = IL_INVALID_VALUE; /* Should we stay with this modulation mode, * or search for a new one? */ @@ -1901,11 +1901,11 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, } /* Else we have enough samples; calculate estimate of * actual average throughput */ - if (window->average_tpt != ((window->success_ratio * + if (win->average_tpt != ((win->success_ratio * tbl->expected_tpt[index] + 64) / 128)) { IL_ERR( "expected_tpt should have been calculated by now\n"); - window->average_tpt = ((window->success_ratio * + win->average_tpt = ((win->success_ratio * tbl->expected_tpt[index] + 64) / 128); } @@ -1914,12 +1914,12 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* If good success, continue using the "search" mode; * no need to send new link quality command, since we're * continuing to use the setup that we've been trying. */ - if (window->average_tpt > lq_sta->last_tpt) { + if (win->average_tpt > lq_sta->last_tpt) { D_RATE("LQ: SWITCHING TO NEW TABLE " "suc=%d cur-tpt=%d old-tpt=%d\n", - window->success_ratio, - window->average_tpt, + win->success_ratio, + win->average_tpt, lq_sta->last_tpt); if (!is_legacy(tbl->lq_type)) @@ -1927,15 +1927,15 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Swap tables; "search" becomes "active" */ lq_sta->active_tbl = active_tbl; - current_tpt = window->average_tpt; + current_tpt = win->average_tpt; /* Else poor success; go back to mode in "active" table */ } else { D_RATE("LQ: GOING BACK TO THE OLD TABLE " "suc=%d cur-tpt=%d old-tpt=%d\n", - window->success_ratio, - window->average_tpt, + win->success_ratio, + win->average_tpt, lq_sta->last_tpt); /* Nullify "search" table */ @@ -1973,10 +1973,10 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, lq_sta->max_rate_idx < high) high = IL_RATE_INVALID; - sr = window->success_ratio; + sr = win->success_ratio; /* Collect measured throughputs for current and adjacent rates */ - current_tpt = window->average_tpt; + current_tpt = win->average_tpt; if (low != IL_RATE_INVALID) low_tpt = tbl->win[low].average_tpt; if (high != IL_RATE_INVALID) @@ -2082,7 +2082,7 @@ lq_update: * 3) Allowing a new search */ if (!update_lq && !done_search && !lq_sta->stay_in_tbl && - window->counter) { + win->counter) { /* Save current throughput to compare with "search" throughput*/ lq_sta->last_tpt = current_tpt; @@ -2103,7 +2103,7 @@ lq_update: /* Access the "search" table, clear its history. */ tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); for (i = 0; i < IL_RATE_COUNT; i++) - il4965_rs_rate_scale_clear_window( + il4965_rs_rate_scale_clear_win( &(tbl->win[i])); /* Use new "search" start rate */ @@ -2314,7 +2314,7 @@ static void *il4965_rs_alloc_sta(void *il_rate, struct ieee80211_sta *sta, struct il_priv *il; il = (struct il_priv *)il_rate; - D_RATE("create station rate scale window\n"); + D_RATE("create station rate scale win\n"); lq_sta = &sta_priv->lq_sta; @@ -2346,14 +2346,14 @@ il4965_rs_rate_init(struct il_priv *il, for (j = 0; j < LQ_SIZE; j++) for (i = 0; i < IL_RATE_COUNT; i++) - il4965_rs_rate_scale_clear_window( + il4965_rs_rate_scale_clear_win( &lq_sta->lq_info[j].win[i]); lq_sta->flush_timer = 0; lq_sta->supp_rates = sta->supp_rates[sband->band]; for (j = 0; j < LQ_SIZE; j++) for (i = 0; i < IL_RATE_COUNT; i++) - il4965_rs_rate_scale_clear_window( + il4965_rs_rate_scale_clear_win( &lq_sta->lq_info[j].win[i]); D_RATE("LQ:" diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index dff48e89862e..68c86e009cf3 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -834,7 +834,7 @@ static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, il->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); il4965_set_wr_ptrs(il, txq_id, ssn_idx); - /* Set up Tx window size and frame limit for this queue */ + /* Set up Tx win size and frame limit for this queue */ il_write_targ_mem(il, il->scd_base_addr + IL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id), (SCD_WIN_SIZE << IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & @@ -1171,7 +1171,7 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, D_TX_REPLY("BA %d %d\n", agg->start_idx, ba_resp->seq_ctl); - /* Calculate shift to align block-ack bits with our Tx window bits */ + /* Calculate shift to align block-ack bits with our Tx win bits */ sh = agg->start_idx - SEQ_TO_INDEX(seq_ctl >> 4); if (sh < 0) /* tbw something is wrong with indices */ sh += 0x100; @@ -1260,8 +1260,8 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, /* "flow" corresponds to Tx queue */ u16 scd_flow = le16_to_cpu(ba_resp->scd_flow); - /* "ssn" is start of block-ack Tx window, corresponds to index - * (in Tx queue's circular buffer) of first TFD/frame in window */ + /* "ssn" is start of block-ack Tx win, corresponds to index + * (in Tx queue's circular buffer) of first TFD/frame in win */ u16 ba_resp_scd_ssn = le16_to_cpu(ba_resp->scd_ssn); if (scd_flow >= il->hw_params.max_txq_num) { @@ -1287,7 +1287,7 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, return; } - /* Find index just before block-ack window */ + /* Find index just before block-ack win */ index = il_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd); spin_lock_irqsave(&il->sta_lock, flags); @@ -1309,11 +1309,11 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, agg->start_idx, (unsigned long long)agg->bitmap); - /* Update driver's record of ACK vs. not for each frame in window */ + /* Update driver's record of ACK vs. not for each frame in win */ il4965_tx_status_reply_compressed_ba(il, agg, ba_resp); /* Release all TFDs before the SSN, i.e. all TFDs in front of - * block-ack window (we assume that they've been successfully + * block-ack win (we assume that they've been successfully * transmitted ... if not, it's too late anyway). */ if (txq->q.read_ptr != (ba_resp_scd_ssn & 0xff)) { /* calculate mac80211 ampdu sw queue to wake */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index 9cfc14001d3d..f62475de7591 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -1649,7 +1649,7 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, u64 bitmap = 0; int start = agg->start_idx; - /* Construct bit-map of pending frames within Tx window */ + /* Construct bit-map of pending frames within Tx win */ for (i = 0; i < agg->frame_count; i++) { u16 sc; status = le16_to_cpu(frame_status[i].status); diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h index ea6c0f50ecf7..d1876d05e7f0 100644 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ b/drivers/net/wireless/iwlegacy/iwl-commands.h @@ -754,7 +754,7 @@ struct il4965_rxon_assoc_cmd { struct il_rxon_time_cmd { __le64 timestamp; __le16 beacon_interval; - __le16 atim_window; + __le16 atim_win; __le32 beacon_init_val; __le16 listen_interval; u8 dtim_period; @@ -803,15 +803,15 @@ struct il_csa_notification { * struct il_ac_qos -- QOS timing params for REPLY_QOS_PARAM * One for each of 4 EDCA access categories in struct il_qosparam_cmd * - * @cw_min: Contention window, start value in numbers of slots. + * @cw_min: Contention win, start value in numbers of slots. * Should be a power-of-2, minus 1. Device's default is 0x0f. - * @cw_max: Contention window, max value in numbers of slots. + * @cw_max: Contention win, max value in numbers of slots. * Should be a power-of-2, minus 1. Device's default is 0x3f. * @aifsn: Number of slots in Arbitration Interframe Space (before * performing random backoff timing prior to Tx). Device default 1. * @edca_txop: Length of Tx opportunity, in uSecs. Device default is 0. * - * Device will automatically increase contention window by (2*CW) + 1 for each + * Device will automatically increase contention win by (2*CW) + 1 for each * transmission retry. Device uses cw_max as a bit mask, ANDed with new CW * value, to cap the CW value. */ @@ -1948,13 +1948,13 @@ struct il_link_qual_agg_params { * speculative mode as the new current active mode. * * Each history set contains, separately for each possible rate, data for a - * sliding window of the 62 most recent tx attempts at that rate. The data + * sliding win of the 62 most recent tx attempts at that rate. The data * includes a shifting bitmap of success(1)/failure(0), and sums of successful * and attempted frames, from which the driver can additionally calculate a * success ratio (success / attempted) and number of failures - * (attempted - success), and control the size of the window (attempted). + * (attempted - success), and control the size of the win (attempted). * The driver uses the bit map to remove successes from the success sum, as - * the oldest tx attempts fall out of the window. + * the oldest tx attempts fall out of the win. * * When the 4965 device makes multiple tx attempts for a given frame, each * attempt might be at a different rate, and have different modulation @@ -2017,7 +2017,7 @@ struct il_link_qual_agg_params { * * 6) Re-evaluate the rate after each tx frame. If working with block- * acknowledge, history and stats may be calculated for the entire - * block (including prior history that fits within the history windows), + * block (including prior history that fits within the history wins), * before re-evaluation. * * FINDING BEST STARTING MODULATION MODE: diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index 475bcac7aa9e..6742a6558ba9 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -380,10 +380,10 @@ il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx) beacon_int = vif ? vif->bss_conf.beacon_int : 0; /* - * TODO: For IBSS we need to get atim_window from mac80211, + * TODO: For IBSS we need to get atim_win from mac80211, * for now just always use 0 */ - ctx->timing.atim_window = 0; + ctx->timing.atim_win = 0; beacon_int = il_adjust_beacon_interval(beacon_int, il->hw_params.max_beacon_itrvl * TIME_UNIT); @@ -400,7 +400,7 @@ il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx) "beacon interval %d beacon timer %d beacon tim %d\n", le16_to_cpu(ctx->timing.beacon_interval), le32_to_cpu(ctx->timing.beacon_init_val), - le16_to_cpu(ctx->timing.atim_window)); + le16_to_cpu(ctx->timing.atim_win)); return il_send_cmd_pdu(il, ctx->rxon_timing_cmd, sizeof(ctx->timing), &ctx->timing); diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 4388538b9de8..18dd253b43f7 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -129,7 +129,7 @@ struct il_queue { int read_ptr; /* last used entry (index) host_r*/ /* use for monitoring and recovering the stuck queue */ dma_addr_t dma_addr; /* physical addr for BD's */ - int n_window; /* safe queue window */ + int n_win; /* safe queue win */ u32 id; int low_mark; /* low watermark, resume queue if free * space more than this */ @@ -377,9 +377,9 @@ struct il_rx_queue { * @txq_id: Tx queue used for Tx attempt * @frame_count: # frames attempted by Tx command * @wait_for_ba: Expect block-ack before next Tx reply - * @start_idx: Index of 1st Transmit Frame Descriptor (TFD) in Tx window - * @bitmap0: Low order bitmap, one bit for each frame pending ACK in Tx window - * @bitmap1: High order, one bit for each frame pending ACK in Tx window + * @start_idx: Index of 1st Transmit Frame Descriptor (TFD) in Tx win + * @bitmap0: Low order bitmap, one bit for each frame pending ACK in Tx win + * @bitmap1: High order, one bit for each frame pending ACK in Tx win * @rate_n_flags: Rate at which Tx was attempted * * If REPLY_TX indicates that aggregation was attempted, driver must wait @@ -645,10 +645,10 @@ static inline u8 il_get_cmd_index(struct il_queue *q, u32 index, * the big buffer at end of command array */ if (is_huge) - return q->n_window; /* must be power of 2 */ + return q->n_win; /* must be power of 2 */ /* Otherwise, use normal size buffers */ - return index & (q->n_window - 1); + return index & (q->n_win - 1); } diff --git a/drivers/net/wireless/iwlegacy/iwl-prph.h b/drivers/net/wireless/iwlegacy/iwl-prph.h index caa383726787..200f2955ab54 100644 --- a/drivers/net/wireless/iwlegacy/iwl-prph.h +++ b/drivers/net/wireless/iwlegacy/iwl-prph.h @@ -274,13 +274,13 @@ * The driver sets up each queue to work in one of two modes: * * 1) Scheduler-Ack, in which the scheduler automatically supports a - * block-ack (BA) window of up to 64 TFDs. In this mode, each queue + * block-ack (BA) win of up to 64 TFDs. In this mode, each queue * contains TFDs for a unique combination of Recipient Address (RA) * and Traffic Identifier (TID), that is, traffic of a given * Quality-Of-Service (QOS) priority, destined for a single station. * * In scheduler-ack mode, the scheduler keeps track of the Tx status of - * each frame within the BA window, including whether it's been transmitted, + * each frame within the BA win, including whether it's been transmitted, * and whether it's been acknowledged by the receiving station. The device * automatically processes block-acks received from the receiving STA, * and reschedules un-acked frames to be retransmitted (successful @@ -316,7 +316,7 @@ */ /** - * Max Tx window size is the max number of contiguous TFDs that the scheduler + * Max Tx win size is the max number of contiguous TFDs that the scheduler * can keep track of at one time when creating block-ack chains of frames. * Note that "64" matches the number of ack bits in a block-ack packet. * Driver should use SCD_WIN_SIZE and SCD_FRAME_LIMIT values to initialize @@ -377,7 +377,7 @@ /* * Queue (x) Read Pointers (indexes, really!), one for each Tx queue. * For FIFO mode, index indicates next frame to transmit. - * For Scheduler-ACK mode, index indicates first frame in Tx window. + * For Scheduler-ACK mode, index indicates first frame in Tx win. * Initialized by driver, updated by scheduler. */ #define IL49_SCD_QUEUE_RDPTR(x) (IL49_SCD_START_OFFSET + 0x64 + (x) * 4) @@ -414,7 +414,7 @@ * Driver should init to "1" for aggregation mode, or "0" otherwise. * 7-6: Driver should init to "0" * 5: Window Size Left; indicates whether scheduler can request - * another TFD, based on window size, etc. Driver should init + * another TFD, based on win size, etc. Driver should init * this bit to "1" for aggregation mode, or "0" for non-agg. * 4-1: Tx FIFO to use (range 0-7). * 0: Queue is active (1), not active (0). @@ -460,7 +460,7 @@ * each queue's entry as follows: * * LS Dword bit fields: - * 0-06: Max Tx window size for Scheduler-ACK. Driver should init to 64. + * 0-06: Max Tx win size for Scheduler-ACK. Driver should init to 64. * * MS Dword bit fields: * 16-22: Frame limit. Driver should init to 10 (0xa). diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index 2e95b7885c6d..b9c417ce52b3 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -165,7 +165,7 @@ void il_cmd_queue_unmap(struct il_priv *il) q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); } - i = q->n_window; + i = q->n_win; if (txq->meta[i].flags & CMD_MAPPED) { pci_unmap_single(il->pci_dev, dma_unmap_addr(&txq->meta[i], mapping), @@ -243,7 +243,7 @@ int il_queue_space(const struct il_queue *q) s -= q->n_bd; if (s <= 0) - s += q->n_window; + s += q->n_win; /* keep some reserve to not confuse empty and full situations */ s -= 2; if (s < 0) @@ -260,7 +260,7 @@ static int il_queue_init(struct il_priv *il, struct il_queue *q, int count, int slots_num, u32 id) { q->n_bd = count; - q->n_window = slots_num; + q->n_win = slots_num; q->id = id; /* count must be power-of-two size, otherwise il_queue_inc_wrap @@ -271,11 +271,11 @@ static int il_queue_init(struct il_priv *il, struct il_queue *q, * il_get_cmd_index is broken. */ BUG_ON(!is_power_of_2(slots_num)); - q->low_mark = q->n_window / 4; + q->low_mark = q->n_win / 4; if (q->low_mark < 4) q->low_mark = 4; - q->high_mark = q->n_window / 8; + q->high_mark = q->n_win / 8; if (q->high_mark < 2) q->high_mark = 2; -- cgit v1.2.3 From 2eb058162ea8b72d5d8965520d05bcdc160010b3 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 26 Aug 2011 16:07:43 +0200 Subject: iwlegacy: s/IL_RATE/RATE/ Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-3945-rs.c | 160 ++++++++--------- drivers/net/wireless/iwlegacy/iwl-3945.c | 92 +++++----- drivers/net/wireless/iwlegacy/iwl-3945.h | 4 +- drivers/net/wireless/iwlegacy/iwl-4965-lib.c | 8 +- drivers/net/wireless/iwlegacy/iwl-4965-rs.c | 180 +++++++++---------- drivers/net/wireless/iwlegacy/iwl-4965-sta.c | 4 +- drivers/net/wireless/iwlegacy/iwl-4965-tx.c | 2 +- drivers/net/wireless/iwlegacy/iwl-commands.h | 2 +- drivers/net/wireless/iwlegacy/iwl-core.c | 16 +- drivers/net/wireless/iwlegacy/iwl-legacy-rs.h | 244 +++++++++++++------------- drivers/net/wireless/iwlegacy/iwl-sta.c | 2 +- drivers/net/wireless/iwlegacy/iwl3945-base.c | 8 +- drivers/net/wireless/iwlegacy/iwl4965-base.c | 6 +- 13 files changed, 364 insertions(+), 364 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c index 5c855e88b95e..92fa4366ab89 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c @@ -42,19 +42,19 @@ #define RS_NAME "iwl-3945-rs" -static s32 il3945_expected_tpt_g[IL_RATE_COUNT_3945] = { +static s32 il3945_expected_tpt_g[RATE_COUNT_3945] = { 7, 13, 35, 58, 0, 0, 76, 104, 130, 168, 191, 202 }; -static s32 il3945_expected_tpt_g_prot[IL_RATE_COUNT_3945] = { +static s32 il3945_expected_tpt_g_prot[RATE_COUNT_3945] = { 7, 13, 35, 58, 0, 0, 0, 80, 93, 113, 123, 125 }; -static s32 il3945_expected_tpt_a[IL_RATE_COUNT_3945] = { +static s32 il3945_expected_tpt_a[RATE_COUNT_3945] = { 0, 0, 0, 0, 40, 57, 72, 98, 121, 154, 177, 186 }; -static s32 il3945_expected_tpt_b[IL_RATE_COUNT_3945] = { +static s32 il3945_expected_tpt_b[RATE_COUNT_3945] = { 7, 13, 35, 58, 0, 0, 0, 0, 0, 0, 0, 0 }; @@ -64,39 +64,39 @@ struct il3945_tpt_entry { }; static struct il3945_tpt_entry il3945_tpt_table_a[] = { - {-60, IL_RATE_54M_INDEX}, - {-64, IL_RATE_48M_INDEX}, - {-72, IL_RATE_36M_INDEX}, - {-80, IL_RATE_24M_INDEX}, - {-84, IL_RATE_18M_INDEX}, - {-85, IL_RATE_12M_INDEX}, - {-87, IL_RATE_9M_INDEX}, - {-89, IL_RATE_6M_INDEX} + {-60, RATE_54M_INDEX}, + {-64, RATE_48M_INDEX}, + {-72, RATE_36M_INDEX}, + {-80, RATE_24M_INDEX}, + {-84, RATE_18M_INDEX}, + {-85, RATE_12M_INDEX}, + {-87, RATE_9M_INDEX}, + {-89, RATE_6M_INDEX} }; static struct il3945_tpt_entry il3945_tpt_table_g[] = { - {-60, IL_RATE_54M_INDEX}, - {-64, IL_RATE_48M_INDEX}, - {-68, IL_RATE_36M_INDEX}, - {-80, IL_RATE_24M_INDEX}, - {-84, IL_RATE_18M_INDEX}, - {-85, IL_RATE_12M_INDEX}, - {-86, IL_RATE_11M_INDEX}, - {-88, IL_RATE_5M_INDEX}, - {-90, IL_RATE_2M_INDEX}, - {-92, IL_RATE_1M_INDEX} + {-60, RATE_54M_INDEX}, + {-64, RATE_48M_INDEX}, + {-68, RATE_36M_INDEX}, + {-80, RATE_24M_INDEX}, + {-84, RATE_18M_INDEX}, + {-85, RATE_12M_INDEX}, + {-86, RATE_11M_INDEX}, + {-88, RATE_5M_INDEX}, + {-90, RATE_2M_INDEX}, + {-92, RATE_1M_INDEX} }; -#define IL_RATE_MAX_WINDOW 62 -#define IL_RATE_FLUSH (3*HZ) -#define IL_RATE_WIN_FLUSH (HZ/2) +#define RATE_MAX_WINDOW 62 +#define RATE_FLUSH (3*HZ) +#define RATE_WIN_FLUSH (HZ/2) #define IL39_RATE_HIGH_TH 11520 #define IL_SUCCESS_UP_TH 8960 #define IL_SUCCESS_DOWN_TH 10880 -#define IL_RATE_MIN_FAILURE_TH 6 -#define IL_RATE_MIN_SUCCESS_TH 8 -#define IL_RATE_DECREASE_TH 1920 -#define IL_RATE_RETRY_TH 15 +#define RATE_MIN_FAILURE_TH 6 +#define RATE_MIN_SUCCESS_TH 8 +#define RATE_DECREASE_TH 1920 +#define RATE_RETRY_TH 15 static u8 il3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band) { @@ -157,16 +157,16 @@ static int il3945_rate_scale_flush_wins(struct il3945_rs_sta *rs_sta) /* * For each rate, if we have collected data on that rate - * and it has been more than IL_RATE_WIN_FLUSH + * and it has been more than RATE_WIN_FLUSH * since we flushed, clear out the gathered stats */ - for (i = 0; i < IL_RATE_COUNT_3945; i++) { + for (i = 0; i < RATE_COUNT_3945; i++) { if (!rs_sta->win[i].counter) continue; spin_lock_irqsave(&rs_sta->lock, flags); if (time_after(jiffies, rs_sta->win[i].stamp + - IL_RATE_WIN_FLUSH)) { + RATE_WIN_FLUSH)) { D_RATE("flushing %d samples of rate " "index %d\n", rs_sta->win[i].counter, i); @@ -179,8 +179,8 @@ static int il3945_rate_scale_flush_wins(struct il3945_rs_sta *rs_sta) return unflushed; } -#define IL_RATE_FLUSH_MAX 5000 /* msec */ -#define IL_RATE_FLUSH_MIN 50 /* msec */ +#define RATE_FLUSH_MAX 5000 /* msec */ +#define RATE_FLUSH_MIN 50 /* msec */ #define IL_AVERAGE_PACKETS 1500 static void il3945_bg_rate_scale_flush(unsigned long data) @@ -217,12 +217,12 @@ static void il3945_bg_rate_scale_flush(unsigned long data) if (pps) { duration = (IL_AVERAGE_PACKETS * 1000) / pps; - if (duration < IL_RATE_FLUSH_MIN) - duration = IL_RATE_FLUSH_MIN; - else if (duration > IL_RATE_FLUSH_MAX) - duration = IL_RATE_FLUSH_MAX; + if (duration < RATE_FLUSH_MIN) + duration = RATE_FLUSH_MIN; + else if (duration > RATE_FLUSH_MAX) + duration = RATE_FLUSH_MAX; } else - duration = IL_RATE_FLUSH_MAX; + duration = RATE_FLUSH_MAX; rs_sta->flush_time = msecs_to_jiffies(duration); @@ -234,7 +234,7 @@ static void il3945_bg_rate_scale_flush(unsigned long data) rs_sta->last_partial_flush = jiffies; } else { - rs_sta->flush_time = IL_RATE_FLUSH; + rs_sta->flush_time = RATE_FLUSH; rs_sta->flush_pending = 0; } /* If there weren't any unflushed entries, we don't schedule the timer @@ -278,13 +278,13 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, * we keep these bitmaps!). * */ while (retries > 0) { - if (win->counter >= IL_RATE_MAX_WINDOW) { + if (win->counter >= RATE_MAX_WINDOW) { /* remove earliest */ - win->counter = IL_RATE_MAX_WINDOW - 1; + win->counter = RATE_MAX_WINDOW - 1; - if (win->data & (1ULL << (IL_RATE_MAX_WINDOW - 1))) { - win->data &= ~(1ULL << (IL_RATE_MAX_WINDOW - 1)); + if (win->data & (1ULL << (RATE_MAX_WINDOW - 1))) { + win->data &= ~(1ULL << (RATE_MAX_WINDOW - 1)); win->success_counter--; } } @@ -315,8 +315,8 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, fail_count = win->counter - win->success_counter; /* Calculate average throughput, if we have enough history. */ - if (fail_count >= IL_RATE_MIN_FAILURE_TH || - win->success_counter >= IL_RATE_MIN_SUCCESS_TH) + if (fail_count >= RATE_MIN_FAILURE_TH || + win->success_counter >= RATE_MIN_SUCCESS_TH) win->average_tpt = ((win->success_ratio * rs_sta->expected_tpt[index] + 64) / 128); else @@ -351,20 +351,20 @@ void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_i rs_sta->il = il; - rs_sta->start_rate = IL_RATE_INVALID; + rs_sta->start_rate = RATE_INVALID; /* default to just 802.11b */ rs_sta->expected_tpt = il3945_expected_tpt_b; rs_sta->last_partial_flush = jiffies; rs_sta->last_flush = jiffies; - rs_sta->flush_time = IL_RATE_FLUSH; + rs_sta->flush_time = RATE_FLUSH; rs_sta->last_tx_packets = 0; rs_sta->rate_scale_flush.data = (unsigned long)rs_sta; rs_sta->rate_scale_flush.function = il3945_bg_rate_scale_flush; - for (i = 0; i < IL_RATE_COUNT_3945; i++) + for (i = 0; i < RATE_COUNT_3945; i++) il3945_clear_win(&rs_sta->win[i]); /* TODO: what is a good starting rate for STA? About middle? Maybe not @@ -457,11 +457,11 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * retries = info->status.rates[0].count; /* Sanity Check for retries */ - if (retries > IL_RATE_RETRY_TH) - retries = IL_RATE_RETRY_TH; + if (retries > RATE_RETRY_TH) + retries = RATE_RETRY_TH; first_index = sband->bitrates[info->status.rates[0].idx].hw_value; - if (first_index < 0 || first_index >= IL_RATE_COUNT_3945) { + if (first_index < 0 || first_index >= RATE_COUNT_3945) { D_RATE("leave: Rate out of bounds: %d\n", first_index); return; } @@ -549,8 +549,8 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, u8 index, u16 rate_mask, enum ieee80211_band band) { - u8 high = IL_RATE_INVALID; - u8 low = IL_RATE_INVALID; + u8 high = RATE_INVALID; + u8 low = RATE_INVALID; struct il_priv *il __maybe_unused = rs_sta->il; /* 802.11A walks to the next literal adjacent rate in @@ -570,7 +570,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, /* Find the next rate that is in the rate mask */ i = index + 1; - for (mask = (1 << i); i < IL_RATE_COUNT_3945; + for (mask = (1 << i); i < RATE_COUNT_3945; i++, mask <<= 1) { if (rate_mask & mask) { high = i; @@ -582,12 +582,12 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, } low = index; - while (low != IL_RATE_INVALID) { + while (low != RATE_INVALID) { if (rs_sta->tgg) low = il3945_rates[low].prev_rs_tgg; else low = il3945_rates[low].prev_rs; - if (low == IL_RATE_INVALID) + if (low == RATE_INVALID) break; if (rate_mask & (1 << low)) break; @@ -595,12 +595,12 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, } high = index; - while (high != IL_RATE_INVALID) { + while (high != RATE_INVALID) { if (rs_sta->tgg) high = il3945_rates[high].next_rs_tgg; else high = il3945_rates[high].next_rs; - if (high == IL_RATE_INVALID) + if (high == RATE_INVALID) break; if (rate_mask & (1 << high)) break; @@ -631,8 +631,8 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, { struct ieee80211_supported_band *sband = txrc->sband; struct sk_buff *skb = txrc->skb; - u8 low = IL_RATE_INVALID; - u8 high = IL_RATE_INVALID; + u8 low = RATE_INVALID; + u8 high = RATE_INVALID; u16 high_low; int index; struct il3945_rs_sta *rs_sta = il_sta; @@ -665,10 +665,10 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, max_rate_idx = txrc->max_rate_idx; if (sband->band == IEEE80211_BAND_5GHZ && max_rate_idx != -1) max_rate_idx += IL_FIRST_OFDM_RATE; - if (max_rate_idx < 0 || max_rate_idx >= IL_RATE_COUNT) + if (max_rate_idx < 0 || max_rate_idx >= RATE_COUNT) max_rate_idx = -1; - index = min(rs_sta->last_txrate_idx & 0xffff, IL_RATE_COUNT_3945 - 1); + index = min(rs_sta->last_txrate_idx & 0xffff, RATE_COUNT_3945 - 1); if (sband->band == IEEE80211_BAND_5GHZ) rate_mask = rate_mask << IL_FIRST_OFDM_RATE; @@ -678,11 +678,11 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, /* for recent assoc, choose best rate regarding * to rssi value */ - if (rs_sta->start_rate != IL_RATE_INVALID) { + if (rs_sta->start_rate != RATE_INVALID) { if (rs_sta->start_rate < index && (rate_mask & (1 << rs_sta->start_rate))) index = rs_sta->start_rate; - rs_sta->start_rate = IL_RATE_INVALID; + rs_sta->start_rate = RATE_INVALID; } /* force user max rate if set by user */ @@ -695,8 +695,8 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, fail_count = win->counter - win->success_counter; - if (fail_count < IL_RATE_MIN_FAILURE_TH && - win->success_counter < IL_RATE_MIN_SUCCESS_TH) { + if (fail_count < RATE_MIN_FAILURE_TH && + win->success_counter < RATE_MIN_SUCCESS_TH) { spin_unlock_irqrestore(&rs_sta->lock, flags); D_RATE("Invalid average_tpt on rate %d: " @@ -722,13 +722,13 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, /* If user set max rate, dont allow higher than user constrain */ if (max_rate_idx != -1 && max_rate_idx < high) - high = IL_RATE_INVALID; + high = RATE_INVALID; /* Collect Measured throughputs of adjacent rates */ - if (low != IL_RATE_INVALID) + if (low != RATE_INVALID) low_tpt = rs_sta->win[low].average_tpt; - if (high != IL_RATE_INVALID) + if (high != RATE_INVALID) high_tpt = rs_sta->win[high].average_tpt; spin_unlock_irqrestore(&rs_sta->lock, flags); @@ -736,7 +736,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, scale_action = 0; /* Low success ratio , need to drop the rate */ - if (win->success_ratio < IL_RATE_DECREASE_TH || !current_tpt) { + if (win->success_ratio < RATE_DECREASE_TH || !current_tpt) { D_RATE("decrease rate because of low success_ratio\n"); scale_action = -1; /* No throughput measured yet for adjacent rates, @@ -744,9 +744,9 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, } else if (low_tpt == IL_INVALID_VALUE && high_tpt == IL_INVALID_VALUE) { - if (high != IL_RATE_INVALID && win->success_ratio >= IL_RATE_INCREASE_TH) + if (high != RATE_INVALID && win->success_ratio >= RATE_INCREASE_TH) scale_action = 1; - else if (low != IL_RATE_INVALID) + else if (low != RATE_INVALID) scale_action = 0; /* Both adjacent throughputs are measured, but neither one has @@ -768,7 +768,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, /* High rate has better throughput, Increase * rate */ if (high_tpt > current_tpt && - win->success_ratio >= IL_RATE_INCREASE_TH) + win->success_ratio >= RATE_INCREASE_TH) scale_action = 1; else { D_RATE( @@ -780,7 +780,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, D_RATE( "decrease rate because of low tpt\n"); scale_action = -1; - } else if (win->success_ratio >= IL_RATE_INCREASE_TH) { + } else if (win->success_ratio >= RATE_INCREASE_TH) { /* Lower rate has better * throughput,decrease rate */ scale_action = 1; @@ -790,8 +790,8 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, /* Sanity check; asked for decrease, but success rate or throughput * has been good at old rate. Don't change it. */ - if (scale_action == -1 && low != IL_RATE_INVALID && - (win->success_ratio > IL_RATE_HIGH_TH || + if (scale_action == -1 && low != RATE_INVALID && + (win->success_ratio > RATE_HIGH_TH || current_tpt > 100 * rs_sta->expected_tpt[low])) scale_action = 0; @@ -799,13 +799,13 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, case -1: /* Decrese rate */ - if (low != IL_RATE_INVALID) + if (low != RATE_INVALID) index = low; break; case 1: /* Increase rate */ - if (high != IL_RATE_INVALID) + if (high != RATE_INVALID) index = high; break; @@ -860,7 +860,7 @@ static ssize_t il3945_sta_dbgfs_stats_table_read(struct file *file, lq_sta->tx_packets, lq_sta->last_txrate_idx, lq_sta->start_rate, jiffies_to_msecs(lq_sta->flush_time)); - for (j = 0; j < IL_RATE_COUNT_3945; j++) { + for (j = 0; j < RATE_COUNT_3945; j++) { desc += sprintf(buff+desc, "counter=%d success=%d %%=%d\n", lq_sta->win[j].counter, diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index fa4c33a36f22..728a90c33183 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -52,26 +52,26 @@ #include "iwl-3945-debugfs.h" #define IL_DECLARE_RATE_INFO(r, ip, in, rp, rn, pp, np) \ - [IL_RATE_##r##M_INDEX] = { IL_RATE_##r##M_PLCP, \ - IL_RATE_##r##M_IEEE, \ - IL_RATE_##ip##M_INDEX, \ - IL_RATE_##in##M_INDEX, \ - IL_RATE_##rp##M_INDEX, \ - IL_RATE_##rn##M_INDEX, \ - IL_RATE_##pp##M_INDEX, \ - IL_RATE_##np##M_INDEX, \ - IL_RATE_##r##M_INDEX_TABLE, \ - IL_RATE_##ip##M_INDEX_TABLE } + [RATE_##r##M_INDEX] = { RATE_##r##M_PLCP, \ + RATE_##r##M_IEEE, \ + RATE_##ip##M_INDEX, \ + RATE_##in##M_INDEX, \ + RATE_##rp##M_INDEX, \ + RATE_##rn##M_INDEX, \ + RATE_##pp##M_INDEX, \ + RATE_##np##M_INDEX, \ + RATE_##r##M_INDEX_TABLE, \ + RATE_##ip##M_INDEX_TABLE } /* * Parameter order: * rate, prev rate, next rate, prev tgg rate, next tgg rate * * If there isn't a valid next or previous rate then INV is used which - * maps to IL_RATE_INVALID + * maps to RATE_INVALID * */ -const struct il3945_rate_info il3945_rates[IL_RATE_COUNT_3945] = { +const struct il3945_rate_info il3945_rates[RATE_COUNT_3945] = { IL_DECLARE_RATE_INFO(1, INV, 2, INV, 2, INV, 2), /* 1mbps */ IL_DECLARE_RATE_INFO(2, 1, 5, 1, 5, 1, 5), /* 2mbps */ IL_DECLARE_RATE_INFO(5, 2, 6, 2, 11, 2, 11), /*5.5mbps */ @@ -90,7 +90,7 @@ static inline u8 il3945_get_prev_ieee_rate(u8 rate_index) { u8 rate = il3945_rates[rate_index].prev_ieee; - if (rate == IL_RATE_INVALID) + if (rate == RATE_INVALID) rate = rate_index; return rate; } @@ -194,7 +194,7 @@ static int il3945_hwrate_to_plcp_idx(u8 plcp) { int idx; - for (idx = 0; idx < IL_RATE_COUNT_3945; idx++) + for (idx = 0; idx < RATE_COUNT_3945; idx++) if (il3945_rates[idx].plcp == plcp) return idx; return -1; @@ -246,16 +246,16 @@ int il3945_rs_next_rate(struct il_priv *il, int rate) switch (il->band) { case IEEE80211_BAND_5GHZ: - if (rate == IL_RATE_12M_INDEX) - next_rate = IL_RATE_9M_INDEX; - else if (rate == IL_RATE_6M_INDEX) - next_rate = IL_RATE_6M_INDEX; + if (rate == RATE_12M_INDEX) + next_rate = RATE_9M_INDEX; + else if (rate == RATE_6M_INDEX) + next_rate = RATE_6M_INDEX; break; case IEEE80211_BAND_2GHZ: if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && il_is_associated(il)) { - if (rate == IL_RATE_11M_INDEX) - next_rate = IL_RATE_5M_INDEX; + if (rate == RATE_11M_INDEX) + next_rate = RATE_5M_INDEX; } break; @@ -675,7 +675,7 @@ void il3945_hw_build_tx_cmd_rate(struct il_priv *il, int sta_id, int tx_id) { u16 hw_value = ieee80211_get_tx_rate(il->hw, info)->hw_value; - u16 rate_index = min(hw_value & 0xffff, IL_RATE_COUNT_3945); + u16 rate_index = min(hw_value & 0xffff, RATE_COUNT_3945); u16 rate_mask; int rate; u8 rts_retry_limit; @@ -689,7 +689,7 @@ void il3945_hw_build_tx_cmd_rate(struct il_priv *il, /* We need to figure out how to get the sta->supp_rates while * in this running context */ - rate_mask = IL_RATES_MASK_3945; + rate_mask = RATES_MASK_3945; /* Set retry limit on DATA packets and Probe Responses*/ if (ieee80211_is_probe_resp(fc)) @@ -1330,7 +1330,7 @@ static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_index, /* use this channel group's 6Mbit clipping/saturation pwr, * but cap at regulatory scan power restriction (set during init * based on eeprom channel data) for this channel. */ - power = min(ch_info->scan_power, clip_pwrs[IL_RATE_6M_INDEX_TABLE]); + power = min(ch_info->scan_power, clip_pwrs[RATE_6M_INDEX_TABLE]); power = min(power, il->tx_power_user_lmt); scan_power_info->requested_power = power; @@ -1342,7 +1342,7 @@ static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_index, * *index*. */ power_index = ch_info->power_info[rate_index].power_table_index - (power - ch_info->power_info - [IL_RATE_6M_INDEX_TABLE].requested_power) * 2; + [RATE_6M_INDEX_TABLE].requested_power) * 2; /* store reference index that we use when adjusting *all* scan * powers. So we can accommodate user (all channel) or spectrum @@ -1466,7 +1466,7 @@ static int il3945_hw_reg_set_new_power(struct il_priv *il, power_info = ch_info->power_info; /* update OFDM Txpower settings */ - for (i = IL_RATE_6M_INDEX_TABLE; i <= IL_RATE_54M_INDEX_TABLE; + for (i = RATE_6M_INDEX_TABLE; i <= RATE_54M_INDEX_TABLE; i++, ++power_info) { int delta_idx; @@ -1490,14 +1490,14 @@ static int il3945_hw_reg_set_new_power(struct il_priv *il, * ... all CCK power settings for a given channel are the *same*. */ if (power_changed) { power = - ch_info->power_info[IL_RATE_12M_INDEX_TABLE]. + ch_info->power_info[RATE_12M_INDEX_TABLE]. requested_power + IL_CCK_FROM_OFDM_POWER_DIFF; /* do all CCK rates' il3945_channel_power_info structures */ - for (i = IL_RATE_1M_INDEX_TABLE; i <= IL_RATE_11M_INDEX_TABLE; i++) { + for (i = RATE_1M_INDEX_TABLE; i <= RATE_11M_INDEX_TABLE; i++) { power_info->requested_power = power; power_info->base_power_index = - ch_info->power_info[IL_RATE_12M_INDEX_TABLE]. + ch_info->power_info[RATE_12M_INDEX_TABLE]. base_power_index + IL_CCK_FROM_OFDM_INDEX_DIFF; ++power_info; } @@ -1574,7 +1574,7 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) ref_temp); /* set tx power value for all rates, OFDM and CCK */ - for (rate_index = 0; rate_index < IL_RATE_COUNT_3945; + for (rate_index = 0; rate_index < RATE_COUNT_3945; rate_index++) { int power_idx = ch_info->power_info[rate_index].base_power_index; @@ -1597,7 +1597,7 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) for (scan_tbl_index = 0; scan_tbl_index < IL_NUM_SCAN_RATES; scan_tbl_index++) { s32 actual_index = (scan_tbl_index == 0) ? - IL_RATE_1M_INDEX_TABLE : IL_RATE_6M_INDEX_TABLE; + RATE_1M_INDEX_TABLE : RATE_6M_INDEX_TABLE; il3945_hw_reg_set_scan_power(il, scan_tbl_index, actual_index, clip_pwrs, ch_info, a_band); @@ -2010,21 +2010,21 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *il) /* fill in channel group's nominal powers for each rate */ for (rate_index = 0; - rate_index < IL_RATE_COUNT_3945; rate_index++, clip_pwrs++) { + rate_index < RATE_COUNT_3945; rate_index++, clip_pwrs++) { switch (rate_index) { - case IL_RATE_36M_INDEX_TABLE: + case RATE_36M_INDEX_TABLE: if (i == 0) /* B/G */ *clip_pwrs = satur_pwr; else /* A */ *clip_pwrs = satur_pwr - 5; break; - case IL_RATE_48M_INDEX_TABLE: + case RATE_48M_INDEX_TABLE: if (i == 0) *clip_pwrs = satur_pwr - 7; else *clip_pwrs = satur_pwr - 10; break; - case IL_RATE_54M_INDEX_TABLE: + case RATE_54M_INDEX_TABLE: if (i == 0) *clip_pwrs = satur_pwr - 9; else @@ -2139,7 +2139,7 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) } /* set tx power for CCK rates, based on OFDM 12 Mbit settings*/ - pwr_info = &ch_info->power_info[IL_RATE_12M_INDEX_TABLE]; + pwr_info = &ch_info->power_info[RATE_12M_INDEX_TABLE]; power = pwr_info->requested_power + IL_CCK_FROM_OFDM_POWER_DIFF; pwr_index = pwr_info->power_table_index + @@ -2169,7 +2169,7 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) for (scan_tbl_index = 0; scan_tbl_index < IL_NUM_SCAN_RATES; scan_tbl_index++) { s32 actual_index = (scan_tbl_index == 0) ? - IL_RATE_1M_INDEX_TABLE : IL_RATE_6M_INDEX_TABLE; + RATE_1M_INDEX_TABLE : RATE_6M_INDEX_TABLE; il3945_hw_reg_set_scan_power(il, scan_tbl_index, actual_index, clip_pwrs, ch_info, a_band); } @@ -2289,7 +2289,7 @@ static int il3945_manage_ibss_station(struct il_priv *il, il3945_sync_sta(il, vif_priv->ibss_bssid_sta_id, (il->band == IEEE80211_BAND_5GHZ) ? - IL_RATE_6M_PLCP : IL_RATE_1M_PLCP); + RATE_6M_PLCP : RATE_1M_PLCP); il3945_rate_scale_init(il->hw, vif_priv->ibss_bssid_sta_id); return 0; @@ -2326,17 +2326,17 @@ int il3945_init_hw_rate_table(struct il_priv *il) D_RATE("Select A mode rate scale\n"); /* If one of the following CCK rates is used, * have it fall back to the 6M OFDM rate */ - for (i = IL_RATE_1M_INDEX_TABLE; - i <= IL_RATE_11M_INDEX_TABLE; i++) + for (i = RATE_1M_INDEX_TABLE; + i <= RATE_11M_INDEX_TABLE; i++) table[i].next_rate_index = il3945_rates[IL_FIRST_OFDM_RATE].table_rs_index; /* Don't fall back to CCK rates */ - table[IL_RATE_12M_INDEX_TABLE].next_rate_index = - IL_RATE_9M_INDEX_TABLE; + table[RATE_12M_INDEX_TABLE].next_rate_index = + RATE_9M_INDEX_TABLE; /* Don't drop out of OFDM rates */ - table[IL_RATE_6M_INDEX_TABLE].next_rate_index = + table[RATE_6M_INDEX_TABLE].next_rate_index = il3945_rates[IL_FIRST_OFDM_RATE].table_rs_index; break; @@ -2349,14 +2349,14 @@ int il3945_init_hw_rate_table(struct il_priv *il) il_is_associated(il)) { index = IL_FIRST_CCK_RATE; - for (i = IL_RATE_6M_INDEX_TABLE; - i <= IL_RATE_54M_INDEX_TABLE; i++) + for (i = RATE_6M_INDEX_TABLE; + i <= RATE_54M_INDEX_TABLE; i++) table[i].next_rate_index = il3945_rates[index].table_rs_index; - index = IL_RATE_11M_INDEX_TABLE; + index = RATE_11M_INDEX_TABLE; /* CCK shouldn't fall back to OFDM... */ - table[index].next_rate_index = IL_RATE_5M_INDEX_TABLE; + table[index].next_rate_index = RATE_5M_INDEX_TABLE; } break; diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.h b/drivers/net/wireless/iwlegacy/iwl-3945.h index 967e73357e9c..80fcbf8bbc5b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945.h @@ -96,7 +96,7 @@ struct il3945_rs_sta { u8 flush_pending; u8 start_rate; struct timer_list rate_scale_flush; - struct il3945_rate_scale_data win[IL_RATE_COUNT_3945]; + struct il3945_rate_scale_data win[RATE_COUNT_3945]; #ifdef CONFIG_MAC80211_DEBUGFS struct dentry *rs_sta_dbgfs_stats_table_file; #endif @@ -300,7 +300,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif); void il3945_post_scan(struct il_priv *il); /* rates */ -extern const struct il3945_rate_info il3945_rates[IL_RATE_COUNT_3945]; +extern const struct il3945_rate_info il3945_rates[RATE_COUNT_3945]; /* Requires full declaration of il_priv before including */ #include "iwl-io.h" diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index 57fc190ce675..ee04977c0113 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -423,7 +423,7 @@ int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) } else { if (band == IEEE80211_BAND_5GHZ) band_offset = IL_FIRST_OFDM_RATE; - for (idx = band_offset; idx < IL_RATE_COUNT_LEGACY; idx++) + for (idx = band_offset; idx < RATE_COUNT_LEGACY; idx++) if (il_rates[idx].plcp == (rate_n_flags & 0xFF)) return idx - band_offset; } @@ -870,14 +870,14 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) RXON_FLG_CHANNEL_MODE_MSK) >> RXON_FLG_CHANNEL_MODE_POS; if (chan_mod == CHANNEL_MODE_PURE_40) { - rate = IL_RATE_6M_PLCP; + rate = RATE_6M_PLCP; } else { - rate = IL_RATE_1M_PLCP; + rate = RATE_1M_PLCP; rate_flags = RATE_MCS_CCK_MSK; } break; case IEEE80211_BAND_5GHZ: - rate = IL_RATE_6M_PLCP; + rate = RATE_6M_PLCP; break; default: IL_WARN("Invalid scan band\n"); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index 5d88a452e1a3..e31ee20b06fc 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -46,23 +46,23 @@ #define IL_NUMBER_TRY 1 #define IL_HT_NUMBER_TRY 3 -#define IL_RATE_MAX_WINDOW 62 /* # tx in history win */ -#define IL_RATE_MIN_FAILURE_TH 6 /* min failures to calc tpt */ -#define IL_RATE_MIN_SUCCESS_TH 8 /* min successes to calc tpt */ +#define RATE_MAX_WINDOW 62 /* # tx in history win */ +#define RATE_MIN_FAILURE_TH 6 /* min failures to calc tpt */ +#define RATE_MIN_SUCCESS_TH 8 /* min successes to calc tpt */ /* max allowed rate miss before sync LQ cmd */ #define IL_MISSED_RATE_MAX 15 /* max time to accum history 2 seconds */ -#define IL_RATE_SCALE_FLUSH_INTVL (3*HZ) +#define RATE_SCALE_FLUSH_INTVL (3*HZ) static u8 rs_ht_to_legacy[] = { - IL_RATE_6M_INDEX, IL_RATE_6M_INDEX, - IL_RATE_6M_INDEX, IL_RATE_6M_INDEX, - IL_RATE_6M_INDEX, - IL_RATE_6M_INDEX, IL_RATE_9M_INDEX, - IL_RATE_12M_INDEX, IL_RATE_18M_INDEX, - IL_RATE_24M_INDEX, IL_RATE_36M_INDEX, - IL_RATE_48M_INDEX, IL_RATE_54M_INDEX + RATE_6M_INDEX, RATE_6M_INDEX, + RATE_6M_INDEX, RATE_6M_INDEX, + RATE_6M_INDEX, + RATE_6M_INDEX, RATE_9M_INDEX, + RATE_12M_INDEX, RATE_18M_INDEX, + RATE_24M_INDEX, RATE_36M_INDEX, + RATE_48M_INDEX, RATE_54M_INDEX }; static const u8 ant_toggle_lookup[] = { @@ -77,26 +77,26 @@ static const u8 ant_toggle_lookup[] = { }; #define IL_DECLARE_RATE_INFO(r, s, ip, in, rp, rn, pp, np) \ - [IL_RATE_##r##M_INDEX] = { IL_RATE_##r##M_PLCP, \ - IL_RATE_SISO_##s##M_PLCP, \ - IL_RATE_MIMO2_##s##M_PLCP,\ - IL_RATE_##r##M_IEEE, \ - IL_RATE_##ip##M_INDEX, \ - IL_RATE_##in##M_INDEX, \ - IL_RATE_##rp##M_INDEX, \ - IL_RATE_##rn##M_INDEX, \ - IL_RATE_##pp##M_INDEX, \ - IL_RATE_##np##M_INDEX } + [RATE_##r##M_INDEX] = { RATE_##r##M_PLCP, \ + RATE_SISO_##s##M_PLCP, \ + RATE_MIMO2_##s##M_PLCP,\ + RATE_##r##M_IEEE, \ + RATE_##ip##M_INDEX, \ + RATE_##in##M_INDEX, \ + RATE_##rp##M_INDEX, \ + RATE_##rn##M_INDEX, \ + RATE_##pp##M_INDEX, \ + RATE_##np##M_INDEX } /* * Parameter order: * rate, ht rate, prev rate, next rate, prev tgg rate, next tgg rate * * If there isn't a valid next or previous rate then INV is used which - * maps to IL_RATE_INVALID + * maps to RATE_INVALID * */ -const struct il_rate_info il_rates[IL_RATE_COUNT] = { +const struct il_rate_info il_rates[RATE_COUNT] = { IL_DECLARE_RATE_INFO(1, INV, INV, 2, INV, 2, INV, 2), /* 1mbps */ IL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ IL_DECLARE_RATE_INFO(5, INV, 2, 6, 2, 11, 2, 11), /*5.5mbps */ @@ -120,12 +120,12 @@ static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags) if (rate_n_flags & RATE_MCS_HT_MSK) { idx = (rate_n_flags & 0xff); - if (idx >= IL_RATE_MIMO2_6M_PLCP) - idx = idx - IL_RATE_MIMO2_6M_PLCP; + if (idx >= RATE_MIMO2_6M_PLCP) + idx = idx - RATE_MIMO2_6M_PLCP; idx += IL_FIRST_OFDM_RATE; /* skip 9M not supported in ht*/ - if (idx >= IL_RATE_9M_INDEX) + if (idx >= RATE_9M_INDEX) idx += 1; if (idx >= IL_FIRST_OFDM_RATE && idx <= IL_LAST_OFDM_RATE) return idx; @@ -169,32 +169,32 @@ static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, * (2.4 GHz) band. */ -static s32 expected_tpt_legacy[IL_RATE_COUNT] = { +static s32 expected_tpt_legacy[RATE_COUNT] = { 7, 13, 35, 58, 40, 57, 72, 98, 121, 154, 177, 186, 0 }; -static s32 expected_tpt_siso20MHz[4][IL_RATE_COUNT] = { +static s32 expected_tpt_siso20MHz[4][RATE_COUNT] = { {0, 0, 0, 0, 42, 0, 76, 102, 124, 158, 183, 193, 202}, /* Norm */ {0, 0, 0, 0, 46, 0, 82, 110, 132, 167, 192, 202, 210}, /* SGI */ {0, 0, 0, 0, 48, 0, 93, 135, 176, 251, 319, 351, 381}, /* AGG */ {0, 0, 0, 0, 53, 0, 102, 149, 193, 275, 348, 381, 413}, /* AGG+SGI */ }; -static s32 expected_tpt_siso40MHz[4][IL_RATE_COUNT] = { +static s32 expected_tpt_siso40MHz[4][RATE_COUNT] = { {0, 0, 0, 0, 77, 0, 127, 160, 184, 220, 242, 250, 257}, /* Norm */ {0, 0, 0, 0, 83, 0, 135, 169, 193, 229, 250, 257, 264}, /* SGI */ {0, 0, 0, 0, 96, 0, 182, 259, 328, 451, 553, 598, 640}, /* AGG */ {0, 0, 0, 0, 106, 0, 199, 282, 357, 487, 593, 640, 683}, /* AGG+SGI */ }; -static s32 expected_tpt_mimo2_20MHz[4][IL_RATE_COUNT] = { +static s32 expected_tpt_mimo2_20MHz[4][RATE_COUNT] = { {0, 0, 0, 0, 74, 0, 123, 155, 179, 213, 235, 243, 250}, /* Norm */ {0, 0, 0, 0, 81, 0, 131, 164, 187, 221, 242, 250, 256}, /* SGI */ {0, 0, 0, 0, 92, 0, 175, 250, 317, 436, 534, 578, 619}, /* AGG */ {0, 0, 0, 0, 102, 0, 192, 273, 344, 470, 573, 619, 660}, /* AGG+SGI*/ }; -static s32 expected_tpt_mimo2_40MHz[4][IL_RATE_COUNT] = { +static s32 expected_tpt_mimo2_40MHz[4][RATE_COUNT] = { {0, 0, 0, 0, 123, 0, 182, 214, 235, 264, 279, 285, 289}, /* Norm */ {0, 0, 0, 0, 131, 0, 191, 222, 242, 270, 284, 289, 293}, /* SGI */ {0, 0, 0, 0, 180, 0, 327, 446, 545, 708, 828, 878, 922}, /* AGG */ @@ -202,7 +202,7 @@ static s32 expected_tpt_mimo2_40MHz[4][IL_RATE_COUNT] = { }; /* mbps, mcs */ -static const struct il_rate_mcs_info il_rate_mcs[IL_RATE_COUNT] = { +static const struct il_rate_mcs_info il_rate_mcs[RATE_COUNT] = { { "1", "BPSK DSSS"}, { "2", "QPSK DSSS"}, {"5.5", "BPSK CCK"}, @@ -418,10 +418,10 @@ static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, int scale_index, int attempts, int successes) { struct il_rate_scale_data *win = NULL; - static const u64 mask = (((u64)1) << (IL_RATE_MAX_WINDOW - 1)); + static const u64 mask = (((u64)1) << (RATE_MAX_WINDOW - 1)); s32 fail_count, tpt; - if (scale_index < 0 || scale_index >= IL_RATE_COUNT) + if (scale_index < 0 || scale_index >= RATE_COUNT) return -EINVAL; /* Select win for current tx bit rate */ @@ -439,10 +439,10 @@ static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, * we keep these bitmaps!). */ while (attempts > 0) { - if (win->counter >= IL_RATE_MAX_WINDOW) { + if (win->counter >= RATE_MAX_WINDOW) { /* remove earliest */ - win->counter = IL_RATE_MAX_WINDOW - 1; + win->counter = RATE_MAX_WINDOW - 1; if (win->data & mask) { win->data &= ~mask; @@ -476,8 +476,8 @@ static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, fail_count = win->counter - win->success_counter; /* Calculate average throughput, if we have enough history. */ - if (fail_count >= IL_RATE_MIN_FAILURE_TH || - win->success_counter >= IL_RATE_MIN_SUCCESS_TH) + if (fail_count >= RATE_MIN_FAILURE_TH || + win->success_counter >= RATE_MIN_SUCCESS_TH) win->average_tpt = (win->success_ratio * tpt + 64) / 128; else win->average_tpt = IL_INVALID_VALUE; @@ -557,7 +557,7 @@ static int il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, memset(tbl, 0, sizeof(struct il_scale_tbl_info)); *rate_idx = il4965_hwrate_to_plcp_idx(rate_n_flags); - if (*rate_idx == IL_RATE_INVALID) { + if (*rate_idx == RATE_INVALID) { *rate_idx = -1; return -EINVAL; } @@ -591,7 +591,7 @@ static int il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, mcs = il4965_rs_extract_rate(rate_n_flags); /* SISO */ - if (mcs <= IL_RATE_SISO_60M_PLCP) { + if (mcs <= RATE_SISO_60M_PLCP) { if (il4965_num_of_ant == 1) tbl->lq_type = LQ_SISO; /*else NONE*/ /* MIMO2 */ @@ -669,8 +669,8 @@ static u16 il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, int rate_type) { - u8 high = IL_RATE_INVALID; - u8 low = IL_RATE_INVALID; + u8 high = RATE_INVALID; + u8 low = RATE_INVALID; /* 802.11A or ht walks to the next literal adjacent rate in * the rate table */ @@ -689,7 +689,7 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, /* Find the next rate that is in the rate mask */ i = index + 1; - for (mask = (1 << i); i < IL_RATE_COUNT; i++, mask <<= 1) { + for (mask = (1 << i); i < RATE_COUNT; i++, mask <<= 1) { if (rate_mask & mask) { high = i; break; @@ -700,9 +700,9 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, } low = index; - while (low != IL_RATE_INVALID) { + while (low != RATE_INVALID) { low = il_rates[low].prev_rs; - if (low == IL_RATE_INVALID) + if (low == RATE_INVALID) break; if (rate_mask & (1 << low)) break; @@ -710,9 +710,9 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, } high = index; - while (high != IL_RATE_INVALID) { + while (high != RATE_INVALID) { high = il_rates[high].next_rs; - if (high == IL_RATE_INVALID) + if (high == RATE_INVALID) break; if (rate_mask & (1 << high)) break; @@ -776,7 +776,7 @@ static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, tbl->lq_type); low = high_low & 0xff; - if (low == IL_RATE_INVALID) + if (low == RATE_INVALID) low = scale_index; out: @@ -856,7 +856,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, /* For HT packets, map MCS to PLCP */ if (mac_flags & IEEE80211_TX_RC_MCS) { mac_index &= RATE_MCS_CODE_MSK; /* Remove # of streams */ - if (mac_index >= (IL_RATE_9M_INDEX - IL_FIRST_OFDM_RATE)) + if (mac_index >= (RATE_9M_INDEX - IL_FIRST_OFDM_RATE)) mac_index++; /* * mac80211 HT index is always zero-indexed; we need to move @@ -1023,7 +1023,7 @@ static void il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, struct il_scale_tbl_info *tbl) { /* Used to choose among HT tables */ - s32 (*ht_tbl_pointer)[IL_RATE_COUNT]; + s32 (*ht_tbl_pointer)[RATE_COUNT]; /* Check for invalid LQ type */ if (WARN_ON_ONCE(!is_legacy(tbl->lq_type) && !is_Ht(tbl->lq_type))) { @@ -1089,7 +1089,7 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il, u16 high_low; s8 rate = index; - new_rate = high = low = start_hi = IL_RATE_INVALID; + new_rate = high = low = start_hi = RATE_INVALID; for (; ;) { high_low = il4965_rs_get_adjacent_rate(il, rate, rate_mask, @@ -1114,16 +1114,16 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il, * "active" throughput (under perfect conditions). */ if ((100 * tpt_tbl[rate] > lq_sta->last_tpt && - (active_sr > IL_RATE_DECREASE_TH && - active_sr <= IL_RATE_HIGH_TH && + (active_sr > RATE_DECREASE_TH && + active_sr <= RATE_HIGH_TH && tpt_tbl[rate] <= active_tpt)) || - (active_sr >= IL_RATE_SCALE_SWITCH && + (active_sr >= RATE_SCALE_SWITCH && tpt_tbl[rate] > active_tpt)) { /* (2nd or later pass) * If we've already tried to raise the rate, and are * now trying to lower it, use the higher rate. */ - if (start_hi != IL_RATE_INVALID) { + if (start_hi != RATE_INVALID) { new_rate = start_hi; break; } @@ -1131,7 +1131,7 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il, new_rate = rate; /* Loop again with lower rate */ - if (low != IL_RATE_INVALID) + if (low != RATE_INVALID) rate = low; /* Lower rate not available, use the original */ @@ -1143,11 +1143,11 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il, /* (2nd or later pass) * If we've already tried to lower the rate, and are * now trying to raise it, use the lower rate. */ - if (new_rate != IL_RATE_INVALID) + if (new_rate != RATE_INVALID) break; /* Loop again with higher rate */ - else if (high != IL_RATE_INVALID) { + else if (high != RATE_INVALID) { start_hi = high; rate = high; @@ -1207,7 +1207,7 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *il, D_RATE("LQ: MIMO2 best rate %d mask %X\n", rate, rate_mask); - if (rate == IL_RATE_INVALID || !((1 << rate) & rate_mask)) { + if (rate == RATE_INVALID || !((1 << rate) & rate_mask)) { D_RATE( "Can't switch with index %d rate mask %x\n", rate, rate_mask); @@ -1259,7 +1259,7 @@ static int il4965_rs_switch_to_siso(struct il_priv *il, rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, index); D_RATE("LQ: get best rate %d mask %X\n", rate, rate_mask); - if (rate == IL_RATE_INVALID || !((1 << rate) & rate_mask)) { + if (rate == RATE_INVALID || !((1 << rate) & rate_mask)) { D_RATE( "can not switch with index %d rate mask %x\n", rate, rate_mask); @@ -1286,7 +1286,7 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); struct il_rate_scale_data *win = &(tbl->win[index]); u32 sz = (sizeof(struct il_scale_tbl_info) - - (sizeof(struct il_rate_scale_data) * IL_RATE_COUNT)); + (sizeof(struct il_rate_scale_data) * RATE_COUNT)); u8 start_action; u8 valid_tx_ant = il->hw_params.valid_tx_ant; u8 tx_chains_num = il->hw_params.tx_chains_num; @@ -1404,7 +1404,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, struct il_rate_scale_data *win = &(tbl->win[index]); struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; u32 sz = (sizeof(struct il_scale_tbl_info) - - (sizeof(struct il_rate_scale_data) * IL_RATE_COUNT)); + (sizeof(struct il_rate_scale_data) * RATE_COUNT)); u8 start_action; u8 valid_tx_ant = il->hw_params.valid_tx_ant; u8 tx_chains_num = il->hw_params.tx_chains_num; @@ -1526,7 +1526,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, struct il_rate_scale_data *win = &(tbl->win[index]); struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; u32 sz = (sizeof(struct il_scale_tbl_info) - - (sizeof(struct il_rate_scale_data) * IL_RATE_COUNT)); + (sizeof(struct il_rate_scale_data) * RATE_COUNT)); u8 start_action; u8 valid_tx_ant = il->hw_params.valid_tx_ant; u8 tx_chains_num = il->hw_params.tx_chains_num; @@ -1663,7 +1663,7 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) flush_interval_passed = time_after(jiffies, (unsigned long)(lq_sta->flush_timer + - IL_RATE_SCALE_FLUSH_INTVL)); + RATE_SCALE_FLUSH_INTVL)); /* * Check if we should allow search for new modulation mode. @@ -1703,7 +1703,7 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) D_RATE( "LQ: stay in table clear win\n"); - for (i = 0; i < IL_RATE_COUNT; i++) + for (i = 0; i < RATE_COUNT; i++) il4965_rs_rate_scale_clear_win( &(tbl->win[i])); } @@ -1713,7 +1713,7 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) * bitmaps and stats in active table (this will become the new * "search" table). */ if (!lq_sta->stay_in_tbl) { - for (i = 0; i < IL_RATE_COUNT; i++) + for (i = 0; i < RATE_COUNT; i++) il4965_rs_rate_scale_clear_win( &(tbl->win[i])); } @@ -1752,8 +1752,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, struct ieee80211_conf *conf = &hw->conf; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - int low = IL_RATE_INVALID; - int high = IL_RATE_INVALID; + int low = RATE_INVALID; + int high = RATE_INVALID; int index; int i; struct il_rate_scale_data *win = NULL; @@ -1884,8 +1884,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, * in current association (use new rate found above). */ fail_count = win->counter - win->success_counter; - if (fail_count < IL_RATE_MIN_FAILURE_TH && - win->success_counter < IL_RATE_MIN_SUCCESS_TH) { + if (fail_count < RATE_MIN_FAILURE_TH && + win->success_counter < RATE_MIN_SUCCESS_TH) { D_RATE("LQ: still below TH. succ=%d total=%d " "for index %d\n", win->success_counter, win->counter, index); @@ -1971,21 +1971,21 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* If user set max rate, dont allow higher than user constrain */ if (lq_sta->max_rate_idx != -1 && lq_sta->max_rate_idx < high) - high = IL_RATE_INVALID; + high = RATE_INVALID; sr = win->success_ratio; /* Collect measured throughputs for current and adjacent rates */ current_tpt = win->average_tpt; - if (low != IL_RATE_INVALID) + if (low != RATE_INVALID) low_tpt = tbl->win[low].average_tpt; - if (high != IL_RATE_INVALID) + if (high != RATE_INVALID) high_tpt = tbl->win[high].average_tpt; scale_action = 0; /* Too many failures, decrease rate */ - if (sr <= IL_RATE_DECREASE_TH || current_tpt == 0) { + if (sr <= RATE_DECREASE_TH || current_tpt == 0) { D_RATE( "decrease rate because of low success_ratio\n"); scale_action = -1; @@ -1994,9 +1994,9 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, } else if (low_tpt == IL_INVALID_VALUE && high_tpt == IL_INVALID_VALUE) { - if (high != IL_RATE_INVALID && sr >= IL_RATE_INCREASE_TH) + if (high != RATE_INVALID && sr >= RATE_INCREASE_TH) scale_action = 1; - else if (low != IL_RATE_INVALID) + else if (low != RATE_INVALID) scale_action = 0; } @@ -2013,7 +2013,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, if (high_tpt != IL_INVALID_VALUE) { /* Higher rate has better throughput */ if (high_tpt > current_tpt && - sr >= IL_RATE_INCREASE_TH) { + sr >= RATE_INCREASE_TH) { scale_action = 1; } else { scale_action = 0; @@ -2026,7 +2026,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, D_RATE( "decrease rate because of low tpt\n"); scale_action = -1; - } else if (sr >= IL_RATE_INCREASE_TH) { + } else if (sr >= RATE_INCREASE_TH) { scale_action = 1; } } @@ -2034,14 +2034,14 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Sanity check; asked for decrease, but success rate or throughput * has been good at old rate. Don't change it. */ - if (scale_action == -1 && low != IL_RATE_INVALID && - (sr > IL_RATE_HIGH_TH || current_tpt > 100 * tbl->expected_tpt[low])) + if (scale_action == -1 && low != RATE_INVALID && + (sr > RATE_HIGH_TH || current_tpt > 100 * tbl->expected_tpt[low])) scale_action = 0; switch (scale_action) { case -1: /* Decrease starting rate, update uCode's rate table */ - if (low != IL_RATE_INVALID) { + if (low != RATE_INVALID) { update_lq = 1; index = low; } @@ -2049,7 +2049,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, break; case 1: /* Increase starting rate, update uCode's rate table */ - if (high != IL_RATE_INVALID) { + if (high != RATE_INVALID) { update_lq = 1; index = high; } @@ -2102,7 +2102,7 @@ lq_update: if (lq_sta->search_better_tbl) { /* Access the "search" table, clear its history. */ tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - for (i = 0; i < IL_RATE_COUNT; i++) + for (i = 0; i < RATE_COUNT; i++) il4965_rs_rate_scale_clear_win( &(tbl->win[i])); @@ -2208,7 +2208,7 @@ static void il4965_rs_initialize_lq(struct il_priv *il, tbl = &(lq_sta->lq_info[active_tbl]); - if (i < 0 || i >= IL_RATE_COUNT) + if (i < 0 || i >= RATE_COUNT) i = 0; rate = il_rates[i].plcp; @@ -2251,7 +2251,7 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, lq_sta->max_rate_idx != -1) lq_sta->max_rate_idx += IL_FIRST_OFDM_RATE; if (lq_sta->max_rate_idx < 0 || - lq_sta->max_rate_idx >= IL_RATE_COUNT) + lq_sta->max_rate_idx >= RATE_COUNT) lq_sta->max_rate_idx = -1; } @@ -2275,7 +2275,7 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, /* 6M and 9M shared same MCS index */ rate_idx = (rate_idx > 0) ? (rate_idx - 1) : 0; if (il4965_rs_extract_rate(lq_sta->last_rate_n_flags) >= - IL_RATE_MIMO2_6M_PLCP) + RATE_MIMO2_6M_PLCP) rate_idx = rate_idx + MCS_INDEX_PER_STREAM; info->control.rates[0].flags = IEEE80211_TX_RC_MCS; if (lq_sta->last_rate_n_flags & RATE_MCS_SGI_MSK) @@ -2292,7 +2292,7 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, IEEE80211_TX_RC_GREEN_FIELD; } else { /* Check for invalid rates */ - if (rate_idx < 0 || rate_idx >= IL_RATE_COUNT_LEGACY || + if (rate_idx < 0 || rate_idx >= RATE_COUNT_LEGACY || (sband->band == IEEE80211_BAND_5GHZ && rate_idx < IL_FIRST_OFDM_RATE)) rate_idx = rate_lowest_index(sband, sta); @@ -2345,14 +2345,14 @@ il4965_rs_rate_init(struct il_priv *il, lq_sta->lq.sta_id = sta_id; for (j = 0; j < LQ_SIZE; j++) - for (i = 0; i < IL_RATE_COUNT; i++) + for (i = 0; i < RATE_COUNT; i++) il4965_rs_rate_scale_clear_win( &lq_sta->lq_info[j].win[i]); lq_sta->flush_timer = 0; lq_sta->supp_rates = sta->supp_rates[sband->band]; for (j = 0; j < LQ_SIZE; j++) - for (i = 0; i < IL_RATE_COUNT; i++) + for (i = 0; i < RATE_COUNT; i++) il4965_rs_rate_scale_clear_win( &lq_sta->lq_info[j].win[i]); @@ -2745,7 +2745,7 @@ static ssize_t il4965_rs_sta_dbgfs_stats_table_read(struct file *file, lq_sta->lq_info[i].is_dup, lq_sta->is_green, lq_sta->lq_info[i].current_rate); - for (j = 0; j < IL_RATE_COUNT; j++) { + for (j = 0; j < RATE_COUNT; j++) { desc += sprintf(buff+desc, "counter=%d success=%d %%=%d\n", lq_sta->lq_info[i].win[j].counter, diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c index a82d44489a6c..278517c9083c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c @@ -50,9 +50,9 @@ il4965_sta_alloc_lq(struct il_priv *il, u8 sta_id) /* Set up the rate scaling to start at selected rate, fall back * all the way down to 1M in IEEE order, and then spin on 1M */ if (il->band == IEEE80211_BAND_5GHZ) - r = IL_RATE_6M_INDEX; + r = RATE_6M_INDEX; else - r = IL_RATE_1M_INDEX; + r = RATE_1M_INDEX; if (r >= IL_FIRST_CCK_RATE && r <= IL_LAST_CCK_RATE) rate_flags |= RATE_MCS_CCK_MSK; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index 68c86e009cf3..9671e10ff354 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -196,7 +196,7 @@ static void il4965_tx_cmd_build_rate(struct il_priv *il, */ rate_idx = info->control.rates[0].idx; if ((info->control.rates[0].flags & IEEE80211_TX_RC_MCS) || - rate_idx < 0 || rate_idx > IL_RATE_COUNT_LEGACY) + rate_idx < 0 || rate_idx > RATE_COUNT_LEGACY) rate_idx = rate_lowest_index(&il->bands[info->band], info->control.sta); /* For 5 GHZ band, remap mac80211 rate indices into driver indices */ diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h index d1876d05e7f0..aed11019f094 100644 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ b/drivers/net/wireless/iwlegacy/iwl-commands.h @@ -2094,7 +2094,7 @@ struct il_link_quality_cmd { * 4965 devices works its way through table when retrying Tx. */ struct { - __le32 rate_n_flags; /* RATE_MCS_*, IL_RATE_* */ + __le32 rate_n_flags; /* RATE_MCS_*, RATE_* */ } rs_table[LINK_QUAL_MAX_RETRY_NUM]; __le32 reserved2; } __packed; diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index 6742a6558ba9..de952fb0a96f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -174,7 +174,7 @@ int il_init_geos(struct il_priv *il) if (!channels) return -ENOMEM; - rates = kzalloc((sizeof(struct ieee80211_rate) * IL_RATE_COUNT_LEGACY), + rates = kzalloc((sizeof(struct ieee80211_rate) * RATE_COUNT_LEGACY), GFP_KERNEL); if (!rates) { kfree(channels); @@ -186,7 +186,7 @@ int il_init_geos(struct il_priv *il) sband->channels = &channels[ARRAY_SIZE(il_eeprom_band_1)]; /* just OFDM */ sband->bitrates = &rates[IL_FIRST_OFDM_RATE]; - sband->n_bitrates = IL_RATE_COUNT_LEGACY - IL_FIRST_OFDM_RATE; + sband->n_bitrates = RATE_COUNT_LEGACY - IL_FIRST_OFDM_RATE; if (il->cfg->sku & IL_SKU_N) il_init_ht_hw_capab(il, &sband->ht_cap, @@ -196,7 +196,7 @@ int il_init_geos(struct il_priv *il) sband->channels = channels; /* OFDM & CCK */ sband->bitrates = rates; - sband->n_bitrates = IL_RATE_COUNT_LEGACY; + sband->n_bitrates = RATE_COUNT_LEGACY; if (il->cfg->sku & IL_SKU_N) il_init_ht_hw_capab(il, &sband->ht_cap, @@ -454,8 +454,8 @@ il_check_rxon_cmd(struct il_priv *il, struct il_rxon_context *ctx) } /* make sure basic rates 6Mbps and 1Mbps are supported */ - if ((rxon->ofdm_basic_rates & IL_RATE_6M_MASK) == 0 && - (rxon->cck_basic_rates & IL_RATE_1M_MASK) == 0) { + if ((rxon->ofdm_basic_rates & RATE_6M_MASK) == 0 && + (rxon->cck_basic_rates & RATE_1M_MASK) == 0) { IL_WARN("neither 1 nor 6 are basic\n"); error = true; } @@ -566,9 +566,9 @@ u8 il_get_lowest_plcp(struct il_priv *il, * the beacon skb from mac80211. */ if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) - return IL_RATE_1M_PLCP; + return RATE_1M_PLCP; else - return IL_RATE_6M_PLCP; + return RATE_6M_PLCP; } EXPORT_SYMBOL(il_get_lowest_plcp); @@ -835,7 +835,7 @@ void il_set_rate(struct il_priv *il) for (i = 0; i < hw->n_bitrates; i++) { rate = &(hw->bitrates[i]); - if (rate->hw_value < IL_RATE_COUNT_LEGACY) + if (rate->hw_value < RATE_COUNT_LEGACY) il->active_rate |= (1 << rate->hw_value); } diff --git a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h index 19fa92d0e29f..6670f2eb71ae 100644 --- a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h +++ b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h @@ -28,10 +28,10 @@ #define __il_rs_h__ struct il_rate_info { - u8 plcp; /* uCode API: IL_RATE_6M_PLCP, etc. */ - u8 plcp_siso; /* uCode API: IL_RATE_SISO_6M_PLCP, etc. */ - u8 plcp_mimo2; /* uCode API: IL_RATE_MIMO2_6M_PLCP, etc. */ - u8 ieee; /* MAC header: IL_RATE_6M_IEEE, etc. */ + u8 plcp; /* uCode API: RATE_6M_PLCP, etc. */ + u8 plcp_siso; /* uCode API: RATE_SISO_6M_PLCP, etc. */ + u8 plcp_mimo2; /* uCode API: RATE_MIMO2_6M_PLCP, etc. */ + u8 ieee; /* MAC header: RATE_6M_IEEE, etc. */ u8 prev_ieee; /* previous rate in IEEE speeds */ u8 next_ieee; /* next rate in IEEE speeds */ u8 prev_rs; /* previous rate used in rs algo */ @@ -41,8 +41,8 @@ struct il_rate_info { }; struct il3945_rate_info { - u8 plcp; /* uCode API: IL_RATE_6M_PLCP, etc. */ - u8 ieee; /* MAC header: IL_RATE_6M_IEEE, etc. */ + u8 plcp; /* uCode API: RATE_6M_PLCP, etc. */ + u8 ieee; /* MAC header: RATE_6M_IEEE, etc. */ u8 prev_ieee; /* previous rate in IEEE speeds */ u8 next_ieee; /* next rate in IEEE speeds */ u8 prev_rs; /* previous rate used in rs algo */ @@ -56,153 +56,153 @@ struct il3945_rate_info { /* * These serve as indexes into - * struct il_rate_info il_rates[IL_RATE_COUNT]; + * struct il_rate_info il_rates[RATE_COUNT]; */ enum { - IL_RATE_1M_INDEX = 0, - IL_RATE_2M_INDEX, - IL_RATE_5M_INDEX, - IL_RATE_11M_INDEX, - IL_RATE_6M_INDEX, - IL_RATE_9M_INDEX, - IL_RATE_12M_INDEX, - IL_RATE_18M_INDEX, - IL_RATE_24M_INDEX, - IL_RATE_36M_INDEX, - IL_RATE_48M_INDEX, - IL_RATE_54M_INDEX, - IL_RATE_60M_INDEX, - IL_RATE_COUNT, - IL_RATE_COUNT_LEGACY = IL_RATE_COUNT - 1, /* Excluding 60M */ - IL_RATE_COUNT_3945 = IL_RATE_COUNT - 1, - IL_RATE_INVM_INDEX = IL_RATE_COUNT, - IL_RATE_INVALID = IL_RATE_COUNT, + RATE_1M_INDEX = 0, + RATE_2M_INDEX, + RATE_5M_INDEX, + RATE_11M_INDEX, + RATE_6M_INDEX, + RATE_9M_INDEX, + RATE_12M_INDEX, + RATE_18M_INDEX, + RATE_24M_INDEX, + RATE_36M_INDEX, + RATE_48M_INDEX, + RATE_54M_INDEX, + RATE_60M_INDEX, + RATE_COUNT, + RATE_COUNT_LEGACY = RATE_COUNT - 1, /* Excluding 60M */ + RATE_COUNT_3945 = RATE_COUNT - 1, + RATE_INVM_INDEX = RATE_COUNT, + RATE_INVALID = RATE_COUNT, }; enum { - IL_RATE_6M_INDEX_TABLE = 0, - IL_RATE_9M_INDEX_TABLE, - IL_RATE_12M_INDEX_TABLE, - IL_RATE_18M_INDEX_TABLE, - IL_RATE_24M_INDEX_TABLE, - IL_RATE_36M_INDEX_TABLE, - IL_RATE_48M_INDEX_TABLE, - IL_RATE_54M_INDEX_TABLE, - IL_RATE_1M_INDEX_TABLE, - IL_RATE_2M_INDEX_TABLE, - IL_RATE_5M_INDEX_TABLE, - IL_RATE_11M_INDEX_TABLE, - IL_RATE_INVM_INDEX_TABLE = IL_RATE_INVM_INDEX - 1, + RATE_6M_INDEX_TABLE = 0, + RATE_9M_INDEX_TABLE, + RATE_12M_INDEX_TABLE, + RATE_18M_INDEX_TABLE, + RATE_24M_INDEX_TABLE, + RATE_36M_INDEX_TABLE, + RATE_48M_INDEX_TABLE, + RATE_54M_INDEX_TABLE, + RATE_1M_INDEX_TABLE, + RATE_2M_INDEX_TABLE, + RATE_5M_INDEX_TABLE, + RATE_11M_INDEX_TABLE, + RATE_INVM_INDEX_TABLE = RATE_INVM_INDEX - 1, }; enum { - IL_FIRST_OFDM_RATE = IL_RATE_6M_INDEX, - IL39_LAST_OFDM_RATE = IL_RATE_54M_INDEX, - IL_LAST_OFDM_RATE = IL_RATE_60M_INDEX, - IL_FIRST_CCK_RATE = IL_RATE_1M_INDEX, - IL_LAST_CCK_RATE = IL_RATE_11M_INDEX, + IL_FIRST_OFDM_RATE = RATE_6M_INDEX, + IL39_LAST_OFDM_RATE = RATE_54M_INDEX, + IL_LAST_OFDM_RATE = RATE_60M_INDEX, + IL_FIRST_CCK_RATE = RATE_1M_INDEX, + IL_LAST_CCK_RATE = RATE_11M_INDEX, }; /* #define vs. enum to keep from defaulting to 'large integer' */ -#define IL_RATE_6M_MASK (1 << IL_RATE_6M_INDEX) -#define IL_RATE_9M_MASK (1 << IL_RATE_9M_INDEX) -#define IL_RATE_12M_MASK (1 << IL_RATE_12M_INDEX) -#define IL_RATE_18M_MASK (1 << IL_RATE_18M_INDEX) -#define IL_RATE_24M_MASK (1 << IL_RATE_24M_INDEX) -#define IL_RATE_36M_MASK (1 << IL_RATE_36M_INDEX) -#define IL_RATE_48M_MASK (1 << IL_RATE_48M_INDEX) -#define IL_RATE_54M_MASK (1 << IL_RATE_54M_INDEX) -#define IL_RATE_60M_MASK (1 << IL_RATE_60M_INDEX) -#define IL_RATE_1M_MASK (1 << IL_RATE_1M_INDEX) -#define IL_RATE_2M_MASK (1 << IL_RATE_2M_INDEX) -#define IL_RATE_5M_MASK (1 << IL_RATE_5M_INDEX) -#define IL_RATE_11M_MASK (1 << IL_RATE_11M_INDEX) +#define RATE_6M_MASK (1 << RATE_6M_INDEX) +#define RATE_9M_MASK (1 << RATE_9M_INDEX) +#define RATE_12M_MASK (1 << RATE_12M_INDEX) +#define RATE_18M_MASK (1 << RATE_18M_INDEX) +#define RATE_24M_MASK (1 << RATE_24M_INDEX) +#define RATE_36M_MASK (1 << RATE_36M_INDEX) +#define RATE_48M_MASK (1 << RATE_48M_INDEX) +#define RATE_54M_MASK (1 << RATE_54M_INDEX) +#define RATE_60M_MASK (1 << RATE_60M_INDEX) +#define RATE_1M_MASK (1 << RATE_1M_INDEX) +#define RATE_2M_MASK (1 << RATE_2M_INDEX) +#define RATE_5M_MASK (1 << RATE_5M_INDEX) +#define RATE_11M_MASK (1 << RATE_11M_INDEX) /* uCode API values for legacy bit rates, both OFDM and CCK */ enum { - IL_RATE_6M_PLCP = 13, - IL_RATE_9M_PLCP = 15, - IL_RATE_12M_PLCP = 5, - IL_RATE_18M_PLCP = 7, - IL_RATE_24M_PLCP = 9, - IL_RATE_36M_PLCP = 11, - IL_RATE_48M_PLCP = 1, - IL_RATE_54M_PLCP = 3, - IL_RATE_60M_PLCP = 3,/*FIXME:RS:should be removed*/ - IL_RATE_1M_PLCP = 10, - IL_RATE_2M_PLCP = 20, - IL_RATE_5M_PLCP = 55, - IL_RATE_11M_PLCP = 110, - /*FIXME:RS:add IL_RATE_LEGACY_INVM_PLCP = 0,*/ + RATE_6M_PLCP = 13, + RATE_9M_PLCP = 15, + RATE_12M_PLCP = 5, + RATE_18M_PLCP = 7, + RATE_24M_PLCP = 9, + RATE_36M_PLCP = 11, + RATE_48M_PLCP = 1, + RATE_54M_PLCP = 3, + RATE_60M_PLCP = 3,/*FIXME:RS:should be removed*/ + RATE_1M_PLCP = 10, + RATE_2M_PLCP = 20, + RATE_5M_PLCP = 55, + RATE_11M_PLCP = 110, + /*FIXME:RS:add RATE_LEGACY_INVM_PLCP = 0,*/ }; /* uCode API values for OFDM high-throughput (HT) bit rates */ enum { - IL_RATE_SISO_6M_PLCP = 0, - IL_RATE_SISO_12M_PLCP = 1, - IL_RATE_SISO_18M_PLCP = 2, - IL_RATE_SISO_24M_PLCP = 3, - IL_RATE_SISO_36M_PLCP = 4, - IL_RATE_SISO_48M_PLCP = 5, - IL_RATE_SISO_54M_PLCP = 6, - IL_RATE_SISO_60M_PLCP = 7, - IL_RATE_MIMO2_6M_PLCP = 0x8, - IL_RATE_MIMO2_12M_PLCP = 0x9, - IL_RATE_MIMO2_18M_PLCP = 0xa, - IL_RATE_MIMO2_24M_PLCP = 0xb, - IL_RATE_MIMO2_36M_PLCP = 0xc, - IL_RATE_MIMO2_48M_PLCP = 0xd, - IL_RATE_MIMO2_54M_PLCP = 0xe, - IL_RATE_MIMO2_60M_PLCP = 0xf, - IL_RATE_SISO_INVM_PLCP, - IL_RATE_MIMO2_INVM_PLCP = IL_RATE_SISO_INVM_PLCP, + RATE_SISO_6M_PLCP = 0, + RATE_SISO_12M_PLCP = 1, + RATE_SISO_18M_PLCP = 2, + RATE_SISO_24M_PLCP = 3, + RATE_SISO_36M_PLCP = 4, + RATE_SISO_48M_PLCP = 5, + RATE_SISO_54M_PLCP = 6, + RATE_SISO_60M_PLCP = 7, + RATE_MIMO2_6M_PLCP = 0x8, + RATE_MIMO2_12M_PLCP = 0x9, + RATE_MIMO2_18M_PLCP = 0xa, + RATE_MIMO2_24M_PLCP = 0xb, + RATE_MIMO2_36M_PLCP = 0xc, + RATE_MIMO2_48M_PLCP = 0xd, + RATE_MIMO2_54M_PLCP = 0xe, + RATE_MIMO2_60M_PLCP = 0xf, + RATE_SISO_INVM_PLCP, + RATE_MIMO2_INVM_PLCP = RATE_SISO_INVM_PLCP, }; /* MAC header values for bit rates */ enum { - IL_RATE_6M_IEEE = 12, - IL_RATE_9M_IEEE = 18, - IL_RATE_12M_IEEE = 24, - IL_RATE_18M_IEEE = 36, - IL_RATE_24M_IEEE = 48, - IL_RATE_36M_IEEE = 72, - IL_RATE_48M_IEEE = 96, - IL_RATE_54M_IEEE = 108, - IL_RATE_60M_IEEE = 120, - IL_RATE_1M_IEEE = 2, - IL_RATE_2M_IEEE = 4, - IL_RATE_5M_IEEE = 11, - IL_RATE_11M_IEEE = 22, + RATE_6M_IEEE = 12, + RATE_9M_IEEE = 18, + RATE_12M_IEEE = 24, + RATE_18M_IEEE = 36, + RATE_24M_IEEE = 48, + RATE_36M_IEEE = 72, + RATE_48M_IEEE = 96, + RATE_54M_IEEE = 108, + RATE_60M_IEEE = 120, + RATE_1M_IEEE = 2, + RATE_2M_IEEE = 4, + RATE_5M_IEEE = 11, + RATE_11M_IEEE = 22, }; #define IL_CCK_BASIC_RATES_MASK \ - (IL_RATE_1M_MASK | \ - IL_RATE_2M_MASK) + (RATE_1M_MASK | \ + RATE_2M_MASK) #define IL_CCK_RATES_MASK \ (IL_CCK_BASIC_RATES_MASK | \ - IL_RATE_5M_MASK | \ - IL_RATE_11M_MASK) + RATE_5M_MASK | \ + RATE_11M_MASK) #define IL_OFDM_BASIC_RATES_MASK \ - (IL_RATE_6M_MASK | \ - IL_RATE_12M_MASK | \ - IL_RATE_24M_MASK) + (RATE_6M_MASK | \ + RATE_12M_MASK | \ + RATE_24M_MASK) #define IL_OFDM_RATES_MASK \ (IL_OFDM_BASIC_RATES_MASK | \ - IL_RATE_9M_MASK | \ - IL_RATE_18M_MASK | \ - IL_RATE_36M_MASK | \ - IL_RATE_48M_MASK | \ - IL_RATE_54M_MASK) + RATE_9M_MASK | \ + RATE_18M_MASK | \ + RATE_36M_MASK | \ + RATE_48M_MASK | \ + RATE_54M_MASK) #define IL_BASIC_RATES_MASK \ (IL_OFDM_BASIC_RATES_MASK | \ IL_CCK_BASIC_RATES_MASK) -#define IL_RATES_MASK ((1 << IL_RATE_COUNT) - 1) -#define IL_RATES_MASK_3945 ((1 << IL_RATE_COUNT_3945) - 1) +#define RATES_MASK ((1 << RATE_COUNT) - 1) +#define RATES_MASK_3945 ((1 << RATE_COUNT_3945) - 1) #define IL_INVALID_VALUE -1 @@ -221,10 +221,10 @@ enum { /* Success ratio (ACKed / attempted tx frames) values (perfect is 128 * 100) */ #define IL_RS_GOOD_RATIO 12800 /* 100% */ -#define IL_RATE_SCALE_SWITCH 10880 /* 85% */ -#define IL_RATE_HIGH_TH 10880 /* 85% */ -#define IL_RATE_INCREASE_TH 6400 /* 50% */ -#define IL_RATE_DECREASE_TH 1920 /* 15% */ +#define RATE_SCALE_SWITCH 10880 /* 85% */ +#define RATE_HIGH_TH 10880 /* 85% */ +#define RATE_INCREASE_TH 6400 /* 50% */ +#define RATE_DECREASE_TH 1920 /* 15% */ /* possible actions when in legacy mode */ #define IL_LEGACY_SWITCH_ANTENNA1 0 @@ -268,7 +268,7 @@ enum { #define TID_MAX_TIME_DIFF ((TID_QUEUE_MAX_SIZE - 1) * TID_QUEUE_CELL_SPACING) #define TIME_WRAP_AROUND(x, y) (((y) > (x)) ? (y) - (x) : (0-(x)) + (y)) -extern const struct il_rate_info il_rates[IL_RATE_COUNT]; +extern const struct il_rate_info il_rates[RATE_COUNT]; enum il_table_type { LQ_NONE, @@ -331,7 +331,7 @@ struct il_scale_tbl_info { u8 max_search; /* maximun number of tables we can search */ s32 *expected_tpt; /* throughput metrics; expected_tpt_G, etc. */ u32 current_rate; /* rate_n_flags, uCode API format */ - struct il_rate_scale_data win[IL_RATE_COUNT]; /* rate histories */ + struct il_rate_scale_data win[RATE_COUNT]; /* rate histories */ }; struct il_traffic_load { @@ -371,7 +371,7 @@ struct il_lq_sta { u8 is_dup; enum ieee80211_band band; - /* The following are bitmaps of rates; IL_RATE_6M_MASK, etc. */ + /* The following are bitmaps of rates; RATE_6M_MASK, etc. */ u32 supp_rates; u16 active_legacy_rate; u16 active_siso_rate; diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.c b/drivers/net/wireless/iwlegacy/iwl-sta.c index 3c354a8952ec..dcaa3fb62743 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-sta.c @@ -314,7 +314,7 @@ u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, /* 3945 only */ rate = (il->band == IEEE80211_BAND_5GHZ) ? - IL_RATE_6M_PLCP : IL_RATE_1M_PLCP; + RATE_6M_PLCP : RATE_1M_PLCP; /* Turn on both antennas for the station... */ station->sta.rate_n_flags = cpu_to_le16(rate | RATE_MCS_ANT_AB_MSK); diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index c602570a3408..1fc9bfbc891e 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -1654,7 +1654,7 @@ static void il3945_init_hw_rates(struct il_priv *il, { int i; - for (i = 0; i < IL_RATE_COUNT_LEGACY; i++) { + for (i = 0; i < RATE_COUNT_LEGACY; i++) { rates[i].bitrate = il3945_rates[i].ieee * 5; rates[i].hw_value = i; /* Rate scaling will work on indexes */ rates[i].hw_value_short = i; @@ -2239,7 +2239,7 @@ static void il3945_alive_start(struct il_priv *il) ieee80211_wake_queues(il->hw); - il->active_rate = IL_RATES_MASK_3945; + il->active_rate = RATES_MASK_3945; il_power_update_mode(il, true); @@ -2642,11 +2642,11 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) switch (il->scan_band) { case IEEE80211_BAND_2GHZ: scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; - scan->tx_cmd.rate = IL_RATE_1M_PLCP; + scan->tx_cmd.rate = RATE_1M_PLCP; band = IEEE80211_BAND_2GHZ; break; case IEEE80211_BAND_5GHZ: - scan->tx_cmd.rate = IL_RATE_6M_PLCP; + scan->tx_cmd.rate = RATE_6M_PLCP; band = IEEE80211_BAND_5GHZ; break; default: diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index 736c2f540b16..bc5a0080b9d3 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -1757,7 +1757,7 @@ static void il4965_alive_start(struct il_priv *il) ieee80211_wake_queues(il->hw); - il->active_rate = IL_RATES_MASK; + il->active_rate = RATES_MASK; if (il_is_associated_ctx(ctx)) { struct il_rxon_cmd *active_rxon = @@ -2711,7 +2711,7 @@ static void il4965_init_hw_rates(struct il_priv *il, { int i; - for (i = 0; i < IL_RATE_COUNT_LEGACY; i++) { + for (i = 0; i < RATE_COUNT_LEGACY; i++) { rates[i].bitrate = il_rates[i].ieee * 5; rates[i].hw_value = i; /* Rate scaling will work on indexes */ rates[i].hw_value_short = i; @@ -2721,7 +2721,7 @@ static void il4965_init_hw_rates(struct il_priv *il, * If CCK != 1M then set short preamble rate flag. */ rates[i].flags |= - (il_rates[i].plcp == IL_RATE_1M_PLCP) ? + (il_rates[i].plcp == RATE_1M_PLCP) ? 0 : IEEE80211_RATE_SHORT_PREAMBLE; } } -- cgit v1.2.3 From 2d09b0624a1048f6424b2c7ff60ad3a42d8036ff Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 26 Aug 2011 16:10:40 +0200 Subject: iwlegacy: s/INDEX/IDX/ Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-3945-rs.c | 36 +++++------ drivers/net/wireless/iwlegacy/iwl-3945.c | 82 +++++++++++------------ drivers/net/wireless/iwlegacy/iwl-4965-calib.c | 22 +++---- drivers/net/wireless/iwlegacy/iwl-4965-hw.h | 4 +- drivers/net/wireless/iwlegacy/iwl-4965-rs.c | 36 +++++------ drivers/net/wireless/iwlegacy/iwl-4965-sta.c | 4 +- drivers/net/wireless/iwlegacy/iwl-4965-tx.c | 4 +- drivers/net/wireless/iwlegacy/iwl-4965.c | 8 +-- drivers/net/wireless/iwlegacy/iwl-commands.h | 60 ++++++++--------- drivers/net/wireless/iwlegacy/iwl-fh.h | 2 +- drivers/net/wireless/iwlegacy/iwl-legacy-rs.h | 90 +++++++++++++------------- drivers/net/wireless/iwlegacy/iwl-power.h | 10 +-- drivers/net/wireless/iwlegacy/iwl-rx.c | 8 +-- drivers/net/wireless/iwlegacy/iwl-tx.c | 4 +- drivers/net/wireless/iwlegacy/iwl3945-base.c | 10 +-- 15 files changed, 190 insertions(+), 190 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c index 92fa4366ab89..4d83c6292246 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c @@ -64,27 +64,27 @@ struct il3945_tpt_entry { }; static struct il3945_tpt_entry il3945_tpt_table_a[] = { - {-60, RATE_54M_INDEX}, - {-64, RATE_48M_INDEX}, - {-72, RATE_36M_INDEX}, - {-80, RATE_24M_INDEX}, - {-84, RATE_18M_INDEX}, - {-85, RATE_12M_INDEX}, - {-87, RATE_9M_INDEX}, - {-89, RATE_6M_INDEX} + {-60, RATE_54M_IDX}, + {-64, RATE_48M_IDX}, + {-72, RATE_36M_IDX}, + {-80, RATE_24M_IDX}, + {-84, RATE_18M_IDX}, + {-85, RATE_12M_IDX}, + {-87, RATE_9M_IDX}, + {-89, RATE_6M_IDX} }; static struct il3945_tpt_entry il3945_tpt_table_g[] = { - {-60, RATE_54M_INDEX}, - {-64, RATE_48M_INDEX}, - {-68, RATE_36M_INDEX}, - {-80, RATE_24M_INDEX}, - {-84, RATE_18M_INDEX}, - {-85, RATE_12M_INDEX}, - {-86, RATE_11M_INDEX}, - {-88, RATE_5M_INDEX}, - {-90, RATE_2M_INDEX}, - {-92, RATE_1M_INDEX} + {-60, RATE_54M_IDX}, + {-64, RATE_48M_IDX}, + {-68, RATE_36M_IDX}, + {-80, RATE_24M_IDX}, + {-84, RATE_18M_IDX}, + {-85, RATE_12M_IDX}, + {-86, RATE_11M_IDX}, + {-88, RATE_5M_IDX}, + {-90, RATE_2M_IDX}, + {-92, RATE_1M_IDX} }; #define RATE_MAX_WINDOW 62 diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index 728a90c33183..3908bff8e0ac 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -52,16 +52,16 @@ #include "iwl-3945-debugfs.h" #define IL_DECLARE_RATE_INFO(r, ip, in, rp, rn, pp, np) \ - [RATE_##r##M_INDEX] = { RATE_##r##M_PLCP, \ + [RATE_##r##M_IDX] = { RATE_##r##M_PLCP, \ RATE_##r##M_IEEE, \ - RATE_##ip##M_INDEX, \ - RATE_##in##M_INDEX, \ - RATE_##rp##M_INDEX, \ - RATE_##rn##M_INDEX, \ - RATE_##pp##M_INDEX, \ - RATE_##np##M_INDEX, \ - RATE_##r##M_INDEX_TABLE, \ - RATE_##ip##M_INDEX_TABLE } + RATE_##ip##M_IDX, \ + RATE_##in##M_IDX, \ + RATE_##rp##M_IDX, \ + RATE_##rn##M_IDX, \ + RATE_##pp##M_IDX, \ + RATE_##np##M_IDX, \ + RATE_##r##M_IDX_TABLE, \ + RATE_##ip##M_IDX_TABLE } /* * Parameter order: @@ -246,16 +246,16 @@ int il3945_rs_next_rate(struct il_priv *il, int rate) switch (il->band) { case IEEE80211_BAND_5GHZ: - if (rate == RATE_12M_INDEX) - next_rate = RATE_9M_INDEX; - else if (rate == RATE_6M_INDEX) - next_rate = RATE_6M_INDEX; + if (rate == RATE_12M_IDX) + next_rate = RATE_9M_IDX; + else if (rate == RATE_6M_IDX) + next_rate = RATE_6M_IDX; break; case IEEE80211_BAND_2GHZ: if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && il_is_associated(il)) { - if (rate == RATE_11M_INDEX) - next_rate = RATE_5M_INDEX; + if (rate == RATE_11M_IDX) + next_rate = RATE_5M_IDX; } break; @@ -307,7 +307,7 @@ static void il3945_rx_reply_tx(struct il_priv *il, struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); - int index = SEQ_TO_INDEX(sequence); + int index = SEQ_TO_IDX(sequence); struct il_tx_queue *txq = &il->txq[txq_id]; struct ieee80211_tx_info *info; struct il3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; @@ -1133,7 +1133,7 @@ static int il3945_is_temp_calib_needed(struct il_priv *il) #define IL_MAX_GAIN_ENTRIES 78 #define IL_CCK_FROM_OFDM_POWER_DIFF -5 -#define IL_CCK_FROM_OFDM_INDEX_DIFF (10) +#define IL_CCK_FROM_OFDM_IDX_DIFF (10) /* radio and DSP power table, each step is 1/2 dB. * 1st number is for RF analog gain, 2nd number is for DSP pre-DAC gain. */ @@ -1330,7 +1330,7 @@ static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_index, /* use this channel group's 6Mbit clipping/saturation pwr, * but cap at regulatory scan power restriction (set during init * based on eeprom channel data) for this channel. */ - power = min(ch_info->scan_power, clip_pwrs[RATE_6M_INDEX_TABLE]); + power = min(ch_info->scan_power, clip_pwrs[RATE_6M_IDX_TABLE]); power = min(power, il->tx_power_user_lmt); scan_power_info->requested_power = power; @@ -1342,7 +1342,7 @@ static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_index, * *index*. */ power_index = ch_info->power_info[rate_index].power_table_index - (power - ch_info->power_info - [RATE_6M_INDEX_TABLE].requested_power) * 2; + [RATE_6M_IDX_TABLE].requested_power) * 2; /* store reference index that we use when adjusting *all* scan * powers. So we can accommodate user (all channel) or spectrum @@ -1466,7 +1466,7 @@ static int il3945_hw_reg_set_new_power(struct il_priv *il, power_info = ch_info->power_info; /* update OFDM Txpower settings */ - for (i = RATE_6M_INDEX_TABLE; i <= RATE_54M_INDEX_TABLE; + for (i = RATE_6M_IDX_TABLE; i <= RATE_54M_IDX_TABLE; i++, ++power_info) { int delta_idx; @@ -1490,15 +1490,15 @@ static int il3945_hw_reg_set_new_power(struct il_priv *il, * ... all CCK power settings for a given channel are the *same*. */ if (power_changed) { power = - ch_info->power_info[RATE_12M_INDEX_TABLE]. + ch_info->power_info[RATE_12M_IDX_TABLE]. requested_power + IL_CCK_FROM_OFDM_POWER_DIFF; /* do all CCK rates' il3945_channel_power_info structures */ - for (i = RATE_1M_INDEX_TABLE; i <= RATE_11M_INDEX_TABLE; i++) { + for (i = RATE_1M_IDX_TABLE; i <= RATE_11M_IDX_TABLE; i++) { power_info->requested_power = power; power_info->base_power_index = - ch_info->power_info[RATE_12M_INDEX_TABLE]. - base_power_index + IL_CCK_FROM_OFDM_INDEX_DIFF; + ch_info->power_info[RATE_12M_IDX_TABLE]. + base_power_index + IL_CCK_FROM_OFDM_IDX_DIFF; ++power_info; } } @@ -1597,7 +1597,7 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) for (scan_tbl_index = 0; scan_tbl_index < IL_NUM_SCAN_RATES; scan_tbl_index++) { s32 actual_index = (scan_tbl_index == 0) ? - RATE_1M_INDEX_TABLE : RATE_6M_INDEX_TABLE; + RATE_1M_IDX_TABLE : RATE_6M_IDX_TABLE; il3945_hw_reg_set_scan_power(il, scan_tbl_index, actual_index, clip_pwrs, ch_info, a_band); @@ -2012,19 +2012,19 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *il) for (rate_index = 0; rate_index < RATE_COUNT_3945; rate_index++, clip_pwrs++) { switch (rate_index) { - case RATE_36M_INDEX_TABLE: + case RATE_36M_IDX_TABLE: if (i == 0) /* B/G */ *clip_pwrs = satur_pwr; else /* A */ *clip_pwrs = satur_pwr - 5; break; - case RATE_48M_INDEX_TABLE: + case RATE_48M_IDX_TABLE: if (i == 0) *clip_pwrs = satur_pwr - 7; else *clip_pwrs = satur_pwr - 10; break; - case RATE_54M_INDEX_TABLE: + case RATE_54M_IDX_TABLE: if (i == 0) *clip_pwrs = satur_pwr - 9; else @@ -2139,13 +2139,13 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) } /* set tx power for CCK rates, based on OFDM 12 Mbit settings*/ - pwr_info = &ch_info->power_info[RATE_12M_INDEX_TABLE]; + pwr_info = &ch_info->power_info[RATE_12M_IDX_TABLE]; power = pwr_info->requested_power + IL_CCK_FROM_OFDM_POWER_DIFF; pwr_index = pwr_info->power_table_index + - IL_CCK_FROM_OFDM_INDEX_DIFF; + IL_CCK_FROM_OFDM_IDX_DIFF; base_pwr_index = pwr_info->base_power_index + - IL_CCK_FROM_OFDM_INDEX_DIFF; + IL_CCK_FROM_OFDM_IDX_DIFF; /* stay within table range */ pwr_index = il3945_hw_reg_fix_power_index(pwr_index); @@ -2169,7 +2169,7 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) for (scan_tbl_index = 0; scan_tbl_index < IL_NUM_SCAN_RATES; scan_tbl_index++) { s32 actual_index = (scan_tbl_index == 0) ? - RATE_1M_INDEX_TABLE : RATE_6M_INDEX_TABLE; + RATE_1M_IDX_TABLE : RATE_6M_IDX_TABLE; il3945_hw_reg_set_scan_power(il, scan_tbl_index, actual_index, clip_pwrs, ch_info, a_band); } @@ -2326,17 +2326,17 @@ int il3945_init_hw_rate_table(struct il_priv *il) D_RATE("Select A mode rate scale\n"); /* If one of the following CCK rates is used, * have it fall back to the 6M OFDM rate */ - for (i = RATE_1M_INDEX_TABLE; - i <= RATE_11M_INDEX_TABLE; i++) + for (i = RATE_1M_IDX_TABLE; + i <= RATE_11M_IDX_TABLE; i++) table[i].next_rate_index = il3945_rates[IL_FIRST_OFDM_RATE].table_rs_index; /* Don't fall back to CCK rates */ - table[RATE_12M_INDEX_TABLE].next_rate_index = - RATE_9M_INDEX_TABLE; + table[RATE_12M_IDX_TABLE].next_rate_index = + RATE_9M_IDX_TABLE; /* Don't drop out of OFDM rates */ - table[RATE_6M_INDEX_TABLE].next_rate_index = + table[RATE_6M_IDX_TABLE].next_rate_index = il3945_rates[IL_FIRST_OFDM_RATE].table_rs_index; break; @@ -2349,14 +2349,14 @@ int il3945_init_hw_rate_table(struct il_priv *il) il_is_associated(il)) { index = IL_FIRST_CCK_RATE; - for (i = RATE_6M_INDEX_TABLE; - i <= RATE_54M_INDEX_TABLE; i++) + for (i = RATE_6M_IDX_TABLE; + i <= RATE_54M_IDX_TABLE; i++) table[i].next_rate_index = il3945_rates[index].table_rs_index; - index = RATE_11M_INDEX_TABLE; + index = RATE_11M_IDX_TABLE; /* CCK shouldn't fall back to OFDM... */ - table[index].next_rate_index = RATE_5M_INDEX_TABLE; + table[index].next_rate_index = RATE_5M_IDX_TABLE; } break; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c index bb3bc15c3a36..d622b2781088 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c @@ -374,30 +374,30 @@ static void il4965_prepare_legacy_sensitivity_tbl(struct il_priv *il, struct il_sensitivity_data *data, __le16 *tbl) { - tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX] = + tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_IDX] = cpu_to_le16((u16)data->auto_corr_ofdm); - tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX] = + tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_IDX] = cpu_to_le16((u16)data->auto_corr_ofdm_mrc); - tbl[HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX] = + tbl[HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX] = cpu_to_le16((u16)data->auto_corr_ofdm_x1); - tbl[HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX] = + tbl[HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_IDX] = cpu_to_le16((u16)data->auto_corr_ofdm_mrc_x1); - tbl[HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX] = + tbl[HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX] = cpu_to_le16((u16)data->auto_corr_cck); - tbl[HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX] = + tbl[HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX] = cpu_to_le16((u16)data->auto_corr_cck_mrc); - tbl[HD_MIN_ENERGY_CCK_DET_INDEX] = + tbl[HD_MIN_ENERGY_CCK_DET_IDX] = cpu_to_le16((u16)data->nrg_th_cck); - tbl[HD_MIN_ENERGY_OFDM_DET_INDEX] = + tbl[HD_MIN_ENERGY_OFDM_DET_IDX] = cpu_to_le16((u16)data->nrg_th_ofdm); - tbl[HD_BARKER_CORR_TH_ADD_MIN_INDEX] = + tbl[HD_BARKER_CORR_TH_ADD_MIN_IDX] = cpu_to_le16(data->barker_corr_th_min); - tbl[HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX] = + tbl[HD_BARKER_CORR_TH_ADD_MIN_MRC_IDX] = cpu_to_le16(data->barker_corr_th_min_mrc); - tbl[HD_OFDM_ENERGY_TH_IN_INDEX] = + tbl[HD_OFDM_ENERGY_TH_IN_IDX] = cpu_to_le16(data->nrg_th_cca); D_CALIB("ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n", diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h index 83748c7ae93f..2c1b000e2369 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h @@ -433,8 +433,8 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * present during factory calibration). A 5 Ghz EEPROM index of "40" * corresponds to the 49th entry in the table used by the driver. */ -#define MIN_TX_GAIN_INDEX (0) /* highest gain, lowest idx, 2.4 */ -#define MIN_TX_GAIN_INDEX_52GHZ_EXT (-9) /* highest gain, lowest idx, 5 */ +#define MIN_TX_GAIN_IDX (0) /* highest gain, lowest idx, 2.4 */ +#define MIN_TX_GAIN_IDX_52GHZ_EXT (-9) /* highest gain, lowest idx, 5 */ /** * 2.4 GHz gain table diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index e31ee20b06fc..7478e9167e73 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -56,13 +56,13 @@ #define RATE_SCALE_FLUSH_INTVL (3*HZ) static u8 rs_ht_to_legacy[] = { - RATE_6M_INDEX, RATE_6M_INDEX, - RATE_6M_INDEX, RATE_6M_INDEX, - RATE_6M_INDEX, - RATE_6M_INDEX, RATE_9M_INDEX, - RATE_12M_INDEX, RATE_18M_INDEX, - RATE_24M_INDEX, RATE_36M_INDEX, - RATE_48M_INDEX, RATE_54M_INDEX + RATE_6M_IDX, RATE_6M_IDX, + RATE_6M_IDX, RATE_6M_IDX, + RATE_6M_IDX, + RATE_6M_IDX, RATE_9M_IDX, + RATE_12M_IDX, RATE_18M_IDX, + RATE_24M_IDX, RATE_36M_IDX, + RATE_48M_IDX, RATE_54M_IDX }; static const u8 ant_toggle_lookup[] = { @@ -77,16 +77,16 @@ static const u8 ant_toggle_lookup[] = { }; #define IL_DECLARE_RATE_INFO(r, s, ip, in, rp, rn, pp, np) \ - [RATE_##r##M_INDEX] = { RATE_##r##M_PLCP, \ + [RATE_##r##M_IDX] = { RATE_##r##M_PLCP, \ RATE_SISO_##s##M_PLCP, \ RATE_MIMO2_##s##M_PLCP,\ RATE_##r##M_IEEE, \ - RATE_##ip##M_INDEX, \ - RATE_##in##M_INDEX, \ - RATE_##rp##M_INDEX, \ - RATE_##rn##M_INDEX, \ - RATE_##pp##M_INDEX, \ - RATE_##np##M_INDEX } + RATE_##ip##M_IDX, \ + RATE_##in##M_IDX, \ + RATE_##rp##M_IDX, \ + RATE_##rn##M_IDX, \ + RATE_##pp##M_IDX, \ + RATE_##np##M_IDX } /* * Parameter order: @@ -125,7 +125,7 @@ static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags) idx += IL_FIRST_OFDM_RATE; /* skip 9M not supported in ht*/ - if (idx >= RATE_9M_INDEX) + if (idx >= RATE_9M_IDX) idx += 1; if (idx >= IL_FIRST_OFDM_RATE && idx <= IL_LAST_OFDM_RATE) return idx; @@ -218,7 +218,7 @@ static const struct il_rate_mcs_info il_rate_mcs[RATE_COUNT] = { { "60", "64QAM 5/6"}, }; -#define MCS_INDEX_PER_STREAM (8) +#define MCS_IDX_PER_STREAM (8) static inline u8 il4965_rs_extract_rate(u32 rate_n_flags) { @@ -856,7 +856,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, /* For HT packets, map MCS to PLCP */ if (mac_flags & IEEE80211_TX_RC_MCS) { mac_index &= RATE_MCS_CODE_MSK; /* Remove # of streams */ - if (mac_index >= (RATE_9M_INDEX - IL_FIRST_OFDM_RATE)) + if (mac_index >= (RATE_9M_IDX - IL_FIRST_OFDM_RATE)) mac_index++; /* * mac80211 HT index is always zero-indexed; we need to move @@ -2276,7 +2276,7 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, rate_idx = (rate_idx > 0) ? (rate_idx - 1) : 0; if (il4965_rs_extract_rate(lq_sta->last_rate_n_flags) >= RATE_MIMO2_6M_PLCP) - rate_idx = rate_idx + MCS_INDEX_PER_STREAM; + rate_idx = rate_idx + MCS_IDX_PER_STREAM; info->control.rates[0].flags = IEEE80211_TX_RC_MCS; if (lq_sta->last_rate_n_flags & RATE_MCS_SGI_MSK) info->control.rates[0].flags |= diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c index 278517c9083c..c50d63918773 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c @@ -50,9 +50,9 @@ il4965_sta_alloc_lq(struct il_priv *il, u8 sta_id) /* Set up the rate scaling to start at selected rate, fall back * all the way down to 1M in IEEE order, and then spin on 1M */ if (il->band == IEEE80211_BAND_5GHZ) - r = RATE_6M_INDEX; + r = RATE_6M_IDX; else - r = RATE_1M_INDEX; + r = RATE_1M_IDX; if (r >= IL_FIRST_CCK_RATE && r <= IL_LAST_CCK_RATE) rate_flags |= RATE_MCS_CCK_MSK; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index 9671e10ff354..8f18d36f08ad 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -423,7 +423,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) */ out_cmd->hdr.cmd = REPLY_TX; out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | - INDEX_TO_SEQ(q->write_ptr))); + IDX_TO_SEQ(q->write_ptr))); /* Copy MAC header from skb into command buffer */ memcpy(tx_cmd->hdr, hdr, hdr_len); @@ -1172,7 +1172,7 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, ba_resp->seq_ctl); /* Calculate shift to align block-ack bits with our Tx win bits */ - sh = agg->start_idx - SEQ_TO_INDEX(seq_ctl >> 4); + sh = agg->start_idx - SEQ_TO_IDX(seq_ctl >> 4); if (sh < 0) /* tbw something is wrong with indices */ sh += 0x100; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index f62475de7591..58bdf9302987 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -632,9 +632,9 @@ static s32 get_min_power_index(s32 rate_power_index, u32 band) { if (!band) { if ((rate_power_index & 7) <= 4) - return MIN_TX_GAIN_INDEX_52GHZ_EXT; + return MIN_TX_GAIN_IDX_52GHZ_EXT; } - return MIN_TX_GAIN_INDEX; + return MIN_TX_GAIN_IDX; } struct gain_entry { @@ -1654,7 +1654,7 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, u16 sc; status = le16_to_cpu(frame_status[i].status); seq = le16_to_cpu(frame_status[i].sequence); - idx = SEQ_TO_INDEX(seq); + idx = SEQ_TO_IDX(seq); txq_id = SEQ_TO_QUEUE(seq); if (status & (AGG_TX_STATE_FEW_BYTES_MSK | @@ -1777,7 +1777,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); - int index = SEQ_TO_INDEX(sequence); + int index = SEQ_TO_IDX(sequence); struct il_tx_queue *txq = &il->txq[txq_id]; struct ieee80211_hdr *hdr; struct ieee80211_tx_info *info; diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h index aed11019f094..002f1d7f475b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ b/drivers/net/wireless/iwlegacy/iwl-commands.h @@ -168,8 +168,8 @@ enum { #define SEQ_TO_QUEUE(s) (((s) >> 8) & 0x1f) #define QUEUE_TO_SEQ(q) (((q) & 0x1f) << 8) -#define SEQ_TO_INDEX(s) ((s) & 0xff) -#define INDEX_TO_SEQ(i) ((i) & 0xff) +#define SEQ_TO_IDX(s) ((s) & 0xff) +#define IDX_TO_SEQ(i) ((i) & 0xff) #define SEQ_HUGE_FRAME cpu_to_le16(0x4000) #define SEQ_RX_FRAME cpu_to_le16(0x8000) @@ -3116,10 +3116,10 @@ struct il_missed_beacon_notif { * maximum sensitivity): * * START / MIN / MAX - * HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX 90 / 85 / 120 - * HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX 170 / 170 / 210 - * HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX 105 / 105 / 140 - * HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX 220 / 220 / 270 + * HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX 90 / 85 / 120 + * HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_IDX 170 / 170 / 210 + * HD_AUTO_CORR32_X4_TH_ADD_MIN_IDX 105 / 105 / 140 + * HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_IDX 220 / 220 / 270 * * If actual rate of OFDM false alarms (+ plcp_errors) is too high * (greater than 50 for each 204.8 msecs listening), reduce sensitivity @@ -3156,26 +3156,26 @@ struct il_missed_beacon_notif { * (notice that the start points for CCK are at maximum sensitivity): * * START / MIN / MAX - * HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX 125 / 125 / 200 - * HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX 200 / 200 / 400 - * HD_MIN_ENERGY_CCK_DET_INDEX 100 / 0 / 100 + * HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX 125 / 125 / 200 + * HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX 200 / 200 / 400 + * HD_MIN_ENERGY_CCK_DET_IDX 100 / 0 / 100 * * If actual rate of CCK false alarms (+ plcp_errors) is too high * (greater than 50 for each 204.8 msecs listening), method for reducing * sensitivity is: * - * 1) *Add* 3 to value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX, + * 1) *Add* 3 to value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX, * up to max 400. * - * 2) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is < 160, + * 2) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX is < 160, * sensitivity has been reduced a significant amount; bring it up to * a moderate 161. Otherwise, *add* 3, up to max 200. * - * 3) a) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX is > 160, + * 3) a) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX is > 160, * sensitivity has been reduced only a moderate or small amount; - * *subtract* 2 from value in HD_MIN_ENERGY_CCK_DET_INDEX, + * *subtract* 2 from value in HD_MIN_ENERGY_CCK_DET_IDX, * down to min 0. Otherwise (if gain has been significantly reduced), - * don't change the HD_MIN_ENERGY_CCK_DET_INDEX value. + * don't change the HD_MIN_ENERGY_CCK_DET_IDX value. * * b) Save a snapshot of the "silence reference". * @@ -3191,13 +3191,13 @@ struct il_missed_beacon_notif { * * Method for increasing sensitivity: * - * 1) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX, + * 1) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX, * down to min 125. * - * 2) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX, + * 2) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX, * down to min 200. * - * 3) *Add* 2 to value in HD_MIN_ENERGY_CCK_DET_INDEX, up to max 100. + * 3) *Add* 2 to value in HD_MIN_ENERGY_CCK_DET_IDX, up to max 100. * * If actual rate of CCK false alarms (+ plcp_errors) is within good range * (between 5 and 50 for each 204.8 msecs listening): @@ -3206,13 +3206,13 @@ struct il_missed_beacon_notif { * * 2) If previous beacon had too many CCK false alarms (+ plcp_errors), * give some extra margin to energy threshold by *subtracting* 8 - * from value in HD_MIN_ENERGY_CCK_DET_INDEX. + * from value in HD_MIN_ENERGY_CCK_DET_IDX. * * For all cases (too few, too many, good range), make sure that the CCK * detection threshold (energy) is below the energy level for robust * detection over the past 10 beacon periods, the "Max cck energy". * Lower values mean higher energy; this means making sure that the value - * in HD_MIN_ENERGY_CCK_DET_INDEX is at or *above* "Max cck energy". + * in HD_MIN_ENERGY_CCK_DET_IDX is at or *above* "Max cck energy". * */ @@ -3220,17 +3220,17 @@ struct il_missed_beacon_notif { * Table entries in SENSITIVITY_CMD (struct il_sensitivity_cmd) */ #define HD_TABLE_SIZE (11) /* number of entries */ -#define HD_MIN_ENERGY_CCK_DET_INDEX (0) /* table indexes */ -#define HD_MIN_ENERGY_OFDM_DET_INDEX (1) -#define HD_AUTO_CORR32_X1_TH_ADD_MIN_INDEX (2) -#define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_INDEX (3) -#define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_INDEX (4) -#define HD_AUTO_CORR32_X4_TH_ADD_MIN_INDEX (5) -#define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_INDEX (6) -#define HD_BARKER_CORR_TH_ADD_MIN_INDEX (7) -#define HD_BARKER_CORR_TH_ADD_MIN_MRC_INDEX (8) -#define HD_AUTO_CORR40_X4_TH_ADD_MIN_INDEX (9) -#define HD_OFDM_ENERGY_TH_IN_INDEX (10) +#define HD_MIN_ENERGY_CCK_DET_IDX (0) /* table indexes */ +#define HD_MIN_ENERGY_OFDM_DET_IDX (1) +#define HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX (2) +#define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_IDX (3) +#define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX (4) +#define HD_AUTO_CORR32_X4_TH_ADD_MIN_IDX (5) +#define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_IDX (6) +#define HD_BARKER_CORR_TH_ADD_MIN_IDX (7) +#define HD_BARKER_CORR_TH_ADD_MIN_MRC_IDX (8) +#define HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX (9) +#define HD_OFDM_ENERGY_TH_IN_IDX (10) /* Control field in struct il_sensitivity_cmd */ #define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE cpu_to_le16(0) diff --git a/drivers/net/wireless/iwlegacy/iwl-fh.h b/drivers/net/wireless/iwlegacy/iwl-fh.h index 0ae36df1c293..e993e3ea5b33 100644 --- a/drivers/net/wireless/iwlegacy/iwl-fh.h +++ b/drivers/net/wireless/iwlegacy/iwl-fh.h @@ -162,7 +162,7 @@ * RBs), should be 8 after preparing the first 8 RBs (for example), and must * wrap back to 0 at the end of the circular buffer (but don't wrap before * "read" index has advanced past 1! See below). - * NOTE: 4965 EXPECTS THE WRITE INDEX TO BE INCREMENTED IN MULTIPLES OF 8. + * NOTE: 4965 EXPECTS THE WRITE IDX TO BE INCREMENTED IN MULTIPLES OF 8. * * As the 4965 fills RBs (referenced from contiguous RBDs within the circular * buffer), it updates the Rx status buffer in host DRAM, 2) described above, diff --git a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h index 6670f2eb71ae..f3ee0dd67f57 100644 --- a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h +++ b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h @@ -59,64 +59,64 @@ struct il3945_rate_info { * struct il_rate_info il_rates[RATE_COUNT]; */ enum { - RATE_1M_INDEX = 0, - RATE_2M_INDEX, - RATE_5M_INDEX, - RATE_11M_INDEX, - RATE_6M_INDEX, - RATE_9M_INDEX, - RATE_12M_INDEX, - RATE_18M_INDEX, - RATE_24M_INDEX, - RATE_36M_INDEX, - RATE_48M_INDEX, - RATE_54M_INDEX, - RATE_60M_INDEX, + RATE_1M_IDX = 0, + RATE_2M_IDX, + RATE_5M_IDX, + RATE_11M_IDX, + RATE_6M_IDX, + RATE_9M_IDX, + RATE_12M_IDX, + RATE_18M_IDX, + RATE_24M_IDX, + RATE_36M_IDX, + RATE_48M_IDX, + RATE_54M_IDX, + RATE_60M_IDX, RATE_COUNT, RATE_COUNT_LEGACY = RATE_COUNT - 1, /* Excluding 60M */ RATE_COUNT_3945 = RATE_COUNT - 1, - RATE_INVM_INDEX = RATE_COUNT, + RATE_INVM_IDX = RATE_COUNT, RATE_INVALID = RATE_COUNT, }; enum { - RATE_6M_INDEX_TABLE = 0, - RATE_9M_INDEX_TABLE, - RATE_12M_INDEX_TABLE, - RATE_18M_INDEX_TABLE, - RATE_24M_INDEX_TABLE, - RATE_36M_INDEX_TABLE, - RATE_48M_INDEX_TABLE, - RATE_54M_INDEX_TABLE, - RATE_1M_INDEX_TABLE, - RATE_2M_INDEX_TABLE, - RATE_5M_INDEX_TABLE, - RATE_11M_INDEX_TABLE, - RATE_INVM_INDEX_TABLE = RATE_INVM_INDEX - 1, + RATE_6M_IDX_TABLE = 0, + RATE_9M_IDX_TABLE, + RATE_12M_IDX_TABLE, + RATE_18M_IDX_TABLE, + RATE_24M_IDX_TABLE, + RATE_36M_IDX_TABLE, + RATE_48M_IDX_TABLE, + RATE_54M_IDX_TABLE, + RATE_1M_IDX_TABLE, + RATE_2M_IDX_TABLE, + RATE_5M_IDX_TABLE, + RATE_11M_IDX_TABLE, + RATE_INVM_IDX_TABLE = RATE_INVM_IDX - 1, }; enum { - IL_FIRST_OFDM_RATE = RATE_6M_INDEX, - IL39_LAST_OFDM_RATE = RATE_54M_INDEX, - IL_LAST_OFDM_RATE = RATE_60M_INDEX, - IL_FIRST_CCK_RATE = RATE_1M_INDEX, - IL_LAST_CCK_RATE = RATE_11M_INDEX, + IL_FIRST_OFDM_RATE = RATE_6M_IDX, + IL39_LAST_OFDM_RATE = RATE_54M_IDX, + IL_LAST_OFDM_RATE = RATE_60M_IDX, + IL_FIRST_CCK_RATE = RATE_1M_IDX, + IL_LAST_CCK_RATE = RATE_11M_IDX, }; /* #define vs. enum to keep from defaulting to 'large integer' */ -#define RATE_6M_MASK (1 << RATE_6M_INDEX) -#define RATE_9M_MASK (1 << RATE_9M_INDEX) -#define RATE_12M_MASK (1 << RATE_12M_INDEX) -#define RATE_18M_MASK (1 << RATE_18M_INDEX) -#define RATE_24M_MASK (1 << RATE_24M_INDEX) -#define RATE_36M_MASK (1 << RATE_36M_INDEX) -#define RATE_48M_MASK (1 << RATE_48M_INDEX) -#define RATE_54M_MASK (1 << RATE_54M_INDEX) -#define RATE_60M_MASK (1 << RATE_60M_INDEX) -#define RATE_1M_MASK (1 << RATE_1M_INDEX) -#define RATE_2M_MASK (1 << RATE_2M_INDEX) -#define RATE_5M_MASK (1 << RATE_5M_INDEX) -#define RATE_11M_MASK (1 << RATE_11M_INDEX) +#define RATE_6M_MASK (1 << RATE_6M_IDX) +#define RATE_9M_MASK (1 << RATE_9M_IDX) +#define RATE_12M_MASK (1 << RATE_12M_IDX) +#define RATE_18M_MASK (1 << RATE_18M_IDX) +#define RATE_24M_MASK (1 << RATE_24M_IDX) +#define RATE_36M_MASK (1 << RATE_36M_IDX) +#define RATE_48M_MASK (1 << RATE_48M_IDX) +#define RATE_54M_MASK (1 << RATE_54M_IDX) +#define RATE_60M_MASK (1 << RATE_60M_IDX) +#define RATE_1M_MASK (1 << RATE_1M_IDX) +#define RATE_2M_MASK (1 << RATE_2M_IDX) +#define RATE_5M_MASK (1 << RATE_5M_IDX) +#define RATE_11M_MASK (1 << RATE_11M_IDX) /* uCode API values for legacy bit rates, both OFDM and CCK */ enum { diff --git a/drivers/net/wireless/iwlegacy/iwl-power.h b/drivers/net/wireless/iwlegacy/iwl-power.h index e149f789063f..e4a0ef270819 100644 --- a/drivers/net/wireless/iwlegacy/iwl-power.h +++ b/drivers/net/wireless/iwlegacy/iwl-power.h @@ -31,11 +31,11 @@ #include "iwl-commands.h" enum il_power_level { - IL_POWER_INDEX_1, - IL_POWER_INDEX_2, - IL_POWER_INDEX_3, - IL_POWER_INDEX_4, - IL_POWER_INDEX_5, + IL_POWER_IDX_1, + IL_POWER_IDX_2, + IL_POWER_IDX_3, + IL_POWER_IDX_4, + IL_POWER_IDX_5, IL_POWER_NUM }; diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c index a6bee8432798..5c0d1317d149 100644 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -62,7 +62,7 @@ * WRITE = READ. * * During initialization, the host sets up the READ queue position to the first - * INDEX position, and WRITE to the last (READ - 1 wrapped) + * IDX position, and WRITE to the last (READ - 1 wrapped) * * When the firmware places a packet in a buffer, it will advance the READ index * and fire the RX interrupt. The driver can then query the READ index and @@ -74,13 +74,13 @@ * iwl->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled * to replenish the iwl->rxq->rx_free. * + In il_rx_replenish (scheduled) if 'processed' != 'read' then the - * iwl->rxq is replenished and the READ INDEX is updated (updating the + * iwl->rxq is replenished and the READ IDX is updated (updating the * 'processed' and 'read' driver indexes as well) * + A received packet is processed and handed to the kernel network stack, * detached from the iwl->rxq. The driver 'processed' index is updated. * + The Host/Firmware iwl->rxq is replenished at tasklet time from the rx_free * list. If there are no allocated buffers in iwl->rxq->rx_free, the READ - * INDEX is not incremented and iwl->status(RX_STALLED) is set. If there + * IDX is not incremented and iwl->status(RX_STALLED) is set. If there * were enough free buffers and RX_STALLED is set it is cleared. * * @@ -96,7 +96,7 @@ * * -- enable interrupts -- * ISR - il_rx() Detach il_rx_bufs from pool up to the - * READ INDEX, detaching the SKB from the pool. + * READ IDX, detaching the SKB from the pool. * Moves the packet buffer from queue to rx_used. * Calls il_rx_queue_restock to refill any empty * slots. diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index b9c417ce52b3..45114b495b3e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -500,7 +500,7 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) out_cmd->hdr.flags = 0; out_cmd->hdr.sequence = cpu_to_le16(QUEUE_TO_SEQ(il->cmd_queue) | - INDEX_TO_SEQ(q->write_ptr)); + IDX_TO_SEQ(q->write_ptr)); if (cmd->flags & CMD_SIZE_HUGE) out_cmd->hdr.sequence |= SEQ_HUGE_FRAME; len = sizeof(struct il_device_cmd); @@ -598,7 +598,7 @@ il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb) struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); - int index = SEQ_TO_INDEX(sequence); + int index = SEQ_TO_IDX(sequence); int cmd_index; bool huge = !!(pkt->hdr.sequence & SEQ_HUGE_FRAME); struct il_device_cmd *cmd; diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 1fc9bfbc891e..017b29720423 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -563,7 +563,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) */ out_cmd->hdr.cmd = REPLY_TX; out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | - INDEX_TO_SEQ(q->write_ptr))); + IDX_TO_SEQ(q->write_ptr))); /* Copy MAC header from skb into command buffer */ memcpy(tx_cmd->hdr, hdr, hdr_len); @@ -903,7 +903,7 @@ static void il3945_setup_rx_handlers(struct il_priv *il) * WRITE = READ. * * During initialization, the host sets up the READ queue position to the first - * INDEX position, and WRITE to the last (READ - 1 wrapped) + * IDX position, and WRITE to the last (READ - 1 wrapped) * * When the firmware places a packet in a buffer, it will advance the READ index * and fire the RX interrupt. The driver can then query the READ index and @@ -915,13 +915,13 @@ static void il3945_setup_rx_handlers(struct il_priv *il) * iwl->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled * to replenish the iwl->rxq->rx_free. * + In il3945_rx_replenish (scheduled) if 'processed' != 'read' then the - * iwl->rxq is replenished and the READ INDEX is updated (updating the + * iwl->rxq is replenished and the READ IDX is updated (updating the * 'processed' and 'read' driver indexes as well) * + A received packet is processed and handed to the kernel network stack, * detached from the iwl->rxq. The driver 'processed' index is updated. * + The Host/Firmware iwl->rxq is replenished at tasklet time from the rx_free * list. If there are no allocated buffers in iwl->rxq->rx_free, the READ - * INDEX is not incremented and iwl->status(RX_STALLED) is set. If there + * IDX is not incremented and iwl->status(RX_STALLED) is set. If there * were enough free buffers and RX_STALLED is set it is cleared. * * @@ -936,7 +936,7 @@ static void il3945_setup_rx_handlers(struct il_priv *il) * * -- enable interrupts -- * ISR - il3945_rx() Detach il_rx_bufs from pool up to the - * READ INDEX, detaching the SKB from the pool. + * READ IDX, detaching the SKB from the pool. * Moves the packet buffer from queue to rx_used. * Calls il3945_rx_queue_restock to refill any empty * slots. -- cgit v1.2.3 From 0c2c885200057c44ac5660d123e199192689ca5d Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 12:30:17 +0100 Subject: iwlegacy: s/index/idx/ Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-3945-hw.h | 6 +- drivers/net/wireless/iwlegacy/iwl-3945-rs.c | 110 ++++----- drivers/net/wireless/iwlegacy/iwl-3945.c | 314 +++++++++++++------------- drivers/net/wireless/iwlegacy/iwl-4965-hw.h | 36 +-- drivers/net/wireless/iwlegacy/iwl-4965-lib.c | 4 +- drivers/net/wireless/iwlegacy/iwl-4965-rs.c | 290 ++++++++++++------------ drivers/net/wireless/iwlegacy/iwl-4965-sta.c | 14 +- drivers/net/wireless/iwlegacy/iwl-4965-tx.c | 34 +-- drivers/net/wireless/iwlegacy/iwl-4965.c | 84 +++---- drivers/net/wireless/iwlegacy/iwl-4965.h | 4 +- drivers/net/wireless/iwlegacy/iwl-commands.h | 42 ++-- drivers/net/wireless/iwlegacy/iwl-csr.h | 6 +- drivers/net/wireless/iwlegacy/iwl-dev.h | 34 +-- drivers/net/wireless/iwlegacy/iwl-eeprom.c | 30 +-- drivers/net/wireless/iwlegacy/iwl-eeprom.h | 2 +- drivers/net/wireless/iwlegacy/iwl-fh.h | 30 +-- drivers/net/wireless/iwlegacy/iwl-helpers.h | 16 +- drivers/net/wireless/iwlegacy/iwl-led.c | 2 +- drivers/net/wireless/iwlegacy/iwl-legacy-rs.h | 6 +- drivers/net/wireless/iwlegacy/iwl-prph.h | 18 +- drivers/net/wireless/iwlegacy/iwl-rx.c | 22 +- drivers/net/wireless/iwlegacy/iwl-sta.c | 14 +- drivers/net/wireless/iwlegacy/iwl-sta.h | 2 +- drivers/net/wireless/iwlegacy/iwl-tx.c | 36 +-- drivers/net/wireless/iwlegacy/iwl3945-base.c | 44 ++-- drivers/net/wireless/iwlegacy/iwl4965-base.c | 36 +-- 26 files changed, 618 insertions(+), 618 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-hw.h b/drivers/net/wireless/iwlegacy/iwl-3945-hw.h index fcb466a2f065..53e5fb4373d9 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-hw.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945-hw.h @@ -81,7 +81,7 @@ /* * Mapping of a Tx power level, at factory calibration temperature, - * to a radio/DSP gain table index. + * to a radio/DSP gain table idx. * One for each of 5 "sample" power levels in each band. * v_det is measured at the factory, using the 3945's built-in power amplifier * (PA) output voltage detector. This same detector is used during Tx of @@ -91,13 +91,13 @@ * DO NOT ALTER THIS STRUCTURE!!! */ struct il3945_eeprom_txpower_sample { - u8 gain_index; /* index into power (gain) setup table ... */ + u8 gain_idx; /* idx into power (gain) setup table ... */ s8 power; /* ... for this pwr level for this chnl group */ u16 v_det; /* PA output voltage */ } __packed; /* - * Mappings of Tx power levels -> nominal radio/DSP gain table indexes. + * Mappings of Tx power levels -> nominal radio/DSP gain table idxes. * One for each channel group (a.k.a. "band") (1 for BG, 4 for A). * Tx power setup code interpolates between the 5 "sample" power levels * to determine the nominal setup for a requested power level. diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c index 4d83c6292246..f84ed5ecc676 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c @@ -60,7 +60,7 @@ static s32 il3945_expected_tpt_b[RATE_COUNT_3945] = { struct il3945_tpt_entry { s8 min_rssi; - u8 index; + u8 idx; }; static struct il3945_tpt_entry il3945_tpt_table_a[] = { @@ -98,9 +98,9 @@ static struct il3945_tpt_entry il3945_tpt_table_g[] = { #define RATE_DECREASE_TH 1920 #define RATE_RETRY_TH 15 -static u8 il3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band) +static u8 il3945_get_rate_idx_by_rssi(s32 rssi, enum ieee80211_band band) { - u32 index = 0; + u32 idx = 0; u32 table_size = 0; struct il3945_tpt_entry *tpt_table = NULL; @@ -123,12 +123,12 @@ static u8 il3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band) break; } - while (index < table_size && rssi < tpt_table[index].min_rssi) - index++; + while (idx < table_size && rssi < tpt_table[idx].min_rssi) + idx++; - index = min(index, (table_size - 1)); + idx = min(idx, (table_size - 1)); - return tpt_table[index].index; + return tpt_table[idx].idx; } static void il3945_clear_win(struct il3945_rate_scale_data *win) @@ -168,7 +168,7 @@ static int il3945_rate_scale_flush_wins(struct il3945_rs_sta *rs_sta) if (time_after(jiffies, rs_sta->win[i].stamp + RATE_WIN_FLUSH)) { D_RATE("flushing %d samples of rate " - "index %d\n", + "idx %d\n", rs_sta->win[i].counter, i); il3945_clear_win(&rs_sta->win[i]); } else @@ -256,7 +256,7 @@ static void il3945_bg_rate_scale_flush(unsigned long data) */ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, struct il3945_rate_scale_data *win, - int success, int retries, int index) + int success, int retries, int idx) { unsigned long flags; s32 fail_count; @@ -318,7 +318,7 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, if (fail_count >= RATE_MIN_FAILURE_TH || win->success_counter >= RATE_MIN_SUCCESS_TH) win->average_tpt = ((win->success_ratio * - rs_sta->expected_tpt[index] + 64) / 128); + rs_sta->expected_tpt[idx] + 64) / 128); else win->average_tpt = IL_INVALID_VALUE; @@ -447,7 +447,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * struct sk_buff *skb) { s8 retries = 0, current_count; - int scale_rate_index, first_index, last_index; + int scale_rate_idx, first_idx, last_idx; unsigned long flags; struct il_priv *il = (struct il_priv *)il_rate; struct il3945_rs_sta *rs_sta = il_sta; @@ -460,9 +460,9 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * if (retries > RATE_RETRY_TH) retries = RATE_RETRY_TH; - first_index = sband->bitrates[info->status.rates[0].idx].hw_value; - if (first_index < 0 || first_index >= RATE_COUNT_3945) { - D_RATE("leave: Rate out of bounds: %d\n", first_index); + first_idx = sband->bitrates[info->status.rates[0].idx].hw_value; + if (first_idx < 0 || first_idx >= RATE_COUNT_3945) { + D_RATE("leave: Rate out of bounds: %d\n", first_idx); return; } @@ -480,8 +480,8 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * rs_sta->tx_packets++; - scale_rate_index = first_index; - last_index = first_index; + scale_rate_idx = first_idx; + last_idx = first_idx; /* * Update the win for each rate. We determine which rates @@ -489,42 +489,42 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * * of retries configured for each rate -- currently set to the * il value 'retry_rate' vs. rate specific * - * On exit from this while loop last_index indicates the rate + * On exit from this while loop last_idx indicates the rate * at which the frame was finally transmitted (or failed if no * ACK) */ while (retries > 1) { if ((retries - 1) < il->retry_rate) { current_count = (retries - 1); - last_index = scale_rate_index; + last_idx = scale_rate_idx; } else { current_count = il->retry_rate; - last_index = il3945_rs_next_rate(il, - scale_rate_index); + last_idx = il3945_rs_next_rate(il, + scale_rate_idx); } /* Update this rate accounting for as many retries * as was used for it (per current_count) */ il3945_collect_tx_data(rs_sta, - &rs_sta->win[scale_rate_index], - 0, current_count, scale_rate_index); + &rs_sta->win[scale_rate_idx], + 0, current_count, scale_rate_idx); D_RATE("Update rate %d for %d retries.\n", - scale_rate_index, current_count); + scale_rate_idx, current_count); retries -= current_count; - scale_rate_index = last_index; + scale_rate_idx = last_idx; } - /* Update the last index win with success/failure based on ACK */ + /* Update the last idx win with success/failure based on ACK */ D_RATE("Update rate %d with %s.\n", - last_index, + last_idx, (info->flags & IEEE80211_TX_STAT_ACK) ? "success" : "failure"); il3945_collect_tx_data(rs_sta, - &rs_sta->win[last_index], - info->flags & IEEE80211_TX_STAT_ACK, 1, last_index); + &rs_sta->win[last_idx], + info->flags & IEEE80211_TX_STAT_ACK, 1, last_idx); /* We updated the rate scale win -- if its been more than * flush_time since the last run, schedule the flush @@ -547,7 +547,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * } static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, - u8 index, u16 rate_mask, enum ieee80211_band band) + u8 idx, u16 rate_mask, enum ieee80211_band band) { u8 high = RATE_INVALID; u8 low = RATE_INVALID; @@ -560,7 +560,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, u32 mask; /* Find the previous rate that is in the rate mask */ - i = index - 1; + i = idx - 1; for (mask = (1 << i); i >= 0; i--, mask >>= 1) { if (rate_mask & mask) { low = i; @@ -569,7 +569,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, } /* Find the next rate that is in the rate mask */ - i = index + 1; + i = idx + 1; for (mask = (1 << i); i < RATE_COUNT_3945; i++, mask <<= 1) { if (rate_mask & mask) { @@ -581,7 +581,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, return (high << 8) | low; } - low = index; + low = idx; while (low != RATE_INVALID) { if (rs_sta->tgg) low = il3945_rates[low].prev_rs_tgg; @@ -594,7 +594,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, D_RATE("Skipping masked lower rate: %d\n", low); } - high = index; + high = idx; while (high != RATE_INVALID) { if (rs_sta->tgg) high = il3945_rates[high].next_rs_tgg; @@ -622,7 +622,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, * the entire A/B/G spectrum vs. being limited to just one particular * hw_mode. * - * As such, we can't convert the index obtained below into the hw_mode's + * As such, we can't convert the idx obtained below into the hw_mode's * rate table and must reference the driver allocated rate table * */ @@ -634,7 +634,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, u8 low = RATE_INVALID; u8 high = RATE_INVALID; u16 high_low; - int index; + int idx; struct il3945_rs_sta *rs_sta = il_sta; struct il3945_rate_scale_data *win = NULL; int current_tpt = IL_INVALID_VALUE; @@ -668,7 +668,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, if (max_rate_idx < 0 || max_rate_idx >= RATE_COUNT) max_rate_idx = -1; - index = min(rs_sta->last_txrate_idx & 0xffff, RATE_COUNT_3945 - 1); + idx = min(rs_sta->last_txrate_idx & 0xffff, RATE_COUNT_3945 - 1); if (sband->band == IEEE80211_BAND_5GHZ) rate_mask = rate_mask << IL_FIRST_OFDM_RATE; @@ -679,19 +679,19 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, * to rssi value */ if (rs_sta->start_rate != RATE_INVALID) { - if (rs_sta->start_rate < index && + if (rs_sta->start_rate < idx && (rate_mask & (1 << rs_sta->start_rate))) - index = rs_sta->start_rate; + idx = rs_sta->start_rate; rs_sta->start_rate = RATE_INVALID; } /* force user max rate if set by user */ - if (max_rate_idx != -1 && max_rate_idx < index) { + if (max_rate_idx != -1 && max_rate_idx < idx) { if (rate_mask & (1 << max_rate_idx)) - index = max_rate_idx; + idx = max_rate_idx; } - win = &(rs_sta->win[index]); + win = &(rs_sta->win[idx]); fail_count = win->counter - win->success_counter; @@ -702,7 +702,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, D_RATE("Invalid average_tpt on rate %d: " "counter: %d, success_counter: %d, " "expected_tpt is %sNULL\n", - index, + idx, win->counter, win->success_counter, rs_sta->expected_tpt ? "not " : ""); @@ -715,7 +715,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, current_tpt = win->average_tpt; - high_low = il3945_get_adjacent_rate(rs_sta, index, rate_mask, + high_low = il3945_get_adjacent_rate(rs_sta, idx, rate_mask, sband->band); low = high_low & 0xff; high = (high_low >> 8) & 0xff; @@ -800,13 +800,13 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, /* Decrese rate */ if (low != RATE_INVALID) - index = low; + idx = low; break; case 1: /* Increase rate */ if (high != RATE_INVALID) - index = high; + idx = high; break; @@ -817,21 +817,21 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, } D_RATE("Selected %d (action %d) - low %d high %d\n", - index, scale_action, low, high); + idx, scale_action, low, high); out: if (sband->band == IEEE80211_BAND_5GHZ) { - if (WARN_ON_ONCE(index < IL_FIRST_OFDM_RATE)) - index = IL_FIRST_OFDM_RATE; - rs_sta->last_txrate_idx = index; - info->control.rates[0].idx = index - IL_FIRST_OFDM_RATE; + if (WARN_ON_ONCE(idx < IL_FIRST_OFDM_RATE)) + idx = IL_FIRST_OFDM_RATE; + rs_sta->last_txrate_idx = idx; + info->control.rates[0].idx = idx - IL_FIRST_OFDM_RATE; } else { - rs_sta->last_txrate_idx = index; + rs_sta->last_txrate_idx = idx; info->control.rates[0].idx = rs_sta->last_txrate_idx; } - D_RATE("leave: %d\n", index); + D_RATE("leave: %d\n", idx); } #ifdef CONFIG_MAC80211_DEBUGFS @@ -855,7 +855,7 @@ static ssize_t il3945_sta_dbgfs_stats_table_read(struct file *file, if (!buff) return -ENOMEM; - desc += sprintf(buff + desc, "tx packets=%d last rate index=%d\n" + desc += sprintf(buff + desc, "tx packets=%d last rate idx=%d\n" "rate=0x%X flush time %d\n", lq_sta->tx_packets, lq_sta->last_txrate_idx, @@ -977,9 +977,9 @@ void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) D_RATE("Network RSSI: %d\n", rssi); - rs_sta->start_rate = il3945_get_rate_index_by_rssi(rssi, il->band); + rs_sta->start_rate = il3945_get_rate_idx_by_rssi(rssi, il->band); - D_RATE("leave: rssi %d assign rate index: " + D_RATE("leave: rssi %d assign rate idx: " "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate, il3945_rates[rs_sta->start_rate].plcp); rcu_read_unlock(); diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index 3908bff8e0ac..96a762804944 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -86,12 +86,12 @@ const struct il3945_rate_info il3945_rates[RATE_COUNT_3945] = { IL_DECLARE_RATE_INFO(54, 48, INV, 48, INV, 48, INV),/* 54mbps */ }; -static inline u8 il3945_get_prev_ieee_rate(u8 rate_index) +static inline u8 il3945_get_prev_ieee_rate(u8 rate_idx) { - u8 rate = il3945_rates[rate_index].prev_ieee; + u8 rate = il3945_rates[rate_idx].prev_ieee; if (rate == RATE_INVALID) - rate = rate_index; + rate = rate_idx; return rate; } @@ -270,12 +270,12 @@ int il3945_rs_next_rate(struct il_priv *il, int rate) /** * il3945_tx_queue_reclaim - Reclaim Tx queue entries already Tx'd * - * When FW advances 'R' index, all entries between old and new 'R' index + * When FW advances 'R' idx, all entries between old and new 'R' idx * need to be reclaimed. As result, some free space forms. If there is * enough free space (> low mark), wake the stack that feeds us. */ static void il3945_tx_queue_reclaim(struct il_priv *il, - int txq_id, int index) + int txq_id, int idx) { struct il_tx_queue *txq = &il->txq[txq_id]; struct il_queue *q = &txq->q; @@ -283,8 +283,8 @@ static void il3945_tx_queue_reclaim(struct il_priv *il, BUG_ON(txq_id == IL39_CMD_QUEUE_NUM); - for (index = il_queue_inc_wrap(index, q->n_bd); - q->read_ptr != index; + for (idx = il_queue_inc_wrap(idx, q->n_bd); + q->read_ptr != idx; q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { tx_info = &txq->txb[txq->q.read_ptr]; @@ -307,7 +307,7 @@ static void il3945_rx_reply_tx(struct il_priv *il, struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); - int index = SEQ_TO_IDX(sequence); + int idx = SEQ_TO_IDX(sequence); struct il_tx_queue *txq = &il->txq[txq_id]; struct ieee80211_tx_info *info; struct il3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; @@ -315,10 +315,10 @@ static void il3945_rx_reply_tx(struct il_priv *il, int rate_idx; int fail; - if (index >= txq->q.n_bd || il_queue_used(&txq->q, index) == 0) { - IL_ERR("Read index for DMA queue txq_id (%d) index %d " + if (idx >= txq->q.n_bd || il_queue_used(&txq->q, idx) == 0) { + IL_ERR("Read idx for DMA queue txq_id (%d) idx %d " "is out of range [0-%d] %d %d\n", txq_id, - index, txq->q.n_bd, txq->q.write_ptr, + idx, txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr); return; } @@ -345,8 +345,8 @@ static void il3945_rx_reply_tx(struct il_priv *il, txq_id, il3945_get_tx_fail_reason(status), status, tx_resp->rate, tx_resp->failure_frame); - D_TX_REPLY("Tx queue reclaim %d\n", index); - il3945_tx_queue_reclaim(il, txq_id, index); + D_TX_REPLY("Tx queue reclaim %d\n", idx); + il3945_tx_queue_reclaim(il, txq_id, idx); if (status & TX_ABORT_REQUIRED_MSK) IL_ERR("TODO: Implement Tx ABORT REQUIRED!!!\n"); @@ -616,15 +616,15 @@ int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, } /** - * il3945_hw_txq_free_tfd - Free one TFD, those at index [txq->q.read_ptr] + * il3945_hw_txq_free_tfd - Free one TFD, those at idx [txq->q.read_ptr] * - * Does NOT advance any indexes + * Does NOT advance any idxes */ void il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) { struct il3945_tfd *tfd_tmp = (struct il3945_tfd *)txq->tfds; - int index = txq->q.read_ptr; - struct il3945_tfd *tfd = &tfd_tmp[index]; + int idx = txq->q.read_ptr; + struct il3945_tfd *tfd = &tfd_tmp[idx]; struct pci_dev *dev = il->pci_dev; int i; int counter; @@ -640,8 +640,8 @@ void il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) /* Unmap tx_cmd */ if (counter) pci_unmap_single(dev, - dma_unmap_addr(&txq->meta[index], mapping), - dma_unmap_len(&txq->meta[index], len), + dma_unmap_addr(&txq->meta[idx], mapping), + dma_unmap_len(&txq->meta[idx], len), PCI_DMA_TODEVICE); /* unmap chunks if any */ @@ -675,7 +675,7 @@ void il3945_hw_build_tx_cmd_rate(struct il_priv *il, int sta_id, int tx_id) { u16 hw_value = ieee80211_get_tx_rate(il->hw, info)->hw_value; - u16 rate_index = min(hw_value & 0xffff, RATE_COUNT_3945); + u16 rate_idx = min(hw_value & 0xffff, RATE_COUNT_3945); u16 rate_mask; int rate; u8 rts_retry_limit; @@ -684,7 +684,7 @@ void il3945_hw_build_tx_cmd_rate(struct il_priv *il, __le16 fc = hdr->frame_control; struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; - rate = il3945_rates[rate_index].plcp; + rate = il3945_rates[rate_idx].plcp; tx_flags = tx_cmd->tx_flags; /* We need to figure out how to get the sta->supp_rates while @@ -1040,7 +1040,7 @@ void il3945_hw_txq_ctx_stop(struct il_priv *il) /** * il3945_hw_reg_adjust_power_by_temp - * return index delta into power gain settings table + * return idx delta into power gain settings table */ static int il3945_hw_reg_adjust_power_by_temp(int new_reading, int old_reading) { @@ -1298,13 +1298,13 @@ static struct il3945_tx_power power_gain_table[2][IL_MAX_GAIN_ENTRIES] = { {3, 120} } /* 5.x GHz, lowest power */ }; -static inline u8 il3945_hw_reg_fix_power_index(int index) +static inline u8 il3945_hw_reg_fix_power_idx(int idx) { - if (index < 0) + if (idx < 0) return 0; - if (index >= IL_MAX_GAIN_ENTRIES) + if (idx >= IL_MAX_GAIN_ENTRIES) return IL_MAX_GAIN_ENTRIES - 1; - return (u8) index; + return (u8) idx; } /* Kick off thermal recalibration check every 60 seconds */ @@ -1316,16 +1316,16 @@ static inline u8 il3945_hw_reg_fix_power_index(int index) * Set (in our channel info database) the direct scan Tx power for 1 Mbit (CCK) * or 6 Mbit (OFDM) rates. */ -static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_index, - s32 rate_index, const s8 *clip_pwrs, +static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_idx, + s32 rate_idx, const s8 *clip_pwrs, struct il_channel_info *ch_info, - int band_index) + int band_idx) { struct il3945_scan_power_info *scan_power_info; s8 power; - u8 power_index; + u8 power_idx; - scan_power_info = &ch_info->scan_pwr_info[scan_tbl_index]; + scan_power_info = &ch_info->scan_pwr_info[scan_tbl_idx]; /* use this channel group's 6Mbit clipping/saturation pwr, * but cap at regulatory scan power restriction (set during init @@ -1337,30 +1337,30 @@ static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_index, /* find difference between new scan *power* and current "normal" * Tx *power* for 6Mb. Use this difference (x2) to adjust the - * current "normal" temperature-compensated Tx power *index* for + * current "normal" temperature-compensated Tx power *idx* for * this rate (1Mb or 6Mb) to yield new temp-compensated scan power - * *index*. */ - power_index = ch_info->power_info[rate_index].power_table_index + * *idx*. */ + power_idx = ch_info->power_info[rate_idx].power_table_idx - (power - ch_info->power_info [RATE_6M_IDX_TABLE].requested_power) * 2; - /* store reference index that we use when adjusting *all* scan + /* store reference idx that we use when adjusting *all* scan * powers. So we can accommodate user (all channel) or spectrum * management (single channel) power changes "between" temperature * feedback compensation procedures. - * don't force fit this reference index into gain table; it may be a + * don't force fit this reference idx into gain table; it may be a * negative number. This will help avoid errors when we're at * the lower bounds (highest gains, for warmest temperatures) * of the table. */ /* don't exceed table bounds for "real" setting */ - power_index = il3945_hw_reg_fix_power_index(power_index); + power_idx = il3945_hw_reg_fix_power_idx(power_idx); - scan_power_info->power_table_index = power_index; + scan_power_info->power_table_idx = power_idx; scan_power_info->tpc.tx_gain = - power_gain_table[band_index][power_index].tx_gain; + power_gain_table[band_idx][power_idx].tx_gain; scan_power_info->tpc.dsp_atten = - power_gain_table[band_index][power_index].dsp_atten; + power_gain_table[band_idx][power_idx].dsp_atten; } /** @@ -1438,7 +1438,7 @@ static int il3945_send_tx_power(struct il_priv *il) * il3945_hw_reg_set_new_power - Configures power tables at new levels * @ch_info: Channel to update. Uses power_info.requested_power. * - * Replace requested_power and base_power_index ch_info fields for + * Replace requested_power and base_power_idx ch_info fields for * one channel. * * Called if user or spectrum management changes power preferences. @@ -1460,7 +1460,7 @@ static int il3945_hw_reg_set_new_power(struct il_priv *il, int power; /* Get this chnlgrp's rate-to-max/clip-powers table */ - clip_pwrs = il->_3945.clip_groups[ch_info->group_index].clip_powers; + clip_pwrs = il->_3945.clip_groups[ch_info->group_idx].clip_powers; /* Get this channel's rate-to-current-power settings table */ power_info = ch_info->power_info; @@ -1476,9 +1476,9 @@ static int il3945_hw_reg_set_new_power(struct il_priv *il, continue; /* find difference between old and new requested powers, - * update base (non-temp-compensated) power index */ + * update base (non-temp-compensated) power idx */ delta_idx = (power - power_info->requested_power) * 2; - power_info->base_power_index -= delta_idx; + power_info->base_power_idx -= delta_idx; /* save new requested power value */ power_info->requested_power = power; @@ -1496,9 +1496,9 @@ static int il3945_hw_reg_set_new_power(struct il_priv *il, /* do all CCK rates' il3945_channel_power_info structures */ for (i = RATE_1M_IDX_TABLE; i <= RATE_11M_IDX_TABLE; i++) { power_info->requested_power = power; - power_info->base_power_index = + power_info->base_power_idx = ch_info->power_info[RATE_12M_IDX_TABLE]. - base_power_index + IL_CCK_FROM_OFDM_IDX_DIFF; + base_power_idx + IL_CCK_FROM_OFDM_IDX_DIFF; ++power_info; } } @@ -1537,7 +1537,7 @@ static int il3945_hw_reg_get_ch_txpower_limit(struct il_channel_info *ch_info) * Compensate txpower settings of *all* channels for temperature. * This only accounts for the difference between current temperature * and the factory calibration temperatures, and bases the new settings - * on the channel's base_power_index. + * on the channel's base_power_idx. * * If RxOn is "associated", this sends the new Txpower to NIC! */ @@ -1545,11 +1545,11 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) { struct il_channel_info *ch_info = NULL; struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - int delta_index; + int delta_idx; const s8 *clip_pwrs; /* array of h/w max power levels for each rate */ u8 a_band; - u8 rate_index; - u8 scan_tbl_index; + u8 rate_idx; + u8 scan_tbl_idx; u8 i; int ref_temp; int temperature = il->temperature; @@ -1565,41 +1565,41 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) a_band = il_is_channel_a_band(ch_info); /* Get this chnlgrp's factory calibration temperature */ - ref_temp = (s16)eeprom->groups[ch_info->group_index]. + ref_temp = (s16)eeprom->groups[ch_info->group_idx]. temperature; - /* get power index adjustment based on current and factory + /* get power idx adjustment based on current and factory * temps */ - delta_index = il3945_hw_reg_adjust_power_by_temp(temperature, + delta_idx = il3945_hw_reg_adjust_power_by_temp(temperature, ref_temp); /* set tx power value for all rates, OFDM and CCK */ - for (rate_index = 0; rate_index < RATE_COUNT_3945; - rate_index++) { + for (rate_idx = 0; rate_idx < RATE_COUNT_3945; + rate_idx++) { int power_idx = - ch_info->power_info[rate_index].base_power_index; + ch_info->power_info[rate_idx].base_power_idx; /* temperature compensate */ - power_idx += delta_index; + power_idx += delta_idx; /* stay within table range */ - power_idx = il3945_hw_reg_fix_power_index(power_idx); - ch_info->power_info[rate_index]. - power_table_index = (u8) power_idx; - ch_info->power_info[rate_index].tpc = + power_idx = il3945_hw_reg_fix_power_idx(power_idx); + ch_info->power_info[rate_idx]. + power_table_idx = (u8) power_idx; + ch_info->power_info[rate_idx].tpc = power_gain_table[a_band][power_idx]; } /* Get this chnlgrp's rate-to-max/clip-powers table */ - clip_pwrs = il->_3945.clip_groups[ch_info->group_index].clip_powers; + clip_pwrs = il->_3945.clip_groups[ch_info->group_idx].clip_powers; /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */ - for (scan_tbl_index = 0; - scan_tbl_index < IL_NUM_SCAN_RATES; scan_tbl_index++) { - s32 actual_index = (scan_tbl_index == 0) ? + for (scan_tbl_idx = 0; + scan_tbl_idx < IL_NUM_SCAN_RATES; scan_tbl_idx++) { + s32 actual_idx = (scan_tbl_idx == 0) ? RATE_1M_IDX_TABLE : RATE_6M_IDX_TABLE; - il3945_hw_reg_set_scan_power(il, scan_tbl_index, - actual_index, clip_pwrs, + il3945_hw_reg_set_scan_power(il, scan_tbl_idx, + actual_idx, clip_pwrs, ch_info, a_band); } } @@ -1878,7 +1878,7 @@ static void il3945_bg_reg_txpower_periodic(struct work_struct *work) } /** - * il3945_hw_reg_get_ch_grp_index - find the channel-group index (0-4) + * il3945_hw_reg_get_ch_grp_idx - find the channel-group idx (0-4) * for the channel. * * This function is used when initializing channel-info structs. @@ -1888,48 +1888,48 @@ static void il3945_bg_reg_txpower_periodic(struct work_struct *work) * on A-band, EEPROM's "group frequency" entries represent the top * channel in each group 1-4. Group 5 All B/G channels are in group 0. */ -static u16 il3945_hw_reg_get_ch_grp_index(struct il_priv *il, +static u16 il3945_hw_reg_get_ch_grp_idx(struct il_priv *il, const struct il_channel_info *ch_info) { struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; struct il3945_eeprom_txpower_group *ch_grp = &eeprom->groups[0]; u8 group; - u16 group_index = 0; /* based on factory calib frequencies */ + u16 group_idx = 0; /* based on factory calib frequencies */ u8 grp_channel; - /* Find the group index for the channel ... don't use index 1(?) */ + /* Find the group idx for the channel ... don't use idx 1(?) */ if (il_is_channel_a_band(ch_info)) { for (group = 1; group < 5; group++) { grp_channel = ch_grp[group].group_channel; if (ch_info->channel <= grp_channel) { - group_index = group; + group_idx = group; break; } } /* group 4 has a few channels *above* its factory cal freq */ if (group == 5) - group_index = 4; + group_idx = 4; } else - group_index = 0; /* 2.4 GHz, group 0 */ + group_idx = 0; /* 2.4 GHz, group 0 */ D_POWER("Chnl %d mapped to grp %d\n", ch_info->channel, - group_index); - return group_index; + group_idx); + return group_idx; } /** - * il3945_hw_reg_get_matched_power_index - Interpolate to get nominal index + * il3945_hw_reg_get_matched_power_idx - Interpolate to get nominal idx * - * Interpolate to get nominal (i.e. at factory calibration temperature) index + * Interpolate to get nominal (i.e. at factory calibration temperature) idx * into radio/DSP gain settings table for requested power. */ -static int il3945_hw_reg_get_matched_power_index(struct il_priv *il, +static int il3945_hw_reg_get_matched_power_idx(struct il_priv *il, s8 requested_power, - s32 setting_index, s32 *new_index) + s32 setting_idx, s32 *new_idx) { const struct il3945_eeprom_txpower_group *chnl_grp = NULL; struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - s32 index0, index1; + s32 idx0, idx1; s32 power = 2 * requested_power; s32 i; const struct il3945_eeprom_txpower_sample *samples; @@ -1937,45 +1937,45 @@ static int il3945_hw_reg_get_matched_power_index(struct il_priv *il, s32 res; s32 denominator; - chnl_grp = &eeprom->groups[setting_index]; + chnl_grp = &eeprom->groups[setting_idx]; samples = chnl_grp->samples; for (i = 0; i < 5; i++) { if (power == samples[i].power) { - *new_index = samples[i].gain_index; + *new_idx = samples[i].gain_idx; return 0; } } if (power > samples[1].power) { - index0 = 0; - index1 = 1; + idx0 = 0; + idx1 = 1; } else if (power > samples[2].power) { - index0 = 1; - index1 = 2; + idx0 = 1; + idx1 = 2; } else if (power > samples[3].power) { - index0 = 2; - index1 = 3; + idx0 = 2; + idx1 = 3; } else { - index0 = 3; - index1 = 4; + idx0 = 3; + idx1 = 4; } - denominator = (s32) samples[index1].power - (s32) samples[index0].power; + denominator = (s32) samples[idx1].power - (s32) samples[idx0].power; if (denominator == 0) return -EINVAL; - gains0 = (s32) samples[index0].gain_index * (1 << 19); - gains1 = (s32) samples[index1].gain_index * (1 << 19); + gains0 = (s32) samples[idx0].gain_idx * (1 << 19); + gains1 = (s32) samples[idx1].gain_idx * (1 << 19); res = gains0 + (gains1 - gains0) * - ((s32) power - (s32) samples[index0].power) / denominator + + ((s32) power - (s32) samples[idx0].power) / denominator + (1 << 18); - *new_index = res >> 19; + *new_idx = res >> 19; return 0; } static void il3945_hw_reg_init_channel_groups(struct il_priv *il) { u32 i; - s32 rate_index; + s32 rate_idx; struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; const struct il3945_eeprom_txpower_group *group; @@ -2009,9 +2009,9 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *il) satur_pwr = (s8) (group->saturation_power >> 1); /* fill in channel group's nominal powers for each rate */ - for (rate_index = 0; - rate_index < RATE_COUNT_3945; rate_index++, clip_pwrs++) { - switch (rate_index) { + for (rate_idx = 0; + rate_idx < RATE_COUNT_3945; rate_idx++, clip_pwrs++) { + switch (rate_idx) { case RATE_36M_IDX_TABLE: if (i == 0) /* B/G */ *clip_pwrs = satur_pwr; @@ -2058,13 +2058,13 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) struct il_channel_info *ch_info = NULL; struct il3945_channel_power_info *pwr_info; struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - int delta_index; - u8 rate_index; - u8 scan_tbl_index; + int delta_idx; + u8 rate_idx; + u8 scan_tbl_idx; const s8 *clip_pwrs; /* array of power levels for each rate */ u8 gain, dsp_atten; s8 power; - u8 pwr_index, base_pwr_index, a_band; + u8 pwr_idx, base_pwr_idx, a_band; u8 i; int temperature; @@ -2082,56 +2082,56 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) if (!il_is_channel_valid(ch_info)) continue; - /* find this channel's channel group (*not* "band") index */ - ch_info->group_index = - il3945_hw_reg_get_ch_grp_index(il, ch_info); + /* find this channel's channel group (*not* "band") idx */ + ch_info->group_idx = + il3945_hw_reg_get_ch_grp_idx(il, ch_info); /* Get this chnlgrp's rate->max/clip-powers table */ - clip_pwrs = il->_3945.clip_groups[ch_info->group_index].clip_powers; + clip_pwrs = il->_3945.clip_groups[ch_info->group_idx].clip_powers; - /* calculate power index *adjustment* value according to + /* calculate power idx *adjustment* value according to * diff between current temperature and factory temperature */ - delta_index = il3945_hw_reg_adjust_power_by_temp(temperature, - eeprom->groups[ch_info->group_index]. + delta_idx = il3945_hw_reg_adjust_power_by_temp(temperature, + eeprom->groups[ch_info->group_idx]. temperature); - D_POWER("Delta index for channel %d: %d [%d]\n", - ch_info->channel, delta_index, temperature + + D_POWER("Delta idx for channel %d: %d [%d]\n", + ch_info->channel, delta_idx, temperature + IL_TEMP_CONVERT); /* set tx power value for all OFDM rates */ - for (rate_index = 0; rate_index < IL_OFDM_RATES; - rate_index++) { + for (rate_idx = 0; rate_idx < IL_OFDM_RATES; + rate_idx++) { s32 uninitialized_var(power_idx); int rc; /* use channel group's clip-power table, * but don't exceed channel's max power */ s8 pwr = min(ch_info->max_power_avg, - clip_pwrs[rate_index]); + clip_pwrs[rate_idx]); - pwr_info = &ch_info->power_info[rate_index]; + pwr_info = &ch_info->power_info[rate_idx]; /* get base (i.e. at factory-measured temperature) - * power table index for this rate's power */ - rc = il3945_hw_reg_get_matched_power_index(il, pwr, - ch_info->group_index, + * power table idx for this rate's power */ + rc = il3945_hw_reg_get_matched_power_idx(il, pwr, + ch_info->group_idx, &power_idx); if (rc) { - IL_ERR("Invalid power index\n"); + IL_ERR("Invalid power idx\n"); return rc; } - pwr_info->base_power_index = (u8) power_idx; + pwr_info->base_power_idx = (u8) power_idx; /* temperature compensate */ - power_idx += delta_index; + power_idx += delta_idx; /* stay within range of gain table */ - power_idx = il3945_hw_reg_fix_power_index(power_idx); + power_idx = il3945_hw_reg_fix_power_idx(power_idx); /* fill 1 OFDM rate's il3945_channel_power_info struct */ pwr_info->requested_power = pwr; - pwr_info->power_table_index = (u8) power_idx; + pwr_info->power_table_idx = (u8) power_idx; pwr_info->tpc.tx_gain = power_gain_table[a_band][power_idx].tx_gain; pwr_info->tpc.dsp_atten = @@ -2142,36 +2142,36 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) pwr_info = &ch_info->power_info[RATE_12M_IDX_TABLE]; power = pwr_info->requested_power + IL_CCK_FROM_OFDM_POWER_DIFF; - pwr_index = pwr_info->power_table_index + + pwr_idx = pwr_info->power_table_idx + IL_CCK_FROM_OFDM_IDX_DIFF; - base_pwr_index = pwr_info->base_power_index + + base_pwr_idx = pwr_info->base_power_idx + IL_CCK_FROM_OFDM_IDX_DIFF; /* stay within table range */ - pwr_index = il3945_hw_reg_fix_power_index(pwr_index); - gain = power_gain_table[a_band][pwr_index].tx_gain; - dsp_atten = power_gain_table[a_band][pwr_index].dsp_atten; + pwr_idx = il3945_hw_reg_fix_power_idx(pwr_idx); + gain = power_gain_table[a_band][pwr_idx].tx_gain; + dsp_atten = power_gain_table[a_band][pwr_idx].dsp_atten; /* fill each CCK rate's il3945_channel_power_info structure * NOTE: All CCK-rate Txpwrs are the same for a given chnl! * NOTE: CCK rates start at end of OFDM rates! */ - for (rate_index = 0; - rate_index < IL_CCK_RATES; rate_index++) { - pwr_info = &ch_info->power_info[rate_index+IL_OFDM_RATES]; + for (rate_idx = 0; + rate_idx < IL_CCK_RATES; rate_idx++) { + pwr_info = &ch_info->power_info[rate_idx+IL_OFDM_RATES]; pwr_info->requested_power = power; - pwr_info->power_table_index = pwr_index; - pwr_info->base_power_index = base_pwr_index; + pwr_info->power_table_idx = pwr_idx; + pwr_info->base_power_idx = base_pwr_idx; pwr_info->tpc.tx_gain = gain; pwr_info->tpc.dsp_atten = dsp_atten; } /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */ - for (scan_tbl_index = 0; - scan_tbl_index < IL_NUM_SCAN_RATES; scan_tbl_index++) { - s32 actual_index = (scan_tbl_index == 0) ? + for (scan_tbl_idx = 0; + scan_tbl_idx < IL_NUM_SCAN_RATES; scan_tbl_idx++) { + s32 actual_idx = (scan_tbl_idx == 0) ? RATE_1M_IDX_TABLE : RATE_6M_IDX_TABLE; - il3945_hw_reg_set_scan_power(il, scan_tbl_index, - actual_index, clip_pwrs, ch_info, a_band); + il3945_hw_reg_set_scan_power(il, scan_tbl_idx, + actual_idx, clip_pwrs, ch_info, a_band); } } @@ -2304,21 +2304,21 @@ static int il3945_manage_ibss_station(struct il_priv *il, */ int il3945_init_hw_rate_table(struct il_priv *il) { - int rc, i, index, prev_index; + int rc, i, idx, prev_idx; struct il3945_rate_scaling_cmd rate_cmd = { .reserved = {0, 0, 0}, }; struct il3945_rate_scaling_info *table = rate_cmd.table; for (i = 0; i < ARRAY_SIZE(il3945_rates); i++) { - index = il3945_rates[i].table_rs_index; + idx = il3945_rates[i].table_rs_idx; - table[index].rate_n_flags = + table[idx].rate_n_flags = il3945_hw_set_rate_n_flags(il3945_rates[i].plcp, 0); - table[index].try_cnt = il->retry_rate; - prev_index = il3945_get_prev_ieee_rate(i); - table[index].next_rate_index = - il3945_rates[prev_index].table_rs_index; + table[idx].try_cnt = il->retry_rate; + prev_idx = il3945_get_prev_ieee_rate(i); + table[idx].next_rate_idx = + il3945_rates[prev_idx].table_rs_idx; } switch (il->band) { @@ -2328,16 +2328,16 @@ int il3945_init_hw_rate_table(struct il_priv *il) * have it fall back to the 6M OFDM rate */ for (i = RATE_1M_IDX_TABLE; i <= RATE_11M_IDX_TABLE; i++) - table[i].next_rate_index = - il3945_rates[IL_FIRST_OFDM_RATE].table_rs_index; + table[i].next_rate_idx = + il3945_rates[IL_FIRST_OFDM_RATE].table_rs_idx; /* Don't fall back to CCK rates */ - table[RATE_12M_IDX_TABLE].next_rate_index = + table[RATE_12M_IDX_TABLE].next_rate_idx = RATE_9M_IDX_TABLE; /* Don't drop out of OFDM rates */ - table[RATE_6M_IDX_TABLE].next_rate_index = - il3945_rates[IL_FIRST_OFDM_RATE].table_rs_index; + table[RATE_6M_IDX_TABLE].next_rate_idx = + il3945_rates[IL_FIRST_OFDM_RATE].table_rs_idx; break; case IEEE80211_BAND_2GHZ: @@ -2348,15 +2348,15 @@ int il3945_init_hw_rate_table(struct il_priv *il) if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && il_is_associated(il)) { - index = IL_FIRST_CCK_RATE; + idx = IL_FIRST_CCK_RATE; for (i = RATE_6M_IDX_TABLE; i <= RATE_54M_IDX_TABLE; i++) - table[i].next_rate_index = - il3945_rates[index].table_rs_index; + table[i].next_rate_idx = + il3945_rates[idx].table_rs_idx; - index = RATE_11M_IDX_TABLE; + idx = RATE_11M_IDX_TABLE; /* CCK shouldn't fall back to OFDM... */ - table[index].next_rate_index = RATE_5M_IDX_TABLE; + table[idx].next_rate_idx = RATE_5M_IDX_TABLE; } break; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h index 2c1b000e2369..5c8b8baa3b15 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h @@ -203,7 +203,7 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * 1) Compare desired txpower vs. (EEPROM) regulatory limit for this channel. * Do not exceed regulatory limit; reduce target txpower if necessary. * - * If setting up txpowers for MIMO rates (rate indexes 8-15, 24-31), + * If setting up txpowers for MIMO rates (rate idxes 8-15, 24-31), * 2 transmitters will be used simultaneously; driver must reduce the * regulatory limit by 3 dB (half-power) for each transmitter, so the * combined total output of the 2 transmitters is within regulatory limits. @@ -269,7 +269,7 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * be used (although only one at a time) even for non-MIMO transmissions. * * Driver should interpolate factory values for temperature, gain table - * index, and actual power. The power amplifier detector values are + * idx, and actual power. The power amplifier detector values are * not used by the driver. * * Sanity check: If the target channel happens to be one of the sample @@ -278,13 +278,13 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * * * 5) Find difference between desired txpower and (interpolated) - * factory-measured txpower. Using (interpolated) factory gain table index - * (shown elsewhere) as a starting point, adjust this index lower to + * factory-measured txpower. Using (interpolated) factory gain table idx + * (shown elsewhere) as a starting point, adjust this idx lower to * increase txpower, or higher to decrease txpower, until the target * txpower is reached. Each step in the gain table is 1/2 dB. * * For example, if factory measured txpower is 16 dBm, and target txpower - * is 13 dBm, add 6 steps to the factory gain index to reduce txpower + * is 13 dBm, add 6 steps to the factory gain idx to reduce txpower * by 3 dB. * * @@ -294,7 +294,7 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * "4965 temperature calculation". * * If current temperature is higher than factory temperature, driver must - * increase gain (lower gain table index), and vice verse. + * increase gain (lower gain table idx), and vice verse. * * Temperature affects gain differently for different channels: * @@ -313,16 +313,16 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * indicator (EEPROM). * * If the current voltage is higher (indicator is lower) than factory - * voltage, gain should be reduced (gain table index increased) by: + * voltage, gain should be reduced (gain table idx increased) by: * * (eeprom - current) / 7 * * If the current voltage is lower (indicator is higher) than factory - * voltage, gain should be increased (gain table index decreased) by: + * voltage, gain should be increased (gain table idx decreased) by: * * 2 * (current - eeprom) / 7 * - * If number of index steps in either direction turns out to be > 2, + * If number of idx steps in either direction turns out to be > 2, * something is wrong ... just use 0. * * NOTE: Voltage compensation is independent of band/channel. @@ -333,7 +333,7 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * may be calculated once and used until the next uCode bootload. * * - * 8) If setting up txpowers for MIMO rates (rate indexes 8-15, 24-31), + * 8) If setting up txpowers for MIMO rates (rate idxes 8-15, 24-31), * adjust txpower for each transmitter chain, so txpower is balanced * between the two chains. There are 5 pairs of tx_atten[group][chain] * values in "initialize alive", one pair for each of 5 channel ranges: @@ -344,7 +344,7 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * Group 3: 5 GHz channel 125-200 * Group 4: 2.4 GHz all channels * - * Add the tx_atten[group][chain] value to the index for the target chain. + * Add the tx_atten[group][chain] value to the idx for the target chain. * The values are signed, but are in pairs of 0 and a non-negative number, * so as to reduce gain (if necessary) of the "hotter" channel. This * avoids any need to double-check for regulatory compliance after @@ -352,7 +352,7 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * * * 9) If setting up for a CCK rate, lower the gain by adding a CCK compensation - * value to the index: + * value to the idx: * * Hardware rev B: 9 steps (4.5 dB) * Hardware rev C: 5 steps (2.5 dB) @@ -366,7 +366,7 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * * 10) Select the gain table, based on band (2.4 vs 5 GHz). * - * Limit the adjusted index to stay within the table! + * Limit the adjusted idx to stay within the table! * * * 11) Read gain table entries for DSP and radio gain, place into appropriate @@ -389,7 +389,7 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * * When calculating txpowers for CCK, after making sure that the target power * is within regulatory and saturation limits, driver must additionally - * back off gain by adding these values to the gain table index. + * back off gain by adding these values to the gain table idx. * * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG, * bits [3:2], 1 = B, 2 = C. @@ -428,9 +428,9 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * driver work with the same table). * * There are separate tables for 2.4 GHz and 5 GHz bands. The 5 GHz table - * has an extension (into negative indexes), in case the driver needs to + * has an extension (into negative idxes), in case the driver needs to * boost power setting for high device temperatures (higher than would be - * present during factory calibration). A 5 Ghz EEPROM index of "40" + * present during factory calibration). A 5 Ghz EEPROM idx of "40" * corresponds to the 49th entry in the table used by the driver. */ #define MIN_TX_GAIN_IDX (0) /* highest gain, lowest idx, 2.4 */ @@ -778,8 +778,8 @@ enum { * * When driver sets up a new TFD, it must also enter the total byte count * of the frame to be transmitted into the corresponding entry in the byte - * count table for the chosen Tx queue. If the TFD index is 0-63, the driver - * must duplicate the byte count entry in corresponding index 256-319. + * count table for the chosen Tx queue. If the TFD idx is 0-63, the driver + * must duplicate the byte count entry in corresponding idx 256-319. * * padding puts each byte count table on a 1024-byte boundary; * 4965 assumes tables are separated by 1024 bytes. diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c index ee04977c0113..bbec6bd550d3 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c @@ -105,7 +105,7 @@ int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) /* Stop Rx DMA */ il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); - /* Reset driver's Rx queue write index */ + /* Reset driver's Rx queue write idx */ il_wr(il, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); /* Tell device where to find RBD circular buffer in DRAM */ @@ -222,7 +222,7 @@ static inline __le32 il4965_dma_addr2rbd_ptr(struct il_priv *il, * and we have free pre-allocated buffers, fill the ranks as much * as we can, pulling from rx_free. * - * This moves the 'write' index forward to catch up with 'processed', and + * This moves the 'write' idx forward to catch up with 'processed', and * also updates the memory address in the firmware to reference the new * target buffer. */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index 7478e9167e73..b8f80641f788 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -151,10 +151,10 @@ static void il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, #ifdef CONFIG_MAC80211_DEBUGFS static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, - u32 *rate_n_flags, int index); + u32 *rate_n_flags, int idx); #else static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, - u32 *rate_n_flags, int index) + u32 *rate_n_flags, int idx) {} #endif @@ -271,7 +271,7 @@ static u8 il4965_rs_tl_add_packet(struct il_lq_sta *lq_data, { u32 curr_time = jiffies_to_msecs(jiffies); u32 time_diff; - s32 index; + s32 idx; struct il_traffic_load *tl = NULL; u8 tid; @@ -299,19 +299,19 @@ static u8 il4965_rs_tl_add_packet(struct il_lq_sta *lq_data, } time_diff = TIME_WRAP_AROUND(tl->time_stamp, curr_time); - index = time_diff / TID_QUEUE_CELL_SPACING; + idx = time_diff / TID_QUEUE_CELL_SPACING; /* The history is too long: remove data that is older than */ /* TID_MAX_TIME_DIFF */ - if (index >= TID_QUEUE_MAX_SIZE) + if (idx >= TID_QUEUE_MAX_SIZE) il4965_rs_tl_rm_old_stats(tl, curr_time); - index = (tl->head + index) % TID_QUEUE_MAX_SIZE; - tl->packet_count[index] = tl->packet_count[index] + 1; + idx = (tl->head + idx) % TID_QUEUE_MAX_SIZE; + tl->packet_count[idx] = tl->packet_count[idx] + 1; tl->total = tl->total + 1; - if ((index + 1) > tl->queue_count) - tl->queue_count = index + 1; + if ((idx + 1) > tl->queue_count) + tl->queue_count = idx + 1; return tid; } @@ -323,7 +323,7 @@ static u32 il4965_rs_tl_get_load(struct il_lq_sta *lq_data, u8 tid) { u32 curr_time = jiffies_to_msecs(jiffies); u32 time_diff; - s32 index; + s32 idx; struct il_traffic_load *tl = NULL; if (tid >= TID_MAX_LOAD_COUNT) @@ -337,11 +337,11 @@ static u32 il4965_rs_tl_get_load(struct il_lq_sta *lq_data, u8 tid) return 0; time_diff = TIME_WRAP_AROUND(tl->time_stamp, curr_time); - index = time_diff / TID_QUEUE_CELL_SPACING; + idx = time_diff / TID_QUEUE_CELL_SPACING; /* The history is too long: remove data that is older than */ /* TID_MAX_TIME_DIFF */ - if (index >= TID_QUEUE_MAX_SIZE) + if (idx >= TID_QUEUE_MAX_SIZE) il4965_rs_tl_rm_old_stats(tl, curr_time); return tl->total; @@ -400,10 +400,10 @@ static inline int il4965_get_il4965_num_of_ant_from_rate(u32 rate_n_flags) * that wraps a NULL pointer check */ static s32 -il4965_get_expected_tpt(struct il_scale_tbl_info *tbl, int rs_index) +il4965_get_expected_tpt(struct il_scale_tbl_info *tbl, int rs_idx) { if (tbl->expected_tpt) - return tbl->expected_tpt[rs_index]; + return tbl->expected_tpt[rs_idx]; return 0; } @@ -415,20 +415,20 @@ il4965_get_expected_tpt(struct il_scale_tbl_info *tbl, int rs_index) * packets. */ static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, - int scale_index, int attempts, int successes) + int scale_idx, int attempts, int successes) { struct il_rate_scale_data *win = NULL; static const u64 mask = (((u64)1) << (RATE_MAX_WINDOW - 1)); s32 fail_count, tpt; - if (scale_index < 0 || scale_index >= RATE_COUNT) + if (scale_idx < 0 || scale_idx >= RATE_COUNT) return -EINVAL; /* Select win for current tx bit rate */ - win = &(tbl->win[scale_index]); + win = &(tbl->win[scale_idx]); /* Get expected throughput */ - tpt = il4965_get_expected_tpt(tbl, scale_index); + tpt = il4965_get_expected_tpt(tbl, scale_idx); /* * Keep track of only the latest 62 tx frame attempts in this rate's @@ -493,26 +493,26 @@ static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, */ static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, struct il_scale_tbl_info *tbl, - int index, u8 use_green) + int idx, u8 use_green) { u32 rate_n_flags = 0; if (is_legacy(tbl->lq_type)) { - rate_n_flags = il_rates[index].plcp; - if (index >= IL_FIRST_CCK_RATE && index <= IL_LAST_CCK_RATE) + rate_n_flags = il_rates[idx].plcp; + if (idx >= IL_FIRST_CCK_RATE && idx <= IL_LAST_CCK_RATE) rate_n_flags |= RATE_MCS_CCK_MSK; } else if (is_Ht(tbl->lq_type)) { - if (index > IL_LAST_OFDM_RATE) { - IL_ERR("Invalid HT rate index %d\n", index); - index = IL_LAST_OFDM_RATE; + if (idx > IL_LAST_OFDM_RATE) { + IL_ERR("Invalid HT rate idx %d\n", idx); + idx = IL_LAST_OFDM_RATE; } rate_n_flags = RATE_MCS_HT_MSK; if (is_siso(tbl->lq_type)) - rate_n_flags |= il_rates[index].plcp_siso; + rate_n_flags |= il_rates[idx].plcp_siso; else - rate_n_flags |= il_rates[index].plcp_mimo2; + rate_n_flags |= il_rates[idx].plcp_mimo2; } else { IL_ERR("Invalid tbl->lq_type %d\n", tbl->lq_type); } @@ -666,7 +666,7 @@ static u16 il4965_rs_get_supported_rates(struct il_lq_sta *lq_sta, } static u16 -il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, +il4965_rs_get_adjacent_rate(struct il_priv *il, u8 idx, u16 rate_mask, int rate_type) { u8 high = RATE_INVALID; @@ -679,7 +679,7 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, u32 mask; /* Find the previous rate that is in the rate mask */ - i = index - 1; + i = idx - 1; for (mask = (1 << i); i >= 0; i--, mask >>= 1) { if (rate_mask & mask) { low = i; @@ -688,7 +688,7 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, } /* Find the next rate that is in the rate mask */ - i = index + 1; + i = idx + 1; for (mask = (1 << i); i < RATE_COUNT; i++, mask <<= 1) { if (rate_mask & mask) { high = i; @@ -699,7 +699,7 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, return (high << 8) | low; } - low = index; + low = idx; while (low != RATE_INVALID) { low = il_rates[low].prev_rs; if (low == RATE_INVALID) @@ -709,7 +709,7 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, D_RATE("Skipping masked lower rate: %d\n", low); } - high = index; + high = idx; while (high != RATE_INVALID) { high = il_rates[high].next_rs; if (high == RATE_INVALID) @@ -724,7 +724,7 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 index, u16 rate_mask, static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, struct il_scale_tbl_info *tbl, - u8 scale_index, u8 ht_possible) + u8 scale_idx, u8 ht_possible) { s32 low; u16 rate_mask; @@ -736,9 +736,9 @@ static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, /* check if we need to switch from HT to legacy rates. * assumption is that mandatory rates (1Mbps or 6Mbps) * are always supported (spec demand) */ - if (!is_legacy(tbl->lq_type) && (!ht_possible || !scale_index)) { + if (!is_legacy(tbl->lq_type) && (!ht_possible || !scale_idx)) { switch_to_legacy = 1; - scale_index = rs_ht_to_legacy[scale_index]; + scale_idx = rs_ht_to_legacy[scale_idx]; if (lq_sta->band == IEEE80211_BAND_5GHZ) tbl->lq_type = LQ_A; else @@ -766,18 +766,18 @@ static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, } /* If we switched from HT to legacy, check current rate */ - if (switch_to_legacy && (rate_mask & (1 << scale_index))) { - low = scale_index; + if (switch_to_legacy && (rate_mask & (1 << scale_idx))) { + low = scale_idx; goto out; } high_low = il4965_rs_get_adjacent_rate(lq_sta->drv, - scale_index, rate_mask, + scale_idx, rate_mask, tbl->lq_type); low = high_low & 0xff; if (low == RATE_INVALID) - low = scale_index; + low = scale_idx; out: return il4965_rate_n_flags_from_tbl(lq_sta->drv, tbl, low, is_green); @@ -803,7 +803,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, { int legacy_success; int retries; - int rs_index, mac_index, i; + int rs_idx, mac_idx, i; struct il_lq_sta *lq_sta = il_sta; struct il_link_quality_cmd *table; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; @@ -848,35 +848,35 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, table = &lq_sta->lq; tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); il4965_rs_get_tbl_info_from_mcs(tx_rate, - il->band, &tbl_type, &rs_index); + il->band, &tbl_type, &rs_idx); if (il->band == IEEE80211_BAND_5GHZ) - rs_index -= IL_FIRST_OFDM_RATE; + rs_idx -= IL_FIRST_OFDM_RATE; mac_flags = info->status.rates[0].flags; - mac_index = info->status.rates[0].idx; + mac_idx = info->status.rates[0].idx; /* For HT packets, map MCS to PLCP */ if (mac_flags & IEEE80211_TX_RC_MCS) { - mac_index &= RATE_MCS_CODE_MSK; /* Remove # of streams */ - if (mac_index >= (RATE_9M_IDX - IL_FIRST_OFDM_RATE)) - mac_index++; + mac_idx &= RATE_MCS_CODE_MSK; /* Remove # of streams */ + if (mac_idx >= (RATE_9M_IDX - IL_FIRST_OFDM_RATE)) + mac_idx++; /* - * mac80211 HT index is always zero-indexed; we need to move + * mac80211 HT idx is always zero-idxed; we need to move * HT OFDM rates after CCK rates in 2.4 GHz band */ if (il->band == IEEE80211_BAND_2GHZ) - mac_index += IL_FIRST_OFDM_RATE; + mac_idx += IL_FIRST_OFDM_RATE; } /* Here we actually compare this rate to the latest LQ command */ - if (mac_index < 0 || + if (mac_idx < 0 || tbl_type.is_SGI != !!(mac_flags & IEEE80211_TX_RC_SHORT_GI) || tbl_type.is_ht40 != !!(mac_flags & IEEE80211_TX_RC_40_MHZ_WIDTH) || tbl_type.is_dup != !!(mac_flags & IEEE80211_TX_RC_DUP_DATA) || tbl_type.ant_type != info->antenna_sel_tx || !!(tx_rate & RATE_MCS_HT_MSK) != !!(mac_flags & IEEE80211_TX_RC_MCS) || !!(tx_rate & RATE_MCS_GF_MSK) != !!(mac_flags & IEEE80211_TX_RC_GREEN_FIELD) || - rs_index != mac_index) { + rs_idx != mac_idx) { D_RATE( "initial rate %d does not match %d (0x%x)\n", - mac_index, rs_index, tx_rate); + mac_idx, rs_idx, tx_rate); /* * Since rates mis-match, the last LQ command may have failed. * After IL_MISSED_RATE_MAX mis-matches, resync the uCode with @@ -927,13 +927,13 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, * aggregated. * * For aggregation, all packets were transmitted at the same rate, the - * first index into rate scale table. + * first idx into rate scale table. */ if (info->flags & IEEE80211_TX_STAT_AMPDU) { tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, &tbl_type, - &rs_index); - il4965_rs_collect_tx_data(curr_tbl, rs_index, + &rs_idx); + il4965_rs_collect_tx_data(curr_tbl, rs_idx, info->status.ampdu_len, info->status.ampdu_ack_len); @@ -957,7 +957,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, for (i = 0; i <= retries; ++i) { tx_rate = le32_to_cpu(table->rs_table[i].rate_n_flags); il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, - &tbl_type, &rs_index); + &tbl_type, &rs_idx); /* * Only collect stats if retried rate is in the same RS * table as active/search. @@ -969,7 +969,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, tmp_tbl = other_tbl; else continue; - il4965_rs_collect_tx_data(tmp_tbl, rs_index, 1, + il4965_rs_collect_tx_data(tmp_tbl, rs_idx, 1, i < retries ? 0 : legacy_success); } @@ -1074,20 +1074,20 @@ static void il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, static s32 il4965_rs_get_best_rate(struct il_priv *il, struct il_lq_sta *lq_sta, struct il_scale_tbl_info *tbl, /* "search" */ - u16 rate_mask, s8 index) + u16 rate_mask, s8 idx) { /* "active" values */ struct il_scale_tbl_info *active_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - s32 active_sr = active_tbl->win[index].success_ratio; - s32 active_tpt = active_tbl->expected_tpt[index]; + s32 active_sr = active_tbl->win[idx].success_ratio; + s32 active_tpt = active_tbl->expected_tpt[idx]; /* expected "search" throughput */ s32 *tpt_tbl = tbl->expected_tpt; s32 new_rate, high, low, start_hi; u16 high_low; - s8 rate = index; + s8 rate = idx; new_rate = high = low = start_hi = RATE_INVALID; @@ -1169,7 +1169,7 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *il, struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, - struct il_scale_tbl_info *tbl, int index) + struct il_scale_tbl_info *tbl, int idx) { u16 rate_mask; s32 rate; @@ -1203,20 +1203,20 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *il, il4965_rs_set_expected_tpt_table(lq_sta, tbl); - rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, index); + rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, idx); D_RATE("LQ: MIMO2 best rate %d mask %X\n", rate, rate_mask); if (rate == RATE_INVALID || !((1 << rate) & rate_mask)) { D_RATE( - "Can't switch with index %d rate mask %x\n", + "Can't switch with idx %d rate mask %x\n", rate, rate_mask); return -1; } tbl->current_rate = il4965_rate_n_flags_from_tbl(il, tbl, rate, is_green); - D_RATE("LQ: Switch to new mcs %X index is green %X\n", + D_RATE("LQ: Switch to new mcs %X idx is green %X\n", tbl->current_rate, is_green); return 0; } @@ -1228,7 +1228,7 @@ static int il4965_rs_switch_to_siso(struct il_priv *il, struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, - struct il_scale_tbl_info *tbl, int index) + struct il_scale_tbl_info *tbl, int idx) { u16 rate_mask; u8 is_green = lq_sta->is_green; @@ -1256,18 +1256,18 @@ static int il4965_rs_switch_to_siso(struct il_priv *il, tbl->is_SGI = 0; /*11n spec: no SGI in SISO+Greenfield*/ il4965_rs_set_expected_tpt_table(lq_sta, tbl); - rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, index); + rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, idx); D_RATE("LQ: get best rate %d mask %X\n", rate, rate_mask); if (rate == RATE_INVALID || !((1 << rate) & rate_mask)) { D_RATE( - "can not switch with index %d rate mask %x\n", + "can not switch with idx %d rate mask %x\n", rate, rate_mask); return -1; } tbl->current_rate = il4965_rate_n_flags_from_tbl(il, tbl, rate, is_green); - D_RATE("LQ: Switch to new mcs %X index is green %X\n", + D_RATE("LQ: Switch to new mcs %X idx is green %X\n", tbl->current_rate, is_green); return 0; } @@ -1279,12 +1279,12 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, struct ieee80211_sta *sta, - int index) + int idx) { struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); struct il_scale_tbl_info *search_tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - struct il_rate_scale_data *win = &(tbl->win[index]); + struct il_rate_scale_data *win = &(tbl->win[idx]); u32 sz = (sizeof(struct il_scale_tbl_info) - (sizeof(struct il_rate_scale_data) * RATE_COUNT)); u8 start_action; @@ -1331,7 +1331,7 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, memcpy(search_tbl, tbl, sz); search_tbl->is_SGI = 0; ret = il4965_rs_switch_to_siso(il, lq_sta, conf, sta, - search_tbl, index); + search_tbl, idx); if (!ret) { lq_sta->action_counter = 0; goto out; @@ -1360,7 +1360,7 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, ret = il4965_rs_switch_to_mimo2(il, lq_sta, conf, sta, - search_tbl, index); + search_tbl, idx); if (!ret) { lq_sta->action_counter = 0; goto out; @@ -1395,13 +1395,13 @@ out: static int il4965_rs_move_siso_to_other(struct il_priv *il, struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, - struct ieee80211_sta *sta, int index) + struct ieee80211_sta *sta, int idx) { u8 is_green = lq_sta->is_green; struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); struct il_scale_tbl_info *search_tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - struct il_rate_scale_data *win = &(tbl->win[index]); + struct il_rate_scale_data *win = &(tbl->win[idx]); struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; u32 sz = (sizeof(struct il_scale_tbl_info) - (sizeof(struct il_rate_scale_data) * RATE_COUNT)); @@ -1455,7 +1455,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, ret = il4965_rs_switch_to_mimo2(il, lq_sta, conf, sta, - search_tbl, index); + search_tbl, idx); if (!ret) goto out; break; @@ -1481,12 +1481,12 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, il4965_rs_set_expected_tpt_table(lq_sta, search_tbl); if (tbl->is_SGI) { s32 tpt = lq_sta->last_tpt / 100; - if (tpt >= search_tbl->expected_tpt[index]) + if (tpt >= search_tbl->expected_tpt[idx]) break; } search_tbl->current_rate = il4965_rate_n_flags_from_tbl(il, search_tbl, - index, is_green); + idx, is_green); update_search_tbl_counter = 1; goto out; } @@ -1517,13 +1517,13 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, static int il4965_rs_move_mimo2_to_other(struct il_priv *il, struct il_lq_sta *lq_sta, struct ieee80211_conf *conf, - struct ieee80211_sta *sta, int index) + struct ieee80211_sta *sta, int idx) { s8 is_green = lq_sta->is_green; struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); struct il_scale_tbl_info *search_tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - struct il_rate_scale_data *win = &(tbl->win[index]); + struct il_rate_scale_data *win = &(tbl->win[idx]); struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; u32 sz = (sizeof(struct il_scale_tbl_info) - (sizeof(struct il_rate_scale_data) * RATE_COUNT)); @@ -1575,7 +1575,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, ret = il4965_rs_switch_to_siso(il, lq_sta, conf, sta, - search_tbl, index); + search_tbl, idx); if (!ret) goto out; @@ -1603,12 +1603,12 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, */ if (tbl->is_SGI) { s32 tpt = lq_sta->last_tpt / 100; - if (tpt >= search_tbl->expected_tpt[index]) + if (tpt >= search_tbl->expected_tpt[idx]) break; } search_tbl->current_rate = il4965_rate_n_flags_from_tbl(il, search_tbl, - index, is_green); + idx, is_green); update_search_tbl_counter = 1; goto out; @@ -1728,12 +1728,12 @@ static u32 il4965_rs_update_rate_tbl(struct il_priv *il, struct il_rxon_context *ctx, struct il_lq_sta *lq_sta, struct il_scale_tbl_info *tbl, - int index, u8 is_green) + int idx, u8 is_green) { u32 rate; /* Update uCode's rate table. */ - rate = il4965_rate_n_flags_from_tbl(il, tbl, index, is_green); + rate = il4965_rate_n_flags_from_tbl(il, tbl, idx, is_green); il4965_rs_fill_link_cmd(il, lq_sta, rate); il_send_lq_cmd(il, ctx, &lq_sta->lq, CMD_ASYNC, false); @@ -1754,7 +1754,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; int low = RATE_INVALID; int high = RATE_INVALID; - int index; + int idx; int i; struct il_rate_scale_data *win = NULL; int current_tpt = IL_INVALID_VALUE; @@ -1765,7 +1765,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, u16 rate_mask; u8 update_lq = 0; struct il_scale_tbl_info *tbl, *tbl1; - u16 rate_scale_index_msk = 0; + u16 rate_scale_idx_msk = 0; u32 rate; u8 is_green = 0; u8 active_tbl = 0; @@ -1818,9 +1818,9 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, is_green = lq_sta->is_green; /* current tx rate */ - index = lq_sta->last_txrate_idx; + idx = lq_sta->last_txrate_idx; - D_RATE("Rate scale index %d for type %d\n", index, + D_RATE("Rate scale idx %d for type %d\n", idx, tbl->lq_type); /* rates available for this association, and for modulation mode */ @@ -1832,19 +1832,19 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, if (is_legacy(tbl->lq_type)) { if (lq_sta->band == IEEE80211_BAND_5GHZ) /* supp_rates has no CCK bits in A mode */ - rate_scale_index_msk = (u16) (rate_mask & + rate_scale_idx_msk = (u16) (rate_mask & (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); else - rate_scale_index_msk = (u16) (rate_mask & + rate_scale_idx_msk = (u16) (rate_mask & lq_sta->supp_rates); } else - rate_scale_index_msk = rate_mask; + rate_scale_idx_msk = rate_mask; - if (!rate_scale_index_msk) - rate_scale_index_msk = rate_mask; + if (!rate_scale_idx_msk) + rate_scale_idx_msk = rate_mask; - if (!((1 << index) & rate_scale_index_msk)) { + if (!((1 << idx) & rate_scale_idx_msk)) { IL_ERR("Current Rate is not valid\n"); if (lq_sta->search_better_tbl) { /* revert to active table if search table is not valid*/ @@ -1852,9 +1852,9 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, lq_sta->search_better_tbl = 0; tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); /* get "active" rate info */ - index = il4965_hwrate_to_plcp_idx(tbl->current_rate); + idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); rate = il4965_rs_update_rate_tbl(il, ctx, lq_sta, - tbl, index, is_green); + tbl, idx, is_green); } return; } @@ -1867,14 +1867,14 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* force user max rate if set by user */ if (lq_sta->max_rate_idx != -1 && - lq_sta->max_rate_idx < index) { - index = lq_sta->max_rate_idx; + lq_sta->max_rate_idx < idx) { + idx = lq_sta->max_rate_idx; update_lq = 1; - win = &(tbl->win[index]); + win = &(tbl->win[idx]); goto lq_update; } - win = &(tbl->win[index]); + win = &(tbl->win[idx]); /* * If there is not enough history to calculate actual average @@ -1887,8 +1887,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, if (fail_count < RATE_MIN_FAILURE_TH && win->success_counter < RATE_MIN_SUCCESS_TH) { D_RATE("LQ: still below TH. succ=%d total=%d " - "for index %d\n", - win->success_counter, win->counter, index); + "for idx %d\n", + win->success_counter, win->counter, idx); /* Can't calculate this yet; not enough history */ win->average_tpt = IL_INVALID_VALUE; @@ -1902,11 +1902,11 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Else we have enough samples; calculate estimate of * actual average throughput */ if (win->average_tpt != ((win->success_ratio * - tbl->expected_tpt[index] + 64) / 128)) { + tbl->expected_tpt[idx] + 64) / 128)) { IL_ERR( "expected_tpt should have been calculated by now\n"); win->average_tpt = ((win->success_ratio * - tbl->expected_tpt[index] + 64) / 128); + tbl->expected_tpt[idx] + 64) / 128); } /* If we are searching for better modulation mode, check success. */ @@ -1946,7 +1946,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, tbl = &(lq_sta->lq_info[active_tbl]); /* Revert to "active" rate and throughput info */ - index = il4965_hwrate_to_plcp_idx(tbl->current_rate); + idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); current_tpt = lq_sta->last_tpt; /* Need to set up a new rate table in uCode */ @@ -1962,8 +1962,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* (Else) not in search of better modulation mode, try for better * starting rate, while staying in this mode. */ - high_low = il4965_rs_get_adjacent_rate(il, index, - rate_scale_index_msk, + high_low = il4965_rs_get_adjacent_rate(il, idx, + rate_scale_idx_msk, tbl->lq_type); low = high_low & 0xff; high = (high_low >> 8) & 0xff; @@ -2043,7 +2043,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Decrease starting rate, update uCode's rate table */ if (low != RATE_INVALID) { update_lq = 1; - index = low; + idx = low; } break; @@ -2051,7 +2051,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Increase starting rate, update uCode's rate table */ if (high != RATE_INVALID) { update_lq = 1; - index = high; + idx = high; } break; @@ -2061,15 +2061,15 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, break; } - D_RATE("choose rate scale index %d action %d low %d " + D_RATE("choose rate scale idx %d action %d low %d " "high %d type %d\n", - index, scale_action, low, high, tbl->lq_type); + idx, scale_action, low, high, tbl->lq_type); lq_update: /* Replace uCode's rate table for the destination station. */ if (update_lq) rate = il4965_rs_update_rate_tbl(il, ctx, lq_sta, - tbl, index, is_green); + tbl, idx, is_green); /* Should we stay with this modulation mode, * or search for a new one? */ @@ -2090,13 +2090,13 @@ lq_update: * If one is found, set up the new "search" table. */ if (is_legacy(tbl->lq_type)) il4965_rs_move_legacy_other(il, lq_sta, - conf, sta, index); + conf, sta, idx); else if (is_siso(tbl->lq_type)) il4965_rs_move_siso_to_other(il, lq_sta, - conf, sta, index); + conf, sta, idx); else /* (is_mimo2(tbl->lq_type)) */ il4965_rs_move_mimo2_to_other(il, lq_sta, - conf, sta, index); + conf, sta, idx); /* If new "search" mode was selected, set up in uCode table */ if (lq_sta->search_better_tbl) { @@ -2107,11 +2107,11 @@ lq_update: &(tbl->win[i])); /* Use new "search" start rate */ - index = il4965_hwrate_to_plcp_idx(tbl->current_rate); + idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); D_RATE( - "Switch current mcs: %X index: %d\n", - tbl->current_rate, index); + "Switch current mcs: %X idx: %d\n", + tbl->current_rate, idx); il4965_rs_fill_link_cmd(il, lq_sta, tbl->current_rate); il_send_lq_cmd(il, ctx, @@ -2157,8 +2157,8 @@ lq_update: out: tbl->current_rate = il4965_rate_n_flags_from_tbl(il, tbl, - index, is_green); - i = index; + idx, is_green); + i = idx; lq_sta->last_txrate_idx = i; } @@ -2272,7 +2272,7 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, if (lq_sta->last_rate_n_flags & RATE_MCS_HT_MSK) { rate_idx -= IL_FIRST_OFDM_RATE; - /* 6M and 9M shared same MCS index */ + /* 6M and 9M shared same MCS idx */ rate_idx = (rate_idx > 0) ? (rate_idx - 1) : 0; if (il4965_rs_extract_rate(lq_sta->last_rate_n_flags) >= RATE_MIMO2_6M_PLCP) @@ -2296,7 +2296,7 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, (sband->band == IEEE80211_BAND_5GHZ && rate_idx < IL_FIRST_OFDM_RATE)) rate_idx = rate_lowest_index(sband, sta); - /* On valid 5 GHz rate, adjust index */ + /* On valid 5 GHz rate, adjust idx */ else if (sband->band == IEEE80211_BAND_5GHZ) rate_idx -= IL_FIRST_OFDM_RATE; info->control.rates[0].flags = 0; @@ -2419,7 +2419,7 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, struct il_lq_sta *lq_sta, u32 new_rate) { struct il_scale_tbl_info tbl_type; - int index = 0; + int idx = 0; int rate_idx; int repeat_rate = 0; u8 ant_toggle_cnt = 0; @@ -2427,8 +2427,8 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, u8 valid_tx_ant = 0; struct il_link_quality_cmd *lq_cmd = &lq_sta->lq; - /* Override starting rate (index 0) if needed for debug purposes */ - il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, index); + /* Override starting rate (idx 0) if needed for debug purposes */ + il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, idx); /* Interpret new_rate (rate_n_flags) */ il4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, @@ -2445,8 +2445,8 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, lq_cmd->general_params.mimo_delimiter = is_mimo(tbl_type.lq_type) ? 1 : 0; - /* Fill 1st table entry (index 0) */ - lq_cmd->rs_table[index].rate_n_flags = cpu_to_le32(new_rate); + /* Fill 1st table entry (idx 0) */ + lq_cmd->rs_table[idx].rate_n_flags = cpu_to_le32(new_rate); if (il4965_num_of_ant(tbl_type.ant_type) == 1) { lq_cmd->general_params.single_stream_ant_msk = @@ -2456,17 +2456,17 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, tbl_type.ant_type; } /* otherwise we don't modify the existing value */ - index++; + idx++; repeat_rate--; if (il) valid_tx_ant = il->hw_params.valid_tx_ant; /* Fill rest of rate table */ - while (index < LINK_QUAL_MAX_RETRY_NUM) { + while (idx < LINK_QUAL_MAX_RETRY_NUM) { /* Repeat initial/next rate. * For legacy IL_NUMBER_TRY == 1, this loop will not execute. * For HT IL_HT_NUMBER_TRY == 3, this executes twice. */ - while (repeat_rate > 0 && index < LINK_QUAL_MAX_RETRY_NUM) { + while (repeat_rate > 0 && idx < LINK_QUAL_MAX_RETRY_NUM) { if (is_legacy(tbl_type.lq_type)) { if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE) ant_toggle_cnt++; @@ -2477,13 +2477,13 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, } /* Override next rate if needed for debug purposes */ - il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, index); + il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, idx); /* Fill next table entry */ - lq_cmd->rs_table[index].rate_n_flags = + lq_cmd->rs_table[idx].rate_n_flags = cpu_to_le32(new_rate); repeat_rate--; - index++; + idx++; } il4965_rs_get_tbl_info_from_mcs(new_rate, @@ -2494,7 +2494,7 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, * If initial rate was MIMO, this will finally end up * as (IL_HT_NUMBER_TRY * 2), after 2nd pass, otherwise 0. */ if (is_mimo(tbl_type.lq_type)) - lq_cmd->general_params.mimo_delimiter = index; + lq_cmd->general_params.mimo_delimiter = idx; /* Get next rate */ new_rate = il4965_rs_get_lower_rate(lq_sta, @@ -2520,12 +2520,12 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, use_ht_possible = 0; /* Override next rate if needed for debug purposes */ - il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, index); + il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, idx); /* Fill next table entry */ - lq_cmd->rs_table[index].rate_n_flags = cpu_to_le32(new_rate); + lq_cmd->rs_table[idx].rate_n_flags = cpu_to_le32(new_rate); - index++; + idx++; repeat_rate--; } @@ -2564,7 +2564,7 @@ static int il4965_open_file_generic(struct inode *inode, struct file *file) return 0; } static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, - u32 *rate_n_flags, int index) + u32 *rate_n_flags, int idx) { struct il_priv *il; u8 valid_tx_ant; @@ -2636,7 +2636,7 @@ static ssize_t il4965_rs_sta_dbgfs_scale_table_read(struct file *file, char *buff; int desc = 0; int i = 0; - int index = 0; + int idx = 0; ssize_t ret; struct il_lq_sta *lq_sta = file->private_data; @@ -2687,25 +2687,25 @@ static ssize_t il4965_rs_sta_dbgfs_scale_table_read(struct file *file, desc += sprintf(buff+desc, "Start idx [0]=0x%x [1]=0x%x [2]=0x%x [3]=0x%x\n", - lq_sta->lq.general_params.start_rate_index[0], - lq_sta->lq.general_params.start_rate_index[1], - lq_sta->lq.general_params.start_rate_index[2], - lq_sta->lq.general_params.start_rate_index[3]); + lq_sta->lq.general_params.start_rate_idx[0], + lq_sta->lq.general_params.start_rate_idx[1], + lq_sta->lq.general_params.start_rate_idx[2], + lq_sta->lq.general_params.start_rate_idx[3]); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { - index = il4965_hwrate_to_plcp_idx( + idx = il4965_hwrate_to_plcp_idx( le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags)); if (is_legacy(tbl->lq_type)) { desc += sprintf(buff+desc, " rate[%d] 0x%X %smbps\n", i, le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags), - il_rate_mcs[index].mbps); + il_rate_mcs[idx].mbps); } else { desc += sprintf(buff+desc, " rate[%d] 0x%X %smbps (%s)\n", i, le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags), - il_rate_mcs[index].mbps, il_rate_mcs[index].mcs); + il_rate_mcs[idx].mbps, il_rate_mcs[idx].mcs); } } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c index c50d63918773..4cda277418f6 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c @@ -157,7 +157,7 @@ static int il4965_static_wepkey_cmd(struct il_priv *il, (sizeof(struct il_wep_key) * WEP_KEYS_MAX)); for (i = 0; i < WEP_KEYS_MAX ; i++) { - wep_cmd->key[i].key_index = i; + wep_cmd->key[i].key_idx = i; if (ctx->wep_keys[i].key_size) { wep_cmd->key[i].key_offset = i; not_empty = 1; @@ -283,7 +283,7 @@ static int il4965_set_wep_dynamic_key_info(struct il_priv *il, if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) il->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_index(il); + il_get_free_ucode_key_idx(il); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ @@ -334,7 +334,7 @@ static int il4965_set_ccmp_dynamic_key_info(struct il_priv *il, if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) il->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_index(il); + il_get_free_ucode_key_idx(il); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ @@ -379,7 +379,7 @@ static int il4965_set_tkip_dynamic_key_info(struct il_priv *il, if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) il->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_index(il); + il_get_free_ucode_key_idx(il); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ @@ -457,9 +457,9 @@ int il4965_remove_dynamic_key(struct il_priv *il, keyconf->keyidx, sta_id); if (keyconf->keyidx != keyidx) { - /* We need to remove a key with index different that the one + /* We need to remove a key with idx different that the one * in the uCode. This means that the key we need to remove has - * been replaced by another one with different index. + * been replaced by another one with different idx. * Don't do anything and return ok */ spin_unlock_irqrestore(&il->sta_lock, flags); @@ -475,7 +475,7 @@ int il4965_remove_dynamic_key(struct il_priv *il, if (!test_and_clear_bit(il->stations[sta_id].sta.key.key_offset, &il->ucode_key_table)) - IL_ERR("index %d not used in uCode key table.\n", + IL_ERR("idx %d not used in uCode key table.\n", il->stations[sta_id].sta.key.key_offset); memset(&il->stations[sta_id].keyinfo, 0, sizeof(struct il_hw_key)); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c index 8f18d36f08ad..a6fa1c2296ac 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c @@ -183,7 +183,7 @@ static void il4965_tx_cmd_build_rate(struct il_priv *il, /* DATA packets will use the uCode station table for rate/antenna * selection */ if (ieee80211_is_data(fc)) { - tx_cmd->initial_rate_index = 0; + tx_cmd->initial_rate_idx = 0; tx_cmd->tx_flags |= TX_CMD_FLG_STA_RATE_MSK; return; } @@ -192,7 +192,7 @@ static void il4965_tx_cmd_build_rate(struct il_priv *il, * If the current TX rate stored in mac80211 has the MCS bit set, it's * not really a TX rate. Thus, we use the lowest supported rate for * this band. Also use the lowest supported rate if the stored rate - * index is invalid. + * idx is invalid. */ rate_idx = info->control.rates[0].idx; if ((info->control.rates[0].flags & IEEE80211_TX_RC_MCS) || @@ -319,7 +319,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) if (!ieee80211_is_data(fc)) sta_id = ctx->bcast_sta_id; else { - /* Find index into station table for destination station */ + /* Find idx into station table for destination station */ sta_id = il_sta_id_or_broadcast(il, ctx, info->control.sta); if (sta_id == IL_INVALID_STATION) { @@ -417,7 +417,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) /* * Set up the Tx-command (not MAC!) header. - * Store the chosen Tx queue and TFD index within the sequence field; + * Store the chosen Tx queue and TFD idx within the sequence field; * after Tx, uCode's Tx response will return this value so driver can * locate the frame within the tx queue and do post-tx processing. */ @@ -513,7 +513,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) pci_dma_sync_single_for_device(il->pci_dev, txcmd_phys, firstlen, PCI_DMA_BIDIRECTIONAL); - /* Tell device the write index *just past* this latest filled TFD */ + /* Tell device the write idx *just past* this latest filled TFD */ q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); il_txq_update_write_ptr(il, txq); spin_unlock_irqrestore(&il->lock, flags); @@ -828,7 +828,7 @@ static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, /* Set this queue as a chain-building queue */ il_set_bits_prph(il, IL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); - /* Place first TFD at index corresponding to start sequence number. + /* Place first TFD at idx corresponding to start sequence number. * Assumes that ssn_idx is valid (!= 0xFFF) */ il->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); il->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); @@ -1105,7 +1105,7 @@ il4965_tx_status(struct il_priv *il, struct il_tx_info *tx_info, ieee80211_tx_status_irqsafe(il->hw, tx_info->skb); } -int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int index) +int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx) { struct il_tx_queue *txq = &il->txq[txq_id]; struct il_queue *q = &txq->q; @@ -1113,15 +1113,15 @@ int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int index) int nfreed = 0; struct ieee80211_hdr *hdr; - if (index >= q->n_bd || il_queue_used(q, index) == 0) { - IL_ERR("Read index for DMA queue txq id (%d), index %d, " + if (idx >= q->n_bd || il_queue_used(q, idx) == 0) { + IL_ERR("Read idx for DMA queue txq id (%d), idx %d, " "is out of range [0-%d] %d %d.\n", txq_id, - index, q->n_bd, q->write_ptr, q->read_ptr); + idx, q->n_bd, q->write_ptr, q->read_ptr); return 0; } - for (index = il_queue_inc_wrap(index, q->n_bd); - q->read_ptr != index; + for (idx = il_queue_inc_wrap(idx, q->n_bd); + q->read_ptr != idx; q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { tx_info = &txq->txb[txq->q.read_ptr]; @@ -1252,7 +1252,7 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, struct il_compressed_ba_resp *ba_resp = &pkt->u.compressed_ba; struct il_tx_queue *txq = NULL; struct il_ht_agg *agg; - int index; + int idx; int sta_id; int tid; unsigned long flags; @@ -1260,7 +1260,7 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, /* "flow" corresponds to Tx queue */ u16 scd_flow = le16_to_cpu(ba_resp->scd_flow); - /* "ssn" is start of block-ack Tx win, corresponds to index + /* "ssn" is start of block-ack Tx win, corresponds to idx * (in Tx queue's circular buffer) of first TFD/frame in win */ u16 ba_resp_scd_ssn = le16_to_cpu(ba_resp->scd_ssn); @@ -1287,8 +1287,8 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, return; } - /* Find index just before block-ack win */ - index = il_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd); + /* Find idx just before block-ack win */ + idx = il_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd); spin_lock_irqsave(&il->sta_lock, flags); @@ -1317,7 +1317,7 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, * transmitted ... if not, it's too late anyway). */ if (txq->q.read_ptr != (ba_resp_scd_ssn & 0xff)) { /* calculate mac80211 ampdu sw queue to wake */ - int freed = il4965_tx_queue_reclaim(il, scd_flow, index); + int freed = il4965_tx_queue_reclaim(il, scd_flow, idx); il4965_free_tfds_in_queue(il, sta_id, tid, freed); if (il_queue_space(&txq->q) > txq->q.low_mark && diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index 58bdf9302987..8fd383ea58b8 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -446,12 +446,12 @@ static s32 il4965_math_div_round(s32 num, s32 denom, s32 *res) * il4965_get_voltage_compensation - Power supply voltage comp for txpower * * Determines power supply voltage compensation for txpower calculations. - * Returns number of 1/2-dB steps to subtract from gain table index, + * Returns number of 1/2-dB steps to subtract from gain table idx, * to compensate for difference between power supply voltage during * factory measurements, vs. current power supply voltage. * * Voltage indication is higher for lower voltage. - * Lower voltage requires more gain (lower gain table index). + * Lower voltage requires more gain (lower gain table idx). */ static s32 il4965_get_voltage_compensation(s32 eeprom_voltage, s32 current_voltage) @@ -628,10 +628,10 @@ static struct il4965_txpower_comp_entry { {3, 1} /* group 4 2.4, ch all */ }; -static s32 get_min_power_index(s32 rate_power_index, u32 band) +static s32 get_min_power_idx(s32 rate_power_idx, u32 band) { if (!band) { - if ((rate_power_index & 7) <= 4) + if ((rate_power_idx & 7) <= 4) return MIN_TX_GAIN_IDX_52GHZ_EXT; } return MIN_TX_GAIN_IDX; @@ -643,7 +643,7 @@ struct gain_entry { }; static const struct gain_entry gain_table[2][108] = { - /* 5.2GHz power gain index table */ + /* 5.2GHz power gain idx table */ { {123, 0x3F}, /* highest txpower */ {117, 0x3F}, @@ -754,7 +754,7 @@ static const struct gain_entry gain_table[2][108] = { {83, 0x00}, {78, 0x00}, }, - /* 2.4GHz power gain index table */ + /* 2.4GHz power gain idx table */ { {110, 0x3f}, /* highest txpower */ {104, 0x3f}, @@ -891,12 +891,12 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, s32 degrees_per_05db_denom; s32 factory_temp; s32 temperature_comp[2]; - s32 factory_gain_index[2]; + s32 factory_gain_idx[2]; s32 factory_actual_pwr[2]; - s32 power_index; + s32 power_idx; /* tx_power_user_lmt is in dBm, convert to half-dBm (half-dB units - * are used for indexing into txpower table) */ + * are used for idxing into txpower table) */ user_target_power = 2 * il->tx_power_user_lmt; /* Get current (RXON) channel, band, width */ @@ -995,7 +995,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, degrees_per_05db_num, &temperature_comp[c]); - factory_gain_index[c] = measurement->gain_idx; + factory_gain_idx[c] = measurement->gain_idx; factory_actual_pwr[c] = measurement->actual_pow; D_TXPOWER("chain = %d\n", c); @@ -1005,7 +1005,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, temperature_comp[c]); D_TXPOWER("fctry idx %d, fctry pwr %d\n", - factory_gain_index[c], + factory_gain_idx[c], factory_actual_pwr[c]); } @@ -1053,50 +1053,50 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, else atten_value = 0; - /* calculate index; higher index means lower txpower */ - power_index = (u8) (factory_gain_index[c] - + /* calculate idx; higher idx means lower txpower */ + power_idx = (u8) (factory_gain_idx[c] - (target_power - factory_actual_pwr[c]) - temperature_comp[c] - voltage_compensation + atten_value); -/* D_TXPOWER("calculated txpower index %d\n", - power_index); */ +/* D_TXPOWER("calculated txpower idx %d\n", + power_idx); */ - if (power_index < get_min_power_index(i, band)) - power_index = get_min_power_index(i, band); + if (power_idx < get_min_power_idx(i, band)) + power_idx = get_min_power_idx(i, band); - /* adjust 5 GHz index to support negative indexes */ + /* adjust 5 GHz idx to support negative idxes */ if (!band) - power_index += 9; + power_idx += 9; /* CCK, rate 32, reduce txpower for CCK */ if (i == POWER_TABLE_CCK_ENTRY) - power_index += + power_idx += IL_TX_POWER_CCK_COMPENSATION_C_STEP; /* stay within the table! */ - if (power_index > 107) { - IL_WARN("txpower index %d > 107\n", - power_index); - power_index = 107; + if (power_idx > 107) { + IL_WARN("txpower idx %d > 107\n", + power_idx); + power_idx = 107; } - if (power_index < 0) { - IL_WARN("txpower index %d < 0\n", - power_index); - power_index = 0; + if (power_idx < 0) { + IL_WARN("txpower idx %d < 0\n", + power_idx); + power_idx = 0; } /* fill txpower command for this rate/chain */ tx_power.s.radio_tx_gain[c] = - gain_table[band][power_index].radio; + gain_table[band][power_idx].radio; tx_power.s.dsp_predis_atten[c] = - gain_table[band][power_index].dsp; + gain_table[band][power_idx].dsp; - D_TXPOWER("chain %d mimo %d index %d " + D_TXPOWER("chain %d mimo %d idx %d " "gain 0x%02x dsp %d\n", - c, atten_value, power_index, + c, atten_value, power_idx, tx_power.s.radio_tx_gain[c], tx_power.s.dsp_predis_atten[c]); } /* for each chain */ @@ -1777,7 +1777,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); - int index = SEQ_TO_IDX(sequence); + int idx = SEQ_TO_IDX(sequence); struct il_tx_queue *txq = &il->txq[txq_id]; struct ieee80211_hdr *hdr; struct ieee80211_tx_info *info; @@ -1789,10 +1789,10 @@ static void il4965_rx_reply_tx(struct il_priv *il, u8 *qc = NULL; unsigned long flags; - if (index >= txq->q.n_bd || il_queue_used(&txq->q, index) == 0) { - IL_ERR("Read index for DMA queue txq_id (%d) index %d " + if (idx >= txq->q.n_bd || il_queue_used(&txq->q, idx) == 0) { + IL_ERR("Read idx for DMA queue txq_id (%d) idx %d " "is out of range [0-%d] %d %d\n", txq_id, - index, txq->q.n_bd, txq->q.write_ptr, + idx, txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr); return; } @@ -1801,7 +1801,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb); memset(&info->status, 0, sizeof(info->status)); - hdr = il_tx_queue_get_hdr(il, txq_id, index); + hdr = il_tx_queue_get_hdr(il, txq_id, idx); if (ieee80211_is_data_qos(hdr->frame_control)) { qc = ieee80211_get_qos_ctl(hdr); tid = qc[0] & 0xf; @@ -1821,18 +1821,18 @@ static void il4965_rx_reply_tx(struct il_priv *il, agg = &il->stations[sta_id].tid[tid].agg; - il4965_tx_status_reply_tx(il, agg, tx_resp, txq_id, index); + il4965_tx_status_reply_tx(il, agg, tx_resp, txq_id, idx); /* check if BAR is needed */ if ((tx_resp->frame_count == 1) && !il4965_is_tx_success(status)) info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK; if (txq->q.read_ptr != (scd_ssn & 0xff)) { - index = il_queue_dec_wrap(scd_ssn & 0xff, + idx = il_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); D_TX_REPLY("Retry scheduler reclaim scd_ssn " - "%d index %d\n", scd_ssn , index); - freed = il4965_tx_queue_reclaim(il, txq_id, index); + "%d idx %d\n", scd_ssn , idx); + freed = il4965_tx_queue_reclaim(il, txq_id, idx); if (qc) il4965_free_tfds_in_queue(il, sta_id, tid, freed); @@ -1856,7 +1856,7 @@ static void il4965_rx_reply_tx(struct il_priv *il, le32_to_cpu(tx_resp->rate_n_flags), tx_resp->failure_frame); - freed = il4965_tx_queue_reclaim(il, txq_id, index); + freed = il4965_tx_queue_reclaim(il, txq_id, idx); if (qc && likely(sta_id != IL_INVALID_STATION)) il4965_free_tfds_in_queue(il, sta_id, tid, freed); else if (sta_id == IL_INVALID_STATION) diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.h b/drivers/net/wireless/iwlegacy/iwl-4965.h index a75b62cd61f7..8076bbe28cff 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965.h @@ -123,7 +123,7 @@ int il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id); void il4965_rx_reply_compressed_ba(struct il_priv *il, struct il_rx_buf *rxb); -int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int index); +int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx); void il4965_hw_txq_ctx_free(struct il_priv *il); int il4965_txq_ctx_alloc(struct il_priv *il); void il4965_txq_ctx_reset(struct il_priv *il); @@ -133,7 +133,7 @@ void il4965_txq_set_sched(struct il_priv *il, u32 mask); /* * Acquire il->lock before calling this function ! */ -void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 index); +void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx); /** * il4965_tx_queue_set_status - (optionally) start Tx/Cmd queue * @tx_fifo_id: Tx DMA/FIFO channel (range 0-7) that the queue will feed diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h index 002f1d7f475b..408391295fbd 100644 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ b/drivers/net/wireless/iwlegacy/iwl-commands.h @@ -197,7 +197,7 @@ struct il_cmd_header { * * The Linux driver uses the following format: * - * 0:7 tfd index - position within TX queue + * 0:7 tfd idx - position within TX queue * 8:12 TX queue id * 13 reserved * 14 huge - driver sets this to indicate command is in the @@ -454,7 +454,7 @@ struct il_init_alive_resp { * __le32 log_size; log capacity (in number of entries) * __le32 type; (1) timestamp with each entry, (0) no timestamp * __le32 wraps; # times uCode has wrapped to top of circular buffer - * __le32 write_index; next circular buffer entry that uCode would fill + * __le32 write_idx; next circular buffer entry that uCode would fill * * The header is followed by the circular buffer of log entries. Entries * with timestamps have the following format: @@ -901,7 +901,7 @@ struct il_qosparam_cmd { #define STA_MODIFY_DELBA_TID_MSK 0x10 #define STA_MODIFY_SLEEP_TX_COUNT_MSK 0x20 -/* Receiver address (actually, Rx station's index into station table), +/* Receiver address (actually, Rx station's idx into station table), * combined with Traffic ID (QOS priority), in format used by Tx Scheduler */ #define BUILD_RAxTID(sta_id, tid) (((sta_id) << 4) + (tid)) @@ -918,12 +918,12 @@ struct il4965_keyinfo { /** * struct sta_id_modify * @addr[ETH_ALEN]: station's MAC address - * @sta_id: index of station in uCode's station table + * @sta_id: idx of station in uCode's station table * @modify_mask: STA_MODIFY_*, 1: modify, 0: don't change * - * Driver selects unused table index when adding new station, - * or the index to a pre-existing station entry when modifying that station. - * Some indexes have special purposes (IL_AP_ID, index 0, is for AP). + * Driver selects unused table idx when adding new station, + * or the idx to a pre-existing station entry when modifying that station. + * Some idxes have special purposes (IL_AP_ID, idx 0, is for AP). * * modify_mask flags select which parameters to modify vs. leave alone. */ @@ -959,7 +959,7 @@ struct sta_id_modify { * in the IL_AP_ID entry (1st entry in the table). BROADCAST and AP * are all that are needed for a BSS client station. If the device is * used as AP, or in an IBSS network, driver must set up station table - * entries for all STAs in network, starting with index IL_STA_ID. + * entries for all STAs in network, starting with idx IL_STA_ID. */ struct il3945_addsta_cmd { @@ -1109,7 +1109,7 @@ struct il_rem_sta_cmd { * REPLY_WEP_KEY = 0x20 */ struct il_wep_key { - u8 key_index; + u8 key_idx; u8 key_offset; u8 reserved1[2]; u8 key_size; @@ -1297,7 +1297,7 @@ struct il_rx_mpdu_res_start { /* For 4965 devices: * 1: Use rate scale table (see REPLY_TX_LINK_QUALITY_CMD). - * Tx command's initial_rate_index indicates first rate to try; + * Tx command's initial_rate_idx indicates first rate to try; * uCode walks through table for additional Tx attempts. * 0: Use Tx rate/MCS from Tx command's rate_n_flags field. * This rate will be used for all Tx attempts; it will not be scaled. */ @@ -1499,7 +1499,7 @@ struct il_tx_cmd { * rate (via non-0 value) for special frames (e.g. management), while * still supporting rate scaling for all frames. */ - u8 initial_rate_index; + u8 initial_rate_idx; u8 reserved; u8 key[16]; __le16 next_frame_flags; @@ -1792,7 +1792,7 @@ struct il4965_txpowertable_cmd { struct il3945_rate_scaling_info { __le16 rate_n_flags; u8 try_cnt; - u8 next_rate_index; + u8 next_rate_idx; } __packed; struct il3945_rate_scaling_cmd { @@ -1825,7 +1825,7 @@ struct il3945_rate_scaling_cmd { struct il_link_qual_general_params { u8 flags; - /* No entries at or above this (driver chosen) index contain MIMO */ + /* No entries at or above this (driver chosen) idx contain MIMO */ u8 mimo_delimiter; /* Best single antenna to use for single stream (legacy, SISO). */ @@ -1837,7 +1837,7 @@ struct il_link_qual_general_params { /* * If driver needs to use different initial rates for different * EDCA QOS access categories (as implemented by tx fifos 0-3), - * this table will set that up, by indicating the indexes in the + * this table will set that up, by indicating the idxes in the * rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table at which to start. * Otherwise, driver should set all entries to 0. * @@ -1845,7 +1845,7 @@ struct il_link_qual_general_params { * 0 = Background, 1 = Best Effort (normal), 2 = Video, 3 = Voice * TX FIFOs above 3 use same value (typically 0) as TX FIFO 3. */ - u8 start_rate_index[LINK_QUAL_AC_NUM]; + u8 start_rate_idx[LINK_QUAL_AC_NUM]; } __packed; #define LINK_QUAL_AGG_TIME_LIMIT_DEF (4000) /* 4 milliseconds */ @@ -2089,8 +2089,8 @@ struct il_link_quality_cmd { struct il_link_qual_agg_params agg_params; /* - * Rate info; when using rate-scaling, Tx command's initial_rate_index - * specifies 1st Tx rate attempted, via index into this table. + * Rate info; when using rate-scaling, Tx command's initial_rate_idx + * specifies 1st Tx rate attempted, via idx into this table. * 4965 devices works its way through table when retrying Tx. */ struct { @@ -2233,7 +2233,7 @@ enum il_measure_type { struct il_spectrum_notification { u8 id; /* measurement id -- 0 or 1 */ u8 token; - u8 channel_index; /* index in measurement channel list */ + u8 channel_idx; /* idx in measurement channel list */ u8 state; /* 0 - start, 1 - stop */ __le32 start_time; /* lower 32-bits of TSF */ u8 band; /* 0 - 5.2GHz, 1 - 2.4GHz */ @@ -3220,7 +3220,7 @@ struct il_missed_beacon_notif { * Table entries in SENSITIVITY_CMD (struct il_sensitivity_cmd) */ #define HD_TABLE_SIZE (11) /* number of entries */ -#define HD_MIN_ENERGY_CCK_DET_IDX (0) /* table indexes */ +#define HD_MIN_ENERGY_CCK_DET_IDX (0) /* table idxes */ #define HD_MIN_ENERGY_OFDM_DET_IDX (1) #define HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX (2) #define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_IDX (3) @@ -3239,13 +3239,13 @@ struct il_missed_beacon_notif { /** * struct il_sensitivity_cmd * @control: (1) updates working table, (0) updates default table - * @table: energy threshold values, use HD_* as index into table + * @table: energy threshold values, use HD_* as idx into table * * Always use "1" in "control" to update uCode's working table and DSP. */ struct il_sensitivity_cmd { __le16 control; /* always use "1" */ - __le16 table[HD_TABLE_SIZE]; /* use HD_* as index */ + __le16 table[HD_TABLE_SIZE]; /* use HD_* as idx */ } __packed; diff --git a/drivers/net/wireless/iwlegacy/iwl-csr.h b/drivers/net/wireless/iwlegacy/iwl-csr.h index c00ec353f556..34edec329367 100644 --- a/drivers/net/wireless/iwlegacy/iwl-csr.h +++ b/drivers/net/wireless/iwlegacy/iwl-csr.h @@ -411,10 +411,10 @@ #define HBUS_TARG_PRPH_RDAT (HBUS_BASE+0x050) /* - * Per-Tx-queue write pointer (index, really!) - * Indicates index to next TFD that driver will fill (1 past latest filled). + * Per-Tx-queue write pointer (idx, really!) + * Indicates idx to next TFD that driver will fill (1 past latest filled). * Bit usage: - * 0-7: queue write index + * 0-7: queue write idx * 11-8: queue selector */ #define HBUS_TARG_WRPTR (HBUS_BASE+0x060) diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 18dd253b43f7..2555f9fe9be2 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -125,8 +125,8 @@ struct il_cmd_meta { */ struct il_queue { int n_bd; /* number of BDs in this queue */ - int write_ptr; /* 1-st empty entry (index) host_w*/ - int read_ptr; /* last used entry (index) host_r*/ + int write_ptr; /* 1-st empty entry (idx) host_w*/ + int read_ptr; /* last used entry (idx) host_r*/ /* use for monitoring and recovering the stuck queue */ dma_addr_t dma_addr; /* physical addr for BD's */ int n_win; /* safe queue win */ @@ -152,7 +152,7 @@ struct il_tx_info { * @dma_addr_cmd: physical address of cmd/tx buffer array * @txb: array of per-TFD driver data * @time_stamp: time (in jiffies) of last read_ptr change - * @need_update: indicates need to update read/write index + * @need_update: indicates need to update read/write idx * @sched_retry: indicates queue is high-throughput aggregation (HT AGG) enabled * * A Tx queue consists of circular buffer of BDs (a.k.a. TFDs, transmit frame @@ -199,11 +199,11 @@ struct il3945_clip_group { * -- hardware capabilities (clip-powers) * -- spectrum management * -- user preference (e.g. iwconfig) - * when requested power is set, base power index must also be set. */ + * when requested power is set, base power idx must also be set. */ struct il3945_channel_power_info { struct il3945_tx_power tpc; /* actual radio and DSP gain settings */ - s8 power_table_index; /* actual (compenst'd) index into gain table */ - s8 base_power_index; /* gain index for power at factory temp. */ + s8 power_table_idx; /* actual (compenst'd) idx into gain table */ + s8 base_power_idx; /* gain idx for power at factory temp. */ s8 requested_power; /* power (dBm) requested for this chnl/rate */ }; @@ -211,7 +211,7 @@ struct il3945_channel_power_info { * channel. */ struct il3945_scan_power_info { struct il3945_tx_power tpc; /* actual radio and DSP gain settings */ - s8 power_table_index; /* actual (compenst'd) index into gain table */ + s8 power_table_idx; /* actual (compenst'd) idx into gain table */ s8 requested_power; /* scan pwr (dBm) requested for chnl/rate */ }; @@ -234,8 +234,8 @@ struct il_channel_info { s8 min_power; /* always 0 */ s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */ - u8 group_index; /* 0-4, maps channel to group1/2/3/4/5 */ - u8 band_index; /* 0-4, maps channel to band1/2/3/4/5 */ + u8 group_idx; /* 0-4, maps channel to group1/2/3/4/5 */ + u8 band_idx; /* 0-4, maps channel to band1/2/3/4/5 */ enum ieee80211_band band; /* HT40 channel info */ @@ -245,7 +245,7 @@ struct il_channel_info { /* Radio/DSP gain settings for each "normal" data Tx rate. * These include, in addition to RF and DSP gain, a few fields for - * remembering/modifying gain settings (indexes). */ + * remembering/modifying gain settings (idxes). */ struct il3945_channel_power_info power_info[IL4965_MAX_RATE]; /* Radio/DSP gain settings for each scan rate, for directed scans. */ @@ -337,12 +337,12 @@ struct il_host_cmd { * struct il_rx_queue - Rx queue * @bd: driver's pointer to buffer of receive buffer descriptors (rbd) * @bd_dma: bus address of buffer of receive buffer descriptors (rbd) - * @read: Shared index to newest available Rx buffer - * @write: Shared index to oldest written Rx packet + * @read: Shared idx to newest available Rx buffer + * @write: Shared idx to oldest written Rx packet * @free_count: Number of pre-allocated buffers in rx_free * @rx_free: list of free SKBs for use * @rx_used: List of Rx buffers with no SKB - * @need_update: flag to indicate we need to update read/write index + * @need_update: flag to indicate we need to update read/write idx * @rb_stts: driver's pointer to receive buffer status * @rb_stts_dma: bus address of receive buffer status * @@ -636,7 +636,7 @@ static inline int il_queue_used(const struct il_queue *q, int i) } -static inline u8 il_get_cmd_index(struct il_queue *q, u32 index, +static inline u8 il_get_cmd_idx(struct il_queue *q, u32 idx, int is_huge) { /* @@ -648,7 +648,7 @@ static inline u8 il_get_cmd_index(struct il_queue *q, u32 index, return q->n_win; /* must be power of 2 */ /* Otherwise, use normal size buffers */ - return index & (q->n_win - 1); + return idx & (q->n_win - 1); } @@ -987,7 +987,7 @@ struct il_priv { struct il_force_reset force_reset; /* we allocate array of il_channel_info for NIC's valid channels. - * Access via channel # using indirect index array */ + * Access via channel # using indirect idx array */ struct il_channel_info *channel_info; /* channel info array */ u8 channel_count; /* # of channels */ @@ -1033,7 +1033,7 @@ struct il_priv { struct mac_address addresses[1]; /* uCode images, save to reload in case of failure */ - int fw_index; /* firmware we're trying to load */ + int fw_idx; /* firmware we're trying to load */ u32 ucode_ver; /* version of ucode, copy of il_ucode.ver */ struct fw_desc ucode_code; /* runtime inst */ diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-eeprom.c index 5786abd7c0bb..ee5ad69a534b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.c +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.c @@ -89,7 +89,7 @@ * During init, we copy the eeprom information and channel map * information into il->channel_info_24/52 and il->channel_map_24/52 * - * channel_map_24/52 provides the index in the channel_info array for a + * channel_map_24/52 provides the idx in the channel_info array for a * given channel. We have to have two separate maps as there is channel * overlap with the 2.4GHz and 5.2GHz spectrum as seen in band_1 and * band_2 @@ -267,7 +267,7 @@ EXPORT_SYMBOL(il_eeprom_free); static void il_init_band_reference(const struct il_priv *il, int eep_band, int *eeprom_ch_count, const struct il_eeprom_channel **eeprom_ch_info, - const u8 **eeprom_ch_index) + const u8 **eeprom_ch_idx) { u32 offset = il->cfg->ops->lib-> eeprom_ops.regulatory_bands[eep_band - 1]; @@ -276,43 +276,43 @@ static void il_init_band_reference(const struct il_priv *il, *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_1); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = il_eeprom_band_1; + *eeprom_ch_idx = il_eeprom_band_1; break; case 2: /* 4.9GHz band */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_2); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = il_eeprom_band_2; + *eeprom_ch_idx = il_eeprom_band_2; break; case 3: /* 5.2GHz band */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_3); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = il_eeprom_band_3; + *eeprom_ch_idx = il_eeprom_band_3; break; case 4: /* 5.5GHz band */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_4); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = il_eeprom_band_4; + *eeprom_ch_idx = il_eeprom_band_4; break; case 5: /* 5.7GHz band */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_5); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = il_eeprom_band_5; + *eeprom_ch_idx = il_eeprom_band_5; break; case 6: /* 2.4GHz ht40 channels */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_6); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = il_eeprom_band_6; + *eeprom_ch_idx = il_eeprom_band_6; break; case 7: /* 5 GHz ht40 channels */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_7); *eeprom_ch_info = (struct il_eeprom_channel *) il_eeprom_query_addr(il, offset); - *eeprom_ch_index = il_eeprom_band_7; + *eeprom_ch_idx = il_eeprom_band_7; break; default: BUG(); @@ -374,7 +374,7 @@ static int il_mod_ht40_chan_info(struct il_priv *il, int il_init_channel_map(struct il_priv *il) { int eeprom_ch_count = 0; - const u8 *eeprom_ch_index = NULL; + const u8 *eeprom_ch_idx = NULL; const struct il_eeprom_channel *eeprom_ch_info = NULL; int band, ch; struct il_channel_info *ch_info; @@ -412,11 +412,11 @@ int il_init_channel_map(struct il_priv *il) for (band = 1; band <= 5; band++) { il_init_band_reference(il, band, &eeprom_ch_count, - &eeprom_ch_info, &eeprom_ch_index); + &eeprom_ch_info, &eeprom_ch_idx); /* Loop through each band adding each of the channels */ for (ch = 0; ch < eeprom_ch_count; ch++) { - ch_info->channel = eeprom_ch_index[ch]; + ch_info->channel = eeprom_ch_idx[ch]; ch_info->band = (band == 1) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; @@ -486,7 +486,7 @@ int il_init_channel_map(struct il_priv *il) enum ieee80211_band ieeeband; il_init_band_reference(il, band, &eeprom_ch_count, - &eeprom_ch_info, &eeprom_ch_index); + &eeprom_ch_info, &eeprom_ch_idx); /* EEPROM band 6 is 2.4, band 7 is 5 GHz */ ieeeband = @@ -496,13 +496,13 @@ int il_init_channel_map(struct il_priv *il) for (ch = 0; ch < eeprom_ch_count; ch++) { /* Set up driver's info for lower half */ il_mod_ht40_chan_info(il, ieeeband, - eeprom_ch_index[ch], + eeprom_ch_idx[ch], &eeprom_ch_info[ch], IEEE80211_CHAN_NO_HT40PLUS); /* Set up driver's info for upper half */ il_mod_ht40_chan_info(il, ieeeband, - eeprom_ch_index[ch] + 4, + eeprom_ch_idx[ch] + 4, &eeprom_ch_info[ch], IEEE80211_CHAN_NO_HT40MINUS); } diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.h b/drivers/net/wireless/iwlegacy/iwl-eeprom.h index b97c83735c76..eb868c0e6559 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.h +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.h @@ -153,7 +153,7 @@ extern const u8 il_eeprom_band_1[14]; * * 1) Temperature (degrees Celsius) of device when measurement was made. * - * 2) Gain table index used to achieve the target measurement power. + * 2) Gain table idx used to achieve the target measurement power. * This refers to the "well-known" gain tables (see iwl-4965-hw.h). * * 3) Actual measured output power, in half-dBm ("34" = 17 dBm). diff --git a/drivers/net/wireless/iwlegacy/iwl-fh.h b/drivers/net/wireless/iwlegacy/iwl-fh.h index e993e3ea5b33..f53f1b87d8e9 100644 --- a/drivers/net/wireless/iwlegacy/iwl-fh.h +++ b/drivers/net/wireless/iwlegacy/iwl-fh.h @@ -141,7 +141,7 @@ * into FH_RSCSR_CHNL0_RBDCB_BASE_REG [27:0]. * * 2) Rx status buffer, 8 bytes, in which 4965 indicates which Rx Buffers - * (RBs) have been filled, via a "write pointer", actually the index of + * (RBs) have been filled, via a "write pointer", actually the idx of * the RB's corresponding RBD within the circular buffer. Driver sets * physical address [35:4] into FH_RSCSR_CHNL0_STTS_WPTR_REG [31:0]. * @@ -153,33 +153,33 @@ * * As the driver prepares Receive Buffers (RBs) for 4965 to fill, driver must * enter pointers to these RBs into contiguous RBD circular buffer entries, - * and update the 4965's "write" index register, + * and update the 4965's "write" idx register, * FH_RSCSR_CHNL0_RBDCB_WPTR_REG. * - * This "write" index corresponds to the *next* RBD that the driver will make + * This "write" idx corresponds to the *next* RBD that the driver will make * available, i.e. one RBD past the tail of the ready-to-fill RBDs within * the circular buffer. This value should initially be 0 (before preparing any * RBs), should be 8 after preparing the first 8 RBs (for example), and must * wrap back to 0 at the end of the circular buffer (but don't wrap before - * "read" index has advanced past 1! See below). + * "read" idx has advanced past 1! See below). * NOTE: 4965 EXPECTS THE WRITE IDX TO BE INCREMENTED IN MULTIPLES OF 8. * * As the 4965 fills RBs (referenced from contiguous RBDs within the circular * buffer), it updates the Rx status buffer in host DRAM, 2) described above, - * to tell the driver the index of the latest filled RBD. The driver must - * read this "read" index from DRAM after receiving an Rx interrupt from 4965. + * to tell the driver the idx of the latest filled RBD. The driver must + * read this "read" idx from DRAM after receiving an Rx interrupt from 4965. * - * The driver must also internally keep track of a third index, which is the + * The driver must also internally keep track of a third idx, which is the * next RBD to process. When receiving an Rx interrupt, driver should process * all filled but unprocessed RBs up to, but not including, the RB - * corresponding to the "read" index. For example, if "read" index becomes "1", + * corresponding to the "read" idx. For example, if "read" idx becomes "1", * driver may process the RB pointed to by RBD 0. Depending on volume of * traffic, there may be many RBs to process. * - * If read index == write index, 4965 thinks there is no room to put new data. + * If read idx == write idx, 4965 thinks there is no room to put new data. * Due to this, the maximum number of filled RBs is 255, instead of 256. To * be safe, make sure that there is a gap of at least 2 RBDs between "write" - * and "read" indexes; that is, make sure that there are no more than 254 + * and "read" idxes; that is, make sure that there are no more than 254 * buffers waiting to be filled. */ #define FH_MEM_RSCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xBC0) @@ -201,7 +201,7 @@ #define FH_RSCSR_CHNL0_RBDCB_BASE_REG (FH_MEM_RSCSR_CHNL0 + 0x004) /** - * Rx write pointer (index, really!). + * Rx write pointer (idx, really!). * Bit fields: * 11-0: Index of driver's most recent prepared-to-be-filled RBD, + 1. * NOTE: For 256-entry circular buffer, use only bits [7:0]. @@ -431,11 +431,11 @@ /** * struct il_rb_status - reseve buffer status * host memory mapped FH registers - * @closed_rb_num [0:11] - Indicates the index of the RB which was closed - * @closed_fr_num [0:11] - Indicates the index of the RX Frame which was closed - * @finished_rb_num [0:11] - Indicates the index of the current RB + * @closed_rb_num [0:11] - Indicates the idx of the RB which was closed + * @closed_fr_num [0:11] - Indicates the idx of the RX Frame which was closed + * @finished_rb_num [0:11] - Indicates the idx of the current RB * in which the last frame was written to - * @finished_fr_num [0:11] - Indicates the index of the RX Frame + * @finished_fr_num [0:11] - Indicates the idx of the RX Frame * which was transferred */ struct il_rb_status { diff --git a/drivers/net/wireless/iwlegacy/iwl-helpers.h b/drivers/net/wireless/iwlegacy/iwl-helpers.h index a9d87023e69f..5fcb23e8f5a6 100644 --- a/drivers/net/wireless/iwlegacy/iwl-helpers.h +++ b/drivers/net/wireless/iwlegacy/iwl-helpers.h @@ -45,23 +45,23 @@ static inline struct ieee80211_conf *il_ieee80211_get_hw_conf( } /** - * il_queue_inc_wrap - increment queue index, wrap back to beginning - * @index -- current index + * il_queue_inc_wrap - increment queue idx, wrap back to beginning + * @idx -- current idx * @n_bd -- total number of entries in queue (must be power of 2) */ -static inline int il_queue_inc_wrap(int index, int n_bd) +static inline int il_queue_inc_wrap(int idx, int n_bd) { - return ++index & (n_bd - 1); + return ++idx & (n_bd - 1); } /** - * il_queue_dec_wrap - decrement queue index, wrap back to end - * @index -- current index + * il_queue_dec_wrap - decrement queue idx, wrap back to end + * @idx -- current idx * @n_bd -- total number of entries in queue (must be power of 2) */ -static inline int il_queue_dec_wrap(int index, int n_bd) +static inline int il_queue_dec_wrap(int idx, int n_bd) { - return --index & (n_bd - 1); + return --idx & (n_bd - 1); } /* TODO: Move fw_desc functions to iwl-pci.ko */ diff --git a/drivers/net/wireless/iwlegacy/iwl-led.c b/drivers/net/wireless/iwlegacy/iwl-led.c index a283804da10d..3652cdc1770e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-led.c +++ b/drivers/net/wireless/iwlegacy/iwl-led.c @@ -41,7 +41,7 @@ #include "iwl-core.h" #include "iwl-io.h" -/* default: IL_LED_BLINK(0) using blinking index table */ +/* default: IL_LED_BLINK(0) using blinking idx table */ static int led_mode; module_param(led_mode, int, S_IRUGO); MODULE_PARM_DESC(led_mode, "0=system default, " diff --git a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h index f3ee0dd67f57..bc09a5dc6d89 100644 --- a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h +++ b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h @@ -49,13 +49,13 @@ struct il3945_rate_info { u8 next_rs; /* next rate used in rs algo */ u8 prev_rs_tgg; /* previous rate used in TGG rs algo */ u8 next_rs_tgg; /* next rate used in TGG rs algo */ - u8 table_rs_index; /* index in rate scale table cmd */ + u8 table_rs_idx; /* idx in rate scale table cmd */ u8 prev_table_rs; /* prev in rate table cmd */ }; /* - * These serve as indexes into + * These serve as idxes into * struct il_rate_info il_rates[RATE_COUNT]; */ enum { @@ -351,7 +351,7 @@ struct il_traffic_load { * Pointer to this gets passed back and forth between driver and mac80211. */ struct il_lq_sta { - u8 active_tbl; /* index of active table, range 0-1 */ + u8 active_tbl; /* idx of active table, range 0-1 */ u8 enable_counter; /* indicates HT mode */ u8 stay_in_tbl; /* 1: disallow, 0: allow search for new mode */ u8 search_better_tbl; /* 1: currently trying alternate mode */ diff --git a/drivers/net/wireless/iwlegacy/iwl-prph.h b/drivers/net/wireless/iwlegacy/iwl-prph.h index 200f2955ab54..8128c87262e9 100644 --- a/drivers/net/wireless/iwlegacy/iwl-prph.h +++ b/drivers/net/wireless/iwlegacy/iwl-prph.h @@ -336,7 +336,7 @@ /* * Driver may need to update queue-empty bits after changing queue's - * write and read pointers (indexes) during (re-)initialization (i.e. when + * write and read pointers (idxes) during (re-)initialization (i.e. when * scheduler is not tracking what's happening). * Bit fields: * 31-16: Write mask -- 1: update empty bit, 0: don't change empty bit @@ -351,7 +351,7 @@ * This register points to BC CB for queue 0, must be on 1024-byte boundary. * Others are spaced by 1024 bytes. * Each BC CB is 2 bytes * (256 + 64) = 740 bytes, followed by 384 bytes pad. - * (Index into a queue's BC CB) = (index into queue's TFD CB) = (SSN & 0xff). + * (Index into a queue's BC CB) = (idx into queue's TFD CB) = (SSN & 0xff). * Bit fields: * 25-00: Byte Count CB physical address [35:10], must be 1024-byte aligned. */ @@ -366,18 +366,18 @@ */ #define IL49_SCD_TXFACT (IL49_SCD_START_OFFSET + 0x1c) /* - * Queue (x) Write Pointers (indexes, really!), one for each Tx queue. + * Queue (x) Write Pointers (idxes, really!), one for each Tx queue. * Initialized and updated by driver as new TFDs are added to queue. - * NOTE: If using Block Ack, index must correspond to frame's - * Start Sequence Number; index = (SSN & 0xff) + * NOTE: If using Block Ack, idx must correspond to frame's + * Start Sequence Number; idx = (SSN & 0xff) * NOTE: Alternative to HBUS_TARG_WRPTR, which is what Linux driver uses? */ #define IL49_SCD_QUEUE_WRPTR(x) (IL49_SCD_START_OFFSET + 0x24 + (x) * 4) /* - * Queue (x) Read Pointers (indexes, really!), one for each Tx queue. - * For FIFO mode, index indicates next frame to transmit. - * For Scheduler-ACK mode, index indicates first frame in Tx win. + * Queue (x) Read Pointers (idxes, really!), one for each Tx queue. + * For FIFO mode, idx indicates next frame to transmit. + * For Scheduler-ACK mode, idx indicates first frame in Tx win. * Initialized by driver, updated by scheduler. */ #define IL49_SCD_QUEUE_RDPTR(x) (IL49_SCD_START_OFFSET + 0x64 + (x) * 4) @@ -395,7 +395,7 @@ /* * Select which queues interrupt driver when scheduler increments - * a queue's read pointer (index). + * a queue's read pointer (idx). * Bit fields: * 31-16: Reserved * 15-00: Interrupt enable, one bit for each queue -- 1: enabled, 0: disabled diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c index 5c0d1317d149..58d19c155a3d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -45,17 +45,17 @@ * each of which point to Receive Buffers to be filled by the NIC. These get * used not only for Rx frames, but for any command response or notification * from the NIC. The driver and NIC manage the Rx buffers by means - * of indexes into the circular buffer. + * of idxes into the circular buffer. * * Rx Queue Indexes - * The host/firmware share two index registers for managing the Rx buffers. + * The host/firmware share two idx registers for managing the Rx buffers. * - * The READ index maps to the first position that the firmware may be writing + * The READ idx maps to the first position that the firmware may be writing * to -- the driver can read up to (but not including) this position and get * good data. - * The READ index is managed by the firmware once the card is enabled. + * The READ idx is managed by the firmware once the card is enabled. * - * The WRITE index maps to the last position the driver has read from -- the + * The WRITE idx maps to the last position the driver has read from -- the * position preceding WRITE is the last slot the firmware can place a packet. * * The queue is empty (no good data) if WRITE = READ - 1, and is full if @@ -64,9 +64,9 @@ * During initialization, the host sets up the READ queue position to the first * IDX position, and WRITE to the last (READ - 1 wrapped) * - * When the firmware places a packet in a buffer, it will advance the READ index - * and fire the RX interrupt. The driver can then query the READ index and - * process as many packets as possible, moving the WRITE index forward as it + * When the firmware places a packet in a buffer, it will advance the READ idx + * and fire the RX interrupt. The driver can then query the READ idx and + * process as many packets as possible, moving the WRITE idx forward as it * resets the Rx queue buffers with new memory. * * The management in the driver is as follows: @@ -75,9 +75,9 @@ * to replenish the iwl->rxq->rx_free. * + In il_rx_replenish (scheduled) if 'processed' != 'read' then the * iwl->rxq is replenished and the READ IDX is updated (updating the - * 'processed' and 'read' driver indexes as well) + * 'processed' and 'read' driver idxes as well) * + A received packet is processed and handed to the kernel network stack, - * detached from the iwl->rxq. The driver 'processed' index is updated. + * detached from the iwl->rxq. The driver 'processed' idx is updated. * + The Host/Firmware iwl->rxq is replenished at tasklet time from the rx_free * list. If there are no allocated buffers in iwl->rxq->rx_free, the READ * IDX is not incremented and iwl->status(RX_STALLED) is set. If there @@ -91,7 +91,7 @@ * il_rx_queue_restock * il_rx_queue_restock() Moves available buffers from rx_free into Rx * queue, updates firmware pointers, and updates - * the WRITE index. If insufficient rx_free buffers + * the WRITE idx. If insufficient rx_free buffers * are available, schedules il_rx_replenish * * -- enable interrupts -- diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.c b/drivers/net/wireless/iwlegacy/iwl-sta.c index dcaa3fb62743..a7fe9ea80aa5 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-sta.c @@ -174,7 +174,7 @@ int il_send_add_sta(struct il_priv *il, } EXPORT_SYMBOL(il_send_add_sta); -static void il_set_ht_add_station(struct il_priv *il, u8 index, +static void il_set_ht_add_station(struct il_priv *il, u8 idx, struct ieee80211_sta *sta, struct il_rxon_context *ctx) { @@ -192,7 +192,7 @@ static void il_set_ht_add_station(struct il_priv *il, u8 index, (mimo_ps_mode == WLAN_HT_CAP_SM_PS_DYNAMIC) ? "dynamic" : "disabled"); - sta_flags = il->stations[index].sta.station_flags; + sta_flags = il->stations[idx].sta.station_flags; sta_flags &= ~(STA_FLG_RTS_MIMO_PROT_MSK | STA_FLG_MIMO_DIS_MSK); @@ -221,7 +221,7 @@ static void il_set_ht_add_station(struct il_priv *il, u8 index, else sta_flags &= ~STA_FLG_HT40_EN_MSK; - il->stations[index].sta.station_flags = sta_flags; + il->stations[idx].sta.station_flags = sta_flags; done: return; } @@ -649,7 +649,7 @@ il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) } EXPORT_SYMBOL(il_restore_stations); -int il_get_free_ucode_key_index(struct il_priv *il) +int il_get_free_ucode_key_idx(struct il_priv *il) { int i; @@ -659,7 +659,7 @@ int il_get_free_ucode_key_index(struct il_priv *il) return WEP_INVALID_OFFSET; } -EXPORT_SYMBOL(il_get_free_ucode_key_index); +EXPORT_SYMBOL(il_get_free_ucode_key_idx); void il_dealloc_bcast_stations(struct il_priv *il) { @@ -692,7 +692,7 @@ static void il_dump_lq_cmd(struct il_priv *il, lq->general_params.dual_stream_ant_msk); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) - D_RATE("lq index %d 0x%X\n", + D_RATE("lq idx %d 0x%X\n", i, lq->rs_table[i].rate_n_flags); } #else @@ -728,7 +728,7 @@ static bool il_is_lq_table_valid(struct il_priv *il, if (le32_to_cpu(lq->rs_table[i].rate_n_flags) & RATE_MCS_HT_MSK) { D_INFO( - "index %d of LQ expects HT channel\n", + "idx %d of LQ expects HT channel\n", i); return false; } diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.h b/drivers/net/wireless/iwlegacy/iwl-sta.h index 77cdfd4a6674..f07cd7f7b8ae 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.h +++ b/drivers/net/wireless/iwlegacy/iwl-sta.h @@ -48,7 +48,7 @@ void il_restore_stations(struct il_priv *il, void il_clear_ucode_stations(struct il_priv *il, struct il_rxon_context *ctx); void il_dealloc_bcast_stations(struct il_priv *il); -int il_get_free_ucode_key_index(struct il_priv *il); +int il_get_free_ucode_key_idx(struct il_priv *il); int il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags); int il_add_station_common(struct il_priv *il, diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index 45114b495b3e..10a0914709b3 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -39,7 +39,7 @@ #include "iwl-helpers.h" /** - * il_txq_update_write_ptr - Send new write index to hardware + * il_txq_update_write_ptr - Send new write idx to hardware */ void il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq) @@ -152,7 +152,7 @@ void il_cmd_queue_unmap(struct il_priv *il) return; while (q->read_ptr != q->write_ptr) { - i = il_get_cmd_index(q, q->read_ptr, 0); + i = il_get_cmd_idx(q, q->read_ptr, 0); if (txq->meta[i].flags & CMD_MAPPED) { pci_unmap_single(il->pci_dev, @@ -254,7 +254,7 @@ EXPORT_SYMBOL(il_queue_space); /** - * il_queue_init - Initialize queue's high/low-water and read/write indexes + * il_queue_init - Initialize queue's high/low-water and read/write idxes */ static int il_queue_init(struct il_priv *il, struct il_queue *q, int count, int slots_num, u32 id) @@ -268,7 +268,7 @@ static int il_queue_init(struct il_priv *il, struct il_queue *q, BUG_ON(!is_power_of_2(count)); /* slots_num must be power-of-two size, otherwise - * il_get_cmd_index is broken. */ + * il_get_cmd_idx is broken. */ BUG_ON(!is_power_of_2(slots_num)); q->low_mark = q->n_win / 4; @@ -385,7 +385,7 @@ int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, * il_queue_inc_wrap and il_queue_dec_wrap are broken. */ BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); - /* Initialize queue's high/low-water marks, and head/tail indexes */ + /* Initialize queue's high/low-water marks, and head/tail idxes */ il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); @@ -416,7 +416,7 @@ void il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, txq->need_update = 0; - /* Initialize queue's high/low-water marks, and head/tail indexes */ + /* Initialize queue's high/low-water marks, and head/tail idxes */ il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); @@ -433,7 +433,7 @@ EXPORT_SYMBOL(il_tx_queue_reset); * @cmd: a point to the ucode command structure * * The function returns < 0 values to indicate the operation is - * failed. On success, it turns the index (> 0) of command in the + * failed. On success, it turns the idx (> 0) of command in the * command queue. */ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) @@ -476,7 +476,7 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) return -ENOSPC; } - idx = il_get_cmd_index(q, q->write_ptr, cmd->flags & CMD_SIZE_HUGE); + idx = il_get_cmd_idx(q, q->write_ptr, cmd->flags & CMD_SIZE_HUGE); out_cmd = txq->cmd[idx]; out_meta = &txq->meta[idx]; @@ -543,7 +543,7 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) phys_addr, fix_size, 1, U32_PAD(cmd->len)); - /* Increment and update queue's write index */ + /* Increment and update queue's write idx */ q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); il_txq_update_write_ptr(il, txq); @@ -554,7 +554,7 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) /** * il_hcmd_queue_reclaim - Reclaim TX command queue entries already Tx'd * - * When FW advances 'R' index, all entries between old and new 'R' index + * When FW advances 'R' idx, all entries between old and new 'R' idx * need to be reclaimed. As result, some free space forms. If there is * enough free space (> low mark), wake the stack that feeds us. */ @@ -566,7 +566,7 @@ static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, int nfreed = 0; if (idx >= q->n_bd || il_queue_used(q, idx) == 0) { - IL_ERR("Read index for DMA queue txq id (%d), index %d, " + IL_ERR("Read idx for DMA queue txq id (%d), idx %d, " "is out of range [0-%d] %d %d.\n", txq_id, idx, q->n_bd, q->write_ptr, q->read_ptr); return; @@ -576,7 +576,7 @@ static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { if (nfreed++ > 0) { - IL_ERR("HCMD skipped: index (%d) %d %d\n", idx, + IL_ERR("HCMD skipped: idx (%d) %d %d\n", idx, q->write_ptr, q->read_ptr); queue_work(il->workqueue, &il->restart); } @@ -598,8 +598,8 @@ il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb) struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); int txq_id = SEQ_TO_QUEUE(sequence); - int index = SEQ_TO_IDX(sequence); - int cmd_index; + int idx = SEQ_TO_IDX(sequence); + int cmd_idx; bool huge = !!(pkt->hdr.sequence & SEQ_HUGE_FRAME); struct il_device_cmd *cmd; struct il_cmd_meta *meta; @@ -618,9 +618,9 @@ il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb) return; } - cmd_index = il_get_cmd_index(&txq->q, index, huge); - cmd = txq->cmd[cmd_index]; - meta = &txq->meta[cmd_index]; + cmd_idx = il_get_cmd_idx(&txq->q, idx, huge); + cmd = txq->cmd[cmd_idx]; + meta = &txq->meta[cmd_idx]; txq->time_stamp = jiffies; @@ -638,7 +638,7 @@ il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb) spin_lock_irqsave(&il->hcmd_lock, flags); - il_hcmd_queue_reclaim(il, txq_id, index, cmd_index); + il_hcmd_queue_reclaim(il, txq_id, idx, cmd_idx); if (!(meta->flags & CMD_ASYNC)) { clear_bit(STATUS_HCMD_ACTIVE, &il->status); diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 017b29720423..924420870a2f 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -163,7 +163,7 @@ static int il3945_set_ccmp_dynamic_key_info(struct il_priv *il, if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) il->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_index(il); + il_get_free_ucode_key_idx(il); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ @@ -513,7 +513,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) hdr_len = ieee80211_hdrlen(fc); - /* Find index into station table for destination station */ + /* Find idx into station table for destination station */ sta_id = il_sta_id_or_broadcast( il, &il->ctx, info->control.sta); @@ -541,7 +541,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) spin_lock_irqsave(&il->lock, flags); - idx = il_get_cmd_index(q, q->write_ptr, 0); + idx = il_get_cmd_idx(q, q->write_ptr, 0); /* Set up driver data for this TFD */ memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct il_tx_info)); @@ -557,7 +557,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) /* * Set up the Tx-command (not MAC!) header. - * Store the chosen Tx queue and TFD index within the sequence field; + * Store the chosen Tx queue and TFD idx within the sequence field; * after Tx, uCode's Tx response will return this value so driver can * locate the frame within the tx queue and do post-tx processing. */ @@ -641,7 +641,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) } - /* Tell device the write index *just past* this latest filled TFD */ + /* Tell device the write idx *just past* this latest filled TFD */ q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); il_txq_update_write_ptr(il, txq); spin_unlock_irqrestore(&il->lock, flags); @@ -889,14 +889,14 @@ static void il3945_setup_rx_handlers(struct il_priv *il) * 0 to 31 * * Rx Queue Indexes - * The host/firmware share two index registers for managing the Rx buffers. + * The host/firmware share two idx registers for managing the Rx buffers. * - * The READ index maps to the first position that the firmware may be writing + * The READ idx maps to the first position that the firmware may be writing * to -- the driver can read up to (but not including) this position and get * good data. - * The READ index is managed by the firmware once the card is enabled. + * The READ idx is managed by the firmware once the card is enabled. * - * The WRITE index maps to the last position the driver has read from -- the + * The WRITE idx maps to the last position the driver has read from -- the * position preceding WRITE is the last slot the firmware can place a packet. * * The queue is empty (no good data) if WRITE = READ - 1, and is full if @@ -905,9 +905,9 @@ static void il3945_setup_rx_handlers(struct il_priv *il) * During initialization, the host sets up the READ queue position to the first * IDX position, and WRITE to the last (READ - 1 wrapped) * - * When the firmware places a packet in a buffer, it will advance the READ index - * and fire the RX interrupt. The driver can then query the READ index and - * process as many packets as possible, moving the WRITE index forward as it + * When the firmware places a packet in a buffer, it will advance the READ idx + * and fire the RX interrupt. The driver can then query the READ idx and + * process as many packets as possible, moving the WRITE idx forward as it * resets the Rx queue buffers with new memory. * * The management in the driver is as follows: @@ -916,9 +916,9 @@ static void il3945_setup_rx_handlers(struct il_priv *il) * to replenish the iwl->rxq->rx_free. * + In il3945_rx_replenish (scheduled) if 'processed' != 'read' then the * iwl->rxq is replenished and the READ IDX is updated (updating the - * 'processed' and 'read' driver indexes as well) + * 'processed' and 'read' driver idxes as well) * + A received packet is processed and handed to the kernel network stack, - * detached from the iwl->rxq. The driver 'processed' index is updated. + * detached from the iwl->rxq. The driver 'processed' idx is updated. * + The Host/Firmware iwl->rxq is replenished at tasklet time from the rx_free * list. If there are no allocated buffers in iwl->rxq->rx_free, the READ * IDX is not incremented and iwl->status(RX_STALLED) is set. If there @@ -931,7 +931,7 @@ static void il3945_setup_rx_handlers(struct il_priv *il) * il3945_rx_queue_restock * il3945_rx_queue_restock() Moves available buffers from rx_free into Rx * queue, updates firmware pointers, and updates - * the WRITE index. If insufficient rx_free buffers + * the WRITE idx. If insufficient rx_free buffers * are available, schedules il3945_rx_replenish * * -- enable interrupts -- @@ -960,7 +960,7 @@ static inline __le32 il3945_dma_addr2rbd_ptr(struct il_priv *il, * and we have free pre-allocated buffers, fill the ranks as much * as we can, pulling from rx_free. * - * This moves the 'write' index forward to catch up with 'processed', and + * This moves the 'write' idx forward to catch up with 'processed', and * also updates the memory address in the firmware to reference the new * target buffer. */ @@ -1211,7 +1211,7 @@ static void il3945_rx_handle(struct il_priv *il) u32 count = 8; int total_empty = 0; - /* uCode's read index (stored in shared DRAM) indicates the last Rx + /* uCode's read idx (stored in shared DRAM) indicates the last Rx * buffer that the driver may process (last buffer filled by ucode). */ r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF; i = rxq->read; @@ -1656,7 +1656,7 @@ static void il3945_init_hw_rates(struct il_priv *il, for (i = 0; i < RATE_COUNT_LEGACY; i++) { rates[i].bitrate = il3945_rates[i].ieee * 5; - rates[i].hw_value = i; /* Rate scaling will work on indexes */ + rates[i].hw_value = i; /* Rate scaling will work on idxes */ rates[i].hw_value_short = i; rates[i].flags = 0; if (i > IL39_LAST_OFDM_RATE || i < IL_FIRST_OFDM_RATE) { @@ -1850,7 +1850,7 @@ IL3945_UCODE_GET(boot_size); static int il3945_read_ucode(struct il_priv *il) { const struct il_ucode_header *ucode; - int ret = -EINVAL, index; + int ret = -EINVAL, idx; const struct firmware *ucode_raw; /* firmware file name contains uCode/driver compatibility version */ const char *name_pre = il->cfg->fw_name_pre; @@ -1863,8 +1863,8 @@ static int il3945_read_ucode(struct il_priv *il) /* Ask kernel firmware_class module to get the boot firmware off disk. * request_firmware() is synchronous, file is in memory on return. */ - for (index = api_max; index >= api_min; index--) { - sprintf(buf, "%s%u%s", name_pre, index, ".ucode"); + for (idx = api_max; idx >= api_min; idx--) { + sprintf(buf, "%s%u%s", name_pre, idx, ".ucode"); ret = request_firmware(&ucode_raw, buf, &il->pci_dev->dev); if (ret < 0) { IL_ERR("%s firmware file req failed: %d\n", @@ -1874,7 +1874,7 @@ static int il3945_read_ucode(struct il_priv *il) else goto error; } else { - if (index < api_max) + if (idx < api_max) IL_ERR("Loaded firmware %s, " "which is deprecated. " " Please use API v%u instead.\n", diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index bc5a0080b9d3..afdec783333c 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -173,7 +173,7 @@ static void il4965_set_beacon_tim(struct il_priv *il, struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)beacon; /* - * The index is relative to frame start but we start looking at the + * The idx is relative to frame start but we start looking at the * variable-length part of the beacon. */ tim_idx = mgmt->u.beacon.variable - beacon; @@ -318,7 +318,7 @@ static inline u8 il4965_tfd_get_num_tbs(struct il_tfd *tfd) * @il - driver ilate data * @txq - tx queue * - * Does NOT advance any TFD circular buffer read/write indexes + * Does NOT advance any TFD circular buffer read/write idxes * Does NOT free the TFD itself (which is within circular buffer) */ void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) @@ -326,11 +326,11 @@ void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) struct il_tfd *tfd_tmp = (struct il_tfd *)txq->tfds; struct il_tfd *tfd; struct pci_dev *dev = il->pci_dev; - int index = txq->q.read_ptr; + int idx = txq->q.read_ptr; int i; int num_tbs; - tfd = &tfd_tmp[index]; + tfd = &tfd_tmp[idx]; /* Sanity check on number of chunks */ num_tbs = il4965_tfd_get_num_tbs(tfd); @@ -344,8 +344,8 @@ void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) /* Unmap tx_cmd */ if (num_tbs) pci_unmap_single(dev, - dma_unmap_addr(&txq->meta[index], mapping), - dma_unmap_len(&txq->meta[index], len), + dma_unmap_addr(&txq->meta[idx], mapping), + dma_unmap_len(&txq->meta[idx], len), PCI_DMA_BIDIRECTIONAL); /* Unmap chunks, if any. */ @@ -643,7 +643,7 @@ void il4965_rx_handle(struct il_priv *il) u32 count = 8; int total_empty; - /* uCode's read index (stored in shared DRAM) indicates the last Rx + /* uCode's read idx (stored in shared DRAM) indicates the last Rx * buffer that the driver may process (last buffer filled by ucode). */ r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF; i = rxq->read; @@ -1106,14 +1106,14 @@ static int __must_check il4965_request_firmware(struct il_priv *il, bool first) char tag[8]; if (first) { - il->fw_index = il->cfg->ucode_api_max; - sprintf(tag, "%d", il->fw_index); + il->fw_idx = il->cfg->ucode_api_max; + sprintf(tag, "%d", il->fw_idx); } else { - il->fw_index--; - sprintf(tag, "%d", il->fw_index); + il->fw_idx--; + sprintf(tag, "%d", il->fw_idx); } - if (il->fw_index < il->cfg->ucode_api_min) { + if (il->fw_idx < il->cfg->ucode_api_min) { IL_ERR("no suitable firmware found!\n"); return -ENOENT; } @@ -1213,7 +1213,7 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) memset(&pieces, 0, sizeof(pieces)); if (!ucode_raw) { - if (il->fw_index <= il->cfg->ucode_api_max) + if (il->fw_idx <= il->cfg->ucode_api_max) IL_ERR( "request for firmware file '%s' failed.\n", il->firmware_name); @@ -1655,7 +1655,7 @@ static int il4965_alive_notify(struct il_priv *il) /* Initialize each Tx queue (including the command queue) */ for (i = 0; i < il->hw_params.max_txq_num; i++) { - /* TFD circular buffer read/write indexes */ + /* TFD circular buffer read/write idxes */ il_wr_prph(il, IL49_SCD_QUEUE_RDPTR(i), 0); il_wr(il, HBUS_TARG_WRPTR, 0 | (i << 8)); @@ -2713,7 +2713,7 @@ static void il4965_init_hw_rates(struct il_priv *il, for (i = 0; i < RATE_COUNT_LEGACY; i++) { rates[i].bitrate = il_rates[i].ieee * 5; - rates[i].hw_value = i; /* Rate scaling will work on indexes */ + rates[i].hw_value = i; /* Rate scaling will work on idxes */ rates[i].hw_value_short = i; rates[i].flags = 0; if ((i >= IL_FIRST_CCK_RATE) && (i <= IL_LAST_CCK_RATE)) { @@ -2729,11 +2729,11 @@ static void il4965_init_hw_rates(struct il_priv *il, /* * Acquire il->lock before calling this function ! */ -void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 index) +void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx) { il_wr(il, HBUS_TARG_WRPTR, - (index & 0xff) | (txq_id << 8)); - il_wr_prph(il, IL49_SCD_QUEUE_RDPTR(txq_id), index); + (idx & 0xff) | (txq_id << 8)); + il_wr_prph(il, IL49_SCD_QUEUE_RDPTR(txq_id), idx); } void il4965_tx_queue_set_status(struct il_priv *il, -- cgit v1.2.3 From 3b98c7f49b675eb13e723967cf1264e3d562c480 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 26 Aug 2011 16:29:35 +0200 Subject: iwlegacy: s/TABLE/TBL/ Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-3945-fh.h | 32 ++++++++-------- drivers/net/wireless/iwlegacy/iwl-3945.c | 52 +++++++++++++------------- drivers/net/wireless/iwlegacy/iwl-4965-calib.c | 6 +-- drivers/net/wireless/iwlegacy/iwl-4965-rs.c | 8 ++-- drivers/net/wireless/iwlegacy/iwl-4965.c | 6 +-- drivers/net/wireless/iwlegacy/iwl-commands.h | 44 +++++++++++----------- drivers/net/wireless/iwlegacy/iwl-csr.h | 2 +- drivers/net/wireless/iwlegacy/iwl-dev.h | 2 +- drivers/net/wireless/iwlegacy/iwl-hcmd.c | 4 +- drivers/net/wireless/iwlegacy/iwl-legacy-rs.h | 30 +++++++-------- drivers/net/wireless/iwlegacy/iwl-power.c | 2 +- drivers/net/wireless/iwlegacy/iwl-prph.h | 4 +- drivers/net/wireless/iwlegacy/iwl-sta.c | 2 +- drivers/net/wireless/iwlegacy/iwl3945-base.c | 2 +- drivers/net/wireless/iwlegacy/iwl4965-base.c | 2 +- 15 files changed, 99 insertions(+), 99 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-fh.h b/drivers/net/wireless/iwlegacy/iwl-3945-fh.h index b98cabb2ee10..aa44a9036201 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945-fh.h +++ b/drivers/net/wireless/iwlegacy/iwl-3945-fh.h @@ -74,25 +74,25 @@ #define FH39_MEM_LOWER_BOUND (0x0800) #define FH39_MEM_UPPER_BOUND (0x1000) -#define FH39_CBCC_TABLE (FH39_MEM_LOWER_BOUND + 0x140) -#define FH39_TFDB_TABLE (FH39_MEM_LOWER_BOUND + 0x180) -#define FH39_RCSR_TABLE (FH39_MEM_LOWER_BOUND + 0x400) -#define FH39_RSSR_TABLE (FH39_MEM_LOWER_BOUND + 0x4c0) -#define FH39_TCSR_TABLE (FH39_MEM_LOWER_BOUND + 0x500) -#define FH39_TSSR_TABLE (FH39_MEM_LOWER_BOUND + 0x680) +#define FH39_CBCC_TBL (FH39_MEM_LOWER_BOUND + 0x140) +#define FH39_TFDB_TBL (FH39_MEM_LOWER_BOUND + 0x180) +#define FH39_RCSR_TBL (FH39_MEM_LOWER_BOUND + 0x400) +#define FH39_RSSR_TBL (FH39_MEM_LOWER_BOUND + 0x4c0) +#define FH39_TCSR_TBL (FH39_MEM_LOWER_BOUND + 0x500) +#define FH39_TSSR_TBL (FH39_MEM_LOWER_BOUND + 0x680) /* TFDB (Transmit Frame Buffer Descriptor) */ -#define FH39_TFDB(_ch, buf) (FH39_TFDB_TABLE + \ +#define FH39_TFDB(_ch, buf) (FH39_TFDB_TBL + \ ((_ch) * 2 + (buf)) * 0x28) -#define FH39_TFDB_CHNL_BUF_CTRL_REG(_ch) (FH39_TFDB_TABLE + 0x50 * (_ch)) +#define FH39_TFDB_CHNL_BUF_CTRL_REG(_ch) (FH39_TFDB_TBL + 0x50 * (_ch)) /* CBCC channel is [0,2] */ -#define FH39_CBCC(_ch) (FH39_CBCC_TABLE + (_ch) * 0x8) +#define FH39_CBCC(_ch) (FH39_CBCC_TBL + (_ch) * 0x8) #define FH39_CBCC_CTRL(_ch) (FH39_CBCC(_ch) + 0x00) #define FH39_CBCC_BASE(_ch) (FH39_CBCC(_ch) + 0x04) /* RCSR channel is [0,2] */ -#define FH39_RCSR(_ch) (FH39_RCSR_TABLE + (_ch) * 0x40) +#define FH39_RCSR(_ch) (FH39_RCSR_TBL + (_ch) * 0x40) #define FH39_RCSR_CONFIG(_ch) (FH39_RCSR(_ch) + 0x00) #define FH39_RCSR_RBD_BASE(_ch) (FH39_RCSR(_ch) + 0x04) #define FH39_RCSR_WPTR(_ch) (FH39_RCSR(_ch) + 0x20) @@ -101,19 +101,19 @@ #define FH39_RSCSR_CHNL0_WPTR (FH39_RCSR_WPTR(0)) /* RSSR */ -#define FH39_RSSR_CTRL (FH39_RSSR_TABLE + 0x000) -#define FH39_RSSR_STATUS (FH39_RSSR_TABLE + 0x004) +#define FH39_RSSR_CTRL (FH39_RSSR_TBL + 0x000) +#define FH39_RSSR_STATUS (FH39_RSSR_TBL + 0x004) /* TCSR */ -#define FH39_TCSR(_ch) (FH39_TCSR_TABLE + (_ch) * 0x20) +#define FH39_TCSR(_ch) (FH39_TCSR_TBL + (_ch) * 0x20) #define FH39_TCSR_CONFIG(_ch) (FH39_TCSR(_ch) + 0x00) #define FH39_TCSR_CREDIT(_ch) (FH39_TCSR(_ch) + 0x04) #define FH39_TCSR_BUFF_STTS(_ch) (FH39_TCSR(_ch) + 0x08) /* TSSR */ -#define FH39_TSSR_CBB_BASE (FH39_TSSR_TABLE + 0x000) -#define FH39_TSSR_MSG_CONFIG (FH39_TSSR_TABLE + 0x008) -#define FH39_TSSR_TX_STATUS (FH39_TSSR_TABLE + 0x010) +#define FH39_TSSR_CBB_BASE (FH39_TSSR_TBL + 0x000) +#define FH39_TSSR_MSG_CONFIG (FH39_TSSR_TBL + 0x008) +#define FH39_TSSR_TX_STATUS (FH39_TSSR_TBL + 0x010) /* DBM */ diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c index 96a762804944..b6abf3473fac 100644 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ b/drivers/net/wireless/iwlegacy/iwl-3945.c @@ -60,8 +60,8 @@ RATE_##rn##M_IDX, \ RATE_##pp##M_IDX, \ RATE_##np##M_IDX, \ - RATE_##r##M_IDX_TABLE, \ - RATE_##ip##M_IDX_TABLE } + RATE_##r##M_IDX_TBL, \ + RATE_##ip##M_IDX_TBL } /* * Parameter order: @@ -1330,7 +1330,7 @@ static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_idx, /* use this channel group's 6Mbit clipping/saturation pwr, * but cap at regulatory scan power restriction (set during init * based on eeprom channel data) for this channel. */ - power = min(ch_info->scan_power, clip_pwrs[RATE_6M_IDX_TABLE]); + power = min(ch_info->scan_power, clip_pwrs[RATE_6M_IDX_TBL]); power = min(power, il->tx_power_user_lmt); scan_power_info->requested_power = power; @@ -1342,7 +1342,7 @@ static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_idx, * *idx*. */ power_idx = ch_info->power_info[rate_idx].power_table_idx - (power - ch_info->power_info - [RATE_6M_IDX_TABLE].requested_power) * 2; + [RATE_6M_IDX_TBL].requested_power) * 2; /* store reference idx that we use when adjusting *all* scan * powers. So we can accommodate user (all channel) or spectrum @@ -1394,7 +1394,7 @@ static int il3945_send_tx_power(struct il_priv *il) } if (!il_is_channel_valid(ch_info)) { - D_POWER("Not calling TX_PWR_TABLE_CMD on " + D_POWER("Not calling TX_PWR_TBL_CMD on " "non-Tx channel.\n"); return 0; } @@ -1428,7 +1428,7 @@ static int il3945_send_tx_power(struct il_priv *il) txpower.power[i].rate); } - return il_send_cmd_pdu(il, REPLY_TX_PWR_TABLE_CMD, + return il_send_cmd_pdu(il, REPLY_TX_PWR_TBL_CMD, sizeof(struct il3945_txpowertable_cmd), &txpower); @@ -1466,7 +1466,7 @@ static int il3945_hw_reg_set_new_power(struct il_priv *il, power_info = ch_info->power_info; /* update OFDM Txpower settings */ - for (i = RATE_6M_IDX_TABLE; i <= RATE_54M_IDX_TABLE; + for (i = RATE_6M_IDX_TBL; i <= RATE_54M_IDX_TBL; i++, ++power_info) { int delta_idx; @@ -1490,14 +1490,14 @@ static int il3945_hw_reg_set_new_power(struct il_priv *il, * ... all CCK power settings for a given channel are the *same*. */ if (power_changed) { power = - ch_info->power_info[RATE_12M_IDX_TABLE]. + ch_info->power_info[RATE_12M_IDX_TBL]. requested_power + IL_CCK_FROM_OFDM_POWER_DIFF; /* do all CCK rates' il3945_channel_power_info structures */ - for (i = RATE_1M_IDX_TABLE; i <= RATE_11M_IDX_TABLE; i++) { + for (i = RATE_1M_IDX_TBL; i <= RATE_11M_IDX_TBL; i++) { power_info->requested_power = power; power_info->base_power_idx = - ch_info->power_info[RATE_12M_IDX_TABLE]. + ch_info->power_info[RATE_12M_IDX_TBL]. base_power_idx + IL_CCK_FROM_OFDM_IDX_DIFF; ++power_info; } @@ -1597,7 +1597,7 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) for (scan_tbl_idx = 0; scan_tbl_idx < IL_NUM_SCAN_RATES; scan_tbl_idx++) { s32 actual_idx = (scan_tbl_idx == 0) ? - RATE_1M_IDX_TABLE : RATE_6M_IDX_TABLE; + RATE_1M_IDX_TBL : RATE_6M_IDX_TBL; il3945_hw_reg_set_scan_power(il, scan_tbl_idx, actual_idx, clip_pwrs, ch_info, a_band); @@ -2012,19 +2012,19 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *il) for (rate_idx = 0; rate_idx < RATE_COUNT_3945; rate_idx++, clip_pwrs++) { switch (rate_idx) { - case RATE_36M_IDX_TABLE: + case RATE_36M_IDX_TBL: if (i == 0) /* B/G */ *clip_pwrs = satur_pwr; else /* A */ *clip_pwrs = satur_pwr - 5; break; - case RATE_48M_IDX_TABLE: + case RATE_48M_IDX_TBL: if (i == 0) *clip_pwrs = satur_pwr - 7; else *clip_pwrs = satur_pwr - 10; break; - case RATE_54M_IDX_TABLE: + case RATE_54M_IDX_TBL: if (i == 0) *clip_pwrs = satur_pwr - 9; else @@ -2139,7 +2139,7 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) } /* set tx power for CCK rates, based on OFDM 12 Mbit settings*/ - pwr_info = &ch_info->power_info[RATE_12M_IDX_TABLE]; + pwr_info = &ch_info->power_info[RATE_12M_IDX_TBL]; power = pwr_info->requested_power + IL_CCK_FROM_OFDM_POWER_DIFF; pwr_idx = pwr_info->power_table_idx + @@ -2169,7 +2169,7 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) for (scan_tbl_idx = 0; scan_tbl_idx < IL_NUM_SCAN_RATES; scan_tbl_idx++) { s32 actual_idx = (scan_tbl_idx == 0) ? - RATE_1M_IDX_TABLE : RATE_6M_IDX_TABLE; + RATE_1M_IDX_TBL : RATE_6M_IDX_TBL; il3945_hw_reg_set_scan_power(il, scan_tbl_idx, actual_idx, clip_pwrs, ch_info, a_band); } @@ -2223,7 +2223,7 @@ static u16 il3945_get_hcmd_size(u8 cmd_id, u16 len) switch (cmd_id) { case REPLY_RXON: return sizeof(struct il3945_rxon_cmd); - case POWER_TABLE_CMD: + case POWER_TBL_CMD: return sizeof(struct il3945_powertable_cmd); default: return len; @@ -2326,17 +2326,17 @@ int il3945_init_hw_rate_table(struct il_priv *il) D_RATE("Select A mode rate scale\n"); /* If one of the following CCK rates is used, * have it fall back to the 6M OFDM rate */ - for (i = RATE_1M_IDX_TABLE; - i <= RATE_11M_IDX_TABLE; i++) + for (i = RATE_1M_IDX_TBL; + i <= RATE_11M_IDX_TBL; i++) table[i].next_rate_idx = il3945_rates[IL_FIRST_OFDM_RATE].table_rs_idx; /* Don't fall back to CCK rates */ - table[RATE_12M_IDX_TABLE].next_rate_idx = - RATE_9M_IDX_TABLE; + table[RATE_12M_IDX_TBL].next_rate_idx = + RATE_9M_IDX_TBL; /* Don't drop out of OFDM rates */ - table[RATE_6M_IDX_TABLE].next_rate_idx = + table[RATE_6M_IDX_TBL].next_rate_idx = il3945_rates[IL_FIRST_OFDM_RATE].table_rs_idx; break; @@ -2349,14 +2349,14 @@ int il3945_init_hw_rate_table(struct il_priv *il) il_is_associated(il)) { idx = IL_FIRST_CCK_RATE; - for (i = RATE_6M_IDX_TABLE; - i <= RATE_54M_IDX_TABLE; i++) + for (i = RATE_6M_IDX_TBL; + i <= RATE_54M_IDX_TBL; i++) table[i].next_rate_idx = il3945_rates[idx].table_rs_idx; - idx = RATE_11M_IDX_TABLE; + idx = RATE_11M_IDX_TBL; /* CCK shouldn't fall back to OFDM... */ - table[idx].next_rate_idx = RATE_5M_IDX_TABLE; + table[idx].next_rate_idx = RATE_5M_IDX_TBL; } break; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c index d622b2781088..1d873a68830e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c @@ -429,18 +429,18 @@ static int il4965_sensitivity_write(struct il_priv *il) il4965_prepare_legacy_sensitivity_tbl(il, data, &cmd.table[0]); /* Update uCode's "work" table, and copy it to DSP */ - cmd.control = SENSITIVITY_CMD_CONTROL_WORK_TABLE; + cmd.control = SENSITIVITY_CMD_CONTROL_WORK_TBL; /* Don't send command to uCode if nothing has changed */ if (!memcmp(&cmd.table[0], &(il->sensitivity_tbl[0]), - sizeof(u16)*HD_TABLE_SIZE)) { + sizeof(u16)*HD_TBL_SIZE)) { D_CALIB("No change in SENSITIVITY_CMD\n"); return 0; } /* Copy table for comparison next time */ memcpy(&(il->sensitivity_tbl[0]), &(cmd.table[0]), - sizeof(u16)*HD_TABLE_SIZE); + sizeof(u16)*HD_TBL_SIZE); return il_send_cmd(il, &cmd_out); } diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c index b8f80641f788..4a543114372b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c @@ -1001,11 +1001,11 @@ static void il4965_rs_set_stay_in_table(struct il_priv *il, u8 is_legacy, D_RATE("we are staying in the same table\n"); lq_sta->stay_in_tbl = 1; /* only place this gets set */ if (is_legacy) { - lq_sta->table_count_limit = IL_LEGACY_TABLE_COUNT; + lq_sta->table_count_limit = IL_LEGACY_TBL_COUNT; lq_sta->max_failure_limit = IL_LEGACY_FAILURE_LIMIT; lq_sta->max_success_limit = IL_LEGACY_SUCCESS_LIMIT; } else { - lq_sta->table_count_limit = IL_NONE_LEGACY_TABLE_COUNT; + lq_sta->table_count_limit = IL_NONE_LEGACY_TBL_COUNT; lq_sta->max_failure_limit = IL_NONE_LEGACY_FAILURE_LIMIT; lq_sta->max_success_limit = IL_NONE_LEGACY_SUCCESS_LIMIT; } @@ -1916,7 +1916,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, * continuing to use the setup that we've been trying. */ if (win->average_tpt > lq_sta->last_tpt) { - D_RATE("LQ: SWITCHING TO NEW TABLE " + D_RATE("LQ: SWITCHING TO NEW TBL " "suc=%d cur-tpt=%d old-tpt=%d\n", win->success_ratio, win->average_tpt, @@ -1932,7 +1932,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Else poor success; go back to mode in "active" table */ } else { - D_RATE("LQ: GOING BACK TO THE OLD TABLE " + D_RATE("LQ: GOING BACK TO THE OLD TBL " "suc=%d cur-tpt=%d old-tpt=%d\n", win->success_ratio, win->average_tpt, diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c index 8fd383ea58b8..bdfb3a616fdc 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965.c @@ -1010,7 +1010,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, } /* for each of 33 bit-rates (including 1 for CCK) */ - for (i = 0; i < POWER_TABLE_NUM_ENTRIES; i++) { + for (i = 0; i < POWER_TBL_NUM_ENTRIES; i++) { u8 is_mimo_rate; union il4965_tx_power_dual_stream tx_power; @@ -1072,7 +1072,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, power_idx += 9; /* CCK, rate 32, reduce txpower for CCK */ - if (i == POWER_TABLE_CCK_ENTRY) + if (i == POWER_TBL_CCK_ENTRY) power_idx += IL_TX_POWER_CCK_COMPENSATION_C_STEP; @@ -1144,7 +1144,7 @@ static int il4965_send_tx_power(struct il_priv *il) goto out; ret = il_send_cmd_pdu(il, - REPLY_TX_PWR_TABLE_CMD, sizeof(cmd), &cmd); + REPLY_TX_PWR_TBL_CMD, sizeof(cmd), &cmd); out: return ret; diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h index 408391295fbd..e6688b166ada 100644 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ b/drivers/net/wireless/iwlegacy/iwl-commands.h @@ -114,7 +114,7 @@ enum { SPECTRUM_MEASURE_NOTIFICATION = 0x75, /* Power Management */ - POWER_TABLE_CMD = 0x77, + POWER_TBL_CMD = 0x77, PM_SLEEP_NOTIFICATION = 0x7A, PM_DEBUG_STATISTIC_NOTIFIC = 0x7B, @@ -130,7 +130,7 @@ enum { REPLY_TX_BEACON = 0x91, /* Miscellaneous commands */ - REPLY_TX_PWR_TABLE_CMD = 0x97, + REPLY_TX_PWR_TBL_CMD = 0x97, /* Bluetooth device coexistence config command */ REPLY_BT_CONFIG = 0x9b, @@ -214,7 +214,7 @@ struct il_cmd_header { /** * struct il3945_tx_power * - * Used in REPLY_TX_PWR_TABLE_CMD, REPLY_SCAN_CMD, REPLY_CHANNEL_SWITCH + * Used in REPLY_TX_PWR_TBL_CMD, REPLY_SCAN_CMD, REPLY_CHANNEL_SWITCH * * Each entry contains two values: * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained @@ -233,7 +233,7 @@ struct il3945_tx_power { /** * struct il3945_power_per_rate * - * Used in REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH + * Used in REPLY_TX_PWR_TBL_CMD, REPLY_CHANNEL_SWITCH */ struct il3945_power_per_rate { u8 rate; /* plcp */ @@ -326,9 +326,9 @@ struct il3945_power_per_rate { #define RATE_MCS_ANT_ABC_MSK (RATE_MCS_ANT_AB_MSK | RATE_MCS_ANT_C_MSK) #define RATE_ANT_NUM 3 -#define POWER_TABLE_NUM_ENTRIES 33 -#define POWER_TABLE_NUM_HT_OFDM_ENTRIES 32 -#define POWER_TABLE_CCK_ENTRY 32 +#define POWER_TBL_NUM_ENTRIES 33 +#define POWER_TBL_NUM_HT_OFDM_ENTRIES 32 +#define POWER_TBL_CCK_ENTRY 32 #define IL_PWR_NUM_HT_OFDM_ENTRIES 24 #define IL_PWR_CCK_ENTRIES 2 @@ -336,7 +336,7 @@ struct il3945_power_per_rate { /** * union il4965_tx_power_dual_stream * - * Host format used for REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH + * Host format used for REPLY_TX_PWR_TBL_CMD, REPLY_CHANNEL_SWITCH * Use __le32 version (struct tx_power_dual_stream) when building command. * * Driver provides radio gain and DSP attenuation settings to device in pairs, @@ -360,7 +360,7 @@ union il4965_tx_power_dual_stream { /** * struct tx_power_dual_stream * - * Table entries in REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH + * Table entries in REPLY_TX_PWR_TBL_CMD, REPLY_CHANNEL_SWITCH * * Same format as il_tx_power_dual_stream, but __le32 */ @@ -371,10 +371,10 @@ struct tx_power_dual_stream { /** * struct il4965_tx_power_db * - * Entire table within REPLY_TX_PWR_TABLE_CMD, REPLY_CHANNEL_SWITCH + * Entire table within REPLY_TX_PWR_TBL_CMD, REPLY_CHANNEL_SWITCH */ struct il4965_tx_power_db { - struct tx_power_dual_stream power_tbl[POWER_TABLE_NUM_ENTRIES]; + struct tx_power_dual_stream power_tbl[POWER_TBL_NUM_ENTRIES]; } __packed; /****************************************************************************** @@ -653,7 +653,7 @@ enum { * channel. * * NOTE: All RXONs wipe clean the internal txpower table. Driver must - * issue a new REPLY_TX_PWR_TABLE_CMD after each REPLY_RXON (0x10), + * issue a new REPLY_TX_PWR_TBL_CMD after each REPLY_RXON (0x10), * regardless of whether RXON_FILTER_ASSOC_MSK is set. */ @@ -1067,7 +1067,7 @@ struct il_addsta_cmd { #define ADD_STA_SUCCESS_MSK 0x1 -#define ADD_STA_NO_ROOM_IN_TABLE 0x2 +#define ADD_STA_NO_ROOM_IN_TBL 0x2 #define ADD_STA_NO_BLOCK_ACK_RESOURCE 0x4 #define ADD_STA_MODIFY_NON_EXIST_STA 0x8 /* @@ -1271,7 +1271,7 @@ struct il_rx_mpdu_res_start { * command, as set up by the REPLY_RATE_SCALE (for 3945) or * REPLY_TX_LINK_QUALITY_CMD (4965). * - * Driver sets up transmit power for various rates via REPLY_TX_PWR_TABLE_CMD. + * Driver sets up transmit power for various rates via REPLY_TX_PWR_TBL_CMD. * This command must be executed after every RXON command, before Tx can occur. *****************************************************************************/ @@ -1754,7 +1754,7 @@ struct il_compressed_ba_resp { } __packed; /* - * REPLY_TX_PWR_TABLE_CMD = 0x97 (command, has simple generic response) + * REPLY_TX_PWR_TBL_CMD = 0x97 (command, has simple generic response) * * See details under "TXPOWER" in iwl-4965-hw.h. */ @@ -1909,7 +1909,7 @@ struct il_link_qual_agg_params { * procedures are possible, and may work better for particular environments. * * - * FILLING THE RATE TABLE + * FILLING THE RATE TBL * * Given a particular initial rate and mode, as determined by the rate * scaling algorithm described below, the Linux driver uses the following @@ -2263,7 +2263,7 @@ struct il_spectrum_notification { * struct il_powertable_cmd - Power Table Command * @flags: See below: * - * POWER_TABLE_CMD = 0x77 (command, has simple generic response) + * POWER_TBL_CMD = 0x77 (command, has simple generic response) * * PM allow: * bit 0 - '0' Driver not allow power management @@ -2290,7 +2290,7 @@ struct il_spectrum_notification { * '10' force xtal sleep * '11' Illegal set * - * NOTE: if sleep_interval[SLEEP_INTRVL_TABLE_SIZE-1] > DTIM period then + * NOTE: if sleep_interval[SLEEP_INTRVL_TBL_SIZE-1] > DTIM period then * ucode assume sleep over DTIM is allowed and we don't need to wake up * for every DTIM. */ @@ -3219,7 +3219,7 @@ struct il_missed_beacon_notif { /* * Table entries in SENSITIVITY_CMD (struct il_sensitivity_cmd) */ -#define HD_TABLE_SIZE (11) /* number of entries */ +#define HD_TBL_SIZE (11) /* number of entries */ #define HD_MIN_ENERGY_CCK_DET_IDX (0) /* table idxes */ #define HD_MIN_ENERGY_OFDM_DET_IDX (1) #define HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX (2) @@ -3233,8 +3233,8 @@ struct il_missed_beacon_notif { #define HD_OFDM_ENERGY_TH_IN_IDX (10) /* Control field in struct il_sensitivity_cmd */ -#define SENSITIVITY_CMD_CONTROL_DEFAULT_TABLE cpu_to_le16(0) -#define SENSITIVITY_CMD_CONTROL_WORK_TABLE cpu_to_le16(1) +#define SENSITIVITY_CMD_CONTROL_DEFAULT_TBL cpu_to_le16(0) +#define SENSITIVITY_CMD_CONTROL_WORK_TBL cpu_to_le16(1) /** * struct il_sensitivity_cmd @@ -3245,7 +3245,7 @@ struct il_missed_beacon_notif { */ struct il_sensitivity_cmd { __le16 control; /* always use "1" */ - __le16 table[HD_TABLE_SIZE]; /* use HD_* as idx */ + __le16 table[HD_TBL_SIZE]; /* use HD_* as idx */ } __packed; diff --git a/drivers/net/wireless/iwlegacy/iwl-csr.h b/drivers/net/wireless/iwlegacy/iwl-csr.h index 34edec329367..4db04297560c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-csr.h +++ b/drivers/net/wireless/iwlegacy/iwl-csr.h @@ -357,7 +357,7 @@ /* HPET MEM debug */ #define CSR_DBG_HPET_MEM_REG_VAL (0xFFFF0000) -/* DRAM INT TABLE */ +/* DRAM INT TBL */ #define CSR_DRAM_INT_TBL_ENABLE (1 << 31) #define CSR_DRAM_INIT_TBL_WRAP_CHECK (1 << 27) diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 2555f9fe9be2..7c86d198e89d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -1060,7 +1060,7 @@ struct il_priv { u8 start_calib; struct il_sensitivity_data sensitivity_data; struct il_chain_noise_data chain_noise_data; - __le16 sensitivity_tbl[HD_TABLE_SIZE]; + __le16 sensitivity_tbl[HD_TBL_SIZE]; struct il_ht_config current_ht_config; diff --git a/drivers/net/wireless/iwlegacy/iwl-hcmd.c b/drivers/net/wireless/iwlegacy/iwl-hcmd.c index e63777b2f6e9..0b11f2f549ca 100644 --- a/drivers/net/wireless/iwlegacy/iwl-hcmd.c +++ b/drivers/net/wireless/iwlegacy/iwl-hcmd.c @@ -58,7 +58,7 @@ const char *il_get_cmd_string(u8 cmd) IL_CMD(CHANNEL_SWITCH_NOTIFICATION); IL_CMD(REPLY_SPECTRUM_MEASUREMENT_CMD); IL_CMD(SPECTRUM_MEASURE_NOTIFICATION); - IL_CMD(POWER_TABLE_CMD); + IL_CMD(POWER_TBL_CMD); IL_CMD(PM_SLEEP_NOTIFICATION); IL_CMD(PM_DEBUG_STATISTIC_NOTIFIC); IL_CMD(REPLY_SCAN_CMD); @@ -68,7 +68,7 @@ const char *il_get_cmd_string(u8 cmd) IL_CMD(SCAN_COMPLETE_NOTIFICATION); IL_CMD(BEACON_NOTIFICATION); IL_CMD(REPLY_TX_BEACON); - IL_CMD(REPLY_TX_PWR_TABLE_CMD); + IL_CMD(REPLY_TX_PWR_TBL_CMD); IL_CMD(REPLY_BT_CONFIG); IL_CMD(REPLY_STATISTICS_CMD); IL_CMD(STATISTICS_NOTIFICATION); diff --git a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h index bc09a5dc6d89..58e04cb8b0ed 100644 --- a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h +++ b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h @@ -80,19 +80,19 @@ enum { }; enum { - RATE_6M_IDX_TABLE = 0, - RATE_9M_IDX_TABLE, - RATE_12M_IDX_TABLE, - RATE_18M_IDX_TABLE, - RATE_24M_IDX_TABLE, - RATE_36M_IDX_TABLE, - RATE_48M_IDX_TABLE, - RATE_54M_IDX_TABLE, - RATE_1M_IDX_TABLE, - RATE_2M_IDX_TABLE, - RATE_5M_IDX_TABLE, - RATE_11M_IDX_TABLE, - RATE_INVM_IDX_TABLE = RATE_INVM_IDX - 1, + RATE_6M_IDX_TBL = 0, + RATE_9M_IDX_TBL, + RATE_12M_IDX_TBL, + RATE_18M_IDX_TBL, + RATE_24M_IDX_TBL, + RATE_36M_IDX_TBL, + RATE_48M_IDX_TBL, + RATE_54M_IDX_TBL, + RATE_1M_IDX_TBL, + RATE_2M_IDX_TBL, + RATE_5M_IDX_TBL, + RATE_11M_IDX_TBL, + RATE_INVM_IDX_TBL = RATE_INVM_IDX - 1, }; enum { @@ -213,11 +213,11 @@ enum { * searching for a new modulation mode */ #define IL_LEGACY_FAILURE_LIMIT 160 #define IL_LEGACY_SUCCESS_LIMIT 480 -#define IL_LEGACY_TABLE_COUNT 160 +#define IL_LEGACY_TBL_COUNT 160 #define IL_NONE_LEGACY_FAILURE_LIMIT 400 #define IL_NONE_LEGACY_SUCCESS_LIMIT 4500 -#define IL_NONE_LEGACY_TABLE_COUNT 1500 +#define IL_NONE_LEGACY_TBL_COUNT 1500 /* Success ratio (ACKed / attempted tx frames) values (perfect is 128 * 100) */ #define IL_RS_GOOD_RATIO 12800 /* 100% */ diff --git a/drivers/net/wireless/iwlegacy/iwl-power.c b/drivers/net/wireless/iwlegacy/iwl-power.c index 6c6e5e70c96f..051623ab1147 100644 --- a/drivers/net/wireless/iwlegacy/iwl-power.c +++ b/drivers/net/wireless/iwlegacy/iwl-power.c @@ -88,7 +88,7 @@ il_set_power(struct il_priv *il, struct il_powertable_cmd *cmd) le32_to_cpu(cmd->sleep_interval[3]), le32_to_cpu(cmd->sleep_interval[4])); - return il_send_cmd_pdu(il, POWER_TABLE_CMD, + return il_send_cmd_pdu(il, POWER_TBL_CMD, sizeof(struct il_powertable_cmd), cmd); } diff --git a/drivers/net/wireless/iwlegacy/iwl-prph.h b/drivers/net/wireless/iwlegacy/iwl-prph.h index 8128c87262e9..e34d9073a99e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-prph.h +++ b/drivers/net/wireless/iwlegacy/iwl-prph.h @@ -189,7 +189,7 @@ * procedure. * * This save/restore method is mostly for autonomous power management during - * normal operation (result of POWER_TABLE_CMD). Platform suspend/resume and + * normal operation (result of POWER_TBL_CMD). Platform suspend/resume and * RFKILL should use complete restarts (with total re-initialization) of uCode, * allowing total shutdown (including BSM memory). * @@ -494,7 +494,7 @@ * When queue is in Scheduler-ACK mode, frames placed in a that queue must be * for only one combination of receiver address (RA) and traffic ID (TID), i.e. * one QOS priority level destined for one station (for this wireless link, - * not final destination). The SCD_TRANSLATE_TABLE area provides 16 16-bit + * not final destination). The SCD_TRANSLATE_TBL area provides 16 16-bit * mappings, one for each of the 16 queues. If queue is not in Scheduler-ACK * mode, the device ignores the mapping value. * diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.c b/drivers/net/wireless/iwlegacy/iwl-sta.c index a7fe9ea80aa5..ffb966bf836d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-sta.c @@ -83,7 +83,7 @@ static int il_process_add_sta_resp(struct il_priv *il, il_sta_ucode_activate(il, sta_id); ret = 0; break; - case ADD_STA_NO_ROOM_IN_TABLE: + case ADD_STA_NO_ROOM_IN_TBL: IL_ERR("Adding station %d failed, no room in table.\n", sta_id); break; diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 924420870a2f..41104e72d299 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -885,7 +885,7 @@ static void il3945_setup_rx_handlers(struct il_priv *il) * Rx theory of operation * * The host allocates 32 DMA target addresses and passes the host address - * to the firmware at register IL_RFDS_TABLE_LOWER + N * RFD_SIZE where N is + * to the firmware at register IL_RFDS_TBL_LOWER + N * RFD_SIZE where N is * 0 to 31 * * Rx Queue Indexes diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index afdec783333c..043d51e9d59e 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -1470,7 +1470,7 @@ static const char * const desc_lookup_text[] = { "HW_ERROR_TUNE_LOCK", "HW_ERROR_TEMPERATURE", "ILLEGAL_CHAN_FREQ", - "VCC_NOT_STABLE", + "VCC_NOT_STBL", "FH_ERROR", "NMI_INTERRUPT_HOST", "NMI_INTERRUPT_ACTION_PT", -- cgit v1.2.3 From 17d6e557359e0a4033bf0889e0b481519e145404 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 29 Aug 2011 12:52:20 +0200 Subject: iwlegacy: remove for_each_context We do not support many contexts. Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-4965-sta.c | 11 +- drivers/net/wireless/iwlegacy/iwl-core.c | 204 ++++++++++----------------- drivers/net/wireless/iwlegacy/iwl-debugfs.c | 28 ++-- drivers/net/wireless/iwlegacy/iwl-scan.c | 20 ++- drivers/net/wireless/iwlegacy/iwl-sta.h | 22 ++- drivers/net/wireless/iwlegacy/iwl3945-base.c | 4 +- drivers/net/wireless/iwlegacy/iwl4965-base.c | 52 +++---- 7 files changed, 127 insertions(+), 214 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c index 4cda277418f6..337bf0c1c4c2 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c @@ -615,16 +615,7 @@ static int il4965_update_bcast_station(struct il_priv *il, int il4965_update_bcast_stations(struct il_priv *il) { - struct il_rxon_context *ctx; - int ret = 0; - - for_each_context(il, ctx) { - ret = il4965_update_bcast_station(il, ctx); - if (ret) - break; - } - - return ret; + return il4965_update_bcast_station(il, &il->ctx); } /** diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index de952fb0a96f..bd222f50d26c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -646,10 +646,7 @@ static void _il_set_rxon_ht(struct il_priv *il, void il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf) { - struct il_rxon_context *ctx; - - for_each_context(il, ctx) - _il_set_rxon_ht(il, ht_conf, ctx); + _il_set_rxon_ht(il, ht_conf, &il->ctx); } EXPORT_SYMBOL(il_set_rxon_ht); @@ -661,7 +658,6 @@ u8 il_get_single_channel_number(struct il_priv *il, int i; u8 channel = 0; u8 min, max; - struct il_rxon_context *ctx; if (band == IEEE80211_BAND_5GHZ) { min = 14; @@ -672,19 +668,10 @@ u8 il_get_single_channel_number(struct il_priv *il, } for (i = min; i < max; i++) { - bool busy = false; - - for_each_context(il, ctx) { - busy = il->channel_info[i].channel == - le16_to_cpu(ctx->staging.channel); - if (busy) - break; - } - - if (busy) + channel = il->channel_info[i].channel; + if (channel == le16_to_cpu(il->ctx.staging.channel)) continue; - channel = il->channel_info[i].channel; ch_info = il_get_channel_info(il, band, channel); if (il_is_channel_valid(ch_info)) break; @@ -822,7 +809,6 @@ void il_set_rate(struct il_priv *il) { const struct ieee80211_supported_band *hw = NULL; struct ieee80211_rate *rate; - struct il_rxon_context *ctx; int i; hw = il_get_hw_mode(il, il->band); @@ -841,13 +827,11 @@ void il_set_rate(struct il_priv *il) D_RATE("Set active_rate = %0x\n", il->active_rate); - for_each_context(il, ctx) { - ctx->staging.cck_basic_rates = + il->ctx.staging.cck_basic_rates = (IL_CCK_BASIC_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; - ctx->staging.ofdm_basic_rates = + il->ctx.staging.ofdm_basic_rates = (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; - } } EXPORT_SYMBOL(il_set_rate); @@ -1254,7 +1238,6 @@ int il_mac_conf_tx(struct ieee80211_hw *hw, const struct ieee80211_tx_queue_params *params) { struct il_priv *il = hw->priv; - struct il_rxon_context *ctx; unsigned long flags; int q; @@ -1274,17 +1257,15 @@ int il_mac_conf_tx(struct ieee80211_hw *hw, spin_lock_irqsave(&il->lock, flags); - for_each_context(il, ctx) { - ctx->qos_data.def_qos_parm.ac[q].cw_min = + il->ctx.qos_data.def_qos_parm.ac[q].cw_min = cpu_to_le16(params->cw_min); - ctx->qos_data.def_qos_parm.ac[q].cw_max = + il->ctx.qos_data.def_qos_parm.ac[q].cw_max = cpu_to_le16(params->cw_max); - ctx->qos_data.def_qos_parm.ac[q].aifsn = params->aifs; - ctx->qos_data.def_qos_parm.ac[q].edca_txop = + il->ctx.qos_data.def_qos_parm.ac[q].aifsn = params->aifs; + il->ctx.qos_data.def_qos_parm.ac[q].edca_txop = cpu_to_le16((params->txop * 32)); - ctx->qos_data.def_qos_parm.ac[q].reserved1 = 0; - } + il->ctx.qos_data.def_qos_parm.ac[q].reserved1 = 0; spin_unlock_irqrestore(&il->lock, flags); @@ -1344,8 +1325,8 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { struct il_priv *il = hw->priv; struct il_vif_priv *vif_priv = (void *)vif->drv_priv; - struct il_rxon_context *tmp, *ctx = NULL; int err; + u32 modes; D_MAC80211("enter: type %d, addr %pM\n", vif->type, vif->addr); @@ -1358,42 +1339,29 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) goto out; } - for_each_context(il, tmp) { - u32 possible_modes = - tmp->interface_modes | tmp->exclusive_interface_modes; - - if (tmp->vif) { - /* check if this busy context is exclusive */ - if (tmp->exclusive_interface_modes & - BIT(tmp->vif->type)) { - err = -EINVAL; - goto out; - } - continue; - } - if (!(possible_modes & BIT(vif->type))) - continue; - - /* have maybe usable context w/o interface */ - ctx = tmp; - break; + /* check if busy context is exclusive */ + if (il->ctx.vif && + (il->ctx.exclusive_interface_modes & BIT(il->ctx.vif->type))) { + err = -EINVAL; + goto out; } - if (!ctx) { + modes = il->ctx.interface_modes | il->ctx.exclusive_interface_modes; + if (!(modes & BIT(vif->type))) { err = -EOPNOTSUPP; goto out; } - vif_priv->ctx = ctx; - ctx->vif = vif; + vif_priv->ctx = &il->ctx; + il->ctx.vif = vif; - err = il_setup_interface(il, ctx); - if (!err) - goto out; + err = il_setup_interface(il, &il->ctx); + if (err) { + il->ctx.vif = NULL; + il->iw_mode = NL80211_IFTYPE_STATION; + } - ctx->vif = NULL; - il->iw_mode = NL80211_IFTYPE_STATION; out: mutex_unlock(&il->mutex); @@ -1764,8 +1732,7 @@ il_mac_change_interface(struct ieee80211_hw *hw, { struct il_priv *il = hw->priv; struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - struct il_rxon_context *tmp; - u32 interface_modes; + u32 modes; int err; newtype = ieee80211_iftype_p2p(newtype, newp2p); @@ -1781,28 +1748,16 @@ il_mac_change_interface(struct ieee80211_hw *hw, goto out; } - interface_modes = ctx->interface_modes | ctx->exclusive_interface_modes; - - if (!(interface_modes & BIT(newtype))) { - err = -EBUSY; + modes = ctx->interface_modes | ctx->exclusive_interface_modes; + if (!(modes & BIT(newtype))) { + err = -EOPNOTSUPP; goto out; } - if (ctx->exclusive_interface_modes & BIT(newtype)) { - for_each_context(il, tmp) { - if (ctx == tmp) - continue; - - if (!tmp->vif) - continue; - - /* - * The current mode switch would be exclusive, but - * another context is active ... refuse the switch. - */ - err = -EBUSY; - goto out; - } + if ((il->ctx.exclusive_interface_modes & BIT(il->ctx.vif->type)) || + (il->ctx.exclusive_interface_modes & BIT(newtype))) { + err = -EINVAL; + goto out; } /* success */ @@ -2064,7 +2019,7 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) struct ieee80211_conf *conf = &hw->conf; struct ieee80211_channel *channel = conf->channel; struct il_ht_config *ht_conf = &il->current_ht_config; - struct il_rxon_context *ctx; + struct il_rxon_context *ctx = &il->ctx; unsigned long flags = 0; int ret = 0; u16 ch; @@ -2097,14 +2052,14 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) * configured. */ if (il->cfg->ops->hcmd->set_rxon_chain) - for_each_context(il, ctx) - il->cfg->ops->hcmd->set_rxon_chain(il, ctx); + il->cfg->ops->hcmd->set_rxon_chain(il, &il->ctx); } /* during scanning mac80211 will delay channel setting until * scan finish with changed = 0 */ if (!changed || (changed & IEEE80211_CONF_CHANGE_CHANNEL)) { + if (scan_active) goto set_ch_out; @@ -2125,48 +2080,46 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) spin_lock_irqsave(&il->lock, flags); - for_each_context(il, ctx) { - /* Configure HT40 channels */ - if (ctx->ht.enabled != conf_is_ht(conf)) { - ctx->ht.enabled = conf_is_ht(conf); - ht_changed = true; - } - if (ctx->ht.enabled) { - if (conf_is_ht40_minus(conf)) { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_BELOW; - ctx->ht.is_40mhz = true; - } else if (conf_is_ht40_plus(conf)) { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_ABOVE; - ctx->ht.is_40mhz = true; - } else { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_NONE; - ctx->ht.is_40mhz = false; - } - } else + /* Configure HT40 channels */ + if (ctx->ht.enabled != conf_is_ht(conf)) { + ctx->ht.enabled = conf_is_ht(conf); + ht_changed = true; + } + if (ctx->ht.enabled) { + if (conf_is_ht40_minus(conf)) { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_BELOW; + ctx->ht.is_40mhz = true; + } else if (conf_is_ht40_plus(conf)) { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_ABOVE; + ctx->ht.is_40mhz = true; + } else { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_NONE; ctx->ht.is_40mhz = false; + } + } else + ctx->ht.is_40mhz = false; - /* - * Default to no protection. Protection mode will - * later be set from BSS config in il_ht_conf - */ - ctx->ht.protection = - IEEE80211_HT_OP_MODE_PROTECTION_NONE; + /* + * Default to no protection. Protection mode will + * later be set from BSS config in il_ht_conf + */ + ctx->ht.protection = + IEEE80211_HT_OP_MODE_PROTECTION_NONE; - /* if we are switching from ht to 2.4 clear flags - * from any ht related info since 2.4 does not - * support ht */ - if ((le16_to_cpu(ctx->staging.channel) != ch)) - ctx->staging.flags = 0; + /* if we are switching from ht to 2.4 clear flags + * from any ht related info since 2.4 does not + * support ht */ + if ((le16_to_cpu(ctx->staging.channel) != ch)) + ctx->staging.flags = 0; - il_set_rxon_channel(il, channel, ctx); - il_set_rxon_ht(il, ht_conf); + il_set_rxon_channel(il, channel, ctx); + il_set_rxon_ht(il, ht_conf); - il_set_flags_for_band(il, ctx, channel->band, - ctx->vif); - } + il_set_flags_for_band(il, ctx, channel->band, + ctx->vif); spin_unlock_irqrestore(&il->lock, flags); @@ -2203,15 +2156,12 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) if (scan_active) goto out; - for_each_context(il, ctx) { - if (memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging))) - il_commit_rxon(il, ctx); - else - D_INFO( - "Not re-sending same RXON configuration.\n"); - if (ht_changed) - il_update_qos(il, ctx); - } + if (memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging))) + il_commit_rxon(il, ctx); + else + D_INFO("Not re-sending same RXON configuration.\n"); + if (ht_changed) + il_update_qos(il, ctx); out: D_MAC80211("leave\n"); diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index e8153b0dc5b7..8448db7d8f39 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -599,26 +599,24 @@ il_dbgfs_qos_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; - struct il_rxon_context *ctx; + struct il_rxon_context *ctx = &il->ctx; int pos = 0, i; char buf[256]; const size_t bufsz = sizeof(buf); - for_each_context(il, ctx) { - pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n", - ctx->ctxid); - for (i = 0; i < AC_NUM; i++) { - pos += scnprintf(buf + pos, bufsz - pos, - "\tcw_min\tcw_max\taifsn\ttxop\n"); - pos += scnprintf(buf + pos, bufsz - pos, - "AC[%d]\t%u\t%u\t%u\t%u\n", i, - ctx->qos_data.def_qos_parm.ac[i].cw_min, - ctx->qos_data.def_qos_parm.ac[i].cw_max, - ctx->qos_data.def_qos_parm.ac[i].aifsn, - ctx->qos_data.def_qos_parm.ac[i].edca_txop); - } - pos += scnprintf(buf + pos, bufsz - pos, "\n"); + pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n", + ctx->ctxid); + for (i = 0; i < AC_NUM; i++) { + pos += scnprintf(buf + pos, bufsz - pos, + "\tcw_min\tcw_max\taifsn\ttxop\n"); + pos += scnprintf(buf + pos, bufsz - pos, + "AC[%d]\t%u\t%u\t%u\t%u\n", i, + ctx->qos_data.def_qos_parm.ac[i].cw_min, + ctx->qos_data.def_qos_parm.ac[i].cw_max, + ctx->qos_data.def_qos_parm.ac[i].aifsn, + ctx->qos_data.def_qos_parm.ac[i].edca_txop); } + return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index 71b2fac1b5d3..18226d1988a7 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -290,7 +290,9 @@ u16 il_get_passive_dwell_time(struct il_priv *il, enum ieee80211_band band, struct ieee80211_vif *vif) { - struct il_rxon_context *ctx; + struct il_rxon_context *ctx = &il->ctx; + u16 value; + u16 passive = (band == IEEE80211_BAND_2GHZ) ? IL_PASSIVE_DWELL_BASE + IL_PASSIVE_DWELL_TIME_24 : IL_PASSIVE_DWELL_BASE + IL_PASSIVE_DWELL_TIME_52; @@ -301,17 +303,11 @@ u16 il_get_passive_dwell_time(struct il_priv *il, * dwell time to be 98% of the smallest beacon interval * (minus 2 * channel tune time) */ - for_each_context(il, ctx) { - u16 value; - - if (!il_is_associated_ctx(ctx)) - continue; - value = ctx->vif ? ctx->vif->bss_conf.beacon_int : 0; - if (value > IL_PASSIVE_DWELL_BASE || !value) - value = IL_PASSIVE_DWELL_BASE; - value = (value * 98) / 100 - IL_CHANNEL_TUNE_TIME * 2; - passive = min(value, passive); - } + value = ctx->vif ? ctx->vif->bss_conf.beacon_int : 0; + if (value > IL_PASSIVE_DWELL_BASE || !value) + value = IL_PASSIVE_DWELL_BASE; + value = (value * 98) / 100 - IL_CHANNEL_TUNE_TIME * 2; + passive = min(value, passive); } return passive; diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.h b/drivers/net/wireless/iwlegacy/iwl-sta.h index f07cd7f7b8ae..afd3003f654b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.h +++ b/drivers/net/wireless/iwlegacy/iwl-sta.h @@ -84,7 +84,7 @@ int il_send_lq_cmd(struct il_priv *il, static inline void il_clear_driver_stations(struct il_priv *il) { unsigned long flags; - struct il_rxon_context *ctx; + struct il_rxon_context *ctx = &il->ctx; spin_lock_irqsave(&il->sta_lock, flags); memset(il->stations, 0, sizeof(il->stations)); @@ -92,17 +92,15 @@ static inline void il_clear_driver_stations(struct il_priv *il) il->ucode_key_table = 0; - for_each_context(il, ctx) { - /* - * Remove all key information that is not stored as part - * of station information since mac80211 may not have had - * a chance to remove all the keys. When device is - * reconfigured by mac80211 after an error all keys will - * be reconfigured. - */ - memset(ctx->wep_keys, 0, sizeof(ctx->wep_keys)); - ctx->key_mapping_keys = 0; - } + /* + * Remove all key information that is not stored as part + * of station information since mac80211 may not have had + * a chance to remove all the keys. When device is + * reconfigured by mac80211 after an error all keys will + * be reconfigured. + */ + memset(ctx->wep_keys, 0, sizeof(ctx->wep_keys)); + ctx->key_mapping_keys = 0; spin_unlock_irqrestore(&il->sta_lock, flags); } diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c index 41104e72d299..151c8faa18dd 100644 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c @@ -2710,10 +2710,8 @@ static void il3945_bg_restart(struct work_struct *data) return; if (test_and_clear_bit(STATUS_FW_ERROR, &il->status)) { - struct il_rxon_context *ctx; mutex_lock(&il->mutex); - for_each_context(il, ctx) - ctx->vif = NULL; + il->ctx.vif = NULL; il->is_open = 0; mutex_unlock(&il->mutex); il3945_down(il); diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c index 043d51e9d59e..df86431d3bae 100644 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ b/drivers/net/wireless/iwlegacy/iwl4965-base.c @@ -89,14 +89,10 @@ MODULE_ALIAS("iwl4965"); void il4965_update_chain_flags(struct il_priv *il) { - struct il_rxon_context *ctx; - if (il->cfg->ops->hcmd->set_rxon_chain) { - for_each_context(il, ctx) { - il->cfg->ops->hcmd->set_rxon_chain(il, ctx); - if (ctx->active.rx_chain != ctx->staging.rx_chain) - il_commit_rxon(il, ctx); - } + il->cfg->ops->hcmd->set_rxon_chain(il, &il->ctx); + if (il->ctx.active.rx_chain != il->ctx.staging.rx_chain) + il_commit_rxon(il, &il->ctx); } } @@ -1766,10 +1762,8 @@ static void il4965_alive_start(struct il_priv *il) ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; } else { - struct il_rxon_context *tmp; /* Initialize our rx_config data */ - for_each_context(il, tmp) - il_connection_init_rx_config(il, tmp); + il_connection_init_rx_config(il, &il->ctx); if (il->cfg->ops->hcmd->set_rxon_chain) il->cfg->ops->hcmd->set_rxon_chain(il, ctx); @@ -1950,7 +1944,6 @@ static int il4965_prepare_card_hw(struct il_priv *il) static int __il4965_up(struct il_priv *il) { - struct il_rxon_context *ctx; int i; int ret; @@ -1964,12 +1957,10 @@ static int __il4965_up(struct il_priv *il) return -EIO; } - for_each_context(il, ctx) { - ret = il4965_alloc_bcast_station(il, ctx); - if (ret) { - il_dealloc_bcast_stations(il); - return ret; - } + ret = il4965_alloc_bcast_station(il, &il->ctx); + if (ret) { + il_dealloc_bcast_stations(il); + return ret; } il4965_prepare_card_hw(il); @@ -2121,11 +2112,8 @@ static void il4965_bg_restart(struct work_struct *data) return; if (test_and_clear_bit(STATUS_FW_ERROR, &il->status)) { - struct il_rxon_context *ctx; - mutex_lock(&il->mutex); - for_each_context(il, ctx) - ctx->vif = NULL; + il->ctx.vif = NULL; il->is_open = 0; __il4965_down(il); @@ -2177,7 +2165,6 @@ static int il4965_mac_setup_register(struct il_priv *il, { int ret; struct ieee80211_hw *hw = il->hw; - struct il_rxon_context *ctx; hw->rate_control_algorithm = "iwl-4965-rs"; @@ -2195,10 +2182,8 @@ static int il4965_mac_setup_register(struct il_priv *il, hw->sta_data_size = sizeof(struct il_station_priv); hw->vif_data_size = sizeof(struct il_vif_priv); - for_each_context(il, ctx) { - hw->wiphy->interface_modes |= ctx->interface_modes; - hw->wiphy->interface_modes |= ctx->exclusive_interface_modes; - } + hw->wiphy->interface_modes |= il->ctx.interface_modes; + hw->wiphy->interface_modes |= il->ctx.exclusive_interface_modes; hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | WIPHY_FLAG_DISABLE_BEACON_HINTS; @@ -2590,7 +2575,6 @@ void il4965_configure_filter(struct ieee80211_hw *hw, { struct il_priv *il = hw->priv; __le32 filter_or = 0, filter_nand = 0; - struct il_rxon_context *ctx; #define CHK(test, flag) do { \ if (*total_flags & (test)) \ @@ -2611,15 +2595,13 @@ void il4965_configure_filter(struct ieee80211_hw *hw, mutex_lock(&il->mutex); - for_each_context(il, ctx) { - ctx->staging.filter_flags &= ~filter_nand; - ctx->staging.filter_flags |= filter_or; + il->ctx.staging.filter_flags &= ~filter_nand; + il->ctx.staging.filter_flags |= filter_or; - /* - * Not committing directly because hardware can perform a scan, - * but we'll eventually commit the filter flags change anyway. - */ - } + /* + * Not committing directly because hardware can perform a scan, + * but we'll eventually commit the filter flags change anyway. + */ mutex_unlock(&il->mutex); -- cgit v1.2.3 From 61fe55f61fb48b691251e0f75505674db77f5d29 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 12:40:26 +0100 Subject: iwlegacy: rename base 4965 and 3945 file names Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/3945-mac.c | 4007 ++++++++++++++++++++++++++ drivers/net/wireless/iwlegacy/3945.c | 2740 ++++++++++++++++++ drivers/net/wireless/iwlegacy/4965-mac.c | 3245 +++++++++++++++++++++ drivers/net/wireless/iwlegacy/4965.c | 2183 ++++++++++++++ drivers/net/wireless/iwlegacy/Makefile | 4 +- drivers/net/wireless/iwlegacy/iwl-3945.c | 2740 ------------------ drivers/net/wireless/iwlegacy/iwl-4965.c | 2183 -------------- drivers/net/wireless/iwlegacy/iwl3945-base.c | 4007 -------------------------- drivers/net/wireless/iwlegacy/iwl4965-base.c | 3245 --------------------- 9 files changed, 12177 insertions(+), 12177 deletions(-) create mode 100644 drivers/net/wireless/iwlegacy/3945-mac.c create mode 100644 drivers/net/wireless/iwlegacy/3945.c create mode 100644 drivers/net/wireless/iwlegacy/4965-mac.c create mode 100644 drivers/net/wireless/iwlegacy/4965.c delete mode 100644 drivers/net/wireless/iwlegacy/iwl-3945.c delete mode 100644 drivers/net/wireless/iwlegacy/iwl-4965.c delete mode 100644 drivers/net/wireless/iwlegacy/iwl3945-base.c delete mode 100644 drivers/net/wireless/iwlegacy/iwl4965-base.c (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c new file mode 100644 index 000000000000..151c8faa18dd --- /dev/null +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -0,0 +1,4007 @@ +/****************************************************************************** + * + * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * + * Portions of this file are derived from the ipw3945 project, as well + * as portions of the ieee80211 subsystem header files. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + *****************************************************************************/ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#define DRV_NAME "iwl3945" + +#include "iwl-fh.h" +#include "iwl-3945-fh.h" +#include "iwl-commands.h" +#include "iwl-sta.h" +#include "iwl-3945.h" +#include "iwl-core.h" +#include "iwl-helpers.h" +#include "iwl-dev.h" +#include "iwl-spectrum.h" + +/* + * module name, copyright, version, etc. + */ + +#define DRV_DESCRIPTION \ +"Intel(R) PRO/Wireless 3945ABG/BG Network Connection driver for Linux" + +#ifdef CONFIG_IWLEGACY_DEBUG +#define VD "d" +#else +#define VD +#endif + +/* + * add "s" to indicate spectrum measurement included. + * we add it here to be consistent with previous releases in which + * this was configurable. + */ +#define DRV_VERSION IWLWIFI_VERSION VD "s" +#define DRV_COPYRIGHT "Copyright(c) 2003-2011 Intel Corporation" +#define DRV_AUTHOR "" + +MODULE_DESCRIPTION(DRV_DESCRIPTION); +MODULE_VERSION(DRV_VERSION); +MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); +MODULE_LICENSE("GPL"); + + /* module parameters */ +struct il_mod_params il3945_mod_params = { + .sw_crypto = 1, + .restart_fw = 1, + .disable_hw_scan = 1, + /* the rest are 0 by default */ +}; + +/** + * il3945_get_antenna_flags - Get antenna flags for RXON command + * @il: eeprom and antenna fields are used to determine antenna flags + * + * il->eeprom39 is used to determine if antenna AUX/MAIN are reversed + * il3945_mod_params.antenna specifies the antenna diversity mode: + * + * IL_ANTENNA_DIVERSITY - NIC selects best antenna by itself + * IL_ANTENNA_MAIN - Force MAIN antenna + * IL_ANTENNA_AUX - Force AUX antenna + */ +__le32 il3945_get_antenna_flags(const struct il_priv *il) +{ + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; + + switch (il3945_mod_params.antenna) { + case IL_ANTENNA_DIVERSITY: + return 0; + + case IL_ANTENNA_MAIN: + if (eeprom->antenna_switch_type) + return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_B_MSK; + return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_A_MSK; + + case IL_ANTENNA_AUX: + if (eeprom->antenna_switch_type) + return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_A_MSK; + return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_B_MSK; + } + + /* bad antenna selector value */ + IL_ERR("Bad antenna selector value (0x%x)\n", + il3945_mod_params.antenna); + + return 0; /* "diversity" is default if error */ +} + +static int il3945_set_ccmp_dynamic_key_info(struct il_priv *il, + struct ieee80211_key_conf *keyconf, + u8 sta_id) +{ + unsigned long flags; + __le16 key_flags = 0; + int ret; + + key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK); + key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); + + if (sta_id == il->ctx.bcast_sta_id) + key_flags |= STA_KEY_MULTICAST_MSK; + + keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; + keyconf->hw_key_idx = keyconf->keyidx; + key_flags &= ~STA_KEY_FLG_INVALID; + + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].keyinfo.cipher = keyconf->cipher; + il->stations[sta_id].keyinfo.keylen = keyconf->keylen; + memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, + keyconf->keylen); + + memcpy(il->stations[sta_id].sta.key.key, keyconf->key, + keyconf->keylen); + + if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) + == STA_KEY_FLG_NO_ENC) + il->stations[sta_id].sta.key.key_offset = + il_get_free_ucode_key_idx(il); + /* else, we are overriding an existing key => no need to allocated room + * in uCode. */ + + WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, + "no space for a new key"); + + il->stations[sta_id].sta.key.key_flags = key_flags; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + + D_INFO("hwcrypto: modify ucode station key info\n"); + + ret = il_send_add_sta(il, + &il->stations[sta_id].sta, CMD_ASYNC); + + spin_unlock_irqrestore(&il->sta_lock, flags); + + return ret; +} + +static int il3945_set_tkip_dynamic_key_info(struct il_priv *il, + struct ieee80211_key_conf *keyconf, + u8 sta_id) +{ + return -EOPNOTSUPP; +} + +static int il3945_set_wep_dynamic_key_info(struct il_priv *il, + struct ieee80211_key_conf *keyconf, + u8 sta_id) +{ + return -EOPNOTSUPP; +} + +static int il3945_clear_sta_key_info(struct il_priv *il, u8 sta_id) +{ + unsigned long flags; + struct il_addsta_cmd sta_cmd; + + spin_lock_irqsave(&il->sta_lock, flags); + memset(&il->stations[sta_id].keyinfo, 0, sizeof(struct il_hw_key)); + memset(&il->stations[sta_id].sta.key, 0, + sizeof(struct il4965_keyinfo)); + il->stations[sta_id].sta.key.key_flags = STA_KEY_FLG_NO_ENC; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + memcpy(&sta_cmd, &il->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); + spin_unlock_irqrestore(&il->sta_lock, flags); + + D_INFO("hwcrypto: clear ucode station key info\n"); + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); +} + +static int il3945_set_dynamic_key(struct il_priv *il, + struct ieee80211_key_conf *keyconf, u8 sta_id) +{ + int ret = 0; + + keyconf->hw_key_idx = HW_KEY_DYNAMIC; + + switch (keyconf->cipher) { + case WLAN_CIPHER_SUITE_CCMP: + ret = il3945_set_ccmp_dynamic_key_info(il, keyconf, sta_id); + break; + case WLAN_CIPHER_SUITE_TKIP: + ret = il3945_set_tkip_dynamic_key_info(il, keyconf, sta_id); + break; + case WLAN_CIPHER_SUITE_WEP40: + case WLAN_CIPHER_SUITE_WEP104: + ret = il3945_set_wep_dynamic_key_info(il, keyconf, sta_id); + break; + default: + IL_ERR("Unknown alg: %s alg=%x\n", __func__, + keyconf->cipher); + ret = -EINVAL; + } + + D_WEP("Set dynamic key: alg=%x len=%d idx=%d sta=%d ret=%d\n", + keyconf->cipher, keyconf->keylen, keyconf->keyidx, + sta_id, ret); + + return ret; +} + +static int il3945_remove_static_key(struct il_priv *il) +{ + int ret = -EOPNOTSUPP; + + return ret; +} + +static int il3945_set_static_key(struct il_priv *il, + struct ieee80211_key_conf *key) +{ + if (key->cipher == WLAN_CIPHER_SUITE_WEP40 || + key->cipher == WLAN_CIPHER_SUITE_WEP104) + return -EOPNOTSUPP; + + IL_ERR("Static key invalid: cipher %x\n", key->cipher); + return -EINVAL; +} + +static void il3945_clear_free_frames(struct il_priv *il) +{ + struct list_head *element; + + D_INFO("%d frames on pre-allocated heap on clear.\n", + il->frames_count); + + while (!list_empty(&il->free_frames)) { + element = il->free_frames.next; + list_del(element); + kfree(list_entry(element, struct il3945_frame, list)); + il->frames_count--; + } + + if (il->frames_count) { + IL_WARN("%d frames still in use. Did we lose one?\n", + il->frames_count); + il->frames_count = 0; + } +} + +static struct il3945_frame *il3945_get_free_frame(struct il_priv *il) +{ + struct il3945_frame *frame; + struct list_head *element; + if (list_empty(&il->free_frames)) { + frame = kzalloc(sizeof(*frame), GFP_KERNEL); + if (!frame) { + IL_ERR("Could not allocate frame!\n"); + return NULL; + } + + il->frames_count++; + return frame; + } + + element = il->free_frames.next; + list_del(element); + return list_entry(element, struct il3945_frame, list); +} + +static void il3945_free_frame(struct il_priv *il, struct il3945_frame *frame) +{ + memset(frame, 0, sizeof(*frame)); + list_add(&frame->list, &il->free_frames); +} + +unsigned int il3945_fill_beacon_frame(struct il_priv *il, + struct ieee80211_hdr *hdr, + int left) +{ + + if (!il_is_associated(il) || !il->beacon_skb) + return 0; + + if (il->beacon_skb->len > left) + return 0; + + memcpy(hdr, il->beacon_skb->data, il->beacon_skb->len); + + return il->beacon_skb->len; +} + +static int il3945_send_beacon_cmd(struct il_priv *il) +{ + struct il3945_frame *frame; + unsigned int frame_size; + int rc; + u8 rate; + + frame = il3945_get_free_frame(il); + + if (!frame) { + IL_ERR("Could not obtain free frame buffer for beacon " + "command.\n"); + return -ENOMEM; + } + + rate = il_get_lowest_plcp(il, + &il->ctx); + + frame_size = il3945_hw_get_beacon_cmd(il, frame, rate); + + rc = il_send_cmd_pdu(il, REPLY_TX_BEACON, frame_size, + &frame->u.cmd[0]); + + il3945_free_frame(il, frame); + + return rc; +} + +static void il3945_unset_hw_params(struct il_priv *il) +{ + if (il->_3945.shared_virt) + dma_free_coherent(&il->pci_dev->dev, + sizeof(struct il3945_shared), + il->_3945.shared_virt, + il->_3945.shared_phys); +} + +static void il3945_build_tx_cmd_hwcrypto(struct il_priv *il, + struct ieee80211_tx_info *info, + struct il_device_cmd *cmd, + struct sk_buff *skb_frag, + int sta_id) +{ + struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; + struct il_hw_key *keyinfo = &il->stations[sta_id].keyinfo; + + tx_cmd->sec_ctl = 0; + + switch (keyinfo->cipher) { + case WLAN_CIPHER_SUITE_CCMP: + tx_cmd->sec_ctl = TX_CMD_SEC_CCM; + memcpy(tx_cmd->key, keyinfo->key, keyinfo->keylen); + D_TX("tx_cmd with AES hwcrypto\n"); + break; + + case WLAN_CIPHER_SUITE_TKIP: + break; + + case WLAN_CIPHER_SUITE_WEP104: + tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128; + /* fall through */ + case WLAN_CIPHER_SUITE_WEP40: + tx_cmd->sec_ctl |= TX_CMD_SEC_WEP | + (info->control.hw_key->hw_key_idx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT; + + memcpy(&tx_cmd->key[3], keyinfo->key, keyinfo->keylen); + + D_TX("Configuring packet for WEP encryption " + "with key %d\n", info->control.hw_key->hw_key_idx); + break; + + default: + IL_ERR("Unknown encode cipher %x\n", keyinfo->cipher); + break; + } +} + +/* + * handle build REPLY_TX command notification. + */ +static void il3945_build_tx_cmd_basic(struct il_priv *il, + struct il_device_cmd *cmd, + struct ieee80211_tx_info *info, + struct ieee80211_hdr *hdr, u8 std_id) +{ + struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; + __le32 tx_flags = tx_cmd->tx_flags; + __le16 fc = hdr->frame_control; + + tx_cmd->stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; + if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) { + tx_flags |= TX_CMD_FLG_ACK_MSK; + if (ieee80211_is_mgmt(fc)) + tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; + if (ieee80211_is_probe_resp(fc) && + !(le16_to_cpu(hdr->seq_ctrl) & 0xf)) + tx_flags |= TX_CMD_FLG_TSF_MSK; + } else { + tx_flags &= (~TX_CMD_FLG_ACK_MSK); + tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; + } + + tx_cmd->sta_id = std_id; + if (ieee80211_has_morefrags(fc)) + tx_flags |= TX_CMD_FLG_MORE_FRAG_MSK; + + if (ieee80211_is_data_qos(fc)) { + u8 *qc = ieee80211_get_qos_ctl(hdr); + tx_cmd->tid_tspec = qc[0] & 0xf; + tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK; + } else { + tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; + } + + il_tx_cmd_protection(il, info, fc, &tx_flags); + + tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); + if (ieee80211_is_mgmt(fc)) { + if (ieee80211_is_assoc_req(fc) || ieee80211_is_reassoc_req(fc)) + tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(3); + else + tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(2); + } else { + tx_cmd->timeout.pm_frame_timeout = 0; + } + + tx_cmd->driver_txop = 0; + tx_cmd->tx_flags = tx_flags; + tx_cmd->next_frame_len = 0; +} + +/* + * start REPLY_TX command process + */ +static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) +{ + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct il3945_tx_cmd *tx_cmd; + struct il_tx_queue *txq = NULL; + struct il_queue *q = NULL; + struct il_device_cmd *out_cmd; + struct il_cmd_meta *out_meta; + dma_addr_t phys_addr; + dma_addr_t txcmd_phys; + int txq_id = skb_get_queue_mapping(skb); + u16 len, idx, hdr_len; + u8 id; + u8 unicast; + u8 sta_id; + u8 tid = 0; + __le16 fc; + u8 wait_write_ptr = 0; + unsigned long flags; + + spin_lock_irqsave(&il->lock, flags); + if (il_is_rfkill(il)) { + D_DROP("Dropping - RF KILL\n"); + goto drop_unlock; + } + + if ((ieee80211_get_tx_rate(il->hw, info)->hw_value & 0xFF) == IL_INVALID_RATE) { + IL_ERR("ERROR: No TX rate available.\n"); + goto drop_unlock; + } + + unicast = !is_multicast_ether_addr(hdr->addr1); + id = 0; + + fc = hdr->frame_control; + +#ifdef CONFIG_IWLEGACY_DEBUG + if (ieee80211_is_auth(fc)) + D_TX("Sending AUTH frame\n"); + else if (ieee80211_is_assoc_req(fc)) + D_TX("Sending ASSOC frame\n"); + else if (ieee80211_is_reassoc_req(fc)) + D_TX("Sending REASSOC frame\n"); +#endif + + spin_unlock_irqrestore(&il->lock, flags); + + hdr_len = ieee80211_hdrlen(fc); + + /* Find idx into station table for destination station */ + sta_id = il_sta_id_or_broadcast( + il, &il->ctx, + info->control.sta); + if (sta_id == IL_INVALID_STATION) { + D_DROP("Dropping - INVALID STATION: %pM\n", + hdr->addr1); + goto drop; + } + + D_RATE("station Id %d\n", sta_id); + + if (ieee80211_is_data_qos(fc)) { + u8 *qc = ieee80211_get_qos_ctl(hdr); + tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK; + if (unlikely(tid >= MAX_TID_COUNT)) + goto drop; + } + + /* Descriptor for chosen Tx queue */ + txq = &il->txq[txq_id]; + q = &txq->q; + + if ((il_queue_space(q) < q->high_mark)) + goto drop; + + spin_lock_irqsave(&il->lock, flags); + + idx = il_get_cmd_idx(q, q->write_ptr, 0); + + /* Set up driver data for this TFD */ + memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct il_tx_info)); + txq->txb[q->write_ptr].skb = skb; + txq->txb[q->write_ptr].ctx = &il->ctx; + + /* Init first empty entry in queue's array of Tx/cmd buffers */ + out_cmd = txq->cmd[idx]; + out_meta = &txq->meta[idx]; + tx_cmd = (struct il3945_tx_cmd *)out_cmd->cmd.payload; + memset(&out_cmd->hdr, 0, sizeof(out_cmd->hdr)); + memset(tx_cmd, 0, sizeof(*tx_cmd)); + + /* + * Set up the Tx-command (not MAC!) header. + * Store the chosen Tx queue and TFD idx within the sequence field; + * after Tx, uCode's Tx response will return this value so driver can + * locate the frame within the tx queue and do post-tx processing. + */ + out_cmd->hdr.cmd = REPLY_TX; + out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | + IDX_TO_SEQ(q->write_ptr))); + + /* Copy MAC header from skb into command buffer */ + memcpy(tx_cmd->hdr, hdr, hdr_len); + + + if (info->control.hw_key) + il3945_build_tx_cmd_hwcrypto(il, info, out_cmd, skb, sta_id); + + /* TODO need this for burst mode later on */ + il3945_build_tx_cmd_basic(il, out_cmd, info, hdr, sta_id); + + /* set is_hcca to 0; it probably will never be implemented */ + il3945_hw_build_tx_cmd_rate(il, out_cmd, info, hdr, sta_id, 0); + + /* Total # bytes to be transmitted */ + len = (u16)skb->len; + tx_cmd->len = cpu_to_le16(len); + + il_dbg_log_tx_data_frame(il, len, hdr); + il_update_stats(il, true, fc, len); + tx_cmd->tx_flags &= ~TX_CMD_FLG_ANT_A_MSK; + tx_cmd->tx_flags &= ~TX_CMD_FLG_ANT_B_MSK; + + if (!ieee80211_has_morefrags(hdr->frame_control)) { + txq->need_update = 1; + } else { + wait_write_ptr = 1; + txq->need_update = 0; + } + + D_TX("sequence nr = 0X%x\n", + le16_to_cpu(out_cmd->hdr.sequence)); + D_TX("tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); + il_print_hex_dump(il, IL_DL_TX, tx_cmd, sizeof(*tx_cmd)); + il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd->hdr, + ieee80211_hdrlen(fc)); + + /* + * Use the first empty entry in this queue's command buffer array + * to contain the Tx command and MAC header concatenated together + * (payload data will be in another buffer). + * Size of this varies, due to varying MAC header length. + * If end is not dword aligned, we'll have 2 extra bytes at the end + * of the MAC header (device reads on dword boundaries). + * We'll tell device about this padding later. + */ + len = sizeof(struct il3945_tx_cmd) + + sizeof(struct il_cmd_header) + hdr_len; + len = (len + 3) & ~3; + + /* Physical address of this Tx command's header (not MAC header!), + * within command buffer array. */ + txcmd_phys = pci_map_single(il->pci_dev, &out_cmd->hdr, + len, PCI_DMA_TODEVICE); + /* we do not map meta data ... so we can safely access address to + * provide to unmap command*/ + dma_unmap_addr_set(out_meta, mapping, txcmd_phys); + dma_unmap_len_set(out_meta, len, len); + + /* Add buffer containing Tx command and MAC(!) header to TFD's + * first entry */ + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, + txcmd_phys, len, 1, 0); + + + /* Set up TFD's 2nd entry to point directly to remainder of skb, + * if any (802.11 null frames have no payload). */ + len = skb->len - hdr_len; + if (len) { + phys_addr = pci_map_single(il->pci_dev, skb->data + hdr_len, + len, PCI_DMA_TODEVICE); + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, + phys_addr, len, + 0, U32_PAD(len)); + } + + + /* Tell device the write idx *just past* this latest filled TFD */ + q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); + il_txq_update_write_ptr(il, txq); + spin_unlock_irqrestore(&il->lock, flags); + + if (il_queue_space(q) < q->high_mark + && il->mac80211_registered) { + if (wait_write_ptr) { + spin_lock_irqsave(&il->lock, flags); + txq->need_update = 1; + il_txq_update_write_ptr(il, txq); + spin_unlock_irqrestore(&il->lock, flags); + } + + il_stop_queue(il, txq); + } + + return 0; + +drop_unlock: + spin_unlock_irqrestore(&il->lock, flags); +drop: + return -1; +} + +static int il3945_get_measurement(struct il_priv *il, + struct ieee80211_measurement_params *params, + u8 type) +{ + struct il_spectrum_cmd spectrum; + struct il_rx_pkt *pkt; + struct il_host_cmd cmd = { + .id = REPLY_SPECTRUM_MEASUREMENT_CMD, + .data = (void *)&spectrum, + .flags = CMD_WANT_SKB, + }; + u32 add_time = le64_to_cpu(params->start_time); + int rc; + int spectrum_resp_status; + int duration = le16_to_cpu(params->duration); + struct il_rxon_context *ctx = &il->ctx; + + if (il_is_associated(il)) + add_time = il_usecs_to_beacons(il, + le64_to_cpu(params->start_time) - il->_3945.last_tsf, + le16_to_cpu(ctx->timing.beacon_interval)); + + memset(&spectrum, 0, sizeof(spectrum)); + + spectrum.channel_count = cpu_to_le16(1); + spectrum.flags = + RXON_FLG_TSF2HOST_MSK | RXON_FLG_ANT_A_MSK | RXON_FLG_DIS_DIV_MSK; + spectrum.filter_flags = MEASUREMENT_FILTER_FLAG; + cmd.len = sizeof(spectrum); + spectrum.len = cpu_to_le16(cmd.len - sizeof(spectrum.len)); + + if (il_is_associated(il)) + spectrum.start_time = + il_add_beacon_time(il, + il->_3945.last_beacon_time, add_time, + le16_to_cpu(ctx->timing.beacon_interval)); + else + spectrum.start_time = 0; + + spectrum.channels[0].duration = cpu_to_le32(duration * TIME_UNIT); + spectrum.channels[0].channel = params->channel; + spectrum.channels[0].type = type; + if (ctx->active.flags & RXON_FLG_BAND_24G_MSK) + spectrum.flags |= RXON_FLG_BAND_24G_MSK | + RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_TGG_PROTECT_MSK; + + rc = il_send_cmd_sync(il, &cmd); + if (rc) + return rc; + + pkt = (struct il_rx_pkt *)cmd.reply_page; + if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { + IL_ERR("Bad return from REPLY_RX_ON_ASSOC command\n"); + rc = -EIO; + } + + spectrum_resp_status = le16_to_cpu(pkt->u.spectrum.status); + switch (spectrum_resp_status) { + case 0: /* Command will be handled */ + if (pkt->u.spectrum.id != 0xff) { + D_INFO("Replaced existing measurement: %d\n", + pkt->u.spectrum.id); + il->measurement_status &= ~MEASUREMENT_READY; + } + il->measurement_status |= MEASUREMENT_ACTIVE; + rc = 0; + break; + + case 1: /* Command will not be handled */ + rc = -EAGAIN; + break; + } + + il_free_pages(il, cmd.reply_page); + + return rc; +} + +static void il3945_rx_reply_alive(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il_alive_resp *palive; + struct delayed_work *pwork; + + palive = &pkt->u.alive_frame; + + D_INFO("Alive ucode status 0x%08X revision " + "0x%01X 0x%01X\n", + palive->is_valid, palive->ver_type, + palive->ver_subtype); + + if (palive->ver_subtype == INITIALIZE_SUBTYPE) { + D_INFO("Initialization Alive received.\n"); + memcpy(&il->card_alive_init, &pkt->u.alive_frame, + sizeof(struct il_alive_resp)); + pwork = &il->init_alive_start; + } else { + D_INFO("Runtime Alive received.\n"); + memcpy(&il->card_alive, &pkt->u.alive_frame, + sizeof(struct il_alive_resp)); + pwork = &il->alive_start; + il3945_disable_events(il); + } + + /* We delay the ALIVE response by 5ms to + * give the HW RF Kill time to activate... */ + if (palive->is_valid == UCODE_VALID_OK) + queue_delayed_work(il->workqueue, pwork, + msecs_to_jiffies(5)); + else + IL_WARN("uCode did not respond OK.\n"); +} + +static void il3945_rx_reply_add_sta(struct il_priv *il, + struct il_rx_buf *rxb) +{ +#ifdef CONFIG_IWLEGACY_DEBUG + struct il_rx_pkt *pkt = rxb_addr(rxb); +#endif + + D_RX("Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); +} + +static void il3945_rx_beacon_notif(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il3945_beacon_notif *beacon = &(pkt->u.beacon_status); +#ifdef CONFIG_IWLEGACY_DEBUG + u8 rate = beacon->beacon_notify_hdr.rate; + + D_RX("beacon status %x retries %d iss %d " + "tsf %d %d rate %d\n", + le32_to_cpu(beacon->beacon_notify_hdr.status) & TX_STATUS_MSK, + beacon->beacon_notify_hdr.failure_frame, + le32_to_cpu(beacon->ibss_mgr_status), + le32_to_cpu(beacon->high_tsf), + le32_to_cpu(beacon->low_tsf), rate); +#endif + + il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); + +} + +/* Handle notification from uCode that card's power state is changing + * due to software, hardware, or critical temperature RFKILL */ +static void il3945_rx_card_state_notif(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); + unsigned long status = il->status; + + IL_WARN("Card state received: HW:%s SW:%s\n", + (flags & HW_CARD_DISABLED) ? "Kill" : "On", + (flags & SW_CARD_DISABLED) ? "Kill" : "On"); + + _il_wr(il, CSR_UCODE_DRV_GP1_SET, + CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); + + if (flags & HW_CARD_DISABLED) + set_bit(STATUS_RF_KILL_HW, &il->status); + else + clear_bit(STATUS_RF_KILL_HW, &il->status); + + + il_scan_cancel(il); + + if ((test_bit(STATUS_RF_KILL_HW, &status) != + test_bit(STATUS_RF_KILL_HW, &il->status))) + wiphy_rfkill_set_hw_state(il->hw->wiphy, + test_bit(STATUS_RF_KILL_HW, &il->status)); + else + wake_up(&il->wait_command_queue); +} + +/** + * il3945_setup_rx_handlers - Initialize Rx handler callbacks + * + * Setup the RX handlers for each of the reply types sent from the uCode + * to the host. + * + * This function chains into the hardware specific files for them to setup + * any hardware specific handlers as well. + */ +static void il3945_setup_rx_handlers(struct il_priv *il) +{ + il->rx_handlers[REPLY_ALIVE] = il3945_rx_reply_alive; + il->rx_handlers[REPLY_ADD_STA] = il3945_rx_reply_add_sta; + il->rx_handlers[REPLY_ERROR] = il_rx_reply_error; + il->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa; + il->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = + il_rx_spectrum_measure_notif; + il->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; + il->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = + il_rx_pm_debug_stats_notif; + il->rx_handlers[BEACON_NOTIFICATION] = il3945_rx_beacon_notif; + + /* + * The same handler is used for both the REPLY to a discrete + * stats request from the host as well as for the periodic + * stats notifications (after received beacons) from the uCode. + */ + il->rx_handlers[REPLY_STATISTICS_CMD] = il3945_reply_stats; + il->rx_handlers[STATISTICS_NOTIFICATION] = il3945_hw_rx_stats; + + il_setup_rx_scan_handlers(il); + il->rx_handlers[CARD_STATE_NOTIFICATION] = il3945_rx_card_state_notif; + + /* Set up hardware specific Rx handlers */ + il3945_hw_rx_handler_setup(il); +} + +/************************** RX-FUNCTIONS ****************************/ +/* + * Rx theory of operation + * + * The host allocates 32 DMA target addresses and passes the host address + * to the firmware at register IL_RFDS_TBL_LOWER + N * RFD_SIZE where N is + * 0 to 31 + * + * Rx Queue Indexes + * The host/firmware share two idx registers for managing the Rx buffers. + * + * The READ idx maps to the first position that the firmware may be writing + * to -- the driver can read up to (but not including) this position and get + * good data. + * The READ idx is managed by the firmware once the card is enabled. + * + * The WRITE idx maps to the last position the driver has read from -- the + * position preceding WRITE is the last slot the firmware can place a packet. + * + * The queue is empty (no good data) if WRITE = READ - 1, and is full if + * WRITE = READ. + * + * During initialization, the host sets up the READ queue position to the first + * IDX position, and WRITE to the last (READ - 1 wrapped) + * + * When the firmware places a packet in a buffer, it will advance the READ idx + * and fire the RX interrupt. The driver can then query the READ idx and + * process as many packets as possible, moving the WRITE idx forward as it + * resets the Rx queue buffers with new memory. + * + * The management in the driver is as follows: + * + A list of pre-allocated SKBs is stored in iwl->rxq->rx_free. When + * iwl->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled + * to replenish the iwl->rxq->rx_free. + * + In il3945_rx_replenish (scheduled) if 'processed' != 'read' then the + * iwl->rxq is replenished and the READ IDX is updated (updating the + * 'processed' and 'read' driver idxes as well) + * + A received packet is processed and handed to the kernel network stack, + * detached from the iwl->rxq. The driver 'processed' idx is updated. + * + The Host/Firmware iwl->rxq is replenished at tasklet time from the rx_free + * list. If there are no allocated buffers in iwl->rxq->rx_free, the READ + * IDX is not incremented and iwl->status(RX_STALLED) is set. If there + * were enough free buffers and RX_STALLED is set it is cleared. + * + * + * Driver sequence: + * + * il3945_rx_replenish() Replenishes rx_free list from rx_used, and calls + * il3945_rx_queue_restock + * il3945_rx_queue_restock() Moves available buffers from rx_free into Rx + * queue, updates firmware pointers, and updates + * the WRITE idx. If insufficient rx_free buffers + * are available, schedules il3945_rx_replenish + * + * -- enable interrupts -- + * ISR - il3945_rx() Detach il_rx_bufs from pool up to the + * READ IDX, detaching the SKB from the pool. + * Moves the packet buffer from queue to rx_used. + * Calls il3945_rx_queue_restock to refill any empty + * slots. + * ... + * + */ + +/** + * il3945_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr + */ +static inline __le32 il3945_dma_addr2rbd_ptr(struct il_priv *il, + dma_addr_t dma_addr) +{ + return cpu_to_le32((u32)dma_addr); +} + +/** + * il3945_rx_queue_restock - refill RX queue from pre-allocated pool + * + * If there are slots in the RX queue that need to be restocked, + * and we have free pre-allocated buffers, fill the ranks as much + * as we can, pulling from rx_free. + * + * This moves the 'write' idx forward to catch up with 'processed', and + * also updates the memory address in the firmware to reference the new + * target buffer. + */ +static void il3945_rx_queue_restock(struct il_priv *il) +{ + struct il_rx_queue *rxq = &il->rxq; + struct list_head *element; + struct il_rx_buf *rxb; + unsigned long flags; + int write; + + spin_lock_irqsave(&rxq->lock, flags); + write = rxq->write & ~0x7; + while (il_rx_queue_space(rxq) > 0 && rxq->free_count) { + /* Get next free Rx buffer, remove from free list */ + element = rxq->rx_free.next; + rxb = list_entry(element, struct il_rx_buf, list); + list_del(element); + + /* Point to Rx buffer via next RBD in circular buffer */ + rxq->bd[rxq->write] = il3945_dma_addr2rbd_ptr(il, rxb->page_dma); + rxq->queue[rxq->write] = rxb; + rxq->write = (rxq->write + 1) & RX_QUEUE_MASK; + rxq->free_count--; + } + spin_unlock_irqrestore(&rxq->lock, flags); + /* If the pre-allocated buffer pool is dropping low, schedule to + * refill it */ + if (rxq->free_count <= RX_LOW_WATERMARK) + queue_work(il->workqueue, &il->rx_replenish); + + + /* If we've added more space for the firmware to place data, tell it. + * Increment device's write pointer in multiples of 8. */ + if (rxq->write_actual != (rxq->write & ~0x7) || + abs(rxq->write - rxq->read) > 7) { + spin_lock_irqsave(&rxq->lock, flags); + rxq->need_update = 1; + spin_unlock_irqrestore(&rxq->lock, flags); + il_rx_queue_update_write_ptr(il, rxq); + } +} + +/** + * il3945_rx_replenish - Move all used packet from rx_used to rx_free + * + * When moving to rx_free an SKB is allocated for the slot. + * + * Also restock the Rx queue via il3945_rx_queue_restock. + * This is called as a scheduled work item (except for during initialization) + */ +static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) +{ + struct il_rx_queue *rxq = &il->rxq; + struct list_head *element; + struct il_rx_buf *rxb; + struct page *page; + unsigned long flags; + gfp_t gfp_mask = priority; + + while (1) { + spin_lock_irqsave(&rxq->lock, flags); + + if (list_empty(&rxq->rx_used)) { + spin_unlock_irqrestore(&rxq->lock, flags); + return; + } + spin_unlock_irqrestore(&rxq->lock, flags); + + if (rxq->free_count > RX_LOW_WATERMARK) + gfp_mask |= __GFP_NOWARN; + + if (il->hw_params.rx_page_order > 0) + gfp_mask |= __GFP_COMP; + + /* Alloc a new receive buffer */ + page = alloc_pages(gfp_mask, il->hw_params.rx_page_order); + if (!page) { + if (net_ratelimit()) + D_INFO("Failed to allocate SKB buffer.\n"); + if (rxq->free_count <= RX_LOW_WATERMARK && + net_ratelimit()) + IL_ERR("Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", + priority == GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL", + rxq->free_count); + /* We don't reschedule replenish work here -- we will + * call the restock method and if it still needs + * more buffers it will schedule replenish */ + break; + } + + spin_lock_irqsave(&rxq->lock, flags); + if (list_empty(&rxq->rx_used)) { + spin_unlock_irqrestore(&rxq->lock, flags); + __free_pages(page, il->hw_params.rx_page_order); + return; + } + element = rxq->rx_used.next; + rxb = list_entry(element, struct il_rx_buf, list); + list_del(element); + spin_unlock_irqrestore(&rxq->lock, flags); + + rxb->page = page; + /* Get physical address of RB/SKB */ + rxb->page_dma = pci_map_page(il->pci_dev, page, 0, + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); + + spin_lock_irqsave(&rxq->lock, flags); + + list_add_tail(&rxb->list, &rxq->rx_free); + rxq->free_count++; + il->alloc_rxb_page++; + + spin_unlock_irqrestore(&rxq->lock, flags); + } +} + +void il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) +{ + unsigned long flags; + int i; + spin_lock_irqsave(&rxq->lock, flags); + INIT_LIST_HEAD(&rxq->rx_free); + INIT_LIST_HEAD(&rxq->rx_used); + /* Fill the rx_used queue with _all_ of the Rx buffers */ + for (i = 0; i < RX_FREE_BUFFERS + RX_QUEUE_SIZE; i++) { + /* In the reset function, these buffers may have been allocated + * to an SKB, so we need to unmap and free potential storage */ + if (rxq->pool[i].page != NULL) { + pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); + __il_free_pages(il, rxq->pool[i].page); + rxq->pool[i].page = NULL; + } + list_add_tail(&rxq->pool[i].list, &rxq->rx_used); + } + + /* Set us so that we have processed and used all buffers, but have + * not restocked the Rx queue with fresh buffers */ + rxq->read = rxq->write = 0; + rxq->write_actual = 0; + rxq->free_count = 0; + spin_unlock_irqrestore(&rxq->lock, flags); +} + +void il3945_rx_replenish(void *data) +{ + struct il_priv *il = data; + unsigned long flags; + + il3945_rx_allocate(il, GFP_KERNEL); + + spin_lock_irqsave(&il->lock, flags); + il3945_rx_queue_restock(il); + spin_unlock_irqrestore(&il->lock, flags); +} + +static void il3945_rx_replenish_now(struct il_priv *il) +{ + il3945_rx_allocate(il, GFP_ATOMIC); + + il3945_rx_queue_restock(il); +} + + +/* Assumes that the skb field of the buffers in 'pool' is kept accurate. + * If an SKB has been detached, the POOL needs to have its SKB set to NULL + * This free routine walks the list of POOL entries and if SKB is set to + * non NULL it is unmapped and freed + */ +static void il3945_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq) +{ + int i; + for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { + if (rxq->pool[i].page != NULL) { + pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); + __il_free_pages(il, rxq->pool[i].page); + rxq->pool[i].page = NULL; + } + } + + dma_free_coherent(&il->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, + rxq->bd_dma); + dma_free_coherent(&il->pci_dev->dev, sizeof(struct il_rb_status), + rxq->rb_stts, rxq->rb_stts_dma); + rxq->bd = NULL; + rxq->rb_stts = NULL; +} + + +/* Convert linear signal-to-noise ratio into dB */ +static u8 ratio2dB[100] = { +/* 0 1 2 3 4 5 6 7 8 9 */ + 0, 0, 6, 10, 12, 14, 16, 17, 18, 19, /* 00 - 09 */ + 20, 21, 22, 22, 23, 23, 24, 25, 26, 26, /* 10 - 19 */ + 26, 26, 26, 27, 27, 28, 28, 28, 29, 29, /* 20 - 29 */ + 29, 30, 30, 30, 31, 31, 31, 31, 32, 32, /* 30 - 39 */ + 32, 32, 32, 33, 33, 33, 33, 33, 34, 34, /* 40 - 49 */ + 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, /* 50 - 59 */ + 36, 36, 36, 36, 36, 36, 36, 37, 37, 37, /* 60 - 69 */ + 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, /* 70 - 79 */ + 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, /* 80 - 89 */ + 39, 39, 39, 39, 39, 40, 40, 40, 40, 40 /* 90 - 99 */ +}; + +/* Calculates a relative dB value from a ratio of linear + * (i.e. not dB) signal levels. + * Conversion assumes that levels are voltages (20*log), not powers (10*log). */ +int il3945_calc_db_from_ratio(int sig_ratio) +{ + /* 1000:1 or higher just report as 60 dB */ + if (sig_ratio >= 1000) + return 60; + + /* 100:1 or higher, divide by 10 and use table, + * add 20 dB to make up for divide by 10 */ + if (sig_ratio >= 100) + return 20 + (int)ratio2dB[sig_ratio/10]; + + /* We shouldn't see this */ + if (sig_ratio < 1) + return 0; + + /* Use table for ratios 1:1 - 99:1 */ + return (int)ratio2dB[sig_ratio]; +} + +/** + * il3945_rx_handle - Main entry function for receiving responses from uCode + * + * Uses the il->rx_handlers callback function array to invoke + * the appropriate handlers, including command responses, + * frame-received notifications, and other notifications. + */ +static void il3945_rx_handle(struct il_priv *il) +{ + struct il_rx_buf *rxb; + struct il_rx_pkt *pkt; + struct il_rx_queue *rxq = &il->rxq; + u32 r, i; + int reclaim; + unsigned long flags; + u8 fill_rx = 0; + u32 count = 8; + int total_empty = 0; + + /* uCode's read idx (stored in shared DRAM) indicates the last Rx + * buffer that the driver may process (last buffer filled by ucode). */ + r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF; + i = rxq->read; + + /* calculate total frames need to be restock after handling RX */ + total_empty = r - rxq->write_actual; + if (total_empty < 0) + total_empty += RX_QUEUE_SIZE; + + if (total_empty > (RX_QUEUE_SIZE / 2)) + fill_rx = 1; + /* Rx interrupt, but nothing sent from uCode */ + if (i == r) + D_RX("r = %d, i = %d\n", r, i); + + while (i != r) { + int len; + + rxb = rxq->queue[i]; + + /* If an RXB doesn't have a Rx queue slot associated with it, + * then a bug has been introduced in the queue refilling + * routines -- catch it here */ + BUG_ON(rxb == NULL); + + rxq->queue[i] = NULL; + + pci_unmap_page(il->pci_dev, rxb->page_dma, + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); + pkt = rxb_addr(rxb); + + len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; + len += sizeof(u32); /* account for status word */ + + /* Reclaim a command buffer only if this packet is a response + * to a (driver-originated) command. + * If the packet (e.g. Rx frame) originated from uCode, + * there is no command buffer to reclaim. + * Ucode should set SEQ_RX_FRAME bit if ucode-originated, + * but apparently a few don't get set; catch them here. */ + reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) && + pkt->hdr.cmd != STATISTICS_NOTIFICATION && + pkt->hdr.cmd != REPLY_TX; + + /* Based on type of command response or notification, + * handle those that need handling via function in + * rx_handlers table. See il3945_setup_rx_handlers() */ + if (il->rx_handlers[pkt->hdr.cmd]) { + D_RX("r = %d, i = %d, %s, 0x%02x\n", r, i, + il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); + il->isr_stats.rx_handlers[pkt->hdr.cmd]++; + il->rx_handlers[pkt->hdr.cmd] (il, rxb); + } else { + /* No handling needed */ + D_RX( + "r %d i %d No handler needed for %s, 0x%02x\n", + r, i, il_get_cmd_string(pkt->hdr.cmd), + pkt->hdr.cmd); + } + + /* + * XXX: After here, we should always check rxb->page + * against NULL before touching it or its virtual + * memory (pkt). Because some rx_handler might have + * already taken or freed the pages. + */ + + if (reclaim) { + /* Invoke any callbacks, transfer the buffer to caller, + * and fire off the (possibly) blocking il_send_cmd() + * as we reclaim the driver command queue */ + if (rxb->page) + il_tx_cmd_complete(il, rxb); + else + IL_WARN("Claim null rxb?\n"); + } + + /* Reuse the page if possible. For notification packets and + * SKBs that fail to Rx correctly, add them back into the + * rx_free list for reuse later. */ + spin_lock_irqsave(&rxq->lock, flags); + if (rxb->page != NULL) { + rxb->page_dma = pci_map_page(il->pci_dev, rxb->page, + 0, PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); + list_add_tail(&rxb->list, &rxq->rx_free); + rxq->free_count++; + } else + list_add_tail(&rxb->list, &rxq->rx_used); + + spin_unlock_irqrestore(&rxq->lock, flags); + + i = (i + 1) & RX_QUEUE_MASK; + /* If there are a lot of unused frames, + * restock the Rx queue so ucode won't assert. */ + if (fill_rx) { + count++; + if (count >= 8) { + rxq->read = i; + il3945_rx_replenish_now(il); + count = 0; + } + } + } + + /* Backtrack one entry */ + rxq->read = i; + if (fill_rx) + il3945_rx_replenish_now(il); + else + il3945_rx_queue_restock(il); +} + +/* call this function to flush any scheduled tasklet */ +static inline void il3945_synchronize_irq(struct il_priv *il) +{ + /* wait to make sure we flush pending tasklet*/ + synchronize_irq(il->pci_dev->irq); + tasklet_kill(&il->irq_tasklet); +} + +static const char *il3945_desc_lookup(int i) +{ + switch (i) { + case 1: + return "FAIL"; + case 2: + return "BAD_PARAM"; + case 3: + return "BAD_CHECKSUM"; + case 4: + return "NMI_INTERRUPT"; + case 5: + return "SYSASSERT"; + case 6: + return "FATAL_ERROR"; + } + + return "UNKNOWN"; +} + +#define ERROR_START_OFFSET (1 * sizeof(u32)) +#define ERROR_ELEM_SIZE (7 * sizeof(u32)) + +void il3945_dump_nic_error_log(struct il_priv *il) +{ + u32 i; + u32 desc, time, count, base, data1; + u32 blink1, blink2, ilink1, ilink2; + + base = le32_to_cpu(il->card_alive.error_event_table_ptr); + + if (!il3945_hw_valid_rtc_data_addr(base)) { + IL_ERR("Not valid error log pointer 0x%08X\n", base); + return; + } + + + count = il_read_targ_mem(il, base); + + if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { + IL_ERR("Start IWL Error Log Dump:\n"); + IL_ERR("Status: 0x%08lX, count: %d\n", + il->status, count); + } + + IL_ERR("Desc Time asrtPC blink2 " + "ilink1 nmiPC Line\n"); + for (i = ERROR_START_OFFSET; + i < (count * ERROR_ELEM_SIZE) + ERROR_START_OFFSET; + i += ERROR_ELEM_SIZE) { + desc = il_read_targ_mem(il, base + i); + time = + il_read_targ_mem(il, base + i + 1 * sizeof(u32)); + blink1 = + il_read_targ_mem(il, base + i + 2 * sizeof(u32)); + blink2 = + il_read_targ_mem(il, base + i + 3 * sizeof(u32)); + ilink1 = + il_read_targ_mem(il, base + i + 4 * sizeof(u32)); + ilink2 = + il_read_targ_mem(il, base + i + 5 * sizeof(u32)); + data1 = + il_read_targ_mem(il, base + i + 6 * sizeof(u32)); + + IL_ERR( + "%-13s (0x%X) %010u 0x%05X 0x%05X 0x%05X 0x%05X %u\n\n", + il3945_desc_lookup(desc), desc, time, blink1, blink2, + ilink1, ilink2, data1); + } +} + +static void il3945_irq_tasklet(struct il_priv *il) +{ + u32 inta, handled = 0; + u32 inta_fh; + unsigned long flags; +#ifdef CONFIG_IWLEGACY_DEBUG + u32 inta_mask; +#endif + + spin_lock_irqsave(&il->lock, flags); + + /* Ack/clear/reset pending uCode interrupts. + * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS, + * and will clear only when CSR_FH_INT_STATUS gets cleared. */ + inta = _il_rd(il, CSR_INT); + _il_wr(il, CSR_INT, inta); + + /* Ack/clear/reset pending flow-handler (DMA) interrupts. + * Any new interrupts that happen after this, either while we're + * in this tasklet, or later, will show up in next ISR/tasklet. */ + inta_fh = _il_rd(il, CSR_FH_INT_STATUS); + _il_wr(il, CSR_FH_INT_STATUS, inta_fh); + +#ifdef CONFIG_IWLEGACY_DEBUG + if (il_get_debug_level(il) & IL_DL_ISR) { + /* just for debug */ + inta_mask = _il_rd(il, CSR_INT_MASK); + D_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", + inta, inta_mask, inta_fh); + } +#endif + + spin_unlock_irqrestore(&il->lock, flags); + + /* Since CSR_INT and CSR_FH_INT_STATUS reads and clears are not + * atomic, make sure that inta covers all the interrupts that + * we've discovered, even if FH interrupt came in just after + * reading CSR_INT. */ + if (inta_fh & CSR39_FH_INT_RX_MASK) + inta |= CSR_INT_BIT_FH_RX; + if (inta_fh & CSR39_FH_INT_TX_MASK) + inta |= CSR_INT_BIT_FH_TX; + + /* Now service all interrupt bits discovered above. */ + if (inta & CSR_INT_BIT_HW_ERR) { + IL_ERR("Hardware error detected. Restarting.\n"); + + /* Tell the device to stop sending interrupts */ + il_disable_interrupts(il); + + il->isr_stats.hw++; + il_irq_handle_error(il); + + handled |= CSR_INT_BIT_HW_ERR; + + return; + } + +#ifdef CONFIG_IWLEGACY_DEBUG + if (il_get_debug_level(il) & (IL_DL_ISR)) { + /* NIC fires this, but we don't use it, redundant with WAKEUP */ + if (inta & CSR_INT_BIT_SCD) { + D_ISR("Scheduler finished to transmit " + "the frame/frames.\n"); + il->isr_stats.sch++; + } + + /* Alive notification via Rx interrupt will do the real work */ + if (inta & CSR_INT_BIT_ALIVE) { + D_ISR("Alive interrupt\n"); + il->isr_stats.alive++; + } + } +#endif + /* Safely ignore these bits for debug checks below */ + inta &= ~(CSR_INT_BIT_SCD | CSR_INT_BIT_ALIVE); + + /* Error detected by uCode */ + if (inta & CSR_INT_BIT_SW_ERR) { + IL_ERR("Microcode SW error detected. " + "Restarting 0x%X.\n", inta); + il->isr_stats.sw++; + il_irq_handle_error(il); + handled |= CSR_INT_BIT_SW_ERR; + } + + /* uCode wakes up after power-down sleep */ + if (inta & CSR_INT_BIT_WAKEUP) { + D_ISR("Wakeup interrupt\n"); + il_rx_queue_update_write_ptr(il, &il->rxq); + il_txq_update_write_ptr(il, &il->txq[0]); + il_txq_update_write_ptr(il, &il->txq[1]); + il_txq_update_write_ptr(il, &il->txq[2]); + il_txq_update_write_ptr(il, &il->txq[3]); + il_txq_update_write_ptr(il, &il->txq[4]); + il_txq_update_write_ptr(il, &il->txq[5]); + + il->isr_stats.wakeup++; + handled |= CSR_INT_BIT_WAKEUP; + } + + /* All uCode command responses, including Tx command responses, + * Rx "responses" (frame-received notification), and other + * notifications from uCode come through here*/ + if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) { + il3945_rx_handle(il); + il->isr_stats.rx++; + handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX); + } + + if (inta & CSR_INT_BIT_FH_TX) { + D_ISR("Tx interrupt\n"); + il->isr_stats.tx++; + + _il_wr(il, CSR_FH_INT_STATUS, (1 << 6)); + il_wr(il, FH39_TCSR_CREDIT + (FH39_SRVC_CHNL), 0x0); + handled |= CSR_INT_BIT_FH_TX; + } + + if (inta & ~handled) { + IL_ERR("Unhandled INTA bits 0x%08x\n", inta & ~handled); + il->isr_stats.unhandled++; + } + + if (inta & ~il->inta_mask) { + IL_WARN("Disabled INTA bits 0x%08x were pending\n", + inta & ~il->inta_mask); + IL_WARN(" with FH_INT = 0x%08x\n", inta_fh); + } + + /* Re-enable all interrupts */ + /* only Re-enable if disabled by irq */ + if (test_bit(STATUS_INT_ENABLED, &il->status)) + il_enable_interrupts(il); + +#ifdef CONFIG_IWLEGACY_DEBUG + if (il_get_debug_level(il) & (IL_DL_ISR)) { + inta = _il_rd(il, CSR_INT); + inta_mask = _il_rd(il, CSR_INT_MASK); + inta_fh = _il_rd(il, CSR_FH_INT_STATUS); + D_ISR("End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " + "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); + } +#endif +} + +static int il3945_get_channels_for_scan(struct il_priv *il, + enum ieee80211_band band, + u8 is_active, u8 n_probes, + struct il3945_scan_channel *scan_ch, + struct ieee80211_vif *vif) +{ + struct ieee80211_channel *chan; + const struct ieee80211_supported_band *sband; + const struct il_channel_info *ch_info; + u16 passive_dwell = 0; + u16 active_dwell = 0; + int added, i; + + sband = il_get_hw_mode(il, band); + if (!sband) + return 0; + + active_dwell = il_get_active_dwell_time(il, band, n_probes); + passive_dwell = il_get_passive_dwell_time(il, band, vif); + + if (passive_dwell <= active_dwell) + passive_dwell = active_dwell + 1; + + for (i = 0, added = 0; i < il->scan_request->n_channels; i++) { + chan = il->scan_request->channels[i]; + + if (chan->band != band) + continue; + + scan_ch->channel = chan->hw_value; + + ch_info = il_get_channel_info(il, band, + scan_ch->channel); + if (!il_is_channel_valid(ch_info)) { + D_SCAN( + "Channel %d is INVALID for this band.\n", + scan_ch->channel); + continue; + } + + scan_ch->active_dwell = cpu_to_le16(active_dwell); + scan_ch->passive_dwell = cpu_to_le16(passive_dwell); + /* If passive , set up for auto-switch + * and use long active_dwell time. + */ + if (!is_active || il_is_channel_passive(ch_info) || + (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)) { + scan_ch->type = 0; /* passive */ + if (IL_UCODE_API(il->ucode_ver) == 1) + scan_ch->active_dwell = cpu_to_le16(passive_dwell - 1); + } else { + scan_ch->type = 1; /* active */ + } + + /* Set direct probe bits. These may be used both for active + * scan channels (probes gets sent right away), + * or for passive channels (probes get se sent only after + * hearing clear Rx packet).*/ + if (IL_UCODE_API(il->ucode_ver) >= 2) { + if (n_probes) + scan_ch->type |= IL39_SCAN_PROBE_MASK(n_probes); + } else { + /* uCode v1 does not allow setting direct probe bits on + * passive channel. */ + if ((scan_ch->type & 1) && n_probes) + scan_ch->type |= IL39_SCAN_PROBE_MASK(n_probes); + } + + /* Set txpower levels to defaults */ + scan_ch->tpc.dsp_atten = 110; + /* scan_pwr_info->tpc.dsp_atten; */ + + /*scan_pwr_info->tpc.tx_gain; */ + if (band == IEEE80211_BAND_5GHZ) + scan_ch->tpc.tx_gain = ((1 << 5) | (3 << 3)) | 3; + else { + scan_ch->tpc.tx_gain = ((1 << 5) | (5 << 3)); + /* NOTE: if we were doing 6Mb OFDM for scans we'd use + * power level: + * scan_ch->tpc.tx_gain = ((1 << 5) | (2 << 3)) | 3; + */ + } + + D_SCAN("Scanning %d [%s %d]\n", + scan_ch->channel, + (scan_ch->type & 1) ? "ACTIVE" : "PASSIVE", + (scan_ch->type & 1) ? + active_dwell : passive_dwell); + + scan_ch++; + added++; + } + + D_SCAN("total channels to scan %d\n", added); + return added; +} + +static void il3945_init_hw_rates(struct il_priv *il, + struct ieee80211_rate *rates) +{ + int i; + + for (i = 0; i < RATE_COUNT_LEGACY; i++) { + rates[i].bitrate = il3945_rates[i].ieee * 5; + rates[i].hw_value = i; /* Rate scaling will work on idxes */ + rates[i].hw_value_short = i; + rates[i].flags = 0; + if (i > IL39_LAST_OFDM_RATE || i < IL_FIRST_OFDM_RATE) { + /* + * If CCK != 1M then set short preamble rate flag. + */ + rates[i].flags |= (il3945_rates[i].plcp == 10) ? + 0 : IEEE80211_RATE_SHORT_PREAMBLE; + } + } +} + +/****************************************************************************** + * + * uCode download functions + * + ******************************************************************************/ + +static void il3945_dealloc_ucode_pci(struct il_priv *il) +{ + il_free_fw_desc(il->pci_dev, &il->ucode_code); + il_free_fw_desc(il->pci_dev, &il->ucode_data); + il_free_fw_desc(il->pci_dev, &il->ucode_data_backup); + il_free_fw_desc(il->pci_dev, &il->ucode_init); + il_free_fw_desc(il->pci_dev, &il->ucode_init_data); + il_free_fw_desc(il->pci_dev, &il->ucode_boot); +} + +/** + * il3945_verify_inst_full - verify runtime uCode image in card vs. host, + * looking at all data. + */ +static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) +{ + u32 val; + u32 save_len = len; + int rc = 0; + u32 errcnt; + + D_INFO("ucode inst image size is %u\n", len); + + il_wr(il, HBUS_TARG_MEM_RADDR, + IL39_RTC_INST_LOWER_BOUND); + + errcnt = 0; + for (; len > 0; len -= sizeof(u32), image++) { + /* read data comes through single port, auto-incr addr */ + /* NOTE: Use the debugless read so we don't flood kernel log + * if IL_DL_IO is set */ + val = _il_rd(il, HBUS_TARG_MEM_RDAT); + if (val != le32_to_cpu(*image)) { + IL_ERR("uCode INST section is invalid at " + "offset 0x%x, is 0x%x, s/b 0x%x\n", + save_len - len, val, le32_to_cpu(*image)); + rc = -EIO; + errcnt++; + if (errcnt >= 20) + break; + } + } + + + if (!errcnt) + D_INFO( + "ucode image in INSTRUCTION memory is good\n"); + + return rc; +} + + +/** + * il3945_verify_inst_sparse - verify runtime uCode image in card vs. host, + * using sample data 100 bytes apart. If these sample points are good, + * it's a pretty good bet that everything between them is good, too. + */ +static int il3945_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) +{ + u32 val; + int rc = 0; + u32 errcnt = 0; + u32 i; + + D_INFO("ucode inst image size is %u\n", len); + + for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { + /* read data comes through single port, auto-incr addr */ + /* NOTE: Use the debugless read so we don't flood kernel log + * if IL_DL_IO is set */ + il_wr(il, HBUS_TARG_MEM_RADDR, + i + IL39_RTC_INST_LOWER_BOUND); + val = _il_rd(il, HBUS_TARG_MEM_RDAT); + if (val != le32_to_cpu(*image)) { +#if 0 /* Enable this if you want to see details */ + IL_ERR("uCode INST section is invalid at " + "offset 0x%x, is 0x%x, s/b 0x%x\n", + i, val, *image); +#endif + rc = -EIO; + errcnt++; + if (errcnt >= 3) + break; + } + } + + return rc; +} + + +/** + * il3945_verify_ucode - determine which instruction image is in SRAM, + * and verify its contents + */ +static int il3945_verify_ucode(struct il_priv *il) +{ + __le32 *image; + u32 len; + int rc = 0; + + /* Try bootstrap */ + image = (__le32 *)il->ucode_boot.v_addr; + len = il->ucode_boot.len; + rc = il3945_verify_inst_sparse(il, image, len); + if (rc == 0) { + D_INFO("Bootstrap uCode is good in inst SRAM\n"); + return 0; + } + + /* Try initialize */ + image = (__le32 *)il->ucode_init.v_addr; + len = il->ucode_init.len; + rc = il3945_verify_inst_sparse(il, image, len); + if (rc == 0) { + D_INFO("Initialize uCode is good in inst SRAM\n"); + return 0; + } + + /* Try runtime/protocol */ + image = (__le32 *)il->ucode_code.v_addr; + len = il->ucode_code.len; + rc = il3945_verify_inst_sparse(il, image, len); + if (rc == 0) { + D_INFO("Runtime uCode is good in inst SRAM\n"); + return 0; + } + + IL_ERR("NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); + + /* Since nothing seems to match, show first several data entries in + * instruction SRAM, so maybe visual inspection will give a clue. + * Selection of bootstrap image (vs. other images) is arbitrary. */ + image = (__le32 *)il->ucode_boot.v_addr; + len = il->ucode_boot.len; + rc = il3945_verify_inst_full(il, image, len); + + return rc; +} + +static void il3945_nic_start(struct il_priv *il) +{ + /* Remove all resets to allow NIC to operate */ + _il_wr(il, CSR_RESET, 0); +} + +#define IL3945_UCODE_GET(item) \ +static u32 il3945_ucode_get_##item(const struct il_ucode_header *ucode)\ +{ \ + return le32_to_cpu(ucode->v1.item); \ +} + +static u32 il3945_ucode_get_header_size(u32 api_ver) +{ + return 24; +} + +static u8 *il3945_ucode_get_data(const struct il_ucode_header *ucode) +{ + return (u8 *) ucode->v1.data; +} + +IL3945_UCODE_GET(inst_size); +IL3945_UCODE_GET(data_size); +IL3945_UCODE_GET(init_size); +IL3945_UCODE_GET(init_data_size); +IL3945_UCODE_GET(boot_size); + +/** + * il3945_read_ucode - Read uCode images from disk file. + * + * Copy into buffers for card to fetch via bus-mastering + */ +static int il3945_read_ucode(struct il_priv *il) +{ + const struct il_ucode_header *ucode; + int ret = -EINVAL, idx; + const struct firmware *ucode_raw; + /* firmware file name contains uCode/driver compatibility version */ + const char *name_pre = il->cfg->fw_name_pre; + const unsigned int api_max = il->cfg->ucode_api_max; + const unsigned int api_min = il->cfg->ucode_api_min; + char buf[25]; + u8 *src; + size_t len; + u32 api_ver, inst_size, data_size, init_size, init_data_size, boot_size; + + /* Ask kernel firmware_class module to get the boot firmware off disk. + * request_firmware() is synchronous, file is in memory on return. */ + for (idx = api_max; idx >= api_min; idx--) { + sprintf(buf, "%s%u%s", name_pre, idx, ".ucode"); + ret = request_firmware(&ucode_raw, buf, &il->pci_dev->dev); + if (ret < 0) { + IL_ERR("%s firmware file req failed: %d\n", + buf, ret); + if (ret == -ENOENT) + continue; + else + goto error; + } else { + if (idx < api_max) + IL_ERR("Loaded firmware %s, " + "which is deprecated. " + " Please use API v%u instead.\n", + buf, api_max); + D_INFO("Got firmware '%s' file " + "(%zd bytes) from disk\n", + buf, ucode_raw->size); + break; + } + } + + if (ret < 0) + goto error; + + /* Make sure that we got at least our header! */ + if (ucode_raw->size < il3945_ucode_get_header_size(1)) { + IL_ERR("File size way too small!\n"); + ret = -EINVAL; + goto err_release; + } + + /* Data from ucode file: header followed by uCode images */ + ucode = (struct il_ucode_header *)ucode_raw->data; + + il->ucode_ver = le32_to_cpu(ucode->ver); + api_ver = IL_UCODE_API(il->ucode_ver); + inst_size = il3945_ucode_get_inst_size(ucode); + data_size = il3945_ucode_get_data_size(ucode); + init_size = il3945_ucode_get_init_size(ucode); + init_data_size = il3945_ucode_get_init_data_size(ucode); + boot_size = il3945_ucode_get_boot_size(ucode); + src = il3945_ucode_get_data(ucode); + + /* api_ver should match the api version forming part of the + * firmware filename ... but we don't check for that and only rely + * on the API version read from firmware header from here on forward */ + + if (api_ver < api_min || api_ver > api_max) { + IL_ERR("Driver unable to support your firmware API. " + "Driver supports v%u, firmware is v%u.\n", + api_max, api_ver); + il->ucode_ver = 0; + ret = -EINVAL; + goto err_release; + } + if (api_ver != api_max) + IL_ERR("Firmware has old API version. Expected %u, " + "got %u. New firmware can be obtained " + "from http://www.intellinuxwireless.org.\n", + api_max, api_ver); + + IL_INFO("loaded firmware version %u.%u.%u.%u\n", + IL_UCODE_MAJOR(il->ucode_ver), + IL_UCODE_MINOR(il->ucode_ver), + IL_UCODE_API(il->ucode_ver), + IL_UCODE_SERIAL(il->ucode_ver)); + + snprintf(il->hw->wiphy->fw_version, + sizeof(il->hw->wiphy->fw_version), + "%u.%u.%u.%u", + IL_UCODE_MAJOR(il->ucode_ver), + IL_UCODE_MINOR(il->ucode_ver), + IL_UCODE_API(il->ucode_ver), + IL_UCODE_SERIAL(il->ucode_ver)); + + D_INFO("f/w package hdr ucode version raw = 0x%x\n", + il->ucode_ver); + D_INFO("f/w package hdr runtime inst size = %u\n", + inst_size); + D_INFO("f/w package hdr runtime data size = %u\n", + data_size); + D_INFO("f/w package hdr init inst size = %u\n", + init_size); + D_INFO("f/w package hdr init data size = %u\n", + init_data_size); + D_INFO("f/w package hdr boot inst size = %u\n", + boot_size); + + + /* Verify size of file vs. image size info in file's header */ + if (ucode_raw->size != il3945_ucode_get_header_size(api_ver) + + inst_size + data_size + init_size + + init_data_size + boot_size) { + + D_INFO( + "uCode file size %zd does not match expected size\n", + ucode_raw->size); + ret = -EINVAL; + goto err_release; + } + + /* Verify that uCode images will fit in card's SRAM */ + if (inst_size > IL39_MAX_INST_SIZE) { + D_INFO("uCode instr len %d too large to fit in\n", + inst_size); + ret = -EINVAL; + goto err_release; + } + + if (data_size > IL39_MAX_DATA_SIZE) { + D_INFO("uCode data len %d too large to fit in\n", + data_size); + ret = -EINVAL; + goto err_release; + } + if (init_size > IL39_MAX_INST_SIZE) { + D_INFO( + "uCode init instr len %d too large to fit in\n", + init_size); + ret = -EINVAL; + goto err_release; + } + if (init_data_size > IL39_MAX_DATA_SIZE) { + D_INFO( + "uCode init data len %d too large to fit in\n", + init_data_size); + ret = -EINVAL; + goto err_release; + } + if (boot_size > IL39_MAX_BSM_SIZE) { + D_INFO( + "uCode boot instr len %d too large to fit in\n", + boot_size); + ret = -EINVAL; + goto err_release; + } + + /* Allocate ucode buffers for card's bus-master loading ... */ + + /* Runtime instructions and 2 copies of data: + * 1) unmodified from disk + * 2) backup cache for save/restore during power-downs */ + il->ucode_code.len = inst_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_code); + + il->ucode_data.len = data_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_data); + + il->ucode_data_backup.len = data_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_data_backup); + + if (!il->ucode_code.v_addr || !il->ucode_data.v_addr || + !il->ucode_data_backup.v_addr) + goto err_pci_alloc; + + /* Initialization instructions and data */ + if (init_size && init_data_size) { + il->ucode_init.len = init_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_init); + + il->ucode_init_data.len = init_data_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_init_data); + + if (!il->ucode_init.v_addr || !il->ucode_init_data.v_addr) + goto err_pci_alloc; + } + + /* Bootstrap (instructions only, no data) */ + if (boot_size) { + il->ucode_boot.len = boot_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_boot); + + if (!il->ucode_boot.v_addr) + goto err_pci_alloc; + } + + /* Copy images into buffers for card's bus-master reads ... */ + + /* Runtime instructions (first block of data in file) */ + len = inst_size; + D_INFO( + "Copying (but not loading) uCode instr len %zd\n", len); + memcpy(il->ucode_code.v_addr, src, len); + src += len; + + D_INFO("uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", + il->ucode_code.v_addr, (u32)il->ucode_code.p_addr); + + /* Runtime data (2nd block) + * NOTE: Copy into backup buffer will be done in il3945_up() */ + len = data_size; + D_INFO( + "Copying (but not loading) uCode data len %zd\n", len); + memcpy(il->ucode_data.v_addr, src, len); + memcpy(il->ucode_data_backup.v_addr, src, len); + src += len; + + /* Initialization instructions (3rd block) */ + if (init_size) { + len = init_size; + D_INFO( + "Copying (but not loading) init instr len %zd\n", len); + memcpy(il->ucode_init.v_addr, src, len); + src += len; + } + + /* Initialization data (4th block) */ + if (init_data_size) { + len = init_data_size; + D_INFO( + "Copying (but not loading) init data len %zd\n", len); + memcpy(il->ucode_init_data.v_addr, src, len); + src += len; + } + + /* Bootstrap instructions (5th block) */ + len = boot_size; + D_INFO( + "Copying (but not loading) boot instr len %zd\n", len); + memcpy(il->ucode_boot.v_addr, src, len); + + /* We have our copies now, allow OS release its copies */ + release_firmware(ucode_raw); + return 0; + + err_pci_alloc: + IL_ERR("failed to allocate pci memory\n"); + ret = -ENOMEM; + il3945_dealloc_ucode_pci(il); + + err_release: + release_firmware(ucode_raw); + + error: + return ret; +} + + +/** + * il3945_set_ucode_ptrs - Set uCode address location + * + * Tell initialization uCode where to find runtime uCode. + * + * BSM registers initially contain pointers to initialization uCode. + * We need to replace them to load runtime uCode inst and data, + * and to save runtime data when powering down. + */ +static int il3945_set_ucode_ptrs(struct il_priv *il) +{ + dma_addr_t pinst; + dma_addr_t pdata; + + /* bits 31:0 for 3945 */ + pinst = il->ucode_code.p_addr; + pdata = il->ucode_data_backup.p_addr; + + /* Tell bootstrap uCode where to find image to load */ + il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); + il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); + il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, + il->ucode_data.len); + + /* Inst byte count must be last to set up, bit 31 signals uCode + * that all new ptr/size info is in place */ + il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, + il->ucode_code.len | BSM_DRAM_INST_LOAD); + + D_INFO("Runtime uCode pointers are set.\n"); + + return 0; +} + +/** + * il3945_init_alive_start - Called after REPLY_ALIVE notification received + * + * Called after REPLY_ALIVE notification received from "initialize" uCode. + * + * Tell "initialize" uCode to go ahead and load the runtime uCode. + */ +static void il3945_init_alive_start(struct il_priv *il) +{ + /* Check alive response for "valid" sign from uCode */ + if (il->card_alive_init.is_valid != UCODE_VALID_OK) { + /* We had an error bringing up the hardware, so take it + * all the way back down so we can try again */ + D_INFO("Initialize Alive failed.\n"); + goto restart; + } + + /* Bootstrap uCode has loaded initialize uCode ... verify inst image. + * This is a paranoid check, because we would not have gotten the + * "initialize" alive if code weren't properly loaded. */ + if (il3945_verify_ucode(il)) { + /* Runtime instruction load was bad; + * take it all the way back down so we can try again */ + D_INFO("Bad \"initialize\" uCode load.\n"); + goto restart; + } + + /* Send pointers to protocol/runtime uCode image ... init code will + * load and launch runtime uCode, which will send us another "Alive" + * notification. */ + D_INFO("Initialization Alive received.\n"); + if (il3945_set_ucode_ptrs(il)) { + /* Runtime instruction load won't happen; + * take it all the way back down so we can try again */ + D_INFO("Couldn't set up uCode pointers.\n"); + goto restart; + } + return; + + restart: + queue_work(il->workqueue, &il->restart); +} + +/** + * il3945_alive_start - called after REPLY_ALIVE notification received + * from protocol/runtime uCode (initialization uCode's + * Alive gets handled by il3945_init_alive_start()). + */ +static void il3945_alive_start(struct il_priv *il) +{ + int thermal_spin = 0; + u32 rfkill; + struct il_rxon_context *ctx = &il->ctx; + + D_INFO("Runtime Alive received.\n"); + + if (il->card_alive.is_valid != UCODE_VALID_OK) { + /* We had an error bringing up the hardware, so take it + * all the way back down so we can try again */ + D_INFO("Alive failed.\n"); + goto restart; + } + + /* Initialize uCode has loaded Runtime uCode ... verify inst image. + * This is a paranoid check, because we would not have gotten the + * "runtime" alive if code weren't properly loaded. */ + if (il3945_verify_ucode(il)) { + /* Runtime instruction load was bad; + * take it all the way back down so we can try again */ + D_INFO("Bad runtime uCode load.\n"); + goto restart; + } + + rfkill = il_rd_prph(il, APMG_RFKILL_REG); + D_INFO("RFKILL status: 0x%x\n", rfkill); + + if (rfkill & 0x1) { + clear_bit(STATUS_RF_KILL_HW, &il->status); + /* if RFKILL is not on, then wait for thermal + * sensor in adapter to kick in */ + while (il3945_hw_get_temperature(il) == 0) { + thermal_spin++; + udelay(10); + } + + if (thermal_spin) + D_INFO("Thermal calibration took %dus\n", + thermal_spin * 10); + } else + set_bit(STATUS_RF_KILL_HW, &il->status); + + /* After the ALIVE response, we can send commands to 3945 uCode */ + set_bit(STATUS_ALIVE, &il->status); + + /* Enable watchdog to monitor the driver tx queues */ + il_setup_watchdog(il); + + if (il_is_rfkill(il)) + return; + + ieee80211_wake_queues(il->hw); + + il->active_rate = RATES_MASK_3945; + + il_power_update_mode(il, true); + + if (il_is_associated(il)) { + struct il3945_rxon_cmd *active_rxon = + (struct il3945_rxon_cmd *)(&ctx->active); + + ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; + active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; + } else { + /* Initialize our rx_config data */ + il_connection_init_rx_config(il, ctx); + } + + /* Configure Bluetooth device coexistence support */ + il_send_bt_config(il); + + set_bit(STATUS_READY, &il->status); + + /* Configure the adapter for unassociated operation */ + il3945_commit_rxon(il, ctx); + + il3945_reg_txpower_periodic(il); + + D_INFO("ALIVE processing complete.\n"); + wake_up(&il->wait_command_queue); + + return; + + restart: + queue_work(il->workqueue, &il->restart); +} + +static void il3945_cancel_deferred_work(struct il_priv *il); + +static void __il3945_down(struct il_priv *il) +{ + unsigned long flags; + int exit_pending; + + D_INFO(DRV_NAME " is going down\n"); + + il_scan_cancel_timeout(il, 200); + + exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &il->status); + + /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set + * to prevent rearm timer */ + del_timer_sync(&il->watchdog); + + /* Station information will now be cleared in device */ + il_clear_ucode_stations(il, NULL); + il_dealloc_bcast_stations(il); + il_clear_driver_stations(il); + + /* Unblock any waiting calls */ + wake_up_all(&il->wait_command_queue); + + /* Wipe out the EXIT_PENDING status bit if we are not actually + * exiting the module */ + if (!exit_pending) + clear_bit(STATUS_EXIT_PENDING, &il->status); + + /* stop and reset the on-board processor */ + _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + + /* tell the device to stop sending interrupts */ + spin_lock_irqsave(&il->lock, flags); + il_disable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); + il3945_synchronize_irq(il); + + if (il->mac80211_registered) + ieee80211_stop_queues(il->hw); + + /* If we have not previously called il3945_init() then + * clear all bits but the RF Kill bits and return */ + if (!il_is_init(il)) { + il->status = test_bit(STATUS_RF_KILL_HW, &il->status) << + STATUS_RF_KILL_HW | + test_bit(STATUS_GEO_CONFIGURED, &il->status) << + STATUS_GEO_CONFIGURED | + test_bit(STATUS_EXIT_PENDING, &il->status) << + STATUS_EXIT_PENDING; + goto exit; + } + + /* ...otherwise clear out all the status bits but the RF Kill + * bit and continue taking the NIC down. */ + il->status &= test_bit(STATUS_RF_KILL_HW, &il->status) << + STATUS_RF_KILL_HW | + test_bit(STATUS_GEO_CONFIGURED, &il->status) << + STATUS_GEO_CONFIGURED | + test_bit(STATUS_FW_ERROR, &il->status) << + STATUS_FW_ERROR | + test_bit(STATUS_EXIT_PENDING, &il->status) << + STATUS_EXIT_PENDING; + + il3945_hw_txq_ctx_stop(il); + il3945_hw_rxq_stop(il); + + /* Power-down device's busmaster DMA clocks */ + il_wr_prph(il, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); + udelay(5); + + /* Stop the device, and put it in low power state */ + il_apm_stop(il); + + exit: + memset(&il->card_alive, 0, sizeof(struct il_alive_resp)); + + if (il->beacon_skb) + dev_kfree_skb(il->beacon_skb); + il->beacon_skb = NULL; + + /* clear out any free frames */ + il3945_clear_free_frames(il); +} + +static void il3945_down(struct il_priv *il) +{ + mutex_lock(&il->mutex); + __il3945_down(il); + mutex_unlock(&il->mutex); + + il3945_cancel_deferred_work(il); +} + +#define MAX_HW_RESTARTS 5 + +static int il3945_alloc_bcast_station(struct il_priv *il) +{ + struct il_rxon_context *ctx = &il->ctx; + unsigned long flags; + u8 sta_id; + + spin_lock_irqsave(&il->sta_lock, flags); + sta_id = il_prep_station(il, ctx, + il_bcast_addr, false, NULL); + if (sta_id == IL_INVALID_STATION) { + IL_ERR("Unable to prepare broadcast station\n"); + spin_unlock_irqrestore(&il->sta_lock, flags); + + return -EINVAL; + } + + il->stations[sta_id].used |= IL_STA_DRIVER_ACTIVE; + il->stations[sta_id].used |= IL_STA_BCAST; + spin_unlock_irqrestore(&il->sta_lock, flags); + + return 0; +} + +static int __il3945_up(struct il_priv *il) +{ + int rc, i; + + rc = il3945_alloc_bcast_station(il); + if (rc) + return rc; + + if (test_bit(STATUS_EXIT_PENDING, &il->status)) { + IL_WARN("Exit pending; will not bring the NIC up\n"); + return -EIO; + } + + if (!il->ucode_data_backup.v_addr || !il->ucode_data.v_addr) { + IL_ERR("ucode not available for device bring up\n"); + return -EIO; + } + + /* If platform's RF_KILL switch is NOT set to KILL */ + if (_il_rd(il, CSR_GP_CNTRL) & + CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) + clear_bit(STATUS_RF_KILL_HW, &il->status); + else { + set_bit(STATUS_RF_KILL_HW, &il->status); + IL_WARN("Radio disabled by HW RF Kill switch\n"); + return -ENODEV; + } + + _il_wr(il, CSR_INT, 0xFFFFFFFF); + + rc = il3945_hw_nic_init(il); + if (rc) { + IL_ERR("Unable to int nic\n"); + return rc; + } + + /* make sure rfkill handshake bits are cleared */ + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, + CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); + + /* clear (again), then enable host interrupts */ + _il_wr(il, CSR_INT, 0xFFFFFFFF); + il_enable_interrupts(il); + + /* really make sure rfkill handshake bits are cleared */ + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + + /* Copy original ucode data image from disk into backup cache. + * This will be used to initialize the on-board processor's + * data SRAM for a clean start when the runtime program first loads. */ + memcpy(il->ucode_data_backup.v_addr, il->ucode_data.v_addr, + il->ucode_data.len); + + /* We return success when we resume from suspend and rf_kill is on. */ + if (test_bit(STATUS_RF_KILL_HW, &il->status)) + return 0; + + for (i = 0; i < MAX_HW_RESTARTS; i++) { + + /* load bootstrap state machine, + * load bootstrap program into processor's memory, + * prepare to load the "initialize" uCode */ + rc = il->cfg->ops->lib->load_ucode(il); + + if (rc) { + IL_ERR( + "Unable to set up bootstrap uCode: %d\n", rc); + continue; + } + + /* start card; "initialize" will load runtime ucode */ + il3945_nic_start(il); + + D_INFO(DRV_NAME " is coming up\n"); + + return 0; + } + + set_bit(STATUS_EXIT_PENDING, &il->status); + __il3945_down(il); + clear_bit(STATUS_EXIT_PENDING, &il->status); + + /* tried to restart and config the device for as long as our + * patience could withstand */ + IL_ERR("Unable to initialize device after %d attempts.\n", i); + return -EIO; +} + + +/***************************************************************************** + * + * Workqueue callbacks + * + *****************************************************************************/ + +static void il3945_bg_init_alive_start(struct work_struct *data) +{ + struct il_priv *il = + container_of(data, struct il_priv, init_alive_start.work); + + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + goto out; + + il3945_init_alive_start(il); +out: + mutex_unlock(&il->mutex); +} + +static void il3945_bg_alive_start(struct work_struct *data) +{ + struct il_priv *il = + container_of(data, struct il_priv, alive_start.work); + + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + goto out; + + il3945_alive_start(il); +out: + mutex_unlock(&il->mutex); +} + +/* + * 3945 cannot interrupt driver when hardware rf kill switch toggles; + * driver must poll CSR_GP_CNTRL_REG register for change. This register + * *is* readable even when device has been SW_RESET into low power mode + * (e.g. during RF KILL). + */ +static void il3945_rfkill_poll(struct work_struct *data) +{ + struct il_priv *il = + container_of(data, struct il_priv, _3945.rfkill_poll.work); + bool old_rfkill = test_bit(STATUS_RF_KILL_HW, &il->status); + bool new_rfkill = !(_il_rd(il, CSR_GP_CNTRL) + & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW); + + if (new_rfkill != old_rfkill) { + if (new_rfkill) + set_bit(STATUS_RF_KILL_HW, &il->status); + else + clear_bit(STATUS_RF_KILL_HW, &il->status); + + wiphy_rfkill_set_hw_state(il->hw->wiphy, new_rfkill); + + D_RF_KILL("RF_KILL bit toggled to %s.\n", + new_rfkill ? "disable radio" : "enable radio"); + } + + /* Keep this running, even if radio now enabled. This will be + * cancelled in mac_start() if system decides to start again */ + queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, + round_jiffies_relative(2 * HZ)); + +} + +int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) +{ + struct il_host_cmd cmd = { + .id = REPLY_SCAN_CMD, + .len = sizeof(struct il3945_scan_cmd), + .flags = CMD_SIZE_HUGE, + }; + struct il3945_scan_cmd *scan; + u8 n_probes = 0; + enum ieee80211_band band; + bool is_active = false; + int ret; + u16 len; + + lockdep_assert_held(&il->mutex); + + if (!il->scan_cmd) { + il->scan_cmd = kmalloc(sizeof(struct il3945_scan_cmd) + + IL_MAX_SCAN_SIZE, GFP_KERNEL); + if (!il->scan_cmd) { + D_SCAN("Fail to allocate scan memory\n"); + return -ENOMEM; + } + } + scan = il->scan_cmd; + memset(scan, 0, sizeof(struct il3945_scan_cmd) + IL_MAX_SCAN_SIZE); + + scan->quiet_plcp_th = IL_PLCP_QUIET_THRESH; + scan->quiet_time = IL_ACTIVE_QUIET_TIME; + + if (il_is_associated(il)) { + u16 interval; + u32 extra; + u32 suspend_time = 100; + u32 scan_suspend_time = 100; + + D_INFO("Scanning while associated...\n"); + + interval = vif->bss_conf.beacon_int; + + scan->suspend_time = 0; + scan->max_out_time = cpu_to_le32(200 * 1024); + if (!interval) + interval = suspend_time; + /* + * suspend time format: + * 0-19: beacon interval in usec (time before exec.) + * 20-23: 0 + * 24-31: number of beacons (suspend between channels) + */ + + extra = (suspend_time / interval) << 24; + scan_suspend_time = 0xFF0FFFFF & + (extra | ((suspend_time % interval) * 1024)); + + scan->suspend_time = cpu_to_le32(scan_suspend_time); + D_SCAN("suspend_time 0x%X beacon interval %d\n", + scan_suspend_time, interval); + } + + if (il->scan_request->n_ssids) { + int i, p = 0; + D_SCAN("Kicking off active scan\n"); + for (i = 0; i < il->scan_request->n_ssids; i++) { + /* always does wildcard anyway */ + if (!il->scan_request->ssids[i].ssid_len) + continue; + scan->direct_scan[p].id = WLAN_EID_SSID; + scan->direct_scan[p].len = + il->scan_request->ssids[i].ssid_len; + memcpy(scan->direct_scan[p].ssid, + il->scan_request->ssids[i].ssid, + il->scan_request->ssids[i].ssid_len); + n_probes++; + p++; + } + is_active = true; + } else + D_SCAN("Kicking off passive scan.\n"); + + /* We don't build a direct scan probe request; the uCode will do + * that based on the direct_mask added to each channel entry */ + scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; + scan->tx_cmd.sta_id = il->ctx.bcast_sta_id; + scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; + + /* flags + rate selection */ + + switch (il->scan_band) { + case IEEE80211_BAND_2GHZ: + scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; + scan->tx_cmd.rate = RATE_1M_PLCP; + band = IEEE80211_BAND_2GHZ; + break; + case IEEE80211_BAND_5GHZ: + scan->tx_cmd.rate = RATE_6M_PLCP; + band = IEEE80211_BAND_5GHZ; + break; + default: + IL_WARN("Invalid scan band\n"); + return -EIO; + } + + /* + * If active scaning is requested but a certain channel + * is marked passive, we can do active scanning if we + * detect transmissions. + */ + scan->good_CRC_th = is_active ? IL_GOOD_CRC_TH_DEFAULT : + IL_GOOD_CRC_TH_DISABLED; + + len = il_fill_probe_req(il, (struct ieee80211_mgmt *)scan->data, + vif->addr, il->scan_request->ie, + il->scan_request->ie_len, + IL_MAX_SCAN_SIZE - sizeof(*scan)); + scan->tx_cmd.len = cpu_to_le16(len); + + /* select Rx antennas */ + scan->flags |= il3945_get_antenna_flags(il); + + scan->channel_count = il3945_get_channels_for_scan(il, band, is_active, n_probes, + (void *)&scan->data[len], vif); + if (scan->channel_count == 0) { + D_SCAN("channel count %d\n", scan->channel_count); + return -EIO; + } + + cmd.len += le16_to_cpu(scan->tx_cmd.len) + + scan->channel_count * sizeof(struct il3945_scan_channel); + cmd.data = scan; + scan->len = cpu_to_le16(cmd.len); + + set_bit(STATUS_SCAN_HW, &il->status); + ret = il_send_cmd_sync(il, &cmd); + if (ret) + clear_bit(STATUS_SCAN_HW, &il->status); + return ret; +} + +void il3945_post_scan(struct il_priv *il) +{ + struct il_rxon_context *ctx = &il->ctx; + + /* + * Since setting the RXON may have been deferred while + * performing the scan, fire one off if needed + */ + if (memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) + il3945_commit_rxon(il, ctx); +} + +static void il3945_bg_restart(struct work_struct *data) +{ + struct il_priv *il = container_of(data, struct il_priv, restart); + + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + return; + + if (test_and_clear_bit(STATUS_FW_ERROR, &il->status)) { + mutex_lock(&il->mutex); + il->ctx.vif = NULL; + il->is_open = 0; + mutex_unlock(&il->mutex); + il3945_down(il); + ieee80211_restart_hw(il->hw); + } else { + il3945_down(il); + + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) { + mutex_unlock(&il->mutex); + return; + } + + __il3945_up(il); + mutex_unlock(&il->mutex); + } +} + +static void il3945_bg_rx_replenish(struct work_struct *data) +{ + struct il_priv *il = + container_of(data, struct il_priv, rx_replenish); + + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + goto out; + + il3945_rx_replenish(il); +out: + mutex_unlock(&il->mutex); +} + +void il3945_post_associate(struct il_priv *il) +{ + int rc = 0; + struct ieee80211_conf *conf = NULL; + struct il_rxon_context *ctx = &il->ctx; + + if (!ctx->vif || !il->is_open) + return; + + D_ASSOC("Associated as %d to: %pM\n", + ctx->vif->bss_conf.aid, ctx->active.bssid_addr); + + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + return; + + il_scan_cancel_timeout(il, 200); + + conf = il_ieee80211_get_hw_conf(il->hw); + + ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; + il3945_commit_rxon(il, ctx); + + rc = il_send_rxon_timing(il, ctx); + if (rc) + IL_WARN("REPLY_RXON_TIMING failed - " + "Attempting to continue.\n"); + + ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; + + ctx->staging.assoc_id = cpu_to_le16(ctx->vif->bss_conf.aid); + + D_ASSOC("assoc id %d beacon interval %d\n", + ctx->vif->bss_conf.aid, ctx->vif->bss_conf.beacon_int); + + if (ctx->vif->bss_conf.use_short_preamble) + ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; + else + ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; + + if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) { + if (ctx->vif->bss_conf.use_short_slot) + ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; + else + ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; + } + + il3945_commit_rxon(il, ctx); + + switch (ctx->vif->type) { + case NL80211_IFTYPE_STATION: + il3945_rate_scale_init(il->hw, IL_AP_ID); + break; + case NL80211_IFTYPE_ADHOC: + il3945_send_beacon_cmd(il); + break; + default: + IL_ERR("%s Should not be called in %d mode\n", + __func__, ctx->vif->type); + break; + } +} + +/***************************************************************************** + * + * mac80211 entry point functions + * + *****************************************************************************/ + +#define UCODE_READY_TIMEOUT (2 * HZ) + +static int il3945_mac_start(struct ieee80211_hw *hw) +{ + struct il_priv *il = hw->priv; + int ret; + + D_MAC80211("enter\n"); + + /* we should be verifying the device is ready to be opened */ + mutex_lock(&il->mutex); + + /* fetch ucode file from disk, alloc and copy to bus-master buffers ... + * ucode filename and max sizes are card-specific. */ + + if (!il->ucode_code.len) { + ret = il3945_read_ucode(il); + if (ret) { + IL_ERR("Could not read microcode: %d\n", ret); + mutex_unlock(&il->mutex); + goto out_release_irq; + } + } + + ret = __il3945_up(il); + + mutex_unlock(&il->mutex); + + if (ret) + goto out_release_irq; + + D_INFO("Start UP work.\n"); + + /* Wait for START_ALIVE from ucode. Otherwise callbacks from + * mac80211 will not be run successfully. */ + ret = wait_event_timeout(il->wait_command_queue, + test_bit(STATUS_READY, &il->status), + UCODE_READY_TIMEOUT); + if (!ret) { + if (!test_bit(STATUS_READY, &il->status)) { + IL_ERR( + "Wait for START_ALIVE timeout after %dms.\n", + jiffies_to_msecs(UCODE_READY_TIMEOUT)); + ret = -ETIMEDOUT; + goto out_release_irq; + } + } + + /* ucode is running and will send rfkill notifications, + * no need to poll the killswitch state anymore */ + cancel_delayed_work(&il->_3945.rfkill_poll); + + il->is_open = 1; + D_MAC80211("leave\n"); + return 0; + +out_release_irq: + il->is_open = 0; + D_MAC80211("leave - failed\n"); + return ret; +} + +static void il3945_mac_stop(struct ieee80211_hw *hw) +{ + struct il_priv *il = hw->priv; + + D_MAC80211("enter\n"); + + if (!il->is_open) { + D_MAC80211("leave - skip\n"); + return; + } + + il->is_open = 0; + + il3945_down(il); + + flush_workqueue(il->workqueue); + + /* start polling the killswitch state again */ + queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, + round_jiffies_relative(2 * HZ)); + + D_MAC80211("leave\n"); +} + +static void il3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) +{ + struct il_priv *il = hw->priv; + + D_MAC80211("enter\n"); + + D_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, + ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); + + if (il3945_tx_skb(il, skb)) + dev_kfree_skb_any(skb); + + D_MAC80211("leave\n"); +} + +void il3945_config_ap(struct il_priv *il) +{ + struct il_rxon_context *ctx = &il->ctx; + struct ieee80211_vif *vif = ctx->vif; + int rc = 0; + + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + return; + + /* The following should be done only at AP bring up */ + if (!(il_is_associated(il))) { + + /* RXON - unassoc (to set timing command) */ + ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; + il3945_commit_rxon(il, ctx); + + /* RXON Timing */ + rc = il_send_rxon_timing(il, ctx); + if (rc) + IL_WARN("REPLY_RXON_TIMING failed - " + "Attempting to continue.\n"); + + ctx->staging.assoc_id = 0; + + if (vif->bss_conf.use_short_preamble) + ctx->staging.flags |= + RXON_FLG_SHORT_PREAMBLE_MSK; + else + ctx->staging.flags &= + ~RXON_FLG_SHORT_PREAMBLE_MSK; + + if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) { + if (vif->bss_conf.use_short_slot) + ctx->staging.flags |= + RXON_FLG_SHORT_SLOT_MSK; + else + ctx->staging.flags &= + ~RXON_FLG_SHORT_SLOT_MSK; + } + /* restore RXON assoc */ + ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; + il3945_commit_rxon(il, ctx); + } + il3945_send_beacon_cmd(il); +} + +static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta, + struct ieee80211_key_conf *key) +{ + struct il_priv *il = hw->priv; + int ret = 0; + u8 sta_id = IL_INVALID_STATION; + u8 static_key; + + D_MAC80211("enter\n"); + + if (il3945_mod_params.sw_crypto) { + D_MAC80211("leave - hwcrypto disabled\n"); + return -EOPNOTSUPP; + } + + /* + * To support IBSS RSN, don't program group keys in IBSS, the + * hardware will then not attempt to decrypt the frames. + */ + if (vif->type == NL80211_IFTYPE_ADHOC && + !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) + return -EOPNOTSUPP; + + static_key = !il_is_associated(il); + + if (!static_key) { + sta_id = il_sta_id_or_broadcast( + il, &il->ctx, sta); + if (sta_id == IL_INVALID_STATION) + return -EINVAL; + } + + mutex_lock(&il->mutex); + il_scan_cancel_timeout(il, 100); + + switch (cmd) { + case SET_KEY: + if (static_key) + ret = il3945_set_static_key(il, key); + else + ret = il3945_set_dynamic_key(il, key, sta_id); + D_MAC80211("enable hwcrypto key\n"); + break; + case DISABLE_KEY: + if (static_key) + ret = il3945_remove_static_key(il); + else + ret = il3945_clear_sta_key_info(il, sta_id); + D_MAC80211("disable hwcrypto key\n"); + break; + default: + ret = -EINVAL; + } + + mutex_unlock(&il->mutex); + D_MAC80211("leave\n"); + + return ret; +} + +static int il3945_mac_sta_add(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta) +{ + struct il_priv *il = hw->priv; + struct il3945_sta_priv *sta_priv = (void *)sta->drv_priv; + int ret; + bool is_ap = vif->type == NL80211_IFTYPE_STATION; + u8 sta_id; + + D_INFO("received request to add station %pM\n", + sta->addr); + mutex_lock(&il->mutex); + D_INFO("proceeding to add station %pM\n", + sta->addr); + sta_priv->common.sta_id = IL_INVALID_STATION; + + + ret = il_add_station_common(il, + &il->ctx, + sta->addr, is_ap, sta, &sta_id); + if (ret) { + IL_ERR("Unable to add station %pM (%d)\n", + sta->addr, ret); + /* Should we return success if return code is EEXIST ? */ + mutex_unlock(&il->mutex); + return ret; + } + + sta_priv->common.sta_id = sta_id; + + /* Initialize rate scaling */ + D_INFO("Initializing rate scaling for station %pM\n", + sta->addr); + il3945_rs_rate_init(il, sta, sta_id); + mutex_unlock(&il->mutex); + + return 0; +} + +static void il3945_configure_filter(struct ieee80211_hw *hw, + unsigned int changed_flags, + unsigned int *total_flags, + u64 multicast) +{ + struct il_priv *il = hw->priv; + __le32 filter_or = 0, filter_nand = 0; + struct il_rxon_context *ctx = &il->ctx; + +#define CHK(test, flag) do { \ + if (*total_flags & (test)) \ + filter_or |= (flag); \ + else \ + filter_nand |= (flag); \ + } while (0) + + D_MAC80211("Enter: changed: 0x%x, total: 0x%x\n", + changed_flags, *total_flags); + + CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); + CHK(FIF_CONTROL, RXON_FILTER_CTL2HOST_MSK); + CHK(FIF_BCN_PRBRESP_PROMISC, RXON_FILTER_BCON_AWARE_MSK); + +#undef CHK + + mutex_lock(&il->mutex); + + ctx->staging.filter_flags &= ~filter_nand; + ctx->staging.filter_flags |= filter_or; + + /* + * Not committing directly because hardware can perform a scan, + * but even if hw is ready, committing here breaks for some reason, + * we'll eventually commit the filter flags change anyway. + */ + + mutex_unlock(&il->mutex); + + /* + * Receiving all multicast frames is always enabled by the + * default flags setup in il_connection_init_rx_config() + * since we currently do not support programming multicast + * filters into the device. + */ + *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | + FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; +} + + +/***************************************************************************** + * + * sysfs attributes + * + *****************************************************************************/ + +#ifdef CONFIG_IWLEGACY_DEBUG + +/* + * The following adds a new attribute to the sysfs representation + * of this device driver (i.e. a new file in /sys/bus/pci/drivers/iwl/) + * used for controlling the debug level. + * + * See the level definitions in iwl for details. + * + * The debug_level being managed using sysfs below is a per device debug + * level that is used instead of the global debug level if it (the per + * device debug level) is set. + */ +static ssize_t il3945_show_debug_level(struct device *d, + struct device_attribute *attr, char *buf) +{ + struct il_priv *il = dev_get_drvdata(d); + return sprintf(buf, "0x%08X\n", il_get_debug_level(il)); +} +static ssize_t il3945_store_debug_level(struct device *d, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct il_priv *il = dev_get_drvdata(d); + unsigned long val; + int ret; + + ret = strict_strtoul(buf, 0, &val); + if (ret) + IL_INFO("%s is not in hex or decimal form.\n", buf); + else { + il->debug_level = val; + if (il_alloc_traffic_mem(il)) + IL_ERR( + "Not enough memory to generate traffic log\n"); + } + return strnlen(buf, count); +} + +static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, + il3945_show_debug_level, il3945_store_debug_level); + +#endif /* CONFIG_IWLEGACY_DEBUG */ + +static ssize_t il3945_show_temperature(struct device *d, + struct device_attribute *attr, char *buf) +{ + struct il_priv *il = dev_get_drvdata(d); + + if (!il_is_alive(il)) + return -EAGAIN; + + return sprintf(buf, "%d\n", il3945_hw_get_temperature(il)); +} + +static DEVICE_ATTR(temperature, S_IRUGO, il3945_show_temperature, NULL); + +static ssize_t il3945_show_tx_power(struct device *d, + struct device_attribute *attr, char *buf) +{ + struct il_priv *il = dev_get_drvdata(d); + return sprintf(buf, "%d\n", il->tx_power_user_lmt); +} + +static ssize_t il3945_store_tx_power(struct device *d, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct il_priv *il = dev_get_drvdata(d); + char *p = (char *)buf; + u32 val; + + val = simple_strtoul(p, &p, 10); + if (p == buf) + IL_INFO(": %s is not in decimal form.\n", buf); + else + il3945_hw_reg_set_txpower(il, val); + + return count; +} + +static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, il3945_show_tx_power, il3945_store_tx_power); + +static ssize_t il3945_show_flags(struct device *d, + struct device_attribute *attr, char *buf) +{ + struct il_priv *il = dev_get_drvdata(d); + struct il_rxon_context *ctx = &il->ctx; + + return sprintf(buf, "0x%04X\n", ctx->active.flags); +} + +static ssize_t il3945_store_flags(struct device *d, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct il_priv *il = dev_get_drvdata(d); + u32 flags = simple_strtoul(buf, NULL, 0); + struct il_rxon_context *ctx = &il->ctx; + + mutex_lock(&il->mutex); + if (le32_to_cpu(ctx->staging.flags) != flags) { + /* Cancel any currently running scans... */ + if (il_scan_cancel_timeout(il, 100)) + IL_WARN("Could not cancel scan.\n"); + else { + D_INFO("Committing rxon.flags = 0x%04X\n", + flags); + ctx->staging.flags = cpu_to_le32(flags); + il3945_commit_rxon(il, ctx); + } + } + mutex_unlock(&il->mutex); + + return count; +} + +static DEVICE_ATTR(flags, S_IWUSR | S_IRUGO, il3945_show_flags, il3945_store_flags); + +static ssize_t il3945_show_filter_flags(struct device *d, + struct device_attribute *attr, char *buf) +{ + struct il_priv *il = dev_get_drvdata(d); + struct il_rxon_context *ctx = &il->ctx; + + return sprintf(buf, "0x%04X\n", + le32_to_cpu(ctx->active.filter_flags)); +} + +static ssize_t il3945_store_filter_flags(struct device *d, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct il_priv *il = dev_get_drvdata(d); + struct il_rxon_context *ctx = &il->ctx; + u32 filter_flags = simple_strtoul(buf, NULL, 0); + + mutex_lock(&il->mutex); + if (le32_to_cpu(ctx->staging.filter_flags) != filter_flags) { + /* Cancel any currently running scans... */ + if (il_scan_cancel_timeout(il, 100)) + IL_WARN("Could not cancel scan.\n"); + else { + D_INFO("Committing rxon.filter_flags = " + "0x%04X\n", filter_flags); + ctx->staging.filter_flags = + cpu_to_le32(filter_flags); + il3945_commit_rxon(il, ctx); + } + } + mutex_unlock(&il->mutex); + + return count; +} + +static DEVICE_ATTR(filter_flags, S_IWUSR | S_IRUGO, il3945_show_filter_flags, + il3945_store_filter_flags); + +static ssize_t il3945_show_measurement(struct device *d, + struct device_attribute *attr, char *buf) +{ + struct il_priv *il = dev_get_drvdata(d); + struct il_spectrum_notification measure_report; + u32 size = sizeof(measure_report), len = 0, ofs = 0; + u8 *data = (u8 *)&measure_report; + unsigned long flags; + + spin_lock_irqsave(&il->lock, flags); + if (!(il->measurement_status & MEASUREMENT_READY)) { + spin_unlock_irqrestore(&il->lock, flags); + return 0; + } + memcpy(&measure_report, &il->measure_report, size); + il->measurement_status = 0; + spin_unlock_irqrestore(&il->lock, flags); + + while (size && PAGE_SIZE - len) { + hex_dump_to_buffer(data + ofs, size, 16, 1, buf + len, + PAGE_SIZE - len, 1); + len = strlen(buf); + if (PAGE_SIZE - len) + buf[len++] = '\n'; + + ofs += 16; + size -= min(size, 16U); + } + + return len; +} + +static ssize_t il3945_store_measurement(struct device *d, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct il_priv *il = dev_get_drvdata(d); + struct il_rxon_context *ctx = &il->ctx; + struct ieee80211_measurement_params params = { + .channel = le16_to_cpu(ctx->active.channel), + .start_time = cpu_to_le64(il->_3945.last_tsf), + .duration = cpu_to_le16(1), + }; + u8 type = IL_MEASURE_BASIC; + u8 buffer[32]; + u8 channel; + + if (count) { + char *p = buffer; + strncpy(buffer, buf, min(sizeof(buffer), count)); + channel = simple_strtoul(p, NULL, 0); + if (channel) + params.channel = channel; + + p = buffer; + while (*p && *p != ' ') + p++; + if (*p) + type = simple_strtoul(p + 1, NULL, 0); + } + + D_INFO("Invoking measurement of type %d on " + "channel %d (for '%s')\n", type, params.channel, buf); + il3945_get_measurement(il, ¶ms, type); + + return count; +} + +static DEVICE_ATTR(measurement, S_IRUSR | S_IWUSR, + il3945_show_measurement, il3945_store_measurement); + +static ssize_t il3945_store_retry_rate(struct device *d, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct il_priv *il = dev_get_drvdata(d); + + il->retry_rate = simple_strtoul(buf, NULL, 0); + if (il->retry_rate <= 0) + il->retry_rate = 1; + + return count; +} + +static ssize_t il3945_show_retry_rate(struct device *d, + struct device_attribute *attr, char *buf) +{ + struct il_priv *il = dev_get_drvdata(d); + return sprintf(buf, "%d", il->retry_rate); +} + +static DEVICE_ATTR(retry_rate, S_IWUSR | S_IRUSR, il3945_show_retry_rate, + il3945_store_retry_rate); + + +static ssize_t il3945_show_channels(struct device *d, + struct device_attribute *attr, char *buf) +{ + /* all this shit doesn't belong into sysfs anyway */ + return 0; +} + +static DEVICE_ATTR(channels, S_IRUSR, il3945_show_channels, NULL); + +static ssize_t il3945_show_antenna(struct device *d, + struct device_attribute *attr, char *buf) +{ + struct il_priv *il = dev_get_drvdata(d); + + if (!il_is_alive(il)) + return -EAGAIN; + + return sprintf(buf, "%d\n", il3945_mod_params.antenna); +} + +static ssize_t il3945_store_antenna(struct device *d, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct il_priv *il __maybe_unused = dev_get_drvdata(d); + int ant; + + if (count == 0) + return 0; + + if (sscanf(buf, "%1i", &ant) != 1) { + D_INFO("not in hex or decimal form.\n"); + return count; + } + + if (ant >= 0 && ant <= 2) { + D_INFO("Setting antenna select to %d.\n", ant); + il3945_mod_params.antenna = (enum il3945_antenna)ant; + } else + D_INFO("Bad antenna select value %d.\n", ant); + + + return count; +} + +static DEVICE_ATTR(antenna, S_IWUSR | S_IRUGO, il3945_show_antenna, il3945_store_antenna); + +static ssize_t il3945_show_status(struct device *d, + struct device_attribute *attr, char *buf) +{ + struct il_priv *il = dev_get_drvdata(d); + if (!il_is_alive(il)) + return -EAGAIN; + return sprintf(buf, "0x%08x\n", (int)il->status); +} + +static DEVICE_ATTR(status, S_IRUGO, il3945_show_status, NULL); + +static ssize_t il3945_dump_error_log(struct device *d, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct il_priv *il = dev_get_drvdata(d); + char *p = (char *)buf; + + if (p[0] == '1') + il3945_dump_nic_error_log(il); + + return strnlen(buf, count); +} + +static DEVICE_ATTR(dump_errors, S_IWUSR, NULL, il3945_dump_error_log); + +/***************************************************************************** + * + * driver setup and tear down + * + *****************************************************************************/ + +static void il3945_setup_deferred_work(struct il_priv *il) +{ + il->workqueue = create_singlethread_workqueue(DRV_NAME); + + init_waitqueue_head(&il->wait_command_queue); + + INIT_WORK(&il->restart, il3945_bg_restart); + INIT_WORK(&il->rx_replenish, il3945_bg_rx_replenish); + INIT_DELAYED_WORK(&il->init_alive_start, il3945_bg_init_alive_start); + INIT_DELAYED_WORK(&il->alive_start, il3945_bg_alive_start); + INIT_DELAYED_WORK(&il->_3945.rfkill_poll, il3945_rfkill_poll); + + il_setup_scan_deferred_work(il); + + il3945_hw_setup_deferred_work(il); + + init_timer(&il->watchdog); + il->watchdog.data = (unsigned long)il; + il->watchdog.function = il_bg_watchdog; + + tasklet_init(&il->irq_tasklet, (void (*)(unsigned long)) + il3945_irq_tasklet, (unsigned long)il); +} + +static void il3945_cancel_deferred_work(struct il_priv *il) +{ + il3945_hw_cancel_deferred_work(il); + + cancel_delayed_work_sync(&il->init_alive_start); + cancel_delayed_work(&il->alive_start); + + il_cancel_scan_deferred_work(il); +} + +static struct attribute *il3945_sysfs_entries[] = { + &dev_attr_antenna.attr, + &dev_attr_channels.attr, + &dev_attr_dump_errors.attr, + &dev_attr_flags.attr, + &dev_attr_filter_flags.attr, + &dev_attr_measurement.attr, + &dev_attr_retry_rate.attr, + &dev_attr_status.attr, + &dev_attr_temperature.attr, + &dev_attr_tx_power.attr, +#ifdef CONFIG_IWLEGACY_DEBUG + &dev_attr_debug_level.attr, +#endif + NULL +}; + +static struct attribute_group il3945_attribute_group = { + .name = NULL, /* put in device directory */ + .attrs = il3945_sysfs_entries, +}; + +struct ieee80211_ops il3945_hw_ops = { + .tx = il3945_mac_tx, + .start = il3945_mac_start, + .stop = il3945_mac_stop, + .add_interface = il_mac_add_interface, + .remove_interface = il_mac_remove_interface, + .change_interface = il_mac_change_interface, + .config = il_mac_config, + .configure_filter = il3945_configure_filter, + .set_key = il3945_mac_set_key, + .conf_tx = il_mac_conf_tx, + .reset_tsf = il_mac_reset_tsf, + .bss_info_changed = il_mac_bss_info_changed, + .hw_scan = il_mac_hw_scan, + .sta_add = il3945_mac_sta_add, + .sta_remove = il_mac_sta_remove, + .tx_last_beacon = il_mac_tx_last_beacon, +}; + +static int il3945_init_drv(struct il_priv *il) +{ + int ret; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; + + il->retry_rate = 1; + il->beacon_skb = NULL; + + spin_lock_init(&il->sta_lock); + spin_lock_init(&il->hcmd_lock); + + INIT_LIST_HEAD(&il->free_frames); + + mutex_init(&il->mutex); + + il->ieee_channels = NULL; + il->ieee_rates = NULL; + il->band = IEEE80211_BAND_2GHZ; + + il->iw_mode = NL80211_IFTYPE_STATION; + il->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; + + /* initialize force reset */ + il->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; + + if (eeprom->version < EEPROM_3945_EEPROM_VERSION) { + IL_WARN("Unsupported EEPROM version: 0x%04X\n", + eeprom->version); + ret = -EINVAL; + goto err; + } + ret = il_init_channel_map(il); + if (ret) { + IL_ERR("initializing regulatory failed: %d\n", ret); + goto err; + } + + /* Set up txpower settings in driver for all channels */ + if (il3945_txpower_set_from_eeprom(il)) { + ret = -EIO; + goto err_free_channel_map; + } + + ret = il_init_geos(il); + if (ret) { + IL_ERR("initializing geos failed: %d\n", ret); + goto err_free_channel_map; + } + il3945_init_hw_rates(il, il->ieee_rates); + + return 0; + +err_free_channel_map: + il_free_channel_map(il); +err: + return ret; +} + +#define IL3945_MAX_PROBE_REQUEST 200 + +static int il3945_setup_mac(struct il_priv *il) +{ + int ret; + struct ieee80211_hw *hw = il->hw; + + hw->rate_control_algorithm = "iwl-3945-rs"; + hw->sta_data_size = sizeof(struct il3945_sta_priv); + hw->vif_data_size = sizeof(struct il_vif_priv); + + /* Tell mac80211 our characteristics */ + hw->flags = IEEE80211_HW_SIGNAL_DBM | + IEEE80211_HW_SPECTRUM_MGMT; + + hw->wiphy->interface_modes = + il->ctx.interface_modes; + + hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | + WIPHY_FLAG_DISABLE_BEACON_HINTS | + WIPHY_FLAG_IBSS_RSN; + + hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX_3945; + /* we create the 802.11 header and a zero-length SSID element */ + hw->wiphy->max_scan_ie_len = IL3945_MAX_PROBE_REQUEST - 24 - 2; + + /* Default value; 4 EDCA QOS priorities */ + hw->queues = 4; + + if (il->bands[IEEE80211_BAND_2GHZ].n_channels) + il->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = + &il->bands[IEEE80211_BAND_2GHZ]; + + if (il->bands[IEEE80211_BAND_5GHZ].n_channels) + il->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = + &il->bands[IEEE80211_BAND_5GHZ]; + + il_leds_init(il); + + ret = ieee80211_register_hw(il->hw); + if (ret) { + IL_ERR("Failed to register hw (error %d)\n", ret); + return ret; + } + il->mac80211_registered = 1; + + return 0; +} + +static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) +{ + int err = 0; + struct il_priv *il; + struct ieee80211_hw *hw; + struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data); + struct il3945_eeprom *eeprom; + unsigned long flags; + + /*********************** + * 1. Allocating HW data + * ********************/ + + /* mac80211 allocates memory for this device instance, including + * space for this driver's ilate structure */ + hw = il_alloc_all(cfg); + if (hw == NULL) { + pr_err("Can not allocate network device\n"); + err = -ENOMEM; + goto out; + } + il = hw->priv; + SET_IEEE80211_DEV(hw, &pdev->dev); + + il->cmd_queue = IL39_CMD_QUEUE_NUM; + + il->ctx.ctxid = 0; + + il->ctx.rxon_cmd = REPLY_RXON; + il->ctx.rxon_timing_cmd = REPLY_RXON_TIMING; + il->ctx.rxon_assoc_cmd = REPLY_RXON_ASSOC; + il->ctx.qos_cmd = REPLY_QOS_PARAM; + il->ctx.ap_sta_id = IL_AP_ID; + il->ctx.wep_key_cmd = REPLY_WEPKEY; + il->ctx.interface_modes = + BIT(NL80211_IFTYPE_STATION) | + BIT(NL80211_IFTYPE_ADHOC); + il->ctx.ibss_devtype = RXON_DEV_TYPE_IBSS; + il->ctx.station_devtype = RXON_DEV_TYPE_ESS; + il->ctx.unused_devtype = RXON_DEV_TYPE_ESS; + + /* + * Disabling hardware scan means that mac80211 will perform scans + * "the hard way", rather than using device's scan. + */ + if (il3945_mod_params.disable_hw_scan) { + D_INFO("Disabling hw_scan\n"); + il3945_hw_ops.hw_scan = NULL; + } + + D_INFO("*** LOAD DRIVER ***\n"); + il->cfg = cfg; + il->pci_dev = pdev; + il->inta_mask = CSR_INI_SET_MASK; + + if (il_alloc_traffic_mem(il)) + IL_ERR("Not enough memory to generate traffic log\n"); + + /*************************** + * 2. Initializing PCI bus + * *************************/ + pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | + PCIE_LINK_STATE_CLKPM); + + if (pci_enable_device(pdev)) { + err = -ENODEV; + goto out_ieee80211_free_hw; + } + + pci_set_master(pdev); + + err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); + if (!err) + err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); + if (err) { + IL_WARN("No suitable DMA available.\n"); + goto out_pci_disable_device; + } + + pci_set_drvdata(pdev, il); + err = pci_request_regions(pdev, DRV_NAME); + if (err) + goto out_pci_disable_device; + + /*********************** + * 3. Read REV Register + * ********************/ + il->hw_base = pci_iomap(pdev, 0, 0); + if (!il->hw_base) { + err = -ENODEV; + goto out_pci_release_regions; + } + + D_INFO("pci_resource_len = 0x%08llx\n", + (unsigned long long) pci_resource_len(pdev, 0)); + D_INFO("pci_resource_base = %p\n", il->hw_base); + + /* We disable the RETRY_TIMEOUT register (0x41) to keep + * PCI Tx retries from interfering with C3 CPU state */ + pci_write_config_byte(pdev, 0x41, 0x00); + + /* these spin locks will be used in apm_ops.init and EEPROM access + * we should init now + */ + spin_lock_init(&il->reg_lock); + spin_lock_init(&il->lock); + + /* + * stop and reset the on-board processor just in case it is in a + * strange state ... like being left stranded by a primary kernel + * and this is now the kdump kernel trying to start up + */ + _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + + /*********************** + * 4. Read EEPROM + * ********************/ + + /* Read the EEPROM */ + err = il_eeprom_init(il); + if (err) { + IL_ERR("Unable to init EEPROM\n"); + goto out_iounmap; + } + /* MAC Address location in EEPROM same for 3945/4965 */ + eeprom = (struct il3945_eeprom *)il->eeprom; + D_INFO("MAC address: %pM\n", eeprom->mac_address); + SET_IEEE80211_PERM_ADDR(il->hw, eeprom->mac_address); + + /*********************** + * 5. Setup HW Constants + * ********************/ + /* Device-specific setup */ + if (il3945_hw_set_hw_params(il)) { + IL_ERR("failed to set hw settings\n"); + goto out_eeprom_free; + } + + /*********************** + * 6. Setup il + * ********************/ + + err = il3945_init_drv(il); + if (err) { + IL_ERR("initializing driver failed\n"); + goto out_unset_hw_params; + } + + IL_INFO("Detected Intel Wireless WiFi Link %s\n", + il->cfg->name); + + /*********************** + * 7. Setup Services + * ********************/ + + spin_lock_irqsave(&il->lock, flags); + il_disable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); + + pci_enable_msi(il->pci_dev); + + err = request_irq(il->pci_dev->irq, il_isr, + IRQF_SHARED, DRV_NAME, il); + if (err) { + IL_ERR("Error allocating IRQ %d\n", il->pci_dev->irq); + goto out_disable_msi; + } + + err = sysfs_create_group(&pdev->dev.kobj, &il3945_attribute_group); + if (err) { + IL_ERR("failed to create sysfs device attributes\n"); + goto out_release_irq; + } + + il_set_rxon_channel(il, + &il->bands[IEEE80211_BAND_2GHZ].channels[5], + &il->ctx); + il3945_setup_deferred_work(il); + il3945_setup_rx_handlers(il); + il_power_initialize(il); + + /********************************* + * 8. Setup and Register mac80211 + * *******************************/ + + il_enable_interrupts(il); + + err = il3945_setup_mac(il); + if (err) + goto out_remove_sysfs; + + err = il_dbgfs_register(il, DRV_NAME); + if (err) + IL_ERR("failed to create debugfs files. Ignoring error: %d\n", err); + + /* Start monitoring the killswitch */ + queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, + 2 * HZ); + + return 0; + + out_remove_sysfs: + destroy_workqueue(il->workqueue); + il->workqueue = NULL; + sysfs_remove_group(&pdev->dev.kobj, &il3945_attribute_group); + out_release_irq: + free_irq(il->pci_dev->irq, il); + out_disable_msi: + pci_disable_msi(il->pci_dev); + il_free_geos(il); + il_free_channel_map(il); + out_unset_hw_params: + il3945_unset_hw_params(il); + out_eeprom_free: + il_eeprom_free(il); + out_iounmap: + pci_iounmap(pdev, il->hw_base); + out_pci_release_regions: + pci_release_regions(pdev); + out_pci_disable_device: + pci_set_drvdata(pdev, NULL); + pci_disable_device(pdev); + out_ieee80211_free_hw: + il_free_traffic_mem(il); + ieee80211_free_hw(il->hw); + out: + return err; +} + +static void __devexit il3945_pci_remove(struct pci_dev *pdev) +{ + struct il_priv *il = pci_get_drvdata(pdev); + unsigned long flags; + + if (!il) + return; + + D_INFO("*** UNLOAD DRIVER ***\n"); + + il_dbgfs_unregister(il); + + set_bit(STATUS_EXIT_PENDING, &il->status); + + il_leds_exit(il); + + if (il->mac80211_registered) { + ieee80211_unregister_hw(il->hw); + il->mac80211_registered = 0; + } else { + il3945_down(il); + } + + /* + * Make sure device is reset to low power before unloading driver. + * This may be redundant with il_down(), but there are paths to + * run il_down() without calling apm_ops.stop(), and there are + * paths to avoid running il_down() at all before leaving driver. + * This (inexpensive) call *makes sure* device is reset. + */ + il_apm_stop(il); + + /* make sure we flush any pending irq or + * tasklet for the driver + */ + spin_lock_irqsave(&il->lock, flags); + il_disable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); + + il3945_synchronize_irq(il); + + sysfs_remove_group(&pdev->dev.kobj, &il3945_attribute_group); + + cancel_delayed_work_sync(&il->_3945.rfkill_poll); + + il3945_dealloc_ucode_pci(il); + + if (il->rxq.bd) + il3945_rx_queue_free(il, &il->rxq); + il3945_hw_txq_ctx_free(il); + + il3945_unset_hw_params(il); + + /*netif_stop_queue(dev); */ + flush_workqueue(il->workqueue); + + /* ieee80211_unregister_hw calls il3945_mac_stop, which flushes + * il->workqueue... so we can't take down the workqueue + * until now... */ + destroy_workqueue(il->workqueue); + il->workqueue = NULL; + il_free_traffic_mem(il); + + free_irq(pdev->irq, il); + pci_disable_msi(pdev); + + pci_iounmap(pdev, il->hw_base); + pci_release_regions(pdev); + pci_disable_device(pdev); + pci_set_drvdata(pdev, NULL); + + il_free_channel_map(il); + il_free_geos(il); + kfree(il->scan_cmd); + if (il->beacon_skb) + dev_kfree_skb(il->beacon_skb); + + ieee80211_free_hw(il->hw); +} + + +/***************************************************************************** + * + * driver and module entry point + * + *****************************************************************************/ + +static struct pci_driver il3945_driver = { + .name = DRV_NAME, + .id_table = il3945_hw_card_ids, + .probe = il3945_pci_probe, + .remove = __devexit_p(il3945_pci_remove), + .driver.pm = IL_LEGACY_PM_OPS, +}; + +static int __init il3945_init(void) +{ + + int ret; + pr_info(DRV_DESCRIPTION ", " DRV_VERSION "\n"); + pr_info(DRV_COPYRIGHT "\n"); + + ret = il3945_rate_control_register(); + if (ret) { + pr_err("Unable to register rate control algorithm: %d\n", ret); + return ret; + } + + ret = pci_register_driver(&il3945_driver); + if (ret) { + pr_err("Unable to initialize PCI module\n"); + goto error_register; + } + + return ret; + +error_register: + il3945_rate_control_unregister(); + return ret; +} + +static void __exit il3945_exit(void) +{ + pci_unregister_driver(&il3945_driver); + il3945_rate_control_unregister(); +} + +MODULE_FIRMWARE(IL3945_MODULE_FIRMWARE(IL3945_UCODE_API_MAX)); + +module_param_named(antenna, il3945_mod_params.antenna, int, S_IRUGO); +MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])"); +module_param_named(swcrypto, il3945_mod_params.sw_crypto, int, S_IRUGO); +MODULE_PARM_DESC(swcrypto, + "using software crypto (default 1 [software])"); +module_param_named(disable_hw_scan, il3945_mod_params.disable_hw_scan, + int, S_IRUGO); +MODULE_PARM_DESC(disable_hw_scan, "disable hardware scanning (default 1)"); +#ifdef CONFIG_IWLEGACY_DEBUG +module_param_named(debug, il_debug_level, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(debug, "debug output mask"); +#endif +module_param_named(fw_restart, il3945_mod_params.restart_fw, int, S_IRUGO); +MODULE_PARM_DESC(fw_restart, "restart firmware in case of error"); + +module_exit(il3945_exit); +module_init(il3945_init); diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c new file mode 100644 index 000000000000..b6abf3473fac --- /dev/null +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -0,0 +1,2740 @@ +/****************************************************************************** + * + * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + *****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "iwl-fh.h" +#include "iwl-3945-fh.h" +#include "iwl-commands.h" +#include "iwl-sta.h" +#include "iwl-3945.h" +#include "iwl-eeprom.h" +#include "iwl-core.h" +#include "iwl-helpers.h" +#include "iwl-led.h" +#include "iwl-3945-led.h" +#include "iwl-3945-debugfs.h" + +#define IL_DECLARE_RATE_INFO(r, ip, in, rp, rn, pp, np) \ + [RATE_##r##M_IDX] = { RATE_##r##M_PLCP, \ + RATE_##r##M_IEEE, \ + RATE_##ip##M_IDX, \ + RATE_##in##M_IDX, \ + RATE_##rp##M_IDX, \ + RATE_##rn##M_IDX, \ + RATE_##pp##M_IDX, \ + RATE_##np##M_IDX, \ + RATE_##r##M_IDX_TBL, \ + RATE_##ip##M_IDX_TBL } + +/* + * Parameter order: + * rate, prev rate, next rate, prev tgg rate, next tgg rate + * + * If there isn't a valid next or previous rate then INV is used which + * maps to RATE_INVALID + * + */ +const struct il3945_rate_info il3945_rates[RATE_COUNT_3945] = { + IL_DECLARE_RATE_INFO(1, INV, 2, INV, 2, INV, 2), /* 1mbps */ + IL_DECLARE_RATE_INFO(2, 1, 5, 1, 5, 1, 5), /* 2mbps */ + IL_DECLARE_RATE_INFO(5, 2, 6, 2, 11, 2, 11), /*5.5mbps */ + IL_DECLARE_RATE_INFO(11, 9, 12, 5, 12, 5, 18), /* 11mbps */ + IL_DECLARE_RATE_INFO(6, 5, 9, 5, 11, 5, 11), /* 6mbps */ + IL_DECLARE_RATE_INFO(9, 6, 11, 5, 11, 5, 11), /* 9mbps */ + IL_DECLARE_RATE_INFO(12, 11, 18, 11, 18, 11, 18), /* 12mbps */ + IL_DECLARE_RATE_INFO(18, 12, 24, 12, 24, 11, 24), /* 18mbps */ + IL_DECLARE_RATE_INFO(24, 18, 36, 18, 36, 18, 36), /* 24mbps */ + IL_DECLARE_RATE_INFO(36, 24, 48, 24, 48, 24, 48), /* 36mbps */ + IL_DECLARE_RATE_INFO(48, 36, 54, 36, 54, 36, 54), /* 48mbps */ + IL_DECLARE_RATE_INFO(54, 48, INV, 48, INV, 48, INV),/* 54mbps */ +}; + +static inline u8 il3945_get_prev_ieee_rate(u8 rate_idx) +{ + u8 rate = il3945_rates[rate_idx].prev_ieee; + + if (rate == RATE_INVALID) + rate = rate_idx; + return rate; +} + +/* 1 = enable the il3945_disable_events() function */ +#define IL_EVT_DISABLE (0) +#define IL_EVT_DISABLE_SIZE (1532/32) + +/** + * il3945_disable_events - Disable selected events in uCode event log + * + * Disable an event by writing "1"s into "disable" + * bitmap in SRAM. Bit position corresponds to Event # (id/type). + * Default values of 0 enable uCode events to be logged. + * Use for only special debugging. This function is just a placeholder as-is, + * you'll need to provide the special bits! ... + * ... and set IL_EVT_DISABLE to 1. */ +void il3945_disable_events(struct il_priv *il) +{ + int i; + u32 base; /* SRAM address of event log header */ + u32 disable_ptr; /* SRAM address of event-disable bitmap array */ + u32 array_size; /* # of u32 entries in array */ + static const u32 evt_disable[IL_EVT_DISABLE_SIZE] = { + 0x00000000, /* 31 - 0 Event id numbers */ + 0x00000000, /* 63 - 32 */ + 0x00000000, /* 95 - 64 */ + 0x00000000, /* 127 - 96 */ + 0x00000000, /* 159 - 128 */ + 0x00000000, /* 191 - 160 */ + 0x00000000, /* 223 - 192 */ + 0x00000000, /* 255 - 224 */ + 0x00000000, /* 287 - 256 */ + 0x00000000, /* 319 - 288 */ + 0x00000000, /* 351 - 320 */ + 0x00000000, /* 383 - 352 */ + 0x00000000, /* 415 - 384 */ + 0x00000000, /* 447 - 416 */ + 0x00000000, /* 479 - 448 */ + 0x00000000, /* 511 - 480 */ + 0x00000000, /* 543 - 512 */ + 0x00000000, /* 575 - 544 */ + 0x00000000, /* 607 - 576 */ + 0x00000000, /* 639 - 608 */ + 0x00000000, /* 671 - 640 */ + 0x00000000, /* 703 - 672 */ + 0x00000000, /* 735 - 704 */ + 0x00000000, /* 767 - 736 */ + 0x00000000, /* 799 - 768 */ + 0x00000000, /* 831 - 800 */ + 0x00000000, /* 863 - 832 */ + 0x00000000, /* 895 - 864 */ + 0x00000000, /* 927 - 896 */ + 0x00000000, /* 959 - 928 */ + 0x00000000, /* 991 - 960 */ + 0x00000000, /* 1023 - 992 */ + 0x00000000, /* 1055 - 1024 */ + 0x00000000, /* 1087 - 1056 */ + 0x00000000, /* 1119 - 1088 */ + 0x00000000, /* 1151 - 1120 */ + 0x00000000, /* 1183 - 1152 */ + 0x00000000, /* 1215 - 1184 */ + 0x00000000, /* 1247 - 1216 */ + 0x00000000, /* 1279 - 1248 */ + 0x00000000, /* 1311 - 1280 */ + 0x00000000, /* 1343 - 1312 */ + 0x00000000, /* 1375 - 1344 */ + 0x00000000, /* 1407 - 1376 */ + 0x00000000, /* 1439 - 1408 */ + 0x00000000, /* 1471 - 1440 */ + 0x00000000, /* 1503 - 1472 */ + }; + + base = le32_to_cpu(il->card_alive.log_event_table_ptr); + if (!il3945_hw_valid_rtc_data_addr(base)) { + IL_ERR("Invalid event log pointer 0x%08X\n", base); + return; + } + + disable_ptr = il_read_targ_mem(il, base + (4 * sizeof(u32))); + array_size = il_read_targ_mem(il, base + (5 * sizeof(u32))); + + if (IL_EVT_DISABLE && array_size == IL_EVT_DISABLE_SIZE) { + D_INFO("Disabling selected uCode log events at 0x%x\n", + disable_ptr); + for (i = 0; i < IL_EVT_DISABLE_SIZE; i++) + il_write_targ_mem(il, + disable_ptr + (i * sizeof(u32)), + evt_disable[i]); + + } else { + D_INFO("Selected uCode log events may be disabled\n"); + D_INFO(" by writing \"1\"s into disable bitmap\n"); + D_INFO(" in SRAM at 0x%x, size %d u32s\n", + disable_ptr, array_size); + } + +} + +static int il3945_hwrate_to_plcp_idx(u8 plcp) +{ + int idx; + + for (idx = 0; idx < RATE_COUNT_3945; idx++) + if (il3945_rates[idx].plcp == plcp) + return idx; + return -1; +} + +#ifdef CONFIG_IWLEGACY_DEBUG +#define TX_STATUS_ENTRY(x) case TX_3945_STATUS_FAIL_ ## x: return #x + +static const char *il3945_get_tx_fail_reason(u32 status) +{ + switch (status & TX_STATUS_MSK) { + case TX_3945_STATUS_SUCCESS: + return "SUCCESS"; + TX_STATUS_ENTRY(SHORT_LIMIT); + TX_STATUS_ENTRY(LONG_LIMIT); + TX_STATUS_ENTRY(FIFO_UNDERRUN); + TX_STATUS_ENTRY(MGMNT_ABORT); + TX_STATUS_ENTRY(NEXT_FRAG); + TX_STATUS_ENTRY(LIFE_EXPIRE); + TX_STATUS_ENTRY(DEST_PS); + TX_STATUS_ENTRY(ABORTED); + TX_STATUS_ENTRY(BT_RETRY); + TX_STATUS_ENTRY(STA_INVALID); + TX_STATUS_ENTRY(FRAG_DROPPED); + TX_STATUS_ENTRY(TID_DISABLE); + TX_STATUS_ENTRY(FRAME_FLUSHED); + TX_STATUS_ENTRY(INSUFFICIENT_CF_POLL); + TX_STATUS_ENTRY(TX_LOCKED); + TX_STATUS_ENTRY(NO_BEACON_ON_RADAR); + } + + return "UNKNOWN"; +} +#else +static inline const char *il3945_get_tx_fail_reason(u32 status) +{ + return ""; +} +#endif + +/* + * get ieee prev rate from rate scale table. + * for A and B mode we need to overright prev + * value + */ +int il3945_rs_next_rate(struct il_priv *il, int rate) +{ + int next_rate = il3945_get_prev_ieee_rate(rate); + + switch (il->band) { + case IEEE80211_BAND_5GHZ: + if (rate == RATE_12M_IDX) + next_rate = RATE_9M_IDX; + else if (rate == RATE_6M_IDX) + next_rate = RATE_6M_IDX; + break; + case IEEE80211_BAND_2GHZ: + if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && + il_is_associated(il)) { + if (rate == RATE_11M_IDX) + next_rate = RATE_5M_IDX; + } + break; + + default: + break; + } + + return next_rate; +} + + +/** + * il3945_tx_queue_reclaim - Reclaim Tx queue entries already Tx'd + * + * When FW advances 'R' idx, all entries between old and new 'R' idx + * need to be reclaimed. As result, some free space forms. If there is + * enough free space (> low mark), wake the stack that feeds us. + */ +static void il3945_tx_queue_reclaim(struct il_priv *il, + int txq_id, int idx) +{ + struct il_tx_queue *txq = &il->txq[txq_id]; + struct il_queue *q = &txq->q; + struct il_tx_info *tx_info; + + BUG_ON(txq_id == IL39_CMD_QUEUE_NUM); + + for (idx = il_queue_inc_wrap(idx, q->n_bd); + q->read_ptr != idx; + q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { + + tx_info = &txq->txb[txq->q.read_ptr]; + ieee80211_tx_status_irqsafe(il->hw, tx_info->skb); + tx_info->skb = NULL; + il->cfg->ops->lib->txq_free_tfd(il, txq); + } + + if (il_queue_space(q) > q->low_mark && txq_id >= 0 && + txq_id != IL39_CMD_QUEUE_NUM && il->mac80211_registered) + il_wake_queue(il, txq); +} + +/** + * il3945_rx_reply_tx - Handle Tx response + */ +static void il3945_rx_reply_tx(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + u16 sequence = le16_to_cpu(pkt->hdr.sequence); + int txq_id = SEQ_TO_QUEUE(sequence); + int idx = SEQ_TO_IDX(sequence); + struct il_tx_queue *txq = &il->txq[txq_id]; + struct ieee80211_tx_info *info; + struct il3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; + u32 status = le32_to_cpu(tx_resp->status); + int rate_idx; + int fail; + + if (idx >= txq->q.n_bd || il_queue_used(&txq->q, idx) == 0) { + IL_ERR("Read idx for DMA queue txq_id (%d) idx %d " + "is out of range [0-%d] %d %d\n", txq_id, + idx, txq->q.n_bd, txq->q.write_ptr, + txq->q.read_ptr); + return; + } + + txq->time_stamp = jiffies; + info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb); + ieee80211_tx_info_clear_status(info); + + /* Fill the MRR chain with some info about on-chip retransmissions */ + rate_idx = il3945_hwrate_to_plcp_idx(tx_resp->rate); + if (info->band == IEEE80211_BAND_5GHZ) + rate_idx -= IL_FIRST_OFDM_RATE; + + fail = tx_resp->failure_frame; + + info->status.rates[0].idx = rate_idx; + info->status.rates[0].count = fail + 1; /* add final attempt */ + + /* tx_status->rts_retry_count = tx_resp->failure_rts; */ + info->flags |= ((status & TX_STATUS_MSK) == TX_STATUS_SUCCESS) ? + IEEE80211_TX_STAT_ACK : 0; + + D_TX("Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", + txq_id, il3945_get_tx_fail_reason(status), status, + tx_resp->rate, tx_resp->failure_frame); + + D_TX_REPLY("Tx queue reclaim %d\n", idx); + il3945_tx_queue_reclaim(il, txq_id, idx); + + if (status & TX_ABORT_REQUIRED_MSK) + IL_ERR("TODO: Implement Tx ABORT REQUIRED!!!\n"); +} + + + +/***************************************************************************** + * + * Intel PRO/Wireless 3945ABG/BG Network Connection + * + * RX handler implementations + * + *****************************************************************************/ +#ifdef CONFIG_IWLEGACY_DEBUGFS +static void il3945_accumulative_stats(struct il_priv *il, + __le32 *stats) +{ + int i; + __le32 *prev_stats; + u32 *accum_stats; + u32 *delta, *max_delta; + + prev_stats = (__le32 *)&il->_3945.stats; + accum_stats = (u32 *)&il->_3945.accum_stats; + delta = (u32 *)&il->_3945.delta_stats; + max_delta = (u32 *)&il->_3945.max_delta; + + for (i = sizeof(__le32); i < sizeof(struct il3945_notif_stats); + i += sizeof(__le32), stats++, prev_stats++, delta++, + max_delta++, accum_stats++) { + if (le32_to_cpu(*stats) > le32_to_cpu(*prev_stats)) { + *delta = (le32_to_cpu(*stats) - + le32_to_cpu(*prev_stats)); + *accum_stats += *delta; + if (*delta > *max_delta) + *max_delta = *delta; + } + } + + /* reset accumulative stats for "no-counter" type stats */ + il->_3945.accum_stats.general.temperature = + il->_3945.stats.general.temperature; + il->_3945.accum_stats.general.ttl_timestamp = + il->_3945.stats.general.ttl_timestamp; +} +#endif + +void il3945_hw_rx_stats(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + + D_RX("Statistics notification received (%d vs %d).\n", + (int)sizeof(struct il3945_notif_stats), + le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK); +#ifdef CONFIG_IWLEGACY_DEBUGFS + il3945_accumulative_stats(il, (__le32 *)&pkt->u.raw); +#endif + + memcpy(&il->_3945.stats, pkt->u.raw, sizeof(il->_3945.stats)); +} + +void il3945_reply_stats(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + __le32 *flag = (__le32 *)&pkt->u.raw; + + if (le32_to_cpu(*flag) & UCODE_STATISTICS_CLEAR_MSK) { +#ifdef CONFIG_IWLEGACY_DEBUGFS + memset(&il->_3945.accum_stats, 0, + sizeof(struct il3945_notif_stats)); + memset(&il->_3945.delta_stats, 0, + sizeof(struct il3945_notif_stats)); + memset(&il->_3945.max_delta, 0, + sizeof(struct il3945_notif_stats)); +#endif + D_RX("Statistics have been cleared\n"); + } + il3945_hw_rx_stats(il, rxb); +} + + +/****************************************************************************** + * + * Misc. internal state and helper functions + * + ******************************************************************************/ + +/* This is necessary only for a number of stats, see the caller. */ +static int il3945_is_network_packet(struct il_priv *il, + struct ieee80211_hdr *header) +{ + /* Filter incoming packets to determine if they are targeted toward + * this network, discarding packets coming from ourselves */ + switch (il->iw_mode) { + case NL80211_IFTYPE_ADHOC: /* Header: Dest. | Source | BSSID */ + /* packets to our IBSS update information */ + return !compare_ether_addr(header->addr3, il->bssid); + case NL80211_IFTYPE_STATION: /* Header: Dest. | AP{BSSID} | Source */ + /* packets to our IBSS update information */ + return !compare_ether_addr(header->addr2, il->bssid); + default: + return 1; + } +} + +static void il3945_pass_packet_to_mac80211(struct il_priv *il, + struct il_rx_buf *rxb, + struct ieee80211_rx_status *stats) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)IL_RX_DATA(pkt); + struct il3945_rx_frame_hdr *rx_hdr = IL_RX_HDR(pkt); + struct il3945_rx_frame_end *rx_end = IL_RX_END(pkt); + u16 len = le16_to_cpu(rx_hdr->len); + struct sk_buff *skb; + __le16 fc = hdr->frame_control; + + /* We received data from the HW, so stop the watchdog */ + if (unlikely(len + IL39_RX_FRAME_SIZE > + PAGE_SIZE << il->hw_params.rx_page_order)) { + D_DROP("Corruption detected!\n"); + return; + } + + /* We only process data packets if the interface is open */ + if (unlikely(!il->is_open)) { + D_DROP( + "Dropping packet while interface is not open.\n"); + return; + } + + skb = dev_alloc_skb(128); + if (!skb) { + IL_ERR("dev_alloc_skb failed\n"); + return; + } + + if (!il3945_mod_params.sw_crypto) + il_set_decrypted_flag(il, + (struct ieee80211_hdr *)rxb_addr(rxb), + le32_to_cpu(rx_end->status), stats); + + skb_add_rx_frag(skb, 0, rxb->page, + (void *)rx_hdr->payload - (void *)pkt, len); + + il_update_stats(il, false, fc, len); + memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats)); + + ieee80211_rx(il->hw, skb); + il->alloc_rxb_page--; + rxb->page = NULL; +} + +#define IL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6) + +static void il3945_rx_reply_rx(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct ieee80211_hdr *header; + struct ieee80211_rx_status rx_status; + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il3945_rx_frame_stats *rx_stats = IL_RX_STATS(pkt); + struct il3945_rx_frame_hdr *rx_hdr = IL_RX_HDR(pkt); + struct il3945_rx_frame_end *rx_end = IL_RX_END(pkt); + u16 rx_stats_sig_avg __maybe_unused = le16_to_cpu(rx_stats->sig_avg); + u16 rx_stats_noise_diff __maybe_unused = le16_to_cpu(rx_stats->noise_diff); + u8 network_packet; + + rx_status.flag = 0; + rx_status.mactime = le64_to_cpu(rx_end->timestamp); + rx_status.band = (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? + IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; + rx_status.freq = + ieee80211_channel_to_frequency(le16_to_cpu(rx_hdr->channel), + rx_status.band); + + rx_status.rate_idx = il3945_hwrate_to_plcp_idx(rx_hdr->rate); + if (rx_status.band == IEEE80211_BAND_5GHZ) + rx_status.rate_idx -= IL_FIRST_OFDM_RATE; + + rx_status.antenna = (le16_to_cpu(rx_hdr->phy_flags) & + RX_RES_PHY_FLAGS_ANTENNA_MSK) >> 4; + + /* set the preamble flag if appropriate */ + if (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK) + rx_status.flag |= RX_FLAG_SHORTPRE; + + if ((unlikely(rx_stats->phy_count > 20))) { + D_DROP("dsp size out of range [0,20]: %d/n", + rx_stats->phy_count); + return; + } + + if (!(rx_end->status & RX_RES_STATUS_NO_CRC32_ERROR) || + !(rx_end->status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { + D_RX("Bad CRC or FIFO: 0x%08X.\n", rx_end->status); + return; + } + + + + /* Convert 3945's rssi indicator to dBm */ + rx_status.signal = rx_stats->rssi - IL39_RSSI_OFFSET; + + D_STATS("Rssi %d sig_avg %d noise_diff %d\n", + rx_status.signal, rx_stats_sig_avg, + rx_stats_noise_diff); + + header = (struct ieee80211_hdr *)IL_RX_DATA(pkt); + + network_packet = il3945_is_network_packet(il, header); + + D_STATS("[%c] %d RSSI:%d Signal:%u, Rate:%u\n", + network_packet ? '*' : ' ', + le16_to_cpu(rx_hdr->channel), + rx_status.signal, rx_status.signal, + rx_status.rate_idx); + + il_dbg_log_rx_data_frame(il, le16_to_cpu(rx_hdr->len), + header); + + if (network_packet) { + il->_3945.last_beacon_time = + le32_to_cpu(rx_end->beacon_timestamp); + il->_3945.last_tsf = le64_to_cpu(rx_end->timestamp); + il->_3945.last_rx_rssi = rx_status.signal; + } + + il3945_pass_packet_to_mac80211(il, rxb, &rx_status); +} + +int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, + struct il_tx_queue *txq, + dma_addr_t addr, u16 len, u8 reset, u8 pad) +{ + int count; + struct il_queue *q; + struct il3945_tfd *tfd, *tfd_tmp; + + q = &txq->q; + tfd_tmp = (struct il3945_tfd *)txq->tfds; + tfd = &tfd_tmp[q->write_ptr]; + + if (reset) + memset(tfd, 0, sizeof(*tfd)); + + count = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags)); + + if (count >= NUM_TFD_CHUNKS || count < 0) { + IL_ERR("Error can not send more than %d chunks\n", + NUM_TFD_CHUNKS); + return -EINVAL; + } + + tfd->tbs[count].addr = cpu_to_le32(addr); + tfd->tbs[count].len = cpu_to_le32(len); + + count++; + + tfd->control_flags = cpu_to_le32(TFD_CTL_COUNT_SET(count) | + TFD_CTL_PAD_SET(pad)); + + return 0; +} + +/** + * il3945_hw_txq_free_tfd - Free one TFD, those at idx [txq->q.read_ptr] + * + * Does NOT advance any idxes + */ +void il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) +{ + struct il3945_tfd *tfd_tmp = (struct il3945_tfd *)txq->tfds; + int idx = txq->q.read_ptr; + struct il3945_tfd *tfd = &tfd_tmp[idx]; + struct pci_dev *dev = il->pci_dev; + int i; + int counter; + + /* sanity check */ + counter = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags)); + if (counter > NUM_TFD_CHUNKS) { + IL_ERR("Too many chunks: %i\n", counter); + /* @todo issue fatal error, it is quite serious situation */ + return; + } + + /* Unmap tx_cmd */ + if (counter) + pci_unmap_single(dev, + dma_unmap_addr(&txq->meta[idx], mapping), + dma_unmap_len(&txq->meta[idx], len), + PCI_DMA_TODEVICE); + + /* unmap chunks if any */ + + for (i = 1; i < counter; i++) + pci_unmap_single(dev, le32_to_cpu(tfd->tbs[i].addr), + le32_to_cpu(tfd->tbs[i].len), PCI_DMA_TODEVICE); + + /* free SKB */ + if (txq->txb) { + struct sk_buff *skb; + + skb = txq->txb[txq->q.read_ptr].skb; + + /* can be called from irqs-disabled context */ + if (skb) { + dev_kfree_skb_any(skb); + txq->txb[txq->q.read_ptr].skb = NULL; + } + } +} + +/** + * il3945_hw_build_tx_cmd_rate - Add rate portion to TX_CMD: + * +*/ +void il3945_hw_build_tx_cmd_rate(struct il_priv *il, + struct il_device_cmd *cmd, + struct ieee80211_tx_info *info, + struct ieee80211_hdr *hdr, + int sta_id, int tx_id) +{ + u16 hw_value = ieee80211_get_tx_rate(il->hw, info)->hw_value; + u16 rate_idx = min(hw_value & 0xffff, RATE_COUNT_3945); + u16 rate_mask; + int rate; + u8 rts_retry_limit; + u8 data_retry_limit; + __le32 tx_flags; + __le16 fc = hdr->frame_control; + struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; + + rate = il3945_rates[rate_idx].plcp; + tx_flags = tx_cmd->tx_flags; + + /* We need to figure out how to get the sta->supp_rates while + * in this running context */ + rate_mask = RATES_MASK_3945; + + /* Set retry limit on DATA packets and Probe Responses*/ + if (ieee80211_is_probe_resp(fc)) + data_retry_limit = 3; + else + data_retry_limit = IL_DEFAULT_TX_RETRY; + tx_cmd->data_retry_limit = data_retry_limit; + + if (tx_id >= IL39_CMD_QUEUE_NUM) + rts_retry_limit = 3; + else + rts_retry_limit = 7; + + if (data_retry_limit < rts_retry_limit) + rts_retry_limit = data_retry_limit; + tx_cmd->rts_retry_limit = rts_retry_limit; + + tx_cmd->rate = rate; + tx_cmd->tx_flags = tx_flags; + + /* OFDM */ + tx_cmd->supp_rates[0] = + ((rate_mask & IL_OFDM_RATES_MASK) >> IL_FIRST_OFDM_RATE) & 0xFF; + + /* CCK */ + tx_cmd->supp_rates[1] = (rate_mask & 0xF); + + D_RATE("Tx sta id: %d, rate: %d (plcp), flags: 0x%4X " + "cck/ofdm mask: 0x%x/0x%x\n", sta_id, + tx_cmd->rate, le32_to_cpu(tx_cmd->tx_flags), + tx_cmd->supp_rates[1], tx_cmd->supp_rates[0]); +} + +static u8 il3945_sync_sta(struct il_priv *il, int sta_id, u16 tx_rate) +{ + unsigned long flags_spin; + struct il_station_entry *station; + + if (sta_id == IL_INVALID_STATION) + return IL_INVALID_STATION; + + spin_lock_irqsave(&il->sta_lock, flags_spin); + station = &il->stations[sta_id]; + + station->sta.sta.modify_mask = STA_MODIFY_TX_RATE_MSK; + station->sta.rate_n_flags = cpu_to_le16(tx_rate); + station->sta.mode = STA_CONTROL_MODIFY_MSK; + il_send_add_sta(il, &station->sta, CMD_ASYNC); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + + D_RATE("SCALE sync station %d to rate %d\n", + sta_id, tx_rate); + return sta_id; +} + +static void il3945_set_pwr_vmain(struct il_priv *il) +{ +/* + * (for documentation purposes) + * to set power to V_AUX, do + + if (pci_pme_capable(il->pci_dev, PCI_D3cold)) { + il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, + APMG_PS_CTRL_VAL_PWR_SRC_VAUX, + ~APMG_PS_CTRL_MSK_PWR_SRC); + + _il_poll_bit(il, CSR_GPIO_IN, + CSR_GPIO_IN_VAL_VAUX_PWR_SRC, + CSR_GPIO_IN_BIT_AUX_POWER, 5000); + } + */ + + il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, + APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, + ~APMG_PS_CTRL_MSK_PWR_SRC); + + _il_poll_bit(il, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC, + CSR_GPIO_IN_BIT_AUX_POWER, 5000); /* uS */ +} + +static int il3945_rx_init(struct il_priv *il, struct il_rx_queue *rxq) +{ + il_wr(il, FH39_RCSR_RBD_BASE(0), rxq->bd_dma); + il_wr(il, FH39_RCSR_RPTR_ADDR(0), + rxq->rb_stts_dma); + il_wr(il, FH39_RCSR_WPTR(0), 0); + il_wr(il, FH39_RCSR_CONFIG(0), + FH39_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE | + FH39_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE | + FH39_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN | + FH39_RCSR_RX_CONFIG_REG_VAL_MAX_FRAG_SIZE_128 | + (RX_QUEUE_SIZE_LOG << FH39_RCSR_RX_CONFIG_REG_POS_RBDC_SIZE) | + FH39_RCSR_RX_CONFIG_REG_VAL_IRQ_DEST_INT_HOST | + (1 << FH39_RCSR_RX_CONFIG_REG_POS_IRQ_RBTH) | + FH39_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH); + + /* fake read to flush all prev I/O */ + il_rd(il, FH39_RSSR_CTRL); + + return 0; +} + +static int il3945_tx_reset(struct il_priv *il) +{ + + /* bypass mode */ + il_wr_prph(il, ALM_SCD_MODE_REG, 0x2); + + /* RA 0 is active */ + il_wr_prph(il, ALM_SCD_ARASTAT_REG, 0x01); + + /* all 6 fifo are active */ + il_wr_prph(il, ALM_SCD_TXFACT_REG, 0x3f); + + il_wr_prph(il, ALM_SCD_SBYP_MODE_1_REG, 0x010000); + il_wr_prph(il, ALM_SCD_SBYP_MODE_2_REG, 0x030002); + il_wr_prph(il, ALM_SCD_TXF4MF_REG, 0x000004); + il_wr_prph(il, ALM_SCD_TXF5MF_REG, 0x000005); + + il_wr(il, FH39_TSSR_CBB_BASE, + il->_3945.shared_phys); + + il_wr(il, FH39_TSSR_MSG_CONFIG, + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON | + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON | + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B | + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON | + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON | + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH | + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH); + + + return 0; +} + +/** + * il3945_txq_ctx_reset - Reset TX queue context + * + * Destroys all DMA structures and initialize them again + */ +static int il3945_txq_ctx_reset(struct il_priv *il) +{ + int rc; + int txq_id, slots_num; + + il3945_hw_txq_ctx_free(il); + + /* allocate tx queue structure */ + rc = il_alloc_txq_mem(il); + if (rc) + return rc; + + /* Tx CMD queue */ + rc = il3945_tx_reset(il); + if (rc) + goto error; + + /* Tx queue(s) */ + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { + slots_num = (txq_id == IL39_CMD_QUEUE_NUM) ? + TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; + rc = il_tx_queue_init(il, &il->txq[txq_id], + slots_num, txq_id); + if (rc) { + IL_ERR("Tx %d queue init failed\n", txq_id); + goto error; + } + } + + return rc; + + error: + il3945_hw_txq_ctx_free(il); + return rc; +} + + +/* + * Start up 3945's basic functionality after it has been reset + * (e.g. after platform boot, or shutdown via il_apm_stop()) + * NOTE: This does not load uCode nor start the embedded processor + */ +static int il3945_apm_init(struct il_priv *il) +{ + int ret = il_apm_init(il); + + /* Clear APMG (NIC's internal power management) interrupts */ + il_wr_prph(il, APMG_RTC_INT_MSK_REG, 0x0); + il_wr_prph(il, APMG_RTC_INT_STT_REG, 0xFFFFFFFF); + + /* Reset radio chip */ + il_set_bits_prph(il, APMG_PS_CTRL_REG, + APMG_PS_CTRL_VAL_RESET_REQ); + udelay(5); + il_clear_bits_prph(il, APMG_PS_CTRL_REG, + APMG_PS_CTRL_VAL_RESET_REQ); + + return ret; +} + +static void il3945_nic_config(struct il_priv *il) +{ + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; + unsigned long flags; + u8 rev_id = il->pci_dev->revision; + + spin_lock_irqsave(&il->lock, flags); + + /* Determine HW type */ + D_INFO("HW Revision ID = 0x%X\n", rev_id); + + if (rev_id & PCI_CFG_REV_ID_BIT_RTP) + D_INFO("RTP type\n"); + else if (rev_id & PCI_CFG_REV_ID_BIT_BASIC_SKU) { + D_INFO("3945 RADIO-MB type\n"); + il_set_bit(il, CSR_HW_IF_CONFIG_REG, + CSR39_HW_IF_CONFIG_REG_BIT_3945_MB); + } else { + D_INFO("3945 RADIO-MM type\n"); + il_set_bit(il, CSR_HW_IF_CONFIG_REG, + CSR39_HW_IF_CONFIG_REG_BIT_3945_MM); + } + + if (EEPROM_SKU_CAP_OP_MODE_MRC == eeprom->sku_cap) { + D_INFO("SKU OP mode is mrc\n"); + il_set_bit(il, CSR_HW_IF_CONFIG_REG, + CSR39_HW_IF_CONFIG_REG_BIT_SKU_MRC); + } else + D_INFO("SKU OP mode is basic\n"); + + if ((eeprom->board_revision & 0xF0) == 0xD0) { + D_INFO("3945ABG revision is 0x%X\n", + eeprom->board_revision); + il_set_bit(il, CSR_HW_IF_CONFIG_REG, + CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); + } else { + D_INFO("3945ABG revision is 0x%X\n", + eeprom->board_revision); + il_clear_bit(il, CSR_HW_IF_CONFIG_REG, + CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); + } + + if (eeprom->almgor_m_version <= 1) { + il_set_bit(il, CSR_HW_IF_CONFIG_REG, + CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A); + D_INFO("Card M type A version is 0x%X\n", + eeprom->almgor_m_version); + } else { + D_INFO("Card M type B version is 0x%X\n", + eeprom->almgor_m_version); + il_set_bit(il, CSR_HW_IF_CONFIG_REG, + CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B); + } + spin_unlock_irqrestore(&il->lock, flags); + + if (eeprom->sku_cap & EEPROM_SKU_CAP_SW_RF_KILL_ENABLE) + D_RF_KILL("SW RF KILL supported in EEPROM.\n"); + + if (eeprom->sku_cap & EEPROM_SKU_CAP_HW_RF_KILL_ENABLE) + D_RF_KILL("HW RF KILL supported in EEPROM.\n"); +} + +int il3945_hw_nic_init(struct il_priv *il) +{ + int rc; + unsigned long flags; + struct il_rx_queue *rxq = &il->rxq; + + spin_lock_irqsave(&il->lock, flags); + il->cfg->ops->lib->apm_ops.init(il); + spin_unlock_irqrestore(&il->lock, flags); + + il3945_set_pwr_vmain(il); + + il->cfg->ops->lib->apm_ops.config(il); + + /* Allocate the RX queue, or reset if it is already allocated */ + if (!rxq->bd) { + rc = il_rx_queue_alloc(il); + if (rc) { + IL_ERR("Unable to initialize Rx queue\n"); + return -ENOMEM; + } + } else + il3945_rx_queue_reset(il, rxq); + + il3945_rx_replenish(il); + + il3945_rx_init(il, rxq); + + + /* Look at using this instead: + rxq->need_update = 1; + il_rx_queue_update_write_ptr(il, rxq); + */ + + il_wr(il, FH39_RCSR_WPTR(0), rxq->write & ~7); + + rc = il3945_txq_ctx_reset(il); + if (rc) + return rc; + + set_bit(STATUS_INIT, &il->status); + + return 0; +} + +/** + * il3945_hw_txq_ctx_free - Free TXQ Context + * + * Destroy all TX DMA queues and structures + */ +void il3945_hw_txq_ctx_free(struct il_priv *il) +{ + int txq_id; + + /* Tx queues */ + if (il->txq) + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; + txq_id++) + if (txq_id == IL39_CMD_QUEUE_NUM) + il_cmd_queue_free(il); + else + il_tx_queue_free(il, txq_id); + + /* free tx queue structure */ + il_txq_mem(il); +} + +void il3945_hw_txq_ctx_stop(struct il_priv *il) +{ + int txq_id; + + /* stop SCD */ + il_wr_prph(il, ALM_SCD_MODE_REG, 0); + il_wr_prph(il, ALM_SCD_TXFACT_REG, 0); + + /* reset TFD queues */ + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { + il_wr(il, FH39_TCSR_CONFIG(txq_id), 0x0); + il_poll_bit(il, FH39_TSSR_TX_STATUS, + FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(txq_id), + 1000); + } + + il3945_hw_txq_ctx_free(il); +} + +/** + * il3945_hw_reg_adjust_power_by_temp + * return idx delta into power gain settings table +*/ +static int il3945_hw_reg_adjust_power_by_temp(int new_reading, int old_reading) +{ + return (new_reading - old_reading) * (-11) / 100; +} + +/** + * il3945_hw_reg_temp_out_of_range - Keep temperature in sane range + */ +static inline int il3945_hw_reg_temp_out_of_range(int temperature) +{ + return (temperature < -260 || temperature > 25) ? 1 : 0; +} + +int il3945_hw_get_temperature(struct il_priv *il) +{ + return _il_rd(il, CSR_UCODE_DRV_GP2); +} + +/** + * il3945_hw_reg_txpower_get_temperature + * get the current temperature by reading from NIC +*/ +static int il3945_hw_reg_txpower_get_temperature(struct il_priv *il) +{ + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; + int temperature; + + temperature = il3945_hw_get_temperature(il); + + /* driver's okay range is -260 to +25. + * human readable okay range is 0 to +285 */ + D_INFO("Temperature: %d\n", temperature + IL_TEMP_CONVERT); + + /* handle insane temp reading */ + if (il3945_hw_reg_temp_out_of_range(temperature)) { + IL_ERR("Error bad temperature value %d\n", temperature); + + /* if really really hot(?), + * substitute the 3rd band/group's temp measured at factory */ + if (il->last_temperature > 100) + temperature = eeprom->groups[2].temperature; + else /* else use most recent "sane" value from driver */ + temperature = il->last_temperature; + } + + return temperature; /* raw, not "human readable" */ +} + +/* Adjust Txpower only if temperature variance is greater than threshold. + * + * Both are lower than older versions' 9 degrees */ +#define IL_TEMPERATURE_LIMIT_TIMER 6 + +/** + * il3945_is_temp_calib_needed - determines if new calibration is needed + * + * records new temperature in tx_mgr->temperature. + * replaces tx_mgr->last_temperature *only* if calib needed + * (assumes caller will actually do the calibration!). */ +static int il3945_is_temp_calib_needed(struct il_priv *il) +{ + int temp_diff; + + il->temperature = il3945_hw_reg_txpower_get_temperature(il); + temp_diff = il->temperature - il->last_temperature; + + /* get absolute value */ + if (temp_diff < 0) { + D_POWER("Getting cooler, delta %d,\n", temp_diff); + temp_diff = -temp_diff; + } else if (temp_diff == 0) + D_POWER("Same temp,\n"); + else + D_POWER("Getting warmer, delta %d,\n", temp_diff); + + /* if we don't need calibration, *don't* update last_temperature */ + if (temp_diff < IL_TEMPERATURE_LIMIT_TIMER) { + D_POWER("Timed thermal calib not needed\n"); + return 0; + } + + D_POWER("Timed thermal calib needed\n"); + + /* assume that caller will actually do calib ... + * update the "last temperature" value */ + il->last_temperature = il->temperature; + return 1; +} + +#define IL_MAX_GAIN_ENTRIES 78 +#define IL_CCK_FROM_OFDM_POWER_DIFF -5 +#define IL_CCK_FROM_OFDM_IDX_DIFF (10) + +/* radio and DSP power table, each step is 1/2 dB. + * 1st number is for RF analog gain, 2nd number is for DSP pre-DAC gain. */ +static struct il3945_tx_power power_gain_table[2][IL_MAX_GAIN_ENTRIES] = { + { + {251, 127}, /* 2.4 GHz, highest power */ + {251, 127}, + {251, 127}, + {251, 127}, + {251, 125}, + {251, 110}, + {251, 105}, + {251, 98}, + {187, 125}, + {187, 115}, + {187, 108}, + {187, 99}, + {243, 119}, + {243, 111}, + {243, 105}, + {243, 97}, + {243, 92}, + {211, 106}, + {211, 100}, + {179, 120}, + {179, 113}, + {179, 107}, + {147, 125}, + {147, 119}, + {147, 112}, + {147, 106}, + {147, 101}, + {147, 97}, + {147, 91}, + {115, 107}, + {235, 121}, + {235, 115}, + {235, 109}, + {203, 127}, + {203, 121}, + {203, 115}, + {203, 108}, + {203, 102}, + {203, 96}, + {203, 92}, + {171, 110}, + {171, 104}, + {171, 98}, + {139, 116}, + {227, 125}, + {227, 119}, + {227, 113}, + {227, 107}, + {227, 101}, + {227, 96}, + {195, 113}, + {195, 106}, + {195, 102}, + {195, 95}, + {163, 113}, + {163, 106}, + {163, 102}, + {163, 95}, + {131, 113}, + {131, 106}, + {131, 102}, + {131, 95}, + {99, 113}, + {99, 106}, + {99, 102}, + {99, 95}, + {67, 113}, + {67, 106}, + {67, 102}, + {67, 95}, + {35, 113}, + {35, 106}, + {35, 102}, + {35, 95}, + {3, 113}, + {3, 106}, + {3, 102}, + {3, 95} }, /* 2.4 GHz, lowest power */ + { + {251, 127}, /* 5.x GHz, highest power */ + {251, 120}, + {251, 114}, + {219, 119}, + {219, 101}, + {187, 113}, + {187, 102}, + {155, 114}, + {155, 103}, + {123, 117}, + {123, 107}, + {123, 99}, + {123, 92}, + {91, 108}, + {59, 125}, + {59, 118}, + {59, 109}, + {59, 102}, + {59, 96}, + {59, 90}, + {27, 104}, + {27, 98}, + {27, 92}, + {115, 118}, + {115, 111}, + {115, 104}, + {83, 126}, + {83, 121}, + {83, 113}, + {83, 105}, + {83, 99}, + {51, 118}, + {51, 111}, + {51, 104}, + {51, 98}, + {19, 116}, + {19, 109}, + {19, 102}, + {19, 98}, + {19, 93}, + {171, 113}, + {171, 107}, + {171, 99}, + {139, 120}, + {139, 113}, + {139, 107}, + {139, 99}, + {107, 120}, + {107, 113}, + {107, 107}, + {107, 99}, + {75, 120}, + {75, 113}, + {75, 107}, + {75, 99}, + {43, 120}, + {43, 113}, + {43, 107}, + {43, 99}, + {11, 120}, + {11, 113}, + {11, 107}, + {11, 99}, + {131, 107}, + {131, 99}, + {99, 120}, + {99, 113}, + {99, 107}, + {99, 99}, + {67, 120}, + {67, 113}, + {67, 107}, + {67, 99}, + {35, 120}, + {35, 113}, + {35, 107}, + {35, 99}, + {3, 120} } /* 5.x GHz, lowest power */ +}; + +static inline u8 il3945_hw_reg_fix_power_idx(int idx) +{ + if (idx < 0) + return 0; + if (idx >= IL_MAX_GAIN_ENTRIES) + return IL_MAX_GAIN_ENTRIES - 1; + return (u8) idx; +} + +/* Kick off thermal recalibration check every 60 seconds */ +#define REG_RECALIB_PERIOD (60) + +/** + * il3945_hw_reg_set_scan_power - Set Tx power for scan probe requests + * + * Set (in our channel info database) the direct scan Tx power for 1 Mbit (CCK) + * or 6 Mbit (OFDM) rates. + */ +static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_idx, + s32 rate_idx, const s8 *clip_pwrs, + struct il_channel_info *ch_info, + int band_idx) +{ + struct il3945_scan_power_info *scan_power_info; + s8 power; + u8 power_idx; + + scan_power_info = &ch_info->scan_pwr_info[scan_tbl_idx]; + + /* use this channel group's 6Mbit clipping/saturation pwr, + * but cap at regulatory scan power restriction (set during init + * based on eeprom channel data) for this channel. */ + power = min(ch_info->scan_power, clip_pwrs[RATE_6M_IDX_TBL]); + + power = min(power, il->tx_power_user_lmt); + scan_power_info->requested_power = power; + + /* find difference between new scan *power* and current "normal" + * Tx *power* for 6Mb. Use this difference (x2) to adjust the + * current "normal" temperature-compensated Tx power *idx* for + * this rate (1Mb or 6Mb) to yield new temp-compensated scan power + * *idx*. */ + power_idx = ch_info->power_info[rate_idx].power_table_idx + - (power - ch_info->power_info + [RATE_6M_IDX_TBL].requested_power) * 2; + + /* store reference idx that we use when adjusting *all* scan + * powers. So we can accommodate user (all channel) or spectrum + * management (single channel) power changes "between" temperature + * feedback compensation procedures. + * don't force fit this reference idx into gain table; it may be a + * negative number. This will help avoid errors when we're at + * the lower bounds (highest gains, for warmest temperatures) + * of the table. */ + + /* don't exceed table bounds for "real" setting */ + power_idx = il3945_hw_reg_fix_power_idx(power_idx); + + scan_power_info->power_table_idx = power_idx; + scan_power_info->tpc.tx_gain = + power_gain_table[band_idx][power_idx].tx_gain; + scan_power_info->tpc.dsp_atten = + power_gain_table[band_idx][power_idx].dsp_atten; +} + +/** + * il3945_send_tx_power - fill in Tx Power command with gain settings + * + * Configures power settings for all rates for the current channel, + * using values from channel info struct, and send to NIC + */ +static int il3945_send_tx_power(struct il_priv *il) +{ + int rate_idx, i; + const struct il_channel_info *ch_info = NULL; + struct il3945_txpowertable_cmd txpower = { + .channel = il->ctx.active.channel, + }; + u16 chan; + + if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &il->status), + "TX Power requested while scanning!\n")) + return -EAGAIN; + + chan = le16_to_cpu(il->ctx.active.channel); + + txpower.band = (il->band == IEEE80211_BAND_5GHZ) ? 0 : 1; + ch_info = il_get_channel_info(il, il->band, chan); + if (!ch_info) { + IL_ERR( + "Failed to get channel info for channel %d [%d]\n", + chan, il->band); + return -EINVAL; + } + + if (!il_is_channel_valid(ch_info)) { + D_POWER("Not calling TX_PWR_TBL_CMD on " + "non-Tx channel.\n"); + return 0; + } + + /* fill cmd with power settings for all rates for current channel */ + /* Fill OFDM rate */ + for (rate_idx = IL_FIRST_OFDM_RATE, i = 0; + rate_idx <= IL39_LAST_OFDM_RATE; rate_idx++, i++) { + + txpower.power[i].tpc = ch_info->power_info[i].tpc; + txpower.power[i].rate = il3945_rates[rate_idx].plcp; + + D_POWER("ch %d:%d rf %d dsp %3d rate code 0x%02x\n", + le16_to_cpu(txpower.channel), + txpower.band, + txpower.power[i].tpc.tx_gain, + txpower.power[i].tpc.dsp_atten, + txpower.power[i].rate); + } + /* Fill CCK rates */ + for (rate_idx = IL_FIRST_CCK_RATE; + rate_idx <= IL_LAST_CCK_RATE; rate_idx++, i++) { + txpower.power[i].tpc = ch_info->power_info[i].tpc; + txpower.power[i].rate = il3945_rates[rate_idx].plcp; + + D_POWER("ch %d:%d rf %d dsp %3d rate code 0x%02x\n", + le16_to_cpu(txpower.channel), + txpower.band, + txpower.power[i].tpc.tx_gain, + txpower.power[i].tpc.dsp_atten, + txpower.power[i].rate); + } + + return il_send_cmd_pdu(il, REPLY_TX_PWR_TBL_CMD, + sizeof(struct il3945_txpowertable_cmd), + &txpower); + +} + +/** + * il3945_hw_reg_set_new_power - Configures power tables at new levels + * @ch_info: Channel to update. Uses power_info.requested_power. + * + * Replace requested_power and base_power_idx ch_info fields for + * one channel. + * + * Called if user or spectrum management changes power preferences. + * Takes into account h/w and modulation limitations (clip power). + * + * This does *not* send anything to NIC, just sets up ch_info for one channel. + * + * NOTE: reg_compensate_for_temperature_dif() *must* be run after this to + * properly fill out the scan powers, and actual h/w gain settings, + * and send changes to NIC + */ +static int il3945_hw_reg_set_new_power(struct il_priv *il, + struct il_channel_info *ch_info) +{ + struct il3945_channel_power_info *power_info; + int power_changed = 0; + int i; + const s8 *clip_pwrs; + int power; + + /* Get this chnlgrp's rate-to-max/clip-powers table */ + clip_pwrs = il->_3945.clip_groups[ch_info->group_idx].clip_powers; + + /* Get this channel's rate-to-current-power settings table */ + power_info = ch_info->power_info; + + /* update OFDM Txpower settings */ + for (i = RATE_6M_IDX_TBL; i <= RATE_54M_IDX_TBL; + i++, ++power_info) { + int delta_idx; + + /* limit new power to be no more than h/w capability */ + power = min(ch_info->curr_txpow, clip_pwrs[i]); + if (power == power_info->requested_power) + continue; + + /* find difference between old and new requested powers, + * update base (non-temp-compensated) power idx */ + delta_idx = (power - power_info->requested_power) * 2; + power_info->base_power_idx -= delta_idx; + + /* save new requested power value */ + power_info->requested_power = power; + + power_changed = 1; + } + + /* update CCK Txpower settings, based on OFDM 12M setting ... + * ... all CCK power settings for a given channel are the *same*. */ + if (power_changed) { + power = + ch_info->power_info[RATE_12M_IDX_TBL]. + requested_power + IL_CCK_FROM_OFDM_POWER_DIFF; + + /* do all CCK rates' il3945_channel_power_info structures */ + for (i = RATE_1M_IDX_TBL; i <= RATE_11M_IDX_TBL; i++) { + power_info->requested_power = power; + power_info->base_power_idx = + ch_info->power_info[RATE_12M_IDX_TBL]. + base_power_idx + IL_CCK_FROM_OFDM_IDX_DIFF; + ++power_info; + } + } + + return 0; +} + +/** + * il3945_hw_reg_get_ch_txpower_limit - returns new power limit for channel + * + * NOTE: Returned power limit may be less (but not more) than requested, + * based strictly on regulatory (eeprom and spectrum mgt) limitations + * (no consideration for h/w clipping limitations). + */ +static int il3945_hw_reg_get_ch_txpower_limit(struct il_channel_info *ch_info) +{ + s8 max_power; + +#if 0 + /* if we're using TGd limits, use lower of TGd or EEPROM */ + if (ch_info->tgd_data.max_power != 0) + max_power = min(ch_info->tgd_data.max_power, + ch_info->eeprom.max_power_avg); + + /* else just use EEPROM limits */ + else +#endif + max_power = ch_info->eeprom.max_power_avg; + + return min(max_power, ch_info->max_power_avg); +} + +/** + * il3945_hw_reg_comp_txpower_temp - Compensate for temperature + * + * Compensate txpower settings of *all* channels for temperature. + * This only accounts for the difference between current temperature + * and the factory calibration temperatures, and bases the new settings + * on the channel's base_power_idx. + * + * If RxOn is "associated", this sends the new Txpower to NIC! + */ +static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) +{ + struct il_channel_info *ch_info = NULL; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; + int delta_idx; + const s8 *clip_pwrs; /* array of h/w max power levels for each rate */ + u8 a_band; + u8 rate_idx; + u8 scan_tbl_idx; + u8 i; + int ref_temp; + int temperature = il->temperature; + + if (il->disable_tx_power_cal || + test_bit(STATUS_SCANNING, &il->status)) { + /* do not perform tx power calibration */ + return 0; + } + /* set up new Tx power info for each and every channel, 2.4 and 5.x */ + for (i = 0; i < il->channel_count; i++) { + ch_info = &il->channel_info[i]; + a_band = il_is_channel_a_band(ch_info); + + /* Get this chnlgrp's factory calibration temperature */ + ref_temp = (s16)eeprom->groups[ch_info->group_idx]. + temperature; + + /* get power idx adjustment based on current and factory + * temps */ + delta_idx = il3945_hw_reg_adjust_power_by_temp(temperature, + ref_temp); + + /* set tx power value for all rates, OFDM and CCK */ + for (rate_idx = 0; rate_idx < RATE_COUNT_3945; + rate_idx++) { + int power_idx = + ch_info->power_info[rate_idx].base_power_idx; + + /* temperature compensate */ + power_idx += delta_idx; + + /* stay within table range */ + power_idx = il3945_hw_reg_fix_power_idx(power_idx); + ch_info->power_info[rate_idx]. + power_table_idx = (u8) power_idx; + ch_info->power_info[rate_idx].tpc = + power_gain_table[a_band][power_idx]; + } + + /* Get this chnlgrp's rate-to-max/clip-powers table */ + clip_pwrs = il->_3945.clip_groups[ch_info->group_idx].clip_powers; + + /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */ + for (scan_tbl_idx = 0; + scan_tbl_idx < IL_NUM_SCAN_RATES; scan_tbl_idx++) { + s32 actual_idx = (scan_tbl_idx == 0) ? + RATE_1M_IDX_TBL : RATE_6M_IDX_TBL; + il3945_hw_reg_set_scan_power(il, scan_tbl_idx, + actual_idx, clip_pwrs, + ch_info, a_band); + } + } + + /* send Txpower command for current channel to ucode */ + return il->cfg->ops->lib->send_tx_power(il); +} + +int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power) +{ + struct il_channel_info *ch_info; + s8 max_power; + u8 a_band; + u8 i; + + if (il->tx_power_user_lmt == power) { + D_POWER("Requested Tx power same as current " + "limit: %ddBm.\n", power); + return 0; + } + + D_POWER("Setting upper limit clamp to %ddBm.\n", power); + il->tx_power_user_lmt = power; + + /* set up new Tx powers for each and every channel, 2.4 and 5.x */ + + for (i = 0; i < il->channel_count; i++) { + ch_info = &il->channel_info[i]; + a_band = il_is_channel_a_band(ch_info); + + /* find minimum power of all user and regulatory constraints + * (does not consider h/w clipping limitations) */ + max_power = il3945_hw_reg_get_ch_txpower_limit(ch_info); + max_power = min(power, max_power); + if (max_power != ch_info->curr_txpow) { + ch_info->curr_txpow = max_power; + + /* this considers the h/w clipping limitations */ + il3945_hw_reg_set_new_power(il, ch_info); + } + } + + /* update txpower settings for all channels, + * send to NIC if associated. */ + il3945_is_temp_calib_needed(il); + il3945_hw_reg_comp_txpower_temp(il); + + return 0; +} + +static int il3945_send_rxon_assoc(struct il_priv *il, + struct il_rxon_context *ctx) +{ + int rc = 0; + struct il_rx_pkt *pkt; + struct il3945_rxon_assoc_cmd rxon_assoc; + struct il_host_cmd cmd = { + .id = REPLY_RXON_ASSOC, + .len = sizeof(rxon_assoc), + .flags = CMD_WANT_SKB, + .data = &rxon_assoc, + }; + const struct il_rxon_cmd *rxon1 = &ctx->staging; + const struct il_rxon_cmd *rxon2 = &ctx->active; + + if (rxon1->flags == rxon2->flags && + rxon1->filter_flags == rxon2->filter_flags && + rxon1->cck_basic_rates == rxon2->cck_basic_rates && + rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates) { + D_INFO("Using current RXON_ASSOC. Not resending.\n"); + return 0; + } + + rxon_assoc.flags = ctx->staging.flags; + rxon_assoc.filter_flags = ctx->staging.filter_flags; + rxon_assoc.ofdm_basic_rates = ctx->staging.ofdm_basic_rates; + rxon_assoc.cck_basic_rates = ctx->staging.cck_basic_rates; + rxon_assoc.reserved = 0; + + rc = il_send_cmd_sync(il, &cmd); + if (rc) + return rc; + + pkt = (struct il_rx_pkt *)cmd.reply_page; + if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { + IL_ERR("Bad return from REPLY_RXON_ASSOC command\n"); + rc = -EIO; + } + + il_free_pages(il, cmd.reply_page); + + return rc; +} + +/** + * il3945_commit_rxon - commit staging_rxon to hardware + * + * The RXON command in staging_rxon is committed to the hardware and + * the active_rxon structure is updated with the new data. This + * function correctly transitions out of the RXON_ASSOC_MSK state if + * a HW tune is required based on the RXON structure changes. + */ +int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) +{ + /* cast away the const for active_rxon in this function */ + struct il3945_rxon_cmd *active_rxon = (void *)&ctx->active; + struct il3945_rxon_cmd *staging_rxon = (void *)&ctx->staging; + int rc = 0; + bool new_assoc = !!(staging_rxon->filter_flags & RXON_FILTER_ASSOC_MSK); + + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + return -EINVAL; + + if (!il_is_alive(il)) + return -1; + + /* always get timestamp with Rx frame */ + staging_rxon->flags |= RXON_FLG_TSF2HOST_MSK; + + /* select antenna */ + staging_rxon->flags &= + ~(RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_SEL_MSK); + staging_rxon->flags |= il3945_get_antenna_flags(il); + + rc = il_check_rxon_cmd(il, ctx); + if (rc) { + IL_ERR("Invalid RXON configuration. Not committing.\n"); + return -EINVAL; + } + + /* If we don't need to send a full RXON, we can use + * il3945_rxon_assoc_cmd which is used to reconfigure filter + * and other flags for the current radio configuration. */ + if (!il_full_rxon_required(il, + &il->ctx)) { + rc = il_send_rxon_assoc(il, + &il->ctx); + if (rc) { + IL_ERR("Error setting RXON_ASSOC " + "configuration (%d).\n", rc); + return rc; + } + + memcpy(active_rxon, staging_rxon, sizeof(*active_rxon)); + /* + * We do not commit tx power settings while channel changing, + * do it now if tx power changed. + */ + il_set_tx_power(il, il->tx_power_next, false); + return 0; + } + + /* If we are currently associated and the new config requires + * an RXON_ASSOC and the new config wants the associated mask enabled, + * we must clear the associated from the active configuration + * before we apply the new config */ + if (il_is_associated(il) && new_assoc) { + D_INFO("Toggling associated bit on current RXON\n"); + active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; + + /* + * reserved4 and 5 could have been filled by the iwlcore code. + * Let's clear them before pushing to the 3945. + */ + active_rxon->reserved4 = 0; + active_rxon->reserved5 = 0; + rc = il_send_cmd_pdu(il, REPLY_RXON, + sizeof(struct il3945_rxon_cmd), + &il->ctx.active); + + /* If the mask clearing failed then we set + * active_rxon back to what it was previously */ + if (rc) { + active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK; + IL_ERR("Error clearing ASSOC_MSK on current " + "configuration (%d).\n", rc); + return rc; + } + il_clear_ucode_stations(il, + &il->ctx); + il_restore_stations(il, + &il->ctx); + } + + D_INFO("Sending RXON\n" + "* with%s RXON_FILTER_ASSOC_MSK\n" + "* channel = %d\n" + "* bssid = %pM\n", + (new_assoc ? "" : "out"), + le16_to_cpu(staging_rxon->channel), + staging_rxon->bssid_addr); + + /* + * reserved4 and 5 could have been filled by the iwlcore code. + * Let's clear them before pushing to the 3945. + */ + staging_rxon->reserved4 = 0; + staging_rxon->reserved5 = 0; + + il_set_rxon_hwcrypto(il, ctx, !il3945_mod_params.sw_crypto); + + /* Apply the new configuration */ + rc = il_send_cmd_pdu(il, REPLY_RXON, + sizeof(struct il3945_rxon_cmd), + staging_rxon); + if (rc) { + IL_ERR("Error setting new configuration (%d).\n", rc); + return rc; + } + + memcpy(active_rxon, staging_rxon, sizeof(*active_rxon)); + + if (!new_assoc) { + il_clear_ucode_stations(il, + &il->ctx); + il_restore_stations(il, + &il->ctx); + } + + /* If we issue a new RXON command which required a tune then we must + * send a new TXPOWER command or we won't be able to Tx any frames */ + rc = il_set_tx_power(il, il->tx_power_next, true); + if (rc) { + IL_ERR("Error setting Tx power (%d).\n", rc); + return rc; + } + + /* Init the hardware's rate fallback order based on the band */ + rc = il3945_init_hw_rate_table(il); + if (rc) { + IL_ERR("Error setting HW rate table: %02X\n", rc); + return -EIO; + } + + return 0; +} + +/** + * il3945_reg_txpower_periodic - called when time to check our temperature. + * + * -- reset periodic timer + * -- see if temp has changed enough to warrant re-calibration ... if so: + * -- correct coeffs for temp (can reset temp timer) + * -- save this temp as "last", + * -- send new set of gain settings to NIC + * NOTE: This should continue working, even when we're not associated, + * so we can keep our internal table of scan powers current. */ +void il3945_reg_txpower_periodic(struct il_priv *il) +{ + /* This will kick in the "brute force" + * il3945_hw_reg_comp_txpower_temp() below */ + if (!il3945_is_temp_calib_needed(il)) + goto reschedule; + + /* Set up a new set of temp-adjusted TxPowers, send to NIC. + * This is based *only* on current temperature, + * ignoring any previous power measurements */ + il3945_hw_reg_comp_txpower_temp(il); + + reschedule: + queue_delayed_work(il->workqueue, + &il->_3945.thermal_periodic, REG_RECALIB_PERIOD * HZ); +} + +static void il3945_bg_reg_txpower_periodic(struct work_struct *work) +{ + struct il_priv *il = container_of(work, struct il_priv, + _3945.thermal_periodic.work); + + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + return; + + mutex_lock(&il->mutex); + il3945_reg_txpower_periodic(il); + mutex_unlock(&il->mutex); +} + +/** + * il3945_hw_reg_get_ch_grp_idx - find the channel-group idx (0-4) + * for the channel. + * + * This function is used when initializing channel-info structs. + * + * NOTE: These channel groups do *NOT* match the bands above! + * These channel groups are based on factory-tested channels; + * on A-band, EEPROM's "group frequency" entries represent the top + * channel in each group 1-4. Group 5 All B/G channels are in group 0. + */ +static u16 il3945_hw_reg_get_ch_grp_idx(struct il_priv *il, + const struct il_channel_info *ch_info) +{ + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; + struct il3945_eeprom_txpower_group *ch_grp = &eeprom->groups[0]; + u8 group; + u16 group_idx = 0; /* based on factory calib frequencies */ + u8 grp_channel; + + /* Find the group idx for the channel ... don't use idx 1(?) */ + if (il_is_channel_a_band(ch_info)) { + for (group = 1; group < 5; group++) { + grp_channel = ch_grp[group].group_channel; + if (ch_info->channel <= grp_channel) { + group_idx = group; + break; + } + } + /* group 4 has a few channels *above* its factory cal freq */ + if (group == 5) + group_idx = 4; + } else + group_idx = 0; /* 2.4 GHz, group 0 */ + + D_POWER("Chnl %d mapped to grp %d\n", ch_info->channel, + group_idx); + return group_idx; +} + +/** + * il3945_hw_reg_get_matched_power_idx - Interpolate to get nominal idx + * + * Interpolate to get nominal (i.e. at factory calibration temperature) idx + * into radio/DSP gain settings table for requested power. + */ +static int il3945_hw_reg_get_matched_power_idx(struct il_priv *il, + s8 requested_power, + s32 setting_idx, s32 *new_idx) +{ + const struct il3945_eeprom_txpower_group *chnl_grp = NULL; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; + s32 idx0, idx1; + s32 power = 2 * requested_power; + s32 i; + const struct il3945_eeprom_txpower_sample *samples; + s32 gains0, gains1; + s32 res; + s32 denominator; + + chnl_grp = &eeprom->groups[setting_idx]; + samples = chnl_grp->samples; + for (i = 0; i < 5; i++) { + if (power == samples[i].power) { + *new_idx = samples[i].gain_idx; + return 0; + } + } + + if (power > samples[1].power) { + idx0 = 0; + idx1 = 1; + } else if (power > samples[2].power) { + idx0 = 1; + idx1 = 2; + } else if (power > samples[3].power) { + idx0 = 2; + idx1 = 3; + } else { + idx0 = 3; + idx1 = 4; + } + + denominator = (s32) samples[idx1].power - (s32) samples[idx0].power; + if (denominator == 0) + return -EINVAL; + gains0 = (s32) samples[idx0].gain_idx * (1 << 19); + gains1 = (s32) samples[idx1].gain_idx * (1 << 19); + res = gains0 + (gains1 - gains0) * + ((s32) power - (s32) samples[idx0].power) / denominator + + (1 << 18); + *new_idx = res >> 19; + return 0; +} + +static void il3945_hw_reg_init_channel_groups(struct il_priv *il) +{ + u32 i; + s32 rate_idx; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; + const struct il3945_eeprom_txpower_group *group; + + D_POWER("Initializing factory calib info from EEPROM\n"); + + for (i = 0; i < IL_NUM_TX_CALIB_GROUPS; i++) { + s8 *clip_pwrs; /* table of power levels for each rate */ + s8 satur_pwr; /* saturation power for each chnl group */ + group = &eeprom->groups[i]; + + /* sanity check on factory saturation power value */ + if (group->saturation_power < 40) { + IL_WARN("Error: saturation power is %d, " + "less than minimum expected 40\n", + group->saturation_power); + return; + } + + /* + * Derive requested power levels for each rate, based on + * hardware capabilities (saturation power for band). + * Basic value is 3dB down from saturation, with further + * power reductions for highest 3 data rates. These + * backoffs provide headroom for high rate modulation + * power peaks, without too much distortion (clipping). + */ + /* we'll fill in this array with h/w max power levels */ + clip_pwrs = (s8 *) il->_3945.clip_groups[i].clip_powers; + + /* divide factory saturation power by 2 to find -3dB level */ + satur_pwr = (s8) (group->saturation_power >> 1); + + /* fill in channel group's nominal powers for each rate */ + for (rate_idx = 0; + rate_idx < RATE_COUNT_3945; rate_idx++, clip_pwrs++) { + switch (rate_idx) { + case RATE_36M_IDX_TBL: + if (i == 0) /* B/G */ + *clip_pwrs = satur_pwr; + else /* A */ + *clip_pwrs = satur_pwr - 5; + break; + case RATE_48M_IDX_TBL: + if (i == 0) + *clip_pwrs = satur_pwr - 7; + else + *clip_pwrs = satur_pwr - 10; + break; + case RATE_54M_IDX_TBL: + if (i == 0) + *clip_pwrs = satur_pwr - 9; + else + *clip_pwrs = satur_pwr - 12; + break; + default: + *clip_pwrs = satur_pwr; + break; + } + } + } +} + +/** + * il3945_txpower_set_from_eeprom - Set channel power info based on EEPROM + * + * Second pass (during init) to set up il->channel_info + * + * Set up Tx-power settings in our channel info database for each VALID + * (for this geo/SKU) channel, at all Tx data rates, based on eeprom values + * and current temperature. + * + * Since this is based on current temperature (at init time), these values may + * not be valid for very long, but it gives us a starting/default point, + * and allows us to active (i.e. using Tx) scan. + * + * This does *not* write values to NIC, just sets up our internal table. + */ +int il3945_txpower_set_from_eeprom(struct il_priv *il) +{ + struct il_channel_info *ch_info = NULL; + struct il3945_channel_power_info *pwr_info; + struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; + int delta_idx; + u8 rate_idx; + u8 scan_tbl_idx; + const s8 *clip_pwrs; /* array of power levels for each rate */ + u8 gain, dsp_atten; + s8 power; + u8 pwr_idx, base_pwr_idx, a_band; + u8 i; + int temperature; + + /* save temperature reference, + * so we can determine next time to calibrate */ + temperature = il3945_hw_reg_txpower_get_temperature(il); + il->last_temperature = temperature; + + il3945_hw_reg_init_channel_groups(il); + + /* initialize Tx power info for each and every channel, 2.4 and 5.x */ + for (i = 0, ch_info = il->channel_info; i < il->channel_count; + i++, ch_info++) { + a_band = il_is_channel_a_band(ch_info); + if (!il_is_channel_valid(ch_info)) + continue; + + /* find this channel's channel group (*not* "band") idx */ + ch_info->group_idx = + il3945_hw_reg_get_ch_grp_idx(il, ch_info); + + /* Get this chnlgrp's rate->max/clip-powers table */ + clip_pwrs = il->_3945.clip_groups[ch_info->group_idx].clip_powers; + + /* calculate power idx *adjustment* value according to + * diff between current temperature and factory temperature */ + delta_idx = il3945_hw_reg_adjust_power_by_temp(temperature, + eeprom->groups[ch_info->group_idx]. + temperature); + + D_POWER("Delta idx for channel %d: %d [%d]\n", + ch_info->channel, delta_idx, temperature + + IL_TEMP_CONVERT); + + /* set tx power value for all OFDM rates */ + for (rate_idx = 0; rate_idx < IL_OFDM_RATES; + rate_idx++) { + s32 uninitialized_var(power_idx); + int rc; + + /* use channel group's clip-power table, + * but don't exceed channel's max power */ + s8 pwr = min(ch_info->max_power_avg, + clip_pwrs[rate_idx]); + + pwr_info = &ch_info->power_info[rate_idx]; + + /* get base (i.e. at factory-measured temperature) + * power table idx for this rate's power */ + rc = il3945_hw_reg_get_matched_power_idx(il, pwr, + ch_info->group_idx, + &power_idx); + if (rc) { + IL_ERR("Invalid power idx\n"); + return rc; + } + pwr_info->base_power_idx = (u8) power_idx; + + /* temperature compensate */ + power_idx += delta_idx; + + /* stay within range of gain table */ + power_idx = il3945_hw_reg_fix_power_idx(power_idx); + + /* fill 1 OFDM rate's il3945_channel_power_info struct */ + pwr_info->requested_power = pwr; + pwr_info->power_table_idx = (u8) power_idx; + pwr_info->tpc.tx_gain = + power_gain_table[a_band][power_idx].tx_gain; + pwr_info->tpc.dsp_atten = + power_gain_table[a_band][power_idx].dsp_atten; + } + + /* set tx power for CCK rates, based on OFDM 12 Mbit settings*/ + pwr_info = &ch_info->power_info[RATE_12M_IDX_TBL]; + power = pwr_info->requested_power + + IL_CCK_FROM_OFDM_POWER_DIFF; + pwr_idx = pwr_info->power_table_idx + + IL_CCK_FROM_OFDM_IDX_DIFF; + base_pwr_idx = pwr_info->base_power_idx + + IL_CCK_FROM_OFDM_IDX_DIFF; + + /* stay within table range */ + pwr_idx = il3945_hw_reg_fix_power_idx(pwr_idx); + gain = power_gain_table[a_band][pwr_idx].tx_gain; + dsp_atten = power_gain_table[a_band][pwr_idx].dsp_atten; + + /* fill each CCK rate's il3945_channel_power_info structure + * NOTE: All CCK-rate Txpwrs are the same for a given chnl! + * NOTE: CCK rates start at end of OFDM rates! */ + for (rate_idx = 0; + rate_idx < IL_CCK_RATES; rate_idx++) { + pwr_info = &ch_info->power_info[rate_idx+IL_OFDM_RATES]; + pwr_info->requested_power = power; + pwr_info->power_table_idx = pwr_idx; + pwr_info->base_power_idx = base_pwr_idx; + pwr_info->tpc.tx_gain = gain; + pwr_info->tpc.dsp_atten = dsp_atten; + } + + /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */ + for (scan_tbl_idx = 0; + scan_tbl_idx < IL_NUM_SCAN_RATES; scan_tbl_idx++) { + s32 actual_idx = (scan_tbl_idx == 0) ? + RATE_1M_IDX_TBL : RATE_6M_IDX_TBL; + il3945_hw_reg_set_scan_power(il, scan_tbl_idx, + actual_idx, clip_pwrs, ch_info, a_band); + } + } + + return 0; +} + +int il3945_hw_rxq_stop(struct il_priv *il) +{ + int rc; + + il_wr(il, FH39_RCSR_CONFIG(0), 0); + rc = il_poll_bit(il, FH39_RSSR_STATUS, + FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); + if (rc < 0) + IL_ERR("Can't stop Rx DMA.\n"); + + return 0; +} + +int il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq) +{ + int txq_id = txq->q.id; + + struct il3945_shared *shared_data = il->_3945.shared_virt; + + shared_data->tx_base_ptr[txq_id] = cpu_to_le32((u32)txq->q.dma_addr); + + il_wr(il, FH39_CBCC_CTRL(txq_id), 0); + il_wr(il, FH39_CBCC_BASE(txq_id), 0); + + il_wr(il, FH39_TCSR_CONFIG(txq_id), + FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT | + FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF | + FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD | + FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL | + FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE); + + /* fake read to flush all prev. writes */ + _il_rd(il, FH39_TSSR_CBB_BASE); + + return 0; +} + +/* + * HCMD utils + */ +static u16 il3945_get_hcmd_size(u8 cmd_id, u16 len) +{ + switch (cmd_id) { + case REPLY_RXON: + return sizeof(struct il3945_rxon_cmd); + case POWER_TBL_CMD: + return sizeof(struct il3945_powertable_cmd); + default: + return len; + } +} + + +static u16 il3945_build_addsta_hcmd(const struct il_addsta_cmd *cmd, + u8 *data) +{ + struct il3945_addsta_cmd *addsta = (struct il3945_addsta_cmd *)data; + addsta->mode = cmd->mode; + memcpy(&addsta->sta, &cmd->sta, sizeof(struct sta_id_modify)); + memcpy(&addsta->key, &cmd->key, sizeof(struct il4965_keyinfo)); + addsta->station_flags = cmd->station_flags; + addsta->station_flags_msk = cmd->station_flags_msk; + addsta->tid_disable_tx = cpu_to_le16(0); + addsta->rate_n_flags = cmd->rate_n_flags; + addsta->add_immediate_ba_tid = cmd->add_immediate_ba_tid; + addsta->remove_immediate_ba_tid = cmd->remove_immediate_ba_tid; + addsta->add_immediate_ba_ssn = cmd->add_immediate_ba_ssn; + + return (u16)sizeof(struct il3945_addsta_cmd); +} + +static int il3945_add_bssid_station(struct il_priv *il, + const u8 *addr, u8 *sta_id_r) +{ + struct il_rxon_context *ctx = &il->ctx; + int ret; + u8 sta_id; + unsigned long flags; + + if (sta_id_r) + *sta_id_r = IL_INVALID_STATION; + + ret = il_add_station_common(il, ctx, addr, 0, NULL, &sta_id); + if (ret) { + IL_ERR("Unable to add station %pM\n", addr); + return ret; + } + + if (sta_id_r) + *sta_id_r = sta_id; + + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].used |= IL_STA_LOCAL; + spin_unlock_irqrestore(&il->sta_lock, flags); + + return 0; +} +static int il3945_manage_ibss_station(struct il_priv *il, + struct ieee80211_vif *vif, bool add) +{ + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; + int ret; + + if (add) { + ret = il3945_add_bssid_station(il, vif->bss_conf.bssid, + &vif_priv->ibss_bssid_sta_id); + if (ret) + return ret; + + il3945_sync_sta(il, vif_priv->ibss_bssid_sta_id, + (il->band == IEEE80211_BAND_5GHZ) ? + RATE_6M_PLCP : RATE_1M_PLCP); + il3945_rate_scale_init(il->hw, vif_priv->ibss_bssid_sta_id); + + return 0; + } + + return il_remove_station(il, vif_priv->ibss_bssid_sta_id, + vif->bss_conf.bssid); +} + +/** + * il3945_init_hw_rate_table - Initialize the hardware rate fallback table + */ +int il3945_init_hw_rate_table(struct il_priv *il) +{ + int rc, i, idx, prev_idx; + struct il3945_rate_scaling_cmd rate_cmd = { + .reserved = {0, 0, 0}, + }; + struct il3945_rate_scaling_info *table = rate_cmd.table; + + for (i = 0; i < ARRAY_SIZE(il3945_rates); i++) { + idx = il3945_rates[i].table_rs_idx; + + table[idx].rate_n_flags = + il3945_hw_set_rate_n_flags(il3945_rates[i].plcp, 0); + table[idx].try_cnt = il->retry_rate; + prev_idx = il3945_get_prev_ieee_rate(i); + table[idx].next_rate_idx = + il3945_rates[prev_idx].table_rs_idx; + } + + switch (il->band) { + case IEEE80211_BAND_5GHZ: + D_RATE("Select A mode rate scale\n"); + /* If one of the following CCK rates is used, + * have it fall back to the 6M OFDM rate */ + for (i = RATE_1M_IDX_TBL; + i <= RATE_11M_IDX_TBL; i++) + table[i].next_rate_idx = + il3945_rates[IL_FIRST_OFDM_RATE].table_rs_idx; + + /* Don't fall back to CCK rates */ + table[RATE_12M_IDX_TBL].next_rate_idx = + RATE_9M_IDX_TBL; + + /* Don't drop out of OFDM rates */ + table[RATE_6M_IDX_TBL].next_rate_idx = + il3945_rates[IL_FIRST_OFDM_RATE].table_rs_idx; + break; + + case IEEE80211_BAND_2GHZ: + D_RATE("Select B/G mode rate scale\n"); + /* If an OFDM rate is used, have it fall back to the + * 1M CCK rates */ + + if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && + il_is_associated(il)) { + + idx = IL_FIRST_CCK_RATE; + for (i = RATE_6M_IDX_TBL; + i <= RATE_54M_IDX_TBL; i++) + table[i].next_rate_idx = + il3945_rates[idx].table_rs_idx; + + idx = RATE_11M_IDX_TBL; + /* CCK shouldn't fall back to OFDM... */ + table[idx].next_rate_idx = RATE_5M_IDX_TBL; + } + break; + + default: + WARN_ON(1); + break; + } + + /* Update the rate scaling for control frame Tx */ + rate_cmd.table_id = 0; + rc = il_send_cmd_pdu(il, REPLY_RATE_SCALE, sizeof(rate_cmd), + &rate_cmd); + if (rc) + return rc; + + /* Update the rate scaling for data frame Tx */ + rate_cmd.table_id = 1; + return il_send_cmd_pdu(il, REPLY_RATE_SCALE, sizeof(rate_cmd), + &rate_cmd); +} + +/* Called when initializing driver */ +int il3945_hw_set_hw_params(struct il_priv *il) +{ + memset((void *)&il->hw_params, 0, + sizeof(struct il_hw_params)); + + il->_3945.shared_virt = + dma_alloc_coherent(&il->pci_dev->dev, + sizeof(struct il3945_shared), + &il->_3945.shared_phys, GFP_KERNEL); + if (!il->_3945.shared_virt) { + IL_ERR("failed to allocate pci memory\n"); + return -ENOMEM; + } + + /* Assign number of Usable TX queues */ + il->hw_params.max_txq_num = il->cfg->base_params->num_of_queues; + + il->hw_params.tfd_size = sizeof(struct il3945_tfd); + il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_3K); + il->hw_params.max_rxq_size = RX_QUEUE_SIZE; + il->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; + il->hw_params.max_stations = IL3945_STATION_COUNT; + il->ctx.bcast_sta_id = IL3945_BROADCAST_ID; + + il->sta_key_max_num = STA_KEY_MAX_NUM; + + il->hw_params.rx_wrt_ptr_reg = FH39_RSCSR_CHNL0_WPTR; + il->hw_params.max_beacon_itrvl = IL39_MAX_UCODE_BEACON_INTERVAL; + il->hw_params.beacon_time_tsf_bits = IL3945_EXT_BEACON_TIME_POS; + + return 0; +} + +unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, + struct il3945_frame *frame, u8 rate) +{ + struct il3945_tx_beacon_cmd *tx_beacon_cmd; + unsigned int frame_size; + + tx_beacon_cmd = (struct il3945_tx_beacon_cmd *)&frame->u; + memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); + + tx_beacon_cmd->tx.sta_id = + il->ctx.bcast_sta_id; + tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; + + frame_size = il3945_fill_beacon_frame(il, + tx_beacon_cmd->frame, + sizeof(frame->u) - sizeof(*tx_beacon_cmd)); + + BUG_ON(frame_size > MAX_MPDU_SIZE); + tx_beacon_cmd->tx.len = cpu_to_le16((u16)frame_size); + + tx_beacon_cmd->tx.rate = rate; + tx_beacon_cmd->tx.tx_flags = (TX_CMD_FLG_SEQ_CTL_MSK | + TX_CMD_FLG_TSF_MSK); + + /* supp_rates[0] == OFDM start at IL_FIRST_OFDM_RATE*/ + tx_beacon_cmd->tx.supp_rates[0] = + (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; + + tx_beacon_cmd->tx.supp_rates[1] = + (IL_CCK_BASIC_RATES_MASK & 0xF); + + return sizeof(struct il3945_tx_beacon_cmd) + frame_size; +} + +void il3945_hw_rx_handler_setup(struct il_priv *il) +{ + il->rx_handlers[REPLY_TX] = il3945_rx_reply_tx; + il->rx_handlers[REPLY_3945_RX] = il3945_rx_reply_rx; +} + +void il3945_hw_setup_deferred_work(struct il_priv *il) +{ + INIT_DELAYED_WORK(&il->_3945.thermal_periodic, + il3945_bg_reg_txpower_periodic); +} + +void il3945_hw_cancel_deferred_work(struct il_priv *il) +{ + cancel_delayed_work(&il->_3945.thermal_periodic); +} + +/* check contents of special bootstrap uCode SRAM */ +static int il3945_verify_bsm(struct il_priv *il) + { + __le32 *image = il->ucode_boot.v_addr; + u32 len = il->ucode_boot.len; + u32 reg; + u32 val; + + D_INFO("Begin verify bsm\n"); + + /* verify BSM SRAM contents */ + val = il_rd_prph(il, BSM_WR_DWCOUNT_REG); + for (reg = BSM_SRAM_LOWER_BOUND; + reg < BSM_SRAM_LOWER_BOUND + len; + reg += sizeof(u32), image++) { + val = il_rd_prph(il, reg); + if (val != le32_to_cpu(*image)) { + IL_ERR("BSM uCode verification failed at " + "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", + BSM_SRAM_LOWER_BOUND, + reg - BSM_SRAM_LOWER_BOUND, len, + val, le32_to_cpu(*image)); + return -EIO; + } + } + + D_INFO("BSM bootstrap uCode image OK\n"); + + return 0; +} + + +/****************************************************************************** + * + * EEPROM related functions + * + ******************************************************************************/ + +/* + * Clear the OWNER_MSK, to establish driver (instead of uCode running on + * embedded controller) as EEPROM reader; each read is a series of pulses + * to/from the EEPROM chip, not a single event, so even reads could conflict + * if they weren't arbitrated by some ownership mechanism. Here, the driver + * simply claims ownership, which should be safe when this function is called + * (i.e. before loading uCode!). + */ +static int il3945_eeprom_acquire_semaphore(struct il_priv *il) +{ + _il_clear_bit(il, CSR_EEPROM_GP, CSR_EEPROM_GP_IF_OWNER_MSK); + return 0; +} + + +static void il3945_eeprom_release_semaphore(struct il_priv *il) +{ + return; +} + + /** + * il3945_load_bsm - Load bootstrap instructions + * + * BSM operation: + * + * The Bootstrap State Machine (BSM) stores a short bootstrap uCode program + * in special SRAM that does not power down during RFKILL. When powering back + * up after power-saving sleeps (or during initial uCode load), the BSM loads + * the bootstrap program into the on-board processor, and starts it. + * + * The bootstrap program loads (via DMA) instructions and data for a new + * program from host DRAM locations indicated by the host driver in the + * BSM_DRAM_* registers. Once the new program is loaded, it starts + * automatically. + * + * When initializing the NIC, the host driver points the BSM to the + * "initialize" uCode image. This uCode sets up some internal data, then + * notifies host via "initialize alive" that it is complete. + * + * The host then replaces the BSM_DRAM_* pointer values to point to the + * normal runtime uCode instructions and a backup uCode data cache buffer + * (filled initially with starting data values for the on-board processor), + * then triggers the "initialize" uCode to load and launch the runtime uCode, + * which begins normal operation. + * + * When doing a power-save shutdown, runtime uCode saves data SRAM into + * the backup data cache in DRAM before SRAM is powered down. + * + * When powering back up, the BSM loads the bootstrap program. This reloads + * the runtime uCode instructions and the backup data cache into SRAM, + * and re-launches the runtime uCode from where it left off. + */ +static int il3945_load_bsm(struct il_priv *il) +{ + __le32 *image = il->ucode_boot.v_addr; + u32 len = il->ucode_boot.len; + dma_addr_t pinst; + dma_addr_t pdata; + u32 inst_len; + u32 data_len; + int rc; + int i; + u32 done; + u32 reg_offset; + + D_INFO("Begin load bsm\n"); + + /* make sure bootstrap program is no larger than BSM's SRAM size */ + if (len > IL39_MAX_BSM_SIZE) + return -EINVAL; + + /* Tell bootstrap uCode where to find the "Initialize" uCode + * in host DRAM ... host DRAM physical address bits 31:0 for 3945. + * NOTE: il3945_initialize_alive_start() will replace these values, + * after the "initialize" uCode has run, to point to + * runtime/protocol instructions and backup data cache. */ + pinst = il->ucode_init.p_addr; + pdata = il->ucode_init_data.p_addr; + inst_len = il->ucode_init.len; + data_len = il->ucode_init_data.len; + + il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); + il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); + il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); + il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); + + /* Fill BSM memory with bootstrap instructions */ + for (reg_offset = BSM_SRAM_LOWER_BOUND; + reg_offset < BSM_SRAM_LOWER_BOUND + len; + reg_offset += sizeof(u32), image++) + _il_wr_prph(il, reg_offset, + le32_to_cpu(*image)); + + rc = il3945_verify_bsm(il); + if (rc) + return rc; + + /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ + il_wr_prph(il, BSM_WR_MEM_SRC_REG, 0x0); + il_wr_prph(il, BSM_WR_MEM_DST_REG, + IL39_RTC_INST_LOWER_BOUND); + il_wr_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); + + /* Load bootstrap code into instruction SRAM now, + * to prepare to load "initialize" uCode */ + il_wr_prph(il, BSM_WR_CTRL_REG, + BSM_WR_CTRL_REG_BIT_START); + + /* Wait for load of bootstrap uCode to finish */ + for (i = 0; i < 100; i++) { + done = il_rd_prph(il, BSM_WR_CTRL_REG); + if (!(done & BSM_WR_CTRL_REG_BIT_START)) + break; + udelay(10); + } + if (i < 100) + D_INFO("BSM write complete, poll %d iterations\n", i); + else { + IL_ERR("BSM write did not complete!\n"); + return -EIO; + } + + /* Enable future boot loads whenever power management unit triggers it + * (e.g. when powering back up after power-save shutdown) */ + il_wr_prph(il, BSM_WR_CTRL_REG, + BSM_WR_CTRL_REG_BIT_START_EN); + + return 0; +} + +static struct il_hcmd_ops il3945_hcmd = { + .rxon_assoc = il3945_send_rxon_assoc, + .commit_rxon = il3945_commit_rxon, +}; + +static struct il_lib_ops il3945_lib = { + .txq_attach_buf_to_tfd = il3945_hw_txq_attach_buf_to_tfd, + .txq_free_tfd = il3945_hw_txq_free_tfd, + .txq_init = il3945_hw_tx_queue_init, + .load_ucode = il3945_load_bsm, + .dump_nic_error_log = il3945_dump_nic_error_log, + .apm_ops = { + .init = il3945_apm_init, + .config = il3945_nic_config, + }, + .eeprom_ops = { + .regulatory_bands = { + EEPROM_REGULATORY_BAND_1_CHANNELS, + EEPROM_REGULATORY_BAND_2_CHANNELS, + EEPROM_REGULATORY_BAND_3_CHANNELS, + EEPROM_REGULATORY_BAND_4_CHANNELS, + EEPROM_REGULATORY_BAND_5_CHANNELS, + EEPROM_REGULATORY_BAND_NO_HT40, + EEPROM_REGULATORY_BAND_NO_HT40, + }, + .acquire_semaphore = il3945_eeprom_acquire_semaphore, + .release_semaphore = il3945_eeprom_release_semaphore, + }, + .send_tx_power = il3945_send_tx_power, + .is_valid_rtc_data_addr = il3945_hw_valid_rtc_data_addr, + + .debugfs_ops = { + .rx_stats_read = il3945_ucode_rx_stats_read, + .tx_stats_read = il3945_ucode_tx_stats_read, + .general_stats_read = il3945_ucode_general_stats_read, + }, +}; + +static const struct il_legacy_ops il3945_legacy_ops = { + .post_associate = il3945_post_associate, + .config_ap = il3945_config_ap, + .manage_ibss_station = il3945_manage_ibss_station, +}; + +static struct il_hcmd_utils_ops il3945_hcmd_utils = { + .get_hcmd_size = il3945_get_hcmd_size, + .build_addsta_hcmd = il3945_build_addsta_hcmd, + .request_scan = il3945_request_scan, + .post_scan = il3945_post_scan, +}; + +static const struct il_ops il3945_ops = { + .lib = &il3945_lib, + .hcmd = &il3945_hcmd, + .utils = &il3945_hcmd_utils, + .led = &il3945_led_ops, + .legacy = &il3945_legacy_ops, + .ieee80211_ops = &il3945_hw_ops, +}; + +static struct il_base_params il3945_base_params = { + .eeprom_size = IL3945_EEPROM_IMG_SIZE, + .num_of_queues = IL39_NUM_QUEUES, + .pll_cfg_val = CSR39_ANA_PLL_CFG_VAL, + .set_l0s = false, + .use_bsm = true, + .led_compensation = 64, + .wd_timeout = IL_DEF_WD_TIMEOUT, +}; + +static struct il_cfg il3945_bg_cfg = { + .name = "3945BG", + .fw_name_pre = IL3945_FW_PRE, + .ucode_api_max = IL3945_UCODE_API_MAX, + .ucode_api_min = IL3945_UCODE_API_MIN, + .sku = IL_SKU_G, + .eeprom_ver = EEPROM_3945_EEPROM_VERSION, + .ops = &il3945_ops, + .mod_params = &il3945_mod_params, + .base_params = &il3945_base_params, + .led_mode = IL_LED_BLINK, +}; + +static struct il_cfg il3945_abg_cfg = { + .name = "3945ABG", + .fw_name_pre = IL3945_FW_PRE, + .ucode_api_max = IL3945_UCODE_API_MAX, + .ucode_api_min = IL3945_UCODE_API_MIN, + .sku = IL_SKU_A|IL_SKU_G, + .eeprom_ver = EEPROM_3945_EEPROM_VERSION, + .ops = &il3945_ops, + .mod_params = &il3945_mod_params, + .base_params = &il3945_base_params, + .led_mode = IL_LED_BLINK, +}; + +DEFINE_PCI_DEVICE_TABLE(il3945_hw_card_ids) = { + {IL_PCI_DEVICE(0x4222, 0x1005, il3945_bg_cfg)}, + {IL_PCI_DEVICE(0x4222, 0x1034, il3945_bg_cfg)}, + {IL_PCI_DEVICE(0x4222, 0x1044, il3945_bg_cfg)}, + {IL_PCI_DEVICE(0x4227, 0x1014, il3945_bg_cfg)}, + {IL_PCI_DEVICE(0x4222, PCI_ANY_ID, il3945_abg_cfg)}, + {IL_PCI_DEVICE(0x4227, PCI_ANY_ID, il3945_abg_cfg)}, + {0} +}; + +MODULE_DEVICE_TABLE(pci, il3945_hw_card_ids); diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c new file mode 100644 index 000000000000..df86431d3bae --- /dev/null +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -0,0 +1,3245 @@ +/****************************************************************************** + * + * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * + * Portions of this file are derived from the ipw3945 project, as well + * as portions of the ieee80211 subsystem header files. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + *****************************************************************************/ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#define DRV_NAME "iwl4965" + +#include "iwl-eeprom.h" +#include "iwl-dev.h" +#include "iwl-core.h" +#include "iwl-io.h" +#include "iwl-helpers.h" +#include "iwl-sta.h" +#include "iwl-4965-calib.h" +#include "iwl-4965.h" +#include "iwl-4965-led.h" + + +/****************************************************************************** + * + * module boiler plate + * + ******************************************************************************/ + +/* + * module name, copyright, version, etc. + */ +#define DRV_DESCRIPTION "Intel(R) Wireless WiFi 4965 driver for Linux" + +#ifdef CONFIG_IWLEGACY_DEBUG +#define VD "d" +#else +#define VD +#endif + +#define DRV_VERSION IWLWIFI_VERSION VD + + +MODULE_DESCRIPTION(DRV_DESCRIPTION); +MODULE_VERSION(DRV_VERSION); +MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("iwl4965"); + +void il4965_update_chain_flags(struct il_priv *il) +{ + if (il->cfg->ops->hcmd->set_rxon_chain) { + il->cfg->ops->hcmd->set_rxon_chain(il, &il->ctx); + if (il->ctx.active.rx_chain != il->ctx.staging.rx_chain) + il_commit_rxon(il, &il->ctx); + } +} + +static void il4965_clear_free_frames(struct il_priv *il) +{ + struct list_head *element; + + D_INFO("%d frames on pre-allocated heap on clear.\n", + il->frames_count); + + while (!list_empty(&il->free_frames)) { + element = il->free_frames.next; + list_del(element); + kfree(list_entry(element, struct il_frame, list)); + il->frames_count--; + } + + if (il->frames_count) { + IL_WARN("%d frames still in use. Did we lose one?\n", + il->frames_count); + il->frames_count = 0; + } +} + +static struct il_frame *il4965_get_free_frame(struct il_priv *il) +{ + struct il_frame *frame; + struct list_head *element; + if (list_empty(&il->free_frames)) { + frame = kzalloc(sizeof(*frame), GFP_KERNEL); + if (!frame) { + IL_ERR("Could not allocate frame!\n"); + return NULL; + } + + il->frames_count++; + return frame; + } + + element = il->free_frames.next; + list_del(element); + return list_entry(element, struct il_frame, list); +} + +static void il4965_free_frame(struct il_priv *il, struct il_frame *frame) +{ + memset(frame, 0, sizeof(*frame)); + list_add(&frame->list, &il->free_frames); +} + +static u32 il4965_fill_beacon_frame(struct il_priv *il, + struct ieee80211_hdr *hdr, + int left) +{ + lockdep_assert_held(&il->mutex); + + if (!il->beacon_skb) + return 0; + + if (il->beacon_skb->len > left) + return 0; + + memcpy(hdr, il->beacon_skb->data, il->beacon_skb->len); + + return il->beacon_skb->len; +} + +/* Parse the beacon frame to find the TIM element and set tim_idx & tim_size */ +static void il4965_set_beacon_tim(struct il_priv *il, + struct il_tx_beacon_cmd *tx_beacon_cmd, + u8 *beacon, u32 frame_size) +{ + u16 tim_idx; + struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)beacon; + + /* + * The idx is relative to frame start but we start looking at the + * variable-length part of the beacon. + */ + tim_idx = mgmt->u.beacon.variable - beacon; + + /* Parse variable-length elements of beacon to find WLAN_EID_TIM */ + while ((tim_idx < (frame_size - 2)) && + (beacon[tim_idx] != WLAN_EID_TIM)) + tim_idx += beacon[tim_idx+1] + 2; + + /* If TIM field was found, set variables */ + if ((tim_idx < (frame_size - 1)) && (beacon[tim_idx] == WLAN_EID_TIM)) { + tx_beacon_cmd->tim_idx = cpu_to_le16(tim_idx); + tx_beacon_cmd->tim_size = beacon[tim_idx+1]; + } else + IL_WARN("Unable to find TIM Element in beacon\n"); +} + +static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *il, + struct il_frame *frame) +{ + struct il_tx_beacon_cmd *tx_beacon_cmd; + u32 frame_size; + u32 rate_flags; + u32 rate; + /* + * We have to set up the TX command, the TX Beacon command, and the + * beacon contents. + */ + + lockdep_assert_held(&il->mutex); + + if (!il->beacon_ctx) { + IL_ERR("trying to build beacon w/o beacon context!\n"); + return 0; + } + + /* Initialize memory */ + tx_beacon_cmd = &frame->u.beacon; + memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); + + /* Set up TX beacon contents */ + frame_size = il4965_fill_beacon_frame(il, tx_beacon_cmd->frame, + sizeof(frame->u) - sizeof(*tx_beacon_cmd)); + if (WARN_ON_ONCE(frame_size > MAX_MPDU_SIZE)) + return 0; + if (!frame_size) + return 0; + + /* Set up TX command fields */ + tx_beacon_cmd->tx.len = cpu_to_le16((u16)frame_size); + tx_beacon_cmd->tx.sta_id = il->beacon_ctx->bcast_sta_id; + tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; + tx_beacon_cmd->tx.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK | + TX_CMD_FLG_TSF_MSK | TX_CMD_FLG_STA_RATE_MSK; + + /* Set up TX beacon command fields */ + il4965_set_beacon_tim(il, tx_beacon_cmd, (u8 *)tx_beacon_cmd->frame, + frame_size); + + /* Set up packet rate and flags */ + rate = il_get_lowest_plcp(il, il->beacon_ctx); + il->mgmt_tx_ant = il4965_toggle_tx_ant(il, il->mgmt_tx_ant, + il->hw_params.valid_tx_ant); + rate_flags = il4965_ant_idx_to_flags(il->mgmt_tx_ant); + if ((rate >= IL_FIRST_CCK_RATE) && (rate <= IL_LAST_CCK_RATE)) + rate_flags |= RATE_MCS_CCK_MSK; + tx_beacon_cmd->tx.rate_n_flags = il4965_hw_set_rate_n_flags(rate, + rate_flags); + + return sizeof(*tx_beacon_cmd) + frame_size; +} + +int il4965_send_beacon_cmd(struct il_priv *il) +{ + struct il_frame *frame; + unsigned int frame_size; + int rc; + + frame = il4965_get_free_frame(il); + if (!frame) { + IL_ERR("Could not obtain free frame buffer for beacon " + "command.\n"); + return -ENOMEM; + } + + frame_size = il4965_hw_get_beacon_cmd(il, frame); + if (!frame_size) { + IL_ERR("Error configuring the beacon command\n"); + il4965_free_frame(il, frame); + return -EINVAL; + } + + rc = il_send_cmd_pdu(il, REPLY_TX_BEACON, frame_size, + &frame->u.cmd[0]); + + il4965_free_frame(il, frame); + + return rc; +} + +static inline dma_addr_t il4965_tfd_tb_get_addr(struct il_tfd *tfd, u8 idx) +{ + struct il_tfd_tb *tb = &tfd->tbs[idx]; + + dma_addr_t addr = get_unaligned_le32(&tb->lo); + if (sizeof(dma_addr_t) > sizeof(u32)) + addr |= + ((dma_addr_t)(le16_to_cpu(tb->hi_n_len) & 0xF) << 16) << 16; + + return addr; +} + +static inline u16 il4965_tfd_tb_get_len(struct il_tfd *tfd, u8 idx) +{ + struct il_tfd_tb *tb = &tfd->tbs[idx]; + + return le16_to_cpu(tb->hi_n_len) >> 4; +} + +static inline void il4965_tfd_set_tb(struct il_tfd *tfd, u8 idx, + dma_addr_t addr, u16 len) +{ + struct il_tfd_tb *tb = &tfd->tbs[idx]; + u16 hi_n_len = len << 4; + + put_unaligned_le32(addr, &tb->lo); + if (sizeof(dma_addr_t) > sizeof(u32)) + hi_n_len |= ((addr >> 16) >> 16) & 0xF; + + tb->hi_n_len = cpu_to_le16(hi_n_len); + + tfd->num_tbs = idx + 1; +} + +static inline u8 il4965_tfd_get_num_tbs(struct il_tfd *tfd) +{ + return tfd->num_tbs & 0x1f; +} + +/** + * il4965_hw_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr] + * @il - driver ilate data + * @txq - tx queue + * + * Does NOT advance any TFD circular buffer read/write idxes + * Does NOT free the TFD itself (which is within circular buffer) + */ +void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) +{ + struct il_tfd *tfd_tmp = (struct il_tfd *)txq->tfds; + struct il_tfd *tfd; + struct pci_dev *dev = il->pci_dev; + int idx = txq->q.read_ptr; + int i; + int num_tbs; + + tfd = &tfd_tmp[idx]; + + /* Sanity check on number of chunks */ + num_tbs = il4965_tfd_get_num_tbs(tfd); + + if (num_tbs >= IL_NUM_OF_TBS) { + IL_ERR("Too many chunks: %i\n", num_tbs); + /* @todo issue fatal error, it is quite serious situation */ + return; + } + + /* Unmap tx_cmd */ + if (num_tbs) + pci_unmap_single(dev, + dma_unmap_addr(&txq->meta[idx], mapping), + dma_unmap_len(&txq->meta[idx], len), + PCI_DMA_BIDIRECTIONAL); + + /* Unmap chunks, if any. */ + for (i = 1; i < num_tbs; i++) + pci_unmap_single(dev, il4965_tfd_tb_get_addr(tfd, i), + il4965_tfd_tb_get_len(tfd, i), + PCI_DMA_TODEVICE); + + /* free SKB */ + if (txq->txb) { + struct sk_buff *skb; + + skb = txq->txb[txq->q.read_ptr].skb; + + /* can be called from irqs-disabled context */ + if (skb) { + dev_kfree_skb_any(skb); + txq->txb[txq->q.read_ptr].skb = NULL; + } + } +} + +int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, + struct il_tx_queue *txq, + dma_addr_t addr, u16 len, + u8 reset, u8 pad) +{ + struct il_queue *q; + struct il_tfd *tfd, *tfd_tmp; + u32 num_tbs; + + q = &txq->q; + tfd_tmp = (struct il_tfd *)txq->tfds; + tfd = &tfd_tmp[q->write_ptr]; + + if (reset) + memset(tfd, 0, sizeof(*tfd)); + + num_tbs = il4965_tfd_get_num_tbs(tfd); + + /* Each TFD can point to a maximum 20 Tx buffers */ + if (num_tbs >= IL_NUM_OF_TBS) { + IL_ERR("Error can not send more than %d chunks\n", + IL_NUM_OF_TBS); + return -EINVAL; + } + + BUG_ON(addr & ~DMA_BIT_MASK(36)); + if (unlikely(addr & ~IL_TX_DMA_MASK)) + IL_ERR("Unaligned address = %llx\n", + (unsigned long long)addr); + + il4965_tfd_set_tb(tfd, num_tbs, addr, len); + + return 0; +} + +/* + * Tell nic where to find circular buffer of Tx Frame Descriptors for + * given Tx queue, and enable the DMA channel used for that queue. + * + * 4965 supports up to 16 Tx queues in DRAM, mapped to up to 8 Tx DMA + * channels supported in hardware. + */ +int il4965_hw_tx_queue_init(struct il_priv *il, + struct il_tx_queue *txq) +{ + int txq_id = txq->q.id; + + /* Circular buffer (TFD queue in DRAM) physical base address */ + il_wr(il, FH_MEM_CBBC_QUEUE(txq_id), + txq->q.dma_addr >> 8); + + return 0; +} + +/****************************************************************************** + * + * Generic RX handler implementations + * + ******************************************************************************/ +static void il4965_rx_reply_alive(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il_alive_resp *palive; + struct delayed_work *pwork; + + palive = &pkt->u.alive_frame; + + D_INFO("Alive ucode status 0x%08X revision " + "0x%01X 0x%01X\n", + palive->is_valid, palive->ver_type, + palive->ver_subtype); + + if (palive->ver_subtype == INITIALIZE_SUBTYPE) { + D_INFO("Initialization Alive received.\n"); + memcpy(&il->card_alive_init, + &pkt->u.alive_frame, + sizeof(struct il_init_alive_resp)); + pwork = &il->init_alive_start; + } else { + D_INFO("Runtime Alive received.\n"); + memcpy(&il->card_alive, &pkt->u.alive_frame, + sizeof(struct il_alive_resp)); + pwork = &il->alive_start; + } + + /* We delay the ALIVE response by 5ms to + * give the HW RF Kill time to activate... */ + if (palive->is_valid == UCODE_VALID_OK) + queue_delayed_work(il->workqueue, pwork, + msecs_to_jiffies(5)); + else + IL_WARN("uCode did not respond OK.\n"); +} + +/** + * il4965_bg_stats_periodic - Timer callback to queue stats + * + * This callback is provided in order to send a stats request. + * + * This timer function is continually reset to execute within + * REG_RECALIB_PERIOD seconds since the last STATISTICS_NOTIFICATION + * was received. We need to ensure we receive the stats in order + * to update the temperature used for calibrating the TXPOWER. + */ +static void il4965_bg_stats_periodic(unsigned long data) +{ + struct il_priv *il = (struct il_priv *)data; + + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + return; + + /* dont send host command if rf-kill is on */ + if (!il_is_ready_rf(il)) + return; + + il_send_stats_request(il, CMD_ASYNC, false); +} + +static void il4965_rx_beacon_notif(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il4965_beacon_notif *beacon = + (struct il4965_beacon_notif *)pkt->u.raw; +#ifdef CONFIG_IWLEGACY_DEBUG + u8 rate = il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); + + D_RX("beacon status %x retries %d iss %d " + "tsf %d %d rate %d\n", + le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, + beacon->beacon_notify_hdr.failure_frame, + le32_to_cpu(beacon->ibss_mgr_status), + le32_to_cpu(beacon->high_tsf), + le32_to_cpu(beacon->low_tsf), rate); +#endif + + il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); +} + +static void il4965_perform_ct_kill_task(struct il_priv *il) +{ + unsigned long flags; + + D_POWER("Stop all queues\n"); + + if (il->mac80211_registered) + ieee80211_stop_queues(il->hw); + + _il_wr(il, CSR_UCODE_DRV_GP1_SET, + CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); + _il_rd(il, CSR_UCODE_DRV_GP1); + + spin_lock_irqsave(&il->reg_lock, flags); + if (!_il_grab_nic_access(il)) + _il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, flags); +} + +/* Handle notification from uCode that card's power state is changing + * due to software, hardware, or critical temperature RFKILL */ +static void il4965_rx_card_state_notif(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); + unsigned long status = il->status; + + D_RF_KILL("Card state received: HW:%s SW:%s CT:%s\n", + (flags & HW_CARD_DISABLED) ? "Kill" : "On", + (flags & SW_CARD_DISABLED) ? "Kill" : "On", + (flags & CT_CARD_DISABLED) ? + "Reached" : "Not reached"); + + if (flags & (SW_CARD_DISABLED | HW_CARD_DISABLED | + CT_CARD_DISABLED)) { + + _il_wr(il, CSR_UCODE_DRV_GP1_SET, + CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); + + il_wr(il, HBUS_TARG_MBX_C, + HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); + + if (!(flags & RXON_CARD_DISABLED)) { + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, + CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); + il_wr(il, HBUS_TARG_MBX_C, + HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); + } + } + + if (flags & CT_CARD_DISABLED) + il4965_perform_ct_kill_task(il); + + if (flags & HW_CARD_DISABLED) + set_bit(STATUS_RF_KILL_HW, &il->status); + else + clear_bit(STATUS_RF_KILL_HW, &il->status); + + if (!(flags & RXON_CARD_DISABLED)) + il_scan_cancel(il); + + if ((test_bit(STATUS_RF_KILL_HW, &status) != + test_bit(STATUS_RF_KILL_HW, &il->status))) + wiphy_rfkill_set_hw_state(il->hw->wiphy, + test_bit(STATUS_RF_KILL_HW, &il->status)); + else + wake_up(&il->wait_command_queue); +} + +/** + * il4965_setup_rx_handlers - Initialize Rx handler callbacks + * + * Setup the RX handlers for each of the reply types sent from the uCode + * to the host. + * + * This function chains into the hardware specific files for them to setup + * any hardware specific handlers as well. + */ +static void il4965_setup_rx_handlers(struct il_priv *il) +{ + il->rx_handlers[REPLY_ALIVE] = il4965_rx_reply_alive; + il->rx_handlers[REPLY_ERROR] = il_rx_reply_error; + il->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa; + il->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = + il_rx_spectrum_measure_notif; + il->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; + il->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = + il_rx_pm_debug_stats_notif; + il->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; + + /* + * The same handler is used for both the REPLY to a discrete + * stats request from the host as well as for the periodic + * stats notifications (after received beacons) from the uCode. + */ + il->rx_handlers[REPLY_STATISTICS_CMD] = il4965_reply_stats; + il->rx_handlers[STATISTICS_NOTIFICATION] = il4965_rx_stats; + + il_setup_rx_scan_handlers(il); + + /* status change handler */ + il->rx_handlers[CARD_STATE_NOTIFICATION] = + il4965_rx_card_state_notif; + + il->rx_handlers[MISSED_BEACONS_NOTIFICATION] = + il4965_rx_missed_beacon_notif; + /* Rx handlers */ + il->rx_handlers[REPLY_RX_PHY_CMD] = il4965_rx_reply_rx_phy; + il->rx_handlers[REPLY_RX_MPDU_CMD] = il4965_rx_reply_rx; + /* block ack */ + il->rx_handlers[REPLY_COMPRESSED_BA] = il4965_rx_reply_compressed_ba; + /* Set up hardware specific Rx handlers */ + il->cfg->ops->lib->rx_handler_setup(il); +} + +/** + * il4965_rx_handle - Main entry function for receiving responses from uCode + * + * Uses the il->rx_handlers callback function array to invoke + * the appropriate handlers, including command responses, + * frame-received notifications, and other notifications. + */ +void il4965_rx_handle(struct il_priv *il) +{ + struct il_rx_buf *rxb; + struct il_rx_pkt *pkt; + struct il_rx_queue *rxq = &il->rxq; + u32 r, i; + int reclaim; + unsigned long flags; + u8 fill_rx = 0; + u32 count = 8; + int total_empty; + + /* uCode's read idx (stored in shared DRAM) indicates the last Rx + * buffer that the driver may process (last buffer filled by ucode). */ + r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF; + i = rxq->read; + + /* Rx interrupt, but nothing sent from uCode */ + if (i == r) + D_RX("r = %d, i = %d\n", r, i); + + /* calculate total frames need to be restock after handling RX */ + total_empty = r - rxq->write_actual; + if (total_empty < 0) + total_empty += RX_QUEUE_SIZE; + + if (total_empty > (RX_QUEUE_SIZE / 2)) + fill_rx = 1; + + while (i != r) { + int len; + + rxb = rxq->queue[i]; + + /* If an RXB doesn't have a Rx queue slot associated with it, + * then a bug has been introduced in the queue refilling + * routines -- catch it here */ + BUG_ON(rxb == NULL); + + rxq->queue[i] = NULL; + + pci_unmap_page(il->pci_dev, rxb->page_dma, + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); + pkt = rxb_addr(rxb); + + len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; + len += sizeof(u32); /* account for status word */ + + /* Reclaim a command buffer only if this packet is a response + * to a (driver-originated) command. + * If the packet (e.g. Rx frame) originated from uCode, + * there is no command buffer to reclaim. + * Ucode should set SEQ_RX_FRAME bit if ucode-originated, + * but apparently a few don't get set; catch them here. */ + reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) && + (pkt->hdr.cmd != REPLY_RX_PHY_CMD) && + (pkt->hdr.cmd != REPLY_RX) && + (pkt->hdr.cmd != REPLY_RX_MPDU_CMD) && + (pkt->hdr.cmd != REPLY_COMPRESSED_BA) && + (pkt->hdr.cmd != STATISTICS_NOTIFICATION) && + (pkt->hdr.cmd != REPLY_TX); + + /* Based on type of command response or notification, + * handle those that need handling via function in + * rx_handlers table. See il4965_setup_rx_handlers() */ + if (il->rx_handlers[pkt->hdr.cmd]) { + D_RX("r = %d, i = %d, %s, 0x%02x\n", r, + i, il_get_cmd_string(pkt->hdr.cmd), + pkt->hdr.cmd); + il->isr_stats.rx_handlers[pkt->hdr.cmd]++; + il->rx_handlers[pkt->hdr.cmd] (il, rxb); + } else { + /* No handling needed */ + D_RX( + "r %d i %d No handler needed for %s, 0x%02x\n", + r, i, il_get_cmd_string(pkt->hdr.cmd), + pkt->hdr.cmd); + } + + /* + * XXX: After here, we should always check rxb->page + * against NULL before touching it or its virtual + * memory (pkt). Because some rx_handler might have + * already taken or freed the pages. + */ + + if (reclaim) { + /* Invoke any callbacks, transfer the buffer to caller, + * and fire off the (possibly) blocking il_send_cmd() + * as we reclaim the driver command queue */ + if (rxb->page) + il_tx_cmd_complete(il, rxb); + else + IL_WARN("Claim null rxb?\n"); + } + + /* Reuse the page if possible. For notification packets and + * SKBs that fail to Rx correctly, add them back into the + * rx_free list for reuse later. */ + spin_lock_irqsave(&rxq->lock, flags); + if (rxb->page != NULL) { + rxb->page_dma = pci_map_page(il->pci_dev, rxb->page, + 0, PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); + list_add_tail(&rxb->list, &rxq->rx_free); + rxq->free_count++; + } else + list_add_tail(&rxb->list, &rxq->rx_used); + + spin_unlock_irqrestore(&rxq->lock, flags); + + i = (i + 1) & RX_QUEUE_MASK; + /* If there are a lot of unused frames, + * restock the Rx queue so ucode wont assert. */ + if (fill_rx) { + count++; + if (count >= 8) { + rxq->read = i; + il4965_rx_replenish_now(il); + count = 0; + } + } + } + + /* Backtrack one entry */ + rxq->read = i; + if (fill_rx) + il4965_rx_replenish_now(il); + else + il4965_rx_queue_restock(il); +} + +/* call this function to flush any scheduled tasklet */ +static inline void il4965_synchronize_irq(struct il_priv *il) +{ + /* wait to make sure we flush pending tasklet*/ + synchronize_irq(il->pci_dev->irq); + tasklet_kill(&il->irq_tasklet); +} + +static void il4965_irq_tasklet(struct il_priv *il) +{ + u32 inta, handled = 0; + u32 inta_fh; + unsigned long flags; + u32 i; +#ifdef CONFIG_IWLEGACY_DEBUG + u32 inta_mask; +#endif + + spin_lock_irqsave(&il->lock, flags); + + /* Ack/clear/reset pending uCode interrupts. + * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS, + * and will clear only when CSR_FH_INT_STATUS gets cleared. */ + inta = _il_rd(il, CSR_INT); + _il_wr(il, CSR_INT, inta); + + /* Ack/clear/reset pending flow-handler (DMA) interrupts. + * Any new interrupts that happen after this, either while we're + * in this tasklet, or later, will show up in next ISR/tasklet. */ + inta_fh = _il_rd(il, CSR_FH_INT_STATUS); + _il_wr(il, CSR_FH_INT_STATUS, inta_fh); + +#ifdef CONFIG_IWLEGACY_DEBUG + if (il_get_debug_level(il) & IL_DL_ISR) { + /* just for debug */ + inta_mask = _il_rd(il, CSR_INT_MASK); + D_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", + inta, inta_mask, inta_fh); + } +#endif + + spin_unlock_irqrestore(&il->lock, flags); + + /* Since CSR_INT and CSR_FH_INT_STATUS reads and clears are not + * atomic, make sure that inta covers all the interrupts that + * we've discovered, even if FH interrupt came in just after + * reading CSR_INT. */ + if (inta_fh & CSR49_FH_INT_RX_MASK) + inta |= CSR_INT_BIT_FH_RX; + if (inta_fh & CSR49_FH_INT_TX_MASK) + inta |= CSR_INT_BIT_FH_TX; + + /* Now service all interrupt bits discovered above. */ + if (inta & CSR_INT_BIT_HW_ERR) { + IL_ERR("Hardware error detected. Restarting.\n"); + + /* Tell the device to stop sending interrupts */ + il_disable_interrupts(il); + + il->isr_stats.hw++; + il_irq_handle_error(il); + + handled |= CSR_INT_BIT_HW_ERR; + + return; + } + +#ifdef CONFIG_IWLEGACY_DEBUG + if (il_get_debug_level(il) & (IL_DL_ISR)) { + /* NIC fires this, but we don't use it, redundant with WAKEUP */ + if (inta & CSR_INT_BIT_SCD) { + D_ISR("Scheduler finished to transmit " + "the frame/frames.\n"); + il->isr_stats.sch++; + } + + /* Alive notification via Rx interrupt will do the real work */ + if (inta & CSR_INT_BIT_ALIVE) { + D_ISR("Alive interrupt\n"); + il->isr_stats.alive++; + } + } +#endif + /* Safely ignore these bits for debug checks below */ + inta &= ~(CSR_INT_BIT_SCD | CSR_INT_BIT_ALIVE); + + /* HW RF KILL switch toggled */ + if (inta & CSR_INT_BIT_RF_KILL) { + int hw_rf_kill = 0; + if (!(_il_rd(il, CSR_GP_CNTRL) & + CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) + hw_rf_kill = 1; + + IL_WARN("RF_KILL bit toggled to %s.\n", + hw_rf_kill ? "disable radio" : "enable radio"); + + il->isr_stats.rfkill++; + + /* driver only loads ucode once setting the interface up. + * the driver allows loading the ucode even if the radio + * is killed. Hence update the killswitch state here. The + * rfkill handler will care about restarting if needed. + */ + if (!test_bit(STATUS_ALIVE, &il->status)) { + if (hw_rf_kill) + set_bit(STATUS_RF_KILL_HW, &il->status); + else + clear_bit(STATUS_RF_KILL_HW, &il->status); + wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rf_kill); + } + + handled |= CSR_INT_BIT_RF_KILL; + } + + /* Chip got too hot and stopped itself */ + if (inta & CSR_INT_BIT_CT_KILL) { + IL_ERR("Microcode CT kill error detected.\n"); + il->isr_stats.ctkill++; + handled |= CSR_INT_BIT_CT_KILL; + } + + /* Error detected by uCode */ + if (inta & CSR_INT_BIT_SW_ERR) { + IL_ERR("Microcode SW error detected. " + " Restarting 0x%X.\n", inta); + il->isr_stats.sw++; + il_irq_handle_error(il); + handled |= CSR_INT_BIT_SW_ERR; + } + + /* + * uCode wakes up after power-down sleep. + * Tell device about any new tx or host commands enqueued, + * and about any Rx buffers made available while asleep. + */ + if (inta & CSR_INT_BIT_WAKEUP) { + D_ISR("Wakeup interrupt\n"); + il_rx_queue_update_write_ptr(il, &il->rxq); + for (i = 0; i < il->hw_params.max_txq_num; i++) + il_txq_update_write_ptr(il, &il->txq[i]); + il->isr_stats.wakeup++; + handled |= CSR_INT_BIT_WAKEUP; + } + + /* All uCode command responses, including Tx command responses, + * Rx "responses" (frame-received notification), and other + * notifications from uCode come through here*/ + if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) { + il4965_rx_handle(il); + il->isr_stats.rx++; + handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX); + } + + /* This "Tx" DMA channel is used only for loading uCode */ + if (inta & CSR_INT_BIT_FH_TX) { + D_ISR("uCode load interrupt\n"); + il->isr_stats.tx++; + handled |= CSR_INT_BIT_FH_TX; + /* Wake up uCode load routine, now that load is complete */ + il->ucode_write_complete = 1; + wake_up(&il->wait_command_queue); + } + + if (inta & ~handled) { + IL_ERR("Unhandled INTA bits 0x%08x\n", inta & ~handled); + il->isr_stats.unhandled++; + } + + if (inta & ~(il->inta_mask)) { + IL_WARN("Disabled INTA bits 0x%08x were pending\n", + inta & ~il->inta_mask); + IL_WARN(" with FH_INT = 0x%08x\n", inta_fh); + } + + /* Re-enable all interrupts */ + /* only Re-enable if disabled by irq */ + if (test_bit(STATUS_INT_ENABLED, &il->status)) + il_enable_interrupts(il); + /* Re-enable RF_KILL if it occurred */ + else if (handled & CSR_INT_BIT_RF_KILL) + il_enable_rfkill_int(il); + +#ifdef CONFIG_IWLEGACY_DEBUG + if (il_get_debug_level(il) & (IL_DL_ISR)) { + inta = _il_rd(il, CSR_INT); + inta_mask = _il_rd(il, CSR_INT_MASK); + inta_fh = _il_rd(il, CSR_FH_INT_STATUS); + D_ISR( + "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " + "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); + } +#endif +} + +/***************************************************************************** + * + * sysfs attributes + * + *****************************************************************************/ + +#ifdef CONFIG_IWLEGACY_DEBUG + +/* + * The following adds a new attribute to the sysfs representation + * of this device driver (i.e. a new file in /sys/class/net/wlan0/device/) + * used for controlling the debug level. + * + * See the level definitions in iwl for details. + * + * The debug_level being managed using sysfs below is a per device debug + * level that is used instead of the global debug level if it (the per + * device debug level) is set. + */ +static ssize_t il4965_show_debug_level(struct device *d, + struct device_attribute *attr, char *buf) +{ + struct il_priv *il = dev_get_drvdata(d); + return sprintf(buf, "0x%08X\n", il_get_debug_level(il)); +} +static ssize_t il4965_store_debug_level(struct device *d, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct il_priv *il = dev_get_drvdata(d); + unsigned long val; + int ret; + + ret = strict_strtoul(buf, 0, &val); + if (ret) + IL_ERR("%s is not in hex or decimal form.\n", buf); + else { + il->debug_level = val; + if (il_alloc_traffic_mem(il)) + IL_ERR( + "Not enough memory to generate traffic log\n"); + } + return strnlen(buf, count); +} + +static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, + il4965_show_debug_level, il4965_store_debug_level); + + +#endif /* CONFIG_IWLEGACY_DEBUG */ + + +static ssize_t il4965_show_temperature(struct device *d, + struct device_attribute *attr, char *buf) +{ + struct il_priv *il = dev_get_drvdata(d); + + if (!il_is_alive(il)) + return -EAGAIN; + + return sprintf(buf, "%d\n", il->temperature); +} + +static DEVICE_ATTR(temperature, S_IRUGO, il4965_show_temperature, NULL); + +static ssize_t il4965_show_tx_power(struct device *d, + struct device_attribute *attr, char *buf) +{ + struct il_priv *il = dev_get_drvdata(d); + + if (!il_is_ready_rf(il)) + return sprintf(buf, "off\n"); + else + return sprintf(buf, "%d\n", il->tx_power_user_lmt); +} + +static ssize_t il4965_store_tx_power(struct device *d, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct il_priv *il = dev_get_drvdata(d); + unsigned long val; + int ret; + + ret = strict_strtoul(buf, 10, &val); + if (ret) + IL_INFO("%s is not in decimal form.\n", buf); + else { + ret = il_set_tx_power(il, val, false); + if (ret) + IL_ERR("failed setting tx power (0x%d).\n", + ret); + else + ret = count; + } + return ret; +} + +static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, + il4965_show_tx_power, il4965_store_tx_power); + +static struct attribute *il_sysfs_entries[] = { + &dev_attr_temperature.attr, + &dev_attr_tx_power.attr, +#ifdef CONFIG_IWLEGACY_DEBUG + &dev_attr_debug_level.attr, +#endif + NULL +}; + +static struct attribute_group il_attribute_group = { + .name = NULL, /* put in device directory */ + .attrs = il_sysfs_entries, +}; + +/****************************************************************************** + * + * uCode download functions + * + ******************************************************************************/ + +static void il4965_dealloc_ucode_pci(struct il_priv *il) +{ + il_free_fw_desc(il->pci_dev, &il->ucode_code); + il_free_fw_desc(il->pci_dev, &il->ucode_data); + il_free_fw_desc(il->pci_dev, &il->ucode_data_backup); + il_free_fw_desc(il->pci_dev, &il->ucode_init); + il_free_fw_desc(il->pci_dev, &il->ucode_init_data); + il_free_fw_desc(il->pci_dev, &il->ucode_boot); +} + +static void il4965_nic_start(struct il_priv *il) +{ + /* Remove all resets to allow NIC to operate */ + _il_wr(il, CSR_RESET, 0); +} + +static void il4965_ucode_callback(const struct firmware *ucode_raw, + void *context); +static int il4965_mac_setup_register(struct il_priv *il, + u32 max_probe_length); + +static int __must_check il4965_request_firmware(struct il_priv *il, bool first) +{ + const char *name_pre = il->cfg->fw_name_pre; + char tag[8]; + + if (first) { + il->fw_idx = il->cfg->ucode_api_max; + sprintf(tag, "%d", il->fw_idx); + } else { + il->fw_idx--; + sprintf(tag, "%d", il->fw_idx); + } + + if (il->fw_idx < il->cfg->ucode_api_min) { + IL_ERR("no suitable firmware found!\n"); + return -ENOENT; + } + + sprintf(il->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); + + D_INFO("attempting to load firmware '%s'\n", + il->firmware_name); + + return request_firmware_nowait(THIS_MODULE, 1, il->firmware_name, + &il->pci_dev->dev, GFP_KERNEL, il, + il4965_ucode_callback); +} + +struct il4965_firmware_pieces { + const void *inst, *data, *init, *init_data, *boot; + size_t inst_size, data_size, init_size, init_data_size, boot_size; +}; + +static int il4965_load_firmware(struct il_priv *il, + const struct firmware *ucode_raw, + struct il4965_firmware_pieces *pieces) +{ + struct il_ucode_header *ucode = (void *)ucode_raw->data; + u32 api_ver, hdr_size; + const u8 *src; + + il->ucode_ver = le32_to_cpu(ucode->ver); + api_ver = IL_UCODE_API(il->ucode_ver); + + switch (api_ver) { + default: + case 0: + case 1: + case 2: + hdr_size = 24; + if (ucode_raw->size < hdr_size) { + IL_ERR("File size too small!\n"); + return -EINVAL; + } + pieces->inst_size = le32_to_cpu(ucode->v1.inst_size); + pieces->data_size = le32_to_cpu(ucode->v1.data_size); + pieces->init_size = le32_to_cpu(ucode->v1.init_size); + pieces->init_data_size = + le32_to_cpu(ucode->v1.init_data_size); + pieces->boot_size = le32_to_cpu(ucode->v1.boot_size); + src = ucode->v1.data; + break; + } + + /* Verify size of file vs. image size info in file's header */ + if (ucode_raw->size != hdr_size + pieces->inst_size + + pieces->data_size + pieces->init_size + + pieces->init_data_size + pieces->boot_size) { + + IL_ERR( + "uCode file size %d does not match expected size\n", + (int)ucode_raw->size); + return -EINVAL; + } + + pieces->inst = src; + src += pieces->inst_size; + pieces->data = src; + src += pieces->data_size; + pieces->init = src; + src += pieces->init_size; + pieces->init_data = src; + src += pieces->init_data_size; + pieces->boot = src; + src += pieces->boot_size; + + return 0; +} + +/** + * il4965_ucode_callback - callback when firmware was loaded + * + * If loaded successfully, copies the firmware into buffers + * for the card to fetch (via DMA). + */ +static void +il4965_ucode_callback(const struct firmware *ucode_raw, void *context) +{ + struct il_priv *il = context; + struct il_ucode_header *ucode; + int err; + struct il4965_firmware_pieces pieces; + const unsigned int api_max = il->cfg->ucode_api_max; + const unsigned int api_min = il->cfg->ucode_api_min; + u32 api_ver; + + u32 max_probe_length = 200; + u32 standard_phy_calibration_size = + IL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE; + + memset(&pieces, 0, sizeof(pieces)); + + if (!ucode_raw) { + if (il->fw_idx <= il->cfg->ucode_api_max) + IL_ERR( + "request for firmware file '%s' failed.\n", + il->firmware_name); + goto try_again; + } + + D_INFO("Loaded firmware file '%s' (%zd bytes).\n", + il->firmware_name, ucode_raw->size); + + /* Make sure that we got at least the API version number */ + if (ucode_raw->size < 4) { + IL_ERR("File size way too small!\n"); + goto try_again; + } + + /* Data from ucode file: header followed by uCode images */ + ucode = (struct il_ucode_header *)ucode_raw->data; + + err = il4965_load_firmware(il, ucode_raw, &pieces); + + if (err) + goto try_again; + + api_ver = IL_UCODE_API(il->ucode_ver); + + /* + * api_ver should match the api version forming part of the + * firmware filename ... but we don't check for that and only rely + * on the API version read from firmware header from here on forward + */ + if (api_ver < api_min || api_ver > api_max) { + IL_ERR( + "Driver unable to support your firmware API. " + "Driver supports v%u, firmware is v%u.\n", + api_max, api_ver); + goto try_again; + } + + if (api_ver != api_max) + IL_ERR( + "Firmware has old API version. Expected v%u, " + "got v%u. New firmware can be obtained " + "from http://www.intellinuxwireless.org.\n", + api_max, api_ver); + + IL_INFO("loaded firmware version %u.%u.%u.%u\n", + IL_UCODE_MAJOR(il->ucode_ver), + IL_UCODE_MINOR(il->ucode_ver), + IL_UCODE_API(il->ucode_ver), + IL_UCODE_SERIAL(il->ucode_ver)); + + snprintf(il->hw->wiphy->fw_version, + sizeof(il->hw->wiphy->fw_version), + "%u.%u.%u.%u", + IL_UCODE_MAJOR(il->ucode_ver), + IL_UCODE_MINOR(il->ucode_ver), + IL_UCODE_API(il->ucode_ver), + IL_UCODE_SERIAL(il->ucode_ver)); + + /* + * For any of the failures below (before allocating pci memory) + * we will try to load a version with a smaller API -- maybe the + * user just got a corrupted version of the latest API. + */ + + D_INFO("f/w package hdr ucode version raw = 0x%x\n", + il->ucode_ver); + D_INFO("f/w package hdr runtime inst size = %Zd\n", + pieces.inst_size); + D_INFO("f/w package hdr runtime data size = %Zd\n", + pieces.data_size); + D_INFO("f/w package hdr init inst size = %Zd\n", + pieces.init_size); + D_INFO("f/w package hdr init data size = %Zd\n", + pieces.init_data_size); + D_INFO("f/w package hdr boot inst size = %Zd\n", + pieces.boot_size); + + /* Verify that uCode images will fit in card's SRAM */ + if (pieces.inst_size > il->hw_params.max_inst_size) { + IL_ERR("uCode instr len %Zd too large to fit in\n", + pieces.inst_size); + goto try_again; + } + + if (pieces.data_size > il->hw_params.max_data_size) { + IL_ERR("uCode data len %Zd too large to fit in\n", + pieces.data_size); + goto try_again; + } + + if (pieces.init_size > il->hw_params.max_inst_size) { + IL_ERR("uCode init instr len %Zd too large to fit in\n", + pieces.init_size); + goto try_again; + } + + if (pieces.init_data_size > il->hw_params.max_data_size) { + IL_ERR("uCode init data len %Zd too large to fit in\n", + pieces.init_data_size); + goto try_again; + } + + if (pieces.boot_size > il->hw_params.max_bsm_size) { + IL_ERR("uCode boot instr len %Zd too large to fit in\n", + pieces.boot_size); + goto try_again; + } + + /* Allocate ucode buffers for card's bus-master loading ... */ + + /* Runtime instructions and 2 copies of data: + * 1) unmodified from disk + * 2) backup cache for save/restore during power-downs */ + il->ucode_code.len = pieces.inst_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_code); + + il->ucode_data.len = pieces.data_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_data); + + il->ucode_data_backup.len = pieces.data_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_data_backup); + + if (!il->ucode_code.v_addr || !il->ucode_data.v_addr || + !il->ucode_data_backup.v_addr) + goto err_pci_alloc; + + /* Initialization instructions and data */ + if (pieces.init_size && pieces.init_data_size) { + il->ucode_init.len = pieces.init_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_init); + + il->ucode_init_data.len = pieces.init_data_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_init_data); + + if (!il->ucode_init.v_addr || !il->ucode_init_data.v_addr) + goto err_pci_alloc; + } + + /* Bootstrap (instructions only, no data) */ + if (pieces.boot_size) { + il->ucode_boot.len = pieces.boot_size; + il_alloc_fw_desc(il->pci_dev, &il->ucode_boot); + + if (!il->ucode_boot.v_addr) + goto err_pci_alloc; + } + + /* Now that we can no longer fail, copy information */ + + il->sta_key_max_num = STA_KEY_MAX_NUM; + + /* Copy images into buffers for card's bus-master reads ... */ + + /* Runtime instructions (first block of data in file) */ + D_INFO("Copying (but not loading) uCode instr len %Zd\n", + pieces.inst_size); + memcpy(il->ucode_code.v_addr, pieces.inst, pieces.inst_size); + + D_INFO("uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", + il->ucode_code.v_addr, (u32)il->ucode_code.p_addr); + + /* + * Runtime data + * NOTE: Copy into backup buffer will be done in il_up() + */ + D_INFO("Copying (but not loading) uCode data len %Zd\n", + pieces.data_size); + memcpy(il->ucode_data.v_addr, pieces.data, pieces.data_size); + memcpy(il->ucode_data_backup.v_addr, pieces.data, pieces.data_size); + + /* Initialization instructions */ + if (pieces.init_size) { + D_INFO( + "Copying (but not loading) init instr len %Zd\n", + pieces.init_size); + memcpy(il->ucode_init.v_addr, pieces.init, pieces.init_size); + } + + /* Initialization data */ + if (pieces.init_data_size) { + D_INFO( + "Copying (but not loading) init data len %Zd\n", + pieces.init_data_size); + memcpy(il->ucode_init_data.v_addr, pieces.init_data, + pieces.init_data_size); + } + + /* Bootstrap instructions */ + D_INFO("Copying (but not loading) boot instr len %Zd\n", + pieces.boot_size); + memcpy(il->ucode_boot.v_addr, pieces.boot, pieces.boot_size); + + /* + * figure out the offset of chain noise reset and gain commands + * base on the size of standard phy calibration commands table size + */ + il->_4965.phy_calib_chain_noise_reset_cmd = + standard_phy_calibration_size; + il->_4965.phy_calib_chain_noise_gain_cmd = + standard_phy_calibration_size + 1; + + /************************************************** + * This is still part of probe() in a sense... + * + * 9. Setup and register with mac80211 and debugfs + **************************************************/ + err = il4965_mac_setup_register(il, max_probe_length); + if (err) + goto out_unbind; + + err = il_dbgfs_register(il, DRV_NAME); + if (err) + IL_ERR( + "failed to create debugfs files. Ignoring error: %d\n", err); + + err = sysfs_create_group(&il->pci_dev->dev.kobj, + &il_attribute_group); + if (err) { + IL_ERR("failed to create sysfs device attributes\n"); + goto out_unbind; + } + + /* We have our copies now, allow OS release its copies */ + release_firmware(ucode_raw); + complete(&il->_4965.firmware_loading_complete); + return; + + try_again: + /* try next, if any */ + if (il4965_request_firmware(il, false)) + goto out_unbind; + release_firmware(ucode_raw); + return; + + err_pci_alloc: + IL_ERR("failed to allocate pci memory\n"); + il4965_dealloc_ucode_pci(il); + out_unbind: + complete(&il->_4965.firmware_loading_complete); + device_release_driver(&il->pci_dev->dev); + release_firmware(ucode_raw); +} + +static const char * const desc_lookup_text[] = { + "OK", + "FAIL", + "BAD_PARAM", + "BAD_CHECKSUM", + "NMI_INTERRUPT_WDG", + "SYSASSERT", + "FATAL_ERROR", + "BAD_COMMAND", + "HW_ERROR_TUNE_LOCK", + "HW_ERROR_TEMPERATURE", + "ILLEGAL_CHAN_FREQ", + "VCC_NOT_STBL", + "FH_ERROR", + "NMI_INTERRUPT_HOST", + "NMI_INTERRUPT_ACTION_PT", + "NMI_INTERRUPT_UNKNOWN", + "UCODE_VERSION_MISMATCH", + "HW_ERROR_ABS_LOCK", + "HW_ERROR_CAL_LOCK_FAIL", + "NMI_INTERRUPT_INST_ACTION_PT", + "NMI_INTERRUPT_DATA_ACTION_PT", + "NMI_TRM_HW_ER", + "NMI_INTERRUPT_TRM", + "NMI_INTERRUPT_BREAK_POINT", + "DEBUG_0", + "DEBUG_1", + "DEBUG_2", + "DEBUG_3", +}; + +static struct { char *name; u8 num; } advanced_lookup[] = { + { "NMI_INTERRUPT_WDG", 0x34 }, + { "SYSASSERT", 0x35 }, + { "UCODE_VERSION_MISMATCH", 0x37 }, + { "BAD_COMMAND", 0x38 }, + { "NMI_INTERRUPT_DATA_ACTION_PT", 0x3C }, + { "FATAL_ERROR", 0x3D }, + { "NMI_TRM_HW_ERR", 0x46 }, + { "NMI_INTERRUPT_TRM", 0x4C }, + { "NMI_INTERRUPT_BREAK_POINT", 0x54 }, + { "NMI_INTERRUPT_WDG_RXF_FULL", 0x5C }, + { "NMI_INTERRUPT_WDG_NO_RBD_RXF_FULL", 0x64 }, + { "NMI_INTERRUPT_HOST", 0x66 }, + { "NMI_INTERRUPT_ACTION_PT", 0x7C }, + { "NMI_INTERRUPT_UNKNOWN", 0x84 }, + { "NMI_INTERRUPT_INST_ACTION_PT", 0x86 }, + { "ADVANCED_SYSASSERT", 0 }, +}; + +static const char *il4965_desc_lookup(u32 num) +{ + int i; + int max = ARRAY_SIZE(desc_lookup_text); + + if (num < max) + return desc_lookup_text[num]; + + max = ARRAY_SIZE(advanced_lookup) - 1; + for (i = 0; i < max; i++) { + if (advanced_lookup[i].num == num) + break; + } + return advanced_lookup[i].name; +} + +#define ERROR_START_OFFSET (1 * sizeof(u32)) +#define ERROR_ELEM_SIZE (7 * sizeof(u32)) + +void il4965_dump_nic_error_log(struct il_priv *il) +{ + u32 data2, line; + u32 desc, time, count, base, data1; + u32 blink1, blink2, ilink1, ilink2; + u32 pc, hcmd; + + if (il->ucode_type == UCODE_INIT) { + base = le32_to_cpu(il->card_alive_init.error_event_table_ptr); + } else { + base = le32_to_cpu(il->card_alive.error_event_table_ptr); + } + + if (!il->cfg->ops->lib->is_valid_rtc_data_addr(base)) { + IL_ERR( + "Not valid error log pointer 0x%08X for %s uCode\n", + base, (il->ucode_type == UCODE_INIT) ? "Init" : "RT"); + return; + } + + count = il_read_targ_mem(il, base); + + if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { + IL_ERR("Start IWL Error Log Dump:\n"); + IL_ERR("Status: 0x%08lX, count: %d\n", + il->status, count); + } + + desc = il_read_targ_mem(il, base + 1 * sizeof(u32)); + il->isr_stats.err_code = desc; + pc = il_read_targ_mem(il, base + 2 * sizeof(u32)); + blink1 = il_read_targ_mem(il, base + 3 * sizeof(u32)); + blink2 = il_read_targ_mem(il, base + 4 * sizeof(u32)); + ilink1 = il_read_targ_mem(il, base + 5 * sizeof(u32)); + ilink2 = il_read_targ_mem(il, base + 6 * sizeof(u32)); + data1 = il_read_targ_mem(il, base + 7 * sizeof(u32)); + data2 = il_read_targ_mem(il, base + 8 * sizeof(u32)); + line = il_read_targ_mem(il, base + 9 * sizeof(u32)); + time = il_read_targ_mem(il, base + 11 * sizeof(u32)); + hcmd = il_read_targ_mem(il, base + 22 * sizeof(u32)); + + IL_ERR("Desc Time " + "data1 data2 line\n"); + IL_ERR("%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n", + il4965_desc_lookup(desc), desc, time, data1, data2, line); + IL_ERR("pc blink1 blink2 ilink1 ilink2 hcmd\n"); + IL_ERR("0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n", + pc, blink1, blink2, ilink1, ilink2, hcmd); +} + +static void il4965_rf_kill_ct_config(struct il_priv *il) +{ + struct il_ct_kill_config cmd; + unsigned long flags; + int ret = 0; + + spin_lock_irqsave(&il->lock, flags); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, + CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); + spin_unlock_irqrestore(&il->lock, flags); + + cmd.critical_temperature_R = + cpu_to_le32(il->hw_params.ct_kill_threshold); + + ret = il_send_cmd_pdu(il, REPLY_CT_KILL_CONFIG_CMD, + sizeof(cmd), &cmd); + if (ret) + IL_ERR("REPLY_CT_KILL_CONFIG_CMD failed\n"); + else + D_INFO("REPLY_CT_KILL_CONFIG_CMD " + "succeeded, " + "critical temperature is %d\n", + il->hw_params.ct_kill_threshold); +} + +static const s8 default_queue_to_tx_fifo[] = { + IL_TX_FIFO_VO, + IL_TX_FIFO_VI, + IL_TX_FIFO_BE, + IL_TX_FIFO_BK, + IL49_CMD_FIFO_NUM, + IL_TX_FIFO_UNUSED, + IL_TX_FIFO_UNUSED, +}; + +static int il4965_alive_notify(struct il_priv *il) +{ + u32 a; + unsigned long flags; + int i, chan; + u32 reg_val; + + spin_lock_irqsave(&il->lock, flags); + + /* Clear 4965's internal Tx Scheduler data base */ + il->scd_base_addr = il_rd_prph(il, + IL49_SCD_SRAM_BASE_ADDR); + a = il->scd_base_addr + IL49_SCD_CONTEXT_DATA_OFFSET; + for (; a < il->scd_base_addr + IL49_SCD_TX_STTS_BITMAP_OFFSET; a += 4) + il_write_targ_mem(il, a, 0); + for (; a < il->scd_base_addr + IL49_SCD_TRANSLATE_TBL_OFFSET; a += 4) + il_write_targ_mem(il, a, 0); + for (; a < il->scd_base_addr + + IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(il->hw_params.max_txq_num); a += 4) + il_write_targ_mem(il, a, 0); + + /* Tel 4965 where to find Tx byte count tables */ + il_wr_prph(il, IL49_SCD_DRAM_BASE_ADDR, + il->scd_bc_tbls.dma >> 10); + + /* Enable DMA channel */ + for (chan = 0; chan < FH49_TCSR_CHNL_NUM ; chan++) + il_wr(il, + FH_TCSR_CHNL_TX_CONFIG_REG(chan), + FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | + FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE); + + /* Update FH chicken bits */ + reg_val = il_rd(il, FH_TX_CHICKEN_BITS_REG); + il_wr(il, FH_TX_CHICKEN_BITS_REG, + reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); + + /* Disable chain mode for all queues */ + il_wr_prph(il, IL49_SCD_QUEUECHAIN_SEL, 0); + + /* Initialize each Tx queue (including the command queue) */ + for (i = 0; i < il->hw_params.max_txq_num; i++) { + + /* TFD circular buffer read/write idxes */ + il_wr_prph(il, IL49_SCD_QUEUE_RDPTR(i), 0); + il_wr(il, HBUS_TARG_WRPTR, 0 | (i << 8)); + + /* Max Tx Window size for Scheduler-ACK mode */ + il_write_targ_mem(il, il->scd_base_addr + + IL49_SCD_CONTEXT_QUEUE_OFFSET(i), + (SCD_WIN_SIZE << + IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & + IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); + + /* Frame limit */ + il_write_targ_mem(il, il->scd_base_addr + + IL49_SCD_CONTEXT_QUEUE_OFFSET(i) + + sizeof(u32), + (SCD_FRAME_LIMIT << + IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) & + IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); + + } + il_wr_prph(il, IL49_SCD_INTERRUPT_MASK, + (1 << il->hw_params.max_txq_num) - 1); + + /* Activate all Tx DMA/FIFO channels */ + il4965_txq_set_sched(il, IL_MASK(0, 6)); + + il4965_set_wr_ptrs(il, IL_DEFAULT_CMD_QUEUE_NUM, 0); + + /* make sure all queue are not stopped */ + memset(&il->queue_stopped[0], 0, sizeof(il->queue_stopped)); + for (i = 0; i < 4; i++) + atomic_set(&il->queue_stop_count[i], 0); + + /* reset to 0 to enable all the queue first */ + il->txq_ctx_active_msk = 0; + /* Map each Tx/cmd queue to its corresponding fifo */ + BUILD_BUG_ON(ARRAY_SIZE(default_queue_to_tx_fifo) != 7); + + for (i = 0; i < ARRAY_SIZE(default_queue_to_tx_fifo); i++) { + int ac = default_queue_to_tx_fifo[i]; + + il_txq_ctx_activate(il, i); + + if (ac == IL_TX_FIFO_UNUSED) + continue; + + il4965_tx_queue_set_status(il, &il->txq[i], ac, 0); + } + + spin_unlock_irqrestore(&il->lock, flags); + + return 0; +} + +/** + * il4965_alive_start - called after REPLY_ALIVE notification received + * from protocol/runtime uCode (initialization uCode's + * Alive gets handled by il_init_alive_start()). + */ +static void il4965_alive_start(struct il_priv *il) +{ + int ret = 0; + struct il_rxon_context *ctx = &il->ctx; + + D_INFO("Runtime Alive received.\n"); + + if (il->card_alive.is_valid != UCODE_VALID_OK) { + /* We had an error bringing up the hardware, so take it + * all the way back down so we can try again */ + D_INFO("Alive failed.\n"); + goto restart; + } + + /* Initialize uCode has loaded Runtime uCode ... verify inst image. + * This is a paranoid check, because we would not have gotten the + * "runtime" alive if code weren't properly loaded. */ + if (il4965_verify_ucode(il)) { + /* Runtime instruction load was bad; + * take it all the way back down so we can try again */ + D_INFO("Bad runtime uCode load.\n"); + goto restart; + } + + ret = il4965_alive_notify(il); + if (ret) { + IL_WARN( + "Could not complete ALIVE transition [ntf]: %d\n", ret); + goto restart; + } + + + /* After the ALIVE response, we can send host commands to the uCode */ + set_bit(STATUS_ALIVE, &il->status); + + /* Enable watchdog to monitor the driver tx queues */ + il_setup_watchdog(il); + + if (il_is_rfkill(il)) + return; + + ieee80211_wake_queues(il->hw); + + il->active_rate = RATES_MASK; + + if (il_is_associated_ctx(ctx)) { + struct il_rxon_cmd *active_rxon = + (struct il_rxon_cmd *)&ctx->active; + /* apply any changes in staging */ + ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; + active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; + } else { + /* Initialize our rx_config data */ + il_connection_init_rx_config(il, &il->ctx); + + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); + } + + /* Configure bluetooth coexistence if enabled */ + il_send_bt_config(il); + + il4965_reset_run_time_calib(il); + + set_bit(STATUS_READY, &il->status); + + /* Configure the adapter for unassociated operation */ + il_commit_rxon(il, ctx); + + /* At this point, the NIC is initialized and operational */ + il4965_rf_kill_ct_config(il); + + D_INFO("ALIVE processing complete.\n"); + wake_up(&il->wait_command_queue); + + il_power_update_mode(il, true); + D_INFO("Updated power mode\n"); + + return; + + restart: + queue_work(il->workqueue, &il->restart); +} + +static void il4965_cancel_deferred_work(struct il_priv *il); + +static void __il4965_down(struct il_priv *il) +{ + unsigned long flags; + int exit_pending; + + D_INFO(DRV_NAME " is going down\n"); + + il_scan_cancel_timeout(il, 200); + + exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &il->status); + + /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set + * to prevent rearm timer */ + del_timer_sync(&il->watchdog); + + il_clear_ucode_stations(il, NULL); + il_dealloc_bcast_stations(il); + il_clear_driver_stations(il); + + /* Unblock any waiting calls */ + wake_up_all(&il->wait_command_queue); + + /* Wipe out the EXIT_PENDING status bit if we are not actually + * exiting the module */ + if (!exit_pending) + clear_bit(STATUS_EXIT_PENDING, &il->status); + + /* stop and reset the on-board processor */ + _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + + /* tell the device to stop sending interrupts */ + spin_lock_irqsave(&il->lock, flags); + il_disable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); + il4965_synchronize_irq(il); + + if (il->mac80211_registered) + ieee80211_stop_queues(il->hw); + + /* If we have not previously called il_init() then + * clear all bits but the RF Kill bit and return */ + if (!il_is_init(il)) { + il->status = test_bit(STATUS_RF_KILL_HW, &il->status) << + STATUS_RF_KILL_HW | + test_bit(STATUS_GEO_CONFIGURED, &il->status) << + STATUS_GEO_CONFIGURED | + test_bit(STATUS_EXIT_PENDING, &il->status) << + STATUS_EXIT_PENDING; + goto exit; + } + + /* ...otherwise clear out all the status bits but the RF Kill + * bit and continue taking the NIC down. */ + il->status &= test_bit(STATUS_RF_KILL_HW, &il->status) << + STATUS_RF_KILL_HW | + test_bit(STATUS_GEO_CONFIGURED, &il->status) << + STATUS_GEO_CONFIGURED | + test_bit(STATUS_FW_ERROR, &il->status) << + STATUS_FW_ERROR | + test_bit(STATUS_EXIT_PENDING, &il->status) << + STATUS_EXIT_PENDING; + + il4965_txq_ctx_stop(il); + il4965_rxq_stop(il); + + /* Power-down device's busmaster DMA clocks */ + il_wr_prph(il, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); + udelay(5); + + /* Make sure (redundant) we've released our request to stay awake */ + il_clear_bit(il, CSR_GP_CNTRL, + CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); + + /* Stop the device, and put it in low power state */ + il_apm_stop(il); + + exit: + memset(&il->card_alive, 0, sizeof(struct il_alive_resp)); + + dev_kfree_skb(il->beacon_skb); + il->beacon_skb = NULL; + + /* clear out any free frames */ + il4965_clear_free_frames(il); +} + +static void il4965_down(struct il_priv *il) +{ + mutex_lock(&il->mutex); + __il4965_down(il); + mutex_unlock(&il->mutex); + + il4965_cancel_deferred_work(il); +} + +#define HW_READY_TIMEOUT (50) + +static int il4965_set_hw_ready(struct il_priv *il) +{ + int ret = 0; + + il_set_bit(il, CSR_HW_IF_CONFIG_REG, + CSR_HW_IF_CONFIG_REG_BIT_NIC_READY); + + /* See if we got it */ + ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, + CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, + CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, + HW_READY_TIMEOUT); + if (ret != -ETIMEDOUT) + il->hw_ready = true; + else + il->hw_ready = false; + + D_INFO("hardware %s\n", + (il->hw_ready == 1) ? "ready" : "not ready"); + return ret; +} + +static int il4965_prepare_card_hw(struct il_priv *il) +{ + int ret = 0; + + D_INFO("il4965_prepare_card_hw enter\n"); + + ret = il4965_set_hw_ready(il); + if (il->hw_ready) + return ret; + + /* If HW is not ready, prepare the conditions to check again */ + il_set_bit(il, CSR_HW_IF_CONFIG_REG, + CSR_HW_IF_CONFIG_REG_PREPARE); + + ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, + ~CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, + CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, 150000); + + /* HW should be ready by now, check again. */ + if (ret != -ETIMEDOUT) + il4965_set_hw_ready(il); + + return ret; +} + +#define MAX_HW_RESTARTS 5 + +static int __il4965_up(struct il_priv *il) +{ + int i; + int ret; + + if (test_bit(STATUS_EXIT_PENDING, &il->status)) { + IL_WARN("Exit pending; will not bring the NIC up\n"); + return -EIO; + } + + if (!il->ucode_data_backup.v_addr || !il->ucode_data.v_addr) { + IL_ERR("ucode not available for device bringup\n"); + return -EIO; + } + + ret = il4965_alloc_bcast_station(il, &il->ctx); + if (ret) { + il_dealloc_bcast_stations(il); + return ret; + } + + il4965_prepare_card_hw(il); + + if (!il->hw_ready) { + IL_WARN("Exit HW not ready\n"); + return -EIO; + } + + /* If platform's RF_KILL switch is NOT set to KILL */ + if (_il_rd(il, + CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) + clear_bit(STATUS_RF_KILL_HW, &il->status); + else + set_bit(STATUS_RF_KILL_HW, &il->status); + + if (il_is_rfkill(il)) { + wiphy_rfkill_set_hw_state(il->hw->wiphy, true); + + il_enable_interrupts(il); + IL_WARN("Radio disabled by HW RF Kill switch\n"); + return 0; + } + + _il_wr(il, CSR_INT, 0xFFFFFFFF); + + /* must be initialised before il_hw_nic_init */ + il->cmd_queue = IL_DEFAULT_CMD_QUEUE_NUM; + + ret = il4965_hw_nic_init(il); + if (ret) { + IL_ERR("Unable to init nic\n"); + return ret; + } + + /* make sure rfkill handshake bits are cleared */ + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, + CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); + + /* clear (again), then enable host interrupts */ + _il_wr(il, CSR_INT, 0xFFFFFFFF); + il_enable_interrupts(il); + + /* really make sure rfkill handshake bits are cleared */ + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); + + /* Copy original ucode data image from disk into backup cache. + * This will be used to initialize the on-board processor's + * data SRAM for a clean start when the runtime program first loads. */ + memcpy(il->ucode_data_backup.v_addr, il->ucode_data.v_addr, + il->ucode_data.len); + + for (i = 0; i < MAX_HW_RESTARTS; i++) { + + /* load bootstrap state machine, + * load bootstrap program into processor's memory, + * prepare to load the "initialize" uCode */ + ret = il->cfg->ops->lib->load_ucode(il); + + if (ret) { + IL_ERR("Unable to set up bootstrap uCode: %d\n", + ret); + continue; + } + + /* start card; "initialize" will load runtime ucode */ + il4965_nic_start(il); + + D_INFO(DRV_NAME " is coming up\n"); + + return 0; + } + + set_bit(STATUS_EXIT_PENDING, &il->status); + __il4965_down(il); + clear_bit(STATUS_EXIT_PENDING, &il->status); + + /* tried to restart and config the device for as long as our + * patience could withstand */ + IL_ERR("Unable to initialize device after %d attempts.\n", i); + return -EIO; +} + + +/***************************************************************************** + * + * Workqueue callbacks + * + *****************************************************************************/ + +static void il4965_bg_init_alive_start(struct work_struct *data) +{ + struct il_priv *il = + container_of(data, struct il_priv, init_alive_start.work); + + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + goto out; + + il->cfg->ops->lib->init_alive_start(il); +out: + mutex_unlock(&il->mutex); +} + +static void il4965_bg_alive_start(struct work_struct *data) +{ + struct il_priv *il = + container_of(data, struct il_priv, alive_start.work); + + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + goto out; + + il4965_alive_start(il); +out: + mutex_unlock(&il->mutex); +} + +static void il4965_bg_run_time_calib_work(struct work_struct *work) +{ + struct il_priv *il = container_of(work, struct il_priv, + run_time_calib_work); + + mutex_lock(&il->mutex); + + if (test_bit(STATUS_EXIT_PENDING, &il->status) || + test_bit(STATUS_SCANNING, &il->status)) { + mutex_unlock(&il->mutex); + return; + } + + if (il->start_calib) { + il4965_chain_noise_calibration(il, + (void *)&il->_4965.stats); + il4965_sensitivity_calibration(il, + (void *)&il->_4965.stats); + } + + mutex_unlock(&il->mutex); +} + +static void il4965_bg_restart(struct work_struct *data) +{ + struct il_priv *il = container_of(data, struct il_priv, restart); + + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + return; + + if (test_and_clear_bit(STATUS_FW_ERROR, &il->status)) { + mutex_lock(&il->mutex); + il->ctx.vif = NULL; + il->is_open = 0; + + __il4965_down(il); + + mutex_unlock(&il->mutex); + il4965_cancel_deferred_work(il); + ieee80211_restart_hw(il->hw); + } else { + il4965_down(il); + + mutex_lock(&il->mutex); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) { + mutex_unlock(&il->mutex); + return; + } + + __il4965_up(il); + mutex_unlock(&il->mutex); + } +} + +static void il4965_bg_rx_replenish(struct work_struct *data) +{ + struct il_priv *il = + container_of(data, struct il_priv, rx_replenish); + + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + return; + + mutex_lock(&il->mutex); + il4965_rx_replenish(il); + mutex_unlock(&il->mutex); +} + +/***************************************************************************** + * + * mac80211 entry point functions + * + *****************************************************************************/ + +#define UCODE_READY_TIMEOUT (4 * HZ) + +/* + * Not a mac80211 entry point function, but it fits in with all the + * other mac80211 functions grouped here. + */ +static int il4965_mac_setup_register(struct il_priv *il, + u32 max_probe_length) +{ + int ret; + struct ieee80211_hw *hw = il->hw; + + hw->rate_control_algorithm = "iwl-4965-rs"; + + /* Tell mac80211 our characteristics */ + hw->flags = IEEE80211_HW_SIGNAL_DBM | + IEEE80211_HW_AMPDU_AGGREGATION | + IEEE80211_HW_NEED_DTIM_PERIOD | + IEEE80211_HW_SPECTRUM_MGMT | + IEEE80211_HW_REPORTS_TX_ACK_STATUS; + + if (il->cfg->sku & IL_SKU_N) + hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | + IEEE80211_HW_SUPPORTS_STATIC_SMPS; + + hw->sta_data_size = sizeof(struct il_station_priv); + hw->vif_data_size = sizeof(struct il_vif_priv); + + hw->wiphy->interface_modes |= il->ctx.interface_modes; + hw->wiphy->interface_modes |= il->ctx.exclusive_interface_modes; + + hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | + WIPHY_FLAG_DISABLE_BEACON_HINTS; + + /* + * For now, disable PS by default because it affects + * RX performance significantly. + */ + hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; + + hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; + /* we create the 802.11 header and a zero-length SSID element */ + hw->wiphy->max_scan_ie_len = max_probe_length - 24 - 2; + + /* Default value; 4 EDCA QOS priorities */ + hw->queues = 4; + + hw->max_listen_interval = IL_CONN_MAX_LISTEN_INTERVAL; + + if (il->bands[IEEE80211_BAND_2GHZ].n_channels) + il->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = + &il->bands[IEEE80211_BAND_2GHZ]; + if (il->bands[IEEE80211_BAND_5GHZ].n_channels) + il->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = + &il->bands[IEEE80211_BAND_5GHZ]; + + il_leds_init(il); + + ret = ieee80211_register_hw(il->hw); + if (ret) { + IL_ERR("Failed to register hw (error %d)\n", ret); + return ret; + } + il->mac80211_registered = 1; + + return 0; +} + + +int il4965_mac_start(struct ieee80211_hw *hw) +{ + struct il_priv *il = hw->priv; + int ret; + + D_MAC80211("enter\n"); + + /* we should be verifying the device is ready to be opened */ + mutex_lock(&il->mutex); + ret = __il4965_up(il); + mutex_unlock(&il->mutex); + + if (ret) + return ret; + + if (il_is_rfkill(il)) + goto out; + + D_INFO("Start UP work done.\n"); + + /* Wait for START_ALIVE from Run Time ucode. Otherwise callbacks from + * mac80211 will not be run successfully. */ + ret = wait_event_timeout(il->wait_command_queue, + test_bit(STATUS_READY, &il->status), + UCODE_READY_TIMEOUT); + if (!ret) { + if (!test_bit(STATUS_READY, &il->status)) { + IL_ERR("START_ALIVE timeout after %dms.\n", + jiffies_to_msecs(UCODE_READY_TIMEOUT)); + return -ETIMEDOUT; + } + } + + il4965_led_enable(il); + +out: + il->is_open = 1; + D_MAC80211("leave\n"); + return 0; +} + +void il4965_mac_stop(struct ieee80211_hw *hw) +{ + struct il_priv *il = hw->priv; + + D_MAC80211("enter\n"); + + if (!il->is_open) + return; + + il->is_open = 0; + + il4965_down(il); + + flush_workqueue(il->workqueue); + + /* User space software may expect getting rfkill changes + * even if interface is down */ + _il_wr(il, CSR_INT, 0xFFFFFFFF); + il_enable_rfkill_int(il); + + D_MAC80211("leave\n"); +} + +void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) +{ + struct il_priv *il = hw->priv; + + D_MACDUMP("enter\n"); + + D_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, + ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); + + if (il4965_tx_skb(il, skb)) + dev_kfree_skb_any(skb); + + D_MACDUMP("leave\n"); +} + +void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_key_conf *keyconf, + struct ieee80211_sta *sta, + u32 iv32, u16 *phase1key) +{ + struct il_priv *il = hw->priv; + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; + + D_MAC80211("enter\n"); + + il4965_update_tkip_key(il, vif_priv->ctx, keyconf, sta, + iv32, phase1key); + + D_MAC80211("leave\n"); +} + +int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, + struct ieee80211_vif *vif, struct ieee80211_sta *sta, + struct ieee80211_key_conf *key) +{ + struct il_priv *il = hw->priv; + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; + struct il_rxon_context *ctx = vif_priv->ctx; + int ret; + u8 sta_id; + bool is_default_wep_key = false; + + D_MAC80211("enter\n"); + + if (il->cfg->mod_params->sw_crypto) { + D_MAC80211("leave - hwcrypto disabled\n"); + return -EOPNOTSUPP; + } + + sta_id = il_sta_id_or_broadcast(il, vif_priv->ctx, sta); + if (sta_id == IL_INVALID_STATION) + return -EINVAL; + + mutex_lock(&il->mutex); + il_scan_cancel_timeout(il, 100); + + /* + * If we are getting WEP group key and we didn't receive any key mapping + * so far, we are in legacy wep mode (group key only), otherwise we are + * in 1X mode. + * In legacy wep mode, we use another host command to the uCode. + */ + if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || + key->cipher == WLAN_CIPHER_SUITE_WEP104) && + !sta) { + if (cmd == SET_KEY) + is_default_wep_key = !ctx->key_mapping_keys; + else + is_default_wep_key = + (key->hw_key_idx == HW_KEY_DEFAULT); + } + + switch (cmd) { + case SET_KEY: + if (is_default_wep_key) + ret = il4965_set_default_wep_key(il, + vif_priv->ctx, key); + else + ret = il4965_set_dynamic_key(il, vif_priv->ctx, + key, sta_id); + + D_MAC80211("enable hwcrypto key\n"); + break; + case DISABLE_KEY: + if (is_default_wep_key) + ret = il4965_remove_default_wep_key(il, ctx, key); + else + ret = il4965_remove_dynamic_key(il, ctx, + key, sta_id); + + D_MAC80211("disable hwcrypto key\n"); + break; + default: + ret = -EINVAL; + } + + mutex_unlock(&il->mutex); + D_MAC80211("leave\n"); + + return ret; +} + +int il4965_mac_ampdu_action(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + enum ieee80211_ampdu_mlme_action action, + struct ieee80211_sta *sta, u16 tid, u16 *ssn, + u8 buf_size) +{ + struct il_priv *il = hw->priv; + int ret = -EINVAL; + + D_HT("A-MPDU action on addr %pM tid %d\n", + sta->addr, tid); + + if (!(il->cfg->sku & IL_SKU_N)) + return -EACCES; + + mutex_lock(&il->mutex); + + switch (action) { + case IEEE80211_AMPDU_RX_START: + D_HT("start Rx\n"); + ret = il4965_sta_rx_agg_start(il, sta, tid, *ssn); + break; + case IEEE80211_AMPDU_RX_STOP: + D_HT("stop Rx\n"); + ret = il4965_sta_rx_agg_stop(il, sta, tid); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + ret = 0; + break; + case IEEE80211_AMPDU_TX_START: + D_HT("start Tx\n"); + ret = il4965_tx_agg_start(il, vif, sta, tid, ssn); + break; + case IEEE80211_AMPDU_TX_STOP: + D_HT("stop Tx\n"); + ret = il4965_tx_agg_stop(il, vif, sta, tid); + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + ret = 0; + break; + case IEEE80211_AMPDU_TX_OPERATIONAL: + ret = 0; + break; + } + mutex_unlock(&il->mutex); + + return ret; +} + +int il4965_mac_sta_add(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta) +{ + struct il_priv *il = hw->priv; + struct il_station_priv *sta_priv = (void *)sta->drv_priv; + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; + bool is_ap = vif->type == NL80211_IFTYPE_STATION; + int ret; + u8 sta_id; + + D_INFO("received request to add station %pM\n", + sta->addr); + mutex_lock(&il->mutex); + D_INFO("proceeding to add station %pM\n", + sta->addr); + sta_priv->common.sta_id = IL_INVALID_STATION; + + atomic_set(&sta_priv->pending_frames, 0); + + ret = il_add_station_common(il, vif_priv->ctx, sta->addr, + is_ap, sta, &sta_id); + if (ret) { + IL_ERR("Unable to add station %pM (%d)\n", + sta->addr, ret); + /* Should we return success if return code is EEXIST ? */ + mutex_unlock(&il->mutex); + return ret; + } + + sta_priv->common.sta_id = sta_id; + + /* Initialize rate scaling */ + D_INFO("Initializing rate scaling for station %pM\n", + sta->addr); + il4965_rs_rate_init(il, sta, sta_id); + mutex_unlock(&il->mutex); + + return 0; +} + +void il4965_mac_channel_switch(struct ieee80211_hw *hw, + struct ieee80211_channel_switch *ch_switch) +{ + struct il_priv *il = hw->priv; + const struct il_channel_info *ch_info; + struct ieee80211_conf *conf = &hw->conf; + struct ieee80211_channel *channel = ch_switch->channel; + struct il_ht_config *ht_conf = &il->current_ht_config; + + struct il_rxon_context *ctx = &il->ctx; + u16 ch; + + D_MAC80211("enter\n"); + + mutex_lock(&il->mutex); + + if (il_is_rfkill(il)) + goto out; + + if (test_bit(STATUS_EXIT_PENDING, &il->status) || + test_bit(STATUS_SCANNING, &il->status) || + test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status)) + goto out; + + if (!il_is_associated_ctx(ctx)) + goto out; + + if (!il->cfg->ops->lib->set_channel_switch) + goto out; + + ch = channel->hw_value; + if (le16_to_cpu(ctx->active.channel) == ch) + goto out; + + ch_info = il_get_channel_info(il, channel->band, ch); + if (!il_is_channel_valid(ch_info)) { + D_MAC80211("invalid channel\n"); + goto out; + } + + spin_lock_irq(&il->lock); + + il->current_ht_config.smps = conf->smps_mode; + + /* Configure HT40 channels */ + ctx->ht.enabled = conf_is_ht(conf); + if (ctx->ht.enabled) { + if (conf_is_ht40_minus(conf)) { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_BELOW; + ctx->ht.is_40mhz = true; + } else if (conf_is_ht40_plus(conf)) { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_ABOVE; + ctx->ht.is_40mhz = true; + } else { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_NONE; + ctx->ht.is_40mhz = false; + } + } else + ctx->ht.is_40mhz = false; + + if ((le16_to_cpu(ctx->staging.channel) != ch)) + ctx->staging.flags = 0; + + il_set_rxon_channel(il, channel, ctx); + il_set_rxon_ht(il, ht_conf); + il_set_flags_for_band(il, ctx, channel->band, ctx->vif); + + spin_unlock_irq(&il->lock); + + il_set_rate(il); + /* + * at this point, staging_rxon has the + * configuration for channel switch + */ + set_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status); + il->switch_channel = cpu_to_le16(ch); + if (il->cfg->ops->lib->set_channel_switch(il, ch_switch)) { + clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status); + il->switch_channel = 0; + ieee80211_chswitch_done(ctx->vif, false); + } + +out: + mutex_unlock(&il->mutex); + D_MAC80211("leave\n"); +} + +void il4965_configure_filter(struct ieee80211_hw *hw, + unsigned int changed_flags, + unsigned int *total_flags, + u64 multicast) +{ + struct il_priv *il = hw->priv; + __le32 filter_or = 0, filter_nand = 0; + +#define CHK(test, flag) do { \ + if (*total_flags & (test)) \ + filter_or |= (flag); \ + else \ + filter_nand |= (flag); \ + } while (0) + + D_MAC80211("Enter: changed: 0x%x, total: 0x%x\n", + changed_flags, *total_flags); + + CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); + /* Setting _just_ RXON_FILTER_CTL2HOST_MSK causes FH errors */ + CHK(FIF_CONTROL, RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_PROMISC_MSK); + CHK(FIF_BCN_PRBRESP_PROMISC, RXON_FILTER_BCON_AWARE_MSK); + +#undef CHK + + mutex_lock(&il->mutex); + + il->ctx.staging.filter_flags &= ~filter_nand; + il->ctx.staging.filter_flags |= filter_or; + + /* + * Not committing directly because hardware can perform a scan, + * but we'll eventually commit the filter flags change anyway. + */ + + mutex_unlock(&il->mutex); + + /* + * Receiving all multicast frames is always enabled by the + * default flags setup in il_connection_init_rx_config() + * since we currently do not support programming multicast + * filters into the device. + */ + *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | + FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; +} + +/***************************************************************************** + * + * driver setup and teardown + * + *****************************************************************************/ + +static void il4965_bg_txpower_work(struct work_struct *work) +{ + struct il_priv *il = container_of(work, struct il_priv, + txpower_work); + + mutex_lock(&il->mutex); + + /* If a scan happened to start before we got here + * then just return; the stats notification will + * kick off another scheduled work to compensate for + * any temperature delta we missed here. */ + if (test_bit(STATUS_EXIT_PENDING, &il->status) || + test_bit(STATUS_SCANNING, &il->status)) + goto out; + + /* Regardless of if we are associated, we must reconfigure the + * TX power since frames can be sent on non-radar channels while + * not associated */ + il->cfg->ops->lib->send_tx_power(il); + + /* Update last_temperature to keep is_calib_needed from running + * when it isn't needed... */ + il->last_temperature = il->temperature; +out: + mutex_unlock(&il->mutex); +} + +static void il4965_setup_deferred_work(struct il_priv *il) +{ + il->workqueue = create_singlethread_workqueue(DRV_NAME); + + init_waitqueue_head(&il->wait_command_queue); + + INIT_WORK(&il->restart, il4965_bg_restart); + INIT_WORK(&il->rx_replenish, il4965_bg_rx_replenish); + INIT_WORK(&il->run_time_calib_work, il4965_bg_run_time_calib_work); + INIT_DELAYED_WORK(&il->init_alive_start, il4965_bg_init_alive_start); + INIT_DELAYED_WORK(&il->alive_start, il4965_bg_alive_start); + + il_setup_scan_deferred_work(il); + + INIT_WORK(&il->txpower_work, il4965_bg_txpower_work); + + init_timer(&il->stats_periodic); + il->stats_periodic.data = (unsigned long)il; + il->stats_periodic.function = il4965_bg_stats_periodic; + + init_timer(&il->watchdog); + il->watchdog.data = (unsigned long)il; + il->watchdog.function = il_bg_watchdog; + + tasklet_init(&il->irq_tasklet, (void (*)(unsigned long)) + il4965_irq_tasklet, (unsigned long)il); +} + +static void il4965_cancel_deferred_work(struct il_priv *il) +{ + cancel_work_sync(&il->txpower_work); + cancel_delayed_work_sync(&il->init_alive_start); + cancel_delayed_work(&il->alive_start); + cancel_work_sync(&il->run_time_calib_work); + + il_cancel_scan_deferred_work(il); + + del_timer_sync(&il->stats_periodic); +} + +static void il4965_init_hw_rates(struct il_priv *il, + struct ieee80211_rate *rates) +{ + int i; + + for (i = 0; i < RATE_COUNT_LEGACY; i++) { + rates[i].bitrate = il_rates[i].ieee * 5; + rates[i].hw_value = i; /* Rate scaling will work on idxes */ + rates[i].hw_value_short = i; + rates[i].flags = 0; + if ((i >= IL_FIRST_CCK_RATE) && (i <= IL_LAST_CCK_RATE)) { + /* + * If CCK != 1M then set short preamble rate flag. + */ + rates[i].flags |= + (il_rates[i].plcp == RATE_1M_PLCP) ? + 0 : IEEE80211_RATE_SHORT_PREAMBLE; + } + } +} +/* + * Acquire il->lock before calling this function ! + */ +void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx) +{ + il_wr(il, HBUS_TARG_WRPTR, + (idx & 0xff) | (txq_id << 8)); + il_wr_prph(il, IL49_SCD_QUEUE_RDPTR(txq_id), idx); +} + +void il4965_tx_queue_set_status(struct il_priv *il, + struct il_tx_queue *txq, + int tx_fifo_id, int scd_retry) +{ + int txq_id = txq->q.id; + + /* Find out whether to activate Tx queue */ + int active = test_bit(txq_id, &il->txq_ctx_active_msk) ? 1 : 0; + + /* Set up and activate */ + il_wr_prph(il, IL49_SCD_QUEUE_STATUS_BITS(txq_id), + (active << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | + (tx_fifo_id << IL49_SCD_QUEUE_STTS_REG_POS_TXF) | + (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_WSL) | + (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK) | + IL49_SCD_QUEUE_STTS_REG_MSK); + + txq->sched_retry = scd_retry; + + D_INFO("%s %s Queue %d on AC %d\n", + active ? "Activate" : "Deactivate", + scd_retry ? "BA" : "AC", txq_id, tx_fifo_id); +} + + +static int il4965_init_drv(struct il_priv *il) +{ + int ret; + + spin_lock_init(&il->sta_lock); + spin_lock_init(&il->hcmd_lock); + + INIT_LIST_HEAD(&il->free_frames); + + mutex_init(&il->mutex); + + il->ieee_channels = NULL; + il->ieee_rates = NULL; + il->band = IEEE80211_BAND_2GHZ; + + il->iw_mode = NL80211_IFTYPE_STATION; + il->current_ht_config.smps = IEEE80211_SMPS_STATIC; + il->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; + + /* initialize force reset */ + il->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; + + /* Choose which receivers/antennas to use */ + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, + &il->ctx); + + il_init_scan_params(il); + + ret = il_init_channel_map(il); + if (ret) { + IL_ERR("initializing regulatory failed: %d\n", ret); + goto err; + } + + ret = il_init_geos(il); + if (ret) { + IL_ERR("initializing geos failed: %d\n", ret); + goto err_free_channel_map; + } + il4965_init_hw_rates(il, il->ieee_rates); + + return 0; + +err_free_channel_map: + il_free_channel_map(il); +err: + return ret; +} + +static void il4965_uninit_drv(struct il_priv *il) +{ + il4965_calib_free_results(il); + il_free_geos(il); + il_free_channel_map(il); + kfree(il->scan_cmd); +} + +static void il4965_hw_detect(struct il_priv *il) +{ + il->hw_rev = _il_rd(il, CSR_HW_REV); + il->hw_wa_rev = _il_rd(il, CSR_HW_REV_WA_REG); + il->rev_id = il->pci_dev->revision; + D_INFO("HW Revision ID = 0x%X\n", il->rev_id); +} + +static int il4965_set_hw_params(struct il_priv *il) +{ + il->hw_params.max_rxq_size = RX_QUEUE_SIZE; + il->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; + if (il->cfg->mod_params->amsdu_size_8K) + il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_8K); + else + il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_4K); + + il->hw_params.max_beacon_itrvl = IL_MAX_UCODE_BEACON_INTERVAL; + + if (il->cfg->mod_params->disable_11n) + il->cfg->sku &= ~IL_SKU_N; + + /* Device-specific setup */ + return il->cfg->ops->lib->set_hw_params(il); +} + +static const u8 il4965_bss_ac_to_fifo[] = { + IL_TX_FIFO_VO, + IL_TX_FIFO_VI, + IL_TX_FIFO_BE, + IL_TX_FIFO_BK, +}; + +static const u8 il4965_bss_ac_to_queue[] = { + 0, 1, 2, 3, +}; + +static int +il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) +{ + int err = 0; + struct il_priv *il; + struct ieee80211_hw *hw; + struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data); + unsigned long flags; + u16 pci_cmd; + + /************************ + * 1. Allocating HW data + ************************/ + + hw = il_alloc_all(cfg); + if (!hw) { + err = -ENOMEM; + goto out; + } + il = hw->priv; + /* At this point both hw and il are allocated. */ + + il->ctx.ctxid = 0; + + il->ctx.always_active = true; + il->ctx.is_active = true; + il->ctx.rxon_cmd = REPLY_RXON; + il->ctx.rxon_timing_cmd = REPLY_RXON_TIMING; + il->ctx.rxon_assoc_cmd = REPLY_RXON_ASSOC; + il->ctx.qos_cmd = REPLY_QOS_PARAM; + il->ctx.ap_sta_id = IL_AP_ID; + il->ctx.wep_key_cmd = REPLY_WEPKEY; + il->ctx.ac_to_fifo = il4965_bss_ac_to_fifo; + il->ctx.ac_to_queue = il4965_bss_ac_to_queue; + il->ctx.exclusive_interface_modes = + BIT(NL80211_IFTYPE_ADHOC); + il->ctx.interface_modes = + BIT(NL80211_IFTYPE_STATION); + il->ctx.ap_devtype = RXON_DEV_TYPE_AP; + il->ctx.ibss_devtype = RXON_DEV_TYPE_IBSS; + il->ctx.station_devtype = RXON_DEV_TYPE_ESS; + il->ctx.unused_devtype = RXON_DEV_TYPE_ESS; + + SET_IEEE80211_DEV(hw, &pdev->dev); + + D_INFO("*** LOAD DRIVER ***\n"); + il->cfg = cfg; + il->pci_dev = pdev; + il->inta_mask = CSR_INI_SET_MASK; + + if (il_alloc_traffic_mem(il)) + IL_ERR("Not enough memory to generate traffic log\n"); + + /************************** + * 2. Initializing PCI bus + **************************/ + pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | + PCIE_LINK_STATE_CLKPM); + + if (pci_enable_device(pdev)) { + err = -ENODEV; + goto out_ieee80211_free_hw; + } + + pci_set_master(pdev); + + err = pci_set_dma_mask(pdev, DMA_BIT_MASK(36)); + if (!err) + err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(36)); + if (err) { + err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); + if (!err) + err = pci_set_consistent_dma_mask(pdev, + DMA_BIT_MASK(32)); + /* both attempts failed: */ + if (err) { + IL_WARN("No suitable DMA available.\n"); + goto out_pci_disable_device; + } + } + + err = pci_request_regions(pdev, DRV_NAME); + if (err) + goto out_pci_disable_device; + + pci_set_drvdata(pdev, il); + + + /*********************** + * 3. Read REV register + ***********************/ + il->hw_base = pci_iomap(pdev, 0, 0); + if (!il->hw_base) { + err = -ENODEV; + goto out_pci_release_regions; + } + + D_INFO("pci_resource_len = 0x%08llx\n", + (unsigned long long) pci_resource_len(pdev, 0)); + D_INFO("pci_resource_base = %p\n", il->hw_base); + + /* these spin locks will be used in apm_ops.init and EEPROM access + * we should init now + */ + spin_lock_init(&il->reg_lock); + spin_lock_init(&il->lock); + + /* + * stop and reset the on-board processor just in case it is in a + * strange state ... like being left stranded by a primary kernel + * and this is now the kdump kernel trying to start up + */ + _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); + + il4965_hw_detect(il); + IL_INFO("Detected %s, REV=0x%X\n", + il->cfg->name, il->hw_rev); + + /* We disable the RETRY_TIMEOUT register (0x41) to keep + * PCI Tx retries from interfering with C3 CPU state */ + pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); + + il4965_prepare_card_hw(il); + if (!il->hw_ready) { + IL_WARN("Failed, HW not ready\n"); + goto out_iounmap; + } + + /***************** + * 4. Read EEPROM + *****************/ + /* Read the EEPROM */ + err = il_eeprom_init(il); + if (err) { + IL_ERR("Unable to init EEPROM\n"); + goto out_iounmap; + } + err = il4965_eeprom_check_version(il); + if (err) + goto out_free_eeprom; + + if (err) + goto out_free_eeprom; + + /* extract MAC Address */ + il4965_eeprom_get_mac(il, il->addresses[0].addr); + D_INFO("MAC address: %pM\n", il->addresses[0].addr); + il->hw->wiphy->addresses = il->addresses; + il->hw->wiphy->n_addresses = 1; + + /************************ + * 5. Setup HW constants + ************************/ + if (il4965_set_hw_params(il)) { + IL_ERR("failed to set hw parameters\n"); + goto out_free_eeprom; + } + + /******************* + * 6. Setup il + *******************/ + + err = il4965_init_drv(il); + if (err) + goto out_free_eeprom; + /* At this point both hw and il are initialized. */ + + /******************** + * 7. Setup services + ********************/ + spin_lock_irqsave(&il->lock, flags); + il_disable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); + + pci_enable_msi(il->pci_dev); + + err = request_irq(il->pci_dev->irq, il_isr, + IRQF_SHARED, DRV_NAME, il); + if (err) { + IL_ERR("Error allocating IRQ %d\n", il->pci_dev->irq); + goto out_disable_msi; + } + + il4965_setup_deferred_work(il); + il4965_setup_rx_handlers(il); + + /********************************************* + * 8. Enable interrupts and read RFKILL state + *********************************************/ + + /* enable rfkill interrupt: hw bug w/a */ + pci_read_config_word(il->pci_dev, PCI_COMMAND, &pci_cmd); + if (pci_cmd & PCI_COMMAND_INTX_DISABLE) { + pci_cmd &= ~PCI_COMMAND_INTX_DISABLE; + pci_write_config_word(il->pci_dev, PCI_COMMAND, pci_cmd); + } + + il_enable_rfkill_int(il); + + /* If platform's RF_KILL switch is NOT set to KILL */ + if (_il_rd(il, CSR_GP_CNTRL) & + CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) + clear_bit(STATUS_RF_KILL_HW, &il->status); + else + set_bit(STATUS_RF_KILL_HW, &il->status); + + wiphy_rfkill_set_hw_state(il->hw->wiphy, + test_bit(STATUS_RF_KILL_HW, &il->status)); + + il_power_initialize(il); + + init_completion(&il->_4965.firmware_loading_complete); + + err = il4965_request_firmware(il, true); + if (err) + goto out_destroy_workqueue; + + return 0; + + out_destroy_workqueue: + destroy_workqueue(il->workqueue); + il->workqueue = NULL; + free_irq(il->pci_dev->irq, il); + out_disable_msi: + pci_disable_msi(il->pci_dev); + il4965_uninit_drv(il); + out_free_eeprom: + il_eeprom_free(il); + out_iounmap: + pci_iounmap(pdev, il->hw_base); + out_pci_release_regions: + pci_set_drvdata(pdev, NULL); + pci_release_regions(pdev); + out_pci_disable_device: + pci_disable_device(pdev); + out_ieee80211_free_hw: + il_free_traffic_mem(il); + ieee80211_free_hw(il->hw); + out: + return err; +} + +static void __devexit il4965_pci_remove(struct pci_dev *pdev) +{ + struct il_priv *il = pci_get_drvdata(pdev); + unsigned long flags; + + if (!il) + return; + + wait_for_completion(&il->_4965.firmware_loading_complete); + + D_INFO("*** UNLOAD DRIVER ***\n"); + + il_dbgfs_unregister(il); + sysfs_remove_group(&pdev->dev.kobj, &il_attribute_group); + + /* ieee80211_unregister_hw call wil cause il_mac_stop to + * to be called and il4965_down since we are removing the device + * we need to set STATUS_EXIT_PENDING bit. + */ + set_bit(STATUS_EXIT_PENDING, &il->status); + + il_leds_exit(il); + + if (il->mac80211_registered) { + ieee80211_unregister_hw(il->hw); + il->mac80211_registered = 0; + } else { + il4965_down(il); + } + + /* + * Make sure device is reset to low power before unloading driver. + * This may be redundant with il4965_down(), but there are paths to + * run il4965_down() without calling apm_ops.stop(), and there are + * paths to avoid running il4965_down() at all before leaving driver. + * This (inexpensive) call *makes sure* device is reset. + */ + il_apm_stop(il); + + /* make sure we flush any pending irq or + * tasklet for the driver + */ + spin_lock_irqsave(&il->lock, flags); + il_disable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); + + il4965_synchronize_irq(il); + + il4965_dealloc_ucode_pci(il); + + if (il->rxq.bd) + il4965_rx_queue_free(il, &il->rxq); + il4965_hw_txq_ctx_free(il); + + il_eeprom_free(il); + + + /*netif_stop_queue(dev); */ + flush_workqueue(il->workqueue); + + /* ieee80211_unregister_hw calls il_mac_stop, which flushes + * il->workqueue... so we can't take down the workqueue + * until now... */ + destroy_workqueue(il->workqueue); + il->workqueue = NULL; + il_free_traffic_mem(il); + + free_irq(il->pci_dev->irq, il); + pci_disable_msi(il->pci_dev); + pci_iounmap(pdev, il->hw_base); + pci_release_regions(pdev); + pci_disable_device(pdev); + pci_set_drvdata(pdev, NULL); + + il4965_uninit_drv(il); + + dev_kfree_skb(il->beacon_skb); + + ieee80211_free_hw(il->hw); +} + +/* + * Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask + * must be called under il->lock and mac access + */ +void il4965_txq_set_sched(struct il_priv *il, u32 mask) +{ + il_wr_prph(il, IL49_SCD_TXFACT, mask); +} + +/***************************************************************************** + * + * driver and module entry point + * + *****************************************************************************/ + +/* Hardware specific file defines the PCI IDs table for that hardware module */ +static DEFINE_PCI_DEVICE_TABLE(il4965_hw_card_ids) = { + {IL_PCI_DEVICE(0x4229, PCI_ANY_ID, il4965_cfg)}, + {IL_PCI_DEVICE(0x4230, PCI_ANY_ID, il4965_cfg)}, + {0} +}; +MODULE_DEVICE_TABLE(pci, il4965_hw_card_ids); + +static struct pci_driver il4965_driver = { + .name = DRV_NAME, + .id_table = il4965_hw_card_ids, + .probe = il4965_pci_probe, + .remove = __devexit_p(il4965_pci_remove), + .driver.pm = IL_LEGACY_PM_OPS, +}; + +static int __init il4965_init(void) +{ + + int ret; + pr_info(DRV_DESCRIPTION ", " DRV_VERSION "\n"); + pr_info(DRV_COPYRIGHT "\n"); + + ret = il4965_rate_control_register(); + if (ret) { + pr_err("Unable to register rate control algorithm: %d\n", ret); + return ret; + } + + ret = pci_register_driver(&il4965_driver); + if (ret) { + pr_err("Unable to initialize PCI module\n"); + goto error_register; + } + + return ret; + +error_register: + il4965_rate_control_unregister(); + return ret; +} + +static void __exit il4965_exit(void) +{ + pci_unregister_driver(&il4965_driver); + il4965_rate_control_unregister(); +} + +module_exit(il4965_exit); +module_init(il4965_init); + +#ifdef CONFIG_IWLEGACY_DEBUG +module_param_named(debug, il_debug_level, uint, S_IRUGO | S_IWUSR); +MODULE_PARM_DESC(debug, "debug output mask"); +#endif + +module_param_named(swcrypto, il4965_mod_params.sw_crypto, int, S_IRUGO); +MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])"); +module_param_named(queues_num, il4965_mod_params.num_of_queues, int, S_IRUGO); +MODULE_PARM_DESC(queues_num, "number of hw queues."); +module_param_named(11n_disable, il4965_mod_params.disable_11n, int, S_IRUGO); +MODULE_PARM_DESC(11n_disable, "disable 11n functionality"); +module_param_named(amsdu_size_8K, il4965_mod_params.amsdu_size_8K, + int, S_IRUGO); +MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size"); +module_param_named(fw_restart, il4965_mod_params.restart_fw, int, S_IRUGO); +MODULE_PARM_DESC(fw_restart, "restart firmware in case of error"); diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c new file mode 100644 index 000000000000..bdfb3a616fdc --- /dev/null +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -0,0 +1,2183 @@ +/****************************************************************************** + * + * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + *****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "iwl-eeprom.h" +#include "iwl-dev.h" +#include "iwl-core.h" +#include "iwl-io.h" +#include "iwl-helpers.h" +#include "iwl-4965-calib.h" +#include "iwl-sta.h" +#include "iwl-4965-led.h" +#include "iwl-4965.h" +#include "iwl-4965-debugfs.h" + +static int il4965_send_tx_power(struct il_priv *il); +static int il4965_hw_get_temperature(struct il_priv *il); + +/* Highest firmware API version supported */ +#define IL4965_UCODE_API_MAX 2 + +/* Lowest firmware API version supported */ +#define IL4965_UCODE_API_MIN 2 + +#define IL4965_FW_PRE "iwlwifi-4965-" +#define _IL4965_MODULE_FIRMWARE(api) IL4965_FW_PRE #api ".ucode" +#define IL4965_MODULE_FIRMWARE(api) _IL4965_MODULE_FIRMWARE(api) + +/* check contents of special bootstrap uCode SRAM */ +static int il4965_verify_bsm(struct il_priv *il) +{ + __le32 *image = il->ucode_boot.v_addr; + u32 len = il->ucode_boot.len; + u32 reg; + u32 val; + + D_INFO("Begin verify bsm\n"); + + /* verify BSM SRAM contents */ + val = il_rd_prph(il, BSM_WR_DWCOUNT_REG); + for (reg = BSM_SRAM_LOWER_BOUND; + reg < BSM_SRAM_LOWER_BOUND + len; + reg += sizeof(u32), image++) { + val = il_rd_prph(il, reg); + if (val != le32_to_cpu(*image)) { + IL_ERR("BSM uCode verification failed at " + "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", + BSM_SRAM_LOWER_BOUND, + reg - BSM_SRAM_LOWER_BOUND, len, + val, le32_to_cpu(*image)); + return -EIO; + } + } + + D_INFO("BSM bootstrap uCode image OK\n"); + + return 0; +} + +/** + * il4965_load_bsm - Load bootstrap instructions + * + * BSM operation: + * + * The Bootstrap State Machine (BSM) stores a short bootstrap uCode program + * in special SRAM that does not power down during RFKILL. When powering back + * up after power-saving sleeps (or during initial uCode load), the BSM loads + * the bootstrap program into the on-board processor, and starts it. + * + * The bootstrap program loads (via DMA) instructions and data for a new + * program from host DRAM locations indicated by the host driver in the + * BSM_DRAM_* registers. Once the new program is loaded, it starts + * automatically. + * + * When initializing the NIC, the host driver points the BSM to the + * "initialize" uCode image. This uCode sets up some internal data, then + * notifies host via "initialize alive" that it is complete. + * + * The host then replaces the BSM_DRAM_* pointer values to point to the + * normal runtime uCode instructions and a backup uCode data cache buffer + * (filled initially with starting data values for the on-board processor), + * then triggers the "initialize" uCode to load and launch the runtime uCode, + * which begins normal operation. + * + * When doing a power-save shutdown, runtime uCode saves data SRAM into + * the backup data cache in DRAM before SRAM is powered down. + * + * When powering back up, the BSM loads the bootstrap program. This reloads + * the runtime uCode instructions and the backup data cache into SRAM, + * and re-launches the runtime uCode from where it left off. + */ +static int il4965_load_bsm(struct il_priv *il) +{ + __le32 *image = il->ucode_boot.v_addr; + u32 len = il->ucode_boot.len; + dma_addr_t pinst; + dma_addr_t pdata; + u32 inst_len; + u32 data_len; + int i; + u32 done; + u32 reg_offset; + int ret; + + D_INFO("Begin load bsm\n"); + + il->ucode_type = UCODE_RT; + + /* make sure bootstrap program is no larger than BSM's SRAM size */ + if (len > IL49_MAX_BSM_SIZE) + return -EINVAL; + + /* Tell bootstrap uCode where to find the "Initialize" uCode + * in host DRAM ... host DRAM physical address bits 35:4 for 4965. + * NOTE: il_init_alive_start() will replace these values, + * after the "initialize" uCode has run, to point to + * runtime/protocol instructions and backup data cache. + */ + pinst = il->ucode_init.p_addr >> 4; + pdata = il->ucode_init_data.p_addr >> 4; + inst_len = il->ucode_init.len; + data_len = il->ucode_init_data.len; + + il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); + il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); + il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); + il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); + + /* Fill BSM memory with bootstrap instructions */ + for (reg_offset = BSM_SRAM_LOWER_BOUND; + reg_offset < BSM_SRAM_LOWER_BOUND + len; + reg_offset += sizeof(u32), image++) + _il_wr_prph(il, reg_offset, le32_to_cpu(*image)); + + ret = il4965_verify_bsm(il); + if (ret) + return ret; + + /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ + il_wr_prph(il, BSM_WR_MEM_SRC_REG, 0x0); + il_wr_prph(il, + BSM_WR_MEM_DST_REG, IL49_RTC_INST_LOWER_BOUND); + il_wr_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); + + /* Load bootstrap code into instruction SRAM now, + * to prepare to load "initialize" uCode */ + il_wr_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START); + + /* Wait for load of bootstrap uCode to finish */ + for (i = 0; i < 100; i++) { + done = il_rd_prph(il, BSM_WR_CTRL_REG); + if (!(done & BSM_WR_CTRL_REG_BIT_START)) + break; + udelay(10); + } + if (i < 100) + D_INFO("BSM write complete, poll %d iterations\n", i); + else { + IL_ERR("BSM write did not complete!\n"); + return -EIO; + } + + /* Enable future boot loads whenever power management unit triggers it + * (e.g. when powering back up after power-save shutdown) */ + il_wr_prph(il, + BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN); + + + return 0; +} + +/** + * il4965_set_ucode_ptrs - Set uCode address location + * + * Tell initialization uCode where to find runtime uCode. + * + * BSM registers initially contain pointers to initialization uCode. + * We need to replace them to load runtime uCode inst and data, + * and to save runtime data when powering down. + */ +static int il4965_set_ucode_ptrs(struct il_priv *il) +{ + dma_addr_t pinst; + dma_addr_t pdata; + int ret = 0; + + /* bits 35:4 for 4965 */ + pinst = il->ucode_code.p_addr >> 4; + pdata = il->ucode_data_backup.p_addr >> 4; + + /* Tell bootstrap uCode where to find image to load */ + il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); + il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); + il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, + il->ucode_data.len); + + /* Inst byte count must be last to set up, bit 31 signals uCode + * that all new ptr/size info is in place */ + il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, + il->ucode_code.len | BSM_DRAM_INST_LOAD); + D_INFO("Runtime uCode pointers are set.\n"); + + return ret; +} + +/** + * il4965_init_alive_start - Called after REPLY_ALIVE notification received + * + * Called after REPLY_ALIVE notification received from "initialize" uCode. + * + * The 4965 "initialize" ALIVE reply contains calibration data for: + * Voltage, temperature, and MIMO tx gain correction, now stored in il + * (3945 does not contain this data). + * + * Tell "initialize" uCode to go ahead and load the runtime uCode. +*/ +static void il4965_init_alive_start(struct il_priv *il) +{ + /* Bootstrap uCode has loaded initialize uCode ... verify inst image. + * This is a paranoid check, because we would not have gotten the + * "initialize" alive if code weren't properly loaded. */ + if (il4965_verify_ucode(il)) { + /* Runtime instruction load was bad; + * take it all the way back down so we can try again */ + D_INFO("Bad \"initialize\" uCode load.\n"); + goto restart; + } + + /* Calculate temperature */ + il->temperature = il4965_hw_get_temperature(il); + + /* Send pointers to protocol/runtime uCode image ... init code will + * load and launch runtime uCode, which will send us another "Alive" + * notification. */ + D_INFO("Initialization Alive received.\n"); + if (il4965_set_ucode_ptrs(il)) { + /* Runtime instruction load won't happen; + * take it all the way back down so we can try again */ + D_INFO("Couldn't set up uCode pointers.\n"); + goto restart; + } + return; + +restart: + queue_work(il->workqueue, &il->restart); +} + +static bool iw4965_is_ht40_channel(__le32 rxon_flags) +{ + int chan_mod = le32_to_cpu(rxon_flags & RXON_FLG_CHANNEL_MODE_MSK) + >> RXON_FLG_CHANNEL_MODE_POS; + return (chan_mod == CHANNEL_MODE_PURE_40 || + chan_mod == CHANNEL_MODE_MIXED); +} + +static void il4965_nic_config(struct il_priv *il) +{ + unsigned long flags; + u16 radio_cfg; + + spin_lock_irqsave(&il->lock, flags); + + radio_cfg = il_eeprom_query16(il, EEPROM_RADIO_CONFIG); + + /* write radio config values to register */ + if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) == EEPROM_4965_RF_CFG_TYPE_MAX) + il_set_bit(il, CSR_HW_IF_CONFIG_REG, + EEPROM_RF_CFG_TYPE_MSK(radio_cfg) | + EEPROM_RF_CFG_STEP_MSK(radio_cfg) | + EEPROM_RF_CFG_DASH_MSK(radio_cfg)); + + /* set CSR_HW_CONFIG_REG for uCode use */ + il_set_bit(il, CSR_HW_IF_CONFIG_REG, + CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | + CSR_HW_IF_CONFIG_REG_BIT_MAC_SI); + + il->calib_info = (struct il_eeprom_calib_info *) + il_eeprom_query_addr(il, + EEPROM_4965_CALIB_TXPOWER_OFFSET); + + spin_unlock_irqrestore(&il->lock, flags); +} + +/* Reset differential Rx gains in NIC to prepare for chain noise calibration. + * Called after every association, but this runs only once! + * ... once chain noise is calibrated the first time, it's good forever. */ +static void il4965_chain_noise_reset(struct il_priv *il) +{ + struct il_chain_noise_data *data = &(il->chain_noise_data); + + if (data->state == IL_CHAIN_NOISE_ALIVE && + il_is_any_associated(il)) { + struct il_calib_diff_gain_cmd cmd; + + /* clear data for chain noise calibration algorithm */ + data->chain_noise_a = 0; + data->chain_noise_b = 0; + data->chain_noise_c = 0; + data->chain_signal_a = 0; + data->chain_signal_b = 0; + data->chain_signal_c = 0; + data->beacon_count = 0; + + memset(&cmd, 0, sizeof(cmd)); + cmd.hdr.op_code = IL_PHY_CALIBRATE_DIFF_GAIN_CMD; + cmd.diff_gain_a = 0; + cmd.diff_gain_b = 0; + cmd.diff_gain_c = 0; + if (il_send_cmd_pdu(il, REPLY_PHY_CALIBRATION_CMD, + sizeof(cmd), &cmd)) + IL_ERR( + "Could not send REPLY_PHY_CALIBRATION_CMD\n"); + data->state = IL_CHAIN_NOISE_ACCUMULATE; + D_CALIB("Run chain_noise_calibrate\n"); + } +} + +static struct il_sensitivity_ranges il4965_sensitivity = { + .min_nrg_cck = 97, + .max_nrg_cck = 0, /* not used, set to 0 */ + + .auto_corr_min_ofdm = 85, + .auto_corr_min_ofdm_mrc = 170, + .auto_corr_min_ofdm_x1 = 105, + .auto_corr_min_ofdm_mrc_x1 = 220, + + .auto_corr_max_ofdm = 120, + .auto_corr_max_ofdm_mrc = 210, + .auto_corr_max_ofdm_x1 = 140, + .auto_corr_max_ofdm_mrc_x1 = 270, + + .auto_corr_min_cck = 125, + .auto_corr_max_cck = 200, + .auto_corr_min_cck_mrc = 200, + .auto_corr_max_cck_mrc = 400, + + .nrg_th_cck = 100, + .nrg_th_ofdm = 100, + + .barker_corr_th_min = 190, + .barker_corr_th_min_mrc = 390, + .nrg_th_cca = 62, +}; + +static void il4965_set_ct_threshold(struct il_priv *il) +{ + /* want Kelvin */ + il->hw_params.ct_kill_threshold = + CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY); +} + +/** + * il4965_hw_set_hw_params + * + * Called when initializing driver + */ +static int il4965_hw_set_hw_params(struct il_priv *il) +{ + if (il->cfg->mod_params->num_of_queues >= IL_MIN_NUM_QUEUES && + il->cfg->mod_params->num_of_queues <= IL49_NUM_QUEUES) + il->cfg->base_params->num_of_queues = + il->cfg->mod_params->num_of_queues; + + il->hw_params.max_txq_num = il->cfg->base_params->num_of_queues; + il->hw_params.dma_chnl_num = FH49_TCSR_CHNL_NUM; + il->hw_params.scd_bc_tbls_size = + il->cfg->base_params->num_of_queues * + sizeof(struct il4965_scd_bc_tbl); + il->hw_params.tfd_size = sizeof(struct il_tfd); + il->hw_params.max_stations = IL4965_STATION_COUNT; + il->ctx.bcast_sta_id = IL4965_BROADCAST_ID; + il->hw_params.max_data_size = IL49_RTC_DATA_SIZE; + il->hw_params.max_inst_size = IL49_RTC_INST_SIZE; + il->hw_params.max_bsm_size = BSM_SRAM_SIZE; + il->hw_params.ht40_channel = BIT(IEEE80211_BAND_5GHZ); + + il->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR; + + il->hw_params.tx_chains_num = il4965_num_of_ant(il->cfg->valid_tx_ant); + il->hw_params.rx_chains_num = il4965_num_of_ant(il->cfg->valid_rx_ant); + il->hw_params.valid_tx_ant = il->cfg->valid_tx_ant; + il->hw_params.valid_rx_ant = il->cfg->valid_rx_ant; + + il4965_set_ct_threshold(il); + + il->hw_params.sens = &il4965_sensitivity; + il->hw_params.beacon_time_tsf_bits = IL4965_EXT_BEACON_TIME_POS; + + return 0; +} + +static s32 il4965_math_div_round(s32 num, s32 denom, s32 *res) +{ + s32 sign = 1; + + if (num < 0) { + sign = -sign; + num = -num; + } + if (denom < 0) { + sign = -sign; + denom = -denom; + } + *res = 1; + *res = ((num * 2 + denom) / (denom * 2)) * sign; + + return 1; +} + +/** + * il4965_get_voltage_compensation - Power supply voltage comp for txpower + * + * Determines power supply voltage compensation for txpower calculations. + * Returns number of 1/2-dB steps to subtract from gain table idx, + * to compensate for difference between power supply voltage during + * factory measurements, vs. current power supply voltage. + * + * Voltage indication is higher for lower voltage. + * Lower voltage requires more gain (lower gain table idx). + */ +static s32 il4965_get_voltage_compensation(s32 eeprom_voltage, + s32 current_voltage) +{ + s32 comp = 0; + + if (TX_POWER_IL_ILLEGAL_VOLTAGE == eeprom_voltage || + TX_POWER_IL_ILLEGAL_VOLTAGE == current_voltage) + return 0; + + il4965_math_div_round(current_voltage - eeprom_voltage, + TX_POWER_IL_VOLTAGE_CODES_PER_03V, &comp); + + if (current_voltage > eeprom_voltage) + comp *= 2; + if ((comp < -2) || (comp > 2)) + comp = 0; + + return comp; +} + +static s32 il4965_get_tx_atten_grp(u16 channel) +{ + if (channel >= CALIB_IL_TX_ATTEN_GR5_FCH && + channel <= CALIB_IL_TX_ATTEN_GR5_LCH) + return CALIB_CH_GROUP_5; + + if (channel >= CALIB_IL_TX_ATTEN_GR1_FCH && + channel <= CALIB_IL_TX_ATTEN_GR1_LCH) + return CALIB_CH_GROUP_1; + + if (channel >= CALIB_IL_TX_ATTEN_GR2_FCH && + channel <= CALIB_IL_TX_ATTEN_GR2_LCH) + return CALIB_CH_GROUP_2; + + if (channel >= CALIB_IL_TX_ATTEN_GR3_FCH && + channel <= CALIB_IL_TX_ATTEN_GR3_LCH) + return CALIB_CH_GROUP_3; + + if (channel >= CALIB_IL_TX_ATTEN_GR4_FCH && + channel <= CALIB_IL_TX_ATTEN_GR4_LCH) + return CALIB_CH_GROUP_4; + + return -EINVAL; +} + +static u32 il4965_get_sub_band(const struct il_priv *il, u32 channel) +{ + s32 b = -1; + + for (b = 0; b < EEPROM_TX_POWER_BANDS; b++) { + if (il->calib_info->band_info[b].ch_from == 0) + continue; + + if (channel >= il->calib_info->band_info[b].ch_from && + channel <= il->calib_info->band_info[b].ch_to) + break; + } + + return b; +} + +static s32 il4965_interpolate_value(s32 x, s32 x1, s32 y1, s32 x2, s32 y2) +{ + s32 val; + + if (x2 == x1) + return y1; + else { + il4965_math_div_round((x2 - x) * (y1 - y2), (x2 - x1), &val); + return val + y2; + } +} + +/** + * il4965_interpolate_chan - Interpolate factory measurements for one channel + * + * Interpolates factory measurements from the two sample channels within a + * sub-band, to apply to channel of interest. Interpolation is proportional to + * differences in channel frequencies, which is proportional to differences + * in channel number. + */ +static int il4965_interpolate_chan(struct il_priv *il, u32 channel, + struct il_eeprom_calib_ch_info *chan_info) +{ + s32 s = -1; + u32 c; + u32 m; + const struct il_eeprom_calib_measure *m1; + const struct il_eeprom_calib_measure *m2; + struct il_eeprom_calib_measure *omeas; + u32 ch_i1; + u32 ch_i2; + + s = il4965_get_sub_band(il, channel); + if (s >= EEPROM_TX_POWER_BANDS) { + IL_ERR("Tx Power can not find channel %d\n", channel); + return -1; + } + + ch_i1 = il->calib_info->band_info[s].ch1.ch_num; + ch_i2 = il->calib_info->band_info[s].ch2.ch_num; + chan_info->ch_num = (u8) channel; + + D_TXPOWER("channel %d subband %d factory cal ch %d & %d\n", + channel, s, ch_i1, ch_i2); + + for (c = 0; c < EEPROM_TX_POWER_TX_CHAINS; c++) { + for (m = 0; m < EEPROM_TX_POWER_MEASUREMENTS; m++) { + m1 = &(il->calib_info->band_info[s].ch1. + measurements[c][m]); + m2 = &(il->calib_info->band_info[s].ch2. + measurements[c][m]); + omeas = &(chan_info->measurements[c][m]); + + omeas->actual_pow = + (u8) il4965_interpolate_value(channel, ch_i1, + m1->actual_pow, + ch_i2, + m2->actual_pow); + omeas->gain_idx = + (u8) il4965_interpolate_value(channel, ch_i1, + m1->gain_idx, ch_i2, + m2->gain_idx); + omeas->temperature = + (u8) il4965_interpolate_value(channel, ch_i1, + m1->temperature, + ch_i2, + m2->temperature); + omeas->pa_det = + (s8) il4965_interpolate_value(channel, ch_i1, + m1->pa_det, ch_i2, + m2->pa_det); + + D_TXPOWER( + "chain %d meas %d AP1=%d AP2=%d AP=%d\n", c, m, + m1->actual_pow, m2->actual_pow, omeas->actual_pow); + D_TXPOWER( + "chain %d meas %d NI1=%d NI2=%d NI=%d\n", c, m, + m1->gain_idx, m2->gain_idx, omeas->gain_idx); + D_TXPOWER( + "chain %d meas %d PA1=%d PA2=%d PA=%d\n", c, m, + m1->pa_det, m2->pa_det, omeas->pa_det); + D_TXPOWER( + "chain %d meas %d T1=%d T2=%d T=%d\n", c, m, + m1->temperature, m2->temperature, + omeas->temperature); + } + } + + return 0; +} + +/* bit-rate-dependent table to prevent Tx distortion, in half-dB units, + * for OFDM 6, 12, 18, 24, 36, 48, 54, 60 MBit, and CCK all rates. */ +static s32 back_off_table[] = { + 10, 10, 10, 10, 10, 15, 17, 20, /* OFDM SISO 20 MHz */ + 10, 10, 10, 10, 10, 15, 17, 20, /* OFDM MIMO 20 MHz */ + 10, 10, 10, 10, 10, 15, 17, 20, /* OFDM SISO 40 MHz */ + 10, 10, 10, 10, 10, 15, 17, 20, /* OFDM MIMO 40 MHz */ + 10 /* CCK */ +}; + +/* Thermal compensation values for txpower for various frequency ranges ... + * ratios from 3:1 to 4.5:1 of degrees (Celsius) per half-dB gain adjust */ +static struct il4965_txpower_comp_entry { + s32 degrees_per_05db_a; + s32 degrees_per_05db_a_denom; +} tx_power_cmp_tble[CALIB_CH_GROUP_MAX] = { + {9, 2}, /* group 0 5.2, ch 34-43 */ + {4, 1}, /* group 1 5.2, ch 44-70 */ + {4, 1}, /* group 2 5.2, ch 71-124 */ + {4, 1}, /* group 3 5.2, ch 125-200 */ + {3, 1} /* group 4 2.4, ch all */ +}; + +static s32 get_min_power_idx(s32 rate_power_idx, u32 band) +{ + if (!band) { + if ((rate_power_idx & 7) <= 4) + return MIN_TX_GAIN_IDX_52GHZ_EXT; + } + return MIN_TX_GAIN_IDX; +} + +struct gain_entry { + u8 dsp; + u8 radio; +}; + +static const struct gain_entry gain_table[2][108] = { + /* 5.2GHz power gain idx table */ + { + {123, 0x3F}, /* highest txpower */ + {117, 0x3F}, + {110, 0x3F}, + {104, 0x3F}, + {98, 0x3F}, + {110, 0x3E}, + {104, 0x3E}, + {98, 0x3E}, + {110, 0x3D}, + {104, 0x3D}, + {98, 0x3D}, + {110, 0x3C}, + {104, 0x3C}, + {98, 0x3C}, + {110, 0x3B}, + {104, 0x3B}, + {98, 0x3B}, + {110, 0x3A}, + {104, 0x3A}, + {98, 0x3A}, + {110, 0x39}, + {104, 0x39}, + {98, 0x39}, + {110, 0x38}, + {104, 0x38}, + {98, 0x38}, + {110, 0x37}, + {104, 0x37}, + {98, 0x37}, + {110, 0x36}, + {104, 0x36}, + {98, 0x36}, + {110, 0x35}, + {104, 0x35}, + {98, 0x35}, + {110, 0x34}, + {104, 0x34}, + {98, 0x34}, + {110, 0x33}, + {104, 0x33}, + {98, 0x33}, + {110, 0x32}, + {104, 0x32}, + {98, 0x32}, + {110, 0x31}, + {104, 0x31}, + {98, 0x31}, + {110, 0x30}, + {104, 0x30}, + {98, 0x30}, + {110, 0x25}, + {104, 0x25}, + {98, 0x25}, + {110, 0x24}, + {104, 0x24}, + {98, 0x24}, + {110, 0x23}, + {104, 0x23}, + {98, 0x23}, + {110, 0x22}, + {104, 0x18}, + {98, 0x18}, + {110, 0x17}, + {104, 0x17}, + {98, 0x17}, + {110, 0x16}, + {104, 0x16}, + {98, 0x16}, + {110, 0x15}, + {104, 0x15}, + {98, 0x15}, + {110, 0x14}, + {104, 0x14}, + {98, 0x14}, + {110, 0x13}, + {104, 0x13}, + {98, 0x13}, + {110, 0x12}, + {104, 0x08}, + {98, 0x08}, + {110, 0x07}, + {104, 0x07}, + {98, 0x07}, + {110, 0x06}, + {104, 0x06}, + {98, 0x06}, + {110, 0x05}, + {104, 0x05}, + {98, 0x05}, + {110, 0x04}, + {104, 0x04}, + {98, 0x04}, + {110, 0x03}, + {104, 0x03}, + {98, 0x03}, + {110, 0x02}, + {104, 0x02}, + {98, 0x02}, + {110, 0x01}, + {104, 0x01}, + {98, 0x01}, + {110, 0x00}, + {104, 0x00}, + {98, 0x00}, + {93, 0x00}, + {88, 0x00}, + {83, 0x00}, + {78, 0x00}, + }, + /* 2.4GHz power gain idx table */ + { + {110, 0x3f}, /* highest txpower */ + {104, 0x3f}, + {98, 0x3f}, + {110, 0x3e}, + {104, 0x3e}, + {98, 0x3e}, + {110, 0x3d}, + {104, 0x3d}, + {98, 0x3d}, + {110, 0x3c}, + {104, 0x3c}, + {98, 0x3c}, + {110, 0x3b}, + {104, 0x3b}, + {98, 0x3b}, + {110, 0x3a}, + {104, 0x3a}, + {98, 0x3a}, + {110, 0x39}, + {104, 0x39}, + {98, 0x39}, + {110, 0x38}, + {104, 0x38}, + {98, 0x38}, + {110, 0x37}, + {104, 0x37}, + {98, 0x37}, + {110, 0x36}, + {104, 0x36}, + {98, 0x36}, + {110, 0x35}, + {104, 0x35}, + {98, 0x35}, + {110, 0x34}, + {104, 0x34}, + {98, 0x34}, + {110, 0x33}, + {104, 0x33}, + {98, 0x33}, + {110, 0x32}, + {104, 0x32}, + {98, 0x32}, + {110, 0x31}, + {104, 0x31}, + {98, 0x31}, + {110, 0x30}, + {104, 0x30}, + {98, 0x30}, + {110, 0x6}, + {104, 0x6}, + {98, 0x6}, + {110, 0x5}, + {104, 0x5}, + {98, 0x5}, + {110, 0x4}, + {104, 0x4}, + {98, 0x4}, + {110, 0x3}, + {104, 0x3}, + {98, 0x3}, + {110, 0x2}, + {104, 0x2}, + {98, 0x2}, + {110, 0x1}, + {104, 0x1}, + {98, 0x1}, + {110, 0x0}, + {104, 0x0}, + {98, 0x0}, + {97, 0}, + {96, 0}, + {95, 0}, + {94, 0}, + {93, 0}, + {92, 0}, + {91, 0}, + {90, 0}, + {89, 0}, + {88, 0}, + {87, 0}, + {86, 0}, + {85, 0}, + {84, 0}, + {83, 0}, + {82, 0}, + {81, 0}, + {80, 0}, + {79, 0}, + {78, 0}, + {77, 0}, + {76, 0}, + {75, 0}, + {74, 0}, + {73, 0}, + {72, 0}, + {71, 0}, + {70, 0}, + {69, 0}, + {68, 0}, + {67, 0}, + {66, 0}, + {65, 0}, + {64, 0}, + {63, 0}, + {62, 0}, + {61, 0}, + {60, 0}, + {59, 0}, + } +}; + +static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, + u8 is_ht40, u8 ctrl_chan_high, + struct il4965_tx_power_db *tx_power_tbl) +{ + u8 saturation_power; + s32 target_power; + s32 user_target_power; + s32 power_limit; + s32 current_temp; + s32 reg_limit; + s32 current_regulatory; + s32 txatten_grp = CALIB_CH_GROUP_MAX; + int i; + int c; + const struct il_channel_info *ch_info = NULL; + struct il_eeprom_calib_ch_info ch_eeprom_info; + const struct il_eeprom_calib_measure *measurement; + s16 voltage; + s32 init_voltage; + s32 voltage_compensation; + s32 degrees_per_05db_num; + s32 degrees_per_05db_denom; + s32 factory_temp; + s32 temperature_comp[2]; + s32 factory_gain_idx[2]; + s32 factory_actual_pwr[2]; + s32 power_idx; + + /* tx_power_user_lmt is in dBm, convert to half-dBm (half-dB units + * are used for idxing into txpower table) */ + user_target_power = 2 * il->tx_power_user_lmt; + + /* Get current (RXON) channel, band, width */ + D_TXPOWER("chan %d band %d is_ht40 %d\n", channel, band, + is_ht40); + + ch_info = il_get_channel_info(il, il->band, channel); + + if (!il_is_channel_valid(ch_info)) + return -EINVAL; + + /* get txatten group, used to select 1) thermal txpower adjustment + * and 2) mimo txpower balance between Tx chains. */ + txatten_grp = il4965_get_tx_atten_grp(channel); + if (txatten_grp < 0) { + IL_ERR("Can't find txatten group for channel %d.\n", + channel); + return txatten_grp; + } + + D_TXPOWER("channel %d belongs to txatten group %d\n", + channel, txatten_grp); + + if (is_ht40) { + if (ctrl_chan_high) + channel -= 2; + else + channel += 2; + } + + /* hardware txpower limits ... + * saturation (clipping distortion) txpowers are in half-dBm */ + if (band) + saturation_power = il->calib_info->saturation_power24; + else + saturation_power = il->calib_info->saturation_power52; + + if (saturation_power < IL_TX_POWER_SATURATION_MIN || + saturation_power > IL_TX_POWER_SATURATION_MAX) { + if (band) + saturation_power = IL_TX_POWER_DEFAULT_SATURATION_24; + else + saturation_power = IL_TX_POWER_DEFAULT_SATURATION_52; + } + + /* regulatory txpower limits ... reg_limit values are in half-dBm, + * max_power_avg values are in dBm, convert * 2 */ + if (is_ht40) + reg_limit = ch_info->ht40_max_power_avg * 2; + else + reg_limit = ch_info->max_power_avg * 2; + + if ((reg_limit < IL_TX_POWER_REGULATORY_MIN) || + (reg_limit > IL_TX_POWER_REGULATORY_MAX)) { + if (band) + reg_limit = IL_TX_POWER_DEFAULT_REGULATORY_24; + else + reg_limit = IL_TX_POWER_DEFAULT_REGULATORY_52; + } + + /* Interpolate txpower calibration values for this channel, + * based on factory calibration tests on spaced channels. */ + il4965_interpolate_chan(il, channel, &ch_eeprom_info); + + /* calculate tx gain adjustment based on power supply voltage */ + voltage = le16_to_cpu(il->calib_info->voltage); + init_voltage = (s32)le32_to_cpu(il->card_alive_init.voltage); + voltage_compensation = + il4965_get_voltage_compensation(voltage, init_voltage); + + D_TXPOWER("curr volt %d eeprom volt %d volt comp %d\n", + init_voltage, + voltage, voltage_compensation); + + /* get current temperature (Celsius) */ + current_temp = max(il->temperature, IL_TX_POWER_TEMPERATURE_MIN); + current_temp = min(il->temperature, IL_TX_POWER_TEMPERATURE_MAX); + current_temp = KELVIN_TO_CELSIUS(current_temp); + + /* select thermal txpower adjustment params, based on channel group + * (same frequency group used for mimo txatten adjustment) */ + degrees_per_05db_num = + tx_power_cmp_tble[txatten_grp].degrees_per_05db_a; + degrees_per_05db_denom = + tx_power_cmp_tble[txatten_grp].degrees_per_05db_a_denom; + + /* get per-chain txpower values from factory measurements */ + for (c = 0; c < 2; c++) { + measurement = &ch_eeprom_info.measurements[c][1]; + + /* txgain adjustment (in half-dB steps) based on difference + * between factory and current temperature */ + factory_temp = measurement->temperature; + il4965_math_div_round((current_temp - factory_temp) * + degrees_per_05db_denom, + degrees_per_05db_num, + &temperature_comp[c]); + + factory_gain_idx[c] = measurement->gain_idx; + factory_actual_pwr[c] = measurement->actual_pow; + + D_TXPOWER("chain = %d\n", c); + D_TXPOWER("fctry tmp %d, " + "curr tmp %d, comp %d steps\n", + factory_temp, current_temp, + temperature_comp[c]); + + D_TXPOWER("fctry idx %d, fctry pwr %d\n", + factory_gain_idx[c], + factory_actual_pwr[c]); + } + + /* for each of 33 bit-rates (including 1 for CCK) */ + for (i = 0; i < POWER_TBL_NUM_ENTRIES; i++) { + u8 is_mimo_rate; + union il4965_tx_power_dual_stream tx_power; + + /* for mimo, reduce each chain's txpower by half + * (3dB, 6 steps), so total output power is regulatory + * compliant. */ + if (i & 0x8) { + current_regulatory = reg_limit - + IL_TX_POWER_MIMO_REGULATORY_COMPENSATION; + is_mimo_rate = 1; + } else { + current_regulatory = reg_limit; + is_mimo_rate = 0; + } + + /* find txpower limit, either hardware or regulatory */ + power_limit = saturation_power - back_off_table[i]; + if (power_limit > current_regulatory) + power_limit = current_regulatory; + + /* reduce user's txpower request if necessary + * for this rate on this channel */ + target_power = user_target_power; + if (target_power > power_limit) + target_power = power_limit; + + D_TXPOWER("rate %d sat %d reg %d usr %d tgt %d\n", + i, saturation_power - back_off_table[i], + current_regulatory, user_target_power, + target_power); + + /* for each of 2 Tx chains (radio transmitters) */ + for (c = 0; c < 2; c++) { + s32 atten_value; + + if (is_mimo_rate) + atten_value = + (s32)le32_to_cpu(il->card_alive_init. + tx_atten[txatten_grp][c]); + else + atten_value = 0; + + /* calculate idx; higher idx means lower txpower */ + power_idx = (u8) (factory_gain_idx[c] - + (target_power - + factory_actual_pwr[c]) - + temperature_comp[c] - + voltage_compensation + + atten_value); + +/* D_TXPOWER("calculated txpower idx %d\n", + power_idx); */ + + if (power_idx < get_min_power_idx(i, band)) + power_idx = get_min_power_idx(i, band); + + /* adjust 5 GHz idx to support negative idxes */ + if (!band) + power_idx += 9; + + /* CCK, rate 32, reduce txpower for CCK */ + if (i == POWER_TBL_CCK_ENTRY) + power_idx += + IL_TX_POWER_CCK_COMPENSATION_C_STEP; + + /* stay within the table! */ + if (power_idx > 107) { + IL_WARN("txpower idx %d > 107\n", + power_idx); + power_idx = 107; + } + if (power_idx < 0) { + IL_WARN("txpower idx %d < 0\n", + power_idx); + power_idx = 0; + } + + /* fill txpower command for this rate/chain */ + tx_power.s.radio_tx_gain[c] = + gain_table[band][power_idx].radio; + tx_power.s.dsp_predis_atten[c] = + gain_table[band][power_idx].dsp; + + D_TXPOWER("chain %d mimo %d idx %d " + "gain 0x%02x dsp %d\n", + c, atten_value, power_idx, + tx_power.s.radio_tx_gain[c], + tx_power.s.dsp_predis_atten[c]); + } /* for each chain */ + + tx_power_tbl->power_tbl[i].dw = cpu_to_le32(tx_power.dw); + + } /* for each rate */ + + return 0; +} + +/** + * il4965_send_tx_power - Configure the TXPOWER level user limit + * + * Uses the active RXON for channel, band, and characteristics (ht40, high) + * The power limit is taken from il->tx_power_user_lmt. + */ +static int il4965_send_tx_power(struct il_priv *il) +{ + struct il4965_txpowertable_cmd cmd = { 0 }; + int ret; + u8 band = 0; + bool is_ht40 = false; + u8 ctrl_chan_high = 0; + struct il_rxon_context *ctx = &il->ctx; + + if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &il->status), + "TX Power requested while scanning!\n")) + return -EAGAIN; + + band = il->band == IEEE80211_BAND_2GHZ; + + is_ht40 = iw4965_is_ht40_channel(ctx->active.flags); + + if (is_ht40 && (ctx->active.flags & RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK)) + ctrl_chan_high = 1; + + cmd.band = band; + cmd.channel = ctx->active.channel; + + ret = il4965_fill_txpower_tbl(il, band, + le16_to_cpu(ctx->active.channel), + is_ht40, ctrl_chan_high, &cmd.tx_power); + if (ret) + goto out; + + ret = il_send_cmd_pdu(il, + REPLY_TX_PWR_TBL_CMD, sizeof(cmd), &cmd); + +out: + return ret; +} + +static int il4965_send_rxon_assoc(struct il_priv *il, + struct il_rxon_context *ctx) +{ + int ret = 0; + struct il4965_rxon_assoc_cmd rxon_assoc; + const struct il_rxon_cmd *rxon1 = &ctx->staging; + const struct il_rxon_cmd *rxon2 = &ctx->active; + + if (rxon1->flags == rxon2->flags && + rxon1->filter_flags == rxon2->filter_flags && + rxon1->cck_basic_rates == rxon2->cck_basic_rates && + rxon1->ofdm_ht_single_stream_basic_rates == + rxon2->ofdm_ht_single_stream_basic_rates && + rxon1->ofdm_ht_dual_stream_basic_rates == + rxon2->ofdm_ht_dual_stream_basic_rates && + rxon1->rx_chain == rxon2->rx_chain && + rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates) { + D_INFO("Using current RXON_ASSOC. Not resending.\n"); + return 0; + } + + rxon_assoc.flags = ctx->staging.flags; + rxon_assoc.filter_flags = ctx->staging.filter_flags; + rxon_assoc.ofdm_basic_rates = ctx->staging.ofdm_basic_rates; + rxon_assoc.cck_basic_rates = ctx->staging.cck_basic_rates; + rxon_assoc.reserved = 0; + rxon_assoc.ofdm_ht_single_stream_basic_rates = + ctx->staging.ofdm_ht_single_stream_basic_rates; + rxon_assoc.ofdm_ht_dual_stream_basic_rates = + ctx->staging.ofdm_ht_dual_stream_basic_rates; + rxon_assoc.rx_chain_select_flags = ctx->staging.rx_chain; + + ret = il_send_cmd_pdu_async(il, REPLY_RXON_ASSOC, + sizeof(rxon_assoc), &rxon_assoc, NULL); + + return ret; +} + +static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) +{ + /* cast away the const for active_rxon in this function */ + struct il_rxon_cmd *active_rxon = (void *)&ctx->active; + int ret; + bool new_assoc = + !!(ctx->staging.filter_flags & RXON_FILTER_ASSOC_MSK); + + if (!il_is_alive(il)) + return -EBUSY; + + if (!ctx->is_active) + return 0; + + /* always get timestamp with Rx frame */ + ctx->staging.flags |= RXON_FLG_TSF2HOST_MSK; + + ret = il_check_rxon_cmd(il, ctx); + if (ret) { + IL_ERR("Invalid RXON configuration. Not committing.\n"); + return -EINVAL; + } + + /* + * receive commit_rxon request + * abort any previous channel switch if still in process + */ + if (test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status) && + il->switch_channel != ctx->staging.channel) { + D_11H("abort channel switch on %d\n", + le16_to_cpu(il->switch_channel)); + il_chswitch_done(il, false); + } + + /* If we don't need to send a full RXON, we can use + * il_rxon_assoc_cmd which is used to reconfigure filter + * and other flags for the current radio configuration. */ + if (!il_full_rxon_required(il, ctx)) { + ret = il_send_rxon_assoc(il, ctx); + if (ret) { + IL_ERR("Error setting RXON_ASSOC (%d)\n", ret); + return ret; + } + + memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); + il_print_rx_config_cmd(il, ctx); + /* + * We do not commit tx power settings while channel changing, + * do it now if tx power changed. + */ + il_set_tx_power(il, il->tx_power_next, false); + return 0; + } + + /* If we are currently associated and the new config requires + * an RXON_ASSOC and the new config wants the associated mask enabled, + * we must clear the associated from the active configuration + * before we apply the new config */ + if (il_is_associated_ctx(ctx) && new_assoc) { + D_INFO("Toggling associated bit on current RXON\n"); + active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; + + ret = il_send_cmd_pdu(il, ctx->rxon_cmd, + sizeof(struct il_rxon_cmd), + active_rxon); + + /* If the mask clearing failed then we set + * active_rxon back to what it was previously */ + if (ret) { + active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK; + IL_ERR("Error clearing ASSOC_MSK (%d)\n", ret); + return ret; + } + il_clear_ucode_stations(il, ctx); + il_restore_stations(il, ctx); + ret = il4965_restore_default_wep_keys(il, ctx); + if (ret) { + IL_ERR("Failed to restore WEP keys (%d)\n", ret); + return ret; + } + } + + D_INFO("Sending RXON\n" + "* with%s RXON_FILTER_ASSOC_MSK\n" + "* channel = %d\n" + "* bssid = %pM\n", + (new_assoc ? "" : "out"), + le16_to_cpu(ctx->staging.channel), + ctx->staging.bssid_addr); + + il_set_rxon_hwcrypto(il, ctx, + !il->cfg->mod_params->sw_crypto); + + /* Apply the new configuration + * RXON unassoc clears the station table in uCode so restoration of + * stations is needed after it (the RXON command) completes + */ + if (!new_assoc) { + ret = il_send_cmd_pdu(il, ctx->rxon_cmd, + sizeof(struct il_rxon_cmd), &ctx->staging); + if (ret) { + IL_ERR("Error setting new RXON (%d)\n", ret); + return ret; + } + D_INFO("Return from !new_assoc RXON.\n"); + memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); + il_clear_ucode_stations(il, ctx); + il_restore_stations(il, ctx); + ret = il4965_restore_default_wep_keys(il, ctx); + if (ret) { + IL_ERR("Failed to restore WEP keys (%d)\n", ret); + return ret; + } + } + if (new_assoc) { + il->start_calib = 0; + /* Apply the new configuration + * RXON assoc doesn't clear the station table in uCode, + */ + ret = il_send_cmd_pdu(il, ctx->rxon_cmd, + sizeof(struct il_rxon_cmd), &ctx->staging); + if (ret) { + IL_ERR("Error setting new RXON (%d)\n", ret); + return ret; + } + memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); + } + il_print_rx_config_cmd(il, ctx); + + il4965_init_sensitivity(il); + + /* If we issue a new RXON command which required a tune then we must + * send a new TXPOWER command or we won't be able to Tx any frames */ + ret = il_set_tx_power(il, il->tx_power_next, true); + if (ret) { + IL_ERR("Error sending TX power (%d)\n", ret); + return ret; + } + + return 0; +} + +static int il4965_hw_channel_switch(struct il_priv *il, + struct ieee80211_channel_switch *ch_switch) +{ + struct il_rxon_context *ctx = &il->ctx; + int rc; + u8 band = 0; + bool is_ht40 = false; + u8 ctrl_chan_high = 0; + struct il4965_channel_switch_cmd cmd; + const struct il_channel_info *ch_info; + u32 switch_time_in_usec, ucode_switch_time; + u16 ch; + u32 tsf_low; + u8 switch_count; + u16 beacon_interval = le16_to_cpu(ctx->timing.beacon_interval); + struct ieee80211_vif *vif = ctx->vif; + band = il->band == IEEE80211_BAND_2GHZ; + + is_ht40 = iw4965_is_ht40_channel(ctx->staging.flags); + + if (is_ht40 && + (ctx->staging.flags & RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK)) + ctrl_chan_high = 1; + + cmd.band = band; + cmd.expect_beacon = 0; + ch = ch_switch->channel->hw_value; + cmd.channel = cpu_to_le16(ch); + cmd.rxon_flags = ctx->staging.flags; + cmd.rxon_filter_flags = ctx->staging.filter_flags; + switch_count = ch_switch->count; + tsf_low = ch_switch->timestamp & 0x0ffffffff; + /* + * calculate the ucode channel switch time + * adding TSF as one of the factor for when to switch + */ + if (il->ucode_beacon_time > tsf_low && beacon_interval) { + if (switch_count > ((il->ucode_beacon_time - tsf_low) / + beacon_interval)) { + switch_count -= (il->ucode_beacon_time - + tsf_low) / beacon_interval; + } else + switch_count = 0; + } + if (switch_count <= 1) + cmd.switch_time = cpu_to_le32(il->ucode_beacon_time); + else { + switch_time_in_usec = + vif->bss_conf.beacon_int * switch_count * TIME_UNIT; + ucode_switch_time = il_usecs_to_beacons(il, + switch_time_in_usec, + beacon_interval); + cmd.switch_time = il_add_beacon_time(il, + il->ucode_beacon_time, + ucode_switch_time, + beacon_interval); + } + D_11H("uCode time for the switch is 0x%x\n", + cmd.switch_time); + ch_info = il_get_channel_info(il, il->band, ch); + if (ch_info) + cmd.expect_beacon = il_is_channel_radar(ch_info); + else { + IL_ERR("invalid channel switch from %u to %u\n", + ctx->active.channel, ch); + return -EFAULT; + } + + rc = il4965_fill_txpower_tbl(il, band, ch, is_ht40, + ctrl_chan_high, &cmd.tx_power); + if (rc) { + D_11H("error:%d fill txpower_tbl\n", rc); + return rc; + } + + return il_send_cmd_pdu(il, + REPLY_CHANNEL_SWITCH, sizeof(cmd), &cmd); +} + +/** + * il4965_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array + */ +static void il4965_txq_update_byte_cnt_tbl(struct il_priv *il, + struct il_tx_queue *txq, + u16 byte_cnt) +{ + struct il4965_scd_bc_tbl *scd_bc_tbl = il->scd_bc_tbls.addr; + int txq_id = txq->q.id; + int write_ptr = txq->q.write_ptr; + int len = byte_cnt + IL_TX_CRC_SIZE + IL_TX_DELIMITER_SIZE; + __le16 bc_ent; + + WARN_ON(len > 0xFFF || write_ptr >= TFD_QUEUE_SIZE_MAX); + + bc_ent = cpu_to_le16(len & 0xFFF); + /* Set up byte count within first 256 entries */ + scd_bc_tbl[txq_id].tfd_offset[write_ptr] = bc_ent; + + /* If within first 64 entries, duplicate at end */ + if (write_ptr < TFD_QUEUE_SIZE_BC_DUP) + scd_bc_tbl[txq_id]. + tfd_offset[TFD_QUEUE_SIZE_MAX + write_ptr] = bc_ent; +} + +/** + * il4965_hw_get_temperature - return the calibrated temperature (in Kelvin) + * @stats: Provides the temperature reading from the uCode + * + * A return of <0 indicates bogus data in the stats + */ +static int il4965_hw_get_temperature(struct il_priv *il) +{ + s32 temperature; + s32 vt; + s32 R1, R2, R3; + u32 R4; + + if (test_bit(STATUS_TEMPERATURE, &il->status) && + (il->_4965.stats.flag & + STATISTICS_REPLY_FLG_HT40_MODE_MSK)) { + D_TEMP("Running HT40 temperature calibration\n"); + R1 = (s32)le32_to_cpu(il->card_alive_init.therm_r1[1]); + R2 = (s32)le32_to_cpu(il->card_alive_init.therm_r2[1]); + R3 = (s32)le32_to_cpu(il->card_alive_init.therm_r3[1]); + R4 = le32_to_cpu(il->card_alive_init.therm_r4[1]); + } else { + D_TEMP("Running temperature calibration\n"); + R1 = (s32)le32_to_cpu(il->card_alive_init.therm_r1[0]); + R2 = (s32)le32_to_cpu(il->card_alive_init.therm_r2[0]); + R3 = (s32)le32_to_cpu(il->card_alive_init.therm_r3[0]); + R4 = le32_to_cpu(il->card_alive_init.therm_r4[0]); + } + + /* + * Temperature is only 23 bits, so sign extend out to 32. + * + * NOTE If we haven't received a stats notification yet + * with an updated temperature, use R4 provided to us in the + * "initialize" ALIVE response. + */ + if (!test_bit(STATUS_TEMPERATURE, &il->status)) + vt = sign_extend32(R4, 23); + else + vt = sign_extend32(le32_to_cpu(il->_4965.stats. + general.common.temperature), 23); + + D_TEMP("Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt); + + if (R3 == R1) { + IL_ERR("Calibration conflict R1 == R3\n"); + return -1; + } + + /* Calculate temperature in degrees Kelvin, adjust by 97%. + * Add offset to center the adjustment around 0 degrees Centigrade. */ + temperature = TEMPERATURE_CALIB_A_VAL * (vt - R2); + temperature /= (R3 - R1); + temperature = (temperature * 97) / 100 + TEMPERATURE_CALIB_KELVIN_OFFSET; + + D_TEMP("Calibrated temperature: %dK, %dC\n", + temperature, KELVIN_TO_CELSIUS(temperature)); + + return temperature; +} + +/* Adjust Txpower only if temperature variance is greater than threshold. */ +#define IL_TEMPERATURE_THRESHOLD 3 + +/** + * il4965_is_temp_calib_needed - determines if new calibration is needed + * + * If the temperature changed has changed sufficiently, then a recalibration + * is needed. + * + * Assumes caller will replace il->last_temperature once calibration + * executed. + */ +static int il4965_is_temp_calib_needed(struct il_priv *il) +{ + int temp_diff; + + if (!test_bit(STATUS_STATISTICS, &il->status)) { + D_TEMP("Temperature not updated -- no stats.\n"); + return 0; + } + + temp_diff = il->temperature - il->last_temperature; + + /* get absolute value */ + if (temp_diff < 0) { + D_POWER("Getting cooler, delta %d\n", temp_diff); + temp_diff = -temp_diff; + } else if (temp_diff == 0) + D_POWER("Temperature unchanged\n"); + else + D_POWER("Getting warmer, delta %d\n", temp_diff); + + if (temp_diff < IL_TEMPERATURE_THRESHOLD) { + D_POWER(" => thermal txpower calib not needed\n"); + return 0; + } + + D_POWER(" => thermal txpower calib needed\n"); + + return 1; +} + +static void il4965_temperature_calib(struct il_priv *il) +{ + s32 temp; + + temp = il4965_hw_get_temperature(il); + if (IL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(temp)) + return; + + if (il->temperature != temp) { + if (il->temperature) + D_TEMP("Temperature changed " + "from %dC to %dC\n", + KELVIN_TO_CELSIUS(il->temperature), + KELVIN_TO_CELSIUS(temp)); + else + D_TEMP("Temperature " + "initialized to %dC\n", + KELVIN_TO_CELSIUS(temp)); + } + + il->temperature = temp; + set_bit(STATUS_TEMPERATURE, &il->status); + + if (!il->disable_tx_power_cal && + unlikely(!test_bit(STATUS_SCANNING, &il->status)) && + il4965_is_temp_calib_needed(il)) + queue_work(il->workqueue, &il->txpower_work); +} + +static u16 il4965_get_hcmd_size(u8 cmd_id, u16 len) +{ + switch (cmd_id) { + case REPLY_RXON: + return (u16) sizeof(struct il4965_rxon_cmd); + default: + return len; + } +} + +static u16 il4965_build_addsta_hcmd(const struct il_addsta_cmd *cmd, + u8 *data) +{ + struct il4965_addsta_cmd *addsta = (struct il4965_addsta_cmd *)data; + addsta->mode = cmd->mode; + memcpy(&addsta->sta, &cmd->sta, sizeof(struct sta_id_modify)); + memcpy(&addsta->key, &cmd->key, sizeof(struct il4965_keyinfo)); + addsta->station_flags = cmd->station_flags; + addsta->station_flags_msk = cmd->station_flags_msk; + addsta->tid_disable_tx = cmd->tid_disable_tx; + addsta->add_immediate_ba_tid = cmd->add_immediate_ba_tid; + addsta->remove_immediate_ba_tid = cmd->remove_immediate_ba_tid; + addsta->add_immediate_ba_ssn = cmd->add_immediate_ba_ssn; + addsta->sleep_tx_count = cmd->sleep_tx_count; + addsta->reserved1 = cpu_to_le16(0); + addsta->reserved2 = cpu_to_le16(0); + + return (u16)sizeof(struct il4965_addsta_cmd); +} + +static inline u32 il4965_get_scd_ssn(struct il4965_tx_resp *tx_resp) +{ + return le32_to_cpup(&tx_resp->u.status + tx_resp->frame_count) & MAX_SN; +} + +/** + * il4965_tx_status_reply_tx - Handle Tx response for frames in aggregation queue + */ +static int il4965_tx_status_reply_tx(struct il_priv *il, + struct il_ht_agg *agg, + struct il4965_tx_resp *tx_resp, + int txq_id, u16 start_idx) +{ + u16 status; + struct agg_tx_status *frame_status = tx_resp->u.agg_status; + struct ieee80211_tx_info *info = NULL; + struct ieee80211_hdr *hdr = NULL; + u32 rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); + int i, sh, idx; + u16 seq; + if (agg->wait_for_ba) + D_TX_REPLY("got tx response w/o block-ack\n"); + + agg->frame_count = tx_resp->frame_count; + agg->start_idx = start_idx; + agg->rate_n_flags = rate_n_flags; + agg->bitmap = 0; + + /* num frames attempted by Tx command */ + if (agg->frame_count == 1) { + /* Only one frame was attempted; no block-ack will arrive */ + status = le16_to_cpu(frame_status[0].status); + idx = start_idx; + + D_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n", + agg->frame_count, agg->start_idx, idx); + + info = IEEE80211_SKB_CB(il->txq[txq_id].txb[idx].skb); + info->status.rates[0].count = tx_resp->failure_frame + 1; + info->flags &= ~IEEE80211_TX_CTL_AMPDU; + info->flags |= il4965_tx_status_to_mac80211(status); + il4965_hwrate_to_tx_control(il, rate_n_flags, info); + + D_TX_REPLY("1 Frame 0x%x failure :%d\n", + status & 0xff, tx_resp->failure_frame); + D_TX_REPLY("Rate Info rate_n_flags=%x\n", rate_n_flags); + + agg->wait_for_ba = 0; + } else { + /* Two or more frames were attempted; expect block-ack */ + u64 bitmap = 0; + int start = agg->start_idx; + + /* Construct bit-map of pending frames within Tx win */ + for (i = 0; i < agg->frame_count; i++) { + u16 sc; + status = le16_to_cpu(frame_status[i].status); + seq = le16_to_cpu(frame_status[i].sequence); + idx = SEQ_TO_IDX(seq); + txq_id = SEQ_TO_QUEUE(seq); + + if (status & (AGG_TX_STATE_FEW_BYTES_MSK | + AGG_TX_STATE_ABORT_MSK)) + continue; + + D_TX_REPLY("FrameCnt = %d, txq_id=%d idx=%d\n", + agg->frame_count, txq_id, idx); + + hdr = il_tx_queue_get_hdr(il, txq_id, idx); + if (!hdr) { + IL_ERR( + "BUG_ON idx doesn't point to valid skb" + " idx=%d, txq_id=%d\n", idx, txq_id); + return -1; + } + + sc = le16_to_cpu(hdr->seq_ctrl); + if (idx != (SEQ_TO_SN(sc) & 0xff)) { + IL_ERR( + "BUG_ON idx doesn't match seq control" + " idx=%d, seq_idx=%d, seq=%d\n", + idx, SEQ_TO_SN(sc), hdr->seq_ctrl); + return -1; + } + + D_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n", + i, idx, SEQ_TO_SN(sc)); + + sh = idx - start; + if (sh > 64) { + sh = (start - idx) + 0xff; + bitmap = bitmap << sh; + sh = 0; + start = idx; + } else if (sh < -64) + sh = 0xff - (start - idx); + else if (sh < 0) { + sh = start - idx; + start = idx; + bitmap = bitmap << sh; + sh = 0; + } + bitmap |= 1ULL << sh; + D_TX_REPLY("start=%d bitmap=0x%llx\n", + start, (unsigned long long)bitmap); + } + + agg->bitmap = bitmap; + agg->start_idx = start; + D_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n", + agg->frame_count, agg->start_idx, + (unsigned long long)agg->bitmap); + + if (bitmap) + agg->wait_for_ba = 1; + } + return 0; +} + +static u8 il4965_find_station(struct il_priv *il, const u8 *addr) +{ + int i; + int start = 0; + int ret = IL_INVALID_STATION; + unsigned long flags; + + if ((il->iw_mode == NL80211_IFTYPE_ADHOC)) + start = IL_STA_ID; + + if (is_broadcast_ether_addr(addr)) + return il->ctx.bcast_sta_id; + + spin_lock_irqsave(&il->sta_lock, flags); + for (i = start; i < il->hw_params.max_stations; i++) + if (il->stations[i].used && + (!compare_ether_addr(il->stations[i].sta.sta.addr, + addr))) { + ret = i; + goto out; + } + + D_ASSOC("can not find STA %pM total %d\n", + addr, il->num_stations); + + out: + /* + * It may be possible that more commands interacting with stations + * arrive before we completed processing the adding of + * station + */ + if (ret != IL_INVALID_STATION && + (!(il->stations[ret].used & IL_STA_UCODE_ACTIVE) || + ((il->stations[ret].used & IL_STA_UCODE_ACTIVE) && + (il->stations[ret].used & IL_STA_UCODE_INPROGRESS)))) { + IL_ERR("Requested station info for sta %d before ready.\n", + ret); + ret = IL_INVALID_STATION; + } + spin_unlock_irqrestore(&il->sta_lock, flags); + return ret; +} + +static int il4965_get_ra_sta_id(struct il_priv *il, struct ieee80211_hdr *hdr) +{ + if (il->iw_mode == NL80211_IFTYPE_STATION) { + return IL_AP_ID; + } else { + u8 *da = ieee80211_get_DA(hdr); + return il4965_find_station(il, da); + } +} + +/** + * il4965_rx_reply_tx - Handle standard (non-aggregation) Tx response + */ +static void il4965_rx_reply_tx(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + u16 sequence = le16_to_cpu(pkt->hdr.sequence); + int txq_id = SEQ_TO_QUEUE(sequence); + int idx = SEQ_TO_IDX(sequence); + struct il_tx_queue *txq = &il->txq[txq_id]; + struct ieee80211_hdr *hdr; + struct ieee80211_tx_info *info; + struct il4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; + u32 status = le32_to_cpu(tx_resp->u.status); + int uninitialized_var(tid); + int sta_id; + int freed; + u8 *qc = NULL; + unsigned long flags; + + if (idx >= txq->q.n_bd || il_queue_used(&txq->q, idx) == 0) { + IL_ERR("Read idx for DMA queue txq_id (%d) idx %d " + "is out of range [0-%d] %d %d\n", txq_id, + idx, txq->q.n_bd, txq->q.write_ptr, + txq->q.read_ptr); + return; + } + + txq->time_stamp = jiffies; + info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb); + memset(&info->status, 0, sizeof(info->status)); + + hdr = il_tx_queue_get_hdr(il, txq_id, idx); + if (ieee80211_is_data_qos(hdr->frame_control)) { + qc = ieee80211_get_qos_ctl(hdr); + tid = qc[0] & 0xf; + } + + sta_id = il4965_get_ra_sta_id(il, hdr); + if (txq->sched_retry && unlikely(sta_id == IL_INVALID_STATION)) { + IL_ERR("Station not known\n"); + return; + } + + spin_lock_irqsave(&il->sta_lock, flags); + if (txq->sched_retry) { + const u32 scd_ssn = il4965_get_scd_ssn(tx_resp); + struct il_ht_agg *agg = NULL; + WARN_ON(!qc); + + agg = &il->stations[sta_id].tid[tid].agg; + + il4965_tx_status_reply_tx(il, agg, tx_resp, txq_id, idx); + + /* check if BAR is needed */ + if ((tx_resp->frame_count == 1) && !il4965_is_tx_success(status)) + info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK; + + if (txq->q.read_ptr != (scd_ssn & 0xff)) { + idx = il_queue_dec_wrap(scd_ssn & 0xff, + txq->q.n_bd); + D_TX_REPLY("Retry scheduler reclaim scd_ssn " + "%d idx %d\n", scd_ssn , idx); + freed = il4965_tx_queue_reclaim(il, txq_id, idx); + if (qc) + il4965_free_tfds_in_queue(il, sta_id, + tid, freed); + + if (il->mac80211_registered && + il_queue_space(&txq->q) > txq->q.low_mark && + agg->state != IL_EMPTYING_HW_QUEUE_DELBA) + il_wake_queue(il, txq); + } + } else { + info->status.rates[0].count = tx_resp->failure_frame + 1; + info->flags |= il4965_tx_status_to_mac80211(status); + il4965_hwrate_to_tx_control(il, + le32_to_cpu(tx_resp->rate_n_flags), + info); + + D_TX_REPLY("TXQ %d status %s (0x%08x) " + "rate_n_flags 0x%x retries %d\n", + txq_id, + il4965_get_tx_fail_reason(status), status, + le32_to_cpu(tx_resp->rate_n_flags), + tx_resp->failure_frame); + + freed = il4965_tx_queue_reclaim(il, txq_id, idx); + if (qc && likely(sta_id != IL_INVALID_STATION)) + il4965_free_tfds_in_queue(il, sta_id, tid, freed); + else if (sta_id == IL_INVALID_STATION) + D_TX_REPLY("Station not known\n"); + + if (il->mac80211_registered && + il_queue_space(&txq->q) > txq->q.low_mark) + il_wake_queue(il, txq); + } + if (qc && likely(sta_id != IL_INVALID_STATION)) + il4965_txq_check_empty(il, sta_id, tid, txq_id); + + il4965_check_abort_status(il, tx_resp->frame_count, status); + + spin_unlock_irqrestore(&il->sta_lock, flags); +} + +static void il4965_rx_beacon_notif(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il4965_beacon_notif *beacon = (void *)pkt->u.raw; + u8 rate __maybe_unused = + il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); + + D_RX("beacon status %#x, retries:%d ibssmgr:%d " + "tsf:0x%.8x%.8x rate:%d\n", + le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, + beacon->beacon_notify_hdr.failure_frame, + le32_to_cpu(beacon->ibss_mgr_status), + le32_to_cpu(beacon->high_tsf), + le32_to_cpu(beacon->low_tsf), rate); + + il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); +} + +/* Set up 4965-specific Rx frame reply handlers */ +static void il4965_rx_handler_setup(struct il_priv *il) +{ + /* Legacy Rx frames */ + il->rx_handlers[REPLY_RX] = il4965_rx_reply_rx; + /* Tx response */ + il->rx_handlers[REPLY_TX] = il4965_rx_reply_tx; + il->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; +} + +static struct il_hcmd_ops il4965_hcmd = { + .rxon_assoc = il4965_send_rxon_assoc, + .commit_rxon = il4965_commit_rxon, + .set_rxon_chain = il4965_set_rxon_chain, +}; + +static void il4965_post_scan(struct il_priv *il) +{ + struct il_rxon_context *ctx = &il->ctx; + + /* + * Since setting the RXON may have been deferred while + * performing the scan, fire one off if needed + */ + if (memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) + il_commit_rxon(il, ctx); +} + +static void il4965_post_associate(struct il_priv *il) +{ + struct il_rxon_context *ctx = &il->ctx; + struct ieee80211_vif *vif = ctx->vif; + struct ieee80211_conf *conf = NULL; + int ret = 0; + + if (!vif || !il->is_open) + return; + + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + return; + + il_scan_cancel_timeout(il, 200); + + conf = il_ieee80211_get_hw_conf(il->hw); + + ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; + il_commit_rxon(il, ctx); + + ret = il_send_rxon_timing(il, ctx); + if (ret) + IL_WARN("RXON timing - " + "Attempting to continue.\n"); + + ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; + + il_set_rxon_ht(il, &il->current_ht_config); + + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); + + ctx->staging.assoc_id = cpu_to_le16(vif->bss_conf.aid); + + D_ASSOC("assoc id %d beacon interval %d\n", + vif->bss_conf.aid, vif->bss_conf.beacon_int); + + if (vif->bss_conf.use_short_preamble) + ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; + else + ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; + + if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) { + if (vif->bss_conf.use_short_slot) + ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; + else + ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; + } + + il_commit_rxon(il, ctx); + + D_ASSOC("Associated as %d to: %pM\n", + vif->bss_conf.aid, ctx->active.bssid_addr); + + switch (vif->type) { + case NL80211_IFTYPE_STATION: + break; + case NL80211_IFTYPE_ADHOC: + il4965_send_beacon_cmd(il); + break; + default: + IL_ERR("%s Should not be called in %d mode\n", + __func__, vif->type); + break; + } + + /* the chain noise calibration will enabled PM upon completion + * If chain noise has already been run, then we need to enable + * power management here */ + if (il->chain_noise_data.state == IL_CHAIN_NOISE_DONE) + il_power_update_mode(il, false); + + /* Enable Rx differential gain and sensitivity calibrations */ + il4965_chain_noise_reset(il); + il->start_calib = 1; +} + +static void il4965_config_ap(struct il_priv *il) +{ + struct il_rxon_context *ctx = &il->ctx; + struct ieee80211_vif *vif = ctx->vif; + int ret = 0; + + lockdep_assert_held(&il->mutex); + + if (test_bit(STATUS_EXIT_PENDING, &il->status)) + return; + + /* The following should be done only at AP bring up */ + if (!il_is_associated_ctx(ctx)) { + + /* RXON - unassoc (to set timing command) */ + ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; + il_commit_rxon(il, ctx); + + /* RXON Timing */ + ret = il_send_rxon_timing(il, ctx); + if (ret) + IL_WARN("RXON timing failed - " + "Attempting to continue.\n"); + + /* AP has all antennas */ + il->chain_noise_data.active_chains = + il->hw_params.valid_rx_ant; + il_set_rxon_ht(il, &il->current_ht_config); + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); + + ctx->staging.assoc_id = 0; + + if (vif->bss_conf.use_short_preamble) + ctx->staging.flags |= + RXON_FLG_SHORT_PREAMBLE_MSK; + else + ctx->staging.flags &= + ~RXON_FLG_SHORT_PREAMBLE_MSK; + + if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) { + if (vif->bss_conf.use_short_slot) + ctx->staging.flags |= + RXON_FLG_SHORT_SLOT_MSK; + else + ctx->staging.flags &= + ~RXON_FLG_SHORT_SLOT_MSK; + } + /* need to send beacon cmd before committing assoc RXON! */ + il4965_send_beacon_cmd(il); + /* restore RXON assoc */ + ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; + il_commit_rxon(il, ctx); + } + il4965_send_beacon_cmd(il); +} + +static struct il_hcmd_utils_ops il4965_hcmd_utils = { + .get_hcmd_size = il4965_get_hcmd_size, + .build_addsta_hcmd = il4965_build_addsta_hcmd, + .request_scan = il4965_request_scan, + .post_scan = il4965_post_scan, +}; + +static struct il_lib_ops il4965_lib = { + .set_hw_params = il4965_hw_set_hw_params, + .txq_update_byte_cnt_tbl = il4965_txq_update_byte_cnt_tbl, + .txq_attach_buf_to_tfd = il4965_hw_txq_attach_buf_to_tfd, + .txq_free_tfd = il4965_hw_txq_free_tfd, + .txq_init = il4965_hw_tx_queue_init, + .rx_handler_setup = il4965_rx_handler_setup, + .is_valid_rtc_data_addr = il4965_hw_valid_rtc_data_addr, + .init_alive_start = il4965_init_alive_start, + .load_ucode = il4965_load_bsm, + .dump_nic_error_log = il4965_dump_nic_error_log, + .dump_fh = il4965_dump_fh, + .set_channel_switch = il4965_hw_channel_switch, + .apm_ops = { + .init = il_apm_init, + .config = il4965_nic_config, + }, + .eeprom_ops = { + .regulatory_bands = { + EEPROM_REGULATORY_BAND_1_CHANNELS, + EEPROM_REGULATORY_BAND_2_CHANNELS, + EEPROM_REGULATORY_BAND_3_CHANNELS, + EEPROM_REGULATORY_BAND_4_CHANNELS, + EEPROM_REGULATORY_BAND_5_CHANNELS, + EEPROM_4965_REGULATORY_BAND_24_HT40_CHANNELS, + EEPROM_4965_REGULATORY_BAND_52_HT40_CHANNELS + }, + .acquire_semaphore = il4965_eeprom_acquire_semaphore, + .release_semaphore = il4965_eeprom_release_semaphore, + }, + .send_tx_power = il4965_send_tx_power, + .update_chain_flags = il4965_update_chain_flags, + .temp_ops = { + .temperature = il4965_temperature_calib, + }, + .debugfs_ops = { + .rx_stats_read = il4965_ucode_rx_stats_read, + .tx_stats_read = il4965_ucode_tx_stats_read, + .general_stats_read = il4965_ucode_general_stats_read, + }, +}; + +static const struct il_legacy_ops il4965_legacy_ops = { + .post_associate = il4965_post_associate, + .config_ap = il4965_config_ap, + .manage_ibss_station = il4965_manage_ibss_station, + .update_bcast_stations = il4965_update_bcast_stations, +}; + +struct ieee80211_ops il4965_hw_ops = { + .tx = il4965_mac_tx, + .start = il4965_mac_start, + .stop = il4965_mac_stop, + .add_interface = il_mac_add_interface, + .remove_interface = il_mac_remove_interface, + .change_interface = il_mac_change_interface, + .config = il_mac_config, + .configure_filter = il4965_configure_filter, + .set_key = il4965_mac_set_key, + .update_tkip_key = il4965_mac_update_tkip_key, + .conf_tx = il_mac_conf_tx, + .reset_tsf = il_mac_reset_tsf, + .bss_info_changed = il_mac_bss_info_changed, + .ampdu_action = il4965_mac_ampdu_action, + .hw_scan = il_mac_hw_scan, + .sta_add = il4965_mac_sta_add, + .sta_remove = il_mac_sta_remove, + .channel_switch = il4965_mac_channel_switch, + .tx_last_beacon = il_mac_tx_last_beacon, +}; + +static const struct il_ops il4965_ops = { + .lib = &il4965_lib, + .hcmd = &il4965_hcmd, + .utils = &il4965_hcmd_utils, + .led = &il4965_led_ops, + .legacy = &il4965_legacy_ops, + .ieee80211_ops = &il4965_hw_ops, +}; + +static struct il_base_params il4965_base_params = { + .eeprom_size = IL4965_EEPROM_IMG_SIZE, + .num_of_queues = IL49_NUM_QUEUES, + .num_of_ampdu_queues = IL49_NUM_AMPDU_QUEUES, + .pll_cfg_val = 0, + .set_l0s = true, + .use_bsm = true, + .led_compensation = 61, + .chain_noise_num_beacons = IL4965_CAL_NUM_BEACONS, + .wd_timeout = IL_DEF_WD_TIMEOUT, + .temperature_kelvin = true, + .ucode_tracing = true, + .sensitivity_calib_by_driver = true, + .chain_noise_calib_by_driver = true, +}; + +struct il_cfg il4965_cfg = { + .name = "Intel(R) Wireless WiFi Link 4965AGN", + .fw_name_pre = IL4965_FW_PRE, + .ucode_api_max = IL4965_UCODE_API_MAX, + .ucode_api_min = IL4965_UCODE_API_MIN, + .sku = IL_SKU_A|IL_SKU_G|IL_SKU_N, + .valid_tx_ant = ANT_AB, + .valid_rx_ant = ANT_ABC, + .eeprom_ver = EEPROM_4965_EEPROM_VERSION, + .eeprom_calib_ver = EEPROM_4965_TX_POWER_VERSION, + .ops = &il4965_ops, + .mod_params = &il4965_mod_params, + .base_params = &il4965_base_params, + .led_mode = IL_LED_BLINK, + /* + * Force use of chains B and C for scan RX on 5 GHz band + * because the device has off-channel reception on chain A. + */ + .scan_rx_antennas[IEEE80211_BAND_5GHZ] = ANT_BC, +}; + +/* Module firmware */ +MODULE_FIRMWARE(IL4965_MODULE_FIRMWARE(IL4965_UCODE_API_MAX)); diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index 49c4b36383cd..cd8ac73d45bf 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -8,7 +8,7 @@ iwl-legacy-objs += $(iwl-legacy-m) # 4965 obj-$(CONFIG_IWL4965) += iwl4965.o -iwl4965-objs := iwl-4965.o iwl4965-base.o iwl-4965-rs.o iwl-4965-led.o +iwl4965-objs := 4965.o 4965-mac.o iwl-4965-rs.o iwl-4965-led.o iwl4965-objs += iwl-4965-ucode.o iwl-4965-tx.o iwl4965-objs += iwl-4965-lib.o iwl-4965-rx.o iwl-4965-calib.o iwl4965-objs += iwl-4965-sta.o iwl-4965-eeprom.o @@ -16,7 +16,7 @@ iwl4965-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-4965-debugfs.o # 3945 obj-$(CONFIG_IWL3945) += iwl3945.o -iwl3945-objs := iwl3945-base.o iwl-3945.o iwl-3945-rs.o iwl-3945-led.o +iwl3945-objs := 3945-mac.o 3945.o iwl-3945-rs.o iwl-3945-led.o iwl3945-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-3945-debugfs.o ccflags-y += -D__CHECK_ENDIAN__ diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c deleted file mode 100644 index b6abf3473fac..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-3945.c +++ /dev/null @@ -1,2740 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "iwl-fh.h" -#include "iwl-3945-fh.h" -#include "iwl-commands.h" -#include "iwl-sta.h" -#include "iwl-3945.h" -#include "iwl-eeprom.h" -#include "iwl-core.h" -#include "iwl-helpers.h" -#include "iwl-led.h" -#include "iwl-3945-led.h" -#include "iwl-3945-debugfs.h" - -#define IL_DECLARE_RATE_INFO(r, ip, in, rp, rn, pp, np) \ - [RATE_##r##M_IDX] = { RATE_##r##M_PLCP, \ - RATE_##r##M_IEEE, \ - RATE_##ip##M_IDX, \ - RATE_##in##M_IDX, \ - RATE_##rp##M_IDX, \ - RATE_##rn##M_IDX, \ - RATE_##pp##M_IDX, \ - RATE_##np##M_IDX, \ - RATE_##r##M_IDX_TBL, \ - RATE_##ip##M_IDX_TBL } - -/* - * Parameter order: - * rate, prev rate, next rate, prev tgg rate, next tgg rate - * - * If there isn't a valid next or previous rate then INV is used which - * maps to RATE_INVALID - * - */ -const struct il3945_rate_info il3945_rates[RATE_COUNT_3945] = { - IL_DECLARE_RATE_INFO(1, INV, 2, INV, 2, INV, 2), /* 1mbps */ - IL_DECLARE_RATE_INFO(2, 1, 5, 1, 5, 1, 5), /* 2mbps */ - IL_DECLARE_RATE_INFO(5, 2, 6, 2, 11, 2, 11), /*5.5mbps */ - IL_DECLARE_RATE_INFO(11, 9, 12, 5, 12, 5, 18), /* 11mbps */ - IL_DECLARE_RATE_INFO(6, 5, 9, 5, 11, 5, 11), /* 6mbps */ - IL_DECLARE_RATE_INFO(9, 6, 11, 5, 11, 5, 11), /* 9mbps */ - IL_DECLARE_RATE_INFO(12, 11, 18, 11, 18, 11, 18), /* 12mbps */ - IL_DECLARE_RATE_INFO(18, 12, 24, 12, 24, 11, 24), /* 18mbps */ - IL_DECLARE_RATE_INFO(24, 18, 36, 18, 36, 18, 36), /* 24mbps */ - IL_DECLARE_RATE_INFO(36, 24, 48, 24, 48, 24, 48), /* 36mbps */ - IL_DECLARE_RATE_INFO(48, 36, 54, 36, 54, 36, 54), /* 48mbps */ - IL_DECLARE_RATE_INFO(54, 48, INV, 48, INV, 48, INV),/* 54mbps */ -}; - -static inline u8 il3945_get_prev_ieee_rate(u8 rate_idx) -{ - u8 rate = il3945_rates[rate_idx].prev_ieee; - - if (rate == RATE_INVALID) - rate = rate_idx; - return rate; -} - -/* 1 = enable the il3945_disable_events() function */ -#define IL_EVT_DISABLE (0) -#define IL_EVT_DISABLE_SIZE (1532/32) - -/** - * il3945_disable_events - Disable selected events in uCode event log - * - * Disable an event by writing "1"s into "disable" - * bitmap in SRAM. Bit position corresponds to Event # (id/type). - * Default values of 0 enable uCode events to be logged. - * Use for only special debugging. This function is just a placeholder as-is, - * you'll need to provide the special bits! ... - * ... and set IL_EVT_DISABLE to 1. */ -void il3945_disable_events(struct il_priv *il) -{ - int i; - u32 base; /* SRAM address of event log header */ - u32 disable_ptr; /* SRAM address of event-disable bitmap array */ - u32 array_size; /* # of u32 entries in array */ - static const u32 evt_disable[IL_EVT_DISABLE_SIZE] = { - 0x00000000, /* 31 - 0 Event id numbers */ - 0x00000000, /* 63 - 32 */ - 0x00000000, /* 95 - 64 */ - 0x00000000, /* 127 - 96 */ - 0x00000000, /* 159 - 128 */ - 0x00000000, /* 191 - 160 */ - 0x00000000, /* 223 - 192 */ - 0x00000000, /* 255 - 224 */ - 0x00000000, /* 287 - 256 */ - 0x00000000, /* 319 - 288 */ - 0x00000000, /* 351 - 320 */ - 0x00000000, /* 383 - 352 */ - 0x00000000, /* 415 - 384 */ - 0x00000000, /* 447 - 416 */ - 0x00000000, /* 479 - 448 */ - 0x00000000, /* 511 - 480 */ - 0x00000000, /* 543 - 512 */ - 0x00000000, /* 575 - 544 */ - 0x00000000, /* 607 - 576 */ - 0x00000000, /* 639 - 608 */ - 0x00000000, /* 671 - 640 */ - 0x00000000, /* 703 - 672 */ - 0x00000000, /* 735 - 704 */ - 0x00000000, /* 767 - 736 */ - 0x00000000, /* 799 - 768 */ - 0x00000000, /* 831 - 800 */ - 0x00000000, /* 863 - 832 */ - 0x00000000, /* 895 - 864 */ - 0x00000000, /* 927 - 896 */ - 0x00000000, /* 959 - 928 */ - 0x00000000, /* 991 - 960 */ - 0x00000000, /* 1023 - 992 */ - 0x00000000, /* 1055 - 1024 */ - 0x00000000, /* 1087 - 1056 */ - 0x00000000, /* 1119 - 1088 */ - 0x00000000, /* 1151 - 1120 */ - 0x00000000, /* 1183 - 1152 */ - 0x00000000, /* 1215 - 1184 */ - 0x00000000, /* 1247 - 1216 */ - 0x00000000, /* 1279 - 1248 */ - 0x00000000, /* 1311 - 1280 */ - 0x00000000, /* 1343 - 1312 */ - 0x00000000, /* 1375 - 1344 */ - 0x00000000, /* 1407 - 1376 */ - 0x00000000, /* 1439 - 1408 */ - 0x00000000, /* 1471 - 1440 */ - 0x00000000, /* 1503 - 1472 */ - }; - - base = le32_to_cpu(il->card_alive.log_event_table_ptr); - if (!il3945_hw_valid_rtc_data_addr(base)) { - IL_ERR("Invalid event log pointer 0x%08X\n", base); - return; - } - - disable_ptr = il_read_targ_mem(il, base + (4 * sizeof(u32))); - array_size = il_read_targ_mem(il, base + (5 * sizeof(u32))); - - if (IL_EVT_DISABLE && array_size == IL_EVT_DISABLE_SIZE) { - D_INFO("Disabling selected uCode log events at 0x%x\n", - disable_ptr); - for (i = 0; i < IL_EVT_DISABLE_SIZE; i++) - il_write_targ_mem(il, - disable_ptr + (i * sizeof(u32)), - evt_disable[i]); - - } else { - D_INFO("Selected uCode log events may be disabled\n"); - D_INFO(" by writing \"1\"s into disable bitmap\n"); - D_INFO(" in SRAM at 0x%x, size %d u32s\n", - disable_ptr, array_size); - } - -} - -static int il3945_hwrate_to_plcp_idx(u8 plcp) -{ - int idx; - - for (idx = 0; idx < RATE_COUNT_3945; idx++) - if (il3945_rates[idx].plcp == plcp) - return idx; - return -1; -} - -#ifdef CONFIG_IWLEGACY_DEBUG -#define TX_STATUS_ENTRY(x) case TX_3945_STATUS_FAIL_ ## x: return #x - -static const char *il3945_get_tx_fail_reason(u32 status) -{ - switch (status & TX_STATUS_MSK) { - case TX_3945_STATUS_SUCCESS: - return "SUCCESS"; - TX_STATUS_ENTRY(SHORT_LIMIT); - TX_STATUS_ENTRY(LONG_LIMIT); - TX_STATUS_ENTRY(FIFO_UNDERRUN); - TX_STATUS_ENTRY(MGMNT_ABORT); - TX_STATUS_ENTRY(NEXT_FRAG); - TX_STATUS_ENTRY(LIFE_EXPIRE); - TX_STATUS_ENTRY(DEST_PS); - TX_STATUS_ENTRY(ABORTED); - TX_STATUS_ENTRY(BT_RETRY); - TX_STATUS_ENTRY(STA_INVALID); - TX_STATUS_ENTRY(FRAG_DROPPED); - TX_STATUS_ENTRY(TID_DISABLE); - TX_STATUS_ENTRY(FRAME_FLUSHED); - TX_STATUS_ENTRY(INSUFFICIENT_CF_POLL); - TX_STATUS_ENTRY(TX_LOCKED); - TX_STATUS_ENTRY(NO_BEACON_ON_RADAR); - } - - return "UNKNOWN"; -} -#else -static inline const char *il3945_get_tx_fail_reason(u32 status) -{ - return ""; -} -#endif - -/* - * get ieee prev rate from rate scale table. - * for A and B mode we need to overright prev - * value - */ -int il3945_rs_next_rate(struct il_priv *il, int rate) -{ - int next_rate = il3945_get_prev_ieee_rate(rate); - - switch (il->band) { - case IEEE80211_BAND_5GHZ: - if (rate == RATE_12M_IDX) - next_rate = RATE_9M_IDX; - else if (rate == RATE_6M_IDX) - next_rate = RATE_6M_IDX; - break; - case IEEE80211_BAND_2GHZ: - if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && - il_is_associated(il)) { - if (rate == RATE_11M_IDX) - next_rate = RATE_5M_IDX; - } - break; - - default: - break; - } - - return next_rate; -} - - -/** - * il3945_tx_queue_reclaim - Reclaim Tx queue entries already Tx'd - * - * When FW advances 'R' idx, all entries between old and new 'R' idx - * need to be reclaimed. As result, some free space forms. If there is - * enough free space (> low mark), wake the stack that feeds us. - */ -static void il3945_tx_queue_reclaim(struct il_priv *il, - int txq_id, int idx) -{ - struct il_tx_queue *txq = &il->txq[txq_id]; - struct il_queue *q = &txq->q; - struct il_tx_info *tx_info; - - BUG_ON(txq_id == IL39_CMD_QUEUE_NUM); - - for (idx = il_queue_inc_wrap(idx, q->n_bd); - q->read_ptr != idx; - q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { - - tx_info = &txq->txb[txq->q.read_ptr]; - ieee80211_tx_status_irqsafe(il->hw, tx_info->skb); - tx_info->skb = NULL; - il->cfg->ops->lib->txq_free_tfd(il, txq); - } - - if (il_queue_space(q) > q->low_mark && txq_id >= 0 && - txq_id != IL39_CMD_QUEUE_NUM && il->mac80211_registered) - il_wake_queue(il, txq); -} - -/** - * il3945_rx_reply_tx - Handle Tx response - */ -static void il3945_rx_reply_tx(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - u16 sequence = le16_to_cpu(pkt->hdr.sequence); - int txq_id = SEQ_TO_QUEUE(sequence); - int idx = SEQ_TO_IDX(sequence); - struct il_tx_queue *txq = &il->txq[txq_id]; - struct ieee80211_tx_info *info; - struct il3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; - u32 status = le32_to_cpu(tx_resp->status); - int rate_idx; - int fail; - - if (idx >= txq->q.n_bd || il_queue_used(&txq->q, idx) == 0) { - IL_ERR("Read idx for DMA queue txq_id (%d) idx %d " - "is out of range [0-%d] %d %d\n", txq_id, - idx, txq->q.n_bd, txq->q.write_ptr, - txq->q.read_ptr); - return; - } - - txq->time_stamp = jiffies; - info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb); - ieee80211_tx_info_clear_status(info); - - /* Fill the MRR chain with some info about on-chip retransmissions */ - rate_idx = il3945_hwrate_to_plcp_idx(tx_resp->rate); - if (info->band == IEEE80211_BAND_5GHZ) - rate_idx -= IL_FIRST_OFDM_RATE; - - fail = tx_resp->failure_frame; - - info->status.rates[0].idx = rate_idx; - info->status.rates[0].count = fail + 1; /* add final attempt */ - - /* tx_status->rts_retry_count = tx_resp->failure_rts; */ - info->flags |= ((status & TX_STATUS_MSK) == TX_STATUS_SUCCESS) ? - IEEE80211_TX_STAT_ACK : 0; - - D_TX("Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", - txq_id, il3945_get_tx_fail_reason(status), status, - tx_resp->rate, tx_resp->failure_frame); - - D_TX_REPLY("Tx queue reclaim %d\n", idx); - il3945_tx_queue_reclaim(il, txq_id, idx); - - if (status & TX_ABORT_REQUIRED_MSK) - IL_ERR("TODO: Implement Tx ABORT REQUIRED!!!\n"); -} - - - -/***************************************************************************** - * - * Intel PRO/Wireless 3945ABG/BG Network Connection - * - * RX handler implementations - * - *****************************************************************************/ -#ifdef CONFIG_IWLEGACY_DEBUGFS -static void il3945_accumulative_stats(struct il_priv *il, - __le32 *stats) -{ - int i; - __le32 *prev_stats; - u32 *accum_stats; - u32 *delta, *max_delta; - - prev_stats = (__le32 *)&il->_3945.stats; - accum_stats = (u32 *)&il->_3945.accum_stats; - delta = (u32 *)&il->_3945.delta_stats; - max_delta = (u32 *)&il->_3945.max_delta; - - for (i = sizeof(__le32); i < sizeof(struct il3945_notif_stats); - i += sizeof(__le32), stats++, prev_stats++, delta++, - max_delta++, accum_stats++) { - if (le32_to_cpu(*stats) > le32_to_cpu(*prev_stats)) { - *delta = (le32_to_cpu(*stats) - - le32_to_cpu(*prev_stats)); - *accum_stats += *delta; - if (*delta > *max_delta) - *max_delta = *delta; - } - } - - /* reset accumulative stats for "no-counter" type stats */ - il->_3945.accum_stats.general.temperature = - il->_3945.stats.general.temperature; - il->_3945.accum_stats.general.ttl_timestamp = - il->_3945.stats.general.ttl_timestamp; -} -#endif - -void il3945_hw_rx_stats(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - - D_RX("Statistics notification received (%d vs %d).\n", - (int)sizeof(struct il3945_notif_stats), - le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK); -#ifdef CONFIG_IWLEGACY_DEBUGFS - il3945_accumulative_stats(il, (__le32 *)&pkt->u.raw); -#endif - - memcpy(&il->_3945.stats, pkt->u.raw, sizeof(il->_3945.stats)); -} - -void il3945_reply_stats(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - __le32 *flag = (__le32 *)&pkt->u.raw; - - if (le32_to_cpu(*flag) & UCODE_STATISTICS_CLEAR_MSK) { -#ifdef CONFIG_IWLEGACY_DEBUGFS - memset(&il->_3945.accum_stats, 0, - sizeof(struct il3945_notif_stats)); - memset(&il->_3945.delta_stats, 0, - sizeof(struct il3945_notif_stats)); - memset(&il->_3945.max_delta, 0, - sizeof(struct il3945_notif_stats)); -#endif - D_RX("Statistics have been cleared\n"); - } - il3945_hw_rx_stats(il, rxb); -} - - -/****************************************************************************** - * - * Misc. internal state and helper functions - * - ******************************************************************************/ - -/* This is necessary only for a number of stats, see the caller. */ -static int il3945_is_network_packet(struct il_priv *il, - struct ieee80211_hdr *header) -{ - /* Filter incoming packets to determine if they are targeted toward - * this network, discarding packets coming from ourselves */ - switch (il->iw_mode) { - case NL80211_IFTYPE_ADHOC: /* Header: Dest. | Source | BSSID */ - /* packets to our IBSS update information */ - return !compare_ether_addr(header->addr3, il->bssid); - case NL80211_IFTYPE_STATION: /* Header: Dest. | AP{BSSID} | Source */ - /* packets to our IBSS update information */ - return !compare_ether_addr(header->addr2, il->bssid); - default: - return 1; - } -} - -static void il3945_pass_packet_to_mac80211(struct il_priv *il, - struct il_rx_buf *rxb, - struct ieee80211_rx_status *stats) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)IL_RX_DATA(pkt); - struct il3945_rx_frame_hdr *rx_hdr = IL_RX_HDR(pkt); - struct il3945_rx_frame_end *rx_end = IL_RX_END(pkt); - u16 len = le16_to_cpu(rx_hdr->len); - struct sk_buff *skb; - __le16 fc = hdr->frame_control; - - /* We received data from the HW, so stop the watchdog */ - if (unlikely(len + IL39_RX_FRAME_SIZE > - PAGE_SIZE << il->hw_params.rx_page_order)) { - D_DROP("Corruption detected!\n"); - return; - } - - /* We only process data packets if the interface is open */ - if (unlikely(!il->is_open)) { - D_DROP( - "Dropping packet while interface is not open.\n"); - return; - } - - skb = dev_alloc_skb(128); - if (!skb) { - IL_ERR("dev_alloc_skb failed\n"); - return; - } - - if (!il3945_mod_params.sw_crypto) - il_set_decrypted_flag(il, - (struct ieee80211_hdr *)rxb_addr(rxb), - le32_to_cpu(rx_end->status), stats); - - skb_add_rx_frag(skb, 0, rxb->page, - (void *)rx_hdr->payload - (void *)pkt, len); - - il_update_stats(il, false, fc, len); - memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats)); - - ieee80211_rx(il->hw, skb); - il->alloc_rxb_page--; - rxb->page = NULL; -} - -#define IL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6) - -static void il3945_rx_reply_rx(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct ieee80211_hdr *header; - struct ieee80211_rx_status rx_status; - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il3945_rx_frame_stats *rx_stats = IL_RX_STATS(pkt); - struct il3945_rx_frame_hdr *rx_hdr = IL_RX_HDR(pkt); - struct il3945_rx_frame_end *rx_end = IL_RX_END(pkt); - u16 rx_stats_sig_avg __maybe_unused = le16_to_cpu(rx_stats->sig_avg); - u16 rx_stats_noise_diff __maybe_unused = le16_to_cpu(rx_stats->noise_diff); - u8 network_packet; - - rx_status.flag = 0; - rx_status.mactime = le64_to_cpu(rx_end->timestamp); - rx_status.band = (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? - IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; - rx_status.freq = - ieee80211_channel_to_frequency(le16_to_cpu(rx_hdr->channel), - rx_status.band); - - rx_status.rate_idx = il3945_hwrate_to_plcp_idx(rx_hdr->rate); - if (rx_status.band == IEEE80211_BAND_5GHZ) - rx_status.rate_idx -= IL_FIRST_OFDM_RATE; - - rx_status.antenna = (le16_to_cpu(rx_hdr->phy_flags) & - RX_RES_PHY_FLAGS_ANTENNA_MSK) >> 4; - - /* set the preamble flag if appropriate */ - if (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK) - rx_status.flag |= RX_FLAG_SHORTPRE; - - if ((unlikely(rx_stats->phy_count > 20))) { - D_DROP("dsp size out of range [0,20]: %d/n", - rx_stats->phy_count); - return; - } - - if (!(rx_end->status & RX_RES_STATUS_NO_CRC32_ERROR) || - !(rx_end->status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { - D_RX("Bad CRC or FIFO: 0x%08X.\n", rx_end->status); - return; - } - - - - /* Convert 3945's rssi indicator to dBm */ - rx_status.signal = rx_stats->rssi - IL39_RSSI_OFFSET; - - D_STATS("Rssi %d sig_avg %d noise_diff %d\n", - rx_status.signal, rx_stats_sig_avg, - rx_stats_noise_diff); - - header = (struct ieee80211_hdr *)IL_RX_DATA(pkt); - - network_packet = il3945_is_network_packet(il, header); - - D_STATS("[%c] %d RSSI:%d Signal:%u, Rate:%u\n", - network_packet ? '*' : ' ', - le16_to_cpu(rx_hdr->channel), - rx_status.signal, rx_status.signal, - rx_status.rate_idx); - - il_dbg_log_rx_data_frame(il, le16_to_cpu(rx_hdr->len), - header); - - if (network_packet) { - il->_3945.last_beacon_time = - le32_to_cpu(rx_end->beacon_timestamp); - il->_3945.last_tsf = le64_to_cpu(rx_end->timestamp); - il->_3945.last_rx_rssi = rx_status.signal; - } - - il3945_pass_packet_to_mac80211(il, rxb, &rx_status); -} - -int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, - struct il_tx_queue *txq, - dma_addr_t addr, u16 len, u8 reset, u8 pad) -{ - int count; - struct il_queue *q; - struct il3945_tfd *tfd, *tfd_tmp; - - q = &txq->q; - tfd_tmp = (struct il3945_tfd *)txq->tfds; - tfd = &tfd_tmp[q->write_ptr]; - - if (reset) - memset(tfd, 0, sizeof(*tfd)); - - count = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags)); - - if (count >= NUM_TFD_CHUNKS || count < 0) { - IL_ERR("Error can not send more than %d chunks\n", - NUM_TFD_CHUNKS); - return -EINVAL; - } - - tfd->tbs[count].addr = cpu_to_le32(addr); - tfd->tbs[count].len = cpu_to_le32(len); - - count++; - - tfd->control_flags = cpu_to_le32(TFD_CTL_COUNT_SET(count) | - TFD_CTL_PAD_SET(pad)); - - return 0; -} - -/** - * il3945_hw_txq_free_tfd - Free one TFD, those at idx [txq->q.read_ptr] - * - * Does NOT advance any idxes - */ -void il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) -{ - struct il3945_tfd *tfd_tmp = (struct il3945_tfd *)txq->tfds; - int idx = txq->q.read_ptr; - struct il3945_tfd *tfd = &tfd_tmp[idx]; - struct pci_dev *dev = il->pci_dev; - int i; - int counter; - - /* sanity check */ - counter = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags)); - if (counter > NUM_TFD_CHUNKS) { - IL_ERR("Too many chunks: %i\n", counter); - /* @todo issue fatal error, it is quite serious situation */ - return; - } - - /* Unmap tx_cmd */ - if (counter) - pci_unmap_single(dev, - dma_unmap_addr(&txq->meta[idx], mapping), - dma_unmap_len(&txq->meta[idx], len), - PCI_DMA_TODEVICE); - - /* unmap chunks if any */ - - for (i = 1; i < counter; i++) - pci_unmap_single(dev, le32_to_cpu(tfd->tbs[i].addr), - le32_to_cpu(tfd->tbs[i].len), PCI_DMA_TODEVICE); - - /* free SKB */ - if (txq->txb) { - struct sk_buff *skb; - - skb = txq->txb[txq->q.read_ptr].skb; - - /* can be called from irqs-disabled context */ - if (skb) { - dev_kfree_skb_any(skb); - txq->txb[txq->q.read_ptr].skb = NULL; - } - } -} - -/** - * il3945_hw_build_tx_cmd_rate - Add rate portion to TX_CMD: - * -*/ -void il3945_hw_build_tx_cmd_rate(struct il_priv *il, - struct il_device_cmd *cmd, - struct ieee80211_tx_info *info, - struct ieee80211_hdr *hdr, - int sta_id, int tx_id) -{ - u16 hw_value = ieee80211_get_tx_rate(il->hw, info)->hw_value; - u16 rate_idx = min(hw_value & 0xffff, RATE_COUNT_3945); - u16 rate_mask; - int rate; - u8 rts_retry_limit; - u8 data_retry_limit; - __le32 tx_flags; - __le16 fc = hdr->frame_control; - struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; - - rate = il3945_rates[rate_idx].plcp; - tx_flags = tx_cmd->tx_flags; - - /* We need to figure out how to get the sta->supp_rates while - * in this running context */ - rate_mask = RATES_MASK_3945; - - /* Set retry limit on DATA packets and Probe Responses*/ - if (ieee80211_is_probe_resp(fc)) - data_retry_limit = 3; - else - data_retry_limit = IL_DEFAULT_TX_RETRY; - tx_cmd->data_retry_limit = data_retry_limit; - - if (tx_id >= IL39_CMD_QUEUE_NUM) - rts_retry_limit = 3; - else - rts_retry_limit = 7; - - if (data_retry_limit < rts_retry_limit) - rts_retry_limit = data_retry_limit; - tx_cmd->rts_retry_limit = rts_retry_limit; - - tx_cmd->rate = rate; - tx_cmd->tx_flags = tx_flags; - - /* OFDM */ - tx_cmd->supp_rates[0] = - ((rate_mask & IL_OFDM_RATES_MASK) >> IL_FIRST_OFDM_RATE) & 0xFF; - - /* CCK */ - tx_cmd->supp_rates[1] = (rate_mask & 0xF); - - D_RATE("Tx sta id: %d, rate: %d (plcp), flags: 0x%4X " - "cck/ofdm mask: 0x%x/0x%x\n", sta_id, - tx_cmd->rate, le32_to_cpu(tx_cmd->tx_flags), - tx_cmd->supp_rates[1], tx_cmd->supp_rates[0]); -} - -static u8 il3945_sync_sta(struct il_priv *il, int sta_id, u16 tx_rate) -{ - unsigned long flags_spin; - struct il_station_entry *station; - - if (sta_id == IL_INVALID_STATION) - return IL_INVALID_STATION; - - spin_lock_irqsave(&il->sta_lock, flags_spin); - station = &il->stations[sta_id]; - - station->sta.sta.modify_mask = STA_MODIFY_TX_RATE_MSK; - station->sta.rate_n_flags = cpu_to_le16(tx_rate); - station->sta.mode = STA_CONTROL_MODIFY_MSK; - il_send_add_sta(il, &station->sta, CMD_ASYNC); - spin_unlock_irqrestore(&il->sta_lock, flags_spin); - - D_RATE("SCALE sync station %d to rate %d\n", - sta_id, tx_rate); - return sta_id; -} - -static void il3945_set_pwr_vmain(struct il_priv *il) -{ -/* - * (for documentation purposes) - * to set power to V_AUX, do - - if (pci_pme_capable(il->pci_dev, PCI_D3cold)) { - il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, - APMG_PS_CTRL_VAL_PWR_SRC_VAUX, - ~APMG_PS_CTRL_MSK_PWR_SRC); - - _il_poll_bit(il, CSR_GPIO_IN, - CSR_GPIO_IN_VAL_VAUX_PWR_SRC, - CSR_GPIO_IN_BIT_AUX_POWER, 5000); - } - */ - - il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, - APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, - ~APMG_PS_CTRL_MSK_PWR_SRC); - - _il_poll_bit(il, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC, - CSR_GPIO_IN_BIT_AUX_POWER, 5000); /* uS */ -} - -static int il3945_rx_init(struct il_priv *il, struct il_rx_queue *rxq) -{ - il_wr(il, FH39_RCSR_RBD_BASE(0), rxq->bd_dma); - il_wr(il, FH39_RCSR_RPTR_ADDR(0), - rxq->rb_stts_dma); - il_wr(il, FH39_RCSR_WPTR(0), 0); - il_wr(il, FH39_RCSR_CONFIG(0), - FH39_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE | - FH39_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE | - FH39_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN | - FH39_RCSR_RX_CONFIG_REG_VAL_MAX_FRAG_SIZE_128 | - (RX_QUEUE_SIZE_LOG << FH39_RCSR_RX_CONFIG_REG_POS_RBDC_SIZE) | - FH39_RCSR_RX_CONFIG_REG_VAL_IRQ_DEST_INT_HOST | - (1 << FH39_RCSR_RX_CONFIG_REG_POS_IRQ_RBTH) | - FH39_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH); - - /* fake read to flush all prev I/O */ - il_rd(il, FH39_RSSR_CTRL); - - return 0; -} - -static int il3945_tx_reset(struct il_priv *il) -{ - - /* bypass mode */ - il_wr_prph(il, ALM_SCD_MODE_REG, 0x2); - - /* RA 0 is active */ - il_wr_prph(il, ALM_SCD_ARASTAT_REG, 0x01); - - /* all 6 fifo are active */ - il_wr_prph(il, ALM_SCD_TXFACT_REG, 0x3f); - - il_wr_prph(il, ALM_SCD_SBYP_MODE_1_REG, 0x010000); - il_wr_prph(il, ALM_SCD_SBYP_MODE_2_REG, 0x030002); - il_wr_prph(il, ALM_SCD_TXF4MF_REG, 0x000004); - il_wr_prph(il, ALM_SCD_TXF5MF_REG, 0x000005); - - il_wr(il, FH39_TSSR_CBB_BASE, - il->_3945.shared_phys); - - il_wr(il, FH39_TSSR_MSG_CONFIG, - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON | - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON | - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B | - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON | - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON | - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH | - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH); - - - return 0; -} - -/** - * il3945_txq_ctx_reset - Reset TX queue context - * - * Destroys all DMA structures and initialize them again - */ -static int il3945_txq_ctx_reset(struct il_priv *il) -{ - int rc; - int txq_id, slots_num; - - il3945_hw_txq_ctx_free(il); - - /* allocate tx queue structure */ - rc = il_alloc_txq_mem(il); - if (rc) - return rc; - - /* Tx CMD queue */ - rc = il3945_tx_reset(il); - if (rc) - goto error; - - /* Tx queue(s) */ - for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { - slots_num = (txq_id == IL39_CMD_QUEUE_NUM) ? - TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - rc = il_tx_queue_init(il, &il->txq[txq_id], - slots_num, txq_id); - if (rc) { - IL_ERR("Tx %d queue init failed\n", txq_id); - goto error; - } - } - - return rc; - - error: - il3945_hw_txq_ctx_free(il); - return rc; -} - - -/* - * Start up 3945's basic functionality after it has been reset - * (e.g. after platform boot, or shutdown via il_apm_stop()) - * NOTE: This does not load uCode nor start the embedded processor - */ -static int il3945_apm_init(struct il_priv *il) -{ - int ret = il_apm_init(il); - - /* Clear APMG (NIC's internal power management) interrupts */ - il_wr_prph(il, APMG_RTC_INT_MSK_REG, 0x0); - il_wr_prph(il, APMG_RTC_INT_STT_REG, 0xFFFFFFFF); - - /* Reset radio chip */ - il_set_bits_prph(il, APMG_PS_CTRL_REG, - APMG_PS_CTRL_VAL_RESET_REQ); - udelay(5); - il_clear_bits_prph(il, APMG_PS_CTRL_REG, - APMG_PS_CTRL_VAL_RESET_REQ); - - return ret; -} - -static void il3945_nic_config(struct il_priv *il) -{ - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - unsigned long flags; - u8 rev_id = il->pci_dev->revision; - - spin_lock_irqsave(&il->lock, flags); - - /* Determine HW type */ - D_INFO("HW Revision ID = 0x%X\n", rev_id); - - if (rev_id & PCI_CFG_REV_ID_BIT_RTP) - D_INFO("RTP type\n"); - else if (rev_id & PCI_CFG_REV_ID_BIT_BASIC_SKU) { - D_INFO("3945 RADIO-MB type\n"); - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BIT_3945_MB); - } else { - D_INFO("3945 RADIO-MM type\n"); - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BIT_3945_MM); - } - - if (EEPROM_SKU_CAP_OP_MODE_MRC == eeprom->sku_cap) { - D_INFO("SKU OP mode is mrc\n"); - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BIT_SKU_MRC); - } else - D_INFO("SKU OP mode is basic\n"); - - if ((eeprom->board_revision & 0xF0) == 0xD0) { - D_INFO("3945ABG revision is 0x%X\n", - eeprom->board_revision); - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); - } else { - D_INFO("3945ABG revision is 0x%X\n", - eeprom->board_revision); - il_clear_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); - } - - if (eeprom->almgor_m_version <= 1) { - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A); - D_INFO("Card M type A version is 0x%X\n", - eeprom->almgor_m_version); - } else { - D_INFO("Card M type B version is 0x%X\n", - eeprom->almgor_m_version); - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B); - } - spin_unlock_irqrestore(&il->lock, flags); - - if (eeprom->sku_cap & EEPROM_SKU_CAP_SW_RF_KILL_ENABLE) - D_RF_KILL("SW RF KILL supported in EEPROM.\n"); - - if (eeprom->sku_cap & EEPROM_SKU_CAP_HW_RF_KILL_ENABLE) - D_RF_KILL("HW RF KILL supported in EEPROM.\n"); -} - -int il3945_hw_nic_init(struct il_priv *il) -{ - int rc; - unsigned long flags; - struct il_rx_queue *rxq = &il->rxq; - - spin_lock_irqsave(&il->lock, flags); - il->cfg->ops->lib->apm_ops.init(il); - spin_unlock_irqrestore(&il->lock, flags); - - il3945_set_pwr_vmain(il); - - il->cfg->ops->lib->apm_ops.config(il); - - /* Allocate the RX queue, or reset if it is already allocated */ - if (!rxq->bd) { - rc = il_rx_queue_alloc(il); - if (rc) { - IL_ERR("Unable to initialize Rx queue\n"); - return -ENOMEM; - } - } else - il3945_rx_queue_reset(il, rxq); - - il3945_rx_replenish(il); - - il3945_rx_init(il, rxq); - - - /* Look at using this instead: - rxq->need_update = 1; - il_rx_queue_update_write_ptr(il, rxq); - */ - - il_wr(il, FH39_RCSR_WPTR(0), rxq->write & ~7); - - rc = il3945_txq_ctx_reset(il); - if (rc) - return rc; - - set_bit(STATUS_INIT, &il->status); - - return 0; -} - -/** - * il3945_hw_txq_ctx_free - Free TXQ Context - * - * Destroy all TX DMA queues and structures - */ -void il3945_hw_txq_ctx_free(struct il_priv *il) -{ - int txq_id; - - /* Tx queues */ - if (il->txq) - for (txq_id = 0; txq_id < il->hw_params.max_txq_num; - txq_id++) - if (txq_id == IL39_CMD_QUEUE_NUM) - il_cmd_queue_free(il); - else - il_tx_queue_free(il, txq_id); - - /* free tx queue structure */ - il_txq_mem(il); -} - -void il3945_hw_txq_ctx_stop(struct il_priv *il) -{ - int txq_id; - - /* stop SCD */ - il_wr_prph(il, ALM_SCD_MODE_REG, 0); - il_wr_prph(il, ALM_SCD_TXFACT_REG, 0); - - /* reset TFD queues */ - for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { - il_wr(il, FH39_TCSR_CONFIG(txq_id), 0x0); - il_poll_bit(il, FH39_TSSR_TX_STATUS, - FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(txq_id), - 1000); - } - - il3945_hw_txq_ctx_free(il); -} - -/** - * il3945_hw_reg_adjust_power_by_temp - * return idx delta into power gain settings table -*/ -static int il3945_hw_reg_adjust_power_by_temp(int new_reading, int old_reading) -{ - return (new_reading - old_reading) * (-11) / 100; -} - -/** - * il3945_hw_reg_temp_out_of_range - Keep temperature in sane range - */ -static inline int il3945_hw_reg_temp_out_of_range(int temperature) -{ - return (temperature < -260 || temperature > 25) ? 1 : 0; -} - -int il3945_hw_get_temperature(struct il_priv *il) -{ - return _il_rd(il, CSR_UCODE_DRV_GP2); -} - -/** - * il3945_hw_reg_txpower_get_temperature - * get the current temperature by reading from NIC -*/ -static int il3945_hw_reg_txpower_get_temperature(struct il_priv *il) -{ - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - int temperature; - - temperature = il3945_hw_get_temperature(il); - - /* driver's okay range is -260 to +25. - * human readable okay range is 0 to +285 */ - D_INFO("Temperature: %d\n", temperature + IL_TEMP_CONVERT); - - /* handle insane temp reading */ - if (il3945_hw_reg_temp_out_of_range(temperature)) { - IL_ERR("Error bad temperature value %d\n", temperature); - - /* if really really hot(?), - * substitute the 3rd band/group's temp measured at factory */ - if (il->last_temperature > 100) - temperature = eeprom->groups[2].temperature; - else /* else use most recent "sane" value from driver */ - temperature = il->last_temperature; - } - - return temperature; /* raw, not "human readable" */ -} - -/* Adjust Txpower only if temperature variance is greater than threshold. - * - * Both are lower than older versions' 9 degrees */ -#define IL_TEMPERATURE_LIMIT_TIMER 6 - -/** - * il3945_is_temp_calib_needed - determines if new calibration is needed - * - * records new temperature in tx_mgr->temperature. - * replaces tx_mgr->last_temperature *only* if calib needed - * (assumes caller will actually do the calibration!). */ -static int il3945_is_temp_calib_needed(struct il_priv *il) -{ - int temp_diff; - - il->temperature = il3945_hw_reg_txpower_get_temperature(il); - temp_diff = il->temperature - il->last_temperature; - - /* get absolute value */ - if (temp_diff < 0) { - D_POWER("Getting cooler, delta %d,\n", temp_diff); - temp_diff = -temp_diff; - } else if (temp_diff == 0) - D_POWER("Same temp,\n"); - else - D_POWER("Getting warmer, delta %d,\n", temp_diff); - - /* if we don't need calibration, *don't* update last_temperature */ - if (temp_diff < IL_TEMPERATURE_LIMIT_TIMER) { - D_POWER("Timed thermal calib not needed\n"); - return 0; - } - - D_POWER("Timed thermal calib needed\n"); - - /* assume that caller will actually do calib ... - * update the "last temperature" value */ - il->last_temperature = il->temperature; - return 1; -} - -#define IL_MAX_GAIN_ENTRIES 78 -#define IL_CCK_FROM_OFDM_POWER_DIFF -5 -#define IL_CCK_FROM_OFDM_IDX_DIFF (10) - -/* radio and DSP power table, each step is 1/2 dB. - * 1st number is for RF analog gain, 2nd number is for DSP pre-DAC gain. */ -static struct il3945_tx_power power_gain_table[2][IL_MAX_GAIN_ENTRIES] = { - { - {251, 127}, /* 2.4 GHz, highest power */ - {251, 127}, - {251, 127}, - {251, 127}, - {251, 125}, - {251, 110}, - {251, 105}, - {251, 98}, - {187, 125}, - {187, 115}, - {187, 108}, - {187, 99}, - {243, 119}, - {243, 111}, - {243, 105}, - {243, 97}, - {243, 92}, - {211, 106}, - {211, 100}, - {179, 120}, - {179, 113}, - {179, 107}, - {147, 125}, - {147, 119}, - {147, 112}, - {147, 106}, - {147, 101}, - {147, 97}, - {147, 91}, - {115, 107}, - {235, 121}, - {235, 115}, - {235, 109}, - {203, 127}, - {203, 121}, - {203, 115}, - {203, 108}, - {203, 102}, - {203, 96}, - {203, 92}, - {171, 110}, - {171, 104}, - {171, 98}, - {139, 116}, - {227, 125}, - {227, 119}, - {227, 113}, - {227, 107}, - {227, 101}, - {227, 96}, - {195, 113}, - {195, 106}, - {195, 102}, - {195, 95}, - {163, 113}, - {163, 106}, - {163, 102}, - {163, 95}, - {131, 113}, - {131, 106}, - {131, 102}, - {131, 95}, - {99, 113}, - {99, 106}, - {99, 102}, - {99, 95}, - {67, 113}, - {67, 106}, - {67, 102}, - {67, 95}, - {35, 113}, - {35, 106}, - {35, 102}, - {35, 95}, - {3, 113}, - {3, 106}, - {3, 102}, - {3, 95} }, /* 2.4 GHz, lowest power */ - { - {251, 127}, /* 5.x GHz, highest power */ - {251, 120}, - {251, 114}, - {219, 119}, - {219, 101}, - {187, 113}, - {187, 102}, - {155, 114}, - {155, 103}, - {123, 117}, - {123, 107}, - {123, 99}, - {123, 92}, - {91, 108}, - {59, 125}, - {59, 118}, - {59, 109}, - {59, 102}, - {59, 96}, - {59, 90}, - {27, 104}, - {27, 98}, - {27, 92}, - {115, 118}, - {115, 111}, - {115, 104}, - {83, 126}, - {83, 121}, - {83, 113}, - {83, 105}, - {83, 99}, - {51, 118}, - {51, 111}, - {51, 104}, - {51, 98}, - {19, 116}, - {19, 109}, - {19, 102}, - {19, 98}, - {19, 93}, - {171, 113}, - {171, 107}, - {171, 99}, - {139, 120}, - {139, 113}, - {139, 107}, - {139, 99}, - {107, 120}, - {107, 113}, - {107, 107}, - {107, 99}, - {75, 120}, - {75, 113}, - {75, 107}, - {75, 99}, - {43, 120}, - {43, 113}, - {43, 107}, - {43, 99}, - {11, 120}, - {11, 113}, - {11, 107}, - {11, 99}, - {131, 107}, - {131, 99}, - {99, 120}, - {99, 113}, - {99, 107}, - {99, 99}, - {67, 120}, - {67, 113}, - {67, 107}, - {67, 99}, - {35, 120}, - {35, 113}, - {35, 107}, - {35, 99}, - {3, 120} } /* 5.x GHz, lowest power */ -}; - -static inline u8 il3945_hw_reg_fix_power_idx(int idx) -{ - if (idx < 0) - return 0; - if (idx >= IL_MAX_GAIN_ENTRIES) - return IL_MAX_GAIN_ENTRIES - 1; - return (u8) idx; -} - -/* Kick off thermal recalibration check every 60 seconds */ -#define REG_RECALIB_PERIOD (60) - -/** - * il3945_hw_reg_set_scan_power - Set Tx power for scan probe requests - * - * Set (in our channel info database) the direct scan Tx power for 1 Mbit (CCK) - * or 6 Mbit (OFDM) rates. - */ -static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_idx, - s32 rate_idx, const s8 *clip_pwrs, - struct il_channel_info *ch_info, - int band_idx) -{ - struct il3945_scan_power_info *scan_power_info; - s8 power; - u8 power_idx; - - scan_power_info = &ch_info->scan_pwr_info[scan_tbl_idx]; - - /* use this channel group's 6Mbit clipping/saturation pwr, - * but cap at regulatory scan power restriction (set during init - * based on eeprom channel data) for this channel. */ - power = min(ch_info->scan_power, clip_pwrs[RATE_6M_IDX_TBL]); - - power = min(power, il->tx_power_user_lmt); - scan_power_info->requested_power = power; - - /* find difference between new scan *power* and current "normal" - * Tx *power* for 6Mb. Use this difference (x2) to adjust the - * current "normal" temperature-compensated Tx power *idx* for - * this rate (1Mb or 6Mb) to yield new temp-compensated scan power - * *idx*. */ - power_idx = ch_info->power_info[rate_idx].power_table_idx - - (power - ch_info->power_info - [RATE_6M_IDX_TBL].requested_power) * 2; - - /* store reference idx that we use when adjusting *all* scan - * powers. So we can accommodate user (all channel) or spectrum - * management (single channel) power changes "between" temperature - * feedback compensation procedures. - * don't force fit this reference idx into gain table; it may be a - * negative number. This will help avoid errors when we're at - * the lower bounds (highest gains, for warmest temperatures) - * of the table. */ - - /* don't exceed table bounds for "real" setting */ - power_idx = il3945_hw_reg_fix_power_idx(power_idx); - - scan_power_info->power_table_idx = power_idx; - scan_power_info->tpc.tx_gain = - power_gain_table[band_idx][power_idx].tx_gain; - scan_power_info->tpc.dsp_atten = - power_gain_table[band_idx][power_idx].dsp_atten; -} - -/** - * il3945_send_tx_power - fill in Tx Power command with gain settings - * - * Configures power settings for all rates for the current channel, - * using values from channel info struct, and send to NIC - */ -static int il3945_send_tx_power(struct il_priv *il) -{ - int rate_idx, i; - const struct il_channel_info *ch_info = NULL; - struct il3945_txpowertable_cmd txpower = { - .channel = il->ctx.active.channel, - }; - u16 chan; - - if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &il->status), - "TX Power requested while scanning!\n")) - return -EAGAIN; - - chan = le16_to_cpu(il->ctx.active.channel); - - txpower.band = (il->band == IEEE80211_BAND_5GHZ) ? 0 : 1; - ch_info = il_get_channel_info(il, il->band, chan); - if (!ch_info) { - IL_ERR( - "Failed to get channel info for channel %d [%d]\n", - chan, il->band); - return -EINVAL; - } - - if (!il_is_channel_valid(ch_info)) { - D_POWER("Not calling TX_PWR_TBL_CMD on " - "non-Tx channel.\n"); - return 0; - } - - /* fill cmd with power settings for all rates for current channel */ - /* Fill OFDM rate */ - for (rate_idx = IL_FIRST_OFDM_RATE, i = 0; - rate_idx <= IL39_LAST_OFDM_RATE; rate_idx++, i++) { - - txpower.power[i].tpc = ch_info->power_info[i].tpc; - txpower.power[i].rate = il3945_rates[rate_idx].plcp; - - D_POWER("ch %d:%d rf %d dsp %3d rate code 0x%02x\n", - le16_to_cpu(txpower.channel), - txpower.band, - txpower.power[i].tpc.tx_gain, - txpower.power[i].tpc.dsp_atten, - txpower.power[i].rate); - } - /* Fill CCK rates */ - for (rate_idx = IL_FIRST_CCK_RATE; - rate_idx <= IL_LAST_CCK_RATE; rate_idx++, i++) { - txpower.power[i].tpc = ch_info->power_info[i].tpc; - txpower.power[i].rate = il3945_rates[rate_idx].plcp; - - D_POWER("ch %d:%d rf %d dsp %3d rate code 0x%02x\n", - le16_to_cpu(txpower.channel), - txpower.band, - txpower.power[i].tpc.tx_gain, - txpower.power[i].tpc.dsp_atten, - txpower.power[i].rate); - } - - return il_send_cmd_pdu(il, REPLY_TX_PWR_TBL_CMD, - sizeof(struct il3945_txpowertable_cmd), - &txpower); - -} - -/** - * il3945_hw_reg_set_new_power - Configures power tables at new levels - * @ch_info: Channel to update. Uses power_info.requested_power. - * - * Replace requested_power and base_power_idx ch_info fields for - * one channel. - * - * Called if user or spectrum management changes power preferences. - * Takes into account h/w and modulation limitations (clip power). - * - * This does *not* send anything to NIC, just sets up ch_info for one channel. - * - * NOTE: reg_compensate_for_temperature_dif() *must* be run after this to - * properly fill out the scan powers, and actual h/w gain settings, - * and send changes to NIC - */ -static int il3945_hw_reg_set_new_power(struct il_priv *il, - struct il_channel_info *ch_info) -{ - struct il3945_channel_power_info *power_info; - int power_changed = 0; - int i; - const s8 *clip_pwrs; - int power; - - /* Get this chnlgrp's rate-to-max/clip-powers table */ - clip_pwrs = il->_3945.clip_groups[ch_info->group_idx].clip_powers; - - /* Get this channel's rate-to-current-power settings table */ - power_info = ch_info->power_info; - - /* update OFDM Txpower settings */ - for (i = RATE_6M_IDX_TBL; i <= RATE_54M_IDX_TBL; - i++, ++power_info) { - int delta_idx; - - /* limit new power to be no more than h/w capability */ - power = min(ch_info->curr_txpow, clip_pwrs[i]); - if (power == power_info->requested_power) - continue; - - /* find difference between old and new requested powers, - * update base (non-temp-compensated) power idx */ - delta_idx = (power - power_info->requested_power) * 2; - power_info->base_power_idx -= delta_idx; - - /* save new requested power value */ - power_info->requested_power = power; - - power_changed = 1; - } - - /* update CCK Txpower settings, based on OFDM 12M setting ... - * ... all CCK power settings for a given channel are the *same*. */ - if (power_changed) { - power = - ch_info->power_info[RATE_12M_IDX_TBL]. - requested_power + IL_CCK_FROM_OFDM_POWER_DIFF; - - /* do all CCK rates' il3945_channel_power_info structures */ - for (i = RATE_1M_IDX_TBL; i <= RATE_11M_IDX_TBL; i++) { - power_info->requested_power = power; - power_info->base_power_idx = - ch_info->power_info[RATE_12M_IDX_TBL]. - base_power_idx + IL_CCK_FROM_OFDM_IDX_DIFF; - ++power_info; - } - } - - return 0; -} - -/** - * il3945_hw_reg_get_ch_txpower_limit - returns new power limit for channel - * - * NOTE: Returned power limit may be less (but not more) than requested, - * based strictly on regulatory (eeprom and spectrum mgt) limitations - * (no consideration for h/w clipping limitations). - */ -static int il3945_hw_reg_get_ch_txpower_limit(struct il_channel_info *ch_info) -{ - s8 max_power; - -#if 0 - /* if we're using TGd limits, use lower of TGd or EEPROM */ - if (ch_info->tgd_data.max_power != 0) - max_power = min(ch_info->tgd_data.max_power, - ch_info->eeprom.max_power_avg); - - /* else just use EEPROM limits */ - else -#endif - max_power = ch_info->eeprom.max_power_avg; - - return min(max_power, ch_info->max_power_avg); -} - -/** - * il3945_hw_reg_comp_txpower_temp - Compensate for temperature - * - * Compensate txpower settings of *all* channels for temperature. - * This only accounts for the difference between current temperature - * and the factory calibration temperatures, and bases the new settings - * on the channel's base_power_idx. - * - * If RxOn is "associated", this sends the new Txpower to NIC! - */ -static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) -{ - struct il_channel_info *ch_info = NULL; - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - int delta_idx; - const s8 *clip_pwrs; /* array of h/w max power levels for each rate */ - u8 a_band; - u8 rate_idx; - u8 scan_tbl_idx; - u8 i; - int ref_temp; - int temperature = il->temperature; - - if (il->disable_tx_power_cal || - test_bit(STATUS_SCANNING, &il->status)) { - /* do not perform tx power calibration */ - return 0; - } - /* set up new Tx power info for each and every channel, 2.4 and 5.x */ - for (i = 0; i < il->channel_count; i++) { - ch_info = &il->channel_info[i]; - a_band = il_is_channel_a_band(ch_info); - - /* Get this chnlgrp's factory calibration temperature */ - ref_temp = (s16)eeprom->groups[ch_info->group_idx]. - temperature; - - /* get power idx adjustment based on current and factory - * temps */ - delta_idx = il3945_hw_reg_adjust_power_by_temp(temperature, - ref_temp); - - /* set tx power value for all rates, OFDM and CCK */ - for (rate_idx = 0; rate_idx < RATE_COUNT_3945; - rate_idx++) { - int power_idx = - ch_info->power_info[rate_idx].base_power_idx; - - /* temperature compensate */ - power_idx += delta_idx; - - /* stay within table range */ - power_idx = il3945_hw_reg_fix_power_idx(power_idx); - ch_info->power_info[rate_idx]. - power_table_idx = (u8) power_idx; - ch_info->power_info[rate_idx].tpc = - power_gain_table[a_band][power_idx]; - } - - /* Get this chnlgrp's rate-to-max/clip-powers table */ - clip_pwrs = il->_3945.clip_groups[ch_info->group_idx].clip_powers; - - /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */ - for (scan_tbl_idx = 0; - scan_tbl_idx < IL_NUM_SCAN_RATES; scan_tbl_idx++) { - s32 actual_idx = (scan_tbl_idx == 0) ? - RATE_1M_IDX_TBL : RATE_6M_IDX_TBL; - il3945_hw_reg_set_scan_power(il, scan_tbl_idx, - actual_idx, clip_pwrs, - ch_info, a_band); - } - } - - /* send Txpower command for current channel to ucode */ - return il->cfg->ops->lib->send_tx_power(il); -} - -int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power) -{ - struct il_channel_info *ch_info; - s8 max_power; - u8 a_band; - u8 i; - - if (il->tx_power_user_lmt == power) { - D_POWER("Requested Tx power same as current " - "limit: %ddBm.\n", power); - return 0; - } - - D_POWER("Setting upper limit clamp to %ddBm.\n", power); - il->tx_power_user_lmt = power; - - /* set up new Tx powers for each and every channel, 2.4 and 5.x */ - - for (i = 0; i < il->channel_count; i++) { - ch_info = &il->channel_info[i]; - a_band = il_is_channel_a_band(ch_info); - - /* find minimum power of all user and regulatory constraints - * (does not consider h/w clipping limitations) */ - max_power = il3945_hw_reg_get_ch_txpower_limit(ch_info); - max_power = min(power, max_power); - if (max_power != ch_info->curr_txpow) { - ch_info->curr_txpow = max_power; - - /* this considers the h/w clipping limitations */ - il3945_hw_reg_set_new_power(il, ch_info); - } - } - - /* update txpower settings for all channels, - * send to NIC if associated. */ - il3945_is_temp_calib_needed(il); - il3945_hw_reg_comp_txpower_temp(il); - - return 0; -} - -static int il3945_send_rxon_assoc(struct il_priv *il, - struct il_rxon_context *ctx) -{ - int rc = 0; - struct il_rx_pkt *pkt; - struct il3945_rxon_assoc_cmd rxon_assoc; - struct il_host_cmd cmd = { - .id = REPLY_RXON_ASSOC, - .len = sizeof(rxon_assoc), - .flags = CMD_WANT_SKB, - .data = &rxon_assoc, - }; - const struct il_rxon_cmd *rxon1 = &ctx->staging; - const struct il_rxon_cmd *rxon2 = &ctx->active; - - if (rxon1->flags == rxon2->flags && - rxon1->filter_flags == rxon2->filter_flags && - rxon1->cck_basic_rates == rxon2->cck_basic_rates && - rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates) { - D_INFO("Using current RXON_ASSOC. Not resending.\n"); - return 0; - } - - rxon_assoc.flags = ctx->staging.flags; - rxon_assoc.filter_flags = ctx->staging.filter_flags; - rxon_assoc.ofdm_basic_rates = ctx->staging.ofdm_basic_rates; - rxon_assoc.cck_basic_rates = ctx->staging.cck_basic_rates; - rxon_assoc.reserved = 0; - - rc = il_send_cmd_sync(il, &cmd); - if (rc) - return rc; - - pkt = (struct il_rx_pkt *)cmd.reply_page; - if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR("Bad return from REPLY_RXON_ASSOC command\n"); - rc = -EIO; - } - - il_free_pages(il, cmd.reply_page); - - return rc; -} - -/** - * il3945_commit_rxon - commit staging_rxon to hardware - * - * The RXON command in staging_rxon is committed to the hardware and - * the active_rxon structure is updated with the new data. This - * function correctly transitions out of the RXON_ASSOC_MSK state if - * a HW tune is required based on the RXON structure changes. - */ -int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) -{ - /* cast away the const for active_rxon in this function */ - struct il3945_rxon_cmd *active_rxon = (void *)&ctx->active; - struct il3945_rxon_cmd *staging_rxon = (void *)&ctx->staging; - int rc = 0; - bool new_assoc = !!(staging_rxon->filter_flags & RXON_FILTER_ASSOC_MSK); - - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - return -EINVAL; - - if (!il_is_alive(il)) - return -1; - - /* always get timestamp with Rx frame */ - staging_rxon->flags |= RXON_FLG_TSF2HOST_MSK; - - /* select antenna */ - staging_rxon->flags &= - ~(RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_SEL_MSK); - staging_rxon->flags |= il3945_get_antenna_flags(il); - - rc = il_check_rxon_cmd(il, ctx); - if (rc) { - IL_ERR("Invalid RXON configuration. Not committing.\n"); - return -EINVAL; - } - - /* If we don't need to send a full RXON, we can use - * il3945_rxon_assoc_cmd which is used to reconfigure filter - * and other flags for the current radio configuration. */ - if (!il_full_rxon_required(il, - &il->ctx)) { - rc = il_send_rxon_assoc(il, - &il->ctx); - if (rc) { - IL_ERR("Error setting RXON_ASSOC " - "configuration (%d).\n", rc); - return rc; - } - - memcpy(active_rxon, staging_rxon, sizeof(*active_rxon)); - /* - * We do not commit tx power settings while channel changing, - * do it now if tx power changed. - */ - il_set_tx_power(il, il->tx_power_next, false); - return 0; - } - - /* If we are currently associated and the new config requires - * an RXON_ASSOC and the new config wants the associated mask enabled, - * we must clear the associated from the active configuration - * before we apply the new config */ - if (il_is_associated(il) && new_assoc) { - D_INFO("Toggling associated bit on current RXON\n"); - active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; - - /* - * reserved4 and 5 could have been filled by the iwlcore code. - * Let's clear them before pushing to the 3945. - */ - active_rxon->reserved4 = 0; - active_rxon->reserved5 = 0; - rc = il_send_cmd_pdu(il, REPLY_RXON, - sizeof(struct il3945_rxon_cmd), - &il->ctx.active); - - /* If the mask clearing failed then we set - * active_rxon back to what it was previously */ - if (rc) { - active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK; - IL_ERR("Error clearing ASSOC_MSK on current " - "configuration (%d).\n", rc); - return rc; - } - il_clear_ucode_stations(il, - &il->ctx); - il_restore_stations(il, - &il->ctx); - } - - D_INFO("Sending RXON\n" - "* with%s RXON_FILTER_ASSOC_MSK\n" - "* channel = %d\n" - "* bssid = %pM\n", - (new_assoc ? "" : "out"), - le16_to_cpu(staging_rxon->channel), - staging_rxon->bssid_addr); - - /* - * reserved4 and 5 could have been filled by the iwlcore code. - * Let's clear them before pushing to the 3945. - */ - staging_rxon->reserved4 = 0; - staging_rxon->reserved5 = 0; - - il_set_rxon_hwcrypto(il, ctx, !il3945_mod_params.sw_crypto); - - /* Apply the new configuration */ - rc = il_send_cmd_pdu(il, REPLY_RXON, - sizeof(struct il3945_rxon_cmd), - staging_rxon); - if (rc) { - IL_ERR("Error setting new configuration (%d).\n", rc); - return rc; - } - - memcpy(active_rxon, staging_rxon, sizeof(*active_rxon)); - - if (!new_assoc) { - il_clear_ucode_stations(il, - &il->ctx); - il_restore_stations(il, - &il->ctx); - } - - /* If we issue a new RXON command which required a tune then we must - * send a new TXPOWER command or we won't be able to Tx any frames */ - rc = il_set_tx_power(il, il->tx_power_next, true); - if (rc) { - IL_ERR("Error setting Tx power (%d).\n", rc); - return rc; - } - - /* Init the hardware's rate fallback order based on the band */ - rc = il3945_init_hw_rate_table(il); - if (rc) { - IL_ERR("Error setting HW rate table: %02X\n", rc); - return -EIO; - } - - return 0; -} - -/** - * il3945_reg_txpower_periodic - called when time to check our temperature. - * - * -- reset periodic timer - * -- see if temp has changed enough to warrant re-calibration ... if so: - * -- correct coeffs for temp (can reset temp timer) - * -- save this temp as "last", - * -- send new set of gain settings to NIC - * NOTE: This should continue working, even when we're not associated, - * so we can keep our internal table of scan powers current. */ -void il3945_reg_txpower_periodic(struct il_priv *il) -{ - /* This will kick in the "brute force" - * il3945_hw_reg_comp_txpower_temp() below */ - if (!il3945_is_temp_calib_needed(il)) - goto reschedule; - - /* Set up a new set of temp-adjusted TxPowers, send to NIC. - * This is based *only* on current temperature, - * ignoring any previous power measurements */ - il3945_hw_reg_comp_txpower_temp(il); - - reschedule: - queue_delayed_work(il->workqueue, - &il->_3945.thermal_periodic, REG_RECALIB_PERIOD * HZ); -} - -static void il3945_bg_reg_txpower_periodic(struct work_struct *work) -{ - struct il_priv *il = container_of(work, struct il_priv, - _3945.thermal_periodic.work); - - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - return; - - mutex_lock(&il->mutex); - il3945_reg_txpower_periodic(il); - mutex_unlock(&il->mutex); -} - -/** - * il3945_hw_reg_get_ch_grp_idx - find the channel-group idx (0-4) - * for the channel. - * - * This function is used when initializing channel-info structs. - * - * NOTE: These channel groups do *NOT* match the bands above! - * These channel groups are based on factory-tested channels; - * on A-band, EEPROM's "group frequency" entries represent the top - * channel in each group 1-4. Group 5 All B/G channels are in group 0. - */ -static u16 il3945_hw_reg_get_ch_grp_idx(struct il_priv *il, - const struct il_channel_info *ch_info) -{ - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - struct il3945_eeprom_txpower_group *ch_grp = &eeprom->groups[0]; - u8 group; - u16 group_idx = 0; /* based on factory calib frequencies */ - u8 grp_channel; - - /* Find the group idx for the channel ... don't use idx 1(?) */ - if (il_is_channel_a_band(ch_info)) { - for (group = 1; group < 5; group++) { - grp_channel = ch_grp[group].group_channel; - if (ch_info->channel <= grp_channel) { - group_idx = group; - break; - } - } - /* group 4 has a few channels *above* its factory cal freq */ - if (group == 5) - group_idx = 4; - } else - group_idx = 0; /* 2.4 GHz, group 0 */ - - D_POWER("Chnl %d mapped to grp %d\n", ch_info->channel, - group_idx); - return group_idx; -} - -/** - * il3945_hw_reg_get_matched_power_idx - Interpolate to get nominal idx - * - * Interpolate to get nominal (i.e. at factory calibration temperature) idx - * into radio/DSP gain settings table for requested power. - */ -static int il3945_hw_reg_get_matched_power_idx(struct il_priv *il, - s8 requested_power, - s32 setting_idx, s32 *new_idx) -{ - const struct il3945_eeprom_txpower_group *chnl_grp = NULL; - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - s32 idx0, idx1; - s32 power = 2 * requested_power; - s32 i; - const struct il3945_eeprom_txpower_sample *samples; - s32 gains0, gains1; - s32 res; - s32 denominator; - - chnl_grp = &eeprom->groups[setting_idx]; - samples = chnl_grp->samples; - for (i = 0; i < 5; i++) { - if (power == samples[i].power) { - *new_idx = samples[i].gain_idx; - return 0; - } - } - - if (power > samples[1].power) { - idx0 = 0; - idx1 = 1; - } else if (power > samples[2].power) { - idx0 = 1; - idx1 = 2; - } else if (power > samples[3].power) { - idx0 = 2; - idx1 = 3; - } else { - idx0 = 3; - idx1 = 4; - } - - denominator = (s32) samples[idx1].power - (s32) samples[idx0].power; - if (denominator == 0) - return -EINVAL; - gains0 = (s32) samples[idx0].gain_idx * (1 << 19); - gains1 = (s32) samples[idx1].gain_idx * (1 << 19); - res = gains0 + (gains1 - gains0) * - ((s32) power - (s32) samples[idx0].power) / denominator + - (1 << 18); - *new_idx = res >> 19; - return 0; -} - -static void il3945_hw_reg_init_channel_groups(struct il_priv *il) -{ - u32 i; - s32 rate_idx; - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - const struct il3945_eeprom_txpower_group *group; - - D_POWER("Initializing factory calib info from EEPROM\n"); - - for (i = 0; i < IL_NUM_TX_CALIB_GROUPS; i++) { - s8 *clip_pwrs; /* table of power levels for each rate */ - s8 satur_pwr; /* saturation power for each chnl group */ - group = &eeprom->groups[i]; - - /* sanity check on factory saturation power value */ - if (group->saturation_power < 40) { - IL_WARN("Error: saturation power is %d, " - "less than minimum expected 40\n", - group->saturation_power); - return; - } - - /* - * Derive requested power levels for each rate, based on - * hardware capabilities (saturation power for band). - * Basic value is 3dB down from saturation, with further - * power reductions for highest 3 data rates. These - * backoffs provide headroom for high rate modulation - * power peaks, without too much distortion (clipping). - */ - /* we'll fill in this array with h/w max power levels */ - clip_pwrs = (s8 *) il->_3945.clip_groups[i].clip_powers; - - /* divide factory saturation power by 2 to find -3dB level */ - satur_pwr = (s8) (group->saturation_power >> 1); - - /* fill in channel group's nominal powers for each rate */ - for (rate_idx = 0; - rate_idx < RATE_COUNT_3945; rate_idx++, clip_pwrs++) { - switch (rate_idx) { - case RATE_36M_IDX_TBL: - if (i == 0) /* B/G */ - *clip_pwrs = satur_pwr; - else /* A */ - *clip_pwrs = satur_pwr - 5; - break; - case RATE_48M_IDX_TBL: - if (i == 0) - *clip_pwrs = satur_pwr - 7; - else - *clip_pwrs = satur_pwr - 10; - break; - case RATE_54M_IDX_TBL: - if (i == 0) - *clip_pwrs = satur_pwr - 9; - else - *clip_pwrs = satur_pwr - 12; - break; - default: - *clip_pwrs = satur_pwr; - break; - } - } - } -} - -/** - * il3945_txpower_set_from_eeprom - Set channel power info based on EEPROM - * - * Second pass (during init) to set up il->channel_info - * - * Set up Tx-power settings in our channel info database for each VALID - * (for this geo/SKU) channel, at all Tx data rates, based on eeprom values - * and current temperature. - * - * Since this is based on current temperature (at init time), these values may - * not be valid for very long, but it gives us a starting/default point, - * and allows us to active (i.e. using Tx) scan. - * - * This does *not* write values to NIC, just sets up our internal table. - */ -int il3945_txpower_set_from_eeprom(struct il_priv *il) -{ - struct il_channel_info *ch_info = NULL; - struct il3945_channel_power_info *pwr_info; - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - int delta_idx; - u8 rate_idx; - u8 scan_tbl_idx; - const s8 *clip_pwrs; /* array of power levels for each rate */ - u8 gain, dsp_atten; - s8 power; - u8 pwr_idx, base_pwr_idx, a_band; - u8 i; - int temperature; - - /* save temperature reference, - * so we can determine next time to calibrate */ - temperature = il3945_hw_reg_txpower_get_temperature(il); - il->last_temperature = temperature; - - il3945_hw_reg_init_channel_groups(il); - - /* initialize Tx power info for each and every channel, 2.4 and 5.x */ - for (i = 0, ch_info = il->channel_info; i < il->channel_count; - i++, ch_info++) { - a_band = il_is_channel_a_band(ch_info); - if (!il_is_channel_valid(ch_info)) - continue; - - /* find this channel's channel group (*not* "band") idx */ - ch_info->group_idx = - il3945_hw_reg_get_ch_grp_idx(il, ch_info); - - /* Get this chnlgrp's rate->max/clip-powers table */ - clip_pwrs = il->_3945.clip_groups[ch_info->group_idx].clip_powers; - - /* calculate power idx *adjustment* value according to - * diff between current temperature and factory temperature */ - delta_idx = il3945_hw_reg_adjust_power_by_temp(temperature, - eeprom->groups[ch_info->group_idx]. - temperature); - - D_POWER("Delta idx for channel %d: %d [%d]\n", - ch_info->channel, delta_idx, temperature + - IL_TEMP_CONVERT); - - /* set tx power value for all OFDM rates */ - for (rate_idx = 0; rate_idx < IL_OFDM_RATES; - rate_idx++) { - s32 uninitialized_var(power_idx); - int rc; - - /* use channel group's clip-power table, - * but don't exceed channel's max power */ - s8 pwr = min(ch_info->max_power_avg, - clip_pwrs[rate_idx]); - - pwr_info = &ch_info->power_info[rate_idx]; - - /* get base (i.e. at factory-measured temperature) - * power table idx for this rate's power */ - rc = il3945_hw_reg_get_matched_power_idx(il, pwr, - ch_info->group_idx, - &power_idx); - if (rc) { - IL_ERR("Invalid power idx\n"); - return rc; - } - pwr_info->base_power_idx = (u8) power_idx; - - /* temperature compensate */ - power_idx += delta_idx; - - /* stay within range of gain table */ - power_idx = il3945_hw_reg_fix_power_idx(power_idx); - - /* fill 1 OFDM rate's il3945_channel_power_info struct */ - pwr_info->requested_power = pwr; - pwr_info->power_table_idx = (u8) power_idx; - pwr_info->tpc.tx_gain = - power_gain_table[a_band][power_idx].tx_gain; - pwr_info->tpc.dsp_atten = - power_gain_table[a_band][power_idx].dsp_atten; - } - - /* set tx power for CCK rates, based on OFDM 12 Mbit settings*/ - pwr_info = &ch_info->power_info[RATE_12M_IDX_TBL]; - power = pwr_info->requested_power + - IL_CCK_FROM_OFDM_POWER_DIFF; - pwr_idx = pwr_info->power_table_idx + - IL_CCK_FROM_OFDM_IDX_DIFF; - base_pwr_idx = pwr_info->base_power_idx + - IL_CCK_FROM_OFDM_IDX_DIFF; - - /* stay within table range */ - pwr_idx = il3945_hw_reg_fix_power_idx(pwr_idx); - gain = power_gain_table[a_band][pwr_idx].tx_gain; - dsp_atten = power_gain_table[a_band][pwr_idx].dsp_atten; - - /* fill each CCK rate's il3945_channel_power_info structure - * NOTE: All CCK-rate Txpwrs are the same for a given chnl! - * NOTE: CCK rates start at end of OFDM rates! */ - for (rate_idx = 0; - rate_idx < IL_CCK_RATES; rate_idx++) { - pwr_info = &ch_info->power_info[rate_idx+IL_OFDM_RATES]; - pwr_info->requested_power = power; - pwr_info->power_table_idx = pwr_idx; - pwr_info->base_power_idx = base_pwr_idx; - pwr_info->tpc.tx_gain = gain; - pwr_info->tpc.dsp_atten = dsp_atten; - } - - /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */ - for (scan_tbl_idx = 0; - scan_tbl_idx < IL_NUM_SCAN_RATES; scan_tbl_idx++) { - s32 actual_idx = (scan_tbl_idx == 0) ? - RATE_1M_IDX_TBL : RATE_6M_IDX_TBL; - il3945_hw_reg_set_scan_power(il, scan_tbl_idx, - actual_idx, clip_pwrs, ch_info, a_band); - } - } - - return 0; -} - -int il3945_hw_rxq_stop(struct il_priv *il) -{ - int rc; - - il_wr(il, FH39_RCSR_CONFIG(0), 0); - rc = il_poll_bit(il, FH39_RSSR_STATUS, - FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); - if (rc < 0) - IL_ERR("Can't stop Rx DMA.\n"); - - return 0; -} - -int il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq) -{ - int txq_id = txq->q.id; - - struct il3945_shared *shared_data = il->_3945.shared_virt; - - shared_data->tx_base_ptr[txq_id] = cpu_to_le32((u32)txq->q.dma_addr); - - il_wr(il, FH39_CBCC_CTRL(txq_id), 0); - il_wr(il, FH39_CBCC_BASE(txq_id), 0); - - il_wr(il, FH39_TCSR_CONFIG(txq_id), - FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT | - FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF | - FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD | - FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL | - FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE); - - /* fake read to flush all prev. writes */ - _il_rd(il, FH39_TSSR_CBB_BASE); - - return 0; -} - -/* - * HCMD utils - */ -static u16 il3945_get_hcmd_size(u8 cmd_id, u16 len) -{ - switch (cmd_id) { - case REPLY_RXON: - return sizeof(struct il3945_rxon_cmd); - case POWER_TBL_CMD: - return sizeof(struct il3945_powertable_cmd); - default: - return len; - } -} - - -static u16 il3945_build_addsta_hcmd(const struct il_addsta_cmd *cmd, - u8 *data) -{ - struct il3945_addsta_cmd *addsta = (struct il3945_addsta_cmd *)data; - addsta->mode = cmd->mode; - memcpy(&addsta->sta, &cmd->sta, sizeof(struct sta_id_modify)); - memcpy(&addsta->key, &cmd->key, sizeof(struct il4965_keyinfo)); - addsta->station_flags = cmd->station_flags; - addsta->station_flags_msk = cmd->station_flags_msk; - addsta->tid_disable_tx = cpu_to_le16(0); - addsta->rate_n_flags = cmd->rate_n_flags; - addsta->add_immediate_ba_tid = cmd->add_immediate_ba_tid; - addsta->remove_immediate_ba_tid = cmd->remove_immediate_ba_tid; - addsta->add_immediate_ba_ssn = cmd->add_immediate_ba_ssn; - - return (u16)sizeof(struct il3945_addsta_cmd); -} - -static int il3945_add_bssid_station(struct il_priv *il, - const u8 *addr, u8 *sta_id_r) -{ - struct il_rxon_context *ctx = &il->ctx; - int ret; - u8 sta_id; - unsigned long flags; - - if (sta_id_r) - *sta_id_r = IL_INVALID_STATION; - - ret = il_add_station_common(il, ctx, addr, 0, NULL, &sta_id); - if (ret) { - IL_ERR("Unable to add station %pM\n", addr); - return ret; - } - - if (sta_id_r) - *sta_id_r = sta_id; - - spin_lock_irqsave(&il->sta_lock, flags); - il->stations[sta_id].used |= IL_STA_LOCAL; - spin_unlock_irqrestore(&il->sta_lock, flags); - - return 0; -} -static int il3945_manage_ibss_station(struct il_priv *il, - struct ieee80211_vif *vif, bool add) -{ - struct il_vif_priv *vif_priv = (void *)vif->drv_priv; - int ret; - - if (add) { - ret = il3945_add_bssid_station(il, vif->bss_conf.bssid, - &vif_priv->ibss_bssid_sta_id); - if (ret) - return ret; - - il3945_sync_sta(il, vif_priv->ibss_bssid_sta_id, - (il->band == IEEE80211_BAND_5GHZ) ? - RATE_6M_PLCP : RATE_1M_PLCP); - il3945_rate_scale_init(il->hw, vif_priv->ibss_bssid_sta_id); - - return 0; - } - - return il_remove_station(il, vif_priv->ibss_bssid_sta_id, - vif->bss_conf.bssid); -} - -/** - * il3945_init_hw_rate_table - Initialize the hardware rate fallback table - */ -int il3945_init_hw_rate_table(struct il_priv *il) -{ - int rc, i, idx, prev_idx; - struct il3945_rate_scaling_cmd rate_cmd = { - .reserved = {0, 0, 0}, - }; - struct il3945_rate_scaling_info *table = rate_cmd.table; - - for (i = 0; i < ARRAY_SIZE(il3945_rates); i++) { - idx = il3945_rates[i].table_rs_idx; - - table[idx].rate_n_flags = - il3945_hw_set_rate_n_flags(il3945_rates[i].plcp, 0); - table[idx].try_cnt = il->retry_rate; - prev_idx = il3945_get_prev_ieee_rate(i); - table[idx].next_rate_idx = - il3945_rates[prev_idx].table_rs_idx; - } - - switch (il->band) { - case IEEE80211_BAND_5GHZ: - D_RATE("Select A mode rate scale\n"); - /* If one of the following CCK rates is used, - * have it fall back to the 6M OFDM rate */ - for (i = RATE_1M_IDX_TBL; - i <= RATE_11M_IDX_TBL; i++) - table[i].next_rate_idx = - il3945_rates[IL_FIRST_OFDM_RATE].table_rs_idx; - - /* Don't fall back to CCK rates */ - table[RATE_12M_IDX_TBL].next_rate_idx = - RATE_9M_IDX_TBL; - - /* Don't drop out of OFDM rates */ - table[RATE_6M_IDX_TBL].next_rate_idx = - il3945_rates[IL_FIRST_OFDM_RATE].table_rs_idx; - break; - - case IEEE80211_BAND_2GHZ: - D_RATE("Select B/G mode rate scale\n"); - /* If an OFDM rate is used, have it fall back to the - * 1M CCK rates */ - - if (!(il->_3945.sta_supp_rates & IL_OFDM_RATES_MASK) && - il_is_associated(il)) { - - idx = IL_FIRST_CCK_RATE; - for (i = RATE_6M_IDX_TBL; - i <= RATE_54M_IDX_TBL; i++) - table[i].next_rate_idx = - il3945_rates[idx].table_rs_idx; - - idx = RATE_11M_IDX_TBL; - /* CCK shouldn't fall back to OFDM... */ - table[idx].next_rate_idx = RATE_5M_IDX_TBL; - } - break; - - default: - WARN_ON(1); - break; - } - - /* Update the rate scaling for control frame Tx */ - rate_cmd.table_id = 0; - rc = il_send_cmd_pdu(il, REPLY_RATE_SCALE, sizeof(rate_cmd), - &rate_cmd); - if (rc) - return rc; - - /* Update the rate scaling for data frame Tx */ - rate_cmd.table_id = 1; - return il_send_cmd_pdu(il, REPLY_RATE_SCALE, sizeof(rate_cmd), - &rate_cmd); -} - -/* Called when initializing driver */ -int il3945_hw_set_hw_params(struct il_priv *il) -{ - memset((void *)&il->hw_params, 0, - sizeof(struct il_hw_params)); - - il->_3945.shared_virt = - dma_alloc_coherent(&il->pci_dev->dev, - sizeof(struct il3945_shared), - &il->_3945.shared_phys, GFP_KERNEL); - if (!il->_3945.shared_virt) { - IL_ERR("failed to allocate pci memory\n"); - return -ENOMEM; - } - - /* Assign number of Usable TX queues */ - il->hw_params.max_txq_num = il->cfg->base_params->num_of_queues; - - il->hw_params.tfd_size = sizeof(struct il3945_tfd); - il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_3K); - il->hw_params.max_rxq_size = RX_QUEUE_SIZE; - il->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; - il->hw_params.max_stations = IL3945_STATION_COUNT; - il->ctx.bcast_sta_id = IL3945_BROADCAST_ID; - - il->sta_key_max_num = STA_KEY_MAX_NUM; - - il->hw_params.rx_wrt_ptr_reg = FH39_RSCSR_CHNL0_WPTR; - il->hw_params.max_beacon_itrvl = IL39_MAX_UCODE_BEACON_INTERVAL; - il->hw_params.beacon_time_tsf_bits = IL3945_EXT_BEACON_TIME_POS; - - return 0; -} - -unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, - struct il3945_frame *frame, u8 rate) -{ - struct il3945_tx_beacon_cmd *tx_beacon_cmd; - unsigned int frame_size; - - tx_beacon_cmd = (struct il3945_tx_beacon_cmd *)&frame->u; - memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); - - tx_beacon_cmd->tx.sta_id = - il->ctx.bcast_sta_id; - tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; - - frame_size = il3945_fill_beacon_frame(il, - tx_beacon_cmd->frame, - sizeof(frame->u) - sizeof(*tx_beacon_cmd)); - - BUG_ON(frame_size > MAX_MPDU_SIZE); - tx_beacon_cmd->tx.len = cpu_to_le16((u16)frame_size); - - tx_beacon_cmd->tx.rate = rate; - tx_beacon_cmd->tx.tx_flags = (TX_CMD_FLG_SEQ_CTL_MSK | - TX_CMD_FLG_TSF_MSK); - - /* supp_rates[0] == OFDM start at IL_FIRST_OFDM_RATE*/ - tx_beacon_cmd->tx.supp_rates[0] = - (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; - - tx_beacon_cmd->tx.supp_rates[1] = - (IL_CCK_BASIC_RATES_MASK & 0xF); - - return sizeof(struct il3945_tx_beacon_cmd) + frame_size; -} - -void il3945_hw_rx_handler_setup(struct il_priv *il) -{ - il->rx_handlers[REPLY_TX] = il3945_rx_reply_tx; - il->rx_handlers[REPLY_3945_RX] = il3945_rx_reply_rx; -} - -void il3945_hw_setup_deferred_work(struct il_priv *il) -{ - INIT_DELAYED_WORK(&il->_3945.thermal_periodic, - il3945_bg_reg_txpower_periodic); -} - -void il3945_hw_cancel_deferred_work(struct il_priv *il) -{ - cancel_delayed_work(&il->_3945.thermal_periodic); -} - -/* check contents of special bootstrap uCode SRAM */ -static int il3945_verify_bsm(struct il_priv *il) - { - __le32 *image = il->ucode_boot.v_addr; - u32 len = il->ucode_boot.len; - u32 reg; - u32 val; - - D_INFO("Begin verify bsm\n"); - - /* verify BSM SRAM contents */ - val = il_rd_prph(il, BSM_WR_DWCOUNT_REG); - for (reg = BSM_SRAM_LOWER_BOUND; - reg < BSM_SRAM_LOWER_BOUND + len; - reg += sizeof(u32), image++) { - val = il_rd_prph(il, reg); - if (val != le32_to_cpu(*image)) { - IL_ERR("BSM uCode verification failed at " - "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", - BSM_SRAM_LOWER_BOUND, - reg - BSM_SRAM_LOWER_BOUND, len, - val, le32_to_cpu(*image)); - return -EIO; - } - } - - D_INFO("BSM bootstrap uCode image OK\n"); - - return 0; -} - - -/****************************************************************************** - * - * EEPROM related functions - * - ******************************************************************************/ - -/* - * Clear the OWNER_MSK, to establish driver (instead of uCode running on - * embedded controller) as EEPROM reader; each read is a series of pulses - * to/from the EEPROM chip, not a single event, so even reads could conflict - * if they weren't arbitrated by some ownership mechanism. Here, the driver - * simply claims ownership, which should be safe when this function is called - * (i.e. before loading uCode!). - */ -static int il3945_eeprom_acquire_semaphore(struct il_priv *il) -{ - _il_clear_bit(il, CSR_EEPROM_GP, CSR_EEPROM_GP_IF_OWNER_MSK); - return 0; -} - - -static void il3945_eeprom_release_semaphore(struct il_priv *il) -{ - return; -} - - /** - * il3945_load_bsm - Load bootstrap instructions - * - * BSM operation: - * - * The Bootstrap State Machine (BSM) stores a short bootstrap uCode program - * in special SRAM that does not power down during RFKILL. When powering back - * up after power-saving sleeps (or during initial uCode load), the BSM loads - * the bootstrap program into the on-board processor, and starts it. - * - * The bootstrap program loads (via DMA) instructions and data for a new - * program from host DRAM locations indicated by the host driver in the - * BSM_DRAM_* registers. Once the new program is loaded, it starts - * automatically. - * - * When initializing the NIC, the host driver points the BSM to the - * "initialize" uCode image. This uCode sets up some internal data, then - * notifies host via "initialize alive" that it is complete. - * - * The host then replaces the BSM_DRAM_* pointer values to point to the - * normal runtime uCode instructions and a backup uCode data cache buffer - * (filled initially with starting data values for the on-board processor), - * then triggers the "initialize" uCode to load and launch the runtime uCode, - * which begins normal operation. - * - * When doing a power-save shutdown, runtime uCode saves data SRAM into - * the backup data cache in DRAM before SRAM is powered down. - * - * When powering back up, the BSM loads the bootstrap program. This reloads - * the runtime uCode instructions and the backup data cache into SRAM, - * and re-launches the runtime uCode from where it left off. - */ -static int il3945_load_bsm(struct il_priv *il) -{ - __le32 *image = il->ucode_boot.v_addr; - u32 len = il->ucode_boot.len; - dma_addr_t pinst; - dma_addr_t pdata; - u32 inst_len; - u32 data_len; - int rc; - int i; - u32 done; - u32 reg_offset; - - D_INFO("Begin load bsm\n"); - - /* make sure bootstrap program is no larger than BSM's SRAM size */ - if (len > IL39_MAX_BSM_SIZE) - return -EINVAL; - - /* Tell bootstrap uCode where to find the "Initialize" uCode - * in host DRAM ... host DRAM physical address bits 31:0 for 3945. - * NOTE: il3945_initialize_alive_start() will replace these values, - * after the "initialize" uCode has run, to point to - * runtime/protocol instructions and backup data cache. */ - pinst = il->ucode_init.p_addr; - pdata = il->ucode_init_data.p_addr; - inst_len = il->ucode_init.len; - data_len = il->ucode_init_data.len; - - il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); - il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); - il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); - il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); - - /* Fill BSM memory with bootstrap instructions */ - for (reg_offset = BSM_SRAM_LOWER_BOUND; - reg_offset < BSM_SRAM_LOWER_BOUND + len; - reg_offset += sizeof(u32), image++) - _il_wr_prph(il, reg_offset, - le32_to_cpu(*image)); - - rc = il3945_verify_bsm(il); - if (rc) - return rc; - - /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ - il_wr_prph(il, BSM_WR_MEM_SRC_REG, 0x0); - il_wr_prph(il, BSM_WR_MEM_DST_REG, - IL39_RTC_INST_LOWER_BOUND); - il_wr_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); - - /* Load bootstrap code into instruction SRAM now, - * to prepare to load "initialize" uCode */ - il_wr_prph(il, BSM_WR_CTRL_REG, - BSM_WR_CTRL_REG_BIT_START); - - /* Wait for load of bootstrap uCode to finish */ - for (i = 0; i < 100; i++) { - done = il_rd_prph(il, BSM_WR_CTRL_REG); - if (!(done & BSM_WR_CTRL_REG_BIT_START)) - break; - udelay(10); - } - if (i < 100) - D_INFO("BSM write complete, poll %d iterations\n", i); - else { - IL_ERR("BSM write did not complete!\n"); - return -EIO; - } - - /* Enable future boot loads whenever power management unit triggers it - * (e.g. when powering back up after power-save shutdown) */ - il_wr_prph(il, BSM_WR_CTRL_REG, - BSM_WR_CTRL_REG_BIT_START_EN); - - return 0; -} - -static struct il_hcmd_ops il3945_hcmd = { - .rxon_assoc = il3945_send_rxon_assoc, - .commit_rxon = il3945_commit_rxon, -}; - -static struct il_lib_ops il3945_lib = { - .txq_attach_buf_to_tfd = il3945_hw_txq_attach_buf_to_tfd, - .txq_free_tfd = il3945_hw_txq_free_tfd, - .txq_init = il3945_hw_tx_queue_init, - .load_ucode = il3945_load_bsm, - .dump_nic_error_log = il3945_dump_nic_error_log, - .apm_ops = { - .init = il3945_apm_init, - .config = il3945_nic_config, - }, - .eeprom_ops = { - .regulatory_bands = { - EEPROM_REGULATORY_BAND_1_CHANNELS, - EEPROM_REGULATORY_BAND_2_CHANNELS, - EEPROM_REGULATORY_BAND_3_CHANNELS, - EEPROM_REGULATORY_BAND_4_CHANNELS, - EEPROM_REGULATORY_BAND_5_CHANNELS, - EEPROM_REGULATORY_BAND_NO_HT40, - EEPROM_REGULATORY_BAND_NO_HT40, - }, - .acquire_semaphore = il3945_eeprom_acquire_semaphore, - .release_semaphore = il3945_eeprom_release_semaphore, - }, - .send_tx_power = il3945_send_tx_power, - .is_valid_rtc_data_addr = il3945_hw_valid_rtc_data_addr, - - .debugfs_ops = { - .rx_stats_read = il3945_ucode_rx_stats_read, - .tx_stats_read = il3945_ucode_tx_stats_read, - .general_stats_read = il3945_ucode_general_stats_read, - }, -}; - -static const struct il_legacy_ops il3945_legacy_ops = { - .post_associate = il3945_post_associate, - .config_ap = il3945_config_ap, - .manage_ibss_station = il3945_manage_ibss_station, -}; - -static struct il_hcmd_utils_ops il3945_hcmd_utils = { - .get_hcmd_size = il3945_get_hcmd_size, - .build_addsta_hcmd = il3945_build_addsta_hcmd, - .request_scan = il3945_request_scan, - .post_scan = il3945_post_scan, -}; - -static const struct il_ops il3945_ops = { - .lib = &il3945_lib, - .hcmd = &il3945_hcmd, - .utils = &il3945_hcmd_utils, - .led = &il3945_led_ops, - .legacy = &il3945_legacy_ops, - .ieee80211_ops = &il3945_hw_ops, -}; - -static struct il_base_params il3945_base_params = { - .eeprom_size = IL3945_EEPROM_IMG_SIZE, - .num_of_queues = IL39_NUM_QUEUES, - .pll_cfg_val = CSR39_ANA_PLL_CFG_VAL, - .set_l0s = false, - .use_bsm = true, - .led_compensation = 64, - .wd_timeout = IL_DEF_WD_TIMEOUT, -}; - -static struct il_cfg il3945_bg_cfg = { - .name = "3945BG", - .fw_name_pre = IL3945_FW_PRE, - .ucode_api_max = IL3945_UCODE_API_MAX, - .ucode_api_min = IL3945_UCODE_API_MIN, - .sku = IL_SKU_G, - .eeprom_ver = EEPROM_3945_EEPROM_VERSION, - .ops = &il3945_ops, - .mod_params = &il3945_mod_params, - .base_params = &il3945_base_params, - .led_mode = IL_LED_BLINK, -}; - -static struct il_cfg il3945_abg_cfg = { - .name = "3945ABG", - .fw_name_pre = IL3945_FW_PRE, - .ucode_api_max = IL3945_UCODE_API_MAX, - .ucode_api_min = IL3945_UCODE_API_MIN, - .sku = IL_SKU_A|IL_SKU_G, - .eeprom_ver = EEPROM_3945_EEPROM_VERSION, - .ops = &il3945_ops, - .mod_params = &il3945_mod_params, - .base_params = &il3945_base_params, - .led_mode = IL_LED_BLINK, -}; - -DEFINE_PCI_DEVICE_TABLE(il3945_hw_card_ids) = { - {IL_PCI_DEVICE(0x4222, 0x1005, il3945_bg_cfg)}, - {IL_PCI_DEVICE(0x4222, 0x1034, il3945_bg_cfg)}, - {IL_PCI_DEVICE(0x4222, 0x1044, il3945_bg_cfg)}, - {IL_PCI_DEVICE(0x4227, 0x1014, il3945_bg_cfg)}, - {IL_PCI_DEVICE(0x4222, PCI_ANY_ID, il3945_abg_cfg)}, - {IL_PCI_DEVICE(0x4227, PCI_ANY_ID, il3945_abg_cfg)}, - {0} -}; - -MODULE_DEVICE_TABLE(pci, il3945_hw_card_ids); diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c deleted file mode 100644 index bdfb3a616fdc..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965.c +++ /dev/null @@ -1,2183 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "iwl-eeprom.h" -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-io.h" -#include "iwl-helpers.h" -#include "iwl-4965-calib.h" -#include "iwl-sta.h" -#include "iwl-4965-led.h" -#include "iwl-4965.h" -#include "iwl-4965-debugfs.h" - -static int il4965_send_tx_power(struct il_priv *il); -static int il4965_hw_get_temperature(struct il_priv *il); - -/* Highest firmware API version supported */ -#define IL4965_UCODE_API_MAX 2 - -/* Lowest firmware API version supported */ -#define IL4965_UCODE_API_MIN 2 - -#define IL4965_FW_PRE "iwlwifi-4965-" -#define _IL4965_MODULE_FIRMWARE(api) IL4965_FW_PRE #api ".ucode" -#define IL4965_MODULE_FIRMWARE(api) _IL4965_MODULE_FIRMWARE(api) - -/* check contents of special bootstrap uCode SRAM */ -static int il4965_verify_bsm(struct il_priv *il) -{ - __le32 *image = il->ucode_boot.v_addr; - u32 len = il->ucode_boot.len; - u32 reg; - u32 val; - - D_INFO("Begin verify bsm\n"); - - /* verify BSM SRAM contents */ - val = il_rd_prph(il, BSM_WR_DWCOUNT_REG); - for (reg = BSM_SRAM_LOWER_BOUND; - reg < BSM_SRAM_LOWER_BOUND + len; - reg += sizeof(u32), image++) { - val = il_rd_prph(il, reg); - if (val != le32_to_cpu(*image)) { - IL_ERR("BSM uCode verification failed at " - "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", - BSM_SRAM_LOWER_BOUND, - reg - BSM_SRAM_LOWER_BOUND, len, - val, le32_to_cpu(*image)); - return -EIO; - } - } - - D_INFO("BSM bootstrap uCode image OK\n"); - - return 0; -} - -/** - * il4965_load_bsm - Load bootstrap instructions - * - * BSM operation: - * - * The Bootstrap State Machine (BSM) stores a short bootstrap uCode program - * in special SRAM that does not power down during RFKILL. When powering back - * up after power-saving sleeps (or during initial uCode load), the BSM loads - * the bootstrap program into the on-board processor, and starts it. - * - * The bootstrap program loads (via DMA) instructions and data for a new - * program from host DRAM locations indicated by the host driver in the - * BSM_DRAM_* registers. Once the new program is loaded, it starts - * automatically. - * - * When initializing the NIC, the host driver points the BSM to the - * "initialize" uCode image. This uCode sets up some internal data, then - * notifies host via "initialize alive" that it is complete. - * - * The host then replaces the BSM_DRAM_* pointer values to point to the - * normal runtime uCode instructions and a backup uCode data cache buffer - * (filled initially with starting data values for the on-board processor), - * then triggers the "initialize" uCode to load and launch the runtime uCode, - * which begins normal operation. - * - * When doing a power-save shutdown, runtime uCode saves data SRAM into - * the backup data cache in DRAM before SRAM is powered down. - * - * When powering back up, the BSM loads the bootstrap program. This reloads - * the runtime uCode instructions and the backup data cache into SRAM, - * and re-launches the runtime uCode from where it left off. - */ -static int il4965_load_bsm(struct il_priv *il) -{ - __le32 *image = il->ucode_boot.v_addr; - u32 len = il->ucode_boot.len; - dma_addr_t pinst; - dma_addr_t pdata; - u32 inst_len; - u32 data_len; - int i; - u32 done; - u32 reg_offset; - int ret; - - D_INFO("Begin load bsm\n"); - - il->ucode_type = UCODE_RT; - - /* make sure bootstrap program is no larger than BSM's SRAM size */ - if (len > IL49_MAX_BSM_SIZE) - return -EINVAL; - - /* Tell bootstrap uCode where to find the "Initialize" uCode - * in host DRAM ... host DRAM physical address bits 35:4 for 4965. - * NOTE: il_init_alive_start() will replace these values, - * after the "initialize" uCode has run, to point to - * runtime/protocol instructions and backup data cache. - */ - pinst = il->ucode_init.p_addr >> 4; - pdata = il->ucode_init_data.p_addr >> 4; - inst_len = il->ucode_init.len; - data_len = il->ucode_init_data.len; - - il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); - il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); - il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); - il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); - - /* Fill BSM memory with bootstrap instructions */ - for (reg_offset = BSM_SRAM_LOWER_BOUND; - reg_offset < BSM_SRAM_LOWER_BOUND + len; - reg_offset += sizeof(u32), image++) - _il_wr_prph(il, reg_offset, le32_to_cpu(*image)); - - ret = il4965_verify_bsm(il); - if (ret) - return ret; - - /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ - il_wr_prph(il, BSM_WR_MEM_SRC_REG, 0x0); - il_wr_prph(il, - BSM_WR_MEM_DST_REG, IL49_RTC_INST_LOWER_BOUND); - il_wr_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); - - /* Load bootstrap code into instruction SRAM now, - * to prepare to load "initialize" uCode */ - il_wr_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START); - - /* Wait for load of bootstrap uCode to finish */ - for (i = 0; i < 100; i++) { - done = il_rd_prph(il, BSM_WR_CTRL_REG); - if (!(done & BSM_WR_CTRL_REG_BIT_START)) - break; - udelay(10); - } - if (i < 100) - D_INFO("BSM write complete, poll %d iterations\n", i); - else { - IL_ERR("BSM write did not complete!\n"); - return -EIO; - } - - /* Enable future boot loads whenever power management unit triggers it - * (e.g. when powering back up after power-save shutdown) */ - il_wr_prph(il, - BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN); - - - return 0; -} - -/** - * il4965_set_ucode_ptrs - Set uCode address location - * - * Tell initialization uCode where to find runtime uCode. - * - * BSM registers initially contain pointers to initialization uCode. - * We need to replace them to load runtime uCode inst and data, - * and to save runtime data when powering down. - */ -static int il4965_set_ucode_ptrs(struct il_priv *il) -{ - dma_addr_t pinst; - dma_addr_t pdata; - int ret = 0; - - /* bits 35:4 for 4965 */ - pinst = il->ucode_code.p_addr >> 4; - pdata = il->ucode_data_backup.p_addr >> 4; - - /* Tell bootstrap uCode where to find image to load */ - il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); - il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); - il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, - il->ucode_data.len); - - /* Inst byte count must be last to set up, bit 31 signals uCode - * that all new ptr/size info is in place */ - il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, - il->ucode_code.len | BSM_DRAM_INST_LOAD); - D_INFO("Runtime uCode pointers are set.\n"); - - return ret; -} - -/** - * il4965_init_alive_start - Called after REPLY_ALIVE notification received - * - * Called after REPLY_ALIVE notification received from "initialize" uCode. - * - * The 4965 "initialize" ALIVE reply contains calibration data for: - * Voltage, temperature, and MIMO tx gain correction, now stored in il - * (3945 does not contain this data). - * - * Tell "initialize" uCode to go ahead and load the runtime uCode. -*/ -static void il4965_init_alive_start(struct il_priv *il) -{ - /* Bootstrap uCode has loaded initialize uCode ... verify inst image. - * This is a paranoid check, because we would not have gotten the - * "initialize" alive if code weren't properly loaded. */ - if (il4965_verify_ucode(il)) { - /* Runtime instruction load was bad; - * take it all the way back down so we can try again */ - D_INFO("Bad \"initialize\" uCode load.\n"); - goto restart; - } - - /* Calculate temperature */ - il->temperature = il4965_hw_get_temperature(il); - - /* Send pointers to protocol/runtime uCode image ... init code will - * load and launch runtime uCode, which will send us another "Alive" - * notification. */ - D_INFO("Initialization Alive received.\n"); - if (il4965_set_ucode_ptrs(il)) { - /* Runtime instruction load won't happen; - * take it all the way back down so we can try again */ - D_INFO("Couldn't set up uCode pointers.\n"); - goto restart; - } - return; - -restart: - queue_work(il->workqueue, &il->restart); -} - -static bool iw4965_is_ht40_channel(__le32 rxon_flags) -{ - int chan_mod = le32_to_cpu(rxon_flags & RXON_FLG_CHANNEL_MODE_MSK) - >> RXON_FLG_CHANNEL_MODE_POS; - return (chan_mod == CHANNEL_MODE_PURE_40 || - chan_mod == CHANNEL_MODE_MIXED); -} - -static void il4965_nic_config(struct il_priv *il) -{ - unsigned long flags; - u16 radio_cfg; - - spin_lock_irqsave(&il->lock, flags); - - radio_cfg = il_eeprom_query16(il, EEPROM_RADIO_CONFIG); - - /* write radio config values to register */ - if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) == EEPROM_4965_RF_CFG_TYPE_MAX) - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - EEPROM_RF_CFG_TYPE_MSK(radio_cfg) | - EEPROM_RF_CFG_STEP_MSK(radio_cfg) | - EEPROM_RF_CFG_DASH_MSK(radio_cfg)); - - /* set CSR_HW_CONFIG_REG for uCode use */ - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | - CSR_HW_IF_CONFIG_REG_BIT_MAC_SI); - - il->calib_info = (struct il_eeprom_calib_info *) - il_eeprom_query_addr(il, - EEPROM_4965_CALIB_TXPOWER_OFFSET); - - spin_unlock_irqrestore(&il->lock, flags); -} - -/* Reset differential Rx gains in NIC to prepare for chain noise calibration. - * Called after every association, but this runs only once! - * ... once chain noise is calibrated the first time, it's good forever. */ -static void il4965_chain_noise_reset(struct il_priv *il) -{ - struct il_chain_noise_data *data = &(il->chain_noise_data); - - if (data->state == IL_CHAIN_NOISE_ALIVE && - il_is_any_associated(il)) { - struct il_calib_diff_gain_cmd cmd; - - /* clear data for chain noise calibration algorithm */ - data->chain_noise_a = 0; - data->chain_noise_b = 0; - data->chain_noise_c = 0; - data->chain_signal_a = 0; - data->chain_signal_b = 0; - data->chain_signal_c = 0; - data->beacon_count = 0; - - memset(&cmd, 0, sizeof(cmd)); - cmd.hdr.op_code = IL_PHY_CALIBRATE_DIFF_GAIN_CMD; - cmd.diff_gain_a = 0; - cmd.diff_gain_b = 0; - cmd.diff_gain_c = 0; - if (il_send_cmd_pdu(il, REPLY_PHY_CALIBRATION_CMD, - sizeof(cmd), &cmd)) - IL_ERR( - "Could not send REPLY_PHY_CALIBRATION_CMD\n"); - data->state = IL_CHAIN_NOISE_ACCUMULATE; - D_CALIB("Run chain_noise_calibrate\n"); - } -} - -static struct il_sensitivity_ranges il4965_sensitivity = { - .min_nrg_cck = 97, - .max_nrg_cck = 0, /* not used, set to 0 */ - - .auto_corr_min_ofdm = 85, - .auto_corr_min_ofdm_mrc = 170, - .auto_corr_min_ofdm_x1 = 105, - .auto_corr_min_ofdm_mrc_x1 = 220, - - .auto_corr_max_ofdm = 120, - .auto_corr_max_ofdm_mrc = 210, - .auto_corr_max_ofdm_x1 = 140, - .auto_corr_max_ofdm_mrc_x1 = 270, - - .auto_corr_min_cck = 125, - .auto_corr_max_cck = 200, - .auto_corr_min_cck_mrc = 200, - .auto_corr_max_cck_mrc = 400, - - .nrg_th_cck = 100, - .nrg_th_ofdm = 100, - - .barker_corr_th_min = 190, - .barker_corr_th_min_mrc = 390, - .nrg_th_cca = 62, -}; - -static void il4965_set_ct_threshold(struct il_priv *il) -{ - /* want Kelvin */ - il->hw_params.ct_kill_threshold = - CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY); -} - -/** - * il4965_hw_set_hw_params - * - * Called when initializing driver - */ -static int il4965_hw_set_hw_params(struct il_priv *il) -{ - if (il->cfg->mod_params->num_of_queues >= IL_MIN_NUM_QUEUES && - il->cfg->mod_params->num_of_queues <= IL49_NUM_QUEUES) - il->cfg->base_params->num_of_queues = - il->cfg->mod_params->num_of_queues; - - il->hw_params.max_txq_num = il->cfg->base_params->num_of_queues; - il->hw_params.dma_chnl_num = FH49_TCSR_CHNL_NUM; - il->hw_params.scd_bc_tbls_size = - il->cfg->base_params->num_of_queues * - sizeof(struct il4965_scd_bc_tbl); - il->hw_params.tfd_size = sizeof(struct il_tfd); - il->hw_params.max_stations = IL4965_STATION_COUNT; - il->ctx.bcast_sta_id = IL4965_BROADCAST_ID; - il->hw_params.max_data_size = IL49_RTC_DATA_SIZE; - il->hw_params.max_inst_size = IL49_RTC_INST_SIZE; - il->hw_params.max_bsm_size = BSM_SRAM_SIZE; - il->hw_params.ht40_channel = BIT(IEEE80211_BAND_5GHZ); - - il->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR; - - il->hw_params.tx_chains_num = il4965_num_of_ant(il->cfg->valid_tx_ant); - il->hw_params.rx_chains_num = il4965_num_of_ant(il->cfg->valid_rx_ant); - il->hw_params.valid_tx_ant = il->cfg->valid_tx_ant; - il->hw_params.valid_rx_ant = il->cfg->valid_rx_ant; - - il4965_set_ct_threshold(il); - - il->hw_params.sens = &il4965_sensitivity; - il->hw_params.beacon_time_tsf_bits = IL4965_EXT_BEACON_TIME_POS; - - return 0; -} - -static s32 il4965_math_div_round(s32 num, s32 denom, s32 *res) -{ - s32 sign = 1; - - if (num < 0) { - sign = -sign; - num = -num; - } - if (denom < 0) { - sign = -sign; - denom = -denom; - } - *res = 1; - *res = ((num * 2 + denom) / (denom * 2)) * sign; - - return 1; -} - -/** - * il4965_get_voltage_compensation - Power supply voltage comp for txpower - * - * Determines power supply voltage compensation for txpower calculations. - * Returns number of 1/2-dB steps to subtract from gain table idx, - * to compensate for difference between power supply voltage during - * factory measurements, vs. current power supply voltage. - * - * Voltage indication is higher for lower voltage. - * Lower voltage requires more gain (lower gain table idx). - */ -static s32 il4965_get_voltage_compensation(s32 eeprom_voltage, - s32 current_voltage) -{ - s32 comp = 0; - - if (TX_POWER_IL_ILLEGAL_VOLTAGE == eeprom_voltage || - TX_POWER_IL_ILLEGAL_VOLTAGE == current_voltage) - return 0; - - il4965_math_div_round(current_voltage - eeprom_voltage, - TX_POWER_IL_VOLTAGE_CODES_PER_03V, &comp); - - if (current_voltage > eeprom_voltage) - comp *= 2; - if ((comp < -2) || (comp > 2)) - comp = 0; - - return comp; -} - -static s32 il4965_get_tx_atten_grp(u16 channel) -{ - if (channel >= CALIB_IL_TX_ATTEN_GR5_FCH && - channel <= CALIB_IL_TX_ATTEN_GR5_LCH) - return CALIB_CH_GROUP_5; - - if (channel >= CALIB_IL_TX_ATTEN_GR1_FCH && - channel <= CALIB_IL_TX_ATTEN_GR1_LCH) - return CALIB_CH_GROUP_1; - - if (channel >= CALIB_IL_TX_ATTEN_GR2_FCH && - channel <= CALIB_IL_TX_ATTEN_GR2_LCH) - return CALIB_CH_GROUP_2; - - if (channel >= CALIB_IL_TX_ATTEN_GR3_FCH && - channel <= CALIB_IL_TX_ATTEN_GR3_LCH) - return CALIB_CH_GROUP_3; - - if (channel >= CALIB_IL_TX_ATTEN_GR4_FCH && - channel <= CALIB_IL_TX_ATTEN_GR4_LCH) - return CALIB_CH_GROUP_4; - - return -EINVAL; -} - -static u32 il4965_get_sub_band(const struct il_priv *il, u32 channel) -{ - s32 b = -1; - - for (b = 0; b < EEPROM_TX_POWER_BANDS; b++) { - if (il->calib_info->band_info[b].ch_from == 0) - continue; - - if (channel >= il->calib_info->band_info[b].ch_from && - channel <= il->calib_info->band_info[b].ch_to) - break; - } - - return b; -} - -static s32 il4965_interpolate_value(s32 x, s32 x1, s32 y1, s32 x2, s32 y2) -{ - s32 val; - - if (x2 == x1) - return y1; - else { - il4965_math_div_round((x2 - x) * (y1 - y2), (x2 - x1), &val); - return val + y2; - } -} - -/** - * il4965_interpolate_chan - Interpolate factory measurements for one channel - * - * Interpolates factory measurements from the two sample channels within a - * sub-band, to apply to channel of interest. Interpolation is proportional to - * differences in channel frequencies, which is proportional to differences - * in channel number. - */ -static int il4965_interpolate_chan(struct il_priv *il, u32 channel, - struct il_eeprom_calib_ch_info *chan_info) -{ - s32 s = -1; - u32 c; - u32 m; - const struct il_eeprom_calib_measure *m1; - const struct il_eeprom_calib_measure *m2; - struct il_eeprom_calib_measure *omeas; - u32 ch_i1; - u32 ch_i2; - - s = il4965_get_sub_band(il, channel); - if (s >= EEPROM_TX_POWER_BANDS) { - IL_ERR("Tx Power can not find channel %d\n", channel); - return -1; - } - - ch_i1 = il->calib_info->band_info[s].ch1.ch_num; - ch_i2 = il->calib_info->band_info[s].ch2.ch_num; - chan_info->ch_num = (u8) channel; - - D_TXPOWER("channel %d subband %d factory cal ch %d & %d\n", - channel, s, ch_i1, ch_i2); - - for (c = 0; c < EEPROM_TX_POWER_TX_CHAINS; c++) { - for (m = 0; m < EEPROM_TX_POWER_MEASUREMENTS; m++) { - m1 = &(il->calib_info->band_info[s].ch1. - measurements[c][m]); - m2 = &(il->calib_info->band_info[s].ch2. - measurements[c][m]); - omeas = &(chan_info->measurements[c][m]); - - omeas->actual_pow = - (u8) il4965_interpolate_value(channel, ch_i1, - m1->actual_pow, - ch_i2, - m2->actual_pow); - omeas->gain_idx = - (u8) il4965_interpolate_value(channel, ch_i1, - m1->gain_idx, ch_i2, - m2->gain_idx); - omeas->temperature = - (u8) il4965_interpolate_value(channel, ch_i1, - m1->temperature, - ch_i2, - m2->temperature); - omeas->pa_det = - (s8) il4965_interpolate_value(channel, ch_i1, - m1->pa_det, ch_i2, - m2->pa_det); - - D_TXPOWER( - "chain %d meas %d AP1=%d AP2=%d AP=%d\n", c, m, - m1->actual_pow, m2->actual_pow, omeas->actual_pow); - D_TXPOWER( - "chain %d meas %d NI1=%d NI2=%d NI=%d\n", c, m, - m1->gain_idx, m2->gain_idx, omeas->gain_idx); - D_TXPOWER( - "chain %d meas %d PA1=%d PA2=%d PA=%d\n", c, m, - m1->pa_det, m2->pa_det, omeas->pa_det); - D_TXPOWER( - "chain %d meas %d T1=%d T2=%d T=%d\n", c, m, - m1->temperature, m2->temperature, - omeas->temperature); - } - } - - return 0; -} - -/* bit-rate-dependent table to prevent Tx distortion, in half-dB units, - * for OFDM 6, 12, 18, 24, 36, 48, 54, 60 MBit, and CCK all rates. */ -static s32 back_off_table[] = { - 10, 10, 10, 10, 10, 15, 17, 20, /* OFDM SISO 20 MHz */ - 10, 10, 10, 10, 10, 15, 17, 20, /* OFDM MIMO 20 MHz */ - 10, 10, 10, 10, 10, 15, 17, 20, /* OFDM SISO 40 MHz */ - 10, 10, 10, 10, 10, 15, 17, 20, /* OFDM MIMO 40 MHz */ - 10 /* CCK */ -}; - -/* Thermal compensation values for txpower for various frequency ranges ... - * ratios from 3:1 to 4.5:1 of degrees (Celsius) per half-dB gain adjust */ -static struct il4965_txpower_comp_entry { - s32 degrees_per_05db_a; - s32 degrees_per_05db_a_denom; -} tx_power_cmp_tble[CALIB_CH_GROUP_MAX] = { - {9, 2}, /* group 0 5.2, ch 34-43 */ - {4, 1}, /* group 1 5.2, ch 44-70 */ - {4, 1}, /* group 2 5.2, ch 71-124 */ - {4, 1}, /* group 3 5.2, ch 125-200 */ - {3, 1} /* group 4 2.4, ch all */ -}; - -static s32 get_min_power_idx(s32 rate_power_idx, u32 band) -{ - if (!band) { - if ((rate_power_idx & 7) <= 4) - return MIN_TX_GAIN_IDX_52GHZ_EXT; - } - return MIN_TX_GAIN_IDX; -} - -struct gain_entry { - u8 dsp; - u8 radio; -}; - -static const struct gain_entry gain_table[2][108] = { - /* 5.2GHz power gain idx table */ - { - {123, 0x3F}, /* highest txpower */ - {117, 0x3F}, - {110, 0x3F}, - {104, 0x3F}, - {98, 0x3F}, - {110, 0x3E}, - {104, 0x3E}, - {98, 0x3E}, - {110, 0x3D}, - {104, 0x3D}, - {98, 0x3D}, - {110, 0x3C}, - {104, 0x3C}, - {98, 0x3C}, - {110, 0x3B}, - {104, 0x3B}, - {98, 0x3B}, - {110, 0x3A}, - {104, 0x3A}, - {98, 0x3A}, - {110, 0x39}, - {104, 0x39}, - {98, 0x39}, - {110, 0x38}, - {104, 0x38}, - {98, 0x38}, - {110, 0x37}, - {104, 0x37}, - {98, 0x37}, - {110, 0x36}, - {104, 0x36}, - {98, 0x36}, - {110, 0x35}, - {104, 0x35}, - {98, 0x35}, - {110, 0x34}, - {104, 0x34}, - {98, 0x34}, - {110, 0x33}, - {104, 0x33}, - {98, 0x33}, - {110, 0x32}, - {104, 0x32}, - {98, 0x32}, - {110, 0x31}, - {104, 0x31}, - {98, 0x31}, - {110, 0x30}, - {104, 0x30}, - {98, 0x30}, - {110, 0x25}, - {104, 0x25}, - {98, 0x25}, - {110, 0x24}, - {104, 0x24}, - {98, 0x24}, - {110, 0x23}, - {104, 0x23}, - {98, 0x23}, - {110, 0x22}, - {104, 0x18}, - {98, 0x18}, - {110, 0x17}, - {104, 0x17}, - {98, 0x17}, - {110, 0x16}, - {104, 0x16}, - {98, 0x16}, - {110, 0x15}, - {104, 0x15}, - {98, 0x15}, - {110, 0x14}, - {104, 0x14}, - {98, 0x14}, - {110, 0x13}, - {104, 0x13}, - {98, 0x13}, - {110, 0x12}, - {104, 0x08}, - {98, 0x08}, - {110, 0x07}, - {104, 0x07}, - {98, 0x07}, - {110, 0x06}, - {104, 0x06}, - {98, 0x06}, - {110, 0x05}, - {104, 0x05}, - {98, 0x05}, - {110, 0x04}, - {104, 0x04}, - {98, 0x04}, - {110, 0x03}, - {104, 0x03}, - {98, 0x03}, - {110, 0x02}, - {104, 0x02}, - {98, 0x02}, - {110, 0x01}, - {104, 0x01}, - {98, 0x01}, - {110, 0x00}, - {104, 0x00}, - {98, 0x00}, - {93, 0x00}, - {88, 0x00}, - {83, 0x00}, - {78, 0x00}, - }, - /* 2.4GHz power gain idx table */ - { - {110, 0x3f}, /* highest txpower */ - {104, 0x3f}, - {98, 0x3f}, - {110, 0x3e}, - {104, 0x3e}, - {98, 0x3e}, - {110, 0x3d}, - {104, 0x3d}, - {98, 0x3d}, - {110, 0x3c}, - {104, 0x3c}, - {98, 0x3c}, - {110, 0x3b}, - {104, 0x3b}, - {98, 0x3b}, - {110, 0x3a}, - {104, 0x3a}, - {98, 0x3a}, - {110, 0x39}, - {104, 0x39}, - {98, 0x39}, - {110, 0x38}, - {104, 0x38}, - {98, 0x38}, - {110, 0x37}, - {104, 0x37}, - {98, 0x37}, - {110, 0x36}, - {104, 0x36}, - {98, 0x36}, - {110, 0x35}, - {104, 0x35}, - {98, 0x35}, - {110, 0x34}, - {104, 0x34}, - {98, 0x34}, - {110, 0x33}, - {104, 0x33}, - {98, 0x33}, - {110, 0x32}, - {104, 0x32}, - {98, 0x32}, - {110, 0x31}, - {104, 0x31}, - {98, 0x31}, - {110, 0x30}, - {104, 0x30}, - {98, 0x30}, - {110, 0x6}, - {104, 0x6}, - {98, 0x6}, - {110, 0x5}, - {104, 0x5}, - {98, 0x5}, - {110, 0x4}, - {104, 0x4}, - {98, 0x4}, - {110, 0x3}, - {104, 0x3}, - {98, 0x3}, - {110, 0x2}, - {104, 0x2}, - {98, 0x2}, - {110, 0x1}, - {104, 0x1}, - {98, 0x1}, - {110, 0x0}, - {104, 0x0}, - {98, 0x0}, - {97, 0}, - {96, 0}, - {95, 0}, - {94, 0}, - {93, 0}, - {92, 0}, - {91, 0}, - {90, 0}, - {89, 0}, - {88, 0}, - {87, 0}, - {86, 0}, - {85, 0}, - {84, 0}, - {83, 0}, - {82, 0}, - {81, 0}, - {80, 0}, - {79, 0}, - {78, 0}, - {77, 0}, - {76, 0}, - {75, 0}, - {74, 0}, - {73, 0}, - {72, 0}, - {71, 0}, - {70, 0}, - {69, 0}, - {68, 0}, - {67, 0}, - {66, 0}, - {65, 0}, - {64, 0}, - {63, 0}, - {62, 0}, - {61, 0}, - {60, 0}, - {59, 0}, - } -}; - -static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, - u8 is_ht40, u8 ctrl_chan_high, - struct il4965_tx_power_db *tx_power_tbl) -{ - u8 saturation_power; - s32 target_power; - s32 user_target_power; - s32 power_limit; - s32 current_temp; - s32 reg_limit; - s32 current_regulatory; - s32 txatten_grp = CALIB_CH_GROUP_MAX; - int i; - int c; - const struct il_channel_info *ch_info = NULL; - struct il_eeprom_calib_ch_info ch_eeprom_info; - const struct il_eeprom_calib_measure *measurement; - s16 voltage; - s32 init_voltage; - s32 voltage_compensation; - s32 degrees_per_05db_num; - s32 degrees_per_05db_denom; - s32 factory_temp; - s32 temperature_comp[2]; - s32 factory_gain_idx[2]; - s32 factory_actual_pwr[2]; - s32 power_idx; - - /* tx_power_user_lmt is in dBm, convert to half-dBm (half-dB units - * are used for idxing into txpower table) */ - user_target_power = 2 * il->tx_power_user_lmt; - - /* Get current (RXON) channel, band, width */ - D_TXPOWER("chan %d band %d is_ht40 %d\n", channel, band, - is_ht40); - - ch_info = il_get_channel_info(il, il->band, channel); - - if (!il_is_channel_valid(ch_info)) - return -EINVAL; - - /* get txatten group, used to select 1) thermal txpower adjustment - * and 2) mimo txpower balance between Tx chains. */ - txatten_grp = il4965_get_tx_atten_grp(channel); - if (txatten_grp < 0) { - IL_ERR("Can't find txatten group for channel %d.\n", - channel); - return txatten_grp; - } - - D_TXPOWER("channel %d belongs to txatten group %d\n", - channel, txatten_grp); - - if (is_ht40) { - if (ctrl_chan_high) - channel -= 2; - else - channel += 2; - } - - /* hardware txpower limits ... - * saturation (clipping distortion) txpowers are in half-dBm */ - if (band) - saturation_power = il->calib_info->saturation_power24; - else - saturation_power = il->calib_info->saturation_power52; - - if (saturation_power < IL_TX_POWER_SATURATION_MIN || - saturation_power > IL_TX_POWER_SATURATION_MAX) { - if (band) - saturation_power = IL_TX_POWER_DEFAULT_SATURATION_24; - else - saturation_power = IL_TX_POWER_DEFAULT_SATURATION_52; - } - - /* regulatory txpower limits ... reg_limit values are in half-dBm, - * max_power_avg values are in dBm, convert * 2 */ - if (is_ht40) - reg_limit = ch_info->ht40_max_power_avg * 2; - else - reg_limit = ch_info->max_power_avg * 2; - - if ((reg_limit < IL_TX_POWER_REGULATORY_MIN) || - (reg_limit > IL_TX_POWER_REGULATORY_MAX)) { - if (band) - reg_limit = IL_TX_POWER_DEFAULT_REGULATORY_24; - else - reg_limit = IL_TX_POWER_DEFAULT_REGULATORY_52; - } - - /* Interpolate txpower calibration values for this channel, - * based on factory calibration tests on spaced channels. */ - il4965_interpolate_chan(il, channel, &ch_eeprom_info); - - /* calculate tx gain adjustment based on power supply voltage */ - voltage = le16_to_cpu(il->calib_info->voltage); - init_voltage = (s32)le32_to_cpu(il->card_alive_init.voltage); - voltage_compensation = - il4965_get_voltage_compensation(voltage, init_voltage); - - D_TXPOWER("curr volt %d eeprom volt %d volt comp %d\n", - init_voltage, - voltage, voltage_compensation); - - /* get current temperature (Celsius) */ - current_temp = max(il->temperature, IL_TX_POWER_TEMPERATURE_MIN); - current_temp = min(il->temperature, IL_TX_POWER_TEMPERATURE_MAX); - current_temp = KELVIN_TO_CELSIUS(current_temp); - - /* select thermal txpower adjustment params, based on channel group - * (same frequency group used for mimo txatten adjustment) */ - degrees_per_05db_num = - tx_power_cmp_tble[txatten_grp].degrees_per_05db_a; - degrees_per_05db_denom = - tx_power_cmp_tble[txatten_grp].degrees_per_05db_a_denom; - - /* get per-chain txpower values from factory measurements */ - for (c = 0; c < 2; c++) { - measurement = &ch_eeprom_info.measurements[c][1]; - - /* txgain adjustment (in half-dB steps) based on difference - * between factory and current temperature */ - factory_temp = measurement->temperature; - il4965_math_div_round((current_temp - factory_temp) * - degrees_per_05db_denom, - degrees_per_05db_num, - &temperature_comp[c]); - - factory_gain_idx[c] = measurement->gain_idx; - factory_actual_pwr[c] = measurement->actual_pow; - - D_TXPOWER("chain = %d\n", c); - D_TXPOWER("fctry tmp %d, " - "curr tmp %d, comp %d steps\n", - factory_temp, current_temp, - temperature_comp[c]); - - D_TXPOWER("fctry idx %d, fctry pwr %d\n", - factory_gain_idx[c], - factory_actual_pwr[c]); - } - - /* for each of 33 bit-rates (including 1 for CCK) */ - for (i = 0; i < POWER_TBL_NUM_ENTRIES; i++) { - u8 is_mimo_rate; - union il4965_tx_power_dual_stream tx_power; - - /* for mimo, reduce each chain's txpower by half - * (3dB, 6 steps), so total output power is regulatory - * compliant. */ - if (i & 0x8) { - current_regulatory = reg_limit - - IL_TX_POWER_MIMO_REGULATORY_COMPENSATION; - is_mimo_rate = 1; - } else { - current_regulatory = reg_limit; - is_mimo_rate = 0; - } - - /* find txpower limit, either hardware or regulatory */ - power_limit = saturation_power - back_off_table[i]; - if (power_limit > current_regulatory) - power_limit = current_regulatory; - - /* reduce user's txpower request if necessary - * for this rate on this channel */ - target_power = user_target_power; - if (target_power > power_limit) - target_power = power_limit; - - D_TXPOWER("rate %d sat %d reg %d usr %d tgt %d\n", - i, saturation_power - back_off_table[i], - current_regulatory, user_target_power, - target_power); - - /* for each of 2 Tx chains (radio transmitters) */ - for (c = 0; c < 2; c++) { - s32 atten_value; - - if (is_mimo_rate) - atten_value = - (s32)le32_to_cpu(il->card_alive_init. - tx_atten[txatten_grp][c]); - else - atten_value = 0; - - /* calculate idx; higher idx means lower txpower */ - power_idx = (u8) (factory_gain_idx[c] - - (target_power - - factory_actual_pwr[c]) - - temperature_comp[c] - - voltage_compensation + - atten_value); - -/* D_TXPOWER("calculated txpower idx %d\n", - power_idx); */ - - if (power_idx < get_min_power_idx(i, band)) - power_idx = get_min_power_idx(i, band); - - /* adjust 5 GHz idx to support negative idxes */ - if (!band) - power_idx += 9; - - /* CCK, rate 32, reduce txpower for CCK */ - if (i == POWER_TBL_CCK_ENTRY) - power_idx += - IL_TX_POWER_CCK_COMPENSATION_C_STEP; - - /* stay within the table! */ - if (power_idx > 107) { - IL_WARN("txpower idx %d > 107\n", - power_idx); - power_idx = 107; - } - if (power_idx < 0) { - IL_WARN("txpower idx %d < 0\n", - power_idx); - power_idx = 0; - } - - /* fill txpower command for this rate/chain */ - tx_power.s.radio_tx_gain[c] = - gain_table[band][power_idx].radio; - tx_power.s.dsp_predis_atten[c] = - gain_table[band][power_idx].dsp; - - D_TXPOWER("chain %d mimo %d idx %d " - "gain 0x%02x dsp %d\n", - c, atten_value, power_idx, - tx_power.s.radio_tx_gain[c], - tx_power.s.dsp_predis_atten[c]); - } /* for each chain */ - - tx_power_tbl->power_tbl[i].dw = cpu_to_le32(tx_power.dw); - - } /* for each rate */ - - return 0; -} - -/** - * il4965_send_tx_power - Configure the TXPOWER level user limit - * - * Uses the active RXON for channel, band, and characteristics (ht40, high) - * The power limit is taken from il->tx_power_user_lmt. - */ -static int il4965_send_tx_power(struct il_priv *il) -{ - struct il4965_txpowertable_cmd cmd = { 0 }; - int ret; - u8 band = 0; - bool is_ht40 = false; - u8 ctrl_chan_high = 0; - struct il_rxon_context *ctx = &il->ctx; - - if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &il->status), - "TX Power requested while scanning!\n")) - return -EAGAIN; - - band = il->band == IEEE80211_BAND_2GHZ; - - is_ht40 = iw4965_is_ht40_channel(ctx->active.flags); - - if (is_ht40 && (ctx->active.flags & RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK)) - ctrl_chan_high = 1; - - cmd.band = band; - cmd.channel = ctx->active.channel; - - ret = il4965_fill_txpower_tbl(il, band, - le16_to_cpu(ctx->active.channel), - is_ht40, ctrl_chan_high, &cmd.tx_power); - if (ret) - goto out; - - ret = il_send_cmd_pdu(il, - REPLY_TX_PWR_TBL_CMD, sizeof(cmd), &cmd); - -out: - return ret; -} - -static int il4965_send_rxon_assoc(struct il_priv *il, - struct il_rxon_context *ctx) -{ - int ret = 0; - struct il4965_rxon_assoc_cmd rxon_assoc; - const struct il_rxon_cmd *rxon1 = &ctx->staging; - const struct il_rxon_cmd *rxon2 = &ctx->active; - - if (rxon1->flags == rxon2->flags && - rxon1->filter_flags == rxon2->filter_flags && - rxon1->cck_basic_rates == rxon2->cck_basic_rates && - rxon1->ofdm_ht_single_stream_basic_rates == - rxon2->ofdm_ht_single_stream_basic_rates && - rxon1->ofdm_ht_dual_stream_basic_rates == - rxon2->ofdm_ht_dual_stream_basic_rates && - rxon1->rx_chain == rxon2->rx_chain && - rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates) { - D_INFO("Using current RXON_ASSOC. Not resending.\n"); - return 0; - } - - rxon_assoc.flags = ctx->staging.flags; - rxon_assoc.filter_flags = ctx->staging.filter_flags; - rxon_assoc.ofdm_basic_rates = ctx->staging.ofdm_basic_rates; - rxon_assoc.cck_basic_rates = ctx->staging.cck_basic_rates; - rxon_assoc.reserved = 0; - rxon_assoc.ofdm_ht_single_stream_basic_rates = - ctx->staging.ofdm_ht_single_stream_basic_rates; - rxon_assoc.ofdm_ht_dual_stream_basic_rates = - ctx->staging.ofdm_ht_dual_stream_basic_rates; - rxon_assoc.rx_chain_select_flags = ctx->staging.rx_chain; - - ret = il_send_cmd_pdu_async(il, REPLY_RXON_ASSOC, - sizeof(rxon_assoc), &rxon_assoc, NULL); - - return ret; -} - -static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) -{ - /* cast away the const for active_rxon in this function */ - struct il_rxon_cmd *active_rxon = (void *)&ctx->active; - int ret; - bool new_assoc = - !!(ctx->staging.filter_flags & RXON_FILTER_ASSOC_MSK); - - if (!il_is_alive(il)) - return -EBUSY; - - if (!ctx->is_active) - return 0; - - /* always get timestamp with Rx frame */ - ctx->staging.flags |= RXON_FLG_TSF2HOST_MSK; - - ret = il_check_rxon_cmd(il, ctx); - if (ret) { - IL_ERR("Invalid RXON configuration. Not committing.\n"); - return -EINVAL; - } - - /* - * receive commit_rxon request - * abort any previous channel switch if still in process - */ - if (test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status) && - il->switch_channel != ctx->staging.channel) { - D_11H("abort channel switch on %d\n", - le16_to_cpu(il->switch_channel)); - il_chswitch_done(il, false); - } - - /* If we don't need to send a full RXON, we can use - * il_rxon_assoc_cmd which is used to reconfigure filter - * and other flags for the current radio configuration. */ - if (!il_full_rxon_required(il, ctx)) { - ret = il_send_rxon_assoc(il, ctx); - if (ret) { - IL_ERR("Error setting RXON_ASSOC (%d)\n", ret); - return ret; - } - - memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); - il_print_rx_config_cmd(il, ctx); - /* - * We do not commit tx power settings while channel changing, - * do it now if tx power changed. - */ - il_set_tx_power(il, il->tx_power_next, false); - return 0; - } - - /* If we are currently associated and the new config requires - * an RXON_ASSOC and the new config wants the associated mask enabled, - * we must clear the associated from the active configuration - * before we apply the new config */ - if (il_is_associated_ctx(ctx) && new_assoc) { - D_INFO("Toggling associated bit on current RXON\n"); - active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; - - ret = il_send_cmd_pdu(il, ctx->rxon_cmd, - sizeof(struct il_rxon_cmd), - active_rxon); - - /* If the mask clearing failed then we set - * active_rxon back to what it was previously */ - if (ret) { - active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK; - IL_ERR("Error clearing ASSOC_MSK (%d)\n", ret); - return ret; - } - il_clear_ucode_stations(il, ctx); - il_restore_stations(il, ctx); - ret = il4965_restore_default_wep_keys(il, ctx); - if (ret) { - IL_ERR("Failed to restore WEP keys (%d)\n", ret); - return ret; - } - } - - D_INFO("Sending RXON\n" - "* with%s RXON_FILTER_ASSOC_MSK\n" - "* channel = %d\n" - "* bssid = %pM\n", - (new_assoc ? "" : "out"), - le16_to_cpu(ctx->staging.channel), - ctx->staging.bssid_addr); - - il_set_rxon_hwcrypto(il, ctx, - !il->cfg->mod_params->sw_crypto); - - /* Apply the new configuration - * RXON unassoc clears the station table in uCode so restoration of - * stations is needed after it (the RXON command) completes - */ - if (!new_assoc) { - ret = il_send_cmd_pdu(il, ctx->rxon_cmd, - sizeof(struct il_rxon_cmd), &ctx->staging); - if (ret) { - IL_ERR("Error setting new RXON (%d)\n", ret); - return ret; - } - D_INFO("Return from !new_assoc RXON.\n"); - memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); - il_clear_ucode_stations(il, ctx); - il_restore_stations(il, ctx); - ret = il4965_restore_default_wep_keys(il, ctx); - if (ret) { - IL_ERR("Failed to restore WEP keys (%d)\n", ret); - return ret; - } - } - if (new_assoc) { - il->start_calib = 0; - /* Apply the new configuration - * RXON assoc doesn't clear the station table in uCode, - */ - ret = il_send_cmd_pdu(il, ctx->rxon_cmd, - sizeof(struct il_rxon_cmd), &ctx->staging); - if (ret) { - IL_ERR("Error setting new RXON (%d)\n", ret); - return ret; - } - memcpy(active_rxon, &ctx->staging, sizeof(*active_rxon)); - } - il_print_rx_config_cmd(il, ctx); - - il4965_init_sensitivity(il); - - /* If we issue a new RXON command which required a tune then we must - * send a new TXPOWER command or we won't be able to Tx any frames */ - ret = il_set_tx_power(il, il->tx_power_next, true); - if (ret) { - IL_ERR("Error sending TX power (%d)\n", ret); - return ret; - } - - return 0; -} - -static int il4965_hw_channel_switch(struct il_priv *il, - struct ieee80211_channel_switch *ch_switch) -{ - struct il_rxon_context *ctx = &il->ctx; - int rc; - u8 band = 0; - bool is_ht40 = false; - u8 ctrl_chan_high = 0; - struct il4965_channel_switch_cmd cmd; - const struct il_channel_info *ch_info; - u32 switch_time_in_usec, ucode_switch_time; - u16 ch; - u32 tsf_low; - u8 switch_count; - u16 beacon_interval = le16_to_cpu(ctx->timing.beacon_interval); - struct ieee80211_vif *vif = ctx->vif; - band = il->band == IEEE80211_BAND_2GHZ; - - is_ht40 = iw4965_is_ht40_channel(ctx->staging.flags); - - if (is_ht40 && - (ctx->staging.flags & RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK)) - ctrl_chan_high = 1; - - cmd.band = band; - cmd.expect_beacon = 0; - ch = ch_switch->channel->hw_value; - cmd.channel = cpu_to_le16(ch); - cmd.rxon_flags = ctx->staging.flags; - cmd.rxon_filter_flags = ctx->staging.filter_flags; - switch_count = ch_switch->count; - tsf_low = ch_switch->timestamp & 0x0ffffffff; - /* - * calculate the ucode channel switch time - * adding TSF as one of the factor for when to switch - */ - if (il->ucode_beacon_time > tsf_low && beacon_interval) { - if (switch_count > ((il->ucode_beacon_time - tsf_low) / - beacon_interval)) { - switch_count -= (il->ucode_beacon_time - - tsf_low) / beacon_interval; - } else - switch_count = 0; - } - if (switch_count <= 1) - cmd.switch_time = cpu_to_le32(il->ucode_beacon_time); - else { - switch_time_in_usec = - vif->bss_conf.beacon_int * switch_count * TIME_UNIT; - ucode_switch_time = il_usecs_to_beacons(il, - switch_time_in_usec, - beacon_interval); - cmd.switch_time = il_add_beacon_time(il, - il->ucode_beacon_time, - ucode_switch_time, - beacon_interval); - } - D_11H("uCode time for the switch is 0x%x\n", - cmd.switch_time); - ch_info = il_get_channel_info(il, il->band, ch); - if (ch_info) - cmd.expect_beacon = il_is_channel_radar(ch_info); - else { - IL_ERR("invalid channel switch from %u to %u\n", - ctx->active.channel, ch); - return -EFAULT; - } - - rc = il4965_fill_txpower_tbl(il, band, ch, is_ht40, - ctrl_chan_high, &cmd.tx_power); - if (rc) { - D_11H("error:%d fill txpower_tbl\n", rc); - return rc; - } - - return il_send_cmd_pdu(il, - REPLY_CHANNEL_SWITCH, sizeof(cmd), &cmd); -} - -/** - * il4965_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array - */ -static void il4965_txq_update_byte_cnt_tbl(struct il_priv *il, - struct il_tx_queue *txq, - u16 byte_cnt) -{ - struct il4965_scd_bc_tbl *scd_bc_tbl = il->scd_bc_tbls.addr; - int txq_id = txq->q.id; - int write_ptr = txq->q.write_ptr; - int len = byte_cnt + IL_TX_CRC_SIZE + IL_TX_DELIMITER_SIZE; - __le16 bc_ent; - - WARN_ON(len > 0xFFF || write_ptr >= TFD_QUEUE_SIZE_MAX); - - bc_ent = cpu_to_le16(len & 0xFFF); - /* Set up byte count within first 256 entries */ - scd_bc_tbl[txq_id].tfd_offset[write_ptr] = bc_ent; - - /* If within first 64 entries, duplicate at end */ - if (write_ptr < TFD_QUEUE_SIZE_BC_DUP) - scd_bc_tbl[txq_id]. - tfd_offset[TFD_QUEUE_SIZE_MAX + write_ptr] = bc_ent; -} - -/** - * il4965_hw_get_temperature - return the calibrated temperature (in Kelvin) - * @stats: Provides the temperature reading from the uCode - * - * A return of <0 indicates bogus data in the stats - */ -static int il4965_hw_get_temperature(struct il_priv *il) -{ - s32 temperature; - s32 vt; - s32 R1, R2, R3; - u32 R4; - - if (test_bit(STATUS_TEMPERATURE, &il->status) && - (il->_4965.stats.flag & - STATISTICS_REPLY_FLG_HT40_MODE_MSK)) { - D_TEMP("Running HT40 temperature calibration\n"); - R1 = (s32)le32_to_cpu(il->card_alive_init.therm_r1[1]); - R2 = (s32)le32_to_cpu(il->card_alive_init.therm_r2[1]); - R3 = (s32)le32_to_cpu(il->card_alive_init.therm_r3[1]); - R4 = le32_to_cpu(il->card_alive_init.therm_r4[1]); - } else { - D_TEMP("Running temperature calibration\n"); - R1 = (s32)le32_to_cpu(il->card_alive_init.therm_r1[0]); - R2 = (s32)le32_to_cpu(il->card_alive_init.therm_r2[0]); - R3 = (s32)le32_to_cpu(il->card_alive_init.therm_r3[0]); - R4 = le32_to_cpu(il->card_alive_init.therm_r4[0]); - } - - /* - * Temperature is only 23 bits, so sign extend out to 32. - * - * NOTE If we haven't received a stats notification yet - * with an updated temperature, use R4 provided to us in the - * "initialize" ALIVE response. - */ - if (!test_bit(STATUS_TEMPERATURE, &il->status)) - vt = sign_extend32(R4, 23); - else - vt = sign_extend32(le32_to_cpu(il->_4965.stats. - general.common.temperature), 23); - - D_TEMP("Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt); - - if (R3 == R1) { - IL_ERR("Calibration conflict R1 == R3\n"); - return -1; - } - - /* Calculate temperature in degrees Kelvin, adjust by 97%. - * Add offset to center the adjustment around 0 degrees Centigrade. */ - temperature = TEMPERATURE_CALIB_A_VAL * (vt - R2); - temperature /= (R3 - R1); - temperature = (temperature * 97) / 100 + TEMPERATURE_CALIB_KELVIN_OFFSET; - - D_TEMP("Calibrated temperature: %dK, %dC\n", - temperature, KELVIN_TO_CELSIUS(temperature)); - - return temperature; -} - -/* Adjust Txpower only if temperature variance is greater than threshold. */ -#define IL_TEMPERATURE_THRESHOLD 3 - -/** - * il4965_is_temp_calib_needed - determines if new calibration is needed - * - * If the temperature changed has changed sufficiently, then a recalibration - * is needed. - * - * Assumes caller will replace il->last_temperature once calibration - * executed. - */ -static int il4965_is_temp_calib_needed(struct il_priv *il) -{ - int temp_diff; - - if (!test_bit(STATUS_STATISTICS, &il->status)) { - D_TEMP("Temperature not updated -- no stats.\n"); - return 0; - } - - temp_diff = il->temperature - il->last_temperature; - - /* get absolute value */ - if (temp_diff < 0) { - D_POWER("Getting cooler, delta %d\n", temp_diff); - temp_diff = -temp_diff; - } else if (temp_diff == 0) - D_POWER("Temperature unchanged\n"); - else - D_POWER("Getting warmer, delta %d\n", temp_diff); - - if (temp_diff < IL_TEMPERATURE_THRESHOLD) { - D_POWER(" => thermal txpower calib not needed\n"); - return 0; - } - - D_POWER(" => thermal txpower calib needed\n"); - - return 1; -} - -static void il4965_temperature_calib(struct il_priv *il) -{ - s32 temp; - - temp = il4965_hw_get_temperature(il); - if (IL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(temp)) - return; - - if (il->temperature != temp) { - if (il->temperature) - D_TEMP("Temperature changed " - "from %dC to %dC\n", - KELVIN_TO_CELSIUS(il->temperature), - KELVIN_TO_CELSIUS(temp)); - else - D_TEMP("Temperature " - "initialized to %dC\n", - KELVIN_TO_CELSIUS(temp)); - } - - il->temperature = temp; - set_bit(STATUS_TEMPERATURE, &il->status); - - if (!il->disable_tx_power_cal && - unlikely(!test_bit(STATUS_SCANNING, &il->status)) && - il4965_is_temp_calib_needed(il)) - queue_work(il->workqueue, &il->txpower_work); -} - -static u16 il4965_get_hcmd_size(u8 cmd_id, u16 len) -{ - switch (cmd_id) { - case REPLY_RXON: - return (u16) sizeof(struct il4965_rxon_cmd); - default: - return len; - } -} - -static u16 il4965_build_addsta_hcmd(const struct il_addsta_cmd *cmd, - u8 *data) -{ - struct il4965_addsta_cmd *addsta = (struct il4965_addsta_cmd *)data; - addsta->mode = cmd->mode; - memcpy(&addsta->sta, &cmd->sta, sizeof(struct sta_id_modify)); - memcpy(&addsta->key, &cmd->key, sizeof(struct il4965_keyinfo)); - addsta->station_flags = cmd->station_flags; - addsta->station_flags_msk = cmd->station_flags_msk; - addsta->tid_disable_tx = cmd->tid_disable_tx; - addsta->add_immediate_ba_tid = cmd->add_immediate_ba_tid; - addsta->remove_immediate_ba_tid = cmd->remove_immediate_ba_tid; - addsta->add_immediate_ba_ssn = cmd->add_immediate_ba_ssn; - addsta->sleep_tx_count = cmd->sleep_tx_count; - addsta->reserved1 = cpu_to_le16(0); - addsta->reserved2 = cpu_to_le16(0); - - return (u16)sizeof(struct il4965_addsta_cmd); -} - -static inline u32 il4965_get_scd_ssn(struct il4965_tx_resp *tx_resp) -{ - return le32_to_cpup(&tx_resp->u.status + tx_resp->frame_count) & MAX_SN; -} - -/** - * il4965_tx_status_reply_tx - Handle Tx response for frames in aggregation queue - */ -static int il4965_tx_status_reply_tx(struct il_priv *il, - struct il_ht_agg *agg, - struct il4965_tx_resp *tx_resp, - int txq_id, u16 start_idx) -{ - u16 status; - struct agg_tx_status *frame_status = tx_resp->u.agg_status; - struct ieee80211_tx_info *info = NULL; - struct ieee80211_hdr *hdr = NULL; - u32 rate_n_flags = le32_to_cpu(tx_resp->rate_n_flags); - int i, sh, idx; - u16 seq; - if (agg->wait_for_ba) - D_TX_REPLY("got tx response w/o block-ack\n"); - - agg->frame_count = tx_resp->frame_count; - agg->start_idx = start_idx; - agg->rate_n_flags = rate_n_flags; - agg->bitmap = 0; - - /* num frames attempted by Tx command */ - if (agg->frame_count == 1) { - /* Only one frame was attempted; no block-ack will arrive */ - status = le16_to_cpu(frame_status[0].status); - idx = start_idx; - - D_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n", - agg->frame_count, agg->start_idx, idx); - - info = IEEE80211_SKB_CB(il->txq[txq_id].txb[idx].skb); - info->status.rates[0].count = tx_resp->failure_frame + 1; - info->flags &= ~IEEE80211_TX_CTL_AMPDU; - info->flags |= il4965_tx_status_to_mac80211(status); - il4965_hwrate_to_tx_control(il, rate_n_flags, info); - - D_TX_REPLY("1 Frame 0x%x failure :%d\n", - status & 0xff, tx_resp->failure_frame); - D_TX_REPLY("Rate Info rate_n_flags=%x\n", rate_n_flags); - - agg->wait_for_ba = 0; - } else { - /* Two or more frames were attempted; expect block-ack */ - u64 bitmap = 0; - int start = agg->start_idx; - - /* Construct bit-map of pending frames within Tx win */ - for (i = 0; i < agg->frame_count; i++) { - u16 sc; - status = le16_to_cpu(frame_status[i].status); - seq = le16_to_cpu(frame_status[i].sequence); - idx = SEQ_TO_IDX(seq); - txq_id = SEQ_TO_QUEUE(seq); - - if (status & (AGG_TX_STATE_FEW_BYTES_MSK | - AGG_TX_STATE_ABORT_MSK)) - continue; - - D_TX_REPLY("FrameCnt = %d, txq_id=%d idx=%d\n", - agg->frame_count, txq_id, idx); - - hdr = il_tx_queue_get_hdr(il, txq_id, idx); - if (!hdr) { - IL_ERR( - "BUG_ON idx doesn't point to valid skb" - " idx=%d, txq_id=%d\n", idx, txq_id); - return -1; - } - - sc = le16_to_cpu(hdr->seq_ctrl); - if (idx != (SEQ_TO_SN(sc) & 0xff)) { - IL_ERR( - "BUG_ON idx doesn't match seq control" - " idx=%d, seq_idx=%d, seq=%d\n", - idx, SEQ_TO_SN(sc), hdr->seq_ctrl); - return -1; - } - - D_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n", - i, idx, SEQ_TO_SN(sc)); - - sh = idx - start; - if (sh > 64) { - sh = (start - idx) + 0xff; - bitmap = bitmap << sh; - sh = 0; - start = idx; - } else if (sh < -64) - sh = 0xff - (start - idx); - else if (sh < 0) { - sh = start - idx; - start = idx; - bitmap = bitmap << sh; - sh = 0; - } - bitmap |= 1ULL << sh; - D_TX_REPLY("start=%d bitmap=0x%llx\n", - start, (unsigned long long)bitmap); - } - - agg->bitmap = bitmap; - agg->start_idx = start; - D_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n", - agg->frame_count, agg->start_idx, - (unsigned long long)agg->bitmap); - - if (bitmap) - agg->wait_for_ba = 1; - } - return 0; -} - -static u8 il4965_find_station(struct il_priv *il, const u8 *addr) -{ - int i; - int start = 0; - int ret = IL_INVALID_STATION; - unsigned long flags; - - if ((il->iw_mode == NL80211_IFTYPE_ADHOC)) - start = IL_STA_ID; - - if (is_broadcast_ether_addr(addr)) - return il->ctx.bcast_sta_id; - - spin_lock_irqsave(&il->sta_lock, flags); - for (i = start; i < il->hw_params.max_stations; i++) - if (il->stations[i].used && - (!compare_ether_addr(il->stations[i].sta.sta.addr, - addr))) { - ret = i; - goto out; - } - - D_ASSOC("can not find STA %pM total %d\n", - addr, il->num_stations); - - out: - /* - * It may be possible that more commands interacting with stations - * arrive before we completed processing the adding of - * station - */ - if (ret != IL_INVALID_STATION && - (!(il->stations[ret].used & IL_STA_UCODE_ACTIVE) || - ((il->stations[ret].used & IL_STA_UCODE_ACTIVE) && - (il->stations[ret].used & IL_STA_UCODE_INPROGRESS)))) { - IL_ERR("Requested station info for sta %d before ready.\n", - ret); - ret = IL_INVALID_STATION; - } - spin_unlock_irqrestore(&il->sta_lock, flags); - return ret; -} - -static int il4965_get_ra_sta_id(struct il_priv *il, struct ieee80211_hdr *hdr) -{ - if (il->iw_mode == NL80211_IFTYPE_STATION) { - return IL_AP_ID; - } else { - u8 *da = ieee80211_get_DA(hdr); - return il4965_find_station(il, da); - } -} - -/** - * il4965_rx_reply_tx - Handle standard (non-aggregation) Tx response - */ -static void il4965_rx_reply_tx(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - u16 sequence = le16_to_cpu(pkt->hdr.sequence); - int txq_id = SEQ_TO_QUEUE(sequence); - int idx = SEQ_TO_IDX(sequence); - struct il_tx_queue *txq = &il->txq[txq_id]; - struct ieee80211_hdr *hdr; - struct ieee80211_tx_info *info; - struct il4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; - u32 status = le32_to_cpu(tx_resp->u.status); - int uninitialized_var(tid); - int sta_id; - int freed; - u8 *qc = NULL; - unsigned long flags; - - if (idx >= txq->q.n_bd || il_queue_used(&txq->q, idx) == 0) { - IL_ERR("Read idx for DMA queue txq_id (%d) idx %d " - "is out of range [0-%d] %d %d\n", txq_id, - idx, txq->q.n_bd, txq->q.write_ptr, - txq->q.read_ptr); - return; - } - - txq->time_stamp = jiffies; - info = IEEE80211_SKB_CB(txq->txb[txq->q.read_ptr].skb); - memset(&info->status, 0, sizeof(info->status)); - - hdr = il_tx_queue_get_hdr(il, txq_id, idx); - if (ieee80211_is_data_qos(hdr->frame_control)) { - qc = ieee80211_get_qos_ctl(hdr); - tid = qc[0] & 0xf; - } - - sta_id = il4965_get_ra_sta_id(il, hdr); - if (txq->sched_retry && unlikely(sta_id == IL_INVALID_STATION)) { - IL_ERR("Station not known\n"); - return; - } - - spin_lock_irqsave(&il->sta_lock, flags); - if (txq->sched_retry) { - const u32 scd_ssn = il4965_get_scd_ssn(tx_resp); - struct il_ht_agg *agg = NULL; - WARN_ON(!qc); - - agg = &il->stations[sta_id].tid[tid].agg; - - il4965_tx_status_reply_tx(il, agg, tx_resp, txq_id, idx); - - /* check if BAR is needed */ - if ((tx_resp->frame_count == 1) && !il4965_is_tx_success(status)) - info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK; - - if (txq->q.read_ptr != (scd_ssn & 0xff)) { - idx = il_queue_dec_wrap(scd_ssn & 0xff, - txq->q.n_bd); - D_TX_REPLY("Retry scheduler reclaim scd_ssn " - "%d idx %d\n", scd_ssn , idx); - freed = il4965_tx_queue_reclaim(il, txq_id, idx); - if (qc) - il4965_free_tfds_in_queue(il, sta_id, - tid, freed); - - if (il->mac80211_registered && - il_queue_space(&txq->q) > txq->q.low_mark && - agg->state != IL_EMPTYING_HW_QUEUE_DELBA) - il_wake_queue(il, txq); - } - } else { - info->status.rates[0].count = tx_resp->failure_frame + 1; - info->flags |= il4965_tx_status_to_mac80211(status); - il4965_hwrate_to_tx_control(il, - le32_to_cpu(tx_resp->rate_n_flags), - info); - - D_TX_REPLY("TXQ %d status %s (0x%08x) " - "rate_n_flags 0x%x retries %d\n", - txq_id, - il4965_get_tx_fail_reason(status), status, - le32_to_cpu(tx_resp->rate_n_flags), - tx_resp->failure_frame); - - freed = il4965_tx_queue_reclaim(il, txq_id, idx); - if (qc && likely(sta_id != IL_INVALID_STATION)) - il4965_free_tfds_in_queue(il, sta_id, tid, freed); - else if (sta_id == IL_INVALID_STATION) - D_TX_REPLY("Station not known\n"); - - if (il->mac80211_registered && - il_queue_space(&txq->q) > txq->q.low_mark) - il_wake_queue(il, txq); - } - if (qc && likely(sta_id != IL_INVALID_STATION)) - il4965_txq_check_empty(il, sta_id, tid, txq_id); - - il4965_check_abort_status(il, tx_resp->frame_count, status); - - spin_unlock_irqrestore(&il->sta_lock, flags); -} - -static void il4965_rx_beacon_notif(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il4965_beacon_notif *beacon = (void *)pkt->u.raw; - u8 rate __maybe_unused = - il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); - - D_RX("beacon status %#x, retries:%d ibssmgr:%d " - "tsf:0x%.8x%.8x rate:%d\n", - le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, - beacon->beacon_notify_hdr.failure_frame, - le32_to_cpu(beacon->ibss_mgr_status), - le32_to_cpu(beacon->high_tsf), - le32_to_cpu(beacon->low_tsf), rate); - - il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); -} - -/* Set up 4965-specific Rx frame reply handlers */ -static void il4965_rx_handler_setup(struct il_priv *il) -{ - /* Legacy Rx frames */ - il->rx_handlers[REPLY_RX] = il4965_rx_reply_rx; - /* Tx response */ - il->rx_handlers[REPLY_TX] = il4965_rx_reply_tx; - il->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; -} - -static struct il_hcmd_ops il4965_hcmd = { - .rxon_assoc = il4965_send_rxon_assoc, - .commit_rxon = il4965_commit_rxon, - .set_rxon_chain = il4965_set_rxon_chain, -}; - -static void il4965_post_scan(struct il_priv *il) -{ - struct il_rxon_context *ctx = &il->ctx; - - /* - * Since setting the RXON may have been deferred while - * performing the scan, fire one off if needed - */ - if (memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) - il_commit_rxon(il, ctx); -} - -static void il4965_post_associate(struct il_priv *il) -{ - struct il_rxon_context *ctx = &il->ctx; - struct ieee80211_vif *vif = ctx->vif; - struct ieee80211_conf *conf = NULL; - int ret = 0; - - if (!vif || !il->is_open) - return; - - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - return; - - il_scan_cancel_timeout(il, 200); - - conf = il_ieee80211_get_hw_conf(il->hw); - - ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - il_commit_rxon(il, ctx); - - ret = il_send_rxon_timing(il, ctx); - if (ret) - IL_WARN("RXON timing - " - "Attempting to continue.\n"); - - ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - - il_set_rxon_ht(il, &il->current_ht_config); - - if (il->cfg->ops->hcmd->set_rxon_chain) - il->cfg->ops->hcmd->set_rxon_chain(il, ctx); - - ctx->staging.assoc_id = cpu_to_le16(vif->bss_conf.aid); - - D_ASSOC("assoc id %d beacon interval %d\n", - vif->bss_conf.aid, vif->bss_conf.beacon_int); - - if (vif->bss_conf.use_short_preamble) - ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; - else - ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; - - if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) { - if (vif->bss_conf.use_short_slot) - ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; - else - ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; - } - - il_commit_rxon(il, ctx); - - D_ASSOC("Associated as %d to: %pM\n", - vif->bss_conf.aid, ctx->active.bssid_addr); - - switch (vif->type) { - case NL80211_IFTYPE_STATION: - break; - case NL80211_IFTYPE_ADHOC: - il4965_send_beacon_cmd(il); - break; - default: - IL_ERR("%s Should not be called in %d mode\n", - __func__, vif->type); - break; - } - - /* the chain noise calibration will enabled PM upon completion - * If chain noise has already been run, then we need to enable - * power management here */ - if (il->chain_noise_data.state == IL_CHAIN_NOISE_DONE) - il_power_update_mode(il, false); - - /* Enable Rx differential gain and sensitivity calibrations */ - il4965_chain_noise_reset(il); - il->start_calib = 1; -} - -static void il4965_config_ap(struct il_priv *il) -{ - struct il_rxon_context *ctx = &il->ctx; - struct ieee80211_vif *vif = ctx->vif; - int ret = 0; - - lockdep_assert_held(&il->mutex); - - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - return; - - /* The following should be done only at AP bring up */ - if (!il_is_associated_ctx(ctx)) { - - /* RXON - unassoc (to set timing command) */ - ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - il_commit_rxon(il, ctx); - - /* RXON Timing */ - ret = il_send_rxon_timing(il, ctx); - if (ret) - IL_WARN("RXON timing failed - " - "Attempting to continue.\n"); - - /* AP has all antennas */ - il->chain_noise_data.active_chains = - il->hw_params.valid_rx_ant; - il_set_rxon_ht(il, &il->current_ht_config); - if (il->cfg->ops->hcmd->set_rxon_chain) - il->cfg->ops->hcmd->set_rxon_chain(il, ctx); - - ctx->staging.assoc_id = 0; - - if (vif->bss_conf.use_short_preamble) - ctx->staging.flags |= - RXON_FLG_SHORT_PREAMBLE_MSK; - else - ctx->staging.flags &= - ~RXON_FLG_SHORT_PREAMBLE_MSK; - - if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) { - if (vif->bss_conf.use_short_slot) - ctx->staging.flags |= - RXON_FLG_SHORT_SLOT_MSK; - else - ctx->staging.flags &= - ~RXON_FLG_SHORT_SLOT_MSK; - } - /* need to send beacon cmd before committing assoc RXON! */ - il4965_send_beacon_cmd(il); - /* restore RXON assoc */ - ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - il_commit_rxon(il, ctx); - } - il4965_send_beacon_cmd(il); -} - -static struct il_hcmd_utils_ops il4965_hcmd_utils = { - .get_hcmd_size = il4965_get_hcmd_size, - .build_addsta_hcmd = il4965_build_addsta_hcmd, - .request_scan = il4965_request_scan, - .post_scan = il4965_post_scan, -}; - -static struct il_lib_ops il4965_lib = { - .set_hw_params = il4965_hw_set_hw_params, - .txq_update_byte_cnt_tbl = il4965_txq_update_byte_cnt_tbl, - .txq_attach_buf_to_tfd = il4965_hw_txq_attach_buf_to_tfd, - .txq_free_tfd = il4965_hw_txq_free_tfd, - .txq_init = il4965_hw_tx_queue_init, - .rx_handler_setup = il4965_rx_handler_setup, - .is_valid_rtc_data_addr = il4965_hw_valid_rtc_data_addr, - .init_alive_start = il4965_init_alive_start, - .load_ucode = il4965_load_bsm, - .dump_nic_error_log = il4965_dump_nic_error_log, - .dump_fh = il4965_dump_fh, - .set_channel_switch = il4965_hw_channel_switch, - .apm_ops = { - .init = il_apm_init, - .config = il4965_nic_config, - }, - .eeprom_ops = { - .regulatory_bands = { - EEPROM_REGULATORY_BAND_1_CHANNELS, - EEPROM_REGULATORY_BAND_2_CHANNELS, - EEPROM_REGULATORY_BAND_3_CHANNELS, - EEPROM_REGULATORY_BAND_4_CHANNELS, - EEPROM_REGULATORY_BAND_5_CHANNELS, - EEPROM_4965_REGULATORY_BAND_24_HT40_CHANNELS, - EEPROM_4965_REGULATORY_BAND_52_HT40_CHANNELS - }, - .acquire_semaphore = il4965_eeprom_acquire_semaphore, - .release_semaphore = il4965_eeprom_release_semaphore, - }, - .send_tx_power = il4965_send_tx_power, - .update_chain_flags = il4965_update_chain_flags, - .temp_ops = { - .temperature = il4965_temperature_calib, - }, - .debugfs_ops = { - .rx_stats_read = il4965_ucode_rx_stats_read, - .tx_stats_read = il4965_ucode_tx_stats_read, - .general_stats_read = il4965_ucode_general_stats_read, - }, -}; - -static const struct il_legacy_ops il4965_legacy_ops = { - .post_associate = il4965_post_associate, - .config_ap = il4965_config_ap, - .manage_ibss_station = il4965_manage_ibss_station, - .update_bcast_stations = il4965_update_bcast_stations, -}; - -struct ieee80211_ops il4965_hw_ops = { - .tx = il4965_mac_tx, - .start = il4965_mac_start, - .stop = il4965_mac_stop, - .add_interface = il_mac_add_interface, - .remove_interface = il_mac_remove_interface, - .change_interface = il_mac_change_interface, - .config = il_mac_config, - .configure_filter = il4965_configure_filter, - .set_key = il4965_mac_set_key, - .update_tkip_key = il4965_mac_update_tkip_key, - .conf_tx = il_mac_conf_tx, - .reset_tsf = il_mac_reset_tsf, - .bss_info_changed = il_mac_bss_info_changed, - .ampdu_action = il4965_mac_ampdu_action, - .hw_scan = il_mac_hw_scan, - .sta_add = il4965_mac_sta_add, - .sta_remove = il_mac_sta_remove, - .channel_switch = il4965_mac_channel_switch, - .tx_last_beacon = il_mac_tx_last_beacon, -}; - -static const struct il_ops il4965_ops = { - .lib = &il4965_lib, - .hcmd = &il4965_hcmd, - .utils = &il4965_hcmd_utils, - .led = &il4965_led_ops, - .legacy = &il4965_legacy_ops, - .ieee80211_ops = &il4965_hw_ops, -}; - -static struct il_base_params il4965_base_params = { - .eeprom_size = IL4965_EEPROM_IMG_SIZE, - .num_of_queues = IL49_NUM_QUEUES, - .num_of_ampdu_queues = IL49_NUM_AMPDU_QUEUES, - .pll_cfg_val = 0, - .set_l0s = true, - .use_bsm = true, - .led_compensation = 61, - .chain_noise_num_beacons = IL4965_CAL_NUM_BEACONS, - .wd_timeout = IL_DEF_WD_TIMEOUT, - .temperature_kelvin = true, - .ucode_tracing = true, - .sensitivity_calib_by_driver = true, - .chain_noise_calib_by_driver = true, -}; - -struct il_cfg il4965_cfg = { - .name = "Intel(R) Wireless WiFi Link 4965AGN", - .fw_name_pre = IL4965_FW_PRE, - .ucode_api_max = IL4965_UCODE_API_MAX, - .ucode_api_min = IL4965_UCODE_API_MIN, - .sku = IL_SKU_A|IL_SKU_G|IL_SKU_N, - .valid_tx_ant = ANT_AB, - .valid_rx_ant = ANT_ABC, - .eeprom_ver = EEPROM_4965_EEPROM_VERSION, - .eeprom_calib_ver = EEPROM_4965_TX_POWER_VERSION, - .ops = &il4965_ops, - .mod_params = &il4965_mod_params, - .base_params = &il4965_base_params, - .led_mode = IL_LED_BLINK, - /* - * Force use of chains B and C for scan RX on 5 GHz band - * because the device has off-channel reception on chain A. - */ - .scan_rx_antennas[IEEE80211_BAND_5GHZ] = ANT_BC, -}; - -/* Module firmware */ -MODULE_FIRMWARE(IL4965_MODULE_FIRMWARE(IL4965_UCODE_API_MAX)); diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c deleted file mode 100644 index 151c8faa18dd..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl3945-base.c +++ /dev/null @@ -1,4007 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * Portions of this file are derived from the ipw3945 project, as well - * as portions of the ieee80211 subsystem header files. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#define DRV_NAME "iwl3945" - -#include "iwl-fh.h" -#include "iwl-3945-fh.h" -#include "iwl-commands.h" -#include "iwl-sta.h" -#include "iwl-3945.h" -#include "iwl-core.h" -#include "iwl-helpers.h" -#include "iwl-dev.h" -#include "iwl-spectrum.h" - -/* - * module name, copyright, version, etc. - */ - -#define DRV_DESCRIPTION \ -"Intel(R) PRO/Wireless 3945ABG/BG Network Connection driver for Linux" - -#ifdef CONFIG_IWLEGACY_DEBUG -#define VD "d" -#else -#define VD -#endif - -/* - * add "s" to indicate spectrum measurement included. - * we add it here to be consistent with previous releases in which - * this was configurable. - */ -#define DRV_VERSION IWLWIFI_VERSION VD "s" -#define DRV_COPYRIGHT "Copyright(c) 2003-2011 Intel Corporation" -#define DRV_AUTHOR "" - -MODULE_DESCRIPTION(DRV_DESCRIPTION); -MODULE_VERSION(DRV_VERSION); -MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); -MODULE_LICENSE("GPL"); - - /* module parameters */ -struct il_mod_params il3945_mod_params = { - .sw_crypto = 1, - .restart_fw = 1, - .disable_hw_scan = 1, - /* the rest are 0 by default */ -}; - -/** - * il3945_get_antenna_flags - Get antenna flags for RXON command - * @il: eeprom and antenna fields are used to determine antenna flags - * - * il->eeprom39 is used to determine if antenna AUX/MAIN are reversed - * il3945_mod_params.antenna specifies the antenna diversity mode: - * - * IL_ANTENNA_DIVERSITY - NIC selects best antenna by itself - * IL_ANTENNA_MAIN - Force MAIN antenna - * IL_ANTENNA_AUX - Force AUX antenna - */ -__le32 il3945_get_antenna_flags(const struct il_priv *il) -{ - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - - switch (il3945_mod_params.antenna) { - case IL_ANTENNA_DIVERSITY: - return 0; - - case IL_ANTENNA_MAIN: - if (eeprom->antenna_switch_type) - return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_B_MSK; - return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_A_MSK; - - case IL_ANTENNA_AUX: - if (eeprom->antenna_switch_type) - return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_A_MSK; - return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_B_MSK; - } - - /* bad antenna selector value */ - IL_ERR("Bad antenna selector value (0x%x)\n", - il3945_mod_params.antenna); - - return 0; /* "diversity" is default if error */ -} - -static int il3945_set_ccmp_dynamic_key_info(struct il_priv *il, - struct ieee80211_key_conf *keyconf, - u8 sta_id) -{ - unsigned long flags; - __le16 key_flags = 0; - int ret; - - key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK); - key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); - - if (sta_id == il->ctx.bcast_sta_id) - key_flags |= STA_KEY_MULTICAST_MSK; - - keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; - keyconf->hw_key_idx = keyconf->keyidx; - key_flags &= ~STA_KEY_FLG_INVALID; - - spin_lock_irqsave(&il->sta_lock, flags); - il->stations[sta_id].keyinfo.cipher = keyconf->cipher; - il->stations[sta_id].keyinfo.keylen = keyconf->keylen; - memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, - keyconf->keylen); - - memcpy(il->stations[sta_id].sta.key.key, keyconf->key, - keyconf->keylen); - - if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) - == STA_KEY_FLG_NO_ENC) - il->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_idx(il); - /* else, we are overriding an existing key => no need to allocated room - * in uCode. */ - - WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, - "no space for a new key"); - - il->stations[sta_id].sta.key.key_flags = key_flags; - il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; - il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - - D_INFO("hwcrypto: modify ucode station key info\n"); - - ret = il_send_add_sta(il, - &il->stations[sta_id].sta, CMD_ASYNC); - - spin_unlock_irqrestore(&il->sta_lock, flags); - - return ret; -} - -static int il3945_set_tkip_dynamic_key_info(struct il_priv *il, - struct ieee80211_key_conf *keyconf, - u8 sta_id) -{ - return -EOPNOTSUPP; -} - -static int il3945_set_wep_dynamic_key_info(struct il_priv *il, - struct ieee80211_key_conf *keyconf, - u8 sta_id) -{ - return -EOPNOTSUPP; -} - -static int il3945_clear_sta_key_info(struct il_priv *il, u8 sta_id) -{ - unsigned long flags; - struct il_addsta_cmd sta_cmd; - - spin_lock_irqsave(&il->sta_lock, flags); - memset(&il->stations[sta_id].keyinfo, 0, sizeof(struct il_hw_key)); - memset(&il->stations[sta_id].sta.key, 0, - sizeof(struct il4965_keyinfo)); - il->stations[sta_id].sta.key.key_flags = STA_KEY_FLG_NO_ENC; - il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; - il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - memcpy(&sta_cmd, &il->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&il->sta_lock, flags); - - D_INFO("hwcrypto: clear ucode station key info\n"); - return il_send_add_sta(il, &sta_cmd, CMD_SYNC); -} - -static int il3945_set_dynamic_key(struct il_priv *il, - struct ieee80211_key_conf *keyconf, u8 sta_id) -{ - int ret = 0; - - keyconf->hw_key_idx = HW_KEY_DYNAMIC; - - switch (keyconf->cipher) { - case WLAN_CIPHER_SUITE_CCMP: - ret = il3945_set_ccmp_dynamic_key_info(il, keyconf, sta_id); - break; - case WLAN_CIPHER_SUITE_TKIP: - ret = il3945_set_tkip_dynamic_key_info(il, keyconf, sta_id); - break; - case WLAN_CIPHER_SUITE_WEP40: - case WLAN_CIPHER_SUITE_WEP104: - ret = il3945_set_wep_dynamic_key_info(il, keyconf, sta_id); - break; - default: - IL_ERR("Unknown alg: %s alg=%x\n", __func__, - keyconf->cipher); - ret = -EINVAL; - } - - D_WEP("Set dynamic key: alg=%x len=%d idx=%d sta=%d ret=%d\n", - keyconf->cipher, keyconf->keylen, keyconf->keyidx, - sta_id, ret); - - return ret; -} - -static int il3945_remove_static_key(struct il_priv *il) -{ - int ret = -EOPNOTSUPP; - - return ret; -} - -static int il3945_set_static_key(struct il_priv *il, - struct ieee80211_key_conf *key) -{ - if (key->cipher == WLAN_CIPHER_SUITE_WEP40 || - key->cipher == WLAN_CIPHER_SUITE_WEP104) - return -EOPNOTSUPP; - - IL_ERR("Static key invalid: cipher %x\n", key->cipher); - return -EINVAL; -} - -static void il3945_clear_free_frames(struct il_priv *il) -{ - struct list_head *element; - - D_INFO("%d frames on pre-allocated heap on clear.\n", - il->frames_count); - - while (!list_empty(&il->free_frames)) { - element = il->free_frames.next; - list_del(element); - kfree(list_entry(element, struct il3945_frame, list)); - il->frames_count--; - } - - if (il->frames_count) { - IL_WARN("%d frames still in use. Did we lose one?\n", - il->frames_count); - il->frames_count = 0; - } -} - -static struct il3945_frame *il3945_get_free_frame(struct il_priv *il) -{ - struct il3945_frame *frame; - struct list_head *element; - if (list_empty(&il->free_frames)) { - frame = kzalloc(sizeof(*frame), GFP_KERNEL); - if (!frame) { - IL_ERR("Could not allocate frame!\n"); - return NULL; - } - - il->frames_count++; - return frame; - } - - element = il->free_frames.next; - list_del(element); - return list_entry(element, struct il3945_frame, list); -} - -static void il3945_free_frame(struct il_priv *il, struct il3945_frame *frame) -{ - memset(frame, 0, sizeof(*frame)); - list_add(&frame->list, &il->free_frames); -} - -unsigned int il3945_fill_beacon_frame(struct il_priv *il, - struct ieee80211_hdr *hdr, - int left) -{ - - if (!il_is_associated(il) || !il->beacon_skb) - return 0; - - if (il->beacon_skb->len > left) - return 0; - - memcpy(hdr, il->beacon_skb->data, il->beacon_skb->len); - - return il->beacon_skb->len; -} - -static int il3945_send_beacon_cmd(struct il_priv *il) -{ - struct il3945_frame *frame; - unsigned int frame_size; - int rc; - u8 rate; - - frame = il3945_get_free_frame(il); - - if (!frame) { - IL_ERR("Could not obtain free frame buffer for beacon " - "command.\n"); - return -ENOMEM; - } - - rate = il_get_lowest_plcp(il, - &il->ctx); - - frame_size = il3945_hw_get_beacon_cmd(il, frame, rate); - - rc = il_send_cmd_pdu(il, REPLY_TX_BEACON, frame_size, - &frame->u.cmd[0]); - - il3945_free_frame(il, frame); - - return rc; -} - -static void il3945_unset_hw_params(struct il_priv *il) -{ - if (il->_3945.shared_virt) - dma_free_coherent(&il->pci_dev->dev, - sizeof(struct il3945_shared), - il->_3945.shared_virt, - il->_3945.shared_phys); -} - -static void il3945_build_tx_cmd_hwcrypto(struct il_priv *il, - struct ieee80211_tx_info *info, - struct il_device_cmd *cmd, - struct sk_buff *skb_frag, - int sta_id) -{ - struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; - struct il_hw_key *keyinfo = &il->stations[sta_id].keyinfo; - - tx_cmd->sec_ctl = 0; - - switch (keyinfo->cipher) { - case WLAN_CIPHER_SUITE_CCMP: - tx_cmd->sec_ctl = TX_CMD_SEC_CCM; - memcpy(tx_cmd->key, keyinfo->key, keyinfo->keylen); - D_TX("tx_cmd with AES hwcrypto\n"); - break; - - case WLAN_CIPHER_SUITE_TKIP: - break; - - case WLAN_CIPHER_SUITE_WEP104: - tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128; - /* fall through */ - case WLAN_CIPHER_SUITE_WEP40: - tx_cmd->sec_ctl |= TX_CMD_SEC_WEP | - (info->control.hw_key->hw_key_idx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT; - - memcpy(&tx_cmd->key[3], keyinfo->key, keyinfo->keylen); - - D_TX("Configuring packet for WEP encryption " - "with key %d\n", info->control.hw_key->hw_key_idx); - break; - - default: - IL_ERR("Unknown encode cipher %x\n", keyinfo->cipher); - break; - } -} - -/* - * handle build REPLY_TX command notification. - */ -static void il3945_build_tx_cmd_basic(struct il_priv *il, - struct il_device_cmd *cmd, - struct ieee80211_tx_info *info, - struct ieee80211_hdr *hdr, u8 std_id) -{ - struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; - __le32 tx_flags = tx_cmd->tx_flags; - __le16 fc = hdr->frame_control; - - tx_cmd->stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; - if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) { - tx_flags |= TX_CMD_FLG_ACK_MSK; - if (ieee80211_is_mgmt(fc)) - tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; - if (ieee80211_is_probe_resp(fc) && - !(le16_to_cpu(hdr->seq_ctrl) & 0xf)) - tx_flags |= TX_CMD_FLG_TSF_MSK; - } else { - tx_flags &= (~TX_CMD_FLG_ACK_MSK); - tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; - } - - tx_cmd->sta_id = std_id; - if (ieee80211_has_morefrags(fc)) - tx_flags |= TX_CMD_FLG_MORE_FRAG_MSK; - - if (ieee80211_is_data_qos(fc)) { - u8 *qc = ieee80211_get_qos_ctl(hdr); - tx_cmd->tid_tspec = qc[0] & 0xf; - tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK; - } else { - tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; - } - - il_tx_cmd_protection(il, info, fc, &tx_flags); - - tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); - if (ieee80211_is_mgmt(fc)) { - if (ieee80211_is_assoc_req(fc) || ieee80211_is_reassoc_req(fc)) - tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(3); - else - tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(2); - } else { - tx_cmd->timeout.pm_frame_timeout = 0; - } - - tx_cmd->driver_txop = 0; - tx_cmd->tx_flags = tx_flags; - tx_cmd->next_frame_len = 0; -} - -/* - * start REPLY_TX command process - */ -static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) -{ - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - struct il3945_tx_cmd *tx_cmd; - struct il_tx_queue *txq = NULL; - struct il_queue *q = NULL; - struct il_device_cmd *out_cmd; - struct il_cmd_meta *out_meta; - dma_addr_t phys_addr; - dma_addr_t txcmd_phys; - int txq_id = skb_get_queue_mapping(skb); - u16 len, idx, hdr_len; - u8 id; - u8 unicast; - u8 sta_id; - u8 tid = 0; - __le16 fc; - u8 wait_write_ptr = 0; - unsigned long flags; - - spin_lock_irqsave(&il->lock, flags); - if (il_is_rfkill(il)) { - D_DROP("Dropping - RF KILL\n"); - goto drop_unlock; - } - - if ((ieee80211_get_tx_rate(il->hw, info)->hw_value & 0xFF) == IL_INVALID_RATE) { - IL_ERR("ERROR: No TX rate available.\n"); - goto drop_unlock; - } - - unicast = !is_multicast_ether_addr(hdr->addr1); - id = 0; - - fc = hdr->frame_control; - -#ifdef CONFIG_IWLEGACY_DEBUG - if (ieee80211_is_auth(fc)) - D_TX("Sending AUTH frame\n"); - else if (ieee80211_is_assoc_req(fc)) - D_TX("Sending ASSOC frame\n"); - else if (ieee80211_is_reassoc_req(fc)) - D_TX("Sending REASSOC frame\n"); -#endif - - spin_unlock_irqrestore(&il->lock, flags); - - hdr_len = ieee80211_hdrlen(fc); - - /* Find idx into station table for destination station */ - sta_id = il_sta_id_or_broadcast( - il, &il->ctx, - info->control.sta); - if (sta_id == IL_INVALID_STATION) { - D_DROP("Dropping - INVALID STATION: %pM\n", - hdr->addr1); - goto drop; - } - - D_RATE("station Id %d\n", sta_id); - - if (ieee80211_is_data_qos(fc)) { - u8 *qc = ieee80211_get_qos_ctl(hdr); - tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK; - if (unlikely(tid >= MAX_TID_COUNT)) - goto drop; - } - - /* Descriptor for chosen Tx queue */ - txq = &il->txq[txq_id]; - q = &txq->q; - - if ((il_queue_space(q) < q->high_mark)) - goto drop; - - spin_lock_irqsave(&il->lock, flags); - - idx = il_get_cmd_idx(q, q->write_ptr, 0); - - /* Set up driver data for this TFD */ - memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct il_tx_info)); - txq->txb[q->write_ptr].skb = skb; - txq->txb[q->write_ptr].ctx = &il->ctx; - - /* Init first empty entry in queue's array of Tx/cmd buffers */ - out_cmd = txq->cmd[idx]; - out_meta = &txq->meta[idx]; - tx_cmd = (struct il3945_tx_cmd *)out_cmd->cmd.payload; - memset(&out_cmd->hdr, 0, sizeof(out_cmd->hdr)); - memset(tx_cmd, 0, sizeof(*tx_cmd)); - - /* - * Set up the Tx-command (not MAC!) header. - * Store the chosen Tx queue and TFD idx within the sequence field; - * after Tx, uCode's Tx response will return this value so driver can - * locate the frame within the tx queue and do post-tx processing. - */ - out_cmd->hdr.cmd = REPLY_TX; - out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | - IDX_TO_SEQ(q->write_ptr))); - - /* Copy MAC header from skb into command buffer */ - memcpy(tx_cmd->hdr, hdr, hdr_len); - - - if (info->control.hw_key) - il3945_build_tx_cmd_hwcrypto(il, info, out_cmd, skb, sta_id); - - /* TODO need this for burst mode later on */ - il3945_build_tx_cmd_basic(il, out_cmd, info, hdr, sta_id); - - /* set is_hcca to 0; it probably will never be implemented */ - il3945_hw_build_tx_cmd_rate(il, out_cmd, info, hdr, sta_id, 0); - - /* Total # bytes to be transmitted */ - len = (u16)skb->len; - tx_cmd->len = cpu_to_le16(len); - - il_dbg_log_tx_data_frame(il, len, hdr); - il_update_stats(il, true, fc, len); - tx_cmd->tx_flags &= ~TX_CMD_FLG_ANT_A_MSK; - tx_cmd->tx_flags &= ~TX_CMD_FLG_ANT_B_MSK; - - if (!ieee80211_has_morefrags(hdr->frame_control)) { - txq->need_update = 1; - } else { - wait_write_ptr = 1; - txq->need_update = 0; - } - - D_TX("sequence nr = 0X%x\n", - le16_to_cpu(out_cmd->hdr.sequence)); - D_TX("tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); - il_print_hex_dump(il, IL_DL_TX, tx_cmd, sizeof(*tx_cmd)); - il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd->hdr, - ieee80211_hdrlen(fc)); - - /* - * Use the first empty entry in this queue's command buffer array - * to contain the Tx command and MAC header concatenated together - * (payload data will be in another buffer). - * Size of this varies, due to varying MAC header length. - * If end is not dword aligned, we'll have 2 extra bytes at the end - * of the MAC header (device reads on dword boundaries). - * We'll tell device about this padding later. - */ - len = sizeof(struct il3945_tx_cmd) + - sizeof(struct il_cmd_header) + hdr_len; - len = (len + 3) & ~3; - - /* Physical address of this Tx command's header (not MAC header!), - * within command buffer array. */ - txcmd_phys = pci_map_single(il->pci_dev, &out_cmd->hdr, - len, PCI_DMA_TODEVICE); - /* we do not map meta data ... so we can safely access address to - * provide to unmap command*/ - dma_unmap_addr_set(out_meta, mapping, txcmd_phys); - dma_unmap_len_set(out_meta, len, len); - - /* Add buffer containing Tx command and MAC(!) header to TFD's - * first entry */ - il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, - txcmd_phys, len, 1, 0); - - - /* Set up TFD's 2nd entry to point directly to remainder of skb, - * if any (802.11 null frames have no payload). */ - len = skb->len - hdr_len; - if (len) { - phys_addr = pci_map_single(il->pci_dev, skb->data + hdr_len, - len, PCI_DMA_TODEVICE); - il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, - phys_addr, len, - 0, U32_PAD(len)); - } - - - /* Tell device the write idx *just past* this latest filled TFD */ - q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); - il_txq_update_write_ptr(il, txq); - spin_unlock_irqrestore(&il->lock, flags); - - if (il_queue_space(q) < q->high_mark - && il->mac80211_registered) { - if (wait_write_ptr) { - spin_lock_irqsave(&il->lock, flags); - txq->need_update = 1; - il_txq_update_write_ptr(il, txq); - spin_unlock_irqrestore(&il->lock, flags); - } - - il_stop_queue(il, txq); - } - - return 0; - -drop_unlock: - spin_unlock_irqrestore(&il->lock, flags); -drop: - return -1; -} - -static int il3945_get_measurement(struct il_priv *il, - struct ieee80211_measurement_params *params, - u8 type) -{ - struct il_spectrum_cmd spectrum; - struct il_rx_pkt *pkt; - struct il_host_cmd cmd = { - .id = REPLY_SPECTRUM_MEASUREMENT_CMD, - .data = (void *)&spectrum, - .flags = CMD_WANT_SKB, - }; - u32 add_time = le64_to_cpu(params->start_time); - int rc; - int spectrum_resp_status; - int duration = le16_to_cpu(params->duration); - struct il_rxon_context *ctx = &il->ctx; - - if (il_is_associated(il)) - add_time = il_usecs_to_beacons(il, - le64_to_cpu(params->start_time) - il->_3945.last_tsf, - le16_to_cpu(ctx->timing.beacon_interval)); - - memset(&spectrum, 0, sizeof(spectrum)); - - spectrum.channel_count = cpu_to_le16(1); - spectrum.flags = - RXON_FLG_TSF2HOST_MSK | RXON_FLG_ANT_A_MSK | RXON_FLG_DIS_DIV_MSK; - spectrum.filter_flags = MEASUREMENT_FILTER_FLAG; - cmd.len = sizeof(spectrum); - spectrum.len = cpu_to_le16(cmd.len - sizeof(spectrum.len)); - - if (il_is_associated(il)) - spectrum.start_time = - il_add_beacon_time(il, - il->_3945.last_beacon_time, add_time, - le16_to_cpu(ctx->timing.beacon_interval)); - else - spectrum.start_time = 0; - - spectrum.channels[0].duration = cpu_to_le32(duration * TIME_UNIT); - spectrum.channels[0].channel = params->channel; - spectrum.channels[0].type = type; - if (ctx->active.flags & RXON_FLG_BAND_24G_MSK) - spectrum.flags |= RXON_FLG_BAND_24G_MSK | - RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_TGG_PROTECT_MSK; - - rc = il_send_cmd_sync(il, &cmd); - if (rc) - return rc; - - pkt = (struct il_rx_pkt *)cmd.reply_page; - if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR("Bad return from REPLY_RX_ON_ASSOC command\n"); - rc = -EIO; - } - - spectrum_resp_status = le16_to_cpu(pkt->u.spectrum.status); - switch (spectrum_resp_status) { - case 0: /* Command will be handled */ - if (pkt->u.spectrum.id != 0xff) { - D_INFO("Replaced existing measurement: %d\n", - pkt->u.spectrum.id); - il->measurement_status &= ~MEASUREMENT_READY; - } - il->measurement_status |= MEASUREMENT_ACTIVE; - rc = 0; - break; - - case 1: /* Command will not be handled */ - rc = -EAGAIN; - break; - } - - il_free_pages(il, cmd.reply_page); - - return rc; -} - -static void il3945_rx_reply_alive(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il_alive_resp *palive; - struct delayed_work *pwork; - - palive = &pkt->u.alive_frame; - - D_INFO("Alive ucode status 0x%08X revision " - "0x%01X 0x%01X\n", - palive->is_valid, palive->ver_type, - palive->ver_subtype); - - if (palive->ver_subtype == INITIALIZE_SUBTYPE) { - D_INFO("Initialization Alive received.\n"); - memcpy(&il->card_alive_init, &pkt->u.alive_frame, - sizeof(struct il_alive_resp)); - pwork = &il->init_alive_start; - } else { - D_INFO("Runtime Alive received.\n"); - memcpy(&il->card_alive, &pkt->u.alive_frame, - sizeof(struct il_alive_resp)); - pwork = &il->alive_start; - il3945_disable_events(il); - } - - /* We delay the ALIVE response by 5ms to - * give the HW RF Kill time to activate... */ - if (palive->is_valid == UCODE_VALID_OK) - queue_delayed_work(il->workqueue, pwork, - msecs_to_jiffies(5)); - else - IL_WARN("uCode did not respond OK.\n"); -} - -static void il3945_rx_reply_add_sta(struct il_priv *il, - struct il_rx_buf *rxb) -{ -#ifdef CONFIG_IWLEGACY_DEBUG - struct il_rx_pkt *pkt = rxb_addr(rxb); -#endif - - D_RX("Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); -} - -static void il3945_rx_beacon_notif(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il3945_beacon_notif *beacon = &(pkt->u.beacon_status); -#ifdef CONFIG_IWLEGACY_DEBUG - u8 rate = beacon->beacon_notify_hdr.rate; - - D_RX("beacon status %x retries %d iss %d " - "tsf %d %d rate %d\n", - le32_to_cpu(beacon->beacon_notify_hdr.status) & TX_STATUS_MSK, - beacon->beacon_notify_hdr.failure_frame, - le32_to_cpu(beacon->ibss_mgr_status), - le32_to_cpu(beacon->high_tsf), - le32_to_cpu(beacon->low_tsf), rate); -#endif - - il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); - -} - -/* Handle notification from uCode that card's power state is changing - * due to software, hardware, or critical temperature RFKILL */ -static void il3945_rx_card_state_notif(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); - unsigned long status = il->status; - - IL_WARN("Card state received: HW:%s SW:%s\n", - (flags & HW_CARD_DISABLED) ? "Kill" : "On", - (flags & SW_CARD_DISABLED) ? "Kill" : "On"); - - _il_wr(il, CSR_UCODE_DRV_GP1_SET, - CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - - if (flags & HW_CARD_DISABLED) - set_bit(STATUS_RF_KILL_HW, &il->status); - else - clear_bit(STATUS_RF_KILL_HW, &il->status); - - - il_scan_cancel(il); - - if ((test_bit(STATUS_RF_KILL_HW, &status) != - test_bit(STATUS_RF_KILL_HW, &il->status))) - wiphy_rfkill_set_hw_state(il->hw->wiphy, - test_bit(STATUS_RF_KILL_HW, &il->status)); - else - wake_up(&il->wait_command_queue); -} - -/** - * il3945_setup_rx_handlers - Initialize Rx handler callbacks - * - * Setup the RX handlers for each of the reply types sent from the uCode - * to the host. - * - * This function chains into the hardware specific files for them to setup - * any hardware specific handlers as well. - */ -static void il3945_setup_rx_handlers(struct il_priv *il) -{ - il->rx_handlers[REPLY_ALIVE] = il3945_rx_reply_alive; - il->rx_handlers[REPLY_ADD_STA] = il3945_rx_reply_add_sta; - il->rx_handlers[REPLY_ERROR] = il_rx_reply_error; - il->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa; - il->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = - il_rx_spectrum_measure_notif; - il->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; - il->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = - il_rx_pm_debug_stats_notif; - il->rx_handlers[BEACON_NOTIFICATION] = il3945_rx_beacon_notif; - - /* - * The same handler is used for both the REPLY to a discrete - * stats request from the host as well as for the periodic - * stats notifications (after received beacons) from the uCode. - */ - il->rx_handlers[REPLY_STATISTICS_CMD] = il3945_reply_stats; - il->rx_handlers[STATISTICS_NOTIFICATION] = il3945_hw_rx_stats; - - il_setup_rx_scan_handlers(il); - il->rx_handlers[CARD_STATE_NOTIFICATION] = il3945_rx_card_state_notif; - - /* Set up hardware specific Rx handlers */ - il3945_hw_rx_handler_setup(il); -} - -/************************** RX-FUNCTIONS ****************************/ -/* - * Rx theory of operation - * - * The host allocates 32 DMA target addresses and passes the host address - * to the firmware at register IL_RFDS_TBL_LOWER + N * RFD_SIZE where N is - * 0 to 31 - * - * Rx Queue Indexes - * The host/firmware share two idx registers for managing the Rx buffers. - * - * The READ idx maps to the first position that the firmware may be writing - * to -- the driver can read up to (but not including) this position and get - * good data. - * The READ idx is managed by the firmware once the card is enabled. - * - * The WRITE idx maps to the last position the driver has read from -- the - * position preceding WRITE is the last slot the firmware can place a packet. - * - * The queue is empty (no good data) if WRITE = READ - 1, and is full if - * WRITE = READ. - * - * During initialization, the host sets up the READ queue position to the first - * IDX position, and WRITE to the last (READ - 1 wrapped) - * - * When the firmware places a packet in a buffer, it will advance the READ idx - * and fire the RX interrupt. The driver can then query the READ idx and - * process as many packets as possible, moving the WRITE idx forward as it - * resets the Rx queue buffers with new memory. - * - * The management in the driver is as follows: - * + A list of pre-allocated SKBs is stored in iwl->rxq->rx_free. When - * iwl->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled - * to replenish the iwl->rxq->rx_free. - * + In il3945_rx_replenish (scheduled) if 'processed' != 'read' then the - * iwl->rxq is replenished and the READ IDX is updated (updating the - * 'processed' and 'read' driver idxes as well) - * + A received packet is processed and handed to the kernel network stack, - * detached from the iwl->rxq. The driver 'processed' idx is updated. - * + The Host/Firmware iwl->rxq is replenished at tasklet time from the rx_free - * list. If there are no allocated buffers in iwl->rxq->rx_free, the READ - * IDX is not incremented and iwl->status(RX_STALLED) is set. If there - * were enough free buffers and RX_STALLED is set it is cleared. - * - * - * Driver sequence: - * - * il3945_rx_replenish() Replenishes rx_free list from rx_used, and calls - * il3945_rx_queue_restock - * il3945_rx_queue_restock() Moves available buffers from rx_free into Rx - * queue, updates firmware pointers, and updates - * the WRITE idx. If insufficient rx_free buffers - * are available, schedules il3945_rx_replenish - * - * -- enable interrupts -- - * ISR - il3945_rx() Detach il_rx_bufs from pool up to the - * READ IDX, detaching the SKB from the pool. - * Moves the packet buffer from queue to rx_used. - * Calls il3945_rx_queue_restock to refill any empty - * slots. - * ... - * - */ - -/** - * il3945_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr - */ -static inline __le32 il3945_dma_addr2rbd_ptr(struct il_priv *il, - dma_addr_t dma_addr) -{ - return cpu_to_le32((u32)dma_addr); -} - -/** - * il3945_rx_queue_restock - refill RX queue from pre-allocated pool - * - * If there are slots in the RX queue that need to be restocked, - * and we have free pre-allocated buffers, fill the ranks as much - * as we can, pulling from rx_free. - * - * This moves the 'write' idx forward to catch up with 'processed', and - * also updates the memory address in the firmware to reference the new - * target buffer. - */ -static void il3945_rx_queue_restock(struct il_priv *il) -{ - struct il_rx_queue *rxq = &il->rxq; - struct list_head *element; - struct il_rx_buf *rxb; - unsigned long flags; - int write; - - spin_lock_irqsave(&rxq->lock, flags); - write = rxq->write & ~0x7; - while (il_rx_queue_space(rxq) > 0 && rxq->free_count) { - /* Get next free Rx buffer, remove from free list */ - element = rxq->rx_free.next; - rxb = list_entry(element, struct il_rx_buf, list); - list_del(element); - - /* Point to Rx buffer via next RBD in circular buffer */ - rxq->bd[rxq->write] = il3945_dma_addr2rbd_ptr(il, rxb->page_dma); - rxq->queue[rxq->write] = rxb; - rxq->write = (rxq->write + 1) & RX_QUEUE_MASK; - rxq->free_count--; - } - spin_unlock_irqrestore(&rxq->lock, flags); - /* If the pre-allocated buffer pool is dropping low, schedule to - * refill it */ - if (rxq->free_count <= RX_LOW_WATERMARK) - queue_work(il->workqueue, &il->rx_replenish); - - - /* If we've added more space for the firmware to place data, tell it. - * Increment device's write pointer in multiples of 8. */ - if (rxq->write_actual != (rxq->write & ~0x7) || - abs(rxq->write - rxq->read) > 7) { - spin_lock_irqsave(&rxq->lock, flags); - rxq->need_update = 1; - spin_unlock_irqrestore(&rxq->lock, flags); - il_rx_queue_update_write_ptr(il, rxq); - } -} - -/** - * il3945_rx_replenish - Move all used packet from rx_used to rx_free - * - * When moving to rx_free an SKB is allocated for the slot. - * - * Also restock the Rx queue via il3945_rx_queue_restock. - * This is called as a scheduled work item (except for during initialization) - */ -static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) -{ - struct il_rx_queue *rxq = &il->rxq; - struct list_head *element; - struct il_rx_buf *rxb; - struct page *page; - unsigned long flags; - gfp_t gfp_mask = priority; - - while (1) { - spin_lock_irqsave(&rxq->lock, flags); - - if (list_empty(&rxq->rx_used)) { - spin_unlock_irqrestore(&rxq->lock, flags); - return; - } - spin_unlock_irqrestore(&rxq->lock, flags); - - if (rxq->free_count > RX_LOW_WATERMARK) - gfp_mask |= __GFP_NOWARN; - - if (il->hw_params.rx_page_order > 0) - gfp_mask |= __GFP_COMP; - - /* Alloc a new receive buffer */ - page = alloc_pages(gfp_mask, il->hw_params.rx_page_order); - if (!page) { - if (net_ratelimit()) - D_INFO("Failed to allocate SKB buffer.\n"); - if (rxq->free_count <= RX_LOW_WATERMARK && - net_ratelimit()) - IL_ERR("Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", - priority == GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL", - rxq->free_count); - /* We don't reschedule replenish work here -- we will - * call the restock method and if it still needs - * more buffers it will schedule replenish */ - break; - } - - spin_lock_irqsave(&rxq->lock, flags); - if (list_empty(&rxq->rx_used)) { - spin_unlock_irqrestore(&rxq->lock, flags); - __free_pages(page, il->hw_params.rx_page_order); - return; - } - element = rxq->rx_used.next; - rxb = list_entry(element, struct il_rx_buf, list); - list_del(element); - spin_unlock_irqrestore(&rxq->lock, flags); - - rxb->page = page; - /* Get physical address of RB/SKB */ - rxb->page_dma = pci_map_page(il->pci_dev, page, 0, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); - - spin_lock_irqsave(&rxq->lock, flags); - - list_add_tail(&rxb->list, &rxq->rx_free); - rxq->free_count++; - il->alloc_rxb_page++; - - spin_unlock_irqrestore(&rxq->lock, flags); - } -} - -void il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) -{ - unsigned long flags; - int i; - spin_lock_irqsave(&rxq->lock, flags); - INIT_LIST_HEAD(&rxq->rx_free); - INIT_LIST_HEAD(&rxq->rx_used); - /* Fill the rx_used queue with _all_ of the Rx buffers */ - for (i = 0; i < RX_FREE_BUFFERS + RX_QUEUE_SIZE; i++) { - /* In the reset function, these buffers may have been allocated - * to an SKB, so we need to unmap and free potential storage */ - if (rxq->pool[i].page != NULL) { - pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); - __il_free_pages(il, rxq->pool[i].page); - rxq->pool[i].page = NULL; - } - list_add_tail(&rxq->pool[i].list, &rxq->rx_used); - } - - /* Set us so that we have processed and used all buffers, but have - * not restocked the Rx queue with fresh buffers */ - rxq->read = rxq->write = 0; - rxq->write_actual = 0; - rxq->free_count = 0; - spin_unlock_irqrestore(&rxq->lock, flags); -} - -void il3945_rx_replenish(void *data) -{ - struct il_priv *il = data; - unsigned long flags; - - il3945_rx_allocate(il, GFP_KERNEL); - - spin_lock_irqsave(&il->lock, flags); - il3945_rx_queue_restock(il); - spin_unlock_irqrestore(&il->lock, flags); -} - -static void il3945_rx_replenish_now(struct il_priv *il) -{ - il3945_rx_allocate(il, GFP_ATOMIC); - - il3945_rx_queue_restock(il); -} - - -/* Assumes that the skb field of the buffers in 'pool' is kept accurate. - * If an SKB has been detached, the POOL needs to have its SKB set to NULL - * This free routine walks the list of POOL entries and if SKB is set to - * non NULL it is unmapped and freed - */ -static void il3945_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq) -{ - int i; - for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { - if (rxq->pool[i].page != NULL) { - pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); - __il_free_pages(il, rxq->pool[i].page); - rxq->pool[i].page = NULL; - } - } - - dma_free_coherent(&il->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, - rxq->bd_dma); - dma_free_coherent(&il->pci_dev->dev, sizeof(struct il_rb_status), - rxq->rb_stts, rxq->rb_stts_dma); - rxq->bd = NULL; - rxq->rb_stts = NULL; -} - - -/* Convert linear signal-to-noise ratio into dB */ -static u8 ratio2dB[100] = { -/* 0 1 2 3 4 5 6 7 8 9 */ - 0, 0, 6, 10, 12, 14, 16, 17, 18, 19, /* 00 - 09 */ - 20, 21, 22, 22, 23, 23, 24, 25, 26, 26, /* 10 - 19 */ - 26, 26, 26, 27, 27, 28, 28, 28, 29, 29, /* 20 - 29 */ - 29, 30, 30, 30, 31, 31, 31, 31, 32, 32, /* 30 - 39 */ - 32, 32, 32, 33, 33, 33, 33, 33, 34, 34, /* 40 - 49 */ - 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, /* 50 - 59 */ - 36, 36, 36, 36, 36, 36, 36, 37, 37, 37, /* 60 - 69 */ - 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, /* 70 - 79 */ - 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, /* 80 - 89 */ - 39, 39, 39, 39, 39, 40, 40, 40, 40, 40 /* 90 - 99 */ -}; - -/* Calculates a relative dB value from a ratio of linear - * (i.e. not dB) signal levels. - * Conversion assumes that levels are voltages (20*log), not powers (10*log). */ -int il3945_calc_db_from_ratio(int sig_ratio) -{ - /* 1000:1 or higher just report as 60 dB */ - if (sig_ratio >= 1000) - return 60; - - /* 100:1 or higher, divide by 10 and use table, - * add 20 dB to make up for divide by 10 */ - if (sig_ratio >= 100) - return 20 + (int)ratio2dB[sig_ratio/10]; - - /* We shouldn't see this */ - if (sig_ratio < 1) - return 0; - - /* Use table for ratios 1:1 - 99:1 */ - return (int)ratio2dB[sig_ratio]; -} - -/** - * il3945_rx_handle - Main entry function for receiving responses from uCode - * - * Uses the il->rx_handlers callback function array to invoke - * the appropriate handlers, including command responses, - * frame-received notifications, and other notifications. - */ -static void il3945_rx_handle(struct il_priv *il) -{ - struct il_rx_buf *rxb; - struct il_rx_pkt *pkt; - struct il_rx_queue *rxq = &il->rxq; - u32 r, i; - int reclaim; - unsigned long flags; - u8 fill_rx = 0; - u32 count = 8; - int total_empty = 0; - - /* uCode's read idx (stored in shared DRAM) indicates the last Rx - * buffer that the driver may process (last buffer filled by ucode). */ - r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF; - i = rxq->read; - - /* calculate total frames need to be restock after handling RX */ - total_empty = r - rxq->write_actual; - if (total_empty < 0) - total_empty += RX_QUEUE_SIZE; - - if (total_empty > (RX_QUEUE_SIZE / 2)) - fill_rx = 1; - /* Rx interrupt, but nothing sent from uCode */ - if (i == r) - D_RX("r = %d, i = %d\n", r, i); - - while (i != r) { - int len; - - rxb = rxq->queue[i]; - - /* If an RXB doesn't have a Rx queue slot associated with it, - * then a bug has been introduced in the queue refilling - * routines -- catch it here */ - BUG_ON(rxb == NULL); - - rxq->queue[i] = NULL; - - pci_unmap_page(il->pci_dev, rxb->page_dma, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); - pkt = rxb_addr(rxb); - - len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; - len += sizeof(u32); /* account for status word */ - - /* Reclaim a command buffer only if this packet is a response - * to a (driver-originated) command. - * If the packet (e.g. Rx frame) originated from uCode, - * there is no command buffer to reclaim. - * Ucode should set SEQ_RX_FRAME bit if ucode-originated, - * but apparently a few don't get set; catch them here. */ - reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) && - pkt->hdr.cmd != STATISTICS_NOTIFICATION && - pkt->hdr.cmd != REPLY_TX; - - /* Based on type of command response or notification, - * handle those that need handling via function in - * rx_handlers table. See il3945_setup_rx_handlers() */ - if (il->rx_handlers[pkt->hdr.cmd]) { - D_RX("r = %d, i = %d, %s, 0x%02x\n", r, i, - il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); - il->isr_stats.rx_handlers[pkt->hdr.cmd]++; - il->rx_handlers[pkt->hdr.cmd] (il, rxb); - } else { - /* No handling needed */ - D_RX( - "r %d i %d No handler needed for %s, 0x%02x\n", - r, i, il_get_cmd_string(pkt->hdr.cmd), - pkt->hdr.cmd); - } - - /* - * XXX: After here, we should always check rxb->page - * against NULL before touching it or its virtual - * memory (pkt). Because some rx_handler might have - * already taken or freed the pages. - */ - - if (reclaim) { - /* Invoke any callbacks, transfer the buffer to caller, - * and fire off the (possibly) blocking il_send_cmd() - * as we reclaim the driver command queue */ - if (rxb->page) - il_tx_cmd_complete(il, rxb); - else - IL_WARN("Claim null rxb?\n"); - } - - /* Reuse the page if possible. For notification packets and - * SKBs that fail to Rx correctly, add them back into the - * rx_free list for reuse later. */ - spin_lock_irqsave(&rxq->lock, flags); - if (rxb->page != NULL) { - rxb->page_dma = pci_map_page(il->pci_dev, rxb->page, - 0, PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); - list_add_tail(&rxb->list, &rxq->rx_free); - rxq->free_count++; - } else - list_add_tail(&rxb->list, &rxq->rx_used); - - spin_unlock_irqrestore(&rxq->lock, flags); - - i = (i + 1) & RX_QUEUE_MASK; - /* If there are a lot of unused frames, - * restock the Rx queue so ucode won't assert. */ - if (fill_rx) { - count++; - if (count >= 8) { - rxq->read = i; - il3945_rx_replenish_now(il); - count = 0; - } - } - } - - /* Backtrack one entry */ - rxq->read = i; - if (fill_rx) - il3945_rx_replenish_now(il); - else - il3945_rx_queue_restock(il); -} - -/* call this function to flush any scheduled tasklet */ -static inline void il3945_synchronize_irq(struct il_priv *il) -{ - /* wait to make sure we flush pending tasklet*/ - synchronize_irq(il->pci_dev->irq); - tasklet_kill(&il->irq_tasklet); -} - -static const char *il3945_desc_lookup(int i) -{ - switch (i) { - case 1: - return "FAIL"; - case 2: - return "BAD_PARAM"; - case 3: - return "BAD_CHECKSUM"; - case 4: - return "NMI_INTERRUPT"; - case 5: - return "SYSASSERT"; - case 6: - return "FATAL_ERROR"; - } - - return "UNKNOWN"; -} - -#define ERROR_START_OFFSET (1 * sizeof(u32)) -#define ERROR_ELEM_SIZE (7 * sizeof(u32)) - -void il3945_dump_nic_error_log(struct il_priv *il) -{ - u32 i; - u32 desc, time, count, base, data1; - u32 blink1, blink2, ilink1, ilink2; - - base = le32_to_cpu(il->card_alive.error_event_table_ptr); - - if (!il3945_hw_valid_rtc_data_addr(base)) { - IL_ERR("Not valid error log pointer 0x%08X\n", base); - return; - } - - - count = il_read_targ_mem(il, base); - - if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { - IL_ERR("Start IWL Error Log Dump:\n"); - IL_ERR("Status: 0x%08lX, count: %d\n", - il->status, count); - } - - IL_ERR("Desc Time asrtPC blink2 " - "ilink1 nmiPC Line\n"); - for (i = ERROR_START_OFFSET; - i < (count * ERROR_ELEM_SIZE) + ERROR_START_OFFSET; - i += ERROR_ELEM_SIZE) { - desc = il_read_targ_mem(il, base + i); - time = - il_read_targ_mem(il, base + i + 1 * sizeof(u32)); - blink1 = - il_read_targ_mem(il, base + i + 2 * sizeof(u32)); - blink2 = - il_read_targ_mem(il, base + i + 3 * sizeof(u32)); - ilink1 = - il_read_targ_mem(il, base + i + 4 * sizeof(u32)); - ilink2 = - il_read_targ_mem(il, base + i + 5 * sizeof(u32)); - data1 = - il_read_targ_mem(il, base + i + 6 * sizeof(u32)); - - IL_ERR( - "%-13s (0x%X) %010u 0x%05X 0x%05X 0x%05X 0x%05X %u\n\n", - il3945_desc_lookup(desc), desc, time, blink1, blink2, - ilink1, ilink2, data1); - } -} - -static void il3945_irq_tasklet(struct il_priv *il) -{ - u32 inta, handled = 0; - u32 inta_fh; - unsigned long flags; -#ifdef CONFIG_IWLEGACY_DEBUG - u32 inta_mask; -#endif - - spin_lock_irqsave(&il->lock, flags); - - /* Ack/clear/reset pending uCode interrupts. - * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS, - * and will clear only when CSR_FH_INT_STATUS gets cleared. */ - inta = _il_rd(il, CSR_INT); - _il_wr(il, CSR_INT, inta); - - /* Ack/clear/reset pending flow-handler (DMA) interrupts. - * Any new interrupts that happen after this, either while we're - * in this tasklet, or later, will show up in next ISR/tasklet. */ - inta_fh = _il_rd(il, CSR_FH_INT_STATUS); - _il_wr(il, CSR_FH_INT_STATUS, inta_fh); - -#ifdef CONFIG_IWLEGACY_DEBUG - if (il_get_debug_level(il) & IL_DL_ISR) { - /* just for debug */ - inta_mask = _il_rd(il, CSR_INT_MASK); - D_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", - inta, inta_mask, inta_fh); - } -#endif - - spin_unlock_irqrestore(&il->lock, flags); - - /* Since CSR_INT and CSR_FH_INT_STATUS reads and clears are not - * atomic, make sure that inta covers all the interrupts that - * we've discovered, even if FH interrupt came in just after - * reading CSR_INT. */ - if (inta_fh & CSR39_FH_INT_RX_MASK) - inta |= CSR_INT_BIT_FH_RX; - if (inta_fh & CSR39_FH_INT_TX_MASK) - inta |= CSR_INT_BIT_FH_TX; - - /* Now service all interrupt bits discovered above. */ - if (inta & CSR_INT_BIT_HW_ERR) { - IL_ERR("Hardware error detected. Restarting.\n"); - - /* Tell the device to stop sending interrupts */ - il_disable_interrupts(il); - - il->isr_stats.hw++; - il_irq_handle_error(il); - - handled |= CSR_INT_BIT_HW_ERR; - - return; - } - -#ifdef CONFIG_IWLEGACY_DEBUG - if (il_get_debug_level(il) & (IL_DL_ISR)) { - /* NIC fires this, but we don't use it, redundant with WAKEUP */ - if (inta & CSR_INT_BIT_SCD) { - D_ISR("Scheduler finished to transmit " - "the frame/frames.\n"); - il->isr_stats.sch++; - } - - /* Alive notification via Rx interrupt will do the real work */ - if (inta & CSR_INT_BIT_ALIVE) { - D_ISR("Alive interrupt\n"); - il->isr_stats.alive++; - } - } -#endif - /* Safely ignore these bits for debug checks below */ - inta &= ~(CSR_INT_BIT_SCD | CSR_INT_BIT_ALIVE); - - /* Error detected by uCode */ - if (inta & CSR_INT_BIT_SW_ERR) { - IL_ERR("Microcode SW error detected. " - "Restarting 0x%X.\n", inta); - il->isr_stats.sw++; - il_irq_handle_error(il); - handled |= CSR_INT_BIT_SW_ERR; - } - - /* uCode wakes up after power-down sleep */ - if (inta & CSR_INT_BIT_WAKEUP) { - D_ISR("Wakeup interrupt\n"); - il_rx_queue_update_write_ptr(il, &il->rxq); - il_txq_update_write_ptr(il, &il->txq[0]); - il_txq_update_write_ptr(il, &il->txq[1]); - il_txq_update_write_ptr(il, &il->txq[2]); - il_txq_update_write_ptr(il, &il->txq[3]); - il_txq_update_write_ptr(il, &il->txq[4]); - il_txq_update_write_ptr(il, &il->txq[5]); - - il->isr_stats.wakeup++; - handled |= CSR_INT_BIT_WAKEUP; - } - - /* All uCode command responses, including Tx command responses, - * Rx "responses" (frame-received notification), and other - * notifications from uCode come through here*/ - if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) { - il3945_rx_handle(il); - il->isr_stats.rx++; - handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX); - } - - if (inta & CSR_INT_BIT_FH_TX) { - D_ISR("Tx interrupt\n"); - il->isr_stats.tx++; - - _il_wr(il, CSR_FH_INT_STATUS, (1 << 6)); - il_wr(il, FH39_TCSR_CREDIT - (FH39_SRVC_CHNL), 0x0); - handled |= CSR_INT_BIT_FH_TX; - } - - if (inta & ~handled) { - IL_ERR("Unhandled INTA bits 0x%08x\n", inta & ~handled); - il->isr_stats.unhandled++; - } - - if (inta & ~il->inta_mask) { - IL_WARN("Disabled INTA bits 0x%08x were pending\n", - inta & ~il->inta_mask); - IL_WARN(" with FH_INT = 0x%08x\n", inta_fh); - } - - /* Re-enable all interrupts */ - /* only Re-enable if disabled by irq */ - if (test_bit(STATUS_INT_ENABLED, &il->status)) - il_enable_interrupts(il); - -#ifdef CONFIG_IWLEGACY_DEBUG - if (il_get_debug_level(il) & (IL_DL_ISR)) { - inta = _il_rd(il, CSR_INT); - inta_mask = _il_rd(il, CSR_INT_MASK); - inta_fh = _il_rd(il, CSR_FH_INT_STATUS); - D_ISR("End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " - "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); - } -#endif -} - -static int il3945_get_channels_for_scan(struct il_priv *il, - enum ieee80211_band band, - u8 is_active, u8 n_probes, - struct il3945_scan_channel *scan_ch, - struct ieee80211_vif *vif) -{ - struct ieee80211_channel *chan; - const struct ieee80211_supported_band *sband; - const struct il_channel_info *ch_info; - u16 passive_dwell = 0; - u16 active_dwell = 0; - int added, i; - - sband = il_get_hw_mode(il, band); - if (!sband) - return 0; - - active_dwell = il_get_active_dwell_time(il, band, n_probes); - passive_dwell = il_get_passive_dwell_time(il, band, vif); - - if (passive_dwell <= active_dwell) - passive_dwell = active_dwell + 1; - - for (i = 0, added = 0; i < il->scan_request->n_channels; i++) { - chan = il->scan_request->channels[i]; - - if (chan->band != band) - continue; - - scan_ch->channel = chan->hw_value; - - ch_info = il_get_channel_info(il, band, - scan_ch->channel); - if (!il_is_channel_valid(ch_info)) { - D_SCAN( - "Channel %d is INVALID for this band.\n", - scan_ch->channel); - continue; - } - - scan_ch->active_dwell = cpu_to_le16(active_dwell); - scan_ch->passive_dwell = cpu_to_le16(passive_dwell); - /* If passive , set up for auto-switch - * and use long active_dwell time. - */ - if (!is_active || il_is_channel_passive(ch_info) || - (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)) { - scan_ch->type = 0; /* passive */ - if (IL_UCODE_API(il->ucode_ver) == 1) - scan_ch->active_dwell = cpu_to_le16(passive_dwell - 1); - } else { - scan_ch->type = 1; /* active */ - } - - /* Set direct probe bits. These may be used both for active - * scan channels (probes gets sent right away), - * or for passive channels (probes get se sent only after - * hearing clear Rx packet).*/ - if (IL_UCODE_API(il->ucode_ver) >= 2) { - if (n_probes) - scan_ch->type |= IL39_SCAN_PROBE_MASK(n_probes); - } else { - /* uCode v1 does not allow setting direct probe bits on - * passive channel. */ - if ((scan_ch->type & 1) && n_probes) - scan_ch->type |= IL39_SCAN_PROBE_MASK(n_probes); - } - - /* Set txpower levels to defaults */ - scan_ch->tpc.dsp_atten = 110; - /* scan_pwr_info->tpc.dsp_atten; */ - - /*scan_pwr_info->tpc.tx_gain; */ - if (band == IEEE80211_BAND_5GHZ) - scan_ch->tpc.tx_gain = ((1 << 5) | (3 << 3)) | 3; - else { - scan_ch->tpc.tx_gain = ((1 << 5) | (5 << 3)); - /* NOTE: if we were doing 6Mb OFDM for scans we'd use - * power level: - * scan_ch->tpc.tx_gain = ((1 << 5) | (2 << 3)) | 3; - */ - } - - D_SCAN("Scanning %d [%s %d]\n", - scan_ch->channel, - (scan_ch->type & 1) ? "ACTIVE" : "PASSIVE", - (scan_ch->type & 1) ? - active_dwell : passive_dwell); - - scan_ch++; - added++; - } - - D_SCAN("total channels to scan %d\n", added); - return added; -} - -static void il3945_init_hw_rates(struct il_priv *il, - struct ieee80211_rate *rates) -{ - int i; - - for (i = 0; i < RATE_COUNT_LEGACY; i++) { - rates[i].bitrate = il3945_rates[i].ieee * 5; - rates[i].hw_value = i; /* Rate scaling will work on idxes */ - rates[i].hw_value_short = i; - rates[i].flags = 0; - if (i > IL39_LAST_OFDM_RATE || i < IL_FIRST_OFDM_RATE) { - /* - * If CCK != 1M then set short preamble rate flag. - */ - rates[i].flags |= (il3945_rates[i].plcp == 10) ? - 0 : IEEE80211_RATE_SHORT_PREAMBLE; - } - } -} - -/****************************************************************************** - * - * uCode download functions - * - ******************************************************************************/ - -static void il3945_dealloc_ucode_pci(struct il_priv *il) -{ - il_free_fw_desc(il->pci_dev, &il->ucode_code); - il_free_fw_desc(il->pci_dev, &il->ucode_data); - il_free_fw_desc(il->pci_dev, &il->ucode_data_backup); - il_free_fw_desc(il->pci_dev, &il->ucode_init); - il_free_fw_desc(il->pci_dev, &il->ucode_init_data); - il_free_fw_desc(il->pci_dev, &il->ucode_boot); -} - -/** - * il3945_verify_inst_full - verify runtime uCode image in card vs. host, - * looking at all data. - */ -static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) -{ - u32 val; - u32 save_len = len; - int rc = 0; - u32 errcnt; - - D_INFO("ucode inst image size is %u\n", len); - - il_wr(il, HBUS_TARG_MEM_RADDR, - IL39_RTC_INST_LOWER_BOUND); - - errcnt = 0; - for (; len > 0; len -= sizeof(u32), image++) { - /* read data comes through single port, auto-incr addr */ - /* NOTE: Use the debugless read so we don't flood kernel log - * if IL_DL_IO is set */ - val = _il_rd(il, HBUS_TARG_MEM_RDAT); - if (val != le32_to_cpu(*image)) { - IL_ERR("uCode INST section is invalid at " - "offset 0x%x, is 0x%x, s/b 0x%x\n", - save_len - len, val, le32_to_cpu(*image)); - rc = -EIO; - errcnt++; - if (errcnt >= 20) - break; - } - } - - - if (!errcnt) - D_INFO( - "ucode image in INSTRUCTION memory is good\n"); - - return rc; -} - - -/** - * il3945_verify_inst_sparse - verify runtime uCode image in card vs. host, - * using sample data 100 bytes apart. If these sample points are good, - * it's a pretty good bet that everything between them is good, too. - */ -static int il3945_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) -{ - u32 val; - int rc = 0; - u32 errcnt = 0; - u32 i; - - D_INFO("ucode inst image size is %u\n", len); - - for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { - /* read data comes through single port, auto-incr addr */ - /* NOTE: Use the debugless read so we don't flood kernel log - * if IL_DL_IO is set */ - il_wr(il, HBUS_TARG_MEM_RADDR, - i + IL39_RTC_INST_LOWER_BOUND); - val = _il_rd(il, HBUS_TARG_MEM_RDAT); - if (val != le32_to_cpu(*image)) { -#if 0 /* Enable this if you want to see details */ - IL_ERR("uCode INST section is invalid at " - "offset 0x%x, is 0x%x, s/b 0x%x\n", - i, val, *image); -#endif - rc = -EIO; - errcnt++; - if (errcnt >= 3) - break; - } - } - - return rc; -} - - -/** - * il3945_verify_ucode - determine which instruction image is in SRAM, - * and verify its contents - */ -static int il3945_verify_ucode(struct il_priv *il) -{ - __le32 *image; - u32 len; - int rc = 0; - - /* Try bootstrap */ - image = (__le32 *)il->ucode_boot.v_addr; - len = il->ucode_boot.len; - rc = il3945_verify_inst_sparse(il, image, len); - if (rc == 0) { - D_INFO("Bootstrap uCode is good in inst SRAM\n"); - return 0; - } - - /* Try initialize */ - image = (__le32 *)il->ucode_init.v_addr; - len = il->ucode_init.len; - rc = il3945_verify_inst_sparse(il, image, len); - if (rc == 0) { - D_INFO("Initialize uCode is good in inst SRAM\n"); - return 0; - } - - /* Try runtime/protocol */ - image = (__le32 *)il->ucode_code.v_addr; - len = il->ucode_code.len; - rc = il3945_verify_inst_sparse(il, image, len); - if (rc == 0) { - D_INFO("Runtime uCode is good in inst SRAM\n"); - return 0; - } - - IL_ERR("NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); - - /* Since nothing seems to match, show first several data entries in - * instruction SRAM, so maybe visual inspection will give a clue. - * Selection of bootstrap image (vs. other images) is arbitrary. */ - image = (__le32 *)il->ucode_boot.v_addr; - len = il->ucode_boot.len; - rc = il3945_verify_inst_full(il, image, len); - - return rc; -} - -static void il3945_nic_start(struct il_priv *il) -{ - /* Remove all resets to allow NIC to operate */ - _il_wr(il, CSR_RESET, 0); -} - -#define IL3945_UCODE_GET(item) \ -static u32 il3945_ucode_get_##item(const struct il_ucode_header *ucode)\ -{ \ - return le32_to_cpu(ucode->v1.item); \ -} - -static u32 il3945_ucode_get_header_size(u32 api_ver) -{ - return 24; -} - -static u8 *il3945_ucode_get_data(const struct il_ucode_header *ucode) -{ - return (u8 *) ucode->v1.data; -} - -IL3945_UCODE_GET(inst_size); -IL3945_UCODE_GET(data_size); -IL3945_UCODE_GET(init_size); -IL3945_UCODE_GET(init_data_size); -IL3945_UCODE_GET(boot_size); - -/** - * il3945_read_ucode - Read uCode images from disk file. - * - * Copy into buffers for card to fetch via bus-mastering - */ -static int il3945_read_ucode(struct il_priv *il) -{ - const struct il_ucode_header *ucode; - int ret = -EINVAL, idx; - const struct firmware *ucode_raw; - /* firmware file name contains uCode/driver compatibility version */ - const char *name_pre = il->cfg->fw_name_pre; - const unsigned int api_max = il->cfg->ucode_api_max; - const unsigned int api_min = il->cfg->ucode_api_min; - char buf[25]; - u8 *src; - size_t len; - u32 api_ver, inst_size, data_size, init_size, init_data_size, boot_size; - - /* Ask kernel firmware_class module to get the boot firmware off disk. - * request_firmware() is synchronous, file is in memory on return. */ - for (idx = api_max; idx >= api_min; idx--) { - sprintf(buf, "%s%u%s", name_pre, idx, ".ucode"); - ret = request_firmware(&ucode_raw, buf, &il->pci_dev->dev); - if (ret < 0) { - IL_ERR("%s firmware file req failed: %d\n", - buf, ret); - if (ret == -ENOENT) - continue; - else - goto error; - } else { - if (idx < api_max) - IL_ERR("Loaded firmware %s, " - "which is deprecated. " - " Please use API v%u instead.\n", - buf, api_max); - D_INFO("Got firmware '%s' file " - "(%zd bytes) from disk\n", - buf, ucode_raw->size); - break; - } - } - - if (ret < 0) - goto error; - - /* Make sure that we got at least our header! */ - if (ucode_raw->size < il3945_ucode_get_header_size(1)) { - IL_ERR("File size way too small!\n"); - ret = -EINVAL; - goto err_release; - } - - /* Data from ucode file: header followed by uCode images */ - ucode = (struct il_ucode_header *)ucode_raw->data; - - il->ucode_ver = le32_to_cpu(ucode->ver); - api_ver = IL_UCODE_API(il->ucode_ver); - inst_size = il3945_ucode_get_inst_size(ucode); - data_size = il3945_ucode_get_data_size(ucode); - init_size = il3945_ucode_get_init_size(ucode); - init_data_size = il3945_ucode_get_init_data_size(ucode); - boot_size = il3945_ucode_get_boot_size(ucode); - src = il3945_ucode_get_data(ucode); - - /* api_ver should match the api version forming part of the - * firmware filename ... but we don't check for that and only rely - * on the API version read from firmware header from here on forward */ - - if (api_ver < api_min || api_ver > api_max) { - IL_ERR("Driver unable to support your firmware API. " - "Driver supports v%u, firmware is v%u.\n", - api_max, api_ver); - il->ucode_ver = 0; - ret = -EINVAL; - goto err_release; - } - if (api_ver != api_max) - IL_ERR("Firmware has old API version. Expected %u, " - "got %u. New firmware can be obtained " - "from http://www.intellinuxwireless.org.\n", - api_max, api_ver); - - IL_INFO("loaded firmware version %u.%u.%u.%u\n", - IL_UCODE_MAJOR(il->ucode_ver), - IL_UCODE_MINOR(il->ucode_ver), - IL_UCODE_API(il->ucode_ver), - IL_UCODE_SERIAL(il->ucode_ver)); - - snprintf(il->hw->wiphy->fw_version, - sizeof(il->hw->wiphy->fw_version), - "%u.%u.%u.%u", - IL_UCODE_MAJOR(il->ucode_ver), - IL_UCODE_MINOR(il->ucode_ver), - IL_UCODE_API(il->ucode_ver), - IL_UCODE_SERIAL(il->ucode_ver)); - - D_INFO("f/w package hdr ucode version raw = 0x%x\n", - il->ucode_ver); - D_INFO("f/w package hdr runtime inst size = %u\n", - inst_size); - D_INFO("f/w package hdr runtime data size = %u\n", - data_size); - D_INFO("f/w package hdr init inst size = %u\n", - init_size); - D_INFO("f/w package hdr init data size = %u\n", - init_data_size); - D_INFO("f/w package hdr boot inst size = %u\n", - boot_size); - - - /* Verify size of file vs. image size info in file's header */ - if (ucode_raw->size != il3945_ucode_get_header_size(api_ver) + - inst_size + data_size + init_size + - init_data_size + boot_size) { - - D_INFO( - "uCode file size %zd does not match expected size\n", - ucode_raw->size); - ret = -EINVAL; - goto err_release; - } - - /* Verify that uCode images will fit in card's SRAM */ - if (inst_size > IL39_MAX_INST_SIZE) { - D_INFO("uCode instr len %d too large to fit in\n", - inst_size); - ret = -EINVAL; - goto err_release; - } - - if (data_size > IL39_MAX_DATA_SIZE) { - D_INFO("uCode data len %d too large to fit in\n", - data_size); - ret = -EINVAL; - goto err_release; - } - if (init_size > IL39_MAX_INST_SIZE) { - D_INFO( - "uCode init instr len %d too large to fit in\n", - init_size); - ret = -EINVAL; - goto err_release; - } - if (init_data_size > IL39_MAX_DATA_SIZE) { - D_INFO( - "uCode init data len %d too large to fit in\n", - init_data_size); - ret = -EINVAL; - goto err_release; - } - if (boot_size > IL39_MAX_BSM_SIZE) { - D_INFO( - "uCode boot instr len %d too large to fit in\n", - boot_size); - ret = -EINVAL; - goto err_release; - } - - /* Allocate ucode buffers for card's bus-master loading ... */ - - /* Runtime instructions and 2 copies of data: - * 1) unmodified from disk - * 2) backup cache for save/restore during power-downs */ - il->ucode_code.len = inst_size; - il_alloc_fw_desc(il->pci_dev, &il->ucode_code); - - il->ucode_data.len = data_size; - il_alloc_fw_desc(il->pci_dev, &il->ucode_data); - - il->ucode_data_backup.len = data_size; - il_alloc_fw_desc(il->pci_dev, &il->ucode_data_backup); - - if (!il->ucode_code.v_addr || !il->ucode_data.v_addr || - !il->ucode_data_backup.v_addr) - goto err_pci_alloc; - - /* Initialization instructions and data */ - if (init_size && init_data_size) { - il->ucode_init.len = init_size; - il_alloc_fw_desc(il->pci_dev, &il->ucode_init); - - il->ucode_init_data.len = init_data_size; - il_alloc_fw_desc(il->pci_dev, &il->ucode_init_data); - - if (!il->ucode_init.v_addr || !il->ucode_init_data.v_addr) - goto err_pci_alloc; - } - - /* Bootstrap (instructions only, no data) */ - if (boot_size) { - il->ucode_boot.len = boot_size; - il_alloc_fw_desc(il->pci_dev, &il->ucode_boot); - - if (!il->ucode_boot.v_addr) - goto err_pci_alloc; - } - - /* Copy images into buffers for card's bus-master reads ... */ - - /* Runtime instructions (first block of data in file) */ - len = inst_size; - D_INFO( - "Copying (but not loading) uCode instr len %zd\n", len); - memcpy(il->ucode_code.v_addr, src, len); - src += len; - - D_INFO("uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", - il->ucode_code.v_addr, (u32)il->ucode_code.p_addr); - - /* Runtime data (2nd block) - * NOTE: Copy into backup buffer will be done in il3945_up() */ - len = data_size; - D_INFO( - "Copying (but not loading) uCode data len %zd\n", len); - memcpy(il->ucode_data.v_addr, src, len); - memcpy(il->ucode_data_backup.v_addr, src, len); - src += len; - - /* Initialization instructions (3rd block) */ - if (init_size) { - len = init_size; - D_INFO( - "Copying (but not loading) init instr len %zd\n", len); - memcpy(il->ucode_init.v_addr, src, len); - src += len; - } - - /* Initialization data (4th block) */ - if (init_data_size) { - len = init_data_size; - D_INFO( - "Copying (but not loading) init data len %zd\n", len); - memcpy(il->ucode_init_data.v_addr, src, len); - src += len; - } - - /* Bootstrap instructions (5th block) */ - len = boot_size; - D_INFO( - "Copying (but not loading) boot instr len %zd\n", len); - memcpy(il->ucode_boot.v_addr, src, len); - - /* We have our copies now, allow OS release its copies */ - release_firmware(ucode_raw); - return 0; - - err_pci_alloc: - IL_ERR("failed to allocate pci memory\n"); - ret = -ENOMEM; - il3945_dealloc_ucode_pci(il); - - err_release: - release_firmware(ucode_raw); - - error: - return ret; -} - - -/** - * il3945_set_ucode_ptrs - Set uCode address location - * - * Tell initialization uCode where to find runtime uCode. - * - * BSM registers initially contain pointers to initialization uCode. - * We need to replace them to load runtime uCode inst and data, - * and to save runtime data when powering down. - */ -static int il3945_set_ucode_ptrs(struct il_priv *il) -{ - dma_addr_t pinst; - dma_addr_t pdata; - - /* bits 31:0 for 3945 */ - pinst = il->ucode_code.p_addr; - pdata = il->ucode_data_backup.p_addr; - - /* Tell bootstrap uCode where to find image to load */ - il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); - il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); - il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, - il->ucode_data.len); - - /* Inst byte count must be last to set up, bit 31 signals uCode - * that all new ptr/size info is in place */ - il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, - il->ucode_code.len | BSM_DRAM_INST_LOAD); - - D_INFO("Runtime uCode pointers are set.\n"); - - return 0; -} - -/** - * il3945_init_alive_start - Called after REPLY_ALIVE notification received - * - * Called after REPLY_ALIVE notification received from "initialize" uCode. - * - * Tell "initialize" uCode to go ahead and load the runtime uCode. - */ -static void il3945_init_alive_start(struct il_priv *il) -{ - /* Check alive response for "valid" sign from uCode */ - if (il->card_alive_init.is_valid != UCODE_VALID_OK) { - /* We had an error bringing up the hardware, so take it - * all the way back down so we can try again */ - D_INFO("Initialize Alive failed.\n"); - goto restart; - } - - /* Bootstrap uCode has loaded initialize uCode ... verify inst image. - * This is a paranoid check, because we would not have gotten the - * "initialize" alive if code weren't properly loaded. */ - if (il3945_verify_ucode(il)) { - /* Runtime instruction load was bad; - * take it all the way back down so we can try again */ - D_INFO("Bad \"initialize\" uCode load.\n"); - goto restart; - } - - /* Send pointers to protocol/runtime uCode image ... init code will - * load and launch runtime uCode, which will send us another "Alive" - * notification. */ - D_INFO("Initialization Alive received.\n"); - if (il3945_set_ucode_ptrs(il)) { - /* Runtime instruction load won't happen; - * take it all the way back down so we can try again */ - D_INFO("Couldn't set up uCode pointers.\n"); - goto restart; - } - return; - - restart: - queue_work(il->workqueue, &il->restart); -} - -/** - * il3945_alive_start - called after REPLY_ALIVE notification received - * from protocol/runtime uCode (initialization uCode's - * Alive gets handled by il3945_init_alive_start()). - */ -static void il3945_alive_start(struct il_priv *il) -{ - int thermal_spin = 0; - u32 rfkill; - struct il_rxon_context *ctx = &il->ctx; - - D_INFO("Runtime Alive received.\n"); - - if (il->card_alive.is_valid != UCODE_VALID_OK) { - /* We had an error bringing up the hardware, so take it - * all the way back down so we can try again */ - D_INFO("Alive failed.\n"); - goto restart; - } - - /* Initialize uCode has loaded Runtime uCode ... verify inst image. - * This is a paranoid check, because we would not have gotten the - * "runtime" alive if code weren't properly loaded. */ - if (il3945_verify_ucode(il)) { - /* Runtime instruction load was bad; - * take it all the way back down so we can try again */ - D_INFO("Bad runtime uCode load.\n"); - goto restart; - } - - rfkill = il_rd_prph(il, APMG_RFKILL_REG); - D_INFO("RFKILL status: 0x%x\n", rfkill); - - if (rfkill & 0x1) { - clear_bit(STATUS_RF_KILL_HW, &il->status); - /* if RFKILL is not on, then wait for thermal - * sensor in adapter to kick in */ - while (il3945_hw_get_temperature(il) == 0) { - thermal_spin++; - udelay(10); - } - - if (thermal_spin) - D_INFO("Thermal calibration took %dus\n", - thermal_spin * 10); - } else - set_bit(STATUS_RF_KILL_HW, &il->status); - - /* After the ALIVE response, we can send commands to 3945 uCode */ - set_bit(STATUS_ALIVE, &il->status); - - /* Enable watchdog to monitor the driver tx queues */ - il_setup_watchdog(il); - - if (il_is_rfkill(il)) - return; - - ieee80211_wake_queues(il->hw); - - il->active_rate = RATES_MASK_3945; - - il_power_update_mode(il, true); - - if (il_is_associated(il)) { - struct il3945_rxon_cmd *active_rxon = - (struct il3945_rxon_cmd *)(&ctx->active); - - ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; - } else { - /* Initialize our rx_config data */ - il_connection_init_rx_config(il, ctx); - } - - /* Configure Bluetooth device coexistence support */ - il_send_bt_config(il); - - set_bit(STATUS_READY, &il->status); - - /* Configure the adapter for unassociated operation */ - il3945_commit_rxon(il, ctx); - - il3945_reg_txpower_periodic(il); - - D_INFO("ALIVE processing complete.\n"); - wake_up(&il->wait_command_queue); - - return; - - restart: - queue_work(il->workqueue, &il->restart); -} - -static void il3945_cancel_deferred_work(struct il_priv *il); - -static void __il3945_down(struct il_priv *il) -{ - unsigned long flags; - int exit_pending; - - D_INFO(DRV_NAME " is going down\n"); - - il_scan_cancel_timeout(il, 200); - - exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &il->status); - - /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set - * to prevent rearm timer */ - del_timer_sync(&il->watchdog); - - /* Station information will now be cleared in device */ - il_clear_ucode_stations(il, NULL); - il_dealloc_bcast_stations(il); - il_clear_driver_stations(il); - - /* Unblock any waiting calls */ - wake_up_all(&il->wait_command_queue); - - /* Wipe out the EXIT_PENDING status bit if we are not actually - * exiting the module */ - if (!exit_pending) - clear_bit(STATUS_EXIT_PENDING, &il->status); - - /* stop and reset the on-board processor */ - _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); - - /* tell the device to stop sending interrupts */ - spin_lock_irqsave(&il->lock, flags); - il_disable_interrupts(il); - spin_unlock_irqrestore(&il->lock, flags); - il3945_synchronize_irq(il); - - if (il->mac80211_registered) - ieee80211_stop_queues(il->hw); - - /* If we have not previously called il3945_init() then - * clear all bits but the RF Kill bits and return */ - if (!il_is_init(il)) { - il->status = test_bit(STATUS_RF_KILL_HW, &il->status) << - STATUS_RF_KILL_HW | - test_bit(STATUS_GEO_CONFIGURED, &il->status) << - STATUS_GEO_CONFIGURED | - test_bit(STATUS_EXIT_PENDING, &il->status) << - STATUS_EXIT_PENDING; - goto exit; - } - - /* ...otherwise clear out all the status bits but the RF Kill - * bit and continue taking the NIC down. */ - il->status &= test_bit(STATUS_RF_KILL_HW, &il->status) << - STATUS_RF_KILL_HW | - test_bit(STATUS_GEO_CONFIGURED, &il->status) << - STATUS_GEO_CONFIGURED | - test_bit(STATUS_FW_ERROR, &il->status) << - STATUS_FW_ERROR | - test_bit(STATUS_EXIT_PENDING, &il->status) << - STATUS_EXIT_PENDING; - - il3945_hw_txq_ctx_stop(il); - il3945_hw_rxq_stop(il); - - /* Power-down device's busmaster DMA clocks */ - il_wr_prph(il, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); - udelay(5); - - /* Stop the device, and put it in low power state */ - il_apm_stop(il); - - exit: - memset(&il->card_alive, 0, sizeof(struct il_alive_resp)); - - if (il->beacon_skb) - dev_kfree_skb(il->beacon_skb); - il->beacon_skb = NULL; - - /* clear out any free frames */ - il3945_clear_free_frames(il); -} - -static void il3945_down(struct il_priv *il) -{ - mutex_lock(&il->mutex); - __il3945_down(il); - mutex_unlock(&il->mutex); - - il3945_cancel_deferred_work(il); -} - -#define MAX_HW_RESTARTS 5 - -static int il3945_alloc_bcast_station(struct il_priv *il) -{ - struct il_rxon_context *ctx = &il->ctx; - unsigned long flags; - u8 sta_id; - - spin_lock_irqsave(&il->sta_lock, flags); - sta_id = il_prep_station(il, ctx, - il_bcast_addr, false, NULL); - if (sta_id == IL_INVALID_STATION) { - IL_ERR("Unable to prepare broadcast station\n"); - spin_unlock_irqrestore(&il->sta_lock, flags); - - return -EINVAL; - } - - il->stations[sta_id].used |= IL_STA_DRIVER_ACTIVE; - il->stations[sta_id].used |= IL_STA_BCAST; - spin_unlock_irqrestore(&il->sta_lock, flags); - - return 0; -} - -static int __il3945_up(struct il_priv *il) -{ - int rc, i; - - rc = il3945_alloc_bcast_station(il); - if (rc) - return rc; - - if (test_bit(STATUS_EXIT_PENDING, &il->status)) { - IL_WARN("Exit pending; will not bring the NIC up\n"); - return -EIO; - } - - if (!il->ucode_data_backup.v_addr || !il->ucode_data.v_addr) { - IL_ERR("ucode not available for device bring up\n"); - return -EIO; - } - - /* If platform's RF_KILL switch is NOT set to KILL */ - if (_il_rd(il, CSR_GP_CNTRL) & - CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) - clear_bit(STATUS_RF_KILL_HW, &il->status); - else { - set_bit(STATUS_RF_KILL_HW, &il->status); - IL_WARN("Radio disabled by HW RF Kill switch\n"); - return -ENODEV; - } - - _il_wr(il, CSR_INT, 0xFFFFFFFF); - - rc = il3945_hw_nic_init(il); - if (rc) { - IL_ERR("Unable to int nic\n"); - return rc; - } - - /* make sure rfkill handshake bits are cleared */ - _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - _il_wr(il, CSR_UCODE_DRV_GP1_CLR, - CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - - /* clear (again), then enable host interrupts */ - _il_wr(il, CSR_INT, 0xFFFFFFFF); - il_enable_interrupts(il); - - /* really make sure rfkill handshake bits are cleared */ - _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - - /* Copy original ucode data image from disk into backup cache. - * This will be used to initialize the on-board processor's - * data SRAM for a clean start when the runtime program first loads. */ - memcpy(il->ucode_data_backup.v_addr, il->ucode_data.v_addr, - il->ucode_data.len); - - /* We return success when we resume from suspend and rf_kill is on. */ - if (test_bit(STATUS_RF_KILL_HW, &il->status)) - return 0; - - for (i = 0; i < MAX_HW_RESTARTS; i++) { - - /* load bootstrap state machine, - * load bootstrap program into processor's memory, - * prepare to load the "initialize" uCode */ - rc = il->cfg->ops->lib->load_ucode(il); - - if (rc) { - IL_ERR( - "Unable to set up bootstrap uCode: %d\n", rc); - continue; - } - - /* start card; "initialize" will load runtime ucode */ - il3945_nic_start(il); - - D_INFO(DRV_NAME " is coming up\n"); - - return 0; - } - - set_bit(STATUS_EXIT_PENDING, &il->status); - __il3945_down(il); - clear_bit(STATUS_EXIT_PENDING, &il->status); - - /* tried to restart and config the device for as long as our - * patience could withstand */ - IL_ERR("Unable to initialize device after %d attempts.\n", i); - return -EIO; -} - - -/***************************************************************************** - * - * Workqueue callbacks - * - *****************************************************************************/ - -static void il3945_bg_init_alive_start(struct work_struct *data) -{ - struct il_priv *il = - container_of(data, struct il_priv, init_alive_start.work); - - mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - goto out; - - il3945_init_alive_start(il); -out: - mutex_unlock(&il->mutex); -} - -static void il3945_bg_alive_start(struct work_struct *data) -{ - struct il_priv *il = - container_of(data, struct il_priv, alive_start.work); - - mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - goto out; - - il3945_alive_start(il); -out: - mutex_unlock(&il->mutex); -} - -/* - * 3945 cannot interrupt driver when hardware rf kill switch toggles; - * driver must poll CSR_GP_CNTRL_REG register for change. This register - * *is* readable even when device has been SW_RESET into low power mode - * (e.g. during RF KILL). - */ -static void il3945_rfkill_poll(struct work_struct *data) -{ - struct il_priv *il = - container_of(data, struct il_priv, _3945.rfkill_poll.work); - bool old_rfkill = test_bit(STATUS_RF_KILL_HW, &il->status); - bool new_rfkill = !(_il_rd(il, CSR_GP_CNTRL) - & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW); - - if (new_rfkill != old_rfkill) { - if (new_rfkill) - set_bit(STATUS_RF_KILL_HW, &il->status); - else - clear_bit(STATUS_RF_KILL_HW, &il->status); - - wiphy_rfkill_set_hw_state(il->hw->wiphy, new_rfkill); - - D_RF_KILL("RF_KILL bit toggled to %s.\n", - new_rfkill ? "disable radio" : "enable radio"); - } - - /* Keep this running, even if radio now enabled. This will be - * cancelled in mac_start() if system decides to start again */ - queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, - round_jiffies_relative(2 * HZ)); - -} - -int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) -{ - struct il_host_cmd cmd = { - .id = REPLY_SCAN_CMD, - .len = sizeof(struct il3945_scan_cmd), - .flags = CMD_SIZE_HUGE, - }; - struct il3945_scan_cmd *scan; - u8 n_probes = 0; - enum ieee80211_band band; - bool is_active = false; - int ret; - u16 len; - - lockdep_assert_held(&il->mutex); - - if (!il->scan_cmd) { - il->scan_cmd = kmalloc(sizeof(struct il3945_scan_cmd) + - IL_MAX_SCAN_SIZE, GFP_KERNEL); - if (!il->scan_cmd) { - D_SCAN("Fail to allocate scan memory\n"); - return -ENOMEM; - } - } - scan = il->scan_cmd; - memset(scan, 0, sizeof(struct il3945_scan_cmd) + IL_MAX_SCAN_SIZE); - - scan->quiet_plcp_th = IL_PLCP_QUIET_THRESH; - scan->quiet_time = IL_ACTIVE_QUIET_TIME; - - if (il_is_associated(il)) { - u16 interval; - u32 extra; - u32 suspend_time = 100; - u32 scan_suspend_time = 100; - - D_INFO("Scanning while associated...\n"); - - interval = vif->bss_conf.beacon_int; - - scan->suspend_time = 0; - scan->max_out_time = cpu_to_le32(200 * 1024); - if (!interval) - interval = suspend_time; - /* - * suspend time format: - * 0-19: beacon interval in usec (time before exec.) - * 20-23: 0 - * 24-31: number of beacons (suspend between channels) - */ - - extra = (suspend_time / interval) << 24; - scan_suspend_time = 0xFF0FFFFF & - (extra | ((suspend_time % interval) * 1024)); - - scan->suspend_time = cpu_to_le32(scan_suspend_time); - D_SCAN("suspend_time 0x%X beacon interval %d\n", - scan_suspend_time, interval); - } - - if (il->scan_request->n_ssids) { - int i, p = 0; - D_SCAN("Kicking off active scan\n"); - for (i = 0; i < il->scan_request->n_ssids; i++) { - /* always does wildcard anyway */ - if (!il->scan_request->ssids[i].ssid_len) - continue; - scan->direct_scan[p].id = WLAN_EID_SSID; - scan->direct_scan[p].len = - il->scan_request->ssids[i].ssid_len; - memcpy(scan->direct_scan[p].ssid, - il->scan_request->ssids[i].ssid, - il->scan_request->ssids[i].ssid_len); - n_probes++; - p++; - } - is_active = true; - } else - D_SCAN("Kicking off passive scan.\n"); - - /* We don't build a direct scan probe request; the uCode will do - * that based on the direct_mask added to each channel entry */ - scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; - scan->tx_cmd.sta_id = il->ctx.bcast_sta_id; - scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; - - /* flags + rate selection */ - - switch (il->scan_band) { - case IEEE80211_BAND_2GHZ: - scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; - scan->tx_cmd.rate = RATE_1M_PLCP; - band = IEEE80211_BAND_2GHZ; - break; - case IEEE80211_BAND_5GHZ: - scan->tx_cmd.rate = RATE_6M_PLCP; - band = IEEE80211_BAND_5GHZ; - break; - default: - IL_WARN("Invalid scan band\n"); - return -EIO; - } - - /* - * If active scaning is requested but a certain channel - * is marked passive, we can do active scanning if we - * detect transmissions. - */ - scan->good_CRC_th = is_active ? IL_GOOD_CRC_TH_DEFAULT : - IL_GOOD_CRC_TH_DISABLED; - - len = il_fill_probe_req(il, (struct ieee80211_mgmt *)scan->data, - vif->addr, il->scan_request->ie, - il->scan_request->ie_len, - IL_MAX_SCAN_SIZE - sizeof(*scan)); - scan->tx_cmd.len = cpu_to_le16(len); - - /* select Rx antennas */ - scan->flags |= il3945_get_antenna_flags(il); - - scan->channel_count = il3945_get_channels_for_scan(il, band, is_active, n_probes, - (void *)&scan->data[len], vif); - if (scan->channel_count == 0) { - D_SCAN("channel count %d\n", scan->channel_count); - return -EIO; - } - - cmd.len += le16_to_cpu(scan->tx_cmd.len) + - scan->channel_count * sizeof(struct il3945_scan_channel); - cmd.data = scan; - scan->len = cpu_to_le16(cmd.len); - - set_bit(STATUS_SCAN_HW, &il->status); - ret = il_send_cmd_sync(il, &cmd); - if (ret) - clear_bit(STATUS_SCAN_HW, &il->status); - return ret; -} - -void il3945_post_scan(struct il_priv *il) -{ - struct il_rxon_context *ctx = &il->ctx; - - /* - * Since setting the RXON may have been deferred while - * performing the scan, fire one off if needed - */ - if (memcmp(&ctx->staging, &ctx->active, sizeof(ctx->staging))) - il3945_commit_rxon(il, ctx); -} - -static void il3945_bg_restart(struct work_struct *data) -{ - struct il_priv *il = container_of(data, struct il_priv, restart); - - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - return; - - if (test_and_clear_bit(STATUS_FW_ERROR, &il->status)) { - mutex_lock(&il->mutex); - il->ctx.vif = NULL; - il->is_open = 0; - mutex_unlock(&il->mutex); - il3945_down(il); - ieee80211_restart_hw(il->hw); - } else { - il3945_down(il); - - mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) { - mutex_unlock(&il->mutex); - return; - } - - __il3945_up(il); - mutex_unlock(&il->mutex); - } -} - -static void il3945_bg_rx_replenish(struct work_struct *data) -{ - struct il_priv *il = - container_of(data, struct il_priv, rx_replenish); - - mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - goto out; - - il3945_rx_replenish(il); -out: - mutex_unlock(&il->mutex); -} - -void il3945_post_associate(struct il_priv *il) -{ - int rc = 0; - struct ieee80211_conf *conf = NULL; - struct il_rxon_context *ctx = &il->ctx; - - if (!ctx->vif || !il->is_open) - return; - - D_ASSOC("Associated as %d to: %pM\n", - ctx->vif->bss_conf.aid, ctx->active.bssid_addr); - - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - return; - - il_scan_cancel_timeout(il, 200); - - conf = il_ieee80211_get_hw_conf(il->hw); - - ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - il3945_commit_rxon(il, ctx); - - rc = il_send_rxon_timing(il, ctx); - if (rc) - IL_WARN("REPLY_RXON_TIMING failed - " - "Attempting to continue.\n"); - - ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - - ctx->staging.assoc_id = cpu_to_le16(ctx->vif->bss_conf.aid); - - D_ASSOC("assoc id %d beacon interval %d\n", - ctx->vif->bss_conf.aid, ctx->vif->bss_conf.beacon_int); - - if (ctx->vif->bss_conf.use_short_preamble) - ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; - else - ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; - - if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) { - if (ctx->vif->bss_conf.use_short_slot) - ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; - else - ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; - } - - il3945_commit_rxon(il, ctx); - - switch (ctx->vif->type) { - case NL80211_IFTYPE_STATION: - il3945_rate_scale_init(il->hw, IL_AP_ID); - break; - case NL80211_IFTYPE_ADHOC: - il3945_send_beacon_cmd(il); - break; - default: - IL_ERR("%s Should not be called in %d mode\n", - __func__, ctx->vif->type); - break; - } -} - -/***************************************************************************** - * - * mac80211 entry point functions - * - *****************************************************************************/ - -#define UCODE_READY_TIMEOUT (2 * HZ) - -static int il3945_mac_start(struct ieee80211_hw *hw) -{ - struct il_priv *il = hw->priv; - int ret; - - D_MAC80211("enter\n"); - - /* we should be verifying the device is ready to be opened */ - mutex_lock(&il->mutex); - - /* fetch ucode file from disk, alloc and copy to bus-master buffers ... - * ucode filename and max sizes are card-specific. */ - - if (!il->ucode_code.len) { - ret = il3945_read_ucode(il); - if (ret) { - IL_ERR("Could not read microcode: %d\n", ret); - mutex_unlock(&il->mutex); - goto out_release_irq; - } - } - - ret = __il3945_up(il); - - mutex_unlock(&il->mutex); - - if (ret) - goto out_release_irq; - - D_INFO("Start UP work.\n"); - - /* Wait for START_ALIVE from ucode. Otherwise callbacks from - * mac80211 will not be run successfully. */ - ret = wait_event_timeout(il->wait_command_queue, - test_bit(STATUS_READY, &il->status), - UCODE_READY_TIMEOUT); - if (!ret) { - if (!test_bit(STATUS_READY, &il->status)) { - IL_ERR( - "Wait for START_ALIVE timeout after %dms.\n", - jiffies_to_msecs(UCODE_READY_TIMEOUT)); - ret = -ETIMEDOUT; - goto out_release_irq; - } - } - - /* ucode is running and will send rfkill notifications, - * no need to poll the killswitch state anymore */ - cancel_delayed_work(&il->_3945.rfkill_poll); - - il->is_open = 1; - D_MAC80211("leave\n"); - return 0; - -out_release_irq: - il->is_open = 0; - D_MAC80211("leave - failed\n"); - return ret; -} - -static void il3945_mac_stop(struct ieee80211_hw *hw) -{ - struct il_priv *il = hw->priv; - - D_MAC80211("enter\n"); - - if (!il->is_open) { - D_MAC80211("leave - skip\n"); - return; - } - - il->is_open = 0; - - il3945_down(il); - - flush_workqueue(il->workqueue); - - /* start polling the killswitch state again */ - queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, - round_jiffies_relative(2 * HZ)); - - D_MAC80211("leave\n"); -} - -static void il3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) -{ - struct il_priv *il = hw->priv; - - D_MAC80211("enter\n"); - - D_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, - ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); - - if (il3945_tx_skb(il, skb)) - dev_kfree_skb_any(skb); - - D_MAC80211("leave\n"); -} - -void il3945_config_ap(struct il_priv *il) -{ - struct il_rxon_context *ctx = &il->ctx; - struct ieee80211_vif *vif = ctx->vif; - int rc = 0; - - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - return; - - /* The following should be done only at AP bring up */ - if (!(il_is_associated(il))) { - - /* RXON - unassoc (to set timing command) */ - ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - il3945_commit_rxon(il, ctx); - - /* RXON Timing */ - rc = il_send_rxon_timing(il, ctx); - if (rc) - IL_WARN("REPLY_RXON_TIMING failed - " - "Attempting to continue.\n"); - - ctx->staging.assoc_id = 0; - - if (vif->bss_conf.use_short_preamble) - ctx->staging.flags |= - RXON_FLG_SHORT_PREAMBLE_MSK; - else - ctx->staging.flags &= - ~RXON_FLG_SHORT_PREAMBLE_MSK; - - if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) { - if (vif->bss_conf.use_short_slot) - ctx->staging.flags |= - RXON_FLG_SHORT_SLOT_MSK; - else - ctx->staging.flags &= - ~RXON_FLG_SHORT_SLOT_MSK; - } - /* restore RXON assoc */ - ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - il3945_commit_rxon(il, ctx); - } - il3945_send_beacon_cmd(il); -} - -static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta, - struct ieee80211_key_conf *key) -{ - struct il_priv *il = hw->priv; - int ret = 0; - u8 sta_id = IL_INVALID_STATION; - u8 static_key; - - D_MAC80211("enter\n"); - - if (il3945_mod_params.sw_crypto) { - D_MAC80211("leave - hwcrypto disabled\n"); - return -EOPNOTSUPP; - } - - /* - * To support IBSS RSN, don't program group keys in IBSS, the - * hardware will then not attempt to decrypt the frames. - */ - if (vif->type == NL80211_IFTYPE_ADHOC && - !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) - return -EOPNOTSUPP; - - static_key = !il_is_associated(il); - - if (!static_key) { - sta_id = il_sta_id_or_broadcast( - il, &il->ctx, sta); - if (sta_id == IL_INVALID_STATION) - return -EINVAL; - } - - mutex_lock(&il->mutex); - il_scan_cancel_timeout(il, 100); - - switch (cmd) { - case SET_KEY: - if (static_key) - ret = il3945_set_static_key(il, key); - else - ret = il3945_set_dynamic_key(il, key, sta_id); - D_MAC80211("enable hwcrypto key\n"); - break; - case DISABLE_KEY: - if (static_key) - ret = il3945_remove_static_key(il); - else - ret = il3945_clear_sta_key_info(il, sta_id); - D_MAC80211("disable hwcrypto key\n"); - break; - default: - ret = -EINVAL; - } - - mutex_unlock(&il->mutex); - D_MAC80211("leave\n"); - - return ret; -} - -static int il3945_mac_sta_add(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta) -{ - struct il_priv *il = hw->priv; - struct il3945_sta_priv *sta_priv = (void *)sta->drv_priv; - int ret; - bool is_ap = vif->type == NL80211_IFTYPE_STATION; - u8 sta_id; - - D_INFO("received request to add station %pM\n", - sta->addr); - mutex_lock(&il->mutex); - D_INFO("proceeding to add station %pM\n", - sta->addr); - sta_priv->common.sta_id = IL_INVALID_STATION; - - - ret = il_add_station_common(il, - &il->ctx, - sta->addr, is_ap, sta, &sta_id); - if (ret) { - IL_ERR("Unable to add station %pM (%d)\n", - sta->addr, ret); - /* Should we return success if return code is EEXIST ? */ - mutex_unlock(&il->mutex); - return ret; - } - - sta_priv->common.sta_id = sta_id; - - /* Initialize rate scaling */ - D_INFO("Initializing rate scaling for station %pM\n", - sta->addr); - il3945_rs_rate_init(il, sta, sta_id); - mutex_unlock(&il->mutex); - - return 0; -} - -static void il3945_configure_filter(struct ieee80211_hw *hw, - unsigned int changed_flags, - unsigned int *total_flags, - u64 multicast) -{ - struct il_priv *il = hw->priv; - __le32 filter_or = 0, filter_nand = 0; - struct il_rxon_context *ctx = &il->ctx; - -#define CHK(test, flag) do { \ - if (*total_flags & (test)) \ - filter_or |= (flag); \ - else \ - filter_nand |= (flag); \ - } while (0) - - D_MAC80211("Enter: changed: 0x%x, total: 0x%x\n", - changed_flags, *total_flags); - - CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); - CHK(FIF_CONTROL, RXON_FILTER_CTL2HOST_MSK); - CHK(FIF_BCN_PRBRESP_PROMISC, RXON_FILTER_BCON_AWARE_MSK); - -#undef CHK - - mutex_lock(&il->mutex); - - ctx->staging.filter_flags &= ~filter_nand; - ctx->staging.filter_flags |= filter_or; - - /* - * Not committing directly because hardware can perform a scan, - * but even if hw is ready, committing here breaks for some reason, - * we'll eventually commit the filter flags change anyway. - */ - - mutex_unlock(&il->mutex); - - /* - * Receiving all multicast frames is always enabled by the - * default flags setup in il_connection_init_rx_config() - * since we currently do not support programming multicast - * filters into the device. - */ - *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | - FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; -} - - -/***************************************************************************** - * - * sysfs attributes - * - *****************************************************************************/ - -#ifdef CONFIG_IWLEGACY_DEBUG - -/* - * The following adds a new attribute to the sysfs representation - * of this device driver (i.e. a new file in /sys/bus/pci/drivers/iwl/) - * used for controlling the debug level. - * - * See the level definitions in iwl for details. - * - * The debug_level being managed using sysfs below is a per device debug - * level that is used instead of the global debug level if it (the per - * device debug level) is set. - */ -static ssize_t il3945_show_debug_level(struct device *d, - struct device_attribute *attr, char *buf) -{ - struct il_priv *il = dev_get_drvdata(d); - return sprintf(buf, "0x%08X\n", il_get_debug_level(il)); -} -static ssize_t il3945_store_debug_level(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct il_priv *il = dev_get_drvdata(d); - unsigned long val; - int ret; - - ret = strict_strtoul(buf, 0, &val); - if (ret) - IL_INFO("%s is not in hex or decimal form.\n", buf); - else { - il->debug_level = val; - if (il_alloc_traffic_mem(il)) - IL_ERR( - "Not enough memory to generate traffic log\n"); - } - return strnlen(buf, count); -} - -static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, - il3945_show_debug_level, il3945_store_debug_level); - -#endif /* CONFIG_IWLEGACY_DEBUG */ - -static ssize_t il3945_show_temperature(struct device *d, - struct device_attribute *attr, char *buf) -{ - struct il_priv *il = dev_get_drvdata(d); - - if (!il_is_alive(il)) - return -EAGAIN; - - return sprintf(buf, "%d\n", il3945_hw_get_temperature(il)); -} - -static DEVICE_ATTR(temperature, S_IRUGO, il3945_show_temperature, NULL); - -static ssize_t il3945_show_tx_power(struct device *d, - struct device_attribute *attr, char *buf) -{ - struct il_priv *il = dev_get_drvdata(d); - return sprintf(buf, "%d\n", il->tx_power_user_lmt); -} - -static ssize_t il3945_store_tx_power(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct il_priv *il = dev_get_drvdata(d); - char *p = (char *)buf; - u32 val; - - val = simple_strtoul(p, &p, 10); - if (p == buf) - IL_INFO(": %s is not in decimal form.\n", buf); - else - il3945_hw_reg_set_txpower(il, val); - - return count; -} - -static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, il3945_show_tx_power, il3945_store_tx_power); - -static ssize_t il3945_show_flags(struct device *d, - struct device_attribute *attr, char *buf) -{ - struct il_priv *il = dev_get_drvdata(d); - struct il_rxon_context *ctx = &il->ctx; - - return sprintf(buf, "0x%04X\n", ctx->active.flags); -} - -static ssize_t il3945_store_flags(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct il_priv *il = dev_get_drvdata(d); - u32 flags = simple_strtoul(buf, NULL, 0); - struct il_rxon_context *ctx = &il->ctx; - - mutex_lock(&il->mutex); - if (le32_to_cpu(ctx->staging.flags) != flags) { - /* Cancel any currently running scans... */ - if (il_scan_cancel_timeout(il, 100)) - IL_WARN("Could not cancel scan.\n"); - else { - D_INFO("Committing rxon.flags = 0x%04X\n", - flags); - ctx->staging.flags = cpu_to_le32(flags); - il3945_commit_rxon(il, ctx); - } - } - mutex_unlock(&il->mutex); - - return count; -} - -static DEVICE_ATTR(flags, S_IWUSR | S_IRUGO, il3945_show_flags, il3945_store_flags); - -static ssize_t il3945_show_filter_flags(struct device *d, - struct device_attribute *attr, char *buf) -{ - struct il_priv *il = dev_get_drvdata(d); - struct il_rxon_context *ctx = &il->ctx; - - return sprintf(buf, "0x%04X\n", - le32_to_cpu(ctx->active.filter_flags)); -} - -static ssize_t il3945_store_filter_flags(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct il_priv *il = dev_get_drvdata(d); - struct il_rxon_context *ctx = &il->ctx; - u32 filter_flags = simple_strtoul(buf, NULL, 0); - - mutex_lock(&il->mutex); - if (le32_to_cpu(ctx->staging.filter_flags) != filter_flags) { - /* Cancel any currently running scans... */ - if (il_scan_cancel_timeout(il, 100)) - IL_WARN("Could not cancel scan.\n"); - else { - D_INFO("Committing rxon.filter_flags = " - "0x%04X\n", filter_flags); - ctx->staging.filter_flags = - cpu_to_le32(filter_flags); - il3945_commit_rxon(il, ctx); - } - } - mutex_unlock(&il->mutex); - - return count; -} - -static DEVICE_ATTR(filter_flags, S_IWUSR | S_IRUGO, il3945_show_filter_flags, - il3945_store_filter_flags); - -static ssize_t il3945_show_measurement(struct device *d, - struct device_attribute *attr, char *buf) -{ - struct il_priv *il = dev_get_drvdata(d); - struct il_spectrum_notification measure_report; - u32 size = sizeof(measure_report), len = 0, ofs = 0; - u8 *data = (u8 *)&measure_report; - unsigned long flags; - - spin_lock_irqsave(&il->lock, flags); - if (!(il->measurement_status & MEASUREMENT_READY)) { - spin_unlock_irqrestore(&il->lock, flags); - return 0; - } - memcpy(&measure_report, &il->measure_report, size); - il->measurement_status = 0; - spin_unlock_irqrestore(&il->lock, flags); - - while (size && PAGE_SIZE - len) { - hex_dump_to_buffer(data + ofs, size, 16, 1, buf + len, - PAGE_SIZE - len, 1); - len = strlen(buf); - if (PAGE_SIZE - len) - buf[len++] = '\n'; - - ofs += 16; - size -= min(size, 16U); - } - - return len; -} - -static ssize_t il3945_store_measurement(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct il_priv *il = dev_get_drvdata(d); - struct il_rxon_context *ctx = &il->ctx; - struct ieee80211_measurement_params params = { - .channel = le16_to_cpu(ctx->active.channel), - .start_time = cpu_to_le64(il->_3945.last_tsf), - .duration = cpu_to_le16(1), - }; - u8 type = IL_MEASURE_BASIC; - u8 buffer[32]; - u8 channel; - - if (count) { - char *p = buffer; - strncpy(buffer, buf, min(sizeof(buffer), count)); - channel = simple_strtoul(p, NULL, 0); - if (channel) - params.channel = channel; - - p = buffer; - while (*p && *p != ' ') - p++; - if (*p) - type = simple_strtoul(p + 1, NULL, 0); - } - - D_INFO("Invoking measurement of type %d on " - "channel %d (for '%s')\n", type, params.channel, buf); - il3945_get_measurement(il, ¶ms, type); - - return count; -} - -static DEVICE_ATTR(measurement, S_IRUSR | S_IWUSR, - il3945_show_measurement, il3945_store_measurement); - -static ssize_t il3945_store_retry_rate(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct il_priv *il = dev_get_drvdata(d); - - il->retry_rate = simple_strtoul(buf, NULL, 0); - if (il->retry_rate <= 0) - il->retry_rate = 1; - - return count; -} - -static ssize_t il3945_show_retry_rate(struct device *d, - struct device_attribute *attr, char *buf) -{ - struct il_priv *il = dev_get_drvdata(d); - return sprintf(buf, "%d", il->retry_rate); -} - -static DEVICE_ATTR(retry_rate, S_IWUSR | S_IRUSR, il3945_show_retry_rate, - il3945_store_retry_rate); - - -static ssize_t il3945_show_channels(struct device *d, - struct device_attribute *attr, char *buf) -{ - /* all this shit doesn't belong into sysfs anyway */ - return 0; -} - -static DEVICE_ATTR(channels, S_IRUSR, il3945_show_channels, NULL); - -static ssize_t il3945_show_antenna(struct device *d, - struct device_attribute *attr, char *buf) -{ - struct il_priv *il = dev_get_drvdata(d); - - if (!il_is_alive(il)) - return -EAGAIN; - - return sprintf(buf, "%d\n", il3945_mod_params.antenna); -} - -static ssize_t il3945_store_antenna(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct il_priv *il __maybe_unused = dev_get_drvdata(d); - int ant; - - if (count == 0) - return 0; - - if (sscanf(buf, "%1i", &ant) != 1) { - D_INFO("not in hex or decimal form.\n"); - return count; - } - - if (ant >= 0 && ant <= 2) { - D_INFO("Setting antenna select to %d.\n", ant); - il3945_mod_params.antenna = (enum il3945_antenna)ant; - } else - D_INFO("Bad antenna select value %d.\n", ant); - - - return count; -} - -static DEVICE_ATTR(antenna, S_IWUSR | S_IRUGO, il3945_show_antenna, il3945_store_antenna); - -static ssize_t il3945_show_status(struct device *d, - struct device_attribute *attr, char *buf) -{ - struct il_priv *il = dev_get_drvdata(d); - if (!il_is_alive(il)) - return -EAGAIN; - return sprintf(buf, "0x%08x\n", (int)il->status); -} - -static DEVICE_ATTR(status, S_IRUGO, il3945_show_status, NULL); - -static ssize_t il3945_dump_error_log(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct il_priv *il = dev_get_drvdata(d); - char *p = (char *)buf; - - if (p[0] == '1') - il3945_dump_nic_error_log(il); - - return strnlen(buf, count); -} - -static DEVICE_ATTR(dump_errors, S_IWUSR, NULL, il3945_dump_error_log); - -/***************************************************************************** - * - * driver setup and tear down - * - *****************************************************************************/ - -static void il3945_setup_deferred_work(struct il_priv *il) -{ - il->workqueue = create_singlethread_workqueue(DRV_NAME); - - init_waitqueue_head(&il->wait_command_queue); - - INIT_WORK(&il->restart, il3945_bg_restart); - INIT_WORK(&il->rx_replenish, il3945_bg_rx_replenish); - INIT_DELAYED_WORK(&il->init_alive_start, il3945_bg_init_alive_start); - INIT_DELAYED_WORK(&il->alive_start, il3945_bg_alive_start); - INIT_DELAYED_WORK(&il->_3945.rfkill_poll, il3945_rfkill_poll); - - il_setup_scan_deferred_work(il); - - il3945_hw_setup_deferred_work(il); - - init_timer(&il->watchdog); - il->watchdog.data = (unsigned long)il; - il->watchdog.function = il_bg_watchdog; - - tasklet_init(&il->irq_tasklet, (void (*)(unsigned long)) - il3945_irq_tasklet, (unsigned long)il); -} - -static void il3945_cancel_deferred_work(struct il_priv *il) -{ - il3945_hw_cancel_deferred_work(il); - - cancel_delayed_work_sync(&il->init_alive_start); - cancel_delayed_work(&il->alive_start); - - il_cancel_scan_deferred_work(il); -} - -static struct attribute *il3945_sysfs_entries[] = { - &dev_attr_antenna.attr, - &dev_attr_channels.attr, - &dev_attr_dump_errors.attr, - &dev_attr_flags.attr, - &dev_attr_filter_flags.attr, - &dev_attr_measurement.attr, - &dev_attr_retry_rate.attr, - &dev_attr_status.attr, - &dev_attr_temperature.attr, - &dev_attr_tx_power.attr, -#ifdef CONFIG_IWLEGACY_DEBUG - &dev_attr_debug_level.attr, -#endif - NULL -}; - -static struct attribute_group il3945_attribute_group = { - .name = NULL, /* put in device directory */ - .attrs = il3945_sysfs_entries, -}; - -struct ieee80211_ops il3945_hw_ops = { - .tx = il3945_mac_tx, - .start = il3945_mac_start, - .stop = il3945_mac_stop, - .add_interface = il_mac_add_interface, - .remove_interface = il_mac_remove_interface, - .change_interface = il_mac_change_interface, - .config = il_mac_config, - .configure_filter = il3945_configure_filter, - .set_key = il3945_mac_set_key, - .conf_tx = il_mac_conf_tx, - .reset_tsf = il_mac_reset_tsf, - .bss_info_changed = il_mac_bss_info_changed, - .hw_scan = il_mac_hw_scan, - .sta_add = il3945_mac_sta_add, - .sta_remove = il_mac_sta_remove, - .tx_last_beacon = il_mac_tx_last_beacon, -}; - -static int il3945_init_drv(struct il_priv *il) -{ - int ret; - struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; - - il->retry_rate = 1; - il->beacon_skb = NULL; - - spin_lock_init(&il->sta_lock); - spin_lock_init(&il->hcmd_lock); - - INIT_LIST_HEAD(&il->free_frames); - - mutex_init(&il->mutex); - - il->ieee_channels = NULL; - il->ieee_rates = NULL; - il->band = IEEE80211_BAND_2GHZ; - - il->iw_mode = NL80211_IFTYPE_STATION; - il->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; - - /* initialize force reset */ - il->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; - - if (eeprom->version < EEPROM_3945_EEPROM_VERSION) { - IL_WARN("Unsupported EEPROM version: 0x%04X\n", - eeprom->version); - ret = -EINVAL; - goto err; - } - ret = il_init_channel_map(il); - if (ret) { - IL_ERR("initializing regulatory failed: %d\n", ret); - goto err; - } - - /* Set up txpower settings in driver for all channels */ - if (il3945_txpower_set_from_eeprom(il)) { - ret = -EIO; - goto err_free_channel_map; - } - - ret = il_init_geos(il); - if (ret) { - IL_ERR("initializing geos failed: %d\n", ret); - goto err_free_channel_map; - } - il3945_init_hw_rates(il, il->ieee_rates); - - return 0; - -err_free_channel_map: - il_free_channel_map(il); -err: - return ret; -} - -#define IL3945_MAX_PROBE_REQUEST 200 - -static int il3945_setup_mac(struct il_priv *il) -{ - int ret; - struct ieee80211_hw *hw = il->hw; - - hw->rate_control_algorithm = "iwl-3945-rs"; - hw->sta_data_size = sizeof(struct il3945_sta_priv); - hw->vif_data_size = sizeof(struct il_vif_priv); - - /* Tell mac80211 our characteristics */ - hw->flags = IEEE80211_HW_SIGNAL_DBM | - IEEE80211_HW_SPECTRUM_MGMT; - - hw->wiphy->interface_modes = - il->ctx.interface_modes; - - hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | - WIPHY_FLAG_DISABLE_BEACON_HINTS | - WIPHY_FLAG_IBSS_RSN; - - hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX_3945; - /* we create the 802.11 header and a zero-length SSID element */ - hw->wiphy->max_scan_ie_len = IL3945_MAX_PROBE_REQUEST - 24 - 2; - - /* Default value; 4 EDCA QOS priorities */ - hw->queues = 4; - - if (il->bands[IEEE80211_BAND_2GHZ].n_channels) - il->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = - &il->bands[IEEE80211_BAND_2GHZ]; - - if (il->bands[IEEE80211_BAND_5GHZ].n_channels) - il->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = - &il->bands[IEEE80211_BAND_5GHZ]; - - il_leds_init(il); - - ret = ieee80211_register_hw(il->hw); - if (ret) { - IL_ERR("Failed to register hw (error %d)\n", ret); - return ret; - } - il->mac80211_registered = 1; - - return 0; -} - -static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) -{ - int err = 0; - struct il_priv *il; - struct ieee80211_hw *hw; - struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data); - struct il3945_eeprom *eeprom; - unsigned long flags; - - /*********************** - * 1. Allocating HW data - * ********************/ - - /* mac80211 allocates memory for this device instance, including - * space for this driver's ilate structure */ - hw = il_alloc_all(cfg); - if (hw == NULL) { - pr_err("Can not allocate network device\n"); - err = -ENOMEM; - goto out; - } - il = hw->priv; - SET_IEEE80211_DEV(hw, &pdev->dev); - - il->cmd_queue = IL39_CMD_QUEUE_NUM; - - il->ctx.ctxid = 0; - - il->ctx.rxon_cmd = REPLY_RXON; - il->ctx.rxon_timing_cmd = REPLY_RXON_TIMING; - il->ctx.rxon_assoc_cmd = REPLY_RXON_ASSOC; - il->ctx.qos_cmd = REPLY_QOS_PARAM; - il->ctx.ap_sta_id = IL_AP_ID; - il->ctx.wep_key_cmd = REPLY_WEPKEY; - il->ctx.interface_modes = - BIT(NL80211_IFTYPE_STATION) | - BIT(NL80211_IFTYPE_ADHOC); - il->ctx.ibss_devtype = RXON_DEV_TYPE_IBSS; - il->ctx.station_devtype = RXON_DEV_TYPE_ESS; - il->ctx.unused_devtype = RXON_DEV_TYPE_ESS; - - /* - * Disabling hardware scan means that mac80211 will perform scans - * "the hard way", rather than using device's scan. - */ - if (il3945_mod_params.disable_hw_scan) { - D_INFO("Disabling hw_scan\n"); - il3945_hw_ops.hw_scan = NULL; - } - - D_INFO("*** LOAD DRIVER ***\n"); - il->cfg = cfg; - il->pci_dev = pdev; - il->inta_mask = CSR_INI_SET_MASK; - - if (il_alloc_traffic_mem(il)) - IL_ERR("Not enough memory to generate traffic log\n"); - - /*************************** - * 2. Initializing PCI bus - * *************************/ - pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | - PCIE_LINK_STATE_CLKPM); - - if (pci_enable_device(pdev)) { - err = -ENODEV; - goto out_ieee80211_free_hw; - } - - pci_set_master(pdev); - - err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); - if (!err) - err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); - if (err) { - IL_WARN("No suitable DMA available.\n"); - goto out_pci_disable_device; - } - - pci_set_drvdata(pdev, il); - err = pci_request_regions(pdev, DRV_NAME); - if (err) - goto out_pci_disable_device; - - /*********************** - * 3. Read REV Register - * ********************/ - il->hw_base = pci_iomap(pdev, 0, 0); - if (!il->hw_base) { - err = -ENODEV; - goto out_pci_release_regions; - } - - D_INFO("pci_resource_len = 0x%08llx\n", - (unsigned long long) pci_resource_len(pdev, 0)); - D_INFO("pci_resource_base = %p\n", il->hw_base); - - /* We disable the RETRY_TIMEOUT register (0x41) to keep - * PCI Tx retries from interfering with C3 CPU state */ - pci_write_config_byte(pdev, 0x41, 0x00); - - /* these spin locks will be used in apm_ops.init and EEPROM access - * we should init now - */ - spin_lock_init(&il->reg_lock); - spin_lock_init(&il->lock); - - /* - * stop and reset the on-board processor just in case it is in a - * strange state ... like being left stranded by a primary kernel - * and this is now the kdump kernel trying to start up - */ - _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); - - /*********************** - * 4. Read EEPROM - * ********************/ - - /* Read the EEPROM */ - err = il_eeprom_init(il); - if (err) { - IL_ERR("Unable to init EEPROM\n"); - goto out_iounmap; - } - /* MAC Address location in EEPROM same for 3945/4965 */ - eeprom = (struct il3945_eeprom *)il->eeprom; - D_INFO("MAC address: %pM\n", eeprom->mac_address); - SET_IEEE80211_PERM_ADDR(il->hw, eeprom->mac_address); - - /*********************** - * 5. Setup HW Constants - * ********************/ - /* Device-specific setup */ - if (il3945_hw_set_hw_params(il)) { - IL_ERR("failed to set hw settings\n"); - goto out_eeprom_free; - } - - /*********************** - * 6. Setup il - * ********************/ - - err = il3945_init_drv(il); - if (err) { - IL_ERR("initializing driver failed\n"); - goto out_unset_hw_params; - } - - IL_INFO("Detected Intel Wireless WiFi Link %s\n", - il->cfg->name); - - /*********************** - * 7. Setup Services - * ********************/ - - spin_lock_irqsave(&il->lock, flags); - il_disable_interrupts(il); - spin_unlock_irqrestore(&il->lock, flags); - - pci_enable_msi(il->pci_dev); - - err = request_irq(il->pci_dev->irq, il_isr, - IRQF_SHARED, DRV_NAME, il); - if (err) { - IL_ERR("Error allocating IRQ %d\n", il->pci_dev->irq); - goto out_disable_msi; - } - - err = sysfs_create_group(&pdev->dev.kobj, &il3945_attribute_group); - if (err) { - IL_ERR("failed to create sysfs device attributes\n"); - goto out_release_irq; - } - - il_set_rxon_channel(il, - &il->bands[IEEE80211_BAND_2GHZ].channels[5], - &il->ctx); - il3945_setup_deferred_work(il); - il3945_setup_rx_handlers(il); - il_power_initialize(il); - - /********************************* - * 8. Setup and Register mac80211 - * *******************************/ - - il_enable_interrupts(il); - - err = il3945_setup_mac(il); - if (err) - goto out_remove_sysfs; - - err = il_dbgfs_register(il, DRV_NAME); - if (err) - IL_ERR("failed to create debugfs files. Ignoring error: %d\n", err); - - /* Start monitoring the killswitch */ - queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, - 2 * HZ); - - return 0; - - out_remove_sysfs: - destroy_workqueue(il->workqueue); - il->workqueue = NULL; - sysfs_remove_group(&pdev->dev.kobj, &il3945_attribute_group); - out_release_irq: - free_irq(il->pci_dev->irq, il); - out_disable_msi: - pci_disable_msi(il->pci_dev); - il_free_geos(il); - il_free_channel_map(il); - out_unset_hw_params: - il3945_unset_hw_params(il); - out_eeprom_free: - il_eeprom_free(il); - out_iounmap: - pci_iounmap(pdev, il->hw_base); - out_pci_release_regions: - pci_release_regions(pdev); - out_pci_disable_device: - pci_set_drvdata(pdev, NULL); - pci_disable_device(pdev); - out_ieee80211_free_hw: - il_free_traffic_mem(il); - ieee80211_free_hw(il->hw); - out: - return err; -} - -static void __devexit il3945_pci_remove(struct pci_dev *pdev) -{ - struct il_priv *il = pci_get_drvdata(pdev); - unsigned long flags; - - if (!il) - return; - - D_INFO("*** UNLOAD DRIVER ***\n"); - - il_dbgfs_unregister(il); - - set_bit(STATUS_EXIT_PENDING, &il->status); - - il_leds_exit(il); - - if (il->mac80211_registered) { - ieee80211_unregister_hw(il->hw); - il->mac80211_registered = 0; - } else { - il3945_down(il); - } - - /* - * Make sure device is reset to low power before unloading driver. - * This may be redundant with il_down(), but there are paths to - * run il_down() without calling apm_ops.stop(), and there are - * paths to avoid running il_down() at all before leaving driver. - * This (inexpensive) call *makes sure* device is reset. - */ - il_apm_stop(il); - - /* make sure we flush any pending irq or - * tasklet for the driver - */ - spin_lock_irqsave(&il->lock, flags); - il_disable_interrupts(il); - spin_unlock_irqrestore(&il->lock, flags); - - il3945_synchronize_irq(il); - - sysfs_remove_group(&pdev->dev.kobj, &il3945_attribute_group); - - cancel_delayed_work_sync(&il->_3945.rfkill_poll); - - il3945_dealloc_ucode_pci(il); - - if (il->rxq.bd) - il3945_rx_queue_free(il, &il->rxq); - il3945_hw_txq_ctx_free(il); - - il3945_unset_hw_params(il); - - /*netif_stop_queue(dev); */ - flush_workqueue(il->workqueue); - - /* ieee80211_unregister_hw calls il3945_mac_stop, which flushes - * il->workqueue... so we can't take down the workqueue - * until now... */ - destroy_workqueue(il->workqueue); - il->workqueue = NULL; - il_free_traffic_mem(il); - - free_irq(pdev->irq, il); - pci_disable_msi(pdev); - - pci_iounmap(pdev, il->hw_base); - pci_release_regions(pdev); - pci_disable_device(pdev); - pci_set_drvdata(pdev, NULL); - - il_free_channel_map(il); - il_free_geos(il); - kfree(il->scan_cmd); - if (il->beacon_skb) - dev_kfree_skb(il->beacon_skb); - - ieee80211_free_hw(il->hw); -} - - -/***************************************************************************** - * - * driver and module entry point - * - *****************************************************************************/ - -static struct pci_driver il3945_driver = { - .name = DRV_NAME, - .id_table = il3945_hw_card_ids, - .probe = il3945_pci_probe, - .remove = __devexit_p(il3945_pci_remove), - .driver.pm = IL_LEGACY_PM_OPS, -}; - -static int __init il3945_init(void) -{ - - int ret; - pr_info(DRV_DESCRIPTION ", " DRV_VERSION "\n"); - pr_info(DRV_COPYRIGHT "\n"); - - ret = il3945_rate_control_register(); - if (ret) { - pr_err("Unable to register rate control algorithm: %d\n", ret); - return ret; - } - - ret = pci_register_driver(&il3945_driver); - if (ret) { - pr_err("Unable to initialize PCI module\n"); - goto error_register; - } - - return ret; - -error_register: - il3945_rate_control_unregister(); - return ret; -} - -static void __exit il3945_exit(void) -{ - pci_unregister_driver(&il3945_driver); - il3945_rate_control_unregister(); -} - -MODULE_FIRMWARE(IL3945_MODULE_FIRMWARE(IL3945_UCODE_API_MAX)); - -module_param_named(antenna, il3945_mod_params.antenna, int, S_IRUGO); -MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])"); -module_param_named(swcrypto, il3945_mod_params.sw_crypto, int, S_IRUGO); -MODULE_PARM_DESC(swcrypto, - "using software crypto (default 1 [software])"); -module_param_named(disable_hw_scan, il3945_mod_params.disable_hw_scan, - int, S_IRUGO); -MODULE_PARM_DESC(disable_hw_scan, "disable hardware scanning (default 1)"); -#ifdef CONFIG_IWLEGACY_DEBUG -module_param_named(debug, il_debug_level, uint, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(debug, "debug output mask"); -#endif -module_param_named(fw_restart, il3945_mod_params.restart_fw, int, S_IRUGO); -MODULE_PARM_DESC(fw_restart, "restart firmware in case of error"); - -module_exit(il3945_exit); -module_init(il3945_init); diff --git a/drivers/net/wireless/iwlegacy/iwl4965-base.c b/drivers/net/wireless/iwlegacy/iwl4965-base.c deleted file mode 100644 index df86431d3bae..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl4965-base.c +++ /dev/null @@ -1,3245 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * Portions of this file are derived from the ipw3945 project, as well - * as portions of the ieee80211 subsystem header files. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#define DRV_NAME "iwl4965" - -#include "iwl-eeprom.h" -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-io.h" -#include "iwl-helpers.h" -#include "iwl-sta.h" -#include "iwl-4965-calib.h" -#include "iwl-4965.h" -#include "iwl-4965-led.h" - - -/****************************************************************************** - * - * module boiler plate - * - ******************************************************************************/ - -/* - * module name, copyright, version, etc. - */ -#define DRV_DESCRIPTION "Intel(R) Wireless WiFi 4965 driver for Linux" - -#ifdef CONFIG_IWLEGACY_DEBUG -#define VD "d" -#else -#define VD -#endif - -#define DRV_VERSION IWLWIFI_VERSION VD - - -MODULE_DESCRIPTION(DRV_DESCRIPTION); -MODULE_VERSION(DRV_VERSION); -MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("iwl4965"); - -void il4965_update_chain_flags(struct il_priv *il) -{ - if (il->cfg->ops->hcmd->set_rxon_chain) { - il->cfg->ops->hcmd->set_rxon_chain(il, &il->ctx); - if (il->ctx.active.rx_chain != il->ctx.staging.rx_chain) - il_commit_rxon(il, &il->ctx); - } -} - -static void il4965_clear_free_frames(struct il_priv *il) -{ - struct list_head *element; - - D_INFO("%d frames on pre-allocated heap on clear.\n", - il->frames_count); - - while (!list_empty(&il->free_frames)) { - element = il->free_frames.next; - list_del(element); - kfree(list_entry(element, struct il_frame, list)); - il->frames_count--; - } - - if (il->frames_count) { - IL_WARN("%d frames still in use. Did we lose one?\n", - il->frames_count); - il->frames_count = 0; - } -} - -static struct il_frame *il4965_get_free_frame(struct il_priv *il) -{ - struct il_frame *frame; - struct list_head *element; - if (list_empty(&il->free_frames)) { - frame = kzalloc(sizeof(*frame), GFP_KERNEL); - if (!frame) { - IL_ERR("Could not allocate frame!\n"); - return NULL; - } - - il->frames_count++; - return frame; - } - - element = il->free_frames.next; - list_del(element); - return list_entry(element, struct il_frame, list); -} - -static void il4965_free_frame(struct il_priv *il, struct il_frame *frame) -{ - memset(frame, 0, sizeof(*frame)); - list_add(&frame->list, &il->free_frames); -} - -static u32 il4965_fill_beacon_frame(struct il_priv *il, - struct ieee80211_hdr *hdr, - int left) -{ - lockdep_assert_held(&il->mutex); - - if (!il->beacon_skb) - return 0; - - if (il->beacon_skb->len > left) - return 0; - - memcpy(hdr, il->beacon_skb->data, il->beacon_skb->len); - - return il->beacon_skb->len; -} - -/* Parse the beacon frame to find the TIM element and set tim_idx & tim_size */ -static void il4965_set_beacon_tim(struct il_priv *il, - struct il_tx_beacon_cmd *tx_beacon_cmd, - u8 *beacon, u32 frame_size) -{ - u16 tim_idx; - struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)beacon; - - /* - * The idx is relative to frame start but we start looking at the - * variable-length part of the beacon. - */ - tim_idx = mgmt->u.beacon.variable - beacon; - - /* Parse variable-length elements of beacon to find WLAN_EID_TIM */ - while ((tim_idx < (frame_size - 2)) && - (beacon[tim_idx] != WLAN_EID_TIM)) - tim_idx += beacon[tim_idx+1] + 2; - - /* If TIM field was found, set variables */ - if ((tim_idx < (frame_size - 1)) && (beacon[tim_idx] == WLAN_EID_TIM)) { - tx_beacon_cmd->tim_idx = cpu_to_le16(tim_idx); - tx_beacon_cmd->tim_size = beacon[tim_idx+1]; - } else - IL_WARN("Unable to find TIM Element in beacon\n"); -} - -static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *il, - struct il_frame *frame) -{ - struct il_tx_beacon_cmd *tx_beacon_cmd; - u32 frame_size; - u32 rate_flags; - u32 rate; - /* - * We have to set up the TX command, the TX Beacon command, and the - * beacon contents. - */ - - lockdep_assert_held(&il->mutex); - - if (!il->beacon_ctx) { - IL_ERR("trying to build beacon w/o beacon context!\n"); - return 0; - } - - /* Initialize memory */ - tx_beacon_cmd = &frame->u.beacon; - memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); - - /* Set up TX beacon contents */ - frame_size = il4965_fill_beacon_frame(il, tx_beacon_cmd->frame, - sizeof(frame->u) - sizeof(*tx_beacon_cmd)); - if (WARN_ON_ONCE(frame_size > MAX_MPDU_SIZE)) - return 0; - if (!frame_size) - return 0; - - /* Set up TX command fields */ - tx_beacon_cmd->tx.len = cpu_to_le16((u16)frame_size); - tx_beacon_cmd->tx.sta_id = il->beacon_ctx->bcast_sta_id; - tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; - tx_beacon_cmd->tx.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK | - TX_CMD_FLG_TSF_MSK | TX_CMD_FLG_STA_RATE_MSK; - - /* Set up TX beacon command fields */ - il4965_set_beacon_tim(il, tx_beacon_cmd, (u8 *)tx_beacon_cmd->frame, - frame_size); - - /* Set up packet rate and flags */ - rate = il_get_lowest_plcp(il, il->beacon_ctx); - il->mgmt_tx_ant = il4965_toggle_tx_ant(il, il->mgmt_tx_ant, - il->hw_params.valid_tx_ant); - rate_flags = il4965_ant_idx_to_flags(il->mgmt_tx_ant); - if ((rate >= IL_FIRST_CCK_RATE) && (rate <= IL_LAST_CCK_RATE)) - rate_flags |= RATE_MCS_CCK_MSK; - tx_beacon_cmd->tx.rate_n_flags = il4965_hw_set_rate_n_flags(rate, - rate_flags); - - return sizeof(*tx_beacon_cmd) + frame_size; -} - -int il4965_send_beacon_cmd(struct il_priv *il) -{ - struct il_frame *frame; - unsigned int frame_size; - int rc; - - frame = il4965_get_free_frame(il); - if (!frame) { - IL_ERR("Could not obtain free frame buffer for beacon " - "command.\n"); - return -ENOMEM; - } - - frame_size = il4965_hw_get_beacon_cmd(il, frame); - if (!frame_size) { - IL_ERR("Error configuring the beacon command\n"); - il4965_free_frame(il, frame); - return -EINVAL; - } - - rc = il_send_cmd_pdu(il, REPLY_TX_BEACON, frame_size, - &frame->u.cmd[0]); - - il4965_free_frame(il, frame); - - return rc; -} - -static inline dma_addr_t il4965_tfd_tb_get_addr(struct il_tfd *tfd, u8 idx) -{ - struct il_tfd_tb *tb = &tfd->tbs[idx]; - - dma_addr_t addr = get_unaligned_le32(&tb->lo); - if (sizeof(dma_addr_t) > sizeof(u32)) - addr |= - ((dma_addr_t)(le16_to_cpu(tb->hi_n_len) & 0xF) << 16) << 16; - - return addr; -} - -static inline u16 il4965_tfd_tb_get_len(struct il_tfd *tfd, u8 idx) -{ - struct il_tfd_tb *tb = &tfd->tbs[idx]; - - return le16_to_cpu(tb->hi_n_len) >> 4; -} - -static inline void il4965_tfd_set_tb(struct il_tfd *tfd, u8 idx, - dma_addr_t addr, u16 len) -{ - struct il_tfd_tb *tb = &tfd->tbs[idx]; - u16 hi_n_len = len << 4; - - put_unaligned_le32(addr, &tb->lo); - if (sizeof(dma_addr_t) > sizeof(u32)) - hi_n_len |= ((addr >> 16) >> 16) & 0xF; - - tb->hi_n_len = cpu_to_le16(hi_n_len); - - tfd->num_tbs = idx + 1; -} - -static inline u8 il4965_tfd_get_num_tbs(struct il_tfd *tfd) -{ - return tfd->num_tbs & 0x1f; -} - -/** - * il4965_hw_txq_free_tfd - Free all chunks referenced by TFD [txq->q.read_ptr] - * @il - driver ilate data - * @txq - tx queue - * - * Does NOT advance any TFD circular buffer read/write idxes - * Does NOT free the TFD itself (which is within circular buffer) - */ -void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) -{ - struct il_tfd *tfd_tmp = (struct il_tfd *)txq->tfds; - struct il_tfd *tfd; - struct pci_dev *dev = il->pci_dev; - int idx = txq->q.read_ptr; - int i; - int num_tbs; - - tfd = &tfd_tmp[idx]; - - /* Sanity check on number of chunks */ - num_tbs = il4965_tfd_get_num_tbs(tfd); - - if (num_tbs >= IL_NUM_OF_TBS) { - IL_ERR("Too many chunks: %i\n", num_tbs); - /* @todo issue fatal error, it is quite serious situation */ - return; - } - - /* Unmap tx_cmd */ - if (num_tbs) - pci_unmap_single(dev, - dma_unmap_addr(&txq->meta[idx], mapping), - dma_unmap_len(&txq->meta[idx], len), - PCI_DMA_BIDIRECTIONAL); - - /* Unmap chunks, if any. */ - for (i = 1; i < num_tbs; i++) - pci_unmap_single(dev, il4965_tfd_tb_get_addr(tfd, i), - il4965_tfd_tb_get_len(tfd, i), - PCI_DMA_TODEVICE); - - /* free SKB */ - if (txq->txb) { - struct sk_buff *skb; - - skb = txq->txb[txq->q.read_ptr].skb; - - /* can be called from irqs-disabled context */ - if (skb) { - dev_kfree_skb_any(skb); - txq->txb[txq->q.read_ptr].skb = NULL; - } - } -} - -int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, - struct il_tx_queue *txq, - dma_addr_t addr, u16 len, - u8 reset, u8 pad) -{ - struct il_queue *q; - struct il_tfd *tfd, *tfd_tmp; - u32 num_tbs; - - q = &txq->q; - tfd_tmp = (struct il_tfd *)txq->tfds; - tfd = &tfd_tmp[q->write_ptr]; - - if (reset) - memset(tfd, 0, sizeof(*tfd)); - - num_tbs = il4965_tfd_get_num_tbs(tfd); - - /* Each TFD can point to a maximum 20 Tx buffers */ - if (num_tbs >= IL_NUM_OF_TBS) { - IL_ERR("Error can not send more than %d chunks\n", - IL_NUM_OF_TBS); - return -EINVAL; - } - - BUG_ON(addr & ~DMA_BIT_MASK(36)); - if (unlikely(addr & ~IL_TX_DMA_MASK)) - IL_ERR("Unaligned address = %llx\n", - (unsigned long long)addr); - - il4965_tfd_set_tb(tfd, num_tbs, addr, len); - - return 0; -} - -/* - * Tell nic where to find circular buffer of Tx Frame Descriptors for - * given Tx queue, and enable the DMA channel used for that queue. - * - * 4965 supports up to 16 Tx queues in DRAM, mapped to up to 8 Tx DMA - * channels supported in hardware. - */ -int il4965_hw_tx_queue_init(struct il_priv *il, - struct il_tx_queue *txq) -{ - int txq_id = txq->q.id; - - /* Circular buffer (TFD queue in DRAM) physical base address */ - il_wr(il, FH_MEM_CBBC_QUEUE(txq_id), - txq->q.dma_addr >> 8); - - return 0; -} - -/****************************************************************************** - * - * Generic RX handler implementations - * - ******************************************************************************/ -static void il4965_rx_reply_alive(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il_alive_resp *palive; - struct delayed_work *pwork; - - palive = &pkt->u.alive_frame; - - D_INFO("Alive ucode status 0x%08X revision " - "0x%01X 0x%01X\n", - palive->is_valid, palive->ver_type, - palive->ver_subtype); - - if (palive->ver_subtype == INITIALIZE_SUBTYPE) { - D_INFO("Initialization Alive received.\n"); - memcpy(&il->card_alive_init, - &pkt->u.alive_frame, - sizeof(struct il_init_alive_resp)); - pwork = &il->init_alive_start; - } else { - D_INFO("Runtime Alive received.\n"); - memcpy(&il->card_alive, &pkt->u.alive_frame, - sizeof(struct il_alive_resp)); - pwork = &il->alive_start; - } - - /* We delay the ALIVE response by 5ms to - * give the HW RF Kill time to activate... */ - if (palive->is_valid == UCODE_VALID_OK) - queue_delayed_work(il->workqueue, pwork, - msecs_to_jiffies(5)); - else - IL_WARN("uCode did not respond OK.\n"); -} - -/** - * il4965_bg_stats_periodic - Timer callback to queue stats - * - * This callback is provided in order to send a stats request. - * - * This timer function is continually reset to execute within - * REG_RECALIB_PERIOD seconds since the last STATISTICS_NOTIFICATION - * was received. We need to ensure we receive the stats in order - * to update the temperature used for calibrating the TXPOWER. - */ -static void il4965_bg_stats_periodic(unsigned long data) -{ - struct il_priv *il = (struct il_priv *)data; - - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - return; - - /* dont send host command if rf-kill is on */ - if (!il_is_ready_rf(il)) - return; - - il_send_stats_request(il, CMD_ASYNC, false); -} - -static void il4965_rx_beacon_notif(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il4965_beacon_notif *beacon = - (struct il4965_beacon_notif *)pkt->u.raw; -#ifdef CONFIG_IWLEGACY_DEBUG - u8 rate = il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); - - D_RX("beacon status %x retries %d iss %d " - "tsf %d %d rate %d\n", - le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, - beacon->beacon_notify_hdr.failure_frame, - le32_to_cpu(beacon->ibss_mgr_status), - le32_to_cpu(beacon->high_tsf), - le32_to_cpu(beacon->low_tsf), rate); -#endif - - il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); -} - -static void il4965_perform_ct_kill_task(struct il_priv *il) -{ - unsigned long flags; - - D_POWER("Stop all queues\n"); - - if (il->mac80211_registered) - ieee80211_stop_queues(il->hw); - - _il_wr(il, CSR_UCODE_DRV_GP1_SET, - CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); - _il_rd(il, CSR_UCODE_DRV_GP1); - - spin_lock_irqsave(&il->reg_lock, flags); - if (!_il_grab_nic_access(il)) - _il_release_nic_access(il); - spin_unlock_irqrestore(&il->reg_lock, flags); -} - -/* Handle notification from uCode that card's power state is changing - * due to software, hardware, or critical temperature RFKILL */ -static void il4965_rx_card_state_notif(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); - unsigned long status = il->status; - - D_RF_KILL("Card state received: HW:%s SW:%s CT:%s\n", - (flags & HW_CARD_DISABLED) ? "Kill" : "On", - (flags & SW_CARD_DISABLED) ? "Kill" : "On", - (flags & CT_CARD_DISABLED) ? - "Reached" : "Not reached"); - - if (flags & (SW_CARD_DISABLED | HW_CARD_DISABLED | - CT_CARD_DISABLED)) { - - _il_wr(il, CSR_UCODE_DRV_GP1_SET, - CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - - il_wr(il, HBUS_TARG_MBX_C, - HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); - - if (!(flags & RXON_CARD_DISABLED)) { - _il_wr(il, CSR_UCODE_DRV_GP1_CLR, - CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - il_wr(il, HBUS_TARG_MBX_C, - HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); - } - } - - if (flags & CT_CARD_DISABLED) - il4965_perform_ct_kill_task(il); - - if (flags & HW_CARD_DISABLED) - set_bit(STATUS_RF_KILL_HW, &il->status); - else - clear_bit(STATUS_RF_KILL_HW, &il->status); - - if (!(flags & RXON_CARD_DISABLED)) - il_scan_cancel(il); - - if ((test_bit(STATUS_RF_KILL_HW, &status) != - test_bit(STATUS_RF_KILL_HW, &il->status))) - wiphy_rfkill_set_hw_state(il->hw->wiphy, - test_bit(STATUS_RF_KILL_HW, &il->status)); - else - wake_up(&il->wait_command_queue); -} - -/** - * il4965_setup_rx_handlers - Initialize Rx handler callbacks - * - * Setup the RX handlers for each of the reply types sent from the uCode - * to the host. - * - * This function chains into the hardware specific files for them to setup - * any hardware specific handlers as well. - */ -static void il4965_setup_rx_handlers(struct il_priv *il) -{ - il->rx_handlers[REPLY_ALIVE] = il4965_rx_reply_alive; - il->rx_handlers[REPLY_ERROR] = il_rx_reply_error; - il->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa; - il->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = - il_rx_spectrum_measure_notif; - il->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; - il->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = - il_rx_pm_debug_stats_notif; - il->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; - - /* - * The same handler is used for both the REPLY to a discrete - * stats request from the host as well as for the periodic - * stats notifications (after received beacons) from the uCode. - */ - il->rx_handlers[REPLY_STATISTICS_CMD] = il4965_reply_stats; - il->rx_handlers[STATISTICS_NOTIFICATION] = il4965_rx_stats; - - il_setup_rx_scan_handlers(il); - - /* status change handler */ - il->rx_handlers[CARD_STATE_NOTIFICATION] = - il4965_rx_card_state_notif; - - il->rx_handlers[MISSED_BEACONS_NOTIFICATION] = - il4965_rx_missed_beacon_notif; - /* Rx handlers */ - il->rx_handlers[REPLY_RX_PHY_CMD] = il4965_rx_reply_rx_phy; - il->rx_handlers[REPLY_RX_MPDU_CMD] = il4965_rx_reply_rx; - /* block ack */ - il->rx_handlers[REPLY_COMPRESSED_BA] = il4965_rx_reply_compressed_ba; - /* Set up hardware specific Rx handlers */ - il->cfg->ops->lib->rx_handler_setup(il); -} - -/** - * il4965_rx_handle - Main entry function for receiving responses from uCode - * - * Uses the il->rx_handlers callback function array to invoke - * the appropriate handlers, including command responses, - * frame-received notifications, and other notifications. - */ -void il4965_rx_handle(struct il_priv *il) -{ - struct il_rx_buf *rxb; - struct il_rx_pkt *pkt; - struct il_rx_queue *rxq = &il->rxq; - u32 r, i; - int reclaim; - unsigned long flags; - u8 fill_rx = 0; - u32 count = 8; - int total_empty; - - /* uCode's read idx (stored in shared DRAM) indicates the last Rx - * buffer that the driver may process (last buffer filled by ucode). */ - r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF; - i = rxq->read; - - /* Rx interrupt, but nothing sent from uCode */ - if (i == r) - D_RX("r = %d, i = %d\n", r, i); - - /* calculate total frames need to be restock after handling RX */ - total_empty = r - rxq->write_actual; - if (total_empty < 0) - total_empty += RX_QUEUE_SIZE; - - if (total_empty > (RX_QUEUE_SIZE / 2)) - fill_rx = 1; - - while (i != r) { - int len; - - rxb = rxq->queue[i]; - - /* If an RXB doesn't have a Rx queue slot associated with it, - * then a bug has been introduced in the queue refilling - * routines -- catch it here */ - BUG_ON(rxb == NULL); - - rxq->queue[i] = NULL; - - pci_unmap_page(il->pci_dev, rxb->page_dma, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); - pkt = rxb_addr(rxb); - - len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; - len += sizeof(u32); /* account for status word */ - - /* Reclaim a command buffer only if this packet is a response - * to a (driver-originated) command. - * If the packet (e.g. Rx frame) originated from uCode, - * there is no command buffer to reclaim. - * Ucode should set SEQ_RX_FRAME bit if ucode-originated, - * but apparently a few don't get set; catch them here. */ - reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) && - (pkt->hdr.cmd != REPLY_RX_PHY_CMD) && - (pkt->hdr.cmd != REPLY_RX) && - (pkt->hdr.cmd != REPLY_RX_MPDU_CMD) && - (pkt->hdr.cmd != REPLY_COMPRESSED_BA) && - (pkt->hdr.cmd != STATISTICS_NOTIFICATION) && - (pkt->hdr.cmd != REPLY_TX); - - /* Based on type of command response or notification, - * handle those that need handling via function in - * rx_handlers table. See il4965_setup_rx_handlers() */ - if (il->rx_handlers[pkt->hdr.cmd]) { - D_RX("r = %d, i = %d, %s, 0x%02x\n", r, - i, il_get_cmd_string(pkt->hdr.cmd), - pkt->hdr.cmd); - il->isr_stats.rx_handlers[pkt->hdr.cmd]++; - il->rx_handlers[pkt->hdr.cmd] (il, rxb); - } else { - /* No handling needed */ - D_RX( - "r %d i %d No handler needed for %s, 0x%02x\n", - r, i, il_get_cmd_string(pkt->hdr.cmd), - pkt->hdr.cmd); - } - - /* - * XXX: After here, we should always check rxb->page - * against NULL before touching it or its virtual - * memory (pkt). Because some rx_handler might have - * already taken or freed the pages. - */ - - if (reclaim) { - /* Invoke any callbacks, transfer the buffer to caller, - * and fire off the (possibly) blocking il_send_cmd() - * as we reclaim the driver command queue */ - if (rxb->page) - il_tx_cmd_complete(il, rxb); - else - IL_WARN("Claim null rxb?\n"); - } - - /* Reuse the page if possible. For notification packets and - * SKBs that fail to Rx correctly, add them back into the - * rx_free list for reuse later. */ - spin_lock_irqsave(&rxq->lock, flags); - if (rxb->page != NULL) { - rxb->page_dma = pci_map_page(il->pci_dev, rxb->page, - 0, PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); - list_add_tail(&rxb->list, &rxq->rx_free); - rxq->free_count++; - } else - list_add_tail(&rxb->list, &rxq->rx_used); - - spin_unlock_irqrestore(&rxq->lock, flags); - - i = (i + 1) & RX_QUEUE_MASK; - /* If there are a lot of unused frames, - * restock the Rx queue so ucode wont assert. */ - if (fill_rx) { - count++; - if (count >= 8) { - rxq->read = i; - il4965_rx_replenish_now(il); - count = 0; - } - } - } - - /* Backtrack one entry */ - rxq->read = i; - if (fill_rx) - il4965_rx_replenish_now(il); - else - il4965_rx_queue_restock(il); -} - -/* call this function to flush any scheduled tasklet */ -static inline void il4965_synchronize_irq(struct il_priv *il) -{ - /* wait to make sure we flush pending tasklet*/ - synchronize_irq(il->pci_dev->irq); - tasklet_kill(&il->irq_tasklet); -} - -static void il4965_irq_tasklet(struct il_priv *il) -{ - u32 inta, handled = 0; - u32 inta_fh; - unsigned long flags; - u32 i; -#ifdef CONFIG_IWLEGACY_DEBUG - u32 inta_mask; -#endif - - spin_lock_irqsave(&il->lock, flags); - - /* Ack/clear/reset pending uCode interrupts. - * Note: Some bits in CSR_INT are "OR" of bits in CSR_FH_INT_STATUS, - * and will clear only when CSR_FH_INT_STATUS gets cleared. */ - inta = _il_rd(il, CSR_INT); - _il_wr(il, CSR_INT, inta); - - /* Ack/clear/reset pending flow-handler (DMA) interrupts. - * Any new interrupts that happen after this, either while we're - * in this tasklet, or later, will show up in next ISR/tasklet. */ - inta_fh = _il_rd(il, CSR_FH_INT_STATUS); - _il_wr(il, CSR_FH_INT_STATUS, inta_fh); - -#ifdef CONFIG_IWLEGACY_DEBUG - if (il_get_debug_level(il) & IL_DL_ISR) { - /* just for debug */ - inta_mask = _il_rd(il, CSR_INT_MASK); - D_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", - inta, inta_mask, inta_fh); - } -#endif - - spin_unlock_irqrestore(&il->lock, flags); - - /* Since CSR_INT and CSR_FH_INT_STATUS reads and clears are not - * atomic, make sure that inta covers all the interrupts that - * we've discovered, even if FH interrupt came in just after - * reading CSR_INT. */ - if (inta_fh & CSR49_FH_INT_RX_MASK) - inta |= CSR_INT_BIT_FH_RX; - if (inta_fh & CSR49_FH_INT_TX_MASK) - inta |= CSR_INT_BIT_FH_TX; - - /* Now service all interrupt bits discovered above. */ - if (inta & CSR_INT_BIT_HW_ERR) { - IL_ERR("Hardware error detected. Restarting.\n"); - - /* Tell the device to stop sending interrupts */ - il_disable_interrupts(il); - - il->isr_stats.hw++; - il_irq_handle_error(il); - - handled |= CSR_INT_BIT_HW_ERR; - - return; - } - -#ifdef CONFIG_IWLEGACY_DEBUG - if (il_get_debug_level(il) & (IL_DL_ISR)) { - /* NIC fires this, but we don't use it, redundant with WAKEUP */ - if (inta & CSR_INT_BIT_SCD) { - D_ISR("Scheduler finished to transmit " - "the frame/frames.\n"); - il->isr_stats.sch++; - } - - /* Alive notification via Rx interrupt will do the real work */ - if (inta & CSR_INT_BIT_ALIVE) { - D_ISR("Alive interrupt\n"); - il->isr_stats.alive++; - } - } -#endif - /* Safely ignore these bits for debug checks below */ - inta &= ~(CSR_INT_BIT_SCD | CSR_INT_BIT_ALIVE); - - /* HW RF KILL switch toggled */ - if (inta & CSR_INT_BIT_RF_KILL) { - int hw_rf_kill = 0; - if (!(_il_rd(il, CSR_GP_CNTRL) & - CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) - hw_rf_kill = 1; - - IL_WARN("RF_KILL bit toggled to %s.\n", - hw_rf_kill ? "disable radio" : "enable radio"); - - il->isr_stats.rfkill++; - - /* driver only loads ucode once setting the interface up. - * the driver allows loading the ucode even if the radio - * is killed. Hence update the killswitch state here. The - * rfkill handler will care about restarting if needed. - */ - if (!test_bit(STATUS_ALIVE, &il->status)) { - if (hw_rf_kill) - set_bit(STATUS_RF_KILL_HW, &il->status); - else - clear_bit(STATUS_RF_KILL_HW, &il->status); - wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rf_kill); - } - - handled |= CSR_INT_BIT_RF_KILL; - } - - /* Chip got too hot and stopped itself */ - if (inta & CSR_INT_BIT_CT_KILL) { - IL_ERR("Microcode CT kill error detected.\n"); - il->isr_stats.ctkill++; - handled |= CSR_INT_BIT_CT_KILL; - } - - /* Error detected by uCode */ - if (inta & CSR_INT_BIT_SW_ERR) { - IL_ERR("Microcode SW error detected. " - " Restarting 0x%X.\n", inta); - il->isr_stats.sw++; - il_irq_handle_error(il); - handled |= CSR_INT_BIT_SW_ERR; - } - - /* - * uCode wakes up after power-down sleep. - * Tell device about any new tx or host commands enqueued, - * and about any Rx buffers made available while asleep. - */ - if (inta & CSR_INT_BIT_WAKEUP) { - D_ISR("Wakeup interrupt\n"); - il_rx_queue_update_write_ptr(il, &il->rxq); - for (i = 0; i < il->hw_params.max_txq_num; i++) - il_txq_update_write_ptr(il, &il->txq[i]); - il->isr_stats.wakeup++; - handled |= CSR_INT_BIT_WAKEUP; - } - - /* All uCode command responses, including Tx command responses, - * Rx "responses" (frame-received notification), and other - * notifications from uCode come through here*/ - if (inta & (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX)) { - il4965_rx_handle(il); - il->isr_stats.rx++; - handled |= (CSR_INT_BIT_FH_RX | CSR_INT_BIT_SW_RX); - } - - /* This "Tx" DMA channel is used only for loading uCode */ - if (inta & CSR_INT_BIT_FH_TX) { - D_ISR("uCode load interrupt\n"); - il->isr_stats.tx++; - handled |= CSR_INT_BIT_FH_TX; - /* Wake up uCode load routine, now that load is complete */ - il->ucode_write_complete = 1; - wake_up(&il->wait_command_queue); - } - - if (inta & ~handled) { - IL_ERR("Unhandled INTA bits 0x%08x\n", inta & ~handled); - il->isr_stats.unhandled++; - } - - if (inta & ~(il->inta_mask)) { - IL_WARN("Disabled INTA bits 0x%08x were pending\n", - inta & ~il->inta_mask); - IL_WARN(" with FH_INT = 0x%08x\n", inta_fh); - } - - /* Re-enable all interrupts */ - /* only Re-enable if disabled by irq */ - if (test_bit(STATUS_INT_ENABLED, &il->status)) - il_enable_interrupts(il); - /* Re-enable RF_KILL if it occurred */ - else if (handled & CSR_INT_BIT_RF_KILL) - il_enable_rfkill_int(il); - -#ifdef CONFIG_IWLEGACY_DEBUG - if (il_get_debug_level(il) & (IL_DL_ISR)) { - inta = _il_rd(il, CSR_INT); - inta_mask = _il_rd(il, CSR_INT_MASK); - inta_fh = _il_rd(il, CSR_FH_INT_STATUS); - D_ISR( - "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " - "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); - } -#endif -} - -/***************************************************************************** - * - * sysfs attributes - * - *****************************************************************************/ - -#ifdef CONFIG_IWLEGACY_DEBUG - -/* - * The following adds a new attribute to the sysfs representation - * of this device driver (i.e. a new file in /sys/class/net/wlan0/device/) - * used for controlling the debug level. - * - * See the level definitions in iwl for details. - * - * The debug_level being managed using sysfs below is a per device debug - * level that is used instead of the global debug level if it (the per - * device debug level) is set. - */ -static ssize_t il4965_show_debug_level(struct device *d, - struct device_attribute *attr, char *buf) -{ - struct il_priv *il = dev_get_drvdata(d); - return sprintf(buf, "0x%08X\n", il_get_debug_level(il)); -} -static ssize_t il4965_store_debug_level(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct il_priv *il = dev_get_drvdata(d); - unsigned long val; - int ret; - - ret = strict_strtoul(buf, 0, &val); - if (ret) - IL_ERR("%s is not in hex or decimal form.\n", buf); - else { - il->debug_level = val; - if (il_alloc_traffic_mem(il)) - IL_ERR( - "Not enough memory to generate traffic log\n"); - } - return strnlen(buf, count); -} - -static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, - il4965_show_debug_level, il4965_store_debug_level); - - -#endif /* CONFIG_IWLEGACY_DEBUG */ - - -static ssize_t il4965_show_temperature(struct device *d, - struct device_attribute *attr, char *buf) -{ - struct il_priv *il = dev_get_drvdata(d); - - if (!il_is_alive(il)) - return -EAGAIN; - - return sprintf(buf, "%d\n", il->temperature); -} - -static DEVICE_ATTR(temperature, S_IRUGO, il4965_show_temperature, NULL); - -static ssize_t il4965_show_tx_power(struct device *d, - struct device_attribute *attr, char *buf) -{ - struct il_priv *il = dev_get_drvdata(d); - - if (!il_is_ready_rf(il)) - return sprintf(buf, "off\n"); - else - return sprintf(buf, "%d\n", il->tx_power_user_lmt); -} - -static ssize_t il4965_store_tx_power(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct il_priv *il = dev_get_drvdata(d); - unsigned long val; - int ret; - - ret = strict_strtoul(buf, 10, &val); - if (ret) - IL_INFO("%s is not in decimal form.\n", buf); - else { - ret = il_set_tx_power(il, val, false); - if (ret) - IL_ERR("failed setting tx power (0x%d).\n", - ret); - else - ret = count; - } - return ret; -} - -static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, - il4965_show_tx_power, il4965_store_tx_power); - -static struct attribute *il_sysfs_entries[] = { - &dev_attr_temperature.attr, - &dev_attr_tx_power.attr, -#ifdef CONFIG_IWLEGACY_DEBUG - &dev_attr_debug_level.attr, -#endif - NULL -}; - -static struct attribute_group il_attribute_group = { - .name = NULL, /* put in device directory */ - .attrs = il_sysfs_entries, -}; - -/****************************************************************************** - * - * uCode download functions - * - ******************************************************************************/ - -static void il4965_dealloc_ucode_pci(struct il_priv *il) -{ - il_free_fw_desc(il->pci_dev, &il->ucode_code); - il_free_fw_desc(il->pci_dev, &il->ucode_data); - il_free_fw_desc(il->pci_dev, &il->ucode_data_backup); - il_free_fw_desc(il->pci_dev, &il->ucode_init); - il_free_fw_desc(il->pci_dev, &il->ucode_init_data); - il_free_fw_desc(il->pci_dev, &il->ucode_boot); -} - -static void il4965_nic_start(struct il_priv *il) -{ - /* Remove all resets to allow NIC to operate */ - _il_wr(il, CSR_RESET, 0); -} - -static void il4965_ucode_callback(const struct firmware *ucode_raw, - void *context); -static int il4965_mac_setup_register(struct il_priv *il, - u32 max_probe_length); - -static int __must_check il4965_request_firmware(struct il_priv *il, bool first) -{ - const char *name_pre = il->cfg->fw_name_pre; - char tag[8]; - - if (first) { - il->fw_idx = il->cfg->ucode_api_max; - sprintf(tag, "%d", il->fw_idx); - } else { - il->fw_idx--; - sprintf(tag, "%d", il->fw_idx); - } - - if (il->fw_idx < il->cfg->ucode_api_min) { - IL_ERR("no suitable firmware found!\n"); - return -ENOENT; - } - - sprintf(il->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); - - D_INFO("attempting to load firmware '%s'\n", - il->firmware_name); - - return request_firmware_nowait(THIS_MODULE, 1, il->firmware_name, - &il->pci_dev->dev, GFP_KERNEL, il, - il4965_ucode_callback); -} - -struct il4965_firmware_pieces { - const void *inst, *data, *init, *init_data, *boot; - size_t inst_size, data_size, init_size, init_data_size, boot_size; -}; - -static int il4965_load_firmware(struct il_priv *il, - const struct firmware *ucode_raw, - struct il4965_firmware_pieces *pieces) -{ - struct il_ucode_header *ucode = (void *)ucode_raw->data; - u32 api_ver, hdr_size; - const u8 *src; - - il->ucode_ver = le32_to_cpu(ucode->ver); - api_ver = IL_UCODE_API(il->ucode_ver); - - switch (api_ver) { - default: - case 0: - case 1: - case 2: - hdr_size = 24; - if (ucode_raw->size < hdr_size) { - IL_ERR("File size too small!\n"); - return -EINVAL; - } - pieces->inst_size = le32_to_cpu(ucode->v1.inst_size); - pieces->data_size = le32_to_cpu(ucode->v1.data_size); - pieces->init_size = le32_to_cpu(ucode->v1.init_size); - pieces->init_data_size = - le32_to_cpu(ucode->v1.init_data_size); - pieces->boot_size = le32_to_cpu(ucode->v1.boot_size); - src = ucode->v1.data; - break; - } - - /* Verify size of file vs. image size info in file's header */ - if (ucode_raw->size != hdr_size + pieces->inst_size + - pieces->data_size + pieces->init_size + - pieces->init_data_size + pieces->boot_size) { - - IL_ERR( - "uCode file size %d does not match expected size\n", - (int)ucode_raw->size); - return -EINVAL; - } - - pieces->inst = src; - src += pieces->inst_size; - pieces->data = src; - src += pieces->data_size; - pieces->init = src; - src += pieces->init_size; - pieces->init_data = src; - src += pieces->init_data_size; - pieces->boot = src; - src += pieces->boot_size; - - return 0; -} - -/** - * il4965_ucode_callback - callback when firmware was loaded - * - * If loaded successfully, copies the firmware into buffers - * for the card to fetch (via DMA). - */ -static void -il4965_ucode_callback(const struct firmware *ucode_raw, void *context) -{ - struct il_priv *il = context; - struct il_ucode_header *ucode; - int err; - struct il4965_firmware_pieces pieces; - const unsigned int api_max = il->cfg->ucode_api_max; - const unsigned int api_min = il->cfg->ucode_api_min; - u32 api_ver; - - u32 max_probe_length = 200; - u32 standard_phy_calibration_size = - IL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE; - - memset(&pieces, 0, sizeof(pieces)); - - if (!ucode_raw) { - if (il->fw_idx <= il->cfg->ucode_api_max) - IL_ERR( - "request for firmware file '%s' failed.\n", - il->firmware_name); - goto try_again; - } - - D_INFO("Loaded firmware file '%s' (%zd bytes).\n", - il->firmware_name, ucode_raw->size); - - /* Make sure that we got at least the API version number */ - if (ucode_raw->size < 4) { - IL_ERR("File size way too small!\n"); - goto try_again; - } - - /* Data from ucode file: header followed by uCode images */ - ucode = (struct il_ucode_header *)ucode_raw->data; - - err = il4965_load_firmware(il, ucode_raw, &pieces); - - if (err) - goto try_again; - - api_ver = IL_UCODE_API(il->ucode_ver); - - /* - * api_ver should match the api version forming part of the - * firmware filename ... but we don't check for that and only rely - * on the API version read from firmware header from here on forward - */ - if (api_ver < api_min || api_ver > api_max) { - IL_ERR( - "Driver unable to support your firmware API. " - "Driver supports v%u, firmware is v%u.\n", - api_max, api_ver); - goto try_again; - } - - if (api_ver != api_max) - IL_ERR( - "Firmware has old API version. Expected v%u, " - "got v%u. New firmware can be obtained " - "from http://www.intellinuxwireless.org.\n", - api_max, api_ver); - - IL_INFO("loaded firmware version %u.%u.%u.%u\n", - IL_UCODE_MAJOR(il->ucode_ver), - IL_UCODE_MINOR(il->ucode_ver), - IL_UCODE_API(il->ucode_ver), - IL_UCODE_SERIAL(il->ucode_ver)); - - snprintf(il->hw->wiphy->fw_version, - sizeof(il->hw->wiphy->fw_version), - "%u.%u.%u.%u", - IL_UCODE_MAJOR(il->ucode_ver), - IL_UCODE_MINOR(il->ucode_ver), - IL_UCODE_API(il->ucode_ver), - IL_UCODE_SERIAL(il->ucode_ver)); - - /* - * For any of the failures below (before allocating pci memory) - * we will try to load a version with a smaller API -- maybe the - * user just got a corrupted version of the latest API. - */ - - D_INFO("f/w package hdr ucode version raw = 0x%x\n", - il->ucode_ver); - D_INFO("f/w package hdr runtime inst size = %Zd\n", - pieces.inst_size); - D_INFO("f/w package hdr runtime data size = %Zd\n", - pieces.data_size); - D_INFO("f/w package hdr init inst size = %Zd\n", - pieces.init_size); - D_INFO("f/w package hdr init data size = %Zd\n", - pieces.init_data_size); - D_INFO("f/w package hdr boot inst size = %Zd\n", - pieces.boot_size); - - /* Verify that uCode images will fit in card's SRAM */ - if (pieces.inst_size > il->hw_params.max_inst_size) { - IL_ERR("uCode instr len %Zd too large to fit in\n", - pieces.inst_size); - goto try_again; - } - - if (pieces.data_size > il->hw_params.max_data_size) { - IL_ERR("uCode data len %Zd too large to fit in\n", - pieces.data_size); - goto try_again; - } - - if (pieces.init_size > il->hw_params.max_inst_size) { - IL_ERR("uCode init instr len %Zd too large to fit in\n", - pieces.init_size); - goto try_again; - } - - if (pieces.init_data_size > il->hw_params.max_data_size) { - IL_ERR("uCode init data len %Zd too large to fit in\n", - pieces.init_data_size); - goto try_again; - } - - if (pieces.boot_size > il->hw_params.max_bsm_size) { - IL_ERR("uCode boot instr len %Zd too large to fit in\n", - pieces.boot_size); - goto try_again; - } - - /* Allocate ucode buffers for card's bus-master loading ... */ - - /* Runtime instructions and 2 copies of data: - * 1) unmodified from disk - * 2) backup cache for save/restore during power-downs */ - il->ucode_code.len = pieces.inst_size; - il_alloc_fw_desc(il->pci_dev, &il->ucode_code); - - il->ucode_data.len = pieces.data_size; - il_alloc_fw_desc(il->pci_dev, &il->ucode_data); - - il->ucode_data_backup.len = pieces.data_size; - il_alloc_fw_desc(il->pci_dev, &il->ucode_data_backup); - - if (!il->ucode_code.v_addr || !il->ucode_data.v_addr || - !il->ucode_data_backup.v_addr) - goto err_pci_alloc; - - /* Initialization instructions and data */ - if (pieces.init_size && pieces.init_data_size) { - il->ucode_init.len = pieces.init_size; - il_alloc_fw_desc(il->pci_dev, &il->ucode_init); - - il->ucode_init_data.len = pieces.init_data_size; - il_alloc_fw_desc(il->pci_dev, &il->ucode_init_data); - - if (!il->ucode_init.v_addr || !il->ucode_init_data.v_addr) - goto err_pci_alloc; - } - - /* Bootstrap (instructions only, no data) */ - if (pieces.boot_size) { - il->ucode_boot.len = pieces.boot_size; - il_alloc_fw_desc(il->pci_dev, &il->ucode_boot); - - if (!il->ucode_boot.v_addr) - goto err_pci_alloc; - } - - /* Now that we can no longer fail, copy information */ - - il->sta_key_max_num = STA_KEY_MAX_NUM; - - /* Copy images into buffers for card's bus-master reads ... */ - - /* Runtime instructions (first block of data in file) */ - D_INFO("Copying (but not loading) uCode instr len %Zd\n", - pieces.inst_size); - memcpy(il->ucode_code.v_addr, pieces.inst, pieces.inst_size); - - D_INFO("uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", - il->ucode_code.v_addr, (u32)il->ucode_code.p_addr); - - /* - * Runtime data - * NOTE: Copy into backup buffer will be done in il_up() - */ - D_INFO("Copying (but not loading) uCode data len %Zd\n", - pieces.data_size); - memcpy(il->ucode_data.v_addr, pieces.data, pieces.data_size); - memcpy(il->ucode_data_backup.v_addr, pieces.data, pieces.data_size); - - /* Initialization instructions */ - if (pieces.init_size) { - D_INFO( - "Copying (but not loading) init instr len %Zd\n", - pieces.init_size); - memcpy(il->ucode_init.v_addr, pieces.init, pieces.init_size); - } - - /* Initialization data */ - if (pieces.init_data_size) { - D_INFO( - "Copying (but not loading) init data len %Zd\n", - pieces.init_data_size); - memcpy(il->ucode_init_data.v_addr, pieces.init_data, - pieces.init_data_size); - } - - /* Bootstrap instructions */ - D_INFO("Copying (but not loading) boot instr len %Zd\n", - pieces.boot_size); - memcpy(il->ucode_boot.v_addr, pieces.boot, pieces.boot_size); - - /* - * figure out the offset of chain noise reset and gain commands - * base on the size of standard phy calibration commands table size - */ - il->_4965.phy_calib_chain_noise_reset_cmd = - standard_phy_calibration_size; - il->_4965.phy_calib_chain_noise_gain_cmd = - standard_phy_calibration_size + 1; - - /************************************************** - * This is still part of probe() in a sense... - * - * 9. Setup and register with mac80211 and debugfs - **************************************************/ - err = il4965_mac_setup_register(il, max_probe_length); - if (err) - goto out_unbind; - - err = il_dbgfs_register(il, DRV_NAME); - if (err) - IL_ERR( - "failed to create debugfs files. Ignoring error: %d\n", err); - - err = sysfs_create_group(&il->pci_dev->dev.kobj, - &il_attribute_group); - if (err) { - IL_ERR("failed to create sysfs device attributes\n"); - goto out_unbind; - } - - /* We have our copies now, allow OS release its copies */ - release_firmware(ucode_raw); - complete(&il->_4965.firmware_loading_complete); - return; - - try_again: - /* try next, if any */ - if (il4965_request_firmware(il, false)) - goto out_unbind; - release_firmware(ucode_raw); - return; - - err_pci_alloc: - IL_ERR("failed to allocate pci memory\n"); - il4965_dealloc_ucode_pci(il); - out_unbind: - complete(&il->_4965.firmware_loading_complete); - device_release_driver(&il->pci_dev->dev); - release_firmware(ucode_raw); -} - -static const char * const desc_lookup_text[] = { - "OK", - "FAIL", - "BAD_PARAM", - "BAD_CHECKSUM", - "NMI_INTERRUPT_WDG", - "SYSASSERT", - "FATAL_ERROR", - "BAD_COMMAND", - "HW_ERROR_TUNE_LOCK", - "HW_ERROR_TEMPERATURE", - "ILLEGAL_CHAN_FREQ", - "VCC_NOT_STBL", - "FH_ERROR", - "NMI_INTERRUPT_HOST", - "NMI_INTERRUPT_ACTION_PT", - "NMI_INTERRUPT_UNKNOWN", - "UCODE_VERSION_MISMATCH", - "HW_ERROR_ABS_LOCK", - "HW_ERROR_CAL_LOCK_FAIL", - "NMI_INTERRUPT_INST_ACTION_PT", - "NMI_INTERRUPT_DATA_ACTION_PT", - "NMI_TRM_HW_ER", - "NMI_INTERRUPT_TRM", - "NMI_INTERRUPT_BREAK_POINT", - "DEBUG_0", - "DEBUG_1", - "DEBUG_2", - "DEBUG_3", -}; - -static struct { char *name; u8 num; } advanced_lookup[] = { - { "NMI_INTERRUPT_WDG", 0x34 }, - { "SYSASSERT", 0x35 }, - { "UCODE_VERSION_MISMATCH", 0x37 }, - { "BAD_COMMAND", 0x38 }, - { "NMI_INTERRUPT_DATA_ACTION_PT", 0x3C }, - { "FATAL_ERROR", 0x3D }, - { "NMI_TRM_HW_ERR", 0x46 }, - { "NMI_INTERRUPT_TRM", 0x4C }, - { "NMI_INTERRUPT_BREAK_POINT", 0x54 }, - { "NMI_INTERRUPT_WDG_RXF_FULL", 0x5C }, - { "NMI_INTERRUPT_WDG_NO_RBD_RXF_FULL", 0x64 }, - { "NMI_INTERRUPT_HOST", 0x66 }, - { "NMI_INTERRUPT_ACTION_PT", 0x7C }, - { "NMI_INTERRUPT_UNKNOWN", 0x84 }, - { "NMI_INTERRUPT_INST_ACTION_PT", 0x86 }, - { "ADVANCED_SYSASSERT", 0 }, -}; - -static const char *il4965_desc_lookup(u32 num) -{ - int i; - int max = ARRAY_SIZE(desc_lookup_text); - - if (num < max) - return desc_lookup_text[num]; - - max = ARRAY_SIZE(advanced_lookup) - 1; - for (i = 0; i < max; i++) { - if (advanced_lookup[i].num == num) - break; - } - return advanced_lookup[i].name; -} - -#define ERROR_START_OFFSET (1 * sizeof(u32)) -#define ERROR_ELEM_SIZE (7 * sizeof(u32)) - -void il4965_dump_nic_error_log(struct il_priv *il) -{ - u32 data2, line; - u32 desc, time, count, base, data1; - u32 blink1, blink2, ilink1, ilink2; - u32 pc, hcmd; - - if (il->ucode_type == UCODE_INIT) { - base = le32_to_cpu(il->card_alive_init.error_event_table_ptr); - } else { - base = le32_to_cpu(il->card_alive.error_event_table_ptr); - } - - if (!il->cfg->ops->lib->is_valid_rtc_data_addr(base)) { - IL_ERR( - "Not valid error log pointer 0x%08X for %s uCode\n", - base, (il->ucode_type == UCODE_INIT) ? "Init" : "RT"); - return; - } - - count = il_read_targ_mem(il, base); - - if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { - IL_ERR("Start IWL Error Log Dump:\n"); - IL_ERR("Status: 0x%08lX, count: %d\n", - il->status, count); - } - - desc = il_read_targ_mem(il, base + 1 * sizeof(u32)); - il->isr_stats.err_code = desc; - pc = il_read_targ_mem(il, base + 2 * sizeof(u32)); - blink1 = il_read_targ_mem(il, base + 3 * sizeof(u32)); - blink2 = il_read_targ_mem(il, base + 4 * sizeof(u32)); - ilink1 = il_read_targ_mem(il, base + 5 * sizeof(u32)); - ilink2 = il_read_targ_mem(il, base + 6 * sizeof(u32)); - data1 = il_read_targ_mem(il, base + 7 * sizeof(u32)); - data2 = il_read_targ_mem(il, base + 8 * sizeof(u32)); - line = il_read_targ_mem(il, base + 9 * sizeof(u32)); - time = il_read_targ_mem(il, base + 11 * sizeof(u32)); - hcmd = il_read_targ_mem(il, base + 22 * sizeof(u32)); - - IL_ERR("Desc Time " - "data1 data2 line\n"); - IL_ERR("%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n", - il4965_desc_lookup(desc), desc, time, data1, data2, line); - IL_ERR("pc blink1 blink2 ilink1 ilink2 hcmd\n"); - IL_ERR("0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n", - pc, blink1, blink2, ilink1, ilink2, hcmd); -} - -static void il4965_rf_kill_ct_config(struct il_priv *il) -{ - struct il_ct_kill_config cmd; - unsigned long flags; - int ret = 0; - - spin_lock_irqsave(&il->lock, flags); - _il_wr(il, CSR_UCODE_DRV_GP1_CLR, - CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); - spin_unlock_irqrestore(&il->lock, flags); - - cmd.critical_temperature_R = - cpu_to_le32(il->hw_params.ct_kill_threshold); - - ret = il_send_cmd_pdu(il, REPLY_CT_KILL_CONFIG_CMD, - sizeof(cmd), &cmd); - if (ret) - IL_ERR("REPLY_CT_KILL_CONFIG_CMD failed\n"); - else - D_INFO("REPLY_CT_KILL_CONFIG_CMD " - "succeeded, " - "critical temperature is %d\n", - il->hw_params.ct_kill_threshold); -} - -static const s8 default_queue_to_tx_fifo[] = { - IL_TX_FIFO_VO, - IL_TX_FIFO_VI, - IL_TX_FIFO_BE, - IL_TX_FIFO_BK, - IL49_CMD_FIFO_NUM, - IL_TX_FIFO_UNUSED, - IL_TX_FIFO_UNUSED, -}; - -static int il4965_alive_notify(struct il_priv *il) -{ - u32 a; - unsigned long flags; - int i, chan; - u32 reg_val; - - spin_lock_irqsave(&il->lock, flags); - - /* Clear 4965's internal Tx Scheduler data base */ - il->scd_base_addr = il_rd_prph(il, - IL49_SCD_SRAM_BASE_ADDR); - a = il->scd_base_addr + IL49_SCD_CONTEXT_DATA_OFFSET; - for (; a < il->scd_base_addr + IL49_SCD_TX_STTS_BITMAP_OFFSET; a += 4) - il_write_targ_mem(il, a, 0); - for (; a < il->scd_base_addr + IL49_SCD_TRANSLATE_TBL_OFFSET; a += 4) - il_write_targ_mem(il, a, 0); - for (; a < il->scd_base_addr + - IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(il->hw_params.max_txq_num); a += 4) - il_write_targ_mem(il, a, 0); - - /* Tel 4965 where to find Tx byte count tables */ - il_wr_prph(il, IL49_SCD_DRAM_BASE_ADDR, - il->scd_bc_tbls.dma >> 10); - - /* Enable DMA channel */ - for (chan = 0; chan < FH49_TCSR_CHNL_NUM ; chan++) - il_wr(il, - FH_TCSR_CHNL_TX_CONFIG_REG(chan), - FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | - FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE); - - /* Update FH chicken bits */ - reg_val = il_rd(il, FH_TX_CHICKEN_BITS_REG); - il_wr(il, FH_TX_CHICKEN_BITS_REG, - reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); - - /* Disable chain mode for all queues */ - il_wr_prph(il, IL49_SCD_QUEUECHAIN_SEL, 0); - - /* Initialize each Tx queue (including the command queue) */ - for (i = 0; i < il->hw_params.max_txq_num; i++) { - - /* TFD circular buffer read/write idxes */ - il_wr_prph(il, IL49_SCD_QUEUE_RDPTR(i), 0); - il_wr(il, HBUS_TARG_WRPTR, 0 | (i << 8)); - - /* Max Tx Window size for Scheduler-ACK mode */ - il_write_targ_mem(il, il->scd_base_addr + - IL49_SCD_CONTEXT_QUEUE_OFFSET(i), - (SCD_WIN_SIZE << - IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & - IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); - - /* Frame limit */ - il_write_targ_mem(il, il->scd_base_addr + - IL49_SCD_CONTEXT_QUEUE_OFFSET(i) + - sizeof(u32), - (SCD_FRAME_LIMIT << - IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) & - IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); - - } - il_wr_prph(il, IL49_SCD_INTERRUPT_MASK, - (1 << il->hw_params.max_txq_num) - 1); - - /* Activate all Tx DMA/FIFO channels */ - il4965_txq_set_sched(il, IL_MASK(0, 6)); - - il4965_set_wr_ptrs(il, IL_DEFAULT_CMD_QUEUE_NUM, 0); - - /* make sure all queue are not stopped */ - memset(&il->queue_stopped[0], 0, sizeof(il->queue_stopped)); - for (i = 0; i < 4; i++) - atomic_set(&il->queue_stop_count[i], 0); - - /* reset to 0 to enable all the queue first */ - il->txq_ctx_active_msk = 0; - /* Map each Tx/cmd queue to its corresponding fifo */ - BUILD_BUG_ON(ARRAY_SIZE(default_queue_to_tx_fifo) != 7); - - for (i = 0; i < ARRAY_SIZE(default_queue_to_tx_fifo); i++) { - int ac = default_queue_to_tx_fifo[i]; - - il_txq_ctx_activate(il, i); - - if (ac == IL_TX_FIFO_UNUSED) - continue; - - il4965_tx_queue_set_status(il, &il->txq[i], ac, 0); - } - - spin_unlock_irqrestore(&il->lock, flags); - - return 0; -} - -/** - * il4965_alive_start - called after REPLY_ALIVE notification received - * from protocol/runtime uCode (initialization uCode's - * Alive gets handled by il_init_alive_start()). - */ -static void il4965_alive_start(struct il_priv *il) -{ - int ret = 0; - struct il_rxon_context *ctx = &il->ctx; - - D_INFO("Runtime Alive received.\n"); - - if (il->card_alive.is_valid != UCODE_VALID_OK) { - /* We had an error bringing up the hardware, so take it - * all the way back down so we can try again */ - D_INFO("Alive failed.\n"); - goto restart; - } - - /* Initialize uCode has loaded Runtime uCode ... verify inst image. - * This is a paranoid check, because we would not have gotten the - * "runtime" alive if code weren't properly loaded. */ - if (il4965_verify_ucode(il)) { - /* Runtime instruction load was bad; - * take it all the way back down so we can try again */ - D_INFO("Bad runtime uCode load.\n"); - goto restart; - } - - ret = il4965_alive_notify(il); - if (ret) { - IL_WARN( - "Could not complete ALIVE transition [ntf]: %d\n", ret); - goto restart; - } - - - /* After the ALIVE response, we can send host commands to the uCode */ - set_bit(STATUS_ALIVE, &il->status); - - /* Enable watchdog to monitor the driver tx queues */ - il_setup_watchdog(il); - - if (il_is_rfkill(il)) - return; - - ieee80211_wake_queues(il->hw); - - il->active_rate = RATES_MASK; - - if (il_is_associated_ctx(ctx)) { - struct il_rxon_cmd *active_rxon = - (struct il_rxon_cmd *)&ctx->active; - /* apply any changes in staging */ - ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; - active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; - } else { - /* Initialize our rx_config data */ - il_connection_init_rx_config(il, &il->ctx); - - if (il->cfg->ops->hcmd->set_rxon_chain) - il->cfg->ops->hcmd->set_rxon_chain(il, ctx); - } - - /* Configure bluetooth coexistence if enabled */ - il_send_bt_config(il); - - il4965_reset_run_time_calib(il); - - set_bit(STATUS_READY, &il->status); - - /* Configure the adapter for unassociated operation */ - il_commit_rxon(il, ctx); - - /* At this point, the NIC is initialized and operational */ - il4965_rf_kill_ct_config(il); - - D_INFO("ALIVE processing complete.\n"); - wake_up(&il->wait_command_queue); - - il_power_update_mode(il, true); - D_INFO("Updated power mode\n"); - - return; - - restart: - queue_work(il->workqueue, &il->restart); -} - -static void il4965_cancel_deferred_work(struct il_priv *il); - -static void __il4965_down(struct il_priv *il) -{ - unsigned long flags; - int exit_pending; - - D_INFO(DRV_NAME " is going down\n"); - - il_scan_cancel_timeout(il, 200); - - exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &il->status); - - /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set - * to prevent rearm timer */ - del_timer_sync(&il->watchdog); - - il_clear_ucode_stations(il, NULL); - il_dealloc_bcast_stations(il); - il_clear_driver_stations(il); - - /* Unblock any waiting calls */ - wake_up_all(&il->wait_command_queue); - - /* Wipe out the EXIT_PENDING status bit if we are not actually - * exiting the module */ - if (!exit_pending) - clear_bit(STATUS_EXIT_PENDING, &il->status); - - /* stop and reset the on-board processor */ - _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); - - /* tell the device to stop sending interrupts */ - spin_lock_irqsave(&il->lock, flags); - il_disable_interrupts(il); - spin_unlock_irqrestore(&il->lock, flags); - il4965_synchronize_irq(il); - - if (il->mac80211_registered) - ieee80211_stop_queues(il->hw); - - /* If we have not previously called il_init() then - * clear all bits but the RF Kill bit and return */ - if (!il_is_init(il)) { - il->status = test_bit(STATUS_RF_KILL_HW, &il->status) << - STATUS_RF_KILL_HW | - test_bit(STATUS_GEO_CONFIGURED, &il->status) << - STATUS_GEO_CONFIGURED | - test_bit(STATUS_EXIT_PENDING, &il->status) << - STATUS_EXIT_PENDING; - goto exit; - } - - /* ...otherwise clear out all the status bits but the RF Kill - * bit and continue taking the NIC down. */ - il->status &= test_bit(STATUS_RF_KILL_HW, &il->status) << - STATUS_RF_KILL_HW | - test_bit(STATUS_GEO_CONFIGURED, &il->status) << - STATUS_GEO_CONFIGURED | - test_bit(STATUS_FW_ERROR, &il->status) << - STATUS_FW_ERROR | - test_bit(STATUS_EXIT_PENDING, &il->status) << - STATUS_EXIT_PENDING; - - il4965_txq_ctx_stop(il); - il4965_rxq_stop(il); - - /* Power-down device's busmaster DMA clocks */ - il_wr_prph(il, APMG_CLK_DIS_REG, APMG_CLK_VAL_DMA_CLK_RQT); - udelay(5); - - /* Make sure (redundant) we've released our request to stay awake */ - il_clear_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); - - /* Stop the device, and put it in low power state */ - il_apm_stop(il); - - exit: - memset(&il->card_alive, 0, sizeof(struct il_alive_resp)); - - dev_kfree_skb(il->beacon_skb); - il->beacon_skb = NULL; - - /* clear out any free frames */ - il4965_clear_free_frames(il); -} - -static void il4965_down(struct il_priv *il) -{ - mutex_lock(&il->mutex); - __il4965_down(il); - mutex_unlock(&il->mutex); - - il4965_cancel_deferred_work(il); -} - -#define HW_READY_TIMEOUT (50) - -static int il4965_set_hw_ready(struct il_priv *il) -{ - int ret = 0; - - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_NIC_READY); - - /* See if we got it */ - ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, - CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, - HW_READY_TIMEOUT); - if (ret != -ETIMEDOUT) - il->hw_ready = true; - else - il->hw_ready = false; - - D_INFO("hardware %s\n", - (il->hw_ready == 1) ? "ready" : "not ready"); - return ret; -} - -static int il4965_prepare_card_hw(struct il_priv *il) -{ - int ret = 0; - - D_INFO("il4965_prepare_card_hw enter\n"); - - ret = il4965_set_hw_ready(il); - if (il->hw_ready) - return ret; - - /* If HW is not ready, prepare the conditions to check again */ - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_PREPARE); - - ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, - ~CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, - CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, 150000); - - /* HW should be ready by now, check again. */ - if (ret != -ETIMEDOUT) - il4965_set_hw_ready(il); - - return ret; -} - -#define MAX_HW_RESTARTS 5 - -static int __il4965_up(struct il_priv *il) -{ - int i; - int ret; - - if (test_bit(STATUS_EXIT_PENDING, &il->status)) { - IL_WARN("Exit pending; will not bring the NIC up\n"); - return -EIO; - } - - if (!il->ucode_data_backup.v_addr || !il->ucode_data.v_addr) { - IL_ERR("ucode not available for device bringup\n"); - return -EIO; - } - - ret = il4965_alloc_bcast_station(il, &il->ctx); - if (ret) { - il_dealloc_bcast_stations(il); - return ret; - } - - il4965_prepare_card_hw(il); - - if (!il->hw_ready) { - IL_WARN("Exit HW not ready\n"); - return -EIO; - } - - /* If platform's RF_KILL switch is NOT set to KILL */ - if (_il_rd(il, - CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) - clear_bit(STATUS_RF_KILL_HW, &il->status); - else - set_bit(STATUS_RF_KILL_HW, &il->status); - - if (il_is_rfkill(il)) { - wiphy_rfkill_set_hw_state(il->hw->wiphy, true); - - il_enable_interrupts(il); - IL_WARN("Radio disabled by HW RF Kill switch\n"); - return 0; - } - - _il_wr(il, CSR_INT, 0xFFFFFFFF); - - /* must be initialised before il_hw_nic_init */ - il->cmd_queue = IL_DEFAULT_CMD_QUEUE_NUM; - - ret = il4965_hw_nic_init(il); - if (ret) { - IL_ERR("Unable to init nic\n"); - return ret; - } - - /* make sure rfkill handshake bits are cleared */ - _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - _il_wr(il, CSR_UCODE_DRV_GP1_CLR, - CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - - /* clear (again), then enable host interrupts */ - _il_wr(il, CSR_INT, 0xFFFFFFFF); - il_enable_interrupts(il); - - /* really make sure rfkill handshake bits are cleared */ - _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - - /* Copy original ucode data image from disk into backup cache. - * This will be used to initialize the on-board processor's - * data SRAM for a clean start when the runtime program first loads. */ - memcpy(il->ucode_data_backup.v_addr, il->ucode_data.v_addr, - il->ucode_data.len); - - for (i = 0; i < MAX_HW_RESTARTS; i++) { - - /* load bootstrap state machine, - * load bootstrap program into processor's memory, - * prepare to load the "initialize" uCode */ - ret = il->cfg->ops->lib->load_ucode(il); - - if (ret) { - IL_ERR("Unable to set up bootstrap uCode: %d\n", - ret); - continue; - } - - /* start card; "initialize" will load runtime ucode */ - il4965_nic_start(il); - - D_INFO(DRV_NAME " is coming up\n"); - - return 0; - } - - set_bit(STATUS_EXIT_PENDING, &il->status); - __il4965_down(il); - clear_bit(STATUS_EXIT_PENDING, &il->status); - - /* tried to restart and config the device for as long as our - * patience could withstand */ - IL_ERR("Unable to initialize device after %d attempts.\n", i); - return -EIO; -} - - -/***************************************************************************** - * - * Workqueue callbacks - * - *****************************************************************************/ - -static void il4965_bg_init_alive_start(struct work_struct *data) -{ - struct il_priv *il = - container_of(data, struct il_priv, init_alive_start.work); - - mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - goto out; - - il->cfg->ops->lib->init_alive_start(il); -out: - mutex_unlock(&il->mutex); -} - -static void il4965_bg_alive_start(struct work_struct *data) -{ - struct il_priv *il = - container_of(data, struct il_priv, alive_start.work); - - mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - goto out; - - il4965_alive_start(il); -out: - mutex_unlock(&il->mutex); -} - -static void il4965_bg_run_time_calib_work(struct work_struct *work) -{ - struct il_priv *il = container_of(work, struct il_priv, - run_time_calib_work); - - mutex_lock(&il->mutex); - - if (test_bit(STATUS_EXIT_PENDING, &il->status) || - test_bit(STATUS_SCANNING, &il->status)) { - mutex_unlock(&il->mutex); - return; - } - - if (il->start_calib) { - il4965_chain_noise_calibration(il, - (void *)&il->_4965.stats); - il4965_sensitivity_calibration(il, - (void *)&il->_4965.stats); - } - - mutex_unlock(&il->mutex); -} - -static void il4965_bg_restart(struct work_struct *data) -{ - struct il_priv *il = container_of(data, struct il_priv, restart); - - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - return; - - if (test_and_clear_bit(STATUS_FW_ERROR, &il->status)) { - mutex_lock(&il->mutex); - il->ctx.vif = NULL; - il->is_open = 0; - - __il4965_down(il); - - mutex_unlock(&il->mutex); - il4965_cancel_deferred_work(il); - ieee80211_restart_hw(il->hw); - } else { - il4965_down(il); - - mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) { - mutex_unlock(&il->mutex); - return; - } - - __il4965_up(il); - mutex_unlock(&il->mutex); - } -} - -static void il4965_bg_rx_replenish(struct work_struct *data) -{ - struct il_priv *il = - container_of(data, struct il_priv, rx_replenish); - - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - return; - - mutex_lock(&il->mutex); - il4965_rx_replenish(il); - mutex_unlock(&il->mutex); -} - -/***************************************************************************** - * - * mac80211 entry point functions - * - *****************************************************************************/ - -#define UCODE_READY_TIMEOUT (4 * HZ) - -/* - * Not a mac80211 entry point function, but it fits in with all the - * other mac80211 functions grouped here. - */ -static int il4965_mac_setup_register(struct il_priv *il, - u32 max_probe_length) -{ - int ret; - struct ieee80211_hw *hw = il->hw; - - hw->rate_control_algorithm = "iwl-4965-rs"; - - /* Tell mac80211 our characteristics */ - hw->flags = IEEE80211_HW_SIGNAL_DBM | - IEEE80211_HW_AMPDU_AGGREGATION | - IEEE80211_HW_NEED_DTIM_PERIOD | - IEEE80211_HW_SPECTRUM_MGMT | - IEEE80211_HW_REPORTS_TX_ACK_STATUS; - - if (il->cfg->sku & IL_SKU_N) - hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | - IEEE80211_HW_SUPPORTS_STATIC_SMPS; - - hw->sta_data_size = sizeof(struct il_station_priv); - hw->vif_data_size = sizeof(struct il_vif_priv); - - hw->wiphy->interface_modes |= il->ctx.interface_modes; - hw->wiphy->interface_modes |= il->ctx.exclusive_interface_modes; - - hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | - WIPHY_FLAG_DISABLE_BEACON_HINTS; - - /* - * For now, disable PS by default because it affects - * RX performance significantly. - */ - hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; - - hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; - /* we create the 802.11 header and a zero-length SSID element */ - hw->wiphy->max_scan_ie_len = max_probe_length - 24 - 2; - - /* Default value; 4 EDCA QOS priorities */ - hw->queues = 4; - - hw->max_listen_interval = IL_CONN_MAX_LISTEN_INTERVAL; - - if (il->bands[IEEE80211_BAND_2GHZ].n_channels) - il->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = - &il->bands[IEEE80211_BAND_2GHZ]; - if (il->bands[IEEE80211_BAND_5GHZ].n_channels) - il->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = - &il->bands[IEEE80211_BAND_5GHZ]; - - il_leds_init(il); - - ret = ieee80211_register_hw(il->hw); - if (ret) { - IL_ERR("Failed to register hw (error %d)\n", ret); - return ret; - } - il->mac80211_registered = 1; - - return 0; -} - - -int il4965_mac_start(struct ieee80211_hw *hw) -{ - struct il_priv *il = hw->priv; - int ret; - - D_MAC80211("enter\n"); - - /* we should be verifying the device is ready to be opened */ - mutex_lock(&il->mutex); - ret = __il4965_up(il); - mutex_unlock(&il->mutex); - - if (ret) - return ret; - - if (il_is_rfkill(il)) - goto out; - - D_INFO("Start UP work done.\n"); - - /* Wait for START_ALIVE from Run Time ucode. Otherwise callbacks from - * mac80211 will not be run successfully. */ - ret = wait_event_timeout(il->wait_command_queue, - test_bit(STATUS_READY, &il->status), - UCODE_READY_TIMEOUT); - if (!ret) { - if (!test_bit(STATUS_READY, &il->status)) { - IL_ERR("START_ALIVE timeout after %dms.\n", - jiffies_to_msecs(UCODE_READY_TIMEOUT)); - return -ETIMEDOUT; - } - } - - il4965_led_enable(il); - -out: - il->is_open = 1; - D_MAC80211("leave\n"); - return 0; -} - -void il4965_mac_stop(struct ieee80211_hw *hw) -{ - struct il_priv *il = hw->priv; - - D_MAC80211("enter\n"); - - if (!il->is_open) - return; - - il->is_open = 0; - - il4965_down(il); - - flush_workqueue(il->workqueue); - - /* User space software may expect getting rfkill changes - * even if interface is down */ - _il_wr(il, CSR_INT, 0xFFFFFFFF); - il_enable_rfkill_int(il); - - D_MAC80211("leave\n"); -} - -void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) -{ - struct il_priv *il = hw->priv; - - D_MACDUMP("enter\n"); - - D_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, - ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); - - if (il4965_tx_skb(il, skb)) - dev_kfree_skb_any(skb); - - D_MACDUMP("leave\n"); -} - -void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_key_conf *keyconf, - struct ieee80211_sta *sta, - u32 iv32, u16 *phase1key) -{ - struct il_priv *il = hw->priv; - struct il_vif_priv *vif_priv = (void *)vif->drv_priv; - - D_MAC80211("enter\n"); - - il4965_update_tkip_key(il, vif_priv->ctx, keyconf, sta, - iv32, phase1key); - - D_MAC80211("leave\n"); -} - -int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, - struct ieee80211_vif *vif, struct ieee80211_sta *sta, - struct ieee80211_key_conf *key) -{ - struct il_priv *il = hw->priv; - struct il_vif_priv *vif_priv = (void *)vif->drv_priv; - struct il_rxon_context *ctx = vif_priv->ctx; - int ret; - u8 sta_id; - bool is_default_wep_key = false; - - D_MAC80211("enter\n"); - - if (il->cfg->mod_params->sw_crypto) { - D_MAC80211("leave - hwcrypto disabled\n"); - return -EOPNOTSUPP; - } - - sta_id = il_sta_id_or_broadcast(il, vif_priv->ctx, sta); - if (sta_id == IL_INVALID_STATION) - return -EINVAL; - - mutex_lock(&il->mutex); - il_scan_cancel_timeout(il, 100); - - /* - * If we are getting WEP group key and we didn't receive any key mapping - * so far, we are in legacy wep mode (group key only), otherwise we are - * in 1X mode. - * In legacy wep mode, we use another host command to the uCode. - */ - if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || - key->cipher == WLAN_CIPHER_SUITE_WEP104) && - !sta) { - if (cmd == SET_KEY) - is_default_wep_key = !ctx->key_mapping_keys; - else - is_default_wep_key = - (key->hw_key_idx == HW_KEY_DEFAULT); - } - - switch (cmd) { - case SET_KEY: - if (is_default_wep_key) - ret = il4965_set_default_wep_key(il, - vif_priv->ctx, key); - else - ret = il4965_set_dynamic_key(il, vif_priv->ctx, - key, sta_id); - - D_MAC80211("enable hwcrypto key\n"); - break; - case DISABLE_KEY: - if (is_default_wep_key) - ret = il4965_remove_default_wep_key(il, ctx, key); - else - ret = il4965_remove_dynamic_key(il, ctx, - key, sta_id); - - D_MAC80211("disable hwcrypto key\n"); - break; - default: - ret = -EINVAL; - } - - mutex_unlock(&il->mutex); - D_MAC80211("leave\n"); - - return ret; -} - -int il4965_mac_ampdu_action(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - enum ieee80211_ampdu_mlme_action action, - struct ieee80211_sta *sta, u16 tid, u16 *ssn, - u8 buf_size) -{ - struct il_priv *il = hw->priv; - int ret = -EINVAL; - - D_HT("A-MPDU action on addr %pM tid %d\n", - sta->addr, tid); - - if (!(il->cfg->sku & IL_SKU_N)) - return -EACCES; - - mutex_lock(&il->mutex); - - switch (action) { - case IEEE80211_AMPDU_RX_START: - D_HT("start Rx\n"); - ret = il4965_sta_rx_agg_start(il, sta, tid, *ssn); - break; - case IEEE80211_AMPDU_RX_STOP: - D_HT("stop Rx\n"); - ret = il4965_sta_rx_agg_stop(il, sta, tid); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - ret = 0; - break; - case IEEE80211_AMPDU_TX_START: - D_HT("start Tx\n"); - ret = il4965_tx_agg_start(il, vif, sta, tid, ssn); - break; - case IEEE80211_AMPDU_TX_STOP: - D_HT("stop Tx\n"); - ret = il4965_tx_agg_stop(il, vif, sta, tid); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) - ret = 0; - break; - case IEEE80211_AMPDU_TX_OPERATIONAL: - ret = 0; - break; - } - mutex_unlock(&il->mutex); - - return ret; -} - -int il4965_mac_sta_add(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta) -{ - struct il_priv *il = hw->priv; - struct il_station_priv *sta_priv = (void *)sta->drv_priv; - struct il_vif_priv *vif_priv = (void *)vif->drv_priv; - bool is_ap = vif->type == NL80211_IFTYPE_STATION; - int ret; - u8 sta_id; - - D_INFO("received request to add station %pM\n", - sta->addr); - mutex_lock(&il->mutex); - D_INFO("proceeding to add station %pM\n", - sta->addr); - sta_priv->common.sta_id = IL_INVALID_STATION; - - atomic_set(&sta_priv->pending_frames, 0); - - ret = il_add_station_common(il, vif_priv->ctx, sta->addr, - is_ap, sta, &sta_id); - if (ret) { - IL_ERR("Unable to add station %pM (%d)\n", - sta->addr, ret); - /* Should we return success if return code is EEXIST ? */ - mutex_unlock(&il->mutex); - return ret; - } - - sta_priv->common.sta_id = sta_id; - - /* Initialize rate scaling */ - D_INFO("Initializing rate scaling for station %pM\n", - sta->addr); - il4965_rs_rate_init(il, sta, sta_id); - mutex_unlock(&il->mutex); - - return 0; -} - -void il4965_mac_channel_switch(struct ieee80211_hw *hw, - struct ieee80211_channel_switch *ch_switch) -{ - struct il_priv *il = hw->priv; - const struct il_channel_info *ch_info; - struct ieee80211_conf *conf = &hw->conf; - struct ieee80211_channel *channel = ch_switch->channel; - struct il_ht_config *ht_conf = &il->current_ht_config; - - struct il_rxon_context *ctx = &il->ctx; - u16 ch; - - D_MAC80211("enter\n"); - - mutex_lock(&il->mutex); - - if (il_is_rfkill(il)) - goto out; - - if (test_bit(STATUS_EXIT_PENDING, &il->status) || - test_bit(STATUS_SCANNING, &il->status) || - test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status)) - goto out; - - if (!il_is_associated_ctx(ctx)) - goto out; - - if (!il->cfg->ops->lib->set_channel_switch) - goto out; - - ch = channel->hw_value; - if (le16_to_cpu(ctx->active.channel) == ch) - goto out; - - ch_info = il_get_channel_info(il, channel->band, ch); - if (!il_is_channel_valid(ch_info)) { - D_MAC80211("invalid channel\n"); - goto out; - } - - spin_lock_irq(&il->lock); - - il->current_ht_config.smps = conf->smps_mode; - - /* Configure HT40 channels */ - ctx->ht.enabled = conf_is_ht(conf); - if (ctx->ht.enabled) { - if (conf_is_ht40_minus(conf)) { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_BELOW; - ctx->ht.is_40mhz = true; - } else if (conf_is_ht40_plus(conf)) { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_ABOVE; - ctx->ht.is_40mhz = true; - } else { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_NONE; - ctx->ht.is_40mhz = false; - } - } else - ctx->ht.is_40mhz = false; - - if ((le16_to_cpu(ctx->staging.channel) != ch)) - ctx->staging.flags = 0; - - il_set_rxon_channel(il, channel, ctx); - il_set_rxon_ht(il, ht_conf); - il_set_flags_for_band(il, ctx, channel->band, ctx->vif); - - spin_unlock_irq(&il->lock); - - il_set_rate(il); - /* - * at this point, staging_rxon has the - * configuration for channel switch - */ - set_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status); - il->switch_channel = cpu_to_le16(ch); - if (il->cfg->ops->lib->set_channel_switch(il, ch_switch)) { - clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status); - il->switch_channel = 0; - ieee80211_chswitch_done(ctx->vif, false); - } - -out: - mutex_unlock(&il->mutex); - D_MAC80211("leave\n"); -} - -void il4965_configure_filter(struct ieee80211_hw *hw, - unsigned int changed_flags, - unsigned int *total_flags, - u64 multicast) -{ - struct il_priv *il = hw->priv; - __le32 filter_or = 0, filter_nand = 0; - -#define CHK(test, flag) do { \ - if (*total_flags & (test)) \ - filter_or |= (flag); \ - else \ - filter_nand |= (flag); \ - } while (0) - - D_MAC80211("Enter: changed: 0x%x, total: 0x%x\n", - changed_flags, *total_flags); - - CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); - /* Setting _just_ RXON_FILTER_CTL2HOST_MSK causes FH errors */ - CHK(FIF_CONTROL, RXON_FILTER_CTL2HOST_MSK | RXON_FILTER_PROMISC_MSK); - CHK(FIF_BCN_PRBRESP_PROMISC, RXON_FILTER_BCON_AWARE_MSK); - -#undef CHK - - mutex_lock(&il->mutex); - - il->ctx.staging.filter_flags &= ~filter_nand; - il->ctx.staging.filter_flags |= filter_or; - - /* - * Not committing directly because hardware can perform a scan, - * but we'll eventually commit the filter flags change anyway. - */ - - mutex_unlock(&il->mutex); - - /* - * Receiving all multicast frames is always enabled by the - * default flags setup in il_connection_init_rx_config() - * since we currently do not support programming multicast - * filters into the device. - */ - *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | - FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; -} - -/***************************************************************************** - * - * driver setup and teardown - * - *****************************************************************************/ - -static void il4965_bg_txpower_work(struct work_struct *work) -{ - struct il_priv *il = container_of(work, struct il_priv, - txpower_work); - - mutex_lock(&il->mutex); - - /* If a scan happened to start before we got here - * then just return; the stats notification will - * kick off another scheduled work to compensate for - * any temperature delta we missed here. */ - if (test_bit(STATUS_EXIT_PENDING, &il->status) || - test_bit(STATUS_SCANNING, &il->status)) - goto out; - - /* Regardless of if we are associated, we must reconfigure the - * TX power since frames can be sent on non-radar channels while - * not associated */ - il->cfg->ops->lib->send_tx_power(il); - - /* Update last_temperature to keep is_calib_needed from running - * when it isn't needed... */ - il->last_temperature = il->temperature; -out: - mutex_unlock(&il->mutex); -} - -static void il4965_setup_deferred_work(struct il_priv *il) -{ - il->workqueue = create_singlethread_workqueue(DRV_NAME); - - init_waitqueue_head(&il->wait_command_queue); - - INIT_WORK(&il->restart, il4965_bg_restart); - INIT_WORK(&il->rx_replenish, il4965_bg_rx_replenish); - INIT_WORK(&il->run_time_calib_work, il4965_bg_run_time_calib_work); - INIT_DELAYED_WORK(&il->init_alive_start, il4965_bg_init_alive_start); - INIT_DELAYED_WORK(&il->alive_start, il4965_bg_alive_start); - - il_setup_scan_deferred_work(il); - - INIT_WORK(&il->txpower_work, il4965_bg_txpower_work); - - init_timer(&il->stats_periodic); - il->stats_periodic.data = (unsigned long)il; - il->stats_periodic.function = il4965_bg_stats_periodic; - - init_timer(&il->watchdog); - il->watchdog.data = (unsigned long)il; - il->watchdog.function = il_bg_watchdog; - - tasklet_init(&il->irq_tasklet, (void (*)(unsigned long)) - il4965_irq_tasklet, (unsigned long)il); -} - -static void il4965_cancel_deferred_work(struct il_priv *il) -{ - cancel_work_sync(&il->txpower_work); - cancel_delayed_work_sync(&il->init_alive_start); - cancel_delayed_work(&il->alive_start); - cancel_work_sync(&il->run_time_calib_work); - - il_cancel_scan_deferred_work(il); - - del_timer_sync(&il->stats_periodic); -} - -static void il4965_init_hw_rates(struct il_priv *il, - struct ieee80211_rate *rates) -{ - int i; - - for (i = 0; i < RATE_COUNT_LEGACY; i++) { - rates[i].bitrate = il_rates[i].ieee * 5; - rates[i].hw_value = i; /* Rate scaling will work on idxes */ - rates[i].hw_value_short = i; - rates[i].flags = 0; - if ((i >= IL_FIRST_CCK_RATE) && (i <= IL_LAST_CCK_RATE)) { - /* - * If CCK != 1M then set short preamble rate flag. - */ - rates[i].flags |= - (il_rates[i].plcp == RATE_1M_PLCP) ? - 0 : IEEE80211_RATE_SHORT_PREAMBLE; - } - } -} -/* - * Acquire il->lock before calling this function ! - */ -void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx) -{ - il_wr(il, HBUS_TARG_WRPTR, - (idx & 0xff) | (txq_id << 8)); - il_wr_prph(il, IL49_SCD_QUEUE_RDPTR(txq_id), idx); -} - -void il4965_tx_queue_set_status(struct il_priv *il, - struct il_tx_queue *txq, - int tx_fifo_id, int scd_retry) -{ - int txq_id = txq->q.id; - - /* Find out whether to activate Tx queue */ - int active = test_bit(txq_id, &il->txq_ctx_active_msk) ? 1 : 0; - - /* Set up and activate */ - il_wr_prph(il, IL49_SCD_QUEUE_STATUS_BITS(txq_id), - (active << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | - (tx_fifo_id << IL49_SCD_QUEUE_STTS_REG_POS_TXF) | - (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_WSL) | - (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK) | - IL49_SCD_QUEUE_STTS_REG_MSK); - - txq->sched_retry = scd_retry; - - D_INFO("%s %s Queue %d on AC %d\n", - active ? "Activate" : "Deactivate", - scd_retry ? "BA" : "AC", txq_id, tx_fifo_id); -} - - -static int il4965_init_drv(struct il_priv *il) -{ - int ret; - - spin_lock_init(&il->sta_lock); - spin_lock_init(&il->hcmd_lock); - - INIT_LIST_HEAD(&il->free_frames); - - mutex_init(&il->mutex); - - il->ieee_channels = NULL; - il->ieee_rates = NULL; - il->band = IEEE80211_BAND_2GHZ; - - il->iw_mode = NL80211_IFTYPE_STATION; - il->current_ht_config.smps = IEEE80211_SMPS_STATIC; - il->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; - - /* initialize force reset */ - il->force_reset.reset_duration = IL_DELAY_NEXT_FORCE_FW_RELOAD; - - /* Choose which receivers/antennas to use */ - if (il->cfg->ops->hcmd->set_rxon_chain) - il->cfg->ops->hcmd->set_rxon_chain(il, - &il->ctx); - - il_init_scan_params(il); - - ret = il_init_channel_map(il); - if (ret) { - IL_ERR("initializing regulatory failed: %d\n", ret); - goto err; - } - - ret = il_init_geos(il); - if (ret) { - IL_ERR("initializing geos failed: %d\n", ret); - goto err_free_channel_map; - } - il4965_init_hw_rates(il, il->ieee_rates); - - return 0; - -err_free_channel_map: - il_free_channel_map(il); -err: - return ret; -} - -static void il4965_uninit_drv(struct il_priv *il) -{ - il4965_calib_free_results(il); - il_free_geos(il); - il_free_channel_map(il); - kfree(il->scan_cmd); -} - -static void il4965_hw_detect(struct il_priv *il) -{ - il->hw_rev = _il_rd(il, CSR_HW_REV); - il->hw_wa_rev = _il_rd(il, CSR_HW_REV_WA_REG); - il->rev_id = il->pci_dev->revision; - D_INFO("HW Revision ID = 0x%X\n", il->rev_id); -} - -static int il4965_set_hw_params(struct il_priv *il) -{ - il->hw_params.max_rxq_size = RX_QUEUE_SIZE; - il->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; - if (il->cfg->mod_params->amsdu_size_8K) - il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_8K); - else - il->hw_params.rx_page_order = get_order(IL_RX_BUF_SIZE_4K); - - il->hw_params.max_beacon_itrvl = IL_MAX_UCODE_BEACON_INTERVAL; - - if (il->cfg->mod_params->disable_11n) - il->cfg->sku &= ~IL_SKU_N; - - /* Device-specific setup */ - return il->cfg->ops->lib->set_hw_params(il); -} - -static const u8 il4965_bss_ac_to_fifo[] = { - IL_TX_FIFO_VO, - IL_TX_FIFO_VI, - IL_TX_FIFO_BE, - IL_TX_FIFO_BK, -}; - -static const u8 il4965_bss_ac_to_queue[] = { - 0, 1, 2, 3, -}; - -static int -il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) -{ - int err = 0; - struct il_priv *il; - struct ieee80211_hw *hw; - struct il_cfg *cfg = (struct il_cfg *)(ent->driver_data); - unsigned long flags; - u16 pci_cmd; - - /************************ - * 1. Allocating HW data - ************************/ - - hw = il_alloc_all(cfg); - if (!hw) { - err = -ENOMEM; - goto out; - } - il = hw->priv; - /* At this point both hw and il are allocated. */ - - il->ctx.ctxid = 0; - - il->ctx.always_active = true; - il->ctx.is_active = true; - il->ctx.rxon_cmd = REPLY_RXON; - il->ctx.rxon_timing_cmd = REPLY_RXON_TIMING; - il->ctx.rxon_assoc_cmd = REPLY_RXON_ASSOC; - il->ctx.qos_cmd = REPLY_QOS_PARAM; - il->ctx.ap_sta_id = IL_AP_ID; - il->ctx.wep_key_cmd = REPLY_WEPKEY; - il->ctx.ac_to_fifo = il4965_bss_ac_to_fifo; - il->ctx.ac_to_queue = il4965_bss_ac_to_queue; - il->ctx.exclusive_interface_modes = - BIT(NL80211_IFTYPE_ADHOC); - il->ctx.interface_modes = - BIT(NL80211_IFTYPE_STATION); - il->ctx.ap_devtype = RXON_DEV_TYPE_AP; - il->ctx.ibss_devtype = RXON_DEV_TYPE_IBSS; - il->ctx.station_devtype = RXON_DEV_TYPE_ESS; - il->ctx.unused_devtype = RXON_DEV_TYPE_ESS; - - SET_IEEE80211_DEV(hw, &pdev->dev); - - D_INFO("*** LOAD DRIVER ***\n"); - il->cfg = cfg; - il->pci_dev = pdev; - il->inta_mask = CSR_INI_SET_MASK; - - if (il_alloc_traffic_mem(il)) - IL_ERR("Not enough memory to generate traffic log\n"); - - /************************** - * 2. Initializing PCI bus - **************************/ - pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | - PCIE_LINK_STATE_CLKPM); - - if (pci_enable_device(pdev)) { - err = -ENODEV; - goto out_ieee80211_free_hw; - } - - pci_set_master(pdev); - - err = pci_set_dma_mask(pdev, DMA_BIT_MASK(36)); - if (!err) - err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(36)); - if (err) { - err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); - if (!err) - err = pci_set_consistent_dma_mask(pdev, - DMA_BIT_MASK(32)); - /* both attempts failed: */ - if (err) { - IL_WARN("No suitable DMA available.\n"); - goto out_pci_disable_device; - } - } - - err = pci_request_regions(pdev, DRV_NAME); - if (err) - goto out_pci_disable_device; - - pci_set_drvdata(pdev, il); - - - /*********************** - * 3. Read REV register - ***********************/ - il->hw_base = pci_iomap(pdev, 0, 0); - if (!il->hw_base) { - err = -ENODEV; - goto out_pci_release_regions; - } - - D_INFO("pci_resource_len = 0x%08llx\n", - (unsigned long long) pci_resource_len(pdev, 0)); - D_INFO("pci_resource_base = %p\n", il->hw_base); - - /* these spin locks will be used in apm_ops.init and EEPROM access - * we should init now - */ - spin_lock_init(&il->reg_lock); - spin_lock_init(&il->lock); - - /* - * stop and reset the on-board processor just in case it is in a - * strange state ... like being left stranded by a primary kernel - * and this is now the kdump kernel trying to start up - */ - _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); - - il4965_hw_detect(il); - IL_INFO("Detected %s, REV=0x%X\n", - il->cfg->name, il->hw_rev); - - /* We disable the RETRY_TIMEOUT register (0x41) to keep - * PCI Tx retries from interfering with C3 CPU state */ - pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); - - il4965_prepare_card_hw(il); - if (!il->hw_ready) { - IL_WARN("Failed, HW not ready\n"); - goto out_iounmap; - } - - /***************** - * 4. Read EEPROM - *****************/ - /* Read the EEPROM */ - err = il_eeprom_init(il); - if (err) { - IL_ERR("Unable to init EEPROM\n"); - goto out_iounmap; - } - err = il4965_eeprom_check_version(il); - if (err) - goto out_free_eeprom; - - if (err) - goto out_free_eeprom; - - /* extract MAC Address */ - il4965_eeprom_get_mac(il, il->addresses[0].addr); - D_INFO("MAC address: %pM\n", il->addresses[0].addr); - il->hw->wiphy->addresses = il->addresses; - il->hw->wiphy->n_addresses = 1; - - /************************ - * 5. Setup HW constants - ************************/ - if (il4965_set_hw_params(il)) { - IL_ERR("failed to set hw parameters\n"); - goto out_free_eeprom; - } - - /******************* - * 6. Setup il - *******************/ - - err = il4965_init_drv(il); - if (err) - goto out_free_eeprom; - /* At this point both hw and il are initialized. */ - - /******************** - * 7. Setup services - ********************/ - spin_lock_irqsave(&il->lock, flags); - il_disable_interrupts(il); - spin_unlock_irqrestore(&il->lock, flags); - - pci_enable_msi(il->pci_dev); - - err = request_irq(il->pci_dev->irq, il_isr, - IRQF_SHARED, DRV_NAME, il); - if (err) { - IL_ERR("Error allocating IRQ %d\n", il->pci_dev->irq); - goto out_disable_msi; - } - - il4965_setup_deferred_work(il); - il4965_setup_rx_handlers(il); - - /********************************************* - * 8. Enable interrupts and read RFKILL state - *********************************************/ - - /* enable rfkill interrupt: hw bug w/a */ - pci_read_config_word(il->pci_dev, PCI_COMMAND, &pci_cmd); - if (pci_cmd & PCI_COMMAND_INTX_DISABLE) { - pci_cmd &= ~PCI_COMMAND_INTX_DISABLE; - pci_write_config_word(il->pci_dev, PCI_COMMAND, pci_cmd); - } - - il_enable_rfkill_int(il); - - /* If platform's RF_KILL switch is NOT set to KILL */ - if (_il_rd(il, CSR_GP_CNTRL) & - CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) - clear_bit(STATUS_RF_KILL_HW, &il->status); - else - set_bit(STATUS_RF_KILL_HW, &il->status); - - wiphy_rfkill_set_hw_state(il->hw->wiphy, - test_bit(STATUS_RF_KILL_HW, &il->status)); - - il_power_initialize(il); - - init_completion(&il->_4965.firmware_loading_complete); - - err = il4965_request_firmware(il, true); - if (err) - goto out_destroy_workqueue; - - return 0; - - out_destroy_workqueue: - destroy_workqueue(il->workqueue); - il->workqueue = NULL; - free_irq(il->pci_dev->irq, il); - out_disable_msi: - pci_disable_msi(il->pci_dev); - il4965_uninit_drv(il); - out_free_eeprom: - il_eeprom_free(il); - out_iounmap: - pci_iounmap(pdev, il->hw_base); - out_pci_release_regions: - pci_set_drvdata(pdev, NULL); - pci_release_regions(pdev); - out_pci_disable_device: - pci_disable_device(pdev); - out_ieee80211_free_hw: - il_free_traffic_mem(il); - ieee80211_free_hw(il->hw); - out: - return err; -} - -static void __devexit il4965_pci_remove(struct pci_dev *pdev) -{ - struct il_priv *il = pci_get_drvdata(pdev); - unsigned long flags; - - if (!il) - return; - - wait_for_completion(&il->_4965.firmware_loading_complete); - - D_INFO("*** UNLOAD DRIVER ***\n"); - - il_dbgfs_unregister(il); - sysfs_remove_group(&pdev->dev.kobj, &il_attribute_group); - - /* ieee80211_unregister_hw call wil cause il_mac_stop to - * to be called and il4965_down since we are removing the device - * we need to set STATUS_EXIT_PENDING bit. - */ - set_bit(STATUS_EXIT_PENDING, &il->status); - - il_leds_exit(il); - - if (il->mac80211_registered) { - ieee80211_unregister_hw(il->hw); - il->mac80211_registered = 0; - } else { - il4965_down(il); - } - - /* - * Make sure device is reset to low power before unloading driver. - * This may be redundant with il4965_down(), but there are paths to - * run il4965_down() without calling apm_ops.stop(), and there are - * paths to avoid running il4965_down() at all before leaving driver. - * This (inexpensive) call *makes sure* device is reset. - */ - il_apm_stop(il); - - /* make sure we flush any pending irq or - * tasklet for the driver - */ - spin_lock_irqsave(&il->lock, flags); - il_disable_interrupts(il); - spin_unlock_irqrestore(&il->lock, flags); - - il4965_synchronize_irq(il); - - il4965_dealloc_ucode_pci(il); - - if (il->rxq.bd) - il4965_rx_queue_free(il, &il->rxq); - il4965_hw_txq_ctx_free(il); - - il_eeprom_free(il); - - - /*netif_stop_queue(dev); */ - flush_workqueue(il->workqueue); - - /* ieee80211_unregister_hw calls il_mac_stop, which flushes - * il->workqueue... so we can't take down the workqueue - * until now... */ - destroy_workqueue(il->workqueue); - il->workqueue = NULL; - il_free_traffic_mem(il); - - free_irq(il->pci_dev->irq, il); - pci_disable_msi(il->pci_dev); - pci_iounmap(pdev, il->hw_base); - pci_release_regions(pdev); - pci_disable_device(pdev); - pci_set_drvdata(pdev, NULL); - - il4965_uninit_drv(il); - - dev_kfree_skb(il->beacon_skb); - - ieee80211_free_hw(il->hw); -} - -/* - * Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask - * must be called under il->lock and mac access - */ -void il4965_txq_set_sched(struct il_priv *il, u32 mask) -{ - il_wr_prph(il, IL49_SCD_TXFACT, mask); -} - -/***************************************************************************** - * - * driver and module entry point - * - *****************************************************************************/ - -/* Hardware specific file defines the PCI IDs table for that hardware module */ -static DEFINE_PCI_DEVICE_TABLE(il4965_hw_card_ids) = { - {IL_PCI_DEVICE(0x4229, PCI_ANY_ID, il4965_cfg)}, - {IL_PCI_DEVICE(0x4230, PCI_ANY_ID, il4965_cfg)}, - {0} -}; -MODULE_DEVICE_TABLE(pci, il4965_hw_card_ids); - -static struct pci_driver il4965_driver = { - .name = DRV_NAME, - .id_table = il4965_hw_card_ids, - .probe = il4965_pci_probe, - .remove = __devexit_p(il4965_pci_remove), - .driver.pm = IL_LEGACY_PM_OPS, -}; - -static int __init il4965_init(void) -{ - - int ret; - pr_info(DRV_DESCRIPTION ", " DRV_VERSION "\n"); - pr_info(DRV_COPYRIGHT "\n"); - - ret = il4965_rate_control_register(); - if (ret) { - pr_err("Unable to register rate control algorithm: %d\n", ret); - return ret; - } - - ret = pci_register_driver(&il4965_driver); - if (ret) { - pr_err("Unable to initialize PCI module\n"); - goto error_register; - } - - return ret; - -error_register: - il4965_rate_control_unregister(); - return ret; -} - -static void __exit il4965_exit(void) -{ - pci_unregister_driver(&il4965_driver); - il4965_rate_control_unregister(); -} - -module_exit(il4965_exit); -module_init(il4965_init); - -#ifdef CONFIG_IWLEGACY_DEBUG -module_param_named(debug, il_debug_level, uint, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(debug, "debug output mask"); -#endif - -module_param_named(swcrypto, il4965_mod_params.sw_crypto, int, S_IRUGO); -MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])"); -module_param_named(queues_num, il4965_mod_params.num_of_queues, int, S_IRUGO); -MODULE_PARM_DESC(queues_num, "number of hw queues."); -module_param_named(11n_disable, il4965_mod_params.disable_11n, int, S_IRUGO); -MODULE_PARM_DESC(11n_disable, "disable 11n functionality"); -module_param_named(amsdu_size_8K, il4965_mod_params.amsdu_size_8K, - int, S_IRUGO); -MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size"); -module_param_named(fw_restart, il4965_mod_params.restart_fw, int, S_IRUGO); -MODULE_PARM_DESC(fw_restart, "restart firmware in case of error"); -- cgit v1.2.3 From fc19cbde0c38c24f2d473f9095fbd5772883ec59 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 29 Aug 2011 16:59:15 +0200 Subject: iwlegacy: merge iwl-4965-led.c into 4965.c Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/4965-mac.c | 1 - drivers/net/wireless/iwlegacy/4965.c | 31 +++++++++++- drivers/net/wireless/iwlegacy/Makefile | 2 +- drivers/net/wireless/iwlegacy/iwl-4965-led.c | 73 ---------------------------- drivers/net/wireless/iwlegacy/iwl-4965-led.h | 33 ------------- drivers/net/wireless/iwlegacy/iwl-4965.h | 2 + 6 files changed, 33 insertions(+), 109 deletions(-) delete mode 100644 drivers/net/wireless/iwlegacy/iwl-4965-led.c delete mode 100644 drivers/net/wireless/iwlegacy/iwl-4965-led.h (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index df86431d3bae..4a8ad8df828d 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -58,7 +58,6 @@ #include "iwl-sta.h" #include "iwl-4965-calib.h" #include "iwl-4965.h" -#include "iwl-4965-led.h" /****************************************************************************** diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index bdfb3a616fdc..8f68b94fd74b 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -44,10 +44,39 @@ #include "iwl-helpers.h" #include "iwl-4965-calib.h" #include "iwl-sta.h" -#include "iwl-4965-led.h" #include "iwl-4965.h" #include "iwl-4965-debugfs.h" +/* Send led command */ +static int +il4965_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd) +{ + struct il_host_cmd cmd = { + .id = REPLY_LEDS_CMD, + .len = sizeof(struct il_led_cmd), + .data = led_cmd, + .flags = CMD_ASYNC, + .callback = NULL, + }; + u32 reg; + + reg = _il_rd(il, CSR_LED_REG); + if (reg != (reg & CSR_LED_BSM_CTRL_MSK)) + _il_wr(il, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK); + + return il_send_cmd(il, &cmd); +} + +/* Set led register off */ +void il4965_led_enable(struct il_priv *il) +{ + _il_wr(il, CSR_LED_REG, CSR_LED_REG_TRUN_ON); +} + +const struct il_led_ops il4965_led_ops = { + .cmd = il4965_send_led_cmd, +}; + static int il4965_send_tx_power(struct il_priv *il); static int il4965_hw_get_temperature(struct il_priv *il); diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index cd8ac73d45bf..b909352484a6 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -8,7 +8,7 @@ iwl-legacy-objs += $(iwl-legacy-m) # 4965 obj-$(CONFIG_IWL4965) += iwl4965.o -iwl4965-objs := 4965.o 4965-mac.o iwl-4965-rs.o iwl-4965-led.o +iwl4965-objs := 4965.o 4965-mac.o iwl-4965-rs.o iwl4965-objs += iwl-4965-ucode.o iwl-4965-tx.o iwl4965-objs += iwl-4965-lib.o iwl-4965-rx.o iwl-4965-calib.o iwl4965-objs += iwl-4965-sta.o iwl-4965-eeprom.o diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-led.c b/drivers/net/wireless/iwlegacy/iwl-4965-led.c deleted file mode 100644 index 48541577202a..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-led.c +++ /dev/null @@ -1,73 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "iwl-commands.h" -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-io.h" -#include "iwl-4965-led.h" - -/* Send led command */ -static int -il4965_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd) -{ - struct il_host_cmd cmd = { - .id = REPLY_LEDS_CMD, - .len = sizeof(struct il_led_cmd), - .data = led_cmd, - .flags = CMD_ASYNC, - .callback = NULL, - }; - u32 reg; - - reg = _il_rd(il, CSR_LED_REG); - if (reg != (reg & CSR_LED_BSM_CTRL_MSK)) - _il_wr(il, CSR_LED_REG, reg & CSR_LED_BSM_CTRL_MSK); - - return il_send_cmd(il, &cmd); -} - -/* Set led register off */ -void il4965_led_enable(struct il_priv *il) -{ - _il_wr(il, CSR_LED_REG, CSR_LED_REG_TRUN_ON); -} - -const struct il_led_ops il4965_led_ops = { - .cmd = il4965_send_led_cmd, -}; diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-led.h b/drivers/net/wireless/iwlegacy/iwl-4965-led.h deleted file mode 100644 index e804fe16caef..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-led.h +++ /dev/null @@ -1,33 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#ifndef __il_4965_led_h__ -#define __il_4965_led_h__ - -extern const struct il_led_ops il4965_led_ops; -void il4965_led_enable(struct il_priv *il); - -#endif /* __il_4965_led_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.h b/drivers/net/wireless/iwlegacy/iwl-4965.h index 8076bbe28cff..c0bb45b012d2 100644 --- a/drivers/net/wireless/iwlegacy/iwl-4965.h +++ b/drivers/net/wireless/iwlegacy/iwl-4965.h @@ -279,4 +279,6 @@ int il4965_mac_sta_add(struct ieee80211_hw *hw, void il4965_mac_channel_switch(struct ieee80211_hw *hw, struct ieee80211_channel_switch *ch_switch); +void il4965_led_enable(struct il_priv *il); + #endif /* __il_4965_h__ */ -- cgit v1.2.3 From ecce1f09e847351d18e503e533000f781cac1d41 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 29 Aug 2011 17:05:28 +0200 Subject: iwlegacy: merge iwl-3945-led.c into 3945.c Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/3945.c | 20 ++++++++- drivers/net/wireless/iwlegacy/Makefile | 2 +- drivers/net/wireless/iwlegacy/iwl-3945-led.c | 63 ---------------------------- drivers/net/wireless/iwlegacy/iwl-3945-led.h | 32 -------------- 4 files changed, 20 insertions(+), 97 deletions(-) delete mode 100644 drivers/net/wireless/iwlegacy/iwl-3945-led.c delete mode 100644 drivers/net/wireless/iwlegacy/iwl-3945-led.h (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index b6abf3473fac..b41e60b40264 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -48,9 +48,27 @@ #include "iwl-core.h" #include "iwl-helpers.h" #include "iwl-led.h" -#include "iwl-3945-led.h" #include "iwl-3945-debugfs.h" +/* Send led command */ +static int il3945_send_led_cmd(struct il_priv *il, + struct il_led_cmd *led_cmd) +{ + struct il_host_cmd cmd = { + .id = REPLY_LEDS_CMD, + .len = sizeof(struct il_led_cmd), + .data = led_cmd, + .flags = CMD_ASYNC, + .callback = NULL, + }; + + return il_send_cmd(il, &cmd); +} + +const struct il_led_ops il3945_led_ops = { + .cmd = il3945_send_led_cmd, +}; + #define IL_DECLARE_RATE_INFO(r, ip, in, rp, rn, pp, np) \ [RATE_##r##M_IDX] = { RATE_##r##M_PLCP, \ RATE_##r##M_IEEE, \ diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index b909352484a6..da83c69458bf 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -16,7 +16,7 @@ iwl4965-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-4965-debugfs.o # 3945 obj-$(CONFIG_IWL3945) += iwl3945.o -iwl3945-objs := 3945-mac.o 3945.o iwl-3945-rs.o iwl-3945-led.o +iwl3945-objs := 3945-mac.o 3945.o iwl-3945-rs.o iwl3945-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-3945-debugfs.o ccflags-y += -D__CHECK_ENDIAN__ diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-led.c b/drivers/net/wireless/iwlegacy/iwl-3945-led.c deleted file mode 100644 index 53ec4637015e..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-3945-led.c +++ /dev/null @@ -1,63 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "iwl-commands.h" -#include "iwl-3945.h" -#include "iwl-core.h" -#include "iwl-dev.h" -#include "iwl-3945-led.h" - - -/* Send led command */ -static int il3945_send_led_cmd(struct il_priv *il, - struct il_led_cmd *led_cmd) -{ - struct il_host_cmd cmd = { - .id = REPLY_LEDS_CMD, - .len = sizeof(struct il_led_cmd), - .data = led_cmd, - .flags = CMD_ASYNC, - .callback = NULL, - }; - - return il_send_cmd(il, &cmd); -} - -const struct il_led_ops il3945_led_ops = { - .cmd = il3945_send_led_cmd, -}; diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-led.h b/drivers/net/wireless/iwlegacy/iwl-3945-led.h deleted file mode 100644 index 369c72d5cd68..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-3945-led.h +++ /dev/null @@ -1,32 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#ifndef __il_3945_led_h__ -#define __il_3945_led_h__ - -extern const struct il_led_ops il3945_led_ops; - -#endif /* __il_3945_led_h__ */ -- cgit v1.2.3 From 56e7a8cca0fd9e096acd2233f0e9f95df6423071 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 30 Aug 2011 12:45:25 +0200 Subject: iwlegacy: merge iwl-4965-eeprom.c into 4965.c Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/4965.c | 74 ++++++++++++ drivers/net/wireless/iwlegacy/Makefile | 2 +- drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c | 150 ------------------------ 3 files changed, 75 insertions(+), 151 deletions(-) delete mode 100644 drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 8f68b94fd74b..a4b42cc4c4c7 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -47,6 +47,80 @@ #include "iwl-4965.h" #include "iwl-4965-debugfs.h" +/****************************************************************************** + * + * EEPROM related functions + * +******************************************************************************/ + +/* + * The device's EEPROM semaphore prevents conflicts between driver and uCode + * when accessing the EEPROM; each access is a series of pulses to/from the + * EEPROM chip, not a single event, so even reads could conflict if they + * weren't arbitrated by the semaphore. + */ +int il4965_eeprom_acquire_semaphore(struct il_priv *il) +{ + u16 count; + int ret; + + for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) { + /* Request semaphore */ + il_set_bit(il, CSR_HW_IF_CONFIG_REG, + CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); + + /* See if we got it */ + ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, + CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, + CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, + EEPROM_SEM_TIMEOUT); + if (ret >= 0) + return ret; + } + + return ret; +} + +void il4965_eeprom_release_semaphore(struct il_priv *il) +{ + il_clear_bit(il, CSR_HW_IF_CONFIG_REG, + CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); + +} + +int il4965_eeprom_check_version(struct il_priv *il) +{ + u16 eeprom_ver; + u16 calib_ver; + + eeprom_ver = il_eeprom_query16(il, EEPROM_VERSION); + calib_ver = il_eeprom_query16(il, + EEPROM_4965_CALIB_VERSION_OFFSET); + + if (eeprom_ver < il->cfg->eeprom_ver || + calib_ver < il->cfg->eeprom_calib_ver) + goto err; + + IL_INFO("device EEPROM VER=0x%x, CALIB=0x%x\n", + eeprom_ver, calib_ver); + + return 0; +err: + IL_ERR("Unsupported (too old) EEPROM VER=0x%x < 0x%x " + "CALIB=0x%x < 0x%x\n", + eeprom_ver, il->cfg->eeprom_ver, + calib_ver, il->cfg->eeprom_calib_ver); + return -EINVAL; + +} + +void il4965_eeprom_get_mac(const struct il_priv *il, u8 *mac) +{ + const u8 *addr = il_eeprom_query_addr(il, + EEPROM_MAC_ADDRESS); + memcpy(mac, addr, ETH_ALEN); +} + /* Send led command */ static int il4965_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd) diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index da83c69458bf..2776845be8d9 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -11,7 +11,7 @@ obj-$(CONFIG_IWL4965) += iwl4965.o iwl4965-objs := 4965.o 4965-mac.o iwl-4965-rs.o iwl4965-objs += iwl-4965-ucode.o iwl-4965-tx.o iwl4965-objs += iwl-4965-lib.o iwl-4965-rx.o iwl-4965-calib.o -iwl4965-objs += iwl-4965-sta.o iwl-4965-eeprom.o +iwl4965-objs += iwl-4965-sta.o iwl4965-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-4965-debugfs.o # 3945 diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c deleted file mode 100644 index a5192570d093..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-eeprom.c +++ /dev/null @@ -1,150 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - - -#include -#include -#include -#include - -#include - -#include "iwl-commands.h" -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-debug.h" -#include "iwl-4965.h" -#include "iwl-io.h" - -/****************************************************************************** - * - * EEPROM related functions - * -******************************************************************************/ - -/* - * The device's EEPROM semaphore prevents conflicts between driver and uCode - * when accessing the EEPROM; each access is a series of pulses to/from the - * EEPROM chip, not a single event, so even reads could conflict if they - * weren't arbitrated by the semaphore. - */ -int il4965_eeprom_acquire_semaphore(struct il_priv *il) -{ - u16 count; - int ret; - - for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) { - /* Request semaphore */ - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); - - /* See if we got it */ - ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, - CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, - EEPROM_SEM_TIMEOUT); - if (ret >= 0) - return ret; - } - - return ret; -} - -void il4965_eeprom_release_semaphore(struct il_priv *il) -{ - il_clear_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); - -} - -int il4965_eeprom_check_version(struct il_priv *il) -{ - u16 eeprom_ver; - u16 calib_ver; - - eeprom_ver = il_eeprom_query16(il, EEPROM_VERSION); - calib_ver = il_eeprom_query16(il, - EEPROM_4965_CALIB_VERSION_OFFSET); - - if (eeprom_ver < il->cfg->eeprom_ver || - calib_ver < il->cfg->eeprom_calib_ver) - goto err; - - IL_INFO("device EEPROM VER=0x%x, CALIB=0x%x\n", - eeprom_ver, calib_ver); - - return 0; -err: - IL_ERR("Unsupported (too old) EEPROM VER=0x%x < 0x%x " - "CALIB=0x%x < 0x%x\n", - eeprom_ver, il->cfg->eeprom_ver, - calib_ver, il->cfg->eeprom_calib_ver); - return -EINVAL; - -} - -void il4965_eeprom_get_mac(const struct il_priv *il, u8 *mac) -{ - const u8 *addr = il_eeprom_query_addr(il, - EEPROM_MAC_ADDRESS); - memcpy(mac, addr, ETH_ALEN); -} -- cgit v1.2.3 From 862d32e6db6183e5cb67fe465818578556196a94 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 30 Aug 2011 12:50:25 +0200 Subject: iwlegacy: merge iwl-4965-ucode.c into 4965.c Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/4965.c | 125 +++++++++++++++++++ drivers/net/wireless/iwlegacy/Makefile | 2 +- drivers/net/wireless/iwlegacy/iwl-4965-ucode.c | 166 ------------------------- 3 files changed, 126 insertions(+), 167 deletions(-) delete mode 100644 drivers/net/wireless/iwlegacy/iwl-4965-ucode.c (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index a4b42cc4c4c7..752564d36c98 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -47,6 +47,131 @@ #include "iwl-4965.h" #include "iwl-4965-debugfs.h" +#define IL_AC_UNSET -1 + +/** + * il_verify_inst_sparse - verify runtime uCode image in card vs. host, + * using sample data 100 bytes apart. If these sample points are good, + * it's a pretty good bet that everything between them is good, too. + */ +static int +il4965_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) +{ + u32 val; + int ret = 0; + u32 errcnt = 0; + u32 i; + + D_INFO("ucode inst image size is %u\n", len); + + for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { + /* read data comes through single port, auto-incr addr */ + /* NOTE: Use the debugless read so we don't flood kernel log + * if IL_DL_IO is set */ + il_wr(il, HBUS_TARG_MEM_RADDR, + i + IL4965_RTC_INST_LOWER_BOUND); + val = _il_rd(il, HBUS_TARG_MEM_RDAT); + if (val != le32_to_cpu(*image)) { + ret = -EIO; + errcnt++; + if (errcnt >= 3) + break; + } + } + + return ret; +} + +/** + * il4965_verify_inst_full - verify runtime uCode image in card vs. host, + * looking at all data. + */ +static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, + u32 len) +{ + u32 val; + u32 save_len = len; + int ret = 0; + u32 errcnt; + + D_INFO("ucode inst image size is %u\n", len); + + il_wr(il, HBUS_TARG_MEM_RADDR, + IL4965_RTC_INST_LOWER_BOUND); + + errcnt = 0; + for (; len > 0; len -= sizeof(u32), image++) { + /* read data comes through single port, auto-incr addr */ + /* NOTE: Use the debugless read so we don't flood kernel log + * if IL_DL_IO is set */ + val = _il_rd(il, HBUS_TARG_MEM_RDAT); + if (val != le32_to_cpu(*image)) { + IL_ERR("uCode INST section is invalid at " + "offset 0x%x, is 0x%x, s/b 0x%x\n", + save_len - len, val, le32_to_cpu(*image)); + ret = -EIO; + errcnt++; + if (errcnt >= 20) + break; + } + } + + if (!errcnt) + D_INFO( + "ucode image in INSTRUCTION memory is good\n"); + + return ret; +} + +/** + * il4965_verify_ucode - determine which instruction image is in SRAM, + * and verify its contents + */ +int il4965_verify_ucode(struct il_priv *il) +{ + __le32 *image; + u32 len; + int ret; + + /* Try bootstrap */ + image = (__le32 *)il->ucode_boot.v_addr; + len = il->ucode_boot.len; + ret = il4965_verify_inst_sparse(il, image, len); + if (!ret) { + D_INFO("Bootstrap uCode is good in inst SRAM\n"); + return 0; + } + + /* Try initialize */ + image = (__le32 *)il->ucode_init.v_addr; + len = il->ucode_init.len; + ret = il4965_verify_inst_sparse(il, image, len); + if (!ret) { + D_INFO("Initialize uCode is good in inst SRAM\n"); + return 0; + } + + /* Try runtime/protocol */ + image = (__le32 *)il->ucode_code.v_addr; + len = il->ucode_code.len; + ret = il4965_verify_inst_sparse(il, image, len); + if (!ret) { + D_INFO("Runtime uCode is good in inst SRAM\n"); + return 0; + } + + IL_ERR("NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); + + /* Since nothing seems to match, show first several data entries in + * instruction SRAM, so maybe visual inspection will give a clue. + * Selection of bootstrap image (vs. other images) is arbitrary. */ + image = (__le32 *)il->ucode_boot.v_addr; + len = il->ucode_boot.len; + ret = il4965_verify_inst_full(il, image, len); + + return ret; +} + /****************************************************************************** * * EEPROM related functions diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index 2776845be8d9..43daa07ac898 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -9,7 +9,7 @@ iwl-legacy-objs += $(iwl-legacy-m) # 4965 obj-$(CONFIG_IWL4965) += iwl4965.o iwl4965-objs := 4965.o 4965-mac.o iwl-4965-rs.o -iwl4965-objs += iwl-4965-ucode.o iwl-4965-tx.o +iwl4965-objs += iwl-4965-tx.o iwl4965-objs += iwl-4965-lib.o iwl-4965-rx.o iwl-4965-calib.o iwl4965-objs += iwl-4965-sta.o iwl4965-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-4965-debugfs.o diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c b/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c deleted file mode 100644 index 633caf5f60fc..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-ucode.c +++ /dev/null @@ -1,166 +0,0 @@ -/****************************************************************************** - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include -#include -#include -#include - -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-io.h" -#include "iwl-helpers.h" -#include "iwl-4965-hw.h" -#include "iwl-4965.h" -#include "iwl-4965-calib.h" - -#define IL_AC_UNSET -1 - -/** - * il_verify_inst_sparse - verify runtime uCode image in card vs. host, - * using sample data 100 bytes apart. If these sample points are good, - * it's a pretty good bet that everything between them is good, too. - */ -static int -il4965_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) -{ - u32 val; - int ret = 0; - u32 errcnt = 0; - u32 i; - - D_INFO("ucode inst image size is %u\n", len); - - for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { - /* read data comes through single port, auto-incr addr */ - /* NOTE: Use the debugless read so we don't flood kernel log - * if IL_DL_IO is set */ - il_wr(il, HBUS_TARG_MEM_RADDR, - i + IL4965_RTC_INST_LOWER_BOUND); - val = _il_rd(il, HBUS_TARG_MEM_RDAT); - if (val != le32_to_cpu(*image)) { - ret = -EIO; - errcnt++; - if (errcnt >= 3) - break; - } - } - - return ret; -} - -/** - * il4965_verify_inst_full - verify runtime uCode image in card vs. host, - * looking at all data. - */ -static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, - u32 len) -{ - u32 val; - u32 save_len = len; - int ret = 0; - u32 errcnt; - - D_INFO("ucode inst image size is %u\n", len); - - il_wr(il, HBUS_TARG_MEM_RADDR, - IL4965_RTC_INST_LOWER_BOUND); - - errcnt = 0; - for (; len > 0; len -= sizeof(u32), image++) { - /* read data comes through single port, auto-incr addr */ - /* NOTE: Use the debugless read so we don't flood kernel log - * if IL_DL_IO is set */ - val = _il_rd(il, HBUS_TARG_MEM_RDAT); - if (val != le32_to_cpu(*image)) { - IL_ERR("uCode INST section is invalid at " - "offset 0x%x, is 0x%x, s/b 0x%x\n", - save_len - len, val, le32_to_cpu(*image)); - ret = -EIO; - errcnt++; - if (errcnt >= 20) - break; - } - } - - if (!errcnt) - D_INFO( - "ucode image in INSTRUCTION memory is good\n"); - - return ret; -} - -/** - * il4965_verify_ucode - determine which instruction image is in SRAM, - * and verify its contents - */ -int il4965_verify_ucode(struct il_priv *il) -{ - __le32 *image; - u32 len; - int ret; - - /* Try bootstrap */ - image = (__le32 *)il->ucode_boot.v_addr; - len = il->ucode_boot.len; - ret = il4965_verify_inst_sparse(il, image, len); - if (!ret) { - D_INFO("Bootstrap uCode is good in inst SRAM\n"); - return 0; - } - - /* Try initialize */ - image = (__le32 *)il->ucode_init.v_addr; - len = il->ucode_init.len; - ret = il4965_verify_inst_sparse(il, image, len); - if (!ret) { - D_INFO("Initialize uCode is good in inst SRAM\n"); - return 0; - } - - /* Try runtime/protocol */ - image = (__le32 *)il->ucode_code.v_addr; - len = il->ucode_code.len; - ret = il4965_verify_inst_sparse(il, image, len); - if (!ret) { - D_INFO("Runtime uCode is good in inst SRAM\n"); - return 0; - } - - IL_ERR("NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n"); - - /* Since nothing seems to match, show first several data entries in - * instruction SRAM, so maybe visual inspection will give a clue. - * Selection of bootstrap image (vs. other images) is arbitrary. */ - image = (__le32 *)il->ucode_boot.v_addr; - len = il->ucode_boot.len; - ret = il4965_verify_inst_full(il, image, len); - - return ret; -} -- cgit v1.2.3 From eb3cdfb72d1cc73d8f78f01bc107064d77727d30 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 30 Aug 2011 12:58:35 +0200 Subject: iwlegacy: merge iwl-4965-sta.c into 4965-mac.c Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/4965-mac.c | 677 +++++++++++++++++++++++++ drivers/net/wireless/iwlegacy/Makefile | 1 - drivers/net/wireless/iwlegacy/iwl-4965-sta.c | 712 --------------------------- 3 files changed, 677 insertions(+), 713 deletions(-) delete mode 100644 drivers/net/wireless/iwlegacy/iwl-4965-sta.c (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 4a8ad8df828d..142d39f94498 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -86,6 +86,683 @@ MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); MODULE_LICENSE("GPL"); MODULE_ALIAS("iwl4965"); +static struct il_link_quality_cmd * +il4965_sta_alloc_lq(struct il_priv *il, u8 sta_id) +{ + int i, r; + struct il_link_quality_cmd *link_cmd; + u32 rate_flags = 0; + __le32 rate_n_flags; + + link_cmd = kzalloc(sizeof(struct il_link_quality_cmd), GFP_KERNEL); + if (!link_cmd) { + IL_ERR("Unable to allocate memory for LQ cmd.\n"); + return NULL; + } + /* Set up the rate scaling to start at selected rate, fall back + * all the way down to 1M in IEEE order, and then spin on 1M */ + if (il->band == IEEE80211_BAND_5GHZ) + r = RATE_6M_IDX; + else + r = RATE_1M_IDX; + + if (r >= IL_FIRST_CCK_RATE && r <= IL_LAST_CCK_RATE) + rate_flags |= RATE_MCS_CCK_MSK; + + rate_flags |= il4965_first_antenna(il->hw_params.valid_tx_ant) << + RATE_MCS_ANT_POS; + rate_n_flags = il4965_hw_set_rate_n_flags(il_rates[r].plcp, + rate_flags); + for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) + link_cmd->rs_table[i].rate_n_flags = rate_n_flags; + + link_cmd->general_params.single_stream_ant_msk = + il4965_first_antenna(il->hw_params.valid_tx_ant); + + link_cmd->general_params.dual_stream_ant_msk = + il->hw_params.valid_tx_ant & + ~il4965_first_antenna(il->hw_params.valid_tx_ant); + if (!link_cmd->general_params.dual_stream_ant_msk) { + link_cmd->general_params.dual_stream_ant_msk = ANT_AB; + } else if (il4965_num_of_ant(il->hw_params.valid_tx_ant) == 2) { + link_cmd->general_params.dual_stream_ant_msk = + il->hw_params.valid_tx_ant; + } + + link_cmd->agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF; + link_cmd->agg_params.agg_time_limit = + cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF); + + link_cmd->sta_id = sta_id; + + return link_cmd; +} + +/* + * il4965_add_bssid_station - Add the special IBSS BSSID station + * + * Function sleeps. + */ +int +il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, + const u8 *addr, u8 *sta_id_r) +{ + int ret; + u8 sta_id; + struct il_link_quality_cmd *link_cmd; + unsigned long flags; + + if (sta_id_r) + *sta_id_r = IL_INVALID_STATION; + + ret = il_add_station_common(il, ctx, addr, 0, NULL, &sta_id); + if (ret) { + IL_ERR("Unable to add station %pM\n", addr); + return ret; + } + + if (sta_id_r) + *sta_id_r = sta_id; + + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].used |= IL_STA_LOCAL; + spin_unlock_irqrestore(&il->sta_lock, flags); + + /* Set up default rate scaling table in device's station table */ + link_cmd = il4965_sta_alloc_lq(il, sta_id); + if (!link_cmd) { + IL_ERR( + "Unable to initialize rate scaling for station %pM.\n", + addr); + return -ENOMEM; + } + + ret = il_send_lq_cmd(il, ctx, link_cmd, CMD_SYNC, true); + if (ret) + IL_ERR("Link quality command failed (%d)\n", ret); + + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].lq = link_cmd; + spin_unlock_irqrestore(&il->sta_lock, flags); + + return 0; +} + +static int il4965_static_wepkey_cmd(struct il_priv *il, + struct il_rxon_context *ctx, + bool send_if_empty) +{ + int i, not_empty = 0; + u8 buff[sizeof(struct il_wep_cmd) + + sizeof(struct il_wep_key) * WEP_KEYS_MAX]; + struct il_wep_cmd *wep_cmd = (struct il_wep_cmd *)buff; + size_t cmd_size = sizeof(struct il_wep_cmd); + struct il_host_cmd cmd = { + .id = ctx->wep_key_cmd, + .data = wep_cmd, + .flags = CMD_SYNC, + }; + + might_sleep(); + + memset(wep_cmd, 0, cmd_size + + (sizeof(struct il_wep_key) * WEP_KEYS_MAX)); + + for (i = 0; i < WEP_KEYS_MAX ; i++) { + wep_cmd->key[i].key_idx = i; + if (ctx->wep_keys[i].key_size) { + wep_cmd->key[i].key_offset = i; + not_empty = 1; + } else { + wep_cmd->key[i].key_offset = WEP_INVALID_OFFSET; + } + + wep_cmd->key[i].key_size = ctx->wep_keys[i].key_size; + memcpy(&wep_cmd->key[i].key[3], ctx->wep_keys[i].key, + ctx->wep_keys[i].key_size); + } + + wep_cmd->global_key_type = WEP_KEY_WEP_TYPE; + wep_cmd->num_keys = WEP_KEYS_MAX; + + cmd_size += sizeof(struct il_wep_key) * WEP_KEYS_MAX; + + cmd.len = cmd_size; + + if (not_empty || send_if_empty) + return il_send_cmd(il, &cmd); + else + return 0; +} + +int il4965_restore_default_wep_keys(struct il_priv *il, + struct il_rxon_context *ctx) +{ + lockdep_assert_held(&il->mutex); + + return il4965_static_wepkey_cmd(il, ctx, false); +} + +int il4965_remove_default_wep_key(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf) +{ + int ret; + + lockdep_assert_held(&il->mutex); + + D_WEP("Removing default WEP key: idx=%d\n", + keyconf->keyidx); + + memset(&ctx->wep_keys[keyconf->keyidx], 0, sizeof(ctx->wep_keys[0])); + if (il_is_rfkill(il)) { + D_WEP( + "Not sending REPLY_WEPKEY command due to RFKILL.\n"); + /* but keys in device are clear anyway so return success */ + return 0; + } + ret = il4965_static_wepkey_cmd(il, ctx, 1); + D_WEP("Remove default WEP key: idx=%d ret=%d\n", + keyconf->keyidx, ret); + + return ret; +} + +int il4965_set_default_wep_key(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf) +{ + int ret; + + lockdep_assert_held(&il->mutex); + + if (keyconf->keylen != WEP_KEY_LEN_128 && + keyconf->keylen != WEP_KEY_LEN_64) { + D_WEP("Bad WEP key length %d\n", keyconf->keylen); + return -EINVAL; + } + + keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV; + keyconf->hw_key_idx = HW_KEY_DEFAULT; + il->stations[ctx->ap_sta_id].keyinfo.cipher = keyconf->cipher; + + ctx->wep_keys[keyconf->keyidx].key_size = keyconf->keylen; + memcpy(&ctx->wep_keys[keyconf->keyidx].key, &keyconf->key, + keyconf->keylen); + + ret = il4965_static_wepkey_cmd(il, ctx, false); + D_WEP("Set default WEP key: len=%d idx=%d ret=%d\n", + keyconf->keylen, keyconf->keyidx, ret); + + return ret; +} + +static int il4965_set_wep_dynamic_key_info(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, + u8 sta_id) +{ + unsigned long flags; + __le16 key_flags = 0; + struct il_addsta_cmd sta_cmd; + + lockdep_assert_held(&il->mutex); + + keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV; + + key_flags |= (STA_KEY_FLG_WEP | STA_KEY_FLG_MAP_KEY_MSK); + key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); + key_flags &= ~STA_KEY_FLG_INVALID; + + if (keyconf->keylen == WEP_KEY_LEN_128) + key_flags |= STA_KEY_FLG_KEY_SIZE_MSK; + + if (sta_id == ctx->bcast_sta_id) + key_flags |= STA_KEY_MULTICAST_MSK; + + spin_lock_irqsave(&il->sta_lock, flags); + + il->stations[sta_id].keyinfo.cipher = keyconf->cipher; + il->stations[sta_id].keyinfo.keylen = keyconf->keylen; + il->stations[sta_id].keyinfo.keyidx = keyconf->keyidx; + + memcpy(il->stations[sta_id].keyinfo.key, + keyconf->key, keyconf->keylen); + + memcpy(&il->stations[sta_id].sta.key.key[3], + keyconf->key, keyconf->keylen); + + if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) + == STA_KEY_FLG_NO_ENC) + il->stations[sta_id].sta.key.key_offset = + il_get_free_ucode_key_idx(il); + /* else, we are overriding an existing key => no need to allocated room + * in uCode. */ + + WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, + "no space for a new key"); + + il->stations[sta_id].sta.key.key_flags = key_flags; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + + memcpy(&sta_cmd, &il->stations[sta_id].sta, + sizeof(struct il_addsta_cmd)); + spin_unlock_irqrestore(&il->sta_lock, flags); + + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); +} + +static int il4965_set_ccmp_dynamic_key_info(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, + u8 sta_id) +{ + unsigned long flags; + __le16 key_flags = 0; + struct il_addsta_cmd sta_cmd; + + lockdep_assert_held(&il->mutex); + + key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK); + key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); + key_flags &= ~STA_KEY_FLG_INVALID; + + if (sta_id == ctx->bcast_sta_id) + key_flags |= STA_KEY_MULTICAST_MSK; + + keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; + + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].keyinfo.cipher = keyconf->cipher; + il->stations[sta_id].keyinfo.keylen = keyconf->keylen; + + memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, + keyconf->keylen); + + memcpy(il->stations[sta_id].sta.key.key, keyconf->key, + keyconf->keylen); + + if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) + == STA_KEY_FLG_NO_ENC) + il->stations[sta_id].sta.key.key_offset = + il_get_free_ucode_key_idx(il); + /* else, we are overriding an existing key => no need to allocated room + * in uCode. */ + + WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, + "no space for a new key"); + + il->stations[sta_id].sta.key.key_flags = key_flags; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + + memcpy(&sta_cmd, &il->stations[sta_id].sta, + sizeof(struct il_addsta_cmd)); + spin_unlock_irqrestore(&il->sta_lock, flags); + + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); +} + +static int il4965_set_tkip_dynamic_key_info(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, + u8 sta_id) +{ + unsigned long flags; + int ret = 0; + __le16 key_flags = 0; + + key_flags |= (STA_KEY_FLG_TKIP | STA_KEY_FLG_MAP_KEY_MSK); + key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); + key_flags &= ~STA_KEY_FLG_INVALID; + + if (sta_id == ctx->bcast_sta_id) + key_flags |= STA_KEY_MULTICAST_MSK; + + keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; + keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; + + spin_lock_irqsave(&il->sta_lock, flags); + + il->stations[sta_id].keyinfo.cipher = keyconf->cipher; + il->stations[sta_id].keyinfo.keylen = 16; + + if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) + == STA_KEY_FLG_NO_ENC) + il->stations[sta_id].sta.key.key_offset = + il_get_free_ucode_key_idx(il); + /* else, we are overriding an existing key => no need to allocated room + * in uCode. */ + + WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, + "no space for a new key"); + + il->stations[sta_id].sta.key.key_flags = key_flags; + + + /* This copy is acutally not needed: we get the key with each TX */ + memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, 16); + + memcpy(il->stations[sta_id].sta.key.key, keyconf->key, 16); + + spin_unlock_irqrestore(&il->sta_lock, flags); + + return ret; +} + +void il4965_update_tkip_key(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, + struct ieee80211_sta *sta, u32 iv32, u16 *phase1key) +{ + u8 sta_id; + unsigned long flags; + int i; + + if (il_scan_cancel(il)) { + /* cancel scan failed, just live w/ bad key and rely + briefly on SW decryption */ + return; + } + + sta_id = il_sta_id_or_broadcast(il, ctx, sta); + if (sta_id == IL_INVALID_STATION) + return; + + spin_lock_irqsave(&il->sta_lock, flags); + + il->stations[sta_id].sta.key.tkip_rx_tsc_byte2 = (u8) iv32; + + for (i = 0; i < 5; i++) + il->stations[sta_id].sta.key.tkip_rx_ttak[i] = + cpu_to_le16(phase1key[i]); + + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + + il_send_add_sta(il, &il->stations[sta_id].sta, CMD_ASYNC); + + spin_unlock_irqrestore(&il->sta_lock, flags); + +} + +int il4965_remove_dynamic_key(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, + u8 sta_id) +{ + unsigned long flags; + u16 key_flags; + u8 keyidx; + struct il_addsta_cmd sta_cmd; + + lockdep_assert_held(&il->mutex); + + ctx->key_mapping_keys--; + + spin_lock_irqsave(&il->sta_lock, flags); + key_flags = le16_to_cpu(il->stations[sta_id].sta.key.key_flags); + keyidx = (key_flags >> STA_KEY_FLG_KEYID_POS) & 0x3; + + D_WEP("Remove dynamic key: idx=%d sta=%d\n", + keyconf->keyidx, sta_id); + + if (keyconf->keyidx != keyidx) { + /* We need to remove a key with idx different that the one + * in the uCode. This means that the key we need to remove has + * been replaced by another one with different idx. + * Don't do anything and return ok + */ + spin_unlock_irqrestore(&il->sta_lock, flags); + return 0; + } + + if (il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET) { + IL_WARN("Removing wrong key %d 0x%x\n", + keyconf->keyidx, key_flags); + spin_unlock_irqrestore(&il->sta_lock, flags); + return 0; + } + + if (!test_and_clear_bit(il->stations[sta_id].sta.key.key_offset, + &il->ucode_key_table)) + IL_ERR("idx %d not used in uCode key table.\n", + il->stations[sta_id].sta.key.key_offset); + memset(&il->stations[sta_id].keyinfo, 0, + sizeof(struct il_hw_key)); + memset(&il->stations[sta_id].sta.key, 0, + sizeof(struct il4965_keyinfo)); + il->stations[sta_id].sta.key.key_flags = + STA_KEY_FLG_NO_ENC | STA_KEY_FLG_INVALID; + il->stations[sta_id].sta.key.key_offset = WEP_INVALID_OFFSET; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + + if (il_is_rfkill(il)) { + D_WEP( + "Not sending REPLY_ADD_STA command because RFKILL enabled.\n"); + spin_unlock_irqrestore(&il->sta_lock, flags); + return 0; + } + memcpy(&sta_cmd, &il->stations[sta_id].sta, + sizeof(struct il_addsta_cmd)); + spin_unlock_irqrestore(&il->sta_lock, flags); + + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); +} + +int il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, u8 sta_id) +{ + int ret; + + lockdep_assert_held(&il->mutex); + + ctx->key_mapping_keys++; + keyconf->hw_key_idx = HW_KEY_DYNAMIC; + + switch (keyconf->cipher) { + case WLAN_CIPHER_SUITE_CCMP: + ret = il4965_set_ccmp_dynamic_key_info(il, ctx, + keyconf, sta_id); + break; + case WLAN_CIPHER_SUITE_TKIP: + ret = il4965_set_tkip_dynamic_key_info(il, ctx, + keyconf, sta_id); + break; + case WLAN_CIPHER_SUITE_WEP40: + case WLAN_CIPHER_SUITE_WEP104: + ret = il4965_set_wep_dynamic_key_info(il, ctx, + keyconf, sta_id); + break; + default: + IL_ERR( + "Unknown alg: %s cipher = %x\n", __func__, + keyconf->cipher); + ret = -EINVAL; + } + + D_WEP( + "Set dynamic key: cipher=%x len=%d idx=%d sta=%d ret=%d\n", + keyconf->cipher, keyconf->keylen, keyconf->keyidx, + sta_id, ret); + + return ret; +} + +/** + * il4965_alloc_bcast_station - add broadcast station into driver's station table. + * + * This adds the broadcast station into the driver's station table + * and marks it driver active, so that it will be restored to the + * device at the next best time. + */ +int il4965_alloc_bcast_station(struct il_priv *il, + struct il_rxon_context *ctx) +{ + struct il_link_quality_cmd *link_cmd; + unsigned long flags; + u8 sta_id; + + spin_lock_irqsave(&il->sta_lock, flags); + sta_id = il_prep_station(il, ctx, il_bcast_addr, + false, NULL); + if (sta_id == IL_INVALID_STATION) { + IL_ERR("Unable to prepare broadcast station\n"); + spin_unlock_irqrestore(&il->sta_lock, flags); + + return -EINVAL; + } + + il->stations[sta_id].used |= IL_STA_DRIVER_ACTIVE; + il->stations[sta_id].used |= IL_STA_BCAST; + spin_unlock_irqrestore(&il->sta_lock, flags); + + link_cmd = il4965_sta_alloc_lq(il, sta_id); + if (!link_cmd) { + IL_ERR( + "Unable to initialize rate scaling for bcast station.\n"); + return -ENOMEM; + } + + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].lq = link_cmd; + spin_unlock_irqrestore(&il->sta_lock, flags); + + return 0; +} + +/** + * il4965_update_bcast_station - update broadcast station's LQ command + * + * Only used by iwl4965. Placed here to have all bcast station management + * code together. + */ +static int il4965_update_bcast_station(struct il_priv *il, + struct il_rxon_context *ctx) +{ + unsigned long flags; + struct il_link_quality_cmd *link_cmd; + u8 sta_id = ctx->bcast_sta_id; + + link_cmd = il4965_sta_alloc_lq(il, sta_id); + if (!link_cmd) { + IL_ERR( + "Unable to initialize rate scaling for bcast station.\n"); + return -ENOMEM; + } + + spin_lock_irqsave(&il->sta_lock, flags); + if (il->stations[sta_id].lq) + kfree(il->stations[sta_id].lq); + else + D_INFO( + "Bcast station rate scaling has not been initialized yet.\n"); + il->stations[sta_id].lq = link_cmd; + spin_unlock_irqrestore(&il->sta_lock, flags); + + return 0; +} + +int il4965_update_bcast_stations(struct il_priv *il) +{ + return il4965_update_bcast_station(il, &il->ctx); +} + +/** + * il4965_sta_tx_modify_enable_tid - Enable Tx for this TID in station table + */ +int il4965_sta_tx_modify_enable_tid(struct il_priv *il, int sta_id, int tid) +{ + unsigned long flags; + struct il_addsta_cmd sta_cmd; + + lockdep_assert_held(&il->mutex); + + /* Remove "disable" flag, to enable Tx for this TID */ + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_TID_DISABLE_TX; + il->stations[sta_id].sta.tid_disable_tx &= cpu_to_le16(~(1 << tid)); + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + memcpy(&sta_cmd, &il->stations[sta_id].sta, + sizeof(struct il_addsta_cmd)); + spin_unlock_irqrestore(&il->sta_lock, flags); + + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); +} + +int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta, + int tid, u16 ssn) +{ + unsigned long flags; + int sta_id; + struct il_addsta_cmd sta_cmd; + + lockdep_assert_held(&il->mutex); + + sta_id = il_sta_id(sta); + if (sta_id == IL_INVALID_STATION) + return -ENXIO; + + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].sta.station_flags_msk = 0; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_ADDBA_TID_MSK; + il->stations[sta_id].sta.add_immediate_ba_tid = (u8)tid; + il->stations[sta_id].sta.add_immediate_ba_ssn = cpu_to_le16(ssn); + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + memcpy(&sta_cmd, &il->stations[sta_id].sta, + sizeof(struct il_addsta_cmd)); + spin_unlock_irqrestore(&il->sta_lock, flags); + + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); +} + +int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta, + int tid) +{ + unsigned long flags; + int sta_id; + struct il_addsta_cmd sta_cmd; + + lockdep_assert_held(&il->mutex); + + sta_id = il_sta_id(sta); + if (sta_id == IL_INVALID_STATION) { + IL_ERR("Invalid station for AGG tid %d\n", tid); + return -ENXIO; + } + + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].sta.station_flags_msk = 0; + il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_DELBA_TID_MSK; + il->stations[sta_id].sta.remove_immediate_ba_tid = (u8)tid; + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + memcpy(&sta_cmd, &il->stations[sta_id].sta, + sizeof(struct il_addsta_cmd)); + spin_unlock_irqrestore(&il->sta_lock, flags); + + return il_send_add_sta(il, &sta_cmd, CMD_SYNC); +} + +void +il4965_sta_modify_sleep_tx_count(struct il_priv *il, int sta_id, int cnt) +{ + unsigned long flags; + + spin_lock_irqsave(&il->sta_lock, flags); + il->stations[sta_id].sta.station_flags |= STA_FLG_PWR_SAVE_MSK; + il->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK; + il->stations[sta_id].sta.sta.modify_mask = + STA_MODIFY_SLEEP_TX_COUNT_MSK; + il->stations[sta_id].sta.sleep_tx_count = cpu_to_le16(cnt); + il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; + il_send_add_sta(il, + &il->stations[sta_id].sta, CMD_ASYNC); + spin_unlock_irqrestore(&il->sta_lock, flags); + +} + void il4965_update_chain_flags(struct il_priv *il) { if (il->cfg->ops->hcmd->set_rxon_chain) { diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index 43daa07ac898..0643fda0656c 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -11,7 +11,6 @@ obj-$(CONFIG_IWL4965) += iwl4965.o iwl4965-objs := 4965.o 4965-mac.o iwl-4965-rs.o iwl4965-objs += iwl-4965-tx.o iwl4965-objs += iwl-4965-lib.o iwl-4965-rx.o iwl-4965-calib.o -iwl4965-objs += iwl-4965-sta.o iwl4965-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-4965-debugfs.o # 3945 diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c b/drivers/net/wireless/iwlegacy/iwl-4965-sta.c deleted file mode 100644 index 337bf0c1c4c2..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-sta.c +++ /dev/null @@ -1,712 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * Portions of this file are derived from the ipw3945 project, as well - * as portions of the ieee80211 subsystem header files. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include - -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-sta.h" -#include "iwl-4965.h" - -static struct il_link_quality_cmd * -il4965_sta_alloc_lq(struct il_priv *il, u8 sta_id) -{ - int i, r; - struct il_link_quality_cmd *link_cmd; - u32 rate_flags = 0; - __le32 rate_n_flags; - - link_cmd = kzalloc(sizeof(struct il_link_quality_cmd), GFP_KERNEL); - if (!link_cmd) { - IL_ERR("Unable to allocate memory for LQ cmd.\n"); - return NULL; - } - /* Set up the rate scaling to start at selected rate, fall back - * all the way down to 1M in IEEE order, and then spin on 1M */ - if (il->band == IEEE80211_BAND_5GHZ) - r = RATE_6M_IDX; - else - r = RATE_1M_IDX; - - if (r >= IL_FIRST_CCK_RATE && r <= IL_LAST_CCK_RATE) - rate_flags |= RATE_MCS_CCK_MSK; - - rate_flags |= il4965_first_antenna(il->hw_params.valid_tx_ant) << - RATE_MCS_ANT_POS; - rate_n_flags = il4965_hw_set_rate_n_flags(il_rates[r].plcp, - rate_flags); - for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) - link_cmd->rs_table[i].rate_n_flags = rate_n_flags; - - link_cmd->general_params.single_stream_ant_msk = - il4965_first_antenna(il->hw_params.valid_tx_ant); - - link_cmd->general_params.dual_stream_ant_msk = - il->hw_params.valid_tx_ant & - ~il4965_first_antenna(il->hw_params.valid_tx_ant); - if (!link_cmd->general_params.dual_stream_ant_msk) { - link_cmd->general_params.dual_stream_ant_msk = ANT_AB; - } else if (il4965_num_of_ant(il->hw_params.valid_tx_ant) == 2) { - link_cmd->general_params.dual_stream_ant_msk = - il->hw_params.valid_tx_ant; - } - - link_cmd->agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF; - link_cmd->agg_params.agg_time_limit = - cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF); - - link_cmd->sta_id = sta_id; - - return link_cmd; -} - -/* - * il4965_add_bssid_station - Add the special IBSS BSSID station - * - * Function sleeps. - */ -int -il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, - const u8 *addr, u8 *sta_id_r) -{ - int ret; - u8 sta_id; - struct il_link_quality_cmd *link_cmd; - unsigned long flags; - - if (sta_id_r) - *sta_id_r = IL_INVALID_STATION; - - ret = il_add_station_common(il, ctx, addr, 0, NULL, &sta_id); - if (ret) { - IL_ERR("Unable to add station %pM\n", addr); - return ret; - } - - if (sta_id_r) - *sta_id_r = sta_id; - - spin_lock_irqsave(&il->sta_lock, flags); - il->stations[sta_id].used |= IL_STA_LOCAL; - spin_unlock_irqrestore(&il->sta_lock, flags); - - /* Set up default rate scaling table in device's station table */ - link_cmd = il4965_sta_alloc_lq(il, sta_id); - if (!link_cmd) { - IL_ERR( - "Unable to initialize rate scaling for station %pM.\n", - addr); - return -ENOMEM; - } - - ret = il_send_lq_cmd(il, ctx, link_cmd, CMD_SYNC, true); - if (ret) - IL_ERR("Link quality command failed (%d)\n", ret); - - spin_lock_irqsave(&il->sta_lock, flags); - il->stations[sta_id].lq = link_cmd; - spin_unlock_irqrestore(&il->sta_lock, flags); - - return 0; -} - -static int il4965_static_wepkey_cmd(struct il_priv *il, - struct il_rxon_context *ctx, - bool send_if_empty) -{ - int i, not_empty = 0; - u8 buff[sizeof(struct il_wep_cmd) + - sizeof(struct il_wep_key) * WEP_KEYS_MAX]; - struct il_wep_cmd *wep_cmd = (struct il_wep_cmd *)buff; - size_t cmd_size = sizeof(struct il_wep_cmd); - struct il_host_cmd cmd = { - .id = ctx->wep_key_cmd, - .data = wep_cmd, - .flags = CMD_SYNC, - }; - - might_sleep(); - - memset(wep_cmd, 0, cmd_size + - (sizeof(struct il_wep_key) * WEP_KEYS_MAX)); - - for (i = 0; i < WEP_KEYS_MAX ; i++) { - wep_cmd->key[i].key_idx = i; - if (ctx->wep_keys[i].key_size) { - wep_cmd->key[i].key_offset = i; - not_empty = 1; - } else { - wep_cmd->key[i].key_offset = WEP_INVALID_OFFSET; - } - - wep_cmd->key[i].key_size = ctx->wep_keys[i].key_size; - memcpy(&wep_cmd->key[i].key[3], ctx->wep_keys[i].key, - ctx->wep_keys[i].key_size); - } - - wep_cmd->global_key_type = WEP_KEY_WEP_TYPE; - wep_cmd->num_keys = WEP_KEYS_MAX; - - cmd_size += sizeof(struct il_wep_key) * WEP_KEYS_MAX; - - cmd.len = cmd_size; - - if (not_empty || send_if_empty) - return il_send_cmd(il, &cmd); - else - return 0; -} - -int il4965_restore_default_wep_keys(struct il_priv *il, - struct il_rxon_context *ctx) -{ - lockdep_assert_held(&il->mutex); - - return il4965_static_wepkey_cmd(il, ctx, false); -} - -int il4965_remove_default_wep_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf) -{ - int ret; - - lockdep_assert_held(&il->mutex); - - D_WEP("Removing default WEP key: idx=%d\n", - keyconf->keyidx); - - memset(&ctx->wep_keys[keyconf->keyidx], 0, sizeof(ctx->wep_keys[0])); - if (il_is_rfkill(il)) { - D_WEP( - "Not sending REPLY_WEPKEY command due to RFKILL.\n"); - /* but keys in device are clear anyway so return success */ - return 0; - } - ret = il4965_static_wepkey_cmd(il, ctx, 1); - D_WEP("Remove default WEP key: idx=%d ret=%d\n", - keyconf->keyidx, ret); - - return ret; -} - -int il4965_set_default_wep_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf) -{ - int ret; - - lockdep_assert_held(&il->mutex); - - if (keyconf->keylen != WEP_KEY_LEN_128 && - keyconf->keylen != WEP_KEY_LEN_64) { - D_WEP("Bad WEP key length %d\n", keyconf->keylen); - return -EINVAL; - } - - keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV; - keyconf->hw_key_idx = HW_KEY_DEFAULT; - il->stations[ctx->ap_sta_id].keyinfo.cipher = keyconf->cipher; - - ctx->wep_keys[keyconf->keyidx].key_size = keyconf->keylen; - memcpy(&ctx->wep_keys[keyconf->keyidx].key, &keyconf->key, - keyconf->keylen); - - ret = il4965_static_wepkey_cmd(il, ctx, false); - D_WEP("Set default WEP key: len=%d idx=%d ret=%d\n", - keyconf->keylen, keyconf->keyidx, ret); - - return ret; -} - -static int il4965_set_wep_dynamic_key_info(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, - u8 sta_id) -{ - unsigned long flags; - __le16 key_flags = 0; - struct il_addsta_cmd sta_cmd; - - lockdep_assert_held(&il->mutex); - - keyconf->flags &= ~IEEE80211_KEY_FLAG_GENERATE_IV; - - key_flags |= (STA_KEY_FLG_WEP | STA_KEY_FLG_MAP_KEY_MSK); - key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); - key_flags &= ~STA_KEY_FLG_INVALID; - - if (keyconf->keylen == WEP_KEY_LEN_128) - key_flags |= STA_KEY_FLG_KEY_SIZE_MSK; - - if (sta_id == ctx->bcast_sta_id) - key_flags |= STA_KEY_MULTICAST_MSK; - - spin_lock_irqsave(&il->sta_lock, flags); - - il->stations[sta_id].keyinfo.cipher = keyconf->cipher; - il->stations[sta_id].keyinfo.keylen = keyconf->keylen; - il->stations[sta_id].keyinfo.keyidx = keyconf->keyidx; - - memcpy(il->stations[sta_id].keyinfo.key, - keyconf->key, keyconf->keylen); - - memcpy(&il->stations[sta_id].sta.key.key[3], - keyconf->key, keyconf->keylen); - - if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) - == STA_KEY_FLG_NO_ENC) - il->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_idx(il); - /* else, we are overriding an existing key => no need to allocated room - * in uCode. */ - - WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, - "no space for a new key"); - - il->stations[sta_id].sta.key.key_flags = key_flags; - il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; - il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - - memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&il->sta_lock, flags); - - return il_send_add_sta(il, &sta_cmd, CMD_SYNC); -} - -static int il4965_set_ccmp_dynamic_key_info(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, - u8 sta_id) -{ - unsigned long flags; - __le16 key_flags = 0; - struct il_addsta_cmd sta_cmd; - - lockdep_assert_held(&il->mutex); - - key_flags |= (STA_KEY_FLG_CCMP | STA_KEY_FLG_MAP_KEY_MSK); - key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); - key_flags &= ~STA_KEY_FLG_INVALID; - - if (sta_id == ctx->bcast_sta_id) - key_flags |= STA_KEY_MULTICAST_MSK; - - keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; - - spin_lock_irqsave(&il->sta_lock, flags); - il->stations[sta_id].keyinfo.cipher = keyconf->cipher; - il->stations[sta_id].keyinfo.keylen = keyconf->keylen; - - memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, - keyconf->keylen); - - memcpy(il->stations[sta_id].sta.key.key, keyconf->key, - keyconf->keylen); - - if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) - == STA_KEY_FLG_NO_ENC) - il->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_idx(il); - /* else, we are overriding an existing key => no need to allocated room - * in uCode. */ - - WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, - "no space for a new key"); - - il->stations[sta_id].sta.key.key_flags = key_flags; - il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; - il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - - memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&il->sta_lock, flags); - - return il_send_add_sta(il, &sta_cmd, CMD_SYNC); -} - -static int il4965_set_tkip_dynamic_key_info(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, - u8 sta_id) -{ - unsigned long flags; - int ret = 0; - __le16 key_flags = 0; - - key_flags |= (STA_KEY_FLG_TKIP | STA_KEY_FLG_MAP_KEY_MSK); - key_flags |= cpu_to_le16(keyconf->keyidx << STA_KEY_FLG_KEYID_POS); - key_flags &= ~STA_KEY_FLG_INVALID; - - if (sta_id == ctx->bcast_sta_id) - key_flags |= STA_KEY_MULTICAST_MSK; - - keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; - keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; - - spin_lock_irqsave(&il->sta_lock, flags); - - il->stations[sta_id].keyinfo.cipher = keyconf->cipher; - il->stations[sta_id].keyinfo.keylen = 16; - - if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) - == STA_KEY_FLG_NO_ENC) - il->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_idx(il); - /* else, we are overriding an existing key => no need to allocated room - * in uCode. */ - - WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, - "no space for a new key"); - - il->stations[sta_id].sta.key.key_flags = key_flags; - - - /* This copy is acutally not needed: we get the key with each TX */ - memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, 16); - - memcpy(il->stations[sta_id].sta.key.key, keyconf->key, 16); - - spin_unlock_irqrestore(&il->sta_lock, flags); - - return ret; -} - -void il4965_update_tkip_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, - struct ieee80211_sta *sta, u32 iv32, u16 *phase1key) -{ - u8 sta_id; - unsigned long flags; - int i; - - if (il_scan_cancel(il)) { - /* cancel scan failed, just live w/ bad key and rely - briefly on SW decryption */ - return; - } - - sta_id = il_sta_id_or_broadcast(il, ctx, sta); - if (sta_id == IL_INVALID_STATION) - return; - - spin_lock_irqsave(&il->sta_lock, flags); - - il->stations[sta_id].sta.key.tkip_rx_tsc_byte2 = (u8) iv32; - - for (i = 0; i < 5; i++) - il->stations[sta_id].sta.key.tkip_rx_ttak[i] = - cpu_to_le16(phase1key[i]); - - il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; - il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - - il_send_add_sta(il, &il->stations[sta_id].sta, CMD_ASYNC); - - spin_unlock_irqrestore(&il->sta_lock, flags); - -} - -int il4965_remove_dynamic_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, - u8 sta_id) -{ - unsigned long flags; - u16 key_flags; - u8 keyidx; - struct il_addsta_cmd sta_cmd; - - lockdep_assert_held(&il->mutex); - - ctx->key_mapping_keys--; - - spin_lock_irqsave(&il->sta_lock, flags); - key_flags = le16_to_cpu(il->stations[sta_id].sta.key.key_flags); - keyidx = (key_flags >> STA_KEY_FLG_KEYID_POS) & 0x3; - - D_WEP("Remove dynamic key: idx=%d sta=%d\n", - keyconf->keyidx, sta_id); - - if (keyconf->keyidx != keyidx) { - /* We need to remove a key with idx different that the one - * in the uCode. This means that the key we need to remove has - * been replaced by another one with different idx. - * Don't do anything and return ok - */ - spin_unlock_irqrestore(&il->sta_lock, flags); - return 0; - } - - if (il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET) { - IL_WARN("Removing wrong key %d 0x%x\n", - keyconf->keyidx, key_flags); - spin_unlock_irqrestore(&il->sta_lock, flags); - return 0; - } - - if (!test_and_clear_bit(il->stations[sta_id].sta.key.key_offset, - &il->ucode_key_table)) - IL_ERR("idx %d not used in uCode key table.\n", - il->stations[sta_id].sta.key.key_offset); - memset(&il->stations[sta_id].keyinfo, 0, - sizeof(struct il_hw_key)); - memset(&il->stations[sta_id].sta.key, 0, - sizeof(struct il4965_keyinfo)); - il->stations[sta_id].sta.key.key_flags = - STA_KEY_FLG_NO_ENC | STA_KEY_FLG_INVALID; - il->stations[sta_id].sta.key.key_offset = WEP_INVALID_OFFSET; - il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; - il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - - if (il_is_rfkill(il)) { - D_WEP( - "Not sending REPLY_ADD_STA command because RFKILL enabled.\n"); - spin_unlock_irqrestore(&il->sta_lock, flags); - return 0; - } - memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&il->sta_lock, flags); - - return il_send_add_sta(il, &sta_cmd, CMD_SYNC); -} - -int il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, u8 sta_id) -{ - int ret; - - lockdep_assert_held(&il->mutex); - - ctx->key_mapping_keys++; - keyconf->hw_key_idx = HW_KEY_DYNAMIC; - - switch (keyconf->cipher) { - case WLAN_CIPHER_SUITE_CCMP: - ret = il4965_set_ccmp_dynamic_key_info(il, ctx, - keyconf, sta_id); - break; - case WLAN_CIPHER_SUITE_TKIP: - ret = il4965_set_tkip_dynamic_key_info(il, ctx, - keyconf, sta_id); - break; - case WLAN_CIPHER_SUITE_WEP40: - case WLAN_CIPHER_SUITE_WEP104: - ret = il4965_set_wep_dynamic_key_info(il, ctx, - keyconf, sta_id); - break; - default: - IL_ERR( - "Unknown alg: %s cipher = %x\n", __func__, - keyconf->cipher); - ret = -EINVAL; - } - - D_WEP( - "Set dynamic key: cipher=%x len=%d idx=%d sta=%d ret=%d\n", - keyconf->cipher, keyconf->keylen, keyconf->keyidx, - sta_id, ret); - - return ret; -} - -/** - * il4965_alloc_bcast_station - add broadcast station into driver's station table. - * - * This adds the broadcast station into the driver's station table - * and marks it driver active, so that it will be restored to the - * device at the next best time. - */ -int il4965_alloc_bcast_station(struct il_priv *il, - struct il_rxon_context *ctx) -{ - struct il_link_quality_cmd *link_cmd; - unsigned long flags; - u8 sta_id; - - spin_lock_irqsave(&il->sta_lock, flags); - sta_id = il_prep_station(il, ctx, il_bcast_addr, - false, NULL); - if (sta_id == IL_INVALID_STATION) { - IL_ERR("Unable to prepare broadcast station\n"); - spin_unlock_irqrestore(&il->sta_lock, flags); - - return -EINVAL; - } - - il->stations[sta_id].used |= IL_STA_DRIVER_ACTIVE; - il->stations[sta_id].used |= IL_STA_BCAST; - spin_unlock_irqrestore(&il->sta_lock, flags); - - link_cmd = il4965_sta_alloc_lq(il, sta_id); - if (!link_cmd) { - IL_ERR( - "Unable to initialize rate scaling for bcast station.\n"); - return -ENOMEM; - } - - spin_lock_irqsave(&il->sta_lock, flags); - il->stations[sta_id].lq = link_cmd; - spin_unlock_irqrestore(&il->sta_lock, flags); - - return 0; -} - -/** - * il4965_update_bcast_station - update broadcast station's LQ command - * - * Only used by iwl4965. Placed here to have all bcast station management - * code together. - */ -static int il4965_update_bcast_station(struct il_priv *il, - struct il_rxon_context *ctx) -{ - unsigned long flags; - struct il_link_quality_cmd *link_cmd; - u8 sta_id = ctx->bcast_sta_id; - - link_cmd = il4965_sta_alloc_lq(il, sta_id); - if (!link_cmd) { - IL_ERR( - "Unable to initialize rate scaling for bcast station.\n"); - return -ENOMEM; - } - - spin_lock_irqsave(&il->sta_lock, flags); - if (il->stations[sta_id].lq) - kfree(il->stations[sta_id].lq); - else - D_INFO( - "Bcast station rate scaling has not been initialized yet.\n"); - il->stations[sta_id].lq = link_cmd; - spin_unlock_irqrestore(&il->sta_lock, flags); - - return 0; -} - -int il4965_update_bcast_stations(struct il_priv *il) -{ - return il4965_update_bcast_station(il, &il->ctx); -} - -/** - * il4965_sta_tx_modify_enable_tid - Enable Tx for this TID in station table - */ -int il4965_sta_tx_modify_enable_tid(struct il_priv *il, int sta_id, int tid) -{ - unsigned long flags; - struct il_addsta_cmd sta_cmd; - - lockdep_assert_held(&il->mutex); - - /* Remove "disable" flag, to enable Tx for this TID */ - spin_lock_irqsave(&il->sta_lock, flags); - il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_TID_DISABLE_TX; - il->stations[sta_id].sta.tid_disable_tx &= cpu_to_le16(~(1 << tid)); - il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&il->sta_lock, flags); - - return il_send_add_sta(il, &sta_cmd, CMD_SYNC); -} - -int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta, - int tid, u16 ssn) -{ - unsigned long flags; - int sta_id; - struct il_addsta_cmd sta_cmd; - - lockdep_assert_held(&il->mutex); - - sta_id = il_sta_id(sta); - if (sta_id == IL_INVALID_STATION) - return -ENXIO; - - spin_lock_irqsave(&il->sta_lock, flags); - il->stations[sta_id].sta.station_flags_msk = 0; - il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_ADDBA_TID_MSK; - il->stations[sta_id].sta.add_immediate_ba_tid = (u8)tid; - il->stations[sta_id].sta.add_immediate_ba_ssn = cpu_to_le16(ssn); - il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&il->sta_lock, flags); - - return il_send_add_sta(il, &sta_cmd, CMD_SYNC); -} - -int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta, - int tid) -{ - unsigned long flags; - int sta_id; - struct il_addsta_cmd sta_cmd; - - lockdep_assert_held(&il->mutex); - - sta_id = il_sta_id(sta); - if (sta_id == IL_INVALID_STATION) { - IL_ERR("Invalid station for AGG tid %d\n", tid); - return -ENXIO; - } - - spin_lock_irqsave(&il->sta_lock, flags); - il->stations[sta_id].sta.station_flags_msk = 0; - il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_DELBA_TID_MSK; - il->stations[sta_id].sta.remove_immediate_ba_tid = (u8)tid; - il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); - spin_unlock_irqrestore(&il->sta_lock, flags); - - return il_send_add_sta(il, &sta_cmd, CMD_SYNC); -} - -void -il4965_sta_modify_sleep_tx_count(struct il_priv *il, int sta_id, int cnt) -{ - unsigned long flags; - - spin_lock_irqsave(&il->sta_lock, flags); - il->stations[sta_id].sta.station_flags |= STA_FLG_PWR_SAVE_MSK; - il->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK; - il->stations[sta_id].sta.sta.modify_mask = - STA_MODIFY_SLEEP_TX_COUNT_MSK; - il->stations[sta_id].sta.sleep_tx_count = cpu_to_le16(cnt); - il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - il_send_add_sta(il, - &il->stations[sta_id].sta, CMD_ASYNC); - spin_unlock_irqrestore(&il->sta_lock, flags); - -} -- cgit v1.2.3 From a1751b22a82e6cd2da6c9e79611cfd6d6aba1d39 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 12:50:37 +0100 Subject: iwlegacy: merge iwl-4965-{tx,rx}.c into 4965-mac.c Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/4965-mac.c | 1477 +++++++++++++++++++++++++++ drivers/net/wireless/iwlegacy/Makefile | 3 +- drivers/net/wireless/iwlegacy/iwl-4965-rx.c | 215 ---- drivers/net/wireless/iwlegacy/iwl-4965-tx.c | 1371 ------------------------- 4 files changed, 1478 insertions(+), 1588 deletions(-) delete mode 100644 drivers/net/wireless/iwlegacy/iwl-4965-rx.c delete mode 100644 drivers/net/wireless/iwlegacy/iwl-4965-tx.c (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 142d39f94498..b6f96b4b1f5c 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -86,6 +86,1483 @@ MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); MODULE_LICENSE("GPL"); MODULE_ALIAS("iwl4965"); +void il4965_rx_missed_beacon_notif(struct il_priv *il, + struct il_rx_buf *rxb) + +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il_missed_beacon_notif *missed_beacon; + + missed_beacon = &pkt->u.missed_beacon; + if (le32_to_cpu(missed_beacon->consecutive_missed_beacons) > + il->missed_beacon_threshold) { + D_CALIB( + "missed bcn cnsq %d totl %d rcd %d expctd %d\n", + le32_to_cpu(missed_beacon->consecutive_missed_beacons), + le32_to_cpu(missed_beacon->total_missed_becons), + le32_to_cpu(missed_beacon->num_recvd_beacons), + le32_to_cpu(missed_beacon->num_expected_beacons)); + if (!test_bit(STATUS_SCANNING, &il->status)) + il4965_init_sensitivity(il); + } +} + +/* Calculate noise level, based on measurements during network silence just + * before arriving beacon. This measurement can be done only if we know + * exactly when to expect beacons, therefore only when we're associated. */ +static void il4965_rx_calc_noise(struct il_priv *il) +{ + struct stats_rx_non_phy *rx_info; + int num_active_rx = 0; + int total_silence = 0; + int bcn_silence_a, bcn_silence_b, bcn_silence_c; + int last_rx_noise; + + rx_info = &(il->_4965.stats.rx.general); + bcn_silence_a = + le32_to_cpu(rx_info->beacon_silence_rssi_a) & IN_BAND_FILTER; + bcn_silence_b = + le32_to_cpu(rx_info->beacon_silence_rssi_b) & IN_BAND_FILTER; + bcn_silence_c = + le32_to_cpu(rx_info->beacon_silence_rssi_c) & IN_BAND_FILTER; + + if (bcn_silence_a) { + total_silence += bcn_silence_a; + num_active_rx++; + } + if (bcn_silence_b) { + total_silence += bcn_silence_b; + num_active_rx++; + } + if (bcn_silence_c) { + total_silence += bcn_silence_c; + num_active_rx++; + } + + /* Average among active antennas */ + if (num_active_rx) + last_rx_noise = (total_silence / num_active_rx) - 107; + else + last_rx_noise = IL_NOISE_MEAS_NOT_AVAILABLE; + + D_CALIB("inband silence a %u, b %u, c %u, dBm %d\n", + bcn_silence_a, bcn_silence_b, bcn_silence_c, + last_rx_noise); +} + +#ifdef CONFIG_IWLEGACY_DEBUGFS +/* + * based on the assumption of all stats counter are in DWORD + * FIXME: This function is for debugging, do not deal with + * the case of counters roll-over. + */ +static void il4965_accumulative_stats(struct il_priv *il, + __le32 *stats) +{ + int i, size; + __le32 *prev_stats; + u32 *accum_stats; + u32 *delta, *max_delta; + struct stats_general_common *general, *accum_general; + struct stats_tx *tx, *accum_tx; + + prev_stats = (__le32 *)&il->_4965.stats; + accum_stats = (u32 *)&il->_4965.accum_stats; + size = sizeof(struct il_notif_stats); + general = &il->_4965.stats.general.common; + accum_general = &il->_4965.accum_stats.general.common; + tx = &il->_4965.stats.tx; + accum_tx = &il->_4965.accum_stats.tx; + delta = (u32 *)&il->_4965.delta_stats; + max_delta = (u32 *)&il->_4965.max_delta; + + for (i = sizeof(__le32); i < size; + i += sizeof(__le32), stats++, prev_stats++, delta++, + max_delta++, accum_stats++) { + if (le32_to_cpu(*stats) > le32_to_cpu(*prev_stats)) { + *delta = (le32_to_cpu(*stats) - + le32_to_cpu(*prev_stats)); + *accum_stats += *delta; + if (*delta > *max_delta) + *max_delta = *delta; + } + } + + /* reset accumulative stats for "no-counter" type stats */ + accum_general->temperature = general->temperature; + accum_general->ttl_timestamp = general->ttl_timestamp; +} +#endif + +#define REG_RECALIB_PERIOD (60) + +void il4965_rx_stats(struct il_priv *il, + struct il_rx_buf *rxb) +{ + int change; + struct il_rx_pkt *pkt = rxb_addr(rxb); + + D_RX( + "Statistics notification received (%d vs %d).\n", + (int)sizeof(struct il_notif_stats), + le32_to_cpu(pkt->len_n_flags) & + FH_RSCSR_FRAME_SIZE_MSK); + + change = ((il->_4965.stats.general.common.temperature != + pkt->u.stats.general.common.temperature) || + ((il->_4965.stats.flag & + STATISTICS_REPLY_FLG_HT40_MODE_MSK) != + (pkt->u.stats.flag & + STATISTICS_REPLY_FLG_HT40_MODE_MSK))); +#ifdef CONFIG_IWLEGACY_DEBUGFS + il4965_accumulative_stats(il, (__le32 *)&pkt->u.stats); +#endif + + /* TODO: reading some of stats is unneeded */ + memcpy(&il->_4965.stats, &pkt->u.stats, + sizeof(il->_4965.stats)); + + set_bit(STATUS_STATISTICS, &il->status); + + /* Reschedule the stats timer to occur in + * REG_RECALIB_PERIOD seconds to ensure we get a + * thermal update even if the uCode doesn't give + * us one */ + mod_timer(&il->stats_periodic, jiffies + + msecs_to_jiffies(REG_RECALIB_PERIOD * 1000)); + + if (unlikely(!test_bit(STATUS_SCANNING, &il->status)) && + (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) { + il4965_rx_calc_noise(il); + queue_work(il->workqueue, &il->run_time_calib_work); + } + if (il->cfg->ops->lib->temp_ops.temperature && change) + il->cfg->ops->lib->temp_ops.temperature(il); +} + +void il4965_reply_stats(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + + if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATISTICS_CLEAR_MSK) { +#ifdef CONFIG_IWLEGACY_DEBUGFS + memset(&il->_4965.accum_stats, 0, + sizeof(struct il_notif_stats)); + memset(&il->_4965.delta_stats, 0, + sizeof(struct il_notif_stats)); + memset(&il->_4965.max_delta, 0, + sizeof(struct il_notif_stats)); +#endif + D_RX("Statistics have been cleared\n"); + } + il4965_rx_stats(il, rxb); +} + +static const u8 tid_to_ac[] = { + IEEE80211_AC_BE, + IEEE80211_AC_BK, + IEEE80211_AC_BK, + IEEE80211_AC_BE, + IEEE80211_AC_VI, + IEEE80211_AC_VI, + IEEE80211_AC_VO, + IEEE80211_AC_VO +}; + +static inline int il4965_get_ac_from_tid(u16 tid) +{ + if (likely(tid < ARRAY_SIZE(tid_to_ac))) + return tid_to_ac[tid]; + + /* no support for TIDs 8-15 yet */ + return -EINVAL; +} + +static inline int +il4965_get_fifo_from_tid(struct il_rxon_context *ctx, u16 tid) +{ + if (likely(tid < ARRAY_SIZE(tid_to_ac))) + return ctx->ac_to_fifo[tid_to_ac[tid]]; + + /* no support for TIDs 8-15 yet */ + return -EINVAL; +} + +/* + * handle build REPLY_TX command notification. + */ +static void il4965_tx_cmd_build_basic(struct il_priv *il, + struct sk_buff *skb, + struct il_tx_cmd *tx_cmd, + struct ieee80211_tx_info *info, + struct ieee80211_hdr *hdr, + u8 std_id) +{ + __le16 fc = hdr->frame_control; + __le32 tx_flags = tx_cmd->tx_flags; + + tx_cmd->stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; + if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) { + tx_flags |= TX_CMD_FLG_ACK_MSK; + if (ieee80211_is_mgmt(fc)) + tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; + if (ieee80211_is_probe_resp(fc) && + !(le16_to_cpu(hdr->seq_ctrl) & 0xf)) + tx_flags |= TX_CMD_FLG_TSF_MSK; + } else { + tx_flags &= (~TX_CMD_FLG_ACK_MSK); + tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; + } + + if (ieee80211_is_back_req(fc)) + tx_flags |= TX_CMD_FLG_ACK_MSK | TX_CMD_FLG_IMM_BA_RSP_MASK; + + tx_cmd->sta_id = std_id; + if (ieee80211_has_morefrags(fc)) + tx_flags |= TX_CMD_FLG_MORE_FRAG_MSK; + + if (ieee80211_is_data_qos(fc)) { + u8 *qc = ieee80211_get_qos_ctl(hdr); + tx_cmd->tid_tspec = qc[0] & 0xf; + tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK; + } else { + tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; + } + + il_tx_cmd_protection(il, info, fc, &tx_flags); + + tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); + if (ieee80211_is_mgmt(fc)) { + if (ieee80211_is_assoc_req(fc) || ieee80211_is_reassoc_req(fc)) + tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(3); + else + tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(2); + } else { + tx_cmd->timeout.pm_frame_timeout = 0; + } + + tx_cmd->driver_txop = 0; + tx_cmd->tx_flags = tx_flags; + tx_cmd->next_frame_len = 0; +} + +#define RTS_DFAULT_RETRY_LIMIT 60 + +static void il4965_tx_cmd_build_rate(struct il_priv *il, + struct il_tx_cmd *tx_cmd, + struct ieee80211_tx_info *info, + __le16 fc) +{ + u32 rate_flags; + int rate_idx; + u8 rts_retry_limit; + u8 data_retry_limit; + u8 rate_plcp; + + /* Set retry limit on DATA packets and Probe Responses*/ + if (ieee80211_is_probe_resp(fc)) + data_retry_limit = 3; + else + data_retry_limit = IL4965_DEFAULT_TX_RETRY; + tx_cmd->data_retry_limit = data_retry_limit; + + /* Set retry limit on RTS packets */ + rts_retry_limit = RTS_DFAULT_RETRY_LIMIT; + if (data_retry_limit < rts_retry_limit) + rts_retry_limit = data_retry_limit; + tx_cmd->rts_retry_limit = rts_retry_limit; + + /* DATA packets will use the uCode station table for rate/antenna + * selection */ + if (ieee80211_is_data(fc)) { + tx_cmd->initial_rate_idx = 0; + tx_cmd->tx_flags |= TX_CMD_FLG_STA_RATE_MSK; + return; + } + + /** + * If the current TX rate stored in mac80211 has the MCS bit set, it's + * not really a TX rate. Thus, we use the lowest supported rate for + * this band. Also use the lowest supported rate if the stored rate + * idx is invalid. + */ + rate_idx = info->control.rates[0].idx; + if ((info->control.rates[0].flags & IEEE80211_TX_RC_MCS) || + rate_idx < 0 || rate_idx > RATE_COUNT_LEGACY) + rate_idx = rate_lowest_index(&il->bands[info->band], + info->control.sta); + /* For 5 GHZ band, remap mac80211 rate indices into driver indices */ + if (info->band == IEEE80211_BAND_5GHZ) + rate_idx += IL_FIRST_OFDM_RATE; + /* Get PLCP rate for tx_cmd->rate_n_flags */ + rate_plcp = il_rates[rate_idx].plcp; + /* Zero out flags for this packet */ + rate_flags = 0; + + /* Set CCK flag as needed */ + if (rate_idx >= IL_FIRST_CCK_RATE && rate_idx <= IL_LAST_CCK_RATE) + rate_flags |= RATE_MCS_CCK_MSK; + + /* Set up antennas */ + il->mgmt_tx_ant = il4965_toggle_tx_ant(il, il->mgmt_tx_ant, + il->hw_params.valid_tx_ant); + + rate_flags |= il4965_ant_idx_to_flags(il->mgmt_tx_ant); + + /* Set the rate in the TX cmd */ + tx_cmd->rate_n_flags = il4965_hw_set_rate_n_flags(rate_plcp, rate_flags); +} + +static void il4965_tx_cmd_build_hwcrypto(struct il_priv *il, + struct ieee80211_tx_info *info, + struct il_tx_cmd *tx_cmd, + struct sk_buff *skb_frag, + int sta_id) +{ + struct ieee80211_key_conf *keyconf = info->control.hw_key; + + switch (keyconf->cipher) { + case WLAN_CIPHER_SUITE_CCMP: + tx_cmd->sec_ctl = TX_CMD_SEC_CCM; + memcpy(tx_cmd->key, keyconf->key, keyconf->keylen); + if (info->flags & IEEE80211_TX_CTL_AMPDU) + tx_cmd->tx_flags |= TX_CMD_FLG_AGG_CCMP_MSK; + D_TX("tx_cmd with AES hwcrypto\n"); + break; + + case WLAN_CIPHER_SUITE_TKIP: + tx_cmd->sec_ctl = TX_CMD_SEC_TKIP; + ieee80211_get_tkip_p2k(keyconf, skb_frag, tx_cmd->key); + D_TX("tx_cmd with tkip hwcrypto\n"); + break; + + case WLAN_CIPHER_SUITE_WEP104: + tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128; + /* fall through */ + case WLAN_CIPHER_SUITE_WEP40: + tx_cmd->sec_ctl |= (TX_CMD_SEC_WEP | + (keyconf->keyidx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT); + + memcpy(&tx_cmd->key[3], keyconf->key, keyconf->keylen); + + D_TX("Configuring packet for WEP encryption " + "with key %d\n", keyconf->keyidx); + break; + + default: + IL_ERR("Unknown encode cipher %x\n", keyconf->cipher); + break; + } +} + +/* + * start REPLY_TX command process + */ +int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) +{ + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct ieee80211_sta *sta = info->control.sta; + struct il_station_priv *sta_priv = NULL; + struct il_tx_queue *txq; + struct il_queue *q; + struct il_device_cmd *out_cmd; + struct il_cmd_meta *out_meta; + struct il_tx_cmd *tx_cmd; + struct il_rxon_context *ctx = &il->ctx; + int txq_id; + dma_addr_t phys_addr; + dma_addr_t txcmd_phys; + dma_addr_t scratch_phys; + u16 len, firstlen, secondlen; + u16 seq_number = 0; + __le16 fc; + u8 hdr_len; + u8 sta_id; + u8 wait_write_ptr = 0; + u8 tid = 0; + u8 *qc = NULL; + unsigned long flags; + bool is_agg = false; + + if (info->control.vif) + ctx = il_rxon_ctx_from_vif(info->control.vif); + + spin_lock_irqsave(&il->lock, flags); + if (il_is_rfkill(il)) { + D_DROP("Dropping - RF KILL\n"); + goto drop_unlock; + } + + fc = hdr->frame_control; + +#ifdef CONFIG_IWLEGACY_DEBUG + if (ieee80211_is_auth(fc)) + D_TX("Sending AUTH frame\n"); + else if (ieee80211_is_assoc_req(fc)) + D_TX("Sending ASSOC frame\n"); + else if (ieee80211_is_reassoc_req(fc)) + D_TX("Sending REASSOC frame\n"); +#endif + + hdr_len = ieee80211_hdrlen(fc); + + /* For management frames use broadcast id to do not break aggregation */ + if (!ieee80211_is_data(fc)) + sta_id = ctx->bcast_sta_id; + else { + /* Find idx into station table for destination station */ + sta_id = il_sta_id_or_broadcast(il, ctx, info->control.sta); + + if (sta_id == IL_INVALID_STATION) { + D_DROP("Dropping - INVALID STATION: %pM\n", + hdr->addr1); + goto drop_unlock; + } + } + + D_TX("station Id %d\n", sta_id); + + if (sta) + sta_priv = (void *)sta->drv_priv; + + if (sta_priv && sta_priv->asleep && + (info->flags & IEEE80211_TX_CTL_POLL_RESPONSE)) { + /* + * This sends an asynchronous command to the device, + * but we can rely on it being processed before the + * next frame is processed -- and the next frame to + * this station is the one that will consume this + * counter. + * For now set the counter to just 1 since we do not + * support uAPSD yet. + */ + il4965_sta_modify_sleep_tx_count(il, sta_id, 1); + } + + /* + * Send this frame after DTIM -- there's a special queue + * reserved for this for contexts that support AP mode. + */ + if (info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) { + txq_id = ctx->mcast_queue; + /* + * The microcode will clear the more data + * bit in the last frame it transmits. + */ + hdr->frame_control |= + cpu_to_le16(IEEE80211_FCTL_MOREDATA); + } else + txq_id = ctx->ac_to_queue[skb_get_queue_mapping(skb)]; + + /* irqs already disabled/saved above when locking il->lock */ + spin_lock(&il->sta_lock); + + if (ieee80211_is_data_qos(fc)) { + qc = ieee80211_get_qos_ctl(hdr); + tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK; + if (WARN_ON_ONCE(tid >= MAX_TID_COUNT)) { + spin_unlock(&il->sta_lock); + goto drop_unlock; + } + seq_number = il->stations[sta_id].tid[tid].seq_number; + seq_number &= IEEE80211_SCTL_SEQ; + hdr->seq_ctrl = hdr->seq_ctrl & + cpu_to_le16(IEEE80211_SCTL_FRAG); + hdr->seq_ctrl |= cpu_to_le16(seq_number); + seq_number += 0x10; + /* aggregation is on for this */ + if (info->flags & IEEE80211_TX_CTL_AMPDU && + il->stations[sta_id].tid[tid].agg.state == IL_AGG_ON) { + txq_id = il->stations[sta_id].tid[tid].agg.txq_id; + is_agg = true; + } + } + + txq = &il->txq[txq_id]; + q = &txq->q; + + if (unlikely(il_queue_space(q) < q->high_mark)) { + spin_unlock(&il->sta_lock); + goto drop_unlock; + } + + if (ieee80211_is_data_qos(fc)) { + il->stations[sta_id].tid[tid].tfds_in_queue++; + if (!ieee80211_has_morefrags(fc)) + il->stations[sta_id].tid[tid].seq_number = seq_number; + } + + spin_unlock(&il->sta_lock); + + /* Set up driver data for this TFD */ + memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct il_tx_info)); + txq->txb[q->write_ptr].skb = skb; + txq->txb[q->write_ptr].ctx = ctx; + + /* Set up first empty entry in queue's array of Tx/cmd buffers */ + out_cmd = txq->cmd[q->write_ptr]; + out_meta = &txq->meta[q->write_ptr]; + tx_cmd = &out_cmd->cmd.tx; + memset(&out_cmd->hdr, 0, sizeof(out_cmd->hdr)); + memset(tx_cmd, 0, sizeof(struct il_tx_cmd)); + + /* + * Set up the Tx-command (not MAC!) header. + * Store the chosen Tx queue and TFD idx within the sequence field; + * after Tx, uCode's Tx response will return this value so driver can + * locate the frame within the tx queue and do post-tx processing. + */ + out_cmd->hdr.cmd = REPLY_TX; + out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | + IDX_TO_SEQ(q->write_ptr))); + + /* Copy MAC header from skb into command buffer */ + memcpy(tx_cmd->hdr, hdr, hdr_len); + + + /* Total # bytes to be transmitted */ + len = (u16)skb->len; + tx_cmd->len = cpu_to_le16(len); + + if (info->control.hw_key) + il4965_tx_cmd_build_hwcrypto(il, info, tx_cmd, skb, sta_id); + + /* TODO need this for burst mode later on */ + il4965_tx_cmd_build_basic(il, skb, tx_cmd, info, hdr, sta_id); + il_dbg_log_tx_data_frame(il, len, hdr); + + il4965_tx_cmd_build_rate(il, tx_cmd, info, fc); + + il_update_stats(il, true, fc, len); + /* + * Use the first empty entry in this queue's command buffer array + * to contain the Tx command and MAC header concatenated together + * (payload data will be in another buffer). + * Size of this varies, due to varying MAC header length. + * If end is not dword aligned, we'll have 2 extra bytes at the end + * of the MAC header (device reads on dword boundaries). + * We'll tell device about this padding later. + */ + len = sizeof(struct il_tx_cmd) + + sizeof(struct il_cmd_header) + hdr_len; + firstlen = (len + 3) & ~3; + + /* Tell NIC about any 2-byte padding after MAC header */ + if (firstlen != len) + tx_cmd->tx_flags |= TX_CMD_FLG_MH_PAD_MSK; + + /* Physical address of this Tx command's header (not MAC header!), + * within command buffer array. */ + txcmd_phys = pci_map_single(il->pci_dev, + &out_cmd->hdr, firstlen, + PCI_DMA_BIDIRECTIONAL); + dma_unmap_addr_set(out_meta, mapping, txcmd_phys); + dma_unmap_len_set(out_meta, len, firstlen); + /* Add buffer containing Tx command and MAC(!) header to TFD's + * first entry */ + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, + txcmd_phys, firstlen, 1, 0); + + if (!ieee80211_has_morefrags(hdr->frame_control)) { + txq->need_update = 1; + } else { + wait_write_ptr = 1; + txq->need_update = 0; + } + + /* Set up TFD's 2nd entry to point directly to remainder of skb, + * if any (802.11 null frames have no payload). */ + secondlen = skb->len - hdr_len; + if (secondlen > 0) { + phys_addr = pci_map_single(il->pci_dev, skb->data + hdr_len, + secondlen, PCI_DMA_TODEVICE); + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, + phys_addr, secondlen, + 0, 0); + } + + scratch_phys = txcmd_phys + sizeof(struct il_cmd_header) + + offsetof(struct il_tx_cmd, scratch); + + /* take back ownership of DMA buffer to enable update */ + pci_dma_sync_single_for_cpu(il->pci_dev, txcmd_phys, + firstlen, PCI_DMA_BIDIRECTIONAL); + tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys); + tx_cmd->dram_msb_ptr = il_get_dma_hi_addr(scratch_phys); + + D_TX("sequence nr = 0X%x\n", + le16_to_cpu(out_cmd->hdr.sequence)); + D_TX("tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); + il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd, sizeof(*tx_cmd)); + il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd->hdr, hdr_len); + + /* Set up entry for this TFD in Tx byte-count array */ + if (info->flags & IEEE80211_TX_CTL_AMPDU) + il->cfg->ops->lib->txq_update_byte_cnt_tbl(il, txq, + le16_to_cpu(tx_cmd->len)); + + pci_dma_sync_single_for_device(il->pci_dev, txcmd_phys, + firstlen, PCI_DMA_BIDIRECTIONAL); + + /* Tell device the write idx *just past* this latest filled TFD */ + q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); + il_txq_update_write_ptr(il, txq); + spin_unlock_irqrestore(&il->lock, flags); + + /* + * At this point the frame is "transmitted" successfully + * and we will get a TX status notification eventually, + * regardless of the value of ret. "ret" only indicates + * whether or not we should update the write pointer. + */ + + /* + * Avoid atomic ops if it isn't an associated client. + * Also, if this is a packet for aggregation, don't + * increase the counter because the ucode will stop + * aggregation queues when their respective station + * goes to sleep. + */ + if (sta_priv && sta_priv->client && !is_agg) + atomic_inc(&sta_priv->pending_frames); + + if (il_queue_space(q) < q->high_mark && il->mac80211_registered) { + if (wait_write_ptr) { + spin_lock_irqsave(&il->lock, flags); + txq->need_update = 1; + il_txq_update_write_ptr(il, txq); + spin_unlock_irqrestore(&il->lock, flags); + } else { + il_stop_queue(il, txq); + } + } + + return 0; + +drop_unlock: + spin_unlock_irqrestore(&il->lock, flags); + return -1; +} + +static inline int il4965_alloc_dma_ptr(struct il_priv *il, + struct il_dma_ptr *ptr, size_t size) +{ + ptr->addr = dma_alloc_coherent(&il->pci_dev->dev, size, &ptr->dma, + GFP_KERNEL); + if (!ptr->addr) + return -ENOMEM; + ptr->size = size; + return 0; +} + +static inline void il4965_free_dma_ptr(struct il_priv *il, + struct il_dma_ptr *ptr) +{ + if (unlikely(!ptr->addr)) + return; + + dma_free_coherent(&il->pci_dev->dev, ptr->size, ptr->addr, ptr->dma); + memset(ptr, 0, sizeof(*ptr)); +} + +/** + * il4965_hw_txq_ctx_free - Free TXQ Context + * + * Destroy all TX DMA queues and structures + */ +void il4965_hw_txq_ctx_free(struct il_priv *il) +{ + int txq_id; + + /* Tx queues */ + if (il->txq) { + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) + if (txq_id == il->cmd_queue) + il_cmd_queue_free(il); + else + il_tx_queue_free(il, txq_id); + } + il4965_free_dma_ptr(il, &il->kw); + + il4965_free_dma_ptr(il, &il->scd_bc_tbls); + + /* free tx queue structure */ + il_txq_mem(il); +} + +/** + * il4965_txq_ctx_alloc - allocate TX queue context + * Allocate all Tx DMA structures and initialize them + * + * @param il + * @return error code + */ +int il4965_txq_ctx_alloc(struct il_priv *il) +{ + int ret; + int txq_id, slots_num; + unsigned long flags; + + /* Free all tx/cmd queues and keep-warm buffer */ + il4965_hw_txq_ctx_free(il); + + ret = il4965_alloc_dma_ptr(il, &il->scd_bc_tbls, + il->hw_params.scd_bc_tbls_size); + if (ret) { + IL_ERR("Scheduler BC Table allocation failed\n"); + goto error_bc_tbls; + } + /* Alloc keep-warm buffer */ + ret = il4965_alloc_dma_ptr(il, &il->kw, IL_KW_SIZE); + if (ret) { + IL_ERR("Keep Warm allocation failed\n"); + goto error_kw; + } + + /* allocate tx queue structure */ + ret = il_alloc_txq_mem(il); + if (ret) + goto error; + + spin_lock_irqsave(&il->lock, flags); + + /* Turn off all Tx DMA fifos */ + il4965_txq_set_sched(il, 0); + + /* Tell NIC where to find the "keep warm" buffer */ + il_wr(il, FH_KW_MEM_ADDR_REG, il->kw.dma >> 4); + + spin_unlock_irqrestore(&il->lock, flags); + + /* Alloc and init all Tx queues, including the command queue (#4/#9) */ + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { + slots_num = (txq_id == il->cmd_queue) ? + TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; + ret = il_tx_queue_init(il, + &il->txq[txq_id], slots_num, + txq_id); + if (ret) { + IL_ERR("Tx %d queue init failed\n", txq_id); + goto error; + } + } + + return ret; + + error: + il4965_hw_txq_ctx_free(il); + il4965_free_dma_ptr(il, &il->kw); + error_kw: + il4965_free_dma_ptr(il, &il->scd_bc_tbls); + error_bc_tbls: + return ret; +} + +void il4965_txq_ctx_reset(struct il_priv *il) +{ + int txq_id, slots_num; + unsigned long flags; + + spin_lock_irqsave(&il->lock, flags); + + /* Turn off all Tx DMA fifos */ + il4965_txq_set_sched(il, 0); + + /* Tell NIC where to find the "keep warm" buffer */ + il_wr(il, FH_KW_MEM_ADDR_REG, il->kw.dma >> 4); + + spin_unlock_irqrestore(&il->lock, flags); + + /* Alloc and init all Tx queues, including the command queue (#4) */ + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { + slots_num = txq_id == il->cmd_queue ? + TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; + il_tx_queue_reset(il, &il->txq[txq_id], + slots_num, txq_id); + } +} + +/** + * il4965_txq_ctx_stop - Stop all Tx DMA channels + */ +void il4965_txq_ctx_stop(struct il_priv *il) +{ + int ch, txq_id; + unsigned long flags; + + /* Turn off all Tx DMA fifos */ + spin_lock_irqsave(&il->lock, flags); + + il4965_txq_set_sched(il, 0); + + /* Stop each Tx DMA channel, and wait for it to be idle */ + for (ch = 0; ch < il->hw_params.dma_chnl_num; ch++) { + il_wr(il, + FH_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0); + if (il_poll_bit(il, FH_TSSR_TX_STATUS_REG, + FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), + 1000)) + IL_ERR("Failing on timeout while stopping" + " DMA channel %d [0x%08x]", ch, + il_rd(il, + FH_TSSR_TX_STATUS_REG)); + } + spin_unlock_irqrestore(&il->lock, flags); + + if (!il->txq) + return; + + /* Unmap DMA from host system and free skb's */ + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) + if (txq_id == il->cmd_queue) + il_cmd_queue_unmap(il); + else + il_tx_queue_unmap(il, txq_id); +} + +/* + * Find first available (lowest unused) Tx Queue, mark it "active". + * Called only when finding queue for aggregation. + * Should never return anything < 7, because they should already + * be in use as EDCA AC (0-3), Command (4), reserved (5, 6) + */ +static int il4965_txq_ctx_activate_free(struct il_priv *il) +{ + int txq_id; + + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) + if (!test_and_set_bit(txq_id, &il->txq_ctx_active_msk)) + return txq_id; + return -1; +} + +/** + * il4965_tx_queue_stop_scheduler - Stop queue, but keep configuration + */ +static void il4965_tx_queue_stop_scheduler(struct il_priv *il, + u16 txq_id) +{ + /* Simply stop the queue, but don't change any configuration; + * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */ + il_wr_prph(il, + IL49_SCD_QUEUE_STATUS_BITS(txq_id), + (0 << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE)| + (1 << IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); +} + +/** + * il4965_tx_queue_set_q2ratid - Map unique receiver/tid combination to a queue + */ +static int il4965_tx_queue_set_q2ratid(struct il_priv *il, u16 ra_tid, + u16 txq_id) +{ + u32 tbl_dw_addr; + u32 tbl_dw; + u16 scd_q2ratid; + + scd_q2ratid = ra_tid & IL_SCD_QUEUE_RA_TID_MAP_RATID_MSK; + + tbl_dw_addr = il->scd_base_addr + + IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id); + + tbl_dw = il_read_targ_mem(il, tbl_dw_addr); + + if (txq_id & 0x1) + tbl_dw = (scd_q2ratid << 16) | (tbl_dw & 0x0000FFFF); + else + tbl_dw = scd_q2ratid | (tbl_dw & 0xFFFF0000); + + il_write_targ_mem(il, tbl_dw_addr, tbl_dw); + + return 0; +} + +/** + * il4965_tx_queue_agg_enable - Set up & enable aggregation for selected queue + * + * NOTE: txq_id must be greater than IL49_FIRST_AMPDU_QUEUE, + * i.e. it must be one of the higher queues used for aggregation + */ +static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, + int tx_fifo, int sta_id, int tid, u16 ssn_idx) +{ + unsigned long flags; + u16 ra_tid; + int ret; + + if ((IL49_FIRST_AMPDU_QUEUE > txq_id) || + (IL49_FIRST_AMPDU_QUEUE + + il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { + IL_WARN( + "queue number out of range: %d, must be %d to %d\n", + txq_id, IL49_FIRST_AMPDU_QUEUE, + IL49_FIRST_AMPDU_QUEUE + + il->cfg->base_params->num_of_ampdu_queues - 1); + return -EINVAL; + } + + ra_tid = BUILD_RAxTID(sta_id, tid); + + /* Modify device's station table to Tx this TID */ + ret = il4965_sta_tx_modify_enable_tid(il, sta_id, tid); + if (ret) + return ret; + + spin_lock_irqsave(&il->lock, flags); + + /* Stop this Tx queue before configuring it */ + il4965_tx_queue_stop_scheduler(il, txq_id); + + /* Map receiver-address / traffic-ID to this queue */ + il4965_tx_queue_set_q2ratid(il, ra_tid, txq_id); + + /* Set this queue as a chain-building queue */ + il_set_bits_prph(il, IL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); + + /* Place first TFD at idx corresponding to start sequence number. + * Assumes that ssn_idx is valid (!= 0xFFF) */ + il->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); + il->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); + il4965_set_wr_ptrs(il, txq_id, ssn_idx); + + /* Set up Tx win size and frame limit for this queue */ + il_write_targ_mem(il, + il->scd_base_addr + IL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id), + (SCD_WIN_SIZE << IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & + IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); + + il_write_targ_mem(il, il->scd_base_addr + + IL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id) + sizeof(u32), + (SCD_FRAME_LIMIT << IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) + & IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); + + il_set_bits_prph(il, IL49_SCD_INTERRUPT_MASK, (1 << txq_id)); + + /* Set up Status area in SRAM, map to Tx DMA/FIFO, activate the queue */ + il4965_tx_queue_set_status(il, &il->txq[txq_id], tx_fifo, 1); + + spin_unlock_irqrestore(&il->lock, flags); + + return 0; +} + + +int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, + struct ieee80211_sta *sta, u16 tid, u16 *ssn) +{ + int sta_id; + int tx_fifo; + int txq_id; + int ret; + unsigned long flags; + struct il_tid_data *tid_data; + + tx_fifo = il4965_get_fifo_from_tid(il_rxon_ctx_from_vif(vif), tid); + if (unlikely(tx_fifo < 0)) + return tx_fifo; + + IL_WARN("%s on ra = %pM tid = %d\n", + __func__, sta->addr, tid); + + sta_id = il_sta_id(sta); + if (sta_id == IL_INVALID_STATION) { + IL_ERR("Start AGG on invalid station\n"); + return -ENXIO; + } + if (unlikely(tid >= MAX_TID_COUNT)) + return -EINVAL; + + if (il->stations[sta_id].tid[tid].agg.state != IL_AGG_OFF) { + IL_ERR("Start AGG when state is not IL_AGG_OFF !\n"); + return -ENXIO; + } + + txq_id = il4965_txq_ctx_activate_free(il); + if (txq_id == -1) { + IL_ERR("No free aggregation queue available\n"); + return -ENXIO; + } + + spin_lock_irqsave(&il->sta_lock, flags); + tid_data = &il->stations[sta_id].tid[tid]; + *ssn = SEQ_TO_SN(tid_data->seq_number); + tid_data->agg.txq_id = txq_id; + il_set_swq_id(&il->txq[txq_id], + il4965_get_ac_from_tid(tid), txq_id); + spin_unlock_irqrestore(&il->sta_lock, flags); + + ret = il4965_txq_agg_enable(il, txq_id, tx_fifo, + sta_id, tid, *ssn); + if (ret) + return ret; + + spin_lock_irqsave(&il->sta_lock, flags); + tid_data = &il->stations[sta_id].tid[tid]; + if (tid_data->tfds_in_queue == 0) { + D_HT("HW queue is empty\n"); + tid_data->agg.state = IL_AGG_ON; + ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid); + } else { + D_HT( + "HW queue is NOT empty: %d packets in HW queue\n", + tid_data->tfds_in_queue); + tid_data->agg.state = IL_EMPTYING_HW_QUEUE_ADDBA; + } + spin_unlock_irqrestore(&il->sta_lock, flags); + return ret; +} + +/** + * txq_id must be greater than IL49_FIRST_AMPDU_QUEUE + * il->lock must be held by the caller + */ +static int il4965_txq_agg_disable(struct il_priv *il, u16 txq_id, + u16 ssn_idx, u8 tx_fifo) +{ + if ((IL49_FIRST_AMPDU_QUEUE > txq_id) || + (IL49_FIRST_AMPDU_QUEUE + + il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { + IL_WARN( + "queue number out of range: %d, must be %d to %d\n", + txq_id, IL49_FIRST_AMPDU_QUEUE, + IL49_FIRST_AMPDU_QUEUE + + il->cfg->base_params->num_of_ampdu_queues - 1); + return -EINVAL; + } + + il4965_tx_queue_stop_scheduler(il, txq_id); + + il_clear_bits_prph(il, + IL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); + + il->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); + il->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); + /* supposes that ssn_idx is valid (!= 0xFFF) */ + il4965_set_wr_ptrs(il, txq_id, ssn_idx); + + il_clear_bits_prph(il, + IL49_SCD_INTERRUPT_MASK, (1 << txq_id)); + il_txq_ctx_deactivate(il, txq_id); + il4965_tx_queue_set_status(il, &il->txq[txq_id], tx_fifo, 0); + + return 0; +} + +int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, + struct ieee80211_sta *sta, u16 tid) +{ + int tx_fifo_id, txq_id, sta_id, ssn; + struct il_tid_data *tid_data; + int write_ptr, read_ptr; + unsigned long flags; + + tx_fifo_id = il4965_get_fifo_from_tid(il_rxon_ctx_from_vif(vif), tid); + if (unlikely(tx_fifo_id < 0)) + return tx_fifo_id; + + sta_id = il_sta_id(sta); + + if (sta_id == IL_INVALID_STATION) { + IL_ERR("Invalid station for AGG tid %d\n", tid); + return -ENXIO; + } + + spin_lock_irqsave(&il->sta_lock, flags); + + tid_data = &il->stations[sta_id].tid[tid]; + ssn = (tid_data->seq_number & IEEE80211_SCTL_SEQ) >> 4; + txq_id = tid_data->agg.txq_id; + + switch (il->stations[sta_id].tid[tid].agg.state) { + case IL_EMPTYING_HW_QUEUE_ADDBA: + /* + * This can happen if the peer stops aggregation + * again before we've had a chance to drain the + * queue we selected previously, i.e. before the + * session was really started completely. + */ + D_HT("AGG stop before setup done\n"); + goto turn_off; + case IL_AGG_ON: + break; + default: + IL_WARN("Stopping AGG while state not ON or starting\n"); + } + + write_ptr = il->txq[txq_id].q.write_ptr; + read_ptr = il->txq[txq_id].q.read_ptr; + + /* The queue is not empty */ + if (write_ptr != read_ptr) { + D_HT("Stopping a non empty AGG HW QUEUE\n"); + il->stations[sta_id].tid[tid].agg.state = + IL_EMPTYING_HW_QUEUE_DELBA; + spin_unlock_irqrestore(&il->sta_lock, flags); + return 0; + } + + D_HT("HW queue is empty\n"); + turn_off: + il->stations[sta_id].tid[tid].agg.state = IL_AGG_OFF; + + /* do not restore/save irqs */ + spin_unlock(&il->sta_lock); + spin_lock(&il->lock); + + /* + * the only reason this call can fail is queue number out of range, + * which can happen if uCode is reloaded and all the station + * information are lost. if it is outside the range, there is no need + * to deactivate the uCode queue, just return "success" to allow + * mac80211 to clean up it own data. + */ + il4965_txq_agg_disable(il, txq_id, ssn, tx_fifo_id); + spin_unlock_irqrestore(&il->lock, flags); + + ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); + + return 0; +} + +int il4965_txq_check_empty(struct il_priv *il, + int sta_id, u8 tid, int txq_id) +{ + struct il_queue *q = &il->txq[txq_id].q; + u8 *addr = il->stations[sta_id].sta.sta.addr; + struct il_tid_data *tid_data = &il->stations[sta_id].tid[tid]; + struct il_rxon_context *ctx; + + ctx = &il->ctx; + + lockdep_assert_held(&il->sta_lock); + + switch (il->stations[sta_id].tid[tid].agg.state) { + case IL_EMPTYING_HW_QUEUE_DELBA: + /* We are reclaiming the last packet of the */ + /* aggregated HW queue */ + if (txq_id == tid_data->agg.txq_id && + q->read_ptr == q->write_ptr) { + u16 ssn = SEQ_TO_SN(tid_data->seq_number); + int tx_fifo = il4965_get_fifo_from_tid(ctx, tid); + D_HT( + "HW queue empty: continue DELBA flow\n"); + il4965_txq_agg_disable(il, txq_id, ssn, tx_fifo); + tid_data->agg.state = IL_AGG_OFF; + ieee80211_stop_tx_ba_cb_irqsafe(ctx->vif, addr, tid); + } + break; + case IL_EMPTYING_HW_QUEUE_ADDBA: + /* We are reclaiming the last packet of the queue */ + if (tid_data->tfds_in_queue == 0) { + D_HT( + "HW queue empty: continue ADDBA flow\n"); + tid_data->agg.state = IL_AGG_ON; + ieee80211_start_tx_ba_cb_irqsafe(ctx->vif, addr, tid); + } + break; + } + + return 0; +} + +static void il4965_non_agg_tx_status(struct il_priv *il, + struct il_rxon_context *ctx, + const u8 *addr1) +{ + struct ieee80211_sta *sta; + struct il_station_priv *sta_priv; + + rcu_read_lock(); + sta = ieee80211_find_sta(ctx->vif, addr1); + if (sta) { + sta_priv = (void *)sta->drv_priv; + /* avoid atomic ops if this isn't a client */ + if (sta_priv->client && + atomic_dec_return(&sta_priv->pending_frames) == 0) + ieee80211_sta_block_awake(il->hw, sta, false); + } + rcu_read_unlock(); +} + +static void +il4965_tx_status(struct il_priv *il, struct il_tx_info *tx_info, + bool is_agg) +{ + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx_info->skb->data; + + if (!is_agg) + il4965_non_agg_tx_status(il, tx_info->ctx, hdr->addr1); + + ieee80211_tx_status_irqsafe(il->hw, tx_info->skb); +} + +int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx) +{ + struct il_tx_queue *txq = &il->txq[txq_id]; + struct il_queue *q = &txq->q; + struct il_tx_info *tx_info; + int nfreed = 0; + struct ieee80211_hdr *hdr; + + if (idx >= q->n_bd || il_queue_used(q, idx) == 0) { + IL_ERR("Read idx for DMA queue txq id (%d), idx %d, " + "is out of range [0-%d] %d %d.\n", txq_id, + idx, q->n_bd, q->write_ptr, q->read_ptr); + return 0; + } + + for (idx = il_queue_inc_wrap(idx, q->n_bd); + q->read_ptr != idx; + q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { + + tx_info = &txq->txb[txq->q.read_ptr]; + + if (WARN_ON_ONCE(tx_info->skb == NULL)) + continue; + + hdr = (struct ieee80211_hdr *)tx_info->skb->data; + if (ieee80211_is_data_qos(hdr->frame_control)) + nfreed++; + + il4965_tx_status(il, tx_info, + txq_id >= IL4965_FIRST_AMPDU_QUEUE); + tx_info->skb = NULL; + + il->cfg->ops->lib->txq_free_tfd(il, txq); + } + return nfreed; +} + +/** + * il4965_tx_status_reply_compressed_ba - Update tx status from block-ack + * + * Go through block-ack's bitmap of ACK'd frames, update driver's record of + * ACK vs. not. This gets sent to mac80211, then to rate scaling algo. + */ +static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, + struct il_ht_agg *agg, + struct il_compressed_ba_resp *ba_resp) + +{ + int i, sh, ack; + u16 seq_ctl = le16_to_cpu(ba_resp->seq_ctl); + u16 scd_flow = le16_to_cpu(ba_resp->scd_flow); + int successes = 0; + struct ieee80211_tx_info *info; + u64 bitmap, sent_bitmap; + + if (unlikely(!agg->wait_for_ba)) { + if (unlikely(ba_resp->bitmap)) + IL_ERR("Received BA when not expected\n"); + return -EINVAL; + } + + /* Mark that the expected block-ack response arrived */ + agg->wait_for_ba = 0; + D_TX_REPLY("BA %d %d\n", agg->start_idx, + ba_resp->seq_ctl); + + /* Calculate shift to align block-ack bits with our Tx win bits */ + sh = agg->start_idx - SEQ_TO_IDX(seq_ctl >> 4); + if (sh < 0) /* tbw something is wrong with indices */ + sh += 0x100; + + if (agg->frame_count > (64 - sh)) { + D_TX_REPLY("more frames than bitmap size"); + return -1; + } + + /* don't use 64-bit values for now */ + bitmap = le64_to_cpu(ba_resp->bitmap) >> sh; + + /* check for success or failure according to the + * transmitted bitmap and block-ack bitmap */ + sent_bitmap = bitmap & agg->bitmap; + + /* For each frame attempted in aggregation, + * update driver's record of tx frame's status. */ + i = 0; + while (sent_bitmap) { + ack = sent_bitmap & 1ULL; + successes += ack; + D_TX_REPLY("%s ON i=%d idx=%d raw=%d\n", + ack ? "ACK" : "NACK", i, + (agg->start_idx + i) & 0xff, + agg->start_idx + i); + sent_bitmap >>= 1; + ++i; + } + + D_TX_REPLY("Bitmap %llx\n", + (unsigned long long)bitmap); + + info = IEEE80211_SKB_CB(il->txq[scd_flow].txb[agg->start_idx].skb); + memset(&info->status, 0, sizeof(info->status)); + info->flags |= IEEE80211_TX_STAT_ACK; + info->flags |= IEEE80211_TX_STAT_AMPDU; + info->status.ampdu_ack_len = successes; + info->status.ampdu_len = agg->frame_count; + il4965_hwrate_to_tx_control(il, agg->rate_n_flags, info); + + return 0; +} + +/** + * translate ucode response to mac80211 tx status control values + */ +void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, + struct ieee80211_tx_info *info) +{ + struct ieee80211_tx_rate *r = &info->control.rates[0]; + + info->antenna_sel_tx = + ((rate_n_flags & RATE_MCS_ANT_ABC_MSK) >> RATE_MCS_ANT_POS); + if (rate_n_flags & RATE_MCS_HT_MSK) + r->flags |= IEEE80211_TX_RC_MCS; + if (rate_n_flags & RATE_MCS_GF_MSK) + r->flags |= IEEE80211_TX_RC_GREEN_FIELD; + if (rate_n_flags & RATE_MCS_HT40_MSK) + r->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH; + if (rate_n_flags & RATE_MCS_DUP_MSK) + r->flags |= IEEE80211_TX_RC_DUP_DATA; + if (rate_n_flags & RATE_MCS_SGI_MSK) + r->flags |= IEEE80211_TX_RC_SHORT_GI; + r->idx = il4965_hwrate_to_mac80211_idx(rate_n_flags, info->band); +} + +/** + * il4965_rx_reply_compressed_ba - Handler for REPLY_COMPRESSED_BA + * + * Handles block-acknowledge notification from device, which reports success + * of frames sent via aggregation. + */ +void il4965_rx_reply_compressed_ba(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il_compressed_ba_resp *ba_resp = &pkt->u.compressed_ba; + struct il_tx_queue *txq = NULL; + struct il_ht_agg *agg; + int idx; + int sta_id; + int tid; + unsigned long flags; + + /* "flow" corresponds to Tx queue */ + u16 scd_flow = le16_to_cpu(ba_resp->scd_flow); + + /* "ssn" is start of block-ack Tx win, corresponds to idx + * (in Tx queue's circular buffer) of first TFD/frame in win */ + u16 ba_resp_scd_ssn = le16_to_cpu(ba_resp->scd_ssn); + + if (scd_flow >= il->hw_params.max_txq_num) { + IL_ERR( + "BUG_ON scd_flow is bigger than number of queues\n"); + return; + } + + txq = &il->txq[scd_flow]; + sta_id = ba_resp->sta_id; + tid = ba_resp->tid; + agg = &il->stations[sta_id].tid[tid].agg; + if (unlikely(agg->txq_id != scd_flow)) { + /* + * FIXME: this is a uCode bug which need to be addressed, + * log the information and return for now! + * since it is possible happen very often and in order + * not to fill the syslog, don't enable the logging by default + */ + D_TX_REPLY( + "BA scd_flow %d does not match txq_id %d\n", + scd_flow, agg->txq_id); + return; + } + + /* Find idx just before block-ack win */ + idx = il_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd); + + spin_lock_irqsave(&il->sta_lock, flags); + + D_TX_REPLY("REPLY_COMPRESSED_BA [%d] Received from %pM, " + "sta_id = %d\n", + agg->wait_for_ba, + (u8 *) &ba_resp->sta_addr_lo32, + ba_resp->sta_id); + D_TX_REPLY("TID = %d, SeqCtl = %d, bitmap = 0x%llx," + "scd_flow = " + "%d, scd_ssn = %d\n", + ba_resp->tid, + ba_resp->seq_ctl, + (unsigned long long)le64_to_cpu(ba_resp->bitmap), + ba_resp->scd_flow, + ba_resp->scd_ssn); + D_TX_REPLY("DAT start_idx = %d, bitmap = 0x%llx\n", + agg->start_idx, + (unsigned long long)agg->bitmap); + + /* Update driver's record of ACK vs. not for each frame in win */ + il4965_tx_status_reply_compressed_ba(il, agg, ba_resp); + + /* Release all TFDs before the SSN, i.e. all TFDs in front of + * block-ack win (we assume that they've been successfully + * transmitted ... if not, it's too late anyway). */ + if (txq->q.read_ptr != (ba_resp_scd_ssn & 0xff)) { + /* calculate mac80211 ampdu sw queue to wake */ + int freed = il4965_tx_queue_reclaim(il, scd_flow, idx); + il4965_free_tfds_in_queue(il, sta_id, tid, freed); + + if (il_queue_space(&txq->q) > txq->q.low_mark && + il->mac80211_registered && + agg->state != IL_EMPTYING_HW_QUEUE_DELBA) + il_wake_queue(il, txq); + + il4965_txq_check_empty(il, sta_id, tid, scd_flow); + } + + spin_unlock_irqrestore(&il->sta_lock, flags); +} + +#ifdef CONFIG_IWLEGACY_DEBUG +const char *il4965_get_tx_fail_reason(u32 status) +{ +#define TX_STATUS_FAIL(x) case TX_STATUS_FAIL_ ## x: return #x +#define TX_STATUS_POSTPONE(x) case TX_STATUS_POSTPONE_ ## x: return #x + + switch (status & TX_STATUS_MSK) { + case TX_STATUS_SUCCESS: + return "SUCCESS"; + TX_STATUS_POSTPONE(DELAY); + TX_STATUS_POSTPONE(FEW_BYTES); + TX_STATUS_POSTPONE(QUIET_PERIOD); + TX_STATUS_POSTPONE(CALC_TTAK); + TX_STATUS_FAIL(INTERNAL_CROSSED_RETRY); + TX_STATUS_FAIL(SHORT_LIMIT); + TX_STATUS_FAIL(LONG_LIMIT); + TX_STATUS_FAIL(FIFO_UNDERRUN); + TX_STATUS_FAIL(DRAIN_FLOW); + TX_STATUS_FAIL(RFKILL_FLUSH); + TX_STATUS_FAIL(LIFE_EXPIRE); + TX_STATUS_FAIL(DEST_PS); + TX_STATUS_FAIL(HOST_ABORTED); + TX_STATUS_FAIL(BT_RETRY); + TX_STATUS_FAIL(STA_INVALID); + TX_STATUS_FAIL(FRAG_DROPPED); + TX_STATUS_FAIL(TID_DISABLE); + TX_STATUS_FAIL(FIFO_FLUSHED); + TX_STATUS_FAIL(INSUFFICIENT_CF_POLL); + TX_STATUS_FAIL(PASSIVE_NO_RX); + TX_STATUS_FAIL(NO_BEACON_ON_RADAR); + } + + return "UNKNOWN"; + +#undef TX_STATUS_FAIL +#undef TX_STATUS_POSTPONE +} +#endif /* CONFIG_IWLEGACY_DEBUG */ + static struct il_link_quality_cmd * il4965_sta_alloc_lq(struct il_priv *il, u8 sta_id) { diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index 0643fda0656c..884470479223 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -9,8 +9,7 @@ iwl-legacy-objs += $(iwl-legacy-m) # 4965 obj-$(CONFIG_IWL4965) += iwl4965.o iwl4965-objs := 4965.o 4965-mac.o iwl-4965-rs.o -iwl4965-objs += iwl-4965-tx.o -iwl4965-objs += iwl-4965-lib.o iwl-4965-rx.o iwl-4965-calib.o +iwl4965-objs += iwl-4965-lib.o iwl-4965-calib.o iwl4965-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-4965-debugfs.o # 3945 diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c b/drivers/net/wireless/iwlegacy/iwl-4965-rx.c deleted file mode 100644 index b32295747851..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rx.c +++ /dev/null @@ -1,215 +0,0 @@ -/****************************************************************************** - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include -#include -#include -#include - -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-4965-calib.h" -#include "iwl-sta.h" -#include "iwl-io.h" -#include "iwl-helpers.h" -#include "iwl-4965-hw.h" -#include "iwl-4965.h" - -void il4965_rx_missed_beacon_notif(struct il_priv *il, - struct il_rx_buf *rxb) - -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il_missed_beacon_notif *missed_beacon; - - missed_beacon = &pkt->u.missed_beacon; - if (le32_to_cpu(missed_beacon->consecutive_missed_beacons) > - il->missed_beacon_threshold) { - D_CALIB( - "missed bcn cnsq %d totl %d rcd %d expctd %d\n", - le32_to_cpu(missed_beacon->consecutive_missed_beacons), - le32_to_cpu(missed_beacon->total_missed_becons), - le32_to_cpu(missed_beacon->num_recvd_beacons), - le32_to_cpu(missed_beacon->num_expected_beacons)); - if (!test_bit(STATUS_SCANNING, &il->status)) - il4965_init_sensitivity(il); - } -} - -/* Calculate noise level, based on measurements during network silence just - * before arriving beacon. This measurement can be done only if we know - * exactly when to expect beacons, therefore only when we're associated. */ -static void il4965_rx_calc_noise(struct il_priv *il) -{ - struct stats_rx_non_phy *rx_info; - int num_active_rx = 0; - int total_silence = 0; - int bcn_silence_a, bcn_silence_b, bcn_silence_c; - int last_rx_noise; - - rx_info = &(il->_4965.stats.rx.general); - bcn_silence_a = - le32_to_cpu(rx_info->beacon_silence_rssi_a) & IN_BAND_FILTER; - bcn_silence_b = - le32_to_cpu(rx_info->beacon_silence_rssi_b) & IN_BAND_FILTER; - bcn_silence_c = - le32_to_cpu(rx_info->beacon_silence_rssi_c) & IN_BAND_FILTER; - - if (bcn_silence_a) { - total_silence += bcn_silence_a; - num_active_rx++; - } - if (bcn_silence_b) { - total_silence += bcn_silence_b; - num_active_rx++; - } - if (bcn_silence_c) { - total_silence += bcn_silence_c; - num_active_rx++; - } - - /* Average among active antennas */ - if (num_active_rx) - last_rx_noise = (total_silence / num_active_rx) - 107; - else - last_rx_noise = IL_NOISE_MEAS_NOT_AVAILABLE; - - D_CALIB("inband silence a %u, b %u, c %u, dBm %d\n", - bcn_silence_a, bcn_silence_b, bcn_silence_c, - last_rx_noise); -} - -#ifdef CONFIG_IWLEGACY_DEBUGFS -/* - * based on the assumption of all stats counter are in DWORD - * FIXME: This function is for debugging, do not deal with - * the case of counters roll-over. - */ -static void il4965_accumulative_stats(struct il_priv *il, - __le32 *stats) -{ - int i, size; - __le32 *prev_stats; - u32 *accum_stats; - u32 *delta, *max_delta; - struct stats_general_common *general, *accum_general; - struct stats_tx *tx, *accum_tx; - - prev_stats = (__le32 *)&il->_4965.stats; - accum_stats = (u32 *)&il->_4965.accum_stats; - size = sizeof(struct il_notif_stats); - general = &il->_4965.stats.general.common; - accum_general = &il->_4965.accum_stats.general.common; - tx = &il->_4965.stats.tx; - accum_tx = &il->_4965.accum_stats.tx; - delta = (u32 *)&il->_4965.delta_stats; - max_delta = (u32 *)&il->_4965.max_delta; - - for (i = sizeof(__le32); i < size; - i += sizeof(__le32), stats++, prev_stats++, delta++, - max_delta++, accum_stats++) { - if (le32_to_cpu(*stats) > le32_to_cpu(*prev_stats)) { - *delta = (le32_to_cpu(*stats) - - le32_to_cpu(*prev_stats)); - *accum_stats += *delta; - if (*delta > *max_delta) - *max_delta = *delta; - } - } - - /* reset accumulative stats for "no-counter" type stats */ - accum_general->temperature = general->temperature; - accum_general->ttl_timestamp = general->ttl_timestamp; -} -#endif - -#define REG_RECALIB_PERIOD (60) - -void il4965_rx_stats(struct il_priv *il, - struct il_rx_buf *rxb) -{ - int change; - struct il_rx_pkt *pkt = rxb_addr(rxb); - - D_RX( - "Statistics notification received (%d vs %d).\n", - (int)sizeof(struct il_notif_stats), - le32_to_cpu(pkt->len_n_flags) & - FH_RSCSR_FRAME_SIZE_MSK); - - change = ((il->_4965.stats.general.common.temperature != - pkt->u.stats.general.common.temperature) || - ((il->_4965.stats.flag & - STATISTICS_REPLY_FLG_HT40_MODE_MSK) != - (pkt->u.stats.flag & - STATISTICS_REPLY_FLG_HT40_MODE_MSK))); -#ifdef CONFIG_IWLEGACY_DEBUGFS - il4965_accumulative_stats(il, (__le32 *)&pkt->u.stats); -#endif - - /* TODO: reading some of stats is unneeded */ - memcpy(&il->_4965.stats, &pkt->u.stats, - sizeof(il->_4965.stats)); - - set_bit(STATUS_STATISTICS, &il->status); - - /* Reschedule the stats timer to occur in - * REG_RECALIB_PERIOD seconds to ensure we get a - * thermal update even if the uCode doesn't give - * us one */ - mod_timer(&il->stats_periodic, jiffies + - msecs_to_jiffies(REG_RECALIB_PERIOD * 1000)); - - if (unlikely(!test_bit(STATUS_SCANNING, &il->status)) && - (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) { - il4965_rx_calc_noise(il); - queue_work(il->workqueue, &il->run_time_calib_work); - } - if (il->cfg->ops->lib->temp_ops.temperature && change) - il->cfg->ops->lib->temp_ops.temperature(il); -} - -void il4965_reply_stats(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - - if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATISTICS_CLEAR_MSK) { -#ifdef CONFIG_IWLEGACY_DEBUGFS - memset(&il->_4965.accum_stats, 0, - sizeof(struct il_notif_stats)); - memset(&il->_4965.delta_stats, 0, - sizeof(struct il_notif_stats)); - memset(&il->_4965.max_delta, 0, - sizeof(struct il_notif_stats)); -#endif - D_RX("Statistics have been cleared\n"); - } - il4965_rx_stats(il, rxb); -} diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c deleted file mode 100644 index a6fa1c2296ac..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c +++ /dev/null @@ -1,1371 +0,0 @@ -/****************************************************************************** - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include -#include -#include -#include - -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-sta.h" -#include "iwl-io.h" -#include "iwl-helpers.h" -#include "iwl-4965-hw.h" -#include "iwl-4965.h" - -/* - * mac80211 queues, ACs, hardware queues, FIFOs. - * - * Cf. http://wireless.kernel.org/en/developers/Documentation/mac80211/queues - * - * Mac80211 uses the following numbers, which we get as from it - * by way of skb_get_queue_mapping(skb): - * - * VO 0 - * VI 1 - * BE 2 - * BK 3 - * - * - * Regular (not A-MPDU) frames are put into hardware queues corresponding - * to the FIFOs, see comments in iwl-prph.h. Aggregated frames get their - * own queue per aggregation session (RA/TID combination), such queues are - * set up to map into FIFOs too, for which we need an AC->FIFO mapping. In - * order to map frames to the right queue, we also need an AC->hw queue - * mapping. This is implemented here. - * - * Due to the way hw queues are set up (by the hw specific modules like - * iwl-4965.c), the AC->hw queue mapping is the identity - * mapping. - */ - -static const u8 tid_to_ac[] = { - IEEE80211_AC_BE, - IEEE80211_AC_BK, - IEEE80211_AC_BK, - IEEE80211_AC_BE, - IEEE80211_AC_VI, - IEEE80211_AC_VI, - IEEE80211_AC_VO, - IEEE80211_AC_VO -}; - -static inline int il4965_get_ac_from_tid(u16 tid) -{ - if (likely(tid < ARRAY_SIZE(tid_to_ac))) - return tid_to_ac[tid]; - - /* no support for TIDs 8-15 yet */ - return -EINVAL; -} - -static inline int -il4965_get_fifo_from_tid(struct il_rxon_context *ctx, u16 tid) -{ - if (likely(tid < ARRAY_SIZE(tid_to_ac))) - return ctx->ac_to_fifo[tid_to_ac[tid]]; - - /* no support for TIDs 8-15 yet */ - return -EINVAL; -} - -/* - * handle build REPLY_TX command notification. - */ -static void il4965_tx_cmd_build_basic(struct il_priv *il, - struct sk_buff *skb, - struct il_tx_cmd *tx_cmd, - struct ieee80211_tx_info *info, - struct ieee80211_hdr *hdr, - u8 std_id) -{ - __le16 fc = hdr->frame_control; - __le32 tx_flags = tx_cmd->tx_flags; - - tx_cmd->stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; - if (!(info->flags & IEEE80211_TX_CTL_NO_ACK)) { - tx_flags |= TX_CMD_FLG_ACK_MSK; - if (ieee80211_is_mgmt(fc)) - tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; - if (ieee80211_is_probe_resp(fc) && - !(le16_to_cpu(hdr->seq_ctrl) & 0xf)) - tx_flags |= TX_CMD_FLG_TSF_MSK; - } else { - tx_flags &= (~TX_CMD_FLG_ACK_MSK); - tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; - } - - if (ieee80211_is_back_req(fc)) - tx_flags |= TX_CMD_FLG_ACK_MSK | TX_CMD_FLG_IMM_BA_RSP_MASK; - - tx_cmd->sta_id = std_id; - if (ieee80211_has_morefrags(fc)) - tx_flags |= TX_CMD_FLG_MORE_FRAG_MSK; - - if (ieee80211_is_data_qos(fc)) { - u8 *qc = ieee80211_get_qos_ctl(hdr); - tx_cmd->tid_tspec = qc[0] & 0xf; - tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK; - } else { - tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; - } - - il_tx_cmd_protection(il, info, fc, &tx_flags); - - tx_flags &= ~(TX_CMD_FLG_ANT_SEL_MSK); - if (ieee80211_is_mgmt(fc)) { - if (ieee80211_is_assoc_req(fc) || ieee80211_is_reassoc_req(fc)) - tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(3); - else - tx_cmd->timeout.pm_frame_timeout = cpu_to_le16(2); - } else { - tx_cmd->timeout.pm_frame_timeout = 0; - } - - tx_cmd->driver_txop = 0; - tx_cmd->tx_flags = tx_flags; - tx_cmd->next_frame_len = 0; -} - -#define RTS_DFAULT_RETRY_LIMIT 60 - -static void il4965_tx_cmd_build_rate(struct il_priv *il, - struct il_tx_cmd *tx_cmd, - struct ieee80211_tx_info *info, - __le16 fc) -{ - u32 rate_flags; - int rate_idx; - u8 rts_retry_limit; - u8 data_retry_limit; - u8 rate_plcp; - - /* Set retry limit on DATA packets and Probe Responses*/ - if (ieee80211_is_probe_resp(fc)) - data_retry_limit = 3; - else - data_retry_limit = IL4965_DEFAULT_TX_RETRY; - tx_cmd->data_retry_limit = data_retry_limit; - - /* Set retry limit on RTS packets */ - rts_retry_limit = RTS_DFAULT_RETRY_LIMIT; - if (data_retry_limit < rts_retry_limit) - rts_retry_limit = data_retry_limit; - tx_cmd->rts_retry_limit = rts_retry_limit; - - /* DATA packets will use the uCode station table for rate/antenna - * selection */ - if (ieee80211_is_data(fc)) { - tx_cmd->initial_rate_idx = 0; - tx_cmd->tx_flags |= TX_CMD_FLG_STA_RATE_MSK; - return; - } - - /** - * If the current TX rate stored in mac80211 has the MCS bit set, it's - * not really a TX rate. Thus, we use the lowest supported rate for - * this band. Also use the lowest supported rate if the stored rate - * idx is invalid. - */ - rate_idx = info->control.rates[0].idx; - if ((info->control.rates[0].flags & IEEE80211_TX_RC_MCS) || - rate_idx < 0 || rate_idx > RATE_COUNT_LEGACY) - rate_idx = rate_lowest_index(&il->bands[info->band], - info->control.sta); - /* For 5 GHZ band, remap mac80211 rate indices into driver indices */ - if (info->band == IEEE80211_BAND_5GHZ) - rate_idx += IL_FIRST_OFDM_RATE; - /* Get PLCP rate for tx_cmd->rate_n_flags */ - rate_plcp = il_rates[rate_idx].plcp; - /* Zero out flags for this packet */ - rate_flags = 0; - - /* Set CCK flag as needed */ - if (rate_idx >= IL_FIRST_CCK_RATE && rate_idx <= IL_LAST_CCK_RATE) - rate_flags |= RATE_MCS_CCK_MSK; - - /* Set up antennas */ - il->mgmt_tx_ant = il4965_toggle_tx_ant(il, il->mgmt_tx_ant, - il->hw_params.valid_tx_ant); - - rate_flags |= il4965_ant_idx_to_flags(il->mgmt_tx_ant); - - /* Set the rate in the TX cmd */ - tx_cmd->rate_n_flags = il4965_hw_set_rate_n_flags(rate_plcp, rate_flags); -} - -static void il4965_tx_cmd_build_hwcrypto(struct il_priv *il, - struct ieee80211_tx_info *info, - struct il_tx_cmd *tx_cmd, - struct sk_buff *skb_frag, - int sta_id) -{ - struct ieee80211_key_conf *keyconf = info->control.hw_key; - - switch (keyconf->cipher) { - case WLAN_CIPHER_SUITE_CCMP: - tx_cmd->sec_ctl = TX_CMD_SEC_CCM; - memcpy(tx_cmd->key, keyconf->key, keyconf->keylen); - if (info->flags & IEEE80211_TX_CTL_AMPDU) - tx_cmd->tx_flags |= TX_CMD_FLG_AGG_CCMP_MSK; - D_TX("tx_cmd with AES hwcrypto\n"); - break; - - case WLAN_CIPHER_SUITE_TKIP: - tx_cmd->sec_ctl = TX_CMD_SEC_TKIP; - ieee80211_get_tkip_p2k(keyconf, skb_frag, tx_cmd->key); - D_TX("tx_cmd with tkip hwcrypto\n"); - break; - - case WLAN_CIPHER_SUITE_WEP104: - tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128; - /* fall through */ - case WLAN_CIPHER_SUITE_WEP40: - tx_cmd->sec_ctl |= (TX_CMD_SEC_WEP | - (keyconf->keyidx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT); - - memcpy(&tx_cmd->key[3], keyconf->key, keyconf->keylen); - - D_TX("Configuring packet for WEP encryption " - "with key %d\n", keyconf->keyidx); - break; - - default: - IL_ERR("Unknown encode cipher %x\n", keyconf->cipher); - break; - } -} - -/* - * start REPLY_TX command process - */ -int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) -{ - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - struct ieee80211_sta *sta = info->control.sta; - struct il_station_priv *sta_priv = NULL; - struct il_tx_queue *txq; - struct il_queue *q; - struct il_device_cmd *out_cmd; - struct il_cmd_meta *out_meta; - struct il_tx_cmd *tx_cmd; - struct il_rxon_context *ctx = &il->ctx; - int txq_id; - dma_addr_t phys_addr; - dma_addr_t txcmd_phys; - dma_addr_t scratch_phys; - u16 len, firstlen, secondlen; - u16 seq_number = 0; - __le16 fc; - u8 hdr_len; - u8 sta_id; - u8 wait_write_ptr = 0; - u8 tid = 0; - u8 *qc = NULL; - unsigned long flags; - bool is_agg = false; - - if (info->control.vif) - ctx = il_rxon_ctx_from_vif(info->control.vif); - - spin_lock_irqsave(&il->lock, flags); - if (il_is_rfkill(il)) { - D_DROP("Dropping - RF KILL\n"); - goto drop_unlock; - } - - fc = hdr->frame_control; - -#ifdef CONFIG_IWLEGACY_DEBUG - if (ieee80211_is_auth(fc)) - D_TX("Sending AUTH frame\n"); - else if (ieee80211_is_assoc_req(fc)) - D_TX("Sending ASSOC frame\n"); - else if (ieee80211_is_reassoc_req(fc)) - D_TX("Sending REASSOC frame\n"); -#endif - - hdr_len = ieee80211_hdrlen(fc); - - /* For management frames use broadcast id to do not break aggregation */ - if (!ieee80211_is_data(fc)) - sta_id = ctx->bcast_sta_id; - else { - /* Find idx into station table for destination station */ - sta_id = il_sta_id_or_broadcast(il, ctx, info->control.sta); - - if (sta_id == IL_INVALID_STATION) { - D_DROP("Dropping - INVALID STATION: %pM\n", - hdr->addr1); - goto drop_unlock; - } - } - - D_TX("station Id %d\n", sta_id); - - if (sta) - sta_priv = (void *)sta->drv_priv; - - if (sta_priv && sta_priv->asleep && - (info->flags & IEEE80211_TX_CTL_POLL_RESPONSE)) { - /* - * This sends an asynchronous command to the device, - * but we can rely on it being processed before the - * next frame is processed -- and the next frame to - * this station is the one that will consume this - * counter. - * For now set the counter to just 1 since we do not - * support uAPSD yet. - */ - il4965_sta_modify_sleep_tx_count(il, sta_id, 1); - } - - /* - * Send this frame after DTIM -- there's a special queue - * reserved for this for contexts that support AP mode. - */ - if (info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) { - txq_id = ctx->mcast_queue; - /* - * The microcode will clear the more data - * bit in the last frame it transmits. - */ - hdr->frame_control |= - cpu_to_le16(IEEE80211_FCTL_MOREDATA); - } else - txq_id = ctx->ac_to_queue[skb_get_queue_mapping(skb)]; - - /* irqs already disabled/saved above when locking il->lock */ - spin_lock(&il->sta_lock); - - if (ieee80211_is_data_qos(fc)) { - qc = ieee80211_get_qos_ctl(hdr); - tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK; - if (WARN_ON_ONCE(tid >= MAX_TID_COUNT)) { - spin_unlock(&il->sta_lock); - goto drop_unlock; - } - seq_number = il->stations[sta_id].tid[tid].seq_number; - seq_number &= IEEE80211_SCTL_SEQ; - hdr->seq_ctrl = hdr->seq_ctrl & - cpu_to_le16(IEEE80211_SCTL_FRAG); - hdr->seq_ctrl |= cpu_to_le16(seq_number); - seq_number += 0x10; - /* aggregation is on for this */ - if (info->flags & IEEE80211_TX_CTL_AMPDU && - il->stations[sta_id].tid[tid].agg.state == IL_AGG_ON) { - txq_id = il->stations[sta_id].tid[tid].agg.txq_id; - is_agg = true; - } - } - - txq = &il->txq[txq_id]; - q = &txq->q; - - if (unlikely(il_queue_space(q) < q->high_mark)) { - spin_unlock(&il->sta_lock); - goto drop_unlock; - } - - if (ieee80211_is_data_qos(fc)) { - il->stations[sta_id].tid[tid].tfds_in_queue++; - if (!ieee80211_has_morefrags(fc)) - il->stations[sta_id].tid[tid].seq_number = seq_number; - } - - spin_unlock(&il->sta_lock); - - /* Set up driver data for this TFD */ - memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct il_tx_info)); - txq->txb[q->write_ptr].skb = skb; - txq->txb[q->write_ptr].ctx = ctx; - - /* Set up first empty entry in queue's array of Tx/cmd buffers */ - out_cmd = txq->cmd[q->write_ptr]; - out_meta = &txq->meta[q->write_ptr]; - tx_cmd = &out_cmd->cmd.tx; - memset(&out_cmd->hdr, 0, sizeof(out_cmd->hdr)); - memset(tx_cmd, 0, sizeof(struct il_tx_cmd)); - - /* - * Set up the Tx-command (not MAC!) header. - * Store the chosen Tx queue and TFD idx within the sequence field; - * after Tx, uCode's Tx response will return this value so driver can - * locate the frame within the tx queue and do post-tx processing. - */ - out_cmd->hdr.cmd = REPLY_TX; - out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | - IDX_TO_SEQ(q->write_ptr))); - - /* Copy MAC header from skb into command buffer */ - memcpy(tx_cmd->hdr, hdr, hdr_len); - - - /* Total # bytes to be transmitted */ - len = (u16)skb->len; - tx_cmd->len = cpu_to_le16(len); - - if (info->control.hw_key) - il4965_tx_cmd_build_hwcrypto(il, info, tx_cmd, skb, sta_id); - - /* TODO need this for burst mode later on */ - il4965_tx_cmd_build_basic(il, skb, tx_cmd, info, hdr, sta_id); - il_dbg_log_tx_data_frame(il, len, hdr); - - il4965_tx_cmd_build_rate(il, tx_cmd, info, fc); - - il_update_stats(il, true, fc, len); - /* - * Use the first empty entry in this queue's command buffer array - * to contain the Tx command and MAC header concatenated together - * (payload data will be in another buffer). - * Size of this varies, due to varying MAC header length. - * If end is not dword aligned, we'll have 2 extra bytes at the end - * of the MAC header (device reads on dword boundaries). - * We'll tell device about this padding later. - */ - len = sizeof(struct il_tx_cmd) + - sizeof(struct il_cmd_header) + hdr_len; - firstlen = (len + 3) & ~3; - - /* Tell NIC about any 2-byte padding after MAC header */ - if (firstlen != len) - tx_cmd->tx_flags |= TX_CMD_FLG_MH_PAD_MSK; - - /* Physical address of this Tx command's header (not MAC header!), - * within command buffer array. */ - txcmd_phys = pci_map_single(il->pci_dev, - &out_cmd->hdr, firstlen, - PCI_DMA_BIDIRECTIONAL); - dma_unmap_addr_set(out_meta, mapping, txcmd_phys); - dma_unmap_len_set(out_meta, len, firstlen); - /* Add buffer containing Tx command and MAC(!) header to TFD's - * first entry */ - il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, - txcmd_phys, firstlen, 1, 0); - - if (!ieee80211_has_morefrags(hdr->frame_control)) { - txq->need_update = 1; - } else { - wait_write_ptr = 1; - txq->need_update = 0; - } - - /* Set up TFD's 2nd entry to point directly to remainder of skb, - * if any (802.11 null frames have no payload). */ - secondlen = skb->len - hdr_len; - if (secondlen > 0) { - phys_addr = pci_map_single(il->pci_dev, skb->data + hdr_len, - secondlen, PCI_DMA_TODEVICE); - il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, - phys_addr, secondlen, - 0, 0); - } - - scratch_phys = txcmd_phys + sizeof(struct il_cmd_header) + - offsetof(struct il_tx_cmd, scratch); - - /* take back ownership of DMA buffer to enable update */ - pci_dma_sync_single_for_cpu(il->pci_dev, txcmd_phys, - firstlen, PCI_DMA_BIDIRECTIONAL); - tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys); - tx_cmd->dram_msb_ptr = il_get_dma_hi_addr(scratch_phys); - - D_TX("sequence nr = 0X%x\n", - le16_to_cpu(out_cmd->hdr.sequence)); - D_TX("tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); - il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd, sizeof(*tx_cmd)); - il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd->hdr, hdr_len); - - /* Set up entry for this TFD in Tx byte-count array */ - if (info->flags & IEEE80211_TX_CTL_AMPDU) - il->cfg->ops->lib->txq_update_byte_cnt_tbl(il, txq, - le16_to_cpu(tx_cmd->len)); - - pci_dma_sync_single_for_device(il->pci_dev, txcmd_phys, - firstlen, PCI_DMA_BIDIRECTIONAL); - - /* Tell device the write idx *just past* this latest filled TFD */ - q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); - il_txq_update_write_ptr(il, txq); - spin_unlock_irqrestore(&il->lock, flags); - - /* - * At this point the frame is "transmitted" successfully - * and we will get a TX status notification eventually, - * regardless of the value of ret. "ret" only indicates - * whether or not we should update the write pointer. - */ - - /* - * Avoid atomic ops if it isn't an associated client. - * Also, if this is a packet for aggregation, don't - * increase the counter because the ucode will stop - * aggregation queues when their respective station - * goes to sleep. - */ - if (sta_priv && sta_priv->client && !is_agg) - atomic_inc(&sta_priv->pending_frames); - - if (il_queue_space(q) < q->high_mark && il->mac80211_registered) { - if (wait_write_ptr) { - spin_lock_irqsave(&il->lock, flags); - txq->need_update = 1; - il_txq_update_write_ptr(il, txq); - spin_unlock_irqrestore(&il->lock, flags); - } else { - il_stop_queue(il, txq); - } - } - - return 0; - -drop_unlock: - spin_unlock_irqrestore(&il->lock, flags); - return -1; -} - -static inline int il4965_alloc_dma_ptr(struct il_priv *il, - struct il_dma_ptr *ptr, size_t size) -{ - ptr->addr = dma_alloc_coherent(&il->pci_dev->dev, size, &ptr->dma, - GFP_KERNEL); - if (!ptr->addr) - return -ENOMEM; - ptr->size = size; - return 0; -} - -static inline void il4965_free_dma_ptr(struct il_priv *il, - struct il_dma_ptr *ptr) -{ - if (unlikely(!ptr->addr)) - return; - - dma_free_coherent(&il->pci_dev->dev, ptr->size, ptr->addr, ptr->dma); - memset(ptr, 0, sizeof(*ptr)); -} - -/** - * il4965_hw_txq_ctx_free - Free TXQ Context - * - * Destroy all TX DMA queues and structures - */ -void il4965_hw_txq_ctx_free(struct il_priv *il) -{ - int txq_id; - - /* Tx queues */ - if (il->txq) { - for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) - if (txq_id == il->cmd_queue) - il_cmd_queue_free(il); - else - il_tx_queue_free(il, txq_id); - } - il4965_free_dma_ptr(il, &il->kw); - - il4965_free_dma_ptr(il, &il->scd_bc_tbls); - - /* free tx queue structure */ - il_txq_mem(il); -} - -/** - * il4965_txq_ctx_alloc - allocate TX queue context - * Allocate all Tx DMA structures and initialize them - * - * @param il - * @return error code - */ -int il4965_txq_ctx_alloc(struct il_priv *il) -{ - int ret; - int txq_id, slots_num; - unsigned long flags; - - /* Free all tx/cmd queues and keep-warm buffer */ - il4965_hw_txq_ctx_free(il); - - ret = il4965_alloc_dma_ptr(il, &il->scd_bc_tbls, - il->hw_params.scd_bc_tbls_size); - if (ret) { - IL_ERR("Scheduler BC Table allocation failed\n"); - goto error_bc_tbls; - } - /* Alloc keep-warm buffer */ - ret = il4965_alloc_dma_ptr(il, &il->kw, IL_KW_SIZE); - if (ret) { - IL_ERR("Keep Warm allocation failed\n"); - goto error_kw; - } - - /* allocate tx queue structure */ - ret = il_alloc_txq_mem(il); - if (ret) - goto error; - - spin_lock_irqsave(&il->lock, flags); - - /* Turn off all Tx DMA fifos */ - il4965_txq_set_sched(il, 0); - - /* Tell NIC where to find the "keep warm" buffer */ - il_wr(il, FH_KW_MEM_ADDR_REG, il->kw.dma >> 4); - - spin_unlock_irqrestore(&il->lock, flags); - - /* Alloc and init all Tx queues, including the command queue (#4/#9) */ - for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { - slots_num = (txq_id == il->cmd_queue) ? - TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - ret = il_tx_queue_init(il, - &il->txq[txq_id], slots_num, - txq_id); - if (ret) { - IL_ERR("Tx %d queue init failed\n", txq_id); - goto error; - } - } - - return ret; - - error: - il4965_hw_txq_ctx_free(il); - il4965_free_dma_ptr(il, &il->kw); - error_kw: - il4965_free_dma_ptr(il, &il->scd_bc_tbls); - error_bc_tbls: - return ret; -} - -void il4965_txq_ctx_reset(struct il_priv *il) -{ - int txq_id, slots_num; - unsigned long flags; - - spin_lock_irqsave(&il->lock, flags); - - /* Turn off all Tx DMA fifos */ - il4965_txq_set_sched(il, 0); - - /* Tell NIC where to find the "keep warm" buffer */ - il_wr(il, FH_KW_MEM_ADDR_REG, il->kw.dma >> 4); - - spin_unlock_irqrestore(&il->lock, flags); - - /* Alloc and init all Tx queues, including the command queue (#4) */ - for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { - slots_num = txq_id == il->cmd_queue ? - TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - il_tx_queue_reset(il, &il->txq[txq_id], - slots_num, txq_id); - } -} - -/** - * il4965_txq_ctx_stop - Stop all Tx DMA channels - */ -void il4965_txq_ctx_stop(struct il_priv *il) -{ - int ch, txq_id; - unsigned long flags; - - /* Turn off all Tx DMA fifos */ - spin_lock_irqsave(&il->lock, flags); - - il4965_txq_set_sched(il, 0); - - /* Stop each Tx DMA channel, and wait for it to be idle */ - for (ch = 0; ch < il->hw_params.dma_chnl_num; ch++) { - il_wr(il, - FH_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0); - if (il_poll_bit(il, FH_TSSR_TX_STATUS_REG, - FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), - 1000)) - IL_ERR("Failing on timeout while stopping" - " DMA channel %d [0x%08x]", ch, - il_rd(il, - FH_TSSR_TX_STATUS_REG)); - } - spin_unlock_irqrestore(&il->lock, flags); - - if (!il->txq) - return; - - /* Unmap DMA from host system and free skb's */ - for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) - if (txq_id == il->cmd_queue) - il_cmd_queue_unmap(il); - else - il_tx_queue_unmap(il, txq_id); -} - -/* - * Find first available (lowest unused) Tx Queue, mark it "active". - * Called only when finding queue for aggregation. - * Should never return anything < 7, because they should already - * be in use as EDCA AC (0-3), Command (4), reserved (5, 6) - */ -static int il4965_txq_ctx_activate_free(struct il_priv *il) -{ - int txq_id; - - for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) - if (!test_and_set_bit(txq_id, &il->txq_ctx_active_msk)) - return txq_id; - return -1; -} - -/** - * il4965_tx_queue_stop_scheduler - Stop queue, but keep configuration - */ -static void il4965_tx_queue_stop_scheduler(struct il_priv *il, - u16 txq_id) -{ - /* Simply stop the queue, but don't change any configuration; - * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */ - il_wr_prph(il, - IL49_SCD_QUEUE_STATUS_BITS(txq_id), - (0 << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE)| - (1 << IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); -} - -/** - * il4965_tx_queue_set_q2ratid - Map unique receiver/tid combination to a queue - */ -static int il4965_tx_queue_set_q2ratid(struct il_priv *il, u16 ra_tid, - u16 txq_id) -{ - u32 tbl_dw_addr; - u32 tbl_dw; - u16 scd_q2ratid; - - scd_q2ratid = ra_tid & IL_SCD_QUEUE_RA_TID_MAP_RATID_MSK; - - tbl_dw_addr = il->scd_base_addr + - IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id); - - tbl_dw = il_read_targ_mem(il, tbl_dw_addr); - - if (txq_id & 0x1) - tbl_dw = (scd_q2ratid << 16) | (tbl_dw & 0x0000FFFF); - else - tbl_dw = scd_q2ratid | (tbl_dw & 0xFFFF0000); - - il_write_targ_mem(il, tbl_dw_addr, tbl_dw); - - return 0; -} - -/** - * il4965_tx_queue_agg_enable - Set up & enable aggregation for selected queue - * - * NOTE: txq_id must be greater than IL49_FIRST_AMPDU_QUEUE, - * i.e. it must be one of the higher queues used for aggregation - */ -static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, - int tx_fifo, int sta_id, int tid, u16 ssn_idx) -{ - unsigned long flags; - u16 ra_tid; - int ret; - - if ((IL49_FIRST_AMPDU_QUEUE > txq_id) || - (IL49_FIRST_AMPDU_QUEUE + - il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { - IL_WARN( - "queue number out of range: %d, must be %d to %d\n", - txq_id, IL49_FIRST_AMPDU_QUEUE, - IL49_FIRST_AMPDU_QUEUE + - il->cfg->base_params->num_of_ampdu_queues - 1); - return -EINVAL; - } - - ra_tid = BUILD_RAxTID(sta_id, tid); - - /* Modify device's station table to Tx this TID */ - ret = il4965_sta_tx_modify_enable_tid(il, sta_id, tid); - if (ret) - return ret; - - spin_lock_irqsave(&il->lock, flags); - - /* Stop this Tx queue before configuring it */ - il4965_tx_queue_stop_scheduler(il, txq_id); - - /* Map receiver-address / traffic-ID to this queue */ - il4965_tx_queue_set_q2ratid(il, ra_tid, txq_id); - - /* Set this queue as a chain-building queue */ - il_set_bits_prph(il, IL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); - - /* Place first TFD at idx corresponding to start sequence number. - * Assumes that ssn_idx is valid (!= 0xFFF) */ - il->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); - il->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); - il4965_set_wr_ptrs(il, txq_id, ssn_idx); - - /* Set up Tx win size and frame limit for this queue */ - il_write_targ_mem(il, - il->scd_base_addr + IL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id), - (SCD_WIN_SIZE << IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & - IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); - - il_write_targ_mem(il, il->scd_base_addr + - IL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id) + sizeof(u32), - (SCD_FRAME_LIMIT << IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) - & IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); - - il_set_bits_prph(il, IL49_SCD_INTERRUPT_MASK, (1 << txq_id)); - - /* Set up Status area in SRAM, map to Tx DMA/FIFO, activate the queue */ - il4965_tx_queue_set_status(il, &il->txq[txq_id], tx_fifo, 1); - - spin_unlock_irqrestore(&il->lock, flags); - - return 0; -} - - -int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, - struct ieee80211_sta *sta, u16 tid, u16 *ssn) -{ - int sta_id; - int tx_fifo; - int txq_id; - int ret; - unsigned long flags; - struct il_tid_data *tid_data; - - tx_fifo = il4965_get_fifo_from_tid(il_rxon_ctx_from_vif(vif), tid); - if (unlikely(tx_fifo < 0)) - return tx_fifo; - - IL_WARN("%s on ra = %pM tid = %d\n", - __func__, sta->addr, tid); - - sta_id = il_sta_id(sta); - if (sta_id == IL_INVALID_STATION) { - IL_ERR("Start AGG on invalid station\n"); - return -ENXIO; - } - if (unlikely(tid >= MAX_TID_COUNT)) - return -EINVAL; - - if (il->stations[sta_id].tid[tid].agg.state != IL_AGG_OFF) { - IL_ERR("Start AGG when state is not IL_AGG_OFF !\n"); - return -ENXIO; - } - - txq_id = il4965_txq_ctx_activate_free(il); - if (txq_id == -1) { - IL_ERR("No free aggregation queue available\n"); - return -ENXIO; - } - - spin_lock_irqsave(&il->sta_lock, flags); - tid_data = &il->stations[sta_id].tid[tid]; - *ssn = SEQ_TO_SN(tid_data->seq_number); - tid_data->agg.txq_id = txq_id; - il_set_swq_id(&il->txq[txq_id], - il4965_get_ac_from_tid(tid), txq_id); - spin_unlock_irqrestore(&il->sta_lock, flags); - - ret = il4965_txq_agg_enable(il, txq_id, tx_fifo, - sta_id, tid, *ssn); - if (ret) - return ret; - - spin_lock_irqsave(&il->sta_lock, flags); - tid_data = &il->stations[sta_id].tid[tid]; - if (tid_data->tfds_in_queue == 0) { - D_HT("HW queue is empty\n"); - tid_data->agg.state = IL_AGG_ON; - ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid); - } else { - D_HT( - "HW queue is NOT empty: %d packets in HW queue\n", - tid_data->tfds_in_queue); - tid_data->agg.state = IL_EMPTYING_HW_QUEUE_ADDBA; - } - spin_unlock_irqrestore(&il->sta_lock, flags); - return ret; -} - -/** - * txq_id must be greater than IL49_FIRST_AMPDU_QUEUE - * il->lock must be held by the caller - */ -static int il4965_txq_agg_disable(struct il_priv *il, u16 txq_id, - u16 ssn_idx, u8 tx_fifo) -{ - if ((IL49_FIRST_AMPDU_QUEUE > txq_id) || - (IL49_FIRST_AMPDU_QUEUE + - il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { - IL_WARN( - "queue number out of range: %d, must be %d to %d\n", - txq_id, IL49_FIRST_AMPDU_QUEUE, - IL49_FIRST_AMPDU_QUEUE + - il->cfg->base_params->num_of_ampdu_queues - 1); - return -EINVAL; - } - - il4965_tx_queue_stop_scheduler(il, txq_id); - - il_clear_bits_prph(il, - IL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); - - il->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); - il->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); - /* supposes that ssn_idx is valid (!= 0xFFF) */ - il4965_set_wr_ptrs(il, txq_id, ssn_idx); - - il_clear_bits_prph(il, - IL49_SCD_INTERRUPT_MASK, (1 << txq_id)); - il_txq_ctx_deactivate(il, txq_id); - il4965_tx_queue_set_status(il, &il->txq[txq_id], tx_fifo, 0); - - return 0; -} - -int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, - struct ieee80211_sta *sta, u16 tid) -{ - int tx_fifo_id, txq_id, sta_id, ssn; - struct il_tid_data *tid_data; - int write_ptr, read_ptr; - unsigned long flags; - - tx_fifo_id = il4965_get_fifo_from_tid(il_rxon_ctx_from_vif(vif), tid); - if (unlikely(tx_fifo_id < 0)) - return tx_fifo_id; - - sta_id = il_sta_id(sta); - - if (sta_id == IL_INVALID_STATION) { - IL_ERR("Invalid station for AGG tid %d\n", tid); - return -ENXIO; - } - - spin_lock_irqsave(&il->sta_lock, flags); - - tid_data = &il->stations[sta_id].tid[tid]; - ssn = (tid_data->seq_number & IEEE80211_SCTL_SEQ) >> 4; - txq_id = tid_data->agg.txq_id; - - switch (il->stations[sta_id].tid[tid].agg.state) { - case IL_EMPTYING_HW_QUEUE_ADDBA: - /* - * This can happen if the peer stops aggregation - * again before we've had a chance to drain the - * queue we selected previously, i.e. before the - * session was really started completely. - */ - D_HT("AGG stop before setup done\n"); - goto turn_off; - case IL_AGG_ON: - break; - default: - IL_WARN("Stopping AGG while state not ON or starting\n"); - } - - write_ptr = il->txq[txq_id].q.write_ptr; - read_ptr = il->txq[txq_id].q.read_ptr; - - /* The queue is not empty */ - if (write_ptr != read_ptr) { - D_HT("Stopping a non empty AGG HW QUEUE\n"); - il->stations[sta_id].tid[tid].agg.state = - IL_EMPTYING_HW_QUEUE_DELBA; - spin_unlock_irqrestore(&il->sta_lock, flags); - return 0; - } - - D_HT("HW queue is empty\n"); - turn_off: - il->stations[sta_id].tid[tid].agg.state = IL_AGG_OFF; - - /* do not restore/save irqs */ - spin_unlock(&il->sta_lock); - spin_lock(&il->lock); - - /* - * the only reason this call can fail is queue number out of range, - * which can happen if uCode is reloaded and all the station - * information are lost. if it is outside the range, there is no need - * to deactivate the uCode queue, just return "success" to allow - * mac80211 to clean up it own data. - */ - il4965_txq_agg_disable(il, txq_id, ssn, tx_fifo_id); - spin_unlock_irqrestore(&il->lock, flags); - - ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); - - return 0; -} - -int il4965_txq_check_empty(struct il_priv *il, - int sta_id, u8 tid, int txq_id) -{ - struct il_queue *q = &il->txq[txq_id].q; - u8 *addr = il->stations[sta_id].sta.sta.addr; - struct il_tid_data *tid_data = &il->stations[sta_id].tid[tid]; - struct il_rxon_context *ctx; - - ctx = &il->ctx; - - lockdep_assert_held(&il->sta_lock); - - switch (il->stations[sta_id].tid[tid].agg.state) { - case IL_EMPTYING_HW_QUEUE_DELBA: - /* We are reclaiming the last packet of the */ - /* aggregated HW queue */ - if (txq_id == tid_data->agg.txq_id && - q->read_ptr == q->write_ptr) { - u16 ssn = SEQ_TO_SN(tid_data->seq_number); - int tx_fifo = il4965_get_fifo_from_tid(ctx, tid); - D_HT( - "HW queue empty: continue DELBA flow\n"); - il4965_txq_agg_disable(il, txq_id, ssn, tx_fifo); - tid_data->agg.state = IL_AGG_OFF; - ieee80211_stop_tx_ba_cb_irqsafe(ctx->vif, addr, tid); - } - break; - case IL_EMPTYING_HW_QUEUE_ADDBA: - /* We are reclaiming the last packet of the queue */ - if (tid_data->tfds_in_queue == 0) { - D_HT( - "HW queue empty: continue ADDBA flow\n"); - tid_data->agg.state = IL_AGG_ON; - ieee80211_start_tx_ba_cb_irqsafe(ctx->vif, addr, tid); - } - break; - } - - return 0; -} - -static void il4965_non_agg_tx_status(struct il_priv *il, - struct il_rxon_context *ctx, - const u8 *addr1) -{ - struct ieee80211_sta *sta; - struct il_station_priv *sta_priv; - - rcu_read_lock(); - sta = ieee80211_find_sta(ctx->vif, addr1); - if (sta) { - sta_priv = (void *)sta->drv_priv; - /* avoid atomic ops if this isn't a client */ - if (sta_priv->client && - atomic_dec_return(&sta_priv->pending_frames) == 0) - ieee80211_sta_block_awake(il->hw, sta, false); - } - rcu_read_unlock(); -} - -static void -il4965_tx_status(struct il_priv *il, struct il_tx_info *tx_info, - bool is_agg) -{ - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx_info->skb->data; - - if (!is_agg) - il4965_non_agg_tx_status(il, tx_info->ctx, hdr->addr1); - - ieee80211_tx_status_irqsafe(il->hw, tx_info->skb); -} - -int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx) -{ - struct il_tx_queue *txq = &il->txq[txq_id]; - struct il_queue *q = &txq->q; - struct il_tx_info *tx_info; - int nfreed = 0; - struct ieee80211_hdr *hdr; - - if (idx >= q->n_bd || il_queue_used(q, idx) == 0) { - IL_ERR("Read idx for DMA queue txq id (%d), idx %d, " - "is out of range [0-%d] %d %d.\n", txq_id, - idx, q->n_bd, q->write_ptr, q->read_ptr); - return 0; - } - - for (idx = il_queue_inc_wrap(idx, q->n_bd); - q->read_ptr != idx; - q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { - - tx_info = &txq->txb[txq->q.read_ptr]; - - if (WARN_ON_ONCE(tx_info->skb == NULL)) - continue; - - hdr = (struct ieee80211_hdr *)tx_info->skb->data; - if (ieee80211_is_data_qos(hdr->frame_control)) - nfreed++; - - il4965_tx_status(il, tx_info, - txq_id >= IL4965_FIRST_AMPDU_QUEUE); - tx_info->skb = NULL; - - il->cfg->ops->lib->txq_free_tfd(il, txq); - } - return nfreed; -} - -/** - * il4965_tx_status_reply_compressed_ba - Update tx status from block-ack - * - * Go through block-ack's bitmap of ACK'd frames, update driver's record of - * ACK vs. not. This gets sent to mac80211, then to rate scaling algo. - */ -static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, - struct il_ht_agg *agg, - struct il_compressed_ba_resp *ba_resp) - -{ - int i, sh, ack; - u16 seq_ctl = le16_to_cpu(ba_resp->seq_ctl); - u16 scd_flow = le16_to_cpu(ba_resp->scd_flow); - int successes = 0; - struct ieee80211_tx_info *info; - u64 bitmap, sent_bitmap; - - if (unlikely(!agg->wait_for_ba)) { - if (unlikely(ba_resp->bitmap)) - IL_ERR("Received BA when not expected\n"); - return -EINVAL; - } - - /* Mark that the expected block-ack response arrived */ - agg->wait_for_ba = 0; - D_TX_REPLY("BA %d %d\n", agg->start_idx, - ba_resp->seq_ctl); - - /* Calculate shift to align block-ack bits with our Tx win bits */ - sh = agg->start_idx - SEQ_TO_IDX(seq_ctl >> 4); - if (sh < 0) /* tbw something is wrong with indices */ - sh += 0x100; - - if (agg->frame_count > (64 - sh)) { - D_TX_REPLY("more frames than bitmap size"); - return -1; - } - - /* don't use 64-bit values for now */ - bitmap = le64_to_cpu(ba_resp->bitmap) >> sh; - - /* check for success or failure according to the - * transmitted bitmap and block-ack bitmap */ - sent_bitmap = bitmap & agg->bitmap; - - /* For each frame attempted in aggregation, - * update driver's record of tx frame's status. */ - i = 0; - while (sent_bitmap) { - ack = sent_bitmap & 1ULL; - successes += ack; - D_TX_REPLY("%s ON i=%d idx=%d raw=%d\n", - ack ? "ACK" : "NACK", i, - (agg->start_idx + i) & 0xff, - agg->start_idx + i); - sent_bitmap >>= 1; - ++i; - } - - D_TX_REPLY("Bitmap %llx\n", - (unsigned long long)bitmap); - - info = IEEE80211_SKB_CB(il->txq[scd_flow].txb[agg->start_idx].skb); - memset(&info->status, 0, sizeof(info->status)); - info->flags |= IEEE80211_TX_STAT_ACK; - info->flags |= IEEE80211_TX_STAT_AMPDU; - info->status.ampdu_ack_len = successes; - info->status.ampdu_len = agg->frame_count; - il4965_hwrate_to_tx_control(il, agg->rate_n_flags, info); - - return 0; -} - -/** - * translate ucode response to mac80211 tx status control values - */ -void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, - struct ieee80211_tx_info *info) -{ - struct ieee80211_tx_rate *r = &info->control.rates[0]; - - info->antenna_sel_tx = - ((rate_n_flags & RATE_MCS_ANT_ABC_MSK) >> RATE_MCS_ANT_POS); - if (rate_n_flags & RATE_MCS_HT_MSK) - r->flags |= IEEE80211_TX_RC_MCS; - if (rate_n_flags & RATE_MCS_GF_MSK) - r->flags |= IEEE80211_TX_RC_GREEN_FIELD; - if (rate_n_flags & RATE_MCS_HT40_MSK) - r->flags |= IEEE80211_TX_RC_40_MHZ_WIDTH; - if (rate_n_flags & RATE_MCS_DUP_MSK) - r->flags |= IEEE80211_TX_RC_DUP_DATA; - if (rate_n_flags & RATE_MCS_SGI_MSK) - r->flags |= IEEE80211_TX_RC_SHORT_GI; - r->idx = il4965_hwrate_to_mac80211_idx(rate_n_flags, info->band); -} - -/** - * il4965_rx_reply_compressed_ba - Handler for REPLY_COMPRESSED_BA - * - * Handles block-acknowledge notification from device, which reports success - * of frames sent via aggregation. - */ -void il4965_rx_reply_compressed_ba(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il_compressed_ba_resp *ba_resp = &pkt->u.compressed_ba; - struct il_tx_queue *txq = NULL; - struct il_ht_agg *agg; - int idx; - int sta_id; - int tid; - unsigned long flags; - - /* "flow" corresponds to Tx queue */ - u16 scd_flow = le16_to_cpu(ba_resp->scd_flow); - - /* "ssn" is start of block-ack Tx win, corresponds to idx - * (in Tx queue's circular buffer) of first TFD/frame in win */ - u16 ba_resp_scd_ssn = le16_to_cpu(ba_resp->scd_ssn); - - if (scd_flow >= il->hw_params.max_txq_num) { - IL_ERR( - "BUG_ON scd_flow is bigger than number of queues\n"); - return; - } - - txq = &il->txq[scd_flow]; - sta_id = ba_resp->sta_id; - tid = ba_resp->tid; - agg = &il->stations[sta_id].tid[tid].agg; - if (unlikely(agg->txq_id != scd_flow)) { - /* - * FIXME: this is a uCode bug which need to be addressed, - * log the information and return for now! - * since it is possible happen very often and in order - * not to fill the syslog, don't enable the logging by default - */ - D_TX_REPLY( - "BA scd_flow %d does not match txq_id %d\n", - scd_flow, agg->txq_id); - return; - } - - /* Find idx just before block-ack win */ - idx = il_queue_dec_wrap(ba_resp_scd_ssn & 0xff, txq->q.n_bd); - - spin_lock_irqsave(&il->sta_lock, flags); - - D_TX_REPLY("REPLY_COMPRESSED_BA [%d] Received from %pM, " - "sta_id = %d\n", - agg->wait_for_ba, - (u8 *) &ba_resp->sta_addr_lo32, - ba_resp->sta_id); - D_TX_REPLY("TID = %d, SeqCtl = %d, bitmap = 0x%llx," - "scd_flow = " - "%d, scd_ssn = %d\n", - ba_resp->tid, - ba_resp->seq_ctl, - (unsigned long long)le64_to_cpu(ba_resp->bitmap), - ba_resp->scd_flow, - ba_resp->scd_ssn); - D_TX_REPLY("DAT start_idx = %d, bitmap = 0x%llx\n", - agg->start_idx, - (unsigned long long)agg->bitmap); - - /* Update driver's record of ACK vs. not for each frame in win */ - il4965_tx_status_reply_compressed_ba(il, agg, ba_resp); - - /* Release all TFDs before the SSN, i.e. all TFDs in front of - * block-ack win (we assume that they've been successfully - * transmitted ... if not, it's too late anyway). */ - if (txq->q.read_ptr != (ba_resp_scd_ssn & 0xff)) { - /* calculate mac80211 ampdu sw queue to wake */ - int freed = il4965_tx_queue_reclaim(il, scd_flow, idx); - il4965_free_tfds_in_queue(il, sta_id, tid, freed); - - if (il_queue_space(&txq->q) > txq->q.low_mark && - il->mac80211_registered && - agg->state != IL_EMPTYING_HW_QUEUE_DELBA) - il_wake_queue(il, txq); - - il4965_txq_check_empty(il, sta_id, tid, scd_flow); - } - - spin_unlock_irqrestore(&il->sta_lock, flags); -} - -#ifdef CONFIG_IWLEGACY_DEBUG -const char *il4965_get_tx_fail_reason(u32 status) -{ -#define TX_STATUS_FAIL(x) case TX_STATUS_FAIL_ ## x: return #x -#define TX_STATUS_POSTPONE(x) case TX_STATUS_POSTPONE_ ## x: return #x - - switch (status & TX_STATUS_MSK) { - case TX_STATUS_SUCCESS: - return "SUCCESS"; - TX_STATUS_POSTPONE(DELAY); - TX_STATUS_POSTPONE(FEW_BYTES); - TX_STATUS_POSTPONE(QUIET_PERIOD); - TX_STATUS_POSTPONE(CALC_TTAK); - TX_STATUS_FAIL(INTERNAL_CROSSED_RETRY); - TX_STATUS_FAIL(SHORT_LIMIT); - TX_STATUS_FAIL(LONG_LIMIT); - TX_STATUS_FAIL(FIFO_UNDERRUN); - TX_STATUS_FAIL(DRAIN_FLOW); - TX_STATUS_FAIL(RFKILL_FLUSH); - TX_STATUS_FAIL(LIFE_EXPIRE); - TX_STATUS_FAIL(DEST_PS); - TX_STATUS_FAIL(HOST_ABORTED); - TX_STATUS_FAIL(BT_RETRY); - TX_STATUS_FAIL(STA_INVALID); - TX_STATUS_FAIL(FRAG_DROPPED); - TX_STATUS_FAIL(TID_DISABLE); - TX_STATUS_FAIL(FIFO_FLUSHED); - TX_STATUS_FAIL(INSUFFICIENT_CF_POLL); - TX_STATUS_FAIL(PASSIVE_NO_RX); - TX_STATUS_FAIL(NO_BEACON_ON_RADAR); - } - - return "UNKNOWN"; - -#undef TX_STATUS_FAIL -#undef TX_STATUS_POSTPONE -} -#endif /* CONFIG_IWLEGACY_DEBUG */ -- cgit v1.2.3 From fcb74588dccb06d8e3e13afb36c5401cae470518 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 30 Aug 2011 13:06:03 +0200 Subject: iwlegacy: merge iwl-4965-lib.c into 4965-mac.c Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/4965-mac.c | 1152 +++++++++++++++++++++++++ drivers/net/wireless/iwlegacy/Makefile | 2 +- drivers/net/wireless/iwlegacy/iwl-4965-lib.c | 1194 -------------------------- 3 files changed, 1153 insertions(+), 1195 deletions(-) delete mode 100644 drivers/net/wireless/iwlegacy/iwl-4965-lib.c (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index b6f96b4b1f5c..d817d8d3fe18 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -86,6 +86,1158 @@ MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); MODULE_LICENSE("GPL"); MODULE_ALIAS("iwl4965"); +void il4965_check_abort_status(struct il_priv *il, + u8 frame_count, u32 status) +{ + if (frame_count == 1 && status == TX_STATUS_FAIL_RFKILL_FLUSH) { + IL_ERR("Tx flush command to flush out all frames\n"); + if (!test_bit(STATUS_EXIT_PENDING, &il->status)) + queue_work(il->workqueue, &il->tx_flush); + } +} + +/* + * EEPROM + */ +struct il_mod_params il4965_mod_params = { + .amsdu_size_8K = 1, + .restart_fw = 1, + /* the rest are 0 by default */ +}; + +void il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) +{ + unsigned long flags; + int i; + spin_lock_irqsave(&rxq->lock, flags); + INIT_LIST_HEAD(&rxq->rx_free); + INIT_LIST_HEAD(&rxq->rx_used); + /* Fill the rx_used queue with _all_ of the Rx buffers */ + for (i = 0; i < RX_FREE_BUFFERS + RX_QUEUE_SIZE; i++) { + /* In the reset function, these buffers may have been allocated + * to an SKB, so we need to unmap and free potential storage */ + if (rxq->pool[i].page != NULL) { + pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); + __il_free_pages(il, rxq->pool[i].page); + rxq->pool[i].page = NULL; + } + list_add_tail(&rxq->pool[i].list, &rxq->rx_used); + } + + for (i = 0; i < RX_QUEUE_SIZE; i++) + rxq->queue[i] = NULL; + + /* Set us so that we have processed and used all buffers, but have + * not restocked the Rx queue with fresh buffers */ + rxq->read = rxq->write = 0; + rxq->write_actual = 0; + rxq->free_count = 0; + spin_unlock_irqrestore(&rxq->lock, flags); +} + +int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) +{ + u32 rb_size; + const u32 rfdnlog = RX_QUEUE_SIZE_LOG; /* 256 RBDs */ + u32 rb_timeout = 0; + + if (il->cfg->mod_params->amsdu_size_8K) + rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K; + else + rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K; + + /* Stop Rx DMA */ + il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); + + /* Reset driver's Rx queue write idx */ + il_wr(il, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); + + /* Tell device where to find RBD circular buffer in DRAM */ + il_wr(il, FH_RSCSR_CHNL0_RBDCB_BASE_REG, + (u32)(rxq->bd_dma >> 8)); + + /* Tell device where in DRAM to update its Rx status */ + il_wr(il, FH_RSCSR_CHNL0_STTS_WPTR_REG, + rxq->rb_stts_dma >> 4); + + /* Enable Rx DMA + * Direct rx interrupts to hosts + * Rx buffer size 4 or 8k + * RB timeout 0x10 + * 256 RBDs + */ + il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, + FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL | + FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL | + FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK | + rb_size| + (rb_timeout << FH_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS)| + (rfdnlog << FH_RCSR_RX_CONFIG_RBDCB_SIZE_POS)); + + /* Set interrupt coalescing timer to default (2048 usecs) */ + il_write8(il, CSR_INT_COALESCING, IL_HOST_INT_TIMEOUT_DEF); + + return 0; +} + +static void il4965_set_pwr_vmain(struct il_priv *il) +{ +/* + * (for documentation purposes) + * to set power to V_AUX, do: + + if (pci_pme_capable(il->pci_dev, PCI_D3cold)) + il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, + APMG_PS_CTRL_VAL_PWR_SRC_VAUX, + ~APMG_PS_CTRL_MSK_PWR_SRC); + */ + + il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, + APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, + ~APMG_PS_CTRL_MSK_PWR_SRC); +} + +int il4965_hw_nic_init(struct il_priv *il) +{ + unsigned long flags; + struct il_rx_queue *rxq = &il->rxq; + int ret; + + /* nic_init */ + spin_lock_irqsave(&il->lock, flags); + il->cfg->ops->lib->apm_ops.init(il); + + /* Set interrupt coalescing calibration timer to default (512 usecs) */ + il_write8(il, CSR_INT_COALESCING, IL_HOST_INT_CALIB_TIMEOUT_DEF); + + spin_unlock_irqrestore(&il->lock, flags); + + il4965_set_pwr_vmain(il); + + il->cfg->ops->lib->apm_ops.config(il); + + /* Allocate the RX queue, or reset if it is already allocated */ + if (!rxq->bd) { + ret = il_rx_queue_alloc(il); + if (ret) { + IL_ERR("Unable to initialize Rx queue\n"); + return -ENOMEM; + } + } else + il4965_rx_queue_reset(il, rxq); + + il4965_rx_replenish(il); + + il4965_rx_init(il, rxq); + + spin_lock_irqsave(&il->lock, flags); + + rxq->need_update = 1; + il_rx_queue_update_write_ptr(il, rxq); + + spin_unlock_irqrestore(&il->lock, flags); + + /* Allocate or reset and init all Tx and Command queues */ + if (!il->txq) { + ret = il4965_txq_ctx_alloc(il); + if (ret) + return ret; + } else + il4965_txq_ctx_reset(il); + + set_bit(STATUS_INIT, &il->status); + + return 0; +} + +/** + * il4965_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr + */ +static inline __le32 il4965_dma_addr2rbd_ptr(struct il_priv *il, + dma_addr_t dma_addr) +{ + return cpu_to_le32((u32)(dma_addr >> 8)); +} + +/** + * il4965_rx_queue_restock - refill RX queue from pre-allocated pool + * + * If there are slots in the RX queue that need to be restocked, + * and we have free pre-allocated buffers, fill the ranks as much + * as we can, pulling from rx_free. + * + * This moves the 'write' idx forward to catch up with 'processed', and + * also updates the memory address in the firmware to reference the new + * target buffer. + */ +void il4965_rx_queue_restock(struct il_priv *il) +{ + struct il_rx_queue *rxq = &il->rxq; + struct list_head *element; + struct il_rx_buf *rxb; + unsigned long flags; + + spin_lock_irqsave(&rxq->lock, flags); + while (il_rx_queue_space(rxq) > 0 && rxq->free_count) { + /* The overwritten rxb must be a used one */ + rxb = rxq->queue[rxq->write]; + BUG_ON(rxb && rxb->page); + + /* Get next free Rx buffer, remove from free list */ + element = rxq->rx_free.next; + rxb = list_entry(element, struct il_rx_buf, list); + list_del(element); + + /* Point to Rx buffer via next RBD in circular buffer */ + rxq->bd[rxq->write] = il4965_dma_addr2rbd_ptr(il, + rxb->page_dma); + rxq->queue[rxq->write] = rxb; + rxq->write = (rxq->write + 1) & RX_QUEUE_MASK; + rxq->free_count--; + } + spin_unlock_irqrestore(&rxq->lock, flags); + /* If the pre-allocated buffer pool is dropping low, schedule to + * refill it */ + if (rxq->free_count <= RX_LOW_WATERMARK) + queue_work(il->workqueue, &il->rx_replenish); + + + /* If we've added more space for the firmware to place data, tell it. + * Increment device's write pointer in multiples of 8. */ + if (rxq->write_actual != (rxq->write & ~0x7)) { + spin_lock_irqsave(&rxq->lock, flags); + rxq->need_update = 1; + spin_unlock_irqrestore(&rxq->lock, flags); + il_rx_queue_update_write_ptr(il, rxq); + } +} + +/** + * il4965_rx_replenish - Move all used packet from rx_used to rx_free + * + * When moving to rx_free an SKB is allocated for the slot. + * + * Also restock the Rx queue via il_rx_queue_restock. + * This is called as a scheduled work item (except for during initialization) + */ +static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) +{ + struct il_rx_queue *rxq = &il->rxq; + struct list_head *element; + struct il_rx_buf *rxb; + struct page *page; + unsigned long flags; + gfp_t gfp_mask = priority; + + while (1) { + spin_lock_irqsave(&rxq->lock, flags); + if (list_empty(&rxq->rx_used)) { + spin_unlock_irqrestore(&rxq->lock, flags); + return; + } + spin_unlock_irqrestore(&rxq->lock, flags); + + if (rxq->free_count > RX_LOW_WATERMARK) + gfp_mask |= __GFP_NOWARN; + + if (il->hw_params.rx_page_order > 0) + gfp_mask |= __GFP_COMP; + + /* Alloc a new receive buffer */ + page = alloc_pages(gfp_mask, il->hw_params.rx_page_order); + if (!page) { + if (net_ratelimit()) + D_INFO("alloc_pages failed, " + "order: %d\n", + il->hw_params.rx_page_order); + + if (rxq->free_count <= RX_LOW_WATERMARK && + net_ratelimit()) + IL_ERR( + "Failed to alloc_pages with %s. " + "Only %u free buffers remaining.\n", + priority == GFP_ATOMIC ? + "GFP_ATOMIC" : "GFP_KERNEL", + rxq->free_count); + /* We don't reschedule replenish work here -- we will + * call the restock method and if it still needs + * more buffers it will schedule replenish */ + return; + } + + spin_lock_irqsave(&rxq->lock, flags); + + if (list_empty(&rxq->rx_used)) { + spin_unlock_irqrestore(&rxq->lock, flags); + __free_pages(page, il->hw_params.rx_page_order); + return; + } + element = rxq->rx_used.next; + rxb = list_entry(element, struct il_rx_buf, list); + list_del(element); + + spin_unlock_irqrestore(&rxq->lock, flags); + + BUG_ON(rxb->page); + rxb->page = page; + /* Get physical address of the RB */ + rxb->page_dma = pci_map_page(il->pci_dev, page, 0, + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); + /* dma address must be no more than 36 bits */ + BUG_ON(rxb->page_dma & ~DMA_BIT_MASK(36)); + /* and also 256 byte aligned! */ + BUG_ON(rxb->page_dma & DMA_BIT_MASK(8)); + + spin_lock_irqsave(&rxq->lock, flags); + + list_add_tail(&rxb->list, &rxq->rx_free); + rxq->free_count++; + il->alloc_rxb_page++; + + spin_unlock_irqrestore(&rxq->lock, flags); + } +} + +void il4965_rx_replenish(struct il_priv *il) +{ + unsigned long flags; + + il4965_rx_allocate(il, GFP_KERNEL); + + spin_lock_irqsave(&il->lock, flags); + il4965_rx_queue_restock(il); + spin_unlock_irqrestore(&il->lock, flags); +} + +void il4965_rx_replenish_now(struct il_priv *il) +{ + il4965_rx_allocate(il, GFP_ATOMIC); + + il4965_rx_queue_restock(il); +} + +/* Assumes that the skb field of the buffers in 'pool' is kept accurate. + * If an SKB has been detached, the POOL needs to have its SKB set to NULL + * This free routine walks the list of POOL entries and if SKB is set to + * non NULL it is unmapped and freed + */ +void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq) +{ + int i; + for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { + if (rxq->pool[i].page != NULL) { + pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); + __il_free_pages(il, rxq->pool[i].page); + rxq->pool[i].page = NULL; + } + } + + dma_free_coherent(&il->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, + rxq->bd_dma); + dma_free_coherent(&il->pci_dev->dev, sizeof(struct il_rb_status), + rxq->rb_stts, rxq->rb_stts_dma); + rxq->bd = NULL; + rxq->rb_stts = NULL; +} + +int il4965_rxq_stop(struct il_priv *il) +{ + + /* stop Rx DMA */ + il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); + il_poll_bit(il, FH_MEM_RSSR_RX_STATUS_REG, + FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); + + return 0; +} + +int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) +{ + int idx = 0; + int band_offset = 0; + + /* HT rate format: mac80211 wants an MCS number, which is just LSB */ + if (rate_n_flags & RATE_MCS_HT_MSK) { + idx = (rate_n_flags & 0xff); + return idx; + /* Legacy rate format, search for match in table */ + } else { + if (band == IEEE80211_BAND_5GHZ) + band_offset = IL_FIRST_OFDM_RATE; + for (idx = band_offset; idx < RATE_COUNT_LEGACY; idx++) + if (il_rates[idx].plcp == (rate_n_flags & 0xFF)) + return idx - band_offset; + } + + return -1; +} + +static int il4965_calc_rssi(struct il_priv *il, + struct il_rx_phy_res *rx_resp) +{ + /* data from PHY/DSP regarding signal strength, etc., + * contents are always there, not configurable by host. */ + struct il4965_rx_non_cfg_phy *ncphy = + (struct il4965_rx_non_cfg_phy *)rx_resp->non_cfg_phy_buf; + u32 agc = (le16_to_cpu(ncphy->agc_info) & IL49_AGC_DB_MASK) + >> IL49_AGC_DB_POS; + + u32 valid_antennae = + (le16_to_cpu(rx_resp->phy_flags) & IL49_RX_PHY_FLAGS_ANTENNAE_MASK) + >> IL49_RX_PHY_FLAGS_ANTENNAE_OFFSET; + u8 max_rssi = 0; + u32 i; + + /* Find max rssi among 3 possible receivers. + * These values are measured by the digital signal processor (DSP). + * They should stay fairly constant even as the signal strength varies, + * if the radio's automatic gain control (AGC) is working right. + * AGC value (see below) will provide the "interesting" info. */ + for (i = 0; i < 3; i++) + if (valid_antennae & (1 << i)) + max_rssi = max(ncphy->rssi_info[i << 1], max_rssi); + + D_STATS("Rssi In A %d B %d C %d Max %d AGC dB %d\n", + ncphy->rssi_info[0], ncphy->rssi_info[2], ncphy->rssi_info[4], + max_rssi, agc); + + /* dBm = max_rssi dB - agc dB - constant. + * Higher AGC (higher radio gain) means lower signal. */ + return max_rssi - agc - IL4965_RSSI_OFFSET; +} + + +static u32 il4965_translate_rx_status(struct il_priv *il, u32 decrypt_in) +{ + u32 decrypt_out = 0; + + if ((decrypt_in & RX_RES_STATUS_STATION_FOUND) == + RX_RES_STATUS_STATION_FOUND) + decrypt_out |= (RX_RES_STATUS_STATION_FOUND | + RX_RES_STATUS_NO_STATION_INFO_MISMATCH); + + decrypt_out |= (decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK); + + /* packet was not encrypted */ + if ((decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) == + RX_RES_STATUS_SEC_TYPE_NONE) + return decrypt_out; + + /* packet was encrypted with unknown alg */ + if ((decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) == + RX_RES_STATUS_SEC_TYPE_ERR) + return decrypt_out; + + /* decryption was not done in HW */ + if ((decrypt_in & RX_MPDU_RES_STATUS_DEC_DONE_MSK) != + RX_MPDU_RES_STATUS_DEC_DONE_MSK) + return decrypt_out; + + switch (decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) { + + case RX_RES_STATUS_SEC_TYPE_CCMP: + /* alg is CCM: check MIC only */ + if (!(decrypt_in & RX_MPDU_RES_STATUS_MIC_OK)) + /* Bad MIC */ + decrypt_out |= RX_RES_STATUS_BAD_ICV_MIC; + else + decrypt_out |= RX_RES_STATUS_DECRYPT_OK; + + break; + + case RX_RES_STATUS_SEC_TYPE_TKIP: + if (!(decrypt_in & RX_MPDU_RES_STATUS_TTAK_OK)) { + /* Bad TTAK */ + decrypt_out |= RX_RES_STATUS_BAD_KEY_TTAK; + break; + } + /* fall through if TTAK OK */ + default: + if (!(decrypt_in & RX_MPDU_RES_STATUS_ICV_OK)) + decrypt_out |= RX_RES_STATUS_BAD_ICV_MIC; + else + decrypt_out |= RX_RES_STATUS_DECRYPT_OK; + break; + } + + D_RX("decrypt_in:0x%x decrypt_out = 0x%x\n", + decrypt_in, decrypt_out); + + return decrypt_out; +} + +static void il4965_pass_packet_to_mac80211(struct il_priv *il, + struct ieee80211_hdr *hdr, + u16 len, + u32 ampdu_status, + struct il_rx_buf *rxb, + struct ieee80211_rx_status *stats) +{ + struct sk_buff *skb; + __le16 fc = hdr->frame_control; + + /* We only process data packets if the interface is open */ + if (unlikely(!il->is_open)) { + D_DROP( + "Dropping packet while interface is not open.\n"); + return; + } + + /* In case of HW accelerated crypto and bad decryption, drop */ + if (!il->cfg->mod_params->sw_crypto && + il_set_decrypted_flag(il, hdr, ampdu_status, stats)) + return; + + skb = dev_alloc_skb(128); + if (!skb) { + IL_ERR("dev_alloc_skb failed\n"); + return; + } + + skb_add_rx_frag(skb, 0, rxb->page, (void *)hdr - rxb_addr(rxb), len); + + il_update_stats(il, false, fc, len); + memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats)); + + ieee80211_rx(il->hw, skb); + il->alloc_rxb_page--; + rxb->page = NULL; +} + +/* Called for REPLY_RX (legacy ABG frames), or + * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */ +void il4965_rx_reply_rx(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct ieee80211_hdr *header; + struct ieee80211_rx_status rx_status; + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il_rx_phy_res *phy_res; + __le32 rx_pkt_status; + struct il_rx_mpdu_res_start *amsdu; + u32 len; + u32 ampdu_status; + u32 rate_n_flags; + + /** + * REPLY_RX and REPLY_RX_MPDU_CMD are handled differently. + * REPLY_RX: physical layer info is in this buffer + * REPLY_RX_MPDU_CMD: physical layer info was sent in separate + * command and cached in il->last_phy_res + * + * Here we set up local variables depending on which command is + * received. + */ + if (pkt->hdr.cmd == REPLY_RX) { + phy_res = (struct il_rx_phy_res *)pkt->u.raw; + header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*phy_res) + + phy_res->cfg_phy_cnt); + + len = le16_to_cpu(phy_res->byte_count); + rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*phy_res) + + phy_res->cfg_phy_cnt + len); + ampdu_status = le32_to_cpu(rx_pkt_status); + } else { + if (!il->_4965.last_phy_res_valid) { + IL_ERR("MPDU frame without cached PHY data\n"); + return; + } + phy_res = &il->_4965.last_phy_res; + amsdu = (struct il_rx_mpdu_res_start *)pkt->u.raw; + header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*amsdu)); + len = le16_to_cpu(amsdu->byte_count); + rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*amsdu) + len); + ampdu_status = il4965_translate_rx_status(il, + le32_to_cpu(rx_pkt_status)); + } + + if ((unlikely(phy_res->cfg_phy_cnt > 20))) { + D_DROP("dsp size out of range [0,20]: %d/n", + phy_res->cfg_phy_cnt); + return; + } + + if (!(rx_pkt_status & RX_RES_STATUS_NO_CRC32_ERROR) || + !(rx_pkt_status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { + D_RX("Bad CRC or FIFO: 0x%08X.\n", + le32_to_cpu(rx_pkt_status)); + return; + } + + /* This will be used in several places later */ + rate_n_flags = le32_to_cpu(phy_res->rate_n_flags); + + /* rx_status carries information about the packet to mac80211 */ + rx_status.mactime = le64_to_cpu(phy_res->timestamp); + rx_status.band = (phy_res->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? + IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; + rx_status.freq = + ieee80211_channel_to_frequency(le16_to_cpu(phy_res->channel), + rx_status.band); + rx_status.rate_idx = + il4965_hwrate_to_mac80211_idx(rate_n_flags, rx_status.band); + rx_status.flag = 0; + + /* TSF isn't reliable. In order to allow smooth user experience, + * this W/A doesn't propagate it to the mac80211 */ + /*rx_status.flag |= RX_FLAG_MACTIME_MPDU;*/ + + il->ucode_beacon_time = le32_to_cpu(phy_res->beacon_time_stamp); + + /* Find max signal strength (dBm) among 3 antenna/receiver chains */ + rx_status.signal = il4965_calc_rssi(il, phy_res); + + il_dbg_log_rx_data_frame(il, len, header); + D_STATS("Rssi %d, TSF %llu\n", + rx_status.signal, (unsigned long long)rx_status.mactime); + + /* + * "antenna number" + * + * It seems that the antenna field in the phy flags value + * is actually a bit field. This is undefined by radiotap, + * it wants an actual antenna number but I always get "7" + * for most legacy frames I receive indicating that the + * same frame was received on all three RX chains. + * + * I think this field should be removed in favor of a + * new 802.11n radiotap field "RX chains" that is defined + * as a bitmask. + */ + rx_status.antenna = + (le16_to_cpu(phy_res->phy_flags) & RX_RES_PHY_FLAGS_ANTENNA_MSK) + >> RX_RES_PHY_FLAGS_ANTENNA_POS; + + /* set the preamble flag if appropriate */ + if (phy_res->phy_flags & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK) + rx_status.flag |= RX_FLAG_SHORTPRE; + + /* Set up the HT phy flags */ + if (rate_n_flags & RATE_MCS_HT_MSK) + rx_status.flag |= RX_FLAG_HT; + if (rate_n_flags & RATE_MCS_HT40_MSK) + rx_status.flag |= RX_FLAG_40MHZ; + if (rate_n_flags & RATE_MCS_SGI_MSK) + rx_status.flag |= RX_FLAG_SHORT_GI; + + il4965_pass_packet_to_mac80211(il, header, len, ampdu_status, + rxb, &rx_status); +} + +/* Cache phy data (Rx signal strength, etc) for HT frame (REPLY_RX_PHY_CMD). + * This will be used later in il_rx_reply_rx() for REPLY_RX_MPDU_CMD. */ +void il4965_rx_reply_rx_phy(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + il->_4965.last_phy_res_valid = true; + memcpy(&il->_4965.last_phy_res, pkt->u.raw, + sizeof(struct il_rx_phy_res)); +} + +static int il4965_get_channels_for_scan(struct il_priv *il, + struct ieee80211_vif *vif, + enum ieee80211_band band, + u8 is_active, u8 n_probes, + struct il_scan_channel *scan_ch) +{ + struct ieee80211_channel *chan; + const struct ieee80211_supported_band *sband; + const struct il_channel_info *ch_info; + u16 passive_dwell = 0; + u16 active_dwell = 0; + int added, i; + u16 channel; + + sband = il_get_hw_mode(il, band); + if (!sband) + return 0; + + active_dwell = il_get_active_dwell_time(il, band, n_probes); + passive_dwell = il_get_passive_dwell_time(il, band, vif); + + if (passive_dwell <= active_dwell) + passive_dwell = active_dwell + 1; + + for (i = 0, added = 0; i < il->scan_request->n_channels; i++) { + chan = il->scan_request->channels[i]; + + if (chan->band != band) + continue; + + channel = chan->hw_value; + scan_ch->channel = cpu_to_le16(channel); + + ch_info = il_get_channel_info(il, band, channel); + if (!il_is_channel_valid(ch_info)) { + D_SCAN( + "Channel %d is INVALID for this band.\n", + channel); + continue; + } + + if (!is_active || il_is_channel_passive(ch_info) || + (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)) + scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE; + else + scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE; + + if (n_probes) + scan_ch->type |= IL_SCAN_PROBE_MASK(n_probes); + + scan_ch->active_dwell = cpu_to_le16(active_dwell); + scan_ch->passive_dwell = cpu_to_le16(passive_dwell); + + /* Set txpower levels to defaults */ + scan_ch->dsp_atten = 110; + + /* NOTE: if we were doing 6Mb OFDM for scans we'd use + * power level: + * scan_ch->tx_gain = ((1 << 5) | (2 << 3)) | 3; + */ + if (band == IEEE80211_BAND_5GHZ) + scan_ch->tx_gain = ((1 << 5) | (3 << 3)) | 3; + else + scan_ch->tx_gain = ((1 << 5) | (5 << 3)); + + D_SCAN("Scanning ch=%d prob=0x%X [%s %d]\n", + channel, le32_to_cpu(scan_ch->type), + (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ? + "ACTIVE" : "PASSIVE", + (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ? + active_dwell : passive_dwell); + + scan_ch++; + added++; + } + + D_SCAN("total channels to scan %d\n", added); + return added; +} + +int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) +{ + struct il_host_cmd cmd = { + .id = REPLY_SCAN_CMD, + .len = sizeof(struct il_scan_cmd), + .flags = CMD_SIZE_HUGE, + }; + struct il_scan_cmd *scan; + struct il_rxon_context *ctx = &il->ctx; + u32 rate_flags = 0; + u16 cmd_len; + u16 rx_chain = 0; + enum ieee80211_band band; + u8 n_probes = 0; + u8 rx_ant = il->hw_params.valid_rx_ant; + u8 rate; + bool is_active = false; + int chan_mod; + u8 active_chains; + u8 scan_tx_antennas = il->hw_params.valid_tx_ant; + int ret; + + lockdep_assert_held(&il->mutex); + + if (vif) + ctx = il_rxon_ctx_from_vif(vif); + + if (!il->scan_cmd) { + il->scan_cmd = kmalloc(sizeof(struct il_scan_cmd) + + IL_MAX_SCAN_SIZE, GFP_KERNEL); + if (!il->scan_cmd) { + D_SCAN( + "fail to allocate memory for scan\n"); + return -ENOMEM; + } + } + scan = il->scan_cmd; + memset(scan, 0, sizeof(struct il_scan_cmd) + IL_MAX_SCAN_SIZE); + + scan->quiet_plcp_th = IL_PLCP_QUIET_THRESH; + scan->quiet_time = IL_ACTIVE_QUIET_TIME; + + if (il_is_any_associated(il)) { + u16 interval; + u32 extra; + u32 suspend_time = 100; + u32 scan_suspend_time = 100; + + D_INFO("Scanning while associated...\n"); + interval = vif->bss_conf.beacon_int; + + scan->suspend_time = 0; + scan->max_out_time = cpu_to_le32(200 * 1024); + if (!interval) + interval = suspend_time; + + extra = (suspend_time / interval) << 22; + scan_suspend_time = (extra | + ((suspend_time % interval) * 1024)); + scan->suspend_time = cpu_to_le32(scan_suspend_time); + D_SCAN("suspend_time 0x%X beacon interval %d\n", + scan_suspend_time, interval); + } + + if (il->scan_request->n_ssids) { + int i, p = 0; + D_SCAN("Kicking off active scan\n"); + for (i = 0; i < il->scan_request->n_ssids; i++) { + /* always does wildcard anyway */ + if (!il->scan_request->ssids[i].ssid_len) + continue; + scan->direct_scan[p].id = WLAN_EID_SSID; + scan->direct_scan[p].len = + il->scan_request->ssids[i].ssid_len; + memcpy(scan->direct_scan[p].ssid, + il->scan_request->ssids[i].ssid, + il->scan_request->ssids[i].ssid_len); + n_probes++; + p++; + } + is_active = true; + } else + D_SCAN("Start passive scan.\n"); + + scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; + scan->tx_cmd.sta_id = ctx->bcast_sta_id; + scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; + + switch (il->scan_band) { + case IEEE80211_BAND_2GHZ: + scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; + chan_mod = le32_to_cpu( + il->ctx.active.flags & + RXON_FLG_CHANNEL_MODE_MSK) + >> RXON_FLG_CHANNEL_MODE_POS; + if (chan_mod == CHANNEL_MODE_PURE_40) { + rate = RATE_6M_PLCP; + } else { + rate = RATE_1M_PLCP; + rate_flags = RATE_MCS_CCK_MSK; + } + break; + case IEEE80211_BAND_5GHZ: + rate = RATE_6M_PLCP; + break; + default: + IL_WARN("Invalid scan band\n"); + return -EIO; + } + + /* + * If active scanning is requested but a certain channel is + * marked passive, we can do active scanning if we detect + * transmissions. + * + * There is an issue with some firmware versions that triggers + * a sysassert on a "good CRC threshold" of zero (== disabled), + * on a radar channel even though this means that we should NOT + * send probes. + * + * The "good CRC threshold" is the number of frames that we + * need to receive during our dwell time on a channel before + * sending out probes -- setting this to a huge value will + * mean we never reach it, but at the same time work around + * the aforementioned issue. Thus use IL_GOOD_CRC_TH_NEVER + * here instead of IL_GOOD_CRC_TH_DISABLED. + */ + scan->good_CRC_th = is_active ? IL_GOOD_CRC_TH_DEFAULT : + IL_GOOD_CRC_TH_NEVER; + + band = il->scan_band; + + if (il->cfg->scan_rx_antennas[band]) + rx_ant = il->cfg->scan_rx_antennas[band]; + + il->scan_tx_ant[band] = il4965_toggle_tx_ant(il, + il->scan_tx_ant[band], + scan_tx_antennas); + rate_flags |= il4965_ant_idx_to_flags(il->scan_tx_ant[band]); + scan->tx_cmd.rate_n_flags = il4965_hw_set_rate_n_flags(rate, rate_flags); + + /* In power save mode use one chain, otherwise use all chains */ + if (test_bit(STATUS_POWER_PMI, &il->status)) { + /* rx_ant has been set to all valid chains previously */ + active_chains = rx_ant & + ((u8)(il->chain_noise_data.active_chains)); + if (!active_chains) + active_chains = rx_ant; + + D_SCAN("chain_noise_data.active_chains: %u\n", + il->chain_noise_data.active_chains); + + rx_ant = il4965_first_antenna(active_chains); + } + + /* MIMO is not used here, but value is required */ + rx_chain |= il->hw_params.valid_rx_ant << RXON_RX_CHAIN_VALID_POS; + rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS; + rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_SEL_POS; + rx_chain |= 0x1 << RXON_RX_CHAIN_DRIVER_FORCE_POS; + scan->rx_chain = cpu_to_le16(rx_chain); + + cmd_len = il_fill_probe_req(il, + (struct ieee80211_mgmt *)scan->data, + vif->addr, + il->scan_request->ie, + il->scan_request->ie_len, + IL_MAX_SCAN_SIZE - sizeof(*scan)); + scan->tx_cmd.len = cpu_to_le16(cmd_len); + + scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK | + RXON_FILTER_BCON_AWARE_MSK); + + scan->channel_count = il4965_get_channels_for_scan(il, vif, band, + is_active, n_probes, + (void *)&scan->data[cmd_len]); + if (scan->channel_count == 0) { + D_SCAN("channel count %d\n", scan->channel_count); + return -EIO; + } + + cmd.len += le16_to_cpu(scan->tx_cmd.len) + + scan->channel_count * sizeof(struct il_scan_channel); + cmd.data = scan; + scan->len = cpu_to_le16(cmd.len); + + set_bit(STATUS_SCAN_HW, &il->status); + + ret = il_send_cmd_sync(il, &cmd); + if (ret) + clear_bit(STATUS_SCAN_HW, &il->status); + + return ret; +} + +int il4965_manage_ibss_station(struct il_priv *il, + struct ieee80211_vif *vif, bool add) +{ + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; + + if (add) + return il4965_add_bssid_station(il, vif_priv->ctx, + vif->bss_conf.bssid, + &vif_priv->ibss_bssid_sta_id); + return il_remove_station(il, vif_priv->ibss_bssid_sta_id, + vif->bss_conf.bssid); +} + +void il4965_free_tfds_in_queue(struct il_priv *il, + int sta_id, int tid, int freed) +{ + lockdep_assert_held(&il->sta_lock); + + if (il->stations[sta_id].tid[tid].tfds_in_queue >= freed) + il->stations[sta_id].tid[tid].tfds_in_queue -= freed; + else { + D_TX("free more than tfds_in_queue (%u:%d)\n", + il->stations[sta_id].tid[tid].tfds_in_queue, + freed); + il->stations[sta_id].tid[tid].tfds_in_queue = 0; + } +} + +#define IL_TX_QUEUE_MSK 0xfffff + +static bool il4965_is_single_rx_stream(struct il_priv *il) +{ + return il->current_ht_config.smps == IEEE80211_SMPS_STATIC || + il->current_ht_config.single_chain_sufficient; +} + +#define IL_NUM_RX_CHAINS_MULTIPLE 3 +#define IL_NUM_RX_CHAINS_SINGLE 2 +#define IL_NUM_IDLE_CHAINS_DUAL 2 +#define IL_NUM_IDLE_CHAINS_SINGLE 1 + +/* + * Determine how many receiver/antenna chains to use. + * + * More provides better reception via diversity. Fewer saves power + * at the expense of throughput, but only when not in powersave to + * start with. + * + * MIMO (dual stream) requires at least 2, but works better with 3. + * This does not determine *which* chains to use, just how many. + */ +static int il4965_get_active_rx_chain_count(struct il_priv *il) +{ + /* # of Rx chains to use when expecting MIMO. */ + if (il4965_is_single_rx_stream(il)) + return IL_NUM_RX_CHAINS_SINGLE; + else + return IL_NUM_RX_CHAINS_MULTIPLE; +} + +/* + * When we are in power saving mode, unless device support spatial + * multiplexing power save, use the active count for rx chain count. + */ +static int +il4965_get_idle_rx_chain_count(struct il_priv *il, int active_cnt) +{ + /* # Rx chains when idling, depending on SMPS mode */ + switch (il->current_ht_config.smps) { + case IEEE80211_SMPS_STATIC: + case IEEE80211_SMPS_DYNAMIC: + return IL_NUM_IDLE_CHAINS_SINGLE; + case IEEE80211_SMPS_OFF: + return active_cnt; + default: + WARN(1, "invalid SMPS mode %d", + il->current_ht_config.smps); + return active_cnt; + } +} + +/* up to 4 chains */ +static u8 il4965_count_chain_bitmap(u32 chain_bitmap) +{ + u8 res; + res = (chain_bitmap & BIT(0)) >> 0; + res += (chain_bitmap & BIT(1)) >> 1; + res += (chain_bitmap & BIT(2)) >> 2; + res += (chain_bitmap & BIT(3)) >> 3; + return res; +} + +/** + * il4965_set_rxon_chain - Set up Rx chain usage in "staging" RXON image + * + * Selects how many and which Rx receivers/antennas/chains to use. + * This should not be used for scan command ... it puts data in wrong place. + */ +void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx) +{ + bool is_single = il4965_is_single_rx_stream(il); + bool is_cam = !test_bit(STATUS_POWER_PMI, &il->status); + u8 idle_rx_cnt, active_rx_cnt, valid_rx_cnt; + u32 active_chains; + u16 rx_chain; + + /* Tell uCode which antennas are actually connected. + * Before first association, we assume all antennas are connected. + * Just after first association, il4965_chain_noise_calibration() + * checks which antennas actually *are* connected. */ + if (il->chain_noise_data.active_chains) + active_chains = il->chain_noise_data.active_chains; + else + active_chains = il->hw_params.valid_rx_ant; + + rx_chain = active_chains << RXON_RX_CHAIN_VALID_POS; + + /* How many receivers should we use? */ + active_rx_cnt = il4965_get_active_rx_chain_count(il); + idle_rx_cnt = il4965_get_idle_rx_chain_count(il, active_rx_cnt); + + + /* correct rx chain count according hw settings + * and chain noise calibration + */ + valid_rx_cnt = il4965_count_chain_bitmap(active_chains); + if (valid_rx_cnt < active_rx_cnt) + active_rx_cnt = valid_rx_cnt; + + if (valid_rx_cnt < idle_rx_cnt) + idle_rx_cnt = valid_rx_cnt; + + rx_chain |= active_rx_cnt << RXON_RX_CHAIN_MIMO_CNT_POS; + rx_chain |= idle_rx_cnt << RXON_RX_CHAIN_CNT_POS; + + ctx->staging.rx_chain = cpu_to_le16(rx_chain); + + if (!is_single && active_rx_cnt >= IL_NUM_RX_CHAINS_SINGLE && is_cam) + ctx->staging.rx_chain |= RXON_RX_CHAIN_MIMO_FORCE_MSK; + else + ctx->staging.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK; + + D_ASSOC("rx_chain=0x%X active=%d idle=%d\n", + ctx->staging.rx_chain, + active_rx_cnt, idle_rx_cnt); + + WARN_ON(active_rx_cnt == 0 || idle_rx_cnt == 0 || + active_rx_cnt < idle_rx_cnt); +} + +u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant, u8 valid) +{ + int i; + u8 ind = ant; + + for (i = 0; i < RATE_ANT_NUM - 1; i++) { + ind = (ind + 1) < RATE_ANT_NUM ? ind + 1 : 0; + if (valid & BIT(ind)) + return ind; + } + return ant; +} + +static const char *il4965_get_fh_string(int cmd) +{ + switch (cmd) { + IL_CMD(FH_RSCSR_CHNL0_STTS_WPTR_REG); + IL_CMD(FH_RSCSR_CHNL0_RBDCB_BASE_REG); + IL_CMD(FH_RSCSR_CHNL0_WPTR); + IL_CMD(FH_MEM_RCSR_CHNL0_CONFIG_REG); + IL_CMD(FH_MEM_RSSR_SHARED_CTRL_REG); + IL_CMD(FH_MEM_RSSR_RX_STATUS_REG); + IL_CMD(FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV); + IL_CMD(FH_TSSR_TX_STATUS_REG); + IL_CMD(FH_TSSR_TX_ERROR_REG); + default: + return "UNKNOWN"; + } +} + +int il4965_dump_fh(struct il_priv *il, char **buf, bool display) +{ + int i; +#ifdef CONFIG_IWLEGACY_DEBUG + int pos = 0; + size_t bufsz = 0; +#endif + static const u32 fh_tbl[] = { + FH_RSCSR_CHNL0_STTS_WPTR_REG, + FH_RSCSR_CHNL0_RBDCB_BASE_REG, + FH_RSCSR_CHNL0_WPTR, + FH_MEM_RCSR_CHNL0_CONFIG_REG, + FH_MEM_RSSR_SHARED_CTRL_REG, + FH_MEM_RSSR_RX_STATUS_REG, + FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV, + FH_TSSR_TX_STATUS_REG, + FH_TSSR_TX_ERROR_REG + }; +#ifdef CONFIG_IWLEGACY_DEBUG + if (display) { + bufsz = ARRAY_SIZE(fh_tbl) * 48 + 40; + *buf = kmalloc(bufsz, GFP_KERNEL); + if (!*buf) + return -ENOMEM; + pos += scnprintf(*buf + pos, bufsz - pos, + "FH register values:\n"); + for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { + pos += scnprintf(*buf + pos, bufsz - pos, + " %34s: 0X%08x\n", + il4965_get_fh_string(fh_tbl[i]), + il_rd(il, fh_tbl[i])); + } + return pos; + } +#endif + IL_ERR("FH register values:\n"); + for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { + IL_ERR(" %34s: 0X%08x\n", + il4965_get_fh_string(fh_tbl[i]), + il_rd(il, fh_tbl[i])); + } + return 0; +} void il4965_rx_missed_beacon_notif(struct il_priv *il, struct il_rx_buf *rxb) diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index 884470479223..d0f9f23feea9 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -9,7 +9,7 @@ iwl-legacy-objs += $(iwl-legacy-m) # 4965 obj-$(CONFIG_IWL4965) += iwl4965.o iwl4965-objs := 4965.o 4965-mac.o iwl-4965-rs.o -iwl4965-objs += iwl-4965-lib.o iwl-4965-calib.o +iwl4965-objs += iwl-4965-calib.o iwl4965-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-4965-debugfs.o # 3945 diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c deleted file mode 100644 index bbec6bd550d3..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c +++ /dev/null @@ -1,1194 +0,0 @@ -/****************************************************************************** - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ -#include -#include -#include -#include -#include - -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-io.h" -#include "iwl-helpers.h" -#include "iwl-4965-hw.h" -#include "iwl-4965.h" -#include "iwl-sta.h" - -void il4965_check_abort_status(struct il_priv *il, - u8 frame_count, u32 status) -{ - if (frame_count == 1 && status == TX_STATUS_FAIL_RFKILL_FLUSH) { - IL_ERR("Tx flush command to flush out all frames\n"); - if (!test_bit(STATUS_EXIT_PENDING, &il->status)) - queue_work(il->workqueue, &il->tx_flush); - } -} - -/* - * EEPROM - */ -struct il_mod_params il4965_mod_params = { - .amsdu_size_8K = 1, - .restart_fw = 1, - /* the rest are 0 by default */ -}; - -void il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) -{ - unsigned long flags; - int i; - spin_lock_irqsave(&rxq->lock, flags); - INIT_LIST_HEAD(&rxq->rx_free); - INIT_LIST_HEAD(&rxq->rx_used); - /* Fill the rx_used queue with _all_ of the Rx buffers */ - for (i = 0; i < RX_FREE_BUFFERS + RX_QUEUE_SIZE; i++) { - /* In the reset function, these buffers may have been allocated - * to an SKB, so we need to unmap and free potential storage */ - if (rxq->pool[i].page != NULL) { - pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); - __il_free_pages(il, rxq->pool[i].page); - rxq->pool[i].page = NULL; - } - list_add_tail(&rxq->pool[i].list, &rxq->rx_used); - } - - for (i = 0; i < RX_QUEUE_SIZE; i++) - rxq->queue[i] = NULL; - - /* Set us so that we have processed and used all buffers, but have - * not restocked the Rx queue with fresh buffers */ - rxq->read = rxq->write = 0; - rxq->write_actual = 0; - rxq->free_count = 0; - spin_unlock_irqrestore(&rxq->lock, flags); -} - -int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) -{ - u32 rb_size; - const u32 rfdnlog = RX_QUEUE_SIZE_LOG; /* 256 RBDs */ - u32 rb_timeout = 0; - - if (il->cfg->mod_params->amsdu_size_8K) - rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K; - else - rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K; - - /* Stop Rx DMA */ - il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); - - /* Reset driver's Rx queue write idx */ - il_wr(il, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); - - /* Tell device where to find RBD circular buffer in DRAM */ - il_wr(il, FH_RSCSR_CHNL0_RBDCB_BASE_REG, - (u32)(rxq->bd_dma >> 8)); - - /* Tell device where in DRAM to update its Rx status */ - il_wr(il, FH_RSCSR_CHNL0_STTS_WPTR_REG, - rxq->rb_stts_dma >> 4); - - /* Enable Rx DMA - * Direct rx interrupts to hosts - * Rx buffer size 4 or 8k - * RB timeout 0x10 - * 256 RBDs - */ - il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, - FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL | - FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL | - FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK | - rb_size| - (rb_timeout << FH_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS)| - (rfdnlog << FH_RCSR_RX_CONFIG_RBDCB_SIZE_POS)); - - /* Set interrupt coalescing timer to default (2048 usecs) */ - il_write8(il, CSR_INT_COALESCING, IL_HOST_INT_TIMEOUT_DEF); - - return 0; -} - -static void il4965_set_pwr_vmain(struct il_priv *il) -{ -/* - * (for documentation purposes) - * to set power to V_AUX, do: - - if (pci_pme_capable(il->pci_dev, PCI_D3cold)) - il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, - APMG_PS_CTRL_VAL_PWR_SRC_VAUX, - ~APMG_PS_CTRL_MSK_PWR_SRC); - */ - - il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, - APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, - ~APMG_PS_CTRL_MSK_PWR_SRC); -} - -int il4965_hw_nic_init(struct il_priv *il) -{ - unsigned long flags; - struct il_rx_queue *rxq = &il->rxq; - int ret; - - /* nic_init */ - spin_lock_irqsave(&il->lock, flags); - il->cfg->ops->lib->apm_ops.init(il); - - /* Set interrupt coalescing calibration timer to default (512 usecs) */ - il_write8(il, CSR_INT_COALESCING, IL_HOST_INT_CALIB_TIMEOUT_DEF); - - spin_unlock_irqrestore(&il->lock, flags); - - il4965_set_pwr_vmain(il); - - il->cfg->ops->lib->apm_ops.config(il); - - /* Allocate the RX queue, or reset if it is already allocated */ - if (!rxq->bd) { - ret = il_rx_queue_alloc(il); - if (ret) { - IL_ERR("Unable to initialize Rx queue\n"); - return -ENOMEM; - } - } else - il4965_rx_queue_reset(il, rxq); - - il4965_rx_replenish(il); - - il4965_rx_init(il, rxq); - - spin_lock_irqsave(&il->lock, flags); - - rxq->need_update = 1; - il_rx_queue_update_write_ptr(il, rxq); - - spin_unlock_irqrestore(&il->lock, flags); - - /* Allocate or reset and init all Tx and Command queues */ - if (!il->txq) { - ret = il4965_txq_ctx_alloc(il); - if (ret) - return ret; - } else - il4965_txq_ctx_reset(il); - - set_bit(STATUS_INIT, &il->status); - - return 0; -} - -/** - * il4965_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr - */ -static inline __le32 il4965_dma_addr2rbd_ptr(struct il_priv *il, - dma_addr_t dma_addr) -{ - return cpu_to_le32((u32)(dma_addr >> 8)); -} - -/** - * il4965_rx_queue_restock - refill RX queue from pre-allocated pool - * - * If there are slots in the RX queue that need to be restocked, - * and we have free pre-allocated buffers, fill the ranks as much - * as we can, pulling from rx_free. - * - * This moves the 'write' idx forward to catch up with 'processed', and - * also updates the memory address in the firmware to reference the new - * target buffer. - */ -void il4965_rx_queue_restock(struct il_priv *il) -{ - struct il_rx_queue *rxq = &il->rxq; - struct list_head *element; - struct il_rx_buf *rxb; - unsigned long flags; - - spin_lock_irqsave(&rxq->lock, flags); - while (il_rx_queue_space(rxq) > 0 && rxq->free_count) { - /* The overwritten rxb must be a used one */ - rxb = rxq->queue[rxq->write]; - BUG_ON(rxb && rxb->page); - - /* Get next free Rx buffer, remove from free list */ - element = rxq->rx_free.next; - rxb = list_entry(element, struct il_rx_buf, list); - list_del(element); - - /* Point to Rx buffer via next RBD in circular buffer */ - rxq->bd[rxq->write] = il4965_dma_addr2rbd_ptr(il, - rxb->page_dma); - rxq->queue[rxq->write] = rxb; - rxq->write = (rxq->write + 1) & RX_QUEUE_MASK; - rxq->free_count--; - } - spin_unlock_irqrestore(&rxq->lock, flags); - /* If the pre-allocated buffer pool is dropping low, schedule to - * refill it */ - if (rxq->free_count <= RX_LOW_WATERMARK) - queue_work(il->workqueue, &il->rx_replenish); - - - /* If we've added more space for the firmware to place data, tell it. - * Increment device's write pointer in multiples of 8. */ - if (rxq->write_actual != (rxq->write & ~0x7)) { - spin_lock_irqsave(&rxq->lock, flags); - rxq->need_update = 1; - spin_unlock_irqrestore(&rxq->lock, flags); - il_rx_queue_update_write_ptr(il, rxq); - } -} - -/** - * il4965_rx_replenish - Move all used packet from rx_used to rx_free - * - * When moving to rx_free an SKB is allocated for the slot. - * - * Also restock the Rx queue via il_rx_queue_restock. - * This is called as a scheduled work item (except for during initialization) - */ -static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) -{ - struct il_rx_queue *rxq = &il->rxq; - struct list_head *element; - struct il_rx_buf *rxb; - struct page *page; - unsigned long flags; - gfp_t gfp_mask = priority; - - while (1) { - spin_lock_irqsave(&rxq->lock, flags); - if (list_empty(&rxq->rx_used)) { - spin_unlock_irqrestore(&rxq->lock, flags); - return; - } - spin_unlock_irqrestore(&rxq->lock, flags); - - if (rxq->free_count > RX_LOW_WATERMARK) - gfp_mask |= __GFP_NOWARN; - - if (il->hw_params.rx_page_order > 0) - gfp_mask |= __GFP_COMP; - - /* Alloc a new receive buffer */ - page = alloc_pages(gfp_mask, il->hw_params.rx_page_order); - if (!page) { - if (net_ratelimit()) - D_INFO("alloc_pages failed, " - "order: %d\n", - il->hw_params.rx_page_order); - - if (rxq->free_count <= RX_LOW_WATERMARK && - net_ratelimit()) - IL_ERR( - "Failed to alloc_pages with %s. " - "Only %u free buffers remaining.\n", - priority == GFP_ATOMIC ? - "GFP_ATOMIC" : "GFP_KERNEL", - rxq->free_count); - /* We don't reschedule replenish work here -- we will - * call the restock method and if it still needs - * more buffers it will schedule replenish */ - return; - } - - spin_lock_irqsave(&rxq->lock, flags); - - if (list_empty(&rxq->rx_used)) { - spin_unlock_irqrestore(&rxq->lock, flags); - __free_pages(page, il->hw_params.rx_page_order); - return; - } - element = rxq->rx_used.next; - rxb = list_entry(element, struct il_rx_buf, list); - list_del(element); - - spin_unlock_irqrestore(&rxq->lock, flags); - - BUG_ON(rxb->page); - rxb->page = page; - /* Get physical address of the RB */ - rxb->page_dma = pci_map_page(il->pci_dev, page, 0, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); - /* dma address must be no more than 36 bits */ - BUG_ON(rxb->page_dma & ~DMA_BIT_MASK(36)); - /* and also 256 byte aligned! */ - BUG_ON(rxb->page_dma & DMA_BIT_MASK(8)); - - spin_lock_irqsave(&rxq->lock, flags); - - list_add_tail(&rxb->list, &rxq->rx_free); - rxq->free_count++; - il->alloc_rxb_page++; - - spin_unlock_irqrestore(&rxq->lock, flags); - } -} - -void il4965_rx_replenish(struct il_priv *il) -{ - unsigned long flags; - - il4965_rx_allocate(il, GFP_KERNEL); - - spin_lock_irqsave(&il->lock, flags); - il4965_rx_queue_restock(il); - spin_unlock_irqrestore(&il->lock, flags); -} - -void il4965_rx_replenish_now(struct il_priv *il) -{ - il4965_rx_allocate(il, GFP_ATOMIC); - - il4965_rx_queue_restock(il); -} - -/* Assumes that the skb field of the buffers in 'pool' is kept accurate. - * If an SKB has been detached, the POOL needs to have its SKB set to NULL - * This free routine walks the list of POOL entries and if SKB is set to - * non NULL it is unmapped and freed - */ -void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq) -{ - int i; - for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { - if (rxq->pool[i].page != NULL) { - pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); - __il_free_pages(il, rxq->pool[i].page); - rxq->pool[i].page = NULL; - } - } - - dma_free_coherent(&il->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, - rxq->bd_dma); - dma_free_coherent(&il->pci_dev->dev, sizeof(struct il_rb_status), - rxq->rb_stts, rxq->rb_stts_dma); - rxq->bd = NULL; - rxq->rb_stts = NULL; -} - -int il4965_rxq_stop(struct il_priv *il) -{ - - /* stop Rx DMA */ - il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); - il_poll_bit(il, FH_MEM_RSSR_RX_STATUS_REG, - FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); - - return 0; -} - -int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) -{ - int idx = 0; - int band_offset = 0; - - /* HT rate format: mac80211 wants an MCS number, which is just LSB */ - if (rate_n_flags & RATE_MCS_HT_MSK) { - idx = (rate_n_flags & 0xff); - return idx; - /* Legacy rate format, search for match in table */ - } else { - if (band == IEEE80211_BAND_5GHZ) - band_offset = IL_FIRST_OFDM_RATE; - for (idx = band_offset; idx < RATE_COUNT_LEGACY; idx++) - if (il_rates[idx].plcp == (rate_n_flags & 0xFF)) - return idx - band_offset; - } - - return -1; -} - -static int il4965_calc_rssi(struct il_priv *il, - struct il_rx_phy_res *rx_resp) -{ - /* data from PHY/DSP regarding signal strength, etc., - * contents are always there, not configurable by host. */ - struct il4965_rx_non_cfg_phy *ncphy = - (struct il4965_rx_non_cfg_phy *)rx_resp->non_cfg_phy_buf; - u32 agc = (le16_to_cpu(ncphy->agc_info) & IL49_AGC_DB_MASK) - >> IL49_AGC_DB_POS; - - u32 valid_antennae = - (le16_to_cpu(rx_resp->phy_flags) & IL49_RX_PHY_FLAGS_ANTENNAE_MASK) - >> IL49_RX_PHY_FLAGS_ANTENNAE_OFFSET; - u8 max_rssi = 0; - u32 i; - - /* Find max rssi among 3 possible receivers. - * These values are measured by the digital signal processor (DSP). - * They should stay fairly constant even as the signal strength varies, - * if the radio's automatic gain control (AGC) is working right. - * AGC value (see below) will provide the "interesting" info. */ - for (i = 0; i < 3; i++) - if (valid_antennae & (1 << i)) - max_rssi = max(ncphy->rssi_info[i << 1], max_rssi); - - D_STATS("Rssi In A %d B %d C %d Max %d AGC dB %d\n", - ncphy->rssi_info[0], ncphy->rssi_info[2], ncphy->rssi_info[4], - max_rssi, agc); - - /* dBm = max_rssi dB - agc dB - constant. - * Higher AGC (higher radio gain) means lower signal. */ - return max_rssi - agc - IL4965_RSSI_OFFSET; -} - - -static u32 il4965_translate_rx_status(struct il_priv *il, u32 decrypt_in) -{ - u32 decrypt_out = 0; - - if ((decrypt_in & RX_RES_STATUS_STATION_FOUND) == - RX_RES_STATUS_STATION_FOUND) - decrypt_out |= (RX_RES_STATUS_STATION_FOUND | - RX_RES_STATUS_NO_STATION_INFO_MISMATCH); - - decrypt_out |= (decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK); - - /* packet was not encrypted */ - if ((decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) == - RX_RES_STATUS_SEC_TYPE_NONE) - return decrypt_out; - - /* packet was encrypted with unknown alg */ - if ((decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) == - RX_RES_STATUS_SEC_TYPE_ERR) - return decrypt_out; - - /* decryption was not done in HW */ - if ((decrypt_in & RX_MPDU_RES_STATUS_DEC_DONE_MSK) != - RX_MPDU_RES_STATUS_DEC_DONE_MSK) - return decrypt_out; - - switch (decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) { - - case RX_RES_STATUS_SEC_TYPE_CCMP: - /* alg is CCM: check MIC only */ - if (!(decrypt_in & RX_MPDU_RES_STATUS_MIC_OK)) - /* Bad MIC */ - decrypt_out |= RX_RES_STATUS_BAD_ICV_MIC; - else - decrypt_out |= RX_RES_STATUS_DECRYPT_OK; - - break; - - case RX_RES_STATUS_SEC_TYPE_TKIP: - if (!(decrypt_in & RX_MPDU_RES_STATUS_TTAK_OK)) { - /* Bad TTAK */ - decrypt_out |= RX_RES_STATUS_BAD_KEY_TTAK; - break; - } - /* fall through if TTAK OK */ - default: - if (!(decrypt_in & RX_MPDU_RES_STATUS_ICV_OK)) - decrypt_out |= RX_RES_STATUS_BAD_ICV_MIC; - else - decrypt_out |= RX_RES_STATUS_DECRYPT_OK; - break; - } - - D_RX("decrypt_in:0x%x decrypt_out = 0x%x\n", - decrypt_in, decrypt_out); - - return decrypt_out; -} - -static void il4965_pass_packet_to_mac80211(struct il_priv *il, - struct ieee80211_hdr *hdr, - u16 len, - u32 ampdu_status, - struct il_rx_buf *rxb, - struct ieee80211_rx_status *stats) -{ - struct sk_buff *skb; - __le16 fc = hdr->frame_control; - - /* We only process data packets if the interface is open */ - if (unlikely(!il->is_open)) { - D_DROP( - "Dropping packet while interface is not open.\n"); - return; - } - - /* In case of HW accelerated crypto and bad decryption, drop */ - if (!il->cfg->mod_params->sw_crypto && - il_set_decrypted_flag(il, hdr, ampdu_status, stats)) - return; - - skb = dev_alloc_skb(128); - if (!skb) { - IL_ERR("dev_alloc_skb failed\n"); - return; - } - - skb_add_rx_frag(skb, 0, rxb->page, (void *)hdr - rxb_addr(rxb), len); - - il_update_stats(il, false, fc, len); - memcpy(IEEE80211_SKB_RXCB(skb), stats, sizeof(*stats)); - - ieee80211_rx(il->hw, skb); - il->alloc_rxb_page--; - rxb->page = NULL; -} - -/* Called for REPLY_RX (legacy ABG frames), or - * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */ -void il4965_rx_reply_rx(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct ieee80211_hdr *header; - struct ieee80211_rx_status rx_status; - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il_rx_phy_res *phy_res; - __le32 rx_pkt_status; - struct il_rx_mpdu_res_start *amsdu; - u32 len; - u32 ampdu_status; - u32 rate_n_flags; - - /** - * REPLY_RX and REPLY_RX_MPDU_CMD are handled differently. - * REPLY_RX: physical layer info is in this buffer - * REPLY_RX_MPDU_CMD: physical layer info was sent in separate - * command and cached in il->last_phy_res - * - * Here we set up local variables depending on which command is - * received. - */ - if (pkt->hdr.cmd == REPLY_RX) { - phy_res = (struct il_rx_phy_res *)pkt->u.raw; - header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*phy_res) - + phy_res->cfg_phy_cnt); - - len = le16_to_cpu(phy_res->byte_count); - rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*phy_res) + - phy_res->cfg_phy_cnt + len); - ampdu_status = le32_to_cpu(rx_pkt_status); - } else { - if (!il->_4965.last_phy_res_valid) { - IL_ERR("MPDU frame without cached PHY data\n"); - return; - } - phy_res = &il->_4965.last_phy_res; - amsdu = (struct il_rx_mpdu_res_start *)pkt->u.raw; - header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*amsdu)); - len = le16_to_cpu(amsdu->byte_count); - rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*amsdu) + len); - ampdu_status = il4965_translate_rx_status(il, - le32_to_cpu(rx_pkt_status)); - } - - if ((unlikely(phy_res->cfg_phy_cnt > 20))) { - D_DROP("dsp size out of range [0,20]: %d/n", - phy_res->cfg_phy_cnt); - return; - } - - if (!(rx_pkt_status & RX_RES_STATUS_NO_CRC32_ERROR) || - !(rx_pkt_status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { - D_RX("Bad CRC or FIFO: 0x%08X.\n", - le32_to_cpu(rx_pkt_status)); - return; - } - - /* This will be used in several places later */ - rate_n_flags = le32_to_cpu(phy_res->rate_n_flags); - - /* rx_status carries information about the packet to mac80211 */ - rx_status.mactime = le64_to_cpu(phy_res->timestamp); - rx_status.band = (phy_res->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? - IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; - rx_status.freq = - ieee80211_channel_to_frequency(le16_to_cpu(phy_res->channel), - rx_status.band); - rx_status.rate_idx = - il4965_hwrate_to_mac80211_idx(rate_n_flags, rx_status.band); - rx_status.flag = 0; - - /* TSF isn't reliable. In order to allow smooth user experience, - * this W/A doesn't propagate it to the mac80211 */ - /*rx_status.flag |= RX_FLAG_MACTIME_MPDU;*/ - - il->ucode_beacon_time = le32_to_cpu(phy_res->beacon_time_stamp); - - /* Find max signal strength (dBm) among 3 antenna/receiver chains */ - rx_status.signal = il4965_calc_rssi(il, phy_res); - - il_dbg_log_rx_data_frame(il, len, header); - D_STATS("Rssi %d, TSF %llu\n", - rx_status.signal, (unsigned long long)rx_status.mactime); - - /* - * "antenna number" - * - * It seems that the antenna field in the phy flags value - * is actually a bit field. This is undefined by radiotap, - * it wants an actual antenna number but I always get "7" - * for most legacy frames I receive indicating that the - * same frame was received on all three RX chains. - * - * I think this field should be removed in favor of a - * new 802.11n radiotap field "RX chains" that is defined - * as a bitmask. - */ - rx_status.antenna = - (le16_to_cpu(phy_res->phy_flags) & RX_RES_PHY_FLAGS_ANTENNA_MSK) - >> RX_RES_PHY_FLAGS_ANTENNA_POS; - - /* set the preamble flag if appropriate */ - if (phy_res->phy_flags & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK) - rx_status.flag |= RX_FLAG_SHORTPRE; - - /* Set up the HT phy flags */ - if (rate_n_flags & RATE_MCS_HT_MSK) - rx_status.flag |= RX_FLAG_HT; - if (rate_n_flags & RATE_MCS_HT40_MSK) - rx_status.flag |= RX_FLAG_40MHZ; - if (rate_n_flags & RATE_MCS_SGI_MSK) - rx_status.flag |= RX_FLAG_SHORT_GI; - - il4965_pass_packet_to_mac80211(il, header, len, ampdu_status, - rxb, &rx_status); -} - -/* Cache phy data (Rx signal strength, etc) for HT frame (REPLY_RX_PHY_CMD). - * This will be used later in il_rx_reply_rx() for REPLY_RX_MPDU_CMD. */ -void il4965_rx_reply_rx_phy(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - il->_4965.last_phy_res_valid = true; - memcpy(&il->_4965.last_phy_res, pkt->u.raw, - sizeof(struct il_rx_phy_res)); -} - -static int il4965_get_channels_for_scan(struct il_priv *il, - struct ieee80211_vif *vif, - enum ieee80211_band band, - u8 is_active, u8 n_probes, - struct il_scan_channel *scan_ch) -{ - struct ieee80211_channel *chan; - const struct ieee80211_supported_band *sband; - const struct il_channel_info *ch_info; - u16 passive_dwell = 0; - u16 active_dwell = 0; - int added, i; - u16 channel; - - sband = il_get_hw_mode(il, band); - if (!sband) - return 0; - - active_dwell = il_get_active_dwell_time(il, band, n_probes); - passive_dwell = il_get_passive_dwell_time(il, band, vif); - - if (passive_dwell <= active_dwell) - passive_dwell = active_dwell + 1; - - for (i = 0, added = 0; i < il->scan_request->n_channels; i++) { - chan = il->scan_request->channels[i]; - - if (chan->band != band) - continue; - - channel = chan->hw_value; - scan_ch->channel = cpu_to_le16(channel); - - ch_info = il_get_channel_info(il, band, channel); - if (!il_is_channel_valid(ch_info)) { - D_SCAN( - "Channel %d is INVALID for this band.\n", - channel); - continue; - } - - if (!is_active || il_is_channel_passive(ch_info) || - (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)) - scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE; - else - scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE; - - if (n_probes) - scan_ch->type |= IL_SCAN_PROBE_MASK(n_probes); - - scan_ch->active_dwell = cpu_to_le16(active_dwell); - scan_ch->passive_dwell = cpu_to_le16(passive_dwell); - - /* Set txpower levels to defaults */ - scan_ch->dsp_atten = 110; - - /* NOTE: if we were doing 6Mb OFDM for scans we'd use - * power level: - * scan_ch->tx_gain = ((1 << 5) | (2 << 3)) | 3; - */ - if (band == IEEE80211_BAND_5GHZ) - scan_ch->tx_gain = ((1 << 5) | (3 << 3)) | 3; - else - scan_ch->tx_gain = ((1 << 5) | (5 << 3)); - - D_SCAN("Scanning ch=%d prob=0x%X [%s %d]\n", - channel, le32_to_cpu(scan_ch->type), - (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ? - "ACTIVE" : "PASSIVE", - (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ? - active_dwell : passive_dwell); - - scan_ch++; - added++; - } - - D_SCAN("total channels to scan %d\n", added); - return added; -} - -int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) -{ - struct il_host_cmd cmd = { - .id = REPLY_SCAN_CMD, - .len = sizeof(struct il_scan_cmd), - .flags = CMD_SIZE_HUGE, - }; - struct il_scan_cmd *scan; - struct il_rxon_context *ctx = &il->ctx; - u32 rate_flags = 0; - u16 cmd_len; - u16 rx_chain = 0; - enum ieee80211_band band; - u8 n_probes = 0; - u8 rx_ant = il->hw_params.valid_rx_ant; - u8 rate; - bool is_active = false; - int chan_mod; - u8 active_chains; - u8 scan_tx_antennas = il->hw_params.valid_tx_ant; - int ret; - - lockdep_assert_held(&il->mutex); - - if (vif) - ctx = il_rxon_ctx_from_vif(vif); - - if (!il->scan_cmd) { - il->scan_cmd = kmalloc(sizeof(struct il_scan_cmd) + - IL_MAX_SCAN_SIZE, GFP_KERNEL); - if (!il->scan_cmd) { - D_SCAN( - "fail to allocate memory for scan\n"); - return -ENOMEM; - } - } - scan = il->scan_cmd; - memset(scan, 0, sizeof(struct il_scan_cmd) + IL_MAX_SCAN_SIZE); - - scan->quiet_plcp_th = IL_PLCP_QUIET_THRESH; - scan->quiet_time = IL_ACTIVE_QUIET_TIME; - - if (il_is_any_associated(il)) { - u16 interval; - u32 extra; - u32 suspend_time = 100; - u32 scan_suspend_time = 100; - - D_INFO("Scanning while associated...\n"); - interval = vif->bss_conf.beacon_int; - - scan->suspend_time = 0; - scan->max_out_time = cpu_to_le32(200 * 1024); - if (!interval) - interval = suspend_time; - - extra = (suspend_time / interval) << 22; - scan_suspend_time = (extra | - ((suspend_time % interval) * 1024)); - scan->suspend_time = cpu_to_le32(scan_suspend_time); - D_SCAN("suspend_time 0x%X beacon interval %d\n", - scan_suspend_time, interval); - } - - if (il->scan_request->n_ssids) { - int i, p = 0; - D_SCAN("Kicking off active scan\n"); - for (i = 0; i < il->scan_request->n_ssids; i++) { - /* always does wildcard anyway */ - if (!il->scan_request->ssids[i].ssid_len) - continue; - scan->direct_scan[p].id = WLAN_EID_SSID; - scan->direct_scan[p].len = - il->scan_request->ssids[i].ssid_len; - memcpy(scan->direct_scan[p].ssid, - il->scan_request->ssids[i].ssid, - il->scan_request->ssids[i].ssid_len); - n_probes++; - p++; - } - is_active = true; - } else - D_SCAN("Start passive scan.\n"); - - scan->tx_cmd.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK; - scan->tx_cmd.sta_id = ctx->bcast_sta_id; - scan->tx_cmd.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; - - switch (il->scan_band) { - case IEEE80211_BAND_2GHZ: - scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; - chan_mod = le32_to_cpu( - il->ctx.active.flags & - RXON_FLG_CHANNEL_MODE_MSK) - >> RXON_FLG_CHANNEL_MODE_POS; - if (chan_mod == CHANNEL_MODE_PURE_40) { - rate = RATE_6M_PLCP; - } else { - rate = RATE_1M_PLCP; - rate_flags = RATE_MCS_CCK_MSK; - } - break; - case IEEE80211_BAND_5GHZ: - rate = RATE_6M_PLCP; - break; - default: - IL_WARN("Invalid scan band\n"); - return -EIO; - } - - /* - * If active scanning is requested but a certain channel is - * marked passive, we can do active scanning if we detect - * transmissions. - * - * There is an issue with some firmware versions that triggers - * a sysassert on a "good CRC threshold" of zero (== disabled), - * on a radar channel even though this means that we should NOT - * send probes. - * - * The "good CRC threshold" is the number of frames that we - * need to receive during our dwell time on a channel before - * sending out probes -- setting this to a huge value will - * mean we never reach it, but at the same time work around - * the aforementioned issue. Thus use IL_GOOD_CRC_TH_NEVER - * here instead of IL_GOOD_CRC_TH_DISABLED. - */ - scan->good_CRC_th = is_active ? IL_GOOD_CRC_TH_DEFAULT : - IL_GOOD_CRC_TH_NEVER; - - band = il->scan_band; - - if (il->cfg->scan_rx_antennas[band]) - rx_ant = il->cfg->scan_rx_antennas[band]; - - il->scan_tx_ant[band] = il4965_toggle_tx_ant(il, - il->scan_tx_ant[band], - scan_tx_antennas); - rate_flags |= il4965_ant_idx_to_flags(il->scan_tx_ant[band]); - scan->tx_cmd.rate_n_flags = il4965_hw_set_rate_n_flags(rate, rate_flags); - - /* In power save mode use one chain, otherwise use all chains */ - if (test_bit(STATUS_POWER_PMI, &il->status)) { - /* rx_ant has been set to all valid chains previously */ - active_chains = rx_ant & - ((u8)(il->chain_noise_data.active_chains)); - if (!active_chains) - active_chains = rx_ant; - - D_SCAN("chain_noise_data.active_chains: %u\n", - il->chain_noise_data.active_chains); - - rx_ant = il4965_first_antenna(active_chains); - } - - /* MIMO is not used here, but value is required */ - rx_chain |= il->hw_params.valid_rx_ant << RXON_RX_CHAIN_VALID_POS; - rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_MIMO_SEL_POS; - rx_chain |= rx_ant << RXON_RX_CHAIN_FORCE_SEL_POS; - rx_chain |= 0x1 << RXON_RX_CHAIN_DRIVER_FORCE_POS; - scan->rx_chain = cpu_to_le16(rx_chain); - - cmd_len = il_fill_probe_req(il, - (struct ieee80211_mgmt *)scan->data, - vif->addr, - il->scan_request->ie, - il->scan_request->ie_len, - IL_MAX_SCAN_SIZE - sizeof(*scan)); - scan->tx_cmd.len = cpu_to_le16(cmd_len); - - scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK | - RXON_FILTER_BCON_AWARE_MSK); - - scan->channel_count = il4965_get_channels_for_scan(il, vif, band, - is_active, n_probes, - (void *)&scan->data[cmd_len]); - if (scan->channel_count == 0) { - D_SCAN("channel count %d\n", scan->channel_count); - return -EIO; - } - - cmd.len += le16_to_cpu(scan->tx_cmd.len) + - scan->channel_count * sizeof(struct il_scan_channel); - cmd.data = scan; - scan->len = cpu_to_le16(cmd.len); - - set_bit(STATUS_SCAN_HW, &il->status); - - ret = il_send_cmd_sync(il, &cmd); - if (ret) - clear_bit(STATUS_SCAN_HW, &il->status); - - return ret; -} - -int il4965_manage_ibss_station(struct il_priv *il, - struct ieee80211_vif *vif, bool add) -{ - struct il_vif_priv *vif_priv = (void *)vif->drv_priv; - - if (add) - return il4965_add_bssid_station(il, vif_priv->ctx, - vif->bss_conf.bssid, - &vif_priv->ibss_bssid_sta_id); - return il_remove_station(il, vif_priv->ibss_bssid_sta_id, - vif->bss_conf.bssid); -} - -void il4965_free_tfds_in_queue(struct il_priv *il, - int sta_id, int tid, int freed) -{ - lockdep_assert_held(&il->sta_lock); - - if (il->stations[sta_id].tid[tid].tfds_in_queue >= freed) - il->stations[sta_id].tid[tid].tfds_in_queue -= freed; - else { - D_TX("free more than tfds_in_queue (%u:%d)\n", - il->stations[sta_id].tid[tid].tfds_in_queue, - freed); - il->stations[sta_id].tid[tid].tfds_in_queue = 0; - } -} - -#define IL_TX_QUEUE_MSK 0xfffff - -static bool il4965_is_single_rx_stream(struct il_priv *il) -{ - return il->current_ht_config.smps == IEEE80211_SMPS_STATIC || - il->current_ht_config.single_chain_sufficient; -} - -#define IL_NUM_RX_CHAINS_MULTIPLE 3 -#define IL_NUM_RX_CHAINS_SINGLE 2 -#define IL_NUM_IDLE_CHAINS_DUAL 2 -#define IL_NUM_IDLE_CHAINS_SINGLE 1 - -/* - * Determine how many receiver/antenna chains to use. - * - * More provides better reception via diversity. Fewer saves power - * at the expense of throughput, but only when not in powersave to - * start with. - * - * MIMO (dual stream) requires at least 2, but works better with 3. - * This does not determine *which* chains to use, just how many. - */ -static int il4965_get_active_rx_chain_count(struct il_priv *il) -{ - /* # of Rx chains to use when expecting MIMO. */ - if (il4965_is_single_rx_stream(il)) - return IL_NUM_RX_CHAINS_SINGLE; - else - return IL_NUM_RX_CHAINS_MULTIPLE; -} - -/* - * When we are in power saving mode, unless device support spatial - * multiplexing power save, use the active count for rx chain count. - */ -static int -il4965_get_idle_rx_chain_count(struct il_priv *il, int active_cnt) -{ - /* # Rx chains when idling, depending on SMPS mode */ - switch (il->current_ht_config.smps) { - case IEEE80211_SMPS_STATIC: - case IEEE80211_SMPS_DYNAMIC: - return IL_NUM_IDLE_CHAINS_SINGLE; - case IEEE80211_SMPS_OFF: - return active_cnt; - default: - WARN(1, "invalid SMPS mode %d", - il->current_ht_config.smps); - return active_cnt; - } -} - -/* up to 4 chains */ -static u8 il4965_count_chain_bitmap(u32 chain_bitmap) -{ - u8 res; - res = (chain_bitmap & BIT(0)) >> 0; - res += (chain_bitmap & BIT(1)) >> 1; - res += (chain_bitmap & BIT(2)) >> 2; - res += (chain_bitmap & BIT(3)) >> 3; - return res; -} - -/** - * il4965_set_rxon_chain - Set up Rx chain usage in "staging" RXON image - * - * Selects how many and which Rx receivers/antennas/chains to use. - * This should not be used for scan command ... it puts data in wrong place. - */ -void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx) -{ - bool is_single = il4965_is_single_rx_stream(il); - bool is_cam = !test_bit(STATUS_POWER_PMI, &il->status); - u8 idle_rx_cnt, active_rx_cnt, valid_rx_cnt; - u32 active_chains; - u16 rx_chain; - - /* Tell uCode which antennas are actually connected. - * Before first association, we assume all antennas are connected. - * Just after first association, il4965_chain_noise_calibration() - * checks which antennas actually *are* connected. */ - if (il->chain_noise_data.active_chains) - active_chains = il->chain_noise_data.active_chains; - else - active_chains = il->hw_params.valid_rx_ant; - - rx_chain = active_chains << RXON_RX_CHAIN_VALID_POS; - - /* How many receivers should we use? */ - active_rx_cnt = il4965_get_active_rx_chain_count(il); - idle_rx_cnt = il4965_get_idle_rx_chain_count(il, active_rx_cnt); - - - /* correct rx chain count according hw settings - * and chain noise calibration - */ - valid_rx_cnt = il4965_count_chain_bitmap(active_chains); - if (valid_rx_cnt < active_rx_cnt) - active_rx_cnt = valid_rx_cnt; - - if (valid_rx_cnt < idle_rx_cnt) - idle_rx_cnt = valid_rx_cnt; - - rx_chain |= active_rx_cnt << RXON_RX_CHAIN_MIMO_CNT_POS; - rx_chain |= idle_rx_cnt << RXON_RX_CHAIN_CNT_POS; - - ctx->staging.rx_chain = cpu_to_le16(rx_chain); - - if (!is_single && active_rx_cnt >= IL_NUM_RX_CHAINS_SINGLE && is_cam) - ctx->staging.rx_chain |= RXON_RX_CHAIN_MIMO_FORCE_MSK; - else - ctx->staging.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK; - - D_ASSOC("rx_chain=0x%X active=%d idle=%d\n", - ctx->staging.rx_chain, - active_rx_cnt, idle_rx_cnt); - - WARN_ON(active_rx_cnt == 0 || idle_rx_cnt == 0 || - active_rx_cnt < idle_rx_cnt); -} - -u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant, u8 valid) -{ - int i; - u8 ind = ant; - - for (i = 0; i < RATE_ANT_NUM - 1; i++) { - ind = (ind + 1) < RATE_ANT_NUM ? ind + 1 : 0; - if (valid & BIT(ind)) - return ind; - } - return ant; -} - -static const char *il4965_get_fh_string(int cmd) -{ - switch (cmd) { - IL_CMD(FH_RSCSR_CHNL0_STTS_WPTR_REG); - IL_CMD(FH_RSCSR_CHNL0_RBDCB_BASE_REG); - IL_CMD(FH_RSCSR_CHNL0_WPTR); - IL_CMD(FH_MEM_RCSR_CHNL0_CONFIG_REG); - IL_CMD(FH_MEM_RSSR_SHARED_CTRL_REG); - IL_CMD(FH_MEM_RSSR_RX_STATUS_REG); - IL_CMD(FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV); - IL_CMD(FH_TSSR_TX_STATUS_REG); - IL_CMD(FH_TSSR_TX_ERROR_REG); - default: - return "UNKNOWN"; - } -} - -int il4965_dump_fh(struct il_priv *il, char **buf, bool display) -{ - int i; -#ifdef CONFIG_IWLEGACY_DEBUG - int pos = 0; - size_t bufsz = 0; -#endif - static const u32 fh_tbl[] = { - FH_RSCSR_CHNL0_STTS_WPTR_REG, - FH_RSCSR_CHNL0_RBDCB_BASE_REG, - FH_RSCSR_CHNL0_WPTR, - FH_MEM_RCSR_CHNL0_CONFIG_REG, - FH_MEM_RSSR_SHARED_CTRL_REG, - FH_MEM_RSSR_RX_STATUS_REG, - FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV, - FH_TSSR_TX_STATUS_REG, - FH_TSSR_TX_ERROR_REG - }; -#ifdef CONFIG_IWLEGACY_DEBUG - if (display) { - bufsz = ARRAY_SIZE(fh_tbl) * 48 + 40; - *buf = kmalloc(bufsz, GFP_KERNEL); - if (!*buf) - return -ENOMEM; - pos += scnprintf(*buf + pos, bufsz - pos, - "FH register values:\n"); - for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { - pos += scnprintf(*buf + pos, bufsz - pos, - " %34s: 0X%08x\n", - il4965_get_fh_string(fh_tbl[i]), - il_rd(il, fh_tbl[i])); - } - return pos; - } -#endif - IL_ERR("FH register values:\n"); - for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { - IL_ERR(" %34s: 0X%08x\n", - il4965_get_fh_string(fh_tbl[i]), - il_rd(il, fh_tbl[i])); - } - return 0; -} -- cgit v1.2.3 From f3a1b49d669472159e05327fff64ec55315a0f54 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 30 Aug 2011 13:14:41 +0200 Subject: iwlegacy: rename iwl-4965-{rs,calib,debugfs}.c to 4965-{rs,calib,debug}.c Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/4965-calib.c | 966 ++++++++ drivers/net/wireless/iwlegacy/4965-debug.c | 774 ++++++ drivers/net/wireless/iwlegacy/4965-rs.c | 2862 ++++++++++++++++++++++ drivers/net/wireless/iwlegacy/Makefile | 5 +- drivers/net/wireless/iwlegacy/iwl-4965-calib.c | 966 -------- drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c | 774 ------ drivers/net/wireless/iwlegacy/iwl-4965-rs.c | 2862 ---------------------- 7 files changed, 4604 insertions(+), 4605 deletions(-) create mode 100644 drivers/net/wireless/iwlegacy/4965-calib.c create mode 100644 drivers/net/wireless/iwlegacy/4965-debug.c create mode 100644 drivers/net/wireless/iwlegacy/4965-rs.c delete mode 100644 drivers/net/wireless/iwlegacy/iwl-4965-calib.c delete mode 100644 drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c delete mode 100644 drivers/net/wireless/iwlegacy/iwl-4965-rs.c (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/4965-calib.c b/drivers/net/wireless/iwlegacy/4965-calib.c new file mode 100644 index 000000000000..1d873a68830e --- /dev/null +++ b/drivers/net/wireless/iwlegacy/4965-calib.c @@ -0,0 +1,966 @@ +/****************************************************************************** + * + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, + * USA + * + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + * BSD LICENSE + * + * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +#include +#include + +#include "iwl-dev.h" +#include "iwl-core.h" +#include "iwl-4965-calib.h" + +/***************************************************************************** + * INIT calibrations framework + *****************************************************************************/ + +struct stats_general_data { + u32 beacon_silence_rssi_a; + u32 beacon_silence_rssi_b; + u32 beacon_silence_rssi_c; + u32 beacon_energy_a; + u32 beacon_energy_b; + u32 beacon_energy_c; +}; + +void il4965_calib_free_results(struct il_priv *il) +{ + int i; + + for (i = 0; i < IL_CALIB_MAX; i++) { + kfree(il->calib_results[i].buf); + il->calib_results[i].buf = NULL; + il->calib_results[i].buf_len = 0; + } +} + +/***************************************************************************** + * RUNTIME calibrations framework + *****************************************************************************/ + +/* "false alarms" are signals that our DSP tries to lock onto, + * but then determines that they are either noise, or transmissions + * from a distant wireless network (also "noise", really) that get + * "stepped on" by stronger transmissions within our own network. + * This algorithm attempts to set a sensitivity level that is high + * enough to receive all of our own network traffic, but not so + * high that our DSP gets too busy trying to lock onto non-network + * activity/noise. */ +static int il4965_sens_energy_cck(struct il_priv *il, + u32 norm_fa, + u32 rx_enable_time, + struct stats_general_data *rx_info) +{ + u32 max_nrg_cck = 0; + int i = 0; + u8 max_silence_rssi = 0; + u32 silence_ref = 0; + u8 silence_rssi_a = 0; + u8 silence_rssi_b = 0; + u8 silence_rssi_c = 0; + u32 val; + + /* "false_alarms" values below are cross-multiplications to assess the + * numbers of false alarms within the measured period of actual Rx + * (Rx is off when we're txing), vs the min/max expected false alarms + * (some should be expected if rx is sensitive enough) in a + * hypothetical listening period of 200 time units (TU), 204.8 msec: + * + * MIN_FA/fixed-time < false_alarms/actual-rx-time < MAX_FA/beacon-time + * + * */ + u32 false_alarms = norm_fa * 200 * 1024; + u32 max_false_alarms = MAX_FA_CCK * rx_enable_time; + u32 min_false_alarms = MIN_FA_CCK * rx_enable_time; + struct il_sensitivity_data *data = NULL; + const struct il_sensitivity_ranges *ranges = il->hw_params.sens; + + data = &(il->sensitivity_data); + + data->nrg_auto_corr_silence_diff = 0; + + /* Find max silence rssi among all 3 receivers. + * This is background noise, which may include transmissions from other + * networks, measured during silence before our network's beacon */ + silence_rssi_a = (u8)((rx_info->beacon_silence_rssi_a & + ALL_BAND_FILTER) >> 8); + silence_rssi_b = (u8)((rx_info->beacon_silence_rssi_b & + ALL_BAND_FILTER) >> 8); + silence_rssi_c = (u8)((rx_info->beacon_silence_rssi_c & + ALL_BAND_FILTER) >> 8); + + val = max(silence_rssi_b, silence_rssi_c); + max_silence_rssi = max(silence_rssi_a, (u8) val); + + /* Store silence rssi in 20-beacon history table */ + data->nrg_silence_rssi[data->nrg_silence_idx] = max_silence_rssi; + data->nrg_silence_idx++; + if (data->nrg_silence_idx >= NRG_NUM_PREV_STAT_L) + data->nrg_silence_idx = 0; + + /* Find max silence rssi across 20 beacon history */ + for (i = 0; i < NRG_NUM_PREV_STAT_L; i++) { + val = data->nrg_silence_rssi[i]; + silence_ref = max(silence_ref, val); + } + D_CALIB("silence a %u, b %u, c %u, 20-bcn max %u\n", + silence_rssi_a, silence_rssi_b, silence_rssi_c, + silence_ref); + + /* Find max rx energy (min value!) among all 3 receivers, + * measured during beacon frame. + * Save it in 10-beacon history table. */ + i = data->nrg_energy_idx; + val = min(rx_info->beacon_energy_b, rx_info->beacon_energy_c); + data->nrg_value[i] = min(rx_info->beacon_energy_a, val); + + data->nrg_energy_idx++; + if (data->nrg_energy_idx >= 10) + data->nrg_energy_idx = 0; + + /* Find min rx energy (max value) across 10 beacon history. + * This is the minimum signal level that we want to receive well. + * Add backoff (margin so we don't miss slightly lower energy frames). + * This establishes an upper bound (min value) for energy threshold. */ + max_nrg_cck = data->nrg_value[0]; + for (i = 1; i < 10; i++) + max_nrg_cck = (u32) max(max_nrg_cck, (data->nrg_value[i])); + max_nrg_cck += 6; + + D_CALIB("rx energy a %u, b %u, c %u, 10-bcn max/min %u\n", + rx_info->beacon_energy_a, rx_info->beacon_energy_b, + rx_info->beacon_energy_c, max_nrg_cck - 6); + + /* Count number of consecutive beacons with fewer-than-desired + * false alarms. */ + if (false_alarms < min_false_alarms) + data->num_in_cck_no_fa++; + else + data->num_in_cck_no_fa = 0; + D_CALIB("consecutive bcns with few false alarms = %u\n", + data->num_in_cck_no_fa); + + /* If we got too many false alarms this time, reduce sensitivity */ + if (false_alarms > max_false_alarms && + data->auto_corr_cck > AUTO_CORR_MAX_TH_CCK) { + D_CALIB("norm FA %u > max FA %u\n", + false_alarms, max_false_alarms); + D_CALIB("... reducing sensitivity\n"); + data->nrg_curr_state = IL_FA_TOO_MANY; + /* Store for "fewer than desired" on later beacon */ + data->nrg_silence_ref = silence_ref; + + /* increase energy threshold (reduce nrg value) + * to decrease sensitivity */ + data->nrg_th_cck = data->nrg_th_cck - NRG_STEP_CCK; + /* Else if we got fewer than desired, increase sensitivity */ + } else if (false_alarms < min_false_alarms) { + data->nrg_curr_state = IL_FA_TOO_FEW; + + /* Compare silence level with silence level for most recent + * healthy number or too many false alarms */ + data->nrg_auto_corr_silence_diff = (s32)data->nrg_silence_ref - + (s32)silence_ref; + + D_CALIB( + "norm FA %u < min FA %u, silence diff %d\n", + false_alarms, min_false_alarms, + data->nrg_auto_corr_silence_diff); + + /* Increase value to increase sensitivity, but only if: + * 1a) previous beacon did *not* have *too many* false alarms + * 1b) AND there's a significant difference in Rx levels + * from a previous beacon with too many, or healthy # FAs + * OR 2) We've seen a lot of beacons (100) with too few + * false alarms */ + if (data->nrg_prev_state != IL_FA_TOO_MANY && + (data->nrg_auto_corr_silence_diff > NRG_DIFF || + data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA)) { + + D_CALIB("... increasing sensitivity\n"); + /* Increase nrg value to increase sensitivity */ + val = data->nrg_th_cck + NRG_STEP_CCK; + data->nrg_th_cck = min((u32)ranges->min_nrg_cck, val); + } else { + D_CALIB( + "... but not changing sensitivity\n"); + } + + /* Else we got a healthy number of false alarms, keep status quo */ + } else { + D_CALIB(" FA in safe zone\n"); + data->nrg_curr_state = IL_FA_GOOD_RANGE; + + /* Store for use in "fewer than desired" with later beacon */ + data->nrg_silence_ref = silence_ref; + + /* If previous beacon had too many false alarms, + * give it some extra margin by reducing sensitivity again + * (but don't go below measured energy of desired Rx) */ + if (IL_FA_TOO_MANY == data->nrg_prev_state) { + D_CALIB("... increasing margin\n"); + if (data->nrg_th_cck > (max_nrg_cck + NRG_MARGIN)) + data->nrg_th_cck -= NRG_MARGIN; + else + data->nrg_th_cck = max_nrg_cck; + } + } + + /* Make sure the energy threshold does not go above the measured + * energy of the desired Rx signals (reduced by backoff margin), + * or else we might start missing Rx frames. + * Lower value is higher energy, so we use max()! + */ + data->nrg_th_cck = max(max_nrg_cck, data->nrg_th_cck); + D_CALIB("new nrg_th_cck %u\n", data->nrg_th_cck); + + data->nrg_prev_state = data->nrg_curr_state; + + /* Auto-correlation CCK algorithm */ + if (false_alarms > min_false_alarms) { + + /* increase auto_corr values to decrease sensitivity + * so the DSP won't be disturbed by the noise + */ + if (data->auto_corr_cck < AUTO_CORR_MAX_TH_CCK) + data->auto_corr_cck = AUTO_CORR_MAX_TH_CCK + 1; + else { + val = data->auto_corr_cck + AUTO_CORR_STEP_CCK; + data->auto_corr_cck = + min((u32)ranges->auto_corr_max_cck, val); + } + val = data->auto_corr_cck_mrc + AUTO_CORR_STEP_CCK; + data->auto_corr_cck_mrc = + min((u32)ranges->auto_corr_max_cck_mrc, val); + } else if (false_alarms < min_false_alarms && + (data->nrg_auto_corr_silence_diff > NRG_DIFF || + data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA)) { + + /* Decrease auto_corr values to increase sensitivity */ + val = data->auto_corr_cck - AUTO_CORR_STEP_CCK; + data->auto_corr_cck = + max((u32)ranges->auto_corr_min_cck, val); + val = data->auto_corr_cck_mrc - AUTO_CORR_STEP_CCK; + data->auto_corr_cck_mrc = + max((u32)ranges->auto_corr_min_cck_mrc, val); + } + + return 0; +} + + +static int il4965_sens_auto_corr_ofdm(struct il_priv *il, + u32 norm_fa, + u32 rx_enable_time) +{ + u32 val; + u32 false_alarms = norm_fa * 200 * 1024; + u32 max_false_alarms = MAX_FA_OFDM * rx_enable_time; + u32 min_false_alarms = MIN_FA_OFDM * rx_enable_time; + struct il_sensitivity_data *data = NULL; + const struct il_sensitivity_ranges *ranges = il->hw_params.sens; + + data = &(il->sensitivity_data); + + /* If we got too many false alarms this time, reduce sensitivity */ + if (false_alarms > max_false_alarms) { + + D_CALIB("norm FA %u > max FA %u)\n", + false_alarms, max_false_alarms); + + val = data->auto_corr_ofdm + AUTO_CORR_STEP_OFDM; + data->auto_corr_ofdm = + min((u32)ranges->auto_corr_max_ofdm, val); + + val = data->auto_corr_ofdm_mrc + AUTO_CORR_STEP_OFDM; + data->auto_corr_ofdm_mrc = + min((u32)ranges->auto_corr_max_ofdm_mrc, val); + + val = data->auto_corr_ofdm_x1 + AUTO_CORR_STEP_OFDM; + data->auto_corr_ofdm_x1 = + min((u32)ranges->auto_corr_max_ofdm_x1, val); + + val = data->auto_corr_ofdm_mrc_x1 + AUTO_CORR_STEP_OFDM; + data->auto_corr_ofdm_mrc_x1 = + min((u32)ranges->auto_corr_max_ofdm_mrc_x1, val); + } + + /* Else if we got fewer than desired, increase sensitivity */ + else if (false_alarms < min_false_alarms) { + + D_CALIB("norm FA %u < min FA %u\n", + false_alarms, min_false_alarms); + + val = data->auto_corr_ofdm - AUTO_CORR_STEP_OFDM; + data->auto_corr_ofdm = + max((u32)ranges->auto_corr_min_ofdm, val); + + val = data->auto_corr_ofdm_mrc - AUTO_CORR_STEP_OFDM; + data->auto_corr_ofdm_mrc = + max((u32)ranges->auto_corr_min_ofdm_mrc, val); + + val = data->auto_corr_ofdm_x1 - AUTO_CORR_STEP_OFDM; + data->auto_corr_ofdm_x1 = + max((u32)ranges->auto_corr_min_ofdm_x1, val); + + val = data->auto_corr_ofdm_mrc_x1 - AUTO_CORR_STEP_OFDM; + data->auto_corr_ofdm_mrc_x1 = + max((u32)ranges->auto_corr_min_ofdm_mrc_x1, val); + } else { + D_CALIB("min FA %u < norm FA %u < max FA %u OK\n", + min_false_alarms, false_alarms, max_false_alarms); + } + return 0; +} + +static void il4965_prepare_legacy_sensitivity_tbl(struct il_priv *il, + struct il_sensitivity_data *data, + __le16 *tbl) +{ + tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_IDX] = + cpu_to_le16((u16)data->auto_corr_ofdm); + tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_IDX] = + cpu_to_le16((u16)data->auto_corr_ofdm_mrc); + tbl[HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX] = + cpu_to_le16((u16)data->auto_corr_ofdm_x1); + tbl[HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_IDX] = + cpu_to_le16((u16)data->auto_corr_ofdm_mrc_x1); + + tbl[HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX] = + cpu_to_le16((u16)data->auto_corr_cck); + tbl[HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX] = + cpu_to_le16((u16)data->auto_corr_cck_mrc); + + tbl[HD_MIN_ENERGY_CCK_DET_IDX] = + cpu_to_le16((u16)data->nrg_th_cck); + tbl[HD_MIN_ENERGY_OFDM_DET_IDX] = + cpu_to_le16((u16)data->nrg_th_ofdm); + + tbl[HD_BARKER_CORR_TH_ADD_MIN_IDX] = + cpu_to_le16(data->barker_corr_th_min); + tbl[HD_BARKER_CORR_TH_ADD_MIN_MRC_IDX] = + cpu_to_le16(data->barker_corr_th_min_mrc); + tbl[HD_OFDM_ENERGY_TH_IN_IDX] = + cpu_to_le16(data->nrg_th_cca); + + D_CALIB("ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n", + data->auto_corr_ofdm, data->auto_corr_ofdm_mrc, + data->auto_corr_ofdm_x1, data->auto_corr_ofdm_mrc_x1, + data->nrg_th_ofdm); + + D_CALIB("cck: ac %u mrc %u thresh %u\n", + data->auto_corr_cck, data->auto_corr_cck_mrc, + data->nrg_th_cck); +} + +/* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */ +static int il4965_sensitivity_write(struct il_priv *il) +{ + struct il_sensitivity_cmd cmd; + struct il_sensitivity_data *data = NULL; + struct il_host_cmd cmd_out = { + .id = SENSITIVITY_CMD, + .len = sizeof(struct il_sensitivity_cmd), + .flags = CMD_ASYNC, + .data = &cmd, + }; + + data = &(il->sensitivity_data); + + memset(&cmd, 0, sizeof(cmd)); + + il4965_prepare_legacy_sensitivity_tbl(il, data, &cmd.table[0]); + + /* Update uCode's "work" table, and copy it to DSP */ + cmd.control = SENSITIVITY_CMD_CONTROL_WORK_TBL; + + /* Don't send command to uCode if nothing has changed */ + if (!memcmp(&cmd.table[0], &(il->sensitivity_tbl[0]), + sizeof(u16)*HD_TBL_SIZE)) { + D_CALIB("No change in SENSITIVITY_CMD\n"); + return 0; + } + + /* Copy table for comparison next time */ + memcpy(&(il->sensitivity_tbl[0]), &(cmd.table[0]), + sizeof(u16)*HD_TBL_SIZE); + + return il_send_cmd(il, &cmd_out); +} + +void il4965_init_sensitivity(struct il_priv *il) +{ + int ret = 0; + int i; + struct il_sensitivity_data *data = NULL; + const struct il_sensitivity_ranges *ranges = il->hw_params.sens; + + if (il->disable_sens_cal) + return; + + D_CALIB("Start il4965_init_sensitivity\n"); + + /* Clear driver's sensitivity algo data */ + data = &(il->sensitivity_data); + + if (ranges == NULL) + return; + + memset(data, 0, sizeof(struct il_sensitivity_data)); + + data->num_in_cck_no_fa = 0; + data->nrg_curr_state = IL_FA_TOO_MANY; + data->nrg_prev_state = IL_FA_TOO_MANY; + data->nrg_silence_ref = 0; + data->nrg_silence_idx = 0; + data->nrg_energy_idx = 0; + + for (i = 0; i < 10; i++) + data->nrg_value[i] = 0; + + for (i = 0; i < NRG_NUM_PREV_STAT_L; i++) + data->nrg_silence_rssi[i] = 0; + + data->auto_corr_ofdm = ranges->auto_corr_min_ofdm; + data->auto_corr_ofdm_mrc = ranges->auto_corr_min_ofdm_mrc; + data->auto_corr_ofdm_x1 = ranges->auto_corr_min_ofdm_x1; + data->auto_corr_ofdm_mrc_x1 = ranges->auto_corr_min_ofdm_mrc_x1; + data->auto_corr_cck = AUTO_CORR_CCK_MIN_VAL_DEF; + data->auto_corr_cck_mrc = ranges->auto_corr_min_cck_mrc; + data->nrg_th_cck = ranges->nrg_th_cck; + data->nrg_th_ofdm = ranges->nrg_th_ofdm; + data->barker_corr_th_min = ranges->barker_corr_th_min; + data->barker_corr_th_min_mrc = ranges->barker_corr_th_min_mrc; + data->nrg_th_cca = ranges->nrg_th_cca; + + data->last_bad_plcp_cnt_ofdm = 0; + data->last_fa_cnt_ofdm = 0; + data->last_bad_plcp_cnt_cck = 0; + data->last_fa_cnt_cck = 0; + + ret |= il4965_sensitivity_write(il); + D_CALIB("<disable_sens_cal) + return; + + data = &(il->sensitivity_data); + + if (!il_is_any_associated(il)) { + D_CALIB("<< - not associated\n"); + return; + } + + spin_lock_irqsave(&il->lock, flags); + + rx_info = &(((struct il_notif_stats *)resp)->rx.general); + ofdm = &(((struct il_notif_stats *)resp)->rx.ofdm); + cck = &(((struct il_notif_stats *)resp)->rx.cck); + + if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { + D_CALIB("<< invalid data.\n"); + spin_unlock_irqrestore(&il->lock, flags); + return; + } + + /* Extract Statistics: */ + rx_enable_time = le32_to_cpu(rx_info->channel_load); + fa_cck = le32_to_cpu(cck->false_alarm_cnt); + fa_ofdm = le32_to_cpu(ofdm->false_alarm_cnt); + bad_plcp_cck = le32_to_cpu(cck->plcp_err); + bad_plcp_ofdm = le32_to_cpu(ofdm->plcp_err); + + statis.beacon_silence_rssi_a = + le32_to_cpu(rx_info->beacon_silence_rssi_a); + statis.beacon_silence_rssi_b = + le32_to_cpu(rx_info->beacon_silence_rssi_b); + statis.beacon_silence_rssi_c = + le32_to_cpu(rx_info->beacon_silence_rssi_c); + statis.beacon_energy_a = + le32_to_cpu(rx_info->beacon_energy_a); + statis.beacon_energy_b = + le32_to_cpu(rx_info->beacon_energy_b); + statis.beacon_energy_c = + le32_to_cpu(rx_info->beacon_energy_c); + + spin_unlock_irqrestore(&il->lock, flags); + + D_CALIB("rx_enable_time = %u usecs\n", rx_enable_time); + + if (!rx_enable_time) { + D_CALIB("<< RX Enable Time == 0!\n"); + return; + } + + /* These stats increase monotonically, and do not reset + * at each beacon. Calculate difference from last value, or just + * use the new stats value if it has reset or wrapped around. */ + if (data->last_bad_plcp_cnt_cck > bad_plcp_cck) + data->last_bad_plcp_cnt_cck = bad_plcp_cck; + else { + bad_plcp_cck -= data->last_bad_plcp_cnt_cck; + data->last_bad_plcp_cnt_cck += bad_plcp_cck; + } + + if (data->last_bad_plcp_cnt_ofdm > bad_plcp_ofdm) + data->last_bad_plcp_cnt_ofdm = bad_plcp_ofdm; + else { + bad_plcp_ofdm -= data->last_bad_plcp_cnt_ofdm; + data->last_bad_plcp_cnt_ofdm += bad_plcp_ofdm; + } + + if (data->last_fa_cnt_ofdm > fa_ofdm) + data->last_fa_cnt_ofdm = fa_ofdm; + else { + fa_ofdm -= data->last_fa_cnt_ofdm; + data->last_fa_cnt_ofdm += fa_ofdm; + } + + if (data->last_fa_cnt_cck > fa_cck) + data->last_fa_cnt_cck = fa_cck; + else { + fa_cck -= data->last_fa_cnt_cck; + data->last_fa_cnt_cck += fa_cck; + } + + /* Total aborted signal locks */ + norm_fa_ofdm = fa_ofdm + bad_plcp_ofdm; + norm_fa_cck = fa_cck + bad_plcp_cck; + + D_CALIB( + "cck: fa %u badp %u ofdm: fa %u badp %u\n", fa_cck, + bad_plcp_cck, fa_ofdm, bad_plcp_ofdm); + + il4965_sens_auto_corr_ofdm(il, norm_fa_ofdm, rx_enable_time); + il4965_sens_energy_cck(il, norm_fa_cck, rx_enable_time, &statis); + + il4965_sensitivity_write(il); +} + +static inline u8 il4965_find_first_chain(u8 mask) +{ + if (mask & ANT_A) + return CHAIN_A; + if (mask & ANT_B) + return CHAIN_B; + return CHAIN_C; +} + +/** + * Run disconnected antenna algorithm to find out which antennas are + * disconnected. + */ +static void +il4965_find_disconn_antenna(struct il_priv *il, u32* average_sig, + struct il_chain_noise_data *data) +{ + u32 active_chains = 0; + u32 max_average_sig; + u16 max_average_sig_antenna_i; + u8 num_tx_chains; + u8 first_chain; + u16 i = 0; + + average_sig[0] = data->chain_signal_a / + il->cfg->base_params->chain_noise_num_beacons; + average_sig[1] = data->chain_signal_b / + il->cfg->base_params->chain_noise_num_beacons; + average_sig[2] = data->chain_signal_c / + il->cfg->base_params->chain_noise_num_beacons; + + if (average_sig[0] >= average_sig[1]) { + max_average_sig = average_sig[0]; + max_average_sig_antenna_i = 0; + active_chains = (1 << max_average_sig_antenna_i); + } else { + max_average_sig = average_sig[1]; + max_average_sig_antenna_i = 1; + active_chains = (1 << max_average_sig_antenna_i); + } + + if (average_sig[2] >= max_average_sig) { + max_average_sig = average_sig[2]; + max_average_sig_antenna_i = 2; + active_chains = (1 << max_average_sig_antenna_i); + } + + D_CALIB("average_sig: a %d b %d c %d\n", + average_sig[0], average_sig[1], average_sig[2]); + D_CALIB("max_average_sig = %d, antenna %d\n", + max_average_sig, max_average_sig_antenna_i); + + /* Compare signal strengths for all 3 receivers. */ + for (i = 0; i < NUM_RX_CHAINS; i++) { + if (i != max_average_sig_antenna_i) { + s32 rssi_delta = (max_average_sig - average_sig[i]); + + /* If signal is very weak, compared with + * strongest, mark it as disconnected. */ + if (rssi_delta > MAXIMUM_ALLOWED_PATHLOSS) + data->disconn_array[i] = 1; + else + active_chains |= (1 << i); + D_CALIB("i = %d rssiDelta = %d " + "disconn_array[i] = %d\n", + i, rssi_delta, data->disconn_array[i]); + } + } + + /* + * The above algorithm sometimes fails when the ucode + * reports 0 for all chains. It's not clear why that + * happens to start with, but it is then causing trouble + * because this can make us enable more chains than the + * hardware really has. + * + * To be safe, simply mask out any chains that we know + * are not on the device. + */ + active_chains &= il->hw_params.valid_rx_ant; + + num_tx_chains = 0; + for (i = 0; i < NUM_RX_CHAINS; i++) { + /* loops on all the bits of + * il->hw_setting.valid_tx_ant */ + u8 ant_msk = (1 << i); + if (!(il->hw_params.valid_tx_ant & ant_msk)) + continue; + + num_tx_chains++; + if (data->disconn_array[i] == 0) + /* there is a Tx antenna connected */ + break; + if (num_tx_chains == il->hw_params.tx_chains_num && + data->disconn_array[i]) { + /* + * If all chains are disconnected + * connect the first valid tx chain + */ + first_chain = + il4965_find_first_chain(il->cfg->valid_tx_ant); + data->disconn_array[first_chain] = 0; + active_chains |= BIT(first_chain); + D_CALIB( + "All Tx chains are disconnected W/A - declare %d as connected\n", + first_chain); + break; + } + } + + if (active_chains != il->hw_params.valid_rx_ant && + active_chains != il->chain_noise_data.active_chains) + D_CALIB( + "Detected that not all antennas are connected! " + "Connected: %#x, valid: %#x.\n", + active_chains, il->hw_params.valid_rx_ant); + + /* Save for use within RXON, TX, SCAN commands, etc. */ + data->active_chains = active_chains; + D_CALIB("active_chains (bitwise) = 0x%x\n", + active_chains); +} + +static void il4965_gain_computation(struct il_priv *il, + u32 *average_noise, + u16 min_average_noise_antenna_i, + u32 min_average_noise, + u8 default_chain) +{ + int i, ret; + struct il_chain_noise_data *data = &il->chain_noise_data; + + data->delta_gain_code[min_average_noise_antenna_i] = 0; + + for (i = default_chain; i < NUM_RX_CHAINS; i++) { + s32 delta_g = 0; + + if (!data->disconn_array[i] && + data->delta_gain_code[i] == CHAIN_NOISE_DELTA_GAIN_INIT_VAL) { + delta_g = average_noise[i] - min_average_noise; + data->delta_gain_code[i] = (u8)((delta_g * 10) / 15); + data->delta_gain_code[i] = + min(data->delta_gain_code[i], + (u8) CHAIN_NOISE_MAX_DELTA_GAIN_CODE); + + data->delta_gain_code[i] = + (data->delta_gain_code[i] | (1 << 2)); + } else { + data->delta_gain_code[i] = 0; + } + } + D_CALIB("delta_gain_codes: a %d b %d c %d\n", + data->delta_gain_code[0], + data->delta_gain_code[1], + data->delta_gain_code[2]); + + /* Differential gain gets sent to uCode only once */ + if (!data->radio_write) { + struct il_calib_diff_gain_cmd cmd; + data->radio_write = 1; + + memset(&cmd, 0, sizeof(cmd)); + cmd.hdr.op_code = IL_PHY_CALIBRATE_DIFF_GAIN_CMD; + cmd.diff_gain_a = data->delta_gain_code[0]; + cmd.diff_gain_b = data->delta_gain_code[1]; + cmd.diff_gain_c = data->delta_gain_code[2]; + ret = il_send_cmd_pdu(il, REPLY_PHY_CALIBRATION_CMD, + sizeof(cmd), &cmd); + if (ret) + D_CALIB("fail sending cmd " + "REPLY_PHY_CALIBRATION_CMD\n"); + + /* TODO we might want recalculate + * rx_chain in rxon cmd */ + + /* Mark so we run this algo only once! */ + data->state = IL_CHAIN_NOISE_CALIBRATED; + } +} + + + +/* + * Accumulate 16 beacons of signal and noise stats for each of + * 3 receivers/antennas/rx-chains, then figure out: + * 1) Which antennas are connected. + * 2) Differential rx gain settings to balance the 3 receivers. + */ +void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) +{ + struct il_chain_noise_data *data = NULL; + + u32 chain_noise_a; + u32 chain_noise_b; + u32 chain_noise_c; + u32 chain_sig_a; + u32 chain_sig_b; + u32 chain_sig_c; + u32 average_sig[NUM_RX_CHAINS] = {INITIALIZATION_VALUE}; + u32 average_noise[NUM_RX_CHAINS] = {INITIALIZATION_VALUE}; + u32 min_average_noise = MIN_AVERAGE_NOISE_MAX_VALUE; + u16 min_average_noise_antenna_i = INITIALIZATION_VALUE; + u16 i = 0; + u16 rxon_chnum = INITIALIZATION_VALUE; + u16 stat_chnum = INITIALIZATION_VALUE; + u8 rxon_band24; + u8 stat_band24; + unsigned long flags; + struct stats_rx_non_phy *rx_info; + + struct il_rxon_context *ctx = &il->ctx; + + if (il->disable_chain_noise_cal) + return; + + data = &(il->chain_noise_data); + + /* + * Accumulate just the first "chain_noise_num_beacons" after + * the first association, then we're done forever. + */ + if (data->state != IL_CHAIN_NOISE_ACCUMULATE) { + if (data->state == IL_CHAIN_NOISE_ALIVE) + D_CALIB("Wait for noise calib reset\n"); + return; + } + + spin_lock_irqsave(&il->lock, flags); + + rx_info = &(((struct il_notif_stats *)stat_resp)-> + rx.general); + + if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { + D_CALIB(" << Interference data unavailable\n"); + spin_unlock_irqrestore(&il->lock, flags); + return; + } + + rxon_band24 = !!(ctx->staging.flags & RXON_FLG_BAND_24G_MSK); + rxon_chnum = le16_to_cpu(ctx->staging.channel); + + stat_band24 = !!(((struct il_notif_stats *) + stat_resp)->flag & + STATISTICS_REPLY_FLG_BAND_24G_MSK); + stat_chnum = le32_to_cpu(((struct il_notif_stats *) + stat_resp)->flag) >> 16; + + /* Make sure we accumulate data for just the associated channel + * (even if scanning). */ + if (rxon_chnum != stat_chnum || rxon_band24 != stat_band24) { + D_CALIB("Stats not from chan=%d, band24=%d\n", + rxon_chnum, rxon_band24); + spin_unlock_irqrestore(&il->lock, flags); + return; + } + + /* + * Accumulate beacon stats values across + * "chain_noise_num_beacons" + */ + chain_noise_a = le32_to_cpu(rx_info->beacon_silence_rssi_a) & + IN_BAND_FILTER; + chain_noise_b = le32_to_cpu(rx_info->beacon_silence_rssi_b) & + IN_BAND_FILTER; + chain_noise_c = le32_to_cpu(rx_info->beacon_silence_rssi_c) & + IN_BAND_FILTER; + + chain_sig_a = le32_to_cpu(rx_info->beacon_rssi_a) & IN_BAND_FILTER; + chain_sig_b = le32_to_cpu(rx_info->beacon_rssi_b) & IN_BAND_FILTER; + chain_sig_c = le32_to_cpu(rx_info->beacon_rssi_c) & IN_BAND_FILTER; + + spin_unlock_irqrestore(&il->lock, flags); + + data->beacon_count++; + + data->chain_noise_a = (chain_noise_a + data->chain_noise_a); + data->chain_noise_b = (chain_noise_b + data->chain_noise_b); + data->chain_noise_c = (chain_noise_c + data->chain_noise_c); + + data->chain_signal_a = (chain_sig_a + data->chain_signal_a); + data->chain_signal_b = (chain_sig_b + data->chain_signal_b); + data->chain_signal_c = (chain_sig_c + data->chain_signal_c); + + D_CALIB("chan=%d, band24=%d, beacon=%d\n", + rxon_chnum, rxon_band24, data->beacon_count); + D_CALIB("chain_sig: a %d b %d c %d\n", + chain_sig_a, chain_sig_b, chain_sig_c); + D_CALIB("chain_noise: a %d b %d c %d\n", + chain_noise_a, chain_noise_b, chain_noise_c); + + /* If this is the "chain_noise_num_beacons", determine: + * 1) Disconnected antennas (using signal strengths) + * 2) Differential gain (using silence noise) to balance receivers */ + if (data->beacon_count != + il->cfg->base_params->chain_noise_num_beacons) + return; + + /* Analyze signal for disconnected antenna */ + il4965_find_disconn_antenna(il, average_sig, data); + + /* Analyze noise for rx balance */ + average_noise[0] = data->chain_noise_a / + il->cfg->base_params->chain_noise_num_beacons; + average_noise[1] = data->chain_noise_b / + il->cfg->base_params->chain_noise_num_beacons; + average_noise[2] = data->chain_noise_c / + il->cfg->base_params->chain_noise_num_beacons; + + for (i = 0; i < NUM_RX_CHAINS; i++) { + if (!data->disconn_array[i] && + average_noise[i] <= min_average_noise) { + /* This means that chain i is active and has + * lower noise values so far: */ + min_average_noise = average_noise[i]; + min_average_noise_antenna_i = i; + } + } + + D_CALIB("average_noise: a %d b %d c %d\n", + average_noise[0], average_noise[1], + average_noise[2]); + + D_CALIB("min_average_noise = %d, antenna %d\n", + min_average_noise, min_average_noise_antenna_i); + + il4965_gain_computation(il, average_noise, + min_average_noise_antenna_i, min_average_noise, + il4965_find_first_chain(il->cfg->valid_rx_ant)); + + /* Some power changes may have been made during the calibration. + * Update and commit the RXON + */ + if (il->cfg->ops->lib->update_chain_flags) + il->cfg->ops->lib->update_chain_flags(il); + + data->state = IL_CHAIN_NOISE_DONE; + il_power_update_mode(il, false); +} + +void il4965_reset_run_time_calib(struct il_priv *il) +{ + int i; + memset(&(il->sensitivity_data), 0, + sizeof(struct il_sensitivity_data)); + memset(&(il->chain_noise_data), 0, + sizeof(struct il_chain_noise_data)); + for (i = 0; i < NUM_RX_CHAINS; i++) + il->chain_noise_data.delta_gain_code[i] = + CHAIN_NOISE_DELTA_GAIN_INIT_VAL; + + /* Ask for stats now, the uCode will send notification + * periodically after association */ + il_send_stats_request(il, CMD_ASYNC, true); +} diff --git a/drivers/net/wireless/iwlegacy/4965-debug.c b/drivers/net/wireless/iwlegacy/4965-debug.c new file mode 100644 index 000000000000..89e5828ce383 --- /dev/null +++ b/drivers/net/wireless/iwlegacy/4965-debug.c @@ -0,0 +1,774 @@ +/****************************************************************************** +* +* GPL LICENSE SUMMARY +* +* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, +* USA +* +* The full GNU General Public License is included in this distribution +* in the file called LICENSE.GPL. +* +* Contact Information: +* Intel Linux Wireless +* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 +*****************************************************************************/ +#include "iwl-4965.h" +#include "iwl-4965-debugfs.h" + +static const char *fmt_value = " %-30s %10u\n"; +static const char *fmt_table = " %-30s %10u %10u %10u %10u\n"; +static const char *fmt_header = + "%-32s current cumulative delta max\n"; + +static int il4965_stats_flag(struct il_priv *il, char *buf, int bufsz) +{ + int p = 0; + u32 flag; + + flag = le32_to_cpu(il->_4965.stats.flag); + + p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag); + if (flag & UCODE_STATISTICS_CLEAR_MSK) + p += scnprintf(buf + p, bufsz - p, + "\tStatistics have been cleared\n"); + p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n", + (flag & UCODE_STATISTICS_FREQUENCY_MSK) + ? "2.4 GHz" : "5.2 GHz"); + p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n", + (flag & UCODE_STATISTICS_NARROW_BAND_MSK) + ? "enabled" : "disabled"); + + return p; +} + +ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + int pos = 0; + char *buf; + int bufsz = sizeof(struct stats_rx_phy) * 40 + + sizeof(struct stats_rx_non_phy) * 40 + + sizeof(struct stats_rx_ht_phy) * 40 + 400; + ssize_t ret; + struct stats_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm; + struct stats_rx_phy *cck, *accum_cck, *delta_cck, *max_cck; + struct stats_rx_non_phy *general, *accum_general; + struct stats_rx_non_phy *delta_general, *max_general; + struct stats_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht; + + if (!il_is_alive(il)) + return -EAGAIN; + + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) { + IL_ERR("Can not allocate Buffer\n"); + return -ENOMEM; + } + + /* + * the statistic information display here is based on + * the last stats notification from uCode + * might not reflect the current uCode activity + */ + ofdm = &il->_4965.stats.rx.ofdm; + cck = &il->_4965.stats.rx.cck; + general = &il->_4965.stats.rx.general; + ht = &il->_4965.stats.rx.ofdm_ht; + accum_ofdm = &il->_4965.accum_stats.rx.ofdm; + accum_cck = &il->_4965.accum_stats.rx.cck; + accum_general = &il->_4965.accum_stats.rx.general; + accum_ht = &il->_4965.accum_stats.rx.ofdm_ht; + delta_ofdm = &il->_4965.delta_stats.rx.ofdm; + delta_cck = &il->_4965.delta_stats.rx.cck; + delta_general = &il->_4965.delta_stats.rx.general; + delta_ht = &il->_4965.delta_stats.rx.ofdm_ht; + max_ofdm = &il->_4965.max_delta.rx.ofdm; + max_cck = &il->_4965.max_delta.rx.cck; + max_general = &il->_4965.max_delta.rx.general; + max_ht = &il->_4965.max_delta.rx.ofdm_ht; + + pos += il4965_stats_flag(il, buf, bufsz); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_header, "Statistics_Rx - OFDM:"); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "ina_cnt:", + le32_to_cpu(ofdm->ina_cnt), + accum_ofdm->ina_cnt, + delta_ofdm->ina_cnt, max_ofdm->ina_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "fina_cnt:", + le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt, + delta_ofdm->fina_cnt, max_ofdm->fina_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "plcp_err:", + le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err, + delta_ofdm->plcp_err, max_ofdm->plcp_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "crc32_err:", + le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err, + delta_ofdm->crc32_err, max_ofdm->crc32_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "overrun_err:", + le32_to_cpu(ofdm->overrun_err), + accum_ofdm->overrun_err, delta_ofdm->overrun_err, + max_ofdm->overrun_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "early_overrun_err:", + le32_to_cpu(ofdm->early_overrun_err), + accum_ofdm->early_overrun_err, + delta_ofdm->early_overrun_err, + max_ofdm->early_overrun_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "crc32_good:", + le32_to_cpu(ofdm->crc32_good), + accum_ofdm->crc32_good, delta_ofdm->crc32_good, + max_ofdm->crc32_good); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "false_alarm_cnt:", + le32_to_cpu(ofdm->false_alarm_cnt), + accum_ofdm->false_alarm_cnt, + delta_ofdm->false_alarm_cnt, + max_ofdm->false_alarm_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "fina_sync_err_cnt:", + le32_to_cpu(ofdm->fina_sync_err_cnt), + accum_ofdm->fina_sync_err_cnt, + delta_ofdm->fina_sync_err_cnt, + max_ofdm->fina_sync_err_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "sfd_timeout:", + le32_to_cpu(ofdm->sfd_timeout), + accum_ofdm->sfd_timeout, delta_ofdm->sfd_timeout, + max_ofdm->sfd_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "fina_timeout:", + le32_to_cpu(ofdm->fina_timeout), + accum_ofdm->fina_timeout, delta_ofdm->fina_timeout, + max_ofdm->fina_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "unresponded_rts:", + le32_to_cpu(ofdm->unresponded_rts), + accum_ofdm->unresponded_rts, + delta_ofdm->unresponded_rts, + max_ofdm->unresponded_rts); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "rxe_frame_lmt_ovrun:", + le32_to_cpu(ofdm->rxe_frame_limit_overrun), + accum_ofdm->rxe_frame_limit_overrun, + delta_ofdm->rxe_frame_limit_overrun, + max_ofdm->rxe_frame_limit_overrun); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "sent_ack_cnt:", + le32_to_cpu(ofdm->sent_ack_cnt), + accum_ofdm->sent_ack_cnt, delta_ofdm->sent_ack_cnt, + max_ofdm->sent_ack_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "sent_cts_cnt:", + le32_to_cpu(ofdm->sent_cts_cnt), + accum_ofdm->sent_cts_cnt, delta_ofdm->sent_cts_cnt, + max_ofdm->sent_cts_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "sent_ba_rsp_cnt:", + le32_to_cpu(ofdm->sent_ba_rsp_cnt), + accum_ofdm->sent_ba_rsp_cnt, + delta_ofdm->sent_ba_rsp_cnt, + max_ofdm->sent_ba_rsp_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "dsp_self_kill:", + le32_to_cpu(ofdm->dsp_self_kill), + accum_ofdm->dsp_self_kill, + delta_ofdm->dsp_self_kill, + max_ofdm->dsp_self_kill); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "mh_format_err:", + le32_to_cpu(ofdm->mh_format_err), + accum_ofdm->mh_format_err, + delta_ofdm->mh_format_err, + max_ofdm->mh_format_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "re_acq_main_rssi_sum:", + le32_to_cpu(ofdm->re_acq_main_rssi_sum), + accum_ofdm->re_acq_main_rssi_sum, + delta_ofdm->re_acq_main_rssi_sum, + max_ofdm->re_acq_main_rssi_sum); + + pos += scnprintf(buf + pos, bufsz - pos, + fmt_header, "Statistics_Rx - CCK:"); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "ina_cnt:", + le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt, + delta_cck->ina_cnt, max_cck->ina_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "fina_cnt:", + le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt, + delta_cck->fina_cnt, max_cck->fina_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "plcp_err:", + le32_to_cpu(cck->plcp_err), accum_cck->plcp_err, + delta_cck->plcp_err, max_cck->plcp_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "crc32_err:", + le32_to_cpu(cck->crc32_err), accum_cck->crc32_err, + delta_cck->crc32_err, max_cck->crc32_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "overrun_err:", + le32_to_cpu(cck->overrun_err), + accum_cck->overrun_err, delta_cck->overrun_err, + max_cck->overrun_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "early_overrun_err:", + le32_to_cpu(cck->early_overrun_err), + accum_cck->early_overrun_err, + delta_cck->early_overrun_err, + max_cck->early_overrun_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "crc32_good:", + le32_to_cpu(cck->crc32_good), accum_cck->crc32_good, + delta_cck->crc32_good, max_cck->crc32_good); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "false_alarm_cnt:", + le32_to_cpu(cck->false_alarm_cnt), + accum_cck->false_alarm_cnt, + delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "fina_sync_err_cnt:", + le32_to_cpu(cck->fina_sync_err_cnt), + accum_cck->fina_sync_err_cnt, + delta_cck->fina_sync_err_cnt, + max_cck->fina_sync_err_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "sfd_timeout:", + le32_to_cpu(cck->sfd_timeout), + accum_cck->sfd_timeout, delta_cck->sfd_timeout, + max_cck->sfd_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "fina_timeout:", + le32_to_cpu(cck->fina_timeout), + accum_cck->fina_timeout, delta_cck->fina_timeout, + max_cck->fina_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "unresponded_rts:", + le32_to_cpu(cck->unresponded_rts), + accum_cck->unresponded_rts, delta_cck->unresponded_rts, + max_cck->unresponded_rts); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "rxe_frame_lmt_ovrun:", + le32_to_cpu(cck->rxe_frame_limit_overrun), + accum_cck->rxe_frame_limit_overrun, + delta_cck->rxe_frame_limit_overrun, + max_cck->rxe_frame_limit_overrun); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "sent_ack_cnt:", + le32_to_cpu(cck->sent_ack_cnt), + accum_cck->sent_ack_cnt, delta_cck->sent_ack_cnt, + max_cck->sent_ack_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "sent_cts_cnt:", + le32_to_cpu(cck->sent_cts_cnt), + accum_cck->sent_cts_cnt, delta_cck->sent_cts_cnt, + max_cck->sent_cts_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "sent_ba_rsp_cnt:", + le32_to_cpu(cck->sent_ba_rsp_cnt), + accum_cck->sent_ba_rsp_cnt, + delta_cck->sent_ba_rsp_cnt, + max_cck->sent_ba_rsp_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "dsp_self_kill:", + le32_to_cpu(cck->dsp_self_kill), + accum_cck->dsp_self_kill, delta_cck->dsp_self_kill, + max_cck->dsp_self_kill); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "mh_format_err:", + le32_to_cpu(cck->mh_format_err), + accum_cck->mh_format_err, delta_cck->mh_format_err, + max_cck->mh_format_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "re_acq_main_rssi_sum:", + le32_to_cpu(cck->re_acq_main_rssi_sum), + accum_cck->re_acq_main_rssi_sum, + delta_cck->re_acq_main_rssi_sum, + max_cck->re_acq_main_rssi_sum); + + pos += scnprintf(buf + pos, bufsz - pos, + fmt_header, "Statistics_Rx - GENERAL:"); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "bogus_cts:", + le32_to_cpu(general->bogus_cts), + accum_general->bogus_cts, delta_general->bogus_cts, + max_general->bogus_cts); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "bogus_ack:", + le32_to_cpu(general->bogus_ack), + accum_general->bogus_ack, delta_general->bogus_ack, + max_general->bogus_ack); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "non_bssid_frames:", + le32_to_cpu(general->non_bssid_frames), + accum_general->non_bssid_frames, + delta_general->non_bssid_frames, + max_general->non_bssid_frames); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "filtered_frames:", + le32_to_cpu(general->filtered_frames), + accum_general->filtered_frames, + delta_general->filtered_frames, + max_general->filtered_frames); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "non_channel_beacons:", + le32_to_cpu(general->non_channel_beacons), + accum_general->non_channel_beacons, + delta_general->non_channel_beacons, + max_general->non_channel_beacons); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "channel_beacons:", + le32_to_cpu(general->channel_beacons), + accum_general->channel_beacons, + delta_general->channel_beacons, + max_general->channel_beacons); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "num_missed_bcon:", + le32_to_cpu(general->num_missed_bcon), + accum_general->num_missed_bcon, + delta_general->num_missed_bcon, + max_general->num_missed_bcon); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "adc_rx_saturation_time:", + le32_to_cpu(general->adc_rx_saturation_time), + accum_general->adc_rx_saturation_time, + delta_general->adc_rx_saturation_time, + max_general->adc_rx_saturation_time); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "ina_detect_search_tm:", + le32_to_cpu(general->ina_detection_search_time), + accum_general->ina_detection_search_time, + delta_general->ina_detection_search_time, + max_general->ina_detection_search_time); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "beacon_silence_rssi_a:", + le32_to_cpu(general->beacon_silence_rssi_a), + accum_general->beacon_silence_rssi_a, + delta_general->beacon_silence_rssi_a, + max_general->beacon_silence_rssi_a); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "beacon_silence_rssi_b:", + le32_to_cpu(general->beacon_silence_rssi_b), + accum_general->beacon_silence_rssi_b, + delta_general->beacon_silence_rssi_b, + max_general->beacon_silence_rssi_b); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "beacon_silence_rssi_c:", + le32_to_cpu(general->beacon_silence_rssi_c), + accum_general->beacon_silence_rssi_c, + delta_general->beacon_silence_rssi_c, + max_general->beacon_silence_rssi_c); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "interference_data_flag:", + le32_to_cpu(general->interference_data_flag), + accum_general->interference_data_flag, + delta_general->interference_data_flag, + max_general->interference_data_flag); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "channel_load:", + le32_to_cpu(general->channel_load), + accum_general->channel_load, + delta_general->channel_load, + max_general->channel_load); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "dsp_false_alarms:", + le32_to_cpu(general->dsp_false_alarms), + accum_general->dsp_false_alarms, + delta_general->dsp_false_alarms, + max_general->dsp_false_alarms); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "beacon_rssi_a:", + le32_to_cpu(general->beacon_rssi_a), + accum_general->beacon_rssi_a, + delta_general->beacon_rssi_a, + max_general->beacon_rssi_a); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "beacon_rssi_b:", + le32_to_cpu(general->beacon_rssi_b), + accum_general->beacon_rssi_b, + delta_general->beacon_rssi_b, + max_general->beacon_rssi_b); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "beacon_rssi_c:", + le32_to_cpu(general->beacon_rssi_c), + accum_general->beacon_rssi_c, + delta_general->beacon_rssi_c, + max_general->beacon_rssi_c); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "beacon_energy_a:", + le32_to_cpu(general->beacon_energy_a), + accum_general->beacon_energy_a, + delta_general->beacon_energy_a, + max_general->beacon_energy_a); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "beacon_energy_b:", + le32_to_cpu(general->beacon_energy_b), + accum_general->beacon_energy_b, + delta_general->beacon_energy_b, + max_general->beacon_energy_b); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "beacon_energy_c:", + le32_to_cpu(general->beacon_energy_c), + accum_general->beacon_energy_c, + delta_general->beacon_energy_c, + max_general->beacon_energy_c); + + pos += scnprintf(buf + pos, bufsz - pos, + fmt_header, "Statistics_Rx - OFDM_HT:"); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "plcp_err:", + le32_to_cpu(ht->plcp_err), accum_ht->plcp_err, + delta_ht->plcp_err, max_ht->plcp_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "overrun_err:", + le32_to_cpu(ht->overrun_err), accum_ht->overrun_err, + delta_ht->overrun_err, max_ht->overrun_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "early_overrun_err:", + le32_to_cpu(ht->early_overrun_err), + accum_ht->early_overrun_err, + delta_ht->early_overrun_err, + max_ht->early_overrun_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "crc32_good:", + le32_to_cpu(ht->crc32_good), accum_ht->crc32_good, + delta_ht->crc32_good, max_ht->crc32_good); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "crc32_err:", + le32_to_cpu(ht->crc32_err), accum_ht->crc32_err, + delta_ht->crc32_err, max_ht->crc32_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "mh_format_err:", + le32_to_cpu(ht->mh_format_err), + accum_ht->mh_format_err, + delta_ht->mh_format_err, max_ht->mh_format_err); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg_crc32_good:", + le32_to_cpu(ht->agg_crc32_good), + accum_ht->agg_crc32_good, + delta_ht->agg_crc32_good, max_ht->agg_crc32_good); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg_mpdu_cnt:", + le32_to_cpu(ht->agg_mpdu_cnt), + accum_ht->agg_mpdu_cnt, + delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg_cnt:", + le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt, + delta_ht->agg_cnt, max_ht->agg_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "unsupport_mcs:", + le32_to_cpu(ht->unsupport_mcs), + accum_ht->unsupport_mcs, + delta_ht->unsupport_mcs, max_ht->unsupport_mcs); + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +ssize_t il4965_ucode_tx_stats_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + int pos = 0; + char *buf; + int bufsz = (sizeof(struct stats_tx) * 48) + 250; + ssize_t ret; + struct stats_tx *tx, *accum_tx, *delta_tx, *max_tx; + + if (!il_is_alive(il)) + return -EAGAIN; + + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) { + IL_ERR("Can not allocate Buffer\n"); + return -ENOMEM; + } + + /* the statistic information display here is based on + * the last stats notification from uCode + * might not reflect the current uCode activity + */ + tx = &il->_4965.stats.tx; + accum_tx = &il->_4965.accum_stats.tx; + delta_tx = &il->_4965.delta_stats.tx; + max_tx = &il->_4965.max_delta.tx; + + pos += il4965_stats_flag(il, buf, bufsz); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_header, "Statistics_Tx:"); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "preamble:", + le32_to_cpu(tx->preamble_cnt), + accum_tx->preamble_cnt, + delta_tx->preamble_cnt, max_tx->preamble_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "rx_detected_cnt:", + le32_to_cpu(tx->rx_detected_cnt), + accum_tx->rx_detected_cnt, + delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "bt_prio_defer_cnt:", + le32_to_cpu(tx->bt_prio_defer_cnt), + accum_tx->bt_prio_defer_cnt, + delta_tx->bt_prio_defer_cnt, + max_tx->bt_prio_defer_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "bt_prio_kill_cnt:", + le32_to_cpu(tx->bt_prio_kill_cnt), + accum_tx->bt_prio_kill_cnt, + delta_tx->bt_prio_kill_cnt, + max_tx->bt_prio_kill_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "few_bytes_cnt:", + le32_to_cpu(tx->few_bytes_cnt), + accum_tx->few_bytes_cnt, + delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "cts_timeout:", + le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout, + delta_tx->cts_timeout, max_tx->cts_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "ack_timeout:", + le32_to_cpu(tx->ack_timeout), + accum_tx->ack_timeout, + delta_tx->ack_timeout, max_tx->ack_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "expected_ack_cnt:", + le32_to_cpu(tx->expected_ack_cnt), + accum_tx->expected_ack_cnt, + delta_tx->expected_ack_cnt, + max_tx->expected_ack_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "actual_ack_cnt:", + le32_to_cpu(tx->actual_ack_cnt), + accum_tx->actual_ack_cnt, + delta_tx->actual_ack_cnt, + max_tx->actual_ack_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "dump_msdu_cnt:", + le32_to_cpu(tx->dump_msdu_cnt), + accum_tx->dump_msdu_cnt, + delta_tx->dump_msdu_cnt, + max_tx->dump_msdu_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "abort_nxt_frame_mismatch:", + le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt), + accum_tx->burst_abort_next_frame_mismatch_cnt, + delta_tx->burst_abort_next_frame_mismatch_cnt, + max_tx->burst_abort_next_frame_mismatch_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "abort_missing_nxt_frame:", + le32_to_cpu(tx->burst_abort_missing_next_frame_cnt), + accum_tx->burst_abort_missing_next_frame_cnt, + delta_tx->burst_abort_missing_next_frame_cnt, + max_tx->burst_abort_missing_next_frame_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "cts_timeout_collision:", + le32_to_cpu(tx->cts_timeout_collision), + accum_tx->cts_timeout_collision, + delta_tx->cts_timeout_collision, + max_tx->cts_timeout_collision); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "ack_ba_timeout_collision:", + le32_to_cpu(tx->ack_or_ba_timeout_collision), + accum_tx->ack_or_ba_timeout_collision, + delta_tx->ack_or_ba_timeout_collision, + max_tx->ack_or_ba_timeout_collision); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg ba_timeout:", + le32_to_cpu(tx->agg.ba_timeout), + accum_tx->agg.ba_timeout, + delta_tx->agg.ba_timeout, + max_tx->agg.ba_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg ba_resched_frames:", + le32_to_cpu(tx->agg.ba_reschedule_frames), + accum_tx->agg.ba_reschedule_frames, + delta_tx->agg.ba_reschedule_frames, + max_tx->agg.ba_reschedule_frames); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg scd_query_agg_frame:", + le32_to_cpu(tx->agg.scd_query_agg_frame_cnt), + accum_tx->agg.scd_query_agg_frame_cnt, + delta_tx->agg.scd_query_agg_frame_cnt, + max_tx->agg.scd_query_agg_frame_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg scd_query_no_agg:", + le32_to_cpu(tx->agg.scd_query_no_agg), + accum_tx->agg.scd_query_no_agg, + delta_tx->agg.scd_query_no_agg, + max_tx->agg.scd_query_no_agg); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg scd_query_agg:", + le32_to_cpu(tx->agg.scd_query_agg), + accum_tx->agg.scd_query_agg, + delta_tx->agg.scd_query_agg, + max_tx->agg.scd_query_agg); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg scd_query_mismatch:", + le32_to_cpu(tx->agg.scd_query_mismatch), + accum_tx->agg.scd_query_mismatch, + delta_tx->agg.scd_query_mismatch, + max_tx->agg.scd_query_mismatch); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg frame_not_ready:", + le32_to_cpu(tx->agg.frame_not_ready), + accum_tx->agg.frame_not_ready, + delta_tx->agg.frame_not_ready, + max_tx->agg.frame_not_ready); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg underrun:", + le32_to_cpu(tx->agg.underrun), + accum_tx->agg.underrun, + delta_tx->agg.underrun, max_tx->agg.underrun); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg bt_prio_kill:", + le32_to_cpu(tx->agg.bt_prio_kill), + accum_tx->agg.bt_prio_kill, + delta_tx->agg.bt_prio_kill, + max_tx->agg.bt_prio_kill); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "agg rx_ba_rsp_cnt:", + le32_to_cpu(tx->agg.rx_ba_rsp_cnt), + accum_tx->agg.rx_ba_rsp_cnt, + delta_tx->agg.rx_ba_rsp_cnt, + max_tx->agg.rx_ba_rsp_cnt); + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +ssize_t +il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + int pos = 0; + char *buf; + int bufsz = sizeof(struct stats_general) * 10 + 300; + ssize_t ret; + struct stats_general_common *general, *accum_general; + struct stats_general_common *delta_general, *max_general; + struct stats_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; + struct stats_div *div, *accum_div, *delta_div, *max_div; + + if (!il_is_alive(il)) + return -EAGAIN; + + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) { + IL_ERR("Can not allocate Buffer\n"); + return -ENOMEM; + } + + /* the statistic information display here is based on + * the last stats notification from uCode + * might not reflect the current uCode activity + */ + general = &il->_4965.stats.general.common; + dbg = &il->_4965.stats.general.common.dbg; + div = &il->_4965.stats.general.common.div; + accum_general = &il->_4965.accum_stats.general.common; + accum_dbg = &il->_4965.accum_stats.general.common.dbg; + accum_div = &il->_4965.accum_stats.general.common.div; + delta_general = &il->_4965.delta_stats.general.common; + max_general = &il->_4965.max_delta.general.common; + delta_dbg = &il->_4965.delta_stats.general.common.dbg; + max_dbg = &il->_4965.max_delta.general.common.dbg; + delta_div = &il->_4965.delta_stats.general.common.div; + max_div = &il->_4965.max_delta.general.common.div; + + pos += il4965_stats_flag(il, buf, bufsz); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_header, "Statistics_General:"); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_value, "temperature:", + le32_to_cpu(general->temperature)); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_value, "ttl_timestamp:", + le32_to_cpu(general->ttl_timestamp)); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "burst_check:", + le32_to_cpu(dbg->burst_check), + accum_dbg->burst_check, + delta_dbg->burst_check, max_dbg->burst_check); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "burst_count:", + le32_to_cpu(dbg->burst_count), + accum_dbg->burst_count, + delta_dbg->burst_count, max_dbg->burst_count); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "wait_for_silence_timeout_count:", + le32_to_cpu(dbg->wait_for_silence_timeout_cnt), + accum_dbg->wait_for_silence_timeout_cnt, + delta_dbg->wait_for_silence_timeout_cnt, + max_dbg->wait_for_silence_timeout_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "sleep_time:", + le32_to_cpu(general->sleep_time), + accum_general->sleep_time, + delta_general->sleep_time, max_general->sleep_time); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "slots_out:", + le32_to_cpu(general->slots_out), + accum_general->slots_out, + delta_general->slots_out, max_general->slots_out); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "slots_idle:", + le32_to_cpu(general->slots_idle), + accum_general->slots_idle, + delta_general->slots_idle, max_general->slots_idle); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "tx_on_a:", + le32_to_cpu(div->tx_on_a), accum_div->tx_on_a, + delta_div->tx_on_a, max_div->tx_on_a); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "tx_on_b:", + le32_to_cpu(div->tx_on_b), accum_div->tx_on_b, + delta_div->tx_on_b, max_div->tx_on_b); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "exec_time:", + le32_to_cpu(div->exec_time), accum_div->exec_time, + delta_div->exec_time, max_div->exec_time); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "probe_time:", + le32_to_cpu(div->probe_time), accum_div->probe_time, + delta_div->probe_time, max_div->probe_time); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "rx_enable_counter:", + le32_to_cpu(general->rx_enable_counter), + accum_general->rx_enable_counter, + delta_general->rx_enable_counter, + max_general->rx_enable_counter); + pos += scnprintf(buf + pos, bufsz - pos, + fmt_table, "num_of_sos_states:", + le32_to_cpu(general->num_of_sos_states), + accum_general->num_of_sos_states, + delta_general->num_of_sos_states, + max_general->num_of_sos_states); + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} diff --git a/drivers/net/wireless/iwlegacy/4965-rs.c b/drivers/net/wireless/iwlegacy/4965-rs.c new file mode 100644 index 000000000000..4a543114372b --- /dev/null +++ b/drivers/net/wireless/iwlegacy/4965-rs.c @@ -0,0 +1,2862 @@ +/****************************************************************************** + * + * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + *****************************************************************************/ +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include "iwl-dev.h" +#include "iwl-sta.h" +#include "iwl-core.h" +#include "iwl-4965.h" + +#define IL4965_RS_NAME "iwl-4965-rs" + +#define NUM_TRY_BEFORE_ANT_TOGGLE 1 +#define IL_NUMBER_TRY 1 +#define IL_HT_NUMBER_TRY 3 + +#define RATE_MAX_WINDOW 62 /* # tx in history win */ +#define RATE_MIN_FAILURE_TH 6 /* min failures to calc tpt */ +#define RATE_MIN_SUCCESS_TH 8 /* min successes to calc tpt */ + +/* max allowed rate miss before sync LQ cmd */ +#define IL_MISSED_RATE_MAX 15 +/* max time to accum history 2 seconds */ +#define RATE_SCALE_FLUSH_INTVL (3*HZ) + +static u8 rs_ht_to_legacy[] = { + RATE_6M_IDX, RATE_6M_IDX, + RATE_6M_IDX, RATE_6M_IDX, + RATE_6M_IDX, + RATE_6M_IDX, RATE_9M_IDX, + RATE_12M_IDX, RATE_18M_IDX, + RATE_24M_IDX, RATE_36M_IDX, + RATE_48M_IDX, RATE_54M_IDX +}; + +static const u8 ant_toggle_lookup[] = { + /*ANT_NONE -> */ ANT_NONE, + /*ANT_A -> */ ANT_B, + /*ANT_B -> */ ANT_C, + /*ANT_AB -> */ ANT_BC, + /*ANT_C -> */ ANT_A, + /*ANT_AC -> */ ANT_AB, + /*ANT_BC -> */ ANT_AC, + /*ANT_ABC -> */ ANT_ABC, +}; + +#define IL_DECLARE_RATE_INFO(r, s, ip, in, rp, rn, pp, np) \ + [RATE_##r##M_IDX] = { RATE_##r##M_PLCP, \ + RATE_SISO_##s##M_PLCP, \ + RATE_MIMO2_##s##M_PLCP,\ + RATE_##r##M_IEEE, \ + RATE_##ip##M_IDX, \ + RATE_##in##M_IDX, \ + RATE_##rp##M_IDX, \ + RATE_##rn##M_IDX, \ + RATE_##pp##M_IDX, \ + RATE_##np##M_IDX } + +/* + * Parameter order: + * rate, ht rate, prev rate, next rate, prev tgg rate, next tgg rate + * + * If there isn't a valid next or previous rate then INV is used which + * maps to RATE_INVALID + * + */ +const struct il_rate_info il_rates[RATE_COUNT] = { + IL_DECLARE_RATE_INFO(1, INV, INV, 2, INV, 2, INV, 2), /* 1mbps */ + IL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ + IL_DECLARE_RATE_INFO(5, INV, 2, 6, 2, 11, 2, 11), /*5.5mbps */ + IL_DECLARE_RATE_INFO(11, INV, 9, 12, 9, 12, 5, 18), /* 11mbps */ + IL_DECLARE_RATE_INFO(6, 6, 5, 9, 5, 11, 5, 11), /* 6mbps */ + IL_DECLARE_RATE_INFO(9, 6, 6, 11, 6, 11, 5, 11), /* 9mbps */ + IL_DECLARE_RATE_INFO(12, 12, 11, 18, 11, 18, 11, 18), /* 12mbps */ + IL_DECLARE_RATE_INFO(18, 18, 12, 24, 12, 24, 11, 24), /* 18mbps */ + IL_DECLARE_RATE_INFO(24, 24, 18, 36, 18, 36, 18, 36), /* 24mbps */ + IL_DECLARE_RATE_INFO(36, 36, 24, 48, 24, 48, 24, 48), /* 36mbps */ + IL_DECLARE_RATE_INFO(48, 48, 36, 54, 36, 54, 36, 54), /* 48mbps */ + IL_DECLARE_RATE_INFO(54, 54, 48, INV, 48, INV, 48, INV),/* 54mbps */ + IL_DECLARE_RATE_INFO(60, 60, 48, INV, 48, INV, 48, INV),/* 60mbps */ +}; + +static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags) +{ + int idx = 0; + + /* HT rate format */ + if (rate_n_flags & RATE_MCS_HT_MSK) { + idx = (rate_n_flags & 0xff); + + if (idx >= RATE_MIMO2_6M_PLCP) + idx = idx - RATE_MIMO2_6M_PLCP; + + idx += IL_FIRST_OFDM_RATE; + /* skip 9M not supported in ht*/ + if (idx >= RATE_9M_IDX) + idx += 1; + if (idx >= IL_FIRST_OFDM_RATE && idx <= IL_LAST_OFDM_RATE) + return idx; + + /* legacy rate format, search for match in table */ + } else { + for (idx = 0; idx < ARRAY_SIZE(il_rates); idx++) + if (il_rates[idx].plcp == (rate_n_flags & 0xFF)) + return idx; + } + + return -1; +} + +static void il4965_rs_rate_scale_perform(struct il_priv *il, + struct sk_buff *skb, + struct ieee80211_sta *sta, + struct il_lq_sta *lq_sta); +static void il4965_rs_fill_link_cmd(struct il_priv *il, + struct il_lq_sta *lq_sta, u32 rate_n_flags); +static void il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, + bool force_search); + +#ifdef CONFIG_MAC80211_DEBUGFS +static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, + u32 *rate_n_flags, int idx); +#else +static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, + u32 *rate_n_flags, int idx) +{} +#endif + +/** + * The following tables contain the expected throughput metrics for all rates + * + * 1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54, 60 MBits + * + * where invalid entries are zeros. + * + * CCK rates are only valid in legacy table and will only be used in G + * (2.4 GHz) band. + */ + +static s32 expected_tpt_legacy[RATE_COUNT] = { + 7, 13, 35, 58, 40, 57, 72, 98, 121, 154, 177, 186, 0 +}; + +static s32 expected_tpt_siso20MHz[4][RATE_COUNT] = { + {0, 0, 0, 0, 42, 0, 76, 102, 124, 158, 183, 193, 202}, /* Norm */ + {0, 0, 0, 0, 46, 0, 82, 110, 132, 167, 192, 202, 210}, /* SGI */ + {0, 0, 0, 0, 48, 0, 93, 135, 176, 251, 319, 351, 381}, /* AGG */ + {0, 0, 0, 0, 53, 0, 102, 149, 193, 275, 348, 381, 413}, /* AGG+SGI */ +}; + +static s32 expected_tpt_siso40MHz[4][RATE_COUNT] = { + {0, 0, 0, 0, 77, 0, 127, 160, 184, 220, 242, 250, 257}, /* Norm */ + {0, 0, 0, 0, 83, 0, 135, 169, 193, 229, 250, 257, 264}, /* SGI */ + {0, 0, 0, 0, 96, 0, 182, 259, 328, 451, 553, 598, 640}, /* AGG */ + {0, 0, 0, 0, 106, 0, 199, 282, 357, 487, 593, 640, 683}, /* AGG+SGI */ +}; + +static s32 expected_tpt_mimo2_20MHz[4][RATE_COUNT] = { + {0, 0, 0, 0, 74, 0, 123, 155, 179, 213, 235, 243, 250}, /* Norm */ + {0, 0, 0, 0, 81, 0, 131, 164, 187, 221, 242, 250, 256}, /* SGI */ + {0, 0, 0, 0, 92, 0, 175, 250, 317, 436, 534, 578, 619}, /* AGG */ + {0, 0, 0, 0, 102, 0, 192, 273, 344, 470, 573, 619, 660}, /* AGG+SGI*/ +}; + +static s32 expected_tpt_mimo2_40MHz[4][RATE_COUNT] = { + {0, 0, 0, 0, 123, 0, 182, 214, 235, 264, 279, 285, 289}, /* Norm */ + {0, 0, 0, 0, 131, 0, 191, 222, 242, 270, 284, 289, 293}, /* SGI */ + {0, 0, 0, 0, 180, 0, 327, 446, 545, 708, 828, 878, 922}, /* AGG */ + {0, 0, 0, 0, 197, 0, 355, 481, 584, 752, 872, 922, 966}, /* AGG+SGI */ +}; + +/* mbps, mcs */ +static const struct il_rate_mcs_info il_rate_mcs[RATE_COUNT] = { + { "1", "BPSK DSSS"}, + { "2", "QPSK DSSS"}, + {"5.5", "BPSK CCK"}, + { "11", "QPSK CCK"}, + { "6", "BPSK 1/2"}, + { "9", "BPSK 1/2"}, + { "12", "QPSK 1/2"}, + { "18", "QPSK 3/4"}, + { "24", "16QAM 1/2"}, + { "36", "16QAM 3/4"}, + { "48", "64QAM 2/3"}, + { "54", "64QAM 3/4"}, + { "60", "64QAM 5/6"}, +}; + +#define MCS_IDX_PER_STREAM (8) + +static inline u8 il4965_rs_extract_rate(u32 rate_n_flags) +{ + return (u8)(rate_n_flags & 0xFF); +} + +static void +il4965_rs_rate_scale_clear_win(struct il_rate_scale_data *win) +{ + win->data = 0; + win->success_counter = 0; + win->success_ratio = IL_INVALID_VALUE; + win->counter = 0; + win->average_tpt = IL_INVALID_VALUE; + win->stamp = 0; +} + +static inline u8 il4965_rs_is_valid_ant(u8 valid_antenna, u8 ant_type) +{ + return (ant_type & valid_antenna) == ant_type; +} + +/* + * removes the old data from the stats. All data that is older than + * TID_MAX_TIME_DIFF, will be deleted. + */ +static void +il4965_rs_tl_rm_old_stats(struct il_traffic_load *tl, u32 curr_time) +{ + /* The oldest age we want to keep */ + u32 oldest_time = curr_time - TID_MAX_TIME_DIFF; + + while (tl->queue_count && tl->time_stamp < oldest_time) { + tl->total -= tl->packet_count[tl->head]; + tl->packet_count[tl->head] = 0; + tl->time_stamp += TID_QUEUE_CELL_SPACING; + tl->queue_count--; + tl->head++; + if (tl->head >= TID_QUEUE_MAX_SIZE) + tl->head = 0; + } +} + +/* + * increment traffic load value for tid and also remove + * any old values if passed the certain time period + */ +static u8 il4965_rs_tl_add_packet(struct il_lq_sta *lq_data, + struct ieee80211_hdr *hdr) +{ + u32 curr_time = jiffies_to_msecs(jiffies); + u32 time_diff; + s32 idx; + struct il_traffic_load *tl = NULL; + u8 tid; + + if (ieee80211_is_data_qos(hdr->frame_control)) { + u8 *qc = ieee80211_get_qos_ctl(hdr); + tid = qc[0] & 0xf; + } else + return MAX_TID_COUNT; + + if (unlikely(tid >= TID_MAX_LOAD_COUNT)) + return MAX_TID_COUNT; + + tl = &lq_data->load[tid]; + + curr_time -= curr_time % TID_ROUND_VALUE; + + /* Happens only for the first packet. Initialize the data */ + if (!(tl->queue_count)) { + tl->total = 1; + tl->time_stamp = curr_time; + tl->queue_count = 1; + tl->head = 0; + tl->packet_count[0] = 1; + return MAX_TID_COUNT; + } + + time_diff = TIME_WRAP_AROUND(tl->time_stamp, curr_time); + idx = time_diff / TID_QUEUE_CELL_SPACING; + + /* The history is too long: remove data that is older than */ + /* TID_MAX_TIME_DIFF */ + if (idx >= TID_QUEUE_MAX_SIZE) + il4965_rs_tl_rm_old_stats(tl, curr_time); + + idx = (tl->head + idx) % TID_QUEUE_MAX_SIZE; + tl->packet_count[idx] = tl->packet_count[idx] + 1; + tl->total = tl->total + 1; + + if ((idx + 1) > tl->queue_count) + tl->queue_count = idx + 1; + + return tid; +} + +/* + get the traffic load value for tid +*/ +static u32 il4965_rs_tl_get_load(struct il_lq_sta *lq_data, u8 tid) +{ + u32 curr_time = jiffies_to_msecs(jiffies); + u32 time_diff; + s32 idx; + struct il_traffic_load *tl = NULL; + + if (tid >= TID_MAX_LOAD_COUNT) + return 0; + + tl = &(lq_data->load[tid]); + + curr_time -= curr_time % TID_ROUND_VALUE; + + if (!(tl->queue_count)) + return 0; + + time_diff = TIME_WRAP_AROUND(tl->time_stamp, curr_time); + idx = time_diff / TID_QUEUE_CELL_SPACING; + + /* The history is too long: remove data that is older than */ + /* TID_MAX_TIME_DIFF */ + if (idx >= TID_QUEUE_MAX_SIZE) + il4965_rs_tl_rm_old_stats(tl, curr_time); + + return tl->total; +} + +static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *il, + struct il_lq_sta *lq_data, u8 tid, + struct ieee80211_sta *sta) +{ + int ret = -EAGAIN; + u32 load; + + load = il4965_rs_tl_get_load(lq_data, tid); + + if (load > IL_AGG_LOAD_THRESHOLD) { + D_HT("Starting Tx agg: STA: %pM tid: %d\n", + sta->addr, tid); + ret = ieee80211_start_tx_ba_session(sta, tid, 5000); + if (ret == -EAGAIN) { + /* + * driver and mac80211 is out of sync + * this might be cause by reloading firmware + * stop the tx ba session here + */ + IL_ERR("Fail start Tx agg on tid: %d\n", + tid); + ieee80211_stop_tx_ba_session(sta, tid); + } + } else { + IL_ERR("Aggregation not enabled for tid %d " + "because load = %u\n", tid, load); + } + return ret; +} + +static void il4965_rs_tl_turn_on_agg(struct il_priv *il, u8 tid, + struct il_lq_sta *lq_data, + struct ieee80211_sta *sta) +{ + if (tid < TID_MAX_LOAD_COUNT) + il4965_rs_tl_turn_on_agg_for_tid(il, lq_data, tid, sta); + else + IL_ERR("tid exceeds max load count: %d/%d\n", + tid, TID_MAX_LOAD_COUNT); +} + +static inline int il4965_get_il4965_num_of_ant_from_rate(u32 rate_n_flags) +{ + return !!(rate_n_flags & RATE_MCS_ANT_A_MSK) + + !!(rate_n_flags & RATE_MCS_ANT_B_MSK) + + !!(rate_n_flags & RATE_MCS_ANT_C_MSK); +} + +/* + * Static function to get the expected throughput from an il_scale_tbl_info + * that wraps a NULL pointer check + */ +static s32 +il4965_get_expected_tpt(struct il_scale_tbl_info *tbl, int rs_idx) +{ + if (tbl->expected_tpt) + return tbl->expected_tpt[rs_idx]; + return 0; +} + +/** + * il4965_rs_collect_tx_data - Update the success/failure sliding win + * + * We keep a sliding win of the last 62 packets transmitted + * at this rate. win->data contains the bitmask of successful + * packets. + */ +static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, + int scale_idx, int attempts, int successes) +{ + struct il_rate_scale_data *win = NULL; + static const u64 mask = (((u64)1) << (RATE_MAX_WINDOW - 1)); + s32 fail_count, tpt; + + if (scale_idx < 0 || scale_idx >= RATE_COUNT) + return -EINVAL; + + /* Select win for current tx bit rate */ + win = &(tbl->win[scale_idx]); + + /* Get expected throughput */ + tpt = il4965_get_expected_tpt(tbl, scale_idx); + + /* + * Keep track of only the latest 62 tx frame attempts in this rate's + * history win; anything older isn't really relevant any more. + * If we have filled up the sliding win, drop the oldest attempt; + * if the oldest attempt (highest bit in bitmap) shows "success", + * subtract "1" from the success counter (this is the main reason + * we keep these bitmaps!). + */ + while (attempts > 0) { + if (win->counter >= RATE_MAX_WINDOW) { + + /* remove earliest */ + win->counter = RATE_MAX_WINDOW - 1; + + if (win->data & mask) { + win->data &= ~mask; + win->success_counter--; + } + } + + /* Increment frames-attempted counter */ + win->counter++; + + /* Shift bitmap by one frame to throw away oldest history */ + win->data <<= 1; + + /* Mark the most recent #successes attempts as successful */ + if (successes > 0) { + win->success_counter++; + win->data |= 0x1; + successes--; + } + + attempts--; + } + + /* Calculate current success ratio, avoid divide-by-0! */ + if (win->counter > 0) + win->success_ratio = 128 * (100 * win->success_counter) + / win->counter; + else + win->success_ratio = IL_INVALID_VALUE; + + fail_count = win->counter - win->success_counter; + + /* Calculate average throughput, if we have enough history. */ + if (fail_count >= RATE_MIN_FAILURE_TH || + win->success_counter >= RATE_MIN_SUCCESS_TH) + win->average_tpt = (win->success_ratio * tpt + 64) / 128; + else + win->average_tpt = IL_INVALID_VALUE; + + /* Tag this win as having been updated */ + win->stamp = jiffies; + + return 0; +} + +/* + * Fill uCode API rate_n_flags field, based on "search" or "active" table. + */ +static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, + struct il_scale_tbl_info *tbl, + int idx, u8 use_green) +{ + u32 rate_n_flags = 0; + + if (is_legacy(tbl->lq_type)) { + rate_n_flags = il_rates[idx].plcp; + if (idx >= IL_FIRST_CCK_RATE && idx <= IL_LAST_CCK_RATE) + rate_n_flags |= RATE_MCS_CCK_MSK; + + } else if (is_Ht(tbl->lq_type)) { + if (idx > IL_LAST_OFDM_RATE) { + IL_ERR("Invalid HT rate idx %d\n", idx); + idx = IL_LAST_OFDM_RATE; + } + rate_n_flags = RATE_MCS_HT_MSK; + + if (is_siso(tbl->lq_type)) + rate_n_flags |= il_rates[idx].plcp_siso; + else + rate_n_flags |= il_rates[idx].plcp_mimo2; + } else { + IL_ERR("Invalid tbl->lq_type %d\n", tbl->lq_type); + } + + rate_n_flags |= ((tbl->ant_type << RATE_MCS_ANT_POS) & + RATE_MCS_ANT_ABC_MSK); + + if (is_Ht(tbl->lq_type)) { + if (tbl->is_ht40) { + if (tbl->is_dup) + rate_n_flags |= RATE_MCS_DUP_MSK; + else + rate_n_flags |= RATE_MCS_HT40_MSK; + } + if (tbl->is_SGI) + rate_n_flags |= RATE_MCS_SGI_MSK; + + if (use_green) { + rate_n_flags |= RATE_MCS_GF_MSK; + if (is_siso(tbl->lq_type) && tbl->is_SGI) { + rate_n_flags &= ~RATE_MCS_SGI_MSK; + IL_ERR("GF was set with SGI:SISO\n"); + } + } + } + return rate_n_flags; +} + +/* + * Interpret uCode API's rate_n_flags format, + * fill "search" or "active" tx mode table. + */ +static int il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, + enum ieee80211_band band, + struct il_scale_tbl_info *tbl, + int *rate_idx) +{ + u32 ant_msk = (rate_n_flags & RATE_MCS_ANT_ABC_MSK); + u8 il4965_num_of_ant = il4965_get_il4965_num_of_ant_from_rate(rate_n_flags); + u8 mcs; + + memset(tbl, 0, sizeof(struct il_scale_tbl_info)); + *rate_idx = il4965_hwrate_to_plcp_idx(rate_n_flags); + + if (*rate_idx == RATE_INVALID) { + *rate_idx = -1; + return -EINVAL; + } + tbl->is_SGI = 0; /* default legacy setup */ + tbl->is_ht40 = 0; + tbl->is_dup = 0; + tbl->ant_type = (ant_msk >> RATE_MCS_ANT_POS); + tbl->lq_type = LQ_NONE; + tbl->max_search = IL_MAX_SEARCH; + + /* legacy rate format */ + if (!(rate_n_flags & RATE_MCS_HT_MSK)) { + if (il4965_num_of_ant == 1) { + if (band == IEEE80211_BAND_5GHZ) + tbl->lq_type = LQ_A; + else + tbl->lq_type = LQ_G; + } + /* HT rate format */ + } else { + if (rate_n_flags & RATE_MCS_SGI_MSK) + tbl->is_SGI = 1; + + if ((rate_n_flags & RATE_MCS_HT40_MSK) || + (rate_n_flags & RATE_MCS_DUP_MSK)) + tbl->is_ht40 = 1; + + if (rate_n_flags & RATE_MCS_DUP_MSK) + tbl->is_dup = 1; + + mcs = il4965_rs_extract_rate(rate_n_flags); + + /* SISO */ + if (mcs <= RATE_SISO_60M_PLCP) { + if (il4965_num_of_ant == 1) + tbl->lq_type = LQ_SISO; /*else NONE*/ + /* MIMO2 */ + } else { + if (il4965_num_of_ant == 2) + tbl->lq_type = LQ_MIMO2; + } + } + return 0; +} + +/* switch to another antenna/antennas and return 1 */ +/* if no other valid antenna found, return 0 */ +static int il4965_rs_toggle_antenna(u32 valid_ant, u32 *rate_n_flags, + struct il_scale_tbl_info *tbl) +{ + u8 new_ant_type; + + if (!tbl->ant_type || tbl->ant_type > ANT_ABC) + return 0; + + if (!il4965_rs_is_valid_ant(valid_ant, tbl->ant_type)) + return 0; + + new_ant_type = ant_toggle_lookup[tbl->ant_type]; + + while (new_ant_type != tbl->ant_type && + !il4965_rs_is_valid_ant(valid_ant, new_ant_type)) + new_ant_type = ant_toggle_lookup[new_ant_type]; + + if (new_ant_type == tbl->ant_type) + return 0; + + tbl->ant_type = new_ant_type; + *rate_n_flags &= ~RATE_MCS_ANT_ABC_MSK; + *rate_n_flags |= new_ant_type << RATE_MCS_ANT_POS; + return 1; +} + +/** + * Green-field mode is valid if the station supports it and + * there are no non-GF stations present in the BSS. + */ +static bool il4965_rs_use_green(struct ieee80211_sta *sta) +{ + struct il_station_priv *sta_priv = (void *)sta->drv_priv; + struct il_rxon_context *ctx = sta_priv->common.ctx; + + return (sta->ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD) && + !(ctx->ht.non_gf_sta_present); +} + +/** + * il4965_rs_get_supported_rates - get the available rates + * + * if management frame or broadcast frame only return + * basic available rates. + * + */ +static u16 il4965_rs_get_supported_rates(struct il_lq_sta *lq_sta, + struct ieee80211_hdr *hdr, + enum il_table_type rate_type) +{ + if (is_legacy(rate_type)) { + return lq_sta->active_legacy_rate; + } else { + if (is_siso(rate_type)) + return lq_sta->active_siso_rate; + else + return lq_sta->active_mimo2_rate; + } +} + +static u16 +il4965_rs_get_adjacent_rate(struct il_priv *il, u8 idx, u16 rate_mask, + int rate_type) +{ + u8 high = RATE_INVALID; + u8 low = RATE_INVALID; + + /* 802.11A or ht walks to the next literal adjacent rate in + * the rate table */ + if (is_a_band(rate_type) || !is_legacy(rate_type)) { + int i; + u32 mask; + + /* Find the previous rate that is in the rate mask */ + i = idx - 1; + for (mask = (1 << i); i >= 0; i--, mask >>= 1) { + if (rate_mask & mask) { + low = i; + break; + } + } + + /* Find the next rate that is in the rate mask */ + i = idx + 1; + for (mask = (1 << i); i < RATE_COUNT; i++, mask <<= 1) { + if (rate_mask & mask) { + high = i; + break; + } + } + + return (high << 8) | low; + } + + low = idx; + while (low != RATE_INVALID) { + low = il_rates[low].prev_rs; + if (low == RATE_INVALID) + break; + if (rate_mask & (1 << low)) + break; + D_RATE("Skipping masked lower rate: %d\n", low); + } + + high = idx; + while (high != RATE_INVALID) { + high = il_rates[high].next_rs; + if (high == RATE_INVALID) + break; + if (rate_mask & (1 << high)) + break; + D_RATE("Skipping masked higher rate: %d\n", high); + } + + return (high << 8) | low; +} + +static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, + struct il_scale_tbl_info *tbl, + u8 scale_idx, u8 ht_possible) +{ + s32 low; + u16 rate_mask; + u16 high_low; + u8 switch_to_legacy = 0; + u8 is_green = lq_sta->is_green; + struct il_priv *il = lq_sta->drv; + + /* check if we need to switch from HT to legacy rates. + * assumption is that mandatory rates (1Mbps or 6Mbps) + * are always supported (spec demand) */ + if (!is_legacy(tbl->lq_type) && (!ht_possible || !scale_idx)) { + switch_to_legacy = 1; + scale_idx = rs_ht_to_legacy[scale_idx]; + if (lq_sta->band == IEEE80211_BAND_5GHZ) + tbl->lq_type = LQ_A; + else + tbl->lq_type = LQ_G; + + if (il4965_num_of_ant(tbl->ant_type) > 1) + tbl->ant_type = + il4965_first_antenna(il->hw_params.valid_tx_ant); + + tbl->is_ht40 = 0; + tbl->is_SGI = 0; + tbl->max_search = IL_MAX_SEARCH; + } + + rate_mask = il4965_rs_get_supported_rates(lq_sta, NULL, tbl->lq_type); + + /* Mask with station rate restriction */ + if (is_legacy(tbl->lq_type)) { + /* supp_rates has no CCK bits in A mode */ + if (lq_sta->band == IEEE80211_BAND_5GHZ) + rate_mask = (u16)(rate_mask & + (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); + else + rate_mask = (u16)(rate_mask & lq_sta->supp_rates); + } + + /* If we switched from HT to legacy, check current rate */ + if (switch_to_legacy && (rate_mask & (1 << scale_idx))) { + low = scale_idx; + goto out; + } + + high_low = il4965_rs_get_adjacent_rate(lq_sta->drv, + scale_idx, rate_mask, + tbl->lq_type); + low = high_low & 0xff; + + if (low == RATE_INVALID) + low = scale_idx; + +out: + return il4965_rate_n_flags_from_tbl(lq_sta->drv, tbl, low, is_green); +} + +/* + * Simple function to compare two rate scale table types + */ +static bool il4965_table_type_matches(struct il_scale_tbl_info *a, + struct il_scale_tbl_info *b) +{ + return (a->lq_type == b->lq_type && a->ant_type == b->ant_type && + a->is_SGI == b->is_SGI); +} + +/* + * mac80211 sends us Tx status + */ +static void +il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, + struct ieee80211_sta *sta, void *il_sta, + struct sk_buff *skb) +{ + int legacy_success; + int retries; + int rs_idx, mac_idx, i; + struct il_lq_sta *lq_sta = il_sta; + struct il_link_quality_cmd *table; + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + struct il_priv *il = (struct il_priv *)il_r; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + enum mac80211_rate_control_flags mac_flags; + u32 tx_rate; + struct il_scale_tbl_info tbl_type; + struct il_scale_tbl_info *curr_tbl, *other_tbl, *tmp_tbl; + struct il_station_priv *sta_priv = (void *)sta->drv_priv; + struct il_rxon_context *ctx = sta_priv->common.ctx; + + D_RATE( + "get frame ack response, update rate scale win\n"); + + /* Treat uninitialized rate scaling data same as non-existing. */ + if (!lq_sta) { + D_RATE("Station rate scaling not created yet.\n"); + return; + } else if (!lq_sta->drv) { + D_RATE("Rate scaling not initialized yet.\n"); + return; + } + + if (!ieee80211_is_data(hdr->frame_control) || + (info->flags & IEEE80211_TX_CTL_NO_ACK)) + return; + + /* This packet was aggregated but doesn't carry status info */ + if ((info->flags & IEEE80211_TX_CTL_AMPDU) && + !(info->flags & IEEE80211_TX_STAT_AMPDU)) + return; + + /* + * Ignore this Tx frame response if its initial rate doesn't match + * that of latest Link Quality command. There may be stragglers + * from a previous Link Quality command, but we're no longer interested + * in those; they're either from the "active" mode while we're trying + * to check "search" mode, or a prior "search" mode after we've moved + * to a new "search" mode (which might become the new "active" mode). + */ + table = &lq_sta->lq; + tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); + il4965_rs_get_tbl_info_from_mcs(tx_rate, + il->band, &tbl_type, &rs_idx); + if (il->band == IEEE80211_BAND_5GHZ) + rs_idx -= IL_FIRST_OFDM_RATE; + mac_flags = info->status.rates[0].flags; + mac_idx = info->status.rates[0].idx; + /* For HT packets, map MCS to PLCP */ + if (mac_flags & IEEE80211_TX_RC_MCS) { + mac_idx &= RATE_MCS_CODE_MSK; /* Remove # of streams */ + if (mac_idx >= (RATE_9M_IDX - IL_FIRST_OFDM_RATE)) + mac_idx++; + /* + * mac80211 HT idx is always zero-idxed; we need to move + * HT OFDM rates after CCK rates in 2.4 GHz band + */ + if (il->band == IEEE80211_BAND_2GHZ) + mac_idx += IL_FIRST_OFDM_RATE; + } + /* Here we actually compare this rate to the latest LQ command */ + if (mac_idx < 0 || + tbl_type.is_SGI != !!(mac_flags & IEEE80211_TX_RC_SHORT_GI) || + tbl_type.is_ht40 != !!(mac_flags & IEEE80211_TX_RC_40_MHZ_WIDTH) || + tbl_type.is_dup != !!(mac_flags & IEEE80211_TX_RC_DUP_DATA) || + tbl_type.ant_type != info->antenna_sel_tx || + !!(tx_rate & RATE_MCS_HT_MSK) != !!(mac_flags & IEEE80211_TX_RC_MCS) || + !!(tx_rate & RATE_MCS_GF_MSK) != !!(mac_flags & IEEE80211_TX_RC_GREEN_FIELD) || + rs_idx != mac_idx) { + D_RATE( + "initial rate %d does not match %d (0x%x)\n", + mac_idx, rs_idx, tx_rate); + /* + * Since rates mis-match, the last LQ command may have failed. + * After IL_MISSED_RATE_MAX mis-matches, resync the uCode with + * ... driver. + */ + lq_sta->missed_rate_counter++; + if (lq_sta->missed_rate_counter > IL_MISSED_RATE_MAX) { + lq_sta->missed_rate_counter = 0; + il_send_lq_cmd(il, ctx, &lq_sta->lq, + CMD_ASYNC, false); + } + /* Regardless, ignore this status info for outdated rate */ + return; + } else + /* Rate did match, so reset the missed_rate_counter */ + lq_sta->missed_rate_counter = 0; + + /* Figure out if rate scale algorithm is in active or search table */ + if (il4965_table_type_matches(&tbl_type, + &(lq_sta->lq_info[lq_sta->active_tbl]))) { + curr_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); + other_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); + } else if (il4965_table_type_matches(&tbl_type, + &lq_sta->lq_info[1 - lq_sta->active_tbl])) { + curr_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); + other_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); + } else { + D_RATE( + "Neither active nor search matches tx rate\n"); + tmp_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); + D_RATE("active- lq:%x, ant:%x, SGI:%d\n", + tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); + tmp_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); + D_RATE("search- lq:%x, ant:%x, SGI:%d\n", + tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); + D_RATE("actual- lq:%x, ant:%x, SGI:%d\n", + tbl_type.lq_type, tbl_type.ant_type, tbl_type.is_SGI); + /* + * no matching table found, let's by-pass the data collection + * and continue to perform rate scale to find the rate table + */ + il4965_rs_stay_in_table(lq_sta, true); + goto done; + } + + /* + * Updating the frame history depends on whether packets were + * aggregated. + * + * For aggregation, all packets were transmitted at the same rate, the + * first idx into rate scale table. + */ + if (info->flags & IEEE80211_TX_STAT_AMPDU) { + tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); + il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, &tbl_type, + &rs_idx); + il4965_rs_collect_tx_data(curr_tbl, rs_idx, + info->status.ampdu_len, + info->status.ampdu_ack_len); + + /* Update success/fail counts if not searching for new mode */ + if (lq_sta->stay_in_tbl) { + lq_sta->total_success += info->status.ampdu_ack_len; + lq_sta->total_failed += (info->status.ampdu_len - + info->status.ampdu_ack_len); + } + } else { + /* + * For legacy, update frame history with for each Tx retry. + */ + retries = info->status.rates[0].count - 1; + /* HW doesn't send more than 15 retries */ + retries = min(retries, 15); + + /* The last transmission may have been successful */ + legacy_success = !!(info->flags & IEEE80211_TX_STAT_ACK); + /* Collect data for each rate used during failed TX attempts */ + for (i = 0; i <= retries; ++i) { + tx_rate = le32_to_cpu(table->rs_table[i].rate_n_flags); + il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, + &tbl_type, &rs_idx); + /* + * Only collect stats if retried rate is in the same RS + * table as active/search. + */ + if (il4965_table_type_matches(&tbl_type, curr_tbl)) + tmp_tbl = curr_tbl; + else if (il4965_table_type_matches(&tbl_type, + other_tbl)) + tmp_tbl = other_tbl; + else + continue; + il4965_rs_collect_tx_data(tmp_tbl, rs_idx, 1, + i < retries ? 0 : legacy_success); + } + + /* Update success/fail counts if not searching for new mode */ + if (lq_sta->stay_in_tbl) { + lq_sta->total_success += legacy_success; + lq_sta->total_failed += retries + (1 - legacy_success); + } + } + /* The last TX rate is cached in lq_sta; it's set in if/else above */ + lq_sta->last_rate_n_flags = tx_rate; +done: + /* See if there's a better rate or modulation mode to try. */ + if (sta && sta->supp_rates[sband->band]) + il4965_rs_rate_scale_perform(il, skb, sta, lq_sta); +} + +/* + * Begin a period of staying with a selected modulation mode. + * Set "stay_in_tbl" flag to prevent any mode switches. + * Set frame tx success limits according to legacy vs. high-throughput, + * and reset overall (spanning all rates) tx success history stats. + * These control how long we stay using same modulation mode before + * searching for a new mode. + */ +static void il4965_rs_set_stay_in_table(struct il_priv *il, u8 is_legacy, + struct il_lq_sta *lq_sta) +{ + D_RATE("we are staying in the same table\n"); + lq_sta->stay_in_tbl = 1; /* only place this gets set */ + if (is_legacy) { + lq_sta->table_count_limit = IL_LEGACY_TBL_COUNT; + lq_sta->max_failure_limit = IL_LEGACY_FAILURE_LIMIT; + lq_sta->max_success_limit = IL_LEGACY_SUCCESS_LIMIT; + } else { + lq_sta->table_count_limit = IL_NONE_LEGACY_TBL_COUNT; + lq_sta->max_failure_limit = IL_NONE_LEGACY_FAILURE_LIMIT; + lq_sta->max_success_limit = IL_NONE_LEGACY_SUCCESS_LIMIT; + } + lq_sta->table_count = 0; + lq_sta->total_failed = 0; + lq_sta->total_success = 0; + lq_sta->flush_timer = jiffies; + lq_sta->action_counter = 0; +} + +/* + * Find correct throughput table for given mode of modulation + */ +static void il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, + struct il_scale_tbl_info *tbl) +{ + /* Used to choose among HT tables */ + s32 (*ht_tbl_pointer)[RATE_COUNT]; + + /* Check for invalid LQ type */ + if (WARN_ON_ONCE(!is_legacy(tbl->lq_type) && !is_Ht(tbl->lq_type))) { + tbl->expected_tpt = expected_tpt_legacy; + return; + } + + /* Legacy rates have only one table */ + if (is_legacy(tbl->lq_type)) { + tbl->expected_tpt = expected_tpt_legacy; + return; + } + + /* Choose among many HT tables depending on number of streams + * (SISO/MIMO2), channel width (20/40), SGI, and aggregation + * status */ + if (is_siso(tbl->lq_type) && (!tbl->is_ht40 || lq_sta->is_dup)) + ht_tbl_pointer = expected_tpt_siso20MHz; + else if (is_siso(tbl->lq_type)) + ht_tbl_pointer = expected_tpt_siso40MHz; + else if (is_mimo2(tbl->lq_type) && (!tbl->is_ht40 || lq_sta->is_dup)) + ht_tbl_pointer = expected_tpt_mimo2_20MHz; + else /* if (is_mimo2(tbl->lq_type)) <-- must be true */ + ht_tbl_pointer = expected_tpt_mimo2_40MHz; + + if (!tbl->is_SGI && !lq_sta->is_agg) /* Normal */ + tbl->expected_tpt = ht_tbl_pointer[0]; + else if (tbl->is_SGI && !lq_sta->is_agg) /* SGI */ + tbl->expected_tpt = ht_tbl_pointer[1]; + else if (!tbl->is_SGI && lq_sta->is_agg) /* AGG */ + tbl->expected_tpt = ht_tbl_pointer[2]; + else /* AGG+SGI */ + tbl->expected_tpt = ht_tbl_pointer[3]; +} + +/* + * Find starting rate for new "search" high-throughput mode of modulation. + * Goal is to find lowest expected rate (under perfect conditions) that is + * above the current measured throughput of "active" mode, to give new mode + * a fair chance to prove itself without too many challenges. + * + * This gets called when transitioning to more aggressive modulation + * (i.e. legacy to SISO or MIMO, or SISO to MIMO), as well as less aggressive + * (i.e. MIMO to SISO). When moving to MIMO, bit rate will typically need + * to decrease to match "active" throughput. When moving from MIMO to SISO, + * bit rate will typically need to increase, but not if performance was bad. + */ +static s32 il4965_rs_get_best_rate(struct il_priv *il, + struct il_lq_sta *lq_sta, + struct il_scale_tbl_info *tbl, /* "search" */ + u16 rate_mask, s8 idx) +{ + /* "active" values */ + struct il_scale_tbl_info *active_tbl = + &(lq_sta->lq_info[lq_sta->active_tbl]); + s32 active_sr = active_tbl->win[idx].success_ratio; + s32 active_tpt = active_tbl->expected_tpt[idx]; + + /* expected "search" throughput */ + s32 *tpt_tbl = tbl->expected_tpt; + + s32 new_rate, high, low, start_hi; + u16 high_low; + s8 rate = idx; + + new_rate = high = low = start_hi = RATE_INVALID; + + for (; ;) { + high_low = il4965_rs_get_adjacent_rate(il, rate, rate_mask, + tbl->lq_type); + + low = high_low & 0xff; + high = (high_low >> 8) & 0xff; + + /* + * Lower the "search" bit rate, to give new "search" mode + * approximately the same throughput as "active" if: + * + * 1) "Active" mode has been working modestly well (but not + * great), and expected "search" throughput (under perfect + * conditions) at candidate rate is above the actual + * measured "active" throughput (but less than expected + * "active" throughput under perfect conditions). + * OR + * 2) "Active" mode has been working perfectly or very well + * and expected "search" throughput (under perfect + * conditions) at candidate rate is above expected + * "active" throughput (under perfect conditions). + */ + if ((100 * tpt_tbl[rate] > lq_sta->last_tpt && + (active_sr > RATE_DECREASE_TH && + active_sr <= RATE_HIGH_TH && + tpt_tbl[rate] <= active_tpt)) || + (active_sr >= RATE_SCALE_SWITCH && + tpt_tbl[rate] > active_tpt)) { + + /* (2nd or later pass) + * If we've already tried to raise the rate, and are + * now trying to lower it, use the higher rate. */ + if (start_hi != RATE_INVALID) { + new_rate = start_hi; + break; + } + + new_rate = rate; + + /* Loop again with lower rate */ + if (low != RATE_INVALID) + rate = low; + + /* Lower rate not available, use the original */ + else + break; + + /* Else try to raise the "search" rate to match "active" */ + } else { + /* (2nd or later pass) + * If we've already tried to lower the rate, and are + * now trying to raise it, use the lower rate. */ + if (new_rate != RATE_INVALID) + break; + + /* Loop again with higher rate */ + else if (high != RATE_INVALID) { + start_hi = high; + rate = high; + + /* Higher rate not available, use the original */ + } else { + new_rate = rate; + break; + } + } + } + + return new_rate; +} + +/* + * Set up search table for MIMO2 + */ +static int il4965_rs_switch_to_mimo2(struct il_priv *il, + struct il_lq_sta *lq_sta, + struct ieee80211_conf *conf, + struct ieee80211_sta *sta, + struct il_scale_tbl_info *tbl, int idx) +{ + u16 rate_mask; + s32 rate; + s8 is_green = lq_sta->is_green; + struct il_station_priv *sta_priv = (void *)sta->drv_priv; + struct il_rxon_context *ctx = sta_priv->common.ctx; + + if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) + return -1; + + if (((sta->ht_cap.cap & IEEE80211_HT_CAP_SM_PS) >> 2) + == WLAN_HT_CAP_SM_PS_STATIC) + return -1; + + /* Need both Tx chains/antennas to support MIMO */ + if (il->hw_params.tx_chains_num < 2) + return -1; + + D_RATE("LQ: try to switch to MIMO2\n"); + + tbl->lq_type = LQ_MIMO2; + tbl->is_dup = lq_sta->is_dup; + tbl->action = 0; + tbl->max_search = IL_MAX_SEARCH; + rate_mask = lq_sta->active_mimo2_rate; + + if (il_is_ht40_tx_allowed(il, ctx, &sta->ht_cap)) + tbl->is_ht40 = 1; + else + tbl->is_ht40 = 0; + + il4965_rs_set_expected_tpt_table(lq_sta, tbl); + + rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, idx); + + D_RATE("LQ: MIMO2 best rate %d mask %X\n", + rate, rate_mask); + if (rate == RATE_INVALID || !((1 << rate) & rate_mask)) { + D_RATE( + "Can't switch with idx %d rate mask %x\n", + rate, rate_mask); + return -1; + } + tbl->current_rate = il4965_rate_n_flags_from_tbl(il, + tbl, rate, is_green); + + D_RATE("LQ: Switch to new mcs %X idx is green %X\n", + tbl->current_rate, is_green); + return 0; +} + +/* + * Set up search table for SISO + */ +static int il4965_rs_switch_to_siso(struct il_priv *il, + struct il_lq_sta *lq_sta, + struct ieee80211_conf *conf, + struct ieee80211_sta *sta, + struct il_scale_tbl_info *tbl, int idx) +{ + u16 rate_mask; + u8 is_green = lq_sta->is_green; + s32 rate; + struct il_station_priv *sta_priv = (void *)sta->drv_priv; + struct il_rxon_context *ctx = sta_priv->common.ctx; + + if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) + return -1; + + D_RATE("LQ: try to switch to SISO\n"); + + tbl->is_dup = lq_sta->is_dup; + tbl->lq_type = LQ_SISO; + tbl->action = 0; + tbl->max_search = IL_MAX_SEARCH; + rate_mask = lq_sta->active_siso_rate; + + if (il_is_ht40_tx_allowed(il, ctx, &sta->ht_cap)) + tbl->is_ht40 = 1; + else + tbl->is_ht40 = 0; + + if (is_green) + tbl->is_SGI = 0; /*11n spec: no SGI in SISO+Greenfield*/ + + il4965_rs_set_expected_tpt_table(lq_sta, tbl); + rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, idx); + + D_RATE("LQ: get best rate %d mask %X\n", rate, rate_mask); + if (rate == RATE_INVALID || !((1 << rate) & rate_mask)) { + D_RATE( + "can not switch with idx %d rate mask %x\n", + rate, rate_mask); + return -1; + } + tbl->current_rate = il4965_rate_n_flags_from_tbl(il, + tbl, rate, is_green); + D_RATE("LQ: Switch to new mcs %X idx is green %X\n", + tbl->current_rate, is_green); + return 0; +} + +/* + * Try to switch to new modulation mode from legacy + */ +static int il4965_rs_move_legacy_other(struct il_priv *il, + struct il_lq_sta *lq_sta, + struct ieee80211_conf *conf, + struct ieee80211_sta *sta, + int idx) +{ + struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); + struct il_scale_tbl_info *search_tbl = + &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); + struct il_rate_scale_data *win = &(tbl->win[idx]); + u32 sz = (sizeof(struct il_scale_tbl_info) - + (sizeof(struct il_rate_scale_data) * RATE_COUNT)); + u8 start_action; + u8 valid_tx_ant = il->hw_params.valid_tx_ant; + u8 tx_chains_num = il->hw_params.tx_chains_num; + int ret = 0; + u8 update_search_tbl_counter = 0; + + tbl->action = IL_LEGACY_SWITCH_SISO; + + start_action = tbl->action; + for (; ;) { + lq_sta->action_counter++; + switch (tbl->action) { + case IL_LEGACY_SWITCH_ANTENNA1: + case IL_LEGACY_SWITCH_ANTENNA2: + D_RATE("LQ: Legacy toggle Antenna\n"); + + if ((tbl->action == IL_LEGACY_SWITCH_ANTENNA1 && + tx_chains_num <= 1) || + (tbl->action == IL_LEGACY_SWITCH_ANTENNA2 && + tx_chains_num <= 2)) + break; + + /* Don't change antenna if success has been great */ + if (win->success_ratio >= IL_RS_GOOD_RATIO) + break; + + /* Set up search table to try other antenna */ + memcpy(search_tbl, tbl, sz); + + if (il4965_rs_toggle_antenna(valid_tx_ant, + &search_tbl->current_rate, search_tbl)) { + update_search_tbl_counter = 1; + il4965_rs_set_expected_tpt_table(lq_sta, + search_tbl); + goto out; + } + break; + case IL_LEGACY_SWITCH_SISO: + D_RATE("LQ: Legacy switch to SISO\n"); + + /* Set up search table to try SISO */ + memcpy(search_tbl, tbl, sz); + search_tbl->is_SGI = 0; + ret = il4965_rs_switch_to_siso(il, lq_sta, conf, sta, + search_tbl, idx); + if (!ret) { + lq_sta->action_counter = 0; + goto out; + } + + break; + case IL_LEGACY_SWITCH_MIMO2_AB: + case IL_LEGACY_SWITCH_MIMO2_AC: + case IL_LEGACY_SWITCH_MIMO2_BC: + D_RATE("LQ: Legacy switch to MIMO2\n"); + + /* Set up search table to try MIMO */ + memcpy(search_tbl, tbl, sz); + search_tbl->is_SGI = 0; + + if (tbl->action == IL_LEGACY_SWITCH_MIMO2_AB) + search_tbl->ant_type = ANT_AB; + else if (tbl->action == IL_LEGACY_SWITCH_MIMO2_AC) + search_tbl->ant_type = ANT_AC; + else + search_tbl->ant_type = ANT_BC; + + if (!il4965_rs_is_valid_ant(valid_tx_ant, + search_tbl->ant_type)) + break; + + ret = il4965_rs_switch_to_mimo2(il, lq_sta, + conf, sta, + search_tbl, idx); + if (!ret) { + lq_sta->action_counter = 0; + goto out; + } + break; + } + tbl->action++; + if (tbl->action > IL_LEGACY_SWITCH_MIMO2_BC) + tbl->action = IL_LEGACY_SWITCH_ANTENNA1; + + if (tbl->action == start_action) + break; + + } + search_tbl->lq_type = LQ_NONE; + return 0; + +out: + lq_sta->search_better_tbl = 1; + tbl->action++; + if (tbl->action > IL_LEGACY_SWITCH_MIMO2_BC) + tbl->action = IL_LEGACY_SWITCH_ANTENNA1; + if (update_search_tbl_counter) + search_tbl->action = tbl->action; + return 0; + +} + +/* + * Try to switch to new modulation mode from SISO + */ +static int il4965_rs_move_siso_to_other(struct il_priv *il, + struct il_lq_sta *lq_sta, + struct ieee80211_conf *conf, + struct ieee80211_sta *sta, int idx) +{ + u8 is_green = lq_sta->is_green; + struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); + struct il_scale_tbl_info *search_tbl = + &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); + struct il_rate_scale_data *win = &(tbl->win[idx]); + struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; + u32 sz = (sizeof(struct il_scale_tbl_info) - + (sizeof(struct il_rate_scale_data) * RATE_COUNT)); + u8 start_action; + u8 valid_tx_ant = il->hw_params.valid_tx_ant; + u8 tx_chains_num = il->hw_params.tx_chains_num; + u8 update_search_tbl_counter = 0; + int ret; + + start_action = tbl->action; + + for (;;) { + lq_sta->action_counter++; + switch (tbl->action) { + case IL_SISO_SWITCH_ANTENNA1: + case IL_SISO_SWITCH_ANTENNA2: + D_RATE("LQ: SISO toggle Antenna\n"); + if ((tbl->action == IL_SISO_SWITCH_ANTENNA1 && + tx_chains_num <= 1) || + (tbl->action == IL_SISO_SWITCH_ANTENNA2 && + tx_chains_num <= 2)) + break; + + if (win->success_ratio >= IL_RS_GOOD_RATIO) + break; + + memcpy(search_tbl, tbl, sz); + if (il4965_rs_toggle_antenna(valid_tx_ant, + &search_tbl->current_rate, search_tbl)) { + update_search_tbl_counter = 1; + goto out; + } + break; + case IL_SISO_SWITCH_MIMO2_AB: + case IL_SISO_SWITCH_MIMO2_AC: + case IL_SISO_SWITCH_MIMO2_BC: + D_RATE("LQ: SISO switch to MIMO2\n"); + memcpy(search_tbl, tbl, sz); + search_tbl->is_SGI = 0; + + if (tbl->action == IL_SISO_SWITCH_MIMO2_AB) + search_tbl->ant_type = ANT_AB; + else if (tbl->action == IL_SISO_SWITCH_MIMO2_AC) + search_tbl->ant_type = ANT_AC; + else + search_tbl->ant_type = ANT_BC; + + if (!il4965_rs_is_valid_ant(valid_tx_ant, + search_tbl->ant_type)) + break; + + ret = il4965_rs_switch_to_mimo2(il, lq_sta, + conf, sta, + search_tbl, idx); + if (!ret) + goto out; + break; + case IL_SISO_SWITCH_GI: + if (!tbl->is_ht40 && !(ht_cap->cap & + IEEE80211_HT_CAP_SGI_20)) + break; + if (tbl->is_ht40 && !(ht_cap->cap & + IEEE80211_HT_CAP_SGI_40)) + break; + + D_RATE("LQ: SISO toggle SGI/NGI\n"); + + memcpy(search_tbl, tbl, sz); + if (is_green) { + if (!tbl->is_SGI) + break; + else + IL_ERR( + "SGI was set in GF+SISO\n"); + } + search_tbl->is_SGI = !tbl->is_SGI; + il4965_rs_set_expected_tpt_table(lq_sta, search_tbl); + if (tbl->is_SGI) { + s32 tpt = lq_sta->last_tpt / 100; + if (tpt >= search_tbl->expected_tpt[idx]) + break; + } + search_tbl->current_rate = + il4965_rate_n_flags_from_tbl(il, search_tbl, + idx, is_green); + update_search_tbl_counter = 1; + goto out; + } + tbl->action++; + if (tbl->action > IL_SISO_SWITCH_GI) + tbl->action = IL_SISO_SWITCH_ANTENNA1; + + if (tbl->action == start_action) + break; + } + search_tbl->lq_type = LQ_NONE; + return 0; + + out: + lq_sta->search_better_tbl = 1; + tbl->action++; + if (tbl->action > IL_SISO_SWITCH_GI) + tbl->action = IL_SISO_SWITCH_ANTENNA1; + if (update_search_tbl_counter) + search_tbl->action = tbl->action; + + return 0; +} + +/* + * Try to switch to new modulation mode from MIMO2 + */ +static int il4965_rs_move_mimo2_to_other(struct il_priv *il, + struct il_lq_sta *lq_sta, + struct ieee80211_conf *conf, + struct ieee80211_sta *sta, int idx) +{ + s8 is_green = lq_sta->is_green; + struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); + struct il_scale_tbl_info *search_tbl = + &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); + struct il_rate_scale_data *win = &(tbl->win[idx]); + struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; + u32 sz = (sizeof(struct il_scale_tbl_info) - + (sizeof(struct il_rate_scale_data) * RATE_COUNT)); + u8 start_action; + u8 valid_tx_ant = il->hw_params.valid_tx_ant; + u8 tx_chains_num = il->hw_params.tx_chains_num; + u8 update_search_tbl_counter = 0; + int ret; + + start_action = tbl->action; + for (;;) { + lq_sta->action_counter++; + switch (tbl->action) { + case IL_MIMO2_SWITCH_ANTENNA1: + case IL_MIMO2_SWITCH_ANTENNA2: + D_RATE("LQ: MIMO2 toggle Antennas\n"); + + if (tx_chains_num <= 2) + break; + + if (win->success_ratio >= IL_RS_GOOD_RATIO) + break; + + memcpy(search_tbl, tbl, sz); + if (il4965_rs_toggle_antenna(valid_tx_ant, + &search_tbl->current_rate, search_tbl)) { + update_search_tbl_counter = 1; + goto out; + } + break; + case IL_MIMO2_SWITCH_SISO_A: + case IL_MIMO2_SWITCH_SISO_B: + case IL_MIMO2_SWITCH_SISO_C: + D_RATE("LQ: MIMO2 switch to SISO\n"); + + /* Set up new search table for SISO */ + memcpy(search_tbl, tbl, sz); + + if (tbl->action == IL_MIMO2_SWITCH_SISO_A) + search_tbl->ant_type = ANT_A; + else if (tbl->action == IL_MIMO2_SWITCH_SISO_B) + search_tbl->ant_type = ANT_B; + else + search_tbl->ant_type = ANT_C; + + if (!il4965_rs_is_valid_ant(valid_tx_ant, + search_tbl->ant_type)) + break; + + ret = il4965_rs_switch_to_siso(il, lq_sta, + conf, sta, + search_tbl, idx); + if (!ret) + goto out; + + break; + + case IL_MIMO2_SWITCH_GI: + if (!tbl->is_ht40 && !(ht_cap->cap & + IEEE80211_HT_CAP_SGI_20)) + break; + if (tbl->is_ht40 && !(ht_cap->cap & + IEEE80211_HT_CAP_SGI_40)) + break; + + D_RATE("LQ: MIMO2 toggle SGI/NGI\n"); + + /* Set up new search table for MIMO2 */ + memcpy(search_tbl, tbl, sz); + search_tbl->is_SGI = !tbl->is_SGI; + il4965_rs_set_expected_tpt_table(lq_sta, search_tbl); + /* + * If active table already uses the fastest possible + * modulation (dual stream with short guard interval), + * and it's working well, there's no need to look + * for a better type of modulation! + */ + if (tbl->is_SGI) { + s32 tpt = lq_sta->last_tpt / 100; + if (tpt >= search_tbl->expected_tpt[idx]) + break; + } + search_tbl->current_rate = + il4965_rate_n_flags_from_tbl(il, search_tbl, + idx, is_green); + update_search_tbl_counter = 1; + goto out; + + } + tbl->action++; + if (tbl->action > IL_MIMO2_SWITCH_GI) + tbl->action = IL_MIMO2_SWITCH_ANTENNA1; + + if (tbl->action == start_action) + break; + } + search_tbl->lq_type = LQ_NONE; + return 0; + out: + lq_sta->search_better_tbl = 1; + tbl->action++; + if (tbl->action > IL_MIMO2_SWITCH_GI) + tbl->action = IL_MIMO2_SWITCH_ANTENNA1; + if (update_search_tbl_counter) + search_tbl->action = tbl->action; + + return 0; + +} + +/* + * Check whether we should continue using same modulation mode, or + * begin search for a new mode, based on: + * 1) # tx successes or failures while using this mode + * 2) # times calling this function + * 3) elapsed time in this mode (not used, for now) + */ +static void +il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) +{ + struct il_scale_tbl_info *tbl; + int i; + int active_tbl; + int flush_interval_passed = 0; + struct il_priv *il; + + il = lq_sta->drv; + active_tbl = lq_sta->active_tbl; + + tbl = &(lq_sta->lq_info[active_tbl]); + + /* If we've been disallowing search, see if we should now allow it */ + if (lq_sta->stay_in_tbl) { + + /* Elapsed time using current modulation mode */ + if (lq_sta->flush_timer) + flush_interval_passed = + time_after(jiffies, + (unsigned long)(lq_sta->flush_timer + + RATE_SCALE_FLUSH_INTVL)); + + /* + * Check if we should allow search for new modulation mode. + * If many frames have failed or succeeded, or we've used + * this same modulation for a long time, allow search, and + * reset history stats that keep track of whether we should + * allow a new search. Also (below) reset all bitmaps and + * stats in active history. + */ + if (force_search || + lq_sta->total_failed > lq_sta->max_failure_limit || + lq_sta->total_success > lq_sta->max_success_limit || + (!lq_sta->search_better_tbl && lq_sta->flush_timer && + flush_interval_passed)) { + D_RATE("LQ: stay is expired %d %d %d\n:", + lq_sta->total_failed, + lq_sta->total_success, + flush_interval_passed); + + /* Allow search for new mode */ + lq_sta->stay_in_tbl = 0; /* only place reset */ + lq_sta->total_failed = 0; + lq_sta->total_success = 0; + lq_sta->flush_timer = 0; + + /* + * Else if we've used this modulation mode enough repetitions + * (regardless of elapsed time or success/failure), reset + * history bitmaps and rate-specific stats for all rates in + * active table. + */ + } else { + lq_sta->table_count++; + if (lq_sta->table_count >= + lq_sta->table_count_limit) { + lq_sta->table_count = 0; + + D_RATE( + "LQ: stay in table clear win\n"); + for (i = 0; i < RATE_COUNT; i++) + il4965_rs_rate_scale_clear_win( + &(tbl->win[i])); + } + } + + /* If transitioning to allow "search", reset all history + * bitmaps and stats in active table (this will become the new + * "search" table). */ + if (!lq_sta->stay_in_tbl) { + for (i = 0; i < RATE_COUNT; i++) + il4965_rs_rate_scale_clear_win( + &(tbl->win[i])); + } + } +} + +/* + * setup rate table in uCode + * return rate_n_flags as used in the table + */ +static u32 il4965_rs_update_rate_tbl(struct il_priv *il, + struct il_rxon_context *ctx, + struct il_lq_sta *lq_sta, + struct il_scale_tbl_info *tbl, + int idx, u8 is_green) +{ + u32 rate; + + /* Update uCode's rate table. */ + rate = il4965_rate_n_flags_from_tbl(il, tbl, idx, is_green); + il4965_rs_fill_link_cmd(il, lq_sta, rate); + il_send_lq_cmd(il, ctx, &lq_sta->lq, CMD_ASYNC, false); + + return rate; +} + +/* + * Do rate scaling and search for new modulation mode. + */ +static void il4965_rs_rate_scale_perform(struct il_priv *il, + struct sk_buff *skb, + struct ieee80211_sta *sta, + struct il_lq_sta *lq_sta) +{ + struct ieee80211_hw *hw = il->hw; + struct ieee80211_conf *conf = &hw->conf; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + int low = RATE_INVALID; + int high = RATE_INVALID; + int idx; + int i; + struct il_rate_scale_data *win = NULL; + int current_tpt = IL_INVALID_VALUE; + int low_tpt = IL_INVALID_VALUE; + int high_tpt = IL_INVALID_VALUE; + u32 fail_count; + s8 scale_action = 0; + u16 rate_mask; + u8 update_lq = 0; + struct il_scale_tbl_info *tbl, *tbl1; + u16 rate_scale_idx_msk = 0; + u32 rate; + u8 is_green = 0; + u8 active_tbl = 0; + u8 done_search = 0; + u16 high_low; + s32 sr; + u8 tid = MAX_TID_COUNT; + struct il_tid_data *tid_data; + struct il_station_priv *sta_priv = (void *)sta->drv_priv; + struct il_rxon_context *ctx = sta_priv->common.ctx; + + D_RATE("rate scale calculate new rate for skb\n"); + + /* Send management frames and NO_ACK data using lowest rate. */ + /* TODO: this could probably be improved.. */ + if (!ieee80211_is_data(hdr->frame_control) || + (info->flags & IEEE80211_TX_CTL_NO_ACK)) + return; + + if (!sta || !lq_sta) + return; + + lq_sta->supp_rates = sta->supp_rates[lq_sta->band]; + + tid = il4965_rs_tl_add_packet(lq_sta, hdr); + if (tid != MAX_TID_COUNT && (lq_sta->tx_agg_tid_en & (1 << tid))) { + tid_data = &il->stations[lq_sta->lq.sta_id].tid[tid]; + if (tid_data->agg.state == IL_AGG_OFF) + lq_sta->is_agg = 0; + else + lq_sta->is_agg = 1; + } else + lq_sta->is_agg = 0; + + /* + * Select rate-scale / modulation-mode table to work with in + * the rest of this function: "search" if searching for better + * modulation mode, or "active" if doing rate scaling within a mode. + */ + if (!lq_sta->search_better_tbl) + active_tbl = lq_sta->active_tbl; + else + active_tbl = 1 - lq_sta->active_tbl; + + tbl = &(lq_sta->lq_info[active_tbl]); + if (is_legacy(tbl->lq_type)) + lq_sta->is_green = 0; + else + lq_sta->is_green = il4965_rs_use_green(sta); + is_green = lq_sta->is_green; + + /* current tx rate */ + idx = lq_sta->last_txrate_idx; + + D_RATE("Rate scale idx %d for type %d\n", idx, + tbl->lq_type); + + /* rates available for this association, and for modulation mode */ + rate_mask = il4965_rs_get_supported_rates(lq_sta, hdr, tbl->lq_type); + + D_RATE("mask 0x%04X\n", rate_mask); + + /* mask with station rate restriction */ + if (is_legacy(tbl->lq_type)) { + if (lq_sta->band == IEEE80211_BAND_5GHZ) + /* supp_rates has no CCK bits in A mode */ + rate_scale_idx_msk = (u16) (rate_mask & + (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); + else + rate_scale_idx_msk = (u16) (rate_mask & + lq_sta->supp_rates); + + } else + rate_scale_idx_msk = rate_mask; + + if (!rate_scale_idx_msk) + rate_scale_idx_msk = rate_mask; + + if (!((1 << idx) & rate_scale_idx_msk)) { + IL_ERR("Current Rate is not valid\n"); + if (lq_sta->search_better_tbl) { + /* revert to active table if search table is not valid*/ + tbl->lq_type = LQ_NONE; + lq_sta->search_better_tbl = 0; + tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); + /* get "active" rate info */ + idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); + rate = il4965_rs_update_rate_tbl(il, ctx, lq_sta, + tbl, idx, is_green); + } + return; + } + + /* Get expected throughput table and history win for current rate */ + if (!tbl->expected_tpt) { + IL_ERR("tbl->expected_tpt is NULL\n"); + return; + } + + /* force user max rate if set by user */ + if (lq_sta->max_rate_idx != -1 && + lq_sta->max_rate_idx < idx) { + idx = lq_sta->max_rate_idx; + update_lq = 1; + win = &(tbl->win[idx]); + goto lq_update; + } + + win = &(tbl->win[idx]); + + /* + * If there is not enough history to calculate actual average + * throughput, keep analyzing results of more tx frames, without + * changing rate or mode (bypass most of the rest of this function). + * Set up new rate table in uCode only if old rate is not supported + * in current association (use new rate found above). + */ + fail_count = win->counter - win->success_counter; + if (fail_count < RATE_MIN_FAILURE_TH && + win->success_counter < RATE_MIN_SUCCESS_TH) { + D_RATE("LQ: still below TH. succ=%d total=%d " + "for idx %d\n", + win->success_counter, win->counter, idx); + + /* Can't calculate this yet; not enough history */ + win->average_tpt = IL_INVALID_VALUE; + + /* Should we stay with this modulation mode, + * or search for a new one? */ + il4965_rs_stay_in_table(lq_sta, false); + + goto out; + } + /* Else we have enough samples; calculate estimate of + * actual average throughput */ + if (win->average_tpt != ((win->success_ratio * + tbl->expected_tpt[idx] + 64) / 128)) { + IL_ERR( + "expected_tpt should have been calculated by now\n"); + win->average_tpt = ((win->success_ratio * + tbl->expected_tpt[idx] + 64) / 128); + } + + /* If we are searching for better modulation mode, check success. */ + if (lq_sta->search_better_tbl) { + /* If good success, continue using the "search" mode; + * no need to send new link quality command, since we're + * continuing to use the setup that we've been trying. */ + if (win->average_tpt > lq_sta->last_tpt) { + + D_RATE("LQ: SWITCHING TO NEW TBL " + "suc=%d cur-tpt=%d old-tpt=%d\n", + win->success_ratio, + win->average_tpt, + lq_sta->last_tpt); + + if (!is_legacy(tbl->lq_type)) + lq_sta->enable_counter = 1; + + /* Swap tables; "search" becomes "active" */ + lq_sta->active_tbl = active_tbl; + current_tpt = win->average_tpt; + + /* Else poor success; go back to mode in "active" table */ + } else { + + D_RATE("LQ: GOING BACK TO THE OLD TBL " + "suc=%d cur-tpt=%d old-tpt=%d\n", + win->success_ratio, + win->average_tpt, + lq_sta->last_tpt); + + /* Nullify "search" table */ + tbl->lq_type = LQ_NONE; + + /* Revert to "active" table */ + active_tbl = lq_sta->active_tbl; + tbl = &(lq_sta->lq_info[active_tbl]); + + /* Revert to "active" rate and throughput info */ + idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); + current_tpt = lq_sta->last_tpt; + + /* Need to set up a new rate table in uCode */ + update_lq = 1; + } + + /* Either way, we've made a decision; modulation mode + * search is done, allow rate adjustment next time. */ + lq_sta->search_better_tbl = 0; + done_search = 1; /* Don't switch modes below! */ + goto lq_update; + } + + /* (Else) not in search of better modulation mode, try for better + * starting rate, while staying in this mode. */ + high_low = il4965_rs_get_adjacent_rate(il, idx, + rate_scale_idx_msk, + tbl->lq_type); + low = high_low & 0xff; + high = (high_low >> 8) & 0xff; + + /* If user set max rate, dont allow higher than user constrain */ + if (lq_sta->max_rate_idx != -1 && + lq_sta->max_rate_idx < high) + high = RATE_INVALID; + + sr = win->success_ratio; + + /* Collect measured throughputs for current and adjacent rates */ + current_tpt = win->average_tpt; + if (low != RATE_INVALID) + low_tpt = tbl->win[low].average_tpt; + if (high != RATE_INVALID) + high_tpt = tbl->win[high].average_tpt; + + scale_action = 0; + + /* Too many failures, decrease rate */ + if (sr <= RATE_DECREASE_TH || current_tpt == 0) { + D_RATE( + "decrease rate because of low success_ratio\n"); + scale_action = -1; + + /* No throughput measured yet for adjacent rates; try increase. */ + } else if (low_tpt == IL_INVALID_VALUE && + high_tpt == IL_INVALID_VALUE) { + + if (high != RATE_INVALID && sr >= RATE_INCREASE_TH) + scale_action = 1; + else if (low != RATE_INVALID) + scale_action = 0; + } + + /* Both adjacent throughputs are measured, but neither one has better + * throughput; we're using the best rate, don't change it! */ + else if (low_tpt != IL_INVALID_VALUE && high_tpt != IL_INVALID_VALUE && + low_tpt < current_tpt && high_tpt < current_tpt) + scale_action = 0; + + /* At least one adjacent rate's throughput is measured, + * and may have better performance. */ + else { + /* Higher adjacent rate's throughput is measured */ + if (high_tpt != IL_INVALID_VALUE) { + /* Higher rate has better throughput */ + if (high_tpt > current_tpt && + sr >= RATE_INCREASE_TH) { + scale_action = 1; + } else { + scale_action = 0; + } + + /* Lower adjacent rate's throughput is measured */ + } else if (low_tpt != IL_INVALID_VALUE) { + /* Lower rate has better throughput */ + if (low_tpt > current_tpt) { + D_RATE( + "decrease rate because of low tpt\n"); + scale_action = -1; + } else if (sr >= RATE_INCREASE_TH) { + scale_action = 1; + } + } + } + + /* Sanity check; asked for decrease, but success rate or throughput + * has been good at old rate. Don't change it. */ + if (scale_action == -1 && low != RATE_INVALID && + (sr > RATE_HIGH_TH || current_tpt > 100 * tbl->expected_tpt[low])) + scale_action = 0; + + switch (scale_action) { + case -1: + /* Decrease starting rate, update uCode's rate table */ + if (low != RATE_INVALID) { + update_lq = 1; + idx = low; + } + + break; + case 1: + /* Increase starting rate, update uCode's rate table */ + if (high != RATE_INVALID) { + update_lq = 1; + idx = high; + } + + break; + case 0: + /* No change */ + default: + break; + } + + D_RATE("choose rate scale idx %d action %d low %d " + "high %d type %d\n", + idx, scale_action, low, high, tbl->lq_type); + +lq_update: + /* Replace uCode's rate table for the destination station. */ + if (update_lq) + rate = il4965_rs_update_rate_tbl(il, ctx, lq_sta, + tbl, idx, is_green); + + /* Should we stay with this modulation mode, + * or search for a new one? */ + il4965_rs_stay_in_table(lq_sta, false); + + /* + * Search for new modulation mode if we're: + * 1) Not changing rates right now + * 2) Not just finishing up a search + * 3) Allowing a new search + */ + if (!update_lq && !done_search && !lq_sta->stay_in_tbl && + win->counter) { + /* Save current throughput to compare with "search" throughput*/ + lq_sta->last_tpt = current_tpt; + + /* Select a new "search" modulation mode to try. + * If one is found, set up the new "search" table. */ + if (is_legacy(tbl->lq_type)) + il4965_rs_move_legacy_other(il, lq_sta, + conf, sta, idx); + else if (is_siso(tbl->lq_type)) + il4965_rs_move_siso_to_other(il, lq_sta, + conf, sta, idx); + else /* (is_mimo2(tbl->lq_type)) */ + il4965_rs_move_mimo2_to_other(il, lq_sta, + conf, sta, idx); + + /* If new "search" mode was selected, set up in uCode table */ + if (lq_sta->search_better_tbl) { + /* Access the "search" table, clear its history. */ + tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); + for (i = 0; i < RATE_COUNT; i++) + il4965_rs_rate_scale_clear_win( + &(tbl->win[i])); + + /* Use new "search" start rate */ + idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); + + D_RATE( + "Switch current mcs: %X idx: %d\n", + tbl->current_rate, idx); + il4965_rs_fill_link_cmd(il, lq_sta, + tbl->current_rate); + il_send_lq_cmd(il, ctx, + &lq_sta->lq, CMD_ASYNC, false); + } else + done_search = 1; + } + + if (done_search && !lq_sta->stay_in_tbl) { + /* If the "active" (non-search) mode was legacy, + * and we've tried switching antennas, + * but we haven't been able to try HT modes (not available), + * stay with best antenna legacy modulation for a while + * before next round of mode comparisons. */ + tbl1 = &(lq_sta->lq_info[lq_sta->active_tbl]); + if (is_legacy(tbl1->lq_type) && !conf_is_ht(conf) && + lq_sta->action_counter > tbl1->max_search) { + D_RATE("LQ: STAY in legacy table\n"); + il4965_rs_set_stay_in_table(il, 1, lq_sta); + } + + /* If we're in an HT mode, and all 3 mode switch actions + * have been tried and compared, stay in this best modulation + * mode for a while before next round of mode comparisons. */ + if (lq_sta->enable_counter && + lq_sta->action_counter >= tbl1->max_search) { + if (lq_sta->last_tpt > IL_AGG_TPT_THREHOLD && + (lq_sta->tx_agg_tid_en & (1 << tid)) && + tid != MAX_TID_COUNT) { + tid_data = + &il->stations[lq_sta->lq.sta_id].tid[tid]; + if (tid_data->agg.state == IL_AGG_OFF) { + D_RATE( + "try to aggregate tid %d\n", + tid); + il4965_rs_tl_turn_on_agg(il, tid, + lq_sta, sta); + } + } + il4965_rs_set_stay_in_table(il, 0, lq_sta); + } + } + +out: + tbl->current_rate = il4965_rate_n_flags_from_tbl(il, tbl, + idx, is_green); + i = idx; + lq_sta->last_txrate_idx = i; +} + +/** + * il4965_rs_initialize_lq - Initialize a station's hardware rate table + * + * The uCode's station table contains a table of fallback rates + * for automatic fallback during transmission. + * + * NOTE: This sets up a default set of values. These will be replaced later + * if the driver's iwl-4965-rs rate scaling algorithm is used, instead of + * rc80211_simple. + * + * NOTE: Run REPLY_ADD_STA command to set up station table entry, before + * calling this function (which runs REPLY_TX_LINK_QUALITY_CMD, + * which requires station table entry to exist). + */ +static void il4965_rs_initialize_lq(struct il_priv *il, + struct ieee80211_conf *conf, + struct ieee80211_sta *sta, + struct il_lq_sta *lq_sta) +{ + struct il_scale_tbl_info *tbl; + int rate_idx; + int i; + u32 rate; + u8 use_green = il4965_rs_use_green(sta); + u8 active_tbl = 0; + u8 valid_tx_ant; + struct il_station_priv *sta_priv; + struct il_rxon_context *ctx; + + if (!sta || !lq_sta) + return; + + sta_priv = (void *)sta->drv_priv; + ctx = sta_priv->common.ctx; + + i = lq_sta->last_txrate_idx; + + valid_tx_ant = il->hw_params.valid_tx_ant; + + if (!lq_sta->search_better_tbl) + active_tbl = lq_sta->active_tbl; + else + active_tbl = 1 - lq_sta->active_tbl; + + tbl = &(lq_sta->lq_info[active_tbl]); + + if (i < 0 || i >= RATE_COUNT) + i = 0; + + rate = il_rates[i].plcp; + tbl->ant_type = il4965_first_antenna(valid_tx_ant); + rate |= tbl->ant_type << RATE_MCS_ANT_POS; + + if (i >= IL_FIRST_CCK_RATE && i <= IL_LAST_CCK_RATE) + rate |= RATE_MCS_CCK_MSK; + + il4965_rs_get_tbl_info_from_mcs(rate, il->band, tbl, &rate_idx); + if (!il4965_rs_is_valid_ant(valid_tx_ant, tbl->ant_type)) + il4965_rs_toggle_antenna(valid_tx_ant, &rate, tbl); + + rate = il4965_rate_n_flags_from_tbl(il, tbl, rate_idx, use_green); + tbl->current_rate = rate; + il4965_rs_set_expected_tpt_table(lq_sta, tbl); + il4965_rs_fill_link_cmd(NULL, lq_sta, rate); + il->stations[lq_sta->lq.sta_id].lq = &lq_sta->lq; + il_send_lq_cmd(il, ctx, &lq_sta->lq, CMD_SYNC, true); +} + +static void +il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, + struct ieee80211_tx_rate_control *txrc) +{ + + struct sk_buff *skb = txrc->skb; + struct ieee80211_supported_band *sband = txrc->sband; + struct il_priv *il __maybe_unused = (struct il_priv *)il_r; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + struct il_lq_sta *lq_sta = il_sta; + int rate_idx; + + D_RATE("rate scale calculate new rate for skb\n"); + + /* Get max rate if user set max rate */ + if (lq_sta) { + lq_sta->max_rate_idx = txrc->max_rate_idx; + if (sband->band == IEEE80211_BAND_5GHZ && + lq_sta->max_rate_idx != -1) + lq_sta->max_rate_idx += IL_FIRST_OFDM_RATE; + if (lq_sta->max_rate_idx < 0 || + lq_sta->max_rate_idx >= RATE_COUNT) + lq_sta->max_rate_idx = -1; + } + + /* Treat uninitialized rate scaling data same as non-existing. */ + if (lq_sta && !lq_sta->drv) { + D_RATE("Rate scaling not initialized yet.\n"); + il_sta = NULL; + } + + /* Send management frames and NO_ACK data using lowest rate. */ + if (rate_control_send_low(sta, il_sta, txrc)) + return; + + if (!lq_sta) + return; + + rate_idx = lq_sta->last_txrate_idx; + + if (lq_sta->last_rate_n_flags & RATE_MCS_HT_MSK) { + rate_idx -= IL_FIRST_OFDM_RATE; + /* 6M and 9M shared same MCS idx */ + rate_idx = (rate_idx > 0) ? (rate_idx - 1) : 0; + if (il4965_rs_extract_rate(lq_sta->last_rate_n_flags) >= + RATE_MIMO2_6M_PLCP) + rate_idx = rate_idx + MCS_IDX_PER_STREAM; + info->control.rates[0].flags = IEEE80211_TX_RC_MCS; + if (lq_sta->last_rate_n_flags & RATE_MCS_SGI_MSK) + info->control.rates[0].flags |= + IEEE80211_TX_RC_SHORT_GI; + if (lq_sta->last_rate_n_flags & RATE_MCS_DUP_MSK) + info->control.rates[0].flags |= + IEEE80211_TX_RC_DUP_DATA; + if (lq_sta->last_rate_n_flags & RATE_MCS_HT40_MSK) + info->control.rates[0].flags |= + IEEE80211_TX_RC_40_MHZ_WIDTH; + if (lq_sta->last_rate_n_flags & RATE_MCS_GF_MSK) + info->control.rates[0].flags |= + IEEE80211_TX_RC_GREEN_FIELD; + } else { + /* Check for invalid rates */ + if (rate_idx < 0 || rate_idx >= RATE_COUNT_LEGACY || + (sband->band == IEEE80211_BAND_5GHZ && + rate_idx < IL_FIRST_OFDM_RATE)) + rate_idx = rate_lowest_index(sband, sta); + /* On valid 5 GHz rate, adjust idx */ + else if (sband->band == IEEE80211_BAND_5GHZ) + rate_idx -= IL_FIRST_OFDM_RATE; + info->control.rates[0].flags = 0; + } + info->control.rates[0].idx = rate_idx; + +} + +static void *il4965_rs_alloc_sta(void *il_rate, struct ieee80211_sta *sta, + gfp_t gfp) +{ + struct il_lq_sta *lq_sta; + struct il_station_priv *sta_priv = + (struct il_station_priv *) sta->drv_priv; + struct il_priv *il; + + il = (struct il_priv *)il_rate; + D_RATE("create station rate scale win\n"); + + lq_sta = &sta_priv->lq_sta; + + return lq_sta; +} + +/* + * Called after adding a new station to initialize rate scaling + */ +void +il4965_rs_rate_init(struct il_priv *il, + struct ieee80211_sta *sta, + u8 sta_id) +{ + int i, j; + struct ieee80211_hw *hw = il->hw; + struct ieee80211_conf *conf = &il->hw->conf; + struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; + struct il_station_priv *sta_priv; + struct il_lq_sta *lq_sta; + struct ieee80211_supported_band *sband; + + sta_priv = (struct il_station_priv *) sta->drv_priv; + lq_sta = &sta_priv->lq_sta; + sband = hw->wiphy->bands[conf->channel->band]; + + + lq_sta->lq.sta_id = sta_id; + + for (j = 0; j < LQ_SIZE; j++) + for (i = 0; i < RATE_COUNT; i++) + il4965_rs_rate_scale_clear_win( + &lq_sta->lq_info[j].win[i]); + + lq_sta->flush_timer = 0; + lq_sta->supp_rates = sta->supp_rates[sband->band]; + for (j = 0; j < LQ_SIZE; j++) + for (i = 0; i < RATE_COUNT; i++) + il4965_rs_rate_scale_clear_win( + &lq_sta->lq_info[j].win[i]); + + D_RATE("LQ:" + "*** rate scale station global init for station %d ***\n", + sta_id); + /* TODO: what is a good starting rate for STA? About middle? Maybe not + * the lowest or the highest rate.. Could consider using RSSI from + * previous packets? Need to have IEEE 802.1X auth succeed immediately + * after assoc.. */ + + lq_sta->is_dup = 0; + lq_sta->max_rate_idx = -1; + lq_sta->missed_rate_counter = IL_MISSED_RATE_MAX; + lq_sta->is_green = il4965_rs_use_green(sta); + lq_sta->active_legacy_rate = il->active_rate & ~(0x1000); + lq_sta->band = il->band; + /* + * active_siso_rate mask includes 9 MBits (bit 5), and CCK (bits 0-3), + * supp_rates[] does not; shift to convert format, force 9 MBits off. + */ + lq_sta->active_siso_rate = ht_cap->mcs.rx_mask[0] << 1; + lq_sta->active_siso_rate |= ht_cap->mcs.rx_mask[0] & 0x1; + lq_sta->active_siso_rate &= ~((u16)0x2); + lq_sta->active_siso_rate <<= IL_FIRST_OFDM_RATE; + + /* Same here */ + lq_sta->active_mimo2_rate = ht_cap->mcs.rx_mask[1] << 1; + lq_sta->active_mimo2_rate |= ht_cap->mcs.rx_mask[1] & 0x1; + lq_sta->active_mimo2_rate &= ~((u16)0x2); + lq_sta->active_mimo2_rate <<= IL_FIRST_OFDM_RATE; + + /* These values will be overridden later */ + lq_sta->lq.general_params.single_stream_ant_msk = + il4965_first_antenna(il->hw_params.valid_tx_ant); + lq_sta->lq.general_params.dual_stream_ant_msk = + il->hw_params.valid_tx_ant & + ~il4965_first_antenna(il->hw_params.valid_tx_ant); + if (!lq_sta->lq.general_params.dual_stream_ant_msk) { + lq_sta->lq.general_params.dual_stream_ant_msk = ANT_AB; + } else if (il4965_num_of_ant(il->hw_params.valid_tx_ant) == 2) { + lq_sta->lq.general_params.dual_stream_ant_msk = + il->hw_params.valid_tx_ant; + } + + /* as default allow aggregation for all tids */ + lq_sta->tx_agg_tid_en = IL_AGG_ALL_TID; + lq_sta->drv = il; + + /* Set last_txrate_idx to lowest rate */ + lq_sta->last_txrate_idx = rate_lowest_index(sband, sta); + if (sband->band == IEEE80211_BAND_5GHZ) + lq_sta->last_txrate_idx += IL_FIRST_OFDM_RATE; + lq_sta->is_agg = 0; + +#ifdef CONFIG_MAC80211_DEBUGFS + lq_sta->dbg_fixed_rate = 0; +#endif + + il4965_rs_initialize_lq(il, conf, sta, lq_sta); +} + +static void il4965_rs_fill_link_cmd(struct il_priv *il, + struct il_lq_sta *lq_sta, u32 new_rate) +{ + struct il_scale_tbl_info tbl_type; + int idx = 0; + int rate_idx; + int repeat_rate = 0; + u8 ant_toggle_cnt = 0; + u8 use_ht_possible = 1; + u8 valid_tx_ant = 0; + struct il_link_quality_cmd *lq_cmd = &lq_sta->lq; + + /* Override starting rate (idx 0) if needed for debug purposes */ + il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, idx); + + /* Interpret new_rate (rate_n_flags) */ + il4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, + &tbl_type, &rate_idx); + + /* How many times should we repeat the initial rate? */ + if (is_legacy(tbl_type.lq_type)) { + ant_toggle_cnt = 1; + repeat_rate = IL_NUMBER_TRY; + } else { + repeat_rate = IL_HT_NUMBER_TRY; + } + + lq_cmd->general_params.mimo_delimiter = + is_mimo(tbl_type.lq_type) ? 1 : 0; + + /* Fill 1st table entry (idx 0) */ + lq_cmd->rs_table[idx].rate_n_flags = cpu_to_le32(new_rate); + + if (il4965_num_of_ant(tbl_type.ant_type) == 1) { + lq_cmd->general_params.single_stream_ant_msk = + tbl_type.ant_type; + } else if (il4965_num_of_ant(tbl_type.ant_type) == 2) { + lq_cmd->general_params.dual_stream_ant_msk = + tbl_type.ant_type; + } /* otherwise we don't modify the existing value */ + + idx++; + repeat_rate--; + if (il) + valid_tx_ant = il->hw_params.valid_tx_ant; + + /* Fill rest of rate table */ + while (idx < LINK_QUAL_MAX_RETRY_NUM) { + /* Repeat initial/next rate. + * For legacy IL_NUMBER_TRY == 1, this loop will not execute. + * For HT IL_HT_NUMBER_TRY == 3, this executes twice. */ + while (repeat_rate > 0 && idx < LINK_QUAL_MAX_RETRY_NUM) { + if (is_legacy(tbl_type.lq_type)) { + if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE) + ant_toggle_cnt++; + else if (il && + il4965_rs_toggle_antenna(valid_tx_ant, + &new_rate, &tbl_type)) + ant_toggle_cnt = 1; + } + + /* Override next rate if needed for debug purposes */ + il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, idx); + + /* Fill next table entry */ + lq_cmd->rs_table[idx].rate_n_flags = + cpu_to_le32(new_rate); + repeat_rate--; + idx++; + } + + il4965_rs_get_tbl_info_from_mcs(new_rate, + lq_sta->band, &tbl_type, + &rate_idx); + + /* Indicate to uCode which entries might be MIMO. + * If initial rate was MIMO, this will finally end up + * as (IL_HT_NUMBER_TRY * 2), after 2nd pass, otherwise 0. */ + if (is_mimo(tbl_type.lq_type)) + lq_cmd->general_params.mimo_delimiter = idx; + + /* Get next rate */ + new_rate = il4965_rs_get_lower_rate(lq_sta, + &tbl_type, rate_idx, + use_ht_possible); + + /* How many times should we repeat the next rate? */ + if (is_legacy(tbl_type.lq_type)) { + if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE) + ant_toggle_cnt++; + else if (il && + il4965_rs_toggle_antenna(valid_tx_ant, + &new_rate, &tbl_type)) + ant_toggle_cnt = 1; + + repeat_rate = IL_NUMBER_TRY; + } else { + repeat_rate = IL_HT_NUMBER_TRY; + } + + /* Don't allow HT rates after next pass. + * il4965_rs_get_lower_rate() will change type to LQ_A or LQ_G. */ + use_ht_possible = 0; + + /* Override next rate if needed for debug purposes */ + il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, idx); + + /* Fill next table entry */ + lq_cmd->rs_table[idx].rate_n_flags = cpu_to_le32(new_rate); + + idx++; + repeat_rate--; + } + + lq_cmd->agg_params.agg_frame_cnt_limit = LINK_QUAL_AGG_FRAME_LIMIT_DEF; + lq_cmd->agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF; + + lq_cmd->agg_params.agg_time_limit = + cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF); +} + +static void +*il4965_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) +{ + return hw->priv; +} +/* rate scale requires free function to be implemented */ +static void il4965_rs_free(void *il_rate) +{ + return; +} + +static void il4965_rs_free_sta(void *il_r, struct ieee80211_sta *sta, + void *il_sta) +{ + struct il_priv *il __maybe_unused = il_r; + + D_RATE("enter\n"); + D_RATE("leave\n"); +} + + +#ifdef CONFIG_MAC80211_DEBUGFS +static int il4965_open_file_generic(struct inode *inode, struct file *file) +{ + file->private_data = inode->i_private; + return 0; +} +static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, + u32 *rate_n_flags, int idx) +{ + struct il_priv *il; + u8 valid_tx_ant; + u8 ant_sel_tx; + + il = lq_sta->drv; + valid_tx_ant = il->hw_params.valid_tx_ant; + if (lq_sta->dbg_fixed_rate) { + ant_sel_tx = + ((lq_sta->dbg_fixed_rate & RATE_MCS_ANT_ABC_MSK) + >> RATE_MCS_ANT_POS); + if ((valid_tx_ant & ant_sel_tx) == ant_sel_tx) { + *rate_n_flags = lq_sta->dbg_fixed_rate; + D_RATE("Fixed rate ON\n"); + } else { + lq_sta->dbg_fixed_rate = 0; + IL_ERR( + "Invalid antenna selection 0x%X, Valid is 0x%X\n", + ant_sel_tx, valid_tx_ant); + D_RATE("Fixed rate OFF\n"); + } + } else { + D_RATE("Fixed rate OFF\n"); + } +} + +static ssize_t il4965_rs_sta_dbgfs_scale_table_write(struct file *file, + const char __user *user_buf, size_t count, loff_t *ppos) +{ + struct il_lq_sta *lq_sta = file->private_data; + struct il_priv *il; + char buf[64]; + size_t buf_size; + u32 parsed_rate; + struct il_station_priv *sta_priv = + container_of(lq_sta, struct il_station_priv, lq_sta); + struct il_rxon_context *ctx = sta_priv->common.ctx; + + il = lq_sta->drv; + memset(buf, 0, sizeof(buf)); + buf_size = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + + if (sscanf(buf, "%x", &parsed_rate) == 1) + lq_sta->dbg_fixed_rate = parsed_rate; + else + lq_sta->dbg_fixed_rate = 0; + + lq_sta->active_legacy_rate = 0x0FFF; /* 1 - 54 MBits, includes CCK */ + lq_sta->active_siso_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ + lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ + + D_RATE("sta_id %d rate 0x%X\n", + lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate); + + if (lq_sta->dbg_fixed_rate) { + il4965_rs_fill_link_cmd(NULL, lq_sta, lq_sta->dbg_fixed_rate); + il_send_lq_cmd(lq_sta->drv, ctx, &lq_sta->lq, CMD_ASYNC, + false); + } + + return count; +} + +static ssize_t il4965_rs_sta_dbgfs_scale_table_read(struct file *file, + char __user *user_buf, size_t count, loff_t *ppos) +{ + char *buff; + int desc = 0; + int i = 0; + int idx = 0; + ssize_t ret; + + struct il_lq_sta *lq_sta = file->private_data; + struct il_priv *il; + struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); + + il = lq_sta->drv; + buff = kmalloc(1024, GFP_KERNEL); + if (!buff) + return -ENOMEM; + + desc += sprintf(buff+desc, "sta_id %d\n", lq_sta->lq.sta_id); + desc += sprintf(buff+desc, "failed=%d success=%d rate=0%X\n", + lq_sta->total_failed, lq_sta->total_success, + lq_sta->active_legacy_rate); + desc += sprintf(buff+desc, "fixed rate 0x%X\n", + lq_sta->dbg_fixed_rate); + desc += sprintf(buff+desc, "valid_tx_ant %s%s%s\n", + (il->hw_params.valid_tx_ant & ANT_A) ? "ANT_A," : "", + (il->hw_params.valid_tx_ant & ANT_B) ? "ANT_B," : "", + (il->hw_params.valid_tx_ant & ANT_C) ? "ANT_C" : ""); + desc += sprintf(buff+desc, "lq type %s\n", + (is_legacy(tbl->lq_type)) ? "legacy" : "HT"); + if (is_Ht(tbl->lq_type)) { + desc += sprintf(buff+desc, " %s", + (is_siso(tbl->lq_type)) ? "SISO" : "MIMO2"); + desc += sprintf(buff+desc, " %s", + (tbl->is_ht40) ? "40MHz" : "20MHz"); + desc += sprintf(buff+desc, " %s %s %s\n", + (tbl->is_SGI) ? "SGI" : "", + (lq_sta->is_green) ? "GF enabled" : "", + (lq_sta->is_agg) ? "AGG on" : ""); + } + desc += sprintf(buff+desc, "last tx rate=0x%X\n", + lq_sta->last_rate_n_flags); + desc += sprintf(buff+desc, "general:" + "flags=0x%X mimo-d=%d s-ant0x%x d-ant=0x%x\n", + lq_sta->lq.general_params.flags, + lq_sta->lq.general_params.mimo_delimiter, + lq_sta->lq.general_params.single_stream_ant_msk, + lq_sta->lq.general_params.dual_stream_ant_msk); + + desc += sprintf(buff+desc, "agg:" + "time_limit=%d dist_start_th=%d frame_cnt_limit=%d\n", + le16_to_cpu(lq_sta->lq.agg_params.agg_time_limit), + lq_sta->lq.agg_params.agg_dis_start_th, + lq_sta->lq.agg_params.agg_frame_cnt_limit); + + desc += sprintf(buff+desc, + "Start idx [0]=0x%x [1]=0x%x [2]=0x%x [3]=0x%x\n", + lq_sta->lq.general_params.start_rate_idx[0], + lq_sta->lq.general_params.start_rate_idx[1], + lq_sta->lq.general_params.start_rate_idx[2], + lq_sta->lq.general_params.start_rate_idx[3]); + + for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { + idx = il4965_hwrate_to_plcp_idx( + le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags)); + if (is_legacy(tbl->lq_type)) { + desc += sprintf(buff+desc, " rate[%d] 0x%X %smbps\n", + i, + le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags), + il_rate_mcs[idx].mbps); + } else { + desc += sprintf(buff+desc, + " rate[%d] 0x%X %smbps (%s)\n", + i, + le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags), + il_rate_mcs[idx].mbps, il_rate_mcs[idx].mcs); + } + } + + ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); + kfree(buff); + return ret; +} + +static const struct file_operations rs_sta_dbgfs_scale_table_ops = { + .write = il4965_rs_sta_dbgfs_scale_table_write, + .read = il4965_rs_sta_dbgfs_scale_table_read, + .open = il4965_open_file_generic, + .llseek = default_llseek, +}; +static ssize_t il4965_rs_sta_dbgfs_stats_table_read(struct file *file, + char __user *user_buf, size_t count, loff_t *ppos) +{ + char *buff; + int desc = 0; + int i, j; + ssize_t ret; + + struct il_lq_sta *lq_sta = file->private_data; + + buff = kmalloc(1024, GFP_KERNEL); + if (!buff) + return -ENOMEM; + + for (i = 0; i < LQ_SIZE; i++) { + desc += sprintf(buff+desc, + "%s type=%d SGI=%d HT40=%d DUP=%d GF=%d\n" + "rate=0x%X\n", + lq_sta->active_tbl == i ? "*" : "x", + lq_sta->lq_info[i].lq_type, + lq_sta->lq_info[i].is_SGI, + lq_sta->lq_info[i].is_ht40, + lq_sta->lq_info[i].is_dup, + lq_sta->is_green, + lq_sta->lq_info[i].current_rate); + for (j = 0; j < RATE_COUNT; j++) { + desc += sprintf(buff+desc, + "counter=%d success=%d %%=%d\n", + lq_sta->lq_info[i].win[j].counter, + lq_sta->lq_info[i].win[j].success_counter, + lq_sta->lq_info[i].win[j].success_ratio); + } + } + ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); + kfree(buff); + return ret; +} + +static const struct file_operations rs_sta_dbgfs_stats_table_ops = { + .read = il4965_rs_sta_dbgfs_stats_table_read, + .open = il4965_open_file_generic, + .llseek = default_llseek, +}; + +static ssize_t il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, + char __user *user_buf, size_t count, loff_t *ppos) +{ + char buff[120]; + int desc = 0; + ssize_t ret; + + struct il_lq_sta *lq_sta = file->private_data; + struct il_priv *il; + struct il_scale_tbl_info *tbl = &lq_sta->lq_info[lq_sta->active_tbl]; + + il = lq_sta->drv; + + if (is_Ht(tbl->lq_type)) + desc += sprintf(buff+desc, + "Bit Rate= %d Mb/s\n", + tbl->expected_tpt[lq_sta->last_txrate_idx]); + else + desc += sprintf(buff+desc, + "Bit Rate= %d Mb/s\n", + il_rates[lq_sta->last_txrate_idx].ieee >> 1); + + ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); + return ret; +} + +static const struct file_operations rs_sta_dbgfs_rate_scale_data_ops = { + .read = il4965_rs_sta_dbgfs_rate_scale_data_read, + .open = il4965_open_file_generic, + .llseek = default_llseek, +}; + +static void il4965_rs_add_debugfs(void *il, void *il_sta, + struct dentry *dir) +{ + struct il_lq_sta *lq_sta = il_sta; + lq_sta->rs_sta_dbgfs_scale_table_file = + debugfs_create_file("rate_scale_table", S_IRUSR | S_IWUSR, dir, + lq_sta, &rs_sta_dbgfs_scale_table_ops); + lq_sta->rs_sta_dbgfs_stats_table_file = + debugfs_create_file("rate_stats_table", S_IRUSR, dir, + lq_sta, &rs_sta_dbgfs_stats_table_ops); + lq_sta->rs_sta_dbgfs_rate_scale_data_file = + debugfs_create_file("rate_scale_data", S_IRUSR, dir, + lq_sta, &rs_sta_dbgfs_rate_scale_data_ops); + lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file = + debugfs_create_u8("tx_agg_tid_enable", S_IRUSR | S_IWUSR, dir, + &lq_sta->tx_agg_tid_en); + +} + +static void il4965_rs_remove_debugfs(void *il, void *il_sta) +{ + struct il_lq_sta *lq_sta = il_sta; + debugfs_remove(lq_sta->rs_sta_dbgfs_scale_table_file); + debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file); + debugfs_remove(lq_sta->rs_sta_dbgfs_rate_scale_data_file); + debugfs_remove(lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file); +} +#endif + +/* + * Initialization of rate scaling information is done by driver after + * the station is added. Since mac80211 calls this function before a + * station is added we ignore it. + */ +static void +il4965_rs_rate_init_stub(void *il_r, struct ieee80211_supported_band *sband, + struct ieee80211_sta *sta, void *il_sta) +{ +} +static struct rate_control_ops rs_4965_ops = { + .module = NULL, + .name = IL4965_RS_NAME, + .tx_status = il4965_rs_tx_status, + .get_rate = il4965_rs_get_rate, + .rate_init = il4965_rs_rate_init_stub, + .alloc = il4965_rs_alloc, + .free = il4965_rs_free, + .alloc_sta = il4965_rs_alloc_sta, + .free_sta = il4965_rs_free_sta, +#ifdef CONFIG_MAC80211_DEBUGFS + .add_sta_debugfs = il4965_rs_add_debugfs, + .remove_sta_debugfs = il4965_rs_remove_debugfs, +#endif +}; + +int il4965_rate_control_register(void) +{ + return ieee80211_rate_control_register(&rs_4965_ops); +} + +void il4965_rate_control_unregister(void) +{ + ieee80211_rate_control_unregister(&rs_4965_ops); +} diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index d0f9f23feea9..b0ffa98d179d 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -8,9 +8,8 @@ iwl-legacy-objs += $(iwl-legacy-m) # 4965 obj-$(CONFIG_IWL4965) += iwl4965.o -iwl4965-objs := 4965.o 4965-mac.o iwl-4965-rs.o -iwl4965-objs += iwl-4965-calib.o -iwl4965-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-4965-debugfs.o +iwl4965-objs := 4965.o 4965-mac.o 4965-rs.o 4965-calib.o +iwl4965-$(CONFIG_IWLEGACY_DEBUGFS) += 4965-debug.o # 3945 obj-$(CONFIG_IWL3945) += iwl3945.o diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c deleted file mode 100644 index 1d873a68830e..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c +++ /dev/null @@ -1,966 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#include -#include - -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-4965-calib.h" - -/***************************************************************************** - * INIT calibrations framework - *****************************************************************************/ - -struct stats_general_data { - u32 beacon_silence_rssi_a; - u32 beacon_silence_rssi_b; - u32 beacon_silence_rssi_c; - u32 beacon_energy_a; - u32 beacon_energy_b; - u32 beacon_energy_c; -}; - -void il4965_calib_free_results(struct il_priv *il) -{ - int i; - - for (i = 0; i < IL_CALIB_MAX; i++) { - kfree(il->calib_results[i].buf); - il->calib_results[i].buf = NULL; - il->calib_results[i].buf_len = 0; - } -} - -/***************************************************************************** - * RUNTIME calibrations framework - *****************************************************************************/ - -/* "false alarms" are signals that our DSP tries to lock onto, - * but then determines that they are either noise, or transmissions - * from a distant wireless network (also "noise", really) that get - * "stepped on" by stronger transmissions within our own network. - * This algorithm attempts to set a sensitivity level that is high - * enough to receive all of our own network traffic, but not so - * high that our DSP gets too busy trying to lock onto non-network - * activity/noise. */ -static int il4965_sens_energy_cck(struct il_priv *il, - u32 norm_fa, - u32 rx_enable_time, - struct stats_general_data *rx_info) -{ - u32 max_nrg_cck = 0; - int i = 0; - u8 max_silence_rssi = 0; - u32 silence_ref = 0; - u8 silence_rssi_a = 0; - u8 silence_rssi_b = 0; - u8 silence_rssi_c = 0; - u32 val; - - /* "false_alarms" values below are cross-multiplications to assess the - * numbers of false alarms within the measured period of actual Rx - * (Rx is off when we're txing), vs the min/max expected false alarms - * (some should be expected if rx is sensitive enough) in a - * hypothetical listening period of 200 time units (TU), 204.8 msec: - * - * MIN_FA/fixed-time < false_alarms/actual-rx-time < MAX_FA/beacon-time - * - * */ - u32 false_alarms = norm_fa * 200 * 1024; - u32 max_false_alarms = MAX_FA_CCK * rx_enable_time; - u32 min_false_alarms = MIN_FA_CCK * rx_enable_time; - struct il_sensitivity_data *data = NULL; - const struct il_sensitivity_ranges *ranges = il->hw_params.sens; - - data = &(il->sensitivity_data); - - data->nrg_auto_corr_silence_diff = 0; - - /* Find max silence rssi among all 3 receivers. - * This is background noise, which may include transmissions from other - * networks, measured during silence before our network's beacon */ - silence_rssi_a = (u8)((rx_info->beacon_silence_rssi_a & - ALL_BAND_FILTER) >> 8); - silence_rssi_b = (u8)((rx_info->beacon_silence_rssi_b & - ALL_BAND_FILTER) >> 8); - silence_rssi_c = (u8)((rx_info->beacon_silence_rssi_c & - ALL_BAND_FILTER) >> 8); - - val = max(silence_rssi_b, silence_rssi_c); - max_silence_rssi = max(silence_rssi_a, (u8) val); - - /* Store silence rssi in 20-beacon history table */ - data->nrg_silence_rssi[data->nrg_silence_idx] = max_silence_rssi; - data->nrg_silence_idx++; - if (data->nrg_silence_idx >= NRG_NUM_PREV_STAT_L) - data->nrg_silence_idx = 0; - - /* Find max silence rssi across 20 beacon history */ - for (i = 0; i < NRG_NUM_PREV_STAT_L; i++) { - val = data->nrg_silence_rssi[i]; - silence_ref = max(silence_ref, val); - } - D_CALIB("silence a %u, b %u, c %u, 20-bcn max %u\n", - silence_rssi_a, silence_rssi_b, silence_rssi_c, - silence_ref); - - /* Find max rx energy (min value!) among all 3 receivers, - * measured during beacon frame. - * Save it in 10-beacon history table. */ - i = data->nrg_energy_idx; - val = min(rx_info->beacon_energy_b, rx_info->beacon_energy_c); - data->nrg_value[i] = min(rx_info->beacon_energy_a, val); - - data->nrg_energy_idx++; - if (data->nrg_energy_idx >= 10) - data->nrg_energy_idx = 0; - - /* Find min rx energy (max value) across 10 beacon history. - * This is the minimum signal level that we want to receive well. - * Add backoff (margin so we don't miss slightly lower energy frames). - * This establishes an upper bound (min value) for energy threshold. */ - max_nrg_cck = data->nrg_value[0]; - for (i = 1; i < 10; i++) - max_nrg_cck = (u32) max(max_nrg_cck, (data->nrg_value[i])); - max_nrg_cck += 6; - - D_CALIB("rx energy a %u, b %u, c %u, 10-bcn max/min %u\n", - rx_info->beacon_energy_a, rx_info->beacon_energy_b, - rx_info->beacon_energy_c, max_nrg_cck - 6); - - /* Count number of consecutive beacons with fewer-than-desired - * false alarms. */ - if (false_alarms < min_false_alarms) - data->num_in_cck_no_fa++; - else - data->num_in_cck_no_fa = 0; - D_CALIB("consecutive bcns with few false alarms = %u\n", - data->num_in_cck_no_fa); - - /* If we got too many false alarms this time, reduce sensitivity */ - if (false_alarms > max_false_alarms && - data->auto_corr_cck > AUTO_CORR_MAX_TH_CCK) { - D_CALIB("norm FA %u > max FA %u\n", - false_alarms, max_false_alarms); - D_CALIB("... reducing sensitivity\n"); - data->nrg_curr_state = IL_FA_TOO_MANY; - /* Store for "fewer than desired" on later beacon */ - data->nrg_silence_ref = silence_ref; - - /* increase energy threshold (reduce nrg value) - * to decrease sensitivity */ - data->nrg_th_cck = data->nrg_th_cck - NRG_STEP_CCK; - /* Else if we got fewer than desired, increase sensitivity */ - } else if (false_alarms < min_false_alarms) { - data->nrg_curr_state = IL_FA_TOO_FEW; - - /* Compare silence level with silence level for most recent - * healthy number or too many false alarms */ - data->nrg_auto_corr_silence_diff = (s32)data->nrg_silence_ref - - (s32)silence_ref; - - D_CALIB( - "norm FA %u < min FA %u, silence diff %d\n", - false_alarms, min_false_alarms, - data->nrg_auto_corr_silence_diff); - - /* Increase value to increase sensitivity, but only if: - * 1a) previous beacon did *not* have *too many* false alarms - * 1b) AND there's a significant difference in Rx levels - * from a previous beacon with too many, or healthy # FAs - * OR 2) We've seen a lot of beacons (100) with too few - * false alarms */ - if (data->nrg_prev_state != IL_FA_TOO_MANY && - (data->nrg_auto_corr_silence_diff > NRG_DIFF || - data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA)) { - - D_CALIB("... increasing sensitivity\n"); - /* Increase nrg value to increase sensitivity */ - val = data->nrg_th_cck + NRG_STEP_CCK; - data->nrg_th_cck = min((u32)ranges->min_nrg_cck, val); - } else { - D_CALIB( - "... but not changing sensitivity\n"); - } - - /* Else we got a healthy number of false alarms, keep status quo */ - } else { - D_CALIB(" FA in safe zone\n"); - data->nrg_curr_state = IL_FA_GOOD_RANGE; - - /* Store for use in "fewer than desired" with later beacon */ - data->nrg_silence_ref = silence_ref; - - /* If previous beacon had too many false alarms, - * give it some extra margin by reducing sensitivity again - * (but don't go below measured energy of desired Rx) */ - if (IL_FA_TOO_MANY == data->nrg_prev_state) { - D_CALIB("... increasing margin\n"); - if (data->nrg_th_cck > (max_nrg_cck + NRG_MARGIN)) - data->nrg_th_cck -= NRG_MARGIN; - else - data->nrg_th_cck = max_nrg_cck; - } - } - - /* Make sure the energy threshold does not go above the measured - * energy of the desired Rx signals (reduced by backoff margin), - * or else we might start missing Rx frames. - * Lower value is higher energy, so we use max()! - */ - data->nrg_th_cck = max(max_nrg_cck, data->nrg_th_cck); - D_CALIB("new nrg_th_cck %u\n", data->nrg_th_cck); - - data->nrg_prev_state = data->nrg_curr_state; - - /* Auto-correlation CCK algorithm */ - if (false_alarms > min_false_alarms) { - - /* increase auto_corr values to decrease sensitivity - * so the DSP won't be disturbed by the noise - */ - if (data->auto_corr_cck < AUTO_CORR_MAX_TH_CCK) - data->auto_corr_cck = AUTO_CORR_MAX_TH_CCK + 1; - else { - val = data->auto_corr_cck + AUTO_CORR_STEP_CCK; - data->auto_corr_cck = - min((u32)ranges->auto_corr_max_cck, val); - } - val = data->auto_corr_cck_mrc + AUTO_CORR_STEP_CCK; - data->auto_corr_cck_mrc = - min((u32)ranges->auto_corr_max_cck_mrc, val); - } else if (false_alarms < min_false_alarms && - (data->nrg_auto_corr_silence_diff > NRG_DIFF || - data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA)) { - - /* Decrease auto_corr values to increase sensitivity */ - val = data->auto_corr_cck - AUTO_CORR_STEP_CCK; - data->auto_corr_cck = - max((u32)ranges->auto_corr_min_cck, val); - val = data->auto_corr_cck_mrc - AUTO_CORR_STEP_CCK; - data->auto_corr_cck_mrc = - max((u32)ranges->auto_corr_min_cck_mrc, val); - } - - return 0; -} - - -static int il4965_sens_auto_corr_ofdm(struct il_priv *il, - u32 norm_fa, - u32 rx_enable_time) -{ - u32 val; - u32 false_alarms = norm_fa * 200 * 1024; - u32 max_false_alarms = MAX_FA_OFDM * rx_enable_time; - u32 min_false_alarms = MIN_FA_OFDM * rx_enable_time; - struct il_sensitivity_data *data = NULL; - const struct il_sensitivity_ranges *ranges = il->hw_params.sens; - - data = &(il->sensitivity_data); - - /* If we got too many false alarms this time, reduce sensitivity */ - if (false_alarms > max_false_alarms) { - - D_CALIB("norm FA %u > max FA %u)\n", - false_alarms, max_false_alarms); - - val = data->auto_corr_ofdm + AUTO_CORR_STEP_OFDM; - data->auto_corr_ofdm = - min((u32)ranges->auto_corr_max_ofdm, val); - - val = data->auto_corr_ofdm_mrc + AUTO_CORR_STEP_OFDM; - data->auto_corr_ofdm_mrc = - min((u32)ranges->auto_corr_max_ofdm_mrc, val); - - val = data->auto_corr_ofdm_x1 + AUTO_CORR_STEP_OFDM; - data->auto_corr_ofdm_x1 = - min((u32)ranges->auto_corr_max_ofdm_x1, val); - - val = data->auto_corr_ofdm_mrc_x1 + AUTO_CORR_STEP_OFDM; - data->auto_corr_ofdm_mrc_x1 = - min((u32)ranges->auto_corr_max_ofdm_mrc_x1, val); - } - - /* Else if we got fewer than desired, increase sensitivity */ - else if (false_alarms < min_false_alarms) { - - D_CALIB("norm FA %u < min FA %u\n", - false_alarms, min_false_alarms); - - val = data->auto_corr_ofdm - AUTO_CORR_STEP_OFDM; - data->auto_corr_ofdm = - max((u32)ranges->auto_corr_min_ofdm, val); - - val = data->auto_corr_ofdm_mrc - AUTO_CORR_STEP_OFDM; - data->auto_corr_ofdm_mrc = - max((u32)ranges->auto_corr_min_ofdm_mrc, val); - - val = data->auto_corr_ofdm_x1 - AUTO_CORR_STEP_OFDM; - data->auto_corr_ofdm_x1 = - max((u32)ranges->auto_corr_min_ofdm_x1, val); - - val = data->auto_corr_ofdm_mrc_x1 - AUTO_CORR_STEP_OFDM; - data->auto_corr_ofdm_mrc_x1 = - max((u32)ranges->auto_corr_min_ofdm_mrc_x1, val); - } else { - D_CALIB("min FA %u < norm FA %u < max FA %u OK\n", - min_false_alarms, false_alarms, max_false_alarms); - } - return 0; -} - -static void il4965_prepare_legacy_sensitivity_tbl(struct il_priv *il, - struct il_sensitivity_data *data, - __le16 *tbl) -{ - tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_IDX] = - cpu_to_le16((u16)data->auto_corr_ofdm); - tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_IDX] = - cpu_to_le16((u16)data->auto_corr_ofdm_mrc); - tbl[HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX] = - cpu_to_le16((u16)data->auto_corr_ofdm_x1); - tbl[HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_IDX] = - cpu_to_le16((u16)data->auto_corr_ofdm_mrc_x1); - - tbl[HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX] = - cpu_to_le16((u16)data->auto_corr_cck); - tbl[HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX] = - cpu_to_le16((u16)data->auto_corr_cck_mrc); - - tbl[HD_MIN_ENERGY_CCK_DET_IDX] = - cpu_to_le16((u16)data->nrg_th_cck); - tbl[HD_MIN_ENERGY_OFDM_DET_IDX] = - cpu_to_le16((u16)data->nrg_th_ofdm); - - tbl[HD_BARKER_CORR_TH_ADD_MIN_IDX] = - cpu_to_le16(data->barker_corr_th_min); - tbl[HD_BARKER_CORR_TH_ADD_MIN_MRC_IDX] = - cpu_to_le16(data->barker_corr_th_min_mrc); - tbl[HD_OFDM_ENERGY_TH_IN_IDX] = - cpu_to_le16(data->nrg_th_cca); - - D_CALIB("ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n", - data->auto_corr_ofdm, data->auto_corr_ofdm_mrc, - data->auto_corr_ofdm_x1, data->auto_corr_ofdm_mrc_x1, - data->nrg_th_ofdm); - - D_CALIB("cck: ac %u mrc %u thresh %u\n", - data->auto_corr_cck, data->auto_corr_cck_mrc, - data->nrg_th_cck); -} - -/* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */ -static int il4965_sensitivity_write(struct il_priv *il) -{ - struct il_sensitivity_cmd cmd; - struct il_sensitivity_data *data = NULL; - struct il_host_cmd cmd_out = { - .id = SENSITIVITY_CMD, - .len = sizeof(struct il_sensitivity_cmd), - .flags = CMD_ASYNC, - .data = &cmd, - }; - - data = &(il->sensitivity_data); - - memset(&cmd, 0, sizeof(cmd)); - - il4965_prepare_legacy_sensitivity_tbl(il, data, &cmd.table[0]); - - /* Update uCode's "work" table, and copy it to DSP */ - cmd.control = SENSITIVITY_CMD_CONTROL_WORK_TBL; - - /* Don't send command to uCode if nothing has changed */ - if (!memcmp(&cmd.table[0], &(il->sensitivity_tbl[0]), - sizeof(u16)*HD_TBL_SIZE)) { - D_CALIB("No change in SENSITIVITY_CMD\n"); - return 0; - } - - /* Copy table for comparison next time */ - memcpy(&(il->sensitivity_tbl[0]), &(cmd.table[0]), - sizeof(u16)*HD_TBL_SIZE); - - return il_send_cmd(il, &cmd_out); -} - -void il4965_init_sensitivity(struct il_priv *il) -{ - int ret = 0; - int i; - struct il_sensitivity_data *data = NULL; - const struct il_sensitivity_ranges *ranges = il->hw_params.sens; - - if (il->disable_sens_cal) - return; - - D_CALIB("Start il4965_init_sensitivity\n"); - - /* Clear driver's sensitivity algo data */ - data = &(il->sensitivity_data); - - if (ranges == NULL) - return; - - memset(data, 0, sizeof(struct il_sensitivity_data)); - - data->num_in_cck_no_fa = 0; - data->nrg_curr_state = IL_FA_TOO_MANY; - data->nrg_prev_state = IL_FA_TOO_MANY; - data->nrg_silence_ref = 0; - data->nrg_silence_idx = 0; - data->nrg_energy_idx = 0; - - for (i = 0; i < 10; i++) - data->nrg_value[i] = 0; - - for (i = 0; i < NRG_NUM_PREV_STAT_L; i++) - data->nrg_silence_rssi[i] = 0; - - data->auto_corr_ofdm = ranges->auto_corr_min_ofdm; - data->auto_corr_ofdm_mrc = ranges->auto_corr_min_ofdm_mrc; - data->auto_corr_ofdm_x1 = ranges->auto_corr_min_ofdm_x1; - data->auto_corr_ofdm_mrc_x1 = ranges->auto_corr_min_ofdm_mrc_x1; - data->auto_corr_cck = AUTO_CORR_CCK_MIN_VAL_DEF; - data->auto_corr_cck_mrc = ranges->auto_corr_min_cck_mrc; - data->nrg_th_cck = ranges->nrg_th_cck; - data->nrg_th_ofdm = ranges->nrg_th_ofdm; - data->barker_corr_th_min = ranges->barker_corr_th_min; - data->barker_corr_th_min_mrc = ranges->barker_corr_th_min_mrc; - data->nrg_th_cca = ranges->nrg_th_cca; - - data->last_bad_plcp_cnt_ofdm = 0; - data->last_fa_cnt_ofdm = 0; - data->last_bad_plcp_cnt_cck = 0; - data->last_fa_cnt_cck = 0; - - ret |= il4965_sensitivity_write(il); - D_CALIB("<disable_sens_cal) - return; - - data = &(il->sensitivity_data); - - if (!il_is_any_associated(il)) { - D_CALIB("<< - not associated\n"); - return; - } - - spin_lock_irqsave(&il->lock, flags); - - rx_info = &(((struct il_notif_stats *)resp)->rx.general); - ofdm = &(((struct il_notif_stats *)resp)->rx.ofdm); - cck = &(((struct il_notif_stats *)resp)->rx.cck); - - if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { - D_CALIB("<< invalid data.\n"); - spin_unlock_irqrestore(&il->lock, flags); - return; - } - - /* Extract Statistics: */ - rx_enable_time = le32_to_cpu(rx_info->channel_load); - fa_cck = le32_to_cpu(cck->false_alarm_cnt); - fa_ofdm = le32_to_cpu(ofdm->false_alarm_cnt); - bad_plcp_cck = le32_to_cpu(cck->plcp_err); - bad_plcp_ofdm = le32_to_cpu(ofdm->plcp_err); - - statis.beacon_silence_rssi_a = - le32_to_cpu(rx_info->beacon_silence_rssi_a); - statis.beacon_silence_rssi_b = - le32_to_cpu(rx_info->beacon_silence_rssi_b); - statis.beacon_silence_rssi_c = - le32_to_cpu(rx_info->beacon_silence_rssi_c); - statis.beacon_energy_a = - le32_to_cpu(rx_info->beacon_energy_a); - statis.beacon_energy_b = - le32_to_cpu(rx_info->beacon_energy_b); - statis.beacon_energy_c = - le32_to_cpu(rx_info->beacon_energy_c); - - spin_unlock_irqrestore(&il->lock, flags); - - D_CALIB("rx_enable_time = %u usecs\n", rx_enable_time); - - if (!rx_enable_time) { - D_CALIB("<< RX Enable Time == 0!\n"); - return; - } - - /* These stats increase monotonically, and do not reset - * at each beacon. Calculate difference from last value, or just - * use the new stats value if it has reset or wrapped around. */ - if (data->last_bad_plcp_cnt_cck > bad_plcp_cck) - data->last_bad_plcp_cnt_cck = bad_plcp_cck; - else { - bad_plcp_cck -= data->last_bad_plcp_cnt_cck; - data->last_bad_plcp_cnt_cck += bad_plcp_cck; - } - - if (data->last_bad_plcp_cnt_ofdm > bad_plcp_ofdm) - data->last_bad_plcp_cnt_ofdm = bad_plcp_ofdm; - else { - bad_plcp_ofdm -= data->last_bad_plcp_cnt_ofdm; - data->last_bad_plcp_cnt_ofdm += bad_plcp_ofdm; - } - - if (data->last_fa_cnt_ofdm > fa_ofdm) - data->last_fa_cnt_ofdm = fa_ofdm; - else { - fa_ofdm -= data->last_fa_cnt_ofdm; - data->last_fa_cnt_ofdm += fa_ofdm; - } - - if (data->last_fa_cnt_cck > fa_cck) - data->last_fa_cnt_cck = fa_cck; - else { - fa_cck -= data->last_fa_cnt_cck; - data->last_fa_cnt_cck += fa_cck; - } - - /* Total aborted signal locks */ - norm_fa_ofdm = fa_ofdm + bad_plcp_ofdm; - norm_fa_cck = fa_cck + bad_plcp_cck; - - D_CALIB( - "cck: fa %u badp %u ofdm: fa %u badp %u\n", fa_cck, - bad_plcp_cck, fa_ofdm, bad_plcp_ofdm); - - il4965_sens_auto_corr_ofdm(il, norm_fa_ofdm, rx_enable_time); - il4965_sens_energy_cck(il, norm_fa_cck, rx_enable_time, &statis); - - il4965_sensitivity_write(il); -} - -static inline u8 il4965_find_first_chain(u8 mask) -{ - if (mask & ANT_A) - return CHAIN_A; - if (mask & ANT_B) - return CHAIN_B; - return CHAIN_C; -} - -/** - * Run disconnected antenna algorithm to find out which antennas are - * disconnected. - */ -static void -il4965_find_disconn_antenna(struct il_priv *il, u32* average_sig, - struct il_chain_noise_data *data) -{ - u32 active_chains = 0; - u32 max_average_sig; - u16 max_average_sig_antenna_i; - u8 num_tx_chains; - u8 first_chain; - u16 i = 0; - - average_sig[0] = data->chain_signal_a / - il->cfg->base_params->chain_noise_num_beacons; - average_sig[1] = data->chain_signal_b / - il->cfg->base_params->chain_noise_num_beacons; - average_sig[2] = data->chain_signal_c / - il->cfg->base_params->chain_noise_num_beacons; - - if (average_sig[0] >= average_sig[1]) { - max_average_sig = average_sig[0]; - max_average_sig_antenna_i = 0; - active_chains = (1 << max_average_sig_antenna_i); - } else { - max_average_sig = average_sig[1]; - max_average_sig_antenna_i = 1; - active_chains = (1 << max_average_sig_antenna_i); - } - - if (average_sig[2] >= max_average_sig) { - max_average_sig = average_sig[2]; - max_average_sig_antenna_i = 2; - active_chains = (1 << max_average_sig_antenna_i); - } - - D_CALIB("average_sig: a %d b %d c %d\n", - average_sig[0], average_sig[1], average_sig[2]); - D_CALIB("max_average_sig = %d, antenna %d\n", - max_average_sig, max_average_sig_antenna_i); - - /* Compare signal strengths for all 3 receivers. */ - for (i = 0; i < NUM_RX_CHAINS; i++) { - if (i != max_average_sig_antenna_i) { - s32 rssi_delta = (max_average_sig - average_sig[i]); - - /* If signal is very weak, compared with - * strongest, mark it as disconnected. */ - if (rssi_delta > MAXIMUM_ALLOWED_PATHLOSS) - data->disconn_array[i] = 1; - else - active_chains |= (1 << i); - D_CALIB("i = %d rssiDelta = %d " - "disconn_array[i] = %d\n", - i, rssi_delta, data->disconn_array[i]); - } - } - - /* - * The above algorithm sometimes fails when the ucode - * reports 0 for all chains. It's not clear why that - * happens to start with, but it is then causing trouble - * because this can make us enable more chains than the - * hardware really has. - * - * To be safe, simply mask out any chains that we know - * are not on the device. - */ - active_chains &= il->hw_params.valid_rx_ant; - - num_tx_chains = 0; - for (i = 0; i < NUM_RX_CHAINS; i++) { - /* loops on all the bits of - * il->hw_setting.valid_tx_ant */ - u8 ant_msk = (1 << i); - if (!(il->hw_params.valid_tx_ant & ant_msk)) - continue; - - num_tx_chains++; - if (data->disconn_array[i] == 0) - /* there is a Tx antenna connected */ - break; - if (num_tx_chains == il->hw_params.tx_chains_num && - data->disconn_array[i]) { - /* - * If all chains are disconnected - * connect the first valid tx chain - */ - first_chain = - il4965_find_first_chain(il->cfg->valid_tx_ant); - data->disconn_array[first_chain] = 0; - active_chains |= BIT(first_chain); - D_CALIB( - "All Tx chains are disconnected W/A - declare %d as connected\n", - first_chain); - break; - } - } - - if (active_chains != il->hw_params.valid_rx_ant && - active_chains != il->chain_noise_data.active_chains) - D_CALIB( - "Detected that not all antennas are connected! " - "Connected: %#x, valid: %#x.\n", - active_chains, il->hw_params.valid_rx_ant); - - /* Save for use within RXON, TX, SCAN commands, etc. */ - data->active_chains = active_chains; - D_CALIB("active_chains (bitwise) = 0x%x\n", - active_chains); -} - -static void il4965_gain_computation(struct il_priv *il, - u32 *average_noise, - u16 min_average_noise_antenna_i, - u32 min_average_noise, - u8 default_chain) -{ - int i, ret; - struct il_chain_noise_data *data = &il->chain_noise_data; - - data->delta_gain_code[min_average_noise_antenna_i] = 0; - - for (i = default_chain; i < NUM_RX_CHAINS; i++) { - s32 delta_g = 0; - - if (!data->disconn_array[i] && - data->delta_gain_code[i] == CHAIN_NOISE_DELTA_GAIN_INIT_VAL) { - delta_g = average_noise[i] - min_average_noise; - data->delta_gain_code[i] = (u8)((delta_g * 10) / 15); - data->delta_gain_code[i] = - min(data->delta_gain_code[i], - (u8) CHAIN_NOISE_MAX_DELTA_GAIN_CODE); - - data->delta_gain_code[i] = - (data->delta_gain_code[i] | (1 << 2)); - } else { - data->delta_gain_code[i] = 0; - } - } - D_CALIB("delta_gain_codes: a %d b %d c %d\n", - data->delta_gain_code[0], - data->delta_gain_code[1], - data->delta_gain_code[2]); - - /* Differential gain gets sent to uCode only once */ - if (!data->radio_write) { - struct il_calib_diff_gain_cmd cmd; - data->radio_write = 1; - - memset(&cmd, 0, sizeof(cmd)); - cmd.hdr.op_code = IL_PHY_CALIBRATE_DIFF_GAIN_CMD; - cmd.diff_gain_a = data->delta_gain_code[0]; - cmd.diff_gain_b = data->delta_gain_code[1]; - cmd.diff_gain_c = data->delta_gain_code[2]; - ret = il_send_cmd_pdu(il, REPLY_PHY_CALIBRATION_CMD, - sizeof(cmd), &cmd); - if (ret) - D_CALIB("fail sending cmd " - "REPLY_PHY_CALIBRATION_CMD\n"); - - /* TODO we might want recalculate - * rx_chain in rxon cmd */ - - /* Mark so we run this algo only once! */ - data->state = IL_CHAIN_NOISE_CALIBRATED; - } -} - - - -/* - * Accumulate 16 beacons of signal and noise stats for each of - * 3 receivers/antennas/rx-chains, then figure out: - * 1) Which antennas are connected. - * 2) Differential rx gain settings to balance the 3 receivers. - */ -void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) -{ - struct il_chain_noise_data *data = NULL; - - u32 chain_noise_a; - u32 chain_noise_b; - u32 chain_noise_c; - u32 chain_sig_a; - u32 chain_sig_b; - u32 chain_sig_c; - u32 average_sig[NUM_RX_CHAINS] = {INITIALIZATION_VALUE}; - u32 average_noise[NUM_RX_CHAINS] = {INITIALIZATION_VALUE}; - u32 min_average_noise = MIN_AVERAGE_NOISE_MAX_VALUE; - u16 min_average_noise_antenna_i = INITIALIZATION_VALUE; - u16 i = 0; - u16 rxon_chnum = INITIALIZATION_VALUE; - u16 stat_chnum = INITIALIZATION_VALUE; - u8 rxon_band24; - u8 stat_band24; - unsigned long flags; - struct stats_rx_non_phy *rx_info; - - struct il_rxon_context *ctx = &il->ctx; - - if (il->disable_chain_noise_cal) - return; - - data = &(il->chain_noise_data); - - /* - * Accumulate just the first "chain_noise_num_beacons" after - * the first association, then we're done forever. - */ - if (data->state != IL_CHAIN_NOISE_ACCUMULATE) { - if (data->state == IL_CHAIN_NOISE_ALIVE) - D_CALIB("Wait for noise calib reset\n"); - return; - } - - spin_lock_irqsave(&il->lock, flags); - - rx_info = &(((struct il_notif_stats *)stat_resp)-> - rx.general); - - if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { - D_CALIB(" << Interference data unavailable\n"); - spin_unlock_irqrestore(&il->lock, flags); - return; - } - - rxon_band24 = !!(ctx->staging.flags & RXON_FLG_BAND_24G_MSK); - rxon_chnum = le16_to_cpu(ctx->staging.channel); - - stat_band24 = !!(((struct il_notif_stats *) - stat_resp)->flag & - STATISTICS_REPLY_FLG_BAND_24G_MSK); - stat_chnum = le32_to_cpu(((struct il_notif_stats *) - stat_resp)->flag) >> 16; - - /* Make sure we accumulate data for just the associated channel - * (even if scanning). */ - if (rxon_chnum != stat_chnum || rxon_band24 != stat_band24) { - D_CALIB("Stats not from chan=%d, band24=%d\n", - rxon_chnum, rxon_band24); - spin_unlock_irqrestore(&il->lock, flags); - return; - } - - /* - * Accumulate beacon stats values across - * "chain_noise_num_beacons" - */ - chain_noise_a = le32_to_cpu(rx_info->beacon_silence_rssi_a) & - IN_BAND_FILTER; - chain_noise_b = le32_to_cpu(rx_info->beacon_silence_rssi_b) & - IN_BAND_FILTER; - chain_noise_c = le32_to_cpu(rx_info->beacon_silence_rssi_c) & - IN_BAND_FILTER; - - chain_sig_a = le32_to_cpu(rx_info->beacon_rssi_a) & IN_BAND_FILTER; - chain_sig_b = le32_to_cpu(rx_info->beacon_rssi_b) & IN_BAND_FILTER; - chain_sig_c = le32_to_cpu(rx_info->beacon_rssi_c) & IN_BAND_FILTER; - - spin_unlock_irqrestore(&il->lock, flags); - - data->beacon_count++; - - data->chain_noise_a = (chain_noise_a + data->chain_noise_a); - data->chain_noise_b = (chain_noise_b + data->chain_noise_b); - data->chain_noise_c = (chain_noise_c + data->chain_noise_c); - - data->chain_signal_a = (chain_sig_a + data->chain_signal_a); - data->chain_signal_b = (chain_sig_b + data->chain_signal_b); - data->chain_signal_c = (chain_sig_c + data->chain_signal_c); - - D_CALIB("chan=%d, band24=%d, beacon=%d\n", - rxon_chnum, rxon_band24, data->beacon_count); - D_CALIB("chain_sig: a %d b %d c %d\n", - chain_sig_a, chain_sig_b, chain_sig_c); - D_CALIB("chain_noise: a %d b %d c %d\n", - chain_noise_a, chain_noise_b, chain_noise_c); - - /* If this is the "chain_noise_num_beacons", determine: - * 1) Disconnected antennas (using signal strengths) - * 2) Differential gain (using silence noise) to balance receivers */ - if (data->beacon_count != - il->cfg->base_params->chain_noise_num_beacons) - return; - - /* Analyze signal for disconnected antenna */ - il4965_find_disconn_antenna(il, average_sig, data); - - /* Analyze noise for rx balance */ - average_noise[0] = data->chain_noise_a / - il->cfg->base_params->chain_noise_num_beacons; - average_noise[1] = data->chain_noise_b / - il->cfg->base_params->chain_noise_num_beacons; - average_noise[2] = data->chain_noise_c / - il->cfg->base_params->chain_noise_num_beacons; - - for (i = 0; i < NUM_RX_CHAINS; i++) { - if (!data->disconn_array[i] && - average_noise[i] <= min_average_noise) { - /* This means that chain i is active and has - * lower noise values so far: */ - min_average_noise = average_noise[i]; - min_average_noise_antenna_i = i; - } - } - - D_CALIB("average_noise: a %d b %d c %d\n", - average_noise[0], average_noise[1], - average_noise[2]); - - D_CALIB("min_average_noise = %d, antenna %d\n", - min_average_noise, min_average_noise_antenna_i); - - il4965_gain_computation(il, average_noise, - min_average_noise_antenna_i, min_average_noise, - il4965_find_first_chain(il->cfg->valid_rx_ant)); - - /* Some power changes may have been made during the calibration. - * Update and commit the RXON - */ - if (il->cfg->ops->lib->update_chain_flags) - il->cfg->ops->lib->update_chain_flags(il); - - data->state = IL_CHAIN_NOISE_DONE; - il_power_update_mode(il, false); -} - -void il4965_reset_run_time_calib(struct il_priv *il) -{ - int i; - memset(&(il->sensitivity_data), 0, - sizeof(struct il_sensitivity_data)); - memset(&(il->chain_noise_data), 0, - sizeof(struct il_chain_noise_data)); - for (i = 0; i < NUM_RX_CHAINS; i++) - il->chain_noise_data.delta_gain_code[i] = - CHAIN_NOISE_DELTA_GAIN_INIT_VAL; - - /* Ask for stats now, the uCode will send notification - * periodically after association */ - il_send_stats_request(il, CMD_ASYNC, true); -} diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c deleted file mode 100644 index 89e5828ce383..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.c +++ /dev/null @@ -1,774 +0,0 @@ -/****************************************************************************** -* -* GPL LICENSE SUMMARY -* -* Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of version 2 of the GNU General Public License as -* published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, -* USA -* -* The full GNU General Public License is included in this distribution -* in the file called LICENSE.GPL. -* -* Contact Information: -* Intel Linux Wireless -* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 -*****************************************************************************/ -#include "iwl-4965.h" -#include "iwl-4965-debugfs.h" - -static const char *fmt_value = " %-30s %10u\n"; -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n"; -static const char *fmt_header = - "%-32s current cumulative delta max\n"; - -static int il4965_stats_flag(struct il_priv *il, char *buf, int bufsz) -{ - int p = 0; - u32 flag; - - flag = le32_to_cpu(il->_4965.stats.flag); - - p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag); - if (flag & UCODE_STATISTICS_CLEAR_MSK) - p += scnprintf(buf + p, bufsz - p, - "\tStatistics have been cleared\n"); - p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n", - (flag & UCODE_STATISTICS_FREQUENCY_MSK) - ? "2.4 GHz" : "5.2 GHz"); - p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n", - (flag & UCODE_STATISTICS_NARROW_BAND_MSK) - ? "enabled" : "disabled"); - - return p; -} - -ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - int pos = 0; - char *buf; - int bufsz = sizeof(struct stats_rx_phy) * 40 + - sizeof(struct stats_rx_non_phy) * 40 + - sizeof(struct stats_rx_ht_phy) * 40 + 400; - ssize_t ret; - struct stats_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm; - struct stats_rx_phy *cck, *accum_cck, *delta_cck, *max_cck; - struct stats_rx_non_phy *general, *accum_general; - struct stats_rx_non_phy *delta_general, *max_general; - struct stats_rx_ht_phy *ht, *accum_ht, *delta_ht, *max_ht; - - if (!il_is_alive(il)) - return -EAGAIN; - - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) { - IL_ERR("Can not allocate Buffer\n"); - return -ENOMEM; - } - - /* - * the statistic information display here is based on - * the last stats notification from uCode - * might not reflect the current uCode activity - */ - ofdm = &il->_4965.stats.rx.ofdm; - cck = &il->_4965.stats.rx.cck; - general = &il->_4965.stats.rx.general; - ht = &il->_4965.stats.rx.ofdm_ht; - accum_ofdm = &il->_4965.accum_stats.rx.ofdm; - accum_cck = &il->_4965.accum_stats.rx.cck; - accum_general = &il->_4965.accum_stats.rx.general; - accum_ht = &il->_4965.accum_stats.rx.ofdm_ht; - delta_ofdm = &il->_4965.delta_stats.rx.ofdm; - delta_cck = &il->_4965.delta_stats.rx.cck; - delta_general = &il->_4965.delta_stats.rx.general; - delta_ht = &il->_4965.delta_stats.rx.ofdm_ht; - max_ofdm = &il->_4965.max_delta.rx.ofdm; - max_cck = &il->_4965.max_delta.rx.cck; - max_general = &il->_4965.max_delta.rx.general; - max_ht = &il->_4965.max_delta.rx.ofdm_ht; - - pos += il4965_stats_flag(il, buf, bufsz); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_header, "Statistics_Rx - OFDM:"); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "ina_cnt:", - le32_to_cpu(ofdm->ina_cnt), - accum_ofdm->ina_cnt, - delta_ofdm->ina_cnt, max_ofdm->ina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "fina_cnt:", - le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt, - delta_ofdm->fina_cnt, max_ofdm->fina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "plcp_err:", - le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err, - delta_ofdm->plcp_err, max_ofdm->plcp_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "crc32_err:", - le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err, - delta_ofdm->crc32_err, max_ofdm->crc32_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "overrun_err:", - le32_to_cpu(ofdm->overrun_err), - accum_ofdm->overrun_err, delta_ofdm->overrun_err, - max_ofdm->overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "early_overrun_err:", - le32_to_cpu(ofdm->early_overrun_err), - accum_ofdm->early_overrun_err, - delta_ofdm->early_overrun_err, - max_ofdm->early_overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "crc32_good:", - le32_to_cpu(ofdm->crc32_good), - accum_ofdm->crc32_good, delta_ofdm->crc32_good, - max_ofdm->crc32_good); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "false_alarm_cnt:", - le32_to_cpu(ofdm->false_alarm_cnt), - accum_ofdm->false_alarm_cnt, - delta_ofdm->false_alarm_cnt, - max_ofdm->false_alarm_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "fina_sync_err_cnt:", - le32_to_cpu(ofdm->fina_sync_err_cnt), - accum_ofdm->fina_sync_err_cnt, - delta_ofdm->fina_sync_err_cnt, - max_ofdm->fina_sync_err_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sfd_timeout:", - le32_to_cpu(ofdm->sfd_timeout), - accum_ofdm->sfd_timeout, delta_ofdm->sfd_timeout, - max_ofdm->sfd_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "fina_timeout:", - le32_to_cpu(ofdm->fina_timeout), - accum_ofdm->fina_timeout, delta_ofdm->fina_timeout, - max_ofdm->fina_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "unresponded_rts:", - le32_to_cpu(ofdm->unresponded_rts), - accum_ofdm->unresponded_rts, - delta_ofdm->unresponded_rts, - max_ofdm->unresponded_rts); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "rxe_frame_lmt_ovrun:", - le32_to_cpu(ofdm->rxe_frame_limit_overrun), - accum_ofdm->rxe_frame_limit_overrun, - delta_ofdm->rxe_frame_limit_overrun, - max_ofdm->rxe_frame_limit_overrun); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sent_ack_cnt:", - le32_to_cpu(ofdm->sent_ack_cnt), - accum_ofdm->sent_ack_cnt, delta_ofdm->sent_ack_cnt, - max_ofdm->sent_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sent_cts_cnt:", - le32_to_cpu(ofdm->sent_cts_cnt), - accum_ofdm->sent_cts_cnt, delta_ofdm->sent_cts_cnt, - max_ofdm->sent_cts_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sent_ba_rsp_cnt:", - le32_to_cpu(ofdm->sent_ba_rsp_cnt), - accum_ofdm->sent_ba_rsp_cnt, - delta_ofdm->sent_ba_rsp_cnt, - max_ofdm->sent_ba_rsp_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "dsp_self_kill:", - le32_to_cpu(ofdm->dsp_self_kill), - accum_ofdm->dsp_self_kill, - delta_ofdm->dsp_self_kill, - max_ofdm->dsp_self_kill); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "mh_format_err:", - le32_to_cpu(ofdm->mh_format_err), - accum_ofdm->mh_format_err, - delta_ofdm->mh_format_err, - max_ofdm->mh_format_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "re_acq_main_rssi_sum:", - le32_to_cpu(ofdm->re_acq_main_rssi_sum), - accum_ofdm->re_acq_main_rssi_sum, - delta_ofdm->re_acq_main_rssi_sum, - max_ofdm->re_acq_main_rssi_sum); - - pos += scnprintf(buf + pos, bufsz - pos, - fmt_header, "Statistics_Rx - CCK:"); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "ina_cnt:", - le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt, - delta_cck->ina_cnt, max_cck->ina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "fina_cnt:", - le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt, - delta_cck->fina_cnt, max_cck->fina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "plcp_err:", - le32_to_cpu(cck->plcp_err), accum_cck->plcp_err, - delta_cck->plcp_err, max_cck->plcp_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "crc32_err:", - le32_to_cpu(cck->crc32_err), accum_cck->crc32_err, - delta_cck->crc32_err, max_cck->crc32_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "overrun_err:", - le32_to_cpu(cck->overrun_err), - accum_cck->overrun_err, delta_cck->overrun_err, - max_cck->overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "early_overrun_err:", - le32_to_cpu(cck->early_overrun_err), - accum_cck->early_overrun_err, - delta_cck->early_overrun_err, - max_cck->early_overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "crc32_good:", - le32_to_cpu(cck->crc32_good), accum_cck->crc32_good, - delta_cck->crc32_good, max_cck->crc32_good); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "false_alarm_cnt:", - le32_to_cpu(cck->false_alarm_cnt), - accum_cck->false_alarm_cnt, - delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "fina_sync_err_cnt:", - le32_to_cpu(cck->fina_sync_err_cnt), - accum_cck->fina_sync_err_cnt, - delta_cck->fina_sync_err_cnt, - max_cck->fina_sync_err_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sfd_timeout:", - le32_to_cpu(cck->sfd_timeout), - accum_cck->sfd_timeout, delta_cck->sfd_timeout, - max_cck->sfd_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "fina_timeout:", - le32_to_cpu(cck->fina_timeout), - accum_cck->fina_timeout, delta_cck->fina_timeout, - max_cck->fina_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "unresponded_rts:", - le32_to_cpu(cck->unresponded_rts), - accum_cck->unresponded_rts, delta_cck->unresponded_rts, - max_cck->unresponded_rts); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "rxe_frame_lmt_ovrun:", - le32_to_cpu(cck->rxe_frame_limit_overrun), - accum_cck->rxe_frame_limit_overrun, - delta_cck->rxe_frame_limit_overrun, - max_cck->rxe_frame_limit_overrun); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sent_ack_cnt:", - le32_to_cpu(cck->sent_ack_cnt), - accum_cck->sent_ack_cnt, delta_cck->sent_ack_cnt, - max_cck->sent_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sent_cts_cnt:", - le32_to_cpu(cck->sent_cts_cnt), - accum_cck->sent_cts_cnt, delta_cck->sent_cts_cnt, - max_cck->sent_cts_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sent_ba_rsp_cnt:", - le32_to_cpu(cck->sent_ba_rsp_cnt), - accum_cck->sent_ba_rsp_cnt, - delta_cck->sent_ba_rsp_cnt, - max_cck->sent_ba_rsp_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "dsp_self_kill:", - le32_to_cpu(cck->dsp_self_kill), - accum_cck->dsp_self_kill, delta_cck->dsp_self_kill, - max_cck->dsp_self_kill); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "mh_format_err:", - le32_to_cpu(cck->mh_format_err), - accum_cck->mh_format_err, delta_cck->mh_format_err, - max_cck->mh_format_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "re_acq_main_rssi_sum:", - le32_to_cpu(cck->re_acq_main_rssi_sum), - accum_cck->re_acq_main_rssi_sum, - delta_cck->re_acq_main_rssi_sum, - max_cck->re_acq_main_rssi_sum); - - pos += scnprintf(buf + pos, bufsz - pos, - fmt_header, "Statistics_Rx - GENERAL:"); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "bogus_cts:", - le32_to_cpu(general->bogus_cts), - accum_general->bogus_cts, delta_general->bogus_cts, - max_general->bogus_cts); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "bogus_ack:", - le32_to_cpu(general->bogus_ack), - accum_general->bogus_ack, delta_general->bogus_ack, - max_general->bogus_ack); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "non_bssid_frames:", - le32_to_cpu(general->non_bssid_frames), - accum_general->non_bssid_frames, - delta_general->non_bssid_frames, - max_general->non_bssid_frames); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "filtered_frames:", - le32_to_cpu(general->filtered_frames), - accum_general->filtered_frames, - delta_general->filtered_frames, - max_general->filtered_frames); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "non_channel_beacons:", - le32_to_cpu(general->non_channel_beacons), - accum_general->non_channel_beacons, - delta_general->non_channel_beacons, - max_general->non_channel_beacons); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "channel_beacons:", - le32_to_cpu(general->channel_beacons), - accum_general->channel_beacons, - delta_general->channel_beacons, - max_general->channel_beacons); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "num_missed_bcon:", - le32_to_cpu(general->num_missed_bcon), - accum_general->num_missed_bcon, - delta_general->num_missed_bcon, - max_general->num_missed_bcon); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "adc_rx_saturation_time:", - le32_to_cpu(general->adc_rx_saturation_time), - accum_general->adc_rx_saturation_time, - delta_general->adc_rx_saturation_time, - max_general->adc_rx_saturation_time); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "ina_detect_search_tm:", - le32_to_cpu(general->ina_detection_search_time), - accum_general->ina_detection_search_time, - delta_general->ina_detection_search_time, - max_general->ina_detection_search_time); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_silence_rssi_a:", - le32_to_cpu(general->beacon_silence_rssi_a), - accum_general->beacon_silence_rssi_a, - delta_general->beacon_silence_rssi_a, - max_general->beacon_silence_rssi_a); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_silence_rssi_b:", - le32_to_cpu(general->beacon_silence_rssi_b), - accum_general->beacon_silence_rssi_b, - delta_general->beacon_silence_rssi_b, - max_general->beacon_silence_rssi_b); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_silence_rssi_c:", - le32_to_cpu(general->beacon_silence_rssi_c), - accum_general->beacon_silence_rssi_c, - delta_general->beacon_silence_rssi_c, - max_general->beacon_silence_rssi_c); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "interference_data_flag:", - le32_to_cpu(general->interference_data_flag), - accum_general->interference_data_flag, - delta_general->interference_data_flag, - max_general->interference_data_flag); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "channel_load:", - le32_to_cpu(general->channel_load), - accum_general->channel_load, - delta_general->channel_load, - max_general->channel_load); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "dsp_false_alarms:", - le32_to_cpu(general->dsp_false_alarms), - accum_general->dsp_false_alarms, - delta_general->dsp_false_alarms, - max_general->dsp_false_alarms); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_rssi_a:", - le32_to_cpu(general->beacon_rssi_a), - accum_general->beacon_rssi_a, - delta_general->beacon_rssi_a, - max_general->beacon_rssi_a); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_rssi_b:", - le32_to_cpu(general->beacon_rssi_b), - accum_general->beacon_rssi_b, - delta_general->beacon_rssi_b, - max_general->beacon_rssi_b); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_rssi_c:", - le32_to_cpu(general->beacon_rssi_c), - accum_general->beacon_rssi_c, - delta_general->beacon_rssi_c, - max_general->beacon_rssi_c); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_energy_a:", - le32_to_cpu(general->beacon_energy_a), - accum_general->beacon_energy_a, - delta_general->beacon_energy_a, - max_general->beacon_energy_a); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_energy_b:", - le32_to_cpu(general->beacon_energy_b), - accum_general->beacon_energy_b, - delta_general->beacon_energy_b, - max_general->beacon_energy_b); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_energy_c:", - le32_to_cpu(general->beacon_energy_c), - accum_general->beacon_energy_c, - delta_general->beacon_energy_c, - max_general->beacon_energy_c); - - pos += scnprintf(buf + pos, bufsz - pos, - fmt_header, "Statistics_Rx - OFDM_HT:"); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "plcp_err:", - le32_to_cpu(ht->plcp_err), accum_ht->plcp_err, - delta_ht->plcp_err, max_ht->plcp_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "overrun_err:", - le32_to_cpu(ht->overrun_err), accum_ht->overrun_err, - delta_ht->overrun_err, max_ht->overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "early_overrun_err:", - le32_to_cpu(ht->early_overrun_err), - accum_ht->early_overrun_err, - delta_ht->early_overrun_err, - max_ht->early_overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "crc32_good:", - le32_to_cpu(ht->crc32_good), accum_ht->crc32_good, - delta_ht->crc32_good, max_ht->crc32_good); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "crc32_err:", - le32_to_cpu(ht->crc32_err), accum_ht->crc32_err, - delta_ht->crc32_err, max_ht->crc32_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "mh_format_err:", - le32_to_cpu(ht->mh_format_err), - accum_ht->mh_format_err, - delta_ht->mh_format_err, max_ht->mh_format_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg_crc32_good:", - le32_to_cpu(ht->agg_crc32_good), - accum_ht->agg_crc32_good, - delta_ht->agg_crc32_good, max_ht->agg_crc32_good); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg_mpdu_cnt:", - le32_to_cpu(ht->agg_mpdu_cnt), - accum_ht->agg_mpdu_cnt, - delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg_cnt:", - le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt, - delta_ht->agg_cnt, max_ht->agg_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "unsupport_mcs:", - le32_to_cpu(ht->unsupport_mcs), - accum_ht->unsupport_mcs, - delta_ht->unsupport_mcs, max_ht->unsupport_mcs); - - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -ssize_t il4965_ucode_tx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - int pos = 0; - char *buf; - int bufsz = (sizeof(struct stats_tx) * 48) + 250; - ssize_t ret; - struct stats_tx *tx, *accum_tx, *delta_tx, *max_tx; - - if (!il_is_alive(il)) - return -EAGAIN; - - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) { - IL_ERR("Can not allocate Buffer\n"); - return -ENOMEM; - } - - /* the statistic information display here is based on - * the last stats notification from uCode - * might not reflect the current uCode activity - */ - tx = &il->_4965.stats.tx; - accum_tx = &il->_4965.accum_stats.tx; - delta_tx = &il->_4965.delta_stats.tx; - max_tx = &il->_4965.max_delta.tx; - - pos += il4965_stats_flag(il, buf, bufsz); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_header, "Statistics_Tx:"); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "preamble:", - le32_to_cpu(tx->preamble_cnt), - accum_tx->preamble_cnt, - delta_tx->preamble_cnt, max_tx->preamble_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "rx_detected_cnt:", - le32_to_cpu(tx->rx_detected_cnt), - accum_tx->rx_detected_cnt, - delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "bt_prio_defer_cnt:", - le32_to_cpu(tx->bt_prio_defer_cnt), - accum_tx->bt_prio_defer_cnt, - delta_tx->bt_prio_defer_cnt, - max_tx->bt_prio_defer_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "bt_prio_kill_cnt:", - le32_to_cpu(tx->bt_prio_kill_cnt), - accum_tx->bt_prio_kill_cnt, - delta_tx->bt_prio_kill_cnt, - max_tx->bt_prio_kill_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "few_bytes_cnt:", - le32_to_cpu(tx->few_bytes_cnt), - accum_tx->few_bytes_cnt, - delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "cts_timeout:", - le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout, - delta_tx->cts_timeout, max_tx->cts_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "ack_timeout:", - le32_to_cpu(tx->ack_timeout), - accum_tx->ack_timeout, - delta_tx->ack_timeout, max_tx->ack_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "expected_ack_cnt:", - le32_to_cpu(tx->expected_ack_cnt), - accum_tx->expected_ack_cnt, - delta_tx->expected_ack_cnt, - max_tx->expected_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "actual_ack_cnt:", - le32_to_cpu(tx->actual_ack_cnt), - accum_tx->actual_ack_cnt, - delta_tx->actual_ack_cnt, - max_tx->actual_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "dump_msdu_cnt:", - le32_to_cpu(tx->dump_msdu_cnt), - accum_tx->dump_msdu_cnt, - delta_tx->dump_msdu_cnt, - max_tx->dump_msdu_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "abort_nxt_frame_mismatch:", - le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt), - accum_tx->burst_abort_next_frame_mismatch_cnt, - delta_tx->burst_abort_next_frame_mismatch_cnt, - max_tx->burst_abort_next_frame_mismatch_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "abort_missing_nxt_frame:", - le32_to_cpu(tx->burst_abort_missing_next_frame_cnt), - accum_tx->burst_abort_missing_next_frame_cnt, - delta_tx->burst_abort_missing_next_frame_cnt, - max_tx->burst_abort_missing_next_frame_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "cts_timeout_collision:", - le32_to_cpu(tx->cts_timeout_collision), - accum_tx->cts_timeout_collision, - delta_tx->cts_timeout_collision, - max_tx->cts_timeout_collision); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "ack_ba_timeout_collision:", - le32_to_cpu(tx->ack_or_ba_timeout_collision), - accum_tx->ack_or_ba_timeout_collision, - delta_tx->ack_or_ba_timeout_collision, - max_tx->ack_or_ba_timeout_collision); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg ba_timeout:", - le32_to_cpu(tx->agg.ba_timeout), - accum_tx->agg.ba_timeout, - delta_tx->agg.ba_timeout, - max_tx->agg.ba_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg ba_resched_frames:", - le32_to_cpu(tx->agg.ba_reschedule_frames), - accum_tx->agg.ba_reschedule_frames, - delta_tx->agg.ba_reschedule_frames, - max_tx->agg.ba_reschedule_frames); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg scd_query_agg_frame:", - le32_to_cpu(tx->agg.scd_query_agg_frame_cnt), - accum_tx->agg.scd_query_agg_frame_cnt, - delta_tx->agg.scd_query_agg_frame_cnt, - max_tx->agg.scd_query_agg_frame_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg scd_query_no_agg:", - le32_to_cpu(tx->agg.scd_query_no_agg), - accum_tx->agg.scd_query_no_agg, - delta_tx->agg.scd_query_no_agg, - max_tx->agg.scd_query_no_agg); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg scd_query_agg:", - le32_to_cpu(tx->agg.scd_query_agg), - accum_tx->agg.scd_query_agg, - delta_tx->agg.scd_query_agg, - max_tx->agg.scd_query_agg); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg scd_query_mismatch:", - le32_to_cpu(tx->agg.scd_query_mismatch), - accum_tx->agg.scd_query_mismatch, - delta_tx->agg.scd_query_mismatch, - max_tx->agg.scd_query_mismatch); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg frame_not_ready:", - le32_to_cpu(tx->agg.frame_not_ready), - accum_tx->agg.frame_not_ready, - delta_tx->agg.frame_not_ready, - max_tx->agg.frame_not_ready); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg underrun:", - le32_to_cpu(tx->agg.underrun), - accum_tx->agg.underrun, - delta_tx->agg.underrun, max_tx->agg.underrun); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg bt_prio_kill:", - le32_to_cpu(tx->agg.bt_prio_kill), - accum_tx->agg.bt_prio_kill, - delta_tx->agg.bt_prio_kill, - max_tx->agg.bt_prio_kill); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg rx_ba_rsp_cnt:", - le32_to_cpu(tx->agg.rx_ba_rsp_cnt), - accum_tx->agg.rx_ba_rsp_cnt, - delta_tx->agg.rx_ba_rsp_cnt, - max_tx->agg.rx_ba_rsp_cnt); - - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -ssize_t -il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - int pos = 0; - char *buf; - int bufsz = sizeof(struct stats_general) * 10 + 300; - ssize_t ret; - struct stats_general_common *general, *accum_general; - struct stats_general_common *delta_general, *max_general; - struct stats_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; - struct stats_div *div, *accum_div, *delta_div, *max_div; - - if (!il_is_alive(il)) - return -EAGAIN; - - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) { - IL_ERR("Can not allocate Buffer\n"); - return -ENOMEM; - } - - /* the statistic information display here is based on - * the last stats notification from uCode - * might not reflect the current uCode activity - */ - general = &il->_4965.stats.general.common; - dbg = &il->_4965.stats.general.common.dbg; - div = &il->_4965.stats.general.common.div; - accum_general = &il->_4965.accum_stats.general.common; - accum_dbg = &il->_4965.accum_stats.general.common.dbg; - accum_div = &il->_4965.accum_stats.general.common.div; - delta_general = &il->_4965.delta_stats.general.common; - max_general = &il->_4965.max_delta.general.common; - delta_dbg = &il->_4965.delta_stats.general.common.dbg; - max_dbg = &il->_4965.max_delta.general.common.dbg; - delta_div = &il->_4965.delta_stats.general.common.div; - max_div = &il->_4965.max_delta.general.common.div; - - pos += il4965_stats_flag(il, buf, bufsz); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_header, "Statistics_General:"); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_value, "temperature:", - le32_to_cpu(general->temperature)); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_value, "ttl_timestamp:", - le32_to_cpu(general->ttl_timestamp)); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "burst_check:", - le32_to_cpu(dbg->burst_check), - accum_dbg->burst_check, - delta_dbg->burst_check, max_dbg->burst_check); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "burst_count:", - le32_to_cpu(dbg->burst_count), - accum_dbg->burst_count, - delta_dbg->burst_count, max_dbg->burst_count); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "wait_for_silence_timeout_count:", - le32_to_cpu(dbg->wait_for_silence_timeout_cnt), - accum_dbg->wait_for_silence_timeout_cnt, - delta_dbg->wait_for_silence_timeout_cnt, - max_dbg->wait_for_silence_timeout_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sleep_time:", - le32_to_cpu(general->sleep_time), - accum_general->sleep_time, - delta_general->sleep_time, max_general->sleep_time); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "slots_out:", - le32_to_cpu(general->slots_out), - accum_general->slots_out, - delta_general->slots_out, max_general->slots_out); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "slots_idle:", - le32_to_cpu(general->slots_idle), - accum_general->slots_idle, - delta_general->slots_idle, max_general->slots_idle); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "tx_on_a:", - le32_to_cpu(div->tx_on_a), accum_div->tx_on_a, - delta_div->tx_on_a, max_div->tx_on_a); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "tx_on_b:", - le32_to_cpu(div->tx_on_b), accum_div->tx_on_b, - delta_div->tx_on_b, max_div->tx_on_b); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "exec_time:", - le32_to_cpu(div->exec_time), accum_div->exec_time, - delta_div->exec_time, max_div->exec_time); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "probe_time:", - le32_to_cpu(div->probe_time), accum_div->probe_time, - delta_div->probe_time, max_div->probe_time); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "rx_enable_counter:", - le32_to_cpu(general->rx_enable_counter), - accum_general->rx_enable_counter, - delta_general->rx_enable_counter, - max_general->rx_enable_counter); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "num_of_sos_states:", - le32_to_cpu(general->num_of_sos_states), - accum_general->num_of_sos_states, - delta_general->num_of_sos_states, - max_general->num_of_sos_states); - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c deleted file mode 100644 index 4a543114372b..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c +++ /dev/null @@ -1,2862 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include "iwl-dev.h" -#include "iwl-sta.h" -#include "iwl-core.h" -#include "iwl-4965.h" - -#define IL4965_RS_NAME "iwl-4965-rs" - -#define NUM_TRY_BEFORE_ANT_TOGGLE 1 -#define IL_NUMBER_TRY 1 -#define IL_HT_NUMBER_TRY 3 - -#define RATE_MAX_WINDOW 62 /* # tx in history win */ -#define RATE_MIN_FAILURE_TH 6 /* min failures to calc tpt */ -#define RATE_MIN_SUCCESS_TH 8 /* min successes to calc tpt */ - -/* max allowed rate miss before sync LQ cmd */ -#define IL_MISSED_RATE_MAX 15 -/* max time to accum history 2 seconds */ -#define RATE_SCALE_FLUSH_INTVL (3*HZ) - -static u8 rs_ht_to_legacy[] = { - RATE_6M_IDX, RATE_6M_IDX, - RATE_6M_IDX, RATE_6M_IDX, - RATE_6M_IDX, - RATE_6M_IDX, RATE_9M_IDX, - RATE_12M_IDX, RATE_18M_IDX, - RATE_24M_IDX, RATE_36M_IDX, - RATE_48M_IDX, RATE_54M_IDX -}; - -static const u8 ant_toggle_lookup[] = { - /*ANT_NONE -> */ ANT_NONE, - /*ANT_A -> */ ANT_B, - /*ANT_B -> */ ANT_C, - /*ANT_AB -> */ ANT_BC, - /*ANT_C -> */ ANT_A, - /*ANT_AC -> */ ANT_AB, - /*ANT_BC -> */ ANT_AC, - /*ANT_ABC -> */ ANT_ABC, -}; - -#define IL_DECLARE_RATE_INFO(r, s, ip, in, rp, rn, pp, np) \ - [RATE_##r##M_IDX] = { RATE_##r##M_PLCP, \ - RATE_SISO_##s##M_PLCP, \ - RATE_MIMO2_##s##M_PLCP,\ - RATE_##r##M_IEEE, \ - RATE_##ip##M_IDX, \ - RATE_##in##M_IDX, \ - RATE_##rp##M_IDX, \ - RATE_##rn##M_IDX, \ - RATE_##pp##M_IDX, \ - RATE_##np##M_IDX } - -/* - * Parameter order: - * rate, ht rate, prev rate, next rate, prev tgg rate, next tgg rate - * - * If there isn't a valid next or previous rate then INV is used which - * maps to RATE_INVALID - * - */ -const struct il_rate_info il_rates[RATE_COUNT] = { - IL_DECLARE_RATE_INFO(1, INV, INV, 2, INV, 2, INV, 2), /* 1mbps */ - IL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ - IL_DECLARE_RATE_INFO(5, INV, 2, 6, 2, 11, 2, 11), /*5.5mbps */ - IL_DECLARE_RATE_INFO(11, INV, 9, 12, 9, 12, 5, 18), /* 11mbps */ - IL_DECLARE_RATE_INFO(6, 6, 5, 9, 5, 11, 5, 11), /* 6mbps */ - IL_DECLARE_RATE_INFO(9, 6, 6, 11, 6, 11, 5, 11), /* 9mbps */ - IL_DECLARE_RATE_INFO(12, 12, 11, 18, 11, 18, 11, 18), /* 12mbps */ - IL_DECLARE_RATE_INFO(18, 18, 12, 24, 12, 24, 11, 24), /* 18mbps */ - IL_DECLARE_RATE_INFO(24, 24, 18, 36, 18, 36, 18, 36), /* 24mbps */ - IL_DECLARE_RATE_INFO(36, 36, 24, 48, 24, 48, 24, 48), /* 36mbps */ - IL_DECLARE_RATE_INFO(48, 48, 36, 54, 36, 54, 36, 54), /* 48mbps */ - IL_DECLARE_RATE_INFO(54, 54, 48, INV, 48, INV, 48, INV),/* 54mbps */ - IL_DECLARE_RATE_INFO(60, 60, 48, INV, 48, INV, 48, INV),/* 60mbps */ -}; - -static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags) -{ - int idx = 0; - - /* HT rate format */ - if (rate_n_flags & RATE_MCS_HT_MSK) { - idx = (rate_n_flags & 0xff); - - if (idx >= RATE_MIMO2_6M_PLCP) - idx = idx - RATE_MIMO2_6M_PLCP; - - idx += IL_FIRST_OFDM_RATE; - /* skip 9M not supported in ht*/ - if (idx >= RATE_9M_IDX) - idx += 1; - if (idx >= IL_FIRST_OFDM_RATE && idx <= IL_LAST_OFDM_RATE) - return idx; - - /* legacy rate format, search for match in table */ - } else { - for (idx = 0; idx < ARRAY_SIZE(il_rates); idx++) - if (il_rates[idx].plcp == (rate_n_flags & 0xFF)) - return idx; - } - - return -1; -} - -static void il4965_rs_rate_scale_perform(struct il_priv *il, - struct sk_buff *skb, - struct ieee80211_sta *sta, - struct il_lq_sta *lq_sta); -static void il4965_rs_fill_link_cmd(struct il_priv *il, - struct il_lq_sta *lq_sta, u32 rate_n_flags); -static void il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, - bool force_search); - -#ifdef CONFIG_MAC80211_DEBUGFS -static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, - u32 *rate_n_flags, int idx); -#else -static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, - u32 *rate_n_flags, int idx) -{} -#endif - -/** - * The following tables contain the expected throughput metrics for all rates - * - * 1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54, 60 MBits - * - * where invalid entries are zeros. - * - * CCK rates are only valid in legacy table and will only be used in G - * (2.4 GHz) band. - */ - -static s32 expected_tpt_legacy[RATE_COUNT] = { - 7, 13, 35, 58, 40, 57, 72, 98, 121, 154, 177, 186, 0 -}; - -static s32 expected_tpt_siso20MHz[4][RATE_COUNT] = { - {0, 0, 0, 0, 42, 0, 76, 102, 124, 158, 183, 193, 202}, /* Norm */ - {0, 0, 0, 0, 46, 0, 82, 110, 132, 167, 192, 202, 210}, /* SGI */ - {0, 0, 0, 0, 48, 0, 93, 135, 176, 251, 319, 351, 381}, /* AGG */ - {0, 0, 0, 0, 53, 0, 102, 149, 193, 275, 348, 381, 413}, /* AGG+SGI */ -}; - -static s32 expected_tpt_siso40MHz[4][RATE_COUNT] = { - {0, 0, 0, 0, 77, 0, 127, 160, 184, 220, 242, 250, 257}, /* Norm */ - {0, 0, 0, 0, 83, 0, 135, 169, 193, 229, 250, 257, 264}, /* SGI */ - {0, 0, 0, 0, 96, 0, 182, 259, 328, 451, 553, 598, 640}, /* AGG */ - {0, 0, 0, 0, 106, 0, 199, 282, 357, 487, 593, 640, 683}, /* AGG+SGI */ -}; - -static s32 expected_tpt_mimo2_20MHz[4][RATE_COUNT] = { - {0, 0, 0, 0, 74, 0, 123, 155, 179, 213, 235, 243, 250}, /* Norm */ - {0, 0, 0, 0, 81, 0, 131, 164, 187, 221, 242, 250, 256}, /* SGI */ - {0, 0, 0, 0, 92, 0, 175, 250, 317, 436, 534, 578, 619}, /* AGG */ - {0, 0, 0, 0, 102, 0, 192, 273, 344, 470, 573, 619, 660}, /* AGG+SGI*/ -}; - -static s32 expected_tpt_mimo2_40MHz[4][RATE_COUNT] = { - {0, 0, 0, 0, 123, 0, 182, 214, 235, 264, 279, 285, 289}, /* Norm */ - {0, 0, 0, 0, 131, 0, 191, 222, 242, 270, 284, 289, 293}, /* SGI */ - {0, 0, 0, 0, 180, 0, 327, 446, 545, 708, 828, 878, 922}, /* AGG */ - {0, 0, 0, 0, 197, 0, 355, 481, 584, 752, 872, 922, 966}, /* AGG+SGI */ -}; - -/* mbps, mcs */ -static const struct il_rate_mcs_info il_rate_mcs[RATE_COUNT] = { - { "1", "BPSK DSSS"}, - { "2", "QPSK DSSS"}, - {"5.5", "BPSK CCK"}, - { "11", "QPSK CCK"}, - { "6", "BPSK 1/2"}, - { "9", "BPSK 1/2"}, - { "12", "QPSK 1/2"}, - { "18", "QPSK 3/4"}, - { "24", "16QAM 1/2"}, - { "36", "16QAM 3/4"}, - { "48", "64QAM 2/3"}, - { "54", "64QAM 3/4"}, - { "60", "64QAM 5/6"}, -}; - -#define MCS_IDX_PER_STREAM (8) - -static inline u8 il4965_rs_extract_rate(u32 rate_n_flags) -{ - return (u8)(rate_n_flags & 0xFF); -} - -static void -il4965_rs_rate_scale_clear_win(struct il_rate_scale_data *win) -{ - win->data = 0; - win->success_counter = 0; - win->success_ratio = IL_INVALID_VALUE; - win->counter = 0; - win->average_tpt = IL_INVALID_VALUE; - win->stamp = 0; -} - -static inline u8 il4965_rs_is_valid_ant(u8 valid_antenna, u8 ant_type) -{ - return (ant_type & valid_antenna) == ant_type; -} - -/* - * removes the old data from the stats. All data that is older than - * TID_MAX_TIME_DIFF, will be deleted. - */ -static void -il4965_rs_tl_rm_old_stats(struct il_traffic_load *tl, u32 curr_time) -{ - /* The oldest age we want to keep */ - u32 oldest_time = curr_time - TID_MAX_TIME_DIFF; - - while (tl->queue_count && tl->time_stamp < oldest_time) { - tl->total -= tl->packet_count[tl->head]; - tl->packet_count[tl->head] = 0; - tl->time_stamp += TID_QUEUE_CELL_SPACING; - tl->queue_count--; - tl->head++; - if (tl->head >= TID_QUEUE_MAX_SIZE) - tl->head = 0; - } -} - -/* - * increment traffic load value for tid and also remove - * any old values if passed the certain time period - */ -static u8 il4965_rs_tl_add_packet(struct il_lq_sta *lq_data, - struct ieee80211_hdr *hdr) -{ - u32 curr_time = jiffies_to_msecs(jiffies); - u32 time_diff; - s32 idx; - struct il_traffic_load *tl = NULL; - u8 tid; - - if (ieee80211_is_data_qos(hdr->frame_control)) { - u8 *qc = ieee80211_get_qos_ctl(hdr); - tid = qc[0] & 0xf; - } else - return MAX_TID_COUNT; - - if (unlikely(tid >= TID_MAX_LOAD_COUNT)) - return MAX_TID_COUNT; - - tl = &lq_data->load[tid]; - - curr_time -= curr_time % TID_ROUND_VALUE; - - /* Happens only for the first packet. Initialize the data */ - if (!(tl->queue_count)) { - tl->total = 1; - tl->time_stamp = curr_time; - tl->queue_count = 1; - tl->head = 0; - tl->packet_count[0] = 1; - return MAX_TID_COUNT; - } - - time_diff = TIME_WRAP_AROUND(tl->time_stamp, curr_time); - idx = time_diff / TID_QUEUE_CELL_SPACING; - - /* The history is too long: remove data that is older than */ - /* TID_MAX_TIME_DIFF */ - if (idx >= TID_QUEUE_MAX_SIZE) - il4965_rs_tl_rm_old_stats(tl, curr_time); - - idx = (tl->head + idx) % TID_QUEUE_MAX_SIZE; - tl->packet_count[idx] = tl->packet_count[idx] + 1; - tl->total = tl->total + 1; - - if ((idx + 1) > tl->queue_count) - tl->queue_count = idx + 1; - - return tid; -} - -/* - get the traffic load value for tid -*/ -static u32 il4965_rs_tl_get_load(struct il_lq_sta *lq_data, u8 tid) -{ - u32 curr_time = jiffies_to_msecs(jiffies); - u32 time_diff; - s32 idx; - struct il_traffic_load *tl = NULL; - - if (tid >= TID_MAX_LOAD_COUNT) - return 0; - - tl = &(lq_data->load[tid]); - - curr_time -= curr_time % TID_ROUND_VALUE; - - if (!(tl->queue_count)) - return 0; - - time_diff = TIME_WRAP_AROUND(tl->time_stamp, curr_time); - idx = time_diff / TID_QUEUE_CELL_SPACING; - - /* The history is too long: remove data that is older than */ - /* TID_MAX_TIME_DIFF */ - if (idx >= TID_QUEUE_MAX_SIZE) - il4965_rs_tl_rm_old_stats(tl, curr_time); - - return tl->total; -} - -static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *il, - struct il_lq_sta *lq_data, u8 tid, - struct ieee80211_sta *sta) -{ - int ret = -EAGAIN; - u32 load; - - load = il4965_rs_tl_get_load(lq_data, tid); - - if (load > IL_AGG_LOAD_THRESHOLD) { - D_HT("Starting Tx agg: STA: %pM tid: %d\n", - sta->addr, tid); - ret = ieee80211_start_tx_ba_session(sta, tid, 5000); - if (ret == -EAGAIN) { - /* - * driver and mac80211 is out of sync - * this might be cause by reloading firmware - * stop the tx ba session here - */ - IL_ERR("Fail start Tx agg on tid: %d\n", - tid); - ieee80211_stop_tx_ba_session(sta, tid); - } - } else { - IL_ERR("Aggregation not enabled for tid %d " - "because load = %u\n", tid, load); - } - return ret; -} - -static void il4965_rs_tl_turn_on_agg(struct il_priv *il, u8 tid, - struct il_lq_sta *lq_data, - struct ieee80211_sta *sta) -{ - if (tid < TID_MAX_LOAD_COUNT) - il4965_rs_tl_turn_on_agg_for_tid(il, lq_data, tid, sta); - else - IL_ERR("tid exceeds max load count: %d/%d\n", - tid, TID_MAX_LOAD_COUNT); -} - -static inline int il4965_get_il4965_num_of_ant_from_rate(u32 rate_n_flags) -{ - return !!(rate_n_flags & RATE_MCS_ANT_A_MSK) + - !!(rate_n_flags & RATE_MCS_ANT_B_MSK) + - !!(rate_n_flags & RATE_MCS_ANT_C_MSK); -} - -/* - * Static function to get the expected throughput from an il_scale_tbl_info - * that wraps a NULL pointer check - */ -static s32 -il4965_get_expected_tpt(struct il_scale_tbl_info *tbl, int rs_idx) -{ - if (tbl->expected_tpt) - return tbl->expected_tpt[rs_idx]; - return 0; -} - -/** - * il4965_rs_collect_tx_data - Update the success/failure sliding win - * - * We keep a sliding win of the last 62 packets transmitted - * at this rate. win->data contains the bitmask of successful - * packets. - */ -static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, - int scale_idx, int attempts, int successes) -{ - struct il_rate_scale_data *win = NULL; - static const u64 mask = (((u64)1) << (RATE_MAX_WINDOW - 1)); - s32 fail_count, tpt; - - if (scale_idx < 0 || scale_idx >= RATE_COUNT) - return -EINVAL; - - /* Select win for current tx bit rate */ - win = &(tbl->win[scale_idx]); - - /* Get expected throughput */ - tpt = il4965_get_expected_tpt(tbl, scale_idx); - - /* - * Keep track of only the latest 62 tx frame attempts in this rate's - * history win; anything older isn't really relevant any more. - * If we have filled up the sliding win, drop the oldest attempt; - * if the oldest attempt (highest bit in bitmap) shows "success", - * subtract "1" from the success counter (this is the main reason - * we keep these bitmaps!). - */ - while (attempts > 0) { - if (win->counter >= RATE_MAX_WINDOW) { - - /* remove earliest */ - win->counter = RATE_MAX_WINDOW - 1; - - if (win->data & mask) { - win->data &= ~mask; - win->success_counter--; - } - } - - /* Increment frames-attempted counter */ - win->counter++; - - /* Shift bitmap by one frame to throw away oldest history */ - win->data <<= 1; - - /* Mark the most recent #successes attempts as successful */ - if (successes > 0) { - win->success_counter++; - win->data |= 0x1; - successes--; - } - - attempts--; - } - - /* Calculate current success ratio, avoid divide-by-0! */ - if (win->counter > 0) - win->success_ratio = 128 * (100 * win->success_counter) - / win->counter; - else - win->success_ratio = IL_INVALID_VALUE; - - fail_count = win->counter - win->success_counter; - - /* Calculate average throughput, if we have enough history. */ - if (fail_count >= RATE_MIN_FAILURE_TH || - win->success_counter >= RATE_MIN_SUCCESS_TH) - win->average_tpt = (win->success_ratio * tpt + 64) / 128; - else - win->average_tpt = IL_INVALID_VALUE; - - /* Tag this win as having been updated */ - win->stamp = jiffies; - - return 0; -} - -/* - * Fill uCode API rate_n_flags field, based on "search" or "active" table. - */ -static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, - struct il_scale_tbl_info *tbl, - int idx, u8 use_green) -{ - u32 rate_n_flags = 0; - - if (is_legacy(tbl->lq_type)) { - rate_n_flags = il_rates[idx].plcp; - if (idx >= IL_FIRST_CCK_RATE && idx <= IL_LAST_CCK_RATE) - rate_n_flags |= RATE_MCS_CCK_MSK; - - } else if (is_Ht(tbl->lq_type)) { - if (idx > IL_LAST_OFDM_RATE) { - IL_ERR("Invalid HT rate idx %d\n", idx); - idx = IL_LAST_OFDM_RATE; - } - rate_n_flags = RATE_MCS_HT_MSK; - - if (is_siso(tbl->lq_type)) - rate_n_flags |= il_rates[idx].plcp_siso; - else - rate_n_flags |= il_rates[idx].plcp_mimo2; - } else { - IL_ERR("Invalid tbl->lq_type %d\n", tbl->lq_type); - } - - rate_n_flags |= ((tbl->ant_type << RATE_MCS_ANT_POS) & - RATE_MCS_ANT_ABC_MSK); - - if (is_Ht(tbl->lq_type)) { - if (tbl->is_ht40) { - if (tbl->is_dup) - rate_n_flags |= RATE_MCS_DUP_MSK; - else - rate_n_flags |= RATE_MCS_HT40_MSK; - } - if (tbl->is_SGI) - rate_n_flags |= RATE_MCS_SGI_MSK; - - if (use_green) { - rate_n_flags |= RATE_MCS_GF_MSK; - if (is_siso(tbl->lq_type) && tbl->is_SGI) { - rate_n_flags &= ~RATE_MCS_SGI_MSK; - IL_ERR("GF was set with SGI:SISO\n"); - } - } - } - return rate_n_flags; -} - -/* - * Interpret uCode API's rate_n_flags format, - * fill "search" or "active" tx mode table. - */ -static int il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, - enum ieee80211_band band, - struct il_scale_tbl_info *tbl, - int *rate_idx) -{ - u32 ant_msk = (rate_n_flags & RATE_MCS_ANT_ABC_MSK); - u8 il4965_num_of_ant = il4965_get_il4965_num_of_ant_from_rate(rate_n_flags); - u8 mcs; - - memset(tbl, 0, sizeof(struct il_scale_tbl_info)); - *rate_idx = il4965_hwrate_to_plcp_idx(rate_n_flags); - - if (*rate_idx == RATE_INVALID) { - *rate_idx = -1; - return -EINVAL; - } - tbl->is_SGI = 0; /* default legacy setup */ - tbl->is_ht40 = 0; - tbl->is_dup = 0; - tbl->ant_type = (ant_msk >> RATE_MCS_ANT_POS); - tbl->lq_type = LQ_NONE; - tbl->max_search = IL_MAX_SEARCH; - - /* legacy rate format */ - if (!(rate_n_flags & RATE_MCS_HT_MSK)) { - if (il4965_num_of_ant == 1) { - if (band == IEEE80211_BAND_5GHZ) - tbl->lq_type = LQ_A; - else - tbl->lq_type = LQ_G; - } - /* HT rate format */ - } else { - if (rate_n_flags & RATE_MCS_SGI_MSK) - tbl->is_SGI = 1; - - if ((rate_n_flags & RATE_MCS_HT40_MSK) || - (rate_n_flags & RATE_MCS_DUP_MSK)) - tbl->is_ht40 = 1; - - if (rate_n_flags & RATE_MCS_DUP_MSK) - tbl->is_dup = 1; - - mcs = il4965_rs_extract_rate(rate_n_flags); - - /* SISO */ - if (mcs <= RATE_SISO_60M_PLCP) { - if (il4965_num_of_ant == 1) - tbl->lq_type = LQ_SISO; /*else NONE*/ - /* MIMO2 */ - } else { - if (il4965_num_of_ant == 2) - tbl->lq_type = LQ_MIMO2; - } - } - return 0; -} - -/* switch to another antenna/antennas and return 1 */ -/* if no other valid antenna found, return 0 */ -static int il4965_rs_toggle_antenna(u32 valid_ant, u32 *rate_n_flags, - struct il_scale_tbl_info *tbl) -{ - u8 new_ant_type; - - if (!tbl->ant_type || tbl->ant_type > ANT_ABC) - return 0; - - if (!il4965_rs_is_valid_ant(valid_ant, tbl->ant_type)) - return 0; - - new_ant_type = ant_toggle_lookup[tbl->ant_type]; - - while (new_ant_type != tbl->ant_type && - !il4965_rs_is_valid_ant(valid_ant, new_ant_type)) - new_ant_type = ant_toggle_lookup[new_ant_type]; - - if (new_ant_type == tbl->ant_type) - return 0; - - tbl->ant_type = new_ant_type; - *rate_n_flags &= ~RATE_MCS_ANT_ABC_MSK; - *rate_n_flags |= new_ant_type << RATE_MCS_ANT_POS; - return 1; -} - -/** - * Green-field mode is valid if the station supports it and - * there are no non-GF stations present in the BSS. - */ -static bool il4965_rs_use_green(struct ieee80211_sta *sta) -{ - struct il_station_priv *sta_priv = (void *)sta->drv_priv; - struct il_rxon_context *ctx = sta_priv->common.ctx; - - return (sta->ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD) && - !(ctx->ht.non_gf_sta_present); -} - -/** - * il4965_rs_get_supported_rates - get the available rates - * - * if management frame or broadcast frame only return - * basic available rates. - * - */ -static u16 il4965_rs_get_supported_rates(struct il_lq_sta *lq_sta, - struct ieee80211_hdr *hdr, - enum il_table_type rate_type) -{ - if (is_legacy(rate_type)) { - return lq_sta->active_legacy_rate; - } else { - if (is_siso(rate_type)) - return lq_sta->active_siso_rate; - else - return lq_sta->active_mimo2_rate; - } -} - -static u16 -il4965_rs_get_adjacent_rate(struct il_priv *il, u8 idx, u16 rate_mask, - int rate_type) -{ - u8 high = RATE_INVALID; - u8 low = RATE_INVALID; - - /* 802.11A or ht walks to the next literal adjacent rate in - * the rate table */ - if (is_a_band(rate_type) || !is_legacy(rate_type)) { - int i; - u32 mask; - - /* Find the previous rate that is in the rate mask */ - i = idx - 1; - for (mask = (1 << i); i >= 0; i--, mask >>= 1) { - if (rate_mask & mask) { - low = i; - break; - } - } - - /* Find the next rate that is in the rate mask */ - i = idx + 1; - for (mask = (1 << i); i < RATE_COUNT; i++, mask <<= 1) { - if (rate_mask & mask) { - high = i; - break; - } - } - - return (high << 8) | low; - } - - low = idx; - while (low != RATE_INVALID) { - low = il_rates[low].prev_rs; - if (low == RATE_INVALID) - break; - if (rate_mask & (1 << low)) - break; - D_RATE("Skipping masked lower rate: %d\n", low); - } - - high = idx; - while (high != RATE_INVALID) { - high = il_rates[high].next_rs; - if (high == RATE_INVALID) - break; - if (rate_mask & (1 << high)) - break; - D_RATE("Skipping masked higher rate: %d\n", high); - } - - return (high << 8) | low; -} - -static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, - struct il_scale_tbl_info *tbl, - u8 scale_idx, u8 ht_possible) -{ - s32 low; - u16 rate_mask; - u16 high_low; - u8 switch_to_legacy = 0; - u8 is_green = lq_sta->is_green; - struct il_priv *il = lq_sta->drv; - - /* check if we need to switch from HT to legacy rates. - * assumption is that mandatory rates (1Mbps or 6Mbps) - * are always supported (spec demand) */ - if (!is_legacy(tbl->lq_type) && (!ht_possible || !scale_idx)) { - switch_to_legacy = 1; - scale_idx = rs_ht_to_legacy[scale_idx]; - if (lq_sta->band == IEEE80211_BAND_5GHZ) - tbl->lq_type = LQ_A; - else - tbl->lq_type = LQ_G; - - if (il4965_num_of_ant(tbl->ant_type) > 1) - tbl->ant_type = - il4965_first_antenna(il->hw_params.valid_tx_ant); - - tbl->is_ht40 = 0; - tbl->is_SGI = 0; - tbl->max_search = IL_MAX_SEARCH; - } - - rate_mask = il4965_rs_get_supported_rates(lq_sta, NULL, tbl->lq_type); - - /* Mask with station rate restriction */ - if (is_legacy(tbl->lq_type)) { - /* supp_rates has no CCK bits in A mode */ - if (lq_sta->band == IEEE80211_BAND_5GHZ) - rate_mask = (u16)(rate_mask & - (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); - else - rate_mask = (u16)(rate_mask & lq_sta->supp_rates); - } - - /* If we switched from HT to legacy, check current rate */ - if (switch_to_legacy && (rate_mask & (1 << scale_idx))) { - low = scale_idx; - goto out; - } - - high_low = il4965_rs_get_adjacent_rate(lq_sta->drv, - scale_idx, rate_mask, - tbl->lq_type); - low = high_low & 0xff; - - if (low == RATE_INVALID) - low = scale_idx; - -out: - return il4965_rate_n_flags_from_tbl(lq_sta->drv, tbl, low, is_green); -} - -/* - * Simple function to compare two rate scale table types - */ -static bool il4965_table_type_matches(struct il_scale_tbl_info *a, - struct il_scale_tbl_info *b) -{ - return (a->lq_type == b->lq_type && a->ant_type == b->ant_type && - a->is_SGI == b->is_SGI); -} - -/* - * mac80211 sends us Tx status - */ -static void -il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, void *il_sta, - struct sk_buff *skb) -{ - int legacy_success; - int retries; - int rs_idx, mac_idx, i; - struct il_lq_sta *lq_sta = il_sta; - struct il_link_quality_cmd *table; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - struct il_priv *il = (struct il_priv *)il_r; - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - enum mac80211_rate_control_flags mac_flags; - u32 tx_rate; - struct il_scale_tbl_info tbl_type; - struct il_scale_tbl_info *curr_tbl, *other_tbl, *tmp_tbl; - struct il_station_priv *sta_priv = (void *)sta->drv_priv; - struct il_rxon_context *ctx = sta_priv->common.ctx; - - D_RATE( - "get frame ack response, update rate scale win\n"); - - /* Treat uninitialized rate scaling data same as non-existing. */ - if (!lq_sta) { - D_RATE("Station rate scaling not created yet.\n"); - return; - } else if (!lq_sta->drv) { - D_RATE("Rate scaling not initialized yet.\n"); - return; - } - - if (!ieee80211_is_data(hdr->frame_control) || - (info->flags & IEEE80211_TX_CTL_NO_ACK)) - return; - - /* This packet was aggregated but doesn't carry status info */ - if ((info->flags & IEEE80211_TX_CTL_AMPDU) && - !(info->flags & IEEE80211_TX_STAT_AMPDU)) - return; - - /* - * Ignore this Tx frame response if its initial rate doesn't match - * that of latest Link Quality command. There may be stragglers - * from a previous Link Quality command, but we're no longer interested - * in those; they're either from the "active" mode while we're trying - * to check "search" mode, or a prior "search" mode after we've moved - * to a new "search" mode (which might become the new "active" mode). - */ - table = &lq_sta->lq; - tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); - il4965_rs_get_tbl_info_from_mcs(tx_rate, - il->band, &tbl_type, &rs_idx); - if (il->band == IEEE80211_BAND_5GHZ) - rs_idx -= IL_FIRST_OFDM_RATE; - mac_flags = info->status.rates[0].flags; - mac_idx = info->status.rates[0].idx; - /* For HT packets, map MCS to PLCP */ - if (mac_flags & IEEE80211_TX_RC_MCS) { - mac_idx &= RATE_MCS_CODE_MSK; /* Remove # of streams */ - if (mac_idx >= (RATE_9M_IDX - IL_FIRST_OFDM_RATE)) - mac_idx++; - /* - * mac80211 HT idx is always zero-idxed; we need to move - * HT OFDM rates after CCK rates in 2.4 GHz band - */ - if (il->band == IEEE80211_BAND_2GHZ) - mac_idx += IL_FIRST_OFDM_RATE; - } - /* Here we actually compare this rate to the latest LQ command */ - if (mac_idx < 0 || - tbl_type.is_SGI != !!(mac_flags & IEEE80211_TX_RC_SHORT_GI) || - tbl_type.is_ht40 != !!(mac_flags & IEEE80211_TX_RC_40_MHZ_WIDTH) || - tbl_type.is_dup != !!(mac_flags & IEEE80211_TX_RC_DUP_DATA) || - tbl_type.ant_type != info->antenna_sel_tx || - !!(tx_rate & RATE_MCS_HT_MSK) != !!(mac_flags & IEEE80211_TX_RC_MCS) || - !!(tx_rate & RATE_MCS_GF_MSK) != !!(mac_flags & IEEE80211_TX_RC_GREEN_FIELD) || - rs_idx != mac_idx) { - D_RATE( - "initial rate %d does not match %d (0x%x)\n", - mac_idx, rs_idx, tx_rate); - /* - * Since rates mis-match, the last LQ command may have failed. - * After IL_MISSED_RATE_MAX mis-matches, resync the uCode with - * ... driver. - */ - lq_sta->missed_rate_counter++; - if (lq_sta->missed_rate_counter > IL_MISSED_RATE_MAX) { - lq_sta->missed_rate_counter = 0; - il_send_lq_cmd(il, ctx, &lq_sta->lq, - CMD_ASYNC, false); - } - /* Regardless, ignore this status info for outdated rate */ - return; - } else - /* Rate did match, so reset the missed_rate_counter */ - lq_sta->missed_rate_counter = 0; - - /* Figure out if rate scale algorithm is in active or search table */ - if (il4965_table_type_matches(&tbl_type, - &(lq_sta->lq_info[lq_sta->active_tbl]))) { - curr_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - other_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); - } else if (il4965_table_type_matches(&tbl_type, - &lq_sta->lq_info[1 - lq_sta->active_tbl])) { - curr_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); - other_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - } else { - D_RATE( - "Neither active nor search matches tx rate\n"); - tmp_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - D_RATE("active- lq:%x, ant:%x, SGI:%d\n", - tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); - tmp_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); - D_RATE("search- lq:%x, ant:%x, SGI:%d\n", - tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); - D_RATE("actual- lq:%x, ant:%x, SGI:%d\n", - tbl_type.lq_type, tbl_type.ant_type, tbl_type.is_SGI); - /* - * no matching table found, let's by-pass the data collection - * and continue to perform rate scale to find the rate table - */ - il4965_rs_stay_in_table(lq_sta, true); - goto done; - } - - /* - * Updating the frame history depends on whether packets were - * aggregated. - * - * For aggregation, all packets were transmitted at the same rate, the - * first idx into rate scale table. - */ - if (info->flags & IEEE80211_TX_STAT_AMPDU) { - tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); - il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, &tbl_type, - &rs_idx); - il4965_rs_collect_tx_data(curr_tbl, rs_idx, - info->status.ampdu_len, - info->status.ampdu_ack_len); - - /* Update success/fail counts if not searching for new mode */ - if (lq_sta->stay_in_tbl) { - lq_sta->total_success += info->status.ampdu_ack_len; - lq_sta->total_failed += (info->status.ampdu_len - - info->status.ampdu_ack_len); - } - } else { - /* - * For legacy, update frame history with for each Tx retry. - */ - retries = info->status.rates[0].count - 1; - /* HW doesn't send more than 15 retries */ - retries = min(retries, 15); - - /* The last transmission may have been successful */ - legacy_success = !!(info->flags & IEEE80211_TX_STAT_ACK); - /* Collect data for each rate used during failed TX attempts */ - for (i = 0; i <= retries; ++i) { - tx_rate = le32_to_cpu(table->rs_table[i].rate_n_flags); - il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, - &tbl_type, &rs_idx); - /* - * Only collect stats if retried rate is in the same RS - * table as active/search. - */ - if (il4965_table_type_matches(&tbl_type, curr_tbl)) - tmp_tbl = curr_tbl; - else if (il4965_table_type_matches(&tbl_type, - other_tbl)) - tmp_tbl = other_tbl; - else - continue; - il4965_rs_collect_tx_data(tmp_tbl, rs_idx, 1, - i < retries ? 0 : legacy_success); - } - - /* Update success/fail counts if not searching for new mode */ - if (lq_sta->stay_in_tbl) { - lq_sta->total_success += legacy_success; - lq_sta->total_failed += retries + (1 - legacy_success); - } - } - /* The last TX rate is cached in lq_sta; it's set in if/else above */ - lq_sta->last_rate_n_flags = tx_rate; -done: - /* See if there's a better rate or modulation mode to try. */ - if (sta && sta->supp_rates[sband->band]) - il4965_rs_rate_scale_perform(il, skb, sta, lq_sta); -} - -/* - * Begin a period of staying with a selected modulation mode. - * Set "stay_in_tbl" flag to prevent any mode switches. - * Set frame tx success limits according to legacy vs. high-throughput, - * and reset overall (spanning all rates) tx success history stats. - * These control how long we stay using same modulation mode before - * searching for a new mode. - */ -static void il4965_rs_set_stay_in_table(struct il_priv *il, u8 is_legacy, - struct il_lq_sta *lq_sta) -{ - D_RATE("we are staying in the same table\n"); - lq_sta->stay_in_tbl = 1; /* only place this gets set */ - if (is_legacy) { - lq_sta->table_count_limit = IL_LEGACY_TBL_COUNT; - lq_sta->max_failure_limit = IL_LEGACY_FAILURE_LIMIT; - lq_sta->max_success_limit = IL_LEGACY_SUCCESS_LIMIT; - } else { - lq_sta->table_count_limit = IL_NONE_LEGACY_TBL_COUNT; - lq_sta->max_failure_limit = IL_NONE_LEGACY_FAILURE_LIMIT; - lq_sta->max_success_limit = IL_NONE_LEGACY_SUCCESS_LIMIT; - } - lq_sta->table_count = 0; - lq_sta->total_failed = 0; - lq_sta->total_success = 0; - lq_sta->flush_timer = jiffies; - lq_sta->action_counter = 0; -} - -/* - * Find correct throughput table for given mode of modulation - */ -static void il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, - struct il_scale_tbl_info *tbl) -{ - /* Used to choose among HT tables */ - s32 (*ht_tbl_pointer)[RATE_COUNT]; - - /* Check for invalid LQ type */ - if (WARN_ON_ONCE(!is_legacy(tbl->lq_type) && !is_Ht(tbl->lq_type))) { - tbl->expected_tpt = expected_tpt_legacy; - return; - } - - /* Legacy rates have only one table */ - if (is_legacy(tbl->lq_type)) { - tbl->expected_tpt = expected_tpt_legacy; - return; - } - - /* Choose among many HT tables depending on number of streams - * (SISO/MIMO2), channel width (20/40), SGI, and aggregation - * status */ - if (is_siso(tbl->lq_type) && (!tbl->is_ht40 || lq_sta->is_dup)) - ht_tbl_pointer = expected_tpt_siso20MHz; - else if (is_siso(tbl->lq_type)) - ht_tbl_pointer = expected_tpt_siso40MHz; - else if (is_mimo2(tbl->lq_type) && (!tbl->is_ht40 || lq_sta->is_dup)) - ht_tbl_pointer = expected_tpt_mimo2_20MHz; - else /* if (is_mimo2(tbl->lq_type)) <-- must be true */ - ht_tbl_pointer = expected_tpt_mimo2_40MHz; - - if (!tbl->is_SGI && !lq_sta->is_agg) /* Normal */ - tbl->expected_tpt = ht_tbl_pointer[0]; - else if (tbl->is_SGI && !lq_sta->is_agg) /* SGI */ - tbl->expected_tpt = ht_tbl_pointer[1]; - else if (!tbl->is_SGI && lq_sta->is_agg) /* AGG */ - tbl->expected_tpt = ht_tbl_pointer[2]; - else /* AGG+SGI */ - tbl->expected_tpt = ht_tbl_pointer[3]; -} - -/* - * Find starting rate for new "search" high-throughput mode of modulation. - * Goal is to find lowest expected rate (under perfect conditions) that is - * above the current measured throughput of "active" mode, to give new mode - * a fair chance to prove itself without too many challenges. - * - * This gets called when transitioning to more aggressive modulation - * (i.e. legacy to SISO or MIMO, or SISO to MIMO), as well as less aggressive - * (i.e. MIMO to SISO). When moving to MIMO, bit rate will typically need - * to decrease to match "active" throughput. When moving from MIMO to SISO, - * bit rate will typically need to increase, but not if performance was bad. - */ -static s32 il4965_rs_get_best_rate(struct il_priv *il, - struct il_lq_sta *lq_sta, - struct il_scale_tbl_info *tbl, /* "search" */ - u16 rate_mask, s8 idx) -{ - /* "active" values */ - struct il_scale_tbl_info *active_tbl = - &(lq_sta->lq_info[lq_sta->active_tbl]); - s32 active_sr = active_tbl->win[idx].success_ratio; - s32 active_tpt = active_tbl->expected_tpt[idx]; - - /* expected "search" throughput */ - s32 *tpt_tbl = tbl->expected_tpt; - - s32 new_rate, high, low, start_hi; - u16 high_low; - s8 rate = idx; - - new_rate = high = low = start_hi = RATE_INVALID; - - for (; ;) { - high_low = il4965_rs_get_adjacent_rate(il, rate, rate_mask, - tbl->lq_type); - - low = high_low & 0xff; - high = (high_low >> 8) & 0xff; - - /* - * Lower the "search" bit rate, to give new "search" mode - * approximately the same throughput as "active" if: - * - * 1) "Active" mode has been working modestly well (but not - * great), and expected "search" throughput (under perfect - * conditions) at candidate rate is above the actual - * measured "active" throughput (but less than expected - * "active" throughput under perfect conditions). - * OR - * 2) "Active" mode has been working perfectly or very well - * and expected "search" throughput (under perfect - * conditions) at candidate rate is above expected - * "active" throughput (under perfect conditions). - */ - if ((100 * tpt_tbl[rate] > lq_sta->last_tpt && - (active_sr > RATE_DECREASE_TH && - active_sr <= RATE_HIGH_TH && - tpt_tbl[rate] <= active_tpt)) || - (active_sr >= RATE_SCALE_SWITCH && - tpt_tbl[rate] > active_tpt)) { - - /* (2nd or later pass) - * If we've already tried to raise the rate, and are - * now trying to lower it, use the higher rate. */ - if (start_hi != RATE_INVALID) { - new_rate = start_hi; - break; - } - - new_rate = rate; - - /* Loop again with lower rate */ - if (low != RATE_INVALID) - rate = low; - - /* Lower rate not available, use the original */ - else - break; - - /* Else try to raise the "search" rate to match "active" */ - } else { - /* (2nd or later pass) - * If we've already tried to lower the rate, and are - * now trying to raise it, use the lower rate. */ - if (new_rate != RATE_INVALID) - break; - - /* Loop again with higher rate */ - else if (high != RATE_INVALID) { - start_hi = high; - rate = high; - - /* Higher rate not available, use the original */ - } else { - new_rate = rate; - break; - } - } - } - - return new_rate; -} - -/* - * Set up search table for MIMO2 - */ -static int il4965_rs_switch_to_mimo2(struct il_priv *il, - struct il_lq_sta *lq_sta, - struct ieee80211_conf *conf, - struct ieee80211_sta *sta, - struct il_scale_tbl_info *tbl, int idx) -{ - u16 rate_mask; - s32 rate; - s8 is_green = lq_sta->is_green; - struct il_station_priv *sta_priv = (void *)sta->drv_priv; - struct il_rxon_context *ctx = sta_priv->common.ctx; - - if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) - return -1; - - if (((sta->ht_cap.cap & IEEE80211_HT_CAP_SM_PS) >> 2) - == WLAN_HT_CAP_SM_PS_STATIC) - return -1; - - /* Need both Tx chains/antennas to support MIMO */ - if (il->hw_params.tx_chains_num < 2) - return -1; - - D_RATE("LQ: try to switch to MIMO2\n"); - - tbl->lq_type = LQ_MIMO2; - tbl->is_dup = lq_sta->is_dup; - tbl->action = 0; - tbl->max_search = IL_MAX_SEARCH; - rate_mask = lq_sta->active_mimo2_rate; - - if (il_is_ht40_tx_allowed(il, ctx, &sta->ht_cap)) - tbl->is_ht40 = 1; - else - tbl->is_ht40 = 0; - - il4965_rs_set_expected_tpt_table(lq_sta, tbl); - - rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, idx); - - D_RATE("LQ: MIMO2 best rate %d mask %X\n", - rate, rate_mask); - if (rate == RATE_INVALID || !((1 << rate) & rate_mask)) { - D_RATE( - "Can't switch with idx %d rate mask %x\n", - rate, rate_mask); - return -1; - } - tbl->current_rate = il4965_rate_n_flags_from_tbl(il, - tbl, rate, is_green); - - D_RATE("LQ: Switch to new mcs %X idx is green %X\n", - tbl->current_rate, is_green); - return 0; -} - -/* - * Set up search table for SISO - */ -static int il4965_rs_switch_to_siso(struct il_priv *il, - struct il_lq_sta *lq_sta, - struct ieee80211_conf *conf, - struct ieee80211_sta *sta, - struct il_scale_tbl_info *tbl, int idx) -{ - u16 rate_mask; - u8 is_green = lq_sta->is_green; - s32 rate; - struct il_station_priv *sta_priv = (void *)sta->drv_priv; - struct il_rxon_context *ctx = sta_priv->common.ctx; - - if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) - return -1; - - D_RATE("LQ: try to switch to SISO\n"); - - tbl->is_dup = lq_sta->is_dup; - tbl->lq_type = LQ_SISO; - tbl->action = 0; - tbl->max_search = IL_MAX_SEARCH; - rate_mask = lq_sta->active_siso_rate; - - if (il_is_ht40_tx_allowed(il, ctx, &sta->ht_cap)) - tbl->is_ht40 = 1; - else - tbl->is_ht40 = 0; - - if (is_green) - tbl->is_SGI = 0; /*11n spec: no SGI in SISO+Greenfield*/ - - il4965_rs_set_expected_tpt_table(lq_sta, tbl); - rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, idx); - - D_RATE("LQ: get best rate %d mask %X\n", rate, rate_mask); - if (rate == RATE_INVALID || !((1 << rate) & rate_mask)) { - D_RATE( - "can not switch with idx %d rate mask %x\n", - rate, rate_mask); - return -1; - } - tbl->current_rate = il4965_rate_n_flags_from_tbl(il, - tbl, rate, is_green); - D_RATE("LQ: Switch to new mcs %X idx is green %X\n", - tbl->current_rate, is_green); - return 0; -} - -/* - * Try to switch to new modulation mode from legacy - */ -static int il4965_rs_move_legacy_other(struct il_priv *il, - struct il_lq_sta *lq_sta, - struct ieee80211_conf *conf, - struct ieee80211_sta *sta, - int idx) -{ - struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - struct il_scale_tbl_info *search_tbl = - &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - struct il_rate_scale_data *win = &(tbl->win[idx]); - u32 sz = (sizeof(struct il_scale_tbl_info) - - (sizeof(struct il_rate_scale_data) * RATE_COUNT)); - u8 start_action; - u8 valid_tx_ant = il->hw_params.valid_tx_ant; - u8 tx_chains_num = il->hw_params.tx_chains_num; - int ret = 0; - u8 update_search_tbl_counter = 0; - - tbl->action = IL_LEGACY_SWITCH_SISO; - - start_action = tbl->action; - for (; ;) { - lq_sta->action_counter++; - switch (tbl->action) { - case IL_LEGACY_SWITCH_ANTENNA1: - case IL_LEGACY_SWITCH_ANTENNA2: - D_RATE("LQ: Legacy toggle Antenna\n"); - - if ((tbl->action == IL_LEGACY_SWITCH_ANTENNA1 && - tx_chains_num <= 1) || - (tbl->action == IL_LEGACY_SWITCH_ANTENNA2 && - tx_chains_num <= 2)) - break; - - /* Don't change antenna if success has been great */ - if (win->success_ratio >= IL_RS_GOOD_RATIO) - break; - - /* Set up search table to try other antenna */ - memcpy(search_tbl, tbl, sz); - - if (il4965_rs_toggle_antenna(valid_tx_ant, - &search_tbl->current_rate, search_tbl)) { - update_search_tbl_counter = 1; - il4965_rs_set_expected_tpt_table(lq_sta, - search_tbl); - goto out; - } - break; - case IL_LEGACY_SWITCH_SISO: - D_RATE("LQ: Legacy switch to SISO\n"); - - /* Set up search table to try SISO */ - memcpy(search_tbl, tbl, sz); - search_tbl->is_SGI = 0; - ret = il4965_rs_switch_to_siso(il, lq_sta, conf, sta, - search_tbl, idx); - if (!ret) { - lq_sta->action_counter = 0; - goto out; - } - - break; - case IL_LEGACY_SWITCH_MIMO2_AB: - case IL_LEGACY_SWITCH_MIMO2_AC: - case IL_LEGACY_SWITCH_MIMO2_BC: - D_RATE("LQ: Legacy switch to MIMO2\n"); - - /* Set up search table to try MIMO */ - memcpy(search_tbl, tbl, sz); - search_tbl->is_SGI = 0; - - if (tbl->action == IL_LEGACY_SWITCH_MIMO2_AB) - search_tbl->ant_type = ANT_AB; - else if (tbl->action == IL_LEGACY_SWITCH_MIMO2_AC) - search_tbl->ant_type = ANT_AC; - else - search_tbl->ant_type = ANT_BC; - - if (!il4965_rs_is_valid_ant(valid_tx_ant, - search_tbl->ant_type)) - break; - - ret = il4965_rs_switch_to_mimo2(il, lq_sta, - conf, sta, - search_tbl, idx); - if (!ret) { - lq_sta->action_counter = 0; - goto out; - } - break; - } - tbl->action++; - if (tbl->action > IL_LEGACY_SWITCH_MIMO2_BC) - tbl->action = IL_LEGACY_SWITCH_ANTENNA1; - - if (tbl->action == start_action) - break; - - } - search_tbl->lq_type = LQ_NONE; - return 0; - -out: - lq_sta->search_better_tbl = 1; - tbl->action++; - if (tbl->action > IL_LEGACY_SWITCH_MIMO2_BC) - tbl->action = IL_LEGACY_SWITCH_ANTENNA1; - if (update_search_tbl_counter) - search_tbl->action = tbl->action; - return 0; - -} - -/* - * Try to switch to new modulation mode from SISO - */ -static int il4965_rs_move_siso_to_other(struct il_priv *il, - struct il_lq_sta *lq_sta, - struct ieee80211_conf *conf, - struct ieee80211_sta *sta, int idx) -{ - u8 is_green = lq_sta->is_green; - struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - struct il_scale_tbl_info *search_tbl = - &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - struct il_rate_scale_data *win = &(tbl->win[idx]); - struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; - u32 sz = (sizeof(struct il_scale_tbl_info) - - (sizeof(struct il_rate_scale_data) * RATE_COUNT)); - u8 start_action; - u8 valid_tx_ant = il->hw_params.valid_tx_ant; - u8 tx_chains_num = il->hw_params.tx_chains_num; - u8 update_search_tbl_counter = 0; - int ret; - - start_action = tbl->action; - - for (;;) { - lq_sta->action_counter++; - switch (tbl->action) { - case IL_SISO_SWITCH_ANTENNA1: - case IL_SISO_SWITCH_ANTENNA2: - D_RATE("LQ: SISO toggle Antenna\n"); - if ((tbl->action == IL_SISO_SWITCH_ANTENNA1 && - tx_chains_num <= 1) || - (tbl->action == IL_SISO_SWITCH_ANTENNA2 && - tx_chains_num <= 2)) - break; - - if (win->success_ratio >= IL_RS_GOOD_RATIO) - break; - - memcpy(search_tbl, tbl, sz); - if (il4965_rs_toggle_antenna(valid_tx_ant, - &search_tbl->current_rate, search_tbl)) { - update_search_tbl_counter = 1; - goto out; - } - break; - case IL_SISO_SWITCH_MIMO2_AB: - case IL_SISO_SWITCH_MIMO2_AC: - case IL_SISO_SWITCH_MIMO2_BC: - D_RATE("LQ: SISO switch to MIMO2\n"); - memcpy(search_tbl, tbl, sz); - search_tbl->is_SGI = 0; - - if (tbl->action == IL_SISO_SWITCH_MIMO2_AB) - search_tbl->ant_type = ANT_AB; - else if (tbl->action == IL_SISO_SWITCH_MIMO2_AC) - search_tbl->ant_type = ANT_AC; - else - search_tbl->ant_type = ANT_BC; - - if (!il4965_rs_is_valid_ant(valid_tx_ant, - search_tbl->ant_type)) - break; - - ret = il4965_rs_switch_to_mimo2(il, lq_sta, - conf, sta, - search_tbl, idx); - if (!ret) - goto out; - break; - case IL_SISO_SWITCH_GI: - if (!tbl->is_ht40 && !(ht_cap->cap & - IEEE80211_HT_CAP_SGI_20)) - break; - if (tbl->is_ht40 && !(ht_cap->cap & - IEEE80211_HT_CAP_SGI_40)) - break; - - D_RATE("LQ: SISO toggle SGI/NGI\n"); - - memcpy(search_tbl, tbl, sz); - if (is_green) { - if (!tbl->is_SGI) - break; - else - IL_ERR( - "SGI was set in GF+SISO\n"); - } - search_tbl->is_SGI = !tbl->is_SGI; - il4965_rs_set_expected_tpt_table(lq_sta, search_tbl); - if (tbl->is_SGI) { - s32 tpt = lq_sta->last_tpt / 100; - if (tpt >= search_tbl->expected_tpt[idx]) - break; - } - search_tbl->current_rate = - il4965_rate_n_flags_from_tbl(il, search_tbl, - idx, is_green); - update_search_tbl_counter = 1; - goto out; - } - tbl->action++; - if (tbl->action > IL_SISO_SWITCH_GI) - tbl->action = IL_SISO_SWITCH_ANTENNA1; - - if (tbl->action == start_action) - break; - } - search_tbl->lq_type = LQ_NONE; - return 0; - - out: - lq_sta->search_better_tbl = 1; - tbl->action++; - if (tbl->action > IL_SISO_SWITCH_GI) - tbl->action = IL_SISO_SWITCH_ANTENNA1; - if (update_search_tbl_counter) - search_tbl->action = tbl->action; - - return 0; -} - -/* - * Try to switch to new modulation mode from MIMO2 - */ -static int il4965_rs_move_mimo2_to_other(struct il_priv *il, - struct il_lq_sta *lq_sta, - struct ieee80211_conf *conf, - struct ieee80211_sta *sta, int idx) -{ - s8 is_green = lq_sta->is_green; - struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - struct il_scale_tbl_info *search_tbl = - &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - struct il_rate_scale_data *win = &(tbl->win[idx]); - struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; - u32 sz = (sizeof(struct il_scale_tbl_info) - - (sizeof(struct il_rate_scale_data) * RATE_COUNT)); - u8 start_action; - u8 valid_tx_ant = il->hw_params.valid_tx_ant; - u8 tx_chains_num = il->hw_params.tx_chains_num; - u8 update_search_tbl_counter = 0; - int ret; - - start_action = tbl->action; - for (;;) { - lq_sta->action_counter++; - switch (tbl->action) { - case IL_MIMO2_SWITCH_ANTENNA1: - case IL_MIMO2_SWITCH_ANTENNA2: - D_RATE("LQ: MIMO2 toggle Antennas\n"); - - if (tx_chains_num <= 2) - break; - - if (win->success_ratio >= IL_RS_GOOD_RATIO) - break; - - memcpy(search_tbl, tbl, sz); - if (il4965_rs_toggle_antenna(valid_tx_ant, - &search_tbl->current_rate, search_tbl)) { - update_search_tbl_counter = 1; - goto out; - } - break; - case IL_MIMO2_SWITCH_SISO_A: - case IL_MIMO2_SWITCH_SISO_B: - case IL_MIMO2_SWITCH_SISO_C: - D_RATE("LQ: MIMO2 switch to SISO\n"); - - /* Set up new search table for SISO */ - memcpy(search_tbl, tbl, sz); - - if (tbl->action == IL_MIMO2_SWITCH_SISO_A) - search_tbl->ant_type = ANT_A; - else if (tbl->action == IL_MIMO2_SWITCH_SISO_B) - search_tbl->ant_type = ANT_B; - else - search_tbl->ant_type = ANT_C; - - if (!il4965_rs_is_valid_ant(valid_tx_ant, - search_tbl->ant_type)) - break; - - ret = il4965_rs_switch_to_siso(il, lq_sta, - conf, sta, - search_tbl, idx); - if (!ret) - goto out; - - break; - - case IL_MIMO2_SWITCH_GI: - if (!tbl->is_ht40 && !(ht_cap->cap & - IEEE80211_HT_CAP_SGI_20)) - break; - if (tbl->is_ht40 && !(ht_cap->cap & - IEEE80211_HT_CAP_SGI_40)) - break; - - D_RATE("LQ: MIMO2 toggle SGI/NGI\n"); - - /* Set up new search table for MIMO2 */ - memcpy(search_tbl, tbl, sz); - search_tbl->is_SGI = !tbl->is_SGI; - il4965_rs_set_expected_tpt_table(lq_sta, search_tbl); - /* - * If active table already uses the fastest possible - * modulation (dual stream with short guard interval), - * and it's working well, there's no need to look - * for a better type of modulation! - */ - if (tbl->is_SGI) { - s32 tpt = lq_sta->last_tpt / 100; - if (tpt >= search_tbl->expected_tpt[idx]) - break; - } - search_tbl->current_rate = - il4965_rate_n_flags_from_tbl(il, search_tbl, - idx, is_green); - update_search_tbl_counter = 1; - goto out; - - } - tbl->action++; - if (tbl->action > IL_MIMO2_SWITCH_GI) - tbl->action = IL_MIMO2_SWITCH_ANTENNA1; - - if (tbl->action == start_action) - break; - } - search_tbl->lq_type = LQ_NONE; - return 0; - out: - lq_sta->search_better_tbl = 1; - tbl->action++; - if (tbl->action > IL_MIMO2_SWITCH_GI) - tbl->action = IL_MIMO2_SWITCH_ANTENNA1; - if (update_search_tbl_counter) - search_tbl->action = tbl->action; - - return 0; - -} - -/* - * Check whether we should continue using same modulation mode, or - * begin search for a new mode, based on: - * 1) # tx successes or failures while using this mode - * 2) # times calling this function - * 3) elapsed time in this mode (not used, for now) - */ -static void -il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) -{ - struct il_scale_tbl_info *tbl; - int i; - int active_tbl; - int flush_interval_passed = 0; - struct il_priv *il; - - il = lq_sta->drv; - active_tbl = lq_sta->active_tbl; - - tbl = &(lq_sta->lq_info[active_tbl]); - - /* If we've been disallowing search, see if we should now allow it */ - if (lq_sta->stay_in_tbl) { - - /* Elapsed time using current modulation mode */ - if (lq_sta->flush_timer) - flush_interval_passed = - time_after(jiffies, - (unsigned long)(lq_sta->flush_timer + - RATE_SCALE_FLUSH_INTVL)); - - /* - * Check if we should allow search for new modulation mode. - * If many frames have failed or succeeded, or we've used - * this same modulation for a long time, allow search, and - * reset history stats that keep track of whether we should - * allow a new search. Also (below) reset all bitmaps and - * stats in active history. - */ - if (force_search || - lq_sta->total_failed > lq_sta->max_failure_limit || - lq_sta->total_success > lq_sta->max_success_limit || - (!lq_sta->search_better_tbl && lq_sta->flush_timer && - flush_interval_passed)) { - D_RATE("LQ: stay is expired %d %d %d\n:", - lq_sta->total_failed, - lq_sta->total_success, - flush_interval_passed); - - /* Allow search for new mode */ - lq_sta->stay_in_tbl = 0; /* only place reset */ - lq_sta->total_failed = 0; - lq_sta->total_success = 0; - lq_sta->flush_timer = 0; - - /* - * Else if we've used this modulation mode enough repetitions - * (regardless of elapsed time or success/failure), reset - * history bitmaps and rate-specific stats for all rates in - * active table. - */ - } else { - lq_sta->table_count++; - if (lq_sta->table_count >= - lq_sta->table_count_limit) { - lq_sta->table_count = 0; - - D_RATE( - "LQ: stay in table clear win\n"); - for (i = 0; i < RATE_COUNT; i++) - il4965_rs_rate_scale_clear_win( - &(tbl->win[i])); - } - } - - /* If transitioning to allow "search", reset all history - * bitmaps and stats in active table (this will become the new - * "search" table). */ - if (!lq_sta->stay_in_tbl) { - for (i = 0; i < RATE_COUNT; i++) - il4965_rs_rate_scale_clear_win( - &(tbl->win[i])); - } - } -} - -/* - * setup rate table in uCode - * return rate_n_flags as used in the table - */ -static u32 il4965_rs_update_rate_tbl(struct il_priv *il, - struct il_rxon_context *ctx, - struct il_lq_sta *lq_sta, - struct il_scale_tbl_info *tbl, - int idx, u8 is_green) -{ - u32 rate; - - /* Update uCode's rate table. */ - rate = il4965_rate_n_flags_from_tbl(il, tbl, idx, is_green); - il4965_rs_fill_link_cmd(il, lq_sta, rate); - il_send_lq_cmd(il, ctx, &lq_sta->lq, CMD_ASYNC, false); - - return rate; -} - -/* - * Do rate scaling and search for new modulation mode. - */ -static void il4965_rs_rate_scale_perform(struct il_priv *il, - struct sk_buff *skb, - struct ieee80211_sta *sta, - struct il_lq_sta *lq_sta) -{ - struct ieee80211_hw *hw = il->hw; - struct ieee80211_conf *conf = &hw->conf; - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; - int low = RATE_INVALID; - int high = RATE_INVALID; - int idx; - int i; - struct il_rate_scale_data *win = NULL; - int current_tpt = IL_INVALID_VALUE; - int low_tpt = IL_INVALID_VALUE; - int high_tpt = IL_INVALID_VALUE; - u32 fail_count; - s8 scale_action = 0; - u16 rate_mask; - u8 update_lq = 0; - struct il_scale_tbl_info *tbl, *tbl1; - u16 rate_scale_idx_msk = 0; - u32 rate; - u8 is_green = 0; - u8 active_tbl = 0; - u8 done_search = 0; - u16 high_low; - s32 sr; - u8 tid = MAX_TID_COUNT; - struct il_tid_data *tid_data; - struct il_station_priv *sta_priv = (void *)sta->drv_priv; - struct il_rxon_context *ctx = sta_priv->common.ctx; - - D_RATE("rate scale calculate new rate for skb\n"); - - /* Send management frames and NO_ACK data using lowest rate. */ - /* TODO: this could probably be improved.. */ - if (!ieee80211_is_data(hdr->frame_control) || - (info->flags & IEEE80211_TX_CTL_NO_ACK)) - return; - - if (!sta || !lq_sta) - return; - - lq_sta->supp_rates = sta->supp_rates[lq_sta->band]; - - tid = il4965_rs_tl_add_packet(lq_sta, hdr); - if (tid != MAX_TID_COUNT && (lq_sta->tx_agg_tid_en & (1 << tid))) { - tid_data = &il->stations[lq_sta->lq.sta_id].tid[tid]; - if (tid_data->agg.state == IL_AGG_OFF) - lq_sta->is_agg = 0; - else - lq_sta->is_agg = 1; - } else - lq_sta->is_agg = 0; - - /* - * Select rate-scale / modulation-mode table to work with in - * the rest of this function: "search" if searching for better - * modulation mode, or "active" if doing rate scaling within a mode. - */ - if (!lq_sta->search_better_tbl) - active_tbl = lq_sta->active_tbl; - else - active_tbl = 1 - lq_sta->active_tbl; - - tbl = &(lq_sta->lq_info[active_tbl]); - if (is_legacy(tbl->lq_type)) - lq_sta->is_green = 0; - else - lq_sta->is_green = il4965_rs_use_green(sta); - is_green = lq_sta->is_green; - - /* current tx rate */ - idx = lq_sta->last_txrate_idx; - - D_RATE("Rate scale idx %d for type %d\n", idx, - tbl->lq_type); - - /* rates available for this association, and for modulation mode */ - rate_mask = il4965_rs_get_supported_rates(lq_sta, hdr, tbl->lq_type); - - D_RATE("mask 0x%04X\n", rate_mask); - - /* mask with station rate restriction */ - if (is_legacy(tbl->lq_type)) { - if (lq_sta->band == IEEE80211_BAND_5GHZ) - /* supp_rates has no CCK bits in A mode */ - rate_scale_idx_msk = (u16) (rate_mask & - (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); - else - rate_scale_idx_msk = (u16) (rate_mask & - lq_sta->supp_rates); - - } else - rate_scale_idx_msk = rate_mask; - - if (!rate_scale_idx_msk) - rate_scale_idx_msk = rate_mask; - - if (!((1 << idx) & rate_scale_idx_msk)) { - IL_ERR("Current Rate is not valid\n"); - if (lq_sta->search_better_tbl) { - /* revert to active table if search table is not valid*/ - tbl->lq_type = LQ_NONE; - lq_sta->search_better_tbl = 0; - tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - /* get "active" rate info */ - idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); - rate = il4965_rs_update_rate_tbl(il, ctx, lq_sta, - tbl, idx, is_green); - } - return; - } - - /* Get expected throughput table and history win for current rate */ - if (!tbl->expected_tpt) { - IL_ERR("tbl->expected_tpt is NULL\n"); - return; - } - - /* force user max rate if set by user */ - if (lq_sta->max_rate_idx != -1 && - lq_sta->max_rate_idx < idx) { - idx = lq_sta->max_rate_idx; - update_lq = 1; - win = &(tbl->win[idx]); - goto lq_update; - } - - win = &(tbl->win[idx]); - - /* - * If there is not enough history to calculate actual average - * throughput, keep analyzing results of more tx frames, without - * changing rate or mode (bypass most of the rest of this function). - * Set up new rate table in uCode only if old rate is not supported - * in current association (use new rate found above). - */ - fail_count = win->counter - win->success_counter; - if (fail_count < RATE_MIN_FAILURE_TH && - win->success_counter < RATE_MIN_SUCCESS_TH) { - D_RATE("LQ: still below TH. succ=%d total=%d " - "for idx %d\n", - win->success_counter, win->counter, idx); - - /* Can't calculate this yet; not enough history */ - win->average_tpt = IL_INVALID_VALUE; - - /* Should we stay with this modulation mode, - * or search for a new one? */ - il4965_rs_stay_in_table(lq_sta, false); - - goto out; - } - /* Else we have enough samples; calculate estimate of - * actual average throughput */ - if (win->average_tpt != ((win->success_ratio * - tbl->expected_tpt[idx] + 64) / 128)) { - IL_ERR( - "expected_tpt should have been calculated by now\n"); - win->average_tpt = ((win->success_ratio * - tbl->expected_tpt[idx] + 64) / 128); - } - - /* If we are searching for better modulation mode, check success. */ - if (lq_sta->search_better_tbl) { - /* If good success, continue using the "search" mode; - * no need to send new link quality command, since we're - * continuing to use the setup that we've been trying. */ - if (win->average_tpt > lq_sta->last_tpt) { - - D_RATE("LQ: SWITCHING TO NEW TBL " - "suc=%d cur-tpt=%d old-tpt=%d\n", - win->success_ratio, - win->average_tpt, - lq_sta->last_tpt); - - if (!is_legacy(tbl->lq_type)) - lq_sta->enable_counter = 1; - - /* Swap tables; "search" becomes "active" */ - lq_sta->active_tbl = active_tbl; - current_tpt = win->average_tpt; - - /* Else poor success; go back to mode in "active" table */ - } else { - - D_RATE("LQ: GOING BACK TO THE OLD TBL " - "suc=%d cur-tpt=%d old-tpt=%d\n", - win->success_ratio, - win->average_tpt, - lq_sta->last_tpt); - - /* Nullify "search" table */ - tbl->lq_type = LQ_NONE; - - /* Revert to "active" table */ - active_tbl = lq_sta->active_tbl; - tbl = &(lq_sta->lq_info[active_tbl]); - - /* Revert to "active" rate and throughput info */ - idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); - current_tpt = lq_sta->last_tpt; - - /* Need to set up a new rate table in uCode */ - update_lq = 1; - } - - /* Either way, we've made a decision; modulation mode - * search is done, allow rate adjustment next time. */ - lq_sta->search_better_tbl = 0; - done_search = 1; /* Don't switch modes below! */ - goto lq_update; - } - - /* (Else) not in search of better modulation mode, try for better - * starting rate, while staying in this mode. */ - high_low = il4965_rs_get_adjacent_rate(il, idx, - rate_scale_idx_msk, - tbl->lq_type); - low = high_low & 0xff; - high = (high_low >> 8) & 0xff; - - /* If user set max rate, dont allow higher than user constrain */ - if (lq_sta->max_rate_idx != -1 && - lq_sta->max_rate_idx < high) - high = RATE_INVALID; - - sr = win->success_ratio; - - /* Collect measured throughputs for current and adjacent rates */ - current_tpt = win->average_tpt; - if (low != RATE_INVALID) - low_tpt = tbl->win[low].average_tpt; - if (high != RATE_INVALID) - high_tpt = tbl->win[high].average_tpt; - - scale_action = 0; - - /* Too many failures, decrease rate */ - if (sr <= RATE_DECREASE_TH || current_tpt == 0) { - D_RATE( - "decrease rate because of low success_ratio\n"); - scale_action = -1; - - /* No throughput measured yet for adjacent rates; try increase. */ - } else if (low_tpt == IL_INVALID_VALUE && - high_tpt == IL_INVALID_VALUE) { - - if (high != RATE_INVALID && sr >= RATE_INCREASE_TH) - scale_action = 1; - else if (low != RATE_INVALID) - scale_action = 0; - } - - /* Both adjacent throughputs are measured, but neither one has better - * throughput; we're using the best rate, don't change it! */ - else if (low_tpt != IL_INVALID_VALUE && high_tpt != IL_INVALID_VALUE && - low_tpt < current_tpt && high_tpt < current_tpt) - scale_action = 0; - - /* At least one adjacent rate's throughput is measured, - * and may have better performance. */ - else { - /* Higher adjacent rate's throughput is measured */ - if (high_tpt != IL_INVALID_VALUE) { - /* Higher rate has better throughput */ - if (high_tpt > current_tpt && - sr >= RATE_INCREASE_TH) { - scale_action = 1; - } else { - scale_action = 0; - } - - /* Lower adjacent rate's throughput is measured */ - } else if (low_tpt != IL_INVALID_VALUE) { - /* Lower rate has better throughput */ - if (low_tpt > current_tpt) { - D_RATE( - "decrease rate because of low tpt\n"); - scale_action = -1; - } else if (sr >= RATE_INCREASE_TH) { - scale_action = 1; - } - } - } - - /* Sanity check; asked for decrease, but success rate or throughput - * has been good at old rate. Don't change it. */ - if (scale_action == -1 && low != RATE_INVALID && - (sr > RATE_HIGH_TH || current_tpt > 100 * tbl->expected_tpt[low])) - scale_action = 0; - - switch (scale_action) { - case -1: - /* Decrease starting rate, update uCode's rate table */ - if (low != RATE_INVALID) { - update_lq = 1; - idx = low; - } - - break; - case 1: - /* Increase starting rate, update uCode's rate table */ - if (high != RATE_INVALID) { - update_lq = 1; - idx = high; - } - - break; - case 0: - /* No change */ - default: - break; - } - - D_RATE("choose rate scale idx %d action %d low %d " - "high %d type %d\n", - idx, scale_action, low, high, tbl->lq_type); - -lq_update: - /* Replace uCode's rate table for the destination station. */ - if (update_lq) - rate = il4965_rs_update_rate_tbl(il, ctx, lq_sta, - tbl, idx, is_green); - - /* Should we stay with this modulation mode, - * or search for a new one? */ - il4965_rs_stay_in_table(lq_sta, false); - - /* - * Search for new modulation mode if we're: - * 1) Not changing rates right now - * 2) Not just finishing up a search - * 3) Allowing a new search - */ - if (!update_lq && !done_search && !lq_sta->stay_in_tbl && - win->counter) { - /* Save current throughput to compare with "search" throughput*/ - lq_sta->last_tpt = current_tpt; - - /* Select a new "search" modulation mode to try. - * If one is found, set up the new "search" table. */ - if (is_legacy(tbl->lq_type)) - il4965_rs_move_legacy_other(il, lq_sta, - conf, sta, idx); - else if (is_siso(tbl->lq_type)) - il4965_rs_move_siso_to_other(il, lq_sta, - conf, sta, idx); - else /* (is_mimo2(tbl->lq_type)) */ - il4965_rs_move_mimo2_to_other(il, lq_sta, - conf, sta, idx); - - /* If new "search" mode was selected, set up in uCode table */ - if (lq_sta->search_better_tbl) { - /* Access the "search" table, clear its history. */ - tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); - for (i = 0; i < RATE_COUNT; i++) - il4965_rs_rate_scale_clear_win( - &(tbl->win[i])); - - /* Use new "search" start rate */ - idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); - - D_RATE( - "Switch current mcs: %X idx: %d\n", - tbl->current_rate, idx); - il4965_rs_fill_link_cmd(il, lq_sta, - tbl->current_rate); - il_send_lq_cmd(il, ctx, - &lq_sta->lq, CMD_ASYNC, false); - } else - done_search = 1; - } - - if (done_search && !lq_sta->stay_in_tbl) { - /* If the "active" (non-search) mode was legacy, - * and we've tried switching antennas, - * but we haven't been able to try HT modes (not available), - * stay with best antenna legacy modulation for a while - * before next round of mode comparisons. */ - tbl1 = &(lq_sta->lq_info[lq_sta->active_tbl]); - if (is_legacy(tbl1->lq_type) && !conf_is_ht(conf) && - lq_sta->action_counter > tbl1->max_search) { - D_RATE("LQ: STAY in legacy table\n"); - il4965_rs_set_stay_in_table(il, 1, lq_sta); - } - - /* If we're in an HT mode, and all 3 mode switch actions - * have been tried and compared, stay in this best modulation - * mode for a while before next round of mode comparisons. */ - if (lq_sta->enable_counter && - lq_sta->action_counter >= tbl1->max_search) { - if (lq_sta->last_tpt > IL_AGG_TPT_THREHOLD && - (lq_sta->tx_agg_tid_en & (1 << tid)) && - tid != MAX_TID_COUNT) { - tid_data = - &il->stations[lq_sta->lq.sta_id].tid[tid]; - if (tid_data->agg.state == IL_AGG_OFF) { - D_RATE( - "try to aggregate tid %d\n", - tid); - il4965_rs_tl_turn_on_agg(il, tid, - lq_sta, sta); - } - } - il4965_rs_set_stay_in_table(il, 0, lq_sta); - } - } - -out: - tbl->current_rate = il4965_rate_n_flags_from_tbl(il, tbl, - idx, is_green); - i = idx; - lq_sta->last_txrate_idx = i; -} - -/** - * il4965_rs_initialize_lq - Initialize a station's hardware rate table - * - * The uCode's station table contains a table of fallback rates - * for automatic fallback during transmission. - * - * NOTE: This sets up a default set of values. These will be replaced later - * if the driver's iwl-4965-rs rate scaling algorithm is used, instead of - * rc80211_simple. - * - * NOTE: Run REPLY_ADD_STA command to set up station table entry, before - * calling this function (which runs REPLY_TX_LINK_QUALITY_CMD, - * which requires station table entry to exist). - */ -static void il4965_rs_initialize_lq(struct il_priv *il, - struct ieee80211_conf *conf, - struct ieee80211_sta *sta, - struct il_lq_sta *lq_sta) -{ - struct il_scale_tbl_info *tbl; - int rate_idx; - int i; - u32 rate; - u8 use_green = il4965_rs_use_green(sta); - u8 active_tbl = 0; - u8 valid_tx_ant; - struct il_station_priv *sta_priv; - struct il_rxon_context *ctx; - - if (!sta || !lq_sta) - return; - - sta_priv = (void *)sta->drv_priv; - ctx = sta_priv->common.ctx; - - i = lq_sta->last_txrate_idx; - - valid_tx_ant = il->hw_params.valid_tx_ant; - - if (!lq_sta->search_better_tbl) - active_tbl = lq_sta->active_tbl; - else - active_tbl = 1 - lq_sta->active_tbl; - - tbl = &(lq_sta->lq_info[active_tbl]); - - if (i < 0 || i >= RATE_COUNT) - i = 0; - - rate = il_rates[i].plcp; - tbl->ant_type = il4965_first_antenna(valid_tx_ant); - rate |= tbl->ant_type << RATE_MCS_ANT_POS; - - if (i >= IL_FIRST_CCK_RATE && i <= IL_LAST_CCK_RATE) - rate |= RATE_MCS_CCK_MSK; - - il4965_rs_get_tbl_info_from_mcs(rate, il->band, tbl, &rate_idx); - if (!il4965_rs_is_valid_ant(valid_tx_ant, tbl->ant_type)) - il4965_rs_toggle_antenna(valid_tx_ant, &rate, tbl); - - rate = il4965_rate_n_flags_from_tbl(il, tbl, rate_idx, use_green); - tbl->current_rate = rate; - il4965_rs_set_expected_tpt_table(lq_sta, tbl); - il4965_rs_fill_link_cmd(NULL, lq_sta, rate); - il->stations[lq_sta->lq.sta_id].lq = &lq_sta->lq; - il_send_lq_cmd(il, ctx, &lq_sta->lq, CMD_SYNC, true); -} - -static void -il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, - struct ieee80211_tx_rate_control *txrc) -{ - - struct sk_buff *skb = txrc->skb; - struct ieee80211_supported_band *sband = txrc->sband; - struct il_priv *il __maybe_unused = (struct il_priv *)il_r; - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - struct il_lq_sta *lq_sta = il_sta; - int rate_idx; - - D_RATE("rate scale calculate new rate for skb\n"); - - /* Get max rate if user set max rate */ - if (lq_sta) { - lq_sta->max_rate_idx = txrc->max_rate_idx; - if (sband->band == IEEE80211_BAND_5GHZ && - lq_sta->max_rate_idx != -1) - lq_sta->max_rate_idx += IL_FIRST_OFDM_RATE; - if (lq_sta->max_rate_idx < 0 || - lq_sta->max_rate_idx >= RATE_COUNT) - lq_sta->max_rate_idx = -1; - } - - /* Treat uninitialized rate scaling data same as non-existing. */ - if (lq_sta && !lq_sta->drv) { - D_RATE("Rate scaling not initialized yet.\n"); - il_sta = NULL; - } - - /* Send management frames and NO_ACK data using lowest rate. */ - if (rate_control_send_low(sta, il_sta, txrc)) - return; - - if (!lq_sta) - return; - - rate_idx = lq_sta->last_txrate_idx; - - if (lq_sta->last_rate_n_flags & RATE_MCS_HT_MSK) { - rate_idx -= IL_FIRST_OFDM_RATE; - /* 6M and 9M shared same MCS idx */ - rate_idx = (rate_idx > 0) ? (rate_idx - 1) : 0; - if (il4965_rs_extract_rate(lq_sta->last_rate_n_flags) >= - RATE_MIMO2_6M_PLCP) - rate_idx = rate_idx + MCS_IDX_PER_STREAM; - info->control.rates[0].flags = IEEE80211_TX_RC_MCS; - if (lq_sta->last_rate_n_flags & RATE_MCS_SGI_MSK) - info->control.rates[0].flags |= - IEEE80211_TX_RC_SHORT_GI; - if (lq_sta->last_rate_n_flags & RATE_MCS_DUP_MSK) - info->control.rates[0].flags |= - IEEE80211_TX_RC_DUP_DATA; - if (lq_sta->last_rate_n_flags & RATE_MCS_HT40_MSK) - info->control.rates[0].flags |= - IEEE80211_TX_RC_40_MHZ_WIDTH; - if (lq_sta->last_rate_n_flags & RATE_MCS_GF_MSK) - info->control.rates[0].flags |= - IEEE80211_TX_RC_GREEN_FIELD; - } else { - /* Check for invalid rates */ - if (rate_idx < 0 || rate_idx >= RATE_COUNT_LEGACY || - (sband->band == IEEE80211_BAND_5GHZ && - rate_idx < IL_FIRST_OFDM_RATE)) - rate_idx = rate_lowest_index(sband, sta); - /* On valid 5 GHz rate, adjust idx */ - else if (sband->band == IEEE80211_BAND_5GHZ) - rate_idx -= IL_FIRST_OFDM_RATE; - info->control.rates[0].flags = 0; - } - info->control.rates[0].idx = rate_idx; - -} - -static void *il4965_rs_alloc_sta(void *il_rate, struct ieee80211_sta *sta, - gfp_t gfp) -{ - struct il_lq_sta *lq_sta; - struct il_station_priv *sta_priv = - (struct il_station_priv *) sta->drv_priv; - struct il_priv *il; - - il = (struct il_priv *)il_rate; - D_RATE("create station rate scale win\n"); - - lq_sta = &sta_priv->lq_sta; - - return lq_sta; -} - -/* - * Called after adding a new station to initialize rate scaling - */ -void -il4965_rs_rate_init(struct il_priv *il, - struct ieee80211_sta *sta, - u8 sta_id) -{ - int i, j; - struct ieee80211_hw *hw = il->hw; - struct ieee80211_conf *conf = &il->hw->conf; - struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; - struct il_station_priv *sta_priv; - struct il_lq_sta *lq_sta; - struct ieee80211_supported_band *sband; - - sta_priv = (struct il_station_priv *) sta->drv_priv; - lq_sta = &sta_priv->lq_sta; - sband = hw->wiphy->bands[conf->channel->band]; - - - lq_sta->lq.sta_id = sta_id; - - for (j = 0; j < LQ_SIZE; j++) - for (i = 0; i < RATE_COUNT; i++) - il4965_rs_rate_scale_clear_win( - &lq_sta->lq_info[j].win[i]); - - lq_sta->flush_timer = 0; - lq_sta->supp_rates = sta->supp_rates[sband->band]; - for (j = 0; j < LQ_SIZE; j++) - for (i = 0; i < RATE_COUNT; i++) - il4965_rs_rate_scale_clear_win( - &lq_sta->lq_info[j].win[i]); - - D_RATE("LQ:" - "*** rate scale station global init for station %d ***\n", - sta_id); - /* TODO: what is a good starting rate for STA? About middle? Maybe not - * the lowest or the highest rate.. Could consider using RSSI from - * previous packets? Need to have IEEE 802.1X auth succeed immediately - * after assoc.. */ - - lq_sta->is_dup = 0; - lq_sta->max_rate_idx = -1; - lq_sta->missed_rate_counter = IL_MISSED_RATE_MAX; - lq_sta->is_green = il4965_rs_use_green(sta); - lq_sta->active_legacy_rate = il->active_rate & ~(0x1000); - lq_sta->band = il->band; - /* - * active_siso_rate mask includes 9 MBits (bit 5), and CCK (bits 0-3), - * supp_rates[] does not; shift to convert format, force 9 MBits off. - */ - lq_sta->active_siso_rate = ht_cap->mcs.rx_mask[0] << 1; - lq_sta->active_siso_rate |= ht_cap->mcs.rx_mask[0] & 0x1; - lq_sta->active_siso_rate &= ~((u16)0x2); - lq_sta->active_siso_rate <<= IL_FIRST_OFDM_RATE; - - /* Same here */ - lq_sta->active_mimo2_rate = ht_cap->mcs.rx_mask[1] << 1; - lq_sta->active_mimo2_rate |= ht_cap->mcs.rx_mask[1] & 0x1; - lq_sta->active_mimo2_rate &= ~((u16)0x2); - lq_sta->active_mimo2_rate <<= IL_FIRST_OFDM_RATE; - - /* These values will be overridden later */ - lq_sta->lq.general_params.single_stream_ant_msk = - il4965_first_antenna(il->hw_params.valid_tx_ant); - lq_sta->lq.general_params.dual_stream_ant_msk = - il->hw_params.valid_tx_ant & - ~il4965_first_antenna(il->hw_params.valid_tx_ant); - if (!lq_sta->lq.general_params.dual_stream_ant_msk) { - lq_sta->lq.general_params.dual_stream_ant_msk = ANT_AB; - } else if (il4965_num_of_ant(il->hw_params.valid_tx_ant) == 2) { - lq_sta->lq.general_params.dual_stream_ant_msk = - il->hw_params.valid_tx_ant; - } - - /* as default allow aggregation for all tids */ - lq_sta->tx_agg_tid_en = IL_AGG_ALL_TID; - lq_sta->drv = il; - - /* Set last_txrate_idx to lowest rate */ - lq_sta->last_txrate_idx = rate_lowest_index(sband, sta); - if (sband->band == IEEE80211_BAND_5GHZ) - lq_sta->last_txrate_idx += IL_FIRST_OFDM_RATE; - lq_sta->is_agg = 0; - -#ifdef CONFIG_MAC80211_DEBUGFS - lq_sta->dbg_fixed_rate = 0; -#endif - - il4965_rs_initialize_lq(il, conf, sta, lq_sta); -} - -static void il4965_rs_fill_link_cmd(struct il_priv *il, - struct il_lq_sta *lq_sta, u32 new_rate) -{ - struct il_scale_tbl_info tbl_type; - int idx = 0; - int rate_idx; - int repeat_rate = 0; - u8 ant_toggle_cnt = 0; - u8 use_ht_possible = 1; - u8 valid_tx_ant = 0; - struct il_link_quality_cmd *lq_cmd = &lq_sta->lq; - - /* Override starting rate (idx 0) if needed for debug purposes */ - il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, idx); - - /* Interpret new_rate (rate_n_flags) */ - il4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, - &tbl_type, &rate_idx); - - /* How many times should we repeat the initial rate? */ - if (is_legacy(tbl_type.lq_type)) { - ant_toggle_cnt = 1; - repeat_rate = IL_NUMBER_TRY; - } else { - repeat_rate = IL_HT_NUMBER_TRY; - } - - lq_cmd->general_params.mimo_delimiter = - is_mimo(tbl_type.lq_type) ? 1 : 0; - - /* Fill 1st table entry (idx 0) */ - lq_cmd->rs_table[idx].rate_n_flags = cpu_to_le32(new_rate); - - if (il4965_num_of_ant(tbl_type.ant_type) == 1) { - lq_cmd->general_params.single_stream_ant_msk = - tbl_type.ant_type; - } else if (il4965_num_of_ant(tbl_type.ant_type) == 2) { - lq_cmd->general_params.dual_stream_ant_msk = - tbl_type.ant_type; - } /* otherwise we don't modify the existing value */ - - idx++; - repeat_rate--; - if (il) - valid_tx_ant = il->hw_params.valid_tx_ant; - - /* Fill rest of rate table */ - while (idx < LINK_QUAL_MAX_RETRY_NUM) { - /* Repeat initial/next rate. - * For legacy IL_NUMBER_TRY == 1, this loop will not execute. - * For HT IL_HT_NUMBER_TRY == 3, this executes twice. */ - while (repeat_rate > 0 && idx < LINK_QUAL_MAX_RETRY_NUM) { - if (is_legacy(tbl_type.lq_type)) { - if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE) - ant_toggle_cnt++; - else if (il && - il4965_rs_toggle_antenna(valid_tx_ant, - &new_rate, &tbl_type)) - ant_toggle_cnt = 1; - } - - /* Override next rate if needed for debug purposes */ - il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, idx); - - /* Fill next table entry */ - lq_cmd->rs_table[idx].rate_n_flags = - cpu_to_le32(new_rate); - repeat_rate--; - idx++; - } - - il4965_rs_get_tbl_info_from_mcs(new_rate, - lq_sta->band, &tbl_type, - &rate_idx); - - /* Indicate to uCode which entries might be MIMO. - * If initial rate was MIMO, this will finally end up - * as (IL_HT_NUMBER_TRY * 2), after 2nd pass, otherwise 0. */ - if (is_mimo(tbl_type.lq_type)) - lq_cmd->general_params.mimo_delimiter = idx; - - /* Get next rate */ - new_rate = il4965_rs_get_lower_rate(lq_sta, - &tbl_type, rate_idx, - use_ht_possible); - - /* How many times should we repeat the next rate? */ - if (is_legacy(tbl_type.lq_type)) { - if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE) - ant_toggle_cnt++; - else if (il && - il4965_rs_toggle_antenna(valid_tx_ant, - &new_rate, &tbl_type)) - ant_toggle_cnt = 1; - - repeat_rate = IL_NUMBER_TRY; - } else { - repeat_rate = IL_HT_NUMBER_TRY; - } - - /* Don't allow HT rates after next pass. - * il4965_rs_get_lower_rate() will change type to LQ_A or LQ_G. */ - use_ht_possible = 0; - - /* Override next rate if needed for debug purposes */ - il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, idx); - - /* Fill next table entry */ - lq_cmd->rs_table[idx].rate_n_flags = cpu_to_le32(new_rate); - - idx++; - repeat_rate--; - } - - lq_cmd->agg_params.agg_frame_cnt_limit = LINK_QUAL_AGG_FRAME_LIMIT_DEF; - lq_cmd->agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF; - - lq_cmd->agg_params.agg_time_limit = - cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF); -} - -static void -*il4965_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) -{ - return hw->priv; -} -/* rate scale requires free function to be implemented */ -static void il4965_rs_free(void *il_rate) -{ - return; -} - -static void il4965_rs_free_sta(void *il_r, struct ieee80211_sta *sta, - void *il_sta) -{ - struct il_priv *il __maybe_unused = il_r; - - D_RATE("enter\n"); - D_RATE("leave\n"); -} - - -#ifdef CONFIG_MAC80211_DEBUGFS -static int il4965_open_file_generic(struct inode *inode, struct file *file) -{ - file->private_data = inode->i_private; - return 0; -} -static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, - u32 *rate_n_flags, int idx) -{ - struct il_priv *il; - u8 valid_tx_ant; - u8 ant_sel_tx; - - il = lq_sta->drv; - valid_tx_ant = il->hw_params.valid_tx_ant; - if (lq_sta->dbg_fixed_rate) { - ant_sel_tx = - ((lq_sta->dbg_fixed_rate & RATE_MCS_ANT_ABC_MSK) - >> RATE_MCS_ANT_POS); - if ((valid_tx_ant & ant_sel_tx) == ant_sel_tx) { - *rate_n_flags = lq_sta->dbg_fixed_rate; - D_RATE("Fixed rate ON\n"); - } else { - lq_sta->dbg_fixed_rate = 0; - IL_ERR( - "Invalid antenna selection 0x%X, Valid is 0x%X\n", - ant_sel_tx, valid_tx_ant); - D_RATE("Fixed rate OFF\n"); - } - } else { - D_RATE("Fixed rate OFF\n"); - } -} - -static ssize_t il4965_rs_sta_dbgfs_scale_table_write(struct file *file, - const char __user *user_buf, size_t count, loff_t *ppos) -{ - struct il_lq_sta *lq_sta = file->private_data; - struct il_priv *il; - char buf[64]; - size_t buf_size; - u32 parsed_rate; - struct il_station_priv *sta_priv = - container_of(lq_sta, struct il_station_priv, lq_sta); - struct il_rxon_context *ctx = sta_priv->common.ctx; - - il = lq_sta->drv; - memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - - if (sscanf(buf, "%x", &parsed_rate) == 1) - lq_sta->dbg_fixed_rate = parsed_rate; - else - lq_sta->dbg_fixed_rate = 0; - - lq_sta->active_legacy_rate = 0x0FFF; /* 1 - 54 MBits, includes CCK */ - lq_sta->active_siso_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ - lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ - - D_RATE("sta_id %d rate 0x%X\n", - lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate); - - if (lq_sta->dbg_fixed_rate) { - il4965_rs_fill_link_cmd(NULL, lq_sta, lq_sta->dbg_fixed_rate); - il_send_lq_cmd(lq_sta->drv, ctx, &lq_sta->lq, CMD_ASYNC, - false); - } - - return count; -} - -static ssize_t il4965_rs_sta_dbgfs_scale_table_read(struct file *file, - char __user *user_buf, size_t count, loff_t *ppos) -{ - char *buff; - int desc = 0; - int i = 0; - int idx = 0; - ssize_t ret; - - struct il_lq_sta *lq_sta = file->private_data; - struct il_priv *il; - struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - - il = lq_sta->drv; - buff = kmalloc(1024, GFP_KERNEL); - if (!buff) - return -ENOMEM; - - desc += sprintf(buff+desc, "sta_id %d\n", lq_sta->lq.sta_id); - desc += sprintf(buff+desc, "failed=%d success=%d rate=0%X\n", - lq_sta->total_failed, lq_sta->total_success, - lq_sta->active_legacy_rate); - desc += sprintf(buff+desc, "fixed rate 0x%X\n", - lq_sta->dbg_fixed_rate); - desc += sprintf(buff+desc, "valid_tx_ant %s%s%s\n", - (il->hw_params.valid_tx_ant & ANT_A) ? "ANT_A," : "", - (il->hw_params.valid_tx_ant & ANT_B) ? "ANT_B," : "", - (il->hw_params.valid_tx_ant & ANT_C) ? "ANT_C" : ""); - desc += sprintf(buff+desc, "lq type %s\n", - (is_legacy(tbl->lq_type)) ? "legacy" : "HT"); - if (is_Ht(tbl->lq_type)) { - desc += sprintf(buff+desc, " %s", - (is_siso(tbl->lq_type)) ? "SISO" : "MIMO2"); - desc += sprintf(buff+desc, " %s", - (tbl->is_ht40) ? "40MHz" : "20MHz"); - desc += sprintf(buff+desc, " %s %s %s\n", - (tbl->is_SGI) ? "SGI" : "", - (lq_sta->is_green) ? "GF enabled" : "", - (lq_sta->is_agg) ? "AGG on" : ""); - } - desc += sprintf(buff+desc, "last tx rate=0x%X\n", - lq_sta->last_rate_n_flags); - desc += sprintf(buff+desc, "general:" - "flags=0x%X mimo-d=%d s-ant0x%x d-ant=0x%x\n", - lq_sta->lq.general_params.flags, - lq_sta->lq.general_params.mimo_delimiter, - lq_sta->lq.general_params.single_stream_ant_msk, - lq_sta->lq.general_params.dual_stream_ant_msk); - - desc += sprintf(buff+desc, "agg:" - "time_limit=%d dist_start_th=%d frame_cnt_limit=%d\n", - le16_to_cpu(lq_sta->lq.agg_params.agg_time_limit), - lq_sta->lq.agg_params.agg_dis_start_th, - lq_sta->lq.agg_params.agg_frame_cnt_limit); - - desc += sprintf(buff+desc, - "Start idx [0]=0x%x [1]=0x%x [2]=0x%x [3]=0x%x\n", - lq_sta->lq.general_params.start_rate_idx[0], - lq_sta->lq.general_params.start_rate_idx[1], - lq_sta->lq.general_params.start_rate_idx[2], - lq_sta->lq.general_params.start_rate_idx[3]); - - for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { - idx = il4965_hwrate_to_plcp_idx( - le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags)); - if (is_legacy(tbl->lq_type)) { - desc += sprintf(buff+desc, " rate[%d] 0x%X %smbps\n", - i, - le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags), - il_rate_mcs[idx].mbps); - } else { - desc += sprintf(buff+desc, - " rate[%d] 0x%X %smbps (%s)\n", - i, - le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags), - il_rate_mcs[idx].mbps, il_rate_mcs[idx].mcs); - } - } - - ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); - kfree(buff); - return ret; -} - -static const struct file_operations rs_sta_dbgfs_scale_table_ops = { - .write = il4965_rs_sta_dbgfs_scale_table_write, - .read = il4965_rs_sta_dbgfs_scale_table_read, - .open = il4965_open_file_generic, - .llseek = default_llseek, -}; -static ssize_t il4965_rs_sta_dbgfs_stats_table_read(struct file *file, - char __user *user_buf, size_t count, loff_t *ppos) -{ - char *buff; - int desc = 0; - int i, j; - ssize_t ret; - - struct il_lq_sta *lq_sta = file->private_data; - - buff = kmalloc(1024, GFP_KERNEL); - if (!buff) - return -ENOMEM; - - for (i = 0; i < LQ_SIZE; i++) { - desc += sprintf(buff+desc, - "%s type=%d SGI=%d HT40=%d DUP=%d GF=%d\n" - "rate=0x%X\n", - lq_sta->active_tbl == i ? "*" : "x", - lq_sta->lq_info[i].lq_type, - lq_sta->lq_info[i].is_SGI, - lq_sta->lq_info[i].is_ht40, - lq_sta->lq_info[i].is_dup, - lq_sta->is_green, - lq_sta->lq_info[i].current_rate); - for (j = 0; j < RATE_COUNT; j++) { - desc += sprintf(buff+desc, - "counter=%d success=%d %%=%d\n", - lq_sta->lq_info[i].win[j].counter, - lq_sta->lq_info[i].win[j].success_counter, - lq_sta->lq_info[i].win[j].success_ratio); - } - } - ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); - kfree(buff); - return ret; -} - -static const struct file_operations rs_sta_dbgfs_stats_table_ops = { - .read = il4965_rs_sta_dbgfs_stats_table_read, - .open = il4965_open_file_generic, - .llseek = default_llseek, -}; - -static ssize_t il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, - char __user *user_buf, size_t count, loff_t *ppos) -{ - char buff[120]; - int desc = 0; - ssize_t ret; - - struct il_lq_sta *lq_sta = file->private_data; - struct il_priv *il; - struct il_scale_tbl_info *tbl = &lq_sta->lq_info[lq_sta->active_tbl]; - - il = lq_sta->drv; - - if (is_Ht(tbl->lq_type)) - desc += sprintf(buff+desc, - "Bit Rate= %d Mb/s\n", - tbl->expected_tpt[lq_sta->last_txrate_idx]); - else - desc += sprintf(buff+desc, - "Bit Rate= %d Mb/s\n", - il_rates[lq_sta->last_txrate_idx].ieee >> 1); - - ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); - return ret; -} - -static const struct file_operations rs_sta_dbgfs_rate_scale_data_ops = { - .read = il4965_rs_sta_dbgfs_rate_scale_data_read, - .open = il4965_open_file_generic, - .llseek = default_llseek, -}; - -static void il4965_rs_add_debugfs(void *il, void *il_sta, - struct dentry *dir) -{ - struct il_lq_sta *lq_sta = il_sta; - lq_sta->rs_sta_dbgfs_scale_table_file = - debugfs_create_file("rate_scale_table", S_IRUSR | S_IWUSR, dir, - lq_sta, &rs_sta_dbgfs_scale_table_ops); - lq_sta->rs_sta_dbgfs_stats_table_file = - debugfs_create_file("rate_stats_table", S_IRUSR, dir, - lq_sta, &rs_sta_dbgfs_stats_table_ops); - lq_sta->rs_sta_dbgfs_rate_scale_data_file = - debugfs_create_file("rate_scale_data", S_IRUSR, dir, - lq_sta, &rs_sta_dbgfs_rate_scale_data_ops); - lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file = - debugfs_create_u8("tx_agg_tid_enable", S_IRUSR | S_IWUSR, dir, - &lq_sta->tx_agg_tid_en); - -} - -static void il4965_rs_remove_debugfs(void *il, void *il_sta) -{ - struct il_lq_sta *lq_sta = il_sta; - debugfs_remove(lq_sta->rs_sta_dbgfs_scale_table_file); - debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file); - debugfs_remove(lq_sta->rs_sta_dbgfs_rate_scale_data_file); - debugfs_remove(lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file); -} -#endif - -/* - * Initialization of rate scaling information is done by driver after - * the station is added. Since mac80211 calls this function before a - * station is added we ignore it. - */ -static void -il4965_rs_rate_init_stub(void *il_r, struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, void *il_sta) -{ -} -static struct rate_control_ops rs_4965_ops = { - .module = NULL, - .name = IL4965_RS_NAME, - .tx_status = il4965_rs_tx_status, - .get_rate = il4965_rs_get_rate, - .rate_init = il4965_rs_rate_init_stub, - .alloc = il4965_rs_alloc, - .free = il4965_rs_free, - .alloc_sta = il4965_rs_alloc_sta, - .free_sta = il4965_rs_free_sta, -#ifdef CONFIG_MAC80211_DEBUGFS - .add_sta_debugfs = il4965_rs_add_debugfs, - .remove_sta_debugfs = il4965_rs_remove_debugfs, -#endif -}; - -int il4965_rate_control_register(void) -{ - return ieee80211_rate_control_register(&rs_4965_ops); -} - -void il4965_rate_control_unregister(void) -{ - ieee80211_rate_control_unregister(&rs_4965_ops); -} -- cgit v1.2.3 From ccf5533ec4cdf792ec17c375b1186cfed4086f2a Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 6 Sep 2011 12:28:10 +0200 Subject: iwlegacy: rename iwl-3945-{rs,debugfs}.c to 3945-{rs,debug}.c Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/3945-debug.c | 523 ++++++++++++ drivers/net/wireless/iwlegacy/3945-rs.c | 996 +++++++++++++++++++++++ drivers/net/wireless/iwlegacy/Makefile | 4 +- drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c | 523 ------------ drivers/net/wireless/iwlegacy/iwl-3945-rs.c | 996 ----------------------- 5 files changed, 1521 insertions(+), 1521 deletions(-) create mode 100644 drivers/net/wireless/iwlegacy/3945-debug.c create mode 100644 drivers/net/wireless/iwlegacy/3945-rs.c delete mode 100644 drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c delete mode 100644 drivers/net/wireless/iwlegacy/iwl-3945-rs.c (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/3945-debug.c b/drivers/net/wireless/iwlegacy/3945-debug.c new file mode 100644 index 000000000000..88b3d8fc38f8 --- /dev/null +++ b/drivers/net/wireless/iwlegacy/3945-debug.c @@ -0,0 +1,523 @@ +/****************************************************************************** + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, + * USA + * + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + *****************************************************************************/ + +#include "iwl-3945-debugfs.h" + + +static int il3945_stats_flag(struct il_priv *il, char *buf, int bufsz) +{ + int p = 0; + + p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", + le32_to_cpu(il->_3945.stats.flag)); + if (le32_to_cpu(il->_3945.stats.flag) & + UCODE_STATISTICS_CLEAR_MSK) + p += scnprintf(buf + p, bufsz - p, + "\tStatistics have been cleared\n"); + p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n", + (le32_to_cpu(il->_3945.stats.flag) & + UCODE_STATISTICS_FREQUENCY_MSK) + ? "2.4 GHz" : "5.2 GHz"); + p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n", + (le32_to_cpu(il->_3945.stats.flag) & + UCODE_STATISTICS_NARROW_BAND_MSK) + ? "enabled" : "disabled"); + return p; +} + +ssize_t il3945_ucode_rx_stats_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + int pos = 0; + char *buf; + int bufsz = sizeof(struct iwl39_stats_rx_phy) * 40 + + sizeof(struct iwl39_stats_rx_non_phy) * 40 + 400; + ssize_t ret; + struct iwl39_stats_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, + *max_ofdm; + struct iwl39_stats_rx_phy *cck, *accum_cck, *delta_cck, *max_cck; + struct iwl39_stats_rx_non_phy *general, *accum_general; + struct iwl39_stats_rx_non_phy *delta_general, *max_general; + + if (!il_is_alive(il)) + return -EAGAIN; + + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) { + IL_ERR("Can not allocate Buffer\n"); + return -ENOMEM; + } + + /* + * The statistic information display here is based on + * the last stats notification from uCode + * might not reflect the current uCode activity + */ + ofdm = &il->_3945.stats.rx.ofdm; + cck = &il->_3945.stats.rx.cck; + general = &il->_3945.stats.rx.general; + accum_ofdm = &il->_3945.accum_stats.rx.ofdm; + accum_cck = &il->_3945.accum_stats.rx.cck; + accum_general = &il->_3945.accum_stats.rx.general; + delta_ofdm = &il->_3945.delta_stats.rx.ofdm; + delta_cck = &il->_3945.delta_stats.rx.cck; + delta_general = &il->_3945.delta_stats.rx.general; + max_ofdm = &il->_3945.max_delta.rx.ofdm; + max_cck = &il->_3945.max_delta.rx.cck; + max_general = &il->_3945.max_delta.rx.general; + + pos += il3945_stats_flag(il, buf, bufsz); + pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" + "acumulative delta max\n", + "Statistics_Rx - OFDM:"); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "ina_cnt:", le32_to_cpu(ofdm->ina_cnt), + accum_ofdm->ina_cnt, + delta_ofdm->ina_cnt, max_ofdm->ina_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "fina_cnt:", + le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt, + delta_ofdm->fina_cnt, max_ofdm->fina_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "plcp_err:", + le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err, + delta_ofdm->plcp_err, max_ofdm->plcp_err); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "crc32_err:", + le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err, + delta_ofdm->crc32_err, max_ofdm->crc32_err); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "overrun_err:", + le32_to_cpu(ofdm->overrun_err), + accum_ofdm->overrun_err, delta_ofdm->overrun_err, + max_ofdm->overrun_err); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "early_overrun_err:", + le32_to_cpu(ofdm->early_overrun_err), + accum_ofdm->early_overrun_err, + delta_ofdm->early_overrun_err, + max_ofdm->early_overrun_err); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "crc32_good:", le32_to_cpu(ofdm->crc32_good), + accum_ofdm->crc32_good, delta_ofdm->crc32_good, + max_ofdm->crc32_good); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "false_alarm_cnt:", + le32_to_cpu(ofdm->false_alarm_cnt), + accum_ofdm->false_alarm_cnt, + delta_ofdm->false_alarm_cnt, + max_ofdm->false_alarm_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "fina_sync_err_cnt:", + le32_to_cpu(ofdm->fina_sync_err_cnt), + accum_ofdm->fina_sync_err_cnt, + delta_ofdm->fina_sync_err_cnt, + max_ofdm->fina_sync_err_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "sfd_timeout:", + le32_to_cpu(ofdm->sfd_timeout), + accum_ofdm->sfd_timeout, + delta_ofdm->sfd_timeout, + max_ofdm->sfd_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "fina_timeout:", + le32_to_cpu(ofdm->fina_timeout), + accum_ofdm->fina_timeout, + delta_ofdm->fina_timeout, + max_ofdm->fina_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "unresponded_rts:", + le32_to_cpu(ofdm->unresponded_rts), + accum_ofdm->unresponded_rts, + delta_ofdm->unresponded_rts, + max_ofdm->unresponded_rts); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "rxe_frame_lmt_ovrun:", + le32_to_cpu(ofdm->rxe_frame_limit_overrun), + accum_ofdm->rxe_frame_limit_overrun, + delta_ofdm->rxe_frame_limit_overrun, + max_ofdm->rxe_frame_limit_overrun); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "sent_ack_cnt:", + le32_to_cpu(ofdm->sent_ack_cnt), + accum_ofdm->sent_ack_cnt, + delta_ofdm->sent_ack_cnt, + max_ofdm->sent_ack_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "sent_cts_cnt:", + le32_to_cpu(ofdm->sent_cts_cnt), + accum_ofdm->sent_cts_cnt, + delta_ofdm->sent_cts_cnt, max_ofdm->sent_cts_cnt); + + pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" + "acumulative delta max\n", + "Statistics_Rx - CCK:"); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "ina_cnt:", + le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt, + delta_cck->ina_cnt, max_cck->ina_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "fina_cnt:", + le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt, + delta_cck->fina_cnt, max_cck->fina_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "plcp_err:", + le32_to_cpu(cck->plcp_err), accum_cck->plcp_err, + delta_cck->plcp_err, max_cck->plcp_err); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "crc32_err:", + le32_to_cpu(cck->crc32_err), accum_cck->crc32_err, + delta_cck->crc32_err, max_cck->crc32_err); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "overrun_err:", + le32_to_cpu(cck->overrun_err), + accum_cck->overrun_err, + delta_cck->overrun_err, max_cck->overrun_err); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "early_overrun_err:", + le32_to_cpu(cck->early_overrun_err), + accum_cck->early_overrun_err, + delta_cck->early_overrun_err, + max_cck->early_overrun_err); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "crc32_good:", + le32_to_cpu(cck->crc32_good), accum_cck->crc32_good, + delta_cck->crc32_good, + max_cck->crc32_good); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "false_alarm_cnt:", + le32_to_cpu(cck->false_alarm_cnt), + accum_cck->false_alarm_cnt, + delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "fina_sync_err_cnt:", + le32_to_cpu(cck->fina_sync_err_cnt), + accum_cck->fina_sync_err_cnt, + delta_cck->fina_sync_err_cnt, + max_cck->fina_sync_err_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "sfd_timeout:", + le32_to_cpu(cck->sfd_timeout), + accum_cck->sfd_timeout, + delta_cck->sfd_timeout, max_cck->sfd_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "fina_timeout:", + le32_to_cpu(cck->fina_timeout), + accum_cck->fina_timeout, + delta_cck->fina_timeout, max_cck->fina_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "unresponded_rts:", + le32_to_cpu(cck->unresponded_rts), + accum_cck->unresponded_rts, + delta_cck->unresponded_rts, + max_cck->unresponded_rts); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "rxe_frame_lmt_ovrun:", + le32_to_cpu(cck->rxe_frame_limit_overrun), + accum_cck->rxe_frame_limit_overrun, + delta_cck->rxe_frame_limit_overrun, + max_cck->rxe_frame_limit_overrun); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "sent_ack_cnt:", + le32_to_cpu(cck->sent_ack_cnt), + accum_cck->sent_ack_cnt, + delta_cck->sent_ack_cnt, + max_cck->sent_ack_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "sent_cts_cnt:", + le32_to_cpu(cck->sent_cts_cnt), + accum_cck->sent_cts_cnt, + delta_cck->sent_cts_cnt, + max_cck->sent_cts_cnt); + + pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" + "acumulative delta max\n", + "Statistics_Rx - GENERAL:"); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "bogus_cts:", + le32_to_cpu(general->bogus_cts), + accum_general->bogus_cts, + delta_general->bogus_cts, max_general->bogus_cts); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "bogus_ack:", + le32_to_cpu(general->bogus_ack), + accum_general->bogus_ack, + delta_general->bogus_ack, max_general->bogus_ack); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "non_bssid_frames:", + le32_to_cpu(general->non_bssid_frames), + accum_general->non_bssid_frames, + delta_general->non_bssid_frames, + max_general->non_bssid_frames); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "filtered_frames:", + le32_to_cpu(general->filtered_frames), + accum_general->filtered_frames, + delta_general->filtered_frames, + max_general->filtered_frames); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "non_channel_beacons:", + le32_to_cpu(general->non_channel_beacons), + accum_general->non_channel_beacons, + delta_general->non_channel_beacons, + max_general->non_channel_beacons); + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +ssize_t il3945_ucode_tx_stats_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + int pos = 0; + char *buf; + int bufsz = (sizeof(struct iwl39_stats_tx) * 48) + 250; + ssize_t ret; + struct iwl39_stats_tx *tx, *accum_tx, *delta_tx, *max_tx; + + if (!il_is_alive(il)) + return -EAGAIN; + + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) { + IL_ERR("Can not allocate Buffer\n"); + return -ENOMEM; + } + + /* + * The statistic information display here is based on + * the last stats notification from uCode + * might not reflect the current uCode activity + */ + tx = &il->_3945.stats.tx; + accum_tx = &il->_3945.accum_stats.tx; + delta_tx = &il->_3945.delta_stats.tx; + max_tx = &il->_3945.max_delta.tx; + pos += il3945_stats_flag(il, buf, bufsz); + pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" + "acumulative delta max\n", + "Statistics_Tx:"); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "preamble:", + le32_to_cpu(tx->preamble_cnt), + accum_tx->preamble_cnt, + delta_tx->preamble_cnt, max_tx->preamble_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "rx_detected_cnt:", + le32_to_cpu(tx->rx_detected_cnt), + accum_tx->rx_detected_cnt, + delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "bt_prio_defer_cnt:", + le32_to_cpu(tx->bt_prio_defer_cnt), + accum_tx->bt_prio_defer_cnt, + delta_tx->bt_prio_defer_cnt, + max_tx->bt_prio_defer_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "bt_prio_kill_cnt:", + le32_to_cpu(tx->bt_prio_kill_cnt), + accum_tx->bt_prio_kill_cnt, + delta_tx->bt_prio_kill_cnt, + max_tx->bt_prio_kill_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "few_bytes_cnt:", + le32_to_cpu(tx->few_bytes_cnt), + accum_tx->few_bytes_cnt, + delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "cts_timeout:", + le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout, + delta_tx->cts_timeout, max_tx->cts_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "ack_timeout:", + le32_to_cpu(tx->ack_timeout), + accum_tx->ack_timeout, + delta_tx->ack_timeout, max_tx->ack_timeout); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "expected_ack_cnt:", + le32_to_cpu(tx->expected_ack_cnt), + accum_tx->expected_ack_cnt, + delta_tx->expected_ack_cnt, + max_tx->expected_ack_cnt); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "actual_ack_cnt:", + le32_to_cpu(tx->actual_ack_cnt), + accum_tx->actual_ack_cnt, + delta_tx->actual_ack_cnt, + max_tx->actual_ack_cnt); + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +ssize_t il3945_ucode_general_stats_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + int pos = 0; + char *buf; + int bufsz = sizeof(struct iwl39_stats_general) * 10 + 300; + ssize_t ret; + struct iwl39_stats_general *general, *accum_general; + struct iwl39_stats_general *delta_general, *max_general; + struct stats_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; + struct iwl39_stats_div *div, *accum_div, *delta_div, *max_div; + + if (!il_is_alive(il)) + return -EAGAIN; + + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) { + IL_ERR("Can not allocate Buffer\n"); + return -ENOMEM; + } + + /* + * The statistic information display here is based on + * the last stats notification from uCode + * might not reflect the current uCode activity + */ + general = &il->_3945.stats.general; + dbg = &il->_3945.stats.general.dbg; + div = &il->_3945.stats.general.div; + accum_general = &il->_3945.accum_stats.general; + delta_general = &il->_3945.delta_stats.general; + max_general = &il->_3945.max_delta.general; + accum_dbg = &il->_3945.accum_stats.general.dbg; + delta_dbg = &il->_3945.delta_stats.general.dbg; + max_dbg = &il->_3945.max_delta.general.dbg; + accum_div = &il->_3945.accum_stats.general.div; + delta_div = &il->_3945.delta_stats.general.div; + max_div = &il->_3945.max_delta.general.div; + pos += il3945_stats_flag(il, buf, bufsz); + pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" + "acumulative delta max\n", + "Statistics_General:"); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "burst_check:", + le32_to_cpu(dbg->burst_check), + accum_dbg->burst_check, + delta_dbg->burst_check, max_dbg->burst_check); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "burst_count:", + le32_to_cpu(dbg->burst_count), + accum_dbg->burst_count, + delta_dbg->burst_count, max_dbg->burst_count); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "sleep_time:", + le32_to_cpu(general->sleep_time), + accum_general->sleep_time, + delta_general->sleep_time, max_general->sleep_time); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "slots_out:", + le32_to_cpu(general->slots_out), + accum_general->slots_out, + delta_general->slots_out, max_general->slots_out); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "slots_idle:", + le32_to_cpu(general->slots_idle), + accum_general->slots_idle, + delta_general->slots_idle, max_general->slots_idle); + pos += scnprintf(buf + pos, bufsz - pos, "ttl_timestamp:\t\t\t%u\n", + le32_to_cpu(general->ttl_timestamp)); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "tx_on_a:", + le32_to_cpu(div->tx_on_a), accum_div->tx_on_a, + delta_div->tx_on_a, max_div->tx_on_a); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "tx_on_b:", + le32_to_cpu(div->tx_on_b), accum_div->tx_on_b, + delta_div->tx_on_b, max_div->tx_on_b); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "exec_time:", + le32_to_cpu(div->exec_time), accum_div->exec_time, + delta_div->exec_time, max_div->exec_time); + pos += scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "probe_time:", + le32_to_cpu(div->probe_time), accum_div->probe_time, + delta_div->probe_time, max_div->probe_time); + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} diff --git a/drivers/net/wireless/iwlegacy/3945-rs.c b/drivers/net/wireless/iwlegacy/3945-rs.c new file mode 100644 index 000000000000..f84ed5ecc676 --- /dev/null +++ b/drivers/net/wireless/iwlegacy/3945-rs.c @@ -0,0 +1,996 @@ +/****************************************************************************** + * + * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + *****************************************************************************/ + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include "iwl-commands.h" +#include "iwl-3945.h" +#include "iwl-sta.h" + +#define RS_NAME "iwl-3945-rs" + +static s32 il3945_expected_tpt_g[RATE_COUNT_3945] = { + 7, 13, 35, 58, 0, 0, 76, 104, 130, 168, 191, 202 +}; + +static s32 il3945_expected_tpt_g_prot[RATE_COUNT_3945] = { + 7, 13, 35, 58, 0, 0, 0, 80, 93, 113, 123, 125 +}; + +static s32 il3945_expected_tpt_a[RATE_COUNT_3945] = { + 0, 0, 0, 0, 40, 57, 72, 98, 121, 154, 177, 186 +}; + +static s32 il3945_expected_tpt_b[RATE_COUNT_3945] = { + 7, 13, 35, 58, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +struct il3945_tpt_entry { + s8 min_rssi; + u8 idx; +}; + +static struct il3945_tpt_entry il3945_tpt_table_a[] = { + {-60, RATE_54M_IDX}, + {-64, RATE_48M_IDX}, + {-72, RATE_36M_IDX}, + {-80, RATE_24M_IDX}, + {-84, RATE_18M_IDX}, + {-85, RATE_12M_IDX}, + {-87, RATE_9M_IDX}, + {-89, RATE_6M_IDX} +}; + +static struct il3945_tpt_entry il3945_tpt_table_g[] = { + {-60, RATE_54M_IDX}, + {-64, RATE_48M_IDX}, + {-68, RATE_36M_IDX}, + {-80, RATE_24M_IDX}, + {-84, RATE_18M_IDX}, + {-85, RATE_12M_IDX}, + {-86, RATE_11M_IDX}, + {-88, RATE_5M_IDX}, + {-90, RATE_2M_IDX}, + {-92, RATE_1M_IDX} +}; + +#define RATE_MAX_WINDOW 62 +#define RATE_FLUSH (3*HZ) +#define RATE_WIN_FLUSH (HZ/2) +#define IL39_RATE_HIGH_TH 11520 +#define IL_SUCCESS_UP_TH 8960 +#define IL_SUCCESS_DOWN_TH 10880 +#define RATE_MIN_FAILURE_TH 6 +#define RATE_MIN_SUCCESS_TH 8 +#define RATE_DECREASE_TH 1920 +#define RATE_RETRY_TH 15 + +static u8 il3945_get_rate_idx_by_rssi(s32 rssi, enum ieee80211_band band) +{ + u32 idx = 0; + u32 table_size = 0; + struct il3945_tpt_entry *tpt_table = NULL; + + if (rssi < IL_MIN_RSSI_VAL || rssi > IL_MAX_RSSI_VAL) + rssi = IL_MIN_RSSI_VAL; + + switch (band) { + case IEEE80211_BAND_2GHZ: + tpt_table = il3945_tpt_table_g; + table_size = ARRAY_SIZE(il3945_tpt_table_g); + break; + + case IEEE80211_BAND_5GHZ: + tpt_table = il3945_tpt_table_a; + table_size = ARRAY_SIZE(il3945_tpt_table_a); + break; + + default: + BUG(); + break; + } + + while (idx < table_size && rssi < tpt_table[idx].min_rssi) + idx++; + + idx = min(idx, (table_size - 1)); + + return tpt_table[idx].idx; +} + +static void il3945_clear_win(struct il3945_rate_scale_data *win) +{ + win->data = 0; + win->success_counter = 0; + win->success_ratio = -1; + win->counter = 0; + win->average_tpt = IL_INVALID_VALUE; + win->stamp = 0; +} + +/** + * il3945_rate_scale_flush_wins - flush out the rate scale wins + * + * Returns the number of wins that have gathered data but were + * not flushed. If there were any that were not flushed, then + * reschedule the rate flushing routine. + */ +static int il3945_rate_scale_flush_wins(struct il3945_rs_sta *rs_sta) +{ + int unflushed = 0; + int i; + unsigned long flags; + struct il_priv *il __maybe_unused = rs_sta->il; + + /* + * For each rate, if we have collected data on that rate + * and it has been more than RATE_WIN_FLUSH + * since we flushed, clear out the gathered stats + */ + for (i = 0; i < RATE_COUNT_3945; i++) { + if (!rs_sta->win[i].counter) + continue; + + spin_lock_irqsave(&rs_sta->lock, flags); + if (time_after(jiffies, rs_sta->win[i].stamp + + RATE_WIN_FLUSH)) { + D_RATE("flushing %d samples of rate " + "idx %d\n", + rs_sta->win[i].counter, i); + il3945_clear_win(&rs_sta->win[i]); + } else + unflushed++; + spin_unlock_irqrestore(&rs_sta->lock, flags); + } + + return unflushed; +} + +#define RATE_FLUSH_MAX 5000 /* msec */ +#define RATE_FLUSH_MIN 50 /* msec */ +#define IL_AVERAGE_PACKETS 1500 + +static void il3945_bg_rate_scale_flush(unsigned long data) +{ + struct il3945_rs_sta *rs_sta = (void *)data; + struct il_priv *il __maybe_unused = rs_sta->il; + int unflushed = 0; + unsigned long flags; + u32 packet_count, duration, pps; + + D_RATE("enter\n"); + + unflushed = il3945_rate_scale_flush_wins(rs_sta); + + spin_lock_irqsave(&rs_sta->lock, flags); + + /* Number of packets Rx'd since last time this timer ran */ + packet_count = (rs_sta->tx_packets - rs_sta->last_tx_packets) + 1; + + rs_sta->last_tx_packets = rs_sta->tx_packets + 1; + + if (unflushed) { + duration = + jiffies_to_msecs(jiffies - rs_sta->last_partial_flush); + + D_RATE("Tx'd %d packets in %dms\n", + packet_count, duration); + + /* Determine packets per second */ + if (duration) + pps = (packet_count * 1000) / duration; + else + pps = 0; + + if (pps) { + duration = (IL_AVERAGE_PACKETS * 1000) / pps; + if (duration < RATE_FLUSH_MIN) + duration = RATE_FLUSH_MIN; + else if (duration > RATE_FLUSH_MAX) + duration = RATE_FLUSH_MAX; + } else + duration = RATE_FLUSH_MAX; + + rs_sta->flush_time = msecs_to_jiffies(duration); + + D_RATE("new flush period: %d msec ave %d\n", + duration, packet_count); + + mod_timer(&rs_sta->rate_scale_flush, jiffies + + rs_sta->flush_time); + + rs_sta->last_partial_flush = jiffies; + } else { + rs_sta->flush_time = RATE_FLUSH; + rs_sta->flush_pending = 0; + } + /* If there weren't any unflushed entries, we don't schedule the timer + * to run again */ + + rs_sta->last_flush = jiffies; + + spin_unlock_irqrestore(&rs_sta->lock, flags); + + D_RATE("leave\n"); +} + +/** + * il3945_collect_tx_data - Update the success/failure sliding win + * + * We keep a sliding win of the last 64 packets transmitted + * at this rate. win->data contains the bitmask of successful + * packets. + */ +static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, + struct il3945_rate_scale_data *win, + int success, int retries, int idx) +{ + unsigned long flags; + s32 fail_count; + struct il_priv *il __maybe_unused = rs_sta->il; + + if (!retries) { + D_RATE("leave: retries == 0 -- should be at least 1\n"); + return; + } + + spin_lock_irqsave(&rs_sta->lock, flags); + + /* + * Keep track of only the latest 62 tx frame attempts in this rate's + * history win; anything older isn't really relevant any more. + * If we have filled up the sliding win, drop the oldest attempt; + * if the oldest attempt (highest bit in bitmap) shows "success", + * subtract "1" from the success counter (this is the main reason + * we keep these bitmaps!). + * */ + while (retries > 0) { + if (win->counter >= RATE_MAX_WINDOW) { + + /* remove earliest */ + win->counter = RATE_MAX_WINDOW - 1; + + if (win->data & (1ULL << (RATE_MAX_WINDOW - 1))) { + win->data &= ~(1ULL << (RATE_MAX_WINDOW - 1)); + win->success_counter--; + } + } + + /* Increment frames-attempted counter */ + win->counter++; + + /* Shift bitmap by one frame (throw away oldest history), + * OR in "1", and increment "success" if this + * frame was successful. */ + win->data <<= 1; + if (success > 0) { + win->success_counter++; + win->data |= 0x1; + success--; + } + + retries--; + } + + /* Calculate current success ratio, avoid divide-by-0! */ + if (win->counter > 0) + win->success_ratio = 128 * (100 * win->success_counter) + / win->counter; + else + win->success_ratio = IL_INVALID_VALUE; + + fail_count = win->counter - win->success_counter; + + /* Calculate average throughput, if we have enough history. */ + if (fail_count >= RATE_MIN_FAILURE_TH || + win->success_counter >= RATE_MIN_SUCCESS_TH) + win->average_tpt = ((win->success_ratio * + rs_sta->expected_tpt[idx] + 64) / 128); + else + win->average_tpt = IL_INVALID_VALUE; + + /* Tag this win as having been updated */ + win->stamp = jiffies; + + spin_unlock_irqrestore(&rs_sta->lock, flags); + +} + +/* + * Called after adding a new station to initialize rate scaling + */ +void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_id) +{ + struct ieee80211_hw *hw = il->hw; + struct ieee80211_conf *conf = &il->hw->conf; + struct il3945_sta_priv *psta; + struct il3945_rs_sta *rs_sta; + struct ieee80211_supported_band *sband; + int i; + + D_INFO("enter\n"); + if (sta_id == il->ctx.bcast_sta_id) + goto out; + + psta = (struct il3945_sta_priv *) sta->drv_priv; + rs_sta = &psta->rs_sta; + sband = hw->wiphy->bands[conf->channel->band]; + + rs_sta->il = il; + + rs_sta->start_rate = RATE_INVALID; + + /* default to just 802.11b */ + rs_sta->expected_tpt = il3945_expected_tpt_b; + + rs_sta->last_partial_flush = jiffies; + rs_sta->last_flush = jiffies; + rs_sta->flush_time = RATE_FLUSH; + rs_sta->last_tx_packets = 0; + + rs_sta->rate_scale_flush.data = (unsigned long)rs_sta; + rs_sta->rate_scale_flush.function = il3945_bg_rate_scale_flush; + + for (i = 0; i < RATE_COUNT_3945; i++) + il3945_clear_win(&rs_sta->win[i]); + + /* TODO: what is a good starting rate for STA? About middle? Maybe not + * the lowest or the highest rate.. Could consider using RSSI from + * previous packets? Need to have IEEE 802.1X auth succeed immediately + * after assoc.. */ + + for (i = sband->n_bitrates - 1; i >= 0; i--) { + if (sta->supp_rates[sband->band] & (1 << i)) { + rs_sta->last_txrate_idx = i; + break; + } + } + + il->_3945.sta_supp_rates = sta->supp_rates[sband->band]; + /* For 5 GHz band it start at IL_FIRST_OFDM_RATE */ + if (sband->band == IEEE80211_BAND_5GHZ) { + rs_sta->last_txrate_idx += IL_FIRST_OFDM_RATE; + il->_3945.sta_supp_rates = il->_3945.sta_supp_rates << + IL_FIRST_OFDM_RATE; + } + +out: + il->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; + + D_INFO("leave\n"); +} + +static void *il3945_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) +{ + return hw->priv; +} + +/* rate scale requires free function to be implemented */ +static void il3945_rs_free(void *il) +{ + return; +} + +static void *il3945_rs_alloc_sta(void *il_priv, struct ieee80211_sta *sta, gfp_t gfp) +{ + struct il3945_rs_sta *rs_sta; + struct il3945_sta_priv *psta = (void *) sta->drv_priv; + struct il_priv *il __maybe_unused = il_priv; + + D_RATE("enter\n"); + + rs_sta = &psta->rs_sta; + + spin_lock_init(&rs_sta->lock); + init_timer(&rs_sta->rate_scale_flush); + + D_RATE("leave\n"); + + return rs_sta; +} + +static void il3945_rs_free_sta(void *il_priv, struct ieee80211_sta *sta, + void *il_sta) +{ + struct il3945_rs_sta *rs_sta = il_sta; + + /* + * Be careful not to use any members of il3945_rs_sta (like trying + * to use il_priv to print out debugging) since it may not be fully + * initialized at this point. + */ + del_timer_sync(&rs_sta->rate_scale_flush); +} + + +/** + * il3945_rs_tx_status - Update rate control values based on Tx results + * + * NOTE: Uses il_priv->retry_rate for the # of retries attempted by + * the hardware for each rate. + */ +static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band *sband, + struct ieee80211_sta *sta, void *il_sta, + struct sk_buff *skb) +{ + s8 retries = 0, current_count; + int scale_rate_idx, first_idx, last_idx; + unsigned long flags; + struct il_priv *il = (struct il_priv *)il_rate; + struct il3945_rs_sta *rs_sta = il_sta; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + + D_RATE("enter\n"); + + retries = info->status.rates[0].count; + /* Sanity Check for retries */ + if (retries > RATE_RETRY_TH) + retries = RATE_RETRY_TH; + + first_idx = sband->bitrates[info->status.rates[0].idx].hw_value; + if (first_idx < 0 || first_idx >= RATE_COUNT_3945) { + D_RATE("leave: Rate out of bounds: %d\n", first_idx); + return; + } + + if (!il_sta) { + D_RATE("leave: No STA il data to update!\n"); + return; + } + + /* Treat uninitialized rate scaling data same as non-existing. */ + if (!rs_sta->il) { + D_RATE("leave: STA il data uninitialized!\n"); + return; + } + + + rs_sta->tx_packets++; + + scale_rate_idx = first_idx; + last_idx = first_idx; + + /* + * Update the win for each rate. We determine which rates + * were Tx'd based on the total number of retries vs. the number + * of retries configured for each rate -- currently set to the + * il value 'retry_rate' vs. rate specific + * + * On exit from this while loop last_idx indicates the rate + * at which the frame was finally transmitted (or failed if no + * ACK) + */ + while (retries > 1) { + if ((retries - 1) < il->retry_rate) { + current_count = (retries - 1); + last_idx = scale_rate_idx; + } else { + current_count = il->retry_rate; + last_idx = il3945_rs_next_rate(il, + scale_rate_idx); + } + + /* Update this rate accounting for as many retries + * as was used for it (per current_count) */ + il3945_collect_tx_data(rs_sta, + &rs_sta->win[scale_rate_idx], + 0, current_count, scale_rate_idx); + D_RATE("Update rate %d for %d retries.\n", + scale_rate_idx, current_count); + + retries -= current_count; + + scale_rate_idx = last_idx; + } + + + /* Update the last idx win with success/failure based on ACK */ + D_RATE("Update rate %d with %s.\n", + last_idx, + (info->flags & IEEE80211_TX_STAT_ACK) ? + "success" : "failure"); + il3945_collect_tx_data(rs_sta, + &rs_sta->win[last_idx], + info->flags & IEEE80211_TX_STAT_ACK, 1, last_idx); + + /* We updated the rate scale win -- if its been more than + * flush_time since the last run, schedule the flush + * again */ + spin_lock_irqsave(&rs_sta->lock, flags); + + if (!rs_sta->flush_pending && + time_after(jiffies, rs_sta->last_flush + + rs_sta->flush_time)) { + + rs_sta->last_partial_flush = jiffies; + rs_sta->flush_pending = 1; + mod_timer(&rs_sta->rate_scale_flush, + jiffies + rs_sta->flush_time); + } + + spin_unlock_irqrestore(&rs_sta->lock, flags); + + D_RATE("leave\n"); +} + +static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, + u8 idx, u16 rate_mask, enum ieee80211_band band) +{ + u8 high = RATE_INVALID; + u8 low = RATE_INVALID; + struct il_priv *il __maybe_unused = rs_sta->il; + + /* 802.11A walks to the next literal adjacent rate in + * the rate table */ + if (unlikely(band == IEEE80211_BAND_5GHZ)) { + int i; + u32 mask; + + /* Find the previous rate that is in the rate mask */ + i = idx - 1; + for (mask = (1 << i); i >= 0; i--, mask >>= 1) { + if (rate_mask & mask) { + low = i; + break; + } + } + + /* Find the next rate that is in the rate mask */ + i = idx + 1; + for (mask = (1 << i); i < RATE_COUNT_3945; + i++, mask <<= 1) { + if (rate_mask & mask) { + high = i; + break; + } + } + + return (high << 8) | low; + } + + low = idx; + while (low != RATE_INVALID) { + if (rs_sta->tgg) + low = il3945_rates[low].prev_rs_tgg; + else + low = il3945_rates[low].prev_rs; + if (low == RATE_INVALID) + break; + if (rate_mask & (1 << low)) + break; + D_RATE("Skipping masked lower rate: %d\n", low); + } + + high = idx; + while (high != RATE_INVALID) { + if (rs_sta->tgg) + high = il3945_rates[high].next_rs_tgg; + else + high = il3945_rates[high].next_rs; + if (high == RATE_INVALID) + break; + if (rate_mask & (1 << high)) + break; + D_RATE("Skipping masked higher rate: %d\n", high); + } + + return (high << 8) | low; +} + +/** + * il3945_rs_get_rate - find the rate for the requested packet + * + * Returns the ieee80211_rate structure allocated by the driver. + * + * The rate control algorithm has no internal mapping between hw_mode's + * rate ordering and the rate ordering used by the rate control algorithm. + * + * The rate control algorithm uses a single table of rates that goes across + * the entire A/B/G spectrum vs. being limited to just one particular + * hw_mode. + * + * As such, we can't convert the idx obtained below into the hw_mode's + * rate table and must reference the driver allocated rate table + * + */ +static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, + void *il_sta, struct ieee80211_tx_rate_control *txrc) +{ + struct ieee80211_supported_band *sband = txrc->sband; + struct sk_buff *skb = txrc->skb; + u8 low = RATE_INVALID; + u8 high = RATE_INVALID; + u16 high_low; + int idx; + struct il3945_rs_sta *rs_sta = il_sta; + struct il3945_rate_scale_data *win = NULL; + int current_tpt = IL_INVALID_VALUE; + int low_tpt = IL_INVALID_VALUE; + int high_tpt = IL_INVALID_VALUE; + u32 fail_count; + s8 scale_action = 0; + unsigned long flags; + u16 rate_mask; + s8 max_rate_idx = -1; + struct il_priv *il __maybe_unused = (struct il_priv *)il_r; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); + + D_RATE("enter\n"); + + /* Treat uninitialized rate scaling data same as non-existing. */ + if (rs_sta && !rs_sta->il) { + D_RATE("Rate scaling information not initialized yet.\n"); + il_sta = NULL; + } + + if (rate_control_send_low(sta, il_sta, txrc)) + return; + + rate_mask = sta->supp_rates[sband->band]; + + /* get user max rate if set */ + max_rate_idx = txrc->max_rate_idx; + if (sband->band == IEEE80211_BAND_5GHZ && max_rate_idx != -1) + max_rate_idx += IL_FIRST_OFDM_RATE; + if (max_rate_idx < 0 || max_rate_idx >= RATE_COUNT) + max_rate_idx = -1; + + idx = min(rs_sta->last_txrate_idx & 0xffff, RATE_COUNT_3945 - 1); + + if (sband->band == IEEE80211_BAND_5GHZ) + rate_mask = rate_mask << IL_FIRST_OFDM_RATE; + + spin_lock_irqsave(&rs_sta->lock, flags); + + /* for recent assoc, choose best rate regarding + * to rssi value + */ + if (rs_sta->start_rate != RATE_INVALID) { + if (rs_sta->start_rate < idx && + (rate_mask & (1 << rs_sta->start_rate))) + idx = rs_sta->start_rate; + rs_sta->start_rate = RATE_INVALID; + } + + /* force user max rate if set by user */ + if (max_rate_idx != -1 && max_rate_idx < idx) { + if (rate_mask & (1 << max_rate_idx)) + idx = max_rate_idx; + } + + win = &(rs_sta->win[idx]); + + fail_count = win->counter - win->success_counter; + + if (fail_count < RATE_MIN_FAILURE_TH && + win->success_counter < RATE_MIN_SUCCESS_TH) { + spin_unlock_irqrestore(&rs_sta->lock, flags); + + D_RATE("Invalid average_tpt on rate %d: " + "counter: %d, success_counter: %d, " + "expected_tpt is %sNULL\n", + idx, + win->counter, + win->success_counter, + rs_sta->expected_tpt ? "not " : ""); + + /* Can't calculate this yet; not enough history */ + win->average_tpt = IL_INVALID_VALUE; + goto out; + + } + + current_tpt = win->average_tpt; + + high_low = il3945_get_adjacent_rate(rs_sta, idx, rate_mask, + sband->band); + low = high_low & 0xff; + high = (high_low >> 8) & 0xff; + + /* If user set max rate, dont allow higher than user constrain */ + if (max_rate_idx != -1 && max_rate_idx < high) + high = RATE_INVALID; + + /* Collect Measured throughputs of adjacent rates */ + if (low != RATE_INVALID) + low_tpt = rs_sta->win[low].average_tpt; + + if (high != RATE_INVALID) + high_tpt = rs_sta->win[high].average_tpt; + + spin_unlock_irqrestore(&rs_sta->lock, flags); + + scale_action = 0; + + /* Low success ratio , need to drop the rate */ + if (win->success_ratio < RATE_DECREASE_TH || !current_tpt) { + D_RATE("decrease rate because of low success_ratio\n"); + scale_action = -1; + /* No throughput measured yet for adjacent rates, + * try increase */ + } else if (low_tpt == IL_INVALID_VALUE && + high_tpt == IL_INVALID_VALUE) { + + if (high != RATE_INVALID && win->success_ratio >= RATE_INCREASE_TH) + scale_action = 1; + else if (low != RATE_INVALID) + scale_action = 0; + + /* Both adjacent throughputs are measured, but neither one has + * better throughput; we're using the best rate, don't change + * it! */ + } else if (low_tpt != IL_INVALID_VALUE && + high_tpt != IL_INVALID_VALUE && + low_tpt < current_tpt && high_tpt < current_tpt) { + + D_RATE("No action -- low [%d] & high [%d] < " + "current_tpt [%d]\n", + low_tpt, high_tpt, current_tpt); + scale_action = 0; + + /* At least one of the rates has better throughput */ + } else { + if (high_tpt != IL_INVALID_VALUE) { + + /* High rate has better throughput, Increase + * rate */ + if (high_tpt > current_tpt && + win->success_ratio >= RATE_INCREASE_TH) + scale_action = 1; + else { + D_RATE( + "decrease rate because of high tpt\n"); + scale_action = 0; + } + } else if (low_tpt != IL_INVALID_VALUE) { + if (low_tpt > current_tpt) { + D_RATE( + "decrease rate because of low tpt\n"); + scale_action = -1; + } else if (win->success_ratio >= RATE_INCREASE_TH) { + /* Lower rate has better + * throughput,decrease rate */ + scale_action = 1; + } + } + } + + /* Sanity check; asked for decrease, but success rate or throughput + * has been good at old rate. Don't change it. */ + if (scale_action == -1 && low != RATE_INVALID && + (win->success_ratio > RATE_HIGH_TH || + current_tpt > 100 * rs_sta->expected_tpt[low])) + scale_action = 0; + + switch (scale_action) { + case -1: + + /* Decrese rate */ + if (low != RATE_INVALID) + idx = low; + break; + + case 1: + /* Increase rate */ + if (high != RATE_INVALID) + idx = high; + + break; + + case 0: + default: + /* No change */ + break; + } + + D_RATE("Selected %d (action %d) - low %d high %d\n", + idx, scale_action, low, high); + + out: + + if (sband->band == IEEE80211_BAND_5GHZ) { + if (WARN_ON_ONCE(idx < IL_FIRST_OFDM_RATE)) + idx = IL_FIRST_OFDM_RATE; + rs_sta->last_txrate_idx = idx; + info->control.rates[0].idx = idx - IL_FIRST_OFDM_RATE; + } else { + rs_sta->last_txrate_idx = idx; + info->control.rates[0].idx = rs_sta->last_txrate_idx; + } + + D_RATE("leave: %d\n", idx); +} + +#ifdef CONFIG_MAC80211_DEBUGFS +static int il3945_open_file_generic(struct inode *inode, struct file *file) +{ + file->private_data = inode->i_private; + return 0; +} + +static ssize_t il3945_sta_dbgfs_stats_table_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + char *buff; + int desc = 0; + int j; + ssize_t ret; + struct il3945_rs_sta *lq_sta = file->private_data; + + buff = kmalloc(1024, GFP_KERNEL); + if (!buff) + return -ENOMEM; + + desc += sprintf(buff + desc, "tx packets=%d last rate idx=%d\n" + "rate=0x%X flush time %d\n", + lq_sta->tx_packets, + lq_sta->last_txrate_idx, + lq_sta->start_rate, jiffies_to_msecs(lq_sta->flush_time)); + for (j = 0; j < RATE_COUNT_3945; j++) { + desc += sprintf(buff+desc, + "counter=%d success=%d %%=%d\n", + lq_sta->win[j].counter, + lq_sta->win[j].success_counter, + lq_sta->win[j].success_ratio); + } + ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); + kfree(buff); + return ret; +} + +static const struct file_operations rs_sta_dbgfs_stats_table_ops = { + .read = il3945_sta_dbgfs_stats_table_read, + .open = il3945_open_file_generic, + .llseek = default_llseek, +}; + +static void il3945_add_debugfs(void *il, void *il_sta, + struct dentry *dir) +{ + struct il3945_rs_sta *lq_sta = il_sta; + + lq_sta->rs_sta_dbgfs_stats_table_file = + debugfs_create_file("rate_stats_table", 0600, dir, + lq_sta, &rs_sta_dbgfs_stats_table_ops); + +} + +static void il3945_remove_debugfs(void *il, void *il_sta) +{ + struct il3945_rs_sta *lq_sta = il_sta; + debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file); +} +#endif + +/* + * Initialization of rate scaling information is done by driver after + * the station is added. Since mac80211 calls this function before a + * station is added we ignore it. + */ +static void il3945_rs_rate_init_stub(void *il_r, + struct ieee80211_supported_band *sband, + struct ieee80211_sta *sta, void *il_sta) +{ +} + +static struct rate_control_ops rs_ops = { + .module = NULL, + .name = RS_NAME, + .tx_status = il3945_rs_tx_status, + .get_rate = il3945_rs_get_rate, + .rate_init = il3945_rs_rate_init_stub, + .alloc = il3945_rs_alloc, + .free = il3945_rs_free, + .alloc_sta = il3945_rs_alloc_sta, + .free_sta = il3945_rs_free_sta, +#ifdef CONFIG_MAC80211_DEBUGFS + .add_sta_debugfs = il3945_add_debugfs, + .remove_sta_debugfs = il3945_remove_debugfs, +#endif + +}; +void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) +{ + struct il_priv *il = hw->priv; + s32 rssi = 0; + unsigned long flags; + struct il3945_rs_sta *rs_sta; + struct ieee80211_sta *sta; + struct il3945_sta_priv *psta; + + D_RATE("enter\n"); + + rcu_read_lock(); + + sta = ieee80211_find_sta(il->ctx.vif, + il->stations[sta_id].sta.sta.addr); + if (!sta) { + D_RATE("Unable to find station to initialize rate scaling.\n"); + rcu_read_unlock(); + return; + } + + psta = (void *) sta->drv_priv; + rs_sta = &psta->rs_sta; + + spin_lock_irqsave(&rs_sta->lock, flags); + + rs_sta->tgg = 0; + switch (il->band) { + case IEEE80211_BAND_2GHZ: + /* TODO: this always does G, not a regression */ + if (il->ctx.active.flags & + RXON_FLG_TGG_PROTECT_MSK) { + rs_sta->tgg = 1; + rs_sta->expected_tpt = il3945_expected_tpt_g_prot; + } else + rs_sta->expected_tpt = il3945_expected_tpt_g; + break; + + case IEEE80211_BAND_5GHZ: + rs_sta->expected_tpt = il3945_expected_tpt_a; + break; + case IEEE80211_NUM_BANDS: + BUG(); + break; + } + + spin_unlock_irqrestore(&rs_sta->lock, flags); + + rssi = il->_3945.last_rx_rssi; + if (rssi == 0) + rssi = IL_MIN_RSSI_VAL; + + D_RATE("Network RSSI: %d\n", rssi); + + rs_sta->start_rate = il3945_get_rate_idx_by_rssi(rssi, il->band); + + D_RATE("leave: rssi %d assign rate idx: " + "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate, + il3945_rates[rs_sta->start_rate].plcp); + rcu_read_unlock(); +} + +int il3945_rate_control_register(void) +{ + return ieee80211_rate_control_register(&rs_ops); +} + +void il3945_rate_control_unregister(void) +{ + ieee80211_rate_control_unregister(&rs_ops); +} diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index b0ffa98d179d..d402496759e4 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -13,7 +13,7 @@ iwl4965-$(CONFIG_IWLEGACY_DEBUGFS) += 4965-debug.o # 3945 obj-$(CONFIG_IWL3945) += iwl3945.o -iwl3945-objs := 3945-mac.o 3945.o iwl-3945-rs.o -iwl3945-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-3945-debugfs.o +iwl3945-objs := 3945-mac.o 3945.o 3945-rs.o +iwl3945-$(CONFIG_IWLEGACY_DEBUGFS) += 3945-debug.o ccflags-y += -D__CHECK_ENDIAN__ diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c deleted file mode 100644 index 88b3d8fc38f8..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.c +++ /dev/null @@ -1,523 +0,0 @@ -/****************************************************************************** - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - *****************************************************************************/ - -#include "iwl-3945-debugfs.h" - - -static int il3945_stats_flag(struct il_priv *il, char *buf, int bufsz) -{ - int p = 0; - - p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", - le32_to_cpu(il->_3945.stats.flag)); - if (le32_to_cpu(il->_3945.stats.flag) & - UCODE_STATISTICS_CLEAR_MSK) - p += scnprintf(buf + p, bufsz - p, - "\tStatistics have been cleared\n"); - p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n", - (le32_to_cpu(il->_3945.stats.flag) & - UCODE_STATISTICS_FREQUENCY_MSK) - ? "2.4 GHz" : "5.2 GHz"); - p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n", - (le32_to_cpu(il->_3945.stats.flag) & - UCODE_STATISTICS_NARROW_BAND_MSK) - ? "enabled" : "disabled"); - return p; -} - -ssize_t il3945_ucode_rx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - int pos = 0; - char *buf; - int bufsz = sizeof(struct iwl39_stats_rx_phy) * 40 + - sizeof(struct iwl39_stats_rx_non_phy) * 40 + 400; - ssize_t ret; - struct iwl39_stats_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, - *max_ofdm; - struct iwl39_stats_rx_phy *cck, *accum_cck, *delta_cck, *max_cck; - struct iwl39_stats_rx_non_phy *general, *accum_general; - struct iwl39_stats_rx_non_phy *delta_general, *max_general; - - if (!il_is_alive(il)) - return -EAGAIN; - - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) { - IL_ERR("Can not allocate Buffer\n"); - return -ENOMEM; - } - - /* - * The statistic information display here is based on - * the last stats notification from uCode - * might not reflect the current uCode activity - */ - ofdm = &il->_3945.stats.rx.ofdm; - cck = &il->_3945.stats.rx.cck; - general = &il->_3945.stats.rx.general; - accum_ofdm = &il->_3945.accum_stats.rx.ofdm; - accum_cck = &il->_3945.accum_stats.rx.cck; - accum_general = &il->_3945.accum_stats.rx.general; - delta_ofdm = &il->_3945.delta_stats.rx.ofdm; - delta_cck = &il->_3945.delta_stats.rx.cck; - delta_general = &il->_3945.delta_stats.rx.general; - max_ofdm = &il->_3945.max_delta.rx.ofdm; - max_cck = &il->_3945.max_delta.rx.cck; - max_general = &il->_3945.max_delta.rx.general; - - pos += il3945_stats_flag(il, buf, bufsz); - pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" - "acumulative delta max\n", - "Statistics_Rx - OFDM:"); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "ina_cnt:", le32_to_cpu(ofdm->ina_cnt), - accum_ofdm->ina_cnt, - delta_ofdm->ina_cnt, max_ofdm->ina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "fina_cnt:", - le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt, - delta_ofdm->fina_cnt, max_ofdm->fina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", "plcp_err:", - le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err, - delta_ofdm->plcp_err, max_ofdm->plcp_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", "crc32_err:", - le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err, - delta_ofdm->crc32_err, max_ofdm->crc32_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", "overrun_err:", - le32_to_cpu(ofdm->overrun_err), - accum_ofdm->overrun_err, delta_ofdm->overrun_err, - max_ofdm->overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "early_overrun_err:", - le32_to_cpu(ofdm->early_overrun_err), - accum_ofdm->early_overrun_err, - delta_ofdm->early_overrun_err, - max_ofdm->early_overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "crc32_good:", le32_to_cpu(ofdm->crc32_good), - accum_ofdm->crc32_good, delta_ofdm->crc32_good, - max_ofdm->crc32_good); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", "false_alarm_cnt:", - le32_to_cpu(ofdm->false_alarm_cnt), - accum_ofdm->false_alarm_cnt, - delta_ofdm->false_alarm_cnt, - max_ofdm->false_alarm_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "fina_sync_err_cnt:", - le32_to_cpu(ofdm->fina_sync_err_cnt), - accum_ofdm->fina_sync_err_cnt, - delta_ofdm->fina_sync_err_cnt, - max_ofdm->fina_sync_err_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sfd_timeout:", - le32_to_cpu(ofdm->sfd_timeout), - accum_ofdm->sfd_timeout, - delta_ofdm->sfd_timeout, - max_ofdm->sfd_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "fina_timeout:", - le32_to_cpu(ofdm->fina_timeout), - accum_ofdm->fina_timeout, - delta_ofdm->fina_timeout, - max_ofdm->fina_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "unresponded_rts:", - le32_to_cpu(ofdm->unresponded_rts), - accum_ofdm->unresponded_rts, - delta_ofdm->unresponded_rts, - max_ofdm->unresponded_rts); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "rxe_frame_lmt_ovrun:", - le32_to_cpu(ofdm->rxe_frame_limit_overrun), - accum_ofdm->rxe_frame_limit_overrun, - delta_ofdm->rxe_frame_limit_overrun, - max_ofdm->rxe_frame_limit_overrun); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sent_ack_cnt:", - le32_to_cpu(ofdm->sent_ack_cnt), - accum_ofdm->sent_ack_cnt, - delta_ofdm->sent_ack_cnt, - max_ofdm->sent_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sent_cts_cnt:", - le32_to_cpu(ofdm->sent_cts_cnt), - accum_ofdm->sent_cts_cnt, - delta_ofdm->sent_cts_cnt, max_ofdm->sent_cts_cnt); - - pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" - "acumulative delta max\n", - "Statistics_Rx - CCK:"); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "ina_cnt:", - le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt, - delta_cck->ina_cnt, max_cck->ina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "fina_cnt:", - le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt, - delta_cck->fina_cnt, max_cck->fina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "plcp_err:", - le32_to_cpu(cck->plcp_err), accum_cck->plcp_err, - delta_cck->plcp_err, max_cck->plcp_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "crc32_err:", - le32_to_cpu(cck->crc32_err), accum_cck->crc32_err, - delta_cck->crc32_err, max_cck->crc32_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "overrun_err:", - le32_to_cpu(cck->overrun_err), - accum_cck->overrun_err, - delta_cck->overrun_err, max_cck->overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "early_overrun_err:", - le32_to_cpu(cck->early_overrun_err), - accum_cck->early_overrun_err, - delta_cck->early_overrun_err, - max_cck->early_overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "crc32_good:", - le32_to_cpu(cck->crc32_good), accum_cck->crc32_good, - delta_cck->crc32_good, - max_cck->crc32_good); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "false_alarm_cnt:", - le32_to_cpu(cck->false_alarm_cnt), - accum_cck->false_alarm_cnt, - delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "fina_sync_err_cnt:", - le32_to_cpu(cck->fina_sync_err_cnt), - accum_cck->fina_sync_err_cnt, - delta_cck->fina_sync_err_cnt, - max_cck->fina_sync_err_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sfd_timeout:", - le32_to_cpu(cck->sfd_timeout), - accum_cck->sfd_timeout, - delta_cck->sfd_timeout, max_cck->sfd_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "fina_timeout:", - le32_to_cpu(cck->fina_timeout), - accum_cck->fina_timeout, - delta_cck->fina_timeout, max_cck->fina_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "unresponded_rts:", - le32_to_cpu(cck->unresponded_rts), - accum_cck->unresponded_rts, - delta_cck->unresponded_rts, - max_cck->unresponded_rts); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "rxe_frame_lmt_ovrun:", - le32_to_cpu(cck->rxe_frame_limit_overrun), - accum_cck->rxe_frame_limit_overrun, - delta_cck->rxe_frame_limit_overrun, - max_cck->rxe_frame_limit_overrun); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sent_ack_cnt:", - le32_to_cpu(cck->sent_ack_cnt), - accum_cck->sent_ack_cnt, - delta_cck->sent_ack_cnt, - max_cck->sent_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sent_cts_cnt:", - le32_to_cpu(cck->sent_cts_cnt), - accum_cck->sent_cts_cnt, - delta_cck->sent_cts_cnt, - max_cck->sent_cts_cnt); - - pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" - "acumulative delta max\n", - "Statistics_Rx - GENERAL:"); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "bogus_cts:", - le32_to_cpu(general->bogus_cts), - accum_general->bogus_cts, - delta_general->bogus_cts, max_general->bogus_cts); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "bogus_ack:", - le32_to_cpu(general->bogus_ack), - accum_general->bogus_ack, - delta_general->bogus_ack, max_general->bogus_ack); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "non_bssid_frames:", - le32_to_cpu(general->non_bssid_frames), - accum_general->non_bssid_frames, - delta_general->non_bssid_frames, - max_general->non_bssid_frames); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "filtered_frames:", - le32_to_cpu(general->filtered_frames), - accum_general->filtered_frames, - delta_general->filtered_frames, - max_general->filtered_frames); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "non_channel_beacons:", - le32_to_cpu(general->non_channel_beacons), - accum_general->non_channel_beacons, - delta_general->non_channel_beacons, - max_general->non_channel_beacons); - - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -ssize_t il3945_ucode_tx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - int pos = 0; - char *buf; - int bufsz = (sizeof(struct iwl39_stats_tx) * 48) + 250; - ssize_t ret; - struct iwl39_stats_tx *tx, *accum_tx, *delta_tx, *max_tx; - - if (!il_is_alive(il)) - return -EAGAIN; - - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) { - IL_ERR("Can not allocate Buffer\n"); - return -ENOMEM; - } - - /* - * The statistic information display here is based on - * the last stats notification from uCode - * might not reflect the current uCode activity - */ - tx = &il->_3945.stats.tx; - accum_tx = &il->_3945.accum_stats.tx; - delta_tx = &il->_3945.delta_stats.tx; - max_tx = &il->_3945.max_delta.tx; - pos += il3945_stats_flag(il, buf, bufsz); - pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" - "acumulative delta max\n", - "Statistics_Tx:"); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "preamble:", - le32_to_cpu(tx->preamble_cnt), - accum_tx->preamble_cnt, - delta_tx->preamble_cnt, max_tx->preamble_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "rx_detected_cnt:", - le32_to_cpu(tx->rx_detected_cnt), - accum_tx->rx_detected_cnt, - delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "bt_prio_defer_cnt:", - le32_to_cpu(tx->bt_prio_defer_cnt), - accum_tx->bt_prio_defer_cnt, - delta_tx->bt_prio_defer_cnt, - max_tx->bt_prio_defer_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "bt_prio_kill_cnt:", - le32_to_cpu(tx->bt_prio_kill_cnt), - accum_tx->bt_prio_kill_cnt, - delta_tx->bt_prio_kill_cnt, - max_tx->bt_prio_kill_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "few_bytes_cnt:", - le32_to_cpu(tx->few_bytes_cnt), - accum_tx->few_bytes_cnt, - delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "cts_timeout:", - le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout, - delta_tx->cts_timeout, max_tx->cts_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "ack_timeout:", - le32_to_cpu(tx->ack_timeout), - accum_tx->ack_timeout, - delta_tx->ack_timeout, max_tx->ack_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "expected_ack_cnt:", - le32_to_cpu(tx->expected_ack_cnt), - accum_tx->expected_ack_cnt, - delta_tx->expected_ack_cnt, - max_tx->expected_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "actual_ack_cnt:", - le32_to_cpu(tx->actual_ack_cnt), - accum_tx->actual_ack_cnt, - delta_tx->actual_ack_cnt, - max_tx->actual_ack_cnt); - - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -ssize_t il3945_ucode_general_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - int pos = 0; - char *buf; - int bufsz = sizeof(struct iwl39_stats_general) * 10 + 300; - ssize_t ret; - struct iwl39_stats_general *general, *accum_general; - struct iwl39_stats_general *delta_general, *max_general; - struct stats_dbg *dbg, *accum_dbg, *delta_dbg, *max_dbg; - struct iwl39_stats_div *div, *accum_div, *delta_div, *max_div; - - if (!il_is_alive(il)) - return -EAGAIN; - - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) { - IL_ERR("Can not allocate Buffer\n"); - return -ENOMEM; - } - - /* - * The statistic information display here is based on - * the last stats notification from uCode - * might not reflect the current uCode activity - */ - general = &il->_3945.stats.general; - dbg = &il->_3945.stats.general.dbg; - div = &il->_3945.stats.general.div; - accum_general = &il->_3945.accum_stats.general; - delta_general = &il->_3945.delta_stats.general; - max_general = &il->_3945.max_delta.general; - accum_dbg = &il->_3945.accum_stats.general.dbg; - delta_dbg = &il->_3945.delta_stats.general.dbg; - max_dbg = &il->_3945.max_delta.general.dbg; - accum_div = &il->_3945.accum_stats.general.div; - delta_div = &il->_3945.delta_stats.general.div; - max_div = &il->_3945.max_delta.general.div; - pos += il3945_stats_flag(il, buf, bufsz); - pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" - "acumulative delta max\n", - "Statistics_General:"); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "burst_check:", - le32_to_cpu(dbg->burst_check), - accum_dbg->burst_check, - delta_dbg->burst_check, max_dbg->burst_check); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "burst_count:", - le32_to_cpu(dbg->burst_count), - accum_dbg->burst_count, - delta_dbg->burst_count, max_dbg->burst_count); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sleep_time:", - le32_to_cpu(general->sleep_time), - accum_general->sleep_time, - delta_general->sleep_time, max_general->sleep_time); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "slots_out:", - le32_to_cpu(general->slots_out), - accum_general->slots_out, - delta_general->slots_out, max_general->slots_out); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "slots_idle:", - le32_to_cpu(general->slots_idle), - accum_general->slots_idle, - delta_general->slots_idle, max_general->slots_idle); - pos += scnprintf(buf + pos, bufsz - pos, "ttl_timestamp:\t\t\t%u\n", - le32_to_cpu(general->ttl_timestamp)); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "tx_on_a:", - le32_to_cpu(div->tx_on_a), accum_div->tx_on_a, - delta_div->tx_on_a, max_div->tx_on_a); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "tx_on_b:", - le32_to_cpu(div->tx_on_b), accum_div->tx_on_b, - delta_div->tx_on_b, max_div->tx_on_b); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "exec_time:", - le32_to_cpu(div->exec_time), accum_div->exec_time, - delta_div->exec_time, max_div->exec_time); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "probe_time:", - le32_to_cpu(div->probe_time), accum_div->probe_time, - delta_div->probe_time, max_div->probe_time); - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c deleted file mode 100644 index f84ed5ecc676..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c +++ /dev/null @@ -1,996 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include "iwl-commands.h" -#include "iwl-3945.h" -#include "iwl-sta.h" - -#define RS_NAME "iwl-3945-rs" - -static s32 il3945_expected_tpt_g[RATE_COUNT_3945] = { - 7, 13, 35, 58, 0, 0, 76, 104, 130, 168, 191, 202 -}; - -static s32 il3945_expected_tpt_g_prot[RATE_COUNT_3945] = { - 7, 13, 35, 58, 0, 0, 0, 80, 93, 113, 123, 125 -}; - -static s32 il3945_expected_tpt_a[RATE_COUNT_3945] = { - 0, 0, 0, 0, 40, 57, 72, 98, 121, 154, 177, 186 -}; - -static s32 il3945_expected_tpt_b[RATE_COUNT_3945] = { - 7, 13, 35, 58, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -struct il3945_tpt_entry { - s8 min_rssi; - u8 idx; -}; - -static struct il3945_tpt_entry il3945_tpt_table_a[] = { - {-60, RATE_54M_IDX}, - {-64, RATE_48M_IDX}, - {-72, RATE_36M_IDX}, - {-80, RATE_24M_IDX}, - {-84, RATE_18M_IDX}, - {-85, RATE_12M_IDX}, - {-87, RATE_9M_IDX}, - {-89, RATE_6M_IDX} -}; - -static struct il3945_tpt_entry il3945_tpt_table_g[] = { - {-60, RATE_54M_IDX}, - {-64, RATE_48M_IDX}, - {-68, RATE_36M_IDX}, - {-80, RATE_24M_IDX}, - {-84, RATE_18M_IDX}, - {-85, RATE_12M_IDX}, - {-86, RATE_11M_IDX}, - {-88, RATE_5M_IDX}, - {-90, RATE_2M_IDX}, - {-92, RATE_1M_IDX} -}; - -#define RATE_MAX_WINDOW 62 -#define RATE_FLUSH (3*HZ) -#define RATE_WIN_FLUSH (HZ/2) -#define IL39_RATE_HIGH_TH 11520 -#define IL_SUCCESS_UP_TH 8960 -#define IL_SUCCESS_DOWN_TH 10880 -#define RATE_MIN_FAILURE_TH 6 -#define RATE_MIN_SUCCESS_TH 8 -#define RATE_DECREASE_TH 1920 -#define RATE_RETRY_TH 15 - -static u8 il3945_get_rate_idx_by_rssi(s32 rssi, enum ieee80211_band band) -{ - u32 idx = 0; - u32 table_size = 0; - struct il3945_tpt_entry *tpt_table = NULL; - - if (rssi < IL_MIN_RSSI_VAL || rssi > IL_MAX_RSSI_VAL) - rssi = IL_MIN_RSSI_VAL; - - switch (band) { - case IEEE80211_BAND_2GHZ: - tpt_table = il3945_tpt_table_g; - table_size = ARRAY_SIZE(il3945_tpt_table_g); - break; - - case IEEE80211_BAND_5GHZ: - tpt_table = il3945_tpt_table_a; - table_size = ARRAY_SIZE(il3945_tpt_table_a); - break; - - default: - BUG(); - break; - } - - while (idx < table_size && rssi < tpt_table[idx].min_rssi) - idx++; - - idx = min(idx, (table_size - 1)); - - return tpt_table[idx].idx; -} - -static void il3945_clear_win(struct il3945_rate_scale_data *win) -{ - win->data = 0; - win->success_counter = 0; - win->success_ratio = -1; - win->counter = 0; - win->average_tpt = IL_INVALID_VALUE; - win->stamp = 0; -} - -/** - * il3945_rate_scale_flush_wins - flush out the rate scale wins - * - * Returns the number of wins that have gathered data but were - * not flushed. If there were any that were not flushed, then - * reschedule the rate flushing routine. - */ -static int il3945_rate_scale_flush_wins(struct il3945_rs_sta *rs_sta) -{ - int unflushed = 0; - int i; - unsigned long flags; - struct il_priv *il __maybe_unused = rs_sta->il; - - /* - * For each rate, if we have collected data on that rate - * and it has been more than RATE_WIN_FLUSH - * since we flushed, clear out the gathered stats - */ - for (i = 0; i < RATE_COUNT_3945; i++) { - if (!rs_sta->win[i].counter) - continue; - - spin_lock_irqsave(&rs_sta->lock, flags); - if (time_after(jiffies, rs_sta->win[i].stamp + - RATE_WIN_FLUSH)) { - D_RATE("flushing %d samples of rate " - "idx %d\n", - rs_sta->win[i].counter, i); - il3945_clear_win(&rs_sta->win[i]); - } else - unflushed++; - spin_unlock_irqrestore(&rs_sta->lock, flags); - } - - return unflushed; -} - -#define RATE_FLUSH_MAX 5000 /* msec */ -#define RATE_FLUSH_MIN 50 /* msec */ -#define IL_AVERAGE_PACKETS 1500 - -static void il3945_bg_rate_scale_flush(unsigned long data) -{ - struct il3945_rs_sta *rs_sta = (void *)data; - struct il_priv *il __maybe_unused = rs_sta->il; - int unflushed = 0; - unsigned long flags; - u32 packet_count, duration, pps; - - D_RATE("enter\n"); - - unflushed = il3945_rate_scale_flush_wins(rs_sta); - - spin_lock_irqsave(&rs_sta->lock, flags); - - /* Number of packets Rx'd since last time this timer ran */ - packet_count = (rs_sta->tx_packets - rs_sta->last_tx_packets) + 1; - - rs_sta->last_tx_packets = rs_sta->tx_packets + 1; - - if (unflushed) { - duration = - jiffies_to_msecs(jiffies - rs_sta->last_partial_flush); - - D_RATE("Tx'd %d packets in %dms\n", - packet_count, duration); - - /* Determine packets per second */ - if (duration) - pps = (packet_count * 1000) / duration; - else - pps = 0; - - if (pps) { - duration = (IL_AVERAGE_PACKETS * 1000) / pps; - if (duration < RATE_FLUSH_MIN) - duration = RATE_FLUSH_MIN; - else if (duration > RATE_FLUSH_MAX) - duration = RATE_FLUSH_MAX; - } else - duration = RATE_FLUSH_MAX; - - rs_sta->flush_time = msecs_to_jiffies(duration); - - D_RATE("new flush period: %d msec ave %d\n", - duration, packet_count); - - mod_timer(&rs_sta->rate_scale_flush, jiffies + - rs_sta->flush_time); - - rs_sta->last_partial_flush = jiffies; - } else { - rs_sta->flush_time = RATE_FLUSH; - rs_sta->flush_pending = 0; - } - /* If there weren't any unflushed entries, we don't schedule the timer - * to run again */ - - rs_sta->last_flush = jiffies; - - spin_unlock_irqrestore(&rs_sta->lock, flags); - - D_RATE("leave\n"); -} - -/** - * il3945_collect_tx_data - Update the success/failure sliding win - * - * We keep a sliding win of the last 64 packets transmitted - * at this rate. win->data contains the bitmask of successful - * packets. - */ -static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, - struct il3945_rate_scale_data *win, - int success, int retries, int idx) -{ - unsigned long flags; - s32 fail_count; - struct il_priv *il __maybe_unused = rs_sta->il; - - if (!retries) { - D_RATE("leave: retries == 0 -- should be at least 1\n"); - return; - } - - spin_lock_irqsave(&rs_sta->lock, flags); - - /* - * Keep track of only the latest 62 tx frame attempts in this rate's - * history win; anything older isn't really relevant any more. - * If we have filled up the sliding win, drop the oldest attempt; - * if the oldest attempt (highest bit in bitmap) shows "success", - * subtract "1" from the success counter (this is the main reason - * we keep these bitmaps!). - * */ - while (retries > 0) { - if (win->counter >= RATE_MAX_WINDOW) { - - /* remove earliest */ - win->counter = RATE_MAX_WINDOW - 1; - - if (win->data & (1ULL << (RATE_MAX_WINDOW - 1))) { - win->data &= ~(1ULL << (RATE_MAX_WINDOW - 1)); - win->success_counter--; - } - } - - /* Increment frames-attempted counter */ - win->counter++; - - /* Shift bitmap by one frame (throw away oldest history), - * OR in "1", and increment "success" if this - * frame was successful. */ - win->data <<= 1; - if (success > 0) { - win->success_counter++; - win->data |= 0x1; - success--; - } - - retries--; - } - - /* Calculate current success ratio, avoid divide-by-0! */ - if (win->counter > 0) - win->success_ratio = 128 * (100 * win->success_counter) - / win->counter; - else - win->success_ratio = IL_INVALID_VALUE; - - fail_count = win->counter - win->success_counter; - - /* Calculate average throughput, if we have enough history. */ - if (fail_count >= RATE_MIN_FAILURE_TH || - win->success_counter >= RATE_MIN_SUCCESS_TH) - win->average_tpt = ((win->success_ratio * - rs_sta->expected_tpt[idx] + 64) / 128); - else - win->average_tpt = IL_INVALID_VALUE; - - /* Tag this win as having been updated */ - win->stamp = jiffies; - - spin_unlock_irqrestore(&rs_sta->lock, flags); - -} - -/* - * Called after adding a new station to initialize rate scaling - */ -void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_id) -{ - struct ieee80211_hw *hw = il->hw; - struct ieee80211_conf *conf = &il->hw->conf; - struct il3945_sta_priv *psta; - struct il3945_rs_sta *rs_sta; - struct ieee80211_supported_band *sband; - int i; - - D_INFO("enter\n"); - if (sta_id == il->ctx.bcast_sta_id) - goto out; - - psta = (struct il3945_sta_priv *) sta->drv_priv; - rs_sta = &psta->rs_sta; - sband = hw->wiphy->bands[conf->channel->band]; - - rs_sta->il = il; - - rs_sta->start_rate = RATE_INVALID; - - /* default to just 802.11b */ - rs_sta->expected_tpt = il3945_expected_tpt_b; - - rs_sta->last_partial_flush = jiffies; - rs_sta->last_flush = jiffies; - rs_sta->flush_time = RATE_FLUSH; - rs_sta->last_tx_packets = 0; - - rs_sta->rate_scale_flush.data = (unsigned long)rs_sta; - rs_sta->rate_scale_flush.function = il3945_bg_rate_scale_flush; - - for (i = 0; i < RATE_COUNT_3945; i++) - il3945_clear_win(&rs_sta->win[i]); - - /* TODO: what is a good starting rate for STA? About middle? Maybe not - * the lowest or the highest rate.. Could consider using RSSI from - * previous packets? Need to have IEEE 802.1X auth succeed immediately - * after assoc.. */ - - for (i = sband->n_bitrates - 1; i >= 0; i--) { - if (sta->supp_rates[sband->band] & (1 << i)) { - rs_sta->last_txrate_idx = i; - break; - } - } - - il->_3945.sta_supp_rates = sta->supp_rates[sband->band]; - /* For 5 GHz band it start at IL_FIRST_OFDM_RATE */ - if (sband->band == IEEE80211_BAND_5GHZ) { - rs_sta->last_txrate_idx += IL_FIRST_OFDM_RATE; - il->_3945.sta_supp_rates = il->_3945.sta_supp_rates << - IL_FIRST_OFDM_RATE; - } - -out: - il->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; - - D_INFO("leave\n"); -} - -static void *il3945_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) -{ - return hw->priv; -} - -/* rate scale requires free function to be implemented */ -static void il3945_rs_free(void *il) -{ - return; -} - -static void *il3945_rs_alloc_sta(void *il_priv, struct ieee80211_sta *sta, gfp_t gfp) -{ - struct il3945_rs_sta *rs_sta; - struct il3945_sta_priv *psta = (void *) sta->drv_priv; - struct il_priv *il __maybe_unused = il_priv; - - D_RATE("enter\n"); - - rs_sta = &psta->rs_sta; - - spin_lock_init(&rs_sta->lock); - init_timer(&rs_sta->rate_scale_flush); - - D_RATE("leave\n"); - - return rs_sta; -} - -static void il3945_rs_free_sta(void *il_priv, struct ieee80211_sta *sta, - void *il_sta) -{ - struct il3945_rs_sta *rs_sta = il_sta; - - /* - * Be careful not to use any members of il3945_rs_sta (like trying - * to use il_priv to print out debugging) since it may not be fully - * initialized at this point. - */ - del_timer_sync(&rs_sta->rate_scale_flush); -} - - -/** - * il3945_rs_tx_status - Update rate control values based on Tx results - * - * NOTE: Uses il_priv->retry_rate for the # of retries attempted by - * the hardware for each rate. - */ -static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, void *il_sta, - struct sk_buff *skb) -{ - s8 retries = 0, current_count; - int scale_rate_idx, first_idx, last_idx; - unsigned long flags; - struct il_priv *il = (struct il_priv *)il_rate; - struct il3945_rs_sta *rs_sta = il_sta; - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - - D_RATE("enter\n"); - - retries = info->status.rates[0].count; - /* Sanity Check for retries */ - if (retries > RATE_RETRY_TH) - retries = RATE_RETRY_TH; - - first_idx = sband->bitrates[info->status.rates[0].idx].hw_value; - if (first_idx < 0 || first_idx >= RATE_COUNT_3945) { - D_RATE("leave: Rate out of bounds: %d\n", first_idx); - return; - } - - if (!il_sta) { - D_RATE("leave: No STA il data to update!\n"); - return; - } - - /* Treat uninitialized rate scaling data same as non-existing. */ - if (!rs_sta->il) { - D_RATE("leave: STA il data uninitialized!\n"); - return; - } - - - rs_sta->tx_packets++; - - scale_rate_idx = first_idx; - last_idx = first_idx; - - /* - * Update the win for each rate. We determine which rates - * were Tx'd based on the total number of retries vs. the number - * of retries configured for each rate -- currently set to the - * il value 'retry_rate' vs. rate specific - * - * On exit from this while loop last_idx indicates the rate - * at which the frame was finally transmitted (or failed if no - * ACK) - */ - while (retries > 1) { - if ((retries - 1) < il->retry_rate) { - current_count = (retries - 1); - last_idx = scale_rate_idx; - } else { - current_count = il->retry_rate; - last_idx = il3945_rs_next_rate(il, - scale_rate_idx); - } - - /* Update this rate accounting for as many retries - * as was used for it (per current_count) */ - il3945_collect_tx_data(rs_sta, - &rs_sta->win[scale_rate_idx], - 0, current_count, scale_rate_idx); - D_RATE("Update rate %d for %d retries.\n", - scale_rate_idx, current_count); - - retries -= current_count; - - scale_rate_idx = last_idx; - } - - - /* Update the last idx win with success/failure based on ACK */ - D_RATE("Update rate %d with %s.\n", - last_idx, - (info->flags & IEEE80211_TX_STAT_ACK) ? - "success" : "failure"); - il3945_collect_tx_data(rs_sta, - &rs_sta->win[last_idx], - info->flags & IEEE80211_TX_STAT_ACK, 1, last_idx); - - /* We updated the rate scale win -- if its been more than - * flush_time since the last run, schedule the flush - * again */ - spin_lock_irqsave(&rs_sta->lock, flags); - - if (!rs_sta->flush_pending && - time_after(jiffies, rs_sta->last_flush + - rs_sta->flush_time)) { - - rs_sta->last_partial_flush = jiffies; - rs_sta->flush_pending = 1; - mod_timer(&rs_sta->rate_scale_flush, - jiffies + rs_sta->flush_time); - } - - spin_unlock_irqrestore(&rs_sta->lock, flags); - - D_RATE("leave\n"); -} - -static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, - u8 idx, u16 rate_mask, enum ieee80211_band band) -{ - u8 high = RATE_INVALID; - u8 low = RATE_INVALID; - struct il_priv *il __maybe_unused = rs_sta->il; - - /* 802.11A walks to the next literal adjacent rate in - * the rate table */ - if (unlikely(band == IEEE80211_BAND_5GHZ)) { - int i; - u32 mask; - - /* Find the previous rate that is in the rate mask */ - i = idx - 1; - for (mask = (1 << i); i >= 0; i--, mask >>= 1) { - if (rate_mask & mask) { - low = i; - break; - } - } - - /* Find the next rate that is in the rate mask */ - i = idx + 1; - for (mask = (1 << i); i < RATE_COUNT_3945; - i++, mask <<= 1) { - if (rate_mask & mask) { - high = i; - break; - } - } - - return (high << 8) | low; - } - - low = idx; - while (low != RATE_INVALID) { - if (rs_sta->tgg) - low = il3945_rates[low].prev_rs_tgg; - else - low = il3945_rates[low].prev_rs; - if (low == RATE_INVALID) - break; - if (rate_mask & (1 << low)) - break; - D_RATE("Skipping masked lower rate: %d\n", low); - } - - high = idx; - while (high != RATE_INVALID) { - if (rs_sta->tgg) - high = il3945_rates[high].next_rs_tgg; - else - high = il3945_rates[high].next_rs; - if (high == RATE_INVALID) - break; - if (rate_mask & (1 << high)) - break; - D_RATE("Skipping masked higher rate: %d\n", high); - } - - return (high << 8) | low; -} - -/** - * il3945_rs_get_rate - find the rate for the requested packet - * - * Returns the ieee80211_rate structure allocated by the driver. - * - * The rate control algorithm has no internal mapping between hw_mode's - * rate ordering and the rate ordering used by the rate control algorithm. - * - * The rate control algorithm uses a single table of rates that goes across - * the entire A/B/G spectrum vs. being limited to just one particular - * hw_mode. - * - * As such, we can't convert the idx obtained below into the hw_mode's - * rate table and must reference the driver allocated rate table - * - */ -static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, - void *il_sta, struct ieee80211_tx_rate_control *txrc) -{ - struct ieee80211_supported_band *sband = txrc->sband; - struct sk_buff *skb = txrc->skb; - u8 low = RATE_INVALID; - u8 high = RATE_INVALID; - u16 high_low; - int idx; - struct il3945_rs_sta *rs_sta = il_sta; - struct il3945_rate_scale_data *win = NULL; - int current_tpt = IL_INVALID_VALUE; - int low_tpt = IL_INVALID_VALUE; - int high_tpt = IL_INVALID_VALUE; - u32 fail_count; - s8 scale_action = 0; - unsigned long flags; - u16 rate_mask; - s8 max_rate_idx = -1; - struct il_priv *il __maybe_unused = (struct il_priv *)il_r; - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); - - D_RATE("enter\n"); - - /* Treat uninitialized rate scaling data same as non-existing. */ - if (rs_sta && !rs_sta->il) { - D_RATE("Rate scaling information not initialized yet.\n"); - il_sta = NULL; - } - - if (rate_control_send_low(sta, il_sta, txrc)) - return; - - rate_mask = sta->supp_rates[sband->band]; - - /* get user max rate if set */ - max_rate_idx = txrc->max_rate_idx; - if (sband->band == IEEE80211_BAND_5GHZ && max_rate_idx != -1) - max_rate_idx += IL_FIRST_OFDM_RATE; - if (max_rate_idx < 0 || max_rate_idx >= RATE_COUNT) - max_rate_idx = -1; - - idx = min(rs_sta->last_txrate_idx & 0xffff, RATE_COUNT_3945 - 1); - - if (sband->band == IEEE80211_BAND_5GHZ) - rate_mask = rate_mask << IL_FIRST_OFDM_RATE; - - spin_lock_irqsave(&rs_sta->lock, flags); - - /* for recent assoc, choose best rate regarding - * to rssi value - */ - if (rs_sta->start_rate != RATE_INVALID) { - if (rs_sta->start_rate < idx && - (rate_mask & (1 << rs_sta->start_rate))) - idx = rs_sta->start_rate; - rs_sta->start_rate = RATE_INVALID; - } - - /* force user max rate if set by user */ - if (max_rate_idx != -1 && max_rate_idx < idx) { - if (rate_mask & (1 << max_rate_idx)) - idx = max_rate_idx; - } - - win = &(rs_sta->win[idx]); - - fail_count = win->counter - win->success_counter; - - if (fail_count < RATE_MIN_FAILURE_TH && - win->success_counter < RATE_MIN_SUCCESS_TH) { - spin_unlock_irqrestore(&rs_sta->lock, flags); - - D_RATE("Invalid average_tpt on rate %d: " - "counter: %d, success_counter: %d, " - "expected_tpt is %sNULL\n", - idx, - win->counter, - win->success_counter, - rs_sta->expected_tpt ? "not " : ""); - - /* Can't calculate this yet; not enough history */ - win->average_tpt = IL_INVALID_VALUE; - goto out; - - } - - current_tpt = win->average_tpt; - - high_low = il3945_get_adjacent_rate(rs_sta, idx, rate_mask, - sband->band); - low = high_low & 0xff; - high = (high_low >> 8) & 0xff; - - /* If user set max rate, dont allow higher than user constrain */ - if (max_rate_idx != -1 && max_rate_idx < high) - high = RATE_INVALID; - - /* Collect Measured throughputs of adjacent rates */ - if (low != RATE_INVALID) - low_tpt = rs_sta->win[low].average_tpt; - - if (high != RATE_INVALID) - high_tpt = rs_sta->win[high].average_tpt; - - spin_unlock_irqrestore(&rs_sta->lock, flags); - - scale_action = 0; - - /* Low success ratio , need to drop the rate */ - if (win->success_ratio < RATE_DECREASE_TH || !current_tpt) { - D_RATE("decrease rate because of low success_ratio\n"); - scale_action = -1; - /* No throughput measured yet for adjacent rates, - * try increase */ - } else if (low_tpt == IL_INVALID_VALUE && - high_tpt == IL_INVALID_VALUE) { - - if (high != RATE_INVALID && win->success_ratio >= RATE_INCREASE_TH) - scale_action = 1; - else if (low != RATE_INVALID) - scale_action = 0; - - /* Both adjacent throughputs are measured, but neither one has - * better throughput; we're using the best rate, don't change - * it! */ - } else if (low_tpt != IL_INVALID_VALUE && - high_tpt != IL_INVALID_VALUE && - low_tpt < current_tpt && high_tpt < current_tpt) { - - D_RATE("No action -- low [%d] & high [%d] < " - "current_tpt [%d]\n", - low_tpt, high_tpt, current_tpt); - scale_action = 0; - - /* At least one of the rates has better throughput */ - } else { - if (high_tpt != IL_INVALID_VALUE) { - - /* High rate has better throughput, Increase - * rate */ - if (high_tpt > current_tpt && - win->success_ratio >= RATE_INCREASE_TH) - scale_action = 1; - else { - D_RATE( - "decrease rate because of high tpt\n"); - scale_action = 0; - } - } else if (low_tpt != IL_INVALID_VALUE) { - if (low_tpt > current_tpt) { - D_RATE( - "decrease rate because of low tpt\n"); - scale_action = -1; - } else if (win->success_ratio >= RATE_INCREASE_TH) { - /* Lower rate has better - * throughput,decrease rate */ - scale_action = 1; - } - } - } - - /* Sanity check; asked for decrease, but success rate or throughput - * has been good at old rate. Don't change it. */ - if (scale_action == -1 && low != RATE_INVALID && - (win->success_ratio > RATE_HIGH_TH || - current_tpt > 100 * rs_sta->expected_tpt[low])) - scale_action = 0; - - switch (scale_action) { - case -1: - - /* Decrese rate */ - if (low != RATE_INVALID) - idx = low; - break; - - case 1: - /* Increase rate */ - if (high != RATE_INVALID) - idx = high; - - break; - - case 0: - default: - /* No change */ - break; - } - - D_RATE("Selected %d (action %d) - low %d high %d\n", - idx, scale_action, low, high); - - out: - - if (sband->band == IEEE80211_BAND_5GHZ) { - if (WARN_ON_ONCE(idx < IL_FIRST_OFDM_RATE)) - idx = IL_FIRST_OFDM_RATE; - rs_sta->last_txrate_idx = idx; - info->control.rates[0].idx = idx - IL_FIRST_OFDM_RATE; - } else { - rs_sta->last_txrate_idx = idx; - info->control.rates[0].idx = rs_sta->last_txrate_idx; - } - - D_RATE("leave: %d\n", idx); -} - -#ifdef CONFIG_MAC80211_DEBUGFS -static int il3945_open_file_generic(struct inode *inode, struct file *file) -{ - file->private_data = inode->i_private; - return 0; -} - -static ssize_t il3945_sta_dbgfs_stats_table_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - char *buff; - int desc = 0; - int j; - ssize_t ret; - struct il3945_rs_sta *lq_sta = file->private_data; - - buff = kmalloc(1024, GFP_KERNEL); - if (!buff) - return -ENOMEM; - - desc += sprintf(buff + desc, "tx packets=%d last rate idx=%d\n" - "rate=0x%X flush time %d\n", - lq_sta->tx_packets, - lq_sta->last_txrate_idx, - lq_sta->start_rate, jiffies_to_msecs(lq_sta->flush_time)); - for (j = 0; j < RATE_COUNT_3945; j++) { - desc += sprintf(buff+desc, - "counter=%d success=%d %%=%d\n", - lq_sta->win[j].counter, - lq_sta->win[j].success_counter, - lq_sta->win[j].success_ratio); - } - ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); - kfree(buff); - return ret; -} - -static const struct file_operations rs_sta_dbgfs_stats_table_ops = { - .read = il3945_sta_dbgfs_stats_table_read, - .open = il3945_open_file_generic, - .llseek = default_llseek, -}; - -static void il3945_add_debugfs(void *il, void *il_sta, - struct dentry *dir) -{ - struct il3945_rs_sta *lq_sta = il_sta; - - lq_sta->rs_sta_dbgfs_stats_table_file = - debugfs_create_file("rate_stats_table", 0600, dir, - lq_sta, &rs_sta_dbgfs_stats_table_ops); - -} - -static void il3945_remove_debugfs(void *il, void *il_sta) -{ - struct il3945_rs_sta *lq_sta = il_sta; - debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file); -} -#endif - -/* - * Initialization of rate scaling information is done by driver after - * the station is added. Since mac80211 calls this function before a - * station is added we ignore it. - */ -static void il3945_rs_rate_init_stub(void *il_r, - struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, void *il_sta) -{ -} - -static struct rate_control_ops rs_ops = { - .module = NULL, - .name = RS_NAME, - .tx_status = il3945_rs_tx_status, - .get_rate = il3945_rs_get_rate, - .rate_init = il3945_rs_rate_init_stub, - .alloc = il3945_rs_alloc, - .free = il3945_rs_free, - .alloc_sta = il3945_rs_alloc_sta, - .free_sta = il3945_rs_free_sta, -#ifdef CONFIG_MAC80211_DEBUGFS - .add_sta_debugfs = il3945_add_debugfs, - .remove_sta_debugfs = il3945_remove_debugfs, -#endif - -}; -void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) -{ - struct il_priv *il = hw->priv; - s32 rssi = 0; - unsigned long flags; - struct il3945_rs_sta *rs_sta; - struct ieee80211_sta *sta; - struct il3945_sta_priv *psta; - - D_RATE("enter\n"); - - rcu_read_lock(); - - sta = ieee80211_find_sta(il->ctx.vif, - il->stations[sta_id].sta.sta.addr); - if (!sta) { - D_RATE("Unable to find station to initialize rate scaling.\n"); - rcu_read_unlock(); - return; - } - - psta = (void *) sta->drv_priv; - rs_sta = &psta->rs_sta; - - spin_lock_irqsave(&rs_sta->lock, flags); - - rs_sta->tgg = 0; - switch (il->band) { - case IEEE80211_BAND_2GHZ: - /* TODO: this always does G, not a regression */ - if (il->ctx.active.flags & - RXON_FLG_TGG_PROTECT_MSK) { - rs_sta->tgg = 1; - rs_sta->expected_tpt = il3945_expected_tpt_g_prot; - } else - rs_sta->expected_tpt = il3945_expected_tpt_g; - break; - - case IEEE80211_BAND_5GHZ: - rs_sta->expected_tpt = il3945_expected_tpt_a; - break; - case IEEE80211_NUM_BANDS: - BUG(); - break; - } - - spin_unlock_irqrestore(&rs_sta->lock, flags); - - rssi = il->_3945.last_rx_rssi; - if (rssi == 0) - rssi = IL_MIN_RSSI_VAL; - - D_RATE("Network RSSI: %d\n", rssi); - - rs_sta->start_rate = il3945_get_rate_idx_by_rssi(rssi, il->band); - - D_RATE("leave: rssi %d assign rate idx: " - "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate, - il3945_rates[rs_sta->start_rate].plcp); - rcu_read_unlock(); -} - -int il3945_rate_control_register(void) -{ - return ieee80211_rate_control_register(&rs_ops); -} - -void il3945_rate_control_unregister(void) -{ - ieee80211_rate_control_unregister(&rs_ops); -} -- cgit v1.2.3 From 8f29b456f8b2c560819f698b82ef2efc09ac47c5 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 12:57:25 +0100 Subject: iwlegacy: add accidentally removed comments Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/4965-mac.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index d817d8d3fe18..a8a6461d103f 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -1411,6 +1411,33 @@ void il4965_reply_stats(struct il_priv *il, il4965_rx_stats(il, rxb); } + +/* + * mac80211 queues, ACs, hardware queues, FIFOs. + * + * Cf. http://wireless.kernel.org/en/developers/Documentation/mac80211/queues + * + * Mac80211 uses the following numbers, which we get as from it + * by way of skb_get_queue_mapping(skb): + * + * VO 0 + * VI 1 + * BE 2 + * BK 3 + * + * + * Regular (not A-MPDU) frames are put into hardware queues corresponding + * to the FIFOs, see comments in iwl-prph.h. Aggregated frames get their + * own queue per aggregation session (RA/TID combination), such queues are + * set up to map into FIFOs too, for which we need an AC->FIFO mapping. In + * order to map frames to the right queue, we also need an AC->hw queue + * mapping. This is implemented here. + * + * Due to the way hw queues are set up (by the hw specific modules like + * iwl-4965.c), the AC->hw queue mapping is the identity + * mapping. + */ + static const u8 tid_to_ac[] = { IEEE80211_AC_BE, IEEE80211_AC_BK, -- cgit v1.2.3 From af038f404ffb851dcefa0c56c5c81cacd06f0903 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 30 Aug 2011 13:58:27 +0200 Subject: iwlegacy: move iwl-4965-{,hw,debugfs,calib}.h to 4965.h Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/4965-calib.c | 2 +- drivers/net/wireless/iwlegacy/4965-debug.c | 5 +- drivers/net/wireless/iwlegacy/4965-mac.c | 10 +- drivers/net/wireless/iwlegacy/4965-rs.c | 2 +- drivers/net/wireless/iwlegacy/4965.c | 26 +- drivers/net/wireless/iwlegacy/4965.h | 1004 ++++++++++++++++++++++ drivers/net/wireless/iwlegacy/iwl-4965-calib.h | 75 -- drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h | 59 -- drivers/net/wireless/iwlegacy/iwl-4965-hw.h | 811 ----------------- drivers/net/wireless/iwlegacy/iwl-4965.h | 284 ------ drivers/net/wireless/iwlegacy/iwl-commands.h | 4 +- drivers/net/wireless/iwlegacy/iwl-dev.h | 4 +- drivers/net/wireless/iwlegacy/iwl-eeprom.h | 2 +- drivers/net/wireless/iwlegacy/iwl-prph.h | 2 +- drivers/net/wireless/iwlegacy/iwl-tx.c | 2 +- 15 files changed, 1046 insertions(+), 1246 deletions(-) create mode 100644 drivers/net/wireless/iwlegacy/4965.h delete mode 100644 drivers/net/wireless/iwlegacy/iwl-4965-calib.h delete mode 100644 drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h delete mode 100644 drivers/net/wireless/iwlegacy/iwl-4965-hw.h delete mode 100644 drivers/net/wireless/iwlegacy/iwl-4965.h (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/4965-calib.c b/drivers/net/wireless/iwlegacy/4965-calib.c index 1d873a68830e..1d0502ecb41d 100644 --- a/drivers/net/wireless/iwlegacy/4965-calib.c +++ b/drivers/net/wireless/iwlegacy/4965-calib.c @@ -65,7 +65,7 @@ #include "iwl-dev.h" #include "iwl-core.h" -#include "iwl-4965-calib.h" +#include "4965.h" /***************************************************************************** * INIT calibrations framework diff --git a/drivers/net/wireless/iwlegacy/4965-debug.c b/drivers/net/wireless/iwlegacy/4965-debug.c index 89e5828ce383..825d0aa707e0 100644 --- a/drivers/net/wireless/iwlegacy/4965-debug.c +++ b/drivers/net/wireless/iwlegacy/4965-debug.c @@ -25,8 +25,9 @@ * Intel Linux Wireless * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 *****************************************************************************/ -#include "iwl-4965.h" -#include "iwl-4965-debugfs.h" +#include "iwl-dev.h" +#include "iwl-core.h" +#include "4965.h" static const char *fmt_value = " %-30s %10u\n"; static const char *fmt_table = " %-30s %10u %10u %10u %10u\n"; diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index a8a6461d103f..ee084a885adc 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -56,8 +56,7 @@ #include "iwl-io.h" #include "iwl-helpers.h" #include "iwl-sta.h" -#include "iwl-4965-calib.h" -#include "iwl-4965.h" +#include "4965.h" /****************************************************************************** @@ -820,6 +819,11 @@ static int il4965_get_channels_for_scan(struct il_priv *il, return added; } +static inline u32 il4965_ant_idx_to_flags(u8 ant_idx) +{ + return BIT(ant_idx) << RATE_MCS_ANT_POS; +} + int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) { struct il_host_cmd cmd = { @@ -1434,7 +1438,7 @@ void il4965_reply_stats(struct il_priv *il, * mapping. This is implemented here. * * Due to the way hw queues are set up (by the hw specific modules like - * iwl-4965.c), the AC->hw queue mapping is the identity + * 4965.c), the AC->hw queue mapping is the identity * mapping. */ diff --git a/drivers/net/wireless/iwlegacy/4965-rs.c b/drivers/net/wireless/iwlegacy/4965-rs.c index 4a543114372b..c4bf4aafad9d 100644 --- a/drivers/net/wireless/iwlegacy/4965-rs.c +++ b/drivers/net/wireless/iwlegacy/4965-rs.c @@ -38,7 +38,7 @@ #include "iwl-dev.h" #include "iwl-sta.h" #include "iwl-core.h" -#include "iwl-4965.h" +#include "4965.h" #define IL4965_RS_NAME "iwl-4965-rs" diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 752564d36c98..8199e635d537 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -42,10 +42,8 @@ #include "iwl-core.h" #include "iwl-io.h" #include "iwl-helpers.h" -#include "iwl-4965-calib.h" #include "iwl-sta.h" -#include "iwl-4965.h" -#include "iwl-4965-debugfs.h" +#include "4965.h" #define IL_AC_UNSET -1 @@ -1829,6 +1827,28 @@ static inline u32 il4965_get_scd_ssn(struct il4965_tx_resp *tx_resp) return le32_to_cpup(&tx_resp->u.status + tx_resp->frame_count) & MAX_SN; } +static inline u32 il4965_tx_status_to_mac80211(u32 status) +{ + status &= TX_STATUS_MSK; + + switch (status) { + case TX_STATUS_SUCCESS: + case TX_STATUS_DIRECT_DONE: + return IEEE80211_TX_STAT_ACK; + case TX_STATUS_FAIL_DEST_PS: + return IEEE80211_TX_STAT_TX_FILTERED; + default: + return 0; + } +} + +static inline bool il4965_is_tx_success(u32 status) +{ + status &= TX_STATUS_MSK; + return (status == TX_STATUS_SUCCESS || + status == TX_STATUS_DIRECT_DONE); +} + /** * il4965_tx_status_reply_tx - Handle Tx response for frames in aggregation queue */ diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h new file mode 100644 index 000000000000..b1a01c9bbbc8 --- /dev/null +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -0,0 +1,1004 @@ +/****************************************************************************** + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, + * USA + * + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + *****************************************************************************/ + +#ifndef __il_4965_h__ +#define __il_4965_h__ + +#include "iwl-fh.h" +#include "iwl-debug.h" + +struct il_rx_queue; +struct il_rx_buf; +struct il_rx_pkt; +struct il_tx_queue; +struct il_rxon_context; + +/* configuration for the _4965 devices */ +extern struct il_cfg il4965_cfg; + +extern struct il_mod_params il4965_mod_params; + +extern struct ieee80211_ops il4965_hw_ops; + +/* tx queue */ +void il4965_free_tfds_in_queue(struct il_priv *il, + int sta_id, int tid, int freed); + +/* RXON */ +void il4965_set_rxon_chain(struct il_priv *il, + struct il_rxon_context *ctx); + +/* uCode */ +int il4965_verify_ucode(struct il_priv *il); + +/* lib */ +void il4965_check_abort_status(struct il_priv *il, + u8 frame_count, u32 status); + +void il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq); +int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq); +int il4965_hw_nic_init(struct il_priv *il); +int il4965_dump_fh(struct il_priv *il, char **buf, bool display); + +/* rx */ +void il4965_rx_queue_restock(struct il_priv *il); +void il4965_rx_replenish(struct il_priv *il); +void il4965_rx_replenish_now(struct il_priv *il); +void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq); +int il4965_rxq_stop(struct il_priv *il); +int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); +void il4965_rx_reply_rx(struct il_priv *il, + struct il_rx_buf *rxb); +void il4965_rx_reply_rx_phy(struct il_priv *il, + struct il_rx_buf *rxb); +void il4965_rx_handle(struct il_priv *il); + +/* tx */ +void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq); +int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, + struct il_tx_queue *txq, + dma_addr_t addr, u16 len, u8 reset, u8 pad); +int il4965_hw_tx_queue_init(struct il_priv *il, + struct il_tx_queue *txq); +void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, + struct ieee80211_tx_info *info); +int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb); +int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, + struct ieee80211_sta *sta, u16 tid, u16 *ssn); +int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, + struct ieee80211_sta *sta, u16 tid); +int il4965_txq_check_empty(struct il_priv *il, + int sta_id, u8 tid, int txq_id); +void il4965_rx_reply_compressed_ba(struct il_priv *il, + struct il_rx_buf *rxb); +int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx); +void il4965_hw_txq_ctx_free(struct il_priv *il); +int il4965_txq_ctx_alloc(struct il_priv *il); +void il4965_txq_ctx_reset(struct il_priv *il); +void il4965_txq_ctx_stop(struct il_priv *il); +void il4965_txq_set_sched(struct il_priv *il, u32 mask); + +/* + * Acquire il->lock before calling this function ! + */ +void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx); +/** + * il4965_tx_queue_set_status - (optionally) start Tx/Cmd queue + * @tx_fifo_id: Tx DMA/FIFO channel (range 0-7) that the queue will feed + * @scd_retry: (1) Indicates queue will be used in aggregation mode + * + * NOTE: Acquire il->lock before calling this function ! + */ +void il4965_tx_queue_set_status(struct il_priv *il, + struct il_tx_queue *txq, + int tx_fifo_id, int scd_retry); + +u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant_idx, u8 valid); + +/* rx */ +void il4965_rx_missed_beacon_notif(struct il_priv *il, + struct il_rx_buf *rxb); +bool il4965_good_plcp_health(struct il_priv *il, + struct il_rx_pkt *pkt); +void il4965_rx_stats(struct il_priv *il, + struct il_rx_buf *rxb); +void il4965_reply_stats(struct il_priv *il, + struct il_rx_buf *rxb); + +/* scan */ +int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif); + +/* station mgmt */ +int il4965_manage_ibss_station(struct il_priv *il, + struct ieee80211_vif *vif, bool add); + +/* hcmd */ +int il4965_send_beacon_cmd(struct il_priv *il); + +#ifdef CONFIG_IWLEGACY_DEBUG +const char *il4965_get_tx_fail_reason(u32 status); +#else +static inline const char * +il4965_get_tx_fail_reason(u32 status) { return ""; } +#endif + +/* station management */ +int il4965_alloc_bcast_station(struct il_priv *il, + struct il_rxon_context *ctx); +int il4965_add_bssid_station(struct il_priv *il, + struct il_rxon_context *ctx, + const u8 *addr, u8 *sta_id_r); +int il4965_remove_default_wep_key(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *key); +int il4965_set_default_wep_key(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *key); +int il4965_restore_default_wep_keys(struct il_priv *il, + struct il_rxon_context *ctx); +int il4965_set_dynamic_key(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *key, u8 sta_id); +int il4965_remove_dynamic_key(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *key, u8 sta_id); +void il4965_update_tkip_key(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, + struct ieee80211_sta *sta, u32 iv32, u16 *phase1key); +int il4965_sta_tx_modify_enable_tid(struct il_priv *il, + int sta_id, int tid); +int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta, + int tid, u16 ssn); +int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta, + int tid); +void il4965_sta_modify_sleep_tx_count(struct il_priv *il, + int sta_id, int cnt); +int il4965_update_bcast_stations(struct il_priv *il); + +/* rate */ +static inline u8 il4965_hw_get_rate(__le32 rate_n_flags) +{ + return le32_to_cpu(rate_n_flags) & 0xFF; +} + +static inline __le32 il4965_hw_set_rate_n_flags(u8 rate, u32 flags) +{ + return cpu_to_le32(flags|(u32)rate); +} + +/* eeprom */ +void il4965_eeprom_get_mac(const struct il_priv *il, u8 *mac); +int il4965_eeprom_acquire_semaphore(struct il_priv *il); +void il4965_eeprom_release_semaphore(struct il_priv *il); +int il4965_eeprom_check_version(struct il_priv *il); + +/* mac80211 handlers (for 4965) */ +void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb); +int il4965_mac_start(struct ieee80211_hw *hw); +void il4965_mac_stop(struct ieee80211_hw *hw); +void il4965_configure_filter(struct ieee80211_hw *hw, + unsigned int changed_flags, + unsigned int *total_flags, + u64 multicast); +int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, + struct ieee80211_vif *vif, struct ieee80211_sta *sta, + struct ieee80211_key_conf *key); +void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_key_conf *keyconf, + struct ieee80211_sta *sta, + u32 iv32, u16 *phase1key); +int il4965_mac_ampdu_action(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + enum ieee80211_ampdu_mlme_action action, + struct ieee80211_sta *sta, u16 tid, u16 *ssn, + u8 buf_size); +int il4965_mac_sta_add(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta); +void il4965_mac_channel_switch(struct ieee80211_hw *hw, + struct ieee80211_channel_switch *ch_switch); + +void il4965_led_enable(struct il_priv *il); + + +/* EEPROM */ +#define IL4965_EEPROM_IMG_SIZE 1024 + +/* + * uCode queue management definitions ... + * The first queue used for block-ack aggregation is #7 (4965 only). + * All block-ack aggregation queues should map to Tx DMA/FIFO channel 7. + */ +#define IL49_FIRST_AMPDU_QUEUE 7 + +/* Sizes and addresses for instruction and data memory (SRAM) in + * 4965's embedded processor. Driver access is via HBUS_TARG_MEM_* regs. */ +#define IL49_RTC_INST_LOWER_BOUND (0x000000) +#define IL49_RTC_INST_UPPER_BOUND (0x018000) + +#define IL49_RTC_DATA_LOWER_BOUND (0x800000) +#define IL49_RTC_DATA_UPPER_BOUND (0x80A000) + +#define IL49_RTC_INST_SIZE (IL49_RTC_INST_UPPER_BOUND - \ + IL49_RTC_INST_LOWER_BOUND) +#define IL49_RTC_DATA_SIZE (IL49_RTC_DATA_UPPER_BOUND - \ + IL49_RTC_DATA_LOWER_BOUND) + +#define IL49_MAX_INST_SIZE IL49_RTC_INST_SIZE +#define IL49_MAX_DATA_SIZE IL49_RTC_DATA_SIZE + +/* Size of uCode instruction memory in bootstrap state machine */ +#define IL49_MAX_BSM_SIZE BSM_SRAM_SIZE + +static inline int il4965_hw_valid_rtc_data_addr(u32 addr) +{ + return (addr >= IL49_RTC_DATA_LOWER_BOUND && + addr < IL49_RTC_DATA_UPPER_BOUND); +} + +/********************* START TEMPERATURE *************************************/ + +/** + * 4965 temperature calculation. + * + * The driver must calculate the device temperature before calculating + * a txpower setting (amplifier gain is temperature dependent). The + * calculation uses 4 measurements, 3 of which (R1, R2, R3) are calibration + * values used for the life of the driver, and one of which (R4) is the + * real-time temperature indicator. + * + * uCode provides all 4 values to the driver via the "initialize alive" + * notification (see struct il4965_init_alive_resp). After the runtime uCode + * image loads, uCode updates the R4 value via stats notifications + * (see STATISTICS_NOTIFICATION), which occur after each received beacon + * when associated, or can be requested via REPLY_STATISTICS_CMD. + * + * NOTE: uCode provides the R4 value as a 23-bit signed value. Driver + * must sign-extend to 32 bits before applying formula below. + * + * Formula: + * + * degrees Kelvin = ((97 * 259 * (R4 - R2) / (R3 - R1)) / 100) + 8 + * + * NOTE: The basic formula is 259 * (R4-R2) / (R3-R1). The 97/100 is + * an additional correction, which should be centered around 0 degrees + * Celsius (273 degrees Kelvin). The 8 (3 percent of 273) compensates for + * centering the 97/100 correction around 0 degrees K. + * + * Add 273 to Kelvin value to find degrees Celsius, for comparing current + * temperature with factory-measured temperatures when calculating txpower + * settings. + */ +#define TEMPERATURE_CALIB_KELVIN_OFFSET 8 +#define TEMPERATURE_CALIB_A_VAL 259 + +/* Limit range of calculated temperature to be between these Kelvin values */ +#define IL_TX_POWER_TEMPERATURE_MIN (263) +#define IL_TX_POWER_TEMPERATURE_MAX (410) + +#define IL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(t) \ + ((t) < IL_TX_POWER_TEMPERATURE_MIN || \ + (t) > IL_TX_POWER_TEMPERATURE_MAX) + +/********************* END TEMPERATURE ***************************************/ + +/********************* START TXPOWER *****************************************/ + +/** + * 4965 txpower calculations rely on information from three sources: + * + * 1) EEPROM + * 2) "initialize" alive notification + * 3) stats notifications + * + * EEPROM data consists of: + * + * 1) Regulatory information (max txpower and channel usage flags) is provided + * separately for each channel that can possibly supported by 4965. + * 40 MHz wide (.11n HT40) channels are listed separately from 20 MHz + * (legacy) channels. + * + * See struct il4965_eeprom_channel for format, and struct il4965_eeprom + * for locations in EEPROM. + * + * 2) Factory txpower calibration information is provided separately for + * sub-bands of contiguous channels. 2.4GHz has just one sub-band, + * but 5 GHz has several sub-bands. + * + * In addition, per-band (2.4 and 5 Ghz) saturation txpowers are provided. + * + * See struct il4965_eeprom_calib_info (and the tree of structures + * contained within it) for format, and struct il4965_eeprom for + * locations in EEPROM. + * + * "Initialization alive" notification (see struct il4965_init_alive_resp) + * consists of: + * + * 1) Temperature calculation parameters. + * + * 2) Power supply voltage measurement. + * + * 3) Tx gain compensation to balance 2 transmitters for MIMO use. + * + * Statistics notifications deliver: + * + * 1) Current values for temperature param R4. + */ + +/** + * To calculate a txpower setting for a given desired target txpower, channel, + * modulation bit rate, and transmitter chain (4965 has 2 transmitters to + * support MIMO and transmit diversity), driver must do the following: + * + * 1) Compare desired txpower vs. (EEPROM) regulatory limit for this channel. + * Do not exceed regulatory limit; reduce target txpower if necessary. + * + * If setting up txpowers for MIMO rates (rate idxes 8-15, 24-31), + * 2 transmitters will be used simultaneously; driver must reduce the + * regulatory limit by 3 dB (half-power) for each transmitter, so the + * combined total output of the 2 transmitters is within regulatory limits. + * + * + * 2) Compare target txpower vs. (EEPROM) saturation txpower *reduced by + * backoff for this bit rate*. Do not exceed (saturation - backoff[rate]); + * reduce target txpower if necessary. + * + * Backoff values below are in 1/2 dB units (equivalent to steps in + * txpower gain tables): + * + * OFDM 6 - 36 MBit: 10 steps (5 dB) + * OFDM 48 MBit: 15 steps (7.5 dB) + * OFDM 54 MBit: 17 steps (8.5 dB) + * OFDM 60 MBit: 20 steps (10 dB) + * CCK all rates: 10 steps (5 dB) + * + * Backoff values apply to saturation txpower on a per-transmitter basis; + * when using MIMO (2 transmitters), each transmitter uses the same + * saturation level provided in EEPROM, and the same backoff values; + * no reduction (such as with regulatory txpower limits) is required. + * + * Saturation and Backoff values apply equally to 20 Mhz (legacy) channel + * widths and 40 Mhz (.11n HT40) channel widths; there is no separate + * factory measurement for ht40 channels. + * + * The result of this step is the final target txpower. The rest of + * the steps figure out the proper settings for the device to achieve + * that target txpower. + * + * + * 3) Determine (EEPROM) calibration sub band for the target channel, by + * comparing against first and last channels in each sub band + * (see struct il4965_eeprom_calib_subband_info). + * + * + * 4) Linearly interpolate (EEPROM) factory calibration measurement sets, + * referencing the 2 factory-measured (sample) channels within the sub band. + * + * Interpolation is based on difference between target channel's frequency + * and the sample channels' frequencies. Since channel numbers are based + * on frequency (5 MHz between each channel number), this is equivalent + * to interpolating based on channel number differences. + * + * Note that the sample channels may or may not be the channels at the + * edges of the sub band. The target channel may be "outside" of the + * span of the sampled channels. + * + * Driver may choose the pair (for 2 Tx chains) of measurements (see + * struct il4965_eeprom_calib_ch_info) for which the actual measured + * txpower comes closest to the desired txpower. Usually, though, + * the middle set of measurements is closest to the regulatory limits, + * and is therefore a good choice for all txpower calculations (this + * assumes that high accuracy is needed for maximizing legal txpower, + * while lower txpower configurations do not need as much accuracy). + * + * Driver should interpolate both members of the chosen measurement pair, + * i.e. for both Tx chains (radio transmitters), unless the driver knows + * that only one of the chains will be used (e.g. only one tx antenna + * connected, but this should be unusual). The rate scaling algorithm + * switches antennas to find best performance, so both Tx chains will + * be used (although only one at a time) even for non-MIMO transmissions. + * + * Driver should interpolate factory values for temperature, gain table + * idx, and actual power. The power amplifier detector values are + * not used by the driver. + * + * Sanity check: If the target channel happens to be one of the sample + * channels, the results should agree with the sample channel's + * measurements! + * + * + * 5) Find difference between desired txpower and (interpolated) + * factory-measured txpower. Using (interpolated) factory gain table idx + * (shown elsewhere) as a starting point, adjust this idx lower to + * increase txpower, or higher to decrease txpower, until the target + * txpower is reached. Each step in the gain table is 1/2 dB. + * + * For example, if factory measured txpower is 16 dBm, and target txpower + * is 13 dBm, add 6 steps to the factory gain idx to reduce txpower + * by 3 dB. + * + * + * 6) Find difference between current device temperature and (interpolated) + * factory-measured temperature for sub-band. Factory values are in + * degrees Celsius. To calculate current temperature, see comments for + * "4965 temperature calculation". + * + * If current temperature is higher than factory temperature, driver must + * increase gain (lower gain table idx), and vice verse. + * + * Temperature affects gain differently for different channels: + * + * 2.4 GHz all channels: 3.5 degrees per half-dB step + * 5 GHz channels 34-43: 4.5 degrees per half-dB step + * 5 GHz channels >= 44: 4.0 degrees per half-dB step + * + * NOTE: Temperature can increase rapidly when transmitting, especially + * with heavy traffic at high txpowers. Driver should update + * temperature calculations often under these conditions to + * maintain strong txpower in the face of rising temperature. + * + * + * 7) Find difference between current power supply voltage indicator + * (from "initialize alive") and factory-measured power supply voltage + * indicator (EEPROM). + * + * If the current voltage is higher (indicator is lower) than factory + * voltage, gain should be reduced (gain table idx increased) by: + * + * (eeprom - current) / 7 + * + * If the current voltage is lower (indicator is higher) than factory + * voltage, gain should be increased (gain table idx decreased) by: + * + * 2 * (current - eeprom) / 7 + * + * If number of idx steps in either direction turns out to be > 2, + * something is wrong ... just use 0. + * + * NOTE: Voltage compensation is independent of band/channel. + * + * NOTE: "Initialize" uCode measures current voltage, which is assumed + * to be constant after this initial measurement. Voltage + * compensation for txpower (number of steps in gain table) + * may be calculated once and used until the next uCode bootload. + * + * + * 8) If setting up txpowers for MIMO rates (rate idxes 8-15, 24-31), + * adjust txpower for each transmitter chain, so txpower is balanced + * between the two chains. There are 5 pairs of tx_atten[group][chain] + * values in "initialize alive", one pair for each of 5 channel ranges: + * + * Group 0: 5 GHz channel 34-43 + * Group 1: 5 GHz channel 44-70 + * Group 2: 5 GHz channel 71-124 + * Group 3: 5 GHz channel 125-200 + * Group 4: 2.4 GHz all channels + * + * Add the tx_atten[group][chain] value to the idx for the target chain. + * The values are signed, but are in pairs of 0 and a non-negative number, + * so as to reduce gain (if necessary) of the "hotter" channel. This + * avoids any need to double-check for regulatory compliance after + * this step. + * + * + * 9) If setting up for a CCK rate, lower the gain by adding a CCK compensation + * value to the idx: + * + * Hardware rev B: 9 steps (4.5 dB) + * Hardware rev C: 5 steps (2.5 dB) + * + * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG, + * bits [3:2], 1 = B, 2 = C. + * + * NOTE: This compensation is in addition to any saturation backoff that + * might have been applied in an earlier step. + * + * + * 10) Select the gain table, based on band (2.4 vs 5 GHz). + * + * Limit the adjusted idx to stay within the table! + * + * + * 11) Read gain table entries for DSP and radio gain, place into appropriate + * location(s) in command (struct il4965_txpowertable_cmd). + */ + +/** + * When MIMO is used (2 transmitters operating simultaneously), driver should + * limit each transmitter to deliver a max of 3 dB below the regulatory limit + * for the device. That is, use half power for each transmitter, so total + * txpower is within regulatory limits. + * + * The value "6" represents number of steps in gain table to reduce power 3 dB. + * Each step is 1/2 dB. + */ +#define IL_TX_POWER_MIMO_REGULATORY_COMPENSATION (6) + +/** + * CCK gain compensation. + * + * When calculating txpowers for CCK, after making sure that the target power + * is within regulatory and saturation limits, driver must additionally + * back off gain by adding these values to the gain table idx. + * + * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG, + * bits [3:2], 1 = B, 2 = C. + */ +#define IL_TX_POWER_CCK_COMPENSATION_B_STEP (9) +#define IL_TX_POWER_CCK_COMPENSATION_C_STEP (5) + +/* + * 4965 power supply voltage compensation for txpower + */ +#define TX_POWER_IL_VOLTAGE_CODES_PER_03V (7) + +/** + * Gain tables. + * + * The following tables contain pair of values for setting txpower, i.e. + * gain settings for the output of the device's digital signal processor (DSP), + * and for the analog gain structure of the transmitter. + * + * Each entry in the gain tables represents a step of 1/2 dB. Note that these + * are *relative* steps, not indications of absolute output power. Output + * power varies with temperature, voltage, and channel frequency, and also + * requires consideration of average power (to satisfy regulatory constraints), + * and peak power (to avoid distortion of the output signal). + * + * Each entry contains two values: + * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained + * linear value that multiplies the output of the digital signal processor, + * before being sent to the analog radio. + * 2) Radio gain. This sets the analog gain of the radio Tx path. + * It is a coarser setting, and behaves in a logarithmic (dB) fashion. + * + * EEPROM contains factory calibration data for txpower. This maps actual + * measured txpower levels to gain settings in the "well known" tables + * below ("well-known" means here that both factory calibration *and* the + * driver work with the same table). + * + * There are separate tables for 2.4 GHz and 5 GHz bands. The 5 GHz table + * has an extension (into negative idxes), in case the driver needs to + * boost power setting for high device temperatures (higher than would be + * present during factory calibration). A 5 Ghz EEPROM idx of "40" + * corresponds to the 49th entry in the table used by the driver. + */ +#define MIN_TX_GAIN_IDX (0) /* highest gain, lowest idx, 2.4 */ +#define MIN_TX_GAIN_IDX_52GHZ_EXT (-9) /* highest gain, lowest idx, 5 */ + +/** + * 2.4 GHz gain table + * + * Index Dsp gain Radio gain + * 0 110 0x3f (highest gain) + * 1 104 0x3f + * 2 98 0x3f + * 3 110 0x3e + * 4 104 0x3e + * 5 98 0x3e + * 6 110 0x3d + * 7 104 0x3d + * 8 98 0x3d + * 9 110 0x3c + * 10 104 0x3c + * 11 98 0x3c + * 12 110 0x3b + * 13 104 0x3b + * 14 98 0x3b + * 15 110 0x3a + * 16 104 0x3a + * 17 98 0x3a + * 18 110 0x39 + * 19 104 0x39 + * 20 98 0x39 + * 21 110 0x38 + * 22 104 0x38 + * 23 98 0x38 + * 24 110 0x37 + * 25 104 0x37 + * 26 98 0x37 + * 27 110 0x36 + * 28 104 0x36 + * 29 98 0x36 + * 30 110 0x35 + * 31 104 0x35 + * 32 98 0x35 + * 33 110 0x34 + * 34 104 0x34 + * 35 98 0x34 + * 36 110 0x33 + * 37 104 0x33 + * 38 98 0x33 + * 39 110 0x32 + * 40 104 0x32 + * 41 98 0x32 + * 42 110 0x31 + * 43 104 0x31 + * 44 98 0x31 + * 45 110 0x30 + * 46 104 0x30 + * 47 98 0x30 + * 48 110 0x6 + * 49 104 0x6 + * 50 98 0x6 + * 51 110 0x5 + * 52 104 0x5 + * 53 98 0x5 + * 54 110 0x4 + * 55 104 0x4 + * 56 98 0x4 + * 57 110 0x3 + * 58 104 0x3 + * 59 98 0x3 + * 60 110 0x2 + * 61 104 0x2 + * 62 98 0x2 + * 63 110 0x1 + * 64 104 0x1 + * 65 98 0x1 + * 66 110 0x0 + * 67 104 0x0 + * 68 98 0x0 + * 69 97 0 + * 70 96 0 + * 71 95 0 + * 72 94 0 + * 73 93 0 + * 74 92 0 + * 75 91 0 + * 76 90 0 + * 77 89 0 + * 78 88 0 + * 79 87 0 + * 80 86 0 + * 81 85 0 + * 82 84 0 + * 83 83 0 + * 84 82 0 + * 85 81 0 + * 86 80 0 + * 87 79 0 + * 88 78 0 + * 89 77 0 + * 90 76 0 + * 91 75 0 + * 92 74 0 + * 93 73 0 + * 94 72 0 + * 95 71 0 + * 96 70 0 + * 97 69 0 + * 98 68 0 + */ + +/** + * 5 GHz gain table + * + * Index Dsp gain Radio gain + * -9 123 0x3F (highest gain) + * -8 117 0x3F + * -7 110 0x3F + * -6 104 0x3F + * -5 98 0x3F + * -4 110 0x3E + * -3 104 0x3E + * -2 98 0x3E + * -1 110 0x3D + * 0 104 0x3D + * 1 98 0x3D + * 2 110 0x3C + * 3 104 0x3C + * 4 98 0x3C + * 5 110 0x3B + * 6 104 0x3B + * 7 98 0x3B + * 8 110 0x3A + * 9 104 0x3A + * 10 98 0x3A + * 11 110 0x39 + * 12 104 0x39 + * 13 98 0x39 + * 14 110 0x38 + * 15 104 0x38 + * 16 98 0x38 + * 17 110 0x37 + * 18 104 0x37 + * 19 98 0x37 + * 20 110 0x36 + * 21 104 0x36 + * 22 98 0x36 + * 23 110 0x35 + * 24 104 0x35 + * 25 98 0x35 + * 26 110 0x34 + * 27 104 0x34 + * 28 98 0x34 + * 29 110 0x33 + * 30 104 0x33 + * 31 98 0x33 + * 32 110 0x32 + * 33 104 0x32 + * 34 98 0x32 + * 35 110 0x31 + * 36 104 0x31 + * 37 98 0x31 + * 38 110 0x30 + * 39 104 0x30 + * 40 98 0x30 + * 41 110 0x25 + * 42 104 0x25 + * 43 98 0x25 + * 44 110 0x24 + * 45 104 0x24 + * 46 98 0x24 + * 47 110 0x23 + * 48 104 0x23 + * 49 98 0x23 + * 50 110 0x22 + * 51 104 0x18 + * 52 98 0x18 + * 53 110 0x17 + * 54 104 0x17 + * 55 98 0x17 + * 56 110 0x16 + * 57 104 0x16 + * 58 98 0x16 + * 59 110 0x15 + * 60 104 0x15 + * 61 98 0x15 + * 62 110 0x14 + * 63 104 0x14 + * 64 98 0x14 + * 65 110 0x13 + * 66 104 0x13 + * 67 98 0x13 + * 68 110 0x12 + * 69 104 0x08 + * 70 98 0x08 + * 71 110 0x07 + * 72 104 0x07 + * 73 98 0x07 + * 74 110 0x06 + * 75 104 0x06 + * 76 98 0x06 + * 77 110 0x05 + * 78 104 0x05 + * 79 98 0x05 + * 80 110 0x04 + * 81 104 0x04 + * 82 98 0x04 + * 83 110 0x03 + * 84 104 0x03 + * 85 98 0x03 + * 86 110 0x02 + * 87 104 0x02 + * 88 98 0x02 + * 89 110 0x01 + * 90 104 0x01 + * 91 98 0x01 + * 92 110 0x00 + * 93 104 0x00 + * 94 98 0x00 + * 95 93 0x00 + * 96 88 0x00 + * 97 83 0x00 + * 98 78 0x00 + */ + + +/** + * Sanity checks and default values for EEPROM regulatory levels. + * If EEPROM values fall outside MIN/MAX range, use default values. + * + * Regulatory limits refer to the maximum average txpower allowed by + * regulatory agencies in the geographies in which the device is meant + * to be operated. These limits are SKU-specific (i.e. geography-specific), + * and channel-specific; each channel has an individual regulatory limit + * listed in the EEPROM. + * + * Units are in half-dBm (i.e. "34" means 17 dBm). + */ +#define IL_TX_POWER_DEFAULT_REGULATORY_24 (34) +#define IL_TX_POWER_DEFAULT_REGULATORY_52 (34) +#define IL_TX_POWER_REGULATORY_MIN (0) +#define IL_TX_POWER_REGULATORY_MAX (34) + +/** + * Sanity checks and default values for EEPROM saturation levels. + * If EEPROM values fall outside MIN/MAX range, use default values. + * + * Saturation is the highest level that the output power amplifier can produce + * without significant clipping distortion. This is a "peak" power level. + * Different types of modulation (i.e. various "rates", and OFDM vs. CCK) + * require differing amounts of backoff, relative to their average power output, + * in order to avoid clipping distortion. + * + * Driver must make sure that it is violating neither the saturation limit, + * nor the regulatory limit, when calculating Tx power settings for various + * rates. + * + * Units are in half-dBm (i.e. "38" means 19 dBm). + */ +#define IL_TX_POWER_DEFAULT_SATURATION_24 (38) +#define IL_TX_POWER_DEFAULT_SATURATION_52 (38) +#define IL_TX_POWER_SATURATION_MIN (20) +#define IL_TX_POWER_SATURATION_MAX (50) + +/** + * Channel groups used for Tx Attenuation calibration (MIMO tx channel balance) + * and thermal Txpower calibration. + * + * When calculating txpower, driver must compensate for current device + * temperature; higher temperature requires higher gain. Driver must calculate + * current temperature (see "4965 temperature calculation"), then compare vs. + * factory calibration temperature in EEPROM; if current temperature is higher + * than factory temperature, driver must *increase* gain by proportions shown + * in table below. If current temperature is lower than factory, driver must + * *decrease* gain. + * + * Different frequency ranges require different compensation, as shown below. + */ +/* Group 0, 5.2 GHz ch 34-43: 4.5 degrees per 1/2 dB. */ +#define CALIB_IL_TX_ATTEN_GR1_FCH 34 +#define CALIB_IL_TX_ATTEN_GR1_LCH 43 + +/* Group 1, 5.3 GHz ch 44-70: 4.0 degrees per 1/2 dB. */ +#define CALIB_IL_TX_ATTEN_GR2_FCH 44 +#define CALIB_IL_TX_ATTEN_GR2_LCH 70 + +/* Group 2, 5.5 GHz ch 71-124: 4.0 degrees per 1/2 dB. */ +#define CALIB_IL_TX_ATTEN_GR3_FCH 71 +#define CALIB_IL_TX_ATTEN_GR3_LCH 124 + +/* Group 3, 5.7 GHz ch 125-200: 4.0 degrees per 1/2 dB. */ +#define CALIB_IL_TX_ATTEN_GR4_FCH 125 +#define CALIB_IL_TX_ATTEN_GR4_LCH 200 + +/* Group 4, 2.4 GHz all channels: 3.5 degrees per 1/2 dB. */ +#define CALIB_IL_TX_ATTEN_GR5_FCH 1 +#define CALIB_IL_TX_ATTEN_GR5_LCH 20 + +enum { + CALIB_CH_GROUP_1 = 0, + CALIB_CH_GROUP_2 = 1, + CALIB_CH_GROUP_3 = 2, + CALIB_CH_GROUP_4 = 3, + CALIB_CH_GROUP_5 = 4, + CALIB_CH_GROUP_MAX +}; + +/********************* END TXPOWER *****************************************/ + + +/** + * Tx/Rx Queues + * + * Most communication between driver and 4965 is via queues of data buffers. + * For example, all commands that the driver issues to device's embedded + * controller (uCode) are via the command queue (one of the Tx queues). All + * uCode command responses/replies/notifications, including Rx frames, are + * conveyed from uCode to driver via the Rx queue. + * + * Most support for these queues, including handshake support, resides in + * structures in host DRAM, shared between the driver and the device. When + * allocating this memory, the driver must make sure that data written by + * the host CPU updates DRAM immediately (and does not get "stuck" in CPU's + * cache memory), so DRAM and cache are consistent, and the device can + * immediately see changes made by the driver. + * + * 4965 supports up to 16 DRAM-based Tx queues, and services these queues via + * up to 7 DMA channels (FIFOs). Each Tx queue is supported by a circular array + * in DRAM containing 256 Transmit Frame Descriptors (TFDs). + */ +#define IL49_NUM_FIFOS 7 +#define IL49_CMD_FIFO_NUM 4 +#define IL49_NUM_QUEUES 16 +#define IL49_NUM_AMPDU_QUEUES 8 + + +/** + * struct il4965_schedq_bc_tbl + * + * Byte Count table + * + * Each Tx queue uses a byte-count table containing 320 entries: + * one 16-bit entry for each of 256 TFDs, plus an additional 64 entries that + * duplicate the first 64 entries (to avoid wrap-around within a Tx win; + * max Tx win is 64 TFDs). + * + * When driver sets up a new TFD, it must also enter the total byte count + * of the frame to be transmitted into the corresponding entry in the byte + * count table for the chosen Tx queue. If the TFD idx is 0-63, the driver + * must duplicate the byte count entry in corresponding idx 256-319. + * + * padding puts each byte count table on a 1024-byte boundary; + * 4965 assumes tables are separated by 1024 bytes. + */ +struct il4965_scd_bc_tbl { + __le16 tfd_offset[TFD_QUEUE_BC_SIZE]; + u8 pad[1024 - (TFD_QUEUE_BC_SIZE) * sizeof(__le16)]; +} __packed; + + +#define IL4965_RTC_INST_LOWER_BOUND (0x000000) + +/* RSSI to dBm */ +#define IL4965_RSSI_OFFSET 44 + +/* PCI registers */ +#define PCI_CFG_RETRY_TIMEOUT 0x041 + +/* PCI register values */ +#define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01 +#define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02 + +#define IL4965_DEFAULT_TX_RETRY 15 + +/* EEPROM */ +#define IL4965_FIRST_AMPDU_QUEUE 10 + +/* Calibration */ +void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp); +void il4965_sensitivity_calibration(struct il_priv *il, void *resp); +void il4965_init_sensitivity(struct il_priv *il); +void il4965_reset_run_time_calib(struct il_priv *il); +void il4965_calib_free_results(struct il_priv *il); + +/* Debug */ +#ifdef CONFIG_IWLEGACY_DEBUGFS +ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); +ssize_t il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); +ssize_t il4965_ucode_general_stats_read(struct file *file, + char __user *user_buf, size_t count, loff_t *ppos); +#else +static ssize_t +il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + return 0; +} +static ssize_t +il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + return 0; +} +static ssize_t +il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + return 0; +} +#endif + +#endif /* __il_4965_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.h b/drivers/net/wireless/iwlegacy/iwl-4965-calib.h deleted file mode 100644 index 0e30ea7ff12e..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.h +++ /dev/null @@ -1,75 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ -#ifndef __il_4965_calib_h__ -#define __il_4965_calib_h__ - -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-commands.h" - -void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp); -void il4965_sensitivity_calibration(struct il_priv *il, void *resp); -void il4965_init_sensitivity(struct il_priv *il); -void il4965_reset_run_time_calib(struct il_priv *il); -void il4965_calib_free_results(struct il_priv *il); - -#endif /* __il_4965_calib_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h b/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h deleted file mode 100644 index 284604c49440..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-debugfs.h +++ /dev/null @@ -1,59 +0,0 @@ -/****************************************************************************** - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - *****************************************************************************/ - -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-debug.h" - -#ifdef CONFIG_IWLEGACY_DEBUGFS -ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); -ssize_t il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); -ssize_t il4965_ucode_general_stats_read(struct file *file, - char __user *user_buf, size_t count, loff_t *ppos); -#else -static ssize_t -il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - return 0; -} -static ssize_t -il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - return 0; -} -static ssize_t -il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - return 0; -} -#endif diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h deleted file mode 100644 index 5c8b8baa3b15..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h +++ /dev/null @@ -1,811 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - *****************************************************************************/ -/* - * Please use this file (iwl-4965-hw.h) only for hardware-related definitions. - * Use iwl-commands.h for uCode API definitions. - * Use iwl-dev.h for driver implementation definitions. - */ - -#ifndef __il_4965_hw_h__ -#define __il_4965_hw_h__ - -#include "iwl-fh.h" - -/* EEPROM */ -#define IL4965_EEPROM_IMG_SIZE 1024 - -/* - * uCode queue management definitions ... - * The first queue used for block-ack aggregation is #7 (4965 only). - * All block-ack aggregation queues should map to Tx DMA/FIFO channel 7. - */ -#define IL49_FIRST_AMPDU_QUEUE 7 - -/* Sizes and addresses for instruction and data memory (SRAM) in - * 4965's embedded processor. Driver access is via HBUS_TARG_MEM_* regs. */ -#define IL49_RTC_INST_LOWER_BOUND (0x000000) -#define IL49_RTC_INST_UPPER_BOUND (0x018000) - -#define IL49_RTC_DATA_LOWER_BOUND (0x800000) -#define IL49_RTC_DATA_UPPER_BOUND (0x80A000) - -#define IL49_RTC_INST_SIZE (IL49_RTC_INST_UPPER_BOUND - \ - IL49_RTC_INST_LOWER_BOUND) -#define IL49_RTC_DATA_SIZE (IL49_RTC_DATA_UPPER_BOUND - \ - IL49_RTC_DATA_LOWER_BOUND) - -#define IL49_MAX_INST_SIZE IL49_RTC_INST_SIZE -#define IL49_MAX_DATA_SIZE IL49_RTC_DATA_SIZE - -/* Size of uCode instruction memory in bootstrap state machine */ -#define IL49_MAX_BSM_SIZE BSM_SRAM_SIZE - -static inline int il4965_hw_valid_rtc_data_addr(u32 addr) -{ - return (addr >= IL49_RTC_DATA_LOWER_BOUND && - addr < IL49_RTC_DATA_UPPER_BOUND); -} - -/********************* START TEMPERATURE *************************************/ - -/** - * 4965 temperature calculation. - * - * The driver must calculate the device temperature before calculating - * a txpower setting (amplifier gain is temperature dependent). The - * calculation uses 4 measurements, 3 of which (R1, R2, R3) are calibration - * values used for the life of the driver, and one of which (R4) is the - * real-time temperature indicator. - * - * uCode provides all 4 values to the driver via the "initialize alive" - * notification (see struct il4965_init_alive_resp). After the runtime uCode - * image loads, uCode updates the R4 value via stats notifications - * (see STATISTICS_NOTIFICATION), which occur after each received beacon - * when associated, or can be requested via REPLY_STATISTICS_CMD. - * - * NOTE: uCode provides the R4 value as a 23-bit signed value. Driver - * must sign-extend to 32 bits before applying formula below. - * - * Formula: - * - * degrees Kelvin = ((97 * 259 * (R4 - R2) / (R3 - R1)) / 100) + 8 - * - * NOTE: The basic formula is 259 * (R4-R2) / (R3-R1). The 97/100 is - * an additional correction, which should be centered around 0 degrees - * Celsius (273 degrees Kelvin). The 8 (3 percent of 273) compensates for - * centering the 97/100 correction around 0 degrees K. - * - * Add 273 to Kelvin value to find degrees Celsius, for comparing current - * temperature with factory-measured temperatures when calculating txpower - * settings. - */ -#define TEMPERATURE_CALIB_KELVIN_OFFSET 8 -#define TEMPERATURE_CALIB_A_VAL 259 - -/* Limit range of calculated temperature to be between these Kelvin values */ -#define IL_TX_POWER_TEMPERATURE_MIN (263) -#define IL_TX_POWER_TEMPERATURE_MAX (410) - -#define IL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(t) \ - ((t) < IL_TX_POWER_TEMPERATURE_MIN || \ - (t) > IL_TX_POWER_TEMPERATURE_MAX) - -/********************* END TEMPERATURE ***************************************/ - -/********************* START TXPOWER *****************************************/ - -/** - * 4965 txpower calculations rely on information from three sources: - * - * 1) EEPROM - * 2) "initialize" alive notification - * 3) stats notifications - * - * EEPROM data consists of: - * - * 1) Regulatory information (max txpower and channel usage flags) is provided - * separately for each channel that can possibly supported by 4965. - * 40 MHz wide (.11n HT40) channels are listed separately from 20 MHz - * (legacy) channels. - * - * See struct il4965_eeprom_channel for format, and struct il4965_eeprom - * for locations in EEPROM. - * - * 2) Factory txpower calibration information is provided separately for - * sub-bands of contiguous channels. 2.4GHz has just one sub-band, - * but 5 GHz has several sub-bands. - * - * In addition, per-band (2.4 and 5 Ghz) saturation txpowers are provided. - * - * See struct il4965_eeprom_calib_info (and the tree of structures - * contained within it) for format, and struct il4965_eeprom for - * locations in EEPROM. - * - * "Initialization alive" notification (see struct il4965_init_alive_resp) - * consists of: - * - * 1) Temperature calculation parameters. - * - * 2) Power supply voltage measurement. - * - * 3) Tx gain compensation to balance 2 transmitters for MIMO use. - * - * Statistics notifications deliver: - * - * 1) Current values for temperature param R4. - */ - -/** - * To calculate a txpower setting for a given desired target txpower, channel, - * modulation bit rate, and transmitter chain (4965 has 2 transmitters to - * support MIMO and transmit diversity), driver must do the following: - * - * 1) Compare desired txpower vs. (EEPROM) regulatory limit for this channel. - * Do not exceed regulatory limit; reduce target txpower if necessary. - * - * If setting up txpowers for MIMO rates (rate idxes 8-15, 24-31), - * 2 transmitters will be used simultaneously; driver must reduce the - * regulatory limit by 3 dB (half-power) for each transmitter, so the - * combined total output of the 2 transmitters is within regulatory limits. - * - * - * 2) Compare target txpower vs. (EEPROM) saturation txpower *reduced by - * backoff for this bit rate*. Do not exceed (saturation - backoff[rate]); - * reduce target txpower if necessary. - * - * Backoff values below are in 1/2 dB units (equivalent to steps in - * txpower gain tables): - * - * OFDM 6 - 36 MBit: 10 steps (5 dB) - * OFDM 48 MBit: 15 steps (7.5 dB) - * OFDM 54 MBit: 17 steps (8.5 dB) - * OFDM 60 MBit: 20 steps (10 dB) - * CCK all rates: 10 steps (5 dB) - * - * Backoff values apply to saturation txpower on a per-transmitter basis; - * when using MIMO (2 transmitters), each transmitter uses the same - * saturation level provided in EEPROM, and the same backoff values; - * no reduction (such as with regulatory txpower limits) is required. - * - * Saturation and Backoff values apply equally to 20 Mhz (legacy) channel - * widths and 40 Mhz (.11n HT40) channel widths; there is no separate - * factory measurement for ht40 channels. - * - * The result of this step is the final target txpower. The rest of - * the steps figure out the proper settings for the device to achieve - * that target txpower. - * - * - * 3) Determine (EEPROM) calibration sub band for the target channel, by - * comparing against first and last channels in each sub band - * (see struct il4965_eeprom_calib_subband_info). - * - * - * 4) Linearly interpolate (EEPROM) factory calibration measurement sets, - * referencing the 2 factory-measured (sample) channels within the sub band. - * - * Interpolation is based on difference between target channel's frequency - * and the sample channels' frequencies. Since channel numbers are based - * on frequency (5 MHz between each channel number), this is equivalent - * to interpolating based on channel number differences. - * - * Note that the sample channels may or may not be the channels at the - * edges of the sub band. The target channel may be "outside" of the - * span of the sampled channels. - * - * Driver may choose the pair (for 2 Tx chains) of measurements (see - * struct il4965_eeprom_calib_ch_info) for which the actual measured - * txpower comes closest to the desired txpower. Usually, though, - * the middle set of measurements is closest to the regulatory limits, - * and is therefore a good choice for all txpower calculations (this - * assumes that high accuracy is needed for maximizing legal txpower, - * while lower txpower configurations do not need as much accuracy). - * - * Driver should interpolate both members of the chosen measurement pair, - * i.e. for both Tx chains (radio transmitters), unless the driver knows - * that only one of the chains will be used (e.g. only one tx antenna - * connected, but this should be unusual). The rate scaling algorithm - * switches antennas to find best performance, so both Tx chains will - * be used (although only one at a time) even for non-MIMO transmissions. - * - * Driver should interpolate factory values for temperature, gain table - * idx, and actual power. The power amplifier detector values are - * not used by the driver. - * - * Sanity check: If the target channel happens to be one of the sample - * channels, the results should agree with the sample channel's - * measurements! - * - * - * 5) Find difference between desired txpower and (interpolated) - * factory-measured txpower. Using (interpolated) factory gain table idx - * (shown elsewhere) as a starting point, adjust this idx lower to - * increase txpower, or higher to decrease txpower, until the target - * txpower is reached. Each step in the gain table is 1/2 dB. - * - * For example, if factory measured txpower is 16 dBm, and target txpower - * is 13 dBm, add 6 steps to the factory gain idx to reduce txpower - * by 3 dB. - * - * - * 6) Find difference between current device temperature and (interpolated) - * factory-measured temperature for sub-band. Factory values are in - * degrees Celsius. To calculate current temperature, see comments for - * "4965 temperature calculation". - * - * If current temperature is higher than factory temperature, driver must - * increase gain (lower gain table idx), and vice verse. - * - * Temperature affects gain differently for different channels: - * - * 2.4 GHz all channels: 3.5 degrees per half-dB step - * 5 GHz channels 34-43: 4.5 degrees per half-dB step - * 5 GHz channels >= 44: 4.0 degrees per half-dB step - * - * NOTE: Temperature can increase rapidly when transmitting, especially - * with heavy traffic at high txpowers. Driver should update - * temperature calculations often under these conditions to - * maintain strong txpower in the face of rising temperature. - * - * - * 7) Find difference between current power supply voltage indicator - * (from "initialize alive") and factory-measured power supply voltage - * indicator (EEPROM). - * - * If the current voltage is higher (indicator is lower) than factory - * voltage, gain should be reduced (gain table idx increased) by: - * - * (eeprom - current) / 7 - * - * If the current voltage is lower (indicator is higher) than factory - * voltage, gain should be increased (gain table idx decreased) by: - * - * 2 * (current - eeprom) / 7 - * - * If number of idx steps in either direction turns out to be > 2, - * something is wrong ... just use 0. - * - * NOTE: Voltage compensation is independent of band/channel. - * - * NOTE: "Initialize" uCode measures current voltage, which is assumed - * to be constant after this initial measurement. Voltage - * compensation for txpower (number of steps in gain table) - * may be calculated once and used until the next uCode bootload. - * - * - * 8) If setting up txpowers for MIMO rates (rate idxes 8-15, 24-31), - * adjust txpower for each transmitter chain, so txpower is balanced - * between the two chains. There are 5 pairs of tx_atten[group][chain] - * values in "initialize alive", one pair for each of 5 channel ranges: - * - * Group 0: 5 GHz channel 34-43 - * Group 1: 5 GHz channel 44-70 - * Group 2: 5 GHz channel 71-124 - * Group 3: 5 GHz channel 125-200 - * Group 4: 2.4 GHz all channels - * - * Add the tx_atten[group][chain] value to the idx for the target chain. - * The values are signed, but are in pairs of 0 and a non-negative number, - * so as to reduce gain (if necessary) of the "hotter" channel. This - * avoids any need to double-check for regulatory compliance after - * this step. - * - * - * 9) If setting up for a CCK rate, lower the gain by adding a CCK compensation - * value to the idx: - * - * Hardware rev B: 9 steps (4.5 dB) - * Hardware rev C: 5 steps (2.5 dB) - * - * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG, - * bits [3:2], 1 = B, 2 = C. - * - * NOTE: This compensation is in addition to any saturation backoff that - * might have been applied in an earlier step. - * - * - * 10) Select the gain table, based on band (2.4 vs 5 GHz). - * - * Limit the adjusted idx to stay within the table! - * - * - * 11) Read gain table entries for DSP and radio gain, place into appropriate - * location(s) in command (struct il4965_txpowertable_cmd). - */ - -/** - * When MIMO is used (2 transmitters operating simultaneously), driver should - * limit each transmitter to deliver a max of 3 dB below the regulatory limit - * for the device. That is, use half power for each transmitter, so total - * txpower is within regulatory limits. - * - * The value "6" represents number of steps in gain table to reduce power 3 dB. - * Each step is 1/2 dB. - */ -#define IL_TX_POWER_MIMO_REGULATORY_COMPENSATION (6) - -/** - * CCK gain compensation. - * - * When calculating txpowers for CCK, after making sure that the target power - * is within regulatory and saturation limits, driver must additionally - * back off gain by adding these values to the gain table idx. - * - * Hardware rev for 4965 can be determined by reading CSR_HW_REV_WA_REG, - * bits [3:2], 1 = B, 2 = C. - */ -#define IL_TX_POWER_CCK_COMPENSATION_B_STEP (9) -#define IL_TX_POWER_CCK_COMPENSATION_C_STEP (5) - -/* - * 4965 power supply voltage compensation for txpower - */ -#define TX_POWER_IL_VOLTAGE_CODES_PER_03V (7) - -/** - * Gain tables. - * - * The following tables contain pair of values for setting txpower, i.e. - * gain settings for the output of the device's digital signal processor (DSP), - * and for the analog gain structure of the transmitter. - * - * Each entry in the gain tables represents a step of 1/2 dB. Note that these - * are *relative* steps, not indications of absolute output power. Output - * power varies with temperature, voltage, and channel frequency, and also - * requires consideration of average power (to satisfy regulatory constraints), - * and peak power (to avoid distortion of the output signal). - * - * Each entry contains two values: - * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained - * linear value that multiplies the output of the digital signal processor, - * before being sent to the analog radio. - * 2) Radio gain. This sets the analog gain of the radio Tx path. - * It is a coarser setting, and behaves in a logarithmic (dB) fashion. - * - * EEPROM contains factory calibration data for txpower. This maps actual - * measured txpower levels to gain settings in the "well known" tables - * below ("well-known" means here that both factory calibration *and* the - * driver work with the same table). - * - * There are separate tables for 2.4 GHz and 5 GHz bands. The 5 GHz table - * has an extension (into negative idxes), in case the driver needs to - * boost power setting for high device temperatures (higher than would be - * present during factory calibration). A 5 Ghz EEPROM idx of "40" - * corresponds to the 49th entry in the table used by the driver. - */ -#define MIN_TX_GAIN_IDX (0) /* highest gain, lowest idx, 2.4 */ -#define MIN_TX_GAIN_IDX_52GHZ_EXT (-9) /* highest gain, lowest idx, 5 */ - -/** - * 2.4 GHz gain table - * - * Index Dsp gain Radio gain - * 0 110 0x3f (highest gain) - * 1 104 0x3f - * 2 98 0x3f - * 3 110 0x3e - * 4 104 0x3e - * 5 98 0x3e - * 6 110 0x3d - * 7 104 0x3d - * 8 98 0x3d - * 9 110 0x3c - * 10 104 0x3c - * 11 98 0x3c - * 12 110 0x3b - * 13 104 0x3b - * 14 98 0x3b - * 15 110 0x3a - * 16 104 0x3a - * 17 98 0x3a - * 18 110 0x39 - * 19 104 0x39 - * 20 98 0x39 - * 21 110 0x38 - * 22 104 0x38 - * 23 98 0x38 - * 24 110 0x37 - * 25 104 0x37 - * 26 98 0x37 - * 27 110 0x36 - * 28 104 0x36 - * 29 98 0x36 - * 30 110 0x35 - * 31 104 0x35 - * 32 98 0x35 - * 33 110 0x34 - * 34 104 0x34 - * 35 98 0x34 - * 36 110 0x33 - * 37 104 0x33 - * 38 98 0x33 - * 39 110 0x32 - * 40 104 0x32 - * 41 98 0x32 - * 42 110 0x31 - * 43 104 0x31 - * 44 98 0x31 - * 45 110 0x30 - * 46 104 0x30 - * 47 98 0x30 - * 48 110 0x6 - * 49 104 0x6 - * 50 98 0x6 - * 51 110 0x5 - * 52 104 0x5 - * 53 98 0x5 - * 54 110 0x4 - * 55 104 0x4 - * 56 98 0x4 - * 57 110 0x3 - * 58 104 0x3 - * 59 98 0x3 - * 60 110 0x2 - * 61 104 0x2 - * 62 98 0x2 - * 63 110 0x1 - * 64 104 0x1 - * 65 98 0x1 - * 66 110 0x0 - * 67 104 0x0 - * 68 98 0x0 - * 69 97 0 - * 70 96 0 - * 71 95 0 - * 72 94 0 - * 73 93 0 - * 74 92 0 - * 75 91 0 - * 76 90 0 - * 77 89 0 - * 78 88 0 - * 79 87 0 - * 80 86 0 - * 81 85 0 - * 82 84 0 - * 83 83 0 - * 84 82 0 - * 85 81 0 - * 86 80 0 - * 87 79 0 - * 88 78 0 - * 89 77 0 - * 90 76 0 - * 91 75 0 - * 92 74 0 - * 93 73 0 - * 94 72 0 - * 95 71 0 - * 96 70 0 - * 97 69 0 - * 98 68 0 - */ - -/** - * 5 GHz gain table - * - * Index Dsp gain Radio gain - * -9 123 0x3F (highest gain) - * -8 117 0x3F - * -7 110 0x3F - * -6 104 0x3F - * -5 98 0x3F - * -4 110 0x3E - * -3 104 0x3E - * -2 98 0x3E - * -1 110 0x3D - * 0 104 0x3D - * 1 98 0x3D - * 2 110 0x3C - * 3 104 0x3C - * 4 98 0x3C - * 5 110 0x3B - * 6 104 0x3B - * 7 98 0x3B - * 8 110 0x3A - * 9 104 0x3A - * 10 98 0x3A - * 11 110 0x39 - * 12 104 0x39 - * 13 98 0x39 - * 14 110 0x38 - * 15 104 0x38 - * 16 98 0x38 - * 17 110 0x37 - * 18 104 0x37 - * 19 98 0x37 - * 20 110 0x36 - * 21 104 0x36 - * 22 98 0x36 - * 23 110 0x35 - * 24 104 0x35 - * 25 98 0x35 - * 26 110 0x34 - * 27 104 0x34 - * 28 98 0x34 - * 29 110 0x33 - * 30 104 0x33 - * 31 98 0x33 - * 32 110 0x32 - * 33 104 0x32 - * 34 98 0x32 - * 35 110 0x31 - * 36 104 0x31 - * 37 98 0x31 - * 38 110 0x30 - * 39 104 0x30 - * 40 98 0x30 - * 41 110 0x25 - * 42 104 0x25 - * 43 98 0x25 - * 44 110 0x24 - * 45 104 0x24 - * 46 98 0x24 - * 47 110 0x23 - * 48 104 0x23 - * 49 98 0x23 - * 50 110 0x22 - * 51 104 0x18 - * 52 98 0x18 - * 53 110 0x17 - * 54 104 0x17 - * 55 98 0x17 - * 56 110 0x16 - * 57 104 0x16 - * 58 98 0x16 - * 59 110 0x15 - * 60 104 0x15 - * 61 98 0x15 - * 62 110 0x14 - * 63 104 0x14 - * 64 98 0x14 - * 65 110 0x13 - * 66 104 0x13 - * 67 98 0x13 - * 68 110 0x12 - * 69 104 0x08 - * 70 98 0x08 - * 71 110 0x07 - * 72 104 0x07 - * 73 98 0x07 - * 74 110 0x06 - * 75 104 0x06 - * 76 98 0x06 - * 77 110 0x05 - * 78 104 0x05 - * 79 98 0x05 - * 80 110 0x04 - * 81 104 0x04 - * 82 98 0x04 - * 83 110 0x03 - * 84 104 0x03 - * 85 98 0x03 - * 86 110 0x02 - * 87 104 0x02 - * 88 98 0x02 - * 89 110 0x01 - * 90 104 0x01 - * 91 98 0x01 - * 92 110 0x00 - * 93 104 0x00 - * 94 98 0x00 - * 95 93 0x00 - * 96 88 0x00 - * 97 83 0x00 - * 98 78 0x00 - */ - - -/** - * Sanity checks and default values for EEPROM regulatory levels. - * If EEPROM values fall outside MIN/MAX range, use default values. - * - * Regulatory limits refer to the maximum average txpower allowed by - * regulatory agencies in the geographies in which the device is meant - * to be operated. These limits are SKU-specific (i.e. geography-specific), - * and channel-specific; each channel has an individual regulatory limit - * listed in the EEPROM. - * - * Units are in half-dBm (i.e. "34" means 17 dBm). - */ -#define IL_TX_POWER_DEFAULT_REGULATORY_24 (34) -#define IL_TX_POWER_DEFAULT_REGULATORY_52 (34) -#define IL_TX_POWER_REGULATORY_MIN (0) -#define IL_TX_POWER_REGULATORY_MAX (34) - -/** - * Sanity checks and default values for EEPROM saturation levels. - * If EEPROM values fall outside MIN/MAX range, use default values. - * - * Saturation is the highest level that the output power amplifier can produce - * without significant clipping distortion. This is a "peak" power level. - * Different types of modulation (i.e. various "rates", and OFDM vs. CCK) - * require differing amounts of backoff, relative to their average power output, - * in order to avoid clipping distortion. - * - * Driver must make sure that it is violating neither the saturation limit, - * nor the regulatory limit, when calculating Tx power settings for various - * rates. - * - * Units are in half-dBm (i.e. "38" means 19 dBm). - */ -#define IL_TX_POWER_DEFAULT_SATURATION_24 (38) -#define IL_TX_POWER_DEFAULT_SATURATION_52 (38) -#define IL_TX_POWER_SATURATION_MIN (20) -#define IL_TX_POWER_SATURATION_MAX (50) - -/** - * Channel groups used for Tx Attenuation calibration (MIMO tx channel balance) - * and thermal Txpower calibration. - * - * When calculating txpower, driver must compensate for current device - * temperature; higher temperature requires higher gain. Driver must calculate - * current temperature (see "4965 temperature calculation"), then compare vs. - * factory calibration temperature in EEPROM; if current temperature is higher - * than factory temperature, driver must *increase* gain by proportions shown - * in table below. If current temperature is lower than factory, driver must - * *decrease* gain. - * - * Different frequency ranges require different compensation, as shown below. - */ -/* Group 0, 5.2 GHz ch 34-43: 4.5 degrees per 1/2 dB. */ -#define CALIB_IL_TX_ATTEN_GR1_FCH 34 -#define CALIB_IL_TX_ATTEN_GR1_LCH 43 - -/* Group 1, 5.3 GHz ch 44-70: 4.0 degrees per 1/2 dB. */ -#define CALIB_IL_TX_ATTEN_GR2_FCH 44 -#define CALIB_IL_TX_ATTEN_GR2_LCH 70 - -/* Group 2, 5.5 GHz ch 71-124: 4.0 degrees per 1/2 dB. */ -#define CALIB_IL_TX_ATTEN_GR3_FCH 71 -#define CALIB_IL_TX_ATTEN_GR3_LCH 124 - -/* Group 3, 5.7 GHz ch 125-200: 4.0 degrees per 1/2 dB. */ -#define CALIB_IL_TX_ATTEN_GR4_FCH 125 -#define CALIB_IL_TX_ATTEN_GR4_LCH 200 - -/* Group 4, 2.4 GHz all channels: 3.5 degrees per 1/2 dB. */ -#define CALIB_IL_TX_ATTEN_GR5_FCH 1 -#define CALIB_IL_TX_ATTEN_GR5_LCH 20 - -enum { - CALIB_CH_GROUP_1 = 0, - CALIB_CH_GROUP_2 = 1, - CALIB_CH_GROUP_3 = 2, - CALIB_CH_GROUP_4 = 3, - CALIB_CH_GROUP_5 = 4, - CALIB_CH_GROUP_MAX -}; - -/********************* END TXPOWER *****************************************/ - - -/** - * Tx/Rx Queues - * - * Most communication between driver and 4965 is via queues of data buffers. - * For example, all commands that the driver issues to device's embedded - * controller (uCode) are via the command queue (one of the Tx queues). All - * uCode command responses/replies/notifications, including Rx frames, are - * conveyed from uCode to driver via the Rx queue. - * - * Most support for these queues, including handshake support, resides in - * structures in host DRAM, shared between the driver and the device. When - * allocating this memory, the driver must make sure that data written by - * the host CPU updates DRAM immediately (and does not get "stuck" in CPU's - * cache memory), so DRAM and cache are consistent, and the device can - * immediately see changes made by the driver. - * - * 4965 supports up to 16 DRAM-based Tx queues, and services these queues via - * up to 7 DMA channels (FIFOs). Each Tx queue is supported by a circular array - * in DRAM containing 256 Transmit Frame Descriptors (TFDs). - */ -#define IL49_NUM_FIFOS 7 -#define IL49_CMD_FIFO_NUM 4 -#define IL49_NUM_QUEUES 16 -#define IL49_NUM_AMPDU_QUEUES 8 - - -/** - * struct il4965_schedq_bc_tbl - * - * Byte Count table - * - * Each Tx queue uses a byte-count table containing 320 entries: - * one 16-bit entry for each of 256 TFDs, plus an additional 64 entries that - * duplicate the first 64 entries (to avoid wrap-around within a Tx win; - * max Tx win is 64 TFDs). - * - * When driver sets up a new TFD, it must also enter the total byte count - * of the frame to be transmitted into the corresponding entry in the byte - * count table for the chosen Tx queue. If the TFD idx is 0-63, the driver - * must duplicate the byte count entry in corresponding idx 256-319. - * - * padding puts each byte count table on a 1024-byte boundary; - * 4965 assumes tables are separated by 1024 bytes. - */ -struct il4965_scd_bc_tbl { - __le16 tfd_offset[TFD_QUEUE_BC_SIZE]; - u8 pad[1024 - (TFD_QUEUE_BC_SIZE) * sizeof(__le16)]; -} __packed; - - -#define IL4965_RTC_INST_LOWER_BOUND (0x000000) - -/* RSSI to dBm */ -#define IL4965_RSSI_OFFSET 44 - -/* PCI registers */ -#define PCI_CFG_RETRY_TIMEOUT 0x041 - -/* PCI register values */ -#define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01 -#define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02 - -#define IL4965_DEFAULT_TX_RETRY 15 - -/* EEPROM */ -#define IL4965_FIRST_AMPDU_QUEUE 10 - - -#endif /* !__il_4965_hw_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.h b/drivers/net/wireless/iwlegacy/iwl-4965.h deleted file mode 100644 index c0bb45b012d2..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-4965.h +++ /dev/null @@ -1,284 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef __il_4965_h__ -#define __il_4965_h__ - -#include "iwl-dev.h" - -/* configuration for the _4965 devices */ -extern struct il_cfg il4965_cfg; - -extern struct il_mod_params il4965_mod_params; - -extern struct ieee80211_ops il4965_hw_ops; - -/* tx queue */ -void il4965_free_tfds_in_queue(struct il_priv *il, - int sta_id, int tid, int freed); - -/* RXON */ -void il4965_set_rxon_chain(struct il_priv *il, - struct il_rxon_context *ctx); - -/* uCode */ -int il4965_verify_ucode(struct il_priv *il); - -/* lib */ -void il4965_check_abort_status(struct il_priv *il, - u8 frame_count, u32 status); - -void il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq); -int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq); -int il4965_hw_nic_init(struct il_priv *il); -int il4965_dump_fh(struct il_priv *il, char **buf, bool display); - -/* rx */ -void il4965_rx_queue_restock(struct il_priv *il); -void il4965_rx_replenish(struct il_priv *il); -void il4965_rx_replenish_now(struct il_priv *il); -void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq); -int il4965_rxq_stop(struct il_priv *il); -int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); -void il4965_rx_reply_rx(struct il_priv *il, - struct il_rx_buf *rxb); -void il4965_rx_reply_rx_phy(struct il_priv *il, - struct il_rx_buf *rxb); -void il4965_rx_handle(struct il_priv *il); - -/* tx */ -void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq); -int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, - struct il_tx_queue *txq, - dma_addr_t addr, u16 len, u8 reset, u8 pad); -int il4965_hw_tx_queue_init(struct il_priv *il, - struct il_tx_queue *txq); -void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, - struct ieee80211_tx_info *info); -int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb); -int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, - struct ieee80211_sta *sta, u16 tid, u16 *ssn); -int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, - struct ieee80211_sta *sta, u16 tid); -int il4965_txq_check_empty(struct il_priv *il, - int sta_id, u8 tid, int txq_id); -void il4965_rx_reply_compressed_ba(struct il_priv *il, - struct il_rx_buf *rxb); -int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx); -void il4965_hw_txq_ctx_free(struct il_priv *il); -int il4965_txq_ctx_alloc(struct il_priv *il); -void il4965_txq_ctx_reset(struct il_priv *il); -void il4965_txq_ctx_stop(struct il_priv *il); -void il4965_txq_set_sched(struct il_priv *il, u32 mask); - -/* - * Acquire il->lock before calling this function ! - */ -void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx); -/** - * il4965_tx_queue_set_status - (optionally) start Tx/Cmd queue - * @tx_fifo_id: Tx DMA/FIFO channel (range 0-7) that the queue will feed - * @scd_retry: (1) Indicates queue will be used in aggregation mode - * - * NOTE: Acquire il->lock before calling this function ! - */ -void il4965_tx_queue_set_status(struct il_priv *il, - struct il_tx_queue *txq, - int tx_fifo_id, int scd_retry); - -static inline u32 il4965_tx_status_to_mac80211(u32 status) -{ - status &= TX_STATUS_MSK; - - switch (status) { - case TX_STATUS_SUCCESS: - case TX_STATUS_DIRECT_DONE: - return IEEE80211_TX_STAT_ACK; - case TX_STATUS_FAIL_DEST_PS: - return IEEE80211_TX_STAT_TX_FILTERED; - default: - return 0; - } -} - -static inline bool il4965_is_tx_success(u32 status) -{ - status &= TX_STATUS_MSK; - return (status == TX_STATUS_SUCCESS || - status == TX_STATUS_DIRECT_DONE); -} - -u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant_idx, u8 valid); - -/* rx */ -void il4965_rx_missed_beacon_notif(struct il_priv *il, - struct il_rx_buf *rxb); -bool il4965_good_plcp_health(struct il_priv *il, - struct il_rx_pkt *pkt); -void il4965_rx_stats(struct il_priv *il, - struct il_rx_buf *rxb); -void il4965_reply_stats(struct il_priv *il, - struct il_rx_buf *rxb); - -/* scan */ -int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif); - -/* station mgmt */ -int il4965_manage_ibss_station(struct il_priv *il, - struct ieee80211_vif *vif, bool add); - -/* hcmd */ -int il4965_send_beacon_cmd(struct il_priv *il); - -#ifdef CONFIG_IWLEGACY_DEBUG -const char *il4965_get_tx_fail_reason(u32 status); -#else -static inline const char * -il4965_get_tx_fail_reason(u32 status) { return ""; } -#endif - -/* station management */ -int il4965_alloc_bcast_station(struct il_priv *il, - struct il_rxon_context *ctx); -int il4965_add_bssid_station(struct il_priv *il, - struct il_rxon_context *ctx, - const u8 *addr, u8 *sta_id_r); -int il4965_remove_default_wep_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *key); -int il4965_set_default_wep_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *key); -int il4965_restore_default_wep_keys(struct il_priv *il, - struct il_rxon_context *ctx); -int il4965_set_dynamic_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *key, u8 sta_id); -int il4965_remove_dynamic_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *key, u8 sta_id); -void il4965_update_tkip_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, - struct ieee80211_sta *sta, u32 iv32, u16 *phase1key); -int il4965_sta_tx_modify_enable_tid(struct il_priv *il, - int sta_id, int tid); -int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta, - int tid, u16 ssn); -int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta, - int tid); -void il4965_sta_modify_sleep_tx_count(struct il_priv *il, - int sta_id, int cnt); -int il4965_update_bcast_stations(struct il_priv *il); - -/* rate */ -static inline u32 il4965_ant_idx_to_flags(u8 ant_idx) -{ - return BIT(ant_idx) << RATE_MCS_ANT_POS; -} - -static inline u8 il4965_hw_get_rate(__le32 rate_n_flags) -{ - return le32_to_cpu(rate_n_flags) & 0xFF; -} - -static inline __le32 il4965_hw_set_rate_n_flags(u8 rate, u32 flags) -{ - return cpu_to_le32(flags|(u32)rate); -} - -/* eeprom */ -void il4965_eeprom_get_mac(const struct il_priv *il, u8 *mac); -int il4965_eeprom_acquire_semaphore(struct il_priv *il); -void il4965_eeprom_release_semaphore(struct il_priv *il); -int il4965_eeprom_check_version(struct il_priv *il); - -/* mac80211 handlers (for 4965) */ -void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb); -int il4965_mac_start(struct ieee80211_hw *hw); -void il4965_mac_stop(struct ieee80211_hw *hw); -void il4965_configure_filter(struct ieee80211_hw *hw, - unsigned int changed_flags, - unsigned int *total_flags, - u64 multicast); -int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, - struct ieee80211_vif *vif, struct ieee80211_sta *sta, - struct ieee80211_key_conf *key); -void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_key_conf *keyconf, - struct ieee80211_sta *sta, - u32 iv32, u16 *phase1key); -int il4965_mac_ampdu_action(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - enum ieee80211_ampdu_mlme_action action, - struct ieee80211_sta *sta, u16 tid, u16 *ssn, - u8 buf_size); -int il4965_mac_sta_add(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta); -void il4965_mac_channel_switch(struct ieee80211_hw *hw, - struct ieee80211_channel_switch *ch_switch); - -void il4965_led_enable(struct il_priv *il); - -#endif /* __il_4965_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h index e6688b166ada..55822da4b162 100644 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ b/drivers/net/wireless/iwlegacy/iwl-commands.h @@ -347,7 +347,7 @@ struct il3945_power_per_rate { * For MIMO rates, one value may be different from the other, * in order to balance the Tx output between the two transmitters. * - * See more details in doc for TXPOWER in iwl-4965-hw.h. + * See more details in doc for TXPOWER in 4965.h. */ union il4965_tx_power_dual_stream { struct { @@ -1756,7 +1756,7 @@ struct il_compressed_ba_resp { /* * REPLY_TX_PWR_TBL_CMD = 0x97 (command, has simple generic response) * - * See details under "TXPOWER" in iwl-4965-hw.h. + * See details under "TXPOWER" in 4965.h. */ struct il3945_txpowertable_cmd { diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 7c86d198e89d..97b25730c329 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -26,7 +26,7 @@ /* * Please use this file (iwl-dev.h) for driver implementation definitions. * Please use iwl-commands.h for uCode API definitions. - * Please use iwl-4965-hw.h for hardware-related definitions. + * Please use 4965.h for hardware-related definitions. */ #ifndef __il_dev_h__ @@ -44,7 +44,7 @@ #include "iwl-prph.h" #include "iwl-fh.h" #include "iwl-debug.h" -#include "iwl-4965-hw.h" +#include "4965.h" #include "iwl-3945-hw.h" #include "iwl-led.h" #include "iwl-power.h" diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.h b/drivers/net/wireless/iwlegacy/iwl-eeprom.h index eb868c0e6559..61435a522c84 100644 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.h +++ b/drivers/net/wireless/iwlegacy/iwl-eeprom.h @@ -154,7 +154,7 @@ extern const u8 il_eeprom_band_1[14]; * 1) Temperature (degrees Celsius) of device when measurement was made. * * 2) Gain table idx used to achieve the target measurement power. - * This refers to the "well-known" gain tables (see iwl-4965-hw.h). + * This refers to the "well-known" gain tables (see 4965.h). * * 3) Actual measured output power, in half-dBm ("34" = 17 dBm). * diff --git a/drivers/net/wireless/iwlegacy/iwl-prph.h b/drivers/net/wireless/iwlegacy/iwl-prph.h index e34d9073a99e..b0bf6848bd1d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-prph.h +++ b/drivers/net/wireless/iwlegacy/iwl-prph.h @@ -255,7 +255,7 @@ * but one DMA channel may take input from several queues. * * Tx DMA FIFOs have dedicated purposes. For 4965, they are used as follows - * (cf. default_queue_to_tx_fifo in iwl-4965.c): + * (cf. default_queue_to_tx_fifo in 4965.c): * * 0 -- EDCA BK (background) frames, lowest priority * 1 -- EDCA BE (best effort) frames, normal priority diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index 10a0914709b3..e46e58829216 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -232,7 +232,7 @@ EXPORT_SYMBOL(il_cmd_queue_free); * reclaiming packets (on 'tx done IRQ), if free space become > high mark, * Tx queue resumed. * - * See more detailed info in iwl-4965-hw.h. + * See more detailed info in 4965.h. ***************************************************/ int il_queue_space(const struct il_queue *q) -- cgit v1.2.3 From 6bbb1370c3083190cae8487c2c61c0d24f869e68 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 30 Aug 2011 14:12:12 +0200 Subject: iwlegacy: move iwl-3945-{,hw,fh,debugfs}.h to 3945.h Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/3945-debug.c | 5 +- drivers/net/wireless/iwlegacy/3945-mac.c | 3 +- drivers/net/wireless/iwlegacy/3945-rs.c | 2 +- drivers/net/wireless/iwlegacy/3945.c | 4 +- drivers/net/wireless/iwlegacy/3945.h | 667 +++++++++++++++++++++++ drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h | 60 -- drivers/net/wireless/iwlegacy/iwl-3945-fh.h | 187 ------- drivers/net/wireless/iwlegacy/iwl-3945-hw.h | 291 ---------- drivers/net/wireless/iwlegacy/iwl-3945.h | 308 ----------- drivers/net/wireless/iwlegacy/iwl-dev.h | 3 +- 10 files changed, 675 insertions(+), 855 deletions(-) create mode 100644 drivers/net/wireless/iwlegacy/3945.h delete mode 100644 drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h delete mode 100644 drivers/net/wireless/iwlegacy/iwl-3945-fh.h delete mode 100644 drivers/net/wireless/iwlegacy/iwl-3945-hw.h delete mode 100644 drivers/net/wireless/iwlegacy/iwl-3945.h (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/3945-debug.c b/drivers/net/wireless/iwlegacy/3945-debug.c index 88b3d8fc38f8..9c837c3c4f04 100644 --- a/drivers/net/wireless/iwlegacy/3945-debug.c +++ b/drivers/net/wireless/iwlegacy/3945-debug.c @@ -26,8 +26,9 @@ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 *****************************************************************************/ -#include "iwl-3945-debugfs.h" - +#include "iwl-dev.h" +#include "iwl-core.h" +#include "3945.h" static int il3945_stats_flag(struct il_priv *il, char *buf, int bufsz) { diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 151c8faa18dd..17edbdf9dc84 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -52,10 +52,9 @@ #define DRV_NAME "iwl3945" #include "iwl-fh.h" -#include "iwl-3945-fh.h" #include "iwl-commands.h" #include "iwl-sta.h" -#include "iwl-3945.h" +#include "3945.h" #include "iwl-core.h" #include "iwl-helpers.h" #include "iwl-dev.h" diff --git a/drivers/net/wireless/iwlegacy/3945-rs.c b/drivers/net/wireless/iwlegacy/3945-rs.c index f84ed5ecc676..0d2beba1a25a 100644 --- a/drivers/net/wireless/iwlegacy/3945-rs.c +++ b/drivers/net/wireless/iwlegacy/3945-rs.c @@ -37,7 +37,7 @@ #include #include "iwl-commands.h" -#include "iwl-3945.h" +#include "3945.h" #include "iwl-sta.h" #define RS_NAME "iwl-3945-rs" diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index b41e60b40264..17615c33d1aa 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -40,15 +40,13 @@ #include #include "iwl-fh.h" -#include "iwl-3945-fh.h" #include "iwl-commands.h" #include "iwl-sta.h" -#include "iwl-3945.h" #include "iwl-eeprom.h" #include "iwl-core.h" #include "iwl-helpers.h" #include "iwl-led.h" -#include "iwl-3945-debugfs.h" +#include "3945.h" /* Send led command */ static int il3945_send_led_cmd(struct il_priv *il, diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h new file mode 100644 index 000000000000..d65565f7c871 --- /dev/null +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -0,0 +1,667 @@ +/****************************************************************************** + * + * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + *****************************************************************************/ + +#ifndef __il_3945_h__ +#define __il_3945_h__ + +#include /* for struct pci_device_id */ +#include +#include + +/* Hardware specific file defines the PCI IDs table for that hardware module */ +extern const struct pci_device_id il3945_hw_card_ids[]; + +#include "iwl-csr.h" +#include "iwl-prph.h" +#include "iwl-fh.h" +#include "iwl-debug.h" +#include "iwl-power.h" +#include "iwl-dev.h" +#include "iwl-led.h" +#include "iwl-eeprom.h" + +/* Highest firmware API version supported */ +#define IL3945_UCODE_API_MAX 2 + +/* Lowest firmware API version supported */ +#define IL3945_UCODE_API_MIN 1 + +#define IL3945_FW_PRE "iwlwifi-3945-" +#define _IL3945_MODULE_FIRMWARE(api) IL3945_FW_PRE #api ".ucode" +#define IL3945_MODULE_FIRMWARE(api) _IL3945_MODULE_FIRMWARE(api) + +/* Default noise level to report when noise measurement is not available. + * This may be because we're: + * 1) Not associated (4965, no beacon stats being sent to driver) + * 2) Scanning (noise measurement does not apply to associated channel) + * 3) Receiving CCK (3945 delivers noise info only for OFDM frames) + * Use default noise value of -127 ... this is below the range of measurable + * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user. + * Also, -127 works better than 0 when averaging frames with/without + * noise info (e.g. averaging might be done in app); measured dBm values are + * always negative ... using a negative value as the default keeps all + * averages within an s8's (used in some apps) range of negative values. */ +#define IL_NOISE_MEAS_NOT_AVAILABLE (-127) + +/* Module parameters accessible from iwl-*.c */ +extern struct il_mod_params il3945_mod_params; + +struct il3945_rate_scale_data { + u64 data; + s32 success_counter; + s32 success_ratio; + s32 counter; + s32 average_tpt; + unsigned long stamp; +}; + +struct il3945_rs_sta { + spinlock_t lock; + struct il_priv *il; + s32 *expected_tpt; + unsigned long last_partial_flush; + unsigned long last_flush; + u32 flush_time; + u32 last_tx_packets; + u32 tx_packets; + u8 tgg; + u8 flush_pending; + u8 start_rate; + struct timer_list rate_scale_flush; + struct il3945_rate_scale_data win[RATE_COUNT_3945]; +#ifdef CONFIG_MAC80211_DEBUGFS + struct dentry *rs_sta_dbgfs_stats_table_file; +#endif + + /* used to be in sta_info */ + int last_txrate_idx; +}; + + +/* + * The common struct MUST be first because it is shared between + * 3945 and 4965! + */ +struct il3945_sta_priv { + struct il_station_priv_common common; + struct il3945_rs_sta rs_sta; +}; + +enum il3945_antenna { + IL_ANTENNA_DIVERSITY, + IL_ANTENNA_MAIN, + IL_ANTENNA_AUX +}; + +/* + * RTS threshold here is total size [2347] minus 4 FCS bytes + * Per spec: + * a value of 0 means RTS on all data/management packets + * a value > max MSDU size means no RTS + * else RTS for data/management frames where MPDU is larger + * than RTS value. + */ +#define DEFAULT_RTS_THRESHOLD 2347U +#define MIN_RTS_THRESHOLD 0U +#define MAX_RTS_THRESHOLD 2347U +#define MAX_MSDU_SIZE 2304U +#define MAX_MPDU_SIZE 2346U +#define DEFAULT_BEACON_INTERVAL 100U +#define DEFAULT_SHORT_RETRY_LIMIT 7U +#define DEFAULT_LONG_RETRY_LIMIT 4U + +#define IL_TX_FIFO_AC0 0 +#define IL_TX_FIFO_AC1 1 +#define IL_TX_FIFO_AC2 2 +#define IL_TX_FIFO_AC3 3 +#define IL_TX_FIFO_HCCA_1 5 +#define IL_TX_FIFO_HCCA_2 6 +#define IL_TX_FIFO_NONE 7 + +#define IEEE80211_DATA_LEN 2304 +#define IEEE80211_4ADDR_LEN 30 +#define IEEE80211_HLEN (IEEE80211_4ADDR_LEN) +#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) + +struct il3945_frame { + union { + struct ieee80211_hdr frame; + struct il3945_tx_beacon_cmd beacon; + u8 raw[IEEE80211_FRAME_LEN]; + u8 cmd[360]; + } u; + struct list_head list; +}; + +#define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) +#define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ) +#define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4) + +#define SUP_RATE_11A_MAX_NUM_CHANNELS 8 +#define SUP_RATE_11B_MAX_NUM_CHANNELS 4 +#define SUP_RATE_11G_MAX_NUM_CHANNELS 12 + +#define IL_SUPPORTED_RATES_IE_LEN 8 + +#define SCAN_INTERVAL 100 + +#define MAX_TID_COUNT 9 + +#define IL_INVALID_RATE 0xFF +#define IL_INVALID_VALUE -1 + +#define STA_PS_STATUS_WAKE 0 +#define STA_PS_STATUS_SLEEP 1 + +struct il3945_ibss_seq { + u8 mac[ETH_ALEN]; + u16 seq_num; + u16 frag_num; + unsigned long packet_time; + struct list_head list; +}; + +#define IL_RX_HDR(x) ((struct il3945_rx_frame_hdr *)(\ + x->u.rx_frame.stats.payload + \ + x->u.rx_frame.stats.phy_count)) +#define IL_RX_END(x) ((struct il3945_rx_frame_end *)(\ + IL_RX_HDR(x)->payload + \ + le16_to_cpu(IL_RX_HDR(x)->len))) +#define IL_RX_STATS(x) (&x->u.rx_frame.stats) +#define IL_RX_DATA(x) (IL_RX_HDR(x)->payload) + + +/****************************************************************************** + * + * Functions implemented in iwl3945-base.c which are forward declared here + * for use by iwl-*.c + * + *****************************************************************************/ +extern int il3945_calc_db_from_ratio(int sig_ratio); +extern void il3945_rx_replenish(void *data); +extern void il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq); +extern unsigned int il3945_fill_beacon_frame(struct il_priv *il, + struct ieee80211_hdr *hdr, int left); +extern int il3945_dump_nic_event_log(struct il_priv *il, bool full_log, + char **buf, bool display); +extern void il3945_dump_nic_error_log(struct il_priv *il); + +/****************************************************************************** + * + * Functions implemented in iwl-[34]*.c which are forward declared here + * for use by iwl3945-base.c + * + * NOTE: The implementation of these functions are hardware specific + * which is why they are in the hardware specific files (vs. iwl-base.c) + * + * Naming convention -- + * il3945_ <-- Its part of iwlwifi (should be changed to il3945_) + * il3945_hw_ <-- Hardware specific (implemented in iwl-XXXX.c by all HW) + * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX) + * il3945_bg_ <-- Called from work queue context + * il3945_mac_ <-- mac80211 callback + * + ****************************************************************************/ +extern void il3945_hw_rx_handler_setup(struct il_priv *il); +extern void il3945_hw_setup_deferred_work(struct il_priv *il); +extern void il3945_hw_cancel_deferred_work(struct il_priv *il); +extern int il3945_hw_rxq_stop(struct il_priv *il); +extern int il3945_hw_set_hw_params(struct il_priv *il); +extern int il3945_hw_nic_init(struct il_priv *il); +extern int il3945_hw_nic_stop_master(struct il_priv *il); +extern void il3945_hw_txq_ctx_free(struct il_priv *il); +extern void il3945_hw_txq_ctx_stop(struct il_priv *il); +extern int il3945_hw_nic_reset(struct il_priv *il); +extern int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, + struct il_tx_queue *txq, + dma_addr_t addr, u16 len, + u8 reset, u8 pad); +extern void il3945_hw_txq_free_tfd(struct il_priv *il, + struct il_tx_queue *txq); +extern int il3945_hw_get_temperature(struct il_priv *il); +extern int il3945_hw_tx_queue_init(struct il_priv *il, + struct il_tx_queue *txq); +extern unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, + struct il3945_frame *frame, u8 rate); +void il3945_hw_build_tx_cmd_rate(struct il_priv *il, + struct il_device_cmd *cmd, + struct ieee80211_tx_info *info, + struct ieee80211_hdr *hdr, + int sta_id, int tx_id); +extern int il3945_hw_reg_send_txpower(struct il_priv *il); +extern int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power); +extern void il3945_hw_rx_stats(struct il_priv *il, + struct il_rx_buf *rxb); +void il3945_reply_stats(struct il_priv *il, + struct il_rx_buf *rxb); +extern void il3945_disable_events(struct il_priv *il); +extern int il4965_get_temperature(const struct il_priv *il); +extern void il3945_post_associate(struct il_priv *il); +extern void il3945_config_ap(struct il_priv *il); + +extern int il3945_commit_rxon(struct il_priv *il, + struct il_rxon_context *ctx); + +/** + * il3945_hw_find_station - Find station id for a given BSSID + * @bssid: MAC address of station ID to find + * + * NOTE: This should not be hardware specific but the code has + * not yet been merged into a single common layer for managing the + * station tables. + */ +extern u8 il3945_hw_find_station(struct il_priv *il, const u8 *bssid); + +extern struct ieee80211_ops il3945_hw_ops; + +extern __le32 il3945_get_antenna_flags(const struct il_priv *il); +extern int il3945_init_hw_rate_table(struct il_priv *il); +extern void il3945_reg_txpower_periodic(struct il_priv *il); +extern int il3945_txpower_set_from_eeprom(struct il_priv *il); + +extern const struct il_channel_info *il3945_get_channel_info( + const struct il_priv *il, enum ieee80211_band band, u16 channel); + +extern int il3945_rs_next_rate(struct il_priv *il, int rate); + +/* scanning */ +int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif); +void il3945_post_scan(struct il_priv *il); + +/* rates */ +extern const struct il3945_rate_info il3945_rates[RATE_COUNT_3945]; + + + +/* RSSI to dBm */ +#define IL39_RSSI_OFFSET 95 + +/* + * EEPROM related constants, enums, and structures. + */ +#define EEPROM_SKU_CAP_OP_MODE_MRC (1 << 7) + +/* + * Mapping of a Tx power level, at factory calibration temperature, + * to a radio/DSP gain table idx. + * One for each of 5 "sample" power levels in each band. + * v_det is measured at the factory, using the 3945's built-in power amplifier + * (PA) output voltage detector. This same detector is used during Tx of + * long packets in normal operation to provide feedback as to proper output + * level. + * Data copied from EEPROM. + * DO NOT ALTER THIS STRUCTURE!!! + */ +struct il3945_eeprom_txpower_sample { + u8 gain_idx; /* idx into power (gain) setup table ... */ + s8 power; /* ... for this pwr level for this chnl group */ + u16 v_det; /* PA output voltage */ +} __packed; + +/* + * Mappings of Tx power levels -> nominal radio/DSP gain table idxes. + * One for each channel group (a.k.a. "band") (1 for BG, 4 for A). + * Tx power setup code interpolates between the 5 "sample" power levels + * to determine the nominal setup for a requested power level. + * Data copied from EEPROM. + * DO NOT ALTER THIS STRUCTURE!!! + */ +struct il3945_eeprom_txpower_group { + struct il3945_eeprom_txpower_sample samples[5]; /* 5 power levels */ + s32 a, b, c, d, e; /* coefficients for voltage->power + * formula (signed) */ + s32 Fa, Fb, Fc, Fd, Fe; /* these modify coeffs based on + * frequency (signed) */ + s8 saturation_power; /* highest power possible by h/w in this + * band */ + u8 group_channel; /* "representative" channel # in this band */ + s16 temperature; /* h/w temperature at factory calib this band + * (signed) */ +} __packed; + +/* + * Temperature-based Tx-power compensation data, not band-specific. + * These coefficients are use to modify a/b/c/d/e coeffs based on + * difference between current temperature and factory calib temperature. + * Data copied from EEPROM. + */ +struct il3945_eeprom_temperature_corr { + u32 Ta; + u32 Tb; + u32 Tc; + u32 Td; + u32 Te; +} __packed; + +/* + * EEPROM map + */ +struct il3945_eeprom { + u8 reserved0[16]; + u16 device_id; /* abs.ofs: 16 */ + u8 reserved1[2]; + u16 pmc; /* abs.ofs: 20 */ + u8 reserved2[20]; + u8 mac_address[6]; /* abs.ofs: 42 */ + u8 reserved3[58]; + u16 board_revision; /* abs.ofs: 106 */ + u8 reserved4[11]; + u8 board_pba_number[9]; /* abs.ofs: 119 */ + u8 reserved5[8]; + u16 version; /* abs.ofs: 136 */ + u8 sku_cap; /* abs.ofs: 138 */ + u8 leds_mode; /* abs.ofs: 139 */ + u16 oem_mode; + u16 wowlan_mode; /* abs.ofs: 142 */ + u16 leds_time_interval; /* abs.ofs: 144 */ + u8 leds_off_time; /* abs.ofs: 146 */ + u8 leds_on_time; /* abs.ofs: 147 */ + u8 almgor_m_version; /* abs.ofs: 148 */ + u8 antenna_switch_type; /* abs.ofs: 149 */ + u8 reserved6[42]; + u8 sku_id[4]; /* abs.ofs: 192 */ + +/* + * Per-channel regulatory data. + * + * Each channel that *might* be supported by 3945 has a fixed location + * in EEPROM containing EEPROM_CHANNEL_* usage flags (LSB) and max regulatory + * txpower (MSB). + * + * Entries immediately below are for 20 MHz channel width. + * + * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 + */ + u16 band_1_count; /* abs.ofs: 196 */ + struct il_eeprom_channel band_1_channels[14]; /* abs.ofs: 198 */ + +/* + * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196, + * 5.0 GHz channels 7, 8, 11, 12, 16 + * (4915-5080MHz) (none of these is ever supported) + */ + u16 band_2_count; /* abs.ofs: 226 */ + struct il_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */ + +/* + * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 + * (5170-5320MHz) + */ + u16 band_3_count; /* abs.ofs: 254 */ + struct il_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */ + +/* + * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 + * (5500-5700MHz) + */ + u16 band_4_count; /* abs.ofs: 280 */ + struct il_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */ + +/* + * 5.7 GHz channels 145, 149, 153, 157, 161, 165 + * (5725-5825MHz) + */ + u16 band_5_count; /* abs.ofs: 304 */ + struct il_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */ + + u8 reserved9[194]; + +/* + * 3945 Txpower calibration data. + */ +#define IL_NUM_TX_CALIB_GROUPS 5 + struct il3945_eeprom_txpower_group groups[IL_NUM_TX_CALIB_GROUPS]; +/* abs.ofs: 512 */ + struct il3945_eeprom_temperature_corr corrections; /* abs.ofs: 832 */ + u8 reserved16[172]; /* fill out to full 1024 byte block */ +} __packed; + +#define IL3945_EEPROM_IMG_SIZE 1024 + +/* End of EEPROM */ + +#define PCI_CFG_REV_ID_BIT_BASIC_SKU (0x40) /* bit 6 */ +#define PCI_CFG_REV_ID_BIT_RTP (0x80) /* bit 7 */ + +/* 4 DATA + 1 CMD. There are 2 HCCA queues that are not used. */ +#define IL39_NUM_QUEUES 5 +#define IL39_CMD_QUEUE_NUM 4 + +#define IL_DEFAULT_TX_RETRY 15 + +/*********************************************/ + +#define RFD_SIZE 4 +#define NUM_TFD_CHUNKS 4 + +#define RX_QUEUE_SIZE 256 +#define RX_QUEUE_MASK 255 +#define RX_QUEUE_SIZE_LOG 8 + +#define TFD_CTL_COUNT_SET(n) (n << 24) +#define TFD_CTL_COUNT_GET(ctl) ((ctl >> 24) & 7) +#define TFD_CTL_PAD_SET(n) (n << 28) +#define TFD_CTL_PAD_GET(ctl) (ctl >> 28) + +/* Sizes and addresses for instruction and data memory (SRAM) in + * 3945's embedded processor. Driver access is via HBUS_TARG_MEM_* regs. */ +#define IL39_RTC_INST_LOWER_BOUND (0x000000) +#define IL39_RTC_INST_UPPER_BOUND (0x014000) + +#define IL39_RTC_DATA_LOWER_BOUND (0x800000) +#define IL39_RTC_DATA_UPPER_BOUND (0x808000) + +#define IL39_RTC_INST_SIZE (IL39_RTC_INST_UPPER_BOUND - \ + IL39_RTC_INST_LOWER_BOUND) +#define IL39_RTC_DATA_SIZE (IL39_RTC_DATA_UPPER_BOUND - \ + IL39_RTC_DATA_LOWER_BOUND) + +#define IL39_MAX_INST_SIZE IL39_RTC_INST_SIZE +#define IL39_MAX_DATA_SIZE IL39_RTC_DATA_SIZE + +/* Size of uCode instruction memory in bootstrap state machine */ +#define IL39_MAX_BSM_SIZE IL39_RTC_INST_SIZE + +static inline int il3945_hw_valid_rtc_data_addr(u32 addr) +{ + return (addr >= IL39_RTC_DATA_LOWER_BOUND && + addr < IL39_RTC_DATA_UPPER_BOUND); +} + +/* Base physical address of il3945_shared is provided to FH_TSSR_CBB_BASE + * and &il3945_shared.rx_read_ptr[0] is provided to FH_RCSR_RPTR_ADDR(0) */ +struct il3945_shared { + __le32 tx_base_ptr[8]; +} __packed; + +static inline u8 il3945_hw_get_rate(__le16 rate_n_flags) +{ + return le16_to_cpu(rate_n_flags) & 0xFF; +} + +static inline u16 il3945_hw_get_rate_n_flags(__le16 rate_n_flags) +{ + return le16_to_cpu(rate_n_flags); +} + +static inline __le16 il3945_hw_set_rate_n_flags(u8 rate, u16 flags) +{ + return cpu_to_le16((u16)rate|flags); +} + +/************************************/ +/* iwl3945 Flow Handler Definitions */ +/************************************/ + +/** + * This I/O area is directly read/writable by driver (e.g. Linux uses writel()) + * Addresses are offsets from device's PCI hardware base address. + */ +#define FH39_MEM_LOWER_BOUND (0x0800) +#define FH39_MEM_UPPER_BOUND (0x1000) + +#define FH39_CBCC_TBL (FH39_MEM_LOWER_BOUND + 0x140) +#define FH39_TFDB_TBL (FH39_MEM_LOWER_BOUND + 0x180) +#define FH39_RCSR_TBL (FH39_MEM_LOWER_BOUND + 0x400) +#define FH39_RSSR_TBL (FH39_MEM_LOWER_BOUND + 0x4c0) +#define FH39_TCSR_TBL (FH39_MEM_LOWER_BOUND + 0x500) +#define FH39_TSSR_TBL (FH39_MEM_LOWER_BOUND + 0x680) + +/* TFDB (Transmit Frame Buffer Descriptor) */ +#define FH39_TFDB(_ch, buf) (FH39_TFDB_TBL + \ + ((_ch) * 2 + (buf)) * 0x28) +#define FH39_TFDB_CHNL_BUF_CTRL_REG(_ch) (FH39_TFDB_TBL + 0x50 * (_ch)) + +/* CBCC channel is [0,2] */ +#define FH39_CBCC(_ch) (FH39_CBCC_TBL + (_ch) * 0x8) +#define FH39_CBCC_CTRL(_ch) (FH39_CBCC(_ch) + 0x00) +#define FH39_CBCC_BASE(_ch) (FH39_CBCC(_ch) + 0x04) + +/* RCSR channel is [0,2] */ +#define FH39_RCSR(_ch) (FH39_RCSR_TBL + (_ch) * 0x40) +#define FH39_RCSR_CONFIG(_ch) (FH39_RCSR(_ch) + 0x00) +#define FH39_RCSR_RBD_BASE(_ch) (FH39_RCSR(_ch) + 0x04) +#define FH39_RCSR_WPTR(_ch) (FH39_RCSR(_ch) + 0x20) +#define FH39_RCSR_RPTR_ADDR(_ch) (FH39_RCSR(_ch) + 0x24) + +#define FH39_RSCSR_CHNL0_WPTR (FH39_RCSR_WPTR(0)) + +/* RSSR */ +#define FH39_RSSR_CTRL (FH39_RSSR_TBL + 0x000) +#define FH39_RSSR_STATUS (FH39_RSSR_TBL + 0x004) + +/* TCSR */ +#define FH39_TCSR(_ch) (FH39_TCSR_TBL + (_ch) * 0x20) +#define FH39_TCSR_CONFIG(_ch) (FH39_TCSR(_ch) + 0x00) +#define FH39_TCSR_CREDIT(_ch) (FH39_TCSR(_ch) + 0x04) +#define FH39_TCSR_BUFF_STTS(_ch) (FH39_TCSR(_ch) + 0x08) + +/* TSSR */ +#define FH39_TSSR_CBB_BASE (FH39_TSSR_TBL + 0x000) +#define FH39_TSSR_MSG_CONFIG (FH39_TSSR_TBL + 0x008) +#define FH39_TSSR_TX_STATUS (FH39_TSSR_TBL + 0x010) + + +/* DBM */ + +#define FH39_SRVC_CHNL (6) + +#define FH39_RCSR_RX_CONFIG_REG_POS_RBDC_SIZE (20) +#define FH39_RCSR_RX_CONFIG_REG_POS_IRQ_RBTH (4) + +#define FH39_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN (0x08000000) + +#define FH39_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE (0x80000000) + +#define FH39_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE (0x20000000) + +#define FH39_RCSR_RX_CONFIG_REG_VAL_MAX_FRAG_SIZE_128 (0x01000000) + +#define FH39_RCSR_RX_CONFIG_REG_VAL_IRQ_DEST_INT_HOST (0x00001000) + +#define FH39_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH (0x00000000) + +#define FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000) +#define FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRIVER (0x00000001) + +#define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL (0x00000000) +#define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL (0x00000008) + +#define FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000) + +#define FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000) + +#define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000) +#define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000) + +#define FH39_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00004000) + +#define FH39_TCSR_CHNL_TX_BUF_STS_REG_BIT_TFDB_WPTR (0x00000001) + +#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON (0xFF000000) +#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON (0x00FF0000) + +#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B (0x00000400) + +#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON (0x00000100) +#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON (0x00000080) + +#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH (0x00000020) +#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH (0x00000005) + +#define FH39_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_ch) (BIT(_ch) << 24) +#define FH39_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_ch) (BIT(_ch) << 16) + +#define FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_ch) \ + (FH39_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_ch) | \ + FH39_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_ch)) + +#define FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000) + +struct il3945_tfd_tb { + __le32 addr; + __le32 len; +} __packed; + +struct il3945_tfd { + __le32 control_flags; + struct il3945_tfd_tb tbs[4]; + u8 __pad[28]; +} __packed; + +#ifdef CONFIG_IWLEGACY_DEBUGFS +ssize_t il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); +ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); +ssize_t il3945_ucode_general_stats_read(struct file *file, + char __user *user_buf, size_t count, + loff_t *ppos); +#else +static ssize_t il3945_ucode_rx_stats_read(struct file *file, + char __user *user_buf, size_t count, + loff_t *ppos) +{ + return 0; +} +static ssize_t il3945_ucode_tx_stats_read(struct file *file, + char __user *user_buf, size_t count, + loff_t *ppos) +{ + return 0; +} +static ssize_t il3945_ucode_general_stats_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + return 0; +} +#endif + +/* Requires full declaration of il_priv before including */ +#include "iwl-io.h" + +#endif diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h b/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h deleted file mode 100644 index 9d1a4a041b18..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-3945-debugfs.h +++ /dev/null @@ -1,60 +0,0 @@ -/****************************************************************************** - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - *****************************************************************************/ - -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-debug.h" - -#ifdef CONFIG_IWLEGACY_DEBUGFS -ssize_t il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); -ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); -ssize_t il3945_ucode_general_stats_read(struct file *file, - char __user *user_buf, size_t count, - loff_t *ppos); -#else -static ssize_t il3945_ucode_rx_stats_read(struct file *file, - char __user *user_buf, size_t count, - loff_t *ppos) -{ - return 0; -} -static ssize_t il3945_ucode_tx_stats_read(struct file *file, - char __user *user_buf, size_t count, - loff_t *ppos) -{ - return 0; -} -static ssize_t il3945_ucode_general_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - return 0; -} -#endif diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-fh.h b/drivers/net/wireless/iwlegacy/iwl-3945-fh.h deleted file mode 100644 index aa44a9036201..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-3945-fh.h +++ /dev/null @@ -1,187 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - *****************************************************************************/ -#ifndef __il_3945_fh_h__ -#define __il_3945_fh_h__ - -/************************************/ -/* iwl3945 Flow Handler Definitions */ -/************************************/ - -/** - * This I/O area is directly read/writable by driver (e.g. Linux uses writel()) - * Addresses are offsets from device's PCI hardware base address. - */ -#define FH39_MEM_LOWER_BOUND (0x0800) -#define FH39_MEM_UPPER_BOUND (0x1000) - -#define FH39_CBCC_TBL (FH39_MEM_LOWER_BOUND + 0x140) -#define FH39_TFDB_TBL (FH39_MEM_LOWER_BOUND + 0x180) -#define FH39_RCSR_TBL (FH39_MEM_LOWER_BOUND + 0x400) -#define FH39_RSSR_TBL (FH39_MEM_LOWER_BOUND + 0x4c0) -#define FH39_TCSR_TBL (FH39_MEM_LOWER_BOUND + 0x500) -#define FH39_TSSR_TBL (FH39_MEM_LOWER_BOUND + 0x680) - -/* TFDB (Transmit Frame Buffer Descriptor) */ -#define FH39_TFDB(_ch, buf) (FH39_TFDB_TBL + \ - ((_ch) * 2 + (buf)) * 0x28) -#define FH39_TFDB_CHNL_BUF_CTRL_REG(_ch) (FH39_TFDB_TBL + 0x50 * (_ch)) - -/* CBCC channel is [0,2] */ -#define FH39_CBCC(_ch) (FH39_CBCC_TBL + (_ch) * 0x8) -#define FH39_CBCC_CTRL(_ch) (FH39_CBCC(_ch) + 0x00) -#define FH39_CBCC_BASE(_ch) (FH39_CBCC(_ch) + 0x04) - -/* RCSR channel is [0,2] */ -#define FH39_RCSR(_ch) (FH39_RCSR_TBL + (_ch) * 0x40) -#define FH39_RCSR_CONFIG(_ch) (FH39_RCSR(_ch) + 0x00) -#define FH39_RCSR_RBD_BASE(_ch) (FH39_RCSR(_ch) + 0x04) -#define FH39_RCSR_WPTR(_ch) (FH39_RCSR(_ch) + 0x20) -#define FH39_RCSR_RPTR_ADDR(_ch) (FH39_RCSR(_ch) + 0x24) - -#define FH39_RSCSR_CHNL0_WPTR (FH39_RCSR_WPTR(0)) - -/* RSSR */ -#define FH39_RSSR_CTRL (FH39_RSSR_TBL + 0x000) -#define FH39_RSSR_STATUS (FH39_RSSR_TBL + 0x004) - -/* TCSR */ -#define FH39_TCSR(_ch) (FH39_TCSR_TBL + (_ch) * 0x20) -#define FH39_TCSR_CONFIG(_ch) (FH39_TCSR(_ch) + 0x00) -#define FH39_TCSR_CREDIT(_ch) (FH39_TCSR(_ch) + 0x04) -#define FH39_TCSR_BUFF_STTS(_ch) (FH39_TCSR(_ch) + 0x08) - -/* TSSR */ -#define FH39_TSSR_CBB_BASE (FH39_TSSR_TBL + 0x000) -#define FH39_TSSR_MSG_CONFIG (FH39_TSSR_TBL + 0x008) -#define FH39_TSSR_TX_STATUS (FH39_TSSR_TBL + 0x010) - - -/* DBM */ - -#define FH39_SRVC_CHNL (6) - -#define FH39_RCSR_RX_CONFIG_REG_POS_RBDC_SIZE (20) -#define FH39_RCSR_RX_CONFIG_REG_POS_IRQ_RBTH (4) - -#define FH39_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN (0x08000000) - -#define FH39_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE (0x80000000) - -#define FH39_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE (0x20000000) - -#define FH39_RCSR_RX_CONFIG_REG_VAL_MAX_FRAG_SIZE_128 (0x01000000) - -#define FH39_RCSR_RX_CONFIG_REG_VAL_IRQ_DEST_INT_HOST (0x00001000) - -#define FH39_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH (0x00000000) - -#define FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000) -#define FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRIVER (0x00000001) - -#define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE_VAL (0x00000000) -#define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL (0x00000008) - -#define FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000) - -#define FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000) - -#define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000) -#define FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000) - -#define FH39_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00004000) - -#define FH39_TCSR_CHNL_TX_BUF_STS_REG_BIT_TFDB_WPTR (0x00000001) - -#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON (0xFF000000) -#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON (0x00FF0000) - -#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B (0x00000400) - -#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON (0x00000100) -#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON (0x00000080) - -#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH (0x00000020) -#define FH39_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH (0x00000005) - -#define FH39_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_ch) (BIT(_ch) << 24) -#define FH39_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_ch) (BIT(_ch) << 16) - -#define FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_ch) \ - (FH39_TSSR_TX_STATUS_REG_BIT_BUFS_EMPTY(_ch) | \ - FH39_TSSR_TX_STATUS_REG_BIT_NO_PEND_REQ(_ch)) - -#define FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000) - -struct il3945_tfd_tb { - __le32 addr; - __le32 len; -} __packed; - -struct il3945_tfd { - __le32 control_flags; - struct il3945_tfd_tb tbs[4]; - u8 __pad[28]; -} __packed; - - -#endif /* __il_3945_fh_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-hw.h b/drivers/net/wireless/iwlegacy/iwl-3945-hw.h deleted file mode 100644 index 53e5fb4373d9..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-3945-hw.h +++ /dev/null @@ -1,291 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - *****************************************************************************/ -/* - * Please use this file (iwl-3945-hw.h) only for hardware-related definitions. - * Please use iwl-commands.h for uCode API definitions. - * Please use iwl-3945.h for driver implementation definitions. - */ - -#ifndef __il_3945_hw__ -#define __il_3945_hw__ - -#include "iwl-eeprom.h" - -/* RSSI to dBm */ -#define IL39_RSSI_OFFSET 95 - -/* - * EEPROM related constants, enums, and structures. - */ -#define EEPROM_SKU_CAP_OP_MODE_MRC (1 << 7) - -/* - * Mapping of a Tx power level, at factory calibration temperature, - * to a radio/DSP gain table idx. - * One for each of 5 "sample" power levels in each band. - * v_det is measured at the factory, using the 3945's built-in power amplifier - * (PA) output voltage detector. This same detector is used during Tx of - * long packets in normal operation to provide feedback as to proper output - * level. - * Data copied from EEPROM. - * DO NOT ALTER THIS STRUCTURE!!! - */ -struct il3945_eeprom_txpower_sample { - u8 gain_idx; /* idx into power (gain) setup table ... */ - s8 power; /* ... for this pwr level for this chnl group */ - u16 v_det; /* PA output voltage */ -} __packed; - -/* - * Mappings of Tx power levels -> nominal radio/DSP gain table idxes. - * One for each channel group (a.k.a. "band") (1 for BG, 4 for A). - * Tx power setup code interpolates between the 5 "sample" power levels - * to determine the nominal setup for a requested power level. - * Data copied from EEPROM. - * DO NOT ALTER THIS STRUCTURE!!! - */ -struct il3945_eeprom_txpower_group { - struct il3945_eeprom_txpower_sample samples[5]; /* 5 power levels */ - s32 a, b, c, d, e; /* coefficients for voltage->power - * formula (signed) */ - s32 Fa, Fb, Fc, Fd, Fe; /* these modify coeffs based on - * frequency (signed) */ - s8 saturation_power; /* highest power possible by h/w in this - * band */ - u8 group_channel; /* "representative" channel # in this band */ - s16 temperature; /* h/w temperature at factory calib this band - * (signed) */ -} __packed; - -/* - * Temperature-based Tx-power compensation data, not band-specific. - * These coefficients are use to modify a/b/c/d/e coeffs based on - * difference between current temperature and factory calib temperature. - * Data copied from EEPROM. - */ -struct il3945_eeprom_temperature_corr { - u32 Ta; - u32 Tb; - u32 Tc; - u32 Td; - u32 Te; -} __packed; - -/* - * EEPROM map - */ -struct il3945_eeprom { - u8 reserved0[16]; - u16 device_id; /* abs.ofs: 16 */ - u8 reserved1[2]; - u16 pmc; /* abs.ofs: 20 */ - u8 reserved2[20]; - u8 mac_address[6]; /* abs.ofs: 42 */ - u8 reserved3[58]; - u16 board_revision; /* abs.ofs: 106 */ - u8 reserved4[11]; - u8 board_pba_number[9]; /* abs.ofs: 119 */ - u8 reserved5[8]; - u16 version; /* abs.ofs: 136 */ - u8 sku_cap; /* abs.ofs: 138 */ - u8 leds_mode; /* abs.ofs: 139 */ - u16 oem_mode; - u16 wowlan_mode; /* abs.ofs: 142 */ - u16 leds_time_interval; /* abs.ofs: 144 */ - u8 leds_off_time; /* abs.ofs: 146 */ - u8 leds_on_time; /* abs.ofs: 147 */ - u8 almgor_m_version; /* abs.ofs: 148 */ - u8 antenna_switch_type; /* abs.ofs: 149 */ - u8 reserved6[42]; - u8 sku_id[4]; /* abs.ofs: 192 */ - -/* - * Per-channel regulatory data. - * - * Each channel that *might* be supported by 3945 has a fixed location - * in EEPROM containing EEPROM_CHANNEL_* usage flags (LSB) and max regulatory - * txpower (MSB). - * - * Entries immediately below are for 20 MHz channel width. - * - * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 - */ - u16 band_1_count; /* abs.ofs: 196 */ - struct il_eeprom_channel band_1_channels[14]; /* abs.ofs: 198 */ - -/* - * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196, - * 5.0 GHz channels 7, 8, 11, 12, 16 - * (4915-5080MHz) (none of these is ever supported) - */ - u16 band_2_count; /* abs.ofs: 226 */ - struct il_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */ - -/* - * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 - * (5170-5320MHz) - */ - u16 band_3_count; /* abs.ofs: 254 */ - struct il_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */ - -/* - * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 - * (5500-5700MHz) - */ - u16 band_4_count; /* abs.ofs: 280 */ - struct il_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */ - -/* - * 5.7 GHz channels 145, 149, 153, 157, 161, 165 - * (5725-5825MHz) - */ - u16 band_5_count; /* abs.ofs: 304 */ - struct il_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */ - - u8 reserved9[194]; - -/* - * 3945 Txpower calibration data. - */ -#define IL_NUM_TX_CALIB_GROUPS 5 - struct il3945_eeprom_txpower_group groups[IL_NUM_TX_CALIB_GROUPS]; -/* abs.ofs: 512 */ - struct il3945_eeprom_temperature_corr corrections; /* abs.ofs: 832 */ - u8 reserved16[172]; /* fill out to full 1024 byte block */ -} __packed; - -#define IL3945_EEPROM_IMG_SIZE 1024 - -/* End of EEPROM */ - -#define PCI_CFG_REV_ID_BIT_BASIC_SKU (0x40) /* bit 6 */ -#define PCI_CFG_REV_ID_BIT_RTP (0x80) /* bit 7 */ - -/* 4 DATA + 1 CMD. There are 2 HCCA queues that are not used. */ -#define IL39_NUM_QUEUES 5 -#define IL39_CMD_QUEUE_NUM 4 - -#define IL_DEFAULT_TX_RETRY 15 - -/*********************************************/ - -#define RFD_SIZE 4 -#define NUM_TFD_CHUNKS 4 - -#define RX_QUEUE_SIZE 256 -#define RX_QUEUE_MASK 255 -#define RX_QUEUE_SIZE_LOG 8 - -#define U32_PAD(n) ((4-(n))&0x3) - -#define TFD_CTL_COUNT_SET(n) (n << 24) -#define TFD_CTL_COUNT_GET(ctl) ((ctl >> 24) & 7) -#define TFD_CTL_PAD_SET(n) (n << 28) -#define TFD_CTL_PAD_GET(ctl) (ctl >> 28) - -/* Sizes and addresses for instruction and data memory (SRAM) in - * 3945's embedded processor. Driver access is via HBUS_TARG_MEM_* regs. */ -#define IL39_RTC_INST_LOWER_BOUND (0x000000) -#define IL39_RTC_INST_UPPER_BOUND (0x014000) - -#define IL39_RTC_DATA_LOWER_BOUND (0x800000) -#define IL39_RTC_DATA_UPPER_BOUND (0x808000) - -#define IL39_RTC_INST_SIZE (IL39_RTC_INST_UPPER_BOUND - \ - IL39_RTC_INST_LOWER_BOUND) -#define IL39_RTC_DATA_SIZE (IL39_RTC_DATA_UPPER_BOUND - \ - IL39_RTC_DATA_LOWER_BOUND) - -#define IL39_MAX_INST_SIZE IL39_RTC_INST_SIZE -#define IL39_MAX_DATA_SIZE IL39_RTC_DATA_SIZE - -/* Size of uCode instruction memory in bootstrap state machine */ -#define IL39_MAX_BSM_SIZE IL39_RTC_INST_SIZE - -static inline int il3945_hw_valid_rtc_data_addr(u32 addr) -{ - return (addr >= IL39_RTC_DATA_LOWER_BOUND && - addr < IL39_RTC_DATA_UPPER_BOUND); -} - -/* Base physical address of il3945_shared is provided to FH_TSSR_CBB_BASE - * and &il3945_shared.rx_read_ptr[0] is provided to FH_RCSR_RPTR_ADDR(0) */ -struct il3945_shared { - __le32 tx_base_ptr[8]; -} __packed; - -static inline u8 il3945_hw_get_rate(__le16 rate_n_flags) -{ - return le16_to_cpu(rate_n_flags) & 0xFF; -} - -static inline u16 il3945_hw_get_rate_n_flags(__le16 rate_n_flags) -{ - return le16_to_cpu(rate_n_flags); -} - -static inline __le16 il3945_hw_set_rate_n_flags(u8 rate, u16 flags) -{ - return cpu_to_le16((u16)rate|flags); -} -#endif diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.h b/drivers/net/wireless/iwlegacy/iwl-3945.h deleted file mode 100644 index 80fcbf8bbc5b..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-3945.h +++ /dev/null @@ -1,308 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ -/* - * Please use this file (iwl-3945.h) for driver implementation definitions. - * Please use iwl-3945-commands.h for uCode API definitions. - * Please use iwl-3945-hw.h for hardware-related definitions. - */ - -#ifndef __il_3945_h__ -#define __il_3945_h__ - -#include /* for struct pci_device_id */ -#include -#include - -/* Hardware specific file defines the PCI IDs table for that hardware module */ -extern const struct pci_device_id il3945_hw_card_ids[]; - -#include "iwl-csr.h" -#include "iwl-prph.h" -#include "iwl-fh.h" -#include "iwl-3945-hw.h" -#include "iwl-debug.h" -#include "iwl-power.h" -#include "iwl-dev.h" -#include "iwl-led.h" - -/* Highest firmware API version supported */ -#define IL3945_UCODE_API_MAX 2 - -/* Lowest firmware API version supported */ -#define IL3945_UCODE_API_MIN 1 - -#define IL3945_FW_PRE "iwlwifi-3945-" -#define _IL3945_MODULE_FIRMWARE(api) IL3945_FW_PRE #api ".ucode" -#define IL3945_MODULE_FIRMWARE(api) _IL3945_MODULE_FIRMWARE(api) - -/* Default noise level to report when noise measurement is not available. - * This may be because we're: - * 1) Not associated (4965, no beacon stats being sent to driver) - * 2) Scanning (noise measurement does not apply to associated channel) - * 3) Receiving CCK (3945 delivers noise info only for OFDM frames) - * Use default noise value of -127 ... this is below the range of measurable - * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user. - * Also, -127 works better than 0 when averaging frames with/without - * noise info (e.g. averaging might be done in app); measured dBm values are - * always negative ... using a negative value as the default keeps all - * averages within an s8's (used in some apps) range of negative values. */ -#define IL_NOISE_MEAS_NOT_AVAILABLE (-127) - -/* Module parameters accessible from iwl-*.c */ -extern struct il_mod_params il3945_mod_params; - -struct il3945_rate_scale_data { - u64 data; - s32 success_counter; - s32 success_ratio; - s32 counter; - s32 average_tpt; - unsigned long stamp; -}; - -struct il3945_rs_sta { - spinlock_t lock; - struct il_priv *il; - s32 *expected_tpt; - unsigned long last_partial_flush; - unsigned long last_flush; - u32 flush_time; - u32 last_tx_packets; - u32 tx_packets; - u8 tgg; - u8 flush_pending; - u8 start_rate; - struct timer_list rate_scale_flush; - struct il3945_rate_scale_data win[RATE_COUNT_3945]; -#ifdef CONFIG_MAC80211_DEBUGFS - struct dentry *rs_sta_dbgfs_stats_table_file; -#endif - - /* used to be in sta_info */ - int last_txrate_idx; -}; - - -/* - * The common struct MUST be first because it is shared between - * 3945 and 4965! - */ -struct il3945_sta_priv { - struct il_station_priv_common common; - struct il3945_rs_sta rs_sta; -}; - -enum il3945_antenna { - IL_ANTENNA_DIVERSITY, - IL_ANTENNA_MAIN, - IL_ANTENNA_AUX -}; - -/* - * RTS threshold here is total size [2347] minus 4 FCS bytes - * Per spec: - * a value of 0 means RTS on all data/management packets - * a value > max MSDU size means no RTS - * else RTS for data/management frames where MPDU is larger - * than RTS value. - */ -#define DEFAULT_RTS_THRESHOLD 2347U -#define MIN_RTS_THRESHOLD 0U -#define MAX_RTS_THRESHOLD 2347U -#define MAX_MSDU_SIZE 2304U -#define MAX_MPDU_SIZE 2346U -#define DEFAULT_BEACON_INTERVAL 100U -#define DEFAULT_SHORT_RETRY_LIMIT 7U -#define DEFAULT_LONG_RETRY_LIMIT 4U - -#define IL_TX_FIFO_AC0 0 -#define IL_TX_FIFO_AC1 1 -#define IL_TX_FIFO_AC2 2 -#define IL_TX_FIFO_AC3 3 -#define IL_TX_FIFO_HCCA_1 5 -#define IL_TX_FIFO_HCCA_2 6 -#define IL_TX_FIFO_NONE 7 - -#define IEEE80211_DATA_LEN 2304 -#define IEEE80211_4ADDR_LEN 30 -#define IEEE80211_HLEN (IEEE80211_4ADDR_LEN) -#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) - -struct il3945_frame { - union { - struct ieee80211_hdr frame; - struct il3945_tx_beacon_cmd beacon; - u8 raw[IEEE80211_FRAME_LEN]; - u8 cmd[360]; - } u; - struct list_head list; -}; - -#define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) -#define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ) -#define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4) - -#define SUP_RATE_11A_MAX_NUM_CHANNELS 8 -#define SUP_RATE_11B_MAX_NUM_CHANNELS 4 -#define SUP_RATE_11G_MAX_NUM_CHANNELS 12 - -#define IL_SUPPORTED_RATES_IE_LEN 8 - -#define SCAN_INTERVAL 100 - -#define MAX_TID_COUNT 9 - -#define IL_INVALID_RATE 0xFF -#define IL_INVALID_VALUE -1 - -#define STA_PS_STATUS_WAKE 0 -#define STA_PS_STATUS_SLEEP 1 - -struct il3945_ibss_seq { - u8 mac[ETH_ALEN]; - u16 seq_num; - u16 frag_num; - unsigned long packet_time; - struct list_head list; -}; - -#define IL_RX_HDR(x) ((struct il3945_rx_frame_hdr *)(\ - x->u.rx_frame.stats.payload + \ - x->u.rx_frame.stats.phy_count)) -#define IL_RX_END(x) ((struct il3945_rx_frame_end *)(\ - IL_RX_HDR(x)->payload + \ - le16_to_cpu(IL_RX_HDR(x)->len))) -#define IL_RX_STATS(x) (&x->u.rx_frame.stats) -#define IL_RX_DATA(x) (IL_RX_HDR(x)->payload) - - -/****************************************************************************** - * - * Functions implemented in iwl3945-base.c which are forward declared here - * for use by iwl-*.c - * - *****************************************************************************/ -extern int il3945_calc_db_from_ratio(int sig_ratio); -extern void il3945_rx_replenish(void *data); -extern void il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq); -extern unsigned int il3945_fill_beacon_frame(struct il_priv *il, - struct ieee80211_hdr *hdr, int left); -extern int il3945_dump_nic_event_log(struct il_priv *il, bool full_log, - char **buf, bool display); -extern void il3945_dump_nic_error_log(struct il_priv *il); - -/****************************************************************************** - * - * Functions implemented in iwl-[34]*.c which are forward declared here - * for use by iwl3945-base.c - * - * NOTE: The implementation of these functions are hardware specific - * which is why they are in the hardware specific files (vs. iwl-base.c) - * - * Naming convention -- - * il3945_ <-- Its part of iwlwifi (should be changed to il3945_) - * il3945_hw_ <-- Hardware specific (implemented in iwl-XXXX.c by all HW) - * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX) - * il3945_bg_ <-- Called from work queue context - * il3945_mac_ <-- mac80211 callback - * - ****************************************************************************/ -extern void il3945_hw_rx_handler_setup(struct il_priv *il); -extern void il3945_hw_setup_deferred_work(struct il_priv *il); -extern void il3945_hw_cancel_deferred_work(struct il_priv *il); -extern int il3945_hw_rxq_stop(struct il_priv *il); -extern int il3945_hw_set_hw_params(struct il_priv *il); -extern int il3945_hw_nic_init(struct il_priv *il); -extern int il3945_hw_nic_stop_master(struct il_priv *il); -extern void il3945_hw_txq_ctx_free(struct il_priv *il); -extern void il3945_hw_txq_ctx_stop(struct il_priv *il); -extern int il3945_hw_nic_reset(struct il_priv *il); -extern int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, - struct il_tx_queue *txq, - dma_addr_t addr, u16 len, - u8 reset, u8 pad); -extern void il3945_hw_txq_free_tfd(struct il_priv *il, - struct il_tx_queue *txq); -extern int il3945_hw_get_temperature(struct il_priv *il); -extern int il3945_hw_tx_queue_init(struct il_priv *il, - struct il_tx_queue *txq); -extern unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, - struct il3945_frame *frame, u8 rate); -void il3945_hw_build_tx_cmd_rate(struct il_priv *il, - struct il_device_cmd *cmd, - struct ieee80211_tx_info *info, - struct ieee80211_hdr *hdr, - int sta_id, int tx_id); -extern int il3945_hw_reg_send_txpower(struct il_priv *il); -extern int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power); -extern void il3945_hw_rx_stats(struct il_priv *il, - struct il_rx_buf *rxb); -void il3945_reply_stats(struct il_priv *il, - struct il_rx_buf *rxb); -extern void il3945_disable_events(struct il_priv *il); -extern int il4965_get_temperature(const struct il_priv *il); -extern void il3945_post_associate(struct il_priv *il); -extern void il3945_config_ap(struct il_priv *il); - -extern int il3945_commit_rxon(struct il_priv *il, - struct il_rxon_context *ctx); - -/** - * il3945_hw_find_station - Find station id for a given BSSID - * @bssid: MAC address of station ID to find - * - * NOTE: This should not be hardware specific but the code has - * not yet been merged into a single common layer for managing the - * station tables. - */ -extern u8 il3945_hw_find_station(struct il_priv *il, const u8 *bssid); - -extern struct ieee80211_ops il3945_hw_ops; - -/* - * Forward declare iwl-3945.c functions for iwl3945-base.c - */ -extern __le32 il3945_get_antenna_flags(const struct il_priv *il); -extern int il3945_init_hw_rate_table(struct il_priv *il); -extern void il3945_reg_txpower_periodic(struct il_priv *il); -extern int il3945_txpower_set_from_eeprom(struct il_priv *il); - -extern const struct il_channel_info *il3945_get_channel_info( - const struct il_priv *il, enum ieee80211_band band, u16 channel); - -extern int il3945_rs_next_rate(struct il_priv *il, int rate); - -/* scanning */ -int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif); -void il3945_post_scan(struct il_priv *il); - -/* rates */ -extern const struct il3945_rate_info il3945_rates[RATE_COUNT_3945]; - -/* Requires full declaration of il_priv before including */ -#include "iwl-io.h" - -#endif diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 97b25730c329..f7c3b43ae049 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -45,11 +45,12 @@ #include "iwl-fh.h" #include "iwl-debug.h" #include "4965.h" -#include "iwl-3945-hw.h" #include "iwl-led.h" #include "iwl-power.h" #include "iwl-legacy-rs.h" +#define U32_PAD(n) ((4-(n))&0x3) + struct il_tx_queue; /* CT-KILL constants */ -- cgit v1.2.3 From a6766ccdaf9cc80d565672516d429a562d1a732d Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 13:09:01 +0100 Subject: iwlegacy: s/STATUS_/S_/ Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/3945-mac.c | 98 ++++++++++---------- drivers/net/wireless/iwlegacy/3945.c | 10 +-- drivers/net/wireless/iwlegacy/4965-mac.c | 134 ++++++++++++++-------------- drivers/net/wireless/iwlegacy/4965.c | 18 ++-- drivers/net/wireless/iwlegacy/iwl-core.c | 40 ++++----- drivers/net/wireless/iwlegacy/iwl-core.h | 50 +++++------ drivers/net/wireless/iwlegacy/iwl-debugfs.c | 66 +++++++------- drivers/net/wireless/iwlegacy/iwl-hcmd.c | 14 +-- drivers/net/wireless/iwlegacy/iwl-helpers.h | 4 +- drivers/net/wireless/iwlegacy/iwl-led.c | 2 +- drivers/net/wireless/iwlegacy/iwl-power.c | 6 +- drivers/net/wireless/iwlegacy/iwl-rx.c | 2 +- drivers/net/wireless/iwlegacy/iwl-scan.c | 42 ++++----- drivers/net/wireless/iwlegacy/iwl-tx.c | 4 +- 14 files changed, 245 insertions(+), 245 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 17edbdf9dc84..f69211ee5fe7 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -827,17 +827,17 @@ static void il3945_rx_card_state_notif(struct il_priv *il, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); if (flags & HW_CARD_DISABLED) - set_bit(STATUS_RF_KILL_HW, &il->status); + set_bit(S_RF_KILL_HW, &il->status); else - clear_bit(STATUS_RF_KILL_HW, &il->status); + clear_bit(S_RF_KILL_HW, &il->status); il_scan_cancel(il); - if ((test_bit(STATUS_RF_KILL_HW, &status) != - test_bit(STATUS_RF_KILL_HW, &il->status))) + if ((test_bit(S_RF_KILL_HW, &status) != + test_bit(S_RF_KILL_HW, &il->status))) wiphy_rfkill_set_hw_state(il->hw->wiphy, - test_bit(STATUS_RF_KILL_HW, &il->status)); + test_bit(S_RF_KILL_HW, &il->status)); else wake_up(&il->wait_command_queue); } @@ -1537,7 +1537,7 @@ static void il3945_irq_tasklet(struct il_priv *il) /* Re-enable all interrupts */ /* only Re-enable if disabled by irq */ - if (test_bit(STATUS_INT_ENABLED, &il->status)) + if (test_bit(S_INT_ENABLED, &il->status)) il_enable_interrupts(il); #ifdef CONFIG_IWLEGACY_DEBUG @@ -2213,7 +2213,7 @@ static void il3945_alive_start(struct il_priv *il) D_INFO("RFKILL status: 0x%x\n", rfkill); if (rfkill & 0x1) { - clear_bit(STATUS_RF_KILL_HW, &il->status); + clear_bit(S_RF_KILL_HW, &il->status); /* if RFKILL is not on, then wait for thermal * sensor in adapter to kick in */ while (il3945_hw_get_temperature(il) == 0) { @@ -2225,10 +2225,10 @@ static void il3945_alive_start(struct il_priv *il) D_INFO("Thermal calibration took %dus\n", thermal_spin * 10); } else - set_bit(STATUS_RF_KILL_HW, &il->status); + set_bit(S_RF_KILL_HW, &il->status); /* After the ALIVE response, we can send commands to 3945 uCode */ - set_bit(STATUS_ALIVE, &il->status); + set_bit(S_ALIVE, &il->status); /* Enable watchdog to monitor the driver tx queues */ il_setup_watchdog(il); @@ -2256,7 +2256,7 @@ static void il3945_alive_start(struct il_priv *il) /* Configure Bluetooth device coexistence support */ il_send_bt_config(il); - set_bit(STATUS_READY, &il->status); + set_bit(S_READY, &il->status); /* Configure the adapter for unassociated operation */ il3945_commit_rxon(il, ctx); @@ -2283,9 +2283,9 @@ static void __il3945_down(struct il_priv *il) il_scan_cancel_timeout(il, 200); - exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &il->status); + exit_pending = test_and_set_bit(S_EXIT_PENDING, &il->status); - /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set + /* Stop TX queues watchdog. We need to have S_EXIT_PENDING bit set * to prevent rearm timer */ del_timer_sync(&il->watchdog); @@ -2300,7 +2300,7 @@ static void __il3945_down(struct il_priv *il) /* Wipe out the EXIT_PENDING status bit if we are not actually * exiting the module */ if (!exit_pending) - clear_bit(STATUS_EXIT_PENDING, &il->status); + clear_bit(S_EXIT_PENDING, &il->status); /* stop and reset the on-board processor */ _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); @@ -2317,25 +2317,25 @@ static void __il3945_down(struct il_priv *il) /* If we have not previously called il3945_init() then * clear all bits but the RF Kill bits and return */ if (!il_is_init(il)) { - il->status = test_bit(STATUS_RF_KILL_HW, &il->status) << - STATUS_RF_KILL_HW | - test_bit(STATUS_GEO_CONFIGURED, &il->status) << - STATUS_GEO_CONFIGURED | - test_bit(STATUS_EXIT_PENDING, &il->status) << - STATUS_EXIT_PENDING; + il->status = test_bit(S_RF_KILL_HW, &il->status) << + S_RF_KILL_HW | + test_bit(S_GEO_CONFIGURED, &il->status) << + S_GEO_CONFIGURED | + test_bit(S_EXIT_PENDING, &il->status) << + S_EXIT_PENDING; goto exit; } /* ...otherwise clear out all the status bits but the RF Kill * bit and continue taking the NIC down. */ - il->status &= test_bit(STATUS_RF_KILL_HW, &il->status) << - STATUS_RF_KILL_HW | - test_bit(STATUS_GEO_CONFIGURED, &il->status) << - STATUS_GEO_CONFIGURED | - test_bit(STATUS_FW_ERROR, &il->status) << - STATUS_FW_ERROR | - test_bit(STATUS_EXIT_PENDING, &il->status) << - STATUS_EXIT_PENDING; + il->status &= test_bit(S_RF_KILL_HW, &il->status) << + S_RF_KILL_HW | + test_bit(S_GEO_CONFIGURED, &il->status) << + S_GEO_CONFIGURED | + test_bit(S_FW_ERROR, &il->status) << + S_FW_ERROR | + test_bit(S_EXIT_PENDING, &il->status) << + S_EXIT_PENDING; il3945_hw_txq_ctx_stop(il); il3945_hw_rxq_stop(il); @@ -2400,7 +2400,7 @@ static int __il3945_up(struct il_priv *il) if (rc) return rc; - if (test_bit(STATUS_EXIT_PENDING, &il->status)) { + if (test_bit(S_EXIT_PENDING, &il->status)) { IL_WARN("Exit pending; will not bring the NIC up\n"); return -EIO; } @@ -2413,9 +2413,9 @@ static int __il3945_up(struct il_priv *il) /* If platform's RF_KILL switch is NOT set to KILL */ if (_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) - clear_bit(STATUS_RF_KILL_HW, &il->status); + clear_bit(S_RF_KILL_HW, &il->status); else { - set_bit(STATUS_RF_KILL_HW, &il->status); + set_bit(S_RF_KILL_HW, &il->status); IL_WARN("Radio disabled by HW RF Kill switch\n"); return -ENODEV; } @@ -2448,7 +2448,7 @@ static int __il3945_up(struct il_priv *il) il->ucode_data.len); /* We return success when we resume from suspend and rf_kill is on. */ - if (test_bit(STATUS_RF_KILL_HW, &il->status)) + if (test_bit(S_RF_KILL_HW, &il->status)) return 0; for (i = 0; i < MAX_HW_RESTARTS; i++) { @@ -2472,9 +2472,9 @@ static int __il3945_up(struct il_priv *il) return 0; } - set_bit(STATUS_EXIT_PENDING, &il->status); + set_bit(S_EXIT_PENDING, &il->status); __il3945_down(il); - clear_bit(STATUS_EXIT_PENDING, &il->status); + clear_bit(S_EXIT_PENDING, &il->status); /* tried to restart and config the device for as long as our * patience could withstand */ @@ -2495,7 +2495,7 @@ static void il3945_bg_init_alive_start(struct work_struct *data) container_of(data, struct il_priv, init_alive_start.work); mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) goto out; il3945_init_alive_start(il); @@ -2509,7 +2509,7 @@ static void il3945_bg_alive_start(struct work_struct *data) container_of(data, struct il_priv, alive_start.work); mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) goto out; il3945_alive_start(il); @@ -2527,15 +2527,15 @@ static void il3945_rfkill_poll(struct work_struct *data) { struct il_priv *il = container_of(data, struct il_priv, _3945.rfkill_poll.work); - bool old_rfkill = test_bit(STATUS_RF_KILL_HW, &il->status); + bool old_rfkill = test_bit(S_RF_KILL_HW, &il->status); bool new_rfkill = !(_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW); if (new_rfkill != old_rfkill) { if (new_rfkill) - set_bit(STATUS_RF_KILL_HW, &il->status); + set_bit(S_RF_KILL_HW, &il->status); else - clear_bit(STATUS_RF_KILL_HW, &il->status); + clear_bit(S_RF_KILL_HW, &il->status); wiphy_rfkill_set_hw_state(il->hw->wiphy, new_rfkill); @@ -2682,10 +2682,10 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) cmd.data = scan; scan->len = cpu_to_le16(cmd.len); - set_bit(STATUS_SCAN_HW, &il->status); + set_bit(S_SCAN_HW, &il->status); ret = il_send_cmd_sync(il, &cmd); if (ret) - clear_bit(STATUS_SCAN_HW, &il->status); + clear_bit(S_SCAN_HW, &il->status); return ret; } @@ -2705,10 +2705,10 @@ static void il3945_bg_restart(struct work_struct *data) { struct il_priv *il = container_of(data, struct il_priv, restart); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return; - if (test_and_clear_bit(STATUS_FW_ERROR, &il->status)) { + if (test_and_clear_bit(S_FW_ERROR, &il->status)) { mutex_lock(&il->mutex); il->ctx.vif = NULL; il->is_open = 0; @@ -2719,7 +2719,7 @@ static void il3945_bg_restart(struct work_struct *data) il3945_down(il); mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) { + if (test_bit(S_EXIT_PENDING, &il->status)) { mutex_unlock(&il->mutex); return; } @@ -2735,7 +2735,7 @@ static void il3945_bg_rx_replenish(struct work_struct *data) container_of(data, struct il_priv, rx_replenish); mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) goto out; il3945_rx_replenish(il); @@ -2755,7 +2755,7 @@ void il3945_post_associate(struct il_priv *il) D_ASSOC("Associated as %d to: %pM\n", ctx->vif->bss_conf.aid, ctx->active.bssid_addr); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return; il_scan_cancel_timeout(il, 200); @@ -2847,10 +2847,10 @@ static int il3945_mac_start(struct ieee80211_hw *hw) /* Wait for START_ALIVE from ucode. Otherwise callbacks from * mac80211 will not be run successfully. */ ret = wait_event_timeout(il->wait_command_queue, - test_bit(STATUS_READY, &il->status), + test_bit(S_READY, &il->status), UCODE_READY_TIMEOUT); if (!ret) { - if (!test_bit(STATUS_READY, &il->status)) { + if (!test_bit(S_READY, &il->status)) { IL_ERR( "Wait for START_ALIVE timeout after %dms.\n", jiffies_to_msecs(UCODE_READY_TIMEOUT)); @@ -2918,7 +2918,7 @@ void il3945_config_ap(struct il_priv *il) struct ieee80211_vif *vif = ctx->vif; int rc = 0; - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return; /* The following should be done only at AP bring up */ @@ -3870,7 +3870,7 @@ static void __devexit il3945_pci_remove(struct pci_dev *pdev) il_dbgfs_unregister(il); - set_bit(STATUS_EXIT_PENDING, &il->status); + set_bit(S_EXIT_PENDING, &il->status); il_leds_exit(il); diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 17615c33d1aa..8ebd576dfe62 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -1008,7 +1008,7 @@ int il3945_hw_nic_init(struct il_priv *il) if (rc) return rc; - set_bit(STATUS_INIT, &il->status); + set_bit(S_INIT, &il->status); return 0; } @@ -1394,7 +1394,7 @@ static int il3945_send_tx_power(struct il_priv *il) }; u16 chan; - if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &il->status), + if (WARN_ONCE(test_bit(S_SCAN_HW, &il->status), "TX Power requested while scanning!\n")) return -EAGAIN; @@ -1571,7 +1571,7 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) int temperature = il->temperature; if (il->disable_tx_power_cal || - test_bit(STATUS_SCANNING, &il->status)) { + test_bit(S_SCANNING, &il->status)) { /* do not perform tx power calibration */ return 0; } @@ -1726,7 +1726,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) int rc = 0; bool new_assoc = !!(staging_rxon->filter_flags & RXON_FILTER_ASSOC_MSK); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return -EINVAL; if (!il_is_alive(il)) @@ -1885,7 +1885,7 @@ static void il3945_bg_reg_txpower_periodic(struct work_struct *work) struct il_priv *il = container_of(work, struct il_priv, _3945.thermal_periodic.work); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return; mutex_lock(&il->mutex); diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index ee084a885adc..c4198bd42889 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -90,7 +90,7 @@ void il4965_check_abort_status(struct il_priv *il, { if (frame_count == 1 && status == TX_STATUS_FAIL_RFKILL_FLUSH) { IL_ERR("Tx flush command to flush out all frames\n"); - if (!test_bit(STATUS_EXIT_PENDING, &il->status)) + if (!test_bit(S_EXIT_PENDING, &il->status)) queue_work(il->workqueue, &il->tx_flush); } } @@ -246,7 +246,7 @@ int il4965_hw_nic_init(struct il_priv *il) } else il4965_txq_ctx_reset(il); - set_bit(STATUS_INIT, &il->status); + set_bit(S_INIT, &il->status); return 0; } @@ -966,7 +966,7 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) scan->tx_cmd.rate_n_flags = il4965_hw_set_rate_n_flags(rate, rate_flags); /* In power save mode use one chain, otherwise use all chains */ - if (test_bit(STATUS_POWER_PMI, &il->status)) { + if (test_bit(S_POWER_PMI, &il->status)) { /* rx_ant has been set to all valid chains previously */ active_chains = rx_ant & ((u8)(il->chain_noise_data.active_chains)); @@ -1010,11 +1010,11 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) cmd.data = scan; scan->len = cpu_to_le16(cmd.len); - set_bit(STATUS_SCAN_HW, &il->status); + set_bit(S_SCAN_HW, &il->status); ret = il_send_cmd_sync(il, &cmd); if (ret) - clear_bit(STATUS_SCAN_HW, &il->status); + clear_bit(S_SCAN_HW, &il->status); return ret; } @@ -1120,7 +1120,7 @@ static u8 il4965_count_chain_bitmap(u32 chain_bitmap) void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx) { bool is_single = il4965_is_single_rx_stream(il); - bool is_cam = !test_bit(STATUS_POWER_PMI, &il->status); + bool is_cam = !test_bit(S_POWER_PMI, &il->status); u8 idle_rx_cnt, active_rx_cnt, valid_rx_cnt; u32 active_chains; u16 rx_chain; @@ -1258,7 +1258,7 @@ void il4965_rx_missed_beacon_notif(struct il_priv *il, le32_to_cpu(missed_beacon->total_missed_becons), le32_to_cpu(missed_beacon->num_recvd_beacons), le32_to_cpu(missed_beacon->num_expected_beacons)); - if (!test_bit(STATUS_SCANNING, &il->status)) + if (!test_bit(S_SCANNING, &il->status)) il4965_init_sensitivity(il); } } @@ -1378,7 +1378,7 @@ void il4965_rx_stats(struct il_priv *il, memcpy(&il->_4965.stats, &pkt->u.stats, sizeof(il->_4965.stats)); - set_bit(STATUS_STATISTICS, &il->status); + set_bit(S_STATISTICS, &il->status); /* Reschedule the stats timer to occur in * REG_RECALIB_PERIOD seconds to ensure we get a @@ -1387,7 +1387,7 @@ void il4965_rx_stats(struct il_priv *il, mod_timer(&il->stats_periodic, jiffies + msecs_to_jiffies(REG_RECALIB_PERIOD * 1000)); - if (unlikely(!test_bit(STATUS_SCANNING, &il->status)) && + if (unlikely(!test_bit(S_SCANNING, &il->status)) && (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) { il4965_rx_calc_noise(il); queue_work(il->workqueue, &il->run_time_calib_work); @@ -3809,7 +3809,7 @@ static void il4965_bg_stats_periodic(unsigned long data) { struct il_priv *il = (struct il_priv *)data; - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return; /* dont send host command if rf-kill is on */ @@ -3895,17 +3895,17 @@ static void il4965_rx_card_state_notif(struct il_priv *il, il4965_perform_ct_kill_task(il); if (flags & HW_CARD_DISABLED) - set_bit(STATUS_RF_KILL_HW, &il->status); + set_bit(S_RF_KILL_HW, &il->status); else - clear_bit(STATUS_RF_KILL_HW, &il->status); + clear_bit(S_RF_KILL_HW, &il->status); if (!(flags & RXON_CARD_DISABLED)) il_scan_cancel(il); - if ((test_bit(STATUS_RF_KILL_HW, &status) != - test_bit(STATUS_RF_KILL_HW, &il->status))) + if ((test_bit(S_RF_KILL_HW, &status) != + test_bit(S_RF_KILL_HW, &il->status))) wiphy_rfkill_set_hw_state(il->hw->wiphy, - test_bit(STATUS_RF_KILL_HW, &il->status)); + test_bit(S_RF_KILL_HW, &il->status)); else wake_up(&il->wait_command_queue); } @@ -4199,11 +4199,11 @@ static void il4965_irq_tasklet(struct il_priv *il) * is killed. Hence update the killswitch state here. The * rfkill handler will care about restarting if needed. */ - if (!test_bit(STATUS_ALIVE, &il->status)) { + if (!test_bit(S_ALIVE, &il->status)) { if (hw_rf_kill) - set_bit(STATUS_RF_KILL_HW, &il->status); + set_bit(S_RF_KILL_HW, &il->status); else - clear_bit(STATUS_RF_KILL_HW, &il->status); + clear_bit(S_RF_KILL_HW, &il->status); wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rf_kill); } @@ -4272,7 +4272,7 @@ static void il4965_irq_tasklet(struct il_priv *il) /* Re-enable all interrupts */ /* only Re-enable if disabled by irq */ - if (test_bit(STATUS_INT_ENABLED, &il->status)) + if (test_bit(S_INT_ENABLED, &il->status)) il_enable_interrupts(il); /* Re-enable RF_KILL if it occurred */ else if (handled & CSR_INT_BIT_RF_KILL) @@ -5079,7 +5079,7 @@ static void il4965_alive_start(struct il_priv *il) /* After the ALIVE response, we can send host commands to the uCode */ - set_bit(STATUS_ALIVE, &il->status); + set_bit(S_ALIVE, &il->status); /* Enable watchdog to monitor the driver tx queues */ il_setup_watchdog(il); @@ -5110,7 +5110,7 @@ static void il4965_alive_start(struct il_priv *il) il4965_reset_run_time_calib(il); - set_bit(STATUS_READY, &il->status); + set_bit(S_READY, &il->status); /* Configure the adapter for unassociated operation */ il_commit_rxon(il, ctx); @@ -5141,9 +5141,9 @@ static void __il4965_down(struct il_priv *il) il_scan_cancel_timeout(il, 200); - exit_pending = test_and_set_bit(STATUS_EXIT_PENDING, &il->status); + exit_pending = test_and_set_bit(S_EXIT_PENDING, &il->status); - /* Stop TX queues watchdog. We need to have STATUS_EXIT_PENDING bit set + /* Stop TX queues watchdog. We need to have S_EXIT_PENDING bit set * to prevent rearm timer */ del_timer_sync(&il->watchdog); @@ -5157,7 +5157,7 @@ static void __il4965_down(struct il_priv *il) /* Wipe out the EXIT_PENDING status bit if we are not actually * exiting the module */ if (!exit_pending) - clear_bit(STATUS_EXIT_PENDING, &il->status); + clear_bit(S_EXIT_PENDING, &il->status); /* stop and reset the on-board processor */ _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); @@ -5174,25 +5174,25 @@ static void __il4965_down(struct il_priv *il) /* If we have not previously called il_init() then * clear all bits but the RF Kill bit and return */ if (!il_is_init(il)) { - il->status = test_bit(STATUS_RF_KILL_HW, &il->status) << - STATUS_RF_KILL_HW | - test_bit(STATUS_GEO_CONFIGURED, &il->status) << - STATUS_GEO_CONFIGURED | - test_bit(STATUS_EXIT_PENDING, &il->status) << - STATUS_EXIT_PENDING; + il->status = test_bit(S_RF_KILL_HW, &il->status) << + S_RF_KILL_HW | + test_bit(S_GEO_CONFIGURED, &il->status) << + S_GEO_CONFIGURED | + test_bit(S_EXIT_PENDING, &il->status) << + S_EXIT_PENDING; goto exit; } /* ...otherwise clear out all the status bits but the RF Kill * bit and continue taking the NIC down. */ - il->status &= test_bit(STATUS_RF_KILL_HW, &il->status) << - STATUS_RF_KILL_HW | - test_bit(STATUS_GEO_CONFIGURED, &il->status) << - STATUS_GEO_CONFIGURED | - test_bit(STATUS_FW_ERROR, &il->status) << - STATUS_FW_ERROR | - test_bit(STATUS_EXIT_PENDING, &il->status) << - STATUS_EXIT_PENDING; + il->status &= test_bit(S_RF_KILL_HW, &il->status) << + S_RF_KILL_HW | + test_bit(S_GEO_CONFIGURED, &il->status) << + S_GEO_CONFIGURED | + test_bit(S_FW_ERROR, &il->status) << + S_FW_ERROR | + test_bit(S_EXIT_PENDING, &il->status) << + S_EXIT_PENDING; il4965_txq_ctx_stop(il); il4965_rxq_stop(il); @@ -5283,7 +5283,7 @@ static int __il4965_up(struct il_priv *il) int i; int ret; - if (test_bit(STATUS_EXIT_PENDING, &il->status)) { + if (test_bit(S_EXIT_PENDING, &il->status)) { IL_WARN("Exit pending; will not bring the NIC up\n"); return -EIO; } @@ -5309,9 +5309,9 @@ static int __il4965_up(struct il_priv *il) /* If platform's RF_KILL switch is NOT set to KILL */ if (_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) - clear_bit(STATUS_RF_KILL_HW, &il->status); + clear_bit(S_RF_KILL_HW, &il->status); else - set_bit(STATUS_RF_KILL_HW, &il->status); + set_bit(S_RF_KILL_HW, &il->status); if (il_is_rfkill(il)) { wiphy_rfkill_set_hw_state(il->hw->wiphy, true); @@ -5372,9 +5372,9 @@ static int __il4965_up(struct il_priv *il) return 0; } - set_bit(STATUS_EXIT_PENDING, &il->status); + set_bit(S_EXIT_PENDING, &il->status); __il4965_down(il); - clear_bit(STATUS_EXIT_PENDING, &il->status); + clear_bit(S_EXIT_PENDING, &il->status); /* tried to restart and config the device for as long as our * patience could withstand */ @@ -5395,7 +5395,7 @@ static void il4965_bg_init_alive_start(struct work_struct *data) container_of(data, struct il_priv, init_alive_start.work); mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) goto out; il->cfg->ops->lib->init_alive_start(il); @@ -5409,7 +5409,7 @@ static void il4965_bg_alive_start(struct work_struct *data) container_of(data, struct il_priv, alive_start.work); mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) goto out; il4965_alive_start(il); @@ -5424,8 +5424,8 @@ static void il4965_bg_run_time_calib_work(struct work_struct *work) mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status) || - test_bit(STATUS_SCANNING, &il->status)) { + if (test_bit(S_EXIT_PENDING, &il->status) || + test_bit(S_SCANNING, &il->status)) { mutex_unlock(&il->mutex); return; } @@ -5444,10 +5444,10 @@ static void il4965_bg_restart(struct work_struct *data) { struct il_priv *il = container_of(data, struct il_priv, restart); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return; - if (test_and_clear_bit(STATUS_FW_ERROR, &il->status)) { + if (test_and_clear_bit(S_FW_ERROR, &il->status)) { mutex_lock(&il->mutex); il->ctx.vif = NULL; il->is_open = 0; @@ -5461,7 +5461,7 @@ static void il4965_bg_restart(struct work_struct *data) il4965_down(il); mutex_lock(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) { + if (test_bit(S_EXIT_PENDING, &il->status)) { mutex_unlock(&il->mutex); return; } @@ -5476,7 +5476,7 @@ static void il4965_bg_rx_replenish(struct work_struct *data) struct il_priv *il = container_of(data, struct il_priv, rx_replenish); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return; mutex_lock(&il->mutex); @@ -5582,10 +5582,10 @@ int il4965_mac_start(struct ieee80211_hw *hw) /* Wait for START_ALIVE from Run Time ucode. Otherwise callbacks from * mac80211 will not be run successfully. */ ret = wait_event_timeout(il->wait_command_queue, - test_bit(STATUS_READY, &il->status), + test_bit(S_READY, &il->status), UCODE_READY_TIMEOUT); if (!ret) { - if (!test_bit(STATUS_READY, &il->status)) { + if (!test_bit(S_READY, &il->status)) { IL_ERR("START_ALIVE timeout after %dms.\n", jiffies_to_msecs(UCODE_READY_TIMEOUT)); return -ETIMEDOUT; @@ -5751,7 +5751,7 @@ int il4965_mac_ampdu_action(struct ieee80211_hw *hw, case IEEE80211_AMPDU_RX_STOP: D_HT("stop Rx\n"); ret = il4965_sta_rx_agg_stop(il, sta, tid); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) ret = 0; break; case IEEE80211_AMPDU_TX_START: @@ -5761,7 +5761,7 @@ int il4965_mac_ampdu_action(struct ieee80211_hw *hw, case IEEE80211_AMPDU_TX_STOP: D_HT("stop Tx\n"); ret = il4965_tx_agg_stop(il, vif, sta, tid); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) ret = 0; break; case IEEE80211_AMPDU_TX_OPERATIONAL: @@ -5833,9 +5833,9 @@ void il4965_mac_channel_switch(struct ieee80211_hw *hw, if (il_is_rfkill(il)) goto out; - if (test_bit(STATUS_EXIT_PENDING, &il->status) || - test_bit(STATUS_SCANNING, &il->status) || - test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status) || + test_bit(S_SCANNING, &il->status) || + test_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) goto out; if (!il_is_associated_ctx(ctx)) @@ -5891,10 +5891,10 @@ void il4965_mac_channel_switch(struct ieee80211_hw *hw, * at this point, staging_rxon has the * configuration for channel switch */ - set_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status); + set_bit(S_CHANNEL_SWITCH_PENDING, &il->status); il->switch_channel = cpu_to_le16(ch); if (il->cfg->ops->lib->set_channel_switch(il, ch_switch)) { - clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status); + clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status); il->switch_channel = 0; ieee80211_chswitch_done(ctx->vif, false); } @@ -5968,8 +5968,8 @@ static void il4965_bg_txpower_work(struct work_struct *work) * then just return; the stats notification will * kick off another scheduled work to compensate for * any temperature delta we missed here. */ - if (test_bit(STATUS_EXIT_PENDING, &il->status) || - test_bit(STATUS_SCANNING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status) || + test_bit(S_SCANNING, &il->status)) goto out; /* Regardless of if we are associated, we must reconfigure the @@ -6376,12 +6376,12 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) /* If platform's RF_KILL switch is NOT set to KILL */ if (_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) - clear_bit(STATUS_RF_KILL_HW, &il->status); + clear_bit(S_RF_KILL_HW, &il->status); else - set_bit(STATUS_RF_KILL_HW, &il->status); + set_bit(S_RF_KILL_HW, &il->status); wiphy_rfkill_set_hw_state(il->hw->wiphy, - test_bit(STATUS_RF_KILL_HW, &il->status)); + test_bit(S_RF_KILL_HW, &il->status)); il_power_initialize(il); @@ -6433,9 +6433,9 @@ static void __devexit il4965_pci_remove(struct pci_dev *pdev) /* ieee80211_unregister_hw call wil cause il_mac_stop to * to be called and il4965_down since we are removing the device - * we need to set STATUS_EXIT_PENDING bit. + * we need to set S_EXIT_PENDING bit. */ - set_bit(STATUS_EXIT_PENDING, &il->status); + set_bit(S_EXIT_PENDING, &il->status); il_leds_exit(il); diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 8199e635d537..1efe824963a8 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -1349,7 +1349,7 @@ static int il4965_send_tx_power(struct il_priv *il) u8 ctrl_chan_high = 0; struct il_rxon_context *ctx = &il->ctx; - if (WARN_ONCE(test_bit(STATUS_SCAN_HW, &il->status), + if (WARN_ONCE(test_bit(S_SCAN_HW, &il->status), "TX Power requested while scanning!\n")) return -EAGAIN; @@ -1441,7 +1441,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) * receive commit_rxon request * abort any previous channel switch if still in process */ - if (test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status) && + if (test_bit(S_CHANNEL_SWITCH_PENDING, &il->status) && il->switch_channel != ctx->staging.channel) { D_11H("abort channel switch on %d\n", le16_to_cpu(il->switch_channel)); @@ -1673,7 +1673,7 @@ static int il4965_hw_get_temperature(struct il_priv *il) s32 R1, R2, R3; u32 R4; - if (test_bit(STATUS_TEMPERATURE, &il->status) && + if (test_bit(S_TEMPERATURE, &il->status) && (il->_4965.stats.flag & STATISTICS_REPLY_FLG_HT40_MODE_MSK)) { D_TEMP("Running HT40 temperature calibration\n"); @@ -1696,7 +1696,7 @@ static int il4965_hw_get_temperature(struct il_priv *il) * with an updated temperature, use R4 provided to us in the * "initialize" ALIVE response. */ - if (!test_bit(STATUS_TEMPERATURE, &il->status)) + if (!test_bit(S_TEMPERATURE, &il->status)) vt = sign_extend32(R4, 23); else vt = sign_extend32(le32_to_cpu(il->_4965.stats. @@ -1737,7 +1737,7 @@ static int il4965_is_temp_calib_needed(struct il_priv *il) { int temp_diff; - if (!test_bit(STATUS_STATISTICS, &il->status)) { + if (!test_bit(S_STATISTICS, &il->status)) { D_TEMP("Temperature not updated -- no stats.\n"); return 0; } @@ -1784,10 +1784,10 @@ static void il4965_temperature_calib(struct il_priv *il) } il->temperature = temp; - set_bit(STATUS_TEMPERATURE, &il->status); + set_bit(S_TEMPERATURE, &il->status); if (!il->disable_tx_power_cal && - unlikely(!test_bit(STATUS_SCANNING, &il->status)) && + unlikely(!test_bit(S_SCANNING, &il->status)) && il4965_is_temp_calib_needed(il)) queue_work(il->workqueue, &il->txpower_work); } @@ -2179,7 +2179,7 @@ static void il4965_post_associate(struct il_priv *il) if (!vif || !il->is_open) return; - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return; il_scan_cancel_timeout(il, 200); @@ -2254,7 +2254,7 @@ static void il4965_config_ap(struct il_priv *il) lockdep_assert_held(&il->mutex); - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return; /* The following should be done only at AP bring up */ diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index bd222f50d26c..ba7ee4b4528f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -165,7 +165,7 @@ int il_init_geos(struct il_priv *il) if (il->bands[IEEE80211_BAND_2GHZ].n_bitrates || il->bands[IEEE80211_BAND_5GHZ].n_bitrates) { D_INFO("Geography modes already initialized.\n"); - set_bit(STATUS_GEO_CONFIGURED, &il->status); + set_bit(S_GEO_CONFIGURED, &il->status); return 0; } @@ -264,7 +264,7 @@ int il_init_geos(struct il_priv *il) il->bands[IEEE80211_BAND_2GHZ].n_channels, il->bands[IEEE80211_BAND_5GHZ].n_channels); - set_bit(STATUS_GEO_CONFIGURED, &il->status); + set_bit(S_GEO_CONFIGURED, &il->status); return 0; } @@ -277,7 +277,7 @@ void il_free_geos(struct il_priv *il) { kfree(il->ieee_channels); kfree(il->ieee_rates); - clear_bit(STATUS_GEO_CONFIGURED, &il->status); + clear_bit(S_GEO_CONFIGURED, &il->status); } EXPORT_SYMBOL(il_free_geos); @@ -839,10 +839,10 @@ void il_chswitch_done(struct il_priv *il, bool is_success) { struct il_rxon_context *ctx = &il->ctx; - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return; - if (test_and_clear_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status)) + if (test_and_clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) ieee80211_chswitch_done(ctx->vif, is_success); } EXPORT_SYMBOL(il_chswitch_done); @@ -855,7 +855,7 @@ void il_rx_csa(struct il_priv *il, struct il_rx_buf *rxb) struct il_rxon_context *ctx = &il->ctx; struct il_rxon_cmd *rxon = (void *)&ctx->active; - if (!test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status)) + if (!test_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) return; if (!le32_to_cpu(csa->status) && csa->channel == il->switch_channel) { @@ -903,10 +903,10 @@ EXPORT_SYMBOL(il_print_rx_config_cmd); void il_irq_handle_error(struct il_priv *il) { /* Set the FW error flag -- cleared on il_down */ - set_bit(STATUS_FW_ERROR, &il->status); + set_bit(S_FW_ERROR, &il->status); /* Cancel currently queued command. */ - clear_bit(STATUS_HCMD_ACTIVE, &il->status); + clear_bit(S_HCMD_ACTIVE, &il->status); IL_ERR("Loaded firmware version: %s\n", il->hw->wiphy->fw_version); @@ -924,9 +924,9 @@ void il_irq_handle_error(struct il_priv *il) /* Keep the restart process from trying to send host * commands by clearing the INIT status bit */ - clear_bit(STATUS_READY, &il->status); + clear_bit(S_READY, &il->status); - if (!test_bit(STATUS_EXIT_PENDING, &il->status)) { + if (!test_bit(S_EXIT_PENDING, &il->status)) { IL_DBG(IL_DL_FW_ERRORS, "Restarting adapter due to uCode error.\n"); @@ -1127,7 +1127,7 @@ int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) il->tx_power_next = tx_power; /* do not set tx power when scanning or channel changing */ - defer = test_bit(STATUS_SCANNING, &il->status) || + defer = test_bit(S_SCANNING, &il->status) || memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging)); if (defer && !force) { D_INFO("Deferring tx power set\n"); @@ -1678,7 +1678,7 @@ int il_force_reset(struct il_priv *il, bool external) { struct il_force_reset *force_reset; - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return -EINVAL; force_reset = &il->force_reset; @@ -1713,13 +1713,13 @@ int il_force_reset(struct il_priv *il, bool external) IL_ERR("On demand firmware reload\n"); /* Set the FW error flag -- cleared on il_down */ - set_bit(STATUS_FW_ERROR, &il->status); + set_bit(S_FW_ERROR, &il->status); wake_up(&il->wait_command_queue); /* * Keep the restart process from trying to send host * commands by clearing the INIT status bit */ - clear_bit(STATUS_READY, &il->status); + clear_bit(S_READY, &il->status); queue_work(il->workqueue, &il->restart); return 0; @@ -1826,7 +1826,7 @@ void il_bg_watchdog(unsigned long data) int cnt; unsigned long timeout; - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return; timeout = il->cfg->base_params->wd_timeout; @@ -1960,9 +1960,9 @@ int il_pci_resume(struct device *device) hw_rfkill = true; if (hw_rfkill) - set_bit(STATUS_RF_KILL_HW, &il->status); + set_bit(S_RF_KILL_HW, &il->status); else - clear_bit(STATUS_RF_KILL_HW, &il->status); + clear_bit(S_RF_KILL_HW, &il->status); wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rfkill); @@ -1985,7 +1985,7 @@ EXPORT_SYMBOL(il_pm_ops); static void il_update_qos(struct il_priv *il, struct il_rxon_context *ctx) { - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return; if (!ctx->is_active) @@ -2034,7 +2034,7 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) D_MAC80211("enter to channel %d changed 0x%X\n", channel->hw_value, changed); - if (unlikely(test_bit(STATUS_SCANNING, &il->status))) { + if (unlikely(test_bit(S_SCANNING, &il->status))) { scan_active = 1; D_MAC80211("scan active\n"); } @@ -2566,7 +2566,7 @@ unplugged: none: /* re-enable interrupts here since we don't have anything to service. */ /* only Re-enable if disabled by irq */ - if (test_bit(STATUS_INT_ENABLED, &il->status)) + if (test_bit(S_INT_ENABLED, &il->status)) il_enable_interrupts(il); spin_unlock_irqrestore(&il->lock, flags); return IRQ_NONE; diff --git a/drivers/net/wireless/iwlegacy/iwl-core.h b/drivers/net/wireless/iwlegacy/iwl-core.h index 833376171207..5b2883f645ab 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.h +++ b/drivers/net/wireless/iwlegacy/iwl-core.h @@ -533,47 +533,47 @@ void il_free_geos(struct il_priv *il); /*************** DRIVER STATUS FUNCTIONS *****/ -#define STATUS_HCMD_ACTIVE 0 /* host command in progress */ -/* 1 is unused (used to be STATUS_HCMD_SYNC_ACTIVE) */ -#define STATUS_INT_ENABLED 2 -#define STATUS_RF_KILL_HW 3 -#define STATUS_CT_KILL 4 -#define STATUS_INIT 5 -#define STATUS_ALIVE 6 -#define STATUS_READY 7 -#define STATUS_TEMPERATURE 8 -#define STATUS_GEO_CONFIGURED 9 -#define STATUS_EXIT_PENDING 10 -#define STATUS_STATISTICS 12 -#define STATUS_SCANNING 13 -#define STATUS_SCAN_ABORTING 14 -#define STATUS_SCAN_HW 15 -#define STATUS_POWER_PMI 16 -#define STATUS_FW_ERROR 17 -#define STATUS_CHANNEL_SWITCH_PENDING 18 +#define S_HCMD_ACTIVE 0 /* host command in progress */ +/* 1 is unused (used to be S_HCMD_SYNC_ACTIVE) */ +#define S_INT_ENABLED 2 +#define S_RF_KILL_HW 3 +#define S_CT_KILL 4 +#define S_INIT 5 +#define S_ALIVE 6 +#define S_READY 7 +#define S_TEMPERATURE 8 +#define S_GEO_CONFIGURED 9 +#define S_EXIT_PENDING 10 +#define S_STATISTICS 12 +#define S_SCANNING 13 +#define S_SCAN_ABORTING 14 +#define S_SCAN_HW 15 +#define S_POWER_PMI 16 +#define S_FW_ERROR 17 +#define S_CHANNEL_SWITCH_PENDING 18 static inline int il_is_ready(struct il_priv *il) { /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are * set but EXIT_PENDING is not */ - return test_bit(STATUS_READY, &il->status) && - test_bit(STATUS_GEO_CONFIGURED, &il->status) && - !test_bit(STATUS_EXIT_PENDING, &il->status); + return test_bit(S_READY, &il->status) && + test_bit(S_GEO_CONFIGURED, &il->status) && + !test_bit(S_EXIT_PENDING, &il->status); } static inline int il_is_alive(struct il_priv *il) { - return test_bit(STATUS_ALIVE, &il->status); + return test_bit(S_ALIVE, &il->status); } static inline int il_is_init(struct il_priv *il) { - return test_bit(STATUS_INIT, &il->status); + return test_bit(S_INIT, &il->status); } static inline int il_is_rfkill_hw(struct il_priv *il) { - return test_bit(STATUS_RF_KILL_HW, &il->status); + return test_bit(S_RF_KILL_HW, &il->status); } static inline int il_is_rfkill(struct il_priv *il) @@ -583,7 +583,7 @@ static inline int il_is_rfkill(struct il_priv *il) static inline int il_is_ctkill(struct il_priv *il) { - return test_bit(STATUS_CT_KILL, &il->status); + return test_bit(S_CT_KILL, &il->status); } static inline int il_is_ready_rf(struct il_priv *il) diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index 8448db7d8f39..114922bc83d2 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -402,7 +402,7 @@ il_dbgfs_channels_read(struct file *file, char __user *user_buf, char *buf; ssize_t ret; - if (!test_bit(STATUS_GEO_CONFIGURED, &il->status)) + if (!test_bit(S_GEO_CONFIGURED, &il->status)) return -EAGAIN; buf = kzalloc(bufsz, GFP_KERNEL); @@ -471,38 +471,38 @@ static ssize_t il_dbgfs_status_read(struct file *file, int pos = 0; const size_t bufsz = sizeof(buf); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_HCMD_ACTIVE:\t %d\n", - test_bit(STATUS_HCMD_ACTIVE, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INT_ENABLED:\t %d\n", - test_bit(STATUS_INT_ENABLED, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_RF_KILL_HW:\t %d\n", - test_bit(STATUS_RF_KILL_HW, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_CT_KILL:\t\t %d\n", - test_bit(STATUS_CT_KILL, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_INIT:\t\t %d\n", - test_bit(STATUS_INIT, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_ALIVE:\t\t %d\n", - test_bit(STATUS_ALIVE, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_READY:\t\t %d\n", - test_bit(STATUS_READY, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_TEMPERATURE:\t %d\n", - test_bit(STATUS_TEMPERATURE, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_GEO_CONFIGURED:\t %d\n", - test_bit(STATUS_GEO_CONFIGURED, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_EXIT_PENDING:\t %d\n", - test_bit(STATUS_EXIT_PENDING, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_STATISTICS:\t %d\n", - test_bit(STATUS_STATISTICS, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCANNING:\t %d\n", - test_bit(STATUS_SCANNING, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_ABORTING:\t %d\n", - test_bit(STATUS_SCAN_ABORTING, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_SCAN_HW:\t\t %d\n", - test_bit(STATUS_SCAN_HW, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_POWER_PMI:\t %d\n", - test_bit(STATUS_POWER_PMI, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "STATUS_FW_ERROR:\t %d\n", - test_bit(STATUS_FW_ERROR, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_HCMD_ACTIVE:\t %d\n", + test_bit(S_HCMD_ACTIVE, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_INT_ENABLED:\t %d\n", + test_bit(S_INT_ENABLED, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_RF_KILL_HW:\t %d\n", + test_bit(S_RF_KILL_HW, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_CT_KILL:\t\t %d\n", + test_bit(S_CT_KILL, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_INIT:\t\t %d\n", + test_bit(S_INIT, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_ALIVE:\t\t %d\n", + test_bit(S_ALIVE, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_READY:\t\t %d\n", + test_bit(S_READY, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_TEMPERATURE:\t %d\n", + test_bit(S_TEMPERATURE, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_GEO_CONFIGURED:\t %d\n", + test_bit(S_GEO_CONFIGURED, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_EXIT_PENDING:\t %d\n", + test_bit(S_EXIT_PENDING, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_STATISTICS:\t %d\n", + test_bit(S_STATISTICS, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_SCANNING:\t %d\n", + test_bit(S_SCANNING, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_SCAN_ABORTING:\t %d\n", + test_bit(S_SCAN_ABORTING, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_SCAN_HW:\t\t %d\n", + test_bit(S_SCAN_HW, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_POWER_PMI:\t %d\n", + test_bit(S_POWER_PMI, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_FW_ERROR:\t %d\n", + test_bit(S_FW_ERROR, &il->status)); return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } diff --git a/drivers/net/wireless/iwlegacy/iwl-hcmd.c b/drivers/net/wireless/iwlegacy/iwl-hcmd.c index 0b11f2f549ca..4762a0e8c88f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-hcmd.c +++ b/drivers/net/wireless/iwlegacy/iwl-hcmd.c @@ -128,7 +128,7 @@ il_send_cmd_async(struct il_priv *il, struct il_host_cmd *cmd) if (!cmd->callback) cmd->callback = il_generic_cmd_callback; - if (test_bit(STATUS_EXIT_PENDING, &il->status)) + if (test_bit(S_EXIT_PENDING, &il->status)) return -EBUSY; ret = il_enqueue_hcmd(il, cmd); @@ -155,7 +155,7 @@ int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) D_INFO("Attempting to send sync command %s\n", il_get_cmd_string(cmd->id)); - set_bit(STATUS_HCMD_ACTIVE, &il->status); + set_bit(S_HCMD_ACTIVE, &il->status); D_INFO("Setting HCMD_ACTIVE for command %s\n", il_get_cmd_string(cmd->id)); @@ -168,16 +168,16 @@ int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) } ret = wait_event_timeout(il->wait_command_queue, - !test_bit(STATUS_HCMD_ACTIVE, &il->status), + !test_bit(S_HCMD_ACTIVE, &il->status), HOST_COMPLETE_TIMEOUT); if (!ret) { - if (test_bit(STATUS_HCMD_ACTIVE, &il->status)) { + if (test_bit(S_HCMD_ACTIVE, &il->status)) { IL_ERR( "Error sending %s: time out after %dms.\n", il_get_cmd_string(cmd->id), jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); - clear_bit(STATUS_HCMD_ACTIVE, &il->status); + clear_bit(S_HCMD_ACTIVE, &il->status); D_INFO( "Clearing HCMD_ACTIVE for command %s\n", il_get_cmd_string(cmd->id)); @@ -186,13 +186,13 @@ int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) } } - if (test_bit(STATUS_RF_KILL_HW, &il->status)) { + if (test_bit(S_RF_KILL_HW, &il->status)) { IL_ERR("Command %s aborted: RF KILL Switch\n", il_get_cmd_string(cmd->id)); ret = -ECANCELED; goto fail; } - if (test_bit(STATUS_FW_ERROR, &il->status)) { + if (test_bit(S_FW_ERROR, &il->status)) { IL_ERR("Command %s failed: FW Error\n", il_get_cmd_string(cmd->id)); ret = -EIO; diff --git a/drivers/net/wireless/iwlegacy/iwl-helpers.h b/drivers/net/wireless/iwlegacy/iwl-helpers.h index 5fcb23e8f5a6..0e64003274f4 100644 --- a/drivers/net/wireless/iwlegacy/iwl-helpers.h +++ b/drivers/net/wireless/iwlegacy/iwl-helpers.h @@ -146,7 +146,7 @@ static inline void il_stop_queue(struct il_priv *il, static inline void il_disable_interrupts(struct il_priv *il) { - clear_bit(STATUS_INT_ENABLED, &il->status); + clear_bit(S_INT_ENABLED, &il->status); /* disable interrupts from uCode/NIC to host */ _il_wr(il, CSR_INT_MASK, 0x00000000); @@ -167,7 +167,7 @@ static inline void il_enable_rfkill_int(struct il_priv *il) static inline void il_enable_interrupts(struct il_priv *il) { D_ISR("Enabling interrupts\n"); - set_bit(STATUS_INT_ENABLED, &il->status); + set_bit(S_INT_ENABLED, &il->status); _il_wr(il, CSR_INT_MASK, il->inta_mask); } diff --git a/drivers/net/wireless/iwlegacy/iwl-led.c b/drivers/net/wireless/iwlegacy/iwl-led.c index 3652cdc1770e..a840c2e54764 100644 --- a/drivers/net/wireless/iwlegacy/iwl-led.c +++ b/drivers/net/wireless/iwlegacy/iwl-led.c @@ -107,7 +107,7 @@ static int il_led_cmd(struct il_priv *il, }; int ret; - if (!test_bit(STATUS_READY, &il->status)) + if (!test_bit(S_READY, &il->status)) return -EBUSY; if (il->blink_on == on && il->blink_off == off) diff --git a/drivers/net/wireless/iwlegacy/iwl-power.c b/drivers/net/wireless/iwlegacy/iwl-power.c index 051623ab1147..c66a0f77dc32 100644 --- a/drivers/net/wireless/iwlegacy/iwl-power.c +++ b/drivers/net/wireless/iwlegacy/iwl-power.c @@ -113,18 +113,18 @@ il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, /* scan complete use sleep_power_next, need to be updated */ memcpy(&il->power_data.sleep_cmd_next, cmd, sizeof(*cmd)); - if (test_bit(STATUS_SCANNING, &il->status) && !force) { + if (test_bit(S_SCANNING, &il->status) && !force) { D_INFO("Defer power set mode while scanning\n"); return 0; } if (cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK) - set_bit(STATUS_POWER_PMI, &il->status); + set_bit(S_POWER_PMI, &il->status); ret = il_set_power(il, cmd); if (!ret) { if (!(cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK)) - clear_bit(STATUS_POWER_PMI, &il->status); + clear_bit(S_POWER_PMI, &il->status); if (il->cfg->ops->lib->update_chain_flags && update_chains) il->cfg->ops->lib->update_chain_flags(il); diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c index 58d19c155a3d..76f2361031bb 100644 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -137,7 +137,7 @@ il_rx_queue_update_write_ptr(struct il_priv *il, goto exit_unlock; /* If power-saving is in use, make sure device is awake */ - if (test_bit(STATUS_POWER_PMI, &il->status)) { + if (test_bit(S_POWER_PMI, &il->status)) { reg = _il_rd(il, CSR_UCODE_DRV_GP1); if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index 18226d1988a7..6d20f2b64c3e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -66,11 +66,11 @@ static int il_send_scan_abort(struct il_priv *il) /* Exit instantly with error when device is not ready * to receive scan abort command or it does not perform * hardware scan currently */ - if (!test_bit(STATUS_READY, &il->status) || - !test_bit(STATUS_GEO_CONFIGURED, &il->status) || - !test_bit(STATUS_SCAN_HW, &il->status) || - test_bit(STATUS_FW_ERROR, &il->status) || - test_bit(STATUS_EXIT_PENDING, &il->status)) + if (!test_bit(S_READY, &il->status) || + !test_bit(S_GEO_CONFIGURED, &il->status) || + !test_bit(S_SCAN_HW, &il->status) || + test_bit(S_FW_ERROR, &il->status) || + test_bit(S_EXIT_PENDING, &il->status)) return -EIO; ret = il_send_cmd_sync(il, &cmd); @@ -109,15 +109,15 @@ void il_force_scan_end(struct il_priv *il) { lockdep_assert_held(&il->mutex); - if (!test_bit(STATUS_SCANNING, &il->status)) { + if (!test_bit(S_SCANNING, &il->status)) { D_SCAN("Forcing scan end while not scanning\n"); return; } D_SCAN("Forcing scan end\n"); - clear_bit(STATUS_SCANNING, &il->status); - clear_bit(STATUS_SCAN_HW, &il->status); - clear_bit(STATUS_SCAN_ABORTING, &il->status); + clear_bit(S_SCANNING, &il->status); + clear_bit(S_SCAN_HW, &il->status); + clear_bit(S_SCAN_ABORTING, &il->status); il_complete_scan(il, true); } @@ -127,12 +127,12 @@ static void il_do_scan_abort(struct il_priv *il) lockdep_assert_held(&il->mutex); - if (!test_bit(STATUS_SCANNING, &il->status)) { + if (!test_bit(S_SCANNING, &il->status)) { D_SCAN("Not performing scan to abort\n"); return; } - if (test_and_set_bit(STATUS_SCAN_ABORTING, &il->status)) { + if (test_and_set_bit(S_SCAN_ABORTING, &il->status)) { D_SCAN("Scan abort in progress\n"); return; } @@ -172,12 +172,12 @@ int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms) il_do_scan_abort(il); while (time_before_eq(jiffies, timeout)) { - if (!test_bit(STATUS_SCAN_HW, &il->status)) + if (!test_bit(S_SCAN_HW, &il->status)) break; msleep(20); } - return test_bit(STATUS_SCAN_HW, &il->status); + return test_bit(S_SCAN_HW, &il->status); } EXPORT_SYMBOL(il_scan_cancel_timeout); @@ -251,7 +251,7 @@ static void il_rx_scan_complete_notif(struct il_priv *il, scan_notif->tsf_high, scan_notif->status); /* The HW is no longer scanning */ - clear_bit(STATUS_SCAN_HW, &il->status); + clear_bit(S_SCAN_HW, &il->status); D_SCAN("Scan on %sGHz took %dms\n", (il->scan_band == IEEE80211_BAND_2GHZ) ? "2.4" : "5.2", @@ -341,25 +341,25 @@ static int il_scan_initiate(struct il_priv *il, return -EIO; } - if (test_bit(STATUS_SCAN_HW, &il->status)) { + if (test_bit(S_SCAN_HW, &il->status)) { D_SCAN( "Multiple concurrent scan requests in parallel.\n"); return -EBUSY; } - if (test_bit(STATUS_SCAN_ABORTING, &il->status)) { + if (test_bit(S_SCAN_ABORTING, &il->status)) { D_SCAN("Scan request while abort pending.\n"); return -EBUSY; } D_SCAN("Starting scan...\n"); - set_bit(STATUS_SCANNING, &il->status); + set_bit(S_SCANNING, &il->status); il->scan_start = jiffies; ret = il->cfg->ops->utils->request_scan(il, vif); if (ret) { - clear_bit(STATUS_SCANNING, &il->status); + clear_bit(S_SCANNING, &il->status); return ret; } @@ -383,7 +383,7 @@ int il_mac_hw_scan(struct ieee80211_hw *hw, mutex_lock(&il->mutex); - if (test_bit(STATUS_SCANNING, &il->status)) { + if (test_bit(S_SCANNING, &il->status)) { D_SCAN("Scan already in progress.\n"); ret = -EAGAIN; goto out_unlock; @@ -494,11 +494,11 @@ static void il_bg_scan_completed(struct work_struct *work) mutex_lock(&il->mutex); - aborted = test_and_clear_bit(STATUS_SCAN_ABORTING, &il->status); + aborted = test_and_clear_bit(S_SCAN_ABORTING, &il->status); if (aborted) D_SCAN("Aborted scan completed.\n"); - if (!test_and_clear_bit(STATUS_SCANNING, &il->status)) { + if (!test_and_clear_bit(S_SCANNING, &il->status)) { D_SCAN("Scan already completed.\n"); goto out_settings; } diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index e46e58829216..3f97d09fa00a 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -51,7 +51,7 @@ il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq) return; /* if we're trying to save power */ - if (test_bit(STATUS_POWER_PMI, &il->status)) { + if (test_bit(S_POWER_PMI, &il->status)) { /* wake up nic if it's powered down ... * uCode will wake up, and interrupt us again, so next * time we'll skip this part. */ @@ -641,7 +641,7 @@ il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb) il_hcmd_queue_reclaim(il, txq_id, idx, cmd_idx); if (!(meta->flags & CMD_ASYNC)) { - clear_bit(STATUS_HCMD_ACTIVE, &il->status); + clear_bit(S_HCMD_ACTIVE, &il->status); D_INFO("Clearing HCMD_ACTIVE for command %s\n", il_get_cmd_string(cmd->hdr.cmd)); wake_up(&il->wait_command_queue); -- cgit v1.2.3 From db7746f78cab25ee39dd20f61d9b2e6b5993d8fa Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 13:11:50 +0100 Subject: iwlegacy: s/STATISTICS/STATS/ Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/3945-debug.c | 6 ++--- drivers/net/wireless/iwlegacy/3945-mac.c | 6 ++--- drivers/net/wireless/iwlegacy/3945.c | 2 +- drivers/net/wireless/iwlegacy/4965-calib.c | 2 +- drivers/net/wireless/iwlegacy/4965-debug.c | 6 ++--- drivers/net/wireless/iwlegacy/4965-mac.c | 18 ++++++------- drivers/net/wireless/iwlegacy/4965.c | 4 +-- drivers/net/wireless/iwlegacy/4965.h | 4 +-- drivers/net/wireless/iwlegacy/iwl-commands.h | 38 ++++++++++++++-------------- drivers/net/wireless/iwlegacy/iwl-core.c | 4 +-- drivers/net/wireless/iwlegacy/iwl-core.h | 2 +- drivers/net/wireless/iwlegacy/iwl-debugfs.c | 4 +-- drivers/net/wireless/iwlegacy/iwl-hcmd.c | 4 +-- 13 files changed, 50 insertions(+), 50 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/3945-debug.c b/drivers/net/wireless/iwlegacy/3945-debug.c index 9c837c3c4f04..fc2d651b43a3 100644 --- a/drivers/net/wireless/iwlegacy/3945-debug.c +++ b/drivers/net/wireless/iwlegacy/3945-debug.c @@ -37,16 +37,16 @@ static int il3945_stats_flag(struct il_priv *il, char *buf, int bufsz) p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", le32_to_cpu(il->_3945.stats.flag)); if (le32_to_cpu(il->_3945.stats.flag) & - UCODE_STATISTICS_CLEAR_MSK) + UCODE_STATS_CLEAR_MSK) p += scnprintf(buf + p, bufsz - p, "\tStatistics have been cleared\n"); p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n", (le32_to_cpu(il->_3945.stats.flag) & - UCODE_STATISTICS_FREQUENCY_MSK) + UCODE_STATS_FREQUENCY_MSK) ? "2.4 GHz" : "5.2 GHz"); p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n", (le32_to_cpu(il->_3945.stats.flag) & - UCODE_STATISTICS_NARROW_BAND_MSK) + UCODE_STATS_NARROW_BAND_MSK) ? "enabled" : "disabled"); return p; } diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index f69211ee5fe7..2ff807515212 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -869,8 +869,8 @@ static void il3945_setup_rx_handlers(struct il_priv *il) * stats request from the host as well as for the periodic * stats notifications (after received beacons) from the uCode. */ - il->rx_handlers[REPLY_STATISTICS_CMD] = il3945_reply_stats; - il->rx_handlers[STATISTICS_NOTIFICATION] = il3945_hw_rx_stats; + il->rx_handlers[REPLY_STATS_CMD] = il3945_reply_stats; + il->rx_handlers[STATS_NOTIFICATION] = il3945_hw_rx_stats; il_setup_rx_scan_handlers(il); il->rx_handlers[CARD_STATE_NOTIFICATION] = il3945_rx_card_state_notif; @@ -1253,7 +1253,7 @@ static void il3945_rx_handle(struct il_priv *il) * Ucode should set SEQ_RX_FRAME bit if ucode-originated, * but apparently a few don't get set; catch them here. */ reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) && - pkt->hdr.cmd != STATISTICS_NOTIFICATION && + pkt->hdr.cmd != STATS_NOTIFICATION && pkt->hdr.cmd != REPLY_TX; /* Based on type of command response or notification, diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 8ebd576dfe62..82534a20ee8e 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -432,7 +432,7 @@ void il3945_reply_stats(struct il_priv *il, struct il_rx_pkt *pkt = rxb_addr(rxb); __le32 *flag = (__le32 *)&pkt->u.raw; - if (le32_to_cpu(*flag) & UCODE_STATISTICS_CLEAR_MSK) { + if (le32_to_cpu(*flag) & UCODE_STATS_CLEAR_MSK) { #ifdef CONFIG_IWLEGACY_DEBUGFS memset(&il->_3945.accum_stats, 0, sizeof(struct il3945_notif_stats)); diff --git a/drivers/net/wireless/iwlegacy/4965-calib.c b/drivers/net/wireless/iwlegacy/4965-calib.c index 1d0502ecb41d..cd61050160ac 100644 --- a/drivers/net/wireless/iwlegacy/4965-calib.c +++ b/drivers/net/wireless/iwlegacy/4965-calib.c @@ -853,7 +853,7 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) stat_band24 = !!(((struct il_notif_stats *) stat_resp)->flag & - STATISTICS_REPLY_FLG_BAND_24G_MSK); + STATS_REPLY_FLG_BAND_24G_MSK); stat_chnum = le32_to_cpu(((struct il_notif_stats *) stat_resp)->flag) >> 16; diff --git a/drivers/net/wireless/iwlegacy/4965-debug.c b/drivers/net/wireless/iwlegacy/4965-debug.c index 825d0aa707e0..ad9c6d0a560e 100644 --- a/drivers/net/wireless/iwlegacy/4965-debug.c +++ b/drivers/net/wireless/iwlegacy/4965-debug.c @@ -42,14 +42,14 @@ static int il4965_stats_flag(struct il_priv *il, char *buf, int bufsz) flag = le32_to_cpu(il->_4965.stats.flag); p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag); - if (flag & UCODE_STATISTICS_CLEAR_MSK) + if (flag & UCODE_STATS_CLEAR_MSK) p += scnprintf(buf + p, bufsz - p, "\tStatistics have been cleared\n"); p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n", - (flag & UCODE_STATISTICS_FREQUENCY_MSK) + (flag & UCODE_STATS_FREQUENCY_MSK) ? "2.4 GHz" : "5.2 GHz"); p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n", - (flag & UCODE_STATISTICS_NARROW_BAND_MSK) + (flag & UCODE_STATS_NARROW_BAND_MSK) ? "enabled" : "disabled"); return p; diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index c4198bd42889..c3f8137642c3 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -1367,9 +1367,9 @@ void il4965_rx_stats(struct il_priv *il, change = ((il->_4965.stats.general.common.temperature != pkt->u.stats.general.common.temperature) || ((il->_4965.stats.flag & - STATISTICS_REPLY_FLG_HT40_MODE_MSK) != + STATS_REPLY_FLG_HT40_MODE_MSK) != (pkt->u.stats.flag & - STATISTICS_REPLY_FLG_HT40_MODE_MSK))); + STATS_REPLY_FLG_HT40_MODE_MSK))); #ifdef CONFIG_IWLEGACY_DEBUGFS il4965_accumulative_stats(il, (__le32 *)&pkt->u.stats); #endif @@ -1378,7 +1378,7 @@ void il4965_rx_stats(struct il_priv *il, memcpy(&il->_4965.stats, &pkt->u.stats, sizeof(il->_4965.stats)); - set_bit(S_STATISTICS, &il->status); + set_bit(S_STATS, &il->status); /* Reschedule the stats timer to occur in * REG_RECALIB_PERIOD seconds to ensure we get a @@ -1388,7 +1388,7 @@ void il4965_rx_stats(struct il_priv *il, msecs_to_jiffies(REG_RECALIB_PERIOD * 1000)); if (unlikely(!test_bit(S_SCANNING, &il->status)) && - (pkt->hdr.cmd == STATISTICS_NOTIFICATION)) { + (pkt->hdr.cmd == STATS_NOTIFICATION)) { il4965_rx_calc_noise(il); queue_work(il->workqueue, &il->run_time_calib_work); } @@ -1401,7 +1401,7 @@ void il4965_reply_stats(struct il_priv *il, { struct il_rx_pkt *pkt = rxb_addr(rxb); - if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATISTICS_CLEAR_MSK) { + if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATS_CLEAR_MSK) { #ifdef CONFIG_IWLEGACY_DEBUGFS memset(&il->_4965.accum_stats, 0, sizeof(struct il_notif_stats)); @@ -3801,7 +3801,7 @@ static void il4965_rx_reply_alive(struct il_priv *il, * This callback is provided in order to send a stats request. * * This timer function is continually reset to execute within - * REG_RECALIB_PERIOD seconds since the last STATISTICS_NOTIFICATION + * REG_RECALIB_PERIOD seconds since the last STATS_NOTIFICATION * was received. We need to ensure we receive the stats in order * to update the temperature used for calibrating the TXPOWER. */ @@ -3936,8 +3936,8 @@ static void il4965_setup_rx_handlers(struct il_priv *il) * stats request from the host as well as for the periodic * stats notifications (after received beacons) from the uCode. */ - il->rx_handlers[REPLY_STATISTICS_CMD] = il4965_reply_stats; - il->rx_handlers[STATISTICS_NOTIFICATION] = il4965_rx_stats; + il->rx_handlers[REPLY_STATS_CMD] = il4965_reply_stats; + il->rx_handlers[STATS_NOTIFICATION] = il4965_rx_stats; il_setup_rx_scan_handlers(il); @@ -4023,7 +4023,7 @@ void il4965_rx_handle(struct il_priv *il) (pkt->hdr.cmd != REPLY_RX) && (pkt->hdr.cmd != REPLY_RX_MPDU_CMD) && (pkt->hdr.cmd != REPLY_COMPRESSED_BA) && - (pkt->hdr.cmd != STATISTICS_NOTIFICATION) && + (pkt->hdr.cmd != STATS_NOTIFICATION) && (pkt->hdr.cmd != REPLY_TX); /* Based on type of command response or notification, diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 1efe824963a8..361a1ca39896 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -1675,7 +1675,7 @@ static int il4965_hw_get_temperature(struct il_priv *il) if (test_bit(S_TEMPERATURE, &il->status) && (il->_4965.stats.flag & - STATISTICS_REPLY_FLG_HT40_MODE_MSK)) { + STATS_REPLY_FLG_HT40_MODE_MSK)) { D_TEMP("Running HT40 temperature calibration\n"); R1 = (s32)le32_to_cpu(il->card_alive_init.therm_r1[1]); R2 = (s32)le32_to_cpu(il->card_alive_init.therm_r2[1]); @@ -1737,7 +1737,7 @@ static int il4965_is_temp_calib_needed(struct il_priv *il) { int temp_diff; - if (!test_bit(S_STATISTICS, &il->status)) { + if (!test_bit(S_STATS, &il->status)) { D_TEMP("Temperature not updated -- no stats.\n"); return 0; } diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h index b1a01c9bbbc8..85c3a49d7e14 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -278,8 +278,8 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * uCode provides all 4 values to the driver via the "initialize alive" * notification (see struct il4965_init_alive_resp). After the runtime uCode * image loads, uCode updates the R4 value via stats notifications - * (see STATISTICS_NOTIFICATION), which occur after each received beacon - * when associated, or can be requested via REPLY_STATISTICS_CMD. + * (see STATS_NOTIFICATION), which occur after each received beacon + * when associated, or can be requested via REPLY_STATS_CMD. * * NOTE: uCode provides the R4 value as a 23-bit signed value. Driver * must sign-extend to 32 bits before applying formula below. diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h index 55822da4b162..1a6ca36b4c78 100644 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ b/drivers/net/wireless/iwlegacy/iwl-commands.h @@ -136,8 +136,8 @@ enum { REPLY_BT_CONFIG = 0x9b, /* Statistics */ - REPLY_STATISTICS_CMD = 0x9c, - STATISTICS_NOTIFICATION = 0x9d, + REPLY_STATS_CMD = 0x9c, + STATS_NOTIFICATION = 0x9d, /* RF-KILL commands and notifications */ CARD_STATE_NOTIFICATION = 0xa1, @@ -2626,7 +2626,7 @@ struct il_scanstart_notification { #define IL_PROBE_STATUS_FAIL_TTL BIT(1) #define IL_PROBE_STATUS_FAIL_BT BIT(2) -#define NUMBER_OF_STATISTICS 1 /* first __le32 is good CRC */ +#define NUMBER_OF_STATS 1 /* first __le32 is good CRC */ /* * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command) */ @@ -2637,7 +2637,7 @@ struct il_scanresults_notification { u8 num_probe_not_sent; /* not enough time to send */ __le32 tsf_low; __le32 tsf_high; - __le32 stats[NUMBER_OF_STATISTICS]; + __le32 stats[NUMBER_OF_STATS]; } __packed; /* @@ -2958,24 +2958,24 @@ struct stats_general { __le32 reserved3; } __packed; -#define UCODE_STATISTICS_CLEAR_MSK (0x1 << 0) -#define UCODE_STATISTICS_FREQUENCY_MSK (0x1 << 1) -#define UCODE_STATISTICS_NARROW_BAND_MSK (0x1 << 2) +#define UCODE_STATS_CLEAR_MSK (0x1 << 0) +#define UCODE_STATS_FREQUENCY_MSK (0x1 << 1) +#define UCODE_STATS_NARROW_BAND_MSK (0x1 << 2) /* - * REPLY_STATISTICS_CMD = 0x9c, + * REPLY_STATS_CMD = 0x9c, * all devices identical. * * This command triggers an immediate response containing uCode stats. - * The response is in the same format as STATISTICS_NOTIFICATION 0x9d, below. + * The response is in the same format as STATS_NOTIFICATION 0x9d, below. * * If the CLEAR_STATS configuration flag is set, uCode will clear its * internal copy of the stats (counters) after issuing the response. - * This flag does not affect STATISTICS_NOTIFICATIONs after beacons (see below). + * This flag does not affect STATS_NOTIFICATIONs after beacons (see below). * * If the DISABLE_NOTIF configuration flag is set, uCode will not issue - * STATISTICS_NOTIFICATIONs after received beacons (see below). This flag - * does not affect the response to the REPLY_STATISTICS_CMD 0x9c itself. + * STATS_NOTIFICATIONs after received beacons (see below). This flag + * does not affect the response to the REPLY_STATS_CMD 0x9c itself. */ #define IL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1) /* see above */ #define IL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */ @@ -2984,22 +2984,22 @@ struct il_stats_cmd { } __packed; /* - * STATISTICS_NOTIFICATION = 0x9d (notification only, not a command) + * STATS_NOTIFICATION = 0x9d (notification only, not a command) * * By default, uCode issues this notification after receiving a beacon * while associated. To disable this behavior, set DISABLE_NOTIF flag in the - * REPLY_STATISTICS_CMD 0x9c, above. + * REPLY_STATS_CMD 0x9c, above. * * Statistics counters continue to increment beacon after beacon, but are - * cleared when changing channels or when driver issues REPLY_STATISTICS_CMD + * cleared when changing channels or when driver issues REPLY_STATS_CMD * 0x9c with CLEAR_STATS bit set (see above). * * uCode also issues this notification during scans. uCode clears stats * appropriately so that each notification contains stats for only the * one channel that has just been scanned. */ -#define STATISTICS_REPLY_FLG_BAND_24G_MSK cpu_to_le32(0x2) -#define STATISTICS_REPLY_FLG_HT40_MODE_MSK cpu_to_le32(0x8) +#define STATS_REPLY_FLG_BAND_24G_MSK cpu_to_le32(0x2) +#define STATS_REPLY_FLG_HT40_MODE_MSK cpu_to_le32(0x8) struct il3945_notif_stats { __le32 flag; @@ -3076,7 +3076,7 @@ struct il_missed_beacon_notif { * time listening, not transmitting). Driver must adjust sensitivity so that * the ratio of actual false alarms to actual Rx time falls within this range. * - * While associated, uCode delivers STATISTICS_NOTIFICATIONs after each + * While associated, uCode delivers STATS_NOTIFICATIONs after each * received beacon. These provide information to the driver to analyze the * sensitivity. Don't analyze stats that come in from scanning, or any * other non-associated-network source. Pertinent stats include: @@ -3255,7 +3255,7 @@ struct il_sensitivity_cmd { * This command sets the relative gains of 4965 device's 3 radio receiver chains. * * After the first association, driver should accumulate signal and noise - * stats from the STATISTICS_NOTIFICATIONs that follow the first 20 + * stats from the STATS_NOTIFICATIONs that follow the first 20 * beacons from the associated network (don't collect stats that come * in from scanning, or any other non-network source). * diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index ba7ee4b4528f..e6c7d5f77e78 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -1179,11 +1179,11 @@ int il_send_stats_request(struct il_priv *il, u8 flags, bool clear) }; if (flags & CMD_ASYNC) - return il_send_cmd_pdu_async(il, REPLY_STATISTICS_CMD, + return il_send_cmd_pdu_async(il, REPLY_STATS_CMD, sizeof(struct il_stats_cmd), &stats_cmd, NULL); else - return il_send_cmd_pdu(il, REPLY_STATISTICS_CMD, + return il_send_cmd_pdu(il, REPLY_STATS_CMD, sizeof(struct il_stats_cmd), &stats_cmd); } diff --git a/drivers/net/wireless/iwlegacy/iwl-core.h b/drivers/net/wireless/iwlegacy/iwl-core.h index 5b2883f645ab..e275ffc9f7e0 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.h +++ b/drivers/net/wireless/iwlegacy/iwl-core.h @@ -544,7 +544,7 @@ void il_free_geos(struct il_priv *il); #define S_TEMPERATURE 8 #define S_GEO_CONFIGURED 9 #define S_EXIT_PENDING 10 -#define S_STATISTICS 12 +#define S_STATS 12 #define S_SCANNING 13 #define S_SCAN_ABORTING 14 #define S_SCAN_HW 15 diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index 114922bc83d2..b9888ac0f518 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -491,8 +491,8 @@ static ssize_t il_dbgfs_status_read(struct file *file, test_bit(S_GEO_CONFIGURED, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "S_EXIT_PENDING:\t %d\n", test_bit(S_EXIT_PENDING, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_STATISTICS:\t %d\n", - test_bit(S_STATISTICS, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_STATS:\t %d\n", + test_bit(S_STATS, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "S_SCANNING:\t %d\n", test_bit(S_SCANNING, &il->status)); pos += scnprintf(buf + pos, bufsz - pos, "S_SCAN_ABORTING:\t %d\n", diff --git a/drivers/net/wireless/iwlegacy/iwl-hcmd.c b/drivers/net/wireless/iwlegacy/iwl-hcmd.c index 4762a0e8c88f..19a59558e247 100644 --- a/drivers/net/wireless/iwlegacy/iwl-hcmd.c +++ b/drivers/net/wireless/iwlegacy/iwl-hcmd.c @@ -70,8 +70,8 @@ const char *il_get_cmd_string(u8 cmd) IL_CMD(REPLY_TX_BEACON); IL_CMD(REPLY_TX_PWR_TBL_CMD); IL_CMD(REPLY_BT_CONFIG); - IL_CMD(REPLY_STATISTICS_CMD); - IL_CMD(STATISTICS_NOTIFICATION); + IL_CMD(REPLY_STATS_CMD); + IL_CMD(STATS_NOTIFICATION); IL_CMD(CARD_STATE_NOTIFICATION); IL_CMD(MISSED_BEACONS_NOTIFICATION); IL_CMD(REPLY_CT_KILL_CONFIG_CMD); -- cgit v1.2.3 From 4d69c7521a90cba945b4720672b4511b1e541189 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 30 Aug 2011 15:26:35 +0200 Subject: iwlegacy: rename REPLY_ to N_ or C_ Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/3945-mac.c | 62 +++---- drivers/net/wireless/iwlegacy/3945.c | 24 +-- drivers/net/wireless/iwlegacy/4965-calib.c | 12 +- drivers/net/wireless/iwlegacy/4965-mac.c | 96 +++++----- drivers/net/wireless/iwlegacy/4965-rs.c | 4 +- drivers/net/wireless/iwlegacy/4965.c | 24 +-- drivers/net/wireless/iwlegacy/4965.h | 4 +- drivers/net/wireless/iwlegacy/iwl-commands.h | 260 +++++++++++++-------------- drivers/net/wireless/iwlegacy/iwl-core.c | 6 +- drivers/net/wireless/iwlegacy/iwl-debugfs.c | 2 +- drivers/net/wireless/iwlegacy/iwl-dev.h | 8 +- drivers/net/wireless/iwlegacy/iwl-hcmd.c | 86 ++++----- drivers/net/wireless/iwlegacy/iwl-power.c | 2 +- drivers/net/wireless/iwlegacy/iwl-prph.h | 2 +- drivers/net/wireless/iwlegacy/iwl-scan.c | 18 +- drivers/net/wireless/iwlegacy/iwl-sta.c | 20 +-- drivers/net/wireless/iwlegacy/iwl-tx.c | 4 +- 17 files changed, 317 insertions(+), 317 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 2ff807515212..65cab84661ef 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -348,7 +348,7 @@ static int il3945_send_beacon_cmd(struct il_priv *il) frame_size = il3945_hw_get_beacon_cmd(il, frame, rate); - rc = il_send_cmd_pdu(il, REPLY_TX_BEACON, frame_size, + rc = il_send_cmd_pdu(il, C_TX_BEACON, frame_size, &frame->u.cmd[0]); il3945_free_frame(il, frame); @@ -406,7 +406,7 @@ static void il3945_build_tx_cmd_hwcrypto(struct il_priv *il, } /* - * handle build REPLY_TX command notification. + * handle build C_TX command notification. */ static void il3945_build_tx_cmd_basic(struct il_priv *il, struct il_device_cmd *cmd, @@ -460,7 +460,7 @@ static void il3945_build_tx_cmd_basic(struct il_priv *il, } /* - * start REPLY_TX command process + * start C_TX command process */ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) { @@ -560,7 +560,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) * after Tx, uCode's Tx response will return this value so driver can * locate the frame within the tx queue and do post-tx processing. */ - out_cmd->hdr.cmd = REPLY_TX; + out_cmd->hdr.cmd = C_TX; out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | IDX_TO_SEQ(q->write_ptr))); @@ -672,7 +672,7 @@ static int il3945_get_measurement(struct il_priv *il, struct il_spectrum_cmd spectrum; struct il_rx_pkt *pkt; struct il_host_cmd cmd = { - .id = REPLY_SPECTRUM_MEASUREMENT_CMD, + .id = C_SPECTRUM_MEASUREMENT, .data = (void *)&spectrum, .flags = CMD_WANT_SKB, }; @@ -717,7 +717,7 @@ static int il3945_get_measurement(struct il_priv *il, pkt = (struct il_rx_pkt *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR("Bad return from REPLY_RX_ON_ASSOC command\n"); + IL_ERR("Bad return from N_RX_ON_ASSOC command\n"); rc = -EIO; } @@ -786,7 +786,7 @@ static void il3945_rx_reply_add_sta(struct il_priv *il, struct il_rx_pkt *pkt = rxb_addr(rxb); #endif - D_RX("Received REPLY_ADD_STA: 0x%02X\n", pkt->u.status); + D_RX("Received C_ADD_STA: 0x%02X\n", pkt->u.status); } static void il3945_rx_beacon_notif(struct il_priv *il, @@ -853,27 +853,27 @@ static void il3945_rx_card_state_notif(struct il_priv *il, */ static void il3945_setup_rx_handlers(struct il_priv *il) { - il->rx_handlers[REPLY_ALIVE] = il3945_rx_reply_alive; - il->rx_handlers[REPLY_ADD_STA] = il3945_rx_reply_add_sta; - il->rx_handlers[REPLY_ERROR] = il_rx_reply_error; - il->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa; - il->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = + il->rx_handlers[N_ALIVE] = il3945_rx_reply_alive; + il->rx_handlers[C_ADD_STA] = il3945_rx_reply_add_sta; + il->rx_handlers[N_ERROR] = il_rx_reply_error; + il->rx_handlers[N_CHANNEL_SWITCH] = il_rx_csa; + il->rx_handlers[N_SPECTRUM_MEASUREMENT] = il_rx_spectrum_measure_notif; - il->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; - il->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = + il->rx_handlers[N_PM_SLEEP] = il_rx_pm_sleep_notif; + il->rx_handlers[N_PM_DEBUG_STATS] = il_rx_pm_debug_stats_notif; - il->rx_handlers[BEACON_NOTIFICATION] = il3945_rx_beacon_notif; + il->rx_handlers[N_BEACON] = il3945_rx_beacon_notif; /* * The same handler is used for both the REPLY to a discrete * stats request from the host as well as for the periodic * stats notifications (after received beacons) from the uCode. */ - il->rx_handlers[REPLY_STATS_CMD] = il3945_reply_stats; - il->rx_handlers[STATS_NOTIFICATION] = il3945_hw_rx_stats; + il->rx_handlers[C_STATS] = il3945_reply_stats; + il->rx_handlers[N_STATS] = il3945_hw_rx_stats; il_setup_rx_scan_handlers(il); - il->rx_handlers[CARD_STATE_NOTIFICATION] = il3945_rx_card_state_notif; + il->rx_handlers[N_CARD_STATE] = il3945_rx_card_state_notif; /* Set up hardware specific Rx handlers */ il3945_hw_rx_handler_setup(il); @@ -1253,8 +1253,8 @@ static void il3945_rx_handle(struct il_priv *il) * Ucode should set SEQ_RX_FRAME bit if ucode-originated, * but apparently a few don't get set; catch them here. */ reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) && - pkt->hdr.cmd != STATS_NOTIFICATION && - pkt->hdr.cmd != REPLY_TX; + pkt->hdr.cmd != N_STATS && + pkt->hdr.cmd != C_TX; /* Based on type of command response or notification, * handle those that need handling via function in @@ -2137,9 +2137,9 @@ static int il3945_set_ucode_ptrs(struct il_priv *il) } /** - * il3945_init_alive_start - Called after REPLY_ALIVE notification received + * il3945_init_alive_start - Called after N_ALIVE notification received * - * Called after REPLY_ALIVE notification received from "initialize" uCode. + * Called after N_ALIVE notification received from "initialize" uCode. * * Tell "initialize" uCode to go ahead and load the runtime uCode. */ @@ -2180,7 +2180,7 @@ static void il3945_init_alive_start(struct il_priv *il) } /** - * il3945_alive_start - called after REPLY_ALIVE notification received + * il3945_alive_start - called after N_ALIVE notification received * from protocol/runtime uCode (initialization uCode's * Alive gets handled by il3945_init_alive_start()). */ @@ -2553,7 +2553,7 @@ static void il3945_rfkill_poll(struct work_struct *data) int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) { struct il_host_cmd cmd = { - .id = REPLY_SCAN_CMD, + .id = C_SCAN, .len = sizeof(struct il3945_scan_cmd), .flags = CMD_SIZE_HUGE, }; @@ -2767,7 +2767,7 @@ void il3945_post_associate(struct il_priv *il) rc = il_send_rxon_timing(il, ctx); if (rc) - IL_WARN("REPLY_RXON_TIMING failed - " + IL_WARN("C_RXON_TIMING failed - " "Attempting to continue.\n"); ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; @@ -2931,7 +2931,7 @@ void il3945_config_ap(struct il_priv *il) /* RXON Timing */ rc = il_send_rxon_timing(il, ctx); if (rc) - IL_WARN("REPLY_RXON_TIMING failed - " + IL_WARN("C_RXON_TIMING failed - " "Attempting to continue.\n"); ctx->staging.assoc_id = 0; @@ -3657,12 +3657,12 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en il->ctx.ctxid = 0; - il->ctx.rxon_cmd = REPLY_RXON; - il->ctx.rxon_timing_cmd = REPLY_RXON_TIMING; - il->ctx.rxon_assoc_cmd = REPLY_RXON_ASSOC; - il->ctx.qos_cmd = REPLY_QOS_PARAM; + il->ctx.rxon_cmd = C_RXON; + il->ctx.rxon_timing_cmd = C_RXON_TIMING; + il->ctx.rxon_assoc_cmd = C_RXON_ASSOC; + il->ctx.qos_cmd = C_QOS_PARAM; il->ctx.ap_sta_id = IL_AP_ID; - il->ctx.wep_key_cmd = REPLY_WEPKEY; + il->ctx.wep_key_cmd = C_WEPKEY; il->ctx.interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC); diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 82534a20ee8e..ba250f7e8fb3 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -53,7 +53,7 @@ static int il3945_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd) { struct il_host_cmd cmd = { - .id = REPLY_LEDS_CMD, + .id = C_LEDS, .len = sizeof(struct il_led_cmd), .data = led_cmd, .flags = CMD_ASYNC, @@ -1444,7 +1444,7 @@ static int il3945_send_tx_power(struct il_priv *il) txpower.power[i].rate); } - return il_send_cmd_pdu(il, REPLY_TX_PWR_TBL_CMD, + return il_send_cmd_pdu(il, C_TX_PWR_TBL, sizeof(struct il3945_txpowertable_cmd), &txpower); @@ -1673,7 +1673,7 @@ static int il3945_send_rxon_assoc(struct il_priv *il, struct il_rx_pkt *pkt; struct il3945_rxon_assoc_cmd rxon_assoc; struct il_host_cmd cmd = { - .id = REPLY_RXON_ASSOC, + .id = C_RXON_ASSOC, .len = sizeof(rxon_assoc), .flags = CMD_WANT_SKB, .data = &rxon_assoc, @@ -1701,7 +1701,7 @@ static int il3945_send_rxon_assoc(struct il_priv *il, pkt = (struct il_rx_pkt *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR("Bad return from REPLY_RXON_ASSOC command\n"); + IL_ERR("Bad return from C_RXON_ASSOC command\n"); rc = -EIO; } @@ -1782,7 +1782,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) */ active_rxon->reserved4 = 0; active_rxon->reserved5 = 0; - rc = il_send_cmd_pdu(il, REPLY_RXON, + rc = il_send_cmd_pdu(il, C_RXON, sizeof(struct il3945_rxon_cmd), &il->ctx.active); @@ -1818,7 +1818,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) il_set_rxon_hwcrypto(il, ctx, !il3945_mod_params.sw_crypto); /* Apply the new configuration */ - rc = il_send_cmd_pdu(il, REPLY_RXON, + rc = il_send_cmd_pdu(il, C_RXON, sizeof(struct il3945_rxon_cmd), staging_rxon); if (rc) { @@ -2237,9 +2237,9 @@ int il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq) static u16 il3945_get_hcmd_size(u8 cmd_id, u16 len) { switch (cmd_id) { - case REPLY_RXON: + case C_RXON: return sizeof(struct il3945_rxon_cmd); - case POWER_TBL_CMD: + case C_POWER_TBL: return sizeof(struct il3945_powertable_cmd); default: return len; @@ -2383,14 +2383,14 @@ int il3945_init_hw_rate_table(struct il_priv *il) /* Update the rate scaling for control frame Tx */ rate_cmd.table_id = 0; - rc = il_send_cmd_pdu(il, REPLY_RATE_SCALE, sizeof(rate_cmd), + rc = il_send_cmd_pdu(il, C_RATE_SCALE, sizeof(rate_cmd), &rate_cmd); if (rc) return rc; /* Update the rate scaling for data frame Tx */ rate_cmd.table_id = 1; - return il_send_cmd_pdu(il, REPLY_RATE_SCALE, sizeof(rate_cmd), + return il_send_cmd_pdu(il, C_RATE_SCALE, sizeof(rate_cmd), &rate_cmd); } @@ -2464,8 +2464,8 @@ unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, void il3945_hw_rx_handler_setup(struct il_priv *il) { - il->rx_handlers[REPLY_TX] = il3945_rx_reply_tx; - il->rx_handlers[REPLY_3945_RX] = il3945_rx_reply_rx; + il->rx_handlers[C_TX] = il3945_rx_reply_tx; + il->rx_handlers[N_3945_RX] = il3945_rx_reply_rx; } void il3945_hw_setup_deferred_work(struct il_priv *il) diff --git a/drivers/net/wireless/iwlegacy/4965-calib.c b/drivers/net/wireless/iwlegacy/4965-calib.c index cd61050160ac..c5dcc528e5ff 100644 --- a/drivers/net/wireless/iwlegacy/4965-calib.c +++ b/drivers/net/wireless/iwlegacy/4965-calib.c @@ -410,13 +410,13 @@ static void il4965_prepare_legacy_sensitivity_tbl(struct il_priv *il, data->nrg_th_cck); } -/* Prepare a SENSITIVITY_CMD, send to uCode if values have changed */ +/* Prepare a C_SENSITIVITY, send to uCode if values have changed */ static int il4965_sensitivity_write(struct il_priv *il) { struct il_sensitivity_cmd cmd; struct il_sensitivity_data *data = NULL; struct il_host_cmd cmd_out = { - .id = SENSITIVITY_CMD, + .id = C_SENSITIVITY, .len = sizeof(struct il_sensitivity_cmd), .flags = CMD_ASYNC, .data = &cmd, @@ -429,12 +429,12 @@ static int il4965_sensitivity_write(struct il_priv *il) il4965_prepare_legacy_sensitivity_tbl(il, data, &cmd.table[0]); /* Update uCode's "work" table, and copy it to DSP */ - cmd.control = SENSITIVITY_CMD_CONTROL_WORK_TBL; + cmd.control = C_SENSITIVITY_CONTROL_WORK_TBL; /* Don't send command to uCode if nothing has changed */ if (!memcmp(&cmd.table[0], &(il->sensitivity_tbl[0]), sizeof(u16)*HD_TBL_SIZE)) { - D_CALIB("No change in SENSITIVITY_CMD\n"); + D_CALIB("No change in C_SENSITIVITY\n"); return 0; } @@ -776,11 +776,11 @@ static void il4965_gain_computation(struct il_priv *il, cmd.diff_gain_a = data->delta_gain_code[0]; cmd.diff_gain_b = data->delta_gain_code[1]; cmd.diff_gain_c = data->delta_gain_code[2]; - ret = il_send_cmd_pdu(il, REPLY_PHY_CALIBRATION_CMD, + ret = il_send_cmd_pdu(il, C_PHY_CALIBRATION, sizeof(cmd), &cmd); if (ret) D_CALIB("fail sending cmd " - "REPLY_PHY_CALIBRATION_CMD\n"); + "C_PHY_CALIBRATION\n"); /* TODO we might want recalculate * rx_chain in rxon cmd */ diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index c3f8137642c3..098d86397d91 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -608,8 +608,8 @@ static void il4965_pass_packet_to_mac80211(struct il_priv *il, rxb->page = NULL; } -/* Called for REPLY_RX (legacy ABG frames), or - * REPLY_RX_MPDU_CMD (HT high-throughput N frames). */ +/* Called for N_RX (legacy ABG frames), or + * N_RX_MPDU (HT high-throughput N frames). */ void il4965_rx_reply_rx(struct il_priv *il, struct il_rx_buf *rxb) { @@ -624,15 +624,15 @@ void il4965_rx_reply_rx(struct il_priv *il, u32 rate_n_flags; /** - * REPLY_RX and REPLY_RX_MPDU_CMD are handled differently. - * REPLY_RX: physical layer info is in this buffer - * REPLY_RX_MPDU_CMD: physical layer info was sent in separate + * N_RX and N_RX_MPDU are handled differently. + * N_RX: physical layer info is in this buffer + * N_RX_MPDU: physical layer info was sent in separate * command and cached in il->last_phy_res * * Here we set up local variables depending on which command is * received. */ - if (pkt->hdr.cmd == REPLY_RX) { + if (pkt->hdr.cmd == N_RX) { phy_res = (struct il_rx_phy_res *)pkt->u.raw; header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*phy_res) + phy_res->cfg_phy_cnt); @@ -728,8 +728,8 @@ void il4965_rx_reply_rx(struct il_priv *il, rxb, &rx_status); } -/* Cache phy data (Rx signal strength, etc) for HT frame (REPLY_RX_PHY_CMD). - * This will be used later in il_rx_reply_rx() for REPLY_RX_MPDU_CMD. */ +/* Cache phy data (Rx signal strength, etc) for HT frame (N_RX_PHY). + * This will be used later in il_rx_reply_rx() for N_RX_MPDU. */ void il4965_rx_reply_rx_phy(struct il_priv *il, struct il_rx_buf *rxb) { @@ -827,7 +827,7 @@ static inline u32 il4965_ant_idx_to_flags(u8 ant_idx) int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) { struct il_host_cmd cmd = { - .id = REPLY_SCAN_CMD, + .id = C_SCAN, .len = sizeof(struct il_scan_cmd), .flags = CMD_SIZE_HUGE, }; @@ -1388,7 +1388,7 @@ void il4965_rx_stats(struct il_priv *il, msecs_to_jiffies(REG_RECALIB_PERIOD * 1000)); if (unlikely(!test_bit(S_SCANNING, &il->status)) && - (pkt->hdr.cmd == STATS_NOTIFICATION)) { + (pkt->hdr.cmd == N_STATS)) { il4965_rx_calc_noise(il); queue_work(il->workqueue, &il->run_time_calib_work); } @@ -1473,7 +1473,7 @@ il4965_get_fifo_from_tid(struct il_rxon_context *ctx, u16 tid) } /* - * handle build REPLY_TX command notification. + * handle build C_TX command notification. */ static void il4965_tx_cmd_build_basic(struct il_priv *il, struct sk_buff *skb, @@ -1640,7 +1640,7 @@ static void il4965_tx_cmd_build_hwcrypto(struct il_priv *il, } /* - * start REPLY_TX command process + * start C_TX command process */ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) { @@ -1797,7 +1797,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) * after Tx, uCode's Tx response will return this value so driver can * locate the frame within the tx queue and do post-tx processing. */ - out_cmd->hdr.cmd = REPLY_TX; + out_cmd->hdr.cmd = C_TX; out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | IDX_TO_SEQ(q->write_ptr))); @@ -2616,7 +2616,7 @@ void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, } /** - * il4965_rx_reply_compressed_ba - Handler for REPLY_COMPRESSED_BA + * il4965_rx_reply_compressed_ba - Handler for N_COMPRESSED_BA * * Handles block-acknowledge notification from device, which reports success * of frames sent via aggregation. @@ -2668,7 +2668,7 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il, spin_lock_irqsave(&il->sta_lock, flags); - D_TX_REPLY("REPLY_COMPRESSED_BA [%d] Received from %pM, " + D_TX_REPLY("N_COMPRESSED_BA [%d] Received from %pM, " "sta_id = %d\n", agg->wait_for_ba, (u8 *) &ba_resp->sta_addr_lo32, @@ -2917,7 +2917,7 @@ int il4965_remove_default_wep_key(struct il_priv *il, memset(&ctx->wep_keys[keyconf->keyidx], 0, sizeof(ctx->wep_keys[0])); if (il_is_rfkill(il)) { D_WEP( - "Not sending REPLY_WEPKEY command due to RFKILL.\n"); + "Not sending C_WEPKEY command due to RFKILL.\n"); /* but keys in device are clear anyway so return success */ return 0; } @@ -3201,7 +3201,7 @@ int il4965_remove_dynamic_key(struct il_priv *il, if (il_is_rfkill(il)) { D_WEP( - "Not sending REPLY_ADD_STA command because RFKILL enabled.\n"); + "Not sending C_ADD_STA command because RFKILL enabled.\n"); spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } @@ -3598,7 +3598,7 @@ int il4965_send_beacon_cmd(struct il_priv *il) return -EINVAL; } - rc = il_send_cmd_pdu(il, REPLY_TX_BEACON, frame_size, + rc = il_send_cmd_pdu(il, C_TX_BEACON, frame_size, &frame->u.cmd[0]); il4965_free_frame(il, frame); @@ -3801,7 +3801,7 @@ static void il4965_rx_reply_alive(struct il_priv *il, * This callback is provided in order to send a stats request. * * This timer function is continually reset to execute within - * REG_RECALIB_PERIOD seconds since the last STATS_NOTIFICATION + * REG_RECALIB_PERIOD seconds since the last N_STATS * was received. We need to ensure we receive the stats in order * to update the temperature used for calibrating the TXPOWER. */ @@ -3921,37 +3921,37 @@ static void il4965_rx_card_state_notif(struct il_priv *il, */ static void il4965_setup_rx_handlers(struct il_priv *il) { - il->rx_handlers[REPLY_ALIVE] = il4965_rx_reply_alive; - il->rx_handlers[REPLY_ERROR] = il_rx_reply_error; - il->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = il_rx_csa; - il->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = + il->rx_handlers[N_ALIVE] = il4965_rx_reply_alive; + il->rx_handlers[N_ERROR] = il_rx_reply_error; + il->rx_handlers[N_CHANNEL_SWITCH] = il_rx_csa; + il->rx_handlers[N_SPECTRUM_MEASUREMENT] = il_rx_spectrum_measure_notif; - il->rx_handlers[PM_SLEEP_NOTIFICATION] = il_rx_pm_sleep_notif; - il->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = + il->rx_handlers[N_PM_SLEEP] = il_rx_pm_sleep_notif; + il->rx_handlers[N_PM_DEBUG_STATS] = il_rx_pm_debug_stats_notif; - il->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; + il->rx_handlers[N_BEACON] = il4965_rx_beacon_notif; /* * The same handler is used for both the REPLY to a discrete * stats request from the host as well as for the periodic * stats notifications (after received beacons) from the uCode. */ - il->rx_handlers[REPLY_STATS_CMD] = il4965_reply_stats; - il->rx_handlers[STATS_NOTIFICATION] = il4965_rx_stats; + il->rx_handlers[C_STATS] = il4965_reply_stats; + il->rx_handlers[N_STATS] = il4965_rx_stats; il_setup_rx_scan_handlers(il); /* status change handler */ - il->rx_handlers[CARD_STATE_NOTIFICATION] = + il->rx_handlers[N_CARD_STATE] = il4965_rx_card_state_notif; - il->rx_handlers[MISSED_BEACONS_NOTIFICATION] = + il->rx_handlers[N_MISSED_BEACONS] = il4965_rx_missed_beacon_notif; /* Rx handlers */ - il->rx_handlers[REPLY_RX_PHY_CMD] = il4965_rx_reply_rx_phy; - il->rx_handlers[REPLY_RX_MPDU_CMD] = il4965_rx_reply_rx; + il->rx_handlers[N_RX_PHY] = il4965_rx_reply_rx_phy; + il->rx_handlers[N_RX_MPDU] = il4965_rx_reply_rx; /* block ack */ - il->rx_handlers[REPLY_COMPRESSED_BA] = il4965_rx_reply_compressed_ba; + il->rx_handlers[N_COMPRESSED_BA] = il4965_rx_reply_compressed_ba; /* Set up hardware specific Rx handlers */ il->cfg->ops->lib->rx_handler_setup(il); } @@ -4019,12 +4019,12 @@ void il4965_rx_handle(struct il_priv *il) * Ucode should set SEQ_RX_FRAME bit if ucode-originated, * but apparently a few don't get set; catch them here. */ reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) && - (pkt->hdr.cmd != REPLY_RX_PHY_CMD) && - (pkt->hdr.cmd != REPLY_RX) && - (pkt->hdr.cmd != REPLY_RX_MPDU_CMD) && - (pkt->hdr.cmd != REPLY_COMPRESSED_BA) && - (pkt->hdr.cmd != STATS_NOTIFICATION) && - (pkt->hdr.cmd != REPLY_TX); + (pkt->hdr.cmd != N_RX_PHY) && + (pkt->hdr.cmd != N_RX) && + (pkt->hdr.cmd != N_RX_MPDU) && + (pkt->hdr.cmd != N_COMPRESSED_BA) && + (pkt->hdr.cmd != N_STATS) && + (pkt->hdr.cmd != C_TX); /* Based on type of command response or notification, * handle those that need handling via function in @@ -4923,12 +4923,12 @@ static void il4965_rf_kill_ct_config(struct il_priv *il) cmd.critical_temperature_R = cpu_to_le32(il->hw_params.ct_kill_threshold); - ret = il_send_cmd_pdu(il, REPLY_CT_KILL_CONFIG_CMD, + ret = il_send_cmd_pdu(il, C_CT_KILL_CONFIG, sizeof(cmd), &cmd); if (ret) - IL_ERR("REPLY_CT_KILL_CONFIG_CMD failed\n"); + IL_ERR("C_CT_KILL_CONFIG failed\n"); else - D_INFO("REPLY_CT_KILL_CONFIG_CMD " + D_INFO("C_CT_KILL_CONFIG " "succeeded, " "critical temperature is %d\n", il->hw_params.ct_kill_threshold); @@ -5042,7 +5042,7 @@ static int il4965_alive_notify(struct il_priv *il) } /** - * il4965_alive_start - called after REPLY_ALIVE notification received + * il4965_alive_start - called after N_ALIVE notification received * from protocol/runtime uCode (initialization uCode's * Alive gets handled by il_init_alive_start()). */ @@ -6200,12 +6200,12 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) il->ctx.always_active = true; il->ctx.is_active = true; - il->ctx.rxon_cmd = REPLY_RXON; - il->ctx.rxon_timing_cmd = REPLY_RXON_TIMING; - il->ctx.rxon_assoc_cmd = REPLY_RXON_ASSOC; - il->ctx.qos_cmd = REPLY_QOS_PARAM; + il->ctx.rxon_cmd = C_RXON; + il->ctx.rxon_timing_cmd = C_RXON_TIMING; + il->ctx.rxon_assoc_cmd = C_RXON_ASSOC; + il->ctx.qos_cmd = C_QOS_PARAM; il->ctx.ap_sta_id = IL_AP_ID; - il->ctx.wep_key_cmd = REPLY_WEPKEY; + il->ctx.wep_key_cmd = C_WEPKEY; il->ctx.ac_to_fifo = il4965_bss_ac_to_fifo; il->ctx.ac_to_queue = il4965_bss_ac_to_queue; il->ctx.exclusive_interface_modes = diff --git a/drivers/net/wireless/iwlegacy/4965-rs.c b/drivers/net/wireless/iwlegacy/4965-rs.c index c4bf4aafad9d..4809a9d4b977 100644 --- a/drivers/net/wireless/iwlegacy/4965-rs.c +++ b/drivers/net/wireless/iwlegacy/4965-rs.c @@ -2172,8 +2172,8 @@ out: * if the driver's iwl-4965-rs rate scaling algorithm is used, instead of * rc80211_simple. * - * NOTE: Run REPLY_ADD_STA command to set up station table entry, before - * calling this function (which runs REPLY_TX_LINK_QUALITY_CMD, + * NOTE: Run C_ADD_STA command to set up station table entry, before + * calling this function (which runs C_TX_LINK_QUALITY_CMD, * which requires station table entry to exist). */ static void il4965_rs_initialize_lq(struct il_priv *il, diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 361a1ca39896..3b101c142171 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -249,7 +249,7 @@ static int il4965_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd) { struct il_host_cmd cmd = { - .id = REPLY_LEDS_CMD, + .id = C_LEDS, .len = sizeof(struct il_led_cmd), .data = led_cmd, .flags = CMD_ASYNC, @@ -465,9 +465,9 @@ static int il4965_set_ucode_ptrs(struct il_priv *il) } /** - * il4965_init_alive_start - Called after REPLY_ALIVE notification received + * il4965_init_alive_start - Called after N_ALIVE notification received * - * Called after REPLY_ALIVE notification received from "initialize" uCode. + * Called after N_ALIVE notification received from "initialize" uCode. * * The 4965 "initialize" ALIVE reply contains calibration data for: * Voltage, temperature, and MIMO tx gain correction, now stored in il @@ -567,10 +567,10 @@ static void il4965_chain_noise_reset(struct il_priv *il) cmd.diff_gain_a = 0; cmd.diff_gain_b = 0; cmd.diff_gain_c = 0; - if (il_send_cmd_pdu(il, REPLY_PHY_CALIBRATION_CMD, + if (il_send_cmd_pdu(il, C_PHY_CALIBRATION, sizeof(cmd), &cmd)) IL_ERR( - "Could not send REPLY_PHY_CALIBRATION_CMD\n"); + "Could not send C_PHY_CALIBRATION\n"); data->state = IL_CHAIN_NOISE_ACCUMULATE; D_CALIB("Run chain_noise_calibrate\n"); } @@ -1370,7 +1370,7 @@ static int il4965_send_tx_power(struct il_priv *il) goto out; ret = il_send_cmd_pdu(il, - REPLY_TX_PWR_TBL_CMD, sizeof(cmd), &cmd); + C_TX_PWR_TBL, sizeof(cmd), &cmd); out: return ret; @@ -1408,7 +1408,7 @@ static int il4965_send_rxon_assoc(struct il_priv *il, ctx->staging.ofdm_ht_dual_stream_basic_rates; rxon_assoc.rx_chain_select_flags = ctx->staging.rx_chain; - ret = il_send_cmd_pdu_async(il, REPLY_RXON_ASSOC, + ret = il_send_cmd_pdu_async(il, C_RXON_ASSOC, sizeof(rxon_assoc), &rxon_assoc, NULL); return ret; @@ -1632,7 +1632,7 @@ static int il4965_hw_channel_switch(struct il_priv *il, } return il_send_cmd_pdu(il, - REPLY_CHANNEL_SWITCH, sizeof(cmd), &cmd); + C_CHANNEL_SWITCH, sizeof(cmd), &cmd); } /** @@ -1795,7 +1795,7 @@ static void il4965_temperature_calib(struct il_priv *il) static u16 il4965_get_hcmd_size(u8 cmd_id, u16 len) { switch (cmd_id) { - case REPLY_RXON: + case C_RXON: return (u16) sizeof(struct il4965_rxon_cmd); default: return len; @@ -2145,10 +2145,10 @@ static void il4965_rx_beacon_notif(struct il_priv *il, static void il4965_rx_handler_setup(struct il_priv *il) { /* Legacy Rx frames */ - il->rx_handlers[REPLY_RX] = il4965_rx_reply_rx; + il->rx_handlers[N_RX] = il4965_rx_reply_rx; /* Tx response */ - il->rx_handlers[REPLY_TX] = il4965_rx_reply_tx; - il->rx_handlers[BEACON_NOTIFICATION] = il4965_rx_beacon_notif; + il->rx_handlers[C_TX] = il4965_rx_reply_tx; + il->rx_handlers[N_BEACON] = il4965_rx_beacon_notif; } static struct il_hcmd_ops il4965_hcmd = { diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h index 85c3a49d7e14..94cf7e7da7f9 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -278,8 +278,8 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * uCode provides all 4 values to the driver via the "initialize alive" * notification (see struct il4965_init_alive_resp). After the runtime uCode * image loads, uCode updates the R4 value via stats notifications - * (see STATS_NOTIFICATION), which occur after each received beacon - * when associated, or can be requested via REPLY_STATS_CMD. + * (see N_STATS), which occur after each received beacon + * when associated, or can be requested via C_STATS. * * NOTE: uCode provides the R4 value as a 23-bit signed value. Driver * must sign-extend to 32 bits before applying formula below. diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h index 1a6ca36b4c78..8df4d252168b 100644 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ b/drivers/net/wireless/iwlegacy/iwl-commands.h @@ -84,76 +84,76 @@ struct il_priv; #define IL_MAX_RATES (IL_CCK_RATES + IL_OFDM_RATES) enum { - REPLY_ALIVE = 0x1, - REPLY_ERROR = 0x2, + N_ALIVE = 0x1, + N_ERROR = 0x2, /* RXON and QOS commands */ - REPLY_RXON = 0x10, - REPLY_RXON_ASSOC = 0x11, - REPLY_QOS_PARAM = 0x13, - REPLY_RXON_TIMING = 0x14, + C_RXON = 0x10, + C_RXON_ASSOC = 0x11, + C_QOS_PARAM = 0x13, + C_RXON_TIMING = 0x14, /* Multi-Station support */ - REPLY_ADD_STA = 0x18, - REPLY_REMOVE_STA = 0x19, + C_ADD_STA = 0x18, + C_REM_STA = 0x19, /* Security */ - REPLY_WEPKEY = 0x20, + C_WEPKEY = 0x20, /* RX, TX, LEDs */ - REPLY_3945_RX = 0x1b, /* 3945 only */ - REPLY_TX = 0x1c, - REPLY_RATE_SCALE = 0x47, /* 3945 only */ - REPLY_LEDS_CMD = 0x48, - REPLY_TX_LINK_QUALITY_CMD = 0x4e, /* for 4965 and up */ + N_3945_RX = 0x1b, /* 3945 only */ + C_TX = 0x1c, + C_RATE_SCALE = 0x47, /* 3945 only */ + C_LEDS = 0x48, + C_TX_LINK_QUALITY_CMD = 0x4e, /* for 4965 */ /* 802.11h related */ - REPLY_CHANNEL_SWITCH = 0x72, - CHANNEL_SWITCH_NOTIFICATION = 0x73, - REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74, - SPECTRUM_MEASURE_NOTIFICATION = 0x75, + C_CHANNEL_SWITCH = 0x72, + N_CHANNEL_SWITCH = 0x73, + C_SPECTRUM_MEASUREMENT = 0x74, + N_SPECTRUM_MEASUREMENT = 0x75, /* Power Management */ - POWER_TBL_CMD = 0x77, - PM_SLEEP_NOTIFICATION = 0x7A, - PM_DEBUG_STATISTIC_NOTIFIC = 0x7B, + C_POWER_TBL = 0x77, + N_PM_SLEEP = 0x7A, + N_PM_DEBUG_STATS = 0x7B, /* Scan commands and notifications */ - REPLY_SCAN_CMD = 0x80, - REPLY_SCAN_ABORT_CMD = 0x81, - SCAN_START_NOTIFICATION = 0x82, - SCAN_RESULTS_NOTIFICATION = 0x83, - SCAN_COMPLETE_NOTIFICATION = 0x84, + C_SCAN = 0x80, + C_SCAN_ABORT = 0x81, + N_SCAN_START = 0x82, + N_SCAN_RESULTS = 0x83, + N_SCAN_COMPLETE = 0x84, /* IBSS/AP commands */ - BEACON_NOTIFICATION = 0x90, - REPLY_TX_BEACON = 0x91, + N_BEACON = 0x90, + C_TX_BEACON= 0x91, /* Miscellaneous commands */ - REPLY_TX_PWR_TBL_CMD = 0x97, + C_TX_PWR_TBL = 0x97, /* Bluetooth device coexistence config command */ - REPLY_BT_CONFIG = 0x9b, + C_BT_CONFIG = 0x9b, /* Statistics */ - REPLY_STATS_CMD = 0x9c, - STATS_NOTIFICATION = 0x9d, + C_STATS = 0x9c, + N_STATS = 0x9d, /* RF-KILL commands and notifications */ - CARD_STATE_NOTIFICATION = 0xa1, + N_CARD_STATE = 0xa1, /* Missed beacons notification */ - MISSED_BEACONS_NOTIFICATION = 0xa2, + N_MISSED_BEACONS = 0xa2, - REPLY_CT_KILL_CONFIG_CMD = 0xa4, - SENSITIVITY_CMD = 0xa8, - REPLY_PHY_CALIBRATION_CMD = 0xb0, - REPLY_RX_PHY_CMD = 0xc0, - REPLY_RX_MPDU_CMD = 0xc1, - REPLY_RX = 0xc3, - REPLY_COMPRESSED_BA = 0xc5, + C_CT_KILL_CONFIG = 0xa4, + C_SENSITIVITY = 0xa8, + C_PHY_CALIBRATION = 0xb0, + N_RX_PHY = 0xc0, + N_RX_MPDU = 0xc1, + N_RX = 0xc3, + N_COMPRESSED_BA = 0xc5, - REPLY_MAX = 0xff + IL_CN_MAX = 0xff }; /****************************************************************************** @@ -180,7 +180,7 @@ enum { * driver, and each response/notification received from uCode. */ struct il_cmd_header { - u8 cmd; /* Command ID: REPLY_RXON, etc. */ + u8 cmd; /* Command ID: C_RXON, etc. */ u8 flags; /* 0:5 reserved, 6 abort, 7 internal */ /* * The driver sets up the sequence number to values of its choosing. @@ -192,7 +192,7 @@ struct il_cmd_header { * There is one exception: uCode sets bit 15 when it originates * the response/notification, i.e. when the response/notification * is not a direct response to a command sent by the driver. For - * example, uCode issues REPLY_3945_RX when it sends a received frame + * example, uCode issues N_3945_RX when it sends a received frame * to the driver; it is not a direct response to any driver command. * * The Linux driver uses the following format: @@ -214,7 +214,7 @@ struct il_cmd_header { /** * struct il3945_tx_power * - * Used in REPLY_TX_PWR_TBL_CMD, REPLY_SCAN_CMD, REPLY_CHANNEL_SWITCH + * Used in C_TX_PWR_TBL, C_SCAN, C_CHANNEL_SWITCH * * Each entry contains two values: * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained @@ -233,7 +233,7 @@ struct il3945_tx_power { /** * struct il3945_power_per_rate * - * Used in REPLY_TX_PWR_TBL_CMD, REPLY_CHANNEL_SWITCH + * Used in C_TX_PWR_TBL, C_CHANNEL_SWITCH */ struct il3945_power_per_rate { u8 rate; /* plcp */ @@ -245,10 +245,10 @@ struct il3945_power_per_rate { * iwl4965 rate_n_flags bit fields * * rate_n_flags format is used in following iwl4965 commands: - * REPLY_RX (response only) - * REPLY_RX_MPDU (response only) - * REPLY_TX (both command and response) - * REPLY_TX_LINK_QUALITY_CMD + * N_RX (response only) + * N_RX_MPDU (response only) + * C_TX (both command and response) + * C_TX_LINK_QUALITY_CMD * * High-throughput (HT) rate format for bits 7:0 (bit 8 must be "1"): * 2-0: 0) 6 Mbps @@ -336,7 +336,7 @@ struct il3945_power_per_rate { /** * union il4965_tx_power_dual_stream * - * Host format used for REPLY_TX_PWR_TBL_CMD, REPLY_CHANNEL_SWITCH + * Host format used for C_TX_PWR_TBL, C_CHANNEL_SWITCH * Use __le32 version (struct tx_power_dual_stream) when building command. * * Driver provides radio gain and DSP attenuation settings to device in pairs, @@ -360,7 +360,7 @@ union il4965_tx_power_dual_stream { /** * struct tx_power_dual_stream * - * Table entries in REPLY_TX_PWR_TBL_CMD, REPLY_CHANNEL_SWITCH + * Table entries in C_TX_PWR_TBL, C_CHANNEL_SWITCH * * Same format as il_tx_power_dual_stream, but __le32 */ @@ -371,7 +371,7 @@ struct tx_power_dual_stream { /** * struct il4965_tx_power_db * - * Entire table within REPLY_TX_PWR_TBL_CMD, REPLY_CHANNEL_SWITCH + * Entire table within C_TX_PWR_TBL, C_CHANNEL_SWITCH */ struct il4965_tx_power_db { struct tx_power_dual_stream power_tbl[POWER_TBL_NUM_ENTRIES]; @@ -387,7 +387,7 @@ struct il4965_tx_power_db { #define INITIALIZE_SUBTYPE (9) /* - * ("Initialize") REPLY_ALIVE = 0x1 (response only, not a command) + * ("Initialize") N_ALIVE = 0x1 (response only, not a command) * * uCode issues this "initialize alive" notification once the initialization * uCode image has completed its work, and is ready to load the runtime image. @@ -435,7 +435,7 @@ struct il_init_alive_resp { /** - * REPLY_ALIVE = 0x1 (response only, not a command) + * N_ALIVE = 0x1 (response only, not a command) * * uCode issues this "alive" notification once the runtime image is ready * to receive commands from the driver. This is the *second* "alive" @@ -526,7 +526,7 @@ struct il_alive_resp { } __packed; /* - * REPLY_ERROR = 0x2 (response only, not a command) + * N_ERROR = 0x2 (response only, not a command) */ struct il_error_resp { __le32 error_type; @@ -640,7 +640,7 @@ enum { #define RXON_FILTER_BCON_AWARE_MSK cpu_to_le32(1 << 6) /** - * REPLY_RXON = 0x10 (command, has simple generic response) + * C_RXON = 0x10 (command, has simple generic response) * * RXON tunes the radio tuner to a service channel, and sets up a number * of parameters that are used primarily for Rx, but also for Tx operations. @@ -653,7 +653,7 @@ enum { * channel. * * NOTE: All RXONs wipe clean the internal txpower table. Driver must - * issue a new REPLY_TX_PWR_TBL_CMD after each REPLY_RXON (0x10), + * issue a new C_TX_PWR_TBL after each C_RXON (0x10), * regardless of whether RXON_FILTER_ASSOC_MSK is set. */ @@ -723,7 +723,7 @@ struct il_rxon_cmd { /* - * REPLY_RXON_ASSOC = 0x11 (command, has simple generic response) + * C_RXON_ASSOC = 0x11 (command, has simple generic response) */ struct il3945_rxon_assoc_cmd { __le32 flags; @@ -749,7 +749,7 @@ struct il4965_rxon_assoc_cmd { #define IL39_MAX_UCODE_BEACON_INTERVAL 1 /* 1024 */ /* - * REPLY_RXON_TIMING = 0x14 (command, has simple generic response) + * C_RXON_TIMING = 0x14 (command, has simple generic response) */ struct il_rxon_time_cmd { __le64 timestamp; @@ -762,7 +762,7 @@ struct il_rxon_time_cmd { } __packed; /* - * REPLY_CHANNEL_SWITCH = 0x72 (command, has simple generic response) + * C_CHANNEL_SWITCH = 0x72 (command, has simple generic response) */ struct il3945_channel_switch_cmd { u8 band; @@ -785,7 +785,7 @@ struct il4965_channel_switch_cmd { } __packed; /* - * CHANNEL_SWITCH_NOTIFICATION = 0x73 (notification only, not a command) + * N_CHANNEL_SWITCH = 0x73 (notification only, not a command) */ struct il_csa_notification { __le16 band; @@ -800,7 +800,7 @@ struct il_csa_notification { *****************************************************************************/ /** - * struct il_ac_qos -- QOS timing params for REPLY_QOS_PARAM + * struct il_ac_qos -- QOS timing params for C_QOS_PARAM * One for each of 4 EDCA access categories in struct il_qosparam_cmd * * @cw_min: Contention win, start value in numbers of slots. @@ -832,7 +832,7 @@ struct il_ac_qos { #define AC_NUM 4 /* - * REPLY_QOS_PARAM = 0x13 (command, has simple generic response) + * C_QOS_PARAM = 0x13 (command, has simple generic response) * * This command sets up timings for each of the 4 prioritized EDCA Tx FIFOs * 0: Background, 1: Best Effort, 2: Video, 3: Voice. @@ -936,15 +936,15 @@ struct sta_id_modify { } __packed; /* - * REPLY_ADD_STA = 0x18 (command) + * C_ADD_STA = 0x18 (command) * * The device contains an internal table of per-station information, * with info on security keys, aggregation parameters, and Tx rates for * initial Tx attempt and any retries (4965 devices uses - * REPLY_TX_LINK_QUALITY_CMD, - * 3945 uses REPLY_RATE_SCALE to set up rate tables). + * C_TX_LINK_QUALITY_CMD, + * 3945 uses C_RATE_SCALE to set up rate tables). * - * REPLY_ADD_STA sets up the table entry for one station, either creating + * C_ADD_STA sets up the table entry for one station, either creating * a new entry, or modifying a pre-existing one. * * NOTE: RXON command (without "associated" bit set) wipes the station table @@ -1071,7 +1071,7 @@ struct il_addsta_cmd { #define ADD_STA_NO_BLOCK_ACK_RESOURCE 0x4 #define ADD_STA_MODIFY_NON_EXIST_STA 0x8 /* - * REPLY_ADD_STA = 0x18 (response) + * C_ADD_STA = 0x18 (response) */ struct il_add_sta_resp { u8 status; /* ADD_STA_* */ @@ -1079,14 +1079,14 @@ struct il_add_sta_resp { #define REM_STA_SUCCESS_MSK 0x1 /* - * REPLY_REM_STA = 0x19 (response) + * C_REM_STA = 0x19 (response) */ struct il_rem_sta_resp { u8 status; } __packed; /* - * REPLY_REM_STA = 0x19 (command) + * C_REM_STA = 0x19 (command) */ struct il_rem_sta_cmd { u8 num_sta; /* number of removed stations */ @@ -1195,7 +1195,7 @@ struct il3945_rx_frame_end { } __packed; /* - * REPLY_3945_RX = 0x1b (response only, not a command) + * N_3945_RX = 0x1b (response only, not a command) * * NOTE: DO NOT dereference from casts to this structure * It is provided only for calculating minimum data set size. @@ -1226,7 +1226,7 @@ struct il4965_rx_non_cfg_phy { /* - * REPLY_RX = 0xc3 (response only, not a command) + * N_RX = 0xc3 (response only, not a command) * Used only for legacy (non 11n) frames. */ struct il_rx_phy_res { @@ -1254,7 +1254,7 @@ struct il_rx_mpdu_res_start { * (5) * Tx Commands & Responses: * - * Driver must place each REPLY_TX command into one of the prioritized Tx + * Driver must place each C_TX command into one of the prioritized Tx * queues in host DRAM, shared between driver and device (see comments for * SCD registers and Tx/Rx Queues). When the device's Tx scheduler and uCode * are preparing to transmit, the device pulls the Tx command over the PCI @@ -1264,18 +1264,18 @@ struct il_rx_mpdu_res_start { * uCode handles all timing and protocol related to control frames * (RTS/CTS/ACK), based on flags in the Tx command. uCode and Tx scheduler * handle reception of block-acks; uCode updates the host driver via - * REPLY_COMPRESSED_BA. + * N_COMPRESSED_BA. * * uCode handles retrying Tx when an ACK is expected but not received. * This includes trying lower data rates than the one requested in the Tx - * command, as set up by the REPLY_RATE_SCALE (for 3945) or - * REPLY_TX_LINK_QUALITY_CMD (4965). + * command, as set up by the C_RATE_SCALE (for 3945) or + * C_TX_LINK_QUALITY_CMD (4965). * - * Driver sets up transmit power for various rates via REPLY_TX_PWR_TBL_CMD. + * Driver sets up transmit power for various rates via C_TX_PWR_TBL. * This command must be executed after every RXON command, before Tx can occur. *****************************************************************************/ -/* REPLY_TX Tx flags field */ +/* C_TX Tx flags field */ /* * 1: Use Request-To-Send protocol before this frame. @@ -1296,7 +1296,7 @@ struct il_rx_mpdu_res_start { #define TX_CMD_FLG_ACK_MSK cpu_to_le32(1 << 3) /* For 4965 devices: - * 1: Use rate scale table (see REPLY_TX_LINK_QUALITY_CMD). + * 1: Use rate scale table (see C_TX_LINK_QUALITY_CMD). * Tx command's initial_rate_idx indicates first rate to try; * uCode walks through table for additional Tx attempts. * 0: Use Tx rate/MCS from Tx command's rate_n_flags field. @@ -1322,7 +1322,7 @@ struct il_rx_mpdu_res_start { /* 1: uCode overrides sequence control field in MAC header. * 0: Driver provides sequence control field in MAC header. * Set this for management frames, non-QOS data frames, non-unicast frames, - * and also in Tx command embedded in REPLY_SCAN_CMD for active scans. */ + * and also in Tx command embedded in C_SCAN for active scans. */ #define TX_CMD_FLG_SEQ_CTL_MSK cpu_to_le32(1 << 13) /* 1: This frame is non-last MPDU; more fragments are coming. @@ -1369,7 +1369,7 @@ struct il_rx_mpdu_res_start { #define TKIP_ICV_LEN 4 /* - * REPLY_TX = 0x1c (command) + * C_TX = 0x1c (command) */ struct il3945_tx_cmd { @@ -1434,7 +1434,7 @@ struct il3945_tx_cmd { } __packed; /* - * REPLY_TX = 0x1c (response) + * C_TX = 0x1c (response) */ struct il3945_tx_resp { u8 failure_rts; @@ -1493,7 +1493,7 @@ struct il_tx_cmd { u8 sec_ctl; /* TX_CMD_SEC_* */ /* - * Index into rate table (see REPLY_TX_LINK_QUALITY_CMD) for initial + * Index into rate table (see C_TX_LINK_QUALITY_CMD) for initial * Tx attempt, if TX_CMD_FLG_STA_RATE_MSK is set. Normally "0" for * data frames, this field may be used to selectively reduce initial * rate (via non-0 value) for special frames (e.g. management), while @@ -1671,7 +1671,7 @@ enum { #define AGG_TX_STATE_SEQ_NUM_MSK 0xffff0000 /* - * REPLY_TX = 0x1c (response) + * C_TX = 0x1c (response) * * This response may be in one of two slightly different formats, indicated * by the frame_count field: @@ -1735,7 +1735,7 @@ struct il4965_tx_resp { } __packed; /* - * REPLY_COMPRESSED_BA = 0xc5 (response only, not a command) + * N_COMPRESSED_BA = 0xc5 (response only, not a command) * * Reports Block-Acknowledge from recipient station */ @@ -1754,7 +1754,7 @@ struct il_compressed_ba_resp { } __packed; /* - * REPLY_TX_PWR_TBL_CMD = 0x97 (command, has simple generic response) + * C_TX_PWR_TBL = 0x97 (command, has simple generic response) * * See details under "TXPOWER" in 4965.h. */ @@ -1777,7 +1777,7 @@ struct il4965_txpowertable_cmd { /** * struct il3945_rate_scaling_cmd - Rate Scaling Command & Response * - * REPLY_RATE_SCALE = 0x47 (command, has simple generic response) + * C_RATE_SCALE = 0x47 (command, has simple generic response) * * NOTE: The table of rates passed to the uCode via the * RATE_SCALE command sets up the corresponding order of @@ -1786,7 +1786,7 @@ struct il4965_txpowertable_cmd { * * For example, if you set 9MB (PLCP 0x0f) as the first * rate in the rate table, the bit mask for that rate - * when passed through ofdm_basic_rates on the REPLY_RXON + * when passed through ofdm_basic_rates on the C_RXON * command would be bit 0 (1 << 0) */ struct il3945_rate_scaling_info { @@ -1820,7 +1820,7 @@ struct il3945_rate_scaling_cmd { /** * struct il_link_qual_general_params * - * Used in REPLY_TX_LINK_QUALITY_CMD + * Used in C_TX_LINK_QUALITY_CMD */ struct il_link_qual_general_params { u8 flags; @@ -1863,7 +1863,7 @@ struct il_link_qual_general_params { /** * struct il_link_qual_agg_params * - * Used in REPLY_TX_LINK_QUALITY_CMD + * Used in C_TX_LINK_QUALITY_CMD */ struct il_link_qual_agg_params { @@ -1892,9 +1892,9 @@ struct il_link_qual_agg_params { } __packed; /* - * REPLY_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response) + * C_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response) * - * For 4965 devices only; 3945 uses REPLY_RATE_SCALE. + * For 4965 devices only; 3945 uses C_RATE_SCALE. * * Each station in the 4965 device's internal station table has its own table * of 16 @@ -1903,7 +1903,7 @@ struct il_link_qual_agg_params { * one station. * * NOTE: Station must already be in 4965 device's station table. - * Use REPLY_ADD_STA. + * Use C_ADD_STA. * * The rate scaling procedures described below work well. Of course, other * procedures are possible, and may work better for particular environments. @@ -2117,7 +2117,7 @@ struct il_link_quality_cmd { #define BT_MAX_KILL_DEF (0x5) /* - * REPLY_BT_CONFIG = 0x9b (command, has simple generic response) + * C_BT_CONFIG = 0x9b (command, has simple generic response) * * 3945 and 4965 devices support hardware handshake with Bluetooth device on * same platform. Bluetooth device alerts wireless device when it will Tx; @@ -2159,7 +2159,7 @@ struct il_measure_channel { } __packed; /* - * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (command) + * C_SPECTRUM_MEASUREMENT = 0x74 (command) */ struct il_spectrum_cmd { __le16 len; /* number of bytes starting from token */ @@ -2178,7 +2178,7 @@ struct il_spectrum_cmd { } __packed; /* - * REPLY_SPECTRUM_MEASUREMENT_CMD = 0x74 (response) + * C_SPECTRUM_MEASUREMENT = 0x74 (response) */ struct il_spectrum_resp { u8 token; @@ -2228,7 +2228,7 @@ enum il_measure_type { }; /* - * SPECTRUM_MEASURE_NOTIFICATION = 0x75 (notification only, not a command) + * N_SPECTRUM_MEASUREMENT = 0x75 (notification only, not a command) */ struct il_spectrum_notification { u8 id; /* measurement id -- 0 or 1 */ @@ -2263,7 +2263,7 @@ struct il_spectrum_notification { * struct il_powertable_cmd - Power Table Command * @flags: See below: * - * POWER_TBL_CMD = 0x77 (command, has simple generic response) + * C_POWER_TBL = 0x77 (command, has simple generic response) * * PM allow: * bit 0 - '0' Driver not allow power management @@ -2318,7 +2318,7 @@ struct il_powertable_cmd { } __packed; /* - * PM_SLEEP_NOTIFICATION = 0x7A (notification only, not a command) + * N_PM_SLEEP = 0x7A (notification only, not a command) * all devices identical. */ struct il_sleep_notification { @@ -2346,7 +2346,7 @@ enum { }; /* - * CARD_STATE_NOTIFICATION = 0xa1 (notification only, not a command) + * N_CARD_STATE = 0xa1 (notification only, not a command) */ struct il_card_state_notif { __le32 flags; @@ -2373,7 +2373,7 @@ struct il_ct_kill_config { #define SCAN_CHANNEL_TYPE_ACTIVE cpu_to_le32(1) /** - * struct il_scan_channel - entry in REPLY_SCAN_CMD channel table + * struct il_scan_channel - entry in C_SCAN channel table * * One for each channel in the scan list. * Each channel can independently select: @@ -2431,7 +2431,7 @@ struct il_scan_channel { /** * struct il_ssid_ie - directed scan network information element * - * Up to 20 of these may appear in REPLY_SCAN_CMD (Note: Only 4 are in + * Up to 20 of these may appear in C_SCAN (Note: Only 4 are in * 3945 SCAN api), selected by "type" bit field in struct il_scan_channel; * each channel may select different ssids from among the 20 (4) entries. * SSID IEs get transmitted in reverse order of entry. @@ -2452,7 +2452,7 @@ struct il_ssid_ie { #define IL_MAX_CMD_SIZE 4096 /* - * REPLY_SCAN_CMD = 0x80 (command) + * C_SCAN = 0x80 (command) * * The hardware scan command is very powerful; the driver can set it up to * maintain (relatively) normal network traffic while doing a scan in the @@ -2542,7 +2542,7 @@ struct il3945_scan_cmd { * * NOTE: Only one band of channels can be scanned per pass. You * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait - * for one scan to complete (i.e. receive SCAN_COMPLETE_NOTIFICATION) + * for one scan to complete (i.e. receive N_SCAN_COMPLETE) * before requesting another scan. */ u8 data[0]; @@ -2586,7 +2586,7 @@ struct il_scan_cmd { * * NOTE: Only one band of channels can be scanned per pass. You * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait - * for one scan to complete (i.e. receive SCAN_COMPLETE_NOTIFICATION) + * for one scan to complete (i.e. receive N_SCAN_COMPLETE) * before requesting another scan. */ u8 data[0]; @@ -2598,14 +2598,14 @@ struct il_scan_cmd { #define ABORT_STATUS 0x2 /* - * REPLY_SCAN_CMD = 0x80 (response) + * C_SCAN = 0x80 (response) */ struct il_scanreq_notification { __le32 status; /* 1: okay, 2: cannot fulfill request */ } __packed; /* - * SCAN_START_NOTIFICATION = 0x82 (notification only, not a command) + * N_SCAN_START = 0x82 (notification only, not a command) */ struct il_scanstart_notification { __le32 tsf_low; @@ -2628,7 +2628,7 @@ struct il_scanstart_notification { #define NUMBER_OF_STATS 1 /* first __le32 is good CRC */ /* - * SCAN_RESULTS_NOTIFICATION = 0x83 (notification only, not a command) + * N_SCAN_RESULTS = 0x83 (notification only, not a command) */ struct il_scanresults_notification { u8 channel; @@ -2641,7 +2641,7 @@ struct il_scanresults_notification { } __packed; /* - * SCAN_COMPLETE_NOTIFICATION = 0x84 (notification only, not a command) + * N_SCAN_COMPLETE = 0x84 (notification only, not a command) */ struct il_scancomplete_notification { u8 scanned_channels; @@ -2664,7 +2664,7 @@ enum il_ibss_manager { }; /* - * BEACON_NOTIFICATION = 0x90 (notification only, not a command) + * N_BEACON = 0x90 (notification only, not a command) */ struct il3945_beacon_notif { @@ -2682,7 +2682,7 @@ struct il4965_beacon_notif { } __packed; /* - * REPLY_TX_BEACON = 0x91 (command, has simple generic response) + * C_TX_BEACON= 0x91 (command, has simple generic response) */ struct il3945_tx_beacon_cmd { @@ -2963,19 +2963,19 @@ struct stats_general { #define UCODE_STATS_NARROW_BAND_MSK (0x1 << 2) /* - * REPLY_STATS_CMD = 0x9c, + * C_STATS = 0x9c, * all devices identical. * * This command triggers an immediate response containing uCode stats. - * The response is in the same format as STATS_NOTIFICATION 0x9d, below. + * The response is in the same format as N_STATS 0x9d, below. * * If the CLEAR_STATS configuration flag is set, uCode will clear its * internal copy of the stats (counters) after issuing the response. - * This flag does not affect STATS_NOTIFICATIONs after beacons (see below). + * This flag does not affect N_STATSs after beacons (see below). * * If the DISABLE_NOTIF configuration flag is set, uCode will not issue - * STATS_NOTIFICATIONs after received beacons (see below). This flag - * does not affect the response to the REPLY_STATS_CMD 0x9c itself. + * N_STATSs after received beacons (see below). This flag + * does not affect the response to the C_STATS 0x9c itself. */ #define IL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1) /* see above */ #define IL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */ @@ -2984,14 +2984,14 @@ struct il_stats_cmd { } __packed; /* - * STATS_NOTIFICATION = 0x9d (notification only, not a command) + * N_STATS = 0x9d (notification only, not a command) * * By default, uCode issues this notification after receiving a beacon * while associated. To disable this behavior, set DISABLE_NOTIF flag in the - * REPLY_STATS_CMD 0x9c, above. + * C_STATS 0x9c, above. * * Statistics counters continue to increment beacon after beacon, but are - * cleared when changing channels or when driver issues REPLY_STATS_CMD + * cleared when changing channels or when driver issues C_STATS * 0x9c with CLEAR_STATS bit set (see above). * * uCode also issues this notification during scans. uCode clears stats @@ -3016,9 +3016,9 @@ struct il_notif_stats { } __packed; /* - * MISSED_BEACONS_NOTIFICATION = 0xa2 (notification only, not a command) + * N_MISSED_BEACONS = 0xa2 (notification only, not a command) * - * uCode send MISSED_BEACONS_NOTIFICATION to driver when detect beacon missed + * uCode send N_MISSED_BEACONS to driver when detect beacon missed * in regardless of how many missed beacons, which mean when driver receive the * notification, inside the command, it can find all the beacons information * which include number of total missed beacons, number of consecutive missed @@ -3062,7 +3062,7 @@ struct il_missed_beacon_notif { *****************************************************************************/ /** - * SENSITIVITY_CMD = 0xa8 (command, has simple generic response) + * C_SENSITIVITY = 0xa8 (command, has simple generic response) * * This command sets up the Rx signal detector for a sensitivity level that * is high enough to lock onto all signals within the associated network, @@ -3076,7 +3076,7 @@ struct il_missed_beacon_notif { * time listening, not transmitting). Driver must adjust sensitivity so that * the ratio of actual false alarms to actual Rx time falls within this range. * - * While associated, uCode delivers STATS_NOTIFICATIONs after each + * While associated, uCode delivers N_STATSs after each * received beacon. These provide information to the driver to analyze the * sensitivity. Don't analyze stats that come in from scanning, or any * other non-associated-network source. Pertinent stats include: @@ -3217,7 +3217,7 @@ struct il_missed_beacon_notif { */ /* - * Table entries in SENSITIVITY_CMD (struct il_sensitivity_cmd) + * Table entries in C_SENSITIVITY (struct il_sensitivity_cmd) */ #define HD_TBL_SIZE (11) /* number of entries */ #define HD_MIN_ENERGY_CCK_DET_IDX (0) /* table idxes */ @@ -3233,8 +3233,8 @@ struct il_missed_beacon_notif { #define HD_OFDM_ENERGY_TH_IN_IDX (10) /* Control field in struct il_sensitivity_cmd */ -#define SENSITIVITY_CMD_CONTROL_DEFAULT_TBL cpu_to_le16(0) -#define SENSITIVITY_CMD_CONTROL_WORK_TBL cpu_to_le16(1) +#define C_SENSITIVITY_CONTROL_DEFAULT_TBL cpu_to_le16(0) +#define C_SENSITIVITY_CONTROL_WORK_TBL cpu_to_le16(1) /** * struct il_sensitivity_cmd @@ -3250,12 +3250,12 @@ struct il_sensitivity_cmd { /** - * REPLY_PHY_CALIBRATION_CMD = 0xb0 (command, has simple generic response) + * C_PHY_CALIBRATION = 0xb0 (command, has simple generic response) * * This command sets the relative gains of 4965 device's 3 radio receiver chains. * * After the first association, driver should accumulate signal and noise - * stats from the STATS_NOTIFICATIONs that follow the first 20 + * stats from the N_STATSs that follow the first 20 * beacons from the associated network (don't collect stats that come * in from scanning, or any other non-network source). * @@ -3338,7 +3338,7 @@ struct il_calib_diff_gain_cmd { /* * LEDs Command & Response - * REPLY_LEDS_CMD = 0x48 (command, has simple generic response) + * C_LEDS = 0x48 (command, has simple generic response) * * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field), * this command turns it on or off, or sets up a periodic blinking cycle. diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index e6c7d5f77e78..baed3dc082dc 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -1165,7 +1165,7 @@ void il_send_bt_config(struct il_priv *il) D_INFO("BT coex %s\n", (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active"); - if (il_send_cmd_pdu(il, REPLY_BT_CONFIG, + if (il_send_cmd_pdu(il, C_BT_CONFIG, sizeof(struct il_bt_cmd), &bt_cmd)) IL_ERR("failed to send BT Coex Config\n"); } @@ -1179,11 +1179,11 @@ int il_send_stats_request(struct il_priv *il, u8 flags, bool clear) }; if (flags & CMD_ASYNC) - return il_send_cmd_pdu_async(il, REPLY_STATS_CMD, + return il_send_cmd_pdu_async(il, C_STATS, sizeof(struct il_stats_cmd), &stats_cmd, NULL); else - return il_send_cmd_pdu(il, REPLY_STATS_CMD, + return il_send_cmd_pdu(il, C_STATS, sizeof(struct il_stats_cmd), &stats_cmd); } diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index b9888ac0f518..4076b79e593e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -554,7 +554,7 @@ static ssize_t il_dbgfs_interrupt_read(struct file *file, pos += scnprintf(buf + pos, bufsz - pos, "Rx command responses:\t\t %u\n", il->isr_stats.rx); - for (cnt = 0; cnt < REPLY_MAX; cnt++) { + for (cnt = 0; cnt < IL_CN_MAX; cnt++) { if (il->isr_stats.rx_handlers[cnt] > 0) pos += scnprintf(buf + pos, bufsz - pos, "\tRx handler[%36s]:\t\t %u\n", diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index f7c3b43ae049..1bc4a71ac00f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -383,8 +383,8 @@ struct il_rx_queue { * @bitmap1: High order, one bit for each frame pending ACK in Tx win * @rate_n_flags: Rate at which Tx was attempted * - * If REPLY_TX indicates that aggregation was attempted, driver must wait - * for block ack (REPLY_COMPRESSED_BA). This struct stores tx reply info + * If C_TX indicates that aggregation was attempted, driver must wait + * for block ack (N_COMPRESSED_BA). This struct stores tx reply info * until block ack arrives. */ struct il_ht_agg { @@ -813,7 +813,7 @@ struct isr_stats { u32 ctkill; u32 wakeup; u32 rx; - u32 rx_handlers[REPLY_MAX]; + u32 rx_handlers[IL_CN_MAX]; u32 tx; u32 unhandled; }; @@ -968,7 +968,7 @@ struct il_priv { enum ieee80211_band band; int alloc_rxb_page; - void (*rx_handlers[REPLY_MAX])(struct il_priv *il, + void (*rx_handlers[IL_CN_MAX])(struct il_priv *il, struct il_rx_buf *rxb); struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; diff --git a/drivers/net/wireless/iwlegacy/iwl-hcmd.c b/drivers/net/wireless/iwlegacy/iwl-hcmd.c index 19a59558e247..670a398e0975 100644 --- a/drivers/net/wireless/iwlegacy/iwl-hcmd.c +++ b/drivers/net/wireless/iwlegacy/iwl-hcmd.c @@ -40,47 +40,47 @@ const char *il_get_cmd_string(u8 cmd) { switch (cmd) { - IL_CMD(REPLY_ALIVE); - IL_CMD(REPLY_ERROR); - IL_CMD(REPLY_RXON); - IL_CMD(REPLY_RXON_ASSOC); - IL_CMD(REPLY_QOS_PARAM); - IL_CMD(REPLY_RXON_TIMING); - IL_CMD(REPLY_ADD_STA); - IL_CMD(REPLY_REMOVE_STA); - IL_CMD(REPLY_WEPKEY); - IL_CMD(REPLY_3945_RX); - IL_CMD(REPLY_TX); - IL_CMD(REPLY_RATE_SCALE); - IL_CMD(REPLY_LEDS_CMD); - IL_CMD(REPLY_TX_LINK_QUALITY_CMD); - IL_CMD(REPLY_CHANNEL_SWITCH); - IL_CMD(CHANNEL_SWITCH_NOTIFICATION); - IL_CMD(REPLY_SPECTRUM_MEASUREMENT_CMD); - IL_CMD(SPECTRUM_MEASURE_NOTIFICATION); - IL_CMD(POWER_TBL_CMD); - IL_CMD(PM_SLEEP_NOTIFICATION); - IL_CMD(PM_DEBUG_STATISTIC_NOTIFIC); - IL_CMD(REPLY_SCAN_CMD); - IL_CMD(REPLY_SCAN_ABORT_CMD); - IL_CMD(SCAN_START_NOTIFICATION); - IL_CMD(SCAN_RESULTS_NOTIFICATION); - IL_CMD(SCAN_COMPLETE_NOTIFICATION); - IL_CMD(BEACON_NOTIFICATION); - IL_CMD(REPLY_TX_BEACON); - IL_CMD(REPLY_TX_PWR_TBL_CMD); - IL_CMD(REPLY_BT_CONFIG); - IL_CMD(REPLY_STATS_CMD); - IL_CMD(STATS_NOTIFICATION); - IL_CMD(CARD_STATE_NOTIFICATION); - IL_CMD(MISSED_BEACONS_NOTIFICATION); - IL_CMD(REPLY_CT_KILL_CONFIG_CMD); - IL_CMD(SENSITIVITY_CMD); - IL_CMD(REPLY_PHY_CALIBRATION_CMD); - IL_CMD(REPLY_RX_PHY_CMD); - IL_CMD(REPLY_RX_MPDU_CMD); - IL_CMD(REPLY_RX); - IL_CMD(REPLY_COMPRESSED_BA); + IL_CMD(N_ALIVE); + IL_CMD(N_ERROR); + IL_CMD(C_RXON); + IL_CMD(C_RXON_ASSOC); + IL_CMD(C_QOS_PARAM); + IL_CMD(C_RXON_TIMING); + IL_CMD(C_ADD_STA); + IL_CMD(C_REM_STA); + IL_CMD(C_WEPKEY); + IL_CMD(N_3945_RX); + IL_CMD(C_TX); + IL_CMD(C_RATE_SCALE); + IL_CMD(C_LEDS); + IL_CMD(C_TX_LINK_QUALITY_CMD); + IL_CMD(C_CHANNEL_SWITCH); + IL_CMD(N_CHANNEL_SWITCH); + IL_CMD(C_SPECTRUM_MEASUREMENT); + IL_CMD(N_SPECTRUM_MEASUREMENT); + IL_CMD(C_POWER_TBL); + IL_CMD(N_PM_SLEEP); + IL_CMD(N_PM_DEBUG_STATS); + IL_CMD(C_SCAN); + IL_CMD(C_SCAN_ABORT); + IL_CMD(N_SCAN_START); + IL_CMD(N_SCAN_RESULTS); + IL_CMD(N_SCAN_COMPLETE); + IL_CMD(N_BEACON); + IL_CMD(C_TX_BEACON); + IL_CMD(C_TX_PWR_TBL); + IL_CMD(C_BT_CONFIG); + IL_CMD(C_STATS); + IL_CMD(N_STATS); + IL_CMD(N_CARD_STATE); + IL_CMD(N_MISSED_BEACONS); + IL_CMD(C_CT_KILL_CONFIG); + IL_CMD(C_SENSITIVITY); + IL_CMD(C_PHY_CALIBRATION); + IL_CMD(N_RX_PHY); + IL_CMD(N_RX_MPDU); + IL_CMD(N_RX); + IL_CMD(N_COMPRESSED_BA); default: return "UNKNOWN"; @@ -102,8 +102,8 @@ static void il_generic_cmd_callback(struct il_priv *il, #ifdef CONFIG_IWLEGACY_DEBUG switch (cmd->hdr.cmd) { - case REPLY_TX_LINK_QUALITY_CMD: - case SENSITIVITY_CMD: + case C_TX_LINK_QUALITY_CMD: + case C_SENSITIVITY: D_HC_DUMP("back from %s (0x%08X)\n", il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); break; diff --git a/drivers/net/wireless/iwlegacy/iwl-power.c b/drivers/net/wireless/iwlegacy/iwl-power.c index c66a0f77dc32..2b06a95f97f0 100644 --- a/drivers/net/wireless/iwlegacy/iwl-power.c +++ b/drivers/net/wireless/iwlegacy/iwl-power.c @@ -88,7 +88,7 @@ il_set_power(struct il_priv *il, struct il_powertable_cmd *cmd) le32_to_cpu(cmd->sleep_interval[3]), le32_to_cpu(cmd->sleep_interval[4])); - return il_send_cmd_pdu(il, POWER_TBL_CMD, + return il_send_cmd_pdu(il, C_POWER_TBL, sizeof(struct il_powertable_cmd), cmd); } diff --git a/drivers/net/wireless/iwlegacy/iwl-prph.h b/drivers/net/wireless/iwlegacy/iwl-prph.h index b0bf6848bd1d..029ea8a83dff 100644 --- a/drivers/net/wireless/iwlegacy/iwl-prph.h +++ b/drivers/net/wireless/iwlegacy/iwl-prph.h @@ -189,7 +189,7 @@ * procedure. * * This save/restore method is mostly for autonomous power management during - * normal operation (result of POWER_TBL_CMD). Platform suspend/resume and + * normal operation (result of C_POWER_TBL). Platform suspend/resume and * RFKILL should use complete restarts (with total re-initialization) of uCode, * allowing total shutdown (including BSM memory). * diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index 6d20f2b64c3e..1f81d56ad8ac 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -59,7 +59,7 @@ static int il_send_scan_abort(struct il_priv *il) int ret; struct il_rx_pkt *pkt; struct il_host_cmd cmd = { - .id = REPLY_SCAN_ABORT_CMD, + .id = C_SCAN_ABORT, .flags = CMD_WANT_SKB, }; @@ -181,7 +181,7 @@ int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms) } EXPORT_SYMBOL(il_scan_cancel_timeout); -/* Service response to REPLY_SCAN_CMD (0x80) */ +/* Service response to C_SCAN (0x80) */ static void il_rx_reply_scan(struct il_priv *il, struct il_rx_buf *rxb) { @@ -194,7 +194,7 @@ static void il_rx_reply_scan(struct il_priv *il, #endif } -/* Service SCAN_START_NOTIFICATION (0x82) */ +/* Service N_SCAN_START (0x82) */ static void il_rx_scan_start_notif(struct il_priv *il, struct il_rx_buf *rxb) { @@ -212,7 +212,7 @@ static void il_rx_scan_start_notif(struct il_priv *il, notif->status, notif->beacon_timer); } -/* Service SCAN_RESULTS_NOTIFICATION (0x83) */ +/* Service N_SCAN_RESULTS (0x83) */ static void il_rx_scan_results_notif(struct il_priv *il, struct il_rx_buf *rxb) { @@ -234,7 +234,7 @@ static void il_rx_scan_results_notif(struct il_priv *il, #endif } -/* Service SCAN_COMPLETE_NOTIFICATION (0x84) */ +/* Service N_SCAN_COMPLETE (0x84) */ static void il_rx_scan_complete_notif(struct il_priv *il, struct il_rx_buf *rxb) { @@ -263,12 +263,12 @@ static void il_rx_scan_complete_notif(struct il_priv *il, void il_setup_rx_scan_handlers(struct il_priv *il) { /* scan handlers */ - il->rx_handlers[REPLY_SCAN_CMD] = il_rx_reply_scan; - il->rx_handlers[SCAN_START_NOTIFICATION] = + il->rx_handlers[C_SCAN] = il_rx_reply_scan; + il->rx_handlers[N_SCAN_START] = il_rx_scan_start_notif; - il->rx_handlers[SCAN_RESULTS_NOTIFICATION] = + il->rx_handlers[N_SCAN_RESULTS] = il_rx_scan_results_notif; - il->rx_handlers[SCAN_COMPLETE_NOTIFICATION] = + il->rx_handlers[N_SCAN_COMPLETE] = il_rx_scan_complete_notif; } EXPORT_SYMBOL(il_setup_rx_scan_handlers); diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.c b/drivers/net/wireless/iwlegacy/iwl-sta.c index ffb966bf836d..58762e795f36 100644 --- a/drivers/net/wireless/iwlegacy/iwl-sta.c +++ b/drivers/net/wireless/iwlegacy/iwl-sta.c @@ -67,7 +67,7 @@ static int il_process_add_sta_resp(struct il_priv *il, int ret = -EIO; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR("Bad return from REPLY_ADD_STA (0x%08X)\n", + IL_ERR("Bad return from C_ADD_STA (0x%08X)\n", pkt->hdr.flags); return ret; } @@ -79,7 +79,7 @@ static int il_process_add_sta_resp(struct il_priv *il, switch (pkt->u.add_sta.status) { case ADD_STA_SUCCESS_MSK: - D_INFO("REPLY_ADD_STA PASSED\n"); + D_INFO("C_ADD_STA PASSED\n"); il_sta_ucode_activate(il, sta_id); ret = 0; break; @@ -97,7 +97,7 @@ static int il_process_add_sta_resp(struct il_priv *il, sta_id); break; default: - D_ASSOC("Received REPLY_ADD_STA:(0x%08X)\n", + D_ASSOC("Received C_ADD_STA:(0x%08X)\n", pkt->u.add_sta.status); break; } @@ -142,7 +142,7 @@ int il_send_add_sta(struct il_priv *il, int ret = 0; u8 data[sizeof(*sta)]; struct il_host_cmd cmd = { - .id = REPLY_ADD_STA, + .id = C_ADD_STA, .flags = flags, .data = data, }; @@ -290,7 +290,7 @@ u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, sta_id, addr); il->num_stations++; - /* Set up the REPLY_ADD_STA command to send to device */ + /* Set up the C_ADD_STA command to send to device */ memset(&station->sta, 0, sizeof(struct il_addsta_cmd)); memcpy(station->sta.sta.addr, addr, ETH_ALEN); station->sta.mode = 0; @@ -421,7 +421,7 @@ static int il_send_remove_station(struct il_priv *il, struct il_rem_sta_cmd rm_sta_cmd; struct il_host_cmd cmd = { - .id = REPLY_REMOVE_STA, + .id = C_REM_STA, .len = sizeof(struct il_rem_sta_cmd), .flags = CMD_SYNC, .data = &rm_sta_cmd, @@ -440,7 +440,7 @@ static int il_send_remove_station(struct il_priv *il, pkt = (struct il_rx_pkt *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR("Bad return from REPLY_REMOVE_STA (0x%08X)\n", + IL_ERR("Bad return from C_REM_STA (0x%08X)\n", pkt->hdr.flags); ret = -EIO; } @@ -454,11 +454,11 @@ static int il_send_remove_station(struct il_priv *il, spin_unlock_irqrestore(&il->sta_lock, flags_spin); } - D_ASSOC("REPLY_REMOVE_STA PASSED\n"); + D_ASSOC("C_REM_STA PASSED\n"); break; default: ret = -EIO; - IL_ERR("REPLY_REMOVE_STA failed\n"); + IL_ERR("C_REM_STA failed\n"); break; } } @@ -753,7 +753,7 @@ int il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, unsigned long flags_spin; struct il_host_cmd cmd = { - .id = REPLY_TX_LINK_QUALITY_CMD, + .id = C_TX_LINK_QUALITY_CMD, .len = sizeof(struct il_link_quality_cmd), .flags = flags, .data = lq, diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c index 3f97d09fa00a..3b588b39fd67 100644 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ b/drivers/net/wireless/iwlegacy/iwl-tx.c @@ -509,8 +509,8 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) #ifdef CONFIG_IWLEGACY_DEBUG switch (out_cmd->hdr.cmd) { - case REPLY_TX_LINK_QUALITY_CMD: - case SENSITIVITY_CMD: + case C_TX_LINK_QUALITY_CMD: + case C_SENSITIVITY: D_HC_DUMP( "Sending command %s (#%x), seq: 0x%04X, " "%d bytes at %d[%d]:%d\n", -- cgit v1.2.3 From d0c72347bece3299a90351151c69c0f721f964ff Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 30 Aug 2011 15:39:42 +0200 Subject: iwlegacy: s/rx_handler/handler/ Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/3945-mac.c | 42 ++++++++++++------------- drivers/net/wireless/iwlegacy/3945.c | 6 ++-- drivers/net/wireless/iwlegacy/3945.h | 2 +- drivers/net/wireless/iwlegacy/4965-mac.c | 48 ++++++++++++++--------------- drivers/net/wireless/iwlegacy/4965.c | 10 +++--- drivers/net/wireless/iwlegacy/iwl-core.h | 2 +- drivers/net/wireless/iwlegacy/iwl-debugfs.c | 4 +-- drivers/net/wireless/iwlegacy/iwl-dev.h | 4 +-- drivers/net/wireless/iwlegacy/iwl-scan.c | 8 ++--- 9 files changed, 63 insertions(+), 63 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 65cab84661ef..fa5e03841015 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -843,7 +843,7 @@ static void il3945_rx_card_state_notif(struct il_priv *il, } /** - * il3945_setup_rx_handlers - Initialize Rx handler callbacks + * il3945_setup_handlers - Initialize Rx handler callbacks * * Setup the RX handlers for each of the reply types sent from the uCode * to the host. @@ -851,32 +851,32 @@ static void il3945_rx_card_state_notif(struct il_priv *il, * This function chains into the hardware specific files for them to setup * any hardware specific handlers as well. */ -static void il3945_setup_rx_handlers(struct il_priv *il) +static void il3945_setup_handlers(struct il_priv *il) { - il->rx_handlers[N_ALIVE] = il3945_rx_reply_alive; - il->rx_handlers[C_ADD_STA] = il3945_rx_reply_add_sta; - il->rx_handlers[N_ERROR] = il_rx_reply_error; - il->rx_handlers[N_CHANNEL_SWITCH] = il_rx_csa; - il->rx_handlers[N_SPECTRUM_MEASUREMENT] = + il->handlers[N_ALIVE] = il3945_rx_reply_alive; + il->handlers[C_ADD_STA] = il3945_rx_reply_add_sta; + il->handlers[N_ERROR] = il_rx_reply_error; + il->handlers[N_CHANNEL_SWITCH] = il_rx_csa; + il->handlers[N_SPECTRUM_MEASUREMENT] = il_rx_spectrum_measure_notif; - il->rx_handlers[N_PM_SLEEP] = il_rx_pm_sleep_notif; - il->rx_handlers[N_PM_DEBUG_STATS] = + il->handlers[N_PM_SLEEP] = il_rx_pm_sleep_notif; + il->handlers[N_PM_DEBUG_STATS] = il_rx_pm_debug_stats_notif; - il->rx_handlers[N_BEACON] = il3945_rx_beacon_notif; + il->handlers[N_BEACON] = il3945_rx_beacon_notif; /* * The same handler is used for both the REPLY to a discrete * stats request from the host as well as for the periodic * stats notifications (after received beacons) from the uCode. */ - il->rx_handlers[C_STATS] = il3945_reply_stats; - il->rx_handlers[N_STATS] = il3945_hw_rx_stats; + il->handlers[C_STATS] = il3945_reply_stats; + il->handlers[N_STATS] = il3945_hw_rx_stats; il_setup_rx_scan_handlers(il); - il->rx_handlers[N_CARD_STATE] = il3945_rx_card_state_notif; + il->handlers[N_CARD_STATE] = il3945_rx_card_state_notif; /* Set up hardware specific Rx handlers */ - il3945_hw_rx_handler_setup(il); + il3945_hw_handler_setup(il); } /************************** RX-FUNCTIONS ****************************/ @@ -1194,7 +1194,7 @@ int il3945_calc_db_from_ratio(int sig_ratio) /** * il3945_rx_handle - Main entry function for receiving responses from uCode * - * Uses the il->rx_handlers callback function array to invoke + * Uses the il->handlers callback function array to invoke * the appropriate handlers, including command responses, * frame-received notifications, and other notifications. */ @@ -1258,12 +1258,12 @@ static void il3945_rx_handle(struct il_priv *il) /* Based on type of command response or notification, * handle those that need handling via function in - * rx_handlers table. See il3945_setup_rx_handlers() */ - if (il->rx_handlers[pkt->hdr.cmd]) { + * handlers table. See il3945_setup_handlers() */ + if (il->handlers[pkt->hdr.cmd]) { D_RX("r = %d, i = %d, %s, 0x%02x\n", r, i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); - il->isr_stats.rx_handlers[pkt->hdr.cmd]++; - il->rx_handlers[pkt->hdr.cmd] (il, rxb); + il->isr_stats.handlers[pkt->hdr.cmd]++; + il->handlers[pkt->hdr.cmd] (il, rxb); } else { /* No handling needed */ D_RX( @@ -1275,7 +1275,7 @@ static void il3945_rx_handle(struct il_priv *il) /* * XXX: After here, we should always check rxb->page * against NULL before touching it or its virtual - * memory (pkt). Because some rx_handler might have + * memory (pkt). Because some handler might have * already taken or freed the pages. */ @@ -3807,7 +3807,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en &il->bands[IEEE80211_BAND_2GHZ].channels[5], &il->ctx); il3945_setup_deferred_work(il); - il3945_setup_rx_handlers(il); + il3945_setup_handlers(il); il_power_initialize(il); /********************************* diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index ba250f7e8fb3..94d540c22e13 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -2462,10 +2462,10 @@ unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, return sizeof(struct il3945_tx_beacon_cmd) + frame_size; } -void il3945_hw_rx_handler_setup(struct il_priv *il) +void il3945_hw_handler_setup(struct il_priv *il) { - il->rx_handlers[C_TX] = il3945_rx_reply_tx; - il->rx_handlers[N_3945_RX] = il3945_rx_reply_rx; + il->handlers[C_TX] = il3945_rx_reply_tx; + il->handlers[N_3945_RX] = il3945_rx_reply_rx; } void il3945_hw_setup_deferred_work(struct il_priv *il) diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index d65565f7c871..6000aff4798c 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -225,7 +225,7 @@ extern void il3945_dump_nic_error_log(struct il_priv *il); * il3945_mac_ <-- mac80211 callback * ****************************************************************************/ -extern void il3945_hw_rx_handler_setup(struct il_priv *il); +extern void il3945_hw_handler_setup(struct il_priv *il); extern void il3945_hw_setup_deferred_work(struct il_priv *il); extern void il3945_hw_cancel_deferred_work(struct il_priv *il); extern int il3945_hw_rxq_stop(struct il_priv *il); diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 098d86397d91..d82d05fa8515 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -3911,7 +3911,7 @@ static void il4965_rx_card_state_notif(struct il_priv *il, } /** - * il4965_setup_rx_handlers - Initialize Rx handler callbacks + * il4965_setup_handlers - Initialize Rx handler callbacks * * Setup the RX handlers for each of the reply types sent from the uCode * to the host. @@ -3919,47 +3919,47 @@ static void il4965_rx_card_state_notif(struct il_priv *il, * This function chains into the hardware specific files for them to setup * any hardware specific handlers as well. */ -static void il4965_setup_rx_handlers(struct il_priv *il) +static void il4965_setup_handlers(struct il_priv *il) { - il->rx_handlers[N_ALIVE] = il4965_rx_reply_alive; - il->rx_handlers[N_ERROR] = il_rx_reply_error; - il->rx_handlers[N_CHANNEL_SWITCH] = il_rx_csa; - il->rx_handlers[N_SPECTRUM_MEASUREMENT] = + il->handlers[N_ALIVE] = il4965_rx_reply_alive; + il->handlers[N_ERROR] = il_rx_reply_error; + il->handlers[N_CHANNEL_SWITCH] = il_rx_csa; + il->handlers[N_SPECTRUM_MEASUREMENT] = il_rx_spectrum_measure_notif; - il->rx_handlers[N_PM_SLEEP] = il_rx_pm_sleep_notif; - il->rx_handlers[N_PM_DEBUG_STATS] = + il->handlers[N_PM_SLEEP] = il_rx_pm_sleep_notif; + il->handlers[N_PM_DEBUG_STATS] = il_rx_pm_debug_stats_notif; - il->rx_handlers[N_BEACON] = il4965_rx_beacon_notif; + il->handlers[N_BEACON] = il4965_rx_beacon_notif; /* * The same handler is used for both the REPLY to a discrete * stats request from the host as well as for the periodic * stats notifications (after received beacons) from the uCode. */ - il->rx_handlers[C_STATS] = il4965_reply_stats; - il->rx_handlers[N_STATS] = il4965_rx_stats; + il->handlers[C_STATS] = il4965_reply_stats; + il->handlers[N_STATS] = il4965_rx_stats; il_setup_rx_scan_handlers(il); /* status change handler */ - il->rx_handlers[N_CARD_STATE] = + il->handlers[N_CARD_STATE] = il4965_rx_card_state_notif; - il->rx_handlers[N_MISSED_BEACONS] = + il->handlers[N_MISSED_BEACONS] = il4965_rx_missed_beacon_notif; /* Rx handlers */ - il->rx_handlers[N_RX_PHY] = il4965_rx_reply_rx_phy; - il->rx_handlers[N_RX_MPDU] = il4965_rx_reply_rx; + il->handlers[N_RX_PHY] = il4965_rx_reply_rx_phy; + il->handlers[N_RX_MPDU] = il4965_rx_reply_rx; /* block ack */ - il->rx_handlers[N_COMPRESSED_BA] = il4965_rx_reply_compressed_ba; + il->handlers[N_COMPRESSED_BA] = il4965_rx_reply_compressed_ba; /* Set up hardware specific Rx handlers */ - il->cfg->ops->lib->rx_handler_setup(il); + il->cfg->ops->lib->handler_setup(il); } /** * il4965_rx_handle - Main entry function for receiving responses from uCode * - * Uses the il->rx_handlers callback function array to invoke + * Uses the il->handlers callback function array to invoke * the appropriate handlers, including command responses, * frame-received notifications, and other notifications. */ @@ -4028,13 +4028,13 @@ void il4965_rx_handle(struct il_priv *il) /* Based on type of command response or notification, * handle those that need handling via function in - * rx_handlers table. See il4965_setup_rx_handlers() */ - if (il->rx_handlers[pkt->hdr.cmd]) { + * handlers table. See il4965_setup_handlers() */ + if (il->handlers[pkt->hdr.cmd]) { D_RX("r = %d, i = %d, %s, 0x%02x\n", r, i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); - il->isr_stats.rx_handlers[pkt->hdr.cmd]++; - il->rx_handlers[pkt->hdr.cmd] (il, rxb); + il->isr_stats.handlers[pkt->hdr.cmd]++; + il->handlers[pkt->hdr.cmd] (il, rxb); } else { /* No handling needed */ D_RX( @@ -4046,7 +4046,7 @@ void il4965_rx_handle(struct il_priv *il) /* * XXX: After here, we should always check rxb->page * against NULL before touching it or its virtual - * memory (pkt). Because some rx_handler might have + * memory (pkt). Because some handler might have * already taken or freed the pages. */ @@ -6358,7 +6358,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) } il4965_setup_deferred_work(il); - il4965_setup_rx_handlers(il); + il4965_setup_handlers(il); /********************************************* * 8. Enable interrupts and read RFKILL state diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 3b101c142171..f48cb89deab7 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -2142,13 +2142,13 @@ static void il4965_rx_beacon_notif(struct il_priv *il, } /* Set up 4965-specific Rx frame reply handlers */ -static void il4965_rx_handler_setup(struct il_priv *il) +static void il4965_handler_setup(struct il_priv *il) { /* Legacy Rx frames */ - il->rx_handlers[N_RX] = il4965_rx_reply_rx; + il->handlers[N_RX] = il4965_rx_reply_rx; /* Tx response */ - il->rx_handlers[C_TX] = il4965_rx_reply_tx; - il->rx_handlers[N_BEACON] = il4965_rx_beacon_notif; + il->handlers[C_TX] = il4965_rx_reply_tx; + il->handlers[N_BEACON] = il4965_rx_beacon_notif; } static struct il_hcmd_ops il4965_hcmd = { @@ -2316,7 +2316,7 @@ static struct il_lib_ops il4965_lib = { .txq_attach_buf_to_tfd = il4965_hw_txq_attach_buf_to_tfd, .txq_free_tfd = il4965_hw_txq_free_tfd, .txq_init = il4965_hw_tx_queue_init, - .rx_handler_setup = il4965_rx_handler_setup, + .handler_setup = il4965_handler_setup, .is_valid_rtc_data_addr = il4965_hw_valid_rtc_data_addr, .init_alive_start = il4965_init_alive_start, .load_ucode = il4965_load_bsm, diff --git a/drivers/net/wireless/iwlegacy/iwl-core.h b/drivers/net/wireless/iwlegacy/iwl-core.h index e275ffc9f7e0..a3701a6c8632 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.h +++ b/drivers/net/wireless/iwlegacy/iwl-core.h @@ -136,7 +136,7 @@ struct il_lib_ops { int (*txq_init)(struct il_priv *il, struct il_tx_queue *txq); /* setup Rx handler */ - void (*rx_handler_setup)(struct il_priv *il); + void (*handler_setup)(struct il_priv *il); /* alive notification after init uCode load */ void (*init_alive_start)(struct il_priv *il); /* check validity of rtc data address */ diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index 4076b79e593e..3f6b06e99d2f 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -555,11 +555,11 @@ static ssize_t il_dbgfs_interrupt_read(struct file *file, "Rx command responses:\t\t %u\n", il->isr_stats.rx); for (cnt = 0; cnt < IL_CN_MAX; cnt++) { - if (il->isr_stats.rx_handlers[cnt] > 0) + if (il->isr_stats.handlers[cnt] > 0) pos += scnprintf(buf + pos, bufsz - pos, "\tRx handler[%36s]:\t\t %u\n", il_get_cmd_string(cnt), - il->isr_stats.rx_handlers[cnt]); + il->isr_stats.handlers[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n", diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 1bc4a71ac00f..2ebd807ee16e 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -813,7 +813,7 @@ struct isr_stats { u32 ctkill; u32 wakeup; u32 rx; - u32 rx_handlers[IL_CN_MAX]; + u32 handlers[IL_CN_MAX]; u32 tx; u32 unhandled; }; @@ -968,7 +968,7 @@ struct il_priv { enum ieee80211_band band; int alloc_rxb_page; - void (*rx_handlers[IL_CN_MAX])(struct il_priv *il, + void (*handlers[IL_CN_MAX])(struct il_priv *il, struct il_rx_buf *rxb); struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index 1f81d56ad8ac..2bed3ae914c2 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -263,12 +263,12 @@ static void il_rx_scan_complete_notif(struct il_priv *il, void il_setup_rx_scan_handlers(struct il_priv *il) { /* scan handlers */ - il->rx_handlers[C_SCAN] = il_rx_reply_scan; - il->rx_handlers[N_SCAN_START] = + il->handlers[C_SCAN] = il_rx_reply_scan; + il->handlers[N_SCAN_START] = il_rx_scan_start_notif; - il->rx_handlers[N_SCAN_RESULTS] = + il->handlers[N_SCAN_RESULTS] = il_rx_scan_results_notif; - il->rx_handlers[N_SCAN_COMPLETE] = + il->handlers[N_SCAN_COMPLETE] = il_rx_scan_complete_notif; } EXPORT_SYMBOL(il_setup_rx_scan_handlers); -- cgit v1.2.3 From 6e9848b496cf256ba820094e88e78cc4f8304008 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 30 Aug 2011 15:45:31 +0200 Subject: iwlegacy: s/rx_reply/hdl/ Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/3945-mac.c | 10 +++++----- drivers/net/wireless/iwlegacy/3945.c | 10 +++++----- drivers/net/wireless/iwlegacy/4965-mac.c | 22 +++++++++++----------- drivers/net/wireless/iwlegacy/4965.c | 8 ++++---- drivers/net/wireless/iwlegacy/4965.h | 6 +++--- drivers/net/wireless/iwlegacy/iwl-core.c | 4 ++-- drivers/net/wireless/iwlegacy/iwl-core.h | 2 +- drivers/net/wireless/iwlegacy/iwl-scan.c | 4 ++-- 8 files changed, 33 insertions(+), 33 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index fa5e03841015..e9a1e64a3a16 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -743,7 +743,7 @@ static int il3945_get_measurement(struct il_priv *il, return rc; } -static void il3945_rx_reply_alive(struct il_priv *il, +static void il3945_hdl_alive(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -779,7 +779,7 @@ static void il3945_rx_reply_alive(struct il_priv *il, IL_WARN("uCode did not respond OK.\n"); } -static void il3945_rx_reply_add_sta(struct il_priv *il, +static void il3945_hdl_add_sta(struct il_priv *il, struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG @@ -853,9 +853,9 @@ static void il3945_rx_card_state_notif(struct il_priv *il, */ static void il3945_setup_handlers(struct il_priv *il) { - il->handlers[N_ALIVE] = il3945_rx_reply_alive; - il->handlers[C_ADD_STA] = il3945_rx_reply_add_sta; - il->handlers[N_ERROR] = il_rx_reply_error; + il->handlers[N_ALIVE] = il3945_hdl_alive; + il->handlers[C_ADD_STA] = il3945_hdl_add_sta; + il->handlers[N_ERROR] = il_hdl_error; il->handlers[N_CHANNEL_SWITCH] = il_rx_csa; il->handlers[N_SPECTRUM_MEASUREMENT] = il_rx_spectrum_measure_notif; diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 94d540c22e13..b45905fca76b 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -315,9 +315,9 @@ static void il3945_tx_queue_reclaim(struct il_priv *il, } /** - * il3945_rx_reply_tx - Handle Tx response + * il3945_hdl_tx - Handle Tx response */ -static void il3945_rx_reply_tx(struct il_priv *il, +static void il3945_hdl_tx(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -521,7 +521,7 @@ static void il3945_pass_packet_to_mac80211(struct il_priv *il, #define IL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6) -static void il3945_rx_reply_rx(struct il_priv *il, +static void il3945_hdl_rx(struct il_priv *il, struct il_rx_buf *rxb) { struct ieee80211_hdr *header; @@ -2464,8 +2464,8 @@ unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, void il3945_hw_handler_setup(struct il_priv *il) { - il->handlers[C_TX] = il3945_rx_reply_tx; - il->handlers[N_3945_RX] = il3945_rx_reply_rx; + il->handlers[C_TX] = il3945_hdl_tx; + il->handlers[N_3945_RX] = il3945_hdl_rx; } void il3945_hw_setup_deferred_work(struct il_priv *il) diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index d82d05fa8515..0797c1141128 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -610,7 +610,7 @@ static void il4965_pass_packet_to_mac80211(struct il_priv *il, /* Called for N_RX (legacy ABG frames), or * N_RX_MPDU (HT high-throughput N frames). */ -void il4965_rx_reply_rx(struct il_priv *il, +void il4965_hdl_rx(struct il_priv *il, struct il_rx_buf *rxb) { struct ieee80211_hdr *header; @@ -729,8 +729,8 @@ void il4965_rx_reply_rx(struct il_priv *il, } /* Cache phy data (Rx signal strength, etc) for HT frame (N_RX_PHY). - * This will be used later in il_rx_reply_rx() for N_RX_MPDU. */ -void il4965_rx_reply_rx_phy(struct il_priv *il, + * This will be used later in il_hdl_rx() for N_RX_MPDU. */ +void il4965_hdl_rx_phy(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -2616,12 +2616,12 @@ void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, } /** - * il4965_rx_reply_compressed_ba - Handler for N_COMPRESSED_BA + * il4965_hdl_compressed_ba - Handler for N_COMPRESSED_BA * * Handles block-acknowledge notification from device, which reports success * of frames sent via aggregation. */ -void il4965_rx_reply_compressed_ba(struct il_priv *il, +void il4965_hdl_compressed_ba(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -3759,7 +3759,7 @@ int il4965_hw_tx_queue_init(struct il_priv *il, * Generic RX handler implementations * ******************************************************************************/ -static void il4965_rx_reply_alive(struct il_priv *il, +static void il4965_hdl_alive(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -3921,8 +3921,8 @@ static void il4965_rx_card_state_notif(struct il_priv *il, */ static void il4965_setup_handlers(struct il_priv *il) { - il->handlers[N_ALIVE] = il4965_rx_reply_alive; - il->handlers[N_ERROR] = il_rx_reply_error; + il->handlers[N_ALIVE] = il4965_hdl_alive; + il->handlers[N_ERROR] = il_hdl_error; il->handlers[N_CHANNEL_SWITCH] = il_rx_csa; il->handlers[N_SPECTRUM_MEASUREMENT] = il_rx_spectrum_measure_notif; @@ -3948,10 +3948,10 @@ static void il4965_setup_handlers(struct il_priv *il) il->handlers[N_MISSED_BEACONS] = il4965_rx_missed_beacon_notif; /* Rx handlers */ - il->handlers[N_RX_PHY] = il4965_rx_reply_rx_phy; - il->handlers[N_RX_MPDU] = il4965_rx_reply_rx; + il->handlers[N_RX_PHY] = il4965_hdl_rx_phy; + il->handlers[N_RX_MPDU] = il4965_hdl_rx; /* block ack */ - il->handlers[N_COMPRESSED_BA] = il4965_rx_reply_compressed_ba; + il->handlers[N_COMPRESSED_BA] = il4965_hdl_compressed_ba; /* Set up hardware specific Rx handlers */ il->cfg->ops->lib->handler_setup(il); } diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index f48cb89deab7..726fc80d9cee 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -2017,9 +2017,9 @@ static int il4965_get_ra_sta_id(struct il_priv *il, struct ieee80211_hdr *hdr) } /** - * il4965_rx_reply_tx - Handle standard (non-aggregation) Tx response + * il4965_hdl_tx - Handle standard (non-aggregation) Tx response */ -static void il4965_rx_reply_tx(struct il_priv *il, +static void il4965_hdl_tx(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -2145,9 +2145,9 @@ static void il4965_rx_beacon_notif(struct il_priv *il, static void il4965_handler_setup(struct il_priv *il) { /* Legacy Rx frames */ - il->handlers[N_RX] = il4965_rx_reply_rx; + il->handlers[N_RX] = il4965_hdl_rx; /* Tx response */ - il->handlers[C_TX] = il4965_rx_reply_tx; + il->handlers[C_TX] = il4965_hdl_tx; il->handlers[N_BEACON] = il4965_rx_beacon_notif; } diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h index 94cf7e7da7f9..a8acbbb69cd1 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -73,9 +73,9 @@ void il4965_rx_replenish_now(struct il_priv *il); void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq); int il4965_rxq_stop(struct il_priv *il); int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); -void il4965_rx_reply_rx(struct il_priv *il, +void il4965_hdl_rx(struct il_priv *il, struct il_rx_buf *rxb); -void il4965_rx_reply_rx_phy(struct il_priv *il, +void il4965_hdl_rx_phy(struct il_priv *il, struct il_rx_buf *rxb); void il4965_rx_handle(struct il_priv *il); @@ -95,7 +95,7 @@ int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, struct ieee80211_sta *sta, u16 tid); int il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id); -void il4965_rx_reply_compressed_ba(struct il_priv *il, +void il4965_hdl_compressed_ba(struct il_priv *il, struct il_rx_buf *rxb); int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx); void il4965_hw_txq_ctx_free(struct il_priv *il); diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index baed3dc082dc..abb8d86a0834 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -1213,7 +1213,7 @@ void il_rx_pm_debug_stats_notif(struct il_priv *il, } EXPORT_SYMBOL(il_rx_pm_debug_stats_notif); -void il_rx_reply_error(struct il_priv *il, +void il_hdl_error(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -1226,7 +1226,7 @@ void il_rx_reply_error(struct il_priv *il, le16_to_cpu(pkt->u.err_resp.bad_cmd_seq_num), le32_to_cpu(pkt->u.err_resp.error_info)); } -EXPORT_SYMBOL(il_rx_reply_error); +EXPORT_SYMBOL(il_hdl_error); void il_clear_isr_stats(struct il_priv *il) { diff --git a/drivers/net/wireless/iwlegacy/iwl-core.h b/drivers/net/wireless/iwlegacy/iwl-core.h index a3701a6c8632..9897dac21ee9 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.h +++ b/drivers/net/wireless/iwlegacy/iwl-core.h @@ -373,7 +373,7 @@ void il_rx_pm_sleep_notif(struct il_priv *il, struct il_rx_buf *rxb); void il_rx_pm_debug_stats_notif(struct il_priv *il, struct il_rx_buf *rxb); -void il_rx_reply_error(struct il_priv *il, +void il_hdl_error(struct il_priv *il, struct il_rx_buf *rxb); /***************************************************** diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index 2bed3ae914c2..f81db769809d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -182,7 +182,7 @@ int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms) EXPORT_SYMBOL(il_scan_cancel_timeout); /* Service response to C_SCAN (0x80) */ -static void il_rx_reply_scan(struct il_priv *il, +static void il_hdl_scan(struct il_priv *il, struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG @@ -263,7 +263,7 @@ static void il_rx_scan_complete_notif(struct il_priv *il, void il_setup_rx_scan_handlers(struct il_priv *il) { /* scan handlers */ - il->handlers[C_SCAN] = il_rx_reply_scan; + il->handlers[C_SCAN] = il_hdl_scan; il->handlers[N_SCAN_START] = il_rx_scan_start_notif; il->handlers[N_SCAN_RESULTS] = -- cgit v1.2.3 From d2dfb33ec9a8da257bb0e6ed2872af2fdf85260c Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 13:16:38 +0100 Subject: iwlegacy: rename other handlers Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/3945-mac.c | 20 ++++++++++---------- drivers/net/wireless/iwlegacy/3945.c | 6 +++--- drivers/net/wireless/iwlegacy/3945.h | 4 ++-- drivers/net/wireless/iwlegacy/4965-mac.c | 30 +++++++++++++++--------------- drivers/net/wireless/iwlegacy/4965.c | 4 ++-- drivers/net/wireless/iwlegacy/4965.h | 6 +++--- drivers/net/wireless/iwlegacy/iwl-core.c | 12 ++++++------ drivers/net/wireless/iwlegacy/iwl-core.h | 8 ++++---- drivers/net/wireless/iwlegacy/iwl-rx.c | 4 ++-- drivers/net/wireless/iwlegacy/iwl-scan.c | 12 ++++++------ 10 files changed, 53 insertions(+), 53 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index e9a1e64a3a16..e33ebca106c3 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -789,7 +789,7 @@ static void il3945_hdl_add_sta(struct il_priv *il, D_RX("Received C_ADD_STA: 0x%02X\n", pkt->u.status); } -static void il3945_rx_beacon_notif(struct il_priv *il, +static void il3945_hdl_beacon(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -812,7 +812,7 @@ static void il3945_rx_beacon_notif(struct il_priv *il, /* Handle notification from uCode that card's power state is changing * due to software, hardware, or critical temperature RFKILL */ -static void il3945_rx_card_state_notif(struct il_priv *il, +static void il3945_hdl_card_state(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -856,24 +856,24 @@ static void il3945_setup_handlers(struct il_priv *il) il->handlers[N_ALIVE] = il3945_hdl_alive; il->handlers[C_ADD_STA] = il3945_hdl_add_sta; il->handlers[N_ERROR] = il_hdl_error; - il->handlers[N_CHANNEL_SWITCH] = il_rx_csa; + il->handlers[N_CHANNEL_SWITCH] = il_hdl_csa; il->handlers[N_SPECTRUM_MEASUREMENT] = - il_rx_spectrum_measure_notif; - il->handlers[N_PM_SLEEP] = il_rx_pm_sleep_notif; + il_hdl_spectrum_measurement; + il->handlers[N_PM_SLEEP] = il_hdl_pm_sleep; il->handlers[N_PM_DEBUG_STATS] = - il_rx_pm_debug_stats_notif; - il->handlers[N_BEACON] = il3945_rx_beacon_notif; + il_hdl_pm_debug_stats; + il->handlers[N_BEACON] = il3945_hdl_beacon; /* * The same handler is used for both the REPLY to a discrete * stats request from the host as well as for the periodic * stats notifications (after received beacons) from the uCode. */ - il->handlers[C_STATS] = il3945_reply_stats; - il->handlers[N_STATS] = il3945_hw_rx_stats; + il->handlers[C_STATS] = il3945_hdl_c_stats; + il->handlers[N_STATS] = il3945_hdl_stats; il_setup_rx_scan_handlers(il); - il->handlers[N_CARD_STATE] = il3945_rx_card_state_notif; + il->handlers[N_CARD_STATE] = il3945_hdl_card_state; /* Set up hardware specific Rx handlers */ il3945_hw_handler_setup(il); diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index b45905fca76b..83fe531002f0 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -411,7 +411,7 @@ static void il3945_accumulative_stats(struct il_priv *il, } #endif -void il3945_hw_rx_stats(struct il_priv *il, +void il3945_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -426,7 +426,7 @@ void il3945_hw_rx_stats(struct il_priv *il, memcpy(&il->_3945.stats, pkt->u.raw, sizeof(il->_3945.stats)); } -void il3945_reply_stats(struct il_priv *il, +void il3945_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -443,7 +443,7 @@ void il3945_reply_stats(struct il_priv *il, #endif D_RX("Statistics have been cleared\n"); } - il3945_hw_rx_stats(il, rxb); + il3945_hdl_stats(il, rxb); } diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index 6000aff4798c..9854cf1b7546 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -253,9 +253,9 @@ void il3945_hw_build_tx_cmd_rate(struct il_priv *il, int sta_id, int tx_id); extern int il3945_hw_reg_send_txpower(struct il_priv *il); extern int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power); -extern void il3945_hw_rx_stats(struct il_priv *il, +extern void il3945_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb); -void il3945_reply_stats(struct il_priv *il, +void il3945_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb); extern void il3945_disable_events(struct il_priv *il); extern int il4965_get_temperature(const struct il_priv *il); diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 0797c1141128..2bab0fc34d10 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -1242,7 +1242,7 @@ int il4965_dump_fh(struct il_priv *il, char **buf, bool display) } return 0; } -void il4965_rx_missed_beacon_notif(struct il_priv *il, +void il4965_hdl_missed_beacon(struct il_priv *il, struct il_rx_buf *rxb) { @@ -1352,7 +1352,7 @@ static void il4965_accumulative_stats(struct il_priv *il, #define REG_RECALIB_PERIOD (60) -void il4965_rx_stats(struct il_priv *il, +void il4965_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb) { int change; @@ -1396,7 +1396,7 @@ void il4965_rx_stats(struct il_priv *il, il->cfg->ops->lib->temp_ops.temperature(il); } -void il4965_reply_stats(struct il_priv *il, +void il4965_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -1412,7 +1412,7 @@ void il4965_reply_stats(struct il_priv *il, #endif D_RX("Statistics have been cleared\n"); } - il4965_rx_stats(il, rxb); + il4965_hdl_stats(il, rxb); } @@ -3819,7 +3819,7 @@ static void il4965_bg_stats_periodic(unsigned long data) il_send_stats_request(il, CMD_ASYNC, false); } -static void il4965_rx_beacon_notif(struct il_priv *il, +static void il4965_hdl_beacon(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -3861,7 +3861,7 @@ static void il4965_perform_ct_kill_task(struct il_priv *il) /* Handle notification from uCode that card's power state is changing * due to software, hardware, or critical temperature RFKILL */ -static void il4965_rx_card_state_notif(struct il_priv *il, +static void il4965_hdl_card_state(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -3923,30 +3923,30 @@ static void il4965_setup_handlers(struct il_priv *il) { il->handlers[N_ALIVE] = il4965_hdl_alive; il->handlers[N_ERROR] = il_hdl_error; - il->handlers[N_CHANNEL_SWITCH] = il_rx_csa; + il->handlers[N_CHANNEL_SWITCH] = il_hdl_csa; il->handlers[N_SPECTRUM_MEASUREMENT] = - il_rx_spectrum_measure_notif; - il->handlers[N_PM_SLEEP] = il_rx_pm_sleep_notif; + il_hdl_spectrum_measurement; + il->handlers[N_PM_SLEEP] = il_hdl_pm_sleep; il->handlers[N_PM_DEBUG_STATS] = - il_rx_pm_debug_stats_notif; - il->handlers[N_BEACON] = il4965_rx_beacon_notif; + il_hdl_pm_debug_stats; + il->handlers[N_BEACON] = il4965_hdl_beacon; /* * The same handler is used for both the REPLY to a discrete * stats request from the host as well as for the periodic * stats notifications (after received beacons) from the uCode. */ - il->handlers[C_STATS] = il4965_reply_stats; - il->handlers[N_STATS] = il4965_rx_stats; + il->handlers[C_STATS] = il4965_hdl_c_stats; + il->handlers[N_STATS] = il4965_hdl_stats; il_setup_rx_scan_handlers(il); /* status change handler */ il->handlers[N_CARD_STATE] = - il4965_rx_card_state_notif; + il4965_hdl_card_state; il->handlers[N_MISSED_BEACONS] = - il4965_rx_missed_beacon_notif; + il4965_hdl_missed_beacon; /* Rx handlers */ il->handlers[N_RX_PHY] = il4965_hdl_rx_phy; il->handlers[N_RX_MPDU] = il4965_hdl_rx; diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 726fc80d9cee..ed2c61776fd3 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -2122,7 +2122,7 @@ static void il4965_hdl_tx(struct il_priv *il, spin_unlock_irqrestore(&il->sta_lock, flags); } -static void il4965_rx_beacon_notif(struct il_priv *il, +static void il4965_hdl_beacon(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -2148,7 +2148,7 @@ static void il4965_handler_setup(struct il_priv *il) il->handlers[N_RX] = il4965_hdl_rx; /* Tx response */ il->handlers[C_TX] = il4965_hdl_tx; - il->handlers[N_BEACON] = il4965_rx_beacon_notif; + il->handlers[N_BEACON] = il4965_hdl_beacon; } static struct il_hcmd_ops il4965_hcmd = { diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h index a8acbbb69cd1..5234de72a279 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -122,13 +122,13 @@ void il4965_tx_queue_set_status(struct il_priv *il, u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant_idx, u8 valid); /* rx */ -void il4965_rx_missed_beacon_notif(struct il_priv *il, +void il4965_hdl_missed_beacon(struct il_priv *il, struct il_rx_buf *rxb); bool il4965_good_plcp_health(struct il_priv *il, struct il_rx_pkt *pkt); -void il4965_rx_stats(struct il_priv *il, +void il4965_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb); -void il4965_reply_stats(struct il_priv *il, +void il4965_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb); /* scan */ diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c index abb8d86a0834..856a321ed1ea 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ b/drivers/net/wireless/iwlegacy/iwl-core.c @@ -847,7 +847,7 @@ void il_chswitch_done(struct il_priv *il, bool is_success) } EXPORT_SYMBOL(il_chswitch_done); -void il_rx_csa(struct il_priv *il, struct il_rx_buf *rxb) +void il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_csa_notification *csa = &(pkt->u.csa_notif); @@ -870,7 +870,7 @@ void il_rx_csa(struct il_priv *il, struct il_rx_buf *rxb) il_chswitch_done(il, false); } } -EXPORT_SYMBOL(il_rx_csa); +EXPORT_SYMBOL(il_hdl_csa); #ifdef CONFIG_IWLEGACY_DEBUG void il_print_rx_config_cmd(struct il_priv *il, @@ -1189,7 +1189,7 @@ int il_send_stats_request(struct il_priv *il, u8 flags, bool clear) } EXPORT_SYMBOL(il_send_stats_request); -void il_rx_pm_sleep_notif(struct il_priv *il, +void il_hdl_pm_sleep(struct il_priv *il, struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG @@ -1199,9 +1199,9 @@ void il_rx_pm_sleep_notif(struct il_priv *il, sleep->pm_sleep_mode, sleep->pm_wakeup_src); #endif } -EXPORT_SYMBOL(il_rx_pm_sleep_notif); +EXPORT_SYMBOL(il_hdl_pm_sleep); -void il_rx_pm_debug_stats_notif(struct il_priv *il, +void il_hdl_pm_debug_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -1211,7 +1211,7 @@ void il_rx_pm_debug_stats_notif(struct il_priv *il, il_get_cmd_string(pkt->hdr.cmd)); il_print_hex_dump(il, IL_DL_RADIO, pkt->u.raw, len); } -EXPORT_SYMBOL(il_rx_pm_debug_stats_notif); +EXPORT_SYMBOL(il_hdl_pm_debug_stats); void il_hdl_error(struct il_priv *il, struct il_rx_buf *rxb) diff --git a/drivers/net/wireless/iwlegacy/iwl-core.h b/drivers/net/wireless/iwlegacy/iwl-core.h index 9897dac21ee9..5de742c6ce40 100644 --- a/drivers/net/wireless/iwlegacy/iwl-core.h +++ b/drivers/net/wireless/iwlegacy/iwl-core.h @@ -369,9 +369,9 @@ static inline void il_update_stats(struct il_priv *il, bool is_tx, /***************************************************** * RX handlers. * **************************************************/ -void il_rx_pm_sleep_notif(struct il_priv *il, +void il_hdl_pm_sleep(struct il_priv *il, struct il_rx_buf *rxb); -void il_rx_pm_debug_stats_notif(struct il_priv *il, +void il_hdl_pm_debug_stats(struct il_priv *il, struct il_rx_buf *rxb); void il_hdl_error(struct il_priv *il, struct il_rx_buf *rxb); @@ -388,12 +388,12 @@ int il_rx_queue_space(const struct il_rx_queue *q); void il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb); /* Handlers */ -void il_rx_spectrum_measure_notif(struct il_priv *il, +void il_hdl_spectrum_measurement(struct il_priv *il, struct il_rx_buf *rxb); void il_recover_from_stats(struct il_priv *il, struct il_rx_pkt *pkt); void il_chswitch_done(struct il_priv *il, bool is_success); -void il_rx_csa(struct il_priv *il, struct il_rx_buf *rxb); +void il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb); /* TX helpers */ diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c index 76f2361031bb..7a8ae556f2be 100644 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ b/drivers/net/wireless/iwlegacy/iwl-rx.c @@ -210,7 +210,7 @@ err_bd: EXPORT_SYMBOL(il_rx_queue_alloc); -void il_rx_spectrum_measure_notif(struct il_priv *il, +void il_hdl_spectrum_measurement(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -225,7 +225,7 @@ void il_rx_spectrum_measure_notif(struct il_priv *il, memcpy(&il->measure_report, report, sizeof(*report)); il->measurement_status |= MEASUREMENT_READY; } -EXPORT_SYMBOL(il_rx_spectrum_measure_notif); +EXPORT_SYMBOL(il_hdl_spectrum_measurement); /* * returns non-zero if packet should be dropped diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c index f81db769809d..aaa589abbe33 100644 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ b/drivers/net/wireless/iwlegacy/iwl-scan.c @@ -195,7 +195,7 @@ static void il_hdl_scan(struct il_priv *il, } /* Service N_SCAN_START (0x82) */ -static void il_rx_scan_start_notif(struct il_priv *il, +static void il_hdl_scan_start(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -213,7 +213,7 @@ static void il_rx_scan_start_notif(struct il_priv *il, } /* Service N_SCAN_RESULTS (0x83) */ -static void il_rx_scan_results_notif(struct il_priv *il, +static void il_hdl_scan_results(struct il_priv *il, struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG @@ -235,7 +235,7 @@ static void il_rx_scan_results_notif(struct il_priv *il, } /* Service N_SCAN_COMPLETE (0x84) */ -static void il_rx_scan_complete_notif(struct il_priv *il, +static void il_hdl_scan_complete(struct il_priv *il, struct il_rx_buf *rxb) { @@ -265,11 +265,11 @@ void il_setup_rx_scan_handlers(struct il_priv *il) /* scan handlers */ il->handlers[C_SCAN] = il_hdl_scan; il->handlers[N_SCAN_START] = - il_rx_scan_start_notif; + il_hdl_scan_start; il->handlers[N_SCAN_RESULTS] = - il_rx_scan_results_notif; + il_hdl_scan_results; il->handlers[N_SCAN_COMPLETE] = - il_rx_scan_complete_notif; + il_hdl_scan_complete; } EXPORT_SYMBOL(il_setup_rx_scan_handlers); -- cgit v1.2.3 From 4ed47911a2e0f9a425d22253433452ffa59d533e Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 13:18:51 +0100 Subject: iwlegacy: rename iwl-core.c to common.c Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/Makefile | 2 +- drivers/net/wireless/iwlegacy/common.c | 2608 ++++++++++++++++++++++++++++++ drivers/net/wireless/iwlegacy/iwl-core.c | 2608 ------------------------------ 3 files changed, 2609 insertions(+), 2609 deletions(-) create mode 100644 drivers/net/wireless/iwlegacy/common.c delete mode 100644 drivers/net/wireless/iwlegacy/iwl-core.c (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index d402496759e4..0f51f9d9e647 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -1,5 +1,5 @@ obj-$(CONFIG_IWLEGACY) += iwl-legacy.o -iwl-legacy-objs := iwl-core.o iwl-eeprom.o iwl-hcmd.o iwl-power.o +iwl-legacy-objs := common.o iwl-eeprom.o iwl-hcmd.o iwl-power.o iwl-legacy-objs += iwl-rx.o iwl-tx.o iwl-sta.o iwl-legacy-objs += iwl-scan.o iwl-led.o iwl-legacy-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-debugfs.o diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c new file mode 100644 index 000000000000..856a321ed1ea --- /dev/null +++ b/drivers/net/wireless/iwlegacy/common.c @@ -0,0 +1,2608 @@ +/****************************************************************************** + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, + * USA + * + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + *****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +#include "iwl-eeprom.h" +#include "iwl-dev.h" +#include "iwl-debug.h" +#include "iwl-core.h" +#include "iwl-io.h" +#include "iwl-power.h" +#include "iwl-sta.h" +#include "iwl-helpers.h" + + +MODULE_DESCRIPTION("iwl-legacy: common functions for 3945 and 4965"); +MODULE_VERSION(IWLWIFI_VERSION); +MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); +MODULE_LICENSE("GPL"); + +/* + * set bt_coex_active to true, uCode will do kill/defer + * every time the priority line is asserted (BT is sending signals on the + * priority line in the PCIx). + * set bt_coex_active to false, uCode will ignore the BT activity and + * perform the normal operation + * + * User might experience transmit issue on some platform due to WiFi/BT + * co-exist problem. The possible behaviors are: + * Able to scan and finding all the available AP + * Not able to associate with any AP + * On those platforms, WiFi communication can be restored by set + * "bt_coex_active" module parameter to "false" + * + * default: bt_coex_active = true (BT_COEX_ENABLE) + */ +static bool bt_coex_active = true; +module_param(bt_coex_active, bool, S_IRUGO); +MODULE_PARM_DESC(bt_coex_active, "enable wifi/bluetooth co-exist"); + +u32 il_debug_level; +EXPORT_SYMBOL(il_debug_level); + +const u8 il_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; +EXPORT_SYMBOL(il_bcast_addr); + + +/* This function both allocates and initializes hw and il. */ +struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg) +{ + struct il_priv *il; + /* mac80211 allocates memory for this device instance, including + * space for this driver's ilate structure */ + struct ieee80211_hw *hw; + + hw = ieee80211_alloc_hw(sizeof(struct il_priv), + cfg->ops->ieee80211_ops); + if (hw == NULL) { + pr_err("%s: Can not allocate network device\n", + cfg->name); + goto out; + } + + il = hw->priv; + il->hw = hw; + +out: + return hw; +} +EXPORT_SYMBOL(il_alloc_all); + +#define MAX_BIT_RATE_40_MHZ 150 /* Mbps */ +#define MAX_BIT_RATE_20_MHZ 72 /* Mbps */ +static void il_init_ht_hw_capab(const struct il_priv *il, + struct ieee80211_sta_ht_cap *ht_info, + enum ieee80211_band band) +{ + u16 max_bit_rate = 0; + u8 rx_chains_num = il->hw_params.rx_chains_num; + u8 tx_chains_num = il->hw_params.tx_chains_num; + + ht_info->cap = 0; + memset(&ht_info->mcs, 0, sizeof(ht_info->mcs)); + + ht_info->ht_supported = true; + + ht_info->cap |= IEEE80211_HT_CAP_SGI_20; + max_bit_rate = MAX_BIT_RATE_20_MHZ; + if (il->hw_params.ht40_channel & BIT(band)) { + ht_info->cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40; + ht_info->cap |= IEEE80211_HT_CAP_SGI_40; + ht_info->mcs.rx_mask[4] = 0x01; + max_bit_rate = MAX_BIT_RATE_40_MHZ; + } + + if (il->cfg->mod_params->amsdu_size_8K) + ht_info->cap |= IEEE80211_HT_CAP_MAX_AMSDU; + + ht_info->ampdu_factor = CFG_HT_RX_AMPDU_FACTOR_DEF; + ht_info->ampdu_density = CFG_HT_MPDU_DENSITY_DEF; + + ht_info->mcs.rx_mask[0] = 0xFF; + if (rx_chains_num >= 2) + ht_info->mcs.rx_mask[1] = 0xFF; + if (rx_chains_num >= 3) + ht_info->mcs.rx_mask[2] = 0xFF; + + /* Highest supported Rx data rate */ + max_bit_rate *= rx_chains_num; + WARN_ON(max_bit_rate & ~IEEE80211_HT_MCS_RX_HIGHEST_MASK); + ht_info->mcs.rx_highest = cpu_to_le16(max_bit_rate); + + /* Tx MCS capabilities */ + ht_info->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; + if (tx_chains_num != rx_chains_num) { + ht_info->mcs.tx_params |= IEEE80211_HT_MCS_TX_RX_DIFF; + ht_info->mcs.tx_params |= ((tx_chains_num - 1) << + IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT); + } +} + +/** + * il_init_geos - Initialize mac80211's geo/channel info based from eeprom + */ +int il_init_geos(struct il_priv *il) +{ + struct il_channel_info *ch; + struct ieee80211_supported_band *sband; + struct ieee80211_channel *channels; + struct ieee80211_channel *geo_ch; + struct ieee80211_rate *rates; + int i = 0; + s8 max_tx_power = 0; + + if (il->bands[IEEE80211_BAND_2GHZ].n_bitrates || + il->bands[IEEE80211_BAND_5GHZ].n_bitrates) { + D_INFO("Geography modes already initialized.\n"); + set_bit(S_GEO_CONFIGURED, &il->status); + return 0; + } + + channels = kzalloc(sizeof(struct ieee80211_channel) * + il->channel_count, GFP_KERNEL); + if (!channels) + return -ENOMEM; + + rates = kzalloc((sizeof(struct ieee80211_rate) * RATE_COUNT_LEGACY), + GFP_KERNEL); + if (!rates) { + kfree(channels); + return -ENOMEM; + } + + /* 5.2GHz channels start after the 2.4GHz channels */ + sband = &il->bands[IEEE80211_BAND_5GHZ]; + sband->channels = &channels[ARRAY_SIZE(il_eeprom_band_1)]; + /* just OFDM */ + sband->bitrates = &rates[IL_FIRST_OFDM_RATE]; + sband->n_bitrates = RATE_COUNT_LEGACY - IL_FIRST_OFDM_RATE; + + if (il->cfg->sku & IL_SKU_N) + il_init_ht_hw_capab(il, &sband->ht_cap, + IEEE80211_BAND_5GHZ); + + sband = &il->bands[IEEE80211_BAND_2GHZ]; + sband->channels = channels; + /* OFDM & CCK */ + sband->bitrates = rates; + sband->n_bitrates = RATE_COUNT_LEGACY; + + if (il->cfg->sku & IL_SKU_N) + il_init_ht_hw_capab(il, &sband->ht_cap, + IEEE80211_BAND_2GHZ); + + il->ieee_channels = channels; + il->ieee_rates = rates; + + for (i = 0; i < il->channel_count; i++) { + ch = &il->channel_info[i]; + + if (!il_is_channel_valid(ch)) + continue; + + sband = &il->bands[ch->band]; + + geo_ch = &sband->channels[sband->n_channels++]; + + geo_ch->center_freq = + ieee80211_channel_to_frequency(ch->channel, ch->band); + geo_ch->max_power = ch->max_power_avg; + geo_ch->max_antenna_gain = 0xff; + geo_ch->hw_value = ch->channel; + + if (il_is_channel_valid(ch)) { + if (!(ch->flags & EEPROM_CHANNEL_IBSS)) + geo_ch->flags |= IEEE80211_CHAN_NO_IBSS; + + if (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) + geo_ch->flags |= IEEE80211_CHAN_PASSIVE_SCAN; + + if (ch->flags & EEPROM_CHANNEL_RADAR) + geo_ch->flags |= IEEE80211_CHAN_RADAR; + + geo_ch->flags |= ch->ht40_extension_channel; + + if (ch->max_power_avg > max_tx_power) + max_tx_power = ch->max_power_avg; + } else { + geo_ch->flags |= IEEE80211_CHAN_DISABLED; + } + + D_INFO("Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", + ch->channel, geo_ch->center_freq, + il_is_channel_a_band(ch) ? "5.2" : "2.4", + geo_ch->flags & IEEE80211_CHAN_DISABLED ? + "restricted" : "valid", + geo_ch->flags); + } + + il->tx_power_device_lmt = max_tx_power; + il->tx_power_user_lmt = max_tx_power; + il->tx_power_next = max_tx_power; + + if (il->bands[IEEE80211_BAND_5GHZ].n_channels == 0 && + (il->cfg->sku & IL_SKU_A)) { + IL_INFO("Incorrectly detected BG card as ABG. " + "Please send your PCI ID 0x%04X:0x%04X to maintainer.\n", + il->pci_dev->device, + il->pci_dev->subsystem_device); + il->cfg->sku &= ~IL_SKU_A; + } + + IL_INFO("Tunable channels: %d 802.11bg, %d 802.11a channels\n", + il->bands[IEEE80211_BAND_2GHZ].n_channels, + il->bands[IEEE80211_BAND_5GHZ].n_channels); + + set_bit(S_GEO_CONFIGURED, &il->status); + + return 0; +} +EXPORT_SYMBOL(il_init_geos); + +/* + * il_free_geos - undo allocations in il_init_geos + */ +void il_free_geos(struct il_priv *il) +{ + kfree(il->ieee_channels); + kfree(il->ieee_rates); + clear_bit(S_GEO_CONFIGURED, &il->status); +} +EXPORT_SYMBOL(il_free_geos); + +static bool il_is_channel_extension(struct il_priv *il, + enum ieee80211_band band, + u16 channel, u8 extension_chan_offset) +{ + const struct il_channel_info *ch_info; + + ch_info = il_get_channel_info(il, band, channel); + if (!il_is_channel_valid(ch_info)) + return false; + + if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_ABOVE) + return !(ch_info->ht40_extension_channel & + IEEE80211_CHAN_NO_HT40PLUS); + else if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_BELOW) + return !(ch_info->ht40_extension_channel & + IEEE80211_CHAN_NO_HT40MINUS); + + return false; +} + +bool il_is_ht40_tx_allowed(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_sta_ht_cap *ht_cap) +{ + if (!ctx->ht.enabled || !ctx->ht.is_40mhz) + return false; + + /* + * We do not check for IEEE80211_HT_CAP_SUP_WIDTH_20_40 + * the bit will not set if it is pure 40MHz case + */ + if (ht_cap && !ht_cap->ht_supported) + return false; + +#ifdef CONFIG_IWLEGACY_DEBUGFS + if (il->disable_ht40) + return false; +#endif + + return il_is_channel_extension(il, il->band, + le16_to_cpu(ctx->staging.channel), + ctx->ht.extension_chan_offset); +} +EXPORT_SYMBOL(il_is_ht40_tx_allowed); + +static u16 il_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val) +{ + u16 new_val; + u16 beacon_factor; + + /* + * If mac80211 hasn't given us a beacon interval, program + * the default into the device. + */ + if (!beacon_val) + return DEFAULT_BEACON_INTERVAL; + + /* + * If the beacon interval we obtained from the peer + * is too large, we'll have to wake up more often + * (and in IBSS case, we'll beacon too much) + * + * For example, if max_beacon_val is 4096, and the + * requested beacon interval is 7000, we'll have to + * use 3500 to be able to wake up on the beacons. + * + * This could badly influence beacon detection stats. + */ + + beacon_factor = (beacon_val + max_beacon_val) / max_beacon_val; + new_val = beacon_val / beacon_factor; + + if (!new_val) + new_val = max_beacon_val; + + return new_val; +} + +int +il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx) +{ + u64 tsf; + s32 interval_tm, rem; + struct ieee80211_conf *conf = NULL; + u16 beacon_int; + struct ieee80211_vif *vif = ctx->vif; + + conf = il_ieee80211_get_hw_conf(il->hw); + + lockdep_assert_held(&il->mutex); + + memset(&ctx->timing, 0, sizeof(struct il_rxon_time_cmd)); + + ctx->timing.timestamp = cpu_to_le64(il->timestamp); + ctx->timing.listen_interval = cpu_to_le16(conf->listen_interval); + + beacon_int = vif ? vif->bss_conf.beacon_int : 0; + + /* + * TODO: For IBSS we need to get atim_win from mac80211, + * for now just always use 0 + */ + ctx->timing.atim_win = 0; + + beacon_int = il_adjust_beacon_interval(beacon_int, + il->hw_params.max_beacon_itrvl * TIME_UNIT); + ctx->timing.beacon_interval = cpu_to_le16(beacon_int); + + tsf = il->timestamp; /* tsf is modifed by do_div: copy it */ + interval_tm = beacon_int * TIME_UNIT; + rem = do_div(tsf, interval_tm); + ctx->timing.beacon_init_val = cpu_to_le32(interval_tm - rem); + + ctx->timing.dtim_period = vif ? (vif->bss_conf.dtim_period ?: 1) : 1; + + D_ASSOC( + "beacon interval %d beacon timer %d beacon tim %d\n", + le16_to_cpu(ctx->timing.beacon_interval), + le32_to_cpu(ctx->timing.beacon_init_val), + le16_to_cpu(ctx->timing.atim_win)); + + return il_send_cmd_pdu(il, ctx->rxon_timing_cmd, + sizeof(ctx->timing), &ctx->timing); +} +EXPORT_SYMBOL(il_send_rxon_timing); + +void +il_set_rxon_hwcrypto(struct il_priv *il, + struct il_rxon_context *ctx, + int hw_decrypt) +{ + struct il_rxon_cmd *rxon = &ctx->staging; + + if (hw_decrypt) + rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK; + else + rxon->filter_flags |= RXON_FILTER_DIS_DECRYPT_MSK; + +} +EXPORT_SYMBOL(il_set_rxon_hwcrypto); + +/* validate RXON structure is valid */ +int +il_check_rxon_cmd(struct il_priv *il, struct il_rxon_context *ctx) +{ + struct il_rxon_cmd *rxon = &ctx->staging; + bool error = false; + + if (rxon->flags & RXON_FLG_BAND_24G_MSK) { + if (rxon->flags & RXON_FLG_TGJ_NARROW_BAND_MSK) { + IL_WARN("check 2.4G: wrong narrow\n"); + error = true; + } + if (rxon->flags & RXON_FLG_RADAR_DETECT_MSK) { + IL_WARN("check 2.4G: wrong radar\n"); + error = true; + } + } else { + if (!(rxon->flags & RXON_FLG_SHORT_SLOT_MSK)) { + IL_WARN("check 5.2G: not short slot!\n"); + error = true; + } + if (rxon->flags & RXON_FLG_CCK_MSK) { + IL_WARN("check 5.2G: CCK!\n"); + error = true; + } + } + if ((rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1) { + IL_WARN("mac/bssid mcast!\n"); + error = true; + } + + /* make sure basic rates 6Mbps and 1Mbps are supported */ + if ((rxon->ofdm_basic_rates & RATE_6M_MASK) == 0 && + (rxon->cck_basic_rates & RATE_1M_MASK) == 0) { + IL_WARN("neither 1 nor 6 are basic\n"); + error = true; + } + + if (le16_to_cpu(rxon->assoc_id) > 2007) { + IL_WARN("aid > 2007\n"); + error = true; + } + + if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) + == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) { + IL_WARN("CCK and short slot\n"); + error = true; + } + + if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) + == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) { + IL_WARN("CCK and auto detect"); + error = true; + } + + if ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK | + RXON_FLG_TGG_PROTECT_MSK)) == + RXON_FLG_TGG_PROTECT_MSK) { + IL_WARN("TGg but no auto-detect\n"); + error = true; + } + + if (error) + IL_WARN("Tuning to channel %d\n", + le16_to_cpu(rxon->channel)); + + if (error) { + IL_ERR("Invalid RXON\n"); + return -EINVAL; + } + return 0; +} +EXPORT_SYMBOL(il_check_rxon_cmd); + +/** + * il_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed + * @il: staging_rxon is compared to active_rxon + * + * If the RXON structure is changing enough to require a new tune, + * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that + * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required. + */ +int il_full_rxon_required(struct il_priv *il, + struct il_rxon_context *ctx) +{ + const struct il_rxon_cmd *staging = &ctx->staging; + const struct il_rxon_cmd *active = &ctx->active; + +#define CHK(cond) \ + if ((cond)) { \ + D_INFO("need full RXON - " #cond "\n"); \ + return 1; \ + } + +#define CHK_NEQ(c1, c2) \ + if ((c1) != (c2)) { \ + D_INFO("need full RXON - " \ + #c1 " != " #c2 " - %d != %d\n", \ + (c1), (c2)); \ + return 1; \ + } + + /* These items are only settable from the full RXON command */ + CHK(!il_is_associated_ctx(ctx)); + CHK(compare_ether_addr(staging->bssid_addr, active->bssid_addr)); + CHK(compare_ether_addr(staging->node_addr, active->node_addr)); + CHK(compare_ether_addr(staging->wlap_bssid_addr, + active->wlap_bssid_addr)); + CHK_NEQ(staging->dev_type, active->dev_type); + CHK_NEQ(staging->channel, active->channel); + CHK_NEQ(staging->air_propagation, active->air_propagation); + CHK_NEQ(staging->ofdm_ht_single_stream_basic_rates, + active->ofdm_ht_single_stream_basic_rates); + CHK_NEQ(staging->ofdm_ht_dual_stream_basic_rates, + active->ofdm_ht_dual_stream_basic_rates); + CHK_NEQ(staging->assoc_id, active->assoc_id); + + /* flags, filter_flags, ofdm_basic_rates, and cck_basic_rates can + * be updated with the RXON_ASSOC command -- however only some + * flag transitions are allowed using RXON_ASSOC */ + + /* Check if we are not switching bands */ + CHK_NEQ(staging->flags & RXON_FLG_BAND_24G_MSK, + active->flags & RXON_FLG_BAND_24G_MSK); + + /* Check if we are switching association toggle */ + CHK_NEQ(staging->filter_flags & RXON_FILTER_ASSOC_MSK, + active->filter_flags & RXON_FILTER_ASSOC_MSK); + +#undef CHK +#undef CHK_NEQ + + return 0; +} +EXPORT_SYMBOL(il_full_rxon_required); + +u8 il_get_lowest_plcp(struct il_priv *il, + struct il_rxon_context *ctx) +{ + /* + * Assign the lowest rate -- should really get this from + * the beacon skb from mac80211. + */ + if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) + return RATE_1M_PLCP; + else + return RATE_6M_PLCP; +} +EXPORT_SYMBOL(il_get_lowest_plcp); + +static void _il_set_rxon_ht(struct il_priv *il, + struct il_ht_config *ht_conf, + struct il_rxon_context *ctx) +{ + struct il_rxon_cmd *rxon = &ctx->staging; + + if (!ctx->ht.enabled) { + rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | + RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK | + RXON_FLG_HT40_PROT_MSK | + RXON_FLG_HT_PROT_MSK); + return; + } + + rxon->flags |= cpu_to_le32(ctx->ht.protection << + RXON_FLG_HT_OPERATING_MODE_POS); + + /* Set up channel bandwidth: + * 20 MHz only, 20/40 mixed or pure 40 if ht40 ok */ + /* clear the HT channel mode before set the mode */ + rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | + RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); + if (il_is_ht40_tx_allowed(il, ctx, NULL)) { + /* pure ht40 */ + if (ctx->ht.protection == + IEEE80211_HT_OP_MODE_PROTECTION_20MHZ) { + rxon->flags |= RXON_FLG_CHANNEL_MODE_PURE_40; + /* Note: control channel is opposite of extension channel */ + switch (ctx->ht.extension_chan_offset) { + case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: + rxon->flags &= + ~RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; + break; + case IEEE80211_HT_PARAM_CHA_SEC_BELOW: + rxon->flags |= + RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; + break; + } + } else { + /* Note: control channel is opposite of extension channel */ + switch (ctx->ht.extension_chan_offset) { + case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: + rxon->flags &= + ~(RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); + rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED; + break; + case IEEE80211_HT_PARAM_CHA_SEC_BELOW: + rxon->flags |= + RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; + rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED; + break; + case IEEE80211_HT_PARAM_CHA_SEC_NONE: + default: + /* channel location only valid if in Mixed mode */ + IL_ERR( + "invalid extension channel offset\n"); + break; + } + } + } else { + rxon->flags |= RXON_FLG_CHANNEL_MODE_LEGACY; + } + + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); + + D_ASSOC("rxon flags 0x%X operation mode :0x%X " + "extension channel offset 0x%x\n", + le32_to_cpu(rxon->flags), ctx->ht.protection, + ctx->ht.extension_chan_offset); +} + +void il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf) +{ + _il_set_rxon_ht(il, ht_conf, &il->ctx); +} +EXPORT_SYMBOL(il_set_rxon_ht); + +/* Return valid, unused, channel for a passive scan to reset the RF */ +u8 il_get_single_channel_number(struct il_priv *il, + enum ieee80211_band band) +{ + const struct il_channel_info *ch_info; + int i; + u8 channel = 0; + u8 min, max; + + if (band == IEEE80211_BAND_5GHZ) { + min = 14; + max = il->channel_count; + } else { + min = 0; + max = 14; + } + + for (i = min; i < max; i++) { + channel = il->channel_info[i].channel; + if (channel == le16_to_cpu(il->ctx.staging.channel)) + continue; + + ch_info = il_get_channel_info(il, band, channel); + if (il_is_channel_valid(ch_info)) + break; + } + + return channel; +} +EXPORT_SYMBOL(il_get_single_channel_number); + +/** + * il_set_rxon_channel - Set the band and channel values in staging RXON + * @ch: requested channel as a pointer to struct ieee80211_channel + + * NOTE: Does not commit to the hardware; it sets appropriate bit fields + * in the staging RXON flag structure based on the ch->band + */ +int +il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch, + struct il_rxon_context *ctx) +{ + enum ieee80211_band band = ch->band; + u16 channel = ch->hw_value; + + if (le16_to_cpu(ctx->staging.channel) == channel && il->band == band) + return 0; + + ctx->staging.channel = cpu_to_le16(channel); + if (band == IEEE80211_BAND_5GHZ) + ctx->staging.flags &= ~RXON_FLG_BAND_24G_MSK; + else + ctx->staging.flags |= RXON_FLG_BAND_24G_MSK; + + il->band = band; + + D_INFO("Staging channel set to %d [%d]\n", channel, band); + + return 0; +} +EXPORT_SYMBOL(il_set_rxon_channel); + +void il_set_flags_for_band(struct il_priv *il, + struct il_rxon_context *ctx, + enum ieee80211_band band, + struct ieee80211_vif *vif) +{ + if (band == IEEE80211_BAND_5GHZ) { + ctx->staging.flags &= + ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK + | RXON_FLG_CCK_MSK); + ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; + } else { + /* Copied from il_post_associate() */ + if (vif && vif->bss_conf.use_short_slot) + ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; + else + ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; + + ctx->staging.flags |= RXON_FLG_BAND_24G_MSK; + ctx->staging.flags |= RXON_FLG_AUTO_DETECT_MSK; + ctx->staging.flags &= ~RXON_FLG_CCK_MSK; + } +} +EXPORT_SYMBOL(il_set_flags_for_band); + +/* + * initialize rxon structure with default values from eeprom + */ +void il_connection_init_rx_config(struct il_priv *il, + struct il_rxon_context *ctx) +{ + const struct il_channel_info *ch_info; + + memset(&ctx->staging, 0, sizeof(ctx->staging)); + + if (!ctx->vif) { + ctx->staging.dev_type = ctx->unused_devtype; + } else + switch (ctx->vif->type) { + + case NL80211_IFTYPE_STATION: + ctx->staging.dev_type = ctx->station_devtype; + ctx->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK; + break; + + case NL80211_IFTYPE_ADHOC: + ctx->staging.dev_type = ctx->ibss_devtype; + ctx->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK; + ctx->staging.filter_flags = RXON_FILTER_BCON_AWARE_MSK | + RXON_FILTER_ACCEPT_GRP_MSK; + break; + + default: + IL_ERR("Unsupported interface type %d\n", + ctx->vif->type); + break; + } + +#if 0 + /* TODO: Figure out when short_preamble would be set and cache from + * that */ + if (!hw_to_local(il->hw)->short_preamble) + ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; + else + ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; +#endif + + ch_info = il_get_channel_info(il, il->band, + le16_to_cpu(ctx->active.channel)); + + if (!ch_info) + ch_info = &il->channel_info[0]; + + ctx->staging.channel = cpu_to_le16(ch_info->channel); + il->band = ch_info->band; + + il_set_flags_for_band(il, ctx, il->band, ctx->vif); + + ctx->staging.ofdm_basic_rates = + (IL_OFDM_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; + ctx->staging.cck_basic_rates = + (IL_CCK_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; + + /* clear both MIX and PURE40 mode flag */ + ctx->staging.flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED | + RXON_FLG_CHANNEL_MODE_PURE_40); + if (ctx->vif) + memcpy(ctx->staging.node_addr, ctx->vif->addr, ETH_ALEN); + + ctx->staging.ofdm_ht_single_stream_basic_rates = 0xff; + ctx->staging.ofdm_ht_dual_stream_basic_rates = 0xff; +} +EXPORT_SYMBOL(il_connection_init_rx_config); + +void il_set_rate(struct il_priv *il) +{ + const struct ieee80211_supported_band *hw = NULL; + struct ieee80211_rate *rate; + int i; + + hw = il_get_hw_mode(il, il->band); + if (!hw) { + IL_ERR("Failed to set rate: unable to get hw mode\n"); + return; + } + + il->active_rate = 0; + + for (i = 0; i < hw->n_bitrates; i++) { + rate = &(hw->bitrates[i]); + if (rate->hw_value < RATE_COUNT_LEGACY) + il->active_rate |= (1 << rate->hw_value); + } + + D_RATE("Set active_rate = %0x\n", il->active_rate); + + il->ctx.staging.cck_basic_rates = + (IL_CCK_BASIC_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; + + il->ctx.staging.ofdm_basic_rates = + (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; +} +EXPORT_SYMBOL(il_set_rate); + +void il_chswitch_done(struct il_priv *il, bool is_success) +{ + struct il_rxon_context *ctx = &il->ctx; + + if (test_bit(S_EXIT_PENDING, &il->status)) + return; + + if (test_and_clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) + ieee80211_chswitch_done(ctx->vif, is_success); +} +EXPORT_SYMBOL(il_chswitch_done); + +void il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il_csa_notification *csa = &(pkt->u.csa_notif); + + struct il_rxon_context *ctx = &il->ctx; + struct il_rxon_cmd *rxon = (void *)&ctx->active; + + if (!test_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) + return; + + if (!le32_to_cpu(csa->status) && csa->channel == il->switch_channel) { + rxon->channel = csa->channel; + ctx->staging.channel = csa->channel; + D_11H("CSA notif: channel %d\n", + le16_to_cpu(csa->channel)); + il_chswitch_done(il, true); + } else { + IL_ERR("CSA notif (fail) : channel %d\n", + le16_to_cpu(csa->channel)); + il_chswitch_done(il, false); + } +} +EXPORT_SYMBOL(il_hdl_csa); + +#ifdef CONFIG_IWLEGACY_DEBUG +void il_print_rx_config_cmd(struct il_priv *il, + struct il_rxon_context *ctx) +{ + struct il_rxon_cmd *rxon = &ctx->staging; + + D_RADIO("RX CONFIG:\n"); + il_print_hex_dump(il, IL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); + D_RADIO("u16 channel: 0x%x\n", + le16_to_cpu(rxon->channel)); + D_RADIO("u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags)); + D_RADIO("u32 filter_flags: 0x%08x\n", + le32_to_cpu(rxon->filter_flags)); + D_RADIO("u8 dev_type: 0x%x\n", rxon->dev_type); + D_RADIO("u8 ofdm_basic_rates: 0x%02x\n", + rxon->ofdm_basic_rates); + D_RADIO("u8 cck_basic_rates: 0x%02x\n", + rxon->cck_basic_rates); + D_RADIO("u8[6] node_addr: %pM\n", rxon->node_addr); + D_RADIO("u8[6] bssid_addr: %pM\n", rxon->bssid_addr); + D_RADIO("u16 assoc_id: 0x%x\n", + le16_to_cpu(rxon->assoc_id)); +} +EXPORT_SYMBOL(il_print_rx_config_cmd); +#endif +/** + * il_irq_handle_error - called for HW or SW error interrupt from card + */ +void il_irq_handle_error(struct il_priv *il) +{ + /* Set the FW error flag -- cleared on il_down */ + set_bit(S_FW_ERROR, &il->status); + + /* Cancel currently queued command. */ + clear_bit(S_HCMD_ACTIVE, &il->status); + + IL_ERR("Loaded firmware version: %s\n", + il->hw->wiphy->fw_version); + + il->cfg->ops->lib->dump_nic_error_log(il); + if (il->cfg->ops->lib->dump_fh) + il->cfg->ops->lib->dump_fh(il, NULL, false); +#ifdef CONFIG_IWLEGACY_DEBUG + if (il_get_debug_level(il) & IL_DL_FW_ERRORS) + il_print_rx_config_cmd(il, + &il->ctx); +#endif + + wake_up(&il->wait_command_queue); + + /* Keep the restart process from trying to send host + * commands by clearing the INIT status bit */ + clear_bit(S_READY, &il->status); + + if (!test_bit(S_EXIT_PENDING, &il->status)) { + IL_DBG(IL_DL_FW_ERRORS, + "Restarting adapter due to uCode error.\n"); + + if (il->cfg->mod_params->restart_fw) + queue_work(il->workqueue, &il->restart); + } +} +EXPORT_SYMBOL(il_irq_handle_error); + +static int il_apm_stop_master(struct il_priv *il) +{ + int ret = 0; + + /* stop device's busmaster DMA activity */ + il_set_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); + + ret = _il_poll_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, + CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); + if (ret) + IL_WARN("Master Disable Timed Out, 100 usec\n"); + + D_INFO("stop master\n"); + + return ret; +} + +void il_apm_stop(struct il_priv *il) +{ + D_INFO("Stop card, put in low power state\n"); + + /* Stop device's DMA activity */ + il_apm_stop_master(il); + + /* Reset the entire device */ + il_set_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); + + udelay(10); + + /* + * Clear "initialization complete" bit to move adapter from + * D0A* (powered-up Active) --> D0U* (Uninitialized) state. + */ + il_clear_bit(il, CSR_GP_CNTRL, + CSR_GP_CNTRL_REG_FLAG_INIT_DONE); +} +EXPORT_SYMBOL(il_apm_stop); + + +/* + * Start up NIC's basic functionality after it has been reset + * (e.g. after platform boot, or shutdown via il_apm_stop()) + * NOTE: This does not load uCode nor start the embedded processor + */ +int il_apm_init(struct il_priv *il) +{ + int ret = 0; + u16 lctl; + + D_INFO("Init card's basic functions\n"); + + /* + * Use "set_bit" below rather than "write", to preserve any hardware + * bits already set by default after reset. + */ + + /* Disable L0S exit timer (platform NMI Work/Around) */ + il_set_bit(il, CSR_GIO_CHICKEN_BITS, + CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); + + /* + * Disable L0s without affecting L1; + * don't wait for ICH L0s (ICH bug W/A) + */ + il_set_bit(il, CSR_GIO_CHICKEN_BITS, + CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX); + + /* Set FH wait threshold to maximum (HW error during stress W/A) */ + il_set_bit(il, CSR_DBG_HPET_MEM_REG, + CSR_DBG_HPET_MEM_REG_VAL); + + /* + * Enable HAP INTA (interrupt from management bus) to + * wake device's PCI Express link L1a -> L0s + * NOTE: This is no-op for 3945 (non-existent bit) + */ + il_set_bit(il, CSR_HW_IF_CONFIG_REG, + CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); + + /* + * HW bug W/A for instability in PCIe bus L0->L0S->L1 transition. + * Check if BIOS (or OS) enabled L1-ASPM on this device. + * If so (likely), disable L0S, so device moves directly L0->L1; + * costs negligible amount of power savings. + * If not (unlikely), enable L0S, so there is at least some + * power savings, even without L1. + */ + if (il->cfg->base_params->set_l0s) { + lctl = il_pcie_link_ctl(il); + if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) == + PCI_CFG_LINK_CTRL_VAL_L1_EN) { + /* L1-ASPM enabled; disable(!) L0S */ + il_set_bit(il, CSR_GIO_REG, + CSR_GIO_REG_VAL_L0S_ENABLED); + D_POWER("L1 Enabled; Disabling L0S\n"); + } else { + /* L1-ASPM disabled; enable(!) L0S */ + il_clear_bit(il, CSR_GIO_REG, + CSR_GIO_REG_VAL_L0S_ENABLED); + D_POWER("L1 Disabled; Enabling L0S\n"); + } + } + + /* Configure analog phase-lock-loop before activating to D0A */ + if (il->cfg->base_params->pll_cfg_val) + il_set_bit(il, CSR_ANA_PLL_CFG, + il->cfg->base_params->pll_cfg_val); + + /* + * Set "initialization complete" bit to move adapter from + * D0U* --> D0A* (powered-up active) state. + */ + il_set_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); + + /* + * Wait for clock stabilization; once stabilized, access to + * device-internal resources is supported, e.g. il_wr_prph() + * and accesses to uCode SRAM. + */ + ret = _il_poll_bit(il, CSR_GP_CNTRL, + CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, + CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); + if (ret < 0) { + D_INFO("Failed to init the card\n"); + goto out; + } + + /* + * Enable DMA and BSM (if used) clocks, wait for them to stabilize. + * BSM (Boostrap State Machine) is only in 3945 and 4965. + * + * Write to "CLK_EN_REG"; "1" bits enable clocks, while "0" bits + * do not disable clocks. This preserves any hardware bits already + * set by default in "CLK_CTRL_REG" after reset. + */ + if (il->cfg->base_params->use_bsm) + il_wr_prph(il, APMG_CLK_EN_REG, + APMG_CLK_VAL_DMA_CLK_RQT | APMG_CLK_VAL_BSM_CLK_RQT); + else + il_wr_prph(il, APMG_CLK_EN_REG, + APMG_CLK_VAL_DMA_CLK_RQT); + udelay(20); + + /* Disable L1-Active */ + il_set_bits_prph(il, APMG_PCIDEV_STT_REG, + APMG_PCIDEV_STT_VAL_L1_ACT_DIS); + +out: + return ret; +} +EXPORT_SYMBOL(il_apm_init); + + +int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) +{ + int ret; + s8 prev_tx_power; + bool defer; + struct il_rxon_context *ctx = &il->ctx; + + lockdep_assert_held(&il->mutex); + + if (il->tx_power_user_lmt == tx_power && !force) + return 0; + + if (!il->cfg->ops->lib->send_tx_power) + return -EOPNOTSUPP; + + /* 0 dBm mean 1 milliwatt */ + if (tx_power < 0) { + IL_WARN( + "Requested user TXPOWER %d below 1 mW.\n", + tx_power); + return -EINVAL; + } + + if (tx_power > il->tx_power_device_lmt) { + IL_WARN( + "Requested user TXPOWER %d above upper limit %d.\n", + tx_power, il->tx_power_device_lmt); + return -EINVAL; + } + + if (!il_is_ready_rf(il)) + return -EIO; + + /* scan complete and commit_rxon use tx_power_next value, + * it always need to be updated for newest request */ + il->tx_power_next = tx_power; + + /* do not set tx power when scanning or channel changing */ + defer = test_bit(S_SCANNING, &il->status) || + memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging)); + if (defer && !force) { + D_INFO("Deferring tx power set\n"); + return 0; + } + + prev_tx_power = il->tx_power_user_lmt; + il->tx_power_user_lmt = tx_power; + + ret = il->cfg->ops->lib->send_tx_power(il); + + /* if fail to set tx_power, restore the orig. tx power */ + if (ret) { + il->tx_power_user_lmt = prev_tx_power; + il->tx_power_next = prev_tx_power; + } + return ret; +} +EXPORT_SYMBOL(il_set_tx_power); + +void il_send_bt_config(struct il_priv *il) +{ + struct il_bt_cmd bt_cmd = { + .lead_time = BT_LEAD_TIME_DEF, + .max_kill = BT_MAX_KILL_DEF, + .kill_ack_mask = 0, + .kill_cts_mask = 0, + }; + + if (!bt_coex_active) + bt_cmd.flags = BT_COEX_DISABLE; + else + bt_cmd.flags = BT_COEX_ENABLE; + + D_INFO("BT coex %s\n", + (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active"); + + if (il_send_cmd_pdu(il, C_BT_CONFIG, + sizeof(struct il_bt_cmd), &bt_cmd)) + IL_ERR("failed to send BT Coex Config\n"); +} +EXPORT_SYMBOL(il_send_bt_config); + +int il_send_stats_request(struct il_priv *il, u8 flags, bool clear) +{ + struct il_stats_cmd stats_cmd = { + .configuration_flags = + clear ? IL_STATS_CONF_CLEAR_STATS : 0, + }; + + if (flags & CMD_ASYNC) + return il_send_cmd_pdu_async(il, C_STATS, + sizeof(struct il_stats_cmd), + &stats_cmd, NULL); + else + return il_send_cmd_pdu(il, C_STATS, + sizeof(struct il_stats_cmd), + &stats_cmd); +} +EXPORT_SYMBOL(il_send_stats_request); + +void il_hdl_pm_sleep(struct il_priv *il, + struct il_rx_buf *rxb) +{ +#ifdef CONFIG_IWLEGACY_DEBUG + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il_sleep_notification *sleep = &(pkt->u.sleep_notif); + D_RX("sleep mode: %d, src: %d\n", + sleep->pm_sleep_mode, sleep->pm_wakeup_src); +#endif +} +EXPORT_SYMBOL(il_hdl_pm_sleep); + +void il_hdl_pm_debug_stats(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; + D_RADIO("Dumping %d bytes of unhandled " + "notification for %s:\n", len, + il_get_cmd_string(pkt->hdr.cmd)); + il_print_hex_dump(il, IL_DL_RADIO, pkt->u.raw, len); +} +EXPORT_SYMBOL(il_hdl_pm_debug_stats); + +void il_hdl_error(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + + IL_ERR("Error Reply type 0x%08X cmd %s (0x%02X) " + "seq 0x%04X ser 0x%08X\n", + le32_to_cpu(pkt->u.err_resp.error_type), + il_get_cmd_string(pkt->u.err_resp.cmd_id), + pkt->u.err_resp.cmd_id, + le16_to_cpu(pkt->u.err_resp.bad_cmd_seq_num), + le32_to_cpu(pkt->u.err_resp.error_info)); +} +EXPORT_SYMBOL(il_hdl_error); + +void il_clear_isr_stats(struct il_priv *il) +{ + memset(&il->isr_stats, 0, sizeof(il->isr_stats)); +} + +int il_mac_conf_tx(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, u16 queue, + const struct ieee80211_tx_queue_params *params) +{ + struct il_priv *il = hw->priv; + unsigned long flags; + int q; + + D_MAC80211("enter\n"); + + if (!il_is_ready_rf(il)) { + D_MAC80211("leave - RF not ready\n"); + return -EIO; + } + + if (queue >= AC_NUM) { + D_MAC80211("leave - queue >= AC_NUM %d\n", queue); + return 0; + } + + q = AC_NUM - 1 - queue; + + spin_lock_irqsave(&il->lock, flags); + + il->ctx.qos_data.def_qos_parm.ac[q].cw_min = + cpu_to_le16(params->cw_min); + il->ctx.qos_data.def_qos_parm.ac[q].cw_max = + cpu_to_le16(params->cw_max); + il->ctx.qos_data.def_qos_parm.ac[q].aifsn = params->aifs; + il->ctx.qos_data.def_qos_parm.ac[q].edca_txop = + cpu_to_le16((params->txop * 32)); + + il->ctx.qos_data.def_qos_parm.ac[q].reserved1 = 0; + + spin_unlock_irqrestore(&il->lock, flags); + + D_MAC80211("leave\n"); + return 0; +} +EXPORT_SYMBOL(il_mac_conf_tx); + +int il_mac_tx_last_beacon(struct ieee80211_hw *hw) +{ + struct il_priv *il = hw->priv; + + return il->ibss_manager == IL_IBSS_MANAGER; +} +EXPORT_SYMBOL_GPL(il_mac_tx_last_beacon); + +static int +il_set_mode(struct il_priv *il, struct il_rxon_context *ctx) +{ + il_connection_init_rx_config(il, ctx); + + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); + + return il_commit_rxon(il, ctx); +} + +static int il_setup_interface(struct il_priv *il, + struct il_rxon_context *ctx) +{ + struct ieee80211_vif *vif = ctx->vif; + int err; + + lockdep_assert_held(&il->mutex); + + /* + * This variable will be correct only when there's just + * a single context, but all code using it is for hardware + * that supports only one context. + */ + il->iw_mode = vif->type; + + ctx->is_active = true; + + err = il_set_mode(il, ctx); + if (err) { + if (!ctx->always_active) + ctx->is_active = false; + return err; + } + + return 0; +} + +int +il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) +{ + struct il_priv *il = hw->priv; + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; + int err; + u32 modes; + + D_MAC80211("enter: type %d, addr %pM\n", + vif->type, vif->addr); + + mutex_lock(&il->mutex); + + if (!il_is_ready_rf(il)) { + IL_WARN("Try to add interface when device not ready\n"); + err = -EINVAL; + goto out; + } + + + /* check if busy context is exclusive */ + if (il->ctx.vif && + (il->ctx.exclusive_interface_modes & BIT(il->ctx.vif->type))) { + err = -EINVAL; + goto out; + } + + modes = il->ctx.interface_modes | il->ctx.exclusive_interface_modes; + if (!(modes & BIT(vif->type))) { + err = -EOPNOTSUPP; + goto out; + } + + vif_priv->ctx = &il->ctx; + il->ctx.vif = vif; + + err = il_setup_interface(il, &il->ctx); + if (err) { + il->ctx.vif = NULL; + il->iw_mode = NL80211_IFTYPE_STATION; + } + + out: + mutex_unlock(&il->mutex); + + D_MAC80211("leave\n"); + return err; +} +EXPORT_SYMBOL(il_mac_add_interface); + +static void il_teardown_interface(struct il_priv *il, + struct ieee80211_vif *vif, + bool mode_change) +{ + struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); + + lockdep_assert_held(&il->mutex); + + if (il->scan_vif == vif) { + il_scan_cancel_timeout(il, 200); + il_force_scan_end(il); + } + + if (!mode_change) { + il_set_mode(il, ctx); + if (!ctx->always_active) + ctx->is_active = false; + } +} + +void il_mac_remove_interface(struct ieee80211_hw *hw, + struct ieee80211_vif *vif) +{ + struct il_priv *il = hw->priv; + struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); + + D_MAC80211("enter\n"); + + mutex_lock(&il->mutex); + + WARN_ON(ctx->vif != vif); + ctx->vif = NULL; + + il_teardown_interface(il, vif, false); + + memset(il->bssid, 0, ETH_ALEN); + mutex_unlock(&il->mutex); + + D_MAC80211("leave\n"); + +} +EXPORT_SYMBOL(il_mac_remove_interface); + +int il_alloc_txq_mem(struct il_priv *il) +{ + if (!il->txq) + il->txq = kzalloc( + sizeof(struct il_tx_queue) * + il->cfg->base_params->num_of_queues, + GFP_KERNEL); + if (!il->txq) { + IL_ERR("Not enough memory for txq\n"); + return -ENOMEM; + } + return 0; +} +EXPORT_SYMBOL(il_alloc_txq_mem); + +void il_txq_mem(struct il_priv *il) +{ + kfree(il->txq); + il->txq = NULL; +} +EXPORT_SYMBOL(il_txq_mem); + +#ifdef CONFIG_IWLEGACY_DEBUGFS + +#define IL_TRAFFIC_DUMP_SIZE (IL_TRAFFIC_ENTRY_SIZE * IL_TRAFFIC_ENTRIES) + +void il_reset_traffic_log(struct il_priv *il) +{ + il->tx_traffic_idx = 0; + il->rx_traffic_idx = 0; + if (il->tx_traffic) + memset(il->tx_traffic, 0, IL_TRAFFIC_DUMP_SIZE); + if (il->rx_traffic) + memset(il->rx_traffic, 0, IL_TRAFFIC_DUMP_SIZE); +} + +int il_alloc_traffic_mem(struct il_priv *il) +{ + u32 traffic_size = IL_TRAFFIC_DUMP_SIZE; + + if (il_debug_level & IL_DL_TX) { + if (!il->tx_traffic) { + il->tx_traffic = + kzalloc(traffic_size, GFP_KERNEL); + if (!il->tx_traffic) + return -ENOMEM; + } + } + if (il_debug_level & IL_DL_RX) { + if (!il->rx_traffic) { + il->rx_traffic = + kzalloc(traffic_size, GFP_KERNEL); + if (!il->rx_traffic) + return -ENOMEM; + } + } + il_reset_traffic_log(il); + return 0; +} +EXPORT_SYMBOL(il_alloc_traffic_mem); + +void il_free_traffic_mem(struct il_priv *il) +{ + kfree(il->tx_traffic); + il->tx_traffic = NULL; + + kfree(il->rx_traffic); + il->rx_traffic = NULL; +} +EXPORT_SYMBOL(il_free_traffic_mem); + +void il_dbg_log_tx_data_frame(struct il_priv *il, + u16 length, struct ieee80211_hdr *header) +{ + __le16 fc; + u16 len; + + if (likely(!(il_debug_level & IL_DL_TX))) + return; + + if (!il->tx_traffic) + return; + + fc = header->frame_control; + if (ieee80211_is_data(fc)) { + len = (length > IL_TRAFFIC_ENTRY_SIZE) + ? IL_TRAFFIC_ENTRY_SIZE : length; + memcpy((il->tx_traffic + + (il->tx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), + header, len); + il->tx_traffic_idx = + (il->tx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; + } +} +EXPORT_SYMBOL(il_dbg_log_tx_data_frame); + +void il_dbg_log_rx_data_frame(struct il_priv *il, + u16 length, struct ieee80211_hdr *header) +{ + __le16 fc; + u16 len; + + if (likely(!(il_debug_level & IL_DL_RX))) + return; + + if (!il->rx_traffic) + return; + + fc = header->frame_control; + if (ieee80211_is_data(fc)) { + len = (length > IL_TRAFFIC_ENTRY_SIZE) + ? IL_TRAFFIC_ENTRY_SIZE : length; + memcpy((il->rx_traffic + + (il->rx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), + header, len); + il->rx_traffic_idx = + (il->rx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; + } +} +EXPORT_SYMBOL(il_dbg_log_rx_data_frame); + +const char *il_get_mgmt_string(int cmd) +{ + switch (cmd) { + IL_CMD(MANAGEMENT_ASSOC_REQ); + IL_CMD(MANAGEMENT_ASSOC_RESP); + IL_CMD(MANAGEMENT_REASSOC_REQ); + IL_CMD(MANAGEMENT_REASSOC_RESP); + IL_CMD(MANAGEMENT_PROBE_REQ); + IL_CMD(MANAGEMENT_PROBE_RESP); + IL_CMD(MANAGEMENT_BEACON); + IL_CMD(MANAGEMENT_ATIM); + IL_CMD(MANAGEMENT_DISASSOC); + IL_CMD(MANAGEMENT_AUTH); + IL_CMD(MANAGEMENT_DEAUTH); + IL_CMD(MANAGEMENT_ACTION); + default: + return "UNKNOWN"; + + } +} + +const char *il_get_ctrl_string(int cmd) +{ + switch (cmd) { + IL_CMD(CONTROL_BACK_REQ); + IL_CMD(CONTROL_BACK); + IL_CMD(CONTROL_PSPOLL); + IL_CMD(CONTROL_RTS); + IL_CMD(CONTROL_CTS); + IL_CMD(CONTROL_ACK); + IL_CMD(CONTROL_CFEND); + IL_CMD(CONTROL_CFENDACK); + default: + return "UNKNOWN"; + + } +} + +void il_clear_traffic_stats(struct il_priv *il) +{ + memset(&il->tx_stats, 0, sizeof(struct traffic_stats)); + memset(&il->rx_stats, 0, sizeof(struct traffic_stats)); +} + +/* + * if CONFIG_IWLEGACY_DEBUGFS defined, + * il_update_stats function will + * record all the MGMT, CTRL and DATA pkt for both TX and Rx pass + * Use debugFs to display the rx/rx_stats + * if CONFIG_IWLEGACY_DEBUGFS not being defined, then no MGMT and CTRL + * information will be recorded, but DATA pkt still will be recorded + * for the reason of il_led.c need to control the led blinking based on + * number of tx and rx data. + * + */ +void +il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, u16 len) +{ + struct traffic_stats *stats; + + if (is_tx) + stats = &il->tx_stats; + else + stats = &il->rx_stats; + + if (ieee80211_is_mgmt(fc)) { + switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) { + case cpu_to_le16(IEEE80211_STYPE_ASSOC_REQ): + stats->mgmt[MANAGEMENT_ASSOC_REQ]++; + break; + case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP): + stats->mgmt[MANAGEMENT_ASSOC_RESP]++; + break; + case cpu_to_le16(IEEE80211_STYPE_REASSOC_REQ): + stats->mgmt[MANAGEMENT_REASSOC_REQ]++; + break; + case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP): + stats->mgmt[MANAGEMENT_REASSOC_RESP]++; + break; + case cpu_to_le16(IEEE80211_STYPE_PROBE_REQ): + stats->mgmt[MANAGEMENT_PROBE_REQ]++; + break; + case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP): + stats->mgmt[MANAGEMENT_PROBE_RESP]++; + break; + case cpu_to_le16(IEEE80211_STYPE_BEACON): + stats->mgmt[MANAGEMENT_BEACON]++; + break; + case cpu_to_le16(IEEE80211_STYPE_ATIM): + stats->mgmt[MANAGEMENT_ATIM]++; + break; + case cpu_to_le16(IEEE80211_STYPE_DISASSOC): + stats->mgmt[MANAGEMENT_DISASSOC]++; + break; + case cpu_to_le16(IEEE80211_STYPE_AUTH): + stats->mgmt[MANAGEMENT_AUTH]++; + break; + case cpu_to_le16(IEEE80211_STYPE_DEAUTH): + stats->mgmt[MANAGEMENT_DEAUTH]++; + break; + case cpu_to_le16(IEEE80211_STYPE_ACTION): + stats->mgmt[MANAGEMENT_ACTION]++; + break; + } + } else if (ieee80211_is_ctl(fc)) { + switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) { + case cpu_to_le16(IEEE80211_STYPE_BACK_REQ): + stats->ctrl[CONTROL_BACK_REQ]++; + break; + case cpu_to_le16(IEEE80211_STYPE_BACK): + stats->ctrl[CONTROL_BACK]++; + break; + case cpu_to_le16(IEEE80211_STYPE_PSPOLL): + stats->ctrl[CONTROL_PSPOLL]++; + break; + case cpu_to_le16(IEEE80211_STYPE_RTS): + stats->ctrl[CONTROL_RTS]++; + break; + case cpu_to_le16(IEEE80211_STYPE_CTS): + stats->ctrl[CONTROL_CTS]++; + break; + case cpu_to_le16(IEEE80211_STYPE_ACK): + stats->ctrl[CONTROL_ACK]++; + break; + case cpu_to_le16(IEEE80211_STYPE_CFEND): + stats->ctrl[CONTROL_CFEND]++; + break; + case cpu_to_le16(IEEE80211_STYPE_CFENDACK): + stats->ctrl[CONTROL_CFENDACK]++; + break; + } + } else { + /* data */ + stats->data_cnt++; + stats->data_bytes += len; + } +} +EXPORT_SYMBOL(il_update_stats); +#endif + +int il_force_reset(struct il_priv *il, bool external) +{ + struct il_force_reset *force_reset; + + if (test_bit(S_EXIT_PENDING, &il->status)) + return -EINVAL; + + force_reset = &il->force_reset; + force_reset->reset_request_count++; + if (!external) { + if (force_reset->last_force_reset_jiffies && + time_after(force_reset->last_force_reset_jiffies + + force_reset->reset_duration, jiffies)) { + D_INFO("force reset rejected\n"); + force_reset->reset_reject_count++; + return -EAGAIN; + } + } + force_reset->reset_success_count++; + force_reset->last_force_reset_jiffies = jiffies; + + /* + * if the request is from external(ex: debugfs), + * then always perform the request in regardless the module + * parameter setting + * if the request is from internal (uCode error or driver + * detect failure), then fw_restart module parameter + * need to be check before performing firmware reload + */ + + if (!external && !il->cfg->mod_params->restart_fw) { + D_INFO("Cancel firmware reload based on " + "module parameter setting\n"); + return 0; + } + + IL_ERR("On demand firmware reload\n"); + + /* Set the FW error flag -- cleared on il_down */ + set_bit(S_FW_ERROR, &il->status); + wake_up(&il->wait_command_queue); + /* + * Keep the restart process from trying to send host + * commands by clearing the INIT status bit + */ + clear_bit(S_READY, &il->status); + queue_work(il->workqueue, &il->restart); + + return 0; +} + +int +il_mac_change_interface(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + enum nl80211_iftype newtype, bool newp2p) +{ + struct il_priv *il = hw->priv; + struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); + u32 modes; + int err; + + newtype = ieee80211_iftype_p2p(newtype, newp2p); + + mutex_lock(&il->mutex); + + if (!ctx->vif || !il_is_ready_rf(il)) { + /* + * Huh? But wait ... this can maybe happen when + * we're in the middle of a firmware restart! + */ + err = -EBUSY; + goto out; + } + + modes = ctx->interface_modes | ctx->exclusive_interface_modes; + if (!(modes & BIT(newtype))) { + err = -EOPNOTSUPP; + goto out; + } + + if ((il->ctx.exclusive_interface_modes & BIT(il->ctx.vif->type)) || + (il->ctx.exclusive_interface_modes & BIT(newtype))) { + err = -EINVAL; + goto out; + } + + /* success */ + il_teardown_interface(il, vif, true); + vif->type = newtype; + vif->p2p = newp2p; + err = il_setup_interface(il, ctx); + WARN_ON(err); + /* + * We've switched internally, but submitting to the + * device may have failed for some reason. Mask this + * error, because otherwise mac80211 will not switch + * (and set the interface type back) and we'll be + * out of sync with it. + */ + err = 0; + + out: + mutex_unlock(&il->mutex); + return err; +} +EXPORT_SYMBOL(il_mac_change_interface); + +/* + * On every watchdog tick we check (latest) time stamp. If it does not + * change during timeout period and queue is not empty we reset firmware. + */ +static int il_check_stuck_queue(struct il_priv *il, int cnt) +{ + struct il_tx_queue *txq = &il->txq[cnt]; + struct il_queue *q = &txq->q; + unsigned long timeout; + int ret; + + if (q->read_ptr == q->write_ptr) { + txq->time_stamp = jiffies; + return 0; + } + + timeout = txq->time_stamp + + msecs_to_jiffies(il->cfg->base_params->wd_timeout); + + if (time_after(jiffies, timeout)) { + IL_ERR("Queue %d stuck for %u ms.\n", + q->id, il->cfg->base_params->wd_timeout); + ret = il_force_reset(il, false); + return (ret == -EAGAIN) ? 0 : 1; + } + + return 0; +} + +/* + * Making watchdog tick be a quarter of timeout assure we will + * discover the queue hung between timeout and 1.25*timeout + */ +#define IL_WD_TICK(timeout) ((timeout) / 4) + +/* + * Watchdog timer callback, we check each tx queue for stuck, if if hung + * we reset the firmware. If everything is fine just rearm the timer. + */ +void il_bg_watchdog(unsigned long data) +{ + struct il_priv *il = (struct il_priv *)data; + int cnt; + unsigned long timeout; + + if (test_bit(S_EXIT_PENDING, &il->status)) + return; + + timeout = il->cfg->base_params->wd_timeout; + if (timeout == 0) + return; + + /* monitor and check for stuck cmd queue */ + if (il_check_stuck_queue(il, il->cmd_queue)) + return; + + /* monitor and check for other stuck queues */ + if (il_is_any_associated(il)) { + for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { + /* skip as we already checked the command queue */ + if (cnt == il->cmd_queue) + continue; + if (il_check_stuck_queue(il, cnt)) + return; + } + } + + mod_timer(&il->watchdog, jiffies + + msecs_to_jiffies(IL_WD_TICK(timeout))); +} +EXPORT_SYMBOL(il_bg_watchdog); + +void il_setup_watchdog(struct il_priv *il) +{ + unsigned int timeout = il->cfg->base_params->wd_timeout; + + if (timeout) + mod_timer(&il->watchdog, + jiffies + msecs_to_jiffies(IL_WD_TICK(timeout))); + else + del_timer(&il->watchdog); +} +EXPORT_SYMBOL(il_setup_watchdog); + +/* + * extended beacon time format + * time in usec will be changed into a 32-bit value in extended:internal format + * the extended part is the beacon counts + * the internal part is the time in usec within one beacon interval + */ +u32 +il_usecs_to_beacons(struct il_priv *il, + u32 usec, u32 beacon_interval) +{ + u32 quot; + u32 rem; + u32 interval = beacon_interval * TIME_UNIT; + + if (!interval || !usec) + return 0; + + quot = (usec / interval) & + (il_beacon_time_mask_high(il, + il->hw_params.beacon_time_tsf_bits) >> + il->hw_params.beacon_time_tsf_bits); + rem = (usec % interval) & il_beacon_time_mask_low(il, + il->hw_params.beacon_time_tsf_bits); + + return (quot << il->hw_params.beacon_time_tsf_bits) + rem; +} +EXPORT_SYMBOL(il_usecs_to_beacons); + +/* base is usually what we get from ucode with each received frame, + * the same as HW timer counter counting down + */ +__le32 il_add_beacon_time(struct il_priv *il, u32 base, + u32 addon, u32 beacon_interval) +{ + u32 base_low = base & il_beacon_time_mask_low(il, + il->hw_params.beacon_time_tsf_bits); + u32 addon_low = addon & il_beacon_time_mask_low(il, + il->hw_params.beacon_time_tsf_bits); + u32 interval = beacon_interval * TIME_UNIT; + u32 res = (base & il_beacon_time_mask_high(il, + il->hw_params.beacon_time_tsf_bits)) + + (addon & il_beacon_time_mask_high(il, + il->hw_params.beacon_time_tsf_bits)); + + if (base_low > addon_low) + res += base_low - addon_low; + else if (base_low < addon_low) { + res += interval + base_low - addon_low; + res += (1 << il->hw_params.beacon_time_tsf_bits); + } else + res += (1 << il->hw_params.beacon_time_tsf_bits); + + return cpu_to_le32(res); +} +EXPORT_SYMBOL(il_add_beacon_time); + +#ifdef CONFIG_PM + +int il_pci_suspend(struct device *device) +{ + struct pci_dev *pdev = to_pci_dev(device); + struct il_priv *il = pci_get_drvdata(pdev); + + /* + * This function is called when system goes into suspend state + * mac80211 will call il_mac_stop() from the mac80211 suspend function + * first but since il_mac_stop() has no knowledge of who the caller is, + * it will not call apm_ops.stop() to stop the DMA operation. + * Calling apm_ops.stop here to make sure we stop the DMA. + */ + il_apm_stop(il); + + return 0; +} +EXPORT_SYMBOL(il_pci_suspend); + +int il_pci_resume(struct device *device) +{ + struct pci_dev *pdev = to_pci_dev(device); + struct il_priv *il = pci_get_drvdata(pdev); + bool hw_rfkill = false; + + /* + * We disable the RETRY_TIMEOUT register (0x41) to keep + * PCI Tx retries from interfering with C3 CPU state. + */ + pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); + + il_enable_interrupts(il); + + if (!(_il_rd(il, CSR_GP_CNTRL) & + CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) + hw_rfkill = true; + + if (hw_rfkill) + set_bit(S_RF_KILL_HW, &il->status); + else + clear_bit(S_RF_KILL_HW, &il->status); + + wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rfkill); + + return 0; +} +EXPORT_SYMBOL(il_pci_resume); + +const struct dev_pm_ops il_pm_ops = { + .suspend = il_pci_suspend, + .resume = il_pci_resume, + .freeze = il_pci_suspend, + .thaw = il_pci_resume, + .poweroff = il_pci_suspend, + .restore = il_pci_resume, +}; +EXPORT_SYMBOL(il_pm_ops); + +#endif /* CONFIG_PM */ + +static void +il_update_qos(struct il_priv *il, struct il_rxon_context *ctx) +{ + if (test_bit(S_EXIT_PENDING, &il->status)) + return; + + if (!ctx->is_active) + return; + + ctx->qos_data.def_qos_parm.qos_flags = 0; + + if (ctx->qos_data.qos_active) + ctx->qos_data.def_qos_parm.qos_flags |= + QOS_PARAM_FLG_UPDATE_EDCA_MSK; + + if (ctx->ht.enabled) + ctx->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; + + D_QOS("send QoS cmd with Qos active=%d FLAGS=0x%X\n", + ctx->qos_data.qos_active, + ctx->qos_data.def_qos_parm.qos_flags); + + il_send_cmd_pdu_async(il, ctx->qos_cmd, + sizeof(struct il_qosparam_cmd), + &ctx->qos_data.def_qos_parm, NULL); +} + +/** + * il_mac_config - mac80211 config callback + */ +int il_mac_config(struct ieee80211_hw *hw, u32 changed) +{ + struct il_priv *il = hw->priv; + const struct il_channel_info *ch_info; + struct ieee80211_conf *conf = &hw->conf; + struct ieee80211_channel *channel = conf->channel; + struct il_ht_config *ht_conf = &il->current_ht_config; + struct il_rxon_context *ctx = &il->ctx; + unsigned long flags = 0; + int ret = 0; + u16 ch; + int scan_active = 0; + bool ht_changed = false; + + if (WARN_ON(!il->cfg->ops->legacy)) + return -EOPNOTSUPP; + + mutex_lock(&il->mutex); + + D_MAC80211("enter to channel %d changed 0x%X\n", + channel->hw_value, changed); + + if (unlikely(test_bit(S_SCANNING, &il->status))) { + scan_active = 1; + D_MAC80211("scan active\n"); + } + + if (changed & (IEEE80211_CONF_CHANGE_SMPS | + IEEE80211_CONF_CHANGE_CHANNEL)) { + /* mac80211 uses static for non-HT which is what we want */ + il->current_ht_config.smps = conf->smps_mode; + + /* + * Recalculate chain counts. + * + * If monitor mode is enabled then mac80211 will + * set up the SM PS mode to OFF if an HT channel is + * configured. + */ + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, &il->ctx); + } + + /* during scanning mac80211 will delay channel setting until + * scan finish with changed = 0 + */ + if (!changed || (changed & IEEE80211_CONF_CHANGE_CHANNEL)) { + + if (scan_active) + goto set_ch_out; + + ch = channel->hw_value; + ch_info = il_get_channel_info(il, channel->band, ch); + if (!il_is_channel_valid(ch_info)) { + D_MAC80211("leave - invalid channel\n"); + ret = -EINVAL; + goto set_ch_out; + } + + if (il->iw_mode == NL80211_IFTYPE_ADHOC && + !il_is_channel_ibss(ch_info)) { + D_MAC80211("leave - not IBSS channel\n"); + ret = -EINVAL; + goto set_ch_out; + } + + spin_lock_irqsave(&il->lock, flags); + + /* Configure HT40 channels */ + if (ctx->ht.enabled != conf_is_ht(conf)) { + ctx->ht.enabled = conf_is_ht(conf); + ht_changed = true; + } + if (ctx->ht.enabled) { + if (conf_is_ht40_minus(conf)) { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_BELOW; + ctx->ht.is_40mhz = true; + } else if (conf_is_ht40_plus(conf)) { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_ABOVE; + ctx->ht.is_40mhz = true; + } else { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_NONE; + ctx->ht.is_40mhz = false; + } + } else + ctx->ht.is_40mhz = false; + + /* + * Default to no protection. Protection mode will + * later be set from BSS config in il_ht_conf + */ + ctx->ht.protection = + IEEE80211_HT_OP_MODE_PROTECTION_NONE; + + /* if we are switching from ht to 2.4 clear flags + * from any ht related info since 2.4 does not + * support ht */ + if ((le16_to_cpu(ctx->staging.channel) != ch)) + ctx->staging.flags = 0; + + il_set_rxon_channel(il, channel, ctx); + il_set_rxon_ht(il, ht_conf); + + il_set_flags_for_band(il, ctx, channel->band, + ctx->vif); + + spin_unlock_irqrestore(&il->lock, flags); + + if (il->cfg->ops->legacy->update_bcast_stations) + ret = + il->cfg->ops->legacy->update_bcast_stations(il); + + set_ch_out: + /* The list of supported rates and rate mask can be different + * for each band; since the band may have changed, reset + * the rate mask to what mac80211 lists */ + il_set_rate(il); + } + + if (changed & (IEEE80211_CONF_CHANGE_PS | + IEEE80211_CONF_CHANGE_IDLE)) { + ret = il_power_update_mode(il, false); + if (ret) + D_MAC80211("Error setting sleep level\n"); + } + + if (changed & IEEE80211_CONF_CHANGE_POWER) { + D_MAC80211("TX Power old=%d new=%d\n", + il->tx_power_user_lmt, conf->power_level); + + il_set_tx_power(il, conf->power_level, false); + } + + if (!il_is_ready(il)) { + D_MAC80211("leave - not ready\n"); + goto out; + } + + if (scan_active) + goto out; + + if (memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging))) + il_commit_rxon(il, ctx); + else + D_INFO("Not re-sending same RXON configuration.\n"); + if (ht_changed) + il_update_qos(il, ctx); + +out: + D_MAC80211("leave\n"); + mutex_unlock(&il->mutex); + return ret; +} +EXPORT_SYMBOL(il_mac_config); + +void il_mac_reset_tsf(struct ieee80211_hw *hw, + struct ieee80211_vif *vif) +{ + struct il_priv *il = hw->priv; + unsigned long flags; + struct il_rxon_context *ctx = &il->ctx; + + if (WARN_ON(!il->cfg->ops->legacy)) + return; + + mutex_lock(&il->mutex); + D_MAC80211("enter\n"); + + spin_lock_irqsave(&il->lock, flags); + memset(&il->current_ht_config, 0, sizeof(struct il_ht_config)); + spin_unlock_irqrestore(&il->lock, flags); + + spin_lock_irqsave(&il->lock, flags); + + /* new association get rid of ibss beacon skb */ + if (il->beacon_skb) + dev_kfree_skb(il->beacon_skb); + + il->beacon_skb = NULL; + + il->timestamp = 0; + + spin_unlock_irqrestore(&il->lock, flags); + + il_scan_cancel_timeout(il, 100); + if (!il_is_ready_rf(il)) { + D_MAC80211("leave - not ready\n"); + mutex_unlock(&il->mutex); + return; + } + + /* we are restarting association process + * clear RXON_FILTER_ASSOC_MSK bit + */ + ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; + il_commit_rxon(il, ctx); + + il_set_rate(il); + + mutex_unlock(&il->mutex); + + D_MAC80211("leave\n"); +} +EXPORT_SYMBOL(il_mac_reset_tsf); + +static void il_ht_conf(struct il_priv *il, + struct ieee80211_vif *vif) +{ + struct il_ht_config *ht_conf = &il->current_ht_config; + struct ieee80211_sta *sta; + struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; + struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); + + D_ASSOC("enter:\n"); + + if (!ctx->ht.enabled) + return; + + ctx->ht.protection = + bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION; + ctx->ht.non_gf_sta_present = + !!(bss_conf->ht_operation_mode & + IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); + + ht_conf->single_chain_sufficient = false; + + switch (vif->type) { + case NL80211_IFTYPE_STATION: + rcu_read_lock(); + sta = ieee80211_find_sta(vif, bss_conf->bssid); + if (sta) { + struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; + int maxstreams; + + maxstreams = (ht_cap->mcs.tx_params & + IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK) + >> IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT; + maxstreams += 1; + + if (ht_cap->mcs.rx_mask[1] == 0 && + ht_cap->mcs.rx_mask[2] == 0) + ht_conf->single_chain_sufficient = true; + if (maxstreams <= 1) + ht_conf->single_chain_sufficient = true; + } else { + /* + * If at all, this can only happen through a race + * when the AP disconnects us while we're still + * setting up the connection, in that case mac80211 + * will soon tell us about that. + */ + ht_conf->single_chain_sufficient = true; + } + rcu_read_unlock(); + break; + case NL80211_IFTYPE_ADHOC: + ht_conf->single_chain_sufficient = true; + break; + default: + break; + } + + D_ASSOC("leave\n"); +} + +static inline void il_set_no_assoc(struct il_priv *il, + struct ieee80211_vif *vif) +{ + struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); + + /* + * inform the ucode that there is no longer an + * association and that no more packets should be + * sent + */ + ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; + ctx->staging.assoc_id = 0; + il_commit_rxon(il, ctx); +} + +static void il_beacon_update(struct ieee80211_hw *hw, + struct ieee80211_vif *vif) +{ + struct il_priv *il = hw->priv; + unsigned long flags; + __le64 timestamp; + struct sk_buff *skb = ieee80211_beacon_get(hw, vif); + + if (!skb) + return; + + D_MAC80211("enter\n"); + + lockdep_assert_held(&il->mutex); + + if (!il->beacon_ctx) { + IL_ERR("update beacon but no beacon context!\n"); + dev_kfree_skb(skb); + return; + } + + spin_lock_irqsave(&il->lock, flags); + + if (il->beacon_skb) + dev_kfree_skb(il->beacon_skb); + + il->beacon_skb = skb; + + timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp; + il->timestamp = le64_to_cpu(timestamp); + + D_MAC80211("leave\n"); + spin_unlock_irqrestore(&il->lock, flags); + + if (!il_is_ready_rf(il)) { + D_MAC80211("leave - RF not ready\n"); + return; + } + + il->cfg->ops->legacy->post_associate(il); +} + +void il_mac_bss_info_changed(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_bss_conf *bss_conf, + u32 changes) +{ + struct il_priv *il = hw->priv; + struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); + int ret; + + if (WARN_ON(!il->cfg->ops->legacy)) + return; + + D_MAC80211("changes = 0x%X\n", changes); + + mutex_lock(&il->mutex); + + if (!il_is_alive(il)) { + mutex_unlock(&il->mutex); + return; + } + + if (changes & BSS_CHANGED_QOS) { + unsigned long flags; + + spin_lock_irqsave(&il->lock, flags); + ctx->qos_data.qos_active = bss_conf->qos; + il_update_qos(il, ctx); + spin_unlock_irqrestore(&il->lock, flags); + } + + if (changes & BSS_CHANGED_BEACON_ENABLED) { + /* + * the add_interface code must make sure we only ever + * have a single interface that could be beaconing at + * any time. + */ + if (vif->bss_conf.enable_beacon) + il->beacon_ctx = ctx; + else + il->beacon_ctx = NULL; + } + + if (changes & BSS_CHANGED_BSSID) { + D_MAC80211("BSSID %pM\n", bss_conf->bssid); + + /* + * If there is currently a HW scan going on in the + * background then we need to cancel it else the RXON + * below/in post_associate will fail. + */ + if (il_scan_cancel_timeout(il, 100)) { + IL_WARN( + "Aborted scan still in progress after 100ms\n"); + D_MAC80211( + "leaving - scan abort failed.\n"); + mutex_unlock(&il->mutex); + return; + } + + /* mac80211 only sets assoc when in STATION mode */ + if (vif->type == NL80211_IFTYPE_ADHOC || bss_conf->assoc) { + memcpy(ctx->staging.bssid_addr, + bss_conf->bssid, ETH_ALEN); + + /* currently needed in a few places */ + memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); + } else { + ctx->staging.filter_flags &= + ~RXON_FILTER_ASSOC_MSK; + } + + } + + /* + * This needs to be after setting the BSSID in case + * mac80211 decides to do both changes at once because + * it will invoke post_associate. + */ + if (vif->type == NL80211_IFTYPE_ADHOC && (changes & BSS_CHANGED_BEACON)) + il_beacon_update(hw, vif); + + if (changes & BSS_CHANGED_ERP_PREAMBLE) { + D_MAC80211("ERP_PREAMBLE %d\n", + bss_conf->use_short_preamble); + if (bss_conf->use_short_preamble) + ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; + else + ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; + } + + if (changes & BSS_CHANGED_ERP_CTS_PROT) { + D_MAC80211( + "ERP_CTS %d\n", bss_conf->use_cts_prot); + if (bss_conf->use_cts_prot && il->band != IEEE80211_BAND_5GHZ) + ctx->staging.flags |= RXON_FLG_TGG_PROTECT_MSK; + else + ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK; + if (bss_conf->use_cts_prot) + ctx->staging.flags |= RXON_FLG_SELF_CTS_EN; + else + ctx->staging.flags &= ~RXON_FLG_SELF_CTS_EN; + } + + if (changes & BSS_CHANGED_BASIC_RATES) { + /* XXX use this information + * + * To do that, remove code from il_set_rate() and put something + * like this here: + * + if (A-band) + ctx->staging.ofdm_basic_rates = + bss_conf->basic_rates; + else + ctx->staging.ofdm_basic_rates = + bss_conf->basic_rates >> 4; + ctx->staging.cck_basic_rates = + bss_conf->basic_rates & 0xF; + */ + } + + if (changes & BSS_CHANGED_HT) { + il_ht_conf(il, vif); + + if (il->cfg->ops->hcmd->set_rxon_chain) + il->cfg->ops->hcmd->set_rxon_chain(il, ctx); + } + + if (changes & BSS_CHANGED_ASSOC) { + D_MAC80211("ASSOC %d\n", bss_conf->assoc); + if (bss_conf->assoc) { + il->timestamp = bss_conf->timestamp; + + if (!il_is_rfkill(il)) + il->cfg->ops->legacy->post_associate(il); + } else + il_set_no_assoc(il, vif); + } + + if (changes && il_is_associated_ctx(ctx) && bss_conf->aid) { + D_MAC80211("Changes (%#x) while associated\n", + changes); + ret = il_send_rxon_assoc(il, ctx); + if (!ret) { + /* Sync active_rxon with latest change. */ + memcpy((void *)&ctx->active, + &ctx->staging, + sizeof(struct il_rxon_cmd)); + } + } + + if (changes & BSS_CHANGED_BEACON_ENABLED) { + if (vif->bss_conf.enable_beacon) { + memcpy(ctx->staging.bssid_addr, + bss_conf->bssid, ETH_ALEN); + memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); + il->cfg->ops->legacy->config_ap(il); + } else + il_set_no_assoc(il, vif); + } + + if (changes & BSS_CHANGED_IBSS) { + ret = il->cfg->ops->legacy->manage_ibss_station(il, vif, + bss_conf->ibss_joined); + if (ret) + IL_ERR("failed to %s IBSS station %pM\n", + bss_conf->ibss_joined ? "add" : "remove", + bss_conf->bssid); + } + + mutex_unlock(&il->mutex); + + D_MAC80211("leave\n"); +} +EXPORT_SYMBOL(il_mac_bss_info_changed); + +irqreturn_t il_isr(int irq, void *data) +{ + struct il_priv *il = data; + u32 inta, inta_mask; + u32 inta_fh; + unsigned long flags; + if (!il) + return IRQ_NONE; + + spin_lock_irqsave(&il->lock, flags); + + /* Disable (but don't clear!) interrupts here to avoid + * back-to-back ISRs and sporadic interrupts from our NIC. + * If we have something to service, the tasklet will re-enable ints. + * If we *don't* have something, we'll re-enable before leaving here. */ + inta_mask = _il_rd(il, CSR_INT_MASK); /* just for debug */ + _il_wr(il, CSR_INT_MASK, 0x00000000); + + /* Discover which interrupts are active/pending */ + inta = _il_rd(il, CSR_INT); + inta_fh = _il_rd(il, CSR_FH_INT_STATUS); + + /* Ignore interrupt if there's nothing in NIC to service. + * This may be due to IRQ shared with another device, + * or due to sporadic interrupts thrown from our NIC. */ + if (!inta && !inta_fh) { + D_ISR( + "Ignore interrupt, inta == 0, inta_fh == 0\n"); + goto none; + } + + if (inta == 0xFFFFFFFF || (inta & 0xFFFFFFF0) == 0xa5a5a5a0) { + /* Hardware disappeared. It might have already raised + * an interrupt */ + IL_WARN("HARDWARE GONE?? INTA == 0x%08x\n", inta); + goto unplugged; + } + + D_ISR("ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", + inta, inta_mask, inta_fh); + + inta &= ~CSR_INT_BIT_SCD; + + /* il_irq_tasklet() will service interrupts and re-enable them */ + if (likely(inta || inta_fh)) + tasklet_schedule(&il->irq_tasklet); + +unplugged: + spin_unlock_irqrestore(&il->lock, flags); + return IRQ_HANDLED; + +none: + /* re-enable interrupts here since we don't have anything to service. */ + /* only Re-enable if disabled by irq */ + if (test_bit(S_INT_ENABLED, &il->status)) + il_enable_interrupts(il); + spin_unlock_irqrestore(&il->lock, flags); + return IRQ_NONE; +} +EXPORT_SYMBOL(il_isr); + +/* + * il_tx_cmd_protection: Set rts/cts. 3945 and 4965 only share this + * function. + */ +void il_tx_cmd_protection(struct il_priv *il, + struct ieee80211_tx_info *info, + __le16 fc, __le32 *tx_flags) +{ + if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) { + *tx_flags |= TX_CMD_FLG_RTS_MSK; + *tx_flags &= ~TX_CMD_FLG_CTS_MSK; + *tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; + + if (!ieee80211_is_mgmt(fc)) + return; + + switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) { + case cpu_to_le16(IEEE80211_STYPE_AUTH): + case cpu_to_le16(IEEE80211_STYPE_DEAUTH): + case cpu_to_le16(IEEE80211_STYPE_ASSOC_REQ): + case cpu_to_le16(IEEE80211_STYPE_REASSOC_REQ): + *tx_flags &= ~TX_CMD_FLG_RTS_MSK; + *tx_flags |= TX_CMD_FLG_CTS_MSK; + break; + } + } else if (info->control.rates[0].flags & + IEEE80211_TX_RC_USE_CTS_PROTECT) { + *tx_flags &= ~TX_CMD_FLG_RTS_MSK; + *tx_flags |= TX_CMD_FLG_CTS_MSK; + *tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; + } +} +EXPORT_SYMBOL(il_tx_cmd_protection); diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c deleted file mode 100644 index 856a321ed1ea..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-core.c +++ /dev/null @@ -1,2608 +0,0 @@ -/****************************************************************************** - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - *****************************************************************************/ - -#include -#include -#include -#include -#include -#include - -#include "iwl-eeprom.h" -#include "iwl-dev.h" -#include "iwl-debug.h" -#include "iwl-core.h" -#include "iwl-io.h" -#include "iwl-power.h" -#include "iwl-sta.h" -#include "iwl-helpers.h" - - -MODULE_DESCRIPTION("iwl-legacy: common functions for 3945 and 4965"); -MODULE_VERSION(IWLWIFI_VERSION); -MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); -MODULE_LICENSE("GPL"); - -/* - * set bt_coex_active to true, uCode will do kill/defer - * every time the priority line is asserted (BT is sending signals on the - * priority line in the PCIx). - * set bt_coex_active to false, uCode will ignore the BT activity and - * perform the normal operation - * - * User might experience transmit issue on some platform due to WiFi/BT - * co-exist problem. The possible behaviors are: - * Able to scan and finding all the available AP - * Not able to associate with any AP - * On those platforms, WiFi communication can be restored by set - * "bt_coex_active" module parameter to "false" - * - * default: bt_coex_active = true (BT_COEX_ENABLE) - */ -static bool bt_coex_active = true; -module_param(bt_coex_active, bool, S_IRUGO); -MODULE_PARM_DESC(bt_coex_active, "enable wifi/bluetooth co-exist"); - -u32 il_debug_level; -EXPORT_SYMBOL(il_debug_level); - -const u8 il_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; -EXPORT_SYMBOL(il_bcast_addr); - - -/* This function both allocates and initializes hw and il. */ -struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg) -{ - struct il_priv *il; - /* mac80211 allocates memory for this device instance, including - * space for this driver's ilate structure */ - struct ieee80211_hw *hw; - - hw = ieee80211_alloc_hw(sizeof(struct il_priv), - cfg->ops->ieee80211_ops); - if (hw == NULL) { - pr_err("%s: Can not allocate network device\n", - cfg->name); - goto out; - } - - il = hw->priv; - il->hw = hw; - -out: - return hw; -} -EXPORT_SYMBOL(il_alloc_all); - -#define MAX_BIT_RATE_40_MHZ 150 /* Mbps */ -#define MAX_BIT_RATE_20_MHZ 72 /* Mbps */ -static void il_init_ht_hw_capab(const struct il_priv *il, - struct ieee80211_sta_ht_cap *ht_info, - enum ieee80211_band band) -{ - u16 max_bit_rate = 0; - u8 rx_chains_num = il->hw_params.rx_chains_num; - u8 tx_chains_num = il->hw_params.tx_chains_num; - - ht_info->cap = 0; - memset(&ht_info->mcs, 0, sizeof(ht_info->mcs)); - - ht_info->ht_supported = true; - - ht_info->cap |= IEEE80211_HT_CAP_SGI_20; - max_bit_rate = MAX_BIT_RATE_20_MHZ; - if (il->hw_params.ht40_channel & BIT(band)) { - ht_info->cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40; - ht_info->cap |= IEEE80211_HT_CAP_SGI_40; - ht_info->mcs.rx_mask[4] = 0x01; - max_bit_rate = MAX_BIT_RATE_40_MHZ; - } - - if (il->cfg->mod_params->amsdu_size_8K) - ht_info->cap |= IEEE80211_HT_CAP_MAX_AMSDU; - - ht_info->ampdu_factor = CFG_HT_RX_AMPDU_FACTOR_DEF; - ht_info->ampdu_density = CFG_HT_MPDU_DENSITY_DEF; - - ht_info->mcs.rx_mask[0] = 0xFF; - if (rx_chains_num >= 2) - ht_info->mcs.rx_mask[1] = 0xFF; - if (rx_chains_num >= 3) - ht_info->mcs.rx_mask[2] = 0xFF; - - /* Highest supported Rx data rate */ - max_bit_rate *= rx_chains_num; - WARN_ON(max_bit_rate & ~IEEE80211_HT_MCS_RX_HIGHEST_MASK); - ht_info->mcs.rx_highest = cpu_to_le16(max_bit_rate); - - /* Tx MCS capabilities */ - ht_info->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; - if (tx_chains_num != rx_chains_num) { - ht_info->mcs.tx_params |= IEEE80211_HT_MCS_TX_RX_DIFF; - ht_info->mcs.tx_params |= ((tx_chains_num - 1) << - IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT); - } -} - -/** - * il_init_geos - Initialize mac80211's geo/channel info based from eeprom - */ -int il_init_geos(struct il_priv *il) -{ - struct il_channel_info *ch; - struct ieee80211_supported_band *sband; - struct ieee80211_channel *channels; - struct ieee80211_channel *geo_ch; - struct ieee80211_rate *rates; - int i = 0; - s8 max_tx_power = 0; - - if (il->bands[IEEE80211_BAND_2GHZ].n_bitrates || - il->bands[IEEE80211_BAND_5GHZ].n_bitrates) { - D_INFO("Geography modes already initialized.\n"); - set_bit(S_GEO_CONFIGURED, &il->status); - return 0; - } - - channels = kzalloc(sizeof(struct ieee80211_channel) * - il->channel_count, GFP_KERNEL); - if (!channels) - return -ENOMEM; - - rates = kzalloc((sizeof(struct ieee80211_rate) * RATE_COUNT_LEGACY), - GFP_KERNEL); - if (!rates) { - kfree(channels); - return -ENOMEM; - } - - /* 5.2GHz channels start after the 2.4GHz channels */ - sband = &il->bands[IEEE80211_BAND_5GHZ]; - sband->channels = &channels[ARRAY_SIZE(il_eeprom_band_1)]; - /* just OFDM */ - sband->bitrates = &rates[IL_FIRST_OFDM_RATE]; - sband->n_bitrates = RATE_COUNT_LEGACY - IL_FIRST_OFDM_RATE; - - if (il->cfg->sku & IL_SKU_N) - il_init_ht_hw_capab(il, &sband->ht_cap, - IEEE80211_BAND_5GHZ); - - sband = &il->bands[IEEE80211_BAND_2GHZ]; - sband->channels = channels; - /* OFDM & CCK */ - sband->bitrates = rates; - sband->n_bitrates = RATE_COUNT_LEGACY; - - if (il->cfg->sku & IL_SKU_N) - il_init_ht_hw_capab(il, &sband->ht_cap, - IEEE80211_BAND_2GHZ); - - il->ieee_channels = channels; - il->ieee_rates = rates; - - for (i = 0; i < il->channel_count; i++) { - ch = &il->channel_info[i]; - - if (!il_is_channel_valid(ch)) - continue; - - sband = &il->bands[ch->band]; - - geo_ch = &sband->channels[sband->n_channels++]; - - geo_ch->center_freq = - ieee80211_channel_to_frequency(ch->channel, ch->band); - geo_ch->max_power = ch->max_power_avg; - geo_ch->max_antenna_gain = 0xff; - geo_ch->hw_value = ch->channel; - - if (il_is_channel_valid(ch)) { - if (!(ch->flags & EEPROM_CHANNEL_IBSS)) - geo_ch->flags |= IEEE80211_CHAN_NO_IBSS; - - if (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) - geo_ch->flags |= IEEE80211_CHAN_PASSIVE_SCAN; - - if (ch->flags & EEPROM_CHANNEL_RADAR) - geo_ch->flags |= IEEE80211_CHAN_RADAR; - - geo_ch->flags |= ch->ht40_extension_channel; - - if (ch->max_power_avg > max_tx_power) - max_tx_power = ch->max_power_avg; - } else { - geo_ch->flags |= IEEE80211_CHAN_DISABLED; - } - - D_INFO("Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", - ch->channel, geo_ch->center_freq, - il_is_channel_a_band(ch) ? "5.2" : "2.4", - geo_ch->flags & IEEE80211_CHAN_DISABLED ? - "restricted" : "valid", - geo_ch->flags); - } - - il->tx_power_device_lmt = max_tx_power; - il->tx_power_user_lmt = max_tx_power; - il->tx_power_next = max_tx_power; - - if (il->bands[IEEE80211_BAND_5GHZ].n_channels == 0 && - (il->cfg->sku & IL_SKU_A)) { - IL_INFO("Incorrectly detected BG card as ABG. " - "Please send your PCI ID 0x%04X:0x%04X to maintainer.\n", - il->pci_dev->device, - il->pci_dev->subsystem_device); - il->cfg->sku &= ~IL_SKU_A; - } - - IL_INFO("Tunable channels: %d 802.11bg, %d 802.11a channels\n", - il->bands[IEEE80211_BAND_2GHZ].n_channels, - il->bands[IEEE80211_BAND_5GHZ].n_channels); - - set_bit(S_GEO_CONFIGURED, &il->status); - - return 0; -} -EXPORT_SYMBOL(il_init_geos); - -/* - * il_free_geos - undo allocations in il_init_geos - */ -void il_free_geos(struct il_priv *il) -{ - kfree(il->ieee_channels); - kfree(il->ieee_rates); - clear_bit(S_GEO_CONFIGURED, &il->status); -} -EXPORT_SYMBOL(il_free_geos); - -static bool il_is_channel_extension(struct il_priv *il, - enum ieee80211_band band, - u16 channel, u8 extension_chan_offset) -{ - const struct il_channel_info *ch_info; - - ch_info = il_get_channel_info(il, band, channel); - if (!il_is_channel_valid(ch_info)) - return false; - - if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_ABOVE) - return !(ch_info->ht40_extension_channel & - IEEE80211_CHAN_NO_HT40PLUS); - else if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_BELOW) - return !(ch_info->ht40_extension_channel & - IEEE80211_CHAN_NO_HT40MINUS); - - return false; -} - -bool il_is_ht40_tx_allowed(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_sta_ht_cap *ht_cap) -{ - if (!ctx->ht.enabled || !ctx->ht.is_40mhz) - return false; - - /* - * We do not check for IEEE80211_HT_CAP_SUP_WIDTH_20_40 - * the bit will not set if it is pure 40MHz case - */ - if (ht_cap && !ht_cap->ht_supported) - return false; - -#ifdef CONFIG_IWLEGACY_DEBUGFS - if (il->disable_ht40) - return false; -#endif - - return il_is_channel_extension(il, il->band, - le16_to_cpu(ctx->staging.channel), - ctx->ht.extension_chan_offset); -} -EXPORT_SYMBOL(il_is_ht40_tx_allowed); - -static u16 il_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val) -{ - u16 new_val; - u16 beacon_factor; - - /* - * If mac80211 hasn't given us a beacon interval, program - * the default into the device. - */ - if (!beacon_val) - return DEFAULT_BEACON_INTERVAL; - - /* - * If the beacon interval we obtained from the peer - * is too large, we'll have to wake up more often - * (and in IBSS case, we'll beacon too much) - * - * For example, if max_beacon_val is 4096, and the - * requested beacon interval is 7000, we'll have to - * use 3500 to be able to wake up on the beacons. - * - * This could badly influence beacon detection stats. - */ - - beacon_factor = (beacon_val + max_beacon_val) / max_beacon_val; - new_val = beacon_val / beacon_factor; - - if (!new_val) - new_val = max_beacon_val; - - return new_val; -} - -int -il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx) -{ - u64 tsf; - s32 interval_tm, rem; - struct ieee80211_conf *conf = NULL; - u16 beacon_int; - struct ieee80211_vif *vif = ctx->vif; - - conf = il_ieee80211_get_hw_conf(il->hw); - - lockdep_assert_held(&il->mutex); - - memset(&ctx->timing, 0, sizeof(struct il_rxon_time_cmd)); - - ctx->timing.timestamp = cpu_to_le64(il->timestamp); - ctx->timing.listen_interval = cpu_to_le16(conf->listen_interval); - - beacon_int = vif ? vif->bss_conf.beacon_int : 0; - - /* - * TODO: For IBSS we need to get atim_win from mac80211, - * for now just always use 0 - */ - ctx->timing.atim_win = 0; - - beacon_int = il_adjust_beacon_interval(beacon_int, - il->hw_params.max_beacon_itrvl * TIME_UNIT); - ctx->timing.beacon_interval = cpu_to_le16(beacon_int); - - tsf = il->timestamp; /* tsf is modifed by do_div: copy it */ - interval_tm = beacon_int * TIME_UNIT; - rem = do_div(tsf, interval_tm); - ctx->timing.beacon_init_val = cpu_to_le32(interval_tm - rem); - - ctx->timing.dtim_period = vif ? (vif->bss_conf.dtim_period ?: 1) : 1; - - D_ASSOC( - "beacon interval %d beacon timer %d beacon tim %d\n", - le16_to_cpu(ctx->timing.beacon_interval), - le32_to_cpu(ctx->timing.beacon_init_val), - le16_to_cpu(ctx->timing.atim_win)); - - return il_send_cmd_pdu(il, ctx->rxon_timing_cmd, - sizeof(ctx->timing), &ctx->timing); -} -EXPORT_SYMBOL(il_send_rxon_timing); - -void -il_set_rxon_hwcrypto(struct il_priv *il, - struct il_rxon_context *ctx, - int hw_decrypt) -{ - struct il_rxon_cmd *rxon = &ctx->staging; - - if (hw_decrypt) - rxon->filter_flags &= ~RXON_FILTER_DIS_DECRYPT_MSK; - else - rxon->filter_flags |= RXON_FILTER_DIS_DECRYPT_MSK; - -} -EXPORT_SYMBOL(il_set_rxon_hwcrypto); - -/* validate RXON structure is valid */ -int -il_check_rxon_cmd(struct il_priv *il, struct il_rxon_context *ctx) -{ - struct il_rxon_cmd *rxon = &ctx->staging; - bool error = false; - - if (rxon->flags & RXON_FLG_BAND_24G_MSK) { - if (rxon->flags & RXON_FLG_TGJ_NARROW_BAND_MSK) { - IL_WARN("check 2.4G: wrong narrow\n"); - error = true; - } - if (rxon->flags & RXON_FLG_RADAR_DETECT_MSK) { - IL_WARN("check 2.4G: wrong radar\n"); - error = true; - } - } else { - if (!(rxon->flags & RXON_FLG_SHORT_SLOT_MSK)) { - IL_WARN("check 5.2G: not short slot!\n"); - error = true; - } - if (rxon->flags & RXON_FLG_CCK_MSK) { - IL_WARN("check 5.2G: CCK!\n"); - error = true; - } - } - if ((rxon->node_addr[0] | rxon->bssid_addr[0]) & 0x1) { - IL_WARN("mac/bssid mcast!\n"); - error = true; - } - - /* make sure basic rates 6Mbps and 1Mbps are supported */ - if ((rxon->ofdm_basic_rates & RATE_6M_MASK) == 0 && - (rxon->cck_basic_rates & RATE_1M_MASK) == 0) { - IL_WARN("neither 1 nor 6 are basic\n"); - error = true; - } - - if (le16_to_cpu(rxon->assoc_id) > 2007) { - IL_WARN("aid > 2007\n"); - error = true; - } - - if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) - == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) { - IL_WARN("CCK and short slot\n"); - error = true; - } - - if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) - == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) { - IL_WARN("CCK and auto detect"); - error = true; - } - - if ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK | - RXON_FLG_TGG_PROTECT_MSK)) == - RXON_FLG_TGG_PROTECT_MSK) { - IL_WARN("TGg but no auto-detect\n"); - error = true; - } - - if (error) - IL_WARN("Tuning to channel %d\n", - le16_to_cpu(rxon->channel)); - - if (error) { - IL_ERR("Invalid RXON\n"); - return -EINVAL; - } - return 0; -} -EXPORT_SYMBOL(il_check_rxon_cmd); - -/** - * il_full_rxon_required - check if full RXON (vs RXON_ASSOC) cmd is needed - * @il: staging_rxon is compared to active_rxon - * - * If the RXON structure is changing enough to require a new tune, - * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that - * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required. - */ -int il_full_rxon_required(struct il_priv *il, - struct il_rxon_context *ctx) -{ - const struct il_rxon_cmd *staging = &ctx->staging; - const struct il_rxon_cmd *active = &ctx->active; - -#define CHK(cond) \ - if ((cond)) { \ - D_INFO("need full RXON - " #cond "\n"); \ - return 1; \ - } - -#define CHK_NEQ(c1, c2) \ - if ((c1) != (c2)) { \ - D_INFO("need full RXON - " \ - #c1 " != " #c2 " - %d != %d\n", \ - (c1), (c2)); \ - return 1; \ - } - - /* These items are only settable from the full RXON command */ - CHK(!il_is_associated_ctx(ctx)); - CHK(compare_ether_addr(staging->bssid_addr, active->bssid_addr)); - CHK(compare_ether_addr(staging->node_addr, active->node_addr)); - CHK(compare_ether_addr(staging->wlap_bssid_addr, - active->wlap_bssid_addr)); - CHK_NEQ(staging->dev_type, active->dev_type); - CHK_NEQ(staging->channel, active->channel); - CHK_NEQ(staging->air_propagation, active->air_propagation); - CHK_NEQ(staging->ofdm_ht_single_stream_basic_rates, - active->ofdm_ht_single_stream_basic_rates); - CHK_NEQ(staging->ofdm_ht_dual_stream_basic_rates, - active->ofdm_ht_dual_stream_basic_rates); - CHK_NEQ(staging->assoc_id, active->assoc_id); - - /* flags, filter_flags, ofdm_basic_rates, and cck_basic_rates can - * be updated with the RXON_ASSOC command -- however only some - * flag transitions are allowed using RXON_ASSOC */ - - /* Check if we are not switching bands */ - CHK_NEQ(staging->flags & RXON_FLG_BAND_24G_MSK, - active->flags & RXON_FLG_BAND_24G_MSK); - - /* Check if we are switching association toggle */ - CHK_NEQ(staging->filter_flags & RXON_FILTER_ASSOC_MSK, - active->filter_flags & RXON_FILTER_ASSOC_MSK); - -#undef CHK -#undef CHK_NEQ - - return 0; -} -EXPORT_SYMBOL(il_full_rxon_required); - -u8 il_get_lowest_plcp(struct il_priv *il, - struct il_rxon_context *ctx) -{ - /* - * Assign the lowest rate -- should really get this from - * the beacon skb from mac80211. - */ - if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) - return RATE_1M_PLCP; - else - return RATE_6M_PLCP; -} -EXPORT_SYMBOL(il_get_lowest_plcp); - -static void _il_set_rxon_ht(struct il_priv *il, - struct il_ht_config *ht_conf, - struct il_rxon_context *ctx) -{ - struct il_rxon_cmd *rxon = &ctx->staging; - - if (!ctx->ht.enabled) { - rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | - RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK | - RXON_FLG_HT40_PROT_MSK | - RXON_FLG_HT_PROT_MSK); - return; - } - - rxon->flags |= cpu_to_le32(ctx->ht.protection << - RXON_FLG_HT_OPERATING_MODE_POS); - - /* Set up channel bandwidth: - * 20 MHz only, 20/40 mixed or pure 40 if ht40 ok */ - /* clear the HT channel mode before set the mode */ - rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | - RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); - if (il_is_ht40_tx_allowed(il, ctx, NULL)) { - /* pure ht40 */ - if (ctx->ht.protection == - IEEE80211_HT_OP_MODE_PROTECTION_20MHZ) { - rxon->flags |= RXON_FLG_CHANNEL_MODE_PURE_40; - /* Note: control channel is opposite of extension channel */ - switch (ctx->ht.extension_chan_offset) { - case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: - rxon->flags &= - ~RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; - break; - case IEEE80211_HT_PARAM_CHA_SEC_BELOW: - rxon->flags |= - RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; - break; - } - } else { - /* Note: control channel is opposite of extension channel */ - switch (ctx->ht.extension_chan_offset) { - case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: - rxon->flags &= - ~(RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); - rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED; - break; - case IEEE80211_HT_PARAM_CHA_SEC_BELOW: - rxon->flags |= - RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; - rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED; - break; - case IEEE80211_HT_PARAM_CHA_SEC_NONE: - default: - /* channel location only valid if in Mixed mode */ - IL_ERR( - "invalid extension channel offset\n"); - break; - } - } - } else { - rxon->flags |= RXON_FLG_CHANNEL_MODE_LEGACY; - } - - if (il->cfg->ops->hcmd->set_rxon_chain) - il->cfg->ops->hcmd->set_rxon_chain(il, ctx); - - D_ASSOC("rxon flags 0x%X operation mode :0x%X " - "extension channel offset 0x%x\n", - le32_to_cpu(rxon->flags), ctx->ht.protection, - ctx->ht.extension_chan_offset); -} - -void il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf) -{ - _il_set_rxon_ht(il, ht_conf, &il->ctx); -} -EXPORT_SYMBOL(il_set_rxon_ht); - -/* Return valid, unused, channel for a passive scan to reset the RF */ -u8 il_get_single_channel_number(struct il_priv *il, - enum ieee80211_band band) -{ - const struct il_channel_info *ch_info; - int i; - u8 channel = 0; - u8 min, max; - - if (band == IEEE80211_BAND_5GHZ) { - min = 14; - max = il->channel_count; - } else { - min = 0; - max = 14; - } - - for (i = min; i < max; i++) { - channel = il->channel_info[i].channel; - if (channel == le16_to_cpu(il->ctx.staging.channel)) - continue; - - ch_info = il_get_channel_info(il, band, channel); - if (il_is_channel_valid(ch_info)) - break; - } - - return channel; -} -EXPORT_SYMBOL(il_get_single_channel_number); - -/** - * il_set_rxon_channel - Set the band and channel values in staging RXON - * @ch: requested channel as a pointer to struct ieee80211_channel - - * NOTE: Does not commit to the hardware; it sets appropriate bit fields - * in the staging RXON flag structure based on the ch->band - */ -int -il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch, - struct il_rxon_context *ctx) -{ - enum ieee80211_band band = ch->band; - u16 channel = ch->hw_value; - - if (le16_to_cpu(ctx->staging.channel) == channel && il->band == band) - return 0; - - ctx->staging.channel = cpu_to_le16(channel); - if (band == IEEE80211_BAND_5GHZ) - ctx->staging.flags &= ~RXON_FLG_BAND_24G_MSK; - else - ctx->staging.flags |= RXON_FLG_BAND_24G_MSK; - - il->band = band; - - D_INFO("Staging channel set to %d [%d]\n", channel, band); - - return 0; -} -EXPORT_SYMBOL(il_set_rxon_channel); - -void il_set_flags_for_band(struct il_priv *il, - struct il_rxon_context *ctx, - enum ieee80211_band band, - struct ieee80211_vif *vif) -{ - if (band == IEEE80211_BAND_5GHZ) { - ctx->staging.flags &= - ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK - | RXON_FLG_CCK_MSK); - ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; - } else { - /* Copied from il_post_associate() */ - if (vif && vif->bss_conf.use_short_slot) - ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; - else - ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; - - ctx->staging.flags |= RXON_FLG_BAND_24G_MSK; - ctx->staging.flags |= RXON_FLG_AUTO_DETECT_MSK; - ctx->staging.flags &= ~RXON_FLG_CCK_MSK; - } -} -EXPORT_SYMBOL(il_set_flags_for_band); - -/* - * initialize rxon structure with default values from eeprom - */ -void il_connection_init_rx_config(struct il_priv *il, - struct il_rxon_context *ctx) -{ - const struct il_channel_info *ch_info; - - memset(&ctx->staging, 0, sizeof(ctx->staging)); - - if (!ctx->vif) { - ctx->staging.dev_type = ctx->unused_devtype; - } else - switch (ctx->vif->type) { - - case NL80211_IFTYPE_STATION: - ctx->staging.dev_type = ctx->station_devtype; - ctx->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK; - break; - - case NL80211_IFTYPE_ADHOC: - ctx->staging.dev_type = ctx->ibss_devtype; - ctx->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK; - ctx->staging.filter_flags = RXON_FILTER_BCON_AWARE_MSK | - RXON_FILTER_ACCEPT_GRP_MSK; - break; - - default: - IL_ERR("Unsupported interface type %d\n", - ctx->vif->type); - break; - } - -#if 0 - /* TODO: Figure out when short_preamble would be set and cache from - * that */ - if (!hw_to_local(il->hw)->short_preamble) - ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; - else - ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; -#endif - - ch_info = il_get_channel_info(il, il->band, - le16_to_cpu(ctx->active.channel)); - - if (!ch_info) - ch_info = &il->channel_info[0]; - - ctx->staging.channel = cpu_to_le16(ch_info->channel); - il->band = ch_info->band; - - il_set_flags_for_band(il, ctx, il->band, ctx->vif); - - ctx->staging.ofdm_basic_rates = - (IL_OFDM_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; - ctx->staging.cck_basic_rates = - (IL_CCK_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; - - /* clear both MIX and PURE40 mode flag */ - ctx->staging.flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED | - RXON_FLG_CHANNEL_MODE_PURE_40); - if (ctx->vif) - memcpy(ctx->staging.node_addr, ctx->vif->addr, ETH_ALEN); - - ctx->staging.ofdm_ht_single_stream_basic_rates = 0xff; - ctx->staging.ofdm_ht_dual_stream_basic_rates = 0xff; -} -EXPORT_SYMBOL(il_connection_init_rx_config); - -void il_set_rate(struct il_priv *il) -{ - const struct ieee80211_supported_band *hw = NULL; - struct ieee80211_rate *rate; - int i; - - hw = il_get_hw_mode(il, il->band); - if (!hw) { - IL_ERR("Failed to set rate: unable to get hw mode\n"); - return; - } - - il->active_rate = 0; - - for (i = 0; i < hw->n_bitrates; i++) { - rate = &(hw->bitrates[i]); - if (rate->hw_value < RATE_COUNT_LEGACY) - il->active_rate |= (1 << rate->hw_value); - } - - D_RATE("Set active_rate = %0x\n", il->active_rate); - - il->ctx.staging.cck_basic_rates = - (IL_CCK_BASIC_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; - - il->ctx.staging.ofdm_basic_rates = - (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; -} -EXPORT_SYMBOL(il_set_rate); - -void il_chswitch_done(struct il_priv *il, bool is_success) -{ - struct il_rxon_context *ctx = &il->ctx; - - if (test_bit(S_EXIT_PENDING, &il->status)) - return; - - if (test_and_clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) - ieee80211_chswitch_done(ctx->vif, is_success); -} -EXPORT_SYMBOL(il_chswitch_done); - -void il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il_csa_notification *csa = &(pkt->u.csa_notif); - - struct il_rxon_context *ctx = &il->ctx; - struct il_rxon_cmd *rxon = (void *)&ctx->active; - - if (!test_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) - return; - - if (!le32_to_cpu(csa->status) && csa->channel == il->switch_channel) { - rxon->channel = csa->channel; - ctx->staging.channel = csa->channel; - D_11H("CSA notif: channel %d\n", - le16_to_cpu(csa->channel)); - il_chswitch_done(il, true); - } else { - IL_ERR("CSA notif (fail) : channel %d\n", - le16_to_cpu(csa->channel)); - il_chswitch_done(il, false); - } -} -EXPORT_SYMBOL(il_hdl_csa); - -#ifdef CONFIG_IWLEGACY_DEBUG -void il_print_rx_config_cmd(struct il_priv *il, - struct il_rxon_context *ctx) -{ - struct il_rxon_cmd *rxon = &ctx->staging; - - D_RADIO("RX CONFIG:\n"); - il_print_hex_dump(il, IL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); - D_RADIO("u16 channel: 0x%x\n", - le16_to_cpu(rxon->channel)); - D_RADIO("u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags)); - D_RADIO("u32 filter_flags: 0x%08x\n", - le32_to_cpu(rxon->filter_flags)); - D_RADIO("u8 dev_type: 0x%x\n", rxon->dev_type); - D_RADIO("u8 ofdm_basic_rates: 0x%02x\n", - rxon->ofdm_basic_rates); - D_RADIO("u8 cck_basic_rates: 0x%02x\n", - rxon->cck_basic_rates); - D_RADIO("u8[6] node_addr: %pM\n", rxon->node_addr); - D_RADIO("u8[6] bssid_addr: %pM\n", rxon->bssid_addr); - D_RADIO("u16 assoc_id: 0x%x\n", - le16_to_cpu(rxon->assoc_id)); -} -EXPORT_SYMBOL(il_print_rx_config_cmd); -#endif -/** - * il_irq_handle_error - called for HW or SW error interrupt from card - */ -void il_irq_handle_error(struct il_priv *il) -{ - /* Set the FW error flag -- cleared on il_down */ - set_bit(S_FW_ERROR, &il->status); - - /* Cancel currently queued command. */ - clear_bit(S_HCMD_ACTIVE, &il->status); - - IL_ERR("Loaded firmware version: %s\n", - il->hw->wiphy->fw_version); - - il->cfg->ops->lib->dump_nic_error_log(il); - if (il->cfg->ops->lib->dump_fh) - il->cfg->ops->lib->dump_fh(il, NULL, false); -#ifdef CONFIG_IWLEGACY_DEBUG - if (il_get_debug_level(il) & IL_DL_FW_ERRORS) - il_print_rx_config_cmd(il, - &il->ctx); -#endif - - wake_up(&il->wait_command_queue); - - /* Keep the restart process from trying to send host - * commands by clearing the INIT status bit */ - clear_bit(S_READY, &il->status); - - if (!test_bit(S_EXIT_PENDING, &il->status)) { - IL_DBG(IL_DL_FW_ERRORS, - "Restarting adapter due to uCode error.\n"); - - if (il->cfg->mod_params->restart_fw) - queue_work(il->workqueue, &il->restart); - } -} -EXPORT_SYMBOL(il_irq_handle_error); - -static int il_apm_stop_master(struct il_priv *il) -{ - int ret = 0; - - /* stop device's busmaster DMA activity */ - il_set_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); - - ret = _il_poll_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, - CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); - if (ret) - IL_WARN("Master Disable Timed Out, 100 usec\n"); - - D_INFO("stop master\n"); - - return ret; -} - -void il_apm_stop(struct il_priv *il) -{ - D_INFO("Stop card, put in low power state\n"); - - /* Stop device's DMA activity */ - il_apm_stop_master(il); - - /* Reset the entire device */ - il_set_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); - - udelay(10); - - /* - * Clear "initialization complete" bit to move adapter from - * D0A* (powered-up Active) --> D0U* (Uninitialized) state. - */ - il_clear_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_INIT_DONE); -} -EXPORT_SYMBOL(il_apm_stop); - - -/* - * Start up NIC's basic functionality after it has been reset - * (e.g. after platform boot, or shutdown via il_apm_stop()) - * NOTE: This does not load uCode nor start the embedded processor - */ -int il_apm_init(struct il_priv *il) -{ - int ret = 0; - u16 lctl; - - D_INFO("Init card's basic functions\n"); - - /* - * Use "set_bit" below rather than "write", to preserve any hardware - * bits already set by default after reset. - */ - - /* Disable L0S exit timer (platform NMI Work/Around) */ - il_set_bit(il, CSR_GIO_CHICKEN_BITS, - CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); - - /* - * Disable L0s without affecting L1; - * don't wait for ICH L0s (ICH bug W/A) - */ - il_set_bit(il, CSR_GIO_CHICKEN_BITS, - CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX); - - /* Set FH wait threshold to maximum (HW error during stress W/A) */ - il_set_bit(il, CSR_DBG_HPET_MEM_REG, - CSR_DBG_HPET_MEM_REG_VAL); - - /* - * Enable HAP INTA (interrupt from management bus) to - * wake device's PCI Express link L1a -> L0s - * NOTE: This is no-op for 3945 (non-existent bit) - */ - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); - - /* - * HW bug W/A for instability in PCIe bus L0->L0S->L1 transition. - * Check if BIOS (or OS) enabled L1-ASPM on this device. - * If so (likely), disable L0S, so device moves directly L0->L1; - * costs negligible amount of power savings. - * If not (unlikely), enable L0S, so there is at least some - * power savings, even without L1. - */ - if (il->cfg->base_params->set_l0s) { - lctl = il_pcie_link_ctl(il); - if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) == - PCI_CFG_LINK_CTRL_VAL_L1_EN) { - /* L1-ASPM enabled; disable(!) L0S */ - il_set_bit(il, CSR_GIO_REG, - CSR_GIO_REG_VAL_L0S_ENABLED); - D_POWER("L1 Enabled; Disabling L0S\n"); - } else { - /* L1-ASPM disabled; enable(!) L0S */ - il_clear_bit(il, CSR_GIO_REG, - CSR_GIO_REG_VAL_L0S_ENABLED); - D_POWER("L1 Disabled; Enabling L0S\n"); - } - } - - /* Configure analog phase-lock-loop before activating to D0A */ - if (il->cfg->base_params->pll_cfg_val) - il_set_bit(il, CSR_ANA_PLL_CFG, - il->cfg->base_params->pll_cfg_val); - - /* - * Set "initialization complete" bit to move adapter from - * D0U* --> D0A* (powered-up active) state. - */ - il_set_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); - - /* - * Wait for clock stabilization; once stabilized, access to - * device-internal resources is supported, e.g. il_wr_prph() - * and accesses to uCode SRAM. - */ - ret = _il_poll_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, - CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); - if (ret < 0) { - D_INFO("Failed to init the card\n"); - goto out; - } - - /* - * Enable DMA and BSM (if used) clocks, wait for them to stabilize. - * BSM (Boostrap State Machine) is only in 3945 and 4965. - * - * Write to "CLK_EN_REG"; "1" bits enable clocks, while "0" bits - * do not disable clocks. This preserves any hardware bits already - * set by default in "CLK_CTRL_REG" after reset. - */ - if (il->cfg->base_params->use_bsm) - il_wr_prph(il, APMG_CLK_EN_REG, - APMG_CLK_VAL_DMA_CLK_RQT | APMG_CLK_VAL_BSM_CLK_RQT); - else - il_wr_prph(il, APMG_CLK_EN_REG, - APMG_CLK_VAL_DMA_CLK_RQT); - udelay(20); - - /* Disable L1-Active */ - il_set_bits_prph(il, APMG_PCIDEV_STT_REG, - APMG_PCIDEV_STT_VAL_L1_ACT_DIS); - -out: - return ret; -} -EXPORT_SYMBOL(il_apm_init); - - -int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) -{ - int ret; - s8 prev_tx_power; - bool defer; - struct il_rxon_context *ctx = &il->ctx; - - lockdep_assert_held(&il->mutex); - - if (il->tx_power_user_lmt == tx_power && !force) - return 0; - - if (!il->cfg->ops->lib->send_tx_power) - return -EOPNOTSUPP; - - /* 0 dBm mean 1 milliwatt */ - if (tx_power < 0) { - IL_WARN( - "Requested user TXPOWER %d below 1 mW.\n", - tx_power); - return -EINVAL; - } - - if (tx_power > il->tx_power_device_lmt) { - IL_WARN( - "Requested user TXPOWER %d above upper limit %d.\n", - tx_power, il->tx_power_device_lmt); - return -EINVAL; - } - - if (!il_is_ready_rf(il)) - return -EIO; - - /* scan complete and commit_rxon use tx_power_next value, - * it always need to be updated for newest request */ - il->tx_power_next = tx_power; - - /* do not set tx power when scanning or channel changing */ - defer = test_bit(S_SCANNING, &il->status) || - memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging)); - if (defer && !force) { - D_INFO("Deferring tx power set\n"); - return 0; - } - - prev_tx_power = il->tx_power_user_lmt; - il->tx_power_user_lmt = tx_power; - - ret = il->cfg->ops->lib->send_tx_power(il); - - /* if fail to set tx_power, restore the orig. tx power */ - if (ret) { - il->tx_power_user_lmt = prev_tx_power; - il->tx_power_next = prev_tx_power; - } - return ret; -} -EXPORT_SYMBOL(il_set_tx_power); - -void il_send_bt_config(struct il_priv *il) -{ - struct il_bt_cmd bt_cmd = { - .lead_time = BT_LEAD_TIME_DEF, - .max_kill = BT_MAX_KILL_DEF, - .kill_ack_mask = 0, - .kill_cts_mask = 0, - }; - - if (!bt_coex_active) - bt_cmd.flags = BT_COEX_DISABLE; - else - bt_cmd.flags = BT_COEX_ENABLE; - - D_INFO("BT coex %s\n", - (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active"); - - if (il_send_cmd_pdu(il, C_BT_CONFIG, - sizeof(struct il_bt_cmd), &bt_cmd)) - IL_ERR("failed to send BT Coex Config\n"); -} -EXPORT_SYMBOL(il_send_bt_config); - -int il_send_stats_request(struct il_priv *il, u8 flags, bool clear) -{ - struct il_stats_cmd stats_cmd = { - .configuration_flags = - clear ? IL_STATS_CONF_CLEAR_STATS : 0, - }; - - if (flags & CMD_ASYNC) - return il_send_cmd_pdu_async(il, C_STATS, - sizeof(struct il_stats_cmd), - &stats_cmd, NULL); - else - return il_send_cmd_pdu(il, C_STATS, - sizeof(struct il_stats_cmd), - &stats_cmd); -} -EXPORT_SYMBOL(il_send_stats_request); - -void il_hdl_pm_sleep(struct il_priv *il, - struct il_rx_buf *rxb) -{ -#ifdef CONFIG_IWLEGACY_DEBUG - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il_sleep_notification *sleep = &(pkt->u.sleep_notif); - D_RX("sleep mode: %d, src: %d\n", - sleep->pm_sleep_mode, sleep->pm_wakeup_src); -#endif -} -EXPORT_SYMBOL(il_hdl_pm_sleep); - -void il_hdl_pm_debug_stats(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; - D_RADIO("Dumping %d bytes of unhandled " - "notification for %s:\n", len, - il_get_cmd_string(pkt->hdr.cmd)); - il_print_hex_dump(il, IL_DL_RADIO, pkt->u.raw, len); -} -EXPORT_SYMBOL(il_hdl_pm_debug_stats); - -void il_hdl_error(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - - IL_ERR("Error Reply type 0x%08X cmd %s (0x%02X) " - "seq 0x%04X ser 0x%08X\n", - le32_to_cpu(pkt->u.err_resp.error_type), - il_get_cmd_string(pkt->u.err_resp.cmd_id), - pkt->u.err_resp.cmd_id, - le16_to_cpu(pkt->u.err_resp.bad_cmd_seq_num), - le32_to_cpu(pkt->u.err_resp.error_info)); -} -EXPORT_SYMBOL(il_hdl_error); - -void il_clear_isr_stats(struct il_priv *il) -{ - memset(&il->isr_stats, 0, sizeof(il->isr_stats)); -} - -int il_mac_conf_tx(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, u16 queue, - const struct ieee80211_tx_queue_params *params) -{ - struct il_priv *il = hw->priv; - unsigned long flags; - int q; - - D_MAC80211("enter\n"); - - if (!il_is_ready_rf(il)) { - D_MAC80211("leave - RF not ready\n"); - return -EIO; - } - - if (queue >= AC_NUM) { - D_MAC80211("leave - queue >= AC_NUM %d\n", queue); - return 0; - } - - q = AC_NUM - 1 - queue; - - spin_lock_irqsave(&il->lock, flags); - - il->ctx.qos_data.def_qos_parm.ac[q].cw_min = - cpu_to_le16(params->cw_min); - il->ctx.qos_data.def_qos_parm.ac[q].cw_max = - cpu_to_le16(params->cw_max); - il->ctx.qos_data.def_qos_parm.ac[q].aifsn = params->aifs; - il->ctx.qos_data.def_qos_parm.ac[q].edca_txop = - cpu_to_le16((params->txop * 32)); - - il->ctx.qos_data.def_qos_parm.ac[q].reserved1 = 0; - - spin_unlock_irqrestore(&il->lock, flags); - - D_MAC80211("leave\n"); - return 0; -} -EXPORT_SYMBOL(il_mac_conf_tx); - -int il_mac_tx_last_beacon(struct ieee80211_hw *hw) -{ - struct il_priv *il = hw->priv; - - return il->ibss_manager == IL_IBSS_MANAGER; -} -EXPORT_SYMBOL_GPL(il_mac_tx_last_beacon); - -static int -il_set_mode(struct il_priv *il, struct il_rxon_context *ctx) -{ - il_connection_init_rx_config(il, ctx); - - if (il->cfg->ops->hcmd->set_rxon_chain) - il->cfg->ops->hcmd->set_rxon_chain(il, ctx); - - return il_commit_rxon(il, ctx); -} - -static int il_setup_interface(struct il_priv *il, - struct il_rxon_context *ctx) -{ - struct ieee80211_vif *vif = ctx->vif; - int err; - - lockdep_assert_held(&il->mutex); - - /* - * This variable will be correct only when there's just - * a single context, but all code using it is for hardware - * that supports only one context. - */ - il->iw_mode = vif->type; - - ctx->is_active = true; - - err = il_set_mode(il, ctx); - if (err) { - if (!ctx->always_active) - ctx->is_active = false; - return err; - } - - return 0; -} - -int -il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) -{ - struct il_priv *il = hw->priv; - struct il_vif_priv *vif_priv = (void *)vif->drv_priv; - int err; - u32 modes; - - D_MAC80211("enter: type %d, addr %pM\n", - vif->type, vif->addr); - - mutex_lock(&il->mutex); - - if (!il_is_ready_rf(il)) { - IL_WARN("Try to add interface when device not ready\n"); - err = -EINVAL; - goto out; - } - - - /* check if busy context is exclusive */ - if (il->ctx.vif && - (il->ctx.exclusive_interface_modes & BIT(il->ctx.vif->type))) { - err = -EINVAL; - goto out; - } - - modes = il->ctx.interface_modes | il->ctx.exclusive_interface_modes; - if (!(modes & BIT(vif->type))) { - err = -EOPNOTSUPP; - goto out; - } - - vif_priv->ctx = &il->ctx; - il->ctx.vif = vif; - - err = il_setup_interface(il, &il->ctx); - if (err) { - il->ctx.vif = NULL; - il->iw_mode = NL80211_IFTYPE_STATION; - } - - out: - mutex_unlock(&il->mutex); - - D_MAC80211("leave\n"); - return err; -} -EXPORT_SYMBOL(il_mac_add_interface); - -static void il_teardown_interface(struct il_priv *il, - struct ieee80211_vif *vif, - bool mode_change) -{ - struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - - lockdep_assert_held(&il->mutex); - - if (il->scan_vif == vif) { - il_scan_cancel_timeout(il, 200); - il_force_scan_end(il); - } - - if (!mode_change) { - il_set_mode(il, ctx); - if (!ctx->always_active) - ctx->is_active = false; - } -} - -void il_mac_remove_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif) -{ - struct il_priv *il = hw->priv; - struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - - D_MAC80211("enter\n"); - - mutex_lock(&il->mutex); - - WARN_ON(ctx->vif != vif); - ctx->vif = NULL; - - il_teardown_interface(il, vif, false); - - memset(il->bssid, 0, ETH_ALEN); - mutex_unlock(&il->mutex); - - D_MAC80211("leave\n"); - -} -EXPORT_SYMBOL(il_mac_remove_interface); - -int il_alloc_txq_mem(struct il_priv *il) -{ - if (!il->txq) - il->txq = kzalloc( - sizeof(struct il_tx_queue) * - il->cfg->base_params->num_of_queues, - GFP_KERNEL); - if (!il->txq) { - IL_ERR("Not enough memory for txq\n"); - return -ENOMEM; - } - return 0; -} -EXPORT_SYMBOL(il_alloc_txq_mem); - -void il_txq_mem(struct il_priv *il) -{ - kfree(il->txq); - il->txq = NULL; -} -EXPORT_SYMBOL(il_txq_mem); - -#ifdef CONFIG_IWLEGACY_DEBUGFS - -#define IL_TRAFFIC_DUMP_SIZE (IL_TRAFFIC_ENTRY_SIZE * IL_TRAFFIC_ENTRIES) - -void il_reset_traffic_log(struct il_priv *il) -{ - il->tx_traffic_idx = 0; - il->rx_traffic_idx = 0; - if (il->tx_traffic) - memset(il->tx_traffic, 0, IL_TRAFFIC_DUMP_SIZE); - if (il->rx_traffic) - memset(il->rx_traffic, 0, IL_TRAFFIC_DUMP_SIZE); -} - -int il_alloc_traffic_mem(struct il_priv *il) -{ - u32 traffic_size = IL_TRAFFIC_DUMP_SIZE; - - if (il_debug_level & IL_DL_TX) { - if (!il->tx_traffic) { - il->tx_traffic = - kzalloc(traffic_size, GFP_KERNEL); - if (!il->tx_traffic) - return -ENOMEM; - } - } - if (il_debug_level & IL_DL_RX) { - if (!il->rx_traffic) { - il->rx_traffic = - kzalloc(traffic_size, GFP_KERNEL); - if (!il->rx_traffic) - return -ENOMEM; - } - } - il_reset_traffic_log(il); - return 0; -} -EXPORT_SYMBOL(il_alloc_traffic_mem); - -void il_free_traffic_mem(struct il_priv *il) -{ - kfree(il->tx_traffic); - il->tx_traffic = NULL; - - kfree(il->rx_traffic); - il->rx_traffic = NULL; -} -EXPORT_SYMBOL(il_free_traffic_mem); - -void il_dbg_log_tx_data_frame(struct il_priv *il, - u16 length, struct ieee80211_hdr *header) -{ - __le16 fc; - u16 len; - - if (likely(!(il_debug_level & IL_DL_TX))) - return; - - if (!il->tx_traffic) - return; - - fc = header->frame_control; - if (ieee80211_is_data(fc)) { - len = (length > IL_TRAFFIC_ENTRY_SIZE) - ? IL_TRAFFIC_ENTRY_SIZE : length; - memcpy((il->tx_traffic + - (il->tx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), - header, len); - il->tx_traffic_idx = - (il->tx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; - } -} -EXPORT_SYMBOL(il_dbg_log_tx_data_frame); - -void il_dbg_log_rx_data_frame(struct il_priv *il, - u16 length, struct ieee80211_hdr *header) -{ - __le16 fc; - u16 len; - - if (likely(!(il_debug_level & IL_DL_RX))) - return; - - if (!il->rx_traffic) - return; - - fc = header->frame_control; - if (ieee80211_is_data(fc)) { - len = (length > IL_TRAFFIC_ENTRY_SIZE) - ? IL_TRAFFIC_ENTRY_SIZE : length; - memcpy((il->rx_traffic + - (il->rx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), - header, len); - il->rx_traffic_idx = - (il->rx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; - } -} -EXPORT_SYMBOL(il_dbg_log_rx_data_frame); - -const char *il_get_mgmt_string(int cmd) -{ - switch (cmd) { - IL_CMD(MANAGEMENT_ASSOC_REQ); - IL_CMD(MANAGEMENT_ASSOC_RESP); - IL_CMD(MANAGEMENT_REASSOC_REQ); - IL_CMD(MANAGEMENT_REASSOC_RESP); - IL_CMD(MANAGEMENT_PROBE_REQ); - IL_CMD(MANAGEMENT_PROBE_RESP); - IL_CMD(MANAGEMENT_BEACON); - IL_CMD(MANAGEMENT_ATIM); - IL_CMD(MANAGEMENT_DISASSOC); - IL_CMD(MANAGEMENT_AUTH); - IL_CMD(MANAGEMENT_DEAUTH); - IL_CMD(MANAGEMENT_ACTION); - default: - return "UNKNOWN"; - - } -} - -const char *il_get_ctrl_string(int cmd) -{ - switch (cmd) { - IL_CMD(CONTROL_BACK_REQ); - IL_CMD(CONTROL_BACK); - IL_CMD(CONTROL_PSPOLL); - IL_CMD(CONTROL_RTS); - IL_CMD(CONTROL_CTS); - IL_CMD(CONTROL_ACK); - IL_CMD(CONTROL_CFEND); - IL_CMD(CONTROL_CFENDACK); - default: - return "UNKNOWN"; - - } -} - -void il_clear_traffic_stats(struct il_priv *il) -{ - memset(&il->tx_stats, 0, sizeof(struct traffic_stats)); - memset(&il->rx_stats, 0, sizeof(struct traffic_stats)); -} - -/* - * if CONFIG_IWLEGACY_DEBUGFS defined, - * il_update_stats function will - * record all the MGMT, CTRL and DATA pkt for both TX and Rx pass - * Use debugFs to display the rx/rx_stats - * if CONFIG_IWLEGACY_DEBUGFS not being defined, then no MGMT and CTRL - * information will be recorded, but DATA pkt still will be recorded - * for the reason of il_led.c need to control the led blinking based on - * number of tx and rx data. - * - */ -void -il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, u16 len) -{ - struct traffic_stats *stats; - - if (is_tx) - stats = &il->tx_stats; - else - stats = &il->rx_stats; - - if (ieee80211_is_mgmt(fc)) { - switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) { - case cpu_to_le16(IEEE80211_STYPE_ASSOC_REQ): - stats->mgmt[MANAGEMENT_ASSOC_REQ]++; - break; - case cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP): - stats->mgmt[MANAGEMENT_ASSOC_RESP]++; - break; - case cpu_to_le16(IEEE80211_STYPE_REASSOC_REQ): - stats->mgmt[MANAGEMENT_REASSOC_REQ]++; - break; - case cpu_to_le16(IEEE80211_STYPE_REASSOC_RESP): - stats->mgmt[MANAGEMENT_REASSOC_RESP]++; - break; - case cpu_to_le16(IEEE80211_STYPE_PROBE_REQ): - stats->mgmt[MANAGEMENT_PROBE_REQ]++; - break; - case cpu_to_le16(IEEE80211_STYPE_PROBE_RESP): - stats->mgmt[MANAGEMENT_PROBE_RESP]++; - break; - case cpu_to_le16(IEEE80211_STYPE_BEACON): - stats->mgmt[MANAGEMENT_BEACON]++; - break; - case cpu_to_le16(IEEE80211_STYPE_ATIM): - stats->mgmt[MANAGEMENT_ATIM]++; - break; - case cpu_to_le16(IEEE80211_STYPE_DISASSOC): - stats->mgmt[MANAGEMENT_DISASSOC]++; - break; - case cpu_to_le16(IEEE80211_STYPE_AUTH): - stats->mgmt[MANAGEMENT_AUTH]++; - break; - case cpu_to_le16(IEEE80211_STYPE_DEAUTH): - stats->mgmt[MANAGEMENT_DEAUTH]++; - break; - case cpu_to_le16(IEEE80211_STYPE_ACTION): - stats->mgmt[MANAGEMENT_ACTION]++; - break; - } - } else if (ieee80211_is_ctl(fc)) { - switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) { - case cpu_to_le16(IEEE80211_STYPE_BACK_REQ): - stats->ctrl[CONTROL_BACK_REQ]++; - break; - case cpu_to_le16(IEEE80211_STYPE_BACK): - stats->ctrl[CONTROL_BACK]++; - break; - case cpu_to_le16(IEEE80211_STYPE_PSPOLL): - stats->ctrl[CONTROL_PSPOLL]++; - break; - case cpu_to_le16(IEEE80211_STYPE_RTS): - stats->ctrl[CONTROL_RTS]++; - break; - case cpu_to_le16(IEEE80211_STYPE_CTS): - stats->ctrl[CONTROL_CTS]++; - break; - case cpu_to_le16(IEEE80211_STYPE_ACK): - stats->ctrl[CONTROL_ACK]++; - break; - case cpu_to_le16(IEEE80211_STYPE_CFEND): - stats->ctrl[CONTROL_CFEND]++; - break; - case cpu_to_le16(IEEE80211_STYPE_CFENDACK): - stats->ctrl[CONTROL_CFENDACK]++; - break; - } - } else { - /* data */ - stats->data_cnt++; - stats->data_bytes += len; - } -} -EXPORT_SYMBOL(il_update_stats); -#endif - -int il_force_reset(struct il_priv *il, bool external) -{ - struct il_force_reset *force_reset; - - if (test_bit(S_EXIT_PENDING, &il->status)) - return -EINVAL; - - force_reset = &il->force_reset; - force_reset->reset_request_count++; - if (!external) { - if (force_reset->last_force_reset_jiffies && - time_after(force_reset->last_force_reset_jiffies + - force_reset->reset_duration, jiffies)) { - D_INFO("force reset rejected\n"); - force_reset->reset_reject_count++; - return -EAGAIN; - } - } - force_reset->reset_success_count++; - force_reset->last_force_reset_jiffies = jiffies; - - /* - * if the request is from external(ex: debugfs), - * then always perform the request in regardless the module - * parameter setting - * if the request is from internal (uCode error or driver - * detect failure), then fw_restart module parameter - * need to be check before performing firmware reload - */ - - if (!external && !il->cfg->mod_params->restart_fw) { - D_INFO("Cancel firmware reload based on " - "module parameter setting\n"); - return 0; - } - - IL_ERR("On demand firmware reload\n"); - - /* Set the FW error flag -- cleared on il_down */ - set_bit(S_FW_ERROR, &il->status); - wake_up(&il->wait_command_queue); - /* - * Keep the restart process from trying to send host - * commands by clearing the INIT status bit - */ - clear_bit(S_READY, &il->status); - queue_work(il->workqueue, &il->restart); - - return 0; -} - -int -il_mac_change_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - enum nl80211_iftype newtype, bool newp2p) -{ - struct il_priv *il = hw->priv; - struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - u32 modes; - int err; - - newtype = ieee80211_iftype_p2p(newtype, newp2p); - - mutex_lock(&il->mutex); - - if (!ctx->vif || !il_is_ready_rf(il)) { - /* - * Huh? But wait ... this can maybe happen when - * we're in the middle of a firmware restart! - */ - err = -EBUSY; - goto out; - } - - modes = ctx->interface_modes | ctx->exclusive_interface_modes; - if (!(modes & BIT(newtype))) { - err = -EOPNOTSUPP; - goto out; - } - - if ((il->ctx.exclusive_interface_modes & BIT(il->ctx.vif->type)) || - (il->ctx.exclusive_interface_modes & BIT(newtype))) { - err = -EINVAL; - goto out; - } - - /* success */ - il_teardown_interface(il, vif, true); - vif->type = newtype; - vif->p2p = newp2p; - err = il_setup_interface(il, ctx); - WARN_ON(err); - /* - * We've switched internally, but submitting to the - * device may have failed for some reason. Mask this - * error, because otherwise mac80211 will not switch - * (and set the interface type back) and we'll be - * out of sync with it. - */ - err = 0; - - out: - mutex_unlock(&il->mutex); - return err; -} -EXPORT_SYMBOL(il_mac_change_interface); - -/* - * On every watchdog tick we check (latest) time stamp. If it does not - * change during timeout period and queue is not empty we reset firmware. - */ -static int il_check_stuck_queue(struct il_priv *il, int cnt) -{ - struct il_tx_queue *txq = &il->txq[cnt]; - struct il_queue *q = &txq->q; - unsigned long timeout; - int ret; - - if (q->read_ptr == q->write_ptr) { - txq->time_stamp = jiffies; - return 0; - } - - timeout = txq->time_stamp + - msecs_to_jiffies(il->cfg->base_params->wd_timeout); - - if (time_after(jiffies, timeout)) { - IL_ERR("Queue %d stuck for %u ms.\n", - q->id, il->cfg->base_params->wd_timeout); - ret = il_force_reset(il, false); - return (ret == -EAGAIN) ? 0 : 1; - } - - return 0; -} - -/* - * Making watchdog tick be a quarter of timeout assure we will - * discover the queue hung between timeout and 1.25*timeout - */ -#define IL_WD_TICK(timeout) ((timeout) / 4) - -/* - * Watchdog timer callback, we check each tx queue for stuck, if if hung - * we reset the firmware. If everything is fine just rearm the timer. - */ -void il_bg_watchdog(unsigned long data) -{ - struct il_priv *il = (struct il_priv *)data; - int cnt; - unsigned long timeout; - - if (test_bit(S_EXIT_PENDING, &il->status)) - return; - - timeout = il->cfg->base_params->wd_timeout; - if (timeout == 0) - return; - - /* monitor and check for stuck cmd queue */ - if (il_check_stuck_queue(il, il->cmd_queue)) - return; - - /* monitor and check for other stuck queues */ - if (il_is_any_associated(il)) { - for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { - /* skip as we already checked the command queue */ - if (cnt == il->cmd_queue) - continue; - if (il_check_stuck_queue(il, cnt)) - return; - } - } - - mod_timer(&il->watchdog, jiffies + - msecs_to_jiffies(IL_WD_TICK(timeout))); -} -EXPORT_SYMBOL(il_bg_watchdog); - -void il_setup_watchdog(struct il_priv *il) -{ - unsigned int timeout = il->cfg->base_params->wd_timeout; - - if (timeout) - mod_timer(&il->watchdog, - jiffies + msecs_to_jiffies(IL_WD_TICK(timeout))); - else - del_timer(&il->watchdog); -} -EXPORT_SYMBOL(il_setup_watchdog); - -/* - * extended beacon time format - * time in usec will be changed into a 32-bit value in extended:internal format - * the extended part is the beacon counts - * the internal part is the time in usec within one beacon interval - */ -u32 -il_usecs_to_beacons(struct il_priv *il, - u32 usec, u32 beacon_interval) -{ - u32 quot; - u32 rem; - u32 interval = beacon_interval * TIME_UNIT; - - if (!interval || !usec) - return 0; - - quot = (usec / interval) & - (il_beacon_time_mask_high(il, - il->hw_params.beacon_time_tsf_bits) >> - il->hw_params.beacon_time_tsf_bits); - rem = (usec % interval) & il_beacon_time_mask_low(il, - il->hw_params.beacon_time_tsf_bits); - - return (quot << il->hw_params.beacon_time_tsf_bits) + rem; -} -EXPORT_SYMBOL(il_usecs_to_beacons); - -/* base is usually what we get from ucode with each received frame, - * the same as HW timer counter counting down - */ -__le32 il_add_beacon_time(struct il_priv *il, u32 base, - u32 addon, u32 beacon_interval) -{ - u32 base_low = base & il_beacon_time_mask_low(il, - il->hw_params.beacon_time_tsf_bits); - u32 addon_low = addon & il_beacon_time_mask_low(il, - il->hw_params.beacon_time_tsf_bits); - u32 interval = beacon_interval * TIME_UNIT; - u32 res = (base & il_beacon_time_mask_high(il, - il->hw_params.beacon_time_tsf_bits)) + - (addon & il_beacon_time_mask_high(il, - il->hw_params.beacon_time_tsf_bits)); - - if (base_low > addon_low) - res += base_low - addon_low; - else if (base_low < addon_low) { - res += interval + base_low - addon_low; - res += (1 << il->hw_params.beacon_time_tsf_bits); - } else - res += (1 << il->hw_params.beacon_time_tsf_bits); - - return cpu_to_le32(res); -} -EXPORT_SYMBOL(il_add_beacon_time); - -#ifdef CONFIG_PM - -int il_pci_suspend(struct device *device) -{ - struct pci_dev *pdev = to_pci_dev(device); - struct il_priv *il = pci_get_drvdata(pdev); - - /* - * This function is called when system goes into suspend state - * mac80211 will call il_mac_stop() from the mac80211 suspend function - * first but since il_mac_stop() has no knowledge of who the caller is, - * it will not call apm_ops.stop() to stop the DMA operation. - * Calling apm_ops.stop here to make sure we stop the DMA. - */ - il_apm_stop(il); - - return 0; -} -EXPORT_SYMBOL(il_pci_suspend); - -int il_pci_resume(struct device *device) -{ - struct pci_dev *pdev = to_pci_dev(device); - struct il_priv *il = pci_get_drvdata(pdev); - bool hw_rfkill = false; - - /* - * We disable the RETRY_TIMEOUT register (0x41) to keep - * PCI Tx retries from interfering with C3 CPU state. - */ - pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00); - - il_enable_interrupts(il); - - if (!(_il_rd(il, CSR_GP_CNTRL) & - CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) - hw_rfkill = true; - - if (hw_rfkill) - set_bit(S_RF_KILL_HW, &il->status); - else - clear_bit(S_RF_KILL_HW, &il->status); - - wiphy_rfkill_set_hw_state(il->hw->wiphy, hw_rfkill); - - return 0; -} -EXPORT_SYMBOL(il_pci_resume); - -const struct dev_pm_ops il_pm_ops = { - .suspend = il_pci_suspend, - .resume = il_pci_resume, - .freeze = il_pci_suspend, - .thaw = il_pci_resume, - .poweroff = il_pci_suspend, - .restore = il_pci_resume, -}; -EXPORT_SYMBOL(il_pm_ops); - -#endif /* CONFIG_PM */ - -static void -il_update_qos(struct il_priv *il, struct il_rxon_context *ctx) -{ - if (test_bit(S_EXIT_PENDING, &il->status)) - return; - - if (!ctx->is_active) - return; - - ctx->qos_data.def_qos_parm.qos_flags = 0; - - if (ctx->qos_data.qos_active) - ctx->qos_data.def_qos_parm.qos_flags |= - QOS_PARAM_FLG_UPDATE_EDCA_MSK; - - if (ctx->ht.enabled) - ctx->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; - - D_QOS("send QoS cmd with Qos active=%d FLAGS=0x%X\n", - ctx->qos_data.qos_active, - ctx->qos_data.def_qos_parm.qos_flags); - - il_send_cmd_pdu_async(il, ctx->qos_cmd, - sizeof(struct il_qosparam_cmd), - &ctx->qos_data.def_qos_parm, NULL); -} - -/** - * il_mac_config - mac80211 config callback - */ -int il_mac_config(struct ieee80211_hw *hw, u32 changed) -{ - struct il_priv *il = hw->priv; - const struct il_channel_info *ch_info; - struct ieee80211_conf *conf = &hw->conf; - struct ieee80211_channel *channel = conf->channel; - struct il_ht_config *ht_conf = &il->current_ht_config; - struct il_rxon_context *ctx = &il->ctx; - unsigned long flags = 0; - int ret = 0; - u16 ch; - int scan_active = 0; - bool ht_changed = false; - - if (WARN_ON(!il->cfg->ops->legacy)) - return -EOPNOTSUPP; - - mutex_lock(&il->mutex); - - D_MAC80211("enter to channel %d changed 0x%X\n", - channel->hw_value, changed); - - if (unlikely(test_bit(S_SCANNING, &il->status))) { - scan_active = 1; - D_MAC80211("scan active\n"); - } - - if (changed & (IEEE80211_CONF_CHANGE_SMPS | - IEEE80211_CONF_CHANGE_CHANNEL)) { - /* mac80211 uses static for non-HT which is what we want */ - il->current_ht_config.smps = conf->smps_mode; - - /* - * Recalculate chain counts. - * - * If monitor mode is enabled then mac80211 will - * set up the SM PS mode to OFF if an HT channel is - * configured. - */ - if (il->cfg->ops->hcmd->set_rxon_chain) - il->cfg->ops->hcmd->set_rxon_chain(il, &il->ctx); - } - - /* during scanning mac80211 will delay channel setting until - * scan finish with changed = 0 - */ - if (!changed || (changed & IEEE80211_CONF_CHANGE_CHANNEL)) { - - if (scan_active) - goto set_ch_out; - - ch = channel->hw_value; - ch_info = il_get_channel_info(il, channel->band, ch); - if (!il_is_channel_valid(ch_info)) { - D_MAC80211("leave - invalid channel\n"); - ret = -EINVAL; - goto set_ch_out; - } - - if (il->iw_mode == NL80211_IFTYPE_ADHOC && - !il_is_channel_ibss(ch_info)) { - D_MAC80211("leave - not IBSS channel\n"); - ret = -EINVAL; - goto set_ch_out; - } - - spin_lock_irqsave(&il->lock, flags); - - /* Configure HT40 channels */ - if (ctx->ht.enabled != conf_is_ht(conf)) { - ctx->ht.enabled = conf_is_ht(conf); - ht_changed = true; - } - if (ctx->ht.enabled) { - if (conf_is_ht40_minus(conf)) { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_BELOW; - ctx->ht.is_40mhz = true; - } else if (conf_is_ht40_plus(conf)) { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_ABOVE; - ctx->ht.is_40mhz = true; - } else { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_NONE; - ctx->ht.is_40mhz = false; - } - } else - ctx->ht.is_40mhz = false; - - /* - * Default to no protection. Protection mode will - * later be set from BSS config in il_ht_conf - */ - ctx->ht.protection = - IEEE80211_HT_OP_MODE_PROTECTION_NONE; - - /* if we are switching from ht to 2.4 clear flags - * from any ht related info since 2.4 does not - * support ht */ - if ((le16_to_cpu(ctx->staging.channel) != ch)) - ctx->staging.flags = 0; - - il_set_rxon_channel(il, channel, ctx); - il_set_rxon_ht(il, ht_conf); - - il_set_flags_for_band(il, ctx, channel->band, - ctx->vif); - - spin_unlock_irqrestore(&il->lock, flags); - - if (il->cfg->ops->legacy->update_bcast_stations) - ret = - il->cfg->ops->legacy->update_bcast_stations(il); - - set_ch_out: - /* The list of supported rates and rate mask can be different - * for each band; since the band may have changed, reset - * the rate mask to what mac80211 lists */ - il_set_rate(il); - } - - if (changed & (IEEE80211_CONF_CHANGE_PS | - IEEE80211_CONF_CHANGE_IDLE)) { - ret = il_power_update_mode(il, false); - if (ret) - D_MAC80211("Error setting sleep level\n"); - } - - if (changed & IEEE80211_CONF_CHANGE_POWER) { - D_MAC80211("TX Power old=%d new=%d\n", - il->tx_power_user_lmt, conf->power_level); - - il_set_tx_power(il, conf->power_level, false); - } - - if (!il_is_ready(il)) { - D_MAC80211("leave - not ready\n"); - goto out; - } - - if (scan_active) - goto out; - - if (memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging))) - il_commit_rxon(il, ctx); - else - D_INFO("Not re-sending same RXON configuration.\n"); - if (ht_changed) - il_update_qos(il, ctx); - -out: - D_MAC80211("leave\n"); - mutex_unlock(&il->mutex); - return ret; -} -EXPORT_SYMBOL(il_mac_config); - -void il_mac_reset_tsf(struct ieee80211_hw *hw, - struct ieee80211_vif *vif) -{ - struct il_priv *il = hw->priv; - unsigned long flags; - struct il_rxon_context *ctx = &il->ctx; - - if (WARN_ON(!il->cfg->ops->legacy)) - return; - - mutex_lock(&il->mutex); - D_MAC80211("enter\n"); - - spin_lock_irqsave(&il->lock, flags); - memset(&il->current_ht_config, 0, sizeof(struct il_ht_config)); - spin_unlock_irqrestore(&il->lock, flags); - - spin_lock_irqsave(&il->lock, flags); - - /* new association get rid of ibss beacon skb */ - if (il->beacon_skb) - dev_kfree_skb(il->beacon_skb); - - il->beacon_skb = NULL; - - il->timestamp = 0; - - spin_unlock_irqrestore(&il->lock, flags); - - il_scan_cancel_timeout(il, 100); - if (!il_is_ready_rf(il)) { - D_MAC80211("leave - not ready\n"); - mutex_unlock(&il->mutex); - return; - } - - /* we are restarting association process - * clear RXON_FILTER_ASSOC_MSK bit - */ - ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - il_commit_rxon(il, ctx); - - il_set_rate(il); - - mutex_unlock(&il->mutex); - - D_MAC80211("leave\n"); -} -EXPORT_SYMBOL(il_mac_reset_tsf); - -static void il_ht_conf(struct il_priv *il, - struct ieee80211_vif *vif) -{ - struct il_ht_config *ht_conf = &il->current_ht_config; - struct ieee80211_sta *sta; - struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; - struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - - D_ASSOC("enter:\n"); - - if (!ctx->ht.enabled) - return; - - ctx->ht.protection = - bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION; - ctx->ht.non_gf_sta_present = - !!(bss_conf->ht_operation_mode & - IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); - - ht_conf->single_chain_sufficient = false; - - switch (vif->type) { - case NL80211_IFTYPE_STATION: - rcu_read_lock(); - sta = ieee80211_find_sta(vif, bss_conf->bssid); - if (sta) { - struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; - int maxstreams; - - maxstreams = (ht_cap->mcs.tx_params & - IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK) - >> IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT; - maxstreams += 1; - - if (ht_cap->mcs.rx_mask[1] == 0 && - ht_cap->mcs.rx_mask[2] == 0) - ht_conf->single_chain_sufficient = true; - if (maxstreams <= 1) - ht_conf->single_chain_sufficient = true; - } else { - /* - * If at all, this can only happen through a race - * when the AP disconnects us while we're still - * setting up the connection, in that case mac80211 - * will soon tell us about that. - */ - ht_conf->single_chain_sufficient = true; - } - rcu_read_unlock(); - break; - case NL80211_IFTYPE_ADHOC: - ht_conf->single_chain_sufficient = true; - break; - default: - break; - } - - D_ASSOC("leave\n"); -} - -static inline void il_set_no_assoc(struct il_priv *il, - struct ieee80211_vif *vif) -{ - struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - - /* - * inform the ucode that there is no longer an - * association and that no more packets should be - * sent - */ - ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; - ctx->staging.assoc_id = 0; - il_commit_rxon(il, ctx); -} - -static void il_beacon_update(struct ieee80211_hw *hw, - struct ieee80211_vif *vif) -{ - struct il_priv *il = hw->priv; - unsigned long flags; - __le64 timestamp; - struct sk_buff *skb = ieee80211_beacon_get(hw, vif); - - if (!skb) - return; - - D_MAC80211("enter\n"); - - lockdep_assert_held(&il->mutex); - - if (!il->beacon_ctx) { - IL_ERR("update beacon but no beacon context!\n"); - dev_kfree_skb(skb); - return; - } - - spin_lock_irqsave(&il->lock, flags); - - if (il->beacon_skb) - dev_kfree_skb(il->beacon_skb); - - il->beacon_skb = skb; - - timestamp = ((struct ieee80211_mgmt *)skb->data)->u.beacon.timestamp; - il->timestamp = le64_to_cpu(timestamp); - - D_MAC80211("leave\n"); - spin_unlock_irqrestore(&il->lock, flags); - - if (!il_is_ready_rf(il)) { - D_MAC80211("leave - RF not ready\n"); - return; - } - - il->cfg->ops->legacy->post_associate(il); -} - -void il_mac_bss_info_changed(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_bss_conf *bss_conf, - u32 changes) -{ - struct il_priv *il = hw->priv; - struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); - int ret; - - if (WARN_ON(!il->cfg->ops->legacy)) - return; - - D_MAC80211("changes = 0x%X\n", changes); - - mutex_lock(&il->mutex); - - if (!il_is_alive(il)) { - mutex_unlock(&il->mutex); - return; - } - - if (changes & BSS_CHANGED_QOS) { - unsigned long flags; - - spin_lock_irqsave(&il->lock, flags); - ctx->qos_data.qos_active = bss_conf->qos; - il_update_qos(il, ctx); - spin_unlock_irqrestore(&il->lock, flags); - } - - if (changes & BSS_CHANGED_BEACON_ENABLED) { - /* - * the add_interface code must make sure we only ever - * have a single interface that could be beaconing at - * any time. - */ - if (vif->bss_conf.enable_beacon) - il->beacon_ctx = ctx; - else - il->beacon_ctx = NULL; - } - - if (changes & BSS_CHANGED_BSSID) { - D_MAC80211("BSSID %pM\n", bss_conf->bssid); - - /* - * If there is currently a HW scan going on in the - * background then we need to cancel it else the RXON - * below/in post_associate will fail. - */ - if (il_scan_cancel_timeout(il, 100)) { - IL_WARN( - "Aborted scan still in progress after 100ms\n"); - D_MAC80211( - "leaving - scan abort failed.\n"); - mutex_unlock(&il->mutex); - return; - } - - /* mac80211 only sets assoc when in STATION mode */ - if (vif->type == NL80211_IFTYPE_ADHOC || bss_conf->assoc) { - memcpy(ctx->staging.bssid_addr, - bss_conf->bssid, ETH_ALEN); - - /* currently needed in a few places */ - memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); - } else { - ctx->staging.filter_flags &= - ~RXON_FILTER_ASSOC_MSK; - } - - } - - /* - * This needs to be after setting the BSSID in case - * mac80211 decides to do both changes at once because - * it will invoke post_associate. - */ - if (vif->type == NL80211_IFTYPE_ADHOC && (changes & BSS_CHANGED_BEACON)) - il_beacon_update(hw, vif); - - if (changes & BSS_CHANGED_ERP_PREAMBLE) { - D_MAC80211("ERP_PREAMBLE %d\n", - bss_conf->use_short_preamble); - if (bss_conf->use_short_preamble) - ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; - else - ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; - } - - if (changes & BSS_CHANGED_ERP_CTS_PROT) { - D_MAC80211( - "ERP_CTS %d\n", bss_conf->use_cts_prot); - if (bss_conf->use_cts_prot && il->band != IEEE80211_BAND_5GHZ) - ctx->staging.flags |= RXON_FLG_TGG_PROTECT_MSK; - else - ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK; - if (bss_conf->use_cts_prot) - ctx->staging.flags |= RXON_FLG_SELF_CTS_EN; - else - ctx->staging.flags &= ~RXON_FLG_SELF_CTS_EN; - } - - if (changes & BSS_CHANGED_BASIC_RATES) { - /* XXX use this information - * - * To do that, remove code from il_set_rate() and put something - * like this here: - * - if (A-band) - ctx->staging.ofdm_basic_rates = - bss_conf->basic_rates; - else - ctx->staging.ofdm_basic_rates = - bss_conf->basic_rates >> 4; - ctx->staging.cck_basic_rates = - bss_conf->basic_rates & 0xF; - */ - } - - if (changes & BSS_CHANGED_HT) { - il_ht_conf(il, vif); - - if (il->cfg->ops->hcmd->set_rxon_chain) - il->cfg->ops->hcmd->set_rxon_chain(il, ctx); - } - - if (changes & BSS_CHANGED_ASSOC) { - D_MAC80211("ASSOC %d\n", bss_conf->assoc); - if (bss_conf->assoc) { - il->timestamp = bss_conf->timestamp; - - if (!il_is_rfkill(il)) - il->cfg->ops->legacy->post_associate(il); - } else - il_set_no_assoc(il, vif); - } - - if (changes && il_is_associated_ctx(ctx) && bss_conf->aid) { - D_MAC80211("Changes (%#x) while associated\n", - changes); - ret = il_send_rxon_assoc(il, ctx); - if (!ret) { - /* Sync active_rxon with latest change. */ - memcpy((void *)&ctx->active, - &ctx->staging, - sizeof(struct il_rxon_cmd)); - } - } - - if (changes & BSS_CHANGED_BEACON_ENABLED) { - if (vif->bss_conf.enable_beacon) { - memcpy(ctx->staging.bssid_addr, - bss_conf->bssid, ETH_ALEN); - memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); - il->cfg->ops->legacy->config_ap(il); - } else - il_set_no_assoc(il, vif); - } - - if (changes & BSS_CHANGED_IBSS) { - ret = il->cfg->ops->legacy->manage_ibss_station(il, vif, - bss_conf->ibss_joined); - if (ret) - IL_ERR("failed to %s IBSS station %pM\n", - bss_conf->ibss_joined ? "add" : "remove", - bss_conf->bssid); - } - - mutex_unlock(&il->mutex); - - D_MAC80211("leave\n"); -} -EXPORT_SYMBOL(il_mac_bss_info_changed); - -irqreturn_t il_isr(int irq, void *data) -{ - struct il_priv *il = data; - u32 inta, inta_mask; - u32 inta_fh; - unsigned long flags; - if (!il) - return IRQ_NONE; - - spin_lock_irqsave(&il->lock, flags); - - /* Disable (but don't clear!) interrupts here to avoid - * back-to-back ISRs and sporadic interrupts from our NIC. - * If we have something to service, the tasklet will re-enable ints. - * If we *don't* have something, we'll re-enable before leaving here. */ - inta_mask = _il_rd(il, CSR_INT_MASK); /* just for debug */ - _il_wr(il, CSR_INT_MASK, 0x00000000); - - /* Discover which interrupts are active/pending */ - inta = _il_rd(il, CSR_INT); - inta_fh = _il_rd(il, CSR_FH_INT_STATUS); - - /* Ignore interrupt if there's nothing in NIC to service. - * This may be due to IRQ shared with another device, - * or due to sporadic interrupts thrown from our NIC. */ - if (!inta && !inta_fh) { - D_ISR( - "Ignore interrupt, inta == 0, inta_fh == 0\n"); - goto none; - } - - if (inta == 0xFFFFFFFF || (inta & 0xFFFFFFF0) == 0xa5a5a5a0) { - /* Hardware disappeared. It might have already raised - * an interrupt */ - IL_WARN("HARDWARE GONE?? INTA == 0x%08x\n", inta); - goto unplugged; - } - - D_ISR("ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", - inta, inta_mask, inta_fh); - - inta &= ~CSR_INT_BIT_SCD; - - /* il_irq_tasklet() will service interrupts and re-enable them */ - if (likely(inta || inta_fh)) - tasklet_schedule(&il->irq_tasklet); - -unplugged: - spin_unlock_irqrestore(&il->lock, flags); - return IRQ_HANDLED; - -none: - /* re-enable interrupts here since we don't have anything to service. */ - /* only Re-enable if disabled by irq */ - if (test_bit(S_INT_ENABLED, &il->status)) - il_enable_interrupts(il); - spin_unlock_irqrestore(&il->lock, flags); - return IRQ_NONE; -} -EXPORT_SYMBOL(il_isr); - -/* - * il_tx_cmd_protection: Set rts/cts. 3945 and 4965 only share this - * function. - */ -void il_tx_cmd_protection(struct il_priv *il, - struct ieee80211_tx_info *info, - __le16 fc, __le32 *tx_flags) -{ - if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) { - *tx_flags |= TX_CMD_FLG_RTS_MSK; - *tx_flags &= ~TX_CMD_FLG_CTS_MSK; - *tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; - - if (!ieee80211_is_mgmt(fc)) - return; - - switch (fc & cpu_to_le16(IEEE80211_FCTL_STYPE)) { - case cpu_to_le16(IEEE80211_STYPE_AUTH): - case cpu_to_le16(IEEE80211_STYPE_DEAUTH): - case cpu_to_le16(IEEE80211_STYPE_ASSOC_REQ): - case cpu_to_le16(IEEE80211_STYPE_REASSOC_REQ): - *tx_flags &= ~TX_CMD_FLG_RTS_MSK; - *tx_flags |= TX_CMD_FLG_CTS_MSK; - break; - } - } else if (info->control.rates[0].flags & - IEEE80211_TX_RC_USE_CTS_PROTECT) { - *tx_flags &= ~TX_CMD_FLG_RTS_MSK; - *tx_flags |= TX_CMD_FLG_CTS_MSK; - *tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; - } -} -EXPORT_SYMBOL(il_tx_cmd_protection); -- cgit v1.2.3 From 0cdc21363cc27989fe9aa1cde614ef4c0429d62f Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 13:40:15 +0100 Subject: iwlegacy: merge common .c files Merge iwl-{tx,rx,sta,scan,power,eeprom,led,hcmd}.c into common.c . Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/Makefile | 4 +- drivers/net/wireless/iwlegacy/common.c | 3146 ++++++++++++++++++++++++++++ drivers/net/wireless/iwlegacy/iwl-eeprom.c | 553 ----- drivers/net/wireless/iwlegacy/iwl-hcmd.c | 271 --- drivers/net/wireless/iwlegacy/iwl-led.c | 205 -- drivers/net/wireless/iwlegacy/iwl-power.c | 165 -- drivers/net/wireless/iwlegacy/iwl-rx.c | 281 --- drivers/net/wireless/iwlegacy/iwl-scan.c | 545 ----- drivers/net/wireless/iwlegacy/iwl-tx.c | 655 ------ 9 files changed, 3147 insertions(+), 2678 deletions(-) delete mode 100644 drivers/net/wireless/iwlegacy/iwl-eeprom.c delete mode 100644 drivers/net/wireless/iwlegacy/iwl-hcmd.c delete mode 100644 drivers/net/wireless/iwlegacy/iwl-led.c delete mode 100644 drivers/net/wireless/iwlegacy/iwl-power.c delete mode 100644 drivers/net/wireless/iwlegacy/iwl-rx.c delete mode 100644 drivers/net/wireless/iwlegacy/iwl-scan.c delete mode 100644 drivers/net/wireless/iwlegacy/iwl-tx.c (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index 0f51f9d9e647..413213b0e974 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -1,7 +1,5 @@ obj-$(CONFIG_IWLEGACY) += iwl-legacy.o -iwl-legacy-objs := common.o iwl-eeprom.o iwl-hcmd.o iwl-power.o -iwl-legacy-objs += iwl-rx.o iwl-tx.o iwl-sta.o -iwl-legacy-objs += iwl-scan.o iwl-led.o +iwl-legacy-objs := common.o iwl-legacy-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-debugfs.o iwl-legacy-objs += $(iwl-legacy-m) diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 856a321ed1ea..7062574df365 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -31,6 +31,13 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include #include #include "iwl-eeprom.h" @@ -42,6 +49,3145 @@ #include "iwl-sta.h" #include "iwl-helpers.h" +const char *il_get_cmd_string(u8 cmd) +{ + switch (cmd) { + IL_CMD(N_ALIVE); + IL_CMD(N_ERROR); + IL_CMD(C_RXON); + IL_CMD(C_RXON_ASSOC); + IL_CMD(C_QOS_PARAM); + IL_CMD(C_RXON_TIMING); + IL_CMD(C_ADD_STA); + IL_CMD(C_REM_STA); + IL_CMD(C_WEPKEY); + IL_CMD(N_3945_RX); + IL_CMD(C_TX); + IL_CMD(C_RATE_SCALE); + IL_CMD(C_LEDS); + IL_CMD(C_TX_LINK_QUALITY_CMD); + IL_CMD(C_CHANNEL_SWITCH); + IL_CMD(N_CHANNEL_SWITCH); + IL_CMD(C_SPECTRUM_MEASUREMENT); + IL_CMD(N_SPECTRUM_MEASUREMENT); + IL_CMD(C_POWER_TBL); + IL_CMD(N_PM_SLEEP); + IL_CMD(N_PM_DEBUG_STATS); + IL_CMD(C_SCAN); + IL_CMD(C_SCAN_ABORT); + IL_CMD(N_SCAN_START); + IL_CMD(N_SCAN_RESULTS); + IL_CMD(N_SCAN_COMPLETE); + IL_CMD(N_BEACON); + IL_CMD(C_TX_BEACON); + IL_CMD(C_TX_PWR_TBL); + IL_CMD(C_BT_CONFIG); + IL_CMD(C_STATS); + IL_CMD(N_STATS); + IL_CMD(N_CARD_STATE); + IL_CMD(N_MISSED_BEACONS); + IL_CMD(C_CT_KILL_CONFIG); + IL_CMD(C_SENSITIVITY); + IL_CMD(C_PHY_CALIBRATION); + IL_CMD(N_RX_PHY); + IL_CMD(N_RX_MPDU); + IL_CMD(N_RX); + IL_CMD(N_COMPRESSED_BA); + default: + return "UNKNOWN"; + + } +} +EXPORT_SYMBOL(il_get_cmd_string); + +#define HOST_COMPLETE_TIMEOUT (HZ / 2) + +static void il_generic_cmd_callback(struct il_priv *il, + struct il_device_cmd *cmd, + struct il_rx_pkt *pkt) +{ + if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { + IL_ERR("Bad return from %s (0x%08X)\n", + il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); + return; + } + +#ifdef CONFIG_IWLEGACY_DEBUG + switch (cmd->hdr.cmd) { + case C_TX_LINK_QUALITY_CMD: + case C_SENSITIVITY: + D_HC_DUMP("back from %s (0x%08X)\n", + il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); + break; + default: + D_HC("back from %s (0x%08X)\n", + il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); + } +#endif +} + +static int +il_send_cmd_async(struct il_priv *il, struct il_host_cmd *cmd) +{ + int ret; + + BUG_ON(!(cmd->flags & CMD_ASYNC)); + + /* An asynchronous command can not expect an SKB to be set. */ + BUG_ON(cmd->flags & CMD_WANT_SKB); + + /* Assign a generic callback if one is not provided */ + if (!cmd->callback) + cmd->callback = il_generic_cmd_callback; + + if (test_bit(S_EXIT_PENDING, &il->status)) + return -EBUSY; + + ret = il_enqueue_hcmd(il, cmd); + if (ret < 0) { + IL_ERR("Error sending %s: enqueue_hcmd failed: %d\n", + il_get_cmd_string(cmd->id), ret); + return ret; + } + return 0; +} + +int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) +{ + int cmd_idx; + int ret; + + lockdep_assert_held(&il->mutex); + + BUG_ON(cmd->flags & CMD_ASYNC); + + /* A synchronous command can not have a callback set. */ + BUG_ON(cmd->callback); + + D_INFO("Attempting to send sync command %s\n", + il_get_cmd_string(cmd->id)); + + set_bit(S_HCMD_ACTIVE, &il->status); + D_INFO("Setting HCMD_ACTIVE for command %s\n", + il_get_cmd_string(cmd->id)); + + cmd_idx = il_enqueue_hcmd(il, cmd); + if (cmd_idx < 0) { + ret = cmd_idx; + IL_ERR("Error sending %s: enqueue_hcmd failed: %d\n", + il_get_cmd_string(cmd->id), ret); + goto out; + } + + ret = wait_event_timeout(il->wait_command_queue, + !test_bit(S_HCMD_ACTIVE, &il->status), + HOST_COMPLETE_TIMEOUT); + if (!ret) { + if (test_bit(S_HCMD_ACTIVE, &il->status)) { + IL_ERR( + "Error sending %s: time out after %dms.\n", + il_get_cmd_string(cmd->id), + jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); + + clear_bit(S_HCMD_ACTIVE, &il->status); + D_INFO( + "Clearing HCMD_ACTIVE for command %s\n", + il_get_cmd_string(cmd->id)); + ret = -ETIMEDOUT; + goto cancel; + } + } + + if (test_bit(S_RF_KILL_HW, &il->status)) { + IL_ERR("Command %s aborted: RF KILL Switch\n", + il_get_cmd_string(cmd->id)); + ret = -ECANCELED; + goto fail; + } + if (test_bit(S_FW_ERROR, &il->status)) { + IL_ERR("Command %s failed: FW Error\n", + il_get_cmd_string(cmd->id)); + ret = -EIO; + goto fail; + } + if ((cmd->flags & CMD_WANT_SKB) && !cmd->reply_page) { + IL_ERR("Error: Response NULL in '%s'\n", + il_get_cmd_string(cmd->id)); + ret = -EIO; + goto cancel; + } + + ret = 0; + goto out; + +cancel: + if (cmd->flags & CMD_WANT_SKB) { + /* + * Cancel the CMD_WANT_SKB flag for the cmd in the + * TX cmd queue. Otherwise in case the cmd comes + * in later, it will possibly set an invalid + * address (cmd->meta.source). + */ + il->txq[il->cmd_queue].meta[cmd_idx].flags &= + ~CMD_WANT_SKB; + } +fail: + if (cmd->reply_page) { + il_free_pages(il, cmd->reply_page); + cmd->reply_page = 0; + } +out: + return ret; +} +EXPORT_SYMBOL(il_send_cmd_sync); + +int il_send_cmd(struct il_priv *il, struct il_host_cmd *cmd) +{ + if (cmd->flags & CMD_ASYNC) + return il_send_cmd_async(il, cmd); + + return il_send_cmd_sync(il, cmd); +} +EXPORT_SYMBOL(il_send_cmd); + +int +il_send_cmd_pdu(struct il_priv *il, u8 id, u16 len, const void *data) +{ + struct il_host_cmd cmd = { + .id = id, + .len = len, + .data = data, + }; + + return il_send_cmd_sync(il, &cmd); +} +EXPORT_SYMBOL(il_send_cmd_pdu); + +int il_send_cmd_pdu_async(struct il_priv *il, + u8 id, u16 len, const void *data, + void (*callback)(struct il_priv *il, + struct il_device_cmd *cmd, + struct il_rx_pkt *pkt)) +{ + struct il_host_cmd cmd = { + .id = id, + .len = len, + .data = data, + }; + + cmd.flags |= CMD_ASYNC; + cmd.callback = callback; + + return il_send_cmd_async(il, &cmd); +} +EXPORT_SYMBOL(il_send_cmd_pdu_async); + +/* default: IL_LED_BLINK(0) using blinking idx table */ +static int led_mode; +module_param(led_mode, int, S_IRUGO); +MODULE_PARM_DESC(led_mode, "0=system default, " + "1=On(RF On)/Off(RF Off), 2=blinking"); + +/* Throughput OFF time(ms) ON time (ms) + * >300 25 25 + * >200 to 300 40 40 + * >100 to 200 55 55 + * >70 to 100 65 65 + * >50 to 70 75 75 + * >20 to 50 85 85 + * >10 to 20 95 95 + * >5 to 10 110 110 + * >1 to 5 130 130 + * >0 to 1 167 167 + * <=0 SOLID ON + */ +static const struct ieee80211_tpt_blink il_blink[] = { + { .throughput = 0, .blink_time = 334 }, + { .throughput = 1 * 1024 - 1, .blink_time = 260 }, + { .throughput = 5 * 1024 - 1, .blink_time = 220 }, + { .throughput = 10 * 1024 - 1, .blink_time = 190 }, + { .throughput = 20 * 1024 - 1, .blink_time = 170 }, + { .throughput = 50 * 1024 - 1, .blink_time = 150 }, + { .throughput = 70 * 1024 - 1, .blink_time = 130 }, + { .throughput = 100 * 1024 - 1, .blink_time = 110 }, + { .throughput = 200 * 1024 - 1, .blink_time = 80 }, + { .throughput = 300 * 1024 - 1, .blink_time = 50 }, +}; + +/* + * Adjust led blink rate to compensate on a MAC Clock difference on every HW + * Led blink rate analysis showed an average deviation of 0% on 3945, + * 5% on 4965 HW. + * Need to compensate on the led on/off time per HW according to the deviation + * to achieve the desired led frequency + * The calculation is: (100-averageDeviation)/100 * blinkTime + * For code efficiency the calculation will be: + * compensation = (100 - averageDeviation) * 64 / 100 + * NewBlinkTime = (compensation * BlinkTime) / 64 + */ +static inline u8 il_blink_compensation(struct il_priv *il, + u8 time, u16 compensation) +{ + if (!compensation) { + IL_ERR("undefined blink compensation: " + "use pre-defined blinking time\n"); + return time; + } + + return (u8)((time * compensation) >> 6); +} + +/* Set led pattern command */ +static int il_led_cmd(struct il_priv *il, + unsigned long on, + unsigned long off) +{ + struct il_led_cmd led_cmd = { + .id = IL_LED_LINK, + .interval = IL_DEF_LED_INTRVL + }; + int ret; + + if (!test_bit(S_READY, &il->status)) + return -EBUSY; + + if (il->blink_on == on && il->blink_off == off) + return 0; + + if (off == 0) { + /* led is SOLID_ON */ + on = IL_LED_SOLID; + } + + D_LED("Led blink time compensation=%u\n", + il->cfg->base_params->led_compensation); + led_cmd.on = il_blink_compensation(il, on, + il->cfg->base_params->led_compensation); + led_cmd.off = il_blink_compensation(il, off, + il->cfg->base_params->led_compensation); + + ret = il->cfg->ops->led->cmd(il, &led_cmd); + if (!ret) { + il->blink_on = on; + il->blink_off = off; + } + return ret; +} + +static void il_led_brightness_set(struct led_classdev *led_cdev, + enum led_brightness brightness) +{ + struct il_priv *il = container_of(led_cdev, struct il_priv, led); + unsigned long on = 0; + + if (brightness > 0) + on = IL_LED_SOLID; + + il_led_cmd(il, on, 0); +} + +static int il_led_blink_set(struct led_classdev *led_cdev, + unsigned long *delay_on, + unsigned long *delay_off) +{ + struct il_priv *il = container_of(led_cdev, struct il_priv, led); + + return il_led_cmd(il, *delay_on, *delay_off); +} + +void il_leds_init(struct il_priv *il) +{ + int mode = led_mode; + int ret; + + if (mode == IL_LED_DEFAULT) + mode = il->cfg->led_mode; + + il->led.name = kasprintf(GFP_KERNEL, "%s-led", + wiphy_name(il->hw->wiphy)); + il->led.brightness_set = il_led_brightness_set; + il->led.blink_set = il_led_blink_set; + il->led.max_brightness = 1; + + switch (mode) { + case IL_LED_DEFAULT: + WARN_ON(1); + break; + case IL_LED_BLINK: + il->led.default_trigger = + ieee80211_create_tpt_led_trigger(il->hw, + IEEE80211_TPT_LEDTRIG_FL_CONNECTED, + il_blink, ARRAY_SIZE(il_blink)); + break; + case IL_LED_RF_STATE: + il->led.default_trigger = + ieee80211_get_radio_led_name(il->hw); + break; + } + + ret = led_classdev_register(&il->pci_dev->dev, &il->led); + if (ret) { + kfree(il->led.name); + return; + } + + il->led_registered = true; +} +EXPORT_SYMBOL(il_leds_init); + +void il_leds_exit(struct il_priv *il) +{ + if (!il->led_registered) + return; + + led_classdev_unregister(&il->led); + kfree(il->led.name); +} +EXPORT_SYMBOL(il_leds_exit); + +/************************** EEPROM BANDS **************************** + * + * The il_eeprom_band definitions below provide the mapping from the + * EEPROM contents to the specific channel number supported for each + * band. + * + * For example, il_priv->eeprom.band_3_channels[4] from the band_3 + * definition below maps to physical channel 42 in the 5.2GHz spectrum. + * The specific geography and calibration information for that channel + * is contained in the eeprom map itself. + * + * During init, we copy the eeprom information and channel map + * information into il->channel_info_24/52 and il->channel_map_24/52 + * + * channel_map_24/52 provides the idx in the channel_info array for a + * given channel. We have to have two separate maps as there is channel + * overlap with the 2.4GHz and 5.2GHz spectrum as seen in band_1 and + * band_2 + * + * A value of 0xff stored in the channel_map indicates that the channel + * is not supported by the hardware at all. + * + * A value of 0xfe in the channel_map indicates that the channel is not + * valid for Tx with the current hardware. This means that + * while the system can tune and receive on a given channel, it may not + * be able to associate or transmit any frames on that + * channel. There is no corresponding channel information for that + * entry. + * + *********************************************************************/ + +/* 2.4 GHz */ +const u8 il_eeprom_band_1[14] = { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 +}; + +/* 5.2 GHz bands */ +static const u8 il_eeprom_band_2[] = { /* 4915-5080MHz */ + 183, 184, 185, 187, 188, 189, 192, 196, 7, 8, 11, 12, 16 +}; + +static const u8 il_eeprom_band_3[] = { /* 5170-5320MHz */ + 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 +}; + +static const u8 il_eeprom_band_4[] = { /* 5500-5700MHz */ + 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 +}; + +static const u8 il_eeprom_band_5[] = { /* 5725-5825MHz */ + 145, 149, 153, 157, 161, 165 +}; + +static const u8 il_eeprom_band_6[] = { /* 2.4 ht40 channel */ + 1, 2, 3, 4, 5, 6, 7 +}; + +static const u8 il_eeprom_band_7[] = { /* 5.2 ht40 channel */ + 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157 +}; + +/****************************************************************************** + * + * EEPROM related functions + * +******************************************************************************/ + +static int il_eeprom_verify_signature(struct il_priv *il) +{ + u32 gp = _il_rd(il, CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; + int ret = 0; + + D_EEPROM("EEPROM signature=0x%08x\n", gp); + switch (gp) { + case CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K: + case CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K: + break; + default: + IL_ERR("bad EEPROM signature," + "EEPROM_GP=0x%08x\n", gp); + ret = -ENOENT; + break; + } + return ret; +} + +const u8 +*il_eeprom_query_addr(const struct il_priv *il, size_t offset) +{ + BUG_ON(offset >= il->cfg->base_params->eeprom_size); + return &il->eeprom[offset]; +} +EXPORT_SYMBOL(il_eeprom_query_addr); + +u16 il_eeprom_query16(const struct il_priv *il, size_t offset) +{ + if (!il->eeprom) + return 0; + return (u16)il->eeprom[offset] | ((u16)il->eeprom[offset + 1] << 8); +} +EXPORT_SYMBOL(il_eeprom_query16); + +/** + * il_eeprom_init - read EEPROM contents + * + * Load the EEPROM contents from adapter into il->eeprom + * + * NOTE: This routine uses the non-debug IO access functions. + */ +int il_eeprom_init(struct il_priv *il) +{ + __le16 *e; + u32 gp = _il_rd(il, CSR_EEPROM_GP); + int sz; + int ret; + u16 addr; + + /* allocate eeprom */ + sz = il->cfg->base_params->eeprom_size; + D_EEPROM("NVM size = %d\n", sz); + il->eeprom = kzalloc(sz, GFP_KERNEL); + if (!il->eeprom) { + ret = -ENOMEM; + goto alloc_err; + } + e = (__le16 *)il->eeprom; + + il->cfg->ops->lib->apm_ops.init(il); + + ret = il_eeprom_verify_signature(il); + if (ret < 0) { + IL_ERR("EEPROM not found, EEPROM_GP=0x%08x\n", gp); + ret = -ENOENT; + goto err; + } + + /* Make sure driver (instead of uCode) is allowed to read EEPROM */ + ret = il->cfg->ops->lib->eeprom_ops.acquire_semaphore(il); + if (ret < 0) { + IL_ERR("Failed to acquire EEPROM semaphore.\n"); + ret = -ENOENT; + goto err; + } + + /* eeprom is an array of 16bit values */ + for (addr = 0; addr < sz; addr += sizeof(u16)) { + u32 r; + + _il_wr(il, CSR_EEPROM_REG, + CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); + + ret = _il_poll_bit(il, CSR_EEPROM_REG, + CSR_EEPROM_REG_READ_VALID_MSK, + CSR_EEPROM_REG_READ_VALID_MSK, + IL_EEPROM_ACCESS_TIMEOUT); + if (ret < 0) { + IL_ERR("Time out reading EEPROM[%d]\n", + addr); + goto done; + } + r = _il_rd(il, CSR_EEPROM_REG); + e[addr / 2] = cpu_to_le16(r >> 16); + } + + D_EEPROM("NVM Type: %s, version: 0x%x\n", + "EEPROM", + il_eeprom_query16(il, EEPROM_VERSION)); + + ret = 0; +done: + il->cfg->ops->lib->eeprom_ops.release_semaphore(il); + +err: + if (ret) + il_eeprom_free(il); + /* Reset chip to save power until we load uCode during "up". */ + il_apm_stop(il); +alloc_err: + return ret; +} +EXPORT_SYMBOL(il_eeprom_init); + +void il_eeprom_free(struct il_priv *il) +{ + kfree(il->eeprom); + il->eeprom = NULL; +} +EXPORT_SYMBOL(il_eeprom_free); + +static void il_init_band_reference(const struct il_priv *il, + int eep_band, int *eeprom_ch_count, + const struct il_eeprom_channel **eeprom_ch_info, + const u8 **eeprom_ch_idx) +{ + u32 offset = il->cfg->ops->lib-> + eeprom_ops.regulatory_bands[eep_band - 1]; + switch (eep_band) { + case 1: /* 2.4GHz band */ + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_1); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(il, offset); + *eeprom_ch_idx = il_eeprom_band_1; + break; + case 2: /* 4.9GHz band */ + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_2); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(il, offset); + *eeprom_ch_idx = il_eeprom_band_2; + break; + case 3: /* 5.2GHz band */ + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_3); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(il, offset); + *eeprom_ch_idx = il_eeprom_band_3; + break; + case 4: /* 5.5GHz band */ + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_4); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(il, offset); + *eeprom_ch_idx = il_eeprom_band_4; + break; + case 5: /* 5.7GHz band */ + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_5); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(il, offset); + *eeprom_ch_idx = il_eeprom_band_5; + break; + case 6: /* 2.4GHz ht40 channels */ + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_6); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(il, offset); + *eeprom_ch_idx = il_eeprom_band_6; + break; + case 7: /* 5 GHz ht40 channels */ + *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_7); + *eeprom_ch_info = (struct il_eeprom_channel *) + il_eeprom_query_addr(il, offset); + *eeprom_ch_idx = il_eeprom_band_7; + break; + default: + BUG(); + } +} + +#define CHECK_AND_PRINT(x) ((eeprom_ch->flags & EEPROM_CHANNEL_##x) \ + ? # x " " : "") +/** + * il_mod_ht40_chan_info - Copy ht40 channel info into driver's il. + * + * Does not set up a command, or touch hardware. + */ +static int il_mod_ht40_chan_info(struct il_priv *il, + enum ieee80211_band band, u16 channel, + const struct il_eeprom_channel *eeprom_ch, + u8 clear_ht40_extension_channel) +{ + struct il_channel_info *ch_info; + + ch_info = (struct il_channel_info *) + il_get_channel_info(il, band, channel); + + if (!il_is_channel_valid(ch_info)) + return -1; + + D_EEPROM("HT40 Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):" + " Ad-Hoc %ssupported\n", + ch_info->channel, + il_is_channel_a_band(ch_info) ? + "5.2" : "2.4", + CHECK_AND_PRINT(IBSS), + CHECK_AND_PRINT(ACTIVE), + CHECK_AND_PRINT(RADAR), + CHECK_AND_PRINT(WIDE), + CHECK_AND_PRINT(DFS), + eeprom_ch->flags, + eeprom_ch->max_power_avg, + ((eeprom_ch->flags & EEPROM_CHANNEL_IBSS) + && !(eeprom_ch->flags & EEPROM_CHANNEL_RADAR)) ? + "" : "not "); + + ch_info->ht40_eeprom = *eeprom_ch; + ch_info->ht40_max_power_avg = eeprom_ch->max_power_avg; + ch_info->ht40_flags = eeprom_ch->flags; + if (eeprom_ch->flags & EEPROM_CHANNEL_VALID) + ch_info->ht40_extension_channel &= + ~clear_ht40_extension_channel; + + return 0; +} + +#define CHECK_AND_PRINT_I(x) ((eeprom_ch_info[ch].flags & EEPROM_CHANNEL_##x) \ + ? # x " " : "") + +/** + * il_init_channel_map - Set up driver's info for all possible channels + */ +int il_init_channel_map(struct il_priv *il) +{ + int eeprom_ch_count = 0; + const u8 *eeprom_ch_idx = NULL; + const struct il_eeprom_channel *eeprom_ch_info = NULL; + int band, ch; + struct il_channel_info *ch_info; + + if (il->channel_count) { + D_EEPROM("Channel map already initialized.\n"); + return 0; + } + + D_EEPROM("Initializing regulatory info from EEPROM\n"); + + il->channel_count = + ARRAY_SIZE(il_eeprom_band_1) + + ARRAY_SIZE(il_eeprom_band_2) + + ARRAY_SIZE(il_eeprom_band_3) + + ARRAY_SIZE(il_eeprom_band_4) + + ARRAY_SIZE(il_eeprom_band_5); + + D_EEPROM("Parsing data for %d channels.\n", + il->channel_count); + + il->channel_info = kzalloc(sizeof(struct il_channel_info) * + il->channel_count, GFP_KERNEL); + if (!il->channel_info) { + IL_ERR("Could not allocate channel_info\n"); + il->channel_count = 0; + return -ENOMEM; + } + + ch_info = il->channel_info; + + /* Loop through the 5 EEPROM bands adding them in order to the + * channel map we maintain (that contains additional information than + * what just in the EEPROM) */ + for (band = 1; band <= 5; band++) { + + il_init_band_reference(il, band, &eeprom_ch_count, + &eeprom_ch_info, &eeprom_ch_idx); + + /* Loop through each band adding each of the channels */ + for (ch = 0; ch < eeprom_ch_count; ch++) { + ch_info->channel = eeprom_ch_idx[ch]; + ch_info->band = (band == 1) ? IEEE80211_BAND_2GHZ : + IEEE80211_BAND_5GHZ; + + /* permanently store EEPROM's channel regulatory flags + * and max power in channel info database. */ + ch_info->eeprom = eeprom_ch_info[ch]; + + /* Copy the run-time flags so they are there even on + * invalid channels */ + ch_info->flags = eeprom_ch_info[ch].flags; + /* First write that ht40 is not enabled, and then enable + * one by one */ + ch_info->ht40_extension_channel = + IEEE80211_CHAN_NO_HT40; + + if (!(il_is_channel_valid(ch_info))) { + D_EEPROM( + "Ch. %d Flags %x [%sGHz] - " + "No traffic\n", + ch_info->channel, + ch_info->flags, + il_is_channel_a_band(ch_info) ? + "5.2" : "2.4"); + ch_info++; + continue; + } + + /* Initialize regulatory-based run-time data */ + ch_info->max_power_avg = ch_info->curr_txpow = + eeprom_ch_info[ch].max_power_avg; + ch_info->scan_power = eeprom_ch_info[ch].max_power_avg; + ch_info->min_power = 0; + + D_EEPROM("Ch. %d [%sGHz] " + "%s%s%s%s%s%s(0x%02x %ddBm):" + " Ad-Hoc %ssupported\n", + ch_info->channel, + il_is_channel_a_band(ch_info) ? + "5.2" : "2.4", + CHECK_AND_PRINT_I(VALID), + CHECK_AND_PRINT_I(IBSS), + CHECK_AND_PRINT_I(ACTIVE), + CHECK_AND_PRINT_I(RADAR), + CHECK_AND_PRINT_I(WIDE), + CHECK_AND_PRINT_I(DFS), + eeprom_ch_info[ch].flags, + eeprom_ch_info[ch].max_power_avg, + ((eeprom_ch_info[ch]. + flags & EEPROM_CHANNEL_IBSS) + && !(eeprom_ch_info[ch]. + flags & EEPROM_CHANNEL_RADAR)) + ? "" : "not "); + + ch_info++; + } + } + + /* Check if we do have HT40 channels */ + if (il->cfg->ops->lib->eeprom_ops.regulatory_bands[5] == + EEPROM_REGULATORY_BAND_NO_HT40 && + il->cfg->ops->lib->eeprom_ops.regulatory_bands[6] == + EEPROM_REGULATORY_BAND_NO_HT40) + return 0; + + /* Two additional EEPROM bands for 2.4 and 5 GHz HT40 channels */ + for (band = 6; band <= 7; band++) { + enum ieee80211_band ieeeband; + + il_init_band_reference(il, band, &eeprom_ch_count, + &eeprom_ch_info, &eeprom_ch_idx); + + /* EEPROM band 6 is 2.4, band 7 is 5 GHz */ + ieeeband = + (band == 6) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; + + /* Loop through each band adding each of the channels */ + for (ch = 0; ch < eeprom_ch_count; ch++) { + /* Set up driver's info for lower half */ + il_mod_ht40_chan_info(il, ieeeband, + eeprom_ch_idx[ch], + &eeprom_ch_info[ch], + IEEE80211_CHAN_NO_HT40PLUS); + + /* Set up driver's info for upper half */ + il_mod_ht40_chan_info(il, ieeeband, + eeprom_ch_idx[ch] + 4, + &eeprom_ch_info[ch], + IEEE80211_CHAN_NO_HT40MINUS); + } + } + + return 0; +} +EXPORT_SYMBOL(il_init_channel_map); + +/* + * il_free_channel_map - undo allocations in il_init_channel_map + */ +void il_free_channel_map(struct il_priv *il) +{ + kfree(il->channel_info); + il->channel_count = 0; +} +EXPORT_SYMBOL(il_free_channel_map); + +/** + * il_get_channel_info - Find driver's ilate channel info + * + * Based on band and channel number. + */ +const struct +il_channel_info *il_get_channel_info(const struct il_priv *il, + enum ieee80211_band band, u16 channel) +{ + int i; + + switch (band) { + case IEEE80211_BAND_5GHZ: + for (i = 14; i < il->channel_count; i++) { + if (il->channel_info[i].channel == channel) + return &il->channel_info[i]; + } + break; + case IEEE80211_BAND_2GHZ: + if (channel >= 1 && channel <= 14) + return &il->channel_info[channel - 1]; + break; + default: + BUG(); + } + + return NULL; +} +EXPORT_SYMBOL(il_get_channel_info); + +/* + * Setting power level allows the card to go to sleep when not busy. + * + * We calculate a sleep command based on the required latency, which + * we get from mac80211. In order to handle thermal throttling, we can + * also use pre-defined power levels. + */ + +/* + * This defines the old power levels. They are still used by default + * (level 1) and for thermal throttle (levels 3 through 5) + */ + +struct il_power_vec_entry { + struct il_powertable_cmd cmd; + u8 no_dtim; /* number of skip dtim */ +}; + +static void il_power_sleep_cam_cmd(struct il_priv *il, + struct il_powertable_cmd *cmd) +{ + memset(cmd, 0, sizeof(*cmd)); + + if (il->power_data.pci_pm) + cmd->flags |= IL_POWER_PCI_PM_MSK; + + D_POWER("Sleep command for CAM\n"); +} + +static int +il_set_power(struct il_priv *il, struct il_powertable_cmd *cmd) +{ + D_POWER("Sending power/sleep command\n"); + D_POWER("Flags value = 0x%08X\n", cmd->flags); + D_POWER("Tx timeout = %u\n", + le32_to_cpu(cmd->tx_data_timeout)); + D_POWER("Rx timeout = %u\n", + le32_to_cpu(cmd->rx_data_timeout)); + D_POWER( + "Sleep interval vector = { %d , %d , %d , %d , %d }\n", + le32_to_cpu(cmd->sleep_interval[0]), + le32_to_cpu(cmd->sleep_interval[1]), + le32_to_cpu(cmd->sleep_interval[2]), + le32_to_cpu(cmd->sleep_interval[3]), + le32_to_cpu(cmd->sleep_interval[4])); + + return il_send_cmd_pdu(il, C_POWER_TBL, + sizeof(struct il_powertable_cmd), cmd); +} + +int +il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, + bool force) +{ + int ret; + bool update_chains; + + lockdep_assert_held(&il->mutex); + + /* Don't update the RX chain when chain noise calibration is running */ + update_chains = il->chain_noise_data.state == IL_CHAIN_NOISE_DONE || + il->chain_noise_data.state == IL_CHAIN_NOISE_ALIVE; + + if (!memcmp(&il->power_data.sleep_cmd, cmd, sizeof(*cmd)) && !force) + return 0; + + if (!il_is_ready_rf(il)) + return -EIO; + + /* scan complete use sleep_power_next, need to be updated */ + memcpy(&il->power_data.sleep_cmd_next, cmd, sizeof(*cmd)); + if (test_bit(S_SCANNING, &il->status) && !force) { + D_INFO("Defer power set mode while scanning\n"); + return 0; + } + + if (cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK) + set_bit(S_POWER_PMI, &il->status); + + ret = il_set_power(il, cmd); + if (!ret) { + if (!(cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK)) + clear_bit(S_POWER_PMI, &il->status); + + if (il->cfg->ops->lib->update_chain_flags && update_chains) + il->cfg->ops->lib->update_chain_flags(il); + else if (il->cfg->ops->lib->update_chain_flags) + D_POWER( + "Cannot update the power, chain noise " + "calibration running: %d\n", + il->chain_noise_data.state); + + memcpy(&il->power_data.sleep_cmd, cmd, sizeof(*cmd)); + } else + IL_ERR("set power fail, ret = %d", ret); + + return ret; +} + +int il_power_update_mode(struct il_priv *il, bool force) +{ + struct il_powertable_cmd cmd; + + il_power_sleep_cam_cmd(il, &cmd); + return il_power_set_mode(il, &cmd, force); +} +EXPORT_SYMBOL(il_power_update_mode); + +/* initialize to default */ +void il_power_initialize(struct il_priv *il) +{ + u16 lctl = il_pcie_link_ctl(il); + + il->power_data.pci_pm = !(lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN); + + il->power_data.debug_sleep_level_override = -1; + + memset(&il->power_data.sleep_cmd, 0, + sizeof(il->power_data.sleep_cmd)); +} +EXPORT_SYMBOL(il_power_initialize); + +/* For active scan, listen ACTIVE_DWELL_TIME (msec) on each channel after + * sending probe req. This should be set long enough to hear probe responses + * from more than one AP. */ +#define IL_ACTIVE_DWELL_TIME_24 (30) /* all times in msec */ +#define IL_ACTIVE_DWELL_TIME_52 (20) + +#define IL_ACTIVE_DWELL_FACTOR_24GHZ (3) +#define IL_ACTIVE_DWELL_FACTOR_52GHZ (2) + +/* For passive scan, listen PASSIVE_DWELL_TIME (msec) on each channel. + * Must be set longer than active dwell time. + * For the most reliable scan, set > AP beacon interval (typically 100msec). */ +#define IL_PASSIVE_DWELL_TIME_24 (20) /* all times in msec */ +#define IL_PASSIVE_DWELL_TIME_52 (10) +#define IL_PASSIVE_DWELL_BASE (100) +#define IL_CHANNEL_TUNE_TIME 5 + +static int il_send_scan_abort(struct il_priv *il) +{ + int ret; + struct il_rx_pkt *pkt; + struct il_host_cmd cmd = { + .id = C_SCAN_ABORT, + .flags = CMD_WANT_SKB, + }; + + /* Exit instantly with error when device is not ready + * to receive scan abort command or it does not perform + * hardware scan currently */ + if (!test_bit(S_READY, &il->status) || + !test_bit(S_GEO_CONFIGURED, &il->status) || + !test_bit(S_SCAN_HW, &il->status) || + test_bit(S_FW_ERROR, &il->status) || + test_bit(S_EXIT_PENDING, &il->status)) + return -EIO; + + ret = il_send_cmd_sync(il, &cmd); + if (ret) + return ret; + + pkt = (struct il_rx_pkt *)cmd.reply_page; + if (pkt->u.status != CAN_ABORT_STATUS) { + /* The scan abort will return 1 for success or + * 2 for "failure". A failure condition can be + * due to simply not being in an active scan which + * can occur if we send the scan abort before we + * the microcode has notified us that a scan is + * completed. */ + D_SCAN("SCAN_ABORT ret %d.\n", pkt->u.status); + ret = -EIO; + } + + il_free_pages(il, cmd.reply_page); + return ret; +} + +static void il_complete_scan(struct il_priv *il, bool aborted) +{ + /* check if scan was requested from mac80211 */ + if (il->scan_request) { + D_SCAN("Complete scan in mac80211\n"); + ieee80211_scan_completed(il->hw, aborted); + } + + il->scan_vif = NULL; + il->scan_request = NULL; +} + +void il_force_scan_end(struct il_priv *il) +{ + lockdep_assert_held(&il->mutex); + + if (!test_bit(S_SCANNING, &il->status)) { + D_SCAN("Forcing scan end while not scanning\n"); + return; + } + + D_SCAN("Forcing scan end\n"); + clear_bit(S_SCANNING, &il->status); + clear_bit(S_SCAN_HW, &il->status); + clear_bit(S_SCAN_ABORTING, &il->status); + il_complete_scan(il, true); +} + +static void il_do_scan_abort(struct il_priv *il) +{ + int ret; + + lockdep_assert_held(&il->mutex); + + if (!test_bit(S_SCANNING, &il->status)) { + D_SCAN("Not performing scan to abort\n"); + return; + } + + if (test_and_set_bit(S_SCAN_ABORTING, &il->status)) { + D_SCAN("Scan abort in progress\n"); + return; + } + + ret = il_send_scan_abort(il); + if (ret) { + D_SCAN("Send scan abort failed %d\n", ret); + il_force_scan_end(il); + } else + D_SCAN("Successfully send scan abort\n"); +} + +/** + * il_scan_cancel - Cancel any currently executing HW scan + */ +int il_scan_cancel(struct il_priv *il) +{ + D_SCAN("Queuing abort scan\n"); + queue_work(il->workqueue, &il->abort_scan); + return 0; +} +EXPORT_SYMBOL(il_scan_cancel); + +/** + * il_scan_cancel_timeout - Cancel any currently executing HW scan + * @ms: amount of time to wait (in milliseconds) for scan to abort + * + */ +int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms) +{ + unsigned long timeout = jiffies + msecs_to_jiffies(ms); + + lockdep_assert_held(&il->mutex); + + D_SCAN("Scan cancel timeout\n"); + + il_do_scan_abort(il); + + while (time_before_eq(jiffies, timeout)) { + if (!test_bit(S_SCAN_HW, &il->status)) + break; + msleep(20); + } + + return test_bit(S_SCAN_HW, &il->status); +} +EXPORT_SYMBOL(il_scan_cancel_timeout); + +/* Service response to C_SCAN (0x80) */ +static void il_hdl_scan(struct il_priv *il, + struct il_rx_buf *rxb) +{ +#ifdef CONFIG_IWLEGACY_DEBUG + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il_scanreq_notification *notif = + (struct il_scanreq_notification *)pkt->u.raw; + + D_SCAN("Scan request status = 0x%x\n", notif->status); +#endif +} + +/* Service N_SCAN_START (0x82) */ +static void il_hdl_scan_start(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il_scanstart_notification *notif = + (struct il_scanstart_notification *)pkt->u.raw; + il->scan_start_tsf = le32_to_cpu(notif->tsf_low); + D_SCAN("Scan start: " + "%d [802.11%s] " + "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n", + notif->channel, + notif->band ? "bg" : "a", + le32_to_cpu(notif->tsf_high), + le32_to_cpu(notif->tsf_low), + notif->status, notif->beacon_timer); +} + +/* Service N_SCAN_RESULTS (0x83) */ +static void il_hdl_scan_results(struct il_priv *il, + struct il_rx_buf *rxb) +{ +#ifdef CONFIG_IWLEGACY_DEBUG + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il_scanresults_notification *notif = + (struct il_scanresults_notification *)pkt->u.raw; + + D_SCAN("Scan ch.res: " + "%d [802.11%s] " + "(TSF: 0x%08X:%08X) - %d " + "elapsed=%lu usec\n", + notif->channel, + notif->band ? "bg" : "a", + le32_to_cpu(notif->tsf_high), + le32_to_cpu(notif->tsf_low), + le32_to_cpu(notif->stats[0]), + le32_to_cpu(notif->tsf_low) - il->scan_start_tsf); +#endif +} + +/* Service N_SCAN_COMPLETE (0x84) */ +static void il_hdl_scan_complete(struct il_priv *il, + struct il_rx_buf *rxb) +{ + +#ifdef CONFIG_IWLEGACY_DEBUG + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il_scancomplete_notification *scan_notif = (void *)pkt->u.raw; +#endif + + D_SCAN( + "Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n", + scan_notif->scanned_channels, + scan_notif->tsf_low, + scan_notif->tsf_high, scan_notif->status); + + /* The HW is no longer scanning */ + clear_bit(S_SCAN_HW, &il->status); + + D_SCAN("Scan on %sGHz took %dms\n", + (il->scan_band == IEEE80211_BAND_2GHZ) ? "2.4" : "5.2", + jiffies_to_msecs(jiffies - il->scan_start)); + + queue_work(il->workqueue, &il->scan_completed); +} + +void il_setup_rx_scan_handlers(struct il_priv *il) +{ + /* scan handlers */ + il->handlers[C_SCAN] = il_hdl_scan; + il->handlers[N_SCAN_START] = + il_hdl_scan_start; + il->handlers[N_SCAN_RESULTS] = + il_hdl_scan_results; + il->handlers[N_SCAN_COMPLETE] = + il_hdl_scan_complete; +} +EXPORT_SYMBOL(il_setup_rx_scan_handlers); + +inline u16 il_get_active_dwell_time(struct il_priv *il, + enum ieee80211_band band, + u8 n_probes) +{ + if (band == IEEE80211_BAND_5GHZ) + return IL_ACTIVE_DWELL_TIME_52 + + IL_ACTIVE_DWELL_FACTOR_52GHZ * (n_probes + 1); + else + return IL_ACTIVE_DWELL_TIME_24 + + IL_ACTIVE_DWELL_FACTOR_24GHZ * (n_probes + 1); +} +EXPORT_SYMBOL(il_get_active_dwell_time); + +u16 il_get_passive_dwell_time(struct il_priv *il, + enum ieee80211_band band, + struct ieee80211_vif *vif) +{ + struct il_rxon_context *ctx = &il->ctx; + u16 value; + + u16 passive = (band == IEEE80211_BAND_2GHZ) ? + IL_PASSIVE_DWELL_BASE + IL_PASSIVE_DWELL_TIME_24 : + IL_PASSIVE_DWELL_BASE + IL_PASSIVE_DWELL_TIME_52; + + if (il_is_any_associated(il)) { + /* + * If we're associated, we clamp the maximum passive + * dwell time to be 98% of the smallest beacon interval + * (minus 2 * channel tune time) + */ + value = ctx->vif ? ctx->vif->bss_conf.beacon_int : 0; + if (value > IL_PASSIVE_DWELL_BASE || !value) + value = IL_PASSIVE_DWELL_BASE; + value = (value * 98) / 100 - IL_CHANNEL_TUNE_TIME * 2; + passive = min(value, passive); + } + + return passive; +} +EXPORT_SYMBOL(il_get_passive_dwell_time); + +void il_init_scan_params(struct il_priv *il) +{ + u8 ant_idx = fls(il->hw_params.valid_tx_ant) - 1; + if (!il->scan_tx_ant[IEEE80211_BAND_5GHZ]) + il->scan_tx_ant[IEEE80211_BAND_5GHZ] = ant_idx; + if (!il->scan_tx_ant[IEEE80211_BAND_2GHZ]) + il->scan_tx_ant[IEEE80211_BAND_2GHZ] = ant_idx; +} +EXPORT_SYMBOL(il_init_scan_params); + +static int il_scan_initiate(struct il_priv *il, + struct ieee80211_vif *vif) +{ + int ret; + + lockdep_assert_held(&il->mutex); + + if (WARN_ON(!il->cfg->ops->utils->request_scan)) + return -EOPNOTSUPP; + + cancel_delayed_work(&il->scan_check); + + if (!il_is_ready_rf(il)) { + IL_WARN("Request scan called when driver not ready.\n"); + return -EIO; + } + + if (test_bit(S_SCAN_HW, &il->status)) { + D_SCAN( + "Multiple concurrent scan requests in parallel.\n"); + return -EBUSY; + } + + if (test_bit(S_SCAN_ABORTING, &il->status)) { + D_SCAN("Scan request while abort pending.\n"); + return -EBUSY; + } + + D_SCAN("Starting scan...\n"); + + set_bit(S_SCANNING, &il->status); + il->scan_start = jiffies; + + ret = il->cfg->ops->utils->request_scan(il, vif); + if (ret) { + clear_bit(S_SCANNING, &il->status); + return ret; + } + + queue_delayed_work(il->workqueue, &il->scan_check, + IL_SCAN_CHECK_WATCHDOG); + + return 0; +} + +int il_mac_hw_scan(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct cfg80211_scan_request *req) +{ + struct il_priv *il = hw->priv; + int ret; + + D_MAC80211("enter\n"); + + if (req->n_channels == 0) + return -EINVAL; + + mutex_lock(&il->mutex); + + if (test_bit(S_SCANNING, &il->status)) { + D_SCAN("Scan already in progress.\n"); + ret = -EAGAIN; + goto out_unlock; + } + + /* mac80211 will only ask for one band at a time */ + il->scan_request = req; + il->scan_vif = vif; + il->scan_band = req->channels[0]->band; + + ret = il_scan_initiate(il, vif); + + D_MAC80211("leave\n"); + +out_unlock: + mutex_unlock(&il->mutex); + + return ret; +} +EXPORT_SYMBOL(il_mac_hw_scan); + +static void il_bg_scan_check(struct work_struct *data) +{ + struct il_priv *il = + container_of(data, struct il_priv, scan_check.work); + + D_SCAN("Scan check work\n"); + + /* Since we are here firmware does not finish scan and + * most likely is in bad shape, so we don't bother to + * send abort command, just force scan complete to mac80211 */ + mutex_lock(&il->mutex); + il_force_scan_end(il); + mutex_unlock(&il->mutex); +} + +/** + * il_fill_probe_req - fill in all required fields and IE for probe request + */ + +u16 +il_fill_probe_req(struct il_priv *il, struct ieee80211_mgmt *frame, + const u8 *ta, const u8 *ies, int ie_len, int left) +{ + int len = 0; + u8 *pos = NULL; + + /* Make sure there is enough space for the probe request, + * two mandatory IEs and the data */ + left -= 24; + if (left < 0) + return 0; + + frame->frame_control = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); + memcpy(frame->da, il_bcast_addr, ETH_ALEN); + memcpy(frame->sa, ta, ETH_ALEN); + memcpy(frame->bssid, il_bcast_addr, ETH_ALEN); + frame->seq_ctrl = 0; + + len += 24; + + /* ...next IE... */ + pos = &frame->u.probe_req.variable[0]; + + /* fill in our indirect SSID IE */ + left -= 2; + if (left < 0) + return 0; + *pos++ = WLAN_EID_SSID; + *pos++ = 0; + + len += 2; + + if (WARN_ON(left < ie_len)) + return len; + + if (ies && ie_len) { + memcpy(pos, ies, ie_len); + len += ie_len; + } + + return (u16)len; +} +EXPORT_SYMBOL(il_fill_probe_req); + +static void il_bg_abort_scan(struct work_struct *work) +{ + struct il_priv *il = container_of(work, struct il_priv, abort_scan); + + D_SCAN("Abort scan work\n"); + + /* We keep scan_check work queued in case when firmware will not + * report back scan completed notification */ + mutex_lock(&il->mutex); + il_scan_cancel_timeout(il, 200); + mutex_unlock(&il->mutex); +} + +static void il_bg_scan_completed(struct work_struct *work) +{ + struct il_priv *il = + container_of(work, struct il_priv, scan_completed); + bool aborted; + + D_SCAN("Completed scan.\n"); + + cancel_delayed_work(&il->scan_check); + + mutex_lock(&il->mutex); + + aborted = test_and_clear_bit(S_SCAN_ABORTING, &il->status); + if (aborted) + D_SCAN("Aborted scan completed.\n"); + + if (!test_and_clear_bit(S_SCANNING, &il->status)) { + D_SCAN("Scan already completed.\n"); + goto out_settings; + } + + il_complete_scan(il, aborted); + +out_settings: + /* Can we still talk to firmware ? */ + if (!il_is_ready_rf(il)) + goto out; + + /* + * We do not commit power settings while scan is pending, + * do it now if the settings changed. + */ + il_power_set_mode(il, &il->power_data.sleep_cmd_next, false); + il_set_tx_power(il, il->tx_power_next, false); + + il->cfg->ops->utils->post_scan(il); + +out: + mutex_unlock(&il->mutex); +} + +void il_setup_scan_deferred_work(struct il_priv *il) +{ + INIT_WORK(&il->scan_completed, il_bg_scan_completed); + INIT_WORK(&il->abort_scan, il_bg_abort_scan); + INIT_DELAYED_WORK(&il->scan_check, il_bg_scan_check); +} +EXPORT_SYMBOL(il_setup_scan_deferred_work); + +void il_cancel_scan_deferred_work(struct il_priv *il) +{ + cancel_work_sync(&il->abort_scan); + cancel_work_sync(&il->scan_completed); + + if (cancel_delayed_work_sync(&il->scan_check)) { + mutex_lock(&il->mutex); + il_force_scan_end(il); + mutex_unlock(&il->mutex); + } +} +EXPORT_SYMBOL(il_cancel_scan_deferred_work); + +/* il->sta_lock must be held */ +static void il_sta_ucode_activate(struct il_priv *il, u8 sta_id) +{ + + if (!(il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) + IL_ERR( + "ACTIVATE a non DRIVER active station id %u addr %pM\n", + sta_id, il->stations[sta_id].sta.sta.addr); + + if (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE) { + D_ASSOC( + "STA id %u addr %pM already present" + " in uCode (according to driver)\n", + sta_id, il->stations[sta_id].sta.sta.addr); + } else { + il->stations[sta_id].used |= IL_STA_UCODE_ACTIVE; + D_ASSOC("Added STA id %u addr %pM to uCode\n", + sta_id, il->stations[sta_id].sta.sta.addr); + } +} + +static int il_process_add_sta_resp(struct il_priv *il, + struct il_addsta_cmd *addsta, + struct il_rx_pkt *pkt, + bool sync) +{ + u8 sta_id = addsta->sta.sta_id; + unsigned long flags; + int ret = -EIO; + + if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { + IL_ERR("Bad return from C_ADD_STA (0x%08X)\n", + pkt->hdr.flags); + return ret; + } + + D_INFO("Processing response for adding station %u\n", + sta_id); + + spin_lock_irqsave(&il->sta_lock, flags); + + switch (pkt->u.add_sta.status) { + case ADD_STA_SUCCESS_MSK: + D_INFO("C_ADD_STA PASSED\n"); + il_sta_ucode_activate(il, sta_id); + ret = 0; + break; + case ADD_STA_NO_ROOM_IN_TBL: + IL_ERR("Adding station %d failed, no room in table.\n", + sta_id); + break; + case ADD_STA_NO_BLOCK_ACK_RESOURCE: + IL_ERR( + "Adding station %d failed, no block ack resource.\n", + sta_id); + break; + case ADD_STA_MODIFY_NON_EXIST_STA: + IL_ERR("Attempting to modify non-existing station %d\n", + sta_id); + break; + default: + D_ASSOC("Received C_ADD_STA:(0x%08X)\n", + pkt->u.add_sta.status); + break; + } + + D_INFO("%s station id %u addr %pM\n", + il->stations[sta_id].sta.mode == + STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", + sta_id, il->stations[sta_id].sta.sta.addr); + + /* + * XXX: The MAC address in the command buffer is often changed from + * the original sent to the device. That is, the MAC address + * written to the command buffer often is not the same MAC address + * read from the command buffer when the command returns. This + * issue has not yet been resolved and this debugging is left to + * observe the problem. + */ + D_INFO("%s station according to cmd buffer %pM\n", + il->stations[sta_id].sta.mode == + STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", + addsta->sta.addr); + spin_unlock_irqrestore(&il->sta_lock, flags); + + return ret; +} + +static void il_add_sta_callback(struct il_priv *il, + struct il_device_cmd *cmd, + struct il_rx_pkt *pkt) +{ + struct il_addsta_cmd *addsta = + (struct il_addsta_cmd *)cmd->cmd.payload; + + il_process_add_sta_resp(il, addsta, pkt, false); + +} + +int il_send_add_sta(struct il_priv *il, + struct il_addsta_cmd *sta, u8 flags) +{ + struct il_rx_pkt *pkt = NULL; + int ret = 0; + u8 data[sizeof(*sta)]; + struct il_host_cmd cmd = { + .id = C_ADD_STA, + .flags = flags, + .data = data, + }; + u8 sta_id __maybe_unused = sta->sta.sta_id; + + D_INFO("Adding sta %u (%pM) %ssynchronously\n", + sta_id, sta->sta.addr, flags & CMD_ASYNC ? "a" : ""); + + if (flags & CMD_ASYNC) + cmd.callback = il_add_sta_callback; + else { + cmd.flags |= CMD_WANT_SKB; + might_sleep(); + } + + cmd.len = il->cfg->ops->utils->build_addsta_hcmd(sta, data); + ret = il_send_cmd(il, &cmd); + + if (ret || (flags & CMD_ASYNC)) + return ret; + + if (ret == 0) { + pkt = (struct il_rx_pkt *)cmd.reply_page; + ret = il_process_add_sta_resp(il, sta, pkt, true); + } + il_free_pages(il, cmd.reply_page); + + return ret; +} +EXPORT_SYMBOL(il_send_add_sta); + +static void il_set_ht_add_station(struct il_priv *il, u8 idx, + struct ieee80211_sta *sta, + struct il_rxon_context *ctx) +{ + struct ieee80211_sta_ht_cap *sta_ht_inf = &sta->ht_cap; + __le32 sta_flags; + u8 mimo_ps_mode; + + if (!sta || !sta_ht_inf->ht_supported) + goto done; + + mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_SM_PS) >> 2; + D_ASSOC("spatial multiplexing power save mode: %s\n", + (mimo_ps_mode == WLAN_HT_CAP_SM_PS_STATIC) ? + "static" : + (mimo_ps_mode == WLAN_HT_CAP_SM_PS_DYNAMIC) ? + "dynamic" : "disabled"); + + sta_flags = il->stations[idx].sta.station_flags; + + sta_flags &= ~(STA_FLG_RTS_MIMO_PROT_MSK | STA_FLG_MIMO_DIS_MSK); + + switch (mimo_ps_mode) { + case WLAN_HT_CAP_SM_PS_STATIC: + sta_flags |= STA_FLG_MIMO_DIS_MSK; + break; + case WLAN_HT_CAP_SM_PS_DYNAMIC: + sta_flags |= STA_FLG_RTS_MIMO_PROT_MSK; + break; + case WLAN_HT_CAP_SM_PS_DISABLED: + break; + default: + IL_WARN("Invalid MIMO PS mode %d\n", mimo_ps_mode); + break; + } + + sta_flags |= cpu_to_le32( + (u32)sta_ht_inf->ampdu_factor << STA_FLG_MAX_AGG_SIZE_POS); + + sta_flags |= cpu_to_le32( + (u32)sta_ht_inf->ampdu_density << STA_FLG_AGG_MPDU_DENSITY_POS); + + if (il_is_ht40_tx_allowed(il, ctx, &sta->ht_cap)) + sta_flags |= STA_FLG_HT40_EN_MSK; + else + sta_flags &= ~STA_FLG_HT40_EN_MSK; + + il->stations[idx].sta.station_flags = sta_flags; + done: + return; +} + +/** + * il_prep_station - Prepare station information for addition + * + * should be called with sta_lock held + */ +u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, + const u8 *addr, bool is_ap, struct ieee80211_sta *sta) +{ + struct il_station_entry *station; + int i; + u8 sta_id = IL_INVALID_STATION; + u16 rate; + + if (is_ap) + sta_id = ctx->ap_sta_id; + else if (is_broadcast_ether_addr(addr)) + sta_id = ctx->bcast_sta_id; + else + for (i = IL_STA_ID; i < il->hw_params.max_stations; i++) { + if (!compare_ether_addr(il->stations[i].sta.sta.addr, + addr)) { + sta_id = i; + break; + } + + if (!il->stations[i].used && + sta_id == IL_INVALID_STATION) + sta_id = i; + } + + /* + * These two conditions have the same outcome, but keep them + * separate + */ + if (unlikely(sta_id == IL_INVALID_STATION)) + return sta_id; + + /* + * uCode is not able to deal with multiple requests to add a + * station. Keep track if one is in progress so that we do not send + * another. + */ + if (il->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { + D_INFO( + "STA %d already in process of being added.\n", + sta_id); + return sta_id; + } + + if ((il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && + (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE) && + !compare_ether_addr(il->stations[sta_id].sta.sta.addr, addr)) { + D_ASSOC( + "STA %d (%pM) already added, not adding again.\n", + sta_id, addr); + return sta_id; + } + + station = &il->stations[sta_id]; + station->used = IL_STA_DRIVER_ACTIVE; + D_ASSOC("Add STA to driver ID %d: %pM\n", + sta_id, addr); + il->num_stations++; + + /* Set up the C_ADD_STA command to send to device */ + memset(&station->sta, 0, sizeof(struct il_addsta_cmd)); + memcpy(station->sta.sta.addr, addr, ETH_ALEN); + station->sta.mode = 0; + station->sta.sta.sta_id = sta_id; + station->sta.station_flags = ctx->station_flags; + station->ctxid = ctx->ctxid; + + if (sta) { + struct il_station_priv_common *sta_priv; + + sta_priv = (void *)sta->drv_priv; + sta_priv->ctx = ctx; + } + + /* + * OK to call unconditionally, since local stations (IBSS BSSID + * STA and broadcast STA) pass in a NULL sta, and mac80211 + * doesn't allow HT IBSS. + */ + il_set_ht_add_station(il, sta_id, sta, ctx); + + /* 3945 only */ + rate = (il->band == IEEE80211_BAND_5GHZ) ? + RATE_6M_PLCP : RATE_1M_PLCP; + /* Turn on both antennas for the station... */ + station->sta.rate_n_flags = cpu_to_le16(rate | RATE_MCS_ANT_AB_MSK); + + return sta_id; + +} +EXPORT_SYMBOL_GPL(il_prep_station); + +#define STA_WAIT_TIMEOUT (HZ/2) + +/** + * il_add_station_common - + */ +int +il_add_station_common(struct il_priv *il, + struct il_rxon_context *ctx, + const u8 *addr, bool is_ap, + struct ieee80211_sta *sta, u8 *sta_id_r) +{ + unsigned long flags_spin; + int ret = 0; + u8 sta_id; + struct il_addsta_cmd sta_cmd; + + *sta_id_r = 0; + spin_lock_irqsave(&il->sta_lock, flags_spin); + sta_id = il_prep_station(il, ctx, addr, is_ap, sta); + if (sta_id == IL_INVALID_STATION) { + IL_ERR("Unable to prepare station %pM for addition\n", + addr); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + return -EINVAL; + } + + /* + * uCode is not able to deal with multiple requests to add a + * station. Keep track if one is in progress so that we do not send + * another. + */ + if (il->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { + D_INFO( + "STA %d already in process of being added.\n", + sta_id); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + return -EEXIST; + } + + if ((il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && + (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { + D_ASSOC( + "STA %d (%pM) already added, not adding again.\n", + sta_id, addr); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + return -EEXIST; + } + + il->stations[sta_id].used |= IL_STA_UCODE_INPROGRESS; + memcpy(&sta_cmd, &il->stations[sta_id].sta, + sizeof(struct il_addsta_cmd)); + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + + /* Add station to device's station table */ + ret = il_send_add_sta(il, &sta_cmd, CMD_SYNC); + if (ret) { + spin_lock_irqsave(&il->sta_lock, flags_spin); + IL_ERR("Adding station %pM failed.\n", + il->stations[sta_id].sta.sta.addr); + il->stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE; + il->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + } + *sta_id_r = sta_id; + return ret; +} +EXPORT_SYMBOL(il_add_station_common); + +/** + * il_sta_ucode_deactivate - deactivate ucode status for a station + * + * il->sta_lock must be held + */ +static void il_sta_ucode_deactivate(struct il_priv *il, u8 sta_id) +{ + /* Ucode must be active and driver must be non active */ + if ((il->stations[sta_id].used & + (IL_STA_UCODE_ACTIVE | IL_STA_DRIVER_ACTIVE)) != + IL_STA_UCODE_ACTIVE) + IL_ERR("removed non active STA %u\n", sta_id); + + il->stations[sta_id].used &= ~IL_STA_UCODE_ACTIVE; + + memset(&il->stations[sta_id], 0, sizeof(struct il_station_entry)); + D_ASSOC("Removed STA %u\n", sta_id); +} + +static int il_send_remove_station(struct il_priv *il, + const u8 *addr, int sta_id, + bool temporary) +{ + struct il_rx_pkt *pkt; + int ret; + + unsigned long flags_spin; + struct il_rem_sta_cmd rm_sta_cmd; + + struct il_host_cmd cmd = { + .id = C_REM_STA, + .len = sizeof(struct il_rem_sta_cmd), + .flags = CMD_SYNC, + .data = &rm_sta_cmd, + }; + + memset(&rm_sta_cmd, 0, sizeof(rm_sta_cmd)); + rm_sta_cmd.num_sta = 1; + memcpy(&rm_sta_cmd.addr, addr, ETH_ALEN); + + cmd.flags |= CMD_WANT_SKB; + + ret = il_send_cmd(il, &cmd); + + if (ret) + return ret; + + pkt = (struct il_rx_pkt *)cmd.reply_page; + if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { + IL_ERR("Bad return from C_REM_STA (0x%08X)\n", + pkt->hdr.flags); + ret = -EIO; + } + + if (!ret) { + switch (pkt->u.rem_sta.status) { + case REM_STA_SUCCESS_MSK: + if (!temporary) { + spin_lock_irqsave(&il->sta_lock, flags_spin); + il_sta_ucode_deactivate(il, sta_id); + spin_unlock_irqrestore(&il->sta_lock, + flags_spin); + } + D_ASSOC("C_REM_STA PASSED\n"); + break; + default: + ret = -EIO; + IL_ERR("C_REM_STA failed\n"); + break; + } + } + il_free_pages(il, cmd.reply_page); + + return ret; +} + +/** + * il_remove_station - Remove driver's knowledge of station. + */ +int il_remove_station(struct il_priv *il, const u8 sta_id, + const u8 *addr) +{ + unsigned long flags; + + if (!il_is_ready(il)) { + D_INFO( + "Unable to remove station %pM, device not ready.\n", + addr); + /* + * It is typical for stations to be removed when we are + * going down. Return success since device will be down + * soon anyway + */ + return 0; + } + + D_ASSOC("Removing STA from driver:%d %pM\n", + sta_id, addr); + + if (WARN_ON(sta_id == IL_INVALID_STATION)) + return -EINVAL; + + spin_lock_irqsave(&il->sta_lock, flags); + + if (!(il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) { + D_INFO("Removing %pM but non DRIVER active\n", + addr); + goto out_err; + } + + if (!(il->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { + D_INFO("Removing %pM but non UCODE active\n", + addr); + goto out_err; + } + + if (il->stations[sta_id].used & IL_STA_LOCAL) { + kfree(il->stations[sta_id].lq); + il->stations[sta_id].lq = NULL; + } + + il->stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE; + + il->num_stations--; + + BUG_ON(il->num_stations < 0); + + spin_unlock_irqrestore(&il->sta_lock, flags); + + return il_send_remove_station(il, addr, sta_id, false); +out_err: + spin_unlock_irqrestore(&il->sta_lock, flags); + return -EINVAL; +} +EXPORT_SYMBOL_GPL(il_remove_station); + +/** + * il_clear_ucode_stations - clear ucode station table bits + * + * This function clears all the bits in the driver indicating + * which stations are active in the ucode. Call when something + * other than explicit station management would cause this in + * the ucode, e.g. unassociated RXON. + */ +void il_clear_ucode_stations(struct il_priv *il, + struct il_rxon_context *ctx) +{ + int i; + unsigned long flags_spin; + bool cleared = false; + + D_INFO("Clearing ucode stations in driver\n"); + + spin_lock_irqsave(&il->sta_lock, flags_spin); + for (i = 0; i < il->hw_params.max_stations; i++) { + if (ctx && ctx->ctxid != il->stations[i].ctxid) + continue; + + if (il->stations[i].used & IL_STA_UCODE_ACTIVE) { + D_INFO( + "Clearing ucode active for station %d\n", i); + il->stations[i].used &= ~IL_STA_UCODE_ACTIVE; + cleared = true; + } + } + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + + if (!cleared) + D_INFO( + "No active stations found to be cleared\n"); +} +EXPORT_SYMBOL(il_clear_ucode_stations); + +/** + * il_restore_stations() - Restore driver known stations to device + * + * All stations considered active by driver, but not present in ucode, is + * restored. + * + * Function sleeps. + */ +void +il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) +{ + struct il_addsta_cmd sta_cmd; + struct il_link_quality_cmd lq; + unsigned long flags_spin; + int i; + bool found = false; + int ret; + bool send_lq; + + if (!il_is_ready(il)) { + D_INFO( + "Not ready yet, not restoring any stations.\n"); + return; + } + + D_ASSOC("Restoring all known stations ... start.\n"); + spin_lock_irqsave(&il->sta_lock, flags_spin); + for (i = 0; i < il->hw_params.max_stations; i++) { + if (ctx->ctxid != il->stations[i].ctxid) + continue; + if ((il->stations[i].used & IL_STA_DRIVER_ACTIVE) && + !(il->stations[i].used & IL_STA_UCODE_ACTIVE)) { + D_ASSOC("Restoring sta %pM\n", + il->stations[i].sta.sta.addr); + il->stations[i].sta.mode = 0; + il->stations[i].used |= IL_STA_UCODE_INPROGRESS; + found = true; + } + } + + for (i = 0; i < il->hw_params.max_stations; i++) { + if ((il->stations[i].used & IL_STA_UCODE_INPROGRESS)) { + memcpy(&sta_cmd, &il->stations[i].sta, + sizeof(struct il_addsta_cmd)); + send_lq = false; + if (il->stations[i].lq) { + memcpy(&lq, il->stations[i].lq, + sizeof(struct il_link_quality_cmd)); + send_lq = true; + } + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + ret = il_send_add_sta(il, &sta_cmd, CMD_SYNC); + if (ret) { + spin_lock_irqsave(&il->sta_lock, flags_spin); + IL_ERR("Adding station %pM failed.\n", + il->stations[i].sta.sta.addr); + il->stations[i].used &= + ~IL_STA_DRIVER_ACTIVE; + il->stations[i].used &= + ~IL_STA_UCODE_INPROGRESS; + spin_unlock_irqrestore(&il->sta_lock, + flags_spin); + } + /* + * Rate scaling has already been initialized, send + * current LQ command + */ + if (send_lq) + il_send_lq_cmd(il, ctx, &lq, + CMD_SYNC, true); + spin_lock_irqsave(&il->sta_lock, flags_spin); + il->stations[i].used &= ~IL_STA_UCODE_INPROGRESS; + } + } + + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + if (!found) + D_INFO("Restoring all known stations" + " .... no stations to be restored.\n"); + else + D_INFO("Restoring all known stations" + " .... complete.\n"); +} +EXPORT_SYMBOL(il_restore_stations); + +int il_get_free_ucode_key_idx(struct il_priv *il) +{ + int i; + + for (i = 0; i < il->sta_key_max_num; i++) + if (!test_and_set_bit(i, &il->ucode_key_table)) + return i; + + return WEP_INVALID_OFFSET; +} +EXPORT_SYMBOL(il_get_free_ucode_key_idx); + +void il_dealloc_bcast_stations(struct il_priv *il) +{ + unsigned long flags; + int i; + + spin_lock_irqsave(&il->sta_lock, flags); + for (i = 0; i < il->hw_params.max_stations; i++) { + if (!(il->stations[i].used & IL_STA_BCAST)) + continue; + + il->stations[i].used &= ~IL_STA_UCODE_ACTIVE; + il->num_stations--; + BUG_ON(il->num_stations < 0); + kfree(il->stations[i].lq); + il->stations[i].lq = NULL; + } + spin_unlock_irqrestore(&il->sta_lock, flags); +} +EXPORT_SYMBOL_GPL(il_dealloc_bcast_stations); + +#ifdef CONFIG_IWLEGACY_DEBUG +static void il_dump_lq_cmd(struct il_priv *il, + struct il_link_quality_cmd *lq) +{ + int i; + D_RATE("lq station id 0x%x\n", lq->sta_id); + D_RATE("lq ant 0x%X 0x%X\n", + lq->general_params.single_stream_ant_msk, + lq->general_params.dual_stream_ant_msk); + + for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) + D_RATE("lq idx %d 0x%X\n", + i, lq->rs_table[i].rate_n_flags); +} +#else +static inline void il_dump_lq_cmd(struct il_priv *il, + struct il_link_quality_cmd *lq) +{ +} +#endif + +/** + * il_is_lq_table_valid() - Test one aspect of LQ cmd for validity + * + * It sometimes happens when a HT rate has been in use and we + * loose connectivity with AP then mac80211 will first tell us that the + * current channel is not HT anymore before removing the station. In such a + * scenario the RXON flags will be updated to indicate we are not + * communicating HT anymore, but the LQ command may still contain HT rates. + * Test for this to prevent driver from sending LQ command between the time + * RXON flags are updated and when LQ command is updated. + */ +static bool il_is_lq_table_valid(struct il_priv *il, + struct il_rxon_context *ctx, + struct il_link_quality_cmd *lq) +{ + int i; + + if (ctx->ht.enabled) + return true; + + D_INFO("Channel %u is not an HT channel\n", + ctx->active.channel); + for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { + if (le32_to_cpu(lq->rs_table[i].rate_n_flags) & + RATE_MCS_HT_MSK) { + D_INFO( + "idx %d of LQ expects HT channel\n", + i); + return false; + } + } + return true; +} + +/** + * il_send_lq_cmd() - Send link quality command + * @init: This command is sent as part of station initialization right + * after station has been added. + * + * The link quality command is sent as the last step of station creation. + * This is the special case in which init is set and we call a callback in + * this case to clear the state indicating that station creation is in + * progress. + */ +int il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, + struct il_link_quality_cmd *lq, u8 flags, bool init) +{ + int ret = 0; + unsigned long flags_spin; + + struct il_host_cmd cmd = { + .id = C_TX_LINK_QUALITY_CMD, + .len = sizeof(struct il_link_quality_cmd), + .flags = flags, + .data = lq, + }; + + if (WARN_ON(lq->sta_id == IL_INVALID_STATION)) + return -EINVAL; + + + spin_lock_irqsave(&il->sta_lock, flags_spin); + if (!(il->stations[lq->sta_id].used & IL_STA_DRIVER_ACTIVE)) { + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + return -EINVAL; + } + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + + il_dump_lq_cmd(il, lq); + BUG_ON(init && (cmd.flags & CMD_ASYNC)); + + if (il_is_lq_table_valid(il, ctx, lq)) + ret = il_send_cmd(il, &cmd); + else + ret = -EINVAL; + + if (cmd.flags & CMD_ASYNC) + return ret; + + if (init) { + D_INFO("init LQ command complete," + " clearing sta addition status for sta %d\n", + lq->sta_id); + spin_lock_irqsave(&il->sta_lock, flags_spin); + il->stations[lq->sta_id].used &= ~IL_STA_UCODE_INPROGRESS; + spin_unlock_irqrestore(&il->sta_lock, flags_spin); + } + return ret; +} +EXPORT_SYMBOL(il_send_lq_cmd); + +int il_mac_sta_remove(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta) +{ + struct il_priv *il = hw->priv; + struct il_station_priv_common *sta_common = (void *)sta->drv_priv; + int ret; + + D_INFO("received request to remove station %pM\n", + sta->addr); + mutex_lock(&il->mutex); + D_INFO("proceeding to remove station %pM\n", + sta->addr); + ret = il_remove_station(il, sta_common->sta_id, sta->addr); + if (ret) + IL_ERR("Error removing station %pM\n", + sta->addr); + mutex_unlock(&il->mutex); + return ret; +} +EXPORT_SYMBOL(il_mac_sta_remove); + +/************************** RX-FUNCTIONS ****************************/ +/* + * Rx theory of operation + * + * Driver allocates a circular buffer of Receive Buffer Descriptors (RBDs), + * each of which point to Receive Buffers to be filled by the NIC. These get + * used not only for Rx frames, but for any command response or notification + * from the NIC. The driver and NIC manage the Rx buffers by means + * of idxes into the circular buffer. + * + * Rx Queue Indexes + * The host/firmware share two idx registers for managing the Rx buffers. + * + * The READ idx maps to the first position that the firmware may be writing + * to -- the driver can read up to (but not including) this position and get + * good data. + * The READ idx is managed by the firmware once the card is enabled. + * + * The WRITE idx maps to the last position the driver has read from -- the + * position preceding WRITE is the last slot the firmware can place a packet. + * + * The queue is empty (no good data) if WRITE = READ - 1, and is full if + * WRITE = READ. + * + * During initialization, the host sets up the READ queue position to the first + * IDX position, and WRITE to the last (READ - 1 wrapped) + * + * When the firmware places a packet in a buffer, it will advance the READ idx + * and fire the RX interrupt. The driver can then query the READ idx and + * process as many packets as possible, moving the WRITE idx forward as it + * resets the Rx queue buffers with new memory. + * + * The management in the driver is as follows: + * + A list of pre-allocated SKBs is stored in iwl->rxq->rx_free. When + * iwl->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled + * to replenish the iwl->rxq->rx_free. + * + In il_rx_replenish (scheduled) if 'processed' != 'read' then the + * iwl->rxq is replenished and the READ IDX is updated (updating the + * 'processed' and 'read' driver idxes as well) + * + A received packet is processed and handed to the kernel network stack, + * detached from the iwl->rxq. The driver 'processed' idx is updated. + * + The Host/Firmware iwl->rxq is replenished at tasklet time from the rx_free + * list. If there are no allocated buffers in iwl->rxq->rx_free, the READ + * IDX is not incremented and iwl->status(RX_STALLED) is set. If there + * were enough free buffers and RX_STALLED is set it is cleared. + * + * + * Driver sequence: + * + * il_rx_queue_alloc() Allocates rx_free + * il_rx_replenish() Replenishes rx_free list from rx_used, and calls + * il_rx_queue_restock + * il_rx_queue_restock() Moves available buffers from rx_free into Rx + * queue, updates firmware pointers, and updates + * the WRITE idx. If insufficient rx_free buffers + * are available, schedules il_rx_replenish + * + * -- enable interrupts -- + * ISR - il_rx() Detach il_rx_bufs from pool up to the + * READ IDX, detaching the SKB from the pool. + * Moves the packet buffer from queue to rx_used. + * Calls il_rx_queue_restock to refill any empty + * slots. + * ... + * + */ + +/** + * il_rx_queue_space - Return number of free slots available in queue. + */ +int il_rx_queue_space(const struct il_rx_queue *q) +{ + int s = q->read - q->write; + if (s <= 0) + s += RX_QUEUE_SIZE; + /* keep some buffer to not confuse full and empty queue */ + s -= 2; + if (s < 0) + s = 0; + return s; +} +EXPORT_SYMBOL(il_rx_queue_space); + +/** + * il_rx_queue_update_write_ptr - Update the write pointer for the RX queue + */ +void +il_rx_queue_update_write_ptr(struct il_priv *il, + struct il_rx_queue *q) +{ + unsigned long flags; + u32 rx_wrt_ptr_reg = il->hw_params.rx_wrt_ptr_reg; + u32 reg; + + spin_lock_irqsave(&q->lock, flags); + + if (q->need_update == 0) + goto exit_unlock; + + /* If power-saving is in use, make sure device is awake */ + if (test_bit(S_POWER_PMI, &il->status)) { + reg = _il_rd(il, CSR_UCODE_DRV_GP1); + + if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { + D_INFO( + "Rx queue requesting wakeup," + " GP1 = 0x%x\n", reg); + il_set_bit(il, CSR_GP_CNTRL, + CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); + goto exit_unlock; + } + + q->write_actual = (q->write & ~0x7); + il_wr(il, rx_wrt_ptr_reg, + q->write_actual); + + /* Else device is assumed to be awake */ + } else { + /* Device expects a multiple of 8 */ + q->write_actual = (q->write & ~0x7); + il_wr(il, rx_wrt_ptr_reg, + q->write_actual); + } + + q->need_update = 0; + + exit_unlock: + spin_unlock_irqrestore(&q->lock, flags); +} +EXPORT_SYMBOL(il_rx_queue_update_write_ptr); + +int il_rx_queue_alloc(struct il_priv *il) +{ + struct il_rx_queue *rxq = &il->rxq; + struct device *dev = &il->pci_dev->dev; + int i; + + spin_lock_init(&rxq->lock); + INIT_LIST_HEAD(&rxq->rx_free); + INIT_LIST_HEAD(&rxq->rx_used); + + /* Alloc the circular buffer of Read Buffer Descriptors (RBDs) */ + rxq->bd = dma_alloc_coherent(dev, 4 * RX_QUEUE_SIZE, &rxq->bd_dma, + GFP_KERNEL); + if (!rxq->bd) + goto err_bd; + + rxq->rb_stts = dma_alloc_coherent(dev, sizeof(struct il_rb_status), + &rxq->rb_stts_dma, GFP_KERNEL); + if (!rxq->rb_stts) + goto err_rb; + + /* Fill the rx_used queue with _all_ of the Rx buffers */ + for (i = 0; i < RX_FREE_BUFFERS + RX_QUEUE_SIZE; i++) + list_add_tail(&rxq->pool[i].list, &rxq->rx_used); + + /* Set us so that we have processed and used all buffers, but have + * not restocked the Rx queue with fresh buffers */ + rxq->read = rxq->write = 0; + rxq->write_actual = 0; + rxq->free_count = 0; + rxq->need_update = 0; + return 0; + +err_rb: + dma_free_coherent(&il->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, + rxq->bd_dma); +err_bd: + return -ENOMEM; +} +EXPORT_SYMBOL(il_rx_queue_alloc); + + +void il_hdl_spectrum_measurement(struct il_priv *il, + struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + struct il_spectrum_notification *report = &(pkt->u.spectrum_notif); + + if (!report->state) { + D_11H( + "Spectrum Measure Notification: Start\n"); + return; + } + + memcpy(&il->measure_report, report, sizeof(*report)); + il->measurement_status |= MEASUREMENT_READY; +} +EXPORT_SYMBOL(il_hdl_spectrum_measurement); + +/* + * returns non-zero if packet should be dropped + */ +int il_set_decrypted_flag(struct il_priv *il, + struct ieee80211_hdr *hdr, + u32 decrypt_res, + struct ieee80211_rx_status *stats) +{ + u16 fc = le16_to_cpu(hdr->frame_control); + + /* + * All contexts have the same setting here due to it being + * a module parameter, so OK to check any context. + */ + if (il->ctx.active.filter_flags & + RXON_FILTER_DIS_DECRYPT_MSK) + return 0; + + if (!(fc & IEEE80211_FCTL_PROTECTED)) + return 0; + + D_RX("decrypt_res:0x%x\n", decrypt_res); + switch (decrypt_res & RX_RES_STATUS_SEC_TYPE_MSK) { + case RX_RES_STATUS_SEC_TYPE_TKIP: + /* The uCode has got a bad phase 1 Key, pushes the packet. + * Decryption will be done in SW. */ + if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) == + RX_RES_STATUS_BAD_KEY_TTAK) + break; + + case RX_RES_STATUS_SEC_TYPE_WEP: + if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) == + RX_RES_STATUS_BAD_ICV_MIC) { + /* bad ICV, the packet is destroyed since the + * decryption is inplace, drop it */ + D_RX("Packet destroyed\n"); + return -1; + } + case RX_RES_STATUS_SEC_TYPE_CCMP: + if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) == + RX_RES_STATUS_DECRYPT_OK) { + D_RX("hw decrypt successfully!!!\n"); + stats->flag |= RX_FLAG_DECRYPTED; + } + break; + + default: + break; + } + return 0; +} +EXPORT_SYMBOL(il_set_decrypted_flag); + +/** + * il_txq_update_write_ptr - Send new write idx to hardware + */ +void +il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq) +{ + u32 reg = 0; + int txq_id = txq->q.id; + + if (txq->need_update == 0) + return; + + /* if we're trying to save power */ + if (test_bit(S_POWER_PMI, &il->status)) { + /* wake up nic if it's powered down ... + * uCode will wake up, and interrupt us again, so next + * time we'll skip this part. */ + reg = _il_rd(il, CSR_UCODE_DRV_GP1); + + if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { + D_INFO( + "Tx queue %d requesting wakeup," + " GP1 = 0x%x\n", txq_id, reg); + il_set_bit(il, CSR_GP_CNTRL, + CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); + return; + } + + il_wr(il, HBUS_TARG_WRPTR, + txq->q.write_ptr | (txq_id << 8)); + + /* + * else not in power-save mode, + * uCode will never sleep when we're + * trying to tx (during RFKILL, we're not trying to tx). + */ + } else + _il_wr(il, HBUS_TARG_WRPTR, + txq->q.write_ptr | (txq_id << 8)); + txq->need_update = 0; +} +EXPORT_SYMBOL(il_txq_update_write_ptr); + +/** + * il_tx_queue_unmap - Unmap any remaining DMA mappings and free skb's + */ +void il_tx_queue_unmap(struct il_priv *il, int txq_id) +{ + struct il_tx_queue *txq = &il->txq[txq_id]; + struct il_queue *q = &txq->q; + + if (q->n_bd == 0) + return; + + while (q->write_ptr != q->read_ptr) { + il->cfg->ops->lib->txq_free_tfd(il, txq); + q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); + } +} +EXPORT_SYMBOL(il_tx_queue_unmap); + +/** + * il_tx_queue_free - Deallocate DMA queue. + * @txq: Transmit queue to deallocate. + * + * Empty queue by removing and destroying all BD's. + * Free all buffers. + * 0-fill, but do not free "txq" descriptor structure. + */ +void il_tx_queue_free(struct il_priv *il, int txq_id) +{ + struct il_tx_queue *txq = &il->txq[txq_id]; + struct device *dev = &il->pci_dev->dev; + int i; + + il_tx_queue_unmap(il, txq_id); + + /* De-alloc array of command/tx buffers */ + for (i = 0; i < TFD_TX_CMD_SLOTS; i++) + kfree(txq->cmd[i]); + + /* De-alloc circular buffer of TFDs */ + if (txq->q.n_bd) + dma_free_coherent(dev, il->hw_params.tfd_size * + txq->q.n_bd, txq->tfds, txq->q.dma_addr); + + /* De-alloc array of per-TFD driver data */ + kfree(txq->txb); + txq->txb = NULL; + + /* deallocate arrays */ + kfree(txq->cmd); + kfree(txq->meta); + txq->cmd = NULL; + txq->meta = NULL; + + /* 0-fill queue descriptor structure */ + memset(txq, 0, sizeof(*txq)); +} +EXPORT_SYMBOL(il_tx_queue_free); + +/** + * il_cmd_queue_unmap - Unmap any remaining DMA mappings from command queue + */ +void il_cmd_queue_unmap(struct il_priv *il) +{ + struct il_tx_queue *txq = &il->txq[il->cmd_queue]; + struct il_queue *q = &txq->q; + int i; + + if (q->n_bd == 0) + return; + + while (q->read_ptr != q->write_ptr) { + i = il_get_cmd_idx(q, q->read_ptr, 0); + + if (txq->meta[i].flags & CMD_MAPPED) { + pci_unmap_single(il->pci_dev, + dma_unmap_addr(&txq->meta[i], mapping), + dma_unmap_len(&txq->meta[i], len), + PCI_DMA_BIDIRECTIONAL); + txq->meta[i].flags = 0; + } + + q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); + } + + i = q->n_win; + if (txq->meta[i].flags & CMD_MAPPED) { + pci_unmap_single(il->pci_dev, + dma_unmap_addr(&txq->meta[i], mapping), + dma_unmap_len(&txq->meta[i], len), + PCI_DMA_BIDIRECTIONAL); + txq->meta[i].flags = 0; + } +} +EXPORT_SYMBOL(il_cmd_queue_unmap); + +/** + * il_cmd_queue_free - Deallocate DMA queue. + * @txq: Transmit queue to deallocate. + * + * Empty queue by removing and destroying all BD's. + * Free all buffers. + * 0-fill, but do not free "txq" descriptor structure. + */ +void il_cmd_queue_free(struct il_priv *il) +{ + struct il_tx_queue *txq = &il->txq[il->cmd_queue]; + struct device *dev = &il->pci_dev->dev; + int i; + + il_cmd_queue_unmap(il); + + /* De-alloc array of command/tx buffers */ + for (i = 0; i <= TFD_CMD_SLOTS; i++) + kfree(txq->cmd[i]); + + /* De-alloc circular buffer of TFDs */ + if (txq->q.n_bd) + dma_free_coherent(dev, il->hw_params.tfd_size * txq->q.n_bd, + txq->tfds, txq->q.dma_addr); + + /* deallocate arrays */ + kfree(txq->cmd); + kfree(txq->meta); + txq->cmd = NULL; + txq->meta = NULL; + + /* 0-fill queue descriptor structure */ + memset(txq, 0, sizeof(*txq)); +} +EXPORT_SYMBOL(il_cmd_queue_free); + +/*************** DMA-QUEUE-GENERAL-FUNCTIONS ***** + * DMA services + * + * Theory of operation + * + * A Tx or Rx queue resides in host DRAM, and is comprised of a circular buffer + * of buffer descriptors, each of which points to one or more data buffers for + * the device to read from or fill. Driver and device exchange status of each + * queue via "read" and "write" pointers. Driver keeps minimum of 2 empty + * entries in each circular buffer, to protect against confusing empty and full + * queue states. + * + * The device reads or writes the data in the queues via the device's several + * DMA/FIFO channels. Each queue is mapped to a single DMA channel. + * + * For Tx queue, there are low mark and high mark limits. If, after queuing + * the packet for Tx, free space become < low mark, Tx queue stopped. When + * reclaiming packets (on 'tx done IRQ), if free space become > high mark, + * Tx queue resumed. + * + * See more detailed info in 4965.h. + ***************************************************/ + +int il_queue_space(const struct il_queue *q) +{ + int s = q->read_ptr - q->write_ptr; + + if (q->read_ptr > q->write_ptr) + s -= q->n_bd; + + if (s <= 0) + s += q->n_win; + /* keep some reserve to not confuse empty and full situations */ + s -= 2; + if (s < 0) + s = 0; + return s; +} +EXPORT_SYMBOL(il_queue_space); + + +/** + * il_queue_init - Initialize queue's high/low-water and read/write idxes + */ +static int il_queue_init(struct il_priv *il, struct il_queue *q, + int count, int slots_num, u32 id) +{ + q->n_bd = count; + q->n_win = slots_num; + q->id = id; + + /* count must be power-of-two size, otherwise il_queue_inc_wrap + * and il_queue_dec_wrap are broken. */ + BUG_ON(!is_power_of_2(count)); + + /* slots_num must be power-of-two size, otherwise + * il_get_cmd_idx is broken. */ + BUG_ON(!is_power_of_2(slots_num)); + + q->low_mark = q->n_win / 4; + if (q->low_mark < 4) + q->low_mark = 4; + + q->high_mark = q->n_win / 8; + if (q->high_mark < 2) + q->high_mark = 2; + + q->write_ptr = q->read_ptr = 0; + + return 0; +} + +/** + * il_tx_queue_alloc - Alloc driver data and TFD CB for one Tx/cmd queue + */ +static int il_tx_queue_alloc(struct il_priv *il, + struct il_tx_queue *txq, u32 id) +{ + struct device *dev = &il->pci_dev->dev; + size_t tfd_sz = il->hw_params.tfd_size * TFD_QUEUE_SIZE_MAX; + + /* Driver ilate data, only for Tx (not command) queues, + * not shared with device. */ + if (id != il->cmd_queue) { + txq->txb = kzalloc(sizeof(txq->txb[0]) * + TFD_QUEUE_SIZE_MAX, GFP_KERNEL); + if (!txq->txb) { + IL_ERR("kmalloc for auxiliary BD " + "structures failed\n"); + goto error; + } + } else { + txq->txb = NULL; + } + + /* Circular buffer of transmit frame descriptors (TFDs), + * shared with device */ + txq->tfds = dma_alloc_coherent(dev, tfd_sz, &txq->q.dma_addr, + GFP_KERNEL); + if (!txq->tfds) { + IL_ERR("pci_alloc_consistent(%zd) failed\n", tfd_sz); + goto error; + } + txq->q.id = id; + + return 0; + + error: + kfree(txq->txb); + txq->txb = NULL; + + return -ENOMEM; +} + +/** + * il_tx_queue_init - Allocate and initialize one tx/cmd queue + */ +int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, + int slots_num, u32 txq_id) +{ + int i, len; + int ret; + int actual_slots = slots_num; + + /* + * Alloc buffer array for commands (Tx or other types of commands). + * For the command queue (#4/#9), allocate command space + one big + * command for scan, since scan command is very huge; the system will + * not have two scans at the same time, so only one is needed. + * For normal Tx queues (all other queues), no super-size command + * space is needed. + */ + if (txq_id == il->cmd_queue) + actual_slots++; + + txq->meta = kzalloc(sizeof(struct il_cmd_meta) * actual_slots, + GFP_KERNEL); + txq->cmd = kzalloc(sizeof(struct il_device_cmd *) * actual_slots, + GFP_KERNEL); + + if (!txq->meta || !txq->cmd) + goto out_free_arrays; + + len = sizeof(struct il_device_cmd); + for (i = 0; i < actual_slots; i++) { + /* only happens for cmd queue */ + if (i == slots_num) + len = IL_MAX_CMD_SIZE; + + txq->cmd[i] = kmalloc(len, GFP_KERNEL); + if (!txq->cmd[i]) + goto err; + } + + /* Alloc driver data array and TFD circular buffer */ + ret = il_tx_queue_alloc(il, txq, txq_id); + if (ret) + goto err; + + txq->need_update = 0; + + /* + * For the default queues 0-3, set up the swq_id + * already -- all others need to get one later + * (if they need one at all). + */ + if (txq_id < 4) + il_set_swq_id(txq, txq_id, txq_id); + + /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise + * il_queue_inc_wrap and il_queue_dec_wrap are broken. */ + BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); + + /* Initialize queue's high/low-water marks, and head/tail idxes */ + il_queue_init(il, &txq->q, + TFD_QUEUE_SIZE_MAX, slots_num, txq_id); + + /* Tell device where to find queue */ + il->cfg->ops->lib->txq_init(il, txq); + + return 0; +err: + for (i = 0; i < actual_slots; i++) + kfree(txq->cmd[i]); +out_free_arrays: + kfree(txq->meta); + kfree(txq->cmd); + + return -ENOMEM; +} +EXPORT_SYMBOL(il_tx_queue_init); + +void il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, + int slots_num, u32 txq_id) +{ + int actual_slots = slots_num; + + if (txq_id == il->cmd_queue) + actual_slots++; + + memset(txq->meta, 0, sizeof(struct il_cmd_meta) * actual_slots); + + txq->need_update = 0; + + /* Initialize queue's high/low-water marks, and head/tail idxes */ + il_queue_init(il, &txq->q, + TFD_QUEUE_SIZE_MAX, slots_num, txq_id); + + /* Tell device where to find queue */ + il->cfg->ops->lib->txq_init(il, txq); +} +EXPORT_SYMBOL(il_tx_queue_reset); + +/*************** HOST COMMAND QUEUE FUNCTIONS *****/ + +/** + * il_enqueue_hcmd - enqueue a uCode command + * @il: device ilate data point + * @cmd: a point to the ucode command structure + * + * The function returns < 0 values to indicate the operation is + * failed. On success, it turns the idx (> 0) of command in the + * command queue. + */ +int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) +{ + struct il_tx_queue *txq = &il->txq[il->cmd_queue]; + struct il_queue *q = &txq->q; + struct il_device_cmd *out_cmd; + struct il_cmd_meta *out_meta; + dma_addr_t phys_addr; + unsigned long flags; + int len; + u32 idx; + u16 fix_size; + + cmd->len = il->cfg->ops->utils->get_hcmd_size(cmd->id, cmd->len); + fix_size = (u16)(cmd->len + sizeof(out_cmd->hdr)); + + /* If any of the command structures end up being larger than + * the TFD_MAX_PAYLOAD_SIZE, and it sent as a 'small' command then + * we will need to increase the size of the TFD entries + * Also, check to see if command buffer should not exceed the size + * of device_cmd and max_cmd_size. */ + BUG_ON((fix_size > TFD_MAX_PAYLOAD_SIZE) && + !(cmd->flags & CMD_SIZE_HUGE)); + BUG_ON(fix_size > IL_MAX_CMD_SIZE); + + if (il_is_rfkill(il) || il_is_ctkill(il)) { + IL_WARN("Not sending command - %s KILL\n", + il_is_rfkill(il) ? "RF" : "CT"); + return -EIO; + } + + spin_lock_irqsave(&il->hcmd_lock, flags); + + if (il_queue_space(q) < ((cmd->flags & CMD_ASYNC) ? 2 : 1)) { + spin_unlock_irqrestore(&il->hcmd_lock, flags); + + IL_ERR("Restarting adapter due to command queue full\n"); + queue_work(il->workqueue, &il->restart); + return -ENOSPC; + } + + idx = il_get_cmd_idx(q, q->write_ptr, cmd->flags & CMD_SIZE_HUGE); + out_cmd = txq->cmd[idx]; + out_meta = &txq->meta[idx]; + + if (WARN_ON(out_meta->flags & CMD_MAPPED)) { + spin_unlock_irqrestore(&il->hcmd_lock, flags); + return -ENOSPC; + } + + memset(out_meta, 0, sizeof(*out_meta)); /* re-initialize to NULL */ + out_meta->flags = cmd->flags | CMD_MAPPED; + if (cmd->flags & CMD_WANT_SKB) + out_meta->source = cmd; + if (cmd->flags & CMD_ASYNC) + out_meta->callback = cmd->callback; + + out_cmd->hdr.cmd = cmd->id; + memcpy(&out_cmd->cmd.payload, cmd->data, cmd->len); + + /* At this point, the out_cmd now has all of the incoming cmd + * information */ + + out_cmd->hdr.flags = 0; + out_cmd->hdr.sequence = cpu_to_le16(QUEUE_TO_SEQ(il->cmd_queue) | + IDX_TO_SEQ(q->write_ptr)); + if (cmd->flags & CMD_SIZE_HUGE) + out_cmd->hdr.sequence |= SEQ_HUGE_FRAME; + len = sizeof(struct il_device_cmd); + if (idx == TFD_CMD_SLOTS) + len = IL_MAX_CMD_SIZE; + +#ifdef CONFIG_IWLEGACY_DEBUG + switch (out_cmd->hdr.cmd) { + case C_TX_LINK_QUALITY_CMD: + case C_SENSITIVITY: + D_HC_DUMP( + "Sending command %s (#%x), seq: 0x%04X, " + "%d bytes at %d[%d]:%d\n", + il_get_cmd_string(out_cmd->hdr.cmd), + out_cmd->hdr.cmd, + le16_to_cpu(out_cmd->hdr.sequence), fix_size, + q->write_ptr, idx, il->cmd_queue); + break; + default: + D_HC("Sending command %s (#%x), seq: 0x%04X, " + "%d bytes at %d[%d]:%d\n", + il_get_cmd_string(out_cmd->hdr.cmd), + out_cmd->hdr.cmd, + le16_to_cpu(out_cmd->hdr.sequence), fix_size, + q->write_ptr, idx, il->cmd_queue); + } +#endif + txq->need_update = 1; + + if (il->cfg->ops->lib->txq_update_byte_cnt_tbl) + /* Set up entry in queue's byte count circular buffer */ + il->cfg->ops->lib->txq_update_byte_cnt_tbl(il, txq, 0); + + phys_addr = pci_map_single(il->pci_dev, &out_cmd->hdr, + fix_size, PCI_DMA_BIDIRECTIONAL); + dma_unmap_addr_set(out_meta, mapping, phys_addr); + dma_unmap_len_set(out_meta, len, fix_size); + + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, + phys_addr, fix_size, 1, + U32_PAD(cmd->len)); + + /* Increment and update queue's write idx */ + q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); + il_txq_update_write_ptr(il, txq); + + spin_unlock_irqrestore(&il->hcmd_lock, flags); + return idx; +} + +/** + * il_hcmd_queue_reclaim - Reclaim TX command queue entries already Tx'd + * + * When FW advances 'R' idx, all entries between old and new 'R' idx + * need to be reclaimed. As result, some free space forms. If there is + * enough free space (> low mark), wake the stack that feeds us. + */ +static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, + int idx, int cmd_idx) +{ + struct il_tx_queue *txq = &il->txq[txq_id]; + struct il_queue *q = &txq->q; + int nfreed = 0; + + if (idx >= q->n_bd || il_queue_used(q, idx) == 0) { + IL_ERR("Read idx for DMA queue txq id (%d), idx %d, " + "is out of range [0-%d] %d %d.\n", txq_id, + idx, q->n_bd, q->write_ptr, q->read_ptr); + return; + } + + for (idx = il_queue_inc_wrap(idx, q->n_bd); q->read_ptr != idx; + q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { + + if (nfreed++ > 0) { + IL_ERR("HCMD skipped: idx (%d) %d %d\n", idx, + q->write_ptr, q->read_ptr); + queue_work(il->workqueue, &il->restart); + } + + } +} + +/** + * il_tx_cmd_complete - Pull unused buffers off the queue and reclaim them + * @rxb: Rx buffer to reclaim + * + * If an Rx buffer has an async callback associated with it the callback + * will be executed. The attached skb (if present) will only be freed + * if the callback returns 1 + */ +void +il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb) +{ + struct il_rx_pkt *pkt = rxb_addr(rxb); + u16 sequence = le16_to_cpu(pkt->hdr.sequence); + int txq_id = SEQ_TO_QUEUE(sequence); + int idx = SEQ_TO_IDX(sequence); + int cmd_idx; + bool huge = !!(pkt->hdr.sequence & SEQ_HUGE_FRAME); + struct il_device_cmd *cmd; + struct il_cmd_meta *meta; + struct il_tx_queue *txq = &il->txq[il->cmd_queue]; + unsigned long flags; + + /* If a Tx command is being handled and it isn't in the actual + * command queue then there a command routing bug has been introduced + * in the queue management code. */ + if (WARN(txq_id != il->cmd_queue, + "wrong command queue %d (should be %d), sequence 0x%X readp=%d writep=%d\n", + txq_id, il->cmd_queue, sequence, + il->txq[il->cmd_queue].q.read_ptr, + il->txq[il->cmd_queue].q.write_ptr)) { + il_print_hex_error(il, pkt, 32); + return; + } + + cmd_idx = il_get_cmd_idx(&txq->q, idx, huge); + cmd = txq->cmd[cmd_idx]; + meta = &txq->meta[cmd_idx]; + + txq->time_stamp = jiffies; + + pci_unmap_single(il->pci_dev, + dma_unmap_addr(meta, mapping), + dma_unmap_len(meta, len), + PCI_DMA_BIDIRECTIONAL); + + /* Input error checking is done when commands are added to queue. */ + if (meta->flags & CMD_WANT_SKB) { + meta->source->reply_page = (unsigned long)rxb_addr(rxb); + rxb->page = NULL; + } else if (meta->callback) + meta->callback(il, cmd, pkt); + + spin_lock_irqsave(&il->hcmd_lock, flags); + + il_hcmd_queue_reclaim(il, txq_id, idx, cmd_idx); + + if (!(meta->flags & CMD_ASYNC)) { + clear_bit(S_HCMD_ACTIVE, &il->status); + D_INFO("Clearing HCMD_ACTIVE for command %s\n", + il_get_cmd_string(cmd->hdr.cmd)); + wake_up(&il->wait_command_queue); + } + + /* Mark as unmapped */ + meta->flags = 0; + + spin_unlock_irqrestore(&il->hcmd_lock, flags); +} +EXPORT_SYMBOL(il_tx_cmd_complete); MODULE_DESCRIPTION("iwl-legacy: common functions for 3945 and 4965"); MODULE_VERSION(IWLWIFI_VERSION); diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.c b/drivers/net/wireless/iwlegacy/iwl-eeprom.c deleted file mode 100644 index ee5ad69a534b..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.c +++ /dev/null @@ -1,553 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - - -#include -#include -#include -#include - -#include - -#include "iwl-commands.h" -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-debug.h" -#include "iwl-eeprom.h" -#include "iwl-io.h" - -/************************** EEPROM BANDS **************************** - * - * The il_eeprom_band definitions below provide the mapping from the - * EEPROM contents to the specific channel number supported for each - * band. - * - * For example, il_priv->eeprom.band_3_channels[4] from the band_3 - * definition below maps to physical channel 42 in the 5.2GHz spectrum. - * The specific geography and calibration information for that channel - * is contained in the eeprom map itself. - * - * During init, we copy the eeprom information and channel map - * information into il->channel_info_24/52 and il->channel_map_24/52 - * - * channel_map_24/52 provides the idx in the channel_info array for a - * given channel. We have to have two separate maps as there is channel - * overlap with the 2.4GHz and 5.2GHz spectrum as seen in band_1 and - * band_2 - * - * A value of 0xff stored in the channel_map indicates that the channel - * is not supported by the hardware at all. - * - * A value of 0xfe in the channel_map indicates that the channel is not - * valid for Tx with the current hardware. This means that - * while the system can tune and receive on a given channel, it may not - * be able to associate or transmit any frames on that - * channel. There is no corresponding channel information for that - * entry. - * - *********************************************************************/ - -/* 2.4 GHz */ -const u8 il_eeprom_band_1[14] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 -}; - -/* 5.2 GHz bands */ -static const u8 il_eeprom_band_2[] = { /* 4915-5080MHz */ - 183, 184, 185, 187, 188, 189, 192, 196, 7, 8, 11, 12, 16 -}; - -static const u8 il_eeprom_band_3[] = { /* 5170-5320MHz */ - 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 -}; - -static const u8 il_eeprom_band_4[] = { /* 5500-5700MHz */ - 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 -}; - -static const u8 il_eeprom_band_5[] = { /* 5725-5825MHz */ - 145, 149, 153, 157, 161, 165 -}; - -static const u8 il_eeprom_band_6[] = { /* 2.4 ht40 channel */ - 1, 2, 3, 4, 5, 6, 7 -}; - -static const u8 il_eeprom_band_7[] = { /* 5.2 ht40 channel */ - 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157 -}; - -/****************************************************************************** - * - * EEPROM related functions - * -******************************************************************************/ - -static int il_eeprom_verify_signature(struct il_priv *il) -{ - u32 gp = _il_rd(il, CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; - int ret = 0; - - D_EEPROM("EEPROM signature=0x%08x\n", gp); - switch (gp) { - case CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K: - case CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K: - break; - default: - IL_ERR("bad EEPROM signature," - "EEPROM_GP=0x%08x\n", gp); - ret = -ENOENT; - break; - } - return ret; -} - -const u8 -*il_eeprom_query_addr(const struct il_priv *il, size_t offset) -{ - BUG_ON(offset >= il->cfg->base_params->eeprom_size); - return &il->eeprom[offset]; -} -EXPORT_SYMBOL(il_eeprom_query_addr); - -u16 il_eeprom_query16(const struct il_priv *il, size_t offset) -{ - if (!il->eeprom) - return 0; - return (u16)il->eeprom[offset] | ((u16)il->eeprom[offset + 1] << 8); -} -EXPORT_SYMBOL(il_eeprom_query16); - -/** - * il_eeprom_init - read EEPROM contents - * - * Load the EEPROM contents from adapter into il->eeprom - * - * NOTE: This routine uses the non-debug IO access functions. - */ -int il_eeprom_init(struct il_priv *il) -{ - __le16 *e; - u32 gp = _il_rd(il, CSR_EEPROM_GP); - int sz; - int ret; - u16 addr; - - /* allocate eeprom */ - sz = il->cfg->base_params->eeprom_size; - D_EEPROM("NVM size = %d\n", sz); - il->eeprom = kzalloc(sz, GFP_KERNEL); - if (!il->eeprom) { - ret = -ENOMEM; - goto alloc_err; - } - e = (__le16 *)il->eeprom; - - il->cfg->ops->lib->apm_ops.init(il); - - ret = il_eeprom_verify_signature(il); - if (ret < 0) { - IL_ERR("EEPROM not found, EEPROM_GP=0x%08x\n", gp); - ret = -ENOENT; - goto err; - } - - /* Make sure driver (instead of uCode) is allowed to read EEPROM */ - ret = il->cfg->ops->lib->eeprom_ops.acquire_semaphore(il); - if (ret < 0) { - IL_ERR("Failed to acquire EEPROM semaphore.\n"); - ret = -ENOENT; - goto err; - } - - /* eeprom is an array of 16bit values */ - for (addr = 0; addr < sz; addr += sizeof(u16)) { - u32 r; - - _il_wr(il, CSR_EEPROM_REG, - CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); - - ret = _il_poll_bit(il, CSR_EEPROM_REG, - CSR_EEPROM_REG_READ_VALID_MSK, - CSR_EEPROM_REG_READ_VALID_MSK, - IL_EEPROM_ACCESS_TIMEOUT); - if (ret < 0) { - IL_ERR("Time out reading EEPROM[%d]\n", - addr); - goto done; - } - r = _il_rd(il, CSR_EEPROM_REG); - e[addr / 2] = cpu_to_le16(r >> 16); - } - - D_EEPROM("NVM Type: %s, version: 0x%x\n", - "EEPROM", - il_eeprom_query16(il, EEPROM_VERSION)); - - ret = 0; -done: - il->cfg->ops->lib->eeprom_ops.release_semaphore(il); - -err: - if (ret) - il_eeprom_free(il); - /* Reset chip to save power until we load uCode during "up". */ - il_apm_stop(il); -alloc_err: - return ret; -} -EXPORT_SYMBOL(il_eeprom_init); - -void il_eeprom_free(struct il_priv *il) -{ - kfree(il->eeprom); - il->eeprom = NULL; -} -EXPORT_SYMBOL(il_eeprom_free); - -static void il_init_band_reference(const struct il_priv *il, - int eep_band, int *eeprom_ch_count, - const struct il_eeprom_channel **eeprom_ch_info, - const u8 **eeprom_ch_idx) -{ - u32 offset = il->cfg->ops->lib-> - eeprom_ops.regulatory_bands[eep_band - 1]; - switch (eep_band) { - case 1: /* 2.4GHz band */ - *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_1); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); - *eeprom_ch_idx = il_eeprom_band_1; - break; - case 2: /* 4.9GHz band */ - *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_2); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); - *eeprom_ch_idx = il_eeprom_band_2; - break; - case 3: /* 5.2GHz band */ - *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_3); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); - *eeprom_ch_idx = il_eeprom_band_3; - break; - case 4: /* 5.5GHz band */ - *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_4); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); - *eeprom_ch_idx = il_eeprom_band_4; - break; - case 5: /* 5.7GHz band */ - *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_5); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); - *eeprom_ch_idx = il_eeprom_band_5; - break; - case 6: /* 2.4GHz ht40 channels */ - *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_6); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); - *eeprom_ch_idx = il_eeprom_band_6; - break; - case 7: /* 5 GHz ht40 channels */ - *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_7); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); - *eeprom_ch_idx = il_eeprom_band_7; - break; - default: - BUG(); - } -} - -#define CHECK_AND_PRINT(x) ((eeprom_ch->flags & EEPROM_CHANNEL_##x) \ - ? # x " " : "") -/** - * il_mod_ht40_chan_info - Copy ht40 channel info into driver's il. - * - * Does not set up a command, or touch hardware. - */ -static int il_mod_ht40_chan_info(struct il_priv *il, - enum ieee80211_band band, u16 channel, - const struct il_eeprom_channel *eeprom_ch, - u8 clear_ht40_extension_channel) -{ - struct il_channel_info *ch_info; - - ch_info = (struct il_channel_info *) - il_get_channel_info(il, band, channel); - - if (!il_is_channel_valid(ch_info)) - return -1; - - D_EEPROM("HT40 Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):" - " Ad-Hoc %ssupported\n", - ch_info->channel, - il_is_channel_a_band(ch_info) ? - "5.2" : "2.4", - CHECK_AND_PRINT(IBSS), - CHECK_AND_PRINT(ACTIVE), - CHECK_AND_PRINT(RADAR), - CHECK_AND_PRINT(WIDE), - CHECK_AND_PRINT(DFS), - eeprom_ch->flags, - eeprom_ch->max_power_avg, - ((eeprom_ch->flags & EEPROM_CHANNEL_IBSS) - && !(eeprom_ch->flags & EEPROM_CHANNEL_RADAR)) ? - "" : "not "); - - ch_info->ht40_eeprom = *eeprom_ch; - ch_info->ht40_max_power_avg = eeprom_ch->max_power_avg; - ch_info->ht40_flags = eeprom_ch->flags; - if (eeprom_ch->flags & EEPROM_CHANNEL_VALID) - ch_info->ht40_extension_channel &= - ~clear_ht40_extension_channel; - - return 0; -} - -#define CHECK_AND_PRINT_I(x) ((eeprom_ch_info[ch].flags & EEPROM_CHANNEL_##x) \ - ? # x " " : "") - -/** - * il_init_channel_map - Set up driver's info for all possible channels - */ -int il_init_channel_map(struct il_priv *il) -{ - int eeprom_ch_count = 0; - const u8 *eeprom_ch_idx = NULL; - const struct il_eeprom_channel *eeprom_ch_info = NULL; - int band, ch; - struct il_channel_info *ch_info; - - if (il->channel_count) { - D_EEPROM("Channel map already initialized.\n"); - return 0; - } - - D_EEPROM("Initializing regulatory info from EEPROM\n"); - - il->channel_count = - ARRAY_SIZE(il_eeprom_band_1) + - ARRAY_SIZE(il_eeprom_band_2) + - ARRAY_SIZE(il_eeprom_band_3) + - ARRAY_SIZE(il_eeprom_band_4) + - ARRAY_SIZE(il_eeprom_band_5); - - D_EEPROM("Parsing data for %d channels.\n", - il->channel_count); - - il->channel_info = kzalloc(sizeof(struct il_channel_info) * - il->channel_count, GFP_KERNEL); - if (!il->channel_info) { - IL_ERR("Could not allocate channel_info\n"); - il->channel_count = 0; - return -ENOMEM; - } - - ch_info = il->channel_info; - - /* Loop through the 5 EEPROM bands adding them in order to the - * channel map we maintain (that contains additional information than - * what just in the EEPROM) */ - for (band = 1; band <= 5; band++) { - - il_init_band_reference(il, band, &eeprom_ch_count, - &eeprom_ch_info, &eeprom_ch_idx); - - /* Loop through each band adding each of the channels */ - for (ch = 0; ch < eeprom_ch_count; ch++) { - ch_info->channel = eeprom_ch_idx[ch]; - ch_info->band = (band == 1) ? IEEE80211_BAND_2GHZ : - IEEE80211_BAND_5GHZ; - - /* permanently store EEPROM's channel regulatory flags - * and max power in channel info database. */ - ch_info->eeprom = eeprom_ch_info[ch]; - - /* Copy the run-time flags so they are there even on - * invalid channels */ - ch_info->flags = eeprom_ch_info[ch].flags; - /* First write that ht40 is not enabled, and then enable - * one by one */ - ch_info->ht40_extension_channel = - IEEE80211_CHAN_NO_HT40; - - if (!(il_is_channel_valid(ch_info))) { - D_EEPROM( - "Ch. %d Flags %x [%sGHz] - " - "No traffic\n", - ch_info->channel, - ch_info->flags, - il_is_channel_a_band(ch_info) ? - "5.2" : "2.4"); - ch_info++; - continue; - } - - /* Initialize regulatory-based run-time data */ - ch_info->max_power_avg = ch_info->curr_txpow = - eeprom_ch_info[ch].max_power_avg; - ch_info->scan_power = eeprom_ch_info[ch].max_power_avg; - ch_info->min_power = 0; - - D_EEPROM("Ch. %d [%sGHz] " - "%s%s%s%s%s%s(0x%02x %ddBm):" - " Ad-Hoc %ssupported\n", - ch_info->channel, - il_is_channel_a_band(ch_info) ? - "5.2" : "2.4", - CHECK_AND_PRINT_I(VALID), - CHECK_AND_PRINT_I(IBSS), - CHECK_AND_PRINT_I(ACTIVE), - CHECK_AND_PRINT_I(RADAR), - CHECK_AND_PRINT_I(WIDE), - CHECK_AND_PRINT_I(DFS), - eeprom_ch_info[ch].flags, - eeprom_ch_info[ch].max_power_avg, - ((eeprom_ch_info[ch]. - flags & EEPROM_CHANNEL_IBSS) - && !(eeprom_ch_info[ch]. - flags & EEPROM_CHANNEL_RADAR)) - ? "" : "not "); - - ch_info++; - } - } - - /* Check if we do have HT40 channels */ - if (il->cfg->ops->lib->eeprom_ops.regulatory_bands[5] == - EEPROM_REGULATORY_BAND_NO_HT40 && - il->cfg->ops->lib->eeprom_ops.regulatory_bands[6] == - EEPROM_REGULATORY_BAND_NO_HT40) - return 0; - - /* Two additional EEPROM bands for 2.4 and 5 GHz HT40 channels */ - for (band = 6; band <= 7; band++) { - enum ieee80211_band ieeeband; - - il_init_band_reference(il, band, &eeprom_ch_count, - &eeprom_ch_info, &eeprom_ch_idx); - - /* EEPROM band 6 is 2.4, band 7 is 5 GHz */ - ieeeband = - (band == 6) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; - - /* Loop through each band adding each of the channels */ - for (ch = 0; ch < eeprom_ch_count; ch++) { - /* Set up driver's info for lower half */ - il_mod_ht40_chan_info(il, ieeeband, - eeprom_ch_idx[ch], - &eeprom_ch_info[ch], - IEEE80211_CHAN_NO_HT40PLUS); - - /* Set up driver's info for upper half */ - il_mod_ht40_chan_info(il, ieeeband, - eeprom_ch_idx[ch] + 4, - &eeprom_ch_info[ch], - IEEE80211_CHAN_NO_HT40MINUS); - } - } - - return 0; -} -EXPORT_SYMBOL(il_init_channel_map); - -/* - * il_free_channel_map - undo allocations in il_init_channel_map - */ -void il_free_channel_map(struct il_priv *il) -{ - kfree(il->channel_info); - il->channel_count = 0; -} -EXPORT_SYMBOL(il_free_channel_map); - -/** - * il_get_channel_info - Find driver's ilate channel info - * - * Based on band and channel number. - */ -const struct -il_channel_info *il_get_channel_info(const struct il_priv *il, - enum ieee80211_band band, u16 channel) -{ - int i; - - switch (band) { - case IEEE80211_BAND_5GHZ: - for (i = 14; i < il->channel_count; i++) { - if (il->channel_info[i].channel == channel) - return &il->channel_info[i]; - } - break; - case IEEE80211_BAND_2GHZ: - if (channel >= 1 && channel <= 14) - return &il->channel_info[channel - 1]; - break; - default: - BUG(); - } - - return NULL; -} -EXPORT_SYMBOL(il_get_channel_info); diff --git a/drivers/net/wireless/iwlegacy/iwl-hcmd.c b/drivers/net/wireless/iwlegacy/iwl-hcmd.c deleted file mode 100644 index 670a398e0975..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-hcmd.c +++ /dev/null @@ -1,271 +0,0 @@ -/****************************************************************************** - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - *****************************************************************************/ - -#include -#include -#include -#include - -#include "iwl-dev.h" -#include "iwl-debug.h" -#include "iwl-eeprom.h" -#include "iwl-core.h" - - -const char *il_get_cmd_string(u8 cmd) -{ - switch (cmd) { - IL_CMD(N_ALIVE); - IL_CMD(N_ERROR); - IL_CMD(C_RXON); - IL_CMD(C_RXON_ASSOC); - IL_CMD(C_QOS_PARAM); - IL_CMD(C_RXON_TIMING); - IL_CMD(C_ADD_STA); - IL_CMD(C_REM_STA); - IL_CMD(C_WEPKEY); - IL_CMD(N_3945_RX); - IL_CMD(C_TX); - IL_CMD(C_RATE_SCALE); - IL_CMD(C_LEDS); - IL_CMD(C_TX_LINK_QUALITY_CMD); - IL_CMD(C_CHANNEL_SWITCH); - IL_CMD(N_CHANNEL_SWITCH); - IL_CMD(C_SPECTRUM_MEASUREMENT); - IL_CMD(N_SPECTRUM_MEASUREMENT); - IL_CMD(C_POWER_TBL); - IL_CMD(N_PM_SLEEP); - IL_CMD(N_PM_DEBUG_STATS); - IL_CMD(C_SCAN); - IL_CMD(C_SCAN_ABORT); - IL_CMD(N_SCAN_START); - IL_CMD(N_SCAN_RESULTS); - IL_CMD(N_SCAN_COMPLETE); - IL_CMD(N_BEACON); - IL_CMD(C_TX_BEACON); - IL_CMD(C_TX_PWR_TBL); - IL_CMD(C_BT_CONFIG); - IL_CMD(C_STATS); - IL_CMD(N_STATS); - IL_CMD(N_CARD_STATE); - IL_CMD(N_MISSED_BEACONS); - IL_CMD(C_CT_KILL_CONFIG); - IL_CMD(C_SENSITIVITY); - IL_CMD(C_PHY_CALIBRATION); - IL_CMD(N_RX_PHY); - IL_CMD(N_RX_MPDU); - IL_CMD(N_RX); - IL_CMD(N_COMPRESSED_BA); - default: - return "UNKNOWN"; - - } -} -EXPORT_SYMBOL(il_get_cmd_string); - -#define HOST_COMPLETE_TIMEOUT (HZ / 2) - -static void il_generic_cmd_callback(struct il_priv *il, - struct il_device_cmd *cmd, - struct il_rx_pkt *pkt) -{ - if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR("Bad return from %s (0x%08X)\n", - il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); - return; - } - -#ifdef CONFIG_IWLEGACY_DEBUG - switch (cmd->hdr.cmd) { - case C_TX_LINK_QUALITY_CMD: - case C_SENSITIVITY: - D_HC_DUMP("back from %s (0x%08X)\n", - il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); - break; - default: - D_HC("back from %s (0x%08X)\n", - il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); - } -#endif -} - -static int -il_send_cmd_async(struct il_priv *il, struct il_host_cmd *cmd) -{ - int ret; - - BUG_ON(!(cmd->flags & CMD_ASYNC)); - - /* An asynchronous command can not expect an SKB to be set. */ - BUG_ON(cmd->flags & CMD_WANT_SKB); - - /* Assign a generic callback if one is not provided */ - if (!cmd->callback) - cmd->callback = il_generic_cmd_callback; - - if (test_bit(S_EXIT_PENDING, &il->status)) - return -EBUSY; - - ret = il_enqueue_hcmd(il, cmd); - if (ret < 0) { - IL_ERR("Error sending %s: enqueue_hcmd failed: %d\n", - il_get_cmd_string(cmd->id), ret); - return ret; - } - return 0; -} - -int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) -{ - int cmd_idx; - int ret; - - lockdep_assert_held(&il->mutex); - - BUG_ON(cmd->flags & CMD_ASYNC); - - /* A synchronous command can not have a callback set. */ - BUG_ON(cmd->callback); - - D_INFO("Attempting to send sync command %s\n", - il_get_cmd_string(cmd->id)); - - set_bit(S_HCMD_ACTIVE, &il->status); - D_INFO("Setting HCMD_ACTIVE for command %s\n", - il_get_cmd_string(cmd->id)); - - cmd_idx = il_enqueue_hcmd(il, cmd); - if (cmd_idx < 0) { - ret = cmd_idx; - IL_ERR("Error sending %s: enqueue_hcmd failed: %d\n", - il_get_cmd_string(cmd->id), ret); - goto out; - } - - ret = wait_event_timeout(il->wait_command_queue, - !test_bit(S_HCMD_ACTIVE, &il->status), - HOST_COMPLETE_TIMEOUT); - if (!ret) { - if (test_bit(S_HCMD_ACTIVE, &il->status)) { - IL_ERR( - "Error sending %s: time out after %dms.\n", - il_get_cmd_string(cmd->id), - jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); - - clear_bit(S_HCMD_ACTIVE, &il->status); - D_INFO( - "Clearing HCMD_ACTIVE for command %s\n", - il_get_cmd_string(cmd->id)); - ret = -ETIMEDOUT; - goto cancel; - } - } - - if (test_bit(S_RF_KILL_HW, &il->status)) { - IL_ERR("Command %s aborted: RF KILL Switch\n", - il_get_cmd_string(cmd->id)); - ret = -ECANCELED; - goto fail; - } - if (test_bit(S_FW_ERROR, &il->status)) { - IL_ERR("Command %s failed: FW Error\n", - il_get_cmd_string(cmd->id)); - ret = -EIO; - goto fail; - } - if ((cmd->flags & CMD_WANT_SKB) && !cmd->reply_page) { - IL_ERR("Error: Response NULL in '%s'\n", - il_get_cmd_string(cmd->id)); - ret = -EIO; - goto cancel; - } - - ret = 0; - goto out; - -cancel: - if (cmd->flags & CMD_WANT_SKB) { - /* - * Cancel the CMD_WANT_SKB flag for the cmd in the - * TX cmd queue. Otherwise in case the cmd comes - * in later, it will possibly set an invalid - * address (cmd->meta.source). - */ - il->txq[il->cmd_queue].meta[cmd_idx].flags &= - ~CMD_WANT_SKB; - } -fail: - if (cmd->reply_page) { - il_free_pages(il, cmd->reply_page); - cmd->reply_page = 0; - } -out: - return ret; -} -EXPORT_SYMBOL(il_send_cmd_sync); - -int il_send_cmd(struct il_priv *il, struct il_host_cmd *cmd) -{ - if (cmd->flags & CMD_ASYNC) - return il_send_cmd_async(il, cmd); - - return il_send_cmd_sync(il, cmd); -} -EXPORT_SYMBOL(il_send_cmd); - -int -il_send_cmd_pdu(struct il_priv *il, u8 id, u16 len, const void *data) -{ - struct il_host_cmd cmd = { - .id = id, - .len = len, - .data = data, - }; - - return il_send_cmd_sync(il, &cmd); -} -EXPORT_SYMBOL(il_send_cmd_pdu); - -int il_send_cmd_pdu_async(struct il_priv *il, - u8 id, u16 len, const void *data, - void (*callback)(struct il_priv *il, - struct il_device_cmd *cmd, - struct il_rx_pkt *pkt)) -{ - struct il_host_cmd cmd = { - .id = id, - .len = len, - .data = data, - }; - - cmd.flags |= CMD_ASYNC; - cmd.callback = callback; - - return il_send_cmd_async(il, &cmd); -} -EXPORT_SYMBOL(il_send_cmd_pdu_async); diff --git a/drivers/net/wireless/iwlegacy/iwl-led.c b/drivers/net/wireless/iwlegacy/iwl-led.c deleted file mode 100644 index a840c2e54764..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-led.c +++ /dev/null @@ -1,205 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-io.h" - -/* default: IL_LED_BLINK(0) using blinking idx table */ -static int led_mode; -module_param(led_mode, int, S_IRUGO); -MODULE_PARM_DESC(led_mode, "0=system default, " - "1=On(RF On)/Off(RF Off), 2=blinking"); - -/* Throughput OFF time(ms) ON time (ms) - * >300 25 25 - * >200 to 300 40 40 - * >100 to 200 55 55 - * >70 to 100 65 65 - * >50 to 70 75 75 - * >20 to 50 85 85 - * >10 to 20 95 95 - * >5 to 10 110 110 - * >1 to 5 130 130 - * >0 to 1 167 167 - * <=0 SOLID ON - */ -static const struct ieee80211_tpt_blink il_blink[] = { - { .throughput = 0, .blink_time = 334 }, - { .throughput = 1 * 1024 - 1, .blink_time = 260 }, - { .throughput = 5 * 1024 - 1, .blink_time = 220 }, - { .throughput = 10 * 1024 - 1, .blink_time = 190 }, - { .throughput = 20 * 1024 - 1, .blink_time = 170 }, - { .throughput = 50 * 1024 - 1, .blink_time = 150 }, - { .throughput = 70 * 1024 - 1, .blink_time = 130 }, - { .throughput = 100 * 1024 - 1, .blink_time = 110 }, - { .throughput = 200 * 1024 - 1, .blink_time = 80 }, - { .throughput = 300 * 1024 - 1, .blink_time = 50 }, -}; - -/* - * Adjust led blink rate to compensate on a MAC Clock difference on every HW - * Led blink rate analysis showed an average deviation of 0% on 3945, - * 5% on 4965 HW. - * Need to compensate on the led on/off time per HW according to the deviation - * to achieve the desired led frequency - * The calculation is: (100-averageDeviation)/100 * blinkTime - * For code efficiency the calculation will be: - * compensation = (100 - averageDeviation) * 64 / 100 - * NewBlinkTime = (compensation * BlinkTime) / 64 - */ -static inline u8 il_blink_compensation(struct il_priv *il, - u8 time, u16 compensation) -{ - if (!compensation) { - IL_ERR("undefined blink compensation: " - "use pre-defined blinking time\n"); - return time; - } - - return (u8)((time * compensation) >> 6); -} - -/* Set led pattern command */ -static int il_led_cmd(struct il_priv *il, - unsigned long on, - unsigned long off) -{ - struct il_led_cmd led_cmd = { - .id = IL_LED_LINK, - .interval = IL_DEF_LED_INTRVL - }; - int ret; - - if (!test_bit(S_READY, &il->status)) - return -EBUSY; - - if (il->blink_on == on && il->blink_off == off) - return 0; - - if (off == 0) { - /* led is SOLID_ON */ - on = IL_LED_SOLID; - } - - D_LED("Led blink time compensation=%u\n", - il->cfg->base_params->led_compensation); - led_cmd.on = il_blink_compensation(il, on, - il->cfg->base_params->led_compensation); - led_cmd.off = il_blink_compensation(il, off, - il->cfg->base_params->led_compensation); - - ret = il->cfg->ops->led->cmd(il, &led_cmd); - if (!ret) { - il->blink_on = on; - il->blink_off = off; - } - return ret; -} - -static void il_led_brightness_set(struct led_classdev *led_cdev, - enum led_brightness brightness) -{ - struct il_priv *il = container_of(led_cdev, struct il_priv, led); - unsigned long on = 0; - - if (brightness > 0) - on = IL_LED_SOLID; - - il_led_cmd(il, on, 0); -} - -static int il_led_blink_set(struct led_classdev *led_cdev, - unsigned long *delay_on, - unsigned long *delay_off) -{ - struct il_priv *il = container_of(led_cdev, struct il_priv, led); - - return il_led_cmd(il, *delay_on, *delay_off); -} - -void il_leds_init(struct il_priv *il) -{ - int mode = led_mode; - int ret; - - if (mode == IL_LED_DEFAULT) - mode = il->cfg->led_mode; - - il->led.name = kasprintf(GFP_KERNEL, "%s-led", - wiphy_name(il->hw->wiphy)); - il->led.brightness_set = il_led_brightness_set; - il->led.blink_set = il_led_blink_set; - il->led.max_brightness = 1; - - switch (mode) { - case IL_LED_DEFAULT: - WARN_ON(1); - break; - case IL_LED_BLINK: - il->led.default_trigger = - ieee80211_create_tpt_led_trigger(il->hw, - IEEE80211_TPT_LEDTRIG_FL_CONNECTED, - il_blink, ARRAY_SIZE(il_blink)); - break; - case IL_LED_RF_STATE: - il->led.default_trigger = - ieee80211_get_radio_led_name(il->hw); - break; - } - - ret = led_classdev_register(&il->pci_dev->dev, &il->led); - if (ret) { - kfree(il->led.name); - return; - } - - il->led_registered = true; -} -EXPORT_SYMBOL(il_leds_init); - -void il_leds_exit(struct il_priv *il) -{ - if (!il->led_registered) - return; - - led_classdev_unregister(&il->led); - kfree(il->led.name); -} -EXPORT_SYMBOL(il_leds_exit); diff --git a/drivers/net/wireless/iwlegacy/iwl-power.c b/drivers/net/wireless/iwlegacy/iwl-power.c deleted file mode 100644 index 2b06a95f97f0..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-power.c +++ /dev/null @@ -1,165 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. - * - * Portions of this file are derived from the ipw3945 project, as well - * as portions of the ieee80211 subsystem header files. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - *****************************************************************************/ - - -#include -#include -#include -#include - -#include - -#include "iwl-eeprom.h" -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-io.h" -#include "iwl-commands.h" -#include "iwl-debug.h" -#include "iwl-power.h" - -/* - * Setting power level allows the card to go to sleep when not busy. - * - * We calculate a sleep command based on the required latency, which - * we get from mac80211. In order to handle thermal throttling, we can - * also use pre-defined power levels. - */ - -/* - * This defines the old power levels. They are still used by default - * (level 1) and for thermal throttle (levels 3 through 5) - */ - -struct il_power_vec_entry { - struct il_powertable_cmd cmd; - u8 no_dtim; /* number of skip dtim */ -}; - -static void il_power_sleep_cam_cmd(struct il_priv *il, - struct il_powertable_cmd *cmd) -{ - memset(cmd, 0, sizeof(*cmd)); - - if (il->power_data.pci_pm) - cmd->flags |= IL_POWER_PCI_PM_MSK; - - D_POWER("Sleep command for CAM\n"); -} - -static int -il_set_power(struct il_priv *il, struct il_powertable_cmd *cmd) -{ - D_POWER("Sending power/sleep command\n"); - D_POWER("Flags value = 0x%08X\n", cmd->flags); - D_POWER("Tx timeout = %u\n", - le32_to_cpu(cmd->tx_data_timeout)); - D_POWER("Rx timeout = %u\n", - le32_to_cpu(cmd->rx_data_timeout)); - D_POWER( - "Sleep interval vector = { %d , %d , %d , %d , %d }\n", - le32_to_cpu(cmd->sleep_interval[0]), - le32_to_cpu(cmd->sleep_interval[1]), - le32_to_cpu(cmd->sleep_interval[2]), - le32_to_cpu(cmd->sleep_interval[3]), - le32_to_cpu(cmd->sleep_interval[4])); - - return il_send_cmd_pdu(il, C_POWER_TBL, - sizeof(struct il_powertable_cmd), cmd); -} - -int -il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, - bool force) -{ - int ret; - bool update_chains; - - lockdep_assert_held(&il->mutex); - - /* Don't update the RX chain when chain noise calibration is running */ - update_chains = il->chain_noise_data.state == IL_CHAIN_NOISE_DONE || - il->chain_noise_data.state == IL_CHAIN_NOISE_ALIVE; - - if (!memcmp(&il->power_data.sleep_cmd, cmd, sizeof(*cmd)) && !force) - return 0; - - if (!il_is_ready_rf(il)) - return -EIO; - - /* scan complete use sleep_power_next, need to be updated */ - memcpy(&il->power_data.sleep_cmd_next, cmd, sizeof(*cmd)); - if (test_bit(S_SCANNING, &il->status) && !force) { - D_INFO("Defer power set mode while scanning\n"); - return 0; - } - - if (cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK) - set_bit(S_POWER_PMI, &il->status); - - ret = il_set_power(il, cmd); - if (!ret) { - if (!(cmd->flags & IL_POWER_DRIVER_ALLOW_SLEEP_MSK)) - clear_bit(S_POWER_PMI, &il->status); - - if (il->cfg->ops->lib->update_chain_flags && update_chains) - il->cfg->ops->lib->update_chain_flags(il); - else if (il->cfg->ops->lib->update_chain_flags) - D_POWER( - "Cannot update the power, chain noise " - "calibration running: %d\n", - il->chain_noise_data.state); - - memcpy(&il->power_data.sleep_cmd, cmd, sizeof(*cmd)); - } else - IL_ERR("set power fail, ret = %d", ret); - - return ret; -} - -int il_power_update_mode(struct il_priv *il, bool force) -{ - struct il_powertable_cmd cmd; - - il_power_sleep_cam_cmd(il, &cmd); - return il_power_set_mode(il, &cmd, force); -} -EXPORT_SYMBOL(il_power_update_mode); - -/* initialize to default */ -void il_power_initialize(struct il_priv *il) -{ - u16 lctl = il_pcie_link_ctl(il); - - il->power_data.pci_pm = !(lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN); - - il->power_data.debug_sleep_level_override = -1; - - memset(&il->power_data.sleep_cmd, 0, - sizeof(il->power_data.sleep_cmd)); -} -EXPORT_SYMBOL(il_power_initialize); diff --git a/drivers/net/wireless/iwlegacy/iwl-rx.c b/drivers/net/wireless/iwlegacy/iwl-rx.c deleted file mode 100644 index 7a8ae556f2be..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-rx.c +++ /dev/null @@ -1,281 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * Portions of this file are derived from the ipw3945 project, as well - * as portions of the ieee80211 subsystem header files. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include -#include -#include -#include -#include "iwl-eeprom.h" -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-sta.h" -#include "iwl-io.h" -#include "iwl-helpers.h" -/************************** RX-FUNCTIONS ****************************/ -/* - * Rx theory of operation - * - * Driver allocates a circular buffer of Receive Buffer Descriptors (RBDs), - * each of which point to Receive Buffers to be filled by the NIC. These get - * used not only for Rx frames, but for any command response or notification - * from the NIC. The driver and NIC manage the Rx buffers by means - * of idxes into the circular buffer. - * - * Rx Queue Indexes - * The host/firmware share two idx registers for managing the Rx buffers. - * - * The READ idx maps to the first position that the firmware may be writing - * to -- the driver can read up to (but not including) this position and get - * good data. - * The READ idx is managed by the firmware once the card is enabled. - * - * The WRITE idx maps to the last position the driver has read from -- the - * position preceding WRITE is the last slot the firmware can place a packet. - * - * The queue is empty (no good data) if WRITE = READ - 1, and is full if - * WRITE = READ. - * - * During initialization, the host sets up the READ queue position to the first - * IDX position, and WRITE to the last (READ - 1 wrapped) - * - * When the firmware places a packet in a buffer, it will advance the READ idx - * and fire the RX interrupt. The driver can then query the READ idx and - * process as many packets as possible, moving the WRITE idx forward as it - * resets the Rx queue buffers with new memory. - * - * The management in the driver is as follows: - * + A list of pre-allocated SKBs is stored in iwl->rxq->rx_free. When - * iwl->rxq->free_count drops to or below RX_LOW_WATERMARK, work is scheduled - * to replenish the iwl->rxq->rx_free. - * + In il_rx_replenish (scheduled) if 'processed' != 'read' then the - * iwl->rxq is replenished and the READ IDX is updated (updating the - * 'processed' and 'read' driver idxes as well) - * + A received packet is processed and handed to the kernel network stack, - * detached from the iwl->rxq. The driver 'processed' idx is updated. - * + The Host/Firmware iwl->rxq is replenished at tasklet time from the rx_free - * list. If there are no allocated buffers in iwl->rxq->rx_free, the READ - * IDX is not incremented and iwl->status(RX_STALLED) is set. If there - * were enough free buffers and RX_STALLED is set it is cleared. - * - * - * Driver sequence: - * - * il_rx_queue_alloc() Allocates rx_free - * il_rx_replenish() Replenishes rx_free list from rx_used, and calls - * il_rx_queue_restock - * il_rx_queue_restock() Moves available buffers from rx_free into Rx - * queue, updates firmware pointers, and updates - * the WRITE idx. If insufficient rx_free buffers - * are available, schedules il_rx_replenish - * - * -- enable interrupts -- - * ISR - il_rx() Detach il_rx_bufs from pool up to the - * READ IDX, detaching the SKB from the pool. - * Moves the packet buffer from queue to rx_used. - * Calls il_rx_queue_restock to refill any empty - * slots. - * ... - * - */ - -/** - * il_rx_queue_space - Return number of free slots available in queue. - */ -int il_rx_queue_space(const struct il_rx_queue *q) -{ - int s = q->read - q->write; - if (s <= 0) - s += RX_QUEUE_SIZE; - /* keep some buffer to not confuse full and empty queue */ - s -= 2; - if (s < 0) - s = 0; - return s; -} -EXPORT_SYMBOL(il_rx_queue_space); - -/** - * il_rx_queue_update_write_ptr - Update the write pointer for the RX queue - */ -void -il_rx_queue_update_write_ptr(struct il_priv *il, - struct il_rx_queue *q) -{ - unsigned long flags; - u32 rx_wrt_ptr_reg = il->hw_params.rx_wrt_ptr_reg; - u32 reg; - - spin_lock_irqsave(&q->lock, flags); - - if (q->need_update == 0) - goto exit_unlock; - - /* If power-saving is in use, make sure device is awake */ - if (test_bit(S_POWER_PMI, &il->status)) { - reg = _il_rd(il, CSR_UCODE_DRV_GP1); - - if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { - D_INFO( - "Rx queue requesting wakeup," - " GP1 = 0x%x\n", reg); - il_set_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); - goto exit_unlock; - } - - q->write_actual = (q->write & ~0x7); - il_wr(il, rx_wrt_ptr_reg, - q->write_actual); - - /* Else device is assumed to be awake */ - } else { - /* Device expects a multiple of 8 */ - q->write_actual = (q->write & ~0x7); - il_wr(il, rx_wrt_ptr_reg, - q->write_actual); - } - - q->need_update = 0; - - exit_unlock: - spin_unlock_irqrestore(&q->lock, flags); -} -EXPORT_SYMBOL(il_rx_queue_update_write_ptr); - -int il_rx_queue_alloc(struct il_priv *il) -{ - struct il_rx_queue *rxq = &il->rxq; - struct device *dev = &il->pci_dev->dev; - int i; - - spin_lock_init(&rxq->lock); - INIT_LIST_HEAD(&rxq->rx_free); - INIT_LIST_HEAD(&rxq->rx_used); - - /* Alloc the circular buffer of Read Buffer Descriptors (RBDs) */ - rxq->bd = dma_alloc_coherent(dev, 4 * RX_QUEUE_SIZE, &rxq->bd_dma, - GFP_KERNEL); - if (!rxq->bd) - goto err_bd; - - rxq->rb_stts = dma_alloc_coherent(dev, sizeof(struct il_rb_status), - &rxq->rb_stts_dma, GFP_KERNEL); - if (!rxq->rb_stts) - goto err_rb; - - /* Fill the rx_used queue with _all_ of the Rx buffers */ - for (i = 0; i < RX_FREE_BUFFERS + RX_QUEUE_SIZE; i++) - list_add_tail(&rxq->pool[i].list, &rxq->rx_used); - - /* Set us so that we have processed and used all buffers, but have - * not restocked the Rx queue with fresh buffers */ - rxq->read = rxq->write = 0; - rxq->write_actual = 0; - rxq->free_count = 0; - rxq->need_update = 0; - return 0; - -err_rb: - dma_free_coherent(&il->pci_dev->dev, 4 * RX_QUEUE_SIZE, rxq->bd, - rxq->bd_dma); -err_bd: - return -ENOMEM; -} -EXPORT_SYMBOL(il_rx_queue_alloc); - - -void il_hdl_spectrum_measurement(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il_spectrum_notification *report = &(pkt->u.spectrum_notif); - - if (!report->state) { - D_11H( - "Spectrum Measure Notification: Start\n"); - return; - } - - memcpy(&il->measure_report, report, sizeof(*report)); - il->measurement_status |= MEASUREMENT_READY; -} -EXPORT_SYMBOL(il_hdl_spectrum_measurement); - -/* - * returns non-zero if packet should be dropped - */ -int il_set_decrypted_flag(struct il_priv *il, - struct ieee80211_hdr *hdr, - u32 decrypt_res, - struct ieee80211_rx_status *stats) -{ - u16 fc = le16_to_cpu(hdr->frame_control); - - /* - * All contexts have the same setting here due to it being - * a module parameter, so OK to check any context. - */ - if (il->ctx.active.filter_flags & - RXON_FILTER_DIS_DECRYPT_MSK) - return 0; - - if (!(fc & IEEE80211_FCTL_PROTECTED)) - return 0; - - D_RX("decrypt_res:0x%x\n", decrypt_res); - switch (decrypt_res & RX_RES_STATUS_SEC_TYPE_MSK) { - case RX_RES_STATUS_SEC_TYPE_TKIP: - /* The uCode has got a bad phase 1 Key, pushes the packet. - * Decryption will be done in SW. */ - if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) == - RX_RES_STATUS_BAD_KEY_TTAK) - break; - - case RX_RES_STATUS_SEC_TYPE_WEP: - if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) == - RX_RES_STATUS_BAD_ICV_MIC) { - /* bad ICV, the packet is destroyed since the - * decryption is inplace, drop it */ - D_RX("Packet destroyed\n"); - return -1; - } - case RX_RES_STATUS_SEC_TYPE_CCMP: - if ((decrypt_res & RX_RES_STATUS_DECRYPT_TYPE_MSK) == - RX_RES_STATUS_DECRYPT_OK) { - D_RX("hw decrypt successfully!!!\n"); - stats->flag |= RX_FLAG_DECRYPTED; - } - break; - - default: - break; - } - return 0; -} -EXPORT_SYMBOL(il_set_decrypted_flag); diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c deleted file mode 100644 index aaa589abbe33..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-scan.c +++ /dev/null @@ -1,545 +0,0 @@ -/****************************************************************************** - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - *****************************************************************************/ -#include -#include -#include -#include - -#include "iwl-eeprom.h" -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-sta.h" -#include "iwl-io.h" -#include "iwl-helpers.h" - -/* For active scan, listen ACTIVE_DWELL_TIME (msec) on each channel after - * sending probe req. This should be set long enough to hear probe responses - * from more than one AP. */ -#define IL_ACTIVE_DWELL_TIME_24 (30) /* all times in msec */ -#define IL_ACTIVE_DWELL_TIME_52 (20) - -#define IL_ACTIVE_DWELL_FACTOR_24GHZ (3) -#define IL_ACTIVE_DWELL_FACTOR_52GHZ (2) - -/* For passive scan, listen PASSIVE_DWELL_TIME (msec) on each channel. - * Must be set longer than active dwell time. - * For the most reliable scan, set > AP beacon interval (typically 100msec). */ -#define IL_PASSIVE_DWELL_TIME_24 (20) /* all times in msec */ -#define IL_PASSIVE_DWELL_TIME_52 (10) -#define IL_PASSIVE_DWELL_BASE (100) -#define IL_CHANNEL_TUNE_TIME 5 - -static int il_send_scan_abort(struct il_priv *il) -{ - int ret; - struct il_rx_pkt *pkt; - struct il_host_cmd cmd = { - .id = C_SCAN_ABORT, - .flags = CMD_WANT_SKB, - }; - - /* Exit instantly with error when device is not ready - * to receive scan abort command or it does not perform - * hardware scan currently */ - if (!test_bit(S_READY, &il->status) || - !test_bit(S_GEO_CONFIGURED, &il->status) || - !test_bit(S_SCAN_HW, &il->status) || - test_bit(S_FW_ERROR, &il->status) || - test_bit(S_EXIT_PENDING, &il->status)) - return -EIO; - - ret = il_send_cmd_sync(il, &cmd); - if (ret) - return ret; - - pkt = (struct il_rx_pkt *)cmd.reply_page; - if (pkt->u.status != CAN_ABORT_STATUS) { - /* The scan abort will return 1 for success or - * 2 for "failure". A failure condition can be - * due to simply not being in an active scan which - * can occur if we send the scan abort before we - * the microcode has notified us that a scan is - * completed. */ - D_SCAN("SCAN_ABORT ret %d.\n", pkt->u.status); - ret = -EIO; - } - - il_free_pages(il, cmd.reply_page); - return ret; -} - -static void il_complete_scan(struct il_priv *il, bool aborted) -{ - /* check if scan was requested from mac80211 */ - if (il->scan_request) { - D_SCAN("Complete scan in mac80211\n"); - ieee80211_scan_completed(il->hw, aborted); - } - - il->scan_vif = NULL; - il->scan_request = NULL; -} - -void il_force_scan_end(struct il_priv *il) -{ - lockdep_assert_held(&il->mutex); - - if (!test_bit(S_SCANNING, &il->status)) { - D_SCAN("Forcing scan end while not scanning\n"); - return; - } - - D_SCAN("Forcing scan end\n"); - clear_bit(S_SCANNING, &il->status); - clear_bit(S_SCAN_HW, &il->status); - clear_bit(S_SCAN_ABORTING, &il->status); - il_complete_scan(il, true); -} - -static void il_do_scan_abort(struct il_priv *il) -{ - int ret; - - lockdep_assert_held(&il->mutex); - - if (!test_bit(S_SCANNING, &il->status)) { - D_SCAN("Not performing scan to abort\n"); - return; - } - - if (test_and_set_bit(S_SCAN_ABORTING, &il->status)) { - D_SCAN("Scan abort in progress\n"); - return; - } - - ret = il_send_scan_abort(il); - if (ret) { - D_SCAN("Send scan abort failed %d\n", ret); - il_force_scan_end(il); - } else - D_SCAN("Successfully send scan abort\n"); -} - -/** - * il_scan_cancel - Cancel any currently executing HW scan - */ -int il_scan_cancel(struct il_priv *il) -{ - D_SCAN("Queuing abort scan\n"); - queue_work(il->workqueue, &il->abort_scan); - return 0; -} -EXPORT_SYMBOL(il_scan_cancel); - -/** - * il_scan_cancel_timeout - Cancel any currently executing HW scan - * @ms: amount of time to wait (in milliseconds) for scan to abort - * - */ -int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms) -{ - unsigned long timeout = jiffies + msecs_to_jiffies(ms); - - lockdep_assert_held(&il->mutex); - - D_SCAN("Scan cancel timeout\n"); - - il_do_scan_abort(il); - - while (time_before_eq(jiffies, timeout)) { - if (!test_bit(S_SCAN_HW, &il->status)) - break; - msleep(20); - } - - return test_bit(S_SCAN_HW, &il->status); -} -EXPORT_SYMBOL(il_scan_cancel_timeout); - -/* Service response to C_SCAN (0x80) */ -static void il_hdl_scan(struct il_priv *il, - struct il_rx_buf *rxb) -{ -#ifdef CONFIG_IWLEGACY_DEBUG - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il_scanreq_notification *notif = - (struct il_scanreq_notification *)pkt->u.raw; - - D_SCAN("Scan request status = 0x%x\n", notif->status); -#endif -} - -/* Service N_SCAN_START (0x82) */ -static void il_hdl_scan_start(struct il_priv *il, - struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il_scanstart_notification *notif = - (struct il_scanstart_notification *)pkt->u.raw; - il->scan_start_tsf = le32_to_cpu(notif->tsf_low); - D_SCAN("Scan start: " - "%d [802.11%s] " - "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n", - notif->channel, - notif->band ? "bg" : "a", - le32_to_cpu(notif->tsf_high), - le32_to_cpu(notif->tsf_low), - notif->status, notif->beacon_timer); -} - -/* Service N_SCAN_RESULTS (0x83) */ -static void il_hdl_scan_results(struct il_priv *il, - struct il_rx_buf *rxb) -{ -#ifdef CONFIG_IWLEGACY_DEBUG - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il_scanresults_notification *notif = - (struct il_scanresults_notification *)pkt->u.raw; - - D_SCAN("Scan ch.res: " - "%d [802.11%s] " - "(TSF: 0x%08X:%08X) - %d " - "elapsed=%lu usec\n", - notif->channel, - notif->band ? "bg" : "a", - le32_to_cpu(notif->tsf_high), - le32_to_cpu(notif->tsf_low), - le32_to_cpu(notif->stats[0]), - le32_to_cpu(notif->tsf_low) - il->scan_start_tsf); -#endif -} - -/* Service N_SCAN_COMPLETE (0x84) */ -static void il_hdl_scan_complete(struct il_priv *il, - struct il_rx_buf *rxb) -{ - -#ifdef CONFIG_IWLEGACY_DEBUG - struct il_rx_pkt *pkt = rxb_addr(rxb); - struct il_scancomplete_notification *scan_notif = (void *)pkt->u.raw; -#endif - - D_SCAN( - "Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n", - scan_notif->scanned_channels, - scan_notif->tsf_low, - scan_notif->tsf_high, scan_notif->status); - - /* The HW is no longer scanning */ - clear_bit(S_SCAN_HW, &il->status); - - D_SCAN("Scan on %sGHz took %dms\n", - (il->scan_band == IEEE80211_BAND_2GHZ) ? "2.4" : "5.2", - jiffies_to_msecs(jiffies - il->scan_start)); - - queue_work(il->workqueue, &il->scan_completed); -} - -void il_setup_rx_scan_handlers(struct il_priv *il) -{ - /* scan handlers */ - il->handlers[C_SCAN] = il_hdl_scan; - il->handlers[N_SCAN_START] = - il_hdl_scan_start; - il->handlers[N_SCAN_RESULTS] = - il_hdl_scan_results; - il->handlers[N_SCAN_COMPLETE] = - il_hdl_scan_complete; -} -EXPORT_SYMBOL(il_setup_rx_scan_handlers); - -inline u16 il_get_active_dwell_time(struct il_priv *il, - enum ieee80211_band band, - u8 n_probes) -{ - if (band == IEEE80211_BAND_5GHZ) - return IL_ACTIVE_DWELL_TIME_52 + - IL_ACTIVE_DWELL_FACTOR_52GHZ * (n_probes + 1); - else - return IL_ACTIVE_DWELL_TIME_24 + - IL_ACTIVE_DWELL_FACTOR_24GHZ * (n_probes + 1); -} -EXPORT_SYMBOL(il_get_active_dwell_time); - -u16 il_get_passive_dwell_time(struct il_priv *il, - enum ieee80211_band band, - struct ieee80211_vif *vif) -{ - struct il_rxon_context *ctx = &il->ctx; - u16 value; - - u16 passive = (band == IEEE80211_BAND_2GHZ) ? - IL_PASSIVE_DWELL_BASE + IL_PASSIVE_DWELL_TIME_24 : - IL_PASSIVE_DWELL_BASE + IL_PASSIVE_DWELL_TIME_52; - - if (il_is_any_associated(il)) { - /* - * If we're associated, we clamp the maximum passive - * dwell time to be 98% of the smallest beacon interval - * (minus 2 * channel tune time) - */ - value = ctx->vif ? ctx->vif->bss_conf.beacon_int : 0; - if (value > IL_PASSIVE_DWELL_BASE || !value) - value = IL_PASSIVE_DWELL_BASE; - value = (value * 98) / 100 - IL_CHANNEL_TUNE_TIME * 2; - passive = min(value, passive); - } - - return passive; -} -EXPORT_SYMBOL(il_get_passive_dwell_time); - -void il_init_scan_params(struct il_priv *il) -{ - u8 ant_idx = fls(il->hw_params.valid_tx_ant) - 1; - if (!il->scan_tx_ant[IEEE80211_BAND_5GHZ]) - il->scan_tx_ant[IEEE80211_BAND_5GHZ] = ant_idx; - if (!il->scan_tx_ant[IEEE80211_BAND_2GHZ]) - il->scan_tx_ant[IEEE80211_BAND_2GHZ] = ant_idx; -} -EXPORT_SYMBOL(il_init_scan_params); - -static int il_scan_initiate(struct il_priv *il, - struct ieee80211_vif *vif) -{ - int ret; - - lockdep_assert_held(&il->mutex); - - if (WARN_ON(!il->cfg->ops->utils->request_scan)) - return -EOPNOTSUPP; - - cancel_delayed_work(&il->scan_check); - - if (!il_is_ready_rf(il)) { - IL_WARN("Request scan called when driver not ready.\n"); - return -EIO; - } - - if (test_bit(S_SCAN_HW, &il->status)) { - D_SCAN( - "Multiple concurrent scan requests in parallel.\n"); - return -EBUSY; - } - - if (test_bit(S_SCAN_ABORTING, &il->status)) { - D_SCAN("Scan request while abort pending.\n"); - return -EBUSY; - } - - D_SCAN("Starting scan...\n"); - - set_bit(S_SCANNING, &il->status); - il->scan_start = jiffies; - - ret = il->cfg->ops->utils->request_scan(il, vif); - if (ret) { - clear_bit(S_SCANNING, &il->status); - return ret; - } - - queue_delayed_work(il->workqueue, &il->scan_check, - IL_SCAN_CHECK_WATCHDOG); - - return 0; -} - -int il_mac_hw_scan(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct cfg80211_scan_request *req) -{ - struct il_priv *il = hw->priv; - int ret; - - D_MAC80211("enter\n"); - - if (req->n_channels == 0) - return -EINVAL; - - mutex_lock(&il->mutex); - - if (test_bit(S_SCANNING, &il->status)) { - D_SCAN("Scan already in progress.\n"); - ret = -EAGAIN; - goto out_unlock; - } - - /* mac80211 will only ask for one band at a time */ - il->scan_request = req; - il->scan_vif = vif; - il->scan_band = req->channels[0]->band; - - ret = il_scan_initiate(il, vif); - - D_MAC80211("leave\n"); - -out_unlock: - mutex_unlock(&il->mutex); - - return ret; -} -EXPORT_SYMBOL(il_mac_hw_scan); - -static void il_bg_scan_check(struct work_struct *data) -{ - struct il_priv *il = - container_of(data, struct il_priv, scan_check.work); - - D_SCAN("Scan check work\n"); - - /* Since we are here firmware does not finish scan and - * most likely is in bad shape, so we don't bother to - * send abort command, just force scan complete to mac80211 */ - mutex_lock(&il->mutex); - il_force_scan_end(il); - mutex_unlock(&il->mutex); -} - -/** - * il_fill_probe_req - fill in all required fields and IE for probe request - */ - -u16 -il_fill_probe_req(struct il_priv *il, struct ieee80211_mgmt *frame, - const u8 *ta, const u8 *ies, int ie_len, int left) -{ - int len = 0; - u8 *pos = NULL; - - /* Make sure there is enough space for the probe request, - * two mandatory IEs and the data */ - left -= 24; - if (left < 0) - return 0; - - frame->frame_control = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); - memcpy(frame->da, il_bcast_addr, ETH_ALEN); - memcpy(frame->sa, ta, ETH_ALEN); - memcpy(frame->bssid, il_bcast_addr, ETH_ALEN); - frame->seq_ctrl = 0; - - len += 24; - - /* ...next IE... */ - pos = &frame->u.probe_req.variable[0]; - - /* fill in our indirect SSID IE */ - left -= 2; - if (left < 0) - return 0; - *pos++ = WLAN_EID_SSID; - *pos++ = 0; - - len += 2; - - if (WARN_ON(left < ie_len)) - return len; - - if (ies && ie_len) { - memcpy(pos, ies, ie_len); - len += ie_len; - } - - return (u16)len; -} -EXPORT_SYMBOL(il_fill_probe_req); - -static void il_bg_abort_scan(struct work_struct *work) -{ - struct il_priv *il = container_of(work, struct il_priv, abort_scan); - - D_SCAN("Abort scan work\n"); - - /* We keep scan_check work queued in case when firmware will not - * report back scan completed notification */ - mutex_lock(&il->mutex); - il_scan_cancel_timeout(il, 200); - mutex_unlock(&il->mutex); -} - -static void il_bg_scan_completed(struct work_struct *work) -{ - struct il_priv *il = - container_of(work, struct il_priv, scan_completed); - bool aborted; - - D_SCAN("Completed scan.\n"); - - cancel_delayed_work(&il->scan_check); - - mutex_lock(&il->mutex); - - aborted = test_and_clear_bit(S_SCAN_ABORTING, &il->status); - if (aborted) - D_SCAN("Aborted scan completed.\n"); - - if (!test_and_clear_bit(S_SCANNING, &il->status)) { - D_SCAN("Scan already completed.\n"); - goto out_settings; - } - - il_complete_scan(il, aborted); - -out_settings: - /* Can we still talk to firmware ? */ - if (!il_is_ready_rf(il)) - goto out; - - /* - * We do not commit power settings while scan is pending, - * do it now if the settings changed. - */ - il_power_set_mode(il, &il->power_data.sleep_cmd_next, false); - il_set_tx_power(il, il->tx_power_next, false); - - il->cfg->ops->utils->post_scan(il); - -out: - mutex_unlock(&il->mutex); -} - -void il_setup_scan_deferred_work(struct il_priv *il) -{ - INIT_WORK(&il->scan_completed, il_bg_scan_completed); - INIT_WORK(&il->abort_scan, il_bg_abort_scan); - INIT_DELAYED_WORK(&il->scan_check, il_bg_scan_check); -} -EXPORT_SYMBOL(il_setup_scan_deferred_work); - -void il_cancel_scan_deferred_work(struct il_priv *il) -{ - cancel_work_sync(&il->abort_scan); - cancel_work_sync(&il->scan_completed); - - if (cancel_delayed_work_sync(&il->scan_check)) { - mutex_lock(&il->mutex); - il_force_scan_end(il); - mutex_unlock(&il->mutex); - } -} -EXPORT_SYMBOL(il_cancel_scan_deferred_work); diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c deleted file mode 100644 index 3b588b39fd67..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-tx.c +++ /dev/null @@ -1,655 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * Portions of this file are derived from the ipw3945 project, as well - * as portions of the ieee80211 subsystem header files. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include -#include -#include -#include -#include "iwl-eeprom.h" -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-sta.h" -#include "iwl-io.h" -#include "iwl-helpers.h" - -/** - * il_txq_update_write_ptr - Send new write idx to hardware - */ -void -il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq) -{ - u32 reg = 0; - int txq_id = txq->q.id; - - if (txq->need_update == 0) - return; - - /* if we're trying to save power */ - if (test_bit(S_POWER_PMI, &il->status)) { - /* wake up nic if it's powered down ... - * uCode will wake up, and interrupt us again, so next - * time we'll skip this part. */ - reg = _il_rd(il, CSR_UCODE_DRV_GP1); - - if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { - D_INFO( - "Tx queue %d requesting wakeup," - " GP1 = 0x%x\n", txq_id, reg); - il_set_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); - return; - } - - il_wr(il, HBUS_TARG_WRPTR, - txq->q.write_ptr | (txq_id << 8)); - - /* - * else not in power-save mode, - * uCode will never sleep when we're - * trying to tx (during RFKILL, we're not trying to tx). - */ - } else - _il_wr(il, HBUS_TARG_WRPTR, - txq->q.write_ptr | (txq_id << 8)); - txq->need_update = 0; -} -EXPORT_SYMBOL(il_txq_update_write_ptr); - -/** - * il_tx_queue_unmap - Unmap any remaining DMA mappings and free skb's - */ -void il_tx_queue_unmap(struct il_priv *il, int txq_id) -{ - struct il_tx_queue *txq = &il->txq[txq_id]; - struct il_queue *q = &txq->q; - - if (q->n_bd == 0) - return; - - while (q->write_ptr != q->read_ptr) { - il->cfg->ops->lib->txq_free_tfd(il, txq); - q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); - } -} -EXPORT_SYMBOL(il_tx_queue_unmap); - -/** - * il_tx_queue_free - Deallocate DMA queue. - * @txq: Transmit queue to deallocate. - * - * Empty queue by removing and destroying all BD's. - * Free all buffers. - * 0-fill, but do not free "txq" descriptor structure. - */ -void il_tx_queue_free(struct il_priv *il, int txq_id) -{ - struct il_tx_queue *txq = &il->txq[txq_id]; - struct device *dev = &il->pci_dev->dev; - int i; - - il_tx_queue_unmap(il, txq_id); - - /* De-alloc array of command/tx buffers */ - for (i = 0; i < TFD_TX_CMD_SLOTS; i++) - kfree(txq->cmd[i]); - - /* De-alloc circular buffer of TFDs */ - if (txq->q.n_bd) - dma_free_coherent(dev, il->hw_params.tfd_size * - txq->q.n_bd, txq->tfds, txq->q.dma_addr); - - /* De-alloc array of per-TFD driver data */ - kfree(txq->txb); - txq->txb = NULL; - - /* deallocate arrays */ - kfree(txq->cmd); - kfree(txq->meta); - txq->cmd = NULL; - txq->meta = NULL; - - /* 0-fill queue descriptor structure */ - memset(txq, 0, sizeof(*txq)); -} -EXPORT_SYMBOL(il_tx_queue_free); - -/** - * il_cmd_queue_unmap - Unmap any remaining DMA mappings from command queue - */ -void il_cmd_queue_unmap(struct il_priv *il) -{ - struct il_tx_queue *txq = &il->txq[il->cmd_queue]; - struct il_queue *q = &txq->q; - int i; - - if (q->n_bd == 0) - return; - - while (q->read_ptr != q->write_ptr) { - i = il_get_cmd_idx(q, q->read_ptr, 0); - - if (txq->meta[i].flags & CMD_MAPPED) { - pci_unmap_single(il->pci_dev, - dma_unmap_addr(&txq->meta[i], mapping), - dma_unmap_len(&txq->meta[i], len), - PCI_DMA_BIDIRECTIONAL); - txq->meta[i].flags = 0; - } - - q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); - } - - i = q->n_win; - if (txq->meta[i].flags & CMD_MAPPED) { - pci_unmap_single(il->pci_dev, - dma_unmap_addr(&txq->meta[i], mapping), - dma_unmap_len(&txq->meta[i], len), - PCI_DMA_BIDIRECTIONAL); - txq->meta[i].flags = 0; - } -} -EXPORT_SYMBOL(il_cmd_queue_unmap); - -/** - * il_cmd_queue_free - Deallocate DMA queue. - * @txq: Transmit queue to deallocate. - * - * Empty queue by removing and destroying all BD's. - * Free all buffers. - * 0-fill, but do not free "txq" descriptor structure. - */ -void il_cmd_queue_free(struct il_priv *il) -{ - struct il_tx_queue *txq = &il->txq[il->cmd_queue]; - struct device *dev = &il->pci_dev->dev; - int i; - - il_cmd_queue_unmap(il); - - /* De-alloc array of command/tx buffers */ - for (i = 0; i <= TFD_CMD_SLOTS; i++) - kfree(txq->cmd[i]); - - /* De-alloc circular buffer of TFDs */ - if (txq->q.n_bd) - dma_free_coherent(dev, il->hw_params.tfd_size * txq->q.n_bd, - txq->tfds, txq->q.dma_addr); - - /* deallocate arrays */ - kfree(txq->cmd); - kfree(txq->meta); - txq->cmd = NULL; - txq->meta = NULL; - - /* 0-fill queue descriptor structure */ - memset(txq, 0, sizeof(*txq)); -} -EXPORT_SYMBOL(il_cmd_queue_free); - -/*************** DMA-QUEUE-GENERAL-FUNCTIONS ***** - * DMA services - * - * Theory of operation - * - * A Tx or Rx queue resides in host DRAM, and is comprised of a circular buffer - * of buffer descriptors, each of which points to one or more data buffers for - * the device to read from or fill. Driver and device exchange status of each - * queue via "read" and "write" pointers. Driver keeps minimum of 2 empty - * entries in each circular buffer, to protect against confusing empty and full - * queue states. - * - * The device reads or writes the data in the queues via the device's several - * DMA/FIFO channels. Each queue is mapped to a single DMA channel. - * - * For Tx queue, there are low mark and high mark limits. If, after queuing - * the packet for Tx, free space become < low mark, Tx queue stopped. When - * reclaiming packets (on 'tx done IRQ), if free space become > high mark, - * Tx queue resumed. - * - * See more detailed info in 4965.h. - ***************************************************/ - -int il_queue_space(const struct il_queue *q) -{ - int s = q->read_ptr - q->write_ptr; - - if (q->read_ptr > q->write_ptr) - s -= q->n_bd; - - if (s <= 0) - s += q->n_win; - /* keep some reserve to not confuse empty and full situations */ - s -= 2; - if (s < 0) - s = 0; - return s; -} -EXPORT_SYMBOL(il_queue_space); - - -/** - * il_queue_init - Initialize queue's high/low-water and read/write idxes - */ -static int il_queue_init(struct il_priv *il, struct il_queue *q, - int count, int slots_num, u32 id) -{ - q->n_bd = count; - q->n_win = slots_num; - q->id = id; - - /* count must be power-of-two size, otherwise il_queue_inc_wrap - * and il_queue_dec_wrap are broken. */ - BUG_ON(!is_power_of_2(count)); - - /* slots_num must be power-of-two size, otherwise - * il_get_cmd_idx is broken. */ - BUG_ON(!is_power_of_2(slots_num)); - - q->low_mark = q->n_win / 4; - if (q->low_mark < 4) - q->low_mark = 4; - - q->high_mark = q->n_win / 8; - if (q->high_mark < 2) - q->high_mark = 2; - - q->write_ptr = q->read_ptr = 0; - - return 0; -} - -/** - * il_tx_queue_alloc - Alloc driver data and TFD CB for one Tx/cmd queue - */ -static int il_tx_queue_alloc(struct il_priv *il, - struct il_tx_queue *txq, u32 id) -{ - struct device *dev = &il->pci_dev->dev; - size_t tfd_sz = il->hw_params.tfd_size * TFD_QUEUE_SIZE_MAX; - - /* Driver ilate data, only for Tx (not command) queues, - * not shared with device. */ - if (id != il->cmd_queue) { - txq->txb = kzalloc(sizeof(txq->txb[0]) * - TFD_QUEUE_SIZE_MAX, GFP_KERNEL); - if (!txq->txb) { - IL_ERR("kmalloc for auxiliary BD " - "structures failed\n"); - goto error; - } - } else { - txq->txb = NULL; - } - - /* Circular buffer of transmit frame descriptors (TFDs), - * shared with device */ - txq->tfds = dma_alloc_coherent(dev, tfd_sz, &txq->q.dma_addr, - GFP_KERNEL); - if (!txq->tfds) { - IL_ERR("pci_alloc_consistent(%zd) failed\n", tfd_sz); - goto error; - } - txq->q.id = id; - - return 0; - - error: - kfree(txq->txb); - txq->txb = NULL; - - return -ENOMEM; -} - -/** - * il_tx_queue_init - Allocate and initialize one tx/cmd queue - */ -int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, - int slots_num, u32 txq_id) -{ - int i, len; - int ret; - int actual_slots = slots_num; - - /* - * Alloc buffer array for commands (Tx or other types of commands). - * For the command queue (#4/#9), allocate command space + one big - * command for scan, since scan command is very huge; the system will - * not have two scans at the same time, so only one is needed. - * For normal Tx queues (all other queues), no super-size command - * space is needed. - */ - if (txq_id == il->cmd_queue) - actual_slots++; - - txq->meta = kzalloc(sizeof(struct il_cmd_meta) * actual_slots, - GFP_KERNEL); - txq->cmd = kzalloc(sizeof(struct il_device_cmd *) * actual_slots, - GFP_KERNEL); - - if (!txq->meta || !txq->cmd) - goto out_free_arrays; - - len = sizeof(struct il_device_cmd); - for (i = 0; i < actual_slots; i++) { - /* only happens for cmd queue */ - if (i == slots_num) - len = IL_MAX_CMD_SIZE; - - txq->cmd[i] = kmalloc(len, GFP_KERNEL); - if (!txq->cmd[i]) - goto err; - } - - /* Alloc driver data array and TFD circular buffer */ - ret = il_tx_queue_alloc(il, txq, txq_id); - if (ret) - goto err; - - txq->need_update = 0; - - /* - * For the default queues 0-3, set up the swq_id - * already -- all others need to get one later - * (if they need one at all). - */ - if (txq_id < 4) - il_set_swq_id(txq, txq_id, txq_id); - - /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise - * il_queue_inc_wrap and il_queue_dec_wrap are broken. */ - BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); - - /* Initialize queue's high/low-water marks, and head/tail idxes */ - il_queue_init(il, &txq->q, - TFD_QUEUE_SIZE_MAX, slots_num, txq_id); - - /* Tell device where to find queue */ - il->cfg->ops->lib->txq_init(il, txq); - - return 0; -err: - for (i = 0; i < actual_slots; i++) - kfree(txq->cmd[i]); -out_free_arrays: - kfree(txq->meta); - kfree(txq->cmd); - - return -ENOMEM; -} -EXPORT_SYMBOL(il_tx_queue_init); - -void il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, - int slots_num, u32 txq_id) -{ - int actual_slots = slots_num; - - if (txq_id == il->cmd_queue) - actual_slots++; - - memset(txq->meta, 0, sizeof(struct il_cmd_meta) * actual_slots); - - txq->need_update = 0; - - /* Initialize queue's high/low-water marks, and head/tail idxes */ - il_queue_init(il, &txq->q, - TFD_QUEUE_SIZE_MAX, slots_num, txq_id); - - /* Tell device where to find queue */ - il->cfg->ops->lib->txq_init(il, txq); -} -EXPORT_SYMBOL(il_tx_queue_reset); - -/*************** HOST COMMAND QUEUE FUNCTIONS *****/ - -/** - * il_enqueue_hcmd - enqueue a uCode command - * @il: device ilate data point - * @cmd: a point to the ucode command structure - * - * The function returns < 0 values to indicate the operation is - * failed. On success, it turns the idx (> 0) of command in the - * command queue. - */ -int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) -{ - struct il_tx_queue *txq = &il->txq[il->cmd_queue]; - struct il_queue *q = &txq->q; - struct il_device_cmd *out_cmd; - struct il_cmd_meta *out_meta; - dma_addr_t phys_addr; - unsigned long flags; - int len; - u32 idx; - u16 fix_size; - - cmd->len = il->cfg->ops->utils->get_hcmd_size(cmd->id, cmd->len); - fix_size = (u16)(cmd->len + sizeof(out_cmd->hdr)); - - /* If any of the command structures end up being larger than - * the TFD_MAX_PAYLOAD_SIZE, and it sent as a 'small' command then - * we will need to increase the size of the TFD entries - * Also, check to see if command buffer should not exceed the size - * of device_cmd and max_cmd_size. */ - BUG_ON((fix_size > TFD_MAX_PAYLOAD_SIZE) && - !(cmd->flags & CMD_SIZE_HUGE)); - BUG_ON(fix_size > IL_MAX_CMD_SIZE); - - if (il_is_rfkill(il) || il_is_ctkill(il)) { - IL_WARN("Not sending command - %s KILL\n", - il_is_rfkill(il) ? "RF" : "CT"); - return -EIO; - } - - spin_lock_irqsave(&il->hcmd_lock, flags); - - if (il_queue_space(q) < ((cmd->flags & CMD_ASYNC) ? 2 : 1)) { - spin_unlock_irqrestore(&il->hcmd_lock, flags); - - IL_ERR("Restarting adapter due to command queue full\n"); - queue_work(il->workqueue, &il->restart); - return -ENOSPC; - } - - idx = il_get_cmd_idx(q, q->write_ptr, cmd->flags & CMD_SIZE_HUGE); - out_cmd = txq->cmd[idx]; - out_meta = &txq->meta[idx]; - - if (WARN_ON(out_meta->flags & CMD_MAPPED)) { - spin_unlock_irqrestore(&il->hcmd_lock, flags); - return -ENOSPC; - } - - memset(out_meta, 0, sizeof(*out_meta)); /* re-initialize to NULL */ - out_meta->flags = cmd->flags | CMD_MAPPED; - if (cmd->flags & CMD_WANT_SKB) - out_meta->source = cmd; - if (cmd->flags & CMD_ASYNC) - out_meta->callback = cmd->callback; - - out_cmd->hdr.cmd = cmd->id; - memcpy(&out_cmd->cmd.payload, cmd->data, cmd->len); - - /* At this point, the out_cmd now has all of the incoming cmd - * information */ - - out_cmd->hdr.flags = 0; - out_cmd->hdr.sequence = cpu_to_le16(QUEUE_TO_SEQ(il->cmd_queue) | - IDX_TO_SEQ(q->write_ptr)); - if (cmd->flags & CMD_SIZE_HUGE) - out_cmd->hdr.sequence |= SEQ_HUGE_FRAME; - len = sizeof(struct il_device_cmd); - if (idx == TFD_CMD_SLOTS) - len = IL_MAX_CMD_SIZE; - -#ifdef CONFIG_IWLEGACY_DEBUG - switch (out_cmd->hdr.cmd) { - case C_TX_LINK_QUALITY_CMD: - case C_SENSITIVITY: - D_HC_DUMP( - "Sending command %s (#%x), seq: 0x%04X, " - "%d bytes at %d[%d]:%d\n", - il_get_cmd_string(out_cmd->hdr.cmd), - out_cmd->hdr.cmd, - le16_to_cpu(out_cmd->hdr.sequence), fix_size, - q->write_ptr, idx, il->cmd_queue); - break; - default: - D_HC("Sending command %s (#%x), seq: 0x%04X, " - "%d bytes at %d[%d]:%d\n", - il_get_cmd_string(out_cmd->hdr.cmd), - out_cmd->hdr.cmd, - le16_to_cpu(out_cmd->hdr.sequence), fix_size, - q->write_ptr, idx, il->cmd_queue); - } -#endif - txq->need_update = 1; - - if (il->cfg->ops->lib->txq_update_byte_cnt_tbl) - /* Set up entry in queue's byte count circular buffer */ - il->cfg->ops->lib->txq_update_byte_cnt_tbl(il, txq, 0); - - phys_addr = pci_map_single(il->pci_dev, &out_cmd->hdr, - fix_size, PCI_DMA_BIDIRECTIONAL); - dma_unmap_addr_set(out_meta, mapping, phys_addr); - dma_unmap_len_set(out_meta, len, fix_size); - - il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, - phys_addr, fix_size, 1, - U32_PAD(cmd->len)); - - /* Increment and update queue's write idx */ - q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); - il_txq_update_write_ptr(il, txq); - - spin_unlock_irqrestore(&il->hcmd_lock, flags); - return idx; -} - -/** - * il_hcmd_queue_reclaim - Reclaim TX command queue entries already Tx'd - * - * When FW advances 'R' idx, all entries between old and new 'R' idx - * need to be reclaimed. As result, some free space forms. If there is - * enough free space (> low mark), wake the stack that feeds us. - */ -static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, - int idx, int cmd_idx) -{ - struct il_tx_queue *txq = &il->txq[txq_id]; - struct il_queue *q = &txq->q; - int nfreed = 0; - - if (idx >= q->n_bd || il_queue_used(q, idx) == 0) { - IL_ERR("Read idx for DMA queue txq id (%d), idx %d, " - "is out of range [0-%d] %d %d.\n", txq_id, - idx, q->n_bd, q->write_ptr, q->read_ptr); - return; - } - - for (idx = il_queue_inc_wrap(idx, q->n_bd); q->read_ptr != idx; - q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { - - if (nfreed++ > 0) { - IL_ERR("HCMD skipped: idx (%d) %d %d\n", idx, - q->write_ptr, q->read_ptr); - queue_work(il->workqueue, &il->restart); - } - - } -} - -/** - * il_tx_cmd_complete - Pull unused buffers off the queue and reclaim them - * @rxb: Rx buffer to reclaim - * - * If an Rx buffer has an async callback associated with it the callback - * will be executed. The attached skb (if present) will only be freed - * if the callback returns 1 - */ -void -il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb) -{ - struct il_rx_pkt *pkt = rxb_addr(rxb); - u16 sequence = le16_to_cpu(pkt->hdr.sequence); - int txq_id = SEQ_TO_QUEUE(sequence); - int idx = SEQ_TO_IDX(sequence); - int cmd_idx; - bool huge = !!(pkt->hdr.sequence & SEQ_HUGE_FRAME); - struct il_device_cmd *cmd; - struct il_cmd_meta *meta; - struct il_tx_queue *txq = &il->txq[il->cmd_queue]; - unsigned long flags; - - /* If a Tx command is being handled and it isn't in the actual - * command queue then there a command routing bug has been introduced - * in the queue management code. */ - if (WARN(txq_id != il->cmd_queue, - "wrong command queue %d (should be %d), sequence 0x%X readp=%d writep=%d\n", - txq_id, il->cmd_queue, sequence, - il->txq[il->cmd_queue].q.read_ptr, - il->txq[il->cmd_queue].q.write_ptr)) { - il_print_hex_error(il, pkt, 32); - return; - } - - cmd_idx = il_get_cmd_idx(&txq->q, idx, huge); - cmd = txq->cmd[cmd_idx]; - meta = &txq->meta[cmd_idx]; - - txq->time_stamp = jiffies; - - pci_unmap_single(il->pci_dev, - dma_unmap_addr(meta, mapping), - dma_unmap_len(meta, len), - PCI_DMA_BIDIRECTIONAL); - - /* Input error checking is done when commands are added to queue. */ - if (meta->flags & CMD_WANT_SKB) { - meta->source->reply_page = (unsigned long)rxb_addr(rxb); - rxb->page = NULL; - } else if (meta->callback) - meta->callback(il, cmd, pkt); - - spin_lock_irqsave(&il->hcmd_lock, flags); - - il_hcmd_queue_reclaim(il, txq_id, idx, cmd_idx); - - if (!(meta->flags & CMD_ASYNC)) { - clear_bit(S_HCMD_ACTIVE, &il->status); - D_INFO("Clearing HCMD_ACTIVE for command %s\n", - il_get_cmd_string(cmd->hdr.cmd)); - wake_up(&il->wait_command_queue); - } - - /* Mark as unmapped */ - meta->flags = 0; - - spin_unlock_irqrestore(&il->hcmd_lock, flags); -} -EXPORT_SYMBOL(il_tx_cmd_complete); -- cgit v1.2.3 From 7f8e12238049b0e5398e77cdf15f95a41077841f Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 13:42:04 +0100 Subject: iwlegacy: rename module name Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index 413213b0e974..74218419f8ef 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -1,8 +1,8 @@ -obj-$(CONFIG_IWLEGACY) += iwl-legacy.o -iwl-legacy-objs := common.o -iwl-legacy-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-debugfs.o +obj-$(CONFIG_IWLEGACY) += iwlegacy.o +iwlegacy-objs := common.o +iwlegacy-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-debugfs.o -iwl-legacy-objs += $(iwl-legacy-m) +iwlegacy-objs += $(iwlegacy-m) # 4965 obj-$(CONFIG_IWL4965) += iwl4965.o -- cgit v1.2.3 From d4459a99c41e0e4fe7e36b3816b461c42827fb80 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 10:59:02 +0200 Subject: iwlegacy: rename iwl-commands.h to commands.h On the way remove also not needed iwl-fh.h include. Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/3945-mac.c | 3 +- drivers/net/wireless/iwlegacy/3945-rs.c | 2 +- drivers/net/wireless/iwlegacy/3945.c | 3 +- drivers/net/wireless/iwlegacy/3945.h | 1 - drivers/net/wireless/iwlegacy/commands.h | 3393 +++++++++++++++++++++++++ drivers/net/wireless/iwlegacy/iwl-commands.h | 3398 -------------------------- drivers/net/wireless/iwlegacy/iwl-dev.h | 3 +- drivers/net/wireless/iwlegacy/iwl-power.h | 2 +- 8 files changed, 3398 insertions(+), 3407 deletions(-) create mode 100644 drivers/net/wireless/iwlegacy/commands.h delete mode 100644 drivers/net/wireless/iwlegacy/iwl-commands.h (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index e33ebca106c3..ae60410ab708 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -51,8 +51,7 @@ #define DRV_NAME "iwl3945" -#include "iwl-fh.h" -#include "iwl-commands.h" +#include "commands.h" #include "iwl-sta.h" #include "3945.h" #include "iwl-core.h" diff --git a/drivers/net/wireless/iwlegacy/3945-rs.c b/drivers/net/wireless/iwlegacy/3945-rs.c index 0d2beba1a25a..4aa0432b4a6d 100644 --- a/drivers/net/wireless/iwlegacy/3945-rs.c +++ b/drivers/net/wireless/iwlegacy/3945-rs.c @@ -36,7 +36,7 @@ #include -#include "iwl-commands.h" +#include "commands.h" #include "3945.h" #include "iwl-sta.h" diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 83fe531002f0..ff8818b3c296 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -39,8 +39,7 @@ #include #include -#include "iwl-fh.h" -#include "iwl-commands.h" +#include "commands.h" #include "iwl-sta.h" #include "iwl-eeprom.h" #include "iwl-core.h" diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index 9854cf1b7546..7559a5ed3b6d 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -36,7 +36,6 @@ extern const struct pci_device_id il3945_hw_card_ids[]; #include "iwl-csr.h" #include "iwl-prph.h" -#include "iwl-fh.h" #include "iwl-debug.h" #include "iwl-power.h" #include "iwl-dev.h" diff --git a/drivers/net/wireless/iwlegacy/commands.h b/drivers/net/wireless/iwlegacy/commands.h new file mode 100644 index 000000000000..82cf472157de --- /dev/null +++ b/drivers/net/wireless/iwlegacy/commands.h @@ -0,0 +1,3393 @@ +/****************************************************************************** + * + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, + * USA + * + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + * BSD LICENSE + * + * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *****************************************************************************/ + +#ifndef __il_commands_h__ +#define __il_commands_h__ + +struct il_priv; + +/* uCode version contains 4 values: Major/Minor/API/Serial */ +#define IL_UCODE_MAJOR(ver) (((ver) & 0xFF000000) >> 24) +#define IL_UCODE_MINOR(ver) (((ver) & 0x00FF0000) >> 16) +#define IL_UCODE_API(ver) (((ver) & 0x0000FF00) >> 8) +#define IL_UCODE_SERIAL(ver) ((ver) & 0x000000FF) + + +/* Tx rates */ +#define IL_CCK_RATES 4 +#define IL_OFDM_RATES 8 +#define IL_MAX_RATES (IL_CCK_RATES + IL_OFDM_RATES) + +enum { + N_ALIVE = 0x1, + N_ERROR = 0x2, + + /* RXON and QOS commands */ + C_RXON = 0x10, + C_RXON_ASSOC = 0x11, + C_QOS_PARAM = 0x13, + C_RXON_TIMING = 0x14, + + /* Multi-Station support */ + C_ADD_STA = 0x18, + C_REM_STA = 0x19, + + /* Security */ + C_WEPKEY = 0x20, + + /* RX, TX, LEDs */ + N_3945_RX = 0x1b, /* 3945 only */ + C_TX = 0x1c, + C_RATE_SCALE = 0x47, /* 3945 only */ + C_LEDS = 0x48, + C_TX_LINK_QUALITY_CMD = 0x4e, /* for 4965 */ + + /* 802.11h related */ + C_CHANNEL_SWITCH = 0x72, + N_CHANNEL_SWITCH = 0x73, + C_SPECTRUM_MEASUREMENT = 0x74, + N_SPECTRUM_MEASUREMENT = 0x75, + + /* Power Management */ + C_POWER_TBL = 0x77, + N_PM_SLEEP = 0x7A, + N_PM_DEBUG_STATS = 0x7B, + + /* Scan commands and notifications */ + C_SCAN = 0x80, + C_SCAN_ABORT = 0x81, + N_SCAN_START = 0x82, + N_SCAN_RESULTS = 0x83, + N_SCAN_COMPLETE = 0x84, + + /* IBSS/AP commands */ + N_BEACON = 0x90, + C_TX_BEACON= 0x91, + + /* Miscellaneous commands */ + C_TX_PWR_TBL = 0x97, + + /* Bluetooth device coexistence config command */ + C_BT_CONFIG = 0x9b, + + /* Statistics */ + C_STATS = 0x9c, + N_STATS = 0x9d, + + /* RF-KILL commands and notifications */ + N_CARD_STATE = 0xa1, + + /* Missed beacons notification */ + N_MISSED_BEACONS = 0xa2, + + C_CT_KILL_CONFIG = 0xa4, + C_SENSITIVITY = 0xa8, + C_PHY_CALIBRATION = 0xb0, + N_RX_PHY = 0xc0, + N_RX_MPDU = 0xc1, + N_RX = 0xc3, + N_COMPRESSED_BA = 0xc5, + + IL_CN_MAX = 0xff +}; + +/****************************************************************************** + * (0) + * Commonly used structures and definitions: + * Command header, rate_n_flags, txpower + * + *****************************************************************************/ + +/* il_cmd_header flags value */ +#define IL_CMD_FAILED_MSK 0x40 + +#define SEQ_TO_QUEUE(s) (((s) >> 8) & 0x1f) +#define QUEUE_TO_SEQ(q) (((q) & 0x1f) << 8) +#define SEQ_TO_IDX(s) ((s) & 0xff) +#define IDX_TO_SEQ(i) ((i) & 0xff) +#define SEQ_HUGE_FRAME cpu_to_le16(0x4000) +#define SEQ_RX_FRAME cpu_to_le16(0x8000) + +/** + * struct il_cmd_header + * + * This header format appears in the beginning of each command sent from the + * driver, and each response/notification received from uCode. + */ +struct il_cmd_header { + u8 cmd; /* Command ID: C_RXON, etc. */ + u8 flags; /* 0:5 reserved, 6 abort, 7 internal */ + /* + * The driver sets up the sequence number to values of its choosing. + * uCode does not use this value, but passes it back to the driver + * when sending the response to each driver-originated command, so + * the driver can match the response to the command. Since the values + * don't get used by uCode, the driver may set up an arbitrary format. + * + * There is one exception: uCode sets bit 15 when it originates + * the response/notification, i.e. when the response/notification + * is not a direct response to a command sent by the driver. For + * example, uCode issues N_3945_RX when it sends a received frame + * to the driver; it is not a direct response to any driver command. + * + * The Linux driver uses the following format: + * + * 0:7 tfd idx - position within TX queue + * 8:12 TX queue id + * 13 reserved + * 14 huge - driver sets this to indicate command is in the + * 'huge' storage at the end of the command buffers + * 15 unsolicited RX or uCode-originated notification + */ + __le16 sequence; + + /* command or response/notification data follows immediately */ + u8 data[0]; +} __packed; + + +/** + * struct il3945_tx_power + * + * Used in C_TX_PWR_TBL, C_SCAN, C_CHANNEL_SWITCH + * + * Each entry contains two values: + * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained + * linear value that multiplies the output of the digital signal processor, + * before being sent to the analog radio. + * 2) Radio gain. This sets the analog gain of the radio Tx path. + * It is a coarser setting, and behaves in a logarithmic (dB) fashion. + * + * Driver obtains values from struct il3945_tx_power power_gain_table[][]. + */ +struct il3945_tx_power { + u8 tx_gain; /* gain for analog radio */ + u8 dsp_atten; /* gain for DSP */ +} __packed; + +/** + * struct il3945_power_per_rate + * + * Used in C_TX_PWR_TBL, C_CHANNEL_SWITCH + */ +struct il3945_power_per_rate { + u8 rate; /* plcp */ + struct il3945_tx_power tpc; + u8 reserved; +} __packed; + +/** + * iwl4965 rate_n_flags bit fields + * + * rate_n_flags format is used in following iwl4965 commands: + * N_RX (response only) + * N_RX_MPDU (response only) + * C_TX (both command and response) + * C_TX_LINK_QUALITY_CMD + * + * High-throughput (HT) rate format for bits 7:0 (bit 8 must be "1"): + * 2-0: 0) 6 Mbps + * 1) 12 Mbps + * 2) 18 Mbps + * 3) 24 Mbps + * 4) 36 Mbps + * 5) 48 Mbps + * 6) 54 Mbps + * 7) 60 Mbps + * + * 4-3: 0) Single stream (SISO) + * 1) Dual stream (MIMO) + * 2) Triple stream (MIMO) + * + * 5: Value of 0x20 in bits 7:0 indicates 6 Mbps HT40 duplicate data + * + * Legacy OFDM rate format for bits 7:0 (bit 8 must be "0", bit 9 "0"): + * 3-0: 0xD) 6 Mbps + * 0xF) 9 Mbps + * 0x5) 12 Mbps + * 0x7) 18 Mbps + * 0x9) 24 Mbps + * 0xB) 36 Mbps + * 0x1) 48 Mbps + * 0x3) 54 Mbps + * + * Legacy CCK rate format for bits 7:0 (bit 8 must be "0", bit 9 "1"): + * 6-0: 10) 1 Mbps + * 20) 2 Mbps + * 55) 5.5 Mbps + * 110) 11 Mbps + */ +#define RATE_MCS_CODE_MSK 0x7 +#define RATE_MCS_SPATIAL_POS 3 +#define RATE_MCS_SPATIAL_MSK 0x18 +#define RATE_MCS_HT_DUP_POS 5 +#define RATE_MCS_HT_DUP_MSK 0x20 + +/* Bit 8: (1) HT format, (0) legacy format in bits 7:0 */ +#define RATE_MCS_FLAGS_POS 8 +#define RATE_MCS_HT_POS 8 +#define RATE_MCS_HT_MSK 0x100 + +/* Bit 9: (1) CCK, (0) OFDM. HT (bit 8) must be "0" for this bit to be valid */ +#define RATE_MCS_CCK_POS 9 +#define RATE_MCS_CCK_MSK 0x200 + +/* Bit 10: (1) Use Green Field preamble */ +#define RATE_MCS_GF_POS 10 +#define RATE_MCS_GF_MSK 0x400 + +/* Bit 11: (1) Use 40Mhz HT40 chnl width, (0) use 20 MHz legacy chnl width */ +#define RATE_MCS_HT40_POS 11 +#define RATE_MCS_HT40_MSK 0x800 + +/* Bit 12: (1) Duplicate data on both 20MHz chnls. HT40 (bit 11) must be set. */ +#define RATE_MCS_DUP_POS 12 +#define RATE_MCS_DUP_MSK 0x1000 + +/* Bit 13: (1) Short guard interval (0.4 usec), (0) normal GI (0.8 usec) */ +#define RATE_MCS_SGI_POS 13 +#define RATE_MCS_SGI_MSK 0x2000 + +/** + * rate_n_flags Tx antenna masks + * 4965 has 2 transmitters + * bit14:16 + */ +#define RATE_MCS_ANT_POS 14 +#define RATE_MCS_ANT_A_MSK 0x04000 +#define RATE_MCS_ANT_B_MSK 0x08000 +#define RATE_MCS_ANT_C_MSK 0x10000 +#define RATE_MCS_ANT_AB_MSK (RATE_MCS_ANT_A_MSK | RATE_MCS_ANT_B_MSK) +#define RATE_MCS_ANT_ABC_MSK (RATE_MCS_ANT_AB_MSK | RATE_MCS_ANT_C_MSK) +#define RATE_ANT_NUM 3 + +#define POWER_TBL_NUM_ENTRIES 33 +#define POWER_TBL_NUM_HT_OFDM_ENTRIES 32 +#define POWER_TBL_CCK_ENTRY 32 + +#define IL_PWR_NUM_HT_OFDM_ENTRIES 24 +#define IL_PWR_CCK_ENTRIES 2 + +/** + * union il4965_tx_power_dual_stream + * + * Host format used for C_TX_PWR_TBL, C_CHANNEL_SWITCH + * Use __le32 version (struct tx_power_dual_stream) when building command. + * + * Driver provides radio gain and DSP attenuation settings to device in pairs, + * one value for each transmitter chain. The first value is for transmitter A, + * second for transmitter B. + * + * For SISO bit rates, both values in a pair should be identical. + * For MIMO rates, one value may be different from the other, + * in order to balance the Tx output between the two transmitters. + * + * See more details in doc for TXPOWER in 4965.h. + */ +union il4965_tx_power_dual_stream { + struct { + u8 radio_tx_gain[2]; + u8 dsp_predis_atten[2]; + } s; + u32 dw; +}; + +/** + * struct tx_power_dual_stream + * + * Table entries in C_TX_PWR_TBL, C_CHANNEL_SWITCH + * + * Same format as il_tx_power_dual_stream, but __le32 + */ +struct tx_power_dual_stream { + __le32 dw; +} __packed; + +/** + * struct il4965_tx_power_db + * + * Entire table within C_TX_PWR_TBL, C_CHANNEL_SWITCH + */ +struct il4965_tx_power_db { + struct tx_power_dual_stream power_tbl[POWER_TBL_NUM_ENTRIES]; +} __packed; + +/****************************************************************************** + * (0a) + * Alive and Error Commands & Responses: + * + *****************************************************************************/ + +#define UCODE_VALID_OK cpu_to_le32(0x1) +#define INITIALIZE_SUBTYPE (9) + +/* + * ("Initialize") N_ALIVE = 0x1 (response only, not a command) + * + * uCode issues this "initialize alive" notification once the initialization + * uCode image has completed its work, and is ready to load the runtime image. + * This is the *first* "alive" notification that the driver will receive after + * rebooting uCode; the "initialize" alive is indicated by subtype field == 9. + * + * See comments documenting "BSM" (bootstrap state machine). + * + * For 4965, this notification contains important calibration data for + * calculating txpower settings: + * + * 1) Power supply voltage indication. The voltage sensor outputs higher + * values for lower voltage, and vice verse. + * + * 2) Temperature measurement parameters, for each of two channel widths + * (20 MHz and 40 MHz) supported by the radios. Temperature sensing + * is done via one of the receiver chains, and channel width influences + * the results. + * + * 3) Tx gain compensation to balance 4965's 2 Tx chains for MIMO operation, + * for each of 5 frequency ranges. + */ +struct il_init_alive_resp { + u8 ucode_minor; + u8 ucode_major; + __le16 reserved1; + u8 sw_rev[8]; + u8 ver_type; + u8 ver_subtype; /* "9" for initialize alive */ + __le16 reserved2; + __le32 log_event_table_ptr; + __le32 error_event_table_ptr; + __le32 timestamp; + __le32 is_valid; + + /* calibration values from "initialize" uCode */ + __le32 voltage; /* signed, higher value is lower voltage */ + __le32 therm_r1[2]; /* signed, 1st for normal, 2nd for HT40 */ + __le32 therm_r2[2]; /* signed */ + __le32 therm_r3[2]; /* signed */ + __le32 therm_r4[2]; /* signed */ + __le32 tx_atten[5][2]; /* signed MIMO gain comp, 5 freq groups, + * 2 Tx chains */ +} __packed; + + +/** + * N_ALIVE = 0x1 (response only, not a command) + * + * uCode issues this "alive" notification once the runtime image is ready + * to receive commands from the driver. This is the *second* "alive" + * notification that the driver will receive after rebooting uCode; + * this "alive" is indicated by subtype field != 9. + * + * See comments documenting "BSM" (bootstrap state machine). + * + * This response includes two pointers to structures within the device's + * data SRAM (access via HBUS_TARG_MEM_* regs) that are useful for debugging: + * + * 1) log_event_table_ptr indicates base of the event log. This traces + * a 256-entry history of uCode execution within a circular buffer. + * Its header format is: + * + * __le32 log_size; log capacity (in number of entries) + * __le32 type; (1) timestamp with each entry, (0) no timestamp + * __le32 wraps; # times uCode has wrapped to top of circular buffer + * __le32 write_idx; next circular buffer entry that uCode would fill + * + * The header is followed by the circular buffer of log entries. Entries + * with timestamps have the following format: + * + * __le32 event_id; range 0 - 1500 + * __le32 timestamp; low 32 bits of TSF (of network, if associated) + * __le32 data; event_id-specific data value + * + * Entries without timestamps contain only event_id and data. + * + * + * 2) error_event_table_ptr indicates base of the error log. This contains + * information about any uCode error that occurs. For 4965, the format + * of the error log is: + * + * __le32 valid; (nonzero) valid, (0) log is empty + * __le32 error_id; type of error + * __le32 pc; program counter + * __le32 blink1; branch link + * __le32 blink2; branch link + * __le32 ilink1; interrupt link + * __le32 ilink2; interrupt link + * __le32 data1; error-specific data + * __le32 data2; error-specific data + * __le32 line; source code line of error + * __le32 bcon_time; beacon timer + * __le32 tsf_low; network timestamp function timer + * __le32 tsf_hi; network timestamp function timer + * __le32 gp1; GP1 timer register + * __le32 gp2; GP2 timer register + * __le32 gp3; GP3 timer register + * __le32 ucode_ver; uCode version + * __le32 hw_ver; HW Silicon version + * __le32 brd_ver; HW board version + * __le32 log_pc; log program counter + * __le32 frame_ptr; frame pointer + * __le32 stack_ptr; stack pointer + * __le32 hcmd; last host command + * __le32 isr0; isr status register LMPM_NIC_ISR0: rxtx_flag + * __le32 isr1; isr status register LMPM_NIC_ISR1: host_flag + * __le32 isr2; isr status register LMPM_NIC_ISR2: enc_flag + * __le32 isr3; isr status register LMPM_NIC_ISR3: time_flag + * __le32 isr4; isr status register LMPM_NIC_ISR4: wico interrupt + * __le32 isr_pref; isr status register LMPM_NIC_PREF_STAT + * __le32 wait_event; wait event() caller address + * __le32 l2p_control; L2pControlField + * __le32 l2p_duration; L2pDurationField + * __le32 l2p_mhvalid; L2pMhValidBits + * __le32 l2p_addr_match; L2pAddrMatchStat + * __le32 lmpm_pmg_sel; indicate which clocks are turned on (LMPM_PMG_SEL) + * __le32 u_timestamp; indicate when the date and time of the compilation + * __le32 reserved; + * + * The Linux driver can print both logs to the system log when a uCode error + * occurs. + */ +struct il_alive_resp { + u8 ucode_minor; + u8 ucode_major; + __le16 reserved1; + u8 sw_rev[8]; + u8 ver_type; + u8 ver_subtype; /* not "9" for runtime alive */ + __le16 reserved2; + __le32 log_event_table_ptr; /* SRAM address for event log */ + __le32 error_event_table_ptr; /* SRAM address for error log */ + __le32 timestamp; + __le32 is_valid; +} __packed; + +/* + * N_ERROR = 0x2 (response only, not a command) + */ +struct il_error_resp { + __le32 error_type; + u8 cmd_id; + u8 reserved1; + __le16 bad_cmd_seq_num; + __le32 error_info; + __le64 timestamp; +} __packed; + +/****************************************************************************** + * (1) + * RXON Commands & Responses: + * + *****************************************************************************/ + +/* + * Rx config defines & structure + */ +/* rx_config device types */ +enum { + RXON_DEV_TYPE_AP = 1, + RXON_DEV_TYPE_ESS = 3, + RXON_DEV_TYPE_IBSS = 4, + RXON_DEV_TYPE_SNIFFER = 6, +}; + + +#define RXON_RX_CHAIN_DRIVER_FORCE_MSK cpu_to_le16(0x1 << 0) +#define RXON_RX_CHAIN_DRIVER_FORCE_POS (0) +#define RXON_RX_CHAIN_VALID_MSK cpu_to_le16(0x7 << 1) +#define RXON_RX_CHAIN_VALID_POS (1) +#define RXON_RX_CHAIN_FORCE_SEL_MSK cpu_to_le16(0x7 << 4) +#define RXON_RX_CHAIN_FORCE_SEL_POS (4) +#define RXON_RX_CHAIN_FORCE_MIMO_SEL_MSK cpu_to_le16(0x7 << 7) +#define RXON_RX_CHAIN_FORCE_MIMO_SEL_POS (7) +#define RXON_RX_CHAIN_CNT_MSK cpu_to_le16(0x3 << 10) +#define RXON_RX_CHAIN_CNT_POS (10) +#define RXON_RX_CHAIN_MIMO_CNT_MSK cpu_to_le16(0x3 << 12) +#define RXON_RX_CHAIN_MIMO_CNT_POS (12) +#define RXON_RX_CHAIN_MIMO_FORCE_MSK cpu_to_le16(0x1 << 14) +#define RXON_RX_CHAIN_MIMO_FORCE_POS (14) + +/* rx_config flags */ +/* band & modulation selection */ +#define RXON_FLG_BAND_24G_MSK cpu_to_le32(1 << 0) +#define RXON_FLG_CCK_MSK cpu_to_le32(1 << 1) +/* auto detection enable */ +#define RXON_FLG_AUTO_DETECT_MSK cpu_to_le32(1 << 2) +/* TGg protection when tx */ +#define RXON_FLG_TGG_PROTECT_MSK cpu_to_le32(1 << 3) +/* cck short slot & preamble */ +#define RXON_FLG_SHORT_SLOT_MSK cpu_to_le32(1 << 4) +#define RXON_FLG_SHORT_PREAMBLE_MSK cpu_to_le32(1 << 5) +/* antenna selection */ +#define RXON_FLG_DIS_DIV_MSK cpu_to_le32(1 << 7) +#define RXON_FLG_ANT_SEL_MSK cpu_to_le32(0x0f00) +#define RXON_FLG_ANT_A_MSK cpu_to_le32(1 << 8) +#define RXON_FLG_ANT_B_MSK cpu_to_le32(1 << 9) +/* radar detection enable */ +#define RXON_FLG_RADAR_DETECT_MSK cpu_to_le32(1 << 12) +#define RXON_FLG_TGJ_NARROW_BAND_MSK cpu_to_le32(1 << 13) +/* rx response to host with 8-byte TSF +* (according to ON_AIR deassertion) */ +#define RXON_FLG_TSF2HOST_MSK cpu_to_le32(1 << 15) + + +/* HT flags */ +#define RXON_FLG_CTRL_CHANNEL_LOC_POS (22) +#define RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK cpu_to_le32(0x1 << 22) + +#define RXON_FLG_HT_OPERATING_MODE_POS (23) + +#define RXON_FLG_HT_PROT_MSK cpu_to_le32(0x1 << 23) +#define RXON_FLG_HT40_PROT_MSK cpu_to_le32(0x2 << 23) + +#define RXON_FLG_CHANNEL_MODE_POS (25) +#define RXON_FLG_CHANNEL_MODE_MSK cpu_to_le32(0x3 << 25) + +/* channel mode */ +enum { + CHANNEL_MODE_LEGACY = 0, + CHANNEL_MODE_PURE_40 = 1, + CHANNEL_MODE_MIXED = 2, + CHANNEL_MODE_RESERVED = 3, +}; +#define RXON_FLG_CHANNEL_MODE_LEGACY \ + cpu_to_le32(CHANNEL_MODE_LEGACY << RXON_FLG_CHANNEL_MODE_POS) +#define RXON_FLG_CHANNEL_MODE_PURE_40 \ + cpu_to_le32(CHANNEL_MODE_PURE_40 << RXON_FLG_CHANNEL_MODE_POS) +#define RXON_FLG_CHANNEL_MODE_MIXED \ + cpu_to_le32(CHANNEL_MODE_MIXED << RXON_FLG_CHANNEL_MODE_POS) + +/* CTS to self (if spec allows) flag */ +#define RXON_FLG_SELF_CTS_EN cpu_to_le32(0x1<<30) + +/* rx_config filter flags */ +/* accept all data frames */ +#define RXON_FILTER_PROMISC_MSK cpu_to_le32(1 << 0) +/* pass control & management to host */ +#define RXON_FILTER_CTL2HOST_MSK cpu_to_le32(1 << 1) +/* accept multi-cast */ +#define RXON_FILTER_ACCEPT_GRP_MSK cpu_to_le32(1 << 2) +/* don't decrypt uni-cast frames */ +#define RXON_FILTER_DIS_DECRYPT_MSK cpu_to_le32(1 << 3) +/* don't decrypt multi-cast frames */ +#define RXON_FILTER_DIS_GRP_DECRYPT_MSK cpu_to_le32(1 << 4) +/* STA is associated */ +#define RXON_FILTER_ASSOC_MSK cpu_to_le32(1 << 5) +/* transfer to host non bssid beacons in associated state */ +#define RXON_FILTER_BCON_AWARE_MSK cpu_to_le32(1 << 6) + +/** + * C_RXON = 0x10 (command, has simple generic response) + * + * RXON tunes the radio tuner to a service channel, and sets up a number + * of parameters that are used primarily for Rx, but also for Tx operations. + * + * NOTE: When tuning to a new channel, driver must set the + * RXON_FILTER_ASSOC_MSK to 0. This will clear station-dependent + * info within the device, including the station tables, tx retry + * rate tables, and txpower tables. Driver must build a new station + * table and txpower table before transmitting anything on the RXON + * channel. + * + * NOTE: All RXONs wipe clean the internal txpower table. Driver must + * issue a new C_TX_PWR_TBL after each C_RXON (0x10), + * regardless of whether RXON_FILTER_ASSOC_MSK is set. + */ + +struct il3945_rxon_cmd { + u8 node_addr[6]; + __le16 reserved1; + u8 bssid_addr[6]; + __le16 reserved2; + u8 wlap_bssid_addr[6]; + __le16 reserved3; + u8 dev_type; + u8 air_propagation; + __le16 reserved4; + u8 ofdm_basic_rates; + u8 cck_basic_rates; + __le16 assoc_id; + __le32 flags; + __le32 filter_flags; + __le16 channel; + __le16 reserved5; +} __packed; + +struct il4965_rxon_cmd { + u8 node_addr[6]; + __le16 reserved1; + u8 bssid_addr[6]; + __le16 reserved2; + u8 wlap_bssid_addr[6]; + __le16 reserved3; + u8 dev_type; + u8 air_propagation; + __le16 rx_chain; + u8 ofdm_basic_rates; + u8 cck_basic_rates; + __le16 assoc_id; + __le32 flags; + __le32 filter_flags; + __le16 channel; + u8 ofdm_ht_single_stream_basic_rates; + u8 ofdm_ht_dual_stream_basic_rates; +} __packed; + +/* Create a common rxon cmd which will be typecast into the 3945 or 4965 + * specific rxon cmd, depending on where it is called from. + */ +struct il_rxon_cmd { + u8 node_addr[6]; + __le16 reserved1; + u8 bssid_addr[6]; + __le16 reserved2; + u8 wlap_bssid_addr[6]; + __le16 reserved3; + u8 dev_type; + u8 air_propagation; + __le16 rx_chain; + u8 ofdm_basic_rates; + u8 cck_basic_rates; + __le16 assoc_id; + __le32 flags; + __le32 filter_flags; + __le16 channel; + u8 ofdm_ht_single_stream_basic_rates; + u8 ofdm_ht_dual_stream_basic_rates; + u8 reserved4; + u8 reserved5; +} __packed; + + +/* + * C_RXON_ASSOC = 0x11 (command, has simple generic response) + */ +struct il3945_rxon_assoc_cmd { + __le32 flags; + __le32 filter_flags; + u8 ofdm_basic_rates; + u8 cck_basic_rates; + __le16 reserved; +} __packed; + +struct il4965_rxon_assoc_cmd { + __le32 flags; + __le32 filter_flags; + u8 ofdm_basic_rates; + u8 cck_basic_rates; + u8 ofdm_ht_single_stream_basic_rates; + u8 ofdm_ht_dual_stream_basic_rates; + __le16 rx_chain_select_flags; + __le16 reserved; +} __packed; + +#define IL_CONN_MAX_LISTEN_INTERVAL 10 +#define IL_MAX_UCODE_BEACON_INTERVAL 4 /* 4096 */ +#define IL39_MAX_UCODE_BEACON_INTERVAL 1 /* 1024 */ + +/* + * C_RXON_TIMING = 0x14 (command, has simple generic response) + */ +struct il_rxon_time_cmd { + __le64 timestamp; + __le16 beacon_interval; + __le16 atim_win; + __le32 beacon_init_val; + __le16 listen_interval; + u8 dtim_period; + u8 delta_cp_bss_tbtts; +} __packed; + +/* + * C_CHANNEL_SWITCH = 0x72 (command, has simple generic response) + */ +struct il3945_channel_switch_cmd { + u8 band; + u8 expect_beacon; + __le16 channel; + __le32 rxon_flags; + __le32 rxon_filter_flags; + __le32 switch_time; + struct il3945_power_per_rate power[IL_MAX_RATES]; +} __packed; + +struct il4965_channel_switch_cmd { + u8 band; + u8 expect_beacon; + __le16 channel; + __le32 rxon_flags; + __le32 rxon_filter_flags; + __le32 switch_time; + struct il4965_tx_power_db tx_power; +} __packed; + +/* + * N_CHANNEL_SWITCH = 0x73 (notification only, not a command) + */ +struct il_csa_notification { + __le16 band; + __le16 channel; + __le32 status; /* 0 - OK, 1 - fail */ +} __packed; + +/****************************************************************************** + * (2) + * Quality-of-Service (QOS) Commands & Responses: + * + *****************************************************************************/ + +/** + * struct il_ac_qos -- QOS timing params for C_QOS_PARAM + * One for each of 4 EDCA access categories in struct il_qosparam_cmd + * + * @cw_min: Contention win, start value in numbers of slots. + * Should be a power-of-2, minus 1. Device's default is 0x0f. + * @cw_max: Contention win, max value in numbers of slots. + * Should be a power-of-2, minus 1. Device's default is 0x3f. + * @aifsn: Number of slots in Arbitration Interframe Space (before + * performing random backoff timing prior to Tx). Device default 1. + * @edca_txop: Length of Tx opportunity, in uSecs. Device default is 0. + * + * Device will automatically increase contention win by (2*CW) + 1 for each + * transmission retry. Device uses cw_max as a bit mask, ANDed with new CW + * value, to cap the CW value. + */ +struct il_ac_qos { + __le16 cw_min; + __le16 cw_max; + u8 aifsn; + u8 reserved1; + __le16 edca_txop; +} __packed; + +/* QoS flags defines */ +#define QOS_PARAM_FLG_UPDATE_EDCA_MSK cpu_to_le32(0x01) +#define QOS_PARAM_FLG_TGN_MSK cpu_to_le32(0x02) +#define QOS_PARAM_FLG_TXOP_TYPE_MSK cpu_to_le32(0x10) + +/* Number of Access Categories (AC) (EDCA), queues 0..3 */ +#define AC_NUM 4 + +/* + * C_QOS_PARAM = 0x13 (command, has simple generic response) + * + * This command sets up timings for each of the 4 prioritized EDCA Tx FIFOs + * 0: Background, 1: Best Effort, 2: Video, 3: Voice. + */ +struct il_qosparam_cmd { + __le32 qos_flags; + struct il_ac_qos ac[AC_NUM]; +} __packed; + +/****************************************************************************** + * (3) + * Add/Modify Stations Commands & Responses: + * + *****************************************************************************/ +/* + * Multi station support + */ + +/* Special, dedicated locations within device's station table */ +#define IL_AP_ID 0 +#define IL_STA_ID 2 +#define IL3945_BROADCAST_ID 24 +#define IL3945_STATION_COUNT 25 +#define IL4965_BROADCAST_ID 31 +#define IL4965_STATION_COUNT 32 + +#define IL_STATION_COUNT 32 /* MAX(3945,4965)*/ +#define IL_INVALID_STATION 255 + +#define STA_FLG_TX_RATE_MSK cpu_to_le32(1 << 2) +#define STA_FLG_PWR_SAVE_MSK cpu_to_le32(1 << 8) +#define STA_FLG_RTS_MIMO_PROT_MSK cpu_to_le32(1 << 17) +#define STA_FLG_AGG_MPDU_8US_MSK cpu_to_le32(1 << 18) +#define STA_FLG_MAX_AGG_SIZE_POS (19) +#define STA_FLG_MAX_AGG_SIZE_MSK cpu_to_le32(3 << 19) +#define STA_FLG_HT40_EN_MSK cpu_to_le32(1 << 21) +#define STA_FLG_MIMO_DIS_MSK cpu_to_le32(1 << 22) +#define STA_FLG_AGG_MPDU_DENSITY_POS (23) +#define STA_FLG_AGG_MPDU_DENSITY_MSK cpu_to_le32(7 << 23) + +/* Use in mode field. 1: modify existing entry, 0: add new station entry */ +#define STA_CONTROL_MODIFY_MSK 0x01 + +/* key flags __le16*/ +#define STA_KEY_FLG_ENCRYPT_MSK cpu_to_le16(0x0007) +#define STA_KEY_FLG_NO_ENC cpu_to_le16(0x0000) +#define STA_KEY_FLG_WEP cpu_to_le16(0x0001) +#define STA_KEY_FLG_CCMP cpu_to_le16(0x0002) +#define STA_KEY_FLG_TKIP cpu_to_le16(0x0003) + +#define STA_KEY_FLG_KEYID_POS 8 +#define STA_KEY_FLG_INVALID cpu_to_le16(0x0800) +/* wep key is either from global key (0) or from station info array (1) */ +#define STA_KEY_FLG_MAP_KEY_MSK cpu_to_le16(0x0008) + +/* wep key in STA: 5-bytes (0) or 13-bytes (1) */ +#define STA_KEY_FLG_KEY_SIZE_MSK cpu_to_le16(0x1000) +#define STA_KEY_MULTICAST_MSK cpu_to_le16(0x4000) +#define STA_KEY_MAX_NUM 8 + +/* Flags indicate whether to modify vs. don't change various station params */ +#define STA_MODIFY_KEY_MASK 0x01 +#define STA_MODIFY_TID_DISABLE_TX 0x02 +#define STA_MODIFY_TX_RATE_MSK 0x04 +#define STA_MODIFY_ADDBA_TID_MSK 0x08 +#define STA_MODIFY_DELBA_TID_MSK 0x10 +#define STA_MODIFY_SLEEP_TX_COUNT_MSK 0x20 + +/* Receiver address (actually, Rx station's idx into station table), + * combined with Traffic ID (QOS priority), in format used by Tx Scheduler */ +#define BUILD_RAxTID(sta_id, tid) (((sta_id) << 4) + (tid)) + +struct il4965_keyinfo { + __le16 key_flags; + u8 tkip_rx_tsc_byte2; /* TSC[2] for key mix ph1 detection */ + u8 reserved1; + __le16 tkip_rx_ttak[5]; /* 10-byte unicast TKIP TTAK */ + u8 key_offset; + u8 reserved2; + u8 key[16]; /* 16-byte unicast decryption key */ +} __packed; + +/** + * struct sta_id_modify + * @addr[ETH_ALEN]: station's MAC address + * @sta_id: idx of station in uCode's station table + * @modify_mask: STA_MODIFY_*, 1: modify, 0: don't change + * + * Driver selects unused table idx when adding new station, + * or the idx to a pre-existing station entry when modifying that station. + * Some idxes have special purposes (IL_AP_ID, idx 0, is for AP). + * + * modify_mask flags select which parameters to modify vs. leave alone. + */ +struct sta_id_modify { + u8 addr[ETH_ALEN]; + __le16 reserved1; + u8 sta_id; + u8 modify_mask; + __le16 reserved2; +} __packed; + +/* + * C_ADD_STA = 0x18 (command) + * + * The device contains an internal table of per-station information, + * with info on security keys, aggregation parameters, and Tx rates for + * initial Tx attempt and any retries (4965 devices uses + * C_TX_LINK_QUALITY_CMD, + * 3945 uses C_RATE_SCALE to set up rate tables). + * + * C_ADD_STA sets up the table entry for one station, either creating + * a new entry, or modifying a pre-existing one. + * + * NOTE: RXON command (without "associated" bit set) wipes the station table + * clean. Moving into RF_KILL state does this also. Driver must set up + * new station table before transmitting anything on the RXON channel + * (except active scans or active measurements; those commands carry + * their own txpower/rate setup data). + * + * When getting started on a new channel, driver must set up the + * IL_BROADCAST_ID entry (last entry in the table). For a client + * station in a BSS, once an AP is selected, driver sets up the AP STA + * in the IL_AP_ID entry (1st entry in the table). BROADCAST and AP + * are all that are needed for a BSS client station. If the device is + * used as AP, or in an IBSS network, driver must set up station table + * entries for all STAs in network, starting with idx IL_STA_ID. + */ + +struct il3945_addsta_cmd { + u8 mode; /* 1: modify existing, 0: add new station */ + u8 reserved[3]; + struct sta_id_modify sta; + struct il4965_keyinfo key; + __le32 station_flags; /* STA_FLG_* */ + __le32 station_flags_msk; /* STA_FLG_* */ + + /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID) + * corresponding to bit (e.g. bit 5 controls TID 5). + * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */ + __le16 tid_disable_tx; + + __le16 rate_n_flags; + + /* TID for which to add block-ack support. + * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ + u8 add_immediate_ba_tid; + + /* TID for which to remove block-ack support. + * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */ + u8 remove_immediate_ba_tid; + + /* Starting Sequence Number for added block-ack support. + * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ + __le16 add_immediate_ba_ssn; +} __packed; + +struct il4965_addsta_cmd { + u8 mode; /* 1: modify existing, 0: add new station */ + u8 reserved[3]; + struct sta_id_modify sta; + struct il4965_keyinfo key; + __le32 station_flags; /* STA_FLG_* */ + __le32 station_flags_msk; /* STA_FLG_* */ + + /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID) + * corresponding to bit (e.g. bit 5 controls TID 5). + * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */ + __le16 tid_disable_tx; + + __le16 reserved1; + + /* TID for which to add block-ack support. + * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ + u8 add_immediate_ba_tid; + + /* TID for which to remove block-ack support. + * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */ + u8 remove_immediate_ba_tid; + + /* Starting Sequence Number for added block-ack support. + * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ + __le16 add_immediate_ba_ssn; + + /* + * Number of packets OK to transmit to station even though + * it is asleep -- used to synchronise PS-poll and u-APSD + * responses while ucode keeps track of STA sleep state. + */ + __le16 sleep_tx_count; + + __le16 reserved2; +} __packed; + +/* Wrapper struct for 3945 and 4965 addsta_cmd structures */ +struct il_addsta_cmd { + u8 mode; /* 1: modify existing, 0: add new station */ + u8 reserved[3]; + struct sta_id_modify sta; + struct il4965_keyinfo key; + __le32 station_flags; /* STA_FLG_* */ + __le32 station_flags_msk; /* STA_FLG_* */ + + /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID) + * corresponding to bit (e.g. bit 5 controls TID 5). + * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */ + __le16 tid_disable_tx; + + __le16 rate_n_flags; /* 3945 only */ + + /* TID for which to add block-ack support. + * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ + u8 add_immediate_ba_tid; + + /* TID for which to remove block-ack support. + * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */ + u8 remove_immediate_ba_tid; + + /* Starting Sequence Number for added block-ack support. + * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ + __le16 add_immediate_ba_ssn; + + /* + * Number of packets OK to transmit to station even though + * it is asleep -- used to synchronise PS-poll and u-APSD + * responses while ucode keeps track of STA sleep state. + */ + __le16 sleep_tx_count; + + __le16 reserved2; +} __packed; + + +#define ADD_STA_SUCCESS_MSK 0x1 +#define ADD_STA_NO_ROOM_IN_TBL 0x2 +#define ADD_STA_NO_BLOCK_ACK_RESOURCE 0x4 +#define ADD_STA_MODIFY_NON_EXIST_STA 0x8 +/* + * C_ADD_STA = 0x18 (response) + */ +struct il_add_sta_resp { + u8 status; /* ADD_STA_* */ +} __packed; + +#define REM_STA_SUCCESS_MSK 0x1 +/* + * C_REM_STA = 0x19 (response) + */ +struct il_rem_sta_resp { + u8 status; +} __packed; + +/* + * C_REM_STA = 0x19 (command) + */ +struct il_rem_sta_cmd { + u8 num_sta; /* number of removed stations */ + u8 reserved[3]; + u8 addr[ETH_ALEN]; /* MAC addr of the first station */ + u8 reserved2[2]; +} __packed; + +#define IL_TX_FIFO_BK_MSK cpu_to_le32(BIT(0)) +#define IL_TX_FIFO_BE_MSK cpu_to_le32(BIT(1)) +#define IL_TX_FIFO_VI_MSK cpu_to_le32(BIT(2)) +#define IL_TX_FIFO_VO_MSK cpu_to_le32(BIT(3)) +#define IL_AGG_TX_QUEUE_MSK cpu_to_le32(0xffc00) + +#define IL_DROP_SINGLE 0 +#define IL_DROP_SELECTED 1 +#define IL_DROP_ALL 2 + +/* + * REPLY_WEP_KEY = 0x20 + */ +struct il_wep_key { + u8 key_idx; + u8 key_offset; + u8 reserved1[2]; + u8 key_size; + u8 reserved2[3]; + u8 key[16]; +} __packed; + +struct il_wep_cmd { + u8 num_keys; + u8 global_key_type; + u8 flags; + u8 reserved; + struct il_wep_key key[0]; +} __packed; + +#define WEP_KEY_WEP_TYPE 1 +#define WEP_KEYS_MAX 4 +#define WEP_INVALID_OFFSET 0xff +#define WEP_KEY_LEN_64 5 +#define WEP_KEY_LEN_128 13 + +/****************************************************************************** + * (4) + * Rx Responses: + * + *****************************************************************************/ + +#define RX_RES_STATUS_NO_CRC32_ERROR cpu_to_le32(1 << 0) +#define RX_RES_STATUS_NO_RXE_OVERFLOW cpu_to_le32(1 << 1) + +#define RX_RES_PHY_FLAGS_BAND_24_MSK cpu_to_le16(1 << 0) +#define RX_RES_PHY_FLAGS_MOD_CCK_MSK cpu_to_le16(1 << 1) +#define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK cpu_to_le16(1 << 2) +#define RX_RES_PHY_FLAGS_NARROW_BAND_MSK cpu_to_le16(1 << 3) +#define RX_RES_PHY_FLAGS_ANTENNA_MSK 0xf0 +#define RX_RES_PHY_FLAGS_ANTENNA_POS 4 + +#define RX_RES_STATUS_SEC_TYPE_MSK (0x7 << 8) +#define RX_RES_STATUS_SEC_TYPE_NONE (0x0 << 8) +#define RX_RES_STATUS_SEC_TYPE_WEP (0x1 << 8) +#define RX_RES_STATUS_SEC_TYPE_CCMP (0x2 << 8) +#define RX_RES_STATUS_SEC_TYPE_TKIP (0x3 << 8) +#define RX_RES_STATUS_SEC_TYPE_ERR (0x7 << 8) + +#define RX_RES_STATUS_STATION_FOUND (1<<6) +#define RX_RES_STATUS_NO_STATION_INFO_MISMATCH (1<<7) + +#define RX_RES_STATUS_DECRYPT_TYPE_MSK (0x3 << 11) +#define RX_RES_STATUS_NOT_DECRYPT (0x0 << 11) +#define RX_RES_STATUS_DECRYPT_OK (0x3 << 11) +#define RX_RES_STATUS_BAD_ICV_MIC (0x1 << 11) +#define RX_RES_STATUS_BAD_KEY_TTAK (0x2 << 11) + +#define RX_MPDU_RES_STATUS_ICV_OK (0x20) +#define RX_MPDU_RES_STATUS_MIC_OK (0x40) +#define RX_MPDU_RES_STATUS_TTAK_OK (1 << 7) +#define RX_MPDU_RES_STATUS_DEC_DONE_MSK (0x800) + + +struct il3945_rx_frame_stats { + u8 phy_count; + u8 id; + u8 rssi; + u8 agc; + __le16 sig_avg; + __le16 noise_diff; + u8 payload[0]; +} __packed; + +struct il3945_rx_frame_hdr { + __le16 channel; + __le16 phy_flags; + u8 reserved1; + u8 rate; + __le16 len; + u8 payload[0]; +} __packed; + +struct il3945_rx_frame_end { + __le32 status; + __le64 timestamp; + __le32 beacon_timestamp; +} __packed; + +/* + * N_3945_RX = 0x1b (response only, not a command) + * + * NOTE: DO NOT dereference from casts to this structure + * It is provided only for calculating minimum data set size. + * The actual offsets of the hdr and end are dynamic based on + * stats.phy_count + */ +struct il3945_rx_frame { + struct il3945_rx_frame_stats stats; + struct il3945_rx_frame_hdr hdr; + struct il3945_rx_frame_end end; +} __packed; + +#define IL39_RX_FRAME_SIZE (4 + sizeof(struct il3945_rx_frame)) + +/* Fixed (non-configurable) rx data from phy */ + +#define IL49_RX_RES_PHY_CNT 14 +#define IL49_RX_PHY_FLAGS_ANTENNAE_OFFSET (4) +#define IL49_RX_PHY_FLAGS_ANTENNAE_MASK (0x70) +#define IL49_AGC_DB_MASK (0x3f80) /* MASK(7,13) */ +#define IL49_AGC_DB_POS (7) +struct il4965_rx_non_cfg_phy { + __le16 ant_selection; /* ant A bit 4, ant B bit 5, ant C bit 6 */ + __le16 agc_info; /* agc code 0:6, agc dB 7:13, reserved 14:15 */ + u8 rssi_info[6]; /* we use even entries, 0/2/4 for A/B/C rssi */ + u8 pad[0]; +} __packed; + + +/* + * N_RX = 0xc3 (response only, not a command) + * Used only for legacy (non 11n) frames. + */ +struct il_rx_phy_res { + u8 non_cfg_phy_cnt; /* non configurable DSP phy data byte count */ + u8 cfg_phy_cnt; /* configurable DSP phy data byte count */ + u8 stat_id; /* configurable DSP phy data set ID */ + u8 reserved1; + __le64 timestamp; /* TSF at on air rise */ + __le32 beacon_time_stamp; /* beacon at on-air rise */ + __le16 phy_flags; /* general phy flags: band, modulation, ... */ + __le16 channel; /* channel number */ + u8 non_cfg_phy_buf[32]; /* for various implementations of non_cfg_phy */ + __le32 rate_n_flags; /* RATE_MCS_* */ + __le16 byte_count; /* frame's byte-count */ + __le16 frame_time; /* frame's time on the air */ +} __packed; + +struct il_rx_mpdu_res_start { + __le16 byte_count; + __le16 reserved; +} __packed; + + +/****************************************************************************** + * (5) + * Tx Commands & Responses: + * + * Driver must place each C_TX command into one of the prioritized Tx + * queues in host DRAM, shared between driver and device (see comments for + * SCD registers and Tx/Rx Queues). When the device's Tx scheduler and uCode + * are preparing to transmit, the device pulls the Tx command over the PCI + * bus via one of the device's Tx DMA channels, to fill an internal FIFO + * from which data will be transmitted. + * + * uCode handles all timing and protocol related to control frames + * (RTS/CTS/ACK), based on flags in the Tx command. uCode and Tx scheduler + * handle reception of block-acks; uCode updates the host driver via + * N_COMPRESSED_BA. + * + * uCode handles retrying Tx when an ACK is expected but not received. + * This includes trying lower data rates than the one requested in the Tx + * command, as set up by the C_RATE_SCALE (for 3945) or + * C_TX_LINK_QUALITY_CMD (4965). + * + * Driver sets up transmit power for various rates via C_TX_PWR_TBL. + * This command must be executed after every RXON command, before Tx can occur. + *****************************************************************************/ + +/* C_TX Tx flags field */ + +/* + * 1: Use Request-To-Send protocol before this frame. + * Mutually exclusive vs. TX_CMD_FLG_CTS_MSK. + */ +#define TX_CMD_FLG_RTS_MSK cpu_to_le32(1 << 1) + +/* + * 1: Transmit Clear-To-Send to self before this frame. + * Driver should set this for AUTH/DEAUTH/ASSOC-REQ/REASSOC mgmnt frames. + * Mutually exclusive vs. TX_CMD_FLG_RTS_MSK. + */ +#define TX_CMD_FLG_CTS_MSK cpu_to_le32(1 << 2) + +/* 1: Expect ACK from receiving station + * 0: Don't expect ACK (MAC header's duration field s/b 0) + * Set this for unicast frames, but not broadcast/multicast. */ +#define TX_CMD_FLG_ACK_MSK cpu_to_le32(1 << 3) + +/* For 4965 devices: + * 1: Use rate scale table (see C_TX_LINK_QUALITY_CMD). + * Tx command's initial_rate_idx indicates first rate to try; + * uCode walks through table for additional Tx attempts. + * 0: Use Tx rate/MCS from Tx command's rate_n_flags field. + * This rate will be used for all Tx attempts; it will not be scaled. */ +#define TX_CMD_FLG_STA_RATE_MSK cpu_to_le32(1 << 4) + +/* 1: Expect immediate block-ack. + * Set when Txing a block-ack request frame. Also set TX_CMD_FLG_ACK_MSK. */ +#define TX_CMD_FLG_IMM_BA_RSP_MASK cpu_to_le32(1 << 6) + +/* + * 1: Frame requires full Tx-Op protection. + * Set this if either RTS or CTS Tx Flag gets set. + */ +#define TX_CMD_FLG_FULL_TXOP_PROT_MSK cpu_to_le32(1 << 7) + +/* Tx antenna selection field; used only for 3945, reserved (0) for 4965 devices. + * Set field to "0" to allow 3945 uCode to select antenna (normal usage). */ +#define TX_CMD_FLG_ANT_SEL_MSK cpu_to_le32(0xf00) +#define TX_CMD_FLG_ANT_A_MSK cpu_to_le32(1 << 8) +#define TX_CMD_FLG_ANT_B_MSK cpu_to_le32(1 << 9) + +/* 1: uCode overrides sequence control field in MAC header. + * 0: Driver provides sequence control field in MAC header. + * Set this for management frames, non-QOS data frames, non-unicast frames, + * and also in Tx command embedded in C_SCAN for active scans. */ +#define TX_CMD_FLG_SEQ_CTL_MSK cpu_to_le32(1 << 13) + +/* 1: This frame is non-last MPDU; more fragments are coming. + * 0: Last fragment, or not using fragmentation. */ +#define TX_CMD_FLG_MORE_FRAG_MSK cpu_to_le32(1 << 14) + +/* 1: uCode calculates and inserts Timestamp Function (TSF) in outgoing frame. + * 0: No TSF required in outgoing frame. + * Set this for transmitting beacons and probe responses. */ +#define TX_CMD_FLG_TSF_MSK cpu_to_le32(1 << 16) + +/* 1: Driver inserted 2 bytes pad after the MAC header, for (required) dword + * alignment of frame's payload data field. + * 0: No pad + * Set this for MAC headers with 26 or 30 bytes, i.e. those with QOS or ADDR4 + * field (but not both). Driver must align frame data (i.e. data following + * MAC header) to DWORD boundary. */ +#define TX_CMD_FLG_MH_PAD_MSK cpu_to_le32(1 << 20) + +/* accelerate aggregation support + * 0 - no CCMP encryption; 1 - CCMP encryption */ +#define TX_CMD_FLG_AGG_CCMP_MSK cpu_to_le32(1 << 22) + +/* HCCA-AP - disable duration overwriting. */ +#define TX_CMD_FLG_DUR_MSK cpu_to_le32(1 << 25) + + +/* + * TX command security control + */ +#define TX_CMD_SEC_WEP 0x01 +#define TX_CMD_SEC_CCM 0x02 +#define TX_CMD_SEC_TKIP 0x03 +#define TX_CMD_SEC_MSK 0x03 +#define TX_CMD_SEC_SHIFT 6 +#define TX_CMD_SEC_KEY128 0x08 + +/* + * security overhead sizes + */ +#define WEP_IV_LEN 4 +#define WEP_ICV_LEN 4 +#define CCMP_MIC_LEN 8 +#define TKIP_ICV_LEN 4 + +/* + * C_TX = 0x1c (command) + */ + +struct il3945_tx_cmd { + /* + * MPDU byte count: + * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size, + * + 8 byte IV for CCM or TKIP (not used for WEP) + * + Data payload + * + 8-byte MIC (not used for CCM/WEP) + * NOTE: Does not include Tx command bytes, post-MAC pad bytes, + * MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i + * Range: 14-2342 bytes. + */ + __le16 len; + + /* + * MPDU or MSDU byte count for next frame. + * Used for fragmentation and bursting, but not 11n aggregation. + * Same as "len", but for next frame. Set to 0 if not applicable. + */ + __le16 next_frame_len; + + __le32 tx_flags; /* TX_CMD_FLG_* */ + + u8 rate; + + /* Index of recipient station in uCode's station table */ + u8 sta_id; + u8 tid_tspec; + u8 sec_ctl; + u8 key[16]; + union { + u8 byte[8]; + __le16 word[4]; + __le32 dw[2]; + } tkip_mic; + __le32 next_frame_info; + union { + __le32 life_time; + __le32 attempt; + } stop_time; + u8 supp_rates[2]; + u8 rts_retry_limit; /*byte 50 */ + u8 data_retry_limit; /*byte 51 */ + union { + __le16 pm_frame_timeout; + __le16 attempt_duration; + } timeout; + + /* + * Duration of EDCA burst Tx Opportunity, in 32-usec units. + * Set this if txop time is not specified by HCCA protocol (e.g. by AP). + */ + __le16 driver_txop; + + /* + * MAC header goes here, followed by 2 bytes padding if MAC header + * length is 26 or 30 bytes, followed by payload data + */ + u8 payload[0]; + struct ieee80211_hdr hdr[0]; +} __packed; + +/* + * C_TX = 0x1c (response) + */ +struct il3945_tx_resp { + u8 failure_rts; + u8 failure_frame; + u8 bt_kill_count; + u8 rate; + __le32 wireless_media_time; + __le32 status; /* TX status */ +} __packed; + + +/* + * 4965 uCode updates these Tx attempt count values in host DRAM. + * Used for managing Tx retries when expecting block-acks. + * Driver should set these fields to 0. + */ +struct il_dram_scratch { + u8 try_cnt; /* Tx attempts */ + u8 bt_kill_cnt; /* Tx attempts blocked by Bluetooth device */ + __le16 reserved; +} __packed; + +struct il_tx_cmd { + /* + * MPDU byte count: + * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size, + * + 8 byte IV for CCM or TKIP (not used for WEP) + * + Data payload + * + 8-byte MIC (not used for CCM/WEP) + * NOTE: Does not include Tx command bytes, post-MAC pad bytes, + * MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i + * Range: 14-2342 bytes. + */ + __le16 len; + + /* + * MPDU or MSDU byte count for next frame. + * Used for fragmentation and bursting, but not 11n aggregation. + * Same as "len", but for next frame. Set to 0 if not applicable. + */ + __le16 next_frame_len; + + __le32 tx_flags; /* TX_CMD_FLG_* */ + + /* uCode may modify this field of the Tx command (in host DRAM!). + * Driver must also set dram_lsb_ptr and dram_msb_ptr in this cmd. */ + struct il_dram_scratch scratch; + + /* Rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is cleared. */ + __le32 rate_n_flags; /* RATE_MCS_* */ + + /* Index of destination station in uCode's station table */ + u8 sta_id; + + /* Type of security encryption: CCM or TKIP */ + u8 sec_ctl; /* TX_CMD_SEC_* */ + + /* + * Index into rate table (see C_TX_LINK_QUALITY_CMD) for initial + * Tx attempt, if TX_CMD_FLG_STA_RATE_MSK is set. Normally "0" for + * data frames, this field may be used to selectively reduce initial + * rate (via non-0 value) for special frames (e.g. management), while + * still supporting rate scaling for all frames. + */ + u8 initial_rate_idx; + u8 reserved; + u8 key[16]; + __le16 next_frame_flags; + __le16 reserved2; + union { + __le32 life_time; + __le32 attempt; + } stop_time; + + /* Host DRAM physical address pointer to "scratch" in this command. + * Must be dword aligned. "0" in dram_lsb_ptr disables usage. */ + __le32 dram_lsb_ptr; + u8 dram_msb_ptr; + + u8 rts_retry_limit; /*byte 50 */ + u8 data_retry_limit; /*byte 51 */ + u8 tid_tspec; + union { + __le16 pm_frame_timeout; + __le16 attempt_duration; + } timeout; + + /* + * Duration of EDCA burst Tx Opportunity, in 32-usec units. + * Set this if txop time is not specified by HCCA protocol (e.g. by AP). + */ + __le16 driver_txop; + + /* + * MAC header goes here, followed by 2 bytes padding if MAC header + * length is 26 or 30 bytes, followed by payload data + */ + u8 payload[0]; + struct ieee80211_hdr hdr[0]; +} __packed; + +/* TX command response is sent after *3945* transmission attempts. + * + * NOTES: + * + * TX_STATUS_FAIL_NEXT_FRAG + * + * If the fragment flag in the MAC header for the frame being transmitted + * is set and there is insufficient time to transmit the next frame, the + * TX status will be returned with 'TX_STATUS_FAIL_NEXT_FRAG'. + * + * TX_STATUS_FIFO_UNDERRUN + * + * Indicates the host did not provide bytes to the FIFO fast enough while + * a TX was in progress. + * + * TX_STATUS_FAIL_MGMNT_ABORT + * + * This status is only possible if the ABORT ON MGMT RX parameter was + * set to true with the TX command. + * + * If the MSB of the status parameter is set then an abort sequence is + * required. This sequence consists of the host activating the TX Abort + * control line, and then waiting for the TX Abort command response. This + * indicates that a the device is no longer in a transmit state, and that the + * command FIFO has been cleared. The host must then deactivate the TX Abort + * control line. Receiving is still allowed in this case. + */ +enum { + TX_3945_STATUS_SUCCESS = 0x01, + TX_3945_STATUS_DIRECT_DONE = 0x02, + TX_3945_STATUS_FAIL_SHORT_LIMIT = 0x82, + TX_3945_STATUS_FAIL_LONG_LIMIT = 0x83, + TX_3945_STATUS_FAIL_FIFO_UNDERRUN = 0x84, + TX_3945_STATUS_FAIL_MGMNT_ABORT = 0x85, + TX_3945_STATUS_FAIL_NEXT_FRAG = 0x86, + TX_3945_STATUS_FAIL_LIFE_EXPIRE = 0x87, + TX_3945_STATUS_FAIL_DEST_PS = 0x88, + TX_3945_STATUS_FAIL_ABORTED = 0x89, + TX_3945_STATUS_FAIL_BT_RETRY = 0x8a, + TX_3945_STATUS_FAIL_STA_INVALID = 0x8b, + TX_3945_STATUS_FAIL_FRAG_DROPPED = 0x8c, + TX_3945_STATUS_FAIL_TID_DISABLE = 0x8d, + TX_3945_STATUS_FAIL_FRAME_FLUSHED = 0x8e, + TX_3945_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f, + TX_3945_STATUS_FAIL_TX_LOCKED = 0x90, + TX_3945_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91, +}; + +/* + * TX command response is sent after *4965* transmission attempts. + * + * both postpone and abort status are expected behavior from uCode. there is + * no special operation required from driver; except for RFKILL_FLUSH, + * which required tx flush host command to flush all the tx frames in queues + */ +enum { + TX_STATUS_SUCCESS = 0x01, + TX_STATUS_DIRECT_DONE = 0x02, + /* postpone TX */ + TX_STATUS_POSTPONE_DELAY = 0x40, + TX_STATUS_POSTPONE_FEW_BYTES = 0x41, + TX_STATUS_POSTPONE_QUIET_PERIOD = 0x43, + TX_STATUS_POSTPONE_CALC_TTAK = 0x44, + /* abort TX */ + TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY = 0x81, + TX_STATUS_FAIL_SHORT_LIMIT = 0x82, + TX_STATUS_FAIL_LONG_LIMIT = 0x83, + TX_STATUS_FAIL_FIFO_UNDERRUN = 0x84, + TX_STATUS_FAIL_DRAIN_FLOW = 0x85, + TX_STATUS_FAIL_RFKILL_FLUSH = 0x86, + TX_STATUS_FAIL_LIFE_EXPIRE = 0x87, + TX_STATUS_FAIL_DEST_PS = 0x88, + TX_STATUS_FAIL_HOST_ABORTED = 0x89, + TX_STATUS_FAIL_BT_RETRY = 0x8a, + TX_STATUS_FAIL_STA_INVALID = 0x8b, + TX_STATUS_FAIL_FRAG_DROPPED = 0x8c, + TX_STATUS_FAIL_TID_DISABLE = 0x8d, + TX_STATUS_FAIL_FIFO_FLUSHED = 0x8e, + TX_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f, + TX_STATUS_FAIL_PASSIVE_NO_RX = 0x90, + TX_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91, +}; + +#define TX_PACKET_MODE_REGULAR 0x0000 +#define TX_PACKET_MODE_BURST_SEQ 0x0100 +#define TX_PACKET_MODE_BURST_FIRST 0x0200 + +enum { + TX_POWER_PA_NOT_ACTIVE = 0x0, +}; + +enum { + TX_STATUS_MSK = 0x000000ff, /* bits 0:7 */ + TX_STATUS_DELAY_MSK = 0x00000040, + TX_STATUS_ABORT_MSK = 0x00000080, + TX_PACKET_MODE_MSK = 0x0000ff00, /* bits 8:15 */ + TX_FIFO_NUMBER_MSK = 0x00070000, /* bits 16:18 */ + TX_RESERVED = 0x00780000, /* bits 19:22 */ + TX_POWER_PA_DETECT_MSK = 0x7f800000, /* bits 23:30 */ + TX_ABORT_REQUIRED_MSK = 0x80000000, /* bits 31:31 */ +}; + +/* ******************************* + * TX aggregation status + ******************************* */ + +enum { + AGG_TX_STATE_TRANSMITTED = 0x00, + AGG_TX_STATE_UNDERRUN_MSK = 0x01, + AGG_TX_STATE_FEW_BYTES_MSK = 0x04, + AGG_TX_STATE_ABORT_MSK = 0x08, + AGG_TX_STATE_LAST_SENT_TTL_MSK = 0x10, + AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK = 0x20, + AGG_TX_STATE_SCD_QUERY_MSK = 0x80, + AGG_TX_STATE_TEST_BAD_CRC32_MSK = 0x100, + AGG_TX_STATE_RESPONSE_MSK = 0x1ff, + AGG_TX_STATE_DUMP_TX_MSK = 0x200, + AGG_TX_STATE_DELAY_TX_MSK = 0x400 +}; + +#define AGG_TX_STATUS_MSK 0x00000fff /* bits 0:11 */ +#define AGG_TX_TRY_MSK 0x0000f000 /* bits 12:15 */ + +#define AGG_TX_STATE_LAST_SENT_MSK (AGG_TX_STATE_LAST_SENT_TTL_MSK | \ + AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK) + +/* # tx attempts for first frame in aggregation */ +#define AGG_TX_STATE_TRY_CNT_POS 12 +#define AGG_TX_STATE_TRY_CNT_MSK 0xf000 + +/* Command ID and sequence number of Tx command for this frame */ +#define AGG_TX_STATE_SEQ_NUM_POS 16 +#define AGG_TX_STATE_SEQ_NUM_MSK 0xffff0000 + +/* + * C_TX = 0x1c (response) + * + * This response may be in one of two slightly different formats, indicated + * by the frame_count field: + * + * 1) No aggregation (frame_count == 1). This reports Tx results for + * a single frame. Multiple attempts, at various bit rates, may have + * been made for this frame. + * + * 2) Aggregation (frame_count > 1). This reports Tx results for + * 2 or more frames that used block-acknowledge. All frames were + * transmitted at same rate. Rate scaling may have been used if first + * frame in this new agg block failed in previous agg block(s). + * + * Note that, for aggregation, ACK (block-ack) status is not delivered here; + * block-ack has not been received by the time the 4965 device records + * this status. + * This status relates to reasons the tx might have been blocked or aborted + * within the sending station (this 4965 device), rather than whether it was + * received successfully by the destination station. + */ +struct agg_tx_status { + __le16 status; + __le16 sequence; +} __packed; + +struct il4965_tx_resp { + u8 frame_count; /* 1 no aggregation, >1 aggregation */ + u8 bt_kill_count; /* # blocked by bluetooth (unused for agg) */ + u8 failure_rts; /* # failures due to unsuccessful RTS */ + u8 failure_frame; /* # failures due to no ACK (unused for agg) */ + + /* For non-agg: Rate at which frame was successful. + * For agg: Rate at which all frames were transmitted. */ + __le32 rate_n_flags; /* RATE_MCS_* */ + + /* For non-agg: RTS + CTS + frame tx attempts time + ACK. + * For agg: RTS + CTS + aggregation tx time + block-ack time. */ + __le16 wireless_media_time; /* uSecs */ + + __le16 reserved; + __le32 pa_power1; /* RF power amplifier measurement (not used) */ + __le32 pa_power2; + + /* + * For non-agg: frame status TX_STATUS_* + * For agg: status of 1st frame, AGG_TX_STATE_*; other frame status + * fields follow this one, up to frame_count. + * Bit fields: + * 11- 0: AGG_TX_STATE_* status code + * 15-12: Retry count for 1st frame in aggregation (retries + * occur if tx failed for this frame when it was a + * member of a previous aggregation block). If rate + * scaling is used, retry count indicates the rate + * table entry used for all frames in the new agg. + * 31-16: Sequence # for this frame's Tx cmd (not SSN!) + */ + union { + __le32 status; + struct agg_tx_status agg_status[0]; /* for each agg frame */ + } u; +} __packed; + +/* + * N_COMPRESSED_BA = 0xc5 (response only, not a command) + * + * Reports Block-Acknowledge from recipient station + */ +struct il_compressed_ba_resp { + __le32 sta_addr_lo32; + __le16 sta_addr_hi16; + __le16 reserved; + + /* Index of recipient (BA-sending) station in uCode's station table */ + u8 sta_id; + u8 tid; + __le16 seq_ctl; + __le64 bitmap; + __le16 scd_flow; + __le16 scd_ssn; +} __packed; + +/* + * C_TX_PWR_TBL = 0x97 (command, has simple generic response) + * + * See details under "TXPOWER" in 4965.h. + */ + +struct il3945_txpowertable_cmd { + u8 band; /* 0: 5 GHz, 1: 2.4 GHz */ + u8 reserved; + __le16 channel; + struct il3945_power_per_rate power[IL_MAX_RATES]; +} __packed; + +struct il4965_txpowertable_cmd { + u8 band; /* 0: 5 GHz, 1: 2.4 GHz */ + u8 reserved; + __le16 channel; + struct il4965_tx_power_db tx_power; +} __packed; + + +/** + * struct il3945_rate_scaling_cmd - Rate Scaling Command & Response + * + * C_RATE_SCALE = 0x47 (command, has simple generic response) + * + * NOTE: The table of rates passed to the uCode via the + * RATE_SCALE command sets up the corresponding order of + * rates used for all related commands, including rate + * masks, etc. + * + * For example, if you set 9MB (PLCP 0x0f) as the first + * rate in the rate table, the bit mask for that rate + * when passed through ofdm_basic_rates on the C_RXON + * command would be bit 0 (1 << 0) + */ +struct il3945_rate_scaling_info { + __le16 rate_n_flags; + u8 try_cnt; + u8 next_rate_idx; +} __packed; + +struct il3945_rate_scaling_cmd { + u8 table_id; + u8 reserved[3]; + struct il3945_rate_scaling_info table[IL_MAX_RATES]; +} __packed; + + +/*RS_NEW_API: only TLC_RTS remains and moved to bit 0 */ +#define LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK (1 << 0) + +/* # of EDCA prioritized tx fifos */ +#define LINK_QUAL_AC_NUM AC_NUM + +/* # entries in rate scale table to support Tx retries */ +#define LINK_QUAL_MAX_RETRY_NUM 16 + +/* Tx antenna selection values */ +#define LINK_QUAL_ANT_A_MSK (1 << 0) +#define LINK_QUAL_ANT_B_MSK (1 << 1) +#define LINK_QUAL_ANT_MSK (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK) + + +/** + * struct il_link_qual_general_params + * + * Used in C_TX_LINK_QUALITY_CMD + */ +struct il_link_qual_general_params { + u8 flags; + + /* No entries at or above this (driver chosen) idx contain MIMO */ + u8 mimo_delimiter; + + /* Best single antenna to use for single stream (legacy, SISO). */ + u8 single_stream_ant_msk; /* LINK_QUAL_ANT_* */ + + /* Best antennas to use for MIMO (unused for 4965, assumes both). */ + u8 dual_stream_ant_msk; /* LINK_QUAL_ANT_* */ + + /* + * If driver needs to use different initial rates for different + * EDCA QOS access categories (as implemented by tx fifos 0-3), + * this table will set that up, by indicating the idxes in the + * rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table at which to start. + * Otherwise, driver should set all entries to 0. + * + * Entry usage: + * 0 = Background, 1 = Best Effort (normal), 2 = Video, 3 = Voice + * TX FIFOs above 3 use same value (typically 0) as TX FIFO 3. + */ + u8 start_rate_idx[LINK_QUAL_AC_NUM]; +} __packed; + +#define LINK_QUAL_AGG_TIME_LIMIT_DEF (4000) /* 4 milliseconds */ +#define LINK_QUAL_AGG_TIME_LIMIT_MAX (8000) +#define LINK_QUAL_AGG_TIME_LIMIT_MIN (100) + +#define LINK_QUAL_AGG_DISABLE_START_DEF (3) +#define LINK_QUAL_AGG_DISABLE_START_MAX (255) +#define LINK_QUAL_AGG_DISABLE_START_MIN (0) + +#define LINK_QUAL_AGG_FRAME_LIMIT_DEF (31) +#define LINK_QUAL_AGG_FRAME_LIMIT_MAX (63) +#define LINK_QUAL_AGG_FRAME_LIMIT_MIN (0) + +/** + * struct il_link_qual_agg_params + * + * Used in C_TX_LINK_QUALITY_CMD + */ +struct il_link_qual_agg_params { + + /* + *Maximum number of uSec in aggregation. + * default set to 4000 (4 milliseconds) if not configured in .cfg + */ + __le16 agg_time_limit; + + /* + * Number of Tx retries allowed for a frame, before that frame will + * no longer be considered for the start of an aggregation sequence + * (scheduler will then try to tx it as single frame). + * Driver should set this to 3. + */ + u8 agg_dis_start_th; + + /* + * Maximum number of frames in aggregation. + * 0 = no limit (default). 1 = no aggregation. + * Other values = max # frames in aggregation. + */ + u8 agg_frame_cnt_limit; + + __le32 reserved; +} __packed; + +/* + * C_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response) + * + * For 4965 devices only; 3945 uses C_RATE_SCALE. + * + * Each station in the 4965 device's internal station table has its own table + * of 16 + * Tx rates and modulation modes (e.g. legacy/SISO/MIMO) for retrying Tx when + * an ACK is not received. This command replaces the entire table for + * one station. + * + * NOTE: Station must already be in 4965 device's station table. + * Use C_ADD_STA. + * + * The rate scaling procedures described below work well. Of course, other + * procedures are possible, and may work better for particular environments. + * + * + * FILLING THE RATE TBL + * + * Given a particular initial rate and mode, as determined by the rate + * scaling algorithm described below, the Linux driver uses the following + * formula to fill the rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table in the + * Link Quality command: + * + * + * 1) If using High-throughput (HT) (SISO or MIMO) initial rate: + * a) Use this same initial rate for first 3 entries. + * b) Find next lower available rate using same mode (SISO or MIMO), + * use for next 3 entries. If no lower rate available, switch to + * legacy mode (no HT40 channel, no MIMO, no short guard interval). + * c) If using MIMO, set command's mimo_delimiter to number of entries + * using MIMO (3 or 6). + * d) After trying 2 HT rates, switch to legacy mode (no HT40 channel, + * no MIMO, no short guard interval), at the next lower bit rate + * (e.g. if second HT bit rate was 54, try 48 legacy), and follow + * legacy procedure for remaining table entries. + * + * 2) If using legacy initial rate: + * a) Use the initial rate for only one entry. + * b) For each following entry, reduce the rate to next lower available + * rate, until reaching the lowest available rate. + * c) When reducing rate, also switch antenna selection. + * d) Once lowest available rate is reached, repeat this rate until + * rate table is filled (16 entries), switching antenna each entry. + * + * + * ACCUMULATING HISTORY + * + * The rate scaling algorithm for 4965 devices, as implemented in Linux driver, + * uses two sets of frame Tx success history: One for the current/active + * modulation mode, and one for a speculative/search mode that is being + * attempted. If the speculative mode turns out to be more effective (i.e. + * actual transfer rate is better), then the driver continues to use the + * speculative mode as the new current active mode. + * + * Each history set contains, separately for each possible rate, data for a + * sliding win of the 62 most recent tx attempts at that rate. The data + * includes a shifting bitmap of success(1)/failure(0), and sums of successful + * and attempted frames, from which the driver can additionally calculate a + * success ratio (success / attempted) and number of failures + * (attempted - success), and control the size of the win (attempted). + * The driver uses the bit map to remove successes from the success sum, as + * the oldest tx attempts fall out of the win. + * + * When the 4965 device makes multiple tx attempts for a given frame, each + * attempt might be at a different rate, and have different modulation + * characteristics (e.g. antenna, fat channel, short guard interval), as set + * up in the rate scaling table in the Link Quality command. The driver must + * determine which rate table entry was used for each tx attempt, to determine + * which rate-specific history to update, and record only those attempts that + * match the modulation characteristics of the history set. + * + * When using block-ack (aggregation), all frames are transmitted at the same + * rate, since there is no per-attempt acknowledgment from the destination + * station. The Tx response struct il_tx_resp indicates the Tx rate in + * rate_n_flags field. After receiving a block-ack, the driver can update + * history for the entire block all at once. + * + * + * FINDING BEST STARTING RATE: + * + * When working with a selected initial modulation mode (see below), the + * driver attempts to find a best initial rate. The initial rate is the + * first entry in the Link Quality command's rate table. + * + * 1) Calculate actual throughput (success ratio * expected throughput, see + * table below) for current initial rate. Do this only if enough frames + * have been attempted to make the value meaningful: at least 6 failed + * tx attempts, or at least 8 successes. If not enough, don't try rate + * scaling yet. + * + * 2) Find available rates adjacent to current initial rate. Available means: + * a) supported by hardware && + * b) supported by association && + * c) within any constraints selected by user + * + * 3) Gather measured throughputs for adjacent rates. These might not have + * enough history to calculate a throughput. That's okay, we might try + * using one of them anyway! + * + * 4) Try decreasing rate if, for current rate: + * a) success ratio is < 15% || + * b) lower adjacent rate has better measured throughput || + * c) higher adjacent rate has worse throughput, and lower is unmeasured + * + * As a sanity check, if decrease was determined above, leave rate + * unchanged if: + * a) lower rate unavailable + * b) success ratio at current rate > 85% (very good) + * c) current measured throughput is better than expected throughput + * of lower rate (under perfect 100% tx conditions, see table below) + * + * 5) Try increasing rate if, for current rate: + * a) success ratio is < 15% || + * b) both adjacent rates' throughputs are unmeasured (try it!) || + * b) higher adjacent rate has better measured throughput || + * c) lower adjacent rate has worse throughput, and higher is unmeasured + * + * As a sanity check, if increase was determined above, leave rate + * unchanged if: + * a) success ratio at current rate < 70%. This is not particularly + * good performance; higher rate is sure to have poorer success. + * + * 6) Re-evaluate the rate after each tx frame. If working with block- + * acknowledge, history and stats may be calculated for the entire + * block (including prior history that fits within the history wins), + * before re-evaluation. + * + * FINDING BEST STARTING MODULATION MODE: + * + * After working with a modulation mode for a "while" (and doing rate scaling), + * the driver searches for a new initial mode in an attempt to improve + * throughput. The "while" is measured by numbers of attempted frames: + * + * For legacy mode, search for new mode after: + * 480 successful frames, or 160 failed frames + * For high-throughput modes (SISO or MIMO), search for new mode after: + * 4500 successful frames, or 400 failed frames + * + * Mode switch possibilities are (3 for each mode): + * + * For legacy: + * Change antenna, try SISO (if HT association), try MIMO (if HT association) + * For SISO: + * Change antenna, try MIMO, try shortened guard interval (SGI) + * For MIMO: + * Try SISO antenna A, SISO antenna B, try shortened guard interval (SGI) + * + * When trying a new mode, use the same bit rate as the old/current mode when + * trying antenna switches and shortened guard interval. When switching to + * SISO from MIMO or legacy, or to MIMO from SISO or legacy, use a rate + * for which the expected throughput (under perfect conditions) is about the + * same or slightly better than the actual measured throughput delivered by + * the old/current mode. + * + * Actual throughput can be estimated by multiplying the expected throughput + * by the success ratio (successful / attempted tx frames). Frame size is + * not considered in this calculation; it assumes that frame size will average + * out to be fairly consistent over several samples. The following are + * metric values for expected throughput assuming 100% success ratio. + * Only G band has support for CCK rates: + * + * RATE: 1 2 5 11 6 9 12 18 24 36 48 54 60 + * + * G: 7 13 35 58 40 57 72 98 121 154 177 186 186 + * A: 0 0 0 0 40 57 72 98 121 154 177 186 186 + * SISO 20MHz: 0 0 0 0 42 42 76 102 124 159 183 193 202 + * SGI SISO 20MHz: 0 0 0 0 46 46 82 110 132 168 192 202 211 + * MIMO 20MHz: 0 0 0 0 74 74 123 155 179 214 236 244 251 + * SGI MIMO 20MHz: 0 0 0 0 81 81 131 164 188 222 243 251 257 + * SISO 40MHz: 0 0 0 0 77 77 127 160 184 220 242 250 257 + * SGI SISO 40MHz: 0 0 0 0 83 83 135 169 193 229 250 257 264 + * MIMO 40MHz: 0 0 0 0 123 123 182 214 235 264 279 285 289 + * SGI MIMO 40MHz: 0 0 0 0 131 131 191 222 242 270 284 289 293 + * + * After the new mode has been tried for a short while (minimum of 6 failed + * frames or 8 successful frames), compare success ratio and actual throughput + * estimate of the new mode with the old. If either is better with the new + * mode, continue to use the new mode. + * + * Continue comparing modes until all 3 possibilities have been tried. + * If moving from legacy to HT, try all 3 possibilities from the new HT + * mode. After trying all 3, a best mode is found. Continue to use this mode + * for the longer "while" described above (e.g. 480 successful frames for + * legacy), and then repeat the search process. + * + */ +struct il_link_quality_cmd { + + /* Index of destination/recipient station in uCode's station table */ + u8 sta_id; + u8 reserved1; + __le16 control; /* not used */ + struct il_link_qual_general_params general_params; + struct il_link_qual_agg_params agg_params; + + /* + * Rate info; when using rate-scaling, Tx command's initial_rate_idx + * specifies 1st Tx rate attempted, via idx into this table. + * 4965 devices works its way through table when retrying Tx. + */ + struct { + __le32 rate_n_flags; /* RATE_MCS_*, RATE_* */ + } rs_table[LINK_QUAL_MAX_RETRY_NUM]; + __le32 reserved2; +} __packed; + +/* + * BT configuration enable flags: + * bit 0 - 1: BT channel announcement enabled + * 0: disable + * bit 1 - 1: priority of BT device enabled + * 0: disable + */ +#define BT_COEX_DISABLE (0x0) +#define BT_ENABLE_CHANNEL_ANNOUNCE BIT(0) +#define BT_ENABLE_PRIORITY BIT(1) + +#define BT_COEX_ENABLE (BT_ENABLE_CHANNEL_ANNOUNCE | BT_ENABLE_PRIORITY) + +#define BT_LEAD_TIME_DEF (0x1E) + +#define BT_MAX_KILL_DEF (0x5) + +/* + * C_BT_CONFIG = 0x9b (command, has simple generic response) + * + * 3945 and 4965 devices support hardware handshake with Bluetooth device on + * same platform. Bluetooth device alerts wireless device when it will Tx; + * wireless device can delay or kill its own Tx to accommodate. + */ +struct il_bt_cmd { + u8 flags; + u8 lead_time; + u8 max_kill; + u8 reserved; + __le32 kill_ack_mask; + __le32 kill_cts_mask; +} __packed; + + +/****************************************************************************** + * (6) + * Spectrum Management (802.11h) Commands, Responses, Notifications: + * + *****************************************************************************/ + +/* + * Spectrum Management + */ +#define MEASUREMENT_FILTER_FLAG (RXON_FILTER_PROMISC_MSK | \ + RXON_FILTER_CTL2HOST_MSK | \ + RXON_FILTER_ACCEPT_GRP_MSK | \ + RXON_FILTER_DIS_DECRYPT_MSK | \ + RXON_FILTER_DIS_GRP_DECRYPT_MSK | \ + RXON_FILTER_ASSOC_MSK | \ + RXON_FILTER_BCON_AWARE_MSK) + +struct il_measure_channel { + __le32 duration; /* measurement duration in extended beacon + * format */ + u8 channel; /* channel to measure */ + u8 type; /* see enum il_measure_type */ + __le16 reserved; +} __packed; + +/* + * C_SPECTRUM_MEASUREMENT = 0x74 (command) + */ +struct il_spectrum_cmd { + __le16 len; /* number of bytes starting from token */ + u8 token; /* token id */ + u8 id; /* measurement id -- 0 or 1 */ + u8 origin; /* 0 = TGh, 1 = other, 2 = TGk */ + u8 periodic; /* 1 = periodic */ + __le16 path_loss_timeout; + __le32 start_time; /* start time in extended beacon format */ + __le32 reserved2; + __le32 flags; /* rxon flags */ + __le32 filter_flags; /* rxon filter flags */ + __le16 channel_count; /* minimum 1, maximum 10 */ + __le16 reserved3; + struct il_measure_channel channels[10]; +} __packed; + +/* + * C_SPECTRUM_MEASUREMENT = 0x74 (response) + */ +struct il_spectrum_resp { + u8 token; + u8 id; /* id of the prior command replaced, or 0xff */ + __le16 status; /* 0 - command will be handled + * 1 - cannot handle (conflicts with another + * measurement) */ +} __packed; + +enum il_measurement_state { + IL_MEASUREMENT_START = 0, + IL_MEASUREMENT_STOP = 1, +}; + +enum il_measurement_status { + IL_MEASUREMENT_OK = 0, + IL_MEASUREMENT_CONCURRENT = 1, + IL_MEASUREMENT_CSA_CONFLICT = 2, + IL_MEASUREMENT_TGH_CONFLICT = 3, + /* 4-5 reserved */ + IL_MEASUREMENT_STOPPED = 6, + IL_MEASUREMENT_TIMEOUT = 7, + IL_MEASUREMENT_PERIODIC_FAILED = 8, +}; + +#define NUM_ELEMENTS_IN_HISTOGRAM 8 + +struct il_measurement_histogram { + __le32 ofdm[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 0.8usec counts */ + __le32 cck[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 1usec counts */ +} __packed; + +/* clear channel availability counters */ +struct il_measurement_cca_counters { + __le32 ofdm; + __le32 cck; +} __packed; + +enum il_measure_type { + IL_MEASURE_BASIC = (1 << 0), + IL_MEASURE_CHANNEL_LOAD = (1 << 1), + IL_MEASURE_HISTOGRAM_RPI = (1 << 2), + IL_MEASURE_HISTOGRAM_NOISE = (1 << 3), + IL_MEASURE_FRAME = (1 << 4), + /* bits 5:6 are reserved */ + IL_MEASURE_IDLE = (1 << 7), +}; + +/* + * N_SPECTRUM_MEASUREMENT = 0x75 (notification only, not a command) + */ +struct il_spectrum_notification { + u8 id; /* measurement id -- 0 or 1 */ + u8 token; + u8 channel_idx; /* idx in measurement channel list */ + u8 state; /* 0 - start, 1 - stop */ + __le32 start_time; /* lower 32-bits of TSF */ + u8 band; /* 0 - 5.2GHz, 1 - 2.4GHz */ + u8 channel; + u8 type; /* see enum il_measurement_type */ + u8 reserved1; + /* NOTE: cca_ofdm, cca_cck, basic_type, and histogram are only only + * valid if applicable for measurement type requested. */ + __le32 cca_ofdm; /* cca fraction time in 40Mhz clock periods */ + __le32 cca_cck; /* cca fraction time in 44Mhz clock periods */ + __le32 cca_time; /* channel load time in usecs */ + u8 basic_type; /* 0 - bss, 1 - ofdm preamble, 2 - + * unidentified */ + u8 reserved2[3]; + struct il_measurement_histogram histogram; + __le32 stop_time; /* lower 32-bits of TSF */ + __le32 status; /* see il_measurement_status */ +} __packed; + +/****************************************************************************** + * (7) + * Power Management Commands, Responses, Notifications: + * + *****************************************************************************/ + +/** + * struct il_powertable_cmd - Power Table Command + * @flags: See below: + * + * C_POWER_TBL = 0x77 (command, has simple generic response) + * + * PM allow: + * bit 0 - '0' Driver not allow power management + * '1' Driver allow PM (use rest of parameters) + * + * uCode send sleep notifications: + * bit 1 - '0' Don't send sleep notification + * '1' send sleep notification (SEND_PM_NOTIFICATION) + * + * Sleep over DTIM + * bit 2 - '0' PM have to walk up every DTIM + * '1' PM could sleep over DTIM till listen Interval. + * + * PCI power managed + * bit 3 - '0' (PCI_CFG_LINK_CTRL & 0x1) + * '1' !(PCI_CFG_LINK_CTRL & 0x1) + * + * Fast PD + * bit 4 - '1' Put radio to sleep when receiving frame for others + * + * Force sleep Modes + * bit 31/30- '00' use both mac/xtal sleeps + * '01' force Mac sleep + * '10' force xtal sleep + * '11' Illegal set + * + * NOTE: if sleep_interval[SLEEP_INTRVL_TBL_SIZE-1] > DTIM period then + * ucode assume sleep over DTIM is allowed and we don't need to wake up + * for every DTIM. + */ +#define IL_POWER_VEC_SIZE 5 + +#define IL_POWER_DRIVER_ALLOW_SLEEP_MSK cpu_to_le16(BIT(0)) +#define IL_POWER_PCI_PM_MSK cpu_to_le16(BIT(3)) + +struct il3945_powertable_cmd { + __le16 flags; + u8 reserved[2]; + __le32 rx_data_timeout; + __le32 tx_data_timeout; + __le32 sleep_interval[IL_POWER_VEC_SIZE]; +} __packed; + +struct il_powertable_cmd { + __le16 flags; + u8 keep_alive_seconds; /* 3945 reserved */ + u8 debug_flags; /* 3945 reserved */ + __le32 rx_data_timeout; + __le32 tx_data_timeout; + __le32 sleep_interval[IL_POWER_VEC_SIZE]; + __le32 keep_alive_beacons; +} __packed; + +/* + * N_PM_SLEEP = 0x7A (notification only, not a command) + * all devices identical. + */ +struct il_sleep_notification { + u8 pm_sleep_mode; + u8 pm_wakeup_src; + __le16 reserved; + __le32 sleep_time; + __le32 tsf_low; + __le32 bcon_timer; +} __packed; + +/* Sleep states. all devices identical. */ +enum { + IL_PM_NO_SLEEP = 0, + IL_PM_SLP_MAC = 1, + IL_PM_SLP_FULL_MAC_UNASSOCIATE = 2, + IL_PM_SLP_FULL_MAC_CARD_STATE = 3, + IL_PM_SLP_PHY = 4, + IL_PM_SLP_REPENT = 5, + IL_PM_WAKEUP_BY_TIMER = 6, + IL_PM_WAKEUP_BY_DRIVER = 7, + IL_PM_WAKEUP_BY_RFKILL = 8, + /* 3 reserved */ + IL_PM_NUM_OF_MODES = 12, +}; + +/* + * N_CARD_STATE = 0xa1 (notification only, not a command) + */ +struct il_card_state_notif { + __le32 flags; +} __packed; + +#define HW_CARD_DISABLED 0x01 +#define SW_CARD_DISABLED 0x02 +#define CT_CARD_DISABLED 0x04 +#define RXON_CARD_DISABLED 0x10 + +struct il_ct_kill_config { + __le32 reserved; + __le32 critical_temperature_M; + __le32 critical_temperature_R; +} __packed; + +/****************************************************************************** + * (8) + * Scan Commands, Responses, Notifications: + * + *****************************************************************************/ + +#define SCAN_CHANNEL_TYPE_PASSIVE cpu_to_le32(0) +#define SCAN_CHANNEL_TYPE_ACTIVE cpu_to_le32(1) + +/** + * struct il_scan_channel - entry in C_SCAN channel table + * + * One for each channel in the scan list. + * Each channel can independently select: + * 1) SSID for directed active scans + * 2) Txpower setting (for rate specified within Tx command) + * 3) How long to stay on-channel (behavior may be modified by quiet_time, + * quiet_plcp_th, good_CRC_th) + * + * To avoid uCode errors, make sure the following are true (see comments + * under struct il_scan_cmd about max_out_time and quiet_time): + * 1) If using passive_dwell (i.e. passive_dwell != 0): + * active_dwell <= passive_dwell (< max_out_time if max_out_time != 0) + * 2) quiet_time <= active_dwell + * 3) If restricting off-channel time (i.e. max_out_time !=0): + * passive_dwell < max_out_time + * active_dwell < max_out_time + */ +struct il3945_scan_channel { + /* + * type is defined as: + * 0:0 1 = active, 0 = passive + * 1:4 SSID direct bit map; if a bit is set, then corresponding + * SSID IE is transmitted in probe request. + * 5:7 reserved + */ + u8 type; + u8 channel; /* band is selected by il3945_scan_cmd "flags" field */ + struct il3945_tx_power tpc; + __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */ + __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */ +} __packed; + +/* set number of direct probes u8 type */ +#define IL39_SCAN_PROBE_MASK(n) ((BIT(n) | (BIT(n) - BIT(1)))) + +struct il_scan_channel { + /* + * type is defined as: + * 0:0 1 = active, 0 = passive + * 1:20 SSID direct bit map; if a bit is set, then corresponding + * SSID IE is transmitted in probe request. + * 21:31 reserved + */ + __le32 type; + __le16 channel; /* band is selected by il_scan_cmd "flags" field */ + u8 tx_gain; /* gain for analog radio */ + u8 dsp_atten; /* gain for DSP */ + __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */ + __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */ +} __packed; + +/* set number of direct probes __le32 type */ +#define IL_SCAN_PROBE_MASK(n) cpu_to_le32((BIT(n) | (BIT(n) - BIT(1)))) + +/** + * struct il_ssid_ie - directed scan network information element + * + * Up to 20 of these may appear in C_SCAN (Note: Only 4 are in + * 3945 SCAN api), selected by "type" bit field in struct il_scan_channel; + * each channel may select different ssids from among the 20 (4) entries. + * SSID IEs get transmitted in reverse order of entry. + */ +struct il_ssid_ie { + u8 id; + u8 len; + u8 ssid[32]; +} __packed; + +#define PROBE_OPTION_MAX_3945 4 +#define PROBE_OPTION_MAX 20 +#define TX_CMD_LIFE_TIME_INFINITE cpu_to_le32(0xFFFFFFFF) +#define IL_GOOD_CRC_TH_DISABLED 0 +#define IL_GOOD_CRC_TH_DEFAULT cpu_to_le16(1) +#define IL_GOOD_CRC_TH_NEVER cpu_to_le16(0xffff) +#define IL_MAX_SCAN_SIZE 1024 +#define IL_MAX_CMD_SIZE 4096 + +/* + * C_SCAN = 0x80 (command) + * + * The hardware scan command is very powerful; the driver can set it up to + * maintain (relatively) normal network traffic while doing a scan in the + * background. The max_out_time and suspend_time control the ratio of how + * long the device stays on an associated network channel ("service channel") + * vs. how long it's away from the service channel, i.e. tuned to other channels + * for scanning. + * + * max_out_time is the max time off-channel (in usec), and suspend_time + * is how long (in "extended beacon" format) that the scan is "suspended" + * after returning to the service channel. That is, suspend_time is the + * time that we stay on the service channel, doing normal work, between + * scan segments. The driver may set these parameters differently to support + * scanning when associated vs. not associated, and light vs. heavy traffic + * loads when associated. + * + * After receiving this command, the device's scan engine does the following; + * + * 1) Sends SCAN_START notification to driver + * 2) Checks to see if it has time to do scan for one channel + * 3) Sends NULL packet, with power-save (PS) bit set to 1, + * to tell AP that we're going off-channel + * 4) Tunes to first channel in scan list, does active or passive scan + * 5) Sends SCAN_RESULT notification to driver + * 6) Checks to see if it has time to do scan on *next* channel in list + * 7) Repeats 4-6 until it no longer has time to scan the next channel + * before max_out_time expires + * 8) Returns to service channel + * 9) Sends NULL packet with PS=0 to tell AP that we're back + * 10) Stays on service channel until suspend_time expires + * 11) Repeats entire process 2-10 until list is complete + * 12) Sends SCAN_COMPLETE notification + * + * For fast, efficient scans, the scan command also has support for staying on + * a channel for just a short time, if doing active scanning and getting no + * responses to the transmitted probe request. This time is controlled by + * quiet_time, and the number of received packets below which a channel is + * considered "quiet" is controlled by quiet_plcp_threshold. + * + * For active scanning on channels that have regulatory restrictions against + * blindly transmitting, the scan can listen before transmitting, to make sure + * that there is already legitimate activity on the channel. If enough + * packets are cleanly received on the channel (controlled by good_CRC_th, + * typical value 1), the scan engine starts transmitting probe requests. + * + * Driver must use separate scan commands for 2.4 vs. 5 GHz bands. + * + * To avoid uCode errors, see timing restrictions described under + * struct il_scan_channel. + */ + +struct il3945_scan_cmd { + __le16 len; + u8 reserved0; + u8 channel_count; /* # channels in channel list */ + __le16 quiet_time; /* dwell only this # millisecs on quiet channel + * (only for active scan) */ + __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */ + __le16 good_CRC_th; /* passive -> active promotion threshold */ + __le16 reserved1; + __le32 max_out_time; /* max usec to be away from associated (service) + * channel */ + __le32 suspend_time; /* pause scan this long (in "extended beacon + * format") when returning to service channel: + * 3945; 31:24 # beacons, 19:0 additional usec, + * 4965; 31:22 # beacons, 21:0 additional usec. + */ + __le32 flags; /* RXON_FLG_* */ + __le32 filter_flags; /* RXON_FILTER_* */ + + /* For active scans (set to all-0s for passive scans). + * Does not include payload. Must specify Tx rate; no rate scaling. */ + struct il3945_tx_cmd tx_cmd; + + /* For directed active scans (set to all-0s otherwise) */ + struct il_ssid_ie direct_scan[PROBE_OPTION_MAX_3945]; + + /* + * Probe request frame, followed by channel list. + * + * Size of probe request frame is specified by byte count in tx_cmd. + * Channel list follows immediately after probe request frame. + * Number of channels in list is specified by channel_count. + * Each channel in list is of type: + * + * struct il3945_scan_channel channels[0]; + * + * NOTE: Only one band of channels can be scanned per pass. You + * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait + * for one scan to complete (i.e. receive N_SCAN_COMPLETE) + * before requesting another scan. + */ + u8 data[0]; +} __packed; + +struct il_scan_cmd { + __le16 len; + u8 reserved0; + u8 channel_count; /* # channels in channel list */ + __le16 quiet_time; /* dwell only this # millisecs on quiet channel + * (only for active scan) */ + __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */ + __le16 good_CRC_th; /* passive -> active promotion threshold */ + __le16 rx_chain; /* RXON_RX_CHAIN_* */ + __le32 max_out_time; /* max usec to be away from associated (service) + * channel */ + __le32 suspend_time; /* pause scan this long (in "extended beacon + * format") when returning to service chnl: + * 3945; 31:24 # beacons, 19:0 additional usec, + * 4965; 31:22 # beacons, 21:0 additional usec. + */ + __le32 flags; /* RXON_FLG_* */ + __le32 filter_flags; /* RXON_FILTER_* */ + + /* For active scans (set to all-0s for passive scans). + * Does not include payload. Must specify Tx rate; no rate scaling. */ + struct il_tx_cmd tx_cmd; + + /* For directed active scans (set to all-0s otherwise) */ + struct il_ssid_ie direct_scan[PROBE_OPTION_MAX]; + + /* + * Probe request frame, followed by channel list. + * + * Size of probe request frame is specified by byte count in tx_cmd. + * Channel list follows immediately after probe request frame. + * Number of channels in list is specified by channel_count. + * Each channel in list is of type: + * + * struct il_scan_channel channels[0]; + * + * NOTE: Only one band of channels can be scanned per pass. You + * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait + * for one scan to complete (i.e. receive N_SCAN_COMPLETE) + * before requesting another scan. + */ + u8 data[0]; +} __packed; + +/* Can abort will notify by complete notification with abort status. */ +#define CAN_ABORT_STATUS cpu_to_le32(0x1) +/* complete notification statuses */ +#define ABORT_STATUS 0x2 + +/* + * C_SCAN = 0x80 (response) + */ +struct il_scanreq_notification { + __le32 status; /* 1: okay, 2: cannot fulfill request */ +} __packed; + +/* + * N_SCAN_START = 0x82 (notification only, not a command) + */ +struct il_scanstart_notification { + __le32 tsf_low; + __le32 tsf_high; + __le32 beacon_timer; + u8 channel; + u8 band; + u8 reserved[2]; + __le32 status; +} __packed; + +#define SCAN_OWNER_STATUS 0x1 +#define MEASURE_OWNER_STATUS 0x2 + +#define IL_PROBE_STATUS_OK 0 +#define IL_PROBE_STATUS_TX_FAILED BIT(0) +/* error statuses combined with TX_FAILED */ +#define IL_PROBE_STATUS_FAIL_TTL BIT(1) +#define IL_PROBE_STATUS_FAIL_BT BIT(2) + +#define NUMBER_OF_STATS 1 /* first __le32 is good CRC */ +/* + * N_SCAN_RESULTS = 0x83 (notification only, not a command) + */ +struct il_scanresults_notification { + u8 channel; + u8 band; + u8 probe_status; + u8 num_probe_not_sent; /* not enough time to send */ + __le32 tsf_low; + __le32 tsf_high; + __le32 stats[NUMBER_OF_STATS]; +} __packed; + +/* + * N_SCAN_COMPLETE = 0x84 (notification only, not a command) + */ +struct il_scancomplete_notification { + u8 scanned_channels; + u8 status; + u8 last_channel; + __le32 tsf_low; + __le32 tsf_high; +} __packed; + + +/****************************************************************************** + * (9) + * IBSS/AP Commands and Notifications: + * + *****************************************************************************/ + +enum il_ibss_manager { + IL_NOT_IBSS_MANAGER = 0, + IL_IBSS_MANAGER = 1, +}; + +/* + * N_BEACON = 0x90 (notification only, not a command) + */ + +struct il3945_beacon_notif { + struct il3945_tx_resp beacon_notify_hdr; + __le32 low_tsf; + __le32 high_tsf; + __le32 ibss_mgr_status; +} __packed; + +struct il4965_beacon_notif { + struct il4965_tx_resp beacon_notify_hdr; + __le32 low_tsf; + __le32 high_tsf; + __le32 ibss_mgr_status; +} __packed; + +/* + * C_TX_BEACON= 0x91 (command, has simple generic response) + */ + +struct il3945_tx_beacon_cmd { + struct il3945_tx_cmd tx; + __le16 tim_idx; + u8 tim_size; + u8 reserved1; + struct ieee80211_hdr frame[0]; /* beacon frame */ +} __packed; + +struct il_tx_beacon_cmd { + struct il_tx_cmd tx; + __le16 tim_idx; + u8 tim_size; + u8 reserved1; + struct ieee80211_hdr frame[0]; /* beacon frame */ +} __packed; + +/****************************************************************************** + * (10) + * Statistics Commands and Notifications: + * + *****************************************************************************/ + +#define IL_TEMP_CONVERT 260 + +#define SUP_RATE_11A_MAX_NUM_CHANNELS 8 +#define SUP_RATE_11B_MAX_NUM_CHANNELS 4 +#define SUP_RATE_11G_MAX_NUM_CHANNELS 12 + +/* Used for passing to driver number of successes and failures per rate */ +struct rate_histogram { + union { + __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS]; + __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS]; + __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS]; + } success; + union { + __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS]; + __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS]; + __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS]; + } failed; +} __packed; + +/* stats command response */ + +struct iwl39_stats_rx_phy { + __le32 ina_cnt; + __le32 fina_cnt; + __le32 plcp_err; + __le32 crc32_err; + __le32 overrun_err; + __le32 early_overrun_err; + __le32 crc32_good; + __le32 false_alarm_cnt; + __le32 fina_sync_err_cnt; + __le32 sfd_timeout; + __le32 fina_timeout; + __le32 unresponded_rts; + __le32 rxe_frame_limit_overrun; + __le32 sent_ack_cnt; + __le32 sent_cts_cnt; +} __packed; + +struct iwl39_stats_rx_non_phy { + __le32 bogus_cts; /* CTS received when not expecting CTS */ + __le32 bogus_ack; /* ACK received when not expecting ACK */ + __le32 non_bssid_frames; /* number of frames with BSSID that + * doesn't belong to the STA BSSID */ + __le32 filtered_frames; /* count frames that were dumped in the + * filtering process */ + __le32 non_channel_beacons; /* beacons with our bss id but not on + * our serving channel */ +} __packed; + +struct iwl39_stats_rx { + struct iwl39_stats_rx_phy ofdm; + struct iwl39_stats_rx_phy cck; + struct iwl39_stats_rx_non_phy general; +} __packed; + +struct iwl39_stats_tx { + __le32 preamble_cnt; + __le32 rx_detected_cnt; + __le32 bt_prio_defer_cnt; + __le32 bt_prio_kill_cnt; + __le32 few_bytes_cnt; + __le32 cts_timeout; + __le32 ack_timeout; + __le32 expected_ack_cnt; + __le32 actual_ack_cnt; +} __packed; + +struct stats_dbg { + __le32 burst_check; + __le32 burst_count; + __le32 wait_for_silence_timeout_cnt; + __le32 reserved[3]; +} __packed; + +struct iwl39_stats_div { + __le32 tx_on_a; + __le32 tx_on_b; + __le32 exec_time; + __le32 probe_time; +} __packed; + +struct iwl39_stats_general { + __le32 temperature; + struct stats_dbg dbg; + __le32 sleep_time; + __le32 slots_out; + __le32 slots_idle; + __le32 ttl_timestamp; + struct iwl39_stats_div div; +} __packed; + +struct stats_rx_phy { + __le32 ina_cnt; + __le32 fina_cnt; + __le32 plcp_err; + __le32 crc32_err; + __le32 overrun_err; + __le32 early_overrun_err; + __le32 crc32_good; + __le32 false_alarm_cnt; + __le32 fina_sync_err_cnt; + __le32 sfd_timeout; + __le32 fina_timeout; + __le32 unresponded_rts; + __le32 rxe_frame_limit_overrun; + __le32 sent_ack_cnt; + __le32 sent_cts_cnt; + __le32 sent_ba_rsp_cnt; + __le32 dsp_self_kill; + __le32 mh_format_err; + __le32 re_acq_main_rssi_sum; + __le32 reserved3; +} __packed; + +struct stats_rx_ht_phy { + __le32 plcp_err; + __le32 overrun_err; + __le32 early_overrun_err; + __le32 crc32_good; + __le32 crc32_err; + __le32 mh_format_err; + __le32 agg_crc32_good; + __le32 agg_mpdu_cnt; + __le32 agg_cnt; + __le32 unsupport_mcs; +} __packed; + +#define INTERFERENCE_DATA_AVAILABLE cpu_to_le32(1) + +struct stats_rx_non_phy { + __le32 bogus_cts; /* CTS received when not expecting CTS */ + __le32 bogus_ack; /* ACK received when not expecting ACK */ + __le32 non_bssid_frames; /* number of frames with BSSID that + * doesn't belong to the STA BSSID */ + __le32 filtered_frames; /* count frames that were dumped in the + * filtering process */ + __le32 non_channel_beacons; /* beacons with our bss id but not on + * our serving channel */ + __le32 channel_beacons; /* beacons with our bss id and in our + * serving channel */ + __le32 num_missed_bcon; /* number of missed beacons */ + __le32 adc_rx_saturation_time; /* count in 0.8us units the time the + * ADC was in saturation */ + __le32 ina_detection_search_time;/* total time (in 0.8us) searched + * for INA */ + __le32 beacon_silence_rssi_a; /* RSSI silence after beacon frame */ + __le32 beacon_silence_rssi_b; /* RSSI silence after beacon frame */ + __le32 beacon_silence_rssi_c; /* RSSI silence after beacon frame */ + __le32 interference_data_flag; /* flag for interference data + * availability. 1 when data is + * available. */ + __le32 channel_load; /* counts RX Enable time in uSec */ + __le32 dsp_false_alarms; /* DSP false alarm (both OFDM + * and CCK) counter */ + __le32 beacon_rssi_a; + __le32 beacon_rssi_b; + __le32 beacon_rssi_c; + __le32 beacon_energy_a; + __le32 beacon_energy_b; + __le32 beacon_energy_c; +} __packed; + +struct stats_rx { + struct stats_rx_phy ofdm; + struct stats_rx_phy cck; + struct stats_rx_non_phy general; + struct stats_rx_ht_phy ofdm_ht; +} __packed; + +/** + * struct stats_tx_power - current tx power + * + * @ant_a: current tx power on chain a in 1/2 dB step + * @ant_b: current tx power on chain b in 1/2 dB step + * @ant_c: current tx power on chain c in 1/2 dB step + */ +struct stats_tx_power { + u8 ant_a; + u8 ant_b; + u8 ant_c; + u8 reserved; +} __packed; + +struct stats_tx_non_phy_agg { + __le32 ba_timeout; + __le32 ba_reschedule_frames; + __le32 scd_query_agg_frame_cnt; + __le32 scd_query_no_agg; + __le32 scd_query_agg; + __le32 scd_query_mismatch; + __le32 frame_not_ready; + __le32 underrun; + __le32 bt_prio_kill; + __le32 rx_ba_rsp_cnt; +} __packed; + +struct stats_tx { + __le32 preamble_cnt; + __le32 rx_detected_cnt; + __le32 bt_prio_defer_cnt; + __le32 bt_prio_kill_cnt; + __le32 few_bytes_cnt; + __le32 cts_timeout; + __le32 ack_timeout; + __le32 expected_ack_cnt; + __le32 actual_ack_cnt; + __le32 dump_msdu_cnt; + __le32 burst_abort_next_frame_mismatch_cnt; + __le32 burst_abort_missing_next_frame_cnt; + __le32 cts_timeout_collision; + __le32 ack_or_ba_timeout_collision; + struct stats_tx_non_phy_agg agg; + + __le32 reserved1; +} __packed; + + +struct stats_div { + __le32 tx_on_a; + __le32 tx_on_b; + __le32 exec_time; + __le32 probe_time; + __le32 reserved1; + __le32 reserved2; +} __packed; + +struct stats_general_common { + __le32 temperature; /* radio temperature */ + struct stats_dbg dbg; + __le32 sleep_time; + __le32 slots_out; + __le32 slots_idle; + __le32 ttl_timestamp; + struct stats_div div; + __le32 rx_enable_counter; + /* + * num_of_sos_states: + * count the number of times we have to re-tune + * in order to get out of bad PHY status + */ + __le32 num_of_sos_states; +} __packed; + +struct stats_general { + struct stats_general_common common; + __le32 reserved2; + __le32 reserved3; +} __packed; + +#define UCODE_STATS_CLEAR_MSK (0x1 << 0) +#define UCODE_STATS_FREQUENCY_MSK (0x1 << 1) +#define UCODE_STATS_NARROW_BAND_MSK (0x1 << 2) + +/* + * C_STATS = 0x9c, + * all devices identical. + * + * This command triggers an immediate response containing uCode stats. + * The response is in the same format as N_STATS 0x9d, below. + * + * If the CLEAR_STATS configuration flag is set, uCode will clear its + * internal copy of the stats (counters) after issuing the response. + * This flag does not affect N_STATSs after beacons (see below). + * + * If the DISABLE_NOTIF configuration flag is set, uCode will not issue + * N_STATSs after received beacons (see below). This flag + * does not affect the response to the C_STATS 0x9c itself. + */ +#define IL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1) /* see above */ +#define IL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */ +struct il_stats_cmd { + __le32 configuration_flags; /* IL_STATS_CONF_* */ +} __packed; + +/* + * N_STATS = 0x9d (notification only, not a command) + * + * By default, uCode issues this notification after receiving a beacon + * while associated. To disable this behavior, set DISABLE_NOTIF flag in the + * C_STATS 0x9c, above. + * + * Statistics counters continue to increment beacon after beacon, but are + * cleared when changing channels or when driver issues C_STATS + * 0x9c with CLEAR_STATS bit set (see above). + * + * uCode also issues this notification during scans. uCode clears stats + * appropriately so that each notification contains stats for only the + * one channel that has just been scanned. + */ +#define STATS_REPLY_FLG_BAND_24G_MSK cpu_to_le32(0x2) +#define STATS_REPLY_FLG_HT40_MODE_MSK cpu_to_le32(0x8) + +struct il3945_notif_stats { + __le32 flag; + struct iwl39_stats_rx rx; + struct iwl39_stats_tx tx; + struct iwl39_stats_general general; +} __packed; + +struct il_notif_stats { + __le32 flag; + struct stats_rx rx; + struct stats_tx tx; + struct stats_general general; +} __packed; + +/* + * N_MISSED_BEACONS = 0xa2 (notification only, not a command) + * + * uCode send N_MISSED_BEACONS to driver when detect beacon missed + * in regardless of how many missed beacons, which mean when driver receive the + * notification, inside the command, it can find all the beacons information + * which include number of total missed beacons, number of consecutive missed + * beacons, number of beacons received and number of beacons expected to + * receive. + * + * If uCode detected consecutive_missed_beacons > 5, it will reset the radio + * in order to bring the radio/PHY back to working state; which has no relation + * to when driver will perform sensitivity calibration. + * + * Driver should set it own missed_beacon_threshold to decide when to perform + * sensitivity calibration based on number of consecutive missed beacons in + * order to improve overall performance, especially in noisy environment. + * + */ + +#define IL_MISSED_BEACON_THRESHOLD_MIN (1) +#define IL_MISSED_BEACON_THRESHOLD_DEF (5) +#define IL_MISSED_BEACON_THRESHOLD_MAX IL_MISSED_BEACON_THRESHOLD_DEF + +struct il_missed_beacon_notif { + __le32 consecutive_missed_beacons; + __le32 total_missed_becons; + __le32 num_expected_beacons; + __le32 num_recvd_beacons; +} __packed; + + +/****************************************************************************** + * (11) + * Rx Calibration Commands: + * + * With the uCode used for open source drivers, most Tx calibration (except + * for Tx Power) and most Rx calibration is done by uCode during the + * "initialize" phase of uCode boot. Driver must calibrate only: + * + * 1) Tx power (depends on temperature), described elsewhere + * 2) Receiver gain balance (optimize MIMO, and detect disconnected antennas) + * 3) Receiver sensitivity (to optimize signal detection) + * + *****************************************************************************/ + +/** + * C_SENSITIVITY = 0xa8 (command, has simple generic response) + * + * This command sets up the Rx signal detector for a sensitivity level that + * is high enough to lock onto all signals within the associated network, + * but low enough to ignore signals that are below a certain threshold, so as + * not to have too many "false alarms". False alarms are signals that the + * Rx DSP tries to lock onto, but then discards after determining that they + * are noise. + * + * The optimum number of false alarms is between 5 and 50 per 200 TUs + * (200 * 1024 uSecs, i.e. 204.8 milliseconds) of actual Rx time (i.e. + * time listening, not transmitting). Driver must adjust sensitivity so that + * the ratio of actual false alarms to actual Rx time falls within this range. + * + * While associated, uCode delivers N_STATSs after each + * received beacon. These provide information to the driver to analyze the + * sensitivity. Don't analyze stats that come in from scanning, or any + * other non-associated-network source. Pertinent stats include: + * + * From "general" stats (struct stats_rx_non_phy): + * + * (beacon_energy_[abc] & 0x0FF00) >> 8 (unsigned, higher value is lower level) + * Measure of energy of desired signal. Used for establishing a level + * below which the device does not detect signals. + * + * (beacon_silence_rssi_[abc] & 0x0FF00) >> 8 (unsigned, units in dB) + * Measure of background noise in silent period after beacon. + * + * channel_load + * uSecs of actual Rx time during beacon period (varies according to + * how much time was spent transmitting). + * + * From "cck" and "ofdm" stats (struct stats_rx_phy), separately: + * + * false_alarm_cnt + * Signal locks abandoned early (before phy-level header). + * + * plcp_err + * Signal locks abandoned late (during phy-level header). + * + * NOTE: Both false_alarm_cnt and plcp_err increment monotonically from + * beacon to beacon, i.e. each value is an accumulation of all errors + * before and including the latest beacon. Values will wrap around to 0 + * after counting up to 2^32 - 1. Driver must differentiate vs. + * previous beacon's values to determine # false alarms in the current + * beacon period. + * + * Total number of false alarms = false_alarms + plcp_errs + * + * For OFDM, adjust the following table entries in struct il_sensitivity_cmd + * (notice that the start points for OFDM are at or close to settings for + * maximum sensitivity): + * + * START / MIN / MAX + * HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX 90 / 85 / 120 + * HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_IDX 170 / 170 / 210 + * HD_AUTO_CORR32_X4_TH_ADD_MIN_IDX 105 / 105 / 140 + * HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_IDX 220 / 220 / 270 + * + * If actual rate of OFDM false alarms (+ plcp_errors) is too high + * (greater than 50 for each 204.8 msecs listening), reduce sensitivity + * by *adding* 1 to all 4 of the table entries above, up to the max for + * each entry. Conversely, if false alarm rate is too low (less than 5 + * for each 204.8 msecs listening), *subtract* 1 from each entry to + * increase sensitivity. + * + * For CCK sensitivity, keep track of the following: + * + * 1). 20-beacon history of maximum background noise, indicated by + * (beacon_silence_rssi_[abc] & 0x0FF00), units in dB, across the + * 3 receivers. For any given beacon, the "silence reference" is + * the maximum of last 60 samples (20 beacons * 3 receivers). + * + * 2). 10-beacon history of strongest signal level, as indicated + * by (beacon_energy_[abc] & 0x0FF00) >> 8, across the 3 receivers, + * i.e. the strength of the signal through the best receiver at the + * moment. These measurements are "upside down", with lower values + * for stronger signals, so max energy will be *minimum* value. + * + * Then for any given beacon, the driver must determine the *weakest* + * of the strongest signals; this is the minimum level that needs to be + * successfully detected, when using the best receiver at the moment. + * "Max cck energy" is the maximum (higher value means lower energy!) + * of the last 10 minima. Once this is determined, driver must add + * a little margin by adding "6" to it. + * + * 3). Number of consecutive beacon periods with too few false alarms. + * Reset this to 0 at the first beacon period that falls within the + * "good" range (5 to 50 false alarms per 204.8 milliseconds rx). + * + * Then, adjust the following CCK table entries in struct il_sensitivity_cmd + * (notice that the start points for CCK are at maximum sensitivity): + * + * START / MIN / MAX + * HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX 125 / 125 / 200 + * HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX 200 / 200 / 400 + * HD_MIN_ENERGY_CCK_DET_IDX 100 / 0 / 100 + * + * If actual rate of CCK false alarms (+ plcp_errors) is too high + * (greater than 50 for each 204.8 msecs listening), method for reducing + * sensitivity is: + * + * 1) *Add* 3 to value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX, + * up to max 400. + * + * 2) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX is < 160, + * sensitivity has been reduced a significant amount; bring it up to + * a moderate 161. Otherwise, *add* 3, up to max 200. + * + * 3) a) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX is > 160, + * sensitivity has been reduced only a moderate or small amount; + * *subtract* 2 from value in HD_MIN_ENERGY_CCK_DET_IDX, + * down to min 0. Otherwise (if gain has been significantly reduced), + * don't change the HD_MIN_ENERGY_CCK_DET_IDX value. + * + * b) Save a snapshot of the "silence reference". + * + * If actual rate of CCK false alarms (+ plcp_errors) is too low + * (less than 5 for each 204.8 msecs listening), method for increasing + * sensitivity is used only if: + * + * 1a) Previous beacon did not have too many false alarms + * 1b) AND difference between previous "silence reference" and current + * "silence reference" (prev - current) is 2 or more, + * OR 2) 100 or more consecutive beacon periods have had rate of + * less than 5 false alarms per 204.8 milliseconds rx time. + * + * Method for increasing sensitivity: + * + * 1) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX, + * down to min 125. + * + * 2) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX, + * down to min 200. + * + * 3) *Add* 2 to value in HD_MIN_ENERGY_CCK_DET_IDX, up to max 100. + * + * If actual rate of CCK false alarms (+ plcp_errors) is within good range + * (between 5 and 50 for each 204.8 msecs listening): + * + * 1) Save a snapshot of the silence reference. + * + * 2) If previous beacon had too many CCK false alarms (+ plcp_errors), + * give some extra margin to energy threshold by *subtracting* 8 + * from value in HD_MIN_ENERGY_CCK_DET_IDX. + * + * For all cases (too few, too many, good range), make sure that the CCK + * detection threshold (energy) is below the energy level for robust + * detection over the past 10 beacon periods, the "Max cck energy". + * Lower values mean higher energy; this means making sure that the value + * in HD_MIN_ENERGY_CCK_DET_IDX is at or *above* "Max cck energy". + * + */ + +/* + * Table entries in C_SENSITIVITY (struct il_sensitivity_cmd) + */ +#define HD_TBL_SIZE (11) /* number of entries */ +#define HD_MIN_ENERGY_CCK_DET_IDX (0) /* table idxes */ +#define HD_MIN_ENERGY_OFDM_DET_IDX (1) +#define HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX (2) +#define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_IDX (3) +#define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX (4) +#define HD_AUTO_CORR32_X4_TH_ADD_MIN_IDX (5) +#define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_IDX (6) +#define HD_BARKER_CORR_TH_ADD_MIN_IDX (7) +#define HD_BARKER_CORR_TH_ADD_MIN_MRC_IDX (8) +#define HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX (9) +#define HD_OFDM_ENERGY_TH_IN_IDX (10) + +/* Control field in struct il_sensitivity_cmd */ +#define C_SENSITIVITY_CONTROL_DEFAULT_TBL cpu_to_le16(0) +#define C_SENSITIVITY_CONTROL_WORK_TBL cpu_to_le16(1) + +/** + * struct il_sensitivity_cmd + * @control: (1) updates working table, (0) updates default table + * @table: energy threshold values, use HD_* as idx into table + * + * Always use "1" in "control" to update uCode's working table and DSP. + */ +struct il_sensitivity_cmd { + __le16 control; /* always use "1" */ + __le16 table[HD_TBL_SIZE]; /* use HD_* as idx */ +} __packed; + + +/** + * C_PHY_CALIBRATION = 0xb0 (command, has simple generic response) + * + * This command sets the relative gains of 4965 device's 3 radio receiver chains. + * + * After the first association, driver should accumulate signal and noise + * stats from the N_STATSs that follow the first 20 + * beacons from the associated network (don't collect stats that come + * in from scanning, or any other non-network source). + * + * DISCONNECTED ANTENNA: + * + * Driver should determine which antennas are actually connected, by comparing + * average beacon signal levels for the 3 Rx chains. Accumulate (add) the + * following values over 20 beacons, one accumulator for each of the chains + * a/b/c, from struct stats_rx_non_phy: + * + * beacon_rssi_[abc] & 0x0FF (unsigned, units in dB) + * + * Find the strongest signal from among a/b/c. Compare the other two to the + * strongest. If any signal is more than 15 dB (times 20, unless you + * divide the accumulated values by 20) below the strongest, the driver + * considers that antenna to be disconnected, and should not try to use that + * antenna/chain for Rx or Tx. If both A and B seem to be disconnected, + * driver should declare the stronger one as connected, and attempt to use it + * (A and B are the only 2 Tx chains!). + * + * + * RX BALANCE: + * + * Driver should balance the 3 receivers (but just the ones that are connected + * to antennas, see above) for gain, by comparing the average signal levels + * detected during the silence after each beacon (background noise). + * Accumulate (add) the following values over 20 beacons, one accumulator for + * each of the chains a/b/c, from struct stats_rx_non_phy: + * + * beacon_silence_rssi_[abc] & 0x0FF (unsigned, units in dB) + * + * Find the weakest background noise level from among a/b/c. This Rx chain + * will be the reference, with 0 gain adjustment. Attenuate other channels by + * finding noise difference: + * + * (accum_noise[i] - accum_noise[reference]) / 30 + * + * The "30" adjusts the dB in the 20 accumulated samples to units of 1.5 dB. + * For use in diff_gain_[abc] fields of struct il_calibration_cmd, the + * driver should limit the difference results to a range of 0-3 (0-4.5 dB), + * and set bit 2 to indicate "reduce gain". The value for the reference + * (weakest) chain should be "0". + * + * diff_gain_[abc] bit fields: + * 2: (1) reduce gain, (0) increase gain + * 1-0: amount of gain, units of 1.5 dB + */ + +/* Phy calibration command for series */ +/* The default calibrate table size if not specified by firmware */ +#define IL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE 18 +enum { + IL_PHY_CALIBRATE_DIFF_GAIN_CMD = 7, + IL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE = 19, +}; + +#define IL_MAX_PHY_CALIBRATE_TBL_SIZE (253) + +struct il_calib_hdr { + u8 op_code; + u8 first_group; + u8 groups_num; + u8 data_valid; +} __packed; + +/* IL_PHY_CALIBRATE_DIFF_GAIN_CMD (7) */ +struct il_calib_diff_gain_cmd { + struct il_calib_hdr hdr; + s8 diff_gain_a; /* see above */ + s8 diff_gain_b; + s8 diff_gain_c; + u8 reserved1; +} __packed; + +/****************************************************************************** + * (12) + * Miscellaneous Commands: + * + *****************************************************************************/ + +/* + * LEDs Command & Response + * C_LEDS = 0x48 (command, has simple generic response) + * + * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field), + * this command turns it on or off, or sets up a periodic blinking cycle. + */ +struct il_led_cmd { + __le32 interval; /* "interval" in uSec */ + u8 id; /* 1: Activity, 2: Link, 3: Tech */ + u8 off; /* # intervals off while blinking; + * "0", with >0 "on" value, turns LED on */ + u8 on; /* # intervals on while blinking; + * "0", regardless of "off", turns LED off */ + u8 reserved; +} __packed; + + +/****************************************************************************** + * (13) + * Union of all expected notifications/responses: + * + *****************************************************************************/ + +struct il_rx_pkt { + /* + * The first 4 bytes of the RX frame header contain both the RX frame + * size and some flags. + * Bit fields: + * 31: flag flush RB request + * 30: flag ignore TC (terminal counter) request + * 29: flag fast IRQ request + * 28-14: Reserved + * 13-00: RX frame size + */ + __le32 len_n_flags; + struct il_cmd_header hdr; + union { + struct il3945_rx_frame rx_frame; + struct il3945_tx_resp tx_resp; + struct il3945_beacon_notif beacon_status; + + struct il_alive_resp alive_frame; + struct il_spectrum_notification spectrum_notif; + struct il_csa_notification csa_notif; + struct il_error_resp err_resp; + struct il_card_state_notif card_state_notif; + struct il_add_sta_resp add_sta; + struct il_rem_sta_resp rem_sta; + struct il_sleep_notification sleep_notif; + struct il_spectrum_resp spectrum; + struct il_notif_stats stats; + struct il_compressed_ba_resp compressed_ba; + struct il_missed_beacon_notif missed_beacon; + __le32 status; + u8 raw[0]; + } u; +} __packed; + +#endif /* __il_commands_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-commands.h b/drivers/net/wireless/iwlegacy/iwl-commands.h deleted file mode 100644 index 8df4d252168b..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-commands.h +++ /dev/null @@ -1,3398 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - *****************************************************************************/ -/* - * Please use this file (iwl-commands.h) only for uCode API definitions. - * Please use iwl-xxxx-hw.h for hardware-related definitions. - * Please use iwl-dev.h for driver implementation definitions. - */ - -#ifndef __il_commands_h__ -#define __il_commands_h__ - -struct il_priv; - -/* uCode version contains 4 values: Major/Minor/API/Serial */ -#define IL_UCODE_MAJOR(ver) (((ver) & 0xFF000000) >> 24) -#define IL_UCODE_MINOR(ver) (((ver) & 0x00FF0000) >> 16) -#define IL_UCODE_API(ver) (((ver) & 0x0000FF00) >> 8) -#define IL_UCODE_SERIAL(ver) ((ver) & 0x000000FF) - - -/* Tx rates */ -#define IL_CCK_RATES 4 -#define IL_OFDM_RATES 8 -#define IL_MAX_RATES (IL_CCK_RATES + IL_OFDM_RATES) - -enum { - N_ALIVE = 0x1, - N_ERROR = 0x2, - - /* RXON and QOS commands */ - C_RXON = 0x10, - C_RXON_ASSOC = 0x11, - C_QOS_PARAM = 0x13, - C_RXON_TIMING = 0x14, - - /* Multi-Station support */ - C_ADD_STA = 0x18, - C_REM_STA = 0x19, - - /* Security */ - C_WEPKEY = 0x20, - - /* RX, TX, LEDs */ - N_3945_RX = 0x1b, /* 3945 only */ - C_TX = 0x1c, - C_RATE_SCALE = 0x47, /* 3945 only */ - C_LEDS = 0x48, - C_TX_LINK_QUALITY_CMD = 0x4e, /* for 4965 */ - - /* 802.11h related */ - C_CHANNEL_SWITCH = 0x72, - N_CHANNEL_SWITCH = 0x73, - C_SPECTRUM_MEASUREMENT = 0x74, - N_SPECTRUM_MEASUREMENT = 0x75, - - /* Power Management */ - C_POWER_TBL = 0x77, - N_PM_SLEEP = 0x7A, - N_PM_DEBUG_STATS = 0x7B, - - /* Scan commands and notifications */ - C_SCAN = 0x80, - C_SCAN_ABORT = 0x81, - N_SCAN_START = 0x82, - N_SCAN_RESULTS = 0x83, - N_SCAN_COMPLETE = 0x84, - - /* IBSS/AP commands */ - N_BEACON = 0x90, - C_TX_BEACON= 0x91, - - /* Miscellaneous commands */ - C_TX_PWR_TBL = 0x97, - - /* Bluetooth device coexistence config command */ - C_BT_CONFIG = 0x9b, - - /* Statistics */ - C_STATS = 0x9c, - N_STATS = 0x9d, - - /* RF-KILL commands and notifications */ - N_CARD_STATE = 0xa1, - - /* Missed beacons notification */ - N_MISSED_BEACONS = 0xa2, - - C_CT_KILL_CONFIG = 0xa4, - C_SENSITIVITY = 0xa8, - C_PHY_CALIBRATION = 0xb0, - N_RX_PHY = 0xc0, - N_RX_MPDU = 0xc1, - N_RX = 0xc3, - N_COMPRESSED_BA = 0xc5, - - IL_CN_MAX = 0xff -}; - -/****************************************************************************** - * (0) - * Commonly used structures and definitions: - * Command header, rate_n_flags, txpower - * - *****************************************************************************/ - -/* il_cmd_header flags value */ -#define IL_CMD_FAILED_MSK 0x40 - -#define SEQ_TO_QUEUE(s) (((s) >> 8) & 0x1f) -#define QUEUE_TO_SEQ(q) (((q) & 0x1f) << 8) -#define SEQ_TO_IDX(s) ((s) & 0xff) -#define IDX_TO_SEQ(i) ((i) & 0xff) -#define SEQ_HUGE_FRAME cpu_to_le16(0x4000) -#define SEQ_RX_FRAME cpu_to_le16(0x8000) - -/** - * struct il_cmd_header - * - * This header format appears in the beginning of each command sent from the - * driver, and each response/notification received from uCode. - */ -struct il_cmd_header { - u8 cmd; /* Command ID: C_RXON, etc. */ - u8 flags; /* 0:5 reserved, 6 abort, 7 internal */ - /* - * The driver sets up the sequence number to values of its choosing. - * uCode does not use this value, but passes it back to the driver - * when sending the response to each driver-originated command, so - * the driver can match the response to the command. Since the values - * don't get used by uCode, the driver may set up an arbitrary format. - * - * There is one exception: uCode sets bit 15 when it originates - * the response/notification, i.e. when the response/notification - * is not a direct response to a command sent by the driver. For - * example, uCode issues N_3945_RX when it sends a received frame - * to the driver; it is not a direct response to any driver command. - * - * The Linux driver uses the following format: - * - * 0:7 tfd idx - position within TX queue - * 8:12 TX queue id - * 13 reserved - * 14 huge - driver sets this to indicate command is in the - * 'huge' storage at the end of the command buffers - * 15 unsolicited RX or uCode-originated notification - */ - __le16 sequence; - - /* command or response/notification data follows immediately */ - u8 data[0]; -} __packed; - - -/** - * struct il3945_tx_power - * - * Used in C_TX_PWR_TBL, C_SCAN, C_CHANNEL_SWITCH - * - * Each entry contains two values: - * 1) DSP gain (or sometimes called DSP attenuation). This is a fine-grained - * linear value that multiplies the output of the digital signal processor, - * before being sent to the analog radio. - * 2) Radio gain. This sets the analog gain of the radio Tx path. - * It is a coarser setting, and behaves in a logarithmic (dB) fashion. - * - * Driver obtains values from struct il3945_tx_power power_gain_table[][]. - */ -struct il3945_tx_power { - u8 tx_gain; /* gain for analog radio */ - u8 dsp_atten; /* gain for DSP */ -} __packed; - -/** - * struct il3945_power_per_rate - * - * Used in C_TX_PWR_TBL, C_CHANNEL_SWITCH - */ -struct il3945_power_per_rate { - u8 rate; /* plcp */ - struct il3945_tx_power tpc; - u8 reserved; -} __packed; - -/** - * iwl4965 rate_n_flags bit fields - * - * rate_n_flags format is used in following iwl4965 commands: - * N_RX (response only) - * N_RX_MPDU (response only) - * C_TX (both command and response) - * C_TX_LINK_QUALITY_CMD - * - * High-throughput (HT) rate format for bits 7:0 (bit 8 must be "1"): - * 2-0: 0) 6 Mbps - * 1) 12 Mbps - * 2) 18 Mbps - * 3) 24 Mbps - * 4) 36 Mbps - * 5) 48 Mbps - * 6) 54 Mbps - * 7) 60 Mbps - * - * 4-3: 0) Single stream (SISO) - * 1) Dual stream (MIMO) - * 2) Triple stream (MIMO) - * - * 5: Value of 0x20 in bits 7:0 indicates 6 Mbps HT40 duplicate data - * - * Legacy OFDM rate format for bits 7:0 (bit 8 must be "0", bit 9 "0"): - * 3-0: 0xD) 6 Mbps - * 0xF) 9 Mbps - * 0x5) 12 Mbps - * 0x7) 18 Mbps - * 0x9) 24 Mbps - * 0xB) 36 Mbps - * 0x1) 48 Mbps - * 0x3) 54 Mbps - * - * Legacy CCK rate format for bits 7:0 (bit 8 must be "0", bit 9 "1"): - * 6-0: 10) 1 Mbps - * 20) 2 Mbps - * 55) 5.5 Mbps - * 110) 11 Mbps - */ -#define RATE_MCS_CODE_MSK 0x7 -#define RATE_MCS_SPATIAL_POS 3 -#define RATE_MCS_SPATIAL_MSK 0x18 -#define RATE_MCS_HT_DUP_POS 5 -#define RATE_MCS_HT_DUP_MSK 0x20 - -/* Bit 8: (1) HT format, (0) legacy format in bits 7:0 */ -#define RATE_MCS_FLAGS_POS 8 -#define RATE_MCS_HT_POS 8 -#define RATE_MCS_HT_MSK 0x100 - -/* Bit 9: (1) CCK, (0) OFDM. HT (bit 8) must be "0" for this bit to be valid */ -#define RATE_MCS_CCK_POS 9 -#define RATE_MCS_CCK_MSK 0x200 - -/* Bit 10: (1) Use Green Field preamble */ -#define RATE_MCS_GF_POS 10 -#define RATE_MCS_GF_MSK 0x400 - -/* Bit 11: (1) Use 40Mhz HT40 chnl width, (0) use 20 MHz legacy chnl width */ -#define RATE_MCS_HT40_POS 11 -#define RATE_MCS_HT40_MSK 0x800 - -/* Bit 12: (1) Duplicate data on both 20MHz chnls. HT40 (bit 11) must be set. */ -#define RATE_MCS_DUP_POS 12 -#define RATE_MCS_DUP_MSK 0x1000 - -/* Bit 13: (1) Short guard interval (0.4 usec), (0) normal GI (0.8 usec) */ -#define RATE_MCS_SGI_POS 13 -#define RATE_MCS_SGI_MSK 0x2000 - -/** - * rate_n_flags Tx antenna masks - * 4965 has 2 transmitters - * bit14:16 - */ -#define RATE_MCS_ANT_POS 14 -#define RATE_MCS_ANT_A_MSK 0x04000 -#define RATE_MCS_ANT_B_MSK 0x08000 -#define RATE_MCS_ANT_C_MSK 0x10000 -#define RATE_MCS_ANT_AB_MSK (RATE_MCS_ANT_A_MSK | RATE_MCS_ANT_B_MSK) -#define RATE_MCS_ANT_ABC_MSK (RATE_MCS_ANT_AB_MSK | RATE_MCS_ANT_C_MSK) -#define RATE_ANT_NUM 3 - -#define POWER_TBL_NUM_ENTRIES 33 -#define POWER_TBL_NUM_HT_OFDM_ENTRIES 32 -#define POWER_TBL_CCK_ENTRY 32 - -#define IL_PWR_NUM_HT_OFDM_ENTRIES 24 -#define IL_PWR_CCK_ENTRIES 2 - -/** - * union il4965_tx_power_dual_stream - * - * Host format used for C_TX_PWR_TBL, C_CHANNEL_SWITCH - * Use __le32 version (struct tx_power_dual_stream) when building command. - * - * Driver provides radio gain and DSP attenuation settings to device in pairs, - * one value for each transmitter chain. The first value is for transmitter A, - * second for transmitter B. - * - * For SISO bit rates, both values in a pair should be identical. - * For MIMO rates, one value may be different from the other, - * in order to balance the Tx output between the two transmitters. - * - * See more details in doc for TXPOWER in 4965.h. - */ -union il4965_tx_power_dual_stream { - struct { - u8 radio_tx_gain[2]; - u8 dsp_predis_atten[2]; - } s; - u32 dw; -}; - -/** - * struct tx_power_dual_stream - * - * Table entries in C_TX_PWR_TBL, C_CHANNEL_SWITCH - * - * Same format as il_tx_power_dual_stream, but __le32 - */ -struct tx_power_dual_stream { - __le32 dw; -} __packed; - -/** - * struct il4965_tx_power_db - * - * Entire table within C_TX_PWR_TBL, C_CHANNEL_SWITCH - */ -struct il4965_tx_power_db { - struct tx_power_dual_stream power_tbl[POWER_TBL_NUM_ENTRIES]; -} __packed; - -/****************************************************************************** - * (0a) - * Alive and Error Commands & Responses: - * - *****************************************************************************/ - -#define UCODE_VALID_OK cpu_to_le32(0x1) -#define INITIALIZE_SUBTYPE (9) - -/* - * ("Initialize") N_ALIVE = 0x1 (response only, not a command) - * - * uCode issues this "initialize alive" notification once the initialization - * uCode image has completed its work, and is ready to load the runtime image. - * This is the *first* "alive" notification that the driver will receive after - * rebooting uCode; the "initialize" alive is indicated by subtype field == 9. - * - * See comments documenting "BSM" (bootstrap state machine). - * - * For 4965, this notification contains important calibration data for - * calculating txpower settings: - * - * 1) Power supply voltage indication. The voltage sensor outputs higher - * values for lower voltage, and vice verse. - * - * 2) Temperature measurement parameters, for each of two channel widths - * (20 MHz and 40 MHz) supported by the radios. Temperature sensing - * is done via one of the receiver chains, and channel width influences - * the results. - * - * 3) Tx gain compensation to balance 4965's 2 Tx chains for MIMO operation, - * for each of 5 frequency ranges. - */ -struct il_init_alive_resp { - u8 ucode_minor; - u8 ucode_major; - __le16 reserved1; - u8 sw_rev[8]; - u8 ver_type; - u8 ver_subtype; /* "9" for initialize alive */ - __le16 reserved2; - __le32 log_event_table_ptr; - __le32 error_event_table_ptr; - __le32 timestamp; - __le32 is_valid; - - /* calibration values from "initialize" uCode */ - __le32 voltage; /* signed, higher value is lower voltage */ - __le32 therm_r1[2]; /* signed, 1st for normal, 2nd for HT40 */ - __le32 therm_r2[2]; /* signed */ - __le32 therm_r3[2]; /* signed */ - __le32 therm_r4[2]; /* signed */ - __le32 tx_atten[5][2]; /* signed MIMO gain comp, 5 freq groups, - * 2 Tx chains */ -} __packed; - - -/** - * N_ALIVE = 0x1 (response only, not a command) - * - * uCode issues this "alive" notification once the runtime image is ready - * to receive commands from the driver. This is the *second* "alive" - * notification that the driver will receive after rebooting uCode; - * this "alive" is indicated by subtype field != 9. - * - * See comments documenting "BSM" (bootstrap state machine). - * - * This response includes two pointers to structures within the device's - * data SRAM (access via HBUS_TARG_MEM_* regs) that are useful for debugging: - * - * 1) log_event_table_ptr indicates base of the event log. This traces - * a 256-entry history of uCode execution within a circular buffer. - * Its header format is: - * - * __le32 log_size; log capacity (in number of entries) - * __le32 type; (1) timestamp with each entry, (0) no timestamp - * __le32 wraps; # times uCode has wrapped to top of circular buffer - * __le32 write_idx; next circular buffer entry that uCode would fill - * - * The header is followed by the circular buffer of log entries. Entries - * with timestamps have the following format: - * - * __le32 event_id; range 0 - 1500 - * __le32 timestamp; low 32 bits of TSF (of network, if associated) - * __le32 data; event_id-specific data value - * - * Entries without timestamps contain only event_id and data. - * - * - * 2) error_event_table_ptr indicates base of the error log. This contains - * information about any uCode error that occurs. For 4965, the format - * of the error log is: - * - * __le32 valid; (nonzero) valid, (0) log is empty - * __le32 error_id; type of error - * __le32 pc; program counter - * __le32 blink1; branch link - * __le32 blink2; branch link - * __le32 ilink1; interrupt link - * __le32 ilink2; interrupt link - * __le32 data1; error-specific data - * __le32 data2; error-specific data - * __le32 line; source code line of error - * __le32 bcon_time; beacon timer - * __le32 tsf_low; network timestamp function timer - * __le32 tsf_hi; network timestamp function timer - * __le32 gp1; GP1 timer register - * __le32 gp2; GP2 timer register - * __le32 gp3; GP3 timer register - * __le32 ucode_ver; uCode version - * __le32 hw_ver; HW Silicon version - * __le32 brd_ver; HW board version - * __le32 log_pc; log program counter - * __le32 frame_ptr; frame pointer - * __le32 stack_ptr; stack pointer - * __le32 hcmd; last host command - * __le32 isr0; isr status register LMPM_NIC_ISR0: rxtx_flag - * __le32 isr1; isr status register LMPM_NIC_ISR1: host_flag - * __le32 isr2; isr status register LMPM_NIC_ISR2: enc_flag - * __le32 isr3; isr status register LMPM_NIC_ISR3: time_flag - * __le32 isr4; isr status register LMPM_NIC_ISR4: wico interrupt - * __le32 isr_pref; isr status register LMPM_NIC_PREF_STAT - * __le32 wait_event; wait event() caller address - * __le32 l2p_control; L2pControlField - * __le32 l2p_duration; L2pDurationField - * __le32 l2p_mhvalid; L2pMhValidBits - * __le32 l2p_addr_match; L2pAddrMatchStat - * __le32 lmpm_pmg_sel; indicate which clocks are turned on (LMPM_PMG_SEL) - * __le32 u_timestamp; indicate when the date and time of the compilation - * __le32 reserved; - * - * The Linux driver can print both logs to the system log when a uCode error - * occurs. - */ -struct il_alive_resp { - u8 ucode_minor; - u8 ucode_major; - __le16 reserved1; - u8 sw_rev[8]; - u8 ver_type; - u8 ver_subtype; /* not "9" for runtime alive */ - __le16 reserved2; - __le32 log_event_table_ptr; /* SRAM address for event log */ - __le32 error_event_table_ptr; /* SRAM address for error log */ - __le32 timestamp; - __le32 is_valid; -} __packed; - -/* - * N_ERROR = 0x2 (response only, not a command) - */ -struct il_error_resp { - __le32 error_type; - u8 cmd_id; - u8 reserved1; - __le16 bad_cmd_seq_num; - __le32 error_info; - __le64 timestamp; -} __packed; - -/****************************************************************************** - * (1) - * RXON Commands & Responses: - * - *****************************************************************************/ - -/* - * Rx config defines & structure - */ -/* rx_config device types */ -enum { - RXON_DEV_TYPE_AP = 1, - RXON_DEV_TYPE_ESS = 3, - RXON_DEV_TYPE_IBSS = 4, - RXON_DEV_TYPE_SNIFFER = 6, -}; - - -#define RXON_RX_CHAIN_DRIVER_FORCE_MSK cpu_to_le16(0x1 << 0) -#define RXON_RX_CHAIN_DRIVER_FORCE_POS (0) -#define RXON_RX_CHAIN_VALID_MSK cpu_to_le16(0x7 << 1) -#define RXON_RX_CHAIN_VALID_POS (1) -#define RXON_RX_CHAIN_FORCE_SEL_MSK cpu_to_le16(0x7 << 4) -#define RXON_RX_CHAIN_FORCE_SEL_POS (4) -#define RXON_RX_CHAIN_FORCE_MIMO_SEL_MSK cpu_to_le16(0x7 << 7) -#define RXON_RX_CHAIN_FORCE_MIMO_SEL_POS (7) -#define RXON_RX_CHAIN_CNT_MSK cpu_to_le16(0x3 << 10) -#define RXON_RX_CHAIN_CNT_POS (10) -#define RXON_RX_CHAIN_MIMO_CNT_MSK cpu_to_le16(0x3 << 12) -#define RXON_RX_CHAIN_MIMO_CNT_POS (12) -#define RXON_RX_CHAIN_MIMO_FORCE_MSK cpu_to_le16(0x1 << 14) -#define RXON_RX_CHAIN_MIMO_FORCE_POS (14) - -/* rx_config flags */ -/* band & modulation selection */ -#define RXON_FLG_BAND_24G_MSK cpu_to_le32(1 << 0) -#define RXON_FLG_CCK_MSK cpu_to_le32(1 << 1) -/* auto detection enable */ -#define RXON_FLG_AUTO_DETECT_MSK cpu_to_le32(1 << 2) -/* TGg protection when tx */ -#define RXON_FLG_TGG_PROTECT_MSK cpu_to_le32(1 << 3) -/* cck short slot & preamble */ -#define RXON_FLG_SHORT_SLOT_MSK cpu_to_le32(1 << 4) -#define RXON_FLG_SHORT_PREAMBLE_MSK cpu_to_le32(1 << 5) -/* antenna selection */ -#define RXON_FLG_DIS_DIV_MSK cpu_to_le32(1 << 7) -#define RXON_FLG_ANT_SEL_MSK cpu_to_le32(0x0f00) -#define RXON_FLG_ANT_A_MSK cpu_to_le32(1 << 8) -#define RXON_FLG_ANT_B_MSK cpu_to_le32(1 << 9) -/* radar detection enable */ -#define RXON_FLG_RADAR_DETECT_MSK cpu_to_le32(1 << 12) -#define RXON_FLG_TGJ_NARROW_BAND_MSK cpu_to_le32(1 << 13) -/* rx response to host with 8-byte TSF -* (according to ON_AIR deassertion) */ -#define RXON_FLG_TSF2HOST_MSK cpu_to_le32(1 << 15) - - -/* HT flags */ -#define RXON_FLG_CTRL_CHANNEL_LOC_POS (22) -#define RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK cpu_to_le32(0x1 << 22) - -#define RXON_FLG_HT_OPERATING_MODE_POS (23) - -#define RXON_FLG_HT_PROT_MSK cpu_to_le32(0x1 << 23) -#define RXON_FLG_HT40_PROT_MSK cpu_to_le32(0x2 << 23) - -#define RXON_FLG_CHANNEL_MODE_POS (25) -#define RXON_FLG_CHANNEL_MODE_MSK cpu_to_le32(0x3 << 25) - -/* channel mode */ -enum { - CHANNEL_MODE_LEGACY = 0, - CHANNEL_MODE_PURE_40 = 1, - CHANNEL_MODE_MIXED = 2, - CHANNEL_MODE_RESERVED = 3, -}; -#define RXON_FLG_CHANNEL_MODE_LEGACY \ - cpu_to_le32(CHANNEL_MODE_LEGACY << RXON_FLG_CHANNEL_MODE_POS) -#define RXON_FLG_CHANNEL_MODE_PURE_40 \ - cpu_to_le32(CHANNEL_MODE_PURE_40 << RXON_FLG_CHANNEL_MODE_POS) -#define RXON_FLG_CHANNEL_MODE_MIXED \ - cpu_to_le32(CHANNEL_MODE_MIXED << RXON_FLG_CHANNEL_MODE_POS) - -/* CTS to self (if spec allows) flag */ -#define RXON_FLG_SELF_CTS_EN cpu_to_le32(0x1<<30) - -/* rx_config filter flags */ -/* accept all data frames */ -#define RXON_FILTER_PROMISC_MSK cpu_to_le32(1 << 0) -/* pass control & management to host */ -#define RXON_FILTER_CTL2HOST_MSK cpu_to_le32(1 << 1) -/* accept multi-cast */ -#define RXON_FILTER_ACCEPT_GRP_MSK cpu_to_le32(1 << 2) -/* don't decrypt uni-cast frames */ -#define RXON_FILTER_DIS_DECRYPT_MSK cpu_to_le32(1 << 3) -/* don't decrypt multi-cast frames */ -#define RXON_FILTER_DIS_GRP_DECRYPT_MSK cpu_to_le32(1 << 4) -/* STA is associated */ -#define RXON_FILTER_ASSOC_MSK cpu_to_le32(1 << 5) -/* transfer to host non bssid beacons in associated state */ -#define RXON_FILTER_BCON_AWARE_MSK cpu_to_le32(1 << 6) - -/** - * C_RXON = 0x10 (command, has simple generic response) - * - * RXON tunes the radio tuner to a service channel, and sets up a number - * of parameters that are used primarily for Rx, but also for Tx operations. - * - * NOTE: When tuning to a new channel, driver must set the - * RXON_FILTER_ASSOC_MSK to 0. This will clear station-dependent - * info within the device, including the station tables, tx retry - * rate tables, and txpower tables. Driver must build a new station - * table and txpower table before transmitting anything on the RXON - * channel. - * - * NOTE: All RXONs wipe clean the internal txpower table. Driver must - * issue a new C_TX_PWR_TBL after each C_RXON (0x10), - * regardless of whether RXON_FILTER_ASSOC_MSK is set. - */ - -struct il3945_rxon_cmd { - u8 node_addr[6]; - __le16 reserved1; - u8 bssid_addr[6]; - __le16 reserved2; - u8 wlap_bssid_addr[6]; - __le16 reserved3; - u8 dev_type; - u8 air_propagation; - __le16 reserved4; - u8 ofdm_basic_rates; - u8 cck_basic_rates; - __le16 assoc_id; - __le32 flags; - __le32 filter_flags; - __le16 channel; - __le16 reserved5; -} __packed; - -struct il4965_rxon_cmd { - u8 node_addr[6]; - __le16 reserved1; - u8 bssid_addr[6]; - __le16 reserved2; - u8 wlap_bssid_addr[6]; - __le16 reserved3; - u8 dev_type; - u8 air_propagation; - __le16 rx_chain; - u8 ofdm_basic_rates; - u8 cck_basic_rates; - __le16 assoc_id; - __le32 flags; - __le32 filter_flags; - __le16 channel; - u8 ofdm_ht_single_stream_basic_rates; - u8 ofdm_ht_dual_stream_basic_rates; -} __packed; - -/* Create a common rxon cmd which will be typecast into the 3945 or 4965 - * specific rxon cmd, depending on where it is called from. - */ -struct il_rxon_cmd { - u8 node_addr[6]; - __le16 reserved1; - u8 bssid_addr[6]; - __le16 reserved2; - u8 wlap_bssid_addr[6]; - __le16 reserved3; - u8 dev_type; - u8 air_propagation; - __le16 rx_chain; - u8 ofdm_basic_rates; - u8 cck_basic_rates; - __le16 assoc_id; - __le32 flags; - __le32 filter_flags; - __le16 channel; - u8 ofdm_ht_single_stream_basic_rates; - u8 ofdm_ht_dual_stream_basic_rates; - u8 reserved4; - u8 reserved5; -} __packed; - - -/* - * C_RXON_ASSOC = 0x11 (command, has simple generic response) - */ -struct il3945_rxon_assoc_cmd { - __le32 flags; - __le32 filter_flags; - u8 ofdm_basic_rates; - u8 cck_basic_rates; - __le16 reserved; -} __packed; - -struct il4965_rxon_assoc_cmd { - __le32 flags; - __le32 filter_flags; - u8 ofdm_basic_rates; - u8 cck_basic_rates; - u8 ofdm_ht_single_stream_basic_rates; - u8 ofdm_ht_dual_stream_basic_rates; - __le16 rx_chain_select_flags; - __le16 reserved; -} __packed; - -#define IL_CONN_MAX_LISTEN_INTERVAL 10 -#define IL_MAX_UCODE_BEACON_INTERVAL 4 /* 4096 */ -#define IL39_MAX_UCODE_BEACON_INTERVAL 1 /* 1024 */ - -/* - * C_RXON_TIMING = 0x14 (command, has simple generic response) - */ -struct il_rxon_time_cmd { - __le64 timestamp; - __le16 beacon_interval; - __le16 atim_win; - __le32 beacon_init_val; - __le16 listen_interval; - u8 dtim_period; - u8 delta_cp_bss_tbtts; -} __packed; - -/* - * C_CHANNEL_SWITCH = 0x72 (command, has simple generic response) - */ -struct il3945_channel_switch_cmd { - u8 band; - u8 expect_beacon; - __le16 channel; - __le32 rxon_flags; - __le32 rxon_filter_flags; - __le32 switch_time; - struct il3945_power_per_rate power[IL_MAX_RATES]; -} __packed; - -struct il4965_channel_switch_cmd { - u8 band; - u8 expect_beacon; - __le16 channel; - __le32 rxon_flags; - __le32 rxon_filter_flags; - __le32 switch_time; - struct il4965_tx_power_db tx_power; -} __packed; - -/* - * N_CHANNEL_SWITCH = 0x73 (notification only, not a command) - */ -struct il_csa_notification { - __le16 band; - __le16 channel; - __le32 status; /* 0 - OK, 1 - fail */ -} __packed; - -/****************************************************************************** - * (2) - * Quality-of-Service (QOS) Commands & Responses: - * - *****************************************************************************/ - -/** - * struct il_ac_qos -- QOS timing params for C_QOS_PARAM - * One for each of 4 EDCA access categories in struct il_qosparam_cmd - * - * @cw_min: Contention win, start value in numbers of slots. - * Should be a power-of-2, minus 1. Device's default is 0x0f. - * @cw_max: Contention win, max value in numbers of slots. - * Should be a power-of-2, minus 1. Device's default is 0x3f. - * @aifsn: Number of slots in Arbitration Interframe Space (before - * performing random backoff timing prior to Tx). Device default 1. - * @edca_txop: Length of Tx opportunity, in uSecs. Device default is 0. - * - * Device will automatically increase contention win by (2*CW) + 1 for each - * transmission retry. Device uses cw_max as a bit mask, ANDed with new CW - * value, to cap the CW value. - */ -struct il_ac_qos { - __le16 cw_min; - __le16 cw_max; - u8 aifsn; - u8 reserved1; - __le16 edca_txop; -} __packed; - -/* QoS flags defines */ -#define QOS_PARAM_FLG_UPDATE_EDCA_MSK cpu_to_le32(0x01) -#define QOS_PARAM_FLG_TGN_MSK cpu_to_le32(0x02) -#define QOS_PARAM_FLG_TXOP_TYPE_MSK cpu_to_le32(0x10) - -/* Number of Access Categories (AC) (EDCA), queues 0..3 */ -#define AC_NUM 4 - -/* - * C_QOS_PARAM = 0x13 (command, has simple generic response) - * - * This command sets up timings for each of the 4 prioritized EDCA Tx FIFOs - * 0: Background, 1: Best Effort, 2: Video, 3: Voice. - */ -struct il_qosparam_cmd { - __le32 qos_flags; - struct il_ac_qos ac[AC_NUM]; -} __packed; - -/****************************************************************************** - * (3) - * Add/Modify Stations Commands & Responses: - * - *****************************************************************************/ -/* - * Multi station support - */ - -/* Special, dedicated locations within device's station table */ -#define IL_AP_ID 0 -#define IL_STA_ID 2 -#define IL3945_BROADCAST_ID 24 -#define IL3945_STATION_COUNT 25 -#define IL4965_BROADCAST_ID 31 -#define IL4965_STATION_COUNT 32 - -#define IL_STATION_COUNT 32 /* MAX(3945,4965)*/ -#define IL_INVALID_STATION 255 - -#define STA_FLG_TX_RATE_MSK cpu_to_le32(1 << 2) -#define STA_FLG_PWR_SAVE_MSK cpu_to_le32(1 << 8) -#define STA_FLG_RTS_MIMO_PROT_MSK cpu_to_le32(1 << 17) -#define STA_FLG_AGG_MPDU_8US_MSK cpu_to_le32(1 << 18) -#define STA_FLG_MAX_AGG_SIZE_POS (19) -#define STA_FLG_MAX_AGG_SIZE_MSK cpu_to_le32(3 << 19) -#define STA_FLG_HT40_EN_MSK cpu_to_le32(1 << 21) -#define STA_FLG_MIMO_DIS_MSK cpu_to_le32(1 << 22) -#define STA_FLG_AGG_MPDU_DENSITY_POS (23) -#define STA_FLG_AGG_MPDU_DENSITY_MSK cpu_to_le32(7 << 23) - -/* Use in mode field. 1: modify existing entry, 0: add new station entry */ -#define STA_CONTROL_MODIFY_MSK 0x01 - -/* key flags __le16*/ -#define STA_KEY_FLG_ENCRYPT_MSK cpu_to_le16(0x0007) -#define STA_KEY_FLG_NO_ENC cpu_to_le16(0x0000) -#define STA_KEY_FLG_WEP cpu_to_le16(0x0001) -#define STA_KEY_FLG_CCMP cpu_to_le16(0x0002) -#define STA_KEY_FLG_TKIP cpu_to_le16(0x0003) - -#define STA_KEY_FLG_KEYID_POS 8 -#define STA_KEY_FLG_INVALID cpu_to_le16(0x0800) -/* wep key is either from global key (0) or from station info array (1) */ -#define STA_KEY_FLG_MAP_KEY_MSK cpu_to_le16(0x0008) - -/* wep key in STA: 5-bytes (0) or 13-bytes (1) */ -#define STA_KEY_FLG_KEY_SIZE_MSK cpu_to_le16(0x1000) -#define STA_KEY_MULTICAST_MSK cpu_to_le16(0x4000) -#define STA_KEY_MAX_NUM 8 - -/* Flags indicate whether to modify vs. don't change various station params */ -#define STA_MODIFY_KEY_MASK 0x01 -#define STA_MODIFY_TID_DISABLE_TX 0x02 -#define STA_MODIFY_TX_RATE_MSK 0x04 -#define STA_MODIFY_ADDBA_TID_MSK 0x08 -#define STA_MODIFY_DELBA_TID_MSK 0x10 -#define STA_MODIFY_SLEEP_TX_COUNT_MSK 0x20 - -/* Receiver address (actually, Rx station's idx into station table), - * combined with Traffic ID (QOS priority), in format used by Tx Scheduler */ -#define BUILD_RAxTID(sta_id, tid) (((sta_id) << 4) + (tid)) - -struct il4965_keyinfo { - __le16 key_flags; - u8 tkip_rx_tsc_byte2; /* TSC[2] for key mix ph1 detection */ - u8 reserved1; - __le16 tkip_rx_ttak[5]; /* 10-byte unicast TKIP TTAK */ - u8 key_offset; - u8 reserved2; - u8 key[16]; /* 16-byte unicast decryption key */ -} __packed; - -/** - * struct sta_id_modify - * @addr[ETH_ALEN]: station's MAC address - * @sta_id: idx of station in uCode's station table - * @modify_mask: STA_MODIFY_*, 1: modify, 0: don't change - * - * Driver selects unused table idx when adding new station, - * or the idx to a pre-existing station entry when modifying that station. - * Some idxes have special purposes (IL_AP_ID, idx 0, is for AP). - * - * modify_mask flags select which parameters to modify vs. leave alone. - */ -struct sta_id_modify { - u8 addr[ETH_ALEN]; - __le16 reserved1; - u8 sta_id; - u8 modify_mask; - __le16 reserved2; -} __packed; - -/* - * C_ADD_STA = 0x18 (command) - * - * The device contains an internal table of per-station information, - * with info on security keys, aggregation parameters, and Tx rates for - * initial Tx attempt and any retries (4965 devices uses - * C_TX_LINK_QUALITY_CMD, - * 3945 uses C_RATE_SCALE to set up rate tables). - * - * C_ADD_STA sets up the table entry for one station, either creating - * a new entry, or modifying a pre-existing one. - * - * NOTE: RXON command (without "associated" bit set) wipes the station table - * clean. Moving into RF_KILL state does this also. Driver must set up - * new station table before transmitting anything on the RXON channel - * (except active scans or active measurements; those commands carry - * their own txpower/rate setup data). - * - * When getting started on a new channel, driver must set up the - * IL_BROADCAST_ID entry (last entry in the table). For a client - * station in a BSS, once an AP is selected, driver sets up the AP STA - * in the IL_AP_ID entry (1st entry in the table). BROADCAST and AP - * are all that are needed for a BSS client station. If the device is - * used as AP, or in an IBSS network, driver must set up station table - * entries for all STAs in network, starting with idx IL_STA_ID. - */ - -struct il3945_addsta_cmd { - u8 mode; /* 1: modify existing, 0: add new station */ - u8 reserved[3]; - struct sta_id_modify sta; - struct il4965_keyinfo key; - __le32 station_flags; /* STA_FLG_* */ - __le32 station_flags_msk; /* STA_FLG_* */ - - /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID) - * corresponding to bit (e.g. bit 5 controls TID 5). - * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */ - __le16 tid_disable_tx; - - __le16 rate_n_flags; - - /* TID for which to add block-ack support. - * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ - u8 add_immediate_ba_tid; - - /* TID for which to remove block-ack support. - * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */ - u8 remove_immediate_ba_tid; - - /* Starting Sequence Number for added block-ack support. - * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ - __le16 add_immediate_ba_ssn; -} __packed; - -struct il4965_addsta_cmd { - u8 mode; /* 1: modify existing, 0: add new station */ - u8 reserved[3]; - struct sta_id_modify sta; - struct il4965_keyinfo key; - __le32 station_flags; /* STA_FLG_* */ - __le32 station_flags_msk; /* STA_FLG_* */ - - /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID) - * corresponding to bit (e.g. bit 5 controls TID 5). - * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */ - __le16 tid_disable_tx; - - __le16 reserved1; - - /* TID for which to add block-ack support. - * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ - u8 add_immediate_ba_tid; - - /* TID for which to remove block-ack support. - * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */ - u8 remove_immediate_ba_tid; - - /* Starting Sequence Number for added block-ack support. - * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ - __le16 add_immediate_ba_ssn; - - /* - * Number of packets OK to transmit to station even though - * it is asleep -- used to synchronise PS-poll and u-APSD - * responses while ucode keeps track of STA sleep state. - */ - __le16 sleep_tx_count; - - __le16 reserved2; -} __packed; - -/* Wrapper struct for 3945 and 4965 addsta_cmd structures */ -struct il_addsta_cmd { - u8 mode; /* 1: modify existing, 0: add new station */ - u8 reserved[3]; - struct sta_id_modify sta; - struct il4965_keyinfo key; - __le32 station_flags; /* STA_FLG_* */ - __le32 station_flags_msk; /* STA_FLG_* */ - - /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID) - * corresponding to bit (e.g. bit 5 controls TID 5). - * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */ - __le16 tid_disable_tx; - - __le16 rate_n_flags; /* 3945 only */ - - /* TID for which to add block-ack support. - * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ - u8 add_immediate_ba_tid; - - /* TID for which to remove block-ack support. - * Set modify_mask bit STA_MODIFY_DELBA_TID_MSK to use this field. */ - u8 remove_immediate_ba_tid; - - /* Starting Sequence Number for added block-ack support. - * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ - __le16 add_immediate_ba_ssn; - - /* - * Number of packets OK to transmit to station even though - * it is asleep -- used to synchronise PS-poll and u-APSD - * responses while ucode keeps track of STA sleep state. - */ - __le16 sleep_tx_count; - - __le16 reserved2; -} __packed; - - -#define ADD_STA_SUCCESS_MSK 0x1 -#define ADD_STA_NO_ROOM_IN_TBL 0x2 -#define ADD_STA_NO_BLOCK_ACK_RESOURCE 0x4 -#define ADD_STA_MODIFY_NON_EXIST_STA 0x8 -/* - * C_ADD_STA = 0x18 (response) - */ -struct il_add_sta_resp { - u8 status; /* ADD_STA_* */ -} __packed; - -#define REM_STA_SUCCESS_MSK 0x1 -/* - * C_REM_STA = 0x19 (response) - */ -struct il_rem_sta_resp { - u8 status; -} __packed; - -/* - * C_REM_STA = 0x19 (command) - */ -struct il_rem_sta_cmd { - u8 num_sta; /* number of removed stations */ - u8 reserved[3]; - u8 addr[ETH_ALEN]; /* MAC addr of the first station */ - u8 reserved2[2]; -} __packed; - -#define IL_TX_FIFO_BK_MSK cpu_to_le32(BIT(0)) -#define IL_TX_FIFO_BE_MSK cpu_to_le32(BIT(1)) -#define IL_TX_FIFO_VI_MSK cpu_to_le32(BIT(2)) -#define IL_TX_FIFO_VO_MSK cpu_to_le32(BIT(3)) -#define IL_AGG_TX_QUEUE_MSK cpu_to_le32(0xffc00) - -#define IL_DROP_SINGLE 0 -#define IL_DROP_SELECTED 1 -#define IL_DROP_ALL 2 - -/* - * REPLY_WEP_KEY = 0x20 - */ -struct il_wep_key { - u8 key_idx; - u8 key_offset; - u8 reserved1[2]; - u8 key_size; - u8 reserved2[3]; - u8 key[16]; -} __packed; - -struct il_wep_cmd { - u8 num_keys; - u8 global_key_type; - u8 flags; - u8 reserved; - struct il_wep_key key[0]; -} __packed; - -#define WEP_KEY_WEP_TYPE 1 -#define WEP_KEYS_MAX 4 -#define WEP_INVALID_OFFSET 0xff -#define WEP_KEY_LEN_64 5 -#define WEP_KEY_LEN_128 13 - -/****************************************************************************** - * (4) - * Rx Responses: - * - *****************************************************************************/ - -#define RX_RES_STATUS_NO_CRC32_ERROR cpu_to_le32(1 << 0) -#define RX_RES_STATUS_NO_RXE_OVERFLOW cpu_to_le32(1 << 1) - -#define RX_RES_PHY_FLAGS_BAND_24_MSK cpu_to_le16(1 << 0) -#define RX_RES_PHY_FLAGS_MOD_CCK_MSK cpu_to_le16(1 << 1) -#define RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK cpu_to_le16(1 << 2) -#define RX_RES_PHY_FLAGS_NARROW_BAND_MSK cpu_to_le16(1 << 3) -#define RX_RES_PHY_FLAGS_ANTENNA_MSK 0xf0 -#define RX_RES_PHY_FLAGS_ANTENNA_POS 4 - -#define RX_RES_STATUS_SEC_TYPE_MSK (0x7 << 8) -#define RX_RES_STATUS_SEC_TYPE_NONE (0x0 << 8) -#define RX_RES_STATUS_SEC_TYPE_WEP (0x1 << 8) -#define RX_RES_STATUS_SEC_TYPE_CCMP (0x2 << 8) -#define RX_RES_STATUS_SEC_TYPE_TKIP (0x3 << 8) -#define RX_RES_STATUS_SEC_TYPE_ERR (0x7 << 8) - -#define RX_RES_STATUS_STATION_FOUND (1<<6) -#define RX_RES_STATUS_NO_STATION_INFO_MISMATCH (1<<7) - -#define RX_RES_STATUS_DECRYPT_TYPE_MSK (0x3 << 11) -#define RX_RES_STATUS_NOT_DECRYPT (0x0 << 11) -#define RX_RES_STATUS_DECRYPT_OK (0x3 << 11) -#define RX_RES_STATUS_BAD_ICV_MIC (0x1 << 11) -#define RX_RES_STATUS_BAD_KEY_TTAK (0x2 << 11) - -#define RX_MPDU_RES_STATUS_ICV_OK (0x20) -#define RX_MPDU_RES_STATUS_MIC_OK (0x40) -#define RX_MPDU_RES_STATUS_TTAK_OK (1 << 7) -#define RX_MPDU_RES_STATUS_DEC_DONE_MSK (0x800) - - -struct il3945_rx_frame_stats { - u8 phy_count; - u8 id; - u8 rssi; - u8 agc; - __le16 sig_avg; - __le16 noise_diff; - u8 payload[0]; -} __packed; - -struct il3945_rx_frame_hdr { - __le16 channel; - __le16 phy_flags; - u8 reserved1; - u8 rate; - __le16 len; - u8 payload[0]; -} __packed; - -struct il3945_rx_frame_end { - __le32 status; - __le64 timestamp; - __le32 beacon_timestamp; -} __packed; - -/* - * N_3945_RX = 0x1b (response only, not a command) - * - * NOTE: DO NOT dereference from casts to this structure - * It is provided only for calculating minimum data set size. - * The actual offsets of the hdr and end are dynamic based on - * stats.phy_count - */ -struct il3945_rx_frame { - struct il3945_rx_frame_stats stats; - struct il3945_rx_frame_hdr hdr; - struct il3945_rx_frame_end end; -} __packed; - -#define IL39_RX_FRAME_SIZE (4 + sizeof(struct il3945_rx_frame)) - -/* Fixed (non-configurable) rx data from phy */ - -#define IL49_RX_RES_PHY_CNT 14 -#define IL49_RX_PHY_FLAGS_ANTENNAE_OFFSET (4) -#define IL49_RX_PHY_FLAGS_ANTENNAE_MASK (0x70) -#define IL49_AGC_DB_MASK (0x3f80) /* MASK(7,13) */ -#define IL49_AGC_DB_POS (7) -struct il4965_rx_non_cfg_phy { - __le16 ant_selection; /* ant A bit 4, ant B bit 5, ant C bit 6 */ - __le16 agc_info; /* agc code 0:6, agc dB 7:13, reserved 14:15 */ - u8 rssi_info[6]; /* we use even entries, 0/2/4 for A/B/C rssi */ - u8 pad[0]; -} __packed; - - -/* - * N_RX = 0xc3 (response only, not a command) - * Used only for legacy (non 11n) frames. - */ -struct il_rx_phy_res { - u8 non_cfg_phy_cnt; /* non configurable DSP phy data byte count */ - u8 cfg_phy_cnt; /* configurable DSP phy data byte count */ - u8 stat_id; /* configurable DSP phy data set ID */ - u8 reserved1; - __le64 timestamp; /* TSF at on air rise */ - __le32 beacon_time_stamp; /* beacon at on-air rise */ - __le16 phy_flags; /* general phy flags: band, modulation, ... */ - __le16 channel; /* channel number */ - u8 non_cfg_phy_buf[32]; /* for various implementations of non_cfg_phy */ - __le32 rate_n_flags; /* RATE_MCS_* */ - __le16 byte_count; /* frame's byte-count */ - __le16 frame_time; /* frame's time on the air */ -} __packed; - -struct il_rx_mpdu_res_start { - __le16 byte_count; - __le16 reserved; -} __packed; - - -/****************************************************************************** - * (5) - * Tx Commands & Responses: - * - * Driver must place each C_TX command into one of the prioritized Tx - * queues in host DRAM, shared between driver and device (see comments for - * SCD registers and Tx/Rx Queues). When the device's Tx scheduler and uCode - * are preparing to transmit, the device pulls the Tx command over the PCI - * bus via one of the device's Tx DMA channels, to fill an internal FIFO - * from which data will be transmitted. - * - * uCode handles all timing and protocol related to control frames - * (RTS/CTS/ACK), based on flags in the Tx command. uCode and Tx scheduler - * handle reception of block-acks; uCode updates the host driver via - * N_COMPRESSED_BA. - * - * uCode handles retrying Tx when an ACK is expected but not received. - * This includes trying lower data rates than the one requested in the Tx - * command, as set up by the C_RATE_SCALE (for 3945) or - * C_TX_LINK_QUALITY_CMD (4965). - * - * Driver sets up transmit power for various rates via C_TX_PWR_TBL. - * This command must be executed after every RXON command, before Tx can occur. - *****************************************************************************/ - -/* C_TX Tx flags field */ - -/* - * 1: Use Request-To-Send protocol before this frame. - * Mutually exclusive vs. TX_CMD_FLG_CTS_MSK. - */ -#define TX_CMD_FLG_RTS_MSK cpu_to_le32(1 << 1) - -/* - * 1: Transmit Clear-To-Send to self before this frame. - * Driver should set this for AUTH/DEAUTH/ASSOC-REQ/REASSOC mgmnt frames. - * Mutually exclusive vs. TX_CMD_FLG_RTS_MSK. - */ -#define TX_CMD_FLG_CTS_MSK cpu_to_le32(1 << 2) - -/* 1: Expect ACK from receiving station - * 0: Don't expect ACK (MAC header's duration field s/b 0) - * Set this for unicast frames, but not broadcast/multicast. */ -#define TX_CMD_FLG_ACK_MSK cpu_to_le32(1 << 3) - -/* For 4965 devices: - * 1: Use rate scale table (see C_TX_LINK_QUALITY_CMD). - * Tx command's initial_rate_idx indicates first rate to try; - * uCode walks through table for additional Tx attempts. - * 0: Use Tx rate/MCS from Tx command's rate_n_flags field. - * This rate will be used for all Tx attempts; it will not be scaled. */ -#define TX_CMD_FLG_STA_RATE_MSK cpu_to_le32(1 << 4) - -/* 1: Expect immediate block-ack. - * Set when Txing a block-ack request frame. Also set TX_CMD_FLG_ACK_MSK. */ -#define TX_CMD_FLG_IMM_BA_RSP_MASK cpu_to_le32(1 << 6) - -/* - * 1: Frame requires full Tx-Op protection. - * Set this if either RTS or CTS Tx Flag gets set. - */ -#define TX_CMD_FLG_FULL_TXOP_PROT_MSK cpu_to_le32(1 << 7) - -/* Tx antenna selection field; used only for 3945, reserved (0) for 4965 devices. - * Set field to "0" to allow 3945 uCode to select antenna (normal usage). */ -#define TX_CMD_FLG_ANT_SEL_MSK cpu_to_le32(0xf00) -#define TX_CMD_FLG_ANT_A_MSK cpu_to_le32(1 << 8) -#define TX_CMD_FLG_ANT_B_MSK cpu_to_le32(1 << 9) - -/* 1: uCode overrides sequence control field in MAC header. - * 0: Driver provides sequence control field in MAC header. - * Set this for management frames, non-QOS data frames, non-unicast frames, - * and also in Tx command embedded in C_SCAN for active scans. */ -#define TX_CMD_FLG_SEQ_CTL_MSK cpu_to_le32(1 << 13) - -/* 1: This frame is non-last MPDU; more fragments are coming. - * 0: Last fragment, or not using fragmentation. */ -#define TX_CMD_FLG_MORE_FRAG_MSK cpu_to_le32(1 << 14) - -/* 1: uCode calculates and inserts Timestamp Function (TSF) in outgoing frame. - * 0: No TSF required in outgoing frame. - * Set this for transmitting beacons and probe responses. */ -#define TX_CMD_FLG_TSF_MSK cpu_to_le32(1 << 16) - -/* 1: Driver inserted 2 bytes pad after the MAC header, for (required) dword - * alignment of frame's payload data field. - * 0: No pad - * Set this for MAC headers with 26 or 30 bytes, i.e. those with QOS or ADDR4 - * field (but not both). Driver must align frame data (i.e. data following - * MAC header) to DWORD boundary. */ -#define TX_CMD_FLG_MH_PAD_MSK cpu_to_le32(1 << 20) - -/* accelerate aggregation support - * 0 - no CCMP encryption; 1 - CCMP encryption */ -#define TX_CMD_FLG_AGG_CCMP_MSK cpu_to_le32(1 << 22) - -/* HCCA-AP - disable duration overwriting. */ -#define TX_CMD_FLG_DUR_MSK cpu_to_le32(1 << 25) - - -/* - * TX command security control - */ -#define TX_CMD_SEC_WEP 0x01 -#define TX_CMD_SEC_CCM 0x02 -#define TX_CMD_SEC_TKIP 0x03 -#define TX_CMD_SEC_MSK 0x03 -#define TX_CMD_SEC_SHIFT 6 -#define TX_CMD_SEC_KEY128 0x08 - -/* - * security overhead sizes - */ -#define WEP_IV_LEN 4 -#define WEP_ICV_LEN 4 -#define CCMP_MIC_LEN 8 -#define TKIP_ICV_LEN 4 - -/* - * C_TX = 0x1c (command) - */ - -struct il3945_tx_cmd { - /* - * MPDU byte count: - * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size, - * + 8 byte IV for CCM or TKIP (not used for WEP) - * + Data payload - * + 8-byte MIC (not used for CCM/WEP) - * NOTE: Does not include Tx command bytes, post-MAC pad bytes, - * MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i - * Range: 14-2342 bytes. - */ - __le16 len; - - /* - * MPDU or MSDU byte count for next frame. - * Used for fragmentation and bursting, but not 11n aggregation. - * Same as "len", but for next frame. Set to 0 if not applicable. - */ - __le16 next_frame_len; - - __le32 tx_flags; /* TX_CMD_FLG_* */ - - u8 rate; - - /* Index of recipient station in uCode's station table */ - u8 sta_id; - u8 tid_tspec; - u8 sec_ctl; - u8 key[16]; - union { - u8 byte[8]; - __le16 word[4]; - __le32 dw[2]; - } tkip_mic; - __le32 next_frame_info; - union { - __le32 life_time; - __le32 attempt; - } stop_time; - u8 supp_rates[2]; - u8 rts_retry_limit; /*byte 50 */ - u8 data_retry_limit; /*byte 51 */ - union { - __le16 pm_frame_timeout; - __le16 attempt_duration; - } timeout; - - /* - * Duration of EDCA burst Tx Opportunity, in 32-usec units. - * Set this if txop time is not specified by HCCA protocol (e.g. by AP). - */ - __le16 driver_txop; - - /* - * MAC header goes here, followed by 2 bytes padding if MAC header - * length is 26 or 30 bytes, followed by payload data - */ - u8 payload[0]; - struct ieee80211_hdr hdr[0]; -} __packed; - -/* - * C_TX = 0x1c (response) - */ -struct il3945_tx_resp { - u8 failure_rts; - u8 failure_frame; - u8 bt_kill_count; - u8 rate; - __le32 wireless_media_time; - __le32 status; /* TX status */ -} __packed; - - -/* - * 4965 uCode updates these Tx attempt count values in host DRAM. - * Used for managing Tx retries when expecting block-acks. - * Driver should set these fields to 0. - */ -struct il_dram_scratch { - u8 try_cnt; /* Tx attempts */ - u8 bt_kill_cnt; /* Tx attempts blocked by Bluetooth device */ - __le16 reserved; -} __packed; - -struct il_tx_cmd { - /* - * MPDU byte count: - * MAC header (24/26/30/32 bytes) + 2 bytes pad if 26/30 header size, - * + 8 byte IV for CCM or TKIP (not used for WEP) - * + Data payload - * + 8-byte MIC (not used for CCM/WEP) - * NOTE: Does not include Tx command bytes, post-MAC pad bytes, - * MIC (CCM) 8 bytes, ICV (WEP/TKIP/CKIP) 4 bytes, CRC 4 bytes.i - * Range: 14-2342 bytes. - */ - __le16 len; - - /* - * MPDU or MSDU byte count for next frame. - * Used for fragmentation and bursting, but not 11n aggregation. - * Same as "len", but for next frame. Set to 0 if not applicable. - */ - __le16 next_frame_len; - - __le32 tx_flags; /* TX_CMD_FLG_* */ - - /* uCode may modify this field of the Tx command (in host DRAM!). - * Driver must also set dram_lsb_ptr and dram_msb_ptr in this cmd. */ - struct il_dram_scratch scratch; - - /* Rate for *all* Tx attempts, if TX_CMD_FLG_STA_RATE_MSK is cleared. */ - __le32 rate_n_flags; /* RATE_MCS_* */ - - /* Index of destination station in uCode's station table */ - u8 sta_id; - - /* Type of security encryption: CCM or TKIP */ - u8 sec_ctl; /* TX_CMD_SEC_* */ - - /* - * Index into rate table (see C_TX_LINK_QUALITY_CMD) for initial - * Tx attempt, if TX_CMD_FLG_STA_RATE_MSK is set. Normally "0" for - * data frames, this field may be used to selectively reduce initial - * rate (via non-0 value) for special frames (e.g. management), while - * still supporting rate scaling for all frames. - */ - u8 initial_rate_idx; - u8 reserved; - u8 key[16]; - __le16 next_frame_flags; - __le16 reserved2; - union { - __le32 life_time; - __le32 attempt; - } stop_time; - - /* Host DRAM physical address pointer to "scratch" in this command. - * Must be dword aligned. "0" in dram_lsb_ptr disables usage. */ - __le32 dram_lsb_ptr; - u8 dram_msb_ptr; - - u8 rts_retry_limit; /*byte 50 */ - u8 data_retry_limit; /*byte 51 */ - u8 tid_tspec; - union { - __le16 pm_frame_timeout; - __le16 attempt_duration; - } timeout; - - /* - * Duration of EDCA burst Tx Opportunity, in 32-usec units. - * Set this if txop time is not specified by HCCA protocol (e.g. by AP). - */ - __le16 driver_txop; - - /* - * MAC header goes here, followed by 2 bytes padding if MAC header - * length is 26 or 30 bytes, followed by payload data - */ - u8 payload[0]; - struct ieee80211_hdr hdr[0]; -} __packed; - -/* TX command response is sent after *3945* transmission attempts. - * - * NOTES: - * - * TX_STATUS_FAIL_NEXT_FRAG - * - * If the fragment flag in the MAC header for the frame being transmitted - * is set and there is insufficient time to transmit the next frame, the - * TX status will be returned with 'TX_STATUS_FAIL_NEXT_FRAG'. - * - * TX_STATUS_FIFO_UNDERRUN - * - * Indicates the host did not provide bytes to the FIFO fast enough while - * a TX was in progress. - * - * TX_STATUS_FAIL_MGMNT_ABORT - * - * This status is only possible if the ABORT ON MGMT RX parameter was - * set to true with the TX command. - * - * If the MSB of the status parameter is set then an abort sequence is - * required. This sequence consists of the host activating the TX Abort - * control line, and then waiting for the TX Abort command response. This - * indicates that a the device is no longer in a transmit state, and that the - * command FIFO has been cleared. The host must then deactivate the TX Abort - * control line. Receiving is still allowed in this case. - */ -enum { - TX_3945_STATUS_SUCCESS = 0x01, - TX_3945_STATUS_DIRECT_DONE = 0x02, - TX_3945_STATUS_FAIL_SHORT_LIMIT = 0x82, - TX_3945_STATUS_FAIL_LONG_LIMIT = 0x83, - TX_3945_STATUS_FAIL_FIFO_UNDERRUN = 0x84, - TX_3945_STATUS_FAIL_MGMNT_ABORT = 0x85, - TX_3945_STATUS_FAIL_NEXT_FRAG = 0x86, - TX_3945_STATUS_FAIL_LIFE_EXPIRE = 0x87, - TX_3945_STATUS_FAIL_DEST_PS = 0x88, - TX_3945_STATUS_FAIL_ABORTED = 0x89, - TX_3945_STATUS_FAIL_BT_RETRY = 0x8a, - TX_3945_STATUS_FAIL_STA_INVALID = 0x8b, - TX_3945_STATUS_FAIL_FRAG_DROPPED = 0x8c, - TX_3945_STATUS_FAIL_TID_DISABLE = 0x8d, - TX_3945_STATUS_FAIL_FRAME_FLUSHED = 0x8e, - TX_3945_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f, - TX_3945_STATUS_FAIL_TX_LOCKED = 0x90, - TX_3945_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91, -}; - -/* - * TX command response is sent after *4965* transmission attempts. - * - * both postpone and abort status are expected behavior from uCode. there is - * no special operation required from driver; except for RFKILL_FLUSH, - * which required tx flush host command to flush all the tx frames in queues - */ -enum { - TX_STATUS_SUCCESS = 0x01, - TX_STATUS_DIRECT_DONE = 0x02, - /* postpone TX */ - TX_STATUS_POSTPONE_DELAY = 0x40, - TX_STATUS_POSTPONE_FEW_BYTES = 0x41, - TX_STATUS_POSTPONE_QUIET_PERIOD = 0x43, - TX_STATUS_POSTPONE_CALC_TTAK = 0x44, - /* abort TX */ - TX_STATUS_FAIL_INTERNAL_CROSSED_RETRY = 0x81, - TX_STATUS_FAIL_SHORT_LIMIT = 0x82, - TX_STATUS_FAIL_LONG_LIMIT = 0x83, - TX_STATUS_FAIL_FIFO_UNDERRUN = 0x84, - TX_STATUS_FAIL_DRAIN_FLOW = 0x85, - TX_STATUS_FAIL_RFKILL_FLUSH = 0x86, - TX_STATUS_FAIL_LIFE_EXPIRE = 0x87, - TX_STATUS_FAIL_DEST_PS = 0x88, - TX_STATUS_FAIL_HOST_ABORTED = 0x89, - TX_STATUS_FAIL_BT_RETRY = 0x8a, - TX_STATUS_FAIL_STA_INVALID = 0x8b, - TX_STATUS_FAIL_FRAG_DROPPED = 0x8c, - TX_STATUS_FAIL_TID_DISABLE = 0x8d, - TX_STATUS_FAIL_FIFO_FLUSHED = 0x8e, - TX_STATUS_FAIL_INSUFFICIENT_CF_POLL = 0x8f, - TX_STATUS_FAIL_PASSIVE_NO_RX = 0x90, - TX_STATUS_FAIL_NO_BEACON_ON_RADAR = 0x91, -}; - -#define TX_PACKET_MODE_REGULAR 0x0000 -#define TX_PACKET_MODE_BURST_SEQ 0x0100 -#define TX_PACKET_MODE_BURST_FIRST 0x0200 - -enum { - TX_POWER_PA_NOT_ACTIVE = 0x0, -}; - -enum { - TX_STATUS_MSK = 0x000000ff, /* bits 0:7 */ - TX_STATUS_DELAY_MSK = 0x00000040, - TX_STATUS_ABORT_MSK = 0x00000080, - TX_PACKET_MODE_MSK = 0x0000ff00, /* bits 8:15 */ - TX_FIFO_NUMBER_MSK = 0x00070000, /* bits 16:18 */ - TX_RESERVED = 0x00780000, /* bits 19:22 */ - TX_POWER_PA_DETECT_MSK = 0x7f800000, /* bits 23:30 */ - TX_ABORT_REQUIRED_MSK = 0x80000000, /* bits 31:31 */ -}; - -/* ******************************* - * TX aggregation status - ******************************* */ - -enum { - AGG_TX_STATE_TRANSMITTED = 0x00, - AGG_TX_STATE_UNDERRUN_MSK = 0x01, - AGG_TX_STATE_FEW_BYTES_MSK = 0x04, - AGG_TX_STATE_ABORT_MSK = 0x08, - AGG_TX_STATE_LAST_SENT_TTL_MSK = 0x10, - AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK = 0x20, - AGG_TX_STATE_SCD_QUERY_MSK = 0x80, - AGG_TX_STATE_TEST_BAD_CRC32_MSK = 0x100, - AGG_TX_STATE_RESPONSE_MSK = 0x1ff, - AGG_TX_STATE_DUMP_TX_MSK = 0x200, - AGG_TX_STATE_DELAY_TX_MSK = 0x400 -}; - -#define AGG_TX_STATUS_MSK 0x00000fff /* bits 0:11 */ -#define AGG_TX_TRY_MSK 0x0000f000 /* bits 12:15 */ - -#define AGG_TX_STATE_LAST_SENT_MSK (AGG_TX_STATE_LAST_SENT_TTL_MSK | \ - AGG_TX_STATE_LAST_SENT_TRY_CNT_MSK) - -/* # tx attempts for first frame in aggregation */ -#define AGG_TX_STATE_TRY_CNT_POS 12 -#define AGG_TX_STATE_TRY_CNT_MSK 0xf000 - -/* Command ID and sequence number of Tx command for this frame */ -#define AGG_TX_STATE_SEQ_NUM_POS 16 -#define AGG_TX_STATE_SEQ_NUM_MSK 0xffff0000 - -/* - * C_TX = 0x1c (response) - * - * This response may be in one of two slightly different formats, indicated - * by the frame_count field: - * - * 1) No aggregation (frame_count == 1). This reports Tx results for - * a single frame. Multiple attempts, at various bit rates, may have - * been made for this frame. - * - * 2) Aggregation (frame_count > 1). This reports Tx results for - * 2 or more frames that used block-acknowledge. All frames were - * transmitted at same rate. Rate scaling may have been used if first - * frame in this new agg block failed in previous agg block(s). - * - * Note that, for aggregation, ACK (block-ack) status is not delivered here; - * block-ack has not been received by the time the 4965 device records - * this status. - * This status relates to reasons the tx might have been blocked or aborted - * within the sending station (this 4965 device), rather than whether it was - * received successfully by the destination station. - */ -struct agg_tx_status { - __le16 status; - __le16 sequence; -} __packed; - -struct il4965_tx_resp { - u8 frame_count; /* 1 no aggregation, >1 aggregation */ - u8 bt_kill_count; /* # blocked by bluetooth (unused for agg) */ - u8 failure_rts; /* # failures due to unsuccessful RTS */ - u8 failure_frame; /* # failures due to no ACK (unused for agg) */ - - /* For non-agg: Rate at which frame was successful. - * For agg: Rate at which all frames were transmitted. */ - __le32 rate_n_flags; /* RATE_MCS_* */ - - /* For non-agg: RTS + CTS + frame tx attempts time + ACK. - * For agg: RTS + CTS + aggregation tx time + block-ack time. */ - __le16 wireless_media_time; /* uSecs */ - - __le16 reserved; - __le32 pa_power1; /* RF power amplifier measurement (not used) */ - __le32 pa_power2; - - /* - * For non-agg: frame status TX_STATUS_* - * For agg: status of 1st frame, AGG_TX_STATE_*; other frame status - * fields follow this one, up to frame_count. - * Bit fields: - * 11- 0: AGG_TX_STATE_* status code - * 15-12: Retry count for 1st frame in aggregation (retries - * occur if tx failed for this frame when it was a - * member of a previous aggregation block). If rate - * scaling is used, retry count indicates the rate - * table entry used for all frames in the new agg. - * 31-16: Sequence # for this frame's Tx cmd (not SSN!) - */ - union { - __le32 status; - struct agg_tx_status agg_status[0]; /* for each agg frame */ - } u; -} __packed; - -/* - * N_COMPRESSED_BA = 0xc5 (response only, not a command) - * - * Reports Block-Acknowledge from recipient station - */ -struct il_compressed_ba_resp { - __le32 sta_addr_lo32; - __le16 sta_addr_hi16; - __le16 reserved; - - /* Index of recipient (BA-sending) station in uCode's station table */ - u8 sta_id; - u8 tid; - __le16 seq_ctl; - __le64 bitmap; - __le16 scd_flow; - __le16 scd_ssn; -} __packed; - -/* - * C_TX_PWR_TBL = 0x97 (command, has simple generic response) - * - * See details under "TXPOWER" in 4965.h. - */ - -struct il3945_txpowertable_cmd { - u8 band; /* 0: 5 GHz, 1: 2.4 GHz */ - u8 reserved; - __le16 channel; - struct il3945_power_per_rate power[IL_MAX_RATES]; -} __packed; - -struct il4965_txpowertable_cmd { - u8 band; /* 0: 5 GHz, 1: 2.4 GHz */ - u8 reserved; - __le16 channel; - struct il4965_tx_power_db tx_power; -} __packed; - - -/** - * struct il3945_rate_scaling_cmd - Rate Scaling Command & Response - * - * C_RATE_SCALE = 0x47 (command, has simple generic response) - * - * NOTE: The table of rates passed to the uCode via the - * RATE_SCALE command sets up the corresponding order of - * rates used for all related commands, including rate - * masks, etc. - * - * For example, if you set 9MB (PLCP 0x0f) as the first - * rate in the rate table, the bit mask for that rate - * when passed through ofdm_basic_rates on the C_RXON - * command would be bit 0 (1 << 0) - */ -struct il3945_rate_scaling_info { - __le16 rate_n_flags; - u8 try_cnt; - u8 next_rate_idx; -} __packed; - -struct il3945_rate_scaling_cmd { - u8 table_id; - u8 reserved[3]; - struct il3945_rate_scaling_info table[IL_MAX_RATES]; -} __packed; - - -/*RS_NEW_API: only TLC_RTS remains and moved to bit 0 */ -#define LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK (1 << 0) - -/* # of EDCA prioritized tx fifos */ -#define LINK_QUAL_AC_NUM AC_NUM - -/* # entries in rate scale table to support Tx retries */ -#define LINK_QUAL_MAX_RETRY_NUM 16 - -/* Tx antenna selection values */ -#define LINK_QUAL_ANT_A_MSK (1 << 0) -#define LINK_QUAL_ANT_B_MSK (1 << 1) -#define LINK_QUAL_ANT_MSK (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK) - - -/** - * struct il_link_qual_general_params - * - * Used in C_TX_LINK_QUALITY_CMD - */ -struct il_link_qual_general_params { - u8 flags; - - /* No entries at or above this (driver chosen) idx contain MIMO */ - u8 mimo_delimiter; - - /* Best single antenna to use for single stream (legacy, SISO). */ - u8 single_stream_ant_msk; /* LINK_QUAL_ANT_* */ - - /* Best antennas to use for MIMO (unused for 4965, assumes both). */ - u8 dual_stream_ant_msk; /* LINK_QUAL_ANT_* */ - - /* - * If driver needs to use different initial rates for different - * EDCA QOS access categories (as implemented by tx fifos 0-3), - * this table will set that up, by indicating the idxes in the - * rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table at which to start. - * Otherwise, driver should set all entries to 0. - * - * Entry usage: - * 0 = Background, 1 = Best Effort (normal), 2 = Video, 3 = Voice - * TX FIFOs above 3 use same value (typically 0) as TX FIFO 3. - */ - u8 start_rate_idx[LINK_QUAL_AC_NUM]; -} __packed; - -#define LINK_QUAL_AGG_TIME_LIMIT_DEF (4000) /* 4 milliseconds */ -#define LINK_QUAL_AGG_TIME_LIMIT_MAX (8000) -#define LINK_QUAL_AGG_TIME_LIMIT_MIN (100) - -#define LINK_QUAL_AGG_DISABLE_START_DEF (3) -#define LINK_QUAL_AGG_DISABLE_START_MAX (255) -#define LINK_QUAL_AGG_DISABLE_START_MIN (0) - -#define LINK_QUAL_AGG_FRAME_LIMIT_DEF (31) -#define LINK_QUAL_AGG_FRAME_LIMIT_MAX (63) -#define LINK_QUAL_AGG_FRAME_LIMIT_MIN (0) - -/** - * struct il_link_qual_agg_params - * - * Used in C_TX_LINK_QUALITY_CMD - */ -struct il_link_qual_agg_params { - - /* - *Maximum number of uSec in aggregation. - * default set to 4000 (4 milliseconds) if not configured in .cfg - */ - __le16 agg_time_limit; - - /* - * Number of Tx retries allowed for a frame, before that frame will - * no longer be considered for the start of an aggregation sequence - * (scheduler will then try to tx it as single frame). - * Driver should set this to 3. - */ - u8 agg_dis_start_th; - - /* - * Maximum number of frames in aggregation. - * 0 = no limit (default). 1 = no aggregation. - * Other values = max # frames in aggregation. - */ - u8 agg_frame_cnt_limit; - - __le32 reserved; -} __packed; - -/* - * C_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response) - * - * For 4965 devices only; 3945 uses C_RATE_SCALE. - * - * Each station in the 4965 device's internal station table has its own table - * of 16 - * Tx rates and modulation modes (e.g. legacy/SISO/MIMO) for retrying Tx when - * an ACK is not received. This command replaces the entire table for - * one station. - * - * NOTE: Station must already be in 4965 device's station table. - * Use C_ADD_STA. - * - * The rate scaling procedures described below work well. Of course, other - * procedures are possible, and may work better for particular environments. - * - * - * FILLING THE RATE TBL - * - * Given a particular initial rate and mode, as determined by the rate - * scaling algorithm described below, the Linux driver uses the following - * formula to fill the rs_table[LINK_QUAL_MAX_RETRY_NUM] rate table in the - * Link Quality command: - * - * - * 1) If using High-throughput (HT) (SISO or MIMO) initial rate: - * a) Use this same initial rate for first 3 entries. - * b) Find next lower available rate using same mode (SISO or MIMO), - * use for next 3 entries. If no lower rate available, switch to - * legacy mode (no HT40 channel, no MIMO, no short guard interval). - * c) If using MIMO, set command's mimo_delimiter to number of entries - * using MIMO (3 or 6). - * d) After trying 2 HT rates, switch to legacy mode (no HT40 channel, - * no MIMO, no short guard interval), at the next lower bit rate - * (e.g. if second HT bit rate was 54, try 48 legacy), and follow - * legacy procedure for remaining table entries. - * - * 2) If using legacy initial rate: - * a) Use the initial rate for only one entry. - * b) For each following entry, reduce the rate to next lower available - * rate, until reaching the lowest available rate. - * c) When reducing rate, also switch antenna selection. - * d) Once lowest available rate is reached, repeat this rate until - * rate table is filled (16 entries), switching antenna each entry. - * - * - * ACCUMULATING HISTORY - * - * The rate scaling algorithm for 4965 devices, as implemented in Linux driver, - * uses two sets of frame Tx success history: One for the current/active - * modulation mode, and one for a speculative/search mode that is being - * attempted. If the speculative mode turns out to be more effective (i.e. - * actual transfer rate is better), then the driver continues to use the - * speculative mode as the new current active mode. - * - * Each history set contains, separately for each possible rate, data for a - * sliding win of the 62 most recent tx attempts at that rate. The data - * includes a shifting bitmap of success(1)/failure(0), and sums of successful - * and attempted frames, from which the driver can additionally calculate a - * success ratio (success / attempted) and number of failures - * (attempted - success), and control the size of the win (attempted). - * The driver uses the bit map to remove successes from the success sum, as - * the oldest tx attempts fall out of the win. - * - * When the 4965 device makes multiple tx attempts for a given frame, each - * attempt might be at a different rate, and have different modulation - * characteristics (e.g. antenna, fat channel, short guard interval), as set - * up in the rate scaling table in the Link Quality command. The driver must - * determine which rate table entry was used for each tx attempt, to determine - * which rate-specific history to update, and record only those attempts that - * match the modulation characteristics of the history set. - * - * When using block-ack (aggregation), all frames are transmitted at the same - * rate, since there is no per-attempt acknowledgment from the destination - * station. The Tx response struct il_tx_resp indicates the Tx rate in - * rate_n_flags field. After receiving a block-ack, the driver can update - * history for the entire block all at once. - * - * - * FINDING BEST STARTING RATE: - * - * When working with a selected initial modulation mode (see below), the - * driver attempts to find a best initial rate. The initial rate is the - * first entry in the Link Quality command's rate table. - * - * 1) Calculate actual throughput (success ratio * expected throughput, see - * table below) for current initial rate. Do this only if enough frames - * have been attempted to make the value meaningful: at least 6 failed - * tx attempts, or at least 8 successes. If not enough, don't try rate - * scaling yet. - * - * 2) Find available rates adjacent to current initial rate. Available means: - * a) supported by hardware && - * b) supported by association && - * c) within any constraints selected by user - * - * 3) Gather measured throughputs for adjacent rates. These might not have - * enough history to calculate a throughput. That's okay, we might try - * using one of them anyway! - * - * 4) Try decreasing rate if, for current rate: - * a) success ratio is < 15% || - * b) lower adjacent rate has better measured throughput || - * c) higher adjacent rate has worse throughput, and lower is unmeasured - * - * As a sanity check, if decrease was determined above, leave rate - * unchanged if: - * a) lower rate unavailable - * b) success ratio at current rate > 85% (very good) - * c) current measured throughput is better than expected throughput - * of lower rate (under perfect 100% tx conditions, see table below) - * - * 5) Try increasing rate if, for current rate: - * a) success ratio is < 15% || - * b) both adjacent rates' throughputs are unmeasured (try it!) || - * b) higher adjacent rate has better measured throughput || - * c) lower adjacent rate has worse throughput, and higher is unmeasured - * - * As a sanity check, if increase was determined above, leave rate - * unchanged if: - * a) success ratio at current rate < 70%. This is not particularly - * good performance; higher rate is sure to have poorer success. - * - * 6) Re-evaluate the rate after each tx frame. If working with block- - * acknowledge, history and stats may be calculated for the entire - * block (including prior history that fits within the history wins), - * before re-evaluation. - * - * FINDING BEST STARTING MODULATION MODE: - * - * After working with a modulation mode for a "while" (and doing rate scaling), - * the driver searches for a new initial mode in an attempt to improve - * throughput. The "while" is measured by numbers of attempted frames: - * - * For legacy mode, search for new mode after: - * 480 successful frames, or 160 failed frames - * For high-throughput modes (SISO or MIMO), search for new mode after: - * 4500 successful frames, or 400 failed frames - * - * Mode switch possibilities are (3 for each mode): - * - * For legacy: - * Change antenna, try SISO (if HT association), try MIMO (if HT association) - * For SISO: - * Change antenna, try MIMO, try shortened guard interval (SGI) - * For MIMO: - * Try SISO antenna A, SISO antenna B, try shortened guard interval (SGI) - * - * When trying a new mode, use the same bit rate as the old/current mode when - * trying antenna switches and shortened guard interval. When switching to - * SISO from MIMO or legacy, or to MIMO from SISO or legacy, use a rate - * for which the expected throughput (under perfect conditions) is about the - * same or slightly better than the actual measured throughput delivered by - * the old/current mode. - * - * Actual throughput can be estimated by multiplying the expected throughput - * by the success ratio (successful / attempted tx frames). Frame size is - * not considered in this calculation; it assumes that frame size will average - * out to be fairly consistent over several samples. The following are - * metric values for expected throughput assuming 100% success ratio. - * Only G band has support for CCK rates: - * - * RATE: 1 2 5 11 6 9 12 18 24 36 48 54 60 - * - * G: 7 13 35 58 40 57 72 98 121 154 177 186 186 - * A: 0 0 0 0 40 57 72 98 121 154 177 186 186 - * SISO 20MHz: 0 0 0 0 42 42 76 102 124 159 183 193 202 - * SGI SISO 20MHz: 0 0 0 0 46 46 82 110 132 168 192 202 211 - * MIMO 20MHz: 0 0 0 0 74 74 123 155 179 214 236 244 251 - * SGI MIMO 20MHz: 0 0 0 0 81 81 131 164 188 222 243 251 257 - * SISO 40MHz: 0 0 0 0 77 77 127 160 184 220 242 250 257 - * SGI SISO 40MHz: 0 0 0 0 83 83 135 169 193 229 250 257 264 - * MIMO 40MHz: 0 0 0 0 123 123 182 214 235 264 279 285 289 - * SGI MIMO 40MHz: 0 0 0 0 131 131 191 222 242 270 284 289 293 - * - * After the new mode has been tried for a short while (minimum of 6 failed - * frames or 8 successful frames), compare success ratio and actual throughput - * estimate of the new mode with the old. If either is better with the new - * mode, continue to use the new mode. - * - * Continue comparing modes until all 3 possibilities have been tried. - * If moving from legacy to HT, try all 3 possibilities from the new HT - * mode. After trying all 3, a best mode is found. Continue to use this mode - * for the longer "while" described above (e.g. 480 successful frames for - * legacy), and then repeat the search process. - * - */ -struct il_link_quality_cmd { - - /* Index of destination/recipient station in uCode's station table */ - u8 sta_id; - u8 reserved1; - __le16 control; /* not used */ - struct il_link_qual_general_params general_params; - struct il_link_qual_agg_params agg_params; - - /* - * Rate info; when using rate-scaling, Tx command's initial_rate_idx - * specifies 1st Tx rate attempted, via idx into this table. - * 4965 devices works its way through table when retrying Tx. - */ - struct { - __le32 rate_n_flags; /* RATE_MCS_*, RATE_* */ - } rs_table[LINK_QUAL_MAX_RETRY_NUM]; - __le32 reserved2; -} __packed; - -/* - * BT configuration enable flags: - * bit 0 - 1: BT channel announcement enabled - * 0: disable - * bit 1 - 1: priority of BT device enabled - * 0: disable - */ -#define BT_COEX_DISABLE (0x0) -#define BT_ENABLE_CHANNEL_ANNOUNCE BIT(0) -#define BT_ENABLE_PRIORITY BIT(1) - -#define BT_COEX_ENABLE (BT_ENABLE_CHANNEL_ANNOUNCE | BT_ENABLE_PRIORITY) - -#define BT_LEAD_TIME_DEF (0x1E) - -#define BT_MAX_KILL_DEF (0x5) - -/* - * C_BT_CONFIG = 0x9b (command, has simple generic response) - * - * 3945 and 4965 devices support hardware handshake with Bluetooth device on - * same platform. Bluetooth device alerts wireless device when it will Tx; - * wireless device can delay or kill its own Tx to accommodate. - */ -struct il_bt_cmd { - u8 flags; - u8 lead_time; - u8 max_kill; - u8 reserved; - __le32 kill_ack_mask; - __le32 kill_cts_mask; -} __packed; - - -/****************************************************************************** - * (6) - * Spectrum Management (802.11h) Commands, Responses, Notifications: - * - *****************************************************************************/ - -/* - * Spectrum Management - */ -#define MEASUREMENT_FILTER_FLAG (RXON_FILTER_PROMISC_MSK | \ - RXON_FILTER_CTL2HOST_MSK | \ - RXON_FILTER_ACCEPT_GRP_MSK | \ - RXON_FILTER_DIS_DECRYPT_MSK | \ - RXON_FILTER_DIS_GRP_DECRYPT_MSK | \ - RXON_FILTER_ASSOC_MSK | \ - RXON_FILTER_BCON_AWARE_MSK) - -struct il_measure_channel { - __le32 duration; /* measurement duration in extended beacon - * format */ - u8 channel; /* channel to measure */ - u8 type; /* see enum il_measure_type */ - __le16 reserved; -} __packed; - -/* - * C_SPECTRUM_MEASUREMENT = 0x74 (command) - */ -struct il_spectrum_cmd { - __le16 len; /* number of bytes starting from token */ - u8 token; /* token id */ - u8 id; /* measurement id -- 0 or 1 */ - u8 origin; /* 0 = TGh, 1 = other, 2 = TGk */ - u8 periodic; /* 1 = periodic */ - __le16 path_loss_timeout; - __le32 start_time; /* start time in extended beacon format */ - __le32 reserved2; - __le32 flags; /* rxon flags */ - __le32 filter_flags; /* rxon filter flags */ - __le16 channel_count; /* minimum 1, maximum 10 */ - __le16 reserved3; - struct il_measure_channel channels[10]; -} __packed; - -/* - * C_SPECTRUM_MEASUREMENT = 0x74 (response) - */ -struct il_spectrum_resp { - u8 token; - u8 id; /* id of the prior command replaced, or 0xff */ - __le16 status; /* 0 - command will be handled - * 1 - cannot handle (conflicts with another - * measurement) */ -} __packed; - -enum il_measurement_state { - IL_MEASUREMENT_START = 0, - IL_MEASUREMENT_STOP = 1, -}; - -enum il_measurement_status { - IL_MEASUREMENT_OK = 0, - IL_MEASUREMENT_CONCURRENT = 1, - IL_MEASUREMENT_CSA_CONFLICT = 2, - IL_MEASUREMENT_TGH_CONFLICT = 3, - /* 4-5 reserved */ - IL_MEASUREMENT_STOPPED = 6, - IL_MEASUREMENT_TIMEOUT = 7, - IL_MEASUREMENT_PERIODIC_FAILED = 8, -}; - -#define NUM_ELEMENTS_IN_HISTOGRAM 8 - -struct il_measurement_histogram { - __le32 ofdm[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 0.8usec counts */ - __le32 cck[NUM_ELEMENTS_IN_HISTOGRAM]; /* in 1usec counts */ -} __packed; - -/* clear channel availability counters */ -struct il_measurement_cca_counters { - __le32 ofdm; - __le32 cck; -} __packed; - -enum il_measure_type { - IL_MEASURE_BASIC = (1 << 0), - IL_MEASURE_CHANNEL_LOAD = (1 << 1), - IL_MEASURE_HISTOGRAM_RPI = (1 << 2), - IL_MEASURE_HISTOGRAM_NOISE = (1 << 3), - IL_MEASURE_FRAME = (1 << 4), - /* bits 5:6 are reserved */ - IL_MEASURE_IDLE = (1 << 7), -}; - -/* - * N_SPECTRUM_MEASUREMENT = 0x75 (notification only, not a command) - */ -struct il_spectrum_notification { - u8 id; /* measurement id -- 0 or 1 */ - u8 token; - u8 channel_idx; /* idx in measurement channel list */ - u8 state; /* 0 - start, 1 - stop */ - __le32 start_time; /* lower 32-bits of TSF */ - u8 band; /* 0 - 5.2GHz, 1 - 2.4GHz */ - u8 channel; - u8 type; /* see enum il_measurement_type */ - u8 reserved1; - /* NOTE: cca_ofdm, cca_cck, basic_type, and histogram are only only - * valid if applicable for measurement type requested. */ - __le32 cca_ofdm; /* cca fraction time in 40Mhz clock periods */ - __le32 cca_cck; /* cca fraction time in 44Mhz clock periods */ - __le32 cca_time; /* channel load time in usecs */ - u8 basic_type; /* 0 - bss, 1 - ofdm preamble, 2 - - * unidentified */ - u8 reserved2[3]; - struct il_measurement_histogram histogram; - __le32 stop_time; /* lower 32-bits of TSF */ - __le32 status; /* see il_measurement_status */ -} __packed; - -/****************************************************************************** - * (7) - * Power Management Commands, Responses, Notifications: - * - *****************************************************************************/ - -/** - * struct il_powertable_cmd - Power Table Command - * @flags: See below: - * - * C_POWER_TBL = 0x77 (command, has simple generic response) - * - * PM allow: - * bit 0 - '0' Driver not allow power management - * '1' Driver allow PM (use rest of parameters) - * - * uCode send sleep notifications: - * bit 1 - '0' Don't send sleep notification - * '1' send sleep notification (SEND_PM_NOTIFICATION) - * - * Sleep over DTIM - * bit 2 - '0' PM have to walk up every DTIM - * '1' PM could sleep over DTIM till listen Interval. - * - * PCI power managed - * bit 3 - '0' (PCI_CFG_LINK_CTRL & 0x1) - * '1' !(PCI_CFG_LINK_CTRL & 0x1) - * - * Fast PD - * bit 4 - '1' Put radio to sleep when receiving frame for others - * - * Force sleep Modes - * bit 31/30- '00' use both mac/xtal sleeps - * '01' force Mac sleep - * '10' force xtal sleep - * '11' Illegal set - * - * NOTE: if sleep_interval[SLEEP_INTRVL_TBL_SIZE-1] > DTIM period then - * ucode assume sleep over DTIM is allowed and we don't need to wake up - * for every DTIM. - */ -#define IL_POWER_VEC_SIZE 5 - -#define IL_POWER_DRIVER_ALLOW_SLEEP_MSK cpu_to_le16(BIT(0)) -#define IL_POWER_PCI_PM_MSK cpu_to_le16(BIT(3)) - -struct il3945_powertable_cmd { - __le16 flags; - u8 reserved[2]; - __le32 rx_data_timeout; - __le32 tx_data_timeout; - __le32 sleep_interval[IL_POWER_VEC_SIZE]; -} __packed; - -struct il_powertable_cmd { - __le16 flags; - u8 keep_alive_seconds; /* 3945 reserved */ - u8 debug_flags; /* 3945 reserved */ - __le32 rx_data_timeout; - __le32 tx_data_timeout; - __le32 sleep_interval[IL_POWER_VEC_SIZE]; - __le32 keep_alive_beacons; -} __packed; - -/* - * N_PM_SLEEP = 0x7A (notification only, not a command) - * all devices identical. - */ -struct il_sleep_notification { - u8 pm_sleep_mode; - u8 pm_wakeup_src; - __le16 reserved; - __le32 sleep_time; - __le32 tsf_low; - __le32 bcon_timer; -} __packed; - -/* Sleep states. all devices identical. */ -enum { - IL_PM_NO_SLEEP = 0, - IL_PM_SLP_MAC = 1, - IL_PM_SLP_FULL_MAC_UNASSOCIATE = 2, - IL_PM_SLP_FULL_MAC_CARD_STATE = 3, - IL_PM_SLP_PHY = 4, - IL_PM_SLP_REPENT = 5, - IL_PM_WAKEUP_BY_TIMER = 6, - IL_PM_WAKEUP_BY_DRIVER = 7, - IL_PM_WAKEUP_BY_RFKILL = 8, - /* 3 reserved */ - IL_PM_NUM_OF_MODES = 12, -}; - -/* - * N_CARD_STATE = 0xa1 (notification only, not a command) - */ -struct il_card_state_notif { - __le32 flags; -} __packed; - -#define HW_CARD_DISABLED 0x01 -#define SW_CARD_DISABLED 0x02 -#define CT_CARD_DISABLED 0x04 -#define RXON_CARD_DISABLED 0x10 - -struct il_ct_kill_config { - __le32 reserved; - __le32 critical_temperature_M; - __le32 critical_temperature_R; -} __packed; - -/****************************************************************************** - * (8) - * Scan Commands, Responses, Notifications: - * - *****************************************************************************/ - -#define SCAN_CHANNEL_TYPE_PASSIVE cpu_to_le32(0) -#define SCAN_CHANNEL_TYPE_ACTIVE cpu_to_le32(1) - -/** - * struct il_scan_channel - entry in C_SCAN channel table - * - * One for each channel in the scan list. - * Each channel can independently select: - * 1) SSID for directed active scans - * 2) Txpower setting (for rate specified within Tx command) - * 3) How long to stay on-channel (behavior may be modified by quiet_time, - * quiet_plcp_th, good_CRC_th) - * - * To avoid uCode errors, make sure the following are true (see comments - * under struct il_scan_cmd about max_out_time and quiet_time): - * 1) If using passive_dwell (i.e. passive_dwell != 0): - * active_dwell <= passive_dwell (< max_out_time if max_out_time != 0) - * 2) quiet_time <= active_dwell - * 3) If restricting off-channel time (i.e. max_out_time !=0): - * passive_dwell < max_out_time - * active_dwell < max_out_time - */ -struct il3945_scan_channel { - /* - * type is defined as: - * 0:0 1 = active, 0 = passive - * 1:4 SSID direct bit map; if a bit is set, then corresponding - * SSID IE is transmitted in probe request. - * 5:7 reserved - */ - u8 type; - u8 channel; /* band is selected by il3945_scan_cmd "flags" field */ - struct il3945_tx_power tpc; - __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */ - __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */ -} __packed; - -/* set number of direct probes u8 type */ -#define IL39_SCAN_PROBE_MASK(n) ((BIT(n) | (BIT(n) - BIT(1)))) - -struct il_scan_channel { - /* - * type is defined as: - * 0:0 1 = active, 0 = passive - * 1:20 SSID direct bit map; if a bit is set, then corresponding - * SSID IE is transmitted in probe request. - * 21:31 reserved - */ - __le32 type; - __le16 channel; /* band is selected by il_scan_cmd "flags" field */ - u8 tx_gain; /* gain for analog radio */ - u8 dsp_atten; /* gain for DSP */ - __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */ - __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */ -} __packed; - -/* set number of direct probes __le32 type */ -#define IL_SCAN_PROBE_MASK(n) cpu_to_le32((BIT(n) | (BIT(n) - BIT(1)))) - -/** - * struct il_ssid_ie - directed scan network information element - * - * Up to 20 of these may appear in C_SCAN (Note: Only 4 are in - * 3945 SCAN api), selected by "type" bit field in struct il_scan_channel; - * each channel may select different ssids from among the 20 (4) entries. - * SSID IEs get transmitted in reverse order of entry. - */ -struct il_ssid_ie { - u8 id; - u8 len; - u8 ssid[32]; -} __packed; - -#define PROBE_OPTION_MAX_3945 4 -#define PROBE_OPTION_MAX 20 -#define TX_CMD_LIFE_TIME_INFINITE cpu_to_le32(0xFFFFFFFF) -#define IL_GOOD_CRC_TH_DISABLED 0 -#define IL_GOOD_CRC_TH_DEFAULT cpu_to_le16(1) -#define IL_GOOD_CRC_TH_NEVER cpu_to_le16(0xffff) -#define IL_MAX_SCAN_SIZE 1024 -#define IL_MAX_CMD_SIZE 4096 - -/* - * C_SCAN = 0x80 (command) - * - * The hardware scan command is very powerful; the driver can set it up to - * maintain (relatively) normal network traffic while doing a scan in the - * background. The max_out_time and suspend_time control the ratio of how - * long the device stays on an associated network channel ("service channel") - * vs. how long it's away from the service channel, i.e. tuned to other channels - * for scanning. - * - * max_out_time is the max time off-channel (in usec), and suspend_time - * is how long (in "extended beacon" format) that the scan is "suspended" - * after returning to the service channel. That is, suspend_time is the - * time that we stay on the service channel, doing normal work, between - * scan segments. The driver may set these parameters differently to support - * scanning when associated vs. not associated, and light vs. heavy traffic - * loads when associated. - * - * After receiving this command, the device's scan engine does the following; - * - * 1) Sends SCAN_START notification to driver - * 2) Checks to see if it has time to do scan for one channel - * 3) Sends NULL packet, with power-save (PS) bit set to 1, - * to tell AP that we're going off-channel - * 4) Tunes to first channel in scan list, does active or passive scan - * 5) Sends SCAN_RESULT notification to driver - * 6) Checks to see if it has time to do scan on *next* channel in list - * 7) Repeats 4-6 until it no longer has time to scan the next channel - * before max_out_time expires - * 8) Returns to service channel - * 9) Sends NULL packet with PS=0 to tell AP that we're back - * 10) Stays on service channel until suspend_time expires - * 11) Repeats entire process 2-10 until list is complete - * 12) Sends SCAN_COMPLETE notification - * - * For fast, efficient scans, the scan command also has support for staying on - * a channel for just a short time, if doing active scanning and getting no - * responses to the transmitted probe request. This time is controlled by - * quiet_time, and the number of received packets below which a channel is - * considered "quiet" is controlled by quiet_plcp_threshold. - * - * For active scanning on channels that have regulatory restrictions against - * blindly transmitting, the scan can listen before transmitting, to make sure - * that there is already legitimate activity on the channel. If enough - * packets are cleanly received on the channel (controlled by good_CRC_th, - * typical value 1), the scan engine starts transmitting probe requests. - * - * Driver must use separate scan commands for 2.4 vs. 5 GHz bands. - * - * To avoid uCode errors, see timing restrictions described under - * struct il_scan_channel. - */ - -struct il3945_scan_cmd { - __le16 len; - u8 reserved0; - u8 channel_count; /* # channels in channel list */ - __le16 quiet_time; /* dwell only this # millisecs on quiet channel - * (only for active scan) */ - __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */ - __le16 good_CRC_th; /* passive -> active promotion threshold */ - __le16 reserved1; - __le32 max_out_time; /* max usec to be away from associated (service) - * channel */ - __le32 suspend_time; /* pause scan this long (in "extended beacon - * format") when returning to service channel: - * 3945; 31:24 # beacons, 19:0 additional usec, - * 4965; 31:22 # beacons, 21:0 additional usec. - */ - __le32 flags; /* RXON_FLG_* */ - __le32 filter_flags; /* RXON_FILTER_* */ - - /* For active scans (set to all-0s for passive scans). - * Does not include payload. Must specify Tx rate; no rate scaling. */ - struct il3945_tx_cmd tx_cmd; - - /* For directed active scans (set to all-0s otherwise) */ - struct il_ssid_ie direct_scan[PROBE_OPTION_MAX_3945]; - - /* - * Probe request frame, followed by channel list. - * - * Size of probe request frame is specified by byte count in tx_cmd. - * Channel list follows immediately after probe request frame. - * Number of channels in list is specified by channel_count. - * Each channel in list is of type: - * - * struct il3945_scan_channel channels[0]; - * - * NOTE: Only one band of channels can be scanned per pass. You - * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait - * for one scan to complete (i.e. receive N_SCAN_COMPLETE) - * before requesting another scan. - */ - u8 data[0]; -} __packed; - -struct il_scan_cmd { - __le16 len; - u8 reserved0; - u8 channel_count; /* # channels in channel list */ - __le16 quiet_time; /* dwell only this # millisecs on quiet channel - * (only for active scan) */ - __le16 quiet_plcp_th; /* quiet chnl is < this # pkts (typ. 1) */ - __le16 good_CRC_th; /* passive -> active promotion threshold */ - __le16 rx_chain; /* RXON_RX_CHAIN_* */ - __le32 max_out_time; /* max usec to be away from associated (service) - * channel */ - __le32 suspend_time; /* pause scan this long (in "extended beacon - * format") when returning to service chnl: - * 3945; 31:24 # beacons, 19:0 additional usec, - * 4965; 31:22 # beacons, 21:0 additional usec. - */ - __le32 flags; /* RXON_FLG_* */ - __le32 filter_flags; /* RXON_FILTER_* */ - - /* For active scans (set to all-0s for passive scans). - * Does not include payload. Must specify Tx rate; no rate scaling. */ - struct il_tx_cmd tx_cmd; - - /* For directed active scans (set to all-0s otherwise) */ - struct il_ssid_ie direct_scan[PROBE_OPTION_MAX]; - - /* - * Probe request frame, followed by channel list. - * - * Size of probe request frame is specified by byte count in tx_cmd. - * Channel list follows immediately after probe request frame. - * Number of channels in list is specified by channel_count. - * Each channel in list is of type: - * - * struct il_scan_channel channels[0]; - * - * NOTE: Only one band of channels can be scanned per pass. You - * must not mix 2.4GHz channels and 5.2GHz channels, and you must wait - * for one scan to complete (i.e. receive N_SCAN_COMPLETE) - * before requesting another scan. - */ - u8 data[0]; -} __packed; - -/* Can abort will notify by complete notification with abort status. */ -#define CAN_ABORT_STATUS cpu_to_le32(0x1) -/* complete notification statuses */ -#define ABORT_STATUS 0x2 - -/* - * C_SCAN = 0x80 (response) - */ -struct il_scanreq_notification { - __le32 status; /* 1: okay, 2: cannot fulfill request */ -} __packed; - -/* - * N_SCAN_START = 0x82 (notification only, not a command) - */ -struct il_scanstart_notification { - __le32 tsf_low; - __le32 tsf_high; - __le32 beacon_timer; - u8 channel; - u8 band; - u8 reserved[2]; - __le32 status; -} __packed; - -#define SCAN_OWNER_STATUS 0x1 -#define MEASURE_OWNER_STATUS 0x2 - -#define IL_PROBE_STATUS_OK 0 -#define IL_PROBE_STATUS_TX_FAILED BIT(0) -/* error statuses combined with TX_FAILED */ -#define IL_PROBE_STATUS_FAIL_TTL BIT(1) -#define IL_PROBE_STATUS_FAIL_BT BIT(2) - -#define NUMBER_OF_STATS 1 /* first __le32 is good CRC */ -/* - * N_SCAN_RESULTS = 0x83 (notification only, not a command) - */ -struct il_scanresults_notification { - u8 channel; - u8 band; - u8 probe_status; - u8 num_probe_not_sent; /* not enough time to send */ - __le32 tsf_low; - __le32 tsf_high; - __le32 stats[NUMBER_OF_STATS]; -} __packed; - -/* - * N_SCAN_COMPLETE = 0x84 (notification only, not a command) - */ -struct il_scancomplete_notification { - u8 scanned_channels; - u8 status; - u8 last_channel; - __le32 tsf_low; - __le32 tsf_high; -} __packed; - - -/****************************************************************************** - * (9) - * IBSS/AP Commands and Notifications: - * - *****************************************************************************/ - -enum il_ibss_manager { - IL_NOT_IBSS_MANAGER = 0, - IL_IBSS_MANAGER = 1, -}; - -/* - * N_BEACON = 0x90 (notification only, not a command) - */ - -struct il3945_beacon_notif { - struct il3945_tx_resp beacon_notify_hdr; - __le32 low_tsf; - __le32 high_tsf; - __le32 ibss_mgr_status; -} __packed; - -struct il4965_beacon_notif { - struct il4965_tx_resp beacon_notify_hdr; - __le32 low_tsf; - __le32 high_tsf; - __le32 ibss_mgr_status; -} __packed; - -/* - * C_TX_BEACON= 0x91 (command, has simple generic response) - */ - -struct il3945_tx_beacon_cmd { - struct il3945_tx_cmd tx; - __le16 tim_idx; - u8 tim_size; - u8 reserved1; - struct ieee80211_hdr frame[0]; /* beacon frame */ -} __packed; - -struct il_tx_beacon_cmd { - struct il_tx_cmd tx; - __le16 tim_idx; - u8 tim_size; - u8 reserved1; - struct ieee80211_hdr frame[0]; /* beacon frame */ -} __packed; - -/****************************************************************************** - * (10) - * Statistics Commands and Notifications: - * - *****************************************************************************/ - -#define IL_TEMP_CONVERT 260 - -#define SUP_RATE_11A_MAX_NUM_CHANNELS 8 -#define SUP_RATE_11B_MAX_NUM_CHANNELS 4 -#define SUP_RATE_11G_MAX_NUM_CHANNELS 12 - -/* Used for passing to driver number of successes and failures per rate */ -struct rate_histogram { - union { - __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS]; - __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS]; - __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS]; - } success; - union { - __le32 a[SUP_RATE_11A_MAX_NUM_CHANNELS]; - __le32 b[SUP_RATE_11B_MAX_NUM_CHANNELS]; - __le32 g[SUP_RATE_11G_MAX_NUM_CHANNELS]; - } failed; -} __packed; - -/* stats command response */ - -struct iwl39_stats_rx_phy { - __le32 ina_cnt; - __le32 fina_cnt; - __le32 plcp_err; - __le32 crc32_err; - __le32 overrun_err; - __le32 early_overrun_err; - __le32 crc32_good; - __le32 false_alarm_cnt; - __le32 fina_sync_err_cnt; - __le32 sfd_timeout; - __le32 fina_timeout; - __le32 unresponded_rts; - __le32 rxe_frame_limit_overrun; - __le32 sent_ack_cnt; - __le32 sent_cts_cnt; -} __packed; - -struct iwl39_stats_rx_non_phy { - __le32 bogus_cts; /* CTS received when not expecting CTS */ - __le32 bogus_ack; /* ACK received when not expecting ACK */ - __le32 non_bssid_frames; /* number of frames with BSSID that - * doesn't belong to the STA BSSID */ - __le32 filtered_frames; /* count frames that were dumped in the - * filtering process */ - __le32 non_channel_beacons; /* beacons with our bss id but not on - * our serving channel */ -} __packed; - -struct iwl39_stats_rx { - struct iwl39_stats_rx_phy ofdm; - struct iwl39_stats_rx_phy cck; - struct iwl39_stats_rx_non_phy general; -} __packed; - -struct iwl39_stats_tx { - __le32 preamble_cnt; - __le32 rx_detected_cnt; - __le32 bt_prio_defer_cnt; - __le32 bt_prio_kill_cnt; - __le32 few_bytes_cnt; - __le32 cts_timeout; - __le32 ack_timeout; - __le32 expected_ack_cnt; - __le32 actual_ack_cnt; -} __packed; - -struct stats_dbg { - __le32 burst_check; - __le32 burst_count; - __le32 wait_for_silence_timeout_cnt; - __le32 reserved[3]; -} __packed; - -struct iwl39_stats_div { - __le32 tx_on_a; - __le32 tx_on_b; - __le32 exec_time; - __le32 probe_time; -} __packed; - -struct iwl39_stats_general { - __le32 temperature; - struct stats_dbg dbg; - __le32 sleep_time; - __le32 slots_out; - __le32 slots_idle; - __le32 ttl_timestamp; - struct iwl39_stats_div div; -} __packed; - -struct stats_rx_phy { - __le32 ina_cnt; - __le32 fina_cnt; - __le32 plcp_err; - __le32 crc32_err; - __le32 overrun_err; - __le32 early_overrun_err; - __le32 crc32_good; - __le32 false_alarm_cnt; - __le32 fina_sync_err_cnt; - __le32 sfd_timeout; - __le32 fina_timeout; - __le32 unresponded_rts; - __le32 rxe_frame_limit_overrun; - __le32 sent_ack_cnt; - __le32 sent_cts_cnt; - __le32 sent_ba_rsp_cnt; - __le32 dsp_self_kill; - __le32 mh_format_err; - __le32 re_acq_main_rssi_sum; - __le32 reserved3; -} __packed; - -struct stats_rx_ht_phy { - __le32 plcp_err; - __le32 overrun_err; - __le32 early_overrun_err; - __le32 crc32_good; - __le32 crc32_err; - __le32 mh_format_err; - __le32 agg_crc32_good; - __le32 agg_mpdu_cnt; - __le32 agg_cnt; - __le32 unsupport_mcs; -} __packed; - -#define INTERFERENCE_DATA_AVAILABLE cpu_to_le32(1) - -struct stats_rx_non_phy { - __le32 bogus_cts; /* CTS received when not expecting CTS */ - __le32 bogus_ack; /* ACK received when not expecting ACK */ - __le32 non_bssid_frames; /* number of frames with BSSID that - * doesn't belong to the STA BSSID */ - __le32 filtered_frames; /* count frames that were dumped in the - * filtering process */ - __le32 non_channel_beacons; /* beacons with our bss id but not on - * our serving channel */ - __le32 channel_beacons; /* beacons with our bss id and in our - * serving channel */ - __le32 num_missed_bcon; /* number of missed beacons */ - __le32 adc_rx_saturation_time; /* count in 0.8us units the time the - * ADC was in saturation */ - __le32 ina_detection_search_time;/* total time (in 0.8us) searched - * for INA */ - __le32 beacon_silence_rssi_a; /* RSSI silence after beacon frame */ - __le32 beacon_silence_rssi_b; /* RSSI silence after beacon frame */ - __le32 beacon_silence_rssi_c; /* RSSI silence after beacon frame */ - __le32 interference_data_flag; /* flag for interference data - * availability. 1 when data is - * available. */ - __le32 channel_load; /* counts RX Enable time in uSec */ - __le32 dsp_false_alarms; /* DSP false alarm (both OFDM - * and CCK) counter */ - __le32 beacon_rssi_a; - __le32 beacon_rssi_b; - __le32 beacon_rssi_c; - __le32 beacon_energy_a; - __le32 beacon_energy_b; - __le32 beacon_energy_c; -} __packed; - -struct stats_rx { - struct stats_rx_phy ofdm; - struct stats_rx_phy cck; - struct stats_rx_non_phy general; - struct stats_rx_ht_phy ofdm_ht; -} __packed; - -/** - * struct stats_tx_power - current tx power - * - * @ant_a: current tx power on chain a in 1/2 dB step - * @ant_b: current tx power on chain b in 1/2 dB step - * @ant_c: current tx power on chain c in 1/2 dB step - */ -struct stats_tx_power { - u8 ant_a; - u8 ant_b; - u8 ant_c; - u8 reserved; -} __packed; - -struct stats_tx_non_phy_agg { - __le32 ba_timeout; - __le32 ba_reschedule_frames; - __le32 scd_query_agg_frame_cnt; - __le32 scd_query_no_agg; - __le32 scd_query_agg; - __le32 scd_query_mismatch; - __le32 frame_not_ready; - __le32 underrun; - __le32 bt_prio_kill; - __le32 rx_ba_rsp_cnt; -} __packed; - -struct stats_tx { - __le32 preamble_cnt; - __le32 rx_detected_cnt; - __le32 bt_prio_defer_cnt; - __le32 bt_prio_kill_cnt; - __le32 few_bytes_cnt; - __le32 cts_timeout; - __le32 ack_timeout; - __le32 expected_ack_cnt; - __le32 actual_ack_cnt; - __le32 dump_msdu_cnt; - __le32 burst_abort_next_frame_mismatch_cnt; - __le32 burst_abort_missing_next_frame_cnt; - __le32 cts_timeout_collision; - __le32 ack_or_ba_timeout_collision; - struct stats_tx_non_phy_agg agg; - - __le32 reserved1; -} __packed; - - -struct stats_div { - __le32 tx_on_a; - __le32 tx_on_b; - __le32 exec_time; - __le32 probe_time; - __le32 reserved1; - __le32 reserved2; -} __packed; - -struct stats_general_common { - __le32 temperature; /* radio temperature */ - struct stats_dbg dbg; - __le32 sleep_time; - __le32 slots_out; - __le32 slots_idle; - __le32 ttl_timestamp; - struct stats_div div; - __le32 rx_enable_counter; - /* - * num_of_sos_states: - * count the number of times we have to re-tune - * in order to get out of bad PHY status - */ - __le32 num_of_sos_states; -} __packed; - -struct stats_general { - struct stats_general_common common; - __le32 reserved2; - __le32 reserved3; -} __packed; - -#define UCODE_STATS_CLEAR_MSK (0x1 << 0) -#define UCODE_STATS_FREQUENCY_MSK (0x1 << 1) -#define UCODE_STATS_NARROW_BAND_MSK (0x1 << 2) - -/* - * C_STATS = 0x9c, - * all devices identical. - * - * This command triggers an immediate response containing uCode stats. - * The response is in the same format as N_STATS 0x9d, below. - * - * If the CLEAR_STATS configuration flag is set, uCode will clear its - * internal copy of the stats (counters) after issuing the response. - * This flag does not affect N_STATSs after beacons (see below). - * - * If the DISABLE_NOTIF configuration flag is set, uCode will not issue - * N_STATSs after received beacons (see below). This flag - * does not affect the response to the C_STATS 0x9c itself. - */ -#define IL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1) /* see above */ -#define IL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */ -struct il_stats_cmd { - __le32 configuration_flags; /* IL_STATS_CONF_* */ -} __packed; - -/* - * N_STATS = 0x9d (notification only, not a command) - * - * By default, uCode issues this notification after receiving a beacon - * while associated. To disable this behavior, set DISABLE_NOTIF flag in the - * C_STATS 0x9c, above. - * - * Statistics counters continue to increment beacon after beacon, but are - * cleared when changing channels or when driver issues C_STATS - * 0x9c with CLEAR_STATS bit set (see above). - * - * uCode also issues this notification during scans. uCode clears stats - * appropriately so that each notification contains stats for only the - * one channel that has just been scanned. - */ -#define STATS_REPLY_FLG_BAND_24G_MSK cpu_to_le32(0x2) -#define STATS_REPLY_FLG_HT40_MODE_MSK cpu_to_le32(0x8) - -struct il3945_notif_stats { - __le32 flag; - struct iwl39_stats_rx rx; - struct iwl39_stats_tx tx; - struct iwl39_stats_general general; -} __packed; - -struct il_notif_stats { - __le32 flag; - struct stats_rx rx; - struct stats_tx tx; - struct stats_general general; -} __packed; - -/* - * N_MISSED_BEACONS = 0xa2 (notification only, not a command) - * - * uCode send N_MISSED_BEACONS to driver when detect beacon missed - * in regardless of how many missed beacons, which mean when driver receive the - * notification, inside the command, it can find all the beacons information - * which include number of total missed beacons, number of consecutive missed - * beacons, number of beacons received and number of beacons expected to - * receive. - * - * If uCode detected consecutive_missed_beacons > 5, it will reset the radio - * in order to bring the radio/PHY back to working state; which has no relation - * to when driver will perform sensitivity calibration. - * - * Driver should set it own missed_beacon_threshold to decide when to perform - * sensitivity calibration based on number of consecutive missed beacons in - * order to improve overall performance, especially in noisy environment. - * - */ - -#define IL_MISSED_BEACON_THRESHOLD_MIN (1) -#define IL_MISSED_BEACON_THRESHOLD_DEF (5) -#define IL_MISSED_BEACON_THRESHOLD_MAX IL_MISSED_BEACON_THRESHOLD_DEF - -struct il_missed_beacon_notif { - __le32 consecutive_missed_beacons; - __le32 total_missed_becons; - __le32 num_expected_beacons; - __le32 num_recvd_beacons; -} __packed; - - -/****************************************************************************** - * (11) - * Rx Calibration Commands: - * - * With the uCode used for open source drivers, most Tx calibration (except - * for Tx Power) and most Rx calibration is done by uCode during the - * "initialize" phase of uCode boot. Driver must calibrate only: - * - * 1) Tx power (depends on temperature), described elsewhere - * 2) Receiver gain balance (optimize MIMO, and detect disconnected antennas) - * 3) Receiver sensitivity (to optimize signal detection) - * - *****************************************************************************/ - -/** - * C_SENSITIVITY = 0xa8 (command, has simple generic response) - * - * This command sets up the Rx signal detector for a sensitivity level that - * is high enough to lock onto all signals within the associated network, - * but low enough to ignore signals that are below a certain threshold, so as - * not to have too many "false alarms". False alarms are signals that the - * Rx DSP tries to lock onto, but then discards after determining that they - * are noise. - * - * The optimum number of false alarms is between 5 and 50 per 200 TUs - * (200 * 1024 uSecs, i.e. 204.8 milliseconds) of actual Rx time (i.e. - * time listening, not transmitting). Driver must adjust sensitivity so that - * the ratio of actual false alarms to actual Rx time falls within this range. - * - * While associated, uCode delivers N_STATSs after each - * received beacon. These provide information to the driver to analyze the - * sensitivity. Don't analyze stats that come in from scanning, or any - * other non-associated-network source. Pertinent stats include: - * - * From "general" stats (struct stats_rx_non_phy): - * - * (beacon_energy_[abc] & 0x0FF00) >> 8 (unsigned, higher value is lower level) - * Measure of energy of desired signal. Used for establishing a level - * below which the device does not detect signals. - * - * (beacon_silence_rssi_[abc] & 0x0FF00) >> 8 (unsigned, units in dB) - * Measure of background noise in silent period after beacon. - * - * channel_load - * uSecs of actual Rx time during beacon period (varies according to - * how much time was spent transmitting). - * - * From "cck" and "ofdm" stats (struct stats_rx_phy), separately: - * - * false_alarm_cnt - * Signal locks abandoned early (before phy-level header). - * - * plcp_err - * Signal locks abandoned late (during phy-level header). - * - * NOTE: Both false_alarm_cnt and plcp_err increment monotonically from - * beacon to beacon, i.e. each value is an accumulation of all errors - * before and including the latest beacon. Values will wrap around to 0 - * after counting up to 2^32 - 1. Driver must differentiate vs. - * previous beacon's values to determine # false alarms in the current - * beacon period. - * - * Total number of false alarms = false_alarms + plcp_errs - * - * For OFDM, adjust the following table entries in struct il_sensitivity_cmd - * (notice that the start points for OFDM are at or close to settings for - * maximum sensitivity): - * - * START / MIN / MAX - * HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX 90 / 85 / 120 - * HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_IDX 170 / 170 / 210 - * HD_AUTO_CORR32_X4_TH_ADD_MIN_IDX 105 / 105 / 140 - * HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_IDX 220 / 220 / 270 - * - * If actual rate of OFDM false alarms (+ plcp_errors) is too high - * (greater than 50 for each 204.8 msecs listening), reduce sensitivity - * by *adding* 1 to all 4 of the table entries above, up to the max for - * each entry. Conversely, if false alarm rate is too low (less than 5 - * for each 204.8 msecs listening), *subtract* 1 from each entry to - * increase sensitivity. - * - * For CCK sensitivity, keep track of the following: - * - * 1). 20-beacon history of maximum background noise, indicated by - * (beacon_silence_rssi_[abc] & 0x0FF00), units in dB, across the - * 3 receivers. For any given beacon, the "silence reference" is - * the maximum of last 60 samples (20 beacons * 3 receivers). - * - * 2). 10-beacon history of strongest signal level, as indicated - * by (beacon_energy_[abc] & 0x0FF00) >> 8, across the 3 receivers, - * i.e. the strength of the signal through the best receiver at the - * moment. These measurements are "upside down", with lower values - * for stronger signals, so max energy will be *minimum* value. - * - * Then for any given beacon, the driver must determine the *weakest* - * of the strongest signals; this is the minimum level that needs to be - * successfully detected, when using the best receiver at the moment. - * "Max cck energy" is the maximum (higher value means lower energy!) - * of the last 10 minima. Once this is determined, driver must add - * a little margin by adding "6" to it. - * - * 3). Number of consecutive beacon periods with too few false alarms. - * Reset this to 0 at the first beacon period that falls within the - * "good" range (5 to 50 false alarms per 204.8 milliseconds rx). - * - * Then, adjust the following CCK table entries in struct il_sensitivity_cmd - * (notice that the start points for CCK are at maximum sensitivity): - * - * START / MIN / MAX - * HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX 125 / 125 / 200 - * HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX 200 / 200 / 400 - * HD_MIN_ENERGY_CCK_DET_IDX 100 / 0 / 100 - * - * If actual rate of CCK false alarms (+ plcp_errors) is too high - * (greater than 50 for each 204.8 msecs listening), method for reducing - * sensitivity is: - * - * 1) *Add* 3 to value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX, - * up to max 400. - * - * 2) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX is < 160, - * sensitivity has been reduced a significant amount; bring it up to - * a moderate 161. Otherwise, *add* 3, up to max 200. - * - * 3) a) If current value in HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX is > 160, - * sensitivity has been reduced only a moderate or small amount; - * *subtract* 2 from value in HD_MIN_ENERGY_CCK_DET_IDX, - * down to min 0. Otherwise (if gain has been significantly reduced), - * don't change the HD_MIN_ENERGY_CCK_DET_IDX value. - * - * b) Save a snapshot of the "silence reference". - * - * If actual rate of CCK false alarms (+ plcp_errors) is too low - * (less than 5 for each 204.8 msecs listening), method for increasing - * sensitivity is used only if: - * - * 1a) Previous beacon did not have too many false alarms - * 1b) AND difference between previous "silence reference" and current - * "silence reference" (prev - current) is 2 or more, - * OR 2) 100 or more consecutive beacon periods have had rate of - * less than 5 false alarms per 204.8 milliseconds rx time. - * - * Method for increasing sensitivity: - * - * 1) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX, - * down to min 125. - * - * 2) *Subtract* 3 from value in HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX, - * down to min 200. - * - * 3) *Add* 2 to value in HD_MIN_ENERGY_CCK_DET_IDX, up to max 100. - * - * If actual rate of CCK false alarms (+ plcp_errors) is within good range - * (between 5 and 50 for each 204.8 msecs listening): - * - * 1) Save a snapshot of the silence reference. - * - * 2) If previous beacon had too many CCK false alarms (+ plcp_errors), - * give some extra margin to energy threshold by *subtracting* 8 - * from value in HD_MIN_ENERGY_CCK_DET_IDX. - * - * For all cases (too few, too many, good range), make sure that the CCK - * detection threshold (energy) is below the energy level for robust - * detection over the past 10 beacon periods, the "Max cck energy". - * Lower values mean higher energy; this means making sure that the value - * in HD_MIN_ENERGY_CCK_DET_IDX is at or *above* "Max cck energy". - * - */ - -/* - * Table entries in C_SENSITIVITY (struct il_sensitivity_cmd) - */ -#define HD_TBL_SIZE (11) /* number of entries */ -#define HD_MIN_ENERGY_CCK_DET_IDX (0) /* table idxes */ -#define HD_MIN_ENERGY_OFDM_DET_IDX (1) -#define HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX (2) -#define HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_IDX (3) -#define HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX (4) -#define HD_AUTO_CORR32_X4_TH_ADD_MIN_IDX (5) -#define HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_IDX (6) -#define HD_BARKER_CORR_TH_ADD_MIN_IDX (7) -#define HD_BARKER_CORR_TH_ADD_MIN_MRC_IDX (8) -#define HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX (9) -#define HD_OFDM_ENERGY_TH_IN_IDX (10) - -/* Control field in struct il_sensitivity_cmd */ -#define C_SENSITIVITY_CONTROL_DEFAULT_TBL cpu_to_le16(0) -#define C_SENSITIVITY_CONTROL_WORK_TBL cpu_to_le16(1) - -/** - * struct il_sensitivity_cmd - * @control: (1) updates working table, (0) updates default table - * @table: energy threshold values, use HD_* as idx into table - * - * Always use "1" in "control" to update uCode's working table and DSP. - */ -struct il_sensitivity_cmd { - __le16 control; /* always use "1" */ - __le16 table[HD_TBL_SIZE]; /* use HD_* as idx */ -} __packed; - - -/** - * C_PHY_CALIBRATION = 0xb0 (command, has simple generic response) - * - * This command sets the relative gains of 4965 device's 3 radio receiver chains. - * - * After the first association, driver should accumulate signal and noise - * stats from the N_STATSs that follow the first 20 - * beacons from the associated network (don't collect stats that come - * in from scanning, or any other non-network source). - * - * DISCONNECTED ANTENNA: - * - * Driver should determine which antennas are actually connected, by comparing - * average beacon signal levels for the 3 Rx chains. Accumulate (add) the - * following values over 20 beacons, one accumulator for each of the chains - * a/b/c, from struct stats_rx_non_phy: - * - * beacon_rssi_[abc] & 0x0FF (unsigned, units in dB) - * - * Find the strongest signal from among a/b/c. Compare the other two to the - * strongest. If any signal is more than 15 dB (times 20, unless you - * divide the accumulated values by 20) below the strongest, the driver - * considers that antenna to be disconnected, and should not try to use that - * antenna/chain for Rx or Tx. If both A and B seem to be disconnected, - * driver should declare the stronger one as connected, and attempt to use it - * (A and B are the only 2 Tx chains!). - * - * - * RX BALANCE: - * - * Driver should balance the 3 receivers (but just the ones that are connected - * to antennas, see above) for gain, by comparing the average signal levels - * detected during the silence after each beacon (background noise). - * Accumulate (add) the following values over 20 beacons, one accumulator for - * each of the chains a/b/c, from struct stats_rx_non_phy: - * - * beacon_silence_rssi_[abc] & 0x0FF (unsigned, units in dB) - * - * Find the weakest background noise level from among a/b/c. This Rx chain - * will be the reference, with 0 gain adjustment. Attenuate other channels by - * finding noise difference: - * - * (accum_noise[i] - accum_noise[reference]) / 30 - * - * The "30" adjusts the dB in the 20 accumulated samples to units of 1.5 dB. - * For use in diff_gain_[abc] fields of struct il_calibration_cmd, the - * driver should limit the difference results to a range of 0-3 (0-4.5 dB), - * and set bit 2 to indicate "reduce gain". The value for the reference - * (weakest) chain should be "0". - * - * diff_gain_[abc] bit fields: - * 2: (1) reduce gain, (0) increase gain - * 1-0: amount of gain, units of 1.5 dB - */ - -/* Phy calibration command for series */ -/* The default calibrate table size if not specified by firmware */ -#define IL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE 18 -enum { - IL_PHY_CALIBRATE_DIFF_GAIN_CMD = 7, - IL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE = 19, -}; - -#define IL_MAX_PHY_CALIBRATE_TBL_SIZE (253) - -struct il_calib_hdr { - u8 op_code; - u8 first_group; - u8 groups_num; - u8 data_valid; -} __packed; - -/* IL_PHY_CALIBRATE_DIFF_GAIN_CMD (7) */ -struct il_calib_diff_gain_cmd { - struct il_calib_hdr hdr; - s8 diff_gain_a; /* see above */ - s8 diff_gain_b; - s8 diff_gain_c; - u8 reserved1; -} __packed; - -/****************************************************************************** - * (12) - * Miscellaneous Commands: - * - *****************************************************************************/ - -/* - * LEDs Command & Response - * C_LEDS = 0x48 (command, has simple generic response) - * - * For each of 3 possible LEDs (Activity/Link/Tech, selected by "id" field), - * this command turns it on or off, or sets up a periodic blinking cycle. - */ -struct il_led_cmd { - __le32 interval; /* "interval" in uSec */ - u8 id; /* 1: Activity, 2: Link, 3: Tech */ - u8 off; /* # intervals off while blinking; - * "0", with >0 "on" value, turns LED on */ - u8 on; /* # intervals on while blinking; - * "0", regardless of "off", turns LED off */ - u8 reserved; -} __packed; - - -/****************************************************************************** - * (13) - * Union of all expected notifications/responses: - * - *****************************************************************************/ - -struct il_rx_pkt { - /* - * The first 4 bytes of the RX frame header contain both the RX frame - * size and some flags. - * Bit fields: - * 31: flag flush RB request - * 30: flag ignore TC (terminal counter) request - * 29: flag fast IRQ request - * 28-14: Reserved - * 13-00: RX frame size - */ - __le32 len_n_flags; - struct il_cmd_header hdr; - union { - struct il3945_rx_frame rx_frame; - struct il3945_tx_resp tx_resp; - struct il3945_beacon_notif beacon_status; - - struct il_alive_resp alive_frame; - struct il_spectrum_notification spectrum_notif; - struct il_csa_notification csa_notif; - struct il_error_resp err_resp; - struct il_card_state_notif card_state_notif; - struct il_add_sta_resp add_sta; - struct il_rem_sta_resp rem_sta; - struct il_sleep_notification sleep_notif; - struct il_spectrum_resp spectrum; - struct il_notif_stats stats; - struct il_compressed_ba_resp compressed_ba; - struct il_missed_beacon_notif missed_beacon; - __le32 status; - u8 raw[0]; - } u; -} __packed; - -#endif /* __il_commands_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 2ebd807ee16e..991b455ecca2 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -25,7 +25,7 @@ *****************************************************************************/ /* * Please use this file (iwl-dev.h) for driver implementation definitions. - * Please use iwl-commands.h for uCode API definitions. + * Please use commands.h for uCode API definitions. * Please use 4965.h for hardware-related definitions. */ @@ -42,7 +42,6 @@ #include "iwl-eeprom.h" #include "iwl-csr.h" #include "iwl-prph.h" -#include "iwl-fh.h" #include "iwl-debug.h" #include "4965.h" #include "iwl-led.h" diff --git a/drivers/net/wireless/iwlegacy/iwl-power.h b/drivers/net/wireless/iwlegacy/iwl-power.h index e4a0ef270819..c0ae3fa6d774 100644 --- a/drivers/net/wireless/iwlegacy/iwl-power.h +++ b/drivers/net/wireless/iwlegacy/iwl-power.h @@ -28,7 +28,7 @@ #ifndef __il_power_setting_h__ #define __il_power_setting_h__ -#include "iwl-commands.h" +#include "commands.h" enum il_power_level { IL_POWER_IDX_1, -- cgit v1.2.3 From 6278ddab9f859b8d6311879d35f2b1f74a789964 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 11:13:05 +0200 Subject: iwlegacy: remove il_ieee80211_get_hw_conf Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/3945-mac.c | 2 +- drivers/net/wireless/iwlegacy/4965.c | 2 +- drivers/net/wireless/iwlegacy/common.c | 2 +- drivers/net/wireless/iwlegacy/iwl-helpers.h | 6 ------ 4 files changed, 3 insertions(+), 9 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index ae60410ab708..cd7ae586b663 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -2759,7 +2759,7 @@ void il3945_post_associate(struct il_priv *il) il_scan_cancel_timeout(il, 200); - conf = il_ieee80211_get_hw_conf(il->hw); + conf = &il->hw->conf; ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; il3945_commit_rxon(il, ctx); diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index ed2c61776fd3..6833a3c164e9 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -2184,7 +2184,7 @@ static void il4965_post_associate(struct il_priv *il) il_scan_cancel_timeout(il, 200); - conf = il_ieee80211_get_hw_conf(il->hw); + conf = &il->hw->conf; ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; il_commit_rxon(il, ctx); diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 7062574df365..bbf674d2075b 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -3514,7 +3514,7 @@ il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx) u16 beacon_int; struct ieee80211_vif *vif = ctx->vif; - conf = il_ieee80211_get_hw_conf(il->hw); + conf = &il->hw->conf; lockdep_assert_held(&il->mutex); diff --git a/drivers/net/wireless/iwlegacy/iwl-helpers.h b/drivers/net/wireless/iwlegacy/iwl-helpers.h index 0e64003274f4..eb5a287f2254 100644 --- a/drivers/net/wireless/iwlegacy/iwl-helpers.h +++ b/drivers/net/wireless/iwlegacy/iwl-helpers.h @@ -38,12 +38,6 @@ #define IL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) -static inline struct ieee80211_conf *il_ieee80211_get_hw_conf( - struct ieee80211_hw *hw) -{ - return &hw->conf; -} - /** * il_queue_inc_wrap - increment queue idx, wrap back to beginning * @idx -- current idx -- cgit v1.2.3 From e53aac424767a9f42b3bbac22eb001491f605d4e Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 11:18:16 +0200 Subject: iwlegacy: move IL_MASK Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/4965-mac.c | 2 ++ drivers/net/wireless/iwlegacy/iwl-helpers.h | 3 --- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 2bab0fc34d10..dbe5bf2d5791 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -4944,6 +4944,8 @@ static const s8 default_queue_to_tx_fifo[] = { IL_TX_FIFO_UNUSED, }; +#define IL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) + static int il4965_alive_notify(struct il_priv *il) { u32 a; diff --git a/drivers/net/wireless/iwlegacy/iwl-helpers.h b/drivers/net/wireless/iwlegacy/iwl-helpers.h index eb5a287f2254..2db83fc32103 100644 --- a/drivers/net/wireless/iwlegacy/iwl-helpers.h +++ b/drivers/net/wireless/iwlegacy/iwl-helpers.h @@ -35,9 +35,6 @@ #include "iwl-io.h" -#define IL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) - - /** * il_queue_inc_wrap - increment queue idx, wrap back to beginning * @idx -- current idx -- cgit v1.2.3 From 77375bb01cc030c680d5892eb1e756bc100c8022 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 11:19:51 +0200 Subject: iwlegacy: rename iwl-csr.h to csr.h Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/3945.h | 1 - drivers/net/wireless/iwlegacy/csr.h | 422 ++++++++++++++++++++++++++++++++ drivers/net/wireless/iwlegacy/iwl-csr.h | 422 -------------------------------- drivers/net/wireless/iwlegacy/iwl-dev.h | 2 +- 4 files changed, 423 insertions(+), 424 deletions(-) create mode 100644 drivers/net/wireless/iwlegacy/csr.h delete mode 100644 drivers/net/wireless/iwlegacy/iwl-csr.h (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index 7559a5ed3b6d..e89ca5da7f3c 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -34,7 +34,6 @@ /* Hardware specific file defines the PCI IDs table for that hardware module */ extern const struct pci_device_id il3945_hw_card_ids[]; -#include "iwl-csr.h" #include "iwl-prph.h" #include "iwl-debug.h" #include "iwl-power.h" diff --git a/drivers/net/wireless/iwlegacy/csr.h b/drivers/net/wireless/iwlegacy/csr.h new file mode 100644 index 000000000000..4db04297560c --- /dev/null +++ b/drivers/net/wireless/iwlegacy/csr.h @@ -0,0 +1,422 @@ +/****************************************************************************** + * + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, + * USA + * + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + * BSD LICENSE + * + * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *****************************************************************************/ +#ifndef __il_csr_h__ +#define __il_csr_h__ +/* + * CSR (control and status registers) + * + * CSR registers are mapped directly into PCI bus space, and are accessible + * whenever platform supplies power to device, even when device is in + * low power states due to driver-invoked device resets + * (e.g. CSR_RESET_REG_FLAG_SW_RESET) or uCode-driven power-saving modes. + * + * Use _il_wr() and _il_rd() family to access these registers; + * these provide simple PCI bus access, without waking up the MAC. + * Do not use il_wr() family for these registers; + * no need to "grab nic access" via CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ. + * The MAC (uCode processor, etc.) does not need to be powered up for accessing + * the CSR registers. + * + * NOTE: Device does need to be awake in order to read this memory + * via CSR_EEPROM register + */ +#define CSR_BASE (0x000) + +#define CSR_HW_IF_CONFIG_REG (CSR_BASE+0x000) /* hardware interface config */ +#define CSR_INT_COALESCING (CSR_BASE+0x004) /* accum ints, 32-usec units */ +#define CSR_INT (CSR_BASE+0x008) /* host interrupt status/ack */ +#define CSR_INT_MASK (CSR_BASE+0x00c) /* host interrupt enable */ +#define CSR_FH_INT_STATUS (CSR_BASE+0x010) /* busmaster int status/ack*/ +#define CSR_GPIO_IN (CSR_BASE+0x018) /* read external chip pins */ +#define CSR_RESET (CSR_BASE+0x020) /* busmaster enable, NMI, etc*/ +#define CSR_GP_CNTRL (CSR_BASE+0x024) + +/* 2nd byte of CSR_INT_COALESCING, not accessible via _il_wr()! */ +#define CSR_INT_PERIODIC_REG (CSR_BASE+0x005) + +/* + * Hardware revision info + * Bit fields: + * 31-8: Reserved + * 7-4: Type of device: see CSR_HW_REV_TYPE_xxx definitions + * 3-2: Revision step: 0 = A, 1 = B, 2 = C, 3 = D + * 1-0: "Dash" (-) value, as in A-1, etc. + * + * NOTE: Revision step affects calculation of CCK txpower for 4965. + * NOTE: See also CSR_HW_REV_WA_REG (work-around for bug in 4965). + */ +#define CSR_HW_REV (CSR_BASE+0x028) + +/* + * EEPROM memory reads + * + * NOTE: Device must be awake, initialized via apm_ops.init(), + * in order to read. + */ +#define CSR_EEPROM_REG (CSR_BASE+0x02c) +#define CSR_EEPROM_GP (CSR_BASE+0x030) + +#define CSR_GIO_REG (CSR_BASE+0x03C) +#define CSR_GP_UCODE_REG (CSR_BASE+0x048) +#define CSR_GP_DRIVER_REG (CSR_BASE+0x050) + +/* + * UCODE-DRIVER GP (general purpose) mailbox registers. + * SET/CLR registers set/clear bit(s) if "1" is written. + */ +#define CSR_UCODE_DRV_GP1 (CSR_BASE+0x054) +#define CSR_UCODE_DRV_GP1_SET (CSR_BASE+0x058) +#define CSR_UCODE_DRV_GP1_CLR (CSR_BASE+0x05c) +#define CSR_UCODE_DRV_GP2 (CSR_BASE+0x060) + +#define CSR_LED_REG (CSR_BASE+0x094) +#define CSR_DRAM_INT_TBL_REG (CSR_BASE+0x0A0) + +/* GIO Chicken Bits (PCI Express bus link power management) */ +#define CSR_GIO_CHICKEN_BITS (CSR_BASE+0x100) + +/* Analog phase-lock-loop configuration */ +#define CSR_ANA_PLL_CFG (CSR_BASE+0x20c) + +/* + * CSR Hardware Revision Workaround Register. Indicates hardware rev; + * "step" determines CCK backoff for txpower calculation. Used for 4965 only. + * See also CSR_HW_REV register. + * Bit fields: + * 3-2: 0 = A, 1 = B, 2 = C, 3 = D step + * 1-0: "Dash" (-) value, as in C-1, etc. + */ +#define CSR_HW_REV_WA_REG (CSR_BASE+0x22C) + +#define CSR_DBG_HPET_MEM_REG (CSR_BASE+0x240) +#define CSR_DBG_LINK_PWR_MGMT_REG (CSR_BASE+0x250) + +/* Bits for CSR_HW_IF_CONFIG_REG */ +#define CSR49_HW_IF_CONFIG_REG_BIT_4965_R (0x00000010) +#define CSR_HW_IF_CONFIG_REG_MSK_BOARD_VER (0x00000C00) +#define CSR_HW_IF_CONFIG_REG_BIT_MAC_SI (0x00000100) +#define CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI (0x00000200) + +#define CSR39_HW_IF_CONFIG_REG_BIT_3945_MB (0x00000100) +#define CSR39_HW_IF_CONFIG_REG_BIT_3945_MM (0x00000200) +#define CSR39_HW_IF_CONFIG_REG_BIT_SKU_MRC (0x00000400) +#define CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE (0x00000800) +#define CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A (0x00000000) +#define CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B (0x00001000) + +#define CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A (0x00080000) +#define CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM (0x00200000) +#define CSR_HW_IF_CONFIG_REG_BIT_NIC_READY (0x00400000) /* PCI_OWN_SEM */ +#define CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE (0x02000000) /* ME_OWN */ +#define CSR_HW_IF_CONFIG_REG_PREPARE (0x08000000) /* WAKE_ME */ + +#define CSR_INT_PERIODIC_DIS (0x00) /* disable periodic int*/ +#define CSR_INT_PERIODIC_ENA (0xFF) /* 255*32 usec ~ 8 msec*/ + +/* interrupt flags in INTA, set by uCode or hardware (e.g. dma), + * acknowledged (reset) by host writing "1" to flagged bits. */ +#define CSR_INT_BIT_FH_RX (1 << 31) /* Rx DMA, cmd responses, FH_INT[17:16] */ +#define CSR_INT_BIT_HW_ERR (1 << 29) /* DMA hardware error FH_INT[31] */ +#define CSR_INT_BIT_RX_PERIODIC (1 << 28) /* Rx periodic */ +#define CSR_INT_BIT_FH_TX (1 << 27) /* Tx DMA FH_INT[1:0] */ +#define CSR_INT_BIT_SCD (1 << 26) /* TXQ pointer advanced */ +#define CSR_INT_BIT_SW_ERR (1 << 25) /* uCode error */ +#define CSR_INT_BIT_RF_KILL (1 << 7) /* HW RFKILL switch GP_CNTRL[27] toggled */ +#define CSR_INT_BIT_CT_KILL (1 << 6) /* Critical temp (chip too hot) rfkill */ +#define CSR_INT_BIT_SW_RX (1 << 3) /* Rx, command responses, 3945 */ +#define CSR_INT_BIT_WAKEUP (1 << 1) /* NIC controller waking up (pwr mgmt) */ +#define CSR_INT_BIT_ALIVE (1 << 0) /* uCode interrupts once it initializes */ + +#define CSR_INI_SET_MASK (CSR_INT_BIT_FH_RX | \ + CSR_INT_BIT_HW_ERR | \ + CSR_INT_BIT_FH_TX | \ + CSR_INT_BIT_SW_ERR | \ + CSR_INT_BIT_RF_KILL | \ + CSR_INT_BIT_SW_RX | \ + CSR_INT_BIT_WAKEUP | \ + CSR_INT_BIT_ALIVE) + +/* interrupt flags in FH (flow handler) (PCI busmaster DMA) */ +#define CSR_FH_INT_BIT_ERR (1 << 31) /* Error */ +#define CSR_FH_INT_BIT_HI_PRIOR (1 << 30) /* High priority Rx, bypass coalescing */ +#define CSR39_FH_INT_BIT_RX_CHNL2 (1 << 18) /* Rx channel 2 (3945 only) */ +#define CSR_FH_INT_BIT_RX_CHNL1 (1 << 17) /* Rx channel 1 */ +#define CSR_FH_INT_BIT_RX_CHNL0 (1 << 16) /* Rx channel 0 */ +#define CSR39_FH_INT_BIT_TX_CHNL6 (1 << 6) /* Tx channel 6 (3945 only) */ +#define CSR_FH_INT_BIT_TX_CHNL1 (1 << 1) /* Tx channel 1 */ +#define CSR_FH_INT_BIT_TX_CHNL0 (1 << 0) /* Tx channel 0 */ + +#define CSR39_FH_INT_RX_MASK (CSR_FH_INT_BIT_HI_PRIOR | \ + CSR39_FH_INT_BIT_RX_CHNL2 | \ + CSR_FH_INT_BIT_RX_CHNL1 | \ + CSR_FH_INT_BIT_RX_CHNL0) + + +#define CSR39_FH_INT_TX_MASK (CSR39_FH_INT_BIT_TX_CHNL6 | \ + CSR_FH_INT_BIT_TX_CHNL1 | \ + CSR_FH_INT_BIT_TX_CHNL0) + +#define CSR49_FH_INT_RX_MASK (CSR_FH_INT_BIT_HI_PRIOR | \ + CSR_FH_INT_BIT_RX_CHNL1 | \ + CSR_FH_INT_BIT_RX_CHNL0) + +#define CSR49_FH_INT_TX_MASK (CSR_FH_INT_BIT_TX_CHNL1 | \ + CSR_FH_INT_BIT_TX_CHNL0) + +/* GPIO */ +#define CSR_GPIO_IN_BIT_AUX_POWER (0x00000200) +#define CSR_GPIO_IN_VAL_VAUX_PWR_SRC (0x00000000) +#define CSR_GPIO_IN_VAL_VMAIN_PWR_SRC (0x00000200) + +/* RESET */ +#define CSR_RESET_REG_FLAG_NEVO_RESET (0x00000001) +#define CSR_RESET_REG_FLAG_FORCE_NMI (0x00000002) +#define CSR_RESET_REG_FLAG_SW_RESET (0x00000080) +#define CSR_RESET_REG_FLAG_MASTER_DISABLED (0x00000100) +#define CSR_RESET_REG_FLAG_STOP_MASTER (0x00000200) +#define CSR_RESET_LINK_PWR_MGMT_DISABLED (0x80000000) + +/* + * GP (general purpose) CONTROL REGISTER + * Bit fields: + * 27: HW_RF_KILL_SW + * Indicates state of (platform's) hardware RF-Kill switch + * 26-24: POWER_SAVE_TYPE + * Indicates current power-saving mode: + * 000 -- No power saving + * 001 -- MAC power-down + * 010 -- PHY (radio) power-down + * 011 -- Error + * 9-6: SYS_CONFIG + * Indicates current system configuration, reflecting pins on chip + * as forced high/low by device circuit board. + * 4: GOING_TO_SLEEP + * Indicates MAC is entering a power-saving sleep power-down. + * Not a good time to access device-internal resources. + * 3: MAC_ACCESS_REQ + * Host sets this to request and maintain MAC wakeup, to allow host + * access to device-internal resources. Host must wait for + * MAC_CLOCK_READY (and !GOING_TO_SLEEP) before accessing non-CSR + * device registers. + * 2: INIT_DONE + * Host sets this to put device into fully operational D0 power mode. + * Host resets this after SW_RESET to put device into low power mode. + * 0: MAC_CLOCK_READY + * Indicates MAC (ucode processor, etc.) is powered up and can run. + * Internal resources are accessible. + * NOTE: This does not indicate that the processor is actually running. + * NOTE: This does not indicate that 4965 or 3945 has completed + * init or post-power-down restore of internal SRAM memory. + * Use CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP as indication that + * SRAM is restored and uCode is in normal operation mode. + * Later devices (5xxx/6xxx/1xxx) use non-volatile SRAM, and + * do not need to save/restore it. + * NOTE: After device reset, this bit remains "0" until host sets + * INIT_DONE + */ +#define CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY (0x00000001) +#define CSR_GP_CNTRL_REG_FLAG_INIT_DONE (0x00000004) +#define CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ (0x00000008) +#define CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP (0x00000010) + +#define CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN (0x00000001) + +#define CSR_GP_CNTRL_REG_MSK_POWER_SAVE_TYPE (0x07000000) +#define CSR_GP_CNTRL_REG_FLAG_MAC_POWER_SAVE (0x04000000) +#define CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW (0x08000000) + + +/* EEPROM REG */ +#define CSR_EEPROM_REG_READ_VALID_MSK (0x00000001) +#define CSR_EEPROM_REG_BIT_CMD (0x00000002) +#define CSR_EEPROM_REG_MSK_ADDR (0x0000FFFC) +#define CSR_EEPROM_REG_MSK_DATA (0xFFFF0000) + +/* EEPROM GP */ +#define CSR_EEPROM_GP_VALID_MSK (0x00000007) /* signature */ +#define CSR_EEPROM_GP_IF_OWNER_MSK (0x00000180) +#define CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K (0x00000002) +#define CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K (0x00000004) + +/* GP REG */ +#define CSR_GP_REG_POWER_SAVE_STATUS_MSK (0x03000000) /* bit 24/25 */ +#define CSR_GP_REG_NO_POWER_SAVE (0x00000000) +#define CSR_GP_REG_MAC_POWER_SAVE (0x01000000) +#define CSR_GP_REG_PHY_POWER_SAVE (0x02000000) +#define CSR_GP_REG_POWER_SAVE_ERROR (0x03000000) + + +/* CSR GIO */ +#define CSR_GIO_REG_VAL_L0S_ENABLED (0x00000002) + +/* + * UCODE-DRIVER GP (general purpose) mailbox register 1 + * Host driver and uCode write and/or read this register to communicate with + * each other. + * Bit fields: + * 4: UCODE_DISABLE + * Host sets this to request permanent halt of uCode, same as + * sending CARD_STATE command with "halt" bit set. + * 3: CT_KILL_EXIT + * Host sets this to request exit from CT_KILL state, i.e. host thinks + * device temperature is low enough to continue normal operation. + * 2: CMD_BLOCKED + * Host sets this during RF KILL power-down sequence (HW, SW, CT KILL) + * to release uCode to clear all Tx and command queues, enter + * unassociated mode, and power down. + * NOTE: Some devices also use HBUS_TARG_MBX_C register for this bit. + * 1: SW_BIT_RFKILL + * Host sets this when issuing CARD_STATE command to request + * device sleep. + * 0: MAC_SLEEP + * uCode sets this when preparing a power-saving power-down. + * uCode resets this when power-up is complete and SRAM is sane. + * NOTE: 3945/4965 saves internal SRAM data to host when powering down, + * and must restore this data after powering back up. + * MAC_SLEEP is the best indication that restore is complete. + * Later devices (5xxx/6xxx/1xxx) use non-volatile SRAM, and + * do not need to save/restore it. + */ +#define CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP (0x00000001) +#define CSR_UCODE_SW_BIT_RFKILL (0x00000002) +#define CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED (0x00000004) +#define CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT (0x00000008) + +/* GIO Chicken Bits (PCI Express bus link power management) */ +#define CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX (0x00800000) +#define CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER (0x20000000) + +/* LED */ +#define CSR_LED_BSM_CTRL_MSK (0xFFFFFFDF) +#define CSR_LED_REG_TRUN_ON (0x78) +#define CSR_LED_REG_TRUN_OFF (0x38) + +/* ANA_PLL */ +#define CSR39_ANA_PLL_CFG_VAL (0x01000000) + +/* HPET MEM debug */ +#define CSR_DBG_HPET_MEM_REG_VAL (0xFFFF0000) + +/* DRAM INT TBL */ +#define CSR_DRAM_INT_TBL_ENABLE (1 << 31) +#define CSR_DRAM_INIT_TBL_WRAP_CHECK (1 << 27) + +/* + * HBUS (Host-side Bus) + * + * HBUS registers are mapped directly into PCI bus space, but are used + * to indirectly access device's internal memory or registers that + * may be powered-down. + * + * Use il_wr()/il_rd() family + * for these registers; + * host must "grab nic access" via CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ + * to make sure the MAC (uCode processor, etc.) is powered up for accessing + * internal resources. + * + * Do not use _il_wr()/_il_rd() family to access these registers; + * these provide only simple PCI bus access, without waking up the MAC. + */ +#define HBUS_BASE (0x400) + +/* + * Registers for accessing device's internal SRAM memory (e.g. SCD SRAM + * structures, error log, event log, verifying uCode load). + * First write to address register, then read from or write to data register + * to complete the job. Once the address register is set up, accesses to + * data registers auto-increment the address by one dword. + * Bit usage for address registers (read or write): + * 0-31: memory address within device + */ +#define HBUS_TARG_MEM_RADDR (HBUS_BASE+0x00c) +#define HBUS_TARG_MEM_WADDR (HBUS_BASE+0x010) +#define HBUS_TARG_MEM_WDAT (HBUS_BASE+0x018) +#define HBUS_TARG_MEM_RDAT (HBUS_BASE+0x01c) + +/* Mailbox C, used as workaround alternative to CSR_UCODE_DRV_GP1 mailbox */ +#define HBUS_TARG_MBX_C (HBUS_BASE+0x030) +#define HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED (0x00000004) + +/* + * Registers for accessing device's internal peripheral registers + * (e.g. SCD, BSM, etc.). First write to address register, + * then read from or write to data register to complete the job. + * Bit usage for address registers (read or write): + * 0-15: register address (offset) within device + * 24-25: (# bytes - 1) to read or write (e.g. 3 for dword) + */ +#define HBUS_TARG_PRPH_WADDR (HBUS_BASE+0x044) +#define HBUS_TARG_PRPH_RADDR (HBUS_BASE+0x048) +#define HBUS_TARG_PRPH_WDAT (HBUS_BASE+0x04c) +#define HBUS_TARG_PRPH_RDAT (HBUS_BASE+0x050) + +/* + * Per-Tx-queue write pointer (idx, really!) + * Indicates idx to next TFD that driver will fill (1 past latest filled). + * Bit usage: + * 0-7: queue write idx + * 11-8: queue selector + */ +#define HBUS_TARG_WRPTR (HBUS_BASE+0x060) + +#endif /* !__il_csr_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-csr.h b/drivers/net/wireless/iwlegacy/iwl-csr.h deleted file mode 100644 index 4db04297560c..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-csr.h +++ /dev/null @@ -1,422 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - *****************************************************************************/ -#ifndef __il_csr_h__ -#define __il_csr_h__ -/* - * CSR (control and status registers) - * - * CSR registers are mapped directly into PCI bus space, and are accessible - * whenever platform supplies power to device, even when device is in - * low power states due to driver-invoked device resets - * (e.g. CSR_RESET_REG_FLAG_SW_RESET) or uCode-driven power-saving modes. - * - * Use _il_wr() and _il_rd() family to access these registers; - * these provide simple PCI bus access, without waking up the MAC. - * Do not use il_wr() family for these registers; - * no need to "grab nic access" via CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ. - * The MAC (uCode processor, etc.) does not need to be powered up for accessing - * the CSR registers. - * - * NOTE: Device does need to be awake in order to read this memory - * via CSR_EEPROM register - */ -#define CSR_BASE (0x000) - -#define CSR_HW_IF_CONFIG_REG (CSR_BASE+0x000) /* hardware interface config */ -#define CSR_INT_COALESCING (CSR_BASE+0x004) /* accum ints, 32-usec units */ -#define CSR_INT (CSR_BASE+0x008) /* host interrupt status/ack */ -#define CSR_INT_MASK (CSR_BASE+0x00c) /* host interrupt enable */ -#define CSR_FH_INT_STATUS (CSR_BASE+0x010) /* busmaster int status/ack*/ -#define CSR_GPIO_IN (CSR_BASE+0x018) /* read external chip pins */ -#define CSR_RESET (CSR_BASE+0x020) /* busmaster enable, NMI, etc*/ -#define CSR_GP_CNTRL (CSR_BASE+0x024) - -/* 2nd byte of CSR_INT_COALESCING, not accessible via _il_wr()! */ -#define CSR_INT_PERIODIC_REG (CSR_BASE+0x005) - -/* - * Hardware revision info - * Bit fields: - * 31-8: Reserved - * 7-4: Type of device: see CSR_HW_REV_TYPE_xxx definitions - * 3-2: Revision step: 0 = A, 1 = B, 2 = C, 3 = D - * 1-0: "Dash" (-) value, as in A-1, etc. - * - * NOTE: Revision step affects calculation of CCK txpower for 4965. - * NOTE: See also CSR_HW_REV_WA_REG (work-around for bug in 4965). - */ -#define CSR_HW_REV (CSR_BASE+0x028) - -/* - * EEPROM memory reads - * - * NOTE: Device must be awake, initialized via apm_ops.init(), - * in order to read. - */ -#define CSR_EEPROM_REG (CSR_BASE+0x02c) -#define CSR_EEPROM_GP (CSR_BASE+0x030) - -#define CSR_GIO_REG (CSR_BASE+0x03C) -#define CSR_GP_UCODE_REG (CSR_BASE+0x048) -#define CSR_GP_DRIVER_REG (CSR_BASE+0x050) - -/* - * UCODE-DRIVER GP (general purpose) mailbox registers. - * SET/CLR registers set/clear bit(s) if "1" is written. - */ -#define CSR_UCODE_DRV_GP1 (CSR_BASE+0x054) -#define CSR_UCODE_DRV_GP1_SET (CSR_BASE+0x058) -#define CSR_UCODE_DRV_GP1_CLR (CSR_BASE+0x05c) -#define CSR_UCODE_DRV_GP2 (CSR_BASE+0x060) - -#define CSR_LED_REG (CSR_BASE+0x094) -#define CSR_DRAM_INT_TBL_REG (CSR_BASE+0x0A0) - -/* GIO Chicken Bits (PCI Express bus link power management) */ -#define CSR_GIO_CHICKEN_BITS (CSR_BASE+0x100) - -/* Analog phase-lock-loop configuration */ -#define CSR_ANA_PLL_CFG (CSR_BASE+0x20c) - -/* - * CSR Hardware Revision Workaround Register. Indicates hardware rev; - * "step" determines CCK backoff for txpower calculation. Used for 4965 only. - * See also CSR_HW_REV register. - * Bit fields: - * 3-2: 0 = A, 1 = B, 2 = C, 3 = D step - * 1-0: "Dash" (-) value, as in C-1, etc. - */ -#define CSR_HW_REV_WA_REG (CSR_BASE+0x22C) - -#define CSR_DBG_HPET_MEM_REG (CSR_BASE+0x240) -#define CSR_DBG_LINK_PWR_MGMT_REG (CSR_BASE+0x250) - -/* Bits for CSR_HW_IF_CONFIG_REG */ -#define CSR49_HW_IF_CONFIG_REG_BIT_4965_R (0x00000010) -#define CSR_HW_IF_CONFIG_REG_MSK_BOARD_VER (0x00000C00) -#define CSR_HW_IF_CONFIG_REG_BIT_MAC_SI (0x00000100) -#define CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI (0x00000200) - -#define CSR39_HW_IF_CONFIG_REG_BIT_3945_MB (0x00000100) -#define CSR39_HW_IF_CONFIG_REG_BIT_3945_MM (0x00000200) -#define CSR39_HW_IF_CONFIG_REG_BIT_SKU_MRC (0x00000400) -#define CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE (0x00000800) -#define CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A (0x00000000) -#define CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B (0x00001000) - -#define CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A (0x00080000) -#define CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM (0x00200000) -#define CSR_HW_IF_CONFIG_REG_BIT_NIC_READY (0x00400000) /* PCI_OWN_SEM */ -#define CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE (0x02000000) /* ME_OWN */ -#define CSR_HW_IF_CONFIG_REG_PREPARE (0x08000000) /* WAKE_ME */ - -#define CSR_INT_PERIODIC_DIS (0x00) /* disable periodic int*/ -#define CSR_INT_PERIODIC_ENA (0xFF) /* 255*32 usec ~ 8 msec*/ - -/* interrupt flags in INTA, set by uCode or hardware (e.g. dma), - * acknowledged (reset) by host writing "1" to flagged bits. */ -#define CSR_INT_BIT_FH_RX (1 << 31) /* Rx DMA, cmd responses, FH_INT[17:16] */ -#define CSR_INT_BIT_HW_ERR (1 << 29) /* DMA hardware error FH_INT[31] */ -#define CSR_INT_BIT_RX_PERIODIC (1 << 28) /* Rx periodic */ -#define CSR_INT_BIT_FH_TX (1 << 27) /* Tx DMA FH_INT[1:0] */ -#define CSR_INT_BIT_SCD (1 << 26) /* TXQ pointer advanced */ -#define CSR_INT_BIT_SW_ERR (1 << 25) /* uCode error */ -#define CSR_INT_BIT_RF_KILL (1 << 7) /* HW RFKILL switch GP_CNTRL[27] toggled */ -#define CSR_INT_BIT_CT_KILL (1 << 6) /* Critical temp (chip too hot) rfkill */ -#define CSR_INT_BIT_SW_RX (1 << 3) /* Rx, command responses, 3945 */ -#define CSR_INT_BIT_WAKEUP (1 << 1) /* NIC controller waking up (pwr mgmt) */ -#define CSR_INT_BIT_ALIVE (1 << 0) /* uCode interrupts once it initializes */ - -#define CSR_INI_SET_MASK (CSR_INT_BIT_FH_RX | \ - CSR_INT_BIT_HW_ERR | \ - CSR_INT_BIT_FH_TX | \ - CSR_INT_BIT_SW_ERR | \ - CSR_INT_BIT_RF_KILL | \ - CSR_INT_BIT_SW_RX | \ - CSR_INT_BIT_WAKEUP | \ - CSR_INT_BIT_ALIVE) - -/* interrupt flags in FH (flow handler) (PCI busmaster DMA) */ -#define CSR_FH_INT_BIT_ERR (1 << 31) /* Error */ -#define CSR_FH_INT_BIT_HI_PRIOR (1 << 30) /* High priority Rx, bypass coalescing */ -#define CSR39_FH_INT_BIT_RX_CHNL2 (1 << 18) /* Rx channel 2 (3945 only) */ -#define CSR_FH_INT_BIT_RX_CHNL1 (1 << 17) /* Rx channel 1 */ -#define CSR_FH_INT_BIT_RX_CHNL0 (1 << 16) /* Rx channel 0 */ -#define CSR39_FH_INT_BIT_TX_CHNL6 (1 << 6) /* Tx channel 6 (3945 only) */ -#define CSR_FH_INT_BIT_TX_CHNL1 (1 << 1) /* Tx channel 1 */ -#define CSR_FH_INT_BIT_TX_CHNL0 (1 << 0) /* Tx channel 0 */ - -#define CSR39_FH_INT_RX_MASK (CSR_FH_INT_BIT_HI_PRIOR | \ - CSR39_FH_INT_BIT_RX_CHNL2 | \ - CSR_FH_INT_BIT_RX_CHNL1 | \ - CSR_FH_INT_BIT_RX_CHNL0) - - -#define CSR39_FH_INT_TX_MASK (CSR39_FH_INT_BIT_TX_CHNL6 | \ - CSR_FH_INT_BIT_TX_CHNL1 | \ - CSR_FH_INT_BIT_TX_CHNL0) - -#define CSR49_FH_INT_RX_MASK (CSR_FH_INT_BIT_HI_PRIOR | \ - CSR_FH_INT_BIT_RX_CHNL1 | \ - CSR_FH_INT_BIT_RX_CHNL0) - -#define CSR49_FH_INT_TX_MASK (CSR_FH_INT_BIT_TX_CHNL1 | \ - CSR_FH_INT_BIT_TX_CHNL0) - -/* GPIO */ -#define CSR_GPIO_IN_BIT_AUX_POWER (0x00000200) -#define CSR_GPIO_IN_VAL_VAUX_PWR_SRC (0x00000000) -#define CSR_GPIO_IN_VAL_VMAIN_PWR_SRC (0x00000200) - -/* RESET */ -#define CSR_RESET_REG_FLAG_NEVO_RESET (0x00000001) -#define CSR_RESET_REG_FLAG_FORCE_NMI (0x00000002) -#define CSR_RESET_REG_FLAG_SW_RESET (0x00000080) -#define CSR_RESET_REG_FLAG_MASTER_DISABLED (0x00000100) -#define CSR_RESET_REG_FLAG_STOP_MASTER (0x00000200) -#define CSR_RESET_LINK_PWR_MGMT_DISABLED (0x80000000) - -/* - * GP (general purpose) CONTROL REGISTER - * Bit fields: - * 27: HW_RF_KILL_SW - * Indicates state of (platform's) hardware RF-Kill switch - * 26-24: POWER_SAVE_TYPE - * Indicates current power-saving mode: - * 000 -- No power saving - * 001 -- MAC power-down - * 010 -- PHY (radio) power-down - * 011 -- Error - * 9-6: SYS_CONFIG - * Indicates current system configuration, reflecting pins on chip - * as forced high/low by device circuit board. - * 4: GOING_TO_SLEEP - * Indicates MAC is entering a power-saving sleep power-down. - * Not a good time to access device-internal resources. - * 3: MAC_ACCESS_REQ - * Host sets this to request and maintain MAC wakeup, to allow host - * access to device-internal resources. Host must wait for - * MAC_CLOCK_READY (and !GOING_TO_SLEEP) before accessing non-CSR - * device registers. - * 2: INIT_DONE - * Host sets this to put device into fully operational D0 power mode. - * Host resets this after SW_RESET to put device into low power mode. - * 0: MAC_CLOCK_READY - * Indicates MAC (ucode processor, etc.) is powered up and can run. - * Internal resources are accessible. - * NOTE: This does not indicate that the processor is actually running. - * NOTE: This does not indicate that 4965 or 3945 has completed - * init or post-power-down restore of internal SRAM memory. - * Use CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP as indication that - * SRAM is restored and uCode is in normal operation mode. - * Later devices (5xxx/6xxx/1xxx) use non-volatile SRAM, and - * do not need to save/restore it. - * NOTE: After device reset, this bit remains "0" until host sets - * INIT_DONE - */ -#define CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY (0x00000001) -#define CSR_GP_CNTRL_REG_FLAG_INIT_DONE (0x00000004) -#define CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ (0x00000008) -#define CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP (0x00000010) - -#define CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN (0x00000001) - -#define CSR_GP_CNTRL_REG_MSK_POWER_SAVE_TYPE (0x07000000) -#define CSR_GP_CNTRL_REG_FLAG_MAC_POWER_SAVE (0x04000000) -#define CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW (0x08000000) - - -/* EEPROM REG */ -#define CSR_EEPROM_REG_READ_VALID_MSK (0x00000001) -#define CSR_EEPROM_REG_BIT_CMD (0x00000002) -#define CSR_EEPROM_REG_MSK_ADDR (0x0000FFFC) -#define CSR_EEPROM_REG_MSK_DATA (0xFFFF0000) - -/* EEPROM GP */ -#define CSR_EEPROM_GP_VALID_MSK (0x00000007) /* signature */ -#define CSR_EEPROM_GP_IF_OWNER_MSK (0x00000180) -#define CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K (0x00000002) -#define CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K (0x00000004) - -/* GP REG */ -#define CSR_GP_REG_POWER_SAVE_STATUS_MSK (0x03000000) /* bit 24/25 */ -#define CSR_GP_REG_NO_POWER_SAVE (0x00000000) -#define CSR_GP_REG_MAC_POWER_SAVE (0x01000000) -#define CSR_GP_REG_PHY_POWER_SAVE (0x02000000) -#define CSR_GP_REG_POWER_SAVE_ERROR (0x03000000) - - -/* CSR GIO */ -#define CSR_GIO_REG_VAL_L0S_ENABLED (0x00000002) - -/* - * UCODE-DRIVER GP (general purpose) mailbox register 1 - * Host driver and uCode write and/or read this register to communicate with - * each other. - * Bit fields: - * 4: UCODE_DISABLE - * Host sets this to request permanent halt of uCode, same as - * sending CARD_STATE command with "halt" bit set. - * 3: CT_KILL_EXIT - * Host sets this to request exit from CT_KILL state, i.e. host thinks - * device temperature is low enough to continue normal operation. - * 2: CMD_BLOCKED - * Host sets this during RF KILL power-down sequence (HW, SW, CT KILL) - * to release uCode to clear all Tx and command queues, enter - * unassociated mode, and power down. - * NOTE: Some devices also use HBUS_TARG_MBX_C register for this bit. - * 1: SW_BIT_RFKILL - * Host sets this when issuing CARD_STATE command to request - * device sleep. - * 0: MAC_SLEEP - * uCode sets this when preparing a power-saving power-down. - * uCode resets this when power-up is complete and SRAM is sane. - * NOTE: 3945/4965 saves internal SRAM data to host when powering down, - * and must restore this data after powering back up. - * MAC_SLEEP is the best indication that restore is complete. - * Later devices (5xxx/6xxx/1xxx) use non-volatile SRAM, and - * do not need to save/restore it. - */ -#define CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP (0x00000001) -#define CSR_UCODE_SW_BIT_RFKILL (0x00000002) -#define CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED (0x00000004) -#define CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT (0x00000008) - -/* GIO Chicken Bits (PCI Express bus link power management) */ -#define CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX (0x00800000) -#define CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER (0x20000000) - -/* LED */ -#define CSR_LED_BSM_CTRL_MSK (0xFFFFFFDF) -#define CSR_LED_REG_TRUN_ON (0x78) -#define CSR_LED_REG_TRUN_OFF (0x38) - -/* ANA_PLL */ -#define CSR39_ANA_PLL_CFG_VAL (0x01000000) - -/* HPET MEM debug */ -#define CSR_DBG_HPET_MEM_REG_VAL (0xFFFF0000) - -/* DRAM INT TBL */ -#define CSR_DRAM_INT_TBL_ENABLE (1 << 31) -#define CSR_DRAM_INIT_TBL_WRAP_CHECK (1 << 27) - -/* - * HBUS (Host-side Bus) - * - * HBUS registers are mapped directly into PCI bus space, but are used - * to indirectly access device's internal memory or registers that - * may be powered-down. - * - * Use il_wr()/il_rd() family - * for these registers; - * host must "grab nic access" via CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ - * to make sure the MAC (uCode processor, etc.) is powered up for accessing - * internal resources. - * - * Do not use _il_wr()/_il_rd() family to access these registers; - * these provide only simple PCI bus access, without waking up the MAC. - */ -#define HBUS_BASE (0x400) - -/* - * Registers for accessing device's internal SRAM memory (e.g. SCD SRAM - * structures, error log, event log, verifying uCode load). - * First write to address register, then read from or write to data register - * to complete the job. Once the address register is set up, accesses to - * data registers auto-increment the address by one dword. - * Bit usage for address registers (read or write): - * 0-31: memory address within device - */ -#define HBUS_TARG_MEM_RADDR (HBUS_BASE+0x00c) -#define HBUS_TARG_MEM_WADDR (HBUS_BASE+0x010) -#define HBUS_TARG_MEM_WDAT (HBUS_BASE+0x018) -#define HBUS_TARG_MEM_RDAT (HBUS_BASE+0x01c) - -/* Mailbox C, used as workaround alternative to CSR_UCODE_DRV_GP1 mailbox */ -#define HBUS_TARG_MBX_C (HBUS_BASE+0x030) -#define HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED (0x00000004) - -/* - * Registers for accessing device's internal peripheral registers - * (e.g. SCD, BSM, etc.). First write to address register, - * then read from or write to data register to complete the job. - * Bit usage for address registers (read or write): - * 0-15: register address (offset) within device - * 24-25: (# bytes - 1) to read or write (e.g. 3 for dword) - */ -#define HBUS_TARG_PRPH_WADDR (HBUS_BASE+0x044) -#define HBUS_TARG_PRPH_RADDR (HBUS_BASE+0x048) -#define HBUS_TARG_PRPH_WDAT (HBUS_BASE+0x04c) -#define HBUS_TARG_PRPH_RDAT (HBUS_BASE+0x050) - -/* - * Per-Tx-queue write pointer (idx, really!) - * Indicates idx to next TFD that driver will fill (1 past latest filled). - * Bit usage: - * 0-7: queue write idx - * 11-8: queue selector - */ -#define HBUS_TARG_WRPTR (HBUS_BASE+0x060) - -#endif /* !__il_csr_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h index 991b455ecca2..ce5bc5302044 100644 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ b/drivers/net/wireless/iwlegacy/iwl-dev.h @@ -40,7 +40,7 @@ #include #include "iwl-eeprom.h" -#include "iwl-csr.h" +#include "csr.h" #include "iwl-prph.h" #include "iwl-debug.h" #include "4965.h" -- cgit v1.2.3 From 98613be06e9de8acd20841d2d85b99c39b3b7814 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 14:19:34 +0100 Subject: iwlegacy: rename iwl-core.h to common.h Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/3945-debug.c | 2 +- drivers/net/wireless/iwlegacy/3945-mac.c | 2 +- drivers/net/wireless/iwlegacy/3945.c | 2 +- drivers/net/wireless/iwlegacy/4965-calib.c | 2 +- drivers/net/wireless/iwlegacy/4965-debug.c | 2 +- drivers/net/wireless/iwlegacy/4965-mac.c | 2 +- drivers/net/wireless/iwlegacy/4965-rs.c | 2 +- drivers/net/wireless/iwlegacy/4965.c | 2 +- drivers/net/wireless/iwlegacy/common.c | 2 +- drivers/net/wireless/iwlegacy/common.h | 636 ++++++++++++++++++++++++++++ drivers/net/wireless/iwlegacy/iwl-core.h | 636 ---------------------------- drivers/net/wireless/iwlegacy/iwl-debugfs.c | 2 +- 12 files changed, 646 insertions(+), 646 deletions(-) create mode 100644 drivers/net/wireless/iwlegacy/common.h delete mode 100644 drivers/net/wireless/iwlegacy/iwl-core.h (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/3945-debug.c b/drivers/net/wireless/iwlegacy/3945-debug.c index fc2d651b43a3..b73b4253cd28 100644 --- a/drivers/net/wireless/iwlegacy/3945-debug.c +++ b/drivers/net/wireless/iwlegacy/3945-debug.c @@ -27,7 +27,7 @@ *****************************************************************************/ #include "iwl-dev.h" -#include "iwl-core.h" +#include "common.h" #include "3945.h" static int il3945_stats_flag(struct il_priv *il, char *buf, int bufsz) diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index cd7ae586b663..b650292a7f89 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -54,7 +54,7 @@ #include "commands.h" #include "iwl-sta.h" #include "3945.h" -#include "iwl-core.h" +#include "common.h" #include "iwl-helpers.h" #include "iwl-dev.h" #include "iwl-spectrum.h" diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index ff8818b3c296..795d206f10e8 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -42,7 +42,7 @@ #include "commands.h" #include "iwl-sta.h" #include "iwl-eeprom.h" -#include "iwl-core.h" +#include "common.h" #include "iwl-helpers.h" #include "iwl-led.h" #include "3945.h" diff --git a/drivers/net/wireless/iwlegacy/4965-calib.c b/drivers/net/wireless/iwlegacy/4965-calib.c index c5dcc528e5ff..1e4779847a2b 100644 --- a/drivers/net/wireless/iwlegacy/4965-calib.c +++ b/drivers/net/wireless/iwlegacy/4965-calib.c @@ -64,7 +64,7 @@ #include #include "iwl-dev.h" -#include "iwl-core.h" +#include "common.h" #include "4965.h" /***************************************************************************** diff --git a/drivers/net/wireless/iwlegacy/4965-debug.c b/drivers/net/wireless/iwlegacy/4965-debug.c index ad9c6d0a560e..1056d3e3a157 100644 --- a/drivers/net/wireless/iwlegacy/4965-debug.c +++ b/drivers/net/wireless/iwlegacy/4965-debug.c @@ -26,7 +26,7 @@ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 *****************************************************************************/ #include "iwl-dev.h" -#include "iwl-core.h" +#include "common.h" #include "4965.h" static const char *fmt_value = " %-30s %10u\n"; diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index dbe5bf2d5791..2f747e4bd2fc 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -52,7 +52,7 @@ #include "iwl-eeprom.h" #include "iwl-dev.h" -#include "iwl-core.h" +#include "common.h" #include "iwl-io.h" #include "iwl-helpers.h" #include "iwl-sta.h" diff --git a/drivers/net/wireless/iwlegacy/4965-rs.c b/drivers/net/wireless/iwlegacy/4965-rs.c index 4809a9d4b977..06f5bebbd7d2 100644 --- a/drivers/net/wireless/iwlegacy/4965-rs.c +++ b/drivers/net/wireless/iwlegacy/4965-rs.c @@ -37,7 +37,7 @@ #include "iwl-dev.h" #include "iwl-sta.h" -#include "iwl-core.h" +#include "common.h" #include "4965.h" #define IL4965_RS_NAME "iwl-4965-rs" diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 6833a3c164e9..7febcf365e69 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -39,7 +39,7 @@ #include "iwl-eeprom.h" #include "iwl-dev.h" -#include "iwl-core.h" +#include "common.h" #include "iwl-io.h" #include "iwl-helpers.h" #include "iwl-sta.h" diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index bbf674d2075b..d99ed75a5646 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -43,7 +43,7 @@ #include "iwl-eeprom.h" #include "iwl-dev.h" #include "iwl-debug.h" -#include "iwl-core.h" +#include "common.h" #include "iwl-io.h" #include "iwl-power.h" #include "iwl-sta.h" diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h new file mode 100644 index 000000000000..5de742c6ce40 --- /dev/null +++ b/drivers/net/wireless/iwlegacy/common.h @@ -0,0 +1,636 @@ +/****************************************************************************** + * + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, + * USA + * + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + * BSD LICENSE + * + * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +#ifndef __il_core_h__ +#define __il_core_h__ + +/************************ + * forward declarations * + ************************/ +struct il_host_cmd; +struct il_cmd; + + +#define IWLWIFI_VERSION "in-tree:" +#define DRV_COPYRIGHT "Copyright(c) 2003-2011 Intel Corporation" +#define DRV_AUTHOR "" + +#define IL_PCI_DEVICE(dev, subdev, cfg) \ + .vendor = PCI_VENDOR_ID_INTEL, .device = (dev), \ + .subvendor = PCI_ANY_ID, .subdevice = (subdev), \ + .driver_data = (kernel_ulong_t)&(cfg) + +#define TIME_UNIT 1024 + +#define IL_SKU_G 0x1 +#define IL_SKU_A 0x2 +#define IL_SKU_N 0x8 + +#define IL_CMD(x) case x: return #x + +struct il_hcmd_ops { + int (*rxon_assoc)(struct il_priv *il, struct il_rxon_context *ctx); + int (*commit_rxon)(struct il_priv *il, struct il_rxon_context *ctx); + void (*set_rxon_chain)(struct il_priv *il, + struct il_rxon_context *ctx); +}; + +struct il_hcmd_utils_ops { + u16 (*get_hcmd_size)(u8 cmd_id, u16 len); + u16 (*build_addsta_hcmd)(const struct il_addsta_cmd *cmd, + u8 *data); + int (*request_scan)(struct il_priv *il, struct ieee80211_vif *vif); + void (*post_scan)(struct il_priv *il); +}; + +struct il_apm_ops { + int (*init)(struct il_priv *il); + void (*config)(struct il_priv *il); +}; + +struct il_debugfs_ops { + ssize_t (*rx_stats_read)(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); + ssize_t (*tx_stats_read)(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); + ssize_t (*general_stats_read)(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); +}; + +struct il_temp_ops { + void (*temperature)(struct il_priv *il); +}; + +struct il_lib_ops { + /* set hw dependent parameters */ + int (*set_hw_params)(struct il_priv *il); + /* Handling TX */ + void (*txq_update_byte_cnt_tbl)(struct il_priv *il, + struct il_tx_queue *txq, + u16 byte_cnt); + int (*txq_attach_buf_to_tfd)(struct il_priv *il, + struct il_tx_queue *txq, + dma_addr_t addr, + u16 len, u8 reset, u8 pad); + void (*txq_free_tfd)(struct il_priv *il, + struct il_tx_queue *txq); + int (*txq_init)(struct il_priv *il, + struct il_tx_queue *txq); + /* setup Rx handler */ + void (*handler_setup)(struct il_priv *il); + /* alive notification after init uCode load */ + void (*init_alive_start)(struct il_priv *il); + /* check validity of rtc data address */ + int (*is_valid_rtc_data_addr)(u32 addr); + /* 1st ucode load */ + int (*load_ucode)(struct il_priv *il); + + void (*dump_nic_error_log)(struct il_priv *il); + int (*dump_fh)(struct il_priv *il, char **buf, bool display); + int (*set_channel_switch)(struct il_priv *il, + struct ieee80211_channel_switch *ch_switch); + /* power management */ + struct il_apm_ops apm_ops; + + /* power */ + int (*send_tx_power) (struct il_priv *il); + void (*update_chain_flags)(struct il_priv *il); + + /* eeprom operations (as defined in iwl-eeprom.h) */ + struct il_eeprom_ops eeprom_ops; + + /* temperature */ + struct il_temp_ops temp_ops; + + struct il_debugfs_ops debugfs_ops; + +}; + +struct il_led_ops { + int (*cmd)(struct il_priv *il, struct il_led_cmd *led_cmd); +}; + +struct il_legacy_ops { + void (*post_associate)(struct il_priv *il); + void (*config_ap)(struct il_priv *il); + /* station management */ + int (*update_bcast_stations)(struct il_priv *il); + int (*manage_ibss_station)(struct il_priv *il, + struct ieee80211_vif *vif, bool add); +}; + +struct il_ops { + const struct il_lib_ops *lib; + const struct il_hcmd_ops *hcmd; + const struct il_hcmd_utils_ops *utils; + const struct il_led_ops *led; + const struct il_nic_ops *nic; + const struct il_legacy_ops *legacy; + const struct ieee80211_ops *ieee80211_ops; +}; + +struct il_mod_params { + int sw_crypto; /* def: 0 = using hardware encryption */ + int disable_hw_scan; /* def: 0 = use h/w scan */ + int num_of_queues; /* def: HW dependent */ + int disable_11n; /* def: 0 = 11n capabilities enabled */ + int amsdu_size_8K; /* def: 1 = enable 8K amsdu size */ + int antenna; /* def: 0 = both antennas (use diversity) */ + int restart_fw; /* def: 1 = restart firmware */ +}; + +/* + * @led_compensation: compensate on the led on/off time per HW according + * to the deviation to achieve the desired led frequency. + * The detail algorithm is described in iwl-led.c + * @chain_noise_num_beacons: number of beacons used to compute chain noise + * @wd_timeout: TX queues watchdog timeout + * @temperature_kelvin: temperature report by uCode in kelvin + * @ucode_tracing: support ucode continuous tracing + * @sensitivity_calib_by_driver: driver has the capability to perform + * sensitivity calibration operation + * @chain_noise_calib_by_driver: driver has the capability to perform + * chain noise calibration operation + */ +struct il_base_params { + int eeprom_size; + int num_of_queues; /* def: HW dependent */ + int num_of_ampdu_queues;/* def: HW dependent */ + /* for il_apm_init() */ + u32 pll_cfg_val; + bool set_l0s; + bool use_bsm; + + u16 led_compensation; + int chain_noise_num_beacons; + unsigned int wd_timeout; + bool temperature_kelvin; + const bool ucode_tracing; + const bool sensitivity_calib_by_driver; + const bool chain_noise_calib_by_driver; +}; + +/** + * struct il_cfg + * @fw_name_pre: Firmware filename prefix. The api version and extension + * (.ucode) will be added to filename before loading from disk. The + * filename is constructed as fw_name_pre.ucode. + * @ucode_api_max: Highest version of uCode API supported by driver. + * @ucode_api_min: Lowest version of uCode API supported by driver. + * @scan_antennas: available antenna for scan operation + * @led_mode: 0=blinking, 1=On(RF On)/Off(RF Off) + * + * We enable the driver to be backward compatible wrt API version. The + * driver specifies which APIs it supports (with @ucode_api_max being the + * highest and @ucode_api_min the lowest). Firmware will only be loaded if + * it has a supported API version. The firmware's API version will be + * stored in @il_priv, enabling the driver to make runtime changes based + * on firmware version used. + * + * For example, + * if (IL_UCODE_API(il->ucode_ver) >= 2) { + * Driver interacts with Firmware API version >= 2. + * } else { + * Driver interacts with Firmware API version 1. + * } + * + * The ideal usage of this infrastructure is to treat a new ucode API + * release as a new hardware revision. That is, through utilizing the + * il_hcmd_utils_ops etc. we accommodate different command structures + * and flows between hardware versions as well as their API + * versions. + * + */ +struct il_cfg { + /* params specific to an individual device within a device family */ + const char *name; + const char *fw_name_pre; + const unsigned int ucode_api_max; + const unsigned int ucode_api_min; + u8 valid_tx_ant; + u8 valid_rx_ant; + unsigned int sku; + u16 eeprom_ver; + u16 eeprom_calib_ver; + const struct il_ops *ops; + /* module based parameters which can be set from modprobe cmd */ + const struct il_mod_params *mod_params; + /* params not likely to change within a device family */ + struct il_base_params *base_params; + /* params likely to change within a device family */ + u8 scan_rx_antennas[IEEE80211_NUM_BANDS]; + enum il_led_mode led_mode; +}; + +/*************************** + * L i b * + ***************************/ + +struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg); +int il_mac_conf_tx(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, u16 queue, + const struct ieee80211_tx_queue_params *params); +int il_mac_tx_last_beacon(struct ieee80211_hw *hw); +void il_set_rxon_hwcrypto(struct il_priv *il, + struct il_rxon_context *ctx, + int hw_decrypt); +int il_check_rxon_cmd(struct il_priv *il, + struct il_rxon_context *ctx); +int il_full_rxon_required(struct il_priv *il, + struct il_rxon_context *ctx); +int il_set_rxon_channel(struct il_priv *il, + struct ieee80211_channel *ch, + struct il_rxon_context *ctx); +void il_set_flags_for_band(struct il_priv *il, + struct il_rxon_context *ctx, + enum ieee80211_band band, + struct ieee80211_vif *vif); +u8 il_get_single_channel_number(struct il_priv *il, + enum ieee80211_band band); +void il_set_rxon_ht(struct il_priv *il, + struct il_ht_config *ht_conf); +bool il_is_ht40_tx_allowed(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_sta_ht_cap *ht_cap); +void il_connection_init_rx_config(struct il_priv *il, + struct il_rxon_context *ctx); +void il_set_rate(struct il_priv *il); +int il_set_decrypted_flag(struct il_priv *il, + struct ieee80211_hdr *hdr, + u32 decrypt_res, + struct ieee80211_rx_status *stats); +void il_irq_handle_error(struct il_priv *il); +int il_mac_add_interface(struct ieee80211_hw *hw, + struct ieee80211_vif *vif); +void il_mac_remove_interface(struct ieee80211_hw *hw, + struct ieee80211_vif *vif); +int il_mac_change_interface(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + enum nl80211_iftype newtype, bool newp2p); +int il_alloc_txq_mem(struct il_priv *il); +void il_txq_mem(struct il_priv *il); + +#ifdef CONFIG_IWLEGACY_DEBUGFS +int il_alloc_traffic_mem(struct il_priv *il); +void il_free_traffic_mem(struct il_priv *il); +void il_reset_traffic_log(struct il_priv *il); +void il_dbg_log_tx_data_frame(struct il_priv *il, + u16 length, struct ieee80211_hdr *header); +void il_dbg_log_rx_data_frame(struct il_priv *il, + u16 length, struct ieee80211_hdr *header); +const char *il_get_mgmt_string(int cmd); +const char *il_get_ctrl_string(int cmd); +void il_clear_traffic_stats(struct il_priv *il); +void il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, + u16 len); +#else +static inline int il_alloc_traffic_mem(struct il_priv *il) +{ + return 0; +} +static inline void il_free_traffic_mem(struct il_priv *il) +{ +} +static inline void il_reset_traffic_log(struct il_priv *il) +{ +} +static inline void il_dbg_log_tx_data_frame(struct il_priv *il, + u16 length, struct ieee80211_hdr *header) +{ +} +static inline void il_dbg_log_rx_data_frame(struct il_priv *il, + u16 length, struct ieee80211_hdr *header) +{ +} +static inline void il_update_stats(struct il_priv *il, bool is_tx, + __le16 fc, u16 len) +{ +} +#endif +/***************************************************** + * RX handlers. + * **************************************************/ +void il_hdl_pm_sleep(struct il_priv *il, + struct il_rx_buf *rxb); +void il_hdl_pm_debug_stats(struct il_priv *il, + struct il_rx_buf *rxb); +void il_hdl_error(struct il_priv *il, + struct il_rx_buf *rxb); + +/***************************************************** +* RX +******************************************************/ +void il_cmd_queue_unmap(struct il_priv *il); +void il_cmd_queue_free(struct il_priv *il); +int il_rx_queue_alloc(struct il_priv *il); +void il_rx_queue_update_write_ptr(struct il_priv *il, + struct il_rx_queue *q); +int il_rx_queue_space(const struct il_rx_queue *q); +void il_tx_cmd_complete(struct il_priv *il, + struct il_rx_buf *rxb); +/* Handlers */ +void il_hdl_spectrum_measurement(struct il_priv *il, + struct il_rx_buf *rxb); +void il_recover_from_stats(struct il_priv *il, + struct il_rx_pkt *pkt); +void il_chswitch_done(struct il_priv *il, bool is_success); +void il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb); + +/* TX helpers */ + +/***************************************************** +* TX +******************************************************/ +void il_txq_update_write_ptr(struct il_priv *il, + struct il_tx_queue *txq); +int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, + int slots_num, u32 txq_id); +void il_tx_queue_reset(struct il_priv *il, + struct il_tx_queue *txq, + int slots_num, u32 txq_id); +void il_tx_queue_unmap(struct il_priv *il, int txq_id); +void il_tx_queue_free(struct il_priv *il, int txq_id); +void il_setup_watchdog(struct il_priv *il); +/***************************************************** + * TX power + ****************************************************/ +int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force); + +/******************************************************************************* + * Rate + ******************************************************************************/ + +u8 il_get_lowest_plcp(struct il_priv *il, + struct il_rxon_context *ctx); + +/******************************************************************************* + * Scanning + ******************************************************************************/ +void il_init_scan_params(struct il_priv *il); +int il_scan_cancel(struct il_priv *il); +int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms); +void il_force_scan_end(struct il_priv *il); +int il_mac_hw_scan(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct cfg80211_scan_request *req); +void il_internal_short_hw_scan(struct il_priv *il); +int il_force_reset(struct il_priv *il, bool external); +u16 il_fill_probe_req(struct il_priv *il, + struct ieee80211_mgmt *frame, + const u8 *ta, const u8 *ie, int ie_len, int left); +void il_setup_rx_scan_handlers(struct il_priv *il); +u16 il_get_active_dwell_time(struct il_priv *il, + enum ieee80211_band band, + u8 n_probes); +u16 il_get_passive_dwell_time(struct il_priv *il, + enum ieee80211_band band, + struct ieee80211_vif *vif); +void il_setup_scan_deferred_work(struct il_priv *il); +void il_cancel_scan_deferred_work(struct il_priv *il); + +/* For faster active scanning, scan will move to the next channel if fewer than + * PLCP_QUIET_THRESH packets are heard on this channel within + * ACTIVE_QUIET_TIME after sending probe request. This shortens the dwell + * time if it's a quiet channel (nothing responded to our probe, and there's + * no other traffic). + * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */ +#define IL_ACTIVE_QUIET_TIME cpu_to_le16(10) /* msec */ +#define IL_PLCP_QUIET_THRESH cpu_to_le16(1) /* packets */ + +#define IL_SCAN_CHECK_WATCHDOG (HZ * 7) + +/***************************************************** + * S e n d i n g H o s t C o m m a n d s * + *****************************************************/ + +const char *il_get_cmd_string(u8 cmd); +int __must_check il_send_cmd_sync(struct il_priv *il, + struct il_host_cmd *cmd); +int il_send_cmd(struct il_priv *il, struct il_host_cmd *cmd); +int __must_check il_send_cmd_pdu(struct il_priv *il, u8 id, + u16 len, const void *data); +int il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, + const void *data, + void (*callback)(struct il_priv *il, + struct il_device_cmd *cmd, + struct il_rx_pkt *pkt)); + +int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd); + + +/***************************************************** + * PCI * + *****************************************************/ + +static inline u16 il_pcie_link_ctl(struct il_priv *il) +{ + int pos; + u16 pci_lnk_ctl; + pos = pci_pcie_cap(il->pci_dev); + pci_read_config_word(il->pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl); + return pci_lnk_ctl; +} + +void il_bg_watchdog(unsigned long data); +u32 il_usecs_to_beacons(struct il_priv *il, + u32 usec, u32 beacon_interval); +__le32 il_add_beacon_time(struct il_priv *il, u32 base, + u32 addon, u32 beacon_interval); + +#ifdef CONFIG_PM +int il_pci_suspend(struct device *device); +int il_pci_resume(struct device *device); +extern const struct dev_pm_ops il_pm_ops; + +#define IL_LEGACY_PM_OPS (&il_pm_ops) + +#else /* !CONFIG_PM */ + +#define IL_LEGACY_PM_OPS NULL + +#endif /* !CONFIG_PM */ + +/***************************************************** +* Error Handling Debugging +******************************************************/ +void il4965_dump_nic_error_log(struct il_priv *il); +#ifdef CONFIG_IWLEGACY_DEBUG +void il_print_rx_config_cmd(struct il_priv *il, + struct il_rxon_context *ctx); +#else +static inline void il_print_rx_config_cmd(struct il_priv *il, + struct il_rxon_context *ctx) +{ +} +#endif + +void il_clear_isr_stats(struct il_priv *il); + +/***************************************************** +* GEOS +******************************************************/ +int il_init_geos(struct il_priv *il); +void il_free_geos(struct il_priv *il); + +/*************** DRIVER STATUS FUNCTIONS *****/ + +#define S_HCMD_ACTIVE 0 /* host command in progress */ +/* 1 is unused (used to be S_HCMD_SYNC_ACTIVE) */ +#define S_INT_ENABLED 2 +#define S_RF_KILL_HW 3 +#define S_CT_KILL 4 +#define S_INIT 5 +#define S_ALIVE 6 +#define S_READY 7 +#define S_TEMPERATURE 8 +#define S_GEO_CONFIGURED 9 +#define S_EXIT_PENDING 10 +#define S_STATS 12 +#define S_SCANNING 13 +#define S_SCAN_ABORTING 14 +#define S_SCAN_HW 15 +#define S_POWER_PMI 16 +#define S_FW_ERROR 17 +#define S_CHANNEL_SWITCH_PENDING 18 + +static inline int il_is_ready(struct il_priv *il) +{ + /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are + * set but EXIT_PENDING is not */ + return test_bit(S_READY, &il->status) && + test_bit(S_GEO_CONFIGURED, &il->status) && + !test_bit(S_EXIT_PENDING, &il->status); +} + +static inline int il_is_alive(struct il_priv *il) +{ + return test_bit(S_ALIVE, &il->status); +} + +static inline int il_is_init(struct il_priv *il) +{ + return test_bit(S_INIT, &il->status); +} + +static inline int il_is_rfkill_hw(struct il_priv *il) +{ + return test_bit(S_RF_KILL_HW, &il->status); +} + +static inline int il_is_rfkill(struct il_priv *il) +{ + return il_is_rfkill_hw(il); +} + +static inline int il_is_ctkill(struct il_priv *il) +{ + return test_bit(S_CT_KILL, &il->status); +} + +static inline int il_is_ready_rf(struct il_priv *il) +{ + + if (il_is_rfkill(il)) + return 0; + + return il_is_ready(il); +} + +extern void il_send_bt_config(struct il_priv *il); +extern int il_send_stats_request(struct il_priv *il, + u8 flags, bool clear); +void il_apm_stop(struct il_priv *il); +int il_apm_init(struct il_priv *il); + +int il_send_rxon_timing(struct il_priv *il, + struct il_rxon_context *ctx); +static inline int il_send_rxon_assoc(struct il_priv *il, + struct il_rxon_context *ctx) +{ + return il->cfg->ops->hcmd->rxon_assoc(il, ctx); +} +static inline int il_commit_rxon(struct il_priv *il, + struct il_rxon_context *ctx) +{ + return il->cfg->ops->hcmd->commit_rxon(il, ctx); +} +static inline const struct ieee80211_supported_band *il_get_hw_mode( + struct il_priv *il, enum ieee80211_band band) +{ + return il->hw->wiphy->bands[band]; +} + +/* mac80211 handlers */ +int il_mac_config(struct ieee80211_hw *hw, u32 changed); +void il_mac_reset_tsf(struct ieee80211_hw *hw, + struct ieee80211_vif *vif); +void il_mac_bss_info_changed(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_bss_conf *bss_conf, + u32 changes); +void il_tx_cmd_protection(struct il_priv *il, + struct ieee80211_tx_info *info, + __le16 fc, __le32 *tx_flags); + +irqreturn_t il_isr(int irq, void *data); + +#endif /* __il_core_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-core.h b/drivers/net/wireless/iwlegacy/iwl-core.h deleted file mode 100644 index 5de742c6ce40..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-core.h +++ /dev/null @@ -1,636 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef __il_core_h__ -#define __il_core_h__ - -/************************ - * forward declarations * - ************************/ -struct il_host_cmd; -struct il_cmd; - - -#define IWLWIFI_VERSION "in-tree:" -#define DRV_COPYRIGHT "Copyright(c) 2003-2011 Intel Corporation" -#define DRV_AUTHOR "" - -#define IL_PCI_DEVICE(dev, subdev, cfg) \ - .vendor = PCI_VENDOR_ID_INTEL, .device = (dev), \ - .subvendor = PCI_ANY_ID, .subdevice = (subdev), \ - .driver_data = (kernel_ulong_t)&(cfg) - -#define TIME_UNIT 1024 - -#define IL_SKU_G 0x1 -#define IL_SKU_A 0x2 -#define IL_SKU_N 0x8 - -#define IL_CMD(x) case x: return #x - -struct il_hcmd_ops { - int (*rxon_assoc)(struct il_priv *il, struct il_rxon_context *ctx); - int (*commit_rxon)(struct il_priv *il, struct il_rxon_context *ctx); - void (*set_rxon_chain)(struct il_priv *il, - struct il_rxon_context *ctx); -}; - -struct il_hcmd_utils_ops { - u16 (*get_hcmd_size)(u8 cmd_id, u16 len); - u16 (*build_addsta_hcmd)(const struct il_addsta_cmd *cmd, - u8 *data); - int (*request_scan)(struct il_priv *il, struct ieee80211_vif *vif); - void (*post_scan)(struct il_priv *il); -}; - -struct il_apm_ops { - int (*init)(struct il_priv *il); - void (*config)(struct il_priv *il); -}; - -struct il_debugfs_ops { - ssize_t (*rx_stats_read)(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); - ssize_t (*tx_stats_read)(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); - ssize_t (*general_stats_read)(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); -}; - -struct il_temp_ops { - void (*temperature)(struct il_priv *il); -}; - -struct il_lib_ops { - /* set hw dependent parameters */ - int (*set_hw_params)(struct il_priv *il); - /* Handling TX */ - void (*txq_update_byte_cnt_tbl)(struct il_priv *il, - struct il_tx_queue *txq, - u16 byte_cnt); - int (*txq_attach_buf_to_tfd)(struct il_priv *il, - struct il_tx_queue *txq, - dma_addr_t addr, - u16 len, u8 reset, u8 pad); - void (*txq_free_tfd)(struct il_priv *il, - struct il_tx_queue *txq); - int (*txq_init)(struct il_priv *il, - struct il_tx_queue *txq); - /* setup Rx handler */ - void (*handler_setup)(struct il_priv *il); - /* alive notification after init uCode load */ - void (*init_alive_start)(struct il_priv *il); - /* check validity of rtc data address */ - int (*is_valid_rtc_data_addr)(u32 addr); - /* 1st ucode load */ - int (*load_ucode)(struct il_priv *il); - - void (*dump_nic_error_log)(struct il_priv *il); - int (*dump_fh)(struct il_priv *il, char **buf, bool display); - int (*set_channel_switch)(struct il_priv *il, - struct ieee80211_channel_switch *ch_switch); - /* power management */ - struct il_apm_ops apm_ops; - - /* power */ - int (*send_tx_power) (struct il_priv *il); - void (*update_chain_flags)(struct il_priv *il); - - /* eeprom operations (as defined in iwl-eeprom.h) */ - struct il_eeprom_ops eeprom_ops; - - /* temperature */ - struct il_temp_ops temp_ops; - - struct il_debugfs_ops debugfs_ops; - -}; - -struct il_led_ops { - int (*cmd)(struct il_priv *il, struct il_led_cmd *led_cmd); -}; - -struct il_legacy_ops { - void (*post_associate)(struct il_priv *il); - void (*config_ap)(struct il_priv *il); - /* station management */ - int (*update_bcast_stations)(struct il_priv *il); - int (*manage_ibss_station)(struct il_priv *il, - struct ieee80211_vif *vif, bool add); -}; - -struct il_ops { - const struct il_lib_ops *lib; - const struct il_hcmd_ops *hcmd; - const struct il_hcmd_utils_ops *utils; - const struct il_led_ops *led; - const struct il_nic_ops *nic; - const struct il_legacy_ops *legacy; - const struct ieee80211_ops *ieee80211_ops; -}; - -struct il_mod_params { - int sw_crypto; /* def: 0 = using hardware encryption */ - int disable_hw_scan; /* def: 0 = use h/w scan */ - int num_of_queues; /* def: HW dependent */ - int disable_11n; /* def: 0 = 11n capabilities enabled */ - int amsdu_size_8K; /* def: 1 = enable 8K amsdu size */ - int antenna; /* def: 0 = both antennas (use diversity) */ - int restart_fw; /* def: 1 = restart firmware */ -}; - -/* - * @led_compensation: compensate on the led on/off time per HW according - * to the deviation to achieve the desired led frequency. - * The detail algorithm is described in iwl-led.c - * @chain_noise_num_beacons: number of beacons used to compute chain noise - * @wd_timeout: TX queues watchdog timeout - * @temperature_kelvin: temperature report by uCode in kelvin - * @ucode_tracing: support ucode continuous tracing - * @sensitivity_calib_by_driver: driver has the capability to perform - * sensitivity calibration operation - * @chain_noise_calib_by_driver: driver has the capability to perform - * chain noise calibration operation - */ -struct il_base_params { - int eeprom_size; - int num_of_queues; /* def: HW dependent */ - int num_of_ampdu_queues;/* def: HW dependent */ - /* for il_apm_init() */ - u32 pll_cfg_val; - bool set_l0s; - bool use_bsm; - - u16 led_compensation; - int chain_noise_num_beacons; - unsigned int wd_timeout; - bool temperature_kelvin; - const bool ucode_tracing; - const bool sensitivity_calib_by_driver; - const bool chain_noise_calib_by_driver; -}; - -/** - * struct il_cfg - * @fw_name_pre: Firmware filename prefix. The api version and extension - * (.ucode) will be added to filename before loading from disk. The - * filename is constructed as fw_name_pre.ucode. - * @ucode_api_max: Highest version of uCode API supported by driver. - * @ucode_api_min: Lowest version of uCode API supported by driver. - * @scan_antennas: available antenna for scan operation - * @led_mode: 0=blinking, 1=On(RF On)/Off(RF Off) - * - * We enable the driver to be backward compatible wrt API version. The - * driver specifies which APIs it supports (with @ucode_api_max being the - * highest and @ucode_api_min the lowest). Firmware will only be loaded if - * it has a supported API version. The firmware's API version will be - * stored in @il_priv, enabling the driver to make runtime changes based - * on firmware version used. - * - * For example, - * if (IL_UCODE_API(il->ucode_ver) >= 2) { - * Driver interacts with Firmware API version >= 2. - * } else { - * Driver interacts with Firmware API version 1. - * } - * - * The ideal usage of this infrastructure is to treat a new ucode API - * release as a new hardware revision. That is, through utilizing the - * il_hcmd_utils_ops etc. we accommodate different command structures - * and flows between hardware versions as well as their API - * versions. - * - */ -struct il_cfg { - /* params specific to an individual device within a device family */ - const char *name; - const char *fw_name_pre; - const unsigned int ucode_api_max; - const unsigned int ucode_api_min; - u8 valid_tx_ant; - u8 valid_rx_ant; - unsigned int sku; - u16 eeprom_ver; - u16 eeprom_calib_ver; - const struct il_ops *ops; - /* module based parameters which can be set from modprobe cmd */ - const struct il_mod_params *mod_params; - /* params not likely to change within a device family */ - struct il_base_params *base_params; - /* params likely to change within a device family */ - u8 scan_rx_antennas[IEEE80211_NUM_BANDS]; - enum il_led_mode led_mode; -}; - -/*************************** - * L i b * - ***************************/ - -struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg); -int il_mac_conf_tx(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, u16 queue, - const struct ieee80211_tx_queue_params *params); -int il_mac_tx_last_beacon(struct ieee80211_hw *hw); -void il_set_rxon_hwcrypto(struct il_priv *il, - struct il_rxon_context *ctx, - int hw_decrypt); -int il_check_rxon_cmd(struct il_priv *il, - struct il_rxon_context *ctx); -int il_full_rxon_required(struct il_priv *il, - struct il_rxon_context *ctx); -int il_set_rxon_channel(struct il_priv *il, - struct ieee80211_channel *ch, - struct il_rxon_context *ctx); -void il_set_flags_for_band(struct il_priv *il, - struct il_rxon_context *ctx, - enum ieee80211_band band, - struct ieee80211_vif *vif); -u8 il_get_single_channel_number(struct il_priv *il, - enum ieee80211_band band); -void il_set_rxon_ht(struct il_priv *il, - struct il_ht_config *ht_conf); -bool il_is_ht40_tx_allowed(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_sta_ht_cap *ht_cap); -void il_connection_init_rx_config(struct il_priv *il, - struct il_rxon_context *ctx); -void il_set_rate(struct il_priv *il); -int il_set_decrypted_flag(struct il_priv *il, - struct ieee80211_hdr *hdr, - u32 decrypt_res, - struct ieee80211_rx_status *stats); -void il_irq_handle_error(struct il_priv *il); -int il_mac_add_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif); -void il_mac_remove_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif); -int il_mac_change_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - enum nl80211_iftype newtype, bool newp2p); -int il_alloc_txq_mem(struct il_priv *il); -void il_txq_mem(struct il_priv *il); - -#ifdef CONFIG_IWLEGACY_DEBUGFS -int il_alloc_traffic_mem(struct il_priv *il); -void il_free_traffic_mem(struct il_priv *il); -void il_reset_traffic_log(struct il_priv *il); -void il_dbg_log_tx_data_frame(struct il_priv *il, - u16 length, struct ieee80211_hdr *header); -void il_dbg_log_rx_data_frame(struct il_priv *il, - u16 length, struct ieee80211_hdr *header); -const char *il_get_mgmt_string(int cmd); -const char *il_get_ctrl_string(int cmd); -void il_clear_traffic_stats(struct il_priv *il); -void il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, - u16 len); -#else -static inline int il_alloc_traffic_mem(struct il_priv *il) -{ - return 0; -} -static inline void il_free_traffic_mem(struct il_priv *il) -{ -} -static inline void il_reset_traffic_log(struct il_priv *il) -{ -} -static inline void il_dbg_log_tx_data_frame(struct il_priv *il, - u16 length, struct ieee80211_hdr *header) -{ -} -static inline void il_dbg_log_rx_data_frame(struct il_priv *il, - u16 length, struct ieee80211_hdr *header) -{ -} -static inline void il_update_stats(struct il_priv *il, bool is_tx, - __le16 fc, u16 len) -{ -} -#endif -/***************************************************** - * RX handlers. - * **************************************************/ -void il_hdl_pm_sleep(struct il_priv *il, - struct il_rx_buf *rxb); -void il_hdl_pm_debug_stats(struct il_priv *il, - struct il_rx_buf *rxb); -void il_hdl_error(struct il_priv *il, - struct il_rx_buf *rxb); - -/***************************************************** -* RX -******************************************************/ -void il_cmd_queue_unmap(struct il_priv *il); -void il_cmd_queue_free(struct il_priv *il); -int il_rx_queue_alloc(struct il_priv *il); -void il_rx_queue_update_write_ptr(struct il_priv *il, - struct il_rx_queue *q); -int il_rx_queue_space(const struct il_rx_queue *q); -void il_tx_cmd_complete(struct il_priv *il, - struct il_rx_buf *rxb); -/* Handlers */ -void il_hdl_spectrum_measurement(struct il_priv *il, - struct il_rx_buf *rxb); -void il_recover_from_stats(struct il_priv *il, - struct il_rx_pkt *pkt); -void il_chswitch_done(struct il_priv *il, bool is_success); -void il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb); - -/* TX helpers */ - -/***************************************************** -* TX -******************************************************/ -void il_txq_update_write_ptr(struct il_priv *il, - struct il_tx_queue *txq); -int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, - int slots_num, u32 txq_id); -void il_tx_queue_reset(struct il_priv *il, - struct il_tx_queue *txq, - int slots_num, u32 txq_id); -void il_tx_queue_unmap(struct il_priv *il, int txq_id); -void il_tx_queue_free(struct il_priv *il, int txq_id); -void il_setup_watchdog(struct il_priv *il); -/***************************************************** - * TX power - ****************************************************/ -int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force); - -/******************************************************************************* - * Rate - ******************************************************************************/ - -u8 il_get_lowest_plcp(struct il_priv *il, - struct il_rxon_context *ctx); - -/******************************************************************************* - * Scanning - ******************************************************************************/ -void il_init_scan_params(struct il_priv *il); -int il_scan_cancel(struct il_priv *il); -int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms); -void il_force_scan_end(struct il_priv *il); -int il_mac_hw_scan(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct cfg80211_scan_request *req); -void il_internal_short_hw_scan(struct il_priv *il); -int il_force_reset(struct il_priv *il, bool external); -u16 il_fill_probe_req(struct il_priv *il, - struct ieee80211_mgmt *frame, - const u8 *ta, const u8 *ie, int ie_len, int left); -void il_setup_rx_scan_handlers(struct il_priv *il); -u16 il_get_active_dwell_time(struct il_priv *il, - enum ieee80211_band band, - u8 n_probes); -u16 il_get_passive_dwell_time(struct il_priv *il, - enum ieee80211_band band, - struct ieee80211_vif *vif); -void il_setup_scan_deferred_work(struct il_priv *il); -void il_cancel_scan_deferred_work(struct il_priv *il); - -/* For faster active scanning, scan will move to the next channel if fewer than - * PLCP_QUIET_THRESH packets are heard on this channel within - * ACTIVE_QUIET_TIME after sending probe request. This shortens the dwell - * time if it's a quiet channel (nothing responded to our probe, and there's - * no other traffic). - * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */ -#define IL_ACTIVE_QUIET_TIME cpu_to_le16(10) /* msec */ -#define IL_PLCP_QUIET_THRESH cpu_to_le16(1) /* packets */ - -#define IL_SCAN_CHECK_WATCHDOG (HZ * 7) - -/***************************************************** - * S e n d i n g H o s t C o m m a n d s * - *****************************************************/ - -const char *il_get_cmd_string(u8 cmd); -int __must_check il_send_cmd_sync(struct il_priv *il, - struct il_host_cmd *cmd); -int il_send_cmd(struct il_priv *il, struct il_host_cmd *cmd); -int __must_check il_send_cmd_pdu(struct il_priv *il, u8 id, - u16 len, const void *data); -int il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, - const void *data, - void (*callback)(struct il_priv *il, - struct il_device_cmd *cmd, - struct il_rx_pkt *pkt)); - -int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd); - - -/***************************************************** - * PCI * - *****************************************************/ - -static inline u16 il_pcie_link_ctl(struct il_priv *il) -{ - int pos; - u16 pci_lnk_ctl; - pos = pci_pcie_cap(il->pci_dev); - pci_read_config_word(il->pci_dev, pos + PCI_EXP_LNKCTL, &pci_lnk_ctl); - return pci_lnk_ctl; -} - -void il_bg_watchdog(unsigned long data); -u32 il_usecs_to_beacons(struct il_priv *il, - u32 usec, u32 beacon_interval); -__le32 il_add_beacon_time(struct il_priv *il, u32 base, - u32 addon, u32 beacon_interval); - -#ifdef CONFIG_PM -int il_pci_suspend(struct device *device); -int il_pci_resume(struct device *device); -extern const struct dev_pm_ops il_pm_ops; - -#define IL_LEGACY_PM_OPS (&il_pm_ops) - -#else /* !CONFIG_PM */ - -#define IL_LEGACY_PM_OPS NULL - -#endif /* !CONFIG_PM */ - -/***************************************************** -* Error Handling Debugging -******************************************************/ -void il4965_dump_nic_error_log(struct il_priv *il); -#ifdef CONFIG_IWLEGACY_DEBUG -void il_print_rx_config_cmd(struct il_priv *il, - struct il_rxon_context *ctx); -#else -static inline void il_print_rx_config_cmd(struct il_priv *il, - struct il_rxon_context *ctx) -{ -} -#endif - -void il_clear_isr_stats(struct il_priv *il); - -/***************************************************** -* GEOS -******************************************************/ -int il_init_geos(struct il_priv *il); -void il_free_geos(struct il_priv *il); - -/*************** DRIVER STATUS FUNCTIONS *****/ - -#define S_HCMD_ACTIVE 0 /* host command in progress */ -/* 1 is unused (used to be S_HCMD_SYNC_ACTIVE) */ -#define S_INT_ENABLED 2 -#define S_RF_KILL_HW 3 -#define S_CT_KILL 4 -#define S_INIT 5 -#define S_ALIVE 6 -#define S_READY 7 -#define S_TEMPERATURE 8 -#define S_GEO_CONFIGURED 9 -#define S_EXIT_PENDING 10 -#define S_STATS 12 -#define S_SCANNING 13 -#define S_SCAN_ABORTING 14 -#define S_SCAN_HW 15 -#define S_POWER_PMI 16 -#define S_FW_ERROR 17 -#define S_CHANNEL_SWITCH_PENDING 18 - -static inline int il_is_ready(struct il_priv *il) -{ - /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are - * set but EXIT_PENDING is not */ - return test_bit(S_READY, &il->status) && - test_bit(S_GEO_CONFIGURED, &il->status) && - !test_bit(S_EXIT_PENDING, &il->status); -} - -static inline int il_is_alive(struct il_priv *il) -{ - return test_bit(S_ALIVE, &il->status); -} - -static inline int il_is_init(struct il_priv *il) -{ - return test_bit(S_INIT, &il->status); -} - -static inline int il_is_rfkill_hw(struct il_priv *il) -{ - return test_bit(S_RF_KILL_HW, &il->status); -} - -static inline int il_is_rfkill(struct il_priv *il) -{ - return il_is_rfkill_hw(il); -} - -static inline int il_is_ctkill(struct il_priv *il) -{ - return test_bit(S_CT_KILL, &il->status); -} - -static inline int il_is_ready_rf(struct il_priv *il) -{ - - if (il_is_rfkill(il)) - return 0; - - return il_is_ready(il); -} - -extern void il_send_bt_config(struct il_priv *il); -extern int il_send_stats_request(struct il_priv *il, - u8 flags, bool clear); -void il_apm_stop(struct il_priv *il); -int il_apm_init(struct il_priv *il); - -int il_send_rxon_timing(struct il_priv *il, - struct il_rxon_context *ctx); -static inline int il_send_rxon_assoc(struct il_priv *il, - struct il_rxon_context *ctx) -{ - return il->cfg->ops->hcmd->rxon_assoc(il, ctx); -} -static inline int il_commit_rxon(struct il_priv *il, - struct il_rxon_context *ctx) -{ - return il->cfg->ops->hcmd->commit_rxon(il, ctx); -} -static inline const struct ieee80211_supported_band *il_get_hw_mode( - struct il_priv *il, enum ieee80211_band band) -{ - return il->hw->wiphy->bands[band]; -} - -/* mac80211 handlers */ -int il_mac_config(struct ieee80211_hw *hw, u32 changed); -void il_mac_reset_tsf(struct ieee80211_hw *hw, - struct ieee80211_vif *vif); -void il_mac_bss_info_changed(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_bss_conf *bss_conf, - u32 changes); -void il_tx_cmd_protection(struct il_priv *il, - struct ieee80211_tx_info *info, - __le16 fc, __le32 *tx_flags); - -irqreturn_t il_isr(int irq, void *data); - -#endif /* __il_core_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index 3f6b06e99d2f..6c4bc5065e5c 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -31,7 +31,7 @@ #include "iwl-dev.h" #include "iwl-debug.h" -#include "iwl-core.h" +#include "common.h" #include "iwl-io.h" /* create and remove of files */ -- cgit v1.2.3 From e94a4099adb2ec148776975bcd953a01c6bec992 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 13:23:20 +0200 Subject: iwlegacy: merge common header files Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/3945-debug.c | 1 - drivers/net/wireless/iwlegacy/3945-mac.c | 7 +- drivers/net/wireless/iwlegacy/3945-rs.c | 1 - drivers/net/wireless/iwlegacy/3945.c | 6 +- drivers/net/wireless/iwlegacy/3945.h | 9 +- drivers/net/wireless/iwlegacy/4965-calib.c | 1 - drivers/net/wireless/iwlegacy/4965-debug.c | 1 - drivers/net/wireless/iwlegacy/4965-mac.c | 8 +- drivers/net/wireless/iwlegacy/4965-rs.c | 2 - drivers/net/wireless/iwlegacy/4965.c | 6 +- drivers/net/wireless/iwlegacy/commands.h | 2 + drivers/net/wireless/iwlegacy/common.c | 6 +- drivers/net/wireless/iwlegacy/common.h | 2052 ++++++++++++++++++++++++++- drivers/net/wireless/iwlegacy/iwl-debugfs.c | 2 - drivers/net/wireless/iwlegacy/iwl-dev.h | 1351 ------------------ drivers/net/wireless/iwlegacy/iwl-fh.h | 96 -- drivers/net/wireless/iwlegacy/iwl-io.h | 337 ----- drivers/net/wireless/iwlegacy/iwl-sta.h | 146 -- 18 files changed, 2007 insertions(+), 2027 deletions(-) delete mode 100644 drivers/net/wireless/iwlegacy/iwl-dev.h delete mode 100644 drivers/net/wireless/iwlegacy/iwl-io.h delete mode 100644 drivers/net/wireless/iwlegacy/iwl-sta.h (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/3945-debug.c b/drivers/net/wireless/iwlegacy/3945-debug.c index b73b4253cd28..1a690a046b50 100644 --- a/drivers/net/wireless/iwlegacy/3945-debug.c +++ b/drivers/net/wireless/iwlegacy/3945-debug.c @@ -26,7 +26,6 @@ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 *****************************************************************************/ -#include "iwl-dev.h" #include "common.h" #include "3945.h" diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index b650292a7f89..3c8999960011 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -52,11 +52,8 @@ #define DRV_NAME "iwl3945" #include "commands.h" -#include "iwl-sta.h" -#include "3945.h" #include "common.h" -#include "iwl-helpers.h" -#include "iwl-dev.h" +#include "3945.h" #include "iwl-spectrum.h" /* @@ -1242,7 +1239,7 @@ static void il3945_rx_handle(struct il_priv *il) PCI_DMA_FROMDEVICE); pkt = rxb_addr(rxb); - len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; + len = le32_to_cpu(pkt->len_n_flags) & IL_RX_FRAME_SIZE_MSK; len += sizeof(u32); /* account for status word */ /* Reclaim a command buffer only if this packet is a response diff --git a/drivers/net/wireless/iwlegacy/3945-rs.c b/drivers/net/wireless/iwlegacy/3945-rs.c index 4aa0432b4a6d..dc0dfdd520ab 100644 --- a/drivers/net/wireless/iwlegacy/3945-rs.c +++ b/drivers/net/wireless/iwlegacy/3945-rs.c @@ -38,7 +38,6 @@ #include "commands.h" #include "3945.h" -#include "iwl-sta.h" #define RS_NAME "iwl-3945-rs" diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 795d206f10e8..02ae32cc90de 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -39,11 +39,9 @@ #include #include +#include "common.h" #include "commands.h" -#include "iwl-sta.h" #include "iwl-eeprom.h" -#include "common.h" -#include "iwl-helpers.h" #include "iwl-led.h" #include "3945.h" @@ -417,7 +415,7 @@ void il3945_hdl_stats(struct il_priv *il, D_RX("Statistics notification received (%d vs %d).\n", (int)sizeof(struct il3945_notif_stats), - le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK); + le32_to_cpu(pkt->len_n_flags) & IL_RX_FRAME_SIZE_MSK); #ifdef CONFIG_IWLEGACY_DEBUGFS il3945_accumulative_stats(il, (__le32 *)&pkt->u.raw); #endif diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index e89ca5da7f3c..726ca2c5cd6a 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -34,10 +34,10 @@ /* Hardware specific file defines the PCI IDs table for that hardware module */ extern const struct pci_device_id il3945_hw_card_ids[]; +#include "common.h" #include "iwl-prph.h" #include "iwl-debug.h" #include "iwl-power.h" -#include "iwl-dev.h" #include "iwl-led.h" #include "iwl-eeprom.h" @@ -455,10 +455,6 @@ struct il3945_eeprom { #define RFD_SIZE 4 #define NUM_TFD_CHUNKS 4 -#define RX_QUEUE_SIZE 256 -#define RX_QUEUE_MASK 255 -#define RX_QUEUE_SIZE_LOG 8 - #define TFD_CTL_COUNT_SET(n) (n << 24) #define TFD_CTL_COUNT_GET(ctl) ((ctl >> 24) & 7) #define TFD_CTL_PAD_SET(n) (n << 28) @@ -659,7 +655,4 @@ static ssize_t il3945_ucode_general_stats_read(struct file *file, } #endif -/* Requires full declaration of il_priv before including */ -#include "iwl-io.h" - #endif diff --git a/drivers/net/wireless/iwlegacy/4965-calib.c b/drivers/net/wireless/iwlegacy/4965-calib.c index 1e4779847a2b..405032a9b36e 100644 --- a/drivers/net/wireless/iwlegacy/4965-calib.c +++ b/drivers/net/wireless/iwlegacy/4965-calib.c @@ -63,7 +63,6 @@ #include #include -#include "iwl-dev.h" #include "common.h" #include "4965.h" diff --git a/drivers/net/wireless/iwlegacy/4965-debug.c b/drivers/net/wireless/iwlegacy/4965-debug.c index 1056d3e3a157..5f8903175168 100644 --- a/drivers/net/wireless/iwlegacy/4965-debug.c +++ b/drivers/net/wireless/iwlegacy/4965-debug.c @@ -25,7 +25,6 @@ * Intel Linux Wireless * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 *****************************************************************************/ -#include "iwl-dev.h" #include "common.h" #include "4965.h" diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 2f747e4bd2fc..6848b9182a71 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -51,11 +51,7 @@ #define DRV_NAME "iwl4965" #include "iwl-eeprom.h" -#include "iwl-dev.h" #include "common.h" -#include "iwl-io.h" -#include "iwl-helpers.h" -#include "iwl-sta.h" #include "4965.h" @@ -1362,7 +1358,7 @@ void il4965_hdl_stats(struct il_priv *il, "Statistics notification received (%d vs %d).\n", (int)sizeof(struct il_notif_stats), le32_to_cpu(pkt->len_n_flags) & - FH_RSCSR_FRAME_SIZE_MSK); + IL_RX_FRAME_SIZE_MSK); change = ((il->_4965.stats.general.common.temperature != pkt->u.stats.general.common.temperature) || @@ -4009,7 +4005,7 @@ void il4965_rx_handle(struct il_priv *il) PCI_DMA_FROMDEVICE); pkt = rxb_addr(rxb); - len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; + len = le32_to_cpu(pkt->len_n_flags) & IL_RX_FRAME_SIZE_MSK; len += sizeof(u32); /* account for status word */ /* Reclaim a command buffer only if this packet is a response diff --git a/drivers/net/wireless/iwlegacy/4965-rs.c b/drivers/net/wireless/iwlegacy/4965-rs.c index 06f5bebbd7d2..f9db9df21321 100644 --- a/drivers/net/wireless/iwlegacy/4965-rs.c +++ b/drivers/net/wireless/iwlegacy/4965-rs.c @@ -35,8 +35,6 @@ #include -#include "iwl-dev.h" -#include "iwl-sta.h" #include "common.h" #include "4965.h" diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 7febcf365e69..d66d4e8c1e76 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -37,12 +37,8 @@ #include #include -#include "iwl-eeprom.h" -#include "iwl-dev.h" #include "common.h" -#include "iwl-io.h" -#include "iwl-helpers.h" -#include "iwl-sta.h" +#include "iwl-eeprom.h" #include "4965.h" #define IL_AC_UNSET -1 diff --git a/drivers/net/wireless/iwlegacy/commands.h b/drivers/net/wireless/iwlegacy/commands.h index 82cf472157de..2f64ed391681 100644 --- a/drivers/net/wireless/iwlegacy/commands.h +++ b/drivers/net/wireless/iwlegacy/commands.h @@ -3355,6 +3355,8 @@ struct il_led_cmd { * *****************************************************************************/ +#define IL_RX_FRAME_SIZE_MSK 0x00003fff + struct il_rx_pkt { /* * The first 4 bytes of the RX frame header contain both the RX frame diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index d99ed75a5646..4258bf6d5150 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -41,13 +41,9 @@ #include #include "iwl-eeprom.h" -#include "iwl-dev.h" #include "iwl-debug.h" #include "common.h" -#include "iwl-io.h" #include "iwl-power.h" -#include "iwl-sta.h" -#include "iwl-helpers.h" const char *il_get_cmd_string(u8 cmd) { @@ -4351,7 +4347,7 @@ void il_hdl_pm_debug_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); - u32 len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; + u32 len = le32_to_cpu(pkt->len_n_flags) & IL_RX_FRAME_SIZE_MSK; D_RADIO("Dumping %d bytes of unhandled " "notification for %s:\n", len, il_get_cmd_string(pkt->hdr.cmd)); diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 5de742c6ce40..e83c6ab39fcf 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1,74 +1,1358 @@ /****************************************************************************** * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. + * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as * published by the Free Software Foundation. * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. * * Contact Information: * Intel Linux Wireless * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ + *****************************************************************************/ +#ifndef __il_core_h__ +#define __il_core_h__ + +#include +#include /* for struct pci_device_id */ +#include +#include +#include +#include + +#include "iwl-eeprom.h" +#include "csr.h" +#include "iwl-prph.h" +#include "iwl-debug.h" +#include "iwl-led.h" +#include "iwl-power.h" +#include "iwl-legacy-rs.h" + +struct il_host_cmd; +struct il_cmd; +struct il_tx_queue; + +#define RX_QUEUE_SIZE 256 +#define RX_QUEUE_MASK 255 +#define RX_QUEUE_SIZE_LOG 8 + +/* + * RX related structures and functions + */ +#define RX_FREE_BUFFERS 64 +#define RX_LOW_WATERMARK 8 + +#define U32_PAD(n) ((4-(n))&0x3) + +/* CT-KILL constants */ +#define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */ + +/* Default noise level to report when noise measurement is not available. + * This may be because we're: + * 1) Not associated (4965, no beacon stats being sent to driver) + * 2) Scanning (noise measurement does not apply to associated channel) + * 3) Receiving CCK (3945 delivers noise info only for OFDM frames) + * Use default noise value of -127 ... this is below the range of measurable + * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user. + * Also, -127 works better than 0 when averaging frames with/without + * noise info (e.g. averaging might be done in app); measured dBm values are + * always negative ... using a negative value as the default keeps all + * averages within an s8's (used in some apps) range of negative values. */ +#define IL_NOISE_MEAS_NOT_AVAILABLE (-127) + +/* + * RTS threshold here is total size [2347] minus 4 FCS bytes + * Per spec: + * a value of 0 means RTS on all data/management packets + * a value > max MSDU size means no RTS + * else RTS for data/management frames where MPDU is larger + * than RTS value. + */ +#define DEFAULT_RTS_THRESHOLD 2347U +#define MIN_RTS_THRESHOLD 0U +#define MAX_RTS_THRESHOLD 2347U +#define MAX_MSDU_SIZE 2304U +#define MAX_MPDU_SIZE 2346U +#define DEFAULT_BEACON_INTERVAL 100U +#define DEFAULT_SHORT_RETRY_LIMIT 7U +#define DEFAULT_LONG_RETRY_LIMIT 4U + +struct il_rx_buf { + dma_addr_t page_dma; + struct page *page; + struct list_head list; +}; + +#define rxb_addr(r) page_address(r->page) + +/* defined below */ +struct il_device_cmd; + +struct il_cmd_meta { + /* only for SYNC commands, iff the reply skb is wanted */ + struct il_host_cmd *source; + /* + * only for ASYNC commands + * (which is somewhat stupid -- look at common.c for instance + * which duplicates a bunch of code because the callback isn't + * invoked for SYNC commands, if it were and its result passed + * through it would be simpler...) + */ + void (*callback)(struct il_priv *il, + struct il_device_cmd *cmd, + struct il_rx_pkt *pkt); + + /* The CMD_SIZE_HUGE flag bit indicates that the command + * structure is stored at the end of the shared queue memory. */ + u32 flags; + + DEFINE_DMA_UNMAP_ADDR(mapping); + DEFINE_DMA_UNMAP_LEN(len); +}; + +/* + * Generic queue structure + * + * Contains common data for Rx and Tx queues + */ +struct il_queue { + int n_bd; /* number of BDs in this queue */ + int write_ptr; /* 1-st empty entry (idx) host_w*/ + int read_ptr; /* last used entry (idx) host_r*/ + /* use for monitoring and recovering the stuck queue */ + dma_addr_t dma_addr; /* physical addr for BD's */ + int n_win; /* safe queue win */ + u32 id; + int low_mark; /* low watermark, resume queue if free + * space more than this */ + int high_mark; /* high watermark, stop queue if free + * space less than this */ +}; + +/* One for each TFD */ +struct il_tx_info { + struct sk_buff *skb; + struct il_rxon_context *ctx; +}; + +/** + * struct il_tx_queue - Tx Queue for DMA + * @q: generic Rx/Tx queue descriptor + * @bd: base of circular buffer of TFDs + * @cmd: array of command/TX buffer pointers + * @meta: array of meta data for each command/tx buffer + * @dma_addr_cmd: physical address of cmd/tx buffer array + * @txb: array of per-TFD driver data + * @time_stamp: time (in jiffies) of last read_ptr change + * @need_update: indicates need to update read/write idx + * @sched_retry: indicates queue is high-throughput aggregation (HT AGG) enabled + * + * A Tx queue consists of circular buffer of BDs (a.k.a. TFDs, transmit frame + * descriptors) and required locking structures. + */ +#define TFD_TX_CMD_SLOTS 256 +#define TFD_CMD_SLOTS 32 + +struct il_tx_queue { + struct il_queue q; + void *tfds; + struct il_device_cmd **cmd; + struct il_cmd_meta *meta; + struct il_tx_info *txb; + unsigned long time_stamp; + u8 need_update; + u8 sched_retry; + u8 active; + u8 swq_id; +}; + +#define IL_NUM_SCAN_RATES (2) + +struct il4965_channel_tgd_info { + u8 type; + s8 max_power; +}; + +struct il4965_channel_tgh_info { + s64 last_radar_time; +}; + +#define IL4965_MAX_RATE (33) + +struct il3945_clip_group { + /* maximum power level to prevent clipping for each rate, derived by + * us from this band's saturation power in EEPROM */ + const s8 clip_powers[IL_MAX_RATES]; +}; + +/* current Tx power values to use, one for each rate for each channel. + * requested power is limited by: + * -- regulatory EEPROM limits for this channel + * -- hardware capabilities (clip-powers) + * -- spectrum management + * -- user preference (e.g. iwconfig) + * when requested power is set, base power idx must also be set. */ +struct il3945_channel_power_info { + struct il3945_tx_power tpc; /* actual radio and DSP gain settings */ + s8 power_table_idx; /* actual (compenst'd) idx into gain table */ + s8 base_power_idx; /* gain idx for power at factory temp. */ + s8 requested_power; /* power (dBm) requested for this chnl/rate */ +}; + +/* current scan Tx power values to use, one for each scan rate for each + * channel. */ +struct il3945_scan_power_info { + struct il3945_tx_power tpc; /* actual radio and DSP gain settings */ + s8 power_table_idx; /* actual (compenst'd) idx into gain table */ + s8 requested_power; /* scan pwr (dBm) requested for chnl/rate */ +}; + +/* + * One for each channel, holds all channel setup data + * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant + * with one another! + */ +struct il_channel_info { + struct il4965_channel_tgd_info tgd; + struct il4965_channel_tgh_info tgh; + struct il_eeprom_channel eeprom; /* EEPROM regulatory limit */ + struct il_eeprom_channel ht40_eeprom; /* EEPROM regulatory limit for + * HT40 channel */ + + u8 channel; /* channel number */ + u8 flags; /* flags copied from EEPROM */ + s8 max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */ + s8 curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) limit */ + s8 min_power; /* always 0 */ + s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */ + + u8 group_idx; /* 0-4, maps channel to group1/2/3/4/5 */ + u8 band_idx; /* 0-4, maps channel to band1/2/3/4/5 */ + enum ieee80211_band band; + + /* HT40 channel info */ + s8 ht40_max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */ + u8 ht40_flags; /* flags copied from EEPROM */ + u8 ht40_extension_channel; /* HT_IE_EXT_CHANNEL_* */ + + /* Radio/DSP gain settings for each "normal" data Tx rate. + * These include, in addition to RF and DSP gain, a few fields for + * remembering/modifying gain settings (idxes). */ + struct il3945_channel_power_info power_info[IL4965_MAX_RATE]; + + /* Radio/DSP gain settings for each scan rate, for directed scans. */ + struct il3945_scan_power_info scan_pwr_info[IL_NUM_SCAN_RATES]; +}; + +#define IL_TX_FIFO_BK 0 /* shared */ +#define IL_TX_FIFO_BE 1 +#define IL_TX_FIFO_VI 2 /* shared */ +#define IL_TX_FIFO_VO 3 +#define IL_TX_FIFO_UNUSED -1 + +/* Minimum number of queues. MAX_NUM is defined in hw specific files. + * Set the minimum to accommodate the 4 standard TX queues, 1 command + * queue, 2 (unused) HCCA queues, and 4 HT queues (one for each AC) */ +#define IL_MIN_NUM_QUEUES 10 + +#define IL_DEFAULT_CMD_QUEUE_NUM 4 + +#define IEEE80211_DATA_LEN 2304 +#define IEEE80211_4ADDR_LEN 30 +#define IEEE80211_HLEN (IEEE80211_4ADDR_LEN) +#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) + +struct il_frame { + union { + struct ieee80211_hdr frame; + struct il_tx_beacon_cmd beacon; + u8 raw[IEEE80211_FRAME_LEN]; + u8 cmd[360]; + } u; + struct list_head list; +}; + +#define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) +#define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ) +#define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4) + +enum { + CMD_SYNC = 0, + CMD_SIZE_NORMAL = 0, + CMD_NO_SKB = 0, + CMD_SIZE_HUGE = (1 << 0), + CMD_ASYNC = (1 << 1), + CMD_WANT_SKB = (1 << 2), + CMD_MAPPED = (1 << 3), +}; + +#define DEF_CMD_PAYLOAD_SIZE 320 + +/** + * struct il_device_cmd + * + * For allocation of the command and tx queues, this establishes the overall + * size of the largest command we send to uCode, except for a scan command + * (which is relatively huge; space is allocated separately). + */ +struct il_device_cmd { + struct il_cmd_header hdr; /* uCode API */ + union { + u32 flags; + u8 val8; + u16 val16; + u32 val32; + struct il_tx_cmd tx; + u8 payload[DEF_CMD_PAYLOAD_SIZE]; + } __packed cmd; +} __packed; + +#define TFD_MAX_PAYLOAD_SIZE (sizeof(struct il_device_cmd)) + + +struct il_host_cmd { + const void *data; + unsigned long reply_page; + void (*callback)(struct il_priv *il, + struct il_device_cmd *cmd, + struct il_rx_pkt *pkt); + u32 flags; + u16 len; + u8 id; +}; + +#define SUP_RATE_11A_MAX_NUM_CHANNELS 8 +#define SUP_RATE_11B_MAX_NUM_CHANNELS 4 +#define SUP_RATE_11G_MAX_NUM_CHANNELS 12 + +/** + * struct il_rx_queue - Rx queue + * @bd: driver's pointer to buffer of receive buffer descriptors (rbd) + * @bd_dma: bus address of buffer of receive buffer descriptors (rbd) + * @read: Shared idx to newest available Rx buffer + * @write: Shared idx to oldest written Rx packet + * @free_count: Number of pre-allocated buffers in rx_free + * @rx_free: list of free SKBs for use + * @rx_used: List of Rx buffers with no SKB + * @need_update: flag to indicate we need to update read/write idx + * @rb_stts: driver's pointer to receive buffer status + * @rb_stts_dma: bus address of receive buffer status + * + * NOTE: rx_free and rx_used are used as a FIFO for il_rx_bufs + */ +struct il_rx_queue { + __le32 *bd; + dma_addr_t bd_dma; + struct il_rx_buf pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS]; + struct il_rx_buf *queue[RX_QUEUE_SIZE]; + u32 read; + u32 write; + u32 free_count; + u32 write_actual; + struct list_head rx_free; + struct list_head rx_used; + int need_update; + struct il_rb_status *rb_stts; + dma_addr_t rb_stts_dma; + spinlock_t lock; +}; + +#define IL_SUPPORTED_RATES_IE_LEN 8 + +#define MAX_TID_COUNT 9 + +#define IL_INVALID_RATE 0xFF +#define IL_INVALID_VALUE -1 + +/** + * struct il_ht_agg -- aggregation status while waiting for block-ack + * @txq_id: Tx queue used for Tx attempt + * @frame_count: # frames attempted by Tx command + * @wait_for_ba: Expect block-ack before next Tx reply + * @start_idx: Index of 1st Transmit Frame Descriptor (TFD) in Tx win + * @bitmap0: Low order bitmap, one bit for each frame pending ACK in Tx win + * @bitmap1: High order, one bit for each frame pending ACK in Tx win + * @rate_n_flags: Rate at which Tx was attempted + * + * If C_TX indicates that aggregation was attempted, driver must wait + * for block ack (N_COMPRESSED_BA). This struct stores tx reply info + * until block ack arrives. + */ +struct il_ht_agg { + u16 txq_id; + u16 frame_count; + u16 wait_for_ba; + u16 start_idx; + u64 bitmap; + u32 rate_n_flags; +#define IL_AGG_OFF 0 +#define IL_AGG_ON 1 +#define IL_EMPTYING_HW_QUEUE_ADDBA 2 +#define IL_EMPTYING_HW_QUEUE_DELBA 3 + u8 state; +}; + + +struct il_tid_data { + u16 seq_number; /* 4965 only */ + u16 tfds_in_queue; + struct il_ht_agg agg; +}; + +struct il_hw_key { + u32 cipher; + int keylen; + u8 keyidx; + u8 key[32]; +}; + +union il_ht_rate_supp { + u16 rates; + struct { + u8 siso_rate; + u8 mimo_rate; + }; +}; + +#define CFG_HT_RX_AMPDU_FACTOR_8K (0x0) +#define CFG_HT_RX_AMPDU_FACTOR_16K (0x1) +#define CFG_HT_RX_AMPDU_FACTOR_32K (0x2) +#define CFG_HT_RX_AMPDU_FACTOR_64K (0x3) +#define CFG_HT_RX_AMPDU_FACTOR_DEF CFG_HT_RX_AMPDU_FACTOR_64K +#define CFG_HT_RX_AMPDU_FACTOR_MAX CFG_HT_RX_AMPDU_FACTOR_64K +#define CFG_HT_RX_AMPDU_FACTOR_MIN CFG_HT_RX_AMPDU_FACTOR_8K + +/* + * Maximal MPDU density for TX aggregation + * 4 - 2us density + * 5 - 4us density + * 6 - 8us density + * 7 - 16us density + */ +#define CFG_HT_MPDU_DENSITY_2USEC (0x4) +#define CFG_HT_MPDU_DENSITY_4USEC (0x5) +#define CFG_HT_MPDU_DENSITY_8USEC (0x6) +#define CFG_HT_MPDU_DENSITY_16USEC (0x7) +#define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_4USEC +#define CFG_HT_MPDU_DENSITY_MAX CFG_HT_MPDU_DENSITY_16USEC +#define CFG_HT_MPDU_DENSITY_MIN (0x1) + +struct il_ht_config { + bool single_chain_sufficient; + enum ieee80211_smps_mode smps; /* current smps mode */ +}; + +/* QoS structures */ +struct il_qos_info { + int qos_active; + struct il_qosparam_cmd def_qos_parm; +}; + +/* + * Structure should be accessed with sta_lock held. When station addition + * is in progress (IL_STA_UCODE_INPROGRESS) it is possible to access only + * the commands (il_addsta_cmd and il_link_quality_cmd) without + * sta_lock held. + */ +struct il_station_entry { + struct il_addsta_cmd sta; + struct il_tid_data tid[MAX_TID_COUNT]; + u8 used, ctxid; + struct il_hw_key keyinfo; + struct il_link_quality_cmd *lq; +}; + +struct il_station_priv_common { + struct il_rxon_context *ctx; + u8 sta_id; +}; + +/* + * il_station_priv: Driver's ilate station information + * + * When mac80211 creates a station it reserves some space (hw->sta_data_size) + * in the structure for use by driver. This structure is places in that + * space. + * + * The common struct MUST be first because it is shared between + * 3945 and 4965! + */ +struct il_station_priv { + struct il_station_priv_common common; + struct il_lq_sta lq_sta; + atomic_t pending_frames; + bool client; + bool asleep; +}; + +/** + * struct il_vif_priv - driver's ilate per-interface information + * + * When mac80211 allocates a virtual interface, it can allocate + * space for us to put data into. + */ +struct il_vif_priv { + struct il_rxon_context *ctx; + u8 ibss_bssid_sta_id; +}; + +/* one for each uCode image (inst/data, boot/init/runtime) */ +struct fw_desc { + void *v_addr; /* access by driver */ + dma_addr_t p_addr; /* access by card's busmaster DMA */ + u32 len; /* bytes */ +}; + +/* uCode file layout */ +struct il_ucode_header { + __le32 ver; /* major/minor/API/serial */ + struct { + __le32 inst_size; /* bytes of runtime code */ + __le32 data_size; /* bytes of runtime data */ + __le32 init_size; /* bytes of init code */ + __le32 init_data_size; /* bytes of init data */ + __le32 boot_size; /* bytes of bootstrap code */ + u8 data[0]; /* in same order as sizes */ + } v1; +}; + +struct il4965_ibss_seq { + u8 mac[ETH_ALEN]; + u16 seq_num; + u16 frag_num; + unsigned long packet_time; + struct list_head list; +}; + +struct il_sensitivity_ranges { + u16 min_nrg_cck; + u16 max_nrg_cck; + + u16 nrg_th_cck; + u16 nrg_th_ofdm; + + u16 auto_corr_min_ofdm; + u16 auto_corr_min_ofdm_mrc; + u16 auto_corr_min_ofdm_x1; + u16 auto_corr_min_ofdm_mrc_x1; + + u16 auto_corr_max_ofdm; + u16 auto_corr_max_ofdm_mrc; + u16 auto_corr_max_ofdm_x1; + u16 auto_corr_max_ofdm_mrc_x1; + + u16 auto_corr_max_cck; + u16 auto_corr_max_cck_mrc; + u16 auto_corr_min_cck; + u16 auto_corr_min_cck_mrc; + + u16 barker_corr_th_min; + u16 barker_corr_th_min_mrc; + u16 nrg_th_cca; +}; + + +#define KELVIN_TO_CELSIUS(x) ((x)-273) +#define CELSIUS_TO_KELVIN(x) ((x)+273) + + +/** + * struct il_hw_params + * @max_txq_num: Max # Tx queues supported + * @dma_chnl_num: Number of Tx DMA/FIFO channels + * @scd_bc_tbls_size: size of scheduler byte count tables + * @tfd_size: TFD size + * @tx/rx_chains_num: Number of TX/RX chains + * @valid_tx/rx_ant: usable antennas + * @max_rxq_size: Max # Rx frames in Rx queue (must be power-of-2) + * @max_rxq_log: Log-base-2 of max_rxq_size + * @rx_page_order: Rx buffer page order + * @rx_wrt_ptr_reg: FH{39}_RSCSR_CHNL0_WPTR + * @max_stations: + * @ht40_channel: is 40MHz width possible in band 2.4 + * BIT(IEEE80211_BAND_5GHZ) BIT(IEEE80211_BAND_5GHZ) + * @sw_crypto: 0 for hw, 1 for sw + * @max_xxx_size: for ucode uses + * @ct_kill_threshold: temperature threshold + * @beacon_time_tsf_bits: number of valid tsf bits for beacon time + * @struct il_sensitivity_ranges: range of sensitivity values + */ +struct il_hw_params { + u8 max_txq_num; + u8 dma_chnl_num; + u16 scd_bc_tbls_size; + u32 tfd_size; + u8 tx_chains_num; + u8 rx_chains_num; + u8 valid_tx_ant; + u8 valid_rx_ant; + u16 max_rxq_size; + u16 max_rxq_log; + u32 rx_page_order; + u32 rx_wrt_ptr_reg; + u8 max_stations; + u8 ht40_channel; + u8 max_beacon_itrvl; /* in 1024 ms */ + u32 max_inst_size; + u32 max_data_size; + u32 max_bsm_size; + u32 ct_kill_threshold; /* value in hw-dependent units */ + u16 beacon_time_tsf_bits; + const struct il_sensitivity_ranges *sens; +}; + + +/****************************************************************************** + * + * Functions implemented in core module which are forward declared here + * for use by iwl-[4-5].c + * + * NOTE: The implementation of these functions are not hardware specific + * which is why they are in the core module files. + * + * Naming convention -- + * il_ <-- Is part of iwlwifi + * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX) + * il4965_bg_ <-- Called from work queue context + * il4965_mac_ <-- mac80211 callback + * + ****************************************************************************/ +extern void il4965_update_chain_flags(struct il_priv *il); +extern const u8 il_bcast_addr[ETH_ALEN]; +extern int il_queue_space(const struct il_queue *q); +static inline int il_queue_used(const struct il_queue *q, int i) +{ + return q->write_ptr >= q->read_ptr ? + (i >= q->read_ptr && i < q->write_ptr) : + !(i < q->read_ptr && i >= q->write_ptr); +} + + +static inline u8 il_get_cmd_idx(struct il_queue *q, u32 idx, + int is_huge) +{ + /* + * This is for init calibration result and scan command which + * required buffer > TFD_MAX_PAYLOAD_SIZE, + * the big buffer at end of command array + */ + if (is_huge) + return q->n_win; /* must be power of 2 */ + + /* Otherwise, use normal size buffers */ + return idx & (q->n_win - 1); +} + + +struct il_dma_ptr { + dma_addr_t dma; + void *addr; + size_t size; +}; + +#define IL_OPERATION_MODE_AUTO 0 +#define IL_OPERATION_MODE_HT_ONLY 1 +#define IL_OPERATION_MODE_MIXED 2 +#define IL_OPERATION_MODE_20MHZ 3 + +#define IL_TX_CRC_SIZE 4 +#define IL_TX_DELIMITER_SIZE 4 + +#define TX_POWER_IL_ILLEGAL_VOLTAGE -10000 + +/* Sensitivity and chain noise calibration */ +#define INITIALIZATION_VALUE 0xFFFF +#define IL4965_CAL_NUM_BEACONS 20 +#define IL_CAL_NUM_BEACONS 16 +#define MAXIMUM_ALLOWED_PATHLOSS 15 + +#define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3 + +#define MAX_FA_OFDM 50 +#define MIN_FA_OFDM 5 +#define MAX_FA_CCK 50 +#define MIN_FA_CCK 5 + +#define AUTO_CORR_STEP_OFDM 1 + +#define AUTO_CORR_STEP_CCK 3 +#define AUTO_CORR_MAX_TH_CCK 160 + +#define NRG_DIFF 2 +#define NRG_STEP_CCK 2 +#define NRG_MARGIN 8 +#define MAX_NUMBER_CCK_NO_FA 100 + +#define AUTO_CORR_CCK_MIN_VAL_DEF (125) + +#define CHAIN_A 0 +#define CHAIN_B 1 +#define CHAIN_C 2 +#define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4 +#define ALL_BAND_FILTER 0xFF00 +#define IN_BAND_FILTER 0xFF +#define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF + +#define NRG_NUM_PREV_STAT_L 20 +#define NUM_RX_CHAINS 3 + +enum il4965_false_alarm_state { + IL_FA_TOO_MANY = 0, + IL_FA_TOO_FEW = 1, + IL_FA_GOOD_RANGE = 2, +}; + +enum il4965_chain_noise_state { + IL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */ + IL_CHAIN_NOISE_ACCUMULATE, + IL_CHAIN_NOISE_CALIBRATED, + IL_CHAIN_NOISE_DONE, +}; + +enum il4965_calib_enabled_state { + IL_CALIB_DISABLED = 0, /* must be 0 */ + IL_CALIB_ENABLED = 1, +}; + +/* + * enum il_calib + * defines the order in which results of initial calibrations + * should be sent to the runtime uCode + */ +enum il_calib { + IL_CALIB_MAX, +}; + +/* Opaque calibration results */ +struct il_calib_result { + void *buf; + size_t buf_len; +}; + +enum ucode_type { + UCODE_NONE = 0, + UCODE_INIT, + UCODE_RT +}; + +/* Sensitivity calib data */ +struct il_sensitivity_data { + u32 auto_corr_ofdm; + u32 auto_corr_ofdm_mrc; + u32 auto_corr_ofdm_x1; + u32 auto_corr_ofdm_mrc_x1; + u32 auto_corr_cck; + u32 auto_corr_cck_mrc; + + u32 last_bad_plcp_cnt_ofdm; + u32 last_fa_cnt_ofdm; + u32 last_bad_plcp_cnt_cck; + u32 last_fa_cnt_cck; + + u32 nrg_curr_state; + u32 nrg_prev_state; + u32 nrg_value[10]; + u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L]; + u32 nrg_silence_ref; + u32 nrg_energy_idx; + u32 nrg_silence_idx; + u32 nrg_th_cck; + s32 nrg_auto_corr_silence_diff; + u32 num_in_cck_no_fa; + u32 nrg_th_ofdm; + + u16 barker_corr_th_min; + u16 barker_corr_th_min_mrc; + u16 nrg_th_cca; +}; + +/* Chain noise (differential Rx gain) calib data */ +struct il_chain_noise_data { + u32 active_chains; + u32 chain_noise_a; + u32 chain_noise_b; + u32 chain_noise_c; + u32 chain_signal_a; + u32 chain_signal_b; + u32 chain_signal_c; + u16 beacon_count; + u8 disconn_array[NUM_RX_CHAINS]; + u8 delta_gain_code[NUM_RX_CHAINS]; + u8 radio_write; + u8 state; +}; + +#define EEPROM_SEM_TIMEOUT 10 /* milliseconds */ +#define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ + +#define IL_TRAFFIC_ENTRIES (256) +#define IL_TRAFFIC_ENTRY_SIZE (64) + +enum { + MEASUREMENT_READY = (1 << 0), + MEASUREMENT_ACTIVE = (1 << 1), +}; + +/* interrupt stats */ +struct isr_stats { + u32 hw; + u32 sw; + u32 err_code; + u32 sch; + u32 alive; + u32 rfkill; + u32 ctkill; + u32 wakeup; + u32 rx; + u32 handlers[IL_CN_MAX]; + u32 tx; + u32 unhandled; +}; + +/* management stats */ +enum il_mgmt_stats { + MANAGEMENT_ASSOC_REQ = 0, + MANAGEMENT_ASSOC_RESP, + MANAGEMENT_REASSOC_REQ, + MANAGEMENT_REASSOC_RESP, + MANAGEMENT_PROBE_REQ, + MANAGEMENT_PROBE_RESP, + MANAGEMENT_BEACON, + MANAGEMENT_ATIM, + MANAGEMENT_DISASSOC, + MANAGEMENT_AUTH, + MANAGEMENT_DEAUTH, + MANAGEMENT_ACTION, + MANAGEMENT_MAX, +}; +/* control stats */ +enum il_ctrl_stats { + CONTROL_BACK_REQ = 0, + CONTROL_BACK, + CONTROL_PSPOLL, + CONTROL_RTS, + CONTROL_CTS, + CONTROL_ACK, + CONTROL_CFEND, + CONTROL_CFENDACK, + CONTROL_MAX, +}; + +struct traffic_stats { +#ifdef CONFIG_IWLEGACY_DEBUGFS + u32 mgmt[MANAGEMENT_MAX]; + u32 ctrl[CONTROL_MAX]; + u32 data_cnt; + u64 data_bytes; +#endif +}; + +/* + * host interrupt timeout value + * used with setting interrupt coalescing timer + * the CSR_INT_COALESCING is an 8 bit register in 32-usec unit + * + * default interrupt coalescing timer is 64 x 32 = 2048 usecs + * default interrupt coalescing calibration timer is 16 x 32 = 512 usecs + */ +#define IL_HOST_INT_TIMEOUT_MAX (0xFF) +#define IL_HOST_INT_TIMEOUT_DEF (0x40) +#define IL_HOST_INT_TIMEOUT_MIN (0x0) +#define IL_HOST_INT_CALIB_TIMEOUT_MAX (0xFF) +#define IL_HOST_INT_CALIB_TIMEOUT_DEF (0x10) +#define IL_HOST_INT_CALIB_TIMEOUT_MIN (0x0) + +#define IL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5) + +/* TX queue watchdog timeouts in mSecs */ +#define IL_DEF_WD_TIMEOUT (2000) +#define IL_LONG_WD_TIMEOUT (10000) +#define IL_MAX_WD_TIMEOUT (120000) + +struct il_force_reset { + int reset_request_count; + int reset_success_count; + int reset_reject_count; + unsigned long reset_duration; + unsigned long last_force_reset_jiffies; +}; + +/* extend beacon time format bit shifting */ +/* + * for _3945 devices + * bits 31:24 - extended + * bits 23:0 - interval + */ +#define IL3945_EXT_BEACON_TIME_POS 24 +/* + * for _4965 devices + * bits 31:22 - extended + * bits 21:0 - interval + */ +#define IL4965_EXT_BEACON_TIME_POS 22 + +struct il_rxon_context { + struct ieee80211_vif *vif; + + const u8 *ac_to_fifo; + const u8 *ac_to_queue; + u8 mcast_queue; + + /* + * We could use the vif to indicate active, but we + * also need it to be active during disabling when + * we already removed the vif for type setting. + */ + bool always_active, is_active; + + bool ht_need_multiple_chains; + + int ctxid; + + u32 interface_modes, exclusive_interface_modes; + u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype; + + /* + * We declare this const so it can only be + * changed via explicit cast within the + * routines that actually update the physical + * hardware. + */ + const struct il_rxon_cmd active; + struct il_rxon_cmd staging; + + struct il_rxon_time_cmd timing; + + struct il_qos_info qos_data; + + u8 bcast_sta_id, ap_sta_id; + + u8 rxon_cmd, rxon_assoc_cmd, rxon_timing_cmd; + u8 qos_cmd; + u8 wep_key_cmd; + + struct il_wep_key wep_keys[WEP_KEYS_MAX]; + u8 key_mapping_keys; + + __le32 station_flags; + + struct { + bool non_gf_sta_present; + u8 protection; + bool enabled, is_40mhz; + u8 extension_chan_offset; + } ht; +}; + +struct il_priv { + + /* ieee device used by generic ieee processing code */ + struct ieee80211_hw *hw; + struct ieee80211_channel *ieee_channels; + struct ieee80211_rate *ieee_rates; + struct il_cfg *cfg; + + /* temporary frame storage list */ + struct list_head free_frames; + int frames_count; + + enum ieee80211_band band; + int alloc_rxb_page; + + void (*handlers[IL_CN_MAX])(struct il_priv *il, + struct il_rx_buf *rxb); + + struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; + + /* spectrum measurement report caching */ + struct il_spectrum_notification measure_report; + u8 measurement_status; + + /* ucode beacon time */ + u32 ucode_beacon_time; + int missed_beacon_threshold; + + /* track IBSS manager (last beacon) status */ + u32 ibss_manager; + + /* force reset */ + struct il_force_reset force_reset; + + /* we allocate array of il_channel_info for NIC's valid channels. + * Access via channel # using indirect idx array */ + struct il_channel_info *channel_info; /* channel info array */ + u8 channel_count; /* # of channels */ + + /* thermal calibration */ + s32 temperature; /* degrees Kelvin */ + s32 last_temperature; + + /* init calibration results */ + struct il_calib_result calib_results[IL_CALIB_MAX]; + + /* Scan related variables */ + unsigned long scan_start; + unsigned long scan_start_tsf; + void *scan_cmd; + enum ieee80211_band scan_band; + struct cfg80211_scan_request *scan_request; + struct ieee80211_vif *scan_vif; + u8 scan_tx_ant[IEEE80211_NUM_BANDS]; + u8 mgmt_tx_ant; + + /* spinlock */ + spinlock_t lock; /* protect general shared data */ + spinlock_t hcmd_lock; /* protect hcmd */ + spinlock_t reg_lock; /* protect hw register access */ + struct mutex mutex; + + /* basic pci-network driver stuff */ + struct pci_dev *pci_dev; + + /* pci hardware address support */ + void __iomem *hw_base; + u32 hw_rev; + u32 hw_wa_rev; + u8 rev_id; + + /* command queue number */ + u8 cmd_queue; + + /* max number of station keys */ + u8 sta_key_max_num; + + /* EEPROM MAC addresses */ + struct mac_address addresses[1]; + + /* uCode images, save to reload in case of failure */ + int fw_idx; /* firmware we're trying to load */ + u32 ucode_ver; /* version of ucode, copy of + il_ucode.ver */ + struct fw_desc ucode_code; /* runtime inst */ + struct fw_desc ucode_data; /* runtime data original */ + struct fw_desc ucode_data_backup; /* runtime data save/restore */ + struct fw_desc ucode_init; /* initialization inst */ + struct fw_desc ucode_init_data; /* initialization data */ + struct fw_desc ucode_boot; /* bootstrap inst */ + enum ucode_type ucode_type; + u8 ucode_write_complete; /* the image write is complete */ + char firmware_name[25]; + + struct il_rxon_context ctx; + + __le16 switch_channel; + + /* 1st responses from initialize and runtime uCode images. + * _4965's initialize alive response contains some calibration data. */ + struct il_init_alive_resp card_alive_init; + struct il_alive_resp card_alive; + + u16 active_rate; + + u8 start_calib; + struct il_sensitivity_data sensitivity_data; + struct il_chain_noise_data chain_noise_data; + __le16 sensitivity_tbl[HD_TBL_SIZE]; + + struct il_ht_config current_ht_config; + + /* Rate scaling data */ + u8 retry_rate; + + wait_queue_head_t wait_command_queue; + + int activity_timer_active; + + /* Rx and Tx DMA processing queues */ + struct il_rx_queue rxq; + struct il_tx_queue *txq; + unsigned long txq_ctx_active_msk; + struct il_dma_ptr kw; /* keep warm address */ + struct il_dma_ptr scd_bc_tbls; + + u32 scd_base_addr; /* scheduler sram base address */ + + unsigned long status; + + /* counts mgmt, ctl, and data packets */ + struct traffic_stats tx_stats; + struct traffic_stats rx_stats; + + /* counts interrupts */ + struct isr_stats isr_stats; + + struct il_power_mgr power_data; + + /* context information */ + u8 bssid[ETH_ALEN]; /* used only on 3945 but filled by core */ + + /* station table variables */ + + /* Note: if lock and sta_lock are needed, lock must be acquired first */ + spinlock_t sta_lock; + int num_stations; + struct il_station_entry stations[IL_STATION_COUNT]; + unsigned long ucode_key_table; + + /* queue refcounts */ +#define IL_MAX_HW_QUEUES 32 + unsigned long queue_stopped[BITS_TO_LONGS(IL_MAX_HW_QUEUES)]; + /* for each AC */ + atomic_t queue_stop_count[4]; + + /* Indication if ieee80211_ops->open has been called */ + u8 is_open; + + u8 mac80211_registered; + + /* eeprom -- this is in the card's little endian byte order */ + u8 *eeprom; + struct il_eeprom_calib_info *calib_info; + + enum nl80211_iftype iw_mode; + + /* Last Rx'd beacon timestamp */ + u64 timestamp; + + union { +#if defined(CONFIG_IWL3945) || defined(CONFIG_IWL3945_MODULE) + struct { + void *shared_virt; + dma_addr_t shared_phys; + + struct delayed_work thermal_periodic; + struct delayed_work rfkill_poll; + + struct il3945_notif_stats stats; +#ifdef CONFIG_IWLEGACY_DEBUGFS + struct il3945_notif_stats accum_stats; + struct il3945_notif_stats delta_stats; + struct il3945_notif_stats max_delta; +#endif + + u32 sta_supp_rates; + int last_rx_rssi; /* From Rx packet stats */ + + /* Rx'd packet timing information */ + u32 last_beacon_time; + u64 last_tsf; + + /* + * each calibration channel group in the + * EEPROM has a derived clip setting for + * each rate. + */ + const struct il3945_clip_group clip_groups[5]; + + } _3945; +#endif +#if defined(CONFIG_IWL4965) || defined(CONFIG_IWL4965_MODULE) + struct { + struct il_rx_phy_res last_phy_res; + bool last_phy_res_valid; + + struct completion firmware_loading_complete; + + /* + * chain noise reset and gain commands are the + * two extra calibration commands follows the standard + * phy calibration commands + */ + u8 phy_calib_chain_noise_reset_cmd; + u8 phy_calib_chain_noise_gain_cmd; + + struct il_notif_stats stats; +#ifdef CONFIG_IWLEGACY_DEBUGFS + struct il_notif_stats accum_stats; + struct il_notif_stats delta_stats; + struct il_notif_stats max_delta; +#endif + + } _4965; +#endif + }; + + struct il_hw_params hw_params; + + u32 inta_mask; + + struct workqueue_struct *workqueue; + + struct work_struct restart; + struct work_struct scan_completed; + struct work_struct rx_replenish; + struct work_struct abort_scan; + + struct il_rxon_context *beacon_ctx; + struct sk_buff *beacon_skb; + + struct work_struct tx_flush; + + struct tasklet_struct irq_tasklet; + + struct delayed_work init_alive_start; + struct delayed_work alive_start; + struct delayed_work scan_check; + + /* TX Power */ + s8 tx_power_user_lmt; + s8 tx_power_device_lmt; + s8 tx_power_next; + + +#ifdef CONFIG_IWLEGACY_DEBUG + /* debugging info */ + u32 debug_level; /* per device debugging will override global + il_debug_level if set */ +#endif /* CONFIG_IWLEGACY_DEBUG */ +#ifdef CONFIG_IWLEGACY_DEBUGFS + /* debugfs */ + u16 tx_traffic_idx; + u16 rx_traffic_idx; + u8 *tx_traffic; + u8 *rx_traffic; + struct dentry *debugfs_dir; + u32 dbgfs_sram_offset, dbgfs_sram_len; + bool disable_ht40; +#endif /* CONFIG_IWLEGACY_DEBUGFS */ + + struct work_struct txpower_work; + u32 disable_sens_cal; + u32 disable_chain_noise_cal; + u32 disable_tx_power_cal; + struct work_struct run_time_calib_work; + struct timer_list stats_periodic; + struct timer_list watchdog; + bool hw_ready; + + struct led_classdev led; + unsigned long blink_on, blink_off; + bool led_registered; +}; /*il_priv */ + +static inline void il_txq_ctx_activate(struct il_priv *il, int txq_id) +{ + set_bit(txq_id, &il->txq_ctx_active_msk); +} + +static inline void il_txq_ctx_deactivate(struct il_priv *il, int txq_id) +{ + clear_bit(txq_id, &il->txq_ctx_active_msk); +} + +#ifdef CONFIG_IWLEGACY_DEBUG +/* + * il_get_debug_level: Return active debug level for device + * + * Using sysfs it is possible to set per device debug level. This debug + * level will be used if set, otherwise the global debug level which can be + * set via module parameter is used. + */ +static inline u32 il_get_debug_level(struct il_priv *il) +{ + if (il->debug_level) + return il->debug_level; + else + return il_debug_level; +} +#else +static inline u32 il_get_debug_level(struct il_priv *il) +{ + return il_debug_level; +} +#endif -#ifndef __il_core_h__ -#define __il_core_h__ -/************************ - * forward declarations * - ************************/ -struct il_host_cmd; -struct il_cmd; +static inline struct ieee80211_hdr * +il_tx_queue_get_hdr(struct il_priv *il, + int txq_id, int idx) +{ + if (il->txq[txq_id].txb[idx].skb) + return (struct ieee80211_hdr *)il->txq[txq_id]. + txb[idx].skb->data; + return NULL; +} + +static inline struct il_rxon_context * +il_rxon_ctx_from_vif(struct ieee80211_vif *vif) +{ + struct il_vif_priv *vif_priv = (void *)vif->drv_priv; + + return vif_priv->ctx; +} + +#define for_each_context(il, _ctx) \ + for (_ctx = &il->ctx; _ctx == &il->ctx; _ctx++) + +static inline int il_is_associated(struct il_priv *il) +{ + return (il->ctx.active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; +} + +static inline int il_is_any_associated(struct il_priv *il) +{ + return il_is_associated(il); +} + +static inline int il_is_associated_ctx(struct il_rxon_context *ctx) +{ + return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; +} + +static inline int il_is_channel_valid(const struct il_channel_info *ch_info) +{ + if (ch_info == NULL) + return 0; + return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0; +} + +static inline int il_is_channel_radar(const struct il_channel_info *ch_info) +{ + return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0; +} + +static inline u8 il_is_channel_a_band(const struct il_channel_info *ch_info) +{ + return ch_info->band == IEEE80211_BAND_5GHZ; +} + +static inline int +il_is_channel_passive(const struct il_channel_info *ch) +{ + return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0; +} + +static inline int +il_is_channel_ibss(const struct il_channel_info *ch) +{ + return (ch->flags & EEPROM_CHANNEL_IBSS) ? 1 : 0; +} +static inline void +__il_free_pages(struct il_priv *il, struct page *page) +{ + __free_pages(page, il->hw_params.rx_page_order); + il->alloc_rxb_page--; +} + +static inline void il_free_pages(struct il_priv *il, unsigned long page) +{ + free_pages(page, il->hw_params.rx_page_order); + il->alloc_rxb_page--; +} #define IWLWIFI_VERSION "in-tree:" #define DRV_COPYRIGHT "Copyright(c) 2003-2011 Intel Corporation" @@ -87,6 +1371,11 @@ struct il_cmd; #define IL_CMD(x) case x: return #x +/* Size of one Rx buffer in host DRAM */ +#define IL_RX_BUF_SIZE_3K (3 * 1000) /* 3945 only */ +#define IL_RX_BUF_SIZE_4K (4 * 1024) +#define IL_RX_BUF_SIZE_8K (8 * 1024) + struct il_hcmd_ops { int (*rxon_assoc)(struct il_priv *il, struct il_rxon_context *ctx); int (*commit_rxon)(struct il_priv *il, struct il_rxon_context *ctx); @@ -633,4 +1922,655 @@ void il_tx_cmd_protection(struct il_priv *il, irqreturn_t il_isr(int irq, void *data); + +#include + +static inline void _il_write8(struct il_priv *il, u32 ofs, u8 val) +{ + iowrite8(val, il->hw_base + ofs); +} +#define il_write8(il, ofs, val) _il_write8(il, ofs, val) + +static inline void _il_wr(struct il_priv *il, u32 ofs, u32 val) +{ + iowrite32(val, il->hw_base + ofs); +} + +static inline u32 _il_rd(struct il_priv *il, u32 ofs) +{ + return ioread32(il->hw_base + ofs); +} + +#define IL_POLL_INTERVAL 10 /* microseconds */ +static inline int +_il_poll_bit(struct il_priv *il, u32 addr, + u32 bits, u32 mask, int timeout) +{ + int t = 0; + + do { + if ((_il_rd(il, addr) & mask) == (bits & mask)) + return t; + udelay(IL_POLL_INTERVAL); + t += IL_POLL_INTERVAL; + } while (t < timeout); + + return -ETIMEDOUT; +} + +static inline void _il_set_bit(struct il_priv *il, u32 reg, u32 mask) +{ + _il_wr(il, reg, _il_rd(il, reg) | mask); +} + +static inline void il_set_bit(struct il_priv *p, u32 r, u32 m) +{ + unsigned long reg_flags; + + spin_lock_irqsave(&p->reg_lock, reg_flags); + _il_set_bit(p, r, m); + spin_unlock_irqrestore(&p->reg_lock, reg_flags); +} + +static inline void +_il_clear_bit(struct il_priv *il, u32 reg, u32 mask) +{ + _il_wr(il, reg, _il_rd(il, reg) & ~mask); +} + +static inline void il_clear_bit(struct il_priv *p, u32 r, u32 m) +{ + unsigned long reg_flags; + + spin_lock_irqsave(&p->reg_lock, reg_flags); + _il_clear_bit(p, r, m); + spin_unlock_irqrestore(&p->reg_lock, reg_flags); +} + +static inline int _il_grab_nic_access(struct il_priv *il) +{ + int ret; + u32 val; + + /* this bit wakes up the NIC */ + _il_set_bit(il, CSR_GP_CNTRL, + CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); + + /* + * These bits say the device is running, and should keep running for + * at least a short while (at least as long as MAC_ACCESS_REQ stays 1), + * but they do not indicate that embedded SRAM is restored yet; + * 3945 and 4965 have volatile SRAM, and must save/restore contents + * to/from host DRAM when sleeping/waking for power-saving. + * Each direction takes approximately 1/4 millisecond; with this + * overhead, it's a good idea to grab and hold MAC_ACCESS_REQUEST if a + * series of register accesses are expected (e.g. reading Event Log), + * to keep device from sleeping. + * + * CSR_UCODE_DRV_GP1 register bit MAC_SLEEP == 0 indicates that + * SRAM is okay/restored. We don't check that here because this call + * is just for hardware register access; but GP1 MAC_SLEEP check is a + * good idea before accessing 3945/4965 SRAM (e.g. reading Event Log). + * + */ + ret = _il_poll_bit(il, CSR_GP_CNTRL, + CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN, + (CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY | + CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 15000); + if (ret < 0) { + val = _il_rd(il, CSR_GP_CNTRL); + IL_ERR( + "MAC is in deep sleep!. CSR_GP_CNTRL = 0x%08X\n", val); + _il_wr(il, CSR_RESET, + CSR_RESET_REG_FLAG_FORCE_NMI); + return -EIO; + } + + return 0; +} + +static inline void _il_release_nic_access(struct il_priv *il) +{ + _il_clear_bit(il, CSR_GP_CNTRL, + CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); +} + +static inline u32 il_rd(struct il_priv *il, u32 reg) +{ + u32 value; + unsigned long reg_flags; + + spin_lock_irqsave(&il->reg_lock, reg_flags); + _il_grab_nic_access(il); + value = _il_rd(il, reg); + _il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); + return value; + +} + +static inline void +il_wr(struct il_priv *il, u32 reg, u32 value) +{ + unsigned long reg_flags; + + spin_lock_irqsave(&il->reg_lock, reg_flags); + if (!_il_grab_nic_access(il)) { + _il_wr(il, reg, value); + _il_release_nic_access(il); + } + spin_unlock_irqrestore(&il->reg_lock, reg_flags); +} + +static inline void il_write_reg_buf(struct il_priv *il, + u32 reg, u32 len, u32 *values) +{ + u32 count = sizeof(u32); + + if (il != NULL && values != NULL) { + for (; 0 < len; len -= count, reg += count, values++) + il_wr(il, reg, *values); + } +} + +static inline int il_poll_bit(struct il_priv *il, u32 addr, + u32 mask, int timeout) +{ + int t = 0; + + do { + if ((il_rd(il, addr) & mask) == mask) + return t; + udelay(IL_POLL_INTERVAL); + t += IL_POLL_INTERVAL; + } while (t < timeout); + + return -ETIMEDOUT; +} + +static inline u32 _il_rd_prph(struct il_priv *il, u32 reg) +{ + _il_wr(il, HBUS_TARG_PRPH_RADDR, reg | (3 << 24)); + rmb(); + return _il_rd(il, HBUS_TARG_PRPH_RDAT); +} + +static inline u32 il_rd_prph(struct il_priv *il, u32 reg) +{ + unsigned long reg_flags; + u32 val; + + spin_lock_irqsave(&il->reg_lock, reg_flags); + _il_grab_nic_access(il); + val = _il_rd_prph(il, reg); + _il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); + return val; +} + +static inline void _il_wr_prph(struct il_priv *il, + u32 addr, u32 val) +{ + _il_wr(il, HBUS_TARG_PRPH_WADDR, + ((addr & 0x0000FFFF) | (3 << 24))); + wmb(); + _il_wr(il, HBUS_TARG_PRPH_WDAT, val); +} + +static inline void +il_wr_prph(struct il_priv *il, u32 addr, u32 val) +{ + unsigned long reg_flags; + + spin_lock_irqsave(&il->reg_lock, reg_flags); + if (!_il_grab_nic_access(il)) { + _il_wr_prph(il, addr, val); + _il_release_nic_access(il); + } + spin_unlock_irqrestore(&il->reg_lock, reg_flags); +} + +#define _il_set_bits_prph(il, reg, mask) \ +_il_wr_prph(il, reg, (_il_rd_prph(il, reg) | mask)) + +static inline void +il_set_bits_prph(struct il_priv *il, u32 reg, u32 mask) +{ + unsigned long reg_flags; + + spin_lock_irqsave(&il->reg_lock, reg_flags); + _il_grab_nic_access(il); + _il_set_bits_prph(il, reg, mask); + _il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); +} + +#define _il_set_bits_mask_prph(il, reg, bits, mask) \ +_il_wr_prph(il, reg, \ + ((_il_rd_prph(il, reg) & mask) | bits)) + +static inline void il_set_bits_mask_prph(struct il_priv *il, u32 reg, + u32 bits, u32 mask) +{ + unsigned long reg_flags; + + spin_lock_irqsave(&il->reg_lock, reg_flags); + _il_grab_nic_access(il); + _il_set_bits_mask_prph(il, reg, bits, mask); + _il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); +} + +static inline void il_clear_bits_prph(struct il_priv + *il, u32 reg, u32 mask) +{ + unsigned long reg_flags; + u32 val; + + spin_lock_irqsave(&il->reg_lock, reg_flags); + _il_grab_nic_access(il); + val = _il_rd_prph(il, reg); + _il_wr_prph(il, reg, (val & ~mask)); + _il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); +} + +static inline u32 il_read_targ_mem(struct il_priv *il, u32 addr) +{ + unsigned long reg_flags; + u32 value; + + spin_lock_irqsave(&il->reg_lock, reg_flags); + _il_grab_nic_access(il); + + _il_wr(il, HBUS_TARG_MEM_RADDR, addr); + rmb(); + value = _il_rd(il, HBUS_TARG_MEM_RDAT); + + _il_release_nic_access(il); + spin_unlock_irqrestore(&il->reg_lock, reg_flags); + return value; +} + +static inline void +il_write_targ_mem(struct il_priv *il, u32 addr, u32 val) +{ + unsigned long reg_flags; + + spin_lock_irqsave(&il->reg_lock, reg_flags); + if (!_il_grab_nic_access(il)) { + _il_wr(il, HBUS_TARG_MEM_WADDR, addr); + wmb(); + _il_wr(il, HBUS_TARG_MEM_WDAT, val); + _il_release_nic_access(il); + } + spin_unlock_irqrestore(&il->reg_lock, reg_flags); +} + +static inline void +il_write_targ_mem_buf(struct il_priv *il, u32 addr, + u32 len, u32 *values) +{ + unsigned long reg_flags; + + spin_lock_irqsave(&il->reg_lock, reg_flags); + if (!_il_grab_nic_access(il)) { + _il_wr(il, HBUS_TARG_MEM_WADDR, addr); + wmb(); + for (; 0 < len; len -= sizeof(u32), values++) + _il_wr(il, + HBUS_TARG_MEM_WDAT, *values); + + _il_release_nic_access(il); + } + spin_unlock_irqrestore(&il->reg_lock, reg_flags); +} + +#define HW_KEY_DYNAMIC 0 +#define HW_KEY_DEFAULT 1 + +#define IL_STA_DRIVER_ACTIVE BIT(0) /* driver entry is active */ +#define IL_STA_UCODE_ACTIVE BIT(1) /* ucode entry is active */ +#define IL_STA_UCODE_INPROGRESS BIT(2) /* ucode entry is in process of + being activated */ +#define IL_STA_LOCAL BIT(3) /* station state not directed by mac80211; + (this is for the IBSS BSSID stations) */ +#define IL_STA_BCAST BIT(4) /* this station is the special bcast station */ + + +void il_restore_stations(struct il_priv *il, + struct il_rxon_context *ctx); +void il_clear_ucode_stations(struct il_priv *il, + struct il_rxon_context *ctx); +void il_dealloc_bcast_stations(struct il_priv *il); +int il_get_free_ucode_key_idx(struct il_priv *il); +int il_send_add_sta(struct il_priv *il, + struct il_addsta_cmd *sta, u8 flags); +int il_add_station_common(struct il_priv *il, + struct il_rxon_context *ctx, + const u8 *addr, bool is_ap, + struct ieee80211_sta *sta, u8 *sta_id_r); +int il_remove_station(struct il_priv *il, + const u8 sta_id, + const u8 *addr); +int il_mac_sta_remove(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta); + +u8 il_prep_station(struct il_priv *il, + struct il_rxon_context *ctx, + const u8 *addr, bool is_ap, + struct ieee80211_sta *sta); + +int il_send_lq_cmd(struct il_priv *il, + struct il_rxon_context *ctx, + struct il_link_quality_cmd *lq, + u8 flags, bool init); + +/** + * il_clear_driver_stations - clear knowledge of all stations from driver + * @il: iwl il struct + * + * This is called during il_down() to make sure that in the case + * we're coming there from a hardware restart mac80211 will be + * able to reconfigure stations -- if we're getting there in the + * normal down flow then the stations will already be cleared. + */ +static inline void il_clear_driver_stations(struct il_priv *il) +{ + unsigned long flags; + struct il_rxon_context *ctx = &il->ctx; + + spin_lock_irqsave(&il->sta_lock, flags); + memset(il->stations, 0, sizeof(il->stations)); + il->num_stations = 0; + + il->ucode_key_table = 0; + + /* + * Remove all key information that is not stored as part + * of station information since mac80211 may not have had + * a chance to remove all the keys. When device is + * reconfigured by mac80211 after an error all keys will + * be reconfigured. + */ + memset(ctx->wep_keys, 0, sizeof(ctx->wep_keys)); + ctx->key_mapping_keys = 0; + + spin_unlock_irqrestore(&il->sta_lock, flags); +} + +static inline int il_sta_id(struct ieee80211_sta *sta) +{ + if (WARN_ON(!sta)) + return IL_INVALID_STATION; + + return ((struct il_station_priv_common *)sta->drv_priv)->sta_id; +} + +/** + * il_sta_id_or_broadcast - return sta_id or broadcast sta + * @il: iwl il + * @context: the current context + * @sta: mac80211 station + * + * In certain circumstances mac80211 passes a station pointer + * that may be %NULL, for example during TX or key setup. In + * that case, we need to use the broadcast station, so this + * inline wraps that pattern. + */ +static inline int il_sta_id_or_broadcast(struct il_priv *il, + struct il_rxon_context *context, + struct ieee80211_sta *sta) +{ + int sta_id; + + if (!sta) + return context->bcast_sta_id; + + sta_id = il_sta_id(sta); + + /* + * mac80211 should not be passing a partially + * initialised station! + */ + WARN_ON(sta_id == IL_INVALID_STATION); + + return sta_id; +} + +/** + * il_queue_inc_wrap - increment queue idx, wrap back to beginning + * @idx -- current idx + * @n_bd -- total number of entries in queue (must be power of 2) + */ +static inline int il_queue_inc_wrap(int idx, int n_bd) +{ + return ++idx & (n_bd - 1); +} + +/** + * il_queue_dec_wrap - decrement queue idx, wrap back to end + * @idx -- current idx + * @n_bd -- total number of entries in queue (must be power of 2) + */ +static inline int il_queue_dec_wrap(int idx, int n_bd) +{ + return --idx & (n_bd - 1); +} + +/* TODO: Move fw_desc functions to iwl-pci.ko */ +static inline void il_free_fw_desc(struct pci_dev *pci_dev, + struct fw_desc *desc) +{ + if (desc->v_addr) + dma_free_coherent(&pci_dev->dev, desc->len, + desc->v_addr, desc->p_addr); + desc->v_addr = NULL; + desc->len = 0; +} + +static inline int il_alloc_fw_desc(struct pci_dev *pci_dev, + struct fw_desc *desc) +{ + if (!desc->len) { + desc->v_addr = NULL; + return -EINVAL; + } + + desc->v_addr = dma_alloc_coherent(&pci_dev->dev, desc->len, + &desc->p_addr, GFP_KERNEL); + return (desc->v_addr != NULL) ? 0 : -ENOMEM; +} + +/* + * we have 8 bits used like this: + * + * 7 6 5 4 3 2 1 0 + * | | | | | | | | + * | | | | | | +-+-------- AC queue (0-3) + * | | | | | | + * | +-+-+-+-+------------ HW queue ID + * | + * +---------------------- unused + */ +static inline void +il_set_swq_id(struct il_tx_queue *txq, u8 ac, u8 hwq) +{ + BUG_ON(ac > 3); /* only have 2 bits */ + BUG_ON(hwq > 31); /* only use 5 bits */ + + txq->swq_id = (hwq << 2) | ac; +} + +static inline void il_wake_queue(struct il_priv *il, + struct il_tx_queue *txq) +{ + u8 queue = txq->swq_id; + u8 ac = queue & 3; + u8 hwq = (queue >> 2) & 0x1f; + + if (test_and_clear_bit(hwq, il->queue_stopped)) + if (atomic_dec_return(&il->queue_stop_count[ac]) <= 0) + ieee80211_wake_queue(il->hw, ac); +} + +static inline void il_stop_queue(struct il_priv *il, + struct il_tx_queue *txq) +{ + u8 queue = txq->swq_id; + u8 ac = queue & 3; + u8 hwq = (queue >> 2) & 0x1f; + + if (!test_and_set_bit(hwq, il->queue_stopped)) + if (atomic_inc_return(&il->queue_stop_count[ac]) > 0) + ieee80211_stop_queue(il->hw, ac); +} + +#ifdef ieee80211_stop_queue +#undef ieee80211_stop_queue +#endif + +#define ieee80211_stop_queue DO_NOT_USE_ieee80211_stop_queue + +#ifdef ieee80211_wake_queue +#undef ieee80211_wake_queue +#endif + +#define ieee80211_wake_queue DO_NOT_USE_ieee80211_wake_queue + +static inline void il_disable_interrupts(struct il_priv *il) +{ + clear_bit(S_INT_ENABLED, &il->status); + + /* disable interrupts from uCode/NIC to host */ + _il_wr(il, CSR_INT_MASK, 0x00000000); + + /* acknowledge/clear/reset any interrupts still pending + * from uCode or flow handler (Rx/Tx DMA) */ + _il_wr(il, CSR_INT, 0xffffffff); + _il_wr(il, CSR_FH_INT_STATUS, 0xffffffff); + D_ISR("Disabled interrupts\n"); +} + +static inline void il_enable_rfkill_int(struct il_priv *il) +{ + D_ISR("Enabling rfkill interrupt\n"); + _il_wr(il, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); +} + +static inline void il_enable_interrupts(struct il_priv *il) +{ + D_ISR("Enabling interrupts\n"); + set_bit(S_INT_ENABLED, &il->status); + _il_wr(il, CSR_INT_MASK, il->inta_mask); +} + +/** + * il_beacon_time_mask_low - mask of lower 32 bit of beacon time + * @il -- pointer to il_priv data structure + * @tsf_bits -- number of bits need to shift for masking) + */ +static inline u32 il_beacon_time_mask_low(struct il_priv *il, + u16 tsf_bits) +{ + return (1 << tsf_bits) - 1; +} + +/** + * il_beacon_time_mask_high - mask of higher 32 bit of beacon time + * @il -- pointer to il_priv data structure + * @tsf_bits -- number of bits need to shift for masking) + */ +static inline u32 il_beacon_time_mask_high(struct il_priv *il, + u16 tsf_bits) +{ + return ((1 << (32 - tsf_bits)) - 1) << tsf_bits; +} + +/** + * struct il_rb_status - reseve buffer status host memory mapped FH registers + * + * @closed_rb_num [0:11] - Indicates the idx of the RB which was closed + * @closed_fr_num [0:11] - Indicates the idx of the RX Frame which was closed + * @finished_rb_num [0:11] - Indicates the idx of the current RB + * in which the last frame was written to + * @finished_fr_num [0:11] - Indicates the idx of the RX Frame + * which was transferred + */ +struct il_rb_status { + __le16 closed_rb_num; + __le16 closed_fr_num; + __le16 finished_rb_num; + __le16 finished_fr_nam; + __le32 __unused; /* 3945 only */ +} __packed; + + +#define TFD_QUEUE_SIZE_MAX (256) +#define TFD_QUEUE_SIZE_BC_DUP (64) +#define TFD_QUEUE_BC_SIZE (TFD_QUEUE_SIZE_MAX + TFD_QUEUE_SIZE_BC_DUP) +#define IL_TX_DMA_MASK DMA_BIT_MASK(36) +#define IL_NUM_OF_TBS 20 + +static inline u8 il_get_dma_hi_addr(dma_addr_t addr) +{ + return (sizeof(addr) > sizeof(u32) ? (addr >> 16) >> 16 : 0) & 0xF; +} +/** + * struct il_tfd_tb transmit buffer descriptor within transmit frame descriptor + * + * This structure contains dma address and length of transmission address + * + * @lo: low [31:0] portion of the dma address of TX buffer + * every even is unaligned on 16 bit boundary + * @hi_n_len 0-3 [35:32] portion of dma + * 4-15 length of the tx buffer + */ +struct il_tfd_tb { + __le32 lo; + __le16 hi_n_len; +} __packed; + +/** + * struct il_tfd + * + * Transmit Frame Descriptor (TFD) + * + * @ __reserved1[3] reserved + * @ num_tbs 0-4 number of active tbs + * 5 reserved + * 6-7 padding (not used) + * @ tbs[20] transmit frame buffer descriptors + * @ __pad padding + * + * Each Tx queue uses a circular buffer of 256 TFDs stored in host DRAM. + * Both driver and device share these circular buffers, each of which must be + * contiguous 256 TFDs x 128 bytes-per-TFD = 32 KBytes + * + * Driver must indicate the physical address of the base of each + * circular buffer via the FH_MEM_CBBC_QUEUE registers. + * + * Each TFD contains pointer/size information for up to 20 data buffers + * in host DRAM. These buffers collectively contain the (one) frame described + * by the TFD. Each buffer must be a single contiguous block of memory within + * itself, but buffers may be scattered in host DRAM. Each buffer has max size + * of (4K - 4). The concatenates all of a TFD's buffers into a single + * Tx frame, up to 8 KBytes in size. + * + * A maximum of 255 (not 256!) TFDs may be on a queue waiting for Tx. + */ +struct il_tfd { + u8 __reserved1[3]; + u8 num_tbs; + struct il_tfd_tb tbs[IL_NUM_OF_TBS]; + __le32 __pad; +} __packed; +/* PCI registers */ +#define PCI_CFG_RETRY_TIMEOUT 0x041 + +/* PCI register values */ +#define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01 +#define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02 + #endif /* __il_core_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c index 6c4bc5065e5c..62292a68567d 100644 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ b/drivers/net/wireless/iwlegacy/iwl-debugfs.c @@ -29,10 +29,8 @@ #include -#include "iwl-dev.h" #include "iwl-debug.h" #include "common.h" -#include "iwl-io.h" /* create and remove of files */ #define DEBUGFS_ADD_FILE(name, parent, mode) do { \ diff --git a/drivers/net/wireless/iwlegacy/iwl-dev.h b/drivers/net/wireless/iwlegacy/iwl-dev.h deleted file mode 100644 index ce5bc5302044..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-dev.h +++ /dev/null @@ -1,1351 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ -/* - * Please use this file (iwl-dev.h) for driver implementation definitions. - * Please use commands.h for uCode API definitions. - * Please use 4965.h for hardware-related definitions. - */ - -#ifndef __il_dev_h__ -#define __il_dev_h__ - -#include -#include /* for struct pci_device_id */ -#include -#include -#include -#include - -#include "iwl-eeprom.h" -#include "csr.h" -#include "iwl-prph.h" -#include "iwl-debug.h" -#include "4965.h" -#include "iwl-led.h" -#include "iwl-power.h" -#include "iwl-legacy-rs.h" - -#define U32_PAD(n) ((4-(n))&0x3) - -struct il_tx_queue; - -/* CT-KILL constants */ -#define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */ - -/* Default noise level to report when noise measurement is not available. - * This may be because we're: - * 1) Not associated (4965, no beacon stats being sent to driver) - * 2) Scanning (noise measurement does not apply to associated channel) - * 3) Receiving CCK (3945 delivers noise info only for OFDM frames) - * Use default noise value of -127 ... this is below the range of measurable - * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user. - * Also, -127 works better than 0 when averaging frames with/without - * noise info (e.g. averaging might be done in app); measured dBm values are - * always negative ... using a negative value as the default keeps all - * averages within an s8's (used in some apps) range of negative values. */ -#define IL_NOISE_MEAS_NOT_AVAILABLE (-127) - -/* - * RTS threshold here is total size [2347] minus 4 FCS bytes - * Per spec: - * a value of 0 means RTS on all data/management packets - * a value > max MSDU size means no RTS - * else RTS for data/management frames where MPDU is larger - * than RTS value. - */ -#define DEFAULT_RTS_THRESHOLD 2347U -#define MIN_RTS_THRESHOLD 0U -#define MAX_RTS_THRESHOLD 2347U -#define MAX_MSDU_SIZE 2304U -#define MAX_MPDU_SIZE 2346U -#define DEFAULT_BEACON_INTERVAL 100U -#define DEFAULT_SHORT_RETRY_LIMIT 7U -#define DEFAULT_LONG_RETRY_LIMIT 4U - -struct il_rx_buf { - dma_addr_t page_dma; - struct page *page; - struct list_head list; -}; - -#define rxb_addr(r) page_address(r->page) - -/* defined below */ -struct il_device_cmd; - -struct il_cmd_meta { - /* only for SYNC commands, iff the reply skb is wanted */ - struct il_host_cmd *source; - /* - * only for ASYNC commands - * (which is somewhat stupid -- look at iwl-sta.c for instance - * which duplicates a bunch of code because the callback isn't - * invoked for SYNC commands, if it were and its result passed - * through it would be simpler...) - */ - void (*callback)(struct il_priv *il, - struct il_device_cmd *cmd, - struct il_rx_pkt *pkt); - - /* The CMD_SIZE_HUGE flag bit indicates that the command - * structure is stored at the end of the shared queue memory. */ - u32 flags; - - DEFINE_DMA_UNMAP_ADDR(mapping); - DEFINE_DMA_UNMAP_LEN(len); -}; - -/* - * Generic queue structure - * - * Contains common data for Rx and Tx queues - */ -struct il_queue { - int n_bd; /* number of BDs in this queue */ - int write_ptr; /* 1-st empty entry (idx) host_w*/ - int read_ptr; /* last used entry (idx) host_r*/ - /* use for monitoring and recovering the stuck queue */ - dma_addr_t dma_addr; /* physical addr for BD's */ - int n_win; /* safe queue win */ - u32 id; - int low_mark; /* low watermark, resume queue if free - * space more than this */ - int high_mark; /* high watermark, stop queue if free - * space less than this */ -}; - -/* One for each TFD */ -struct il_tx_info { - struct sk_buff *skb; - struct il_rxon_context *ctx; -}; - -/** - * struct il_tx_queue - Tx Queue for DMA - * @q: generic Rx/Tx queue descriptor - * @bd: base of circular buffer of TFDs - * @cmd: array of command/TX buffer pointers - * @meta: array of meta data for each command/tx buffer - * @dma_addr_cmd: physical address of cmd/tx buffer array - * @txb: array of per-TFD driver data - * @time_stamp: time (in jiffies) of last read_ptr change - * @need_update: indicates need to update read/write idx - * @sched_retry: indicates queue is high-throughput aggregation (HT AGG) enabled - * - * A Tx queue consists of circular buffer of BDs (a.k.a. TFDs, transmit frame - * descriptors) and required locking structures. - */ -#define TFD_TX_CMD_SLOTS 256 -#define TFD_CMD_SLOTS 32 - -struct il_tx_queue { - struct il_queue q; - void *tfds; - struct il_device_cmd **cmd; - struct il_cmd_meta *meta; - struct il_tx_info *txb; - unsigned long time_stamp; - u8 need_update; - u8 sched_retry; - u8 active; - u8 swq_id; -}; - -#define IL_NUM_SCAN_RATES (2) - -struct il4965_channel_tgd_info { - u8 type; - s8 max_power; -}; - -struct il4965_channel_tgh_info { - s64 last_radar_time; -}; - -#define IL4965_MAX_RATE (33) - -struct il3945_clip_group { - /* maximum power level to prevent clipping for each rate, derived by - * us from this band's saturation power in EEPROM */ - const s8 clip_powers[IL_MAX_RATES]; -}; - -/* current Tx power values to use, one for each rate for each channel. - * requested power is limited by: - * -- regulatory EEPROM limits for this channel - * -- hardware capabilities (clip-powers) - * -- spectrum management - * -- user preference (e.g. iwconfig) - * when requested power is set, base power idx must also be set. */ -struct il3945_channel_power_info { - struct il3945_tx_power tpc; /* actual radio and DSP gain settings */ - s8 power_table_idx; /* actual (compenst'd) idx into gain table */ - s8 base_power_idx; /* gain idx for power at factory temp. */ - s8 requested_power; /* power (dBm) requested for this chnl/rate */ -}; - -/* current scan Tx power values to use, one for each scan rate for each - * channel. */ -struct il3945_scan_power_info { - struct il3945_tx_power tpc; /* actual radio and DSP gain settings */ - s8 power_table_idx; /* actual (compenst'd) idx into gain table */ - s8 requested_power; /* scan pwr (dBm) requested for chnl/rate */ -}; - -/* - * One for each channel, holds all channel setup data - * Some of the fields (e.g. eeprom and flags/max_power_avg) are redundant - * with one another! - */ -struct il_channel_info { - struct il4965_channel_tgd_info tgd; - struct il4965_channel_tgh_info tgh; - struct il_eeprom_channel eeprom; /* EEPROM regulatory limit */ - struct il_eeprom_channel ht40_eeprom; /* EEPROM regulatory limit for - * HT40 channel */ - - u8 channel; /* channel number */ - u8 flags; /* flags copied from EEPROM */ - s8 max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */ - s8 curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) limit */ - s8 min_power; /* always 0 */ - s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */ - - u8 group_idx; /* 0-4, maps channel to group1/2/3/4/5 */ - u8 band_idx; /* 0-4, maps channel to band1/2/3/4/5 */ - enum ieee80211_band band; - - /* HT40 channel info */ - s8 ht40_max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */ - u8 ht40_flags; /* flags copied from EEPROM */ - u8 ht40_extension_channel; /* HT_IE_EXT_CHANNEL_* */ - - /* Radio/DSP gain settings for each "normal" data Tx rate. - * These include, in addition to RF and DSP gain, a few fields for - * remembering/modifying gain settings (idxes). */ - struct il3945_channel_power_info power_info[IL4965_MAX_RATE]; - - /* Radio/DSP gain settings for each scan rate, for directed scans. */ - struct il3945_scan_power_info scan_pwr_info[IL_NUM_SCAN_RATES]; -}; - -#define IL_TX_FIFO_BK 0 /* shared */ -#define IL_TX_FIFO_BE 1 -#define IL_TX_FIFO_VI 2 /* shared */ -#define IL_TX_FIFO_VO 3 -#define IL_TX_FIFO_UNUSED -1 - -/* Minimum number of queues. MAX_NUM is defined in hw specific files. - * Set the minimum to accommodate the 4 standard TX queues, 1 command - * queue, 2 (unused) HCCA queues, and 4 HT queues (one for each AC) */ -#define IL_MIN_NUM_QUEUES 10 - -#define IL_DEFAULT_CMD_QUEUE_NUM 4 - -#define IEEE80211_DATA_LEN 2304 -#define IEEE80211_4ADDR_LEN 30 -#define IEEE80211_HLEN (IEEE80211_4ADDR_LEN) -#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) - -struct il_frame { - union { - struct ieee80211_hdr frame; - struct il_tx_beacon_cmd beacon; - u8 raw[IEEE80211_FRAME_LEN]; - u8 cmd[360]; - } u; - struct list_head list; -}; - -#define SEQ_TO_SN(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) -#define SN_TO_SEQ(ssn) (((ssn) << 4) & IEEE80211_SCTL_SEQ) -#define MAX_SN ((IEEE80211_SCTL_SEQ) >> 4) - -enum { - CMD_SYNC = 0, - CMD_SIZE_NORMAL = 0, - CMD_NO_SKB = 0, - CMD_SIZE_HUGE = (1 << 0), - CMD_ASYNC = (1 << 1), - CMD_WANT_SKB = (1 << 2), - CMD_MAPPED = (1 << 3), -}; - -#define DEF_CMD_PAYLOAD_SIZE 320 - -/** - * struct il_device_cmd - * - * For allocation of the command and tx queues, this establishes the overall - * size of the largest command we send to uCode, except for a scan command - * (which is relatively huge; space is allocated separately). - */ -struct il_device_cmd { - struct il_cmd_header hdr; /* uCode API */ - union { - u32 flags; - u8 val8; - u16 val16; - u32 val32; - struct il_tx_cmd tx; - u8 payload[DEF_CMD_PAYLOAD_SIZE]; - } __packed cmd; -} __packed; - -#define TFD_MAX_PAYLOAD_SIZE (sizeof(struct il_device_cmd)) - - -struct il_host_cmd { - const void *data; - unsigned long reply_page; - void (*callback)(struct il_priv *il, - struct il_device_cmd *cmd, - struct il_rx_pkt *pkt); - u32 flags; - u16 len; - u8 id; -}; - -#define SUP_RATE_11A_MAX_NUM_CHANNELS 8 -#define SUP_RATE_11B_MAX_NUM_CHANNELS 4 -#define SUP_RATE_11G_MAX_NUM_CHANNELS 12 - -/** - * struct il_rx_queue - Rx queue - * @bd: driver's pointer to buffer of receive buffer descriptors (rbd) - * @bd_dma: bus address of buffer of receive buffer descriptors (rbd) - * @read: Shared idx to newest available Rx buffer - * @write: Shared idx to oldest written Rx packet - * @free_count: Number of pre-allocated buffers in rx_free - * @rx_free: list of free SKBs for use - * @rx_used: List of Rx buffers with no SKB - * @need_update: flag to indicate we need to update read/write idx - * @rb_stts: driver's pointer to receive buffer status - * @rb_stts_dma: bus address of receive buffer status - * - * NOTE: rx_free and rx_used are used as a FIFO for il_rx_bufs - */ -struct il_rx_queue { - __le32 *bd; - dma_addr_t bd_dma; - struct il_rx_buf pool[RX_QUEUE_SIZE + RX_FREE_BUFFERS]; - struct il_rx_buf *queue[RX_QUEUE_SIZE]; - u32 read; - u32 write; - u32 free_count; - u32 write_actual; - struct list_head rx_free; - struct list_head rx_used; - int need_update; - struct il_rb_status *rb_stts; - dma_addr_t rb_stts_dma; - spinlock_t lock; -}; - -#define IL_SUPPORTED_RATES_IE_LEN 8 - -#define MAX_TID_COUNT 9 - -#define IL_INVALID_RATE 0xFF -#define IL_INVALID_VALUE -1 - -/** - * struct il_ht_agg -- aggregation status while waiting for block-ack - * @txq_id: Tx queue used for Tx attempt - * @frame_count: # frames attempted by Tx command - * @wait_for_ba: Expect block-ack before next Tx reply - * @start_idx: Index of 1st Transmit Frame Descriptor (TFD) in Tx win - * @bitmap0: Low order bitmap, one bit for each frame pending ACK in Tx win - * @bitmap1: High order, one bit for each frame pending ACK in Tx win - * @rate_n_flags: Rate at which Tx was attempted - * - * If C_TX indicates that aggregation was attempted, driver must wait - * for block ack (N_COMPRESSED_BA). This struct stores tx reply info - * until block ack arrives. - */ -struct il_ht_agg { - u16 txq_id; - u16 frame_count; - u16 wait_for_ba; - u16 start_idx; - u64 bitmap; - u32 rate_n_flags; -#define IL_AGG_OFF 0 -#define IL_AGG_ON 1 -#define IL_EMPTYING_HW_QUEUE_ADDBA 2 -#define IL_EMPTYING_HW_QUEUE_DELBA 3 - u8 state; -}; - - -struct il_tid_data { - u16 seq_number; /* 4965 only */ - u16 tfds_in_queue; - struct il_ht_agg agg; -}; - -struct il_hw_key { - u32 cipher; - int keylen; - u8 keyidx; - u8 key[32]; -}; - -union il_ht_rate_supp { - u16 rates; - struct { - u8 siso_rate; - u8 mimo_rate; - }; -}; - -#define CFG_HT_RX_AMPDU_FACTOR_8K (0x0) -#define CFG_HT_RX_AMPDU_FACTOR_16K (0x1) -#define CFG_HT_RX_AMPDU_FACTOR_32K (0x2) -#define CFG_HT_RX_AMPDU_FACTOR_64K (0x3) -#define CFG_HT_RX_AMPDU_FACTOR_DEF CFG_HT_RX_AMPDU_FACTOR_64K -#define CFG_HT_RX_AMPDU_FACTOR_MAX CFG_HT_RX_AMPDU_FACTOR_64K -#define CFG_HT_RX_AMPDU_FACTOR_MIN CFG_HT_RX_AMPDU_FACTOR_8K - -/* - * Maximal MPDU density for TX aggregation - * 4 - 2us density - * 5 - 4us density - * 6 - 8us density - * 7 - 16us density - */ -#define CFG_HT_MPDU_DENSITY_2USEC (0x4) -#define CFG_HT_MPDU_DENSITY_4USEC (0x5) -#define CFG_HT_MPDU_DENSITY_8USEC (0x6) -#define CFG_HT_MPDU_DENSITY_16USEC (0x7) -#define CFG_HT_MPDU_DENSITY_DEF CFG_HT_MPDU_DENSITY_4USEC -#define CFG_HT_MPDU_DENSITY_MAX CFG_HT_MPDU_DENSITY_16USEC -#define CFG_HT_MPDU_DENSITY_MIN (0x1) - -struct il_ht_config { - bool single_chain_sufficient; - enum ieee80211_smps_mode smps; /* current smps mode */ -}; - -/* QoS structures */ -struct il_qos_info { - int qos_active; - struct il_qosparam_cmd def_qos_parm; -}; - -/* - * Structure should be accessed with sta_lock held. When station addition - * is in progress (IL_STA_UCODE_INPROGRESS) it is possible to access only - * the commands (il_addsta_cmd and il_link_quality_cmd) without - * sta_lock held. - */ -struct il_station_entry { - struct il_addsta_cmd sta; - struct il_tid_data tid[MAX_TID_COUNT]; - u8 used, ctxid; - struct il_hw_key keyinfo; - struct il_link_quality_cmd *lq; -}; - -struct il_station_priv_common { - struct il_rxon_context *ctx; - u8 sta_id; -}; - -/* - * il_station_priv: Driver's ilate station information - * - * When mac80211 creates a station it reserves some space (hw->sta_data_size) - * in the structure for use by driver. This structure is places in that - * space. - * - * The common struct MUST be first because it is shared between - * 3945 and 4965! - */ -struct il_station_priv { - struct il_station_priv_common common; - struct il_lq_sta lq_sta; - atomic_t pending_frames; - bool client; - bool asleep; -}; - -/** - * struct il_vif_priv - driver's ilate per-interface information - * - * When mac80211 allocates a virtual interface, it can allocate - * space for us to put data into. - */ -struct il_vif_priv { - struct il_rxon_context *ctx; - u8 ibss_bssid_sta_id; -}; - -/* one for each uCode image (inst/data, boot/init/runtime) */ -struct fw_desc { - void *v_addr; /* access by driver */ - dma_addr_t p_addr; /* access by card's busmaster DMA */ - u32 len; /* bytes */ -}; - -/* uCode file layout */ -struct il_ucode_header { - __le32 ver; /* major/minor/API/serial */ - struct { - __le32 inst_size; /* bytes of runtime code */ - __le32 data_size; /* bytes of runtime data */ - __le32 init_size; /* bytes of init code */ - __le32 init_data_size; /* bytes of init data */ - __le32 boot_size; /* bytes of bootstrap code */ - u8 data[0]; /* in same order as sizes */ - } v1; -}; - -struct il4965_ibss_seq { - u8 mac[ETH_ALEN]; - u16 seq_num; - u16 frag_num; - unsigned long packet_time; - struct list_head list; -}; - -struct il_sensitivity_ranges { - u16 min_nrg_cck; - u16 max_nrg_cck; - - u16 nrg_th_cck; - u16 nrg_th_ofdm; - - u16 auto_corr_min_ofdm; - u16 auto_corr_min_ofdm_mrc; - u16 auto_corr_min_ofdm_x1; - u16 auto_corr_min_ofdm_mrc_x1; - - u16 auto_corr_max_ofdm; - u16 auto_corr_max_ofdm_mrc; - u16 auto_corr_max_ofdm_x1; - u16 auto_corr_max_ofdm_mrc_x1; - - u16 auto_corr_max_cck; - u16 auto_corr_max_cck_mrc; - u16 auto_corr_min_cck; - u16 auto_corr_min_cck_mrc; - - u16 barker_corr_th_min; - u16 barker_corr_th_min_mrc; - u16 nrg_th_cca; -}; - - -#define KELVIN_TO_CELSIUS(x) ((x)-273) -#define CELSIUS_TO_KELVIN(x) ((x)+273) - - -/** - * struct il_hw_params - * @max_txq_num: Max # Tx queues supported - * @dma_chnl_num: Number of Tx DMA/FIFO channels - * @scd_bc_tbls_size: size of scheduler byte count tables - * @tfd_size: TFD size - * @tx/rx_chains_num: Number of TX/RX chains - * @valid_tx/rx_ant: usable antennas - * @max_rxq_size: Max # Rx frames in Rx queue (must be power-of-2) - * @max_rxq_log: Log-base-2 of max_rxq_size - * @rx_page_order: Rx buffer page order - * @rx_wrt_ptr_reg: FH{39}_RSCSR_CHNL0_WPTR - * @max_stations: - * @ht40_channel: is 40MHz width possible in band 2.4 - * BIT(IEEE80211_BAND_5GHZ) BIT(IEEE80211_BAND_5GHZ) - * @sw_crypto: 0 for hw, 1 for sw - * @max_xxx_size: for ucode uses - * @ct_kill_threshold: temperature threshold - * @beacon_time_tsf_bits: number of valid tsf bits for beacon time - * @struct il_sensitivity_ranges: range of sensitivity values - */ -struct il_hw_params { - u8 max_txq_num; - u8 dma_chnl_num; - u16 scd_bc_tbls_size; - u32 tfd_size; - u8 tx_chains_num; - u8 rx_chains_num; - u8 valid_tx_ant; - u8 valid_rx_ant; - u16 max_rxq_size; - u16 max_rxq_log; - u32 rx_page_order; - u32 rx_wrt_ptr_reg; - u8 max_stations; - u8 ht40_channel; - u8 max_beacon_itrvl; /* in 1024 ms */ - u32 max_inst_size; - u32 max_data_size; - u32 max_bsm_size; - u32 ct_kill_threshold; /* value in hw-dependent units */ - u16 beacon_time_tsf_bits; - const struct il_sensitivity_ranges *sens; -}; - - -/****************************************************************************** - * - * Functions implemented in core module which are forward declared here - * for use by iwl-[4-5].c - * - * NOTE: The implementation of these functions are not hardware specific - * which is why they are in the core module files. - * - * Naming convention -- - * il_ <-- Is part of iwlwifi - * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX) - * il4965_bg_ <-- Called from work queue context - * il4965_mac_ <-- mac80211 callback - * - ****************************************************************************/ -extern void il4965_update_chain_flags(struct il_priv *il); -extern const u8 il_bcast_addr[ETH_ALEN]; -extern int il_queue_space(const struct il_queue *q); -static inline int il_queue_used(const struct il_queue *q, int i) -{ - return q->write_ptr >= q->read_ptr ? - (i >= q->read_ptr && i < q->write_ptr) : - !(i < q->read_ptr && i >= q->write_ptr); -} - - -static inline u8 il_get_cmd_idx(struct il_queue *q, u32 idx, - int is_huge) -{ - /* - * This is for init calibration result and scan command which - * required buffer > TFD_MAX_PAYLOAD_SIZE, - * the big buffer at end of command array - */ - if (is_huge) - return q->n_win; /* must be power of 2 */ - - /* Otherwise, use normal size buffers */ - return idx & (q->n_win - 1); -} - - -struct il_dma_ptr { - dma_addr_t dma; - void *addr; - size_t size; -}; - -#define IL_OPERATION_MODE_AUTO 0 -#define IL_OPERATION_MODE_HT_ONLY 1 -#define IL_OPERATION_MODE_MIXED 2 -#define IL_OPERATION_MODE_20MHZ 3 - -#define IL_TX_CRC_SIZE 4 -#define IL_TX_DELIMITER_SIZE 4 - -#define TX_POWER_IL_ILLEGAL_VOLTAGE -10000 - -/* Sensitivity and chain noise calibration */ -#define INITIALIZATION_VALUE 0xFFFF -#define IL4965_CAL_NUM_BEACONS 20 -#define IL_CAL_NUM_BEACONS 16 -#define MAXIMUM_ALLOWED_PATHLOSS 15 - -#define CHAIN_NOISE_MAX_DELTA_GAIN_CODE 3 - -#define MAX_FA_OFDM 50 -#define MIN_FA_OFDM 5 -#define MAX_FA_CCK 50 -#define MIN_FA_CCK 5 - -#define AUTO_CORR_STEP_OFDM 1 - -#define AUTO_CORR_STEP_CCK 3 -#define AUTO_CORR_MAX_TH_CCK 160 - -#define NRG_DIFF 2 -#define NRG_STEP_CCK 2 -#define NRG_MARGIN 8 -#define MAX_NUMBER_CCK_NO_FA 100 - -#define AUTO_CORR_CCK_MIN_VAL_DEF (125) - -#define CHAIN_A 0 -#define CHAIN_B 1 -#define CHAIN_C 2 -#define CHAIN_NOISE_DELTA_GAIN_INIT_VAL 4 -#define ALL_BAND_FILTER 0xFF00 -#define IN_BAND_FILTER 0xFF -#define MIN_AVERAGE_NOISE_MAX_VALUE 0xFFFFFFFF - -#define NRG_NUM_PREV_STAT_L 20 -#define NUM_RX_CHAINS 3 - -enum il4965_false_alarm_state { - IL_FA_TOO_MANY = 0, - IL_FA_TOO_FEW = 1, - IL_FA_GOOD_RANGE = 2, -}; - -enum il4965_chain_noise_state { - IL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */ - IL_CHAIN_NOISE_ACCUMULATE, - IL_CHAIN_NOISE_CALIBRATED, - IL_CHAIN_NOISE_DONE, -}; - -enum il4965_calib_enabled_state { - IL_CALIB_DISABLED = 0, /* must be 0 */ - IL_CALIB_ENABLED = 1, -}; - -/* - * enum il_calib - * defines the order in which results of initial calibrations - * should be sent to the runtime uCode - */ -enum il_calib { - IL_CALIB_MAX, -}; - -/* Opaque calibration results */ -struct il_calib_result { - void *buf; - size_t buf_len; -}; - -enum ucode_type { - UCODE_NONE = 0, - UCODE_INIT, - UCODE_RT -}; - -/* Sensitivity calib data */ -struct il_sensitivity_data { - u32 auto_corr_ofdm; - u32 auto_corr_ofdm_mrc; - u32 auto_corr_ofdm_x1; - u32 auto_corr_ofdm_mrc_x1; - u32 auto_corr_cck; - u32 auto_corr_cck_mrc; - - u32 last_bad_plcp_cnt_ofdm; - u32 last_fa_cnt_ofdm; - u32 last_bad_plcp_cnt_cck; - u32 last_fa_cnt_cck; - - u32 nrg_curr_state; - u32 nrg_prev_state; - u32 nrg_value[10]; - u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L]; - u32 nrg_silence_ref; - u32 nrg_energy_idx; - u32 nrg_silence_idx; - u32 nrg_th_cck; - s32 nrg_auto_corr_silence_diff; - u32 num_in_cck_no_fa; - u32 nrg_th_ofdm; - - u16 barker_corr_th_min; - u16 barker_corr_th_min_mrc; - u16 nrg_th_cca; -}; - -/* Chain noise (differential Rx gain) calib data */ -struct il_chain_noise_data { - u32 active_chains; - u32 chain_noise_a; - u32 chain_noise_b; - u32 chain_noise_c; - u32 chain_signal_a; - u32 chain_signal_b; - u32 chain_signal_c; - u16 beacon_count; - u8 disconn_array[NUM_RX_CHAINS]; - u8 delta_gain_code[NUM_RX_CHAINS]; - u8 radio_write; - u8 state; -}; - -#define EEPROM_SEM_TIMEOUT 10 /* milliseconds */ -#define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ - -#define IL_TRAFFIC_ENTRIES (256) -#define IL_TRAFFIC_ENTRY_SIZE (64) - -enum { - MEASUREMENT_READY = (1 << 0), - MEASUREMENT_ACTIVE = (1 << 1), -}; - -/* interrupt stats */ -struct isr_stats { - u32 hw; - u32 sw; - u32 err_code; - u32 sch; - u32 alive; - u32 rfkill; - u32 ctkill; - u32 wakeup; - u32 rx; - u32 handlers[IL_CN_MAX]; - u32 tx; - u32 unhandled; -}; - -/* management stats */ -enum il_mgmt_stats { - MANAGEMENT_ASSOC_REQ = 0, - MANAGEMENT_ASSOC_RESP, - MANAGEMENT_REASSOC_REQ, - MANAGEMENT_REASSOC_RESP, - MANAGEMENT_PROBE_REQ, - MANAGEMENT_PROBE_RESP, - MANAGEMENT_BEACON, - MANAGEMENT_ATIM, - MANAGEMENT_DISASSOC, - MANAGEMENT_AUTH, - MANAGEMENT_DEAUTH, - MANAGEMENT_ACTION, - MANAGEMENT_MAX, -}; -/* control stats */ -enum il_ctrl_stats { - CONTROL_BACK_REQ = 0, - CONTROL_BACK, - CONTROL_PSPOLL, - CONTROL_RTS, - CONTROL_CTS, - CONTROL_ACK, - CONTROL_CFEND, - CONTROL_CFENDACK, - CONTROL_MAX, -}; - -struct traffic_stats { -#ifdef CONFIG_IWLEGACY_DEBUGFS - u32 mgmt[MANAGEMENT_MAX]; - u32 ctrl[CONTROL_MAX]; - u32 data_cnt; - u64 data_bytes; -#endif -}; - -/* - * host interrupt timeout value - * used with setting interrupt coalescing timer - * the CSR_INT_COALESCING is an 8 bit register in 32-usec unit - * - * default interrupt coalescing timer is 64 x 32 = 2048 usecs - * default interrupt coalescing calibration timer is 16 x 32 = 512 usecs - */ -#define IL_HOST_INT_TIMEOUT_MAX (0xFF) -#define IL_HOST_INT_TIMEOUT_DEF (0x40) -#define IL_HOST_INT_TIMEOUT_MIN (0x0) -#define IL_HOST_INT_CALIB_TIMEOUT_MAX (0xFF) -#define IL_HOST_INT_CALIB_TIMEOUT_DEF (0x10) -#define IL_HOST_INT_CALIB_TIMEOUT_MIN (0x0) - -#define IL_DELAY_NEXT_FORCE_FW_RELOAD (HZ*5) - -/* TX queue watchdog timeouts in mSecs */ -#define IL_DEF_WD_TIMEOUT (2000) -#define IL_LONG_WD_TIMEOUT (10000) -#define IL_MAX_WD_TIMEOUT (120000) - -struct il_force_reset { - int reset_request_count; - int reset_success_count; - int reset_reject_count; - unsigned long reset_duration; - unsigned long last_force_reset_jiffies; -}; - -/* extend beacon time format bit shifting */ -/* - * for _3945 devices - * bits 31:24 - extended - * bits 23:0 - interval - */ -#define IL3945_EXT_BEACON_TIME_POS 24 -/* - * for _4965 devices - * bits 31:22 - extended - * bits 21:0 - interval - */ -#define IL4965_EXT_BEACON_TIME_POS 22 - -struct il_rxon_context { - struct ieee80211_vif *vif; - - const u8 *ac_to_fifo; - const u8 *ac_to_queue; - u8 mcast_queue; - - /* - * We could use the vif to indicate active, but we - * also need it to be active during disabling when - * we already removed the vif for type setting. - */ - bool always_active, is_active; - - bool ht_need_multiple_chains; - - int ctxid; - - u32 interface_modes, exclusive_interface_modes; - u8 unused_devtype, ap_devtype, ibss_devtype, station_devtype; - - /* - * We declare this const so it can only be - * changed via explicit cast within the - * routines that actually update the physical - * hardware. - */ - const struct il_rxon_cmd active; - struct il_rxon_cmd staging; - - struct il_rxon_time_cmd timing; - - struct il_qos_info qos_data; - - u8 bcast_sta_id, ap_sta_id; - - u8 rxon_cmd, rxon_assoc_cmd, rxon_timing_cmd; - u8 qos_cmd; - u8 wep_key_cmd; - - struct il_wep_key wep_keys[WEP_KEYS_MAX]; - u8 key_mapping_keys; - - __le32 station_flags; - - struct { - bool non_gf_sta_present; - u8 protection; - bool enabled, is_40mhz; - u8 extension_chan_offset; - } ht; -}; - -struct il_priv { - - /* ieee device used by generic ieee processing code */ - struct ieee80211_hw *hw; - struct ieee80211_channel *ieee_channels; - struct ieee80211_rate *ieee_rates; - struct il_cfg *cfg; - - /* temporary frame storage list */ - struct list_head free_frames; - int frames_count; - - enum ieee80211_band band; - int alloc_rxb_page; - - void (*handlers[IL_CN_MAX])(struct il_priv *il, - struct il_rx_buf *rxb); - - struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; - - /* spectrum measurement report caching */ - struct il_spectrum_notification measure_report; - u8 measurement_status; - - /* ucode beacon time */ - u32 ucode_beacon_time; - int missed_beacon_threshold; - - /* track IBSS manager (last beacon) status */ - u32 ibss_manager; - - /* force reset */ - struct il_force_reset force_reset; - - /* we allocate array of il_channel_info for NIC's valid channels. - * Access via channel # using indirect idx array */ - struct il_channel_info *channel_info; /* channel info array */ - u8 channel_count; /* # of channels */ - - /* thermal calibration */ - s32 temperature; /* degrees Kelvin */ - s32 last_temperature; - - /* init calibration results */ - struct il_calib_result calib_results[IL_CALIB_MAX]; - - /* Scan related variables */ - unsigned long scan_start; - unsigned long scan_start_tsf; - void *scan_cmd; - enum ieee80211_band scan_band; - struct cfg80211_scan_request *scan_request; - struct ieee80211_vif *scan_vif; - u8 scan_tx_ant[IEEE80211_NUM_BANDS]; - u8 mgmt_tx_ant; - - /* spinlock */ - spinlock_t lock; /* protect general shared data */ - spinlock_t hcmd_lock; /* protect hcmd */ - spinlock_t reg_lock; /* protect hw register access */ - struct mutex mutex; - - /* basic pci-network driver stuff */ - struct pci_dev *pci_dev; - - /* pci hardware address support */ - void __iomem *hw_base; - u32 hw_rev; - u32 hw_wa_rev; - u8 rev_id; - - /* command queue number */ - u8 cmd_queue; - - /* max number of station keys */ - u8 sta_key_max_num; - - /* EEPROM MAC addresses */ - struct mac_address addresses[1]; - - /* uCode images, save to reload in case of failure */ - int fw_idx; /* firmware we're trying to load */ - u32 ucode_ver; /* version of ucode, copy of - il_ucode.ver */ - struct fw_desc ucode_code; /* runtime inst */ - struct fw_desc ucode_data; /* runtime data original */ - struct fw_desc ucode_data_backup; /* runtime data save/restore */ - struct fw_desc ucode_init; /* initialization inst */ - struct fw_desc ucode_init_data; /* initialization data */ - struct fw_desc ucode_boot; /* bootstrap inst */ - enum ucode_type ucode_type; - u8 ucode_write_complete; /* the image write is complete */ - char firmware_name[25]; - - struct il_rxon_context ctx; - - __le16 switch_channel; - - /* 1st responses from initialize and runtime uCode images. - * _4965's initialize alive response contains some calibration data. */ - struct il_init_alive_resp card_alive_init; - struct il_alive_resp card_alive; - - u16 active_rate; - - u8 start_calib; - struct il_sensitivity_data sensitivity_data; - struct il_chain_noise_data chain_noise_data; - __le16 sensitivity_tbl[HD_TBL_SIZE]; - - struct il_ht_config current_ht_config; - - /* Rate scaling data */ - u8 retry_rate; - - wait_queue_head_t wait_command_queue; - - int activity_timer_active; - - /* Rx and Tx DMA processing queues */ - struct il_rx_queue rxq; - struct il_tx_queue *txq; - unsigned long txq_ctx_active_msk; - struct il_dma_ptr kw; /* keep warm address */ - struct il_dma_ptr scd_bc_tbls; - - u32 scd_base_addr; /* scheduler sram base address */ - - unsigned long status; - - /* counts mgmt, ctl, and data packets */ - struct traffic_stats tx_stats; - struct traffic_stats rx_stats; - - /* counts interrupts */ - struct isr_stats isr_stats; - - struct il_power_mgr power_data; - - /* context information */ - u8 bssid[ETH_ALEN]; /* used only on 3945 but filled by core */ - - /* station table variables */ - - /* Note: if lock and sta_lock are needed, lock must be acquired first */ - spinlock_t sta_lock; - int num_stations; - struct il_station_entry stations[IL_STATION_COUNT]; - unsigned long ucode_key_table; - - /* queue refcounts */ -#define IL_MAX_HW_QUEUES 32 - unsigned long queue_stopped[BITS_TO_LONGS(IL_MAX_HW_QUEUES)]; - /* for each AC */ - atomic_t queue_stop_count[4]; - - /* Indication if ieee80211_ops->open has been called */ - u8 is_open; - - u8 mac80211_registered; - - /* eeprom -- this is in the card's little endian byte order */ - u8 *eeprom; - struct il_eeprom_calib_info *calib_info; - - enum nl80211_iftype iw_mode; - - /* Last Rx'd beacon timestamp */ - u64 timestamp; - - union { -#if defined(CONFIG_IWL3945) || defined(CONFIG_IWL3945_MODULE) - struct { - void *shared_virt; - dma_addr_t shared_phys; - - struct delayed_work thermal_periodic; - struct delayed_work rfkill_poll; - - struct il3945_notif_stats stats; -#ifdef CONFIG_IWLEGACY_DEBUGFS - struct il3945_notif_stats accum_stats; - struct il3945_notif_stats delta_stats; - struct il3945_notif_stats max_delta; -#endif - - u32 sta_supp_rates; - int last_rx_rssi; /* From Rx packet stats */ - - /* Rx'd packet timing information */ - u32 last_beacon_time; - u64 last_tsf; - - /* - * each calibration channel group in the - * EEPROM has a derived clip setting for - * each rate. - */ - const struct il3945_clip_group clip_groups[5]; - - } _3945; -#endif -#if defined(CONFIG_IWL4965) || defined(CONFIG_IWL4965_MODULE) - struct { - struct il_rx_phy_res last_phy_res; - bool last_phy_res_valid; - - struct completion firmware_loading_complete; - - /* - * chain noise reset and gain commands are the - * two extra calibration commands follows the standard - * phy calibration commands - */ - u8 phy_calib_chain_noise_reset_cmd; - u8 phy_calib_chain_noise_gain_cmd; - - struct il_notif_stats stats; -#ifdef CONFIG_IWLEGACY_DEBUGFS - struct il_notif_stats accum_stats; - struct il_notif_stats delta_stats; - struct il_notif_stats max_delta; -#endif - - } _4965; -#endif - }; - - struct il_hw_params hw_params; - - u32 inta_mask; - - struct workqueue_struct *workqueue; - - struct work_struct restart; - struct work_struct scan_completed; - struct work_struct rx_replenish; - struct work_struct abort_scan; - - struct il_rxon_context *beacon_ctx; - struct sk_buff *beacon_skb; - - struct work_struct tx_flush; - - struct tasklet_struct irq_tasklet; - - struct delayed_work init_alive_start; - struct delayed_work alive_start; - struct delayed_work scan_check; - - /* TX Power */ - s8 tx_power_user_lmt; - s8 tx_power_device_lmt; - s8 tx_power_next; - - -#ifdef CONFIG_IWLEGACY_DEBUG - /* debugging info */ - u32 debug_level; /* per device debugging will override global - il_debug_level if set */ -#endif /* CONFIG_IWLEGACY_DEBUG */ -#ifdef CONFIG_IWLEGACY_DEBUGFS - /* debugfs */ - u16 tx_traffic_idx; - u16 rx_traffic_idx; - u8 *tx_traffic; - u8 *rx_traffic; - struct dentry *debugfs_dir; - u32 dbgfs_sram_offset, dbgfs_sram_len; - bool disable_ht40; -#endif /* CONFIG_IWLEGACY_DEBUGFS */ - - struct work_struct txpower_work; - u32 disable_sens_cal; - u32 disable_chain_noise_cal; - u32 disable_tx_power_cal; - struct work_struct run_time_calib_work; - struct timer_list stats_periodic; - struct timer_list watchdog; - bool hw_ready; - - struct led_classdev led; - unsigned long blink_on, blink_off; - bool led_registered; -}; /*il_priv */ - -static inline void il_txq_ctx_activate(struct il_priv *il, int txq_id) -{ - set_bit(txq_id, &il->txq_ctx_active_msk); -} - -static inline void il_txq_ctx_deactivate(struct il_priv *il, int txq_id) -{ - clear_bit(txq_id, &il->txq_ctx_active_msk); -} - -#ifdef CONFIG_IWLEGACY_DEBUG -/* - * il_get_debug_level: Return active debug level for device - * - * Using sysfs it is possible to set per device debug level. This debug - * level will be used if set, otherwise the global debug level which can be - * set via module parameter is used. - */ -static inline u32 il_get_debug_level(struct il_priv *il) -{ - if (il->debug_level) - return il->debug_level; - else - return il_debug_level; -} -#else -static inline u32 il_get_debug_level(struct il_priv *il) -{ - return il_debug_level; -} -#endif - - -static inline struct ieee80211_hdr * -il_tx_queue_get_hdr(struct il_priv *il, - int txq_id, int idx) -{ - if (il->txq[txq_id].txb[idx].skb) - return (struct ieee80211_hdr *)il->txq[txq_id]. - txb[idx].skb->data; - return NULL; -} - -static inline struct il_rxon_context * -il_rxon_ctx_from_vif(struct ieee80211_vif *vif) -{ - struct il_vif_priv *vif_priv = (void *)vif->drv_priv; - - return vif_priv->ctx; -} - -#define for_each_context(il, _ctx) \ - for (_ctx = &il->ctx; _ctx == &il->ctx; _ctx++) - -static inline int il_is_associated(struct il_priv *il) -{ - return (il->ctx.active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; -} - -static inline int il_is_any_associated(struct il_priv *il) -{ - return il_is_associated(il); -} - -static inline int il_is_associated_ctx(struct il_rxon_context *ctx) -{ - return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; -} - -static inline int il_is_channel_valid(const struct il_channel_info *ch_info) -{ - if (ch_info == NULL) - return 0; - return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0; -} - -static inline int il_is_channel_radar(const struct il_channel_info *ch_info) -{ - return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0; -} - -static inline u8 il_is_channel_a_band(const struct il_channel_info *ch_info) -{ - return ch_info->band == IEEE80211_BAND_5GHZ; -} - -static inline int -il_is_channel_passive(const struct il_channel_info *ch) -{ - return (!(ch->flags & EEPROM_CHANNEL_ACTIVE)) ? 1 : 0; -} - -static inline int -il_is_channel_ibss(const struct il_channel_info *ch) -{ - return (ch->flags & EEPROM_CHANNEL_IBSS) ? 1 : 0; -} - -static inline void -__il_free_pages(struct il_priv *il, struct page *page) -{ - __free_pages(page, il->hw_params.rx_page_order); - il->alloc_rxb_page--; -} - -static inline void il_free_pages(struct il_priv *il, unsigned long page) -{ - free_pages(page, il->hw_params.rx_page_order); - il->alloc_rxb_page--; -} -#endif /* __il_dev_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-fh.h b/drivers/net/wireless/iwlegacy/iwl-fh.h index f53f1b87d8e9..7846baeef585 100644 --- a/drivers/net/wireless/iwlegacy/iwl-fh.h +++ b/drivers/net/wireless/iwlegacy/iwl-fh.h @@ -266,8 +266,6 @@ #define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL (0x00000000) #define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL (0x00001000) -#define FH_RSCSR_FRAME_SIZE_MSK (0x00003FFF) /* bits 0-13 */ - /** * Rx Shared Status Registers (RSSR) * @@ -413,100 +411,6 @@ */ #define FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN (0x00000002) -#define RX_QUEUE_SIZE 256 -#define RX_QUEUE_MASK 255 -#define RX_QUEUE_SIZE_LOG 8 - -/* - * RX related structures and functions - */ -#define RX_FREE_BUFFERS 64 -#define RX_LOW_WATERMARK 8 - -/* Size of one Rx buffer in host DRAM */ -#define IL_RX_BUF_SIZE_3K (3 * 1000) /* 3945 only */ -#define IL_RX_BUF_SIZE_4K (4 * 1024) -#define IL_RX_BUF_SIZE_8K (8 * 1024) - -/** - * struct il_rb_status - reseve buffer status - * host memory mapped FH registers - * @closed_rb_num [0:11] - Indicates the idx of the RB which was closed - * @closed_fr_num [0:11] - Indicates the idx of the RX Frame which was closed - * @finished_rb_num [0:11] - Indicates the idx of the current RB - * in which the last frame was written to - * @finished_fr_num [0:11] - Indicates the idx of the RX Frame - * which was transferred - */ -struct il_rb_status { - __le16 closed_rb_num; - __le16 closed_fr_num; - __le16 finished_rb_num; - __le16 finished_fr_nam; - __le32 __unused; /* 3945 only */ -} __packed; - - -#define TFD_QUEUE_SIZE_MAX (256) -#define TFD_QUEUE_SIZE_BC_DUP (64) -#define TFD_QUEUE_BC_SIZE (TFD_QUEUE_SIZE_MAX + TFD_QUEUE_SIZE_BC_DUP) -#define IL_TX_DMA_MASK DMA_BIT_MASK(36) -#define IL_NUM_OF_TBS 20 - -static inline u8 il_get_dma_hi_addr(dma_addr_t addr) -{ - return (sizeof(addr) > sizeof(u32) ? (addr >> 16) >> 16 : 0) & 0xF; -} -/** - * struct il_tfd_tb transmit buffer descriptor within transmit frame descriptor - * - * This structure contains dma address and length of transmission address - * - * @lo: low [31:0] portion of the dma address of TX buffer - * every even is unaligned on 16 bit boundary - * @hi_n_len 0-3 [35:32] portion of dma - * 4-15 length of the tx buffer - */ -struct il_tfd_tb { - __le32 lo; - __le16 hi_n_len; -} __packed; - -/** - * struct il_tfd - * - * Transmit Frame Descriptor (TFD) - * - * @ __reserved1[3] reserved - * @ num_tbs 0-4 number of active tbs - * 5 reserved - * 6-7 padding (not used) - * @ tbs[20] transmit frame buffer descriptors - * @ __pad padding - * - * Each Tx queue uses a circular buffer of 256 TFDs stored in host DRAM. - * Both driver and device share these circular buffers, each of which must be - * contiguous 256 TFDs x 128 bytes-per-TFD = 32 KBytes - * - * Driver must indicate the physical address of the base of each - * circular buffer via the FH_MEM_CBBC_QUEUE registers. - * - * Each TFD contains pointer/size information for up to 20 data buffers - * in host DRAM. These buffers collectively contain the (one) frame described - * by the TFD. Each buffer must be a single contiguous block of memory within - * itself, but buffers may be scattered in host DRAM. Each buffer has max size - * of (4K - 4). The concatenates all of a TFD's buffers into a single - * Tx frame, up to 8 KBytes in size. - * - * A maximum of 255 (not 256!) TFDs may be on a queue waiting for Tx. - */ -struct il_tfd { - u8 __reserved1[3]; - u8 num_tbs; - struct il_tfd_tb tbs[IL_NUM_OF_TBS]; - __le32 __pad; -} __packed; - /* Keep Warm Size */ #define IL_KW_SIZE 0x1000 /* 4k */ diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h deleted file mode 100644 index 9d33da82a79f..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-io.h +++ /dev/null @@ -1,337 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * Portions of this file are derived from the ipw3945 project. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#ifndef __il_io_h__ -#define __il_io_h__ - -#include - -#include "iwl-dev.h" -#include "iwl-debug.h" - -static inline void _il_write8(struct il_priv *il, u32 ofs, u8 val) -{ - iowrite8(val, il->hw_base + ofs); -} -#define il_write8(il, ofs, val) _il_write8(il, ofs, val) - -static inline void _il_wr(struct il_priv *il, u32 ofs, u32 val) -{ - iowrite32(val, il->hw_base + ofs); -} - -static inline u32 _il_rd(struct il_priv *il, u32 ofs) -{ - return ioread32(il->hw_base + ofs); -} - -#define IL_POLL_INTERVAL 10 /* microseconds */ -static inline int -_il_poll_bit(struct il_priv *il, u32 addr, - u32 bits, u32 mask, int timeout) -{ - int t = 0; - - do { - if ((_il_rd(il, addr) & mask) == (bits & mask)) - return t; - udelay(IL_POLL_INTERVAL); - t += IL_POLL_INTERVAL; - } while (t < timeout); - - return -ETIMEDOUT; -} - -static inline void _il_set_bit(struct il_priv *il, u32 reg, u32 mask) -{ - _il_wr(il, reg, _il_rd(il, reg) | mask); -} - -static inline void il_set_bit(struct il_priv *p, u32 r, u32 m) -{ - unsigned long reg_flags; - - spin_lock_irqsave(&p->reg_lock, reg_flags); - _il_set_bit(p, r, m); - spin_unlock_irqrestore(&p->reg_lock, reg_flags); -} - -static inline void -_il_clear_bit(struct il_priv *il, u32 reg, u32 mask) -{ - _il_wr(il, reg, _il_rd(il, reg) & ~mask); -} - -static inline void il_clear_bit(struct il_priv *p, u32 r, u32 m) -{ - unsigned long reg_flags; - - spin_lock_irqsave(&p->reg_lock, reg_flags); - _il_clear_bit(p, r, m); - spin_unlock_irqrestore(&p->reg_lock, reg_flags); -} - -static inline int _il_grab_nic_access(struct il_priv *il) -{ - int ret; - u32 val; - - /* this bit wakes up the NIC */ - _il_set_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); - - /* - * These bits say the device is running, and should keep running for - * at least a short while (at least as long as MAC_ACCESS_REQ stays 1), - * but they do not indicate that embedded SRAM is restored yet; - * 3945 and 4965 have volatile SRAM, and must save/restore contents - * to/from host DRAM when sleeping/waking for power-saving. - * Each direction takes approximately 1/4 millisecond; with this - * overhead, it's a good idea to grab and hold MAC_ACCESS_REQUEST if a - * series of register accesses are expected (e.g. reading Event Log), - * to keep device from sleeping. - * - * CSR_UCODE_DRV_GP1 register bit MAC_SLEEP == 0 indicates that - * SRAM is okay/restored. We don't check that here because this call - * is just for hardware register access; but GP1 MAC_SLEEP check is a - * good idea before accessing 3945/4965 SRAM (e.g. reading Event Log). - * - */ - ret = _il_poll_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN, - (CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY | - CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 15000); - if (ret < 0) { - val = _il_rd(il, CSR_GP_CNTRL); - IL_ERR( - "MAC is in deep sleep!. CSR_GP_CNTRL = 0x%08X\n", val); - _il_wr(il, CSR_RESET, - CSR_RESET_REG_FLAG_FORCE_NMI); - return -EIO; - } - - return 0; -} - -static inline void _il_release_nic_access(struct il_priv *il) -{ - _il_clear_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); -} - -static inline u32 il_rd(struct il_priv *il, u32 reg) -{ - u32 value; - unsigned long reg_flags; - - spin_lock_irqsave(&il->reg_lock, reg_flags); - _il_grab_nic_access(il); - value = _il_rd(il, reg); - _il_release_nic_access(il); - spin_unlock_irqrestore(&il->reg_lock, reg_flags); - return value; - -} - -static inline void -il_wr(struct il_priv *il, u32 reg, u32 value) -{ - unsigned long reg_flags; - - spin_lock_irqsave(&il->reg_lock, reg_flags); - if (!_il_grab_nic_access(il)) { - _il_wr(il, reg, value); - _il_release_nic_access(il); - } - spin_unlock_irqrestore(&il->reg_lock, reg_flags); -} - -static inline void il_write_reg_buf(struct il_priv *il, - u32 reg, u32 len, u32 *values) -{ - u32 count = sizeof(u32); - - if (il != NULL && values != NULL) { - for (; 0 < len; len -= count, reg += count, values++) - il_wr(il, reg, *values); - } -} - -static inline int il_poll_bit(struct il_priv *il, u32 addr, - u32 mask, int timeout) -{ - int t = 0; - - do { - if ((il_rd(il, addr) & mask) == mask) - return t; - udelay(IL_POLL_INTERVAL); - t += IL_POLL_INTERVAL; - } while (t < timeout); - - return -ETIMEDOUT; -} - -static inline u32 _il_rd_prph(struct il_priv *il, u32 reg) -{ - _il_wr(il, HBUS_TARG_PRPH_RADDR, reg | (3 << 24)); - rmb(); - return _il_rd(il, HBUS_TARG_PRPH_RDAT); -} - -static inline u32 il_rd_prph(struct il_priv *il, u32 reg) -{ - unsigned long reg_flags; - u32 val; - - spin_lock_irqsave(&il->reg_lock, reg_flags); - _il_grab_nic_access(il); - val = _il_rd_prph(il, reg); - _il_release_nic_access(il); - spin_unlock_irqrestore(&il->reg_lock, reg_flags); - return val; -} - -static inline void _il_wr_prph(struct il_priv *il, - u32 addr, u32 val) -{ - _il_wr(il, HBUS_TARG_PRPH_WADDR, - ((addr & 0x0000FFFF) | (3 << 24))); - wmb(); - _il_wr(il, HBUS_TARG_PRPH_WDAT, val); -} - -static inline void -il_wr_prph(struct il_priv *il, u32 addr, u32 val) -{ - unsigned long reg_flags; - - spin_lock_irqsave(&il->reg_lock, reg_flags); - if (!_il_grab_nic_access(il)) { - _il_wr_prph(il, addr, val); - _il_release_nic_access(il); - } - spin_unlock_irqrestore(&il->reg_lock, reg_flags); -} - -#define _il_set_bits_prph(il, reg, mask) \ -_il_wr_prph(il, reg, (_il_rd_prph(il, reg) | mask)) - -static inline void -il_set_bits_prph(struct il_priv *il, u32 reg, u32 mask) -{ - unsigned long reg_flags; - - spin_lock_irqsave(&il->reg_lock, reg_flags); - _il_grab_nic_access(il); - _il_set_bits_prph(il, reg, mask); - _il_release_nic_access(il); - spin_unlock_irqrestore(&il->reg_lock, reg_flags); -} - -#define _il_set_bits_mask_prph(il, reg, bits, mask) \ -_il_wr_prph(il, reg, \ - ((_il_rd_prph(il, reg) & mask) | bits)) - -static inline void il_set_bits_mask_prph(struct il_priv *il, u32 reg, - u32 bits, u32 mask) -{ - unsigned long reg_flags; - - spin_lock_irqsave(&il->reg_lock, reg_flags); - _il_grab_nic_access(il); - _il_set_bits_mask_prph(il, reg, bits, mask); - _il_release_nic_access(il); - spin_unlock_irqrestore(&il->reg_lock, reg_flags); -} - -static inline void il_clear_bits_prph(struct il_priv - *il, u32 reg, u32 mask) -{ - unsigned long reg_flags; - u32 val; - - spin_lock_irqsave(&il->reg_lock, reg_flags); - _il_grab_nic_access(il); - val = _il_rd_prph(il, reg); - _il_wr_prph(il, reg, (val & ~mask)); - _il_release_nic_access(il); - spin_unlock_irqrestore(&il->reg_lock, reg_flags); -} - -static inline u32 il_read_targ_mem(struct il_priv *il, u32 addr) -{ - unsigned long reg_flags; - u32 value; - - spin_lock_irqsave(&il->reg_lock, reg_flags); - _il_grab_nic_access(il); - - _il_wr(il, HBUS_TARG_MEM_RADDR, addr); - rmb(); - value = _il_rd(il, HBUS_TARG_MEM_RDAT); - - _il_release_nic_access(il); - spin_unlock_irqrestore(&il->reg_lock, reg_flags); - return value; -} - -static inline void -il_write_targ_mem(struct il_priv *il, u32 addr, u32 val) -{ - unsigned long reg_flags; - - spin_lock_irqsave(&il->reg_lock, reg_flags); - if (!_il_grab_nic_access(il)) { - _il_wr(il, HBUS_TARG_MEM_WADDR, addr); - wmb(); - _il_wr(il, HBUS_TARG_MEM_WDAT, val); - _il_release_nic_access(il); - } - spin_unlock_irqrestore(&il->reg_lock, reg_flags); -} - -static inline void -il_write_targ_mem_buf(struct il_priv *il, u32 addr, - u32 len, u32 *values) -{ - unsigned long reg_flags; - - spin_lock_irqsave(&il->reg_lock, reg_flags); - if (!_il_grab_nic_access(il)) { - _il_wr(il, HBUS_TARG_MEM_WADDR, addr); - wmb(); - for (; 0 < len; len -= sizeof(u32), values++) - _il_wr(il, - HBUS_TARG_MEM_WDAT, *values); - - _il_release_nic_access(il); - } - spin_unlock_irqrestore(&il->reg_lock, reg_flags); -} -#endif diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.h b/drivers/net/wireless/iwlegacy/iwl-sta.h deleted file mode 100644 index afd3003f654b..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-sta.h +++ /dev/null @@ -1,146 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * Portions of this file are derived from the ipw3945 project, as well - * as portions of the ieee80211 subsystem header files. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ -#ifndef __il_sta_h__ -#define __il_sta_h__ - -#include "iwl-dev.h" - -#define HW_KEY_DYNAMIC 0 -#define HW_KEY_DEFAULT 1 - -#define IL_STA_DRIVER_ACTIVE BIT(0) /* driver entry is active */ -#define IL_STA_UCODE_ACTIVE BIT(1) /* ucode entry is active */ -#define IL_STA_UCODE_INPROGRESS BIT(2) /* ucode entry is in process of - being activated */ -#define IL_STA_LOCAL BIT(3) /* station state not directed by mac80211; - (this is for the IBSS BSSID stations) */ -#define IL_STA_BCAST BIT(4) /* this station is the special bcast station */ - - -void il_restore_stations(struct il_priv *il, - struct il_rxon_context *ctx); -void il_clear_ucode_stations(struct il_priv *il, - struct il_rxon_context *ctx); -void il_dealloc_bcast_stations(struct il_priv *il); -int il_get_free_ucode_key_idx(struct il_priv *il); -int il_send_add_sta(struct il_priv *il, - struct il_addsta_cmd *sta, u8 flags); -int il_add_station_common(struct il_priv *il, - struct il_rxon_context *ctx, - const u8 *addr, bool is_ap, - struct ieee80211_sta *sta, u8 *sta_id_r); -int il_remove_station(struct il_priv *il, - const u8 sta_id, - const u8 *addr); -int il_mac_sta_remove(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta); - -u8 il_prep_station(struct il_priv *il, - struct il_rxon_context *ctx, - const u8 *addr, bool is_ap, - struct ieee80211_sta *sta); - -int il_send_lq_cmd(struct il_priv *il, - struct il_rxon_context *ctx, - struct il_link_quality_cmd *lq, - u8 flags, bool init); - -/** - * il_clear_driver_stations - clear knowledge of all stations from driver - * @il: iwl il struct - * - * This is called during il_down() to make sure that in the case - * we're coming there from a hardware restart mac80211 will be - * able to reconfigure stations -- if we're getting there in the - * normal down flow then the stations will already be cleared. - */ -static inline void il_clear_driver_stations(struct il_priv *il) -{ - unsigned long flags; - struct il_rxon_context *ctx = &il->ctx; - - spin_lock_irqsave(&il->sta_lock, flags); - memset(il->stations, 0, sizeof(il->stations)); - il->num_stations = 0; - - il->ucode_key_table = 0; - - /* - * Remove all key information that is not stored as part - * of station information since mac80211 may not have had - * a chance to remove all the keys. When device is - * reconfigured by mac80211 after an error all keys will - * be reconfigured. - */ - memset(ctx->wep_keys, 0, sizeof(ctx->wep_keys)); - ctx->key_mapping_keys = 0; - - spin_unlock_irqrestore(&il->sta_lock, flags); -} - -static inline int il_sta_id(struct ieee80211_sta *sta) -{ - if (WARN_ON(!sta)) - return IL_INVALID_STATION; - - return ((struct il_station_priv_common *)sta->drv_priv)->sta_id; -} - -/** - * il_sta_id_or_broadcast - return sta_id or broadcast sta - * @il: iwl il - * @context: the current context - * @sta: mac80211 station - * - * In certain circumstances mac80211 passes a station pointer - * that may be %NULL, for example during TX or key setup. In - * that case, we need to use the broadcast station, so this - * inline wraps that pattern. - */ -static inline int il_sta_id_or_broadcast(struct il_priv *il, - struct il_rxon_context *context, - struct ieee80211_sta *sta) -{ - int sta_id; - - if (!sta) - return context->bcast_sta_id; - - sta_id = il_sta_id(sta); - - /* - * mac80211 should not be passing a partially - * initialised station! - */ - WARN_ON(sta_id == IL_INVALID_STATION); - - return sta_id; -} -#endif /* __il_sta_h__ */ -- cgit v1.2.3 From f44cfaf330b911b43f0763d1932ba0b4e0e353a1 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 13:24:32 +0200 Subject: iwlegacy: remove iwl-helpers.h This file was already merged into common.h Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/iwl-helpers.h | 187 ---------------------------- 1 file changed, 187 deletions(-) delete mode 100644 drivers/net/wireless/iwlegacy/iwl-helpers.h (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/iwl-helpers.h b/drivers/net/wireless/iwlegacy/iwl-helpers.h deleted file mode 100644 index 2db83fc32103..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-helpers.h +++ /dev/null @@ -1,187 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * Portions of this file are derived from the ipw3945 project, as well - * as portions of the ieee80211 subsystem header files. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#ifndef __il_helpers_h__ -#define __il_helpers_h__ - -#include -#include - -#include "iwl-io.h" - -/** - * il_queue_inc_wrap - increment queue idx, wrap back to beginning - * @idx -- current idx - * @n_bd -- total number of entries in queue (must be power of 2) - */ -static inline int il_queue_inc_wrap(int idx, int n_bd) -{ - return ++idx & (n_bd - 1); -} - -/** - * il_queue_dec_wrap - decrement queue idx, wrap back to end - * @idx -- current idx - * @n_bd -- total number of entries in queue (must be power of 2) - */ -static inline int il_queue_dec_wrap(int idx, int n_bd) -{ - return --idx & (n_bd - 1); -} - -/* TODO: Move fw_desc functions to iwl-pci.ko */ -static inline void il_free_fw_desc(struct pci_dev *pci_dev, - struct fw_desc *desc) -{ - if (desc->v_addr) - dma_free_coherent(&pci_dev->dev, desc->len, - desc->v_addr, desc->p_addr); - desc->v_addr = NULL; - desc->len = 0; -} - -static inline int il_alloc_fw_desc(struct pci_dev *pci_dev, - struct fw_desc *desc) -{ - if (!desc->len) { - desc->v_addr = NULL; - return -EINVAL; - } - - desc->v_addr = dma_alloc_coherent(&pci_dev->dev, desc->len, - &desc->p_addr, GFP_KERNEL); - return (desc->v_addr != NULL) ? 0 : -ENOMEM; -} - -/* - * we have 8 bits used like this: - * - * 7 6 5 4 3 2 1 0 - * | | | | | | | | - * | | | | | | +-+-------- AC queue (0-3) - * | | | | | | - * | +-+-+-+-+------------ HW queue ID - * | - * +---------------------- unused - */ -static inline void -il_set_swq_id(struct il_tx_queue *txq, u8 ac, u8 hwq) -{ - BUG_ON(ac > 3); /* only have 2 bits */ - BUG_ON(hwq > 31); /* only use 5 bits */ - - txq->swq_id = (hwq << 2) | ac; -} - -static inline void il_wake_queue(struct il_priv *il, - struct il_tx_queue *txq) -{ - u8 queue = txq->swq_id; - u8 ac = queue & 3; - u8 hwq = (queue >> 2) & 0x1f; - - if (test_and_clear_bit(hwq, il->queue_stopped)) - if (atomic_dec_return(&il->queue_stop_count[ac]) <= 0) - ieee80211_wake_queue(il->hw, ac); -} - -static inline void il_stop_queue(struct il_priv *il, - struct il_tx_queue *txq) -{ - u8 queue = txq->swq_id; - u8 ac = queue & 3; - u8 hwq = (queue >> 2) & 0x1f; - - if (!test_and_set_bit(hwq, il->queue_stopped)) - if (atomic_inc_return(&il->queue_stop_count[ac]) > 0) - ieee80211_stop_queue(il->hw, ac); -} - -#ifdef ieee80211_stop_queue -#undef ieee80211_stop_queue -#endif - -#define ieee80211_stop_queue DO_NOT_USE_ieee80211_stop_queue - -#ifdef ieee80211_wake_queue -#undef ieee80211_wake_queue -#endif - -#define ieee80211_wake_queue DO_NOT_USE_ieee80211_wake_queue - -static inline void il_disable_interrupts(struct il_priv *il) -{ - clear_bit(S_INT_ENABLED, &il->status); - - /* disable interrupts from uCode/NIC to host */ - _il_wr(il, CSR_INT_MASK, 0x00000000); - - /* acknowledge/clear/reset any interrupts still pending - * from uCode or flow handler (Rx/Tx DMA) */ - _il_wr(il, CSR_INT, 0xffffffff); - _il_wr(il, CSR_FH_INT_STATUS, 0xffffffff); - D_ISR("Disabled interrupts\n"); -} - -static inline void il_enable_rfkill_int(struct il_priv *il) -{ - D_ISR("Enabling rfkill interrupt\n"); - _il_wr(il, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); -} - -static inline void il_enable_interrupts(struct il_priv *il) -{ - D_ISR("Enabling interrupts\n"); - set_bit(S_INT_ENABLED, &il->status); - _il_wr(il, CSR_INT_MASK, il->inta_mask); -} - -/** - * il_beacon_time_mask_low - mask of lower 32 bit of beacon time - * @il -- pointer to il_priv data structure - * @tsf_bits -- number of bits need to shift for masking) - */ -static inline u32 il_beacon_time_mask_low(struct il_priv *il, - u16 tsf_bits) -{ - return (1 << tsf_bits) - 1; -} - -/** - * il_beacon_time_mask_high - mask of higher 32 bit of beacon time - * @il -- pointer to il_priv data structure - * @tsf_bits -- number of bits need to shift for masking) - */ -static inline u32 il_beacon_time_mask_high(struct il_priv *il, - u16 tsf_bits) -{ - return ((1 << (32 - tsf_bits)) - 1) << tsf_bits; -} - -#endif /* __il_helpers_h__ */ -- cgit v1.2.3 From 3fbbf9a8083049718c44e43dc88c8e79cb0b7793 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 13:39:29 +0200 Subject: iwlegacy: merge iwl-legacy-rs.h into common.h Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/common.h | 461 ++++++++++++++++++++++++-- drivers/net/wireless/iwlegacy/iwl-legacy-rs.h | 454 ------------------------- 2 files changed, 442 insertions(+), 473 deletions(-) delete mode 100644 drivers/net/wireless/iwlegacy/iwl-legacy-rs.h (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index e83c6ab39fcf..2e66929c34ef 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -39,7 +39,6 @@ #include "iwl-debug.h" #include "iwl-led.h" #include "iwl-power.h" -#include "iwl-legacy-rs.h" struct il_host_cmd; struct il_cmd; @@ -480,24 +479,6 @@ struct il_station_priv_common { u8 sta_id; }; -/* - * il_station_priv: Driver's ilate station information - * - * When mac80211 creates a station it reserves some space (hw->sta_data_size) - * in the structure for use by driver. This structure is places in that - * space. - * - * The common struct MUST be first because it is shared between - * 3945 and 4965! - */ -struct il_station_priv { - struct il_station_priv_common common; - struct il_lq_sta lq_sta; - atomic_t pending_frames; - bool client; - bool asleep; -}; - /** * struct il_vif_priv - driver's ilate per-interface information * @@ -2573,4 +2554,446 @@ struct il_tfd { #define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01 #define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02 +struct il_rate_info { + u8 plcp; /* uCode API: RATE_6M_PLCP, etc. */ + u8 plcp_siso; /* uCode API: RATE_SISO_6M_PLCP, etc. */ + u8 plcp_mimo2; /* uCode API: RATE_MIMO2_6M_PLCP, etc. */ + u8 ieee; /* MAC header: RATE_6M_IEEE, etc. */ + u8 prev_ieee; /* previous rate in IEEE speeds */ + u8 next_ieee; /* next rate in IEEE speeds */ + u8 prev_rs; /* previous rate used in rs algo */ + u8 next_rs; /* next rate used in rs algo */ + u8 prev_rs_tgg; /* previous rate used in TGG rs algo */ + u8 next_rs_tgg; /* next rate used in TGG rs algo */ +}; + +struct il3945_rate_info { + u8 plcp; /* uCode API: RATE_6M_PLCP, etc. */ + u8 ieee; /* MAC header: RATE_6M_IEEE, etc. */ + u8 prev_ieee; /* previous rate in IEEE speeds */ + u8 next_ieee; /* next rate in IEEE speeds */ + u8 prev_rs; /* previous rate used in rs algo */ + u8 next_rs; /* next rate used in rs algo */ + u8 prev_rs_tgg; /* previous rate used in TGG rs algo */ + u8 next_rs_tgg; /* next rate used in TGG rs algo */ + u8 table_rs_idx; /* idx in rate scale table cmd */ + u8 prev_table_rs; /* prev in rate table cmd */ +}; + + +/* + * These serve as idxes into + * struct il_rate_info il_rates[RATE_COUNT]; + */ +enum { + RATE_1M_IDX = 0, + RATE_2M_IDX, + RATE_5M_IDX, + RATE_11M_IDX, + RATE_6M_IDX, + RATE_9M_IDX, + RATE_12M_IDX, + RATE_18M_IDX, + RATE_24M_IDX, + RATE_36M_IDX, + RATE_48M_IDX, + RATE_54M_IDX, + RATE_60M_IDX, + RATE_COUNT, + RATE_COUNT_LEGACY = RATE_COUNT - 1, /* Excluding 60M */ + RATE_COUNT_3945 = RATE_COUNT - 1, + RATE_INVM_IDX = RATE_COUNT, + RATE_INVALID = RATE_COUNT, +}; + +enum { + RATE_6M_IDX_TBL = 0, + RATE_9M_IDX_TBL, + RATE_12M_IDX_TBL, + RATE_18M_IDX_TBL, + RATE_24M_IDX_TBL, + RATE_36M_IDX_TBL, + RATE_48M_IDX_TBL, + RATE_54M_IDX_TBL, + RATE_1M_IDX_TBL, + RATE_2M_IDX_TBL, + RATE_5M_IDX_TBL, + RATE_11M_IDX_TBL, + RATE_INVM_IDX_TBL = RATE_INVM_IDX - 1, +}; + +enum { + IL_FIRST_OFDM_RATE = RATE_6M_IDX, + IL39_LAST_OFDM_RATE = RATE_54M_IDX, + IL_LAST_OFDM_RATE = RATE_60M_IDX, + IL_FIRST_CCK_RATE = RATE_1M_IDX, + IL_LAST_CCK_RATE = RATE_11M_IDX, +}; + +/* #define vs. enum to keep from defaulting to 'large integer' */ +#define RATE_6M_MASK (1 << RATE_6M_IDX) +#define RATE_9M_MASK (1 << RATE_9M_IDX) +#define RATE_12M_MASK (1 << RATE_12M_IDX) +#define RATE_18M_MASK (1 << RATE_18M_IDX) +#define RATE_24M_MASK (1 << RATE_24M_IDX) +#define RATE_36M_MASK (1 << RATE_36M_IDX) +#define RATE_48M_MASK (1 << RATE_48M_IDX) +#define RATE_54M_MASK (1 << RATE_54M_IDX) +#define RATE_60M_MASK (1 << RATE_60M_IDX) +#define RATE_1M_MASK (1 << RATE_1M_IDX) +#define RATE_2M_MASK (1 << RATE_2M_IDX) +#define RATE_5M_MASK (1 << RATE_5M_IDX) +#define RATE_11M_MASK (1 << RATE_11M_IDX) + +/* uCode API values for legacy bit rates, both OFDM and CCK */ +enum { + RATE_6M_PLCP = 13, + RATE_9M_PLCP = 15, + RATE_12M_PLCP = 5, + RATE_18M_PLCP = 7, + RATE_24M_PLCP = 9, + RATE_36M_PLCP = 11, + RATE_48M_PLCP = 1, + RATE_54M_PLCP = 3, + RATE_60M_PLCP = 3,/*FIXME:RS:should be removed*/ + RATE_1M_PLCP = 10, + RATE_2M_PLCP = 20, + RATE_5M_PLCP = 55, + RATE_11M_PLCP = 110, + /*FIXME:RS:add RATE_LEGACY_INVM_PLCP = 0,*/ +}; + +/* uCode API values for OFDM high-throughput (HT) bit rates */ +enum { + RATE_SISO_6M_PLCP = 0, + RATE_SISO_12M_PLCP = 1, + RATE_SISO_18M_PLCP = 2, + RATE_SISO_24M_PLCP = 3, + RATE_SISO_36M_PLCP = 4, + RATE_SISO_48M_PLCP = 5, + RATE_SISO_54M_PLCP = 6, + RATE_SISO_60M_PLCP = 7, + RATE_MIMO2_6M_PLCP = 0x8, + RATE_MIMO2_12M_PLCP = 0x9, + RATE_MIMO2_18M_PLCP = 0xa, + RATE_MIMO2_24M_PLCP = 0xb, + RATE_MIMO2_36M_PLCP = 0xc, + RATE_MIMO2_48M_PLCP = 0xd, + RATE_MIMO2_54M_PLCP = 0xe, + RATE_MIMO2_60M_PLCP = 0xf, + RATE_SISO_INVM_PLCP, + RATE_MIMO2_INVM_PLCP = RATE_SISO_INVM_PLCP, +}; + +/* MAC header values for bit rates */ +enum { + RATE_6M_IEEE = 12, + RATE_9M_IEEE = 18, + RATE_12M_IEEE = 24, + RATE_18M_IEEE = 36, + RATE_24M_IEEE = 48, + RATE_36M_IEEE = 72, + RATE_48M_IEEE = 96, + RATE_54M_IEEE = 108, + RATE_60M_IEEE = 120, + RATE_1M_IEEE = 2, + RATE_2M_IEEE = 4, + RATE_5M_IEEE = 11, + RATE_11M_IEEE = 22, +}; + +#define IL_CCK_BASIC_RATES_MASK \ + (RATE_1M_MASK | \ + RATE_2M_MASK) + +#define IL_CCK_RATES_MASK \ + (IL_CCK_BASIC_RATES_MASK | \ + RATE_5M_MASK | \ + RATE_11M_MASK) + +#define IL_OFDM_BASIC_RATES_MASK \ + (RATE_6M_MASK | \ + RATE_12M_MASK | \ + RATE_24M_MASK) + +#define IL_OFDM_RATES_MASK \ + (IL_OFDM_BASIC_RATES_MASK | \ + RATE_9M_MASK | \ + RATE_18M_MASK | \ + RATE_36M_MASK | \ + RATE_48M_MASK | \ + RATE_54M_MASK) + +#define IL_BASIC_RATES_MASK \ + (IL_OFDM_BASIC_RATES_MASK | \ + IL_CCK_BASIC_RATES_MASK) + +#define RATES_MASK ((1 << RATE_COUNT) - 1) +#define RATES_MASK_3945 ((1 << RATE_COUNT_3945) - 1) + +#define IL_INVALID_VALUE -1 + +#define IL_MIN_RSSI_VAL -100 +#define IL_MAX_RSSI_VAL 0 + +/* These values specify how many Tx frame attempts before + * searching for a new modulation mode */ +#define IL_LEGACY_FAILURE_LIMIT 160 +#define IL_LEGACY_SUCCESS_LIMIT 480 +#define IL_LEGACY_TBL_COUNT 160 + +#define IL_NONE_LEGACY_FAILURE_LIMIT 400 +#define IL_NONE_LEGACY_SUCCESS_LIMIT 4500 +#define IL_NONE_LEGACY_TBL_COUNT 1500 + +/* Success ratio (ACKed / attempted tx frames) values (perfect is 128 * 100) */ +#define IL_RS_GOOD_RATIO 12800 /* 100% */ +#define RATE_SCALE_SWITCH 10880 /* 85% */ +#define RATE_HIGH_TH 10880 /* 85% */ +#define RATE_INCREASE_TH 6400 /* 50% */ +#define RATE_DECREASE_TH 1920 /* 15% */ + +/* possible actions when in legacy mode */ +#define IL_LEGACY_SWITCH_ANTENNA1 0 +#define IL_LEGACY_SWITCH_ANTENNA2 1 +#define IL_LEGACY_SWITCH_SISO 2 +#define IL_LEGACY_SWITCH_MIMO2_AB 3 +#define IL_LEGACY_SWITCH_MIMO2_AC 4 +#define IL_LEGACY_SWITCH_MIMO2_BC 5 + +/* possible actions when in siso mode */ +#define IL_SISO_SWITCH_ANTENNA1 0 +#define IL_SISO_SWITCH_ANTENNA2 1 +#define IL_SISO_SWITCH_MIMO2_AB 2 +#define IL_SISO_SWITCH_MIMO2_AC 3 +#define IL_SISO_SWITCH_MIMO2_BC 4 +#define IL_SISO_SWITCH_GI 5 + +/* possible actions when in mimo mode */ +#define IL_MIMO2_SWITCH_ANTENNA1 0 +#define IL_MIMO2_SWITCH_ANTENNA2 1 +#define IL_MIMO2_SWITCH_SISO_A 2 +#define IL_MIMO2_SWITCH_SISO_B 3 +#define IL_MIMO2_SWITCH_SISO_C 4 +#define IL_MIMO2_SWITCH_GI 5 + +#define IL_MAX_SEARCH IL_MIMO2_SWITCH_GI + +#define IL_ACTION_LIMIT 3 /* # possible actions */ + +#define LQ_SIZE 2 /* 2 mode tables: "Active" and "Search" */ + +/* load per tid defines for A-MPDU activation */ +#define IL_AGG_TPT_THREHOLD 0 +#define IL_AGG_LOAD_THRESHOLD 10 +#define IL_AGG_ALL_TID 0xff +#define TID_QUEUE_CELL_SPACING 50 /*mS */ +#define TID_QUEUE_MAX_SIZE 20 +#define TID_ROUND_VALUE 5 /* mS */ +#define TID_MAX_LOAD_COUNT 8 + +#define TID_MAX_TIME_DIFF ((TID_QUEUE_MAX_SIZE - 1) * TID_QUEUE_CELL_SPACING) +#define TIME_WRAP_AROUND(x, y) (((y) > (x)) ? (y) - (x) : (0-(x)) + (y)) + +extern const struct il_rate_info il_rates[RATE_COUNT]; + +enum il_table_type { + LQ_NONE, + LQ_G, /* legacy types */ + LQ_A, + LQ_SISO, /* high-throughput types */ + LQ_MIMO2, + LQ_MAX, +}; + +#define is_legacy(tbl) ((tbl) == LQ_G || (tbl) == LQ_A) +#define is_siso(tbl) ((tbl) == LQ_SISO) +#define is_mimo2(tbl) ((tbl) == LQ_MIMO2) +#define is_mimo(tbl) (is_mimo2(tbl)) +#define is_Ht(tbl) (is_siso(tbl) || is_mimo(tbl)) +#define is_a_band(tbl) ((tbl) == LQ_A) +#define is_g_and(tbl) ((tbl) == LQ_G) + +#define ANT_NONE 0x0 +#define ANT_A BIT(0) +#define ANT_B BIT(1) +#define ANT_AB (ANT_A | ANT_B) +#define ANT_C BIT(2) +#define ANT_AC (ANT_A | ANT_C) +#define ANT_BC (ANT_B | ANT_C) +#define ANT_ABC (ANT_AB | ANT_C) + +#define IL_MAX_MCS_DISPLAY_SIZE 12 + +struct il_rate_mcs_info { + char mbps[IL_MAX_MCS_DISPLAY_SIZE]; + char mcs[IL_MAX_MCS_DISPLAY_SIZE]; +}; + +/** + * struct il_rate_scale_data -- tx success history for one rate + */ +struct il_rate_scale_data { + u64 data; /* bitmap of successful frames */ + s32 success_counter; /* number of frames successful */ + s32 success_ratio; /* per-cent * 128 */ + s32 counter; /* number of frames attempted */ + s32 average_tpt; /* success ratio * expected throughput */ + unsigned long stamp; +}; + +/** + * struct il_scale_tbl_info -- tx params and success history for all rates + * + * There are two of these in struct il_lq_sta, + * one for "active", and one for "search". + */ +struct il_scale_tbl_info { + enum il_table_type lq_type; + u8 ant_type; + u8 is_SGI; /* 1 = short guard interval */ + u8 is_ht40; /* 1 = 40 MHz channel width */ + u8 is_dup; /* 1 = duplicated data streams */ + u8 action; /* change modulation; IL_[LEGACY/SISO/MIMO]_SWITCH_* */ + u8 max_search; /* maximun number of tables we can search */ + s32 *expected_tpt; /* throughput metrics; expected_tpt_G, etc. */ + u32 current_rate; /* rate_n_flags, uCode API format */ + struct il_rate_scale_data win[RATE_COUNT]; /* rate histories */ +}; + +struct il_traffic_load { + unsigned long time_stamp; /* age of the oldest stats */ + u32 packet_count[TID_QUEUE_MAX_SIZE]; /* packet count in this time + * slice */ + u32 total; /* total num of packets during the + * last TID_MAX_TIME_DIFF */ + u8 queue_count; /* number of queues that has + * been used since the last cleanup */ + u8 head; /* start of the circular buffer */ +}; + +/** + * struct il_lq_sta -- driver's rate scaling ilate structure + * + * Pointer to this gets passed back and forth between driver and mac80211. + */ +struct il_lq_sta { + u8 active_tbl; /* idx of active table, range 0-1 */ + u8 enable_counter; /* indicates HT mode */ + u8 stay_in_tbl; /* 1: disallow, 0: allow search for new mode */ + u8 search_better_tbl; /* 1: currently trying alternate mode */ + s32 last_tpt; + + /* The following determine when to search for a new mode */ + u32 table_count_limit; + u32 max_failure_limit; /* # failed frames before new search */ + u32 max_success_limit; /* # successful frames before new search */ + u32 table_count; + u32 total_failed; /* total failed frames, any/all rates */ + u32 total_success; /* total successful frames, any/all rates */ + u64 flush_timer; /* time staying in mode before new search */ + + u8 action_counter; /* # mode-switch actions tried */ + u8 is_green; + u8 is_dup; + enum ieee80211_band band; + + /* The following are bitmaps of rates; RATE_6M_MASK, etc. */ + u32 supp_rates; + u16 active_legacy_rate; + u16 active_siso_rate; + u16 active_mimo2_rate; + s8 max_rate_idx; /* Max rate set by user */ + u8 missed_rate_counter; + + struct il_link_quality_cmd lq; + struct il_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */ + struct il_traffic_load load[TID_MAX_LOAD_COUNT]; + u8 tx_agg_tid_en; +#ifdef CONFIG_MAC80211_DEBUGFS + struct dentry *rs_sta_dbgfs_scale_table_file; + struct dentry *rs_sta_dbgfs_stats_table_file; + struct dentry *rs_sta_dbgfs_rate_scale_data_file; + struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file; + u32 dbg_fixed_rate; +#endif + struct il_priv *drv; + + /* used to be in sta_info */ + int last_txrate_idx; + /* last tx rate_n_flags */ + u32 last_rate_n_flags; + /* packets destined for this STA are aggregated */ + u8 is_agg; +}; + +/* + * il_station_priv: Driver's ilate station information + * + * When mac80211 creates a station it reserves some space (hw->sta_data_size) + * in the structure for use by driver. This structure is places in that + * space. + * + * The common struct MUST be first because it is shared between + * 3945 and 4965! + */ +struct il_station_priv { + struct il_station_priv_common common; + struct il_lq_sta lq_sta; + atomic_t pending_frames; + bool client; + bool asleep; +}; + +static inline u8 il4965_num_of_ant(u8 m) +{ + return !!(m & ANT_A) + !!(m & ANT_B) + !!(m & ANT_C); +} + +static inline u8 il4965_first_antenna(u8 mask) +{ + if (mask & ANT_A) + return ANT_A; + if (mask & ANT_B) + return ANT_B; + return ANT_C; +} + + +/** + * il3945_rate_scale_init - Initialize the rate scale table based on assoc info + * + * The specific throughput table used is based on the type of network + * the associated with, including A, B, G, and G w/ TGG protection + */ +extern void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id); + +/* Initialize station's rate scaling information after adding station */ +extern void il4965_rs_rate_init(struct il_priv *il, + struct ieee80211_sta *sta, u8 sta_id); +extern void il3945_rs_rate_init(struct il_priv *il, + struct ieee80211_sta *sta, u8 sta_id); + +/** + * il_rate_control_register - Register the rate control algorithm callbacks + * + * Since the rate control algorithm is hardware specific, there is no need + * or reason to place it as a stand alone module. The driver can call + * il_rate_control_register in order to register the rate control callbacks + * with the mac80211 subsystem. This should be performed prior to calling + * ieee80211_register_hw + * + */ +extern int il4965_rate_control_register(void); +extern int il3945_rate_control_register(void); + +/** + * il_rate_control_unregister - Unregister the rate control callbacks + * + * This should be called after calling ieee80211_unregister_hw, but before + * the driver is unloaded. + */ +extern void il4965_rate_control_unregister(void); +extern void il3945_rate_control_unregister(void); + #endif /* __il_core_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h deleted file mode 100644 index 58e04cb8b0ed..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h +++ /dev/null @@ -1,454 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#ifndef __il_rs_h__ -#define __il_rs_h__ - -struct il_rate_info { - u8 plcp; /* uCode API: RATE_6M_PLCP, etc. */ - u8 plcp_siso; /* uCode API: RATE_SISO_6M_PLCP, etc. */ - u8 plcp_mimo2; /* uCode API: RATE_MIMO2_6M_PLCP, etc. */ - u8 ieee; /* MAC header: RATE_6M_IEEE, etc. */ - u8 prev_ieee; /* previous rate in IEEE speeds */ - u8 next_ieee; /* next rate in IEEE speeds */ - u8 prev_rs; /* previous rate used in rs algo */ - u8 next_rs; /* next rate used in rs algo */ - u8 prev_rs_tgg; /* previous rate used in TGG rs algo */ - u8 next_rs_tgg; /* next rate used in TGG rs algo */ -}; - -struct il3945_rate_info { - u8 plcp; /* uCode API: RATE_6M_PLCP, etc. */ - u8 ieee; /* MAC header: RATE_6M_IEEE, etc. */ - u8 prev_ieee; /* previous rate in IEEE speeds */ - u8 next_ieee; /* next rate in IEEE speeds */ - u8 prev_rs; /* previous rate used in rs algo */ - u8 next_rs; /* next rate used in rs algo */ - u8 prev_rs_tgg; /* previous rate used in TGG rs algo */ - u8 next_rs_tgg; /* next rate used in TGG rs algo */ - u8 table_rs_idx; /* idx in rate scale table cmd */ - u8 prev_table_rs; /* prev in rate table cmd */ -}; - - -/* - * These serve as idxes into - * struct il_rate_info il_rates[RATE_COUNT]; - */ -enum { - RATE_1M_IDX = 0, - RATE_2M_IDX, - RATE_5M_IDX, - RATE_11M_IDX, - RATE_6M_IDX, - RATE_9M_IDX, - RATE_12M_IDX, - RATE_18M_IDX, - RATE_24M_IDX, - RATE_36M_IDX, - RATE_48M_IDX, - RATE_54M_IDX, - RATE_60M_IDX, - RATE_COUNT, - RATE_COUNT_LEGACY = RATE_COUNT - 1, /* Excluding 60M */ - RATE_COUNT_3945 = RATE_COUNT - 1, - RATE_INVM_IDX = RATE_COUNT, - RATE_INVALID = RATE_COUNT, -}; - -enum { - RATE_6M_IDX_TBL = 0, - RATE_9M_IDX_TBL, - RATE_12M_IDX_TBL, - RATE_18M_IDX_TBL, - RATE_24M_IDX_TBL, - RATE_36M_IDX_TBL, - RATE_48M_IDX_TBL, - RATE_54M_IDX_TBL, - RATE_1M_IDX_TBL, - RATE_2M_IDX_TBL, - RATE_5M_IDX_TBL, - RATE_11M_IDX_TBL, - RATE_INVM_IDX_TBL = RATE_INVM_IDX - 1, -}; - -enum { - IL_FIRST_OFDM_RATE = RATE_6M_IDX, - IL39_LAST_OFDM_RATE = RATE_54M_IDX, - IL_LAST_OFDM_RATE = RATE_60M_IDX, - IL_FIRST_CCK_RATE = RATE_1M_IDX, - IL_LAST_CCK_RATE = RATE_11M_IDX, -}; - -/* #define vs. enum to keep from defaulting to 'large integer' */ -#define RATE_6M_MASK (1 << RATE_6M_IDX) -#define RATE_9M_MASK (1 << RATE_9M_IDX) -#define RATE_12M_MASK (1 << RATE_12M_IDX) -#define RATE_18M_MASK (1 << RATE_18M_IDX) -#define RATE_24M_MASK (1 << RATE_24M_IDX) -#define RATE_36M_MASK (1 << RATE_36M_IDX) -#define RATE_48M_MASK (1 << RATE_48M_IDX) -#define RATE_54M_MASK (1 << RATE_54M_IDX) -#define RATE_60M_MASK (1 << RATE_60M_IDX) -#define RATE_1M_MASK (1 << RATE_1M_IDX) -#define RATE_2M_MASK (1 << RATE_2M_IDX) -#define RATE_5M_MASK (1 << RATE_5M_IDX) -#define RATE_11M_MASK (1 << RATE_11M_IDX) - -/* uCode API values for legacy bit rates, both OFDM and CCK */ -enum { - RATE_6M_PLCP = 13, - RATE_9M_PLCP = 15, - RATE_12M_PLCP = 5, - RATE_18M_PLCP = 7, - RATE_24M_PLCP = 9, - RATE_36M_PLCP = 11, - RATE_48M_PLCP = 1, - RATE_54M_PLCP = 3, - RATE_60M_PLCP = 3,/*FIXME:RS:should be removed*/ - RATE_1M_PLCP = 10, - RATE_2M_PLCP = 20, - RATE_5M_PLCP = 55, - RATE_11M_PLCP = 110, - /*FIXME:RS:add RATE_LEGACY_INVM_PLCP = 0,*/ -}; - -/* uCode API values for OFDM high-throughput (HT) bit rates */ -enum { - RATE_SISO_6M_PLCP = 0, - RATE_SISO_12M_PLCP = 1, - RATE_SISO_18M_PLCP = 2, - RATE_SISO_24M_PLCP = 3, - RATE_SISO_36M_PLCP = 4, - RATE_SISO_48M_PLCP = 5, - RATE_SISO_54M_PLCP = 6, - RATE_SISO_60M_PLCP = 7, - RATE_MIMO2_6M_PLCP = 0x8, - RATE_MIMO2_12M_PLCP = 0x9, - RATE_MIMO2_18M_PLCP = 0xa, - RATE_MIMO2_24M_PLCP = 0xb, - RATE_MIMO2_36M_PLCP = 0xc, - RATE_MIMO2_48M_PLCP = 0xd, - RATE_MIMO2_54M_PLCP = 0xe, - RATE_MIMO2_60M_PLCP = 0xf, - RATE_SISO_INVM_PLCP, - RATE_MIMO2_INVM_PLCP = RATE_SISO_INVM_PLCP, -}; - -/* MAC header values for bit rates */ -enum { - RATE_6M_IEEE = 12, - RATE_9M_IEEE = 18, - RATE_12M_IEEE = 24, - RATE_18M_IEEE = 36, - RATE_24M_IEEE = 48, - RATE_36M_IEEE = 72, - RATE_48M_IEEE = 96, - RATE_54M_IEEE = 108, - RATE_60M_IEEE = 120, - RATE_1M_IEEE = 2, - RATE_2M_IEEE = 4, - RATE_5M_IEEE = 11, - RATE_11M_IEEE = 22, -}; - -#define IL_CCK_BASIC_RATES_MASK \ - (RATE_1M_MASK | \ - RATE_2M_MASK) - -#define IL_CCK_RATES_MASK \ - (IL_CCK_BASIC_RATES_MASK | \ - RATE_5M_MASK | \ - RATE_11M_MASK) - -#define IL_OFDM_BASIC_RATES_MASK \ - (RATE_6M_MASK | \ - RATE_12M_MASK | \ - RATE_24M_MASK) - -#define IL_OFDM_RATES_MASK \ - (IL_OFDM_BASIC_RATES_MASK | \ - RATE_9M_MASK | \ - RATE_18M_MASK | \ - RATE_36M_MASK | \ - RATE_48M_MASK | \ - RATE_54M_MASK) - -#define IL_BASIC_RATES_MASK \ - (IL_OFDM_BASIC_RATES_MASK | \ - IL_CCK_BASIC_RATES_MASK) - -#define RATES_MASK ((1 << RATE_COUNT) - 1) -#define RATES_MASK_3945 ((1 << RATE_COUNT_3945) - 1) - -#define IL_INVALID_VALUE -1 - -#define IL_MIN_RSSI_VAL -100 -#define IL_MAX_RSSI_VAL 0 - -/* These values specify how many Tx frame attempts before - * searching for a new modulation mode */ -#define IL_LEGACY_FAILURE_LIMIT 160 -#define IL_LEGACY_SUCCESS_LIMIT 480 -#define IL_LEGACY_TBL_COUNT 160 - -#define IL_NONE_LEGACY_FAILURE_LIMIT 400 -#define IL_NONE_LEGACY_SUCCESS_LIMIT 4500 -#define IL_NONE_LEGACY_TBL_COUNT 1500 - -/* Success ratio (ACKed / attempted tx frames) values (perfect is 128 * 100) */ -#define IL_RS_GOOD_RATIO 12800 /* 100% */ -#define RATE_SCALE_SWITCH 10880 /* 85% */ -#define RATE_HIGH_TH 10880 /* 85% */ -#define RATE_INCREASE_TH 6400 /* 50% */ -#define RATE_DECREASE_TH 1920 /* 15% */ - -/* possible actions when in legacy mode */ -#define IL_LEGACY_SWITCH_ANTENNA1 0 -#define IL_LEGACY_SWITCH_ANTENNA2 1 -#define IL_LEGACY_SWITCH_SISO 2 -#define IL_LEGACY_SWITCH_MIMO2_AB 3 -#define IL_LEGACY_SWITCH_MIMO2_AC 4 -#define IL_LEGACY_SWITCH_MIMO2_BC 5 - -/* possible actions when in siso mode */ -#define IL_SISO_SWITCH_ANTENNA1 0 -#define IL_SISO_SWITCH_ANTENNA2 1 -#define IL_SISO_SWITCH_MIMO2_AB 2 -#define IL_SISO_SWITCH_MIMO2_AC 3 -#define IL_SISO_SWITCH_MIMO2_BC 4 -#define IL_SISO_SWITCH_GI 5 - -/* possible actions when in mimo mode */ -#define IL_MIMO2_SWITCH_ANTENNA1 0 -#define IL_MIMO2_SWITCH_ANTENNA2 1 -#define IL_MIMO2_SWITCH_SISO_A 2 -#define IL_MIMO2_SWITCH_SISO_B 3 -#define IL_MIMO2_SWITCH_SISO_C 4 -#define IL_MIMO2_SWITCH_GI 5 - -#define IL_MAX_SEARCH IL_MIMO2_SWITCH_GI - -#define IL_ACTION_LIMIT 3 /* # possible actions */ - -#define LQ_SIZE 2 /* 2 mode tables: "Active" and "Search" */ - -/* load per tid defines for A-MPDU activation */ -#define IL_AGG_TPT_THREHOLD 0 -#define IL_AGG_LOAD_THRESHOLD 10 -#define IL_AGG_ALL_TID 0xff -#define TID_QUEUE_CELL_SPACING 50 /*mS */ -#define TID_QUEUE_MAX_SIZE 20 -#define TID_ROUND_VALUE 5 /* mS */ -#define TID_MAX_LOAD_COUNT 8 - -#define TID_MAX_TIME_DIFF ((TID_QUEUE_MAX_SIZE - 1) * TID_QUEUE_CELL_SPACING) -#define TIME_WRAP_AROUND(x, y) (((y) > (x)) ? (y) - (x) : (0-(x)) + (y)) - -extern const struct il_rate_info il_rates[RATE_COUNT]; - -enum il_table_type { - LQ_NONE, - LQ_G, /* legacy types */ - LQ_A, - LQ_SISO, /* high-throughput types */ - LQ_MIMO2, - LQ_MAX, -}; - -#define is_legacy(tbl) ((tbl) == LQ_G || (tbl) == LQ_A) -#define is_siso(tbl) ((tbl) == LQ_SISO) -#define is_mimo2(tbl) ((tbl) == LQ_MIMO2) -#define is_mimo(tbl) (is_mimo2(tbl)) -#define is_Ht(tbl) (is_siso(tbl) || is_mimo(tbl)) -#define is_a_band(tbl) ((tbl) == LQ_A) -#define is_g_and(tbl) ((tbl) == LQ_G) - -#define ANT_NONE 0x0 -#define ANT_A BIT(0) -#define ANT_B BIT(1) -#define ANT_AB (ANT_A | ANT_B) -#define ANT_C BIT(2) -#define ANT_AC (ANT_A | ANT_C) -#define ANT_BC (ANT_B | ANT_C) -#define ANT_ABC (ANT_AB | ANT_C) - -#define IL_MAX_MCS_DISPLAY_SIZE 12 - -struct il_rate_mcs_info { - char mbps[IL_MAX_MCS_DISPLAY_SIZE]; - char mcs[IL_MAX_MCS_DISPLAY_SIZE]; -}; - -/** - * struct il_rate_scale_data -- tx success history for one rate - */ -struct il_rate_scale_data { - u64 data; /* bitmap of successful frames */ - s32 success_counter; /* number of frames successful */ - s32 success_ratio; /* per-cent * 128 */ - s32 counter; /* number of frames attempted */ - s32 average_tpt; /* success ratio * expected throughput */ - unsigned long stamp; -}; - -/** - * struct il_scale_tbl_info -- tx params and success history for all rates - * - * There are two of these in struct il_lq_sta, - * one for "active", and one for "search". - */ -struct il_scale_tbl_info { - enum il_table_type lq_type; - u8 ant_type; - u8 is_SGI; /* 1 = short guard interval */ - u8 is_ht40; /* 1 = 40 MHz channel width */ - u8 is_dup; /* 1 = duplicated data streams */ - u8 action; /* change modulation; IL_[LEGACY/SISO/MIMO]_SWITCH_* */ - u8 max_search; /* maximun number of tables we can search */ - s32 *expected_tpt; /* throughput metrics; expected_tpt_G, etc. */ - u32 current_rate; /* rate_n_flags, uCode API format */ - struct il_rate_scale_data win[RATE_COUNT]; /* rate histories */ -}; - -struct il_traffic_load { - unsigned long time_stamp; /* age of the oldest stats */ - u32 packet_count[TID_QUEUE_MAX_SIZE]; /* packet count in this time - * slice */ - u32 total; /* total num of packets during the - * last TID_MAX_TIME_DIFF */ - u8 queue_count; /* number of queues that has - * been used since the last cleanup */ - u8 head; /* start of the circular buffer */ -}; - -/** - * struct il_lq_sta -- driver's rate scaling ilate structure - * - * Pointer to this gets passed back and forth between driver and mac80211. - */ -struct il_lq_sta { - u8 active_tbl; /* idx of active table, range 0-1 */ - u8 enable_counter; /* indicates HT mode */ - u8 stay_in_tbl; /* 1: disallow, 0: allow search for new mode */ - u8 search_better_tbl; /* 1: currently trying alternate mode */ - s32 last_tpt; - - /* The following determine when to search for a new mode */ - u32 table_count_limit; - u32 max_failure_limit; /* # failed frames before new search */ - u32 max_success_limit; /* # successful frames before new search */ - u32 table_count; - u32 total_failed; /* total failed frames, any/all rates */ - u32 total_success; /* total successful frames, any/all rates */ - u64 flush_timer; /* time staying in mode before new search */ - - u8 action_counter; /* # mode-switch actions tried */ - u8 is_green; - u8 is_dup; - enum ieee80211_band band; - - /* The following are bitmaps of rates; RATE_6M_MASK, etc. */ - u32 supp_rates; - u16 active_legacy_rate; - u16 active_siso_rate; - u16 active_mimo2_rate; - s8 max_rate_idx; /* Max rate set by user */ - u8 missed_rate_counter; - - struct il_link_quality_cmd lq; - struct il_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */ - struct il_traffic_load load[TID_MAX_LOAD_COUNT]; - u8 tx_agg_tid_en; -#ifdef CONFIG_MAC80211_DEBUGFS - struct dentry *rs_sta_dbgfs_scale_table_file; - struct dentry *rs_sta_dbgfs_stats_table_file; - struct dentry *rs_sta_dbgfs_rate_scale_data_file; - struct dentry *rs_sta_dbgfs_tx_agg_tid_en_file; - u32 dbg_fixed_rate; -#endif - struct il_priv *drv; - - /* used to be in sta_info */ - int last_txrate_idx; - /* last tx rate_n_flags */ - u32 last_rate_n_flags; - /* packets destined for this STA are aggregated */ - u8 is_agg; -}; - -static inline u8 il4965_num_of_ant(u8 m) -{ - return !!(m & ANT_A) + !!(m & ANT_B) + !!(m & ANT_C); -} - -static inline u8 il4965_first_antenna(u8 mask) -{ - if (mask & ANT_A) - return ANT_A; - if (mask & ANT_B) - return ANT_B; - return ANT_C; -} - - -/** - * il3945_rate_scale_init - Initialize the rate scale table based on assoc info - * - * The specific throughput table used is based on the type of network - * the associated with, including A, B, G, and G w/ TGG protection - */ -extern void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id); - -/* Initialize station's rate scaling information after adding station */ -extern void il4965_rs_rate_init(struct il_priv *il, - struct ieee80211_sta *sta, u8 sta_id); -extern void il3945_rs_rate_init(struct il_priv *il, - struct ieee80211_sta *sta, u8 sta_id); - -/** - * il_rate_control_register - Register the rate control algorithm callbacks - * - * Since the rate control algorithm is hardware specific, there is no need - * or reason to place it as a stand alone module. The driver can call - * il_rate_control_register in order to register the rate control callbacks - * with the mac80211 subsystem. This should be performed prior to calling - * ieee80211_register_hw - * - */ -extern int il4965_rate_control_register(void); -extern int il3945_rate_control_register(void); - -/** - * il_rate_control_unregister - Unregister the rate control callbacks - * - * This should be called after calling ieee80211_unregister_hw, but before - * the driver is unloaded. - */ -extern void il4965_rate_control_unregister(void); -extern void il3945_rate_control_unregister(void); - -#endif /* __il_rs__ */ -- cgit v1.2.3 From 99412002a07b63781adfc3d1272d3677841d4170 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 13:53:04 +0200 Subject: iwlegacy: merge iwl-power.h into common.h Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/3945.h | 1 - drivers/net/wireless/iwlegacy/commands.h | 2 ++ drivers/net/wireless/iwlegacy/common.c | 1 - drivers/net/wireless/iwlegacy/common.h | 11 ++++++- drivers/net/wireless/iwlegacy/iwl-power.h | 55 ------------------------------- 5 files changed, 12 insertions(+), 58 deletions(-) delete mode 100644 drivers/net/wireless/iwlegacy/iwl-power.h (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index 726ca2c5cd6a..22166bdbeeec 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -37,7 +37,6 @@ extern const struct pci_device_id il3945_hw_card_ids[]; #include "common.h" #include "iwl-prph.h" #include "iwl-debug.h" -#include "iwl-power.h" #include "iwl-led.h" #include "iwl-eeprom.h" diff --git a/drivers/net/wireless/iwlegacy/commands.h b/drivers/net/wireless/iwlegacy/commands.h index 2f64ed391681..9eb7a83bbf1b 100644 --- a/drivers/net/wireless/iwlegacy/commands.h +++ b/drivers/net/wireless/iwlegacy/commands.h @@ -64,6 +64,8 @@ #ifndef __il_commands_h__ #define __il_commands_h__ +#include + struct il_priv; /* uCode version contains 4 values: Major/Minor/API/Serial */ diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 4258bf6d5150..3b8d47c0d6b5 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -43,7 +43,6 @@ #include "iwl-eeprom.h" #include "iwl-debug.h" #include "common.h" -#include "iwl-power.h" const char *il_get_cmd_string(u8 cmd) { diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 2e66929c34ef..65c593d34bf0 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -33,12 +33,12 @@ #include #include +#include "commands.h" #include "iwl-eeprom.h" #include "csr.h" #include "iwl-prph.h" #include "iwl-debug.h" #include "iwl-led.h" -#include "iwl-power.h" struct il_host_cmd; struct il_cmd; @@ -938,6 +938,13 @@ struct il_rxon_context { } ht; }; +struct il_power_mgr { + struct il_powertable_cmd sleep_cmd; + struct il_powertable_cmd sleep_cmd_next; + int debug_sleep_level_override; + bool pci_pm; +}; + struct il_priv { /* ieee device used by generic ieee processing code */ @@ -2996,4 +3003,6 @@ extern int il3945_rate_control_register(void); extern void il4965_rate_control_unregister(void); extern void il3945_rate_control_unregister(void); +extern int il_power_update_mode(struct il_priv *il, bool force); +extern void il_power_initialize(struct il_priv *il); #endif /* __il_core_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-power.h b/drivers/net/wireless/iwlegacy/iwl-power.h deleted file mode 100644 index c0ae3fa6d774..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-power.h +++ /dev/null @@ -1,55 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved. - * - * Portions of this file are derived from the ipw3945 project, as well - * as portions of the ieee80211 subsystem header files. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - *****************************************************************************/ -#ifndef __il_power_setting_h__ -#define __il_power_setting_h__ - -#include "commands.h" - -enum il_power_level { - IL_POWER_IDX_1, - IL_POWER_IDX_2, - IL_POWER_IDX_3, - IL_POWER_IDX_4, - IL_POWER_IDX_5, - IL_POWER_NUM -}; - -struct il_power_mgr { - struct il_powertable_cmd sleep_cmd; - struct il_powertable_cmd sleep_cmd_next; - int debug_sleep_level_override; - bool pci_pm; -}; - -int -il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, - bool force); -int il_power_update_mode(struct il_priv *il, bool force); -void il_power_initialize(struct il_priv *il); - -#endif /* __il_power_setting_h__ */ -- cgit v1.2.3 From 47ef694dd47b1e97a0d766f3c74067bab3debfa5 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 14:04:45 +0200 Subject: iwlegacy: merge iwl-{eeprom,led}.h into common.h Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/3945.c | 3 - drivers/net/wireless/iwlegacy/3945.h | 2 - drivers/net/wireless/iwlegacy/4965-mac.c | 1 - drivers/net/wireless/iwlegacy/4965.c | 1 - drivers/net/wireless/iwlegacy/common.c | 1 - drivers/net/wireless/iwlegacy/common.h | 307 ++++++++++++++++++++++++- drivers/net/wireless/iwlegacy/iwl-eeprom.h | 344 ----------------------------- drivers/net/wireless/iwlegacy/iwl-led.h | 56 ----- 8 files changed, 303 insertions(+), 412 deletions(-) delete mode 100644 drivers/net/wireless/iwlegacy/iwl-eeprom.h delete mode 100644 drivers/net/wireless/iwlegacy/iwl-led.h (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 02ae32cc90de..b1ced05ab3d3 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -40,9 +40,6 @@ #include #include "common.h" -#include "commands.h" -#include "iwl-eeprom.h" -#include "iwl-led.h" #include "3945.h" /* Send led command */ diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index 22166bdbeeec..5e4fcbc2fab6 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -37,8 +37,6 @@ extern const struct pci_device_id il3945_hw_card_ids[]; #include "common.h" #include "iwl-prph.h" #include "iwl-debug.h" -#include "iwl-led.h" -#include "iwl-eeprom.h" /* Highest firmware API version supported */ #define IL3945_UCODE_API_MAX 2 diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 6848b9182a71..82b6a7b8624a 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -50,7 +50,6 @@ #define DRV_NAME "iwl4965" -#include "iwl-eeprom.h" #include "common.h" #include "4965.h" diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index d66d4e8c1e76..4b977177d8b6 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -38,7 +38,6 @@ #include #include "common.h" -#include "iwl-eeprom.h" #include "4965.h" #define IL_AC_UNSET -1 diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 3b8d47c0d6b5..5d5efcb4045e 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -40,7 +40,6 @@ #include #include -#include "iwl-eeprom.h" #include "iwl-debug.h" #include "common.h" diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 65c593d34bf0..8e4450edfa74 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -31,14 +31,13 @@ #include #include #include +#include #include #include "commands.h" -#include "iwl-eeprom.h" #include "csr.h" #include "iwl-prph.h" #include "iwl-debug.h" -#include "iwl-led.h" struct il_host_cmd; struct il_cmd; @@ -178,6 +177,281 @@ struct il_tx_queue { u8 swq_id; }; +/* + * EEPROM access time values: + * + * Driver initiates EEPROM read by writing byte address << 1 to CSR_EEPROM_REG. + * Driver then polls CSR_EEPROM_REG for CSR_EEPROM_REG_READ_VALID_MSK (0x1). + * When polling, wait 10 uSec between polling loops, up to a maximum 5000 uSec. + * Driver reads 16-bit value from bits 31-16 of CSR_EEPROM_REG. + */ +#define IL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */ + +#define IL_EEPROM_SEM_TIMEOUT 10 /* microseconds */ +#define IL_EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ + + +/* + * Regulatory channel usage flags in EEPROM struct il4965_eeprom_channel.flags. + * + * IBSS and/or AP operation is allowed *only* on those channels with + * (VALID && IBSS && ACTIVE && !RADAR). This restriction is in place because + * RADAR detection is not supported by the 4965 driver, but is a + * requirement for establishing a new network for legal operation on channels + * requiring RADAR detection or restricting ACTIVE scanning. + * + * NOTE: "WIDE" flag does not indicate anything about "HT40" 40 MHz channels. + * It only indicates that 20 MHz channel use is supported; HT40 channel + * usage is indicated by a separate set of regulatory flags for each + * HT40 channel pair. + * + * NOTE: Using a channel inappropriately will result in a uCode error! + */ +#define IL_NUM_TX_CALIB_GROUPS 5 +enum { + EEPROM_CHANNEL_VALID = (1 << 0), /* usable for this SKU/geo */ + EEPROM_CHANNEL_IBSS = (1 << 1), /* usable as an IBSS channel */ + /* Bit 2 Reserved */ + EEPROM_CHANNEL_ACTIVE = (1 << 3), /* active scanning allowed */ + EEPROM_CHANNEL_RADAR = (1 << 4), /* radar detection required */ + EEPROM_CHANNEL_WIDE = (1 << 5), /* 20 MHz channel okay */ + /* Bit 6 Reserved (was Narrow Channel) */ + EEPROM_CHANNEL_DFS = (1 << 7), /* dynamic freq selection candidate */ +}; + +/* SKU Capabilities */ +/* 3945 only */ +#define EEPROM_SKU_CAP_SW_RF_KILL_ENABLE (1 << 0) +#define EEPROM_SKU_CAP_HW_RF_KILL_ENABLE (1 << 1) + +/* *regulatory* channel data format in eeprom, one for each channel. + * There are separate entries for HT40 (40 MHz) vs. normal (20 MHz) channels. */ +struct il_eeprom_channel { + u8 flags; /* EEPROM_CHANNEL_* flags copied from EEPROM */ + s8 max_power_avg; /* max power (dBm) on this chnl, limit 31 */ +} __packed; + +/* 3945 Specific */ +#define EEPROM_3945_EEPROM_VERSION (0x2f) + +/* 4965 has two radio transmitters (and 3 radio receivers) */ +#define EEPROM_TX_POWER_TX_CHAINS (2) + +/* 4965 has room for up to 8 sets of txpower calibration data */ +#define EEPROM_TX_POWER_BANDS (8) + +/* 4965 factory calibration measures txpower gain settings for + * each of 3 target output levels */ +#define EEPROM_TX_POWER_MEASUREMENTS (3) + +/* 4965 Specific */ +/* 4965 driver does not work with txpower calibration version < 5 */ +#define EEPROM_4965_TX_POWER_VERSION (5) +#define EEPROM_4965_EEPROM_VERSION (0x2f) +#define EEPROM_4965_CALIB_VERSION_OFFSET (2*0xB6) /* 2 bytes */ +#define EEPROM_4965_CALIB_TXPOWER_OFFSET (2*0xE8) /* 48 bytes */ +#define EEPROM_4965_BOARD_REVISION (2*0x4F) /* 2 bytes */ +#define EEPROM_4965_BOARD_PBA (2*0x56+1) /* 9 bytes */ + +/* 2.4 GHz */ +extern const u8 il_eeprom_band_1[14]; + +/* + * factory calibration data for one txpower level, on one channel, + * measured on one of the 2 tx chains (radio transmitter and associated + * antenna). EEPROM contains: + * + * 1) Temperature (degrees Celsius) of device when measurement was made. + * + * 2) Gain table idx used to achieve the target measurement power. + * This refers to the "well-known" gain tables (see 4965.h). + * + * 3) Actual measured output power, in half-dBm ("34" = 17 dBm). + * + * 4) RF power amplifier detector level measurement (not used). + */ +struct il_eeprom_calib_measure { + u8 temperature; /* Device temperature (Celsius) */ + u8 gain_idx; /* Index into gain table */ + u8 actual_pow; /* Measured RF output power, half-dBm */ + s8 pa_det; /* Power amp detector level (not used) */ +} __packed; + + +/* + * measurement set for one channel. EEPROM contains: + * + * 1) Channel number measured + * + * 2) Measurements for each of 3 power levels for each of 2 radio transmitters + * (a.k.a. "tx chains") (6 measurements altogether) + */ +struct il_eeprom_calib_ch_info { + u8 ch_num; + struct il_eeprom_calib_measure + measurements[EEPROM_TX_POWER_TX_CHAINS] + [EEPROM_TX_POWER_MEASUREMENTS]; +} __packed; + +/* + * txpower subband info. + * + * For each frequency subband, EEPROM contains the following: + * + * 1) First and last channels within range of the subband. "0" values + * indicate that this sample set is not being used. + * + * 2) Sample measurement sets for 2 channels close to the range endpoints. + */ +struct il_eeprom_calib_subband_info { + u8 ch_from; /* channel number of lowest channel in subband */ + u8 ch_to; /* channel number of highest channel in subband */ + struct il_eeprom_calib_ch_info ch1; + struct il_eeprom_calib_ch_info ch2; +} __packed; + + +/* + * txpower calibration info. EEPROM contains: + * + * 1) Factory-measured saturation power levels (maximum levels at which + * tx power amplifier can output a signal without too much distortion). + * There is one level for 2.4 GHz band and one for 5 GHz band. These + * values apply to all channels within each of the bands. + * + * 2) Factory-measured power supply voltage level. This is assumed to be + * constant (i.e. same value applies to all channels/bands) while the + * factory measurements are being made. + * + * 3) Up to 8 sets of factory-measured txpower calibration values. + * These are for different frequency ranges, since txpower gain + * characteristics of the analog radio circuitry vary with frequency. + * + * Not all sets need to be filled with data; + * struct il_eeprom_calib_subband_info contains range of channels + * (0 if unused) for each set of data. + */ +struct il_eeprom_calib_info { + u8 saturation_power24; /* half-dBm (e.g. "34" = 17 dBm) */ + u8 saturation_power52; /* half-dBm */ + __le16 voltage; /* signed */ + struct il_eeprom_calib_subband_info + band_info[EEPROM_TX_POWER_BANDS]; +} __packed; + + +/* General */ +#define EEPROM_DEVICE_ID (2*0x08) /* 2 bytes */ +#define EEPROM_MAC_ADDRESS (2*0x15) /* 6 bytes */ +#define EEPROM_BOARD_REVISION (2*0x35) /* 2 bytes */ +#define EEPROM_BOARD_PBA_NUMBER (2*0x3B+1) /* 9 bytes */ +#define EEPROM_VERSION (2*0x44) /* 2 bytes */ +#define EEPROM_SKU_CAP (2*0x45) /* 2 bytes */ +#define EEPROM_OEM_MODE (2*0x46) /* 2 bytes */ +#define EEPROM_WOWLAN_MODE (2*0x47) /* 2 bytes */ +#define EEPROM_RADIO_CONFIG (2*0x48) /* 2 bytes */ +#define EEPROM_NUM_MAC_ADDRESS (2*0x4C) /* 2 bytes */ + +/* The following masks are to be applied on EEPROM_RADIO_CONFIG */ +#define EEPROM_RF_CFG_TYPE_MSK(x) (x & 0x3) /* bits 0-1 */ +#define EEPROM_RF_CFG_STEP_MSK(x) ((x >> 2) & 0x3) /* bits 2-3 */ +#define EEPROM_RF_CFG_DASH_MSK(x) ((x >> 4) & 0x3) /* bits 4-5 */ +#define EEPROM_RF_CFG_PNUM_MSK(x) ((x >> 6) & 0x3) /* bits 6-7 */ +#define EEPROM_RF_CFG_TX_ANT_MSK(x) ((x >> 8) & 0xF) /* bits 8-11 */ +#define EEPROM_RF_CFG_RX_ANT_MSK(x) ((x >> 12) & 0xF) /* bits 12-15 */ + +#define EEPROM_3945_RF_CFG_TYPE_MAX 0x0 +#define EEPROM_4965_RF_CFG_TYPE_MAX 0x1 + +/* + * Per-channel regulatory data. + * + * Each channel that *might* be supported by iwl has a fixed location + * in EEPROM containing EEPROM_CHANNEL_* usage flags (LSB) and max regulatory + * txpower (MSB). + * + * Entries immediately below are for 20 MHz channel width. HT40 (40 MHz) + * channels (only for 4965, not supported by 3945) appear later in the EEPROM. + * + * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 + */ +#define EEPROM_REGULATORY_SKU_ID (2*0x60) /* 4 bytes */ +#define EEPROM_REGULATORY_BAND_1 (2*0x62) /* 2 bytes */ +#define EEPROM_REGULATORY_BAND_1_CHANNELS (2*0x63) /* 28 bytes */ + +/* + * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196, + * 5.0 GHz channels 7, 8, 11, 12, 16 + * (4915-5080MHz) (none of these is ever supported) + */ +#define EEPROM_REGULATORY_BAND_2 (2*0x71) /* 2 bytes */ +#define EEPROM_REGULATORY_BAND_2_CHANNELS (2*0x72) /* 26 bytes */ + +/* + * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 + * (5170-5320MHz) + */ +#define EEPROM_REGULATORY_BAND_3 (2*0x7F) /* 2 bytes */ +#define EEPROM_REGULATORY_BAND_3_CHANNELS (2*0x80) /* 24 bytes */ + +/* + * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 + * (5500-5700MHz) + */ +#define EEPROM_REGULATORY_BAND_4 (2*0x8C) /* 2 bytes */ +#define EEPROM_REGULATORY_BAND_4_CHANNELS (2*0x8D) /* 22 bytes */ + +/* + * 5.7 GHz channels 145, 149, 153, 157, 161, 165 + * (5725-5825MHz) + */ +#define EEPROM_REGULATORY_BAND_5 (2*0x98) /* 2 bytes */ +#define EEPROM_REGULATORY_BAND_5_CHANNELS (2*0x99) /* 12 bytes */ + +/* + * 2.4 GHz HT40 channels 1 (5), 2 (6), 3 (7), 4 (8), 5 (9), 6 (10), 7 (11) + * + * The channel listed is the center of the lower 20 MHz half of the channel. + * The overall center frequency is actually 2 channels (10 MHz) above that, + * and the upper half of each HT40 channel is centered 4 channels (20 MHz) away + * from the lower half; e.g. the upper half of HT40 channel 1 is channel 5, + * and the overall HT40 channel width centers on channel 3. + * + * NOTE: The RXON command uses 20 MHz channel numbers to specify the + * control channel to which to tune. RXON also specifies whether the + * control channel is the upper or lower half of a HT40 channel. + * + * NOTE: 4965 does not support HT40 channels on 2.4 GHz. + */ +#define EEPROM_4965_REGULATORY_BAND_24_HT40_CHANNELS (2*0xA0) /* 14 bytes */ + +/* + * 5.2 GHz HT40 channels 36 (40), 44 (48), 52 (56), 60 (64), + * 100 (104), 108 (112), 116 (120), 124 (128), 132 (136), 149 (153), 157 (161) + */ +#define EEPROM_4965_REGULATORY_BAND_52_HT40_CHANNELS (2*0xA8) /* 22 bytes */ + +#define EEPROM_REGULATORY_BAND_NO_HT40 (0) + +struct il_eeprom_ops { + const u32 regulatory_bands[7]; + int (*acquire_semaphore) (struct il_priv *il); + void (*release_semaphore) (struct il_priv *il); +}; + + +int il_eeprom_init(struct il_priv *il); +void il_eeprom_free(struct il_priv *il); +const u8 *il_eeprom_query_addr(const struct il_priv *il, + size_t offset); +u16 il_eeprom_query16(const struct il_priv *il, size_t offset); +int il_init_channel_map(struct il_priv *il); +void il_free_channel_map(struct il_priv *il); +const struct il_channel_info *il_get_channel_info( + const struct il_priv *il, + enum ieee80211_band band, u16 channel); + + #define IL_NUM_SCAN_RATES (2) struct il4965_channel_tgd_info { @@ -1329,6 +1603,7 @@ il_is_channel_ibss(const struct il_channel_info *ch) return (ch->flags & EEPROM_CHANNEL_IBSS) ? 1 : 0; } + static inline void __il_free_pages(struct il_priv *il, struct page *page) { @@ -1432,7 +1707,7 @@ struct il_lib_ops { int (*send_tx_power) (struct il_priv *il); void (*update_chain_flags)(struct il_priv *il); - /* eeprom operations (as defined in iwl-eeprom.h) */ + /* eeprom operations */ struct il_eeprom_ops eeprom_ops; /* temperature */ @@ -1478,7 +1753,7 @@ struct il_mod_params { /* * @led_compensation: compensate on the led on/off time per HW according * to the deviation to achieve the desired led frequency. - * The detail algorithm is described in iwl-led.c + * The detail algorithm is described in common.c * @chain_noise_num_beacons: number of beacons used to compute chain noise * @wd_timeout: TX queues watchdog timeout * @temperature_kelvin: temperature report by uCode in kelvin @@ -1506,6 +1781,29 @@ struct il_base_params { const bool chain_noise_calib_by_driver; }; +#define IL_LED_SOLID 11 +#define IL_DEF_LED_INTRVL cpu_to_le32(1000) + +#define IL_LED_ACTIVITY (0<<1) +#define IL_LED_LINK (1<<1) + +/* + * LED mode + * IL_LED_DEFAULT: use device default + * IL_LED_RF_STATE: turn LED on/off based on RF state + * LED ON = RF ON + * LED OFF = RF OFF + * IL_LED_BLINK: adjust led blink rate based on blink table + */ +enum il_led_mode { + IL_LED_DEFAULT, + IL_LED_RF_STATE, + IL_LED_BLINK, +}; + +void il_leds_init(struct il_priv *il); +void il_leds_exit(struct il_priv *il); + /** * struct il_cfg * @fw_name_pre: Firmware filename prefix. The api version and extension @@ -3005,4 +3303,5 @@ extern void il3945_rate_control_unregister(void); extern int il_power_update_mode(struct il_priv *il, bool force); extern void il_power_initialize(struct il_priv *il); + #endif /* __il_core_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-eeprom.h b/drivers/net/wireless/iwlegacy/iwl-eeprom.h deleted file mode 100644 index 61435a522c84..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-eeprom.h +++ /dev/null @@ -1,344 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef __il_eeprom_h__ -#define __il_eeprom_h__ - -#include - -struct il_priv; - -/* - * EEPROM access time values: - * - * Driver initiates EEPROM read by writing byte address << 1 to CSR_EEPROM_REG. - * Driver then polls CSR_EEPROM_REG for CSR_EEPROM_REG_READ_VALID_MSK (0x1). - * When polling, wait 10 uSec between polling loops, up to a maximum 5000 uSec. - * Driver reads 16-bit value from bits 31-16 of CSR_EEPROM_REG. - */ -#define IL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */ - -#define IL_EEPROM_SEM_TIMEOUT 10 /* microseconds */ -#define IL_EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ - - -/* - * Regulatory channel usage flags in EEPROM struct il4965_eeprom_channel.flags. - * - * IBSS and/or AP operation is allowed *only* on those channels with - * (VALID && IBSS && ACTIVE && !RADAR). This restriction is in place because - * RADAR detection is not supported by the 4965 driver, but is a - * requirement for establishing a new network for legal operation on channels - * requiring RADAR detection or restricting ACTIVE scanning. - * - * NOTE: "WIDE" flag does not indicate anything about "HT40" 40 MHz channels. - * It only indicates that 20 MHz channel use is supported; HT40 channel - * usage is indicated by a separate set of regulatory flags for each - * HT40 channel pair. - * - * NOTE: Using a channel inappropriately will result in a uCode error! - */ -#define IL_NUM_TX_CALIB_GROUPS 5 -enum { - EEPROM_CHANNEL_VALID = (1 << 0), /* usable for this SKU/geo */ - EEPROM_CHANNEL_IBSS = (1 << 1), /* usable as an IBSS channel */ - /* Bit 2 Reserved */ - EEPROM_CHANNEL_ACTIVE = (1 << 3), /* active scanning allowed */ - EEPROM_CHANNEL_RADAR = (1 << 4), /* radar detection required */ - EEPROM_CHANNEL_WIDE = (1 << 5), /* 20 MHz channel okay */ - /* Bit 6 Reserved (was Narrow Channel) */ - EEPROM_CHANNEL_DFS = (1 << 7), /* dynamic freq selection candidate */ -}; - -/* SKU Capabilities */ -/* 3945 only */ -#define EEPROM_SKU_CAP_SW_RF_KILL_ENABLE (1 << 0) -#define EEPROM_SKU_CAP_HW_RF_KILL_ENABLE (1 << 1) - -/* *regulatory* channel data format in eeprom, one for each channel. - * There are separate entries for HT40 (40 MHz) vs. normal (20 MHz) channels. */ -struct il_eeprom_channel { - u8 flags; /* EEPROM_CHANNEL_* flags copied from EEPROM */ - s8 max_power_avg; /* max power (dBm) on this chnl, limit 31 */ -} __packed; - -/* 3945 Specific */ -#define EEPROM_3945_EEPROM_VERSION (0x2f) - -/* 4965 has two radio transmitters (and 3 radio receivers) */ -#define EEPROM_TX_POWER_TX_CHAINS (2) - -/* 4965 has room for up to 8 sets of txpower calibration data */ -#define EEPROM_TX_POWER_BANDS (8) - -/* 4965 factory calibration measures txpower gain settings for - * each of 3 target output levels */ -#define EEPROM_TX_POWER_MEASUREMENTS (3) - -/* 4965 Specific */ -/* 4965 driver does not work with txpower calibration version < 5 */ -#define EEPROM_4965_TX_POWER_VERSION (5) -#define EEPROM_4965_EEPROM_VERSION (0x2f) -#define EEPROM_4965_CALIB_VERSION_OFFSET (2*0xB6) /* 2 bytes */ -#define EEPROM_4965_CALIB_TXPOWER_OFFSET (2*0xE8) /* 48 bytes */ -#define EEPROM_4965_BOARD_REVISION (2*0x4F) /* 2 bytes */ -#define EEPROM_4965_BOARD_PBA (2*0x56+1) /* 9 bytes */ - -/* 2.4 GHz */ -extern const u8 il_eeprom_band_1[14]; - -/* - * factory calibration data for one txpower level, on one channel, - * measured on one of the 2 tx chains (radio transmitter and associated - * antenna). EEPROM contains: - * - * 1) Temperature (degrees Celsius) of device when measurement was made. - * - * 2) Gain table idx used to achieve the target measurement power. - * This refers to the "well-known" gain tables (see 4965.h). - * - * 3) Actual measured output power, in half-dBm ("34" = 17 dBm). - * - * 4) RF power amplifier detector level measurement (not used). - */ -struct il_eeprom_calib_measure { - u8 temperature; /* Device temperature (Celsius) */ - u8 gain_idx; /* Index into gain table */ - u8 actual_pow; /* Measured RF output power, half-dBm */ - s8 pa_det; /* Power amp detector level (not used) */ -} __packed; - - -/* - * measurement set for one channel. EEPROM contains: - * - * 1) Channel number measured - * - * 2) Measurements for each of 3 power levels for each of 2 radio transmitters - * (a.k.a. "tx chains") (6 measurements altogether) - */ -struct il_eeprom_calib_ch_info { - u8 ch_num; - struct il_eeprom_calib_measure - measurements[EEPROM_TX_POWER_TX_CHAINS] - [EEPROM_TX_POWER_MEASUREMENTS]; -} __packed; - -/* - * txpower subband info. - * - * For each frequency subband, EEPROM contains the following: - * - * 1) First and last channels within range of the subband. "0" values - * indicate that this sample set is not being used. - * - * 2) Sample measurement sets for 2 channels close to the range endpoints. - */ -struct il_eeprom_calib_subband_info { - u8 ch_from; /* channel number of lowest channel in subband */ - u8 ch_to; /* channel number of highest channel in subband */ - struct il_eeprom_calib_ch_info ch1; - struct il_eeprom_calib_ch_info ch2; -} __packed; - - -/* - * txpower calibration info. EEPROM contains: - * - * 1) Factory-measured saturation power levels (maximum levels at which - * tx power amplifier can output a signal without too much distortion). - * There is one level for 2.4 GHz band and one for 5 GHz band. These - * values apply to all channels within each of the bands. - * - * 2) Factory-measured power supply voltage level. This is assumed to be - * constant (i.e. same value applies to all channels/bands) while the - * factory measurements are being made. - * - * 3) Up to 8 sets of factory-measured txpower calibration values. - * These are for different frequency ranges, since txpower gain - * characteristics of the analog radio circuitry vary with frequency. - * - * Not all sets need to be filled with data; - * struct il_eeprom_calib_subband_info contains range of channels - * (0 if unused) for each set of data. - */ -struct il_eeprom_calib_info { - u8 saturation_power24; /* half-dBm (e.g. "34" = 17 dBm) */ - u8 saturation_power52; /* half-dBm */ - __le16 voltage; /* signed */ - struct il_eeprom_calib_subband_info - band_info[EEPROM_TX_POWER_BANDS]; -} __packed; - - -/* General */ -#define EEPROM_DEVICE_ID (2*0x08) /* 2 bytes */ -#define EEPROM_MAC_ADDRESS (2*0x15) /* 6 bytes */ -#define EEPROM_BOARD_REVISION (2*0x35) /* 2 bytes */ -#define EEPROM_BOARD_PBA_NUMBER (2*0x3B+1) /* 9 bytes */ -#define EEPROM_VERSION (2*0x44) /* 2 bytes */ -#define EEPROM_SKU_CAP (2*0x45) /* 2 bytes */ -#define EEPROM_OEM_MODE (2*0x46) /* 2 bytes */ -#define EEPROM_WOWLAN_MODE (2*0x47) /* 2 bytes */ -#define EEPROM_RADIO_CONFIG (2*0x48) /* 2 bytes */ -#define EEPROM_NUM_MAC_ADDRESS (2*0x4C) /* 2 bytes */ - -/* The following masks are to be applied on EEPROM_RADIO_CONFIG */ -#define EEPROM_RF_CFG_TYPE_MSK(x) (x & 0x3) /* bits 0-1 */ -#define EEPROM_RF_CFG_STEP_MSK(x) ((x >> 2) & 0x3) /* bits 2-3 */ -#define EEPROM_RF_CFG_DASH_MSK(x) ((x >> 4) & 0x3) /* bits 4-5 */ -#define EEPROM_RF_CFG_PNUM_MSK(x) ((x >> 6) & 0x3) /* bits 6-7 */ -#define EEPROM_RF_CFG_TX_ANT_MSK(x) ((x >> 8) & 0xF) /* bits 8-11 */ -#define EEPROM_RF_CFG_RX_ANT_MSK(x) ((x >> 12) & 0xF) /* bits 12-15 */ - -#define EEPROM_3945_RF_CFG_TYPE_MAX 0x0 -#define EEPROM_4965_RF_CFG_TYPE_MAX 0x1 - -/* - * Per-channel regulatory data. - * - * Each channel that *might* be supported by iwl has a fixed location - * in EEPROM containing EEPROM_CHANNEL_* usage flags (LSB) and max regulatory - * txpower (MSB). - * - * Entries immediately below are for 20 MHz channel width. HT40 (40 MHz) - * channels (only for 4965, not supported by 3945) appear later in the EEPROM. - * - * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 - */ -#define EEPROM_REGULATORY_SKU_ID (2*0x60) /* 4 bytes */ -#define EEPROM_REGULATORY_BAND_1 (2*0x62) /* 2 bytes */ -#define EEPROM_REGULATORY_BAND_1_CHANNELS (2*0x63) /* 28 bytes */ - -/* - * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196, - * 5.0 GHz channels 7, 8, 11, 12, 16 - * (4915-5080MHz) (none of these is ever supported) - */ -#define EEPROM_REGULATORY_BAND_2 (2*0x71) /* 2 bytes */ -#define EEPROM_REGULATORY_BAND_2_CHANNELS (2*0x72) /* 26 bytes */ - -/* - * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 - * (5170-5320MHz) - */ -#define EEPROM_REGULATORY_BAND_3 (2*0x7F) /* 2 bytes */ -#define EEPROM_REGULATORY_BAND_3_CHANNELS (2*0x80) /* 24 bytes */ - -/* - * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 - * (5500-5700MHz) - */ -#define EEPROM_REGULATORY_BAND_4 (2*0x8C) /* 2 bytes */ -#define EEPROM_REGULATORY_BAND_4_CHANNELS (2*0x8D) /* 22 bytes */ - -/* - * 5.7 GHz channels 145, 149, 153, 157, 161, 165 - * (5725-5825MHz) - */ -#define EEPROM_REGULATORY_BAND_5 (2*0x98) /* 2 bytes */ -#define EEPROM_REGULATORY_BAND_5_CHANNELS (2*0x99) /* 12 bytes */ - -/* - * 2.4 GHz HT40 channels 1 (5), 2 (6), 3 (7), 4 (8), 5 (9), 6 (10), 7 (11) - * - * The channel listed is the center of the lower 20 MHz half of the channel. - * The overall center frequency is actually 2 channels (10 MHz) above that, - * and the upper half of each HT40 channel is centered 4 channels (20 MHz) away - * from the lower half; e.g. the upper half of HT40 channel 1 is channel 5, - * and the overall HT40 channel width centers on channel 3. - * - * NOTE: The RXON command uses 20 MHz channel numbers to specify the - * control channel to which to tune. RXON also specifies whether the - * control channel is the upper or lower half of a HT40 channel. - * - * NOTE: 4965 does not support HT40 channels on 2.4 GHz. - */ -#define EEPROM_4965_REGULATORY_BAND_24_HT40_CHANNELS (2*0xA0) /* 14 bytes */ - -/* - * 5.2 GHz HT40 channels 36 (40), 44 (48), 52 (56), 60 (64), - * 100 (104), 108 (112), 116 (120), 124 (128), 132 (136), 149 (153), 157 (161) - */ -#define EEPROM_4965_REGULATORY_BAND_52_HT40_CHANNELS (2*0xA8) /* 22 bytes */ - -#define EEPROM_REGULATORY_BAND_NO_HT40 (0) - -struct il_eeprom_ops { - const u32 regulatory_bands[7]; - int (*acquire_semaphore) (struct il_priv *il); - void (*release_semaphore) (struct il_priv *il); -}; - - -int il_eeprom_init(struct il_priv *il); -void il_eeprom_free(struct il_priv *il); -const u8 *il_eeprom_query_addr(const struct il_priv *il, - size_t offset); -u16 il_eeprom_query16(const struct il_priv *il, size_t offset); -int il_init_channel_map(struct il_priv *il); -void il_free_channel_map(struct il_priv *il); -const struct il_channel_info *il_get_channel_info( - const struct il_priv *il, - enum ieee80211_band band, u16 channel); - -#endif /* __il_eeprom_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-led.h b/drivers/net/wireless/iwlegacy/iwl-led.h deleted file mode 100644 index d3aba57feba7..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-led.h +++ /dev/null @@ -1,56 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#ifndef __il_leds_h__ -#define __il_leds_h__ - - -struct il_priv; - -#define IL_LED_SOLID 11 -#define IL_DEF_LED_INTRVL cpu_to_le32(1000) - -#define IL_LED_ACTIVITY (0<<1) -#define IL_LED_LINK (1<<1) - -/* - * LED mode - * IL_LED_DEFAULT: use device default - * IL_LED_RF_STATE: turn LED on/off based on RF state - * LED ON = RF ON - * LED OFF = RF OFF - * IL_LED_BLINK: adjust led blink rate based on blink table - */ -enum il_led_mode { - IL_LED_DEFAULT, - IL_LED_RF_STATE, - IL_LED_BLINK, -}; - -void il_leds_init(struct il_priv *il); -void il_leds_exit(struct il_priv *il); - -#endif /* __il_leds_h__ */ -- cgit v1.2.3 From e8c39d4e62a01c21330bcccd7989c9c8deac4271 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 14:09:39 +0200 Subject: iwlegacy: rename iwl-prph.h to prph.h Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/3945.h | 1 - drivers/net/wireless/iwlegacy/common.h | 2 +- drivers/net/wireless/iwlegacy/iwl-prph.h | 523 ------------------------------- drivers/net/wireless/iwlegacy/prph.h | 523 +++++++++++++++++++++++++++++++ 4 files changed, 524 insertions(+), 525 deletions(-) delete mode 100644 drivers/net/wireless/iwlegacy/iwl-prph.h create mode 100644 drivers/net/wireless/iwlegacy/prph.h (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index 5e4fcbc2fab6..33233abdd9bb 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -35,7 +35,6 @@ extern const struct pci_device_id il3945_hw_card_ids[]; #include "common.h" -#include "iwl-prph.h" #include "iwl-debug.h" /* Highest firmware API version supported */ diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 8e4450edfa74..8ae4e3f667eb 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -36,7 +36,7 @@ #include "commands.h" #include "csr.h" -#include "iwl-prph.h" +#include "prph.h" #include "iwl-debug.h" struct il_host_cmd; diff --git a/drivers/net/wireless/iwlegacy/iwl-prph.h b/drivers/net/wireless/iwlegacy/iwl-prph.h deleted file mode 100644 index 029ea8a83dff..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-prph.h +++ /dev/null @@ -1,523 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - *****************************************************************************/ - -#ifndef __il_prph_h__ -#define __il_prph_h__ - -/* - * Registers in this file are internal, not PCI bus memory mapped. - * Driver accesses these via HBUS_TARG_PRPH_* registers. - */ -#define PRPH_BASE (0x00000) -#define PRPH_END (0xFFFFF) - -/* APMG (power management) constants */ -#define APMG_BASE (PRPH_BASE + 0x3000) -#define APMG_CLK_CTRL_REG (APMG_BASE + 0x0000) -#define APMG_CLK_EN_REG (APMG_BASE + 0x0004) -#define APMG_CLK_DIS_REG (APMG_BASE + 0x0008) -#define APMG_PS_CTRL_REG (APMG_BASE + 0x000c) -#define APMG_PCIDEV_STT_REG (APMG_BASE + 0x0010) -#define APMG_RFKILL_REG (APMG_BASE + 0x0014) -#define APMG_RTC_INT_STT_REG (APMG_BASE + 0x001c) -#define APMG_RTC_INT_MSK_REG (APMG_BASE + 0x0020) -#define APMG_DIGITAL_SVR_REG (APMG_BASE + 0x0058) -#define APMG_ANALOG_SVR_REG (APMG_BASE + 0x006C) - -#define APMS_CLK_VAL_MRB_FUNC_MODE (0x00000001) -#define APMG_CLK_VAL_DMA_CLK_RQT (0x00000200) -#define APMG_CLK_VAL_BSM_CLK_RQT (0x00000800) - -#define APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS (0x00400000) -#define APMG_PS_CTRL_VAL_RESET_REQ (0x04000000) -#define APMG_PS_CTRL_MSK_PWR_SRC (0x03000000) -#define APMG_PS_CTRL_VAL_PWR_SRC_VMAIN (0x00000000) -#define APMG_PS_CTRL_VAL_PWR_SRC_MAX (0x01000000) /* 3945 only */ -#define APMG_PS_CTRL_VAL_PWR_SRC_VAUX (0x02000000) -#define APMG_SVR_VOLTAGE_CONFIG_BIT_MSK (0x000001E0) /* bit 8:5 */ -#define APMG_SVR_DIGITAL_VOLTAGE_1_32 (0x00000060) - -#define APMG_PCIDEV_STT_VAL_L1_ACT_DIS (0x00000800) - -/** - * BSM (Bootstrap State Machine) - * - * The Bootstrap State Machine (BSM) stores a short bootstrap uCode program - * in special SRAM that does not power down when the embedded control - * processor is sleeping (e.g. for periodic power-saving shutdowns of radio). - * - * When powering back up after sleeps (or during initial uCode load), the BSM - * internally loads the short bootstrap program from the special SRAM into the - * embedded processor's instruction SRAM, and starts the processor so it runs - * the bootstrap program. - * - * This bootstrap program loads (via PCI busmaster DMA) instructions and data - * images for a uCode program from host DRAM locations. The host driver - * indicates DRAM locations and sizes for instruction and data images via the - * four BSM_DRAM_* registers. Once the bootstrap program loads the new program, - * the new program starts automatically. - * - * The uCode used for open-source drivers includes two programs: - * - * 1) Initialization -- performs hardware calibration and sets up some - * internal data, then notifies host via "initialize alive" notification - * (struct il_init_alive_resp) that it has completed all of its work. - * After signal from host, it then loads and starts the runtime program. - * The initialization program must be used when initially setting up the - * NIC after loading the driver. - * - * 2) Runtime/Protocol -- performs all normal runtime operations. This - * notifies host via "alive" notification (struct il_alive_resp) that it - * is ready to be used. - * - * When initializing the NIC, the host driver does the following procedure: - * - * 1) Load bootstrap program (instructions only, no data image for bootstrap) - * into bootstrap memory. Use dword writes starting at BSM_SRAM_LOWER_BOUND - * - * 2) Point (via BSM_DRAM_*) to the "initialize" uCode data and instruction - * images in host DRAM. - * - * 3) Set up BSM to copy from BSM SRAM into uCode instruction SRAM when asked: - * BSM_WR_MEM_SRC_REG = 0 - * BSM_WR_MEM_DST_REG = RTC_INST_LOWER_BOUND - * BSM_WR_MEM_DWCOUNT_REG = # dwords in bootstrap instruction image - * - * 4) Load bootstrap into instruction SRAM: - * BSM_WR_CTRL_REG = BSM_WR_CTRL_REG_BIT_START - * - * 5) Wait for load completion: - * Poll BSM_WR_CTRL_REG for BSM_WR_CTRL_REG_BIT_START = 0 - * - * 6) Enable future boot loads whenever NIC's power management triggers it: - * BSM_WR_CTRL_REG = BSM_WR_CTRL_REG_BIT_START_EN - * - * 7) Start the NIC by removing all reset bits: - * CSR_RESET = 0 - * - * The bootstrap uCode (already in instruction SRAM) loads initialization - * uCode. Initialization uCode performs data initialization, sends - * "initialize alive" notification to host, and waits for a signal from - * host to load runtime code. - * - * 4) Point (via BSM_DRAM_*) to the "runtime" uCode data and instruction - * images in host DRAM. The last register loaded must be the instruction - * byte count register ("1" in MSbit tells initialization uCode to load - * the runtime uCode): - * BSM_DRAM_INST_BYTECOUNT_REG = byte count | BSM_DRAM_INST_LOAD - * - * 5) Wait for "alive" notification, then issue normal runtime commands. - * - * Data caching during power-downs: - * - * Just before the embedded controller powers down (e.g for automatic - * power-saving modes, or for RFKILL), uCode stores (via PCI busmaster DMA) - * a current snapshot of the embedded processor's data SRAM into host DRAM. - * This caches the data while the embedded processor's memory is powered down. - * Location and size are controlled by BSM_DRAM_DATA_* registers. - * - * NOTE: Instruction SRAM does not need to be saved, since that doesn't - * change during operation; the original image (from uCode distribution - * file) can be used for reload. - * - * When powering back up, the BSM loads the bootstrap program. Bootstrap looks - * at the BSM_DRAM_* registers, which now point to the runtime instruction - * image and the cached (modified) runtime data (*not* the initialization - * uCode). Bootstrap reloads these runtime images into SRAM, and restarts the - * uCode from where it left off before the power-down. - * - * NOTE: Initialization uCode does *not* run as part of the save/restore - * procedure. - * - * This save/restore method is mostly for autonomous power management during - * normal operation (result of C_POWER_TBL). Platform suspend/resume and - * RFKILL should use complete restarts (with total re-initialization) of uCode, - * allowing total shutdown (including BSM memory). - * - * Note that, during normal operation, the host DRAM that held the initial - * startup data for the runtime code is now being used as a backup data cache - * for modified data! If you need to completely re-initialize the NIC, make - * sure that you use the runtime data image from the uCode distribution file, - * not the modified/saved runtime data. You may want to store a separate - * "clean" runtime data image in DRAM to avoid disk reads of distribution file. - */ - -/* BSM bit fields */ -#define BSM_WR_CTRL_REG_BIT_START (0x80000000) /* start boot load now */ -#define BSM_WR_CTRL_REG_BIT_START_EN (0x40000000) /* enable boot after pwrup*/ -#define BSM_DRAM_INST_LOAD (0x80000000) /* start program load now */ - -/* BSM addresses */ -#define BSM_BASE (PRPH_BASE + 0x3400) -#define BSM_END (PRPH_BASE + 0x3800) - -#define BSM_WR_CTRL_REG (BSM_BASE + 0x000) /* ctl and status */ -#define BSM_WR_MEM_SRC_REG (BSM_BASE + 0x004) /* source in BSM mem */ -#define BSM_WR_MEM_DST_REG (BSM_BASE + 0x008) /* dest in SRAM mem */ -#define BSM_WR_DWCOUNT_REG (BSM_BASE + 0x00C) /* bytes */ -#define BSM_WR_STATUS_REG (BSM_BASE + 0x010) /* bit 0: 1 == done */ - -/* - * Pointers and size regs for bootstrap load and data SRAM save/restore. - * NOTE: 3945 pointers use bits 31:0 of DRAM address. - * 4965 pointers use bits 35:4 of DRAM address. - */ -#define BSM_DRAM_INST_PTR_REG (BSM_BASE + 0x090) -#define BSM_DRAM_INST_BYTECOUNT_REG (BSM_BASE + 0x094) -#define BSM_DRAM_DATA_PTR_REG (BSM_BASE + 0x098) -#define BSM_DRAM_DATA_BYTECOUNT_REG (BSM_BASE + 0x09C) - -/* - * BSM special memory, stays powered on during power-save sleeps. - * Read/write, address range from LOWER_BOUND to (LOWER_BOUND + SIZE -1) - */ -#define BSM_SRAM_LOWER_BOUND (PRPH_BASE + 0x3800) -#define BSM_SRAM_SIZE (1024) /* bytes */ - - -/* 3945 Tx scheduler registers */ -#define ALM_SCD_BASE (PRPH_BASE + 0x2E00) -#define ALM_SCD_MODE_REG (ALM_SCD_BASE + 0x000) -#define ALM_SCD_ARASTAT_REG (ALM_SCD_BASE + 0x004) -#define ALM_SCD_TXFACT_REG (ALM_SCD_BASE + 0x010) -#define ALM_SCD_TXF4MF_REG (ALM_SCD_BASE + 0x014) -#define ALM_SCD_TXF5MF_REG (ALM_SCD_BASE + 0x020) -#define ALM_SCD_SBYP_MODE_1_REG (ALM_SCD_BASE + 0x02C) -#define ALM_SCD_SBYP_MODE_2_REG (ALM_SCD_BASE + 0x030) - -/** - * Tx Scheduler - * - * The Tx Scheduler selects the next frame to be transmitted, choosing TFDs - * (Transmit Frame Descriptors) from up to 16 circular Tx queues resident in - * host DRAM. It steers each frame's Tx command (which contains the frame - * data) into one of up to 7 prioritized Tx DMA FIFO channels within the - * device. A queue maps to only one (selectable by driver) Tx DMA channel, - * but one DMA channel may take input from several queues. - * - * Tx DMA FIFOs have dedicated purposes. For 4965, they are used as follows - * (cf. default_queue_to_tx_fifo in 4965.c): - * - * 0 -- EDCA BK (background) frames, lowest priority - * 1 -- EDCA BE (best effort) frames, normal priority - * 2 -- EDCA VI (video) frames, higher priority - * 3 -- EDCA VO (voice) and management frames, highest priority - * 4 -- Commands (e.g. RXON, etc.) - * 5 -- unused (HCCA) - * 6 -- unused (HCCA) - * 7 -- not used by driver (device-internal only) - * - * - * Driver should normally map queues 0-6 to Tx DMA/FIFO channels 0-6. - * In addition, driver can map the remaining queues to Tx DMA/FIFO - * channels 0-3 to support 11n aggregation via EDCA DMA channels. - * - * The driver sets up each queue to work in one of two modes: - * - * 1) Scheduler-Ack, in which the scheduler automatically supports a - * block-ack (BA) win of up to 64 TFDs. In this mode, each queue - * contains TFDs for a unique combination of Recipient Address (RA) - * and Traffic Identifier (TID), that is, traffic of a given - * Quality-Of-Service (QOS) priority, destined for a single station. - * - * In scheduler-ack mode, the scheduler keeps track of the Tx status of - * each frame within the BA win, including whether it's been transmitted, - * and whether it's been acknowledged by the receiving station. The device - * automatically processes block-acks received from the receiving STA, - * and reschedules un-acked frames to be retransmitted (successful - * Tx completion may end up being out-of-order). - * - * The driver must maintain the queue's Byte Count table in host DRAM - * (struct il4965_sched_queue_byte_cnt_tbl) for this mode. - * This mode does not support fragmentation. - * - * 2) FIFO (a.k.a. non-Scheduler-ACK), in which each TFD is processed in order. - * The device may automatically retry Tx, but will retry only one frame - * at a time, until receiving ACK from receiving station, or reaching - * retry limit and giving up. - * - * The command queue (#4/#9) must use this mode! - * This mode does not require use of the Byte Count table in host DRAM. - * - * Driver controls scheduler operation via 3 means: - * 1) Scheduler registers - * 2) Shared scheduler data base in internal 4956 SRAM - * 3) Shared data in host DRAM - * - * Initialization: - * - * When loading, driver should allocate memory for: - * 1) 16 TFD circular buffers, each with space for (typically) 256 TFDs. - * 2) 16 Byte Count circular buffers in 16 KBytes contiguous memory - * (1024 bytes for each queue). - * - * After receiving "Alive" response from uCode, driver must initialize - * the scheduler (especially for queue #4/#9, the command queue, otherwise - * the driver can't issue commands!): - */ - -/** - * Max Tx win size is the max number of contiguous TFDs that the scheduler - * can keep track of at one time when creating block-ack chains of frames. - * Note that "64" matches the number of ack bits in a block-ack packet. - * Driver should use SCD_WIN_SIZE and SCD_FRAME_LIMIT values to initialize - * IL49_SCD_CONTEXT_QUEUE_OFFSET(x) values. - */ -#define SCD_WIN_SIZE 64 -#define SCD_FRAME_LIMIT 64 - -/* SCD registers are internal, must be accessed via HBUS_TARG_PRPH regs */ -#define IL49_SCD_START_OFFSET 0xa02c00 - -/* - * 4965 tells driver SRAM address for internal scheduler structs via this reg. - * Value is valid only after "Alive" response from uCode. - */ -#define IL49_SCD_SRAM_BASE_ADDR (IL49_SCD_START_OFFSET + 0x0) - -/* - * Driver may need to update queue-empty bits after changing queue's - * write and read pointers (idxes) during (re-)initialization (i.e. when - * scheduler is not tracking what's happening). - * Bit fields: - * 31-16: Write mask -- 1: update empty bit, 0: don't change empty bit - * 15-00: Empty state, one for each queue -- 1: empty, 0: non-empty - * NOTE: This register is not used by Linux driver. - */ -#define IL49_SCD_EMPTY_BITS (IL49_SCD_START_OFFSET + 0x4) - -/* - * Physical base address of array of byte count (BC) circular buffers (CBs). - * Each Tx queue has a BC CB in host DRAM to support Scheduler-ACK mode. - * This register points to BC CB for queue 0, must be on 1024-byte boundary. - * Others are spaced by 1024 bytes. - * Each BC CB is 2 bytes * (256 + 64) = 740 bytes, followed by 384 bytes pad. - * (Index into a queue's BC CB) = (idx into queue's TFD CB) = (SSN & 0xff). - * Bit fields: - * 25-00: Byte Count CB physical address [35:10], must be 1024-byte aligned. - */ -#define IL49_SCD_DRAM_BASE_ADDR (IL49_SCD_START_OFFSET + 0x10) - -/* - * Enables any/all Tx DMA/FIFO channels. - * Scheduler generates requests for only the active channels. - * Set this to 0xff to enable all 8 channels (normal usage). - * Bit fields: - * 7- 0: Enable (1), disable (0), one bit for each channel 0-7 - */ -#define IL49_SCD_TXFACT (IL49_SCD_START_OFFSET + 0x1c) -/* - * Queue (x) Write Pointers (idxes, really!), one for each Tx queue. - * Initialized and updated by driver as new TFDs are added to queue. - * NOTE: If using Block Ack, idx must correspond to frame's - * Start Sequence Number; idx = (SSN & 0xff) - * NOTE: Alternative to HBUS_TARG_WRPTR, which is what Linux driver uses? - */ -#define IL49_SCD_QUEUE_WRPTR(x) (IL49_SCD_START_OFFSET + 0x24 + (x) * 4) - -/* - * Queue (x) Read Pointers (idxes, really!), one for each Tx queue. - * For FIFO mode, idx indicates next frame to transmit. - * For Scheduler-ACK mode, idx indicates first frame in Tx win. - * Initialized by driver, updated by scheduler. - */ -#define IL49_SCD_QUEUE_RDPTR(x) (IL49_SCD_START_OFFSET + 0x64 + (x) * 4) - -/* - * Select which queues work in chain mode (1) vs. not (0). - * Use chain mode to build chains of aggregated frames. - * Bit fields: - * 31-16: Reserved - * 15-00: Mode, one bit for each queue -- 1: Chain mode, 0: one-at-a-time - * NOTE: If driver sets up queue for chain mode, it should be also set up - * Scheduler-ACK mode as well, via SCD_QUEUE_STATUS_BITS(x). - */ -#define IL49_SCD_QUEUECHAIN_SEL (IL49_SCD_START_OFFSET + 0xd0) - -/* - * Select which queues interrupt driver when scheduler increments - * a queue's read pointer (idx). - * Bit fields: - * 31-16: Reserved - * 15-00: Interrupt enable, one bit for each queue -- 1: enabled, 0: disabled - * NOTE: This functionality is apparently a no-op; driver relies on interrupts - * from Rx queue to read Tx command responses and update Tx queues. - */ -#define IL49_SCD_INTERRUPT_MASK (IL49_SCD_START_OFFSET + 0xe4) - -/* - * Queue search status registers. One for each queue. - * Sets up queue mode and assigns queue to Tx DMA channel. - * Bit fields: - * 19-10: Write mask/enable bits for bits 0-9 - * 9: Driver should init to "0" - * 8: Scheduler-ACK mode (1), non-Scheduler-ACK (i.e. FIFO) mode (0). - * Driver should init to "1" for aggregation mode, or "0" otherwise. - * 7-6: Driver should init to "0" - * 5: Window Size Left; indicates whether scheduler can request - * another TFD, based on win size, etc. Driver should init - * this bit to "1" for aggregation mode, or "0" for non-agg. - * 4-1: Tx FIFO to use (range 0-7). - * 0: Queue is active (1), not active (0). - * Other bits should be written as "0" - * - * NOTE: If enabling Scheduler-ACK mode, chain mode should also be enabled - * via SCD_QUEUECHAIN_SEL. - */ -#define IL49_SCD_QUEUE_STATUS_BITS(x)\ - (IL49_SCD_START_OFFSET + 0x104 + (x) * 4) - -/* Bit field positions */ -#define IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE (0) -#define IL49_SCD_QUEUE_STTS_REG_POS_TXF (1) -#define IL49_SCD_QUEUE_STTS_REG_POS_WSL (5) -#define IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK (8) - -/* Write masks */ -#define IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN (10) -#define IL49_SCD_QUEUE_STTS_REG_MSK (0x0007FC00) - -/** - * 4965 internal SRAM structures for scheduler, shared with driver ... - * - * Driver should clear and initialize the following areas after receiving - * "Alive" response from 4965 uCode, i.e. after initial - * uCode load, or after a uCode load done for error recovery: - * - * SCD_CONTEXT_DATA_OFFSET (size 128 bytes) - * SCD_TX_STTS_BITMAP_OFFSET (size 256 bytes) - * SCD_TRANSLATE_TBL_OFFSET (size 32 bytes) - * - * Driver accesses SRAM via HBUS_TARG_MEM_* registers. - * Driver reads base address of this scheduler area from SCD_SRAM_BASE_ADDR. - * All OFFSET values must be added to this base address. - */ - -/* - * Queue context. One 8-byte entry for each of 16 queues. - * - * Driver should clear this entire area (size 0x80) to 0 after receiving - * "Alive" notification from uCode. Additionally, driver should init - * each queue's entry as follows: - * - * LS Dword bit fields: - * 0-06: Max Tx win size for Scheduler-ACK. Driver should init to 64. - * - * MS Dword bit fields: - * 16-22: Frame limit. Driver should init to 10 (0xa). - * - * Driver should init all other bits to 0. - * - * Init must be done after driver receives "Alive" response from 4965 uCode, - * and when setting up queue for aggregation. - */ -#define IL49_SCD_CONTEXT_DATA_OFFSET 0x380 -#define IL49_SCD_CONTEXT_QUEUE_OFFSET(x) \ - (IL49_SCD_CONTEXT_DATA_OFFSET + ((x) * 8)) - -#define IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS (0) -#define IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK (0x0000007F) -#define IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS (16) -#define IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK (0x007F0000) - -/* - * Tx Status Bitmap - * - * Driver should clear this entire area (size 0x100) to 0 after receiving - * "Alive" notification from uCode. Area is used only by device itself; - * no other support (besides clearing) is required from driver. - */ -#define IL49_SCD_TX_STTS_BITMAP_OFFSET 0x400 - -/* - * RAxTID to queue translation mapping. - * - * When queue is in Scheduler-ACK mode, frames placed in a that queue must be - * for only one combination of receiver address (RA) and traffic ID (TID), i.e. - * one QOS priority level destined for one station (for this wireless link, - * not final destination). The SCD_TRANSLATE_TBL area provides 16 16-bit - * mappings, one for each of the 16 queues. If queue is not in Scheduler-ACK - * mode, the device ignores the mapping value. - * - * Bit fields, for each 16-bit map: - * 15-9: Reserved, set to 0 - * 8-4: Index into device's station table for recipient station - * 3-0: Traffic ID (tid), range 0-15 - * - * Driver should clear this entire area (size 32 bytes) to 0 after receiving - * "Alive" notification from uCode. To update a 16-bit map value, driver - * must read a dword-aligned value from device SRAM, replace the 16-bit map - * value of interest, and write the dword value back into device SRAM. - */ -#define IL49_SCD_TRANSLATE_TBL_OFFSET 0x500 - -/* Find translation table dword to read/write for given queue */ -#define IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \ - ((IL49_SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffffffc) - -#define IL_SCD_TXFIFO_POS_TID (0) -#define IL_SCD_TXFIFO_POS_RA (4) -#define IL_SCD_QUEUE_RA_TID_MAP_RATID_MSK (0x01FF) - -/*********************** END TX SCHEDULER *************************************/ - -#endif /* __il_prph_h__ */ diff --git a/drivers/net/wireless/iwlegacy/prph.h b/drivers/net/wireless/iwlegacy/prph.h new file mode 100644 index 000000000000..029ea8a83dff --- /dev/null +++ b/drivers/net/wireless/iwlegacy/prph.h @@ -0,0 +1,523 @@ +/****************************************************************************** + * + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, + * USA + * + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + * BSD LICENSE + * + * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +#ifndef __il_prph_h__ +#define __il_prph_h__ + +/* + * Registers in this file are internal, not PCI bus memory mapped. + * Driver accesses these via HBUS_TARG_PRPH_* registers. + */ +#define PRPH_BASE (0x00000) +#define PRPH_END (0xFFFFF) + +/* APMG (power management) constants */ +#define APMG_BASE (PRPH_BASE + 0x3000) +#define APMG_CLK_CTRL_REG (APMG_BASE + 0x0000) +#define APMG_CLK_EN_REG (APMG_BASE + 0x0004) +#define APMG_CLK_DIS_REG (APMG_BASE + 0x0008) +#define APMG_PS_CTRL_REG (APMG_BASE + 0x000c) +#define APMG_PCIDEV_STT_REG (APMG_BASE + 0x0010) +#define APMG_RFKILL_REG (APMG_BASE + 0x0014) +#define APMG_RTC_INT_STT_REG (APMG_BASE + 0x001c) +#define APMG_RTC_INT_MSK_REG (APMG_BASE + 0x0020) +#define APMG_DIGITAL_SVR_REG (APMG_BASE + 0x0058) +#define APMG_ANALOG_SVR_REG (APMG_BASE + 0x006C) + +#define APMS_CLK_VAL_MRB_FUNC_MODE (0x00000001) +#define APMG_CLK_VAL_DMA_CLK_RQT (0x00000200) +#define APMG_CLK_VAL_BSM_CLK_RQT (0x00000800) + +#define APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS (0x00400000) +#define APMG_PS_CTRL_VAL_RESET_REQ (0x04000000) +#define APMG_PS_CTRL_MSK_PWR_SRC (0x03000000) +#define APMG_PS_CTRL_VAL_PWR_SRC_VMAIN (0x00000000) +#define APMG_PS_CTRL_VAL_PWR_SRC_MAX (0x01000000) /* 3945 only */ +#define APMG_PS_CTRL_VAL_PWR_SRC_VAUX (0x02000000) +#define APMG_SVR_VOLTAGE_CONFIG_BIT_MSK (0x000001E0) /* bit 8:5 */ +#define APMG_SVR_DIGITAL_VOLTAGE_1_32 (0x00000060) + +#define APMG_PCIDEV_STT_VAL_L1_ACT_DIS (0x00000800) + +/** + * BSM (Bootstrap State Machine) + * + * The Bootstrap State Machine (BSM) stores a short bootstrap uCode program + * in special SRAM that does not power down when the embedded control + * processor is sleeping (e.g. for periodic power-saving shutdowns of radio). + * + * When powering back up after sleeps (or during initial uCode load), the BSM + * internally loads the short bootstrap program from the special SRAM into the + * embedded processor's instruction SRAM, and starts the processor so it runs + * the bootstrap program. + * + * This bootstrap program loads (via PCI busmaster DMA) instructions and data + * images for a uCode program from host DRAM locations. The host driver + * indicates DRAM locations and sizes for instruction and data images via the + * four BSM_DRAM_* registers. Once the bootstrap program loads the new program, + * the new program starts automatically. + * + * The uCode used for open-source drivers includes two programs: + * + * 1) Initialization -- performs hardware calibration and sets up some + * internal data, then notifies host via "initialize alive" notification + * (struct il_init_alive_resp) that it has completed all of its work. + * After signal from host, it then loads and starts the runtime program. + * The initialization program must be used when initially setting up the + * NIC after loading the driver. + * + * 2) Runtime/Protocol -- performs all normal runtime operations. This + * notifies host via "alive" notification (struct il_alive_resp) that it + * is ready to be used. + * + * When initializing the NIC, the host driver does the following procedure: + * + * 1) Load bootstrap program (instructions only, no data image for bootstrap) + * into bootstrap memory. Use dword writes starting at BSM_SRAM_LOWER_BOUND + * + * 2) Point (via BSM_DRAM_*) to the "initialize" uCode data and instruction + * images in host DRAM. + * + * 3) Set up BSM to copy from BSM SRAM into uCode instruction SRAM when asked: + * BSM_WR_MEM_SRC_REG = 0 + * BSM_WR_MEM_DST_REG = RTC_INST_LOWER_BOUND + * BSM_WR_MEM_DWCOUNT_REG = # dwords in bootstrap instruction image + * + * 4) Load bootstrap into instruction SRAM: + * BSM_WR_CTRL_REG = BSM_WR_CTRL_REG_BIT_START + * + * 5) Wait for load completion: + * Poll BSM_WR_CTRL_REG for BSM_WR_CTRL_REG_BIT_START = 0 + * + * 6) Enable future boot loads whenever NIC's power management triggers it: + * BSM_WR_CTRL_REG = BSM_WR_CTRL_REG_BIT_START_EN + * + * 7) Start the NIC by removing all reset bits: + * CSR_RESET = 0 + * + * The bootstrap uCode (already in instruction SRAM) loads initialization + * uCode. Initialization uCode performs data initialization, sends + * "initialize alive" notification to host, and waits for a signal from + * host to load runtime code. + * + * 4) Point (via BSM_DRAM_*) to the "runtime" uCode data and instruction + * images in host DRAM. The last register loaded must be the instruction + * byte count register ("1" in MSbit tells initialization uCode to load + * the runtime uCode): + * BSM_DRAM_INST_BYTECOUNT_REG = byte count | BSM_DRAM_INST_LOAD + * + * 5) Wait for "alive" notification, then issue normal runtime commands. + * + * Data caching during power-downs: + * + * Just before the embedded controller powers down (e.g for automatic + * power-saving modes, or for RFKILL), uCode stores (via PCI busmaster DMA) + * a current snapshot of the embedded processor's data SRAM into host DRAM. + * This caches the data while the embedded processor's memory is powered down. + * Location and size are controlled by BSM_DRAM_DATA_* registers. + * + * NOTE: Instruction SRAM does not need to be saved, since that doesn't + * change during operation; the original image (from uCode distribution + * file) can be used for reload. + * + * When powering back up, the BSM loads the bootstrap program. Bootstrap looks + * at the BSM_DRAM_* registers, which now point to the runtime instruction + * image and the cached (modified) runtime data (*not* the initialization + * uCode). Bootstrap reloads these runtime images into SRAM, and restarts the + * uCode from where it left off before the power-down. + * + * NOTE: Initialization uCode does *not* run as part of the save/restore + * procedure. + * + * This save/restore method is mostly for autonomous power management during + * normal operation (result of C_POWER_TBL). Platform suspend/resume and + * RFKILL should use complete restarts (with total re-initialization) of uCode, + * allowing total shutdown (including BSM memory). + * + * Note that, during normal operation, the host DRAM that held the initial + * startup data for the runtime code is now being used as a backup data cache + * for modified data! If you need to completely re-initialize the NIC, make + * sure that you use the runtime data image from the uCode distribution file, + * not the modified/saved runtime data. You may want to store a separate + * "clean" runtime data image in DRAM to avoid disk reads of distribution file. + */ + +/* BSM bit fields */ +#define BSM_WR_CTRL_REG_BIT_START (0x80000000) /* start boot load now */ +#define BSM_WR_CTRL_REG_BIT_START_EN (0x40000000) /* enable boot after pwrup*/ +#define BSM_DRAM_INST_LOAD (0x80000000) /* start program load now */ + +/* BSM addresses */ +#define BSM_BASE (PRPH_BASE + 0x3400) +#define BSM_END (PRPH_BASE + 0x3800) + +#define BSM_WR_CTRL_REG (BSM_BASE + 0x000) /* ctl and status */ +#define BSM_WR_MEM_SRC_REG (BSM_BASE + 0x004) /* source in BSM mem */ +#define BSM_WR_MEM_DST_REG (BSM_BASE + 0x008) /* dest in SRAM mem */ +#define BSM_WR_DWCOUNT_REG (BSM_BASE + 0x00C) /* bytes */ +#define BSM_WR_STATUS_REG (BSM_BASE + 0x010) /* bit 0: 1 == done */ + +/* + * Pointers and size regs for bootstrap load and data SRAM save/restore. + * NOTE: 3945 pointers use bits 31:0 of DRAM address. + * 4965 pointers use bits 35:4 of DRAM address. + */ +#define BSM_DRAM_INST_PTR_REG (BSM_BASE + 0x090) +#define BSM_DRAM_INST_BYTECOUNT_REG (BSM_BASE + 0x094) +#define BSM_DRAM_DATA_PTR_REG (BSM_BASE + 0x098) +#define BSM_DRAM_DATA_BYTECOUNT_REG (BSM_BASE + 0x09C) + +/* + * BSM special memory, stays powered on during power-save sleeps. + * Read/write, address range from LOWER_BOUND to (LOWER_BOUND + SIZE -1) + */ +#define BSM_SRAM_LOWER_BOUND (PRPH_BASE + 0x3800) +#define BSM_SRAM_SIZE (1024) /* bytes */ + + +/* 3945 Tx scheduler registers */ +#define ALM_SCD_BASE (PRPH_BASE + 0x2E00) +#define ALM_SCD_MODE_REG (ALM_SCD_BASE + 0x000) +#define ALM_SCD_ARASTAT_REG (ALM_SCD_BASE + 0x004) +#define ALM_SCD_TXFACT_REG (ALM_SCD_BASE + 0x010) +#define ALM_SCD_TXF4MF_REG (ALM_SCD_BASE + 0x014) +#define ALM_SCD_TXF5MF_REG (ALM_SCD_BASE + 0x020) +#define ALM_SCD_SBYP_MODE_1_REG (ALM_SCD_BASE + 0x02C) +#define ALM_SCD_SBYP_MODE_2_REG (ALM_SCD_BASE + 0x030) + +/** + * Tx Scheduler + * + * The Tx Scheduler selects the next frame to be transmitted, choosing TFDs + * (Transmit Frame Descriptors) from up to 16 circular Tx queues resident in + * host DRAM. It steers each frame's Tx command (which contains the frame + * data) into one of up to 7 prioritized Tx DMA FIFO channels within the + * device. A queue maps to only one (selectable by driver) Tx DMA channel, + * but one DMA channel may take input from several queues. + * + * Tx DMA FIFOs have dedicated purposes. For 4965, they are used as follows + * (cf. default_queue_to_tx_fifo in 4965.c): + * + * 0 -- EDCA BK (background) frames, lowest priority + * 1 -- EDCA BE (best effort) frames, normal priority + * 2 -- EDCA VI (video) frames, higher priority + * 3 -- EDCA VO (voice) and management frames, highest priority + * 4 -- Commands (e.g. RXON, etc.) + * 5 -- unused (HCCA) + * 6 -- unused (HCCA) + * 7 -- not used by driver (device-internal only) + * + * + * Driver should normally map queues 0-6 to Tx DMA/FIFO channels 0-6. + * In addition, driver can map the remaining queues to Tx DMA/FIFO + * channels 0-3 to support 11n aggregation via EDCA DMA channels. + * + * The driver sets up each queue to work in one of two modes: + * + * 1) Scheduler-Ack, in which the scheduler automatically supports a + * block-ack (BA) win of up to 64 TFDs. In this mode, each queue + * contains TFDs for a unique combination of Recipient Address (RA) + * and Traffic Identifier (TID), that is, traffic of a given + * Quality-Of-Service (QOS) priority, destined for a single station. + * + * In scheduler-ack mode, the scheduler keeps track of the Tx status of + * each frame within the BA win, including whether it's been transmitted, + * and whether it's been acknowledged by the receiving station. The device + * automatically processes block-acks received from the receiving STA, + * and reschedules un-acked frames to be retransmitted (successful + * Tx completion may end up being out-of-order). + * + * The driver must maintain the queue's Byte Count table in host DRAM + * (struct il4965_sched_queue_byte_cnt_tbl) for this mode. + * This mode does not support fragmentation. + * + * 2) FIFO (a.k.a. non-Scheduler-ACK), in which each TFD is processed in order. + * The device may automatically retry Tx, but will retry only one frame + * at a time, until receiving ACK from receiving station, or reaching + * retry limit and giving up. + * + * The command queue (#4/#9) must use this mode! + * This mode does not require use of the Byte Count table in host DRAM. + * + * Driver controls scheduler operation via 3 means: + * 1) Scheduler registers + * 2) Shared scheduler data base in internal 4956 SRAM + * 3) Shared data in host DRAM + * + * Initialization: + * + * When loading, driver should allocate memory for: + * 1) 16 TFD circular buffers, each with space for (typically) 256 TFDs. + * 2) 16 Byte Count circular buffers in 16 KBytes contiguous memory + * (1024 bytes for each queue). + * + * After receiving "Alive" response from uCode, driver must initialize + * the scheduler (especially for queue #4/#9, the command queue, otherwise + * the driver can't issue commands!): + */ + +/** + * Max Tx win size is the max number of contiguous TFDs that the scheduler + * can keep track of at one time when creating block-ack chains of frames. + * Note that "64" matches the number of ack bits in a block-ack packet. + * Driver should use SCD_WIN_SIZE and SCD_FRAME_LIMIT values to initialize + * IL49_SCD_CONTEXT_QUEUE_OFFSET(x) values. + */ +#define SCD_WIN_SIZE 64 +#define SCD_FRAME_LIMIT 64 + +/* SCD registers are internal, must be accessed via HBUS_TARG_PRPH regs */ +#define IL49_SCD_START_OFFSET 0xa02c00 + +/* + * 4965 tells driver SRAM address for internal scheduler structs via this reg. + * Value is valid only after "Alive" response from uCode. + */ +#define IL49_SCD_SRAM_BASE_ADDR (IL49_SCD_START_OFFSET + 0x0) + +/* + * Driver may need to update queue-empty bits after changing queue's + * write and read pointers (idxes) during (re-)initialization (i.e. when + * scheduler is not tracking what's happening). + * Bit fields: + * 31-16: Write mask -- 1: update empty bit, 0: don't change empty bit + * 15-00: Empty state, one for each queue -- 1: empty, 0: non-empty + * NOTE: This register is not used by Linux driver. + */ +#define IL49_SCD_EMPTY_BITS (IL49_SCD_START_OFFSET + 0x4) + +/* + * Physical base address of array of byte count (BC) circular buffers (CBs). + * Each Tx queue has a BC CB in host DRAM to support Scheduler-ACK mode. + * This register points to BC CB for queue 0, must be on 1024-byte boundary. + * Others are spaced by 1024 bytes. + * Each BC CB is 2 bytes * (256 + 64) = 740 bytes, followed by 384 bytes pad. + * (Index into a queue's BC CB) = (idx into queue's TFD CB) = (SSN & 0xff). + * Bit fields: + * 25-00: Byte Count CB physical address [35:10], must be 1024-byte aligned. + */ +#define IL49_SCD_DRAM_BASE_ADDR (IL49_SCD_START_OFFSET + 0x10) + +/* + * Enables any/all Tx DMA/FIFO channels. + * Scheduler generates requests for only the active channels. + * Set this to 0xff to enable all 8 channels (normal usage). + * Bit fields: + * 7- 0: Enable (1), disable (0), one bit for each channel 0-7 + */ +#define IL49_SCD_TXFACT (IL49_SCD_START_OFFSET + 0x1c) +/* + * Queue (x) Write Pointers (idxes, really!), one for each Tx queue. + * Initialized and updated by driver as new TFDs are added to queue. + * NOTE: If using Block Ack, idx must correspond to frame's + * Start Sequence Number; idx = (SSN & 0xff) + * NOTE: Alternative to HBUS_TARG_WRPTR, which is what Linux driver uses? + */ +#define IL49_SCD_QUEUE_WRPTR(x) (IL49_SCD_START_OFFSET + 0x24 + (x) * 4) + +/* + * Queue (x) Read Pointers (idxes, really!), one for each Tx queue. + * For FIFO mode, idx indicates next frame to transmit. + * For Scheduler-ACK mode, idx indicates first frame in Tx win. + * Initialized by driver, updated by scheduler. + */ +#define IL49_SCD_QUEUE_RDPTR(x) (IL49_SCD_START_OFFSET + 0x64 + (x) * 4) + +/* + * Select which queues work in chain mode (1) vs. not (0). + * Use chain mode to build chains of aggregated frames. + * Bit fields: + * 31-16: Reserved + * 15-00: Mode, one bit for each queue -- 1: Chain mode, 0: one-at-a-time + * NOTE: If driver sets up queue for chain mode, it should be also set up + * Scheduler-ACK mode as well, via SCD_QUEUE_STATUS_BITS(x). + */ +#define IL49_SCD_QUEUECHAIN_SEL (IL49_SCD_START_OFFSET + 0xd0) + +/* + * Select which queues interrupt driver when scheduler increments + * a queue's read pointer (idx). + * Bit fields: + * 31-16: Reserved + * 15-00: Interrupt enable, one bit for each queue -- 1: enabled, 0: disabled + * NOTE: This functionality is apparently a no-op; driver relies on interrupts + * from Rx queue to read Tx command responses and update Tx queues. + */ +#define IL49_SCD_INTERRUPT_MASK (IL49_SCD_START_OFFSET + 0xe4) + +/* + * Queue search status registers. One for each queue. + * Sets up queue mode and assigns queue to Tx DMA channel. + * Bit fields: + * 19-10: Write mask/enable bits for bits 0-9 + * 9: Driver should init to "0" + * 8: Scheduler-ACK mode (1), non-Scheduler-ACK (i.e. FIFO) mode (0). + * Driver should init to "1" for aggregation mode, or "0" otherwise. + * 7-6: Driver should init to "0" + * 5: Window Size Left; indicates whether scheduler can request + * another TFD, based on win size, etc. Driver should init + * this bit to "1" for aggregation mode, or "0" for non-agg. + * 4-1: Tx FIFO to use (range 0-7). + * 0: Queue is active (1), not active (0). + * Other bits should be written as "0" + * + * NOTE: If enabling Scheduler-ACK mode, chain mode should also be enabled + * via SCD_QUEUECHAIN_SEL. + */ +#define IL49_SCD_QUEUE_STATUS_BITS(x)\ + (IL49_SCD_START_OFFSET + 0x104 + (x) * 4) + +/* Bit field positions */ +#define IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE (0) +#define IL49_SCD_QUEUE_STTS_REG_POS_TXF (1) +#define IL49_SCD_QUEUE_STTS_REG_POS_WSL (5) +#define IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK (8) + +/* Write masks */ +#define IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN (10) +#define IL49_SCD_QUEUE_STTS_REG_MSK (0x0007FC00) + +/** + * 4965 internal SRAM structures for scheduler, shared with driver ... + * + * Driver should clear and initialize the following areas after receiving + * "Alive" response from 4965 uCode, i.e. after initial + * uCode load, or after a uCode load done for error recovery: + * + * SCD_CONTEXT_DATA_OFFSET (size 128 bytes) + * SCD_TX_STTS_BITMAP_OFFSET (size 256 bytes) + * SCD_TRANSLATE_TBL_OFFSET (size 32 bytes) + * + * Driver accesses SRAM via HBUS_TARG_MEM_* registers. + * Driver reads base address of this scheduler area from SCD_SRAM_BASE_ADDR. + * All OFFSET values must be added to this base address. + */ + +/* + * Queue context. One 8-byte entry for each of 16 queues. + * + * Driver should clear this entire area (size 0x80) to 0 after receiving + * "Alive" notification from uCode. Additionally, driver should init + * each queue's entry as follows: + * + * LS Dword bit fields: + * 0-06: Max Tx win size for Scheduler-ACK. Driver should init to 64. + * + * MS Dword bit fields: + * 16-22: Frame limit. Driver should init to 10 (0xa). + * + * Driver should init all other bits to 0. + * + * Init must be done after driver receives "Alive" response from 4965 uCode, + * and when setting up queue for aggregation. + */ +#define IL49_SCD_CONTEXT_DATA_OFFSET 0x380 +#define IL49_SCD_CONTEXT_QUEUE_OFFSET(x) \ + (IL49_SCD_CONTEXT_DATA_OFFSET + ((x) * 8)) + +#define IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS (0) +#define IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK (0x0000007F) +#define IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS (16) +#define IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK (0x007F0000) + +/* + * Tx Status Bitmap + * + * Driver should clear this entire area (size 0x100) to 0 after receiving + * "Alive" notification from uCode. Area is used only by device itself; + * no other support (besides clearing) is required from driver. + */ +#define IL49_SCD_TX_STTS_BITMAP_OFFSET 0x400 + +/* + * RAxTID to queue translation mapping. + * + * When queue is in Scheduler-ACK mode, frames placed in a that queue must be + * for only one combination of receiver address (RA) and traffic ID (TID), i.e. + * one QOS priority level destined for one station (for this wireless link, + * not final destination). The SCD_TRANSLATE_TBL area provides 16 16-bit + * mappings, one for each of the 16 queues. If queue is not in Scheduler-ACK + * mode, the device ignores the mapping value. + * + * Bit fields, for each 16-bit map: + * 15-9: Reserved, set to 0 + * 8-4: Index into device's station table for recipient station + * 3-0: Traffic ID (tid), range 0-15 + * + * Driver should clear this entire area (size 32 bytes) to 0 after receiving + * "Alive" notification from uCode. To update a 16-bit map value, driver + * must read a dword-aligned value from device SRAM, replace the 16-bit map + * value of interest, and write the dword value back into device SRAM. + */ +#define IL49_SCD_TRANSLATE_TBL_OFFSET 0x500 + +/* Find translation table dword to read/write for given queue */ +#define IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(x) \ + ((IL49_SCD_TRANSLATE_TBL_OFFSET + ((x) * 2)) & 0xfffffffc) + +#define IL_SCD_TXFIFO_POS_TID (0) +#define IL_SCD_TXFIFO_POS_RA (4) +#define IL_SCD_QUEUE_RA_TID_MAP_RATID_MSK (0x01FF) + +/*********************** END TX SCHEDULER *************************************/ + +#endif /* __il_prph_h__ */ -- cgit v1.2.3 From 53143a1809db521ff34371f066bfd8f1619ec2c9 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 14:14:18 +0200 Subject: iwlegacy: use FH39_ prefix in 3945 code Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/3945-mac.c | 2 +- drivers/net/wireless/iwlegacy/3945.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 3c8999960011..ffd6ddf89ec1 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -1528,7 +1528,7 @@ static void il3945_irq_tasklet(struct il_priv *il) if (inta & ~il->inta_mask) { IL_WARN("Disabled INTA bits 0x%08x were pending\n", inta & ~il->inta_mask); - IL_WARN(" with FH_INT = 0x%08x\n", inta_fh); + IL_WARN(" with inta_fh = 0x%08x\n", inta_fh); } /* Re-enable all interrupts */ diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index 33233abdd9bb..ed367bb7878f 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -481,8 +481,8 @@ static inline int il3945_hw_valid_rtc_data_addr(u32 addr) addr < IL39_RTC_DATA_UPPER_BOUND); } -/* Base physical address of il3945_shared is provided to FH_TSSR_CBB_BASE - * and &il3945_shared.rx_read_ptr[0] is provided to FH_RCSR_RPTR_ADDR(0) */ +/* Base physical address of il3945_shared is provided to FH39_TSSR_CBB_BASE + * and &il3945_shared.rx_read_ptr[0] is provided to FH39_RCSR_RPTR_ADDR(0) */ struct il3945_shared { __le32 tx_base_ptr[8]; } __packed; -- cgit v1.2.3 From 9a95b37015de03aa82bf340b3ee8e97af11be910 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 14:20:23 +0200 Subject: iwlegacy: use FH49_ prefix in 4965 code Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/4965-mac.c | 96 +++++++------- drivers/net/wireless/iwlegacy/4965.c | 2 +- drivers/net/wireless/iwlegacy/common.h | 2 +- drivers/net/wireless/iwlegacy/iwl-fh.h | 206 +++++++++++++++---------------- 4 files changed, 153 insertions(+), 153 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 82b6a7b8624a..9e3f74c8e9a7 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -138,22 +138,22 @@ int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) u32 rb_timeout = 0; if (il->cfg->mod_params->amsdu_size_8K) - rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K; + rb_size = FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K; else - rb_size = FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K; + rb_size = FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K; /* Stop Rx DMA */ - il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); + il_wr(il, FH49_MEM_RCSR_CHNL0_CONFIG_REG, 0); /* Reset driver's Rx queue write idx */ - il_wr(il, FH_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); + il_wr(il, FH49_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); /* Tell device where to find RBD circular buffer in DRAM */ - il_wr(il, FH_RSCSR_CHNL0_RBDCB_BASE_REG, + il_wr(il, FH49_RSCSR_CHNL0_RBDCB_BASE_REG, (u32)(rxq->bd_dma >> 8)); /* Tell device where in DRAM to update its Rx status */ - il_wr(il, FH_RSCSR_CHNL0_STTS_WPTR_REG, + il_wr(il, FH49_RSCSR_CHNL0_STTS_WPTR_REG, rxq->rb_stts_dma >> 4); /* Enable Rx DMA @@ -162,13 +162,13 @@ int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) * RB timeout 0x10 * 256 RBDs */ - il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, - FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL | - FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL | - FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK | + il_wr(il, FH49_MEM_RCSR_CHNL0_CONFIG_REG, + FH49_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL | + FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL | + FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK | rb_size| - (rb_timeout << FH_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS)| - (rfdnlog << FH_RCSR_RX_CONFIG_RBDCB_SIZE_POS)); + (rb_timeout << FH49_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS)| + (rfdnlog << FH49_RCSR_RX_CONFIG_RBDCB_SIZE_POS)); /* Set interrupt coalescing timer to default (2048 usecs) */ il_write8(il, CSR_INT_COALESCING, IL_HOST_INT_TIMEOUT_DEF); @@ -443,9 +443,9 @@ int il4965_rxq_stop(struct il_priv *il) { /* stop Rx DMA */ - il_wr(il, FH_MEM_RCSR_CHNL0_CONFIG_REG, 0); - il_poll_bit(il, FH_MEM_RSSR_RX_STATUS_REG, - FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); + il_wr(il, FH49_MEM_RCSR_CHNL0_CONFIG_REG, 0); + il_poll_bit(il, FH49_MEM_RSSR_RX_STATUS_REG, + FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); return 0; } @@ -1180,15 +1180,15 @@ u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant, u8 valid) static const char *il4965_get_fh_string(int cmd) { switch (cmd) { - IL_CMD(FH_RSCSR_CHNL0_STTS_WPTR_REG); - IL_CMD(FH_RSCSR_CHNL0_RBDCB_BASE_REG); - IL_CMD(FH_RSCSR_CHNL0_WPTR); - IL_CMD(FH_MEM_RCSR_CHNL0_CONFIG_REG); - IL_CMD(FH_MEM_RSSR_SHARED_CTRL_REG); - IL_CMD(FH_MEM_RSSR_RX_STATUS_REG); - IL_CMD(FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV); - IL_CMD(FH_TSSR_TX_STATUS_REG); - IL_CMD(FH_TSSR_TX_ERROR_REG); + IL_CMD(FH49_RSCSR_CHNL0_STTS_WPTR_REG); + IL_CMD(FH49_RSCSR_CHNL0_RBDCB_BASE_REG); + IL_CMD(FH49_RSCSR_CHNL0_WPTR); + IL_CMD(FH49_MEM_RCSR_CHNL0_CONFIG_REG); + IL_CMD(FH49_MEM_RSSR_SHARED_CTRL_REG); + IL_CMD(FH49_MEM_RSSR_RX_STATUS_REG); + IL_CMD(FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV); + IL_CMD(FH49_TSSR_TX_STATUS_REG); + IL_CMD(FH49_TSSR_TX_ERROR_REG); default: return "UNKNOWN"; } @@ -1202,15 +1202,15 @@ int il4965_dump_fh(struct il_priv *il, char **buf, bool display) size_t bufsz = 0; #endif static const u32 fh_tbl[] = { - FH_RSCSR_CHNL0_STTS_WPTR_REG, - FH_RSCSR_CHNL0_RBDCB_BASE_REG, - FH_RSCSR_CHNL0_WPTR, - FH_MEM_RCSR_CHNL0_CONFIG_REG, - FH_MEM_RSSR_SHARED_CTRL_REG, - FH_MEM_RSSR_RX_STATUS_REG, - FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV, - FH_TSSR_TX_STATUS_REG, - FH_TSSR_TX_ERROR_REG + FH49_RSCSR_CHNL0_STTS_WPTR_REG, + FH49_RSCSR_CHNL0_RBDCB_BASE_REG, + FH49_RSCSR_CHNL0_WPTR, + FH49_MEM_RCSR_CHNL0_CONFIG_REG, + FH49_MEM_RSSR_SHARED_CTRL_REG, + FH49_MEM_RSSR_RX_STATUS_REG, + FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV, + FH49_TSSR_TX_STATUS_REG, + FH49_TSSR_TX_ERROR_REG }; #ifdef CONFIG_IWLEGACY_DEBUG if (display) { @@ -2010,7 +2010,7 @@ int il4965_txq_ctx_alloc(struct il_priv *il) il4965_txq_set_sched(il, 0); /* Tell NIC where to find the "keep warm" buffer */ - il_wr(il, FH_KW_MEM_ADDR_REG, il->kw.dma >> 4); + il_wr(il, FH49_KW_MEM_ADDR_REG, il->kw.dma >> 4); spin_unlock_irqrestore(&il->lock, flags); @@ -2049,7 +2049,7 @@ void il4965_txq_ctx_reset(struct il_priv *il) il4965_txq_set_sched(il, 0); /* Tell NIC where to find the "keep warm" buffer */ - il_wr(il, FH_KW_MEM_ADDR_REG, il->kw.dma >> 4); + il_wr(il, FH49_KW_MEM_ADDR_REG, il->kw.dma >> 4); spin_unlock_irqrestore(&il->lock, flags); @@ -2078,14 +2078,14 @@ void il4965_txq_ctx_stop(struct il_priv *il) /* Stop each Tx DMA channel, and wait for it to be idle */ for (ch = 0; ch < il->hw_params.dma_chnl_num; ch++) { il_wr(il, - FH_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0); - if (il_poll_bit(il, FH_TSSR_TX_STATUS_REG, - FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), + FH49_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0); + if (il_poll_bit(il, FH49_TSSR_TX_STATUS_REG, + FH49_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), 1000)) IL_ERR("Failing on timeout while stopping" " DMA channel %d [0x%08x]", ch, il_rd(il, - FH_TSSR_TX_STATUS_REG)); + FH49_TSSR_TX_STATUS_REG)); } spin_unlock_irqrestore(&il->lock, flags); @@ -3743,7 +3743,7 @@ int il4965_hw_tx_queue_init(struct il_priv *il, int txq_id = txq->q.id; /* Circular buffer (TFD queue in DRAM) physical base address */ - il_wr(il, FH_MEM_CBBC_QUEUE(txq_id), + il_wr(il, FH49_MEM_CBBC_QUEUE(txq_id), txq->q.dma_addr >> 8); return 0; @@ -4262,7 +4262,7 @@ static void il4965_irq_tasklet(struct il_priv *il) if (inta & ~(il->inta_mask)) { IL_WARN("Disabled INTA bits 0x%08x were pending\n", inta & ~il->inta_mask); - IL_WARN(" with FH_INT = 0x%08x\n", inta_fh); + IL_WARN(" with FH49_INT = 0x%08x\n", inta_fh); } /* Re-enable all interrupts */ @@ -4798,7 +4798,7 @@ static const char * const desc_lookup_text[] = { "HW_ERROR_TEMPERATURE", "ILLEGAL_CHAN_FREQ", "VCC_NOT_STBL", - "FH_ERROR", + "FH49_ERROR", "NMI_INTERRUPT_HOST", "NMI_INTERRUPT_ACTION_PT", "NMI_INTERRUPT_UNKNOWN", @@ -4969,14 +4969,14 @@ static int il4965_alive_notify(struct il_priv *il) /* Enable DMA channel */ for (chan = 0; chan < FH49_TCSR_CHNL_NUM ; chan++) il_wr(il, - FH_TCSR_CHNL_TX_CONFIG_REG(chan), - FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | - FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE); + FH49_TCSR_CHNL_TX_CONFIG_REG(chan), + FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | + FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE); /* Update FH chicken bits */ - reg_val = il_rd(il, FH_TX_CHICKEN_BITS_REG); - il_wr(il, FH_TX_CHICKEN_BITS_REG, - reg_val | FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); + reg_val = il_rd(il, FH49_TX_CHICKEN_BITS_REG); + il_wr(il, FH49_TX_CHICKEN_BITS_REG, + reg_val | FH49_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); /* Disable chain mode for all queues */ il_wr_prph(il, IL49_SCD_QUEUECHAIN_SEL, 0); diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 4b977177d8b6..cbbb2c03f51b 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -630,7 +630,7 @@ static int il4965_hw_set_hw_params(struct il_priv *il) il->hw_params.max_bsm_size = BSM_SRAM_SIZE; il->hw_params.ht40_channel = BIT(IEEE80211_BAND_5GHZ); - il->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR; + il->hw_params.rx_wrt_ptr_reg = FH49_RSCSR_CHNL0_WPTR; il->hw_params.tx_chains_num = il4965_num_of_ant(il->cfg->valid_tx_ant); il->hw_params.rx_chains_num = il4965_num_of_ant(il->cfg->valid_rx_ant); diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 8ae4e3f667eb..be057aa511b6 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -2835,7 +2835,7 @@ struct il_tfd_tb { * contiguous 256 TFDs x 128 bytes-per-TFD = 32 KBytes * * Driver must indicate the physical address of the base of each - * circular buffer via the FH_MEM_CBBC_QUEUE registers. + * circular buffer via the FH49_MEM_CBBC_QUEUE registers. * * Each TFD contains pointer/size information for up to 20 data buffers * in host DRAM. These buffers collectively contain the (one) frame described diff --git a/drivers/net/wireless/iwlegacy/iwl-fh.h b/drivers/net/wireless/iwlegacy/iwl-fh.h index 7846baeef585..ac7c21283205 100644 --- a/drivers/net/wireless/iwlegacy/iwl-fh.h +++ b/drivers/net/wireless/iwlegacy/iwl-fh.h @@ -71,8 +71,8 @@ * This I/O area is directly read/writable by driver (e.g. Linux uses writel()) * Addresses are offsets from device's PCI hardware base address. */ -#define FH_MEM_LOWER_BOUND (0x1000) -#define FH_MEM_UPPER_BOUND (0x2000) +#define FH49_MEM_LOWER_BOUND (0x1000) +#define FH49_MEM_UPPER_BOUND (0x2000) /** * Keep-Warm (KW) buffer base address. @@ -83,7 +83,7 @@ * from going into a power-savings mode that would cause higher DRAM latency, * and possible data over/under-runs, before all Tx/Rx is complete. * - * Driver loads FH_KW_MEM_ADDR_REG with the physical address (bits 35:4) + * Driver loads FH49_KW_MEM_ADDR_REG with the physical address (bits 35:4) * of the buffer, which must be 4K aligned. Once this is set up, the 4965 * automatically invokes keep-warm accesses when normal accesses might not * be sufficient to maintain fast DRAM response. @@ -91,7 +91,7 @@ * Bit fields: * 31-0: Keep-warm buffer physical base address [35:4], must be 4K aligned */ -#define FH_KW_MEM_ADDR_REG (FH_MEM_LOWER_BOUND + 0x97C) +#define FH49_KW_MEM_ADDR_REG (FH49_MEM_LOWER_BOUND + 0x97C) /** @@ -106,11 +106,11 @@ * Bit fields in each pointer register: * 27-0: TFD CB physical base address [35:8], must be 256-byte aligned */ -#define FH_MEM_CBBC_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0x9D0) -#define FH_MEM_CBBC_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xA10) +#define FH49_MEM_CBBC_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x9D0) +#define FH49_MEM_CBBC_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xA10) /* Find TFD CB base pointer for given queue (range 0-15). */ -#define FH_MEM_CBBC_QUEUE(x) (FH_MEM_CBBC_LOWER_BOUND + (x) * 0x4) +#define FH49_MEM_CBBC_QUEUE(x) (FH49_MEM_CBBC_LOWER_BOUND + (x) * 0x4) /** @@ -132,18 +132,18 @@ * Each entry (1 dword) points to a receive buffer (RB) of consistent size * (typically 4K, although 8K or 16K are also selectable by driver). * Driver sets up RB size and number of RBDs in the CB via Rx config - * register FH_MEM_RCSR_CHNL0_CONFIG_REG. + * register FH49_MEM_RCSR_CHNL0_CONFIG_REG. * * Bit fields within one RBD: * 27-0: Receive Buffer physical address bits [35:8], 256-byte aligned * * Driver sets physical address [35:8] of base of RBD circular buffer - * into FH_RSCSR_CHNL0_RBDCB_BASE_REG [27:0]. + * into FH49_RSCSR_CHNL0_RBDCB_BASE_REG [27:0]. * * 2) Rx status buffer, 8 bytes, in which 4965 indicates which Rx Buffers * (RBs) have been filled, via a "write pointer", actually the idx of * the RB's corresponding RBD within the circular buffer. Driver sets - * physical address [35:4] into FH_RSCSR_CHNL0_STTS_WPTR_REG [31:0]. + * physical address [35:4] into FH49_RSCSR_CHNL0_STTS_WPTR_REG [31:0]. * * Bit fields in lower dword of Rx status buffer (upper dword not used * by driver; see struct il4965_shared, val0): @@ -154,7 +154,7 @@ * As the driver prepares Receive Buffers (RBs) for 4965 to fill, driver must * enter pointers to these RBs into contiguous RBD circular buffer entries, * and update the 4965's "write" idx register, - * FH_RSCSR_CHNL0_RBDCB_WPTR_REG. + * FH49_RSCSR_CHNL0_RBDCB_WPTR_REG. * * This "write" idx corresponds to the *next* RBD that the driver will make * available, i.e. one RBD past the tail of the ready-to-fill RBDs within @@ -182,23 +182,23 @@ * and "read" idxes; that is, make sure that there are no more than 254 * buffers waiting to be filled. */ -#define FH_MEM_RSCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xBC0) -#define FH_MEM_RSCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xC00) -#define FH_MEM_RSCSR_CHNL0 (FH_MEM_RSCSR_LOWER_BOUND) +#define FH49_MEM_RSCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xBC0) +#define FH49_MEM_RSCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xC00) +#define FH49_MEM_RSCSR_CHNL0 (FH49_MEM_RSCSR_LOWER_BOUND) /** * Physical base address of 8-byte Rx Status buffer. * Bit fields: * 31-0: Rx status buffer physical base address [35:4], must 16-byte aligned. */ -#define FH_RSCSR_CHNL0_STTS_WPTR_REG (FH_MEM_RSCSR_CHNL0) +#define FH49_RSCSR_CHNL0_STTS_WPTR_REG (FH49_MEM_RSCSR_CHNL0) /** * Physical base address of Rx Buffer Descriptor Circular Buffer. * Bit fields: * 27-0: RBD CD physical base address [35:8], must be 256-byte aligned. */ -#define FH_RSCSR_CHNL0_RBDCB_BASE_REG (FH_MEM_RSCSR_CHNL0 + 0x004) +#define FH49_RSCSR_CHNL0_RBDCB_BASE_REG (FH49_MEM_RSCSR_CHNL0 + 0x004) /** * Rx write pointer (idx, really!). @@ -206,20 +206,20 @@ * 11-0: Index of driver's most recent prepared-to-be-filled RBD, + 1. * NOTE: For 256-entry circular buffer, use only bits [7:0]. */ -#define FH_RSCSR_CHNL0_RBDCB_WPTR_REG (FH_MEM_RSCSR_CHNL0 + 0x008) -#define FH_RSCSR_CHNL0_WPTR (FH_RSCSR_CHNL0_RBDCB_WPTR_REG) +#define FH49_RSCSR_CHNL0_RBDCB_WPTR_REG (FH49_MEM_RSCSR_CHNL0 + 0x008) +#define FH49_RSCSR_CHNL0_WPTR (FH49_RSCSR_CHNL0_RBDCB_WPTR_REG) /** * Rx Config/Status Registers (RCSR) * Rx Config Reg for channel 0 (only channel used) * - * Driver must initialize FH_MEM_RCSR_CHNL0_CONFIG_REG as follows for + * Driver must initialize FH49_MEM_RCSR_CHNL0_CONFIG_REG as follows for * normal operation (see bit fields). * - * Clearing FH_MEM_RCSR_CHNL0_CONFIG_REG to 0 turns off Rx DMA. - * Driver should poll FH_MEM_RSSR_RX_STATUS_REG for - * FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (bit 24) before continuing. + * Clearing FH49_MEM_RCSR_CHNL0_CONFIG_REG to 0 turns off Rx DMA. + * Driver should poll FH49_MEM_RSSR_RX_STATUS_REG for + * FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (bit 24) before continuing. * * Bit fields: * 31-30: Rx DMA channel enable: '00' off/pause, '01' pause at end of frame, @@ -236,67 +236,67 @@ * typical value 0x10 (about 1/2 msec) * 3- 0: reserved */ -#define FH_MEM_RCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xC00) -#define FH_MEM_RCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xCC0) -#define FH_MEM_RCSR_CHNL0 (FH_MEM_RCSR_LOWER_BOUND) +#define FH49_MEM_RCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xC00) +#define FH49_MEM_RCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xCC0) +#define FH49_MEM_RCSR_CHNL0 (FH49_MEM_RCSR_LOWER_BOUND) -#define FH_MEM_RCSR_CHNL0_CONFIG_REG (FH_MEM_RCSR_CHNL0) +#define FH49_MEM_RCSR_CHNL0_CONFIG_REG (FH49_MEM_RCSR_CHNL0) -#define FH_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MSK (0x00000FF0) /* bits 4-11 */ -#define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MSK (0x00001000) /* bits 12 */ -#define FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK (0x00008000) /* bit 15 */ -#define FH_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MSK (0x00030000) /* bits 16-17 */ -#define FH_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MSK (0x00F00000) /* bits 20-23 */ -#define FH_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MSK (0xC0000000) /* bits 30-31*/ +#define FH49_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MSK (0x00000FF0) /* bits 4-11 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MSK (0x00001000) /* bits 12 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK (0x00008000) /* bit 15 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MSK (0x00030000) /* bits 16-17 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MSK (0x00F00000) /* bits 20-23 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MSK (0xC0000000) /* bits 30-31*/ -#define FH_RCSR_RX_CONFIG_RBDCB_SIZE_POS (20) -#define FH_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS (4) +#define FH49_RCSR_RX_CONFIG_RBDCB_SIZE_POS (20) +#define FH49_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS (4) #define RX_RB_TIMEOUT (0x10) -#define FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_VAL (0x00000000) -#define FH_RCSR_RX_CONFIG_CHNL_EN_PAUSE_EOF_VAL (0x40000000) -#define FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL (0x80000000) +#define FH49_RCSR_RX_CONFIG_CHNL_EN_PAUSE_VAL (0x00000000) +#define FH49_RCSR_RX_CONFIG_CHNL_EN_PAUSE_EOF_VAL (0x40000000) +#define FH49_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL (0x80000000) -#define FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K (0x00000000) -#define FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K (0x00010000) -#define FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_12K (0x00020000) -#define FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_16K (0x00030000) +#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K (0x00000000) +#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K (0x00010000) +#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_12K (0x00020000) +#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_16K (0x00030000) -#define FH_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY (0x00000004) -#define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL (0x00000000) -#define FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL (0x00001000) +#define FH49_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY (0x00000004) +#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL (0x00000000) +#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL (0x00001000) /** * Rx Shared Status Registers (RSSR) * * After stopping Rx DMA channel (writing 0 to - * FH_MEM_RCSR_CHNL0_CONFIG_REG), driver must poll - * FH_MEM_RSSR_RX_STATUS_REG until Rx channel is idle. + * FH49_MEM_RCSR_CHNL0_CONFIG_REG), driver must poll + * FH49_MEM_RSSR_RX_STATUS_REG until Rx channel is idle. * * Bit fields: * 24: 1 = Channel 0 is idle * - * FH_MEM_RSSR_SHARED_CTRL_REG and FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV + * FH49_MEM_RSSR_SHARED_CTRL_REG and FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV * contain default values that should not be altered by the driver. */ -#define FH_MEM_RSSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xC40) -#define FH_MEM_RSSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xD00) +#define FH49_MEM_RSSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xC40) +#define FH49_MEM_RSSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xD00) -#define FH_MEM_RSSR_SHARED_CTRL_REG (FH_MEM_RSSR_LOWER_BOUND) -#define FH_MEM_RSSR_RX_STATUS_REG (FH_MEM_RSSR_LOWER_BOUND + 0x004) -#define FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV\ - (FH_MEM_RSSR_LOWER_BOUND + 0x008) +#define FH49_MEM_RSSR_SHARED_CTRL_REG (FH49_MEM_RSSR_LOWER_BOUND) +#define FH49_MEM_RSSR_RX_STATUS_REG (FH49_MEM_RSSR_LOWER_BOUND + 0x004) +#define FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV\ + (FH49_MEM_RSSR_LOWER_BOUND + 0x008) -#define FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000) +#define FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000) -#define FH_MEM_TFDIB_REG1_ADDR_BITSHIFT 28 +#define FH49_MEM_TFDIB_REG1_ADDR_BITSHIFT 28 /* TFDB Area - TFDs buffer table */ -#define FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK (0xFFFFFFFF) -#define FH_TFDIB_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0x900) -#define FH_TFDIB_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0x958) -#define FH_TFDIB_CTRL0_REG(_chnl) (FH_TFDIB_LOWER_BOUND + 0x8 * (_chnl)) -#define FH_TFDIB_CTRL1_REG(_chnl) (FH_TFDIB_LOWER_BOUND + 0x8 * (_chnl) + 0x4) +#define FH49_MEM_TFDIB_DRAM_ADDR_LSB_MSK (0xFFFFFFFF) +#define FH49_TFDIB_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x900) +#define FH49_TFDIB_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0x958) +#define FH49_TFDIB_CTRL0_REG(_chnl) (FH49_TFDIB_LOWER_BOUND + 0x8 * (_chnl)) +#define FH49_TFDIB_CTRL1_REG(_chnl) (FH49_TFDIB_LOWER_BOUND + 0x8 * (_chnl) + 0x4) /** * Transmit DMA Channel Control/Status Registers (TCSR) @@ -306,10 +306,10 @@ * which feed the DMA/FIFO channels); config regs are separated by 0x20 bytes. * * To use a Tx DMA channel, driver must initialize its - * FH_TCSR_CHNL_TX_CONFIG_REG(chnl) with: + * FH49_TCSR_CHNL_TX_CONFIG_REG(chnl) with: * - * FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | - * FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL + * FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | + * FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL * * All other bits should be 0. * @@ -320,62 +320,62 @@ * 3: Enable internal DMA requests (1, normal operation), disable (0) * 2- 0: Reserved, set to "0" */ -#define FH_TCSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xD00) -#define FH_TCSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xE60) +#define FH49_TCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xD00) +#define FH49_TCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xE60) /* Find Control/Status reg for given Tx DMA/FIFO channel */ #define FH49_TCSR_CHNL_NUM (7) #define FH50_TCSR_CHNL_NUM (8) /* TCSR: tx_config register values */ -#define FH_TCSR_CHNL_TX_CONFIG_REG(_chnl) \ - (FH_TCSR_LOWER_BOUND + 0x20 * (_chnl)) -#define FH_TCSR_CHNL_TX_CREDIT_REG(_chnl) \ - (FH_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x4) -#define FH_TCSR_CHNL_TX_BUF_STS_REG(_chnl) \ - (FH_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x8) +#define FH49_TCSR_CHNL_TX_CONFIG_REG(_chnl) \ + (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl)) +#define FH49_TCSR_CHNL_TX_CREDIT_REG(_chnl) \ + (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x4) +#define FH49_TCSR_CHNL_TX_BUF_STS_REG(_chnl) \ + (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x8) -#define FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000) -#define FH_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRV (0x00000001) +#define FH49_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRV (0x00000001) -#define FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE (0x00000000) -#define FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE (0x00000008) +#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE (0x00000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE (0x00000008) -#define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_NOINT (0x00000000) -#define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD (0x00100000) -#define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_NOINT (0x00000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD (0x00100000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000) -#define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000) -#define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_ENDTFD (0x00400000) -#define FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_IFTFD (0x00800000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_ENDTFD (0x00400000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_IFTFD (0x00800000) -#define FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000) -#define FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE_EOF (0x40000000) -#define FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE_EOF (0x40000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000) -#define FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_EMPTY (0x00000000) -#define FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_WAIT (0x00002000) -#define FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00000003) +#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_EMPTY (0x00000000) +#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_WAIT (0x00002000) +#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00000003) -#define FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM (20) -#define FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX (12) +#define FH49_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM (20) +#define FH49_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX (12) /** * Tx Shared Status Registers (TSSR) * * After stopping Tx DMA channel (writing 0 to - * FH_TCSR_CHNL_TX_CONFIG_REG(chnl)), driver must poll - * FH_TSSR_TX_STATUS_REG until selected Tx channel is idle + * FH49_TCSR_CHNL_TX_CONFIG_REG(chnl)), driver must poll + * FH49_TSSR_TX_STATUS_REG until selected Tx channel is idle * (channel's buffers empty | no pending requests). * * Bit fields: * 31-24: 1 = Channel buffers empty (channel 7:0) * 23-16: 1 = No pending requests (channel 7:0) */ -#define FH_TSSR_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0xEA0) -#define FH_TSSR_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0xEC0) +#define FH49_TSSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xEA0) +#define FH49_TSSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xEC0) -#define FH_TSSR_TX_STATUS_REG (FH_TSSR_LOWER_BOUND + 0x010) +#define FH49_TSSR_TX_STATUS_REG (FH49_TSSR_LOWER_BOUND + 0x010) /** * Bit fields for TSSR(Tx Shared Status & Control) error status register: @@ -394,22 +394,22 @@ * synchronized to the TxFIFO status * uCode/driver must write "1" in order to clear this flag */ -#define FH_TSSR_TX_ERROR_REG (FH_TSSR_LOWER_BOUND + 0x018) +#define FH49_TSSR_TX_ERROR_REG (FH49_TSSR_LOWER_BOUND + 0x018) -#define FH_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) ((1 << (_chnl)) << 16) +#define FH49_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) ((1 << (_chnl)) << 16) /* Tx service channels */ -#define FH_SRVC_CHNL (9) -#define FH_SRVC_LOWER_BOUND (FH_MEM_LOWER_BOUND + 0x9C8) -#define FH_SRVC_UPPER_BOUND (FH_MEM_LOWER_BOUND + 0x9D0) -#define FH_SRVC_CHNL_SRAM_ADDR_REG(_chnl) \ - (FH_SRVC_LOWER_BOUND + ((_chnl) - 9) * 0x4) +#define FH49_SRVC_CHNL (9) +#define FH49_SRVC_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x9C8) +#define FH49_SRVC_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0x9D0) +#define FH49_SRVC_CHNL_SRAM_ADDR_REG(_chnl) \ + (FH49_SRVC_LOWER_BOUND + ((_chnl) - 9) * 0x4) -#define FH_TX_CHICKEN_BITS_REG (FH_MEM_LOWER_BOUND + 0xE98) +#define FH49_TX_CHICKEN_BITS_REG (FH49_MEM_LOWER_BOUND + 0xE98) /* Instruct FH to increment the retry count of a packet when * it is brought from the memory to TX-FIFO */ -#define FH_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN (0x00000002) +#define FH49_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN (0x00000002) /* Keep Warm Size */ #define IL_KW_SIZE 0x1000 /* 4k */ -- cgit v1.2.3 From eac3b2127749af8ba033a755efdc0d4b43167906 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 14:29:46 +0200 Subject: iwlegacy: merge iwl-fh.h into 4965.h Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/4965.h | 352 +++++++++++++++++++++++++++- drivers/net/wireless/iwlegacy/iwl-fh.h | 417 --------------------------------- 2 files changed, 351 insertions(+), 418 deletions(-) delete mode 100644 drivers/net/wireless/iwlegacy/iwl-fh.h (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h index 5234de72a279..10d0b13e0e3c 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -30,7 +30,6 @@ #ifndef __il_4965_h__ #define __il_4965_h__ -#include "iwl-fh.h" #include "iwl-debug.h" struct il_rx_queue; @@ -1001,4 +1000,355 @@ il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, } #endif +/****************************/ +/* Flow Handler Definitions */ +/****************************/ + +/** + * This I/O area is directly read/writable by driver (e.g. Linux uses writel()) + * Addresses are offsets from device's PCI hardware base address. + */ +#define FH49_MEM_LOWER_BOUND (0x1000) +#define FH49_MEM_UPPER_BOUND (0x2000) + +/** + * Keep-Warm (KW) buffer base address. + * + * Driver must allocate a 4KByte buffer that is used by 4965 for keeping the + * host DRAM powered on (via dummy accesses to DRAM) to maintain low-latency + * DRAM access when 4965 is Txing or Rxing. The dummy accesses prevent host + * from going into a power-savings mode that would cause higher DRAM latency, + * and possible data over/under-runs, before all Tx/Rx is complete. + * + * Driver loads FH49_KW_MEM_ADDR_REG with the physical address (bits 35:4) + * of the buffer, which must be 4K aligned. Once this is set up, the 4965 + * automatically invokes keep-warm accesses when normal accesses might not + * be sufficient to maintain fast DRAM response. + * + * Bit fields: + * 31-0: Keep-warm buffer physical base address [35:4], must be 4K aligned + */ +#define FH49_KW_MEM_ADDR_REG (FH49_MEM_LOWER_BOUND + 0x97C) + + +/** + * TFD Circular Buffers Base (CBBC) addresses + * + * 4965 has 16 base pointer registers, one for each of 16 host-DRAM-resident + * circular buffers (CBs/queues) containing Transmit Frame Descriptors (TFDs) + * (see struct il_tfd_frame). These 16 pointer registers are offset by 0x04 + * bytes from one another. Each TFD circular buffer in DRAM must be 256-byte + * aligned (address bits 0-7 must be 0). + * + * Bit fields in each pointer register: + * 27-0: TFD CB physical base address [35:8], must be 256-byte aligned + */ +#define FH49_MEM_CBBC_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x9D0) +#define FH49_MEM_CBBC_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xA10) + +/* Find TFD CB base pointer for given queue (range 0-15). */ +#define FH49_MEM_CBBC_QUEUE(x) (FH49_MEM_CBBC_LOWER_BOUND + (x) * 0x4) + + +/** + * Rx SRAM Control and Status Registers (RSCSR) + * + * These registers provide handshake between driver and 4965 for the Rx queue + * (this queue handles *all* command responses, notifications, Rx data, etc. + * sent from 4965 uCode to host driver). Unlike Tx, there is only one Rx + * queue, and only one Rx DMA/FIFO channel. Also unlike Tx, which can + * concatenate up to 20 DRAM buffers to form a Tx frame, each Receive Buffer + * Descriptor (RBD) points to only one Rx Buffer (RB); there is a 1:1 + * mapping between RBDs and RBs. + * + * Driver must allocate host DRAM memory for the following, and set the + * physical address of each into 4965 registers: + * + * 1) Receive Buffer Descriptor (RBD) circular buffer (CB), typically with 256 + * entries (although any power of 2, up to 4096, is selectable by driver). + * Each entry (1 dword) points to a receive buffer (RB) of consistent size + * (typically 4K, although 8K or 16K are also selectable by driver). + * Driver sets up RB size and number of RBDs in the CB via Rx config + * register FH49_MEM_RCSR_CHNL0_CONFIG_REG. + * + * Bit fields within one RBD: + * 27-0: Receive Buffer physical address bits [35:8], 256-byte aligned + * + * Driver sets physical address [35:8] of base of RBD circular buffer + * into FH49_RSCSR_CHNL0_RBDCB_BASE_REG [27:0]. + * + * 2) Rx status buffer, 8 bytes, in which 4965 indicates which Rx Buffers + * (RBs) have been filled, via a "write pointer", actually the idx of + * the RB's corresponding RBD within the circular buffer. Driver sets + * physical address [35:4] into FH49_RSCSR_CHNL0_STTS_WPTR_REG [31:0]. + * + * Bit fields in lower dword of Rx status buffer (upper dword not used + * by driver; see struct il4965_shared, val0): + * 31-12: Not used by driver + * 11- 0: Index of last filled Rx buffer descriptor + * (4965 writes, driver reads this value) + * + * As the driver prepares Receive Buffers (RBs) for 4965 to fill, driver must + * enter pointers to these RBs into contiguous RBD circular buffer entries, + * and update the 4965's "write" idx register, + * FH49_RSCSR_CHNL0_RBDCB_WPTR_REG. + * + * This "write" idx corresponds to the *next* RBD that the driver will make + * available, i.e. one RBD past the tail of the ready-to-fill RBDs within + * the circular buffer. This value should initially be 0 (before preparing any + * RBs), should be 8 after preparing the first 8 RBs (for example), and must + * wrap back to 0 at the end of the circular buffer (but don't wrap before + * "read" idx has advanced past 1! See below). + * NOTE: 4965 EXPECTS THE WRITE IDX TO BE INCREMENTED IN MULTIPLES OF 8. + * + * As the 4965 fills RBs (referenced from contiguous RBDs within the circular + * buffer), it updates the Rx status buffer in host DRAM, 2) described above, + * to tell the driver the idx of the latest filled RBD. The driver must + * read this "read" idx from DRAM after receiving an Rx interrupt from 4965. + * + * The driver must also internally keep track of a third idx, which is the + * next RBD to process. When receiving an Rx interrupt, driver should process + * all filled but unprocessed RBs up to, but not including, the RB + * corresponding to the "read" idx. For example, if "read" idx becomes "1", + * driver may process the RB pointed to by RBD 0. Depending on volume of + * traffic, there may be many RBs to process. + * + * If read idx == write idx, 4965 thinks there is no room to put new data. + * Due to this, the maximum number of filled RBs is 255, instead of 256. To + * be safe, make sure that there is a gap of at least 2 RBDs between "write" + * and "read" idxes; that is, make sure that there are no more than 254 + * buffers waiting to be filled. + */ +#define FH49_MEM_RSCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xBC0) +#define FH49_MEM_RSCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xC00) +#define FH49_MEM_RSCSR_CHNL0 (FH49_MEM_RSCSR_LOWER_BOUND) + +/** + * Physical base address of 8-byte Rx Status buffer. + * Bit fields: + * 31-0: Rx status buffer physical base address [35:4], must 16-byte aligned. + */ +#define FH49_RSCSR_CHNL0_STTS_WPTR_REG (FH49_MEM_RSCSR_CHNL0) + +/** + * Physical base address of Rx Buffer Descriptor Circular Buffer. + * Bit fields: + * 27-0: RBD CD physical base address [35:8], must be 256-byte aligned. + */ +#define FH49_RSCSR_CHNL0_RBDCB_BASE_REG (FH49_MEM_RSCSR_CHNL0 + 0x004) + +/** + * Rx write pointer (idx, really!). + * Bit fields: + * 11-0: Index of driver's most recent prepared-to-be-filled RBD, + 1. + * NOTE: For 256-entry circular buffer, use only bits [7:0]. + */ +#define FH49_RSCSR_CHNL0_RBDCB_WPTR_REG (FH49_MEM_RSCSR_CHNL0 + 0x008) +#define FH49_RSCSR_CHNL0_WPTR (FH49_RSCSR_CHNL0_RBDCB_WPTR_REG) + + +/** + * Rx Config/Status Registers (RCSR) + * Rx Config Reg for channel 0 (only channel used) + * + * Driver must initialize FH49_MEM_RCSR_CHNL0_CONFIG_REG as follows for + * normal operation (see bit fields). + * + * Clearing FH49_MEM_RCSR_CHNL0_CONFIG_REG to 0 turns off Rx DMA. + * Driver should poll FH49_MEM_RSSR_RX_STATUS_REG for + * FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (bit 24) before continuing. + * + * Bit fields: + * 31-30: Rx DMA channel enable: '00' off/pause, '01' pause at end of frame, + * '10' operate normally + * 29-24: reserved + * 23-20: # RBDs in circular buffer = 2^value; use "8" for 256 RBDs (normal), + * min "5" for 32 RBDs, max "12" for 4096 RBDs. + * 19-18: reserved + * 17-16: size of each receive buffer; '00' 4K (normal), '01' 8K, + * '10' 12K, '11' 16K. + * 15-14: reserved + * 13-12: IRQ destination; '00' none, '01' host driver (normal operation) + * 11- 4: timeout for closing Rx buffer and interrupting host (units 32 usec) + * typical value 0x10 (about 1/2 msec) + * 3- 0: reserved + */ +#define FH49_MEM_RCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xC00) +#define FH49_MEM_RCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xCC0) +#define FH49_MEM_RCSR_CHNL0 (FH49_MEM_RCSR_LOWER_BOUND) + +#define FH49_MEM_RCSR_CHNL0_CONFIG_REG (FH49_MEM_RCSR_CHNL0) + +#define FH49_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MSK (0x00000FF0) /* bits 4-11 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MSK (0x00001000) /* bits 12 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK (0x00008000) /* bit 15 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MSK (0x00030000) /* bits 16-17 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MSK (0x00F00000) /* bits 20-23 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MSK (0xC0000000) /* bits 30-31*/ + +#define FH49_RCSR_RX_CONFIG_RBDCB_SIZE_POS (20) +#define FH49_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS (4) +#define RX_RB_TIMEOUT (0x10) + +#define FH49_RCSR_RX_CONFIG_CHNL_EN_PAUSE_VAL (0x00000000) +#define FH49_RCSR_RX_CONFIG_CHNL_EN_PAUSE_EOF_VAL (0x40000000) +#define FH49_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL (0x80000000) + +#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K (0x00000000) +#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K (0x00010000) +#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_12K (0x00020000) +#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_16K (0x00030000) + +#define FH49_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY (0x00000004) +#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL (0x00000000) +#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL (0x00001000) + +/** + * Rx Shared Status Registers (RSSR) + * + * After stopping Rx DMA channel (writing 0 to + * FH49_MEM_RCSR_CHNL0_CONFIG_REG), driver must poll + * FH49_MEM_RSSR_RX_STATUS_REG until Rx channel is idle. + * + * Bit fields: + * 24: 1 = Channel 0 is idle + * + * FH49_MEM_RSSR_SHARED_CTRL_REG and FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV + * contain default values that should not be altered by the driver. + */ +#define FH49_MEM_RSSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xC40) +#define FH49_MEM_RSSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xD00) + +#define FH49_MEM_RSSR_SHARED_CTRL_REG (FH49_MEM_RSSR_LOWER_BOUND) +#define FH49_MEM_RSSR_RX_STATUS_REG (FH49_MEM_RSSR_LOWER_BOUND + 0x004) +#define FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV\ + (FH49_MEM_RSSR_LOWER_BOUND + 0x008) + +#define FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000) + +#define FH49_MEM_TFDIB_REG1_ADDR_BITSHIFT 28 + +/* TFDB Area - TFDs buffer table */ +#define FH49_MEM_TFDIB_DRAM_ADDR_LSB_MSK (0xFFFFFFFF) +#define FH49_TFDIB_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x900) +#define FH49_TFDIB_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0x958) +#define FH49_TFDIB_CTRL0_REG(_chnl) (FH49_TFDIB_LOWER_BOUND + 0x8 * (_chnl)) +#define FH49_TFDIB_CTRL1_REG(_chnl) (FH49_TFDIB_LOWER_BOUND + 0x8 * (_chnl) + 0x4) + +/** + * Transmit DMA Channel Control/Status Registers (TCSR) + * + * 4965 has one configuration register for each of 8 Tx DMA/FIFO channels + * supported in hardware (don't confuse these with the 16 Tx queues in DRAM, + * which feed the DMA/FIFO channels); config regs are separated by 0x20 bytes. + * + * To use a Tx DMA channel, driver must initialize its + * FH49_TCSR_CHNL_TX_CONFIG_REG(chnl) with: + * + * FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | + * FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL + * + * All other bits should be 0. + * + * Bit fields: + * 31-30: Tx DMA channel enable: '00' off/pause, '01' pause at end of frame, + * '10' operate normally + * 29- 4: Reserved, set to "0" + * 3: Enable internal DMA requests (1, normal operation), disable (0) + * 2- 0: Reserved, set to "0" + */ +#define FH49_TCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xD00) +#define FH49_TCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xE60) + +/* Find Control/Status reg for given Tx DMA/FIFO channel */ +#define FH49_TCSR_CHNL_NUM (7) +#define FH50_TCSR_CHNL_NUM (8) + +/* TCSR: tx_config register values */ +#define FH49_TCSR_CHNL_TX_CONFIG_REG(_chnl) \ + (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl)) +#define FH49_TCSR_CHNL_TX_CREDIT_REG(_chnl) \ + (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x4) +#define FH49_TCSR_CHNL_TX_BUF_STS_REG(_chnl) \ + (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x8) + +#define FH49_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRV (0x00000001) + +#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE (0x00000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE (0x00000008) + +#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_NOINT (0x00000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD (0x00100000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000) + +#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_ENDTFD (0x00400000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_IFTFD (0x00800000) + +#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE_EOF (0x40000000) +#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000) + +#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_EMPTY (0x00000000) +#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_WAIT (0x00002000) +#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00000003) + +#define FH49_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM (20) +#define FH49_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX (12) + +/** + * Tx Shared Status Registers (TSSR) + * + * After stopping Tx DMA channel (writing 0 to + * FH49_TCSR_CHNL_TX_CONFIG_REG(chnl)), driver must poll + * FH49_TSSR_TX_STATUS_REG until selected Tx channel is idle + * (channel's buffers empty | no pending requests). + * + * Bit fields: + * 31-24: 1 = Channel buffers empty (channel 7:0) + * 23-16: 1 = No pending requests (channel 7:0) + */ +#define FH49_TSSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xEA0) +#define FH49_TSSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xEC0) + +#define FH49_TSSR_TX_STATUS_REG (FH49_TSSR_LOWER_BOUND + 0x010) + +/** + * Bit fields for TSSR(Tx Shared Status & Control) error status register: + * 31: Indicates an address error when accessed to internal memory + * uCode/driver must write "1" in order to clear this flag + * 30: Indicates that Host did not send the expected number of dwords to FH + * uCode/driver must write "1" in order to clear this flag + * 16-9:Each status bit is for one channel. Indicates that an (Error) ActDMA + * command was received from the scheduler while the TRB was already full + * with previous command + * uCode/driver must write "1" in order to clear this flag + * 7-0: Each status bit indicates a channel's TxCredit error. When an error + * bit is set, it indicates that the FH has received a full indication + * from the RTC TxFIFO and the current value of the TxCredit counter was + * not equal to zero. This mean that the credit mechanism was not + * synchronized to the TxFIFO status + * uCode/driver must write "1" in order to clear this flag + */ +#define FH49_TSSR_TX_ERROR_REG (FH49_TSSR_LOWER_BOUND + 0x018) + +#define FH49_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) ((1 << (_chnl)) << 16) + +/* Tx service channels */ +#define FH49_SRVC_CHNL (9) +#define FH49_SRVC_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x9C8) +#define FH49_SRVC_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0x9D0) +#define FH49_SRVC_CHNL_SRAM_ADDR_REG(_chnl) \ + (FH49_SRVC_LOWER_BOUND + ((_chnl) - 9) * 0x4) + +#define FH49_TX_CHICKEN_BITS_REG (FH49_MEM_LOWER_BOUND + 0xE98) +/* Instruct FH to increment the retry count of a packet when + * it is brought from the memory to TX-FIFO + */ +#define FH49_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN (0x00000002) + +/* Keep Warm Size */ +#define IL_KW_SIZE 0x1000 /* 4k */ + #endif /* __il_4965_h__ */ diff --git a/drivers/net/wireless/iwlegacy/iwl-fh.h b/drivers/net/wireless/iwlegacy/iwl-fh.h deleted file mode 100644 index ac7c21283205..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-fh.h +++ /dev/null @@ -1,417 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2005 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - *****************************************************************************/ -#ifndef __il_fh_h__ -#define __il_fh_h__ - -/****************************/ -/* Flow Handler Definitions */ -/****************************/ - -/** - * This I/O area is directly read/writable by driver (e.g. Linux uses writel()) - * Addresses are offsets from device's PCI hardware base address. - */ -#define FH49_MEM_LOWER_BOUND (0x1000) -#define FH49_MEM_UPPER_BOUND (0x2000) - -/** - * Keep-Warm (KW) buffer base address. - * - * Driver must allocate a 4KByte buffer that is used by 4965 for keeping the - * host DRAM powered on (via dummy accesses to DRAM) to maintain low-latency - * DRAM access when 4965 is Txing or Rxing. The dummy accesses prevent host - * from going into a power-savings mode that would cause higher DRAM latency, - * and possible data over/under-runs, before all Tx/Rx is complete. - * - * Driver loads FH49_KW_MEM_ADDR_REG with the physical address (bits 35:4) - * of the buffer, which must be 4K aligned. Once this is set up, the 4965 - * automatically invokes keep-warm accesses when normal accesses might not - * be sufficient to maintain fast DRAM response. - * - * Bit fields: - * 31-0: Keep-warm buffer physical base address [35:4], must be 4K aligned - */ -#define FH49_KW_MEM_ADDR_REG (FH49_MEM_LOWER_BOUND + 0x97C) - - -/** - * TFD Circular Buffers Base (CBBC) addresses - * - * 4965 has 16 base pointer registers, one for each of 16 host-DRAM-resident - * circular buffers (CBs/queues) containing Transmit Frame Descriptors (TFDs) - * (see struct il_tfd_frame). These 16 pointer registers are offset by 0x04 - * bytes from one another. Each TFD circular buffer in DRAM must be 256-byte - * aligned (address bits 0-7 must be 0). - * - * Bit fields in each pointer register: - * 27-0: TFD CB physical base address [35:8], must be 256-byte aligned - */ -#define FH49_MEM_CBBC_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x9D0) -#define FH49_MEM_CBBC_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xA10) - -/* Find TFD CB base pointer for given queue (range 0-15). */ -#define FH49_MEM_CBBC_QUEUE(x) (FH49_MEM_CBBC_LOWER_BOUND + (x) * 0x4) - - -/** - * Rx SRAM Control and Status Registers (RSCSR) - * - * These registers provide handshake between driver and 4965 for the Rx queue - * (this queue handles *all* command responses, notifications, Rx data, etc. - * sent from 4965 uCode to host driver). Unlike Tx, there is only one Rx - * queue, and only one Rx DMA/FIFO channel. Also unlike Tx, which can - * concatenate up to 20 DRAM buffers to form a Tx frame, each Receive Buffer - * Descriptor (RBD) points to only one Rx Buffer (RB); there is a 1:1 - * mapping between RBDs and RBs. - * - * Driver must allocate host DRAM memory for the following, and set the - * physical address of each into 4965 registers: - * - * 1) Receive Buffer Descriptor (RBD) circular buffer (CB), typically with 256 - * entries (although any power of 2, up to 4096, is selectable by driver). - * Each entry (1 dword) points to a receive buffer (RB) of consistent size - * (typically 4K, although 8K or 16K are also selectable by driver). - * Driver sets up RB size and number of RBDs in the CB via Rx config - * register FH49_MEM_RCSR_CHNL0_CONFIG_REG. - * - * Bit fields within one RBD: - * 27-0: Receive Buffer physical address bits [35:8], 256-byte aligned - * - * Driver sets physical address [35:8] of base of RBD circular buffer - * into FH49_RSCSR_CHNL0_RBDCB_BASE_REG [27:0]. - * - * 2) Rx status buffer, 8 bytes, in which 4965 indicates which Rx Buffers - * (RBs) have been filled, via a "write pointer", actually the idx of - * the RB's corresponding RBD within the circular buffer. Driver sets - * physical address [35:4] into FH49_RSCSR_CHNL0_STTS_WPTR_REG [31:0]. - * - * Bit fields in lower dword of Rx status buffer (upper dword not used - * by driver; see struct il4965_shared, val0): - * 31-12: Not used by driver - * 11- 0: Index of last filled Rx buffer descriptor - * (4965 writes, driver reads this value) - * - * As the driver prepares Receive Buffers (RBs) for 4965 to fill, driver must - * enter pointers to these RBs into contiguous RBD circular buffer entries, - * and update the 4965's "write" idx register, - * FH49_RSCSR_CHNL0_RBDCB_WPTR_REG. - * - * This "write" idx corresponds to the *next* RBD that the driver will make - * available, i.e. one RBD past the tail of the ready-to-fill RBDs within - * the circular buffer. This value should initially be 0 (before preparing any - * RBs), should be 8 after preparing the first 8 RBs (for example), and must - * wrap back to 0 at the end of the circular buffer (but don't wrap before - * "read" idx has advanced past 1! See below). - * NOTE: 4965 EXPECTS THE WRITE IDX TO BE INCREMENTED IN MULTIPLES OF 8. - * - * As the 4965 fills RBs (referenced from contiguous RBDs within the circular - * buffer), it updates the Rx status buffer in host DRAM, 2) described above, - * to tell the driver the idx of the latest filled RBD. The driver must - * read this "read" idx from DRAM after receiving an Rx interrupt from 4965. - * - * The driver must also internally keep track of a third idx, which is the - * next RBD to process. When receiving an Rx interrupt, driver should process - * all filled but unprocessed RBs up to, but not including, the RB - * corresponding to the "read" idx. For example, if "read" idx becomes "1", - * driver may process the RB pointed to by RBD 0. Depending on volume of - * traffic, there may be many RBs to process. - * - * If read idx == write idx, 4965 thinks there is no room to put new data. - * Due to this, the maximum number of filled RBs is 255, instead of 256. To - * be safe, make sure that there is a gap of at least 2 RBDs between "write" - * and "read" idxes; that is, make sure that there are no more than 254 - * buffers waiting to be filled. - */ -#define FH49_MEM_RSCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xBC0) -#define FH49_MEM_RSCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xC00) -#define FH49_MEM_RSCSR_CHNL0 (FH49_MEM_RSCSR_LOWER_BOUND) - -/** - * Physical base address of 8-byte Rx Status buffer. - * Bit fields: - * 31-0: Rx status buffer physical base address [35:4], must 16-byte aligned. - */ -#define FH49_RSCSR_CHNL0_STTS_WPTR_REG (FH49_MEM_RSCSR_CHNL0) - -/** - * Physical base address of Rx Buffer Descriptor Circular Buffer. - * Bit fields: - * 27-0: RBD CD physical base address [35:8], must be 256-byte aligned. - */ -#define FH49_RSCSR_CHNL0_RBDCB_BASE_REG (FH49_MEM_RSCSR_CHNL0 + 0x004) - -/** - * Rx write pointer (idx, really!). - * Bit fields: - * 11-0: Index of driver's most recent prepared-to-be-filled RBD, + 1. - * NOTE: For 256-entry circular buffer, use only bits [7:0]. - */ -#define FH49_RSCSR_CHNL0_RBDCB_WPTR_REG (FH49_MEM_RSCSR_CHNL0 + 0x008) -#define FH49_RSCSR_CHNL0_WPTR (FH49_RSCSR_CHNL0_RBDCB_WPTR_REG) - - -/** - * Rx Config/Status Registers (RCSR) - * Rx Config Reg for channel 0 (only channel used) - * - * Driver must initialize FH49_MEM_RCSR_CHNL0_CONFIG_REG as follows for - * normal operation (see bit fields). - * - * Clearing FH49_MEM_RCSR_CHNL0_CONFIG_REG to 0 turns off Rx DMA. - * Driver should poll FH49_MEM_RSSR_RX_STATUS_REG for - * FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (bit 24) before continuing. - * - * Bit fields: - * 31-30: Rx DMA channel enable: '00' off/pause, '01' pause at end of frame, - * '10' operate normally - * 29-24: reserved - * 23-20: # RBDs in circular buffer = 2^value; use "8" for 256 RBDs (normal), - * min "5" for 32 RBDs, max "12" for 4096 RBDs. - * 19-18: reserved - * 17-16: size of each receive buffer; '00' 4K (normal), '01' 8K, - * '10' 12K, '11' 16K. - * 15-14: reserved - * 13-12: IRQ destination; '00' none, '01' host driver (normal operation) - * 11- 4: timeout for closing Rx buffer and interrupting host (units 32 usec) - * typical value 0x10 (about 1/2 msec) - * 3- 0: reserved - */ -#define FH49_MEM_RCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xC00) -#define FH49_MEM_RCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xCC0) -#define FH49_MEM_RCSR_CHNL0 (FH49_MEM_RCSR_LOWER_BOUND) - -#define FH49_MEM_RCSR_CHNL0_CONFIG_REG (FH49_MEM_RCSR_CHNL0) - -#define FH49_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MSK (0x00000FF0) /* bits 4-11 */ -#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MSK (0x00001000) /* bits 12 */ -#define FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK (0x00008000) /* bit 15 */ -#define FH49_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MSK (0x00030000) /* bits 16-17 */ -#define FH49_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MSK (0x00F00000) /* bits 20-23 */ -#define FH49_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MSK (0xC0000000) /* bits 30-31*/ - -#define FH49_RCSR_RX_CONFIG_RBDCB_SIZE_POS (20) -#define FH49_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS (4) -#define RX_RB_TIMEOUT (0x10) - -#define FH49_RCSR_RX_CONFIG_CHNL_EN_PAUSE_VAL (0x00000000) -#define FH49_RCSR_RX_CONFIG_CHNL_EN_PAUSE_EOF_VAL (0x40000000) -#define FH49_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL (0x80000000) - -#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K (0x00000000) -#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_8K (0x00010000) -#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_12K (0x00020000) -#define FH49_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_16K (0x00030000) - -#define FH49_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY (0x00000004) -#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_NO_INT_VAL (0x00000000) -#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL (0x00001000) - -/** - * Rx Shared Status Registers (RSSR) - * - * After stopping Rx DMA channel (writing 0 to - * FH49_MEM_RCSR_CHNL0_CONFIG_REG), driver must poll - * FH49_MEM_RSSR_RX_STATUS_REG until Rx channel is idle. - * - * Bit fields: - * 24: 1 = Channel 0 is idle - * - * FH49_MEM_RSSR_SHARED_CTRL_REG and FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV - * contain default values that should not be altered by the driver. - */ -#define FH49_MEM_RSSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xC40) -#define FH49_MEM_RSSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xD00) - -#define FH49_MEM_RSSR_SHARED_CTRL_REG (FH49_MEM_RSSR_LOWER_BOUND) -#define FH49_MEM_RSSR_RX_STATUS_REG (FH49_MEM_RSSR_LOWER_BOUND + 0x004) -#define FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV\ - (FH49_MEM_RSSR_LOWER_BOUND + 0x008) - -#define FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000) - -#define FH49_MEM_TFDIB_REG1_ADDR_BITSHIFT 28 - -/* TFDB Area - TFDs buffer table */ -#define FH49_MEM_TFDIB_DRAM_ADDR_LSB_MSK (0xFFFFFFFF) -#define FH49_TFDIB_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x900) -#define FH49_TFDIB_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0x958) -#define FH49_TFDIB_CTRL0_REG(_chnl) (FH49_TFDIB_LOWER_BOUND + 0x8 * (_chnl)) -#define FH49_TFDIB_CTRL1_REG(_chnl) (FH49_TFDIB_LOWER_BOUND + 0x8 * (_chnl) + 0x4) - -/** - * Transmit DMA Channel Control/Status Registers (TCSR) - * - * 4965 has one configuration register for each of 8 Tx DMA/FIFO channels - * supported in hardware (don't confuse these with the 16 Tx queues in DRAM, - * which feed the DMA/FIFO channels); config regs are separated by 0x20 bytes. - * - * To use a Tx DMA channel, driver must initialize its - * FH49_TCSR_CHNL_TX_CONFIG_REG(chnl) with: - * - * FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | - * FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL - * - * All other bits should be 0. - * - * Bit fields: - * 31-30: Tx DMA channel enable: '00' off/pause, '01' pause at end of frame, - * '10' operate normally - * 29- 4: Reserved, set to "0" - * 3: Enable internal DMA requests (1, normal operation), disable (0) - * 2- 0: Reserved, set to "0" - */ -#define FH49_TCSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xD00) -#define FH49_TCSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xE60) - -/* Find Control/Status reg for given Tx DMA/FIFO channel */ -#define FH49_TCSR_CHNL_NUM (7) -#define FH50_TCSR_CHNL_NUM (8) - -/* TCSR: tx_config register values */ -#define FH49_TCSR_CHNL_TX_CONFIG_REG(_chnl) \ - (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl)) -#define FH49_TCSR_CHNL_TX_CREDIT_REG(_chnl) \ - (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x4) -#define FH49_TCSR_CHNL_TX_BUF_STS_REG(_chnl) \ - (FH49_TCSR_LOWER_BOUND + 0x20 * (_chnl) + 0x8) - -#define FH49_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF (0x00000000) -#define FH49_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_DRV (0x00000001) - -#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE (0x00000000) -#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE (0x00000008) - -#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_NOINT (0x00000000) -#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD (0x00100000) -#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD (0x00200000) - -#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT (0x00000000) -#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_ENDTFD (0x00400000) -#define FH49_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_IFTFD (0x00800000) - -#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE (0x00000000) -#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE_EOF (0x40000000) -#define FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE (0x80000000) - -#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_EMPTY (0x00000000) -#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_WAIT (0x00002000) -#define FH49_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID (0x00000003) - -#define FH49_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM (20) -#define FH49_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX (12) - -/** - * Tx Shared Status Registers (TSSR) - * - * After stopping Tx DMA channel (writing 0 to - * FH49_TCSR_CHNL_TX_CONFIG_REG(chnl)), driver must poll - * FH49_TSSR_TX_STATUS_REG until selected Tx channel is idle - * (channel's buffers empty | no pending requests). - * - * Bit fields: - * 31-24: 1 = Channel buffers empty (channel 7:0) - * 23-16: 1 = No pending requests (channel 7:0) - */ -#define FH49_TSSR_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0xEA0) -#define FH49_TSSR_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0xEC0) - -#define FH49_TSSR_TX_STATUS_REG (FH49_TSSR_LOWER_BOUND + 0x010) - -/** - * Bit fields for TSSR(Tx Shared Status & Control) error status register: - * 31: Indicates an address error when accessed to internal memory - * uCode/driver must write "1" in order to clear this flag - * 30: Indicates that Host did not send the expected number of dwords to FH - * uCode/driver must write "1" in order to clear this flag - * 16-9:Each status bit is for one channel. Indicates that an (Error) ActDMA - * command was received from the scheduler while the TRB was already full - * with previous command - * uCode/driver must write "1" in order to clear this flag - * 7-0: Each status bit indicates a channel's TxCredit error. When an error - * bit is set, it indicates that the FH has received a full indication - * from the RTC TxFIFO and the current value of the TxCredit counter was - * not equal to zero. This mean that the credit mechanism was not - * synchronized to the TxFIFO status - * uCode/driver must write "1" in order to clear this flag - */ -#define FH49_TSSR_TX_ERROR_REG (FH49_TSSR_LOWER_BOUND + 0x018) - -#define FH49_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(_chnl) ((1 << (_chnl)) << 16) - -/* Tx service channels */ -#define FH49_SRVC_CHNL (9) -#define FH49_SRVC_LOWER_BOUND (FH49_MEM_LOWER_BOUND + 0x9C8) -#define FH49_SRVC_UPPER_BOUND (FH49_MEM_LOWER_BOUND + 0x9D0) -#define FH49_SRVC_CHNL_SRAM_ADDR_REG(_chnl) \ - (FH49_SRVC_LOWER_BOUND + ((_chnl) - 9) * 0x4) - -#define FH49_TX_CHICKEN_BITS_REG (FH49_MEM_LOWER_BOUND + 0xE98) -/* Instruct FH to increment the retry count of a packet when - * it is brought from the memory to TX-FIFO - */ -#define FH49_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN (0x00000002) - -/* Keep Warm Size */ -#define IL_KW_SIZE 0x1000 /* 4k */ - -#endif /* !__il_fh_h__ */ -- cgit v1.2.3 From f19ab370a7ba40570dcdb2c0c3cdaa8c20efde97 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 14:24:36 +0100 Subject: iwlegacy: rename iwl-debug.c to debug.c Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/Makefile | 2 +- drivers/net/wireless/iwlegacy/debug.c | 1309 +++++++++++++++++++++++++++ drivers/net/wireless/iwlegacy/iwl-debugfs.c | 1309 --------------------------- 3 files changed, 1310 insertions(+), 1310 deletions(-) create mode 100644 drivers/net/wireless/iwlegacy/debug.c delete mode 100644 drivers/net/wireless/iwlegacy/iwl-debugfs.c (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/Makefile b/drivers/net/wireless/iwlegacy/Makefile index 74218419f8ef..c985a01a0731 100644 --- a/drivers/net/wireless/iwlegacy/Makefile +++ b/drivers/net/wireless/iwlegacy/Makefile @@ -1,6 +1,6 @@ obj-$(CONFIG_IWLEGACY) += iwlegacy.o iwlegacy-objs := common.o -iwlegacy-$(CONFIG_IWLEGACY_DEBUGFS) += iwl-debugfs.o +iwlegacy-$(CONFIG_IWLEGACY_DEBUGFS) += debug.o iwlegacy-objs += $(iwlegacy-m) diff --git a/drivers/net/wireless/iwlegacy/debug.c b/drivers/net/wireless/iwlegacy/debug.c new file mode 100644 index 000000000000..62292a68567d --- /dev/null +++ b/drivers/net/wireless/iwlegacy/debug.c @@ -0,0 +1,1309 @@ +/****************************************************************************** + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, + * USA + * + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + *****************************************************************************/ +#include +#include + + +#include "iwl-debug.h" +#include "common.h" + +/* create and remove of files */ +#define DEBUGFS_ADD_FILE(name, parent, mode) do { \ + if (!debugfs_create_file(#name, mode, parent, il, \ + &il_dbgfs_##name##_ops)) \ + goto err; \ +} while (0) + +#define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \ + struct dentry *__tmp; \ + __tmp = debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \ + parent, ptr); \ + if (IS_ERR(__tmp) || !__tmp) \ + goto err; \ +} while (0) + +#define DEBUGFS_ADD_X32(name, parent, ptr) do { \ + struct dentry *__tmp; \ + __tmp = debugfs_create_x32(#name, S_IWUSR | S_IRUSR, \ + parent, ptr); \ + if (IS_ERR(__tmp) || !__tmp) \ + goto err; \ +} while (0) + +/* file operation */ +#define DEBUGFS_READ_FUNC(name) \ +static ssize_t il_dbgfs_##name##_read(struct file *file, \ + char __user *user_buf, \ + size_t count, loff_t *ppos); + +#define DEBUGFS_WRITE_FUNC(name) \ +static ssize_t il_dbgfs_##name##_write(struct file *file, \ + const char __user *user_buf, \ + size_t count, loff_t *ppos); + + +static int +il_dbgfs_open_file_generic(struct inode *inode, struct file *file) +{ + file->private_data = inode->i_private; + return 0; +} + +#define DEBUGFS_READ_FILE_OPS(name) \ + DEBUGFS_READ_FUNC(name); \ +static const struct file_operations il_dbgfs_##name##_ops = { \ + .read = il_dbgfs_##name##_read, \ + .open = il_dbgfs_open_file_generic, \ + .llseek = generic_file_llseek, \ +}; + +#define DEBUGFS_WRITE_FILE_OPS(name) \ + DEBUGFS_WRITE_FUNC(name); \ +static const struct file_operations il_dbgfs_##name##_ops = { \ + .write = il_dbgfs_##name##_write, \ + .open = il_dbgfs_open_file_generic, \ + .llseek = generic_file_llseek, \ +}; + +#define DEBUGFS_READ_WRITE_FILE_OPS(name) \ + DEBUGFS_READ_FUNC(name); \ + DEBUGFS_WRITE_FUNC(name); \ +static const struct file_operations il_dbgfs_##name##_ops = { \ + .write = il_dbgfs_##name##_write, \ + .read = il_dbgfs_##name##_read, \ + .open = il_dbgfs_open_file_generic, \ + .llseek = generic_file_llseek, \ +}; + +static ssize_t il_dbgfs_tx_stats_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + char *buf; + int pos = 0; + + int cnt; + ssize_t ret; + const size_t bufsz = 100 + + sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) + return -ENOMEM; + pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); + for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { + pos += scnprintf(buf + pos, bufsz - pos, + "\t%25s\t\t: %u\n", + il_get_mgmt_string(cnt), + il->tx_stats.mgmt[cnt]); + } + pos += scnprintf(buf + pos, bufsz - pos, "Control\n"); + for (cnt = 0; cnt < CONTROL_MAX; cnt++) { + pos += scnprintf(buf + pos, bufsz - pos, + "\t%25s\t\t: %u\n", + il_get_ctrl_string(cnt), + il->tx_stats.ctrl[cnt]); + } + pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); + pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", + il->tx_stats.data_cnt); + pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", + il->tx_stats.data_bytes); + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +static ssize_t +il_dbgfs_clear_traffic_stats_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + u32 clear_flag; + char buf[8]; + int buf_size; + + memset(buf, 0, sizeof(buf)); + buf_size = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + if (sscanf(buf, "%x", &clear_flag) != 1) + return -EFAULT; + il_clear_traffic_stats(il); + + return count; +} + +static ssize_t il_dbgfs_rx_stats_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + char *buf; + int pos = 0; + int cnt; + ssize_t ret; + const size_t bufsz = 100 + + sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); + for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { + pos += scnprintf(buf + pos, bufsz - pos, + "\t%25s\t\t: %u\n", + il_get_mgmt_string(cnt), + il->rx_stats.mgmt[cnt]); + } + pos += scnprintf(buf + pos, bufsz - pos, "Control:\n"); + for (cnt = 0; cnt < CONTROL_MAX; cnt++) { + pos += scnprintf(buf + pos, bufsz - pos, + "\t%25s\t\t: %u\n", + il_get_ctrl_string(cnt), + il->rx_stats.ctrl[cnt]); + } + pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); + pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", + il->rx_stats.data_cnt); + pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", + il->rx_stats.data_bytes); + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +#define BYTE1_MASK 0x000000ff; +#define BYTE2_MASK 0x0000ffff; +#define BYTE3_MASK 0x00ffffff; +static ssize_t il_dbgfs_sram_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + u32 val; + char *buf; + ssize_t ret; + int i; + int pos = 0; + struct il_priv *il = file->private_data; + size_t bufsz; + + /* default is to dump the entire data segment */ + if (!il->dbgfs_sram_offset && !il->dbgfs_sram_len) { + il->dbgfs_sram_offset = 0x800000; + if (il->ucode_type == UCODE_INIT) + il->dbgfs_sram_len = il->ucode_init_data.len; + else + il->dbgfs_sram_len = il->ucode_data.len; + } + bufsz = 30 + il->dbgfs_sram_len * sizeof(char) * 10; + buf = kmalloc(bufsz, GFP_KERNEL); + if (!buf) + return -ENOMEM; + pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n", + il->dbgfs_sram_len); + pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n", + il->dbgfs_sram_offset); + for (i = il->dbgfs_sram_len; i > 0; i -= 4) { + val = il_read_targ_mem(il, il->dbgfs_sram_offset + \ + il->dbgfs_sram_len - i); + if (i < 4) { + switch (i) { + case 1: + val &= BYTE1_MASK; + break; + case 2: + val &= BYTE2_MASK; + break; + case 3: + val &= BYTE3_MASK; + break; + } + } + if (!(i % 16)) + pos += scnprintf(buf + pos, bufsz - pos, "\n"); + pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val); + } + pos += scnprintf(buf + pos, bufsz - pos, "\n"); + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +static ssize_t il_dbgfs_sram_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + char buf[64]; + int buf_size; + u32 offset, len; + + memset(buf, 0, sizeof(buf)); + buf_size = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + + if (sscanf(buf, "%x,%x", &offset, &len) == 2) { + il->dbgfs_sram_offset = offset; + il->dbgfs_sram_len = len; + } else { + il->dbgfs_sram_offset = 0; + il->dbgfs_sram_len = 0; + } + + return count; +} + +static ssize_t +il_dbgfs_stations_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + struct il_station_entry *station; + int max_sta = il->hw_params.max_stations; + char *buf; + int i, j, pos = 0; + ssize_t ret; + /* Add 30 for initial string */ + const size_t bufsz = 30 + sizeof(char) * 500 * (il->num_stations); + + buf = kmalloc(bufsz, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n", + il->num_stations); + + for (i = 0; i < max_sta; i++) { + station = &il->stations[i]; + if (!station->used) + continue; + pos += scnprintf(buf + pos, bufsz - pos, + "station %d - addr: %pM, flags: %#x\n", + i, station->sta.sta.addr, + station->sta.station_flags_msk); + pos += scnprintf(buf + pos, bufsz - pos, + "TID\tseq_num\ttxq_id\tframes\ttfds\t"); + pos += scnprintf(buf + pos, bufsz - pos, + "start_idx\tbitmap\t\t\trate_n_flags\n"); + + for (j = 0; j < MAX_TID_COUNT; j++) { + pos += scnprintf(buf + pos, bufsz - pos, + "%d:\t%#x\t%#x\t%u\t%u\t%u\t\t%#.16llx\t%#x", + j, station->tid[j].seq_number, + station->tid[j].agg.txq_id, + station->tid[j].agg.frame_count, + station->tid[j].tfds_in_queue, + station->tid[j].agg.start_idx, + station->tid[j].agg.bitmap, + station->tid[j].agg.rate_n_flags); + + if (station->tid[j].agg.wait_for_ba) + pos += scnprintf(buf + pos, bufsz - pos, + " - waitforba"); + pos += scnprintf(buf + pos, bufsz - pos, "\n"); + } + + pos += scnprintf(buf + pos, bufsz - pos, "\n"); + } + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +static ssize_t il_dbgfs_nvm_read(struct file *file, + char __user *user_buf, + size_t count, + loff_t *ppos) +{ + ssize_t ret; + struct il_priv *il = file->private_data; + int pos = 0, ofs = 0, buf_size = 0; + const u8 *ptr; + char *buf; + u16 eeprom_ver; + size_t eeprom_len = il->cfg->base_params->eeprom_size; + buf_size = 4 * eeprom_len + 256; + + if (eeprom_len % 16) { + IL_ERR("NVM size is not multiple of 16.\n"); + return -ENODATA; + } + + ptr = il->eeprom; + if (!ptr) { + IL_ERR("Invalid EEPROM memory\n"); + return -ENOMEM; + } + + /* 4 characters for byte 0xYY */ + buf = kzalloc(buf_size, GFP_KERNEL); + if (!buf) { + IL_ERR("Can not allocate Buffer\n"); + return -ENOMEM; + } + eeprom_ver = il_eeprom_query16(il, EEPROM_VERSION); + pos += scnprintf(buf + pos, buf_size - pos, "EEPROM " + "version: 0x%x\n", eeprom_ver); + for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) { + pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs); + hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos, + buf_size - pos, 0); + pos += strlen(buf + pos); + if (buf_size - pos > 0) + buf[pos++] = '\n'; + } + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +static ssize_t +il_dbgfs_channels_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + struct ieee80211_channel *channels = NULL; + const struct ieee80211_supported_band *supp_band = NULL; + int pos = 0, i, bufsz = PAGE_SIZE; + char *buf; + ssize_t ret; + + if (!test_bit(S_GEO_CONFIGURED, &il->status)) + return -EAGAIN; + + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) { + IL_ERR("Can not allocate Buffer\n"); + return -ENOMEM; + } + + supp_band = il_get_hw_mode(il, IEEE80211_BAND_2GHZ); + if (supp_band) { + channels = supp_band->channels; + + pos += scnprintf(buf + pos, bufsz - pos, + "Displaying %d channels in 2.4GHz band 802.11bg):\n", + supp_band->n_channels); + + for (i = 0; i < supp_band->n_channels; i++) + pos += scnprintf(buf + pos, bufsz - pos, + "%d: %ddBm: BSS%s%s, %s.\n", + channels[i].hw_value, + channels[i].max_power, + channels[i].flags & IEEE80211_CHAN_RADAR ? + " (IEEE 802.11h required)" : "", + ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) + || (channels[i].flags & + IEEE80211_CHAN_RADAR)) ? "" : + ", IBSS", + channels[i].flags & + IEEE80211_CHAN_PASSIVE_SCAN ? + "passive only" : "active/passive"); + } + supp_band = il_get_hw_mode(il, IEEE80211_BAND_5GHZ); + if (supp_band) { + channels = supp_band->channels; + + pos += scnprintf(buf + pos, bufsz - pos, + "Displaying %d channels in 5.2GHz band (802.11a)\n", + supp_band->n_channels); + + for (i = 0; i < supp_band->n_channels; i++) + pos += scnprintf(buf + pos, bufsz - pos, + "%d: %ddBm: BSS%s%s, %s.\n", + channels[i].hw_value, + channels[i].max_power, + channels[i].flags & IEEE80211_CHAN_RADAR ? + " (IEEE 802.11h required)" : "", + ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) + || (channels[i].flags & + IEEE80211_CHAN_RADAR)) ? "" : + ", IBSS", + channels[i].flags & + IEEE80211_CHAN_PASSIVE_SCAN ? + "passive only" : "active/passive"); + } + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +static ssize_t il_dbgfs_status_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + char buf[512]; + int pos = 0; + const size_t bufsz = sizeof(buf); + + pos += scnprintf(buf + pos, bufsz - pos, "S_HCMD_ACTIVE:\t %d\n", + test_bit(S_HCMD_ACTIVE, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_INT_ENABLED:\t %d\n", + test_bit(S_INT_ENABLED, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_RF_KILL_HW:\t %d\n", + test_bit(S_RF_KILL_HW, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_CT_KILL:\t\t %d\n", + test_bit(S_CT_KILL, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_INIT:\t\t %d\n", + test_bit(S_INIT, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_ALIVE:\t\t %d\n", + test_bit(S_ALIVE, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_READY:\t\t %d\n", + test_bit(S_READY, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_TEMPERATURE:\t %d\n", + test_bit(S_TEMPERATURE, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_GEO_CONFIGURED:\t %d\n", + test_bit(S_GEO_CONFIGURED, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_EXIT_PENDING:\t %d\n", + test_bit(S_EXIT_PENDING, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_STATS:\t %d\n", + test_bit(S_STATS, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_SCANNING:\t %d\n", + test_bit(S_SCANNING, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_SCAN_ABORTING:\t %d\n", + test_bit(S_SCAN_ABORTING, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_SCAN_HW:\t\t %d\n", + test_bit(S_SCAN_HW, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_POWER_PMI:\t %d\n", + test_bit(S_POWER_PMI, &il->status)); + pos += scnprintf(buf + pos, bufsz - pos, "S_FW_ERROR:\t %d\n", + test_bit(S_FW_ERROR, &il->status)); + return simple_read_from_buffer(user_buf, count, ppos, buf, pos); +} + +static ssize_t il_dbgfs_interrupt_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + int pos = 0; + int cnt = 0; + char *buf; + int bufsz = 24 * 64; /* 24 items * 64 char per item */ + ssize_t ret; + + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) { + IL_ERR("Can not allocate Buffer\n"); + return -ENOMEM; + } + + pos += scnprintf(buf + pos, bufsz - pos, + "Interrupt Statistics Report:\n"); + + pos += scnprintf(buf + pos, bufsz - pos, "HW Error:\t\t\t %u\n", + il->isr_stats.hw); + pos += scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n", + il->isr_stats.sw); + if (il->isr_stats.sw || il->isr_stats.hw) { + pos += scnprintf(buf + pos, bufsz - pos, + "\tLast Restarting Code: 0x%X\n", + il->isr_stats.err_code); + } +#ifdef CONFIG_IWLEGACY_DEBUG + pos += scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n", + il->isr_stats.sch); + pos += scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n", + il->isr_stats.alive); +#endif + pos += scnprintf(buf + pos, bufsz - pos, + "HW RF KILL switch toggled:\t %u\n", + il->isr_stats.rfkill); + + pos += scnprintf(buf + pos, bufsz - pos, "CT KILL:\t\t\t %u\n", + il->isr_stats.ctkill); + + pos += scnprintf(buf + pos, bufsz - pos, "Wakeup Interrupt:\t\t %u\n", + il->isr_stats.wakeup); + + pos += scnprintf(buf + pos, bufsz - pos, + "Rx command responses:\t\t %u\n", + il->isr_stats.rx); + for (cnt = 0; cnt < IL_CN_MAX; cnt++) { + if (il->isr_stats.handlers[cnt] > 0) + pos += scnprintf(buf + pos, bufsz - pos, + "\tRx handler[%36s]:\t\t %u\n", + il_get_cmd_string(cnt), + il->isr_stats.handlers[cnt]); + } + + pos += scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n", + il->isr_stats.tx); + + pos += scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n", + il->isr_stats.unhandled); + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +static ssize_t il_dbgfs_interrupt_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + char buf[8]; + int buf_size; + u32 reset_flag; + + memset(buf, 0, sizeof(buf)); + buf_size = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + if (sscanf(buf, "%x", &reset_flag) != 1) + return -EFAULT; + if (reset_flag == 0) + il_clear_isr_stats(il); + + return count; +} + +static ssize_t +il_dbgfs_qos_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + struct il_rxon_context *ctx = &il->ctx; + int pos = 0, i; + char buf[256]; + const size_t bufsz = sizeof(buf); + + pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n", + ctx->ctxid); + for (i = 0; i < AC_NUM; i++) { + pos += scnprintf(buf + pos, bufsz - pos, + "\tcw_min\tcw_max\taifsn\ttxop\n"); + pos += scnprintf(buf + pos, bufsz - pos, + "AC[%d]\t%u\t%u\t%u\t%u\n", i, + ctx->qos_data.def_qos_parm.ac[i].cw_min, + ctx->qos_data.def_qos_parm.ac[i].cw_max, + ctx->qos_data.def_qos_parm.ac[i].aifsn, + ctx->qos_data.def_qos_parm.ac[i].edca_txop); + } + + return simple_read_from_buffer(user_buf, count, ppos, buf, pos); +} + +static ssize_t il_dbgfs_disable_ht40_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + char buf[8]; + int buf_size; + int ht40; + + memset(buf, 0, sizeof(buf)); + buf_size = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + if (sscanf(buf, "%d", &ht40) != 1) + return -EFAULT; + if (!il_is_any_associated(il)) + il->disable_ht40 = ht40 ? true : false; + else { + IL_ERR("Sta associated with AP - " + "Change to 40MHz channel support is not allowed\n"); + return -EINVAL; + } + + return count; +} + +static ssize_t il_dbgfs_disable_ht40_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + char buf[100]; + int pos = 0; + const size_t bufsz = sizeof(buf); + + pos += scnprintf(buf + pos, bufsz - pos, + "11n 40MHz Mode: %s\n", + il->disable_ht40 ? "Disabled" : "Enabled"); + return simple_read_from_buffer(user_buf, count, ppos, buf, pos); +} + +DEBUGFS_READ_WRITE_FILE_OPS(sram); +DEBUGFS_READ_FILE_OPS(nvm); +DEBUGFS_READ_FILE_OPS(stations); +DEBUGFS_READ_FILE_OPS(channels); +DEBUGFS_READ_FILE_OPS(status); +DEBUGFS_READ_WRITE_FILE_OPS(interrupt); +DEBUGFS_READ_FILE_OPS(qos); +DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40); + +static ssize_t il_dbgfs_traffic_log_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + int pos = 0, ofs = 0; + int cnt = 0, entry; + struct il_tx_queue *txq; + struct il_queue *q; + struct il_rx_queue *rxq = &il->rxq; + char *buf; + int bufsz = ((IL_TRAFFIC_ENTRIES * IL_TRAFFIC_ENTRY_SIZE * 64) * 2) + + (il->cfg->base_params->num_of_queues * 32 * 8) + 400; + const u8 *ptr; + ssize_t ret; + + if (!il->txq) { + IL_ERR("txq not ready\n"); + return -EAGAIN; + } + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) { + IL_ERR("Can not allocate buffer\n"); + return -ENOMEM; + } + pos += scnprintf(buf + pos, bufsz - pos, "Tx Queue\n"); + for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { + txq = &il->txq[cnt]; + q = &txq->q; + pos += scnprintf(buf + pos, bufsz - pos, + "q[%d]: read_ptr: %u, write_ptr: %u\n", + cnt, q->read_ptr, q->write_ptr); + } + if (il->tx_traffic && (il_debug_level & IL_DL_TX)) { + ptr = il->tx_traffic; + pos += scnprintf(buf + pos, bufsz - pos, + "Tx Traffic idx: %u\n", il->tx_traffic_idx); + for (cnt = 0, ofs = 0; cnt < IL_TRAFFIC_ENTRIES; cnt++) { + for (entry = 0; entry < IL_TRAFFIC_ENTRY_SIZE / 16; + entry++, ofs += 16) { + pos += scnprintf(buf + pos, bufsz - pos, + "0x%.4x ", ofs); + hex_dump_to_buffer(ptr + ofs, 16, 16, 2, + buf + pos, bufsz - pos, 0); + pos += strlen(buf + pos); + if (bufsz - pos > 0) + buf[pos++] = '\n'; + } + } + } + + pos += scnprintf(buf + pos, bufsz - pos, "Rx Queue\n"); + pos += scnprintf(buf + pos, bufsz - pos, + "read: %u, write: %u\n", + rxq->read, rxq->write); + + if (il->rx_traffic && (il_debug_level & IL_DL_RX)) { + ptr = il->rx_traffic; + pos += scnprintf(buf + pos, bufsz - pos, + "Rx Traffic idx: %u\n", il->rx_traffic_idx); + for (cnt = 0, ofs = 0; cnt < IL_TRAFFIC_ENTRIES; cnt++) { + for (entry = 0; entry < IL_TRAFFIC_ENTRY_SIZE / 16; + entry++, ofs += 16) { + pos += scnprintf(buf + pos, bufsz - pos, + "0x%.4x ", ofs); + hex_dump_to_buffer(ptr + ofs, 16, 16, 2, + buf + pos, bufsz - pos, 0); + pos += strlen(buf + pos); + if (bufsz - pos > 0) + buf[pos++] = '\n'; + } + } + } + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +static ssize_t il_dbgfs_traffic_log_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + char buf[8]; + int buf_size; + int traffic_log; + + memset(buf, 0, sizeof(buf)); + buf_size = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + if (sscanf(buf, "%d", &traffic_log) != 1) + return -EFAULT; + if (traffic_log == 0) + il_reset_traffic_log(il); + + return count; +} + +static ssize_t il_dbgfs_tx_queue_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + struct il_tx_queue *txq; + struct il_queue *q; + char *buf; + int pos = 0; + int cnt; + int ret; + const size_t bufsz = sizeof(char) * 64 * + il->cfg->base_params->num_of_queues; + + if (!il->txq) { + IL_ERR("txq not ready\n"); + return -EAGAIN; + } + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { + txq = &il->txq[cnt]; + q = &txq->q; + pos += scnprintf(buf + pos, bufsz - pos, + "hwq %.2d: read=%u write=%u stop=%d" + " swq_id=%#.2x (ac %d/hwq %d)\n", + cnt, q->read_ptr, q->write_ptr, + !!test_bit(cnt, il->queue_stopped), + txq->swq_id, txq->swq_id & 3, + (txq->swq_id >> 2) & 0x1f); + if (cnt >= 4) + continue; + /* for the ACs, display the stop count too */ + pos += scnprintf(buf + pos, bufsz - pos, + " stop-count: %d\n", + atomic_read(&il->queue_stop_count[cnt])); + } + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +static ssize_t il_dbgfs_rx_queue_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + struct il_rx_queue *rxq = &il->rxq; + char buf[256]; + int pos = 0; + const size_t bufsz = sizeof(buf); + + pos += scnprintf(buf + pos, bufsz - pos, "read: %u\n", + rxq->read); + pos += scnprintf(buf + pos, bufsz - pos, "write: %u\n", + rxq->write); + pos += scnprintf(buf + pos, bufsz - pos, "free_count: %u\n", + rxq->free_count); + if (rxq->rb_stts) { + pos += scnprintf(buf + pos, bufsz - pos, "closed_rb_num: %u\n", + le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF); + } else { + pos += scnprintf(buf + pos, bufsz - pos, + "closed_rb_num: Not Allocated\n"); + } + return simple_read_from_buffer(user_buf, count, ppos, buf, pos); +} + +static ssize_t il_dbgfs_ucode_rx_stats_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + return il->cfg->ops->lib->debugfs_ops.rx_stats_read(file, + user_buf, count, ppos); +} + +static ssize_t il_dbgfs_ucode_tx_stats_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + return il->cfg->ops->lib->debugfs_ops.tx_stats_read(file, + user_buf, count, ppos); +} + +static ssize_t il_dbgfs_ucode_general_stats_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + return il->cfg->ops->lib->debugfs_ops.general_stats_read(file, + user_buf, count, ppos); +} + +static ssize_t il_dbgfs_sensitivity_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + int pos = 0; + int cnt = 0; + char *buf; + int bufsz = sizeof(struct il_sensitivity_data) * 4 + 100; + ssize_t ret; + struct il_sensitivity_data *data; + + data = &il->sensitivity_data; + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) { + IL_ERR("Can not allocate Buffer\n"); + return -ENOMEM; + } + + pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n", + data->auto_corr_ofdm); + pos += scnprintf(buf + pos, bufsz - pos, + "auto_corr_ofdm_mrc:\t\t %u\n", + data->auto_corr_ofdm_mrc); + pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n", + data->auto_corr_ofdm_x1); + pos += scnprintf(buf + pos, bufsz - pos, + "auto_corr_ofdm_mrc_x1:\t\t %u\n", + data->auto_corr_ofdm_mrc_x1); + pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n", + data->auto_corr_cck); + pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n", + data->auto_corr_cck_mrc); + pos += scnprintf(buf + pos, bufsz - pos, + "last_bad_plcp_cnt_ofdm:\t\t %u\n", + data->last_bad_plcp_cnt_ofdm); + pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n", + data->last_fa_cnt_ofdm); + pos += scnprintf(buf + pos, bufsz - pos, + "last_bad_plcp_cnt_cck:\t\t %u\n", + data->last_bad_plcp_cnt_cck); + pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n", + data->last_fa_cnt_cck); + pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n", + data->nrg_curr_state); + pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n", + data->nrg_prev_state); + pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t"); + for (cnt = 0; cnt < 10; cnt++) { + pos += scnprintf(buf + pos, bufsz - pos, " %u", + data->nrg_value[cnt]); + } + pos += scnprintf(buf + pos, bufsz - pos, "\n"); + pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t"); + for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) { + pos += scnprintf(buf + pos, bufsz - pos, " %u", + data->nrg_silence_rssi[cnt]); + } + pos += scnprintf(buf + pos, bufsz - pos, "\n"); + pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n", + data->nrg_silence_ref); + pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n", + data->nrg_energy_idx); + pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n", + data->nrg_silence_idx); + pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n", + data->nrg_th_cck); + pos += scnprintf(buf + pos, bufsz - pos, + "nrg_auto_corr_silence_diff:\t %u\n", + data->nrg_auto_corr_silence_diff); + pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n", + data->num_in_cck_no_fa); + pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n", + data->nrg_th_ofdm); + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + + +static ssize_t il_dbgfs_chain_noise_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + int pos = 0; + int cnt = 0; + char *buf; + int bufsz = sizeof(struct il_chain_noise_data) * 4 + 100; + ssize_t ret; + struct il_chain_noise_data *data; + + data = &il->chain_noise_data; + buf = kzalloc(bufsz, GFP_KERNEL); + if (!buf) { + IL_ERR("Can not allocate Buffer\n"); + return -ENOMEM; + } + + pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n", + data->active_chains); + pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n", + data->chain_noise_a); + pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n", + data->chain_noise_b); + pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n", + data->chain_noise_c); + pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n", + data->chain_signal_a); + pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n", + data->chain_signal_b); + pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n", + data->chain_signal_c); + pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n", + data->beacon_count); + + pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t"); + for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { + pos += scnprintf(buf + pos, bufsz - pos, " %u", + data->disconn_array[cnt]); + } + pos += scnprintf(buf + pos, bufsz - pos, "\n"); + pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t"); + for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { + pos += scnprintf(buf + pos, bufsz - pos, " %u", + data->delta_gain_code[cnt]); + } + pos += scnprintf(buf + pos, bufsz - pos, "\n"); + pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n", + data->radio_write); + pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n", + data->state); + + ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); + kfree(buf); + return ret; +} + +static ssize_t il_dbgfs_power_save_status_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + char buf[60]; + int pos = 0; + const size_t bufsz = sizeof(buf); + u32 pwrsave_status; + + pwrsave_status = _il_rd(il, CSR_GP_CNTRL) & + CSR_GP_REG_POWER_SAVE_STATUS_MSK; + + pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: "); + pos += scnprintf(buf + pos, bufsz - pos, "%s\n", + (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" : + (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" : + (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" : + "error"); + + return simple_read_from_buffer(user_buf, count, ppos, buf, pos); +} + +static ssize_t il_dbgfs_clear_ucode_stats_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + char buf[8]; + int buf_size; + int clear; + + memset(buf, 0, sizeof(buf)); + buf_size = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + if (sscanf(buf, "%d", &clear) != 1) + return -EFAULT; + + /* make request to uCode to retrieve stats information */ + mutex_lock(&il->mutex); + il_send_stats_request(il, CMD_SYNC, true); + mutex_unlock(&il->mutex); + + return count; +} + +static ssize_t il_dbgfs_rxon_flags_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + int len = 0; + char buf[20]; + + len = sprintf(buf, "0x%04X\n", + le32_to_cpu(il->ctx.active.flags)); + return simple_read_from_buffer(user_buf, count, ppos, buf, len); +} + +static ssize_t il_dbgfs_rxon_filter_flags_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + int len = 0; + char buf[20]; + + len = sprintf(buf, "0x%04X\n", + le32_to_cpu(il->ctx.active.filter_flags)); + return simple_read_from_buffer(user_buf, count, ppos, buf, len); +} + +static ssize_t il_dbgfs_fh_reg_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + char *buf; + int pos = 0; + ssize_t ret = -EFAULT; + + if (il->cfg->ops->lib->dump_fh) { + ret = pos = il->cfg->ops->lib->dump_fh(il, &buf, true); + if (buf) { + ret = simple_read_from_buffer(user_buf, + count, ppos, buf, pos); + kfree(buf); + } + } + + return ret; +} + +static ssize_t il_dbgfs_missed_beacon_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + int pos = 0; + char buf[12]; + const size_t bufsz = sizeof(buf); + + pos += scnprintf(buf + pos, bufsz - pos, "%d\n", + il->missed_beacon_threshold); + + return simple_read_from_buffer(user_buf, count, ppos, buf, pos); +} + +static ssize_t il_dbgfs_missed_beacon_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct il_priv *il = file->private_data; + char buf[8]; + int buf_size; + int missed; + + memset(buf, 0, sizeof(buf)); + buf_size = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + if (sscanf(buf, "%d", &missed) != 1) + return -EINVAL; + + if (missed < IL_MISSED_BEACON_THRESHOLD_MIN || + missed > IL_MISSED_BEACON_THRESHOLD_MAX) + il->missed_beacon_threshold = + IL_MISSED_BEACON_THRESHOLD_DEF; + else + il->missed_beacon_threshold = missed; + + return count; +} + +static ssize_t il_dbgfs_force_reset_read(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + int pos = 0; + char buf[300]; + const size_t bufsz = sizeof(buf); + struct il_force_reset *force_reset; + + force_reset = &il->force_reset; + + pos += scnprintf(buf + pos, bufsz - pos, + "\tnumber of reset request: %d\n", + force_reset->reset_request_count); + pos += scnprintf(buf + pos, bufsz - pos, + "\tnumber of reset request success: %d\n", + force_reset->reset_success_count); + pos += scnprintf(buf + pos, bufsz - pos, + "\tnumber of reset request reject: %d\n", + force_reset->reset_reject_count); + pos += scnprintf(buf + pos, bufsz - pos, + "\treset duration: %lu\n", + force_reset->reset_duration); + + return simple_read_from_buffer(user_buf, count, ppos, buf, pos); +} + +static ssize_t il_dbgfs_force_reset_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) { + + int ret; + struct il_priv *il = file->private_data; + + ret = il_force_reset(il, true); + + return ret ? ret : count; +} + +static ssize_t il_dbgfs_wd_timeout_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) { + + struct il_priv *il = file->private_data; + char buf[8]; + int buf_size; + int timeout; + + memset(buf, 0, sizeof(buf)); + buf_size = min(count, sizeof(buf) - 1); + if (copy_from_user(buf, user_buf, buf_size)) + return -EFAULT; + if (sscanf(buf, "%d", &timeout) != 1) + return -EINVAL; + if (timeout < 0 || timeout > IL_MAX_WD_TIMEOUT) + timeout = IL_DEF_WD_TIMEOUT; + + il->cfg->base_params->wd_timeout = timeout; + il_setup_watchdog(il); + return count; +} + +DEBUGFS_READ_FILE_OPS(rx_stats); +DEBUGFS_READ_FILE_OPS(tx_stats); +DEBUGFS_READ_WRITE_FILE_OPS(traffic_log); +DEBUGFS_READ_FILE_OPS(rx_queue); +DEBUGFS_READ_FILE_OPS(tx_queue); +DEBUGFS_READ_FILE_OPS(ucode_rx_stats); +DEBUGFS_READ_FILE_OPS(ucode_tx_stats); +DEBUGFS_READ_FILE_OPS(ucode_general_stats); +DEBUGFS_READ_FILE_OPS(sensitivity); +DEBUGFS_READ_FILE_OPS(chain_noise); +DEBUGFS_READ_FILE_OPS(power_save_status); +DEBUGFS_WRITE_FILE_OPS(clear_ucode_stats); +DEBUGFS_WRITE_FILE_OPS(clear_traffic_stats); +DEBUGFS_READ_FILE_OPS(fh_reg); +DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon); +DEBUGFS_READ_WRITE_FILE_OPS(force_reset); +DEBUGFS_READ_FILE_OPS(rxon_flags); +DEBUGFS_READ_FILE_OPS(rxon_filter_flags); +DEBUGFS_WRITE_FILE_OPS(wd_timeout); + +/* + * Create the debugfs files and directories + * + */ +int il_dbgfs_register(struct il_priv *il, const char *name) +{ + struct dentry *phyd = il->hw->wiphy->debugfsdir; + struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug; + + dir_drv = debugfs_create_dir(name, phyd); + if (!dir_drv) + return -ENOMEM; + + il->debugfs_dir = dir_drv; + + dir_data = debugfs_create_dir("data", dir_drv); + if (!dir_data) + goto err; + dir_rf = debugfs_create_dir("rf", dir_drv); + if (!dir_rf) + goto err; + dir_debug = debugfs_create_dir("debug", dir_drv); + if (!dir_debug) + goto err; + + DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR); + DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR); + DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR); + DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR); + DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR); + DEBUGFS_ADD_FILE(interrupt, dir_data, S_IWUSR | S_IRUSR); + DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR); + DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR); + DEBUGFS_ADD_FILE(rx_stats, dir_debug, S_IRUSR); + DEBUGFS_ADD_FILE(tx_stats, dir_debug, S_IRUSR); + DEBUGFS_ADD_FILE(traffic_log, dir_debug, S_IWUSR | S_IRUSR); + DEBUGFS_ADD_FILE(rx_queue, dir_debug, S_IRUSR); + DEBUGFS_ADD_FILE(tx_queue, dir_debug, S_IRUSR); + DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR); + DEBUGFS_ADD_FILE(clear_ucode_stats, dir_debug, S_IWUSR); + DEBUGFS_ADD_FILE(clear_traffic_stats, dir_debug, S_IWUSR); + DEBUGFS_ADD_FILE(fh_reg, dir_debug, S_IRUSR); + DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR); + DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR); + DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR); + DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR); + DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR); + + if (il->cfg->base_params->sensitivity_calib_by_driver) + DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR); + if (il->cfg->base_params->chain_noise_calib_by_driver) + DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR); + DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR); + DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR); + DEBUGFS_ADD_FILE(wd_timeout, dir_debug, S_IWUSR); + if (il->cfg->base_params->sensitivity_calib_by_driver) + DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf, + &il->disable_sens_cal); + if (il->cfg->base_params->chain_noise_calib_by_driver) + DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf, + &il->disable_chain_noise_cal); + DEBUGFS_ADD_BOOL(disable_tx_power, dir_rf, + &il->disable_tx_power_cal); + return 0; + +err: + IL_ERR("Can't create the debugfs directory\n"); + il_dbgfs_unregister(il); + return -ENOMEM; +} +EXPORT_SYMBOL(il_dbgfs_register); + +/** + * Remove the debugfs files and directories + * + */ +void il_dbgfs_unregister(struct il_priv *il) +{ + if (!il->debugfs_dir) + return; + + debugfs_remove_recursive(il->debugfs_dir); + il->debugfs_dir = NULL; +} +EXPORT_SYMBOL(il_dbgfs_unregister); diff --git a/drivers/net/wireless/iwlegacy/iwl-debugfs.c b/drivers/net/wireless/iwlegacy/iwl-debugfs.c deleted file mode 100644 index 62292a68567d..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-debugfs.c +++ /dev/null @@ -1,1309 +0,0 @@ -/****************************************************************************** - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - *****************************************************************************/ -#include -#include - - -#include "iwl-debug.h" -#include "common.h" - -/* create and remove of files */ -#define DEBUGFS_ADD_FILE(name, parent, mode) do { \ - if (!debugfs_create_file(#name, mode, parent, il, \ - &il_dbgfs_##name##_ops)) \ - goto err; \ -} while (0) - -#define DEBUGFS_ADD_BOOL(name, parent, ptr) do { \ - struct dentry *__tmp; \ - __tmp = debugfs_create_bool(#name, S_IWUSR | S_IRUSR, \ - parent, ptr); \ - if (IS_ERR(__tmp) || !__tmp) \ - goto err; \ -} while (0) - -#define DEBUGFS_ADD_X32(name, parent, ptr) do { \ - struct dentry *__tmp; \ - __tmp = debugfs_create_x32(#name, S_IWUSR | S_IRUSR, \ - parent, ptr); \ - if (IS_ERR(__tmp) || !__tmp) \ - goto err; \ -} while (0) - -/* file operation */ -#define DEBUGFS_READ_FUNC(name) \ -static ssize_t il_dbgfs_##name##_read(struct file *file, \ - char __user *user_buf, \ - size_t count, loff_t *ppos); - -#define DEBUGFS_WRITE_FUNC(name) \ -static ssize_t il_dbgfs_##name##_write(struct file *file, \ - const char __user *user_buf, \ - size_t count, loff_t *ppos); - - -static int -il_dbgfs_open_file_generic(struct inode *inode, struct file *file) -{ - file->private_data = inode->i_private; - return 0; -} - -#define DEBUGFS_READ_FILE_OPS(name) \ - DEBUGFS_READ_FUNC(name); \ -static const struct file_operations il_dbgfs_##name##_ops = { \ - .read = il_dbgfs_##name##_read, \ - .open = il_dbgfs_open_file_generic, \ - .llseek = generic_file_llseek, \ -}; - -#define DEBUGFS_WRITE_FILE_OPS(name) \ - DEBUGFS_WRITE_FUNC(name); \ -static const struct file_operations il_dbgfs_##name##_ops = { \ - .write = il_dbgfs_##name##_write, \ - .open = il_dbgfs_open_file_generic, \ - .llseek = generic_file_llseek, \ -}; - -#define DEBUGFS_READ_WRITE_FILE_OPS(name) \ - DEBUGFS_READ_FUNC(name); \ - DEBUGFS_WRITE_FUNC(name); \ -static const struct file_operations il_dbgfs_##name##_ops = { \ - .write = il_dbgfs_##name##_write, \ - .read = il_dbgfs_##name##_read, \ - .open = il_dbgfs_open_file_generic, \ - .llseek = generic_file_llseek, \ -}; - -static ssize_t il_dbgfs_tx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - char *buf; - int pos = 0; - - int cnt; - ssize_t ret; - const size_t bufsz = 100 + - sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) - return -ENOMEM; - pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); - for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, - "\t%25s\t\t: %u\n", - il_get_mgmt_string(cnt), - il->tx_stats.mgmt[cnt]); - } - pos += scnprintf(buf + pos, bufsz - pos, "Control\n"); - for (cnt = 0; cnt < CONTROL_MAX; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, - "\t%25s\t\t: %u\n", - il_get_ctrl_string(cnt), - il->tx_stats.ctrl[cnt]); - } - pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); - pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", - il->tx_stats.data_cnt); - pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", - il->tx_stats.data_bytes); - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -static ssize_t -il_dbgfs_clear_traffic_stats_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - u32 clear_flag; - char buf[8]; - int buf_size; - - memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - if (sscanf(buf, "%x", &clear_flag) != 1) - return -EFAULT; - il_clear_traffic_stats(il); - - return count; -} - -static ssize_t il_dbgfs_rx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - char *buf; - int pos = 0; - int cnt; - ssize_t ret; - const size_t bufsz = 100 + - sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); - for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, - "\t%25s\t\t: %u\n", - il_get_mgmt_string(cnt), - il->rx_stats.mgmt[cnt]); - } - pos += scnprintf(buf + pos, bufsz - pos, "Control:\n"); - for (cnt = 0; cnt < CONTROL_MAX; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, - "\t%25s\t\t: %u\n", - il_get_ctrl_string(cnt), - il->rx_stats.ctrl[cnt]); - } - pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); - pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", - il->rx_stats.data_cnt); - pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", - il->rx_stats.data_bytes); - - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -#define BYTE1_MASK 0x000000ff; -#define BYTE2_MASK 0x0000ffff; -#define BYTE3_MASK 0x00ffffff; -static ssize_t il_dbgfs_sram_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - u32 val; - char *buf; - ssize_t ret; - int i; - int pos = 0; - struct il_priv *il = file->private_data; - size_t bufsz; - - /* default is to dump the entire data segment */ - if (!il->dbgfs_sram_offset && !il->dbgfs_sram_len) { - il->dbgfs_sram_offset = 0x800000; - if (il->ucode_type == UCODE_INIT) - il->dbgfs_sram_len = il->ucode_init_data.len; - else - il->dbgfs_sram_len = il->ucode_data.len; - } - bufsz = 30 + il->dbgfs_sram_len * sizeof(char) * 10; - buf = kmalloc(bufsz, GFP_KERNEL); - if (!buf) - return -ENOMEM; - pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n", - il->dbgfs_sram_len); - pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n", - il->dbgfs_sram_offset); - for (i = il->dbgfs_sram_len; i > 0; i -= 4) { - val = il_read_targ_mem(il, il->dbgfs_sram_offset + \ - il->dbgfs_sram_len - i); - if (i < 4) { - switch (i) { - case 1: - val &= BYTE1_MASK; - break; - case 2: - val &= BYTE2_MASK; - break; - case 3: - val &= BYTE3_MASK; - break; - } - } - if (!(i % 16)) - pos += scnprintf(buf + pos, bufsz - pos, "\n"); - pos += scnprintf(buf + pos, bufsz - pos, "0x%08x ", val); - } - pos += scnprintf(buf + pos, bufsz - pos, "\n"); - - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -static ssize_t il_dbgfs_sram_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - char buf[64]; - int buf_size; - u32 offset, len; - - memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - - if (sscanf(buf, "%x,%x", &offset, &len) == 2) { - il->dbgfs_sram_offset = offset; - il->dbgfs_sram_len = len; - } else { - il->dbgfs_sram_offset = 0; - il->dbgfs_sram_len = 0; - } - - return count; -} - -static ssize_t -il_dbgfs_stations_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - struct il_station_entry *station; - int max_sta = il->hw_params.max_stations; - char *buf; - int i, j, pos = 0; - ssize_t ret; - /* Add 30 for initial string */ - const size_t bufsz = 30 + sizeof(char) * 500 * (il->num_stations); - - buf = kmalloc(bufsz, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n", - il->num_stations); - - for (i = 0; i < max_sta; i++) { - station = &il->stations[i]; - if (!station->used) - continue; - pos += scnprintf(buf + pos, bufsz - pos, - "station %d - addr: %pM, flags: %#x\n", - i, station->sta.sta.addr, - station->sta.station_flags_msk); - pos += scnprintf(buf + pos, bufsz - pos, - "TID\tseq_num\ttxq_id\tframes\ttfds\t"); - pos += scnprintf(buf + pos, bufsz - pos, - "start_idx\tbitmap\t\t\trate_n_flags\n"); - - for (j = 0; j < MAX_TID_COUNT; j++) { - pos += scnprintf(buf + pos, bufsz - pos, - "%d:\t%#x\t%#x\t%u\t%u\t%u\t\t%#.16llx\t%#x", - j, station->tid[j].seq_number, - station->tid[j].agg.txq_id, - station->tid[j].agg.frame_count, - station->tid[j].tfds_in_queue, - station->tid[j].agg.start_idx, - station->tid[j].agg.bitmap, - station->tid[j].agg.rate_n_flags); - - if (station->tid[j].agg.wait_for_ba) - pos += scnprintf(buf + pos, bufsz - pos, - " - waitforba"); - pos += scnprintf(buf + pos, bufsz - pos, "\n"); - } - - pos += scnprintf(buf + pos, bufsz - pos, "\n"); - } - - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -static ssize_t il_dbgfs_nvm_read(struct file *file, - char __user *user_buf, - size_t count, - loff_t *ppos) -{ - ssize_t ret; - struct il_priv *il = file->private_data; - int pos = 0, ofs = 0, buf_size = 0; - const u8 *ptr; - char *buf; - u16 eeprom_ver; - size_t eeprom_len = il->cfg->base_params->eeprom_size; - buf_size = 4 * eeprom_len + 256; - - if (eeprom_len % 16) { - IL_ERR("NVM size is not multiple of 16.\n"); - return -ENODATA; - } - - ptr = il->eeprom; - if (!ptr) { - IL_ERR("Invalid EEPROM memory\n"); - return -ENOMEM; - } - - /* 4 characters for byte 0xYY */ - buf = kzalloc(buf_size, GFP_KERNEL); - if (!buf) { - IL_ERR("Can not allocate Buffer\n"); - return -ENOMEM; - } - eeprom_ver = il_eeprom_query16(il, EEPROM_VERSION); - pos += scnprintf(buf + pos, buf_size - pos, "EEPROM " - "version: 0x%x\n", eeprom_ver); - for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) { - pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs); - hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos, - buf_size - pos, 0); - pos += strlen(buf + pos); - if (buf_size - pos > 0) - buf[pos++] = '\n'; - } - - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -static ssize_t -il_dbgfs_channels_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - struct ieee80211_channel *channels = NULL; - const struct ieee80211_supported_band *supp_band = NULL; - int pos = 0, i, bufsz = PAGE_SIZE; - char *buf; - ssize_t ret; - - if (!test_bit(S_GEO_CONFIGURED, &il->status)) - return -EAGAIN; - - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) { - IL_ERR("Can not allocate Buffer\n"); - return -ENOMEM; - } - - supp_band = il_get_hw_mode(il, IEEE80211_BAND_2GHZ); - if (supp_band) { - channels = supp_band->channels; - - pos += scnprintf(buf + pos, bufsz - pos, - "Displaying %d channels in 2.4GHz band 802.11bg):\n", - supp_band->n_channels); - - for (i = 0; i < supp_band->n_channels; i++) - pos += scnprintf(buf + pos, bufsz - pos, - "%d: %ddBm: BSS%s%s, %s.\n", - channels[i].hw_value, - channels[i].max_power, - channels[i].flags & IEEE80211_CHAN_RADAR ? - " (IEEE 802.11h required)" : "", - ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) - || (channels[i].flags & - IEEE80211_CHAN_RADAR)) ? "" : - ", IBSS", - channels[i].flags & - IEEE80211_CHAN_PASSIVE_SCAN ? - "passive only" : "active/passive"); - } - supp_band = il_get_hw_mode(il, IEEE80211_BAND_5GHZ); - if (supp_band) { - channels = supp_band->channels; - - pos += scnprintf(buf + pos, bufsz - pos, - "Displaying %d channels in 5.2GHz band (802.11a)\n", - supp_band->n_channels); - - for (i = 0; i < supp_band->n_channels; i++) - pos += scnprintf(buf + pos, bufsz - pos, - "%d: %ddBm: BSS%s%s, %s.\n", - channels[i].hw_value, - channels[i].max_power, - channels[i].flags & IEEE80211_CHAN_RADAR ? - " (IEEE 802.11h required)" : "", - ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) - || (channels[i].flags & - IEEE80211_CHAN_RADAR)) ? "" : - ", IBSS", - channels[i].flags & - IEEE80211_CHAN_PASSIVE_SCAN ? - "passive only" : "active/passive"); - } - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -static ssize_t il_dbgfs_status_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - char buf[512]; - int pos = 0; - const size_t bufsz = sizeof(buf); - - pos += scnprintf(buf + pos, bufsz - pos, "S_HCMD_ACTIVE:\t %d\n", - test_bit(S_HCMD_ACTIVE, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_INT_ENABLED:\t %d\n", - test_bit(S_INT_ENABLED, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_RF_KILL_HW:\t %d\n", - test_bit(S_RF_KILL_HW, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_CT_KILL:\t\t %d\n", - test_bit(S_CT_KILL, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_INIT:\t\t %d\n", - test_bit(S_INIT, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_ALIVE:\t\t %d\n", - test_bit(S_ALIVE, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_READY:\t\t %d\n", - test_bit(S_READY, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_TEMPERATURE:\t %d\n", - test_bit(S_TEMPERATURE, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_GEO_CONFIGURED:\t %d\n", - test_bit(S_GEO_CONFIGURED, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_EXIT_PENDING:\t %d\n", - test_bit(S_EXIT_PENDING, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_STATS:\t %d\n", - test_bit(S_STATS, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_SCANNING:\t %d\n", - test_bit(S_SCANNING, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_SCAN_ABORTING:\t %d\n", - test_bit(S_SCAN_ABORTING, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_SCAN_HW:\t\t %d\n", - test_bit(S_SCAN_HW, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_POWER_PMI:\t %d\n", - test_bit(S_POWER_PMI, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_FW_ERROR:\t %d\n", - test_bit(S_FW_ERROR, &il->status)); - return simple_read_from_buffer(user_buf, count, ppos, buf, pos); -} - -static ssize_t il_dbgfs_interrupt_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - int pos = 0; - int cnt = 0; - char *buf; - int bufsz = 24 * 64; /* 24 items * 64 char per item */ - ssize_t ret; - - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) { - IL_ERR("Can not allocate Buffer\n"); - return -ENOMEM; - } - - pos += scnprintf(buf + pos, bufsz - pos, - "Interrupt Statistics Report:\n"); - - pos += scnprintf(buf + pos, bufsz - pos, "HW Error:\t\t\t %u\n", - il->isr_stats.hw); - pos += scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n", - il->isr_stats.sw); - if (il->isr_stats.sw || il->isr_stats.hw) { - pos += scnprintf(buf + pos, bufsz - pos, - "\tLast Restarting Code: 0x%X\n", - il->isr_stats.err_code); - } -#ifdef CONFIG_IWLEGACY_DEBUG - pos += scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n", - il->isr_stats.sch); - pos += scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n", - il->isr_stats.alive); -#endif - pos += scnprintf(buf + pos, bufsz - pos, - "HW RF KILL switch toggled:\t %u\n", - il->isr_stats.rfkill); - - pos += scnprintf(buf + pos, bufsz - pos, "CT KILL:\t\t\t %u\n", - il->isr_stats.ctkill); - - pos += scnprintf(buf + pos, bufsz - pos, "Wakeup Interrupt:\t\t %u\n", - il->isr_stats.wakeup); - - pos += scnprintf(buf + pos, bufsz - pos, - "Rx command responses:\t\t %u\n", - il->isr_stats.rx); - for (cnt = 0; cnt < IL_CN_MAX; cnt++) { - if (il->isr_stats.handlers[cnt] > 0) - pos += scnprintf(buf + pos, bufsz - pos, - "\tRx handler[%36s]:\t\t %u\n", - il_get_cmd_string(cnt), - il->isr_stats.handlers[cnt]); - } - - pos += scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n", - il->isr_stats.tx); - - pos += scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n", - il->isr_stats.unhandled); - - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -static ssize_t il_dbgfs_interrupt_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - char buf[8]; - int buf_size; - u32 reset_flag; - - memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - if (sscanf(buf, "%x", &reset_flag) != 1) - return -EFAULT; - if (reset_flag == 0) - il_clear_isr_stats(il); - - return count; -} - -static ssize_t -il_dbgfs_qos_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - struct il_rxon_context *ctx = &il->ctx; - int pos = 0, i; - char buf[256]; - const size_t bufsz = sizeof(buf); - - pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n", - ctx->ctxid); - for (i = 0; i < AC_NUM; i++) { - pos += scnprintf(buf + pos, bufsz - pos, - "\tcw_min\tcw_max\taifsn\ttxop\n"); - pos += scnprintf(buf + pos, bufsz - pos, - "AC[%d]\t%u\t%u\t%u\t%u\n", i, - ctx->qos_data.def_qos_parm.ac[i].cw_min, - ctx->qos_data.def_qos_parm.ac[i].cw_max, - ctx->qos_data.def_qos_parm.ac[i].aifsn, - ctx->qos_data.def_qos_parm.ac[i].edca_txop); - } - - return simple_read_from_buffer(user_buf, count, ppos, buf, pos); -} - -static ssize_t il_dbgfs_disable_ht40_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - char buf[8]; - int buf_size; - int ht40; - - memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - if (sscanf(buf, "%d", &ht40) != 1) - return -EFAULT; - if (!il_is_any_associated(il)) - il->disable_ht40 = ht40 ? true : false; - else { - IL_ERR("Sta associated with AP - " - "Change to 40MHz channel support is not allowed\n"); - return -EINVAL; - } - - return count; -} - -static ssize_t il_dbgfs_disable_ht40_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - char buf[100]; - int pos = 0; - const size_t bufsz = sizeof(buf); - - pos += scnprintf(buf + pos, bufsz - pos, - "11n 40MHz Mode: %s\n", - il->disable_ht40 ? "Disabled" : "Enabled"); - return simple_read_from_buffer(user_buf, count, ppos, buf, pos); -} - -DEBUGFS_READ_WRITE_FILE_OPS(sram); -DEBUGFS_READ_FILE_OPS(nvm); -DEBUGFS_READ_FILE_OPS(stations); -DEBUGFS_READ_FILE_OPS(channels); -DEBUGFS_READ_FILE_OPS(status); -DEBUGFS_READ_WRITE_FILE_OPS(interrupt); -DEBUGFS_READ_FILE_OPS(qos); -DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40); - -static ssize_t il_dbgfs_traffic_log_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - int pos = 0, ofs = 0; - int cnt = 0, entry; - struct il_tx_queue *txq; - struct il_queue *q; - struct il_rx_queue *rxq = &il->rxq; - char *buf; - int bufsz = ((IL_TRAFFIC_ENTRIES * IL_TRAFFIC_ENTRY_SIZE * 64) * 2) + - (il->cfg->base_params->num_of_queues * 32 * 8) + 400; - const u8 *ptr; - ssize_t ret; - - if (!il->txq) { - IL_ERR("txq not ready\n"); - return -EAGAIN; - } - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) { - IL_ERR("Can not allocate buffer\n"); - return -ENOMEM; - } - pos += scnprintf(buf + pos, bufsz - pos, "Tx Queue\n"); - for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { - txq = &il->txq[cnt]; - q = &txq->q; - pos += scnprintf(buf + pos, bufsz - pos, - "q[%d]: read_ptr: %u, write_ptr: %u\n", - cnt, q->read_ptr, q->write_ptr); - } - if (il->tx_traffic && (il_debug_level & IL_DL_TX)) { - ptr = il->tx_traffic; - pos += scnprintf(buf + pos, bufsz - pos, - "Tx Traffic idx: %u\n", il->tx_traffic_idx); - for (cnt = 0, ofs = 0; cnt < IL_TRAFFIC_ENTRIES; cnt++) { - for (entry = 0; entry < IL_TRAFFIC_ENTRY_SIZE / 16; - entry++, ofs += 16) { - pos += scnprintf(buf + pos, bufsz - pos, - "0x%.4x ", ofs); - hex_dump_to_buffer(ptr + ofs, 16, 16, 2, - buf + pos, bufsz - pos, 0); - pos += strlen(buf + pos); - if (bufsz - pos > 0) - buf[pos++] = '\n'; - } - } - } - - pos += scnprintf(buf + pos, bufsz - pos, "Rx Queue\n"); - pos += scnprintf(buf + pos, bufsz - pos, - "read: %u, write: %u\n", - rxq->read, rxq->write); - - if (il->rx_traffic && (il_debug_level & IL_DL_RX)) { - ptr = il->rx_traffic; - pos += scnprintf(buf + pos, bufsz - pos, - "Rx Traffic idx: %u\n", il->rx_traffic_idx); - for (cnt = 0, ofs = 0; cnt < IL_TRAFFIC_ENTRIES; cnt++) { - for (entry = 0; entry < IL_TRAFFIC_ENTRY_SIZE / 16; - entry++, ofs += 16) { - pos += scnprintf(buf + pos, bufsz - pos, - "0x%.4x ", ofs); - hex_dump_to_buffer(ptr + ofs, 16, 16, 2, - buf + pos, bufsz - pos, 0); - pos += strlen(buf + pos); - if (bufsz - pos > 0) - buf[pos++] = '\n'; - } - } - } - - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -static ssize_t il_dbgfs_traffic_log_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - char buf[8]; - int buf_size; - int traffic_log; - - memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - if (sscanf(buf, "%d", &traffic_log) != 1) - return -EFAULT; - if (traffic_log == 0) - il_reset_traffic_log(il); - - return count; -} - -static ssize_t il_dbgfs_tx_queue_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - struct il_tx_queue *txq; - struct il_queue *q; - char *buf; - int pos = 0; - int cnt; - int ret; - const size_t bufsz = sizeof(char) * 64 * - il->cfg->base_params->num_of_queues; - - if (!il->txq) { - IL_ERR("txq not ready\n"); - return -EAGAIN; - } - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { - txq = &il->txq[cnt]; - q = &txq->q; - pos += scnprintf(buf + pos, bufsz - pos, - "hwq %.2d: read=%u write=%u stop=%d" - " swq_id=%#.2x (ac %d/hwq %d)\n", - cnt, q->read_ptr, q->write_ptr, - !!test_bit(cnt, il->queue_stopped), - txq->swq_id, txq->swq_id & 3, - (txq->swq_id >> 2) & 0x1f); - if (cnt >= 4) - continue; - /* for the ACs, display the stop count too */ - pos += scnprintf(buf + pos, bufsz - pos, - " stop-count: %d\n", - atomic_read(&il->queue_stop_count[cnt])); - } - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -static ssize_t il_dbgfs_rx_queue_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - struct il_rx_queue *rxq = &il->rxq; - char buf[256]; - int pos = 0; - const size_t bufsz = sizeof(buf); - - pos += scnprintf(buf + pos, bufsz - pos, "read: %u\n", - rxq->read); - pos += scnprintf(buf + pos, bufsz - pos, "write: %u\n", - rxq->write); - pos += scnprintf(buf + pos, bufsz - pos, "free_count: %u\n", - rxq->free_count); - if (rxq->rb_stts) { - pos += scnprintf(buf + pos, bufsz - pos, "closed_rb_num: %u\n", - le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF); - } else { - pos += scnprintf(buf + pos, bufsz - pos, - "closed_rb_num: Not Allocated\n"); - } - return simple_read_from_buffer(user_buf, count, ppos, buf, pos); -} - -static ssize_t il_dbgfs_ucode_rx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - return il->cfg->ops->lib->debugfs_ops.rx_stats_read(file, - user_buf, count, ppos); -} - -static ssize_t il_dbgfs_ucode_tx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - return il->cfg->ops->lib->debugfs_ops.tx_stats_read(file, - user_buf, count, ppos); -} - -static ssize_t il_dbgfs_ucode_general_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - return il->cfg->ops->lib->debugfs_ops.general_stats_read(file, - user_buf, count, ppos); -} - -static ssize_t il_dbgfs_sensitivity_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - int pos = 0; - int cnt = 0; - char *buf; - int bufsz = sizeof(struct il_sensitivity_data) * 4 + 100; - ssize_t ret; - struct il_sensitivity_data *data; - - data = &il->sensitivity_data; - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) { - IL_ERR("Can not allocate Buffer\n"); - return -ENOMEM; - } - - pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n", - data->auto_corr_ofdm); - pos += scnprintf(buf + pos, bufsz - pos, - "auto_corr_ofdm_mrc:\t\t %u\n", - data->auto_corr_ofdm_mrc); - pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n", - data->auto_corr_ofdm_x1); - pos += scnprintf(buf + pos, bufsz - pos, - "auto_corr_ofdm_mrc_x1:\t\t %u\n", - data->auto_corr_ofdm_mrc_x1); - pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n", - data->auto_corr_cck); - pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n", - data->auto_corr_cck_mrc); - pos += scnprintf(buf + pos, bufsz - pos, - "last_bad_plcp_cnt_ofdm:\t\t %u\n", - data->last_bad_plcp_cnt_ofdm); - pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n", - data->last_fa_cnt_ofdm); - pos += scnprintf(buf + pos, bufsz - pos, - "last_bad_plcp_cnt_cck:\t\t %u\n", - data->last_bad_plcp_cnt_cck); - pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n", - data->last_fa_cnt_cck); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n", - data->nrg_curr_state); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n", - data->nrg_prev_state); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t"); - for (cnt = 0; cnt < 10; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, " %u", - data->nrg_value[cnt]); - } - pos += scnprintf(buf + pos, bufsz - pos, "\n"); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t"); - for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, " %u", - data->nrg_silence_rssi[cnt]); - } - pos += scnprintf(buf + pos, bufsz - pos, "\n"); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n", - data->nrg_silence_ref); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n", - data->nrg_energy_idx); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n", - data->nrg_silence_idx); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n", - data->nrg_th_cck); - pos += scnprintf(buf + pos, bufsz - pos, - "nrg_auto_corr_silence_diff:\t %u\n", - data->nrg_auto_corr_silence_diff); - pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n", - data->num_in_cck_no_fa); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n", - data->nrg_th_ofdm); - - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - - -static ssize_t il_dbgfs_chain_noise_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - int pos = 0; - int cnt = 0; - char *buf; - int bufsz = sizeof(struct il_chain_noise_data) * 4 + 100; - ssize_t ret; - struct il_chain_noise_data *data; - - data = &il->chain_noise_data; - buf = kzalloc(bufsz, GFP_KERNEL); - if (!buf) { - IL_ERR("Can not allocate Buffer\n"); - return -ENOMEM; - } - - pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n", - data->active_chains); - pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n", - data->chain_noise_a); - pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n", - data->chain_noise_b); - pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n", - data->chain_noise_c); - pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n", - data->chain_signal_a); - pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n", - data->chain_signal_b); - pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n", - data->chain_signal_c); - pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n", - data->beacon_count); - - pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t"); - for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, " %u", - data->disconn_array[cnt]); - } - pos += scnprintf(buf + pos, bufsz - pos, "\n"); - pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t"); - for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, " %u", - data->delta_gain_code[cnt]); - } - pos += scnprintf(buf + pos, bufsz - pos, "\n"); - pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n", - data->radio_write); - pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n", - data->state); - - ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); - kfree(buf); - return ret; -} - -static ssize_t il_dbgfs_power_save_status_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - char buf[60]; - int pos = 0; - const size_t bufsz = sizeof(buf); - u32 pwrsave_status; - - pwrsave_status = _il_rd(il, CSR_GP_CNTRL) & - CSR_GP_REG_POWER_SAVE_STATUS_MSK; - - pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: "); - pos += scnprintf(buf + pos, bufsz - pos, "%s\n", - (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" : - (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" : - (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" : - "error"); - - return simple_read_from_buffer(user_buf, count, ppos, buf, pos); -} - -static ssize_t il_dbgfs_clear_ucode_stats_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - char buf[8]; - int buf_size; - int clear; - - memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - if (sscanf(buf, "%d", &clear) != 1) - return -EFAULT; - - /* make request to uCode to retrieve stats information */ - mutex_lock(&il->mutex); - il_send_stats_request(il, CMD_SYNC, true); - mutex_unlock(&il->mutex); - - return count; -} - -static ssize_t il_dbgfs_rxon_flags_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - int len = 0; - char buf[20]; - - len = sprintf(buf, "0x%04X\n", - le32_to_cpu(il->ctx.active.flags)); - return simple_read_from_buffer(user_buf, count, ppos, buf, len); -} - -static ssize_t il_dbgfs_rxon_filter_flags_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - int len = 0; - char buf[20]; - - len = sprintf(buf, "0x%04X\n", - le32_to_cpu(il->ctx.active.filter_flags)); - return simple_read_from_buffer(user_buf, count, ppos, buf, len); -} - -static ssize_t il_dbgfs_fh_reg_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - char *buf; - int pos = 0; - ssize_t ret = -EFAULT; - - if (il->cfg->ops->lib->dump_fh) { - ret = pos = il->cfg->ops->lib->dump_fh(il, &buf, true); - if (buf) { - ret = simple_read_from_buffer(user_buf, - count, ppos, buf, pos); - kfree(buf); - } - } - - return ret; -} - -static ssize_t il_dbgfs_missed_beacon_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - int pos = 0; - char buf[12]; - const size_t bufsz = sizeof(buf); - - pos += scnprintf(buf + pos, bufsz - pos, "%d\n", - il->missed_beacon_threshold); - - return simple_read_from_buffer(user_buf, count, ppos, buf, pos); -} - -static ssize_t il_dbgfs_missed_beacon_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) -{ - struct il_priv *il = file->private_data; - char buf[8]; - int buf_size; - int missed; - - memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - if (sscanf(buf, "%d", &missed) != 1) - return -EINVAL; - - if (missed < IL_MISSED_BEACON_THRESHOLD_MIN || - missed > IL_MISSED_BEACON_THRESHOLD_MAX) - il->missed_beacon_threshold = - IL_MISSED_BEACON_THRESHOLD_DEF; - else - il->missed_beacon_threshold = missed; - - return count; -} - -static ssize_t il_dbgfs_force_reset_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - int pos = 0; - char buf[300]; - const size_t bufsz = sizeof(buf); - struct il_force_reset *force_reset; - - force_reset = &il->force_reset; - - pos += scnprintf(buf + pos, bufsz - pos, - "\tnumber of reset request: %d\n", - force_reset->reset_request_count); - pos += scnprintf(buf + pos, bufsz - pos, - "\tnumber of reset request success: %d\n", - force_reset->reset_success_count); - pos += scnprintf(buf + pos, bufsz - pos, - "\tnumber of reset request reject: %d\n", - force_reset->reset_reject_count); - pos += scnprintf(buf + pos, bufsz - pos, - "\treset duration: %lu\n", - force_reset->reset_duration); - - return simple_read_from_buffer(user_buf, count, ppos, buf, pos); -} - -static ssize_t il_dbgfs_force_reset_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) { - - int ret; - struct il_priv *il = file->private_data; - - ret = il_force_reset(il, true); - - return ret ? ret : count; -} - -static ssize_t il_dbgfs_wd_timeout_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) { - - struct il_priv *il = file->private_data; - char buf[8]; - int buf_size; - int timeout; - - memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); - if (copy_from_user(buf, user_buf, buf_size)) - return -EFAULT; - if (sscanf(buf, "%d", &timeout) != 1) - return -EINVAL; - if (timeout < 0 || timeout > IL_MAX_WD_TIMEOUT) - timeout = IL_DEF_WD_TIMEOUT; - - il->cfg->base_params->wd_timeout = timeout; - il_setup_watchdog(il); - return count; -} - -DEBUGFS_READ_FILE_OPS(rx_stats); -DEBUGFS_READ_FILE_OPS(tx_stats); -DEBUGFS_READ_WRITE_FILE_OPS(traffic_log); -DEBUGFS_READ_FILE_OPS(rx_queue); -DEBUGFS_READ_FILE_OPS(tx_queue); -DEBUGFS_READ_FILE_OPS(ucode_rx_stats); -DEBUGFS_READ_FILE_OPS(ucode_tx_stats); -DEBUGFS_READ_FILE_OPS(ucode_general_stats); -DEBUGFS_READ_FILE_OPS(sensitivity); -DEBUGFS_READ_FILE_OPS(chain_noise); -DEBUGFS_READ_FILE_OPS(power_save_status); -DEBUGFS_WRITE_FILE_OPS(clear_ucode_stats); -DEBUGFS_WRITE_FILE_OPS(clear_traffic_stats); -DEBUGFS_READ_FILE_OPS(fh_reg); -DEBUGFS_READ_WRITE_FILE_OPS(missed_beacon); -DEBUGFS_READ_WRITE_FILE_OPS(force_reset); -DEBUGFS_READ_FILE_OPS(rxon_flags); -DEBUGFS_READ_FILE_OPS(rxon_filter_flags); -DEBUGFS_WRITE_FILE_OPS(wd_timeout); - -/* - * Create the debugfs files and directories - * - */ -int il_dbgfs_register(struct il_priv *il, const char *name) -{ - struct dentry *phyd = il->hw->wiphy->debugfsdir; - struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug; - - dir_drv = debugfs_create_dir(name, phyd); - if (!dir_drv) - return -ENOMEM; - - il->debugfs_dir = dir_drv; - - dir_data = debugfs_create_dir("data", dir_drv); - if (!dir_data) - goto err; - dir_rf = debugfs_create_dir("rf", dir_drv); - if (!dir_rf) - goto err; - dir_debug = debugfs_create_dir("debug", dir_drv); - if (!dir_debug) - goto err; - - DEBUGFS_ADD_FILE(nvm, dir_data, S_IRUSR); - DEBUGFS_ADD_FILE(sram, dir_data, S_IWUSR | S_IRUSR); - DEBUGFS_ADD_FILE(stations, dir_data, S_IRUSR); - DEBUGFS_ADD_FILE(channels, dir_data, S_IRUSR); - DEBUGFS_ADD_FILE(status, dir_data, S_IRUSR); - DEBUGFS_ADD_FILE(interrupt, dir_data, S_IWUSR | S_IRUSR); - DEBUGFS_ADD_FILE(qos, dir_data, S_IRUSR); - DEBUGFS_ADD_FILE(disable_ht40, dir_data, S_IWUSR | S_IRUSR); - DEBUGFS_ADD_FILE(rx_stats, dir_debug, S_IRUSR); - DEBUGFS_ADD_FILE(tx_stats, dir_debug, S_IRUSR); - DEBUGFS_ADD_FILE(traffic_log, dir_debug, S_IWUSR | S_IRUSR); - DEBUGFS_ADD_FILE(rx_queue, dir_debug, S_IRUSR); - DEBUGFS_ADD_FILE(tx_queue, dir_debug, S_IRUSR); - DEBUGFS_ADD_FILE(power_save_status, dir_debug, S_IRUSR); - DEBUGFS_ADD_FILE(clear_ucode_stats, dir_debug, S_IWUSR); - DEBUGFS_ADD_FILE(clear_traffic_stats, dir_debug, S_IWUSR); - DEBUGFS_ADD_FILE(fh_reg, dir_debug, S_IRUSR); - DEBUGFS_ADD_FILE(missed_beacon, dir_debug, S_IWUSR); - DEBUGFS_ADD_FILE(force_reset, dir_debug, S_IWUSR | S_IRUSR); - DEBUGFS_ADD_FILE(ucode_rx_stats, dir_debug, S_IRUSR); - DEBUGFS_ADD_FILE(ucode_tx_stats, dir_debug, S_IRUSR); - DEBUGFS_ADD_FILE(ucode_general_stats, dir_debug, S_IRUSR); - - if (il->cfg->base_params->sensitivity_calib_by_driver) - DEBUGFS_ADD_FILE(sensitivity, dir_debug, S_IRUSR); - if (il->cfg->base_params->chain_noise_calib_by_driver) - DEBUGFS_ADD_FILE(chain_noise, dir_debug, S_IRUSR); - DEBUGFS_ADD_FILE(rxon_flags, dir_debug, S_IWUSR); - DEBUGFS_ADD_FILE(rxon_filter_flags, dir_debug, S_IWUSR); - DEBUGFS_ADD_FILE(wd_timeout, dir_debug, S_IWUSR); - if (il->cfg->base_params->sensitivity_calib_by_driver) - DEBUGFS_ADD_BOOL(disable_sensitivity, dir_rf, - &il->disable_sens_cal); - if (il->cfg->base_params->chain_noise_calib_by_driver) - DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf, - &il->disable_chain_noise_cal); - DEBUGFS_ADD_BOOL(disable_tx_power, dir_rf, - &il->disable_tx_power_cal); - return 0; - -err: - IL_ERR("Can't create the debugfs directory\n"); - il_dbgfs_unregister(il); - return -ENOMEM; -} -EXPORT_SYMBOL(il_dbgfs_register); - -/** - * Remove the debugfs files and directories - * - */ -void il_dbgfs_unregister(struct il_priv *il) -{ - if (!il->debugfs_dir) - return; - - debugfs_remove_recursive(il->debugfs_dir); - il->debugfs_dir = NULL; -} -EXPORT_SYMBOL(il_dbgfs_unregister); -- cgit v1.2.3 From f02579e3a81954c8f0944c7d2a95159ee48f052d Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 31 Aug 2011 14:49:56 +0200 Subject: iwlegacy: merge iwl-debug.h into common.h Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/3945.h | 1 - drivers/net/wireless/iwlegacy/4965.h | 2 - drivers/net/wireless/iwlegacy/Kconfig | 2 +- drivers/net/wireless/iwlegacy/common.c | 1 - drivers/net/wireless/iwlegacy/common.h | 191 +++++++++++++++++++++++++----- drivers/net/wireless/iwlegacy/debug.c | 2 - drivers/net/wireless/iwlegacy/iwl-debug.h | 175 --------------------------- 7 files changed, 165 insertions(+), 209 deletions(-) delete mode 100644 drivers/net/wireless/iwlegacy/iwl-debug.h (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index ed367bb7878f..1a2430bb1889 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -35,7 +35,6 @@ extern const struct pci_device_id il3945_hw_card_ids[]; #include "common.h" -#include "iwl-debug.h" /* Highest firmware API version supported */ #define IL3945_UCODE_API_MAX 2 diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h index 10d0b13e0e3c..a4e256bb5061 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -30,8 +30,6 @@ #ifndef __il_4965_h__ #define __il_4965_h__ -#include "iwl-debug.h" - struct il_rx_queue; struct il_rx_buf; struct il_rx_pkt; diff --git a/drivers/net/wireless/iwlegacy/Kconfig b/drivers/net/wireless/iwlegacy/Kconfig index b4be3b44f0a0..05bd375cb845 100644 --- a/drivers/net/wireless/iwlegacy/Kconfig +++ b/drivers/net/wireless/iwlegacy/Kconfig @@ -29,7 +29,7 @@ config IWLEGACY_DEBUG % echo 0x43fff > /sys/class/net/wlan0/device/debug_level You can find the list of debug mask values in: - drivers/net/wireless/iwlegacy/iwl-debug.h + drivers/net/wireless/iwlegacy/common.h If this is your first time using this driver, you should say Y here as the debug information can assist others in helping you resolve diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 5d5efcb4045e..627ac9b32012 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -40,7 +40,6 @@ #include #include -#include "iwl-debug.h" #include "common.h" const char *il_get_cmd_string(u8 cmd) diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index be057aa511b6..b1d237fc5fb7 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -37,12 +37,15 @@ #include "commands.h" #include "csr.h" #include "prph.h" -#include "iwl-debug.h" struct il_host_cmd; struct il_cmd; struct il_tx_queue; +#define IL_ERR(f, a...) dev_err(&il->pci_dev->dev, f, ## a) +#define IL_WARN(f, a...) dev_warn(&il->pci_dev->dev, f, ## a) +#define IL_INFO(f, a...) dev_info(&il->pci_dev->dev, f, ## a) + #define RX_QUEUE_SIZE 256 #define RX_QUEUE_MASK 255 #define RX_QUEUE_SIZE_LOG 8 @@ -1515,29 +1518,6 @@ static inline void il_txq_ctx_deactivate(struct il_priv *il, int txq_id) clear_bit(txq_id, &il->txq_ctx_active_msk); } -#ifdef CONFIG_IWLEGACY_DEBUG -/* - * il_get_debug_level: Return active debug level for device - * - * Using sysfs it is possible to set per device debug level. This debug - * level will be used if set, otherwise the global debug level which can be - * set via module parameter is used. - */ -static inline u32 il_get_debug_level(struct il_priv *il) -{ - if (il->debug_level) - return il->debug_level; - else - return il_debug_level; -} -#else -static inline u32 il_get_debug_level(struct il_priv *il) -{ - return il_debug_level; -} -#endif - - static inline struct ieee80211_hdr * il_tx_queue_get_hdr(struct il_priv *il, int txq_id, int idx) @@ -2736,18 +2716,15 @@ static inline void il_disable_interrupts(struct il_priv *il) * from uCode or flow handler (Rx/Tx DMA) */ _il_wr(il, CSR_INT, 0xffffffff); _il_wr(il, CSR_FH_INT_STATUS, 0xffffffff); - D_ISR("Disabled interrupts\n"); } static inline void il_enable_rfkill_int(struct il_priv *il) { - D_ISR("Enabling rfkill interrupt\n"); _il_wr(il, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); } static inline void il_enable_interrupts(struct il_priv *il) { - D_ISR("Enabling interrupts\n"); set_bit(S_INT_ENABLED, &il->status); _il_wr(il, CSR_INT_MASK, il->inta_mask); } @@ -3304,4 +3281,164 @@ extern void il3945_rate_control_unregister(void); extern int il_power_update_mode(struct il_priv *il, bool force); extern void il_power_initialize(struct il_priv *il); +extern u32 il_debug_level; + +#ifdef CONFIG_IWLEGACY_DEBUG +/* + * il_get_debug_level: Return active debug level for device + * + * Using sysfs it is possible to set per device debug level. This debug + * level will be used if set, otherwise the global debug level which can be + * set via module parameter is used. + */ +static inline u32 il_get_debug_level(struct il_priv *il) +{ + if (il->debug_level) + return il->debug_level; + else + return il_debug_level; +} +#else +static inline u32 il_get_debug_level(struct il_priv *il) +{ + return il_debug_level; +} +#endif + +#define il_print_hex_error(il, p, len) \ +do { \ + print_hex_dump(KERN_ERR, "iwl data: ", \ + DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ +} while (0) + +#ifdef CONFIG_IWLEGACY_DEBUG +#define IL_DBG(level, fmt, args...) \ +do { \ + if (il_get_debug_level(il) & level) \ + dev_printk(KERN_ERR, &il->hw->wiphy->dev, \ + "%c %s " fmt, in_interrupt() ? 'I' : 'U', \ + __func__ , ## args); \ +} while (0) + +#define il_print_hex_dump(il, level, p, len) \ +do { \ + if (il_get_debug_level(il) & level) \ + print_hex_dump(KERN_DEBUG, "iwl data: ", \ + DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ +} while (0) + +#else +#define IL_DBG(level, fmt, args...) +static inline void il_print_hex_dump(struct il_priv *il, int level, + const void *p, u32 len) +{} +#endif /* CONFIG_IWLEGACY_DEBUG */ + +#ifdef CONFIG_IWLEGACY_DEBUGFS +int il_dbgfs_register(struct il_priv *il, const char *name); +void il_dbgfs_unregister(struct il_priv *il); +#else +static inline int +il_dbgfs_register(struct il_priv *il, const char *name) +{ + return 0; +} +static inline void il_dbgfs_unregister(struct il_priv *il) +{ +} +#endif /* CONFIG_IWLEGACY_DEBUGFS */ + +/* + * To use the debug system: + * + * If you are defining a new debug classification, simply add it to the #define + * list here in the form of + * + * #define IL_DL_xxxx VALUE + * + * where xxxx should be the name of the classification (for example, WEP). + * + * You then need to either add a IL_xxxx_DEBUG() macro definition for your + * classification, or use IL_DBG(IL_DL_xxxx, ...) whenever you want + * to send output to that classification. + * + * The active debug levels can be accessed via files + * + * /sys/module/iwl4965/parameters/debug + * /sys/module/iwl3945/parameters/debug + * /sys/class/net/wlan0/device/debug_level + * + * when CONFIG_IWLEGACY_DEBUG=y. + */ + +/* 0x0000000F - 0x00000001 */ +#define IL_DL_INFO (1 << 0) +#define IL_DL_MAC80211 (1 << 1) +#define IL_DL_HCMD (1 << 2) +#define IL_DL_STATE (1 << 3) +/* 0x000000F0 - 0x00000010 */ +#define IL_DL_MACDUMP (1 << 4) +#define IL_DL_HCMD_DUMP (1 << 5) +#define IL_DL_EEPROM (1 << 6) +#define IL_DL_RADIO (1 << 7) +/* 0x00000F00 - 0x00000100 */ +#define IL_DL_POWER (1 << 8) +#define IL_DL_TEMP (1 << 9) +#define IL_DL_NOTIF (1 << 10) +#define IL_DL_SCAN (1 << 11) +/* 0x0000F000 - 0x00001000 */ +#define IL_DL_ASSOC (1 << 12) +#define IL_DL_DROP (1 << 13) +#define IL_DL_TXPOWER (1 << 14) +#define IL_DL_AP (1 << 15) +/* 0x000F0000 - 0x00010000 */ +#define IL_DL_FW (1 << 16) +#define IL_DL_RF_KILL (1 << 17) +#define IL_DL_FW_ERRORS (1 << 18) +#define IL_DL_LED (1 << 19) +/* 0x00F00000 - 0x00100000 */ +#define IL_DL_RATE (1 << 20) +#define IL_DL_CALIB (1 << 21) +#define IL_DL_WEP (1 << 22) +#define IL_DL_TX (1 << 23) +/* 0x0F000000 - 0x01000000 */ +#define IL_DL_RX (1 << 24) +#define IL_DL_ISR (1 << 25) +#define IL_DL_HT (1 << 26) +/* 0xF0000000 - 0x10000000 */ +#define IL_DL_11H (1 << 28) +#define IL_DL_STATS (1 << 29) +#define IL_DL_TX_REPLY (1 << 30) +#define IL_DL_QOS (1 << 31) + +#define D_INFO(f, a...) IL_DBG(IL_DL_INFO, f, ## a) +#define D_MAC80211(f, a...) IL_DBG(IL_DL_MAC80211, f, ## a) +#define D_MACDUMP(f, a...) IL_DBG(IL_DL_MACDUMP, f, ## a) +#define D_TEMP(f, a...) IL_DBG(IL_DL_TEMP, f, ## a) +#define D_SCAN(f, a...) IL_DBG(IL_DL_SCAN, f, ## a) +#define D_RX(f, a...) IL_DBG(IL_DL_RX, f, ## a) +#define D_TX(f, a...) IL_DBG(IL_DL_TX, f, ## a) +#define D_ISR(f, a...) IL_DBG(IL_DL_ISR, f, ## a) +#define D_LED(f, a...) IL_DBG(IL_DL_LED, f, ## a) +#define D_WEP(f, a...) IL_DBG(IL_DL_WEP, f, ## a) +#define D_HC(f, a...) IL_DBG(IL_DL_HCMD, f, ## a) +#define D_HC_DUMP(f, a...) IL_DBG(IL_DL_HCMD_DUMP, f, ## a) +#define D_EEPROM(f, a...) IL_DBG(IL_DL_EEPROM, f, ## a) +#define D_CALIB(f, a...) IL_DBG(IL_DL_CALIB, f, ## a) +#define D_FW(f, a...) IL_DBG(IL_DL_FW, f, ## a) +#define D_RF_KILL(f, a...) IL_DBG(IL_DL_RF_KILL, f, ## a) +#define D_DROP(f, a...) IL_DBG(IL_DL_DROP, f, ## a) +#define D_AP(f, a...) IL_DBG(IL_DL_AP, f, ## a) +#define D_TXPOWER(f, a...) IL_DBG(IL_DL_TXPOWER, f, ## a) +#define D_RATE(f, a...) IL_DBG(IL_DL_RATE, f, ## a) +#define D_NOTIF(f, a...) IL_DBG(IL_DL_NOTIF, f, ## a) +#define D_ASSOC(f, a...) IL_DBG(IL_DL_ASSOC, f, ## a) +#define D_HT(f, a...) IL_DBG(IL_DL_HT, f, ## a) +#define D_STATS(f, a...) IL_DBG(IL_DL_STATS, f, ## a) +#define D_TX_REPLY(f, a...) IL_DBG(IL_DL_TX_REPLY, f, ## a) +#define D_QOS(f, a...) IL_DBG(IL_DL_QOS, f, ## a) +#define D_RADIO(f, a...) IL_DBG(IL_DL_RADIO, f, ## a) +#define D_POWER(f, a...) IL_DBG(IL_DL_POWER, f, ## a) +#define D_11H(f, a...) IL_DBG(IL_DL_11H, f, ## a) + #endif /* __il_core_h__ */ diff --git a/drivers/net/wireless/iwlegacy/debug.c b/drivers/net/wireless/iwlegacy/debug.c index 62292a68567d..4e2b6c80849e 100644 --- a/drivers/net/wireless/iwlegacy/debug.c +++ b/drivers/net/wireless/iwlegacy/debug.c @@ -28,8 +28,6 @@ #include #include - -#include "iwl-debug.h" #include "common.h" /* create and remove of files */ diff --git a/drivers/net/wireless/iwlegacy/iwl-debug.h b/drivers/net/wireless/iwlegacy/iwl-debug.h deleted file mode 100644 index c58003aa8185..000000000000 --- a/drivers/net/wireless/iwlegacy/iwl-debug.h +++ /dev/null @@ -1,175 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2003 - 2011 Intel Corporation. All rights reserved. - * - * Portions of this file are derived from the ipw3945 project. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * The full GNU General Public License is included in this distribution in the - * file called LICENSE. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#ifndef __il_debug_h__ -#define __il_debug_h__ - -struct il_priv; -extern u32 il_debug_level; - -#define IL_ERR(f, a...) dev_err(&il->pci_dev->dev, f, ## a) -#define IL_WARN(f, a...) dev_warn(&il->pci_dev->dev, f, ## a) -#define IL_INFO(f, a...) dev_info(&il->pci_dev->dev, f, ## a) - -#define il_print_hex_error(il, p, len) \ -do { \ - print_hex_dump(KERN_ERR, "iwl data: ", \ - DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ -} while (0) - -#ifdef CONFIG_IWLEGACY_DEBUG -#define IL_DBG(level, fmt, args...) \ -do { \ - if (il_get_debug_level(il) & level) \ - dev_printk(KERN_ERR, &il->hw->wiphy->dev, \ - "%c %s " fmt, in_interrupt() ? 'I' : 'U', \ - __func__ , ## args); \ -} while (0) - -#define il_print_hex_dump(il, level, p, len) \ -do { \ - if (il_get_debug_level(il) & level) \ - print_hex_dump(KERN_DEBUG, "iwl data: ", \ - DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ -} while (0) - -#else -#define IL_DBG(level, fmt, args...) -static inline void il_print_hex_dump(struct il_priv *il, int level, - const void *p, u32 len) -{} -#endif /* CONFIG_IWLEGACY_DEBUG */ - -#ifdef CONFIG_IWLEGACY_DEBUGFS -int il_dbgfs_register(struct il_priv *il, const char *name); -void il_dbgfs_unregister(struct il_priv *il); -#else -static inline int -il_dbgfs_register(struct il_priv *il, const char *name) -{ - return 0; -} -static inline void il_dbgfs_unregister(struct il_priv *il) -{ -} -#endif /* CONFIG_IWLEGACY_DEBUGFS */ - -/* - * To use the debug system: - * - * If you are defining a new debug classification, simply add it to the #define - * list here in the form of - * - * #define IL_DL_xxxx VALUE - * - * where xxxx should be the name of the classification (for example, WEP). - * - * You then need to either add a IL_xxxx_DEBUG() macro definition for your - * classification, or use IL_DBG(IL_DL_xxxx, ...) whenever you want - * to send output to that classification. - * - * The active debug levels can be accessed via files - * - * /sys/module/iwl4965/parameters/debug - * /sys/module/iwl3945/parameters/debug - * /sys/class/net/wlan0/device/debug_level - * - * when CONFIG_IWLEGACY_DEBUG=y. - */ - -/* 0x0000000F - 0x00000001 */ -#define IL_DL_INFO (1 << 0) -#define IL_DL_MAC80211 (1 << 1) -#define IL_DL_HCMD (1 << 2) -#define IL_DL_STATE (1 << 3) -/* 0x000000F0 - 0x00000010 */ -#define IL_DL_MACDUMP (1 << 4) -#define IL_DL_HCMD_DUMP (1 << 5) -#define IL_DL_EEPROM (1 << 6) -#define IL_DL_RADIO (1 << 7) -/* 0x00000F00 - 0x00000100 */ -#define IL_DL_POWER (1 << 8) -#define IL_DL_TEMP (1 << 9) -#define IL_DL_NOTIF (1 << 10) -#define IL_DL_SCAN (1 << 11) -/* 0x0000F000 - 0x00001000 */ -#define IL_DL_ASSOC (1 << 12) -#define IL_DL_DROP (1 << 13) -#define IL_DL_TXPOWER (1 << 14) -#define IL_DL_AP (1 << 15) -/* 0x000F0000 - 0x00010000 */ -#define IL_DL_FW (1 << 16) -#define IL_DL_RF_KILL (1 << 17) -#define IL_DL_FW_ERRORS (1 << 18) -#define IL_DL_LED (1 << 19) -/* 0x00F00000 - 0x00100000 */ -#define IL_DL_RATE (1 << 20) -#define IL_DL_CALIB (1 << 21) -#define IL_DL_WEP (1 << 22) -#define IL_DL_TX (1 << 23) -/* 0x0F000000 - 0x01000000 */ -#define IL_DL_RX (1 << 24) -#define IL_DL_ISR (1 << 25) -#define IL_DL_HT (1 << 26) -/* 0xF0000000 - 0x10000000 */ -#define IL_DL_11H (1 << 28) -#define IL_DL_STATS (1 << 29) -#define IL_DL_TX_REPLY (1 << 30) -#define IL_DL_QOS (1 << 31) - -#define D_INFO(f, a...) IL_DBG(IL_DL_INFO, f, ## a) -#define D_MAC80211(f, a...) IL_DBG(IL_DL_MAC80211, f, ## a) -#define D_MACDUMP(f, a...) IL_DBG(IL_DL_MACDUMP, f, ## a) -#define D_TEMP(f, a...) IL_DBG(IL_DL_TEMP, f, ## a) -#define D_SCAN(f, a...) IL_DBG(IL_DL_SCAN, f, ## a) -#define D_RX(f, a...) IL_DBG(IL_DL_RX, f, ## a) -#define D_TX(f, a...) IL_DBG(IL_DL_TX, f, ## a) -#define D_ISR(f, a...) IL_DBG(IL_DL_ISR, f, ## a) -#define D_LED(f, a...) IL_DBG(IL_DL_LED, f, ## a) -#define D_WEP(f, a...) IL_DBG(IL_DL_WEP, f, ## a) -#define D_HC(f, a...) IL_DBG(IL_DL_HCMD, f, ## a) -#define D_HC_DUMP(f, a...) IL_DBG(IL_DL_HCMD_DUMP, f, ## a) -#define D_EEPROM(f, a...) IL_DBG(IL_DL_EEPROM, f, ## a) -#define D_CALIB(f, a...) IL_DBG(IL_DL_CALIB, f, ## a) -#define D_FW(f, a...) IL_DBG(IL_DL_FW, f, ## a) -#define D_RF_KILL(f, a...) IL_DBG(IL_DL_RF_KILL, f, ## a) -#define D_DROP(f, a...) IL_DBG(IL_DL_DROP, f, ## a) -#define D_AP(f, a...) IL_DBG(IL_DL_AP, f, ## a) -#define D_TXPOWER(f, a...) IL_DBG(IL_DL_TXPOWER, f, ## a) -#define D_RATE(f, a...) IL_DBG(IL_DL_RATE, f, ## a) -#define D_NOTIF(f, a...) IL_DBG(IL_DL_NOTIF, f, ## a) -#define D_ASSOC(f, a...) IL_DBG(IL_DL_ASSOC, f, ## a) -#define D_HT(f, a...) IL_DBG(IL_DL_HT, f, ## a) -#define D_STATS(f, a...) IL_DBG(IL_DL_STATS, f, ## a) -#define D_TX_REPLY(f, a...) IL_DBG(IL_DL_TX_REPLY, f, ## a) -#define D_QOS(f, a...) IL_DBG(IL_DL_QOS, f, ## a) -#define D_RADIO(f, a...) IL_DBG(IL_DL_RADIO, f, ## a) -#define D_POWER(f, a...) IL_DBG(IL_DL_POWER, f, ## a) -#define D_11H(f, a...) IL_DBG(IL_DL_11H, f, ## a) - -#endif -- cgit v1.2.3 From e7392364fcd1004a5e495f15cf21b1e0ef874215 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 14:45:59 +0100 Subject: iwlegacy: indentions and whitespaces Process iwlegacy source files using: indent -npro -l500 -nhnl indent -npro -kr -i8 -ts8 -sob -l80 -nbbo -ss -ncs -cp1 -il0 -psl Plus manual compilation fixes. Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/3945-debug.c | 698 +++++---- drivers/net/wireless/iwlegacy/3945-mac.c | 1143 +++++++-------- drivers/net/wireless/iwlegacy/3945-rs.c | 252 ++-- drivers/net/wireless/iwlegacy/3945.c | 920 ++++++------ drivers/net/wireless/iwlegacy/3945.h | 115 +- drivers/net/wireless/iwlegacy/4965-calib.c | 354 +++-- drivers/net/wireless/iwlegacy/4965-debug.c | 1178 ++++++++------- drivers/net/wireless/iwlegacy/4965-mac.c | 2173 ++++++++++++++-------------- drivers/net/wireless/iwlegacy/4965-rs.c | 1094 +++++++------- drivers/net/wireless/iwlegacy/4965.c | 741 +++++----- drivers/net/wireless/iwlegacy/4965.h | 184 ++- drivers/net/wireless/iwlegacy/commands.h | 123 +- drivers/net/wireless/iwlegacy/common.c | 1927 ++++++++++++------------ drivers/net/wireless/iwlegacy/common.h | 934 ++++++------ drivers/net/wireless/iwlegacy/csr.h | 69 +- drivers/net/wireless/iwlegacy/debug.c | 965 ++++++------ drivers/net/wireless/iwlegacy/prph.h | 25 +- 17 files changed, 6439 insertions(+), 6456 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/3945-debug.c b/drivers/net/wireless/iwlegacy/3945-debug.c index 1a690a046b50..382af2e958eb 100644 --- a/drivers/net/wireless/iwlegacy/3945-debug.c +++ b/drivers/net/wireless/iwlegacy/3945-debug.c @@ -29,39 +29,37 @@ #include "common.h" #include "3945.h" -static int il3945_stats_flag(struct il_priv *il, char *buf, int bufsz) +static int +il3945_stats_flag(struct il_priv *il, char *buf, int bufsz) { int p = 0; p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", le32_to_cpu(il->_3945.stats.flag)); - if (le32_to_cpu(il->_3945.stats.flag) & - UCODE_STATS_CLEAR_MSK) + if (le32_to_cpu(il->_3945.stats.flag) & UCODE_STATS_CLEAR_MSK) p += scnprintf(buf + p, bufsz - p, "\tStatistics have been cleared\n"); p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n", (le32_to_cpu(il->_3945.stats.flag) & - UCODE_STATS_FREQUENCY_MSK) - ? "2.4 GHz" : "5.2 GHz"); + UCODE_STATS_FREQUENCY_MSK) ? "2.4 GHz" : "5.2 GHz"); p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n", (le32_to_cpu(il->_3945.stats.flag) & - UCODE_STATS_NARROW_BAND_MSK) - ? "enabled" : "disabled"); + UCODE_STATS_NARROW_BAND_MSK) ? "enabled" : "disabled"); return p; } -ssize_t il3945_ucode_rx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +ssize_t +il3945_ucode_rx_stats_read(struct file * file, char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; int pos = 0; char *buf; - int bufsz = sizeof(struct iwl39_stats_rx_phy) * 40 + - sizeof(struct iwl39_stats_rx_non_phy) * 40 + 400; + int bufsz = + sizeof(struct iwl39_stats_rx_phy) * 40 + + sizeof(struct iwl39_stats_rx_non_phy) * 40 + 400; ssize_t ret; - struct iwl39_stats_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, - *max_ofdm; + struct iwl39_stats_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm; struct iwl39_stats_rx_phy *cck, *accum_cck, *delta_cck, *max_cck; struct iwl39_stats_rx_non_phy *general, *accum_general; struct iwl39_stats_rx_non_phy *delta_general, *max_general; @@ -94,240 +92,230 @@ ssize_t il3945_ucode_rx_stats_read(struct file *file, max_general = &il->_3945.max_delta.rx.general; pos += il3945_stats_flag(il, buf, bufsz); - pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" - "acumulative delta max\n", - "Statistics_Rx - OFDM:"); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "ina_cnt:", le32_to_cpu(ofdm->ina_cnt), - accum_ofdm->ina_cnt, - delta_ofdm->ina_cnt, max_ofdm->ina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "fina_cnt:", - le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt, - delta_ofdm->fina_cnt, max_ofdm->fina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", "plcp_err:", - le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err, - delta_ofdm->plcp_err, max_ofdm->plcp_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", "crc32_err:", - le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err, - delta_ofdm->crc32_err, max_ofdm->crc32_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", "overrun_err:", - le32_to_cpu(ofdm->overrun_err), - accum_ofdm->overrun_err, delta_ofdm->overrun_err, - max_ofdm->overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "early_overrun_err:", - le32_to_cpu(ofdm->early_overrun_err), - accum_ofdm->early_overrun_err, - delta_ofdm->early_overrun_err, - max_ofdm->early_overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "crc32_good:", le32_to_cpu(ofdm->crc32_good), - accum_ofdm->crc32_good, delta_ofdm->crc32_good, - max_ofdm->crc32_good); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", "false_alarm_cnt:", - le32_to_cpu(ofdm->false_alarm_cnt), - accum_ofdm->false_alarm_cnt, - delta_ofdm->false_alarm_cnt, - max_ofdm->false_alarm_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "fina_sync_err_cnt:", - le32_to_cpu(ofdm->fina_sync_err_cnt), - accum_ofdm->fina_sync_err_cnt, - delta_ofdm->fina_sync_err_cnt, - max_ofdm->fina_sync_err_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sfd_timeout:", - le32_to_cpu(ofdm->sfd_timeout), - accum_ofdm->sfd_timeout, - delta_ofdm->sfd_timeout, - max_ofdm->sfd_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "fina_timeout:", - le32_to_cpu(ofdm->fina_timeout), - accum_ofdm->fina_timeout, - delta_ofdm->fina_timeout, - max_ofdm->fina_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "unresponded_rts:", - le32_to_cpu(ofdm->unresponded_rts), - accum_ofdm->unresponded_rts, - delta_ofdm->unresponded_rts, - max_ofdm->unresponded_rts); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "rxe_frame_lmt_ovrun:", - le32_to_cpu(ofdm->rxe_frame_limit_overrun), - accum_ofdm->rxe_frame_limit_overrun, - delta_ofdm->rxe_frame_limit_overrun, - max_ofdm->rxe_frame_limit_overrun); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sent_ack_cnt:", - le32_to_cpu(ofdm->sent_ack_cnt), - accum_ofdm->sent_ack_cnt, - delta_ofdm->sent_ack_cnt, - max_ofdm->sent_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sent_cts_cnt:", - le32_to_cpu(ofdm->sent_cts_cnt), - accum_ofdm->sent_cts_cnt, - delta_ofdm->sent_cts_cnt, max_ofdm->sent_cts_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + "%-32s current" + "acumulative delta max\n", + "Statistics_Rx - OFDM:"); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "ina_cnt:", + le32_to_cpu(ofdm->ina_cnt), accum_ofdm->ina_cnt, + delta_ofdm->ina_cnt, max_ofdm->ina_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "fina_cnt:", + le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt, + delta_ofdm->fina_cnt, max_ofdm->fina_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "plcp_err:", + le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err, + delta_ofdm->plcp_err, max_ofdm->plcp_err); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "crc32_err:", + le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err, + delta_ofdm->crc32_err, max_ofdm->crc32_err); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "overrun_err:", + le32_to_cpu(ofdm->overrun_err), accum_ofdm->overrun_err, + delta_ofdm->overrun_err, max_ofdm->overrun_err); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "early_overrun_err:", + le32_to_cpu(ofdm->early_overrun_err), + accum_ofdm->early_overrun_err, + delta_ofdm->early_overrun_err, + max_ofdm->early_overrun_err); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "crc32_good:", + le32_to_cpu(ofdm->crc32_good), accum_ofdm->crc32_good, + delta_ofdm->crc32_good, max_ofdm->crc32_good); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "false_alarm_cnt:", + le32_to_cpu(ofdm->false_alarm_cnt), + accum_ofdm->false_alarm_cnt, delta_ofdm->false_alarm_cnt, + max_ofdm->false_alarm_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "fina_sync_err_cnt:", + le32_to_cpu(ofdm->fina_sync_err_cnt), + accum_ofdm->fina_sync_err_cnt, + delta_ofdm->fina_sync_err_cnt, + max_ofdm->fina_sync_err_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "sfd_timeout:", + le32_to_cpu(ofdm->sfd_timeout), accum_ofdm->sfd_timeout, + delta_ofdm->sfd_timeout, max_ofdm->sfd_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "fina_timeout:", + le32_to_cpu(ofdm->fina_timeout), accum_ofdm->fina_timeout, + delta_ofdm->fina_timeout, max_ofdm->fina_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "unresponded_rts:", + le32_to_cpu(ofdm->unresponded_rts), + accum_ofdm->unresponded_rts, delta_ofdm->unresponded_rts, + max_ofdm->unresponded_rts); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "rxe_frame_lmt_ovrun:", + le32_to_cpu(ofdm->rxe_frame_limit_overrun), + accum_ofdm->rxe_frame_limit_overrun, + delta_ofdm->rxe_frame_limit_overrun, + max_ofdm->rxe_frame_limit_overrun); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "sent_ack_cnt:", + le32_to_cpu(ofdm->sent_ack_cnt), accum_ofdm->sent_ack_cnt, + delta_ofdm->sent_ack_cnt, max_ofdm->sent_ack_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "sent_cts_cnt:", + le32_to_cpu(ofdm->sent_cts_cnt), accum_ofdm->sent_cts_cnt, + delta_ofdm->sent_cts_cnt, max_ofdm->sent_cts_cnt); - pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" - "acumulative delta max\n", - "Statistics_Rx - CCK:"); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "ina_cnt:", - le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt, - delta_cck->ina_cnt, max_cck->ina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "fina_cnt:", - le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt, - delta_cck->fina_cnt, max_cck->fina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "plcp_err:", - le32_to_cpu(cck->plcp_err), accum_cck->plcp_err, - delta_cck->plcp_err, max_cck->plcp_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "crc32_err:", - le32_to_cpu(cck->crc32_err), accum_cck->crc32_err, - delta_cck->crc32_err, max_cck->crc32_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "overrun_err:", - le32_to_cpu(cck->overrun_err), - accum_cck->overrun_err, - delta_cck->overrun_err, max_cck->overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "early_overrun_err:", - le32_to_cpu(cck->early_overrun_err), - accum_cck->early_overrun_err, - delta_cck->early_overrun_err, - max_cck->early_overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "crc32_good:", - le32_to_cpu(cck->crc32_good), accum_cck->crc32_good, - delta_cck->crc32_good, - max_cck->crc32_good); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "false_alarm_cnt:", - le32_to_cpu(cck->false_alarm_cnt), - accum_cck->false_alarm_cnt, - delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "fina_sync_err_cnt:", - le32_to_cpu(cck->fina_sync_err_cnt), - accum_cck->fina_sync_err_cnt, - delta_cck->fina_sync_err_cnt, - max_cck->fina_sync_err_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sfd_timeout:", - le32_to_cpu(cck->sfd_timeout), - accum_cck->sfd_timeout, - delta_cck->sfd_timeout, max_cck->sfd_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "fina_timeout:", - le32_to_cpu(cck->fina_timeout), - accum_cck->fina_timeout, - delta_cck->fina_timeout, max_cck->fina_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "unresponded_rts:", - le32_to_cpu(cck->unresponded_rts), - accum_cck->unresponded_rts, - delta_cck->unresponded_rts, - max_cck->unresponded_rts); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "rxe_frame_lmt_ovrun:", - le32_to_cpu(cck->rxe_frame_limit_overrun), - accum_cck->rxe_frame_limit_overrun, - delta_cck->rxe_frame_limit_overrun, - max_cck->rxe_frame_limit_overrun); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sent_ack_cnt:", - le32_to_cpu(cck->sent_ack_cnt), - accum_cck->sent_ack_cnt, - delta_cck->sent_ack_cnt, - max_cck->sent_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sent_cts_cnt:", - le32_to_cpu(cck->sent_cts_cnt), - accum_cck->sent_cts_cnt, - delta_cck->sent_cts_cnt, - max_cck->sent_cts_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + "%-32s current" + "acumulative delta max\n", + "Statistics_Rx - CCK:"); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "ina_cnt:", + le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt, + delta_cck->ina_cnt, max_cck->ina_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "fina_cnt:", + le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt, + delta_cck->fina_cnt, max_cck->fina_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "plcp_err:", + le32_to_cpu(cck->plcp_err), accum_cck->plcp_err, + delta_cck->plcp_err, max_cck->plcp_err); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "crc32_err:", + le32_to_cpu(cck->crc32_err), accum_cck->crc32_err, + delta_cck->crc32_err, max_cck->crc32_err); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "overrun_err:", + le32_to_cpu(cck->overrun_err), accum_cck->overrun_err, + delta_cck->overrun_err, max_cck->overrun_err); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "early_overrun_err:", + le32_to_cpu(cck->early_overrun_err), + accum_cck->early_overrun_err, + delta_cck->early_overrun_err, max_cck->early_overrun_err); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "crc32_good:", + le32_to_cpu(cck->crc32_good), accum_cck->crc32_good, + delta_cck->crc32_good, max_cck->crc32_good); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "false_alarm_cnt:", + le32_to_cpu(cck->false_alarm_cnt), + accum_cck->false_alarm_cnt, delta_cck->false_alarm_cnt, + max_cck->false_alarm_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "fina_sync_err_cnt:", + le32_to_cpu(cck->fina_sync_err_cnt), + accum_cck->fina_sync_err_cnt, + delta_cck->fina_sync_err_cnt, max_cck->fina_sync_err_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "sfd_timeout:", + le32_to_cpu(cck->sfd_timeout), accum_cck->sfd_timeout, + delta_cck->sfd_timeout, max_cck->sfd_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "fina_timeout:", + le32_to_cpu(cck->fina_timeout), accum_cck->fina_timeout, + delta_cck->fina_timeout, max_cck->fina_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "unresponded_rts:", + le32_to_cpu(cck->unresponded_rts), + accum_cck->unresponded_rts, delta_cck->unresponded_rts, + max_cck->unresponded_rts); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "rxe_frame_lmt_ovrun:", + le32_to_cpu(cck->rxe_frame_limit_overrun), + accum_cck->rxe_frame_limit_overrun, + delta_cck->rxe_frame_limit_overrun, + max_cck->rxe_frame_limit_overrun); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "sent_ack_cnt:", + le32_to_cpu(cck->sent_ack_cnt), accum_cck->sent_ack_cnt, + delta_cck->sent_ack_cnt, max_cck->sent_ack_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "sent_cts_cnt:", + le32_to_cpu(cck->sent_cts_cnt), accum_cck->sent_cts_cnt, + delta_cck->sent_cts_cnt, max_cck->sent_cts_cnt); - pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" - "acumulative delta max\n", - "Statistics_Rx - GENERAL:"); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "bogus_cts:", - le32_to_cpu(general->bogus_cts), - accum_general->bogus_cts, - delta_general->bogus_cts, max_general->bogus_cts); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "bogus_ack:", - le32_to_cpu(general->bogus_ack), - accum_general->bogus_ack, - delta_general->bogus_ack, max_general->bogus_ack); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "non_bssid_frames:", - le32_to_cpu(general->non_bssid_frames), - accum_general->non_bssid_frames, - delta_general->non_bssid_frames, - max_general->non_bssid_frames); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "filtered_frames:", - le32_to_cpu(general->filtered_frames), - accum_general->filtered_frames, - delta_general->filtered_frames, - max_general->filtered_frames); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "non_channel_beacons:", - le32_to_cpu(general->non_channel_beacons), - accum_general->non_channel_beacons, - delta_general->non_channel_beacons, - max_general->non_channel_beacons); + pos += + scnprintf(buf + pos, bufsz - pos, + "%-32s current" + "acumulative delta max\n", + "Statistics_Rx - GENERAL:"); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "bogus_cts:", + le32_to_cpu(general->bogus_cts), accum_general->bogus_cts, + delta_general->bogus_cts, max_general->bogus_cts); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "bogus_ack:", + le32_to_cpu(general->bogus_ack), accum_general->bogus_ack, + delta_general->bogus_ack, max_general->bogus_ack); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "non_bssid_frames:", + le32_to_cpu(general->non_bssid_frames), + accum_general->non_bssid_frames, + delta_general->non_bssid_frames, + max_general->non_bssid_frames); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "filtered_frames:", + le32_to_cpu(general->filtered_frames), + accum_general->filtered_frames, + delta_general->filtered_frames, + max_general->filtered_frames); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", + "non_channel_beacons:", + le32_to_cpu(general->non_channel_beacons), + accum_general->non_channel_beacons, + delta_general->non_channel_beacons, + max_general->non_channel_beacons); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; } -ssize_t il3945_ucode_tx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +ssize_t +il3945_ucode_tx_stats_read(struct file * file, char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; int pos = 0; @@ -355,75 +343,69 @@ ssize_t il3945_ucode_tx_stats_read(struct file *file, delta_tx = &il->_3945.delta_stats.tx; max_tx = &il->_3945.max_delta.tx; pos += il3945_stats_flag(il, buf, bufsz); - pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" - "acumulative delta max\n", - "Statistics_Tx:"); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "preamble:", - le32_to_cpu(tx->preamble_cnt), - accum_tx->preamble_cnt, - delta_tx->preamble_cnt, max_tx->preamble_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "rx_detected_cnt:", - le32_to_cpu(tx->rx_detected_cnt), - accum_tx->rx_detected_cnt, - delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "bt_prio_defer_cnt:", - le32_to_cpu(tx->bt_prio_defer_cnt), - accum_tx->bt_prio_defer_cnt, - delta_tx->bt_prio_defer_cnt, - max_tx->bt_prio_defer_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "bt_prio_kill_cnt:", - le32_to_cpu(tx->bt_prio_kill_cnt), - accum_tx->bt_prio_kill_cnt, - delta_tx->bt_prio_kill_cnt, - max_tx->bt_prio_kill_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "few_bytes_cnt:", - le32_to_cpu(tx->few_bytes_cnt), - accum_tx->few_bytes_cnt, - delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "cts_timeout:", - le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout, - delta_tx->cts_timeout, max_tx->cts_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "ack_timeout:", - le32_to_cpu(tx->ack_timeout), - accum_tx->ack_timeout, - delta_tx->ack_timeout, max_tx->ack_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "expected_ack_cnt:", - le32_to_cpu(tx->expected_ack_cnt), - accum_tx->expected_ack_cnt, - delta_tx->expected_ack_cnt, - max_tx->expected_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "actual_ack_cnt:", - le32_to_cpu(tx->actual_ack_cnt), - accum_tx->actual_ack_cnt, - delta_tx->actual_ack_cnt, - max_tx->actual_ack_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + "%-32s current" + "acumulative delta max\n", + "Statistics_Tx:"); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "preamble:", + le32_to_cpu(tx->preamble_cnt), accum_tx->preamble_cnt, + delta_tx->preamble_cnt, max_tx->preamble_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "rx_detected_cnt:", + le32_to_cpu(tx->rx_detected_cnt), + accum_tx->rx_detected_cnt, delta_tx->rx_detected_cnt, + max_tx->rx_detected_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "bt_prio_defer_cnt:", + le32_to_cpu(tx->bt_prio_defer_cnt), + accum_tx->bt_prio_defer_cnt, delta_tx->bt_prio_defer_cnt, + max_tx->bt_prio_defer_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "bt_prio_kill_cnt:", + le32_to_cpu(tx->bt_prio_kill_cnt), + accum_tx->bt_prio_kill_cnt, delta_tx->bt_prio_kill_cnt, + max_tx->bt_prio_kill_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "few_bytes_cnt:", + le32_to_cpu(tx->few_bytes_cnt), accum_tx->few_bytes_cnt, + delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "cts_timeout:", + le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout, + delta_tx->cts_timeout, max_tx->cts_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "ack_timeout:", + le32_to_cpu(tx->ack_timeout), accum_tx->ack_timeout, + delta_tx->ack_timeout, max_tx->ack_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "expected_ack_cnt:", + le32_to_cpu(tx->expected_ack_cnt), + accum_tx->expected_ack_cnt, delta_tx->expected_ack_cnt, + max_tx->expected_ack_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "actual_ack_cnt:", + le32_to_cpu(tx->actual_ack_cnt), accum_tx->actual_ack_cnt, + delta_tx->actual_ack_cnt, max_tx->actual_ack_cnt); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; } -ssize_t il3945_ucode_general_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +ssize_t +il3945_ucode_general_stats_read(struct file * file, char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; int pos = 0; @@ -462,61 +444,61 @@ ssize_t il3945_ucode_general_stats_read(struct file *file, delta_div = &il->_3945.delta_stats.general.div; max_div = &il->_3945.max_delta.general.div; pos += il3945_stats_flag(il, buf, bufsz); - pos += scnprintf(buf + pos, bufsz - pos, "%-32s current" - "acumulative delta max\n", - "Statistics_General:"); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "burst_check:", - le32_to_cpu(dbg->burst_check), - accum_dbg->burst_check, - delta_dbg->burst_check, max_dbg->burst_check); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "burst_count:", - le32_to_cpu(dbg->burst_count), - accum_dbg->burst_count, - delta_dbg->burst_count, max_dbg->burst_count); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "sleep_time:", - le32_to_cpu(general->sleep_time), - accum_general->sleep_time, - delta_general->sleep_time, max_general->sleep_time); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "slots_out:", - le32_to_cpu(general->slots_out), - accum_general->slots_out, - delta_general->slots_out, max_general->slots_out); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "slots_idle:", - le32_to_cpu(general->slots_idle), - accum_general->slots_idle, - delta_general->slots_idle, max_general->slots_idle); - pos += scnprintf(buf + pos, bufsz - pos, "ttl_timestamp:\t\t\t%u\n", - le32_to_cpu(general->ttl_timestamp)); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "tx_on_a:", - le32_to_cpu(div->tx_on_a), accum_div->tx_on_a, - delta_div->tx_on_a, max_div->tx_on_a); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "tx_on_b:", - le32_to_cpu(div->tx_on_b), accum_div->tx_on_b, - delta_div->tx_on_b, max_div->tx_on_b); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "exec_time:", - le32_to_cpu(div->exec_time), accum_div->exec_time, - delta_div->exec_time, max_div->exec_time); - pos += scnprintf(buf + pos, bufsz - pos, - " %-30s %10u %10u %10u %10u\n", - "probe_time:", - le32_to_cpu(div->probe_time), accum_div->probe_time, - delta_div->probe_time, max_div->probe_time); + pos += + scnprintf(buf + pos, bufsz - pos, + "%-32s current" + "acumulative delta max\n", + "Statistics_General:"); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "burst_check:", + le32_to_cpu(dbg->burst_check), accum_dbg->burst_check, + delta_dbg->burst_check, max_dbg->burst_check); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "burst_count:", + le32_to_cpu(dbg->burst_count), accum_dbg->burst_count, + delta_dbg->burst_count, max_dbg->burst_count); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "sleep_time:", + le32_to_cpu(general->sleep_time), + accum_general->sleep_time, delta_general->sleep_time, + max_general->sleep_time); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "slots_out:", + le32_to_cpu(general->slots_out), accum_general->slots_out, + delta_general->slots_out, max_general->slots_out); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "slots_idle:", + le32_to_cpu(general->slots_idle), + accum_general->slots_idle, delta_general->slots_idle, + max_general->slots_idle); + pos += + scnprintf(buf + pos, bufsz - pos, "ttl_timestamp:\t\t\t%u\n", + le32_to_cpu(general->ttl_timestamp)); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "tx_on_a:", + le32_to_cpu(div->tx_on_a), accum_div->tx_on_a, + delta_div->tx_on_a, max_div->tx_on_a); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "tx_on_b:", + le32_to_cpu(div->tx_on_b), accum_div->tx_on_b, + delta_div->tx_on_b, max_div->tx_on_b); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "exec_time:", + le32_to_cpu(div->exec_time), accum_div->exec_time, + delta_div->exec_time, max_div->exec_time); + pos += + scnprintf(buf + pos, bufsz - pos, + " %-30s %10u %10u %10u %10u\n", "probe_time:", + le32_to_cpu(div->probe_time), accum_div->probe_time, + delta_div->probe_time, max_div->probe_time); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index ffd6ddf89ec1..2249fe44e669 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -102,7 +102,8 @@ struct il_mod_params il3945_mod_params = { * IL_ANTENNA_MAIN - Force MAIN antenna * IL_ANTENNA_AUX - Force AUX antenna */ -__le32 il3945_get_antenna_flags(const struct il_priv *il) +__le32 +il3945_get_antenna_flags(const struct il_priv *il) { struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; @@ -123,14 +124,14 @@ __le32 il3945_get_antenna_flags(const struct il_priv *il) /* bad antenna selector value */ IL_ERR("Bad antenna selector value (0x%x)\n", - il3945_mod_params.antenna); + il3945_mod_params.antenna); return 0; /* "diversity" is default if error */ } -static int il3945_set_ccmp_dynamic_key_info(struct il_priv *il, - struct ieee80211_key_conf *keyconf, - u8 sta_id) +static int +il3945_set_ccmp_dynamic_key_info(struct il_priv *il, + struct ieee80211_key_conf *keyconf, u8 sta_id) { unsigned long flags; __le16 key_flags = 0; @@ -149,21 +150,19 @@ static int il3945_set_ccmp_dynamic_key_info(struct il_priv *il, spin_lock_irqsave(&il->sta_lock, flags); il->stations[sta_id].keyinfo.cipher = keyconf->cipher; il->stations[sta_id].keyinfo.keylen = keyconf->keylen; - memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, - keyconf->keylen); + memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, keyconf->keylen); - memcpy(il->stations[sta_id].sta.key.key, keyconf->key, - keyconf->keylen); + memcpy(il->stations[sta_id].sta.key.key, keyconf->key, keyconf->keylen); - if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) - == STA_KEY_FLG_NO_ENC) + if ((il->stations[sta_id].sta.key. + key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) il->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_idx(il); + il_get_free_ucode_key_idx(il); /* else, we are overriding an existing key => no need to allocated room - * in uCode. */ + * in uCode. */ WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, - "no space for a new key"); + "no space for a new key"); il->stations[sta_id].sta.key.key_flags = key_flags; il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; @@ -171,49 +170,50 @@ static int il3945_set_ccmp_dynamic_key_info(struct il_priv *il, D_INFO("hwcrypto: modify ucode station key info\n"); - ret = il_send_add_sta(il, - &il->stations[sta_id].sta, CMD_ASYNC); + ret = il_send_add_sta(il, &il->stations[sta_id].sta, CMD_ASYNC); spin_unlock_irqrestore(&il->sta_lock, flags); return ret; } -static int il3945_set_tkip_dynamic_key_info(struct il_priv *il, - struct ieee80211_key_conf *keyconf, - u8 sta_id) +static int +il3945_set_tkip_dynamic_key_info(struct il_priv *il, + struct ieee80211_key_conf *keyconf, u8 sta_id) { return -EOPNOTSUPP; } -static int il3945_set_wep_dynamic_key_info(struct il_priv *il, - struct ieee80211_key_conf *keyconf, - u8 sta_id) +static int +il3945_set_wep_dynamic_key_info(struct il_priv *il, + struct ieee80211_key_conf *keyconf, u8 sta_id) { return -EOPNOTSUPP; } -static int il3945_clear_sta_key_info(struct il_priv *il, u8 sta_id) +static int +il3945_clear_sta_key_info(struct il_priv *il, u8 sta_id) { unsigned long flags; struct il_addsta_cmd sta_cmd; spin_lock_irqsave(&il->sta_lock, flags); memset(&il->stations[sta_id].keyinfo, 0, sizeof(struct il_hw_key)); - memset(&il->stations[sta_id].sta.key, 0, - sizeof(struct il4965_keyinfo)); + memset(&il->stations[sta_id].sta.key, 0, sizeof(struct il4965_keyinfo)); il->stations[sta_id].sta.key.key_flags = STA_KEY_FLG_NO_ENC; il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - memcpy(&sta_cmd, &il->stations[sta_id].sta, sizeof(struct il_addsta_cmd)); + memcpy(&sta_cmd, &il->stations[sta_id].sta, + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&il->sta_lock, flags); D_INFO("hwcrypto: clear ucode station key info\n"); return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } -static int il3945_set_dynamic_key(struct il_priv *il, - struct ieee80211_key_conf *keyconf, u8 sta_id) +static int +il3945_set_dynamic_key(struct il_priv *il, struct ieee80211_key_conf *keyconf, + u8 sta_id) { int ret = 0; @@ -231,27 +231,26 @@ static int il3945_set_dynamic_key(struct il_priv *il, ret = il3945_set_wep_dynamic_key_info(il, keyconf, sta_id); break; default: - IL_ERR("Unknown alg: %s alg=%x\n", __func__, - keyconf->cipher); + IL_ERR("Unknown alg: %s alg=%x\n", __func__, keyconf->cipher); ret = -EINVAL; } D_WEP("Set dynamic key: alg=%x len=%d idx=%d sta=%d ret=%d\n", - keyconf->cipher, keyconf->keylen, keyconf->keyidx, - sta_id, ret); + keyconf->cipher, keyconf->keylen, keyconf->keyidx, sta_id, ret); return ret; } -static int il3945_remove_static_key(struct il_priv *il) +static int +il3945_remove_static_key(struct il_priv *il) { int ret = -EOPNOTSUPP; return ret; } -static int il3945_set_static_key(struct il_priv *il, - struct ieee80211_key_conf *key) +static int +il3945_set_static_key(struct il_priv *il, struct ieee80211_key_conf *key) { if (key->cipher == WLAN_CIPHER_SUITE_WEP40 || key->cipher == WLAN_CIPHER_SUITE_WEP104) @@ -261,12 +260,12 @@ static int il3945_set_static_key(struct il_priv *il, return -EINVAL; } -static void il3945_clear_free_frames(struct il_priv *il) +static void +il3945_clear_free_frames(struct il_priv *il) { struct list_head *element; - D_INFO("%d frames on pre-allocated heap on clear.\n", - il->frames_count); + D_INFO("%d frames on pre-allocated heap on clear.\n", il->frames_count); while (!list_empty(&il->free_frames)) { element = il->free_frames.next; @@ -277,12 +276,13 @@ static void il3945_clear_free_frames(struct il_priv *il) if (il->frames_count) { IL_WARN("%d frames still in use. Did we lose one?\n", - il->frames_count); + il->frames_count); il->frames_count = 0; } } -static struct il3945_frame *il3945_get_free_frame(struct il_priv *il) +static struct il3945_frame * +il3945_get_free_frame(struct il_priv *il) { struct il3945_frame *frame; struct list_head *element; @@ -302,15 +302,16 @@ static struct il3945_frame *il3945_get_free_frame(struct il_priv *il) return list_entry(element, struct il3945_frame, list); } -static void il3945_free_frame(struct il_priv *il, struct il3945_frame *frame) +static void +il3945_free_frame(struct il_priv *il, struct il3945_frame *frame) { memset(frame, 0, sizeof(*frame)); list_add(&frame->list, &il->free_frames); } -unsigned int il3945_fill_beacon_frame(struct il_priv *il, - struct ieee80211_hdr *hdr, - int left) +unsigned int +il3945_fill_beacon_frame(struct il_priv *il, struct ieee80211_hdr *hdr, + int left) { if (!il_is_associated(il) || !il->beacon_skb) @@ -324,7 +325,8 @@ unsigned int il3945_fill_beacon_frame(struct il_priv *il, return il->beacon_skb->len; } -static int il3945_send_beacon_cmd(struct il_priv *il) +static int +il3945_send_beacon_cmd(struct il_priv *il) { struct il3945_frame *frame; unsigned int frame_size; @@ -335,37 +337,34 @@ static int il3945_send_beacon_cmd(struct il_priv *il) if (!frame) { IL_ERR("Could not obtain free frame buffer for beacon " - "command.\n"); + "command.\n"); return -ENOMEM; } - rate = il_get_lowest_plcp(il, - &il->ctx); + rate = il_get_lowest_plcp(il, &il->ctx); frame_size = il3945_hw_get_beacon_cmd(il, frame, rate); - rc = il_send_cmd_pdu(il, C_TX_BEACON, frame_size, - &frame->u.cmd[0]); + rc = il_send_cmd_pdu(il, C_TX_BEACON, frame_size, &frame->u.cmd[0]); il3945_free_frame(il, frame); return rc; } -static void il3945_unset_hw_params(struct il_priv *il) +static void +il3945_unset_hw_params(struct il_priv *il) { if (il->_3945.shared_virt) dma_free_coherent(&il->pci_dev->dev, sizeof(struct il3945_shared), - il->_3945.shared_virt, - il->_3945.shared_phys); + il->_3945.shared_virt, il->_3945.shared_phys); } -static void il3945_build_tx_cmd_hwcrypto(struct il_priv *il, - struct ieee80211_tx_info *info, - struct il_device_cmd *cmd, - struct sk_buff *skb_frag, - int sta_id) +static void +il3945_build_tx_cmd_hwcrypto(struct il_priv *il, struct ieee80211_tx_info *info, + struct il_device_cmd *cmd, + struct sk_buff *skb_frag, int sta_id) { struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; struct il_hw_key *keyinfo = &il->stations[sta_id].keyinfo; @@ -386,13 +385,15 @@ static void il3945_build_tx_cmd_hwcrypto(struct il_priv *il, tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128; /* fall through */ case WLAN_CIPHER_SUITE_WEP40: - tx_cmd->sec_ctl |= TX_CMD_SEC_WEP | - (info->control.hw_key->hw_key_idx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT; + tx_cmd->sec_ctl |= + TX_CMD_SEC_WEP | (info->control.hw_key-> + hw_key_idx & TX_CMD_SEC_MSK) << + TX_CMD_SEC_SHIFT; memcpy(&tx_cmd->key[3], keyinfo->key, keyinfo->keylen); - D_TX("Configuring packet for WEP encryption " - "with key %d\n", info->control.hw_key->hw_key_idx); + D_TX("Configuring packet for WEP encryption " "with key %d\n", + info->control.hw_key->hw_key_idx); break; default: @@ -404,10 +405,10 @@ static void il3945_build_tx_cmd_hwcrypto(struct il_priv *il, /* * handle build C_TX command notification. */ -static void il3945_build_tx_cmd_basic(struct il_priv *il, - struct il_device_cmd *cmd, - struct ieee80211_tx_info *info, - struct ieee80211_hdr *hdr, u8 std_id) +static void +il3945_build_tx_cmd_basic(struct il_priv *il, struct il_device_cmd *cmd, + struct ieee80211_tx_info *info, + struct ieee80211_hdr *hdr, u8 std_id) { struct il3945_tx_cmd *tx_cmd = (struct il3945_tx_cmd *)cmd->cmd.payload; __le32 tx_flags = tx_cmd->tx_flags; @@ -458,7 +459,8 @@ static void il3945_build_tx_cmd_basic(struct il_priv *il, /* * start C_TX command process */ -static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) +static int +il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); @@ -485,7 +487,8 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) goto drop_unlock; } - if ((ieee80211_get_tx_rate(il->hw, info)->hw_value & 0xFF) == IL_INVALID_RATE) { + if ((ieee80211_get_tx_rate(il->hw, info)->hw_value & 0xFF) == + IL_INVALID_RATE) { IL_ERR("ERROR: No TX rate available.\n"); goto drop_unlock; } @@ -509,12 +512,9 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) hdr_len = ieee80211_hdrlen(fc); /* Find idx into station table for destination station */ - sta_id = il_sta_id_or_broadcast( - il, &il->ctx, - info->control.sta); + sta_id = il_sta_id_or_broadcast(il, &il->ctx, info->control.sta); if (sta_id == IL_INVALID_STATION) { - D_DROP("Dropping - INVALID STATION: %pM\n", - hdr->addr1); + D_DROP("Dropping - INVALID STATION: %pM\n", hdr->addr1); goto drop; } @@ -557,13 +557,13 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) * locate the frame within the tx queue and do post-tx processing. */ out_cmd->hdr.cmd = C_TX; - out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | - IDX_TO_SEQ(q->write_ptr))); + out_cmd->hdr.sequence = + cpu_to_le16((u16) + (QUEUE_TO_SEQ(txq_id) | IDX_TO_SEQ(q->write_ptr))); /* Copy MAC header from skb into command buffer */ memcpy(tx_cmd->hdr, hdr, hdr_len); - if (info->control.hw_key) il3945_build_tx_cmd_hwcrypto(il, info, out_cmd, skb, sta_id); @@ -574,7 +574,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) il3945_hw_build_tx_cmd_rate(il, out_cmd, info, hdr, sta_id, 0); /* Total # bytes to be transmitted */ - len = (u16)skb->len; + len = (u16) skb->len; tx_cmd->len = cpu_to_le16(len); il_dbg_log_tx_data_frame(il, len, hdr); @@ -589,12 +589,11 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) txq->need_update = 0; } - D_TX("sequence nr = 0X%x\n", - le16_to_cpu(out_cmd->hdr.sequence)); + D_TX("sequence nr = 0X%x\n", le16_to_cpu(out_cmd->hdr.sequence)); D_TX("tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); il_print_hex_dump(il, IL_DL_TX, tx_cmd, sizeof(*tx_cmd)); - il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd->hdr, - ieee80211_hdrlen(fc)); + il_print_hex_dump(il, IL_DL_TX, (u8 *) tx_cmd->hdr, + ieee80211_hdrlen(fc)); /* * Use the first empty entry in this queue's command buffer array @@ -605,14 +604,15 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) * of the MAC header (device reads on dword boundaries). * We'll tell device about this padding later. */ - len = sizeof(struct il3945_tx_cmd) + - sizeof(struct il_cmd_header) + hdr_len; + len = + sizeof(struct il3945_tx_cmd) + sizeof(struct il_cmd_header) + + hdr_len; len = (len + 3) & ~3; /* Physical address of this Tx command's header (not MAC header!), * within command buffer array. */ - txcmd_phys = pci_map_single(il->pci_dev, &out_cmd->hdr, - len, PCI_DMA_TODEVICE); + txcmd_phys = + pci_map_single(il->pci_dev, &out_cmd->hdr, len, PCI_DMA_TODEVICE); /* we do not map meta data ... so we can safely access address to * provide to unmap command*/ dma_unmap_addr_set(out_meta, mapping, txcmd_phys); @@ -620,29 +620,26 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb) /* Add buffer containing Tx command and MAC(!) header to TFD's * first entry */ - il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, - txcmd_phys, len, 1, 0); - + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, txcmd_phys, len, 1, + 0); /* Set up TFD's 2nd entry to point directly to remainder of skb, * if any (802.11 null frames have no payload). */ len = skb->len - hdr_len; if (len) { - phys_addr = pci_map_single(il->pci_dev, skb->data + hdr_len, - len, PCI_DMA_TODEVICE); - il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, - phys_addr, len, - 0, U32_PAD(len)); + phys_addr = + pci_map_single(il->pci_dev, skb->data + hdr_len, len, + PCI_DMA_TODEVICE); + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr, + len, 0, U32_PAD(len)); } - /* Tell device the write idx *just past* this latest filled TFD */ q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); il_txq_update_write_ptr(il, txq); spin_unlock_irqrestore(&il->lock, flags); - if (il_queue_space(q) < q->high_mark - && il->mac80211_registered) { + if (il_queue_space(q) < q->high_mark && il->mac80211_registered) { if (wait_write_ptr) { spin_lock_irqsave(&il->lock, flags); txq->need_update = 1; @@ -661,9 +658,9 @@ drop: return -1; } -static int il3945_get_measurement(struct il_priv *il, - struct ieee80211_measurement_params *params, - u8 type) +static int +il3945_get_measurement(struct il_priv *il, + struct ieee80211_measurement_params *params, u8 type) { struct il_spectrum_cmd spectrum; struct il_rx_pkt *pkt; @@ -679,9 +676,12 @@ static int il3945_get_measurement(struct il_priv *il, struct il_rxon_context *ctx = &il->ctx; if (il_is_associated(il)) - add_time = il_usecs_to_beacons(il, - le64_to_cpu(params->start_time) - il->_3945.last_tsf, - le16_to_cpu(ctx->timing.beacon_interval)); + add_time = + il_usecs_to_beacons(il, + le64_to_cpu(params->start_time) - + il->_3945.last_tsf, + le16_to_cpu(ctx->timing. + beacon_interval)); memset(&spectrum, 0, sizeof(spectrum)); @@ -694,9 +694,9 @@ static int il3945_get_measurement(struct il_priv *il, if (il_is_associated(il)) spectrum.start_time = - il_add_beacon_time(il, - il->_3945.last_beacon_time, add_time, - le16_to_cpu(ctx->timing.beacon_interval)); + il_add_beacon_time(il, il->_3945.last_beacon_time, add_time, + le16_to_cpu(ctx->timing. + beacon_interval)); else spectrum.start_time = 0; @@ -704,8 +704,9 @@ static int il3945_get_measurement(struct il_priv *il, spectrum.channels[0].channel = params->channel; spectrum.channels[0].type = type; if (ctx->active.flags & RXON_FLG_BAND_24G_MSK) - spectrum.flags |= RXON_FLG_BAND_24G_MSK | - RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_TGG_PROTECT_MSK; + spectrum.flags |= + RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK | + RXON_FLG_TGG_PROTECT_MSK; rc = il_send_cmd_sync(il, &cmd); if (rc) @@ -722,7 +723,7 @@ static int il3945_get_measurement(struct il_priv *il, case 0: /* Command will be handled */ if (pkt->u.spectrum.id != 0xff) { D_INFO("Replaced existing measurement: %d\n", - pkt->u.spectrum.id); + pkt->u.spectrum.id); il->measurement_status &= ~MEASUREMENT_READY; } il->measurement_status |= MEASUREMENT_ACTIVE; @@ -739,8 +740,8 @@ static int il3945_get_measurement(struct il_priv *il, return rc; } -static void il3945_hdl_alive(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il3945_hdl_alive(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_alive_resp *palive; @@ -748,10 +749,8 @@ static void il3945_hdl_alive(struct il_priv *il, palive = &pkt->u.alive_frame; - D_INFO("Alive ucode status 0x%08X revision " - "0x%01X 0x%01X\n", - palive->is_valid, palive->ver_type, - palive->ver_subtype); + D_INFO("Alive ucode status 0x%08X revision " "0x%01X 0x%01X\n", + palive->is_valid, palive->ver_type, palive->ver_subtype); if (palive->ver_subtype == INITIALIZE_SUBTYPE) { D_INFO("Initialization Alive received.\n"); @@ -769,14 +768,13 @@ static void il3945_hdl_alive(struct il_priv *il, /* We delay the ALIVE response by 5ms to * give the HW RF Kill time to activate... */ if (palive->is_valid == UCODE_VALID_OK) - queue_delayed_work(il->workqueue, pwork, - msecs_to_jiffies(5)); + queue_delayed_work(il->workqueue, pwork, msecs_to_jiffies(5)); else IL_WARN("uCode did not respond OK.\n"); } -static void il3945_hdl_add_sta(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il3945_hdl_add_sta(struct il_priv *il, struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -785,21 +783,19 @@ static void il3945_hdl_add_sta(struct il_priv *il, D_RX("Received C_ADD_STA: 0x%02X\n", pkt->u.status); } -static void il3945_hdl_beacon(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il3945_hdl_beacon(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il3945_beacon_notif *beacon = &(pkt->u.beacon_status); #ifdef CONFIG_IWLEGACY_DEBUG u8 rate = beacon->beacon_notify_hdr.rate; - D_RX("beacon status %x retries %d iss %d " - "tsf %d %d rate %d\n", - le32_to_cpu(beacon->beacon_notify_hdr.status) & TX_STATUS_MSK, - beacon->beacon_notify_hdr.failure_frame, - le32_to_cpu(beacon->ibss_mgr_status), - le32_to_cpu(beacon->high_tsf), - le32_to_cpu(beacon->low_tsf), rate); + D_RX("beacon status %x retries %d iss %d " "tsf %d %d rate %d\n", + le32_to_cpu(beacon->beacon_notify_hdr.status) & TX_STATUS_MSK, + beacon->beacon_notify_hdr.failure_frame, + le32_to_cpu(beacon->ibss_mgr_status), + le32_to_cpu(beacon->high_tsf), le32_to_cpu(beacon->low_tsf), rate); #endif il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); @@ -808,32 +804,30 @@ static void il3945_hdl_beacon(struct il_priv *il, /* Handle notification from uCode that card's power state is changing * due to software, hardware, or critical temperature RFKILL */ -static void il3945_hdl_card_state(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il3945_hdl_card_state(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); unsigned long status = il->status; IL_WARN("Card state received: HW:%s SW:%s\n", - (flags & HW_CARD_DISABLED) ? "Kill" : "On", - (flags & SW_CARD_DISABLED) ? "Kill" : "On"); + (flags & HW_CARD_DISABLED) ? "Kill" : "On", + (flags & SW_CARD_DISABLED) ? "Kill" : "On"); - _il_wr(il, CSR_UCODE_DRV_GP1_SET, - CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); + _il_wr(il, CSR_UCODE_DRV_GP1_SET, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); if (flags & HW_CARD_DISABLED) set_bit(S_RF_KILL_HW, &il->status); else clear_bit(S_RF_KILL_HW, &il->status); - il_scan_cancel(il); if ((test_bit(S_RF_KILL_HW, &status) != test_bit(S_RF_KILL_HW, &il->status))) wiphy_rfkill_set_hw_state(il->hw->wiphy, - test_bit(S_RF_KILL_HW, &il->status)); + test_bit(S_RF_KILL_HW, &il->status)); else wake_up(&il->wait_command_queue); } @@ -847,17 +841,16 @@ static void il3945_hdl_card_state(struct il_priv *il, * This function chains into the hardware specific files for them to setup * any hardware specific handlers as well. */ -static void il3945_setup_handlers(struct il_priv *il) +static void +il3945_setup_handlers(struct il_priv *il) { il->handlers[N_ALIVE] = il3945_hdl_alive; il->handlers[C_ADD_STA] = il3945_hdl_add_sta; il->handlers[N_ERROR] = il_hdl_error; il->handlers[N_CHANNEL_SWITCH] = il_hdl_csa; - il->handlers[N_SPECTRUM_MEASUREMENT] = - il_hdl_spectrum_measurement; + il->handlers[N_SPECTRUM_MEASUREMENT] = il_hdl_spectrum_measurement; il->handlers[N_PM_SLEEP] = il_hdl_pm_sleep; - il->handlers[N_PM_DEBUG_STATS] = - il_hdl_pm_debug_stats; + il->handlers[N_PM_DEBUG_STATS] = il_hdl_pm_debug_stats; il->handlers[N_BEACON] = il3945_hdl_beacon; /* @@ -942,10 +935,10 @@ static void il3945_setup_handlers(struct il_priv *il) /** * il3945_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr */ -static inline __le32 il3945_dma_addr2rbd_ptr(struct il_priv *il, - dma_addr_t dma_addr) +static inline __le32 +il3945_dma_addr2rbd_ptr(struct il_priv *il, dma_addr_t dma_addr) { - return cpu_to_le32((u32)dma_addr); + return cpu_to_le32((u32) dma_addr); } /** @@ -959,7 +952,8 @@ static inline __le32 il3945_dma_addr2rbd_ptr(struct il_priv *il, * also updates the memory address in the firmware to reference the new * target buffer. */ -static void il3945_rx_queue_restock(struct il_priv *il) +static void +il3945_rx_queue_restock(struct il_priv *il) { struct il_rx_queue *rxq = &il->rxq; struct list_head *element; @@ -976,7 +970,8 @@ static void il3945_rx_queue_restock(struct il_priv *il) list_del(element); /* Point to Rx buffer via next RBD in circular buffer */ - rxq->bd[rxq->write] = il3945_dma_addr2rbd_ptr(il, rxb->page_dma); + rxq->bd[rxq->write] = + il3945_dma_addr2rbd_ptr(il, rxb->page_dma); rxq->queue[rxq->write] = rxb; rxq->write = (rxq->write + 1) & RX_QUEUE_MASK; rxq->free_count--; @@ -987,7 +982,6 @@ static void il3945_rx_queue_restock(struct il_priv *il) if (rxq->free_count <= RX_LOW_WATERMARK) queue_work(il->workqueue, &il->rx_replenish); - /* If we've added more space for the firmware to place data, tell it. * Increment device's write pointer in multiples of 8. */ if (rxq->write_actual != (rxq->write & ~0x7) || @@ -1007,7 +1001,8 @@ static void il3945_rx_queue_restock(struct il_priv *il) * Also restock the Rx queue via il3945_rx_queue_restock. * This is called as a scheduled work item (except for during initialization) */ -static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) +static void +il3945_rx_allocate(struct il_priv *il, gfp_t priority) { struct il_rx_queue *rxq = &il->rxq; struct list_head *element; @@ -1038,9 +1033,11 @@ static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) D_INFO("Failed to allocate SKB buffer.\n"); if (rxq->free_count <= RX_LOW_WATERMARK && net_ratelimit()) - IL_ERR("Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", - priority == GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL", - rxq->free_count); + IL_ERR + ("Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", + priority == + GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL", + rxq->free_count); /* We don't reschedule replenish work here -- we will * call the restock method and if it still needs * more buffers it will schedule replenish */ @@ -1060,9 +1057,10 @@ static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) rxb->page = page; /* Get physical address of RB/SKB */ - rxb->page_dma = pci_map_page(il->pci_dev, page, 0, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); + rxb->page_dma = + pci_map_page(il->pci_dev, page, 0, + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); spin_lock_irqsave(&rxq->lock, flags); @@ -1074,7 +1072,8 @@ static void il3945_rx_allocate(struct il_priv *il, gfp_t priority) } } -void il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) +void +il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) { unsigned long flags; int i; @@ -1087,8 +1086,8 @@ void il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) * to an SKB, so we need to unmap and free potential storage */ if (rxq->pool[i].page != NULL) { pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); __il_free_pages(il, rxq->pool[i].page); rxq->pool[i].page = NULL; } @@ -1103,7 +1102,8 @@ void il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) spin_unlock_irqrestore(&rxq->lock, flags); } -void il3945_rx_replenish(void *data) +void +il3945_rx_replenish(void *data) { struct il_priv *il = data; unsigned long flags; @@ -1115,27 +1115,28 @@ void il3945_rx_replenish(void *data) spin_unlock_irqrestore(&il->lock, flags); } -static void il3945_rx_replenish_now(struct il_priv *il) +static void +il3945_rx_replenish_now(struct il_priv *il) { il3945_rx_allocate(il, GFP_ATOMIC); il3945_rx_queue_restock(il); } - /* Assumes that the skb field of the buffers in 'pool' is kept accurate. * If an SKB has been detached, the POOL needs to have its SKB set to NULL * This free routine walks the list of POOL entries and if SKB is set to * non NULL it is unmapped and freed */ -static void il3945_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq) +static void +il3945_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq) { int i; for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { if (rxq->pool[i].page != NULL) { pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); __il_free_pages(il, rxq->pool[i].page); rxq->pool[i].page = NULL; } @@ -1146,29 +1147,29 @@ static void il3945_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq) dma_free_coherent(&il->pci_dev->dev, sizeof(struct il_rb_status), rxq->rb_stts, rxq->rb_stts_dma); rxq->bd = NULL; - rxq->rb_stts = NULL; + rxq->rb_stts = NULL; } - /* Convert linear signal-to-noise ratio into dB */ static u8 ratio2dB[100] = { /* 0 1 2 3 4 5 6 7 8 9 */ - 0, 0, 6, 10, 12, 14, 16, 17, 18, 19, /* 00 - 09 */ - 20, 21, 22, 22, 23, 23, 24, 25, 26, 26, /* 10 - 19 */ - 26, 26, 26, 27, 27, 28, 28, 28, 29, 29, /* 20 - 29 */ - 29, 30, 30, 30, 31, 31, 31, 31, 32, 32, /* 30 - 39 */ - 32, 32, 32, 33, 33, 33, 33, 33, 34, 34, /* 40 - 49 */ - 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, /* 50 - 59 */ - 36, 36, 36, 36, 36, 36, 36, 37, 37, 37, /* 60 - 69 */ - 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, /* 70 - 79 */ - 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, /* 80 - 89 */ - 39, 39, 39, 39, 39, 40, 40, 40, 40, 40 /* 90 - 99 */ + 0, 0, 6, 10, 12, 14, 16, 17, 18, 19, /* 00 - 09 */ + 20, 21, 22, 22, 23, 23, 24, 25, 26, 26, /* 10 - 19 */ + 26, 26, 26, 27, 27, 28, 28, 28, 29, 29, /* 20 - 29 */ + 29, 30, 30, 30, 31, 31, 31, 31, 32, 32, /* 30 - 39 */ + 32, 32, 32, 33, 33, 33, 33, 33, 34, 34, /* 40 - 49 */ + 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, /* 50 - 59 */ + 36, 36, 36, 36, 36, 36, 36, 37, 37, 37, /* 60 - 69 */ + 37, 37, 37, 37, 37, 38, 38, 38, 38, 38, /* 70 - 79 */ + 38, 38, 38, 38, 38, 39, 39, 39, 39, 39, /* 80 - 89 */ + 39, 39, 39, 39, 39, 40, 40, 40, 40, 40 /* 90 - 99 */ }; /* Calculates a relative dB value from a ratio of linear * (i.e. not dB) signal levels. * Conversion assumes that levels are voltages (20*log), not powers (10*log). */ -int il3945_calc_db_from_ratio(int sig_ratio) +int +il3945_calc_db_from_ratio(int sig_ratio) { /* 1000:1 or higher just report as 60 dB */ if (sig_ratio >= 1000) @@ -1177,7 +1178,7 @@ int il3945_calc_db_from_ratio(int sig_ratio) /* 100:1 or higher, divide by 10 and use table, * add 20 dB to make up for divide by 10 */ if (sig_ratio >= 100) - return 20 + (int)ratio2dB[sig_ratio/10]; + return 20 + (int)ratio2dB[sig_ratio / 10]; /* We shouldn't see this */ if (sig_ratio < 1) @@ -1194,7 +1195,8 @@ int il3945_calc_db_from_ratio(int sig_ratio) * the appropriate handlers, including command responses, * frame-received notifications, and other notifications. */ -static void il3945_rx_handle(struct il_priv *il) +static void +il3945_rx_handle(struct il_priv *il) { struct il_rx_buf *rxb; struct il_rx_pkt *pkt; @@ -1208,7 +1210,7 @@ static void il3945_rx_handle(struct il_priv *il) /* uCode's read idx (stored in shared DRAM) indicates the last Rx * buffer that the driver may process (last buffer filled by ucode). */ - r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF; + r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF; i = rxq->read; /* calculate total frames need to be restock after handling RX */ @@ -1240,7 +1242,7 @@ static void il3945_rx_handle(struct il_priv *il) pkt = rxb_addr(rxb); len = le32_to_cpu(pkt->len_n_flags) & IL_RX_FRAME_SIZE_MSK; - len += sizeof(u32); /* account for status word */ + len += sizeof(u32); /* account for status word */ /* Reclaim a command buffer only if this packet is a response * to a (driver-originated) command. @@ -1249,23 +1251,20 @@ static void il3945_rx_handle(struct il_priv *il) * Ucode should set SEQ_RX_FRAME bit if ucode-originated, * but apparently a few don't get set; catch them here. */ reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) && - pkt->hdr.cmd != N_STATS && - pkt->hdr.cmd != C_TX; + pkt->hdr.cmd != N_STATS && pkt->hdr.cmd != C_TX; /* Based on type of command response or notification, * handle those that need handling via function in * handlers table. See il3945_setup_handlers() */ if (il->handlers[pkt->hdr.cmd]) { D_RX("r = %d, i = %d, %s, 0x%02x\n", r, i, - il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); + il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); il->isr_stats.handlers[pkt->hdr.cmd]++; il->handlers[pkt->hdr.cmd] (il, rxb); } else { /* No handling needed */ - D_RX( - "r %d i %d No handler needed for %s, 0x%02x\n", - r, i, il_get_cmd_string(pkt->hdr.cmd), - pkt->hdr.cmd); + D_RX("r %d i %d No handler needed for %s, 0x%02x\n", r, + i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); } /* @@ -1290,9 +1289,10 @@ static void il3945_rx_handle(struct il_priv *il) * rx_free list for reuse later. */ spin_lock_irqsave(&rxq->lock, flags); if (rxb->page != NULL) { - rxb->page_dma = pci_map_page(il->pci_dev, rxb->page, - 0, PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); + rxb->page_dma = + pci_map_page(il->pci_dev, rxb->page, 0, + PAGE_SIZE << il->hw_params. + rx_page_order, PCI_DMA_FROMDEVICE); list_add_tail(&rxb->list, &rxq->rx_free); rxq->free_count++; } else @@ -1322,14 +1322,16 @@ static void il3945_rx_handle(struct il_priv *il) } /* call this function to flush any scheduled tasklet */ -static inline void il3945_synchronize_irq(struct il_priv *il) +static inline void +il3945_synchronize_irq(struct il_priv *il) { - /* wait to make sure we flush pending tasklet*/ + /* wait to make sure we flush pending tasklet */ synchronize_irq(il->pci_dev->irq); tasklet_kill(&il->irq_tasklet); } -static const char *il3945_desc_lookup(int i) +static const char * +il3945_desc_lookup(int i) { switch (i) { case 1: @@ -1352,7 +1354,8 @@ static const char *il3945_desc_lookup(int i) #define ERROR_START_OFFSET (1 * sizeof(u32)) #define ERROR_ELEM_SIZE (7 * sizeof(u32)) -void il3945_dump_nic_error_log(struct il_priv *il) +void +il3945_dump_nic_error_log(struct il_priv *il) { u32 i; u32 desc, time, count, base, data1; @@ -1365,42 +1368,34 @@ void il3945_dump_nic_error_log(struct il_priv *il) return; } - count = il_read_targ_mem(il, base); if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { IL_ERR("Start IWL Error Log Dump:\n"); - IL_ERR("Status: 0x%08lX, count: %d\n", - il->status, count); + IL_ERR("Status: 0x%08lX, count: %d\n", il->status, count); } IL_ERR("Desc Time asrtPC blink2 " - "ilink1 nmiPC Line\n"); + "ilink1 nmiPC Line\n"); for (i = ERROR_START_OFFSET; i < (count * ERROR_ELEM_SIZE) + ERROR_START_OFFSET; i += ERROR_ELEM_SIZE) { desc = il_read_targ_mem(il, base + i); - time = - il_read_targ_mem(il, base + i + 1 * sizeof(u32)); - blink1 = - il_read_targ_mem(il, base + i + 2 * sizeof(u32)); - blink2 = - il_read_targ_mem(il, base + i + 3 * sizeof(u32)); - ilink1 = - il_read_targ_mem(il, base + i + 4 * sizeof(u32)); - ilink2 = - il_read_targ_mem(il, base + i + 5 * sizeof(u32)); - data1 = - il_read_targ_mem(il, base + i + 6 * sizeof(u32)); + time = il_read_targ_mem(il, base + i + 1 * sizeof(u32)); + blink1 = il_read_targ_mem(il, base + i + 2 * sizeof(u32)); + blink2 = il_read_targ_mem(il, base + i + 3 * sizeof(u32)); + ilink1 = il_read_targ_mem(il, base + i + 4 * sizeof(u32)); + ilink2 = il_read_targ_mem(il, base + i + 5 * sizeof(u32)); + data1 = il_read_targ_mem(il, base + i + 6 * sizeof(u32)); - IL_ERR( - "%-13s (0x%X) %010u 0x%05X 0x%05X 0x%05X 0x%05X %u\n\n", - il3945_desc_lookup(desc), desc, time, blink1, blink2, - ilink1, ilink2, data1); + IL_ERR("%-13s (0x%X) %010u 0x%05X 0x%05X 0x%05X 0x%05X %u\n\n", + il3945_desc_lookup(desc), desc, time, blink1, blink2, + ilink1, ilink2, data1); } } -static void il3945_irq_tasklet(struct il_priv *il) +static void +il3945_irq_tasklet(struct il_priv *il) { u32 inta, handled = 0; u32 inta_fh; @@ -1427,8 +1422,8 @@ static void il3945_irq_tasklet(struct il_priv *il) if (il_get_debug_level(il) & IL_DL_ISR) { /* just for debug */ inta_mask = _il_rd(il, CSR_INT_MASK); - D_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", - inta, inta_mask, inta_fh); + D_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, + inta_mask, inta_fh); } #endif @@ -1457,13 +1452,12 @@ static void il3945_irq_tasklet(struct il_priv *il) return; } - #ifdef CONFIG_IWLEGACY_DEBUG if (il_get_debug_level(il) & (IL_DL_ISR)) { /* NIC fires this, but we don't use it, redundant with WAKEUP */ if (inta & CSR_INT_BIT_SCD) { D_ISR("Scheduler finished to transmit " - "the frame/frames.\n"); + "the frame/frames.\n"); il->isr_stats.sch++; } @@ -1479,8 +1473,8 @@ static void il3945_irq_tasklet(struct il_priv *il) /* Error detected by uCode */ if (inta & CSR_INT_BIT_SW_ERR) { - IL_ERR("Microcode SW error detected. " - "Restarting 0x%X.\n", inta); + IL_ERR("Microcode SW error detected. " "Restarting 0x%X.\n", + inta); il->isr_stats.sw++; il_irq_handle_error(il); handled |= CSR_INT_BIT_SW_ERR; @@ -1515,8 +1509,7 @@ static void il3945_irq_tasklet(struct il_priv *il) il->isr_stats.tx++; _il_wr(il, CSR_FH_INT_STATUS, (1 << 6)); - il_wr(il, FH39_TCSR_CREDIT - (FH39_SRVC_CHNL), 0x0); + il_wr(il, FH39_TCSR_CREDIT(FH39_SRVC_CHNL), 0x0); handled |= CSR_INT_BIT_FH_TX; } @@ -1527,7 +1520,7 @@ static void il3945_irq_tasklet(struct il_priv *il) if (inta & ~il->inta_mask) { IL_WARN("Disabled INTA bits 0x%08x were pending\n", - inta & ~il->inta_mask); + inta & ~il->inta_mask); IL_WARN(" with inta_fh = 0x%08x\n", inta_fh); } @@ -1542,16 +1535,16 @@ static void il3945_irq_tasklet(struct il_priv *il) inta_mask = _il_rd(il, CSR_INT_MASK); inta_fh = _il_rd(il, CSR_FH_INT_STATUS); D_ISR("End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " - "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); + "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); } #endif } -static int il3945_get_channels_for_scan(struct il_priv *il, - enum ieee80211_band band, - u8 is_active, u8 n_probes, - struct il3945_scan_channel *scan_ch, - struct ieee80211_vif *vif) +static int +il3945_get_channels_for_scan(struct il_priv *il, enum ieee80211_band band, + u8 is_active, u8 n_probes, + struct il3945_scan_channel *scan_ch, + struct ieee80211_vif *vif) { struct ieee80211_channel *chan; const struct ieee80211_supported_band *sband; @@ -1578,11 +1571,9 @@ static int il3945_get_channels_for_scan(struct il_priv *il, scan_ch->channel = chan->hw_value; - ch_info = il_get_channel_info(il, band, - scan_ch->channel); + ch_info = il_get_channel_info(il, band, scan_ch->channel); if (!il_is_channel_valid(ch_info)) { - D_SCAN( - "Channel %d is INVALID for this band.\n", + D_SCAN("Channel %d is INVALID for this band.\n", scan_ch->channel); continue; } @@ -1596,7 +1587,8 @@ static int il3945_get_channels_for_scan(struct il_priv *il, (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)) { scan_ch->type = 0; /* passive */ if (IL_UCODE_API(il->ucode_ver) == 1) - scan_ch->active_dwell = cpu_to_le16(passive_dwell - 1); + scan_ch->active_dwell = + cpu_to_le16(passive_dwell - 1); } else { scan_ch->type = 1; /* active */ } @@ -1630,11 +1622,9 @@ static int il3945_get_channels_for_scan(struct il_priv *il, */ } - D_SCAN("Scanning %d [%s %d]\n", - scan_ch->channel, - (scan_ch->type & 1) ? "ACTIVE" : "PASSIVE", - (scan_ch->type & 1) ? - active_dwell : passive_dwell); + D_SCAN("Scanning %d [%s %d]\n", scan_ch->channel, + (scan_ch->type & 1) ? "ACTIVE" : "PASSIVE", + (scan_ch->type & 1) ? active_dwell : passive_dwell); scan_ch++; added++; @@ -1644,22 +1634,23 @@ static int il3945_get_channels_for_scan(struct il_priv *il, return added; } -static void il3945_init_hw_rates(struct il_priv *il, - struct ieee80211_rate *rates) +static void +il3945_init_hw_rates(struct il_priv *il, struct ieee80211_rate *rates) { int i; for (i = 0; i < RATE_COUNT_LEGACY; i++) { rates[i].bitrate = il3945_rates[i].ieee * 5; - rates[i].hw_value = i; /* Rate scaling will work on idxes */ + rates[i].hw_value = i; /* Rate scaling will work on idxes */ rates[i].hw_value_short = i; rates[i].flags = 0; if (i > IL39_LAST_OFDM_RATE || i < IL_FIRST_OFDM_RATE) { /* * If CCK != 1M then set short preamble rate flag. */ - rates[i].flags |= (il3945_rates[i].plcp == 10) ? - 0 : IEEE80211_RATE_SHORT_PREAMBLE; + rates[i].flags |= + (il3945_rates[i].plcp == + 10) ? 0 : IEEE80211_RATE_SHORT_PREAMBLE; } } } @@ -1670,7 +1661,8 @@ static void il3945_init_hw_rates(struct il_priv *il, * ******************************************************************************/ -static void il3945_dealloc_ucode_pci(struct il_priv *il) +static void +il3945_dealloc_ucode_pci(struct il_priv *il) { il_free_fw_desc(il->pci_dev, &il->ucode_code); il_free_fw_desc(il->pci_dev, &il->ucode_data); @@ -1684,7 +1676,8 @@ static void il3945_dealloc_ucode_pci(struct il_priv *il) * il3945_verify_inst_full - verify runtime uCode image in card vs. host, * looking at all data. */ -static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) +static int +il3945_verify_inst_full(struct il_priv *il, __le32 * image, u32 len) { u32 val; u32 save_len = len; @@ -1693,8 +1686,7 @@ static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) D_INFO("ucode inst image size is %u\n", len); - il_wr(il, HBUS_TARG_MEM_RADDR, - IL39_RTC_INST_LOWER_BOUND); + il_wr(il, HBUS_TARG_MEM_RADDR, IL39_RTC_INST_LOWER_BOUND); errcnt = 0; for (; len > 0; len -= sizeof(u32), image++) { @@ -1704,8 +1696,8 @@ static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { IL_ERR("uCode INST section is invalid at " - "offset 0x%x, is 0x%x, s/b 0x%x\n", - save_len - len, val, le32_to_cpu(*image)); + "offset 0x%x, is 0x%x, s/b 0x%x\n", + save_len - len, val, le32_to_cpu(*image)); rc = -EIO; errcnt++; if (errcnt >= 20) @@ -1713,21 +1705,19 @@ static int il3945_verify_inst_full(struct il_priv *il, __le32 *image, u32 len) } } - if (!errcnt) - D_INFO( - "ucode image in INSTRUCTION memory is good\n"); + D_INFO("ucode image in INSTRUCTION memory is good\n"); return rc; } - /** * il3945_verify_inst_sparse - verify runtime uCode image in card vs. host, * using sample data 100 bytes apart. If these sample points are good, * it's a pretty good bet that everything between them is good, too. */ -static int il3945_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) +static int +il3945_verify_inst_sparse(struct il_priv *il, __le32 * image, u32 len) { u32 val; int rc = 0; @@ -1736,18 +1726,17 @@ static int il3945_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) D_INFO("ucode inst image size is %u\n", len); - for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { + for (i = 0; i < len; i += 100, image += 100 / sizeof(u32)) { /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log * if IL_DL_IO is set */ - il_wr(il, HBUS_TARG_MEM_RADDR, - i + IL39_RTC_INST_LOWER_BOUND); + il_wr(il, HBUS_TARG_MEM_RADDR, i + IL39_RTC_INST_LOWER_BOUND); val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { -#if 0 /* Enable this if you want to see details */ +#if 0 /* Enable this if you want to see details */ IL_ERR("uCode INST section is invalid at " - "offset 0x%x, is 0x%x, s/b 0x%x\n", - i, val, *image); + "offset 0x%x, is 0x%x, s/b 0x%x\n", i, val, + *image); #endif rc = -EIO; errcnt++; @@ -1759,19 +1748,19 @@ static int il3945_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) return rc; } - /** * il3945_verify_ucode - determine which instruction image is in SRAM, * and verify its contents */ -static int il3945_verify_ucode(struct il_priv *il) +static int +il3945_verify_ucode(struct il_priv *il) { __le32 *image; u32 len; int rc = 0; /* Try bootstrap */ - image = (__le32 *)il->ucode_boot.v_addr; + image = (__le32 *) il->ucode_boot.v_addr; len = il->ucode_boot.len; rc = il3945_verify_inst_sparse(il, image, len); if (rc == 0) { @@ -1780,7 +1769,7 @@ static int il3945_verify_ucode(struct il_priv *il) } /* Try initialize */ - image = (__le32 *)il->ucode_init.v_addr; + image = (__le32 *) il->ucode_init.v_addr; len = il->ucode_init.len; rc = il3945_verify_inst_sparse(il, image, len); if (rc == 0) { @@ -1789,7 +1778,7 @@ static int il3945_verify_ucode(struct il_priv *il) } /* Try runtime/protocol */ - image = (__le32 *)il->ucode_code.v_addr; + image = (__le32 *) il->ucode_code.v_addr; len = il->ucode_code.len; rc = il3945_verify_inst_sparse(il, image, len); if (rc == 0) { @@ -1802,14 +1791,15 @@ static int il3945_verify_ucode(struct il_priv *il) /* Since nothing seems to match, show first several data entries in * instruction SRAM, so maybe visual inspection will give a clue. * Selection of bootstrap image (vs. other images) is arbitrary. */ - image = (__le32 *)il->ucode_boot.v_addr; + image = (__le32 *) il->ucode_boot.v_addr; len = il->ucode_boot.len; rc = il3945_verify_inst_full(il, image, len); return rc; } -static void il3945_nic_start(struct il_priv *il) +static void +il3945_nic_start(struct il_priv *il) { /* Remove all resets to allow NIC to operate */ _il_wr(il, CSR_RESET, 0); @@ -1821,12 +1811,14 @@ static u32 il3945_ucode_get_##item(const struct il_ucode_header *ucode)\ return le32_to_cpu(ucode->v1.item); \ } -static u32 il3945_ucode_get_header_size(u32 api_ver) +static u32 +il3945_ucode_get_header_size(u32 api_ver) { return 24; } -static u8 *il3945_ucode_get_data(const struct il_ucode_header *ucode) +static u8 * +il3945_ucode_get_data(const struct il_ucode_header *ucode) { return (u8 *) ucode->v1.data; } @@ -1842,7 +1834,8 @@ IL3945_UCODE_GET(boot_size); * * Copy into buffers for card to fetch via bus-mastering */ -static int il3945_read_ucode(struct il_priv *il) +static int +il3945_read_ucode(struct il_priv *il) { const struct il_ucode_header *ucode; int ret = -EINVAL, idx; @@ -1862,8 +1855,7 @@ static int il3945_read_ucode(struct il_priv *il) sprintf(buf, "%s%u%s", name_pre, idx, ".ucode"); ret = request_firmware(&ucode_raw, buf, &il->pci_dev->dev); if (ret < 0) { - IL_ERR("%s firmware file req failed: %d\n", - buf, ret); + IL_ERR("%s firmware file req failed: %d\n", buf, ret); if (ret == -ENOENT) continue; else @@ -1871,12 +1863,11 @@ static int il3945_read_ucode(struct il_priv *il) } else { if (idx < api_max) IL_ERR("Loaded firmware %s, " - "which is deprecated. " - " Please use API v%u instead.\n", - buf, api_max); + "which is deprecated. " + " Please use API v%u instead.\n", buf, + api_max); D_INFO("Got firmware '%s' file " - "(%zd bytes) from disk\n", - buf, ucode_raw->size); + "(%zd bytes) from disk\n", buf, ucode_raw->size); break; } } @@ -1885,7 +1876,7 @@ static int il3945_read_ucode(struct il_priv *il) goto error; /* Make sure that we got at least our header! */ - if (ucode_raw->size < il3945_ucode_get_header_size(1)) { + if (ucode_raw->size < il3945_ucode_get_header_size(1)) { IL_ERR("File size way too small!\n"); ret = -EINVAL; goto err_release; @@ -1909,90 +1900,72 @@ static int il3945_read_ucode(struct il_priv *il) if (api_ver < api_min || api_ver > api_max) { IL_ERR("Driver unable to support your firmware API. " - "Driver supports v%u, firmware is v%u.\n", - api_max, api_ver); + "Driver supports v%u, firmware is v%u.\n", api_max, + api_ver); il->ucode_ver = 0; ret = -EINVAL; goto err_release; } if (api_ver != api_max) IL_ERR("Firmware has old API version. Expected %u, " - "got %u. New firmware can be obtained " - "from http://www.intellinuxwireless.org.\n", - api_max, api_ver); + "got %u. New firmware can be obtained " + "from http://www.intellinuxwireless.org.\n", api_max, + api_ver); IL_INFO("loaded firmware version %u.%u.%u.%u\n", - IL_UCODE_MAJOR(il->ucode_ver), - IL_UCODE_MINOR(il->ucode_ver), - IL_UCODE_API(il->ucode_ver), - IL_UCODE_SERIAL(il->ucode_ver)); - - snprintf(il->hw->wiphy->fw_version, - sizeof(il->hw->wiphy->fw_version), - "%u.%u.%u.%u", - IL_UCODE_MAJOR(il->ucode_ver), - IL_UCODE_MINOR(il->ucode_ver), - IL_UCODE_API(il->ucode_ver), - IL_UCODE_SERIAL(il->ucode_ver)); + IL_UCODE_MAJOR(il->ucode_ver), IL_UCODE_MINOR(il->ucode_ver), + IL_UCODE_API(il->ucode_ver), IL_UCODE_SERIAL(il->ucode_ver)); - D_INFO("f/w package hdr ucode version raw = 0x%x\n", - il->ucode_ver); - D_INFO("f/w package hdr runtime inst size = %u\n", - inst_size); - D_INFO("f/w package hdr runtime data size = %u\n", - data_size); - D_INFO("f/w package hdr init inst size = %u\n", - init_size); - D_INFO("f/w package hdr init data size = %u\n", - init_data_size); - D_INFO("f/w package hdr boot inst size = %u\n", - boot_size); + snprintf(il->hw->wiphy->fw_version, sizeof(il->hw->wiphy->fw_version), + "%u.%u.%u.%u", IL_UCODE_MAJOR(il->ucode_ver), + IL_UCODE_MINOR(il->ucode_ver), IL_UCODE_API(il->ucode_ver), + IL_UCODE_SERIAL(il->ucode_ver)); + D_INFO("f/w package hdr ucode version raw = 0x%x\n", il->ucode_ver); + D_INFO("f/w package hdr runtime inst size = %u\n", inst_size); + D_INFO("f/w package hdr runtime data size = %u\n", data_size); + D_INFO("f/w package hdr init inst size = %u\n", init_size); + D_INFO("f/w package hdr init data size = %u\n", init_data_size); + D_INFO("f/w package hdr boot inst size = %u\n", boot_size); /* Verify size of file vs. image size info in file's header */ - if (ucode_raw->size != il3945_ucode_get_header_size(api_ver) + - inst_size + data_size + init_size + - init_data_size + boot_size) { + if (ucode_raw->size != + il3945_ucode_get_header_size(api_ver) + inst_size + data_size + + init_size + init_data_size + boot_size) { - D_INFO( - "uCode file size %zd does not match expected size\n", - ucode_raw->size); + D_INFO("uCode file size %zd does not match expected size\n", + ucode_raw->size); ret = -EINVAL; goto err_release; } /* Verify that uCode images will fit in card's SRAM */ if (inst_size > IL39_MAX_INST_SIZE) { - D_INFO("uCode instr len %d too large to fit in\n", - inst_size); + D_INFO("uCode instr len %d too large to fit in\n", inst_size); ret = -EINVAL; goto err_release; } if (data_size > IL39_MAX_DATA_SIZE) { - D_INFO("uCode data len %d too large to fit in\n", - data_size); + D_INFO("uCode data len %d too large to fit in\n", data_size); ret = -EINVAL; goto err_release; } if (init_size > IL39_MAX_INST_SIZE) { - D_INFO( - "uCode init instr len %d too large to fit in\n", - init_size); + D_INFO("uCode init instr len %d too large to fit in\n", + init_size); ret = -EINVAL; goto err_release; } if (init_data_size > IL39_MAX_DATA_SIZE) { - D_INFO( - "uCode init data len %d too large to fit in\n", - init_data_size); + D_INFO("uCode init data len %d too large to fit in\n", + init_data_size); ret = -EINVAL; goto err_release; } if (boot_size > IL39_MAX_BSM_SIZE) { - D_INFO( - "uCode boot instr len %d too large to fit in\n", - boot_size); + D_INFO("uCode boot instr len %d too large to fit in\n", + boot_size); ret = -EINVAL; goto err_release; } @@ -2040,19 +2013,17 @@ static int il3945_read_ucode(struct il_priv *il) /* Runtime instructions (first block of data in file) */ len = inst_size; - D_INFO( - "Copying (but not loading) uCode instr len %zd\n", len); + D_INFO("Copying (but not loading) uCode instr len %zd\n", len); memcpy(il->ucode_code.v_addr, src, len); src += len; D_INFO("uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", - il->ucode_code.v_addr, (u32)il->ucode_code.p_addr); + il->ucode_code.v_addr, (u32) il->ucode_code.p_addr); /* Runtime data (2nd block) * NOTE: Copy into backup buffer will be done in il3945_up() */ len = data_size; - D_INFO( - "Copying (but not loading) uCode data len %zd\n", len); + D_INFO("Copying (but not loading) uCode data len %zd\n", len); memcpy(il->ucode_data.v_addr, src, len); memcpy(il->ucode_data_backup.v_addr, src, len); src += len; @@ -2060,8 +2031,7 @@ static int il3945_read_ucode(struct il_priv *il) /* Initialization instructions (3rd block) */ if (init_size) { len = init_size; - D_INFO( - "Copying (but not loading) init instr len %zd\n", len); + D_INFO("Copying (but not loading) init instr len %zd\n", len); memcpy(il->ucode_init.v_addr, src, len); src += len; } @@ -2069,35 +2039,32 @@ static int il3945_read_ucode(struct il_priv *il) /* Initialization data (4th block) */ if (init_data_size) { len = init_data_size; - D_INFO( - "Copying (but not loading) init data len %zd\n", len); + D_INFO("Copying (but not loading) init data len %zd\n", len); memcpy(il->ucode_init_data.v_addr, src, len); src += len; } /* Bootstrap instructions (5th block) */ len = boot_size; - D_INFO( - "Copying (but not loading) boot instr len %zd\n", len); + D_INFO("Copying (but not loading) boot instr len %zd\n", len); memcpy(il->ucode_boot.v_addr, src, len); /* We have our copies now, allow OS release its copies */ release_firmware(ucode_raw); return 0; - err_pci_alloc: +err_pci_alloc: IL_ERR("failed to allocate pci memory\n"); ret = -ENOMEM; il3945_dealloc_ucode_pci(il); - err_release: +err_release: release_firmware(ucode_raw); - error: +error: return ret; } - /** * il3945_set_ucode_ptrs - Set uCode address location * @@ -2107,7 +2074,8 @@ static int il3945_read_ucode(struct il_priv *il) * We need to replace them to load runtime uCode inst and data, * and to save runtime data when powering down. */ -static int il3945_set_ucode_ptrs(struct il_priv *il) +static int +il3945_set_ucode_ptrs(struct il_priv *il) { dma_addr_t pinst; dma_addr_t pdata; @@ -2119,13 +2087,12 @@ static int il3945_set_ucode_ptrs(struct il_priv *il) /* Tell bootstrap uCode where to find image to load */ il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); - il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, - il->ucode_data.len); + il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, il->ucode_data.len); /* Inst byte count must be last to set up, bit 31 signals uCode * that all new ptr/size info is in place */ il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, - il->ucode_code.len | BSM_DRAM_INST_LOAD); + il->ucode_code.len | BSM_DRAM_INST_LOAD); D_INFO("Runtime uCode pointers are set.\n"); @@ -2139,7 +2106,8 @@ static int il3945_set_ucode_ptrs(struct il_priv *il) * * Tell "initialize" uCode to go ahead and load the runtime uCode. */ -static void il3945_init_alive_start(struct il_priv *il) +static void +il3945_init_alive_start(struct il_priv *il) { /* Check alive response for "valid" sign from uCode */ if (il->card_alive_init.is_valid != UCODE_VALID_OK) { @@ -2171,7 +2139,7 @@ static void il3945_init_alive_start(struct il_priv *il) } return; - restart: +restart: queue_work(il->workqueue, &il->restart); } @@ -2180,7 +2148,8 @@ static void il3945_init_alive_start(struct il_priv *il) * from protocol/runtime uCode (initialization uCode's * Alive gets handled by il3945_init_alive_start()). */ -static void il3945_alive_start(struct il_priv *il) +static void +il3945_alive_start(struct il_priv *il) { int thermal_spin = 0; u32 rfkill; @@ -2219,7 +2188,7 @@ static void il3945_alive_start(struct il_priv *il) if (thermal_spin) D_INFO("Thermal calibration took %dus\n", - thermal_spin * 10); + thermal_spin * 10); } else set_bit(S_RF_KILL_HW, &il->status); @@ -2240,7 +2209,7 @@ static void il3945_alive_start(struct il_priv *il) if (il_is_associated(il)) { struct il3945_rxon_cmd *active_rxon = - (struct il3945_rxon_cmd *)(&ctx->active); + (struct il3945_rxon_cmd *)(&ctx->active); ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; @@ -2264,13 +2233,14 @@ static void il3945_alive_start(struct il_priv *il) return; - restart: +restart: queue_work(il->workqueue, &il->restart); } static void il3945_cancel_deferred_work(struct il_priv *il); -static void __il3945_down(struct il_priv *il) +static void +__il3945_down(struct il_priv *il) { unsigned long flags; int exit_pending; @@ -2313,25 +2283,28 @@ static void __il3945_down(struct il_priv *il) /* If we have not previously called il3945_init() then * clear all bits but the RF Kill bits and return */ if (!il_is_init(il)) { - il->status = test_bit(S_RF_KILL_HW, &il->status) << - S_RF_KILL_HW | - test_bit(S_GEO_CONFIGURED, &il->status) << - S_GEO_CONFIGURED | - test_bit(S_EXIT_PENDING, &il->status) << - S_EXIT_PENDING; + il->status = + test_bit(S_RF_KILL_HW, + &il-> + status) << S_RF_KILL_HW | + test_bit(S_GEO_CONFIGURED, + &il-> + status) << S_GEO_CONFIGURED | + test_bit(S_EXIT_PENDING, &il->status) << S_EXIT_PENDING; goto exit; } /* ...otherwise clear out all the status bits but the RF Kill * bit and continue taking the NIC down. */ - il->status &= test_bit(S_RF_KILL_HW, &il->status) << - S_RF_KILL_HW | - test_bit(S_GEO_CONFIGURED, &il->status) << - S_GEO_CONFIGURED | - test_bit(S_FW_ERROR, &il->status) << - S_FW_ERROR | - test_bit(S_EXIT_PENDING, &il->status) << - S_EXIT_PENDING; + il->status &= + test_bit(S_RF_KILL_HW, + &il->status) << S_RF_KILL_HW | test_bit(S_GEO_CONFIGURED, + &il-> + status) << + S_GEO_CONFIGURED | test_bit(S_FW_ERROR, + &il-> + status) << S_FW_ERROR | + test_bit(S_EXIT_PENDING, &il->status) << S_EXIT_PENDING; il3945_hw_txq_ctx_stop(il); il3945_hw_rxq_stop(il); @@ -2343,7 +2316,7 @@ static void __il3945_down(struct il_priv *il) /* Stop the device, and put it in low power state */ il_apm_stop(il); - exit: +exit: memset(&il->card_alive, 0, sizeof(struct il_alive_resp)); if (il->beacon_skb) @@ -2354,7 +2327,8 @@ static void __il3945_down(struct il_priv *il) il3945_clear_free_frames(il); } -static void il3945_down(struct il_priv *il) +static void +il3945_down(struct il_priv *il) { mutex_lock(&il->mutex); __il3945_down(il); @@ -2365,15 +2339,15 @@ static void il3945_down(struct il_priv *il) #define MAX_HW_RESTARTS 5 -static int il3945_alloc_bcast_station(struct il_priv *il) +static int +il3945_alloc_bcast_station(struct il_priv *il) { struct il_rxon_context *ctx = &il->ctx; unsigned long flags; u8 sta_id; spin_lock_irqsave(&il->sta_lock, flags); - sta_id = il_prep_station(il, ctx, - il_bcast_addr, false, NULL); + sta_id = il_prep_station(il, ctx, il_bcast_addr, false, NULL); if (sta_id == IL_INVALID_STATION) { IL_ERR("Unable to prepare broadcast station\n"); spin_unlock_irqrestore(&il->sta_lock, flags); @@ -2388,7 +2362,8 @@ static int il3945_alloc_bcast_station(struct il_priv *il) return 0; } -static int __il3945_up(struct il_priv *il) +static int +__il3945_up(struct il_priv *il) { int rc, i; @@ -2407,8 +2382,7 @@ static int __il3945_up(struct il_priv *il) } /* If platform's RF_KILL switch is NOT set to KILL */ - if (_il_rd(il, CSR_GP_CNTRL) & - CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) + if (_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) clear_bit(S_RF_KILL_HW, &il->status); else { set_bit(S_RF_KILL_HW, &il->status); @@ -2426,8 +2400,7 @@ static int __il3945_up(struct il_priv *il) /* make sure rfkill handshake bits are cleared */ _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - _il_wr(il, CSR_UCODE_DRV_GP1_CLR, - CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); /* clear (again), then enable host interrupts */ _il_wr(il, CSR_INT, 0xFFFFFFFF); @@ -2455,8 +2428,7 @@ static int __il3945_up(struct il_priv *il) rc = il->cfg->ops->lib->load_ucode(il); if (rc) { - IL_ERR( - "Unable to set up bootstrap uCode: %d\n", rc); + IL_ERR("Unable to set up bootstrap uCode: %d\n", rc); continue; } @@ -2478,14 +2450,14 @@ static int __il3945_up(struct il_priv *il) return -EIO; } - /***************************************************************************** * * Workqueue callbacks * *****************************************************************************/ -static void il3945_bg_init_alive_start(struct work_struct *data) +static void +il3945_bg_init_alive_start(struct work_struct *data) { struct il_priv *il = container_of(data, struct il_priv, init_alive_start.work); @@ -2499,7 +2471,8 @@ out: mutex_unlock(&il->mutex); } -static void il3945_bg_alive_start(struct work_struct *data) +static void +il3945_bg_alive_start(struct work_struct *data) { struct il_priv *il = container_of(data, struct il_priv, alive_start.work); @@ -2519,13 +2492,14 @@ out: * *is* readable even when device has been SW_RESET into low power mode * (e.g. during RF KILL). */ -static void il3945_rfkill_poll(struct work_struct *data) +static void +il3945_rfkill_poll(struct work_struct *data) { struct il_priv *il = container_of(data, struct il_priv, _3945.rfkill_poll.work); bool old_rfkill = test_bit(S_RF_KILL_HW, &il->status); - bool new_rfkill = !(_il_rd(il, CSR_GP_CNTRL) - & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW); + bool new_rfkill = + !(_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW); if (new_rfkill != old_rfkill) { if (new_rfkill) @@ -2536,7 +2510,7 @@ static void il3945_rfkill_poll(struct work_struct *data) wiphy_rfkill_set_hw_state(il->hw->wiphy, new_rfkill); D_RF_KILL("RF_KILL bit toggled to %s.\n", - new_rfkill ? "disable radio" : "enable radio"); + new_rfkill ? "disable radio" : "enable radio"); } /* Keep this running, even if radio now enabled. This will be @@ -2546,7 +2520,8 @@ static void il3945_rfkill_poll(struct work_struct *data) } -int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) +int +il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) { struct il_host_cmd cmd = { .id = C_SCAN, @@ -2563,8 +2538,9 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) lockdep_assert_held(&il->mutex); if (!il->scan_cmd) { - il->scan_cmd = kmalloc(sizeof(struct il3945_scan_cmd) + - IL_MAX_SCAN_SIZE, GFP_KERNEL); + il->scan_cmd = + kmalloc(sizeof(struct il3945_scan_cmd) + IL_MAX_SCAN_SIZE, + GFP_KERNEL); if (!il->scan_cmd) { D_SCAN("Fail to allocate scan memory\n"); return -ENOMEM; @@ -2598,12 +2574,12 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) */ extra = (suspend_time / interval) << 24; - scan_suspend_time = 0xFF0FFFFF & - (extra | ((suspend_time % interval) * 1024)); + scan_suspend_time = + 0xFF0FFFFF & (extra | ((suspend_time % interval) * 1024)); scan->suspend_time = cpu_to_le32(scan_suspend_time); D_SCAN("suspend_time 0x%X beacon interval %d\n", - scan_suspend_time, interval); + scan_suspend_time, interval); } if (il->scan_request->n_ssids) { @@ -2615,7 +2591,7 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) continue; scan->direct_scan[p].id = WLAN_EID_SSID; scan->direct_scan[p].len = - il->scan_request->ssids[i].ssid_len; + il->scan_request->ssids[i].ssid_len; memcpy(scan->direct_scan[p].ssid, il->scan_request->ssids[i].ssid, il->scan_request->ssids[i].ssid_len); @@ -2654,26 +2630,29 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) * is marked passive, we can do active scanning if we * detect transmissions. */ - scan->good_CRC_th = is_active ? IL_GOOD_CRC_TH_DEFAULT : - IL_GOOD_CRC_TH_DISABLED; - - len = il_fill_probe_req(il, (struct ieee80211_mgmt *)scan->data, - vif->addr, il->scan_request->ie, - il->scan_request->ie_len, - IL_MAX_SCAN_SIZE - sizeof(*scan)); + scan->good_CRC_th = + is_active ? IL_GOOD_CRC_TH_DEFAULT : IL_GOOD_CRC_TH_DISABLED; + + len = + il_fill_probe_req(il, (struct ieee80211_mgmt *)scan->data, + vif->addr, il->scan_request->ie, + il->scan_request->ie_len, + IL_MAX_SCAN_SIZE - sizeof(*scan)); scan->tx_cmd.len = cpu_to_le16(len); /* select Rx antennas */ scan->flags |= il3945_get_antenna_flags(il); - scan->channel_count = il3945_get_channels_for_scan(il, band, is_active, n_probes, - (void *)&scan->data[len], vif); + scan->channel_count = + il3945_get_channels_for_scan(il, band, is_active, n_probes, + (void *)&scan->data[len], vif); if (scan->channel_count == 0) { D_SCAN("channel count %d\n", scan->channel_count); return -EIO; } - cmd.len += le16_to_cpu(scan->tx_cmd.len) + + cmd.len += + le16_to_cpu(scan->tx_cmd.len) + scan->channel_count * sizeof(struct il3945_scan_channel); cmd.data = scan; scan->len = cpu_to_le16(cmd.len); @@ -2685,7 +2664,8 @@ int il3945_request_scan(struct il_priv *il, struct ieee80211_vif *vif) return ret; } -void il3945_post_scan(struct il_priv *il) +void +il3945_post_scan(struct il_priv *il) { struct il_rxon_context *ctx = &il->ctx; @@ -2697,7 +2677,8 @@ void il3945_post_scan(struct il_priv *il) il3945_commit_rxon(il, ctx); } -static void il3945_bg_restart(struct work_struct *data) +static void +il3945_bg_restart(struct work_struct *data) { struct il_priv *il = container_of(data, struct il_priv, restart); @@ -2725,10 +2706,10 @@ static void il3945_bg_restart(struct work_struct *data) } } -static void il3945_bg_rx_replenish(struct work_struct *data) +static void +il3945_bg_rx_replenish(struct work_struct *data) { - struct il_priv *il = - container_of(data, struct il_priv, rx_replenish); + struct il_priv *il = container_of(data, struct il_priv, rx_replenish); mutex_lock(&il->mutex); if (test_bit(S_EXIT_PENDING, &il->status)) @@ -2739,7 +2720,8 @@ out: mutex_unlock(&il->mutex); } -void il3945_post_associate(struct il_priv *il) +void +il3945_post_associate(struct il_priv *il) { int rc = 0; struct ieee80211_conf *conf = NULL; @@ -2748,8 +2730,8 @@ void il3945_post_associate(struct il_priv *il) if (!ctx->vif || !il->is_open) return; - D_ASSOC("Associated as %d to: %pM\n", - ctx->vif->bss_conf.aid, ctx->active.bssid_addr); + D_ASSOC("Associated as %d to: %pM\n", ctx->vif->bss_conf.aid, + ctx->active.bssid_addr); if (test_bit(S_EXIT_PENDING, &il->status)) return; @@ -2763,15 +2745,14 @@ void il3945_post_associate(struct il_priv *il) rc = il_send_rxon_timing(il, ctx); if (rc) - IL_WARN("C_RXON_TIMING failed - " - "Attempting to continue.\n"); + IL_WARN("C_RXON_TIMING failed - " "Attempting to continue.\n"); ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; ctx->staging.assoc_id = cpu_to_le16(ctx->vif->bss_conf.aid); - D_ASSOC("assoc id %d beacon interval %d\n", - ctx->vif->bss_conf.aid, ctx->vif->bss_conf.beacon_int); + D_ASSOC("assoc id %d beacon interval %d\n", ctx->vif->bss_conf.aid, + ctx->vif->bss_conf.beacon_int); if (ctx->vif->bss_conf.use_short_preamble) ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; @@ -2795,8 +2776,8 @@ void il3945_post_associate(struct il_priv *il) il3945_send_beacon_cmd(il); break; default: - IL_ERR("%s Should not be called in %d mode\n", - __func__, ctx->vif->type); + IL_ERR("%s Should not be called in %d mode\n", __func__, + ctx->vif->type); break; } } @@ -2809,7 +2790,8 @@ void il3945_post_associate(struct il_priv *il) #define UCODE_READY_TIMEOUT (2 * HZ) -static int il3945_mac_start(struct ieee80211_hw *hw) +static int +il3945_mac_start(struct ieee80211_hw *hw) { struct il_priv *il = hw->priv; int ret; @@ -2843,13 +2825,12 @@ static int il3945_mac_start(struct ieee80211_hw *hw) /* Wait for START_ALIVE from ucode. Otherwise callbacks from * mac80211 will not be run successfully. */ ret = wait_event_timeout(il->wait_command_queue, - test_bit(S_READY, &il->status), - UCODE_READY_TIMEOUT); + test_bit(S_READY, &il->status), + UCODE_READY_TIMEOUT); if (!ret) { if (!test_bit(S_READY, &il->status)) { - IL_ERR( - "Wait for START_ALIVE timeout after %dms.\n", - jiffies_to_msecs(UCODE_READY_TIMEOUT)); + IL_ERR("Wait for START_ALIVE timeout after %dms.\n", + jiffies_to_msecs(UCODE_READY_TIMEOUT)); ret = -ETIMEDOUT; goto out_release_irq; } @@ -2869,7 +2850,8 @@ out_release_irq: return ret; } -static void il3945_mac_stop(struct ieee80211_hw *hw) +static void +il3945_mac_stop(struct ieee80211_hw *hw) { struct il_priv *il = hw->priv; @@ -2893,14 +2875,15 @@ static void il3945_mac_stop(struct ieee80211_hw *hw) D_MAC80211("leave\n"); } -static void il3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) +static void +il3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { struct il_priv *il = hw->priv; D_MAC80211("enter\n"); D_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, - ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); + ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); if (il3945_tx_skb(il, skb)) dev_kfree_skb_any(skb); @@ -2908,7 +2891,8 @@ static void il3945_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) D_MAC80211("leave\n"); } -void il3945_config_ap(struct il_priv *il) +void +il3945_config_ap(struct il_priv *il) { struct il_rxon_context *ctx = &il->ctx; struct ieee80211_vif *vif = ctx->vif; @@ -2928,24 +2912,20 @@ void il3945_config_ap(struct il_priv *il) rc = il_send_rxon_timing(il, ctx); if (rc) IL_WARN("C_RXON_TIMING failed - " - "Attempting to continue.\n"); + "Attempting to continue.\n"); ctx->staging.assoc_id = 0; if (vif->bss_conf.use_short_preamble) - ctx->staging.flags |= - RXON_FLG_SHORT_PREAMBLE_MSK; + ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; else - ctx->staging.flags &= - ~RXON_FLG_SHORT_PREAMBLE_MSK; + ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) { if (vif->bss_conf.use_short_slot) - ctx->staging.flags |= - RXON_FLG_SHORT_SLOT_MSK; + ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; else - ctx->staging.flags &= - ~RXON_FLG_SHORT_SLOT_MSK; + ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; } /* restore RXON assoc */ ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; @@ -2954,10 +2934,10 @@ void il3945_config_ap(struct il_priv *il) il3945_send_beacon_cmd(il); } -static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta, - struct ieee80211_key_conf *key) +static int +il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, + struct ieee80211_vif *vif, struct ieee80211_sta *sta, + struct ieee80211_key_conf *key) { struct il_priv *il = hw->priv; int ret = 0; @@ -2982,8 +2962,7 @@ static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, static_key = !il_is_associated(il); if (!static_key) { - sta_id = il_sta_id_or_broadcast( - il, &il->ctx, sta); + sta_id = il_sta_id_or_broadcast(il, &il->ctx, sta); if (sta_id == IL_INVALID_STATION) return -EINVAL; } @@ -3016,9 +2995,9 @@ static int il3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, return ret; } -static int il3945_mac_sta_add(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta) +static int +il3945_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_sta *sta) { struct il_priv *il = hw->priv; struct il3945_sta_priv *sta_priv = (void *)sta->drv_priv; @@ -3026,20 +3005,15 @@ static int il3945_mac_sta_add(struct ieee80211_hw *hw, bool is_ap = vif->type == NL80211_IFTYPE_STATION; u8 sta_id; - D_INFO("received request to add station %pM\n", - sta->addr); + D_INFO("received request to add station %pM\n", sta->addr); mutex_lock(&il->mutex); - D_INFO("proceeding to add station %pM\n", - sta->addr); + D_INFO("proceeding to add station %pM\n", sta->addr); sta_priv->common.sta_id = IL_INVALID_STATION; - - ret = il_add_station_common(il, - &il->ctx, - sta->addr, is_ap, sta, &sta_id); + ret = + il_add_station_common(il, &il->ctx, sta->addr, is_ap, sta, &sta_id); if (ret) { - IL_ERR("Unable to add station %pM (%d)\n", - sta->addr, ret); + IL_ERR("Unable to add station %pM (%d)\n", sta->addr, ret); /* Should we return success if return code is EEXIST ? */ mutex_unlock(&il->mutex); return ret; @@ -3048,18 +3022,16 @@ static int il3945_mac_sta_add(struct ieee80211_hw *hw, sta_priv->common.sta_id = sta_id; /* Initialize rate scaling */ - D_INFO("Initializing rate scaling for station %pM\n", - sta->addr); + D_INFO("Initializing rate scaling for station %pM\n", sta->addr); il3945_rs_rate_init(il, sta, sta_id); mutex_unlock(&il->mutex); return 0; } -static void il3945_configure_filter(struct ieee80211_hw *hw, - unsigned int changed_flags, - unsigned int *total_flags, - u64 multicast) +static void +il3945_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags, + unsigned int *total_flags, u64 multicast) { struct il_priv *il = hw->priv; __le32 filter_or = 0, filter_nand = 0; @@ -3072,8 +3044,8 @@ static void il3945_configure_filter(struct ieee80211_hw *hw, filter_nand |= (flag); \ } while (0) - D_MAC80211("Enter: changed: 0x%x, total: 0x%x\n", - changed_flags, *total_flags); + D_MAC80211("Enter: changed: 0x%x, total: 0x%x\n", changed_flags, + *total_flags); CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); CHK(FIF_CONTROL, RXON_FILTER_CTL2HOST_MSK); @@ -3100,11 +3072,11 @@ static void il3945_configure_filter(struct ieee80211_hw *hw, * since we currently do not support programming multicast * filters into the device. */ - *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | - FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; + *total_flags &= + FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | + FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; } - /***************************************************************************** * * sysfs attributes @@ -3124,15 +3096,17 @@ static void il3945_configure_filter(struct ieee80211_hw *hw, * level that is used instead of the global debug level if it (the per * device debug level) is set. */ -static ssize_t il3945_show_debug_level(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il3945_show_debug_level(struct device *d, struct device_attribute *attr, + char *buf) { struct il_priv *il = dev_get_drvdata(d); return sprintf(buf, "0x%08X\n", il_get_debug_level(il)); } -static ssize_t il3945_store_debug_level(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) + +static ssize_t +il3945_store_debug_level(struct device *d, struct device_attribute *attr, + const char *buf, size_t count) { struct il_priv *il = dev_get_drvdata(d); unsigned long val; @@ -3144,19 +3118,19 @@ static ssize_t il3945_store_debug_level(struct device *d, else { il->debug_level = val; if (il_alloc_traffic_mem(il)) - IL_ERR( - "Not enough memory to generate traffic log\n"); + IL_ERR("Not enough memory to generate traffic log\n"); } return strnlen(buf, count); } -static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, - il3945_show_debug_level, il3945_store_debug_level); +static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, il3945_show_debug_level, + il3945_store_debug_level); #endif /* CONFIG_IWLEGACY_DEBUG */ -static ssize_t il3945_show_temperature(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il3945_show_temperature(struct device *d, struct device_attribute *attr, + char *buf) { struct il_priv *il = dev_get_drvdata(d); @@ -3168,16 +3142,16 @@ static ssize_t il3945_show_temperature(struct device *d, static DEVICE_ATTR(temperature, S_IRUGO, il3945_show_temperature, NULL); -static ssize_t il3945_show_tx_power(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il3945_show_tx_power(struct device *d, struct device_attribute *attr, char *buf) { struct il_priv *il = dev_get_drvdata(d); return sprintf(buf, "%d\n", il->tx_power_user_lmt); } -static ssize_t il3945_store_tx_power(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t +il3945_store_tx_power(struct device *d, struct device_attribute *attr, + const char *buf, size_t count) { struct il_priv *il = dev_get_drvdata(d); char *p = (char *)buf; @@ -3192,10 +3166,11 @@ static ssize_t il3945_store_tx_power(struct device *d, return count; } -static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, il3945_show_tx_power, il3945_store_tx_power); +static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, il3945_show_tx_power, + il3945_store_tx_power); -static ssize_t il3945_show_flags(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il3945_show_flags(struct device *d, struct device_attribute *attr, char *buf) { struct il_priv *il = dev_get_drvdata(d); struct il_rxon_context *ctx = &il->ctx; @@ -3203,9 +3178,9 @@ static ssize_t il3945_show_flags(struct device *d, return sprintf(buf, "0x%04X\n", ctx->active.flags); } -static ssize_t il3945_store_flags(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t +il3945_store_flags(struct device *d, struct device_attribute *attr, + const char *buf, size_t count) { struct il_priv *il = dev_get_drvdata(d); u32 flags = simple_strtoul(buf, NULL, 0); @@ -3217,8 +3192,7 @@ static ssize_t il3945_store_flags(struct device *d, if (il_scan_cancel_timeout(il, 100)) IL_WARN("Could not cancel scan.\n"); else { - D_INFO("Committing rxon.flags = 0x%04X\n", - flags); + D_INFO("Committing rxon.flags = 0x%04X\n", flags); ctx->staging.flags = cpu_to_le32(flags); il3945_commit_rxon(il, ctx); } @@ -3228,21 +3202,22 @@ static ssize_t il3945_store_flags(struct device *d, return count; } -static DEVICE_ATTR(flags, S_IWUSR | S_IRUGO, il3945_show_flags, il3945_store_flags); +static DEVICE_ATTR(flags, S_IWUSR | S_IRUGO, il3945_show_flags, + il3945_store_flags); -static ssize_t il3945_show_filter_flags(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il3945_show_filter_flags(struct device *d, struct device_attribute *attr, + char *buf) { struct il_priv *il = dev_get_drvdata(d); struct il_rxon_context *ctx = &il->ctx; - return sprintf(buf, "0x%04X\n", - le32_to_cpu(ctx->active.filter_flags)); + return sprintf(buf, "0x%04X\n", le32_to_cpu(ctx->active.filter_flags)); } -static ssize_t il3945_store_filter_flags(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t +il3945_store_filter_flags(struct device *d, struct device_attribute *attr, + const char *buf, size_t count) { struct il_priv *il = dev_get_drvdata(d); struct il_rxon_context *ctx = &il->ctx; @@ -3254,10 +3229,9 @@ static ssize_t il3945_store_filter_flags(struct device *d, if (il_scan_cancel_timeout(il, 100)) IL_WARN("Could not cancel scan.\n"); else { - D_INFO("Committing rxon.filter_flags = " - "0x%04X\n", filter_flags); - ctx->staging.filter_flags = - cpu_to_le32(filter_flags); + D_INFO("Committing rxon.filter_flags = " "0x%04X\n", + filter_flags); + ctx->staging.filter_flags = cpu_to_le32(filter_flags); il3945_commit_rxon(il, ctx); } } @@ -3269,13 +3243,14 @@ static ssize_t il3945_store_filter_flags(struct device *d, static DEVICE_ATTR(filter_flags, S_IWUSR | S_IRUGO, il3945_show_filter_flags, il3945_store_filter_flags); -static ssize_t il3945_show_measurement(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il3945_show_measurement(struct device *d, struct device_attribute *attr, + char *buf) { struct il_priv *il = dev_get_drvdata(d); struct il_spectrum_notification measure_report; u32 size = sizeof(measure_report), len = 0, ofs = 0; - u8 *data = (u8 *)&measure_report; + u8 *data = (u8 *) & measure_report; unsigned long flags; spin_lock_irqsave(&il->lock, flags); @@ -3301,9 +3276,9 @@ static ssize_t il3945_show_measurement(struct device *d, return len; } -static ssize_t il3945_store_measurement(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t +il3945_store_measurement(struct device *d, struct device_attribute *attr, + const char *buf, size_t count) { struct il_priv *il = dev_get_drvdata(d); struct il_rxon_context *ctx = &il->ctx; @@ -3330,19 +3305,19 @@ static ssize_t il3945_store_measurement(struct device *d, type = simple_strtoul(p + 1, NULL, 0); } - D_INFO("Invoking measurement of type %d on " - "channel %d (for '%s')\n", type, params.channel, buf); + D_INFO("Invoking measurement of type %d on " "channel %d (for '%s')\n", + type, params.channel, buf); il3945_get_measurement(il, ¶ms, type); return count; } -static DEVICE_ATTR(measurement, S_IRUSR | S_IWUSR, - il3945_show_measurement, il3945_store_measurement); +static DEVICE_ATTR(measurement, S_IRUSR | S_IWUSR, il3945_show_measurement, + il3945_store_measurement); -static ssize_t il3945_store_retry_rate(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t +il3945_store_retry_rate(struct device *d, struct device_attribute *attr, + const char *buf, size_t count) { struct il_priv *il = dev_get_drvdata(d); @@ -3353,8 +3328,9 @@ static ssize_t il3945_store_retry_rate(struct device *d, return count; } -static ssize_t il3945_show_retry_rate(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il3945_show_retry_rate(struct device *d, struct device_attribute *attr, + char *buf) { struct il_priv *il = dev_get_drvdata(d); return sprintf(buf, "%d", il->retry_rate); @@ -3363,9 +3339,8 @@ static ssize_t il3945_show_retry_rate(struct device *d, static DEVICE_ATTR(retry_rate, S_IWUSR | S_IRUSR, il3945_show_retry_rate, il3945_store_retry_rate); - -static ssize_t il3945_show_channels(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il3945_show_channels(struct device *d, struct device_attribute *attr, char *buf) { /* all this shit doesn't belong into sysfs anyway */ return 0; @@ -3373,8 +3348,8 @@ static ssize_t il3945_show_channels(struct device *d, static DEVICE_ATTR(channels, S_IRUSR, il3945_show_channels, NULL); -static ssize_t il3945_show_antenna(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il3945_show_antenna(struct device *d, struct device_attribute *attr, char *buf) { struct il_priv *il = dev_get_drvdata(d); @@ -3384,9 +3359,9 @@ static ssize_t il3945_show_antenna(struct device *d, return sprintf(buf, "%d\n", il3945_mod_params.antenna); } -static ssize_t il3945_store_antenna(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t +il3945_store_antenna(struct device *d, struct device_attribute *attr, + const char *buf, size_t count) { struct il_priv *il __maybe_unused = dev_get_drvdata(d); int ant; @@ -3405,14 +3380,14 @@ static ssize_t il3945_store_antenna(struct device *d, } else D_INFO("Bad antenna select value %d.\n", ant); - return count; } -static DEVICE_ATTR(antenna, S_IWUSR | S_IRUGO, il3945_show_antenna, il3945_store_antenna); +static DEVICE_ATTR(antenna, S_IWUSR | S_IRUGO, il3945_show_antenna, + il3945_store_antenna); -static ssize_t il3945_show_status(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il3945_show_status(struct device *d, struct device_attribute *attr, char *buf) { struct il_priv *il = dev_get_drvdata(d); if (!il_is_alive(il)) @@ -3422,9 +3397,9 @@ static ssize_t il3945_show_status(struct device *d, static DEVICE_ATTR(status, S_IRUGO, il3945_show_status, NULL); -static ssize_t il3945_dump_error_log(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t +il3945_dump_error_log(struct device *d, struct device_attribute *attr, + const char *buf, size_t count) { struct il_priv *il = dev_get_drvdata(d); char *p = (char *)buf; @@ -3443,7 +3418,8 @@ static DEVICE_ATTR(dump_errors, S_IWUSR, NULL, il3945_dump_error_log); * *****************************************************************************/ -static void il3945_setup_deferred_work(struct il_priv *il) +static void +il3945_setup_deferred_work(struct il_priv *il) { il->workqueue = create_singlethread_workqueue(DRV_NAME); @@ -3463,11 +3439,13 @@ static void il3945_setup_deferred_work(struct il_priv *il) il->watchdog.data = (unsigned long)il; il->watchdog.function = il_bg_watchdog; - tasklet_init(&il->irq_tasklet, (void (*)(unsigned long)) - il3945_irq_tasklet, (unsigned long)il); + tasklet_init(&il->irq_tasklet, + (void (*)(unsigned long))il3945_irq_tasklet, + (unsigned long)il); } -static void il3945_cancel_deferred_work(struct il_priv *il) +static void +il3945_cancel_deferred_work(struct il_priv *il) { il3945_hw_cancel_deferred_work(il); @@ -3518,7 +3496,8 @@ struct ieee80211_ops il3945_hw_ops = { .tx_last_beacon = il_mac_tx_last_beacon, }; -static int il3945_init_drv(struct il_priv *il) +static int +il3945_init_drv(struct il_priv *il) { int ret; struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; @@ -3545,7 +3524,7 @@ static int il3945_init_drv(struct il_priv *il) if (eeprom->version < EEPROM_3945_EEPROM_VERSION) { IL_WARN("Unsupported EEPROM version: 0x%04X\n", - eeprom->version); + eeprom->version); ret = -EINVAL; goto err; } @@ -3578,7 +3557,8 @@ err: #define IL3945_MAX_PROBE_REQUEST 200 -static int il3945_setup_mac(struct il_priv *il) +static int +il3945_setup_mac(struct il_priv *il) { int ret; struct ieee80211_hw *hw = il->hw; @@ -3588,15 +3568,13 @@ static int il3945_setup_mac(struct il_priv *il) hw->vif_data_size = sizeof(struct il_vif_priv); /* Tell mac80211 our characteristics */ - hw->flags = IEEE80211_HW_SIGNAL_DBM | - IEEE80211_HW_SPECTRUM_MGMT; + hw->flags = IEEE80211_HW_SIGNAL_DBM | IEEE80211_HW_SPECTRUM_MGMT; - hw->wiphy->interface_modes = - il->ctx.interface_modes; + hw->wiphy->interface_modes = il->ctx.interface_modes; - hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | - WIPHY_FLAG_DISABLE_BEACON_HINTS | - WIPHY_FLAG_IBSS_RSN; + hw->wiphy->flags |= + WIPHY_FLAG_CUSTOM_REGULATORY | WIPHY_FLAG_DISABLE_BEACON_HINTS | + WIPHY_FLAG_IBSS_RSN; hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX_3945; /* we create the 802.11 header and a zero-length SSID element */ @@ -3607,11 +3585,11 @@ static int il3945_setup_mac(struct il_priv *il) if (il->bands[IEEE80211_BAND_2GHZ].n_channels) il->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = - &il->bands[IEEE80211_BAND_2GHZ]; + &il->bands[IEEE80211_BAND_2GHZ]; if (il->bands[IEEE80211_BAND_5GHZ].n_channels) il->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = - &il->bands[IEEE80211_BAND_5GHZ]; + &il->bands[IEEE80211_BAND_5GHZ]; il_leds_init(il); @@ -3625,7 +3603,8 @@ static int il3945_setup_mac(struct il_priv *il) return 0; } -static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) +static int +il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { int err = 0; struct il_priv *il; @@ -3660,8 +3639,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en il->ctx.ap_sta_id = IL_AP_ID; il->ctx.wep_key_cmd = C_WEPKEY; il->ctx.interface_modes = - BIT(NL80211_IFTYPE_STATION) | - BIT(NL80211_IFTYPE_ADHOC); + BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_ADHOC); il->ctx.ibss_devtype = RXON_DEV_TYPE_IBSS; il->ctx.station_devtype = RXON_DEV_TYPE_ESS; il->ctx.unused_devtype = RXON_DEV_TYPE_ESS; @@ -3686,8 +3664,9 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en /*************************** * 2. Initializing PCI bus * *************************/ - pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | - PCIE_LINK_STATE_CLKPM); + pci_disable_link_state(pdev, + PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | + PCIE_LINK_STATE_CLKPM); if (pci_enable_device(pdev)) { err = -ENODEV; @@ -3719,7 +3698,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en } D_INFO("pci_resource_len = 0x%08llx\n", - (unsigned long long) pci_resource_len(pdev, 0)); + (unsigned long long)pci_resource_len(pdev, 0)); D_INFO("pci_resource_base = %p\n", il->hw_base); /* We disable the RETRY_TIMEOUT register (0x41) to keep @@ -3773,8 +3752,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en goto out_unset_hw_params; } - IL_INFO("Detected Intel Wireless WiFi Link %s\n", - il->cfg->name); + IL_INFO("Detected Intel Wireless WiFi Link %s\n", il->cfg->name); /*********************** * 7. Setup Services @@ -3786,8 +3764,7 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en pci_enable_msi(il->pci_dev); - err = request_irq(il->pci_dev->irq, il_isr, - IRQF_SHARED, DRV_NAME, il); + err = request_irq(il->pci_dev->irq, il_isr, IRQF_SHARED, DRV_NAME, il); if (err) { IL_ERR("Error allocating IRQ %d\n", il->pci_dev->irq); goto out_disable_msi; @@ -3799,9 +3776,8 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en goto out_release_irq; } - il_set_rxon_channel(il, - &il->bands[IEEE80211_BAND_2GHZ].channels[5], - &il->ctx); + il_set_rxon_channel(il, &il->bands[IEEE80211_BAND_2GHZ].channels[5], + &il->ctx); il3945_setup_deferred_work(il); il3945_setup_handlers(il); il_power_initialize(il); @@ -3814,47 +3790,48 @@ static int il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *en err = il3945_setup_mac(il); if (err) - goto out_remove_sysfs; + goto out_remove_sysfs; err = il_dbgfs_register(il, DRV_NAME); if (err) - IL_ERR("failed to create debugfs files. Ignoring error: %d\n", err); + IL_ERR("failed to create debugfs files. Ignoring error: %d\n", + err); /* Start monitoring the killswitch */ - queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, - 2 * HZ); + queue_delayed_work(il->workqueue, &il->_3945.rfkill_poll, 2 * HZ); return 0; - out_remove_sysfs: +out_remove_sysfs: destroy_workqueue(il->workqueue); il->workqueue = NULL; sysfs_remove_group(&pdev->dev.kobj, &il3945_attribute_group); - out_release_irq: +out_release_irq: free_irq(il->pci_dev->irq, il); - out_disable_msi: +out_disable_msi: pci_disable_msi(il->pci_dev); il_free_geos(il); il_free_channel_map(il); - out_unset_hw_params: +out_unset_hw_params: il3945_unset_hw_params(il); - out_eeprom_free: +out_eeprom_free: il_eeprom_free(il); - out_iounmap: +out_iounmap: pci_iounmap(pdev, il->hw_base); - out_pci_release_regions: +out_pci_release_regions: pci_release_regions(pdev); - out_pci_disable_device: +out_pci_disable_device: pci_set_drvdata(pdev, NULL); pci_disable_device(pdev); - out_ieee80211_free_hw: +out_ieee80211_free_hw: il_free_traffic_mem(il); ieee80211_free_hw(il->hw); - out: +out: return err; } -static void __devexit il3945_pci_remove(struct pci_dev *pdev) +static void __devexit +il3945_pci_remove(struct pci_dev *pdev) { struct il_priv *il = pci_get_drvdata(pdev); unsigned long flags; @@ -3934,7 +3911,6 @@ static void __devexit il3945_pci_remove(struct pci_dev *pdev) ieee80211_free_hw(il->hw); } - /***************************************************************************** * * driver and module entry point @@ -3949,7 +3925,8 @@ static struct pci_driver il3945_driver = { .driver.pm = IL_LEGACY_PM_OPS, }; -static int __init il3945_init(void) +static int __init +il3945_init(void) { int ret; @@ -3975,7 +3952,8 @@ error_register: return ret; } -static void __exit il3945_exit(void) +static void __exit +il3945_exit(void) { pci_unregister_driver(&il3945_driver); il3945_rate_control_unregister(); @@ -3986,10 +3964,9 @@ MODULE_FIRMWARE(IL3945_MODULE_FIRMWARE(IL3945_UCODE_API_MAX)); module_param_named(antenna, il3945_mod_params.antenna, int, S_IRUGO); MODULE_PARM_DESC(antenna, "select antenna (1=Main, 2=Aux, default 0 [both])"); module_param_named(swcrypto, il3945_mod_params.sw_crypto, int, S_IRUGO); -MODULE_PARM_DESC(swcrypto, - "using software crypto (default 1 [software])"); -module_param_named(disable_hw_scan, il3945_mod_params.disable_hw_scan, - int, S_IRUGO); +MODULE_PARM_DESC(swcrypto, "using software crypto (default 1 [software])"); +module_param_named(disable_hw_scan, il3945_mod_params.disable_hw_scan, int, + S_IRUGO); MODULE_PARM_DESC(disable_hw_scan, "disable hardware scanning (default 1)"); #ifdef CONFIG_IWLEGACY_DEBUG module_param_named(debug, il_debug_level, uint, S_IRUGO | S_IWUSR); diff --git a/drivers/net/wireless/iwlegacy/3945-rs.c b/drivers/net/wireless/iwlegacy/3945-rs.c index dc0dfdd520ab..3420b1c0ee0c 100644 --- a/drivers/net/wireless/iwlegacy/3945-rs.c +++ b/drivers/net/wireless/iwlegacy/3945-rs.c @@ -97,7 +97,8 @@ static struct il3945_tpt_entry il3945_tpt_table_g[] = { #define RATE_DECREASE_TH 1920 #define RATE_RETRY_TH 15 -static u8 il3945_get_rate_idx_by_rssi(s32 rssi, enum ieee80211_band band) +static u8 +il3945_get_rate_idx_by_rssi(s32 rssi, enum ieee80211_band band) { u32 idx = 0; u32 table_size = 0; @@ -130,7 +131,8 @@ static u8 il3945_get_rate_idx_by_rssi(s32 rssi, enum ieee80211_band band) return tpt_table[idx].idx; } -static void il3945_clear_win(struct il3945_rate_scale_data *win) +static void +il3945_clear_win(struct il3945_rate_scale_data *win) { win->data = 0; win->success_counter = 0; @@ -147,7 +149,8 @@ static void il3945_clear_win(struct il3945_rate_scale_data *win) * not flushed. If there were any that were not flushed, then * reschedule the rate flushing routine. */ -static int il3945_rate_scale_flush_wins(struct il3945_rs_sta *rs_sta) +static int +il3945_rate_scale_flush_wins(struct il3945_rs_sta *rs_sta) { int unflushed = 0; int i; @@ -164,11 +167,9 @@ static int il3945_rate_scale_flush_wins(struct il3945_rs_sta *rs_sta) continue; spin_lock_irqsave(&rs_sta->lock, flags); - if (time_after(jiffies, rs_sta->win[i].stamp + - RATE_WIN_FLUSH)) { - D_RATE("flushing %d samples of rate " - "idx %d\n", - rs_sta->win[i].counter, i); + if (time_after(jiffies, rs_sta->win[i].stamp + RATE_WIN_FLUSH)) { + D_RATE("flushing %d samples of rate " "idx %d\n", + rs_sta->win[i].counter, i); il3945_clear_win(&rs_sta->win[i]); } else unflushed++; @@ -182,7 +183,8 @@ static int il3945_rate_scale_flush_wins(struct il3945_rs_sta *rs_sta) #define RATE_FLUSH_MIN 50 /* msec */ #define IL_AVERAGE_PACKETS 1500 -static void il3945_bg_rate_scale_flush(unsigned long data) +static void +il3945_bg_rate_scale_flush(unsigned long data) { struct il3945_rs_sta *rs_sta = (void *)data; struct il_priv *il __maybe_unused = rs_sta->il; @@ -205,8 +207,7 @@ static void il3945_bg_rate_scale_flush(unsigned long data) duration = jiffies_to_msecs(jiffies - rs_sta->last_partial_flush); - D_RATE("Tx'd %d packets in %dms\n", - packet_count, duration); + D_RATE("Tx'd %d packets in %dms\n", packet_count, duration); /* Determine packets per second */ if (duration) @@ -225,11 +226,11 @@ static void il3945_bg_rate_scale_flush(unsigned long data) rs_sta->flush_time = msecs_to_jiffies(duration); - D_RATE("new flush period: %d msec ave %d\n", - duration, packet_count); + D_RATE("new flush period: %d msec ave %d\n", duration, + packet_count); - mod_timer(&rs_sta->rate_scale_flush, jiffies + - rs_sta->flush_time); + mod_timer(&rs_sta->rate_scale_flush, + jiffies + rs_sta->flush_time); rs_sta->last_partial_flush = jiffies; } else { @@ -253,9 +254,10 @@ static void il3945_bg_rate_scale_flush(unsigned long data) * at this rate. win->data contains the bitmask of successful * packets. */ -static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, - struct il3945_rate_scale_data *win, - int success, int retries, int idx) +static void +il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, + struct il3945_rate_scale_data *win, int success, + int retries, int idx) { unsigned long flags; s32 fail_count; @@ -306,8 +308,8 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, /* Calculate current success ratio, avoid divide-by-0! */ if (win->counter > 0) - win->success_ratio = 128 * (100 * win->success_counter) - / win->counter; + win->success_ratio = + 128 * (100 * win->success_counter) / win->counter; else win->success_ratio = IL_INVALID_VALUE; @@ -316,8 +318,9 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, /* Calculate average throughput, if we have enough history. */ if (fail_count >= RATE_MIN_FAILURE_TH || win->success_counter >= RATE_MIN_SUCCESS_TH) - win->average_tpt = ((win->success_ratio * - rs_sta->expected_tpt[idx] + 64) / 128); + win->average_tpt = + ((win->success_ratio * rs_sta->expected_tpt[idx] + + 64) / 128); else win->average_tpt = IL_INVALID_VALUE; @@ -331,7 +334,8 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta, /* * Called after adding a new station to initialize rate scaling */ -void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_id) +void +il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_id) { struct ieee80211_hw *hw = il->hw; struct ieee80211_conf *conf = &il->hw->conf; @@ -344,7 +348,7 @@ void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_i if (sta_id == il->ctx.bcast_sta_id) goto out; - psta = (struct il3945_sta_priv *) sta->drv_priv; + psta = (struct il3945_sta_priv *)sta->drv_priv; rs_sta = &psta->rs_sta; sband = hw->wiphy->bands[conf->channel->band]; @@ -382,8 +386,8 @@ void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_i /* For 5 GHz band it start at IL_FIRST_OFDM_RATE */ if (sband->band == IEEE80211_BAND_5GHZ) { rs_sta->last_txrate_idx += IL_FIRST_OFDM_RATE; - il->_3945.sta_supp_rates = il->_3945.sta_supp_rates << - IL_FIRST_OFDM_RATE; + il->_3945.sta_supp_rates = + il->_3945.sta_supp_rates << IL_FIRST_OFDM_RATE; } out: @@ -392,21 +396,24 @@ out: D_INFO("leave\n"); } -static void *il3945_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) +static void * +il3945_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) { return hw->priv; } /* rate scale requires free function to be implemented */ -static void il3945_rs_free(void *il) +static void +il3945_rs_free(void *il) { return; } -static void *il3945_rs_alloc_sta(void *il_priv, struct ieee80211_sta *sta, gfp_t gfp) +static void * +il3945_rs_alloc_sta(void *il_priv, struct ieee80211_sta *sta, gfp_t gfp) { struct il3945_rs_sta *rs_sta; - struct il3945_sta_priv *psta = (void *) sta->drv_priv; + struct il3945_sta_priv *psta = (void *)sta->drv_priv; struct il_priv *il __maybe_unused = il_priv; D_RATE("enter\n"); @@ -421,8 +428,8 @@ static void *il3945_rs_alloc_sta(void *il_priv, struct ieee80211_sta *sta, gfp_t return rs_sta; } -static void il3945_rs_free_sta(void *il_priv, struct ieee80211_sta *sta, - void *il_sta) +static void +il3945_rs_free_sta(void *il_priv, struct ieee80211_sta *sta, void *il_sta) { struct il3945_rs_sta *rs_sta = il_sta; @@ -434,16 +441,16 @@ static void il3945_rs_free_sta(void *il_priv, struct ieee80211_sta *sta, del_timer_sync(&rs_sta->rate_scale_flush); } - /** * il3945_rs_tx_status - Update rate control values based on Tx results * * NOTE: Uses il_priv->retry_rate for the # of retries attempted by * the hardware for each rate. */ -static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, void *il_sta, - struct sk_buff *skb) +static void +il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band *sband, + struct ieee80211_sta *sta, void *il_sta, + struct sk_buff *skb) { s8 retries = 0, current_count; int scale_rate_idx, first_idx, last_idx; @@ -476,7 +483,6 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * return; } - rs_sta->tx_packets++; scale_rate_idx = first_idx; @@ -498,32 +504,27 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * last_idx = scale_rate_idx; } else { current_count = il->retry_rate; - last_idx = il3945_rs_next_rate(il, - scale_rate_idx); + last_idx = il3945_rs_next_rate(il, scale_rate_idx); } /* Update this rate accounting for as many retries * as was used for it (per current_count) */ - il3945_collect_tx_data(rs_sta, - &rs_sta->win[scale_rate_idx], - 0, current_count, scale_rate_idx); - D_RATE("Update rate %d for %d retries.\n", - scale_rate_idx, current_count); + il3945_collect_tx_data(rs_sta, &rs_sta->win[scale_rate_idx], 0, + current_count, scale_rate_idx); + D_RATE("Update rate %d for %d retries.\n", scale_rate_idx, + current_count); retries -= current_count; scale_rate_idx = last_idx; } - /* Update the last idx win with success/failure based on ACK */ - D_RATE("Update rate %d with %s.\n", - last_idx, - (info->flags & IEEE80211_TX_STAT_ACK) ? - "success" : "failure"); - il3945_collect_tx_data(rs_sta, - &rs_sta->win[last_idx], - info->flags & IEEE80211_TX_STAT_ACK, 1, last_idx); + D_RATE("Update rate %d with %s.\n", last_idx, + (info->flags & IEEE80211_TX_STAT_ACK) ? "success" : "failure"); + il3945_collect_tx_data(rs_sta, &rs_sta->win[last_idx], + info->flags & IEEE80211_TX_STAT_ACK, 1, + last_idx); /* We updated the rate scale win -- if its been more than * flush_time since the last run, schedule the flush @@ -531,8 +532,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * spin_lock_irqsave(&rs_sta->lock, flags); if (!rs_sta->flush_pending && - time_after(jiffies, rs_sta->last_flush + - rs_sta->flush_time)) { + time_after(jiffies, rs_sta->last_flush + rs_sta->flush_time)) { rs_sta->last_partial_flush = jiffies; rs_sta->flush_pending = 1; @@ -545,8 +545,9 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band * D_RATE("leave\n"); } -static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, - u8 idx, u16 rate_mask, enum ieee80211_band band) +static u16 +il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, u8 idx, u16 rate_mask, + enum ieee80211_band band) { u8 high = RATE_INVALID; u8 low = RATE_INVALID; @@ -569,8 +570,7 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, /* Find the next rate that is in the rate mask */ i = idx + 1; - for (mask = (1 << i); i < RATE_COUNT_3945; - i++, mask <<= 1) { + for (mask = (1 << i); i < RATE_COUNT_3945; i++, mask <<= 1) { if (rate_mask & mask) { high = i; break; @@ -625,8 +625,9 @@ static u16 il3945_get_adjacent_rate(struct il3945_rs_sta *rs_sta, * rate table and must reference the driver allocated rate table * */ -static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, - void *il_sta, struct ieee80211_tx_rate_control *txrc) +static void +il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, + struct ieee80211_tx_rate_control *txrc) { struct ieee80211_supported_band *sband = txrc->sband; struct sk_buff *skb = txrc->skb; @@ -679,7 +680,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, */ if (rs_sta->start_rate != RATE_INVALID) { if (rs_sta->start_rate < idx && - (rate_mask & (1 << rs_sta->start_rate))) + (rate_mask & (1 << rs_sta->start_rate))) idx = rs_sta->start_rate; rs_sta->start_rate = RATE_INVALID; } @@ -699,14 +700,12 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, spin_unlock_irqrestore(&rs_sta->lock, flags); D_RATE("Invalid average_tpt on rate %d: " - "counter: %d, success_counter: %d, " - "expected_tpt is %sNULL\n", - idx, - win->counter, - win->success_counter, - rs_sta->expected_tpt ? "not " : ""); - - /* Can't calculate this yet; not enough history */ + "counter: %d, success_counter: %d, " + "expected_tpt is %sNULL\n", idx, win->counter, + win->success_counter, + rs_sta->expected_tpt ? "not " : ""); + + /* Can't calculate this yet; not enough history */ win->average_tpt = IL_INVALID_VALUE; goto out; @@ -714,8 +713,8 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, current_tpt = win->average_tpt; - high_low = il3945_get_adjacent_rate(rs_sta, idx, rate_mask, - sband->band); + high_low = + il3945_get_adjacent_rate(rs_sta, idx, rate_mask, sband->band); low = high_low & 0xff; high = (high_low >> 8) & 0xff; @@ -738,46 +737,42 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, if (win->success_ratio < RATE_DECREASE_TH || !current_tpt) { D_RATE("decrease rate because of low success_ratio\n"); scale_action = -1; - /* No throughput measured yet for adjacent rates, - * try increase */ - } else if (low_tpt == IL_INVALID_VALUE && - high_tpt == IL_INVALID_VALUE) { + /* No throughput measured yet for adjacent rates, + * try increase */ + } else if (low_tpt == IL_INVALID_VALUE && high_tpt == IL_INVALID_VALUE) { - if (high != RATE_INVALID && win->success_ratio >= RATE_INCREASE_TH) + if (high != RATE_INVALID && + win->success_ratio >= RATE_INCREASE_TH) scale_action = 1; else if (low != RATE_INVALID) scale_action = 0; - /* Both adjacent throughputs are measured, but neither one has - * better throughput; we're using the best rate, don't change - * it! */ - } else if (low_tpt != IL_INVALID_VALUE && - high_tpt != IL_INVALID_VALUE && - low_tpt < current_tpt && high_tpt < current_tpt) { + /* Both adjacent throughputs are measured, but neither one has + * better throughput; we're using the best rate, don't change + * it! */ + } else if (low_tpt != IL_INVALID_VALUE && high_tpt != IL_INVALID_VALUE + && low_tpt < current_tpt && high_tpt < current_tpt) { D_RATE("No action -- low [%d] & high [%d] < " - "current_tpt [%d]\n", - low_tpt, high_tpt, current_tpt); + "current_tpt [%d]\n", low_tpt, high_tpt, current_tpt); scale_action = 0; - /* At least one of the rates has better throughput */ + /* At least one of the rates has better throughput */ } else { if (high_tpt != IL_INVALID_VALUE) { /* High rate has better throughput, Increase * rate */ if (high_tpt > current_tpt && - win->success_ratio >= RATE_INCREASE_TH) + win->success_ratio >= RATE_INCREASE_TH) scale_action = 1; else { - D_RATE( - "decrease rate because of high tpt\n"); + D_RATE("decrease rate because of high tpt\n"); scale_action = 0; } } else if (low_tpt != IL_INVALID_VALUE) { if (low_tpt > current_tpt) { - D_RATE( - "decrease rate because of low tpt\n"); + D_RATE("decrease rate because of low tpt\n"); scale_action = -1; } else if (win->success_ratio >= RATE_INCREASE_TH) { /* Lower rate has better @@ -815,10 +810,10 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, break; } - D_RATE("Selected %d (action %d) - low %d high %d\n", - idx, scale_action, low, high); + D_RATE("Selected %d (action %d) - low %d high %d\n", idx, scale_action, + low, high); - out: +out: if (sband->band == IEEE80211_BAND_5GHZ) { if (WARN_ON_ONCE(idx < IL_FIRST_OFDM_RATE)) @@ -834,15 +829,16 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta, } #ifdef CONFIG_MAC80211_DEBUGFS -static int il3945_open_file_generic(struct inode *inode, struct file *file) +static int +il3945_open_file_generic(struct inode *inode, struct file *file) { file->private_data = inode->i_private; return 0; } -static ssize_t il3945_sta_dbgfs_stats_table_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il3945_sta_dbgfs_stats_table_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { char *buff; int desc = 0; @@ -854,17 +850,18 @@ static ssize_t il3945_sta_dbgfs_stats_table_read(struct file *file, if (!buff) return -ENOMEM; - desc += sprintf(buff + desc, "tx packets=%d last rate idx=%d\n" - "rate=0x%X flush time %d\n", - lq_sta->tx_packets, - lq_sta->last_txrate_idx, - lq_sta->start_rate, jiffies_to_msecs(lq_sta->flush_time)); + desc += + sprintf(buff + desc, + "tx packets=%d last rate idx=%d\n" + "rate=0x%X flush time %d\n", lq_sta->tx_packets, + lq_sta->last_txrate_idx, lq_sta->start_rate, + jiffies_to_msecs(lq_sta->flush_time)); for (j = 0; j < RATE_COUNT_3945; j++) { - desc += sprintf(buff+desc, - "counter=%d success=%d %%=%d\n", - lq_sta->win[j].counter, - lq_sta->win[j].success_counter, - lq_sta->win[j].success_ratio); + desc += + sprintf(buff + desc, "counter=%d success=%d %%=%d\n", + lq_sta->win[j].counter, + lq_sta->win[j].success_counter, + lq_sta->win[j].success_ratio); } ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); kfree(buff); @@ -877,18 +874,19 @@ static const struct file_operations rs_sta_dbgfs_stats_table_ops = { .llseek = default_llseek, }; -static void il3945_add_debugfs(void *il, void *il_sta, - struct dentry *dir) +static void +il3945_add_debugfs(void *il, void *il_sta, struct dentry *dir) { struct il3945_rs_sta *lq_sta = il_sta; lq_sta->rs_sta_dbgfs_stats_table_file = - debugfs_create_file("rate_stats_table", 0600, dir, - lq_sta, &rs_sta_dbgfs_stats_table_ops); + debugfs_create_file("rate_stats_table", 0600, dir, lq_sta, + &rs_sta_dbgfs_stats_table_ops); } -static void il3945_remove_debugfs(void *il, void *il_sta) +static void +il3945_remove_debugfs(void *il, void *il_sta) { struct il3945_rs_sta *lq_sta = il_sta; debugfs_remove(lq_sta->rs_sta_dbgfs_stats_table_file); @@ -900,9 +898,9 @@ static void il3945_remove_debugfs(void *il, void *il_sta) * the station is added. Since mac80211 calls this function before a * station is added we ignore it. */ -static void il3945_rs_rate_init_stub(void *il_r, - struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, void *il_sta) +static void +il3945_rs_rate_init_stub(void *il_r, struct ieee80211_supported_band *sband, + struct ieee80211_sta *sta, void *il_sta) { } @@ -922,7 +920,9 @@ static struct rate_control_ops rs_ops = { #endif }; -void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) + +void +il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) { struct il_priv *il = hw->priv; s32 rssi = 0; @@ -935,15 +935,15 @@ void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) rcu_read_lock(); - sta = ieee80211_find_sta(il->ctx.vif, - il->stations[sta_id].sta.sta.addr); + sta = + ieee80211_find_sta(il->ctx.vif, il->stations[sta_id].sta.sta.addr); if (!sta) { D_RATE("Unable to find station to initialize rate scaling.\n"); rcu_read_unlock(); return; } - psta = (void *) sta->drv_priv; + psta = (void *)sta->drv_priv; rs_sta = &psta->rs_sta; spin_lock_irqsave(&rs_sta->lock, flags); @@ -952,8 +952,7 @@ void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) switch (il->band) { case IEEE80211_BAND_2GHZ: /* TODO: this always does G, not a regression */ - if (il->ctx.active.flags & - RXON_FLG_TGG_PROTECT_MSK) { + if (il->ctx.active.flags & RXON_FLG_TGG_PROTECT_MSK) { rs_sta->tgg = 1; rs_sta->expected_tpt = il3945_expected_tpt_g_prot; } else @@ -978,18 +977,19 @@ void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id) rs_sta->start_rate = il3945_get_rate_idx_by_rssi(rssi, il->band); - D_RATE("leave: rssi %d assign rate idx: " - "%d (plcp 0x%x)\n", rssi, rs_sta->start_rate, - il3945_rates[rs_sta->start_rate].plcp); + D_RATE("leave: rssi %d assign rate idx: " "%d (plcp 0x%x)\n", rssi, + rs_sta->start_rate, il3945_rates[rs_sta->start_rate].plcp); rcu_read_unlock(); } -int il3945_rate_control_register(void) +int +il3945_rate_control_register(void) { return ieee80211_rate_control_register(&rs_ops); } -void il3945_rate_control_unregister(void) +void +il3945_rate_control_unregister(void) { ieee80211_rate_control_unregister(&rs_ops); } diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index b1ced05ab3d3..7f0b9f56f4be 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -43,8 +43,8 @@ #include "3945.h" /* Send led command */ -static int il3945_send_led_cmd(struct il_priv *il, - struct il_led_cmd *led_cmd) +static int +il3945_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd) { struct il_host_cmd cmd = { .id = C_LEDS, @@ -82,21 +82,22 @@ const struct il_led_ops il3945_led_ops = { * */ const struct il3945_rate_info il3945_rates[RATE_COUNT_3945] = { - IL_DECLARE_RATE_INFO(1, INV, 2, INV, 2, INV, 2), /* 1mbps */ - IL_DECLARE_RATE_INFO(2, 1, 5, 1, 5, 1, 5), /* 2mbps */ - IL_DECLARE_RATE_INFO(5, 2, 6, 2, 11, 2, 11), /*5.5mbps */ - IL_DECLARE_RATE_INFO(11, 9, 12, 5, 12, 5, 18), /* 11mbps */ - IL_DECLARE_RATE_INFO(6, 5, 9, 5, 11, 5, 11), /* 6mbps */ - IL_DECLARE_RATE_INFO(9, 6, 11, 5, 11, 5, 11), /* 9mbps */ - IL_DECLARE_RATE_INFO(12, 11, 18, 11, 18, 11, 18), /* 12mbps */ - IL_DECLARE_RATE_INFO(18, 12, 24, 12, 24, 11, 24), /* 18mbps */ - IL_DECLARE_RATE_INFO(24, 18, 36, 18, 36, 18, 36), /* 24mbps */ - IL_DECLARE_RATE_INFO(36, 24, 48, 24, 48, 24, 48), /* 36mbps */ - IL_DECLARE_RATE_INFO(48, 36, 54, 36, 54, 36, 54), /* 48mbps */ - IL_DECLARE_RATE_INFO(54, 48, INV, 48, INV, 48, INV),/* 54mbps */ + IL_DECLARE_RATE_INFO(1, INV, 2, INV, 2, INV, 2), /* 1mbps */ + IL_DECLARE_RATE_INFO(2, 1, 5, 1, 5, 1, 5), /* 2mbps */ + IL_DECLARE_RATE_INFO(5, 2, 6, 2, 11, 2, 11), /*5.5mbps */ + IL_DECLARE_RATE_INFO(11, 9, 12, 5, 12, 5, 18), /* 11mbps */ + IL_DECLARE_RATE_INFO(6, 5, 9, 5, 11, 5, 11), /* 6mbps */ + IL_DECLARE_RATE_INFO(9, 6, 11, 5, 11, 5, 11), /* 9mbps */ + IL_DECLARE_RATE_INFO(12, 11, 18, 11, 18, 11, 18), /* 12mbps */ + IL_DECLARE_RATE_INFO(18, 12, 24, 12, 24, 11, 24), /* 18mbps */ + IL_DECLARE_RATE_INFO(24, 18, 36, 18, 36, 18, 36), /* 24mbps */ + IL_DECLARE_RATE_INFO(36, 24, 48, 24, 48, 24, 48), /* 36mbps */ + IL_DECLARE_RATE_INFO(48, 36, 54, 36, 54, 36, 54), /* 48mbps */ + IL_DECLARE_RATE_INFO(54, 48, INV, 48, INV, 48, INV), /* 54mbps */ }; -static inline u8 il3945_get_prev_ieee_rate(u8 rate_idx) +static inline u8 +il3945_get_prev_ieee_rate(u8 rate_idx) { u8 rate = il3945_rates[rate_idx].prev_ieee; @@ -118,7 +119,8 @@ static inline u8 il3945_get_prev_ieee_rate(u8 rate_idx) * Use for only special debugging. This function is just a placeholder as-is, * you'll need to provide the special bits! ... * ... and set IL_EVT_DISABLE to 1. */ -void il3945_disable_events(struct il_priv *il) +void +il3945_disable_events(struct il_priv *il) { int i; u32 base; /* SRAM address of event log header */ @@ -185,22 +187,22 @@ void il3945_disable_events(struct il_priv *il) if (IL_EVT_DISABLE && array_size == IL_EVT_DISABLE_SIZE) { D_INFO("Disabling selected uCode log events at 0x%x\n", - disable_ptr); + disable_ptr); for (i = 0; i < IL_EVT_DISABLE_SIZE; i++) - il_write_targ_mem(il, - disable_ptr + (i * sizeof(u32)), - evt_disable[i]); + il_write_targ_mem(il, disable_ptr + (i * sizeof(u32)), + evt_disable[i]); } else { D_INFO("Selected uCode log events may be disabled\n"); D_INFO(" by writing \"1\"s into disable bitmap\n"); - D_INFO(" in SRAM at 0x%x, size %d u32s\n", - disable_ptr, array_size); + D_INFO(" in SRAM at 0x%x, size %d u32s\n", disable_ptr, + array_size); } } -static int il3945_hwrate_to_plcp_idx(u8 plcp) +static int +il3945_hwrate_to_plcp_idx(u8 plcp) { int idx; @@ -213,7 +215,8 @@ static int il3945_hwrate_to_plcp_idx(u8 plcp) #ifdef CONFIG_IWLEGACY_DEBUG #define TX_STATUS_ENTRY(x) case TX_3945_STATUS_FAIL_ ## x: return #x -static const char *il3945_get_tx_fail_reason(u32 status) +static const char * +il3945_get_tx_fail_reason(u32 status) { switch (status & TX_STATUS_MSK) { case TX_3945_STATUS_SUCCESS: @@ -239,7 +242,8 @@ static const char *il3945_get_tx_fail_reason(u32 status) return "UNKNOWN"; } #else -static inline const char *il3945_get_tx_fail_reason(u32 status) +static inline const char * +il3945_get_tx_fail_reason(u32 status) { return ""; } @@ -250,7 +254,8 @@ static inline const char *il3945_get_tx_fail_reason(u32 status) * for A and B mode we need to overright prev * value */ -int il3945_rs_next_rate(struct il_priv *il, int rate) +int +il3945_rs_next_rate(struct il_priv *il, int rate) { int next_rate = il3945_get_prev_ieee_rate(rate); @@ -276,7 +281,6 @@ int il3945_rs_next_rate(struct il_priv *il, int rate) return next_rate; } - /** * il3945_tx_queue_reclaim - Reclaim Tx queue entries already Tx'd * @@ -284,8 +288,8 @@ int il3945_rs_next_rate(struct il_priv *il, int rate) * need to be reclaimed. As result, some free space forms. If there is * enough free space (> low mark), wake the stack that feeds us. */ -static void il3945_tx_queue_reclaim(struct il_priv *il, - int txq_id, int idx) +static void +il3945_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx) { struct il_tx_queue *txq = &il->txq[txq_id]; struct il_queue *q = &txq->q; @@ -293,9 +297,8 @@ static void il3945_tx_queue_reclaim(struct il_priv *il, BUG_ON(txq_id == IL39_CMD_QUEUE_NUM); - for (idx = il_queue_inc_wrap(idx, q->n_bd); - q->read_ptr != idx; - q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { + for (idx = il_queue_inc_wrap(idx, q->n_bd); q->read_ptr != idx; + q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { tx_info = &txq->txb[txq->q.read_ptr]; ieee80211_tx_status_irqsafe(il->hw, tx_info->skb); @@ -311,8 +314,8 @@ static void il3945_tx_queue_reclaim(struct il_priv *il, /** * il3945_hdl_tx - Handle Tx response */ -static void il3945_hdl_tx(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il3945_hdl_tx(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); @@ -321,15 +324,14 @@ static void il3945_hdl_tx(struct il_priv *il, struct il_tx_queue *txq = &il->txq[txq_id]; struct ieee80211_tx_info *info; struct il3945_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; - u32 status = le32_to_cpu(tx_resp->status); + u32 status = le32_to_cpu(tx_resp->status); int rate_idx; int fail; if (idx >= txq->q.n_bd || il_queue_used(&txq->q, idx) == 0) { IL_ERR("Read idx for DMA queue txq_id (%d) idx %d " - "is out of range [0-%d] %d %d\n", txq_id, - idx, txq->q.n_bd, txq->q.write_ptr, - txq->q.read_ptr); + "is out of range [0-%d] %d %d\n", txq_id, idx, + txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr); return; } @@ -345,15 +347,16 @@ static void il3945_hdl_tx(struct il_priv *il, fail = tx_resp->failure_frame; info->status.rates[0].idx = rate_idx; - info->status.rates[0].count = fail + 1; /* add final attempt */ + info->status.rates[0].count = fail + 1; /* add final attempt */ /* tx_status->rts_retry_count = tx_resp->failure_rts; */ - info->flags |= ((status & TX_STATUS_MSK) == TX_STATUS_SUCCESS) ? - IEEE80211_TX_STAT_ACK : 0; + info->flags |= + ((status & TX_STATUS_MSK) == + TX_STATUS_SUCCESS) ? IEEE80211_TX_STAT_ACK : 0; - D_TX("Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", - txq_id, il3945_get_tx_fail_reason(status), status, - tx_resp->rate, tx_resp->failure_frame); + D_TX("Tx queue %d Status %s (0x%08x) plcp rate %d retries %d\n", txq_id, + il3945_get_tx_fail_reason(status), status, tx_resp->rate, + tx_resp->failure_frame); D_TX_REPLY("Tx queue reclaim %d\n", idx); il3945_tx_queue_reclaim(il, txq_id, idx); @@ -362,8 +365,6 @@ static void il3945_hdl_tx(struct il_priv *il, IL_ERR("TODO: Implement Tx ABORT REQUIRED!!!\n"); } - - /***************************************************************************** * * Intel PRO/Wireless 3945ABG/BG Network Connection @@ -372,25 +373,26 @@ static void il3945_hdl_tx(struct il_priv *il, * *****************************************************************************/ #ifdef CONFIG_IWLEGACY_DEBUGFS -static void il3945_accumulative_stats(struct il_priv *il, - __le32 *stats) +static void +il3945_accumulative_stats(struct il_priv *il, __le32 * stats) { int i; __le32 *prev_stats; u32 *accum_stats; u32 *delta, *max_delta; - prev_stats = (__le32 *)&il->_3945.stats; - accum_stats = (u32 *)&il->_3945.accum_stats; - delta = (u32 *)&il->_3945.delta_stats; - max_delta = (u32 *)&il->_3945.max_delta; + prev_stats = (__le32 *) & il->_3945.stats; + accum_stats = (u32 *) & il->_3945.accum_stats; + delta = (u32 *) & il->_3945.delta_stats; + max_delta = (u32 *) & il->_3945.max_delta; for (i = sizeof(__le32); i < sizeof(struct il3945_notif_stats); - i += sizeof(__le32), stats++, prev_stats++, delta++, - max_delta++, accum_stats++) { + i += + sizeof(__le32), stats++, prev_stats++, delta++, max_delta++, + accum_stats++) { if (le32_to_cpu(*stats) > le32_to_cpu(*prev_stats)) { - *delta = (le32_to_cpu(*stats) - - le32_to_cpu(*prev_stats)); + *delta = + (le32_to_cpu(*stats) - le32_to_cpu(*prev_stats)); *accum_stats += *delta; if (*delta > *max_delta) *max_delta = *delta; @@ -399,48 +401,47 @@ static void il3945_accumulative_stats(struct il_priv *il, /* reset accumulative stats for "no-counter" type stats */ il->_3945.accum_stats.general.temperature = - il->_3945.stats.general.temperature; + il->_3945.stats.general.temperature; il->_3945.accum_stats.general.ttl_timestamp = - il->_3945.stats.general.ttl_timestamp; + il->_3945.stats.general.ttl_timestamp; } #endif -void il3945_hdl_stats(struct il_priv *il, - struct il_rx_buf *rxb) +void +il3945_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); D_RX("Statistics notification received (%d vs %d).\n", - (int)sizeof(struct il3945_notif_stats), - le32_to_cpu(pkt->len_n_flags) & IL_RX_FRAME_SIZE_MSK); + (int)sizeof(struct il3945_notif_stats), + le32_to_cpu(pkt->len_n_flags) & IL_RX_FRAME_SIZE_MSK); #ifdef CONFIG_IWLEGACY_DEBUGFS - il3945_accumulative_stats(il, (__le32 *)&pkt->u.raw); + il3945_accumulative_stats(il, (__le32 *) & pkt->u.raw); #endif memcpy(&il->_3945.stats, pkt->u.raw, sizeof(il->_3945.stats)); } -void il3945_hdl_c_stats(struct il_priv *il, - struct il_rx_buf *rxb) +void +il3945_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); - __le32 *flag = (__le32 *)&pkt->u.raw; + __le32 *flag = (__le32 *) & pkt->u.raw; if (le32_to_cpu(*flag) & UCODE_STATS_CLEAR_MSK) { #ifdef CONFIG_IWLEGACY_DEBUGFS memset(&il->_3945.accum_stats, 0, - sizeof(struct il3945_notif_stats)); + sizeof(struct il3945_notif_stats)); memset(&il->_3945.delta_stats, 0, - sizeof(struct il3945_notif_stats)); + sizeof(struct il3945_notif_stats)); memset(&il->_3945.max_delta, 0, - sizeof(struct il3945_notif_stats)); + sizeof(struct il3945_notif_stats)); #endif D_RX("Statistics have been cleared\n"); } il3945_hdl_stats(il, rxb); } - /****************************************************************************** * * Misc. internal state and helper functions @@ -448,16 +449,16 @@ void il3945_hdl_c_stats(struct il_priv *il, ******************************************************************************/ /* This is necessary only for a number of stats, see the caller. */ -static int il3945_is_network_packet(struct il_priv *il, - struct ieee80211_hdr *header) +static int +il3945_is_network_packet(struct il_priv *il, struct ieee80211_hdr *header) { /* Filter incoming packets to determine if they are targeted toward * this network, discarding packets coming from ourselves */ switch (il->iw_mode) { - case NL80211_IFTYPE_ADHOC: /* Header: Dest. | Source | BSSID */ + case NL80211_IFTYPE_ADHOC: /* Header: Dest. | Source | BSSID */ /* packets to our IBSS update information */ return !compare_ether_addr(header->addr3, il->bssid); - case NL80211_IFTYPE_STATION: /* Header: Dest. | AP{BSSID} | Source */ + case NL80211_IFTYPE_STATION: /* Header: Dest. | AP{BSSID} | Source */ /* packets to our IBSS update information */ return !compare_ether_addr(header->addr2, il->bssid); default: @@ -465,9 +466,9 @@ static int il3945_is_network_packet(struct il_priv *il, } } -static void il3945_pass_packet_to_mac80211(struct il_priv *il, - struct il_rx_buf *rxb, - struct ieee80211_rx_status *stats) +static void +il3945_pass_packet_to_mac80211(struct il_priv *il, struct il_rx_buf *rxb, + struct ieee80211_rx_status *stats) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)IL_RX_DATA(pkt); @@ -478,16 +479,16 @@ static void il3945_pass_packet_to_mac80211(struct il_priv *il, __le16 fc = hdr->frame_control; /* We received data from the HW, so stop the watchdog */ - if (unlikely(len + IL39_RX_FRAME_SIZE > - PAGE_SIZE << il->hw_params.rx_page_order)) { + if (unlikely + (len + IL39_RX_FRAME_SIZE > + PAGE_SIZE << il->hw_params.rx_page_order)) { D_DROP("Corruption detected!\n"); return; } /* We only process data packets if the interface is open */ if (unlikely(!il->is_open)) { - D_DROP( - "Dropping packet while interface is not open.\n"); + D_DROP("Dropping packet while interface is not open.\n"); return; } @@ -498,9 +499,8 @@ static void il3945_pass_packet_to_mac80211(struct il_priv *il, } if (!il3945_mod_params.sw_crypto) - il_set_decrypted_flag(il, - (struct ieee80211_hdr *)rxb_addr(rxb), - le32_to_cpu(rx_end->status), stats); + il_set_decrypted_flag(il, (struct ieee80211_hdr *)rxb_addr(rxb), + le32_to_cpu(rx_end->status), stats); skb_add_rx_frag(skb, 0, rxb->page, (void *)rx_hdr->payload - (void *)pkt, len); @@ -515,8 +515,8 @@ static void il3945_pass_packet_to_mac80211(struct il_priv *il, #define IL_DELAY_NEXT_SCAN_AFTER_ASSOC (HZ*6) -static void il3945_hdl_rx(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il3945_hdl_rx(struct il_priv *il, struct il_rx_buf *rxb) { struct ieee80211_hdr *header; struct ieee80211_rx_status rx_status; @@ -525,23 +525,27 @@ static void il3945_hdl_rx(struct il_priv *il, struct il3945_rx_frame_hdr *rx_hdr = IL_RX_HDR(pkt); struct il3945_rx_frame_end *rx_end = IL_RX_END(pkt); u16 rx_stats_sig_avg __maybe_unused = le16_to_cpu(rx_stats->sig_avg); - u16 rx_stats_noise_diff __maybe_unused = le16_to_cpu(rx_stats->noise_diff); + u16 rx_stats_noise_diff __maybe_unused = + le16_to_cpu(rx_stats->noise_diff); u8 network_packet; rx_status.flag = 0; rx_status.mactime = le64_to_cpu(rx_end->timestamp); - rx_status.band = (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? - IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; + rx_status.band = + (rx_hdr-> + phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? IEEE80211_BAND_2GHZ : + IEEE80211_BAND_5GHZ; rx_status.freq = - ieee80211_channel_to_frequency(le16_to_cpu(rx_hdr->channel), - rx_status.band); + ieee80211_channel_to_frequency(le16_to_cpu(rx_hdr->channel), + rx_status.band); rx_status.rate_idx = il3945_hwrate_to_plcp_idx(rx_hdr->rate); if (rx_status.band == IEEE80211_BAND_5GHZ) rx_status.rate_idx -= IL_FIRST_OFDM_RATE; - rx_status.antenna = (le16_to_cpu(rx_hdr->phy_flags) & - RX_RES_PHY_FLAGS_ANTENNA_MSK) >> 4; + rx_status.antenna = + (le16_to_cpu(rx_hdr->phy_flags) & RX_RES_PHY_FLAGS_ANTENNA_MSK) >> + 4; /* set the preamble flag if appropriate */ if (rx_hdr->phy_flags & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK) @@ -549,7 +553,7 @@ static void il3945_hdl_rx(struct il_priv *il, if ((unlikely(rx_stats->phy_count > 20))) { D_DROP("dsp size out of range [0,20]: %d/n", - rx_stats->phy_count); + rx_stats->phy_count); return; } @@ -559,31 +563,25 @@ static void il3945_hdl_rx(struct il_priv *il, return; } - - /* Convert 3945's rssi indicator to dBm */ rx_status.signal = rx_stats->rssi - IL39_RSSI_OFFSET; - D_STATS("Rssi %d sig_avg %d noise_diff %d\n", - rx_status.signal, rx_stats_sig_avg, - rx_stats_noise_diff); + D_STATS("Rssi %d sig_avg %d noise_diff %d\n", rx_status.signal, + rx_stats_sig_avg, rx_stats_noise_diff); header = (struct ieee80211_hdr *)IL_RX_DATA(pkt); network_packet = il3945_is_network_packet(il, header); D_STATS("[%c] %d RSSI:%d Signal:%u, Rate:%u\n", - network_packet ? '*' : ' ', - le16_to_cpu(rx_hdr->channel), - rx_status.signal, rx_status.signal, - rx_status.rate_idx); + network_packet ? '*' : ' ', le16_to_cpu(rx_hdr->channel), + rx_status.signal, rx_status.signal, rx_status.rate_idx); - il_dbg_log_rx_data_frame(il, le16_to_cpu(rx_hdr->len), - header); + il_dbg_log_rx_data_frame(il, le16_to_cpu(rx_hdr->len), header); if (network_packet) { il->_3945.last_beacon_time = - le32_to_cpu(rx_end->beacon_timestamp); + le32_to_cpu(rx_end->beacon_timestamp); il->_3945.last_tsf = le64_to_cpu(rx_end->timestamp); il->_3945.last_rx_rssi = rx_status.signal; } @@ -591,9 +589,9 @@ static void il3945_hdl_rx(struct il_priv *il, il3945_pass_packet_to_mac80211(il, rxb, &rx_status); } -int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, - struct il_tx_queue *txq, - dma_addr_t addr, u16 len, u8 reset, u8 pad) +int +il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, struct il_tx_queue *txq, + dma_addr_t addr, u16 len, u8 reset, u8 pad) { int count; struct il_queue *q; @@ -610,7 +608,7 @@ int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, if (count >= NUM_TFD_CHUNKS || count < 0) { IL_ERR("Error can not send more than %d chunks\n", - NUM_TFD_CHUNKS); + NUM_TFD_CHUNKS); return -EINVAL; } @@ -619,8 +617,8 @@ int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, count++; - tfd->control_flags = cpu_to_le32(TFD_CTL_COUNT_SET(count) | - TFD_CTL_PAD_SET(pad)); + tfd->control_flags = + cpu_to_le32(TFD_CTL_COUNT_SET(count) | TFD_CTL_PAD_SET(pad)); return 0; } @@ -630,7 +628,8 @@ int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, * * Does NOT advance any idxes */ -void il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) +void +il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) { struct il3945_tfd *tfd_tmp = (struct il3945_tfd *)txq->tfds; int idx = txq->q.read_ptr; @@ -649,16 +648,16 @@ void il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) /* Unmap tx_cmd */ if (counter) - pci_unmap_single(dev, - dma_unmap_addr(&txq->meta[idx], mapping), - dma_unmap_len(&txq->meta[idx], len), - PCI_DMA_TODEVICE); + pci_unmap_single(dev, dma_unmap_addr(&txq->meta[idx], mapping), + dma_unmap_len(&txq->meta[idx], len), + PCI_DMA_TODEVICE); /* unmap chunks if any */ for (i = 1; i < counter; i++) pci_unmap_single(dev, le32_to_cpu(tfd->tbs[i].addr), - le32_to_cpu(tfd->tbs[i].len), PCI_DMA_TODEVICE); + le32_to_cpu(tfd->tbs[i].len), + PCI_DMA_TODEVICE); /* free SKB */ if (txq->txb) { @@ -678,11 +677,10 @@ void il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) * il3945_hw_build_tx_cmd_rate - Add rate portion to TX_CMD: * */ -void il3945_hw_build_tx_cmd_rate(struct il_priv *il, - struct il_device_cmd *cmd, - struct ieee80211_tx_info *info, - struct ieee80211_hdr *hdr, - int sta_id, int tx_id) +void +il3945_hw_build_tx_cmd_rate(struct il_priv *il, struct il_device_cmd *cmd, + struct ieee80211_tx_info *info, + struct ieee80211_hdr *hdr, int sta_id, int tx_id) { u16 hw_value = ieee80211_get_tx_rate(il->hw, info)->hw_value; u16 rate_idx = min(hw_value & 0xffff, RATE_COUNT_3945); @@ -701,7 +699,7 @@ void il3945_hw_build_tx_cmd_rate(struct il_priv *il, * in this running context */ rate_mask = RATES_MASK_3945; - /* Set retry limit on DATA packets and Probe Responses*/ + /* Set retry limit on DATA packets and Probe Responses */ if (ieee80211_is_probe_resp(fc)) data_retry_limit = 3; else @@ -722,18 +720,19 @@ void il3945_hw_build_tx_cmd_rate(struct il_priv *il, /* OFDM */ tx_cmd->supp_rates[0] = - ((rate_mask & IL_OFDM_RATES_MASK) >> IL_FIRST_OFDM_RATE) & 0xFF; + ((rate_mask & IL_OFDM_RATES_MASK) >> IL_FIRST_OFDM_RATE) & 0xFF; /* CCK */ tx_cmd->supp_rates[1] = (rate_mask & 0xF); D_RATE("Tx sta id: %d, rate: %d (plcp), flags: 0x%4X " - "cck/ofdm mask: 0x%x/0x%x\n", sta_id, - tx_cmd->rate, le32_to_cpu(tx_cmd->tx_flags), - tx_cmd->supp_rates[1], tx_cmd->supp_rates[0]); + "cck/ofdm mask: 0x%x/0x%x\n", sta_id, tx_cmd->rate, + le32_to_cpu(tx_cmd->tx_flags), tx_cmd->supp_rates[1], + tx_cmd->supp_rates[0]); } -static u8 il3945_sync_sta(struct il_priv *il, int sta_id, u16 tx_rate) +static u8 +il3945_sync_sta(struct il_priv *il, int sta_id, u16 tx_rate) { unsigned long flags_spin; struct il_station_entry *station; @@ -750,12 +749,12 @@ static u8 il3945_sync_sta(struct il_priv *il, int sta_id, u16 tx_rate) il_send_add_sta(il, &station->sta, CMD_ASYNC); spin_unlock_irqrestore(&il->sta_lock, flags_spin); - D_RATE("SCALE sync station %d to rate %d\n", - sta_id, tx_rate); + D_RATE("SCALE sync station %d to rate %d\n", sta_id, tx_rate); return sta_id; } -static void il3945_set_pwr_vmain(struct il_priv *il) +static void +il3945_set_pwr_vmain(struct il_priv *il) { /* * (for documentation purposes) @@ -773,28 +772,28 @@ static void il3945_set_pwr_vmain(struct il_priv *il) */ il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, - APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, - ~APMG_PS_CTRL_MSK_PWR_SRC); + APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, + ~APMG_PS_CTRL_MSK_PWR_SRC); - _il_poll_bit(il, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC, - CSR_GPIO_IN_BIT_AUX_POWER, 5000); /* uS */ + _il_poll_bit(il, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC, CSR_GPIO_IN_BIT_AUX_POWER, 5000); /* uS */ } -static int il3945_rx_init(struct il_priv *il, struct il_rx_queue *rxq) +static int +il3945_rx_init(struct il_priv *il, struct il_rx_queue *rxq) { il_wr(il, FH39_RCSR_RBD_BASE(0), rxq->bd_dma); - il_wr(il, FH39_RCSR_RPTR_ADDR(0), - rxq->rb_stts_dma); + il_wr(il, FH39_RCSR_RPTR_ADDR(0), rxq->rb_stts_dma); il_wr(il, FH39_RCSR_WPTR(0), 0); il_wr(il, FH39_RCSR_CONFIG(0), - FH39_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE | - FH39_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE | - FH39_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN | - FH39_RCSR_RX_CONFIG_REG_VAL_MAX_FRAG_SIZE_128 | - (RX_QUEUE_SIZE_LOG << FH39_RCSR_RX_CONFIG_REG_POS_RBDC_SIZE) | - FH39_RCSR_RX_CONFIG_REG_VAL_IRQ_DEST_INT_HOST | - (1 << FH39_RCSR_RX_CONFIG_REG_POS_IRQ_RBTH) | - FH39_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH); + FH39_RCSR_RX_CONFIG_REG_VAL_DMA_CHNL_EN_ENABLE | + FH39_RCSR_RX_CONFIG_REG_VAL_RDRBD_EN_ENABLE | + FH39_RCSR_RX_CONFIG_REG_BIT_WR_STTS_EN | + FH39_RCSR_RX_CONFIG_REG_VAL_MAX_FRAG_SIZE_128 | (RX_QUEUE_SIZE_LOG + << + FH39_RCSR_RX_CONFIG_REG_POS_RBDC_SIZE) + | FH39_RCSR_RX_CONFIG_REG_VAL_IRQ_DEST_INT_HOST | (1 << + FH39_RCSR_RX_CONFIG_REG_POS_IRQ_RBTH) + | FH39_RCSR_RX_CONFIG_REG_VAL_MSG_MODE_FH); /* fake read to flush all prev I/O */ il_rd(il, FH39_RSSR_CTRL); @@ -802,7 +801,8 @@ static int il3945_rx_init(struct il_priv *il, struct il_rx_queue *rxq) return 0; } -static int il3945_tx_reset(struct il_priv *il) +static int +il3945_tx_reset(struct il_priv *il) { /* bypass mode */ @@ -819,18 +819,16 @@ static int il3945_tx_reset(struct il_priv *il) il_wr_prph(il, ALM_SCD_TXF4MF_REG, 0x000004); il_wr_prph(il, ALM_SCD_TXF5MF_REG, 0x000005); - il_wr(il, FH39_TSSR_CBB_BASE, - il->_3945.shared_phys); + il_wr(il, FH39_TSSR_CBB_BASE, il->_3945.shared_phys); il_wr(il, FH39_TSSR_MSG_CONFIG, - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON | - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON | - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B | - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON | - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON | - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH | - FH39_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH); - + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TXPD_ON | + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_TXPD_ON | + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_MAX_FRAG_SIZE_128B | + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_SNOOP_RD_TFD_ON | + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RD_CBB_ON | + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_ORDER_RSP_WAIT_TH | + FH39_TSSR_TX_MSG_CONFIG_REG_VAL_RSP_WAIT_TH); return 0; } @@ -840,7 +838,8 @@ static int il3945_tx_reset(struct il_priv *il) * * Destroys all DMA structures and initialize them again */ -static int il3945_txq_ctx_reset(struct il_priv *il) +static int +il3945_txq_ctx_reset(struct il_priv *il) { int rc; int txq_id, slots_num; @@ -859,10 +858,10 @@ static int il3945_txq_ctx_reset(struct il_priv *il) /* Tx queue(s) */ for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { - slots_num = (txq_id == IL39_CMD_QUEUE_NUM) ? - TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - rc = il_tx_queue_init(il, &il->txq[txq_id], - slots_num, txq_id); + slots_num = + (txq_id == + IL39_CMD_QUEUE_NUM) ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; + rc = il_tx_queue_init(il, &il->txq[txq_id], slots_num, txq_id); if (rc) { IL_ERR("Tx %d queue init failed\n", txq_id); goto error; @@ -871,18 +870,18 @@ static int il3945_txq_ctx_reset(struct il_priv *il) return rc; - error: +error: il3945_hw_txq_ctx_free(il); return rc; } - /* * Start up 3945's basic functionality after it has been reset * (e.g. after platform boot, or shutdown via il_apm_stop()) * NOTE: This does not load uCode nor start the embedded processor */ -static int il3945_apm_init(struct il_priv *il) +static int +il3945_apm_init(struct il_priv *il) { int ret = il_apm_init(il); @@ -891,16 +890,15 @@ static int il3945_apm_init(struct il_priv *il) il_wr_prph(il, APMG_RTC_INT_STT_REG, 0xFFFFFFFF); /* Reset radio chip */ - il_set_bits_prph(il, APMG_PS_CTRL_REG, - APMG_PS_CTRL_VAL_RESET_REQ); + il_set_bits_prph(il, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_RESET_REQ); udelay(5); - il_clear_bits_prph(il, APMG_PS_CTRL_REG, - APMG_PS_CTRL_VAL_RESET_REQ); + il_clear_bits_prph(il, APMG_PS_CTRL_REG, APMG_PS_CTRL_VAL_RESET_REQ); return ret; } -static void il3945_nic_config(struct il_priv *il) +static void +il3945_nic_config(struct il_priv *il) { struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; unsigned long flags; @@ -916,42 +914,40 @@ static void il3945_nic_config(struct il_priv *il) else if (rev_id & PCI_CFG_REV_ID_BIT_BASIC_SKU) { D_INFO("3945 RADIO-MB type\n"); il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BIT_3945_MB); + CSR39_HW_IF_CONFIG_REG_BIT_3945_MB); } else { D_INFO("3945 RADIO-MM type\n"); il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BIT_3945_MM); + CSR39_HW_IF_CONFIG_REG_BIT_3945_MM); } if (EEPROM_SKU_CAP_OP_MODE_MRC == eeprom->sku_cap) { D_INFO("SKU OP mode is mrc\n"); il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BIT_SKU_MRC); + CSR39_HW_IF_CONFIG_REG_BIT_SKU_MRC); } else D_INFO("SKU OP mode is basic\n"); if ((eeprom->board_revision & 0xF0) == 0xD0) { - D_INFO("3945ABG revision is 0x%X\n", - eeprom->board_revision); + D_INFO("3945ABG revision is 0x%X\n", eeprom->board_revision); il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); + CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); } else { - D_INFO("3945ABG revision is 0x%X\n", - eeprom->board_revision); + D_INFO("3945ABG revision is 0x%X\n", eeprom->board_revision); il_clear_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); + CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); } if (eeprom->almgor_m_version <= 1) { il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A); + CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A); D_INFO("Card M type A version is 0x%X\n", - eeprom->almgor_m_version); + eeprom->almgor_m_version); } else { D_INFO("Card M type B version is 0x%X\n", - eeprom->almgor_m_version); + eeprom->almgor_m_version); il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B); + CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B); } spin_unlock_irqrestore(&il->lock, flags); @@ -962,7 +958,8 @@ static void il3945_nic_config(struct il_priv *il) D_RF_KILL("HW RF KILL supported in EEPROM.\n"); } -int il3945_hw_nic_init(struct il_priv *il) +int +il3945_hw_nic_init(struct il_priv *il) { int rc; unsigned long flags; @@ -990,11 +987,10 @@ int il3945_hw_nic_init(struct il_priv *il) il3945_rx_init(il, rxq); - /* Look at using this instead: - rxq->need_update = 1; - il_rx_queue_update_write_ptr(il, rxq); - */ + rxq->need_update = 1; + il_rx_queue_update_write_ptr(il, rxq); + */ il_wr(il, FH39_RCSR_WPTR(0), rxq->write & ~7); @@ -1012,14 +1008,14 @@ int il3945_hw_nic_init(struct il_priv *il) * * Destroy all TX DMA queues and structures */ -void il3945_hw_txq_ctx_free(struct il_priv *il) +void +il3945_hw_txq_ctx_free(struct il_priv *il) { int txq_id; /* Tx queues */ if (il->txq) - for (txq_id = 0; txq_id < il->hw_params.max_txq_num; - txq_id++) + for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) if (txq_id == IL39_CMD_QUEUE_NUM) il_cmd_queue_free(il); else @@ -1029,7 +1025,8 @@ void il3945_hw_txq_ctx_free(struct il_priv *il) il_txq_mem(il); } -void il3945_hw_txq_ctx_stop(struct il_priv *il) +void +il3945_hw_txq_ctx_stop(struct il_priv *il) { int txq_id; @@ -1041,8 +1038,8 @@ void il3945_hw_txq_ctx_stop(struct il_priv *il) for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { il_wr(il, FH39_TCSR_CONFIG(txq_id), 0x0); il_poll_bit(il, FH39_TSSR_TX_STATUS, - FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(txq_id), - 1000); + FH39_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(txq_id), + 1000); } il3945_hw_txq_ctx_free(il); @@ -1052,7 +1049,8 @@ void il3945_hw_txq_ctx_stop(struct il_priv *il) * il3945_hw_reg_adjust_power_by_temp * return idx delta into power gain settings table */ -static int il3945_hw_reg_adjust_power_by_temp(int new_reading, int old_reading) +static int +il3945_hw_reg_adjust_power_by_temp(int new_reading, int old_reading) { return (new_reading - old_reading) * (-11) / 100; } @@ -1060,12 +1058,14 @@ static int il3945_hw_reg_adjust_power_by_temp(int new_reading, int old_reading) /** * il3945_hw_reg_temp_out_of_range - Keep temperature in sane range */ -static inline int il3945_hw_reg_temp_out_of_range(int temperature) +static inline int +il3945_hw_reg_temp_out_of_range(int temperature) { return (temperature < -260 || temperature > 25) ? 1 : 0; } -int il3945_hw_get_temperature(struct il_priv *il) +int +il3945_hw_get_temperature(struct il_priv *il) { return _il_rd(il, CSR_UCODE_DRV_GP2); } @@ -1074,7 +1074,8 @@ int il3945_hw_get_temperature(struct il_priv *il) * il3945_hw_reg_txpower_get_temperature * get the current temperature by reading from NIC */ -static int il3945_hw_reg_txpower_get_temperature(struct il_priv *il) +static int +il3945_hw_reg_txpower_get_temperature(struct il_priv *il) { struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; int temperature; @@ -1093,7 +1094,7 @@ static int il3945_hw_reg_txpower_get_temperature(struct il_priv *il) * substitute the 3rd band/group's temp measured at factory */ if (il->last_temperature > 100) temperature = eeprom->groups[2].temperature; - else /* else use most recent "sane" value from driver */ + else /* else use most recent "sane" value from driver */ temperature = il->last_temperature; } @@ -1111,7 +1112,8 @@ static int il3945_hw_reg_txpower_get_temperature(struct il_priv *il) * records new temperature in tx_mgr->temperature. * replaces tx_mgr->last_temperature *only* if calib needed * (assumes caller will actually do the calibration!). */ -static int il3945_is_temp_calib_needed(struct il_priv *il) +static int +il3945_is_temp_calib_needed(struct il_priv *il) { int temp_diff; @@ -1226,7 +1228,7 @@ static struct il3945_tx_power power_gain_table[2][IL_MAX_GAIN_ENTRIES] = { {3, 113}, {3, 106}, {3, 102}, - {3, 95} }, /* 2.4 GHz, lowest power */ + {3, 95}}, /* 2.4 GHz, lowest power */ { {251, 127}, /* 5.x GHz, highest power */ {251, 120}, @@ -1305,10 +1307,11 @@ static struct il3945_tx_power power_gain_table[2][IL_MAX_GAIN_ENTRIES] = { {35, 113}, {35, 107}, {35, 99}, - {3, 120} } /* 5.x GHz, lowest power */ + {3, 120}} /* 5.x GHz, lowest power */ }; -static inline u8 il3945_hw_reg_fix_power_idx(int idx) +static inline u8 +il3945_hw_reg_fix_power_idx(int idx) { if (idx < 0) return 0; @@ -1326,10 +1329,10 @@ static inline u8 il3945_hw_reg_fix_power_idx(int idx) * Set (in our channel info database) the direct scan Tx power for 1 Mbit (CCK) * or 6 Mbit (OFDM) rates. */ -static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_idx, - s32 rate_idx, const s8 *clip_pwrs, - struct il_channel_info *ch_info, - int band_idx) +static void +il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_idx, s32 rate_idx, + const s8 * clip_pwrs, + struct il_channel_info *ch_info, int band_idx) { struct il3945_scan_power_info *scan_power_info; s8 power; @@ -1350,9 +1353,13 @@ static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_idx, * current "normal" temperature-compensated Tx power *idx* for * this rate (1Mb or 6Mb) to yield new temp-compensated scan power * *idx*. */ - power_idx = ch_info->power_info[rate_idx].power_table_idx - - (power - ch_info->power_info - [RATE_6M_IDX_TBL].requested_power) * 2; + power_idx = + ch_info->power_info[rate_idx].power_table_idx - (power - + ch_info-> + power_info + [RATE_6M_IDX_TBL]. + requested_power) * + 2; /* store reference idx that we use when adjusting *all* scan * powers. So we can accommodate user (all channel) or spectrum @@ -1379,7 +1386,8 @@ static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_idx, * Configures power settings for all rates for the current channel, * using values from channel info struct, and send to NIC */ -static int il3945_send_tx_power(struct il_priv *il) +static int +il3945_send_tx_power(struct il_priv *il) { int rate_idx, i; const struct il_channel_info *ch_info = NULL; @@ -1388,8 +1396,9 @@ static int il3945_send_tx_power(struct il_priv *il) }; u16 chan; - if (WARN_ONCE(test_bit(S_SCAN_HW, &il->status), - "TX Power requested while scanning!\n")) + if (WARN_ONCE + (test_bit(S_SCAN_HW, &il->status), + "TX Power requested while scanning!\n")) return -EAGAIN; chan = le16_to_cpu(il->ctx.active.channel); @@ -1397,15 +1406,13 @@ static int il3945_send_tx_power(struct il_priv *il) txpower.band = (il->band == IEEE80211_BAND_5GHZ) ? 0 : 1; ch_info = il_get_channel_info(il, il->band, chan); if (!ch_info) { - IL_ERR( - "Failed to get channel info for channel %d [%d]\n", - chan, il->band); + IL_ERR("Failed to get channel info for channel %d [%d]\n", chan, + il->band); return -EINVAL; } if (!il_is_channel_valid(ch_info)) { - D_POWER("Not calling TX_PWR_TBL_CMD on " - "non-Tx channel.\n"); + D_POWER("Not calling TX_PWR_TBL_CMD on " "non-Tx channel.\n"); return 0; } @@ -1418,29 +1425,25 @@ static int il3945_send_tx_power(struct il_priv *il) txpower.power[i].rate = il3945_rates[rate_idx].plcp; D_POWER("ch %d:%d rf %d dsp %3d rate code 0x%02x\n", - le16_to_cpu(txpower.channel), - txpower.band, - txpower.power[i].tpc.tx_gain, - txpower.power[i].tpc.dsp_atten, - txpower.power[i].rate); + le16_to_cpu(txpower.channel), txpower.band, + txpower.power[i].tpc.tx_gain, + txpower.power[i].tpc.dsp_atten, txpower.power[i].rate); } /* Fill CCK rates */ - for (rate_idx = IL_FIRST_CCK_RATE; - rate_idx <= IL_LAST_CCK_RATE; rate_idx++, i++) { + for (rate_idx = IL_FIRST_CCK_RATE; rate_idx <= IL_LAST_CCK_RATE; + rate_idx++, i++) { txpower.power[i].tpc = ch_info->power_info[i].tpc; txpower.power[i].rate = il3945_rates[rate_idx].plcp; D_POWER("ch %d:%d rf %d dsp %3d rate code 0x%02x\n", - le16_to_cpu(txpower.channel), - txpower.band, - txpower.power[i].tpc.tx_gain, - txpower.power[i].tpc.dsp_atten, - txpower.power[i].rate); + le16_to_cpu(txpower.channel), txpower.band, + txpower.power[i].tpc.tx_gain, + txpower.power[i].tpc.dsp_atten, txpower.power[i].rate); } return il_send_cmd_pdu(il, C_TX_PWR_TBL, - sizeof(struct il3945_txpowertable_cmd), - &txpower); + sizeof(struct il3945_txpowertable_cmd), + &txpower); } @@ -1460,8 +1463,8 @@ static int il3945_send_tx_power(struct il_priv *il) * properly fill out the scan powers, and actual h/w gain settings, * and send changes to NIC */ -static int il3945_hw_reg_set_new_power(struct il_priv *il, - struct il_channel_info *ch_info) +static int +il3945_hw_reg_set_new_power(struct il_priv *il, struct il_channel_info *ch_info) { struct il3945_channel_power_info *power_info; int power_changed = 0; @@ -1476,8 +1479,7 @@ static int il3945_hw_reg_set_new_power(struct il_priv *il, power_info = ch_info->power_info; /* update OFDM Txpower settings */ - for (i = RATE_6M_IDX_TBL; i <= RATE_54M_IDX_TBL; - i++, ++power_info) { + for (i = RATE_6M_IDX_TBL; i <= RATE_54M_IDX_TBL; i++, ++power_info) { int delta_idx; /* limit new power to be no more than h/w capability */ @@ -1500,8 +1502,8 @@ static int il3945_hw_reg_set_new_power(struct il_priv *il, * ... all CCK power settings for a given channel are the *same*. */ if (power_changed) { power = - ch_info->power_info[RATE_12M_IDX_TBL]. - requested_power + IL_CCK_FROM_OFDM_POWER_DIFF; + ch_info->power_info[RATE_12M_IDX_TBL].requested_power + + IL_CCK_FROM_OFDM_POWER_DIFF; /* do all CCK rates' il3945_channel_power_info structures */ for (i = RATE_1M_IDX_TBL; i <= RATE_11M_IDX_TBL; i++) { @@ -1523,15 +1525,17 @@ static int il3945_hw_reg_set_new_power(struct il_priv *il, * based strictly on regulatory (eeprom and spectrum mgt) limitations * (no consideration for h/w clipping limitations). */ -static int il3945_hw_reg_get_ch_txpower_limit(struct il_channel_info *ch_info) +static int +il3945_hw_reg_get_ch_txpower_limit(struct il_channel_info *ch_info) { s8 max_power; #if 0 /* if we're using TGd limits, use lower of TGd or EEPROM */ if (ch_info->tgd_data.max_power != 0) - max_power = min(ch_info->tgd_data.max_power, - ch_info->eeprom.max_power_avg); + max_power = + min(ch_info->tgd_data.max_power, + ch_info->eeprom.max_power_avg); /* else just use EEPROM limits */ else @@ -1551,12 +1555,13 @@ static int il3945_hw_reg_get_ch_txpower_limit(struct il_channel_info *ch_info) * * If RxOn is "associated", this sends the new Txpower to NIC! */ -static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) +static int +il3945_hw_reg_comp_txpower_temp(struct il_priv *il) { struct il_channel_info *ch_info = NULL; struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; int delta_idx; - const s8 *clip_pwrs; /* array of h/w max power levels for each rate */ + const s8 *clip_pwrs; /* array of h/w max power levels for each rate */ u8 a_band; u8 rate_idx; u8 scan_tbl_idx; @@ -1564,8 +1569,7 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) int ref_temp; int temperature = il->temperature; - if (il->disable_tx_power_cal || - test_bit(S_SCANNING, &il->status)) { + if (il->disable_tx_power_cal || test_bit(S_SCANNING, &il->status)) { /* do not perform tx power calibration */ return 0; } @@ -1575,17 +1579,15 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) a_band = il_is_channel_a_band(ch_info); /* Get this chnlgrp's factory calibration temperature */ - ref_temp = (s16)eeprom->groups[ch_info->group_idx]. - temperature; + ref_temp = (s16) eeprom->groups[ch_info->group_idx].temperature; /* get power idx adjustment based on current and factory * temps */ - delta_idx = il3945_hw_reg_adjust_power_by_temp(temperature, - ref_temp); + delta_idx = + il3945_hw_reg_adjust_power_by_temp(temperature, ref_temp); /* set tx power value for all rates, OFDM and CCK */ - for (rate_idx = 0; rate_idx < RATE_COUNT_3945; - rate_idx++) { + for (rate_idx = 0; rate_idx < RATE_COUNT_3945; rate_idx++) { int power_idx = ch_info->power_info[rate_idx].base_power_idx; @@ -1594,23 +1596,25 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) /* stay within table range */ power_idx = il3945_hw_reg_fix_power_idx(power_idx); - ch_info->power_info[rate_idx]. - power_table_idx = (u8) power_idx; + ch_info->power_info[rate_idx].power_table_idx = + (u8) power_idx; ch_info->power_info[rate_idx].tpc = power_gain_table[a_band][power_idx]; } /* Get this chnlgrp's rate-to-max/clip-powers table */ - clip_pwrs = il->_3945.clip_groups[ch_info->group_idx].clip_powers; + clip_pwrs = + il->_3945.clip_groups[ch_info->group_idx].clip_powers; /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */ - for (scan_tbl_idx = 0; - scan_tbl_idx < IL_NUM_SCAN_RATES; scan_tbl_idx++) { - s32 actual_idx = (scan_tbl_idx == 0) ? - RATE_1M_IDX_TBL : RATE_6M_IDX_TBL; + for (scan_tbl_idx = 0; scan_tbl_idx < IL_NUM_SCAN_RATES; + scan_tbl_idx++) { + s32 actual_idx = + (scan_tbl_idx == + 0) ? RATE_1M_IDX_TBL : RATE_6M_IDX_TBL; il3945_hw_reg_set_scan_power(il, scan_tbl_idx, - actual_idx, clip_pwrs, - ch_info, a_band); + actual_idx, clip_pwrs, + ch_info, a_band); } } @@ -1618,7 +1622,8 @@ static int il3945_hw_reg_comp_txpower_temp(struct il_priv *il) return il->cfg->ops->lib->send_tx_power(il); } -int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power) +int +il3945_hw_reg_set_txpower(struct il_priv *il, s8 power) { struct il_channel_info *ch_info; s8 max_power; @@ -1626,8 +1631,8 @@ int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power) u8 i; if (il->tx_power_user_lmt == power) { - D_POWER("Requested Tx power same as current " - "limit: %ddBm.\n", power); + D_POWER("Requested Tx power same as current " "limit: %ddBm.\n", + power); return 0; } @@ -1660,8 +1665,8 @@ int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power) return 0; } -static int il3945_send_rxon_assoc(struct il_priv *il, - struct il_rxon_context *ctx) +static int +il3945_send_rxon_assoc(struct il_priv *il, struct il_rxon_context *ctx) { int rc = 0; struct il_rx_pkt *pkt; @@ -1712,7 +1717,8 @@ static int il3945_send_rxon_assoc(struct il_priv *il, * function correctly transitions out of the RXON_ASSOC_MSK state if * a HW tune is required based on the RXON structure changes. */ -int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) +int +il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) { /* cast away the const for active_rxon in this function */ struct il3945_rxon_cmd *active_rxon = (void *)&ctx->active; @@ -1730,8 +1736,7 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) staging_rxon->flags |= RXON_FLG_TSF2HOST_MSK; /* select antenna */ - staging_rxon->flags &= - ~(RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_SEL_MSK); + staging_rxon->flags &= ~(RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_SEL_MSK); staging_rxon->flags |= il3945_get_antenna_flags(il); rc = il_check_rxon_cmd(il, ctx); @@ -1743,13 +1748,11 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) /* If we don't need to send a full RXON, we can use * il3945_rxon_assoc_cmd which is used to reconfigure filter * and other flags for the current radio configuration. */ - if (!il_full_rxon_required(il, - &il->ctx)) { - rc = il_send_rxon_assoc(il, - &il->ctx); + if (!il_full_rxon_required(il, &il->ctx)) { + rc = il_send_rxon_assoc(il, &il->ctx); if (rc) { IL_ERR("Error setting RXON_ASSOC " - "configuration (%d).\n", rc); + "configuration (%d).\n", rc); return rc; } @@ -1776,31 +1779,24 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) */ active_rxon->reserved4 = 0; active_rxon->reserved5 = 0; - rc = il_send_cmd_pdu(il, C_RXON, - sizeof(struct il3945_rxon_cmd), - &il->ctx.active); + rc = il_send_cmd_pdu(il, C_RXON, sizeof(struct il3945_rxon_cmd), + &il->ctx.active); /* If the mask clearing failed then we set * active_rxon back to what it was previously */ if (rc) { active_rxon->filter_flags |= RXON_FILTER_ASSOC_MSK; IL_ERR("Error clearing ASSOC_MSK on current " - "configuration (%d).\n", rc); + "configuration (%d).\n", rc); return rc; } - il_clear_ucode_stations(il, - &il->ctx); - il_restore_stations(il, - &il->ctx); + il_clear_ucode_stations(il, &il->ctx); + il_restore_stations(il, &il->ctx); } - D_INFO("Sending RXON\n" - "* with%s RXON_FILTER_ASSOC_MSK\n" - "* channel = %d\n" - "* bssid = %pM\n", - (new_assoc ? "" : "out"), - le16_to_cpu(staging_rxon->channel), - staging_rxon->bssid_addr); + D_INFO("Sending RXON\n" "* with%s RXON_FILTER_ASSOC_MSK\n" + "* channel = %d\n" "* bssid = %pM\n", (new_assoc ? "" : "out"), + le16_to_cpu(staging_rxon->channel), staging_rxon->bssid_addr); /* * reserved4 and 5 could have been filled by the iwlcore code. @@ -1812,9 +1808,8 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) il_set_rxon_hwcrypto(il, ctx, !il3945_mod_params.sw_crypto); /* Apply the new configuration */ - rc = il_send_cmd_pdu(il, C_RXON, - sizeof(struct il3945_rxon_cmd), - staging_rxon); + rc = il_send_cmd_pdu(il, C_RXON, sizeof(struct il3945_rxon_cmd), + staging_rxon); if (rc) { IL_ERR("Error setting new configuration (%d).\n", rc); return rc; @@ -1823,10 +1818,8 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) memcpy(active_rxon, staging_rxon, sizeof(*active_rxon)); if (!new_assoc) { - il_clear_ucode_stations(il, - &il->ctx); - il_restore_stations(il, - &il->ctx); + il_clear_ucode_stations(il, &il->ctx); + il_restore_stations(il, &il->ctx); } /* If we issue a new RXON command which required a tune then we must @@ -1857,7 +1850,8 @@ int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) * -- send new set of gain settings to NIC * NOTE: This should continue working, even when we're not associated, * so we can keep our internal table of scan powers current. */ -void il3945_reg_txpower_periodic(struct il_priv *il) +void +il3945_reg_txpower_periodic(struct il_priv *il) { /* This will kick in the "brute force" * il3945_hw_reg_comp_txpower_temp() below */ @@ -1869,15 +1863,16 @@ void il3945_reg_txpower_periodic(struct il_priv *il) * ignoring any previous power measurements */ il3945_hw_reg_comp_txpower_temp(il); - reschedule: - queue_delayed_work(il->workqueue, - &il->_3945.thermal_periodic, REG_RECALIB_PERIOD * HZ); +reschedule: + queue_delayed_work(il->workqueue, &il->_3945.thermal_periodic, + REG_RECALIB_PERIOD * HZ); } -static void il3945_bg_reg_txpower_periodic(struct work_struct *work) +static void +il3945_bg_reg_txpower_periodic(struct work_struct *work) { struct il_priv *il = container_of(work, struct il_priv, - _3945.thermal_periodic.work); + _3945.thermal_periodic.work); if (test_bit(S_EXIT_PENDING, &il->status)) return; @@ -1898,8 +1893,9 @@ static void il3945_bg_reg_txpower_periodic(struct work_struct *work) * on A-band, EEPROM's "group frequency" entries represent the top * channel in each group 1-4. Group 5 All B/G channels are in group 0. */ -static u16 il3945_hw_reg_get_ch_grp_idx(struct il_priv *il, - const struct il_channel_info *ch_info) +static u16 +il3945_hw_reg_get_ch_grp_idx(struct il_priv *il, + const struct il_channel_info *ch_info) { struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; struct il3945_eeprom_txpower_group *ch_grp = &eeprom->groups[0]; @@ -1922,8 +1918,7 @@ static u16 il3945_hw_reg_get_ch_grp_idx(struct il_priv *il, } else group_idx = 0; /* 2.4 GHz, group 0 */ - D_POWER("Chnl %d mapped to grp %d\n", ch_info->channel, - group_idx); + D_POWER("Chnl %d mapped to grp %d\n", ch_info->channel, group_idx); return group_idx; } @@ -1933,9 +1928,9 @@ static u16 il3945_hw_reg_get_ch_grp_idx(struct il_priv *il, * Interpolate to get nominal (i.e. at factory calibration temperature) idx * into radio/DSP gain settings table for requested power. */ -static int il3945_hw_reg_get_matched_power_idx(struct il_priv *il, - s8 requested_power, - s32 setting_idx, s32 *new_idx) +static int +il3945_hw_reg_get_matched_power_idx(struct il_priv *il, s8 requested_power, + s32 setting_idx, s32 * new_idx) { const struct il3945_eeprom_txpower_group *chnl_grp = NULL; struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; @@ -1975,14 +1970,16 @@ static int il3945_hw_reg_get_matched_power_idx(struct il_priv *il, return -EINVAL; gains0 = (s32) samples[idx0].gain_idx * (1 << 19); gains1 = (s32) samples[idx1].gain_idx * (1 << 19); - res = gains0 + (gains1 - gains0) * - ((s32) power - (s32) samples[idx0].power) / denominator + - (1 << 18); + res = + gains0 + (gains1 - gains0) * ((s32) power - + (s32) samples[idx0].power) / + denominator + (1 << 18); *new_idx = res >> 19; return 0; } -static void il3945_hw_reg_init_channel_groups(struct il_priv *il) +static void +il3945_hw_reg_init_channel_groups(struct il_priv *il) { u32 i; s32 rate_idx; @@ -1999,8 +1996,8 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *il) /* sanity check on factory saturation power value */ if (group->saturation_power < 40) { IL_WARN("Error: saturation power is %d, " - "less than minimum expected 40\n", - group->saturation_power); + "less than minimum expected 40\n", + group->saturation_power); return; } @@ -2019,8 +2016,8 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *il) satur_pwr = (s8) (group->saturation_power >> 1); /* fill in channel group's nominal powers for each rate */ - for (rate_idx = 0; - rate_idx < RATE_COUNT_3945; rate_idx++, clip_pwrs++) { + for (rate_idx = 0; rate_idx < RATE_COUNT_3945; + rate_idx++, clip_pwrs++) { switch (rate_idx) { case RATE_36M_IDX_TBL: if (i == 0) /* B/G */ @@ -2063,7 +2060,8 @@ static void il3945_hw_reg_init_channel_groups(struct il_priv *il) * * This does *not* write values to NIC, just sets up our internal table. */ -int il3945_txpower_set_from_eeprom(struct il_priv *il) +int +il3945_txpower_set_from_eeprom(struct il_priv *il) { struct il_channel_info *ch_info = NULL; struct il3945_channel_power_info *pwr_info; @@ -2093,25 +2091,25 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) continue; /* find this channel's channel group (*not* "band") idx */ - ch_info->group_idx = - il3945_hw_reg_get_ch_grp_idx(il, ch_info); + ch_info->group_idx = il3945_hw_reg_get_ch_grp_idx(il, ch_info); /* Get this chnlgrp's rate->max/clip-powers table */ - clip_pwrs = il->_3945.clip_groups[ch_info->group_idx].clip_powers; + clip_pwrs = + il->_3945.clip_groups[ch_info->group_idx].clip_powers; /* calculate power idx *adjustment* value according to * diff between current temperature and factory temperature */ - delta_idx = il3945_hw_reg_adjust_power_by_temp(temperature, - eeprom->groups[ch_info->group_idx]. - temperature); + delta_idx = + il3945_hw_reg_adjust_power_by_temp(temperature, + eeprom->groups[ch_info-> + group_idx]. + temperature); - D_POWER("Delta idx for channel %d: %d [%d]\n", - ch_info->channel, delta_idx, temperature + - IL_TEMP_CONVERT); + D_POWER("Delta idx for channel %d: %d [%d]\n", ch_info->channel, + delta_idx, temperature + IL_TEMP_CONVERT); /* set tx power value for all OFDM rates */ - for (rate_idx = 0; rate_idx < IL_OFDM_RATES; - rate_idx++) { + for (rate_idx = 0; rate_idx < IL_OFDM_RATES; rate_idx++) { s32 uninitialized_var(power_idx); int rc; @@ -2125,8 +2123,9 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) /* get base (i.e. at factory-measured temperature) * power table idx for this rate's power */ rc = il3945_hw_reg_get_matched_power_idx(il, pwr, - ch_info->group_idx, - &power_idx); + ch_info-> + group_idx, + &power_idx); if (rc) { IL_ERR("Invalid power idx\n"); return rc; @@ -2148,14 +2147,12 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) power_gain_table[a_band][power_idx].dsp_atten; } - /* set tx power for CCK rates, based on OFDM 12 Mbit settings*/ + /* set tx power for CCK rates, based on OFDM 12 Mbit settings */ pwr_info = &ch_info->power_info[RATE_12M_IDX_TBL]; - power = pwr_info->requested_power + - IL_CCK_FROM_OFDM_POWER_DIFF; - pwr_idx = pwr_info->power_table_idx + - IL_CCK_FROM_OFDM_IDX_DIFF; - base_pwr_idx = pwr_info->base_power_idx + - IL_CCK_FROM_OFDM_IDX_DIFF; + power = pwr_info->requested_power + IL_CCK_FROM_OFDM_POWER_DIFF; + pwr_idx = pwr_info->power_table_idx + IL_CCK_FROM_OFDM_IDX_DIFF; + base_pwr_idx = + pwr_info->base_power_idx + IL_CCK_FROM_OFDM_IDX_DIFF; /* stay within table range */ pwr_idx = il3945_hw_reg_fix_power_idx(pwr_idx); @@ -2165,9 +2162,9 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) /* fill each CCK rate's il3945_channel_power_info structure * NOTE: All CCK-rate Txpwrs are the same for a given chnl! * NOTE: CCK rates start at end of OFDM rates! */ - for (rate_idx = 0; - rate_idx < IL_CCK_RATES; rate_idx++) { - pwr_info = &ch_info->power_info[rate_idx+IL_OFDM_RATES]; + for (rate_idx = 0; rate_idx < IL_CCK_RATES; rate_idx++) { + pwr_info = + &ch_info->power_info[rate_idx + IL_OFDM_RATES]; pwr_info->requested_power = power; pwr_info->power_table_idx = pwr_idx; pwr_info->base_power_idx = base_pwr_idx; @@ -2176,48 +2173,52 @@ int il3945_txpower_set_from_eeprom(struct il_priv *il) } /* set scan tx power, 1Mbit for CCK, 6Mbit for OFDM */ - for (scan_tbl_idx = 0; - scan_tbl_idx < IL_NUM_SCAN_RATES; scan_tbl_idx++) { - s32 actual_idx = (scan_tbl_idx == 0) ? - RATE_1M_IDX_TBL : RATE_6M_IDX_TBL; + for (scan_tbl_idx = 0; scan_tbl_idx < IL_NUM_SCAN_RATES; + scan_tbl_idx++) { + s32 actual_idx = + (scan_tbl_idx == + 0) ? RATE_1M_IDX_TBL : RATE_6M_IDX_TBL; il3945_hw_reg_set_scan_power(il, scan_tbl_idx, - actual_idx, clip_pwrs, ch_info, a_band); + actual_idx, clip_pwrs, + ch_info, a_band); } } return 0; } -int il3945_hw_rxq_stop(struct il_priv *il) +int +il3945_hw_rxq_stop(struct il_priv *il) { int rc; il_wr(il, FH39_RCSR_CONFIG(0), 0); rc = il_poll_bit(il, FH39_RSSR_STATUS, - FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); + FH39_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); if (rc < 0) IL_ERR("Can't stop Rx DMA.\n"); return 0; } -int il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq) +int +il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq) { int txq_id = txq->q.id; struct il3945_shared *shared_data = il->_3945.shared_virt; - shared_data->tx_base_ptr[txq_id] = cpu_to_le32((u32)txq->q.dma_addr); + shared_data->tx_base_ptr[txq_id] = cpu_to_le32((u32) txq->q.dma_addr); il_wr(il, FH39_CBCC_CTRL(txq_id), 0); il_wr(il, FH39_CBCC_BASE(txq_id), 0); il_wr(il, FH39_TCSR_CONFIG(txq_id), - FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT | - FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF | - FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD | - FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL | - FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE); + FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_RTC_NOINT | + FH39_TCSR_TX_CONFIG_REG_VAL_MSG_MODE_TXF | + FH39_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_IFTFD | + FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE_VAL | + FH39_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE); /* fake read to flush all prev. writes */ _il_rd(il, FH39_TSSR_CBB_BASE); @@ -2228,7 +2229,8 @@ int il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq) /* * HCMD utils */ -static u16 il3945_get_hcmd_size(u8 cmd_id, u16 len) +static u16 +il3945_get_hcmd_size(u8 cmd_id, u16 len) { switch (cmd_id) { case C_RXON: @@ -2240,9 +2242,8 @@ static u16 il3945_get_hcmd_size(u8 cmd_id, u16 len) } } - -static u16 il3945_build_addsta_hcmd(const struct il_addsta_cmd *cmd, - u8 *data) +static u16 +il3945_build_addsta_hcmd(const struct il_addsta_cmd *cmd, u8 * data) { struct il3945_addsta_cmd *addsta = (struct il3945_addsta_cmd *)data; addsta->mode = cmd->mode; @@ -2256,11 +2257,11 @@ static u16 il3945_build_addsta_hcmd(const struct il_addsta_cmd *cmd, addsta->remove_immediate_ba_tid = cmd->remove_immediate_ba_tid; addsta->add_immediate_ba_ssn = cmd->add_immediate_ba_ssn; - return (u16)sizeof(struct il3945_addsta_cmd); + return (u16) sizeof(struct il3945_addsta_cmd); } -static int il3945_add_bssid_station(struct il_priv *il, - const u8 *addr, u8 *sta_id_r) +static int +il3945_add_bssid_station(struct il_priv *il, const u8 * addr, u8 * sta_id_r) { struct il_rxon_context *ctx = &il->ctx; int ret; @@ -2285,34 +2286,39 @@ static int il3945_add_bssid_station(struct il_priv *il, return 0; } -static int il3945_manage_ibss_station(struct il_priv *il, - struct ieee80211_vif *vif, bool add) + +static int +il3945_manage_ibss_station(struct il_priv *il, struct ieee80211_vif *vif, + bool add) { struct il_vif_priv *vif_priv = (void *)vif->drv_priv; int ret; if (add) { - ret = il3945_add_bssid_station(il, vif->bss_conf.bssid, - &vif_priv->ibss_bssid_sta_id); + ret = + il3945_add_bssid_station(il, vif->bss_conf.bssid, + &vif_priv->ibss_bssid_sta_id); if (ret) return ret; il3945_sync_sta(il, vif_priv->ibss_bssid_sta_id, - (il->band == IEEE80211_BAND_5GHZ) ? - RATE_6M_PLCP : RATE_1M_PLCP); + (il->band == + IEEE80211_BAND_5GHZ) ? RATE_6M_PLCP : + RATE_1M_PLCP); il3945_rate_scale_init(il->hw, vif_priv->ibss_bssid_sta_id); return 0; } return il_remove_station(il, vif_priv->ibss_bssid_sta_id, - vif->bss_conf.bssid); + vif->bss_conf.bssid); } /** * il3945_init_hw_rate_table - Initialize the hardware rate fallback table */ -int il3945_init_hw_rate_table(struct il_priv *il) +int +il3945_init_hw_rate_table(struct il_priv *il) { int rc, i, idx, prev_idx; struct il3945_rate_scaling_cmd rate_cmd = { @@ -2324,11 +2330,10 @@ int il3945_init_hw_rate_table(struct il_priv *il) idx = il3945_rates[i].table_rs_idx; table[idx].rate_n_flags = - il3945_hw_set_rate_n_flags(il3945_rates[i].plcp, 0); + il3945_hw_set_rate_n_flags(il3945_rates[i].plcp, 0); table[idx].try_cnt = il->retry_rate; prev_idx = il3945_get_prev_ieee_rate(i); - table[idx].next_rate_idx = - il3945_rates[prev_idx].table_rs_idx; + table[idx].next_rate_idx = il3945_rates[prev_idx].table_rs_idx; } switch (il->band) { @@ -2336,14 +2341,12 @@ int il3945_init_hw_rate_table(struct il_priv *il) D_RATE("Select A mode rate scale\n"); /* If one of the following CCK rates is used, * have it fall back to the 6M OFDM rate */ - for (i = RATE_1M_IDX_TBL; - i <= RATE_11M_IDX_TBL; i++) + for (i = RATE_1M_IDX_TBL; i <= RATE_11M_IDX_TBL; i++) table[i].next_rate_idx = - il3945_rates[IL_FIRST_OFDM_RATE].table_rs_idx; + il3945_rates[IL_FIRST_OFDM_RATE].table_rs_idx; /* Don't fall back to CCK rates */ - table[RATE_12M_IDX_TBL].next_rate_idx = - RATE_9M_IDX_TBL; + table[RATE_12M_IDX_TBL].next_rate_idx = RATE_9M_IDX_TBL; /* Don't drop out of OFDM rates */ table[RATE_6M_IDX_TBL].next_rate_idx = @@ -2359,10 +2362,9 @@ int il3945_init_hw_rate_table(struct il_priv *il) il_is_associated(il)) { idx = IL_FIRST_CCK_RATE; - for (i = RATE_6M_IDX_TBL; - i <= RATE_54M_IDX_TBL; i++) + for (i = RATE_6M_IDX_TBL; i <= RATE_54M_IDX_TBL; i++) table[i].next_rate_idx = - il3945_rates[idx].table_rs_idx; + il3945_rates[idx].table_rs_idx; idx = RATE_11M_IDX_TBL; /* CCK shouldn't fall back to OFDM... */ @@ -2377,27 +2379,24 @@ int il3945_init_hw_rate_table(struct il_priv *il) /* Update the rate scaling for control frame Tx */ rate_cmd.table_id = 0; - rc = il_send_cmd_pdu(il, C_RATE_SCALE, sizeof(rate_cmd), - &rate_cmd); + rc = il_send_cmd_pdu(il, C_RATE_SCALE, sizeof(rate_cmd), &rate_cmd); if (rc) return rc; /* Update the rate scaling for data frame Tx */ rate_cmd.table_id = 1; - return il_send_cmd_pdu(il, C_RATE_SCALE, sizeof(rate_cmd), - &rate_cmd); + return il_send_cmd_pdu(il, C_RATE_SCALE, sizeof(rate_cmd), &rate_cmd); } /* Called when initializing driver */ -int il3945_hw_set_hw_params(struct il_priv *il) +int +il3945_hw_set_hw_params(struct il_priv *il) { - memset((void *)&il->hw_params, 0, - sizeof(struct il_hw_params)); + memset((void *)&il->hw_params, 0, sizeof(struct il_hw_params)); il->_3945.shared_virt = - dma_alloc_coherent(&il->pci_dev->dev, - sizeof(struct il3945_shared), - &il->_3945.shared_phys, GFP_KERNEL); + dma_alloc_coherent(&il->pci_dev->dev, sizeof(struct il3945_shared), + &il->_3945.shared_phys, GFP_KERNEL); if (!il->_3945.shared_virt) { IL_ERR("failed to allocate pci memory\n"); return -ENOMEM; @@ -2422,8 +2421,9 @@ int il3945_hw_set_hw_params(struct il_priv *il) return 0; } -unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, - struct il3945_frame *frame, u8 rate) +unsigned int +il3945_hw_get_beacon_cmd(struct il_priv *il, struct il3945_frame *frame, + u8 rate) { struct il3945_tx_beacon_cmd *tx_beacon_cmd; unsigned int frame_size; @@ -2431,51 +2431,53 @@ unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, tx_beacon_cmd = (struct il3945_tx_beacon_cmd *)&frame->u; memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); - tx_beacon_cmd->tx.sta_id = - il->ctx.bcast_sta_id; + tx_beacon_cmd->tx.sta_id = il->ctx.bcast_sta_id; tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; - frame_size = il3945_fill_beacon_frame(il, - tx_beacon_cmd->frame, - sizeof(frame->u) - sizeof(*tx_beacon_cmd)); + frame_size = + il3945_fill_beacon_frame(il, tx_beacon_cmd->frame, + sizeof(frame->u) - sizeof(*tx_beacon_cmd)); BUG_ON(frame_size > MAX_MPDU_SIZE); - tx_beacon_cmd->tx.len = cpu_to_le16((u16)frame_size); + tx_beacon_cmd->tx.len = cpu_to_le16((u16) frame_size); tx_beacon_cmd->tx.rate = rate; - tx_beacon_cmd->tx.tx_flags = (TX_CMD_FLG_SEQ_CTL_MSK | - TX_CMD_FLG_TSF_MSK); + tx_beacon_cmd->tx.tx_flags = + (TX_CMD_FLG_SEQ_CTL_MSK | TX_CMD_FLG_TSF_MSK); - /* supp_rates[0] == OFDM start at IL_FIRST_OFDM_RATE*/ + /* supp_rates[0] == OFDM start at IL_FIRST_OFDM_RATE */ tx_beacon_cmd->tx.supp_rates[0] = - (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; + (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; - tx_beacon_cmd->tx.supp_rates[1] = - (IL_CCK_BASIC_RATES_MASK & 0xF); + tx_beacon_cmd->tx.supp_rates[1] = (IL_CCK_BASIC_RATES_MASK & 0xF); return sizeof(struct il3945_tx_beacon_cmd) + frame_size; } -void il3945_hw_handler_setup(struct il_priv *il) +void +il3945_hw_handler_setup(struct il_priv *il) { il->handlers[C_TX] = il3945_hdl_tx; il->handlers[N_3945_RX] = il3945_hdl_rx; } -void il3945_hw_setup_deferred_work(struct il_priv *il) +void +il3945_hw_setup_deferred_work(struct il_priv *il) { INIT_DELAYED_WORK(&il->_3945.thermal_periodic, il3945_bg_reg_txpower_periodic); } -void il3945_hw_cancel_deferred_work(struct il_priv *il) +void +il3945_hw_cancel_deferred_work(struct il_priv *il) { cancel_delayed_work(&il->_3945.thermal_periodic); } /* check contents of special bootstrap uCode SRAM */ -static int il3945_verify_bsm(struct il_priv *il) - { +static int +il3945_verify_bsm(struct il_priv *il) +{ __le32 *image = il->ucode_boot.v_addr; u32 len = il->ucode_boot.len; u32 reg; @@ -2485,16 +2487,14 @@ static int il3945_verify_bsm(struct il_priv *il) /* verify BSM SRAM contents */ val = il_rd_prph(il, BSM_WR_DWCOUNT_REG); - for (reg = BSM_SRAM_LOWER_BOUND; - reg < BSM_SRAM_LOWER_BOUND + len; + for (reg = BSM_SRAM_LOWER_BOUND; reg < BSM_SRAM_LOWER_BOUND + len; reg += sizeof(u32), image++) { val = il_rd_prph(il, reg); if (val != le32_to_cpu(*image)) { IL_ERR("BSM uCode verification failed at " - "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", - BSM_SRAM_LOWER_BOUND, - reg - BSM_SRAM_LOWER_BOUND, len, - val, le32_to_cpu(*image)); + "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", + BSM_SRAM_LOWER_BOUND, reg - BSM_SRAM_LOWER_BOUND, + len, val, le32_to_cpu(*image)); return -EIO; } } @@ -2504,7 +2504,6 @@ static int il3945_verify_bsm(struct il_priv *il) return 0; } - /****************************************************************************** * * EEPROM related functions @@ -2519,14 +2518,15 @@ static int il3945_verify_bsm(struct il_priv *il) * simply claims ownership, which should be safe when this function is called * (i.e. before loading uCode!). */ -static int il3945_eeprom_acquire_semaphore(struct il_priv *il) +static int +il3945_eeprom_acquire_semaphore(struct il_priv *il) { _il_clear_bit(il, CSR_EEPROM_GP, CSR_EEPROM_GP_IF_OWNER_MSK); return 0; } - -static void il3945_eeprom_release_semaphore(struct il_priv *il) +static void +il3945_eeprom_release_semaphore(struct il_priv *il) { return; } @@ -2563,7 +2563,8 @@ static void il3945_eeprom_release_semaphore(struct il_priv *il) * the runtime uCode instructions and the backup data cache into SRAM, * and re-launches the runtime uCode from where it left off. */ -static int il3945_load_bsm(struct il_priv *il) +static int +il3945_load_bsm(struct il_priv *il) { __le32 *image = il->ucode_boot.v_addr; u32 len = il->ucode_boot.len; @@ -2583,10 +2584,10 @@ static int il3945_load_bsm(struct il_priv *il) return -EINVAL; /* Tell bootstrap uCode where to find the "Initialize" uCode - * in host DRAM ... host DRAM physical address bits 31:0 for 3945. - * NOTE: il3945_initialize_alive_start() will replace these values, - * after the "initialize" uCode has run, to point to - * runtime/protocol instructions and backup data cache. */ + * in host DRAM ... host DRAM physical address bits 31:0 for 3945. + * NOTE: il3945_initialize_alive_start() will replace these values, + * after the "initialize" uCode has run, to point to + * runtime/protocol instructions and backup data cache. */ pinst = il->ucode_init.p_addr; pdata = il->ucode_init_data.p_addr; inst_len = il->ucode_init.len; @@ -2601,8 +2602,7 @@ static int il3945_load_bsm(struct il_priv *il) for (reg_offset = BSM_SRAM_LOWER_BOUND; reg_offset < BSM_SRAM_LOWER_BOUND + len; reg_offset += sizeof(u32), image++) - _il_wr_prph(il, reg_offset, - le32_to_cpu(*image)); + _il_wr_prph(il, reg_offset, le32_to_cpu(*image)); rc = il3945_verify_bsm(il); if (rc) @@ -2610,14 +2610,12 @@ static int il3945_load_bsm(struct il_priv *il) /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ il_wr_prph(il, BSM_WR_MEM_SRC_REG, 0x0); - il_wr_prph(il, BSM_WR_MEM_DST_REG, - IL39_RTC_INST_LOWER_BOUND); + il_wr_prph(il, BSM_WR_MEM_DST_REG, IL39_RTC_INST_LOWER_BOUND); il_wr_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); /* Load bootstrap code into instruction SRAM now, * to prepare to load "initialize" uCode */ - il_wr_prph(il, BSM_WR_CTRL_REG, - BSM_WR_CTRL_REG_BIT_START); + il_wr_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START); /* Wait for load of bootstrap uCode to finish */ for (i = 0; i < 100; i++) { @@ -2635,8 +2633,7 @@ static int il3945_load_bsm(struct il_priv *il) /* Enable future boot loads whenever power management unit triggers it * (e.g. when powering back up after power-save shutdown) */ - il_wr_prph(il, BSM_WR_CTRL_REG, - BSM_WR_CTRL_REG_BIT_START_EN); + il_wr_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN); return 0; } @@ -2653,30 +2650,30 @@ static struct il_lib_ops il3945_lib = { .load_ucode = il3945_load_bsm, .dump_nic_error_log = il3945_dump_nic_error_log, .apm_ops = { - .init = il3945_apm_init, - .config = il3945_nic_config, - }, + .init = il3945_apm_init, + .config = il3945_nic_config, + }, .eeprom_ops = { - .regulatory_bands = { - EEPROM_REGULATORY_BAND_1_CHANNELS, - EEPROM_REGULATORY_BAND_2_CHANNELS, - EEPROM_REGULATORY_BAND_3_CHANNELS, - EEPROM_REGULATORY_BAND_4_CHANNELS, - EEPROM_REGULATORY_BAND_5_CHANNELS, - EEPROM_REGULATORY_BAND_NO_HT40, - EEPROM_REGULATORY_BAND_NO_HT40, - }, - .acquire_semaphore = il3945_eeprom_acquire_semaphore, - .release_semaphore = il3945_eeprom_release_semaphore, - }, - .send_tx_power = il3945_send_tx_power, + .regulatory_bands = { + EEPROM_REGULATORY_BAND_1_CHANNELS, + EEPROM_REGULATORY_BAND_2_CHANNELS, + EEPROM_REGULATORY_BAND_3_CHANNELS, + EEPROM_REGULATORY_BAND_4_CHANNELS, + EEPROM_REGULATORY_BAND_5_CHANNELS, + EEPROM_REGULATORY_BAND_NO_HT40, + EEPROM_REGULATORY_BAND_NO_HT40, + }, + .acquire_semaphore = il3945_eeprom_acquire_semaphore, + .release_semaphore = il3945_eeprom_release_semaphore, + }, + .send_tx_power = il3945_send_tx_power, .is_valid_rtc_data_addr = il3945_hw_valid_rtc_data_addr, .debugfs_ops = { - .rx_stats_read = il3945_ucode_rx_stats_read, - .tx_stats_read = il3945_ucode_tx_stats_read, - .general_stats_read = il3945_ucode_general_stats_read, - }, + .rx_stats_read = il3945_ucode_rx_stats_read, + .tx_stats_read = il3945_ucode_tx_stats_read, + .general_stats_read = il3945_ucode_general_stats_read, + }, }; static const struct il_legacy_ops il3945_legacy_ops = { @@ -2729,7 +2726,7 @@ static struct il_cfg il3945_abg_cfg = { .fw_name_pre = IL3945_FW_PRE, .ucode_api_max = IL3945_UCODE_API_MAX, .ucode_api_min = IL3945_UCODE_API_MIN, - .sku = IL_SKU_A|IL_SKU_G, + .sku = IL_SKU_A | IL_SKU_G, .eeprom_ver = EEPROM_3945_EEPROM_VERSION, .ops = &il3945_ops, .mod_params = &il3945_mod_params, @@ -2738,13 +2735,14 @@ static struct il_cfg il3945_abg_cfg = { }; DEFINE_PCI_DEVICE_TABLE(il3945_hw_card_ids) = { - {IL_PCI_DEVICE(0x4222, 0x1005, il3945_bg_cfg)}, - {IL_PCI_DEVICE(0x4222, 0x1034, il3945_bg_cfg)}, - {IL_PCI_DEVICE(0x4222, 0x1044, il3945_bg_cfg)}, - {IL_PCI_DEVICE(0x4227, 0x1014, il3945_bg_cfg)}, - {IL_PCI_DEVICE(0x4222, PCI_ANY_ID, il3945_abg_cfg)}, - {IL_PCI_DEVICE(0x4227, PCI_ANY_ID, il3945_abg_cfg)}, - {0} + { + IL_PCI_DEVICE(0x4222, 0x1005, il3945_bg_cfg)}, { + IL_PCI_DEVICE(0x4222, 0x1034, il3945_bg_cfg)}, { + IL_PCI_DEVICE(0x4222, 0x1044, il3945_bg_cfg)}, { + IL_PCI_DEVICE(0x4227, 0x1014, il3945_bg_cfg)}, { + IL_PCI_DEVICE(0x4222, PCI_ANY_ID, il3945_abg_cfg)}, { + IL_PCI_DEVICE(0x4227, PCI_ANY_ID, il3945_abg_cfg)}, { + 0} }; MODULE_DEVICE_TABLE(pci, il3945_hw_card_ids); diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index 1a2430bb1889..8e53751270f0 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -27,7 +27,7 @@ #ifndef __il_3945_h__ #define __il_3945_h__ -#include /* for struct pci_device_id */ +#include /* for struct pci_device_id */ #include #include @@ -93,7 +93,6 @@ struct il3945_rs_sta { int last_txrate_idx; }; - /* * The common struct MUST be first because it is shared between * 3945 and 4965! @@ -186,7 +185,6 @@ struct il3945_ibss_seq { #define IL_RX_STATS(x) (&x->u.rx_frame.stats) #define IL_RX_DATA(x) (IL_RX_HDR(x)->payload) - /****************************************************************************** * * Functions implemented in iwl3945-base.c which are forward declared here @@ -197,9 +195,10 @@ extern int il3945_calc_db_from_ratio(int sig_ratio); extern void il3945_rx_replenish(void *data); extern void il3945_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq); extern unsigned int il3945_fill_beacon_frame(struct il_priv *il, - struct ieee80211_hdr *hdr, int left); + struct ieee80211_hdr *hdr, + int left); extern int il3945_dump_nic_event_log(struct il_priv *il, bool full_log, - char **buf, bool display); + char **buf, bool display); extern void il3945_dump_nic_error_log(struct il_priv *il); /****************************************************************************** @@ -229,34 +228,29 @@ extern void il3945_hw_txq_ctx_free(struct il_priv *il); extern void il3945_hw_txq_ctx_stop(struct il_priv *il); extern int il3945_hw_nic_reset(struct il_priv *il); extern int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il, - struct il_tx_queue *txq, - dma_addr_t addr, u16 len, - u8 reset, u8 pad); -extern void il3945_hw_txq_free_tfd(struct il_priv *il, - struct il_tx_queue *txq); + struct il_tx_queue *txq, + dma_addr_t addr, u16 len, u8 reset, + u8 pad); +extern void il3945_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq); extern int il3945_hw_get_temperature(struct il_priv *il); -extern int il3945_hw_tx_queue_init(struct il_priv *il, - struct il_tx_queue *txq); +extern int il3945_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq); extern unsigned int il3945_hw_get_beacon_cmd(struct il_priv *il, - struct il3945_frame *frame, u8 rate); -void il3945_hw_build_tx_cmd_rate(struct il_priv *il, - struct il_device_cmd *cmd, - struct ieee80211_tx_info *info, - struct ieee80211_hdr *hdr, - int sta_id, int tx_id); + struct il3945_frame *frame, + u8 rate); +void il3945_hw_build_tx_cmd_rate(struct il_priv *il, struct il_device_cmd *cmd, + struct ieee80211_tx_info *info, + struct ieee80211_hdr *hdr, int sta_id, + int tx_id); extern int il3945_hw_reg_send_txpower(struct il_priv *il); extern int il3945_hw_reg_set_txpower(struct il_priv *il, s8 power); -extern void il3945_hdl_stats(struct il_priv *il, - struct il_rx_buf *rxb); -void il3945_hdl_c_stats(struct il_priv *il, - struct il_rx_buf *rxb); +extern void il3945_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb); +void il3945_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb); extern void il3945_disable_events(struct il_priv *il); extern int il4965_get_temperature(const struct il_priv *il); extern void il3945_post_associate(struct il_priv *il); extern void il3945_config_ap(struct il_priv *il); -extern int il3945_commit_rxon(struct il_priv *il, - struct il_rxon_context *ctx); +extern int il3945_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx); /** * il3945_hw_find_station - Find station id for a given BSSID @@ -266,7 +260,7 @@ extern int il3945_commit_rxon(struct il_priv *il, * not yet been merged into a single common layer for managing the * station tables. */ -extern u8 il3945_hw_find_station(struct il_priv *il, const u8 *bssid); +extern u8 il3945_hw_find_station(struct il_priv *il, const u8 * bssid); extern struct ieee80211_ops il3945_hw_ops; @@ -275,8 +269,10 @@ extern int il3945_init_hw_rate_table(struct il_priv *il); extern void il3945_reg_txpower_periodic(struct il_priv *il); extern int il3945_txpower_set_from_eeprom(struct il_priv *il); -extern const struct il_channel_info *il3945_get_channel_info( - const struct il_priv *il, enum ieee80211_band band, u16 channel); +extern const struct il_channel_info *il3945_get_channel_info(const struct + il_priv *il, + enum ieee80211_band + band, u16 channel); extern int il3945_rs_next_rate(struct il_priv *il, int rate); @@ -287,8 +283,6 @@ void il3945_post_scan(struct il_priv *il); /* rates */ extern const struct il3945_rate_info il3945_rates[RATE_COUNT_3945]; - - /* RSSI to dBm */ #define IL39_RSSI_OFFSET 95 @@ -323,7 +317,7 @@ struct il3945_eeprom_txpower_sample { * DO NOT ALTER THIS STRUCTURE!!! */ struct il3945_eeprom_txpower_group { - struct il3945_eeprom_txpower_sample samples[5]; /* 5 power levels */ + struct il3945_eeprom_txpower_sample samples[5]; /* 5 power levels */ s32 a, b, c, d, e; /* coefficients for voltage->power * formula (signed) */ s32 Fa, Fb, Fc, Fd, Fe; /* these modify coeffs based on @@ -354,7 +348,7 @@ struct il3945_eeprom_temperature_corr { */ struct il3945_eeprom { u8 reserved0[16]; - u16 device_id; /* abs.ofs: 16 */ + u16 device_id; /* abs.ofs: 16 */ u8 reserved1[2]; u16 pmc; /* abs.ofs: 20 */ u8 reserved2[20]; @@ -389,7 +383,7 @@ struct il3945_eeprom { * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 */ u16 band_1_count; /* abs.ofs: 196 */ - struct il_eeprom_channel band_1_channels[14]; /* abs.ofs: 198 */ + struct il_eeprom_channel band_1_channels[14]; /* abs.ofs: 198 */ /* * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196, @@ -397,28 +391,28 @@ struct il3945_eeprom { * (4915-5080MHz) (none of these is ever supported) */ u16 band_2_count; /* abs.ofs: 226 */ - struct il_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */ + struct il_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */ /* * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 * (5170-5320MHz) */ u16 band_3_count; /* abs.ofs: 254 */ - struct il_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */ + struct il_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */ /* * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 * (5500-5700MHz) */ u16 band_4_count; /* abs.ofs: 280 */ - struct il_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */ + struct il_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */ /* * 5.7 GHz channels 145, 149, 153, 157, 161, 165 * (5725-5825MHz) */ u16 band_5_count; /* abs.ofs: 304 */ - struct il_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */ + struct il_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */ u8 reserved9[194]; @@ -428,7 +422,7 @@ struct il3945_eeprom { #define IL_NUM_TX_CALIB_GROUPS 5 struct il3945_eeprom_txpower_group groups[IL_NUM_TX_CALIB_GROUPS]; /* abs.ofs: 512 */ - struct il3945_eeprom_temperature_corr corrections; /* abs.ofs: 832 */ + struct il3945_eeprom_temperature_corr corrections; /* abs.ofs: 832 */ u8 reserved16[172]; /* fill out to full 1024 byte block */ } __packed; @@ -474,7 +468,8 @@ struct il3945_eeprom { /* Size of uCode instruction memory in bootstrap state machine */ #define IL39_MAX_BSM_SIZE IL39_RTC_INST_SIZE -static inline int il3945_hw_valid_rtc_data_addr(u32 addr) +static inline int +il3945_hw_valid_rtc_data_addr(u32 addr) { return (addr >= IL39_RTC_DATA_LOWER_BOUND && addr < IL39_RTC_DATA_UPPER_BOUND); @@ -486,19 +481,22 @@ struct il3945_shared { __le32 tx_base_ptr[8]; } __packed; -static inline u8 il3945_hw_get_rate(__le16 rate_n_flags) +static inline u8 +il3945_hw_get_rate(__le16 rate_n_flags) { return le16_to_cpu(rate_n_flags) & 0xFF; } -static inline u16 il3945_hw_get_rate_n_flags(__le16 rate_n_flags) +static inline u16 +il3945_hw_get_rate_n_flags(__le16 rate_n_flags) { return le16_to_cpu(rate_n_flags); } -static inline __le16 il3945_hw_set_rate_n_flags(u8 rate, u16 flags) +static inline __le16 +il3945_hw_set_rate_n_flags(u8 rate, u16 flags) { - return cpu_to_le16((u16)rate|flags); + return cpu_to_le16((u16) rate | flags); } /************************************/ @@ -553,7 +551,6 @@ static inline __le16 il3945_hw_set_rate_n_flags(u8 rate, u16 flags) #define FH39_TSSR_MSG_CONFIG (FH39_TSSR_TBL + 0x008) #define FH39_TSSR_TX_STATUS (FH39_TSSR_TBL + 0x010) - /* DBM */ #define FH39_SRVC_CHNL (6) @@ -622,29 +619,31 @@ struct il3945_tfd { } __packed; #ifdef CONFIG_IWLEGACY_DEBUGFS -ssize_t il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); -ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); +ssize_t il3945_ucode_rx_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos); +ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos); ssize_t il3945_ucode_general_stats_read(struct file *file, - char __user *user_buf, size_t count, - loff_t *ppos); + char __user * user_buf, size_t count, + loff_t * ppos); #else -static ssize_t il3945_ucode_rx_stats_read(struct file *file, - char __user *user_buf, size_t count, - loff_t *ppos) +static ssize_t +il3945_ucode_rx_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { return 0; } -static ssize_t il3945_ucode_tx_stats_read(struct file *file, - char __user *user_buf, size_t count, - loff_t *ppos) + +static ssize_t +il3945_ucode_tx_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { return 0; } -static ssize_t il3945_ucode_general_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) + +static ssize_t +il3945_ucode_general_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { return 0; } diff --git a/drivers/net/wireless/iwlegacy/4965-calib.c b/drivers/net/wireless/iwlegacy/4965-calib.c index 405032a9b36e..efb32331ec88 100644 --- a/drivers/net/wireless/iwlegacy/4965-calib.c +++ b/drivers/net/wireless/iwlegacy/4965-calib.c @@ -79,7 +79,8 @@ struct stats_general_data { u32 beacon_energy_c; }; -void il4965_calib_free_results(struct il_priv *il) +void +il4965_calib_free_results(struct il_priv *il) { int i; @@ -102,10 +103,9 @@ void il4965_calib_free_results(struct il_priv *il) * enough to receive all of our own network traffic, but not so * high that our DSP gets too busy trying to lock onto non-network * activity/noise. */ -static int il4965_sens_energy_cck(struct il_priv *il, - u32 norm_fa, - u32 rx_enable_time, - struct stats_general_data *rx_info) +static int +il4965_sens_energy_cck(struct il_priv *il, u32 norm_fa, u32 rx_enable_time, + struct stats_general_data *rx_info) { u32 max_nrg_cck = 0; int i = 0; @@ -138,12 +138,12 @@ static int il4965_sens_energy_cck(struct il_priv *il, /* Find max silence rssi among all 3 receivers. * This is background noise, which may include transmissions from other * networks, measured during silence before our network's beacon */ - silence_rssi_a = (u8)((rx_info->beacon_silence_rssi_a & - ALL_BAND_FILTER) >> 8); - silence_rssi_b = (u8)((rx_info->beacon_silence_rssi_b & - ALL_BAND_FILTER) >> 8); - silence_rssi_c = (u8)((rx_info->beacon_silence_rssi_c & - ALL_BAND_FILTER) >> 8); + silence_rssi_a = + (u8) ((rx_info->beacon_silence_rssi_a & ALL_BAND_FILTER) >> 8); + silence_rssi_b = + (u8) ((rx_info->beacon_silence_rssi_b & ALL_BAND_FILTER) >> 8); + silence_rssi_c = + (u8) ((rx_info->beacon_silence_rssi_c & ALL_BAND_FILTER) >> 8); val = max(silence_rssi_b, silence_rssi_c); max_silence_rssi = max(silence_rssi_a, (u8) val); @@ -159,9 +159,8 @@ static int il4965_sens_energy_cck(struct il_priv *il, val = data->nrg_silence_rssi[i]; silence_ref = max(silence_ref, val); } - D_CALIB("silence a %u, b %u, c %u, 20-bcn max %u\n", - silence_rssi_a, silence_rssi_b, silence_rssi_c, - silence_ref); + D_CALIB("silence a %u, b %u, c %u, 20-bcn max %u\n", silence_rssi_a, + silence_rssi_b, silence_rssi_c, silence_ref); /* Find max rx energy (min value!) among all 3 receivers, * measured during beacon frame. @@ -184,8 +183,8 @@ static int il4965_sens_energy_cck(struct il_priv *il, max_nrg_cck += 6; D_CALIB("rx energy a %u, b %u, c %u, 10-bcn max/min %u\n", - rx_info->beacon_energy_a, rx_info->beacon_energy_b, - rx_info->beacon_energy_c, max_nrg_cck - 6); + rx_info->beacon_energy_a, rx_info->beacon_energy_b, + rx_info->beacon_energy_c, max_nrg_cck - 6); /* Count number of consecutive beacons with fewer-than-desired * false alarms. */ @@ -194,13 +193,13 @@ static int il4965_sens_energy_cck(struct il_priv *il, else data->num_in_cck_no_fa = 0; D_CALIB("consecutive bcns with few false alarms = %u\n", - data->num_in_cck_no_fa); + data->num_in_cck_no_fa); /* If we got too many false alarms this time, reduce sensitivity */ if (false_alarms > max_false_alarms && data->auto_corr_cck > AUTO_CORR_MAX_TH_CCK) { - D_CALIB("norm FA %u > max FA %u\n", - false_alarms, max_false_alarms); + D_CALIB("norm FA %u > max FA %u\n", false_alarms, + max_false_alarms); D_CALIB("... reducing sensitivity\n"); data->nrg_curr_state = IL_FA_TOO_MANY; /* Store for "fewer than desired" on later beacon */ @@ -209,19 +208,18 @@ static int il4965_sens_energy_cck(struct il_priv *il, /* increase energy threshold (reduce nrg value) * to decrease sensitivity */ data->nrg_th_cck = data->nrg_th_cck - NRG_STEP_CCK; - /* Else if we got fewer than desired, increase sensitivity */ + /* Else if we got fewer than desired, increase sensitivity */ } else if (false_alarms < min_false_alarms) { data->nrg_curr_state = IL_FA_TOO_FEW; /* Compare silence level with silence level for most recent * healthy number or too many false alarms */ - data->nrg_auto_corr_silence_diff = (s32)data->nrg_silence_ref - - (s32)silence_ref; + data->nrg_auto_corr_silence_diff = + (s32) data->nrg_silence_ref - (s32) silence_ref; - D_CALIB( - "norm FA %u < min FA %u, silence diff %d\n", - false_alarms, min_false_alarms, - data->nrg_auto_corr_silence_diff); + D_CALIB("norm FA %u < min FA %u, silence diff %d\n", + false_alarms, min_false_alarms, + data->nrg_auto_corr_silence_diff); /* Increase value to increase sensitivity, but only if: * 1a) previous beacon did *not* have *too many* false alarms @@ -236,13 +234,12 @@ static int il4965_sens_energy_cck(struct il_priv *il, D_CALIB("... increasing sensitivity\n"); /* Increase nrg value to increase sensitivity */ val = data->nrg_th_cck + NRG_STEP_CCK; - data->nrg_th_cck = min((u32)ranges->min_nrg_cck, val); + data->nrg_th_cck = min((u32) ranges->min_nrg_cck, val); } else { - D_CALIB( - "... but not changing sensitivity\n"); + D_CALIB("... but not changing sensitivity\n"); } - /* Else we got a healthy number of false alarms, keep status quo */ + /* Else we got a healthy number of false alarms, keep status quo */ } else { D_CALIB(" FA in safe zone\n"); data->nrg_curr_state = IL_FA_GOOD_RANGE; @@ -283,31 +280,28 @@ static int il4965_sens_energy_cck(struct il_priv *il, else { val = data->auto_corr_cck + AUTO_CORR_STEP_CCK; data->auto_corr_cck = - min((u32)ranges->auto_corr_max_cck, val); + min((u32) ranges->auto_corr_max_cck, val); } val = data->auto_corr_cck_mrc + AUTO_CORR_STEP_CCK; data->auto_corr_cck_mrc = - min((u32)ranges->auto_corr_max_cck_mrc, val); + min((u32) ranges->auto_corr_max_cck_mrc, val); } else if (false_alarms < min_false_alarms && (data->nrg_auto_corr_silence_diff > NRG_DIFF || data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA)) { /* Decrease auto_corr values to increase sensitivity */ val = data->auto_corr_cck - AUTO_CORR_STEP_CCK; - data->auto_corr_cck = - max((u32)ranges->auto_corr_min_cck, val); + data->auto_corr_cck = max((u32) ranges->auto_corr_min_cck, val); val = data->auto_corr_cck_mrc - AUTO_CORR_STEP_CCK; data->auto_corr_cck_mrc = - max((u32)ranges->auto_corr_min_cck_mrc, val); + max((u32) ranges->auto_corr_min_cck_mrc, val); } return 0; } - -static int il4965_sens_auto_corr_ofdm(struct il_priv *il, - u32 norm_fa, - u32 rx_enable_time) +static int +il4965_sens_auto_corr_ofdm(struct il_priv *il, u32 norm_fa, u32 rx_enable_time) { u32 val; u32 false_alarms = norm_fa * 200 * 1024; @@ -321,96 +315,94 @@ static int il4965_sens_auto_corr_ofdm(struct il_priv *il, /* If we got too many false alarms this time, reduce sensitivity */ if (false_alarms > max_false_alarms) { - D_CALIB("norm FA %u > max FA %u)\n", - false_alarms, max_false_alarms); + D_CALIB("norm FA %u > max FA %u)\n", false_alarms, + max_false_alarms); val = data->auto_corr_ofdm + AUTO_CORR_STEP_OFDM; data->auto_corr_ofdm = - min((u32)ranges->auto_corr_max_ofdm, val); + min((u32) ranges->auto_corr_max_ofdm, val); val = data->auto_corr_ofdm_mrc + AUTO_CORR_STEP_OFDM; data->auto_corr_ofdm_mrc = - min((u32)ranges->auto_corr_max_ofdm_mrc, val); + min((u32) ranges->auto_corr_max_ofdm_mrc, val); val = data->auto_corr_ofdm_x1 + AUTO_CORR_STEP_OFDM; data->auto_corr_ofdm_x1 = - min((u32)ranges->auto_corr_max_ofdm_x1, val); + min((u32) ranges->auto_corr_max_ofdm_x1, val); val = data->auto_corr_ofdm_mrc_x1 + AUTO_CORR_STEP_OFDM; data->auto_corr_ofdm_mrc_x1 = - min((u32)ranges->auto_corr_max_ofdm_mrc_x1, val); + min((u32) ranges->auto_corr_max_ofdm_mrc_x1, val); } /* Else if we got fewer than desired, increase sensitivity */ else if (false_alarms < min_false_alarms) { - D_CALIB("norm FA %u < min FA %u\n", - false_alarms, min_false_alarms); + D_CALIB("norm FA %u < min FA %u\n", false_alarms, + min_false_alarms); val = data->auto_corr_ofdm - AUTO_CORR_STEP_OFDM; data->auto_corr_ofdm = - max((u32)ranges->auto_corr_min_ofdm, val); + max((u32) ranges->auto_corr_min_ofdm, val); val = data->auto_corr_ofdm_mrc - AUTO_CORR_STEP_OFDM; data->auto_corr_ofdm_mrc = - max((u32)ranges->auto_corr_min_ofdm_mrc, val); + max((u32) ranges->auto_corr_min_ofdm_mrc, val); val = data->auto_corr_ofdm_x1 - AUTO_CORR_STEP_OFDM; data->auto_corr_ofdm_x1 = - max((u32)ranges->auto_corr_min_ofdm_x1, val); + max((u32) ranges->auto_corr_min_ofdm_x1, val); val = data->auto_corr_ofdm_mrc_x1 - AUTO_CORR_STEP_OFDM; data->auto_corr_ofdm_mrc_x1 = - max((u32)ranges->auto_corr_min_ofdm_mrc_x1, val); + max((u32) ranges->auto_corr_min_ofdm_mrc_x1, val); } else { D_CALIB("min FA %u < norm FA %u < max FA %u OK\n", - min_false_alarms, false_alarms, max_false_alarms); + min_false_alarms, false_alarms, max_false_alarms); } return 0; } -static void il4965_prepare_legacy_sensitivity_tbl(struct il_priv *il, - struct il_sensitivity_data *data, - __le16 *tbl) +static void +il4965_prepare_legacy_sensitivity_tbl(struct il_priv *il, + struct il_sensitivity_data *data, + __le16 * tbl) { tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_IDX] = - cpu_to_le16((u16)data->auto_corr_ofdm); + cpu_to_le16((u16) data->auto_corr_ofdm); tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_MRC_IDX] = - cpu_to_le16((u16)data->auto_corr_ofdm_mrc); + cpu_to_le16((u16) data->auto_corr_ofdm_mrc); tbl[HD_AUTO_CORR32_X1_TH_ADD_MIN_IDX] = - cpu_to_le16((u16)data->auto_corr_ofdm_x1); + cpu_to_le16((u16) data->auto_corr_ofdm_x1); tbl[HD_AUTO_CORR32_X1_TH_ADD_MIN_MRC_IDX] = - cpu_to_le16((u16)data->auto_corr_ofdm_mrc_x1); + cpu_to_le16((u16) data->auto_corr_ofdm_mrc_x1); tbl[HD_AUTO_CORR40_X4_TH_ADD_MIN_IDX] = - cpu_to_le16((u16)data->auto_corr_cck); + cpu_to_le16((u16) data->auto_corr_cck); tbl[HD_AUTO_CORR40_X4_TH_ADD_MIN_MRC_IDX] = - cpu_to_le16((u16)data->auto_corr_cck_mrc); + cpu_to_le16((u16) data->auto_corr_cck_mrc); - tbl[HD_MIN_ENERGY_CCK_DET_IDX] = - cpu_to_le16((u16)data->nrg_th_cck); - tbl[HD_MIN_ENERGY_OFDM_DET_IDX] = - cpu_to_le16((u16)data->nrg_th_ofdm); + tbl[HD_MIN_ENERGY_CCK_DET_IDX] = cpu_to_le16((u16) data->nrg_th_cck); + tbl[HD_MIN_ENERGY_OFDM_DET_IDX] = cpu_to_le16((u16) data->nrg_th_ofdm); tbl[HD_BARKER_CORR_TH_ADD_MIN_IDX] = - cpu_to_le16(data->barker_corr_th_min); + cpu_to_le16(data->barker_corr_th_min); tbl[HD_BARKER_CORR_TH_ADD_MIN_MRC_IDX] = - cpu_to_le16(data->barker_corr_th_min_mrc); - tbl[HD_OFDM_ENERGY_TH_IN_IDX] = - cpu_to_le16(data->nrg_th_cca); + cpu_to_le16(data->barker_corr_th_min_mrc); + tbl[HD_OFDM_ENERGY_TH_IN_IDX] = cpu_to_le16(data->nrg_th_cca); D_CALIB("ofdm: ac %u mrc %u x1 %u mrc_x1 %u thresh %u\n", - data->auto_corr_ofdm, data->auto_corr_ofdm_mrc, - data->auto_corr_ofdm_x1, data->auto_corr_ofdm_mrc_x1, - data->nrg_th_ofdm); + data->auto_corr_ofdm, data->auto_corr_ofdm_mrc, + data->auto_corr_ofdm_x1, data->auto_corr_ofdm_mrc_x1, + data->nrg_th_ofdm); - D_CALIB("cck: ac %u mrc %u thresh %u\n", - data->auto_corr_cck, data->auto_corr_cck_mrc, - data->nrg_th_cck); + D_CALIB("cck: ac %u mrc %u thresh %u\n", data->auto_corr_cck, + data->auto_corr_cck_mrc, data->nrg_th_cck); } /* Prepare a C_SENSITIVITY, send to uCode if values have changed */ -static int il4965_sensitivity_write(struct il_priv *il) +static int +il4965_sensitivity_write(struct il_priv *il) { struct il_sensitivity_cmd cmd; struct il_sensitivity_data *data = NULL; @@ -431,20 +423,22 @@ static int il4965_sensitivity_write(struct il_priv *il) cmd.control = C_SENSITIVITY_CONTROL_WORK_TBL; /* Don't send command to uCode if nothing has changed */ - if (!memcmp(&cmd.table[0], &(il->sensitivity_tbl[0]), - sizeof(u16)*HD_TBL_SIZE)) { + if (!memcmp + (&cmd.table[0], &(il->sensitivity_tbl[0]), + sizeof(u16) * HD_TBL_SIZE)) { D_CALIB("No change in C_SENSITIVITY\n"); return 0; } /* Copy table for comparison next time */ memcpy(&(il->sensitivity_tbl[0]), &(cmd.table[0]), - sizeof(u16)*HD_TBL_SIZE); + sizeof(u16) * HD_TBL_SIZE); return il_send_cmd(il, &cmd_out); } -void il4965_init_sensitivity(struct il_priv *il) +void +il4965_init_sensitivity(struct il_priv *il) { int ret = 0; int i; @@ -477,9 +471,9 @@ void il4965_init_sensitivity(struct il_priv *il) for (i = 0; i < NRG_NUM_PREV_STAT_L; i++) data->nrg_silence_rssi[i] = 0; - data->auto_corr_ofdm = ranges->auto_corr_min_ofdm; + data->auto_corr_ofdm = ranges->auto_corr_min_ofdm; data->auto_corr_ofdm_mrc = ranges->auto_corr_min_ofdm_mrc; - data->auto_corr_ofdm_x1 = ranges->auto_corr_min_ofdm_x1; + data->auto_corr_ofdm_x1 = ranges->auto_corr_min_ofdm_x1; data->auto_corr_ofdm_mrc_x1 = ranges->auto_corr_min_ofdm_mrc_x1; data->auto_corr_cck = AUTO_CORR_CCK_MIN_VAL_DEF; data->auto_corr_cck_mrc = ranges->auto_corr_min_cck_mrc; @@ -498,7 +492,8 @@ void il4965_init_sensitivity(struct il_priv *il) D_CALIB("<plcp_err); statis.beacon_silence_rssi_a = - le32_to_cpu(rx_info->beacon_silence_rssi_a); + le32_to_cpu(rx_info->beacon_silence_rssi_a); statis.beacon_silence_rssi_b = - le32_to_cpu(rx_info->beacon_silence_rssi_b); + le32_to_cpu(rx_info->beacon_silence_rssi_b); statis.beacon_silence_rssi_c = - le32_to_cpu(rx_info->beacon_silence_rssi_c); - statis.beacon_energy_a = - le32_to_cpu(rx_info->beacon_energy_a); - statis.beacon_energy_b = - le32_to_cpu(rx_info->beacon_energy_b); - statis.beacon_energy_c = - le32_to_cpu(rx_info->beacon_energy_c); + le32_to_cpu(rx_info->beacon_silence_rssi_c); + statis.beacon_energy_a = le32_to_cpu(rx_info->beacon_energy_a); + statis.beacon_energy_b = le32_to_cpu(rx_info->beacon_energy_b); + statis.beacon_energy_c = le32_to_cpu(rx_info->beacon_energy_c); spin_unlock_irqrestore(&il->lock, flags); @@ -599,9 +591,8 @@ void il4965_sensitivity_calibration(struct il_priv *il, void *resp) norm_fa_ofdm = fa_ofdm + bad_plcp_ofdm; norm_fa_cck = fa_cck + bad_plcp_cck; - D_CALIB( - "cck: fa %u badp %u ofdm: fa %u badp %u\n", fa_cck, - bad_plcp_cck, fa_ofdm, bad_plcp_ofdm); + D_CALIB("cck: fa %u badp %u ofdm: fa %u badp %u\n", fa_cck, + bad_plcp_cck, fa_ofdm, bad_plcp_ofdm); il4965_sens_auto_corr_ofdm(il, norm_fa_ofdm, rx_enable_time); il4965_sens_energy_cck(il, norm_fa_cck, rx_enable_time, &statis); @@ -609,7 +600,8 @@ void il4965_sensitivity_calibration(struct il_priv *il, void *resp) il4965_sensitivity_write(il); } -static inline u8 il4965_find_first_chain(u8 mask) +static inline u8 +il4965_find_first_chain(u8 mask) { if (mask & ANT_A) return CHAIN_A; @@ -623,8 +615,8 @@ static inline u8 il4965_find_first_chain(u8 mask) * disconnected. */ static void -il4965_find_disconn_antenna(struct il_priv *il, u32* average_sig, - struct il_chain_noise_data *data) +il4965_find_disconn_antenna(struct il_priv *il, u32 * average_sig, + struct il_chain_noise_data *data) { u32 active_chains = 0; u32 max_average_sig; @@ -633,12 +625,15 @@ il4965_find_disconn_antenna(struct il_priv *il, u32* average_sig, u8 first_chain; u16 i = 0; - average_sig[0] = data->chain_signal_a / - il->cfg->base_params->chain_noise_num_beacons; - average_sig[1] = data->chain_signal_b / - il->cfg->base_params->chain_noise_num_beacons; - average_sig[2] = data->chain_signal_c / - il->cfg->base_params->chain_noise_num_beacons; + average_sig[0] = + data->chain_signal_a / + il->cfg->base_params->chain_noise_num_beacons; + average_sig[1] = + data->chain_signal_b / + il->cfg->base_params->chain_noise_num_beacons; + average_sig[2] = + data->chain_signal_c / + il->cfg->base_params->chain_noise_num_beacons; if (average_sig[0] >= average_sig[1]) { max_average_sig = average_sig[0]; @@ -656,10 +651,10 @@ il4965_find_disconn_antenna(struct il_priv *il, u32* average_sig, active_chains = (1 << max_average_sig_antenna_i); } - D_CALIB("average_sig: a %d b %d c %d\n", - average_sig[0], average_sig[1], average_sig[2]); - D_CALIB("max_average_sig = %d, antenna %d\n", - max_average_sig, max_average_sig_antenna_i); + D_CALIB("average_sig: a %d b %d c %d\n", average_sig[0], average_sig[1], + average_sig[2]); + D_CALIB("max_average_sig = %d, antenna %d\n", max_average_sig, + max_average_sig_antenna_i); /* Compare signal strengths for all 3 receivers. */ for (i = 0; i < NUM_RX_CHAINS; i++) { @@ -673,8 +668,8 @@ il4965_find_disconn_antenna(struct il_priv *il, u32* average_sig, else active_chains |= (1 << i); D_CALIB("i = %d rssiDelta = %d " - "disconn_array[i] = %d\n", - i, rssi_delta, data->disconn_array[i]); + "disconn_array[i] = %d\n", i, rssi_delta, + data->disconn_array[i]); } } @@ -709,34 +704,31 @@ il4965_find_disconn_antenna(struct il_priv *il, u32* average_sig, * connect the first valid tx chain */ first_chain = - il4965_find_first_chain(il->cfg->valid_tx_ant); + il4965_find_first_chain(il->cfg->valid_tx_ant); data->disconn_array[first_chain] = 0; active_chains |= BIT(first_chain); - D_CALIB( - "All Tx chains are disconnected W/A - declare %d as connected\n", - first_chain); + D_CALIB + ("All Tx chains are disconnected W/A - declare %d as connected\n", + first_chain); break; } } if (active_chains != il->hw_params.valid_rx_ant && active_chains != il->chain_noise_data.active_chains) - D_CALIB( - "Detected that not all antennas are connected! " - "Connected: %#x, valid: %#x.\n", - active_chains, il->hw_params.valid_rx_ant); + D_CALIB("Detected that not all antennas are connected! " + "Connected: %#x, valid: %#x.\n", active_chains, + il->hw_params.valid_rx_ant); /* Save for use within RXON, TX, SCAN commands, etc. */ data->active_chains = active_chains; - D_CALIB("active_chains (bitwise) = 0x%x\n", - active_chains); + D_CALIB("active_chains (bitwise) = 0x%x\n", active_chains); } -static void il4965_gain_computation(struct il_priv *il, - u32 *average_noise, - u16 min_average_noise_antenna_i, - u32 min_average_noise, - u8 default_chain) +static void +il4965_gain_computation(struct il_priv *il, u32 * average_noise, + u16 min_average_noise_antenna_i, u32 min_average_noise, + u8 default_chain) { int i, ret; struct il_chain_noise_data *data = &il->chain_noise_data; @@ -747,23 +739,22 @@ static void il4965_gain_computation(struct il_priv *il, s32 delta_g = 0; if (!data->disconn_array[i] && - data->delta_gain_code[i] == CHAIN_NOISE_DELTA_GAIN_INIT_VAL) { + data->delta_gain_code[i] == + CHAIN_NOISE_DELTA_GAIN_INIT_VAL) { delta_g = average_noise[i] - min_average_noise; - data->delta_gain_code[i] = (u8)((delta_g * 10) / 15); + data->delta_gain_code[i] = (u8) ((delta_g * 10) / 15); data->delta_gain_code[i] = - min(data->delta_gain_code[i], + min(data->delta_gain_code[i], (u8) CHAIN_NOISE_MAX_DELTA_GAIN_CODE); data->delta_gain_code[i] = - (data->delta_gain_code[i] | (1 << 2)); + (data->delta_gain_code[i] | (1 << 2)); } else { data->delta_gain_code[i] = 0; } } - D_CALIB("delta_gain_codes: a %d b %d c %d\n", - data->delta_gain_code[0], - data->delta_gain_code[1], - data->delta_gain_code[2]); + D_CALIB("delta_gain_codes: a %d b %d c %d\n", data->delta_gain_code[0], + data->delta_gain_code[1], data->delta_gain_code[2]); /* Differential gain gets sent to uCode only once */ if (!data->radio_write) { @@ -775,11 +766,9 @@ static void il4965_gain_computation(struct il_priv *il, cmd.diff_gain_a = data->delta_gain_code[0]; cmd.diff_gain_b = data->delta_gain_code[1]; cmd.diff_gain_c = data->delta_gain_code[2]; - ret = il_send_cmd_pdu(il, C_PHY_CALIBRATION, - sizeof(cmd), &cmd); + ret = il_send_cmd_pdu(il, C_PHY_CALIBRATION, sizeof(cmd), &cmd); if (ret) - D_CALIB("fail sending cmd " - "C_PHY_CALIBRATION\n"); + D_CALIB("fail sending cmd " "C_PHY_CALIBRATION\n"); /* TODO we might want recalculate * rx_chain in rxon cmd */ @@ -789,15 +778,14 @@ static void il4965_gain_computation(struct il_priv *il, } } - - /* * Accumulate 16 beacons of signal and noise stats for each of * 3 receivers/antennas/rx-chains, then figure out: * 1) Which antennas are connected. * 2) Differential rx gain settings to balance the 3 receivers. */ -void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) +void +il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) { struct il_chain_noise_data *data = NULL; @@ -807,8 +795,8 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) u32 chain_sig_a; u32 chain_sig_b; u32 chain_sig_c; - u32 average_sig[NUM_RX_CHAINS] = {INITIALIZATION_VALUE}; - u32 average_noise[NUM_RX_CHAINS] = {INITIALIZATION_VALUE}; + u32 average_sig[NUM_RX_CHAINS] = { INITIALIZATION_VALUE }; + u32 average_noise[NUM_RX_CHAINS] = { INITIALIZATION_VALUE }; u32 min_average_noise = MIN_AVERAGE_NOISE_MAX_VALUE; u16 min_average_noise_antenna_i = INITIALIZATION_VALUE; u16 i = 0; @@ -838,8 +826,7 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) spin_lock_irqsave(&il->lock, flags); - rx_info = &(((struct il_notif_stats *)stat_resp)-> - rx.general); + rx_info = &(((struct il_notif_stats *)stat_resp)->rx.general); if (rx_info->interference_data_flag != INTERFERENCE_DATA_AVAILABLE) { D_CALIB(" << Interference data unavailable\n"); @@ -850,17 +837,17 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) rxon_band24 = !!(ctx->staging.flags & RXON_FLG_BAND_24G_MSK); rxon_chnum = le16_to_cpu(ctx->staging.channel); - stat_band24 = !!(((struct il_notif_stats *) - stat_resp)->flag & - STATS_REPLY_FLG_BAND_24G_MSK); - stat_chnum = le32_to_cpu(((struct il_notif_stats *) - stat_resp)->flag) >> 16; + stat_band24 = + !!(((struct il_notif_stats *)stat_resp)-> + flag & STATS_REPLY_FLG_BAND_24G_MSK); + stat_chnum = + le32_to_cpu(((struct il_notif_stats *)stat_resp)->flag) >> 16; /* Make sure we accumulate data for just the associated channel * (even if scanning). */ if (rxon_chnum != stat_chnum || rxon_band24 != stat_band24) { - D_CALIB("Stats not from chan=%d, band24=%d\n", - rxon_chnum, rxon_band24); + D_CALIB("Stats not from chan=%d, band24=%d\n", rxon_chnum, + rxon_band24); spin_unlock_irqrestore(&il->lock, flags); return; } @@ -869,12 +856,12 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) * Accumulate beacon stats values across * "chain_noise_num_beacons" */ - chain_noise_a = le32_to_cpu(rx_info->beacon_silence_rssi_a) & - IN_BAND_FILTER; - chain_noise_b = le32_to_cpu(rx_info->beacon_silence_rssi_b) & - IN_BAND_FILTER; - chain_noise_c = le32_to_cpu(rx_info->beacon_silence_rssi_c) & - IN_BAND_FILTER; + chain_noise_a = + le32_to_cpu(rx_info->beacon_silence_rssi_a) & IN_BAND_FILTER; + chain_noise_b = + le32_to_cpu(rx_info->beacon_silence_rssi_b) & IN_BAND_FILTER; + chain_noise_c = + le32_to_cpu(rx_info->beacon_silence_rssi_c) & IN_BAND_FILTER; chain_sig_a = le32_to_cpu(rx_info->beacon_rssi_a) & IN_BAND_FILTER; chain_sig_b = le32_to_cpu(rx_info->beacon_rssi_b) & IN_BAND_FILTER; @@ -892,30 +879,29 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) data->chain_signal_b = (chain_sig_b + data->chain_signal_b); data->chain_signal_c = (chain_sig_c + data->chain_signal_c); - D_CALIB("chan=%d, band24=%d, beacon=%d\n", - rxon_chnum, rxon_band24, data->beacon_count); - D_CALIB("chain_sig: a %d b %d c %d\n", - chain_sig_a, chain_sig_b, chain_sig_c); - D_CALIB("chain_noise: a %d b %d c %d\n", - chain_noise_a, chain_noise_b, chain_noise_c); + D_CALIB("chan=%d, band24=%d, beacon=%d\n", rxon_chnum, rxon_band24, + data->beacon_count); + D_CALIB("chain_sig: a %d b %d c %d\n", chain_sig_a, chain_sig_b, + chain_sig_c); + D_CALIB("chain_noise: a %d b %d c %d\n", chain_noise_a, chain_noise_b, + chain_noise_c); /* If this is the "chain_noise_num_beacons", determine: * 1) Disconnected antennas (using signal strengths) * 2) Differential gain (using silence noise) to balance receivers */ - if (data->beacon_count != - il->cfg->base_params->chain_noise_num_beacons) + if (data->beacon_count != il->cfg->base_params->chain_noise_num_beacons) return; /* Analyze signal for disconnected antenna */ il4965_find_disconn_antenna(il, average_sig, data); /* Analyze noise for rx balance */ - average_noise[0] = data->chain_noise_a / - il->cfg->base_params->chain_noise_num_beacons; - average_noise[1] = data->chain_noise_b / - il->cfg->base_params->chain_noise_num_beacons; - average_noise[2] = data->chain_noise_c / - il->cfg->base_params->chain_noise_num_beacons; + average_noise[0] = + data->chain_noise_a / il->cfg->base_params->chain_noise_num_beacons; + average_noise[1] = + data->chain_noise_b / il->cfg->base_params->chain_noise_num_beacons; + average_noise[2] = + data->chain_noise_c / il->cfg->base_params->chain_noise_num_beacons; for (i = 0; i < NUM_RX_CHAINS; i++) { if (!data->disconn_array[i] && @@ -927,16 +913,15 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) } } - D_CALIB("average_noise: a %d b %d c %d\n", - average_noise[0], average_noise[1], - average_noise[2]); + D_CALIB("average_noise: a %d b %d c %d\n", average_noise[0], + average_noise[1], average_noise[2]); - D_CALIB("min_average_noise = %d, antenna %d\n", - min_average_noise, min_average_noise_antenna_i); + D_CALIB("min_average_noise = %d, antenna %d\n", min_average_noise, + min_average_noise_antenna_i); - il4965_gain_computation(il, average_noise, - min_average_noise_antenna_i, min_average_noise, - il4965_find_first_chain(il->cfg->valid_rx_ant)); + il4965_gain_computation(il, average_noise, min_average_noise_antenna_i, + min_average_noise, + il4965_find_first_chain(il->cfg->valid_rx_ant)); /* Some power changes may have been made during the calibration. * Update and commit the RXON @@ -948,16 +933,15 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp) il_power_update_mode(il, false); } -void il4965_reset_run_time_calib(struct il_priv *il) +void +il4965_reset_run_time_calib(struct il_priv *il) { int i; - memset(&(il->sensitivity_data), 0, - sizeof(struct il_sensitivity_data)); - memset(&(il->chain_noise_data), 0, - sizeof(struct il_chain_noise_data)); + memset(&(il->sensitivity_data), 0, sizeof(struct il_sensitivity_data)); + memset(&(il->chain_noise_data), 0, sizeof(struct il_chain_noise_data)); for (i = 0; i < NUM_RX_CHAINS; i++) il->chain_noise_data.delta_gain_code[i] = - CHAIN_NOISE_DELTA_GAIN_INIT_VAL; + CHAIN_NOISE_DELTA_GAIN_INIT_VAL; /* Ask for stats now, the uCode will send notification * periodically after association */ diff --git a/drivers/net/wireless/iwlegacy/4965-debug.c b/drivers/net/wireless/iwlegacy/4965-debug.c index 5f8903175168..529939938600 100644 --- a/drivers/net/wireless/iwlegacy/4965-debug.c +++ b/drivers/net/wireless/iwlegacy/4965-debug.c @@ -31,9 +31,10 @@ static const char *fmt_value = " %-30s %10u\n"; static const char *fmt_table = " %-30s %10u %10u %10u %10u\n"; static const char *fmt_header = - "%-32s current cumulative delta max\n"; + "%-32s current cumulative delta max\n"; -static int il4965_stats_flag(struct il_priv *il, char *buf, int bufsz) +static int +il4965_stats_flag(struct il_priv *il, char *buf, int bufsz) { int p = 0; u32 flag; @@ -43,26 +44,28 @@ static int il4965_stats_flag(struct il_priv *il, char *buf, int bufsz) p += scnprintf(buf + p, bufsz - p, "Statistics Flag(0x%X):\n", flag); if (flag & UCODE_STATS_CLEAR_MSK) p += scnprintf(buf + p, bufsz - p, - "\tStatistics have been cleared\n"); + "\tStatistics have been cleared\n"); p += scnprintf(buf + p, bufsz - p, "\tOperational Frequency: %s\n", - (flag & UCODE_STATS_FREQUENCY_MSK) - ? "2.4 GHz" : "5.2 GHz"); + (flag & UCODE_STATS_FREQUENCY_MSK) ? "2.4 GHz" : + "5.2 GHz"); p += scnprintf(buf + p, bufsz - p, "\tTGj Narrow Band: %s\n", - (flag & UCODE_STATS_NARROW_BAND_MSK) - ? "enabled" : "disabled"); + (flag & UCODE_STATS_NARROW_BAND_MSK) ? "enabled" : + "disabled"); return p; } -ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) +ssize_t +il4965_ucode_rx_stats_read(struct file * file, char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; int pos = 0; char *buf; - int bufsz = sizeof(struct stats_rx_phy) * 40 + - sizeof(struct stats_rx_non_phy) * 40 + - sizeof(struct stats_rx_ht_phy) * 40 + 400; + int bufsz = + sizeof(struct stats_rx_phy) * 40 + + sizeof(struct stats_rx_non_phy) * 40 + + sizeof(struct stats_rx_ht_phy) * 40 + 400; ssize_t ret; struct stats_rx_phy *ofdm, *accum_ofdm, *delta_ofdm, *max_ofdm; struct stats_rx_phy *cck, *accum_cck, *delta_cck, *max_cck; @@ -102,392 +105,371 @@ ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, max_ht = &il->_4965.max_delta.rx.ofdm_ht; pos += il4965_stats_flag(il, buf, bufsz); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_header, "Statistics_Rx - OFDM:"); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "ina_cnt:", - le32_to_cpu(ofdm->ina_cnt), - accum_ofdm->ina_cnt, - delta_ofdm->ina_cnt, max_ofdm->ina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "fina_cnt:", - le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt, - delta_ofdm->fina_cnt, max_ofdm->fina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "plcp_err:", - le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err, - delta_ofdm->plcp_err, max_ofdm->plcp_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "crc32_err:", - le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err, - delta_ofdm->crc32_err, max_ofdm->crc32_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "overrun_err:", - le32_to_cpu(ofdm->overrun_err), - accum_ofdm->overrun_err, delta_ofdm->overrun_err, - max_ofdm->overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "early_overrun_err:", - le32_to_cpu(ofdm->early_overrun_err), - accum_ofdm->early_overrun_err, - delta_ofdm->early_overrun_err, - max_ofdm->early_overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "crc32_good:", - le32_to_cpu(ofdm->crc32_good), - accum_ofdm->crc32_good, delta_ofdm->crc32_good, - max_ofdm->crc32_good); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "false_alarm_cnt:", - le32_to_cpu(ofdm->false_alarm_cnt), - accum_ofdm->false_alarm_cnt, - delta_ofdm->false_alarm_cnt, - max_ofdm->false_alarm_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "fina_sync_err_cnt:", - le32_to_cpu(ofdm->fina_sync_err_cnt), - accum_ofdm->fina_sync_err_cnt, - delta_ofdm->fina_sync_err_cnt, - max_ofdm->fina_sync_err_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sfd_timeout:", - le32_to_cpu(ofdm->sfd_timeout), - accum_ofdm->sfd_timeout, delta_ofdm->sfd_timeout, - max_ofdm->sfd_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "fina_timeout:", - le32_to_cpu(ofdm->fina_timeout), - accum_ofdm->fina_timeout, delta_ofdm->fina_timeout, - max_ofdm->fina_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "unresponded_rts:", - le32_to_cpu(ofdm->unresponded_rts), - accum_ofdm->unresponded_rts, - delta_ofdm->unresponded_rts, - max_ofdm->unresponded_rts); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "rxe_frame_lmt_ovrun:", - le32_to_cpu(ofdm->rxe_frame_limit_overrun), - accum_ofdm->rxe_frame_limit_overrun, - delta_ofdm->rxe_frame_limit_overrun, - max_ofdm->rxe_frame_limit_overrun); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sent_ack_cnt:", - le32_to_cpu(ofdm->sent_ack_cnt), - accum_ofdm->sent_ack_cnt, delta_ofdm->sent_ack_cnt, - max_ofdm->sent_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sent_cts_cnt:", - le32_to_cpu(ofdm->sent_cts_cnt), - accum_ofdm->sent_cts_cnt, delta_ofdm->sent_cts_cnt, - max_ofdm->sent_cts_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sent_ba_rsp_cnt:", - le32_to_cpu(ofdm->sent_ba_rsp_cnt), - accum_ofdm->sent_ba_rsp_cnt, - delta_ofdm->sent_ba_rsp_cnt, - max_ofdm->sent_ba_rsp_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "dsp_self_kill:", - le32_to_cpu(ofdm->dsp_self_kill), - accum_ofdm->dsp_self_kill, - delta_ofdm->dsp_self_kill, - max_ofdm->dsp_self_kill); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "mh_format_err:", - le32_to_cpu(ofdm->mh_format_err), - accum_ofdm->mh_format_err, - delta_ofdm->mh_format_err, - max_ofdm->mh_format_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "re_acq_main_rssi_sum:", - le32_to_cpu(ofdm->re_acq_main_rssi_sum), - accum_ofdm->re_acq_main_rssi_sum, - delta_ofdm->re_acq_main_rssi_sum, - max_ofdm->re_acq_main_rssi_sum); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_header, + "Statistics_Rx - OFDM:"); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "ina_cnt:", + le32_to_cpu(ofdm->ina_cnt), accum_ofdm->ina_cnt, + delta_ofdm->ina_cnt, max_ofdm->ina_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_cnt:", + le32_to_cpu(ofdm->fina_cnt), accum_ofdm->fina_cnt, + delta_ofdm->fina_cnt, max_ofdm->fina_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "plcp_err:", + le32_to_cpu(ofdm->plcp_err), accum_ofdm->plcp_err, + delta_ofdm->plcp_err, max_ofdm->plcp_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_err:", + le32_to_cpu(ofdm->crc32_err), accum_ofdm->crc32_err, + delta_ofdm->crc32_err, max_ofdm->crc32_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "overrun_err:", + le32_to_cpu(ofdm->overrun_err), accum_ofdm->overrun_err, + delta_ofdm->overrun_err, max_ofdm->overrun_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "early_overrun_err:", + le32_to_cpu(ofdm->early_overrun_err), + accum_ofdm->early_overrun_err, + delta_ofdm->early_overrun_err, + max_ofdm->early_overrun_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_good:", + le32_to_cpu(ofdm->crc32_good), accum_ofdm->crc32_good, + delta_ofdm->crc32_good, max_ofdm->crc32_good); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "false_alarm_cnt:", + le32_to_cpu(ofdm->false_alarm_cnt), + accum_ofdm->false_alarm_cnt, delta_ofdm->false_alarm_cnt, + max_ofdm->false_alarm_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_sync_err_cnt:", + le32_to_cpu(ofdm->fina_sync_err_cnt), + accum_ofdm->fina_sync_err_cnt, + delta_ofdm->fina_sync_err_cnt, + max_ofdm->fina_sync_err_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "sfd_timeout:", + le32_to_cpu(ofdm->sfd_timeout), accum_ofdm->sfd_timeout, + delta_ofdm->sfd_timeout, max_ofdm->sfd_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_timeout:", + le32_to_cpu(ofdm->fina_timeout), accum_ofdm->fina_timeout, + delta_ofdm->fina_timeout, max_ofdm->fina_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "unresponded_rts:", + le32_to_cpu(ofdm->unresponded_rts), + accum_ofdm->unresponded_rts, delta_ofdm->unresponded_rts, + max_ofdm->unresponded_rts); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "rxe_frame_lmt_ovrun:", + le32_to_cpu(ofdm->rxe_frame_limit_overrun), + accum_ofdm->rxe_frame_limit_overrun, + delta_ofdm->rxe_frame_limit_overrun, + max_ofdm->rxe_frame_limit_overrun); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_ack_cnt:", + le32_to_cpu(ofdm->sent_ack_cnt), accum_ofdm->sent_ack_cnt, + delta_ofdm->sent_ack_cnt, max_ofdm->sent_ack_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_cts_cnt:", + le32_to_cpu(ofdm->sent_cts_cnt), accum_ofdm->sent_cts_cnt, + delta_ofdm->sent_cts_cnt, max_ofdm->sent_cts_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_ba_rsp_cnt:", + le32_to_cpu(ofdm->sent_ba_rsp_cnt), + accum_ofdm->sent_ba_rsp_cnt, delta_ofdm->sent_ba_rsp_cnt, + max_ofdm->sent_ba_rsp_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "dsp_self_kill:", + le32_to_cpu(ofdm->dsp_self_kill), + accum_ofdm->dsp_self_kill, delta_ofdm->dsp_self_kill, + max_ofdm->dsp_self_kill); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "mh_format_err:", + le32_to_cpu(ofdm->mh_format_err), + accum_ofdm->mh_format_err, delta_ofdm->mh_format_err, + max_ofdm->mh_format_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "re_acq_main_rssi_sum:", + le32_to_cpu(ofdm->re_acq_main_rssi_sum), + accum_ofdm->re_acq_main_rssi_sum, + delta_ofdm->re_acq_main_rssi_sum, + max_ofdm->re_acq_main_rssi_sum); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_header, "Statistics_Rx - CCK:"); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "ina_cnt:", - le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt, - delta_cck->ina_cnt, max_cck->ina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "fina_cnt:", - le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt, - delta_cck->fina_cnt, max_cck->fina_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "plcp_err:", - le32_to_cpu(cck->plcp_err), accum_cck->plcp_err, - delta_cck->plcp_err, max_cck->plcp_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "crc32_err:", - le32_to_cpu(cck->crc32_err), accum_cck->crc32_err, - delta_cck->crc32_err, max_cck->crc32_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "overrun_err:", - le32_to_cpu(cck->overrun_err), - accum_cck->overrun_err, delta_cck->overrun_err, - max_cck->overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "early_overrun_err:", - le32_to_cpu(cck->early_overrun_err), - accum_cck->early_overrun_err, - delta_cck->early_overrun_err, - max_cck->early_overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "crc32_good:", - le32_to_cpu(cck->crc32_good), accum_cck->crc32_good, - delta_cck->crc32_good, max_cck->crc32_good); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "false_alarm_cnt:", - le32_to_cpu(cck->false_alarm_cnt), - accum_cck->false_alarm_cnt, - delta_cck->false_alarm_cnt, max_cck->false_alarm_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "fina_sync_err_cnt:", - le32_to_cpu(cck->fina_sync_err_cnt), - accum_cck->fina_sync_err_cnt, - delta_cck->fina_sync_err_cnt, - max_cck->fina_sync_err_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sfd_timeout:", - le32_to_cpu(cck->sfd_timeout), - accum_cck->sfd_timeout, delta_cck->sfd_timeout, - max_cck->sfd_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "fina_timeout:", - le32_to_cpu(cck->fina_timeout), - accum_cck->fina_timeout, delta_cck->fina_timeout, - max_cck->fina_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "unresponded_rts:", - le32_to_cpu(cck->unresponded_rts), - accum_cck->unresponded_rts, delta_cck->unresponded_rts, - max_cck->unresponded_rts); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "rxe_frame_lmt_ovrun:", - le32_to_cpu(cck->rxe_frame_limit_overrun), - accum_cck->rxe_frame_limit_overrun, - delta_cck->rxe_frame_limit_overrun, - max_cck->rxe_frame_limit_overrun); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sent_ack_cnt:", - le32_to_cpu(cck->sent_ack_cnt), - accum_cck->sent_ack_cnt, delta_cck->sent_ack_cnt, - max_cck->sent_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sent_cts_cnt:", - le32_to_cpu(cck->sent_cts_cnt), - accum_cck->sent_cts_cnt, delta_cck->sent_cts_cnt, - max_cck->sent_cts_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sent_ba_rsp_cnt:", - le32_to_cpu(cck->sent_ba_rsp_cnt), - accum_cck->sent_ba_rsp_cnt, - delta_cck->sent_ba_rsp_cnt, - max_cck->sent_ba_rsp_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "dsp_self_kill:", - le32_to_cpu(cck->dsp_self_kill), - accum_cck->dsp_self_kill, delta_cck->dsp_self_kill, - max_cck->dsp_self_kill); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "mh_format_err:", - le32_to_cpu(cck->mh_format_err), - accum_cck->mh_format_err, delta_cck->mh_format_err, - max_cck->mh_format_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "re_acq_main_rssi_sum:", - le32_to_cpu(cck->re_acq_main_rssi_sum), - accum_cck->re_acq_main_rssi_sum, - delta_cck->re_acq_main_rssi_sum, - max_cck->re_acq_main_rssi_sum); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_header, + "Statistics_Rx - CCK:"); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "ina_cnt:", + le32_to_cpu(cck->ina_cnt), accum_cck->ina_cnt, + delta_cck->ina_cnt, max_cck->ina_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_cnt:", + le32_to_cpu(cck->fina_cnt), accum_cck->fina_cnt, + delta_cck->fina_cnt, max_cck->fina_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "plcp_err:", + le32_to_cpu(cck->plcp_err), accum_cck->plcp_err, + delta_cck->plcp_err, max_cck->plcp_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_err:", + le32_to_cpu(cck->crc32_err), accum_cck->crc32_err, + delta_cck->crc32_err, max_cck->crc32_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "overrun_err:", + le32_to_cpu(cck->overrun_err), accum_cck->overrun_err, + delta_cck->overrun_err, max_cck->overrun_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "early_overrun_err:", + le32_to_cpu(cck->early_overrun_err), + accum_cck->early_overrun_err, + delta_cck->early_overrun_err, max_cck->early_overrun_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_good:", + le32_to_cpu(cck->crc32_good), accum_cck->crc32_good, + delta_cck->crc32_good, max_cck->crc32_good); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "false_alarm_cnt:", + le32_to_cpu(cck->false_alarm_cnt), + accum_cck->false_alarm_cnt, delta_cck->false_alarm_cnt, + max_cck->false_alarm_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_sync_err_cnt:", + le32_to_cpu(cck->fina_sync_err_cnt), + accum_cck->fina_sync_err_cnt, + delta_cck->fina_sync_err_cnt, max_cck->fina_sync_err_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "sfd_timeout:", + le32_to_cpu(cck->sfd_timeout), accum_cck->sfd_timeout, + delta_cck->sfd_timeout, max_cck->sfd_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "fina_timeout:", + le32_to_cpu(cck->fina_timeout), accum_cck->fina_timeout, + delta_cck->fina_timeout, max_cck->fina_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "unresponded_rts:", + le32_to_cpu(cck->unresponded_rts), + accum_cck->unresponded_rts, delta_cck->unresponded_rts, + max_cck->unresponded_rts); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "rxe_frame_lmt_ovrun:", + le32_to_cpu(cck->rxe_frame_limit_overrun), + accum_cck->rxe_frame_limit_overrun, + delta_cck->rxe_frame_limit_overrun, + max_cck->rxe_frame_limit_overrun); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_ack_cnt:", + le32_to_cpu(cck->sent_ack_cnt), accum_cck->sent_ack_cnt, + delta_cck->sent_ack_cnt, max_cck->sent_ack_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_cts_cnt:", + le32_to_cpu(cck->sent_cts_cnt), accum_cck->sent_cts_cnt, + delta_cck->sent_cts_cnt, max_cck->sent_cts_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "sent_ba_rsp_cnt:", + le32_to_cpu(cck->sent_ba_rsp_cnt), + accum_cck->sent_ba_rsp_cnt, delta_cck->sent_ba_rsp_cnt, + max_cck->sent_ba_rsp_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "dsp_self_kill:", + le32_to_cpu(cck->dsp_self_kill), accum_cck->dsp_self_kill, + delta_cck->dsp_self_kill, max_cck->dsp_self_kill); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "mh_format_err:", + le32_to_cpu(cck->mh_format_err), accum_cck->mh_format_err, + delta_cck->mh_format_err, max_cck->mh_format_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "re_acq_main_rssi_sum:", + le32_to_cpu(cck->re_acq_main_rssi_sum), + accum_cck->re_acq_main_rssi_sum, + delta_cck->re_acq_main_rssi_sum, + max_cck->re_acq_main_rssi_sum); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_header, "Statistics_Rx - GENERAL:"); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "bogus_cts:", - le32_to_cpu(general->bogus_cts), - accum_general->bogus_cts, delta_general->bogus_cts, - max_general->bogus_cts); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "bogus_ack:", - le32_to_cpu(general->bogus_ack), - accum_general->bogus_ack, delta_general->bogus_ack, - max_general->bogus_ack); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "non_bssid_frames:", - le32_to_cpu(general->non_bssid_frames), - accum_general->non_bssid_frames, - delta_general->non_bssid_frames, - max_general->non_bssid_frames); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "filtered_frames:", - le32_to_cpu(general->filtered_frames), - accum_general->filtered_frames, - delta_general->filtered_frames, - max_general->filtered_frames); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "non_channel_beacons:", - le32_to_cpu(general->non_channel_beacons), - accum_general->non_channel_beacons, - delta_general->non_channel_beacons, - max_general->non_channel_beacons); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "channel_beacons:", - le32_to_cpu(general->channel_beacons), - accum_general->channel_beacons, - delta_general->channel_beacons, - max_general->channel_beacons); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "num_missed_bcon:", - le32_to_cpu(general->num_missed_bcon), - accum_general->num_missed_bcon, - delta_general->num_missed_bcon, - max_general->num_missed_bcon); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "adc_rx_saturation_time:", - le32_to_cpu(general->adc_rx_saturation_time), - accum_general->adc_rx_saturation_time, - delta_general->adc_rx_saturation_time, - max_general->adc_rx_saturation_time); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "ina_detect_search_tm:", - le32_to_cpu(general->ina_detection_search_time), - accum_general->ina_detection_search_time, - delta_general->ina_detection_search_time, - max_general->ina_detection_search_time); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_silence_rssi_a:", - le32_to_cpu(general->beacon_silence_rssi_a), - accum_general->beacon_silence_rssi_a, - delta_general->beacon_silence_rssi_a, - max_general->beacon_silence_rssi_a); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_silence_rssi_b:", - le32_to_cpu(general->beacon_silence_rssi_b), - accum_general->beacon_silence_rssi_b, - delta_general->beacon_silence_rssi_b, - max_general->beacon_silence_rssi_b); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_silence_rssi_c:", - le32_to_cpu(general->beacon_silence_rssi_c), - accum_general->beacon_silence_rssi_c, - delta_general->beacon_silence_rssi_c, - max_general->beacon_silence_rssi_c); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "interference_data_flag:", - le32_to_cpu(general->interference_data_flag), - accum_general->interference_data_flag, - delta_general->interference_data_flag, - max_general->interference_data_flag); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "channel_load:", - le32_to_cpu(general->channel_load), - accum_general->channel_load, - delta_general->channel_load, - max_general->channel_load); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "dsp_false_alarms:", - le32_to_cpu(general->dsp_false_alarms), - accum_general->dsp_false_alarms, - delta_general->dsp_false_alarms, - max_general->dsp_false_alarms); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_rssi_a:", - le32_to_cpu(general->beacon_rssi_a), - accum_general->beacon_rssi_a, - delta_general->beacon_rssi_a, - max_general->beacon_rssi_a); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_rssi_b:", - le32_to_cpu(general->beacon_rssi_b), - accum_general->beacon_rssi_b, - delta_general->beacon_rssi_b, - max_general->beacon_rssi_b); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_rssi_c:", - le32_to_cpu(general->beacon_rssi_c), - accum_general->beacon_rssi_c, - delta_general->beacon_rssi_c, - max_general->beacon_rssi_c); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_energy_a:", - le32_to_cpu(general->beacon_energy_a), - accum_general->beacon_energy_a, - delta_general->beacon_energy_a, - max_general->beacon_energy_a); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_energy_b:", - le32_to_cpu(general->beacon_energy_b), - accum_general->beacon_energy_b, - delta_general->beacon_energy_b, - max_general->beacon_energy_b); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "beacon_energy_c:", - le32_to_cpu(general->beacon_energy_c), - accum_general->beacon_energy_c, - delta_general->beacon_energy_c, - max_general->beacon_energy_c); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_header, + "Statistics_Rx - GENERAL:"); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "bogus_cts:", + le32_to_cpu(general->bogus_cts), accum_general->bogus_cts, + delta_general->bogus_cts, max_general->bogus_cts); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "bogus_ack:", + le32_to_cpu(general->bogus_ack), accum_general->bogus_ack, + delta_general->bogus_ack, max_general->bogus_ack); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "non_bssid_frames:", + le32_to_cpu(general->non_bssid_frames), + accum_general->non_bssid_frames, + delta_general->non_bssid_frames, + max_general->non_bssid_frames); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "filtered_frames:", + le32_to_cpu(general->filtered_frames), + accum_general->filtered_frames, + delta_general->filtered_frames, + max_general->filtered_frames); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "non_channel_beacons:", + le32_to_cpu(general->non_channel_beacons), + accum_general->non_channel_beacons, + delta_general->non_channel_beacons, + max_general->non_channel_beacons); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "channel_beacons:", + le32_to_cpu(general->channel_beacons), + accum_general->channel_beacons, + delta_general->channel_beacons, + max_general->channel_beacons); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "num_missed_bcon:", + le32_to_cpu(general->num_missed_bcon), + accum_general->num_missed_bcon, + delta_general->num_missed_bcon, + max_general->num_missed_bcon); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "adc_rx_saturation_time:", + le32_to_cpu(general->adc_rx_saturation_time), + accum_general->adc_rx_saturation_time, + delta_general->adc_rx_saturation_time, + max_general->adc_rx_saturation_time); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "ina_detect_search_tm:", + le32_to_cpu(general->ina_detection_search_time), + accum_general->ina_detection_search_time, + delta_general->ina_detection_search_time, + max_general->ina_detection_search_time); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "beacon_silence_rssi_a:", + le32_to_cpu(general->beacon_silence_rssi_a), + accum_general->beacon_silence_rssi_a, + delta_general->beacon_silence_rssi_a, + max_general->beacon_silence_rssi_a); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "beacon_silence_rssi_b:", + le32_to_cpu(general->beacon_silence_rssi_b), + accum_general->beacon_silence_rssi_b, + delta_general->beacon_silence_rssi_b, + max_general->beacon_silence_rssi_b); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "beacon_silence_rssi_c:", + le32_to_cpu(general->beacon_silence_rssi_c), + accum_general->beacon_silence_rssi_c, + delta_general->beacon_silence_rssi_c, + max_general->beacon_silence_rssi_c); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "interference_data_flag:", + le32_to_cpu(general->interference_data_flag), + accum_general->interference_data_flag, + delta_general->interference_data_flag, + max_general->interference_data_flag); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "channel_load:", + le32_to_cpu(general->channel_load), + accum_general->channel_load, delta_general->channel_load, + max_general->channel_load); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "dsp_false_alarms:", + le32_to_cpu(general->dsp_false_alarms), + accum_general->dsp_false_alarms, + delta_general->dsp_false_alarms, + max_general->dsp_false_alarms); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_rssi_a:", + le32_to_cpu(general->beacon_rssi_a), + accum_general->beacon_rssi_a, + delta_general->beacon_rssi_a, max_general->beacon_rssi_a); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_rssi_b:", + le32_to_cpu(general->beacon_rssi_b), + accum_general->beacon_rssi_b, + delta_general->beacon_rssi_b, max_general->beacon_rssi_b); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_rssi_c:", + le32_to_cpu(general->beacon_rssi_c), + accum_general->beacon_rssi_c, + delta_general->beacon_rssi_c, max_general->beacon_rssi_c); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_energy_a:", + le32_to_cpu(general->beacon_energy_a), + accum_general->beacon_energy_a, + delta_general->beacon_energy_a, + max_general->beacon_energy_a); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_energy_b:", + le32_to_cpu(general->beacon_energy_b), + accum_general->beacon_energy_b, + delta_general->beacon_energy_b, + max_general->beacon_energy_b); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "beacon_energy_c:", + le32_to_cpu(general->beacon_energy_c), + accum_general->beacon_energy_c, + delta_general->beacon_energy_c, + max_general->beacon_energy_c); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_header, "Statistics_Rx - OFDM_HT:"); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "plcp_err:", - le32_to_cpu(ht->plcp_err), accum_ht->plcp_err, - delta_ht->plcp_err, max_ht->plcp_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "overrun_err:", - le32_to_cpu(ht->overrun_err), accum_ht->overrun_err, - delta_ht->overrun_err, max_ht->overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "early_overrun_err:", - le32_to_cpu(ht->early_overrun_err), - accum_ht->early_overrun_err, - delta_ht->early_overrun_err, - max_ht->early_overrun_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "crc32_good:", - le32_to_cpu(ht->crc32_good), accum_ht->crc32_good, - delta_ht->crc32_good, max_ht->crc32_good); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "crc32_err:", - le32_to_cpu(ht->crc32_err), accum_ht->crc32_err, - delta_ht->crc32_err, max_ht->crc32_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "mh_format_err:", - le32_to_cpu(ht->mh_format_err), - accum_ht->mh_format_err, - delta_ht->mh_format_err, max_ht->mh_format_err); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg_crc32_good:", - le32_to_cpu(ht->agg_crc32_good), - accum_ht->agg_crc32_good, - delta_ht->agg_crc32_good, max_ht->agg_crc32_good); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg_mpdu_cnt:", - le32_to_cpu(ht->agg_mpdu_cnt), - accum_ht->agg_mpdu_cnt, - delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg_cnt:", - le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt, - delta_ht->agg_cnt, max_ht->agg_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "unsupport_mcs:", - le32_to_cpu(ht->unsupport_mcs), - accum_ht->unsupport_mcs, - delta_ht->unsupport_mcs, max_ht->unsupport_mcs); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_header, + "Statistics_Rx - OFDM_HT:"); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "plcp_err:", + le32_to_cpu(ht->plcp_err), accum_ht->plcp_err, + delta_ht->plcp_err, max_ht->plcp_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "overrun_err:", + le32_to_cpu(ht->overrun_err), accum_ht->overrun_err, + delta_ht->overrun_err, max_ht->overrun_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "early_overrun_err:", + le32_to_cpu(ht->early_overrun_err), + accum_ht->early_overrun_err, delta_ht->early_overrun_err, + max_ht->early_overrun_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_good:", + le32_to_cpu(ht->crc32_good), accum_ht->crc32_good, + delta_ht->crc32_good, max_ht->crc32_good); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "crc32_err:", + le32_to_cpu(ht->crc32_err), accum_ht->crc32_err, + delta_ht->crc32_err, max_ht->crc32_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "mh_format_err:", + le32_to_cpu(ht->mh_format_err), accum_ht->mh_format_err, + delta_ht->mh_format_err, max_ht->mh_format_err); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "agg_crc32_good:", + le32_to_cpu(ht->agg_crc32_good), accum_ht->agg_crc32_good, + delta_ht->agg_crc32_good, max_ht->agg_crc32_good); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "agg_mpdu_cnt:", + le32_to_cpu(ht->agg_mpdu_cnt), accum_ht->agg_mpdu_cnt, + delta_ht->agg_mpdu_cnt, max_ht->agg_mpdu_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "agg_cnt:", + le32_to_cpu(ht->agg_cnt), accum_ht->agg_cnt, + delta_ht->agg_cnt, max_ht->agg_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "unsupport_mcs:", + le32_to_cpu(ht->unsupport_mcs), accum_ht->unsupport_mcs, + delta_ht->unsupport_mcs, max_ht->unsupport_mcs); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; } -ssize_t il4965_ucode_tx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +ssize_t +il4965_ucode_tx_stats_read(struct file * file, char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; int pos = 0; @@ -506,154 +488,145 @@ ssize_t il4965_ucode_tx_stats_read(struct file *file, } /* the statistic information display here is based on - * the last stats notification from uCode - * might not reflect the current uCode activity - */ + * the last stats notification from uCode + * might not reflect the current uCode activity + */ tx = &il->_4965.stats.tx; accum_tx = &il->_4965.accum_stats.tx; delta_tx = &il->_4965.delta_stats.tx; max_tx = &il->_4965.max_delta.tx; pos += il4965_stats_flag(il, buf, bufsz); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_header, "Statistics_Tx:"); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "preamble:", - le32_to_cpu(tx->preamble_cnt), - accum_tx->preamble_cnt, - delta_tx->preamble_cnt, max_tx->preamble_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "rx_detected_cnt:", - le32_to_cpu(tx->rx_detected_cnt), - accum_tx->rx_detected_cnt, - delta_tx->rx_detected_cnt, max_tx->rx_detected_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "bt_prio_defer_cnt:", - le32_to_cpu(tx->bt_prio_defer_cnt), - accum_tx->bt_prio_defer_cnt, - delta_tx->bt_prio_defer_cnt, - max_tx->bt_prio_defer_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "bt_prio_kill_cnt:", - le32_to_cpu(tx->bt_prio_kill_cnt), - accum_tx->bt_prio_kill_cnt, - delta_tx->bt_prio_kill_cnt, - max_tx->bt_prio_kill_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "few_bytes_cnt:", - le32_to_cpu(tx->few_bytes_cnt), - accum_tx->few_bytes_cnt, - delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "cts_timeout:", - le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout, - delta_tx->cts_timeout, max_tx->cts_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "ack_timeout:", - le32_to_cpu(tx->ack_timeout), - accum_tx->ack_timeout, - delta_tx->ack_timeout, max_tx->ack_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "expected_ack_cnt:", - le32_to_cpu(tx->expected_ack_cnt), - accum_tx->expected_ack_cnt, - delta_tx->expected_ack_cnt, - max_tx->expected_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "actual_ack_cnt:", - le32_to_cpu(tx->actual_ack_cnt), - accum_tx->actual_ack_cnt, - delta_tx->actual_ack_cnt, - max_tx->actual_ack_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "dump_msdu_cnt:", - le32_to_cpu(tx->dump_msdu_cnt), - accum_tx->dump_msdu_cnt, - delta_tx->dump_msdu_cnt, - max_tx->dump_msdu_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "abort_nxt_frame_mismatch:", - le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt), - accum_tx->burst_abort_next_frame_mismatch_cnt, - delta_tx->burst_abort_next_frame_mismatch_cnt, - max_tx->burst_abort_next_frame_mismatch_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "abort_missing_nxt_frame:", - le32_to_cpu(tx->burst_abort_missing_next_frame_cnt), - accum_tx->burst_abort_missing_next_frame_cnt, - delta_tx->burst_abort_missing_next_frame_cnt, - max_tx->burst_abort_missing_next_frame_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "cts_timeout_collision:", - le32_to_cpu(tx->cts_timeout_collision), - accum_tx->cts_timeout_collision, - delta_tx->cts_timeout_collision, - max_tx->cts_timeout_collision); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "ack_ba_timeout_collision:", - le32_to_cpu(tx->ack_or_ba_timeout_collision), - accum_tx->ack_or_ba_timeout_collision, - delta_tx->ack_or_ba_timeout_collision, - max_tx->ack_or_ba_timeout_collision); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg ba_timeout:", - le32_to_cpu(tx->agg.ba_timeout), - accum_tx->agg.ba_timeout, - delta_tx->agg.ba_timeout, - max_tx->agg.ba_timeout); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg ba_resched_frames:", - le32_to_cpu(tx->agg.ba_reschedule_frames), - accum_tx->agg.ba_reschedule_frames, - delta_tx->agg.ba_reschedule_frames, - max_tx->agg.ba_reschedule_frames); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg scd_query_agg_frame:", - le32_to_cpu(tx->agg.scd_query_agg_frame_cnt), - accum_tx->agg.scd_query_agg_frame_cnt, - delta_tx->agg.scd_query_agg_frame_cnt, - max_tx->agg.scd_query_agg_frame_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg scd_query_no_agg:", - le32_to_cpu(tx->agg.scd_query_no_agg), - accum_tx->agg.scd_query_no_agg, - delta_tx->agg.scd_query_no_agg, - max_tx->agg.scd_query_no_agg); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg scd_query_agg:", - le32_to_cpu(tx->agg.scd_query_agg), - accum_tx->agg.scd_query_agg, - delta_tx->agg.scd_query_agg, - max_tx->agg.scd_query_agg); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg scd_query_mismatch:", - le32_to_cpu(tx->agg.scd_query_mismatch), - accum_tx->agg.scd_query_mismatch, - delta_tx->agg.scd_query_mismatch, - max_tx->agg.scd_query_mismatch); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg frame_not_ready:", - le32_to_cpu(tx->agg.frame_not_ready), - accum_tx->agg.frame_not_ready, - delta_tx->agg.frame_not_ready, - max_tx->agg.frame_not_ready); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg underrun:", - le32_to_cpu(tx->agg.underrun), - accum_tx->agg.underrun, - delta_tx->agg.underrun, max_tx->agg.underrun); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg bt_prio_kill:", - le32_to_cpu(tx->agg.bt_prio_kill), - accum_tx->agg.bt_prio_kill, - delta_tx->agg.bt_prio_kill, - max_tx->agg.bt_prio_kill); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "agg rx_ba_rsp_cnt:", - le32_to_cpu(tx->agg.rx_ba_rsp_cnt), - accum_tx->agg.rx_ba_rsp_cnt, - delta_tx->agg.rx_ba_rsp_cnt, - max_tx->agg.rx_ba_rsp_cnt); + pos += scnprintf(buf + pos, bufsz - pos, fmt_header, "Statistics_Tx:"); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "preamble:", + le32_to_cpu(tx->preamble_cnt), accum_tx->preamble_cnt, + delta_tx->preamble_cnt, max_tx->preamble_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "rx_detected_cnt:", + le32_to_cpu(tx->rx_detected_cnt), + accum_tx->rx_detected_cnt, delta_tx->rx_detected_cnt, + max_tx->rx_detected_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "bt_prio_defer_cnt:", + le32_to_cpu(tx->bt_prio_defer_cnt), + accum_tx->bt_prio_defer_cnt, delta_tx->bt_prio_defer_cnt, + max_tx->bt_prio_defer_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "bt_prio_kill_cnt:", + le32_to_cpu(tx->bt_prio_kill_cnt), + accum_tx->bt_prio_kill_cnt, delta_tx->bt_prio_kill_cnt, + max_tx->bt_prio_kill_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "few_bytes_cnt:", + le32_to_cpu(tx->few_bytes_cnt), accum_tx->few_bytes_cnt, + delta_tx->few_bytes_cnt, max_tx->few_bytes_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "cts_timeout:", + le32_to_cpu(tx->cts_timeout), accum_tx->cts_timeout, + delta_tx->cts_timeout, max_tx->cts_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "ack_timeout:", + le32_to_cpu(tx->ack_timeout), accum_tx->ack_timeout, + delta_tx->ack_timeout, max_tx->ack_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "expected_ack_cnt:", + le32_to_cpu(tx->expected_ack_cnt), + accum_tx->expected_ack_cnt, delta_tx->expected_ack_cnt, + max_tx->expected_ack_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "actual_ack_cnt:", + le32_to_cpu(tx->actual_ack_cnt), accum_tx->actual_ack_cnt, + delta_tx->actual_ack_cnt, max_tx->actual_ack_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "dump_msdu_cnt:", + le32_to_cpu(tx->dump_msdu_cnt), accum_tx->dump_msdu_cnt, + delta_tx->dump_msdu_cnt, max_tx->dump_msdu_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "abort_nxt_frame_mismatch:", + le32_to_cpu(tx->burst_abort_next_frame_mismatch_cnt), + accum_tx->burst_abort_next_frame_mismatch_cnt, + delta_tx->burst_abort_next_frame_mismatch_cnt, + max_tx->burst_abort_next_frame_mismatch_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "abort_missing_nxt_frame:", + le32_to_cpu(tx->burst_abort_missing_next_frame_cnt), + accum_tx->burst_abort_missing_next_frame_cnt, + delta_tx->burst_abort_missing_next_frame_cnt, + max_tx->burst_abort_missing_next_frame_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "cts_timeout_collision:", + le32_to_cpu(tx->cts_timeout_collision), + accum_tx->cts_timeout_collision, + delta_tx->cts_timeout_collision, + max_tx->cts_timeout_collision); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "ack_ba_timeout_collision:", + le32_to_cpu(tx->ack_or_ba_timeout_collision), + accum_tx->ack_or_ba_timeout_collision, + delta_tx->ack_or_ba_timeout_collision, + max_tx->ack_or_ba_timeout_collision); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "agg ba_timeout:", + le32_to_cpu(tx->agg.ba_timeout), accum_tx->agg.ba_timeout, + delta_tx->agg.ba_timeout, max_tx->agg.ba_timeout); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "agg ba_resched_frames:", + le32_to_cpu(tx->agg.ba_reschedule_frames), + accum_tx->agg.ba_reschedule_frames, + delta_tx->agg.ba_reschedule_frames, + max_tx->agg.ba_reschedule_frames); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "agg scd_query_agg_frame:", + le32_to_cpu(tx->agg.scd_query_agg_frame_cnt), + accum_tx->agg.scd_query_agg_frame_cnt, + delta_tx->agg.scd_query_agg_frame_cnt, + max_tx->agg.scd_query_agg_frame_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "agg scd_query_no_agg:", + le32_to_cpu(tx->agg.scd_query_no_agg), + accum_tx->agg.scd_query_no_agg, + delta_tx->agg.scd_query_no_agg, + max_tx->agg.scd_query_no_agg); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "agg scd_query_agg:", + le32_to_cpu(tx->agg.scd_query_agg), + accum_tx->agg.scd_query_agg, delta_tx->agg.scd_query_agg, + max_tx->agg.scd_query_agg); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "agg scd_query_mismatch:", + le32_to_cpu(tx->agg.scd_query_mismatch), + accum_tx->agg.scd_query_mismatch, + delta_tx->agg.scd_query_mismatch, + max_tx->agg.scd_query_mismatch); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "agg frame_not_ready:", + le32_to_cpu(tx->agg.frame_not_ready), + accum_tx->agg.frame_not_ready, + delta_tx->agg.frame_not_ready, + max_tx->agg.frame_not_ready); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "agg underrun:", + le32_to_cpu(tx->agg.underrun), accum_tx->agg.underrun, + delta_tx->agg.underrun, max_tx->agg.underrun); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "agg bt_prio_kill:", + le32_to_cpu(tx->agg.bt_prio_kill), + accum_tx->agg.bt_prio_kill, delta_tx->agg.bt_prio_kill, + max_tx->agg.bt_prio_kill); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "agg rx_ba_rsp_cnt:", + le32_to_cpu(tx->agg.rx_ba_rsp_cnt), + accum_tx->agg.rx_ba_rsp_cnt, delta_tx->agg.rx_ba_rsp_cnt, + max_tx->agg.rx_ba_rsp_cnt); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); @@ -661,8 +634,8 @@ ssize_t il4965_ucode_tx_stats_read(struct file *file, } ssize_t -il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) +il4965_ucode_general_stats_read(struct file * file, char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; int pos = 0; @@ -684,9 +657,9 @@ il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, } /* the statistic information display here is based on - * the last stats notification from uCode - * might not reflect the current uCode activity - */ + * the last stats notification from uCode + * might not reflect the current uCode activity + */ general = &il->_4965.stats.general.common; dbg = &il->_4965.stats.general.common.dbg; div = &il->_4965.stats.general.common.div; @@ -701,73 +674,72 @@ il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, max_div = &il->_4965.max_delta.general.common.div; pos += il4965_stats_flag(il, buf, bufsz); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_header, "Statistics_General:"); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_value, "temperature:", - le32_to_cpu(general->temperature)); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_value, "ttl_timestamp:", - le32_to_cpu(general->ttl_timestamp)); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "burst_check:", - le32_to_cpu(dbg->burst_check), - accum_dbg->burst_check, - delta_dbg->burst_check, max_dbg->burst_check); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "burst_count:", - le32_to_cpu(dbg->burst_count), - accum_dbg->burst_count, - delta_dbg->burst_count, max_dbg->burst_count); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "wait_for_silence_timeout_count:", - le32_to_cpu(dbg->wait_for_silence_timeout_cnt), - accum_dbg->wait_for_silence_timeout_cnt, - delta_dbg->wait_for_silence_timeout_cnt, - max_dbg->wait_for_silence_timeout_cnt); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "sleep_time:", - le32_to_cpu(general->sleep_time), - accum_general->sleep_time, - delta_general->sleep_time, max_general->sleep_time); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "slots_out:", - le32_to_cpu(general->slots_out), - accum_general->slots_out, - delta_general->slots_out, max_general->slots_out); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "slots_idle:", - le32_to_cpu(general->slots_idle), - accum_general->slots_idle, - delta_general->slots_idle, max_general->slots_idle); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "tx_on_a:", - le32_to_cpu(div->tx_on_a), accum_div->tx_on_a, - delta_div->tx_on_a, max_div->tx_on_a); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "tx_on_b:", - le32_to_cpu(div->tx_on_b), accum_div->tx_on_b, - delta_div->tx_on_b, max_div->tx_on_b); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "exec_time:", - le32_to_cpu(div->exec_time), accum_div->exec_time, - delta_div->exec_time, max_div->exec_time); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "probe_time:", - le32_to_cpu(div->probe_time), accum_div->probe_time, - delta_div->probe_time, max_div->probe_time); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "rx_enable_counter:", - le32_to_cpu(general->rx_enable_counter), - accum_general->rx_enable_counter, - delta_general->rx_enable_counter, - max_general->rx_enable_counter); - pos += scnprintf(buf + pos, bufsz - pos, - fmt_table, "num_of_sos_states:", - le32_to_cpu(general->num_of_sos_states), - accum_general->num_of_sos_states, - delta_general->num_of_sos_states, - max_general->num_of_sos_states); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_header, + "Statistics_General:"); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_value, "temperature:", + le32_to_cpu(general->temperature)); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_value, "ttl_timestamp:", + le32_to_cpu(general->ttl_timestamp)); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "burst_check:", + le32_to_cpu(dbg->burst_check), accum_dbg->burst_check, + delta_dbg->burst_check, max_dbg->burst_check); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "burst_count:", + le32_to_cpu(dbg->burst_count), accum_dbg->burst_count, + delta_dbg->burst_count, max_dbg->burst_count); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, + "wait_for_silence_timeout_count:", + le32_to_cpu(dbg->wait_for_silence_timeout_cnt), + accum_dbg->wait_for_silence_timeout_cnt, + delta_dbg->wait_for_silence_timeout_cnt, + max_dbg->wait_for_silence_timeout_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "sleep_time:", + le32_to_cpu(general->sleep_time), + accum_general->sleep_time, delta_general->sleep_time, + max_general->sleep_time); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "slots_out:", + le32_to_cpu(general->slots_out), accum_general->slots_out, + delta_general->slots_out, max_general->slots_out); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "slots_idle:", + le32_to_cpu(general->slots_idle), + accum_general->slots_idle, delta_general->slots_idle, + max_general->slots_idle); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "tx_on_a:", + le32_to_cpu(div->tx_on_a), accum_div->tx_on_a, + delta_div->tx_on_a, max_div->tx_on_a); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "tx_on_b:", + le32_to_cpu(div->tx_on_b), accum_div->tx_on_b, + delta_div->tx_on_b, max_div->tx_on_b); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "exec_time:", + le32_to_cpu(div->exec_time), accum_div->exec_time, + delta_div->exec_time, max_div->exec_time); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "probe_time:", + le32_to_cpu(div->probe_time), accum_div->probe_time, + delta_div->probe_time, max_div->probe_time); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "rx_enable_counter:", + le32_to_cpu(general->rx_enable_counter), + accum_general->rx_enable_counter, + delta_general->rx_enable_counter, + max_general->rx_enable_counter); + pos += + scnprintf(buf + pos, bufsz - pos, fmt_table, "num_of_sos_states:", + le32_to_cpu(general->num_of_sos_states), + accum_general->num_of_sos_states, + delta_general->num_of_sos_states, + max_general->num_of_sos_states); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 9e3f74c8e9a7..ca819d872097 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -53,7 +53,6 @@ #include "common.h" #include "4965.h" - /****************************************************************************** * * module boiler plate @@ -73,15 +72,14 @@ #define DRV_VERSION IWLWIFI_VERSION VD - MODULE_DESCRIPTION(DRV_DESCRIPTION); MODULE_VERSION(DRV_VERSION); MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); MODULE_LICENSE("GPL"); MODULE_ALIAS("iwl4965"); -void il4965_check_abort_status(struct il_priv *il, - u8 frame_count, u32 status) +void +il4965_check_abort_status(struct il_priv *il, u8 frame_count, u32 status) { if (frame_count == 1 && status == TX_STATUS_FAIL_RFKILL_FLUSH) { IL_ERR("Tx flush command to flush out all frames\n"); @@ -99,7 +97,8 @@ struct il_mod_params il4965_mod_params = { /* the rest are 0 by default */ }; -void il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) +void +il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) { unsigned long flags; int i; @@ -112,8 +111,8 @@ void il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) * to an SKB, so we need to unmap and free potential storage */ if (rxq->pool[i].page != NULL) { pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); __il_free_pages(il, rxq->pool[i].page); rxq->pool[i].page = NULL; } @@ -131,10 +130,11 @@ void il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq) spin_unlock_irqrestore(&rxq->lock, flags); } -int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) +int +il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) { u32 rb_size; - const u32 rfdnlog = RX_QUEUE_SIZE_LOG; /* 256 RBDs */ + const u32 rfdnlog = RX_QUEUE_SIZE_LOG; /* 256 RBDs */ u32 rb_timeout = 0; if (il->cfg->mod_params->amsdu_size_8K) @@ -149,12 +149,10 @@ int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) il_wr(il, FH49_RSCSR_CHNL0_RBDCB_WPTR_REG, 0); /* Tell device where to find RBD circular buffer in DRAM */ - il_wr(il, FH49_RSCSR_CHNL0_RBDCB_BASE_REG, - (u32)(rxq->bd_dma >> 8)); + il_wr(il, FH49_RSCSR_CHNL0_RBDCB_BASE_REG, (u32) (rxq->bd_dma >> 8)); /* Tell device where in DRAM to update its Rx status */ - il_wr(il, FH49_RSCSR_CHNL0_STTS_WPTR_REG, - rxq->rb_stts_dma >> 4); + il_wr(il, FH49_RSCSR_CHNL0_STTS_WPTR_REG, rxq->rb_stts_dma >> 4); /* Enable Rx DMA * Direct rx interrupts to hosts @@ -163,12 +161,12 @@ int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) * 256 RBDs */ il_wr(il, FH49_MEM_RCSR_CHNL0_CONFIG_REG, - FH49_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL | - FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL | - FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK | - rb_size| - (rb_timeout << FH49_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS)| - (rfdnlog << FH49_RCSR_RX_CONFIG_RBDCB_SIZE_POS)); + FH49_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL | + FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL | + FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK | rb_size | (rb_timeout + << + FH49_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS) + | (rfdnlog << FH49_RCSR_RX_CONFIG_RBDCB_SIZE_POS)); /* Set interrupt coalescing timer to default (2048 usecs) */ il_write8(il, CSR_INT_COALESCING, IL_HOST_INT_TIMEOUT_DEF); @@ -176,7 +174,8 @@ int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) return 0; } -static void il4965_set_pwr_vmain(struct il_priv *il) +static void +il4965_set_pwr_vmain(struct il_priv *il) { /* * (for documentation purposes) @@ -189,11 +188,12 @@ static void il4965_set_pwr_vmain(struct il_priv *il) */ il_set_bits_mask_prph(il, APMG_PS_CTRL_REG, - APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, - ~APMG_PS_CTRL_MSK_PWR_SRC); + APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, + ~APMG_PS_CTRL_MSK_PWR_SRC); } -int il4965_hw_nic_init(struct il_priv *il) +int +il4965_hw_nic_init(struct il_priv *il) { unsigned long flags; struct il_rx_queue *rxq = &il->rxq; @@ -249,10 +249,10 @@ int il4965_hw_nic_init(struct il_priv *il) /** * il4965_dma_addr2rbd_ptr - convert a DMA address to a uCode read buffer ptr */ -static inline __le32 il4965_dma_addr2rbd_ptr(struct il_priv *il, - dma_addr_t dma_addr) +static inline __le32 +il4965_dma_addr2rbd_ptr(struct il_priv *il, dma_addr_t dma_addr) { - return cpu_to_le32((u32)(dma_addr >> 8)); + return cpu_to_le32((u32) (dma_addr >> 8)); } /** @@ -266,7 +266,8 @@ static inline __le32 il4965_dma_addr2rbd_ptr(struct il_priv *il, * also updates the memory address in the firmware to reference the new * target buffer. */ -void il4965_rx_queue_restock(struct il_priv *il) +void +il4965_rx_queue_restock(struct il_priv *il) { struct il_rx_queue *rxq = &il->rxq; struct list_head *element; @@ -285,8 +286,8 @@ void il4965_rx_queue_restock(struct il_priv *il) list_del(element); /* Point to Rx buffer via next RBD in circular buffer */ - rxq->bd[rxq->write] = il4965_dma_addr2rbd_ptr(il, - rxb->page_dma); + rxq->bd[rxq->write] = + il4965_dma_addr2rbd_ptr(il, rxb->page_dma); rxq->queue[rxq->write] = rxb; rxq->write = (rxq->write + 1) & RX_QUEUE_MASK; rxq->free_count--; @@ -297,7 +298,6 @@ void il4965_rx_queue_restock(struct il_priv *il) if (rxq->free_count <= RX_LOW_WATERMARK) queue_work(il->workqueue, &il->rx_replenish); - /* If we've added more space for the firmware to place data, tell it. * Increment device's write pointer in multiples of 8. */ if (rxq->write_actual != (rxq->write & ~0x7)) { @@ -316,7 +316,8 @@ void il4965_rx_queue_restock(struct il_priv *il) * Also restock the Rx queue via il_rx_queue_restock. * This is called as a scheduled work item (except for during initialization) */ -static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) +static void +il4965_rx_allocate(struct il_priv *il, gfp_t priority) { struct il_rx_queue *rxq = &il->rxq; struct list_head *element; @@ -343,18 +344,16 @@ static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) page = alloc_pages(gfp_mask, il->hw_params.rx_page_order); if (!page) { if (net_ratelimit()) - D_INFO("alloc_pages failed, " - "order: %d\n", - il->hw_params.rx_page_order); + D_INFO("alloc_pages failed, " "order: %d\n", + il->hw_params.rx_page_order); if (rxq->free_count <= RX_LOW_WATERMARK && net_ratelimit()) - IL_ERR( - "Failed to alloc_pages with %s. " - "Only %u free buffers remaining.\n", - priority == GFP_ATOMIC ? - "GFP_ATOMIC" : "GFP_KERNEL", - rxq->free_count); + IL_ERR("Failed to alloc_pages with %s. " + "Only %u free buffers remaining.\n", + priority == + GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL", + rxq->free_count); /* We don't reschedule replenish work here -- we will * call the restock method and if it still needs * more buffers it will schedule replenish */ @@ -377,9 +376,10 @@ static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) BUG_ON(rxb->page); rxb->page = page; /* Get physical address of the RB */ - rxb->page_dma = pci_map_page(il->pci_dev, page, 0, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); + rxb->page_dma = + pci_map_page(il->pci_dev, page, 0, + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); /* dma address must be no more than 36 bits */ BUG_ON(rxb->page_dma & ~DMA_BIT_MASK(36)); /* and also 256 byte aligned! */ @@ -395,7 +395,8 @@ static void il4965_rx_allocate(struct il_priv *il, gfp_t priority) } } -void il4965_rx_replenish(struct il_priv *il) +void +il4965_rx_replenish(struct il_priv *il) { unsigned long flags; @@ -406,7 +407,8 @@ void il4965_rx_replenish(struct il_priv *il) spin_unlock_irqrestore(&il->lock, flags); } -void il4965_rx_replenish_now(struct il_priv *il) +void +il4965_rx_replenish_now(struct il_priv *il) { il4965_rx_allocate(il, GFP_ATOMIC); @@ -418,14 +420,15 @@ void il4965_rx_replenish_now(struct il_priv *il) * This free routine walks the list of POOL entries and if SKB is set to * non NULL it is unmapped and freed */ -void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq) +void +il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq) { int i; for (i = 0; i < RX_QUEUE_SIZE + RX_FREE_BUFFERS; i++) { if (rxq->pool[i].page != NULL) { pci_unmap_page(il->pci_dev, rxq->pool[i].page_dma, - PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); + PAGE_SIZE << il->hw_params.rx_page_order, + PCI_DMA_FROMDEVICE); __il_free_pages(il, rxq->pool[i].page); rxq->pool[i].page = NULL; } @@ -436,21 +439,23 @@ void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq) dma_free_coherent(&il->pci_dev->dev, sizeof(struct il_rb_status), rxq->rb_stts, rxq->rb_stts_dma); rxq->bd = NULL; - rxq->rb_stts = NULL; + rxq->rb_stts = NULL; } -int il4965_rxq_stop(struct il_priv *il) +int +il4965_rxq_stop(struct il_priv *il) { /* stop Rx DMA */ il_wr(il, FH49_MEM_RCSR_CHNL0_CONFIG_REG, 0); il_poll_bit(il, FH49_MEM_RSSR_RX_STATUS_REG, - FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); + FH49_RSSR_CHNL0_RX_STATUS_CHNL_IDLE, 1000); return 0; } -int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) +int +il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) { int idx = 0; int band_offset = 0; @@ -459,7 +464,7 @@ int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) if (rate_n_flags & RATE_MCS_HT_MSK) { idx = (rate_n_flags & 0xff); return idx; - /* Legacy rate format, search for match in table */ + /* Legacy rate format, search for match in table */ } else { if (band == IEEE80211_BAND_5GHZ) band_offset = IL_FIRST_OFDM_RATE; @@ -471,19 +476,20 @@ int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band) return -1; } -static int il4965_calc_rssi(struct il_priv *il, - struct il_rx_phy_res *rx_resp) +static int +il4965_calc_rssi(struct il_priv *il, struct il_rx_phy_res *rx_resp) { /* data from PHY/DSP regarding signal strength, etc., * contents are always there, not configurable by host. */ struct il4965_rx_non_cfg_phy *ncphy = (struct il4965_rx_non_cfg_phy *)rx_resp->non_cfg_phy_buf; - u32 agc = (le16_to_cpu(ncphy->agc_info) & IL49_AGC_DB_MASK) - >> IL49_AGC_DB_POS; + u32 agc = + (le16_to_cpu(ncphy->agc_info) & IL49_AGC_DB_MASK) >> + IL49_AGC_DB_POS; u32 valid_antennae = (le16_to_cpu(rx_resp->phy_flags) & IL49_RX_PHY_FLAGS_ANTENNAE_MASK) - >> IL49_RX_PHY_FLAGS_ANTENNAE_OFFSET; + >> IL49_RX_PHY_FLAGS_ANTENNAE_OFFSET; u8 max_rssi = 0; u32 i; @@ -505,31 +511,32 @@ static int il4965_calc_rssi(struct il_priv *il, return max_rssi - agc - IL4965_RSSI_OFFSET; } - -static u32 il4965_translate_rx_status(struct il_priv *il, u32 decrypt_in) +static u32 +il4965_translate_rx_status(struct il_priv *il, u32 decrypt_in) { u32 decrypt_out = 0; if ((decrypt_in & RX_RES_STATUS_STATION_FOUND) == - RX_RES_STATUS_STATION_FOUND) - decrypt_out |= (RX_RES_STATUS_STATION_FOUND | - RX_RES_STATUS_NO_STATION_INFO_MISMATCH); + RX_RES_STATUS_STATION_FOUND) + decrypt_out |= + (RX_RES_STATUS_STATION_FOUND | + RX_RES_STATUS_NO_STATION_INFO_MISMATCH); decrypt_out |= (decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK); /* packet was not encrypted */ if ((decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) == - RX_RES_STATUS_SEC_TYPE_NONE) + RX_RES_STATUS_SEC_TYPE_NONE) return decrypt_out; /* packet was encrypted with unknown alg */ if ((decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) == - RX_RES_STATUS_SEC_TYPE_ERR) + RX_RES_STATUS_SEC_TYPE_ERR) return decrypt_out; /* decryption was not done in HW */ if ((decrypt_in & RX_MPDU_RES_STATUS_DEC_DONE_MSK) != - RX_MPDU_RES_STATUS_DEC_DONE_MSK) + RX_MPDU_RES_STATUS_DEC_DONE_MSK) return decrypt_out; switch (decrypt_in & RX_RES_STATUS_SEC_TYPE_MSK) { @@ -559,26 +566,22 @@ static u32 il4965_translate_rx_status(struct il_priv *il, u32 decrypt_in) break; } - D_RX("decrypt_in:0x%x decrypt_out = 0x%x\n", - decrypt_in, decrypt_out); + D_RX("decrypt_in:0x%x decrypt_out = 0x%x\n", decrypt_in, decrypt_out); return decrypt_out; } -static void il4965_pass_packet_to_mac80211(struct il_priv *il, - struct ieee80211_hdr *hdr, - u16 len, - u32 ampdu_status, - struct il_rx_buf *rxb, - struct ieee80211_rx_status *stats) +static void +il4965_pass_packet_to_mac80211(struct il_priv *il, struct ieee80211_hdr *hdr, + u16 len, u32 ampdu_status, struct il_rx_buf *rxb, + struct ieee80211_rx_status *stats) { struct sk_buff *skb; __le16 fc = hdr->frame_control; /* We only process data packets if the interface is open */ if (unlikely(!il->is_open)) { - D_DROP( - "Dropping packet while interface is not open.\n"); + D_DROP("Dropping packet while interface is not open.\n"); return; } @@ -605,8 +608,8 @@ static void il4965_pass_packet_to_mac80211(struct il_priv *il, /* Called for N_RX (legacy ABG frames), or * N_RX_MPDU (HT high-throughput N frames). */ -void il4965_hdl_rx(struct il_priv *il, - struct il_rx_buf *rxb) +void +il4965_hdl_rx(struct il_priv *il, struct il_rx_buf *rxb) { struct ieee80211_hdr *header; struct ieee80211_rx_status rx_status; @@ -629,12 +632,14 @@ void il4965_hdl_rx(struct il_priv *il, */ if (pkt->hdr.cmd == N_RX) { phy_res = (struct il_rx_phy_res *)pkt->u.raw; - header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*phy_res) - + phy_res->cfg_phy_cnt); + header = + (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*phy_res) + + phy_res->cfg_phy_cnt); len = le16_to_cpu(phy_res->byte_count); - rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*phy_res) + - phy_res->cfg_phy_cnt + len); + rx_pkt_status = + *(__le32 *) (pkt->u.raw + sizeof(*phy_res) + + phy_res->cfg_phy_cnt + len); ampdu_status = le32_to_cpu(rx_pkt_status); } else { if (!il->_4965.last_phy_res_valid) { @@ -645,21 +650,20 @@ void il4965_hdl_rx(struct il_priv *il, amsdu = (struct il_rx_mpdu_res_start *)pkt->u.raw; header = (struct ieee80211_hdr *)(pkt->u.raw + sizeof(*amsdu)); len = le16_to_cpu(amsdu->byte_count); - rx_pkt_status = *(__le32 *)(pkt->u.raw + sizeof(*amsdu) + len); - ampdu_status = il4965_translate_rx_status(il, - le32_to_cpu(rx_pkt_status)); + rx_pkt_status = *(__le32 *) (pkt->u.raw + sizeof(*amsdu) + len); + ampdu_status = + il4965_translate_rx_status(il, le32_to_cpu(rx_pkt_status)); } if ((unlikely(phy_res->cfg_phy_cnt > 20))) { D_DROP("dsp size out of range [0,20]: %d/n", - phy_res->cfg_phy_cnt); + phy_res->cfg_phy_cnt); return; } if (!(rx_pkt_status & RX_RES_STATUS_NO_CRC32_ERROR) || !(rx_pkt_status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { - D_RX("Bad CRC or FIFO: 0x%08X.\n", - le32_to_cpu(rx_pkt_status)); + D_RX("Bad CRC or FIFO: 0x%08X.\n", le32_to_cpu(rx_pkt_status)); return; } @@ -668,18 +672,20 @@ void il4965_hdl_rx(struct il_priv *il, /* rx_status carries information about the packet to mac80211 */ rx_status.mactime = le64_to_cpu(phy_res->timestamp); - rx_status.band = (phy_res->phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? - IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; + rx_status.band = + (phy_res-> + phy_flags & RX_RES_PHY_FLAGS_BAND_24_MSK) ? IEEE80211_BAND_2GHZ : + IEEE80211_BAND_5GHZ; rx_status.freq = - ieee80211_channel_to_frequency(le16_to_cpu(phy_res->channel), - rx_status.band); + ieee80211_channel_to_frequency(le16_to_cpu(phy_res->channel), + rx_status.band); rx_status.rate_idx = - il4965_hwrate_to_mac80211_idx(rate_n_flags, rx_status.band); + il4965_hwrate_to_mac80211_idx(rate_n_flags, rx_status.band); rx_status.flag = 0; /* TSF isn't reliable. In order to allow smooth user experience, * this W/A doesn't propagate it to the mac80211 */ - /*rx_status.flag |= RX_FLAG_MACTIME_MPDU;*/ + /*rx_status.flag |= RX_FLAG_MACTIME_MPDU; */ il->ucode_beacon_time = le32_to_cpu(phy_res->beacon_time_stamp); @@ -687,8 +693,8 @@ void il4965_hdl_rx(struct il_priv *il, rx_status.signal = il4965_calc_rssi(il, phy_res); il_dbg_log_rx_data_frame(il, len, header); - D_STATS("Rssi %d, TSF %llu\n", - rx_status.signal, (unsigned long long)rx_status.mactime); + D_STATS("Rssi %d, TSF %llu\n", rx_status.signal, + (unsigned long long)rx_status.mactime); /* * "antenna number" @@ -704,8 +710,8 @@ void il4965_hdl_rx(struct il_priv *il, * as a bitmask. */ rx_status.antenna = - (le16_to_cpu(phy_res->phy_flags) & RX_RES_PHY_FLAGS_ANTENNA_MSK) - >> RX_RES_PHY_FLAGS_ANTENNA_POS; + (le16_to_cpu(phy_res->phy_flags) & RX_RES_PHY_FLAGS_ANTENNA_MSK) >> + RX_RES_PHY_FLAGS_ANTENNA_POS; /* set the preamble flag if appropriate */ if (phy_res->phy_flags & RX_RES_PHY_FLAGS_SHORT_PREAMBLE_MSK) @@ -719,14 +725,14 @@ void il4965_hdl_rx(struct il_priv *il, if (rate_n_flags & RATE_MCS_SGI_MSK) rx_status.flag |= RX_FLAG_SHORT_GI; - il4965_pass_packet_to_mac80211(il, header, len, ampdu_status, - rxb, &rx_status); + il4965_pass_packet_to_mac80211(il, header, len, ampdu_status, rxb, + &rx_status); } /* Cache phy data (Rx signal strength, etc) for HT frame (N_RX_PHY). * This will be used later in il_hdl_rx() for N_RX_MPDU. */ -void il4965_hdl_rx_phy(struct il_priv *il, - struct il_rx_buf *rxb) +void +il4965_hdl_rx_phy(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); il->_4965.last_phy_res_valid = true; @@ -734,11 +740,10 @@ void il4965_hdl_rx_phy(struct il_priv *il, sizeof(struct il_rx_phy_res)); } -static int il4965_get_channels_for_scan(struct il_priv *il, - struct ieee80211_vif *vif, - enum ieee80211_band band, - u8 is_active, u8 n_probes, - struct il_scan_channel *scan_ch) +static int +il4965_get_channels_for_scan(struct il_priv *il, struct ieee80211_vif *vif, + enum ieee80211_band band, u8 is_active, + u8 n_probes, struct il_scan_channel *scan_ch) { struct ieee80211_channel *chan; const struct ieee80211_supported_band *sband; @@ -769,9 +774,8 @@ static int il4965_get_channels_for_scan(struct il_priv *il, ch_info = il_get_channel_info(il, band, channel); if (!il_is_channel_valid(ch_info)) { - D_SCAN( - "Channel %d is INVALID for this band.\n", - channel); + D_SCAN("Channel %d is INVALID for this band.\n", + channel); continue; } @@ -799,12 +803,13 @@ static int il4965_get_channels_for_scan(struct il_priv *il, else scan_ch->tx_gain = ((1 << 5) | (5 << 3)); - D_SCAN("Scanning ch=%d prob=0x%X [%s %d]\n", - channel, le32_to_cpu(scan_ch->type), - (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ? - "ACTIVE" : "PASSIVE", - (scan_ch->type & SCAN_CHANNEL_TYPE_ACTIVE) ? - active_dwell : passive_dwell); + D_SCAN("Scanning ch=%d prob=0x%X [%s %d]\n", channel, + le32_to_cpu(scan_ch->type), + (scan_ch-> + type & SCAN_CHANNEL_TYPE_ACTIVE) ? "ACTIVE" : "PASSIVE", + (scan_ch-> + type & SCAN_CHANNEL_TYPE_ACTIVE) ? active_dwell : + passive_dwell); scan_ch++; added++; @@ -814,12 +819,14 @@ static int il4965_get_channels_for_scan(struct il_priv *il, return added; } -static inline u32 il4965_ant_idx_to_flags(u8 ant_idx) +static inline u32 +il4965_ant_idx_to_flags(u8 ant_idx) { return BIT(ant_idx) << RATE_MCS_ANT_POS; } -int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) +int +il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) { struct il_host_cmd cmd = { .id = C_SCAN, @@ -836,7 +843,7 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) u8 rx_ant = il->hw_params.valid_rx_ant; u8 rate; bool is_active = false; - int chan_mod; + int chan_mod; u8 active_chains; u8 scan_tx_antennas = il->hw_params.valid_tx_ant; int ret; @@ -847,11 +854,11 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) ctx = il_rxon_ctx_from_vif(vif); if (!il->scan_cmd) { - il->scan_cmd = kmalloc(sizeof(struct il_scan_cmd) + - IL_MAX_SCAN_SIZE, GFP_KERNEL); + il->scan_cmd = + kmalloc(sizeof(struct il_scan_cmd) + IL_MAX_SCAN_SIZE, + GFP_KERNEL); if (!il->scan_cmd) { - D_SCAN( - "fail to allocate memory for scan\n"); + D_SCAN("fail to allocate memory for scan\n"); return -ENOMEM; } } @@ -876,11 +883,11 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) interval = suspend_time; extra = (suspend_time / interval) << 22; - scan_suspend_time = (extra | - ((suspend_time % interval) * 1024)); + scan_suspend_time = + (extra | ((suspend_time % interval) * 1024)); scan->suspend_time = cpu_to_le32(scan_suspend_time); D_SCAN("suspend_time 0x%X beacon interval %d\n", - scan_suspend_time, interval); + scan_suspend_time, interval); } if (il->scan_request->n_ssids) { @@ -892,7 +899,7 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) continue; scan->direct_scan[p].id = WLAN_EID_SSID; scan->direct_scan[p].len = - il->scan_request->ssids[i].ssid_len; + il->scan_request->ssids[i].ssid_len; memcpy(scan->direct_scan[p].ssid, il->scan_request->ssids[i].ssid, il->scan_request->ssids[i].ssid_len); @@ -910,10 +917,10 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) switch (il->scan_band) { case IEEE80211_BAND_2GHZ: scan->flags = RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK; - chan_mod = le32_to_cpu( - il->ctx.active.flags & - RXON_FLG_CHANNEL_MODE_MSK) - >> RXON_FLG_CHANNEL_MODE_POS; + chan_mod = + le32_to_cpu(il->ctx.active. + flags & RXON_FLG_CHANNEL_MODE_MSK) >> + RXON_FLG_CHANNEL_MODE_POS; if (chan_mod == CHANNEL_MODE_PURE_40) { rate = RATE_6M_PLCP; } else { @@ -946,30 +953,30 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) * the aforementioned issue. Thus use IL_GOOD_CRC_TH_NEVER * here instead of IL_GOOD_CRC_TH_DISABLED. */ - scan->good_CRC_th = is_active ? IL_GOOD_CRC_TH_DEFAULT : - IL_GOOD_CRC_TH_NEVER; + scan->good_CRC_th = + is_active ? IL_GOOD_CRC_TH_DEFAULT : IL_GOOD_CRC_TH_NEVER; band = il->scan_band; if (il->cfg->scan_rx_antennas[band]) rx_ant = il->cfg->scan_rx_antennas[band]; - il->scan_tx_ant[band] = il4965_toggle_tx_ant(il, - il->scan_tx_ant[band], - scan_tx_antennas); + il->scan_tx_ant[band] = + il4965_toggle_tx_ant(il, il->scan_tx_ant[band], scan_tx_antennas); rate_flags |= il4965_ant_idx_to_flags(il->scan_tx_ant[band]); - scan->tx_cmd.rate_n_flags = il4965_hw_set_rate_n_flags(rate, rate_flags); + scan->tx_cmd.rate_n_flags = + il4965_hw_set_rate_n_flags(rate, rate_flags); /* In power save mode use one chain, otherwise use all chains */ if (test_bit(S_POWER_PMI, &il->status)) { /* rx_ant has been set to all valid chains previously */ - active_chains = rx_ant & - ((u8)(il->chain_noise_data.active_chains)); + active_chains = + rx_ant & ((u8) (il->chain_noise_data.active_chains)); if (!active_chains) active_chains = rx_ant; D_SCAN("chain_noise_data.active_chains: %u\n", - il->chain_noise_data.active_chains); + il->chain_noise_data.active_chains); rx_ant = il4965_first_antenna(active_chains); } @@ -981,26 +988,26 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) rx_chain |= 0x1 << RXON_RX_CHAIN_DRIVER_FORCE_POS; scan->rx_chain = cpu_to_le16(rx_chain); - cmd_len = il_fill_probe_req(il, - (struct ieee80211_mgmt *)scan->data, - vif->addr, - il->scan_request->ie, - il->scan_request->ie_len, - IL_MAX_SCAN_SIZE - sizeof(*scan)); + cmd_len = + il_fill_probe_req(il, (struct ieee80211_mgmt *)scan->data, + vif->addr, il->scan_request->ie, + il->scan_request->ie_len, + IL_MAX_SCAN_SIZE - sizeof(*scan)); scan->tx_cmd.len = cpu_to_le16(cmd_len); - scan->filter_flags |= (RXON_FILTER_ACCEPT_GRP_MSK | - RXON_FILTER_BCON_AWARE_MSK); + scan->filter_flags |= + (RXON_FILTER_ACCEPT_GRP_MSK | RXON_FILTER_BCON_AWARE_MSK); - scan->channel_count = il4965_get_channels_for_scan(il, vif, band, - is_active, n_probes, - (void *)&scan->data[cmd_len]); + scan->channel_count = + il4965_get_channels_for_scan(il, vif, band, is_active, n_probes, + (void *)&scan->data[cmd_len]); if (scan->channel_count == 0) { D_SCAN("channel count %d\n", scan->channel_count); return -EIO; } - cmd.len += le16_to_cpu(scan->tx_cmd.len) + + cmd.len += + le16_to_cpu(scan->tx_cmd.len) + scan->channel_count * sizeof(struct il_scan_channel); cmd.data = scan; scan->len = cpu_to_le16(cmd.len); @@ -1014,8 +1021,9 @@ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) return ret; } -int il4965_manage_ibss_station(struct il_priv *il, - struct ieee80211_vif *vif, bool add) +int +il4965_manage_ibss_station(struct il_priv *il, struct ieee80211_vif *vif, + bool add) { struct il_vif_priv *vif_priv = (void *)vif->drv_priv; @@ -1024,11 +1032,11 @@ int il4965_manage_ibss_station(struct il_priv *il, vif->bss_conf.bssid, &vif_priv->ibss_bssid_sta_id); return il_remove_station(il, vif_priv->ibss_bssid_sta_id, - vif->bss_conf.bssid); + vif->bss_conf.bssid); } -void il4965_free_tfds_in_queue(struct il_priv *il, - int sta_id, int tid, int freed) +void +il4965_free_tfds_in_queue(struct il_priv *il, int sta_id, int tid, int freed) { lockdep_assert_held(&il->sta_lock); @@ -1036,18 +1044,18 @@ void il4965_free_tfds_in_queue(struct il_priv *il, il->stations[sta_id].tid[tid].tfds_in_queue -= freed; else { D_TX("free more than tfds_in_queue (%u:%d)\n", - il->stations[sta_id].tid[tid].tfds_in_queue, - freed); + il->stations[sta_id].tid[tid].tfds_in_queue, freed); il->stations[sta_id].tid[tid].tfds_in_queue = 0; } } #define IL_TX_QUEUE_MSK 0xfffff -static bool il4965_is_single_rx_stream(struct il_priv *il) +static bool +il4965_is_single_rx_stream(struct il_priv *il) { return il->current_ht_config.smps == IEEE80211_SMPS_STATIC || - il->current_ht_config.single_chain_sufficient; + il->current_ht_config.single_chain_sufficient; } #define IL_NUM_RX_CHAINS_MULTIPLE 3 @@ -1065,7 +1073,8 @@ static bool il4965_is_single_rx_stream(struct il_priv *il) * MIMO (dual stream) requires at least 2, but works better with 3. * This does not determine *which* chains to use, just how many. */ -static int il4965_get_active_rx_chain_count(struct il_priv *il) +static int +il4965_get_active_rx_chain_count(struct il_priv *il) { /* # of Rx chains to use when expecting MIMO. */ if (il4965_is_single_rx_stream(il)) @@ -1089,14 +1098,14 @@ il4965_get_idle_rx_chain_count(struct il_priv *il, int active_cnt) case IEEE80211_SMPS_OFF: return active_cnt; default: - WARN(1, "invalid SMPS mode %d", - il->current_ht_config.smps); + WARN(1, "invalid SMPS mode %d", il->current_ht_config.smps); return active_cnt; } } /* up to 4 chains */ -static u8 il4965_count_chain_bitmap(u32 chain_bitmap) +static u8 +il4965_count_chain_bitmap(u32 chain_bitmap) { u8 res; res = (chain_bitmap & BIT(0)) >> 0; @@ -1112,7 +1121,8 @@ static u8 il4965_count_chain_bitmap(u32 chain_bitmap) * Selects how many and which Rx receivers/antennas/chains to use. * This should not be used for scan command ... it puts data in wrong place. */ -void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx) +void +il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx) { bool is_single = il4965_is_single_rx_stream(il); bool is_cam = !test_bit(S_POWER_PMI, &il->status); @@ -1135,7 +1145,6 @@ void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx) active_rx_cnt = il4965_get_active_rx_chain_count(il); idle_rx_cnt = il4965_get_idle_rx_chain_count(il, active_rx_cnt); - /* correct rx chain count according hw settings * and chain noise calibration */ @@ -1147,7 +1156,7 @@ void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx) idle_rx_cnt = valid_rx_cnt; rx_chain |= active_rx_cnt << RXON_RX_CHAIN_MIMO_CNT_POS; - rx_chain |= idle_rx_cnt << RXON_RX_CHAIN_CNT_POS; + rx_chain |= idle_rx_cnt << RXON_RX_CHAIN_CNT_POS; ctx->staging.rx_chain = cpu_to_le16(rx_chain); @@ -1156,45 +1165,47 @@ void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx) else ctx->staging.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK; - D_ASSOC("rx_chain=0x%X active=%d idle=%d\n", - ctx->staging.rx_chain, - active_rx_cnt, idle_rx_cnt); + D_ASSOC("rx_chain=0x%X active=%d idle=%d\n", ctx->staging.rx_chain, + active_rx_cnt, idle_rx_cnt); WARN_ON(active_rx_cnt == 0 || idle_rx_cnt == 0 || active_rx_cnt < idle_rx_cnt); } -u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant, u8 valid) +u8 +il4965_toggle_tx_ant(struct il_priv *il, u8 ant, u8 valid) { int i; u8 ind = ant; for (i = 0; i < RATE_ANT_NUM - 1; i++) { - ind = (ind + 1) < RATE_ANT_NUM ? ind + 1 : 0; + ind = (ind + 1) < RATE_ANT_NUM ? ind + 1 : 0; if (valid & BIT(ind)) return ind; } return ant; } -static const char *il4965_get_fh_string(int cmd) +static const char * +il4965_get_fh_string(int cmd) { switch (cmd) { - IL_CMD(FH49_RSCSR_CHNL0_STTS_WPTR_REG); - IL_CMD(FH49_RSCSR_CHNL0_RBDCB_BASE_REG); - IL_CMD(FH49_RSCSR_CHNL0_WPTR); - IL_CMD(FH49_MEM_RCSR_CHNL0_CONFIG_REG); - IL_CMD(FH49_MEM_RSSR_SHARED_CTRL_REG); - IL_CMD(FH49_MEM_RSSR_RX_STATUS_REG); - IL_CMD(FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV); - IL_CMD(FH49_TSSR_TX_STATUS_REG); - IL_CMD(FH49_TSSR_TX_ERROR_REG); + IL_CMD(FH49_RSCSR_CHNL0_STTS_WPTR_REG); + IL_CMD(FH49_RSCSR_CHNL0_RBDCB_BASE_REG); + IL_CMD(FH49_RSCSR_CHNL0_WPTR); + IL_CMD(FH49_MEM_RCSR_CHNL0_CONFIG_REG); + IL_CMD(FH49_MEM_RSSR_SHARED_CTRL_REG); + IL_CMD(FH49_MEM_RSSR_RX_STATUS_REG); + IL_CMD(FH49_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV); + IL_CMD(FH49_TSSR_TX_STATUS_REG); + IL_CMD(FH49_TSSR_TX_ERROR_REG); default: return "UNKNOWN"; } } -int il4965_dump_fh(struct il_priv *il, char **buf, bool display) +int +il4965_dump_fh(struct il_priv *il, char **buf, bool display) { int i; #ifdef CONFIG_IWLEGACY_DEBUG @@ -1218,28 +1229,29 @@ int il4965_dump_fh(struct il_priv *il, char **buf, bool display) *buf = kmalloc(bufsz, GFP_KERNEL); if (!*buf) return -ENOMEM; - pos += scnprintf(*buf + pos, bufsz - pos, - "FH register values:\n"); + pos += + scnprintf(*buf + pos, bufsz - pos, "FH register values:\n"); for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { - pos += scnprintf(*buf + pos, bufsz - pos, - " %34s: 0X%08x\n", - il4965_get_fh_string(fh_tbl[i]), - il_rd(il, fh_tbl[i])); + pos += + scnprintf(*buf + pos, bufsz - pos, + " %34s: 0X%08x\n", + il4965_get_fh_string(fh_tbl[i]), il_rd(il, + fh_tbl + [i])); } return pos; } #endif IL_ERR("FH register values:\n"); - for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { - IL_ERR(" %34s: 0X%08x\n", - il4965_get_fh_string(fh_tbl[i]), - il_rd(il, fh_tbl[i])); + for (i = 0; i < ARRAY_SIZE(fh_tbl); i++) { + IL_ERR(" %34s: 0X%08x\n", il4965_get_fh_string(fh_tbl[i]), + il_rd(il, fh_tbl[i])); } return 0; } -void il4965_hdl_missed_beacon(struct il_priv *il, - struct il_rx_buf *rxb) +void +il4965_hdl_missed_beacon(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_missed_beacon_notif *missed_beacon; @@ -1247,12 +1259,11 @@ void il4965_hdl_missed_beacon(struct il_priv *il, missed_beacon = &pkt->u.missed_beacon; if (le32_to_cpu(missed_beacon->consecutive_missed_beacons) > il->missed_beacon_threshold) { - D_CALIB( - "missed bcn cnsq %d totl %d rcd %d expctd %d\n", - le32_to_cpu(missed_beacon->consecutive_missed_beacons), - le32_to_cpu(missed_beacon->total_missed_becons), - le32_to_cpu(missed_beacon->num_recvd_beacons), - le32_to_cpu(missed_beacon->num_expected_beacons)); + D_CALIB("missed bcn cnsq %d totl %d rcd %d expctd %d\n", + le32_to_cpu(missed_beacon->consecutive_missed_beacons), + le32_to_cpu(missed_beacon->total_missed_becons), + le32_to_cpu(missed_beacon->num_recvd_beacons), + le32_to_cpu(missed_beacon->num_expected_beacons)); if (!test_bit(S_SCANNING, &il->status)) il4965_init_sensitivity(il); } @@ -1261,7 +1272,8 @@ void il4965_hdl_missed_beacon(struct il_priv *il, /* Calculate noise level, based on measurements during network silence just * before arriving beacon. This measurement can be done only if we know * exactly when to expect beacons, therefore only when we're associated. */ -static void il4965_rx_calc_noise(struct il_priv *il) +static void +il4965_rx_calc_noise(struct il_priv *il) { struct stats_rx_non_phy *rx_info; int num_active_rx = 0; @@ -1271,11 +1283,11 @@ static void il4965_rx_calc_noise(struct il_priv *il) rx_info = &(il->_4965.stats.rx.general); bcn_silence_a = - le32_to_cpu(rx_info->beacon_silence_rssi_a) & IN_BAND_FILTER; + le32_to_cpu(rx_info->beacon_silence_rssi_a) & IN_BAND_FILTER; bcn_silence_b = - le32_to_cpu(rx_info->beacon_silence_rssi_b) & IN_BAND_FILTER; + le32_to_cpu(rx_info->beacon_silence_rssi_b) & IN_BAND_FILTER; bcn_silence_c = - le32_to_cpu(rx_info->beacon_silence_rssi_c) & IN_BAND_FILTER; + le32_to_cpu(rx_info->beacon_silence_rssi_c) & IN_BAND_FILTER; if (bcn_silence_a) { total_silence += bcn_silence_a; @@ -1296,9 +1308,8 @@ static void il4965_rx_calc_noise(struct il_priv *il) else last_rx_noise = IL_NOISE_MEAS_NOT_AVAILABLE; - D_CALIB("inband silence a %u, b %u, c %u, dBm %d\n", - bcn_silence_a, bcn_silence_b, bcn_silence_c, - last_rx_noise); + D_CALIB("inband silence a %u, b %u, c %u, dBm %d\n", bcn_silence_a, + bcn_silence_b, bcn_silence_c, last_rx_noise); } #ifdef CONFIG_IWLEGACY_DEBUGFS @@ -1307,8 +1318,8 @@ static void il4965_rx_calc_noise(struct il_priv *il) * FIXME: This function is for debugging, do not deal with * the case of counters roll-over. */ -static void il4965_accumulative_stats(struct il_priv *il, - __le32 *stats) +static void +il4965_accumulative_stats(struct il_priv *il, __le32 * stats) { int i, size; __le32 *prev_stats; @@ -1317,22 +1328,23 @@ static void il4965_accumulative_stats(struct il_priv *il, struct stats_general_common *general, *accum_general; struct stats_tx *tx, *accum_tx; - prev_stats = (__le32 *)&il->_4965.stats; - accum_stats = (u32 *)&il->_4965.accum_stats; + prev_stats = (__le32 *) & il->_4965.stats; + accum_stats = (u32 *) & il->_4965.accum_stats; size = sizeof(struct il_notif_stats); general = &il->_4965.stats.general.common; accum_general = &il->_4965.accum_stats.general.common; tx = &il->_4965.stats.tx; accum_tx = &il->_4965.accum_stats.tx; - delta = (u32 *)&il->_4965.delta_stats; - max_delta = (u32 *)&il->_4965.max_delta; + delta = (u32 *) & il->_4965.delta_stats; + max_delta = (u32 *) & il->_4965.max_delta; for (i = sizeof(__le32); i < size; - i += sizeof(__le32), stats++, prev_stats++, delta++, - max_delta++, accum_stats++) { + i += + sizeof(__le32), stats++, prev_stats++, delta++, max_delta++, + accum_stats++) { if (le32_to_cpu(*stats) > le32_to_cpu(*prev_stats)) { - *delta = (le32_to_cpu(*stats) - - le32_to_cpu(*prev_stats)); + *delta = + (le32_to_cpu(*stats) - le32_to_cpu(*prev_stats)); *accum_stats += *delta; if (*delta > *max_delta) *max_delta = *delta; @@ -1347,31 +1359,27 @@ static void il4965_accumulative_stats(struct il_priv *il, #define REG_RECALIB_PERIOD (60) -void il4965_hdl_stats(struct il_priv *il, - struct il_rx_buf *rxb) +void +il4965_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb) { int change; struct il_rx_pkt *pkt = rxb_addr(rxb); - D_RX( - "Statistics notification received (%d vs %d).\n", - (int)sizeof(struct il_notif_stats), - le32_to_cpu(pkt->len_n_flags) & - IL_RX_FRAME_SIZE_MSK); - - change = ((il->_4965.stats.general.common.temperature != - pkt->u.stats.general.common.temperature) || - ((il->_4965.stats.flag & - STATS_REPLY_FLG_HT40_MODE_MSK) != - (pkt->u.stats.flag & - STATS_REPLY_FLG_HT40_MODE_MSK))); + D_RX("Statistics notification received (%d vs %d).\n", + (int)sizeof(struct il_notif_stats), + le32_to_cpu(pkt->len_n_flags) & IL_RX_FRAME_SIZE_MSK); + + change = + ((il->_4965.stats.general.common.temperature != + pkt->u.stats.general.common.temperature) || + ((il->_4965.stats.flag & STATS_REPLY_FLG_HT40_MODE_MSK) != + (pkt->u.stats.flag & STATS_REPLY_FLG_HT40_MODE_MSK))); #ifdef CONFIG_IWLEGACY_DEBUGFS - il4965_accumulative_stats(il, (__le32 *)&pkt->u.stats); + il4965_accumulative_stats(il, (__le32 *) & pkt->u.stats); #endif /* TODO: reading some of stats is unneeded */ - memcpy(&il->_4965.stats, &pkt->u.stats, - sizeof(il->_4965.stats)); + memcpy(&il->_4965.stats, &pkt->u.stats, sizeof(il->_4965.stats)); set_bit(S_STATS, &il->status); @@ -1379,8 +1387,8 @@ void il4965_hdl_stats(struct il_priv *il, * REG_RECALIB_PERIOD seconds to ensure we get a * thermal update even if the uCode doesn't give * us one */ - mod_timer(&il->stats_periodic, jiffies + - msecs_to_jiffies(REG_RECALIB_PERIOD * 1000)); + mod_timer(&il->stats_periodic, + jiffies + msecs_to_jiffies(REG_RECALIB_PERIOD * 1000)); if (unlikely(!test_bit(S_SCANNING, &il->status)) && (pkt->hdr.cmd == N_STATS)) { @@ -1391,19 +1399,18 @@ void il4965_hdl_stats(struct il_priv *il, il->cfg->ops->lib->temp_ops.temperature(il); } -void il4965_hdl_c_stats(struct il_priv *il, - struct il_rx_buf *rxb) +void +il4965_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); if (le32_to_cpu(pkt->u.stats.flag) & UCODE_STATS_CLEAR_MSK) { #ifdef CONFIG_IWLEGACY_DEBUGFS memset(&il->_4965.accum_stats, 0, - sizeof(struct il_notif_stats)); + sizeof(struct il_notif_stats)); memset(&il->_4965.delta_stats, 0, - sizeof(struct il_notif_stats)); - memset(&il->_4965.max_delta, 0, - sizeof(struct il_notif_stats)); + sizeof(struct il_notif_stats)); + memset(&il->_4965.max_delta, 0, sizeof(struct il_notif_stats)); #endif D_RX("Statistics have been cleared\n"); } @@ -1448,7 +1455,8 @@ static const u8 tid_to_ac[] = { IEEE80211_AC_VO }; -static inline int il4965_get_ac_from_tid(u16 tid) +static inline int +il4965_get_ac_from_tid(u16 tid) { if (likely(tid < ARRAY_SIZE(tid_to_ac))) return tid_to_ac[tid]; @@ -1470,12 +1478,11 @@ il4965_get_fifo_from_tid(struct il_rxon_context *ctx, u16 tid) /* * handle build C_TX command notification. */ -static void il4965_tx_cmd_build_basic(struct il_priv *il, - struct sk_buff *skb, - struct il_tx_cmd *tx_cmd, - struct ieee80211_tx_info *info, - struct ieee80211_hdr *hdr, - u8 std_id) +static void +il4965_tx_cmd_build_basic(struct il_priv *il, struct sk_buff *skb, + struct il_tx_cmd *tx_cmd, + struct ieee80211_tx_info *info, + struct ieee80211_hdr *hdr, u8 std_id) { __le16 fc = hdr->frame_control; __le32 tx_flags = tx_cmd->tx_flags; @@ -1527,10 +1534,9 @@ static void il4965_tx_cmd_build_basic(struct il_priv *il, #define RTS_DFAULT_RETRY_LIMIT 60 -static void il4965_tx_cmd_build_rate(struct il_priv *il, - struct il_tx_cmd *tx_cmd, - struct ieee80211_tx_info *info, - __le16 fc) +static void +il4965_tx_cmd_build_rate(struct il_priv *il, struct il_tx_cmd *tx_cmd, + struct ieee80211_tx_info *info, __le16 fc) { u32 rate_flags; int rate_idx; @@ -1538,7 +1544,7 @@ static void il4965_tx_cmd_build_rate(struct il_priv *il, u8 data_retry_limit; u8 rate_plcp; - /* Set retry limit on DATA packets and Probe Responses*/ + /* Set retry limit on DATA packets and Probe Responses */ if (ieee80211_is_probe_resp(fc)) data_retry_limit = 3; else @@ -1566,10 +1572,11 @@ static void il4965_tx_cmd_build_rate(struct il_priv *il, * idx is invalid. */ rate_idx = info->control.rates[0].idx; - if ((info->control.rates[0].flags & IEEE80211_TX_RC_MCS) || - rate_idx < 0 || rate_idx > RATE_COUNT_LEGACY) - rate_idx = rate_lowest_index(&il->bands[info->band], - info->control.sta); + if ((info->control.rates[0].flags & IEEE80211_TX_RC_MCS) || rate_idx < 0 + || rate_idx > RATE_COUNT_LEGACY) + rate_idx = + rate_lowest_index(&il->bands[info->band], + info->control.sta); /* For 5 GHZ band, remap mac80211 rate indices into driver indices */ if (info->band == IEEE80211_BAND_5GHZ) rate_idx += IL_FIRST_OFDM_RATE; @@ -1583,20 +1590,21 @@ static void il4965_tx_cmd_build_rate(struct il_priv *il, rate_flags |= RATE_MCS_CCK_MSK; /* Set up antennas */ - il->mgmt_tx_ant = il4965_toggle_tx_ant(il, il->mgmt_tx_ant, - il->hw_params.valid_tx_ant); + il->mgmt_tx_ant = + il4965_toggle_tx_ant(il, il->mgmt_tx_ant, + il->hw_params.valid_tx_ant); rate_flags |= il4965_ant_idx_to_flags(il->mgmt_tx_ant); /* Set the rate in the TX cmd */ - tx_cmd->rate_n_flags = il4965_hw_set_rate_n_flags(rate_plcp, rate_flags); + tx_cmd->rate_n_flags = + il4965_hw_set_rate_n_flags(rate_plcp, rate_flags); } -static void il4965_tx_cmd_build_hwcrypto(struct il_priv *il, - struct ieee80211_tx_info *info, - struct il_tx_cmd *tx_cmd, - struct sk_buff *skb_frag, - int sta_id) +static void +il4965_tx_cmd_build_hwcrypto(struct il_priv *il, struct ieee80211_tx_info *info, + struct il_tx_cmd *tx_cmd, struct sk_buff *skb_frag, + int sta_id) { struct ieee80211_key_conf *keyconf = info->control.hw_key; @@ -1619,13 +1627,14 @@ static void il4965_tx_cmd_build_hwcrypto(struct il_priv *il, tx_cmd->sec_ctl |= TX_CMD_SEC_KEY128; /* fall through */ case WLAN_CIPHER_SUITE_WEP40: - tx_cmd->sec_ctl |= (TX_CMD_SEC_WEP | - (keyconf->keyidx & TX_CMD_SEC_MSK) << TX_CMD_SEC_SHIFT); + tx_cmd->sec_ctl |= + (TX_CMD_SEC_WEP | (keyconf->keyidx & TX_CMD_SEC_MSK) << + TX_CMD_SEC_SHIFT); memcpy(&tx_cmd->key[3], keyconf->key, keyconf->keylen); - D_TX("Configuring packet for WEP encryption " - "with key %d\n", keyconf->keyidx); + D_TX("Configuring packet for WEP encryption " "with key %d\n", + keyconf->keyidx); break; default: @@ -1637,7 +1646,8 @@ static void il4965_tx_cmd_build_hwcrypto(struct il_priv *il, /* * start C_TX command process */ -int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) +int +il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) { struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); @@ -1694,8 +1704,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) sta_id = il_sta_id_or_broadcast(il, ctx, info->control.sta); if (sta_id == IL_INVALID_STATION) { - D_DROP("Dropping - INVALID STATION: %pM\n", - hdr->addr1); + D_DROP("Dropping - INVALID STATION: %pM\n", hdr->addr1); goto drop_unlock; } } @@ -1729,8 +1738,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) * The microcode will clear the more data * bit in the last frame it transmits. */ - hdr->frame_control |= - cpu_to_le16(IEEE80211_FCTL_MOREDATA); + hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA); } else txq_id = ctx->ac_to_queue[skb_get_queue_mapping(skb)]; @@ -1746,8 +1754,8 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) } seq_number = il->stations[sta_id].tid[tid].seq_number; seq_number &= IEEE80211_SCTL_SEQ; - hdr->seq_ctrl = hdr->seq_ctrl & - cpu_to_le16(IEEE80211_SCTL_FRAG); + hdr->seq_ctrl = + hdr->seq_ctrl & cpu_to_le16(IEEE80211_SCTL_FRAG); hdr->seq_ctrl |= cpu_to_le16(seq_number); seq_number += 0x10; /* aggregation is on for this */ @@ -1793,15 +1801,15 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) * locate the frame within the tx queue and do post-tx processing. */ out_cmd->hdr.cmd = C_TX; - out_cmd->hdr.sequence = cpu_to_le16((u16)(QUEUE_TO_SEQ(txq_id) | - IDX_TO_SEQ(q->write_ptr))); + out_cmd->hdr.sequence = + cpu_to_le16((u16) + (QUEUE_TO_SEQ(txq_id) | IDX_TO_SEQ(q->write_ptr))); /* Copy MAC header from skb into command buffer */ memcpy(tx_cmd->hdr, hdr, hdr_len); - /* Total # bytes to be transmitted */ - len = (u16)skb->len; + len = (u16) skb->len; tx_cmd->len = cpu_to_le16(len); if (info->control.hw_key) @@ -1823,8 +1831,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) * of the MAC header (device reads on dword boundaries). * We'll tell device about this padding later. */ - len = sizeof(struct il_tx_cmd) + - sizeof(struct il_cmd_header) + hdr_len; + len = sizeof(struct il_tx_cmd) + sizeof(struct il_cmd_header) + hdr_len; firstlen = (len + 3) & ~3; /* Tell NIC about any 2-byte padding after MAC header */ @@ -1833,15 +1840,15 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) /* Physical address of this Tx command's header (not MAC header!), * within command buffer array. */ - txcmd_phys = pci_map_single(il->pci_dev, - &out_cmd->hdr, firstlen, - PCI_DMA_BIDIRECTIONAL); + txcmd_phys = + pci_map_single(il->pci_dev, &out_cmd->hdr, firstlen, + PCI_DMA_BIDIRECTIONAL); dma_unmap_addr_set(out_meta, mapping, txcmd_phys); dma_unmap_len_set(out_meta, len, firstlen); /* Add buffer containing Tx command and MAC(!) header to TFD's * first entry */ - il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, - txcmd_phys, firstlen, 1, 0); + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, txcmd_phys, firstlen, + 1, 0); if (!ieee80211_has_morefrags(hdr->frame_control)) { txq->need_update = 1; @@ -1854,35 +1861,36 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb) * if any (802.11 null frames have no payload). */ secondlen = skb->len - hdr_len; if (secondlen > 0) { - phys_addr = pci_map_single(il->pci_dev, skb->data + hdr_len, - secondlen, PCI_DMA_TODEVICE); - il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, - phys_addr, secondlen, - 0, 0); + phys_addr = + pci_map_single(il->pci_dev, skb->data + hdr_len, secondlen, + PCI_DMA_TODEVICE); + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr, + secondlen, 0, 0); } - scratch_phys = txcmd_phys + sizeof(struct il_cmd_header) + - offsetof(struct il_tx_cmd, scratch); + scratch_phys = + txcmd_phys + sizeof(struct il_cmd_header) + + offsetof(struct il_tx_cmd, scratch); /* take back ownership of DMA buffer to enable update */ - pci_dma_sync_single_for_cpu(il->pci_dev, txcmd_phys, - firstlen, PCI_DMA_BIDIRECTIONAL); + pci_dma_sync_single_for_cpu(il->pci_dev, txcmd_phys, firstlen, + PCI_DMA_BIDIRECTIONAL); tx_cmd->dram_lsb_ptr = cpu_to_le32(scratch_phys); tx_cmd->dram_msb_ptr = il_get_dma_hi_addr(scratch_phys); - D_TX("sequence nr = 0X%x\n", - le16_to_cpu(out_cmd->hdr.sequence)); + D_TX("sequence nr = 0X%x\n", le16_to_cpu(out_cmd->hdr.sequence)); D_TX("tx_flags = 0X%x\n", le32_to_cpu(tx_cmd->tx_flags)); - il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd, sizeof(*tx_cmd)); - il_print_hex_dump(il, IL_DL_TX, (u8 *)tx_cmd->hdr, hdr_len); + il_print_hex_dump(il, IL_DL_TX, (u8 *) tx_cmd, sizeof(*tx_cmd)); + il_print_hex_dump(il, IL_DL_TX, (u8 *) tx_cmd->hdr, hdr_len); /* Set up entry for this TFD in Tx byte-count array */ if (info->flags & IEEE80211_TX_CTL_AMPDU) il->cfg->ops->lib->txq_update_byte_cnt_tbl(il, txq, - le16_to_cpu(tx_cmd->len)); + le16_to_cpu(tx_cmd-> + len)); - pci_dma_sync_single_for_device(il->pci_dev, txcmd_phys, - firstlen, PCI_DMA_BIDIRECTIONAL); + pci_dma_sync_single_for_device(il->pci_dev, txcmd_phys, firstlen, + PCI_DMA_BIDIRECTIONAL); /* Tell device the write idx *just past* this latest filled TFD */ q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); @@ -1924,19 +1932,19 @@ drop_unlock: return -1; } -static inline int il4965_alloc_dma_ptr(struct il_priv *il, - struct il_dma_ptr *ptr, size_t size) +static inline int +il4965_alloc_dma_ptr(struct il_priv *il, struct il_dma_ptr *ptr, size_t size) { - ptr->addr = dma_alloc_coherent(&il->pci_dev->dev, size, &ptr->dma, - GFP_KERNEL); + ptr->addr = + dma_alloc_coherent(&il->pci_dev->dev, size, &ptr->dma, GFP_KERNEL); if (!ptr->addr) return -ENOMEM; ptr->size = size; return 0; } -static inline void il4965_free_dma_ptr(struct il_priv *il, - struct il_dma_ptr *ptr) +static inline void +il4965_free_dma_ptr(struct il_priv *il, struct il_dma_ptr *ptr) { if (unlikely(!ptr->addr)) return; @@ -1950,7 +1958,8 @@ static inline void il4965_free_dma_ptr(struct il_priv *il, * * Destroy all TX DMA queues and structures */ -void il4965_hw_txq_ctx_free(struct il_priv *il) +void +il4965_hw_txq_ctx_free(struct il_priv *il) { int txq_id; @@ -1977,7 +1986,8 @@ void il4965_hw_txq_ctx_free(struct il_priv *il) * @param il * @return error code */ -int il4965_txq_ctx_alloc(struct il_priv *il) +int +il4965_txq_ctx_alloc(struct il_priv *il) { int ret; int txq_id, slots_num; @@ -1986,8 +1996,9 @@ int il4965_txq_ctx_alloc(struct il_priv *il) /* Free all tx/cmd queues and keep-warm buffer */ il4965_hw_txq_ctx_free(il); - ret = il4965_alloc_dma_ptr(il, &il->scd_bc_tbls, - il->hw_params.scd_bc_tbls_size); + ret = + il4965_alloc_dma_ptr(il, &il->scd_bc_tbls, + il->hw_params.scd_bc_tbls_size); if (ret) { IL_ERR("Scheduler BC Table allocation failed\n"); goto error_bc_tbls; @@ -2016,11 +2027,10 @@ int il4965_txq_ctx_alloc(struct il_priv *il) /* Alloc and init all Tx queues, including the command queue (#4/#9) */ for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { - slots_num = (txq_id == il->cmd_queue) ? - TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - ret = il_tx_queue_init(il, - &il->txq[txq_id], slots_num, - txq_id); + slots_num = + (txq_id == + il->cmd_queue) ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; + ret = il_tx_queue_init(il, &il->txq[txq_id], slots_num, txq_id); if (ret) { IL_ERR("Tx %d queue init failed\n", txq_id); goto error; @@ -2029,16 +2039,17 @@ int il4965_txq_ctx_alloc(struct il_priv *il) return ret; - error: +error: il4965_hw_txq_ctx_free(il); il4965_free_dma_ptr(il, &il->kw); - error_kw: +error_kw: il4965_free_dma_ptr(il, &il->scd_bc_tbls); - error_bc_tbls: +error_bc_tbls: return ret; } -void il4965_txq_ctx_reset(struct il_priv *il) +void +il4965_txq_ctx_reset(struct il_priv *il) { int txq_id, slots_num; unsigned long flags; @@ -2055,17 +2066,17 @@ void il4965_txq_ctx_reset(struct il_priv *il) /* Alloc and init all Tx queues, including the command queue (#4) */ for (txq_id = 0; txq_id < il->hw_params.max_txq_num; txq_id++) { - slots_num = txq_id == il->cmd_queue ? - TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; - il_tx_queue_reset(il, &il->txq[txq_id], - slots_num, txq_id); + slots_num = + txq_id == il->cmd_queue ? TFD_CMD_SLOTS : TFD_TX_CMD_SLOTS; + il_tx_queue_reset(il, &il->txq[txq_id], slots_num, txq_id); } } /** * il4965_txq_ctx_stop - Stop all Tx DMA channels */ -void il4965_txq_ctx_stop(struct il_priv *il) +void +il4965_txq_ctx_stop(struct il_priv *il) { int ch, txq_id; unsigned long flags; @@ -2077,15 +2088,13 @@ void il4965_txq_ctx_stop(struct il_priv *il) /* Stop each Tx DMA channel, and wait for it to be idle */ for (ch = 0; ch < il->hw_params.dma_chnl_num; ch++) { - il_wr(il, - FH49_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0); - if (il_poll_bit(il, FH49_TSSR_TX_STATUS_REG, - FH49_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), - 1000)) + il_wr(il, FH49_TCSR_CHNL_TX_CONFIG_REG(ch), 0x0); + if (il_poll_bit + (il, FH49_TSSR_TX_STATUS_REG, + FH49_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), 1000)) IL_ERR("Failing on timeout while stopping" - " DMA channel %d [0x%08x]", ch, - il_rd(il, - FH49_TSSR_TX_STATUS_REG)); + " DMA channel %d [0x%08x]", ch, il_rd(il, + FH49_TSSR_TX_STATUS_REG)); } spin_unlock_irqrestore(&il->lock, flags); @@ -2106,7 +2115,8 @@ void il4965_txq_ctx_stop(struct il_priv *il) * Should never return anything < 7, because they should already * be in use as EDCA AC (0-3), Command (4), reserved (5, 6) */ -static int il4965_txq_ctx_activate_free(struct il_priv *il) +static int +il4965_txq_ctx_activate_free(struct il_priv *il) { int txq_id; @@ -2119,22 +2129,21 @@ static int il4965_txq_ctx_activate_free(struct il_priv *il) /** * il4965_tx_queue_stop_scheduler - Stop queue, but keep configuration */ -static void il4965_tx_queue_stop_scheduler(struct il_priv *il, - u16 txq_id) +static void +il4965_tx_queue_stop_scheduler(struct il_priv *il, u16 txq_id) { /* Simply stop the queue, but don't change any configuration; * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */ - il_wr_prph(il, - IL49_SCD_QUEUE_STATUS_BITS(txq_id), - (0 << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE)| - (1 << IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); + il_wr_prph(il, IL49_SCD_QUEUE_STATUS_BITS(txq_id), + (0 << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | (1 << + IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); } /** * il4965_tx_queue_set_q2ratid - Map unique receiver/tid combination to a queue */ -static int il4965_tx_queue_set_q2ratid(struct il_priv *il, u16 ra_tid, - u16 txq_id) +static int +il4965_tx_queue_set_q2ratid(struct il_priv *il, u16 ra_tid, u16 txq_id) { u32 tbl_dw_addr; u32 tbl_dw; @@ -2142,8 +2151,8 @@ static int il4965_tx_queue_set_q2ratid(struct il_priv *il, u16 ra_tid, scd_q2ratid = ra_tid & IL_SCD_QUEUE_RA_TID_MAP_RATID_MSK; - tbl_dw_addr = il->scd_base_addr + - IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id); + tbl_dw_addr = + il->scd_base_addr + IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(txq_id); tbl_dw = il_read_targ_mem(il, tbl_dw_addr); @@ -2163,8 +2172,9 @@ static int il4965_tx_queue_set_q2ratid(struct il_priv *il, u16 ra_tid, * NOTE: txq_id must be greater than IL49_FIRST_AMPDU_QUEUE, * i.e. it must be one of the higher queues used for aggregation */ -static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, - int tx_fifo, int sta_id, int tid, u16 ssn_idx) +static int +il4965_txq_agg_enable(struct il_priv *il, int txq_id, int tx_fifo, int sta_id, + int tid, u16 ssn_idx) { unsigned long flags; u16 ra_tid; @@ -2172,9 +2182,8 @@ static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, if ((IL49_FIRST_AMPDU_QUEUE > txq_id) || (IL49_FIRST_AMPDU_QUEUE + - il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { - IL_WARN( - "queue number out of range: %d, must be %d to %d\n", + il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { + IL_WARN("queue number out of range: %d, must be %d to %d\n", txq_id, IL49_FIRST_AMPDU_QUEUE, IL49_FIRST_AMPDU_QUEUE + il->cfg->base_params->num_of_ampdu_queues - 1); @@ -2207,14 +2216,17 @@ static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, /* Set up Tx win size and frame limit for this queue */ il_write_targ_mem(il, - il->scd_base_addr + IL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id), - (SCD_WIN_SIZE << IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & - IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); + il->scd_base_addr + + IL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id), + (SCD_WIN_SIZE << IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) + & IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); - il_write_targ_mem(il, il->scd_base_addr + - IL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id) + sizeof(u32), - (SCD_FRAME_LIMIT << IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) - & IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); + il_write_targ_mem(il, + il->scd_base_addr + + IL49_SCD_CONTEXT_QUEUE_OFFSET(txq_id) + sizeof(u32), + (SCD_FRAME_LIMIT << + IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) & + IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); il_set_bits_prph(il, IL49_SCD_INTERRUPT_MASK, (1 << txq_id)); @@ -2226,9 +2238,9 @@ static int il4965_txq_agg_enable(struct il_priv *il, int txq_id, return 0; } - -int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, - struct ieee80211_sta *sta, u16 tid, u16 *ssn) +int +il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, + struct ieee80211_sta *sta, u16 tid, u16 * ssn) { int sta_id; int tx_fifo; @@ -2241,8 +2253,7 @@ int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, if (unlikely(tx_fifo < 0)) return tx_fifo; - IL_WARN("%s on ra = %pM tid = %d\n", - __func__, sta->addr, tid); + IL_WARN("%s on ra = %pM tid = %d\n", __func__, sta->addr, tid); sta_id = il_sta_id(sta); if (sta_id == IL_INVALID_STATION) { @@ -2267,12 +2278,10 @@ int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, tid_data = &il->stations[sta_id].tid[tid]; *ssn = SEQ_TO_SN(tid_data->seq_number); tid_data->agg.txq_id = txq_id; - il_set_swq_id(&il->txq[txq_id], - il4965_get_ac_from_tid(tid), txq_id); + il_set_swq_id(&il->txq[txq_id], il4965_get_ac_from_tid(tid), txq_id); spin_unlock_irqrestore(&il->sta_lock, flags); - ret = il4965_txq_agg_enable(il, txq_id, tx_fifo, - sta_id, tid, *ssn); + ret = il4965_txq_agg_enable(il, txq_id, tx_fifo, sta_id, tid, *ssn); if (ret) return ret; @@ -2283,9 +2292,8 @@ int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, tid_data->agg.state = IL_AGG_ON; ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid); } else { - D_HT( - "HW queue is NOT empty: %d packets in HW queue\n", - tid_data->tfds_in_queue); + D_HT("HW queue is NOT empty: %d packets in HW queue\n", + tid_data->tfds_in_queue); tid_data->agg.state = IL_EMPTYING_HW_QUEUE_ADDBA; } spin_unlock_irqrestore(&il->sta_lock, flags); @@ -2296,14 +2304,13 @@ int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, * txq_id must be greater than IL49_FIRST_AMPDU_QUEUE * il->lock must be held by the caller */ -static int il4965_txq_agg_disable(struct il_priv *il, u16 txq_id, - u16 ssn_idx, u8 tx_fifo) +static int +il4965_txq_agg_disable(struct il_priv *il, u16 txq_id, u16 ssn_idx, u8 tx_fifo) { if ((IL49_FIRST_AMPDU_QUEUE > txq_id) || (IL49_FIRST_AMPDU_QUEUE + - il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { - IL_WARN( - "queue number out of range: %d, must be %d to %d\n", + il->cfg->base_params->num_of_ampdu_queues <= txq_id)) { + IL_WARN("queue number out of range: %d, must be %d to %d\n", txq_id, IL49_FIRST_AMPDU_QUEUE, IL49_FIRST_AMPDU_QUEUE + il->cfg->base_params->num_of_ampdu_queues - 1); @@ -2312,24 +2319,23 @@ static int il4965_txq_agg_disable(struct il_priv *il, u16 txq_id, il4965_tx_queue_stop_scheduler(il, txq_id); - il_clear_bits_prph(il, - IL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); + il_clear_bits_prph(il, IL49_SCD_QUEUECHAIN_SEL, (1 << txq_id)); il->txq[txq_id].q.read_ptr = (ssn_idx & 0xff); il->txq[txq_id].q.write_ptr = (ssn_idx & 0xff); /* supposes that ssn_idx is valid (!= 0xFFF) */ il4965_set_wr_ptrs(il, txq_id, ssn_idx); - il_clear_bits_prph(il, - IL49_SCD_INTERRUPT_MASK, (1 << txq_id)); + il_clear_bits_prph(il, IL49_SCD_INTERRUPT_MASK, (1 << txq_id)); il_txq_ctx_deactivate(il, txq_id); il4965_tx_queue_set_status(il, &il->txq[txq_id], tx_fifo, 0); return 0; } -int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, - struct ieee80211_sta *sta, u16 tid) +int +il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, + struct ieee80211_sta *sta, u16 tid) { int tx_fifo_id, txq_id, sta_id, ssn; struct il_tid_data *tid_data; @@ -2376,13 +2382,13 @@ int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, if (write_ptr != read_ptr) { D_HT("Stopping a non empty AGG HW QUEUE\n"); il->stations[sta_id].tid[tid].agg.state = - IL_EMPTYING_HW_QUEUE_DELBA; + IL_EMPTYING_HW_QUEUE_DELBA; spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } D_HT("HW queue is empty\n"); - turn_off: +turn_off: il->stations[sta_id].tid[tid].agg.state = IL_AGG_OFF; /* do not restore/save irqs */ @@ -2404,8 +2410,8 @@ int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, return 0; } -int il4965_txq_check_empty(struct il_priv *il, - int sta_id, u8 tid, int txq_id) +int +il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id) { struct il_queue *q = &il->txq[txq_id].q; u8 *addr = il->stations[sta_id].sta.sta.addr; @@ -2420,12 +2426,11 @@ int il4965_txq_check_empty(struct il_priv *il, case IL_EMPTYING_HW_QUEUE_DELBA: /* We are reclaiming the last packet of the */ /* aggregated HW queue */ - if (txq_id == tid_data->agg.txq_id && + if (txq_id == tid_data->agg.txq_id && q->read_ptr == q->write_ptr) { u16 ssn = SEQ_TO_SN(tid_data->seq_number); int tx_fifo = il4965_get_fifo_from_tid(ctx, tid); - D_HT( - "HW queue empty: continue DELBA flow\n"); + D_HT("HW queue empty: continue DELBA flow\n"); il4965_txq_agg_disable(il, txq_id, ssn, tx_fifo); tid_data->agg.state = IL_AGG_OFF; ieee80211_stop_tx_ba_cb_irqsafe(ctx->vif, addr, tid); @@ -2434,8 +2439,7 @@ int il4965_txq_check_empty(struct il_priv *il, case IL_EMPTYING_HW_QUEUE_ADDBA: /* We are reclaiming the last packet of the queue */ if (tid_data->tfds_in_queue == 0) { - D_HT( - "HW queue empty: continue ADDBA flow\n"); + D_HT("HW queue empty: continue ADDBA flow\n"); tid_data->agg.state = IL_AGG_ON; ieee80211_start_tx_ba_cb_irqsafe(ctx->vif, addr, tid); } @@ -2445,9 +2449,9 @@ int il4965_txq_check_empty(struct il_priv *il, return 0; } -static void il4965_non_agg_tx_status(struct il_priv *il, - struct il_rxon_context *ctx, - const u8 *addr1) +static void +il4965_non_agg_tx_status(struct il_priv *il, struct il_rxon_context *ctx, + const u8 * addr1) { struct ieee80211_sta *sta; struct il_station_priv *sta_priv; @@ -2465,10 +2469,9 @@ static void il4965_non_agg_tx_status(struct il_priv *il, } static void -il4965_tx_status(struct il_priv *il, struct il_tx_info *tx_info, - bool is_agg) +il4965_tx_status(struct il_priv *il, struct il_tx_info *tx_info, bool is_agg) { - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx_info->skb->data; + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx_info->skb->data; if (!is_agg) il4965_non_agg_tx_status(il, tx_info->ctx, hdr->addr1); @@ -2476,7 +2479,8 @@ il4965_tx_status(struct il_priv *il, struct il_tx_info *tx_info, ieee80211_tx_status_irqsafe(il->hw, tx_info->skb); } -int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx) +int +il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx) { struct il_tx_queue *txq = &il->txq[txq_id]; struct il_queue *q = &txq->q; @@ -2486,13 +2490,12 @@ int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx) if (idx >= q->n_bd || il_queue_used(q, idx) == 0) { IL_ERR("Read idx for DMA queue txq id (%d), idx %d, " - "is out of range [0-%d] %d %d.\n", txq_id, - idx, q->n_bd, q->write_ptr, q->read_ptr); + "is out of range [0-%d] %d %d.\n", txq_id, idx, q->n_bd, + q->write_ptr, q->read_ptr); return 0; } - for (idx = il_queue_inc_wrap(idx, q->n_bd); - q->read_ptr != idx; + for (idx = il_queue_inc_wrap(idx, q->n_bd); q->read_ptr != idx; q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd)) { tx_info = &txq->txb[txq->q.read_ptr]; @@ -2519,10 +2522,9 @@ int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx) * Go through block-ack's bitmap of ACK'd frames, update driver's record of * ACK vs. not. This gets sent to mac80211, then to rate scaling algo. */ -static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, - struct il_ht_agg *agg, - struct il_compressed_ba_resp *ba_resp) - +static int +il4965_tx_status_reply_compressed_ba(struct il_priv *il, struct il_ht_agg *agg, + struct il_compressed_ba_resp *ba_resp) { int i, sh, ack; u16 seq_ctl = le16_to_cpu(ba_resp->seq_ctl); @@ -2531,7 +2533,7 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, struct ieee80211_tx_info *info; u64 bitmap, sent_bitmap; - if (unlikely(!agg->wait_for_ba)) { + if (unlikely(!agg->wait_for_ba)) { if (unlikely(ba_resp->bitmap)) IL_ERR("Received BA when not expected\n"); return -EINVAL; @@ -2539,12 +2541,11 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, /* Mark that the expected block-ack response arrived */ agg->wait_for_ba = 0; - D_TX_REPLY("BA %d %d\n", agg->start_idx, - ba_resp->seq_ctl); + D_TX_REPLY("BA %d %d\n", agg->start_idx, ba_resp->seq_ctl); /* Calculate shift to align block-ack bits with our Tx win bits */ sh = agg->start_idx - SEQ_TO_IDX(seq_ctl >> 4); - if (sh < 0) /* tbw something is wrong with indices */ + if (sh < 0) /* tbw something is wrong with indices */ sh += 0x100; if (agg->frame_count > (64 - sh)) { @@ -2565,16 +2566,13 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, while (sent_bitmap) { ack = sent_bitmap & 1ULL; successes += ack; - D_TX_REPLY("%s ON i=%d idx=%d raw=%d\n", - ack ? "ACK" : "NACK", i, - (agg->start_idx + i) & 0xff, - agg->start_idx + i); + D_TX_REPLY("%s ON i=%d idx=%d raw=%d\n", ack ? "ACK" : "NACK", + i, (agg->start_idx + i) & 0xff, agg->start_idx + i); sent_bitmap >>= 1; ++i; } - D_TX_REPLY("Bitmap %llx\n", - (unsigned long long)bitmap); + D_TX_REPLY("Bitmap %llx\n", (unsigned long long)bitmap); info = IEEE80211_SKB_CB(il->txq[scd_flow].txb[agg->start_idx].skb); memset(&info->status, 0, sizeof(info->status)); @@ -2590,13 +2588,14 @@ static int il4965_tx_status_reply_compressed_ba(struct il_priv *il, /** * translate ucode response to mac80211 tx status control values */ -void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, - struct ieee80211_tx_info *info) +void +il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, + struct ieee80211_tx_info *info) { struct ieee80211_tx_rate *r = &info->control.rates[0]; info->antenna_sel_tx = - ((rate_n_flags & RATE_MCS_ANT_ABC_MSK) >> RATE_MCS_ANT_POS); + ((rate_n_flags & RATE_MCS_ANT_ABC_MSK) >> RATE_MCS_ANT_POS); if (rate_n_flags & RATE_MCS_HT_MSK) r->flags |= IEEE80211_TX_RC_MCS; if (rate_n_flags & RATE_MCS_GF_MSK) @@ -2616,8 +2615,8 @@ void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, * Handles block-acknowledge notification from device, which reports success * of frames sent via aggregation. */ -void il4965_hdl_compressed_ba(struct il_priv *il, - struct il_rx_buf *rxb) +void +il4965_hdl_compressed_ba(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_compressed_ba_resp *ba_resp = &pkt->u.compressed_ba; @@ -2636,8 +2635,7 @@ void il4965_hdl_compressed_ba(struct il_priv *il, u16 ba_resp_scd_ssn = le16_to_cpu(ba_resp->scd_ssn); if (scd_flow >= il->hw_params.max_txq_num) { - IL_ERR( - "BUG_ON scd_flow is bigger than number of queues\n"); + IL_ERR("BUG_ON scd_flow is bigger than number of queues\n"); return; } @@ -2652,9 +2650,8 @@ void il4965_hdl_compressed_ba(struct il_priv *il, * since it is possible happen very often and in order * not to fill the syslog, don't enable the logging by default */ - D_TX_REPLY( - "BA scd_flow %d does not match txq_id %d\n", - scd_flow, agg->txq_id); + D_TX_REPLY("BA scd_flow %d does not match txq_id %d\n", + scd_flow, agg->txq_id); return; } @@ -2663,22 +2660,15 @@ void il4965_hdl_compressed_ba(struct il_priv *il, spin_lock_irqsave(&il->sta_lock, flags); - D_TX_REPLY("N_COMPRESSED_BA [%d] Received from %pM, " - "sta_id = %d\n", - agg->wait_for_ba, - (u8 *) &ba_resp->sta_addr_lo32, - ba_resp->sta_id); - D_TX_REPLY("TID = %d, SeqCtl = %d, bitmap = 0x%llx," - "scd_flow = " - "%d, scd_ssn = %d\n", - ba_resp->tid, - ba_resp->seq_ctl, - (unsigned long long)le64_to_cpu(ba_resp->bitmap), - ba_resp->scd_flow, - ba_resp->scd_ssn); - D_TX_REPLY("DAT start_idx = %d, bitmap = 0x%llx\n", - agg->start_idx, - (unsigned long long)agg->bitmap); + D_TX_REPLY("N_COMPRESSED_BA [%d] Received from %pM, " "sta_id = %d\n", + agg->wait_for_ba, (u8 *) & ba_resp->sta_addr_lo32, + ba_resp->sta_id); + D_TX_REPLY("TID = %d, SeqCtl = %d, bitmap = 0x%llx," "scd_flow = " + "%d, scd_ssn = %d\n", ba_resp->tid, ba_resp->seq_ctl, + (unsigned long long)le64_to_cpu(ba_resp->bitmap), + ba_resp->scd_flow, ba_resp->scd_ssn); + D_TX_REPLY("DAT start_idx = %d, bitmap = 0x%llx\n", agg->start_idx, + (unsigned long long)agg->bitmap); /* Update driver's record of ACK vs. not for each frame in win */ il4965_tx_status_reply_compressed_ba(il, agg, ba_resp); @@ -2703,7 +2693,8 @@ void il4965_hdl_compressed_ba(struct il_priv *il, } #ifdef CONFIG_IWLEGACY_DEBUG -const char *il4965_get_tx_fail_reason(u32 status) +const char * +il4965_get_tx_fail_reason(u32 status) { #define TX_STATUS_FAIL(x) case TX_STATUS_FAIL_ ## x: return #x #define TX_STATUS_POSTPONE(x) case TX_STATUS_POSTPONE_ ## x: return #x @@ -2711,27 +2702,27 @@ const char *il4965_get_tx_fail_reason(u32 status) switch (status & TX_STATUS_MSK) { case TX_STATUS_SUCCESS: return "SUCCESS"; - TX_STATUS_POSTPONE(DELAY); - TX_STATUS_POSTPONE(FEW_BYTES); - TX_STATUS_POSTPONE(QUIET_PERIOD); - TX_STATUS_POSTPONE(CALC_TTAK); - TX_STATUS_FAIL(INTERNAL_CROSSED_RETRY); - TX_STATUS_FAIL(SHORT_LIMIT); - TX_STATUS_FAIL(LONG_LIMIT); - TX_STATUS_FAIL(FIFO_UNDERRUN); - TX_STATUS_FAIL(DRAIN_FLOW); - TX_STATUS_FAIL(RFKILL_FLUSH); - TX_STATUS_FAIL(LIFE_EXPIRE); - TX_STATUS_FAIL(DEST_PS); - TX_STATUS_FAIL(HOST_ABORTED); - TX_STATUS_FAIL(BT_RETRY); - TX_STATUS_FAIL(STA_INVALID); - TX_STATUS_FAIL(FRAG_DROPPED); - TX_STATUS_FAIL(TID_DISABLE); - TX_STATUS_FAIL(FIFO_FLUSHED); - TX_STATUS_FAIL(INSUFFICIENT_CF_POLL); - TX_STATUS_FAIL(PASSIVE_NO_RX); - TX_STATUS_FAIL(NO_BEACON_ON_RADAR); + TX_STATUS_POSTPONE(DELAY); + TX_STATUS_POSTPONE(FEW_BYTES); + TX_STATUS_POSTPONE(QUIET_PERIOD); + TX_STATUS_POSTPONE(CALC_TTAK); + TX_STATUS_FAIL(INTERNAL_CROSSED_RETRY); + TX_STATUS_FAIL(SHORT_LIMIT); + TX_STATUS_FAIL(LONG_LIMIT); + TX_STATUS_FAIL(FIFO_UNDERRUN); + TX_STATUS_FAIL(DRAIN_FLOW); + TX_STATUS_FAIL(RFKILL_FLUSH); + TX_STATUS_FAIL(LIFE_EXPIRE); + TX_STATUS_FAIL(DEST_PS); + TX_STATUS_FAIL(HOST_ABORTED); + TX_STATUS_FAIL(BT_RETRY); + TX_STATUS_FAIL(STA_INVALID); + TX_STATUS_FAIL(FRAG_DROPPED); + TX_STATUS_FAIL(TID_DISABLE); + TX_STATUS_FAIL(FIFO_FLUSHED); + TX_STATUS_FAIL(INSUFFICIENT_CF_POLL); + TX_STATUS_FAIL(PASSIVE_NO_RX); + TX_STATUS_FAIL(NO_BEACON_ON_RADAR); } return "UNKNOWN"; @@ -2764,29 +2755,29 @@ il4965_sta_alloc_lq(struct il_priv *il, u8 sta_id) if (r >= IL_FIRST_CCK_RATE && r <= IL_LAST_CCK_RATE) rate_flags |= RATE_MCS_CCK_MSK; - rate_flags |= il4965_first_antenna(il->hw_params.valid_tx_ant) << - RATE_MCS_ANT_POS; - rate_n_flags = il4965_hw_set_rate_n_flags(il_rates[r].plcp, - rate_flags); + rate_flags |= + il4965_first_antenna(il->hw_params. + valid_tx_ant) << RATE_MCS_ANT_POS; + rate_n_flags = il4965_hw_set_rate_n_flags(il_rates[r].plcp, rate_flags); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) link_cmd->rs_table[i].rate_n_flags = rate_n_flags; link_cmd->general_params.single_stream_ant_msk = - il4965_first_antenna(il->hw_params.valid_tx_ant); + il4965_first_antenna(il->hw_params.valid_tx_ant); link_cmd->general_params.dual_stream_ant_msk = - il->hw_params.valid_tx_ant & - ~il4965_first_antenna(il->hw_params.valid_tx_ant); + il->hw_params.valid_tx_ant & ~il4965_first_antenna(il->hw_params. + valid_tx_ant); if (!link_cmd->general_params.dual_stream_ant_msk) { link_cmd->general_params.dual_stream_ant_msk = ANT_AB; } else if (il4965_num_of_ant(il->hw_params.valid_tx_ant) == 2) { link_cmd->general_params.dual_stream_ant_msk = - il->hw_params.valid_tx_ant; + il->hw_params.valid_tx_ant; } link_cmd->agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF; link_cmd->agg_params.agg_time_limit = - cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF); + cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF); link_cmd->sta_id = sta_id; @@ -2800,7 +2791,7 @@ il4965_sta_alloc_lq(struct il_priv *il, u8 sta_id) */ int il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, - const u8 *addr, u8 *sta_id_r) + const u8 * addr, u8 * sta_id_r) { int ret; u8 sta_id; @@ -2826,9 +2817,8 @@ il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, /* Set up default rate scaling table in device's station table */ link_cmd = il4965_sta_alloc_lq(il, sta_id); if (!link_cmd) { - IL_ERR( - "Unable to initialize rate scaling for station %pM.\n", - addr); + IL_ERR("Unable to initialize rate scaling for station %pM.\n", + addr); return -ENOMEM; } @@ -2843,15 +2833,15 @@ il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, return 0; } -static int il4965_static_wepkey_cmd(struct il_priv *il, - struct il_rxon_context *ctx, - bool send_if_empty) +static int +il4965_static_wepkey_cmd(struct il_priv *il, struct il_rxon_context *ctx, + bool send_if_empty) { int i, not_empty = 0; u8 buff[sizeof(struct il_wep_cmd) + sizeof(struct il_wep_key) * WEP_KEYS_MAX]; struct il_wep_cmd *wep_cmd = (struct il_wep_cmd *)buff; - size_t cmd_size = sizeof(struct il_wep_cmd); + size_t cmd_size = sizeof(struct il_wep_cmd); struct il_host_cmd cmd = { .id = ctx->wep_key_cmd, .data = wep_cmd, @@ -2860,10 +2850,10 @@ static int il4965_static_wepkey_cmd(struct il_priv *il, might_sleep(); - memset(wep_cmd, 0, cmd_size + - (sizeof(struct il_wep_key) * WEP_KEYS_MAX)); + memset(wep_cmd, 0, + cmd_size + (sizeof(struct il_wep_key) * WEP_KEYS_MAX)); - for (i = 0; i < WEP_KEYS_MAX ; i++) { + for (i = 0; i < WEP_KEYS_MAX; i++) { wep_cmd->key[i].key_idx = i; if (ctx->wep_keys[i].key_size) { wep_cmd->key[i].key_offset = i; @@ -2874,7 +2864,7 @@ static int il4965_static_wepkey_cmd(struct il_priv *il, wep_cmd->key[i].key_size = ctx->wep_keys[i].key_size; memcpy(&wep_cmd->key[i].key[3], ctx->wep_keys[i].key, - ctx->wep_keys[i].key_size); + ctx->wep_keys[i].key_size); } wep_cmd->global_key_type = WEP_KEY_WEP_TYPE; @@ -2890,42 +2880,39 @@ static int il4965_static_wepkey_cmd(struct il_priv *il, return 0; } -int il4965_restore_default_wep_keys(struct il_priv *il, - struct il_rxon_context *ctx) +int +il4965_restore_default_wep_keys(struct il_priv *il, struct il_rxon_context *ctx) { lockdep_assert_held(&il->mutex); return il4965_static_wepkey_cmd(il, ctx, false); } -int il4965_remove_default_wep_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf) +int +il4965_remove_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf) { int ret; lockdep_assert_held(&il->mutex); - D_WEP("Removing default WEP key: idx=%d\n", - keyconf->keyidx); + D_WEP("Removing default WEP key: idx=%d\n", keyconf->keyidx); memset(&ctx->wep_keys[keyconf->keyidx], 0, sizeof(ctx->wep_keys[0])); if (il_is_rfkill(il)) { - D_WEP( - "Not sending C_WEPKEY command due to RFKILL.\n"); + D_WEP("Not sending C_WEPKEY command due to RFKILL.\n"); /* but keys in device are clear anyway so return success */ return 0; } ret = il4965_static_wepkey_cmd(il, ctx, 1); - D_WEP("Remove default WEP key: idx=%d ret=%d\n", - keyconf->keyidx, ret); + D_WEP("Remove default WEP key: idx=%d ret=%d\n", keyconf->keyidx, ret); return ret; } -int il4965_set_default_wep_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf) +int +il4965_set_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf) { int ret; @@ -2943,19 +2930,18 @@ int il4965_set_default_wep_key(struct il_priv *il, ctx->wep_keys[keyconf->keyidx].key_size = keyconf->keylen; memcpy(&ctx->wep_keys[keyconf->keyidx].key, &keyconf->key, - keyconf->keylen); + keyconf->keylen); ret = il4965_static_wepkey_cmd(il, ctx, false); - D_WEP("Set default WEP key: len=%d idx=%d ret=%d\n", - keyconf->keylen, keyconf->keyidx, ret); + D_WEP("Set default WEP key: len=%d idx=%d ret=%d\n", keyconf->keylen, + keyconf->keyidx, ret); return ret; } -static int il4965_set_wep_dynamic_key_info(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, - u8 sta_id) +static int +il4965_set_wep_dynamic_key_info(struct il_priv *il, struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, u8 sta_id) { unsigned long flags; __le16 key_flags = 0; @@ -2981,37 +2967,36 @@ static int il4965_set_wep_dynamic_key_info(struct il_priv *il, il->stations[sta_id].keyinfo.keylen = keyconf->keylen; il->stations[sta_id].keyinfo.keyidx = keyconf->keyidx; - memcpy(il->stations[sta_id].keyinfo.key, - keyconf->key, keyconf->keylen); + memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, keyconf->keylen); - memcpy(&il->stations[sta_id].sta.key.key[3], - keyconf->key, keyconf->keylen); + memcpy(&il->stations[sta_id].sta.key.key[3], keyconf->key, + keyconf->keylen); - if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) - == STA_KEY_FLG_NO_ENC) + if ((il->stations[sta_id].sta.key. + key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) il->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_idx(il); + il_get_free_ucode_key_idx(il); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, - "no space for a new key"); + "no space for a new key"); il->stations[sta_id].sta.key.key_flags = key_flags; il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&il->sta_lock, flags); return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } -static int il4965_set_ccmp_dynamic_key_info(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, - u8 sta_id) +static int +il4965_set_ccmp_dynamic_key_info(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, u8 sta_id) { unsigned long flags; __le16 key_flags = 0; @@ -3032,37 +3017,35 @@ static int il4965_set_ccmp_dynamic_key_info(struct il_priv *il, il->stations[sta_id].keyinfo.cipher = keyconf->cipher; il->stations[sta_id].keyinfo.keylen = keyconf->keylen; - memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, - keyconf->keylen); + memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, keyconf->keylen); - memcpy(il->stations[sta_id].sta.key.key, keyconf->key, - keyconf->keylen); + memcpy(il->stations[sta_id].sta.key.key, keyconf->key, keyconf->keylen); - if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) - == STA_KEY_FLG_NO_ENC) + if ((il->stations[sta_id].sta.key. + key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) il->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_idx(il); + il_get_free_ucode_key_idx(il); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, - "no space for a new key"); + "no space for a new key"); il->stations[sta_id].sta.key.key_flags = key_flags; il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&il->sta_lock, flags); return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } -static int il4965_set_tkip_dynamic_key_info(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, - u8 sta_id) +static int +il4965_set_tkip_dynamic_key_info(struct il_priv *il, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, u8 sta_id) { unsigned long flags; int ret = 0; @@ -3083,19 +3066,18 @@ static int il4965_set_tkip_dynamic_key_info(struct il_priv *il, il->stations[sta_id].keyinfo.cipher = keyconf->cipher; il->stations[sta_id].keyinfo.keylen = 16; - if ((il->stations[sta_id].sta.key.key_flags & STA_KEY_FLG_ENCRYPT_MSK) - == STA_KEY_FLG_NO_ENC) + if ((il->stations[sta_id].sta.key. + key_flags & STA_KEY_FLG_ENCRYPT_MSK) == STA_KEY_FLG_NO_ENC) il->stations[sta_id].sta.key.key_offset = - il_get_free_ucode_key_idx(il); + il_get_free_ucode_key_idx(il); /* else, we are overriding an existing key => no need to allocated room * in uCode. */ WARN(il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET, - "no space for a new key"); + "no space for a new key"); il->stations[sta_id].sta.key.key_flags = key_flags; - /* This copy is acutally not needed: we get the key with each TX */ memcpy(il->stations[sta_id].keyinfo.key, keyconf->key, 16); @@ -3106,10 +3088,10 @@ static int il4965_set_tkip_dynamic_key_info(struct il_priv *il, return ret; } -void il4965_update_tkip_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, - struct ieee80211_sta *sta, u32 iv32, u16 *phase1key) +void +il4965_update_tkip_key(struct il_priv *il, struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, + struct ieee80211_sta *sta, u32 iv32, u16 * phase1key) { u8 sta_id; unsigned long flags; @@ -3131,7 +3113,7 @@ void il4965_update_tkip_key(struct il_priv *il, for (i = 0; i < 5; i++) il->stations[sta_id].sta.key.tkip_rx_ttak[i] = - cpu_to_le16(phase1key[i]); + cpu_to_le16(phase1key[i]); il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; @@ -3142,10 +3124,9 @@ void il4965_update_tkip_key(struct il_priv *il, } -int il4965_remove_dynamic_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, - u8 sta_id) +int +il4965_remove_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, u8 sta_id) { unsigned long flags; u16 key_flags; @@ -3160,8 +3141,7 @@ int il4965_remove_dynamic_key(struct il_priv *il, key_flags = le16_to_cpu(il->stations[sta_id].sta.key.key_flags); keyidx = (key_flags >> STA_KEY_FLG_KEYID_POS) & 0x3; - D_WEP("Remove dynamic key: idx=%d sta=%d\n", - keyconf->keyidx, sta_id); + D_WEP("Remove dynamic key: idx=%d sta=%d\n", keyconf->keyidx, sta_id); if (keyconf->keyidx != keyidx) { /* We need to remove a key with idx different that the one @@ -3174,41 +3154,40 @@ int il4965_remove_dynamic_key(struct il_priv *il, } if (il->stations[sta_id].sta.key.key_offset == WEP_INVALID_OFFSET) { - IL_WARN("Removing wrong key %d 0x%x\n", - keyconf->keyidx, key_flags); + IL_WARN("Removing wrong key %d 0x%x\n", keyconf->keyidx, + key_flags); spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } - if (!test_and_clear_bit(il->stations[sta_id].sta.key.key_offset, - &il->ucode_key_table)) + if (!test_and_clear_bit + (il->stations[sta_id].sta.key.key_offset, &il->ucode_key_table)) IL_ERR("idx %d not used in uCode key table.\n", - il->stations[sta_id].sta.key.key_offset); - memset(&il->stations[sta_id].keyinfo, 0, - sizeof(struct il_hw_key)); - memset(&il->stations[sta_id].sta.key, 0, - sizeof(struct il4965_keyinfo)); + il->stations[sta_id].sta.key.key_offset); + memset(&il->stations[sta_id].keyinfo, 0, sizeof(struct il_hw_key)); + memset(&il->stations[sta_id].sta.key, 0, sizeof(struct il4965_keyinfo)); il->stations[sta_id].sta.key.key_flags = - STA_KEY_FLG_NO_ENC | STA_KEY_FLG_INVALID; + STA_KEY_FLG_NO_ENC | STA_KEY_FLG_INVALID; il->stations[sta_id].sta.key.key_offset = WEP_INVALID_OFFSET; il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; if (il_is_rfkill(il)) { - D_WEP( - "Not sending C_ADD_STA command because RFKILL enabled.\n"); + D_WEP + ("Not sending C_ADD_STA command because RFKILL enabled.\n"); spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&il->sta_lock, flags); return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } -int il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, u8 sta_id) +int +il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, u8 sta_id) { int ret; @@ -3219,29 +3198,25 @@ int il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, switch (keyconf->cipher) { case WLAN_CIPHER_SUITE_CCMP: - ret = il4965_set_ccmp_dynamic_key_info(il, ctx, - keyconf, sta_id); + ret = + il4965_set_ccmp_dynamic_key_info(il, ctx, keyconf, sta_id); break; case WLAN_CIPHER_SUITE_TKIP: - ret = il4965_set_tkip_dynamic_key_info(il, ctx, - keyconf, sta_id); + ret = + il4965_set_tkip_dynamic_key_info(il, ctx, keyconf, sta_id); break; case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP104: - ret = il4965_set_wep_dynamic_key_info(il, ctx, - keyconf, sta_id); + ret = il4965_set_wep_dynamic_key_info(il, ctx, keyconf, sta_id); break; default: - IL_ERR( - "Unknown alg: %s cipher = %x\n", __func__, - keyconf->cipher); + IL_ERR("Unknown alg: %s cipher = %x\n", __func__, + keyconf->cipher); ret = -EINVAL; } - D_WEP( - "Set dynamic key: cipher=%x len=%d idx=%d sta=%d ret=%d\n", - keyconf->cipher, keyconf->keylen, keyconf->keyidx, - sta_id, ret); + D_WEP("Set dynamic key: cipher=%x len=%d idx=%d sta=%d ret=%d\n", + keyconf->cipher, keyconf->keylen, keyconf->keyidx, sta_id, ret); return ret; } @@ -3253,16 +3228,15 @@ int il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, * and marks it driver active, so that it will be restored to the * device at the next best time. */ -int il4965_alloc_bcast_station(struct il_priv *il, - struct il_rxon_context *ctx) +int +il4965_alloc_bcast_station(struct il_priv *il, struct il_rxon_context *ctx) { struct il_link_quality_cmd *link_cmd; unsigned long flags; u8 sta_id; spin_lock_irqsave(&il->sta_lock, flags); - sta_id = il_prep_station(il, ctx, il_bcast_addr, - false, NULL); + sta_id = il_prep_station(il, ctx, il_bcast_addr, false, NULL); if (sta_id == IL_INVALID_STATION) { IL_ERR("Unable to prepare broadcast station\n"); spin_unlock_irqrestore(&il->sta_lock, flags); @@ -3276,8 +3250,8 @@ int il4965_alloc_bcast_station(struct il_priv *il, link_cmd = il4965_sta_alloc_lq(il, sta_id); if (!link_cmd) { - IL_ERR( - "Unable to initialize rate scaling for bcast station.\n"); + IL_ERR + ("Unable to initialize rate scaling for bcast station.\n"); return -ENOMEM; } @@ -3294,8 +3268,8 @@ int il4965_alloc_bcast_station(struct il_priv *il, * Only used by iwl4965. Placed here to have all bcast station management * code together. */ -static int il4965_update_bcast_station(struct il_priv *il, - struct il_rxon_context *ctx) +static int +il4965_update_bcast_station(struct il_priv *il, struct il_rxon_context *ctx) { unsigned long flags; struct il_link_quality_cmd *link_cmd; @@ -3303,8 +3277,8 @@ static int il4965_update_bcast_station(struct il_priv *il, link_cmd = il4965_sta_alloc_lq(il, sta_id); if (!link_cmd) { - IL_ERR( - "Unable to initialize rate scaling for bcast station.\n"); + IL_ERR + ("Unable to initialize rate scaling for bcast station.\n"); return -ENOMEM; } @@ -3312,15 +3286,16 @@ static int il4965_update_bcast_station(struct il_priv *il, if (il->stations[sta_id].lq) kfree(il->stations[sta_id].lq); else - D_INFO( - "Bcast station rate scaling has not been initialized yet.\n"); + D_INFO + ("Bcast station rate scaling has not been initialized yet.\n"); il->stations[sta_id].lq = link_cmd; spin_unlock_irqrestore(&il->sta_lock, flags); return 0; } -int il4965_update_bcast_stations(struct il_priv *il) +int +il4965_update_bcast_stations(struct il_priv *il) { return il4965_update_bcast_station(il, &il->ctx); } @@ -3328,7 +3303,8 @@ int il4965_update_bcast_stations(struct il_priv *il) /** * il4965_sta_tx_modify_enable_tid - Enable Tx for this TID in station table */ -int il4965_sta_tx_modify_enable_tid(struct il_priv *il, int sta_id, int tid) +int +il4965_sta_tx_modify_enable_tid(struct il_priv *il, int sta_id, int tid) { unsigned long flags; struct il_addsta_cmd sta_cmd; @@ -3341,14 +3317,15 @@ int il4965_sta_tx_modify_enable_tid(struct il_priv *il, int sta_id, int tid) il->stations[sta_id].sta.tid_disable_tx &= cpu_to_le16(~(1 << tid)); il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&il->sta_lock, flags); return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } -int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta, - int tid, u16 ssn) +int +il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta, int tid, + u16 ssn) { unsigned long flags; int sta_id; @@ -3363,18 +3340,18 @@ int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta, spin_lock_irqsave(&il->sta_lock, flags); il->stations[sta_id].sta.station_flags_msk = 0; il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_ADDBA_TID_MSK; - il->stations[sta_id].sta.add_immediate_ba_tid = (u8)tid; + il->stations[sta_id].sta.add_immediate_ba_tid = (u8) tid; il->stations[sta_id].sta.add_immediate_ba_ssn = cpu_to_le16(ssn); il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&il->sta_lock, flags); return il_send_add_sta(il, &sta_cmd, CMD_SYNC); } -int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta, - int tid) +int +il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta, int tid) { unsigned long flags; int sta_id; @@ -3391,10 +3368,10 @@ int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta, spin_lock_irqsave(&il->sta_lock, flags); il->stations[sta_id].sta.station_flags_msk = 0; il->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_DELBA_TID_MSK; - il->stations[sta_id].sta.remove_immediate_ba_tid = (u8)tid; + il->stations[sta_id].sta.remove_immediate_ba_tid = (u8) tid; il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&il->sta_lock, flags); return il_send_add_sta(il, &sta_cmd, CMD_SYNC); @@ -3409,16 +3386,16 @@ il4965_sta_modify_sleep_tx_count(struct il_priv *il, int sta_id, int cnt) il->stations[sta_id].sta.station_flags |= STA_FLG_PWR_SAVE_MSK; il->stations[sta_id].sta.station_flags_msk = STA_FLG_PWR_SAVE_MSK; il->stations[sta_id].sta.sta.modify_mask = - STA_MODIFY_SLEEP_TX_COUNT_MSK; + STA_MODIFY_SLEEP_TX_COUNT_MSK; il->stations[sta_id].sta.sleep_tx_count = cpu_to_le16(cnt); il->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; - il_send_add_sta(il, - &il->stations[sta_id].sta, CMD_ASYNC); + il_send_add_sta(il, &il->stations[sta_id].sta, CMD_ASYNC); spin_unlock_irqrestore(&il->sta_lock, flags); } -void il4965_update_chain_flags(struct il_priv *il) +void +il4965_update_chain_flags(struct il_priv *il) { if (il->cfg->ops->hcmd->set_rxon_chain) { il->cfg->ops->hcmd->set_rxon_chain(il, &il->ctx); @@ -3427,12 +3404,12 @@ void il4965_update_chain_flags(struct il_priv *il) } } -static void il4965_clear_free_frames(struct il_priv *il) +static void +il4965_clear_free_frames(struct il_priv *il) { struct list_head *element; - D_INFO("%d frames on pre-allocated heap on clear.\n", - il->frames_count); + D_INFO("%d frames on pre-allocated heap on clear.\n", il->frames_count); while (!list_empty(&il->free_frames)) { element = il->free_frames.next; @@ -3443,12 +3420,13 @@ static void il4965_clear_free_frames(struct il_priv *il) if (il->frames_count) { IL_WARN("%d frames still in use. Did we lose one?\n", - il->frames_count); + il->frames_count); il->frames_count = 0; } } -static struct il_frame *il4965_get_free_frame(struct il_priv *il) +static struct il_frame * +il4965_get_free_frame(struct il_priv *il) { struct il_frame *frame; struct list_head *element; @@ -3468,15 +3446,16 @@ static struct il_frame *il4965_get_free_frame(struct il_priv *il) return list_entry(element, struct il_frame, list); } -static void il4965_free_frame(struct il_priv *il, struct il_frame *frame) +static void +il4965_free_frame(struct il_priv *il, struct il_frame *frame) { memset(frame, 0, sizeof(*frame)); list_add(&frame->list, &il->free_frames); } -static u32 il4965_fill_beacon_frame(struct il_priv *il, - struct ieee80211_hdr *hdr, - int left) +static u32 +il4965_fill_beacon_frame(struct il_priv *il, struct ieee80211_hdr *hdr, + int left) { lockdep_assert_held(&il->mutex); @@ -3492,9 +3471,10 @@ static u32 il4965_fill_beacon_frame(struct il_priv *il, } /* Parse the beacon frame to find the TIM element and set tim_idx & tim_size */ -static void il4965_set_beacon_tim(struct il_priv *il, - struct il_tx_beacon_cmd *tx_beacon_cmd, - u8 *beacon, u32 frame_size) +static void +il4965_set_beacon_tim(struct il_priv *il, + struct il_tx_beacon_cmd *tx_beacon_cmd, u8 * beacon, + u32 frame_size) { u16 tim_idx; struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)beacon; @@ -3507,19 +3487,19 @@ static void il4965_set_beacon_tim(struct il_priv *il, /* Parse variable-length elements of beacon to find WLAN_EID_TIM */ while ((tim_idx < (frame_size - 2)) && - (beacon[tim_idx] != WLAN_EID_TIM)) - tim_idx += beacon[tim_idx+1] + 2; + (beacon[tim_idx] != WLAN_EID_TIM)) + tim_idx += beacon[tim_idx + 1] + 2; /* If TIM field was found, set variables */ if ((tim_idx < (frame_size - 1)) && (beacon[tim_idx] == WLAN_EID_TIM)) { tx_beacon_cmd->tim_idx = cpu_to_le16(tim_idx); - tx_beacon_cmd->tim_size = beacon[tim_idx+1]; + tx_beacon_cmd->tim_size = beacon[tim_idx + 1]; } else IL_WARN("Unable to find TIM Element in beacon\n"); } -static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *il, - struct il_frame *frame) +static unsigned int +il4965_hw_get_beacon_cmd(struct il_priv *il, struct il_frame *frame) { struct il_tx_beacon_cmd *tx_beacon_cmd; u32 frame_size; @@ -3542,38 +3522,42 @@ static unsigned int il4965_hw_get_beacon_cmd(struct il_priv *il, memset(tx_beacon_cmd, 0, sizeof(*tx_beacon_cmd)); /* Set up TX beacon contents */ - frame_size = il4965_fill_beacon_frame(il, tx_beacon_cmd->frame, - sizeof(frame->u) - sizeof(*tx_beacon_cmd)); + frame_size = + il4965_fill_beacon_frame(il, tx_beacon_cmd->frame, + sizeof(frame->u) - sizeof(*tx_beacon_cmd)); if (WARN_ON_ONCE(frame_size > MAX_MPDU_SIZE)) return 0; if (!frame_size) return 0; /* Set up TX command fields */ - tx_beacon_cmd->tx.len = cpu_to_le16((u16)frame_size); + tx_beacon_cmd->tx.len = cpu_to_le16((u16) frame_size); tx_beacon_cmd->tx.sta_id = il->beacon_ctx->bcast_sta_id; tx_beacon_cmd->tx.stop_time.life_time = TX_CMD_LIFE_TIME_INFINITE; - tx_beacon_cmd->tx.tx_flags = TX_CMD_FLG_SEQ_CTL_MSK | - TX_CMD_FLG_TSF_MSK | TX_CMD_FLG_STA_RATE_MSK; + tx_beacon_cmd->tx.tx_flags = + TX_CMD_FLG_SEQ_CTL_MSK | TX_CMD_FLG_TSF_MSK | + TX_CMD_FLG_STA_RATE_MSK; /* Set up TX beacon command fields */ - il4965_set_beacon_tim(il, tx_beacon_cmd, (u8 *)tx_beacon_cmd->frame, - frame_size); + il4965_set_beacon_tim(il, tx_beacon_cmd, (u8 *) tx_beacon_cmd->frame, + frame_size); /* Set up packet rate and flags */ rate = il_get_lowest_plcp(il, il->beacon_ctx); - il->mgmt_tx_ant = il4965_toggle_tx_ant(il, il->mgmt_tx_ant, - il->hw_params.valid_tx_ant); + il->mgmt_tx_ant = + il4965_toggle_tx_ant(il, il->mgmt_tx_ant, + il->hw_params.valid_tx_ant); rate_flags = il4965_ant_idx_to_flags(il->mgmt_tx_ant); if ((rate >= IL_FIRST_CCK_RATE) && (rate <= IL_LAST_CCK_RATE)) rate_flags |= RATE_MCS_CCK_MSK; - tx_beacon_cmd->tx.rate_n_flags = il4965_hw_set_rate_n_flags(rate, - rate_flags); + tx_beacon_cmd->tx.rate_n_flags = + il4965_hw_set_rate_n_flags(rate, rate_flags); return sizeof(*tx_beacon_cmd) + frame_size; } -int il4965_send_beacon_cmd(struct il_priv *il) +int +il4965_send_beacon_cmd(struct il_priv *il) { struct il_frame *frame; unsigned int frame_size; @@ -3582,7 +3566,7 @@ int il4965_send_beacon_cmd(struct il_priv *il) frame = il4965_get_free_frame(il); if (!frame) { IL_ERR("Could not obtain free frame buffer for beacon " - "command.\n"); + "command.\n"); return -ENOMEM; } @@ -3593,35 +3577,37 @@ int il4965_send_beacon_cmd(struct il_priv *il) return -EINVAL; } - rc = il_send_cmd_pdu(il, C_TX_BEACON, frame_size, - &frame->u.cmd[0]); + rc = il_send_cmd_pdu(il, C_TX_BEACON, frame_size, &frame->u.cmd[0]); il4965_free_frame(il, frame); return rc; } -static inline dma_addr_t il4965_tfd_tb_get_addr(struct il_tfd *tfd, u8 idx) +static inline dma_addr_t +il4965_tfd_tb_get_addr(struct il_tfd *tfd, u8 idx) { struct il_tfd_tb *tb = &tfd->tbs[idx]; dma_addr_t addr = get_unaligned_le32(&tb->lo); if (sizeof(dma_addr_t) > sizeof(u32)) addr |= - ((dma_addr_t)(le16_to_cpu(tb->hi_n_len) & 0xF) << 16) << 16; + ((dma_addr_t) (le16_to_cpu(tb->hi_n_len) & 0xF) << 16) << + 16; return addr; } -static inline u16 il4965_tfd_tb_get_len(struct il_tfd *tfd, u8 idx) +static inline u16 +il4965_tfd_tb_get_len(struct il_tfd *tfd, u8 idx) { struct il_tfd_tb *tb = &tfd->tbs[idx]; return le16_to_cpu(tb->hi_n_len) >> 4; } -static inline void il4965_tfd_set_tb(struct il_tfd *tfd, u8 idx, - dma_addr_t addr, u16 len) +static inline void +il4965_tfd_set_tb(struct il_tfd *tfd, u8 idx, dma_addr_t addr, u16 len) { struct il_tfd_tb *tb = &tfd->tbs[idx]; u16 hi_n_len = len << 4; @@ -3635,7 +3621,8 @@ static inline void il4965_tfd_set_tb(struct il_tfd *tfd, u8 idx, tfd->num_tbs = idx + 1; } -static inline u8 il4965_tfd_get_num_tbs(struct il_tfd *tfd) +static inline u8 +il4965_tfd_get_num_tbs(struct il_tfd *tfd) { return tfd->num_tbs & 0x1f; } @@ -3648,7 +3635,8 @@ static inline u8 il4965_tfd_get_num_tbs(struct il_tfd *tfd) * Does NOT advance any TFD circular buffer read/write idxes * Does NOT free the TFD itself (which is within circular buffer) */ -void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) +void +il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) { struct il_tfd *tfd_tmp = (struct il_tfd *)txq->tfds; struct il_tfd *tfd; @@ -3670,16 +3658,15 @@ void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) /* Unmap tx_cmd */ if (num_tbs) - pci_unmap_single(dev, - dma_unmap_addr(&txq->meta[idx], mapping), - dma_unmap_len(&txq->meta[idx], len), - PCI_DMA_BIDIRECTIONAL); + pci_unmap_single(dev, dma_unmap_addr(&txq->meta[idx], mapping), + dma_unmap_len(&txq->meta[idx], len), + PCI_DMA_BIDIRECTIONAL); /* Unmap chunks, if any. */ for (i = 1; i < num_tbs; i++) pci_unmap_single(dev, il4965_tfd_tb_get_addr(tfd, i), - il4965_tfd_tb_get_len(tfd, i), - PCI_DMA_TODEVICE); + il4965_tfd_tb_get_len(tfd, i), + PCI_DMA_TODEVICE); /* free SKB */ if (txq->txb) { @@ -3695,10 +3682,9 @@ void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq) } } -int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, - struct il_tx_queue *txq, - dma_addr_t addr, u16 len, - u8 reset, u8 pad) +int +il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, struct il_tx_queue *txq, + dma_addr_t addr, u16 len, u8 reset, u8 pad) { struct il_queue *q; struct il_tfd *tfd, *tfd_tmp; @@ -3716,14 +3702,13 @@ int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, /* Each TFD can point to a maximum 20 Tx buffers */ if (num_tbs >= IL_NUM_OF_TBS) { IL_ERR("Error can not send more than %d chunks\n", - IL_NUM_OF_TBS); + IL_NUM_OF_TBS); return -EINVAL; } BUG_ON(addr & ~DMA_BIT_MASK(36)); if (unlikely(addr & ~IL_TX_DMA_MASK)) - IL_ERR("Unaligned address = %llx\n", - (unsigned long long)addr); + IL_ERR("Unaligned address = %llx\n", (unsigned long long)addr); il4965_tfd_set_tb(tfd, num_tbs, addr, len); @@ -3737,14 +3722,13 @@ int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, * 4965 supports up to 16 Tx queues in DRAM, mapped to up to 8 Tx DMA * channels supported in hardware. */ -int il4965_hw_tx_queue_init(struct il_priv *il, - struct il_tx_queue *txq) +int +il4965_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq) { int txq_id = txq->q.id; /* Circular buffer (TFD queue in DRAM) physical base address */ - il_wr(il, FH49_MEM_CBBC_QUEUE(txq_id), - txq->q.dma_addr >> 8); + il_wr(il, FH49_MEM_CBBC_QUEUE(txq_id), txq->q.dma_addr >> 8); return 0; } @@ -3754,8 +3738,8 @@ int il4965_hw_tx_queue_init(struct il_priv *il, * Generic RX handler implementations * ******************************************************************************/ -static void il4965_hdl_alive(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il4965_hdl_alive(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_alive_resp *palive; @@ -3763,15 +3747,12 @@ static void il4965_hdl_alive(struct il_priv *il, palive = &pkt->u.alive_frame; - D_INFO("Alive ucode status 0x%08X revision " - "0x%01X 0x%01X\n", - palive->is_valid, palive->ver_type, - palive->ver_subtype); + D_INFO("Alive ucode status 0x%08X revision " "0x%01X 0x%01X\n", + palive->is_valid, palive->ver_type, palive->ver_subtype); if (palive->ver_subtype == INITIALIZE_SUBTYPE) { D_INFO("Initialization Alive received.\n"); - memcpy(&il->card_alive_init, - &pkt->u.alive_frame, + memcpy(&il->card_alive_init, &pkt->u.alive_frame, sizeof(struct il_init_alive_resp)); pwork = &il->init_alive_start; } else { @@ -3784,8 +3765,7 @@ static void il4965_hdl_alive(struct il_priv *il, /* We delay the ALIVE response by 5ms to * give the HW RF Kill time to activate... */ if (palive->is_valid == UCODE_VALID_OK) - queue_delayed_work(il->workqueue, pwork, - msecs_to_jiffies(5)); + queue_delayed_work(il->workqueue, pwork, msecs_to_jiffies(5)); else IL_WARN("uCode did not respond OK.\n"); } @@ -3800,7 +3780,8 @@ static void il4965_hdl_alive(struct il_priv *il, * was received. We need to ensure we receive the stats in order * to update the temperature used for calibrating the TXPOWER. */ -static void il4965_bg_stats_periodic(unsigned long data) +static void +il4965_bg_stats_periodic(unsigned long data) { struct il_priv *il = (struct il_priv *)data; @@ -3814,28 +3795,27 @@ static void il4965_bg_stats_periodic(unsigned long data) il_send_stats_request(il, CMD_ASYNC, false); } -static void il4965_hdl_beacon(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il4965_hdl_beacon(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il4965_beacon_notif *beacon = - (struct il4965_beacon_notif *)pkt->u.raw; + (struct il4965_beacon_notif *)pkt->u.raw; #ifdef CONFIG_IWLEGACY_DEBUG u8 rate = il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); - D_RX("beacon status %x retries %d iss %d " - "tsf %d %d rate %d\n", - le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, - beacon->beacon_notify_hdr.failure_frame, - le32_to_cpu(beacon->ibss_mgr_status), - le32_to_cpu(beacon->high_tsf), - le32_to_cpu(beacon->low_tsf), rate); + D_RX("beacon status %x retries %d iss %d " "tsf %d %d rate %d\n", + le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, + beacon->beacon_notify_hdr.failure_frame, + le32_to_cpu(beacon->ibss_mgr_status), + le32_to_cpu(beacon->high_tsf), le32_to_cpu(beacon->low_tsf), rate); #endif il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); } -static void il4965_perform_ct_kill_task(struct il_priv *il) +static void +il4965_perform_ct_kill_task(struct il_priv *il) { unsigned long flags; @@ -3845,7 +3825,7 @@ static void il4965_perform_ct_kill_task(struct il_priv *il) ieee80211_stop_queues(il->hw); _il_wr(il, CSR_UCODE_DRV_GP1_SET, - CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); + CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); _il_rd(il, CSR_UCODE_DRV_GP1); spin_lock_irqsave(&il->reg_lock, flags); @@ -3856,33 +3836,30 @@ static void il4965_perform_ct_kill_task(struct il_priv *il) /* Handle notification from uCode that card's power state is changing * due to software, hardware, or critical temperature RFKILL */ -static void il4965_hdl_card_state(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il4965_hdl_card_state(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); u32 flags = le32_to_cpu(pkt->u.card_state_notif.flags); unsigned long status = il->status; D_RF_KILL("Card state received: HW:%s SW:%s CT:%s\n", - (flags & HW_CARD_DISABLED) ? "Kill" : "On", - (flags & SW_CARD_DISABLED) ? "Kill" : "On", - (flags & CT_CARD_DISABLED) ? - "Reached" : "Not reached"); + (flags & HW_CARD_DISABLED) ? "Kill" : "On", + (flags & SW_CARD_DISABLED) ? "Kill" : "On", + (flags & CT_CARD_DISABLED) ? "Reached" : "Not reached"); - if (flags & (SW_CARD_DISABLED | HW_CARD_DISABLED | - CT_CARD_DISABLED)) { + if (flags & (SW_CARD_DISABLED | HW_CARD_DISABLED | CT_CARD_DISABLED)) { _il_wr(il, CSR_UCODE_DRV_GP1_SET, - CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); + CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); - il_wr(il, HBUS_TARG_MBX_C, - HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); + il_wr(il, HBUS_TARG_MBX_C, HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); if (!(flags & RXON_CARD_DISABLED)) { _il_wr(il, CSR_UCODE_DRV_GP1_CLR, - CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); + CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); il_wr(il, HBUS_TARG_MBX_C, - HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); + HBUS_TARG_MBX_C_REG_BIT_CMD_BLOCKED); } } @@ -3900,7 +3877,7 @@ static void il4965_hdl_card_state(struct il_priv *il, if ((test_bit(S_RF_KILL_HW, &status) != test_bit(S_RF_KILL_HW, &il->status))) wiphy_rfkill_set_hw_state(il->hw->wiphy, - test_bit(S_RF_KILL_HW, &il->status)); + test_bit(S_RF_KILL_HW, &il->status)); else wake_up(&il->wait_command_queue); } @@ -3914,16 +3891,15 @@ static void il4965_hdl_card_state(struct il_priv *il, * This function chains into the hardware specific files for them to setup * any hardware specific handlers as well. */ -static void il4965_setup_handlers(struct il_priv *il) +static void +il4965_setup_handlers(struct il_priv *il) { il->handlers[N_ALIVE] = il4965_hdl_alive; il->handlers[N_ERROR] = il_hdl_error; il->handlers[N_CHANNEL_SWITCH] = il_hdl_csa; - il->handlers[N_SPECTRUM_MEASUREMENT] = - il_hdl_spectrum_measurement; + il->handlers[N_SPECTRUM_MEASUREMENT] = il_hdl_spectrum_measurement; il->handlers[N_PM_SLEEP] = il_hdl_pm_sleep; - il->handlers[N_PM_DEBUG_STATS] = - il_hdl_pm_debug_stats; + il->handlers[N_PM_DEBUG_STATS] = il_hdl_pm_debug_stats; il->handlers[N_BEACON] = il4965_hdl_beacon; /* @@ -3937,11 +3913,9 @@ static void il4965_setup_handlers(struct il_priv *il) il_setup_rx_scan_handlers(il); /* status change handler */ - il->handlers[N_CARD_STATE] = - il4965_hdl_card_state; + il->handlers[N_CARD_STATE] = il4965_hdl_card_state; - il->handlers[N_MISSED_BEACONS] = - il4965_hdl_missed_beacon; + il->handlers[N_MISSED_BEACONS] = il4965_hdl_missed_beacon; /* Rx handlers */ il->handlers[N_RX_PHY] = il4965_hdl_rx_phy; il->handlers[N_RX_MPDU] = il4965_hdl_rx; @@ -3958,7 +3932,8 @@ static void il4965_setup_handlers(struct il_priv *il) * the appropriate handlers, including command responses, * frame-received notifications, and other notifications. */ -void il4965_rx_handle(struct il_priv *il) +void +il4965_rx_handle(struct il_priv *il) { struct il_rx_buf *rxb; struct il_rx_pkt *pkt; @@ -3972,7 +3947,7 @@ void il4965_rx_handle(struct il_priv *il) /* uCode's read idx (stored in shared DRAM) indicates the last Rx * buffer that the driver may process (last buffer filled by ucode). */ - r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF; + r = le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF; i = rxq->read; /* Rx interrupt, but nothing sent from uCode */ @@ -4005,7 +3980,7 @@ void il4965_rx_handle(struct il_priv *il) pkt = rxb_addr(rxb); len = le32_to_cpu(pkt->len_n_flags) & IL_RX_FRAME_SIZE_MSK; - len += sizeof(u32); /* account for status word */ + len += sizeof(u32); /* account for status word */ /* Reclaim a command buffer only if this packet is a response * to a (driver-originated) command. @@ -4014,28 +3989,23 @@ void il4965_rx_handle(struct il_priv *il) * Ucode should set SEQ_RX_FRAME bit if ucode-originated, * but apparently a few don't get set; catch them here. */ reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) && - (pkt->hdr.cmd != N_RX_PHY) && - (pkt->hdr.cmd != N_RX) && - (pkt->hdr.cmd != N_RX_MPDU) && - (pkt->hdr.cmd != N_COMPRESSED_BA) && - (pkt->hdr.cmd != N_STATS) && - (pkt->hdr.cmd != C_TX); + (pkt->hdr.cmd != N_RX_PHY) && (pkt->hdr.cmd != N_RX) && + (pkt->hdr.cmd != N_RX_MPDU) && + (pkt->hdr.cmd != N_COMPRESSED_BA) && + (pkt->hdr.cmd != N_STATS) && (pkt->hdr.cmd != C_TX); /* Based on type of command response or notification, * handle those that need handling via function in * handlers table. See il4965_setup_handlers() */ if (il->handlers[pkt->hdr.cmd]) { - D_RX("r = %d, i = %d, %s, 0x%02x\n", r, - i, il_get_cmd_string(pkt->hdr.cmd), - pkt->hdr.cmd); + D_RX("r = %d, i = %d, %s, 0x%02x\n", r, i, + il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); il->isr_stats.handlers[pkt->hdr.cmd]++; il->handlers[pkt->hdr.cmd] (il, rxb); } else { /* No handling needed */ - D_RX( - "r %d i %d No handler needed for %s, 0x%02x\n", - r, i, il_get_cmd_string(pkt->hdr.cmd), - pkt->hdr.cmd); + D_RX("r %d i %d No handler needed for %s, 0x%02x\n", r, + i, il_get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd); } /* @@ -4060,9 +4030,10 @@ void il4965_rx_handle(struct il_priv *il) * rx_free list for reuse later. */ spin_lock_irqsave(&rxq->lock, flags); if (rxb->page != NULL) { - rxb->page_dma = pci_map_page(il->pci_dev, rxb->page, - 0, PAGE_SIZE << il->hw_params.rx_page_order, - PCI_DMA_FROMDEVICE); + rxb->page_dma = + pci_map_page(il->pci_dev, rxb->page, 0, + PAGE_SIZE << il->hw_params. + rx_page_order, PCI_DMA_FROMDEVICE); list_add_tail(&rxb->list, &rxq->rx_free); rxq->free_count++; } else @@ -4092,14 +4063,16 @@ void il4965_rx_handle(struct il_priv *il) } /* call this function to flush any scheduled tasklet */ -static inline void il4965_synchronize_irq(struct il_priv *il) +static inline void +il4965_synchronize_irq(struct il_priv *il) { - /* wait to make sure we flush pending tasklet*/ + /* wait to make sure we flush pending tasklet */ synchronize_irq(il->pci_dev->irq); tasklet_kill(&il->irq_tasklet); } -static void il4965_irq_tasklet(struct il_priv *il) +static void +il4965_irq_tasklet(struct il_priv *il) { u32 inta, handled = 0; u32 inta_fh; @@ -4127,8 +4100,8 @@ static void il4965_irq_tasklet(struct il_priv *il) if (il_get_debug_level(il) & IL_DL_ISR) { /* just for debug */ inta_mask = _il_rd(il, CSR_INT_MASK); - D_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", - inta, inta_mask, inta_fh); + D_ISR("inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, + inta_mask, inta_fh); } #endif @@ -4157,13 +4130,12 @@ static void il4965_irq_tasklet(struct il_priv *il) return; } - #ifdef CONFIG_IWLEGACY_DEBUG if (il_get_debug_level(il) & (IL_DL_ISR)) { /* NIC fires this, but we don't use it, redundant with WAKEUP */ if (inta & CSR_INT_BIT_SCD) { D_ISR("Scheduler finished to transmit " - "the frame/frames.\n"); + "the frame/frames.\n"); il->isr_stats.sch++; } @@ -4180,12 +4152,13 @@ static void il4965_irq_tasklet(struct il_priv *il) /* HW RF KILL switch toggled */ if (inta & CSR_INT_BIT_RF_KILL) { int hw_rf_kill = 0; - if (!(_il_rd(il, CSR_GP_CNTRL) & - CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) + if (! + (_il_rd(il, CSR_GP_CNTRL) & + CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) hw_rf_kill = 1; IL_WARN("RF_KILL bit toggled to %s.\n", - hw_rf_kill ? "disable radio" : "enable radio"); + hw_rf_kill ? "disable radio" : "enable radio"); il->isr_stats.rfkill++; @@ -4214,8 +4187,8 @@ static void il4965_irq_tasklet(struct il_priv *il) /* Error detected by uCode */ if (inta & CSR_INT_BIT_SW_ERR) { - IL_ERR("Microcode SW error detected. " - " Restarting 0x%X.\n", inta); + IL_ERR("Microcode SW error detected. " " Restarting 0x%X.\n", + inta); il->isr_stats.sw++; il_irq_handle_error(il); handled |= CSR_INT_BIT_SW_ERR; @@ -4261,7 +4234,7 @@ static void il4965_irq_tasklet(struct il_priv *il) if (inta & ~(il->inta_mask)) { IL_WARN("Disabled INTA bits 0x%08x were pending\n", - inta & ~il->inta_mask); + inta & ~il->inta_mask); IL_WARN(" with FH49_INT = 0x%08x\n", inta_fh); } @@ -4278,9 +4251,8 @@ static void il4965_irq_tasklet(struct il_priv *il) inta = _il_rd(il, CSR_INT); inta_mask = _il_rd(il, CSR_INT_MASK); inta_fh = _il_rd(il, CSR_FH_INT_STATUS); - D_ISR( - "End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " - "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); + D_ISR("End inta 0x%08x, enabled 0x%08x, fh 0x%08x, " + "flags 0x%08lx\n", inta, inta_mask, inta_fh, flags); } #endif } @@ -4304,15 +4276,17 @@ static void il4965_irq_tasklet(struct il_priv *il) * level that is used instead of the global debug level if it (the per * device debug level) is set. */ -static ssize_t il4965_show_debug_level(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il4965_show_debug_level(struct device *d, struct device_attribute *attr, + char *buf) { struct il_priv *il = dev_get_drvdata(d); return sprintf(buf, "0x%08X\n", il_get_debug_level(il)); } -static ssize_t il4965_store_debug_level(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) + +static ssize_t +il4965_store_debug_level(struct device *d, struct device_attribute *attr, + const char *buf, size_t count) { struct il_priv *il = dev_get_drvdata(d); unsigned long val; @@ -4324,21 +4298,19 @@ static ssize_t il4965_store_debug_level(struct device *d, else { il->debug_level = val; if (il_alloc_traffic_mem(il)) - IL_ERR( - "Not enough memory to generate traffic log\n"); + IL_ERR("Not enough memory to generate traffic log\n"); } return strnlen(buf, count); } -static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, - il4965_show_debug_level, il4965_store_debug_level); - +static DEVICE_ATTR(debug_level, S_IWUSR | S_IRUGO, il4965_show_debug_level, + il4965_store_debug_level); #endif /* CONFIG_IWLEGACY_DEBUG */ - -static ssize_t il4965_show_temperature(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il4965_show_temperature(struct device *d, struct device_attribute *attr, + char *buf) { struct il_priv *il = dev_get_drvdata(d); @@ -4350,8 +4322,8 @@ static ssize_t il4965_show_temperature(struct device *d, static DEVICE_ATTR(temperature, S_IRUGO, il4965_show_temperature, NULL); -static ssize_t il4965_show_tx_power(struct device *d, - struct device_attribute *attr, char *buf) +static ssize_t +il4965_show_tx_power(struct device *d, struct device_attribute *attr, char *buf) { struct il_priv *il = dev_get_drvdata(d); @@ -4361,9 +4333,9 @@ static ssize_t il4965_show_tx_power(struct device *d, return sprintf(buf, "%d\n", il->tx_power_user_lmt); } -static ssize_t il4965_store_tx_power(struct device *d, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t +il4965_store_tx_power(struct device *d, struct device_attribute *attr, + const char *buf, size_t count) { struct il_priv *il = dev_get_drvdata(d); unsigned long val; @@ -4375,16 +4347,15 @@ static ssize_t il4965_store_tx_power(struct device *d, else { ret = il_set_tx_power(il, val, false); if (ret) - IL_ERR("failed setting tx power (0x%d).\n", - ret); + IL_ERR("failed setting tx power (0x%d).\n", ret); else ret = count; } return ret; } -static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, - il4965_show_tx_power, il4965_store_tx_power); +static DEVICE_ATTR(tx_power, S_IWUSR | S_IRUGO, il4965_show_tx_power, + il4965_store_tx_power); static struct attribute *il_sysfs_entries[] = { &dev_attr_temperature.attr, @@ -4406,7 +4377,8 @@ static struct attribute_group il_attribute_group = { * ******************************************************************************/ -static void il4965_dealloc_ucode_pci(struct il_priv *il) +static void +il4965_dealloc_ucode_pci(struct il_priv *il) { il_free_fw_desc(il->pci_dev, &il->ucode_code); il_free_fw_desc(il->pci_dev, &il->ucode_data); @@ -4416,18 +4388,19 @@ static void il4965_dealloc_ucode_pci(struct il_priv *il) il_free_fw_desc(il->pci_dev, &il->ucode_boot); } -static void il4965_nic_start(struct il_priv *il) +static void +il4965_nic_start(struct il_priv *il) { /* Remove all resets to allow NIC to operate */ _il_wr(il, CSR_RESET, 0); } static void il4965_ucode_callback(const struct firmware *ucode_raw, - void *context); -static int il4965_mac_setup_register(struct il_priv *il, - u32 max_probe_length); + void *context); +static int il4965_mac_setup_register(struct il_priv *il, u32 max_probe_length); -static int __must_check il4965_request_firmware(struct il_priv *il, bool first) +static int __must_check +il4965_request_firmware(struct il_priv *il, bool first) { const char *name_pre = il->cfg->fw_name_pre; char tag[8]; @@ -4447,8 +4420,7 @@ static int __must_check il4965_request_firmware(struct il_priv *il, bool first) sprintf(il->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); - D_INFO("attempting to load firmware '%s'\n", - il->firmware_name); + D_INFO("attempting to load firmware '%s'\n", il->firmware_name); return request_firmware_nowait(THIS_MODULE, 1, il->firmware_name, &il->pci_dev->dev, GFP_KERNEL, il, @@ -4460,9 +4432,9 @@ struct il4965_firmware_pieces { size_t inst_size, data_size, init_size, init_data_size, boot_size; }; -static int il4965_load_firmware(struct il_priv *il, - const struct firmware *ucode_raw, - struct il4965_firmware_pieces *pieces) +static int +il4965_load_firmware(struct il_priv *il, const struct firmware *ucode_raw, + struct il4965_firmware_pieces *pieces) { struct il_ucode_header *ucode = (void *)ucode_raw->data; u32 api_ver, hdr_size; @@ -4484,21 +4456,19 @@ static int il4965_load_firmware(struct il_priv *il, pieces->inst_size = le32_to_cpu(ucode->v1.inst_size); pieces->data_size = le32_to_cpu(ucode->v1.data_size); pieces->init_size = le32_to_cpu(ucode->v1.init_size); - pieces->init_data_size = - le32_to_cpu(ucode->v1.init_data_size); + pieces->init_data_size = le32_to_cpu(ucode->v1.init_data_size); pieces->boot_size = le32_to_cpu(ucode->v1.boot_size); src = ucode->v1.data; break; } /* Verify size of file vs. image size info in file's header */ - if (ucode_raw->size != hdr_size + pieces->inst_size + - pieces->data_size + pieces->init_size + - pieces->init_data_size + pieces->boot_size) { + if (ucode_raw->size != + hdr_size + pieces->inst_size + pieces->data_size + + pieces->init_size + pieces->init_data_size + pieces->boot_size) { - IL_ERR( - "uCode file size %d does not match expected size\n", - (int)ucode_raw->size); + IL_ERR("uCode file size %d does not match expected size\n", + (int)ucode_raw->size); return -EINVAL; } @@ -4535,20 +4505,19 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) u32 max_probe_length = 200; u32 standard_phy_calibration_size = - IL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE; + IL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE; memset(&pieces, 0, sizeof(pieces)); if (!ucode_raw) { if (il->fw_idx <= il->cfg->ucode_api_max) - IL_ERR( - "request for firmware file '%s' failed.\n", - il->firmware_name); + IL_ERR("request for firmware file '%s' failed.\n", + il->firmware_name); goto try_again; } - D_INFO("Loaded firmware file '%s' (%zd bytes).\n", - il->firmware_name, ucode_raw->size); + D_INFO("Loaded firmware file '%s' (%zd bytes).\n", il->firmware_name, + ucode_raw->size); /* Make sure that we got at least the API version number */ if (ucode_raw->size < 4) { @@ -4572,32 +4541,25 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) * on the API version read from firmware header from here on forward */ if (api_ver < api_min || api_ver > api_max) { - IL_ERR( - "Driver unable to support your firmware API. " - "Driver supports v%u, firmware is v%u.\n", - api_max, api_ver); + IL_ERR("Driver unable to support your firmware API. " + "Driver supports v%u, firmware is v%u.\n", api_max, + api_ver); goto try_again; } if (api_ver != api_max) - IL_ERR( - "Firmware has old API version. Expected v%u, " - "got v%u. New firmware can be obtained " - "from http://www.intellinuxwireless.org.\n", - api_max, api_ver); + IL_ERR("Firmware has old API version. Expected v%u, " + "got v%u. New firmware can be obtained " + "from http://www.intellinuxwireless.org.\n", api_max, + api_ver); IL_INFO("loaded firmware version %u.%u.%u.%u\n", - IL_UCODE_MAJOR(il->ucode_ver), - IL_UCODE_MINOR(il->ucode_ver), - IL_UCODE_API(il->ucode_ver), - IL_UCODE_SERIAL(il->ucode_ver)); + IL_UCODE_MAJOR(il->ucode_ver), IL_UCODE_MINOR(il->ucode_ver), + IL_UCODE_API(il->ucode_ver), IL_UCODE_SERIAL(il->ucode_ver)); - snprintf(il->hw->wiphy->fw_version, - sizeof(il->hw->wiphy->fw_version), - "%u.%u.%u.%u", - IL_UCODE_MAJOR(il->ucode_ver), - IL_UCODE_MINOR(il->ucode_ver), - IL_UCODE_API(il->ucode_ver), + snprintf(il->hw->wiphy->fw_version, sizeof(il->hw->wiphy->fw_version), + "%u.%u.%u.%u", IL_UCODE_MAJOR(il->ucode_ver), + IL_UCODE_MINOR(il->ucode_ver), IL_UCODE_API(il->ucode_ver), IL_UCODE_SERIAL(il->ucode_ver)); /* @@ -4606,47 +4568,41 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) * user just got a corrupted version of the latest API. */ - D_INFO("f/w package hdr ucode version raw = 0x%x\n", - il->ucode_ver); - D_INFO("f/w package hdr runtime inst size = %Zd\n", - pieces.inst_size); - D_INFO("f/w package hdr runtime data size = %Zd\n", - pieces.data_size); - D_INFO("f/w package hdr init inst size = %Zd\n", - pieces.init_size); - D_INFO("f/w package hdr init data size = %Zd\n", - pieces.init_data_size); - D_INFO("f/w package hdr boot inst size = %Zd\n", - pieces.boot_size); + D_INFO("f/w package hdr ucode version raw = 0x%x\n", il->ucode_ver); + D_INFO("f/w package hdr runtime inst size = %Zd\n", pieces.inst_size); + D_INFO("f/w package hdr runtime data size = %Zd\n", pieces.data_size); + D_INFO("f/w package hdr init inst size = %Zd\n", pieces.init_size); + D_INFO("f/w package hdr init data size = %Zd\n", pieces.init_data_size); + D_INFO("f/w package hdr boot inst size = %Zd\n", pieces.boot_size); /* Verify that uCode images will fit in card's SRAM */ if (pieces.inst_size > il->hw_params.max_inst_size) { IL_ERR("uCode instr len %Zd too large to fit in\n", - pieces.inst_size); + pieces.inst_size); goto try_again; } if (pieces.data_size > il->hw_params.max_data_size) { IL_ERR("uCode data len %Zd too large to fit in\n", - pieces.data_size); + pieces.data_size); goto try_again; } if (pieces.init_size > il->hw_params.max_inst_size) { IL_ERR("uCode init instr len %Zd too large to fit in\n", - pieces.init_size); + pieces.init_size); goto try_again; } if (pieces.init_data_size > il->hw_params.max_data_size) { IL_ERR("uCode init data len %Zd too large to fit in\n", - pieces.init_data_size); + pieces.init_data_size); goto try_again; } if (pieces.boot_size > il->hw_params.max_bsm_size) { IL_ERR("uCode boot instr len %Zd too large to fit in\n", - pieces.boot_size); + pieces.boot_size); goto try_again; } @@ -4697,41 +4653,39 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) /* Runtime instructions (first block of data in file) */ D_INFO("Copying (but not loading) uCode instr len %Zd\n", - pieces.inst_size); + pieces.inst_size); memcpy(il->ucode_code.v_addr, pieces.inst, pieces.inst_size); D_INFO("uCode instr buf vaddr = 0x%p, paddr = 0x%08x\n", - il->ucode_code.v_addr, (u32)il->ucode_code.p_addr); + il->ucode_code.v_addr, (u32) il->ucode_code.p_addr); /* * Runtime data * NOTE: Copy into backup buffer will be done in il_up() */ D_INFO("Copying (but not loading) uCode data len %Zd\n", - pieces.data_size); + pieces.data_size); memcpy(il->ucode_data.v_addr, pieces.data, pieces.data_size); memcpy(il->ucode_data_backup.v_addr, pieces.data, pieces.data_size); /* Initialization instructions */ if (pieces.init_size) { - D_INFO( - "Copying (but not loading) init instr len %Zd\n", - pieces.init_size); + D_INFO("Copying (but not loading) init instr len %Zd\n", + pieces.init_size); memcpy(il->ucode_init.v_addr, pieces.init, pieces.init_size); } /* Initialization data */ if (pieces.init_data_size) { - D_INFO( - "Copying (but not loading) init data len %Zd\n", - pieces.init_data_size); + D_INFO("Copying (but not loading) init data len %Zd\n", + pieces.init_data_size); memcpy(il->ucode_init_data.v_addr, pieces.init_data, pieces.init_data_size); } /* Bootstrap instructions */ D_INFO("Copying (but not loading) boot instr len %Zd\n", - pieces.boot_size); + pieces.boot_size); memcpy(il->ucode_boot.v_addr, pieces.boot, pieces.boot_size); /* @@ -4739,9 +4693,9 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) * base on the size of standard phy calibration commands table size */ il->_4965.phy_calib_chain_noise_reset_cmd = - standard_phy_calibration_size; + standard_phy_calibration_size; il->_4965.phy_calib_chain_noise_gain_cmd = - standard_phy_calibration_size + 1; + standard_phy_calibration_size + 1; /************************************************** * This is still part of probe() in a sense... @@ -4754,11 +4708,10 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) err = il_dbgfs_register(il, DRV_NAME); if (err) - IL_ERR( - "failed to create debugfs files. Ignoring error: %d\n", err); + IL_ERR("failed to create debugfs files. Ignoring error: %d\n", + err); - err = sysfs_create_group(&il->pci_dev->dev.kobj, - &il_attribute_group); + err = sysfs_create_group(&il->pci_dev->dev.kobj, &il_attribute_group); if (err) { IL_ERR("failed to create sysfs device attributes\n"); goto out_unbind; @@ -4769,23 +4722,23 @@ il4965_ucode_callback(const struct firmware *ucode_raw, void *context) complete(&il->_4965.firmware_loading_complete); return; - try_again: +try_again: /* try next, if any */ if (il4965_request_firmware(il, false)) goto out_unbind; release_firmware(ucode_raw); return; - err_pci_alloc: +err_pci_alloc: IL_ERR("failed to allocate pci memory\n"); il4965_dealloc_ucode_pci(il); - out_unbind: +out_unbind: complete(&il->_4965.firmware_loading_complete); device_release_driver(&il->pci_dev->dev); release_firmware(ucode_raw); } -static const char * const desc_lookup_text[] = { +static const char *const desc_lookup_text[] = { "OK", "FAIL", "BAD_PARAM", @@ -4816,26 +4769,30 @@ static const char * const desc_lookup_text[] = { "DEBUG_3", }; -static struct { char *name; u8 num; } advanced_lookup[] = { - { "NMI_INTERRUPT_WDG", 0x34 }, - { "SYSASSERT", 0x35 }, - { "UCODE_VERSION_MISMATCH", 0x37 }, - { "BAD_COMMAND", 0x38 }, - { "NMI_INTERRUPT_DATA_ACTION_PT", 0x3C }, - { "FATAL_ERROR", 0x3D }, - { "NMI_TRM_HW_ERR", 0x46 }, - { "NMI_INTERRUPT_TRM", 0x4C }, - { "NMI_INTERRUPT_BREAK_POINT", 0x54 }, - { "NMI_INTERRUPT_WDG_RXF_FULL", 0x5C }, - { "NMI_INTERRUPT_WDG_NO_RBD_RXF_FULL", 0x64 }, - { "NMI_INTERRUPT_HOST", 0x66 }, - { "NMI_INTERRUPT_ACTION_PT", 0x7C }, - { "NMI_INTERRUPT_UNKNOWN", 0x84 }, - { "NMI_INTERRUPT_INST_ACTION_PT", 0x86 }, - { "ADVANCED_SYSASSERT", 0 }, -}; - -static const char *il4965_desc_lookup(u32 num) +static struct { + char *name; + u8 num; +} advanced_lookup[] = { + { + "NMI_INTERRUPT_WDG", 0x34}, { + "SYSASSERT", 0x35}, { + "UCODE_VERSION_MISMATCH", 0x37}, { + "BAD_COMMAND", 0x38}, { + "NMI_INTERRUPT_DATA_ACTION_PT", 0x3C}, { + "FATAL_ERROR", 0x3D}, { + "NMI_TRM_HW_ERR", 0x46}, { + "NMI_INTERRUPT_TRM", 0x4C}, { + "NMI_INTERRUPT_BREAK_POINT", 0x54}, { + "NMI_INTERRUPT_WDG_RXF_FULL", 0x5C}, { + "NMI_INTERRUPT_WDG_NO_RBD_RXF_FULL", 0x64}, { + "NMI_INTERRUPT_HOST", 0x66}, { + "NMI_INTERRUPT_ACTION_PT", 0x7C}, { + "NMI_INTERRUPT_UNKNOWN", 0x84}, { + "NMI_INTERRUPT_INST_ACTION_PT", 0x86}, { +"ADVANCED_SYSASSERT", 0},}; + +static const char * +il4965_desc_lookup(u32 num) { int i; int max = ARRAY_SIZE(desc_lookup_text); @@ -4854,7 +4811,8 @@ static const char *il4965_desc_lookup(u32 num) #define ERROR_START_OFFSET (1 * sizeof(u32)) #define ERROR_ELEM_SIZE (7 * sizeof(u32)) -void il4965_dump_nic_error_log(struct il_priv *il) +void +il4965_dump_nic_error_log(struct il_priv *il) { u32 data2, line; u32 desc, time, count, base, data1; @@ -4868,9 +4826,8 @@ void il4965_dump_nic_error_log(struct il_priv *il) } if (!il->cfg->ops->lib->is_valid_rtc_data_addr(base)) { - IL_ERR( - "Not valid error log pointer 0x%08X for %s uCode\n", - base, (il->ucode_type == UCODE_INIT) ? "Init" : "RT"); + IL_ERR("Not valid error log pointer 0x%08X for %s uCode\n", + base, (il->ucode_type == UCODE_INIT) ? "Init" : "RT"); return; } @@ -4878,8 +4835,7 @@ void il4965_dump_nic_error_log(struct il_priv *il) if (ERROR_START_OFFSET <= count * ERROR_ELEM_SIZE) { IL_ERR("Start IWL Error Log Dump:\n"); - IL_ERR("Status: 0x%08lX, count: %d\n", - il->status, count); + IL_ERR("Status: 0x%08lX, count: %d\n", il->status, count); } desc = il_read_targ_mem(il, base + 1 * sizeof(u32)); @@ -4896,15 +4852,16 @@ void il4965_dump_nic_error_log(struct il_priv *il) hcmd = il_read_targ_mem(il, base + 22 * sizeof(u32)); IL_ERR("Desc Time " - "data1 data2 line\n"); + "data1 data2 line\n"); IL_ERR("%-28s (0x%04X) %010u 0x%08X 0x%08X %u\n", - il4965_desc_lookup(desc), desc, time, data1, data2, line); + il4965_desc_lookup(desc), desc, time, data1, data2, line); IL_ERR("pc blink1 blink2 ilink1 ilink2 hcmd\n"); - IL_ERR("0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n", - pc, blink1, blink2, ilink1, ilink2, hcmd); + IL_ERR("0x%05X 0x%05X 0x%05X 0x%05X 0x%05X 0x%05X\n", pc, blink1, + blink2, ilink1, ilink2, hcmd); } -static void il4965_rf_kill_ct_config(struct il_priv *il) +static void +il4965_rf_kill_ct_config(struct il_priv *il) { struct il_ct_kill_config cmd; unsigned long flags; @@ -4912,21 +4869,19 @@ static void il4965_rf_kill_ct_config(struct il_priv *il) spin_lock_irqsave(&il->lock, flags); _il_wr(il, CSR_UCODE_DRV_GP1_CLR, - CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); + CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); spin_unlock_irqrestore(&il->lock, flags); cmd.critical_temperature_R = - cpu_to_le32(il->hw_params.ct_kill_threshold); + cpu_to_le32(il->hw_params.ct_kill_threshold); - ret = il_send_cmd_pdu(il, C_CT_KILL_CONFIG, - sizeof(cmd), &cmd); + ret = il_send_cmd_pdu(il, C_CT_KILL_CONFIG, sizeof(cmd), &cmd); if (ret) IL_ERR("C_CT_KILL_CONFIG failed\n"); else - D_INFO("C_CT_KILL_CONFIG " - "succeeded, " - "critical temperature is %d\n", - il->hw_params.ct_kill_threshold); + D_INFO("C_CT_KILL_CONFIG " "succeeded, " + "critical temperature is %d\n", + il->hw_params.ct_kill_threshold); } static const s8 default_queue_to_tx_fifo[] = { @@ -4941,7 +4896,8 @@ static const s8 default_queue_to_tx_fifo[] = { #define IL_MASK(lo, hi) ((1 << (hi)) | ((1 << (hi)) - (1 << (lo)))) -static int il4965_alive_notify(struct il_priv *il) +static int +il4965_alive_notify(struct il_priv *il) { u32 a; unsigned long flags; @@ -4951,32 +4907,32 @@ static int il4965_alive_notify(struct il_priv *il) spin_lock_irqsave(&il->lock, flags); /* Clear 4965's internal Tx Scheduler data base */ - il->scd_base_addr = il_rd_prph(il, - IL49_SCD_SRAM_BASE_ADDR); + il->scd_base_addr = il_rd_prph(il, IL49_SCD_SRAM_BASE_ADDR); a = il->scd_base_addr + IL49_SCD_CONTEXT_DATA_OFFSET; for (; a < il->scd_base_addr + IL49_SCD_TX_STTS_BITMAP_OFFSET; a += 4) il_write_targ_mem(il, a, 0); for (; a < il->scd_base_addr + IL49_SCD_TRANSLATE_TBL_OFFSET; a += 4) il_write_targ_mem(il, a, 0); - for (; a < il->scd_base_addr + - IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(il->hw_params.max_txq_num); a += 4) + for (; + a < + il->scd_base_addr + + IL49_SCD_TRANSLATE_TBL_OFFSET_QUEUE(il->hw_params.max_txq_num); + a += 4) il_write_targ_mem(il, a, 0); /* Tel 4965 where to find Tx byte count tables */ - il_wr_prph(il, IL49_SCD_DRAM_BASE_ADDR, - il->scd_bc_tbls.dma >> 10); + il_wr_prph(il, IL49_SCD_DRAM_BASE_ADDR, il->scd_bc_tbls.dma >> 10); /* Enable DMA channel */ - for (chan = 0; chan < FH49_TCSR_CHNL_NUM ; chan++) - il_wr(il, - FH49_TCSR_CHNL_TX_CONFIG_REG(chan), - FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | - FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE); + for (chan = 0; chan < FH49_TCSR_CHNL_NUM; chan++) + il_wr(il, FH49_TCSR_CHNL_TX_CONFIG_REG(chan), + FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | + FH49_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_ENABLE); /* Update FH chicken bits */ reg_val = il_rd(il, FH49_TX_CHICKEN_BITS_REG); il_wr(il, FH49_TX_CHICKEN_BITS_REG, - reg_val | FH49_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); + reg_val | FH49_TX_CHICKEN_BITS_SCD_AUTO_RETRY_EN); /* Disable chain mode for all queues */ il_wr_prph(il, IL49_SCD_QUEUECHAIN_SEL, 0); @@ -4989,23 +4945,25 @@ static int il4965_alive_notify(struct il_priv *il) il_wr(il, HBUS_TARG_WRPTR, 0 | (i << 8)); /* Max Tx Window size for Scheduler-ACK mode */ - il_write_targ_mem(il, il->scd_base_addr + - IL49_SCD_CONTEXT_QUEUE_OFFSET(i), - (SCD_WIN_SIZE << - IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & - IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); + il_write_targ_mem(il, + il->scd_base_addr + + IL49_SCD_CONTEXT_QUEUE_OFFSET(i), + (SCD_WIN_SIZE << + IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_POS) & + IL49_SCD_QUEUE_CTX_REG1_WIN_SIZE_MSK); /* Frame limit */ - il_write_targ_mem(il, il->scd_base_addr + - IL49_SCD_CONTEXT_QUEUE_OFFSET(i) + - sizeof(u32), - (SCD_FRAME_LIMIT << - IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) & - IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); + il_write_targ_mem(il, + il->scd_base_addr + + IL49_SCD_CONTEXT_QUEUE_OFFSET(i) + + sizeof(u32), + (SCD_FRAME_LIMIT << + IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_POS) & + IL49_SCD_QUEUE_CTX_REG2_FRAME_LIMIT_MSK); } il_wr_prph(il, IL49_SCD_INTERRUPT_MASK, - (1 << il->hw_params.max_txq_num) - 1); + (1 << il->hw_params.max_txq_num) - 1); /* Activate all Tx DMA/FIFO channels */ il4965_txq_set_sched(il, IL_MASK(0, 6)); @@ -5043,7 +5001,8 @@ static int il4965_alive_notify(struct il_priv *il) * from protocol/runtime uCode (initialization uCode's * Alive gets handled by il_init_alive_start()). */ -static void il4965_alive_start(struct il_priv *il) +static void +il4965_alive_start(struct il_priv *il) { int ret = 0; struct il_rxon_context *ctx = &il->ctx; @@ -5069,12 +5028,10 @@ static void il4965_alive_start(struct il_priv *il) ret = il4965_alive_notify(il); if (ret) { - IL_WARN( - "Could not complete ALIVE transition [ntf]: %d\n", ret); + IL_WARN("Could not complete ALIVE transition [ntf]: %d\n", ret); goto restart; } - /* After the ALIVE response, we can send host commands to the uCode */ set_bit(S_ALIVE, &il->status); @@ -5090,7 +5047,7 @@ static void il4965_alive_start(struct il_priv *il) if (il_is_associated_ctx(ctx)) { struct il_rxon_cmd *active_rxon = - (struct il_rxon_cmd *)&ctx->active; + (struct il_rxon_cmd *)&ctx->active; /* apply any changes in staging */ ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; @@ -5123,13 +5080,14 @@ static void il4965_alive_start(struct il_priv *il) return; - restart: +restart: queue_work(il->workqueue, &il->restart); } static void il4965_cancel_deferred_work(struct il_priv *il); -static void __il4965_down(struct il_priv *il) +static void +__il4965_down(struct il_priv *il) { unsigned long flags; int exit_pending; @@ -5171,25 +5129,28 @@ static void __il4965_down(struct il_priv *il) /* If we have not previously called il_init() then * clear all bits but the RF Kill bit and return */ if (!il_is_init(il)) { - il->status = test_bit(S_RF_KILL_HW, &il->status) << - S_RF_KILL_HW | - test_bit(S_GEO_CONFIGURED, &il->status) << - S_GEO_CONFIGURED | - test_bit(S_EXIT_PENDING, &il->status) << - S_EXIT_PENDING; + il->status = + test_bit(S_RF_KILL_HW, + &il-> + status) << S_RF_KILL_HW | + test_bit(S_GEO_CONFIGURED, + &il-> + status) << S_GEO_CONFIGURED | + test_bit(S_EXIT_PENDING, &il->status) << S_EXIT_PENDING; goto exit; } /* ...otherwise clear out all the status bits but the RF Kill * bit and continue taking the NIC down. */ - il->status &= test_bit(S_RF_KILL_HW, &il->status) << - S_RF_KILL_HW | - test_bit(S_GEO_CONFIGURED, &il->status) << - S_GEO_CONFIGURED | - test_bit(S_FW_ERROR, &il->status) << - S_FW_ERROR | - test_bit(S_EXIT_PENDING, &il->status) << - S_EXIT_PENDING; + il->status &= + test_bit(S_RF_KILL_HW, + &il->status) << S_RF_KILL_HW | test_bit(S_GEO_CONFIGURED, + &il-> + status) << + S_GEO_CONFIGURED | test_bit(S_FW_ERROR, + &il-> + status) << S_FW_ERROR | + test_bit(S_EXIT_PENDING, &il->status) << S_EXIT_PENDING; il4965_txq_ctx_stop(il); il4965_rxq_stop(il); @@ -5199,13 +5160,12 @@ static void __il4965_down(struct il_priv *il) udelay(5); /* Make sure (redundant) we've released our request to stay awake */ - il_clear_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); + il_clear_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); /* Stop the device, and put it in low power state */ il_apm_stop(il); - exit: +exit: memset(&il->card_alive, 0, sizeof(struct il_alive_resp)); dev_kfree_skb(il->beacon_skb); @@ -5215,7 +5175,8 @@ static void __il4965_down(struct il_priv *il) il4965_clear_free_frames(il); } -static void il4965_down(struct il_priv *il) +static void +il4965_down(struct il_priv *il) { mutex_lock(&il->mutex); __il4965_down(il); @@ -5226,29 +5187,30 @@ static void il4965_down(struct il_priv *il) #define HW_READY_TIMEOUT (50) -static int il4965_set_hw_ready(struct il_priv *il) +static int +il4965_set_hw_ready(struct il_priv *il) { int ret = 0; il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_NIC_READY); + CSR_HW_IF_CONFIG_REG_BIT_NIC_READY); /* See if we got it */ - ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, - CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, - HW_READY_TIMEOUT); + ret = + _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, + CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, + CSR_HW_IF_CONFIG_REG_BIT_NIC_READY, HW_READY_TIMEOUT); if (ret != -ETIMEDOUT) il->hw_ready = true; else il->hw_ready = false; - D_INFO("hardware %s\n", - (il->hw_ready == 1) ? "ready" : "not ready"); + D_INFO("hardware %s\n", (il->hw_ready == 1) ? "ready" : "not ready"); return ret; } -static int il4965_prepare_card_hw(struct il_priv *il) +static int +il4965_prepare_card_hw(struct il_priv *il) { int ret = 0; @@ -5259,12 +5221,12 @@ static int il4965_prepare_card_hw(struct il_priv *il) return ret; /* If HW is not ready, prepare the conditions to check again */ - il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_PREPARE); + il_set_bit(il, CSR_HW_IF_CONFIG_REG, CSR_HW_IF_CONFIG_REG_PREPARE); - ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, - ~CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, - CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, 150000); + ret = + _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, + ~CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, + CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, 150000); /* HW should be ready by now, check again. */ if (ret != -ETIMEDOUT) @@ -5275,7 +5237,8 @@ static int il4965_prepare_card_hw(struct il_priv *il) #define MAX_HW_RESTARTS 5 -static int __il4965_up(struct il_priv *il) +static int +__il4965_up(struct il_priv *il) { int i; int ret; @@ -5304,8 +5267,7 @@ static int __il4965_up(struct il_priv *il) } /* If platform's RF_KILL switch is NOT set to KILL */ - if (_il_rd(il, - CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) + if (_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) clear_bit(S_RF_KILL_HW, &il->status); else set_bit(S_RF_KILL_HW, &il->status); @@ -5331,8 +5293,7 @@ static int __il4965_up(struct il_priv *il) /* make sure rfkill handshake bits are cleared */ _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); - _il_wr(il, CSR_UCODE_DRV_GP1_CLR, - CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); + _il_wr(il, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_CMD_BLOCKED); /* clear (again), then enable host interrupts */ _il_wr(il, CSR_INT, 0xFFFFFFFF); @@ -5356,8 +5317,7 @@ static int __il4965_up(struct il_priv *il) ret = il->cfg->ops->lib->load_ucode(il); if (ret) { - IL_ERR("Unable to set up bootstrap uCode: %d\n", - ret); + IL_ERR("Unable to set up bootstrap uCode: %d\n", ret); continue; } @@ -5379,14 +5339,14 @@ static int __il4965_up(struct il_priv *il) return -EIO; } - /***************************************************************************** * * Workqueue callbacks * *****************************************************************************/ -static void il4965_bg_init_alive_start(struct work_struct *data) +static void +il4965_bg_init_alive_start(struct work_struct *data) { struct il_priv *il = container_of(data, struct il_priv, init_alive_start.work); @@ -5400,7 +5360,8 @@ out: mutex_unlock(&il->mutex); } -static void il4965_bg_alive_start(struct work_struct *data) +static void +il4965_bg_alive_start(struct work_struct *data) { struct il_priv *il = container_of(data, struct il_priv, alive_start.work); @@ -5414,10 +5375,11 @@ out: mutex_unlock(&il->mutex); } -static void il4965_bg_run_time_calib_work(struct work_struct *work) +static void +il4965_bg_run_time_calib_work(struct work_struct *work) { struct il_priv *il = container_of(work, struct il_priv, - run_time_calib_work); + run_time_calib_work); mutex_lock(&il->mutex); @@ -5428,16 +5390,15 @@ static void il4965_bg_run_time_calib_work(struct work_struct *work) } if (il->start_calib) { - il4965_chain_noise_calibration(il, - (void *)&il->_4965.stats); - il4965_sensitivity_calibration(il, - (void *)&il->_4965.stats); + il4965_chain_noise_calibration(il, (void *)&il->_4965.stats); + il4965_sensitivity_calibration(il, (void *)&il->_4965.stats); } mutex_unlock(&il->mutex); } -static void il4965_bg_restart(struct work_struct *data) +static void +il4965_bg_restart(struct work_struct *data) { struct il_priv *il = container_of(data, struct il_priv, restart); @@ -5468,10 +5429,10 @@ static void il4965_bg_restart(struct work_struct *data) } } -static void il4965_bg_rx_replenish(struct work_struct *data) +static void +il4965_bg_rx_replenish(struct work_struct *data) { - struct il_priv *il = - container_of(data, struct il_priv, rx_replenish); + struct il_priv *il = container_of(data, struct il_priv, rx_replenish); if (test_bit(S_EXIT_PENDING, &il->status)) return; @@ -5493,8 +5454,8 @@ static void il4965_bg_rx_replenish(struct work_struct *data) * Not a mac80211 entry point function, but it fits in with all the * other mac80211 functions grouped here. */ -static int il4965_mac_setup_register(struct il_priv *il, - u32 max_probe_length) +static int +il4965_mac_setup_register(struct il_priv *il, u32 max_probe_length) { int ret; struct ieee80211_hw *hw = il->hw; @@ -5502,15 +5463,15 @@ static int il4965_mac_setup_register(struct il_priv *il, hw->rate_control_algorithm = "iwl-4965-rs"; /* Tell mac80211 our characteristics */ - hw->flags = IEEE80211_HW_SIGNAL_DBM | - IEEE80211_HW_AMPDU_AGGREGATION | - IEEE80211_HW_NEED_DTIM_PERIOD | - IEEE80211_HW_SPECTRUM_MGMT | - IEEE80211_HW_REPORTS_TX_ACK_STATUS; + hw->flags = + IEEE80211_HW_SIGNAL_DBM | IEEE80211_HW_AMPDU_AGGREGATION | + IEEE80211_HW_NEED_DTIM_PERIOD | IEEE80211_HW_SPECTRUM_MGMT | + IEEE80211_HW_REPORTS_TX_ACK_STATUS; if (il->cfg->sku & IL_SKU_N) - hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | - IEEE80211_HW_SUPPORTS_STATIC_SMPS; + hw->flags |= + IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS | + IEEE80211_HW_SUPPORTS_STATIC_SMPS; hw->sta_data_size = sizeof(struct il_station_priv); hw->vif_data_size = sizeof(struct il_vif_priv); @@ -5518,8 +5479,8 @@ static int il4965_mac_setup_register(struct il_priv *il, hw->wiphy->interface_modes |= il->ctx.interface_modes; hw->wiphy->interface_modes |= il->ctx.exclusive_interface_modes; - hw->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY | - WIPHY_FLAG_DISABLE_BEACON_HINTS; + hw->wiphy->flags |= + WIPHY_FLAG_CUSTOM_REGULATORY | WIPHY_FLAG_DISABLE_BEACON_HINTS; /* * For now, disable PS by default because it affects @@ -5538,10 +5499,10 @@ static int il4965_mac_setup_register(struct il_priv *il, if (il->bands[IEEE80211_BAND_2GHZ].n_channels) il->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = - &il->bands[IEEE80211_BAND_2GHZ]; + &il->bands[IEEE80211_BAND_2GHZ]; if (il->bands[IEEE80211_BAND_5GHZ].n_channels) il->hw->wiphy->bands[IEEE80211_BAND_5GHZ] = - &il->bands[IEEE80211_BAND_5GHZ]; + &il->bands[IEEE80211_BAND_5GHZ]; il_leds_init(il); @@ -5555,8 +5516,8 @@ static int il4965_mac_setup_register(struct il_priv *il, return 0; } - -int il4965_mac_start(struct ieee80211_hw *hw) +int +il4965_mac_start(struct ieee80211_hw *hw) { struct il_priv *il = hw->priv; int ret; @@ -5579,8 +5540,8 @@ int il4965_mac_start(struct ieee80211_hw *hw) /* Wait for START_ALIVE from Run Time ucode. Otherwise callbacks from * mac80211 will not be run successfully. */ ret = wait_event_timeout(il->wait_command_queue, - test_bit(S_READY, &il->status), - UCODE_READY_TIMEOUT); + test_bit(S_READY, &il->status), + UCODE_READY_TIMEOUT); if (!ret) { if (!test_bit(S_READY, &il->status)) { IL_ERR("START_ALIVE timeout after %dms.\n", @@ -5597,7 +5558,8 @@ out: return 0; } -void il4965_mac_stop(struct ieee80211_hw *hw) +void +il4965_mac_stop(struct ieee80211_hw *hw) { struct il_priv *il = hw->priv; @@ -5620,14 +5582,15 @@ void il4965_mac_stop(struct ieee80211_hw *hw) D_MAC80211("leave\n"); } -void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) +void +il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { struct il_priv *il = hw->priv; D_MACDUMP("enter\n"); D_TX("dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, - ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); + ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); if (il4965_tx_skb(il, skb)) dev_kfree_skb_any(skb); @@ -5635,26 +5598,26 @@ void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) D_MACDUMP("leave\n"); } -void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_key_conf *keyconf, - struct ieee80211_sta *sta, - u32 iv32, u16 *phase1key) +void +il4965_mac_update_tkip_key(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_key_conf *keyconf, + struct ieee80211_sta *sta, u32 iv32, u16 * phase1key) { struct il_priv *il = hw->priv; struct il_vif_priv *vif_priv = (void *)vif->drv_priv; D_MAC80211("enter\n"); - il4965_update_tkip_key(il, vif_priv->ctx, keyconf, sta, - iv32, phase1key); + il4965_update_tkip_key(il, vif_priv->ctx, keyconf, sta, iv32, + phase1key); D_MAC80211("leave\n"); } -int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, - struct ieee80211_vif *vif, struct ieee80211_sta *sta, - struct ieee80211_key_conf *key) +int +il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, + struct ieee80211_vif *vif, struct ieee80211_sta *sta, + struct ieee80211_key_conf *key) { struct il_priv *il = hw->priv; struct il_vif_priv *vif_priv = (void *)vif->drv_priv; @@ -5684,23 +5647,23 @@ int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, * In legacy wep mode, we use another host command to the uCode. */ if ((key->cipher == WLAN_CIPHER_SUITE_WEP40 || - key->cipher == WLAN_CIPHER_SUITE_WEP104) && - !sta) { + key->cipher == WLAN_CIPHER_SUITE_WEP104) && !sta) { if (cmd == SET_KEY) is_default_wep_key = !ctx->key_mapping_keys; else is_default_wep_key = - (key->hw_key_idx == HW_KEY_DEFAULT); + (key->hw_key_idx == HW_KEY_DEFAULT); } switch (cmd) { case SET_KEY: if (is_default_wep_key) - ret = il4965_set_default_wep_key(il, - vif_priv->ctx, key); + ret = + il4965_set_default_wep_key(il, vif_priv->ctx, key); else - ret = il4965_set_dynamic_key(il, vif_priv->ctx, - key, sta_id); + ret = + il4965_set_dynamic_key(il, vif_priv->ctx, key, + sta_id); D_MAC80211("enable hwcrypto key\n"); break; @@ -5708,8 +5671,7 @@ int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, if (is_default_wep_key) ret = il4965_remove_default_wep_key(il, ctx, key); else - ret = il4965_remove_dynamic_key(il, ctx, - key, sta_id); + ret = il4965_remove_dynamic_key(il, ctx, key, sta_id); D_MAC80211("disable hwcrypto key\n"); break; @@ -5723,17 +5685,16 @@ int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, return ret; } -int il4965_mac_ampdu_action(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - enum ieee80211_ampdu_mlme_action action, - struct ieee80211_sta *sta, u16 tid, u16 *ssn, - u8 buf_size) +int +il4965_mac_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + enum ieee80211_ampdu_mlme_action action, + struct ieee80211_sta *sta, u16 tid, u16 * ssn, + u8 buf_size) { struct il_priv *il = hw->priv; int ret = -EINVAL; - D_HT("A-MPDU action on addr %pM tid %d\n", - sta->addr, tid); + D_HT("A-MPDU action on addr %pM tid %d\n", sta->addr, tid); if (!(il->cfg->sku & IL_SKU_N)) return -EACCES; @@ -5770,9 +5731,9 @@ int il4965_mac_ampdu_action(struct ieee80211_hw *hw, return ret; } -int il4965_mac_sta_add(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta) +int +il4965_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_sta *sta) { struct il_priv *il = hw->priv; struct il_station_priv *sta_priv = (void *)sta->drv_priv; @@ -5781,20 +5742,18 @@ int il4965_mac_sta_add(struct ieee80211_hw *hw, int ret; u8 sta_id; - D_INFO("received request to add station %pM\n", - sta->addr); + D_INFO("received request to add station %pM\n", sta->addr); mutex_lock(&il->mutex); - D_INFO("proceeding to add station %pM\n", - sta->addr); + D_INFO("proceeding to add station %pM\n", sta->addr); sta_priv->common.sta_id = IL_INVALID_STATION; atomic_set(&sta_priv->pending_frames, 0); - ret = il_add_station_common(il, vif_priv->ctx, sta->addr, - is_ap, sta, &sta_id); + ret = + il_add_station_common(il, vif_priv->ctx, sta->addr, is_ap, sta, + &sta_id); if (ret) { - IL_ERR("Unable to add station %pM (%d)\n", - sta->addr, ret); + IL_ERR("Unable to add station %pM (%d)\n", sta->addr, ret); /* Should we return success if return code is EEXIST ? */ mutex_unlock(&il->mutex); return ret; @@ -5803,16 +5762,16 @@ int il4965_mac_sta_add(struct ieee80211_hw *hw, sta_priv->common.sta_id = sta_id; /* Initialize rate scaling */ - D_INFO("Initializing rate scaling for station %pM\n", - sta->addr); + D_INFO("Initializing rate scaling for station %pM\n", sta->addr); il4965_rs_rate_init(il, sta, sta_id); mutex_unlock(&il->mutex); return 0; } -void il4965_mac_channel_switch(struct ieee80211_hw *hw, - struct ieee80211_channel_switch *ch_switch) +void +il4965_mac_channel_switch(struct ieee80211_hw *hw, + struct ieee80211_channel_switch *ch_switch) { struct il_priv *il = hw->priv; const struct il_channel_info *ch_info; @@ -5860,15 +5819,15 @@ void il4965_mac_channel_switch(struct ieee80211_hw *hw, if (ctx->ht.enabled) { if (conf_is_ht40_minus(conf)) { ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_BELOW; + IEEE80211_HT_PARAM_CHA_SEC_BELOW; ctx->ht.is_40mhz = true; } else if (conf_is_ht40_plus(conf)) { ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_ABOVE; + IEEE80211_HT_PARAM_CHA_SEC_ABOVE; ctx->ht.is_40mhz = true; } else { ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_NONE; + IEEE80211_HT_PARAM_CHA_SEC_NONE; ctx->ht.is_40mhz = false; } } else @@ -5901,10 +5860,9 @@ out: D_MAC80211("leave\n"); } -void il4965_configure_filter(struct ieee80211_hw *hw, - unsigned int changed_flags, - unsigned int *total_flags, - u64 multicast) +void +il4965_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags, + unsigned int *total_flags, u64 multicast) { struct il_priv *il = hw->priv; __le32 filter_or = 0, filter_nand = 0; @@ -5916,8 +5874,8 @@ void il4965_configure_filter(struct ieee80211_hw *hw, filter_nand |= (flag); \ } while (0) - D_MAC80211("Enter: changed: 0x%x, total: 0x%x\n", - changed_flags, *total_flags); + D_MAC80211("Enter: changed: 0x%x, total: 0x%x\n", changed_flags, + *total_flags); CHK(FIF_OTHER_BSS | FIF_PROMISC_IN_BSS, RXON_FILTER_PROMISC_MSK); /* Setting _just_ RXON_FILTER_CTL2HOST_MSK causes FH errors */ @@ -5944,8 +5902,9 @@ void il4965_configure_filter(struct ieee80211_hw *hw, * since we currently do not support programming multicast * filters into the device. */ - *total_flags &= FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | - FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; + *total_flags &= + FIF_OTHER_BSS | FIF_ALLMULTI | FIF_PROMISC_IN_BSS | + FIF_BCN_PRBRESP_PROMISC | FIF_CONTROL; } /***************************************************************************** @@ -5954,10 +5913,11 @@ void il4965_configure_filter(struct ieee80211_hw *hw, * *****************************************************************************/ -static void il4965_bg_txpower_work(struct work_struct *work) +static void +il4965_bg_txpower_work(struct work_struct *work) { struct il_priv *il = container_of(work, struct il_priv, - txpower_work); + txpower_work); mutex_lock(&il->mutex); @@ -5981,7 +5941,8 @@ out: mutex_unlock(&il->mutex); } -static void il4965_setup_deferred_work(struct il_priv *il) +static void +il4965_setup_deferred_work(struct il_priv *il) { il->workqueue = create_singlethread_workqueue(DRV_NAME); @@ -6005,11 +5966,13 @@ static void il4965_setup_deferred_work(struct il_priv *il) il->watchdog.data = (unsigned long)il; il->watchdog.function = il_bg_watchdog; - tasklet_init(&il->irq_tasklet, (void (*)(unsigned long)) - il4965_irq_tasklet, (unsigned long)il); + tasklet_init(&il->irq_tasklet, + (void (*)(unsigned long))il4965_irq_tasklet, + (unsigned long)il); } -static void il4965_cancel_deferred_work(struct il_priv *il) +static void +il4965_cancel_deferred_work(struct il_priv *il) { cancel_work_sync(&il->txpower_work); cancel_delayed_work_sync(&il->init_alive_start); @@ -6021,14 +5984,14 @@ static void il4965_cancel_deferred_work(struct il_priv *il) del_timer_sync(&il->stats_periodic); } -static void il4965_init_hw_rates(struct il_priv *il, - struct ieee80211_rate *rates) +static void +il4965_init_hw_rates(struct il_priv *il, struct ieee80211_rate *rates) { int i; for (i = 0; i < RATE_COUNT_LEGACY; i++) { rates[i].bitrate = il_rates[i].ieee * 5; - rates[i].hw_value = i; /* Rate scaling will work on idxes */ + rates[i].hw_value = i; /* Rate scaling will work on idxes */ rates[i].hw_value_short = i; rates[i].flags = 0; if ((i >= IL_FIRST_CCK_RATE) && (i <= IL_LAST_CCK_RATE)) { @@ -6036,24 +5999,25 @@ static void il4965_init_hw_rates(struct il_priv *il, * If CCK != 1M then set short preamble rate flag. */ rates[i].flags |= - (il_rates[i].plcp == RATE_1M_PLCP) ? - 0 : IEEE80211_RATE_SHORT_PREAMBLE; + (il_rates[i].plcp == + RATE_1M_PLCP) ? 0 : IEEE80211_RATE_SHORT_PREAMBLE; } } } + /* * Acquire il->lock before calling this function ! */ -void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx) +void +il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx) { - il_wr(il, HBUS_TARG_WRPTR, - (idx & 0xff) | (txq_id << 8)); + il_wr(il, HBUS_TARG_WRPTR, (idx & 0xff) | (txq_id << 8)); il_wr_prph(il, IL49_SCD_QUEUE_RDPTR(txq_id), idx); } -void il4965_tx_queue_set_status(struct il_priv *il, - struct il_tx_queue *txq, - int tx_fifo_id, int scd_retry) +void +il4965_tx_queue_set_status(struct il_priv *il, struct il_tx_queue *txq, + int tx_fifo_id, int scd_retry) { int txq_id = txq->q.id; @@ -6062,21 +6026,22 @@ void il4965_tx_queue_set_status(struct il_priv *il, /* Set up and activate */ il_wr_prph(il, IL49_SCD_QUEUE_STATUS_BITS(txq_id), - (active << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | - (tx_fifo_id << IL49_SCD_QUEUE_STTS_REG_POS_TXF) | - (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_WSL) | - (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK) | - IL49_SCD_QUEUE_STTS_REG_MSK); + (active << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | (tx_fifo_id + << + IL49_SCD_QUEUE_STTS_REG_POS_TXF) + | (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_WSL) | (scd_retry + << + IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK) + | IL49_SCD_QUEUE_STTS_REG_MSK); txq->sched_retry = scd_retry; - D_INFO("%s %s Queue %d on AC %d\n", - active ? "Activate" : "Deactivate", - scd_retry ? "BA" : "AC", txq_id, tx_fifo_id); + D_INFO("%s %s Queue %d on AC %d\n", active ? "Activate" : "Deactivate", + scd_retry ? "BA" : "AC", txq_id, tx_fifo_id); } - -static int il4965_init_drv(struct il_priv *il) +static int +il4965_init_drv(struct il_priv *il) { int ret; @@ -6100,8 +6065,7 @@ static int il4965_init_drv(struct il_priv *il) /* Choose which receivers/antennas to use */ if (il->cfg->ops->hcmd->set_rxon_chain) - il->cfg->ops->hcmd->set_rxon_chain(il, - &il->ctx); + il->cfg->ops->hcmd->set_rxon_chain(il, &il->ctx); il_init_scan_params(il); @@ -6126,7 +6090,8 @@ err: return ret; } -static void il4965_uninit_drv(struct il_priv *il) +static void +il4965_uninit_drv(struct il_priv *il) { il4965_calib_free_results(il); il_free_geos(il); @@ -6134,7 +6099,8 @@ static void il4965_uninit_drv(struct il_priv *il) kfree(il->scan_cmd); } -static void il4965_hw_detect(struct il_priv *il) +static void +il4965_hw_detect(struct il_priv *il) { il->hw_rev = _il_rd(il, CSR_HW_REV); il->hw_wa_rev = _il_rd(il, CSR_HW_REV_WA_REG); @@ -6142,7 +6108,8 @@ static void il4965_hw_detect(struct il_priv *il) D_INFO("HW Revision ID = 0x%X\n", il->rev_id); } -static int il4965_set_hw_params(struct il_priv *il) +static int +il4965_set_hw_params(struct il_priv *il) { il->hw_params.max_rxq_size = RX_QUEUE_SIZE; il->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; @@ -6205,10 +6172,8 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) il->ctx.wep_key_cmd = C_WEPKEY; il->ctx.ac_to_fifo = il4965_bss_ac_to_fifo; il->ctx.ac_to_queue = il4965_bss_ac_to_queue; - il->ctx.exclusive_interface_modes = - BIT(NL80211_IFTYPE_ADHOC); - il->ctx.interface_modes = - BIT(NL80211_IFTYPE_STATION); + il->ctx.exclusive_interface_modes = BIT(NL80211_IFTYPE_ADHOC); + il->ctx.interface_modes = BIT(NL80211_IFTYPE_STATION); il->ctx.ap_devtype = RXON_DEV_TYPE_AP; il->ctx.ibss_devtype = RXON_DEV_TYPE_IBSS; il->ctx.station_devtype = RXON_DEV_TYPE_ESS; @@ -6227,8 +6192,9 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) /************************** * 2. Initializing PCI bus **************************/ - pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | - PCIE_LINK_STATE_CLKPM); + pci_disable_link_state(pdev, + PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 | + PCIE_LINK_STATE_CLKPM); if (pci_enable_device(pdev)) { err = -ENODEV; @@ -6243,8 +6209,8 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (err) { err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); if (!err) - err = pci_set_consistent_dma_mask(pdev, - DMA_BIT_MASK(32)); + err = + pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); /* both attempts failed: */ if (err) { IL_WARN("No suitable DMA available.\n"); @@ -6258,7 +6224,6 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) pci_set_drvdata(pdev, il); - /*********************** * 3. Read REV register ***********************/ @@ -6269,7 +6234,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) } D_INFO("pci_resource_len = 0x%08llx\n", - (unsigned long long) pci_resource_len(pdev, 0)); + (unsigned long long)pci_resource_len(pdev, 0)); D_INFO("pci_resource_base = %p\n", il->hw_base); /* these spin locks will be used in apm_ops.init and EEPROM access @@ -6286,8 +6251,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); il4965_hw_detect(il); - IL_INFO("Detected %s, REV=0x%X\n", - il->cfg->name, il->hw_rev); + IL_INFO("Detected %s, REV=0x%X\n", il->cfg->name, il->hw_rev); /* We disable the RETRY_TIMEOUT register (0x41) to keep * PCI Tx retries from interfering with C3 CPU state */ @@ -6347,8 +6311,7 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) pci_enable_msi(il->pci_dev); - err = request_irq(il->pci_dev->irq, il_isr, - IRQF_SHARED, DRV_NAME, il); + err = request_irq(il->pci_dev->irq, il_isr, IRQF_SHARED, DRV_NAME, il); if (err) { IL_ERR("Error allocating IRQ %d\n", il->pci_dev->irq); goto out_disable_msi; @@ -6371,14 +6334,13 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) il_enable_rfkill_int(il); /* If platform's RF_KILL switch is NOT set to KILL */ - if (_il_rd(il, CSR_GP_CNTRL) & - CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) + if (_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW) clear_bit(S_RF_KILL_HW, &il->status); else set_bit(S_RF_KILL_HW, &il->status); wiphy_rfkill_set_hw_state(il->hw->wiphy, - test_bit(S_RF_KILL_HW, &il->status)); + test_bit(S_RF_KILL_HW, &il->status)); il_power_initialize(il); @@ -6390,30 +6352,31 @@ il4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) return 0; - out_destroy_workqueue: +out_destroy_workqueue: destroy_workqueue(il->workqueue); il->workqueue = NULL; free_irq(il->pci_dev->irq, il); - out_disable_msi: +out_disable_msi: pci_disable_msi(il->pci_dev); il4965_uninit_drv(il); - out_free_eeprom: +out_free_eeprom: il_eeprom_free(il); - out_iounmap: +out_iounmap: pci_iounmap(pdev, il->hw_base); - out_pci_release_regions: +out_pci_release_regions: pci_set_drvdata(pdev, NULL); pci_release_regions(pdev); - out_pci_disable_device: +out_pci_disable_device: pci_disable_device(pdev); - out_ieee80211_free_hw: +out_ieee80211_free_hw: il_free_traffic_mem(il); ieee80211_free_hw(il->hw); - out: +out: return err; } -static void __devexit il4965_pci_remove(struct pci_dev *pdev) +static void __devexit +il4965_pci_remove(struct pci_dev *pdev) { struct il_priv *il = pci_get_drvdata(pdev); unsigned long flags; @@ -6469,7 +6432,6 @@ static void __devexit il4965_pci_remove(struct pci_dev *pdev) il_eeprom_free(il); - /*netif_stop_queue(dev); */ flush_workqueue(il->workqueue); @@ -6498,7 +6460,8 @@ static void __devexit il4965_pci_remove(struct pci_dev *pdev) * Activate/Deactivate Tx DMA/FIFO channels according tx fifos mask * must be called under il->lock and mac access */ -void il4965_txq_set_sched(struct il_priv *il, u32 mask) +void +il4965_txq_set_sched(struct il_priv *il, u32 mask) { il_wr_prph(il, IL49_SCD_TXFACT, mask); } @@ -6525,7 +6488,8 @@ static struct pci_driver il4965_driver = { .driver.pm = IL_LEGACY_PM_OPS, }; -static int __init il4965_init(void) +static int __init +il4965_init(void) { int ret; @@ -6551,7 +6515,8 @@ error_register: return ret; } -static void __exit il4965_exit(void) +static void __exit +il4965_exit(void) { pci_unregister_driver(&il4965_driver); il4965_rate_control_unregister(); @@ -6571,8 +6536,8 @@ module_param_named(queues_num, il4965_mod_params.num_of_queues, int, S_IRUGO); MODULE_PARM_DESC(queues_num, "number of hw queues."); module_param_named(11n_disable, il4965_mod_params.disable_11n, int, S_IRUGO); MODULE_PARM_DESC(11n_disable, "disable 11n functionality"); -module_param_named(amsdu_size_8K, il4965_mod_params.amsdu_size_8K, - int, S_IRUGO); +module_param_named(amsdu_size_8K, il4965_mod_params.amsdu_size_8K, int, + S_IRUGO); MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size"); module_param_named(fw_restart, il4965_mod_params.restart_fw, int, S_IRUGO); MODULE_PARM_DESC(fw_restart, "restart firmware in case of error"); diff --git a/drivers/net/wireless/iwlegacy/4965-rs.c b/drivers/net/wireless/iwlegacy/4965-rs.c index f9db9df21321..3ea236157058 100644 --- a/drivers/net/wireless/iwlegacy/4965-rs.c +++ b/drivers/net/wireless/iwlegacy/4965-rs.c @@ -95,22 +95,23 @@ static const u8 ant_toggle_lookup[] = { * */ const struct il_rate_info il_rates[RATE_COUNT] = { - IL_DECLARE_RATE_INFO(1, INV, INV, 2, INV, 2, INV, 2), /* 1mbps */ - IL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ - IL_DECLARE_RATE_INFO(5, INV, 2, 6, 2, 11, 2, 11), /*5.5mbps */ - IL_DECLARE_RATE_INFO(11, INV, 9, 12, 9, 12, 5, 18), /* 11mbps */ - IL_DECLARE_RATE_INFO(6, 6, 5, 9, 5, 11, 5, 11), /* 6mbps */ - IL_DECLARE_RATE_INFO(9, 6, 6, 11, 6, 11, 5, 11), /* 9mbps */ - IL_DECLARE_RATE_INFO(12, 12, 11, 18, 11, 18, 11, 18), /* 12mbps */ - IL_DECLARE_RATE_INFO(18, 18, 12, 24, 12, 24, 11, 24), /* 18mbps */ - IL_DECLARE_RATE_INFO(24, 24, 18, 36, 18, 36, 18, 36), /* 24mbps */ - IL_DECLARE_RATE_INFO(36, 36, 24, 48, 24, 48, 24, 48), /* 36mbps */ - IL_DECLARE_RATE_INFO(48, 48, 36, 54, 36, 54, 36, 54), /* 48mbps */ - IL_DECLARE_RATE_INFO(54, 54, 48, INV, 48, INV, 48, INV),/* 54mbps */ - IL_DECLARE_RATE_INFO(60, 60, 48, INV, 48, INV, 48, INV),/* 60mbps */ + IL_DECLARE_RATE_INFO(1, INV, INV, 2, INV, 2, INV, 2), /* 1mbps */ + IL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ + IL_DECLARE_RATE_INFO(5, INV, 2, 6, 2, 11, 2, 11), /*5.5mbps */ + IL_DECLARE_RATE_INFO(11, INV, 9, 12, 9, 12, 5, 18), /* 11mbps */ + IL_DECLARE_RATE_INFO(6, 6, 5, 9, 5, 11, 5, 11), /* 6mbps */ + IL_DECLARE_RATE_INFO(9, 6, 6, 11, 6, 11, 5, 11), /* 9mbps */ + IL_DECLARE_RATE_INFO(12, 12, 11, 18, 11, 18, 11, 18), /* 12mbps */ + IL_DECLARE_RATE_INFO(18, 18, 12, 24, 12, 24, 11, 24), /* 18mbps */ + IL_DECLARE_RATE_INFO(24, 24, 18, 36, 18, 36, 18, 36), /* 24mbps */ + IL_DECLARE_RATE_INFO(36, 36, 24, 48, 24, 48, 24, 48), /* 36mbps */ + IL_DECLARE_RATE_INFO(48, 48, 36, 54, 36, 54, 36, 54), /* 48mbps */ + IL_DECLARE_RATE_INFO(54, 54, 48, INV, 48, INV, 48, INV), /* 54mbps */ + IL_DECLARE_RATE_INFO(60, 60, 48, INV, 48, INV, 48, INV), /* 60mbps */ }; -static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags) +static int +il4965_hwrate_to_plcp_idx(u32 rate_n_flags) { int idx = 0; @@ -122,13 +123,13 @@ static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags) idx = idx - RATE_MIMO2_6M_PLCP; idx += IL_FIRST_OFDM_RATE; - /* skip 9M not supported in ht*/ + /* skip 9M not supported in ht */ if (idx >= RATE_9M_IDX) idx += 1; if (idx >= IL_FIRST_OFDM_RATE && idx <= IL_LAST_OFDM_RATE) return idx; - /* legacy rate format, search for match in table */ + /* legacy rate format, search for match in table */ } else { for (idx = 0; idx < ARRAY_SIZE(il_rates); idx++) if (il_rates[idx].plcp == (rate_n_flags & 0xFF)) @@ -139,21 +140,22 @@ static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags) } static void il4965_rs_rate_scale_perform(struct il_priv *il, - struct sk_buff *skb, - struct ieee80211_sta *sta, - struct il_lq_sta *lq_sta); + struct sk_buff *skb, + struct ieee80211_sta *sta, + struct il_lq_sta *lq_sta); static void il4965_rs_fill_link_cmd(struct il_priv *il, - struct il_lq_sta *lq_sta, u32 rate_n_flags); + struct il_lq_sta *lq_sta, u32 rate_n_flags); static void il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, - bool force_search); + bool force_search); #ifdef CONFIG_MAC80211_DEBUGFS static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, - u32 *rate_n_flags, int idx); + u32 * rate_n_flags, int idx); #else -static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, - u32 *rate_n_flags, int idx) -{} +static void +il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, u32 * rate_n_flags, int idx) +{ +} #endif /** @@ -172,55 +174,56 @@ static s32 expected_tpt_legacy[RATE_COUNT] = { }; static s32 expected_tpt_siso20MHz[4][RATE_COUNT] = { - {0, 0, 0, 0, 42, 0, 76, 102, 124, 158, 183, 193, 202}, /* Norm */ - {0, 0, 0, 0, 46, 0, 82, 110, 132, 167, 192, 202, 210}, /* SGI */ - {0, 0, 0, 0, 48, 0, 93, 135, 176, 251, 319, 351, 381}, /* AGG */ - {0, 0, 0, 0, 53, 0, 102, 149, 193, 275, 348, 381, 413}, /* AGG+SGI */ + {0, 0, 0, 0, 42, 0, 76, 102, 124, 158, 183, 193, 202}, /* Norm */ + {0, 0, 0, 0, 46, 0, 82, 110, 132, 167, 192, 202, 210}, /* SGI */ + {0, 0, 0, 0, 48, 0, 93, 135, 176, 251, 319, 351, 381}, /* AGG */ + {0, 0, 0, 0, 53, 0, 102, 149, 193, 275, 348, 381, 413}, /* AGG+SGI */ }; static s32 expected_tpt_siso40MHz[4][RATE_COUNT] = { - {0, 0, 0, 0, 77, 0, 127, 160, 184, 220, 242, 250, 257}, /* Norm */ - {0, 0, 0, 0, 83, 0, 135, 169, 193, 229, 250, 257, 264}, /* SGI */ - {0, 0, 0, 0, 96, 0, 182, 259, 328, 451, 553, 598, 640}, /* AGG */ - {0, 0, 0, 0, 106, 0, 199, 282, 357, 487, 593, 640, 683}, /* AGG+SGI */ + {0, 0, 0, 0, 77, 0, 127, 160, 184, 220, 242, 250, 257}, /* Norm */ + {0, 0, 0, 0, 83, 0, 135, 169, 193, 229, 250, 257, 264}, /* SGI */ + {0, 0, 0, 0, 96, 0, 182, 259, 328, 451, 553, 598, 640}, /* AGG */ + {0, 0, 0, 0, 106, 0, 199, 282, 357, 487, 593, 640, 683}, /* AGG+SGI */ }; static s32 expected_tpt_mimo2_20MHz[4][RATE_COUNT] = { - {0, 0, 0, 0, 74, 0, 123, 155, 179, 213, 235, 243, 250}, /* Norm */ - {0, 0, 0, 0, 81, 0, 131, 164, 187, 221, 242, 250, 256}, /* SGI */ - {0, 0, 0, 0, 92, 0, 175, 250, 317, 436, 534, 578, 619}, /* AGG */ - {0, 0, 0, 0, 102, 0, 192, 273, 344, 470, 573, 619, 660}, /* AGG+SGI*/ + {0, 0, 0, 0, 74, 0, 123, 155, 179, 213, 235, 243, 250}, /* Norm */ + {0, 0, 0, 0, 81, 0, 131, 164, 187, 221, 242, 250, 256}, /* SGI */ + {0, 0, 0, 0, 92, 0, 175, 250, 317, 436, 534, 578, 619}, /* AGG */ + {0, 0, 0, 0, 102, 0, 192, 273, 344, 470, 573, 619, 660}, /* AGG+SGI */ }; static s32 expected_tpt_mimo2_40MHz[4][RATE_COUNT] = { - {0, 0, 0, 0, 123, 0, 182, 214, 235, 264, 279, 285, 289}, /* Norm */ - {0, 0, 0, 0, 131, 0, 191, 222, 242, 270, 284, 289, 293}, /* SGI */ - {0, 0, 0, 0, 180, 0, 327, 446, 545, 708, 828, 878, 922}, /* AGG */ - {0, 0, 0, 0, 197, 0, 355, 481, 584, 752, 872, 922, 966}, /* AGG+SGI */ + {0, 0, 0, 0, 123, 0, 182, 214, 235, 264, 279, 285, 289}, /* Norm */ + {0, 0, 0, 0, 131, 0, 191, 222, 242, 270, 284, 289, 293}, /* SGI */ + {0, 0, 0, 0, 180, 0, 327, 446, 545, 708, 828, 878, 922}, /* AGG */ + {0, 0, 0, 0, 197, 0, 355, 481, 584, 752, 872, 922, 966}, /* AGG+SGI */ }; /* mbps, mcs */ static const struct il_rate_mcs_info il_rate_mcs[RATE_COUNT] = { - { "1", "BPSK DSSS"}, - { "2", "QPSK DSSS"}, + {"1", "BPSK DSSS"}, + {"2", "QPSK DSSS"}, {"5.5", "BPSK CCK"}, - { "11", "QPSK CCK"}, - { "6", "BPSK 1/2"}, - { "9", "BPSK 1/2"}, - { "12", "QPSK 1/2"}, - { "18", "QPSK 3/4"}, - { "24", "16QAM 1/2"}, - { "36", "16QAM 3/4"}, - { "48", "64QAM 2/3"}, - { "54", "64QAM 3/4"}, - { "60", "64QAM 5/6"}, + {"11", "QPSK CCK"}, + {"6", "BPSK 1/2"}, + {"9", "BPSK 1/2"}, + {"12", "QPSK 1/2"}, + {"18", "QPSK 3/4"}, + {"24", "16QAM 1/2"}, + {"36", "16QAM 3/4"}, + {"48", "64QAM 2/3"}, + {"54", "64QAM 3/4"}, + {"60", "64QAM 5/6"}, }; #define MCS_IDX_PER_STREAM (8) -static inline u8 il4965_rs_extract_rate(u32 rate_n_flags) +static inline u8 +il4965_rs_extract_rate(u32 rate_n_flags) { - return (u8)(rate_n_flags & 0xFF); + return (u8) (rate_n_flags & 0xFF); } static void @@ -234,7 +237,8 @@ il4965_rs_rate_scale_clear_win(struct il_rate_scale_data *win) win->stamp = 0; } -static inline u8 il4965_rs_is_valid_ant(u8 valid_antenna, u8 ant_type) +static inline u8 +il4965_rs_is_valid_ant(u8 valid_antenna, u8 ant_type) { return (ant_type & valid_antenna) == ant_type; } @@ -264,8 +268,8 @@ il4965_rs_tl_rm_old_stats(struct il_traffic_load *tl, u32 curr_time) * increment traffic load value for tid and also remove * any old values if passed the certain time period */ -static u8 il4965_rs_tl_add_packet(struct il_lq_sta *lq_data, - struct ieee80211_hdr *hdr) +static u8 +il4965_rs_tl_add_packet(struct il_lq_sta *lq_data, struct ieee80211_hdr *hdr) { u32 curr_time = jiffies_to_msecs(jiffies); u32 time_diff; @@ -317,7 +321,8 @@ static u8 il4965_rs_tl_add_packet(struct il_lq_sta *lq_data, /* get the traffic load value for tid */ -static u32 il4965_rs_tl_get_load(struct il_lq_sta *lq_data, u8 tid) +static u32 +il4965_rs_tl_get_load(struct il_lq_sta *lq_data, u8 tid) { u32 curr_time = jiffies_to_msecs(jiffies); u32 time_diff; @@ -345,9 +350,9 @@ static u32 il4965_rs_tl_get_load(struct il_lq_sta *lq_data, u8 tid) return tl->total; } -static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *il, - struct il_lq_sta *lq_data, u8 tid, - struct ieee80211_sta *sta) +static int +il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *il, struct il_lq_sta *lq_data, + u8 tid, struct ieee80211_sta *sta) { int ret = -EAGAIN; u32 load; @@ -355,8 +360,7 @@ static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *il, load = il4965_rs_tl_get_load(lq_data, tid); if (load > IL_AGG_LOAD_THRESHOLD) { - D_HT("Starting Tx agg: STA: %pM tid: %d\n", - sta->addr, tid); + D_HT("Starting Tx agg: STA: %pM tid: %d\n", sta->addr, tid); ret = ieee80211_start_tx_ba_session(sta, tid, 5000); if (ret == -EAGAIN) { /* @@ -364,33 +368,33 @@ static int il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *il, * this might be cause by reloading firmware * stop the tx ba session here */ - IL_ERR("Fail start Tx agg on tid: %d\n", - tid); + IL_ERR("Fail start Tx agg on tid: %d\n", tid); ieee80211_stop_tx_ba_session(sta, tid); } } else { IL_ERR("Aggregation not enabled for tid %d " - "because load = %u\n", tid, load); + "because load = %u\n", tid, load); } return ret; } -static void il4965_rs_tl_turn_on_agg(struct il_priv *il, u8 tid, - struct il_lq_sta *lq_data, - struct ieee80211_sta *sta) +static void +il4965_rs_tl_turn_on_agg(struct il_priv *il, u8 tid, struct il_lq_sta *lq_data, + struct ieee80211_sta *sta) { if (tid < TID_MAX_LOAD_COUNT) il4965_rs_tl_turn_on_agg_for_tid(il, lq_data, tid, sta); else - IL_ERR("tid exceeds max load count: %d/%d\n", - tid, TID_MAX_LOAD_COUNT); + IL_ERR("tid exceeds max load count: %d/%d\n", tid, + TID_MAX_LOAD_COUNT); } -static inline int il4965_get_il4965_num_of_ant_from_rate(u32 rate_n_flags) +static inline int +il4965_get_il4965_num_of_ant_from_rate(u32 rate_n_flags) { return !!(rate_n_flags & RATE_MCS_ANT_A_MSK) + - !!(rate_n_flags & RATE_MCS_ANT_B_MSK) + - !!(rate_n_flags & RATE_MCS_ANT_C_MSK); + !!(rate_n_flags & RATE_MCS_ANT_B_MSK) + + !!(rate_n_flags & RATE_MCS_ANT_C_MSK); } /* @@ -412,11 +416,12 @@ il4965_get_expected_tpt(struct il_scale_tbl_info *tbl, int rs_idx) * at this rate. win->data contains the bitmask of successful * packets. */ -static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, - int scale_idx, int attempts, int successes) +static int +il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, int scale_idx, + int attempts, int successes) { struct il_rate_scale_data *win = NULL; - static const u64 mask = (((u64)1) << (RATE_MAX_WINDOW - 1)); + static const u64 mask = (((u64) 1) << (RATE_MAX_WINDOW - 1)); s32 fail_count, tpt; if (scale_idx < 0 || scale_idx >= RATE_COUNT) @@ -466,8 +471,8 @@ static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, /* Calculate current success ratio, avoid divide-by-0! */ if (win->counter > 0) - win->success_ratio = 128 * (100 * win->success_counter) - / win->counter; + win->success_ratio = + 128 * (100 * win->success_counter) / win->counter; else win->success_ratio = IL_INVALID_VALUE; @@ -489,9 +494,9 @@ static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl, /* * Fill uCode API rate_n_flags field, based on "search" or "active" table. */ -static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, - struct il_scale_tbl_info *tbl, - int idx, u8 use_green) +static u32 +il4965_rate_n_flags_from_tbl(struct il_priv *il, struct il_scale_tbl_info *tbl, + int idx, u8 use_green) { u32 rate_n_flags = 0; @@ -508,15 +513,15 @@ static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, rate_n_flags = RATE_MCS_HT_MSK; if (is_siso(tbl->lq_type)) - rate_n_flags |= il_rates[idx].plcp_siso; + rate_n_flags |= il_rates[idx].plcp_siso; else - rate_n_flags |= il_rates[idx].plcp_mimo2; + rate_n_flags |= il_rates[idx].plcp_mimo2; } else { IL_ERR("Invalid tbl->lq_type %d\n", tbl->lq_type); } - rate_n_flags |= ((tbl->ant_type << RATE_MCS_ANT_POS) & - RATE_MCS_ANT_ABC_MSK); + rate_n_flags |= + ((tbl->ant_type << RATE_MCS_ANT_POS) & RATE_MCS_ANT_ABC_MSK); if (is_Ht(tbl->lq_type)) { if (tbl->is_ht40) { @@ -543,19 +548,20 @@ static u32 il4965_rate_n_flags_from_tbl(struct il_priv *il, * Interpret uCode API's rate_n_flags format, * fill "search" or "active" tx mode table. */ -static int il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, - enum ieee80211_band band, - struct il_scale_tbl_info *tbl, - int *rate_idx) +static int +il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, + enum ieee80211_band band, + struct il_scale_tbl_info *tbl, int *rate_idx) { u32 ant_msk = (rate_n_flags & RATE_MCS_ANT_ABC_MSK); - u8 il4965_num_of_ant = il4965_get_il4965_num_of_ant_from_rate(rate_n_flags); + u8 il4965_num_of_ant = + il4965_get_il4965_num_of_ant_from_rate(rate_n_flags); u8 mcs; memset(tbl, 0, sizeof(struct il_scale_tbl_info)); *rate_idx = il4965_hwrate_to_plcp_idx(rate_n_flags); - if (*rate_idx == RATE_INVALID) { + if (*rate_idx == RATE_INVALID) { *rate_idx = -1; return -EINVAL; } @@ -574,7 +580,7 @@ static int il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, else tbl->lq_type = LQ_G; } - /* HT rate format */ + /* HT rate format */ } else { if (rate_n_flags & RATE_MCS_SGI_MSK) tbl->is_SGI = 1; @@ -591,8 +597,8 @@ static int il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, /* SISO */ if (mcs <= RATE_SISO_60M_PLCP) { if (il4965_num_of_ant == 1) - tbl->lq_type = LQ_SISO; /*else NONE*/ - /* MIMO2 */ + tbl->lq_type = LQ_SISO; /*else NONE */ + /* MIMO2 */ } else { if (il4965_num_of_ant == 2) tbl->lq_type = LQ_MIMO2; @@ -603,8 +609,9 @@ static int il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, /* switch to another antenna/antennas and return 1 */ /* if no other valid antenna found, return 0 */ -static int il4965_rs_toggle_antenna(u32 valid_ant, u32 *rate_n_flags, - struct il_scale_tbl_info *tbl) +static int +il4965_rs_toggle_antenna(u32 valid_ant, u32 * rate_n_flags, + struct il_scale_tbl_info *tbl) { u8 new_ant_type; @@ -633,13 +640,14 @@ static int il4965_rs_toggle_antenna(u32 valid_ant, u32 *rate_n_flags, * Green-field mode is valid if the station supports it and * there are no non-GF stations present in the BSS. */ -static bool il4965_rs_use_green(struct ieee80211_sta *sta) +static bool +il4965_rs_use_green(struct ieee80211_sta *sta) { struct il_station_priv *sta_priv = (void *)sta->drv_priv; struct il_rxon_context *ctx = sta_priv->common.ctx; return (sta->ht_cap.cap & IEEE80211_HT_CAP_GRN_FLD) && - !(ctx->ht.non_gf_sta_present); + !(ctx->ht.non_gf_sta_present); } /** @@ -649,9 +657,10 @@ static bool il4965_rs_use_green(struct ieee80211_sta *sta) * basic available rates. * */ -static u16 il4965_rs_get_supported_rates(struct il_lq_sta *lq_sta, - struct ieee80211_hdr *hdr, - enum il_table_type rate_type) +static u16 +il4965_rs_get_supported_rates(struct il_lq_sta *lq_sta, + struct ieee80211_hdr *hdr, + enum il_table_type rate_type) { if (is_legacy(rate_type)) { return lq_sta->active_legacy_rate; @@ -665,7 +674,7 @@ static u16 il4965_rs_get_supported_rates(struct il_lq_sta *lq_sta, static u16 il4965_rs_get_adjacent_rate(struct il_priv *il, u8 idx, u16 rate_mask, - int rate_type) + int rate_type) { u8 high = RATE_INVALID; u8 low = RATE_INVALID; @@ -720,9 +729,10 @@ il4965_rs_get_adjacent_rate(struct il_priv *il, u8 idx, u16 rate_mask, return (high << 8) | low; } -static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, - struct il_scale_tbl_info *tbl, - u8 scale_idx, u8 ht_possible) +static u32 +il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, + struct il_scale_tbl_info *tbl, u8 scale_idx, + u8 ht_possible) { s32 low; u16 rate_mask; @@ -744,7 +754,7 @@ static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, if (il4965_num_of_ant(tbl->ant_type) > 1) tbl->ant_type = - il4965_first_antenna(il->hw_params.valid_tx_ant); + il4965_first_antenna(il->hw_params.valid_tx_ant); tbl->is_ht40 = 0; tbl->is_SGI = 0; @@ -757,10 +767,11 @@ static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, if (is_legacy(tbl->lq_type)) { /* supp_rates has no CCK bits in A mode */ if (lq_sta->band == IEEE80211_BAND_5GHZ) - rate_mask = (u16)(rate_mask & - (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); + rate_mask = + (u16) (rate_mask & + (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); else - rate_mask = (u16)(rate_mask & lq_sta->supp_rates); + rate_mask = (u16) (rate_mask & lq_sta->supp_rates); } /* If we switched from HT to legacy, check current rate */ @@ -769,8 +780,8 @@ static u32 il4965_rs_get_lower_rate(struct il_lq_sta *lq_sta, goto out; } - high_low = il4965_rs_get_adjacent_rate(lq_sta->drv, - scale_idx, rate_mask, + high_low = + il4965_rs_get_adjacent_rate(lq_sta->drv, scale_idx, rate_mask, tbl->lq_type); low = high_low & 0xff; @@ -784,8 +795,9 @@ out: /* * Simple function to compare two rate scale table types */ -static bool il4965_table_type_matches(struct il_scale_tbl_info *a, - struct il_scale_tbl_info *b) +static bool +il4965_table_type_matches(struct il_scale_tbl_info *a, + struct il_scale_tbl_info *b) { return (a->lq_type == b->lq_type && a->ant_type == b->ant_type && a->is_SGI == b->is_SGI); @@ -796,8 +808,8 @@ static bool il4965_table_type_matches(struct il_scale_tbl_info *a, */ static void il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, - struct ieee80211_sta *sta, void *il_sta, - struct sk_buff *skb) + struct ieee80211_sta *sta, void *il_sta, + struct sk_buff *skb) { int legacy_success; int retries; @@ -814,8 +826,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, struct il_station_priv *sta_priv = (void *)sta->drv_priv; struct il_rxon_context *ctx = sta_priv->common.ctx; - D_RATE( - "get frame ack response, update rate scale win\n"); + D_RATE("get frame ack response, update rate scale win\n"); /* Treat uninitialized rate scaling data same as non-existing. */ if (!lq_sta) { @@ -845,8 +856,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, */ table = &lq_sta->lq; tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); - il4965_rs_get_tbl_info_from_mcs(tx_rate, - il->band, &tbl_type, &rs_idx); + il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, &tbl_type, &rs_idx); if (il->band == IEEE80211_BAND_5GHZ) rs_idx -= IL_FIRST_OFDM_RATE; mac_flags = info->status.rates[0].flags; @@ -869,12 +879,11 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, tbl_type.is_ht40 != !!(mac_flags & IEEE80211_TX_RC_40_MHZ_WIDTH) || tbl_type.is_dup != !!(mac_flags & IEEE80211_TX_RC_DUP_DATA) || tbl_type.ant_type != info->antenna_sel_tx || - !!(tx_rate & RATE_MCS_HT_MSK) != !!(mac_flags & IEEE80211_TX_RC_MCS) || - !!(tx_rate & RATE_MCS_GF_MSK) != !!(mac_flags & IEEE80211_TX_RC_GREEN_FIELD) || - rs_idx != mac_idx) { - D_RATE( - "initial rate %d does not match %d (0x%x)\n", - mac_idx, rs_idx, tx_rate); + !!(tx_rate & RATE_MCS_HT_MSK) != !!(mac_flags & IEEE80211_TX_RC_MCS) + || !!(tx_rate & RATE_MCS_GF_MSK) != + !!(mac_flags & IEEE80211_TX_RC_GREEN_FIELD) || rs_idx != mac_idx) { + D_RATE("initial rate %d does not match %d (0x%x)\n", mac_idx, + rs_idx, tx_rate); /* * Since rates mis-match, the last LQ command may have failed. * After IL_MISSED_RATE_MAX mis-matches, resync the uCode with @@ -883,8 +892,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, lq_sta->missed_rate_counter++; if (lq_sta->missed_rate_counter > IL_MISSED_RATE_MAX) { lq_sta->missed_rate_counter = 0; - il_send_lq_cmd(il, ctx, &lq_sta->lq, - CMD_ASYNC, false); + il_send_lq_cmd(il, ctx, &lq_sta->lq, CMD_ASYNC, false); } /* Regardless, ignore this status info for outdated rate */ return; @@ -893,25 +901,25 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, lq_sta->missed_rate_counter = 0; /* Figure out if rate scale algorithm is in active or search table */ - if (il4965_table_type_matches(&tbl_type, - &(lq_sta->lq_info[lq_sta->active_tbl]))) { + if (il4965_table_type_matches + (&tbl_type, &(lq_sta->lq_info[lq_sta->active_tbl]))) { curr_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); other_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); - } else if (il4965_table_type_matches(&tbl_type, - &lq_sta->lq_info[1 - lq_sta->active_tbl])) { + } else + if (il4965_table_type_matches + (&tbl_type, &lq_sta->lq_info[1 - lq_sta->active_tbl])) { curr_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); other_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); } else { - D_RATE( - "Neither active nor search matches tx rate\n"); + D_RATE("Neither active nor search matches tx rate\n"); tmp_tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); - D_RATE("active- lq:%x, ant:%x, SGI:%d\n", - tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); + D_RATE("active- lq:%x, ant:%x, SGI:%d\n", tmp_tbl->lq_type, + tmp_tbl->ant_type, tmp_tbl->is_SGI); tmp_tbl = &(lq_sta->lq_info[1 - lq_sta->active_tbl]); - D_RATE("search- lq:%x, ant:%x, SGI:%d\n", - tmp_tbl->lq_type, tmp_tbl->ant_type, tmp_tbl->is_SGI); - D_RATE("actual- lq:%x, ant:%x, SGI:%d\n", - tbl_type.lq_type, tbl_type.ant_type, tbl_type.is_SGI); + D_RATE("search- lq:%x, ant:%x, SGI:%d\n", tmp_tbl->lq_type, + tmp_tbl->ant_type, tmp_tbl->is_SGI); + D_RATE("actual- lq:%x, ant:%x, SGI:%d\n", tbl_type.lq_type, + tbl_type.ant_type, tbl_type.is_SGI); /* * no matching table found, let's by-pass the data collection * and continue to perform rate scale to find the rate table @@ -930,21 +938,22 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, if (info->flags & IEEE80211_TX_STAT_AMPDU) { tx_rate = le32_to_cpu(table->rs_table[0].rate_n_flags); il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, &tbl_type, - &rs_idx); + &rs_idx); il4965_rs_collect_tx_data(curr_tbl, rs_idx, - info->status.ampdu_len, - info->status.ampdu_ack_len); + info->status.ampdu_len, + info->status.ampdu_ack_len); /* Update success/fail counts if not searching for new mode */ if (lq_sta->stay_in_tbl) { lq_sta->total_success += info->status.ampdu_ack_len; - lq_sta->total_failed += (info->status.ampdu_len - - info->status.ampdu_ack_len); + lq_sta->total_failed += + (info->status.ampdu_len - + info->status.ampdu_ack_len); } } else { - /* - * For legacy, update frame history with for each Tx retry. - */ + /* + * For legacy, update frame history with for each Tx retry. + */ retries = info->status.rates[0].count - 1; /* HW doesn't send more than 15 retries */ retries = min(retries, 15); @@ -955,20 +964,21 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, for (i = 0; i <= retries; ++i) { tx_rate = le32_to_cpu(table->rs_table[i].rate_n_flags); il4965_rs_get_tbl_info_from_mcs(tx_rate, il->band, - &tbl_type, &rs_idx); + &tbl_type, &rs_idx); /* * Only collect stats if retried rate is in the same RS * table as active/search. */ if (il4965_table_type_matches(&tbl_type, curr_tbl)) tmp_tbl = curr_tbl; - else if (il4965_table_type_matches(&tbl_type, - other_tbl)) + else if (il4965_table_type_matches + (&tbl_type, other_tbl)) tmp_tbl = other_tbl; else continue; il4965_rs_collect_tx_data(tmp_tbl, rs_idx, 1, - i < retries ? 0 : legacy_success); + i < + retries ? 0 : legacy_success); } /* Update success/fail counts if not searching for new mode */ @@ -993,8 +1003,9 @@ done: * These control how long we stay using same modulation mode before * searching for a new mode. */ -static void il4965_rs_set_stay_in_table(struct il_priv *il, u8 is_legacy, - struct il_lq_sta *lq_sta) +static void +il4965_rs_set_stay_in_table(struct il_priv *il, u8 is_legacy, + struct il_lq_sta *lq_sta) { D_RATE("we are staying in the same table\n"); lq_sta->stay_in_tbl = 1; /* only place this gets set */ @@ -1017,11 +1028,12 @@ static void il4965_rs_set_stay_in_table(struct il_priv *il, u8 is_legacy, /* * Find correct throughput table for given mode of modulation */ -static void il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, - struct il_scale_tbl_info *tbl) +static void +il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, + struct il_scale_tbl_info *tbl) { /* Used to choose among HT tables */ - s32 (*ht_tbl_pointer)[RATE_COUNT]; + s32(*ht_tbl_pointer)[RATE_COUNT]; /* Check for invalid LQ type */ if (WARN_ON_ONCE(!is_legacy(tbl->lq_type) && !is_Ht(tbl->lq_type))) { @@ -1044,16 +1056,16 @@ static void il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, ht_tbl_pointer = expected_tpt_siso40MHz; else if (is_mimo2(tbl->lq_type) && (!tbl->is_ht40 || lq_sta->is_dup)) ht_tbl_pointer = expected_tpt_mimo2_20MHz; - else /* if (is_mimo2(tbl->lq_type)) <-- must be true */ + else /* if (is_mimo2(tbl->lq_type)) <-- must be true */ ht_tbl_pointer = expected_tpt_mimo2_40MHz; - if (!tbl->is_SGI && !lq_sta->is_agg) /* Normal */ + if (!tbl->is_SGI && !lq_sta->is_agg) /* Normal */ tbl->expected_tpt = ht_tbl_pointer[0]; else if (tbl->is_SGI && !lq_sta->is_agg) /* SGI */ tbl->expected_tpt = ht_tbl_pointer[1]; else if (!tbl->is_SGI && lq_sta->is_agg) /* AGG */ tbl->expected_tpt = ht_tbl_pointer[2]; - else /* AGG+SGI */ + else /* AGG+SGI */ tbl->expected_tpt = ht_tbl_pointer[3]; } @@ -1069,10 +1081,9 @@ static void il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, * to decrease to match "active" throughput. When moving from MIMO to SISO, * bit rate will typically need to increase, but not if performance was bad. */ -static s32 il4965_rs_get_best_rate(struct il_priv *il, - struct il_lq_sta *lq_sta, - struct il_scale_tbl_info *tbl, /* "search" */ - u16 rate_mask, s8 idx) +static s32 +il4965_rs_get_best_rate(struct il_priv *il, struct il_lq_sta *lq_sta, struct il_scale_tbl_info *tbl, /* "search" */ + u16 rate_mask, s8 idx) { /* "active" values */ struct il_scale_tbl_info *active_tbl = @@ -1089,8 +1100,9 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il, new_rate = high = low = start_hi = RATE_INVALID; - for (; ;) { - high_low = il4965_rs_get_adjacent_rate(il, rate, rate_mask, + for (;;) { + high_low = + il4965_rs_get_adjacent_rate(il, rate, rate_mask, tbl->lq_type); low = high_low & 0xff; @@ -1112,9 +1124,8 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il, * "active" throughput (under perfect conditions). */ if ((100 * tpt_tbl[rate] > lq_sta->last_tpt && - (active_sr > RATE_DECREASE_TH && - active_sr <= RATE_HIGH_TH && - tpt_tbl[rate] <= active_tpt)) || + (active_sr > RATE_DECREASE_TH && active_sr <= RATE_HIGH_TH + && tpt_tbl[rate] <= active_tpt)) || (active_sr >= RATE_SCALE_SWITCH && tpt_tbl[rate] > active_tpt)) { @@ -1136,7 +1147,7 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il, else break; - /* Else try to raise the "search" rate to match "active" */ + /* Else try to raise the "search" rate to match "active" */ } else { /* (2nd or later pass) * If we've already tried to lower the rate, and are @@ -1149,7 +1160,7 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il, start_hi = high; rate = high; - /* Higher rate not available, use the original */ + /* Higher rate not available, use the original */ } else { new_rate = rate; break; @@ -1163,11 +1174,11 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il, /* * Set up search table for MIMO2 */ -static int il4965_rs_switch_to_mimo2(struct il_priv *il, - struct il_lq_sta *lq_sta, - struct ieee80211_conf *conf, - struct ieee80211_sta *sta, - struct il_scale_tbl_info *tbl, int idx) +static int +il4965_rs_switch_to_mimo2(struct il_priv *il, struct il_lq_sta *lq_sta, + struct ieee80211_conf *conf, + struct ieee80211_sta *sta, + struct il_scale_tbl_info *tbl, int idx) { u16 rate_mask; s32 rate; @@ -1178,8 +1189,8 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *il, if (!conf_is_ht(conf) || !sta->ht_cap.ht_supported) return -1; - if (((sta->ht_cap.cap & IEEE80211_HT_CAP_SM_PS) >> 2) - == WLAN_HT_CAP_SM_PS_STATIC) + if (((sta->ht_cap.cap & IEEE80211_HT_CAP_SM_PS) >> 2) == + WLAN_HT_CAP_SM_PS_STATIC) return -1; /* Need both Tx chains/antennas to support MIMO */ @@ -1203,30 +1214,27 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *il, rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, idx); - D_RATE("LQ: MIMO2 best rate %d mask %X\n", - rate, rate_mask); + D_RATE("LQ: MIMO2 best rate %d mask %X\n", rate, rate_mask); if (rate == RATE_INVALID || !((1 << rate) & rate_mask)) { - D_RATE( - "Can't switch with idx %d rate mask %x\n", - rate, rate_mask); + D_RATE("Can't switch with idx %d rate mask %x\n", rate, + rate_mask); return -1; } - tbl->current_rate = il4965_rate_n_flags_from_tbl(il, - tbl, rate, is_green); + tbl->current_rate = + il4965_rate_n_flags_from_tbl(il, tbl, rate, is_green); - D_RATE("LQ: Switch to new mcs %X idx is green %X\n", - tbl->current_rate, is_green); + D_RATE("LQ: Switch to new mcs %X idx is green %X\n", tbl->current_rate, + is_green); return 0; } /* * Set up search table for SISO */ -static int il4965_rs_switch_to_siso(struct il_priv *il, - struct il_lq_sta *lq_sta, - struct ieee80211_conf *conf, - struct ieee80211_sta *sta, - struct il_scale_tbl_info *tbl, int idx) +static int +il4965_rs_switch_to_siso(struct il_priv *il, struct il_lq_sta *lq_sta, + struct ieee80211_conf *conf, struct ieee80211_sta *sta, + struct il_scale_tbl_info *tbl, int idx) { u16 rate_mask; u8 is_green = lq_sta->is_green; @@ -1251,40 +1259,39 @@ static int il4965_rs_switch_to_siso(struct il_priv *il, tbl->is_ht40 = 0; if (is_green) - tbl->is_SGI = 0; /*11n spec: no SGI in SISO+Greenfield*/ + tbl->is_SGI = 0; /*11n spec: no SGI in SISO+Greenfield */ il4965_rs_set_expected_tpt_table(lq_sta, tbl); rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, idx); D_RATE("LQ: get best rate %d mask %X\n", rate, rate_mask); if (rate == RATE_INVALID || !((1 << rate) & rate_mask)) { - D_RATE( - "can not switch with idx %d rate mask %x\n", - rate, rate_mask); + D_RATE("can not switch with idx %d rate mask %x\n", rate, + rate_mask); return -1; } - tbl->current_rate = il4965_rate_n_flags_from_tbl(il, - tbl, rate, is_green); - D_RATE("LQ: Switch to new mcs %X idx is green %X\n", - tbl->current_rate, is_green); + tbl->current_rate = + il4965_rate_n_flags_from_tbl(il, tbl, rate, is_green); + D_RATE("LQ: Switch to new mcs %X idx is green %X\n", tbl->current_rate, + is_green); return 0; } /* * Try to switch to new modulation mode from legacy */ -static int il4965_rs_move_legacy_other(struct il_priv *il, - struct il_lq_sta *lq_sta, - struct ieee80211_conf *conf, - struct ieee80211_sta *sta, - int idx) +static int +il4965_rs_move_legacy_other(struct il_priv *il, struct il_lq_sta *lq_sta, + struct ieee80211_conf *conf, + struct ieee80211_sta *sta, int idx) { struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); struct il_scale_tbl_info *search_tbl = - &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); + &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); struct il_rate_scale_data *win = &(tbl->win[idx]); - u32 sz = (sizeof(struct il_scale_tbl_info) - - (sizeof(struct il_rate_scale_data) * RATE_COUNT)); + u32 sz = + (sizeof(struct il_scale_tbl_info) - + (sizeof(struct il_rate_scale_data) * RATE_COUNT)); u8 start_action; u8 valid_tx_ant = il->hw_params.valid_tx_ant; u8 tx_chains_num = il->hw_params.tx_chains_num; @@ -1294,7 +1301,7 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, tbl->action = IL_LEGACY_SWITCH_SISO; start_action = tbl->action; - for (; ;) { + for (;;) { lq_sta->action_counter++; switch (tbl->action) { case IL_LEGACY_SWITCH_ANTENNA1: @@ -1302,9 +1309,9 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, D_RATE("LQ: Legacy toggle Antenna\n"); if ((tbl->action == IL_LEGACY_SWITCH_ANTENNA1 && - tx_chains_num <= 1) || + tx_chains_num <= 1) || (tbl->action == IL_LEGACY_SWITCH_ANTENNA2 && - tx_chains_num <= 2)) + tx_chains_num <= 2)) break; /* Don't change antenna if success has been great */ @@ -1314,11 +1321,12 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, /* Set up search table to try other antenna */ memcpy(search_tbl, tbl, sz); - if (il4965_rs_toggle_antenna(valid_tx_ant, - &search_tbl->current_rate, search_tbl)) { + if (il4965_rs_toggle_antenna + (valid_tx_ant, &search_tbl->current_rate, + search_tbl)) { update_search_tbl_counter = 1; il4965_rs_set_expected_tpt_table(lq_sta, - search_tbl); + search_tbl); goto out; } break; @@ -1328,8 +1336,9 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, /* Set up search table to try SISO */ memcpy(search_tbl, tbl, sz); search_tbl->is_SGI = 0; - ret = il4965_rs_switch_to_siso(il, lq_sta, conf, sta, - search_tbl, idx); + ret = + il4965_rs_switch_to_siso(il, lq_sta, conf, sta, + search_tbl, idx); if (!ret) { lq_sta->action_counter = 0; goto out; @@ -1352,13 +1361,13 @@ static int il4965_rs_move_legacy_other(struct il_priv *il, else search_tbl->ant_type = ANT_BC; - if (!il4965_rs_is_valid_ant(valid_tx_ant, - search_tbl->ant_type)) + if (!il4965_rs_is_valid_ant + (valid_tx_ant, search_tbl->ant_type)) break; - ret = il4965_rs_switch_to_mimo2(il, lq_sta, - conf, sta, - search_tbl, idx); + ret = + il4965_rs_switch_to_mimo2(il, lq_sta, conf, sta, + search_tbl, idx); if (!ret) { lq_sta->action_counter = 0; goto out; @@ -1390,19 +1399,20 @@ out: /* * Try to switch to new modulation mode from SISO */ -static int il4965_rs_move_siso_to_other(struct il_priv *il, - struct il_lq_sta *lq_sta, - struct ieee80211_conf *conf, - struct ieee80211_sta *sta, int idx) +static int +il4965_rs_move_siso_to_other(struct il_priv *il, struct il_lq_sta *lq_sta, + struct ieee80211_conf *conf, + struct ieee80211_sta *sta, int idx) { u8 is_green = lq_sta->is_green; struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); struct il_scale_tbl_info *search_tbl = - &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); + &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); struct il_rate_scale_data *win = &(tbl->win[idx]); struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; - u32 sz = (sizeof(struct il_scale_tbl_info) - - (sizeof(struct il_rate_scale_data) * RATE_COUNT)); + u32 sz = + (sizeof(struct il_scale_tbl_info) - + (sizeof(struct il_rate_scale_data) * RATE_COUNT)); u8 start_action; u8 valid_tx_ant = il->hw_params.valid_tx_ant; u8 tx_chains_num = il->hw_params.tx_chains_num; @@ -1418,17 +1428,18 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, case IL_SISO_SWITCH_ANTENNA2: D_RATE("LQ: SISO toggle Antenna\n"); if ((tbl->action == IL_SISO_SWITCH_ANTENNA1 && - tx_chains_num <= 1) || + tx_chains_num <= 1) || (tbl->action == IL_SISO_SWITCH_ANTENNA2 && - tx_chains_num <= 2)) + tx_chains_num <= 2)) break; if (win->success_ratio >= IL_RS_GOOD_RATIO) break; memcpy(search_tbl, tbl, sz); - if (il4965_rs_toggle_antenna(valid_tx_ant, - &search_tbl->current_rate, search_tbl)) { + if (il4965_rs_toggle_antenna + (valid_tx_ant, &search_tbl->current_rate, + search_tbl)) { update_search_tbl_counter = 1; goto out; } @@ -1447,22 +1458,22 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, else search_tbl->ant_type = ANT_BC; - if (!il4965_rs_is_valid_ant(valid_tx_ant, - search_tbl->ant_type)) + if (!il4965_rs_is_valid_ant + (valid_tx_ant, search_tbl->ant_type)) break; - ret = il4965_rs_switch_to_mimo2(il, lq_sta, - conf, sta, - search_tbl, idx); + ret = + il4965_rs_switch_to_mimo2(il, lq_sta, conf, sta, + search_tbl, idx); if (!ret) goto out; break; case IL_SISO_SWITCH_GI: - if (!tbl->is_ht40 && !(ht_cap->cap & - IEEE80211_HT_CAP_SGI_20)) + if (!tbl->is_ht40 && + !(ht_cap->cap & IEEE80211_HT_CAP_SGI_20)) break; - if (tbl->is_ht40 && !(ht_cap->cap & - IEEE80211_HT_CAP_SGI_40)) + if (tbl->is_ht40 && + !(ht_cap->cap & IEEE80211_HT_CAP_SGI_40)) break; D_RATE("LQ: SISO toggle SGI/NGI\n"); @@ -1472,8 +1483,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, if (!tbl->is_SGI) break; else - IL_ERR( - "SGI was set in GF+SISO\n"); + IL_ERR("SGI was set in GF+SISO\n"); } search_tbl->is_SGI = !tbl->is_SGI; il4965_rs_set_expected_tpt_table(lq_sta, search_tbl); @@ -1483,8 +1493,8 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, break; } search_tbl->current_rate = - il4965_rate_n_flags_from_tbl(il, search_tbl, - idx, is_green); + il4965_rate_n_flags_from_tbl(il, search_tbl, idx, + is_green); update_search_tbl_counter = 1; goto out; } @@ -1498,7 +1508,7 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, search_tbl->lq_type = LQ_NONE; return 0; - out: +out: lq_sta->search_better_tbl = 1; tbl->action++; if (tbl->action > IL_SISO_SWITCH_GI) @@ -1512,19 +1522,20 @@ static int il4965_rs_move_siso_to_other(struct il_priv *il, /* * Try to switch to new modulation mode from MIMO2 */ -static int il4965_rs_move_mimo2_to_other(struct il_priv *il, - struct il_lq_sta *lq_sta, - struct ieee80211_conf *conf, - struct ieee80211_sta *sta, int idx) +static int +il4965_rs_move_mimo2_to_other(struct il_priv *il, struct il_lq_sta *lq_sta, + struct ieee80211_conf *conf, + struct ieee80211_sta *sta, int idx) { s8 is_green = lq_sta->is_green; struct il_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); struct il_scale_tbl_info *search_tbl = - &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); + &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); struct il_rate_scale_data *win = &(tbl->win[idx]); struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; - u32 sz = (sizeof(struct il_scale_tbl_info) - - (sizeof(struct il_rate_scale_data) * RATE_COUNT)); + u32 sz = + (sizeof(struct il_scale_tbl_info) - + (sizeof(struct il_rate_scale_data) * RATE_COUNT)); u8 start_action; u8 valid_tx_ant = il->hw_params.valid_tx_ant; u8 tx_chains_num = il->hw_params.tx_chains_num; @@ -1546,8 +1557,9 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, break; memcpy(search_tbl, tbl, sz); - if (il4965_rs_toggle_antenna(valid_tx_ant, - &search_tbl->current_rate, search_tbl)) { + if (il4965_rs_toggle_antenna + (valid_tx_ant, &search_tbl->current_rate, + search_tbl)) { update_search_tbl_counter = 1; goto out; } @@ -1567,24 +1579,24 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, else search_tbl->ant_type = ANT_C; - if (!il4965_rs_is_valid_ant(valid_tx_ant, - search_tbl->ant_type)) + if (!il4965_rs_is_valid_ant + (valid_tx_ant, search_tbl->ant_type)) break; - ret = il4965_rs_switch_to_siso(il, lq_sta, - conf, sta, - search_tbl, idx); + ret = + il4965_rs_switch_to_siso(il, lq_sta, conf, sta, + search_tbl, idx); if (!ret) goto out; break; case IL_MIMO2_SWITCH_GI: - if (!tbl->is_ht40 && !(ht_cap->cap & - IEEE80211_HT_CAP_SGI_20)) + if (!tbl->is_ht40 && + !(ht_cap->cap & IEEE80211_HT_CAP_SGI_20)) break; - if (tbl->is_ht40 && !(ht_cap->cap & - IEEE80211_HT_CAP_SGI_40)) + if (tbl->is_ht40 && + !(ht_cap->cap & IEEE80211_HT_CAP_SGI_40)) break; D_RATE("LQ: MIMO2 toggle SGI/NGI\n"); @@ -1605,8 +1617,8 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, break; } search_tbl->current_rate = - il4965_rate_n_flags_from_tbl(il, search_tbl, - idx, is_green); + il4965_rate_n_flags_from_tbl(il, search_tbl, idx, + is_green); update_search_tbl_counter = 1; goto out; @@ -1620,7 +1632,7 @@ static int il4965_rs_move_mimo2_to_other(struct il_priv *il, } search_tbl->lq_type = LQ_NONE; return 0; - out: +out: lq_sta->search_better_tbl = 1; tbl->action++; if (tbl->action > IL_MIMO2_SWITCH_GI) @@ -1659,9 +1671,9 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) /* Elapsed time using current modulation mode */ if (lq_sta->flush_timer) flush_interval_passed = - time_after(jiffies, - (unsigned long)(lq_sta->flush_timer + - RATE_SCALE_FLUSH_INTVL)); + time_after(jiffies, + (unsigned long)(lq_sta->flush_timer + + RATE_SCALE_FLUSH_INTVL)); /* * Check if we should allow search for new modulation mode. @@ -1677,9 +1689,8 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) (!lq_sta->search_better_tbl && lq_sta->flush_timer && flush_interval_passed)) { D_RATE("LQ: stay is expired %d %d %d\n:", - lq_sta->total_failed, - lq_sta->total_success, - flush_interval_passed); + lq_sta->total_failed, lq_sta->total_success, + flush_interval_passed); /* Allow search for new mode */ lq_sta->stay_in_tbl = 0; /* only place reset */ @@ -1687,23 +1698,23 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) lq_sta->total_success = 0; lq_sta->flush_timer = 0; - /* - * Else if we've used this modulation mode enough repetitions - * (regardless of elapsed time or success/failure), reset - * history bitmaps and rate-specific stats for all rates in - * active table. - */ + /* + * Else if we've used this modulation mode enough repetitions + * (regardless of elapsed time or success/failure), reset + * history bitmaps and rate-specific stats for all rates in + * active table. + */ } else { lq_sta->table_count++; - if (lq_sta->table_count >= - lq_sta->table_count_limit) { + if (lq_sta->table_count >= lq_sta->table_count_limit) { lq_sta->table_count = 0; - D_RATE( - "LQ: stay in table clear win\n"); + D_RATE("LQ: stay in table clear win\n"); for (i = 0; i < RATE_COUNT; i++) - il4965_rs_rate_scale_clear_win( - &(tbl->win[i])); + il4965_rs_rate_scale_clear_win(& + (tbl-> + win + [i])); } } @@ -1712,8 +1723,7 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) * "search" table). */ if (!lq_sta->stay_in_tbl) { for (i = 0; i < RATE_COUNT; i++) - il4965_rs_rate_scale_clear_win( - &(tbl->win[i])); + il4965_rs_rate_scale_clear_win(&(tbl->win[i])); } } } @@ -1722,11 +1732,10 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) * setup rate table in uCode * return rate_n_flags as used in the table */ -static u32 il4965_rs_update_rate_tbl(struct il_priv *il, - struct il_rxon_context *ctx, - struct il_lq_sta *lq_sta, - struct il_scale_tbl_info *tbl, - int idx, u8 is_green) +static u32 +il4965_rs_update_rate_tbl(struct il_priv *il, struct il_rxon_context *ctx, + struct il_lq_sta *lq_sta, + struct il_scale_tbl_info *tbl, int idx, u8 is_green) { u32 rate; @@ -1741,10 +1750,10 @@ static u32 il4965_rs_update_rate_tbl(struct il_priv *il, /* * Do rate scaling and search for new modulation mode. */ -static void il4965_rs_rate_scale_perform(struct il_priv *il, - struct sk_buff *skb, - struct ieee80211_sta *sta, - struct il_lq_sta *lq_sta) +static void +il4965_rs_rate_scale_perform(struct il_priv *il, struct sk_buff *skb, + struct ieee80211_sta *sta, + struct il_lq_sta *lq_sta) { struct ieee80211_hw *hw = il->hw; struct ieee80211_conf *conf = &hw->conf; @@ -1818,8 +1827,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* current tx rate */ idx = lq_sta->last_txrate_idx; - D_RATE("Rate scale idx %d for type %d\n", idx, - tbl->lq_type); + D_RATE("Rate scale idx %d for type %d\n", idx, tbl->lq_type); /* rates available for this association, and for modulation mode */ rate_mask = il4965_rs_get_supported_rates(lq_sta, hdr, tbl->lq_type); @@ -1830,11 +1838,12 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, if (is_legacy(tbl->lq_type)) { if (lq_sta->band == IEEE80211_BAND_5GHZ) /* supp_rates has no CCK bits in A mode */ - rate_scale_idx_msk = (u16) (rate_mask & - (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); + rate_scale_idx_msk = + (u16) (rate_mask & + (lq_sta->supp_rates << IL_FIRST_OFDM_RATE)); else - rate_scale_idx_msk = (u16) (rate_mask & - lq_sta->supp_rates); + rate_scale_idx_msk = + (u16) (rate_mask & lq_sta->supp_rates); } else rate_scale_idx_msk = rate_mask; @@ -1845,14 +1854,15 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, if (!((1 << idx) & rate_scale_idx_msk)) { IL_ERR("Current Rate is not valid\n"); if (lq_sta->search_better_tbl) { - /* revert to active table if search table is not valid*/ + /* revert to active table if search table is not valid */ tbl->lq_type = LQ_NONE; lq_sta->search_better_tbl = 0; tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); /* get "active" rate info */ idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); - rate = il4965_rs_update_rate_tbl(il, ctx, lq_sta, - tbl, idx, is_green); + rate = + il4965_rs_update_rate_tbl(il, ctx, lq_sta, tbl, idx, + is_green); } return; } @@ -1864,8 +1874,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, } /* force user max rate if set by user */ - if (lq_sta->max_rate_idx != -1 && - lq_sta->max_rate_idx < idx) { + if (lq_sta->max_rate_idx != -1 && lq_sta->max_rate_idx < idx) { idx = lq_sta->max_rate_idx; update_lq = 1; win = &(tbl->win[idx]); @@ -1884,9 +1893,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, fail_count = win->counter - win->success_counter; if (fail_count < RATE_MIN_FAILURE_TH && win->success_counter < RATE_MIN_SUCCESS_TH) { - D_RATE("LQ: still below TH. succ=%d total=%d " - "for idx %d\n", - win->success_counter, win->counter, idx); + D_RATE("LQ: still below TH. succ=%d total=%d " "for idx %d\n", + win->success_counter, win->counter, idx); /* Can't calculate this yet; not enough history */ win->average_tpt = IL_INVALID_VALUE; @@ -1899,12 +1907,11 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, } /* Else we have enough samples; calculate estimate of * actual average throughput */ - if (win->average_tpt != ((win->success_ratio * - tbl->expected_tpt[idx] + 64) / 128)) { - IL_ERR( - "expected_tpt should have been calculated by now\n"); - win->average_tpt = ((win->success_ratio * - tbl->expected_tpt[idx] + 64) / 128); + if (win->average_tpt != + ((win->success_ratio * tbl->expected_tpt[idx] + 64) / 128)) { + IL_ERR("expected_tpt should have been calculated by now\n"); + win->average_tpt = + ((win->success_ratio * tbl->expected_tpt[idx] + 64) / 128); } /* If we are searching for better modulation mode, check success. */ @@ -1915,10 +1922,9 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, if (win->average_tpt > lq_sta->last_tpt) { D_RATE("LQ: SWITCHING TO NEW TBL " - "suc=%d cur-tpt=%d old-tpt=%d\n", - win->success_ratio, - win->average_tpt, - lq_sta->last_tpt); + "suc=%d cur-tpt=%d old-tpt=%d\n", + win->success_ratio, win->average_tpt, + lq_sta->last_tpt); if (!is_legacy(tbl->lq_type)) lq_sta->enable_counter = 1; @@ -1927,14 +1933,13 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, lq_sta->active_tbl = active_tbl; current_tpt = win->average_tpt; - /* Else poor success; go back to mode in "active" table */ + /* Else poor success; go back to mode in "active" table */ } else { D_RATE("LQ: GOING BACK TO THE OLD TBL " - "suc=%d cur-tpt=%d old-tpt=%d\n", - win->success_ratio, - win->average_tpt, - lq_sta->last_tpt); + "suc=%d cur-tpt=%d old-tpt=%d\n", + win->success_ratio, win->average_tpt, + lq_sta->last_tpt); /* Nullify "search" table */ tbl->lq_type = LQ_NONE; @@ -1960,15 +1965,14 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* (Else) not in search of better modulation mode, try for better * starting rate, while staying in this mode. */ - high_low = il4965_rs_get_adjacent_rate(il, idx, - rate_scale_idx_msk, + high_low = + il4965_rs_get_adjacent_rate(il, idx, rate_scale_idx_msk, tbl->lq_type); low = high_low & 0xff; high = (high_low >> 8) & 0xff; /* If user set max rate, dont allow higher than user constrain */ - if (lq_sta->max_rate_idx != -1 && - lq_sta->max_rate_idx < high) + if (lq_sta->max_rate_idx != -1 && lq_sta->max_rate_idx < high) high = RATE_INVALID; sr = win->success_ratio; @@ -1984,13 +1988,11 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Too many failures, decrease rate */ if (sr <= RATE_DECREASE_TH || current_tpt == 0) { - D_RATE( - "decrease rate because of low success_ratio\n"); + D_RATE("decrease rate because of low success_ratio\n"); scale_action = -1; - /* No throughput measured yet for adjacent rates; try increase. */ - } else if (low_tpt == IL_INVALID_VALUE && - high_tpt == IL_INVALID_VALUE) { + /* No throughput measured yet for adjacent rates; try increase. */ + } else if (low_tpt == IL_INVALID_VALUE && high_tpt == IL_INVALID_VALUE) { if (high != RATE_INVALID && sr >= RATE_INCREASE_TH) scale_action = 1; @@ -2010,19 +2012,17 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, /* Higher adjacent rate's throughput is measured */ if (high_tpt != IL_INVALID_VALUE) { /* Higher rate has better throughput */ - if (high_tpt > current_tpt && - sr >= RATE_INCREASE_TH) { + if (high_tpt > current_tpt && sr >= RATE_INCREASE_TH) { scale_action = 1; } else { scale_action = 0; } - /* Lower adjacent rate's throughput is measured */ + /* Lower adjacent rate's throughput is measured */ } else if (low_tpt != IL_INVALID_VALUE) { /* Lower rate has better throughput */ if (low_tpt > current_tpt) { - D_RATE( - "decrease rate because of low tpt\n"); + D_RATE("decrease rate because of low tpt\n"); scale_action = -1; } else if (sr >= RATE_INCREASE_TH) { scale_action = 1; @@ -2059,19 +2059,19 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il, break; } - D_RATE("choose rate scale idx %d action %d low %d " - "high %d type %d\n", - idx, scale_action, low, high, tbl->lq_type); + D_RATE("choose rate scale idx %d action %d low %d " "high %d type %d\n", + idx, scale_action, low, high, tbl->lq_type); lq_update: /* Replace uCode's rate table for the destination station. */ if (update_lq) - rate = il4965_rs_update_rate_tbl(il, ctx, lq_sta, - tbl, idx, is_green); + rate = + il4965_rs_update_rate_tbl(il, ctx, lq_sta, tbl, idx, + is_green); /* Should we stay with this modulation mode, * or search for a new one? */ - il4965_rs_stay_in_table(lq_sta, false); + il4965_rs_stay_in_table(lq_sta, false); /* * Search for new modulation mode if we're: @@ -2079,41 +2079,35 @@ lq_update: * 2) Not just finishing up a search * 3) Allowing a new search */ - if (!update_lq && !done_search && !lq_sta->stay_in_tbl && - win->counter) { - /* Save current throughput to compare with "search" throughput*/ + if (!update_lq && !done_search && !lq_sta->stay_in_tbl && win->counter) { + /* Save current throughput to compare with "search" throughput */ lq_sta->last_tpt = current_tpt; /* Select a new "search" modulation mode to try. * If one is found, set up the new "search" table. */ if (is_legacy(tbl->lq_type)) - il4965_rs_move_legacy_other(il, lq_sta, - conf, sta, idx); + il4965_rs_move_legacy_other(il, lq_sta, conf, sta, idx); else if (is_siso(tbl->lq_type)) - il4965_rs_move_siso_to_other(il, lq_sta, - conf, sta, idx); - else /* (is_mimo2(tbl->lq_type)) */ - il4965_rs_move_mimo2_to_other(il, lq_sta, - conf, sta, idx); + il4965_rs_move_siso_to_other(il, lq_sta, conf, sta, + idx); + else /* (is_mimo2(tbl->lq_type)) */ + il4965_rs_move_mimo2_to_other(il, lq_sta, conf, sta, + idx); /* If new "search" mode was selected, set up in uCode table */ if (lq_sta->search_better_tbl) { /* Access the "search" table, clear its history. */ tbl = &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); for (i = 0; i < RATE_COUNT; i++) - il4965_rs_rate_scale_clear_win( - &(tbl->win[i])); + il4965_rs_rate_scale_clear_win(&(tbl->win[i])); /* Use new "search" start rate */ idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); - D_RATE( - "Switch current mcs: %X idx: %d\n", - tbl->current_rate, idx); - il4965_rs_fill_link_cmd(il, lq_sta, - tbl->current_rate); - il_send_lq_cmd(il, ctx, - &lq_sta->lq, CMD_ASYNC, false); + D_RATE("Switch current mcs: %X idx: %d\n", + tbl->current_rate, idx); + il4965_rs_fill_link_cmd(il, lq_sta, tbl->current_rate); + il_send_lq_cmd(il, ctx, &lq_sta->lq, CMD_ASYNC, false); } else done_search = 1; } @@ -2140,13 +2134,12 @@ lq_update: (lq_sta->tx_agg_tid_en & (1 << tid)) && tid != MAX_TID_COUNT) { tid_data = - &il->stations[lq_sta->lq.sta_id].tid[tid]; + &il->stations[lq_sta->lq.sta_id].tid[tid]; if (tid_data->agg.state == IL_AGG_OFF) { - D_RATE( - "try to aggregate tid %d\n", - tid); + D_RATE("try to aggregate tid %d\n", + tid); il4965_rs_tl_turn_on_agg(il, tid, - lq_sta, sta); + lq_sta, sta); } } il4965_rs_set_stay_in_table(il, 0, lq_sta); @@ -2154,8 +2147,8 @@ lq_update: } out: - tbl->current_rate = il4965_rate_n_flags_from_tbl(il, tbl, - idx, is_green); + tbl->current_rate = + il4965_rate_n_flags_from_tbl(il, tbl, idx, is_green); i = idx; lq_sta->last_txrate_idx = i; } @@ -2174,10 +2167,9 @@ out: * calling this function (which runs C_TX_LINK_QUALITY_CMD, * which requires station table entry to exist). */ -static void il4965_rs_initialize_lq(struct il_priv *il, - struct ieee80211_conf *conf, - struct ieee80211_sta *sta, - struct il_lq_sta *lq_sta) +static void +il4965_rs_initialize_lq(struct il_priv *il, struct ieee80211_conf *conf, + struct ieee80211_sta *sta, struct il_lq_sta *lq_sta) { struct il_scale_tbl_info *tbl; int rate_idx; @@ -2230,7 +2222,7 @@ static void il4965_rs_initialize_lq(struct il_priv *il, static void il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, - struct ieee80211_tx_rate_control *txrc) + struct ieee80211_tx_rate_control *txrc) { struct sk_buff *skb = txrc->skb; @@ -2266,28 +2258,28 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, if (!lq_sta) return; - rate_idx = lq_sta->last_txrate_idx; + rate_idx = lq_sta->last_txrate_idx; if (lq_sta->last_rate_n_flags & RATE_MCS_HT_MSK) { rate_idx -= IL_FIRST_OFDM_RATE; /* 6M and 9M shared same MCS idx */ rate_idx = (rate_idx > 0) ? (rate_idx - 1) : 0; if (il4965_rs_extract_rate(lq_sta->last_rate_n_flags) >= - RATE_MIMO2_6M_PLCP) + RATE_MIMO2_6M_PLCP) rate_idx = rate_idx + MCS_IDX_PER_STREAM; info->control.rates[0].flags = IEEE80211_TX_RC_MCS; if (lq_sta->last_rate_n_flags & RATE_MCS_SGI_MSK) info->control.rates[0].flags |= - IEEE80211_TX_RC_SHORT_GI; + IEEE80211_TX_RC_SHORT_GI; if (lq_sta->last_rate_n_flags & RATE_MCS_DUP_MSK) info->control.rates[0].flags |= - IEEE80211_TX_RC_DUP_DATA; + IEEE80211_TX_RC_DUP_DATA; if (lq_sta->last_rate_n_flags & RATE_MCS_HT40_MSK) info->control.rates[0].flags |= - IEEE80211_TX_RC_40_MHZ_WIDTH; + IEEE80211_TX_RC_40_MHZ_WIDTH; if (lq_sta->last_rate_n_flags & RATE_MCS_GF_MSK) info->control.rates[0].flags |= - IEEE80211_TX_RC_GREEN_FIELD; + IEEE80211_TX_RC_GREEN_FIELD; } else { /* Check for invalid rates */ if (rate_idx < 0 || rate_idx >= RATE_COUNT_LEGACY || @@ -2303,12 +2295,12 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, } -static void *il4965_rs_alloc_sta(void *il_rate, struct ieee80211_sta *sta, - gfp_t gfp) +static void * +il4965_rs_alloc_sta(void *il_rate, struct ieee80211_sta *sta, gfp_t gfp) { struct il_lq_sta *lq_sta; struct il_station_priv *sta_priv = - (struct il_station_priv *) sta->drv_priv; + (struct il_station_priv *)sta->drv_priv; struct il_priv *il; il = (struct il_priv *)il_rate; @@ -2323,9 +2315,7 @@ static void *il4965_rs_alloc_sta(void *il_rate, struct ieee80211_sta *sta, * Called after adding a new station to initialize rate scaling */ void -il4965_rs_rate_init(struct il_priv *il, - struct ieee80211_sta *sta, - u8 sta_id) +il4965_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, u8 sta_id) { int i, j; struct ieee80211_hw *hw = il->hw; @@ -2335,28 +2325,26 @@ il4965_rs_rate_init(struct il_priv *il, struct il_lq_sta *lq_sta; struct ieee80211_supported_band *sband; - sta_priv = (struct il_station_priv *) sta->drv_priv; + sta_priv = (struct il_station_priv *)sta->drv_priv; lq_sta = &sta_priv->lq_sta; sband = hw->wiphy->bands[conf->channel->band]; - lq_sta->lq.sta_id = sta_id; for (j = 0; j < LQ_SIZE; j++) for (i = 0; i < RATE_COUNT; i++) - il4965_rs_rate_scale_clear_win( - &lq_sta->lq_info[j].win[i]); + il4965_rs_rate_scale_clear_win(&lq_sta->lq_info[j]. + win[i]); lq_sta->flush_timer = 0; lq_sta->supp_rates = sta->supp_rates[sband->band]; for (j = 0; j < LQ_SIZE; j++) for (i = 0; i < RATE_COUNT; i++) - il4965_rs_rate_scale_clear_win( - &lq_sta->lq_info[j].win[i]); + il4965_rs_rate_scale_clear_win(&lq_sta->lq_info[j]. + win[i]); - D_RATE("LQ:" - "*** rate scale station global init for station %d ***\n", - sta_id); + D_RATE("LQ:" "*** rate scale station global init for station %d ***\n", + sta_id); /* TODO: what is a good starting rate for STA? About middle? Maybe not * the lowest or the highest rate.. Could consider using RSSI from * previous packets? Need to have IEEE 802.1X auth succeed immediately @@ -2374,26 +2362,26 @@ il4965_rs_rate_init(struct il_priv *il, */ lq_sta->active_siso_rate = ht_cap->mcs.rx_mask[0] << 1; lq_sta->active_siso_rate |= ht_cap->mcs.rx_mask[0] & 0x1; - lq_sta->active_siso_rate &= ~((u16)0x2); + lq_sta->active_siso_rate &= ~((u16) 0x2); lq_sta->active_siso_rate <<= IL_FIRST_OFDM_RATE; /* Same here */ lq_sta->active_mimo2_rate = ht_cap->mcs.rx_mask[1] << 1; lq_sta->active_mimo2_rate |= ht_cap->mcs.rx_mask[1] & 0x1; - lq_sta->active_mimo2_rate &= ~((u16)0x2); + lq_sta->active_mimo2_rate &= ~((u16) 0x2); lq_sta->active_mimo2_rate <<= IL_FIRST_OFDM_RATE; /* These values will be overridden later */ lq_sta->lq.general_params.single_stream_ant_msk = - il4965_first_antenna(il->hw_params.valid_tx_ant); + il4965_first_antenna(il->hw_params.valid_tx_ant); lq_sta->lq.general_params.dual_stream_ant_msk = - il->hw_params.valid_tx_ant & - ~il4965_first_antenna(il->hw_params.valid_tx_ant); + il->hw_params.valid_tx_ant & ~il4965_first_antenna(il->hw_params. + valid_tx_ant); if (!lq_sta->lq.general_params.dual_stream_ant_msk) { lq_sta->lq.general_params.dual_stream_ant_msk = ANT_AB; } else if (il4965_num_of_ant(il->hw_params.valid_tx_ant) == 2) { lq_sta->lq.general_params.dual_stream_ant_msk = - il->hw_params.valid_tx_ant; + il->hw_params.valid_tx_ant; } /* as default allow aggregation for all tids */ @@ -2413,8 +2401,9 @@ il4965_rs_rate_init(struct il_priv *il, il4965_rs_initialize_lq(il, conf, sta, lq_sta); } -static void il4965_rs_fill_link_cmd(struct il_priv *il, - struct il_lq_sta *lq_sta, u32 new_rate) +static void +il4965_rs_fill_link_cmd(struct il_priv *il, struct il_lq_sta *lq_sta, + u32 new_rate) { struct il_scale_tbl_info tbl_type; int idx = 0; @@ -2429,8 +2418,8 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, il4965_rs_dbgfs_set_mcs(lq_sta, &new_rate, idx); /* Interpret new_rate (rate_n_flags) */ - il4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, - &tbl_type, &rate_idx); + il4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, &tbl_type, + &rate_idx); /* How many times should we repeat the initial rate? */ if (is_legacy(tbl_type.lq_type)) { @@ -2441,19 +2430,18 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, } lq_cmd->general_params.mimo_delimiter = - is_mimo(tbl_type.lq_type) ? 1 : 0; + is_mimo(tbl_type.lq_type) ? 1 : 0; /* Fill 1st table entry (idx 0) */ lq_cmd->rs_table[idx].rate_n_flags = cpu_to_le32(new_rate); if (il4965_num_of_ant(tbl_type.ant_type) == 1) { lq_cmd->general_params.single_stream_ant_msk = - tbl_type.ant_type; + tbl_type.ant_type; } else if (il4965_num_of_ant(tbl_type.ant_type) == 2) { - lq_cmd->general_params.dual_stream_ant_msk = - tbl_type.ant_type; - } /* otherwise we don't modify the existing value */ - + lq_cmd->general_params.dual_stream_ant_msk = tbl_type.ant_type; + } + /* otherwise we don't modify the existing value */ idx++; repeat_rate--; if (il) @@ -2470,7 +2458,8 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, ant_toggle_cnt++; else if (il && il4965_rs_toggle_antenna(valid_tx_ant, - &new_rate, &tbl_type)) + &new_rate, + &tbl_type)) ant_toggle_cnt = 1; } @@ -2479,14 +2468,13 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, /* Fill next table entry */ lq_cmd->rs_table[idx].rate_n_flags = - cpu_to_le32(new_rate); + cpu_to_le32(new_rate); repeat_rate--; idx++; } - il4965_rs_get_tbl_info_from_mcs(new_rate, - lq_sta->band, &tbl_type, - &rate_idx); + il4965_rs_get_tbl_info_from_mcs(new_rate, lq_sta->band, + &tbl_type, &rate_idx); /* Indicate to uCode which entries might be MIMO. * If initial rate was MIMO, this will finally end up @@ -2495,8 +2483,8 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, lq_cmd->general_params.mimo_delimiter = idx; /* Get next rate */ - new_rate = il4965_rs_get_lower_rate(lq_sta, - &tbl_type, rate_idx, + new_rate = + il4965_rs_get_lower_rate(lq_sta, &tbl_type, rate_idx, use_ht_possible); /* How many times should we repeat the next rate? */ @@ -2505,7 +2493,7 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, ant_toggle_cnt++; else if (il && il4965_rs_toggle_antenna(valid_tx_ant, - &new_rate, &tbl_type)) + &new_rate, &tbl_type)) ant_toggle_cnt = 1; repeat_rate = IL_NUMBER_TRY; @@ -2531,22 +2519,24 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il, lq_cmd->agg_params.agg_dis_start_th = LINK_QUAL_AGG_DISABLE_START_DEF; lq_cmd->agg_params.agg_time_limit = - cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF); + cpu_to_le16(LINK_QUAL_AGG_TIME_LIMIT_DEF); } -static void -*il4965_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) +static void * +il4965_rs_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir) { return hw->priv; } + /* rate scale requires free function to be implemented */ -static void il4965_rs_free(void *il_rate) +static void +il4965_rs_free(void *il_rate) { return; } -static void il4965_rs_free_sta(void *il_r, struct ieee80211_sta *sta, - void *il_sta) +static void +il4965_rs_free_sta(void *il_r, struct ieee80211_sta *sta, void *il_sta) { struct il_priv *il __maybe_unused = il_r; @@ -2554,15 +2544,16 @@ static void il4965_rs_free_sta(void *il_r, struct ieee80211_sta *sta, D_RATE("leave\n"); } - #ifdef CONFIG_MAC80211_DEBUGFS -static int il4965_open_file_generic(struct inode *inode, struct file *file) +static int +il4965_open_file_generic(struct inode *inode, struct file *file) { file->private_data = inode->i_private; return 0; } -static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, - u32 *rate_n_flags, int idx) + +static void +il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, u32 * rate_n_flags, int idx) { struct il_priv *il; u8 valid_tx_ant; @@ -2572,16 +2563,17 @@ static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, valid_tx_ant = il->hw_params.valid_tx_ant; if (lq_sta->dbg_fixed_rate) { ant_sel_tx = - ((lq_sta->dbg_fixed_rate & RATE_MCS_ANT_ABC_MSK) - >> RATE_MCS_ANT_POS); + ((lq_sta-> + dbg_fixed_rate & RATE_MCS_ANT_ABC_MSK) >> + RATE_MCS_ANT_POS); if ((valid_tx_ant & ant_sel_tx) == ant_sel_tx) { *rate_n_flags = lq_sta->dbg_fixed_rate; D_RATE("Fixed rate ON\n"); } else { lq_sta->dbg_fixed_rate = 0; - IL_ERR( - "Invalid antenna selection 0x%X, Valid is 0x%X\n", - ant_sel_tx, valid_tx_ant); + IL_ERR + ("Invalid antenna selection 0x%X, Valid is 0x%X\n", + ant_sel_tx, valid_tx_ant); D_RATE("Fixed rate OFF\n"); } } else { @@ -2589,8 +2581,10 @@ static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, } } -static ssize_t il4965_rs_sta_dbgfs_scale_table_write(struct file *file, - const char __user *user_buf, size_t count, loff_t *ppos) +static ssize_t +il4965_rs_sta_dbgfs_scale_table_write(struct file *file, + const char __user * user_buf, + size_t count, loff_t * ppos) { struct il_lq_sta *lq_sta = file->private_data; struct il_priv *il; @@ -2598,12 +2592,12 @@ static ssize_t il4965_rs_sta_dbgfs_scale_table_write(struct file *file, size_t buf_size; u32 parsed_rate; struct il_station_priv *sta_priv = - container_of(lq_sta, struct il_station_priv, lq_sta); + container_of(lq_sta, struct il_station_priv, lq_sta); struct il_rxon_context *ctx = sta_priv->common.ctx; il = lq_sta->drv; memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); + buf_size = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, buf_size)) return -EFAULT; @@ -2613,23 +2607,23 @@ static ssize_t il4965_rs_sta_dbgfs_scale_table_write(struct file *file, lq_sta->dbg_fixed_rate = 0; lq_sta->active_legacy_rate = 0x0FFF; /* 1 - 54 MBits, includes CCK */ - lq_sta->active_siso_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ - lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ + lq_sta->active_siso_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ + lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ - D_RATE("sta_id %d rate 0x%X\n", - lq_sta->lq.sta_id, lq_sta->dbg_fixed_rate); + D_RATE("sta_id %d rate 0x%X\n", lq_sta->lq.sta_id, + lq_sta->dbg_fixed_rate); if (lq_sta->dbg_fixed_rate) { il4965_rs_fill_link_cmd(NULL, lq_sta, lq_sta->dbg_fixed_rate); - il_send_lq_cmd(lq_sta->drv, ctx, &lq_sta->lq, CMD_ASYNC, - false); + il_send_lq_cmd(lq_sta->drv, ctx, &lq_sta->lq, CMD_ASYNC, false); } return count; } -static ssize_t il4965_rs_sta_dbgfs_scale_table_read(struct file *file, - char __user *user_buf, size_t count, loff_t *ppos) +static ssize_t +il4965_rs_sta_dbgfs_scale_table_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { char *buff; int desc = 0; @@ -2646,64 +2640,80 @@ static ssize_t il4965_rs_sta_dbgfs_scale_table_read(struct file *file, if (!buff) return -ENOMEM; - desc += sprintf(buff+desc, "sta_id %d\n", lq_sta->lq.sta_id); - desc += sprintf(buff+desc, "failed=%d success=%d rate=0%X\n", - lq_sta->total_failed, lq_sta->total_success, - lq_sta->active_legacy_rate); - desc += sprintf(buff+desc, "fixed rate 0x%X\n", - lq_sta->dbg_fixed_rate); - desc += sprintf(buff+desc, "valid_tx_ant %s%s%s\n", - (il->hw_params.valid_tx_ant & ANT_A) ? "ANT_A," : "", - (il->hw_params.valid_tx_ant & ANT_B) ? "ANT_B," : "", - (il->hw_params.valid_tx_ant & ANT_C) ? "ANT_C" : ""); - desc += sprintf(buff+desc, "lq type %s\n", - (is_legacy(tbl->lq_type)) ? "legacy" : "HT"); + desc += sprintf(buff + desc, "sta_id %d\n", lq_sta->lq.sta_id); + desc += + sprintf(buff + desc, "failed=%d success=%d rate=0%X\n", + lq_sta->total_failed, lq_sta->total_success, + lq_sta->active_legacy_rate); + desc += + sprintf(buff + desc, "fixed rate 0x%X\n", lq_sta->dbg_fixed_rate); + desc += + sprintf(buff + desc, "valid_tx_ant %s%s%s\n", + (il->hw_params.valid_tx_ant & ANT_A) ? "ANT_A," : "", + (il->hw_params.valid_tx_ant & ANT_B) ? "ANT_B," : "", + (il->hw_params.valid_tx_ant & ANT_C) ? "ANT_C" : ""); + desc += + sprintf(buff + desc, "lq type %s\n", + (is_legacy(tbl->lq_type)) ? "legacy" : "HT"); if (is_Ht(tbl->lq_type)) { - desc += sprintf(buff+desc, " %s", - (is_siso(tbl->lq_type)) ? "SISO" : "MIMO2"); - desc += sprintf(buff+desc, " %s", - (tbl->is_ht40) ? "40MHz" : "20MHz"); - desc += sprintf(buff+desc, " %s %s %s\n", - (tbl->is_SGI) ? "SGI" : "", - (lq_sta->is_green) ? "GF enabled" : "", - (lq_sta->is_agg) ? "AGG on" : ""); + desc += + sprintf(buff + desc, " %s", + (is_siso(tbl->lq_type)) ? "SISO" : "MIMO2"); + desc += + sprintf(buff + desc, " %s", + (tbl->is_ht40) ? "40MHz" : "20MHz"); + desc += + sprintf(buff + desc, " %s %s %s\n", + (tbl->is_SGI) ? "SGI" : "", + (lq_sta->is_green) ? "GF enabled" : "", + (lq_sta->is_agg) ? "AGG on" : ""); } - desc += sprintf(buff+desc, "last tx rate=0x%X\n", - lq_sta->last_rate_n_flags); - desc += sprintf(buff+desc, "general:" - "flags=0x%X mimo-d=%d s-ant0x%x d-ant=0x%x\n", - lq_sta->lq.general_params.flags, - lq_sta->lq.general_params.mimo_delimiter, - lq_sta->lq.general_params.single_stream_ant_msk, - lq_sta->lq.general_params.dual_stream_ant_msk); - - desc += sprintf(buff+desc, "agg:" - "time_limit=%d dist_start_th=%d frame_cnt_limit=%d\n", - le16_to_cpu(lq_sta->lq.agg_params.agg_time_limit), - lq_sta->lq.agg_params.agg_dis_start_th, - lq_sta->lq.agg_params.agg_frame_cnt_limit); - - desc += sprintf(buff+desc, - "Start idx [0]=0x%x [1]=0x%x [2]=0x%x [3]=0x%x\n", - lq_sta->lq.general_params.start_rate_idx[0], - lq_sta->lq.general_params.start_rate_idx[1], - lq_sta->lq.general_params.start_rate_idx[2], - lq_sta->lq.general_params.start_rate_idx[3]); + desc += + sprintf(buff + desc, "last tx rate=0x%X\n", + lq_sta->last_rate_n_flags); + desc += + sprintf(buff + desc, + "general:" "flags=0x%X mimo-d=%d s-ant0x%x d-ant=0x%x\n", + lq_sta->lq.general_params.flags, + lq_sta->lq.general_params.mimo_delimiter, + lq_sta->lq.general_params.single_stream_ant_msk, + lq_sta->lq.general_params.dual_stream_ant_msk); + + desc += + sprintf(buff + desc, + "agg:" + "time_limit=%d dist_start_th=%d frame_cnt_limit=%d\n", + le16_to_cpu(lq_sta->lq.agg_params.agg_time_limit), + lq_sta->lq.agg_params.agg_dis_start_th, + lq_sta->lq.agg_params.agg_frame_cnt_limit); + + desc += + sprintf(buff + desc, + "Start idx [0]=0x%x [1]=0x%x [2]=0x%x [3]=0x%x\n", + lq_sta->lq.general_params.start_rate_idx[0], + lq_sta->lq.general_params.start_rate_idx[1], + lq_sta->lq.general_params.start_rate_idx[2], + lq_sta->lq.general_params.start_rate_idx[3]); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { - idx = il4965_hwrate_to_plcp_idx( - le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags)); + idx = + il4965_hwrate_to_plcp_idx(le32_to_cpu + (lq_sta->lq.rs_table[i]. + rate_n_flags)); if (is_legacy(tbl->lq_type)) { - desc += sprintf(buff+desc, " rate[%d] 0x%X %smbps\n", - i, - le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags), - il_rate_mcs[idx].mbps); + desc += + sprintf(buff + desc, " rate[%d] 0x%X %smbps\n", i, + le32_to_cpu(lq_sta->lq.rs_table[i]. + rate_n_flags), + il_rate_mcs[idx].mbps); } else { - desc += sprintf(buff+desc, - " rate[%d] 0x%X %smbps (%s)\n", - i, - le32_to_cpu(lq_sta->lq.rs_table[i].rate_n_flags), - il_rate_mcs[idx].mbps, il_rate_mcs[idx].mcs); + desc += + sprintf(buff + desc, " rate[%d] 0x%X %smbps (%s)\n", + i, + le32_to_cpu(lq_sta->lq.rs_table[i]. + rate_n_flags), + il_rate_mcs[idx].mbps, + il_rate_mcs[idx].mcs); } } @@ -2718,8 +2728,10 @@ static const struct file_operations rs_sta_dbgfs_scale_table_ops = { .open = il4965_open_file_generic, .llseek = default_llseek, }; -static ssize_t il4965_rs_sta_dbgfs_stats_table_read(struct file *file, - char __user *user_buf, size_t count, loff_t *ppos) + +static ssize_t +il4965_rs_sta_dbgfs_stats_table_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { char *buff; int desc = 0; @@ -2733,22 +2745,22 @@ static ssize_t il4965_rs_sta_dbgfs_stats_table_read(struct file *file, return -ENOMEM; for (i = 0; i < LQ_SIZE; i++) { - desc += sprintf(buff+desc, - "%s type=%d SGI=%d HT40=%d DUP=%d GF=%d\n" - "rate=0x%X\n", - lq_sta->active_tbl == i ? "*" : "x", - lq_sta->lq_info[i].lq_type, - lq_sta->lq_info[i].is_SGI, - lq_sta->lq_info[i].is_ht40, - lq_sta->lq_info[i].is_dup, - lq_sta->is_green, - lq_sta->lq_info[i].current_rate); + desc += + sprintf(buff + desc, + "%s type=%d SGI=%d HT40=%d DUP=%d GF=%d\n" + "rate=0x%X\n", lq_sta->active_tbl == i ? "*" : "x", + lq_sta->lq_info[i].lq_type, + lq_sta->lq_info[i].is_SGI, + lq_sta->lq_info[i].is_ht40, + lq_sta->lq_info[i].is_dup, lq_sta->is_green, + lq_sta->lq_info[i].current_rate); for (j = 0; j < RATE_COUNT; j++) { - desc += sprintf(buff+desc, - "counter=%d success=%d %%=%d\n", - lq_sta->lq_info[i].win[j].counter, - lq_sta->lq_info[i].win[j].success_counter, - lq_sta->lq_info[i].win[j].success_ratio); + desc += + sprintf(buff + desc, + "counter=%d success=%d %%=%d\n", + lq_sta->lq_info[i].win[j].counter, + lq_sta->lq_info[i].win[j].success_counter, + lq_sta->lq_info[i].win[j].success_ratio); } } ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); @@ -2762,8 +2774,10 @@ static const struct file_operations rs_sta_dbgfs_stats_table_ops = { .llseek = default_llseek, }; -static ssize_t il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, - char __user *user_buf, size_t count, loff_t *ppos) +static ssize_t +il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, + char __user * user_buf, size_t count, + loff_t * ppos) { char buff[120]; int desc = 0; @@ -2776,13 +2790,13 @@ static ssize_t il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, il = lq_sta->drv; if (is_Ht(tbl->lq_type)) - desc += sprintf(buff+desc, - "Bit Rate= %d Mb/s\n", - tbl->expected_tpt[lq_sta->last_txrate_idx]); + desc += + sprintf(buff + desc, "Bit Rate= %d Mb/s\n", + tbl->expected_tpt[lq_sta->last_txrate_idx]); else - desc += sprintf(buff+desc, - "Bit Rate= %d Mb/s\n", - il_rates[lq_sta->last_txrate_idx].ieee >> 1); + desc += + sprintf(buff + desc, "Bit Rate= %d Mb/s\n", + il_rates[lq_sta->last_txrate_idx].ieee >> 1); ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); return ret; @@ -2794,26 +2808,27 @@ static const struct file_operations rs_sta_dbgfs_rate_scale_data_ops = { .llseek = default_llseek, }; -static void il4965_rs_add_debugfs(void *il, void *il_sta, - struct dentry *dir) +static void +il4965_rs_add_debugfs(void *il, void *il_sta, struct dentry *dir) { struct il_lq_sta *lq_sta = il_sta; lq_sta->rs_sta_dbgfs_scale_table_file = - debugfs_create_file("rate_scale_table", S_IRUSR | S_IWUSR, dir, + debugfs_create_file("rate_scale_table", S_IRUSR | S_IWUSR, dir, lq_sta, &rs_sta_dbgfs_scale_table_ops); lq_sta->rs_sta_dbgfs_stats_table_file = - debugfs_create_file("rate_stats_table", S_IRUSR, dir, - lq_sta, &rs_sta_dbgfs_stats_table_ops); + debugfs_create_file("rate_stats_table", S_IRUSR, dir, lq_sta, + &rs_sta_dbgfs_stats_table_ops); lq_sta->rs_sta_dbgfs_rate_scale_data_file = - debugfs_create_file("rate_scale_data", S_IRUSR, dir, - lq_sta, &rs_sta_dbgfs_rate_scale_data_ops); + debugfs_create_file("rate_scale_data", S_IRUSR, dir, lq_sta, + &rs_sta_dbgfs_rate_scale_data_ops); lq_sta->rs_sta_dbgfs_tx_agg_tid_en_file = - debugfs_create_u8("tx_agg_tid_enable", S_IRUSR | S_IWUSR, dir, - &lq_sta->tx_agg_tid_en); + debugfs_create_u8("tx_agg_tid_enable", S_IRUSR | S_IWUSR, dir, + &lq_sta->tx_agg_tid_en); } -static void il4965_rs_remove_debugfs(void *il, void *il_sta) +static void +il4965_rs_remove_debugfs(void *il, void *il_sta) { struct il_lq_sta *lq_sta = il_sta; debugfs_remove(lq_sta->rs_sta_dbgfs_scale_table_file); @@ -2833,6 +2848,7 @@ il4965_rs_rate_init_stub(void *il_r, struct ieee80211_supported_band *sband, struct ieee80211_sta *sta, void *il_sta) { } + static struct rate_control_ops rs_4965_ops = { .module = NULL, .name = IL4965_RS_NAME, @@ -2849,12 +2865,14 @@ static struct rate_control_ops rs_4965_ops = { #endif }; -int il4965_rate_control_register(void) +int +il4965_rate_control_register(void) { return ieee80211_rate_control_register(&rs_4965_ops); } -void il4965_rate_control_unregister(void) +void +il4965_rate_control_unregister(void) { ieee80211_rate_control_unregister(&rs_4965_ops); } diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index cbbb2c03f51b..be054f1452b8 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -48,7 +48,7 @@ * it's a pretty good bet that everything between them is good, too. */ static int -il4965_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) +il4965_verify_inst_sparse(struct il_priv *il, __le32 * image, u32 len) { u32 val; int ret = 0; @@ -57,12 +57,11 @@ il4965_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) D_INFO("ucode inst image size is %u\n", len); - for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { + for (i = 0; i < len; i += 100, image += 100 / sizeof(u32)) { /* read data comes through single port, auto-incr addr */ /* NOTE: Use the debugless read so we don't flood kernel log * if IL_DL_IO is set */ - il_wr(il, HBUS_TARG_MEM_RADDR, - i + IL4965_RTC_INST_LOWER_BOUND); + il_wr(il, HBUS_TARG_MEM_RADDR, i + IL4965_RTC_INST_LOWER_BOUND); val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { ret = -EIO; @@ -79,8 +78,8 @@ il4965_verify_inst_sparse(struct il_priv *il, __le32 *image, u32 len) * il4965_verify_inst_full - verify runtime uCode image in card vs. host, * looking at all data. */ -static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, - u32 len) +static int +il4965_verify_inst_full(struct il_priv *il, __le32 * image, u32 len) { u32 val; u32 save_len = len; @@ -89,8 +88,7 @@ static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, D_INFO("ucode inst image size is %u\n", len); - il_wr(il, HBUS_TARG_MEM_RADDR, - IL4965_RTC_INST_LOWER_BOUND); + il_wr(il, HBUS_TARG_MEM_RADDR, IL4965_RTC_INST_LOWER_BOUND); errcnt = 0; for (; len > 0; len -= sizeof(u32), image++) { @@ -100,8 +98,8 @@ static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, val = _il_rd(il, HBUS_TARG_MEM_RDAT); if (val != le32_to_cpu(*image)) { IL_ERR("uCode INST section is invalid at " - "offset 0x%x, is 0x%x, s/b 0x%x\n", - save_len - len, val, le32_to_cpu(*image)); + "offset 0x%x, is 0x%x, s/b 0x%x\n", + save_len - len, val, le32_to_cpu(*image)); ret = -EIO; errcnt++; if (errcnt >= 20) @@ -110,8 +108,7 @@ static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, } if (!errcnt) - D_INFO( - "ucode image in INSTRUCTION memory is good\n"); + D_INFO("ucode image in INSTRUCTION memory is good\n"); return ret; } @@ -120,14 +117,15 @@ static int il4965_verify_inst_full(struct il_priv *il, __le32 *image, * il4965_verify_ucode - determine which instruction image is in SRAM, * and verify its contents */ -int il4965_verify_ucode(struct il_priv *il) +int +il4965_verify_ucode(struct il_priv *il) { __le32 *image; u32 len; int ret; /* Try bootstrap */ - image = (__le32 *)il->ucode_boot.v_addr; + image = (__le32 *) il->ucode_boot.v_addr; len = il->ucode_boot.len; ret = il4965_verify_inst_sparse(il, image, len); if (!ret) { @@ -136,7 +134,7 @@ int il4965_verify_ucode(struct il_priv *il) } /* Try initialize */ - image = (__le32 *)il->ucode_init.v_addr; + image = (__le32 *) il->ucode_init.v_addr; len = il->ucode_init.len; ret = il4965_verify_inst_sparse(il, image, len); if (!ret) { @@ -145,7 +143,7 @@ int il4965_verify_ucode(struct il_priv *il) } /* Try runtime/protocol */ - image = (__le32 *)il->ucode_code.v_addr; + image = (__le32 *) il->ucode_code.v_addr; len = il->ucode_code.len; ret = il4965_verify_inst_sparse(il, image, len); if (!ret) { @@ -158,7 +156,7 @@ int il4965_verify_ucode(struct il_priv *il) /* Since nothing seems to match, show first several data entries in * instruction SRAM, so maybe visual inspection will give a clue. * Selection of bootstrap image (vs. other images) is arbitrary. */ - image = (__le32 *)il->ucode_boot.v_addr; + image = (__le32 *) il->ucode_boot.v_addr; len = il->ucode_boot.len; ret = il4965_verify_inst_full(il, image, len); @@ -177,7 +175,8 @@ int il4965_verify_ucode(struct il_priv *il) * EEPROM chip, not a single event, so even reads could conflict if they * weren't arbitrated by the semaphore. */ -int il4965_eeprom_acquire_semaphore(struct il_priv *il) +int +il4965_eeprom_acquire_semaphore(struct il_priv *il) { u16 count; int ret; @@ -185,13 +184,14 @@ int il4965_eeprom_acquire_semaphore(struct il_priv *il) for (count = 0; count < EEPROM_SEM_RETRY_LIMIT; count++) { /* Request semaphore */ il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); + CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); /* See if we got it */ - ret = _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, - CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, - EEPROM_SEM_TIMEOUT); + ret = + _il_poll_bit(il, CSR_HW_IF_CONFIG_REG, + CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, + CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM, + EEPROM_SEM_TIMEOUT); if (ret >= 0) return ret; } @@ -199,43 +199,43 @@ int il4965_eeprom_acquire_semaphore(struct il_priv *il) return ret; } -void il4965_eeprom_release_semaphore(struct il_priv *il) +void +il4965_eeprom_release_semaphore(struct il_priv *il) { il_clear_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); + CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM); } -int il4965_eeprom_check_version(struct il_priv *il) +int +il4965_eeprom_check_version(struct il_priv *il) { u16 eeprom_ver; u16 calib_ver; eeprom_ver = il_eeprom_query16(il, EEPROM_VERSION); - calib_ver = il_eeprom_query16(il, - EEPROM_4965_CALIB_VERSION_OFFSET); + calib_ver = il_eeprom_query16(il, EEPROM_4965_CALIB_VERSION_OFFSET); if (eeprom_ver < il->cfg->eeprom_ver || calib_ver < il->cfg->eeprom_calib_ver) goto err; - IL_INFO("device EEPROM VER=0x%x, CALIB=0x%x\n", - eeprom_ver, calib_ver); + IL_INFO("device EEPROM VER=0x%x, CALIB=0x%x\n", eeprom_ver, calib_ver); return 0; err: IL_ERR("Unsupported (too old) EEPROM VER=0x%x < 0x%x " - "CALIB=0x%x < 0x%x\n", - eeprom_ver, il->cfg->eeprom_ver, - calib_ver, il->cfg->eeprom_calib_ver); + "CALIB=0x%x < 0x%x\n", eeprom_ver, il->cfg->eeprom_ver, + calib_ver, il->cfg->eeprom_calib_ver); return -EINVAL; } -void il4965_eeprom_get_mac(const struct il_priv *il, u8 *mac) +void +il4965_eeprom_get_mac(const struct il_priv *il, u8 * mac) { const u8 *addr = il_eeprom_query_addr(il, - EEPROM_MAC_ADDRESS); + EEPROM_MAC_ADDRESS); memcpy(mac, addr, ETH_ALEN); } @@ -260,7 +260,8 @@ il4965_send_led_cmd(struct il_priv *il, struct il_led_cmd *led_cmd) } /* Set led register off */ -void il4965_led_enable(struct il_priv *il) +void +il4965_led_enable(struct il_priv *il) { _il_wr(il, CSR_LED_REG, CSR_LED_REG_TRUN_ON); } @@ -283,7 +284,8 @@ static int il4965_hw_get_temperature(struct il_priv *il); #define IL4965_MODULE_FIRMWARE(api) _IL4965_MODULE_FIRMWARE(api) /* check contents of special bootstrap uCode SRAM */ -static int il4965_verify_bsm(struct il_priv *il) +static int +il4965_verify_bsm(struct il_priv *il) { __le32 *image = il->ucode_boot.v_addr; u32 len = il->ucode_boot.len; @@ -294,16 +296,14 @@ static int il4965_verify_bsm(struct il_priv *il) /* verify BSM SRAM contents */ val = il_rd_prph(il, BSM_WR_DWCOUNT_REG); - for (reg = BSM_SRAM_LOWER_BOUND; - reg < BSM_SRAM_LOWER_BOUND + len; + for (reg = BSM_SRAM_LOWER_BOUND; reg < BSM_SRAM_LOWER_BOUND + len; reg += sizeof(u32), image++) { val = il_rd_prph(il, reg); if (val != le32_to_cpu(*image)) { IL_ERR("BSM uCode verification failed at " - "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", - BSM_SRAM_LOWER_BOUND, - reg - BSM_SRAM_LOWER_BOUND, len, - val, le32_to_cpu(*image)); + "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", + BSM_SRAM_LOWER_BOUND, reg - BSM_SRAM_LOWER_BOUND, + len, val, le32_to_cpu(*image)); return -EIO; } } @@ -345,7 +345,8 @@ static int il4965_verify_bsm(struct il_priv *il) * the runtime uCode instructions and the backup data cache into SRAM, * and re-launches the runtime uCode from where it left off. */ -static int il4965_load_bsm(struct il_priv *il) +static int +il4965_load_bsm(struct il_priv *il) { __le32 *image = il->ucode_boot.v_addr; u32 len = il->ucode_boot.len; @@ -394,8 +395,7 @@ static int il4965_load_bsm(struct il_priv *il) /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ il_wr_prph(il, BSM_WR_MEM_SRC_REG, 0x0); - il_wr_prph(il, - BSM_WR_MEM_DST_REG, IL49_RTC_INST_LOWER_BOUND); + il_wr_prph(il, BSM_WR_MEM_DST_REG, IL49_RTC_INST_LOWER_BOUND); il_wr_prph(il, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); /* Load bootstrap code into instruction SRAM now, @@ -418,9 +418,7 @@ static int il4965_load_bsm(struct il_priv *il) /* Enable future boot loads whenever power management unit triggers it * (e.g. when powering back up after power-save shutdown) */ - il_wr_prph(il, - BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN); - + il_wr_prph(il, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN); return 0; } @@ -434,7 +432,8 @@ static int il4965_load_bsm(struct il_priv *il) * We need to replace them to load runtime uCode inst and data, * and to save runtime data when powering down. */ -static int il4965_set_ucode_ptrs(struct il_priv *il) +static int +il4965_set_ucode_ptrs(struct il_priv *il) { dma_addr_t pinst; dma_addr_t pdata; @@ -447,13 +446,12 @@ static int il4965_set_ucode_ptrs(struct il_priv *il) /* Tell bootstrap uCode where to find image to load */ il_wr_prph(il, BSM_DRAM_INST_PTR_REG, pinst); il_wr_prph(il, BSM_DRAM_DATA_PTR_REG, pdata); - il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, - il->ucode_data.len); + il_wr_prph(il, BSM_DRAM_DATA_BYTECOUNT_REG, il->ucode_data.len); /* Inst byte count must be last to set up, bit 31 signals uCode * that all new ptr/size info is in place */ il_wr_prph(il, BSM_DRAM_INST_BYTECOUNT_REG, - il->ucode_code.len | BSM_DRAM_INST_LOAD); + il->ucode_code.len | BSM_DRAM_INST_LOAD); D_INFO("Runtime uCode pointers are set.\n"); return ret; @@ -470,7 +468,8 @@ static int il4965_set_ucode_ptrs(struct il_priv *il) * * Tell "initialize" uCode to go ahead and load the runtime uCode. */ -static void il4965_init_alive_start(struct il_priv *il) +static void +il4965_init_alive_start(struct il_priv *il) { /* Bootstrap uCode has loaded initialize uCode ... verify inst image. * This is a paranoid check, because we would not have gotten the @@ -501,15 +500,18 @@ restart: queue_work(il->workqueue, &il->restart); } -static bool iw4965_is_ht40_channel(__le32 rxon_flags) +static bool +iw4965_is_ht40_channel(__le32 rxon_flags) { - int chan_mod = le32_to_cpu(rxon_flags & RXON_FLG_CHANNEL_MODE_MSK) - >> RXON_FLG_CHANNEL_MODE_POS; + int chan_mod = + le32_to_cpu(rxon_flags & RXON_FLG_CHANNEL_MODE_MSK) >> + RXON_FLG_CHANNEL_MODE_POS; return (chan_mod == CHANNEL_MODE_PURE_40 || chan_mod == CHANNEL_MODE_MIXED); } -static void il4965_nic_config(struct il_priv *il) +static void +il4965_nic_config(struct il_priv *il) { unsigned long flags; u16 radio_cfg; @@ -521,18 +523,18 @@ static void il4965_nic_config(struct il_priv *il) /* write radio config values to register */ if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) == EEPROM_4965_RF_CFG_TYPE_MAX) il_set_bit(il, CSR_HW_IF_CONFIG_REG, - EEPROM_RF_CFG_TYPE_MSK(radio_cfg) | - EEPROM_RF_CFG_STEP_MSK(radio_cfg) | - EEPROM_RF_CFG_DASH_MSK(radio_cfg)); + EEPROM_RF_CFG_TYPE_MSK(radio_cfg) | + EEPROM_RF_CFG_STEP_MSK(radio_cfg) | + EEPROM_RF_CFG_DASH_MSK(radio_cfg)); /* set CSR_HW_CONFIG_REG for uCode use */ il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | - CSR_HW_IF_CONFIG_REG_BIT_MAC_SI); + CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | + CSR_HW_IF_CONFIG_REG_BIT_MAC_SI); - il->calib_info = (struct il_eeprom_calib_info *) - il_eeprom_query_addr(il, - EEPROM_4965_CALIB_TXPOWER_OFFSET); + il->calib_info = + (struct il_eeprom_calib_info *)il_eeprom_query_addr(il, + EEPROM_4965_CALIB_TXPOWER_OFFSET); spin_unlock_irqrestore(&il->lock, flags); } @@ -540,12 +542,12 @@ static void il4965_nic_config(struct il_priv *il) /* Reset differential Rx gains in NIC to prepare for chain noise calibration. * Called after every association, but this runs only once! * ... once chain noise is calibrated the first time, it's good forever. */ -static void il4965_chain_noise_reset(struct il_priv *il) +static void +il4965_chain_noise_reset(struct il_priv *il) { struct il_chain_noise_data *data = &(il->chain_noise_data); - if (data->state == IL_CHAIN_NOISE_ALIVE && - il_is_any_associated(il)) { + if (data->state == IL_CHAIN_NOISE_ALIVE && il_is_any_associated(il)) { struct il_calib_diff_gain_cmd cmd; /* clear data for chain noise calibration algorithm */ @@ -562,10 +564,8 @@ static void il4965_chain_noise_reset(struct il_priv *il) cmd.diff_gain_a = 0; cmd.diff_gain_b = 0; cmd.diff_gain_c = 0; - if (il_send_cmd_pdu(il, C_PHY_CALIBRATION, - sizeof(cmd), &cmd)) - IL_ERR( - "Could not send C_PHY_CALIBRATION\n"); + if (il_send_cmd_pdu(il, C_PHY_CALIBRATION, sizeof(cmd), &cmd)) + IL_ERR("Could not send C_PHY_CALIBRATION\n"); data->state = IL_CHAIN_NOISE_ACCUMULATE; D_CALIB("Run chain_noise_calibrate\n"); } @@ -573,7 +573,7 @@ static void il4965_chain_noise_reset(struct il_priv *il) static struct il_sensitivity_ranges il4965_sensitivity = { .min_nrg_cck = 97, - .max_nrg_cck = 0, /* not used, set to 0 */ + .max_nrg_cck = 0, /* not used, set to 0 */ .auto_corr_min_ofdm = 85, .auto_corr_min_ofdm_mrc = 170, @@ -598,11 +598,12 @@ static struct il_sensitivity_ranges il4965_sensitivity = { .nrg_th_cca = 62, }; -static void il4965_set_ct_threshold(struct il_priv *il) +static void +il4965_set_ct_threshold(struct il_priv *il) { /* want Kelvin */ il->hw_params.ct_kill_threshold = - CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY); + CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY); } /** @@ -610,18 +611,19 @@ static void il4965_set_ct_threshold(struct il_priv *il) * * Called when initializing driver */ -static int il4965_hw_set_hw_params(struct il_priv *il) +static int +il4965_hw_set_hw_params(struct il_priv *il) { if (il->cfg->mod_params->num_of_queues >= IL_MIN_NUM_QUEUES && il->cfg->mod_params->num_of_queues <= IL49_NUM_QUEUES) il->cfg->base_params->num_of_queues = - il->cfg->mod_params->num_of_queues; + il->cfg->mod_params->num_of_queues; il->hw_params.max_txq_num = il->cfg->base_params->num_of_queues; il->hw_params.dma_chnl_num = FH49_TCSR_CHNL_NUM; il->hw_params.scd_bc_tbls_size = - il->cfg->base_params->num_of_queues * - sizeof(struct il4965_scd_bc_tbl); + il->cfg->base_params->num_of_queues * + sizeof(struct il4965_scd_bc_tbl); il->hw_params.tfd_size = sizeof(struct il_tfd); il->hw_params.max_stations = IL4965_STATION_COUNT; il->ctx.bcast_sta_id = IL4965_BROADCAST_ID; @@ -645,7 +647,8 @@ static int il4965_hw_set_hw_params(struct il_priv *il) return 0; } -static s32 il4965_math_div_round(s32 num, s32 denom, s32 *res) +static s32 +il4965_math_div_round(s32 num, s32 denom, s32 * res) { s32 sign = 1; @@ -674,8 +677,8 @@ static s32 il4965_math_div_round(s32 num, s32 denom, s32 *res) * Voltage indication is higher for lower voltage. * Lower voltage requires more gain (lower gain table idx). */ -static s32 il4965_get_voltage_compensation(s32 eeprom_voltage, - s32 current_voltage) +static s32 +il4965_get_voltage_compensation(s32 eeprom_voltage, s32 current_voltage) { s32 comp = 0; @@ -684,7 +687,7 @@ static s32 il4965_get_voltage_compensation(s32 eeprom_voltage, return 0; il4965_math_div_round(current_voltage - eeprom_voltage, - TX_POWER_IL_VOLTAGE_CODES_PER_03V, &comp); + TX_POWER_IL_VOLTAGE_CODES_PER_03V, &comp); if (current_voltage > eeprom_voltage) comp *= 2; @@ -694,7 +697,8 @@ static s32 il4965_get_voltage_compensation(s32 eeprom_voltage, return comp; } -static s32 il4965_get_tx_atten_grp(u16 channel) +static s32 +il4965_get_tx_atten_grp(u16 channel) { if (channel >= CALIB_IL_TX_ATTEN_GR5_FCH && channel <= CALIB_IL_TX_ATTEN_GR5_LCH) @@ -719,7 +723,8 @@ static s32 il4965_get_tx_atten_grp(u16 channel) return -EINVAL; } -static u32 il4965_get_sub_band(const struct il_priv *il, u32 channel) +static u32 +il4965_get_sub_band(const struct il_priv *il, u32 channel) { s32 b = -1; @@ -735,7 +740,8 @@ static u32 il4965_get_sub_band(const struct il_priv *il, u32 channel) return b; } -static s32 il4965_interpolate_value(s32 x, s32 x1, s32 y1, s32 x2, s32 y2) +static s32 +il4965_interpolate_value(s32 x, s32 x1, s32 y1, s32 x2, s32 y2) { s32 val; @@ -755,8 +761,9 @@ static s32 il4965_interpolate_value(s32 x, s32 x1, s32 y1, s32 x2, s32 y2) * differences in channel frequencies, which is proportional to differences * in channel number. */ -static int il4965_interpolate_chan(struct il_priv *il, u32 channel, - struct il_eeprom_calib_ch_info *chan_info) +static int +il4965_interpolate_chan(struct il_priv *il, u32 channel, + struct il_eeprom_calib_ch_info *chan_info) { s32 s = -1; u32 c; @@ -777,8 +784,8 @@ static int il4965_interpolate_chan(struct il_priv *il, u32 channel, ch_i2 = il->calib_info->band_info[s].ch2.ch_num; chan_info->ch_num = (u8) channel; - D_TXPOWER("channel %d subband %d factory cal ch %d & %d\n", - channel, s, ch_i1, ch_i2); + D_TXPOWER("channel %d subband %d factory cal ch %d & %d\n", channel, s, + ch_i1, ch_i2); for (c = 0; c < EEPROM_TX_POWER_TX_CHAINS; c++) { for (m = 0; m < EEPROM_TX_POWER_MEASUREMENTS; m++) { @@ -790,36 +797,33 @@ static int il4965_interpolate_chan(struct il_priv *il, u32 channel, omeas->actual_pow = (u8) il4965_interpolate_value(channel, ch_i1, - m1->actual_pow, - ch_i2, - m2->actual_pow); + m1->actual_pow, ch_i2, + m2->actual_pow); omeas->gain_idx = (u8) il4965_interpolate_value(channel, ch_i1, - m1->gain_idx, ch_i2, - m2->gain_idx); + m1->gain_idx, ch_i2, + m2->gain_idx); omeas->temperature = (u8) il4965_interpolate_value(channel, ch_i1, - m1->temperature, - ch_i2, - m2->temperature); + m1->temperature, + ch_i2, + m2->temperature); omeas->pa_det = (s8) il4965_interpolate_value(channel, ch_i1, - m1->pa_det, ch_i2, - m2->pa_det); - - D_TXPOWER( - "chain %d meas %d AP1=%d AP2=%d AP=%d\n", c, m, - m1->actual_pow, m2->actual_pow, omeas->actual_pow); - D_TXPOWER( - "chain %d meas %d NI1=%d NI2=%d NI=%d\n", c, m, - m1->gain_idx, m2->gain_idx, omeas->gain_idx); - D_TXPOWER( - "chain %d meas %d PA1=%d PA2=%d PA=%d\n", c, m, - m1->pa_det, m2->pa_det, omeas->pa_det); - D_TXPOWER( - "chain %d meas %d T1=%d T2=%d T=%d\n", c, m, - m1->temperature, m2->temperature, - omeas->temperature); + m1->pa_det, ch_i2, + m2->pa_det); + + D_TXPOWER("chain %d meas %d AP1=%d AP2=%d AP=%d\n", c, + m, m1->actual_pow, m2->actual_pow, + omeas->actual_pow); + D_TXPOWER("chain %d meas %d NI1=%d NI2=%d NI=%d\n", c, + m, m1->gain_idx, m2->gain_idx, + omeas->gain_idx); + D_TXPOWER("chain %d meas %d PA1=%d PA2=%d PA=%d\n", c, + m, m1->pa_det, m2->pa_det, omeas->pa_det); + D_TXPOWER("chain %d meas %d T1=%d T2=%d T=%d\n", c, + m, m1->temperature, m2->temperature, + omeas->temperature); } } @@ -842,14 +846,20 @@ static struct il4965_txpower_comp_entry { s32 degrees_per_05db_a; s32 degrees_per_05db_a_denom; } tx_power_cmp_tble[CALIB_CH_GROUP_MAX] = { - {9, 2}, /* group 0 5.2, ch 34-43 */ - {4, 1}, /* group 1 5.2, ch 44-70 */ - {4, 1}, /* group 2 5.2, ch 71-124 */ - {4, 1}, /* group 3 5.2, ch 125-200 */ - {3, 1} /* group 4 2.4, ch all */ + { + 9, 2}, /* group 0 5.2, ch 34-43 */ + { + 4, 1}, /* group 1 5.2, ch 44-70 */ + { + 4, 1}, /* group 2 5.2, ch 71-124 */ + { + 4, 1}, /* group 3 5.2, ch 125-200 */ + { + 3, 1} /* group 4 2.4, ch all */ }; -static s32 get_min_power_idx(s32 rate_power_idx, u32 band) +static s32 +get_min_power_idx(s32 rate_power_idx, u32 band) { if (!band) { if ((rate_power_idx & 7) <= 4) @@ -1088,9 +1098,10 @@ static const struct gain_entry gain_table[2][108] = { } }; -static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, - u8 is_ht40, u8 ctrl_chan_high, - struct il4965_tx_power_db *tx_power_tbl) +static int +il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, u8 is_ht40, + u8 ctrl_chan_high, + struct il4965_tx_power_db *tx_power_tbl) { u8 saturation_power; s32 target_power; @@ -1121,8 +1132,7 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, user_target_power = 2 * il->tx_power_user_lmt; /* Get current (RXON) channel, band, width */ - D_TXPOWER("chan %d band %d is_ht40 %d\n", channel, band, - is_ht40); + D_TXPOWER("chan %d band %d is_ht40 %d\n", channel, band, is_ht40); ch_info = il_get_channel_info(il, il->band, channel); @@ -1133,13 +1143,12 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, * and 2) mimo txpower balance between Tx chains. */ txatten_grp = il4965_get_tx_atten_grp(channel); if (txatten_grp < 0) { - IL_ERR("Can't find txatten group for channel %d.\n", - channel); + IL_ERR("Can't find txatten group for channel %d.\n", channel); return txatten_grp; } - D_TXPOWER("channel %d belongs to txatten group %d\n", - channel, txatten_grp); + D_TXPOWER("channel %d belongs to txatten group %d\n", channel, + txatten_grp); if (is_ht40) { if (ctrl_chan_high) @@ -1184,13 +1193,12 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, /* calculate tx gain adjustment based on power supply voltage */ voltage = le16_to_cpu(il->calib_info->voltage); - init_voltage = (s32)le32_to_cpu(il->card_alive_init.voltage); + init_voltage = (s32) le32_to_cpu(il->card_alive_init.voltage); voltage_compensation = il4965_get_voltage_compensation(voltage, init_voltage); - D_TXPOWER("curr volt %d eeprom volt %d volt comp %d\n", - init_voltage, - voltage, voltage_compensation); + D_TXPOWER("curr volt %d eeprom volt %d volt comp %d\n", init_voltage, + voltage, voltage_compensation); /* get current temperature (Celsius) */ current_temp = max(il->temperature, IL_TX_POWER_TEMPERATURE_MIN); @@ -1211,23 +1219,20 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, /* txgain adjustment (in half-dB steps) based on difference * between factory and current temperature */ factory_temp = measurement->temperature; - il4965_math_div_round((current_temp - factory_temp) * - degrees_per_05db_denom, - degrees_per_05db_num, - &temperature_comp[c]); + il4965_math_div_round((current_temp - + factory_temp) * degrees_per_05db_denom, + degrees_per_05db_num, + &temperature_comp[c]); factory_gain_idx[c] = measurement->gain_idx; factory_actual_pwr[c] = measurement->actual_pow; D_TXPOWER("chain = %d\n", c); - D_TXPOWER("fctry tmp %d, " - "curr tmp %d, comp %d steps\n", - factory_temp, current_temp, - temperature_comp[c]); - - D_TXPOWER("fctry idx %d, fctry pwr %d\n", - factory_gain_idx[c], - factory_actual_pwr[c]); + D_TXPOWER("fctry tmp %d, " "curr tmp %d, comp %d steps\n", + factory_temp, current_temp, temperature_comp[c]); + + D_TXPOWER("fctry idx %d, fctry pwr %d\n", factory_gain_idx[c], + factory_actual_pwr[c]); } /* for each of 33 bit-rates (including 1 for CCK) */ @@ -1239,7 +1244,8 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, * (3dB, 6 steps), so total output power is regulatory * compliant. */ if (i & 0x8) { - current_regulatory = reg_limit - + current_regulatory = + reg_limit - IL_TX_POWER_MIMO_REGULATORY_COMPENSATION; is_mimo_rate = 1; } else { @@ -1258,10 +1264,9 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, if (target_power > power_limit) target_power = power_limit; - D_TXPOWER("rate %d sat %d reg %d usr %d tgt %d\n", - i, saturation_power - back_off_table[i], - current_regulatory, user_target_power, - target_power); + D_TXPOWER("rate %d sat %d reg %d usr %d tgt %d\n", i, + saturation_power - back_off_table[i], + current_regulatory, user_target_power, target_power); /* for each of 2 Tx chains (radio transmitters) */ for (c = 0; c < 2; c++) { @@ -1269,18 +1274,17 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, if (is_mimo_rate) atten_value = - (s32)le32_to_cpu(il->card_alive_init. - tx_atten[txatten_grp][c]); + (s32) le32_to_cpu(il->card_alive_init. + tx_atten[txatten_grp][c]); else atten_value = 0; /* calculate idx; higher idx means lower txpower */ - power_idx = (u8) (factory_gain_idx[c] - - (target_power - - factory_actual_pwr[c]) - - temperature_comp[c] - - voltage_compensation + - atten_value); + power_idx = + (u8) (factory_gain_idx[c] - + (target_power - factory_actual_pwr[c]) - + temperature_comp[c] - voltage_compensation + + atten_value); /* D_TXPOWER("calculated txpower idx %d\n", power_idx); */ @@ -1299,32 +1303,29 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, /* stay within the table! */ if (power_idx > 107) { - IL_WARN("txpower idx %d > 107\n", - power_idx); + IL_WARN("txpower idx %d > 107\n", power_idx); power_idx = 107; } if (power_idx < 0) { - IL_WARN("txpower idx %d < 0\n", - power_idx); + IL_WARN("txpower idx %d < 0\n", power_idx); power_idx = 0; } /* fill txpower command for this rate/chain */ tx_power.s.radio_tx_gain[c] = - gain_table[band][power_idx].radio; + gain_table[band][power_idx].radio; tx_power.s.dsp_predis_atten[c] = - gain_table[band][power_idx].dsp; + gain_table[band][power_idx].dsp; D_TXPOWER("chain %d mimo %d idx %d " - "gain 0x%02x dsp %d\n", - c, atten_value, power_idx, - tx_power.s.radio_tx_gain[c], - tx_power.s.dsp_predis_atten[c]); - } /* for each chain */ + "gain 0x%02x dsp %d\n", c, atten_value, + power_idx, tx_power.s.radio_tx_gain[c], + tx_power.s.dsp_predis_atten[c]); + } /* for each chain */ tx_power_tbl->power_tbl[i].dw = cpu_to_le32(tx_power.dw); - } /* for each rate */ + } /* for each rate */ return 0; } @@ -1335,7 +1336,8 @@ static int il4965_fill_txpower_tbl(struct il_priv *il, u8 band, u16 channel, * Uses the active RXON for channel, band, and characteristics (ht40, high) * The power limit is taken from il->tx_power_user_lmt. */ -static int il4965_send_tx_power(struct il_priv *il) +static int +il4965_send_tx_power(struct il_priv *il) { struct il4965_txpowertable_cmd cmd = { 0 }; int ret; @@ -1344,8 +1346,9 @@ static int il4965_send_tx_power(struct il_priv *il) u8 ctrl_chan_high = 0; struct il_rxon_context *ctx = &il->ctx; - if (WARN_ONCE(test_bit(S_SCAN_HW, &il->status), - "TX Power requested while scanning!\n")) + if (WARN_ONCE + (test_bit(S_SCAN_HW, &il->status), + "TX Power requested while scanning!\n")) return -EAGAIN; band = il->band == IEEE80211_BAND_2GHZ; @@ -1358,21 +1361,20 @@ static int il4965_send_tx_power(struct il_priv *il) cmd.band = band; cmd.channel = ctx->active.channel; - ret = il4965_fill_txpower_tbl(il, band, - le16_to_cpu(ctx->active.channel), - is_ht40, ctrl_chan_high, &cmd.tx_power); + ret = + il4965_fill_txpower_tbl(il, band, le16_to_cpu(ctx->active.channel), + is_ht40, ctrl_chan_high, &cmd.tx_power); if (ret) goto out; - ret = il_send_cmd_pdu(il, - C_TX_PWR_TBL, sizeof(cmd), &cmd); + ret = il_send_cmd_pdu(il, C_TX_PWR_TBL, sizeof(cmd), &cmd); out: return ret; } -static int il4965_send_rxon_assoc(struct il_priv *il, - struct il_rxon_context *ctx) +static int +il4965_send_rxon_assoc(struct il_priv *il, struct il_rxon_context *ctx) { int ret = 0; struct il4965_rxon_assoc_cmd rxon_assoc; @@ -1383,9 +1385,9 @@ static int il4965_send_rxon_assoc(struct il_priv *il, rxon1->filter_flags == rxon2->filter_flags && rxon1->cck_basic_rates == rxon2->cck_basic_rates && rxon1->ofdm_ht_single_stream_basic_rates == - rxon2->ofdm_ht_single_stream_basic_rates && + rxon2->ofdm_ht_single_stream_basic_rates && rxon1->ofdm_ht_dual_stream_basic_rates == - rxon2->ofdm_ht_dual_stream_basic_rates && + rxon2->ofdm_ht_dual_stream_basic_rates && rxon1->rx_chain == rxon2->rx_chain && rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates) { D_INFO("Using current RXON_ASSOC. Not resending.\n"); @@ -1403,19 +1405,20 @@ static int il4965_send_rxon_assoc(struct il_priv *il, ctx->staging.ofdm_ht_dual_stream_basic_rates; rxon_assoc.rx_chain_select_flags = ctx->staging.rx_chain; - ret = il_send_cmd_pdu_async(il, C_RXON_ASSOC, - sizeof(rxon_assoc), &rxon_assoc, NULL); + ret = + il_send_cmd_pdu_async(il, C_RXON_ASSOC, sizeof(rxon_assoc), + &rxon_assoc, NULL); return ret; } -static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) +static int +il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) { /* cast away the const for active_rxon in this function */ struct il_rxon_cmd *active_rxon = (void *)&ctx->active; int ret; - bool new_assoc = - !!(ctx->staging.filter_flags & RXON_FILTER_ASSOC_MSK); + bool new_assoc = !!(ctx->staging.filter_flags & RXON_FILTER_ASSOC_MSK); if (!il_is_alive(il)) return -EBUSY; @@ -1471,9 +1474,9 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) D_INFO("Toggling associated bit on current RXON\n"); active_rxon->filter_flags &= ~RXON_FILTER_ASSOC_MSK; - ret = il_send_cmd_pdu(il, ctx->rxon_cmd, - sizeof(struct il_rxon_cmd), - active_rxon); + ret = + il_send_cmd_pdu(il, ctx->rxon_cmd, + sizeof(struct il_rxon_cmd), active_rxon); /* If the mask clearing failed then we set * active_rxon back to what it was previously */ @@ -1491,24 +1494,20 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) } } - D_INFO("Sending RXON\n" - "* with%s RXON_FILTER_ASSOC_MSK\n" - "* channel = %d\n" - "* bssid = %pM\n", - (new_assoc ? "" : "out"), - le16_to_cpu(ctx->staging.channel), - ctx->staging.bssid_addr); + D_INFO("Sending RXON\n" "* with%s RXON_FILTER_ASSOC_MSK\n" + "* channel = %d\n" "* bssid = %pM\n", (new_assoc ? "" : "out"), + le16_to_cpu(ctx->staging.channel), ctx->staging.bssid_addr); - il_set_rxon_hwcrypto(il, ctx, - !il->cfg->mod_params->sw_crypto); + il_set_rxon_hwcrypto(il, ctx, !il->cfg->mod_params->sw_crypto); /* Apply the new configuration * RXON unassoc clears the station table in uCode so restoration of * stations is needed after it (the RXON command) completes */ if (!new_assoc) { - ret = il_send_cmd_pdu(il, ctx->rxon_cmd, - sizeof(struct il_rxon_cmd), &ctx->staging); + ret = + il_send_cmd_pdu(il, ctx->rxon_cmd, + sizeof(struct il_rxon_cmd), &ctx->staging); if (ret) { IL_ERR("Error setting new RXON (%d)\n", ret); return ret; @@ -1528,8 +1527,9 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) /* Apply the new configuration * RXON assoc doesn't clear the station table in uCode, */ - ret = il_send_cmd_pdu(il, ctx->rxon_cmd, - sizeof(struct il_rxon_cmd), &ctx->staging); + ret = + il_send_cmd_pdu(il, ctx->rxon_cmd, + sizeof(struct il_rxon_cmd), &ctx->staging); if (ret) { IL_ERR("Error setting new RXON (%d)\n", ret); return ret; @@ -1551,8 +1551,9 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) return 0; } -static int il4965_hw_channel_switch(struct il_priv *il, - struct ieee80211_channel_switch *ch_switch) +static int +il4965_hw_channel_switch(struct il_priv *il, + struct ieee80211_channel_switch *ch_switch) { struct il_rxon_context *ctx = &il->ctx; int rc; @@ -1571,8 +1572,7 @@ static int il4965_hw_channel_switch(struct il_priv *il, is_ht40 = iw4965_is_ht40_channel(ctx->staging.flags); - if (is_ht40 && - (ctx->staging.flags & RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK)) + if (is_ht40 && (ctx->staging.flags & RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK)) ctrl_chan_high = 1; cmd.band = band; @@ -1588,10 +1588,10 @@ static int il4965_hw_channel_switch(struct il_priv *il, * adding TSF as one of the factor for when to switch */ if (il->ucode_beacon_time > tsf_low && beacon_interval) { - if (switch_count > ((il->ucode_beacon_time - tsf_low) / - beacon_interval)) { - switch_count -= (il->ucode_beacon_time - - tsf_low) / beacon_interval; + if (switch_count > + ((il->ucode_beacon_time - tsf_low) / beacon_interval)) { + switch_count -= + (il->ucode_beacon_time - tsf_low) / beacon_interval; } else switch_count = 0; } @@ -1599,43 +1599,40 @@ static int il4965_hw_channel_switch(struct il_priv *il, cmd.switch_time = cpu_to_le32(il->ucode_beacon_time); else { switch_time_in_usec = - vif->bss_conf.beacon_int * switch_count * TIME_UNIT; - ucode_switch_time = il_usecs_to_beacons(il, - switch_time_in_usec, - beacon_interval); - cmd.switch_time = il_add_beacon_time(il, - il->ucode_beacon_time, - ucode_switch_time, - beacon_interval); + vif->bss_conf.beacon_int * switch_count * TIME_UNIT; + ucode_switch_time = + il_usecs_to_beacons(il, switch_time_in_usec, + beacon_interval); + cmd.switch_time = + il_add_beacon_time(il, il->ucode_beacon_time, + ucode_switch_time, beacon_interval); } - D_11H("uCode time for the switch is 0x%x\n", - cmd.switch_time); + D_11H("uCode time for the switch is 0x%x\n", cmd.switch_time); ch_info = il_get_channel_info(il, il->band, ch); if (ch_info) cmd.expect_beacon = il_is_channel_radar(ch_info); else { IL_ERR("invalid channel switch from %u to %u\n", - ctx->active.channel, ch); + ctx->active.channel, ch); return -EFAULT; } - rc = il4965_fill_txpower_tbl(il, band, ch, is_ht40, - ctrl_chan_high, &cmd.tx_power); + rc = il4965_fill_txpower_tbl(il, band, ch, is_ht40, ctrl_chan_high, + &cmd.tx_power); if (rc) { D_11H("error:%d fill txpower_tbl\n", rc); return rc; } - return il_send_cmd_pdu(il, - C_CHANNEL_SWITCH, sizeof(cmd), &cmd); + return il_send_cmd_pdu(il, C_CHANNEL_SWITCH, sizeof(cmd), &cmd); } /** * il4965_txq_update_byte_cnt_tbl - Set up entry in Tx byte-count array */ -static void il4965_txq_update_byte_cnt_tbl(struct il_priv *il, - struct il_tx_queue *txq, - u16 byte_cnt) +static void +il4965_txq_update_byte_cnt_tbl(struct il_priv *il, struct il_tx_queue *txq, + u16 byte_cnt) { struct il4965_scd_bc_tbl *scd_bc_tbl = il->scd_bc_tbls.addr; int txq_id = txq->q.id; @@ -1651,8 +1648,8 @@ static void il4965_txq_update_byte_cnt_tbl(struct il_priv *il, /* If within first 64 entries, duplicate at end */ if (write_ptr < TFD_QUEUE_SIZE_BC_DUP) - scd_bc_tbl[txq_id]. - tfd_offset[TFD_QUEUE_SIZE_MAX + write_ptr] = bc_ent; + scd_bc_tbl[txq_id].tfd_offset[TFD_QUEUE_SIZE_MAX + write_ptr] = + bc_ent; } /** @@ -1661,7 +1658,8 @@ static void il4965_txq_update_byte_cnt_tbl(struct il_priv *il, * * A return of <0 indicates bogus data in the stats */ -static int il4965_hw_get_temperature(struct il_priv *il) +static int +il4965_hw_get_temperature(struct il_priv *il) { s32 temperature; s32 vt; @@ -1669,18 +1667,17 @@ static int il4965_hw_get_temperature(struct il_priv *il) u32 R4; if (test_bit(S_TEMPERATURE, &il->status) && - (il->_4965.stats.flag & - STATS_REPLY_FLG_HT40_MODE_MSK)) { + (il->_4965.stats.flag & STATS_REPLY_FLG_HT40_MODE_MSK)) { D_TEMP("Running HT40 temperature calibration\n"); - R1 = (s32)le32_to_cpu(il->card_alive_init.therm_r1[1]); - R2 = (s32)le32_to_cpu(il->card_alive_init.therm_r2[1]); - R3 = (s32)le32_to_cpu(il->card_alive_init.therm_r3[1]); + R1 = (s32) le32_to_cpu(il->card_alive_init.therm_r1[1]); + R2 = (s32) le32_to_cpu(il->card_alive_init.therm_r2[1]); + R3 = (s32) le32_to_cpu(il->card_alive_init.therm_r3[1]); R4 = le32_to_cpu(il->card_alive_init.therm_r4[1]); } else { D_TEMP("Running temperature calibration\n"); - R1 = (s32)le32_to_cpu(il->card_alive_init.therm_r1[0]); - R2 = (s32)le32_to_cpu(il->card_alive_init.therm_r2[0]); - R3 = (s32)le32_to_cpu(il->card_alive_init.therm_r3[0]); + R1 = (s32) le32_to_cpu(il->card_alive_init.therm_r1[0]); + R2 = (s32) le32_to_cpu(il->card_alive_init.therm_r2[0]); + R3 = (s32) le32_to_cpu(il->card_alive_init.therm_r3[0]); R4 = le32_to_cpu(il->card_alive_init.therm_r4[0]); } @@ -1694,8 +1691,9 @@ static int il4965_hw_get_temperature(struct il_priv *il) if (!test_bit(S_TEMPERATURE, &il->status)) vt = sign_extend32(R4, 23); else - vt = sign_extend32(le32_to_cpu(il->_4965.stats. - general.common.temperature), 23); + vt = sign_extend32(le32_to_cpu + (il->_4965.stats.general.common.temperature), + 23); D_TEMP("Calib values R[1-3]: %d %d %d R4: %d\n", R1, R2, R3, vt); @@ -1708,10 +1706,11 @@ static int il4965_hw_get_temperature(struct il_priv *il) * Add offset to center the adjustment around 0 degrees Centigrade. */ temperature = TEMPERATURE_CALIB_A_VAL * (vt - R2); temperature /= (R3 - R1); - temperature = (temperature * 97) / 100 + TEMPERATURE_CALIB_KELVIN_OFFSET; + temperature = + (temperature * 97) / 100 + TEMPERATURE_CALIB_KELVIN_OFFSET; - D_TEMP("Calibrated temperature: %dK, %dC\n", - temperature, KELVIN_TO_CELSIUS(temperature)); + D_TEMP("Calibrated temperature: %dK, %dC\n", temperature, + KELVIN_TO_CELSIUS(temperature)); return temperature; } @@ -1728,7 +1727,8 @@ static int il4965_hw_get_temperature(struct il_priv *il) * Assumes caller will replace il->last_temperature once calibration * executed. */ -static int il4965_is_temp_calib_needed(struct il_priv *il) +static int +il4965_is_temp_calib_needed(struct il_priv *il) { int temp_diff; @@ -1758,7 +1758,8 @@ static int il4965_is_temp_calib_needed(struct il_priv *il) return 1; } -static void il4965_temperature_calib(struct il_priv *il) +static void +il4965_temperature_calib(struct il_priv *il) { s32 temp; @@ -1768,26 +1769,25 @@ static void il4965_temperature_calib(struct il_priv *il) if (il->temperature != temp) { if (il->temperature) - D_TEMP("Temperature changed " - "from %dC to %dC\n", - KELVIN_TO_CELSIUS(il->temperature), - KELVIN_TO_CELSIUS(temp)); + D_TEMP("Temperature changed " "from %dC to %dC\n", + KELVIN_TO_CELSIUS(il->temperature), + KELVIN_TO_CELSIUS(temp)); else - D_TEMP("Temperature " - "initialized to %dC\n", - KELVIN_TO_CELSIUS(temp)); + D_TEMP("Temperature " "initialized to %dC\n", + KELVIN_TO_CELSIUS(temp)); } il->temperature = temp; set_bit(S_TEMPERATURE, &il->status); if (!il->disable_tx_power_cal && - unlikely(!test_bit(S_SCANNING, &il->status)) && - il4965_is_temp_calib_needed(il)) + unlikely(!test_bit(S_SCANNING, &il->status)) && + il4965_is_temp_calib_needed(il)) queue_work(il->workqueue, &il->txpower_work); } -static u16 il4965_get_hcmd_size(u8 cmd_id, u16 len) +static u16 +il4965_get_hcmd_size(u8 cmd_id, u16 len) { switch (cmd_id) { case C_RXON: @@ -1797,8 +1797,8 @@ static u16 il4965_get_hcmd_size(u8 cmd_id, u16 len) } } -static u16 il4965_build_addsta_hcmd(const struct il_addsta_cmd *cmd, - u8 *data) +static u16 +il4965_build_addsta_hcmd(const struct il_addsta_cmd *cmd, u8 * data) { struct il4965_addsta_cmd *addsta = (struct il4965_addsta_cmd *)data; addsta->mode = cmd->mode; @@ -1814,15 +1814,17 @@ static u16 il4965_build_addsta_hcmd(const struct il_addsta_cmd *cmd, addsta->reserved1 = cpu_to_le16(0); addsta->reserved2 = cpu_to_le16(0); - return (u16)sizeof(struct il4965_addsta_cmd); + return (u16) sizeof(struct il4965_addsta_cmd); } -static inline u32 il4965_get_scd_ssn(struct il4965_tx_resp *tx_resp) +static inline u32 +il4965_get_scd_ssn(struct il4965_tx_resp *tx_resp) { return le32_to_cpup(&tx_resp->u.status + tx_resp->frame_count) & MAX_SN; } -static inline u32 il4965_tx_status_to_mac80211(u32 status) +static inline u32 +il4965_tx_status_to_mac80211(u32 status) { status &= TX_STATUS_MSK; @@ -1837,20 +1839,20 @@ static inline u32 il4965_tx_status_to_mac80211(u32 status) } } -static inline bool il4965_is_tx_success(u32 status) +static inline bool +il4965_is_tx_success(u32 status) { status &= TX_STATUS_MSK; - return (status == TX_STATUS_SUCCESS || - status == TX_STATUS_DIRECT_DONE); + return (status == TX_STATUS_SUCCESS || status == TX_STATUS_DIRECT_DONE); } /** * il4965_tx_status_reply_tx - Handle Tx response for frames in aggregation queue */ -static int il4965_tx_status_reply_tx(struct il_priv *il, - struct il_ht_agg *agg, - struct il4965_tx_resp *tx_resp, - int txq_id, u16 start_idx) +static int +il4965_tx_status_reply_tx(struct il_priv *il, struct il_ht_agg *agg, + struct il4965_tx_resp *tx_resp, int txq_id, + u16 start_idx) { u16 status; struct agg_tx_status *frame_status = tx_resp->u.agg_status; @@ -1874,7 +1876,7 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, idx = start_idx; D_TX_REPLY("FrameCnt = %d, StartIdx=%d idx=%d\n", - agg->frame_count, agg->start_idx, idx); + agg->frame_count, agg->start_idx, idx); info = IEEE80211_SKB_CB(il->txq[txq_id].txb[idx].skb); info->status.rates[0].count = tx_resp->failure_frame + 1; @@ -1882,8 +1884,8 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, info->flags |= il4965_tx_status_to_mac80211(status); il4965_hwrate_to_tx_control(il, rate_n_flags, info); - D_TX_REPLY("1 Frame 0x%x failure :%d\n", - status & 0xff, tx_resp->failure_frame); + D_TX_REPLY("1 Frame 0x%x failure :%d\n", status & 0xff, + tx_resp->failure_frame); D_TX_REPLY("Rate Info rate_n_flags=%x\n", rate_n_flags); agg->wait_for_ba = 0; @@ -1896,36 +1898,35 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, for (i = 0; i < agg->frame_count; i++) { u16 sc; status = le16_to_cpu(frame_status[i].status); - seq = le16_to_cpu(frame_status[i].sequence); + seq = le16_to_cpu(frame_status[i].sequence); idx = SEQ_TO_IDX(seq); txq_id = SEQ_TO_QUEUE(seq); - if (status & (AGG_TX_STATE_FEW_BYTES_MSK | - AGG_TX_STATE_ABORT_MSK)) + if (status & + (AGG_TX_STATE_FEW_BYTES_MSK | + AGG_TX_STATE_ABORT_MSK)) continue; D_TX_REPLY("FrameCnt = %d, txq_id=%d idx=%d\n", - agg->frame_count, txq_id, idx); + agg->frame_count, txq_id, idx); hdr = il_tx_queue_get_hdr(il, txq_id, idx); if (!hdr) { - IL_ERR( - "BUG_ON idx doesn't point to valid skb" - " idx=%d, txq_id=%d\n", idx, txq_id); + IL_ERR("BUG_ON idx doesn't point to valid skb" + " idx=%d, txq_id=%d\n", idx, txq_id); return -1; } sc = le16_to_cpu(hdr->seq_ctrl); if (idx != (SEQ_TO_SN(sc) & 0xff)) { - IL_ERR( - "BUG_ON idx doesn't match seq control" - " idx=%d, seq_idx=%d, seq=%d\n", - idx, SEQ_TO_SN(sc), hdr->seq_ctrl); + IL_ERR("BUG_ON idx doesn't match seq control" + " idx=%d, seq_idx=%d, seq=%d\n", idx, + SEQ_TO_SN(sc), hdr->seq_ctrl); return -1; } - D_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n", - i, idx, SEQ_TO_SN(sc)); + D_TX_REPLY("AGG Frame i=%d idx %d seq=%d\n", i, idx, + SEQ_TO_SN(sc)); sh = idx - start; if (sh > 64) { @@ -1934,7 +1935,7 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, sh = 0; start = idx; } else if (sh < -64) - sh = 0xff - (start - idx); + sh = 0xff - (start - idx); else if (sh < 0) { sh = start - idx; start = idx; @@ -1942,15 +1943,15 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, sh = 0; } bitmap |= 1ULL << sh; - D_TX_REPLY("start=%d bitmap=0x%llx\n", - start, (unsigned long long)bitmap); + D_TX_REPLY("start=%d bitmap=0x%llx\n", start, + (unsigned long long)bitmap); } agg->bitmap = bitmap; agg->start_idx = start; D_TX_REPLY("Frames %d start_idx=%d bitmap=0x%llx\n", - agg->frame_count, agg->start_idx, - (unsigned long long)agg->bitmap); + agg->frame_count, agg->start_idx, + (unsigned long long)agg->bitmap); if (bitmap) agg->wait_for_ba = 1; @@ -1958,7 +1959,8 @@ static int il4965_tx_status_reply_tx(struct il_priv *il, return 0; } -static u8 il4965_find_station(struct il_priv *il, const u8 *addr) +static u8 +il4965_find_station(struct il_priv *il, const u8 * addr) { int i; int start = 0; @@ -1974,16 +1976,14 @@ static u8 il4965_find_station(struct il_priv *il, const u8 *addr) spin_lock_irqsave(&il->sta_lock, flags); for (i = start; i < il->hw_params.max_stations; i++) if (il->stations[i].used && - (!compare_ether_addr(il->stations[i].sta.sta.addr, - addr))) { + (!compare_ether_addr(il->stations[i].sta.sta.addr, addr))) { ret = i; goto out; } - D_ASSOC("can not find STA %pM total %d\n", - addr, il->num_stations); + D_ASSOC("can not find STA %pM total %d\n", addr, il->num_stations); - out: +out: /* * It may be possible that more commands interacting with stations * arrive before we completed processing the adding of @@ -1994,14 +1994,15 @@ static u8 il4965_find_station(struct il_priv *il, const u8 *addr) ((il->stations[ret].used & IL_STA_UCODE_ACTIVE) && (il->stations[ret].used & IL_STA_UCODE_INPROGRESS)))) { IL_ERR("Requested station info for sta %d before ready.\n", - ret); + ret); ret = IL_INVALID_STATION; } spin_unlock_irqrestore(&il->sta_lock, flags); return ret; } -static int il4965_get_ra_sta_id(struct il_priv *il, struct ieee80211_hdr *hdr) +static int +il4965_get_ra_sta_id(struct il_priv *il, struct ieee80211_hdr *hdr) { if (il->iw_mode == NL80211_IFTYPE_STATION) { return IL_AP_ID; @@ -2014,8 +2015,8 @@ static int il4965_get_ra_sta_id(struct il_priv *il, struct ieee80211_hdr *hdr) /** * il4965_hdl_tx - Handle standard (non-aggregation) Tx response */ -static void il4965_hdl_tx(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il4965_hdl_tx(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); u16 sequence = le16_to_cpu(pkt->hdr.sequence); @@ -2025,7 +2026,7 @@ static void il4965_hdl_tx(struct il_priv *il, struct ieee80211_hdr *hdr; struct ieee80211_tx_info *info; struct il4965_tx_resp *tx_resp = (void *)&pkt->u.raw[0]; - u32 status = le32_to_cpu(tx_resp->u.status); + u32 status = le32_to_cpu(tx_resp->u.status); int uninitialized_var(tid); int sta_id; int freed; @@ -2034,9 +2035,8 @@ static void il4965_hdl_tx(struct il_priv *il, if (idx >= txq->q.n_bd || il_queue_used(&txq->q, idx) == 0) { IL_ERR("Read idx for DMA queue txq_id (%d) idx %d " - "is out of range [0-%d] %d %d\n", txq_id, - idx, txq->q.n_bd, txq->q.write_ptr, - txq->q.read_ptr); + "is out of range [0-%d] %d %d\n", txq_id, idx, + txq->q.n_bd, txq->q.write_ptr, txq->q.read_ptr); return; } @@ -2067,18 +2067,18 @@ static void il4965_hdl_tx(struct il_priv *il, il4965_tx_status_reply_tx(il, agg, tx_resp, txq_id, idx); /* check if BAR is needed */ - if ((tx_resp->frame_count == 1) && !il4965_is_tx_success(status)) + if ((tx_resp->frame_count == 1) && + !il4965_is_tx_success(status)) info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK; if (txq->q.read_ptr != (scd_ssn & 0xff)) { - idx = il_queue_dec_wrap(scd_ssn & 0xff, - txq->q.n_bd); + idx = il_queue_dec_wrap(scd_ssn & 0xff, txq->q.n_bd); D_TX_REPLY("Retry scheduler reclaim scd_ssn " - "%d idx %d\n", scd_ssn , idx); + "%d idx %d\n", scd_ssn, idx); freed = il4965_tx_queue_reclaim(il, txq_id, idx); if (qc) - il4965_free_tfds_in_queue(il, sta_id, - tid, freed); + il4965_free_tfds_in_queue(il, sta_id, tid, + freed); if (il->mac80211_registered && il_queue_space(&txq->q) > txq->q.low_mark && @@ -2089,15 +2089,14 @@ static void il4965_hdl_tx(struct il_priv *il, info->status.rates[0].count = tx_resp->failure_frame + 1; info->flags |= il4965_tx_status_to_mac80211(status); il4965_hwrate_to_tx_control(il, - le32_to_cpu(tx_resp->rate_n_flags), - info); + le32_to_cpu(tx_resp->rate_n_flags), + info); D_TX_REPLY("TXQ %d status %s (0x%08x) " - "rate_n_flags 0x%x retries %d\n", - txq_id, - il4965_get_tx_fail_reason(status), status, - le32_to_cpu(tx_resp->rate_n_flags), - tx_resp->failure_frame); + "rate_n_flags 0x%x retries %d\n", txq_id, + il4965_get_tx_fail_reason(status), status, + le32_to_cpu(tx_resp->rate_n_flags), + tx_resp->failure_frame); freed = il4965_tx_queue_reclaim(il, txq_id, idx); if (qc && likely(sta_id != IL_INVALID_STATION)) @@ -2117,27 +2116,27 @@ static void il4965_hdl_tx(struct il_priv *il, spin_unlock_irqrestore(&il->sta_lock, flags); } -static void il4965_hdl_beacon(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il4965_hdl_beacon(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il4965_beacon_notif *beacon = (void *)pkt->u.raw; u8 rate __maybe_unused = - il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); + il4965_hw_get_rate(beacon->beacon_notify_hdr.rate_n_flags); D_RX("beacon status %#x, retries:%d ibssmgr:%d " - "tsf:0x%.8x%.8x rate:%d\n", - le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, - beacon->beacon_notify_hdr.failure_frame, - le32_to_cpu(beacon->ibss_mgr_status), - le32_to_cpu(beacon->high_tsf), - le32_to_cpu(beacon->low_tsf), rate); + "tsf:0x%.8x%.8x rate:%d\n", + le32_to_cpu(beacon->beacon_notify_hdr.u.status) & TX_STATUS_MSK, + beacon->beacon_notify_hdr.failure_frame, + le32_to_cpu(beacon->ibss_mgr_status), + le32_to_cpu(beacon->high_tsf), le32_to_cpu(beacon->low_tsf), rate); il->ibss_manager = le32_to_cpu(beacon->ibss_mgr_status); } /* Set up 4965-specific Rx frame reply handlers */ -static void il4965_handler_setup(struct il_priv *il) +static void +il4965_handler_setup(struct il_priv *il) { /* Legacy Rx frames */ il->handlers[N_RX] = il4965_hdl_rx; @@ -2152,7 +2151,8 @@ static struct il_hcmd_ops il4965_hcmd = { .set_rxon_chain = il4965_set_rxon_chain, }; -static void il4965_post_scan(struct il_priv *il) +static void +il4965_post_scan(struct il_priv *il) { struct il_rxon_context *ctx = &il->ctx; @@ -2164,7 +2164,8 @@ static void il4965_post_scan(struct il_priv *il) il_commit_rxon(il, ctx); } -static void il4965_post_associate(struct il_priv *il) +static void +il4965_post_associate(struct il_priv *il) { struct il_rxon_context *ctx = &il->ctx; struct ieee80211_vif *vif = ctx->vif; @@ -2186,8 +2187,7 @@ static void il4965_post_associate(struct il_priv *il) ret = il_send_rxon_timing(il, ctx); if (ret) - IL_WARN("RXON timing - " - "Attempting to continue.\n"); + IL_WARN("RXON timing - " "Attempting to continue.\n"); ctx->staging.filter_flags |= RXON_FILTER_ASSOC_MSK; @@ -2198,8 +2198,8 @@ static void il4965_post_associate(struct il_priv *il) ctx->staging.assoc_id = cpu_to_le16(vif->bss_conf.aid); - D_ASSOC("assoc id %d beacon interval %d\n", - vif->bss_conf.aid, vif->bss_conf.beacon_int); + D_ASSOC("assoc id %d beacon interval %d\n", vif->bss_conf.aid, + vif->bss_conf.beacon_int); if (vif->bss_conf.use_short_preamble) ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; @@ -2215,8 +2215,8 @@ static void il4965_post_associate(struct il_priv *il) il_commit_rxon(il, ctx); - D_ASSOC("Associated as %d to: %pM\n", - vif->bss_conf.aid, ctx->active.bssid_addr); + D_ASSOC("Associated as %d to: %pM\n", vif->bss_conf.aid, + ctx->active.bssid_addr); switch (vif->type) { case NL80211_IFTYPE_STATION: @@ -2225,8 +2225,8 @@ static void il4965_post_associate(struct il_priv *il) il4965_send_beacon_cmd(il); break; default: - IL_ERR("%s Should not be called in %d mode\n", - __func__, vif->type); + IL_ERR("%s Should not be called in %d mode\n", __func__, + vif->type); break; } @@ -2241,7 +2241,8 @@ static void il4965_post_associate(struct il_priv *il) il->start_calib = 1; } -static void il4965_config_ap(struct il_priv *il) +static void +il4965_config_ap(struct il_priv *il) { struct il_rxon_context *ctx = &il->ctx; struct ieee80211_vif *vif = ctx->vif; @@ -2263,11 +2264,10 @@ static void il4965_config_ap(struct il_priv *il) ret = il_send_rxon_timing(il, ctx); if (ret) IL_WARN("RXON timing failed - " - "Attempting to continue.\n"); + "Attempting to continue.\n"); /* AP has all antennas */ - il->chain_noise_data.active_chains = - il->hw_params.valid_rx_ant; + il->chain_noise_data.active_chains = il->hw_params.valid_rx_ant; il_set_rxon_ht(il, &il->current_ht_config); if (il->cfg->ops->hcmd->set_rxon_chain) il->cfg->ops->hcmd->set_rxon_chain(il, ctx); @@ -2275,19 +2275,15 @@ static void il4965_config_ap(struct il_priv *il) ctx->staging.assoc_id = 0; if (vif->bss_conf.use_short_preamble) - ctx->staging.flags |= - RXON_FLG_SHORT_PREAMBLE_MSK; + ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; else - ctx->staging.flags &= - ~RXON_FLG_SHORT_PREAMBLE_MSK; + ctx->staging.flags &= ~RXON_FLG_SHORT_PREAMBLE_MSK; if (ctx->staging.flags & RXON_FLG_BAND_24G_MSK) { if (vif->bss_conf.use_short_slot) - ctx->staging.flags |= - RXON_FLG_SHORT_SLOT_MSK; + ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; else - ctx->staging.flags &= - ~RXON_FLG_SHORT_SLOT_MSK; + ctx->staging.flags &= ~RXON_FLG_SHORT_SLOT_MSK; } /* need to send beacon cmd before committing assoc RXON! */ il4965_send_beacon_cmd(il); @@ -2319,32 +2315,31 @@ static struct il_lib_ops il4965_lib = { .dump_fh = il4965_dump_fh, .set_channel_switch = il4965_hw_channel_switch, .apm_ops = { - .init = il_apm_init, - .config = il4965_nic_config, - }, + .init = il_apm_init, + .config = il4965_nic_config, + }, .eeprom_ops = { - .regulatory_bands = { - EEPROM_REGULATORY_BAND_1_CHANNELS, - EEPROM_REGULATORY_BAND_2_CHANNELS, - EEPROM_REGULATORY_BAND_3_CHANNELS, - EEPROM_REGULATORY_BAND_4_CHANNELS, - EEPROM_REGULATORY_BAND_5_CHANNELS, - EEPROM_4965_REGULATORY_BAND_24_HT40_CHANNELS, - EEPROM_4965_REGULATORY_BAND_52_HT40_CHANNELS - }, - .acquire_semaphore = il4965_eeprom_acquire_semaphore, - .release_semaphore = il4965_eeprom_release_semaphore, - }, - .send_tx_power = il4965_send_tx_power, + .regulatory_bands = { + EEPROM_REGULATORY_BAND_1_CHANNELS, + EEPROM_REGULATORY_BAND_2_CHANNELS, + EEPROM_REGULATORY_BAND_3_CHANNELS, + EEPROM_REGULATORY_BAND_4_CHANNELS, + EEPROM_REGULATORY_BAND_5_CHANNELS, + EEPROM_4965_REGULATORY_BAND_24_HT40_CHANNELS, + EEPROM_4965_REGULATORY_BAND_52_HT40_CHANNELS}, + .acquire_semaphore = il4965_eeprom_acquire_semaphore, + .release_semaphore = il4965_eeprom_release_semaphore, + }, + .send_tx_power = il4965_send_tx_power, .update_chain_flags = il4965_update_chain_flags, .temp_ops = { - .temperature = il4965_temperature_calib, - }, + .temperature = il4965_temperature_calib, + }, .debugfs_ops = { - .rx_stats_read = il4965_ucode_rx_stats_read, - .tx_stats_read = il4965_ucode_tx_stats_read, - .general_stats_read = il4965_ucode_general_stats_read, - }, + .rx_stats_read = il4965_ucode_rx_stats_read, + .tx_stats_read = il4965_ucode_tx_stats_read, + .general_stats_read = il4965_ucode_general_stats_read, + }, }; static const struct il_legacy_ops il4965_legacy_ops = { @@ -2406,7 +2401,7 @@ struct il_cfg il4965_cfg = { .fw_name_pre = IL4965_FW_PRE, .ucode_api_max = IL4965_UCODE_API_MAX, .ucode_api_min = IL4965_UCODE_API_MIN, - .sku = IL_SKU_A|IL_SKU_G|IL_SKU_N, + .sku = IL_SKU_A | IL_SKU_G | IL_SKU_N, .valid_tx_ant = ANT_AB, .valid_rx_ant = ANT_ABC, .eeprom_ver = EEPROM_4965_EEPROM_VERSION, diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h index a4e256bb5061..78eae22c8f29 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -44,19 +44,17 @@ extern struct il_mod_params il4965_mod_params; extern struct ieee80211_ops il4965_hw_ops; /* tx queue */ -void il4965_free_tfds_in_queue(struct il_priv *il, - int sta_id, int tid, int freed); +void il4965_free_tfds_in_queue(struct il_priv *il, int sta_id, int tid, + int freed); /* RXON */ -void il4965_set_rxon_chain(struct il_priv *il, - struct il_rxon_context *ctx); +void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx); /* uCode */ int il4965_verify_ucode(struct il_priv *il); /* lib */ -void il4965_check_abort_status(struct il_priv *il, - u8 frame_count, u32 status); +void il4965_check_abort_status(struct il_priv *il, u8 frame_count, u32 status); void il4965_rx_queue_reset(struct il_priv *il, struct il_rx_queue *rxq); int il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq); @@ -70,30 +68,24 @@ void il4965_rx_replenish_now(struct il_priv *il); void il4965_rx_queue_free(struct il_priv *il, struct il_rx_queue *rxq); int il4965_rxq_stop(struct il_priv *il); int il4965_hwrate_to_mac80211_idx(u32 rate_n_flags, enum ieee80211_band band); -void il4965_hdl_rx(struct il_priv *il, - struct il_rx_buf *rxb); -void il4965_hdl_rx_phy(struct il_priv *il, - struct il_rx_buf *rxb); +void il4965_hdl_rx(struct il_priv *il, struct il_rx_buf *rxb); +void il4965_hdl_rx_phy(struct il_priv *il, struct il_rx_buf *rxb); void il4965_rx_handle(struct il_priv *il); /* tx */ void il4965_hw_txq_free_tfd(struct il_priv *il, struct il_tx_queue *txq); -int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, - struct il_tx_queue *txq, - dma_addr_t addr, u16 len, u8 reset, u8 pad); -int il4965_hw_tx_queue_init(struct il_priv *il, - struct il_tx_queue *txq); +int il4965_hw_txq_attach_buf_to_tfd(struct il_priv *il, struct il_tx_queue *txq, + dma_addr_t addr, u16 len, u8 reset, u8 pad); +int il4965_hw_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq); void il4965_hwrate_to_tx_control(struct il_priv *il, u32 rate_n_flags, - struct ieee80211_tx_info *info); + struct ieee80211_tx_info *info); int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb); int il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, - struct ieee80211_sta *sta, u16 tid, u16 *ssn); + struct ieee80211_sta *sta, u16 tid, u16 * ssn); int il4965_tx_agg_stop(struct il_priv *il, struct ieee80211_vif *vif, struct ieee80211_sta *sta, u16 tid); -int il4965_txq_check_empty(struct il_priv *il, - int sta_id, u8 tid, int txq_id); -void il4965_hdl_compressed_ba(struct il_priv *il, - struct il_rx_buf *rxb); +int il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id); +void il4965_hdl_compressed_ba(struct il_priv *il, struct il_rx_buf *rxb); int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int idx); void il4965_hw_txq_ctx_free(struct il_priv *il); int il4965_txq_ctx_alloc(struct il_priv *il); @@ -112,28 +104,23 @@ void il4965_set_wr_ptrs(struct il_priv *il, int txq_id, u32 idx); * * NOTE: Acquire il->lock before calling this function ! */ -void il4965_tx_queue_set_status(struct il_priv *il, - struct il_tx_queue *txq, - int tx_fifo_id, int scd_retry); +void il4965_tx_queue_set_status(struct il_priv *il, struct il_tx_queue *txq, + int tx_fifo_id, int scd_retry); u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant_idx, u8 valid); /* rx */ -void il4965_hdl_missed_beacon(struct il_priv *il, - struct il_rx_buf *rxb); -bool il4965_good_plcp_health(struct il_priv *il, - struct il_rx_pkt *pkt); -void il4965_hdl_stats(struct il_priv *il, - struct il_rx_buf *rxb); -void il4965_hdl_c_stats(struct il_priv *il, - struct il_rx_buf *rxb); +void il4965_hdl_missed_beacon(struct il_priv *il, struct il_rx_buf *rxb); +bool il4965_good_plcp_health(struct il_priv *il, struct il_rx_pkt *pkt); +void il4965_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb); +void il4965_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb); /* scan */ int il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif); /* station mgmt */ -int il4965_manage_ibss_station(struct il_priv *il, - struct ieee80211_vif *vif, bool add); +int il4965_manage_ibss_station(struct il_priv *il, struct ieee80211_vif *vif, + bool add); /* hcmd */ int il4965_send_beacon_cmd(struct il_priv *il); @@ -142,59 +129,57 @@ int il4965_send_beacon_cmd(struct il_priv *il); const char *il4965_get_tx_fail_reason(u32 status); #else static inline const char * -il4965_get_tx_fail_reason(u32 status) { return ""; } +il4965_get_tx_fail_reason(u32 status) +{ + return ""; +} #endif /* station management */ -int il4965_alloc_bcast_station(struct il_priv *il, - struct il_rxon_context *ctx); -int il4965_add_bssid_station(struct il_priv *il, - struct il_rxon_context *ctx, - const u8 *addr, u8 *sta_id_r); +int il4965_alloc_bcast_station(struct il_priv *il, struct il_rxon_context *ctx); +int il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, + const u8 * addr, u8 * sta_id_r); int il4965_remove_default_wep_key(struct il_priv *il, - struct il_rxon_context *ctx, + struct il_rxon_context *ctx, + struct ieee80211_key_conf *key); +int il4965_set_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *key); -int il4965_set_default_wep_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *key); int il4965_restore_default_wep_keys(struct il_priv *il, - struct il_rxon_context *ctx); -int il4965_set_dynamic_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *key, u8 sta_id); -int il4965_remove_dynamic_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *key, u8 sta_id); -void il4965_update_tkip_key(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_key_conf *keyconf, - struct ieee80211_sta *sta, u32 iv32, u16 *phase1key); -int il4965_sta_tx_modify_enable_tid(struct il_priv *il, - int sta_id, int tid); + struct il_rxon_context *ctx); +int il4965_set_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, + struct ieee80211_key_conf *key, u8 sta_id); +int il4965_remove_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, + struct ieee80211_key_conf *key, u8 sta_id); +void il4965_update_tkip_key(struct il_priv *il, struct il_rxon_context *ctx, + struct ieee80211_key_conf *keyconf, + struct ieee80211_sta *sta, u32 iv32, + u16 * phase1key); +int il4965_sta_tx_modify_enable_tid(struct il_priv *il, int sta_id, int tid); int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta, - int tid, u16 ssn); + int tid, u16 ssn); int il4965_sta_rx_agg_stop(struct il_priv *il, struct ieee80211_sta *sta, - int tid); -void il4965_sta_modify_sleep_tx_count(struct il_priv *il, - int sta_id, int cnt); + int tid); +void il4965_sta_modify_sleep_tx_count(struct il_priv *il, int sta_id, int cnt); int il4965_update_bcast_stations(struct il_priv *il); /* rate */ -static inline u8 il4965_hw_get_rate(__le32 rate_n_flags) +static inline u8 +il4965_hw_get_rate(__le32 rate_n_flags) { return le32_to_cpu(rate_n_flags) & 0xFF; } -static inline __le32 il4965_hw_set_rate_n_flags(u8 rate, u32 flags) +static inline __le32 +il4965_hw_set_rate_n_flags(u8 rate, u32 flags) { - return cpu_to_le32(flags|(u32)rate); + return cpu_to_le32(flags | (u32) rate); } /* eeprom */ -void il4965_eeprom_get_mac(const struct il_priv *il, u8 *mac); +void il4965_eeprom_get_mac(const struct il_priv *il, u8 * mac); int il4965_eeprom_acquire_semaphore(struct il_priv *il); void il4965_eeprom_release_semaphore(struct il_priv *il); -int il4965_eeprom_check_version(struct il_priv *il); +int il4965_eeprom_check_version(struct il_priv *il); /* mac80211 handlers (for 4965) */ void il4965_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb); @@ -202,30 +187,26 @@ int il4965_mac_start(struct ieee80211_hw *hw); void il4965_mac_stop(struct ieee80211_hw *hw); void il4965_configure_filter(struct ieee80211_hw *hw, unsigned int changed_flags, - unsigned int *total_flags, - u64 multicast); + unsigned int *total_flags, u64 multicast); int il4965_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, struct ieee80211_vif *vif, struct ieee80211_sta *sta, struct ieee80211_key_conf *key); void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_key_conf *keyconf, - struct ieee80211_sta *sta, - u32 iv32, u16 *phase1key); -int il4965_mac_ampdu_action(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, + struct ieee80211_sta *sta, u32 iv32, + u16 * phase1key); +int il4965_mac_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, enum ieee80211_ampdu_mlme_action action, - struct ieee80211_sta *sta, u16 tid, u16 *ssn, + struct ieee80211_sta *sta, u16 tid, u16 * ssn, u8 buf_size); -int il4965_mac_sta_add(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, +int il4965_mac_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta); void il4965_mac_channel_switch(struct ieee80211_hw *hw, struct ieee80211_channel_switch *ch_switch); void il4965_led_enable(struct il_priv *il); - /* EEPROM */ #define IL4965_EEPROM_IMG_SIZE 1024 @@ -255,7 +236,8 @@ void il4965_led_enable(struct il_priv *il); /* Size of uCode instruction memory in bootstrap state machine */ #define IL49_MAX_BSM_SIZE BSM_SRAM_SIZE -static inline int il4965_hw_valid_rtc_data_addr(u32 addr) +static inline int +il4965_hw_valid_rtc_data_addr(u32 addr) { return (addr >= IL49_RTC_DATA_LOWER_BOUND && addr < IL49_RTC_DATA_UPPER_BOUND); @@ -588,8 +570,8 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * present during factory calibration). A 5 Ghz EEPROM idx of "40" * corresponds to the 49th entry in the table used by the driver. */ -#define MIN_TX_GAIN_IDX (0) /* highest gain, lowest idx, 2.4 */ -#define MIN_TX_GAIN_IDX_52GHZ_EXT (-9) /* highest gain, lowest idx, 5 */ +#define MIN_TX_GAIN_IDX (0) /* highest gain, lowest idx, 2.4 */ +#define MIN_TX_GAIN_IDX_52GHZ_EXT (-9) /* highest gain, lowest idx, 5 */ /** * 2.4 GHz gain table @@ -810,7 +792,6 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr) * 98 78 0x00 */ - /** * Sanity checks and default values for EEPROM regulatory levels. * If EEPROM values fall outside MIN/MAX range, use default values. @@ -894,7 +875,6 @@ enum { /********************* END TXPOWER *****************************************/ - /** * Tx/Rx Queues * @@ -920,7 +900,6 @@ enum { #define IL49_NUM_QUEUES 16 #define IL49_NUM_AMPDU_QUEUES 8 - /** * struct il4965_schedq_bc_tbl * @@ -944,7 +923,6 @@ struct il4965_scd_bc_tbl { u8 pad[1024 - (TFD_QUEUE_BC_SIZE) * sizeof(__le16)]; } __packed; - #define IL4965_RTC_INST_LOWER_BOUND (0x000000) /* RSSI to dBm */ @@ -971,28 +949,31 @@ void il4965_calib_free_results(struct il_priv *il); /* Debug */ #ifdef CONFIG_IWLEGACY_DEBUGFS -ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); -ssize_t il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); +ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos); +ssize_t il4965_ucode_tx_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos); ssize_t il4965_ucode_general_stats_read(struct file *file, - char __user *user_buf, size_t count, loff_t *ppos); + char __user * user_buf, size_t count, + loff_t * ppos); #else static ssize_t -il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) +il4965_ucode_rx_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { return 0; } + static ssize_t -il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) +il4965_ucode_tx_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { return 0; } + static ssize_t -il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) +il4965_ucode_general_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { return 0; } @@ -1028,7 +1009,6 @@ il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, */ #define FH49_KW_MEM_ADDR_REG (FH49_MEM_LOWER_BOUND + 0x97C) - /** * TFD Circular Buffers Base (CBBC) addresses * @@ -1047,7 +1027,6 @@ il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, /* Find TFD CB base pointer for given queue (range 0-15). */ #define FH49_MEM_CBBC_QUEUE(x) (FH49_MEM_CBBC_LOWER_BOUND + (x) * 0x4) - /** * Rx SRAM Control and Status Registers (RSCSR) * @@ -1144,7 +1123,6 @@ il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, #define FH49_RSCSR_CHNL0_RBDCB_WPTR_REG (FH49_MEM_RSCSR_CHNL0 + 0x008) #define FH49_RSCSR_CHNL0_WPTR (FH49_RSCSR_CHNL0_RBDCB_WPTR_REG) - /** * Rx Config/Status Registers (RCSR) * Rx Config Reg for channel 0 (only channel used) @@ -1177,12 +1155,12 @@ il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, #define FH49_MEM_RCSR_CHNL0_CONFIG_REG (FH49_MEM_RCSR_CHNL0) -#define FH49_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MSK (0x00000FF0) /* bits 4-11 */ -#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MSK (0x00001000) /* bits 12 */ -#define FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK (0x00008000) /* bit 15 */ -#define FH49_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MSK (0x00030000) /* bits 16-17 */ -#define FH49_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MSK (0x00F00000) /* bits 20-23 */ -#define FH49_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MSK (0xC0000000) /* bits 30-31*/ +#define FH49_RCSR_CHNL0_RX_CONFIG_RB_TIMEOUT_MSK (0x00000FF0) /* bits 4-11 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_MSK (0x00001000) /* bits 12 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK (0x00008000) /* bit 15 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_RB_SIZE_MSK (0x00030000) /* bits 16-17 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_RBDBC_SIZE_MSK (0x00F00000) /* bits 20-23 */ +#define FH49_RCSR_CHNL0_RX_CONFIG_DMA_CHNL_EN_MSK (0xC0000000) /* bits 30-31 */ #define FH49_RCSR_RX_CONFIG_RBDCB_SIZE_POS (20) #define FH49_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS (4) diff --git a/drivers/net/wireless/iwlegacy/commands.h b/drivers/net/wireless/iwlegacy/commands.h index 9eb7a83bbf1b..25dd7d28d022 100644 --- a/drivers/net/wireless/iwlegacy/commands.h +++ b/drivers/net/wireless/iwlegacy/commands.h @@ -74,7 +74,6 @@ struct il_priv; #define IL_UCODE_API(ver) (((ver) & 0x0000FF00) >> 8) #define IL_UCODE_SERIAL(ver) ((ver) & 0x000000FF) - /* Tx rates */ #define IL_CCK_RATES 4 #define IL_OFDM_RATES 8 @@ -98,11 +97,11 @@ enum { C_WEPKEY = 0x20, /* RX, TX, LEDs */ - N_3945_RX = 0x1b, /* 3945 only */ + N_3945_RX = 0x1b, /* 3945 only */ C_TX = 0x1c, C_RATE_SCALE = 0x47, /* 3945 only */ C_LEDS = 0x48, - C_TX_LINK_QUALITY_CMD = 0x4e, /* for 4965 */ + C_TX_LINK_QUALITY_CMD = 0x4e, /* for 4965 */ /* 802.11h related */ C_CHANNEL_SWITCH = 0x72, @@ -124,7 +123,7 @@ enum { /* IBSS/AP commands */ N_BEACON = 0x90, - C_TX_BEACON= 0x91, + C_TX_BEACON = 0x91, /* Miscellaneous commands */ C_TX_PWR_TBL = 0x97, @@ -177,8 +176,8 @@ enum { * driver, and each response/notification received from uCode. */ struct il_cmd_header { - u8 cmd; /* Command ID: C_RXON, etc. */ - u8 flags; /* 0:5 reserved, 6 abort, 7 internal */ + u8 cmd; /* Command ID: C_RXON, etc. */ + u8 flags; /* 0:5 reserved, 6 abort, 7 internal */ /* * The driver sets up the sequence number to values of its choosing. * uCode does not use this value, but passes it back to the driver @@ -194,20 +193,19 @@ struct il_cmd_header { * * The Linux driver uses the following format: * - * 0:7 tfd idx - position within TX queue - * 8:12 TX queue id - * 13 reserved - * 14 huge - driver sets this to indicate command is in the - * 'huge' storage at the end of the command buffers - * 15 unsolicited RX or uCode-originated notification - */ + * 0:7 tfd idx - position within TX queue + * 8:12 TX queue id + * 13 reserved + * 14 huge - driver sets this to indicate command is in the + * 'huge' storage at the end of the command buffers + * 15 unsolicited RX or uCode-originated notification + */ __le16 sequence; /* command or response/notification data follows immediately */ u8 data[0]; } __packed; - /** * struct il3945_tx_power * @@ -430,7 +428,6 @@ struct il_init_alive_resp { * 2 Tx chains */ } __packed; - /** * N_ALIVE = 0x1 (response only, not a command) * @@ -514,7 +511,7 @@ struct il_alive_resp { __le16 reserved1; u8 sw_rev[8]; u8 ver_type; - u8 ver_subtype; /* not "9" for runtime alive */ + u8 ver_subtype; /* not "9" for runtime alive */ __le16 reserved2; __le32 log_event_table_ptr; /* SRAM address for event log */ __le32 error_event_table_ptr; /* SRAM address for error log */ @@ -551,7 +548,6 @@ enum { RXON_DEV_TYPE_SNIFFER = 6, }; - #define RXON_RX_CHAIN_DRIVER_FORCE_MSK cpu_to_le16(0x1 << 0) #define RXON_RX_CHAIN_DRIVER_FORCE_POS (0) #define RXON_RX_CHAIN_VALID_MSK cpu_to_le16(0x7 << 1) @@ -590,7 +586,6 @@ enum { * (according to ON_AIR deassertion) */ #define RXON_FLG_TSF2HOST_MSK cpu_to_le32(1 << 15) - /* HT flags */ #define RXON_FLG_CTRL_CHANNEL_LOC_POS (22) #define RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK cpu_to_le32(0x1 << 22) @@ -718,7 +713,6 @@ struct il_rxon_cmd { u8 reserved5; } __packed; - /* * C_RXON_ASSOC = 0x11 (command, has simple generic response) */ @@ -742,8 +736,8 @@ struct il4965_rxon_assoc_cmd { } __packed; #define IL_CONN_MAX_LISTEN_INTERVAL 10 -#define IL_MAX_UCODE_BEACON_INTERVAL 4 /* 4096 */ -#define IL39_MAX_UCODE_BEACON_INTERVAL 1 /* 1024 */ +#define IL_MAX_UCODE_BEACON_INTERVAL 4 /* 4096 */ +#define IL39_MAX_UCODE_BEACON_INTERVAL 1 /* 1024 */ /* * C_RXON_TIMING = 0x14 (command, has simple generic response) @@ -856,7 +850,7 @@ struct il_qosparam_cmd { #define IL4965_BROADCAST_ID 31 #define IL4965_STATION_COUNT 32 -#define IL_STATION_COUNT 32 /* MAX(3945,4965)*/ +#define IL_STATION_COUNT 32 /* MAX(3945,4965) */ #define IL_INVALID_STATION 255 #define STA_FLG_TX_RATE_MSK cpu_to_le32(1 << 2) @@ -964,7 +958,7 @@ struct il3945_addsta_cmd { u8 reserved[3]; struct sta_id_modify sta; struct il4965_keyinfo key; - __le32 station_flags; /* STA_FLG_* */ + __le32 station_flags; /* STA_FLG_* */ __le32 station_flags_msk; /* STA_FLG_* */ /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID) @@ -992,7 +986,7 @@ struct il4965_addsta_cmd { u8 reserved[3]; struct sta_id_modify sta; struct il4965_keyinfo key; - __le32 station_flags; /* STA_FLG_* */ + __le32 station_flags; /* STA_FLG_* */ __le32 station_flags_msk; /* STA_FLG_* */ /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID) @@ -1000,7 +994,7 @@ struct il4965_addsta_cmd { * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */ __le16 tid_disable_tx; - __le16 reserved1; + __le16 reserved1; /* TID for which to add block-ack support. * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ @@ -1030,7 +1024,7 @@ struct il_addsta_cmd { u8 reserved[3]; struct sta_id_modify sta; struct il4965_keyinfo key; - __le32 station_flags; /* STA_FLG_* */ + __le32 station_flags; /* STA_FLG_* */ __le32 station_flags_msk; /* STA_FLG_* */ /* bit field to disable (1) or enable (0) Tx for Traffic ID (TID) @@ -1038,7 +1032,7 @@ struct il_addsta_cmd { * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */ __le16 tid_disable_tx; - __le16 rate_n_flags; /* 3945 only */ + __le16 rate_n_flags; /* 3945 only */ /* TID for which to add block-ack support. * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ @@ -1062,7 +1056,6 @@ struct il_addsta_cmd { __le16 reserved2; } __packed; - #define ADD_STA_SUCCESS_MSK 0x1 #define ADD_STA_NO_ROOM_IN_TBL 0x2 #define ADD_STA_NO_BLOCK_ACK_RESOURCE 0x4 @@ -1071,7 +1064,7 @@ struct il_addsta_cmd { * C_ADD_STA = 0x18 (response) */ struct il_add_sta_resp { - u8 status; /* ADD_STA_* */ + u8 status; /* ADD_STA_* */ } __packed; #define REM_STA_SUCCESS_MSK 0x1 @@ -1086,9 +1079,9 @@ struct il_rem_sta_resp { * C_REM_STA = 0x19 (command) */ struct il_rem_sta_cmd { - u8 num_sta; /* number of removed stations */ + u8 num_sta; /* number of removed stations */ u8 reserved[3]; - u8 addr[ETH_ALEN]; /* MAC addr of the first station */ + u8 addr[ETH_ALEN]; /* MAC addr of the first station */ u8 reserved2[2]; } __packed; @@ -1165,7 +1158,6 @@ struct il_wep_cmd { #define RX_MPDU_RES_STATUS_TTAK_OK (1 << 7) #define RX_MPDU_RES_STATUS_DEC_DONE_MSK (0x800) - struct il3945_rx_frame_stats { u8 phy_count; u8 id; @@ -1221,21 +1213,20 @@ struct il4965_rx_non_cfg_phy { u8 pad[0]; } __packed; - /* * N_RX = 0xc3 (response only, not a command) * Used only for legacy (non 11n) frames. */ struct il_rx_phy_res { - u8 non_cfg_phy_cnt; /* non configurable DSP phy data byte count */ + u8 non_cfg_phy_cnt; /* non configurable DSP phy data byte count */ u8 cfg_phy_cnt; /* configurable DSP phy data byte count */ u8 stat_id; /* configurable DSP phy data set ID */ u8 reserved1; __le64 timestamp; /* TSF at on air rise */ - __le32 beacon_time_stamp; /* beacon at on-air rise */ + __le32 beacon_time_stamp; /* beacon at on-air rise */ __le16 phy_flags; /* general phy flags: band, modulation, ... */ __le16 channel; /* channel number */ - u8 non_cfg_phy_buf[32]; /* for various implementations of non_cfg_phy */ + u8 non_cfg_phy_buf[32]; /* for various implementations of non_cfg_phy */ __le32 rate_n_flags; /* RATE_MCS_* */ __le16 byte_count; /* frame's byte-count */ __le16 frame_time; /* frame's time on the air */ @@ -1246,7 +1237,6 @@ struct il_rx_mpdu_res_start { __le16 reserved; } __packed; - /****************************************************************************** * (5) * Tx Commands & Responses: @@ -1346,7 +1336,6 @@ struct il_rx_mpdu_res_start { /* HCCA-AP - disable duration overwriting. */ #define TX_CMD_FLG_DUR_MSK cpu_to_le32(1 << 25) - /* * TX command security control */ @@ -1442,7 +1431,6 @@ struct il3945_tx_resp { __le32 status; /* TX status */ } __packed; - /* * 4965 uCode updates these Tx attempt count values in host DRAM. * Used for managing Tx retries when expecting block-acks. @@ -1625,12 +1613,12 @@ enum { }; enum { - TX_STATUS_MSK = 0x000000ff, /* bits 0:7 */ + TX_STATUS_MSK = 0x000000ff, /* bits 0:7 */ TX_STATUS_DELAY_MSK = 0x00000040, TX_STATUS_ABORT_MSK = 0x00000080, TX_PACKET_MODE_MSK = 0x0000ff00, /* bits 8:15 */ TX_FIFO_NUMBER_MSK = 0x00070000, /* bits 16:18 */ - TX_RESERVED = 0x00780000, /* bits 19:22 */ + TX_RESERVED = 0x00780000, /* bits 19:22 */ TX_POWER_PA_DETECT_MSK = 0x7f800000, /* bits 23:30 */ TX_ABORT_REQUIRED_MSK = 0x80000000, /* bits 31:31 */ }; @@ -1727,7 +1715,7 @@ struct il4965_tx_resp { */ union { __le32 status; - struct agg_tx_status agg_status[0]; /* for each agg frame */ + struct agg_tx_status agg_status[0]; /* for each agg frame */ } u; } __packed; @@ -1770,7 +1758,6 @@ struct il4965_txpowertable_cmd { struct il4965_tx_power_db tx_power; } __packed; - /** * struct il3945_rate_scaling_cmd - Rate Scaling Command & Response * @@ -1798,7 +1785,6 @@ struct il3945_rate_scaling_cmd { struct il3945_rate_scaling_info table[IL_MAX_RATES]; } __packed; - /*RS_NEW_API: only TLC_RTS remains and moved to bit 0 */ #define LINK_QUAL_FLAGS_SET_STA_TLC_RTS_MSK (1 << 0) @@ -1813,7 +1799,6 @@ struct il3945_rate_scaling_cmd { #define LINK_QUAL_ANT_B_MSK (1 << 1) #define LINK_QUAL_ANT_MSK (LINK_QUAL_ANT_A_MSK|LINK_QUAL_ANT_B_MSK) - /** * struct il_link_qual_general_params * @@ -1829,7 +1814,7 @@ struct il_link_qual_general_params { u8 single_stream_ant_msk; /* LINK_QUAL_ANT_* */ /* Best antennas to use for MIMO (unused for 4965, assumes both). */ - u8 dual_stream_ant_msk; /* LINK_QUAL_ANT_* */ + u8 dual_stream_ant_msk; /* LINK_QUAL_ANT_* */ /* * If driver needs to use different initial rates for different @@ -1845,7 +1830,7 @@ struct il_link_qual_general_params { u8 start_rate_idx[LINK_QUAL_AC_NUM]; } __packed; -#define LINK_QUAL_AGG_TIME_LIMIT_DEF (4000) /* 4 milliseconds */ +#define LINK_QUAL_AGG_TIME_LIMIT_DEF (4000) /* 4 milliseconds */ #define LINK_QUAL_AGG_TIME_LIMIT_MAX (8000) #define LINK_QUAL_AGG_TIME_LIMIT_MIN (100) @@ -2129,7 +2114,6 @@ struct il_bt_cmd { __le32 kill_cts_mask; } __packed; - /****************************************************************************** * (6) * Spectrum Management (802.11h) Commands, Responses, Notifications: @@ -2230,7 +2214,7 @@ enum il_measure_type { struct il_spectrum_notification { u8 id; /* measurement id -- 0 or 1 */ u8 token; - u8 channel_idx; /* idx in measurement channel list */ + u8 channel_idx; /* idx in measurement channel list */ u8 state; /* 0 - start, 1 - stop */ __le32 start_time; /* lower 32-bits of TSF */ u8 band; /* 0 - 5.2GHz, 1 - 2.4GHz */ @@ -2306,8 +2290,8 @@ struct il3945_powertable_cmd { struct il_powertable_cmd { __le16 flags; - u8 keep_alive_seconds; /* 3945 reserved */ - u8 debug_flags; /* 3945 reserved */ + u8 keep_alive_seconds; /* 3945 reserved */ + u8 debug_flags; /* 3945 reserved */ __le32 rx_data_timeout; __le32 tx_data_timeout; __le32 sleep_interval[IL_POWER_VEC_SIZE]; @@ -2355,10 +2339,10 @@ struct il_card_state_notif { #define RXON_CARD_DISABLED 0x10 struct il_ct_kill_config { - __le32 reserved; - __le32 critical_temperature_M; - __le32 critical_temperature_R; -} __packed; + __le32 reserved; + __le32 critical_temperature_M; + __le32 critical_temperature_R; +} __packed; /****************************************************************************** * (8) @@ -2397,7 +2381,7 @@ struct il3945_scan_channel { * 5:7 reserved */ u8 type; - u8 channel; /* band is selected by il3945_scan_cmd "flags" field */ + u8 channel; /* band is selected by il3945_scan_cmd "flags" field */ struct il3945_tx_power tpc; __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */ __le16 passive_dwell; /* in 1024-uSec TU (time units), typ 20-500 */ @@ -2415,7 +2399,7 @@ struct il_scan_channel { * 21:31 reserved */ __le32 type; - __le16 channel; /* band is selected by il_scan_cmd "flags" field */ + __le16 channel; /* band is selected by il_scan_cmd "flags" field */ u8 tx_gain; /* gain for analog radio */ u8 dsp_atten; /* gain for DSP */ __le16 active_dwell; /* in 1024-uSec TU (time units), typ 5-50 */ @@ -2631,7 +2615,7 @@ struct il_scanresults_notification { u8 channel; u8 band; u8 probe_status; - u8 num_probe_not_sent; /* not enough time to send */ + u8 num_probe_not_sent; /* not enough time to send */ __le32 tsf_low; __le32 tsf_high; __le32 stats[NUMBER_OF_STATS]; @@ -2648,7 +2632,6 @@ struct il_scancomplete_notification { __le32 tsf_high; } __packed; - /****************************************************************************** * (9) * IBSS/AP Commands and Notifications: @@ -2849,15 +2832,15 @@ struct stats_rx_non_phy { __le32 num_missed_bcon; /* number of missed beacons */ __le32 adc_rx_saturation_time; /* count in 0.8us units the time the * ADC was in saturation */ - __le32 ina_detection_search_time;/* total time (in 0.8us) searched - * for INA */ + __le32 ina_detection_search_time; /* total time (in 0.8us) searched + * for INA */ __le32 beacon_silence_rssi_a; /* RSSI silence after beacon frame */ __le32 beacon_silence_rssi_b; /* RSSI silence after beacon frame */ __le32 beacon_silence_rssi_c; /* RSSI silence after beacon frame */ __le32 interference_data_flag; /* flag for interference data * availability. 1 when data is * available. */ - __le32 channel_load; /* counts RX Enable time in uSec */ + __le32 channel_load; /* counts RX Enable time in uSec */ __le32 dsp_false_alarms; /* DSP false alarm (both OFDM * and CCK) counter */ __le32 beacon_rssi_a; @@ -2922,7 +2905,6 @@ struct stats_tx { __le32 reserved1; } __packed; - struct stats_div { __le32 tx_on_a; __le32 tx_on_b; @@ -2933,7 +2915,7 @@ struct stats_div { } __packed; struct stats_general_common { - __le32 temperature; /* radio temperature */ + __le32 temperature; /* radio temperature */ struct stats_dbg dbg; __le32 sleep_time; __le32 slots_out; @@ -2975,7 +2957,7 @@ struct stats_general { * does not affect the response to the C_STATS 0x9c itself. */ #define IL_STATS_CONF_CLEAR_STATS cpu_to_le32(0x1) /* see above */ -#define IL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2)/* see above */ +#define IL_STATS_CONF_DISABLE_NOTIF cpu_to_le32(0x2) /* see above */ struct il_stats_cmd { __le32 configuration_flags; /* IL_STATS_CONF_* */ } __packed; @@ -3043,7 +3025,6 @@ struct il_missed_beacon_notif { __le32 num_recvd_beacons; } __packed; - /****************************************************************************** * (11) * Rx Calibration Commands: @@ -3241,11 +3222,10 @@ struct il_missed_beacon_notif { * Always use "1" in "control" to update uCode's working table and DSP. */ struct il_sensitivity_cmd { - __le16 control; /* always use "1" */ + __le16 control; /* always use "1" */ __le16 table[HD_TBL_SIZE]; /* use HD_* as idx */ } __packed; - /** * C_PHY_CALIBRATION = 0xb0 (command, has simple generic response) * @@ -3305,8 +3285,8 @@ struct il_sensitivity_cmd { /* The default calibrate table size if not specified by firmware */ #define IL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE 18 enum { - IL_PHY_CALIBRATE_DIFF_GAIN_CMD = 7, - IL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE = 19, + IL_PHY_CALIBRATE_DIFF_GAIN_CMD = 7, + IL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE = 19, }; #define IL_MAX_PHY_CALIBRATE_TBL_SIZE (253) @@ -3350,7 +3330,6 @@ struct il_led_cmd { u8 reserved; } __packed; - /****************************************************************************** * (13) * Union of all expected notifications/responses: @@ -3394,4 +3373,4 @@ struct il_rx_pkt { } u; } __packed; -#endif /* __il_commands_h__ */ +#endif /* __il_commands_h__ */ diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 627ac9b32012..2e1bbb2e8464 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -42,7 +42,8 @@ #include "common.h" -const char *il_get_cmd_string(u8 cmd) +const char * +il_get_cmd_string(u8 cmd) { switch (cmd) { IL_CMD(N_ALIVE); @@ -91,30 +92,30 @@ const char *il_get_cmd_string(u8 cmd) } } + EXPORT_SYMBOL(il_get_cmd_string); #define HOST_COMPLETE_TIMEOUT (HZ / 2) -static void il_generic_cmd_callback(struct il_priv *il, - struct il_device_cmd *cmd, - struct il_rx_pkt *pkt) +static void +il_generic_cmd_callback(struct il_priv *il, struct il_device_cmd *cmd, + struct il_rx_pkt *pkt) { if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { IL_ERR("Bad return from %s (0x%08X)\n", - il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); + il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); return; } - #ifdef CONFIG_IWLEGACY_DEBUG switch (cmd->hdr.cmd) { case C_TX_LINK_QUALITY_CMD: case C_SENSITIVITY: D_HC_DUMP("back from %s (0x%08X)\n", - il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); + il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); break; default: - D_HC("back from %s (0x%08X)\n", - il_get_cmd_string(cmd->hdr.cmd), pkt->hdr.flags); + D_HC("back from %s (0x%08X)\n", il_get_cmd_string(cmd->hdr.cmd), + pkt->hdr.flags); } #endif } @@ -139,13 +140,14 @@ il_send_cmd_async(struct il_priv *il, struct il_host_cmd *cmd) ret = il_enqueue_hcmd(il, cmd); if (ret < 0) { IL_ERR("Error sending %s: enqueue_hcmd failed: %d\n", - il_get_cmd_string(cmd->id), ret); + il_get_cmd_string(cmd->id), ret); return ret; } return 0; } -int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) +int +il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) { int cmd_idx; int ret; @@ -154,38 +156,36 @@ int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) BUG_ON(cmd->flags & CMD_ASYNC); - /* A synchronous command can not have a callback set. */ + /* A synchronous command can not have a callback set. */ BUG_ON(cmd->callback); D_INFO("Attempting to send sync command %s\n", - il_get_cmd_string(cmd->id)); + il_get_cmd_string(cmd->id)); set_bit(S_HCMD_ACTIVE, &il->status); D_INFO("Setting HCMD_ACTIVE for command %s\n", - il_get_cmd_string(cmd->id)); + il_get_cmd_string(cmd->id)); cmd_idx = il_enqueue_hcmd(il, cmd); if (cmd_idx < 0) { ret = cmd_idx; IL_ERR("Error sending %s: enqueue_hcmd failed: %d\n", - il_get_cmd_string(cmd->id), ret); + il_get_cmd_string(cmd->id), ret); goto out; } ret = wait_event_timeout(il->wait_command_queue, - !test_bit(S_HCMD_ACTIVE, &il->status), - HOST_COMPLETE_TIMEOUT); + !test_bit(S_HCMD_ACTIVE, &il->status), + HOST_COMPLETE_TIMEOUT); if (!ret) { if (test_bit(S_HCMD_ACTIVE, &il->status)) { - IL_ERR( - "Error sending %s: time out after %dms.\n", - il_get_cmd_string(cmd->id), - jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); + IL_ERR("Error sending %s: time out after %dms.\n", + il_get_cmd_string(cmd->id), + jiffies_to_msecs(HOST_COMPLETE_TIMEOUT)); clear_bit(S_HCMD_ACTIVE, &il->status); - D_INFO( - "Clearing HCMD_ACTIVE for command %s\n", - il_get_cmd_string(cmd->id)); + D_INFO("Clearing HCMD_ACTIVE for command %s\n", + il_get_cmd_string(cmd->id)); ret = -ETIMEDOUT; goto cancel; } @@ -193,19 +193,19 @@ int il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd) if (test_bit(S_RF_KILL_HW, &il->status)) { IL_ERR("Command %s aborted: RF KILL Switch\n", - il_get_cmd_string(cmd->id)); + il_get_cmd_string(cmd->id)); ret = -ECANCELED; goto fail; } if (test_bit(S_FW_ERROR, &il->status)) { IL_ERR("Command %s failed: FW Error\n", - il_get_cmd_string(cmd->id)); + il_get_cmd_string(cmd->id)); ret = -EIO; goto fail; } if ((cmd->flags & CMD_WANT_SKB) && !cmd->reply_page) { IL_ERR("Error: Response NULL in '%s'\n", - il_get_cmd_string(cmd->id)); + il_get_cmd_string(cmd->id)); ret = -EIO; goto cancel; } @@ -221,8 +221,7 @@ cancel: * in later, it will possibly set an invalid * address (cmd->meta.source). */ - il->txq[il->cmd_queue].meta[cmd_idx].flags &= - ~CMD_WANT_SKB; + il->txq[il->cmd_queue].meta[cmd_idx].flags &= ~CMD_WANT_SKB; } fail: if (cmd->reply_page) { @@ -232,15 +231,18 @@ fail: out: return ret; } + EXPORT_SYMBOL(il_send_cmd_sync); -int il_send_cmd(struct il_priv *il, struct il_host_cmd *cmd) +int +il_send_cmd(struct il_priv *il, struct il_host_cmd *cmd) { if (cmd->flags & CMD_ASYNC) return il_send_cmd_async(il, cmd); return il_send_cmd_sync(il, cmd); } + EXPORT_SYMBOL(il_send_cmd); int @@ -254,13 +256,14 @@ il_send_cmd_pdu(struct il_priv *il, u8 id, u16 len, const void *data) return il_send_cmd_sync(il, &cmd); } + EXPORT_SYMBOL(il_send_cmd_pdu); -int il_send_cmd_pdu_async(struct il_priv *il, - u8 id, u16 len, const void *data, - void (*callback)(struct il_priv *il, - struct il_device_cmd *cmd, - struct il_rx_pkt *pkt)) +int +il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, const void *data, + void (*callback) (struct il_priv * il, + struct il_device_cmd * cmd, + struct il_rx_pkt * pkt)) { struct il_host_cmd cmd = { .id = id, @@ -273,13 +276,14 @@ int il_send_cmd_pdu_async(struct il_priv *il, return il_send_cmd_async(il, &cmd); } + EXPORT_SYMBOL(il_send_cmd_pdu_async); /* default: IL_LED_BLINK(0) using blinking idx table */ static int led_mode; module_param(led_mode, int, S_IRUGO); -MODULE_PARM_DESC(led_mode, "0=system default, " - "1=On(RF On)/Off(RF Off), 2=blinking"); +MODULE_PARM_DESC(led_mode, + "0=system default, " "1=On(RF On)/Off(RF Off), 2=blinking"); /* Throughput OFF time(ms) ON time (ms) * >300 25 25 @@ -295,16 +299,16 @@ MODULE_PARM_DESC(led_mode, "0=system default, " * <=0 SOLID ON */ static const struct ieee80211_tpt_blink il_blink[] = { - { .throughput = 0, .blink_time = 334 }, - { .throughput = 1 * 1024 - 1, .blink_time = 260 }, - { .throughput = 5 * 1024 - 1, .blink_time = 220 }, - { .throughput = 10 * 1024 - 1, .blink_time = 190 }, - { .throughput = 20 * 1024 - 1, .blink_time = 170 }, - { .throughput = 50 * 1024 - 1, .blink_time = 150 }, - { .throughput = 70 * 1024 - 1, .blink_time = 130 }, - { .throughput = 100 * 1024 - 1, .blink_time = 110 }, - { .throughput = 200 * 1024 - 1, .blink_time = 80 }, - { .throughput = 300 * 1024 - 1, .blink_time = 50 }, + {.throughput = 0,.blink_time = 334}, + {.throughput = 1 * 1024 - 1,.blink_time = 260}, + {.throughput = 5 * 1024 - 1,.blink_time = 220}, + {.throughput = 10 * 1024 - 1,.blink_time = 190}, + {.throughput = 20 * 1024 - 1,.blink_time = 170}, + {.throughput = 50 * 1024 - 1,.blink_time = 150}, + {.throughput = 70 * 1024 - 1,.blink_time = 130}, + {.throughput = 100 * 1024 - 1,.blink_time = 110}, + {.throughput = 200 * 1024 - 1,.blink_time = 80}, + {.throughput = 300 * 1024 - 1,.blink_time = 50}, }; /* @@ -318,22 +322,21 @@ static const struct ieee80211_tpt_blink il_blink[] = { * compensation = (100 - averageDeviation) * 64 / 100 * NewBlinkTime = (compensation * BlinkTime) / 64 */ -static inline u8 il_blink_compensation(struct il_priv *il, - u8 time, u16 compensation) +static inline u8 +il_blink_compensation(struct il_priv *il, u8 time, u16 compensation) { if (!compensation) { IL_ERR("undefined blink compensation: " - "use pre-defined blinking time\n"); + "use pre-defined blinking time\n"); return time; } - return (u8)((time * compensation) >> 6); + return (u8) ((time * compensation) >> 6); } /* Set led pattern command */ -static int il_led_cmd(struct il_priv *il, - unsigned long on, - unsigned long off) +static int +il_led_cmd(struct il_priv *il, unsigned long on, unsigned long off) { struct il_led_cmd led_cmd = { .id = IL_LED_LINK, @@ -353,11 +356,13 @@ static int il_led_cmd(struct il_priv *il, } D_LED("Led blink time compensation=%u\n", - il->cfg->base_params->led_compensation); - led_cmd.on = il_blink_compensation(il, on, - il->cfg->base_params->led_compensation); - led_cmd.off = il_blink_compensation(il, off, - il->cfg->base_params->led_compensation); + il->cfg->base_params->led_compensation); + led_cmd.on = + il_blink_compensation(il, on, + il->cfg->base_params->led_compensation); + led_cmd.off = + il_blink_compensation(il, off, + il->cfg->base_params->led_compensation); ret = il->cfg->ops->led->cmd(il, &led_cmd); if (!ret) { @@ -367,8 +372,9 @@ static int il_led_cmd(struct il_priv *il, return ret; } -static void il_led_brightness_set(struct led_classdev *led_cdev, - enum led_brightness brightness) +static void +il_led_brightness_set(struct led_classdev *led_cdev, + enum led_brightness brightness) { struct il_priv *il = container_of(led_cdev, struct il_priv, led); unsigned long on = 0; @@ -379,16 +385,17 @@ static void il_led_brightness_set(struct led_classdev *led_cdev, il_led_cmd(il, on, 0); } -static int il_led_blink_set(struct led_classdev *led_cdev, - unsigned long *delay_on, - unsigned long *delay_off) +static int +il_led_blink_set(struct led_classdev *led_cdev, unsigned long *delay_on, + unsigned long *delay_off) { struct il_priv *il = container_of(led_cdev, struct il_priv, led); return il_led_cmd(il, *delay_on, *delay_off); } -void il_leds_init(struct il_priv *il) +void +il_leds_init(struct il_priv *il) { int mode = led_mode; int ret; @@ -396,8 +403,8 @@ void il_leds_init(struct il_priv *il) if (mode == IL_LED_DEFAULT) mode = il->cfg->led_mode; - il->led.name = kasprintf(GFP_KERNEL, "%s-led", - wiphy_name(il->hw->wiphy)); + il->led.name = + kasprintf(GFP_KERNEL, "%s-led", wiphy_name(il->hw->wiphy)); il->led.brightness_set = il_led_brightness_set; il->led.blink_set = il_led_blink_set; il->led.max_brightness = 1; @@ -408,13 +415,13 @@ void il_leds_init(struct il_priv *il) break; case IL_LED_BLINK: il->led.default_trigger = - ieee80211_create_tpt_led_trigger(il->hw, - IEEE80211_TPT_LEDTRIG_FL_CONNECTED, - il_blink, ARRAY_SIZE(il_blink)); + ieee80211_create_tpt_led_trigger(il->hw, + IEEE80211_TPT_LEDTRIG_FL_CONNECTED, + il_blink, + ARRAY_SIZE(il_blink)); break; case IL_LED_RF_STATE: - il->led.default_trigger = - ieee80211_get_radio_led_name(il->hw); + il->led.default_trigger = ieee80211_get_radio_led_name(il->hw); break; } @@ -426,9 +433,11 @@ void il_leds_init(struct il_priv *il) il->led_registered = true; } + EXPORT_SYMBOL(il_leds_init); -void il_leds_exit(struct il_priv *il) +void +il_leds_exit(struct il_priv *il) { if (!il->led_registered) return; @@ -436,6 +445,7 @@ void il_leds_exit(struct il_priv *il) led_classdev_unregister(&il->led); kfree(il->led.name); } + EXPORT_SYMBOL(il_leds_exit); /************************** EEPROM BANDS **************************** @@ -491,11 +501,11 @@ static const u8 il_eeprom_band_5[] = { /* 5725-5825MHz */ 145, 149, 153, 157, 161, 165 }; -static const u8 il_eeprom_band_6[] = { /* 2.4 ht40 channel */ +static const u8 il_eeprom_band_6[] = { /* 2.4 ht40 channel */ 1, 2, 3, 4, 5, 6, 7 }; -static const u8 il_eeprom_band_7[] = { /* 5.2 ht40 channel */ +static const u8 il_eeprom_band_7[] = { /* 5.2 ht40 channel */ 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157 }; @@ -505,7 +515,8 @@ static const u8 il_eeprom_band_7[] = { /* 5.2 ht40 channel */ * ******************************************************************************/ -static int il_eeprom_verify_signature(struct il_priv *il) +static int +il_eeprom_verify_signature(struct il_priv *il) { u32 gp = _il_rd(il, CSR_EEPROM_GP) & CSR_EEPROM_GP_VALID_MSK; int ret = 0; @@ -516,28 +527,30 @@ static int il_eeprom_verify_signature(struct il_priv *il) case CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K: break; default: - IL_ERR("bad EEPROM signature," - "EEPROM_GP=0x%08x\n", gp); + IL_ERR("bad EEPROM signature," "EEPROM_GP=0x%08x\n", gp); ret = -ENOENT; break; } return ret; } -const u8 -*il_eeprom_query_addr(const struct il_priv *il, size_t offset) +const u8 * +il_eeprom_query_addr(const struct il_priv *il, size_t offset) { BUG_ON(offset >= il->cfg->base_params->eeprom_size); return &il->eeprom[offset]; } + EXPORT_SYMBOL(il_eeprom_query_addr); -u16 il_eeprom_query16(const struct il_priv *il, size_t offset) +u16 +il_eeprom_query16(const struct il_priv * il, size_t offset) { if (!il->eeprom) return 0; - return (u16)il->eeprom[offset] | ((u16)il->eeprom[offset + 1] << 8); + return (u16) il->eeprom[offset] | ((u16) il->eeprom[offset + 1] << 8); } + EXPORT_SYMBOL(il_eeprom_query16); /** @@ -547,7 +560,8 @@ EXPORT_SYMBOL(il_eeprom_query16); * * NOTE: This routine uses the non-debug IO access functions. */ -int il_eeprom_init(struct il_priv *il) +int +il_eeprom_init(struct il_priv *il) { __le16 *e; u32 gp = _il_rd(il, CSR_EEPROM_GP); @@ -563,7 +577,7 @@ int il_eeprom_init(struct il_priv *il) ret = -ENOMEM; goto alloc_err; } - e = (__le16 *)il->eeprom; + e = (__le16 *) il->eeprom; il->cfg->ops->lib->apm_ops.init(il); @@ -587,24 +601,23 @@ int il_eeprom_init(struct il_priv *il) u32 r; _il_wr(il, CSR_EEPROM_REG, - CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); + CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); - ret = _il_poll_bit(il, CSR_EEPROM_REG, - CSR_EEPROM_REG_READ_VALID_MSK, - CSR_EEPROM_REG_READ_VALID_MSK, - IL_EEPROM_ACCESS_TIMEOUT); + ret = + _il_poll_bit(il, CSR_EEPROM_REG, + CSR_EEPROM_REG_READ_VALID_MSK, + CSR_EEPROM_REG_READ_VALID_MSK, + IL_EEPROM_ACCESS_TIMEOUT); if (ret < 0) { - IL_ERR("Time out reading EEPROM[%d]\n", - addr); + IL_ERR("Time out reading EEPROM[%d]\n", addr); goto done; } r = _il_rd(il, CSR_EEPROM_REG); e[addr / 2] = cpu_to_le16(r >> 16); } - D_EEPROM("NVM Type: %s, version: 0x%x\n", - "EEPROM", - il_eeprom_query16(il, EEPROM_VERSION)); + D_EEPROM("NVM Type: %s, version: 0x%x\n", "EEPROM", + il_eeprom_query16(il, EEPROM_VERSION)); ret = 0; done: @@ -618,63 +631,74 @@ err: alloc_err: return ret; } + EXPORT_SYMBOL(il_eeprom_init); -void il_eeprom_free(struct il_priv *il) +void +il_eeprom_free(struct il_priv *il) { kfree(il->eeprom); il->eeprom = NULL; } + EXPORT_SYMBOL(il_eeprom_free); -static void il_init_band_reference(const struct il_priv *il, - int eep_band, int *eeprom_ch_count, - const struct il_eeprom_channel **eeprom_ch_info, - const u8 **eeprom_ch_idx) +static void +il_init_band_reference(const struct il_priv *il, int eep_band, + int *eeprom_ch_count, + const struct il_eeprom_channel **eeprom_ch_info, + const u8 ** eeprom_ch_idx) { - u32 offset = il->cfg->ops->lib-> - eeprom_ops.regulatory_bands[eep_band - 1]; + u32 offset = + il->cfg->ops->lib->eeprom_ops.regulatory_bands[eep_band - 1]; switch (eep_band) { case 1: /* 2.4GHz band */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_1); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); + *eeprom_ch_info = + (struct il_eeprom_channel *)il_eeprom_query_addr(il, + offset); *eeprom_ch_idx = il_eeprom_band_1; break; case 2: /* 4.9GHz band */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_2); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); + *eeprom_ch_info = + (struct il_eeprom_channel *)il_eeprom_query_addr(il, + offset); *eeprom_ch_idx = il_eeprom_band_2; break; case 3: /* 5.2GHz band */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_3); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); + *eeprom_ch_info = + (struct il_eeprom_channel *)il_eeprom_query_addr(il, + offset); *eeprom_ch_idx = il_eeprom_band_3; break; case 4: /* 5.5GHz band */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_4); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); + *eeprom_ch_info = + (struct il_eeprom_channel *)il_eeprom_query_addr(il, + offset); *eeprom_ch_idx = il_eeprom_band_4; break; case 5: /* 5.7GHz band */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_5); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); + *eeprom_ch_info = + (struct il_eeprom_channel *)il_eeprom_query_addr(il, + offset); *eeprom_ch_idx = il_eeprom_band_5; break; case 6: /* 2.4GHz ht40 channels */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_6); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); + *eeprom_ch_info = + (struct il_eeprom_channel *)il_eeprom_query_addr(il, + offset); *eeprom_ch_idx = il_eeprom_band_6; break; case 7: /* 5 GHz ht40 channels */ *eeprom_ch_count = ARRAY_SIZE(il_eeprom_band_7); - *eeprom_ch_info = (struct il_eeprom_channel *) - il_eeprom_query_addr(il, offset); + *eeprom_ch_info = + (struct il_eeprom_channel *)il_eeprom_query_addr(il, + offset); *eeprom_ch_idx = il_eeprom_band_7; break; default: @@ -689,41 +713,35 @@ static void il_init_band_reference(const struct il_priv *il, * * Does not set up a command, or touch hardware. */ -static int il_mod_ht40_chan_info(struct il_priv *il, - enum ieee80211_band band, u16 channel, - const struct il_eeprom_channel *eeprom_ch, - u8 clear_ht40_extension_channel) +static int +il_mod_ht40_chan_info(struct il_priv *il, enum ieee80211_band band, u16 channel, + const struct il_eeprom_channel *eeprom_ch, + u8 clear_ht40_extension_channel) { struct il_channel_info *ch_info; - ch_info = (struct il_channel_info *) - il_get_channel_info(il, band, channel); + ch_info = + (struct il_channel_info *)il_get_channel_info(il, band, channel); if (!il_is_channel_valid(ch_info)) return -1; D_EEPROM("HT40 Ch. %d [%sGHz] %s%s%s%s%s(0x%02x %ddBm):" - " Ad-Hoc %ssupported\n", - ch_info->channel, - il_is_channel_a_band(ch_info) ? - "5.2" : "2.4", - CHECK_AND_PRINT(IBSS), - CHECK_AND_PRINT(ACTIVE), - CHECK_AND_PRINT(RADAR), - CHECK_AND_PRINT(WIDE), - CHECK_AND_PRINT(DFS), - eeprom_ch->flags, - eeprom_ch->max_power_avg, - ((eeprom_ch->flags & EEPROM_CHANNEL_IBSS) - && !(eeprom_ch->flags & EEPROM_CHANNEL_RADAR)) ? - "" : "not "); + " Ad-Hoc %ssupported\n", ch_info->channel, + il_is_channel_a_band(ch_info) ? "5.2" : "2.4", + CHECK_AND_PRINT(IBSS), CHECK_AND_PRINT(ACTIVE), + CHECK_AND_PRINT(RADAR), CHECK_AND_PRINT(WIDE), + CHECK_AND_PRINT(DFS), eeprom_ch->flags, + eeprom_ch->max_power_avg, + ((eeprom_ch->flags & EEPROM_CHANNEL_IBSS) && + !(eeprom_ch->flags & EEPROM_CHANNEL_RADAR)) ? "" : "not "); ch_info->ht40_eeprom = *eeprom_ch; ch_info->ht40_max_power_avg = eeprom_ch->max_power_avg; ch_info->ht40_flags = eeprom_ch->flags; if (eeprom_ch->flags & EEPROM_CHANNEL_VALID) ch_info->ht40_extension_channel &= - ~clear_ht40_extension_channel; + ~clear_ht40_extension_channel; return 0; } @@ -734,7 +752,8 @@ static int il_mod_ht40_chan_info(struct il_priv *il, /** * il_init_channel_map - Set up driver's info for all possible channels */ -int il_init_channel_map(struct il_priv *il) +int +il_init_channel_map(struct il_priv *il) { int eeprom_ch_count = 0; const u8 *eeprom_ch_idx = NULL; @@ -750,17 +769,15 @@ int il_init_channel_map(struct il_priv *il) D_EEPROM("Initializing regulatory info from EEPROM\n"); il->channel_count = - ARRAY_SIZE(il_eeprom_band_1) + - ARRAY_SIZE(il_eeprom_band_2) + - ARRAY_SIZE(il_eeprom_band_3) + - ARRAY_SIZE(il_eeprom_band_4) + + ARRAY_SIZE(il_eeprom_band_1) + ARRAY_SIZE(il_eeprom_band_2) + + ARRAY_SIZE(il_eeprom_band_3) + ARRAY_SIZE(il_eeprom_band_4) + ARRAY_SIZE(il_eeprom_band_5); - D_EEPROM("Parsing data for %d channels.\n", - il->channel_count); + D_EEPROM("Parsing data for %d channels.\n", il->channel_count); - il->channel_info = kzalloc(sizeof(struct il_channel_info) * - il->channel_count, GFP_KERNEL); + il->channel_info = + kzalloc(sizeof(struct il_channel_info) * il->channel_count, + GFP_KERNEL); if (!il->channel_info) { IL_ERR("Could not allocate channel_info\n"); il->channel_count = 0; @@ -775,13 +792,14 @@ int il_init_channel_map(struct il_priv *il) for (band = 1; band <= 5; band++) { il_init_band_reference(il, band, &eeprom_ch_count, - &eeprom_ch_info, &eeprom_ch_idx); + &eeprom_ch_info, &eeprom_ch_idx); /* Loop through each band adding each of the channels */ for (ch = 0; ch < eeprom_ch_count; ch++) { ch_info->channel = eeprom_ch_idx[ch]; - ch_info->band = (band == 1) ? IEEE80211_BAND_2GHZ : - IEEE80211_BAND_5GHZ; + ch_info->band = + (band == + 1) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; /* permanently store EEPROM's channel regulatory flags * and max power in channel info database. */ @@ -793,16 +811,14 @@ int il_init_channel_map(struct il_priv *il) /* First write that ht40 is not enabled, and then enable * one by one */ ch_info->ht40_extension_channel = - IEEE80211_CHAN_NO_HT40; + IEEE80211_CHAN_NO_HT40; if (!(il_is_channel_valid(ch_info))) { - D_EEPROM( - "Ch. %d Flags %x [%sGHz] - " - "No traffic\n", - ch_info->channel, - ch_info->flags, - il_is_channel_a_band(ch_info) ? - "5.2" : "2.4"); + D_EEPROM("Ch. %d Flags %x [%sGHz] - " + "No traffic\n", ch_info->channel, + ch_info->flags, + il_is_channel_a_band(ch_info) ? "5.2" : + "2.4"); ch_info++; continue; } @@ -813,25 +829,22 @@ int il_init_channel_map(struct il_priv *il) ch_info->scan_power = eeprom_ch_info[ch].max_power_avg; ch_info->min_power = 0; - D_EEPROM("Ch. %d [%sGHz] " - "%s%s%s%s%s%s(0x%02x %ddBm):" - " Ad-Hoc %ssupported\n", - ch_info->channel, - il_is_channel_a_band(ch_info) ? - "5.2" : "2.4", - CHECK_AND_PRINT_I(VALID), - CHECK_AND_PRINT_I(IBSS), - CHECK_AND_PRINT_I(ACTIVE), - CHECK_AND_PRINT_I(RADAR), - CHECK_AND_PRINT_I(WIDE), - CHECK_AND_PRINT_I(DFS), - eeprom_ch_info[ch].flags, - eeprom_ch_info[ch].max_power_avg, - ((eeprom_ch_info[ch]. - flags & EEPROM_CHANNEL_IBSS) - && !(eeprom_ch_info[ch]. - flags & EEPROM_CHANNEL_RADAR)) - ? "" : "not "); + D_EEPROM("Ch. %d [%sGHz] " "%s%s%s%s%s%s(0x%02x %ddBm):" + " Ad-Hoc %ssupported\n", ch_info->channel, + il_is_channel_a_band(ch_info) ? "5.2" : "2.4", + CHECK_AND_PRINT_I(VALID), + CHECK_AND_PRINT_I(IBSS), + CHECK_AND_PRINT_I(ACTIVE), + CHECK_AND_PRINT_I(RADAR), + CHECK_AND_PRINT_I(WIDE), + CHECK_AND_PRINT_I(DFS), + eeprom_ch_info[ch].flags, + eeprom_ch_info[ch].max_power_avg, + ((eeprom_ch_info[ch]. + flags & EEPROM_CHANNEL_IBSS) && + !(eeprom_ch_info[ch]. + flags & EEPROM_CHANNEL_RADAR)) ? "" : + "not "); ch_info++; } @@ -849,40 +862,42 @@ int il_init_channel_map(struct il_priv *il) enum ieee80211_band ieeeband; il_init_band_reference(il, band, &eeprom_ch_count, - &eeprom_ch_info, &eeprom_ch_idx); + &eeprom_ch_info, &eeprom_ch_idx); /* EEPROM band 6 is 2.4, band 7 is 5 GHz */ ieeeband = - (band == 6) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; + (band == 6) ? IEEE80211_BAND_2GHZ : IEEE80211_BAND_5GHZ; /* Loop through each band adding each of the channels */ for (ch = 0; ch < eeprom_ch_count; ch++) { /* Set up driver's info for lower half */ - il_mod_ht40_chan_info(il, ieeeband, - eeprom_ch_idx[ch], - &eeprom_ch_info[ch], - IEEE80211_CHAN_NO_HT40PLUS); + il_mod_ht40_chan_info(il, ieeeband, eeprom_ch_idx[ch], + &eeprom_ch_info[ch], + IEEE80211_CHAN_NO_HT40PLUS); /* Set up driver's info for upper half */ il_mod_ht40_chan_info(il, ieeeband, - eeprom_ch_idx[ch] + 4, - &eeprom_ch_info[ch], - IEEE80211_CHAN_NO_HT40MINUS); + eeprom_ch_idx[ch] + 4, + &eeprom_ch_info[ch], + IEEE80211_CHAN_NO_HT40MINUS); } } return 0; } + EXPORT_SYMBOL(il_init_channel_map); /* * il_free_channel_map - undo allocations in il_init_channel_map */ -void il_free_channel_map(struct il_priv *il) +void +il_free_channel_map(struct il_priv *il) { kfree(il->channel_info); il->channel_count = 0; } + EXPORT_SYMBOL(il_free_channel_map); /** @@ -890,9 +905,9 @@ EXPORT_SYMBOL(il_free_channel_map); * * Based on band and channel number. */ -const struct -il_channel_info *il_get_channel_info(const struct il_priv *il, - enum ieee80211_band band, u16 channel) +const struct il_channel_info * +il_get_channel_info(const struct il_priv *il, enum ieee80211_band band, + u16 channel) { int i; @@ -913,6 +928,7 @@ il_channel_info *il_get_channel_info(const struct il_priv *il, return NULL; } + EXPORT_SYMBOL(il_get_channel_info); /* @@ -930,11 +946,11 @@ EXPORT_SYMBOL(il_get_channel_info); struct il_power_vec_entry { struct il_powertable_cmd cmd; - u8 no_dtim; /* number of skip dtim */ + u8 no_dtim; /* number of skip dtim */ }; -static void il_power_sleep_cam_cmd(struct il_priv *il, - struct il_powertable_cmd *cmd) +static void +il_power_sleep_cam_cmd(struct il_priv *il, struct il_powertable_cmd *cmd) { memset(cmd, 0, sizeof(*cmd)); @@ -949,25 +965,21 @@ il_set_power(struct il_priv *il, struct il_powertable_cmd *cmd) { D_POWER("Sending power/sleep command\n"); D_POWER("Flags value = 0x%08X\n", cmd->flags); - D_POWER("Tx timeout = %u\n", - le32_to_cpu(cmd->tx_data_timeout)); - D_POWER("Rx timeout = %u\n", - le32_to_cpu(cmd->rx_data_timeout)); - D_POWER( - "Sleep interval vector = { %d , %d , %d , %d , %d }\n", - le32_to_cpu(cmd->sleep_interval[0]), - le32_to_cpu(cmd->sleep_interval[1]), - le32_to_cpu(cmd->sleep_interval[2]), - le32_to_cpu(cmd->sleep_interval[3]), - le32_to_cpu(cmd->sleep_interval[4])); + D_POWER("Tx timeout = %u\n", le32_to_cpu(cmd->tx_data_timeout)); + D_POWER("Rx timeout = %u\n", le32_to_cpu(cmd->rx_data_timeout)); + D_POWER("Sleep interval vector = { %d , %d , %d , %d , %d }\n", + le32_to_cpu(cmd->sleep_interval[0]), + le32_to_cpu(cmd->sleep_interval[1]), + le32_to_cpu(cmd->sleep_interval[2]), + le32_to_cpu(cmd->sleep_interval[3]), + le32_to_cpu(cmd->sleep_interval[4])); return il_send_cmd_pdu(il, C_POWER_TBL, - sizeof(struct il_powertable_cmd), cmd); + sizeof(struct il_powertable_cmd), cmd); } int -il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, - bool force) +il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, bool force) { int ret; bool update_chains; @@ -976,7 +988,7 @@ il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, /* Don't update the RX chain when chain noise calibration is running */ update_chains = il->chain_noise_data.state == IL_CHAIN_NOISE_DONE || - il->chain_noise_data.state == IL_CHAIN_NOISE_ALIVE; + il->chain_noise_data.state == IL_CHAIN_NOISE_ALIVE; if (!memcmp(&il->power_data.sleep_cmd, cmd, sizeof(*cmd)) && !force) return 0; @@ -1002,10 +1014,9 @@ il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, if (il->cfg->ops->lib->update_chain_flags && update_chains) il->cfg->ops->lib->update_chain_flags(il); else if (il->cfg->ops->lib->update_chain_flags) - D_POWER( - "Cannot update the power, chain noise " - "calibration running: %d\n", - il->chain_noise_data.state); + D_POWER("Cannot update the power, chain noise " + "calibration running: %d\n", + il->chain_noise_data.state); memcpy(&il->power_data.sleep_cmd, cmd, sizeof(*cmd)); } else @@ -1014,17 +1025,20 @@ il_power_set_mode(struct il_priv *il, struct il_powertable_cmd *cmd, return ret; } -int il_power_update_mode(struct il_priv *il, bool force) +int +il_power_update_mode(struct il_priv *il, bool force) { struct il_powertable_cmd cmd; il_power_sleep_cam_cmd(il, &cmd); return il_power_set_mode(il, &cmd, force); } + EXPORT_SYMBOL(il_power_update_mode); /* initialize to default */ -void il_power_initialize(struct il_priv *il) +void +il_power_initialize(struct il_priv *il) { u16 lctl = il_pcie_link_ctl(il); @@ -1032,15 +1046,14 @@ void il_power_initialize(struct il_priv *il) il->power_data.debug_sleep_level_override = -1; - memset(&il->power_data.sleep_cmd, 0, - sizeof(il->power_data.sleep_cmd)); + memset(&il->power_data.sleep_cmd, 0, sizeof(il->power_data.sleep_cmd)); } EXPORT_SYMBOL(il_power_initialize); /* For active scan, listen ACTIVE_DWELL_TIME (msec) on each channel after * sending probe req. This should be set long enough to hear probe responses * from more than one AP. */ -#define IL_ACTIVE_DWELL_TIME_24 (30) /* all times in msec */ +#define IL_ACTIVE_DWELL_TIME_24 (30) /* all times in msec */ #define IL_ACTIVE_DWELL_TIME_52 (20) #define IL_ACTIVE_DWELL_FACTOR_24GHZ (3) @@ -1049,12 +1062,13 @@ EXPORT_SYMBOL(il_power_initialize); /* For passive scan, listen PASSIVE_DWELL_TIME (msec) on each channel. * Must be set longer than active dwell time. * For the most reliable scan, set > AP beacon interval (typically 100msec). */ -#define IL_PASSIVE_DWELL_TIME_24 (20) /* all times in msec */ +#define IL_PASSIVE_DWELL_TIME_24 (20) /* all times in msec */ #define IL_PASSIVE_DWELL_TIME_52 (10) #define IL_PASSIVE_DWELL_BASE (100) #define IL_CHANNEL_TUNE_TIME 5 -static int il_send_scan_abort(struct il_priv *il) +static int +il_send_scan_abort(struct il_priv *il) { int ret; struct il_rx_pkt *pkt; @@ -1093,7 +1107,8 @@ static int il_send_scan_abort(struct il_priv *il) return ret; } -static void il_complete_scan(struct il_priv *il, bool aborted) +static void +il_complete_scan(struct il_priv *il, bool aborted) { /* check if scan was requested from mac80211 */ if (il->scan_request) { @@ -1105,7 +1120,8 @@ static void il_complete_scan(struct il_priv *il, bool aborted) il->scan_request = NULL; } -void il_force_scan_end(struct il_priv *il) +void +il_force_scan_end(struct il_priv *il) { lockdep_assert_held(&il->mutex); @@ -1121,7 +1137,8 @@ void il_force_scan_end(struct il_priv *il) il_complete_scan(il, true); } -static void il_do_scan_abort(struct il_priv *il) +static void +il_do_scan_abort(struct il_priv *il) { int ret; @@ -1148,12 +1165,14 @@ static void il_do_scan_abort(struct il_priv *il) /** * il_scan_cancel - Cancel any currently executing HW scan */ -int il_scan_cancel(struct il_priv *il) +int +il_scan_cancel(struct il_priv *il) { D_SCAN("Queuing abort scan\n"); queue_work(il->workqueue, &il->abort_scan); return 0; } + EXPORT_SYMBOL(il_scan_cancel); /** @@ -1161,7 +1180,8 @@ EXPORT_SYMBOL(il_scan_cancel); * @ms: amount of time to wait (in milliseconds) for scan to abort * */ -int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms) +int +il_scan_cancel_timeout(struct il_priv *il, unsigned long ms) { unsigned long timeout = jiffies + msecs_to_jiffies(ms); @@ -1179,11 +1199,12 @@ int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms) return test_bit(S_SCAN_HW, &il->status); } + EXPORT_SYMBOL(il_scan_cancel_timeout); /* Service response to C_SCAN (0x80) */ -static void il_hdl_scan(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il_hdl_scan(struct il_priv *il, struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -1195,48 +1216,39 @@ static void il_hdl_scan(struct il_priv *il, } /* Service N_SCAN_START (0x82) */ -static void il_hdl_scan_start(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il_hdl_scan_start(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_scanstart_notification *notif = (struct il_scanstart_notification *)pkt->u.raw; il->scan_start_tsf = le32_to_cpu(notif->tsf_low); - D_SCAN("Scan start: " - "%d [802.11%s] " - "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n", - notif->channel, - notif->band ? "bg" : "a", - le32_to_cpu(notif->tsf_high), - le32_to_cpu(notif->tsf_low), - notif->status, notif->beacon_timer); + D_SCAN("Scan start: " "%d [802.11%s] " + "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n", notif->channel, + notif->band ? "bg" : "a", le32_to_cpu(notif->tsf_high), + le32_to_cpu(notif->tsf_low), notif->status, notif->beacon_timer); } /* Service N_SCAN_RESULTS (0x83) */ -static void il_hdl_scan_results(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il_hdl_scan_results(struct il_priv *il, struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_scanresults_notification *notif = (struct il_scanresults_notification *)pkt->u.raw; - D_SCAN("Scan ch.res: " - "%d [802.11%s] " - "(TSF: 0x%08X:%08X) - %d " - "elapsed=%lu usec\n", - notif->channel, - notif->band ? "bg" : "a", - le32_to_cpu(notif->tsf_high), - le32_to_cpu(notif->tsf_low), - le32_to_cpu(notif->stats[0]), - le32_to_cpu(notif->tsf_low) - il->scan_start_tsf); + D_SCAN("Scan ch.res: " "%d [802.11%s] " "(TSF: 0x%08X:%08X) - %d " + "elapsed=%lu usec\n", notif->channel, notif->band ? "bg" : "a", + le32_to_cpu(notif->tsf_high), le32_to_cpu(notif->tsf_low), + le32_to_cpu(notif->stats[0]), + le32_to_cpu(notif->tsf_low) - il->scan_start_tsf); #endif } /* Service N_SCAN_COMPLETE (0x84) */ -static void il_hdl_scan_complete(struct il_priv *il, - struct il_rx_buf *rxb) +static void +il_hdl_scan_complete(struct il_priv *il, struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG @@ -1244,58 +1256,58 @@ static void il_hdl_scan_complete(struct il_priv *il, struct il_scancomplete_notification *scan_notif = (void *)pkt->u.raw; #endif - D_SCAN( - "Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n", - scan_notif->scanned_channels, - scan_notif->tsf_low, - scan_notif->tsf_high, scan_notif->status); + D_SCAN("Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n", + scan_notif->scanned_channels, scan_notif->tsf_low, + scan_notif->tsf_high, scan_notif->status); /* The HW is no longer scanning */ clear_bit(S_SCAN_HW, &il->status); D_SCAN("Scan on %sGHz took %dms\n", - (il->scan_band == IEEE80211_BAND_2GHZ) ? "2.4" : "5.2", - jiffies_to_msecs(jiffies - il->scan_start)); + (il->scan_band == IEEE80211_BAND_2GHZ) ? "2.4" : "5.2", + jiffies_to_msecs(jiffies - il->scan_start)); queue_work(il->workqueue, &il->scan_completed); } -void il_setup_rx_scan_handlers(struct il_priv *il) +void +il_setup_rx_scan_handlers(struct il_priv *il) { /* scan handlers */ il->handlers[C_SCAN] = il_hdl_scan; - il->handlers[N_SCAN_START] = - il_hdl_scan_start; - il->handlers[N_SCAN_RESULTS] = - il_hdl_scan_results; - il->handlers[N_SCAN_COMPLETE] = - il_hdl_scan_complete; + il->handlers[N_SCAN_START] = il_hdl_scan_start; + il->handlers[N_SCAN_RESULTS] = il_hdl_scan_results; + il->handlers[N_SCAN_COMPLETE] = il_hdl_scan_complete; } + EXPORT_SYMBOL(il_setup_rx_scan_handlers); -inline u16 il_get_active_dwell_time(struct il_priv *il, - enum ieee80211_band band, - u8 n_probes) +inline u16 +il_get_active_dwell_time(struct il_priv *il, enum ieee80211_band band, + u8 n_probes) { if (band == IEEE80211_BAND_5GHZ) return IL_ACTIVE_DWELL_TIME_52 + - IL_ACTIVE_DWELL_FACTOR_52GHZ * (n_probes + 1); + IL_ACTIVE_DWELL_FACTOR_52GHZ * (n_probes + 1); else return IL_ACTIVE_DWELL_TIME_24 + - IL_ACTIVE_DWELL_FACTOR_24GHZ * (n_probes + 1); + IL_ACTIVE_DWELL_FACTOR_24GHZ * (n_probes + 1); } + EXPORT_SYMBOL(il_get_active_dwell_time); -u16 il_get_passive_dwell_time(struct il_priv *il, - enum ieee80211_band band, - struct ieee80211_vif *vif) +u16 +il_get_passive_dwell_time(struct il_priv * il, enum ieee80211_band band, + struct ieee80211_vif * vif) { struct il_rxon_context *ctx = &il->ctx; u16 value; - u16 passive = (band == IEEE80211_BAND_2GHZ) ? - IL_PASSIVE_DWELL_BASE + IL_PASSIVE_DWELL_TIME_24 : - IL_PASSIVE_DWELL_BASE + IL_PASSIVE_DWELL_TIME_52; + u16 passive = + (band == + IEEE80211_BAND_2GHZ) ? IL_PASSIVE_DWELL_BASE + + IL_PASSIVE_DWELL_TIME_24 : IL_PASSIVE_DWELL_BASE + + IL_PASSIVE_DWELL_TIME_52; if (il_is_any_associated(il)) { /* @@ -1312,9 +1324,11 @@ u16 il_get_passive_dwell_time(struct il_priv *il, return passive; } + EXPORT_SYMBOL(il_get_passive_dwell_time); -void il_init_scan_params(struct il_priv *il) +void +il_init_scan_params(struct il_priv *il) { u8 ant_idx = fls(il->hw_params.valid_tx_ant) - 1; if (!il->scan_tx_ant[IEEE80211_BAND_5GHZ]) @@ -1322,10 +1336,11 @@ void il_init_scan_params(struct il_priv *il) if (!il->scan_tx_ant[IEEE80211_BAND_2GHZ]) il->scan_tx_ant[IEEE80211_BAND_2GHZ] = ant_idx; } + EXPORT_SYMBOL(il_init_scan_params); -static int il_scan_initiate(struct il_priv *il, - struct ieee80211_vif *vif) +static int +il_scan_initiate(struct il_priv *il, struct ieee80211_vif *vif) { int ret; @@ -1342,8 +1357,7 @@ static int il_scan_initiate(struct il_priv *il, } if (test_bit(S_SCAN_HW, &il->status)) { - D_SCAN( - "Multiple concurrent scan requests in parallel.\n"); + D_SCAN("Multiple concurrent scan requests in parallel.\n"); return -EBUSY; } @@ -1369,9 +1383,9 @@ static int il_scan_initiate(struct il_priv *il, return 0; } -int il_mac_hw_scan(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct cfg80211_scan_request *req) +int +il_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct cfg80211_scan_request *req) { struct il_priv *il = hw->priv; int ret; @@ -1403,9 +1417,11 @@ out_unlock: return ret; } + EXPORT_SYMBOL(il_mac_hw_scan); -static void il_bg_scan_check(struct work_struct *data) +static void +il_bg_scan_check(struct work_struct *data) { struct il_priv *il = container_of(data, struct il_priv, scan_check.work); @@ -1426,7 +1442,7 @@ static void il_bg_scan_check(struct work_struct *data) u16 il_fill_probe_req(struct il_priv *il, struct ieee80211_mgmt *frame, - const u8 *ta, const u8 *ies, int ie_len, int left) + const u8 * ta, const u8 * ies, int ie_len, int left) { int len = 0; u8 *pos = NULL; @@ -1465,11 +1481,13 @@ il_fill_probe_req(struct il_priv *il, struct ieee80211_mgmt *frame, len += ie_len; } - return (u16)len; + return (u16) len; } + EXPORT_SYMBOL(il_fill_probe_req); -static void il_bg_abort_scan(struct work_struct *work) +static void +il_bg_abort_scan(struct work_struct *work) { struct il_priv *il = container_of(work, struct il_priv, abort_scan); @@ -1482,10 +1500,10 @@ static void il_bg_abort_scan(struct work_struct *work) mutex_unlock(&il->mutex); } -static void il_bg_scan_completed(struct work_struct *work) +static void +il_bg_scan_completed(struct work_struct *work) { - struct il_priv *il = - container_of(work, struct il_priv, scan_completed); + struct il_priv *il = container_of(work, struct il_priv, scan_completed); bool aborted; D_SCAN("Completed scan.\n"); @@ -1523,15 +1541,18 @@ out: mutex_unlock(&il->mutex); } -void il_setup_scan_deferred_work(struct il_priv *il) +void +il_setup_scan_deferred_work(struct il_priv *il) { INIT_WORK(&il->scan_completed, il_bg_scan_completed); INIT_WORK(&il->abort_scan, il_bg_abort_scan); INIT_DELAYED_WORK(&il->scan_check, il_bg_scan_check); } + EXPORT_SYMBOL(il_setup_scan_deferred_work); -void il_cancel_scan_deferred_work(struct il_priv *il) +void +il_cancel_scan_deferred_work(struct il_priv *il) { cancel_work_sync(&il->abort_scan); cancel_work_sync(&il->scan_completed); @@ -1542,46 +1563,43 @@ void il_cancel_scan_deferred_work(struct il_priv *il) mutex_unlock(&il->mutex); } } + EXPORT_SYMBOL(il_cancel_scan_deferred_work); /* il->sta_lock must be held */ -static void il_sta_ucode_activate(struct il_priv *il, u8 sta_id) +static void +il_sta_ucode_activate(struct il_priv *il, u8 sta_id) { if (!(il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) - IL_ERR( - "ACTIVATE a non DRIVER active station id %u addr %pM\n", - sta_id, il->stations[sta_id].sta.sta.addr); + IL_ERR("ACTIVATE a non DRIVER active station id %u addr %pM\n", + sta_id, il->stations[sta_id].sta.sta.addr); if (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE) { - D_ASSOC( - "STA id %u addr %pM already present" - " in uCode (according to driver)\n", - sta_id, il->stations[sta_id].sta.sta.addr); + D_ASSOC("STA id %u addr %pM already present" + " in uCode (according to driver)\n", sta_id, + il->stations[sta_id].sta.sta.addr); } else { il->stations[sta_id].used |= IL_STA_UCODE_ACTIVE; - D_ASSOC("Added STA id %u addr %pM to uCode\n", - sta_id, il->stations[sta_id].sta.sta.addr); + D_ASSOC("Added STA id %u addr %pM to uCode\n", sta_id, + il->stations[sta_id].sta.sta.addr); } } -static int il_process_add_sta_resp(struct il_priv *il, - struct il_addsta_cmd *addsta, - struct il_rx_pkt *pkt, - bool sync) +static int +il_process_add_sta_resp(struct il_priv *il, struct il_addsta_cmd *addsta, + struct il_rx_pkt *pkt, bool sync) { u8 sta_id = addsta->sta.sta_id; unsigned long flags; int ret = -EIO; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR("Bad return from C_ADD_STA (0x%08X)\n", - pkt->hdr.flags); + IL_ERR("Bad return from C_ADD_STA (0x%08X)\n", pkt->hdr.flags); return ret; } - D_INFO("Processing response for adding station %u\n", - sta_id); + D_INFO("Processing response for adding station %u\n", sta_id); spin_lock_irqsave(&il->sta_lock, flags); @@ -1592,28 +1610,25 @@ static int il_process_add_sta_resp(struct il_priv *il, ret = 0; break; case ADD_STA_NO_ROOM_IN_TBL: - IL_ERR("Adding station %d failed, no room in table.\n", - sta_id); + IL_ERR("Adding station %d failed, no room in table.\n", sta_id); break; case ADD_STA_NO_BLOCK_ACK_RESOURCE: - IL_ERR( - "Adding station %d failed, no block ack resource.\n", - sta_id); + IL_ERR("Adding station %d failed, no block ack resource.\n", + sta_id); break; case ADD_STA_MODIFY_NON_EXIST_STA: IL_ERR("Attempting to modify non-existing station %d\n", - sta_id); + sta_id); break; default: - D_ASSOC("Received C_ADD_STA:(0x%08X)\n", - pkt->u.add_sta.status); + D_ASSOC("Received C_ADD_STA:(0x%08X)\n", pkt->u.add_sta.status); break; } D_INFO("%s station id %u addr %pM\n", - il->stations[sta_id].sta.mode == - STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", - sta_id, il->stations[sta_id].sta.sta.addr); + il->stations[sta_id].sta.mode == + STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", sta_id, + il->stations[sta_id].sta.sta.addr); /* * XXX: The MAC address in the command buffer is often changed from @@ -1624,27 +1639,25 @@ static int il_process_add_sta_resp(struct il_priv *il, * observe the problem. */ D_INFO("%s station according to cmd buffer %pM\n", - il->stations[sta_id].sta.mode == - STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", - addsta->sta.addr); + il->stations[sta_id].sta.mode == + STA_CONTROL_MODIFY_MSK ? "Modified" : "Added", addsta->sta.addr); spin_unlock_irqrestore(&il->sta_lock, flags); return ret; } -static void il_add_sta_callback(struct il_priv *il, - struct il_device_cmd *cmd, - struct il_rx_pkt *pkt) +static void +il_add_sta_callback(struct il_priv *il, struct il_device_cmd *cmd, + struct il_rx_pkt *pkt) { - struct il_addsta_cmd *addsta = - (struct il_addsta_cmd *)cmd->cmd.payload; + struct il_addsta_cmd *addsta = (struct il_addsta_cmd *)cmd->cmd.payload; il_process_add_sta_resp(il, addsta, pkt, false); } -int il_send_add_sta(struct il_priv *il, - struct il_addsta_cmd *sta, u8 flags) +int +il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags) { struct il_rx_pkt *pkt = NULL; int ret = 0; @@ -1656,8 +1669,8 @@ int il_send_add_sta(struct il_priv *il, }; u8 sta_id __maybe_unused = sta->sta.sta_id; - D_INFO("Adding sta %u (%pM) %ssynchronously\n", - sta_id, sta->sta.addr, flags & CMD_ASYNC ? "a" : ""); + D_INFO("Adding sta %u (%pM) %ssynchronously\n", sta_id, sta->sta.addr, + flags & CMD_ASYNC ? "a" : ""); if (flags & CMD_ASYNC) cmd.callback = il_add_sta_callback; @@ -1680,11 +1693,12 @@ int il_send_add_sta(struct il_priv *il, return ret; } + EXPORT_SYMBOL(il_send_add_sta); -static void il_set_ht_add_station(struct il_priv *il, u8 idx, - struct ieee80211_sta *sta, - struct il_rxon_context *ctx) +static void +il_set_ht_add_station(struct il_priv *il, u8 idx, struct ieee80211_sta *sta, + struct il_rxon_context *ctx) { struct ieee80211_sta_ht_cap *sta_ht_inf = &sta->ht_cap; __le32 sta_flags; @@ -1695,10 +1709,10 @@ static void il_set_ht_add_station(struct il_priv *il, u8 idx, mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_SM_PS) >> 2; D_ASSOC("spatial multiplexing power save mode: %s\n", - (mimo_ps_mode == WLAN_HT_CAP_SM_PS_STATIC) ? - "static" : - (mimo_ps_mode == WLAN_HT_CAP_SM_PS_DYNAMIC) ? - "dynamic" : "disabled"); + (mimo_ps_mode == + WLAN_HT_CAP_SM_PS_STATIC) ? "static" : (mimo_ps_mode == + WLAN_HT_CAP_SM_PS_DYNAMIC) + ? "dynamic" : "disabled"); sta_flags = il->stations[idx].sta.station_flags; @@ -1718,11 +1732,13 @@ static void il_set_ht_add_station(struct il_priv *il, u8 idx, break; } - sta_flags |= cpu_to_le32( - (u32)sta_ht_inf->ampdu_factor << STA_FLG_MAX_AGG_SIZE_POS); + sta_flags |= + cpu_to_le32((u32) sta_ht_inf-> + ampdu_factor << STA_FLG_MAX_AGG_SIZE_POS); - sta_flags |= cpu_to_le32( - (u32)sta_ht_inf->ampdu_density << STA_FLG_AGG_MPDU_DENSITY_POS); + sta_flags |= + cpu_to_le32((u32) sta_ht_inf-> + ampdu_density << STA_FLG_AGG_MPDU_DENSITY_POS); if (il_is_ht40_tx_allowed(il, ctx, &sta->ht_cap)) sta_flags |= STA_FLG_HT40_EN_MSK; @@ -1730,7 +1746,7 @@ static void il_set_ht_add_station(struct il_priv *il, u8 idx, sta_flags &= ~STA_FLG_HT40_EN_MSK; il->stations[idx].sta.station_flags = sta_flags; - done: +done: return; } @@ -1739,8 +1755,9 @@ static void il_set_ht_add_station(struct il_priv *il, u8 idx, * * should be called with sta_lock held */ -u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, - const u8 *addr, bool is_ap, struct ieee80211_sta *sta) +u8 +il_prep_station(struct il_priv * il, struct il_rxon_context * ctx, + const u8 * addr, bool is_ap, struct ieee80211_sta * sta) { struct il_station_entry *station; int i; @@ -1753,8 +1770,8 @@ u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, sta_id = ctx->bcast_sta_id; else for (i = IL_STA_ID; i < il->hw_params.max_stations; i++) { - if (!compare_ether_addr(il->stations[i].sta.sta.addr, - addr)) { + if (!compare_ether_addr + (il->stations[i].sta.sta.addr, addr)) { sta_id = i; break; } @@ -1777,25 +1794,21 @@ u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, * another. */ if (il->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { - D_INFO( - "STA %d already in process of being added.\n", - sta_id); + D_INFO("STA %d already in process of being added.\n", sta_id); return sta_id; } if ((il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE) && !compare_ether_addr(il->stations[sta_id].sta.sta.addr, addr)) { - D_ASSOC( - "STA %d (%pM) already added, not adding again.\n", - sta_id, addr); + D_ASSOC("STA %d (%pM) already added, not adding again.\n", + sta_id, addr); return sta_id; } station = &il->stations[sta_id]; station->used = IL_STA_DRIVER_ACTIVE; - D_ASSOC("Add STA to driver ID %d: %pM\n", - sta_id, addr); + D_ASSOC("Add STA to driver ID %d: %pM\n", sta_id, addr); il->num_stations++; /* Set up the C_ADD_STA command to send to device */ @@ -1821,14 +1834,14 @@ u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, il_set_ht_add_station(il, sta_id, sta, ctx); /* 3945 only */ - rate = (il->band == IEEE80211_BAND_5GHZ) ? - RATE_6M_PLCP : RATE_1M_PLCP; + rate = (il->band == IEEE80211_BAND_5GHZ) ? RATE_6M_PLCP : RATE_1M_PLCP; /* Turn on both antennas for the station... */ station->sta.rate_n_flags = cpu_to_le16(rate | RATE_MCS_ANT_AB_MSK); return sta_id; } + EXPORT_SYMBOL_GPL(il_prep_station); #define STA_WAIT_TIMEOUT (HZ/2) @@ -1837,10 +1850,9 @@ EXPORT_SYMBOL_GPL(il_prep_station); * il_add_station_common - */ int -il_add_station_common(struct il_priv *il, - struct il_rxon_context *ctx, - const u8 *addr, bool is_ap, - struct ieee80211_sta *sta, u8 *sta_id_r) +il_add_station_common(struct il_priv *il, struct il_rxon_context *ctx, + const u8 * addr, bool is_ap, struct ieee80211_sta *sta, + u8 * sta_id_r) { unsigned long flags_spin; int ret = 0; @@ -1851,8 +1863,7 @@ il_add_station_common(struct il_priv *il, spin_lock_irqsave(&il->sta_lock, flags_spin); sta_id = il_prep_station(il, ctx, addr, is_ap, sta); if (sta_id == IL_INVALID_STATION) { - IL_ERR("Unable to prepare station %pM for addition\n", - addr); + IL_ERR("Unable to prepare station %pM for addition\n", addr); spin_unlock_irqrestore(&il->sta_lock, flags_spin); return -EINVAL; } @@ -1863,17 +1874,14 @@ il_add_station_common(struct il_priv *il, * another. */ if (il->stations[sta_id].used & IL_STA_UCODE_INPROGRESS) { - D_INFO( - "STA %d already in process of being added.\n", - sta_id); + D_INFO("STA %d already in process of being added.\n", sta_id); spin_unlock_irqrestore(&il->sta_lock, flags_spin); return -EEXIST; } if ((il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE) && (il->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { - D_ASSOC( - "STA %d (%pM) already added, not adding again.\n", + D_ASSOC("STA %d (%pM) already added, not adding again.\n", sta_id, addr); spin_unlock_irqrestore(&il->sta_lock, flags_spin); return -EEXIST; @@ -1881,7 +1889,7 @@ il_add_station_common(struct il_priv *il, il->stations[sta_id].used |= IL_STA_UCODE_INPROGRESS; memcpy(&sta_cmd, &il->stations[sta_id].sta, - sizeof(struct il_addsta_cmd)); + sizeof(struct il_addsta_cmd)); spin_unlock_irqrestore(&il->sta_lock, flags_spin); /* Add station to device's station table */ @@ -1889,7 +1897,7 @@ il_add_station_common(struct il_priv *il, if (ret) { spin_lock_irqsave(&il->sta_lock, flags_spin); IL_ERR("Adding station %pM failed.\n", - il->stations[sta_id].sta.sta.addr); + il->stations[sta_id].sta.sta.addr); il->stations[sta_id].used &= ~IL_STA_DRIVER_ACTIVE; il->stations[sta_id].used &= ~IL_STA_UCODE_INPROGRESS; spin_unlock_irqrestore(&il->sta_lock, flags_spin); @@ -1897,6 +1905,7 @@ il_add_station_common(struct il_priv *il, *sta_id_r = sta_id; return ret; } + EXPORT_SYMBOL(il_add_station_common); /** @@ -1904,12 +1913,13 @@ EXPORT_SYMBOL(il_add_station_common); * * il->sta_lock must be held */ -static void il_sta_ucode_deactivate(struct il_priv *il, u8 sta_id) +static void +il_sta_ucode_deactivate(struct il_priv *il, u8 sta_id) { /* Ucode must be active and driver must be non active */ - if ((il->stations[sta_id].used & - (IL_STA_UCODE_ACTIVE | IL_STA_DRIVER_ACTIVE)) != - IL_STA_UCODE_ACTIVE) + if ((il->stations[sta_id]. + used & (IL_STA_UCODE_ACTIVE | IL_STA_DRIVER_ACTIVE)) != + IL_STA_UCODE_ACTIVE) IL_ERR("removed non active STA %u\n", sta_id); il->stations[sta_id].used &= ~IL_STA_UCODE_ACTIVE; @@ -1918,9 +1928,9 @@ static void il_sta_ucode_deactivate(struct il_priv *il, u8 sta_id) D_ASSOC("Removed STA %u\n", sta_id); } -static int il_send_remove_station(struct il_priv *il, - const u8 *addr, int sta_id, - bool temporary) +static int +il_send_remove_station(struct il_priv *il, const u8 * addr, int sta_id, + bool temporary) { struct il_rx_pkt *pkt; int ret; @@ -1948,8 +1958,7 @@ static int il_send_remove_station(struct il_priv *il, pkt = (struct il_rx_pkt *)cmd.reply_page; if (pkt->hdr.flags & IL_CMD_FAILED_MSK) { - IL_ERR("Bad return from C_REM_STA (0x%08X)\n", - pkt->hdr.flags); + IL_ERR("Bad return from C_REM_STA (0x%08X)\n", pkt->hdr.flags); ret = -EIO; } @@ -1960,7 +1969,7 @@ static int il_send_remove_station(struct il_priv *il, spin_lock_irqsave(&il->sta_lock, flags_spin); il_sta_ucode_deactivate(il, sta_id); spin_unlock_irqrestore(&il->sta_lock, - flags_spin); + flags_spin); } D_ASSOC("C_REM_STA PASSED\n"); break; @@ -1978,15 +1987,14 @@ static int il_send_remove_station(struct il_priv *il, /** * il_remove_station - Remove driver's knowledge of station. */ -int il_remove_station(struct il_priv *il, const u8 sta_id, - const u8 *addr) +int +il_remove_station(struct il_priv *il, const u8 sta_id, const u8 * addr) { unsigned long flags; if (!il_is_ready(il)) { - D_INFO( - "Unable to remove station %pM, device not ready.\n", - addr); + D_INFO("Unable to remove station %pM, device not ready.\n", + addr); /* * It is typical for stations to be removed when we are * going down. Return success since device will be down @@ -1995,8 +2003,7 @@ int il_remove_station(struct il_priv *il, const u8 sta_id, return 0; } - D_ASSOC("Removing STA from driver:%d %pM\n", - sta_id, addr); + D_ASSOC("Removing STA from driver:%d %pM\n", sta_id, addr); if (WARN_ON(sta_id == IL_INVALID_STATION)) return -EINVAL; @@ -2004,14 +2011,12 @@ int il_remove_station(struct il_priv *il, const u8 sta_id, spin_lock_irqsave(&il->sta_lock, flags); if (!(il->stations[sta_id].used & IL_STA_DRIVER_ACTIVE)) { - D_INFO("Removing %pM but non DRIVER active\n", - addr); + D_INFO("Removing %pM but non DRIVER active\n", addr); goto out_err; } if (!(il->stations[sta_id].used & IL_STA_UCODE_ACTIVE)) { - D_INFO("Removing %pM but non UCODE active\n", - addr); + D_INFO("Removing %pM but non UCODE active\n", addr); goto out_err; } @@ -2033,6 +2038,7 @@ out_err: spin_unlock_irqrestore(&il->sta_lock, flags); return -EINVAL; } + EXPORT_SYMBOL_GPL(il_remove_station); /** @@ -2043,8 +2049,8 @@ EXPORT_SYMBOL_GPL(il_remove_station); * other than explicit station management would cause this in * the ucode, e.g. unassociated RXON. */ -void il_clear_ucode_stations(struct il_priv *il, - struct il_rxon_context *ctx) +void +il_clear_ucode_stations(struct il_priv *il, struct il_rxon_context *ctx) { int i; unsigned long flags_spin; @@ -2058,8 +2064,7 @@ void il_clear_ucode_stations(struct il_priv *il, continue; if (il->stations[i].used & IL_STA_UCODE_ACTIVE) { - D_INFO( - "Clearing ucode active for station %d\n", i); + D_INFO("Clearing ucode active for station %d\n", i); il->stations[i].used &= ~IL_STA_UCODE_ACTIVE; cleared = true; } @@ -2067,9 +2072,9 @@ void il_clear_ucode_stations(struct il_priv *il, spin_unlock_irqrestore(&il->sta_lock, flags_spin); if (!cleared) - D_INFO( - "No active stations found to be cleared\n"); + D_INFO("No active stations found to be cleared\n"); } + EXPORT_SYMBOL(il_clear_ucode_stations); /** @@ -2092,8 +2097,7 @@ il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) bool send_lq; if (!il_is_ready(il)) { - D_INFO( - "Not ready yet, not restoring any stations.\n"); + D_INFO("Not ready yet, not restoring any stations.\n"); return; } @@ -2105,7 +2109,7 @@ il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) if ((il->stations[i].used & IL_STA_DRIVER_ACTIVE) && !(il->stations[i].used & IL_STA_UCODE_ACTIVE)) { D_ASSOC("Restoring sta %pM\n", - il->stations[i].sta.sta.addr); + il->stations[i].sta.sta.addr); il->stations[i].sta.mode = 0; il->stations[i].used |= IL_STA_UCODE_INPROGRESS; found = true; @@ -2127,21 +2131,19 @@ il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) if (ret) { spin_lock_irqsave(&il->sta_lock, flags_spin); IL_ERR("Adding station %pM failed.\n", - il->stations[i].sta.sta.addr); - il->stations[i].used &= - ~IL_STA_DRIVER_ACTIVE; + il->stations[i].sta.sta.addr); + il->stations[i].used &= ~IL_STA_DRIVER_ACTIVE; il->stations[i].used &= - ~IL_STA_UCODE_INPROGRESS; + ~IL_STA_UCODE_INPROGRESS; spin_unlock_irqrestore(&il->sta_lock, - flags_spin); + flags_spin); } /* * Rate scaling has already been initialized, send * current LQ command */ if (send_lq) - il_send_lq_cmd(il, ctx, &lq, - CMD_SYNC, true); + il_send_lq_cmd(il, ctx, &lq, CMD_SYNC, true); spin_lock_irqsave(&il->sta_lock, flags_spin); il->stations[i].used &= ~IL_STA_UCODE_INPROGRESS; } @@ -2150,14 +2152,15 @@ il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) spin_unlock_irqrestore(&il->sta_lock, flags_spin); if (!found) D_INFO("Restoring all known stations" - " .... no stations to be restored.\n"); + " .... no stations to be restored.\n"); else - D_INFO("Restoring all known stations" - " .... complete.\n"); + D_INFO("Restoring all known stations" " .... complete.\n"); } + EXPORT_SYMBOL(il_restore_stations); -int il_get_free_ucode_key_idx(struct il_priv *il) +int +il_get_free_ucode_key_idx(struct il_priv *il) { int i; @@ -2167,9 +2170,11 @@ int il_get_free_ucode_key_idx(struct il_priv *il) return WEP_INVALID_OFFSET; } + EXPORT_SYMBOL(il_get_free_ucode_key_idx); -void il_dealloc_bcast_stations(struct il_priv *il) +void +il_dealloc_bcast_stations(struct il_priv *il) { unsigned long flags; int i; @@ -2187,25 +2192,24 @@ void il_dealloc_bcast_stations(struct il_priv *il) } spin_unlock_irqrestore(&il->sta_lock, flags); } + EXPORT_SYMBOL_GPL(il_dealloc_bcast_stations); #ifdef CONFIG_IWLEGACY_DEBUG -static void il_dump_lq_cmd(struct il_priv *il, - struct il_link_quality_cmd *lq) +static void +il_dump_lq_cmd(struct il_priv *il, struct il_link_quality_cmd *lq) { int i; D_RATE("lq station id 0x%x\n", lq->sta_id); - D_RATE("lq ant 0x%X 0x%X\n", - lq->general_params.single_stream_ant_msk, - lq->general_params.dual_stream_ant_msk); + D_RATE("lq ant 0x%X 0x%X\n", lq->general_params.single_stream_ant_msk, + lq->general_params.dual_stream_ant_msk); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) - D_RATE("lq idx %d 0x%X\n", - i, lq->rs_table[i].rate_n_flags); + D_RATE("lq idx %d 0x%X\n", i, lq->rs_table[i].rate_n_flags); } #else -static inline void il_dump_lq_cmd(struct il_priv *il, - struct il_link_quality_cmd *lq) +static inline void +il_dump_lq_cmd(struct il_priv *il, struct il_link_quality_cmd *lq) { } #endif @@ -2221,23 +2225,19 @@ static inline void il_dump_lq_cmd(struct il_priv *il, * Test for this to prevent driver from sending LQ command between the time * RXON flags are updated and when LQ command is updated. */ -static bool il_is_lq_table_valid(struct il_priv *il, - struct il_rxon_context *ctx, - struct il_link_quality_cmd *lq) +static bool +il_is_lq_table_valid(struct il_priv *il, struct il_rxon_context *ctx, + struct il_link_quality_cmd *lq) { int i; if (ctx->ht.enabled) return true; - D_INFO("Channel %u is not an HT channel\n", - ctx->active.channel); + D_INFO("Channel %u is not an HT channel\n", ctx->active.channel); for (i = 0; i < LINK_QUAL_MAX_RETRY_NUM; i++) { - if (le32_to_cpu(lq->rs_table[i].rate_n_flags) & - RATE_MCS_HT_MSK) { - D_INFO( - "idx %d of LQ expects HT channel\n", - i); + if (le32_to_cpu(lq->rs_table[i].rate_n_flags) & RATE_MCS_HT_MSK) { + D_INFO("idx %d of LQ expects HT channel\n", i); return false; } } @@ -2254,8 +2254,9 @@ static bool il_is_lq_table_valid(struct il_priv *il, * this case to clear the state indicating that station creation is in * progress. */ -int il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, - struct il_link_quality_cmd *lq, u8 flags, bool init) +int +il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, + struct il_link_quality_cmd *lq, u8 flags, bool init) { int ret = 0; unsigned long flags_spin; @@ -2270,7 +2271,6 @@ int il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, if (WARN_ON(lq->sta_id == IL_INVALID_STATION)) return -EINVAL; - spin_lock_irqsave(&il->sta_lock, flags_spin); if (!(il->stations[lq->sta_id].used & IL_STA_DRIVER_ACTIVE)) { spin_unlock_irqrestore(&il->sta_lock, flags_spin); @@ -2291,36 +2291,35 @@ int il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, if (init) { D_INFO("init LQ command complete," - " clearing sta addition status for sta %d\n", - lq->sta_id); + " clearing sta addition status for sta %d\n", + lq->sta_id); spin_lock_irqsave(&il->sta_lock, flags_spin); il->stations[lq->sta_id].used &= ~IL_STA_UCODE_INPROGRESS; spin_unlock_irqrestore(&il->sta_lock, flags_spin); } return ret; } + EXPORT_SYMBOL(il_send_lq_cmd); -int il_mac_sta_remove(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta) +int +il_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_sta *sta) { struct il_priv *il = hw->priv; struct il_station_priv_common *sta_common = (void *)sta->drv_priv; int ret; - D_INFO("received request to remove station %pM\n", - sta->addr); + D_INFO("received request to remove station %pM\n", sta->addr); mutex_lock(&il->mutex); - D_INFO("proceeding to remove station %pM\n", - sta->addr); + D_INFO("proceeding to remove station %pM\n", sta->addr); ret = il_remove_station(il, sta_common->sta_id, sta->addr); if (ret) - IL_ERR("Error removing station %pM\n", - sta->addr); + IL_ERR("Error removing station %pM\n", sta->addr); mutex_unlock(&il->mutex); return ret; } + EXPORT_SYMBOL(il_mac_sta_remove); /************************** RX-FUNCTIONS ****************************/ @@ -2393,7 +2392,8 @@ EXPORT_SYMBOL(il_mac_sta_remove); /** * il_rx_queue_space - Return number of free slots available in queue. */ -int il_rx_queue_space(const struct il_rx_queue *q) +int +il_rx_queue_space(const struct il_rx_queue *q) { int s = q->read - q->write; if (s <= 0) @@ -2404,14 +2404,14 @@ int il_rx_queue_space(const struct il_rx_queue *q) s = 0; return s; } + EXPORT_SYMBOL(il_rx_queue_space); /** * il_rx_queue_update_write_ptr - Update the write pointer for the RX queue */ void -il_rx_queue_update_write_ptr(struct il_priv *il, - struct il_rx_queue *q) +il_rx_queue_update_write_ptr(struct il_priv *il, struct il_rx_queue *q) { unsigned long flags; u32 rx_wrt_ptr_reg = il->hw_params.rx_wrt_ptr_reg; @@ -2427,34 +2427,33 @@ il_rx_queue_update_write_ptr(struct il_priv *il, reg = _il_rd(il, CSR_UCODE_DRV_GP1); if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { - D_INFO( - "Rx queue requesting wakeup," - " GP1 = 0x%x\n", reg); + D_INFO("Rx queue requesting wakeup," " GP1 = 0x%x\n", + reg); il_set_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); + CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); goto exit_unlock; } q->write_actual = (q->write & ~0x7); - il_wr(il, rx_wrt_ptr_reg, - q->write_actual); + il_wr(il, rx_wrt_ptr_reg, q->write_actual); - /* Else device is assumed to be awake */ + /* Else device is assumed to be awake */ } else { /* Device expects a multiple of 8 */ q->write_actual = (q->write & ~0x7); - il_wr(il, rx_wrt_ptr_reg, - q->write_actual); + il_wr(il, rx_wrt_ptr_reg, q->write_actual); } q->need_update = 0; - exit_unlock: +exit_unlock: spin_unlock_irqrestore(&q->lock, flags); } + EXPORT_SYMBOL(il_rx_queue_update_write_ptr); -int il_rx_queue_alloc(struct il_priv *il) +int +il_rx_queue_alloc(struct il_priv *il) { struct il_rx_queue *rxq = &il->rxq; struct device *dev = &il->pci_dev->dev; @@ -2465,13 +2464,15 @@ int il_rx_queue_alloc(struct il_priv *il) INIT_LIST_HEAD(&rxq->rx_used); /* Alloc the circular buffer of Read Buffer Descriptors (RBDs) */ - rxq->bd = dma_alloc_coherent(dev, 4 * RX_QUEUE_SIZE, &rxq->bd_dma, - GFP_KERNEL); + rxq->bd = + dma_alloc_coherent(dev, 4 * RX_QUEUE_SIZE, &rxq->bd_dma, + GFP_KERNEL); if (!rxq->bd) goto err_bd; - rxq->rb_stts = dma_alloc_coherent(dev, sizeof(struct il_rb_status), - &rxq->rb_stts_dma, GFP_KERNEL); + rxq->rb_stts = + dma_alloc_coherent(dev, sizeof(struct il_rb_status), + &rxq->rb_stts_dma, GFP_KERNEL); if (!rxq->rb_stts) goto err_rb; @@ -2493,33 +2494,32 @@ err_rb: err_bd: return -ENOMEM; } -EXPORT_SYMBOL(il_rx_queue_alloc); +EXPORT_SYMBOL(il_rx_queue_alloc); -void il_hdl_spectrum_measurement(struct il_priv *il, - struct il_rx_buf *rxb) +void +il_hdl_spectrum_measurement(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_spectrum_notification *report = &(pkt->u.spectrum_notif); if (!report->state) { - D_11H( - "Spectrum Measure Notification: Start\n"); + D_11H("Spectrum Measure Notification: Start\n"); return; } memcpy(&il->measure_report, report, sizeof(*report)); il->measurement_status |= MEASUREMENT_READY; } + EXPORT_SYMBOL(il_hdl_spectrum_measurement); /* * returns non-zero if packet should be dropped */ -int il_set_decrypted_flag(struct il_priv *il, - struct ieee80211_hdr *hdr, - u32 decrypt_res, - struct ieee80211_rx_status *stats) +int +il_set_decrypted_flag(struct il_priv *il, struct ieee80211_hdr *hdr, + u32 decrypt_res, struct ieee80211_rx_status *stats) { u16 fc = le16_to_cpu(hdr->frame_control); @@ -2527,8 +2527,7 @@ int il_set_decrypted_flag(struct il_priv *il, * All contexts have the same setting here due to it being * a module parameter, so OK to check any context. */ - if (il->ctx.active.filter_flags & - RXON_FILTER_DIS_DECRYPT_MSK) + if (il->ctx.active.filter_flags & RXON_FILTER_DIS_DECRYPT_MSK) return 0; if (!(fc & IEEE80211_FCTL_PROTECTED)) @@ -2564,6 +2563,7 @@ int il_set_decrypted_flag(struct il_priv *il, } return 0; } + EXPORT_SYMBOL(il_set_decrypted_flag); /** @@ -2586,16 +2586,14 @@ il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq) reg = _il_rd(il, CSR_UCODE_DRV_GP1); if (reg & CSR_UCODE_DRV_GP1_BIT_MAC_SLEEP) { - D_INFO( - "Tx queue %d requesting wakeup," - " GP1 = 0x%x\n", txq_id, reg); + D_INFO("Tx queue %d requesting wakeup," " GP1 = 0x%x\n", + txq_id, reg); il_set_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); + CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); return; } - il_wr(il, HBUS_TARG_WRPTR, - txq->q.write_ptr | (txq_id << 8)); + il_wr(il, HBUS_TARG_WRPTR, txq->q.write_ptr | (txq_id << 8)); /* * else not in power-save mode, @@ -2603,16 +2601,17 @@ il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq) * trying to tx (during RFKILL, we're not trying to tx). */ } else - _il_wr(il, HBUS_TARG_WRPTR, - txq->q.write_ptr | (txq_id << 8)); + _il_wr(il, HBUS_TARG_WRPTR, txq->q.write_ptr | (txq_id << 8)); txq->need_update = 0; } + EXPORT_SYMBOL(il_txq_update_write_ptr); /** * il_tx_queue_unmap - Unmap any remaining DMA mappings and free skb's */ -void il_tx_queue_unmap(struct il_priv *il, int txq_id) +void +il_tx_queue_unmap(struct il_priv *il, int txq_id) { struct il_tx_queue *txq = &il->txq[txq_id]; struct il_queue *q = &txq->q; @@ -2625,6 +2624,7 @@ void il_tx_queue_unmap(struct il_priv *il, int txq_id) q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); } } + EXPORT_SYMBOL(il_tx_queue_unmap); /** @@ -2635,7 +2635,8 @@ EXPORT_SYMBOL(il_tx_queue_unmap); * Free all buffers. * 0-fill, but do not free "txq" descriptor structure. */ -void il_tx_queue_free(struct il_priv *il, int txq_id) +void +il_tx_queue_free(struct il_priv *il, int txq_id) { struct il_tx_queue *txq = &il->txq[txq_id]; struct device *dev = &il->pci_dev->dev; @@ -2649,8 +2650,8 @@ void il_tx_queue_free(struct il_priv *il, int txq_id) /* De-alloc circular buffer of TFDs */ if (txq->q.n_bd) - dma_free_coherent(dev, il->hw_params.tfd_size * - txq->q.n_bd, txq->tfds, txq->q.dma_addr); + dma_free_coherent(dev, il->hw_params.tfd_size * txq->q.n_bd, + txq->tfds, txq->q.dma_addr); /* De-alloc array of per-TFD driver data */ kfree(txq->txb); @@ -2665,12 +2666,14 @@ void il_tx_queue_free(struct il_priv *il, int txq_id) /* 0-fill queue descriptor structure */ memset(txq, 0, sizeof(*txq)); } + EXPORT_SYMBOL(il_tx_queue_free); /** * il_cmd_queue_unmap - Unmap any remaining DMA mappings from command queue */ -void il_cmd_queue_unmap(struct il_priv *il) +void +il_cmd_queue_unmap(struct il_priv *il) { struct il_tx_queue *txq = &il->txq[il->cmd_queue]; struct il_queue *q = &txq->q; @@ -2702,6 +2705,7 @@ void il_cmd_queue_unmap(struct il_priv *il) txq->meta[i].flags = 0; } } + EXPORT_SYMBOL(il_cmd_queue_unmap); /** @@ -2712,7 +2716,8 @@ EXPORT_SYMBOL(il_cmd_queue_unmap); * Free all buffers. * 0-fill, but do not free "txq" descriptor structure. */ -void il_cmd_queue_free(struct il_priv *il) +void +il_cmd_queue_free(struct il_priv *il) { struct il_tx_queue *txq = &il->txq[il->cmd_queue]; struct device *dev = &il->pci_dev->dev; @@ -2738,6 +2743,7 @@ void il_cmd_queue_free(struct il_priv *il) /* 0-fill queue descriptor structure */ memset(txq, 0, sizeof(*txq)); } + EXPORT_SYMBOL(il_cmd_queue_free); /*************** DMA-QUEUE-GENERAL-FUNCTIONS ***** @@ -2763,7 +2769,8 @@ EXPORT_SYMBOL(il_cmd_queue_free); * See more detailed info in 4965.h. ***************************************************/ -int il_queue_space(const struct il_queue *q) +int +il_queue_space(const struct il_queue *q) { int s = q->read_ptr - q->write_ptr; @@ -2778,14 +2785,16 @@ int il_queue_space(const struct il_queue *q) s = 0; return s; } + EXPORT_SYMBOL(il_queue_space); /** * il_queue_init - Initialize queue's high/low-water and read/write idxes */ -static int il_queue_init(struct il_priv *il, struct il_queue *q, - int count, int slots_num, u32 id) +static int +il_queue_init(struct il_priv *il, struct il_queue *q, int count, int slots_num, + u32 id) { q->n_bd = count; q->n_win = slots_num; @@ -2815,8 +2824,8 @@ static int il_queue_init(struct il_priv *il, struct il_queue *q, /** * il_tx_queue_alloc - Alloc driver data and TFD CB for one Tx/cmd queue */ -static int il_tx_queue_alloc(struct il_priv *il, - struct il_tx_queue *txq, u32 id) +static int +il_tx_queue_alloc(struct il_priv *il, struct il_tx_queue *txq, u32 id) { struct device *dev = &il->pci_dev->dev; size_t tfd_sz = il->hw_params.tfd_size * TFD_QUEUE_SIZE_MAX; @@ -2824,11 +2833,12 @@ static int il_tx_queue_alloc(struct il_priv *il, /* Driver ilate data, only for Tx (not command) queues, * not shared with device. */ if (id != il->cmd_queue) { - txq->txb = kzalloc(sizeof(txq->txb[0]) * - TFD_QUEUE_SIZE_MAX, GFP_KERNEL); + txq->txb = + kzalloc(sizeof(txq->txb[0]) * TFD_QUEUE_SIZE_MAX, + GFP_KERNEL); if (!txq->txb) { IL_ERR("kmalloc for auxiliary BD " - "structures failed\n"); + "structures failed\n"); goto error; } } else { @@ -2837,8 +2847,8 @@ static int il_tx_queue_alloc(struct il_priv *il, /* Circular buffer of transmit frame descriptors (TFDs), * shared with device */ - txq->tfds = dma_alloc_coherent(dev, tfd_sz, &txq->q.dma_addr, - GFP_KERNEL); + txq->tfds = + dma_alloc_coherent(dev, tfd_sz, &txq->q.dma_addr, GFP_KERNEL); if (!txq->tfds) { IL_ERR("pci_alloc_consistent(%zd) failed\n", tfd_sz); goto error; @@ -2847,7 +2857,7 @@ static int il_tx_queue_alloc(struct il_priv *il, return 0; - error: +error: kfree(txq->txb); txq->txb = NULL; @@ -2857,8 +2867,9 @@ static int il_tx_queue_alloc(struct il_priv *il, /** * il_tx_queue_init - Allocate and initialize one tx/cmd queue */ -int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, - int slots_num, u32 txq_id) +int +il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num, + u32 txq_id) { int i, len; int ret; @@ -2875,10 +2886,10 @@ int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, if (txq_id == il->cmd_queue) actual_slots++; - txq->meta = kzalloc(sizeof(struct il_cmd_meta) * actual_slots, - GFP_KERNEL); - txq->cmd = kzalloc(sizeof(struct il_device_cmd *) * actual_slots, - GFP_KERNEL); + txq->meta = + kzalloc(sizeof(struct il_cmd_meta) * actual_slots, GFP_KERNEL); + txq->cmd = + kzalloc(sizeof(struct il_device_cmd *) * actual_slots, GFP_KERNEL); if (!txq->meta || !txq->cmd) goto out_free_arrays; @@ -2914,8 +2925,7 @@ int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); /* Initialize queue's high/low-water marks, and head/tail idxes */ - il_queue_init(il, &txq->q, - TFD_QUEUE_SIZE_MAX, slots_num, txq_id); + il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); /* Tell device where to find queue */ il->cfg->ops->lib->txq_init(il, txq); @@ -2930,10 +2940,12 @@ out_free_arrays: return -ENOMEM; } + EXPORT_SYMBOL(il_tx_queue_init); -void il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, - int slots_num, u32 txq_id) +void +il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, int slots_num, + u32 txq_id) { int actual_slots = slots_num; @@ -2945,12 +2957,12 @@ void il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, txq->need_update = 0; /* Initialize queue's high/low-water marks, and head/tail idxes */ - il_queue_init(il, &txq->q, - TFD_QUEUE_SIZE_MAX, slots_num, txq_id); + il_queue_init(il, &txq->q, TFD_QUEUE_SIZE_MAX, slots_num, txq_id); /* Tell device where to find queue */ il->cfg->ops->lib->txq_init(il, txq); } + EXPORT_SYMBOL(il_tx_queue_reset); /*************** HOST COMMAND QUEUE FUNCTIONS *****/ @@ -2964,7 +2976,8 @@ EXPORT_SYMBOL(il_tx_queue_reset); * failed. On success, it turns the idx (> 0) of command in the * command queue. */ -int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) +int +il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) { struct il_tx_queue *txq = &il->txq[il->cmd_queue]; struct il_queue *q = &txq->q; @@ -2977,7 +2990,7 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) u16 fix_size; cmd->len = il->cfg->ops->utils->get_hcmd_size(cmd->id, cmd->len); - fix_size = (u16)(cmd->len + sizeof(out_cmd->hdr)); + fix_size = (u16) (cmd->len + sizeof(out_cmd->hdr)); /* If any of the command structures end up being larger than * the TFD_MAX_PAYLOAD_SIZE, and it sent as a 'small' command then @@ -2990,7 +3003,7 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) if (il_is_rfkill(il) || il_is_ctkill(il)) { IL_WARN("Not sending command - %s KILL\n", - il_is_rfkill(il) ? "RF" : "CT"); + il_is_rfkill(il) ? "RF" : "CT"); return -EIO; } @@ -3027,8 +3040,8 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) * information */ out_cmd->hdr.flags = 0; - out_cmd->hdr.sequence = cpu_to_le16(QUEUE_TO_SEQ(il->cmd_queue) | - IDX_TO_SEQ(q->write_ptr)); + out_cmd->hdr.sequence = + cpu_to_le16(QUEUE_TO_SEQ(il->cmd_queue) | IDX_TO_SEQ(q->write_ptr)); if (cmd->flags & CMD_SIZE_HUGE) out_cmd->hdr.sequence |= SEQ_HUGE_FRAME; len = sizeof(struct il_device_cmd); @@ -3039,21 +3052,18 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) switch (out_cmd->hdr.cmd) { case C_TX_LINK_QUALITY_CMD: case C_SENSITIVITY: - D_HC_DUMP( - "Sending command %s (#%x), seq: 0x%04X, " - "%d bytes at %d[%d]:%d\n", - il_get_cmd_string(out_cmd->hdr.cmd), - out_cmd->hdr.cmd, - le16_to_cpu(out_cmd->hdr.sequence), fix_size, - q->write_ptr, idx, il->cmd_queue); + D_HC_DUMP("Sending command %s (#%x), seq: 0x%04X, " + "%d bytes at %d[%d]:%d\n", + il_get_cmd_string(out_cmd->hdr.cmd), out_cmd->hdr.cmd, + le16_to_cpu(out_cmd->hdr.sequence), fix_size, + q->write_ptr, idx, il->cmd_queue); break; default: D_HC("Sending command %s (#%x), seq: 0x%04X, " - "%d bytes at %d[%d]:%d\n", - il_get_cmd_string(out_cmd->hdr.cmd), - out_cmd->hdr.cmd, - le16_to_cpu(out_cmd->hdr.sequence), fix_size, - q->write_ptr, idx, il->cmd_queue); + "%d bytes at %d[%d]:%d\n", + il_get_cmd_string(out_cmd->hdr.cmd), out_cmd->hdr.cmd, + le16_to_cpu(out_cmd->hdr.sequence), fix_size, q->write_ptr, + idx, il->cmd_queue); } #endif txq->need_update = 1; @@ -3062,14 +3072,14 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) /* Set up entry in queue's byte count circular buffer */ il->cfg->ops->lib->txq_update_byte_cnt_tbl(il, txq, 0); - phys_addr = pci_map_single(il->pci_dev, &out_cmd->hdr, - fix_size, PCI_DMA_BIDIRECTIONAL); + phys_addr = + pci_map_single(il->pci_dev, &out_cmd->hdr, fix_size, + PCI_DMA_BIDIRECTIONAL); dma_unmap_addr_set(out_meta, mapping, phys_addr); dma_unmap_len_set(out_meta, len, fix_size); - il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, - phys_addr, fix_size, 1, - U32_PAD(cmd->len)); + il->cfg->ops->lib->txq_attach_buf_to_tfd(il, txq, phys_addr, fix_size, + 1, U32_PAD(cmd->len)); /* Increment and update queue's write idx */ q->write_ptr = il_queue_inc_wrap(q->write_ptr, q->n_bd); @@ -3086,8 +3096,8 @@ int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd) * need to be reclaimed. As result, some free space forms. If there is * enough free space (> low mark), wake the stack that feeds us. */ -static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, - int idx, int cmd_idx) +static void +il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, int idx, int cmd_idx) { struct il_tx_queue *txq = &il->txq[txq_id]; struct il_queue *q = &txq->q; @@ -3095,8 +3105,8 @@ static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, if (idx >= q->n_bd || il_queue_used(q, idx) == 0) { IL_ERR("Read idx for DMA queue txq id (%d), idx %d, " - "is out of range [0-%d] %d %d.\n", txq_id, - idx, q->n_bd, q->write_ptr, q->read_ptr); + "is out of range [0-%d] %d %d.\n", txq_id, idx, q->n_bd, + q->write_ptr, q->read_ptr); return; } @@ -3105,7 +3115,7 @@ static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id, if (nfreed++ > 0) { IL_ERR("HCMD skipped: idx (%d) %d %d\n", idx, - q->write_ptr, q->read_ptr); + q->write_ptr, q->read_ptr); queue_work(il->workqueue, &il->restart); } @@ -3137,11 +3147,11 @@ il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb) /* If a Tx command is being handled and it isn't in the actual * command queue then there a command routing bug has been introduced * in the queue management code. */ - if (WARN(txq_id != il->cmd_queue, - "wrong command queue %d (should be %d), sequence 0x%X readp=%d writep=%d\n", - txq_id, il->cmd_queue, sequence, - il->txq[il->cmd_queue].q.read_ptr, - il->txq[il->cmd_queue].q.write_ptr)) { + if (WARN + (txq_id != il->cmd_queue, + "wrong command queue %d (should be %d), sequence 0x%X readp=%d writep=%d\n", + txq_id, il->cmd_queue, sequence, il->txq[il->cmd_queue].q.read_ptr, + il->txq[il->cmd_queue].q.write_ptr)) { il_print_hex_error(il, pkt, 32); return; } @@ -3152,10 +3162,8 @@ il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb) txq->time_stamp = jiffies; - pci_unmap_single(il->pci_dev, - dma_unmap_addr(meta, mapping), - dma_unmap_len(meta, len), - PCI_DMA_BIDIRECTIONAL); + pci_unmap_single(il->pci_dev, dma_unmap_addr(meta, mapping), + dma_unmap_len(meta, len), PCI_DMA_BIDIRECTIONAL); /* Input error checking is done when commands are added to queue. */ if (meta->flags & CMD_WANT_SKB) { @@ -3171,7 +3179,7 @@ il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb) if (!(meta->flags & CMD_ASYNC)) { clear_bit(S_HCMD_ACTIVE, &il->status); D_INFO("Clearing HCMD_ACTIVE for command %s\n", - il_get_cmd_string(cmd->hdr.cmd)); + il_get_cmd_string(cmd->hdr.cmd)); wake_up(&il->wait_command_queue); } @@ -3211,11 +3219,12 @@ u32 il_debug_level; EXPORT_SYMBOL(il_debug_level); const u8 il_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; -EXPORT_SYMBOL(il_bcast_addr); +EXPORT_SYMBOL(il_bcast_addr); /* This function both allocates and initializes hw and il. */ -struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg) +struct ieee80211_hw * +il_alloc_all(struct il_cfg *cfg) { struct il_priv *il; /* mac80211 allocates memory for this device instance, including @@ -3225,8 +3234,7 @@ struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg) hw = ieee80211_alloc_hw(sizeof(struct il_priv), cfg->ops->ieee80211_ops); if (hw == NULL) { - pr_err("%s: Can not allocate network device\n", - cfg->name); + pr_err("%s: Can not allocate network device\n", cfg->name); goto out; } @@ -3236,13 +3244,15 @@ struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg) out: return hw; } + EXPORT_SYMBOL(il_alloc_all); -#define MAX_BIT_RATE_40_MHZ 150 /* Mbps */ -#define MAX_BIT_RATE_20_MHZ 72 /* Mbps */ -static void il_init_ht_hw_capab(const struct il_priv *il, - struct ieee80211_sta_ht_cap *ht_info, - enum ieee80211_band band) +#define MAX_BIT_RATE_40_MHZ 150 /* Mbps */ +#define MAX_BIT_RATE_20_MHZ 72 /* Mbps */ +static void +il_init_ht_hw_capab(const struct il_priv *il, + struct ieee80211_sta_ht_cap *ht_info, + enum ieee80211_band band) { u16 max_bit_rate = 0; u8 rx_chains_num = il->hw_params.rx_chains_num; @@ -3283,15 +3293,17 @@ static void il_init_ht_hw_capab(const struct il_priv *il, ht_info->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; if (tx_chains_num != rx_chains_num) { ht_info->mcs.tx_params |= IEEE80211_HT_MCS_TX_RX_DIFF; - ht_info->mcs.tx_params |= ((tx_chains_num - 1) << - IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT); + ht_info->mcs.tx_params |= + ((tx_chains_num - + 1) << IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT); } } /** * il_init_geos - Initialize mac80211's geo/channel info based from eeprom */ -int il_init_geos(struct il_priv *il) +int +il_init_geos(struct il_priv *il) { struct il_channel_info *ch; struct ieee80211_supported_band *sband; @@ -3308,13 +3320,15 @@ int il_init_geos(struct il_priv *il) return 0; } - channels = kzalloc(sizeof(struct ieee80211_channel) * - il->channel_count, GFP_KERNEL); + channels = + kzalloc(sizeof(struct ieee80211_channel) * il->channel_count, + GFP_KERNEL); if (!channels) return -ENOMEM; - rates = kzalloc((sizeof(struct ieee80211_rate) * RATE_COUNT_LEGACY), - GFP_KERNEL); + rates = + kzalloc((sizeof(struct ieee80211_rate) * RATE_COUNT_LEGACY), + GFP_KERNEL); if (!rates) { kfree(channels); return -ENOMEM; @@ -3328,8 +3342,7 @@ int il_init_geos(struct il_priv *il) sband->n_bitrates = RATE_COUNT_LEGACY - IL_FIRST_OFDM_RATE; if (il->cfg->sku & IL_SKU_N) - il_init_ht_hw_capab(il, &sband->ht_cap, - IEEE80211_BAND_5GHZ); + il_init_ht_hw_capab(il, &sband->ht_cap, IEEE80211_BAND_5GHZ); sband = &il->bands[IEEE80211_BAND_2GHZ]; sband->channels = channels; @@ -3338,13 +3351,12 @@ int il_init_geos(struct il_priv *il) sband->n_bitrates = RATE_COUNT_LEGACY; if (il->cfg->sku & IL_SKU_N) - il_init_ht_hw_capab(il, &sband->ht_cap, - IEEE80211_BAND_2GHZ); + il_init_ht_hw_capab(il, &sband->ht_cap, IEEE80211_BAND_2GHZ); il->ieee_channels = channels; il->ieee_rates = rates; - for (i = 0; i < il->channel_count; i++) { + for (i = 0; i < il->channel_count; i++) { ch = &il->channel_info[i]; if (!il_is_channel_valid(ch)) @@ -3355,7 +3367,7 @@ int il_init_geos(struct il_priv *il) geo_ch = &sband->channels[sband->n_channels++]; geo_ch->center_freq = - ieee80211_channel_to_frequency(ch->channel, ch->band); + ieee80211_channel_to_frequency(ch->channel, ch->band); geo_ch->max_power = ch->max_power_avg; geo_ch->max_antenna_gain = 0xff; geo_ch->hw_value = ch->channel; @@ -3378,12 +3390,12 @@ int il_init_geos(struct il_priv *il) geo_ch->flags |= IEEE80211_CHAN_DISABLED; } - D_INFO("Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", - ch->channel, geo_ch->center_freq, - il_is_channel_a_band(ch) ? "5.2" : "2.4", - geo_ch->flags & IEEE80211_CHAN_DISABLED ? - "restricted" : "valid", - geo_ch->flags); + D_INFO("Channel %d Freq=%d[%sGHz] %s flag=0x%X\n", ch->channel, + geo_ch->center_freq, + il_is_channel_a_band(ch) ? "5.2" : "2.4", + geo_ch-> + flags & IEEE80211_CHAN_DISABLED ? "restricted" : "valid", + geo_ch->flags); } il->tx_power_device_lmt = max_tx_power; @@ -3394,35 +3406,37 @@ int il_init_geos(struct il_priv *il) (il->cfg->sku & IL_SKU_A)) { IL_INFO("Incorrectly detected BG card as ABG. " "Please send your PCI ID 0x%04X:0x%04X to maintainer.\n", - il->pci_dev->device, - il->pci_dev->subsystem_device); + il->pci_dev->device, il->pci_dev->subsystem_device); il->cfg->sku &= ~IL_SKU_A; } IL_INFO("Tunable channels: %d 802.11bg, %d 802.11a channels\n", - il->bands[IEEE80211_BAND_2GHZ].n_channels, - il->bands[IEEE80211_BAND_5GHZ].n_channels); + il->bands[IEEE80211_BAND_2GHZ].n_channels, + il->bands[IEEE80211_BAND_5GHZ].n_channels); set_bit(S_GEO_CONFIGURED, &il->status); return 0; } + EXPORT_SYMBOL(il_init_geos); /* * il_free_geos - undo allocations in il_init_geos */ -void il_free_geos(struct il_priv *il) +void +il_free_geos(struct il_priv *il) { kfree(il->ieee_channels); kfree(il->ieee_rates); clear_bit(S_GEO_CONFIGURED, &il->status); } + EXPORT_SYMBOL(il_free_geos); -static bool il_is_channel_extension(struct il_priv *il, - enum ieee80211_band band, - u16 channel, u8 extension_chan_offset) +static bool +il_is_channel_extension(struct il_priv *il, enum ieee80211_band band, + u16 channel, u8 extension_chan_offset) { const struct il_channel_info *ch_info; @@ -3431,18 +3445,18 @@ static bool il_is_channel_extension(struct il_priv *il, return false; if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_ABOVE) - return !(ch_info->ht40_extension_channel & - IEEE80211_CHAN_NO_HT40PLUS); + return !(ch_info-> + ht40_extension_channel & IEEE80211_CHAN_NO_HT40PLUS); else if (extension_chan_offset == IEEE80211_HT_PARAM_CHA_SEC_BELOW) - return !(ch_info->ht40_extension_channel & - IEEE80211_CHAN_NO_HT40MINUS); + return !(ch_info-> + ht40_extension_channel & IEEE80211_CHAN_NO_HT40MINUS); return false; } -bool il_is_ht40_tx_allowed(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_sta_ht_cap *ht_cap) +bool +il_is_ht40_tx_allowed(struct il_priv * il, struct il_rxon_context * ctx, + struct ieee80211_sta_ht_cap * ht_cap) { if (!ctx->ht.enabled || !ctx->ht.is_40mhz) return false; @@ -3460,12 +3474,14 @@ bool il_is_ht40_tx_allowed(struct il_priv *il, #endif return il_is_channel_extension(il, il->band, - le16_to_cpu(ctx->staging.channel), - ctx->ht.extension_chan_offset); + le16_to_cpu(ctx->staging.channel), + ctx->ht.extension_chan_offset); } + EXPORT_SYMBOL(il_is_ht40_tx_allowed); -static u16 il_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val) +static u16 +il_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val) { u16 new_val; u16 beacon_factor; @@ -3520,36 +3536,37 @@ il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx) /* * TODO: For IBSS we need to get atim_win from mac80211, - * for now just always use 0 + * for now just always use 0 */ ctx->timing.atim_win = 0; - beacon_int = il_adjust_beacon_interval(beacon_int, - il->hw_params.max_beacon_itrvl * TIME_UNIT); + beacon_int = + il_adjust_beacon_interval(beacon_int, + il->hw_params.max_beacon_itrvl * + TIME_UNIT); ctx->timing.beacon_interval = cpu_to_le16(beacon_int); - tsf = il->timestamp; /* tsf is modifed by do_div: copy it */ + tsf = il->timestamp; /* tsf is modifed by do_div: copy it */ interval_tm = beacon_int * TIME_UNIT; rem = do_div(tsf, interval_tm); ctx->timing.beacon_init_val = cpu_to_le32(interval_tm - rem); - ctx->timing.dtim_period = vif ? (vif->bss_conf.dtim_period ?: 1) : 1; + ctx->timing.dtim_period = vif ? (vif->bss_conf.dtim_period ? : 1) : 1; - D_ASSOC( - "beacon interval %d beacon timer %d beacon tim %d\n", - le16_to_cpu(ctx->timing.beacon_interval), - le32_to_cpu(ctx->timing.beacon_init_val), - le16_to_cpu(ctx->timing.atim_win)); + D_ASSOC("beacon interval %d beacon timer %d beacon tim %d\n", + le16_to_cpu(ctx->timing.beacon_interval), + le32_to_cpu(ctx->timing.beacon_init_val), + le16_to_cpu(ctx->timing.atim_win)); - return il_send_cmd_pdu(il, ctx->rxon_timing_cmd, - sizeof(ctx->timing), &ctx->timing); + return il_send_cmd_pdu(il, ctx->rxon_timing_cmd, sizeof(ctx->timing), + &ctx->timing); } + EXPORT_SYMBOL(il_send_rxon_timing); void -il_set_rxon_hwcrypto(struct il_priv *il, - struct il_rxon_context *ctx, - int hw_decrypt) +il_set_rxon_hwcrypto(struct il_priv *il, struct il_rxon_context *ctx, + int hw_decrypt) { struct il_rxon_cmd *rxon = &ctx->staging; @@ -3559,6 +3576,7 @@ il_set_rxon_hwcrypto(struct il_priv *il, rxon->filter_flags |= RXON_FILTER_DIS_DECRYPT_MSK; } + EXPORT_SYMBOL(il_set_rxon_hwcrypto); /* validate RXON structure is valid */ @@ -3604,28 +3622,27 @@ il_check_rxon_cmd(struct il_priv *il, struct il_rxon_context *ctx) error = true; } - if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) - == (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) { + if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) == + (RXON_FLG_CCK_MSK | RXON_FLG_SHORT_SLOT_MSK)) { IL_WARN("CCK and short slot\n"); error = true; } - if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) - == (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) { + if ((rxon->flags & (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) == + (RXON_FLG_CCK_MSK | RXON_FLG_AUTO_DETECT_MSK)) { IL_WARN("CCK and auto detect"); error = true; } - if ((rxon->flags & (RXON_FLG_AUTO_DETECT_MSK | - RXON_FLG_TGG_PROTECT_MSK)) == - RXON_FLG_TGG_PROTECT_MSK) { + if ((rxon-> + flags & (RXON_FLG_AUTO_DETECT_MSK | RXON_FLG_TGG_PROTECT_MSK)) == + RXON_FLG_TGG_PROTECT_MSK) { IL_WARN("TGg but no auto-detect\n"); error = true; } if (error) - IL_WARN("Tuning to channel %d\n", - le16_to_cpu(rxon->channel)); + IL_WARN("Tuning to channel %d\n", le16_to_cpu(rxon->channel)); if (error) { IL_ERR("Invalid RXON\n"); @@ -3633,6 +3650,7 @@ il_check_rxon_cmd(struct il_priv *il, struct il_rxon_context *ctx) } return 0; } + EXPORT_SYMBOL(il_check_rxon_cmd); /** @@ -3643,8 +3661,8 @@ EXPORT_SYMBOL(il_check_rxon_cmd); * or is clearing the RXON_FILTER_ASSOC_MSK, then return 1 to indicate that * a new tune (full RXON command, rather than RXON_ASSOC cmd) is required. */ -int il_full_rxon_required(struct il_priv *il, - struct il_rxon_context *ctx) +int +il_full_rxon_required(struct il_priv *il, struct il_rxon_context *ctx) { const struct il_rxon_cmd *staging = &ctx->staging; const struct il_rxon_cmd *active = &ctx->active; @@ -3667,8 +3685,8 @@ int il_full_rxon_required(struct il_priv *il, CHK(!il_is_associated_ctx(ctx)); CHK(compare_ether_addr(staging->bssid_addr, active->bssid_addr)); CHK(compare_ether_addr(staging->node_addr, active->node_addr)); - CHK(compare_ether_addr(staging->wlap_bssid_addr, - active->wlap_bssid_addr)); + CHK(compare_ether_addr + (staging->wlap_bssid_addr, active->wlap_bssid_addr)); CHK_NEQ(staging->dev_type, active->dev_type); CHK_NEQ(staging->channel, active->channel); CHK_NEQ(staging->air_propagation, active->air_propagation); @@ -3695,10 +3713,11 @@ int il_full_rxon_required(struct il_priv *il, return 0; } + EXPORT_SYMBOL(il_full_rxon_required); -u8 il_get_lowest_plcp(struct il_priv *il, - struct il_rxon_context *ctx) +u8 +il_get_lowest_plcp(struct il_priv * il, struct il_rxon_context * ctx) { /* * Assign the lowest rate -- should really get this from @@ -3709,44 +3728,43 @@ u8 il_get_lowest_plcp(struct il_priv *il, else return RATE_6M_PLCP; } + EXPORT_SYMBOL(il_get_lowest_plcp); -static void _il_set_rxon_ht(struct il_priv *il, - struct il_ht_config *ht_conf, - struct il_rxon_context *ctx) +static void +_il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf, + struct il_rxon_context *ctx) { struct il_rxon_cmd *rxon = &ctx->staging; if (!ctx->ht.enabled) { - rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | - RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK | - RXON_FLG_HT40_PROT_MSK | - RXON_FLG_HT_PROT_MSK); + rxon->flags &= + ~(RXON_FLG_CHANNEL_MODE_MSK | + RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK | RXON_FLG_HT40_PROT_MSK + | RXON_FLG_HT_PROT_MSK); return; } - rxon->flags |= cpu_to_le32(ctx->ht.protection << - RXON_FLG_HT_OPERATING_MODE_POS); + rxon->flags |= + cpu_to_le32(ctx->ht.protection << RXON_FLG_HT_OPERATING_MODE_POS); /* Set up channel bandwidth: * 20 MHz only, 20/40 mixed or pure 40 if ht40 ok */ /* clear the HT channel mode before set the mode */ - rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | - RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); + rxon->flags &= + ~(RXON_FLG_CHANNEL_MODE_MSK | RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); if (il_is_ht40_tx_allowed(il, ctx, NULL)) { /* pure ht40 */ - if (ctx->ht.protection == - IEEE80211_HT_OP_MODE_PROTECTION_20MHZ) { + if (ctx->ht.protection == IEEE80211_HT_OP_MODE_PROTECTION_20MHZ) { rxon->flags |= RXON_FLG_CHANNEL_MODE_PURE_40; /* Note: control channel is opposite of extension channel */ switch (ctx->ht.extension_chan_offset) { case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: rxon->flags &= - ~RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; + ~RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; break; case IEEE80211_HT_PARAM_CHA_SEC_BELOW: - rxon->flags |= - RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; + rxon->flags |= RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; break; } } else { @@ -3754,19 +3772,17 @@ static void _il_set_rxon_ht(struct il_priv *il, switch (ctx->ht.extension_chan_offset) { case IEEE80211_HT_PARAM_CHA_SEC_ABOVE: rxon->flags &= - ~(RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); + ~(RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK); rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED; break; case IEEE80211_HT_PARAM_CHA_SEC_BELOW: - rxon->flags |= - RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; + rxon->flags |= RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK; rxon->flags |= RXON_FLG_CHANNEL_MODE_MIXED; break; case IEEE80211_HT_PARAM_CHA_SEC_NONE: default: /* channel location only valid if in Mixed mode */ - IL_ERR( - "invalid extension channel offset\n"); + IL_ERR("invalid extension channel offset\n"); break; } } @@ -3778,20 +3794,21 @@ static void _il_set_rxon_ht(struct il_priv *il, il->cfg->ops->hcmd->set_rxon_chain(il, ctx); D_ASSOC("rxon flags 0x%X operation mode :0x%X " - "extension channel offset 0x%x\n", - le32_to_cpu(rxon->flags), ctx->ht.protection, - ctx->ht.extension_chan_offset); + "extension channel offset 0x%x\n", le32_to_cpu(rxon->flags), + ctx->ht.protection, ctx->ht.extension_chan_offset); } -void il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf) +void +il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf) { _il_set_rxon_ht(il, ht_conf, &il->ctx); } + EXPORT_SYMBOL(il_set_rxon_ht); /* Return valid, unused, channel for a passive scan to reset the RF */ -u8 il_get_single_channel_number(struct il_priv *il, - enum ieee80211_band band) +u8 +il_get_single_channel_number(struct il_priv *il, enum ieee80211_band band) { const struct il_channel_info *ch_info; int i; @@ -3818,6 +3835,7 @@ u8 il_get_single_channel_number(struct il_priv *il, return channel; } + EXPORT_SYMBOL(il_get_single_channel_number); /** @@ -3829,7 +3847,7 @@ EXPORT_SYMBOL(il_get_single_channel_number); */ int il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch, - struct il_rxon_context *ctx) + struct il_rxon_context *ctx) { enum ieee80211_band band = ch->band; u16 channel = ch->hw_value; @@ -3849,17 +3867,17 @@ il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch, return 0; } + EXPORT_SYMBOL(il_set_rxon_channel); -void il_set_flags_for_band(struct il_priv *il, - struct il_rxon_context *ctx, - enum ieee80211_band band, - struct ieee80211_vif *vif) +void +il_set_flags_for_band(struct il_priv *il, struct il_rxon_context *ctx, + enum ieee80211_band band, struct ieee80211_vif *vif) { if (band == IEEE80211_BAND_5GHZ) { ctx->staging.flags &= - ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK - | RXON_FLG_CCK_MSK); + ~(RXON_FLG_BAND_24G_MSK | RXON_FLG_AUTO_DETECT_MSK | + RXON_FLG_CCK_MSK); ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; } else { /* Copied from il_post_associate() */ @@ -3873,13 +3891,14 @@ void il_set_flags_for_band(struct il_priv *il, ctx->staging.flags &= ~RXON_FLG_CCK_MSK; } } + EXPORT_SYMBOL(il_set_flags_for_band); /* * initialize rxon structure with default values from eeprom */ -void il_connection_init_rx_config(struct il_priv *il, - struct il_rxon_context *ctx) +void +il_connection_init_rx_config(struct il_priv *il, struct il_rxon_context *ctx) { const struct il_channel_info *ch_info; @@ -3888,25 +3907,26 @@ void il_connection_init_rx_config(struct il_priv *il, if (!ctx->vif) { ctx->staging.dev_type = ctx->unused_devtype; } else - switch (ctx->vif->type) { + switch (ctx->vif->type) { - case NL80211_IFTYPE_STATION: - ctx->staging.dev_type = ctx->station_devtype; - ctx->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK; - break; + case NL80211_IFTYPE_STATION: + ctx->staging.dev_type = ctx->station_devtype; + ctx->staging.filter_flags = RXON_FILTER_ACCEPT_GRP_MSK; + break; - case NL80211_IFTYPE_ADHOC: - ctx->staging.dev_type = ctx->ibss_devtype; - ctx->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK; - ctx->staging.filter_flags = RXON_FILTER_BCON_AWARE_MSK | - RXON_FILTER_ACCEPT_GRP_MSK; - break; + case NL80211_IFTYPE_ADHOC: + ctx->staging.dev_type = ctx->ibss_devtype; + ctx->staging.flags = RXON_FLG_SHORT_PREAMBLE_MSK; + ctx->staging.filter_flags = + RXON_FILTER_BCON_AWARE_MSK | + RXON_FILTER_ACCEPT_GRP_MSK; + break; - default: - IL_ERR("Unsupported interface type %d\n", - ctx->vif->type); - break; - } + default: + IL_ERR("Unsupported interface type %d\n", + ctx->vif->type); + break; + } #if 0 /* TODO: Figure out when short_preamble would be set and cache from @@ -3917,8 +3937,8 @@ void il_connection_init_rx_config(struct il_priv *il, ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; #endif - ch_info = il_get_channel_info(il, il->band, - le16_to_cpu(ctx->active.channel)); + ch_info = + il_get_channel_info(il, il->band, le16_to_cpu(ctx->active.channel)); if (!ch_info) ch_info = &il->channel_info[0]; @@ -3934,17 +3954,19 @@ void il_connection_init_rx_config(struct il_priv *il, (IL_CCK_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; /* clear both MIX and PURE40 mode flag */ - ctx->staging.flags &= ~(RXON_FLG_CHANNEL_MODE_MIXED | - RXON_FLG_CHANNEL_MODE_PURE_40); + ctx->staging.flags &= + ~(RXON_FLG_CHANNEL_MODE_MIXED | RXON_FLG_CHANNEL_MODE_PURE_40); if (ctx->vif) memcpy(ctx->staging.node_addr, ctx->vif->addr, ETH_ALEN); ctx->staging.ofdm_ht_single_stream_basic_rates = 0xff; ctx->staging.ofdm_ht_dual_stream_basic_rates = 0xff; } + EXPORT_SYMBOL(il_connection_init_rx_config); -void il_set_rate(struct il_priv *il) +void +il_set_rate(struct il_priv *il) { const struct ieee80211_supported_band *hw = NULL; struct ieee80211_rate *rate; @@ -3967,14 +3989,16 @@ void il_set_rate(struct il_priv *il) D_RATE("Set active_rate = %0x\n", il->active_rate); il->ctx.staging.cck_basic_rates = - (IL_CCK_BASIC_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; + (IL_CCK_BASIC_RATES_MASK >> IL_FIRST_CCK_RATE) & 0xF; il->ctx.staging.ofdm_basic_rates = - (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; + (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; } + EXPORT_SYMBOL(il_set_rate); -void il_chswitch_done(struct il_priv *il, bool is_success) +void +il_chswitch_done(struct il_priv *il, bool is_success) { struct il_rxon_context *ctx = &il->ctx; @@ -3984,9 +4008,11 @@ void il_chswitch_done(struct il_priv *il, bool is_success) if (test_and_clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) ieee80211_chswitch_done(ctx->vif, is_success); } + EXPORT_SYMBOL(il_chswitch_done); -void il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb) +void +il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_csa_notification *csa = &(pkt->u.csa_notif); @@ -4000,46 +4026,43 @@ void il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb) if (!le32_to_cpu(csa->status) && csa->channel == il->switch_channel) { rxon->channel = csa->channel; ctx->staging.channel = csa->channel; - D_11H("CSA notif: channel %d\n", - le16_to_cpu(csa->channel)); + D_11H("CSA notif: channel %d\n", le16_to_cpu(csa->channel)); il_chswitch_done(il, true); } else { IL_ERR("CSA notif (fail) : channel %d\n", - le16_to_cpu(csa->channel)); + le16_to_cpu(csa->channel)); il_chswitch_done(il, false); } } + EXPORT_SYMBOL(il_hdl_csa); #ifdef CONFIG_IWLEGACY_DEBUG -void il_print_rx_config_cmd(struct il_priv *il, - struct il_rxon_context *ctx) +void +il_print_rx_config_cmd(struct il_priv *il, struct il_rxon_context *ctx) { struct il_rxon_cmd *rxon = &ctx->staging; D_RADIO("RX CONFIG:\n"); il_print_hex_dump(il, IL_DL_RADIO, (u8 *) rxon, sizeof(*rxon)); - D_RADIO("u16 channel: 0x%x\n", - le16_to_cpu(rxon->channel)); + D_RADIO("u16 channel: 0x%x\n", le16_to_cpu(rxon->channel)); D_RADIO("u32 flags: 0x%08X\n", le32_to_cpu(rxon->flags)); - D_RADIO("u32 filter_flags: 0x%08x\n", - le32_to_cpu(rxon->filter_flags)); + D_RADIO("u32 filter_flags: 0x%08x\n", le32_to_cpu(rxon->filter_flags)); D_RADIO("u8 dev_type: 0x%x\n", rxon->dev_type); - D_RADIO("u8 ofdm_basic_rates: 0x%02x\n", - rxon->ofdm_basic_rates); - D_RADIO("u8 cck_basic_rates: 0x%02x\n", - rxon->cck_basic_rates); + D_RADIO("u8 ofdm_basic_rates: 0x%02x\n", rxon->ofdm_basic_rates); + D_RADIO("u8 cck_basic_rates: 0x%02x\n", rxon->cck_basic_rates); D_RADIO("u8[6] node_addr: %pM\n", rxon->node_addr); D_RADIO("u8[6] bssid_addr: %pM\n", rxon->bssid_addr); - D_RADIO("u16 assoc_id: 0x%x\n", - le16_to_cpu(rxon->assoc_id)); + D_RADIO("u16 assoc_id: 0x%x\n", le16_to_cpu(rxon->assoc_id)); } + EXPORT_SYMBOL(il_print_rx_config_cmd); #endif /** * il_irq_handle_error - called for HW or SW error interrupt from card */ -void il_irq_handle_error(struct il_priv *il) +void +il_irq_handle_error(struct il_priv *il) { /* Set the FW error flag -- cleared on il_down */ set_bit(S_FW_ERROR, &il->status); @@ -4047,16 +4070,14 @@ void il_irq_handle_error(struct il_priv *il) /* Cancel currently queued command. */ clear_bit(S_HCMD_ACTIVE, &il->status); - IL_ERR("Loaded firmware version: %s\n", - il->hw->wiphy->fw_version); + IL_ERR("Loaded firmware version: %s\n", il->hw->wiphy->fw_version); il->cfg->ops->lib->dump_nic_error_log(il); if (il->cfg->ops->lib->dump_fh) il->cfg->ops->lib->dump_fh(il, NULL, false); #ifdef CONFIG_IWLEGACY_DEBUG if (il_get_debug_level(il) & IL_DL_FW_ERRORS) - il_print_rx_config_cmd(il, - &il->ctx); + il_print_rx_config_cmd(il, &il->ctx); #endif wake_up(&il->wait_command_queue); @@ -4067,23 +4088,26 @@ void il_irq_handle_error(struct il_priv *il) if (!test_bit(S_EXIT_PENDING, &il->status)) { IL_DBG(IL_DL_FW_ERRORS, - "Restarting adapter due to uCode error.\n"); + "Restarting adapter due to uCode error.\n"); if (il->cfg->mod_params->restart_fw) queue_work(il->workqueue, &il->restart); } } + EXPORT_SYMBOL(il_irq_handle_error); -static int il_apm_stop_master(struct il_priv *il) +static int +il_apm_stop_master(struct il_priv *il) { int ret = 0; /* stop device's busmaster DMA activity */ il_set_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_STOP_MASTER); - ret = _il_poll_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, - CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); + ret = + _il_poll_bit(il, CSR_RESET, CSR_RESET_REG_FLAG_MASTER_DISABLED, + CSR_RESET_REG_FLAG_MASTER_DISABLED, 100); if (ret) IL_WARN("Master Disable Timed Out, 100 usec\n"); @@ -4092,7 +4116,8 @@ static int il_apm_stop_master(struct il_priv *il) return ret; } -void il_apm_stop(struct il_priv *il) +void +il_apm_stop(struct il_priv *il) { D_INFO("Stop card, put in low power state\n"); @@ -4108,18 +4133,18 @@ void il_apm_stop(struct il_priv *il) * Clear "initialization complete" bit to move adapter from * D0A* (powered-up Active) --> D0U* (Uninitialized) state. */ - il_clear_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_INIT_DONE); + il_clear_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); } -EXPORT_SYMBOL(il_apm_stop); +EXPORT_SYMBOL(il_apm_stop); /* * Start up NIC's basic functionality after it has been reset * (e.g. after platform boot, or shutdown via il_apm_stop()) * NOTE: This does not load uCode nor start the embedded processor */ -int il_apm_init(struct il_priv *il) +int +il_apm_init(struct il_priv *il) { int ret = 0; u16 lctl; @@ -4133,18 +4158,17 @@ int il_apm_init(struct il_priv *il) /* Disable L0S exit timer (platform NMI Work/Around) */ il_set_bit(il, CSR_GIO_CHICKEN_BITS, - CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); + CSR_GIO_CHICKEN_BITS_REG_BIT_DIS_L0S_EXIT_TIMER); /* * Disable L0s without affecting L1; * don't wait for ICH L0s (ICH bug W/A) */ il_set_bit(il, CSR_GIO_CHICKEN_BITS, - CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX); + CSR_GIO_CHICKEN_BITS_REG_BIT_L1A_NO_L0S_RX); /* Set FH wait threshold to maximum (HW error during stress W/A) */ - il_set_bit(il, CSR_DBG_HPET_MEM_REG, - CSR_DBG_HPET_MEM_REG_VAL); + il_set_bit(il, CSR_DBG_HPET_MEM_REG, CSR_DBG_HPET_MEM_REG_VAL); /* * Enable HAP INTA (interrupt from management bus) to @@ -4152,7 +4176,7 @@ int il_apm_init(struct il_priv *il) * NOTE: This is no-op for 3945 (non-existent bit) */ il_set_bit(il, CSR_HW_IF_CONFIG_REG, - CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); + CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); /* * HW bug W/A for instability in PCIe bus L0->L0S->L1 transition. @@ -4165,15 +4189,15 @@ int il_apm_init(struct il_priv *il) if (il->cfg->base_params->set_l0s) { lctl = il_pcie_link_ctl(il); if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) == - PCI_CFG_LINK_CTRL_VAL_L1_EN) { + PCI_CFG_LINK_CTRL_VAL_L1_EN) { /* L1-ASPM enabled; disable(!) L0S */ il_set_bit(il, CSR_GIO_REG, - CSR_GIO_REG_VAL_L0S_ENABLED); + CSR_GIO_REG_VAL_L0S_ENABLED); D_POWER("L1 Enabled; Disabling L0S\n"); } else { /* L1-ASPM disabled; enable(!) L0S */ il_clear_bit(il, CSR_GIO_REG, - CSR_GIO_REG_VAL_L0S_ENABLED); + CSR_GIO_REG_VAL_L0S_ENABLED); D_POWER("L1 Disabled; Enabling L0S\n"); } } @@ -4181,7 +4205,7 @@ int il_apm_init(struct il_priv *il) /* Configure analog phase-lock-loop before activating to D0A */ if (il->cfg->base_params->pll_cfg_val) il_set_bit(il, CSR_ANA_PLL_CFG, - il->cfg->base_params->pll_cfg_val); + il->cfg->base_params->pll_cfg_val); /* * Set "initialization complete" bit to move adapter from @@ -4194,9 +4218,10 @@ int il_apm_init(struct il_priv *il) * device-internal resources is supported, e.g. il_wr_prph() * and accesses to uCode SRAM. */ - ret = _il_poll_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, - CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); + ret = + _il_poll_bit(il, CSR_GP_CNTRL, + CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, + CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); if (ret < 0) { D_INFO("Failed to init the card\n"); goto out; @@ -4212,23 +4237,23 @@ int il_apm_init(struct il_priv *il) */ if (il->cfg->base_params->use_bsm) il_wr_prph(il, APMG_CLK_EN_REG, - APMG_CLK_VAL_DMA_CLK_RQT | APMG_CLK_VAL_BSM_CLK_RQT); + APMG_CLK_VAL_DMA_CLK_RQT | APMG_CLK_VAL_BSM_CLK_RQT); else - il_wr_prph(il, APMG_CLK_EN_REG, - APMG_CLK_VAL_DMA_CLK_RQT); + il_wr_prph(il, APMG_CLK_EN_REG, APMG_CLK_VAL_DMA_CLK_RQT); udelay(20); /* Disable L1-Active */ il_set_bits_prph(il, APMG_PCIDEV_STT_REG, - APMG_PCIDEV_STT_VAL_L1_ACT_DIS); + APMG_PCIDEV_STT_VAL_L1_ACT_DIS); out: return ret; } -EXPORT_SYMBOL(il_apm_init); +EXPORT_SYMBOL(il_apm_init); -int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) +int +il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) { int ret; s8 prev_tx_power; @@ -4245,16 +4270,13 @@ int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) /* 0 dBm mean 1 milliwatt */ if (tx_power < 0) { - IL_WARN( - "Requested user TXPOWER %d below 1 mW.\n", - tx_power); + IL_WARN("Requested user TXPOWER %d below 1 mW.\n", tx_power); return -EINVAL; } if (tx_power > il->tx_power_device_lmt) { - IL_WARN( - "Requested user TXPOWER %d above upper limit %d.\n", - tx_power, il->tx_power_device_lmt); + IL_WARN("Requested user TXPOWER %d above upper limit %d.\n", + tx_power, il->tx_power_device_lmt); return -EINVAL; } @@ -4267,7 +4289,7 @@ int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) /* do not set tx power when scanning or channel changing */ defer = test_bit(S_SCANNING, &il->status) || - memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging)); + memcmp(&ctx->active, &ctx->staging, sizeof(ctx->staging)); if (defer && !force) { D_INFO("Deferring tx power set\n"); return 0; @@ -4285,9 +4307,11 @@ int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) } return ret; } + EXPORT_SYMBOL(il_set_tx_power); -void il_send_bt_config(struct il_priv *il) +void +il_send_bt_config(struct il_priv *il) { struct il_bt_cmd bt_cmd = { .lead_time = BT_LEAD_TIME_DEF, @@ -4302,34 +4326,31 @@ void il_send_bt_config(struct il_priv *il) bt_cmd.flags = BT_COEX_ENABLE; D_INFO("BT coex %s\n", - (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active"); + (bt_cmd.flags == BT_COEX_DISABLE) ? "disable" : "active"); - if (il_send_cmd_pdu(il, C_BT_CONFIG, - sizeof(struct il_bt_cmd), &bt_cmd)) + if (il_send_cmd_pdu(il, C_BT_CONFIG, sizeof(struct il_bt_cmd), &bt_cmd)) IL_ERR("failed to send BT Coex Config\n"); } EXPORT_SYMBOL(il_send_bt_config); -int il_send_stats_request(struct il_priv *il, u8 flags, bool clear) +int +il_send_stats_request(struct il_priv *il, u8 flags, bool clear) { struct il_stats_cmd stats_cmd = { - .configuration_flags = - clear ? IL_STATS_CONF_CLEAR_STATS : 0, + .configuration_flags = clear ? IL_STATS_CONF_CLEAR_STATS : 0, }; if (flags & CMD_ASYNC) - return il_send_cmd_pdu_async(il, C_STATS, - sizeof(struct il_stats_cmd), - &stats_cmd, NULL); + return il_send_cmd_pdu_async(il, C_STATS, sizeof(struct il_stats_cmd), + &stats_cmd, NULL); else - return il_send_cmd_pdu(il, C_STATS, - sizeof(struct il_stats_cmd), - &stats_cmd); + return il_send_cmd_pdu(il, C_STATS, sizeof(struct il_stats_cmd), + &stats_cmd); } EXPORT_SYMBOL(il_send_stats_request); -void il_hdl_pm_sleep(struct il_priv *il, - struct il_rx_buf *rxb) +void +il_hdl_pm_sleep(struct il_priv *il, struct il_rx_buf *rxb) { #ifdef CONFIG_IWLEGACY_DEBUG struct il_rx_pkt *pkt = rxb_addr(rxb); @@ -4340,41 +4361,41 @@ void il_hdl_pm_sleep(struct il_priv *il, } EXPORT_SYMBOL(il_hdl_pm_sleep); -void il_hdl_pm_debug_stats(struct il_priv *il, - struct il_rx_buf *rxb) +void +il_hdl_pm_debug_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); u32 len = le32_to_cpu(pkt->len_n_flags) & IL_RX_FRAME_SIZE_MSK; - D_RADIO("Dumping %d bytes of unhandled " - "notification for %s:\n", len, - il_get_cmd_string(pkt->hdr.cmd)); + D_RADIO("Dumping %d bytes of unhandled notification for %s:\n", len, + il_get_cmd_string(pkt->hdr.cmd)); il_print_hex_dump(il, IL_DL_RADIO, pkt->u.raw, len); } EXPORT_SYMBOL(il_hdl_pm_debug_stats); -void il_hdl_error(struct il_priv *il, - struct il_rx_buf *rxb) +void +il_hdl_error(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); IL_ERR("Error Reply type 0x%08X cmd %s (0x%02X) " - "seq 0x%04X ser 0x%08X\n", - le32_to_cpu(pkt->u.err_resp.error_type), - il_get_cmd_string(pkt->u.err_resp.cmd_id), - pkt->u.err_resp.cmd_id, - le16_to_cpu(pkt->u.err_resp.bad_cmd_seq_num), - le32_to_cpu(pkt->u.err_resp.error_info)); + "seq 0x%04X ser 0x%08X\n", + le32_to_cpu(pkt->u.err_resp.error_type), + il_get_cmd_string(pkt->u.err_resp.cmd_id), + pkt->u.err_resp.cmd_id, + le16_to_cpu(pkt->u.err_resp.bad_cmd_seq_num), + le32_to_cpu(pkt->u.err_resp.error_info)); } EXPORT_SYMBOL(il_hdl_error); -void il_clear_isr_stats(struct il_priv *il) +void +il_clear_isr_stats(struct il_priv *il) { memset(&il->isr_stats, 0, sizeof(il->isr_stats)); } -int il_mac_conf_tx(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, u16 queue, - const struct ieee80211_tx_queue_params *params) +int +il_mac_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue, + const struct ieee80211_tx_queue_params *params) { struct il_priv *il = hw->priv; unsigned long flags; @@ -4397,12 +4418,12 @@ int il_mac_conf_tx(struct ieee80211_hw *hw, spin_lock_irqsave(&il->lock, flags); il->ctx.qos_data.def_qos_parm.ac[q].cw_min = - cpu_to_le16(params->cw_min); + cpu_to_le16(params->cw_min); il->ctx.qos_data.def_qos_parm.ac[q].cw_max = - cpu_to_le16(params->cw_max); + cpu_to_le16(params->cw_max); il->ctx.qos_data.def_qos_parm.ac[q].aifsn = params->aifs; il->ctx.qos_data.def_qos_parm.ac[q].edca_txop = - cpu_to_le16((params->txop * 32)); + cpu_to_le16((params->txop * 32)); il->ctx.qos_data.def_qos_parm.ac[q].reserved1 = 0; @@ -4411,14 +4432,17 @@ int il_mac_conf_tx(struct ieee80211_hw *hw, D_MAC80211("leave\n"); return 0; } + EXPORT_SYMBOL(il_mac_conf_tx); -int il_mac_tx_last_beacon(struct ieee80211_hw *hw) +int +il_mac_tx_last_beacon(struct ieee80211_hw *hw) { struct il_priv *il = hw->priv; return il->ibss_manager == IL_IBSS_MANAGER; } + EXPORT_SYMBOL_GPL(il_mac_tx_last_beacon); static int @@ -4432,8 +4456,8 @@ il_set_mode(struct il_priv *il, struct il_rxon_context *ctx) return il_commit_rxon(il, ctx); } -static int il_setup_interface(struct il_priv *il, - struct il_rxon_context *ctx) +static int +il_setup_interface(struct il_priv *il, struct il_rxon_context *ctx) { struct ieee80211_vif *vif = ctx->vif; int err; @@ -4467,8 +4491,7 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) int err; u32 modes; - D_MAC80211("enter: type %d, addr %pM\n", - vif->type, vif->addr); + D_MAC80211("enter: type %d, addr %pM\n", vif->type, vif->addr); mutex_lock(&il->mutex); @@ -4478,7 +4501,6 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) goto out; } - /* check if busy context is exclusive */ if (il->ctx.vif && (il->ctx.exclusive_interface_modes & BIT(il->ctx.vif->type))) { @@ -4501,17 +4523,18 @@ il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) il->iw_mode = NL80211_IFTYPE_STATION; } - out: +out: mutex_unlock(&il->mutex); D_MAC80211("leave\n"); return err; } + EXPORT_SYMBOL(il_mac_add_interface); -static void il_teardown_interface(struct il_priv *il, - struct ieee80211_vif *vif, - bool mode_change) +static void +il_teardown_interface(struct il_priv *il, struct ieee80211_vif *vif, + bool mode_change) { struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); @@ -4529,8 +4552,8 @@ static void il_teardown_interface(struct il_priv *il, } } -void il_mac_remove_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif) +void +il_mac_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { struct il_priv *il = hw->priv; struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); @@ -4550,35 +4573,40 @@ void il_mac_remove_interface(struct ieee80211_hw *hw, D_MAC80211("leave\n"); } + EXPORT_SYMBOL(il_mac_remove_interface); -int il_alloc_txq_mem(struct il_priv *il) +int +il_alloc_txq_mem(struct il_priv *il) { if (!il->txq) - il->txq = kzalloc( - sizeof(struct il_tx_queue) * - il->cfg->base_params->num_of_queues, - GFP_KERNEL); + il->txq = + kzalloc(sizeof(struct il_tx_queue) * + il->cfg->base_params->num_of_queues, GFP_KERNEL); if (!il->txq) { IL_ERR("Not enough memory for txq\n"); return -ENOMEM; } return 0; } + EXPORT_SYMBOL(il_alloc_txq_mem); -void il_txq_mem(struct il_priv *il) +void +il_txq_mem(struct il_priv *il) { kfree(il->txq); il->txq = NULL; } + EXPORT_SYMBOL(il_txq_mem); #ifdef CONFIG_IWLEGACY_DEBUGFS #define IL_TRAFFIC_DUMP_SIZE (IL_TRAFFIC_ENTRY_SIZE * IL_TRAFFIC_ENTRIES) -void il_reset_traffic_log(struct il_priv *il) +void +il_reset_traffic_log(struct il_priv *il) { il->tx_traffic_idx = 0; il->rx_traffic_idx = 0; @@ -4588,22 +4616,21 @@ void il_reset_traffic_log(struct il_priv *il) memset(il->rx_traffic, 0, IL_TRAFFIC_DUMP_SIZE); } -int il_alloc_traffic_mem(struct il_priv *il) +int +il_alloc_traffic_mem(struct il_priv *il) { u32 traffic_size = IL_TRAFFIC_DUMP_SIZE; if (il_debug_level & IL_DL_TX) { if (!il->tx_traffic) { - il->tx_traffic = - kzalloc(traffic_size, GFP_KERNEL); + il->tx_traffic = kzalloc(traffic_size, GFP_KERNEL); if (!il->tx_traffic) return -ENOMEM; } } if (il_debug_level & IL_DL_RX) { if (!il->rx_traffic) { - il->rx_traffic = - kzalloc(traffic_size, GFP_KERNEL); + il->rx_traffic = kzalloc(traffic_size, GFP_KERNEL); if (!il->rx_traffic) return -ENOMEM; } @@ -4611,9 +4638,11 @@ int il_alloc_traffic_mem(struct il_priv *il) il_reset_traffic_log(il); return 0; } + EXPORT_SYMBOL(il_alloc_traffic_mem); -void il_free_traffic_mem(struct il_priv *il) +void +il_free_traffic_mem(struct il_priv *il) { kfree(il->tx_traffic); il->tx_traffic = NULL; @@ -4621,10 +4650,12 @@ void il_free_traffic_mem(struct il_priv *il) kfree(il->rx_traffic); il->rx_traffic = NULL; } + EXPORT_SYMBOL(il_free_traffic_mem); -void il_dbg_log_tx_data_frame(struct il_priv *il, - u16 length, struct ieee80211_hdr *header) +void +il_dbg_log_tx_data_frame(struct il_priv *il, u16 length, + struct ieee80211_hdr *header) { __le16 fc; u16 len; @@ -4637,19 +4668,22 @@ void il_dbg_log_tx_data_frame(struct il_priv *il, fc = header->frame_control; if (ieee80211_is_data(fc)) { - len = (length > IL_TRAFFIC_ENTRY_SIZE) - ? IL_TRAFFIC_ENTRY_SIZE : length; + len = + (length > + IL_TRAFFIC_ENTRY_SIZE) ? IL_TRAFFIC_ENTRY_SIZE : length; memcpy((il->tx_traffic + - (il->tx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), - header, len); + (il->tx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), header, + len); il->tx_traffic_idx = - (il->tx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; + (il->tx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; } } + EXPORT_SYMBOL(il_dbg_log_tx_data_frame); -void il_dbg_log_rx_data_frame(struct il_priv *il, - u16 length, struct ieee80211_hdr *header) +void +il_dbg_log_rx_data_frame(struct il_priv *il, u16 length, + struct ieee80211_hdr *header) { __le16 fc; u16 len; @@ -4662,18 +4696,21 @@ void il_dbg_log_rx_data_frame(struct il_priv *il, fc = header->frame_control; if (ieee80211_is_data(fc)) { - len = (length > IL_TRAFFIC_ENTRY_SIZE) - ? IL_TRAFFIC_ENTRY_SIZE : length; + len = + (length > + IL_TRAFFIC_ENTRY_SIZE) ? IL_TRAFFIC_ENTRY_SIZE : length; memcpy((il->rx_traffic + - (il->rx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), - header, len); + (il->rx_traffic_idx * IL_TRAFFIC_ENTRY_SIZE)), header, + len); il->rx_traffic_idx = - (il->rx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; + (il->rx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; } } + EXPORT_SYMBOL(il_dbg_log_rx_data_frame); -const char *il_get_mgmt_string(int cmd) +const char * +il_get_mgmt_string(int cmd) { switch (cmd) { IL_CMD(MANAGEMENT_ASSOC_REQ); @@ -4694,7 +4731,8 @@ const char *il_get_mgmt_string(int cmd) } } -const char *il_get_ctrl_string(int cmd) +const char * +il_get_ctrl_string(int cmd) { switch (cmd) { IL_CMD(CONTROL_BACK_REQ); @@ -4711,7 +4749,8 @@ const char *il_get_ctrl_string(int cmd) } } -void il_clear_traffic_stats(struct il_priv *il) +void +il_clear_traffic_stats(struct il_priv *il) { memset(&il->tx_stats, 0, sizeof(struct traffic_stats)); memset(&il->rx_stats, 0, sizeof(struct traffic_stats)); @@ -4731,7 +4770,7 @@ void il_clear_traffic_stats(struct il_priv *il) void il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, u16 len) { - struct traffic_stats *stats; + struct traffic_stats *stats; if (is_tx) stats = &il->tx_stats; @@ -4810,10 +4849,12 @@ il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, u16 len) stats->data_bytes += len; } } + EXPORT_SYMBOL(il_update_stats); #endif -int il_force_reset(struct il_priv *il, bool external) +int +il_force_reset(struct il_priv *il, bool external) { struct il_force_reset *force_reset; @@ -4825,7 +4866,7 @@ int il_force_reset(struct il_priv *il, bool external) if (!external) { if (force_reset->last_force_reset_jiffies && time_after(force_reset->last_force_reset_jiffies + - force_reset->reset_duration, jiffies)) { + force_reset->reset_duration, jiffies)) { D_INFO("force reset rejected\n"); force_reset->reset_reject_count++; return -EAGAIN; @@ -4845,7 +4886,7 @@ int il_force_reset(struct il_priv *il, bool external) if (!external && !il->cfg->mod_params->restart_fw) { D_INFO("Cancel firmware reload based on " - "module parameter setting\n"); + "module parameter setting\n"); return 0; } @@ -4865,8 +4906,7 @@ int il_force_reset(struct il_priv *il, bool external) } int -il_mac_change_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, +il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, enum nl80211_iftype newtype, bool newp2p) { struct il_priv *il = hw->priv; @@ -4914,17 +4954,19 @@ il_mac_change_interface(struct ieee80211_hw *hw, */ err = 0; - out: +out: mutex_unlock(&il->mutex); return err; } + EXPORT_SYMBOL(il_mac_change_interface); /* * On every watchdog tick we check (latest) time stamp. If it does not * change during timeout period and queue is not empty we reset firmware. */ -static int il_check_stuck_queue(struct il_priv *il, int cnt) +static int +il_check_stuck_queue(struct il_priv *il, int cnt) { struct il_tx_queue *txq = &il->txq[cnt]; struct il_queue *q = &txq->q; @@ -4936,12 +4978,13 @@ static int il_check_stuck_queue(struct il_priv *il, int cnt) return 0; } - timeout = txq->time_stamp + - msecs_to_jiffies(il->cfg->base_params->wd_timeout); + timeout = + txq->time_stamp + + msecs_to_jiffies(il->cfg->base_params->wd_timeout); if (time_after(jiffies, timeout)) { - IL_ERR("Queue %d stuck for %u ms.\n", - q->id, il->cfg->base_params->wd_timeout); + IL_ERR("Queue %d stuck for %u ms.\n", q->id, + il->cfg->base_params->wd_timeout); ret = il_force_reset(il, false); return (ret == -EAGAIN) ? 0 : 1; } @@ -4959,7 +5002,8 @@ static int il_check_stuck_queue(struct il_priv *il, int cnt) * Watchdog timer callback, we check each tx queue for stuck, if if hung * we reset the firmware. If everything is fine just rearm the timer. */ -void il_bg_watchdog(unsigned long data) +void +il_bg_watchdog(unsigned long data) { struct il_priv *il = (struct il_priv *)data; int cnt; @@ -4987,12 +5031,14 @@ void il_bg_watchdog(unsigned long data) } } - mod_timer(&il->watchdog, jiffies + - msecs_to_jiffies(IL_WD_TICK(timeout))); + mod_timer(&il->watchdog, + jiffies + msecs_to_jiffies(IL_WD_TICK(timeout))); } + EXPORT_SYMBOL(il_bg_watchdog); -void il_setup_watchdog(struct il_priv *il) +void +il_setup_watchdog(struct il_priv *il) { unsigned int timeout = il->cfg->base_params->wd_timeout; @@ -5002,6 +5048,7 @@ void il_setup_watchdog(struct il_priv *il) else del_timer(&il->watchdog); } + EXPORT_SYMBOL(il_setup_watchdog); /* @@ -5011,8 +5058,7 @@ EXPORT_SYMBOL(il_setup_watchdog); * the internal part is the time in usec within one beacon interval */ u32 -il_usecs_to_beacons(struct il_priv *il, - u32 usec, u32 beacon_interval) +il_usecs_to_beacons(struct il_priv *il, u32 usec, u32 beacon_interval) { u32 quot; u32 rem; @@ -5021,32 +5067,42 @@ il_usecs_to_beacons(struct il_priv *il, if (!interval || !usec) return 0; - quot = (usec / interval) & - (il_beacon_time_mask_high(il, - il->hw_params.beacon_time_tsf_bits) >> - il->hw_params.beacon_time_tsf_bits); - rem = (usec % interval) & il_beacon_time_mask_low(il, - il->hw_params.beacon_time_tsf_bits); + quot = + (usec / + interval) & (il_beacon_time_mask_high(il, + il->hw_params. + beacon_time_tsf_bits) >> il-> + hw_params.beacon_time_tsf_bits); + rem = + (usec % interval) & il_beacon_time_mask_low(il, + il->hw_params. + beacon_time_tsf_bits); return (quot << il->hw_params.beacon_time_tsf_bits) + rem; } + EXPORT_SYMBOL(il_usecs_to_beacons); /* base is usually what we get from ucode with each received frame, * the same as HW timer counter counting down */ -__le32 il_add_beacon_time(struct il_priv *il, u32 base, - u32 addon, u32 beacon_interval) +__le32 +il_add_beacon_time(struct il_priv * il, u32 base, u32 addon, + u32 beacon_interval) { u32 base_low = base & il_beacon_time_mask_low(il, - il->hw_params.beacon_time_tsf_bits); + il->hw_params. + beacon_time_tsf_bits); u32 addon_low = addon & il_beacon_time_mask_low(il, - il->hw_params.beacon_time_tsf_bits); + il->hw_params. + beacon_time_tsf_bits); u32 interval = beacon_interval * TIME_UNIT; u32 res = (base & il_beacon_time_mask_high(il, - il->hw_params.beacon_time_tsf_bits)) + - (addon & il_beacon_time_mask_high(il, - il->hw_params.beacon_time_tsf_bits)); + il->hw_params. + beacon_time_tsf_bits)) + + (addon & il_beacon_time_mask_high(il, + il->hw_params. + beacon_time_tsf_bits)); if (base_low > addon_low) res += base_low - addon_low; @@ -5058,11 +5114,13 @@ __le32 il_add_beacon_time(struct il_priv *il, u32 base, return cpu_to_le32(res); } + EXPORT_SYMBOL(il_add_beacon_time); #ifdef CONFIG_PM -int il_pci_suspend(struct device *device) +int +il_pci_suspend(struct device *device) { struct pci_dev *pdev = to_pci_dev(device); struct il_priv *il = pci_get_drvdata(pdev); @@ -5078,9 +5136,11 @@ int il_pci_suspend(struct device *device) return 0; } + EXPORT_SYMBOL(il_pci_suspend); -int il_pci_resume(struct device *device) +int +il_pci_resume(struct device *device) { struct pci_dev *pdev = to_pci_dev(device); struct il_priv *il = pci_get_drvdata(pdev); @@ -5094,8 +5154,7 @@ int il_pci_resume(struct device *device) il_enable_interrupts(il); - if (!(_il_rd(il, CSR_GP_CNTRL) & - CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) + if (!(_il_rd(il, CSR_GP_CNTRL) & CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW)) hw_rfkill = true; if (hw_rfkill) @@ -5107,6 +5166,7 @@ int il_pci_resume(struct device *device) return 0; } + EXPORT_SYMBOL(il_pci_resume); const struct dev_pm_ops il_pm_ops = { @@ -5117,6 +5177,7 @@ const struct dev_pm_ops il_pm_ops = { .poweroff = il_pci_suspend, .restore = il_pci_resume, }; + EXPORT_SYMBOL(il_pm_ops); #endif /* CONFIG_PM */ @@ -5134,24 +5195,23 @@ il_update_qos(struct il_priv *il, struct il_rxon_context *ctx) if (ctx->qos_data.qos_active) ctx->qos_data.def_qos_parm.qos_flags |= - QOS_PARAM_FLG_UPDATE_EDCA_MSK; + QOS_PARAM_FLG_UPDATE_EDCA_MSK; if (ctx->ht.enabled) ctx->qos_data.def_qos_parm.qos_flags |= QOS_PARAM_FLG_TGN_MSK; D_QOS("send QoS cmd with Qos active=%d FLAGS=0x%X\n", - ctx->qos_data.qos_active, - ctx->qos_data.def_qos_parm.qos_flags); + ctx->qos_data.qos_active, ctx->qos_data.def_qos_parm.qos_flags); - il_send_cmd_pdu_async(il, ctx->qos_cmd, - sizeof(struct il_qosparam_cmd), - &ctx->qos_data.def_qos_parm, NULL); + il_send_cmd_pdu_async(il, ctx->qos_cmd, sizeof(struct il_qosparam_cmd), + &ctx->qos_data.def_qos_parm, NULL); } /** * il_mac_config - mac80211 config callback */ -int il_mac_config(struct ieee80211_hw *hw, u32 changed) +int +il_mac_config(struct ieee80211_hw *hw, u32 changed) { struct il_priv *il = hw->priv; const struct il_channel_info *ch_info; @@ -5170,16 +5230,16 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) mutex_lock(&il->mutex); - D_MAC80211("enter to channel %d changed 0x%X\n", - channel->hw_value, changed); + D_MAC80211("enter to channel %d changed 0x%X\n", channel->hw_value, + changed); if (unlikely(test_bit(S_SCANNING, &il->status))) { scan_active = 1; D_MAC80211("scan active\n"); } - if (changed & (IEEE80211_CONF_CHANGE_SMPS | - IEEE80211_CONF_CHANGE_CHANNEL)) { + if (changed & + (IEEE80211_CONF_CHANGE_SMPS | IEEE80211_CONF_CHANGE_CHANNEL)) { /* mac80211 uses static for non-HT which is what we want */ il->current_ht_config.smps = conf->smps_mode; @@ -5227,15 +5287,15 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) if (ctx->ht.enabled) { if (conf_is_ht40_minus(conf)) { ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_BELOW; + IEEE80211_HT_PARAM_CHA_SEC_BELOW; ctx->ht.is_40mhz = true; } else if (conf_is_ht40_plus(conf)) { ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_ABOVE; + IEEE80211_HT_PARAM_CHA_SEC_ABOVE; ctx->ht.is_40mhz = true; } else { ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_NONE; + IEEE80211_HT_PARAM_CHA_SEC_NONE; ctx->ht.is_40mhz = false; } } else @@ -5245,8 +5305,7 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) * Default to no protection. Protection mode will * later be set from BSS config in il_ht_conf */ - ctx->ht.protection = - IEEE80211_HT_OP_MODE_PROTECTION_NONE; + ctx->ht.protection = IEEE80211_HT_OP_MODE_PROTECTION_NONE; /* if we are switching from ht to 2.4 clear flags * from any ht related info since 2.4 does not @@ -5257,32 +5316,29 @@ int il_mac_config(struct ieee80211_hw *hw, u32 changed) il_set_rxon_channel(il, channel, ctx); il_set_rxon_ht(il, ht_conf); - il_set_flags_for_band(il, ctx, channel->band, - ctx->vif); + il_set_flags_for_band(il, ctx, channel->band, ctx->vif); spin_unlock_irqrestore(&il->lock, flags); if (il->cfg->ops->legacy->update_bcast_stations) - ret = - il->cfg->ops->legacy->update_bcast_stations(il); + ret = il->cfg->ops->legacy->update_bcast_stations(il); - set_ch_out: +set_ch_out: /* The list of supported rates and rate mask can be different * for each band; since the band may have changed, reset * the rate mask to what mac80211 lists */ il_set_rate(il); } - if (changed & (IEEE80211_CONF_CHANGE_PS | - IEEE80211_CONF_CHANGE_IDLE)) { + if (changed & (IEEE80211_CONF_CHANGE_PS | IEEE80211_CONF_CHANGE_IDLE)) { ret = il_power_update_mode(il, false); if (ret) D_MAC80211("Error setting sleep level\n"); } if (changed & IEEE80211_CONF_CHANGE_POWER) { - D_MAC80211("TX Power old=%d new=%d\n", - il->tx_power_user_lmt, conf->power_level); + D_MAC80211("TX Power old=%d new=%d\n", il->tx_power_user_lmt, + conf->power_level); il_set_tx_power(il, conf->power_level, false); } @@ -5309,8 +5365,8 @@ out: } EXPORT_SYMBOL(il_mac_config); -void il_mac_reset_tsf(struct ieee80211_hw *hw, - struct ieee80211_vif *vif) +void +il_mac_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { struct il_priv *il = hw->priv; unsigned long flags; @@ -5357,10 +5413,11 @@ void il_mac_reset_tsf(struct ieee80211_hw *hw, D_MAC80211("leave\n"); } + EXPORT_SYMBOL(il_mac_reset_tsf); -static void il_ht_conf(struct il_priv *il, - struct ieee80211_vif *vif) +static void +il_ht_conf(struct il_priv *il, struct ieee80211_vif *vif) { struct il_ht_config *ht_conf = &il->current_ht_config; struct ieee80211_sta *sta; @@ -5373,10 +5430,10 @@ static void il_ht_conf(struct il_priv *il, return; ctx->ht.protection = - bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION; + bss_conf->ht_operation_mode & IEEE80211_HT_OP_MODE_PROTECTION; ctx->ht.non_gf_sta_present = - !!(bss_conf->ht_operation_mode & - IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); + !!(bss_conf-> + ht_operation_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT); ht_conf->single_chain_sufficient = false; @@ -5388,9 +5445,10 @@ static void il_ht_conf(struct il_priv *il, struct ieee80211_sta_ht_cap *ht_cap = &sta->ht_cap; int maxstreams; - maxstreams = (ht_cap->mcs.tx_params & - IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK) - >> IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT; + maxstreams = + (ht_cap->mcs. + tx_params & IEEE80211_HT_MCS_TX_MAX_STREAMS_MASK) + >> IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT; maxstreams += 1; if (ht_cap->mcs.rx_mask[1] == 0 && @@ -5419,8 +5477,8 @@ static void il_ht_conf(struct il_priv *il, D_ASSOC("leave\n"); } -static inline void il_set_no_assoc(struct il_priv *il, - struct ieee80211_vif *vif) +static inline void +il_set_no_assoc(struct il_priv *il, struct ieee80211_vif *vif) { struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); @@ -5434,8 +5492,8 @@ static inline void il_set_no_assoc(struct il_priv *il, il_commit_rxon(il, ctx); } -static void il_beacon_update(struct ieee80211_hw *hw, - struct ieee80211_vif *vif) +static void +il_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif) { struct il_priv *il = hw->priv; unsigned long flags; @@ -5476,10 +5534,9 @@ static void il_beacon_update(struct ieee80211_hw *hw, il->cfg->ops->legacy->post_associate(il); } -void il_mac_bss_info_changed(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_bss_conf *bss_conf, - u32 changes) +void +il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_bss_conf *bss_conf, u32 changes) { struct il_priv *il = hw->priv; struct il_rxon_context *ctx = il_rxon_ctx_from_vif(vif); @@ -5527,24 +5584,21 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, * below/in post_associate will fail. */ if (il_scan_cancel_timeout(il, 100)) { - IL_WARN( - "Aborted scan still in progress after 100ms\n"); - D_MAC80211( - "leaving - scan abort failed.\n"); + IL_WARN("Aborted scan still in progress after 100ms\n"); + D_MAC80211("leaving - scan abort failed.\n"); mutex_unlock(&il->mutex); return; } /* mac80211 only sets assoc when in STATION mode */ if (vif->type == NL80211_IFTYPE_ADHOC || bss_conf->assoc) { - memcpy(ctx->staging.bssid_addr, - bss_conf->bssid, ETH_ALEN); + memcpy(ctx->staging.bssid_addr, bss_conf->bssid, + ETH_ALEN); /* currently needed in a few places */ memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); } else { - ctx->staging.filter_flags &= - ~RXON_FILTER_ASSOC_MSK; + ctx->staging.filter_flags &= ~RXON_FILTER_ASSOC_MSK; } } @@ -5558,8 +5612,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, il_beacon_update(hw, vif); if (changes & BSS_CHANGED_ERP_PREAMBLE) { - D_MAC80211("ERP_PREAMBLE %d\n", - bss_conf->use_short_preamble); + D_MAC80211("ERP_PREAMBLE %d\n", bss_conf->use_short_preamble); if (bss_conf->use_short_preamble) ctx->staging.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; else @@ -5567,8 +5620,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, } if (changes & BSS_CHANGED_ERP_CTS_PROT) { - D_MAC80211( - "ERP_CTS %d\n", bss_conf->use_cts_prot); + D_MAC80211("ERP_CTS %d\n", bss_conf->use_cts_prot); if (bss_conf->use_cts_prot && il->band != IEEE80211_BAND_5GHZ) ctx->staging.flags |= RXON_FLG_TGG_PROTECT_MSK; else @@ -5585,14 +5637,14 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, * To do that, remove code from il_set_rate() and put something * like this here: * - if (A-band) - ctx->staging.ofdm_basic_rates = - bss_conf->basic_rates; - else - ctx->staging.ofdm_basic_rates = - bss_conf->basic_rates >> 4; - ctx->staging.cck_basic_rates = - bss_conf->basic_rates & 0xF; + if (A-band) + ctx->staging.ofdm_basic_rates = + bss_conf->basic_rates; + else + ctx->staging.ofdm_basic_rates = + bss_conf->basic_rates >> 4; + ctx->staging.cck_basic_rates = + bss_conf->basic_rates & 0xF; */ } @@ -5615,21 +5667,19 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, } if (changes && il_is_associated_ctx(ctx) && bss_conf->aid) { - D_MAC80211("Changes (%#x) while associated\n", - changes); + D_MAC80211("Changes (%#x) while associated\n", changes); ret = il_send_rxon_assoc(il, ctx); if (!ret) { /* Sync active_rxon with latest change. */ - memcpy((void *)&ctx->active, - &ctx->staging, - sizeof(struct il_rxon_cmd)); + memcpy((void *)&ctx->active, &ctx->staging, + sizeof(struct il_rxon_cmd)); } } if (changes & BSS_CHANGED_BEACON_ENABLED) { if (vif->bss_conf.enable_beacon) { - memcpy(ctx->staging.bssid_addr, - bss_conf->bssid, ETH_ALEN); + memcpy(ctx->staging.bssid_addr, bss_conf->bssid, + ETH_ALEN); memcpy(il->bssid, bss_conf->bssid, ETH_ALEN); il->cfg->ops->legacy->config_ap(il); } else @@ -5637,21 +5687,25 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw, } if (changes & BSS_CHANGED_IBSS) { - ret = il->cfg->ops->legacy->manage_ibss_station(il, vif, - bss_conf->ibss_joined); + ret = + il->cfg->ops->legacy->manage_ibss_station(il, vif, + bss_conf-> + ibss_joined); if (ret) IL_ERR("failed to %s IBSS station %pM\n", - bss_conf->ibss_joined ? "add" : "remove", - bss_conf->bssid); + bss_conf->ibss_joined ? "add" : "remove", + bss_conf->bssid); } mutex_unlock(&il->mutex); D_MAC80211("leave\n"); } + EXPORT_SYMBOL(il_mac_bss_info_changed); -irqreturn_t il_isr(int irq, void *data) +irqreturn_t +il_isr(int irq, void *data) { struct il_priv *il = data; u32 inta, inta_mask; @@ -5666,7 +5720,7 @@ irqreturn_t il_isr(int irq, void *data) * back-to-back ISRs and sporadic interrupts from our NIC. * If we have something to service, the tasklet will re-enable ints. * If we *don't* have something, we'll re-enable before leaving here. */ - inta_mask = _il_rd(il, CSR_INT_MASK); /* just for debug */ + inta_mask = _il_rd(il, CSR_INT_MASK); /* just for debug */ _il_wr(il, CSR_INT_MASK, 0x00000000); /* Discover which interrupts are active/pending */ @@ -5677,8 +5731,7 @@ irqreturn_t il_isr(int irq, void *data) * This may be due to IRQ shared with another device, * or due to sporadic interrupts thrown from our NIC. */ if (!inta && !inta_fh) { - D_ISR( - "Ignore interrupt, inta == 0, inta_fh == 0\n"); + D_ISR("Ignore interrupt, inta == 0, inta_fh == 0\n"); goto none; } @@ -5689,8 +5742,8 @@ irqreturn_t il_isr(int irq, void *data) goto unplugged; } - D_ISR("ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", - inta, inta_mask, inta_fh); + D_ISR("ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", inta, inta_mask, + inta_fh); inta &= ~CSR_INT_BIT_SCD; @@ -5710,15 +5763,16 @@ none: spin_unlock_irqrestore(&il->lock, flags); return IRQ_NONE; } + EXPORT_SYMBOL(il_isr); /* * il_tx_cmd_protection: Set rts/cts. 3945 and 4965 only share this * function. */ -void il_tx_cmd_protection(struct il_priv *il, - struct ieee80211_tx_info *info, - __le16 fc, __le32 *tx_flags) +void +il_tx_cmd_protection(struct il_priv *il, struct ieee80211_tx_info *info, + __le16 fc, __le32 * tx_flags) { if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) { *tx_flags |= TX_CMD_FLG_RTS_MSK; @@ -5737,11 +5791,12 @@ void il_tx_cmd_protection(struct il_priv *il, *tx_flags |= TX_CMD_FLG_CTS_MSK; break; } - } else if (info->control.rates[0].flags & - IEEE80211_TX_RC_USE_CTS_PROTECT) { + } else if (info->control.rates[0]. + flags & IEEE80211_TX_RC_USE_CTS_PROTECT) { *tx_flags &= ~TX_CMD_FLG_RTS_MSK; *tx_flags |= TX_CMD_FLG_CTS_MSK; *tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; } } + EXPORT_SYMBOL(il_tx_cmd_protection); diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index b1d237fc5fb7..38ff3d66c745 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -27,7 +27,7 @@ #define __il_core_h__ #include -#include /* for struct pci_device_id */ +#include /* for struct pci_device_id */ #include #include #include @@ -59,7 +59,7 @@ struct il_tx_queue; #define U32_PAD(n) ((4-(n))&0x3) /* CT-KILL constants */ -#define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */ +#define CT_KILL_THRESHOLD_LEGACY 110 /* in Celsius */ /* Default noise level to report when noise measurement is not available. * This may be because we're: @@ -112,16 +112,15 @@ struct il_cmd_meta { * invoked for SYNC commands, if it were and its result passed * through it would be simpler...) */ - void (*callback)(struct il_priv *il, - struct il_device_cmd *cmd, - struct il_rx_pkt *pkt); + void (*callback) (struct il_priv * il, struct il_device_cmd * cmd, + struct il_rx_pkt * pkt); /* The CMD_SIZE_HUGE flag bit indicates that the command * structure is stored at the end of the shared queue memory. */ u32 flags; - DEFINE_DMA_UNMAP_ADDR(mapping); - DEFINE_DMA_UNMAP_LEN(len); + DEFINE_DMA_UNMAP_ADDR(mapping); + DEFINE_DMA_UNMAP_LEN(len); }; /* @@ -130,17 +129,17 @@ struct il_cmd_meta { * Contains common data for Rx and Tx queues */ struct il_queue { - int n_bd; /* number of BDs in this queue */ - int write_ptr; /* 1-st empty entry (idx) host_w*/ - int read_ptr; /* last used entry (idx) host_r*/ + int n_bd; /* number of BDs in this queue */ + int write_ptr; /* 1-st empty entry (idx) host_w */ + int read_ptr; /* last used entry (idx) host_r */ /* use for monitoring and recovering the stuck queue */ - dma_addr_t dma_addr; /* physical addr for BD's */ - int n_win; /* safe queue win */ + dma_addr_t dma_addr; /* physical addr for BD's */ + int n_win; /* safe queue win */ u32 id; - int low_mark; /* low watermark, resume queue if free - * space more than this */ - int high_mark; /* high watermark, stop queue if free - * space less than this */ + int low_mark; /* low watermark, resume queue if free + * space more than this */ + int high_mark; /* high watermark, stop queue if free + * space less than this */ }; /* One for each TFD */ @@ -188,11 +187,10 @@ struct il_tx_queue { * When polling, wait 10 uSec between polling loops, up to a maximum 5000 uSec. * Driver reads 16-bit value from bits 31-16 of CSR_EEPROM_REG. */ -#define IL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */ - -#define IL_EEPROM_SEM_TIMEOUT 10 /* microseconds */ -#define IL_EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ +#define IL_EEPROM_ACCESS_TIMEOUT 5000 /* uSec */ +#define IL_EEPROM_SEM_TIMEOUT 10 /* microseconds */ +#define IL_EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ /* * Regulatory channel usage flags in EEPROM struct il4965_eeprom_channel.flags. @@ -213,11 +211,11 @@ struct il_tx_queue { #define IL_NUM_TX_CALIB_GROUPS 5 enum { EEPROM_CHANNEL_VALID = (1 << 0), /* usable for this SKU/geo */ - EEPROM_CHANNEL_IBSS = (1 << 1), /* usable as an IBSS channel */ + EEPROM_CHANNEL_IBSS = (1 << 1), /* usable as an IBSS channel */ /* Bit 2 Reserved */ EEPROM_CHANNEL_ACTIVE = (1 << 3), /* active scanning allowed */ EEPROM_CHANNEL_RADAR = (1 << 4), /* radar detection required */ - EEPROM_CHANNEL_WIDE = (1 << 5), /* 20 MHz channel okay */ + EEPROM_CHANNEL_WIDE = (1 << 5), /* 20 MHz channel okay */ /* Bit 6 Reserved (was Narrow Channel) */ EEPROM_CHANNEL_DFS = (1 << 7), /* dynamic freq selection candidate */ }; @@ -251,10 +249,10 @@ struct il_eeprom_channel { /* 4965 driver does not work with txpower calibration version < 5 */ #define EEPROM_4965_TX_POWER_VERSION (5) #define EEPROM_4965_EEPROM_VERSION (0x2f) -#define EEPROM_4965_CALIB_VERSION_OFFSET (2*0xB6) /* 2 bytes */ -#define EEPROM_4965_CALIB_TXPOWER_OFFSET (2*0xE8) /* 48 bytes */ -#define EEPROM_4965_BOARD_REVISION (2*0x4F) /* 2 bytes */ -#define EEPROM_4965_BOARD_PBA (2*0x56+1) /* 9 bytes */ +#define EEPROM_4965_CALIB_VERSION_OFFSET (2*0xB6) /* 2 bytes */ +#define EEPROM_4965_CALIB_TXPOWER_OFFSET (2*0xE8) /* 48 bytes */ +#define EEPROM_4965_BOARD_REVISION (2*0x4F) /* 2 bytes */ +#define EEPROM_4965_BOARD_PBA (2*0x56+1) /* 9 bytes */ /* 2.4 GHz */ extern const u8 il_eeprom_band_1[14]; @@ -280,7 +278,6 @@ struct il_eeprom_calib_measure { s8 pa_det; /* Power amp detector level (not used) */ } __packed; - /* * measurement set for one channel. EEPROM contains: * @@ -292,8 +289,8 @@ struct il_eeprom_calib_measure { struct il_eeprom_calib_ch_info { u8 ch_num; struct il_eeprom_calib_measure - measurements[EEPROM_TX_POWER_TX_CHAINS] - [EEPROM_TX_POWER_MEASUREMENTS]; + measurements[EEPROM_TX_POWER_TX_CHAINS] + [EEPROM_TX_POWER_MEASUREMENTS]; } __packed; /* @@ -307,13 +304,12 @@ struct il_eeprom_calib_ch_info { * 2) Sample measurement sets for 2 channels close to the range endpoints. */ struct il_eeprom_calib_subband_info { - u8 ch_from; /* channel number of lowest channel in subband */ - u8 ch_to; /* channel number of highest channel in subband */ + u8 ch_from; /* channel number of lowest channel in subband */ + u8 ch_to; /* channel number of highest channel in subband */ struct il_eeprom_calib_ch_info ch1; struct il_eeprom_calib_ch_info ch2; } __packed; - /* * txpower calibration info. EEPROM contains: * @@ -338,11 +334,9 @@ struct il_eeprom_calib_info { u8 saturation_power24; /* half-dBm (e.g. "34" = 17 dBm) */ u8 saturation_power52; /* half-dBm */ __le16 voltage; /* signed */ - struct il_eeprom_calib_subband_info - band_info[EEPROM_TX_POWER_BANDS]; + struct il_eeprom_calib_subband_info band_info[EEPROM_TX_POWER_BANDS]; } __packed; - /* General */ #define EEPROM_DEVICE_ID (2*0x08) /* 2 bytes */ #define EEPROM_MAC_ADDRESS (2*0x15) /* 6 bytes */ @@ -356,12 +350,12 @@ struct il_eeprom_calib_info { #define EEPROM_NUM_MAC_ADDRESS (2*0x4C) /* 2 bytes */ /* The following masks are to be applied on EEPROM_RADIO_CONFIG */ -#define EEPROM_RF_CFG_TYPE_MSK(x) (x & 0x3) /* bits 0-1 */ -#define EEPROM_RF_CFG_STEP_MSK(x) ((x >> 2) & 0x3) /* bits 2-3 */ -#define EEPROM_RF_CFG_DASH_MSK(x) ((x >> 4) & 0x3) /* bits 4-5 */ -#define EEPROM_RF_CFG_PNUM_MSK(x) ((x >> 6) & 0x3) /* bits 6-7 */ -#define EEPROM_RF_CFG_TX_ANT_MSK(x) ((x >> 8) & 0xF) /* bits 8-11 */ -#define EEPROM_RF_CFG_RX_ANT_MSK(x) ((x >> 12) & 0xF) /* bits 12-15 */ +#define EEPROM_RF_CFG_TYPE_MSK(x) (x & 0x3) /* bits 0-1 */ +#define EEPROM_RF_CFG_STEP_MSK(x) ((x >> 2) & 0x3) /* bits 2-3 */ +#define EEPROM_RF_CFG_DASH_MSK(x) ((x >> 4) & 0x3) /* bits 4-5 */ +#define EEPROM_RF_CFG_PNUM_MSK(x) ((x >> 6) & 0x3) /* bits 6-7 */ +#define EEPROM_RF_CFG_TX_ANT_MSK(x) ((x >> 8) & 0xF) /* bits 8-11 */ +#define EEPROM_RF_CFG_RX_ANT_MSK(x) ((x >> 12) & 0xF) /* bits 12-15 */ #define EEPROM_3945_RF_CFG_TYPE_MAX 0x0 #define EEPROM_4965_RF_CFG_TYPE_MAX 0x1 @@ -378,7 +372,7 @@ struct il_eeprom_calib_info { * * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 */ -#define EEPROM_REGULATORY_SKU_ID (2*0x60) /* 4 bytes */ +#define EEPROM_REGULATORY_SKU_ID (2*0x60) /* 4 bytes */ #define EEPROM_REGULATORY_BAND_1 (2*0x62) /* 2 bytes */ #define EEPROM_REGULATORY_BAND_1_CHANNELS (2*0x63) /* 28 bytes */ @@ -438,22 +432,19 @@ struct il_eeprom_calib_info { struct il_eeprom_ops { const u32 regulatory_bands[7]; - int (*acquire_semaphore) (struct il_priv *il); - void (*release_semaphore) (struct il_priv *il); + int (*acquire_semaphore) (struct il_priv * il); + void (*release_semaphore) (struct il_priv * il); }; - int il_eeprom_init(struct il_priv *il); void il_eeprom_free(struct il_priv *il); -const u8 *il_eeprom_query_addr(const struct il_priv *il, - size_t offset); +const u8 *il_eeprom_query_addr(const struct il_priv *il, size_t offset); u16 il_eeprom_query16(const struct il_priv *il, size_t offset); int il_init_channel_map(struct il_priv *il); void il_free_channel_map(struct il_priv *il); -const struct il_channel_info *il_get_channel_info( - const struct il_priv *il, - enum ieee80211_band band, u16 channel); - +const struct il_channel_info *il_get_channel_info(const struct il_priv *il, + enum ieee80211_band band, + u16 channel); #define IL_NUM_SCAN_RATES (2) @@ -508,21 +499,21 @@ struct il_channel_info { struct il_eeprom_channel ht40_eeprom; /* EEPROM regulatory limit for * HT40 channel */ - u8 channel; /* channel number */ - u8 flags; /* flags copied from EEPROM */ - s8 max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */ - s8 curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) limit */ - s8 min_power; /* always 0 */ - s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */ + u8 channel; /* channel number */ + u8 flags; /* flags copied from EEPROM */ + s8 max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */ + s8 curr_txpow; /* (dBm) regulatory/spectrum/user (not h/w) limit */ + s8 min_power; /* always 0 */ + s8 scan_power; /* (dBm) regul. eeprom, direct scans, any rate */ - u8 group_idx; /* 0-4, maps channel to group1/2/3/4/5 */ - u8 band_idx; /* 0-4, maps channel to band1/2/3/4/5 */ + u8 group_idx; /* 0-4, maps channel to group1/2/3/4/5 */ + u8 band_idx; /* 0-4, maps channel to band1/2/3/4/5 */ enum ieee80211_band band; /* HT40 channel info */ s8 ht40_max_power_avg; /* (dBm) regul. eeprom, normal Tx, any rate */ u8 ht40_flags; /* flags copied from EEPROM */ - u8 ht40_extension_channel; /* HT_IE_EXT_CHANNEL_* */ + u8 ht40_extension_channel; /* HT_IE_EXT_CHANNEL_* */ /* Radio/DSP gain settings for each "normal" data Tx rate. * These include, in addition to RF and DSP gain, a few fields for @@ -598,13 +589,11 @@ struct il_device_cmd { #define TFD_MAX_PAYLOAD_SIZE (sizeof(struct il_device_cmd)) - struct il_host_cmd { const void *data; unsigned long reply_page; - void (*callback)(struct il_priv *il, - struct il_device_cmd *cmd, - struct il_rx_pkt *pkt); + void (*callback) (struct il_priv * il, struct il_device_cmd * cmd, + struct il_rx_pkt * pkt); u32 flags; u16 len; u8 id; @@ -681,9 +670,8 @@ struct il_ht_agg { u8 state; }; - struct il_tid_data { - u16 seq_number; /* 4965 only */ + u16 seq_number; /* 4965 only */ u16 tfds_in_queue; struct il_ht_agg agg; }; @@ -728,7 +716,7 @@ union il_ht_rate_supp { struct il_ht_config { bool single_chain_sufficient; - enum ieee80211_smps_mode smps; /* current smps mode */ + enum ieee80211_smps_mode smps; /* current smps mode */ }; /* QoS structures */ @@ -776,14 +764,14 @@ struct fw_desc { /* uCode file layout */ struct il_ucode_header { - __le32 ver; /* major/minor/API/serial */ + __le32 ver; /* major/minor/API/serial */ struct { __le32 inst_size; /* bytes of runtime code */ __le32 data_size; /* bytes of runtime data */ __le32 init_size; /* bytes of init code */ __le32 init_data_size; /* bytes of init data */ __le32 boot_size; /* bytes of bootstrap code */ - u8 data[0]; /* in same order as sizes */ + u8 data[0]; /* in same order as sizes */ } v1; }; @@ -822,11 +810,9 @@ struct il_sensitivity_ranges { u16 nrg_th_cca; }; - #define KELVIN_TO_CELSIUS(x) ((x)-273) #define CELSIUS_TO_KELVIN(x) ((x)+273) - /** * struct il_hw_params * @max_txq_num: Max # Tx queues supported @@ -853,26 +839,25 @@ struct il_hw_params { u8 dma_chnl_num; u16 scd_bc_tbls_size; u32 tfd_size; - u8 tx_chains_num; - u8 rx_chains_num; - u8 valid_tx_ant; - u8 valid_rx_ant; + u8 tx_chains_num; + u8 rx_chains_num; + u8 valid_tx_ant; + u8 valid_rx_ant; u16 max_rxq_size; u16 max_rxq_log; u32 rx_page_order; u32 rx_wrt_ptr_reg; - u8 max_stations; - u8 ht40_channel; - u8 max_beacon_itrvl; /* in 1024 ms */ + u8 max_stations; + u8 ht40_channel; + u8 max_beacon_itrvl; /* in 1024 ms */ u32 max_inst_size; u32 max_data_size; u32 max_bsm_size; - u32 ct_kill_threshold; /* value in hw-dependent units */ + u32 ct_kill_threshold; /* value in hw-dependent units */ u16 beacon_time_tsf_bits; const struct il_sensitivity_ranges *sens; }; - /****************************************************************************** * * Functions implemented in core module which are forward declared here @@ -891,16 +876,19 @@ struct il_hw_params { extern void il4965_update_chain_flags(struct il_priv *il); extern const u8 il_bcast_addr[ETH_ALEN]; extern int il_queue_space(const struct il_queue *q); -static inline int il_queue_used(const struct il_queue *q, int i) +static inline int +il_queue_used(const struct il_queue *q, int i) { - return q->write_ptr >= q->read_ptr ? - (i >= q->read_ptr && i < q->write_ptr) : - !(i < q->read_ptr && i >= q->write_ptr); + return q->write_ptr >= q->read_ptr ? (i >= q->read_ptr && + i < q->write_ptr) : !(i < + q->read_ptr + && i >= + q-> + write_ptr); } - -static inline u8 il_get_cmd_idx(struct il_queue *q, u32 idx, - int is_huge) +static inline u8 +il_get_cmd_idx(struct il_queue *q, u32 idx, int is_huge) { /* * This is for init calibration result and scan command which @@ -914,7 +902,6 @@ static inline u8 il_get_cmd_idx(struct il_queue *q, u32 idx, return idx & (q->n_win - 1); } - struct il_dma_ptr { dma_addr_t dma; void *addr; @@ -974,14 +961,14 @@ enum il4965_false_alarm_state { }; enum il4965_chain_noise_state { - IL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */ + IL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */ IL_CHAIN_NOISE_ACCUMULATE, IL_CHAIN_NOISE_CALIBRATED, IL_CHAIN_NOISE_DONE, }; enum il4965_calib_enabled_state { - IL_CALIB_DISABLED = 0, /* must be 0 */ + IL_CALIB_DISABLED = 0, /* must be 0 */ IL_CALIB_ENABLED = 1, }; @@ -1023,7 +1010,7 @@ struct il_sensitivity_data { u32 nrg_curr_state; u32 nrg_prev_state; u32 nrg_value[10]; - u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L]; + u8 nrg_silence_rssi[NRG_NUM_PREV_STAT_L]; u32 nrg_silence_ref; u32 nrg_energy_idx; u32 nrg_silence_idx; @@ -1053,7 +1040,7 @@ struct il_chain_noise_data { u8 state; }; -#define EEPROM_SEM_TIMEOUT 10 /* milliseconds */ +#define EEPROM_SEM_TIMEOUT 10 /* milliseconds */ #define EEPROM_SEM_RETRY_LIMIT 1000 /* number of attempts (not time) */ #define IL_TRAFFIC_ENTRIES (256) @@ -1098,7 +1085,7 @@ enum il_mgmt_stats { }; /* control stats */ enum il_ctrl_stats { - CONTROL_BACK_REQ = 0, + CONTROL_BACK_REQ = 0, CONTROL_BACK, CONTROL_PSPOLL, CONTROL_RTS, @@ -1237,8 +1224,8 @@ struct il_priv { enum ieee80211_band band; int alloc_rxb_page; - void (*handlers[IL_CN_MAX])(struct il_priv *il, - struct il_rx_buf *rxb); + void (*handlers[IL_CN_MAX]) (struct il_priv * il, + struct il_rx_buf * rxb); struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; @@ -1289,9 +1276,9 @@ struct il_priv { /* pci hardware address support */ void __iomem *hw_base; - u32 hw_rev; - u32 hw_wa_rev; - u8 rev_id; + u32 hw_rev; + u32 hw_wa_rev; + u8 rev_id; /* command queue number */ u8 cmd_queue; @@ -1303,9 +1290,9 @@ struct il_priv { struct mac_address addresses[1]; /* uCode images, save to reload in case of failure */ - int fw_idx; /* firmware we're trying to load */ - u32 ucode_ver; /* version of ucode, copy of - il_ucode.ver */ + int fw_idx; /* firmware we're trying to load */ + u32 ucode_ver; /* version of ucode, copy of + il_ucode.ver */ struct fw_desc ucode_code; /* runtime inst */ struct fw_desc ucode_data; /* runtime data original */ struct fw_desc ucode_data_backup; /* runtime data save/restore */ @@ -1345,8 +1332,8 @@ struct il_priv { struct il_rx_queue rxq; struct il_tx_queue *txq; unsigned long txq_ctx_active_msk; - struct il_dma_ptr kw; /* keep warm address */ - struct il_dma_ptr scd_bc_tbls; + struct il_dma_ptr kw; /* keep warm address */ + struct il_dma_ptr scd_bc_tbls; u32 scd_base_addr; /* scheduler sram base address */ @@ -1362,7 +1349,7 @@ struct il_priv { struct il_power_mgr power_data; /* context information */ - u8 bssid[ETH_ALEN]; /* used only on 3945 but filled by core */ + u8 bssid[ETH_ALEN]; /* used only on 3945 but filled by core */ /* station table variables */ @@ -1477,12 +1464,11 @@ struct il_priv { s8 tx_power_device_lmt; s8 tx_power_next; - #ifdef CONFIG_IWLEGACY_DEBUG /* debugging info */ - u32 debug_level; /* per device debugging will override global - il_debug_level if set */ -#endif /* CONFIG_IWLEGACY_DEBUG */ + u32 debug_level; /* per device debugging will override global + il_debug_level if set */ +#endif /* CONFIG_IWLEGACY_DEBUG */ #ifdef CONFIG_IWLEGACY_DEBUGFS /* debugfs */ u16 tx_traffic_idx; @@ -1492,7 +1478,7 @@ struct il_priv { struct dentry *debugfs_dir; u32 dbgfs_sram_offset, dbgfs_sram_len; bool disable_ht40; -#endif /* CONFIG_IWLEGACY_DEBUGFS */ +#endif /* CONFIG_IWLEGACY_DEBUGFS */ struct work_struct txpower_work; u32 disable_sens_cal; @@ -1506,25 +1492,26 @@ struct il_priv { struct led_classdev led; unsigned long blink_on, blink_off; bool led_registered; -}; /*il_priv */ +}; /*il_priv */ -static inline void il_txq_ctx_activate(struct il_priv *il, int txq_id) +static inline void +il_txq_ctx_activate(struct il_priv *il, int txq_id) { set_bit(txq_id, &il->txq_ctx_active_msk); } -static inline void il_txq_ctx_deactivate(struct il_priv *il, int txq_id) +static inline void +il_txq_ctx_deactivate(struct il_priv *il, int txq_id) { clear_bit(txq_id, &il->txq_ctx_active_msk); } static inline struct ieee80211_hdr * -il_tx_queue_get_hdr(struct il_priv *il, - int txq_id, int idx) +il_tx_queue_get_hdr(struct il_priv *il, int txq_id, int idx) { if (il->txq[txq_id].txb[idx].skb) - return (struct ieee80211_hdr *)il->txq[txq_id]. - txb[idx].skb->data; + return (struct ieee80211_hdr *)il->txq[txq_id].txb[idx].skb-> + data; return NULL; } @@ -1539,34 +1526,40 @@ il_rxon_ctx_from_vif(struct ieee80211_vif *vif) #define for_each_context(il, _ctx) \ for (_ctx = &il->ctx; _ctx == &il->ctx; _ctx++) -static inline int il_is_associated(struct il_priv *il) +static inline int +il_is_associated(struct il_priv *il) { return (il->ctx.active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; } -static inline int il_is_any_associated(struct il_priv *il) +static inline int +il_is_any_associated(struct il_priv *il) { return il_is_associated(il); } -static inline int il_is_associated_ctx(struct il_rxon_context *ctx) +static inline int +il_is_associated_ctx(struct il_rxon_context *ctx) { return (ctx->active.filter_flags & RXON_FILTER_ASSOC_MSK) ? 1 : 0; } -static inline int il_is_channel_valid(const struct il_channel_info *ch_info) +static inline int +il_is_channel_valid(const struct il_channel_info *ch_info) { if (ch_info == NULL) return 0; return (ch_info->flags & EEPROM_CHANNEL_VALID) ? 1 : 0; } -static inline int il_is_channel_radar(const struct il_channel_info *ch_info) +static inline int +il_is_channel_radar(const struct il_channel_info *ch_info) { return (ch_info->flags & EEPROM_CHANNEL_RADAR) ? 1 : 0; } -static inline u8 il_is_channel_a_band(const struct il_channel_info *ch_info) +static inline u8 +il_is_channel_a_band(const struct il_channel_info *ch_info) { return ch_info->band == IEEE80211_BAND_5GHZ; } @@ -1583,7 +1576,6 @@ il_is_channel_ibss(const struct il_channel_info *ch) return (ch->flags & EEPROM_CHANNEL_IBSS) ? 1 : 0; } - static inline void __il_free_pages(struct il_priv *il, struct page *page) { @@ -1591,7 +1583,8 @@ __il_free_pages(struct il_priv *il, struct page *page) il->alloc_rxb_page--; } -static inline void il_free_pages(struct il_priv *il, unsigned long page) +static inline void +il_free_pages(struct il_priv *il, unsigned long page) { free_pages(page, il->hw_params.rx_page_order); il->alloc_rxb_page--; @@ -1615,77 +1608,74 @@ static inline void il_free_pages(struct il_priv *il, unsigned long page) #define IL_CMD(x) case x: return #x /* Size of one Rx buffer in host DRAM */ -#define IL_RX_BUF_SIZE_3K (3 * 1000) /* 3945 only */ +#define IL_RX_BUF_SIZE_3K (3 * 1000) /* 3945 only */ #define IL_RX_BUF_SIZE_4K (4 * 1024) #define IL_RX_BUF_SIZE_8K (8 * 1024) struct il_hcmd_ops { - int (*rxon_assoc)(struct il_priv *il, struct il_rxon_context *ctx); - int (*commit_rxon)(struct il_priv *il, struct il_rxon_context *ctx); - void (*set_rxon_chain)(struct il_priv *il, - struct il_rxon_context *ctx); + int (*rxon_assoc) (struct il_priv * il, struct il_rxon_context * ctx); + int (*commit_rxon) (struct il_priv * il, struct il_rxon_context * ctx); + void (*set_rxon_chain) (struct il_priv * il, + struct il_rxon_context * ctx); }; struct il_hcmd_utils_ops { - u16 (*get_hcmd_size)(u8 cmd_id, u16 len); - u16 (*build_addsta_hcmd)(const struct il_addsta_cmd *cmd, - u8 *data); - int (*request_scan)(struct il_priv *il, struct ieee80211_vif *vif); - void (*post_scan)(struct il_priv *il); + u16(*get_hcmd_size) (u8 cmd_id, u16 len); + u16(*build_addsta_hcmd) (const struct il_addsta_cmd * cmd, u8 * data); + int (*request_scan) (struct il_priv * il, struct ieee80211_vif * vif); + void (*post_scan) (struct il_priv * il); }; struct il_apm_ops { - int (*init)(struct il_priv *il); - void (*config)(struct il_priv *il); + int (*init) (struct il_priv * il); + void (*config) (struct il_priv * il); }; struct il_debugfs_ops { - ssize_t (*rx_stats_read)(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); - ssize_t (*tx_stats_read)(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); - ssize_t (*general_stats_read)(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos); + ssize_t(*rx_stats_read) (struct file * file, char __user * user_buf, + size_t count, loff_t * ppos); + ssize_t(*tx_stats_read) (struct file * file, char __user * user_buf, + size_t count, loff_t * ppos); + ssize_t(*general_stats_read) (struct file * file, + char __user * user_buf, size_t count, + loff_t * ppos); }; struct il_temp_ops { - void (*temperature)(struct il_priv *il); + void (*temperature) (struct il_priv * il); }; struct il_lib_ops { /* set hw dependent parameters */ - int (*set_hw_params)(struct il_priv *il); + int (*set_hw_params) (struct il_priv * il); /* Handling TX */ - void (*txq_update_byte_cnt_tbl)(struct il_priv *il, - struct il_tx_queue *txq, - u16 byte_cnt); - int (*txq_attach_buf_to_tfd)(struct il_priv *il, - struct il_tx_queue *txq, - dma_addr_t addr, - u16 len, u8 reset, u8 pad); - void (*txq_free_tfd)(struct il_priv *il, - struct il_tx_queue *txq); - int (*txq_init)(struct il_priv *il, - struct il_tx_queue *txq); + void (*txq_update_byte_cnt_tbl) (struct il_priv * il, + struct il_tx_queue * txq, + u16 byte_cnt); + int (*txq_attach_buf_to_tfd) (struct il_priv * il, + struct il_tx_queue * txq, dma_addr_t addr, + u16 len, u8 reset, u8 pad); + void (*txq_free_tfd) (struct il_priv * il, struct il_tx_queue * txq); + int (*txq_init) (struct il_priv * il, struct il_tx_queue * txq); /* setup Rx handler */ - void (*handler_setup)(struct il_priv *il); + void (*handler_setup) (struct il_priv * il); /* alive notification after init uCode load */ - void (*init_alive_start)(struct il_priv *il); + void (*init_alive_start) (struct il_priv * il); /* check validity of rtc data address */ - int (*is_valid_rtc_data_addr)(u32 addr); + int (*is_valid_rtc_data_addr) (u32 addr); /* 1st ucode load */ - int (*load_ucode)(struct il_priv *il); + int (*load_ucode) (struct il_priv * il); - void (*dump_nic_error_log)(struct il_priv *il); - int (*dump_fh)(struct il_priv *il, char **buf, bool display); - int (*set_channel_switch)(struct il_priv *il, - struct ieee80211_channel_switch *ch_switch); + void (*dump_nic_error_log) (struct il_priv * il); + int (*dump_fh) (struct il_priv * il, char **buf, bool display); + int (*set_channel_switch) (struct il_priv * il, + struct ieee80211_channel_switch * ch_switch); /* power management */ struct il_apm_ops apm_ops; /* power */ - int (*send_tx_power) (struct il_priv *il); - void (*update_chain_flags)(struct il_priv *il); + int (*send_tx_power) (struct il_priv * il); + void (*update_chain_flags) (struct il_priv * il); /* eeprom operations */ struct il_eeprom_ops eeprom_ops; @@ -1698,16 +1688,16 @@ struct il_lib_ops { }; struct il_led_ops { - int (*cmd)(struct il_priv *il, struct il_led_cmd *led_cmd); + int (*cmd) (struct il_priv * il, struct il_led_cmd * led_cmd); }; struct il_legacy_ops { - void (*post_associate)(struct il_priv *il); - void (*config_ap)(struct il_priv *il); + void (*post_associate) (struct il_priv * il); + void (*config_ap) (struct il_priv * il); /* station management */ - int (*update_bcast_stations)(struct il_priv *il); - int (*manage_ibss_station)(struct il_priv *il, - struct ieee80211_vif *vif, bool add); + int (*update_bcast_stations) (struct il_priv * il); + int (*manage_ibss_station) (struct il_priv * il, + struct ieee80211_vif * vif, bool add); }; struct il_ops { @@ -1726,7 +1716,7 @@ struct il_mod_params { int num_of_queues; /* def: HW dependent */ int disable_11n; /* def: 0 = 11n capabilities enabled */ int amsdu_size_8K; /* def: 1 = enable 8K amsdu size */ - int antenna; /* def: 0 = both antennas (use diversity) */ + int antenna; /* def: 0 = both antennas (use diversity) */ int restart_fw; /* def: 1 = restart firmware */ }; @@ -1746,7 +1736,7 @@ struct il_mod_params { struct il_base_params { int eeprom_size; int num_of_queues; /* def: HW dependent */ - int num_of_ampdu_queues;/* def: HW dependent */ + int num_of_ampdu_queues; /* def: HW dependent */ /* for il_apm_init() */ u32 pll_cfg_val; bool set_l0s; @@ -1821,11 +1811,11 @@ struct il_cfg { const char *fw_name_pre; const unsigned int ucode_api_max; const unsigned int ucode_api_min; - u8 valid_tx_ant; - u8 valid_rx_ant; + u8 valid_tx_ant; + u8 valid_rx_ant; unsigned int sku; - u16 eeprom_ver; - u16 eeprom_calib_ver; + u16 eeprom_ver; + u16 eeprom_calib_ver; const struct il_ops *ops; /* module based parameters which can be set from modprobe cmd */ const struct il_mod_params *mod_params; @@ -1841,46 +1831,33 @@ struct il_cfg { ***************************/ struct ieee80211_hw *il_alloc_all(struct il_cfg *cfg); -int il_mac_conf_tx(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, u16 queue, - const struct ieee80211_tx_queue_params *params); +int il_mac_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + u16 queue, const struct ieee80211_tx_queue_params *params); int il_mac_tx_last_beacon(struct ieee80211_hw *hw); -void il_set_rxon_hwcrypto(struct il_priv *il, - struct il_rxon_context *ctx, - int hw_decrypt); -int il_check_rxon_cmd(struct il_priv *il, - struct il_rxon_context *ctx); -int il_full_rxon_required(struct il_priv *il, - struct il_rxon_context *ctx); -int il_set_rxon_channel(struct il_priv *il, - struct ieee80211_channel *ch, + +void il_set_rxon_hwcrypto(struct il_priv *il, struct il_rxon_context *ctx, + int hw_decrypt); +int il_check_rxon_cmd(struct il_priv *il, struct il_rxon_context *ctx); +int il_full_rxon_required(struct il_priv *il, struct il_rxon_context *ctx); +int il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch, struct il_rxon_context *ctx); -void il_set_flags_for_band(struct il_priv *il, - struct il_rxon_context *ctx, - enum ieee80211_band band, - struct ieee80211_vif *vif); -u8 il_get_single_channel_number(struct il_priv *il, - enum ieee80211_band band); -void il_set_rxon_ht(struct il_priv *il, - struct il_ht_config *ht_conf); -bool il_is_ht40_tx_allowed(struct il_priv *il, - struct il_rxon_context *ctx, - struct ieee80211_sta_ht_cap *ht_cap); +void il_set_flags_for_band(struct il_priv *il, struct il_rxon_context *ctx, + enum ieee80211_band band, struct ieee80211_vif *vif); +u8 il_get_single_channel_number(struct il_priv *il, enum ieee80211_band band); +void il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf); +bool il_is_ht40_tx_allowed(struct il_priv *il, struct il_rxon_context *ctx, + struct ieee80211_sta_ht_cap *ht_cap); void il_connection_init_rx_config(struct il_priv *il, - struct il_rxon_context *ctx); + struct il_rxon_context *ctx); void il_set_rate(struct il_priv *il); -int il_set_decrypted_flag(struct il_priv *il, - struct ieee80211_hdr *hdr, - u32 decrypt_res, - struct ieee80211_rx_status *stats); +int il_set_decrypted_flag(struct il_priv *il, struct ieee80211_hdr *hdr, + u32 decrypt_res, struct ieee80211_rx_status *stats); void il_irq_handle_error(struct il_priv *il); -int il_mac_add_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif); +int il_mac_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif); void il_mac_remove_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif); -int il_mac_change_interface(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - enum nl80211_iftype newtype, bool newp2p); + struct ieee80211_vif *vif); +int il_mac_change_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + enum nl80211_iftype newtype, bool newp2p); int il_alloc_txq_mem(struct il_priv *il); void il_txq_mem(struct il_priv *il); @@ -1888,48 +1865,54 @@ void il_txq_mem(struct il_priv *il); int il_alloc_traffic_mem(struct il_priv *il); void il_free_traffic_mem(struct il_priv *il); void il_reset_traffic_log(struct il_priv *il); -void il_dbg_log_tx_data_frame(struct il_priv *il, - u16 length, struct ieee80211_hdr *header); -void il_dbg_log_rx_data_frame(struct il_priv *il, - u16 length, struct ieee80211_hdr *header); +void il_dbg_log_tx_data_frame(struct il_priv *il, u16 length, + struct ieee80211_hdr *header); +void il_dbg_log_rx_data_frame(struct il_priv *il, u16 length, + struct ieee80211_hdr *header); const char *il_get_mgmt_string(int cmd); const char *il_get_ctrl_string(int cmd); void il_clear_traffic_stats(struct il_priv *il); -void il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, - u16 len); +void il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, u16 len); #else -static inline int il_alloc_traffic_mem(struct il_priv *il) +static inline int +il_alloc_traffic_mem(struct il_priv *il) { return 0; } -static inline void il_free_traffic_mem(struct il_priv *il) + +static inline void +il_free_traffic_mem(struct il_priv *il) { } -static inline void il_reset_traffic_log(struct il_priv *il) + +static inline void +il_reset_traffic_log(struct il_priv *il) { } -static inline void il_dbg_log_tx_data_frame(struct il_priv *il, - u16 length, struct ieee80211_hdr *header) + +static inline void +il_dbg_log_tx_data_frame(struct il_priv *il, u16 length, + struct ieee80211_hdr *header) { } -static inline void il_dbg_log_rx_data_frame(struct il_priv *il, - u16 length, struct ieee80211_hdr *header) + +static inline void +il_dbg_log_rx_data_frame(struct il_priv *il, u16 length, + struct ieee80211_hdr *header) { } -static inline void il_update_stats(struct il_priv *il, bool is_tx, - __le16 fc, u16 len) + +static inline void +il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, u16 len) { } #endif /***************************************************** * RX handlers. * **************************************************/ -void il_hdl_pm_sleep(struct il_priv *il, - struct il_rx_buf *rxb); -void il_hdl_pm_debug_stats(struct il_priv *il, - struct il_rx_buf *rxb); -void il_hdl_error(struct il_priv *il, - struct il_rx_buf *rxb); +void il_hdl_pm_sleep(struct il_priv *il, struct il_rx_buf *rxb); +void il_hdl_pm_debug_stats(struct il_priv *il, struct il_rx_buf *rxb); +void il_hdl_error(struct il_priv *il, struct il_rx_buf *rxb); /***************************************************** * RX @@ -1937,16 +1920,12 @@ void il_hdl_error(struct il_priv *il, void il_cmd_queue_unmap(struct il_priv *il); void il_cmd_queue_free(struct il_priv *il); int il_rx_queue_alloc(struct il_priv *il); -void il_rx_queue_update_write_ptr(struct il_priv *il, - struct il_rx_queue *q); +void il_rx_queue_update_write_ptr(struct il_priv *il, struct il_rx_queue *q); int il_rx_queue_space(const struct il_rx_queue *q); -void il_tx_cmd_complete(struct il_priv *il, - struct il_rx_buf *rxb); +void il_tx_cmd_complete(struct il_priv *il, struct il_rx_buf *rxb); /* Handlers */ -void il_hdl_spectrum_measurement(struct il_priv *il, - struct il_rx_buf *rxb); -void il_recover_from_stats(struct il_priv *il, - struct il_rx_pkt *pkt); +void il_hdl_spectrum_measurement(struct il_priv *il, struct il_rx_buf *rxb); +void il_recover_from_stats(struct il_priv *il, struct il_rx_pkt *pkt); void il_chswitch_done(struct il_priv *il, bool is_success); void il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb); @@ -1955,13 +1934,11 @@ void il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb); /***************************************************** * TX ******************************************************/ -void il_txq_update_write_ptr(struct il_priv *il, - struct il_tx_queue *txq); -int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, - int slots_num, u32 txq_id); -void il_tx_queue_reset(struct il_priv *il, - struct il_tx_queue *txq, - int slots_num, u32 txq_id); +void il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq); +int il_tx_queue_init(struct il_priv *il, struct il_tx_queue *txq, int slots_num, + u32 txq_id); +void il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, + int slots_num, u32 txq_id); void il_tx_queue_unmap(struct il_priv *il, int txq_id); void il_tx_queue_free(struct il_priv *il, int txq_id); void il_setup_watchdog(struct il_priv *il); @@ -1974,8 +1951,7 @@ int il_set_tx_power(struct il_priv *il, s8 tx_power, bool force); * Rate ******************************************************************************/ -u8 il_get_lowest_plcp(struct il_priv *il, - struct il_rxon_context *ctx); +u8 il_get_lowest_plcp(struct il_priv *il, struct il_rxon_context *ctx); /******************************************************************************* * Scanning @@ -1984,21 +1960,17 @@ void il_init_scan_params(struct il_priv *il); int il_scan_cancel(struct il_priv *il); int il_scan_cancel_timeout(struct il_priv *il, unsigned long ms); void il_force_scan_end(struct il_priv *il); -int il_mac_hw_scan(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct cfg80211_scan_request *req); +int il_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct cfg80211_scan_request *req); void il_internal_short_hw_scan(struct il_priv *il); int il_force_reset(struct il_priv *il, bool external); -u16 il_fill_probe_req(struct il_priv *il, - struct ieee80211_mgmt *frame, - const u8 *ta, const u8 *ie, int ie_len, int left); +u16 il_fill_probe_req(struct il_priv *il, struct ieee80211_mgmt *frame, + const u8 * ta, const u8 * ie, int ie_len, int left); void il_setup_rx_scan_handlers(struct il_priv *il); -u16 il_get_active_dwell_time(struct il_priv *il, - enum ieee80211_band band, - u8 n_probes); -u16 il_get_passive_dwell_time(struct il_priv *il, - enum ieee80211_band band, - struct ieee80211_vif *vif); +u16 il_get_active_dwell_time(struct il_priv *il, enum ieee80211_band band, + u8 n_probes); +u16 il_get_passive_dwell_time(struct il_priv *il, enum ieee80211_band band, + struct ieee80211_vif *vif); void il_setup_scan_deferred_work(struct il_priv *il); void il_cancel_scan_deferred_work(struct il_priv *il); @@ -2008,8 +1980,8 @@ void il_cancel_scan_deferred_work(struct il_priv *il); * time if it's a quiet channel (nothing responded to our probe, and there's * no other traffic). * Disable "quiet" feature by setting PLCP_QUIET_THRESH to 0. */ -#define IL_ACTIVE_QUIET_TIME cpu_to_le16(10) /* msec */ -#define IL_PLCP_QUIET_THRESH cpu_to_le16(1) /* packets */ +#define IL_ACTIVE_QUIET_TIME cpu_to_le16(10) /* msec */ +#define IL_PLCP_QUIET_THRESH cpu_to_le16(1) /* packets */ #define IL_SCAN_CHECK_WATCHDOG (HZ * 7) @@ -2018,25 +1990,23 @@ void il_cancel_scan_deferred_work(struct il_priv *il); *****************************************************/ const char *il_get_cmd_string(u8 cmd); -int __must_check il_send_cmd_sync(struct il_priv *il, - struct il_host_cmd *cmd); +int __must_check il_send_cmd_sync(struct il_priv *il, struct il_host_cmd *cmd); int il_send_cmd(struct il_priv *il, struct il_host_cmd *cmd); -int __must_check il_send_cmd_pdu(struct il_priv *il, u8 id, - u16 len, const void *data); -int il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, - const void *data, - void (*callback)(struct il_priv *il, - struct il_device_cmd *cmd, - struct il_rx_pkt *pkt)); +int __must_check il_send_cmd_pdu(struct il_priv *il, u8 id, u16 len, + const void *data); +int il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, const void *data, + void (*callback) (struct il_priv * il, + struct il_device_cmd * cmd, + struct il_rx_pkt * pkt)); int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd); - /***************************************************** * PCI * *****************************************************/ -static inline u16 il_pcie_link_ctl(struct il_priv *il) +static inline u16 +il_pcie_link_ctl(struct il_priv *il) { int pos; u16 pci_lnk_ctl; @@ -2046,10 +2016,9 @@ static inline u16 il_pcie_link_ctl(struct il_priv *il) } void il_bg_watchdog(unsigned long data); -u32 il_usecs_to_beacons(struct il_priv *il, - u32 usec, u32 beacon_interval); -__le32 il_add_beacon_time(struct il_priv *il, u32 base, - u32 addon, u32 beacon_interval); +u32 il_usecs_to_beacons(struct il_priv *il, u32 usec, u32 beacon_interval); +__le32 il_add_beacon_time(struct il_priv *il, u32 base, u32 addon, + u32 beacon_interval); #ifdef CONFIG_PM int il_pci_suspend(struct device *device); @@ -2069,11 +2038,10 @@ extern const struct dev_pm_ops il_pm_ops; ******************************************************/ void il4965_dump_nic_error_log(struct il_priv *il); #ifdef CONFIG_IWLEGACY_DEBUG -void il_print_rx_config_cmd(struct il_priv *il, - struct il_rxon_context *ctx); +void il_print_rx_config_cmd(struct il_priv *il, struct il_rxon_context *ctx); #else -static inline void il_print_rx_config_cmd(struct il_priv *il, - struct il_rxon_context *ctx) +static inline void +il_print_rx_config_cmd(struct il_priv *il, struct il_rxon_context *ctx) { } #endif @@ -2107,41 +2075,48 @@ void il_free_geos(struct il_priv *il); #define S_FW_ERROR 17 #define S_CHANNEL_SWITCH_PENDING 18 -static inline int il_is_ready(struct il_priv *il) +static inline int +il_is_ready(struct il_priv *il) { /* The adapter is 'ready' if READY and GEO_CONFIGURED bits are * set but EXIT_PENDING is not */ return test_bit(S_READY, &il->status) && - test_bit(S_GEO_CONFIGURED, &il->status) && - !test_bit(S_EXIT_PENDING, &il->status); + test_bit(S_GEO_CONFIGURED, &il->status) && + !test_bit(S_EXIT_PENDING, &il->status); } -static inline int il_is_alive(struct il_priv *il) +static inline int +il_is_alive(struct il_priv *il) { return test_bit(S_ALIVE, &il->status); } -static inline int il_is_init(struct il_priv *il) +static inline int +il_is_init(struct il_priv *il) { return test_bit(S_INIT, &il->status); } -static inline int il_is_rfkill_hw(struct il_priv *il) +static inline int +il_is_rfkill_hw(struct il_priv *il) { return test_bit(S_RF_KILL_HW, &il->status); } -static inline int il_is_rfkill(struct il_priv *il) +static inline int +il_is_rfkill(struct il_priv *il) { return il_is_rfkill_hw(il); } -static inline int il_is_ctkill(struct il_priv *il) +static inline int +il_is_ctkill(struct il_priv *il) { return test_bit(S_CT_KILL, &il->status); } -static inline int il_is_ready_rf(struct il_priv *il) +static inline int +il_is_ready_rf(struct il_priv *il) { if (il_is_rfkill(il)) @@ -2151,66 +2126,63 @@ static inline int il_is_ready_rf(struct il_priv *il) } extern void il_send_bt_config(struct il_priv *il); -extern int il_send_stats_request(struct il_priv *il, - u8 flags, bool clear); +extern int il_send_stats_request(struct il_priv *il, u8 flags, bool clear); void il_apm_stop(struct il_priv *il); int il_apm_init(struct il_priv *il); -int il_send_rxon_timing(struct il_priv *il, - struct il_rxon_context *ctx); -static inline int il_send_rxon_assoc(struct il_priv *il, - struct il_rxon_context *ctx) +int il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx); +static inline int +il_send_rxon_assoc(struct il_priv *il, struct il_rxon_context *ctx) { return il->cfg->ops->hcmd->rxon_assoc(il, ctx); } -static inline int il_commit_rxon(struct il_priv *il, - struct il_rxon_context *ctx) + +static inline int +il_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx) { return il->cfg->ops->hcmd->commit_rxon(il, ctx); } -static inline const struct ieee80211_supported_band *il_get_hw_mode( - struct il_priv *il, enum ieee80211_band band) + +static inline const struct ieee80211_supported_band * +il_get_hw_mode(struct il_priv *il, enum ieee80211_band band) { return il->hw->wiphy->bands[band]; } /* mac80211 handlers */ int il_mac_config(struct ieee80211_hw *hw, u32 changed); -void il_mac_reset_tsf(struct ieee80211_hw *hw, - struct ieee80211_vif *vif); -void il_mac_bss_info_changed(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_bss_conf *bss_conf, - u32 changes); -void il_tx_cmd_protection(struct il_priv *il, - struct ieee80211_tx_info *info, - __le16 fc, __le32 *tx_flags); +void il_mac_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif); +void il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_bss_conf *bss_conf, u32 changes); +void il_tx_cmd_protection(struct il_priv *il, struct ieee80211_tx_info *info, + __le16 fc, __le32 * tx_flags); irqreturn_t il_isr(int irq, void *data); - #include -static inline void _il_write8(struct il_priv *il, u32 ofs, u8 val) +static inline void +_il_write8(struct il_priv *il, u32 ofs, u8 val) { iowrite8(val, il->hw_base + ofs); } #define il_write8(il, ofs, val) _il_write8(il, ofs, val) -static inline void _il_wr(struct il_priv *il, u32 ofs, u32 val) +static inline void +_il_wr(struct il_priv *il, u32 ofs, u32 val) { iowrite32(val, il->hw_base + ofs); } -static inline u32 _il_rd(struct il_priv *il, u32 ofs) +static inline u32 +_il_rd(struct il_priv *il, u32 ofs) { return ioread32(il->hw_base + ofs); } #define IL_POLL_INTERVAL 10 /* microseconds */ static inline int -_il_poll_bit(struct il_priv *il, u32 addr, - u32 bits, u32 mask, int timeout) +_il_poll_bit(struct il_priv *il, u32 addr, u32 bits, u32 mask, int timeout) { int t = 0; @@ -2219,17 +2191,20 @@ _il_poll_bit(struct il_priv *il, u32 addr, return t; udelay(IL_POLL_INTERVAL); t += IL_POLL_INTERVAL; - } while (t < timeout); + } + while (t < timeout); return -ETIMEDOUT; } -static inline void _il_set_bit(struct il_priv *il, u32 reg, u32 mask) +static inline void +_il_set_bit(struct il_priv *il, u32 reg, u32 mask) { _il_wr(il, reg, _il_rd(il, reg) | mask); } -static inline void il_set_bit(struct il_priv *p, u32 r, u32 m) +static inline void +il_set_bit(struct il_priv *p, u32 r, u32 m) { unsigned long reg_flags; @@ -2244,7 +2219,8 @@ _il_clear_bit(struct il_priv *il, u32 reg, u32 mask) _il_wr(il, reg, _il_rd(il, reg) & ~mask); } -static inline void il_clear_bit(struct il_priv *p, u32 r, u32 m) +static inline void +il_clear_bit(struct il_priv *p, u32 r, u32 m) { unsigned long reg_flags; @@ -2253,14 +2229,14 @@ static inline void il_clear_bit(struct il_priv *p, u32 r, u32 m) spin_unlock_irqrestore(&p->reg_lock, reg_flags); } -static inline int _il_grab_nic_access(struct il_priv *il) +static inline int +_il_grab_nic_access(struct il_priv *il) { int ret; u32 val; /* this bit wakes up the NIC */ - _il_set_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); + _il_set_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); /* * These bits say the device is running, and should keep running for @@ -2279,29 +2255,28 @@ static inline int _il_grab_nic_access(struct il_priv *il) * good idea before accessing 3945/4965 SRAM (e.g. reading Event Log). * */ - ret = _il_poll_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN, - (CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY | - CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 15000); + ret = + _il_poll_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN, + (CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY | + CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP), 15000); if (ret < 0) { val = _il_rd(il, CSR_GP_CNTRL); - IL_ERR( - "MAC is in deep sleep!. CSR_GP_CNTRL = 0x%08X\n", val); - _il_wr(il, CSR_RESET, - CSR_RESET_REG_FLAG_FORCE_NMI); + IL_ERR("MAC is in deep sleep!. CSR_GP_CNTRL = 0x%08X\n", val); + _il_wr(il, CSR_RESET, CSR_RESET_REG_FLAG_FORCE_NMI); return -EIO; } return 0; } -static inline void _il_release_nic_access(struct il_priv *il) +static inline void +_il_release_nic_access(struct il_priv *il) { - _il_clear_bit(il, CSR_GP_CNTRL, - CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); + _il_clear_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); } -static inline u32 il_rd(struct il_priv *il, u32 reg) +static inline u32 +il_rd(struct il_priv *il, u32 reg) { u32 value; unsigned long reg_flags; @@ -2328,8 +2303,8 @@ il_wr(struct il_priv *il, u32 reg, u32 value) spin_unlock_irqrestore(&il->reg_lock, reg_flags); } -static inline void il_write_reg_buf(struct il_priv *il, - u32 reg, u32 len, u32 *values) +static inline void +il_write_reg_buf(struct il_priv *il, u32 reg, u32 len, u32 * values) { u32 count = sizeof(u32); @@ -2339,8 +2314,8 @@ static inline void il_write_reg_buf(struct il_priv *il, } } -static inline int il_poll_bit(struct il_priv *il, u32 addr, - u32 mask, int timeout) +static inline int +il_poll_bit(struct il_priv *il, u32 addr, u32 mask, int timeout) { int t = 0; @@ -2349,19 +2324,22 @@ static inline int il_poll_bit(struct il_priv *il, u32 addr, return t; udelay(IL_POLL_INTERVAL); t += IL_POLL_INTERVAL; - } while (t < timeout); + } + while (t < timeout); return -ETIMEDOUT; } -static inline u32 _il_rd_prph(struct il_priv *il, u32 reg) +static inline u32 +_il_rd_prph(struct il_priv *il, u32 reg) { _il_wr(il, HBUS_TARG_PRPH_RADDR, reg | (3 << 24)); rmb(); return _il_rd(il, HBUS_TARG_PRPH_RDAT); } -static inline u32 il_rd_prph(struct il_priv *il, u32 reg) +static inline u32 +il_rd_prph(struct il_priv *il, u32 reg) { unsigned long reg_flags; u32 val; @@ -2374,11 +2352,10 @@ static inline u32 il_rd_prph(struct il_priv *il, u32 reg) return val; } -static inline void _il_wr_prph(struct il_priv *il, - u32 addr, u32 val) +static inline void +_il_wr_prph(struct il_priv *il, u32 addr, u32 val) { - _il_wr(il, HBUS_TARG_PRPH_WADDR, - ((addr & 0x0000FFFF) | (3 << 24))); + _il_wr(il, HBUS_TARG_PRPH_WADDR, ((addr & 0x0000FFFF) | (3 << 24))); wmb(); _il_wr(il, HBUS_TARG_PRPH_WDAT, val); } @@ -2415,8 +2392,8 @@ il_set_bits_prph(struct il_priv *il, u32 reg, u32 mask) _il_wr_prph(il, reg, \ ((_il_rd_prph(il, reg) & mask) | bits)) -static inline void il_set_bits_mask_prph(struct il_priv *il, u32 reg, - u32 bits, u32 mask) +static inline void +il_set_bits_mask_prph(struct il_priv *il, u32 reg, u32 bits, u32 mask) { unsigned long reg_flags; @@ -2427,8 +2404,8 @@ static inline void il_set_bits_mask_prph(struct il_priv *il, u32 reg, spin_unlock_irqrestore(&il->reg_lock, reg_flags); } -static inline void il_clear_bits_prph(struct il_priv - *il, u32 reg, u32 mask) +static inline void +il_clear_bits_prph(struct il_priv *il, u32 reg, u32 mask) { unsigned long reg_flags; u32 val; @@ -2441,7 +2418,8 @@ static inline void il_clear_bits_prph(struct il_priv spin_unlock_irqrestore(&il->reg_lock, reg_flags); } -static inline u32 il_read_targ_mem(struct il_priv *il, u32 addr) +static inline u32 +il_read_targ_mem(struct il_priv *il, u32 addr) { unsigned long reg_flags; u32 value; @@ -2474,8 +2452,7 @@ il_write_targ_mem(struct il_priv *il, u32 addr, u32 val) } static inline void -il_write_targ_mem_buf(struct il_priv *il, u32 addr, - u32 len, u32 *values) +il_write_targ_mem_buf(struct il_priv *il, u32 addr, u32 len, u32 * values) { unsigned long reg_flags; @@ -2484,8 +2461,7 @@ il_write_targ_mem_buf(struct il_priv *il, u32 addr, _il_wr(il, HBUS_TARG_MEM_WADDR, addr); wmb(); for (; 0 < len; len -= sizeof(u32), values++) - _il_wr(il, - HBUS_TARG_MEM_WDAT, *values); + _il_wr(il, HBUS_TARG_MEM_WDAT, *values); _il_release_nic_access(il); } @@ -2495,43 +2471,31 @@ il_write_targ_mem_buf(struct il_priv *il, u32 addr, #define HW_KEY_DYNAMIC 0 #define HW_KEY_DEFAULT 1 -#define IL_STA_DRIVER_ACTIVE BIT(0) /* driver entry is active */ -#define IL_STA_UCODE_ACTIVE BIT(1) /* ucode entry is active */ -#define IL_STA_UCODE_INPROGRESS BIT(2) /* ucode entry is in process of - being activated */ -#define IL_STA_LOCAL BIT(3) /* station state not directed by mac80211; - (this is for the IBSS BSSID stations) */ -#define IL_STA_BCAST BIT(4) /* this station is the special bcast station */ +#define IL_STA_DRIVER_ACTIVE BIT(0) /* driver entry is active */ +#define IL_STA_UCODE_ACTIVE BIT(1) /* ucode entry is active */ +#define IL_STA_UCODE_INPROGRESS BIT(2) /* ucode entry is in process of + being activated */ +#define IL_STA_LOCAL BIT(3) /* station state not directed by mac80211; + (this is for the IBSS BSSID stations) */ +#define IL_STA_BCAST BIT(4) /* this station is the special bcast station */ - -void il_restore_stations(struct il_priv *il, - struct il_rxon_context *ctx); -void il_clear_ucode_stations(struct il_priv *il, - struct il_rxon_context *ctx); +void il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx); +void il_clear_ucode_stations(struct il_priv *il, struct il_rxon_context *ctx); void il_dealloc_bcast_stations(struct il_priv *il); int il_get_free_ucode_key_idx(struct il_priv *il); -int il_send_add_sta(struct il_priv *il, - struct il_addsta_cmd *sta, u8 flags); -int il_add_station_common(struct il_priv *il, - struct il_rxon_context *ctx, - const u8 *addr, bool is_ap, - struct ieee80211_sta *sta, u8 *sta_id_r); -int il_remove_station(struct il_priv *il, - const u8 sta_id, - const u8 *addr); -int il_mac_sta_remove(struct ieee80211_hw *hw, - struct ieee80211_vif *vif, - struct ieee80211_sta *sta); - -u8 il_prep_station(struct il_priv *il, - struct il_rxon_context *ctx, - const u8 *addr, bool is_ap, - struct ieee80211_sta *sta); - -int il_send_lq_cmd(struct il_priv *il, - struct il_rxon_context *ctx, - struct il_link_quality_cmd *lq, - u8 flags, bool init); +int il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags); +int il_add_station_common(struct il_priv *il, struct il_rxon_context *ctx, + const u8 * addr, bool is_ap, + struct ieee80211_sta *sta, u8 * sta_id_r); +int il_remove_station(struct il_priv *il, const u8 sta_id, const u8 * addr); +int il_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_sta *sta); + +u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, + const u8 * addr, bool is_ap, struct ieee80211_sta *sta); + +int il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, + struct il_link_quality_cmd *lq, u8 flags, bool init); /** * il_clear_driver_stations - clear knowledge of all stations from driver @@ -2542,7 +2506,8 @@ int il_send_lq_cmd(struct il_priv *il, * able to reconfigure stations -- if we're getting there in the * normal down flow then the stations will already be cleared. */ -static inline void il_clear_driver_stations(struct il_priv *il) +static inline void +il_clear_driver_stations(struct il_priv *il) { unsigned long flags; struct il_rxon_context *ctx = &il->ctx; @@ -2566,7 +2531,8 @@ static inline void il_clear_driver_stations(struct il_priv *il) spin_unlock_irqrestore(&il->sta_lock, flags); } -static inline int il_sta_id(struct ieee80211_sta *sta) +static inline int +il_sta_id(struct ieee80211_sta *sta) { if (WARN_ON(!sta)) return IL_INVALID_STATION; @@ -2585,9 +2551,9 @@ static inline int il_sta_id(struct ieee80211_sta *sta) * that case, we need to use the broadcast station, so this * inline wraps that pattern. */ -static inline int il_sta_id_or_broadcast(struct il_priv *il, - struct il_rxon_context *context, - struct ieee80211_sta *sta) +static inline int +il_sta_id_or_broadcast(struct il_priv *il, struct il_rxon_context *context, + struct ieee80211_sta *sta) { int sta_id; @@ -2610,7 +2576,8 @@ static inline int il_sta_id_or_broadcast(struct il_priv *il, * @idx -- current idx * @n_bd -- total number of entries in queue (must be power of 2) */ -static inline int il_queue_inc_wrap(int idx, int n_bd) +static inline int +il_queue_inc_wrap(int idx, int n_bd) { return ++idx & (n_bd - 1); } @@ -2620,32 +2587,34 @@ static inline int il_queue_inc_wrap(int idx, int n_bd) * @idx -- current idx * @n_bd -- total number of entries in queue (must be power of 2) */ -static inline int il_queue_dec_wrap(int idx, int n_bd) +static inline int +il_queue_dec_wrap(int idx, int n_bd) { return --idx & (n_bd - 1); } /* TODO: Move fw_desc functions to iwl-pci.ko */ -static inline void il_free_fw_desc(struct pci_dev *pci_dev, - struct fw_desc *desc) +static inline void +il_free_fw_desc(struct pci_dev *pci_dev, struct fw_desc *desc) { if (desc->v_addr) - dma_free_coherent(&pci_dev->dev, desc->len, - desc->v_addr, desc->p_addr); + dma_free_coherent(&pci_dev->dev, desc->len, desc->v_addr, + desc->p_addr); desc->v_addr = NULL; desc->len = 0; } -static inline int il_alloc_fw_desc(struct pci_dev *pci_dev, - struct fw_desc *desc) +static inline int +il_alloc_fw_desc(struct pci_dev *pci_dev, struct fw_desc *desc) { if (!desc->len) { desc->v_addr = NULL; return -EINVAL; } - desc->v_addr = dma_alloc_coherent(&pci_dev->dev, desc->len, - &desc->p_addr, GFP_KERNEL); + desc->v_addr = + dma_alloc_coherent(&pci_dev->dev, desc->len, &desc->p_addr, + GFP_KERNEL); return (desc->v_addr != NULL) ? 0 : -ENOMEM; } @@ -2663,14 +2632,14 @@ static inline int il_alloc_fw_desc(struct pci_dev *pci_dev, static inline void il_set_swq_id(struct il_tx_queue *txq, u8 ac, u8 hwq) { - BUG_ON(ac > 3); /* only have 2 bits */ - BUG_ON(hwq > 31); /* only use 5 bits */ + BUG_ON(ac > 3); /* only have 2 bits */ + BUG_ON(hwq > 31); /* only use 5 bits */ txq->swq_id = (hwq << 2) | ac; } -static inline void il_wake_queue(struct il_priv *il, - struct il_tx_queue *txq) +static inline void +il_wake_queue(struct il_priv *il, struct il_tx_queue *txq) { u8 queue = txq->swq_id; u8 ac = queue & 3; @@ -2681,8 +2650,8 @@ static inline void il_wake_queue(struct il_priv *il, ieee80211_wake_queue(il->hw, ac); } -static inline void il_stop_queue(struct il_priv *il, - struct il_tx_queue *txq) +static inline void +il_stop_queue(struct il_priv *il, struct il_tx_queue *txq) { u8 queue = txq->swq_id; u8 ac = queue & 3; @@ -2705,7 +2674,8 @@ static inline void il_stop_queue(struct il_priv *il, #define ieee80211_wake_queue DO_NOT_USE_ieee80211_wake_queue -static inline void il_disable_interrupts(struct il_priv *il) +static inline void +il_disable_interrupts(struct il_priv *il) { clear_bit(S_INT_ENABLED, &il->status); @@ -2718,12 +2688,14 @@ static inline void il_disable_interrupts(struct il_priv *il) _il_wr(il, CSR_FH_INT_STATUS, 0xffffffff); } -static inline void il_enable_rfkill_int(struct il_priv *il) +static inline void +il_enable_rfkill_int(struct il_priv *il) { _il_wr(il, CSR_INT_MASK, CSR_INT_BIT_RF_KILL); } -static inline void il_enable_interrupts(struct il_priv *il) +static inline void +il_enable_interrupts(struct il_priv *il) { set_bit(S_INT_ENABLED, &il->status); _il_wr(il, CSR_INT_MASK, il->inta_mask); @@ -2734,8 +2706,8 @@ static inline void il_enable_interrupts(struct il_priv *il) * @il -- pointer to il_priv data structure * @tsf_bits -- number of bits need to shift for masking) */ -static inline u32 il_beacon_time_mask_low(struct il_priv *il, - u16 tsf_bits) +static inline u32 +il_beacon_time_mask_low(struct il_priv *il, u16 tsf_bits) { return (1 << tsf_bits) - 1; } @@ -2745,8 +2717,8 @@ static inline u32 il_beacon_time_mask_low(struct il_priv *il, * @il -- pointer to il_priv data structure * @tsf_bits -- number of bits need to shift for masking) */ -static inline u32 il_beacon_time_mask_high(struct il_priv *il, - u16 tsf_bits) +static inline u32 +il_beacon_time_mask_high(struct il_priv *il, u16 tsf_bits) { return ((1 << (32 - tsf_bits)) - 1) << tsf_bits; } @@ -2766,20 +2738,21 @@ struct il_rb_status { __le16 closed_fr_num; __le16 finished_rb_num; __le16 finished_fr_nam; - __le32 __unused; /* 3945 only */ + __le32 __unused; /* 3945 only */ } __packed; - #define TFD_QUEUE_SIZE_MAX (256) #define TFD_QUEUE_SIZE_BC_DUP (64) #define TFD_QUEUE_BC_SIZE (TFD_QUEUE_SIZE_MAX + TFD_QUEUE_SIZE_BC_DUP) #define IL_TX_DMA_MASK DMA_BIT_MASK(36) #define IL_NUM_OF_TBS 20 -static inline u8 il_get_dma_hi_addr(dma_addr_t addr) +static inline u8 +il_get_dma_hi_addr(dma_addr_t addr) { return (sizeof(addr) > sizeof(u32) ? (addr >> 16) >> 16 : 0) & 0xF; } + /** * struct il_tfd_tb transmit buffer descriptor within transmit frame descriptor * @@ -2837,16 +2810,16 @@ struct il_tfd { #define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02 struct il_rate_info { - u8 plcp; /* uCode API: RATE_6M_PLCP, etc. */ - u8 plcp_siso; /* uCode API: RATE_SISO_6M_PLCP, etc. */ - u8 plcp_mimo2; /* uCode API: RATE_MIMO2_6M_PLCP, etc. */ - u8 ieee; /* MAC header: RATE_6M_IEEE, etc. */ - u8 prev_ieee; /* previous rate in IEEE speeds */ - u8 next_ieee; /* next rate in IEEE speeds */ - u8 prev_rs; /* previous rate used in rs algo */ - u8 next_rs; /* next rate used in rs algo */ - u8 prev_rs_tgg; /* previous rate used in TGG rs algo */ - u8 next_rs_tgg; /* next rate used in TGG rs algo */ + u8 plcp; /* uCode API: RATE_6M_PLCP, etc. */ + u8 plcp_siso; /* uCode API: RATE_SISO_6M_PLCP, etc. */ + u8 plcp_mimo2; /* uCode API: RATE_MIMO2_6M_PLCP, etc. */ + u8 ieee; /* MAC header: RATE_6M_IEEE, etc. */ + u8 prev_ieee; /* previous rate in IEEE speeds */ + u8 next_ieee; /* next rate in IEEE speeds */ + u8 prev_rs; /* previous rate used in rs algo */ + u8 next_rs; /* next rate used in rs algo */ + u8 prev_rs_tgg; /* previous rate used in TGG rs algo */ + u8 next_rs_tgg; /* next rate used in TGG rs algo */ }; struct il3945_rate_info { @@ -2862,7 +2835,6 @@ struct il3945_rate_info { u8 prev_table_rs; /* prev in rate table cmd */ }; - /* * These serve as idxes into * struct il_rate_info il_rates[RATE_COUNT]; @@ -2929,20 +2901,20 @@ enum { /* uCode API values for legacy bit rates, both OFDM and CCK */ enum { - RATE_6M_PLCP = 13, - RATE_9M_PLCP = 15, + RATE_6M_PLCP = 13, + RATE_9M_PLCP = 15, RATE_12M_PLCP = 5, RATE_18M_PLCP = 7, RATE_24M_PLCP = 9, RATE_36M_PLCP = 11, RATE_48M_PLCP = 1, RATE_54M_PLCP = 3, - RATE_60M_PLCP = 3,/*FIXME:RS:should be removed*/ - RATE_1M_PLCP = 10, - RATE_2M_PLCP = 20, - RATE_5M_PLCP = 55, + RATE_60M_PLCP = 3, /*FIXME:RS:should be removed */ + RATE_1M_PLCP = 10, + RATE_2M_PLCP = 20, + RATE_5M_PLCP = 55, RATE_11M_PLCP = 110, - /*FIXME:RS:add RATE_LEGACY_INVM_PLCP = 0,*/ + /*FIXME:RS:add RATE_LEGACY_INVM_PLCP = 0, */ }; /* uCode API values for OFDM high-throughput (HT) bit rates */ @@ -2955,7 +2927,7 @@ enum { RATE_SISO_48M_PLCP = 5, RATE_SISO_54M_PLCP = 6, RATE_SISO_60M_PLCP = 7, - RATE_MIMO2_6M_PLCP = 0x8, + RATE_MIMO2_6M_PLCP = 0x8, RATE_MIMO2_12M_PLCP = 0x9, RATE_MIMO2_18M_PLCP = 0xa, RATE_MIMO2_24M_PLCP = 0xb, @@ -2969,8 +2941,8 @@ enum { /* MAC header values for bit rates */ enum { - RATE_6M_IEEE = 12, - RATE_9M_IEEE = 18, + RATE_6M_IEEE = 12, + RATE_9M_IEEE = 18, RATE_12M_IEEE = 24, RATE_18M_IEEE = 36, RATE_24M_IEEE = 48, @@ -2978,9 +2950,9 @@ enum { RATE_48M_IEEE = 96, RATE_54M_IEEE = 108, RATE_60M_IEEE = 120, - RATE_1M_IEEE = 2, - RATE_2M_IEEE = 4, - RATE_5M_IEEE = 11, + RATE_1M_IEEE = 2, + RATE_2M_IEEE = 4, + RATE_5M_IEEE = 11, RATE_11M_IEEE = 22, }; @@ -3081,9 +3053,9 @@ extern const struct il_rate_info il_rates[RATE_COUNT]; enum il_table_type { LQ_NONE, - LQ_G, /* legacy types */ + LQ_G, /* legacy types */ LQ_A, - LQ_SISO, /* high-throughput types */ + LQ_SISO, /* high-throughput types */ LQ_MIMO2, LQ_MAX, }; @@ -3108,8 +3080,8 @@ enum il_table_type { #define IL_MAX_MCS_DISPLAY_SIZE 12 struct il_rate_mcs_info { - char mbps[IL_MAX_MCS_DISPLAY_SIZE]; - char mcs[IL_MAX_MCS_DISPLAY_SIZE]; + char mbps[IL_MAX_MCS_DISPLAY_SIZE]; + char mcs[IL_MAX_MCS_DISPLAY_SIZE]; }; /** @@ -3133,25 +3105,25 @@ struct il_rate_scale_data { struct il_scale_tbl_info { enum il_table_type lq_type; u8 ant_type; - u8 is_SGI; /* 1 = short guard interval */ - u8 is_ht40; /* 1 = 40 MHz channel width */ - u8 is_dup; /* 1 = duplicated data streams */ - u8 action; /* change modulation; IL_[LEGACY/SISO/MIMO]_SWITCH_* */ - u8 max_search; /* maximun number of tables we can search */ + u8 is_SGI; /* 1 = short guard interval */ + u8 is_ht40; /* 1 = 40 MHz channel width */ + u8 is_dup; /* 1 = duplicated data streams */ + u8 action; /* change modulation; IL_[LEGACY/SISO/MIMO]_SWITCH_* */ + u8 max_search; /* maximun number of tables we can search */ s32 *expected_tpt; /* throughput metrics; expected_tpt_G, etc. */ - u32 current_rate; /* rate_n_flags, uCode API format */ - struct il_rate_scale_data win[RATE_COUNT]; /* rate histories */ + u32 current_rate; /* rate_n_flags, uCode API format */ + struct il_rate_scale_data win[RATE_COUNT]; /* rate histories */ }; struct il_traffic_load { unsigned long time_stamp; /* age of the oldest stats */ - u32 packet_count[TID_QUEUE_MAX_SIZE]; /* packet count in this time + u32 packet_count[TID_QUEUE_MAX_SIZE]; /* packet count in this time * slice */ - u32 total; /* total num of packets during the - * last TID_MAX_TIME_DIFF */ - u8 queue_count; /* number of queues that has - * been used since the last cleanup */ - u8 head; /* start of the circular buffer */ + u32 total; /* total num of packets during the + * last TID_MAX_TIME_DIFF */ + u8 queue_count; /* number of queues that has + * been used since the last cleanup */ + u8 head; /* start of the circular buffer */ }; /** @@ -3185,11 +3157,11 @@ struct il_lq_sta { u16 active_legacy_rate; u16 active_siso_rate; u16 active_mimo2_rate; - s8 max_rate_idx; /* Max rate set by user */ + s8 max_rate_idx; /* Max rate set by user */ u8 missed_rate_counter; struct il_link_quality_cmd lq; - struct il_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */ + struct il_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */ struct il_traffic_load load[TID_MAX_LOAD_COUNT]; u8 tx_agg_tid_en; #ifdef CONFIG_MAC80211_DEBUGFS @@ -3227,12 +3199,14 @@ struct il_station_priv { bool asleep; }; -static inline u8 il4965_num_of_ant(u8 m) +static inline u8 +il4965_num_of_ant(u8 m) { return !!(m & ANT_A) + !!(m & ANT_B) + !!(m & ANT_C); } -static inline u8 il4965_first_antenna(u8 mask) +static inline u8 +il4965_first_antenna(u8 mask) { if (mask & ANT_A) return ANT_A; @@ -3241,7 +3215,6 @@ static inline u8 il4965_first_antenna(u8 mask) return ANT_C; } - /** * il3945_rate_scale_init - Initialize the rate scale table based on assoc info * @@ -3251,10 +3224,10 @@ static inline u8 il4965_first_antenna(u8 mask) extern void il3945_rate_scale_init(struct ieee80211_hw *hw, s32 sta_id); /* Initialize station's rate scaling information after adding station */ -extern void il4965_rs_rate_init(struct il_priv *il, - struct ieee80211_sta *sta, u8 sta_id); -extern void il3945_rs_rate_init(struct il_priv *il, - struct ieee80211_sta *sta, u8 sta_id); +extern void il4965_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, + u8 sta_id); +extern void il3945_rs_rate_init(struct il_priv *il, struct ieee80211_sta *sta, + u8 sta_id); /** * il_rate_control_register - Register the rate control algorithm callbacks @@ -3291,7 +3264,8 @@ extern u32 il_debug_level; * level will be used if set, otherwise the global debug level which can be * set via module parameter is used. */ -static inline u32 il_get_debug_level(struct il_priv *il) +static inline u32 +il_get_debug_level(struct il_priv *il) { if (il->debug_level) return il->debug_level; @@ -3299,7 +3273,8 @@ static inline u32 il_get_debug_level(struct il_priv *il) return il_debug_level; } #else -static inline u32 il_get_debug_level(struct il_priv *il) +static inline u32 +il_get_debug_level(struct il_priv *il) { return il_debug_level; } @@ -3329,10 +3304,11 @@ do { \ #else #define IL_DBG(level, fmt, args...) -static inline void il_print_hex_dump(struct il_priv *il, int level, - const void *p, u32 len) -{} -#endif /* CONFIG_IWLEGACY_DEBUG */ +static inline void +il_print_hex_dump(struct il_priv *il, int level, const void *p, u32 len) +{ +} +#endif /* CONFIG_IWLEGACY_DEBUG */ #ifdef CONFIG_IWLEGACY_DEBUGFS int il_dbgfs_register(struct il_priv *il, const char *name); @@ -3343,10 +3319,12 @@ il_dbgfs_register(struct il_priv *il, const char *name) { return 0; } -static inline void il_dbgfs_unregister(struct il_priv *il) + +static inline void +il_dbgfs_unregister(struct il_priv *il) { } -#endif /* CONFIG_IWLEGACY_DEBUGFS */ +#endif /* CONFIG_IWLEGACY_DEBUGFS */ /* * To use the debug system: diff --git a/drivers/net/wireless/iwlegacy/csr.h b/drivers/net/wireless/iwlegacy/csr.h index 4db04297560c..9138e15004fa 100644 --- a/drivers/net/wireless/iwlegacy/csr.h +++ b/drivers/net/wireless/iwlegacy/csr.h @@ -82,13 +82,13 @@ */ #define CSR_BASE (0x000) -#define CSR_HW_IF_CONFIG_REG (CSR_BASE+0x000) /* hardware interface config */ -#define CSR_INT_COALESCING (CSR_BASE+0x004) /* accum ints, 32-usec units */ -#define CSR_INT (CSR_BASE+0x008) /* host interrupt status/ack */ -#define CSR_INT_MASK (CSR_BASE+0x00c) /* host interrupt enable */ -#define CSR_FH_INT_STATUS (CSR_BASE+0x010) /* busmaster int status/ack*/ -#define CSR_GPIO_IN (CSR_BASE+0x018) /* read external chip pins */ -#define CSR_RESET (CSR_BASE+0x020) /* busmaster enable, NMI, etc*/ +#define CSR_HW_IF_CONFIG_REG (CSR_BASE+0x000) /* hardware interface config */ +#define CSR_INT_COALESCING (CSR_BASE+0x004) /* accum ints, 32-usec units */ +#define CSR_INT (CSR_BASE+0x008) /* host interrupt status/ack */ +#define CSR_INT_MASK (CSR_BASE+0x00c) /* host interrupt enable */ +#define CSR_FH_INT_STATUS (CSR_BASE+0x010) /* busmaster int status/ack */ +#define CSR_GPIO_IN (CSR_BASE+0x018) /* read external chip pins */ +#define CSR_RESET (CSR_BASE+0x020) /* busmaster enable, NMI, etc */ #define CSR_GP_CNTRL (CSR_BASE+0x024) /* 2nd byte of CSR_INT_COALESCING, not accessible via _il_wr()! */ @@ -166,26 +166,26 @@ #define CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A (0x00080000) #define CSR_HW_IF_CONFIG_REG_BIT_EEPROM_OWN_SEM (0x00200000) -#define CSR_HW_IF_CONFIG_REG_BIT_NIC_READY (0x00400000) /* PCI_OWN_SEM */ -#define CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE (0x02000000) /* ME_OWN */ -#define CSR_HW_IF_CONFIG_REG_PREPARE (0x08000000) /* WAKE_ME */ +#define CSR_HW_IF_CONFIG_REG_BIT_NIC_READY (0x00400000) /* PCI_OWN_SEM */ +#define CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE (0x02000000) /* ME_OWN */ +#define CSR_HW_IF_CONFIG_REG_PREPARE (0x08000000) /* WAKE_ME */ -#define CSR_INT_PERIODIC_DIS (0x00) /* disable periodic int*/ -#define CSR_INT_PERIODIC_ENA (0xFF) /* 255*32 usec ~ 8 msec*/ +#define CSR_INT_PERIODIC_DIS (0x00) /* disable periodic int */ +#define CSR_INT_PERIODIC_ENA (0xFF) /* 255*32 usec ~ 8 msec */ /* interrupt flags in INTA, set by uCode or hardware (e.g. dma), * acknowledged (reset) by host writing "1" to flagged bits. */ -#define CSR_INT_BIT_FH_RX (1 << 31) /* Rx DMA, cmd responses, FH_INT[17:16] */ -#define CSR_INT_BIT_HW_ERR (1 << 29) /* DMA hardware error FH_INT[31] */ -#define CSR_INT_BIT_RX_PERIODIC (1 << 28) /* Rx periodic */ -#define CSR_INT_BIT_FH_TX (1 << 27) /* Tx DMA FH_INT[1:0] */ -#define CSR_INT_BIT_SCD (1 << 26) /* TXQ pointer advanced */ -#define CSR_INT_BIT_SW_ERR (1 << 25) /* uCode error */ -#define CSR_INT_BIT_RF_KILL (1 << 7) /* HW RFKILL switch GP_CNTRL[27] toggled */ -#define CSR_INT_BIT_CT_KILL (1 << 6) /* Critical temp (chip too hot) rfkill */ -#define CSR_INT_BIT_SW_RX (1 << 3) /* Rx, command responses, 3945 */ -#define CSR_INT_BIT_WAKEUP (1 << 1) /* NIC controller waking up (pwr mgmt) */ -#define CSR_INT_BIT_ALIVE (1 << 0) /* uCode interrupts once it initializes */ +#define CSR_INT_BIT_FH_RX (1 << 31) /* Rx DMA, cmd responses, FH_INT[17:16] */ +#define CSR_INT_BIT_HW_ERR (1 << 29) /* DMA hardware error FH_INT[31] */ +#define CSR_INT_BIT_RX_PERIODIC (1 << 28) /* Rx periodic */ +#define CSR_INT_BIT_FH_TX (1 << 27) /* Tx DMA FH_INT[1:0] */ +#define CSR_INT_BIT_SCD (1 << 26) /* TXQ pointer advanced */ +#define CSR_INT_BIT_SW_ERR (1 << 25) /* uCode error */ +#define CSR_INT_BIT_RF_KILL (1 << 7) /* HW RFKILL switch GP_CNTRL[27] toggled */ +#define CSR_INT_BIT_CT_KILL (1 << 6) /* Critical temp (chip too hot) rfkill */ +#define CSR_INT_BIT_SW_RX (1 << 3) /* Rx, command responses, 3945 */ +#define CSR_INT_BIT_WAKEUP (1 << 1) /* NIC controller waking up (pwr mgmt) */ +#define CSR_INT_BIT_ALIVE (1 << 0) /* uCode interrupts once it initializes */ #define CSR_INI_SET_MASK (CSR_INT_BIT_FH_RX | \ CSR_INT_BIT_HW_ERR | \ @@ -197,21 +197,20 @@ CSR_INT_BIT_ALIVE) /* interrupt flags in FH (flow handler) (PCI busmaster DMA) */ -#define CSR_FH_INT_BIT_ERR (1 << 31) /* Error */ -#define CSR_FH_INT_BIT_HI_PRIOR (1 << 30) /* High priority Rx, bypass coalescing */ -#define CSR39_FH_INT_BIT_RX_CHNL2 (1 << 18) /* Rx channel 2 (3945 only) */ -#define CSR_FH_INT_BIT_RX_CHNL1 (1 << 17) /* Rx channel 1 */ -#define CSR_FH_INT_BIT_RX_CHNL0 (1 << 16) /* Rx channel 0 */ -#define CSR39_FH_INT_BIT_TX_CHNL6 (1 << 6) /* Tx channel 6 (3945 only) */ -#define CSR_FH_INT_BIT_TX_CHNL1 (1 << 1) /* Tx channel 1 */ -#define CSR_FH_INT_BIT_TX_CHNL0 (1 << 0) /* Tx channel 0 */ +#define CSR_FH_INT_BIT_ERR (1 << 31) /* Error */ +#define CSR_FH_INT_BIT_HI_PRIOR (1 << 30) /* High priority Rx, bypass coalescing */ +#define CSR39_FH_INT_BIT_RX_CHNL2 (1 << 18) /* Rx channel 2 (3945 only) */ +#define CSR_FH_INT_BIT_RX_CHNL1 (1 << 17) /* Rx channel 1 */ +#define CSR_FH_INT_BIT_RX_CHNL0 (1 << 16) /* Rx channel 0 */ +#define CSR39_FH_INT_BIT_TX_CHNL6 (1 << 6) /* Tx channel 6 (3945 only) */ +#define CSR_FH_INT_BIT_TX_CHNL1 (1 << 1) /* Tx channel 1 */ +#define CSR_FH_INT_BIT_TX_CHNL0 (1 << 0) /* Tx channel 0 */ #define CSR39_FH_INT_RX_MASK (CSR_FH_INT_BIT_HI_PRIOR | \ CSR39_FH_INT_BIT_RX_CHNL2 | \ CSR_FH_INT_BIT_RX_CHNL1 | \ CSR_FH_INT_BIT_RX_CHNL0) - #define CSR39_FH_INT_TX_MASK (CSR39_FH_INT_BIT_TX_CHNL6 | \ CSR_FH_INT_BIT_TX_CHNL1 | \ CSR_FH_INT_BIT_TX_CHNL0) @@ -285,7 +284,6 @@ #define CSR_GP_CNTRL_REG_FLAG_MAC_POWER_SAVE (0x04000000) #define CSR_GP_CNTRL_REG_FLAG_HW_RF_KILL_SW (0x08000000) - /* EEPROM REG */ #define CSR_EEPROM_REG_READ_VALID_MSK (0x00000001) #define CSR_EEPROM_REG_BIT_CMD (0x00000002) @@ -293,19 +291,18 @@ #define CSR_EEPROM_REG_MSK_DATA (0xFFFF0000) /* EEPROM GP */ -#define CSR_EEPROM_GP_VALID_MSK (0x00000007) /* signature */ +#define CSR_EEPROM_GP_VALID_MSK (0x00000007) /* signature */ #define CSR_EEPROM_GP_IF_OWNER_MSK (0x00000180) #define CSR_EEPROM_GP_GOOD_SIG_EEP_LESS_THAN_4K (0x00000002) #define CSR_EEPROM_GP_GOOD_SIG_EEP_MORE_THAN_4K (0x00000004) /* GP REG */ -#define CSR_GP_REG_POWER_SAVE_STATUS_MSK (0x03000000) /* bit 24/25 */ +#define CSR_GP_REG_POWER_SAVE_STATUS_MSK (0x03000000) /* bit 24/25 */ #define CSR_GP_REG_NO_POWER_SAVE (0x00000000) #define CSR_GP_REG_MAC_POWER_SAVE (0x01000000) #define CSR_GP_REG_PHY_POWER_SAVE (0x02000000) #define CSR_GP_REG_POWER_SAVE_ERROR (0x03000000) - /* CSR GIO */ #define CSR_GIO_REG_VAL_L0S_ENABLED (0x00000002) diff --git a/drivers/net/wireless/iwlegacy/debug.c b/drivers/net/wireless/iwlegacy/debug.c index 4e2b6c80849e..e79794a7e326 100644 --- a/drivers/net/wireless/iwlegacy/debug.c +++ b/drivers/net/wireless/iwlegacy/debug.c @@ -64,7 +64,6 @@ static ssize_t il_dbgfs_##name##_write(struct file *file, \ const char __user *user_buf, \ size_t count, loff_t *ppos); - static int il_dbgfs_open_file_generic(struct inode *inode, struct file *file) { @@ -98,9 +97,10 @@ static const struct file_operations il_dbgfs_##name##_ops = { \ .llseek = generic_file_llseek, \ }; -static ssize_t il_dbgfs_tx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_tx_stats_read(struct file *file, char __user * user_buf, size_t count, + loff_t * ppos) +{ struct il_priv *il = file->private_data; char *buf; @@ -108,30 +108,30 @@ static ssize_t il_dbgfs_tx_stats_read(struct file *file, int cnt; ssize_t ret; - const size_t bufsz = 100 + - sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); + const size_t bufsz = + 100 + sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) return -ENOMEM; pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, - "\t%25s\t\t: %u\n", - il_get_mgmt_string(cnt), - il->tx_stats.mgmt[cnt]); + pos += + scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", + il_get_mgmt_string(cnt), il->tx_stats.mgmt[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Control\n"); for (cnt = 0; cnt < CONTROL_MAX; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, - "\t%25s\t\t: %u\n", - il_get_ctrl_string(cnt), - il->tx_stats.ctrl[cnt]); + pos += + scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", + il_get_ctrl_string(cnt), il->tx_stats.ctrl[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); - pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", - il->tx_stats.data_cnt); - pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", - il->tx_stats.data_bytes); + pos += + scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", + il->tx_stats.data_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", + il->tx_stats.data_bytes); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; @@ -139,8 +139,8 @@ static ssize_t il_dbgfs_tx_stats_read(struct file *file, static ssize_t il_dbgfs_clear_traffic_stats_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) + const char __user * user_buf, size_t count, + loff_t * ppos) { struct il_priv *il = file->private_data; u32 clear_flag; @@ -148,7 +148,7 @@ il_dbgfs_clear_traffic_stats_write(struct file *file, int buf_size; memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); + buf_size = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, buf_size)) return -EFAULT; if (sscanf(buf, "%x", &clear_flag) != 1) @@ -158,40 +158,41 @@ il_dbgfs_clear_traffic_stats_write(struct file *file, return count; } -static ssize_t il_dbgfs_rx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_rx_stats_read(struct file *file, char __user * user_buf, size_t count, + loff_t * ppos) +{ struct il_priv *il = file->private_data; char *buf; int pos = 0; int cnt; ssize_t ret; - const size_t bufsz = 100 + - sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); + const size_t bufsz = + 100 + sizeof(char) * 50 * (MANAGEMENT_MAX + CONTROL_MAX); buf = kzalloc(bufsz, GFP_KERNEL); if (!buf) return -ENOMEM; pos += scnprintf(buf + pos, bufsz - pos, "Management:\n"); for (cnt = 0; cnt < MANAGEMENT_MAX; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, - "\t%25s\t\t: %u\n", - il_get_mgmt_string(cnt), - il->rx_stats.mgmt[cnt]); + pos += + scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", + il_get_mgmt_string(cnt), il->rx_stats.mgmt[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Control:\n"); for (cnt = 0; cnt < CONTROL_MAX; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, - "\t%25s\t\t: %u\n", - il_get_ctrl_string(cnt), - il->rx_stats.ctrl[cnt]); + pos += + scnprintf(buf + pos, bufsz - pos, "\t%25s\t\t: %u\n", + il_get_ctrl_string(cnt), il->rx_stats.ctrl[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "Data:\n"); - pos += scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", - il->rx_stats.data_cnt); - pos += scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", - il->rx_stats.data_bytes); + pos += + scnprintf(buf + pos, bufsz - pos, "\tcnt: %u\n", + il->rx_stats.data_cnt); + pos += + scnprintf(buf + pos, bufsz - pos, "\tbytes: %llu\n", + il->rx_stats.data_bytes); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); @@ -201,9 +202,9 @@ static ssize_t il_dbgfs_rx_stats_read(struct file *file, #define BYTE1_MASK 0x000000ff; #define BYTE2_MASK 0x0000ffff; #define BYTE3_MASK 0x00ffffff; -static ssize_t il_dbgfs_sram_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_sram_read(struct file *file, char __user * user_buf, size_t count, + loff_t * ppos) { u32 val; char *buf; @@ -221,17 +222,21 @@ static ssize_t il_dbgfs_sram_read(struct file *file, else il->dbgfs_sram_len = il->ucode_data.len; } - bufsz = 30 + il->dbgfs_sram_len * sizeof(char) * 10; + bufsz = 30 + il->dbgfs_sram_len * sizeof(char) * 10; buf = kmalloc(bufsz, GFP_KERNEL); if (!buf) return -ENOMEM; - pos += scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n", - il->dbgfs_sram_len); - pos += scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n", - il->dbgfs_sram_offset); + pos += + scnprintf(buf + pos, bufsz - pos, "sram_len: 0x%x\n", + il->dbgfs_sram_len); + pos += + scnprintf(buf + pos, bufsz - pos, "sram_offset: 0x%x\n", + il->dbgfs_sram_offset); for (i = il->dbgfs_sram_len; i > 0; i -= 4) { - val = il_read_targ_mem(il, il->dbgfs_sram_offset + \ - il->dbgfs_sram_len - i); + val = + il_read_targ_mem(il, + il->dbgfs_sram_offset + + il->dbgfs_sram_len - i); if (i < 4) { switch (i) { case 1: @@ -256,9 +261,9 @@ static ssize_t il_dbgfs_sram_read(struct file *file, return ret; } -static ssize_t il_dbgfs_sram_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_sram_write(struct file *file, const char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; char buf[64]; @@ -266,7 +271,7 @@ static ssize_t il_dbgfs_sram_write(struct file *file, u32 offset, len; memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); + buf_size = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, buf_size)) return -EFAULT; @@ -282,8 +287,8 @@ static ssize_t il_dbgfs_sram_write(struct file *file, } static ssize_t -il_dbgfs_stations_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) +il_dbgfs_stations_read(struct file *file, char __user * user_buf, size_t count, + loff_t * ppos) { struct il_priv *il = file->private_data; struct il_station_entry *station; @@ -298,36 +303,42 @@ il_dbgfs_stations_read(struct file *file, char __user *user_buf, if (!buf) return -ENOMEM; - pos += scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n", - il->num_stations); + pos += + scnprintf(buf + pos, bufsz - pos, "num of stations: %d\n\n", + il->num_stations); for (i = 0; i < max_sta; i++) { station = &il->stations[i]; if (!station->used) continue; - pos += scnprintf(buf + pos, bufsz - pos, - "station %d - addr: %pM, flags: %#x\n", - i, station->sta.sta.addr, - station->sta.station_flags_msk); - pos += scnprintf(buf + pos, bufsz - pos, - "TID\tseq_num\ttxq_id\tframes\ttfds\t"); - pos += scnprintf(buf + pos, bufsz - pos, - "start_idx\tbitmap\t\t\trate_n_flags\n"); + pos += + scnprintf(buf + pos, bufsz - pos, + "station %d - addr: %pM, flags: %#x\n", i, + station->sta.sta.addr, + station->sta.station_flags_msk); + pos += + scnprintf(buf + pos, bufsz - pos, + "TID\tseq_num\ttxq_id\tframes\ttfds\t"); + pos += + scnprintf(buf + pos, bufsz - pos, + "start_idx\tbitmap\t\t\trate_n_flags\n"); for (j = 0; j < MAX_TID_COUNT; j++) { - pos += scnprintf(buf + pos, bufsz - pos, - "%d:\t%#x\t%#x\t%u\t%u\t%u\t\t%#.16llx\t%#x", - j, station->tid[j].seq_number, - station->tid[j].agg.txq_id, - station->tid[j].agg.frame_count, - station->tid[j].tfds_in_queue, - station->tid[j].agg.start_idx, - station->tid[j].agg.bitmap, - station->tid[j].agg.rate_n_flags); + pos += + scnprintf(buf + pos, bufsz - pos, + "%d:\t%#x\t%#x\t%u\t%u\t%u\t\t%#.16llx\t%#x", + j, station->tid[j].seq_number, + station->tid[j].agg.txq_id, + station->tid[j].agg.frame_count, + station->tid[j].tfds_in_queue, + station->tid[j].agg.start_idx, + station->tid[j].agg.bitmap, + station->tid[j].agg.rate_n_flags); if (station->tid[j].agg.wait_for_ba) - pos += scnprintf(buf + pos, bufsz - pos, - " - waitforba"); + pos += + scnprintf(buf + pos, bufsz - pos, + " - waitforba"); pos += scnprintf(buf + pos, bufsz - pos, "\n"); } @@ -339,10 +350,9 @@ il_dbgfs_stations_read(struct file *file, char __user *user_buf, return ret; } -static ssize_t il_dbgfs_nvm_read(struct file *file, - char __user *user_buf, - size_t count, - loff_t *ppos) +static ssize_t +il_dbgfs_nvm_read(struct file *file, char __user * user_buf, size_t count, + loff_t * ppos) { ssize_t ret; struct il_priv *il = file->private_data; @@ -371,11 +381,12 @@ static ssize_t il_dbgfs_nvm_read(struct file *file, return -ENOMEM; } eeprom_ver = il_eeprom_query16(il, EEPROM_VERSION); - pos += scnprintf(buf + pos, buf_size - pos, "EEPROM " - "version: 0x%x\n", eeprom_ver); - for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) { + pos += + scnprintf(buf + pos, buf_size - pos, "EEPROM " "version: 0x%x\n", + eeprom_ver); + for (ofs = 0; ofs < eeprom_len; ofs += 16) { pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs); - hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos, + hex_dump_to_buffer(ptr + ofs, 16, 16, 2, buf + pos, buf_size - pos, 0); pos += strlen(buf + pos); if (buf_size - pos > 0) @@ -388,8 +399,8 @@ static ssize_t il_dbgfs_nvm_read(struct file *file, } static ssize_t -il_dbgfs_channels_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) +il_dbgfs_channels_read(struct file *file, char __user * user_buf, size_t count, + loff_t * ppos) { struct il_priv *il = file->private_data; struct ieee80211_channel *channels = NULL; @@ -411,106 +422,132 @@ il_dbgfs_channels_read(struct file *file, char __user *user_buf, if (supp_band) { channels = supp_band->channels; - pos += scnprintf(buf + pos, bufsz - pos, - "Displaying %d channels in 2.4GHz band 802.11bg):\n", - supp_band->n_channels); + pos += + scnprintf(buf + pos, bufsz - pos, + "Displaying %d channels in 2.4GHz band 802.11bg):\n", + supp_band->n_channels); for (i = 0; i < supp_band->n_channels; i++) - pos += scnprintf(buf + pos, bufsz - pos, - "%d: %ddBm: BSS%s%s, %s.\n", - channels[i].hw_value, - channels[i].max_power, - channels[i].flags & IEEE80211_CHAN_RADAR ? - " (IEEE 802.11h required)" : "", - ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) - || (channels[i].flags & - IEEE80211_CHAN_RADAR)) ? "" : - ", IBSS", - channels[i].flags & - IEEE80211_CHAN_PASSIVE_SCAN ? - "passive only" : "active/passive"); + pos += + scnprintf(buf + pos, bufsz - pos, + "%d: %ddBm: BSS%s%s, %s.\n", + channels[i].hw_value, + channels[i].max_power, + channels[i]. + flags & IEEE80211_CHAN_RADAR ? + " (IEEE 802.11h required)" : "", + ((channels[i]. + flags & IEEE80211_CHAN_NO_IBSS) || + (channels[i]. + flags & IEEE80211_CHAN_RADAR)) ? "" : + ", IBSS", + channels[i]. + flags & IEEE80211_CHAN_PASSIVE_SCAN ? + "passive only" : "active/passive"); } supp_band = il_get_hw_mode(il, IEEE80211_BAND_5GHZ); if (supp_band) { channels = supp_band->channels; - pos += scnprintf(buf + pos, bufsz - pos, - "Displaying %d channels in 5.2GHz band (802.11a)\n", - supp_band->n_channels); + pos += + scnprintf(buf + pos, bufsz - pos, + "Displaying %d channels in 5.2GHz band (802.11a)\n", + supp_band->n_channels); for (i = 0; i < supp_band->n_channels; i++) - pos += scnprintf(buf + pos, bufsz - pos, - "%d: %ddBm: BSS%s%s, %s.\n", - channels[i].hw_value, - channels[i].max_power, - channels[i].flags & IEEE80211_CHAN_RADAR ? - " (IEEE 802.11h required)" : "", - ((channels[i].flags & IEEE80211_CHAN_NO_IBSS) - || (channels[i].flags & - IEEE80211_CHAN_RADAR)) ? "" : - ", IBSS", - channels[i].flags & - IEEE80211_CHAN_PASSIVE_SCAN ? - "passive only" : "active/passive"); + pos += + scnprintf(buf + pos, bufsz - pos, + "%d: %ddBm: BSS%s%s, %s.\n", + channels[i].hw_value, + channels[i].max_power, + channels[i]. + flags & IEEE80211_CHAN_RADAR ? + " (IEEE 802.11h required)" : "", + ((channels[i]. + flags & IEEE80211_CHAN_NO_IBSS) || + (channels[i]. + flags & IEEE80211_CHAN_RADAR)) ? "" : + ", IBSS", + channels[i]. + flags & IEEE80211_CHAN_PASSIVE_SCAN ? + "passive only" : "active/passive"); } ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; } -static ssize_t il_dbgfs_status_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_status_read(struct file *file, char __user * user_buf, size_t count, + loff_t * ppos) +{ struct il_priv *il = file->private_data; char buf[512]; int pos = 0; const size_t bufsz = sizeof(buf); - pos += scnprintf(buf + pos, bufsz - pos, "S_HCMD_ACTIVE:\t %d\n", - test_bit(S_HCMD_ACTIVE, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_INT_ENABLED:\t %d\n", - test_bit(S_INT_ENABLED, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_RF_KILL_HW:\t %d\n", - test_bit(S_RF_KILL_HW, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_CT_KILL:\t\t %d\n", - test_bit(S_CT_KILL, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_INIT:\t\t %d\n", - test_bit(S_INIT, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_ALIVE:\t\t %d\n", - test_bit(S_ALIVE, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_READY:\t\t %d\n", - test_bit(S_READY, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_TEMPERATURE:\t %d\n", - test_bit(S_TEMPERATURE, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_GEO_CONFIGURED:\t %d\n", - test_bit(S_GEO_CONFIGURED, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_EXIT_PENDING:\t %d\n", - test_bit(S_EXIT_PENDING, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_STATS:\t %d\n", - test_bit(S_STATS, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_SCANNING:\t %d\n", - test_bit(S_SCANNING, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_SCAN_ABORTING:\t %d\n", - test_bit(S_SCAN_ABORTING, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_SCAN_HW:\t\t %d\n", - test_bit(S_SCAN_HW, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_POWER_PMI:\t %d\n", - test_bit(S_POWER_PMI, &il->status)); - pos += scnprintf(buf + pos, bufsz - pos, "S_FW_ERROR:\t %d\n", - test_bit(S_FW_ERROR, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_HCMD_ACTIVE:\t %d\n", + test_bit(S_HCMD_ACTIVE, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_INT_ENABLED:\t %d\n", + test_bit(S_INT_ENABLED, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_RF_KILL_HW:\t %d\n", + test_bit(S_RF_KILL_HW, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_CT_KILL:\t\t %d\n", + test_bit(S_CT_KILL, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_INIT:\t\t %d\n", + test_bit(S_INIT, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_ALIVE:\t\t %d\n", + test_bit(S_ALIVE, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_READY:\t\t %d\n", + test_bit(S_READY, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_TEMPERATURE:\t %d\n", + test_bit(S_TEMPERATURE, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_GEO_CONFIGURED:\t %d\n", + test_bit(S_GEO_CONFIGURED, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_EXIT_PENDING:\t %d\n", + test_bit(S_EXIT_PENDING, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_STATS:\t %d\n", + test_bit(S_STATS, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_SCANNING:\t %d\n", + test_bit(S_SCANNING, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_SCAN_ABORTING:\t %d\n", + test_bit(S_SCAN_ABORTING, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_SCAN_HW:\t\t %d\n", + test_bit(S_SCAN_HW, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_POWER_PMI:\t %d\n", + test_bit(S_POWER_PMI, &il->status)); + pos += + scnprintf(buf + pos, bufsz - pos, "S_FW_ERROR:\t %d\n", + test_bit(S_FW_ERROR, &il->status)); return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t il_dbgfs_interrupt_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_interrupt_read(struct file *file, char __user * user_buf, size_t count, + loff_t * ppos) +{ struct il_priv *il = file->private_data; int pos = 0; int cnt = 0; char *buf; - int bufsz = 24 * 64; /* 24 items * 64 char per item */ + int bufsz = 24 * 64; /* 24 items * 64 char per item */ ssize_t ret; buf = kzalloc(bufsz, GFP_KERNEL); @@ -519,59 +556,70 @@ static ssize_t il_dbgfs_interrupt_read(struct file *file, return -ENOMEM; } - pos += scnprintf(buf + pos, bufsz - pos, - "Interrupt Statistics Report:\n"); + pos += + scnprintf(buf + pos, bufsz - pos, "Interrupt Statistics Report:\n"); - pos += scnprintf(buf + pos, bufsz - pos, "HW Error:\t\t\t %u\n", - il->isr_stats.hw); - pos += scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n", - il->isr_stats.sw); + pos += + scnprintf(buf + pos, bufsz - pos, "HW Error:\t\t\t %u\n", + il->isr_stats.hw); + pos += + scnprintf(buf + pos, bufsz - pos, "SW Error:\t\t\t %u\n", + il->isr_stats.sw); if (il->isr_stats.sw || il->isr_stats.hw) { - pos += scnprintf(buf + pos, bufsz - pos, - "\tLast Restarting Code: 0x%X\n", - il->isr_stats.err_code); + pos += + scnprintf(buf + pos, bufsz - pos, + "\tLast Restarting Code: 0x%X\n", + il->isr_stats.err_code); } #ifdef CONFIG_IWLEGACY_DEBUG - pos += scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n", - il->isr_stats.sch); - pos += scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n", - il->isr_stats.alive); + pos += + scnprintf(buf + pos, bufsz - pos, "Frame transmitted:\t\t %u\n", + il->isr_stats.sch); + pos += + scnprintf(buf + pos, bufsz - pos, "Alive interrupt:\t\t %u\n", + il->isr_stats.alive); #endif - pos += scnprintf(buf + pos, bufsz - pos, - "HW RF KILL switch toggled:\t %u\n", - il->isr_stats.rfkill); - - pos += scnprintf(buf + pos, bufsz - pos, "CT KILL:\t\t\t %u\n", - il->isr_stats.ctkill); - - pos += scnprintf(buf + pos, bufsz - pos, "Wakeup Interrupt:\t\t %u\n", - il->isr_stats.wakeup); - - pos += scnprintf(buf + pos, bufsz - pos, - "Rx command responses:\t\t %u\n", - il->isr_stats.rx); + pos += + scnprintf(buf + pos, bufsz - pos, + "HW RF KILL switch toggled:\t %u\n", + il->isr_stats.rfkill); + + pos += + scnprintf(buf + pos, bufsz - pos, "CT KILL:\t\t\t %u\n", + il->isr_stats.ctkill); + + pos += + scnprintf(buf + pos, bufsz - pos, "Wakeup Interrupt:\t\t %u\n", + il->isr_stats.wakeup); + + pos += + scnprintf(buf + pos, bufsz - pos, "Rx command responses:\t\t %u\n", + il->isr_stats.rx); for (cnt = 0; cnt < IL_CN_MAX; cnt++) { if (il->isr_stats.handlers[cnt] > 0) - pos += scnprintf(buf + pos, bufsz - pos, - "\tRx handler[%36s]:\t\t %u\n", - il_get_cmd_string(cnt), - il->isr_stats.handlers[cnt]); + pos += + scnprintf(buf + pos, bufsz - pos, + "\tRx handler[%36s]:\t\t %u\n", + il_get_cmd_string(cnt), + il->isr_stats.handlers[cnt]); } - pos += scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n", - il->isr_stats.tx); + pos += + scnprintf(buf + pos, bufsz - pos, "Tx/FH interrupt:\t\t %u\n", + il->isr_stats.tx); - pos += scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n", - il->isr_stats.unhandled); + pos += + scnprintf(buf + pos, bufsz - pos, "Unexpected INTA:\t\t %u\n", + il->isr_stats.unhandled); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; } -static ssize_t il_dbgfs_interrupt_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_interrupt_write(struct file *file, const char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; char buf[8]; @@ -579,7 +627,7 @@ static ssize_t il_dbgfs_interrupt_write(struct file *file, u32 reset_flag; memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); + buf_size = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, buf_size)) return -EFAULT; if (sscanf(buf, "%x", &reset_flag) != 1) @@ -591,8 +639,8 @@ static ssize_t il_dbgfs_interrupt_write(struct file *file, } static ssize_t -il_dbgfs_qos_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) +il_dbgfs_qos_read(struct file *file, char __user * user_buf, size_t count, + loff_t * ppos) { struct il_priv *il = file->private_data; struct il_rxon_context *ctx = &il->ctx; @@ -600,25 +648,26 @@ il_dbgfs_qos_read(struct file *file, char __user *user_buf, char buf[256]; const size_t bufsz = sizeof(buf); - pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n", - ctx->ctxid); + pos += scnprintf(buf + pos, bufsz - pos, "context %d:\n", ctx->ctxid); for (i = 0; i < AC_NUM; i++) { - pos += scnprintf(buf + pos, bufsz - pos, - "\tcw_min\tcw_max\taifsn\ttxop\n"); - pos += scnprintf(buf + pos, bufsz - pos, - "AC[%d]\t%u\t%u\t%u\t%u\n", i, - ctx->qos_data.def_qos_parm.ac[i].cw_min, - ctx->qos_data.def_qos_parm.ac[i].cw_max, - ctx->qos_data.def_qos_parm.ac[i].aifsn, - ctx->qos_data.def_qos_parm.ac[i].edca_txop); + pos += + scnprintf(buf + pos, bufsz - pos, + "\tcw_min\tcw_max\taifsn\ttxop\n"); + pos += + scnprintf(buf + pos, bufsz - pos, + "AC[%d]\t%u\t%u\t%u\t%u\n", i, + ctx->qos_data.def_qos_parm.ac[i].cw_min, + ctx->qos_data.def_qos_parm.ac[i].cw_max, + ctx->qos_data.def_qos_parm.ac[i].aifsn, + ctx->qos_data.def_qos_parm.ac[i].edca_txop); } return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t il_dbgfs_disable_ht40_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_disable_ht40_write(struct file *file, const char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; char buf[8]; @@ -626,7 +675,7 @@ static ssize_t il_dbgfs_disable_ht40_write(struct file *file, int ht40; memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); + buf_size = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, buf_size)) return -EFAULT; if (sscanf(buf, "%d", &ht40) != 1) @@ -635,25 +684,25 @@ static ssize_t il_dbgfs_disable_ht40_write(struct file *file, il->disable_ht40 = ht40 ? true : false; else { IL_ERR("Sta associated with AP - " - "Change to 40MHz channel support is not allowed\n"); + "Change to 40MHz channel support is not allowed\n"); return -EINVAL; } return count; } -static ssize_t il_dbgfs_disable_ht40_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_disable_ht40_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; char buf[100]; int pos = 0; const size_t bufsz = sizeof(buf); - pos += scnprintf(buf + pos, bufsz - pos, - "11n 40MHz Mode: %s\n", - il->disable_ht40 ? "Disabled" : "Enabled"); + pos += + scnprintf(buf + pos, bufsz - pos, "11n 40MHz Mode: %s\n", + il->disable_ht40 ? "Disabled" : "Enabled"); return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } @@ -666,9 +715,9 @@ DEBUGFS_READ_WRITE_FILE_OPS(interrupt); DEBUGFS_READ_FILE_OPS(qos); DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40); -static ssize_t il_dbgfs_traffic_log_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_traffic_log_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; int pos = 0, ofs = 0; @@ -677,8 +726,9 @@ static ssize_t il_dbgfs_traffic_log_read(struct file *file, struct il_queue *q; struct il_rx_queue *rxq = &il->rxq; char *buf; - int bufsz = ((IL_TRAFFIC_ENTRIES * IL_TRAFFIC_ENTRY_SIZE * 64) * 2) + - (il->cfg->base_params->num_of_queues * 32 * 8) + 400; + int bufsz = + ((IL_TRAFFIC_ENTRIES * IL_TRAFFIC_ENTRY_SIZE * 64) * 2) + + (il->cfg->base_params->num_of_queues * 32 * 8) + 400; const u8 *ptr; ssize_t ret; @@ -695,19 +745,22 @@ static ssize_t il_dbgfs_traffic_log_read(struct file *file, for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { txq = &il->txq[cnt]; q = &txq->q; - pos += scnprintf(buf + pos, bufsz - pos, - "q[%d]: read_ptr: %u, write_ptr: %u\n", - cnt, q->read_ptr, q->write_ptr); + pos += + scnprintf(buf + pos, bufsz - pos, + "q[%d]: read_ptr: %u, write_ptr: %u\n", cnt, + q->read_ptr, q->write_ptr); } if (il->tx_traffic && (il_debug_level & IL_DL_TX)) { ptr = il->tx_traffic; - pos += scnprintf(buf + pos, bufsz - pos, - "Tx Traffic idx: %u\n", il->tx_traffic_idx); + pos += + scnprintf(buf + pos, bufsz - pos, "Tx Traffic idx: %u\n", + il->tx_traffic_idx); for (cnt = 0, ofs = 0; cnt < IL_TRAFFIC_ENTRIES; cnt++) { for (entry = 0; entry < IL_TRAFFIC_ENTRY_SIZE / 16; - entry++, ofs += 16) { - pos += scnprintf(buf + pos, bufsz - pos, - "0x%.4x ", ofs); + entry++, ofs += 16) { + pos += + scnprintf(buf + pos, bufsz - pos, "0x%.4x ", + ofs); hex_dump_to_buffer(ptr + ofs, 16, 16, 2, buf + pos, bufsz - pos, 0); pos += strlen(buf + pos); @@ -718,19 +771,21 @@ static ssize_t il_dbgfs_traffic_log_read(struct file *file, } pos += scnprintf(buf + pos, bufsz - pos, "Rx Queue\n"); - pos += scnprintf(buf + pos, bufsz - pos, - "read: %u, write: %u\n", - rxq->read, rxq->write); + pos += + scnprintf(buf + pos, bufsz - pos, "read: %u, write: %u\n", + rxq->read, rxq->write); if (il->rx_traffic && (il_debug_level & IL_DL_RX)) { ptr = il->rx_traffic; - pos += scnprintf(buf + pos, bufsz - pos, - "Rx Traffic idx: %u\n", il->rx_traffic_idx); + pos += + scnprintf(buf + pos, bufsz - pos, "Rx Traffic idx: %u\n", + il->rx_traffic_idx); for (cnt = 0, ofs = 0; cnt < IL_TRAFFIC_ENTRIES; cnt++) { for (entry = 0; entry < IL_TRAFFIC_ENTRY_SIZE / 16; - entry++, ofs += 16) { - pos += scnprintf(buf + pos, bufsz - pos, - "0x%.4x ", ofs); + entry++, ofs += 16) { + pos += + scnprintf(buf + pos, bufsz - pos, "0x%.4x ", + ofs); hex_dump_to_buffer(ptr + ofs, 16, 16, 2, buf + pos, bufsz - pos, 0); pos += strlen(buf + pos); @@ -745,9 +800,9 @@ static ssize_t il_dbgfs_traffic_log_read(struct file *file, return ret; } -static ssize_t il_dbgfs_traffic_log_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_traffic_log_write(struct file *file, const char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; char buf[8]; @@ -755,7 +810,7 @@ static ssize_t il_dbgfs_traffic_log_write(struct file *file, int traffic_log; memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); + buf_size = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, buf_size)) return -EFAULT; if (sscanf(buf, "%d", &traffic_log) != 1) @@ -766,9 +821,10 @@ static ssize_t il_dbgfs_traffic_log_write(struct file *file, return count; } -static ssize_t il_dbgfs_tx_queue_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_tx_queue_read(struct file *file, char __user * user_buf, size_t count, + loff_t * ppos) +{ struct il_priv *il = file->private_data; struct il_tx_queue *txq; @@ -777,8 +833,8 @@ static ssize_t il_dbgfs_tx_queue_read(struct file *file, int pos = 0; int cnt; int ret; - const size_t bufsz = sizeof(char) * 64 * - il->cfg->base_params->num_of_queues; + const size_t bufsz = + sizeof(char) * 64 * il->cfg->base_params->num_of_queues; if (!il->txq) { IL_ERR("txq not ready\n"); @@ -791,28 +847,32 @@ static ssize_t il_dbgfs_tx_queue_read(struct file *file, for (cnt = 0; cnt < il->hw_params.max_txq_num; cnt++) { txq = &il->txq[cnt]; q = &txq->q; - pos += scnprintf(buf + pos, bufsz - pos, - "hwq %.2d: read=%u write=%u stop=%d" - " swq_id=%#.2x (ac %d/hwq %d)\n", - cnt, q->read_ptr, q->write_ptr, - !!test_bit(cnt, il->queue_stopped), - txq->swq_id, txq->swq_id & 3, - (txq->swq_id >> 2) & 0x1f); + pos += + scnprintf(buf + pos, bufsz - pos, + "hwq %.2d: read=%u write=%u stop=%d" + " swq_id=%#.2x (ac %d/hwq %d)\n", cnt, + q->read_ptr, q->write_ptr, !!test_bit(cnt, + il-> + queue_stopped), + txq->swq_id, txq->swq_id & 3, + (txq->swq_id >> 2) & 0x1f); if (cnt >= 4) continue; /* for the ACs, display the stop count too */ - pos += scnprintf(buf + pos, bufsz - pos, - " stop-count: %d\n", - atomic_read(&il->queue_stop_count[cnt])); + pos += + scnprintf(buf + pos, bufsz - pos, + " stop-count: %d\n", + atomic_read(&il->queue_stop_count[cnt])); } ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; } -static ssize_t il_dbgfs_rx_queue_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_rx_queue_read(struct file *file, char __user * user_buf, size_t count, + loff_t * ppos) +{ struct il_priv *il = file->private_data; struct il_rx_queue *rxq = &il->rxq; @@ -820,52 +880,55 @@ static ssize_t il_dbgfs_rx_queue_read(struct file *file, int pos = 0; const size_t bufsz = sizeof(buf); - pos += scnprintf(buf + pos, bufsz - pos, "read: %u\n", - rxq->read); - pos += scnprintf(buf + pos, bufsz - pos, "write: %u\n", - rxq->write); - pos += scnprintf(buf + pos, bufsz - pos, "free_count: %u\n", - rxq->free_count); + pos += scnprintf(buf + pos, bufsz - pos, "read: %u\n", rxq->read); + pos += scnprintf(buf + pos, bufsz - pos, "write: %u\n", rxq->write); + pos += + scnprintf(buf + pos, bufsz - pos, "free_count: %u\n", + rxq->free_count); if (rxq->rb_stts) { - pos += scnprintf(buf + pos, bufsz - pos, "closed_rb_num: %u\n", - le16_to_cpu(rxq->rb_stts->closed_rb_num) & 0x0FFF); + pos += + scnprintf(buf + pos, bufsz - pos, "closed_rb_num: %u\n", + le16_to_cpu(rxq->rb_stts-> + closed_rb_num) & 0x0FFF); } else { - pos += scnprintf(buf + pos, bufsz - pos, - "closed_rb_num: Not Allocated\n"); + pos += + scnprintf(buf + pos, bufsz - pos, + "closed_rb_num: Not Allocated\n"); } return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t il_dbgfs_ucode_rx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_ucode_rx_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; - return il->cfg->ops->lib->debugfs_ops.rx_stats_read(file, - user_buf, count, ppos); + return il->cfg->ops->lib->debugfs_ops.rx_stats_read(file, user_buf, + count, ppos); } -static ssize_t il_dbgfs_ucode_tx_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_ucode_tx_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; - return il->cfg->ops->lib->debugfs_ops.tx_stats_read(file, - user_buf, count, ppos); + return il->cfg->ops->lib->debugfs_ops.tx_stats_read(file, user_buf, + count, ppos); } -static ssize_t il_dbgfs_ucode_general_stats_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_ucode_general_stats_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; - return il->cfg->ops->lib->debugfs_ops.general_stats_read(file, - user_buf, count, ppos); + return il->cfg->ops->lib->debugfs_ops.general_stats_read(file, user_buf, + count, ppos); } -static ssize_t il_dbgfs_sensitivity_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_sensitivity_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) +{ struct il_priv *il = file->private_data; int pos = 0; @@ -882,71 +945,89 @@ static ssize_t il_dbgfs_sensitivity_read(struct file *file, return -ENOMEM; } - pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n", - data->auto_corr_ofdm); - pos += scnprintf(buf + pos, bufsz - pos, - "auto_corr_ofdm_mrc:\t\t %u\n", - data->auto_corr_ofdm_mrc); - pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n", - data->auto_corr_ofdm_x1); - pos += scnprintf(buf + pos, bufsz - pos, - "auto_corr_ofdm_mrc_x1:\t\t %u\n", - data->auto_corr_ofdm_mrc_x1); - pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n", - data->auto_corr_cck); - pos += scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n", - data->auto_corr_cck_mrc); - pos += scnprintf(buf + pos, bufsz - pos, - "last_bad_plcp_cnt_ofdm:\t\t %u\n", - data->last_bad_plcp_cnt_ofdm); - pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n", - data->last_fa_cnt_ofdm); - pos += scnprintf(buf + pos, bufsz - pos, - "last_bad_plcp_cnt_cck:\t\t %u\n", - data->last_bad_plcp_cnt_cck); - pos += scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n", - data->last_fa_cnt_cck); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n", - data->nrg_curr_state); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n", - data->nrg_prev_state); + pos += + scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm:\t\t\t %u\n", + data->auto_corr_ofdm); + pos += + scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_mrc:\t\t %u\n", + data->auto_corr_ofdm_mrc); + pos += + scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_x1:\t\t %u\n", + data->auto_corr_ofdm_x1); + pos += + scnprintf(buf + pos, bufsz - pos, "auto_corr_ofdm_mrc_x1:\t\t %u\n", + data->auto_corr_ofdm_mrc_x1); + pos += + scnprintf(buf + pos, bufsz - pos, "auto_corr_cck:\t\t\t %u\n", + data->auto_corr_cck); + pos += + scnprintf(buf + pos, bufsz - pos, "auto_corr_cck_mrc:\t\t %u\n", + data->auto_corr_cck_mrc); + pos += + scnprintf(buf + pos, bufsz - pos, + "last_bad_plcp_cnt_ofdm:\t\t %u\n", + data->last_bad_plcp_cnt_ofdm); + pos += + scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_ofdm:\t\t %u\n", + data->last_fa_cnt_ofdm); + pos += + scnprintf(buf + pos, bufsz - pos, "last_bad_plcp_cnt_cck:\t\t %u\n", + data->last_bad_plcp_cnt_cck); + pos += + scnprintf(buf + pos, bufsz - pos, "last_fa_cnt_cck:\t\t %u\n", + data->last_fa_cnt_cck); + pos += + scnprintf(buf + pos, bufsz - pos, "nrg_curr_state:\t\t\t %u\n", + data->nrg_curr_state); + pos += + scnprintf(buf + pos, bufsz - pos, "nrg_prev_state:\t\t\t %u\n", + data->nrg_prev_state); pos += scnprintf(buf + pos, bufsz - pos, "nrg_value:\t\t\t"); for (cnt = 0; cnt < 10; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, " %u", - data->nrg_value[cnt]); + pos += + scnprintf(buf + pos, bufsz - pos, " %u", + data->nrg_value[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "\n"); pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_rssi:\t\t"); for (cnt = 0; cnt < NRG_NUM_PREV_STAT_L; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, " %u", - data->nrg_silence_rssi[cnt]); + pos += + scnprintf(buf + pos, bufsz - pos, " %u", + data->nrg_silence_rssi[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "\n"); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n", - data->nrg_silence_ref); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n", - data->nrg_energy_idx); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n", - data->nrg_silence_idx); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n", - data->nrg_th_cck); - pos += scnprintf(buf + pos, bufsz - pos, - "nrg_auto_corr_silence_diff:\t %u\n", - data->nrg_auto_corr_silence_diff); - pos += scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n", - data->num_in_cck_no_fa); - pos += scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n", - data->nrg_th_ofdm); + pos += + scnprintf(buf + pos, bufsz - pos, "nrg_silence_ref:\t\t %u\n", + data->nrg_silence_ref); + pos += + scnprintf(buf + pos, bufsz - pos, "nrg_energy_idx:\t\t\t %u\n", + data->nrg_energy_idx); + pos += + scnprintf(buf + pos, bufsz - pos, "nrg_silence_idx:\t\t %u\n", + data->nrg_silence_idx); + pos += + scnprintf(buf + pos, bufsz - pos, "nrg_th_cck:\t\t\t %u\n", + data->nrg_th_cck); + pos += + scnprintf(buf + pos, bufsz - pos, + "nrg_auto_corr_silence_diff:\t %u\n", + data->nrg_auto_corr_silence_diff); + pos += + scnprintf(buf + pos, bufsz - pos, "num_in_cck_no_fa:\t\t %u\n", + data->num_in_cck_no_fa); + pos += + scnprintf(buf + pos, bufsz - pos, "nrg_th_ofdm:\t\t\t %u\n", + data->nrg_th_ofdm); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; } - -static ssize_t il_dbgfs_chain_noise_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_chain_noise_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) +{ struct il_priv *il = file->private_data; int pos = 0; @@ -963,48 +1044,60 @@ static ssize_t il_dbgfs_chain_noise_read(struct file *file, return -ENOMEM; } - pos += scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n", - data->active_chains); - pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n", - data->chain_noise_a); - pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n", - data->chain_noise_b); - pos += scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n", - data->chain_noise_c); - pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n", - data->chain_signal_a); - pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n", - data->chain_signal_b); - pos += scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n", - data->chain_signal_c); - pos += scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n", - data->beacon_count); + pos += + scnprintf(buf + pos, bufsz - pos, "active_chains:\t\t\t %u\n", + data->active_chains); + pos += + scnprintf(buf + pos, bufsz - pos, "chain_noise_a:\t\t\t %u\n", + data->chain_noise_a); + pos += + scnprintf(buf + pos, bufsz - pos, "chain_noise_b:\t\t\t %u\n", + data->chain_noise_b); + pos += + scnprintf(buf + pos, bufsz - pos, "chain_noise_c:\t\t\t %u\n", + data->chain_noise_c); + pos += + scnprintf(buf + pos, bufsz - pos, "chain_signal_a:\t\t\t %u\n", + data->chain_signal_a); + pos += + scnprintf(buf + pos, bufsz - pos, "chain_signal_b:\t\t\t %u\n", + data->chain_signal_b); + pos += + scnprintf(buf + pos, bufsz - pos, "chain_signal_c:\t\t\t %u\n", + data->chain_signal_c); + pos += + scnprintf(buf + pos, bufsz - pos, "beacon_count:\t\t\t %u\n", + data->beacon_count); pos += scnprintf(buf + pos, bufsz - pos, "disconn_array:\t\t\t"); for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, " %u", - data->disconn_array[cnt]); + pos += + scnprintf(buf + pos, bufsz - pos, " %u", + data->disconn_array[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "\n"); pos += scnprintf(buf + pos, bufsz - pos, "delta_gain_code:\t\t"); for (cnt = 0; cnt < NUM_RX_CHAINS; cnt++) { - pos += scnprintf(buf + pos, bufsz - pos, " %u", - data->delta_gain_code[cnt]); + pos += + scnprintf(buf + pos, bufsz - pos, " %u", + data->delta_gain_code[cnt]); } pos += scnprintf(buf + pos, bufsz - pos, "\n"); - pos += scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n", - data->radio_write); - pos += scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n", - data->state); + pos += + scnprintf(buf + pos, bufsz - pos, "radio_write:\t\t\t %u\n", + data->radio_write); + pos += + scnprintf(buf + pos, bufsz - pos, "state:\t\t\t\t %u\n", + data->state); ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos); kfree(buf); return ret; } -static ssize_t il_dbgfs_power_save_status_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_power_save_status_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; char buf[60]; @@ -1012,22 +1105,25 @@ static ssize_t il_dbgfs_power_save_status_read(struct file *file, const size_t bufsz = sizeof(buf); u32 pwrsave_status; - pwrsave_status = _il_rd(il, CSR_GP_CNTRL) & - CSR_GP_REG_POWER_SAVE_STATUS_MSK; + pwrsave_status = + _il_rd(il, CSR_GP_CNTRL) & CSR_GP_REG_POWER_SAVE_STATUS_MSK; pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: "); - pos += scnprintf(buf + pos, bufsz - pos, "%s\n", - (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" : - (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" : - (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" : - "error"); + pos += + scnprintf(buf + pos, bufsz - pos, "%s\n", + (pwrsave_status == + CSR_GP_REG_NO_POWER_SAVE) ? "none" : (pwrsave_status == + CSR_GP_REG_MAC_POWER_SAVE) + ? "MAC" : (pwrsave_status == + CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" : "error"); return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t il_dbgfs_clear_ucode_stats_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_clear_ucode_stats_write(struct file *file, + const char __user * user_buf, size_t count, + loff_t * ppos) { struct il_priv *il = file->private_data; char buf[8]; @@ -1035,7 +1131,7 @@ static ssize_t il_dbgfs_clear_ucode_stats_write(struct file *file, int clear; memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); + buf_size = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, buf_size)) return -EFAULT; if (sscanf(buf, "%d", &clear) != 1) @@ -1049,35 +1145,36 @@ static ssize_t il_dbgfs_clear_ucode_stats_write(struct file *file, return count; } -static ssize_t il_dbgfs_rxon_flags_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_rxon_flags_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) +{ struct il_priv *il = file->private_data; int len = 0; char buf[20]; - len = sprintf(buf, "0x%04X\n", - le32_to_cpu(il->ctx.active.flags)); + len = sprintf(buf, "0x%04X\n", le32_to_cpu(il->ctx.active.flags)); return simple_read_from_buffer(user_buf, count, ppos, buf, len); } -static ssize_t il_dbgfs_rxon_filter_flags_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_rxon_filter_flags_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) +{ struct il_priv *il = file->private_data; int len = 0; char buf[20]; - len = sprintf(buf, "0x%04X\n", - le32_to_cpu(il->ctx.active.filter_flags)); + len = + sprintf(buf, "0x%04X\n", le32_to_cpu(il->ctx.active.filter_flags)); return simple_read_from_buffer(user_buf, count, ppos, buf, len); } -static ssize_t il_dbgfs_fh_reg_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_fh_reg_read(struct file *file, char __user * user_buf, size_t count, + loff_t * ppos) { struct il_priv *il = file->private_data; char *buf; @@ -1087,8 +1184,9 @@ static ssize_t il_dbgfs_fh_reg_read(struct file *file, if (il->cfg->ops->lib->dump_fh) { ret = pos = il->cfg->ops->lib->dump_fh(il, &buf, true); if (buf) { - ret = simple_read_from_buffer(user_buf, - count, ppos, buf, pos); + ret = + simple_read_from_buffer(user_buf, count, ppos, buf, + pos); kfree(buf); } } @@ -1096,24 +1194,26 @@ static ssize_t il_dbgfs_fh_reg_read(struct file *file, return ret; } -static ssize_t il_dbgfs_missed_beacon_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_missed_beacon_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) +{ struct il_priv *il = file->private_data; int pos = 0; char buf[12]; const size_t bufsz = sizeof(buf); - pos += scnprintf(buf + pos, bufsz - pos, "%d\n", - il->missed_beacon_threshold); + pos += + scnprintf(buf + pos, bufsz - pos, "%d\n", + il->missed_beacon_threshold); return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t il_dbgfs_missed_beacon_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) +static ssize_t +il_dbgfs_missed_beacon_write(struct file *file, const char __user * user_buf, + size_t count, loff_t * ppos) { struct il_priv *il = file->private_data; char buf[8]; @@ -1121,7 +1221,7 @@ static ssize_t il_dbgfs_missed_beacon_write(struct file *file, int missed; memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); + buf_size = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, buf_size)) return -EFAULT; if (sscanf(buf, "%d", &missed) != 1) @@ -1129,17 +1229,17 @@ static ssize_t il_dbgfs_missed_beacon_write(struct file *file, if (missed < IL_MISSED_BEACON_THRESHOLD_MIN || missed > IL_MISSED_BEACON_THRESHOLD_MAX) - il->missed_beacon_threshold = - IL_MISSED_BEACON_THRESHOLD_DEF; + il->missed_beacon_threshold = IL_MISSED_BEACON_THRESHOLD_DEF; else il->missed_beacon_threshold = missed; return count; } -static ssize_t il_dbgfs_force_reset_read(struct file *file, - char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_force_reset_read(struct file *file, char __user * user_buf, + size_t count, loff_t * ppos) +{ struct il_priv *il = file->private_data; int pos = 0; @@ -1149,25 +1249,28 @@ static ssize_t il_dbgfs_force_reset_read(struct file *file, force_reset = &il->force_reset; - pos += scnprintf(buf + pos, bufsz - pos, - "\tnumber of reset request: %d\n", - force_reset->reset_request_count); - pos += scnprintf(buf + pos, bufsz - pos, - "\tnumber of reset request success: %d\n", - force_reset->reset_success_count); - pos += scnprintf(buf + pos, bufsz - pos, - "\tnumber of reset request reject: %d\n", - force_reset->reset_reject_count); - pos += scnprintf(buf + pos, bufsz - pos, - "\treset duration: %lu\n", - force_reset->reset_duration); + pos += + scnprintf(buf + pos, bufsz - pos, "\tnumber of reset request: %d\n", + force_reset->reset_request_count); + pos += + scnprintf(buf + pos, bufsz - pos, + "\tnumber of reset request success: %d\n", + force_reset->reset_success_count); + pos += + scnprintf(buf + pos, bufsz - pos, + "\tnumber of reset request reject: %d\n", + force_reset->reset_reject_count); + pos += + scnprintf(buf + pos, bufsz - pos, "\treset duration: %lu\n", + force_reset->reset_duration); return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } -static ssize_t il_dbgfs_force_reset_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_force_reset_write(struct file *file, const char __user * user_buf, + size_t count, loff_t * ppos) +{ int ret; struct il_priv *il = file->private_data; @@ -1177,9 +1280,10 @@ static ssize_t il_dbgfs_force_reset_write(struct file *file, return ret ? ret : count; } -static ssize_t il_dbgfs_wd_timeout_write(struct file *file, - const char __user *user_buf, - size_t count, loff_t *ppos) { +static ssize_t +il_dbgfs_wd_timeout_write(struct file *file, const char __user * user_buf, + size_t count, loff_t * ppos) +{ struct il_priv *il = file->private_data; char buf[8]; @@ -1187,7 +1291,7 @@ static ssize_t il_dbgfs_wd_timeout_write(struct file *file, int timeout; memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); + buf_size = min(count, sizeof(buf) - 1); if (copy_from_user(buf, user_buf, buf_size)) return -EFAULT; if (sscanf(buf, "%d", &timeout) != 1) @@ -1224,7 +1328,8 @@ DEBUGFS_WRITE_FILE_OPS(wd_timeout); * Create the debugfs files and directories * */ -int il_dbgfs_register(struct il_priv *il, const char *name) +int +il_dbgfs_register(struct il_priv *il, const char *name) { struct dentry *phyd = il->hw->wiphy->debugfsdir; struct dentry *dir_drv, *dir_data, *dir_rf, *dir_debug; @@ -1281,8 +1386,7 @@ int il_dbgfs_register(struct il_priv *il, const char *name) if (il->cfg->base_params->chain_noise_calib_by_driver) DEBUGFS_ADD_BOOL(disable_chain_noise, dir_rf, &il->disable_chain_noise_cal); - DEBUGFS_ADD_BOOL(disable_tx_power, dir_rf, - &il->disable_tx_power_cal); + DEBUGFS_ADD_BOOL(disable_tx_power, dir_rf, &il->disable_tx_power_cal); return 0; err: @@ -1290,13 +1394,15 @@ err: il_dbgfs_unregister(il); return -ENOMEM; } + EXPORT_SYMBOL(il_dbgfs_register); /** * Remove the debugfs files and directories * */ -void il_dbgfs_unregister(struct il_priv *il) +void +il_dbgfs_unregister(struct il_priv *il) { if (!il->debugfs_dir) return; @@ -1304,4 +1410,5 @@ void il_dbgfs_unregister(struct il_priv *il) debugfs_remove_recursive(il->debugfs_dir); il->debugfs_dir = NULL; } + EXPORT_SYMBOL(il_dbgfs_unregister); diff --git a/drivers/net/wireless/iwlegacy/prph.h b/drivers/net/wireless/iwlegacy/prph.h index 029ea8a83dff..ffec4b4a248a 100644 --- a/drivers/net/wireless/iwlegacy/prph.h +++ b/drivers/net/wireless/iwlegacy/prph.h @@ -91,9 +91,9 @@ #define APMG_PS_CTRL_VAL_RESET_REQ (0x04000000) #define APMG_PS_CTRL_MSK_PWR_SRC (0x03000000) #define APMG_PS_CTRL_VAL_PWR_SRC_VMAIN (0x00000000) -#define APMG_PS_CTRL_VAL_PWR_SRC_MAX (0x01000000) /* 3945 only */ +#define APMG_PS_CTRL_VAL_PWR_SRC_MAX (0x01000000) /* 3945 only */ #define APMG_PS_CTRL_VAL_PWR_SRC_VAUX (0x02000000) -#define APMG_SVR_VOLTAGE_CONFIG_BIT_MSK (0x000001E0) /* bit 8:5 */ +#define APMG_SVR_VOLTAGE_CONFIG_BIT_MSK (0x000001E0) /* bit 8:5 */ #define APMG_SVR_DIGITAL_VOLTAGE_1_32 (0x00000060) #define APMG_PCIDEV_STT_VAL_L1_ACT_DIS (0x00000800) @@ -202,19 +202,19 @@ */ /* BSM bit fields */ -#define BSM_WR_CTRL_REG_BIT_START (0x80000000) /* start boot load now */ -#define BSM_WR_CTRL_REG_BIT_START_EN (0x40000000) /* enable boot after pwrup*/ -#define BSM_DRAM_INST_LOAD (0x80000000) /* start program load now */ +#define BSM_WR_CTRL_REG_BIT_START (0x80000000) /* start boot load now */ +#define BSM_WR_CTRL_REG_BIT_START_EN (0x40000000) /* enable boot after pwrup */ +#define BSM_DRAM_INST_LOAD (0x80000000) /* start program load now */ /* BSM addresses */ #define BSM_BASE (PRPH_BASE + 0x3400) #define BSM_END (PRPH_BASE + 0x3800) -#define BSM_WR_CTRL_REG (BSM_BASE + 0x000) /* ctl and status */ -#define BSM_WR_MEM_SRC_REG (BSM_BASE + 0x004) /* source in BSM mem */ -#define BSM_WR_MEM_DST_REG (BSM_BASE + 0x008) /* dest in SRAM mem */ -#define BSM_WR_DWCOUNT_REG (BSM_BASE + 0x00C) /* bytes */ -#define BSM_WR_STATUS_REG (BSM_BASE + 0x010) /* bit 0: 1 == done */ +#define BSM_WR_CTRL_REG (BSM_BASE + 0x000) /* ctl and status */ +#define BSM_WR_MEM_SRC_REG (BSM_BASE + 0x004) /* source in BSM mem */ +#define BSM_WR_MEM_DST_REG (BSM_BASE + 0x008) /* dest in SRAM mem */ +#define BSM_WR_DWCOUNT_REG (BSM_BASE + 0x00C) /* bytes */ +#define BSM_WR_STATUS_REG (BSM_BASE + 0x010) /* bit 0: 1 == done */ /* * Pointers and size regs for bootstrap load and data SRAM save/restore. @@ -231,8 +231,7 @@ * Read/write, address range from LOWER_BOUND to (LOWER_BOUND + SIZE -1) */ #define BSM_SRAM_LOWER_BOUND (PRPH_BASE + 0x3800) -#define BSM_SRAM_SIZE (1024) /* bytes */ - +#define BSM_SRAM_SIZE (1024) /* bytes */ /* 3945 Tx scheduler registers */ #define ALM_SCD_BASE (PRPH_BASE + 0x2E00) @@ -520,4 +519,4 @@ /*********************** END TX SCHEDULER *************************************/ -#endif /* __il_prph_h__ */ +#endif /* __il_prph_h__ */ -- cgit v1.2.3 From 1722f8e12a9c6117d872bd19ec5919460ccdfb4e Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 14:51:01 +0100 Subject: iwlegacy: checkpatch.pl fixes Fix most checkpatch.pl ERRORs and some WARNINGs. Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/3945-debug.c | 12 +- drivers/net/wireless/iwlegacy/3945-mac.c | 10 +- drivers/net/wireless/iwlegacy/3945-rs.c | 4 +- drivers/net/wireless/iwlegacy/3945.c | 43 ++++---- drivers/net/wireless/iwlegacy/3945.h | 29 ++--- drivers/net/wireless/iwlegacy/4965-calib.c | 7 +- drivers/net/wireless/iwlegacy/4965-debug.c | 12 +- drivers/net/wireless/iwlegacy/4965-mac.c | 60 +++++----- drivers/net/wireless/iwlegacy/4965-rs.c | 36 +++--- drivers/net/wireless/iwlegacy/4965.c | 4 +- drivers/net/wireless/iwlegacy/4965.h | 30 ++--- drivers/net/wireless/iwlegacy/common.c | 157 ++++++-------------------- drivers/net/wireless/iwlegacy/common.h | 132 +++++++++++----------- drivers/net/wireless/iwlegacy/debug.c | 172 ++++++++++++++--------------- 14 files changed, 297 insertions(+), 411 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/3945-debug.c b/drivers/net/wireless/iwlegacy/3945-debug.c index 382af2e958eb..5e1a19fd354d 100644 --- a/drivers/net/wireless/iwlegacy/3945-debug.c +++ b/drivers/net/wireless/iwlegacy/3945-debug.c @@ -49,8 +49,8 @@ il3945_stats_flag(struct il_priv *il, char *buf, int bufsz) } ssize_t -il3945_ucode_rx_stats_read(struct file * file, char __user * user_buf, - size_t count, loff_t * ppos) +il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; int pos = 0; @@ -314,8 +314,8 @@ il3945_ucode_rx_stats_read(struct file * file, char __user * user_buf, } ssize_t -il3945_ucode_tx_stats_read(struct file * file, char __user * user_buf, - size_t count, loff_t * ppos) +il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; int pos = 0; @@ -404,8 +404,8 @@ il3945_ucode_tx_stats_read(struct file * file, char __user * user_buf, } ssize_t -il3945_ucode_general_stats_read(struct file * file, char __user * user_buf, - size_t count, loff_t * ppos) +il3945_ucode_general_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; int pos = 0; diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c index 2249fe44e669..daef6b58f6cc 100644 --- a/drivers/net/wireless/iwlegacy/3945-mac.c +++ b/drivers/net/wireless/iwlegacy/3945-mac.c @@ -1033,11 +1033,9 @@ il3945_rx_allocate(struct il_priv *il, gfp_t priority) D_INFO("Failed to allocate SKB buffer.\n"); if (rxq->free_count <= RX_LOW_WATERMARK && net_ratelimit()) - IL_ERR - ("Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", - priority == - GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL", - rxq->free_count); + IL_ERR("Failed to allocate SKB buffer with %0x." + "Only %u free buffers remaining.\n", + priority, rxq->free_count); /* We don't reschedule replenish work here -- we will * call the restock method and if it still needs * more buffers it will schedule replenish */ @@ -3250,7 +3248,7 @@ il3945_show_measurement(struct device *d, struct device_attribute *attr, struct il_priv *il = dev_get_drvdata(d); struct il_spectrum_notification measure_report; u32 size = sizeof(measure_report), len = 0, ofs = 0; - u8 *data = (u8 *) & measure_report; + u8 *data = (u8 *) &measure_report; unsigned long flags; spin_lock_irqsave(&il->lock, flags); diff --git a/drivers/net/wireless/iwlegacy/3945-rs.c b/drivers/net/wireless/iwlegacy/3945-rs.c index 3420b1c0ee0c..30ad404f8df7 100644 --- a/drivers/net/wireless/iwlegacy/3945-rs.c +++ b/drivers/net/wireless/iwlegacy/3945-rs.c @@ -837,8 +837,8 @@ il3945_open_file_generic(struct inode *inode, struct file *file) } static ssize_t -il3945_sta_dbgfs_stats_table_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il3945_sta_dbgfs_stats_table_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { char *buff; int desc = 0; diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 7f0b9f56f4be..7367dbb75ec6 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -381,10 +381,10 @@ il3945_accumulative_stats(struct il_priv *il, __le32 * stats) u32 *accum_stats; u32 *delta, *max_delta; - prev_stats = (__le32 *) & il->_3945.stats; - accum_stats = (u32 *) & il->_3945.accum_stats; - delta = (u32 *) & il->_3945.delta_stats; - max_delta = (u32 *) & il->_3945.max_delta; + prev_stats = (__le32 *) &il->_3945.stats; + accum_stats = (u32 *) &il->_3945.accum_stats; + delta = (u32 *) &il->_3945.delta_stats; + max_delta = (u32 *) &il->_3945.max_delta; for (i = sizeof(__le32); i < sizeof(struct il3945_notif_stats); i += @@ -416,7 +416,7 @@ il3945_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb) (int)sizeof(struct il3945_notif_stats), le32_to_cpu(pkt->len_n_flags) & IL_RX_FRAME_SIZE_MSK); #ifdef CONFIG_IWLEGACY_DEBUGFS - il3945_accumulative_stats(il, (__le32 *) & pkt->u.raw); + il3945_accumulative_stats(il, (__le32 *) &pkt->u.raw); #endif memcpy(&il->_3945.stats, pkt->u.raw, sizeof(il->_3945.stats)); @@ -426,7 +426,7 @@ void il3945_hdl_c_stats(struct il_priv *il, struct il_rx_buf *rxb) { struct il_rx_pkt *pkt = rxb_addr(rxb); - __le32 *flag = (__le32 *) & pkt->u.raw; + __le32 *flag = (__le32 *) &pkt->u.raw; if (le32_to_cpu(*flag) & UCODE_STATS_CLEAR_MSK) { #ifdef CONFIG_IWLEGACY_DEBUGFS @@ -775,7 +775,8 @@ il3945_set_pwr_vmain(struct il_priv *il) APMG_PS_CTRL_VAL_PWR_SRC_VMAIN, ~APMG_PS_CTRL_MSK_PWR_SRC); - _il_poll_bit(il, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC, CSR_GPIO_IN_BIT_AUX_POWER, 5000); /* uS */ + _il_poll_bit(il, CSR_GPIO_IN, CSR_GPIO_IN_VAL_VMAIN_PWR_SRC, + CSR_GPIO_IN_BIT_AUX_POWER, 5000); } static int @@ -1228,7 +1229,8 @@ static struct il3945_tx_power power_gain_table[2][IL_MAX_GAIN_ENTRIES] = { {3, 113}, {3, 106}, {3, 102}, - {3, 95}}, /* 2.4 GHz, lowest power */ + {3, 95} /* 2.4 GHz, lowest power */ + }, { {251, 127}, /* 5.x GHz, highest power */ {251, 120}, @@ -1307,7 +1309,8 @@ static struct il3945_tx_power power_gain_table[2][IL_MAX_GAIN_ENTRIES] = { {35, 113}, {35, 107}, {35, 99}, - {3, 120}} /* 5.x GHz, lowest power */ + {3, 120} /* 5.x GHz, lowest power */ + } }; static inline u8 @@ -1331,7 +1334,7 @@ il3945_hw_reg_fix_power_idx(int idx) */ static void il3945_hw_reg_set_scan_power(struct il_priv *il, u32 scan_tbl_idx, s32 rate_idx, - const s8 * clip_pwrs, + const s8 *clip_pwrs, struct il_channel_info *ch_info, int band_idx) { struct il3945_scan_power_info *scan_power_info; @@ -1883,8 +1886,7 @@ il3945_bg_reg_txpower_periodic(struct work_struct *work) } /** - * il3945_hw_reg_get_ch_grp_idx - find the channel-group idx (0-4) - * for the channel. + * il3945_hw_reg_get_ch_grp_idx - find the channel-group idx (0-4) for channel. * * This function is used when initializing channel-info structs. * @@ -1930,7 +1932,7 @@ il3945_hw_reg_get_ch_grp_idx(struct il_priv *il, */ static int il3945_hw_reg_get_matched_power_idx(struct il_priv *il, s8 requested_power, - s32 setting_idx, s32 * new_idx) + s32 setting_idx, s32 *new_idx) { const struct il3945_eeprom_txpower_group *chnl_grp = NULL; struct il3945_eeprom *eeprom = (struct il3945_eeprom *)il->eeprom; @@ -2735,14 +2737,13 @@ static struct il_cfg il3945_abg_cfg = { }; DEFINE_PCI_DEVICE_TABLE(il3945_hw_card_ids) = { - { - IL_PCI_DEVICE(0x4222, 0x1005, il3945_bg_cfg)}, { - IL_PCI_DEVICE(0x4222, 0x1034, il3945_bg_cfg)}, { - IL_PCI_DEVICE(0x4222, 0x1044, il3945_bg_cfg)}, { - IL_PCI_DEVICE(0x4227, 0x1014, il3945_bg_cfg)}, { - IL_PCI_DEVICE(0x4222, PCI_ANY_ID, il3945_abg_cfg)}, { - IL_PCI_DEVICE(0x4227, PCI_ANY_ID, il3945_abg_cfg)}, { - 0} + {IL_PCI_DEVICE(0x4222, 0x1005, il3945_bg_cfg)}, + {IL_PCI_DEVICE(0x4222, 0x1034, il3945_bg_cfg)}, + {IL_PCI_DEVICE(0x4222, 0x1044, il3945_bg_cfg)}, + {IL_PCI_DEVICE(0x4227, 0x1014, il3945_bg_cfg)}, + {IL_PCI_DEVICE(0x4222, PCI_ANY_ID, il3945_abg_cfg)}, + {IL_PCI_DEVICE(0x4227, PCI_ANY_ID, il3945_abg_cfg)}, + {0} }; MODULE_DEVICE_TABLE(pci, il3945_hw_card_ids); diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index 8e53751270f0..00d3336fd16b 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -269,11 +269,6 @@ extern int il3945_init_hw_rate_table(struct il_priv *il); extern void il3945_reg_txpower_periodic(struct il_priv *il); extern int il3945_txpower_set_from_eeprom(struct il_priv *il); -extern const struct il_channel_info *il3945_get_channel_info(const struct - il_priv *il, - enum ieee80211_band - band, u16 channel); - extern int il3945_rs_next_rate(struct il_priv *il, int rate); /* scanning */ @@ -619,31 +614,31 @@ struct il3945_tfd { } __packed; #ifdef CONFIG_IWLEGACY_DEBUGFS -ssize_t il3945_ucode_rx_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos); -ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos); +ssize_t il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); +ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); ssize_t il3945_ucode_general_stats_read(struct file *file, - char __user * user_buf, size_t count, - loff_t * ppos); + char __user *user_buf, size_t count, + loff_t *ppos); #else static ssize_t -il3945_ucode_rx_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { return 0; } static ssize_t -il3945_ucode_tx_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { return 0; } static ssize_t -il3945_ucode_general_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il3945_ucode_general_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { return 0; } diff --git a/drivers/net/wireless/iwlegacy/4965-calib.c b/drivers/net/wireless/iwlegacy/4965-calib.c index efb32331ec88..d3248e3ef23b 100644 --- a/drivers/net/wireless/iwlegacy/4965-calib.c +++ b/drivers/net/wireless/iwlegacy/4965-calib.c @@ -366,7 +366,7 @@ il4965_sens_auto_corr_ofdm(struct il_priv *il, u32 norm_fa, u32 rx_enable_time) static void il4965_prepare_legacy_sensitivity_tbl(struct il_priv *il, struct il_sensitivity_data *data, - __le16 * tbl) + __le16 *tbl) { tbl[HD_AUTO_CORR32_X4_TH_ADD_MIN_IDX] = cpu_to_le16((u16) data->auto_corr_ofdm); @@ -707,9 +707,8 @@ il4965_find_disconn_antenna(struct il_priv *il, u32 * average_sig, il4965_find_first_chain(il->cfg->valid_tx_ant); data->disconn_array[first_chain] = 0; active_chains |= BIT(first_chain); - D_CALIB - ("All Tx chains are disconnected W/A - declare %d as connected\n", - first_chain); + D_CALIB("All Tx chains are disconnected" + "- declare %d as connected\n", first_chain); break; } } diff --git a/drivers/net/wireless/iwlegacy/4965-debug.c b/drivers/net/wireless/iwlegacy/4965-debug.c index 529939938600..98ec39f56ba3 100644 --- a/drivers/net/wireless/iwlegacy/4965-debug.c +++ b/drivers/net/wireless/iwlegacy/4965-debug.c @@ -56,8 +56,8 @@ il4965_stats_flag(struct il_priv *il, char *buf, int bufsz) } ssize_t -il4965_ucode_rx_stats_read(struct file * file, char __user * user_buf, - size_t count, loff_t * ppos) +il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; int pos = 0; @@ -468,8 +468,8 @@ il4965_ucode_rx_stats_read(struct file * file, char __user * user_buf, } ssize_t -il4965_ucode_tx_stats_read(struct file * file, char __user * user_buf, - size_t count, loff_t * ppos) +il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; int pos = 0; @@ -634,8 +634,8 @@ il4965_ucode_tx_stats_read(struct file * file, char __user * user_buf, } ssize_t -il4965_ucode_general_stats_read(struct file * file, char __user * user_buf, - size_t count, loff_t * ppos) +il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; int pos = 0; diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index ca819d872097..21a1381c9748 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -163,10 +163,10 @@ il4965_rx_init(struct il_priv *il, struct il_rx_queue *rxq) il_wr(il, FH49_MEM_RCSR_CHNL0_CONFIG_REG, FH49_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL | FH49_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL | - FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK | rb_size | (rb_timeout - << - FH49_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS) - | (rfdnlog << FH49_RCSR_RX_CONFIG_RBDCB_SIZE_POS)); + FH49_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK | + rb_size | + (rb_timeout << FH49_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS) | + (rfdnlog << FH49_RCSR_RX_CONFIG_RBDCB_SIZE_POS)); /* Set interrupt coalescing timer to default (2048 usecs) */ il_write8(il, CSR_INT_COALESCING, IL_HOST_INT_TIMEOUT_DEF); @@ -1235,9 +1235,8 @@ il4965_dump_fh(struct il_priv *il, char **buf, bool display) pos += scnprintf(*buf + pos, bufsz - pos, " %34s: 0X%08x\n", - il4965_get_fh_string(fh_tbl[i]), il_rd(il, - fh_tbl - [i])); + il4965_get_fh_string(fh_tbl[i]), + il_rd(il, fh_tbl[i])); } return pos; } @@ -1328,15 +1327,15 @@ il4965_accumulative_stats(struct il_priv *il, __le32 * stats) struct stats_general_common *general, *accum_general; struct stats_tx *tx, *accum_tx; - prev_stats = (__le32 *) & il->_4965.stats; - accum_stats = (u32 *) & il->_4965.accum_stats; + prev_stats = (__le32 *) &il->_4965.stats; + accum_stats = (u32 *) &il->_4965.accum_stats; size = sizeof(struct il_notif_stats); general = &il->_4965.stats.general.common; accum_general = &il->_4965.accum_stats.general.common; tx = &il->_4965.stats.tx; accum_tx = &il->_4965.accum_stats.tx; - delta = (u32 *) & il->_4965.delta_stats; - max_delta = (u32 *) & il->_4965.max_delta; + delta = (u32 *) &il->_4965.delta_stats; + max_delta = (u32 *) &il->_4965.max_delta; for (i = sizeof(__le32); i < size; i += @@ -1375,7 +1374,7 @@ il4965_hdl_stats(struct il_priv *il, struct il_rx_buf *rxb) ((il->_4965.stats.flag & STATS_REPLY_FLG_HT40_MODE_MSK) != (pkt->u.stats.flag & STATS_REPLY_FLG_HT40_MODE_MSK))); #ifdef CONFIG_IWLEGACY_DEBUGFS - il4965_accumulative_stats(il, (__le32 *) & pkt->u.stats); + il4965_accumulative_stats(il, (__le32 *) &pkt->u.stats); #endif /* TODO: reading some of stats is unneeded */ @@ -2093,8 +2092,8 @@ il4965_txq_ctx_stop(struct il_priv *il) (il, FH49_TSSR_TX_STATUS_REG, FH49_TSSR_TX_STATUS_REG_MSK_CHNL_IDLE(ch), 1000)) IL_ERR("Failing on timeout while stopping" - " DMA channel %d [0x%08x]", ch, il_rd(il, - FH49_TSSR_TX_STATUS_REG)); + " DMA channel %d [0x%08x]", ch, + il_rd(il, FH49_TSSR_TX_STATUS_REG)); } spin_unlock_irqrestore(&il->lock, flags); @@ -2135,8 +2134,8 @@ il4965_tx_queue_stop_scheduler(struct il_priv *il, u16 txq_id) /* Simply stop the queue, but don't change any configuration; * the SCD_ACT_EN bit is the write-enable mask for the ACTIVE bit. */ il_wr_prph(il, IL49_SCD_QUEUE_STATUS_BITS(txq_id), - (0 << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | (1 << - IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); + (0 << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | + (1 << IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACT_EN)); } /** @@ -2451,7 +2450,7 @@ il4965_txq_check_empty(struct il_priv *il, int sta_id, u8 tid, int txq_id) static void il4965_non_agg_tx_status(struct il_priv *il, struct il_rxon_context *ctx, - const u8 * addr1) + const u8 *addr1) { struct ieee80211_sta *sta; struct il_station_priv *sta_priv; @@ -2661,7 +2660,7 @@ il4965_hdl_compressed_ba(struct il_priv *il, struct il_rx_buf *rxb) spin_lock_irqsave(&il->sta_lock, flags); D_TX_REPLY("N_COMPRESSED_BA [%d] Received from %pM, " "sta_id = %d\n", - agg->wait_for_ba, (u8 *) & ba_resp->sta_addr_lo32, + agg->wait_for_ba, (u8 *) &ba_resp->sta_addr_lo32, ba_resp->sta_id); D_TX_REPLY("TID = %d, SeqCtl = %d, bitmap = 0x%llx," "scd_flow = " "%d, scd_ssn = %d\n", ba_resp->tid, ba_resp->seq_ctl, @@ -2791,7 +2790,7 @@ il4965_sta_alloc_lq(struct il_priv *il, u8 sta_id) */ int il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, - const u8 * addr, u8 * sta_id_r) + const u8 *addr, u8 *sta_id_r) { int ret; u8 sta_id; @@ -3277,8 +3276,7 @@ il4965_update_bcast_station(struct il_priv *il, struct il_rxon_context *ctx) link_cmd = il4965_sta_alloc_lq(il, sta_id); if (!link_cmd) { - IL_ERR - ("Unable to initialize rate scaling for bcast station.\n"); + IL_ERR("Unable to initialize rate scaling for bcast sta.\n"); return -ENOMEM; } @@ -3286,8 +3284,7 @@ il4965_update_bcast_station(struct il_priv *il, struct il_rxon_context *ctx) if (il->stations[sta_id].lq) kfree(il->stations[sta_id].lq); else - D_INFO - ("Bcast station rate scaling has not been initialized yet.\n"); + D_INFO("Bcast sta rate scaling has not been initialized.\n"); il->stations[sta_id].lq = link_cmd; spin_unlock_irqrestore(&il->sta_lock, flags); @@ -4819,11 +4816,10 @@ il4965_dump_nic_error_log(struct il_priv *il) u32 blink1, blink2, ilink1, ilink2; u32 pc, hcmd; - if (il->ucode_type == UCODE_INIT) { + if (il->ucode_type == UCODE_INIT) base = le32_to_cpu(il->card_alive_init.error_event_table_ptr); - } else { + else base = le32_to_cpu(il->card_alive.error_event_table_ptr); - } if (!il->cfg->ops->lib->is_valid_rtc_data_addr(base)) { IL_ERR("Not valid error log pointer 0x%08X for %s uCode\n", @@ -6026,13 +6022,11 @@ il4965_tx_queue_set_status(struct il_priv *il, struct il_tx_queue *txq, /* Set up and activate */ il_wr_prph(il, IL49_SCD_QUEUE_STATUS_BITS(txq_id), - (active << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | (tx_fifo_id - << - IL49_SCD_QUEUE_STTS_REG_POS_TXF) - | (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_WSL) | (scd_retry - << - IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK) - | IL49_SCD_QUEUE_STTS_REG_MSK); + (active << IL49_SCD_QUEUE_STTS_REG_POS_ACTIVE) | + (tx_fifo_id << IL49_SCD_QUEUE_STTS_REG_POS_TXF) | + (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_WSL) | + (scd_retry << IL49_SCD_QUEUE_STTS_REG_POS_SCD_ACK) | + IL49_SCD_QUEUE_STTS_REG_MSK); txq->sched_retry = scd_retry; diff --git a/drivers/net/wireless/iwlegacy/4965-rs.c b/drivers/net/wireless/iwlegacy/4965-rs.c index 3ea236157058..4bc5a1845821 100644 --- a/drivers/net/wireless/iwlegacy/4965-rs.c +++ b/drivers/net/wireless/iwlegacy/4965-rs.c @@ -96,18 +96,18 @@ static const u8 ant_toggle_lookup[] = { */ const struct il_rate_info il_rates[RATE_COUNT] = { IL_DECLARE_RATE_INFO(1, INV, INV, 2, INV, 2, INV, 2), /* 1mbps */ - IL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ + IL_DECLARE_RATE_INFO(2, INV, 1, 5, 1, 5, 1, 5), /* 2mbps */ IL_DECLARE_RATE_INFO(5, INV, 2, 6, 2, 11, 2, 11), /*5.5mbps */ IL_DECLARE_RATE_INFO(11, INV, 9, 12, 9, 12, 5, 18), /* 11mbps */ - IL_DECLARE_RATE_INFO(6, 6, 5, 9, 5, 11, 5, 11), /* 6mbps */ + IL_DECLARE_RATE_INFO(6, 6, 5, 9, 5, 11, 5, 11), /* 6mbps */ IL_DECLARE_RATE_INFO(9, 6, 6, 11, 6, 11, 5, 11), /* 9mbps */ IL_DECLARE_RATE_INFO(12, 12, 11, 18, 11, 18, 11, 18), /* 12mbps */ IL_DECLARE_RATE_INFO(18, 18, 12, 24, 12, 24, 11, 24), /* 18mbps */ IL_DECLARE_RATE_INFO(24, 24, 18, 36, 18, 36, 18, 36), /* 24mbps */ IL_DECLARE_RATE_INFO(36, 36, 24, 48, 24, 48, 24, 48), /* 36mbps */ IL_DECLARE_RATE_INFO(48, 48, 36, 54, 36, 54, 36, 54), /* 48mbps */ - IL_DECLARE_RATE_INFO(54, 54, 48, INV, 48, INV, 48, INV), /* 54mbps */ - IL_DECLARE_RATE_INFO(60, 60, 48, INV, 48, INV, 48, INV), /* 60mbps */ + IL_DECLARE_RATE_INFO(54, 54, 48, INV, 48, INV, 48, INV),/* 54mbps */ + IL_DECLARE_RATE_INFO(60, 60, 48, INV, 48, INV, 48, INV),/* 60mbps */ }; static int @@ -150,7 +150,7 @@ static void il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, #ifdef CONFIG_MAC80211_DEBUGFS static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, - u32 * rate_n_flags, int idx); + u32 *rate_n_flags, int idx); #else static void il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, u32 * rate_n_flags, int idx) @@ -610,7 +610,7 @@ il4965_rs_get_tbl_info_from_mcs(const u32 rate_n_flags, /* switch to another antenna/antennas and return 1 */ /* if no other valid antenna found, return 0 */ static int -il4965_rs_toggle_antenna(u32 valid_ant, u32 * rate_n_flags, +il4965_rs_toggle_antenna(u32 valid_ant, u32 *rate_n_flags, struct il_scale_tbl_info *tbl) { u8 new_ant_type; @@ -1082,7 +1082,8 @@ il4965_rs_set_expected_tpt_table(struct il_lq_sta *lq_sta, * bit rate will typically need to increase, but not if performance was bad. */ static s32 -il4965_rs_get_best_rate(struct il_priv *il, struct il_lq_sta *lq_sta, struct il_scale_tbl_info *tbl, /* "search" */ +il4965_rs_get_best_rate(struct il_priv *il, struct il_lq_sta *lq_sta, + struct il_scale_tbl_info *tbl, /* "search" */ u16 rate_mask, s8 idx) { /* "active" values */ @@ -2012,11 +2013,10 @@ il4965_rs_rate_scale_perform(struct il_priv *il, struct sk_buff *skb, /* Higher adjacent rate's throughput is measured */ if (high_tpt != IL_INVALID_VALUE) { /* Higher rate has better throughput */ - if (high_tpt > current_tpt && sr >= RATE_INCREASE_TH) { + if (high_tpt > current_tpt && sr >= RATE_INCREASE_TH) scale_action = 1; - } else { + else scale_action = 0; - } /* Lower adjacent rate's throughput is measured */ } else if (low_tpt != IL_INVALID_VALUE) { @@ -2583,8 +2583,8 @@ il4965_rs_dbgfs_set_mcs(struct il_lq_sta *lq_sta, u32 * rate_n_flags, int idx) static ssize_t il4965_rs_sta_dbgfs_scale_table_write(struct file *file, - const char __user * user_buf, - size_t count, loff_t * ppos) + const char __user *user_buf, + size_t count, loff_t *ppos) { struct il_lq_sta *lq_sta = file->private_data; struct il_priv *il; @@ -2622,8 +2622,8 @@ il4965_rs_sta_dbgfs_scale_table_write(struct file *file, } static ssize_t -il4965_rs_sta_dbgfs_scale_table_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il4965_rs_sta_dbgfs_scale_table_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { char *buff; int desc = 0; @@ -2730,8 +2730,8 @@ static const struct file_operations rs_sta_dbgfs_scale_table_ops = { }; static ssize_t -il4965_rs_sta_dbgfs_stats_table_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il4965_rs_sta_dbgfs_stats_table_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { char *buff; int desc = 0; @@ -2776,8 +2776,8 @@ static const struct file_operations rs_sta_dbgfs_stats_table_ops = { static ssize_t il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, - char __user * user_buf, size_t count, - loff_t * ppos) + char __user *user_buf, size_t count, + loff_t *ppos) { char buff[120]; int desc = 0; diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index be054f1452b8..6f5e6a15a2cb 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -533,8 +533,8 @@ il4965_nic_config(struct il_priv *il) CSR_HW_IF_CONFIG_REG_BIT_MAC_SI); il->calib_info = - (struct il_eeprom_calib_info *)il_eeprom_query_addr(il, - EEPROM_4965_CALIB_TXPOWER_OFFSET); + (struct il_eeprom_calib_info *) + il_eeprom_query_addr(il, EEPROM_4965_CALIB_TXPOWER_OFFSET); spin_unlock_irqrestore(&il->lock, flags); } diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h index 78eae22c8f29..ded8b922a44e 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -138,7 +138,7 @@ il4965_get_tx_fail_reason(u32 status) /* station management */ int il4965_alloc_bcast_station(struct il_priv *il, struct il_rxon_context *ctx); int il4965_add_bssid_station(struct il_priv *il, struct il_rxon_context *ctx, - const u8 * addr, u8 * sta_id_r); + const u8 *addr, u8 *sta_id_r); int il4965_remove_default_wep_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *key); @@ -153,7 +153,7 @@ int il4965_remove_dynamic_key(struct il_priv *il, struct il_rxon_context *ctx, void il4965_update_tkip_key(struct il_priv *il, struct il_rxon_context *ctx, struct ieee80211_key_conf *keyconf, struct ieee80211_sta *sta, u32 iv32, - u16 * phase1key); + u16 *phase1key); int il4965_sta_tx_modify_enable_tid(struct il_priv *il, int sta_id, int tid); int il4965_sta_rx_agg_start(struct il_priv *il, struct ieee80211_sta *sta, int tid, u16 ssn); @@ -195,7 +195,7 @@ void il4965_mac_update_tkip_key(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_key_conf *keyconf, struct ieee80211_sta *sta, u32 iv32, - u16 * phase1key); + u16 *phase1key); int il4965_mac_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, enum ieee80211_ampdu_mlme_action action, struct ieee80211_sta *sta, u16 tid, u16 * ssn, @@ -949,31 +949,31 @@ void il4965_calib_free_results(struct il_priv *il); /* Debug */ #ifdef CONFIG_IWLEGACY_DEBUGFS -ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos); -ssize_t il4965_ucode_tx_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos); +ssize_t il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); +ssize_t il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); ssize_t il4965_ucode_general_stats_read(struct file *file, - char __user * user_buf, size_t count, - loff_t * ppos); + char __user *user_buf, size_t count, + loff_t *ppos); #else static ssize_t -il4965_ucode_rx_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { return 0; } static ssize_t -il4965_ucode_tx_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { return 0; } static ssize_t -il4965_ucode_general_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { return 0; } diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 2e1bbb2e8464..7e2924f332a7 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -92,7 +92,6 @@ il_get_cmd_string(u8 cmd) } } - EXPORT_SYMBOL(il_get_cmd_string); #define HOST_COMPLETE_TIMEOUT (HZ / 2) @@ -231,7 +230,6 @@ fail: out: return ret; } - EXPORT_SYMBOL(il_send_cmd_sync); int @@ -242,7 +240,6 @@ il_send_cmd(struct il_priv *il, struct il_host_cmd *cmd) return il_send_cmd_sync(il, cmd); } - EXPORT_SYMBOL(il_send_cmd); int @@ -256,14 +253,13 @@ il_send_cmd_pdu(struct il_priv *il, u8 id, u16 len, const void *data) return il_send_cmd_sync(il, &cmd); } - EXPORT_SYMBOL(il_send_cmd_pdu); int il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, const void *data, - void (*callback) (struct il_priv * il, - struct il_device_cmd * cmd, - struct il_rx_pkt * pkt)) + void (*callback) (struct il_priv *il, + struct il_device_cmd *cmd, + struct il_rx_pkt *pkt)) { struct il_host_cmd cmd = { .id = id, @@ -276,7 +272,6 @@ il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, const void *data, return il_send_cmd_async(il, &cmd); } - EXPORT_SYMBOL(il_send_cmd_pdu_async); /* default: IL_LED_BLINK(0) using blinking idx table */ @@ -299,16 +294,16 @@ MODULE_PARM_DESC(led_mode, * <=0 SOLID ON */ static const struct ieee80211_tpt_blink il_blink[] = { - {.throughput = 0,.blink_time = 334}, - {.throughput = 1 * 1024 - 1,.blink_time = 260}, - {.throughput = 5 * 1024 - 1,.blink_time = 220}, - {.throughput = 10 * 1024 - 1,.blink_time = 190}, - {.throughput = 20 * 1024 - 1,.blink_time = 170}, - {.throughput = 50 * 1024 - 1,.blink_time = 150}, - {.throughput = 70 * 1024 - 1,.blink_time = 130}, - {.throughput = 100 * 1024 - 1,.blink_time = 110}, - {.throughput = 200 * 1024 - 1,.blink_time = 80}, - {.throughput = 300 * 1024 - 1,.blink_time = 50}, + {.throughput = 0, .blink_time = 334}, + {.throughput = 1 * 1024 - 1, .blink_time = 260}, + {.throughput = 5 * 1024 - 1, .blink_time = 220}, + {.throughput = 10 * 1024 - 1, .blink_time = 190}, + {.throughput = 20 * 1024 - 1, .blink_time = 170}, + {.throughput = 50 * 1024 - 1, .blink_time = 150}, + {.throughput = 70 * 1024 - 1, .blink_time = 130}, + {.throughput = 100 * 1024 - 1, .blink_time = 110}, + {.throughput = 200 * 1024 - 1, .blink_time = 80}, + {.throughput = 300 * 1024 - 1, .blink_time = 50}, }; /* @@ -433,7 +428,6 @@ il_leds_init(struct il_priv *il) il->led_registered = true; } - EXPORT_SYMBOL(il_leds_init); void @@ -445,7 +439,6 @@ il_leds_exit(struct il_priv *il) led_classdev_unregister(&il->led); kfree(il->led.name); } - EXPORT_SYMBOL(il_leds_exit); /************************** EEPROM BANDS **************************** @@ -540,17 +533,15 @@ il_eeprom_query_addr(const struct il_priv *il, size_t offset) BUG_ON(offset >= il->cfg->base_params->eeprom_size); return &il->eeprom[offset]; } - EXPORT_SYMBOL(il_eeprom_query_addr); u16 -il_eeprom_query16(const struct il_priv * il, size_t offset) +il_eeprom_query16(const struct il_priv *il, size_t offset) { if (!il->eeprom) return 0; return (u16) il->eeprom[offset] | ((u16) il->eeprom[offset + 1] << 8); } - EXPORT_SYMBOL(il_eeprom_query16); /** @@ -631,7 +622,6 @@ err: alloc_err: return ret; } - EXPORT_SYMBOL(il_eeprom_init); void @@ -640,14 +630,13 @@ il_eeprom_free(struct il_priv *il) kfree(il->eeprom); il->eeprom = NULL; } - EXPORT_SYMBOL(il_eeprom_free); static void il_init_band_reference(const struct il_priv *il, int eep_band, int *eeprom_ch_count, const struct il_eeprom_channel **eeprom_ch_info, - const u8 ** eeprom_ch_idx) + const u8 **eeprom_ch_idx) { u32 offset = il->cfg->ops->lib->eeprom_ops.regulatory_bands[eep_band - 1]; @@ -885,7 +874,6 @@ il_init_channel_map(struct il_priv *il) return 0; } - EXPORT_SYMBOL(il_init_channel_map); /* @@ -897,7 +885,6 @@ il_free_channel_map(struct il_priv *il) kfree(il->channel_info); il->channel_count = 0; } - EXPORT_SYMBOL(il_free_channel_map); /** @@ -928,7 +915,6 @@ il_get_channel_info(const struct il_priv *il, enum ieee80211_band band, return NULL; } - EXPORT_SYMBOL(il_get_channel_info); /* @@ -1033,7 +1019,6 @@ il_power_update_mode(struct il_priv *il, bool force) il_power_sleep_cam_cmd(il, &cmd); return il_power_set_mode(il, &cmd, force); } - EXPORT_SYMBOL(il_power_update_mode); /* initialize to default */ @@ -1172,7 +1157,6 @@ il_scan_cancel(struct il_priv *il) queue_work(il->workqueue, &il->abort_scan); return 0; } - EXPORT_SYMBOL(il_scan_cancel); /** @@ -1199,7 +1183,6 @@ il_scan_cancel_timeout(struct il_priv *il, unsigned long ms) return test_bit(S_SCAN_HW, &il->status); } - EXPORT_SYMBOL(il_scan_cancel_timeout); /* Service response to C_SCAN (0x80) */ @@ -1279,7 +1262,6 @@ il_setup_rx_scan_handlers(struct il_priv *il) il->handlers[N_SCAN_RESULTS] = il_hdl_scan_results; il->handlers[N_SCAN_COMPLETE] = il_hdl_scan_complete; } - EXPORT_SYMBOL(il_setup_rx_scan_handlers); inline u16 @@ -1293,12 +1275,11 @@ il_get_active_dwell_time(struct il_priv *il, enum ieee80211_band band, return IL_ACTIVE_DWELL_TIME_24 + IL_ACTIVE_DWELL_FACTOR_24GHZ * (n_probes + 1); } - EXPORT_SYMBOL(il_get_active_dwell_time); u16 -il_get_passive_dwell_time(struct il_priv * il, enum ieee80211_band band, - struct ieee80211_vif * vif) +il_get_passive_dwell_time(struct il_priv *il, enum ieee80211_band band, + struct ieee80211_vif *vif) { struct il_rxon_context *ctx = &il->ctx; u16 value; @@ -1324,7 +1305,6 @@ il_get_passive_dwell_time(struct il_priv * il, enum ieee80211_band band, return passive; } - EXPORT_SYMBOL(il_get_passive_dwell_time); void @@ -1336,7 +1316,6 @@ il_init_scan_params(struct il_priv *il) if (!il->scan_tx_ant[IEEE80211_BAND_2GHZ]) il->scan_tx_ant[IEEE80211_BAND_2GHZ] = ant_idx; } - EXPORT_SYMBOL(il_init_scan_params); static int @@ -1417,7 +1396,6 @@ out_unlock: return ret; } - EXPORT_SYMBOL(il_mac_hw_scan); static void @@ -1442,7 +1420,7 @@ il_bg_scan_check(struct work_struct *data) u16 il_fill_probe_req(struct il_priv *il, struct ieee80211_mgmt *frame, - const u8 * ta, const u8 * ies, int ie_len, int left) + const u8 *ta, const u8 *ies, int ie_len, int left) { int len = 0; u8 *pos = NULL; @@ -1483,7 +1461,6 @@ il_fill_probe_req(struct il_priv *il, struct ieee80211_mgmt *frame, return (u16) len; } - EXPORT_SYMBOL(il_fill_probe_req); static void @@ -1548,7 +1525,6 @@ il_setup_scan_deferred_work(struct il_priv *il) INIT_WORK(&il->abort_scan, il_bg_abort_scan); INIT_DELAYED_WORK(&il->scan_check, il_bg_scan_check); } - EXPORT_SYMBOL(il_setup_scan_deferred_work); void @@ -1563,7 +1539,6 @@ il_cancel_scan_deferred_work(struct il_priv *il) mutex_unlock(&il->mutex); } } - EXPORT_SYMBOL(il_cancel_scan_deferred_work); /* il->sta_lock must be held */ @@ -1693,7 +1668,6 @@ il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags) return ret; } - EXPORT_SYMBOL(il_send_add_sta); static void @@ -1709,10 +1683,9 @@ il_set_ht_add_station(struct il_priv *il, u8 idx, struct ieee80211_sta *sta, mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_SM_PS) >> 2; D_ASSOC("spatial multiplexing power save mode: %s\n", - (mimo_ps_mode == - WLAN_HT_CAP_SM_PS_STATIC) ? "static" : (mimo_ps_mode == - WLAN_HT_CAP_SM_PS_DYNAMIC) - ? "dynamic" : "disabled"); + (mimo_ps_mode == WLAN_HT_CAP_SM_PS_STATIC) ? "static" : + (mimo_ps_mode == WLAN_HT_CAP_SM_PS_DYNAMIC) ? "dynamic" : + "disabled"); sta_flags = il->stations[idx].sta.station_flags; @@ -1756,8 +1729,8 @@ done: * should be called with sta_lock held */ u8 -il_prep_station(struct il_priv * il, struct il_rxon_context * ctx, - const u8 * addr, bool is_ap, struct ieee80211_sta * sta) +il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, + const u8 *addr, bool is_ap, struct ieee80211_sta *sta) { struct il_station_entry *station; int i; @@ -1841,7 +1814,6 @@ il_prep_station(struct il_priv * il, struct il_rxon_context * ctx, return sta_id; } - EXPORT_SYMBOL_GPL(il_prep_station); #define STA_WAIT_TIMEOUT (HZ/2) @@ -1851,8 +1823,8 @@ EXPORT_SYMBOL_GPL(il_prep_station); */ int il_add_station_common(struct il_priv *il, struct il_rxon_context *ctx, - const u8 * addr, bool is_ap, struct ieee80211_sta *sta, - u8 * sta_id_r) + const u8 *addr, bool is_ap, struct ieee80211_sta *sta, + u8 *sta_id_r) { unsigned long flags_spin; int ret = 0; @@ -1905,7 +1877,6 @@ il_add_station_common(struct il_priv *il, struct il_rxon_context *ctx, *sta_id_r = sta_id; return ret; } - EXPORT_SYMBOL(il_add_station_common); /** @@ -2038,7 +2009,6 @@ out_err: spin_unlock_irqrestore(&il->sta_lock, flags); return -EINVAL; } - EXPORT_SYMBOL_GPL(il_remove_station); /** @@ -2074,7 +2044,6 @@ il_clear_ucode_stations(struct il_priv *il, struct il_rxon_context *ctx) if (!cleared) D_INFO("No active stations found to be cleared\n"); } - EXPORT_SYMBOL(il_clear_ucode_stations); /** @@ -2156,7 +2125,6 @@ il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx) else D_INFO("Restoring all known stations" " .... complete.\n"); } - EXPORT_SYMBOL(il_restore_stations); int @@ -2170,7 +2138,6 @@ il_get_free_ucode_key_idx(struct il_priv *il) return WEP_INVALID_OFFSET; } - EXPORT_SYMBOL(il_get_free_ucode_key_idx); void @@ -2192,7 +2159,6 @@ il_dealloc_bcast_stations(struct il_priv *il) } spin_unlock_irqrestore(&il->sta_lock, flags); } - EXPORT_SYMBOL_GPL(il_dealloc_bcast_stations); #ifdef CONFIG_IWLEGACY_DEBUG @@ -2299,7 +2265,6 @@ il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, } return ret; } - EXPORT_SYMBOL(il_send_lq_cmd); int @@ -2319,7 +2284,6 @@ il_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, mutex_unlock(&il->mutex); return ret; } - EXPORT_SYMBOL(il_mac_sta_remove); /************************** RX-FUNCTIONS ****************************/ @@ -2404,7 +2368,6 @@ il_rx_queue_space(const struct il_rx_queue *q) s = 0; return s; } - EXPORT_SYMBOL(il_rx_queue_space); /** @@ -2449,7 +2412,6 @@ il_rx_queue_update_write_ptr(struct il_priv *il, struct il_rx_queue *q) exit_unlock: spin_unlock_irqrestore(&q->lock, flags); } - EXPORT_SYMBOL(il_rx_queue_update_write_ptr); int @@ -2494,7 +2456,6 @@ err_rb: err_bd: return -ENOMEM; } - EXPORT_SYMBOL(il_rx_queue_alloc); void @@ -2511,7 +2472,6 @@ il_hdl_spectrum_measurement(struct il_priv *il, struct il_rx_buf *rxb) memcpy(&il->measure_report, report, sizeof(*report)); il->measurement_status |= MEASUREMENT_READY; } - EXPORT_SYMBOL(il_hdl_spectrum_measurement); /* @@ -2563,7 +2523,6 @@ il_set_decrypted_flag(struct il_priv *il, struct ieee80211_hdr *hdr, } return 0; } - EXPORT_SYMBOL(il_set_decrypted_flag); /** @@ -2604,7 +2563,6 @@ il_txq_update_write_ptr(struct il_priv *il, struct il_tx_queue *txq) _il_wr(il, HBUS_TARG_WRPTR, txq->q.write_ptr | (txq_id << 8)); txq->need_update = 0; } - EXPORT_SYMBOL(il_txq_update_write_ptr); /** @@ -2624,7 +2582,6 @@ il_tx_queue_unmap(struct il_priv *il, int txq_id) q->read_ptr = il_queue_inc_wrap(q->read_ptr, q->n_bd); } } - EXPORT_SYMBOL(il_tx_queue_unmap); /** @@ -2666,7 +2623,6 @@ il_tx_queue_free(struct il_priv *il, int txq_id) /* 0-fill queue descriptor structure */ memset(txq, 0, sizeof(*txq)); } - EXPORT_SYMBOL(il_tx_queue_free); /** @@ -2705,7 +2661,6 @@ il_cmd_queue_unmap(struct il_priv *il) txq->meta[i].flags = 0; } } - EXPORT_SYMBOL(il_cmd_queue_unmap); /** @@ -2743,7 +2698,6 @@ il_cmd_queue_free(struct il_priv *il) /* 0-fill queue descriptor structure */ memset(txq, 0, sizeof(*txq)); } - EXPORT_SYMBOL(il_cmd_queue_free); /*************** DMA-QUEUE-GENERAL-FUNCTIONS ***** @@ -2785,7 +2739,6 @@ il_queue_space(const struct il_queue *q) s = 0; return s; } - EXPORT_SYMBOL(il_queue_space); @@ -2940,7 +2893,6 @@ out_free_arrays: return -ENOMEM; } - EXPORT_SYMBOL(il_tx_queue_init); void @@ -2962,7 +2914,6 @@ il_tx_queue_reset(struct il_priv *il, struct il_tx_queue *txq, int slots_num, /* Tell device where to find queue */ il->cfg->ops->lib->txq_init(il, txq); } - EXPORT_SYMBOL(il_tx_queue_reset); /*************** HOST COMMAND QUEUE FUNCTIONS *****/ @@ -3219,7 +3170,6 @@ u32 il_debug_level; EXPORT_SYMBOL(il_debug_level); const u8 il_bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; - EXPORT_SYMBOL(il_bcast_addr); /* This function both allocates and initializes hw and il. */ @@ -3244,7 +3194,6 @@ il_alloc_all(struct il_cfg *cfg) out: return hw; } - EXPORT_SYMBOL(il_alloc_all); #define MAX_BIT_RATE_40_MHZ 150 /* Mbps */ @@ -3418,7 +3367,6 @@ il_init_geos(struct il_priv *il) return 0; } - EXPORT_SYMBOL(il_init_geos); /* @@ -3431,7 +3379,6 @@ il_free_geos(struct il_priv *il) kfree(il->ieee_rates); clear_bit(S_GEO_CONFIGURED, &il->status); } - EXPORT_SYMBOL(il_free_geos); static bool @@ -3455,8 +3402,8 @@ il_is_channel_extension(struct il_priv *il, enum ieee80211_band band, } bool -il_is_ht40_tx_allowed(struct il_priv * il, struct il_rxon_context * ctx, - struct ieee80211_sta_ht_cap * ht_cap) +il_is_ht40_tx_allowed(struct il_priv *il, struct il_rxon_context *ctx, + struct ieee80211_sta_ht_cap *ht_cap) { if (!ctx->ht.enabled || !ctx->ht.is_40mhz) return false; @@ -3477,7 +3424,6 @@ il_is_ht40_tx_allowed(struct il_priv * il, struct il_rxon_context * ctx, le16_to_cpu(ctx->staging.channel), ctx->ht.extension_chan_offset); } - EXPORT_SYMBOL(il_is_ht40_tx_allowed); static u16 @@ -3561,7 +3507,6 @@ il_send_rxon_timing(struct il_priv *il, struct il_rxon_context *ctx) return il_send_cmd_pdu(il, ctx->rxon_timing_cmd, sizeof(ctx->timing), &ctx->timing); } - EXPORT_SYMBOL(il_send_rxon_timing); void @@ -3576,7 +3521,6 @@ il_set_rxon_hwcrypto(struct il_priv *il, struct il_rxon_context *ctx, rxon->filter_flags |= RXON_FILTER_DIS_DECRYPT_MSK; } - EXPORT_SYMBOL(il_set_rxon_hwcrypto); /* validate RXON structure is valid */ @@ -3650,7 +3594,6 @@ il_check_rxon_cmd(struct il_priv *il, struct il_rxon_context *ctx) } return 0; } - EXPORT_SYMBOL(il_check_rxon_cmd); /** @@ -3713,11 +3656,10 @@ il_full_rxon_required(struct il_priv *il, struct il_rxon_context *ctx) return 0; } - EXPORT_SYMBOL(il_full_rxon_required); u8 -il_get_lowest_plcp(struct il_priv * il, struct il_rxon_context * ctx) +il_get_lowest_plcp(struct il_priv *il, struct il_rxon_context *ctx) { /* * Assign the lowest rate -- should really get this from @@ -3728,7 +3670,6 @@ il_get_lowest_plcp(struct il_priv * il, struct il_rxon_context * ctx) else return RATE_6M_PLCP; } - EXPORT_SYMBOL(il_get_lowest_plcp); static void @@ -3803,7 +3744,6 @@ il_set_rxon_ht(struct il_priv *il, struct il_ht_config *ht_conf) { _il_set_rxon_ht(il, ht_conf, &il->ctx); } - EXPORT_SYMBOL(il_set_rxon_ht); /* Return valid, unused, channel for a passive scan to reset the RF */ @@ -3835,7 +3775,6 @@ il_get_single_channel_number(struct il_priv *il, enum ieee80211_band band) return channel; } - EXPORT_SYMBOL(il_get_single_channel_number); /** @@ -3867,7 +3806,6 @@ il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch, return 0; } - EXPORT_SYMBOL(il_set_rxon_channel); void @@ -3891,7 +3829,6 @@ il_set_flags_for_band(struct il_priv *il, struct il_rxon_context *ctx, ctx->staging.flags &= ~RXON_FLG_CCK_MSK; } } - EXPORT_SYMBOL(il_set_flags_for_band); /* @@ -3962,7 +3899,6 @@ il_connection_init_rx_config(struct il_priv *il, struct il_rxon_context *ctx) ctx->staging.ofdm_ht_single_stream_basic_rates = 0xff; ctx->staging.ofdm_ht_dual_stream_basic_rates = 0xff; } - EXPORT_SYMBOL(il_connection_init_rx_config); void @@ -3994,7 +3930,6 @@ il_set_rate(struct il_priv *il) il->ctx.staging.ofdm_basic_rates = (IL_OFDM_BASIC_RATES_MASK >> IL_FIRST_OFDM_RATE) & 0xFF; } - EXPORT_SYMBOL(il_set_rate); void @@ -4008,7 +3943,6 @@ il_chswitch_done(struct il_priv *il, bool is_success) if (test_and_clear_bit(S_CHANNEL_SWITCH_PENDING, &il->status)) ieee80211_chswitch_done(ctx->vif, is_success); } - EXPORT_SYMBOL(il_chswitch_done); void @@ -4034,7 +3968,6 @@ il_hdl_csa(struct il_priv *il, struct il_rx_buf *rxb) il_chswitch_done(il, false); } } - EXPORT_SYMBOL(il_hdl_csa); #ifdef CONFIG_IWLEGACY_DEBUG @@ -4055,7 +3988,6 @@ il_print_rx_config_cmd(struct il_priv *il, struct il_rxon_context *ctx) D_RADIO("u8[6] bssid_addr: %pM\n", rxon->bssid_addr); D_RADIO("u16 assoc_id: 0x%x\n", le16_to_cpu(rxon->assoc_id)); } - EXPORT_SYMBOL(il_print_rx_config_cmd); #endif /** @@ -4094,7 +4026,6 @@ il_irq_handle_error(struct il_priv *il) queue_work(il->workqueue, &il->restart); } } - EXPORT_SYMBOL(il_irq_handle_error); static int @@ -4135,7 +4066,6 @@ il_apm_stop(struct il_priv *il) */ il_clear_bit(il, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); } - EXPORT_SYMBOL(il_apm_stop); /* @@ -4249,7 +4179,6 @@ il_apm_init(struct il_priv *il) out: return ret; } - EXPORT_SYMBOL(il_apm_init); int @@ -4307,7 +4236,6 @@ il_set_tx_power(struct il_priv *il, s8 tx_power, bool force) } return ret; } - EXPORT_SYMBOL(il_set_tx_power); void @@ -4356,7 +4284,7 @@ il_hdl_pm_sleep(struct il_priv *il, struct il_rx_buf *rxb) struct il_rx_pkt *pkt = rxb_addr(rxb); struct il_sleep_notification *sleep = &(pkt->u.sleep_notif); D_RX("sleep mode: %d, src: %d\n", - sleep->pm_sleep_mode, sleep->pm_wakeup_src); + sleep->pm_sleep_mode, sleep->pm_wakeup_src); #endif } EXPORT_SYMBOL(il_hdl_pm_sleep); @@ -4432,7 +4360,6 @@ il_mac_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue, D_MAC80211("leave\n"); return 0; } - EXPORT_SYMBOL(il_mac_conf_tx); int @@ -4442,7 +4369,6 @@ il_mac_tx_last_beacon(struct ieee80211_hw *hw) return il->ibss_manager == IL_IBSS_MANAGER; } - EXPORT_SYMBOL_GPL(il_mac_tx_last_beacon); static int @@ -4529,7 +4455,6 @@ out: D_MAC80211("leave\n"); return err; } - EXPORT_SYMBOL(il_mac_add_interface); static void @@ -4573,7 +4498,6 @@ il_mac_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) D_MAC80211("leave\n"); } - EXPORT_SYMBOL(il_mac_remove_interface); int @@ -4589,7 +4513,6 @@ il_alloc_txq_mem(struct il_priv *il) } return 0; } - EXPORT_SYMBOL(il_alloc_txq_mem); void @@ -4598,7 +4521,6 @@ il_txq_mem(struct il_priv *il) kfree(il->txq); il->txq = NULL; } - EXPORT_SYMBOL(il_txq_mem); #ifdef CONFIG_IWLEGACY_DEBUGFS @@ -4638,7 +4560,6 @@ il_alloc_traffic_mem(struct il_priv *il) il_reset_traffic_log(il); return 0; } - EXPORT_SYMBOL(il_alloc_traffic_mem); void @@ -4650,7 +4571,6 @@ il_free_traffic_mem(struct il_priv *il) kfree(il->rx_traffic); il->rx_traffic = NULL; } - EXPORT_SYMBOL(il_free_traffic_mem); void @@ -4678,7 +4598,6 @@ il_dbg_log_tx_data_frame(struct il_priv *il, u16 length, (il->tx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; } } - EXPORT_SYMBOL(il_dbg_log_tx_data_frame); void @@ -4706,7 +4625,6 @@ il_dbg_log_rx_data_frame(struct il_priv *il, u16 length, (il->rx_traffic_idx + 1) % IL_TRAFFIC_ENTRIES; } } - EXPORT_SYMBOL(il_dbg_log_rx_data_frame); const char * @@ -4849,7 +4767,6 @@ il_update_stats(struct il_priv *il, bool is_tx, __le16 fc, u16 len) stats->data_bytes += len; } } - EXPORT_SYMBOL(il_update_stats); #endif @@ -4958,7 +4875,6 @@ out: mutex_unlock(&il->mutex); return err; } - EXPORT_SYMBOL(il_mac_change_interface); /* @@ -5034,7 +4950,6 @@ il_bg_watchdog(unsigned long data) mod_timer(&il->watchdog, jiffies + msecs_to_jiffies(IL_WD_TICK(timeout))); } - EXPORT_SYMBOL(il_bg_watchdog); void @@ -5048,7 +4963,6 @@ il_setup_watchdog(struct il_priv *il) else del_timer(&il->watchdog); } - EXPORT_SYMBOL(il_setup_watchdog); /* @@ -5080,14 +4994,13 @@ il_usecs_to_beacons(struct il_priv *il, u32 usec, u32 beacon_interval) return (quot << il->hw_params.beacon_time_tsf_bits) + rem; } - EXPORT_SYMBOL(il_usecs_to_beacons); /* base is usually what we get from ucode with each received frame, * the same as HW timer counter counting down */ __le32 -il_add_beacon_time(struct il_priv * il, u32 base, u32 addon, +il_add_beacon_time(struct il_priv *il, u32 base, u32 addon, u32 beacon_interval) { u32 base_low = base & il_beacon_time_mask_low(il, @@ -5114,7 +5027,6 @@ il_add_beacon_time(struct il_priv * il, u32 base, u32 addon, return cpu_to_le32(res); } - EXPORT_SYMBOL(il_add_beacon_time); #ifdef CONFIG_PM @@ -5136,7 +5048,6 @@ il_pci_suspend(struct device *device) return 0; } - EXPORT_SYMBOL(il_pci_suspend); int @@ -5166,7 +5077,6 @@ il_pci_resume(struct device *device) return 0; } - EXPORT_SYMBOL(il_pci_resume); const struct dev_pm_ops il_pm_ops = { @@ -5177,7 +5087,6 @@ const struct dev_pm_ops il_pm_ops = { .poweroff = il_pci_suspend, .restore = il_pci_resume, }; - EXPORT_SYMBOL(il_pm_ops); #endif /* CONFIG_PM */ @@ -5413,7 +5322,6 @@ il_mac_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif) D_MAC80211("leave\n"); } - EXPORT_SYMBOL(il_mac_reset_tsf); static void @@ -5701,7 +5609,6 @@ il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, D_MAC80211("leave\n"); } - EXPORT_SYMBOL(il_mac_bss_info_changed); irqreturn_t @@ -5763,7 +5670,6 @@ none: spin_unlock_irqrestore(&il->lock, flags); return IRQ_NONE; } - EXPORT_SYMBOL(il_isr); /* @@ -5772,7 +5678,7 @@ EXPORT_SYMBOL(il_isr); */ void il_tx_cmd_protection(struct il_priv *il, struct ieee80211_tx_info *info, - __le16 fc, __le32 * tx_flags) + __le16 fc, __le32 *tx_flags) { if (info->control.rates[0].flags & IEEE80211_TX_RC_USE_RTS_CTS) { *tx_flags |= TX_CMD_FLG_RTS_MSK; @@ -5798,5 +5704,4 @@ il_tx_cmd_protection(struct il_priv *il, struct ieee80211_tx_info *info, *tx_flags |= TX_CMD_FLG_FULL_TXOP_PROT_MSK; } } - EXPORT_SYMBOL(il_tx_cmd_protection); diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index 38ff3d66c745..d0975ab8b908 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -112,8 +112,8 @@ struct il_cmd_meta { * invoked for SYNC commands, if it were and its result passed * through it would be simpler...) */ - void (*callback) (struct il_priv * il, struct il_device_cmd * cmd, - struct il_rx_pkt * pkt); + void (*callback) (struct il_priv *il, struct il_device_cmd *cmd, + struct il_rx_pkt *pkt); /* The CMD_SIZE_HUGE flag bit indicates that the command * structure is stored at the end of the shared queue memory. */ @@ -432,8 +432,8 @@ struct il_eeprom_calib_info { struct il_eeprom_ops { const u32 regulatory_bands[7]; - int (*acquire_semaphore) (struct il_priv * il); - void (*release_semaphore) (struct il_priv * il); + int (*acquire_semaphore) (struct il_priv *il); + void (*release_semaphore) (struct il_priv *il); }; int il_eeprom_init(struct il_priv *il); @@ -592,8 +592,8 @@ struct il_device_cmd { struct il_host_cmd { const void *data; unsigned long reply_page; - void (*callback) (struct il_priv * il, struct il_device_cmd * cmd, - struct il_rx_pkt * pkt); + void (*callback) (struct il_priv *il, struct il_device_cmd *cmd, + struct il_rx_pkt *pkt); u32 flags; u16 len; u8 id; @@ -1224,8 +1224,8 @@ struct il_priv { enum ieee80211_band band; int alloc_rxb_page; - void (*handlers[IL_CN_MAX]) (struct il_priv * il, - struct il_rx_buf * rxb); + void (*handlers[IL_CN_MAX]) (struct il_priv *il, + struct il_rx_buf *rxb); struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; @@ -1613,69 +1613,69 @@ il_free_pages(struct il_priv *il, unsigned long page) #define IL_RX_BUF_SIZE_8K (8 * 1024) struct il_hcmd_ops { - int (*rxon_assoc) (struct il_priv * il, struct il_rxon_context * ctx); - int (*commit_rxon) (struct il_priv * il, struct il_rxon_context * ctx); - void (*set_rxon_chain) (struct il_priv * il, - struct il_rxon_context * ctx); + int (*rxon_assoc) (struct il_priv *il, struct il_rxon_context *ctx); + int (*commit_rxon) (struct il_priv *il, struct il_rxon_context *ctx); + void (*set_rxon_chain) (struct il_priv *il, + struct il_rxon_context *ctx); }; struct il_hcmd_utils_ops { u16(*get_hcmd_size) (u8 cmd_id, u16 len); - u16(*build_addsta_hcmd) (const struct il_addsta_cmd * cmd, u8 * data); - int (*request_scan) (struct il_priv * il, struct ieee80211_vif * vif); - void (*post_scan) (struct il_priv * il); + u16(*build_addsta_hcmd) (const struct il_addsta_cmd *cmd, u8 *data); + int (*request_scan) (struct il_priv *il, struct ieee80211_vif *vif); + void (*post_scan) (struct il_priv *il); }; struct il_apm_ops { - int (*init) (struct il_priv * il); - void (*config) (struct il_priv * il); + int (*init) (struct il_priv *il); + void (*config) (struct il_priv *il); }; struct il_debugfs_ops { - ssize_t(*rx_stats_read) (struct file * file, char __user * user_buf, - size_t count, loff_t * ppos); - ssize_t(*tx_stats_read) (struct file * file, char __user * user_buf, - size_t count, loff_t * ppos); - ssize_t(*general_stats_read) (struct file * file, - char __user * user_buf, size_t count, - loff_t * ppos); + ssize_t(*rx_stats_read) (struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); + ssize_t(*tx_stats_read) (struct file *file, char __user *user_buf, + size_t count, loff_t *ppos); + ssize_t(*general_stats_read) (struct file *file, + char __user *user_buf, size_t count, + loff_t *ppos); }; struct il_temp_ops { - void (*temperature) (struct il_priv * il); + void (*temperature) (struct il_priv *il); }; struct il_lib_ops { /* set hw dependent parameters */ - int (*set_hw_params) (struct il_priv * il); + int (*set_hw_params) (struct il_priv *il); /* Handling TX */ - void (*txq_update_byte_cnt_tbl) (struct il_priv * il, - struct il_tx_queue * txq, + void (*txq_update_byte_cnt_tbl) (struct il_priv *il, + struct il_tx_queue *txq, u16 byte_cnt); - int (*txq_attach_buf_to_tfd) (struct il_priv * il, - struct il_tx_queue * txq, dma_addr_t addr, + int (*txq_attach_buf_to_tfd) (struct il_priv *il, + struct il_tx_queue *txq, dma_addr_t addr, u16 len, u8 reset, u8 pad); - void (*txq_free_tfd) (struct il_priv * il, struct il_tx_queue * txq); - int (*txq_init) (struct il_priv * il, struct il_tx_queue * txq); + void (*txq_free_tfd) (struct il_priv *il, struct il_tx_queue *txq); + int (*txq_init) (struct il_priv *il, struct il_tx_queue *txq); /* setup Rx handler */ - void (*handler_setup) (struct il_priv * il); + void (*handler_setup) (struct il_priv *il); /* alive notification after init uCode load */ - void (*init_alive_start) (struct il_priv * il); + void (*init_alive_start) (struct il_priv *il); /* check validity of rtc data address */ int (*is_valid_rtc_data_addr) (u32 addr); /* 1st ucode load */ - int (*load_ucode) (struct il_priv * il); + int (*load_ucode) (struct il_priv *il); - void (*dump_nic_error_log) (struct il_priv * il); - int (*dump_fh) (struct il_priv * il, char **buf, bool display); - int (*set_channel_switch) (struct il_priv * il, - struct ieee80211_channel_switch * ch_switch); + void (*dump_nic_error_log) (struct il_priv *il); + int (*dump_fh) (struct il_priv *il, char **buf, bool display); + int (*set_channel_switch) (struct il_priv *il, + struct ieee80211_channel_switch *ch_switch); /* power management */ struct il_apm_ops apm_ops; /* power */ - int (*send_tx_power) (struct il_priv * il); - void (*update_chain_flags) (struct il_priv * il); + int (*send_tx_power) (struct il_priv *il); + void (*update_chain_flags) (struct il_priv *il); /* eeprom operations */ struct il_eeprom_ops eeprom_ops; @@ -1688,16 +1688,16 @@ struct il_lib_ops { }; struct il_led_ops { - int (*cmd) (struct il_priv * il, struct il_led_cmd * led_cmd); + int (*cmd) (struct il_priv *il, struct il_led_cmd *led_cmd); }; struct il_legacy_ops { - void (*post_associate) (struct il_priv * il); - void (*config_ap) (struct il_priv * il); + void (*post_associate) (struct il_priv *il); + void (*config_ap) (struct il_priv *il); /* station management */ - int (*update_bcast_stations) (struct il_priv * il); - int (*manage_ibss_station) (struct il_priv * il, - struct ieee80211_vif * vif, bool add); + int (*update_bcast_stations) (struct il_priv *il); + int (*manage_ibss_station) (struct il_priv *il, + struct ieee80211_vif *vif, bool add); }; struct il_ops { @@ -1965,7 +1965,7 @@ int il_mac_hw_scan(struct ieee80211_hw *hw, struct ieee80211_vif *vif, void il_internal_short_hw_scan(struct il_priv *il); int il_force_reset(struct il_priv *il, bool external); u16 il_fill_probe_req(struct il_priv *il, struct ieee80211_mgmt *frame, - const u8 * ta, const u8 * ie, int ie_len, int left); + const u8 *ta, const u8 *ie, int ie_len, int left); void il_setup_rx_scan_handlers(struct il_priv *il); u16 il_get_active_dwell_time(struct il_priv *il, enum ieee80211_band band, u8 n_probes); @@ -1995,9 +1995,9 @@ int il_send_cmd(struct il_priv *il, struct il_host_cmd *cmd); int __must_check il_send_cmd_pdu(struct il_priv *il, u8 id, u16 len, const void *data); int il_send_cmd_pdu_async(struct il_priv *il, u8 id, u16 len, const void *data, - void (*callback) (struct il_priv * il, - struct il_device_cmd * cmd, - struct il_rx_pkt * pkt)); + void (*callback) (struct il_priv *il, + struct il_device_cmd *cmd, + struct il_rx_pkt *pkt)); int il_enqueue_hcmd(struct il_priv *il, struct il_host_cmd *cmd); @@ -2155,7 +2155,7 @@ void il_mac_reset_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif); void il_mac_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_bss_conf *bss_conf, u32 changes); void il_tx_cmd_protection(struct il_priv *il, struct ieee80211_tx_info *info, - __le16 fc, __le32 * tx_flags); + __le16 fc, __le32 *tx_flags); irqreturn_t il_isr(int irq, void *data); @@ -2191,8 +2191,7 @@ _il_poll_bit(struct il_priv *il, u32 addr, u32 bits, u32 mask, int timeout) return t; udelay(IL_POLL_INTERVAL); t += IL_POLL_INTERVAL; - } - while (t < timeout); + } while (t < timeout); return -ETIMEDOUT; } @@ -2324,8 +2323,7 @@ il_poll_bit(struct il_priv *il, u32 addr, u32 mask, int timeout) return t; udelay(IL_POLL_INTERVAL); t += IL_POLL_INTERVAL; - } - while (t < timeout); + } while (t < timeout); return -ETIMEDOUT; } @@ -2485,14 +2483,14 @@ void il_dealloc_bcast_stations(struct il_priv *il); int il_get_free_ucode_key_idx(struct il_priv *il); int il_send_add_sta(struct il_priv *il, struct il_addsta_cmd *sta, u8 flags); int il_add_station_common(struct il_priv *il, struct il_rxon_context *ctx, - const u8 * addr, bool is_ap, - struct ieee80211_sta *sta, u8 * sta_id_r); + const u8 *addr, bool is_ap, + struct ieee80211_sta *sta, u8 *sta_id_r); int il_remove_station(struct il_priv *il, const u8 sta_id, const u8 * addr); int il_mac_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta); u8 il_prep_station(struct il_priv *il, struct il_rxon_context *ctx, - const u8 * addr, bool is_ap, struct ieee80211_sta *sta); + const u8 *addr, bool is_ap, struct ieee80211_sta *sta); int il_send_lq_cmd(struct il_priv *il, struct il_rxon_context *ctx, struct il_link_quality_cmd *lq, u8 flags, bool init); @@ -2758,10 +2756,10 @@ il_get_dma_hi_addr(dma_addr_t addr) * * This structure contains dma address and length of transmission address * - * @lo: low [31:0] portion of the dma address of TX buffer - * every even is unaligned on 16 bit boundary - * @hi_n_len 0-3 [35:32] portion of dma - * 4-15 length of the tx buffer + * @lo: low [31:0] portion of the dma address of TX buffer every even is + * unaligned on 16 bit boundary + * @hi_n_len: 0-3 [35:32] portion of dma + * 4-15 length of the tx buffer */ struct il_tfd_tb { __le32 lo; @@ -2778,7 +2776,7 @@ struct il_tfd_tb { * 5 reserved * 6-7 padding (not used) * @ tbs[20] transmit frame buffer descriptors - * @ __pad padding + * @ __pad padding * * Each Tx queue uses a circular buffer of 256 TFDs stored in host DRAM. * Both driver and device share these circular buffers, each of which must be @@ -3295,7 +3293,7 @@ do { \ __func__ , ## args); \ } while (0) -#define il_print_hex_dump(il, level, p, len) \ +#define il_print_hex_dump(il, level, p, len) \ do { \ if (il_get_debug_level(il) & level) \ print_hex_dump(KERN_DEBUG, "iwl data: ", \ @@ -3342,9 +3340,9 @@ il_dbgfs_unregister(struct il_priv *il) * * The active debug levels can be accessed via files * - * /sys/module/iwl4965/parameters/debug + * /sys/module/iwl4965/parameters/debug * /sys/module/iwl3945/parameters/debug - * /sys/class/net/wlan0/device/debug_level + * /sys/class/net/wlan0/device/debug_level * * when CONFIG_IWLEGACY_DEBUG=y. */ diff --git a/drivers/net/wireless/iwlegacy/debug.c b/drivers/net/wireless/iwlegacy/debug.c index e79794a7e326..928bdbb00085 100644 --- a/drivers/net/wireless/iwlegacy/debug.c +++ b/drivers/net/wireless/iwlegacy/debug.c @@ -71,35 +71,35 @@ il_dbgfs_open_file_generic(struct inode *inode, struct file *file) return 0; } -#define DEBUGFS_READ_FILE_OPS(name) \ - DEBUGFS_READ_FUNC(name); \ +#define DEBUGFS_READ_FILE_OPS(name) \ + DEBUGFS_READ_FUNC(name); \ static const struct file_operations il_dbgfs_##name##_ops = { \ .read = il_dbgfs_##name##_read, \ - .open = il_dbgfs_open_file_generic, \ - .llseek = generic_file_llseek, \ + .open = il_dbgfs_open_file_generic, \ + .llseek = generic_file_llseek, \ }; -#define DEBUGFS_WRITE_FILE_OPS(name) \ - DEBUGFS_WRITE_FUNC(name); \ +#define DEBUGFS_WRITE_FILE_OPS(name) \ + DEBUGFS_WRITE_FUNC(name); \ static const struct file_operations il_dbgfs_##name##_ops = { \ .write = il_dbgfs_##name##_write, \ - .open = il_dbgfs_open_file_generic, \ - .llseek = generic_file_llseek, \ + .open = il_dbgfs_open_file_generic, \ + .llseek = generic_file_llseek, \ }; -#define DEBUGFS_READ_WRITE_FILE_OPS(name) \ - DEBUGFS_READ_FUNC(name); \ - DEBUGFS_WRITE_FUNC(name); \ +#define DEBUGFS_READ_WRITE_FILE_OPS(name) \ + DEBUGFS_READ_FUNC(name); \ + DEBUGFS_WRITE_FUNC(name); \ static const struct file_operations il_dbgfs_##name##_ops = { \ .write = il_dbgfs_##name##_write, \ .read = il_dbgfs_##name##_read, \ .open = il_dbgfs_open_file_generic, \ - .llseek = generic_file_llseek, \ + .llseek = generic_file_llseek, \ }; static ssize_t -il_dbgfs_tx_stats_read(struct file *file, char __user * user_buf, size_t count, - loff_t * ppos) +il_dbgfs_tx_stats_read(struct file *file, char __user *user_buf, size_t count, + loff_t *ppos) { struct il_priv *il = file->private_data; @@ -139,8 +139,8 @@ il_dbgfs_tx_stats_read(struct file *file, char __user * user_buf, size_t count, static ssize_t il_dbgfs_clear_traffic_stats_write(struct file *file, - const char __user * user_buf, size_t count, - loff_t * ppos) + const char __user *user_buf, size_t count, + loff_t *ppos) { struct il_priv *il = file->private_data; u32 clear_flag; @@ -159,8 +159,8 @@ il_dbgfs_clear_traffic_stats_write(struct file *file, } static ssize_t -il_dbgfs_rx_stats_read(struct file *file, char __user * user_buf, size_t count, - loff_t * ppos) +il_dbgfs_rx_stats_read(struct file *file, char __user *user_buf, size_t count, + loff_t *ppos) { struct il_priv *il = file->private_data; @@ -203,8 +203,8 @@ il_dbgfs_rx_stats_read(struct file *file, char __user * user_buf, size_t count, #define BYTE2_MASK 0x0000ffff; #define BYTE3_MASK 0x00ffffff; static ssize_t -il_dbgfs_sram_read(struct file *file, char __user * user_buf, size_t count, - loff_t * ppos) +il_dbgfs_sram_read(struct file *file, char __user *user_buf, size_t count, + loff_t *ppos) { u32 val; char *buf; @@ -262,8 +262,8 @@ il_dbgfs_sram_read(struct file *file, char __user * user_buf, size_t count, } static ssize_t -il_dbgfs_sram_write(struct file *file, const char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_sram_write(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; char buf[64]; @@ -287,8 +287,8 @@ il_dbgfs_sram_write(struct file *file, const char __user * user_buf, } static ssize_t -il_dbgfs_stations_read(struct file *file, char __user * user_buf, size_t count, - loff_t * ppos) +il_dbgfs_stations_read(struct file *file, char __user *user_buf, size_t count, + loff_t *ppos) { struct il_priv *il = file->private_data; struct il_station_entry *station; @@ -351,8 +351,8 @@ il_dbgfs_stations_read(struct file *file, char __user * user_buf, size_t count, } static ssize_t -il_dbgfs_nvm_read(struct file *file, char __user * user_buf, size_t count, - loff_t * ppos) +il_dbgfs_nvm_read(struct file *file, char __user *user_buf, size_t count, + loff_t *ppos) { ssize_t ret; struct il_priv *il = file->private_data; @@ -399,8 +399,8 @@ il_dbgfs_nvm_read(struct file *file, char __user * user_buf, size_t count, } static ssize_t -il_dbgfs_channels_read(struct file *file, char __user * user_buf, size_t count, - loff_t * ppos) +il_dbgfs_channels_read(struct file *file, char __user *user_buf, size_t count, + loff_t *ppos) { struct il_priv *il = file->private_data; struct ieee80211_channel *channels = NULL; @@ -478,8 +478,8 @@ il_dbgfs_channels_read(struct file *file, char __user * user_buf, size_t count, } static ssize_t -il_dbgfs_status_read(struct file *file, char __user * user_buf, size_t count, - loff_t * ppos) +il_dbgfs_status_read(struct file *file, char __user *user_buf, size_t count, + loff_t *ppos) { struct il_priv *il = file->private_data; @@ -539,8 +539,8 @@ il_dbgfs_status_read(struct file *file, char __user * user_buf, size_t count, } static ssize_t -il_dbgfs_interrupt_read(struct file *file, char __user * user_buf, size_t count, - loff_t * ppos) +il_dbgfs_interrupt_read(struct file *file, char __user *user_buf, size_t count, + loff_t *ppos) { struct il_priv *il = file->private_data; @@ -618,8 +618,8 @@ il_dbgfs_interrupt_read(struct file *file, char __user * user_buf, size_t count, } static ssize_t -il_dbgfs_interrupt_write(struct file *file, const char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_interrupt_write(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; char buf[8]; @@ -639,8 +639,8 @@ il_dbgfs_interrupt_write(struct file *file, const char __user * user_buf, } static ssize_t -il_dbgfs_qos_read(struct file *file, char __user * user_buf, size_t count, - loff_t * ppos) +il_dbgfs_qos_read(struct file *file, char __user *user_buf, size_t count, + loff_t *ppos) { struct il_priv *il = file->private_data; struct il_rxon_context *ctx = &il->ctx; @@ -666,8 +666,8 @@ il_dbgfs_qos_read(struct file *file, char __user * user_buf, size_t count, } static ssize_t -il_dbgfs_disable_ht40_write(struct file *file, const char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_disable_ht40_write(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; char buf[8]; @@ -692,8 +692,8 @@ il_dbgfs_disable_ht40_write(struct file *file, const char __user * user_buf, } static ssize_t -il_dbgfs_disable_ht40_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_disable_ht40_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; char buf[100]; @@ -716,8 +716,8 @@ DEBUGFS_READ_FILE_OPS(qos); DEBUGFS_READ_WRITE_FILE_OPS(disable_ht40); static ssize_t -il_dbgfs_traffic_log_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_traffic_log_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; int pos = 0, ofs = 0; @@ -801,8 +801,8 @@ il_dbgfs_traffic_log_read(struct file *file, char __user * user_buf, } static ssize_t -il_dbgfs_traffic_log_write(struct file *file, const char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_traffic_log_write(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; char buf[8]; @@ -822,8 +822,8 @@ il_dbgfs_traffic_log_write(struct file *file, const char __user * user_buf, } static ssize_t -il_dbgfs_tx_queue_read(struct file *file, char __user * user_buf, size_t count, - loff_t * ppos) +il_dbgfs_tx_queue_read(struct file *file, char __user *user_buf, size_t count, + loff_t *ppos) { struct il_priv *il = file->private_data; @@ -851,9 +851,8 @@ il_dbgfs_tx_queue_read(struct file *file, char __user * user_buf, size_t count, scnprintf(buf + pos, bufsz - pos, "hwq %.2d: read=%u write=%u stop=%d" " swq_id=%#.2x (ac %d/hwq %d)\n", cnt, - q->read_ptr, q->write_ptr, !!test_bit(cnt, - il-> - queue_stopped), + q->read_ptr, q->write_ptr, + !!test_bit(cnt, il->queue_stopped), txq->swq_id, txq->swq_id & 3, (txq->swq_id >> 2) & 0x1f); if (cnt >= 4) @@ -870,8 +869,8 @@ il_dbgfs_tx_queue_read(struct file *file, char __user * user_buf, size_t count, } static ssize_t -il_dbgfs_rx_queue_read(struct file *file, char __user * user_buf, size_t count, - loff_t * ppos) +il_dbgfs_rx_queue_read(struct file *file, char __user *user_buf, size_t count, + loff_t *ppos) { struct il_priv *il = file->private_data; @@ -899,8 +898,8 @@ il_dbgfs_rx_queue_read(struct file *file, char __user * user_buf, size_t count, } static ssize_t -il_dbgfs_ucode_rx_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_ucode_rx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; return il->cfg->ops->lib->debugfs_ops.rx_stats_read(file, user_buf, @@ -908,8 +907,8 @@ il_dbgfs_ucode_rx_stats_read(struct file *file, char __user * user_buf, } static ssize_t -il_dbgfs_ucode_tx_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_ucode_tx_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; return il->cfg->ops->lib->debugfs_ops.tx_stats_read(file, user_buf, @@ -917,8 +916,8 @@ il_dbgfs_ucode_tx_stats_read(struct file *file, char __user * user_buf, } static ssize_t -il_dbgfs_ucode_general_stats_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_ucode_general_stats_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; return il->cfg->ops->lib->debugfs_ops.general_stats_read(file, user_buf, @@ -926,8 +925,8 @@ il_dbgfs_ucode_general_stats_read(struct file *file, char __user * user_buf, } static ssize_t -il_dbgfs_sensitivity_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_sensitivity_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; @@ -1025,8 +1024,8 @@ il_dbgfs_sensitivity_read(struct file *file, char __user * user_buf, } static ssize_t -il_dbgfs_chain_noise_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_chain_noise_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; @@ -1096,8 +1095,8 @@ il_dbgfs_chain_noise_read(struct file *file, char __user * user_buf, } static ssize_t -il_dbgfs_power_save_status_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_power_save_status_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; char buf[60]; @@ -1111,19 +1110,18 @@ il_dbgfs_power_save_status_read(struct file *file, char __user * user_buf, pos += scnprintf(buf + pos, bufsz - pos, "Power Save Status: "); pos += scnprintf(buf + pos, bufsz - pos, "%s\n", - (pwrsave_status == - CSR_GP_REG_NO_POWER_SAVE) ? "none" : (pwrsave_status == - CSR_GP_REG_MAC_POWER_SAVE) - ? "MAC" : (pwrsave_status == - CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" : "error"); + (pwrsave_status == CSR_GP_REG_NO_POWER_SAVE) ? "none" : + (pwrsave_status == CSR_GP_REG_MAC_POWER_SAVE) ? "MAC" : + (pwrsave_status == CSR_GP_REG_PHY_POWER_SAVE) ? "PHY" : + "error"); return simple_read_from_buffer(user_buf, count, ppos, buf, pos); } static ssize_t il_dbgfs_clear_ucode_stats_write(struct file *file, - const char __user * user_buf, size_t count, - loff_t * ppos) + const char __user *user_buf, size_t count, + loff_t *ppos) { struct il_priv *il = file->private_data; char buf[8]; @@ -1146,8 +1144,8 @@ il_dbgfs_clear_ucode_stats_write(struct file *file, } static ssize_t -il_dbgfs_rxon_flags_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_rxon_flags_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; @@ -1159,8 +1157,8 @@ il_dbgfs_rxon_flags_read(struct file *file, char __user * user_buf, } static ssize_t -il_dbgfs_rxon_filter_flags_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_rxon_filter_flags_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; @@ -1173,8 +1171,8 @@ il_dbgfs_rxon_filter_flags_read(struct file *file, char __user * user_buf, } static ssize_t -il_dbgfs_fh_reg_read(struct file *file, char __user * user_buf, size_t count, - loff_t * ppos) +il_dbgfs_fh_reg_read(struct file *file, char __user *user_buf, size_t count, + loff_t *ppos) { struct il_priv *il = file->private_data; char *buf; @@ -1195,8 +1193,8 @@ il_dbgfs_fh_reg_read(struct file *file, char __user * user_buf, size_t count, } static ssize_t -il_dbgfs_missed_beacon_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_missed_beacon_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; @@ -1212,8 +1210,8 @@ il_dbgfs_missed_beacon_read(struct file *file, char __user * user_buf, } static ssize_t -il_dbgfs_missed_beacon_write(struct file *file, const char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_missed_beacon_write(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; char buf[8]; @@ -1237,8 +1235,8 @@ il_dbgfs_missed_beacon_write(struct file *file, const char __user * user_buf, } static ssize_t -il_dbgfs_force_reset_read(struct file *file, char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_force_reset_read(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; @@ -1268,8 +1266,8 @@ il_dbgfs_force_reset_read(struct file *file, char __user * user_buf, } static ssize_t -il_dbgfs_force_reset_write(struct file *file, const char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_force_reset_write(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) { int ret; @@ -1281,8 +1279,8 @@ il_dbgfs_force_reset_write(struct file *file, const char __user * user_buf, } static ssize_t -il_dbgfs_wd_timeout_write(struct file *file, const char __user * user_buf, - size_t count, loff_t * ppos) +il_dbgfs_wd_timeout_write(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) { struct il_priv *il = file->private_data; @@ -1394,7 +1392,6 @@ err: il_dbgfs_unregister(il); return -ENOMEM; } - EXPORT_SYMBOL(il_dbgfs_register); /** @@ -1410,5 +1407,4 @@ il_dbgfs_unregister(struct il_priv *il) debugfs_remove_recursive(il->debugfs_dir); il->debugfs_dir = NULL; } - EXPORT_SYMBOL(il_dbgfs_unregister); -- cgit v1.2.3 From 53611e05263ca2101a29736920fdf86ccad0e93b Mon Sep 17 00:00:00 2001 From: Greg Dietsche Date: Sun, 28 Aug 2011 08:26:16 -0500 Subject: iwlegacy: change IL_WARN to D_HT in il4965_tx_agg_start This message should be a debug message and not a warning. Signed-off-by: Greg Dietsche Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/4965-mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 21a1381c9748..8d2f6162d6e8 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -2252,7 +2252,7 @@ il4965_tx_agg_start(struct il_priv *il, struct ieee80211_vif *vif, if (unlikely(tx_fifo < 0)) return tx_fifo; - IL_WARN("%s on ra = %pM tid = %d\n", __func__, sta->addr, tid); + D_HT("%s on ra = %pM tid = %d\n", __func__, sta->addr, tid); sta_id = il_sta_id(sta); if (sta_id == IL_INVALID_STATION) { -- cgit v1.2.3 From dd44eb9e13131f7b1fda65518b24fd3dfcf3a114 Mon Sep 17 00:00:00 2001 From: Greg Dietsche Date: Sun, 28 Aug 2011 08:32:10 -0500 Subject: iwlegacy: change IL_ERR to D_HT in iwl4965_rs_tl_turn_on_agg_for_tid This message should be a debug message and not an error. Signed-off-by: Greg Dietsche Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/4965-rs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/4965-rs.c b/drivers/net/wireless/iwlegacy/4965-rs.c index 4bc5a1845821..93c3a4d9b9b5 100644 --- a/drivers/net/wireless/iwlegacy/4965-rs.c +++ b/drivers/net/wireless/iwlegacy/4965-rs.c @@ -371,10 +371,10 @@ il4965_rs_tl_turn_on_agg_for_tid(struct il_priv *il, struct il_lq_sta *lq_data, IL_ERR("Fail start Tx agg on tid: %d\n", tid); ieee80211_stop_tx_ba_session(sta, tid); } - } else { - IL_ERR("Aggregation not enabled for tid %d " - "because load = %u\n", tid, load); - } + } else + D_HT("Aggregation not enabled for tid %d because load = %u\n", + tid, load); + return ret; } -- cgit v1.2.3 From c63b2d01b1bec83f31259651a0ed2a26104cb7a3 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Tue, 15 Nov 2011 15:20:03 +0100 Subject: iwlegacy: remove unused IL_AC_UNSET define Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/4965.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index 6f5e6a15a2cb..ac80a0069124 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -40,8 +40,6 @@ #include "common.h" #include "4965.h" -#define IL_AC_UNSET -1 - /** * il_verify_inst_sparse - verify runtime uCode image in card vs. host, * using sample data 100 bytes apart. If these sample points are good, -- cgit v1.2.3 From c18b7806e4f3373b2f296a65fb19251a3b49a532 Mon Sep 17 00:00:00 2001 From: Gertjan van Wingerde Date: Sat, 12 Nov 2011 19:10:43 +0100 Subject: rt2x00: Add USB device ID of Buffalo WLI-UC-GNHP. This is reported to be an RT3070 based device. Reported-by: Teika Kazura Signed-off-by: Gertjan van Wingerde Acked-by: Ivo van Doorn Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800usb.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c index f1565792f270..377876315b8d 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/rt2x00/rt2800usb.c @@ -919,6 +919,7 @@ static struct usb_device_id rt2800usb_device_table[] = { { USB_DEVICE(0x050d, 0x935b) }, /* Buffalo */ { USB_DEVICE(0x0411, 0x00e8) }, + { USB_DEVICE(0x0411, 0x0158) }, { USB_DEVICE(0x0411, 0x016f) }, { USB_DEVICE(0x0411, 0x01a2) }, /* Corega */ -- cgit v1.2.3 From ed66ba472a742cd8df37d7072804b2111cdb1014 Mon Sep 17 00:00:00 2001 From: Gertjan van Wingerde Date: Sat, 12 Nov 2011 19:10:44 +0100 Subject: rt2x00: Fix sleep-while-atomic bug in powersaving code. The generic powersaving code that determines after reception of a frame whether the device should go back to sleep or whether is could stay awake was calling rt2x00lib_config directly from RX tasklet context. On a number of the devices this call can actually sleep, due to having to confirm that the sleeping commands have been executed successfully. Fix this by moving the call to rt2x00lib_config to a workqueue call. This fixes bug https://bugzilla.redhat.com/show_bug.cgi?id=731672 Tested-by: Tomas Trnka Signed-off-by: Gertjan van Wingerde Cc: Acked-by: Ivo van Doorn Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2x00.h | 1 + drivers/net/wireless/rt2x00/rt2x00dev.c | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h index 2ec5c00235e6..99ff12d0c29d 100644 --- a/drivers/net/wireless/rt2x00/rt2x00.h +++ b/drivers/net/wireless/rt2x00/rt2x00.h @@ -943,6 +943,7 @@ struct rt2x00_dev { * Powersaving work */ struct delayed_work autowakeup_work; + struct work_struct sleep_work; /* * Data queue arrays for RX, TX, Beacon and ATIM. diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c index e1fb2a8569be..edd317fa7c0a 100644 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c @@ -465,6 +465,23 @@ static u8 *rt2x00lib_find_ie(u8 *data, unsigned int len, u8 ie) return NULL; } +static void rt2x00lib_sleep(struct work_struct *work) +{ + struct rt2x00_dev *rt2x00dev = + container_of(work, struct rt2x00_dev, sleep_work); + + if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags)) + return; + + /* + * Check again is powersaving is enabled, to prevent races from delayed + * work execution. + */ + if (!test_bit(CONFIG_POWERSAVING, &rt2x00dev->flags)) + rt2x00lib_config(rt2x00dev, &rt2x00dev->hw->conf, + IEEE80211_CONF_CHANGE_PS); +} + static void rt2x00lib_rxdone_check_ps(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb, struct rxdone_entry_desc *rxdesc) @@ -512,8 +529,7 @@ static void rt2x00lib_rxdone_check_ps(struct rt2x00_dev *rt2x00dev, cam |= (tim_ie->bitmap_ctrl & 0x01); if (!cam && !test_bit(CONFIG_POWERSAVING, &rt2x00dev->flags)) - rt2x00lib_config(rt2x00dev, &rt2x00dev->hw->conf, - IEEE80211_CONF_CHANGE_PS); + queue_work(rt2x00dev->workqueue, &rt2x00dev->sleep_work); } static int rt2x00lib_rxdone_read_signal(struct rt2x00_dev *rt2x00dev, @@ -1141,6 +1157,7 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev) INIT_WORK(&rt2x00dev->intf_work, rt2x00lib_intf_scheduled); INIT_DELAYED_WORK(&rt2x00dev->autowakeup_work, rt2x00lib_autowakeup); + INIT_WORK(&rt2x00dev->sleep_work, rt2x00lib_sleep); /* * Let the driver probe the device to detect the capabilities. @@ -1197,6 +1214,7 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev) */ cancel_work_sync(&rt2x00dev->intf_work); cancel_delayed_work_sync(&rt2x00dev->autowakeup_work); + cancel_work_sync(&rt2x00dev->sleep_work); if (rt2x00_is_usb(rt2x00dev)) { del_timer_sync(&rt2x00dev->txstatus_timer); cancel_work_sync(&rt2x00dev->rxdone_work); -- cgit v1.2.3 From fe09b32a4361bea44169b2063e8c867cabb6a8ba Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Sun, 13 Nov 2011 22:14:32 +0100 Subject: Net, libertas: Resolve memory leak in if_spi_host_to_card() If we hit the default case in the switch in if_spi_host_to_card() we'll leak the memory we allocated for 'packet'. This patch resolves the leak by freeing the allocated memory in that case. Signed-off-by: Jesper Juhl Acked-by: Dan Williams Cc: stable@vger.kernel.org Signed-off-by: John W. Linville --- drivers/net/wireless/libertas/if_spi.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/libertas/if_spi.c b/drivers/net/wireless/libertas/if_spi.c index 622ae6de0d8b..7059d9645dab 100644 --- a/drivers/net/wireless/libertas/if_spi.c +++ b/drivers/net/wireless/libertas/if_spi.c @@ -995,6 +995,7 @@ static int if_spi_host_to_card(struct lbs_private *priv, spin_unlock_irqrestore(&card->buffer_lock, flags); break; default: + kfree(packet); netdev_err(priv->dev, "can't transfer buffer of type %d\n", type); err = -EINVAL; -- cgit v1.2.3 From 730b4c2102902a0061bb01a3d3fa1b6461973849 Mon Sep 17 00:00:00 2001 From: Greg Dietsche Date: Tue, 6 Sep 2011 17:33:51 -0500 Subject: iwlegacy: 4965: remove vif null check in request_scan remove null check on vif in il4965_request_scan Signed-off-by: Greg Dietsche Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/4965-mac.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c index 8d2f6162d6e8..4aaef4135564 100644 --- a/drivers/net/wireless/iwlegacy/4965-mac.c +++ b/drivers/net/wireless/iwlegacy/4965-mac.c @@ -850,8 +850,7 @@ il4965_request_scan(struct il_priv *il, struct ieee80211_vif *vif) lockdep_assert_held(&il->mutex); - if (vif) - ctx = il_rxon_ctx_from_vif(vif); + ctx = il_rxon_ctx_from_vif(vif); if (!il->scan_cmd) { il->scan_cmd = -- cgit v1.2.3 From da6134d2537363775c73e96186c0d5eb9b2c6b1c Mon Sep 17 00:00:00 2001 From: Greg Dietsche Date: Tue, 6 Sep 2011 17:38:34 -0500 Subject: iwlegacy: 4965-rs: remove null check on sta in il4965_rs_tx_status the null check on sta in il4965_rs_tx_status is not necessary Signed-off-by: Greg Dietsche Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/4965-rs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/4965-rs.c b/drivers/net/wireless/iwlegacy/4965-rs.c index 93c3a4d9b9b5..b0946a1ee37d 100644 --- a/drivers/net/wireless/iwlegacy/4965-rs.c +++ b/drivers/net/wireless/iwlegacy/4965-rs.c @@ -991,7 +991,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband, lq_sta->last_rate_n_flags = tx_rate; done: /* See if there's a better rate or modulation mode to try. */ - if (sta && sta->supp_rates[sband->band]) + if (sta->supp_rates[sband->band]) il4965_rs_rate_scale_perform(il, skb, sta, lq_sta); } -- cgit v1.2.3 From 144c0961b47ab07812ec1440adea6d4218b9a6a6 Mon Sep 17 00:00:00 2001 From: Greg Dietsche Date: Tue, 6 Sep 2011 18:31:13 -0500 Subject: iwlegacy: 4965-rs: remove unnecessary null check for sta and lq_sta both sta and lq_sta are guaranteed to be not null in the calling function so we don't need to check them here. Signed-off-by: Greg Dietsche Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/4965-rs.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/4965-rs.c b/drivers/net/wireless/iwlegacy/4965-rs.c index b0946a1ee37d..2ec808e40c96 100644 --- a/drivers/net/wireless/iwlegacy/4965-rs.c +++ b/drivers/net/wireless/iwlegacy/4965-rs.c @@ -1793,9 +1793,6 @@ il4965_rs_rate_scale_perform(struct il_priv *il, struct sk_buff *skb, (info->flags & IEEE80211_TX_CTL_NO_ACK)) return; - if (!sta || !lq_sta) - return; - lq_sta->supp_rates = sta->supp_rates[lq_sta->band]; tid = il4965_rs_tl_add_packet(lq_sta, hdr); -- cgit v1.2.3 From 3e4b0655207452be0a1d82425f19ed4a081cf48b Mon Sep 17 00:00:00 2001 From: Greg Dietsche Date: Tue, 6 Sep 2011 18:12:05 -0500 Subject: iwlegacy: 4965-rs: il4965_rs_alloc_sta: remove lq_sta local var remove the lq_sta local variable and return the result directly in il4965_rs_alloc_sta Signed-off-by: Greg Dietsche Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/4965-rs.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/4965-rs.c b/drivers/net/wireless/iwlegacy/4965-rs.c index 2ec808e40c96..52006376febd 100644 --- a/drivers/net/wireless/iwlegacy/4965-rs.c +++ b/drivers/net/wireless/iwlegacy/4965-rs.c @@ -2295,7 +2295,6 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta, static void * il4965_rs_alloc_sta(void *il_rate, struct ieee80211_sta *sta, gfp_t gfp) { - struct il_lq_sta *lq_sta; struct il_station_priv *sta_priv = (struct il_station_priv *)sta->drv_priv; struct il_priv *il; @@ -2303,9 +2302,7 @@ il4965_rs_alloc_sta(void *il_rate, struct ieee80211_sta *sta, gfp_t gfp) il = (struct il_priv *)il_rate; D_RATE("create station rate scale win\n"); - lq_sta = &sta_priv->lq_sta; - - return lq_sta; + return &sta_priv->lq_sta; } /* -- cgit v1.2.3 From a741b99577c3fa359208c9ff14aede77bc0d0e02 Mon Sep 17 00:00:00 2001 From: Greg Dietsche Date: Tue, 6 Sep 2011 17:49:07 -0500 Subject: iwlegacy: 4965-rs: don't return rate from il4965_rs_update_rate_tbl 1) don't return rate from il4965_rs_update_rate_tbl 2) fix up il4965_rs_rate_scale_perform Signed-off-by: Greg Dietsche Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/4965-rs.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/4965-rs.c b/drivers/net/wireless/iwlegacy/4965-rs.c index 52006376febd..162c778773ec 100644 --- a/drivers/net/wireless/iwlegacy/4965-rs.c +++ b/drivers/net/wireless/iwlegacy/4965-rs.c @@ -1731,9 +1731,8 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search) /* * setup rate table in uCode - * return rate_n_flags as used in the table */ -static u32 +static void il4965_rs_update_rate_tbl(struct il_priv *il, struct il_rxon_context *ctx, struct il_lq_sta *lq_sta, struct il_scale_tbl_info *tbl, int idx, u8 is_green) @@ -1744,8 +1743,6 @@ il4965_rs_update_rate_tbl(struct il_priv *il, struct il_rxon_context *ctx, rate = il4965_rate_n_flags_from_tbl(il, tbl, idx, is_green); il4965_rs_fill_link_cmd(il, lq_sta, rate); il_send_lq_cmd(il, ctx, &lq_sta->lq, CMD_ASYNC, false); - - return rate; } /* @@ -1774,7 +1771,6 @@ il4965_rs_rate_scale_perform(struct il_priv *il, struct sk_buff *skb, u8 update_lq = 0; struct il_scale_tbl_info *tbl, *tbl1; u16 rate_scale_idx_msk = 0; - u32 rate; u8 is_green = 0; u8 active_tbl = 0; u8 done_search = 0; @@ -1858,8 +1854,7 @@ il4965_rs_rate_scale_perform(struct il_priv *il, struct sk_buff *skb, tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); /* get "active" rate info */ idx = il4965_hwrate_to_plcp_idx(tbl->current_rate); - rate = - il4965_rs_update_rate_tbl(il, ctx, lq_sta, tbl, idx, + il4965_rs_update_rate_tbl(il, ctx, lq_sta, tbl, idx, is_green); } return; @@ -2062,8 +2057,7 @@ il4965_rs_rate_scale_perform(struct il_priv *il, struct sk_buff *skb, lq_update: /* Replace uCode's rate table for the destination station. */ if (update_lq) - rate = - il4965_rs_update_rate_tbl(il, ctx, lq_sta, tbl, idx, + il4965_rs_update_rate_tbl(il, ctx, lq_sta, tbl, idx, is_green); /* Should we stay with this modulation mode, -- cgit v1.2.3 From e3a2c775336641663b1c38dfa7dd8a1c1210ae23 Mon Sep 17 00:00:00 2001 From: Greg Dietsche Date: Tue, 6 Sep 2011 18:25:32 -0500 Subject: iwlegacy: 4965-rs: cleanup il4965_rs_sta_dbgfs_rate_scale_data_read 1) remove ret local var and return the result directly 2) remove il since it is not used Signed-off-by: Greg Dietsche Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/4965-rs.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/4965-rs.c b/drivers/net/wireless/iwlegacy/4965-rs.c index 162c778773ec..467d0cb14ecd 100644 --- a/drivers/net/wireless/iwlegacy/4965-rs.c +++ b/drivers/net/wireless/iwlegacy/4965-rs.c @@ -2769,14 +2769,9 @@ il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, { char buff[120]; int desc = 0; - ssize_t ret; - struct il_lq_sta *lq_sta = file->private_data; - struct il_priv *il; struct il_scale_tbl_info *tbl = &lq_sta->lq_info[lq_sta->active_tbl]; - il = lq_sta->drv; - if (is_Ht(tbl->lq_type)) desc += sprintf(buff + desc, "Bit Rate= %d Mb/s\n", @@ -2786,8 +2781,7 @@ il4965_rs_sta_dbgfs_rate_scale_data_read(struct file *file, sprintf(buff + desc, "Bit Rate= %d Mb/s\n", il_rates[lq_sta->last_txrate_idx].ieee >> 1); - ret = simple_read_from_buffer(user_buf, count, ppos, buff, desc); - return ret; + return simple_read_from_buffer(user_buf, count, ppos, buff, desc); } static const struct file_operations rs_sta_dbgfs_rate_scale_data_ops = { -- cgit v1.2.3 From 9b5e2f463ac6f53789bd5ce43d2bb4b4c01e8607 Mon Sep 17 00:00:00 2001 From: Greg Dietsche Date: Tue, 6 Sep 2011 19:11:35 -0500 Subject: iwlegacy: debugfs_ops should depend on CONFIG_IWLEGACY_DEBUGFS Only setup structs related to debugfs_ops when CONFIG_IWLEGACY_DEBUGFS is set. Signed-off-by: Greg Dietsche Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/iwlegacy/3945.c | 2 ++ drivers/net/wireless/iwlegacy/3945.h | 21 --------------------- drivers/net/wireless/iwlegacy/4965.c | 2 ++ drivers/net/wireless/iwlegacy/4965.h | 21 --------------------- drivers/net/wireless/iwlegacy/common.h | 4 ++++ 5 files changed, 8 insertions(+), 42 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c index 7367dbb75ec6..863664f9ba8b 100644 --- a/drivers/net/wireless/iwlegacy/3945.c +++ b/drivers/net/wireless/iwlegacy/3945.c @@ -2671,11 +2671,13 @@ static struct il_lib_ops il3945_lib = { .send_tx_power = il3945_send_tx_power, .is_valid_rtc_data_addr = il3945_hw_valid_rtc_data_addr, +#ifdef CONFIG_IWLEGACY_DEBUGFS .debugfs_ops = { .rx_stats_read = il3945_ucode_rx_stats_read, .tx_stats_read = il3945_ucode_tx_stats_read, .general_stats_read = il3945_ucode_general_stats_read, }, +#endif }; static const struct il_legacy_ops il3945_legacy_ops = { diff --git a/drivers/net/wireless/iwlegacy/3945.h b/drivers/net/wireless/iwlegacy/3945.h index 00d3336fd16b..2b2895c544d7 100644 --- a/drivers/net/wireless/iwlegacy/3945.h +++ b/drivers/net/wireless/iwlegacy/3945.h @@ -621,27 +621,6 @@ ssize_t il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, ssize_t il3945_ucode_general_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos); -#else -static ssize_t -il3945_ucode_rx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - return 0; -} - -static ssize_t -il3945_ucode_tx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - return 0; -} - -static ssize_t -il3945_ucode_general_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - return 0; -} #endif #endif diff --git a/drivers/net/wireless/iwlegacy/4965.c b/drivers/net/wireless/iwlegacy/4965.c index ac80a0069124..84c54dccf195 100644 --- a/drivers/net/wireless/iwlegacy/4965.c +++ b/drivers/net/wireless/iwlegacy/4965.c @@ -2333,11 +2333,13 @@ static struct il_lib_ops il4965_lib = { .temp_ops = { .temperature = il4965_temperature_calib, }, +#ifdef CONFIG_IWLEGACY_DEBUGFS .debugfs_ops = { .rx_stats_read = il4965_ucode_rx_stats_read, .tx_stats_read = il4965_ucode_tx_stats_read, .general_stats_read = il4965_ucode_general_stats_read, }, +#endif }; static const struct il_legacy_ops il4965_legacy_ops = { diff --git a/drivers/net/wireless/iwlegacy/4965.h b/drivers/net/wireless/iwlegacy/4965.h index ded8b922a44e..74472314bc37 100644 --- a/drivers/net/wireless/iwlegacy/4965.h +++ b/drivers/net/wireless/iwlegacy/4965.h @@ -956,27 +956,6 @@ ssize_t il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, ssize_t il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, size_t count, loff_t *ppos); -#else -static ssize_t -il4965_ucode_rx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - return 0; -} - -static ssize_t -il4965_ucode_tx_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - return 0; -} - -static ssize_t -il4965_ucode_general_stats_read(struct file *file, char __user *user_buf, - size_t count, loff_t *ppos) -{ - return 0; -} #endif /****************************/ diff --git a/drivers/net/wireless/iwlegacy/common.h b/drivers/net/wireless/iwlegacy/common.h index d0975ab8b908..1bc0b02f559c 100644 --- a/drivers/net/wireless/iwlegacy/common.h +++ b/drivers/net/wireless/iwlegacy/common.h @@ -1631,6 +1631,7 @@ struct il_apm_ops { void (*config) (struct il_priv *il); }; +#ifdef CONFIG_IWLEGACY_DEBUGFS struct il_debugfs_ops { ssize_t(*rx_stats_read) (struct file *file, char __user *user_buf, size_t count, loff_t *ppos); @@ -1640,6 +1641,7 @@ struct il_debugfs_ops { char __user *user_buf, size_t count, loff_t *ppos); }; +#endif struct il_temp_ops { void (*temperature) (struct il_priv *il); @@ -1683,7 +1685,9 @@ struct il_lib_ops { /* temperature */ struct il_temp_ops temp_ops; +#ifdef CONFIG_IWLEGACY_DEBUGFS struct il_debugfs_ops debugfs_ops; +#endif }; -- cgit v1.2.3 From 4ba7d9997869d25bd223dea7536fc1ce9fab3b3b Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 16 Nov 2011 11:09:17 +0100 Subject: rt2800pci: handle spurious interrupts Some devices may generate spurious interrupts, we have to handle them otherwise interrupt line will be disabled with below message and driver will not work: [ 2052.114334] irq 17: nobody cared (try booting with the "irqpoll" option) [ 2052.114339] Pid: 0, comm: swapper Tainted: P 2.6.35.6-48.fc14.x86_64 #1 [ 2052.114341] Call Trace: [ 2052.114342] [] __report_bad_irq.clone.1+0x3d/0x8b [ 2052.114349] [] note_interrupt+0x11a/0x17f [ 2052.114352] [] handle_fasteoi_irq+0xa8/0xce [ 2052.114355] [] handle_irq+0x88/0x90 [ 2052.114357] [] do_IRQ+0x5c/0xb4 [ 2052.114360] [] ret_from_intr+0x0/0x11 [ 2052.114361] [] ? native_safe_halt+0xb/0xd [ 2052.114366] [] ? need_resched+0x23/0x2d [ 2052.114367] [] default_idle+0x34/0x4f [ 2052.114370] [] cpu_idle+0xaa/0xcc [ 2052.114373] [] start_secondary+0x24d/0x28e [ 2052.114374] handlers: [ 2052.114375] [] (usb_hcd_irq+0x0/0x7c) [ 2052.114378] [] (rt2800pci_interrupt+0x0/0x18d [rt2800pci]) [ 2052.114384] Disabling IRQ #17 Resolve: https://bugzilla.redhat.com/show_bug.cgi?id=658451 Reported-and-tested-by: Amir Hedayaty Cc: stable@vger.kernel.org Signed-off-by: Stanislaw Gruszka Acked-by: Ivo van Doorn Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800pci.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c index da48c8ac27bd..4dc2d0f840d4 100644 --- a/drivers/net/wireless/rt2x00/rt2800pci.c +++ b/drivers/net/wireless/rt2x00/rt2800pci.c @@ -880,8 +880,13 @@ static irqreturn_t rt2800pci_interrupt(int irq, void *dev_instance) rt2x00pci_register_read(rt2x00dev, INT_SOURCE_CSR, ®); rt2x00pci_register_write(rt2x00dev, INT_SOURCE_CSR, reg); + /* + * Some devices can generate interrupts with empty CSR register, we + * "handle" such irq's to prevent interrupt controller treat them as + * spurious interrupts and disable irq line. + */ if (!reg) - return IRQ_NONE; + return IRQ_HANDLED; if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) return IRQ_HANDLED; -- cgit v1.2.3 From 23085d5796561625db4143a671f1de081f66ef08 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Wed, 16 Nov 2011 13:58:42 +0100 Subject: rt2x00: handle spurious pci interrupts We have documented case of very bad performance issue on rt2800pci device, because it generate spurious interrupt, what cause irq line is disabled: https://bugzilla.redhat.com/show_bug.cgi?id=658451 We already address that problem in separate patch by returning IRQ_HANDLED from interrupt handler. We think similar fix is needed for other rt2x00 PCI devices, because users report performance problems on these devices too. Cc: stable@vger.kernel.org Signed-off-by: Stanislaw Gruszka Acked-by: Ivo van Doorn Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2400pci.c | 2 +- drivers/net/wireless/rt2x00/rt2500pci.c | 2 +- drivers/net/wireless/rt2x00/rt61pci.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c index 3a6b40239bc1..676c7657f5f5 100644 --- a/drivers/net/wireless/rt2x00/rt2400pci.c +++ b/drivers/net/wireless/rt2x00/rt2400pci.c @@ -1380,7 +1380,7 @@ static irqreturn_t rt2400pci_interrupt(int irq, void *dev_instance) rt2x00pci_register_write(rt2x00dev, CSR7, reg); if (!reg) - return IRQ_NONE; + return IRQ_HANDLED; if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) return IRQ_HANDLED; diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c index dcc0e1fcca77..d0b627c6c217 100644 --- a/drivers/net/wireless/rt2x00/rt2500pci.c +++ b/drivers/net/wireless/rt2x00/rt2500pci.c @@ -1512,7 +1512,7 @@ static irqreturn_t rt2500pci_interrupt(int irq, void *dev_instance) rt2x00pci_register_write(rt2x00dev, CSR7, reg); if (!reg) - return IRQ_NONE; + return IRQ_HANDLED; if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) return IRQ_HANDLED; diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c index bf55b4a311e3..9d83e70f3e62 100644 --- a/drivers/net/wireless/rt2x00/rt61pci.c +++ b/drivers/net/wireless/rt2x00/rt61pci.c @@ -2337,7 +2337,7 @@ static irqreturn_t rt61pci_interrupt(int irq, void *dev_instance) rt2x00pci_register_write(rt2x00dev, INT_SOURCE_CSR, reg); if (!reg && !reg_mcu) - return IRQ_NONE; + return IRQ_HANDLED; if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) return IRQ_HANDLED; -- cgit v1.2.3 From 68fa64ef606bcee688fce46d07aa68f175070156 Mon Sep 17 00:00:00 2001 From: Gertjan van Wingerde Date: Wed, 16 Nov 2011 23:16:15 +0100 Subject: rt2x00: Fix efuse EEPROM reading on PPC32. Fix __le32 to __le16 conversion of the first word of an 8-word block of EEPROM read via the efuse method. Reported-and-tested-by: Ingvar Hagelund Signed-off-by: Gertjan van Wingerde CC: Acked-by: Helmut Schaa Acked-by: Ivo van Doorn Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index 3f183a15186e..1ba079dffb11 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c @@ -3771,7 +3771,7 @@ static void rt2800_efuse_read(struct rt2x00_dev *rt2x00dev, unsigned int i) /* Apparently the data is read from end to start */ rt2800_register_read_lock(rt2x00dev, EFUSE_DATA3, ®); /* The returned value is in CPU order, but eeprom is le */ - rt2x00dev->eeprom[i] = cpu_to_le32(reg); + *(u32 *)&rt2x00dev->eeprom[i] = cpu_to_le32(reg); rt2800_register_read_lock(rt2x00dev, EFUSE_DATA2, ®); *(u32 *)&rt2x00dev->eeprom[i + 2] = cpu_to_le32(reg); rt2800_register_read_lock(rt2x00dev, EFUSE_DATA1, ®); -- cgit v1.2.3 From 32d3a3922d617a5a685a5e2d24b20d0e88f192a9 Mon Sep 17 00:00:00 2001 From: Michael Büsch Date: Wed, 16 Nov 2011 23:48:31 +0100 Subject: p54spi: Add missing spin_lock_init The tx_lock is not initialized properly. Add spin_lock_init(). Signed-off-by: Michael Buesch Cc: Acked-by: Christian Lamparter Signed-off-by: John W. Linville --- drivers/net/wireless/p54/p54spi.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/p54/p54spi.c b/drivers/net/wireless/p54/p54spi.c index f18df82eeb92..dda97c54d28f 100644 --- a/drivers/net/wireless/p54/p54spi.c +++ b/drivers/net/wireless/p54/p54spi.c @@ -656,6 +656,7 @@ static int __devinit p54spi_probe(struct spi_device *spi) init_completion(&priv->fw_comp); INIT_LIST_HEAD(&priv->tx_pending); mutex_init(&priv->mutex); + spin_lock_init(&priv->tx_lock); SET_IEEE80211_DEV(hw, &spi->dev); priv->common.open = p54spi_op_start; priv->common.stop = p54spi_op_stop; -- cgit v1.2.3 From 2d1618170eb493d18f66f2ac03775409a6fb97c6 Mon Sep 17 00:00:00 2001 From: Michael Büsch Date: Wed, 16 Nov 2011 23:55:46 +0100 Subject: p54spi: Fix workqueue deadlock priv->work must not be synced while priv->mutex is locked, because the mutex is taken in the work handler. Move cancel_work_sync down to after the device shutdown code. This is safe, because the work handler checks fw_state and bails out early in case of a race. Signed-off-by: Michael Buesch Cc: Acked-by: Christian Lamparter Signed-off-by: John W. Linville --- drivers/net/wireless/p54/p54spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/p54/p54spi.c b/drivers/net/wireless/p54/p54spi.c index dda97c54d28f..78d0d6988553 100644 --- a/drivers/net/wireless/p54/p54spi.c +++ b/drivers/net/wireless/p54/p54spi.c @@ -588,8 +588,6 @@ static void p54spi_op_stop(struct ieee80211_hw *dev) WARN_ON(priv->fw_state != FW_STATE_READY); - cancel_work_sync(&priv->work); - p54spi_power_off(priv); spin_lock_irqsave(&priv->tx_lock, flags); INIT_LIST_HEAD(&priv->tx_pending); @@ -597,6 +595,8 @@ static void p54spi_op_stop(struct ieee80211_hw *dev) priv->fw_state = FW_STATE_OFF; mutex_unlock(&priv->mutex); + + cancel_work_sync(&priv->work); } static int __devinit p54spi_probe(struct spi_device *spi) -- cgit v1.2.3 From 40f9cd299a0e5e8dcdde9b5eb9bfda1cb9109f61 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 21 Nov 2011 17:47:13 +0300 Subject: prism54: potential memory corruption in prism54_get_essid() "dwrq->length" is the capped version of "essid->length". Signed-off-by: Dan Carpenter Signed-off-by: John W. Linville --- drivers/net/wireless/prism54/isl_ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/prism54/isl_ioctl.c b/drivers/net/wireless/prism54/isl_ioctl.c index d97a2caf582b..bc2ba80c47bb 100644 --- a/drivers/net/wireless/prism54/isl_ioctl.c +++ b/drivers/net/wireless/prism54/isl_ioctl.c @@ -778,7 +778,7 @@ prism54_get_essid(struct net_device *ndev, struct iw_request_info *info, dwrq->flags = 0; dwrq->length = 0; } - essid->octets[essid->length] = '\0'; + essid->octets[dwrq->length] = '\0'; memcpy(extra, essid->octets, dwrq->length); kfree(essid); -- cgit v1.2.3 From 83c76570961573e56a238d84ba18f2581ef1e6b5 Mon Sep 17 00:00:00 2001 From: Zefir Kurtisi Date: Wed, 16 Nov 2011 11:09:44 +0100 Subject: ath9k: trivial: reorder rx_tasklet processing DFS events are reported as PHY errors and need to be processed with a correct timestamp set before ath9k_skb_preprocess() is called and the frame is possibly dropped. This patch puts the rxs->mactime calculation before the skb is preprocessed to prepare for DFS event reporting. Signed-off-by: Zefir Kurtisi Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/recv.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c index 67b862cdae6d..4c8e296f663b 100644 --- a/drivers/net/wireless/ath/ath9k/recv.c +++ b/drivers/net/wireless/ath/ath9k/recv.c @@ -1838,11 +1838,6 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) if (sc->sc_flags & SC_OP_RXFLUSH) goto requeue_drop_frag; - retval = ath9k_rx_skb_preprocess(common, hw, hdr, &rs, - rxs, &decrypt_error); - if (retval) - goto requeue_drop_frag; - rxs->mactime = (tsf & ~0xffffffffULL) | rs.rs_tstamp; if (rs.rs_tstamp > tsf_lower && unlikely(rs.rs_tstamp - tsf_lower > 0x10000000)) @@ -1852,6 +1847,11 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) unlikely(tsf_lower - rs.rs_tstamp > 0x10000000)) rxs->mactime += 0x100000000ULL; + retval = ath9k_rx_skb_preprocess(common, hw, hdr, &rs, + rxs, &decrypt_error); + if (retval) + goto requeue_drop_frag; + /* Ensure we always have an skb to requeue once we are done * processing the current buffer's skb */ requeue_skb = ath_rxbuf_alloc(common, common->rx_bufsize, GFP_ATOMIC); -- cgit v1.2.3 From 040a72785cf19fd8032f24d584ee305158c87ac7 Mon Sep 17 00:00:00 2001 From: George Date: Thu, 17 Nov 2011 12:14:42 -0600 Subject: rtlwifi: rtl8192cu: Allow retries for USB I/O The USB driver does not retry reads - allow 10 tries. Signed-off-by: George Signed-off-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h | 2 +- drivers/net/wireless/rtlwifi/usb.c | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h index 3d5823c12621..fcc4032585dc 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h +++ b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h @@ -32,7 +32,7 @@ #define FW_8192C_SIZE 0x3000 #define FW_8192C_START_ADDRESS 0x1000 -#define FW_8192C_END_ADDRESS 0x3FFF +#define FW_8192C_END_ADDRESS 0x1FFF #define FW_8192C_PAGE_SIZE 4096 #define FW_8192C_POLLING_DELAY 5 #define FW_8192C_POLLING_TIMEOUT_COUNT 100 diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c index b42c2e2b2055..209105c8e3dc 100644 --- a/drivers/net/wireless/rtlwifi/usb.c +++ b/drivers/net/wireless/rtlwifi/usb.c @@ -33,6 +33,7 @@ #include "usb.h" #include "base.h" #include "ps.h" +#include "rtl8192c/fw_common.h" #define REALTEK_USB_VENQT_READ 0xC0 #define REALTEK_USB_VENQT_WRITE 0x40 @@ -40,6 +41,7 @@ #define REALTEK_USB_VENQT_CMD_IDX 0x00 #define REALTEK_USB_VENQT_MAX_BUF_SIZE 254 +#define MAX_USBCTRL_VENDORREQ_TIMES 10 static void usbctrl_async_callback(struct urb *urb) { @@ -99,13 +101,23 @@ static int _usbctrl_vendorreq_sync_read(struct usb_device *udev, u8 request, unsigned int pipe; int status; u8 reqtype; + int vendorreq_times = 0; pipe = usb_rcvctrlpipe(udev, 0); /* read_in */ reqtype = REALTEK_USB_VENQT_READ; - status = usb_control_msg(udev, pipe, request, reqtype, value, index, - pdata, len, 0); /* max. timeout */ - + while (++vendorreq_times <= MAX_USBCTRL_VENDORREQ_TIMES) { + status = usb_control_msg(udev, pipe, request, reqtype, value, + index, pdata, len, 0); /*max. timeout*/ + if (status < 0) { + /* firmware download is checksumed, don't retry */ + if ((value >= FW_8192C_START_ADDRESS && + value <= FW_8192C_END_ADDRESS)) + break; + } else { + break; + } + } if (status < 0) pr_err("reg 0x%x, usbctrl_vendorreq TimeOut! status:0x%x value=0x%x\n", value, status, *(u32 *)pdata); -- cgit v1.2.3 From ff6ff96b5ba5b39f7ab3d8ea0cf9ec414452ac92 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 17 Nov 2011 12:14:43 -0600 Subject: rtlwifi: rtl8192cu: Change firmware upload to use block writes Driver rtl8192cu writes the firmware with 32-bit asynchronous writes. This design is OK for USB 2.0 adapters, but the current implementation of xhcu-hcd has a limited ring size, which is exceeded. By converting to synchronous block writes, this error is avoided. Signed-off-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c | 32 +++++++++++++++++++++++ drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h | 1 + drivers/net/wireless/rtlwifi/rtl8192cu/mac.c | 1 + drivers/net/wireless/rtlwifi/usb.c | 26 +++++++++++++++++- drivers/net/wireless/rtlwifi/wifi.h | 7 +++-- 5 files changed, 64 insertions(+), 3 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c index 49a064bdbce6..ebb73a2fae91 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c @@ -72,6 +72,34 @@ static void _rtl92c_enable_fw_download(struct ieee80211_hw *hw, bool enable) } } +static void rtl_block_fw_writeN(struct ieee80211_hw *hw, const u8 *buffer, + u32 size) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + u32 blockSize = REALTEK_USB_VENQT_MAX_BUF_SIZE - 20; + u8 *bufferPtr = (u8 *) buffer; + u32 i, offset, blockCount, remainSize; + + blockCount = size / blockSize; + remainSize = size % blockSize; + + for (i = 0; i < blockCount; i++) { + offset = i * blockSize; + rtlpriv->io.writeN_sync(rtlpriv, + (FW_8192C_START_ADDRESS + offset), + (void *)(bufferPtr + offset), + blockSize); + } + + if (remainSize) { + offset = blockCount * blockSize; + rtlpriv->io.writeN_sync(rtlpriv, + (FW_8192C_START_ADDRESS + offset), + (void *)(bufferPtr + offset), + remainSize); + } +} + static void _rtl92c_fw_block_write(struct ieee80211_hw *hw, const u8 *buffer, u32 size) { @@ -81,6 +109,10 @@ static void _rtl92c_fw_block_write(struct ieee80211_hw *hw, u32 *pu4BytePtr = (u32 *) buffer; u32 i, offset, blockCount, remainSize; + if (rtlpriv->io.writeN_sync) { + rtl_block_fw_writeN(hw, buffer, size); + return; + } blockCount = size / blockSize; remainSize = size % blockSize; diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h index fcc4032585dc..c55c0541ff15 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h +++ b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h @@ -94,5 +94,6 @@ void rtl92c_firmware_selfreset(struct ieee80211_hw *hw); void rtl92c_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode); void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished); void rtl92c_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus); +void usb_writeN_async(struct rtl_priv *rtlpriv, u32 addr, void *data, u16 len); #endif diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c index 060a06f4a885..9e0c8fcdf90f 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/mac.c @@ -84,6 +84,7 @@ void rtl92c_read_chip_version(struct ieee80211_hw *hw) } } rtlhal->version = (enum version_8192c)chip_version; + pr_info("rtl8192cu: Chip version 0x%x\n", chip_version); switch (rtlhal->version) { case VERSION_NORMAL_TSMC_CHIP_92C_1T2R: RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c index 209105c8e3dc..a461822c05b3 100644 --- a/drivers/net/wireless/rtlwifi/usb.c +++ b/drivers/net/wireless/rtlwifi/usb.c @@ -40,7 +40,6 @@ #define REALTEK_USB_VENQT_CMD_REQ 0x05 #define REALTEK_USB_VENQT_CMD_IDX 0x00 -#define REALTEK_USB_VENQT_MAX_BUF_SIZE 254 #define MAX_USBCTRL_VENDORREQ_TIMES 10 static void usbctrl_async_callback(struct urb *urb) @@ -203,6 +202,30 @@ static void _usb_write32_async(struct rtl_priv *rtlpriv, u32 addr, u32 val) _usb_write_async(to_usb_device(dev), addr, val, 4); } +static void _usb_writeN_sync(struct rtl_priv *rtlpriv, u32 addr, void *data, + u16 len) +{ + struct device *dev = rtlpriv->io.dev; + struct usb_device *udev = to_usb_device(dev); + u8 request = REALTEK_USB_VENQT_CMD_REQ; + u8 reqtype = REALTEK_USB_VENQT_WRITE; + u16 wvalue; + u16 index = REALTEK_USB_VENQT_CMD_IDX; + int pipe = usb_sndctrlpipe(udev, 0); /* write_out */ + u8 *buffer; + dma_addr_t dma_addr; + + wvalue = (u16)(addr&0x0000ffff); + buffer = usb_alloc_coherent(udev, (size_t)len, GFP_ATOMIC, &dma_addr); + if (!buffer) + return; + memcpy(buffer, data, len); + usb_control_msg(udev, pipe, request, reqtype, wvalue, + index, buffer, len, 50); + + usb_free_coherent(udev, (size_t)len, buffer, dma_addr); +} + static void _rtl_usb_io_handler_init(struct device *dev, struct ieee80211_hw *hw) { @@ -216,6 +239,7 @@ static void _rtl_usb_io_handler_init(struct device *dev, rtlpriv->io.read8_sync = _usb_read8_sync; rtlpriv->io.read16_sync = _usb_read16_sync; rtlpriv->io.read32_sync = _usb_read32_sync; + rtlpriv->io.writeN_sync = _usb_writeN_sync; } static void _rtl_usb_io_handler_release(struct ieee80211_hw *hw) diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h index 713c7ddba8eb..f3c132b55d42 100644 --- a/drivers/net/wireless/rtlwifi/wifi.h +++ b/drivers/net/wireless/rtlwifi/wifi.h @@ -63,6 +63,7 @@ #define AC_MAX 4 #define QOS_QUEUE_NUM 4 #define RTL_MAC80211_NUM_QUEUE 5 +#define REALTEK_USB_VENQT_MAX_BUF_SIZE 254 #define QBSS_LOAD_SIZE 5 #define MAX_WMMELE_LENGTH 64 @@ -943,8 +944,10 @@ struct rtl_io { unsigned long pci_base_addr; /*device I/O address */ void (*write8_async) (struct rtl_priv *rtlpriv, u32 addr, u8 val); - void (*write16_async) (struct rtl_priv *rtlpriv, u32 addr, __le16 val); - void (*write32_async) (struct rtl_priv *rtlpriv, u32 addr, __le32 val); + void (*write16_async) (struct rtl_priv *rtlpriv, u32 addr, u16 val); + void (*write32_async) (struct rtl_priv *rtlpriv, u32 addr, u32 val); + void (*writeN_sync) (struct rtl_priv *rtlpriv, u32 addr, void *buf, + u16 len); u8(*read8_sync) (struct rtl_priv *rtlpriv, u32 addr); u16(*read16_sync) (struct rtl_priv *rtlpriv, u32 addr); -- cgit v1.2.3 From abfabc9b48f6943dbb707fcfc2ef2a04c329e3e8 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 17 Nov 2011 12:14:44 -0600 Subject: rtlwifi: rtl8192cu: Fix endianian issues Driver rtlwifi fails on a big-endian host. These changes have been tested on a Mac PowerBook G4, which has a PPC processor. Although this patch touches some of the code that will affect endian issues on PCI hardware through drivers rtl8192ce, rtl8192se, and rtl8192de, these have not been tested due to lack of suitable hardware. Signed-off-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/base.c | 6 ++--- drivers/net/wireless/rtlwifi/base.h | 2 +- drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c | 28 +++++++++++++---------- drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h | 20 ++++++++-------- drivers/net/wireless/rtlwifi/rtl8192cu/hw.c | 9 ++++---- drivers/net/wireless/rtlwifi/rtl8192cu/trx.c | 2 +- drivers/net/wireless/rtlwifi/usb.c | 12 ++++++---- 7 files changed, 43 insertions(+), 36 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c index d4fdd2a5a739..c968458c6ecc 100644 --- a/drivers/net/wireless/rtlwifi/base.c +++ b/drivers/net/wireless/rtlwifi/base.c @@ -344,9 +344,9 @@ static void _rtl_init_mac80211(struct ieee80211_hw *hw) if (is_valid_ether_addr(rtlefuse->dev_addr)) { SET_IEEE80211_PERM_ADDR(hw, rtlefuse->dev_addr); } else { - u8 rtlmac[] = { 0x00, 0xe0, 0x4c, 0x81, 0x92, 0x00 }; - get_random_bytes((rtlmac + (ETH_ALEN - 1)), 1); - SET_IEEE80211_PERM_ADDR(hw, rtlmac); + u8 rtlmac1[] = { 0x00, 0xe0, 0x4c, 0x81, 0x92, 0x00 }; + get_random_bytes((rtlmac1 + (ETH_ALEN - 1)), 1); + SET_IEEE80211_PERM_ADDR(hw, rtlmac1); } } diff --git a/drivers/net/wireless/rtlwifi/base.h b/drivers/net/wireless/rtlwifi/base.h index 4ae905983d0d..f66b5757f6b9 100644 --- a/drivers/net/wireless/rtlwifi/base.h +++ b/drivers/net/wireless/rtlwifi/base.h @@ -76,7 +76,7 @@ enum ap_peer { SET_BITS_TO_LE_2BYTE(_hdr, 8, 1, _val) #define SET_80211_PS_POLL_AID(_hdr, _val) \ - (*(u16 *)((u8 *)(_hdr) + 2) = le16_to_cpu(_val)) + (*(u16 *)((u8 *)(_hdr) + 2) = _val) #define SET_80211_PS_POLL_BSSID(_hdr, _val) \ memcpy(((u8 *)(_hdr)) + 4, (u8 *)(_val), ETH_ALEN) #define SET_80211_PS_POLL_TA(_hdr, _val) \ diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c index ebb73a2fae91..1234e3b32fbf 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c @@ -108,6 +108,7 @@ static void _rtl92c_fw_block_write(struct ieee80211_hw *hw, u8 *bufferPtr = (u8 *) buffer; u32 *pu4BytePtr = (u32 *) buffer; u32 i, offset, blockCount, remainSize; + u32 data; if (rtlpriv->io.writeN_sync) { rtl_block_fw_writeN(hw, buffer, size); @@ -115,20 +116,22 @@ static void _rtl92c_fw_block_write(struct ieee80211_hw *hw, } blockCount = size / blockSize; remainSize = size % blockSize; + if (remainSize) { + /* the last word is < 4 bytes - pad it with zeros */ + for (i = 0; i < 4 - remainSize; i++) + *(bufferPtr + size + i) = 0; + blockCount++; + } for (i = 0; i < blockCount; i++) { offset = i * blockSize; + /* for big-endian platforms, the firmware data need to be byte + * swapped as it was read as a byte string and will be written + * as 32-bit dwords and byte swapped when written + */ + data = le32_to_cpu(*(__le32 *)(pu4BytePtr + i)); rtl_write_dword(rtlpriv, (FW_8192C_START_ADDRESS + offset), - *(pu4BytePtr + i)); - } - - if (remainSize) { - offset = blockCount * blockSize; - bufferPtr += offset; - for (i = 0; i < remainSize; i++) { - rtl_write_byte(rtlpriv, (FW_8192C_START_ADDRESS + - offset + i), *(bufferPtr + i)); - } + data); } } @@ -269,8 +272,9 @@ int rtl92c_download_fw(struct ieee80211_hw *hw) if (IS_FW_HEADER_EXIST(pfwheader)) { RT_TRACE(rtlpriv, COMP_FW, DBG_DMESG, ("Firmware Version(%d), Signature(%#x),Size(%d)\n", - pfwheader->version, pfwheader->signature, - (uint)sizeof(struct rtl92c_firmware_header))); + le16_to_cpu(pfwheader->version), + le16_to_cpu(pfwheader->signature), + (uint)sizeof(struct rtl92c_firmware_header))); pfwdata = pfwdata + sizeof(struct rtl92c_firmware_header); fwsize = fwsize - sizeof(struct rtl92c_firmware_header); diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h index c55c0541ff15..cec5a3a1cc53 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h +++ b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.h @@ -38,26 +38,26 @@ #define FW_8192C_POLLING_TIMEOUT_COUNT 100 #define IS_FW_HEADER_EXIST(_pfwhdr) \ - ((_pfwhdr->signature&0xFFF0) == 0x92C0 ||\ - (_pfwhdr->signature&0xFFF0) == 0x88C0) + ((le16_to_cpu(_pfwhdr->signature)&0xFFF0) == 0x92C0 ||\ + (le16_to_cpu(_pfwhdr->signature)&0xFFF0) == 0x88C0) struct rtl92c_firmware_header { - u16 signature; + __le16 signature; u8 category; u8 function; - u16 version; + __le16 version; u8 subversion; u8 rsvd1; u8 month; u8 date; u8 hour; u8 minute; - u16 ramcodeSize; - u16 rsvd2; - u32 svnindex; - u32 rsvd3; - u32 rsvd4; - u32 rsvd5; + __le16 ramcodeSize; + __le16 rsvd2; + __le32 svnindex; + __le32 rsvd3; + __le32 rsvd4; + __le32 rsvd5; }; enum rtl8192c_h2c_cmd { diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c index 814c05df51e8..4ed973a3aa17 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/hw.c @@ -498,7 +498,7 @@ static void _rtl92cu_read_adapter_info(struct ieee80211_hw *hw) } RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_LOUD, ("MAP\n"), hwinfo, HWSET_MAX_SIZE); - eeprom_id = *((u16 *)&hwinfo[0]); + eeprom_id = le16_to_cpu(*((__le16 *)&hwinfo[0])); if (eeprom_id != RTL8190_EEPROM_ID) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, ("EEPROM ID(%#x) is invalid!!\n", eeprom_id)); @@ -516,13 +516,14 @@ static void _rtl92cu_read_adapter_info(struct ieee80211_hw *hw) pr_info("MAC address: %pM\n", rtlefuse->dev_addr); _rtl92cu_read_txpower_info_from_hwpg(hw, rtlefuse->autoload_failflag, hwinfo); - rtlefuse->eeprom_vid = *(u16 *)&hwinfo[EEPROM_VID]; - rtlefuse->eeprom_did = *(u16 *)&hwinfo[EEPROM_DID]; + rtlefuse->eeprom_vid = le16_to_cpu(*(__le16 *)&hwinfo[EEPROM_VID]); + rtlefuse->eeprom_did = le16_to_cpu(*(__le16 *)&hwinfo[EEPROM_DID]); RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, (" VID = 0x%02x PID = 0x%02x\n", rtlefuse->eeprom_vid, rtlefuse->eeprom_did)); rtlefuse->eeprom_channelplan = *(u8 *)&hwinfo[EEPROM_CHANNELPLAN]; - rtlefuse->eeprom_version = *(u16 *)&hwinfo[EEPROM_VERSION]; + rtlefuse->eeprom_version = + le16_to_cpu(*(__le16 *)&hwinfo[EEPROM_VERSION]); rtlefuse->txpwr_fromeprom = true; rtlefuse->eeprom_oemid = *(u8 *)&hwinfo[EEPROM_CUSTOMER_ID]; RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c index bc33b147f44f..b3cc7b949992 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/trx.c @@ -491,7 +491,7 @@ static void _rtl_tx_desc_checksum(u8 *txdesc) SET_TX_DESC_TX_DESC_CHECKSUM(txdesc, 0); for (index = 0; index < 16; index++) checksum = checksum ^ (*(ptr + index)); - SET_TX_DESC_TX_DESC_CHECKSUM(txdesc, checksum); + SET_TX_DESC_TX_DESC_CHECKSUM(txdesc, cpu_to_le16(checksum)); } void rtl92cu_tx_fill_desc(struct ieee80211_hw *hw, diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c index a461822c05b3..79889b83287e 100644 --- a/drivers/net/wireless/rtlwifi/usb.c +++ b/drivers/net/wireless/rtlwifi/usb.c @@ -82,6 +82,7 @@ static int _usbctrl_vendorreq_async_write(struct usb_device *udev, u8 request, dr->wValue = cpu_to_le16(value); dr->wIndex = cpu_to_le16(index); dr->wLength = cpu_to_le16(len); + /* data are already in little-endian order */ memcpy(buf, pdata, len); usb_fill_control_urb(urb, udev, pipe, (unsigned char *)dr, buf, len, @@ -101,6 +102,7 @@ static int _usbctrl_vendorreq_sync_read(struct usb_device *udev, u8 request, int status; u8 reqtype; int vendorreq_times = 0; + static int count; pipe = usb_rcvctrlpipe(udev, 0); /* read_in */ reqtype = REALTEK_USB_VENQT_READ; @@ -117,9 +119,9 @@ static int _usbctrl_vendorreq_sync_read(struct usb_device *udev, u8 request, break; } } - if (status < 0) + if (status < 0 && count++ < 4) pr_err("reg 0x%x, usbctrl_vendorreq TimeOut! status:0x%x value=0x%x\n", - value, status, *(u32 *)pdata); + value, status, le32_to_cpu(*(u32 *)pdata)); return status; } @@ -139,7 +141,7 @@ static u32 _usb_read_sync(struct usb_device *udev, u32 addr, u16 len) wvalue = (u16)addr; _usbctrl_vendorreq_sync_read(udev, request, wvalue, index, data, len); - ret = *data; + ret = le32_to_cpu(*data); kfree(data); return ret; } @@ -171,12 +173,12 @@ static void _usb_write_async(struct usb_device *udev, u32 addr, u32 val, u8 request; u16 wvalue; u16 index; - u32 data; + __le32 data; request = REALTEK_USB_VENQT_CMD_REQ; index = REALTEK_USB_VENQT_CMD_IDX; /* n/a */ wvalue = (u16)(addr&0x0000ffff); - data = val; + data = cpu_to_le32(val); _usbctrl_vendorreq_async_write(udev, request, wvalue, index, &data, len); } -- cgit v1.2.3 From 0dcc3c842930a36d344d240878ee24910c838665 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 17 Nov 2011 12:14:45 -0600 Subject: rtlwifi: Remove redundant code from PCI interrupt The interrupt routine for PCI devices has a special exit that executes the same instructions as does the normal exit. Signed-off-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/pci.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c index 177a8e669241..a197dce732b4 100644 --- a/drivers/net/wireless/rtlwifi/pci.c +++ b/drivers/net/wireless/rtlwifi/pci.c @@ -889,9 +889,6 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id) if (rtlpriv->rtlhal.earlymode_enable) tasklet_schedule(&rtlpriv->works.irq_tasklet); - spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags); - return IRQ_HANDLED; - done: spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags); return IRQ_HANDLED; -- cgit v1.2.3 From 1f1d528977162a1a04aaecdc7f08a5b715a58810 Mon Sep 17 00:00:00 2001 From: Thomas Meyer Date: Thu, 17 Nov 2011 23:43:40 +0100 Subject: brcm80211: smac: Use kmemdup rather than duplicating its implementation The semantic patch that makes this change is available in scripts/coccinelle/api/memdup.cocci. Signed-off-by: Thomas Meyer Acked-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c index 6d3c7b6c5aa0..922c5d969a5b 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c @@ -1549,11 +1549,10 @@ int brcms_ucode_init_buf(struct brcms_info *wl, void **pbuf, u32 idx) if (le32_to_cpu(hdr->idx) == idx) { pdata = wl->fw.fw_bin[i]->data + le32_to_cpu(hdr->offset); - *pbuf = kmalloc(len, GFP_ATOMIC); + *pbuf = kmemdup(pdata, len, GFP_ATOMIC); if (*pbuf == NULL) goto fail; - memcpy(*pbuf, pdata, len); return 0; } } -- cgit v1.2.3 From 08d1700da05a2246ee0d9d2440d5c165615c352c Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Thu, 17 Nov 2011 16:05:09 -0800 Subject: iwlwifi: check the HW when a queue is stuck Add more information when a queue is stuck and actually get information from the scheduler instead of looking at internal variables. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index a1a58330273f..3f2ceb2033dc 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1515,8 +1515,12 @@ static int iwl_trans_pcie_check_stuck_queue(struct iwl_trans *trans, int cnt) if (time_after(jiffies, timeout)) { IWL_ERR(trans, "Queue %d stuck for %u ms.\n", q->id, hw_params(trans).wd_timeout); - IWL_ERR(trans, "Current read_ptr %d write_ptr %d\n", + IWL_ERR(trans, "Current SW read_ptr %d write_ptr %d\n", q->read_ptr, q->write_ptr); + IWL_ERR(trans, "Current HW read_ptr %d write_ptr %d\n", + iwl_read_prph(bus(trans), SCD_QUEUE_RDPTR(cnt)) + & (TFD_QUEUE_SIZE_MAX - 1), + iwl_read_prph(bus(trans), SCD_QUEUE_WRPTR(cnt))); return 1; } -- cgit v1.2.3 From 1daf04b8ac51f911f32aedc77f7f6559924d8ab3 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Thu, 17 Nov 2011 16:05:10 -0800 Subject: iwlwifi: improve the prints in the reclaim path Some information was redundation, other was missing. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 1 + drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h | 5 +++++ drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c | 3 --- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 6 +++--- 4 files changed, 9 insertions(+), 6 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index e6a02e09ee18..4ce64d7ad3be 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -790,6 +790,7 @@ int iwlagn_rx_reply_tx(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, iwl_rx_reply_tx_agg(priv, tx_resp); if (tx_resp->frame_count == 1) { + IWL_DEBUG_TX_REPLY(priv, "Q %d, ssn %d", txq_id, ssn); __skb_queue_head_init(&skbs); /*we can free until ssn % q.n_bd not inclusive */ iwl_trans_reclaim(trans(priv), sta_id, tid, txq_id, diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h index afaaa2a51b96..5a384b309b09 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h @@ -354,6 +354,11 @@ static inline void iwl_set_swq_id(struct iwl_tx_queue *txq, u8 ac, u8 hwq) txq->swq_id = (hwq << 2) | ac; } +static inline u8 iwl_get_queue_ac(struct iwl_tx_queue *txq) +{ + return txq->swq_id & 0x3; +} + static inline void iwl_wake_queue(struct iwl_trans *trans, struct iwl_tx_queue *txq, const char *msg) { diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index 6dba1515023c..b93acce08bd2 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -1121,9 +1121,6 @@ int iwl_tx_queue_reclaim(struct iwl_trans *trans, int txq_id, int index, return 0; } - IWL_DEBUG_TX_REPLY(trans, "reclaim: [%d, %d, %d]\n", txq_id, - q->read_ptr, index); - if (WARN_ON(!skb_queue_empty(skbs))) return 0; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 3f2ceb2033dc..527e7957c932 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1350,9 +1350,9 @@ static void iwl_trans_pcie_reclaim(struct iwl_trans *trans, int sta_id, int tid, } if (txq->q.read_ptr != tfd_num) { - IWL_DEBUG_TX_REPLY(trans, "Retry scheduler reclaim " - "scd_ssn=%d idx=%d txq=%d swq=%d\n", - ssn , tfd_num, txq_id, txq->swq_id); + IWL_DEBUG_TX_REPLY(trans, "[Q %d | AC %d] %d -> %d (%d)\n", + txq_id, iwl_get_queue_ac(txq), txq->q.read_ptr, + tfd_num, ssn); freed = iwl_tx_queue_reclaim(trans, txq_id, tfd_num, skbs); if (iwl_queue_space(&txq->q) > txq->q.low_mark && cond) iwl_wake_queue(trans, txq, "Packets reclaimed"); -- cgit v1.2.3 From 4bf218c03328beeed60ded10d173468f6a551caa Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Thu, 17 Nov 2011 16:05:11 -0800 Subject: iwlwifi: fix endianity issues in debug prints Use the CPUed version of the variables when printing data from the BA notification. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index 4ce64d7ad3be..a1a95d5f3923 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -921,11 +921,9 @@ int iwlagn_rx_reply_compressed_ba(struct iwl_priv *priv, ba_resp->sta_id); IWL_DEBUG_TX_REPLY(priv, "TID = %d, SeqCtl = %d, bitmap = 0x%llx, " "scd_flow = %d, scd_ssn = %d\n", - ba_resp->tid, - ba_resp->seq_ctl, + ba_resp->tid, ba_resp->seq_ctl, (unsigned long long)le64_to_cpu(ba_resp->bitmap), - ba_resp->scd_flow, - ba_resp->scd_ssn); + scd_flow, ba_resp_scd_ssn); /* Mark that the expected block-ack response arrived */ agg->wait_for_ba = false; -- cgit v1.2.3 From b3f15ef22cc539c35e7ec1db97cd652a56ccce04 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Thu, 17 Nov 2011 16:05:12 -0800 Subject: iwlwifi: tid_data is taken twice in iwl_trans_pcie_tx_agg_alloc Remove this redundancy. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c index b93acce08bd2..79331fb10aa5 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-tx.c @@ -559,7 +559,6 @@ int iwl_trans_pcie_tx_agg_alloc(struct iwl_trans *trans, tid_data->agg.txq_id = txq_id; iwl_set_swq_id(&trans_pcie->txq[txq_id], get_ac_from_tid(tid), txq_id); - tid_data = &trans->shrd->tid_data[sta_id][tid]; if (tid_data->tfds_in_queue == 0) { IWL_DEBUG_TX_QUEUES(trans, "HW queue is empty\n"); tid_data->agg.state = IWL_AGG_ON; -- cgit v1.2.3 From 1ffeb2a3e943299a2ca954b8d10c208c853c1960 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Thu, 17 Nov 2011 16:05:13 -0800 Subject: iwlwifi: remove redundancy just use iwl_bus, remove the redundancy Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-io.c b/drivers/net/wireless/iwlwifi/iwl-io.c index 3ffa8e62b856..3464cad7e38c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-io.c +++ b/drivers/net/wireless/iwlwifi/iwl-io.c @@ -143,7 +143,7 @@ u32 iwl_read_direct32(struct iwl_bus *bus, u32 reg) spin_lock_irqsave(&bus->reg_lock, flags); iwl_grab_nic_access(bus); - value = iwl_read32(bus(bus), reg); + value = iwl_read32(bus, reg); iwl_release_nic_access(bus); spin_unlock_irqrestore(&bus->reg_lock, flags); -- cgit v1.2.3 From 1e7aecc26b95efb9d9bdba1ff5c33c99ca34d4ad Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Thu, 17 Nov 2011 17:46:15 -0800 Subject: iwl-debug: Shrink object by using dev_err and deduplicating formats Using dev_err instead of dev_printk(KERN_ERR uses fewer arguments and is a bit smaller. Deduplicating formats used by IWL_DEBUG_QUIET_RFKILL also makes the object a bit smaller. Neatened the macros, used ##__VA_ARGS__. $ size drivers/net/wireless/iwlwifi/built-in.o* text data bss dec hex filename 462652 8646 92576 563874 89aa2 drivers/net/wireless/iwlwifi/built-in.o.new 467557 8646 92592 568795 8addb drivers/net/wireless/iwlwifi/built-in.o.old Signed-off-by: Joe Perches Acked-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-debug.h | 37 ++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h index 40ef97bac1aa..44a7bdd7ccfd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debug.h +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h @@ -47,20 +47,21 @@ do { \ } while (0) #ifdef CONFIG_IWLWIFI_DEBUG -#define IWL_DEBUG(m, level, fmt, args...) \ +#define IWL_DEBUG(m, level, fmt, ...) \ do { \ if (iwl_get_debug_level((m)->shrd) & (level)) \ - dev_printk(KERN_ERR, bus(m)->dev, \ - "%c %s " fmt, in_interrupt() ? 'I' : 'U', \ - __func__ , ## args); \ + dev_err(bus(m)->dev, "%c %s " fmt, \ + in_interrupt() ? 'I' : 'U', __func__, \ + ##__VA_ARGS__); \ } while (0) -#define IWL_DEBUG_LIMIT(m, level, fmt, args...) \ +#define IWL_DEBUG_LIMIT(m, level, fmt, ...) \ do { \ - if (iwl_get_debug_level((m)->shrd) & (level) && net_ratelimit())\ - dev_printk(KERN_ERR, bus(m)->dev, \ - "%c %s " fmt, in_interrupt() ? 'I' : 'U', \ - __func__ , ## args); \ + if (iwl_get_debug_level((m)->shrd) & (level) && \ + net_ratelimit()) \ + dev_err(bus(m)->dev, "%c %s " fmt, \ + in_interrupt() ? 'I' : 'U', __func__, \ + ##__VA_ARGS__); \ } while (0) #define iwl_print_hex_dump(m, level, p, len) \ @@ -70,14 +71,18 @@ do { \ DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ } while (0) -#define IWL_DEBUG_QUIET_RFKILL(p, fmt, args...) \ +#define IWL_DEBUG_QUIET_RFKILL(p, fmt, ...) \ do { \ - if (!iwl_is_rfkill(p->shrd)) \ - dev_printk(KERN_ERR, bus(p)->dev, "%c %s " fmt, \ - (in_interrupt() ? 'I' : 'U'), __func__ , ##args); \ - else if (iwl_get_debug_level(p->shrd) & IWL_DL_RADIO) \ - dev_printk(KERN_ERR, bus(p)->dev, "(RFKILL) %c %s " fmt, \ - (in_interrupt() ? 'I' : 'U'), __func__ , ##args); \ + if (!iwl_is_rfkill(p->shrd)) \ + dev_err(bus(p)->dev, "%s%c %s " fmt, \ + "", \ + in_interrupt() ? 'I' : 'U', __func__, \ + ##__VA_ARGS__); \ + else if (iwl_get_debug_level(p->shrd) & IWL_DL_RADIO) \ + dev_err(bus(p)->dev, "%s%c %s " fmt, \ + "(RFKILL) ", \ + in_interrupt() ? 'I' : 'U', __func__, \ + ##__VA_ARGS__); \ } while (0) #else -- cgit v1.2.3 From 7c4ef7122cef54dc49562eea35cbfaf0f44faa0b Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 18 Nov 2011 15:33:48 +0100 Subject: cfg80211: add flags for off-channel capabilities Currently mac80211 implements these for all devices, but given restrictions of some devices that isn't really true, so prepare for being able to remove the capability for some mac80211 devices. Signed-off-by: Johannes Berg Acked-by: Kalle Valo Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath6kl/init.c | 3 ++- include/net/cfg80211.h | 4 ++++ net/mac80211/main.c | 4 +++- net/wireless/nl80211.c | 16 +++++++++++----- 4 files changed, 20 insertions(+), 7 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath6kl/init.c b/drivers/net/wireless/ath/ath6kl/init.c index 57529acb9144..30050af9d4c6 100644 --- a/drivers/net/wireless/ath/ath6kl/init.c +++ b/drivers/net/wireless/ath/ath6kl/init.c @@ -1602,7 +1602,8 @@ int ath6kl_core_init(struct ath6kl *ar) ar->conf_flags |= ATH6KL_CONF_SUSPEND_CUTPOWER; ar->wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM | - WIPHY_FLAG_HAVE_AP_SME; + WIPHY_FLAG_HAVE_AP_SME | + WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; set_bit(FIRST_BOOT, &ar->flag); diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 8d7ba0961d3e..26890045dbd6 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h @@ -1700,6 +1700,8 @@ struct cfg80211_ops { * cfg80211_report_obss_beacon(). * @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD: When operating as an AP, the device * responds to probe-requests in hardware. + * @WIPHY_FLAG_OFFCHAN_TX: Device supports direct off-channel TX. + * @WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL: Device supports remain-on-channel call. */ enum wiphy_flags { WIPHY_FLAG_CUSTOM_REGULATORY = BIT(0), @@ -1721,6 +1723,8 @@ enum wiphy_flags { WIPHY_FLAG_HAVE_AP_SME = BIT(17), WIPHY_FLAG_REPORTS_OBSS = BIT(18), WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD = BIT(19), + WIPHY_FLAG_OFFCHAN_TX = BIT(20), + WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL = BIT(21), }; /** diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 3df4482bb1d9..f0106d331938 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c @@ -594,7 +594,9 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, wiphy->flags |= WIPHY_FLAG_NETNS_OK | WIPHY_FLAG_4ADDR_AP | WIPHY_FLAG_4ADDR_STATION | - WIPHY_FLAG_REPORTS_OBSS; + WIPHY_FLAG_REPORTS_OBSS | + WIPHY_FLAG_OFFCHAN_TX | + WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; wiphy->features = NL80211_FEATURE_SK_TX_STATUS; diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index ae8ea3827acd..9755b3f04dd7 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -882,7 +882,8 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, CMD(set_pmksa, SET_PMKSA); CMD(del_pmksa, DEL_PMKSA); CMD(flush_pmksa, FLUSH_PMKSA); - CMD(remain_on_channel, REMAIN_ON_CHANNEL); + if (dev->wiphy.flags & WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL) + CMD(remain_on_channel, REMAIN_ON_CHANNEL); CMD(set_bitrate_mask, SET_TX_BITRATE_MASK); CMD(mgmt_tx, FRAME); CMD(mgmt_tx_cancel_wait, FRAME_WAIT_CANCEL); @@ -922,11 +923,12 @@ static int nl80211_send_wiphy(struct sk_buff *msg, u32 pid, u32 seq, int flags, nla_nest_end(msg, nl_cmds); - if (dev->ops->remain_on_channel) + if (dev->ops->remain_on_channel && + dev->wiphy.flags & WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL) NLA_PUT_U32(msg, NL80211_ATTR_MAX_REMAIN_ON_CHANNEL_DURATION, dev->wiphy.max_remain_on_channel_duration); - if (dev->ops->mgmt_tx_cancel_wait) + if (dev->wiphy.flags & WIPHY_FLAG_OFFCHAN_TX) NLA_PUT_FLAG(msg, NL80211_ATTR_OFFCHANNEL_TX_OK); if (mgmt_stypes) { @@ -5127,7 +5129,8 @@ static int nl80211_remain_on_channel(struct sk_buff *skb, duration > rdev->wiphy.max_remain_on_channel_duration) return -EINVAL; - if (!rdev->ops->remain_on_channel) + if (!rdev->ops->remain_on_channel || + !(rdev->wiphy.flags & WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL)) return -EOPNOTSUPP; if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE]) { @@ -5340,7 +5343,7 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info) return -EOPNOTSUPP; if (info->attrs[NL80211_ATTR_DURATION]) { - if (!rdev->ops->mgmt_tx_cancel_wait) + if (!(rdev->wiphy.flags & WIPHY_FLAG_OFFCHAN_TX)) return -EINVAL; wait = nla_get_u32(info->attrs[NL80211_ATTR_DURATION]); } @@ -5358,6 +5361,9 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info) offchan = info->attrs[NL80211_ATTR_OFFCHANNEL_TX_OK]; + if (offchan && !(rdev->wiphy.flags & WIPHY_FLAG_OFFCHAN_TX)) + return -EINVAL; + no_cck = nla_get_flag(info->attrs[NL80211_ATTR_TX_NO_CCK_RATE]); freq = nla_get_u32(info->attrs[NL80211_ATTR_WIPHY_FREQ]); -- cgit v1.2.3 From cb82a66d0f35eb3f510c3f770d6fbdc3b17ab041 Mon Sep 17 00:00:00 2001 From: Jussi Kivilinna Date: Sat, 19 Nov 2011 13:04:05 +0200 Subject: rndis_wlan: split getting current channel to separate function Split getting current channel channel from hardware to separate function as this function will be needed later in patch 'pass channel info to cfg80211_roamed()'. Signed-off-by: Jussi Kivilinna Signed-off-by: John W. Linville --- drivers/net/wireless/rndis_wlan.c | 49 +++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 18 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index 620e3c0e88e0..37c4c4087572 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c @@ -1347,6 +1347,32 @@ static int set_channel(struct usbnet *usbdev, int channel) return ret; } +static struct ieee80211_channel *get_current_channel(struct usbnet *usbdev, + u16 *beacon_interval) +{ + struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); + struct ieee80211_channel *channel; + struct ndis_80211_conf config; + int len, ret; + + /* Get channel and beacon interval */ + len = sizeof(config); + ret = rndis_query_oid(usbdev, OID_802_11_CONFIGURATION, &config, &len); + netdev_dbg(usbdev->net, "%s(): OID_802_11_CONFIGURATION -> %d\n", + __func__, ret); + if (ret < 0) + return NULL; + + channel = ieee80211_get_channel(priv->wdev.wiphy, + KHZ_TO_MHZ(le32_to_cpu(config.ds_config))); + if (!channel) + return NULL; + + if (beacon_interval) + *beacon_interval = le16_to_cpu(config.beacon_period); + return channel; +} + /* index must be 0 - N, as per NDIS */ static int add_wep_key(struct usbnet *usbdev, const u8 *key, int key_len, int index) @@ -2650,13 +2676,12 @@ static void rndis_wlan_craft_connected_bss(struct usbnet *usbdev, u8 *bssid, { struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); struct ieee80211_channel *channel; - struct ndis_80211_conf config; struct ndis_80211_ssid ssid; struct cfg80211_bss *bss; s32 signal; u64 timestamp; u16 capability; - u16 beacon_interval; + u16 beacon_interval = 0; __le32 rssi; u8 ie_buf[34]; int len, ret, ie_len; @@ -2681,22 +2706,10 @@ static void rndis_wlan_craft_connected_bss(struct usbnet *usbdev, u8 *bssid, } /* Get channel and beacon interval */ - len = sizeof(config); - ret = rndis_query_oid(usbdev, OID_802_11_CONFIGURATION, &config, &len); - netdev_dbg(usbdev->net, "%s(): OID_802_11_CONFIGURATION -> %d\n", - __func__, ret); - if (ret >= 0) { - beacon_interval = le16_to_cpu(config.beacon_period); - channel = ieee80211_get_channel(priv->wdev.wiphy, - KHZ_TO_MHZ(le32_to_cpu(config.ds_config))); - if (!channel) { - netdev_warn(usbdev->net, "%s(): could not get channel." - "\n", __func__); - return; - } - } else { - netdev_warn(usbdev->net, "%s(): could not get configuration.\n", - __func__); + channel = get_current_channel(usbdev, &beacon_interval); + if (!channel) { + netdev_warn(usbdev->net, "%s(): could not get channel.\n", + __func__); return; } -- cgit v1.2.3 From 6f104a081b18ffc7c666be2a1cda682f83d7c8b7 Mon Sep 17 00:00:00 2001 From: Jussi Kivilinna Date: Sat, 19 Nov 2011 13:04:11 +0200 Subject: rndis_wlan: pass channel info to cfg80211_roamed() cfg80211_roamed() now has channel parameter so add passing current channel info. Signed-off-by: Jussi Kivilinna Signed-off-by: John W. Linville --- drivers/net/wireless/rndis_wlan.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index 37c4c4087572..d5bfc8d2bcad 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c @@ -2854,8 +2854,9 @@ static void rndis_wlan_do_link_up_work(struct usbnet *usbdev) req_ie_len, resp_ie, resp_ie_len, 0, GFP_KERNEL); else - cfg80211_roamed(usbdev->net, NULL, bssid, - req_ie, req_ie_len, + cfg80211_roamed(usbdev->net, + get_current_channel(usbdev, NULL), + bssid, req_ie, req_ie_len, resp_ie, resp_ie_len, GFP_KERNEL); } else if (priv->infra_mode == NDIS_80211_INFRA_ADHOC) cfg80211_ibss_joined(usbdev->net, bssid, GFP_KERNEL); -- cgit v1.2.3 From 30fd90731d45eab2f4f51e622e522075c90a0d59 Mon Sep 17 00:00:00 2001 From: Jussi Kivilinna Date: Sat, 19 Nov 2011 13:04:16 +0200 Subject: rndis_wlan: add missing __packed Some structures were missing __packed. Signed-off-by: Jussi Kivilinna Signed-off-by: John W. Linville --- drivers/net/wireless/rndis_wlan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index d5bfc8d2bcad..08c85af003fd 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c @@ -387,13 +387,13 @@ struct ndis_80211_capability { struct ndis_80211_bssid_info { u8 bssid[6]; u8 pmkid[16]; -}; +} __packed; struct ndis_80211_pmkid { __le32 length; __le32 bssid_info_count; struct ndis_80211_bssid_info bssid_info[0]; -}; +} __packed; /* * private data -- cgit v1.2.3 From 1c70687536575bcc96ae88b69154ca62dbdac7c1 Mon Sep 17 00:00:00 2001 From: Jussi Kivilinna Date: Sat, 19 Nov 2011 13:04:21 +0200 Subject: rndis_wlan: add reporting of PMKSA candidate events Convert old WEXT reporting to use new cfg80211_pmksa_candidate_notify(). Signed-off-by: Jussi Kivilinna Signed-off-by: John W. Linville --- drivers/net/wireless/rndis_wlan.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index 08c85af003fd..56514d951ffd 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c @@ -244,6 +244,10 @@ enum ndis_80211_power_mode { NDIS_80211_POWER_MODE_FAST_PSP, }; +enum ndis_80211_pmkid_cand_list_flag_bits { + NDIS_80211_PMKID_CAND_PREAUTH = cpu_to_le32(1 << 0) +}; + struct ndis_80211_auth_request { __le32 length; u8 bssid[6]; @@ -3022,25 +3026,13 @@ static void rndis_wlan_pmkid_cand_list_indication(struct usbnet *usbdev, for (i = 0; i < le32_to_cpu(cand_list->num_candidates); i++) { struct ndis_80211_pmkid_candidate *cand = &cand_list->candidate_list[i]; + bool preauth = !!(cand->flags & NDIS_80211_PMKID_CAND_PREAUTH); - netdev_dbg(usbdev->net, "cand[%i]: flags: 0x%08x, bssid: %pM\n", - i, le32_to_cpu(cand->flags), cand->bssid); - -#if 0 - struct iw_pmkid_cand pcand; - union iwreq_data wrqu; + netdev_dbg(usbdev->net, "cand[%i]: flags: 0x%08x, preauth: %d, bssid: %pM\n", + i, le32_to_cpu(cand->flags), preauth, cand->bssid); - memset(&pcand, 0, sizeof(pcand)); - if (le32_to_cpu(cand->flags) & 0x01) - pcand.flags |= IW_PMKID_CAND_PREAUTH; - pcand.index = i; - memcpy(pcand.bssid.sa_data, cand->bssid, ETH_ALEN); - - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.length = sizeof(pcand); - wireless_send_event(usbdev->net, IWEVPMKIDCAND, &wrqu, - (u8 *)&pcand); -#endif + cfg80211_pmksa_candidate_notify(usbdev->net, i, cand->bssid, + preauth, GFP_ATOMIC); } } -- cgit v1.2.3 From a7cf534d4ddc961bf74f54a964ad0fd19b389b6e Mon Sep 17 00:00:00 2001 From: Jussi Kivilinna Date: Sat, 19 Nov 2011 13:04:26 +0200 Subject: rndis_wlan: remove unused macro NET_TYPE_11FB actually has never been used. Signed-off-by: Jussi Kivilinna Signed-off-by: John W. Linville --- drivers/net/wireless/rndis_wlan.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index 56514d951ffd..3802c31fefcd 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c @@ -402,8 +402,6 @@ struct ndis_80211_pmkid { /* * private data */ -#define NET_TYPE_11FB 0 - #define CAP_MODE_80211A 1 #define CAP_MODE_80211B 2 #define CAP_MODE_80211G 4 -- cgit v1.2.3 From c3745b40601513a6a6e901c3ec44ddefd0c428d8 Mon Sep 17 00:00:00 2001 From: Christian Lamparter Date: Sat, 19 Nov 2011 19:25:02 +0100 Subject: p54: use ieee80211_free_txskb In the past, it was fine to simply call dev_kfree_skb when it was impossible to transmit a skb. However, with the new tx status API: "mac80211: implement wifi TX status" Every loose skb needs to be handed back to mac80211. Signed-off-by: Christian Lamparter Signed-off-by: John W. Linville --- drivers/net/wireless/p54/txrx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/p54/txrx.c b/drivers/net/wireless/p54/txrx.c index f485784a60ae..5427c27b6cd8 100644 --- a/drivers/net/wireless/p54/txrx.c +++ b/drivers/net/wireless/p54/txrx.c @@ -241,7 +241,7 @@ void p54_free_skb(struct ieee80211_hw *dev, struct sk_buff *skb) skb_unlink(skb, &priv->tx_queue); p54_tx_qos_accounting_free(priv, skb); - dev_kfree_skb_any(skb); + ieee80211_free_txskb(dev, skb); } EXPORT_SYMBOL_GPL(p54_free_skb); @@ -787,7 +787,7 @@ void p54_tx_80211(struct ieee80211_hw *dev, struct sk_buff *skb) &hdr_flags, &aid, &burst_allowed); if (p54_tx_qos_accounting_alloc(priv, skb, queue)) { - dev_kfree_skb_any(skb); + ieee80211_free_txskb(dev, skb); return; } -- cgit v1.2.3 From fd67a728a97c171e54319833adaf8d2641954781 Mon Sep 17 00:00:00 2001 From: Christian Lamparter Date: Sat, 19 Nov 2011 19:30:20 +0100 Subject: carl9170: use ieee80211_free_txskb In the past, it was fine to simply call dev_kfree_skb when it was impossible to transmit a skb. However, with the new tx status API: "mac80211: implement wifi TX status" Every loose skb needs to be handed back to mac80211. Signed-off-by: Christian Lamparter Signed-off-by: John W. Linville --- drivers/net/wireless/ath/carl9170/tx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/carl9170/tx.c b/drivers/net/wireless/ath/carl9170/tx.c index 59472e1605cd..d19a9ee9d057 100644 --- a/drivers/net/wireless/ath/carl9170/tx.c +++ b/drivers/net/wireless/ath/carl9170/tx.c @@ -314,7 +314,7 @@ static void carl9170_tx_release(struct kref *ref) * feedback either [CTL_REQ_TX_STATUS not set] */ - dev_kfree_skb_any(skb); + ieee80211_free_txskb(ar->hw, skb); return; } else { /* @@ -1432,7 +1432,7 @@ void carl9170_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) err_free: ar->tx_dropped++; - dev_kfree_skb_any(skb); + ieee80211_free_txskb(ar->hw, skb); } void carl9170_tx_scheduler(struct ar9170 *ar) -- cgit v1.2.3 From eb1852b10593dc3ca73e02bf9ac4753a5a464905 Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Mon, 21 Nov 2011 16:37:26 -0500 Subject: rtlwifi: squash warning in _usb_read_sync MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit drivers/net/wireless/rtlwifi/usb.c: In function ‘_usb_read_sync’: drivers/net/wireless/rtlwifi/usb.c:102:6: warning: ‘status’ may be used uninitialized in this function drivers/net/wireless/rtlwifi/usb.c:102:6: note: ‘status’ was declared here My compiler is dumb, but better to eliminate the warning than to have anyone waste time evaluating this again... Signed-off-by: John W. Linville Acked-by: Larry Finger --- drivers/net/wireless/rtlwifi/usb.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c index ad109adcabcb..e956fa71d040 100644 --- a/drivers/net/wireless/rtlwifi/usb.c +++ b/drivers/net/wireless/rtlwifi/usb.c @@ -108,7 +108,7 @@ static int _usbctrl_vendorreq_sync_read(struct usb_device *udev, u8 request, pipe = usb_rcvctrlpipe(udev, 0); /* read_in */ reqtype = REALTEK_USB_VENQT_READ; - while (++vendorreq_times <= MAX_USBCTRL_VENDORREQ_TIMES) { + do { status = usb_control_msg(udev, pipe, request, reqtype, value, index, pdata, len, 0); /*max. timeout*/ if (status < 0) { @@ -119,7 +119,8 @@ static int _usbctrl_vendorreq_sync_read(struct usb_device *udev, u8 request, } else { break; } - } + } while (++vendorreq_times < MAX_USBCTRL_VENDORREQ_TIMES); + if (status < 0 && count++ < 4) pr_err("reg 0x%x, usbctrl_vendorreq TimeOut! status:0x%x value=0x%x\n", value, status, le32_to_cpu(*(u32 *)pdata)); -- cgit v1.2.3 From 6cccccafe9e8b88adb1800940ded6ad76c587e1b Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Tue, 22 Nov 2011 16:36:35 -0500 Subject: Revert "rt2x00: handle spurious pci interrupts" This reverts commit 23085d5796561625db4143a671f1de081f66ef08. The original patch was a misguided attempt to improve performance on some hardware that is apparently prone to spurious interrupt generation. Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2400pci.c | 2 +- drivers/net/wireless/rt2x00/rt2500pci.c | 2 +- drivers/net/wireless/rt2x00/rt61pci.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c index 676c7657f5f5..3a6b40239bc1 100644 --- a/drivers/net/wireless/rt2x00/rt2400pci.c +++ b/drivers/net/wireless/rt2x00/rt2400pci.c @@ -1380,7 +1380,7 @@ static irqreturn_t rt2400pci_interrupt(int irq, void *dev_instance) rt2x00pci_register_write(rt2x00dev, CSR7, reg); if (!reg) - return IRQ_HANDLED; + return IRQ_NONE; if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) return IRQ_HANDLED; diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c index d0b627c6c217..dcc0e1fcca77 100644 --- a/drivers/net/wireless/rt2x00/rt2500pci.c +++ b/drivers/net/wireless/rt2x00/rt2500pci.c @@ -1512,7 +1512,7 @@ static irqreturn_t rt2500pci_interrupt(int irq, void *dev_instance) rt2x00pci_register_write(rt2x00dev, CSR7, reg); if (!reg) - return IRQ_HANDLED; + return IRQ_NONE; if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) return IRQ_HANDLED; diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c index 9d83e70f3e62..bf55b4a311e3 100644 --- a/drivers/net/wireless/rt2x00/rt61pci.c +++ b/drivers/net/wireless/rt2x00/rt61pci.c @@ -2337,7 +2337,7 @@ static irqreturn_t rt61pci_interrupt(int irq, void *dev_instance) rt2x00pci_register_write(rt2x00dev, INT_SOURCE_CSR, reg); if (!reg && !reg_mcu) - return IRQ_HANDLED; + return IRQ_NONE; if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) return IRQ_HANDLED; -- cgit v1.2.3 From 82e5fc2a34fa9ffea38f00c4066b7e600a0ca5e6 Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Tue, 22 Nov 2011 16:38:19 -0500 Subject: Revert "rt2800pci: handle spurious interrupts" This reverts commit 4ba7d9997869d25bd223dea7536fc1ce9fab3b3b. The original patch was a misguided attempt to improve performance on some hardware that is apparently prone to spurious interrupt generation. Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800pci.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c index 4dc2d0f840d4..da48c8ac27bd 100644 --- a/drivers/net/wireless/rt2x00/rt2800pci.c +++ b/drivers/net/wireless/rt2x00/rt2800pci.c @@ -880,13 +880,8 @@ static irqreturn_t rt2800pci_interrupt(int irq, void *dev_instance) rt2x00pci_register_read(rt2x00dev, INT_SOURCE_CSR, ®); rt2x00pci_register_write(rt2x00dev, INT_SOURCE_CSR, reg); - /* - * Some devices can generate interrupts with empty CSR register, we - * "handle" such irq's to prevent interrupt controller treat them as - * spurious interrupts and disable irq line. - */ if (!reg) - return IRQ_HANDLED; + return IRQ_NONE; if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) return IRQ_HANDLED; -- cgit v1.2.3 From e55b32c110b025ce07b40227f620e99700bf8741 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 28 Nov 2011 10:33:40 +0100 Subject: rtlwifi: fix lps_lock deadlock rtl_lps_leave can be called from interrupt context, so we have to disable interrupts when taking lps_lock. Below is full lockdep info about deadlock: [ 93.815269] ================================= [ 93.815390] [ INFO: inconsistent lock state ] [ 93.815472] 2.6.41.1-3.offch.fc15.x86_64.debug #1 [ 93.815556] --------------------------------- [ 93.815635] inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage. [ 93.815743] swapper/0 [HC0[0]:SC1[1]:HE1:SE0] takes: [ 93.815832] (&(&rtlpriv->locks.lps_lock)->rlock){+.?...}, at: [] rtl_lps_leave+0x26/0x103 [rtlwifi] [ 93.815947] {SOFTIRQ-ON-W} state was registered at: [ 93.815947] [] __lock_acquire+0x369/0xd0c [ 93.815947] [] lock_acquire+0xf3/0x13e [ 93.815947] [] _raw_spin_lock+0x45/0x79 [ 93.815947] [] rtl_swlps_rf_awake+0x5a/0x76 [rtlwifi] [ 93.815947] [] rtl_op_config+0x12a/0x32a [rtlwifi] [ 93.815947] [] ieee80211_hw_config+0x124/0x129 [mac80211] [ 93.815947] [] ieee80211_dynamic_ps_disable_work+0x32/0x47 [mac80211] [ 93.815947] [] process_one_work+0x205/0x3e7 [ 93.815947] [] worker_thread+0xda/0x15d [ 93.815947] [] kthread+0xa8/0xb0 [ 93.815947] [] kernel_thread_helper+0x4/0x10 [ 93.815947] irq event stamp: 547822 [ 93.815947] hardirqs last enabled at (547822): [] _raw_spin_unlock_irqrestore+0x45/0x61 [ 93.815947] hardirqs last disabled at (547821): [] _raw_spin_lock_irqsave+0x22/0x8e [ 93.815947] softirqs last enabled at (547790): [] _local_bh_enable+0x13/0x15 [ 93.815947] softirqs last disabled at (547791): [] call_softirq+0x1c/0x30 [ 93.815947] [ 93.815947] other info that might help us debug this: [ 93.815947] Possible unsafe locking scenario: [ 93.815947] [ 93.815947] CPU0 [ 93.815947] ---- [ 93.815947] lock(&(&rtlpriv->locks.lps_lock)->rlock); [ 93.815947] [ 93.815947] lock(&(&rtlpriv->locks.lps_lock)->rlock); [ 93.815947] [ 93.815947] *** DEADLOCK *** [ 93.815947] [ 93.815947] no locks held by swapper/0. [ 93.815947] [ 93.815947] stack backtrace: [ 93.815947] Pid: 0, comm: swapper Not tainted 2.6.41.1-3.offch.fc15.x86_64.debug #1 [ 93.815947] Call Trace: [ 93.815947] [] print_usage_bug+0x1e7/0x1f8 [ 93.815947] [] ? save_stack_trace+0x2c/0x49 [ 93.815947] [] ? print_irq_inversion_bug.part.18+0x1a0/0x1a0 [ 93.815947] [] mark_lock+0x106/0x220 [ 93.815947] [] __lock_acquire+0x2f5/0xd0c [ 93.815947] [] ? native_sched_clock+0x34/0x36 [ 93.830125] [] ? sched_clock+0x9/0xd [ 93.830125] [] ? sched_clock_local+0x12/0x75 [ 93.830125] [] ? rtl_lps_leave+0x26/0x103 [rtlwifi] [ 93.830125] [] lock_acquire+0xf3/0x13e [ 93.830125] [] ? rtl_lps_leave+0x26/0x103 [rtlwifi] [ 93.830125] [] _raw_spin_lock+0x45/0x79 [ 93.830125] [] ? rtl_lps_leave+0x26/0x103 [rtlwifi] [ 93.830125] [] ? skb_dequeue+0x62/0x6d [ 93.830125] [] rtl_lps_leave+0x26/0x103 [rtlwifi] [ 93.830125] [] _rtl_pci_ips_leave_tasklet+0xe/0x10 [rtlwifi] [ 93.830125] [] tasklet_action+0x8d/0xee [ 93.830125] [] __do_softirq+0x112/0x25a [ 93.830125] [] call_softirq+0x1c/0x30 [ 93.830125] [] do_softirq+0x4b/0xa1 [ 93.830125] [] irq_exit+0x5d/0xcf [ 93.830125] [] do_IRQ+0x8e/0xa5 [ 93.830125] [] common_interrupt+0x73/0x73 [ 93.830125] [] ? trace_hardirqs_off+0xd/0xf [ 93.830125] [] ? intel_idle+0xe5/0x10c [ 93.830125] [] ? intel_idle+0xe1/0x10c [ 93.830125] [] cpuidle_idle_call+0x11c/0x1fe [ 93.830125] [] cpu_idle+0xab/0x101 [ 93.830125] [] rest_init+0xd7/0xde [ 93.830125] [] ? csum_partial_copy_generic+0x16c/0x16c [ 93.830125] [] start_kernel+0x3dd/0x3ea [ 93.830125] [] x86_64_start_reservations+0xaf/0xb3 [ 93.830125] [] ? early_idt_handlers+0x140/0x140 [ 93.830125] [] x86_64_start_kernel+0x102/0x111 Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=755154 Reported-by: vjain02@students.poly.edu Reported-and-tested-by: Oliver Paukstadt Cc: stable@vger.kernel.org Acked-by: Larry Finger Signed-off-by: Stanislaw Gruszka Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/ps.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rtlwifi/ps.c b/drivers/net/wireless/rtlwifi/ps.c index a693feffbe72..0b04b2e7b597 100644 --- a/drivers/net/wireless/rtlwifi/ps.c +++ b/drivers/net/wireless/rtlwifi/ps.c @@ -394,7 +394,7 @@ void rtl_lps_enter(struct ieee80211_hw *hw) if (mac->link_state != MAC80211_LINKED) return; - spin_lock(&rtlpriv->locks.lps_lock); + spin_lock_irq(&rtlpriv->locks.lps_lock); /* Idle for a while if we connect to AP a while ago. */ if (mac->cnt_after_linked >= 2) { @@ -406,7 +406,7 @@ void rtl_lps_enter(struct ieee80211_hw *hw) } } - spin_unlock(&rtlpriv->locks.lps_lock); + spin_unlock_irq(&rtlpriv->locks.lps_lock); } /*Leave the leisure power save mode.*/ @@ -415,8 +415,9 @@ void rtl_lps_leave(struct ieee80211_hw *hw) struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); + unsigned long flags; - spin_lock(&rtlpriv->locks.lps_lock); + spin_lock_irqsave(&rtlpriv->locks.lps_lock, flags); if (ppsc->fwctrl_lps) { if (ppsc->dot11_psmode != EACTIVE) { @@ -437,7 +438,7 @@ void rtl_lps_leave(struct ieee80211_hw *hw) rtl_lps_set_psmode(hw, EACTIVE); } } - spin_unlock(&rtlpriv->locks.lps_lock); + spin_unlock_irqrestore(&rtlpriv->locks.lps_lock, flags); } /* For sw LPS*/ @@ -538,9 +539,9 @@ void rtl_swlps_rf_awake(struct ieee80211_hw *hw) RT_CLEAR_PS_LEVEL(ppsc, RT_PS_LEVEL_ASPM); } - spin_lock(&rtlpriv->locks.lps_lock); + spin_lock_irq(&rtlpriv->locks.lps_lock); rtl_ps_set_rf_state(hw, ERFON, RF_CHANGE_BY_PS); - spin_unlock(&rtlpriv->locks.lps_lock); + spin_unlock_irq(&rtlpriv->locks.lps_lock); } void rtl_swlps_rfon_wq_callback(void *data) @@ -573,9 +574,9 @@ void rtl_swlps_rf_sleep(struct ieee80211_hw *hw) if (rtlpriv->link_info.busytraffic) return; - spin_lock(&rtlpriv->locks.lps_lock); + spin_lock_irq(&rtlpriv->locks.lps_lock); rtl_ps_set_rf_state(hw, ERFSLEEP, RF_CHANGE_BY_PS); - spin_unlock(&rtlpriv->locks.lps_lock); + spin_unlock_irq(&rtlpriv->locks.lps_lock); if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_ASPM && !RT_IN_PS_LEVEL(ppsc, RT_PS_LEVEL_ASPM)) { -- cgit v1.2.3 From a73228124bed4022d4d4c5663d9679ba2fb99c6c Mon Sep 17 00:00:00 2001 From: "Rafael J. Wysocki" Date: Sat, 26 Nov 2011 23:37:43 +0100 Subject: ath9k: Revert change that broke AR928X on Acer Ferrari One Revert a hunk in drivers/net/wireless/ath/ath9k/hw.c introduced by commit 2577c6e8f2320f1d2f09be122efef5b9118efee4 (ath9k_hw: Add support for AR946/8x chipsets) that caused a nasty regression to appear on my Acer Ferrari One (the box locks up entirely at random times after the wireless has been started without any way to get debug information out of it). Signed-off-by: Rafael J. Wysocki Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/hw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index b479160dc262..7a9c6f7cd7e1 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -1826,7 +1826,8 @@ static void ath9k_set_power_sleep(struct ath_hw *ah, int setChip) } /* Clear Bit 14 of AR_WA after putting chip into Full Sleep mode. */ - REG_WRITE(ah, AR_WA, ah->WARegVal & ~AR_WA_D3_L1_DISABLE); + if (AR_SREV_9300_20_OR_LATER(ah)) + REG_WRITE(ah, AR_WA, ah->WARegVal & ~AR_WA_D3_L1_DISABLE); } /* -- cgit v1.2.3 From 4eb287a4048e4a2cb0400a6d972d97739ec8c799 Mon Sep 17 00:00:00 2001 From: Nikolay Martynov Date: Mon, 21 Nov 2011 17:32:06 -0500 Subject: ath9k: improve ath_tx_aggr_stop to avoid TID stuck in cleanup state When tx agg is being stopped TID is flushed using ath_tx_flush_tid. It is possible that ath_tx_flush_tid completelly flushes TID (if all packets in this TID have already been retried). If this happened ath_tx_aggr_stop would leave TID in cleanup state permanently. Fix this by making ath_tx_flush_tid remove AGGR_ADDBA_COMPLETE and AGGR_CLEANUP flags from TID status if TID is empty. Signed-off-by: Nikolay Martynov Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/xmit.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c index 55d077e7135d..80639e3e4ac9 100644 --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c @@ -179,6 +179,11 @@ static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid) spin_lock_bh(&txq->axq_lock); } + if (tid->baw_head == tid->baw_tail) { + tid->state &= ~AGGR_ADDBA_COMPLETE; + tid->state &= ~AGGR_CLEANUP; + } + spin_unlock_bh(&txq->axq_lock); } @@ -556,15 +561,9 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, spin_unlock_bh(&txq->axq_lock); } - if (tid->state & AGGR_CLEANUP) { + if (tid->state & AGGR_CLEANUP) ath_tx_flush_tid(sc, tid); - if (tid->baw_head == tid->baw_tail) { - tid->state &= ~AGGR_ADDBA_COMPLETE; - tid->state &= ~AGGR_CLEANUP; - } - } - rcu_read_unlock(); if (needreset) { -- cgit v1.2.3 From a261f0e965b7e903873880cec1a70c9cbc776c76 Mon Sep 17 00:00:00 2001 From: Rajkumar Manoharan Date: Tue, 22 Nov 2011 18:52:00 +0530 Subject: ath9k_hw: Fix minimum CTL power for each runtime mode The conformance test limits (CTL) for each regulatory domains (FCC/ETSI/MKK) are programmed for each runtime modes (11B,11G, HT20 and HT40) in EEPROM. The lowest ctledge power value of a particular running mode should not be used while computing ctledge power for a different running mode.(i.e 11G's min ctledge power should not be used while computing ctledge power for HT20). Currently, the code does not handle this properly which would result in incorrect txpowers in certain cases. So reset the twiceMaxEdgePower to the default while computing min ctlegepower for every mode. Cc: David Quan Signed-off-by: Rajkumar Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9003_eeprom.c | 3 ++- drivers/net/wireless/ath/ath9k/eeprom_4k.c | 6 ++---- drivers/net/wireless/ath/ath9k/eeprom_9287.c | 3 ++- drivers/net/wireless/ath/ath9k/eeprom_def.c | 6 ++---- 4 files changed, 8 insertions(+), 10 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c index a93bd63ad23b..4ba6f52943a8 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c @@ -4779,7 +4779,7 @@ static void ar9003_hw_set_power_per_rate_table(struct ath_hw *ah, { struct ath_common *common = ath9k_hw_common(ah); struct ar9300_eeprom *pEepData = &ah->eeprom.ar9300_eep; - u16 twiceMaxEdgePower = MAX_RATE_POWER; + u16 twiceMaxEdgePower; int i; u16 scaledPower = 0, minCtlPower; static const u16 ctlModesFor11a[] = { @@ -4880,6 +4880,7 @@ static void ar9003_hw_set_power_per_rate_table(struct ath_hw *ah, ctlNum = AR9300_NUM_CTLS_5G; } + twiceMaxEdgePower = MAX_RATE_POWER; for (i = 0; (i < ctlNum) && ctlIndex[i]; i++) { ath_dbg(common, ATH_DBG_REGULATORY, "LOOP-Ctlidx %d: cfgCtl 0x%2.2x pCtlMode 0x%2.2x ctlIndex 0x%2.2x chan %d\n", diff --git a/drivers/net/wireless/ath/ath9k/eeprom_4k.c b/drivers/net/wireless/ath/ath9k/eeprom_4k.c index 9a7520f987f0..61fcab0e2d76 100644 --- a/drivers/net/wireless/ath/ath9k/eeprom_4k.c +++ b/drivers/net/wireless/ath/ath9k/eeprom_4k.c @@ -473,7 +473,7 @@ static void ath9k_hw_set_4k_power_per_rate_table(struct ath_hw *ah, int i; u16 twiceMinEdgePower; - u16 twiceMaxEdgePower = MAX_RATE_POWER; + u16 twiceMaxEdgePower; u16 scaledPower = 0, minCtlPower; u16 numCtlModes; const u16 *pCtlMode; @@ -542,9 +542,7 @@ static void ath9k_hw_set_4k_power_per_rate_table(struct ath_hw *ah, else freq = centers.ctl_center; - if (ah->eep_ops->get_eeprom_ver(ah) == 14 && - ah->eep_ops->get_eeprom_rev(ah) <= 2) - twiceMaxEdgePower = MAX_RATE_POWER; + twiceMaxEdgePower = MAX_RATE_POWER; for (i = 0; (i < AR5416_EEP4K_NUM_CTLS) && pEepData->ctlIndex[i]; i++) { diff --git a/drivers/net/wireless/ath/ath9k/eeprom_9287.c b/drivers/net/wireless/ath/ath9k/eeprom_9287.c index 4f5c50a87ce3..0981c073471d 100644 --- a/drivers/net/wireless/ath/ath9k/eeprom_9287.c +++ b/drivers/net/wireless/ath/ath9k/eeprom_9287.c @@ -569,7 +569,7 @@ static void ath9k_hw_set_ar9287_power_per_rate_table(struct ath_hw *ah, #define REDUCE_SCALED_POWER_BY_TWO_CHAIN 6 #define REDUCE_SCALED_POWER_BY_THREE_CHAIN 10 - u16 twiceMaxEdgePower = MAX_RATE_POWER; + u16 twiceMaxEdgePower; int i; struct cal_ctl_data_ar9287 *rep; struct cal_target_power_leg targetPowerOfdm = {0, {0, 0, 0, 0} }, @@ -669,6 +669,7 @@ static void ath9k_hw_set_ar9287_power_per_rate_table(struct ath_hw *ah, else freq = centers.ctl_center; + twiceMaxEdgePower = MAX_RATE_POWER; /* Walk through the CTL indices stored in EEPROM */ for (i = 0; (i < AR9287_NUM_CTLS) && pEepData->ctlIndex[i]; i++) { struct cal_ctl_edges *pRdEdgesPower; diff --git a/drivers/net/wireless/ath/ath9k/eeprom_def.c b/drivers/net/wireless/ath/ath9k/eeprom_def.c index 81e629671679..55a21d39167c 100644 --- a/drivers/net/wireless/ath/ath9k/eeprom_def.c +++ b/drivers/net/wireless/ath/ath9k/eeprom_def.c @@ -1000,7 +1000,7 @@ static void ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah, #define REDUCE_SCALED_POWER_BY_THREE_CHAIN 9 /* 10*log10(3)*2 */ struct ar5416_eeprom_def *pEepData = &ah->eeprom.def; - u16 twiceMaxEdgePower = MAX_RATE_POWER; + u16 twiceMaxEdgePower; int i; struct cal_ctl_data *rep; struct cal_target_power_leg targetPowerOfdm, targetPowerCck = { @@ -1121,9 +1121,7 @@ static void ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah, else freq = centers.ctl_center; - if (ah->eep_ops->get_eeprom_ver(ah) == 14 && - ah->eep_ops->get_eeprom_rev(ah) <= 2) - twiceMaxEdgePower = MAX_RATE_POWER; + twiceMaxEdgePower = MAX_RATE_POWER; for (i = 0; (i < AR5416_NUM_CTLS) && pEepData->ctlIndex[i]; i++) { if ((((cfgCtl & ~CTL_MODE_M) | -- cgit v1.2.3 From e170d180fb0fa13f86fc9f2b257eceb43f4e0859 Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Tue, 22 Nov 2011 20:15:56 +0530 Subject: ath9k_hw: cosmetic change in calibration debug log Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9003_calib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/ar9003_calib.c b/drivers/net/wireless/ath/ath9k/ar9003_calib.c index 12a730dcb500..e5407df10ea0 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c @@ -824,7 +824,7 @@ static void ar9003_hw_tx_iq_cal_post_proc(struct ath_hw *ah, bool is_reusable) chan_info_tab[i] + offset); ath_dbg(common, ATH_DBG_CALIBRATE, - "IQ RES[%d]=0x%x" + "IQ_RES[%d]=0x%x " "IQ_RES[%d]=0x%x\n", idx, iq_res[idx], idx + 1, iq_res[idx + 1]); -- cgit v1.2.3 From 0b45bf74f91e781b74bfadb8bb08ef341b6befd3 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 22 Nov 2011 17:21:36 -0800 Subject: brcm80211: fmac: cleanup receive path using proper skb_queue functions In the receive path there was still code using the next pointer to access all packets in skb_queue. This patch fixes that. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/dhd.h | 11 ++++- .../net/wireless/brcm80211/brcmfmac/dhd_linux.c | 15 +++---- drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 52 +++++++++------------- 3 files changed, 36 insertions(+), 42 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h index 6da519e7578f..7962f645c5b6 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h @@ -699,7 +699,16 @@ extern bool brcmf_c_prec_enq(struct brcmf_pub *drvr, struct pktq *q, /* Receive frame for delivery to OS. Callee disposes of rxp. */ extern void brcmf_rx_frame(struct brcmf_pub *drvr, int ifidx, - struct sk_buff *rxp, int numpkt); + struct sk_buff_head *rxlist); +static inline void brcmf_rx_packet(struct brcmf_pub *drvr, int ifidx, + struct sk_buff *pkt) +{ + struct sk_buff_head q; + + skb_queue_head_init(&q); + skb_queue_tail(&q, pkt); + brcmf_rx_frame(drvr, ifidx, &q); +} /* Return pointer to interface name */ extern char *brcmf_ifname(struct brcmf_pub *drvr, int idx); diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index 719fd9397eb6..97211745fe36 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -397,26 +397,21 @@ static int brcmf_host_event(struct brcmf_info *drvr_priv, int *ifidx, return bcmerror; } -void brcmf_rx_frame(struct brcmf_pub *drvr, int ifidx, struct sk_buff *skb, - int numpkt) +void brcmf_rx_frame(struct brcmf_pub *drvr, int ifidx, + struct sk_buff_head *skb_list) { struct brcmf_info *drvr_priv = drvr->info; unsigned char *eth; uint len; void *data; - struct sk_buff *pnext, *save_pktbuf; - int i; + struct sk_buff *skb, *pnext; struct brcmf_if *ifp; struct brcmf_event_msg event; brcmf_dbg(TRACE, "Enter\n"); - save_pktbuf = skb; - - for (i = 0; skb && i < numpkt; i++, skb = pnext) { - - pnext = skb->next; - skb->next = NULL; + skb_queue_walk_safe(skb_list, skb, pnext) { + skb_unlink(skb, skb_list); /* Get the protocol, maintain skb around eth_type_trans() * The main reason for this hack is for the limitation of diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 22913af26db8..10b9247ec539 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -1120,7 +1120,7 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) u8 *dptr, num = 0; u16 sublen, check; - struct sk_buff *pfirst, *plast, *pnext, *save_pfirst; + struct sk_buff *pfirst, *pnext; int errcode; u8 chan, seq, doff, sfdoff; @@ -1137,7 +1137,7 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) /* If there's a descriptor, generate the packet chain */ if (bus->glomd) { - pfirst = plast = pnext = NULL; + pfirst = pnext = NULL; dlen = (u16) (bus->glomd->len); dptr = bus->glomd->data; if (!dlen || (dlen & 1)) { @@ -1338,10 +1338,14 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) /* Remove superframe header, remember offset */ skb_pull(pfirst, doff); sfdoff = doff; + num = 0; /* Validate all the subframe headers */ - for (num = 0, pnext = pfirst; pnext && !errcode; - num++, pnext = pnext->next) { + skb_queue_walk(&bus->glom, pnext) { + /* leave when invalid subframe is found */ + if (errcode) + break; + dptr = (u8 *) (pnext->data); dlen = (u16) (pnext->len); sublen = get_unaligned_le16(dptr); @@ -1374,6 +1378,8 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) num, doff, sublen, SDPCM_HDRLEN); errcode = -1; } + /* increase the subframe count */ + num++; } if (errcode) { @@ -1394,13 +1400,8 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) } /* Basic SD framing looks ok - process each packet (header) */ - save_pfirst = pfirst; - plast = NULL; - - for (num = 0; pfirst; rxseq++, pfirst = pnext) { - pnext = pfirst->next; - pfirst->next = NULL; + skb_queue_walk_safe(&bus->glom, pfirst, pnext) { dptr = (u8 *) (pfirst->data); sublen = get_unaligned_le16(dptr); chan = SDPCM_PACKET_CHANNEL(&dptr[SDPCM_FRAMETAG_LEN]); @@ -1420,6 +1421,8 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) bus->rx_badseq++; rxseq = seq; } + rxseq++; + #ifdef BCMDBG if (BRCMF_BYTES_ON() && BRCMF_DATA_ON()) { printk(KERN_DEBUG "Rx Subframe Data:\n"); @@ -1432,36 +1435,22 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) skb_pull(pfirst, doff); if (pfirst->len == 0) { + skb_unlink(pfirst, &bus->glom); brcmu_pkt_buf_free_skb(pfirst); - if (plast) - plast->next = pnext; - else - save_pfirst = pnext; - continue; } else if (brcmf_proto_hdrpull(bus->drvr, &ifidx, pfirst) != 0) { brcmf_dbg(ERROR, "rx protocol error\n"); bus->drvr->rx_errors++; + skb_unlink(pfirst, &bus->glom); brcmu_pkt_buf_free_skb(pfirst); - if (plast) - plast->next = pnext; - else - save_pfirst = pnext; - continue; } - /* this packet will go up, link back into - chain and count it */ - pfirst->next = pnext; - plast = pfirst; - num++; - #ifdef BCMDBG if (BRCMF_GLOM_ON()) { brcmf_dbg(GLOM, "subframe %d to stack, %p (%p/%d) nxt/lnk %p/%p\n", - num, pfirst, pfirst->data, + bus->glom.qlen, pfirst, pfirst->data, pfirst->len, pfirst->next, pfirst->prev); print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, @@ -1470,14 +1459,15 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) } #endif /* BCMDBG */ } - if (num) { + /* sent any remaining packets up */ + if (bus->glom.qlen) { up(&bus->sdsem); - brcmf_rx_frame(bus->drvr, ifidx, save_pfirst, num); + brcmf_rx_frame(bus->drvr, ifidx, &bus->glom); down(&bus->sdsem); } bus->rxglomframes++; - bus->rxglompkts += num; + bus->rxglompkts += bus->glom.qlen; } return num; } @@ -2075,7 +2065,7 @@ deliver: /* Unlock during rx call */ up(&bus->sdsem); - brcmf_rx_frame(bus->drvr, ifidx, pkt, 1); + brcmf_rx_packet(bus->drvr, ifidx, pkt); down(&bus->sdsem); } rxcount = maxframes - rxleft; -- cgit v1.2.3 From 3030794fcae9b07d62a9ff7649a413dff0c88e01 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 22 Nov 2011 17:21:37 -0800 Subject: brcm80211: smac: remove skb next pointer usage from the driver In two places the next pointer was used to process a sk_buff chain but it will always get a single sk_buff so this has been removed. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/dma.c | 62 ++++++++++---------------- drivers/net/wireless/brcm80211/brcmsmac/main.c | 2 - 2 files changed, 24 insertions(+), 40 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/dma.c b/drivers/net/wireless/brcm80211/brcmsmac/dma.c index 0bb8c37e979e..b55b1f6bb4ba 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/dma.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/dma.c @@ -1239,10 +1239,9 @@ bool dma_rxreset(struct dma_pub *pub) * the error(toss frames) could be fatal and cause many subsequent hard * to debug problems */ -int dma_txfast(struct dma_pub *pub, struct sk_buff *p0, bool commit) +int dma_txfast(struct dma_pub *pub, struct sk_buff *p, bool commit) { struct dma_info *di = (struct dma_info *)pub; - struct sk_buff *p, *next; unsigned char *data; uint len; u16 txout; @@ -1254,50 +1253,37 @@ int dma_txfast(struct dma_pub *pub, struct sk_buff *p0, bool commit) txout = di->txout; /* - * Walk the chain of packet buffers - * allocating and initializing transmit descriptor entries. + * obtain and initialize transmit descriptor entry. */ - for (p = p0; p; p = next) { - data = p->data; - len = p->len; - next = p->next; - - /* return nonzero if out of tx descriptors */ - if (nexttxd(di, txout) == di->txin) - goto outoftxd; + data = p->data; + len = p->len; - if (len == 0) - continue; - - /* get physical address of buffer start */ - pa = pci_map_single(di->pbus, data, len, PCI_DMA_TODEVICE); + /* no use to transmit a zero length packet */ + if (len == 0) + return 0; - flags = 0; - if (p == p0) - flags |= D64_CTRL1_SOF; + /* return nonzero if out of tx descriptors */ + if (nexttxd(di, txout) == di->txin) + goto outoftxd; - /* With a DMA segment list, Descriptor table is filled - * using the segment list instead of looping over - * buffers in multi-chain DMA. Therefore, EOF for SGLIST - * is when end of segment list is reached. - */ - if (next == NULL) - flags |= (D64_CTRL1_IOC | D64_CTRL1_EOF); - if (txout == (di->ntxd - 1)) - flags |= D64_CTRL1_EOT; + /* get physical address of buffer start */ + pa = pci_map_single(di->pbus, data, len, PCI_DMA_TODEVICE); - dma64_dd_upd(di, di->txd64, pa, txout, &flags, len); + /* With a DMA segment list, Descriptor table is filled + * using the segment list instead of looping over + * buffers in multi-chain DMA. Therefore, EOF for SGLIST + * is when end of segment list is reached. + */ + flags = D64_CTRL1_SOF | D64_CTRL1_IOC | D64_CTRL1_EOF; + if (txout == (di->ntxd - 1)) + flags |= D64_CTRL1_EOT; - txout = nexttxd(di, txout); - } + dma64_dd_upd(di, di->txd64, pa, txout, &flags, len); - /* if last txd eof not set, fix it */ - if (!(flags & D64_CTRL1_EOF)) - di->txd64[prevtxd(di, txout)].ctrl1 = - cpu_to_le32(flags | D64_CTRL1_IOC | D64_CTRL1_EOF); + txout = nexttxd(di, txout); /* save the packet */ - di->txp[prevtxd(di, txout)] = p0; + di->txp[prevtxd(di, txout)] = p; /* bump the tx descriptor index */ di->txout = txout; @@ -1314,7 +1300,7 @@ int dma_txfast(struct dma_pub *pub, struct sk_buff *p0, bool commit) outoftxd: DMA_ERROR("%s: out of txds !!!\n", di->name); - brcmu_pkt_buf_free_skb(p0); + brcmu_pkt_buf_free_skb(p); di->dma.txavail = 0; di->dma.txnobuf++; return -1; diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index 36e3e0638300..897e252bdb57 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -955,8 +955,6 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs) brcms_c_txfifo_complete(wlc, queue, 1); if (lastframe) { - p->next = NULL; - p->prev = NULL; /* remove PLCP & Broadcom tx descriptor header */ skb_pull(p, D11_PHY_HDR_LEN); skb_pull(p, D11_TXH_LEN); -- cgit v1.2.3 From 5adfeb632c52a6c15e98fa6465bdade6fff915d9 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 22 Nov 2011 17:21:38 -0800 Subject: brcm80211: fmac: separate receiving skb chain from other receive path In the receive path the buffer used to store the receive data from the device can be a chain of sk_buff. It has been separated to allow the use of skb queues. Reported-by: Johannes Berg Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c | 116 +++++++++++++++++---- .../net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 97 ++++++++++++----- drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 47 +++------ .../net/wireless/brcm80211/brcmfmac/sdio_host.h | 18 +++- 4 files changed, 201 insertions(+), 77 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c index 89ff94da556a..9c27870a62c6 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c @@ -222,19 +222,12 @@ bool brcmf_sdcard_regfail(struct brcmf_sdio_dev *sdiodev) return sdiodev->regfail; } -int -brcmf_sdcard_recv_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, - uint flags, - u8 *buf, uint nbytes, struct sk_buff *pkt) +static int brcmf_sdcard_recv_prepare(struct brcmf_sdio_dev *sdiodev, uint fn, + uint flags, uint width, u32 *addr) { - int status; - uint incr_fix; - uint width; - uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK; + uint bar0 = *addr & ~SBSDIO_SB_OFT_ADDR_MASK; int err = 0; - brcmf_dbg(INFO, "fun = %d, addr = 0x%x, size = %d\n", fn, addr, nbytes); - /* Async not implemented yet */ if (flags & SDIO_REQ_ASYNC) return -ENOTSUPP; @@ -247,29 +240,114 @@ brcmf_sdcard_recv_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, sdiodev->sbwad = bar0; } - addr &= SBSDIO_SB_OFT_ADDR_MASK; + *addr &= SBSDIO_SB_OFT_ADDR_MASK; + + if (width == 4) + *addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; + + return 0; +} + +int +brcmf_sdcard_recv_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, + uint flags, u8 *buf, uint nbytes) +{ + struct sk_buff *mypkt; + int err; + + mypkt = brcmu_pkt_buf_get_skb(nbytes); + if (!mypkt) { + brcmf_dbg(ERROR, "brcmu_pkt_buf_get_skb failed: len %d\n", + nbytes); + return -EIO; + } + + err = brcmf_sdcard_recv_pkt(sdiodev, addr, fn, flags, mypkt); + if (!err) + memcpy(buf, mypkt->data, nbytes); + + brcmu_pkt_buf_free_skb(mypkt); + return err; +} + +int +brcmf_sdcard_recv_pkt(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, + uint flags, struct sk_buff *pkt) +{ + uint incr_fix; + uint width; + int err = 0; + + brcmf_dbg(INFO, "fun = %d, addr = 0x%x, size = %d\n", + fn, addr, pkt->len); + + width = (flags & SDIO_REQ_4BYTE) ? 4 : 2; + err = brcmf_sdcard_recv_prepare(sdiodev, fn, flags, width, &addr); + if (err) + return err; incr_fix = (flags & SDIO_REQ_FIXED) ? SDIOH_DATA_FIX : SDIOH_DATA_INC; + err = brcmf_sdioh_request_buffer(sdiodev, incr_fix, SDIOH_READ, + fn, addr, width, 0, NULL, pkt); + + return err; +} + +int brcmf_sdcard_recv_chain(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, + uint flags, struct sk_buff_head *pktq) +{ + uint incr_fix; + uint width; + int err = 0; + + brcmf_dbg(INFO, "fun = %d, addr = 0x%x, size = %d\n", + fn, addr, pktq->qlen); + width = (flags & SDIO_REQ_4BYTE) ? 4 : 2; - if (width == 4) - addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; + err = brcmf_sdcard_recv_prepare(sdiodev, fn, flags, width, &addr); + if (err) + return err; - status = brcmf_sdioh_request_buffer(sdiodev, incr_fix, SDIOH_READ, - fn, addr, width, nbytes, buf, pkt); + incr_fix = (flags & SDIO_REQ_FIXED) ? SDIOH_DATA_FIX : SDIOH_DATA_INC; + err = brcmf_sdioh_request_chain(sdiodev, incr_fix, SDIOH_READ, fn, addr, + pktq); - return status; + return err; } int brcmf_sdcard_send_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, - uint flags, u8 *buf, uint nbytes, struct sk_buff *pkt) + uint flags, u8 *buf, uint nbytes) +{ + struct sk_buff *mypkt; + int err; + + mypkt = brcmu_pkt_buf_get_skb(nbytes); + if (!mypkt) { + brcmf_dbg(ERROR, "brcmu_pkt_buf_get_skb failed: len %d\n", + nbytes); + return -EIO; + } + + memcpy(mypkt->data, buf, nbytes); + err = brcmf_sdcard_send_pkt(sdiodev, addr, fn, flags, mypkt); + + brcmu_pkt_buf_free_skb(mypkt); + return err; + +} + +int +brcmf_sdcard_send_pkt(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, + uint flags, struct sk_buff *pkt) { uint incr_fix; uint width; uint bar0 = addr & ~SBSDIO_SB_OFT_ADDR_MASK; int err = 0; - brcmf_dbg(INFO, "fun = %d, addr = 0x%x, size = %d\n", fn, addr, nbytes); + brcmf_dbg(INFO, "fun = %d, addr = 0x%x, size = %d\n", + fn, addr, pkt->len); /* Async not implemented yet */ if (flags & SDIO_REQ_ASYNC) @@ -291,7 +369,7 @@ brcmf_sdcard_send_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; return brcmf_sdioh_request_buffer(sdiodev, incr_fix, SDIOH_WRITE, fn, - addr, width, nbytes, buf, pkt); + addr, width, 0, NULL, pkt); } int brcmf_sdcard_rwdata(struct brcmf_sdio_dev *sdiodev, uint rw, u32 addr, diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c index bbaeb2d5c93a..4e75c191c290 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -204,16 +204,79 @@ int brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, return err_ret; } +/* precondition: host controller is claimed */ +static int +brcmf_sdioh_request_data(struct brcmf_sdio_dev *sdiodev, uint write, bool fifo, + uint func, uint addr, struct sk_buff *pkt, uint pktlen) +{ + int err_ret = 0; + + if ((write) && (!fifo)) { + err_ret = sdio_memcpy_toio(sdiodev->func[func], addr, + ((u8 *) (pkt->data)), pktlen); + } else if (write) { + err_ret = sdio_memcpy_toio(sdiodev->func[func], addr, + ((u8 *) (pkt->data)), pktlen); + } else if (fifo) { + err_ret = sdio_readsb(sdiodev->func[func], + ((u8 *) (pkt->data)), addr, pktlen); + } else { + err_ret = sdio_memcpy_fromio(sdiodev->func[func], + ((u8 *) (pkt->data)), + addr, pktlen); + } + + return err_ret; +} + static int brcmf_sdioh_request_packet(struct brcmf_sdio_dev *sdiodev, uint fix_inc, uint write, uint func, uint addr, struct sk_buff *pkt) +{ + bool fifo = (fix_inc == SDIOH_DATA_FIX); + int err_ret = 0; + uint pkt_len = pkt->len; + + brcmf_dbg(TRACE, "Enter\n"); + + brcmf_pm_resume_wait(sdiodev, &sdiodev->request_packet_wait); + if (brcmf_pm_resume_error(sdiodev)) + return -EIO; + + /* Claim host controller */ + sdio_claim_host(sdiodev->func[func]); + + pkt_len += 3; + pkt_len &= 0xFFFFFFFC; + + err_ret = brcmf_sdioh_request_data(sdiodev, write, fifo, func, + addr, pkt, pkt_len); + if (err_ret) { + brcmf_dbg(ERROR, "%s FAILED %p, addr=0x%05x, pkt_len=%d, ERR=0x%08x\n", + write ? "TX" : "RX", pkt, addr, pkt_len, err_ret); + } else { + brcmf_dbg(TRACE, "%s xfr'd %p, addr=0x%05x, len=%d\n", + write ? "TX" : "RX", pkt, addr, pkt_len); + } + + /* Release host controller */ + sdio_release_host(sdiodev->func[func]); + + brcmf_dbg(TRACE, "Exit\n"); + return err_ret; +} + +int +brcmf_sdioh_request_chain(struct brcmf_sdio_dev *sdiodev, uint fix_inc, + uint write, uint func, uint addr, + struct sk_buff_head *pktq) { bool fifo = (fix_inc == SDIOH_DATA_FIX); u32 SGCount = 0; int err_ret = 0; - struct sk_buff *pnext; + struct sk_buff *pkt; brcmf_dbg(TRACE, "Enter\n"); @@ -223,43 +286,27 @@ brcmf_sdioh_request_packet(struct brcmf_sdio_dev *sdiodev, uint fix_inc, /* Claim host controller */ sdio_claim_host(sdiodev->func[func]); - for (pnext = pkt; pnext; pnext = pnext->next) { - uint pkt_len = pnext->len; + + skb_queue_walk(pktq, pkt) { + uint pkt_len = pkt->len; pkt_len += 3; pkt_len &= 0xFFFFFFFC; - if ((write) && (!fifo)) { - err_ret = sdio_memcpy_toio(sdiodev->func[func], addr, - ((u8 *) (pnext->data)), - pkt_len); - } else if (write) { - err_ret = sdio_memcpy_toio(sdiodev->func[func], addr, - ((u8 *) (pnext->data)), - pkt_len); - } else if (fifo) { - err_ret = sdio_readsb(sdiodev->func[func], - ((u8 *) (pnext->data)), - addr, pkt_len); - } else { - err_ret = sdio_memcpy_fromio(sdiodev->func[func], - ((u8 *) (pnext->data)), - addr, pkt_len); - } - + err_ret = brcmf_sdioh_request_data(sdiodev, write, fifo, func, + addr, pkt, pkt_len); if (err_ret) { brcmf_dbg(ERROR, "%s FAILED %p[%d], addr=0x%05x, pkt_len=%d, ERR=0x%08x\n", - write ? "TX" : "RX", pnext, SGCount, addr, + write ? "TX" : "RX", pkt, SGCount, addr, pkt_len, err_ret); } else { brcmf_dbg(TRACE, "%s xfr'd %p[%d], addr=0x%05x, len=%d\n", - write ? "TX" : "RX", pnext, SGCount, addr, + write ? "TX" : "RX", pkt, SGCount, addr, pkt_len); } - if (!fifo) addr += pkt_len; - SGCount++; + SGCount++; } /* Release host controller */ diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 10b9247ec539..a9b8272d1b17 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -1228,17 +1228,14 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) * packet and and copy into the chain. */ if (usechain) { - errcode = brcmf_sdcard_recv_buf(bus->sdiodev, + errcode = brcmf_sdcard_recv_chain(bus->sdiodev, bus->sdiodev->sbwad, - SDIO_FUNC_2, - F2SYNC, (u8 *) pfirst->data, dlen, - pfirst); + SDIO_FUNC_2, F2SYNC, &bus->glom); } else if (bus->dataptr) { errcode = brcmf_sdcard_recv_buf(bus->sdiodev, bus->sdiodev->sbwad, - SDIO_FUNC_2, - F2SYNC, bus->dataptr, dlen, - NULL); + SDIO_FUNC_2, F2SYNC, + bus->dataptr, dlen); sublen = (u16) brcmf_sdbrcm_glom_from_buf(bus, dlen); if (sublen != dlen) { brcmf_dbg(ERROR, "FAILED TO COPY, dlen %d sublen %d\n", @@ -1560,8 +1557,7 @@ brcmf_sdbrcm_read_control(struct brcmf_bus *bus, u8 *hdr, uint len, uint doff) sdret = brcmf_sdcard_recv_buf(bus->sdiodev, bus->sdiodev->sbwad, SDIO_FUNC_2, - F2SYNC, (bus->rxctl + BRCMF_FIRSTREAD), rdlen, - NULL); + F2SYNC, (bus->rxctl + BRCMF_FIRSTREAD), rdlen); bus->f2rxdata++; /* Control frame failures need retransmission */ @@ -1617,9 +1613,8 @@ brcmf_alloc_pkt_and_read(struct brcmf_bus *bus, u16 rdlen, pkt_align(*pkt, rdlen, BRCMF_SDALIGN); *rxbuf = (u8 *) ((*pkt)->data); /* Read the entire frame */ - sdret = brcmf_sdcard_recv_buf(bus->sdiodev, bus->sdiodev->sbwad, - SDIO_FUNC_2, F2SYNC, - *rxbuf, rdlen, *pkt); + sdret = brcmf_sdcard_recv_pkt(bus->sdiodev, bus->sdiodev->sbwad, + SDIO_FUNC_2, F2SYNC, *pkt); bus->f2rxdata++; if (sdret < 0) { @@ -1847,7 +1842,7 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) /* Read frame header (hardware and software) */ sdret = brcmf_sdcard_recv_buf(bus->sdiodev, bus->sdiodev->sbwad, SDIO_FUNC_2, F2SYNC, bus->rxhdr, - BRCMF_FIRSTREAD, NULL); + BRCMF_FIRSTREAD); bus->f2rxhdrs++; if (sdret < 0) { @@ -1996,9 +1991,8 @@ brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) pkt_align(pkt, rdlen, BRCMF_SDALIGN); /* Read the remaining frame data */ - sdret = brcmf_sdcard_recv_buf(bus->sdiodev, bus->sdiodev->sbwad, - SDIO_FUNC_2, F2SYNC, ((u8 *) (pkt->data)), - rdlen, pkt); + sdret = brcmf_sdcard_recv_pkt(bus->sdiodev, bus->sdiodev->sbwad, + SDIO_FUNC_2, F2SYNC, pkt); bus->f2rxdata++; if (sdret < 0) { @@ -2085,14 +2079,6 @@ deliver: return rxcount; } -static int -brcmf_sdbrcm_send_buf(struct brcmf_bus *bus, u32 addr, uint fn, uint flags, - u8 *buf, uint nbytes, struct sk_buff *pkt) -{ - return brcmf_sdcard_send_buf - (bus->sdiodev, addr, fn, flags, buf, nbytes, pkt); -} - static void brcmf_sdbrcm_wait_for_event(struct brcmf_bus *bus, bool *lockvar) { @@ -2202,9 +2188,8 @@ static int brcmf_sdbrcm_txpkt(struct brcmf_bus *bus, struct sk_buff *pkt, if (len & (ALIGNMENT - 1)) len = roundup(len, ALIGNMENT); - ret = brcmf_sdbrcm_send_buf(bus, bus->sdiodev->sbwad, - SDIO_FUNC_2, F2SYNC, frame, - len, pkt); + ret = brcmf_sdcard_send_pkt(bus->sdiodev, bus->sdiodev->sbwad, + SDIO_FUNC_2, F2SYNC, pkt); bus->f2txdata++; if (ret < 0) { @@ -2467,9 +2452,9 @@ clkwait: (bus->clkstate == CLK_AVAIL)) { int ret, i; - ret = brcmf_sdbrcm_send_buf(bus, bus->sdiodev->sbwad, + ret = brcmf_sdcard_send_buf(bus->sdiodev, bus->sdiodev->sbwad, SDIO_FUNC_2, F2SYNC, (u8 *) bus->ctrl_frame_buf, - (u32) bus->ctrl_frame_len, NULL); + (u32) bus->ctrl_frame_len); if (ret < 0) { /* On failure, abort the command and @@ -2772,8 +2757,8 @@ static int brcmf_tx_frame(struct brcmf_bus *bus, u8 *frame, u16 len) int ret; bus->ctrl_frame_stat = false; - ret = brcmf_sdbrcm_send_buf(bus, bus->sdiodev->sbwad, - SDIO_FUNC_2, F2SYNC, frame, len, NULL); + ret = brcmf_sdcard_send_buf(bus->sdiodev, bus->sdiodev->sbwad, + SDIO_FUNC_2, F2SYNC, frame, len); if (ret < 0) { /* On failure, abort the command and terminate the frame */ diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h index 726fa8981113..85694ac2f420 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h @@ -182,11 +182,21 @@ extern bool brcmf_sdcard_regfail(struct brcmf_sdio_dev *sdiodev); * NOTE: Async operation is not currently supported. */ extern int +brcmf_sdcard_send_pkt(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, + uint flags, struct sk_buff *pkt); +extern int brcmf_sdcard_send_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, - uint flags, u8 *buf, uint nbytes, struct sk_buff *pkt); + uint flags, u8 *buf, uint nbytes); + +extern int +brcmf_sdcard_recv_pkt(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, + uint flags, struct sk_buff *pkt); extern int brcmf_sdcard_recv_buf(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, - uint flags, u8 *buf, uint nbytes, struct sk_buff *pkt); + uint flags, u8 *buf, uint nbytes); +extern int +brcmf_sdcard_recv_chain(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, + uint flags, struct sk_buff_head *pktq); /* Flags bits */ @@ -240,6 +250,10 @@ brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, uint fix_inc, uint rw, uint fnc_num, u32 addr, uint regwidth, u32 buflen, u8 *buffer, struct sk_buff *pkt); +extern int +brcmf_sdioh_request_chain(struct brcmf_sdio_dev *sdiodev, uint fix_inc, + uint write, uint func, uint addr, + struct sk_buff_head *pktq); /* Watchdog timer interface for pm ops */ extern void brcmf_sdio_wdtmr_enable(struct brcmf_sdio_dev *sdiodev, -- cgit v1.2.3 From 5e8e13b94c7ace2ed8b2aed253211290b329eb5c Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 22 Nov 2011 17:21:39 -0800 Subject: brcm80211: fmac: remove width parameter from brcmf_sdioh_request_buffer The function brcmf_sdioh_request_buffer() was requiring a parameter in its prototype that was not used within the function. It has been removed consequently. Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c | 6 +++--- drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 3 +-- drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c index 9c27870a62c6..e8d1c9ebbf16 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c @@ -288,7 +288,7 @@ brcmf_sdcard_recv_pkt(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, incr_fix = (flags & SDIO_REQ_FIXED) ? SDIOH_DATA_FIX : SDIOH_DATA_INC; err = brcmf_sdioh_request_buffer(sdiodev, incr_fix, SDIOH_READ, - fn, addr, width, 0, NULL, pkt); + fn, addr, 0, NULL, pkt); return err; } @@ -369,7 +369,7 @@ brcmf_sdcard_send_pkt(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; return brcmf_sdioh_request_buffer(sdiodev, incr_fix, SDIOH_WRITE, fn, - addr, width, 0, NULL, pkt); + addr, 0, NULL, pkt); } int brcmf_sdcard_rwdata(struct brcmf_sdio_dev *sdiodev, uint rw, u32 addr, @@ -380,7 +380,7 @@ int brcmf_sdcard_rwdata(struct brcmf_sdio_dev *sdiodev, uint rw, u32 addr, return brcmf_sdioh_request_buffer(sdiodev, SDIOH_DATA_INC, (rw ? SDIOH_WRITE : SDIOH_READ), SDIO_FUNC_1, - addr, 4, nbytes, buf, NULL); + addr, nbytes, buf, NULL); } int brcmf_sdcard_abort(struct brcmf_sdio_dev *sdiodev, uint fn) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 4e75c191c290..271765cff4a6 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -333,8 +333,7 @@ brcmf_sdioh_request_chain(struct brcmf_sdio_dev *sdiodev, uint fix_inc, */ int brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, uint fix_inc, uint write, uint func, uint addr, - uint reg_width, uint buflen_u, u8 *buffer, - struct sk_buff *pkt) + uint buflen_u, u8 *buffer, struct sk_buff *pkt) { int Status; struct sk_buff *mypkt = NULL; diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h index 85694ac2f420..74beffc889c1 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h @@ -247,8 +247,7 @@ brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, /* read or write any buffer using cmd53 */ extern int brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, - uint fix_inc, uint rw, uint fnc_num, - u32 addr, uint regwidth, + uint fix_inc, uint rw, uint fnc_num, u32 addr, u32 buflen, u8 *buffer, struct sk_buff *pkt); extern int brcmf_sdioh_request_chain(struct brcmf_sdio_dev *sdiodev, uint fix_inc, -- cgit v1.2.3 From 4c6e869d2ee7ca489b7049c17c9afe7b68bebecc Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 22 Nov 2011 17:21:40 -0800 Subject: brcm80211: fmac: simplify the brcmf_sdioh_request_buffer() function The function is only called with sk_buff parameter being non-zero so the prototype does not need to support passing a char buffer any longer. When the function is called with a NULL sk_buff parameter it returns -EINVAL now. Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c | 31 +++++++++++++++--- .../net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 37 ++++++---------------- .../net/wireless/brcm80211/brcmfmac/sdio_host.h | 2 +- 3 files changed, 36 insertions(+), 34 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c index e8d1c9ebbf16..668eb36d9faa 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c @@ -288,7 +288,7 @@ brcmf_sdcard_recv_pkt(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, incr_fix = (flags & SDIO_REQ_FIXED) ? SDIOH_DATA_FIX : SDIOH_DATA_INC; err = brcmf_sdioh_request_buffer(sdiodev, incr_fix, SDIOH_READ, - fn, addr, 0, NULL, pkt); + fn, addr, pkt); return err; } @@ -369,18 +369,39 @@ brcmf_sdcard_send_pkt(struct brcmf_sdio_dev *sdiodev, u32 addr, uint fn, addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; return brcmf_sdioh_request_buffer(sdiodev, incr_fix, SDIOH_WRITE, fn, - addr, 0, NULL, pkt); + addr, pkt); } int brcmf_sdcard_rwdata(struct brcmf_sdio_dev *sdiodev, uint rw, u32 addr, u8 *buf, uint nbytes) { + struct sk_buff *mypkt; + bool write = rw ? SDIOH_WRITE : SDIOH_READ; + int err; + addr &= SBSDIO_SB_OFT_ADDR_MASK; addr |= SBSDIO_SB_ACCESS_2_4B_FLAG; - return brcmf_sdioh_request_buffer(sdiodev, SDIOH_DATA_INC, - (rw ? SDIOH_WRITE : SDIOH_READ), SDIO_FUNC_1, - addr, nbytes, buf, NULL); + mypkt = brcmu_pkt_buf_get_skb(nbytes); + if (!mypkt) { + brcmf_dbg(ERROR, "brcmu_pkt_buf_get_skb failed: len %d\n", + nbytes); + return -EIO; + } + + /* For a write, copy the buffer data into the packet. */ + if (write) + memcpy(mypkt->data, buf, nbytes); + + err = brcmf_sdioh_request_buffer(sdiodev, SDIOH_DATA_INC, write, + SDIO_FUNC_1, addr, mypkt); + + /* For a read, copy the packet data back to the buffer. */ + if (!err && !write) + memcpy(buf, mypkt->data, nbytes); + + brcmu_pkt_buf_free_skb(mypkt); + return err; } int brcmf_sdcard_abort(struct brcmf_sdio_dev *sdiodev, uint fn) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 271765cff4a6..2263d3cab2c3 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -333,40 +333,21 @@ brcmf_sdioh_request_chain(struct brcmf_sdio_dev *sdiodev, uint fix_inc, */ int brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, uint fix_inc, uint write, uint func, uint addr, - uint buflen_u, u8 *buffer, struct sk_buff *pkt) + struct sk_buff *pkt) { - int Status; + int status; struct sk_buff *mypkt = NULL; brcmf_dbg(TRACE, "Enter\n"); + if (pkt == NULL) + return -EINVAL; + brcmf_pm_resume_wait(sdiodev, &sdiodev->request_buffer_wait); if (brcmf_pm_resume_error(sdiodev)) return -EIO; - /* Case 1: we don't have a packet. */ - if (pkt == NULL) { - brcmf_dbg(DATA, "Creating new %s Packet, len=%d\n", - write ? "TX" : "RX", buflen_u); - mypkt = brcmu_pkt_buf_get_skb(buflen_u); - if (!mypkt) { - brcmf_dbg(ERROR, "brcmu_pkt_buf_get_skb failed: len %d\n", - buflen_u); - return -EIO; - } - /* For a write, copy the buffer data into the packet. */ - if (write) - memcpy(mypkt->data, buffer, buflen_u); - - Status = brcmf_sdioh_request_packet(sdiodev, fix_inc, write, - func, addr, mypkt); - - /* For a read, copy the packet data back to the buffer. */ - if (!write) - memcpy(buffer, mypkt->data, buflen_u); - - brcmu_pkt_buf_free_skb(mypkt); - } else if (((ulong) (pkt->data) & DMA_ALIGN_MASK) != 0) { + if (((ulong) (pkt->data) & DMA_ALIGN_MASK) != 0) { /* * Case 2: We have a packet, but it is unaligned. * In this case, we cannot have a chain (pkt->next == NULL) @@ -384,7 +365,7 @@ int brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, if (write) memcpy(mypkt->data, pkt->data, pkt->len); - Status = brcmf_sdioh_request_packet(sdiodev, fix_inc, write, + status = brcmf_sdioh_request_packet(sdiodev, fix_inc, write, func, addr, mypkt); /* For a read, copy the packet data back to the buffer. */ @@ -396,11 +377,11 @@ int brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, it is aligned. */ brcmf_dbg(DATA, "Aligned %s Packet, direct DMA\n", write ? "Tx" : "Rx"); - Status = brcmf_sdioh_request_packet(sdiodev, fix_inc, write, + status = brcmf_sdioh_request_packet(sdiodev, fix_inc, write, func, addr, pkt); } - return Status; + return status; } /* Read client card reg */ diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h index 74beffc889c1..1e4a0bb260b6 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h @@ -248,7 +248,7 @@ brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, extern int brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, uint fix_inc, uint rw, uint fnc_num, u32 addr, - u32 buflen, u8 *buffer, struct sk_buff *pkt); + struct sk_buff *pkt); extern int brcmf_sdioh_request_chain(struct brcmf_sdio_dev *sdiodev, uint fix_inc, uint write, uint func, uint addr, -- cgit v1.2.3 From 8dd939cade92647a7c87db5ae895a6e120258320 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Tue, 22 Nov 2011 17:21:41 -0800 Subject: brcm80211: fmac: change firmware/nvram name to be more generic The nvram file contains info for firmware which varies with different hardware designs. Use more common firmware/nvram file names instead of those in Linux firmware repository to avoid misunderstanding. Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/bcmchip.h | 25 ---------------------- .../net/wireless/brcm80211/brcmfmac/dhd_linux.c | 2 -- drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 17 ++++++--------- 3 files changed, 7 insertions(+), 37 deletions(-) delete mode 100644 drivers/net/wireless/brcm80211/brcmfmac/bcmchip.h (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmchip.h b/drivers/net/wireless/brcm80211/brcmfmac/bcmchip.h deleted file mode 100644 index cecb5e5f412b..000000000000 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmchip.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2011 Broadcom Corporation - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _bcmchip_h_ -#define _bcmchip_h_ - -/* bcm4329 */ -/* firmware name */ -#define BCM4329_FW_NAME "brcm/bcm4329-fullmac-4.bin" -#define BCM4329_NV_NAME "brcm/bcm4329-fullmac-4.txt" - -#endif /* _bcmchip_h_ */ diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index 97211745fe36..7af14138c5db 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -43,7 +43,6 @@ #include "dhd_proto.h" #include "dhd_dbg.h" #include "wl_cfg80211.h" -#include "bcmchip.h" MODULE_AUTHOR("Broadcom Corporation"); MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN fullmac driver."); @@ -600,7 +599,6 @@ static void brcmf_ethtool_get_drvinfo(struct net_device *ndev, sprintf(info->driver, KBUILD_MODNAME); sprintf(info->version, "%lu", drvr_priv->pub.drv_version); - sprintf(info->fw_version, "%s", BCM4329_FW_NAME); sprintf(info->bus_info, "%s", dev_name(brcmf_bus_get_device(drvr_priv->pub.bus))); } diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index a9b8272d1b17..1f3e3198ebf1 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -91,7 +91,6 @@ struct rte_console { #include "dhd_bus.h" #include "dhd_proto.h" #include "dhd_dbg.h" -#include #define TXQLEN 2048 /* bulk tx queue length */ #define TXHI (TXQLEN - 256) /* turn on flow control above TXHI */ @@ -310,6 +309,11 @@ struct rte_console { /* Flags for SDH calls */ #define F2SYNC (SDIO_REQ_4BYTE | SDIO_REQ_FIXED) +#define BRCMFMAC_FW_NAME "brcm/brcmfmac.bin" +#define BRCMFMAC_NV_NAME "brcm/brcmfmac.txt" +MODULE_FIRMWARE(BRCMFMAC_FW_NAME); +MODULE_FIRMWARE(BRCMFMAC_NV_NAME); + /* * Conversion of 802.1D priority to precedence level */ @@ -562,9 +566,7 @@ struct brcmf_bus { struct semaphore sdsem; - const char *fw_name; const struct firmware *firmware; - const char *nv_name; u32 fw_ptr; }; @@ -3125,9 +3127,6 @@ static int brcmf_sdbrcm_get_image(char *buf, int len, struct brcmf_bus *bus) return len; } -MODULE_FIRMWARE(BCM4329_FW_NAME); -MODULE_FIRMWARE(BCM4329_NV_NAME); - static int brcmf_sdbrcm_download_code_file(struct brcmf_bus *bus) { int offset = 0; @@ -3137,8 +3136,7 @@ static int brcmf_sdbrcm_download_code_file(struct brcmf_bus *bus) brcmf_dbg(INFO, "Enter\n"); - bus->fw_name = BCM4329_FW_NAME; - ret = request_firmware(&bus->firmware, bus->fw_name, + ret = request_firmware(&bus->firmware, BRCMFMAC_FW_NAME, &bus->sdiodev->func[2]->dev); if (ret) { brcmf_dbg(ERROR, "Fail to request firmware %d\n", ret); @@ -3235,8 +3233,7 @@ static int brcmf_sdbrcm_download_nvram(struct brcmf_bus *bus) char *bufp; int ret; - bus->nv_name = BCM4329_NV_NAME; - ret = request_firmware(&bus->firmware, bus->nv_name, + ret = request_firmware(&bus->firmware, BRCMFMAC_NV_NAME, &bus->sdiodev->func[2]->dev); if (ret) { brcmf_dbg(ERROR, "Fail to request nvram %d\n", ret); -- cgit v1.2.3 From 8906c43cb160abc89c3d7e0721cacb8bc54be927 Mon Sep 17 00:00:00 2001 From: Alwin Beukers Date: Tue, 22 Nov 2011 17:21:42 -0800 Subject: brcm80211: smac: fix channel frequency Reviewed-by: Pieter-Paul Giesberts Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c index e17edf7e6833..008aab9c777c 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c @@ -109,7 +109,7 @@ static const struct chan_info_basic chan_info_all[] = { {204, 5020}, {208, 5040}, {212, 5060}, - {216, 50800} + {216, 5080} }; static const u8 ofdm_rate_lookup[] = { -- cgit v1.2.3 From be667669ec01d514b3820f8c74d9336115be6aa7 Mon Sep 17 00:00:00 2001 From: Alwin Beukers Date: Tue, 22 Nov 2011 17:21:43 -0800 Subject: brcm80211: smac: added support for mac80211 filter flags Added support for handling FIF_PROMISC_IN_BSS, FIF_FCSFAIL, FIF_CONTROL, FIF_OTHER_BSS and FIF_PSPOLL. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Alwin Beukers Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- .../net/wireless/brcm80211/brcmsmac/mac80211_if.c | 38 ++++++++---------- drivers/net/wireless/brcm80211/brcmsmac/main.c | 45 +++++++++------------- drivers/net/wireless/brcm80211/brcmsmac/main.h | 6 +-- 3 files changed, 38 insertions(+), 51 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c index ba3e4b5cba71..76376eb112fe 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c @@ -40,10 +40,10 @@ #define MAC_FILTERS (FIF_PROMISC_IN_BSS | \ FIF_ALLMULTI | \ FIF_FCSFAIL | \ - FIF_PLCPFAIL | \ FIF_CONTROL | \ FIF_OTHER_BSS | \ - FIF_BCN_PRBRESP_PROMISC) + FIF_BCN_PRBRESP_PROMISC | \ + FIF_PSPOLL) #define CHAN2GHZ(channel, freqency, chflags) { \ .band = IEEE80211_BAND_2GHZ, \ @@ -373,7 +373,7 @@ static int brcms_ops_config(struct ieee80211_hw *hw, u32 changed) conf->listen_interval); } if (changed & IEEE80211_CONF_CHANGE_MONITOR) - wiphy_err(wiphy, "%s: change monitor mode: %s (implement)\n", + wiphy_dbg(wiphy, "%s: change monitor mode: %s\n", __func__, conf->flags & IEEE80211_CONF_MONITOR ? "true" : "false"); if (changed & IEEE80211_CONF_CHANGE_PS) @@ -550,29 +550,25 @@ brcms_ops_configure_filter(struct ieee80211_hw *hw, changed_flags &= MAC_FILTERS; *total_flags &= MAC_FILTERS; + if (changed_flags & FIF_PROMISC_IN_BSS) - wiphy_err(wiphy, "FIF_PROMISC_IN_BSS\n"); + wiphy_dbg(wiphy, "FIF_PROMISC_IN_BSS\n"); if (changed_flags & FIF_ALLMULTI) - wiphy_err(wiphy, "FIF_ALLMULTI\n"); + wiphy_dbg(wiphy, "FIF_ALLMULTI\n"); if (changed_flags & FIF_FCSFAIL) - wiphy_err(wiphy, "FIF_FCSFAIL\n"); - if (changed_flags & FIF_PLCPFAIL) - wiphy_err(wiphy, "FIF_PLCPFAIL\n"); + wiphy_dbg(wiphy, "FIF_FCSFAIL\n"); if (changed_flags & FIF_CONTROL) - wiphy_err(wiphy, "FIF_CONTROL\n"); + wiphy_dbg(wiphy, "FIF_CONTROL\n"); if (changed_flags & FIF_OTHER_BSS) - wiphy_err(wiphy, "FIF_OTHER_BSS\n"); - if (changed_flags & FIF_BCN_PRBRESP_PROMISC) { - spin_lock_bh(&wl->lock); - if (*total_flags & FIF_BCN_PRBRESP_PROMISC) { - wl->pub->mac80211_state |= MAC80211_PROMISC_BCNS; - brcms_c_mac_bcn_promisc_change(wl->wlc, 1); - } else { - brcms_c_mac_bcn_promisc_change(wl->wlc, 0); - wl->pub->mac80211_state &= ~MAC80211_PROMISC_BCNS; - } - spin_unlock_bh(&wl->lock); - } + wiphy_dbg(wiphy, "FIF_OTHER_BSS\n"); + if (changed_flags & FIF_PSPOLL) + wiphy_dbg(wiphy, "FIF_PSPOLL\n"); + if (changed_flags & FIF_BCN_PRBRESP_PROMISC) + wiphy_dbg(wiphy, "FIF_BCN_PRBRESP_PROMISC\n"); + + spin_lock_bh(&wl->lock); + brcms_c_mac_promisc(wl->wlc, *total_flags); + spin_unlock_bh(&wl->lock); return; } diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index 897e252bdb57..87f8f5d3d91f 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -3062,7 +3062,7 @@ static bool brcms_c_ps_allowed(struct brcms_c_info *wlc) return false; /* disallow PS when one of these meets when not scanning */ - if (wlc->monitor) + if (wlc->filter_flags & FIF_PROMISC_IN_BSS) return false; if (cfg->associated) { @@ -3582,29 +3582,31 @@ static void brcms_c_bandinit_ordered(struct brcms_c_info *wlc, } /* - * Set or clear maccontrol bits MCTL_PROMISC, MCTL_BCNS_PROMISC and - * MCTL_KEEPCONTROL + * Set or clear filtering related maccontrol bits based on + * specified filter flags */ -static void brcms_c_mac_promisc(struct brcms_c_info *wlc) +void brcms_c_mac_promisc(struct brcms_c_info *wlc, uint filter_flags) { u32 promisc_bits = 0; - if (wlc->bcnmisc_monitor) + wlc->filter_flags = filter_flags; + + if (filter_flags & (FIF_PROMISC_IN_BSS | FIF_OTHER_BSS)) + promisc_bits |= MCTL_PROMISC; + + if (filter_flags & FIF_BCN_PRBRESP_PROMISC) promisc_bits |= MCTL_BCNS_PROMISC; - if (wlc->monitor) - promisc_bits |= - MCTL_PROMISC | MCTL_BCNS_PROMISC | MCTL_KEEPCONTROL; + if (filter_flags & FIF_FCSFAIL) + promisc_bits |= MCTL_KEEPBADFCS; - brcms_b_mctrl(wlc->hw, - MCTL_PROMISC | MCTL_BCNS_PROMISC | MCTL_KEEPCONTROL, - promisc_bits); -} + if (filter_flags & (FIF_CONTROL | FIF_PSPOLL)) + promisc_bits |= MCTL_KEEPCONTROL; -void brcms_c_mac_bcn_promisc_change(struct brcms_c_info *wlc, bool promisc) -{ - wlc->bcnmisc_monitor = promisc; - brcms_c_mac_promisc(wlc); + brcms_b_mctrl(wlc->hw, + MCTL_PROMISC | MCTL_BCNS_PROMISC | + MCTL_KEEPCONTROL | MCTL_KEEPBADFCS, + promisc_bits); } /* @@ -3634,9 +3636,6 @@ static void brcms_c_ucode_mac_upd(struct brcms_c_info *wlc) } else { /* disable an active IBSS if we are not on the home channel */ } - - /* update the various promisc bits */ - brcms_c_mac_promisc(wlc); } static void brcms_c_write_rate_shm(struct brcms_c_info *wlc, u8 rate, @@ -8072,14 +8071,8 @@ static void brcms_c_recv(struct brcms_c_info *wlc, struct sk_buff *p) len = p->len; if (rxh->RxStatus1 & RXS_FCSERR) { - if (wlc->pub->mac80211_state & MAC80211_PROMISC_BCNS) { - wiphy_err(wlc->wiphy, "FCSERR while scanning******* -" - " tossing\n"); + if (!(wlc->filter_flags & FIF_FCSFAIL)) goto toss; - } else { - wiphy_err(wlc->wiphy, "RCSERR!!!\n"); - goto toss; - } } /* check received pkt has at least frame control field */ diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.h b/drivers/net/wireless/brcm80211/brcmsmac/main.h index 251c350b3164..e2de97d93635 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h @@ -519,8 +519,7 @@ struct brcms_c_info { struct brcms_timer *radio_timer; /* promiscuous */ - bool monitor; - bool bcnmisc_monitor; + uint filter_flags; /* driver feature */ bool _rifs; @@ -658,8 +657,7 @@ extern void brcms_c_print_txdesc(struct d11txh *txh); #endif extern int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config); -extern void brcms_c_mac_bcn_promisc_change(struct brcms_c_info *wlc, - bool promisc); +extern void brcms_c_mac_promisc(struct brcms_c_info *wlc, uint filter_flags); extern void brcms_c_send_q(struct brcms_c_info *wlc); extern int brcms_c_prep_pdu(struct brcms_c_info *wlc, struct sk_buff *pdu, uint *fifo); -- cgit v1.2.3 From 8054321b7cb8c685f21762268b20dc590dab2a8d Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 22 Nov 2011 17:21:44 -0800 Subject: brcm80211: fmac: remove alignment check from brcmf_sdioh_request_buffer() The check for alignment is not valid anymore and can be removed. The function is collapsed with brcmf_sdioh_request_packet() as a consequence because it did not add much functionality any longer. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- .../net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 100 ++++----------------- 1 file changed, 18 insertions(+), 82 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 2263d3cab2c3..ccb32c01d527 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -229,44 +229,6 @@ brcmf_sdioh_request_data(struct brcmf_sdio_dev *sdiodev, uint write, bool fifo, return err_ret; } -static int -brcmf_sdioh_request_packet(struct brcmf_sdio_dev *sdiodev, uint fix_inc, - uint write, uint func, uint addr, - struct sk_buff *pkt) -{ - bool fifo = (fix_inc == SDIOH_DATA_FIX); - int err_ret = 0; - uint pkt_len = pkt->len; - - brcmf_dbg(TRACE, "Enter\n"); - - brcmf_pm_resume_wait(sdiodev, &sdiodev->request_packet_wait); - if (brcmf_pm_resume_error(sdiodev)) - return -EIO; - - /* Claim host controller */ - sdio_claim_host(sdiodev->func[func]); - - pkt_len += 3; - pkt_len &= 0xFFFFFFFC; - - err_ret = brcmf_sdioh_request_data(sdiodev, write, fifo, func, - addr, pkt, pkt_len); - if (err_ret) { - brcmf_dbg(ERROR, "%s FAILED %p, addr=0x%05x, pkt_len=%d, ERR=0x%08x\n", - write ? "TX" : "RX", pkt, addr, pkt_len, err_ret); - } else { - brcmf_dbg(TRACE, "%s xfr'd %p, addr=0x%05x, len=%d\n", - write ? "TX" : "RX", pkt, addr, pkt_len); - } - - /* Release host controller */ - sdio_release_host(sdiodev->func[func]); - - brcmf_dbg(TRACE, "Exit\n"); - return err_ret; -} - int brcmf_sdioh_request_chain(struct brcmf_sdio_dev *sdiodev, uint fix_inc, uint write, uint func, uint addr, @@ -317,26 +279,15 @@ brcmf_sdioh_request_chain(struct brcmf_sdio_dev *sdiodev, uint fix_inc, } /* - * This function takes a buffer or packet, and fixes everything up - * so that in the end, a DMA-able packet is created. - * - * A buffer does not have an associated packet pointer, - * and may or may not be aligned. - * A packet may consist of a single packet, or a packet chain. - * If it is a packet chain, then all the packets in the chain - * must be properly aligned. - * - * If the packet data is not aligned, then there may only be - * one packet, and in this case, it is copied to a new - * aligned packet. - * + * This function takes a single DMA-able packet. */ int brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, uint fix_inc, uint write, uint func, uint addr, struct sk_buff *pkt) { int status; - struct sk_buff *mypkt = NULL; + uint pkt_len = pkt->len; + bool fifo = (fix_inc == SDIOH_DATA_FIX); brcmf_dbg(TRACE, "Enter\n"); @@ -347,40 +298,25 @@ int brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, if (brcmf_pm_resume_error(sdiodev)) return -EIO; - if (((ulong) (pkt->data) & DMA_ALIGN_MASK) != 0) { - /* - * Case 2: We have a packet, but it is unaligned. - * In this case, we cannot have a chain (pkt->next == NULL) - */ - brcmf_dbg(DATA, "Creating aligned %s Packet, len=%d\n", - write ? "TX" : "RX", pkt->len); - mypkt = brcmu_pkt_buf_get_skb(pkt->len); - if (!mypkt) { - brcmf_dbg(ERROR, "brcmu_pkt_buf_get_skb failed: len %d\n", - pkt->len); - return -EIO; - } - - /* For a write, copy the buffer data into the packet. */ - if (write) - memcpy(mypkt->data, pkt->data, pkt->len); - - status = brcmf_sdioh_request_packet(sdiodev, fix_inc, write, - func, addr, mypkt); + /* Claim host controller */ + sdio_claim_host(sdiodev->func[func]); - /* For a read, copy the packet data back to the buffer. */ - if (!write) - memcpy(pkt->data, mypkt->data, mypkt->len); + pkt_len += 3; + pkt_len &= (uint)~3; - brcmu_pkt_buf_free_skb(mypkt); - } else { /* case 3: We have a packet and - it is aligned. */ - brcmf_dbg(DATA, "Aligned %s Packet, direct DMA\n", - write ? "Tx" : "Rx"); - status = brcmf_sdioh_request_packet(sdiodev, fix_inc, write, - func, addr, pkt); + status = brcmf_sdioh_request_data(sdiodev, write, fifo, func, + addr, pkt, pkt_len); + if (status) { + brcmf_dbg(ERROR, "%s FAILED %p, addr=0x%05x, pkt_len=%d, ERR=0x%08x\n", + write ? "TX" : "RX", pkt, addr, pkt_len, status); + } else { + brcmf_dbg(TRACE, "%s xfr'd %p, addr=0x%05x, len=%d\n", + write ? "TX" : "RX", pkt, addr, pkt_len); } + /* Release host controller */ + sdio_release_host(sdiodev->func[func]); + return status; } -- cgit v1.2.3 From a52dd17d20be1fb6a111468f3ca8bfa0af7c0903 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Tue, 22 Nov 2011 17:21:45 -0800 Subject: brcm80211: fmac: rename wait queue name to match using function The wait queue request_packet_wait was used in request_chain function and for sake of consistency it has been renamed to request_chain_wait. Reviewed-by: Franky (Zhenhui) Lin Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 8 ++++++-- drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c index ccb32c01d527..adee3057d330 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -229,6 +229,10 @@ brcmf_sdioh_request_data(struct brcmf_sdio_dev *sdiodev, uint write, bool fifo, return err_ret; } +/* + * This function takes a queue of packets. The packets on the queue + * are assumed to be properly aligned by the caller. + */ int brcmf_sdioh_request_chain(struct brcmf_sdio_dev *sdiodev, uint fix_inc, uint write, uint func, uint addr, @@ -242,7 +246,7 @@ brcmf_sdioh_request_chain(struct brcmf_sdio_dev *sdiodev, uint fix_inc, brcmf_dbg(TRACE, "Enter\n"); - brcmf_pm_resume_wait(sdiodev, &sdiodev->request_packet_wait); + brcmf_pm_resume_wait(sdiodev, &sdiodev->request_chain_wait); if (brcmf_pm_resume_error(sdiodev)) return -EIO; @@ -478,7 +482,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, atomic_set(&sdiodev->suspend, false); init_waitqueue_head(&sdiodev->request_byte_wait); init_waitqueue_head(&sdiodev->request_word_wait); - init_waitqueue_head(&sdiodev->request_packet_wait); + init_waitqueue_head(&sdiodev->request_chain_wait); init_waitqueue_head(&sdiodev->request_buffer_wait); } diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h index 1e4a0bb260b6..4e501f8a00f2 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h @@ -132,7 +132,7 @@ struct brcmf_sdio_dev { atomic_t suspend; /* suspend flag */ wait_queue_head_t request_byte_wait; wait_queue_head_t request_word_wait; - wait_queue_head_t request_packet_wait; + wait_queue_head_t request_chain_wait; wait_queue_head_t request_buffer_wait; }; -- cgit v1.2.3 From 0c094c77ce9c338adc08d6d71b2d92a7761992b8 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Tue, 22 Nov 2011 17:21:46 -0800 Subject: brcm80211: fmac: discard packet received when net device not registered A new feature in the dongle firmware requires a handshake during firmware intialization. The request is sent in event packets which the host driver is not able to handle before any net device registered. Discard those packets as the context for handling it is missing. The initialization handler will be added as part of feature support code in the future. Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index 7af14138c5db..62413e861784 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -431,6 +431,12 @@ void brcmf_rx_frame(struct brcmf_pub *drvr, int ifidx, if (ifp == NULL) ifp = drvr_priv->iflist[0]; + if (!ifp || !ifp->ndev || + ifp->ndev->reg_state != NETREG_REGISTERED) { + brcmu_pkt_buf_free_skb(skb); + continue; + } + skb->dev = ifp->ndev; skb->protocol = eth_type_trans(skb, skb->dev); -- cgit v1.2.3 From 3392c888bbe6fb939dea952ea90bea4dc969c234 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Tue, 22 Nov 2011 17:21:47 -0800 Subject: brcm80211: fmac: move module init/exit to sdio layer This patch is part of the fullmac bus interface refactoring series. It moves the module init/exit code to bus layer. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- .../net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 19 +++++++++++---- drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h | 4 ---- .../net/wireless/brcm80211/brcmfmac/dhd_linux.c | 28 ---------------------- 3 files changed, 14 insertions(+), 37 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c index adee3057d330..7a2325b2a564 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -577,17 +577,26 @@ static struct sdio_driver brcmf_sdmmc_driver = { #endif /* CONFIG_PM_SLEEP */ }; -/* bus register interface */ -int brcmf_bus_register(void) +static void __exit brcmf_sdio_exit(void) { brcmf_dbg(TRACE, "Enter\n"); - return sdio_register_driver(&brcmf_sdmmc_driver); + sdio_unregister_driver(&brcmf_sdmmc_driver); } -void brcmf_bus_unregister(void) +static int __init brcmf_sdio_init(void) { + int ret; + brcmf_dbg(TRACE, "Enter\n"); - sdio_unregister_driver(&brcmf_sdmmc_driver); + ret = sdio_register_driver(&brcmf_sdmmc_driver); + + if (ret) + brcmf_dbg(ERROR, "sdio_register_driver failed: %d\n", ret); + + return ret; } + +module_init(brcmf_sdio_init); +module_exit(brcmf_sdio_exit); diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h index a249407c9a1b..118216b1ee29 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h @@ -27,10 +27,6 @@ * Exported from brcmf bus module (brcmf_usb, brcmf_sdio) */ -/* Indicate (dis)interest in finding dongles. */ -extern int brcmf_bus_register(void); -extern void brcmf_bus_unregister(void); - /* obtain linux device object providing bus function */ extern struct device *brcmf_bus_get_device(struct brcmf_bus *bus); diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index 62413e861784..73d328027e19 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -1147,34 +1147,6 @@ void brcmf_detach(struct brcmf_pub *drvr) } } -static void __exit brcmf_module_cleanup(void) -{ - brcmf_dbg(TRACE, "Enter\n"); - - brcmf_bus_unregister(); -} - -static int __init brcmf_module_init(void) -{ - int error; - - brcmf_dbg(TRACE, "Enter\n"); - - error = brcmf_bus_register(); - - if (error) { - brcmf_dbg(ERROR, "brcmf_bus_register failed\n"); - goto failed; - } - return 0; - -failed: - return -EINVAL; -} - -module_init(brcmf_module_init); -module_exit(brcmf_module_cleanup); - int brcmf_os_proto_block(struct brcmf_pub *drvr) { struct brcmf_info *drvr_priv = drvr->info; -- cgit v1.2.3 From 4f96bf1910491e3d8e41915239080422e9810662 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Tue, 22 Nov 2011 17:21:48 -0800 Subject: brcm80211: fmac: remove function brcmf_c_init brcmf_c_init only init brcmf_msg_level used for debug. It's no longer needed as brcmf_msg_level doesn't cause trouble to multiple instances. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/dhd.h | 2 -- drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c | 15 --------------- drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c | 1 + drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 10 ---------- 4 files changed, 1 insertion(+), 27 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h index 7962f645c5b6..046a9e4fd42b 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h @@ -733,8 +733,6 @@ extern int brcmf_c_host_event(struct brcmf_info *drvr_priv, int *idx, void *pktdata, struct brcmf_event_msg *, void **data_ptr); -extern void brcmf_c_init(void); - extern int brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, char *name, u8 *mac_addr); extern void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx); diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c index 40928e58b6a6..69f335aeb255 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_common.c @@ -32,8 +32,6 @@ #define PKTFILTER_BUF_SIZE 2048 #define BRCMF_ARPOL_MODE 0xb /* agent|snoop|peer_autoreply */ -int brcmf_msg_level; - #define MSGTRACE_VERSION 1 #define BRCMF_PKT_FILTER_FIXED_LEN offsetof(struct brcmf_pkt_filter_le, u) @@ -85,19 +83,6 @@ brcmf_c_mkiovar(char *name, char *data, uint datalen, char *buf, uint buflen) return len; } -void brcmf_c_init(void) -{ - /* Init global variables at run-time, not as part of the declaration. - * This is required to support init/de-init of the driver. - * Initialization - * of globals as part of the declaration results in non-deterministic - * behaviour since the value of the globals may be different on the - * first time that the driver is initialized vs subsequent - * initializations. - */ - brcmf_msg_level = BRCMF_ERROR_VAL; -} - bool brcmf_c_prec_enq(struct brcmf_pub *drvr, struct pktq *q, struct sk_buff *pkt, int prec) { diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index 73d328027e19..683a7ed25714 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -76,6 +76,7 @@ struct brcmf_info { }; /* Error bits */ +int brcmf_msg_level = BRCMF_ERROR_VAL; module_param(brcmf_msg_level, int, 0); int brcmf_ifname2idx(struct brcmf_info *drvr_priv, char *name) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 1f3e3198ebf1..8acd1bb94809 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -3867,16 +3867,6 @@ void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, int ret; struct brcmf_bus *bus; - /* Init global variables at run-time, not as part of the declaration. - * This is required to support init/de-init of the driver. - * Initialization - * of globals as part of the declaration results in non-deterministic - * behavior since the value of the globals may be different on the - * first time that the driver is initialized vs subsequent - * initializations. - */ - brcmf_c_init(); - brcmf_dbg(TRACE, "Enter\n"); /* We make an assumption about address window mappings: -- cgit v1.2.3 From 4175b88bd22022a60de175f94fdb303bed087eb9 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Tue, 22 Nov 2011 17:21:49 -0800 Subject: brcm80211: fmac: remove unused parameter of brcmf_sdbrcm_probe bus_no, slot, func and bustype are no longer needed by brcmf_sdbrcm_probe. This patch removes them. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c | 2 +- drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 3 +-- drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c index 668eb36d9faa..6c85d668c9d7 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c @@ -432,7 +432,7 @@ int brcmf_sdio_probe(struct brcmf_sdio_dev *sdiodev) sdiodev->sbwad = SI_ENUM_BASE; /* try to attach to the target device */ - sdiodev->bus = brcmf_sdbrcm_probe(0, 0, 0, 0, regs, sdiodev); + sdiodev->bus = brcmf_sdbrcm_probe(regs, sdiodev); if (!sdiodev->bus) { brcmf_dbg(ERROR, "device attach failed\n"); ret = -ENODEV; diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 8acd1bb94809..f01da6a5b040 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -3861,8 +3861,7 @@ static void brcmf_sdbrcm_release(struct brcmf_bus *bus) brcmf_dbg(TRACE, "Disconnected\n"); } -void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, - u32 regsva, struct brcmf_sdio_dev *sdiodev) +void *brcmf_sdbrcm_probe(u32 regsva, struct brcmf_sdio_dev *sdiodev) { int ret; struct brcmf_bus *bus; diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h index 4e501f8a00f2..0618f5ed1acb 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h @@ -258,8 +258,7 @@ brcmf_sdioh_request_chain(struct brcmf_sdio_dev *sdiodev, uint fix_inc, extern void brcmf_sdio_wdtmr_enable(struct brcmf_sdio_dev *sdiodev, bool enable); -extern void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, - u32 regsva, struct brcmf_sdio_dev *sdiodev); +extern void *brcmf_sdbrcm_probe(u32 regsva, struct brcmf_sdio_dev *sdiodev); extern void brcmf_sdbrcm_disconnect(void *ptr); extern void brcmf_sdbrcm_isr(void *arg); #endif /* _BRCM_SDH_H_ */ -- cgit v1.2.3 From e92eedf4e080fc0bd98e892cb9d31d2163ae8b29 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Tue, 22 Nov 2011 17:21:50 -0800 Subject: brcm80211: fmac: rename structure brcmf_bus to brcmf_sdio Rename sdio bus structure brcmf_bus to brcmf_sdio for preparation of USB bus support. This patch is part of the fullmac bus interface refactoring. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/dhd.h | 6 +- drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h | 12 +-- .../net/wireless/brcm80211/brcmfmac/dhd_linux.c | 2 +- drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 120 ++++++++++----------- 4 files changed, 70 insertions(+), 70 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h index 046a9e4fd42b..451b34ba3984 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h @@ -572,7 +572,7 @@ struct brcmf_dcmd { }; /* Forward decls for struct brcmf_pub (see below) */ -struct brcmf_bus; /* device bus info */ +struct brcmf_sdio; /* device bus info */ struct brcmf_proto; /* device communication protocol info */ struct brcmf_info; /* device driver info */ struct brcmf_cfg80211_dev; /* cfg80211 device info */ @@ -580,7 +580,7 @@ struct brcmf_cfg80211_dev; /* cfg80211 device info */ /* Common structure for module and instance linkage */ struct brcmf_pub { /* Linkage ponters */ - struct brcmf_bus *bus; + struct brcmf_sdio *bus; struct brcmf_proto *prot; struct brcmf_info *info; struct brcmf_cfg80211_dev *config; @@ -681,7 +681,7 @@ extern uint brcmf_c_mkiovar(char *name, char *data, uint datalen, * Returned structure should have bus and prot pointers filled in. * bus_hdrlen specifies required headroom for bus module header. */ -extern struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, +extern struct brcmf_pub *brcmf_attach(struct brcmf_sdio *bus, uint bus_hdrlen); extern int brcmf_net_attach(struct brcmf_pub *drvr, int idx); extern int brcmf_netdev_wait_pend8021x(struct net_device *ndev); diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h index 118216b1ee29..81fc1dbccc55 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h @@ -28,26 +28,26 @@ */ /* obtain linux device object providing bus function */ -extern struct device *brcmf_bus_get_device(struct brcmf_bus *bus); +extern struct device *brcmf_bus_get_device(struct brcmf_sdio *bus); /* Stop bus module: clear pending frames, disable data flow */ -extern void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus); +extern void brcmf_sdbrcm_bus_stop(struct brcmf_sdio *bus); /* Initialize bus module: prepare for communication w/dongle */ extern int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr); /* Send a data frame to the dongle. Callee disposes of txp. */ -extern int brcmf_sdbrcm_bus_txdata(struct brcmf_bus *bus, struct sk_buff *txp); +extern int brcmf_sdbrcm_bus_txdata(struct brcmf_sdio *bus, struct sk_buff *txp); /* Send/receive a control message to/from the dongle. * Expects caller to enforce a single outstanding transaction. */ extern int -brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen); +brcmf_sdbrcm_bus_txctl(struct brcmf_sdio *bus, unsigned char *msg, uint msglen); extern int -brcmf_sdbrcm_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen); +brcmf_sdbrcm_bus_rxctl(struct brcmf_sdio *bus, unsigned char *msg, uint msglen); -extern void brcmf_sdbrcm_wd_timer(struct brcmf_bus *bus, uint wdtick); +extern void brcmf_sdbrcm_wd_timer(struct brcmf_sdio *bus, uint wdtick); #endif /* _BRCMF_BUS_H_ */ diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index 683a7ed25714..e8f7f78f52cc 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -940,7 +940,7 @@ void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx) } } -struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen) +struct brcmf_pub *brcmf_attach(struct brcmf_sdio *bus, uint bus_hdrlen) { struct brcmf_info *drvr_priv = NULL; diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index f01da6a5b040..9ab906a91c48 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -449,7 +449,7 @@ struct sdpcm_shared_le { /* misc chip info needed by some of the routines */ /* Private data for SDIO bus interaction */ -struct brcmf_bus { +struct brcmf_sdio { struct brcmf_pub *drvr; struct brcmf_sdio_dev *sdiodev; /* sdio device handler */ @@ -604,7 +604,7 @@ static void pkt_align(struct sk_buff *p, int len, int align) } /* To check if there's window offered */ -static bool data_ok(struct brcmf_bus *bus) +static bool data_ok(struct brcmf_sdio *bus) { return (u8)(bus->tx_max - bus->tx_seq) != 0 && ((u8)(bus->tx_max - bus->tx_seq) & 0x80) == 0; @@ -615,7 +615,7 @@ static bool data_ok(struct brcmf_bus *bus) * adresses on the 32 bit backplane bus. */ static void -r_sdreg32(struct brcmf_bus *bus, u32 *regvar, u32 reg_offset, u32 *retryvar) +r_sdreg32(struct brcmf_sdio *bus, u32 *regvar, u32 reg_offset, u32 *retryvar) { u8 idx = brcmf_sdio_chip_getinfidx(bus->ci, BCMA_CORE_SDIO_DEV); *retryvar = 0; @@ -635,7 +635,7 @@ r_sdreg32(struct brcmf_bus *bus, u32 *regvar, u32 reg_offset, u32 *retryvar) } static void -w_sdreg32(struct brcmf_bus *bus, u32 regval, u32 reg_offset, u32 *retryvar) +w_sdreg32(struct brcmf_sdio *bus, u32 regval, u32 reg_offset, u32 *retryvar) { u8 idx = brcmf_sdio_chip_getinfidx(bus->ci, BCMA_CORE_SDIO_DEV); *retryvar = 0; @@ -660,14 +660,14 @@ w_sdreg32(struct brcmf_bus *bus, u32 regval, u32 reg_offset, u32 *retryvar) /* Packet free applicable unconditionally for sdio and sdspi. * Conditional if bufpool was present for gspi bus. */ -static void brcmf_sdbrcm_pktfree2(struct brcmf_bus *bus, struct sk_buff *pkt) +static void brcmf_sdbrcm_pktfree2(struct brcmf_sdio *bus, struct sk_buff *pkt) { if (bus->usebufpool) brcmu_pkt_buf_free_skb(pkt); } /* Turn backplane clock on or off */ -static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) +static int brcmf_sdbrcm_htclk(struct brcmf_sdio *bus, bool on, bool pendok) { int err; u8 clkctl, clkreq, devctl; @@ -788,7 +788,7 @@ static int brcmf_sdbrcm_htclk(struct brcmf_bus *bus, bool on, bool pendok) } /* Change idle/active SD state */ -static int brcmf_sdbrcm_sdclk(struct brcmf_bus *bus, bool on) +static int brcmf_sdbrcm_sdclk(struct brcmf_sdio *bus, bool on) { brcmf_dbg(TRACE, "Enter\n"); @@ -801,7 +801,7 @@ static int brcmf_sdbrcm_sdclk(struct brcmf_bus *bus, bool on) } /* Transition SD and backplane clock readiness */ -static int brcmf_sdbrcm_clkctl(struct brcmf_bus *bus, uint target, bool pendok) +static int brcmf_sdbrcm_clkctl(struct brcmf_sdio *bus, uint target, bool pendok) { #ifdef BCMDBG uint oldstate = bus->clkstate; @@ -857,7 +857,7 @@ static int brcmf_sdbrcm_clkctl(struct brcmf_bus *bus, uint target, bool pendok) return 0; } -static int brcmf_sdbrcm_bussleep(struct brcmf_bus *bus, bool sleep) +static int brcmf_sdbrcm_bussleep(struct brcmf_sdio *bus, bool sleep) { uint retries = 0; @@ -929,13 +929,13 @@ static int brcmf_sdbrcm_bussleep(struct brcmf_bus *bus, bool sleep) return 0; } -static void bus_wake(struct brcmf_bus *bus) +static void bus_wake(struct brcmf_sdio *bus) { if (bus->sleeping) brcmf_sdbrcm_bussleep(bus, false); } -static u32 brcmf_sdbrcm_hostmail(struct brcmf_bus *bus) +static u32 brcmf_sdbrcm_hostmail(struct brcmf_sdio *bus) { u32 intstatus = 0; u32 hmb_data; @@ -1011,7 +1011,7 @@ static u32 brcmf_sdbrcm_hostmail(struct brcmf_bus *bus) return intstatus; } -static void brcmf_sdbrcm_rxfail(struct brcmf_bus *bus, bool abort, bool rtx) +static void brcmf_sdbrcm_rxfail(struct brcmf_sdio *bus, bool abort, bool rtx) { uint retries = 0; u16 lastrbc; @@ -1072,7 +1072,7 @@ static void brcmf_sdbrcm_rxfail(struct brcmf_bus *bus, bool abort, bool rtx) } /* copy a buffer into a pkt buffer chain */ -static uint brcmf_sdbrcm_glom_from_buf(struct brcmf_bus *bus, uint len) +static uint brcmf_sdbrcm_glom_from_buf(struct brcmf_sdio *bus, uint len) { uint n, ret = 0; struct sk_buff *p; @@ -1095,7 +1095,7 @@ static uint brcmf_sdbrcm_glom_from_buf(struct brcmf_bus *bus, uint len) } /* return total length of buffer chain */ -static uint brcmf_sdbrcm_glom_len(struct brcmf_bus *bus) +static uint brcmf_sdbrcm_glom_len(struct brcmf_sdio *bus) { struct sk_buff *p; uint total; @@ -1106,7 +1106,7 @@ static uint brcmf_sdbrcm_glom_len(struct brcmf_bus *bus) return total; } -static void brcmf_sdbrcm_free_glom(struct brcmf_bus *bus) +static void brcmf_sdbrcm_free_glom(struct brcmf_sdio *bus) { struct sk_buff *cur, *next; @@ -1116,7 +1116,7 @@ static void brcmf_sdbrcm_free_glom(struct brcmf_bus *bus) } } -static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) +static u8 brcmf_sdbrcm_rxglom(struct brcmf_sdio *bus, u8 rxseq) { u16 dlen, totlen; u8 *dptr, num = 0; @@ -1471,7 +1471,7 @@ static u8 brcmf_sdbrcm_rxglom(struct brcmf_bus *bus, u8 rxseq) return num; } -static int brcmf_sdbrcm_dcmd_resp_wait(struct brcmf_bus *bus, uint *condition, +static int brcmf_sdbrcm_dcmd_resp_wait(struct brcmf_sdio *bus, uint *condition, bool *pending) { DECLARE_WAITQUEUE(wait, current); @@ -1493,7 +1493,7 @@ static int brcmf_sdbrcm_dcmd_resp_wait(struct brcmf_bus *bus, uint *condition, return timeout; } -static int brcmf_sdbrcm_dcmd_resp_wake(struct brcmf_bus *bus) +static int brcmf_sdbrcm_dcmd_resp_wake(struct brcmf_sdio *bus) { if (waitqueue_active(&bus->dcmd_resp_wait)) wake_up_interruptible(&bus->dcmd_resp_wait); @@ -1501,7 +1501,7 @@ static int brcmf_sdbrcm_dcmd_resp_wake(struct brcmf_bus *bus) return 0; } static void -brcmf_sdbrcm_read_control(struct brcmf_bus *bus, u8 *hdr, uint len, uint doff) +brcmf_sdbrcm_read_control(struct brcmf_sdio *bus, u8 *hdr, uint len, uint doff) { uint rdlen, pad; @@ -1590,7 +1590,7 @@ done: } /* Pad read to blocksize for efficiency */ -static void brcmf_pad(struct brcmf_bus *bus, u16 *pad, u16 *rdlen) +static void brcmf_pad(struct brcmf_sdio *bus, u16 *pad, u16 *rdlen) { if (bus->roundup && bus->blocksize && *rdlen > bus->blocksize) { *pad = bus->blocksize - (*rdlen % bus->blocksize); @@ -1603,7 +1603,7 @@ static void brcmf_pad(struct brcmf_bus *bus, u16 *pad, u16 *rdlen) } static void -brcmf_alloc_pkt_and_read(struct brcmf_bus *bus, u16 rdlen, +brcmf_alloc_pkt_and_read(struct brcmf_sdio *bus, u16 rdlen, struct sk_buff **pkt, u8 **rxbuf) { int sdret; /* Return code from calls */ @@ -1635,7 +1635,7 @@ brcmf_alloc_pkt_and_read(struct brcmf_bus *bus, u16 rdlen, /* Checks the header */ static int -brcmf_check_rxbuf(struct brcmf_bus *bus, struct sk_buff *pkt, u8 *rxbuf, +brcmf_check_rxbuf(struct brcmf_sdio *bus, struct sk_buff *pkt, u8 *rxbuf, u8 rxseq, u16 nextlen, u16 *len) { u16 check; @@ -1691,7 +1691,7 @@ fail: /* Return true if there may be more frames to read */ static uint -brcmf_sdbrcm_readframes(struct brcmf_bus *bus, uint maxframes, bool *finished) +brcmf_sdbrcm_readframes(struct brcmf_sdio *bus, uint maxframes, bool *finished) { u16 len, check; /* Extracted hardware header fields */ u8 chan, seq, doff; /* Extracted software header fields */ @@ -2082,7 +2082,7 @@ deliver: } static void -brcmf_sdbrcm_wait_for_event(struct brcmf_bus *bus, bool *lockvar) +brcmf_sdbrcm_wait_for_event(struct brcmf_sdio *bus, bool *lockvar) { up(&bus->sdsem); wait_event_interruptible_timeout(bus->ctrl_wait, @@ -2092,7 +2092,7 @@ brcmf_sdbrcm_wait_for_event(struct brcmf_bus *bus, bool *lockvar) } static void -brcmf_sdbrcm_wait_event_wakeup(struct brcmf_bus *bus) +brcmf_sdbrcm_wait_event_wakeup(struct brcmf_sdio *bus) { if (waitqueue_active(&bus->ctrl_wait)) wake_up_interruptible(&bus->ctrl_wait); @@ -2101,7 +2101,7 @@ brcmf_sdbrcm_wait_event_wakeup(struct brcmf_bus *bus) /* Writes a HW/SW header into the packet and sends it. */ /* Assumes: (a) header space already there, (b) caller holds lock */ -static int brcmf_sdbrcm_txpkt(struct brcmf_bus *bus, struct sk_buff *pkt, +static int brcmf_sdbrcm_txpkt(struct brcmf_sdio *bus, struct sk_buff *pkt, uint chan, bool free_pkt) { int ret; @@ -2238,7 +2238,7 @@ done: return ret; } -static uint brcmf_sdbrcm_sendfromq(struct brcmf_bus *bus, uint maxframes) +static uint brcmf_sdbrcm_sendfromq(struct brcmf_sdio *bus, uint maxframes) { struct sk_buff *pkt; u32 intstatus = 0; @@ -2293,7 +2293,7 @@ static uint brcmf_sdbrcm_sendfromq(struct brcmf_bus *bus, uint maxframes) return cnt; } -static bool brcmf_sdbrcm_dpc(struct brcmf_bus *bus) +static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus) { u32 intstatus, newstatus = 0; uint retries = 0; @@ -2539,7 +2539,7 @@ clkwait: static int brcmf_sdbrcm_dpc_thread(void *data) { - struct brcmf_bus *bus = (struct brcmf_bus *) data; + struct brcmf_sdio *bus = (struct brcmf_sdio *) data; allow_signal(SIGTERM); /* Run until signal received */ @@ -2564,7 +2564,7 @@ static int brcmf_sdbrcm_dpc_thread(void *data) return 0; } -int brcmf_sdbrcm_bus_txdata(struct brcmf_bus *bus, struct sk_buff *pkt) +int brcmf_sdbrcm_bus_txdata(struct brcmf_sdio *bus, struct sk_buff *pkt) { int ret = -EBADE; uint datalen, prec; @@ -2615,7 +2615,7 @@ int brcmf_sdbrcm_bus_txdata(struct brcmf_bus *bus, struct sk_buff *pkt) } static int -brcmf_sdbrcm_membytes(struct brcmf_bus *bus, bool write, u32 address, u8 *data, +brcmf_sdbrcm_membytes(struct brcmf_sdio *bus, bool write, u32 address, u8 *data, uint size) { int bcmerror = 0; @@ -2676,7 +2676,7 @@ xfer_done: #ifdef BCMDBG #define CONSOLE_LINE_MAX 192 -static int brcmf_sdbrcm_readconsole(struct brcmf_bus *bus) +static int brcmf_sdbrcm_readconsole(struct brcmf_sdio *bus) { struct brcmf_console *c = &bus->console; u8 line[CONSOLE_LINE_MAX], ch; @@ -2753,7 +2753,7 @@ break2: } #endif /* BCMDBG */ -static int brcmf_tx_frame(struct brcmf_bus *bus, u8 *frame, u16 len) +static int brcmf_tx_frame(struct brcmf_sdio *bus, u8 *frame, u16 len) { int i; int ret; @@ -2796,7 +2796,7 @@ static int brcmf_tx_frame(struct brcmf_bus *bus, u8 *frame, u16 len) } int -brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) +brcmf_sdbrcm_bus_txctl(struct brcmf_sdio *bus, unsigned char *msg, uint msglen) { u8 *frame; u16 len; @@ -2911,7 +2911,7 @@ brcmf_sdbrcm_bus_txctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) } int -brcmf_sdbrcm_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) +brcmf_sdbrcm_bus_rxctl(struct brcmf_sdio *bus, unsigned char *msg, uint msglen) { int timeleft; uint rxlen = 0; @@ -2948,7 +2948,7 @@ brcmf_sdbrcm_bus_rxctl(struct brcmf_bus *bus, unsigned char *msg, uint msglen) return rxlen ? (int)rxlen : -ETIMEDOUT; } -static int brcmf_sdbrcm_downloadvars(struct brcmf_bus *bus, void *arg, int len) +static int brcmf_sdbrcm_downloadvars(struct brcmf_sdio *bus, void *arg, int len) { int bcmerror = 0; @@ -2981,7 +2981,7 @@ err: return bcmerror; } -static int brcmf_sdbrcm_write_vars(struct brcmf_bus *bus) +static int brcmf_sdbrcm_write_vars(struct brcmf_sdio *bus) { int bcmerror = 0; u32 varsize; @@ -3068,7 +3068,7 @@ static int brcmf_sdbrcm_write_vars(struct brcmf_bus *bus) return bcmerror; } -static int brcmf_sdbrcm_download_state(struct brcmf_bus *bus, bool enter) +static int brcmf_sdbrcm_download_state(struct brcmf_sdio *bus, bool enter) { uint retries; int bcmerror = 0; @@ -3117,7 +3117,7 @@ fail: return bcmerror; } -static int brcmf_sdbrcm_get_image(char *buf, int len, struct brcmf_bus *bus) +static int brcmf_sdbrcm_get_image(char *buf, int len, struct brcmf_sdio *bus) { if (bus->firmware->size < bus->fw_ptr + len) len = bus->firmware->size - bus->fw_ptr; @@ -3127,7 +3127,7 @@ static int brcmf_sdbrcm_get_image(char *buf, int len, struct brcmf_bus *bus) return len; } -static int brcmf_sdbrcm_download_code_file(struct brcmf_bus *bus) +static int brcmf_sdbrcm_download_code_file(struct brcmf_sdio *bus) { int offset = 0; uint len; @@ -3226,7 +3226,7 @@ static uint brcmf_process_nvram_vars(char *varbuf, uint len) return buf_len; } -static int brcmf_sdbrcm_download_nvram(struct brcmf_bus *bus) +static int brcmf_sdbrcm_download_nvram(struct brcmf_sdio *bus) { uint len; char *memblock = NULL; @@ -3273,7 +3273,7 @@ err: return ret; } -static int _brcmf_sdbrcm_download_firmware(struct brcmf_bus *bus) +static int _brcmf_sdbrcm_download_firmware(struct brcmf_sdio *bus) { int bcmerror = -1; @@ -3306,7 +3306,7 @@ err: } static bool -brcmf_sdbrcm_download_firmware(struct brcmf_bus *bus) +brcmf_sdbrcm_download_firmware(struct brcmf_sdio *bus) { bool ret; @@ -3320,7 +3320,7 @@ brcmf_sdbrcm_download_firmware(struct brcmf_bus *bus) return ret; } -void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus) +void brcmf_sdbrcm_bus_stop(struct brcmf_sdio *bus) { u32 local_hostintmask; u8 saveclk; @@ -3400,7 +3400,7 @@ void brcmf_sdbrcm_bus_stop(struct brcmf_bus *bus) int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr) { - struct brcmf_bus *bus = drvr->bus; + struct brcmf_sdio *bus = drvr->bus; unsigned long timeout; uint retries = 0; u8 ready, enable; @@ -3502,7 +3502,7 @@ exit: void brcmf_sdbrcm_isr(void *arg) { - struct brcmf_bus *bus = (struct brcmf_bus *) arg; + struct brcmf_sdio *bus = (struct brcmf_sdio *) arg; brcmf_dbg(TRACE, "Enter\n"); @@ -3536,7 +3536,7 @@ void brcmf_sdbrcm_isr(void *arg) static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *drvr) { - struct brcmf_bus *bus; + struct brcmf_sdio *bus; brcmf_dbg(TIMER, "Enter\n"); @@ -3623,7 +3623,7 @@ static bool brcmf_sdbrcm_chipmatch(u16 chipid) return false; } -static void brcmf_sdbrcm_release_malloc(struct brcmf_bus *bus) +static void brcmf_sdbrcm_release_malloc(struct brcmf_sdio *bus) { brcmf_dbg(TRACE, "Enter\n"); @@ -3635,7 +3635,7 @@ static void brcmf_sdbrcm_release_malloc(struct brcmf_bus *bus) bus->databuf = NULL; } -static bool brcmf_sdbrcm_probe_malloc(struct brcmf_bus *bus) +static bool brcmf_sdbrcm_probe_malloc(struct brcmf_sdio *bus) { brcmf_dbg(TRACE, "Enter\n"); @@ -3671,7 +3671,7 @@ fail: } static bool -brcmf_sdbrcm_probe_attach(struct brcmf_bus *bus, u32 regsva) +brcmf_sdbrcm_probe_attach(struct brcmf_sdio *bus, u32 regsva) { u8 clkctl = 0; int err = 0; @@ -3756,7 +3756,7 @@ fail: return false; } -static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus) +static bool brcmf_sdbrcm_probe_init(struct brcmf_sdio *bus) { brcmf_dbg(TRACE, "Enter\n"); @@ -3791,7 +3791,7 @@ static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus) static int brcmf_sdbrcm_watchdog_thread(void *data) { - struct brcmf_bus *bus = (struct brcmf_bus *)data; + struct brcmf_sdio *bus = (struct brcmf_sdio *)data; allow_signal(SIGTERM); /* Run until signal received */ @@ -3811,7 +3811,7 @@ brcmf_sdbrcm_watchdog_thread(void *data) static void brcmf_sdbrcm_watchdog(unsigned long data) { - struct brcmf_bus *bus = (struct brcmf_bus *)data; + struct brcmf_sdio *bus = (struct brcmf_sdio *)data; if (bus->watchdog_tsk) { complete(&bus->watchdog_wait); @@ -3822,7 +3822,7 @@ brcmf_sdbrcm_watchdog(unsigned long data) } } -static void brcmf_sdbrcm_release_dongle(struct brcmf_bus *bus) +static void brcmf_sdbrcm_release_dongle(struct brcmf_sdio *bus) { brcmf_dbg(TRACE, "Enter\n"); @@ -3839,7 +3839,7 @@ static void brcmf_sdbrcm_release_dongle(struct brcmf_bus *bus) } /* Detach and free everything */ -static void brcmf_sdbrcm_release(struct brcmf_bus *bus) +static void brcmf_sdbrcm_release(struct brcmf_sdio *bus) { brcmf_dbg(TRACE, "Enter\n"); @@ -3864,7 +3864,7 @@ static void brcmf_sdbrcm_release(struct brcmf_bus *bus) void *brcmf_sdbrcm_probe(u32 regsva, struct brcmf_sdio_dev *sdiodev) { int ret; - struct brcmf_bus *bus; + struct brcmf_sdio *bus; brcmf_dbg(TRACE, "Enter\n"); @@ -3872,7 +3872,7 @@ void *brcmf_sdbrcm_probe(u32 regsva, struct brcmf_sdio_dev *sdiodev) * regsva == SI_ENUM_BASE*/ /* Allocate private bus interface state */ - bus = kzalloc(sizeof(struct brcmf_bus), GFP_ATOMIC); + bus = kzalloc(sizeof(struct brcmf_sdio), GFP_ATOMIC); if (!bus) goto fail; @@ -3976,7 +3976,7 @@ fail: void brcmf_sdbrcm_disconnect(void *ptr) { - struct brcmf_bus *bus = (struct brcmf_bus *)ptr; + struct brcmf_sdio *bus = (struct brcmf_sdio *)ptr; brcmf_dbg(TRACE, "Enter\n"); @@ -3986,13 +3986,13 @@ void brcmf_sdbrcm_disconnect(void *ptr) brcmf_dbg(TRACE, "Disconnected\n"); } -struct device *brcmf_bus_get_device(struct brcmf_bus *bus) +struct device *brcmf_bus_get_device(struct brcmf_sdio *bus) { return &bus->sdiodev->func[2]->dev; } void -brcmf_sdbrcm_wd_timer(struct brcmf_bus *bus, uint wdtick) +brcmf_sdbrcm_wd_timer(struct brcmf_sdio *bus, uint wdtick) { /* Totally stop the timer */ if (!wdtick && bus->wd_timer_valid == true) { -- cgit v1.2.3 From 655713be2cf1a69990eb510f3641e9ef05648f51 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Tue, 22 Nov 2011 17:21:51 -0800 Subject: brcm80211: fmac: introduce common bus interface struct brcmf_bus struct brcmf_bus will contain function porinter, bus specific private structure pointer and interface context of generic layer and bus layer. It will be the only shared structure between generic and bus layer. This patch is part of fullmac bus interface refactoring. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c | 3 ++- .../net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 23 +++++++++++++++++----- drivers/net/wireless/brcm80211/brcmfmac/dhd.h | 5 +++++ .../net/wireless/brcm80211/brcmfmac/sdio_host.h | 2 +- 4 files changed, 26 insertions(+), 7 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c index 6c85d668c9d7..74933dccf69e 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c @@ -40,7 +40,8 @@ static void brcmf_sdioh_irqhandler(struct sdio_func *func) { - struct brcmf_sdio_dev *sdiodev = dev_get_drvdata(&func->card->dev); + struct brcmf_bus *bus_if = dev_get_drvdata(&func->card->dev); + struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv; brcmf_dbg(TRACE, "***IRQHandler\n"); diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 7a2325b2a564..77f84f8a0081 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -461,6 +461,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, { int ret = 0; struct brcmf_sdio_dev *sdiodev; + struct brcmf_bus *bus_if; brcmf_dbg(TRACE, "Enter\n"); brcmf_dbg(TRACE, "func->class=%x\n", func->class); brcmf_dbg(TRACE, "sdio_vendor: 0x%04x\n", func->vendor); @@ -472,12 +473,18 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, brcmf_dbg(ERROR, "card private drvdata occupied\n"); return -ENXIO; } + bus_if = kzalloc(sizeof(struct brcmf_bus), GFP_KERNEL); + if (!bus_if) + return -ENOMEM; sdiodev = kzalloc(sizeof(struct brcmf_sdio_dev), GFP_KERNEL); if (!sdiodev) return -ENOMEM; + sdiodev->dev = &func->card->dev; sdiodev->func[0] = func->card->sdio_func[0]; sdiodev->func[1] = func; - dev_set_drvdata(&func->card->dev, sdiodev); + bus_if->bus_priv = sdiodev; + bus_if->type = SDIO_BUS; + dev_set_drvdata(&func->card->dev, bus_if); atomic_set(&sdiodev->suspend, false); init_waitqueue_head(&sdiodev->request_byte_wait); @@ -487,7 +494,8 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, } if (func->num == 2) { - sdiodev = dev_get_drvdata(&func->card->dev); + bus_if = dev_get_drvdata(&func->card->dev); + sdiodev = bus_if->bus_priv; if ((!sdiodev) || (sdiodev->func[1]->card != func->card)) return -ENODEV; sdiodev->func[2] = func; @@ -501,6 +509,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, static void brcmf_ops_sdio_remove(struct sdio_func *func) { + struct brcmf_bus *bus_if; struct brcmf_sdio_dev *sdiodev; brcmf_dbg(TRACE, "Enter\n"); brcmf_dbg(INFO, "func->class=%x\n", func->class); @@ -509,10 +518,12 @@ static void brcmf_ops_sdio_remove(struct sdio_func *func) brcmf_dbg(INFO, "Function#: 0x%04x\n", func->num); if (func->num == 2) { - sdiodev = dev_get_drvdata(&func->card->dev); + bus_if = dev_get_drvdata(&func->card->dev); + sdiodev = bus_if->bus_priv; brcmf_dbg(TRACE, "F2 found, calling brcmf_sdio_remove...\n"); brcmf_sdio_remove(sdiodev); dev_set_drvdata(&func->card->dev, NULL); + kfree(bus_if); kfree(sdiodev); } } @@ -523,11 +534,12 @@ static int brcmf_sdio_suspend(struct device *dev) mmc_pm_flag_t sdio_flags; struct brcmf_sdio_dev *sdiodev; struct sdio_func *func = dev_to_sdio_func(dev); + struct brcmf_bus *bus_if = dev_get_drvdata(&func->card->dev); int ret = 0; brcmf_dbg(TRACE, "\n"); - sdiodev = dev_get_drvdata(&func->card->dev); + sdiodev = bus_if->bus_priv; atomic_set(&sdiodev->suspend, true); @@ -552,8 +564,9 @@ static int brcmf_sdio_resume(struct device *dev) { struct brcmf_sdio_dev *sdiodev; struct sdio_func *func = dev_to_sdio_func(dev); + struct brcmf_bus *bus_if = dev_get_drvdata(&func->card->dev); - sdiodev = dev_get_drvdata(&func->card->dev); + sdiodev = bus_if->bus_priv; brcmf_sdio_wdtmr_enable(sdiodev, true); atomic_set(&sdiodev->suspend, false); return 0; diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h index 451b34ba3984..a557971044bc 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h @@ -571,6 +571,11 @@ struct brcmf_dcmd { uint needed; /* bytes needed (optional) */ }; +struct brcmf_bus { + u8 type; /* bus type */ + void *bus_priv; /* pointer to bus private structure */ +}; + /* Forward decls for struct brcmf_pub (see below) */ struct brcmf_sdio; /* device bus info */ struct brcmf_proto; /* device communication protocol info */ diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h index 0618f5ed1acb..c4c2543438ec 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h @@ -134,7 +134,7 @@ struct brcmf_sdio_dev { wait_queue_head_t request_word_wait; wait_queue_head_t request_chain_wait; wait_queue_head_t request_buffer_wait; - + struct device *dev; }; /* Register/deregister device interrupt handler. */ -- cgit v1.2.3 From 8d169aa00d0356f915e84dbdf6c9be381cce34a4 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Tue, 22 Nov 2011 17:21:52 -0800 Subject: brcm80211: fmac: move busstate to struct brcmf_bus busstate keeps track of the bus (USB/SDIO) status and is used by both generic layer and bus layer. Move it to brcmf_bus helps to clean up the interface. This patch is part of fullmac bus interface refactoring. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/dhd.h | 6 ++-- drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c | 2 +- .../net/wireless/brcm80211/brcmfmac/dhd_linux.c | 18 ++++++---- drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 42 +++++++++++----------- 4 files changed, 37 insertions(+), 31 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h index a557971044bc..a104b74e0004 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h @@ -574,6 +574,7 @@ struct brcmf_dcmd { struct brcmf_bus { u8 type; /* bus type */ void *bus_priv; /* pointer to bus private structure */ + enum brcmf_bus_state state; }; /* Forward decls for struct brcmf_pub (see below) */ @@ -586,6 +587,7 @@ struct brcmf_cfg80211_dev; /* cfg80211 device info */ struct brcmf_pub { /* Linkage ponters */ struct brcmf_sdio *bus; + struct brcmf_bus *bus_if; struct brcmf_proto *prot; struct brcmf_info *info; struct brcmf_cfg80211_dev *config; @@ -593,7 +595,6 @@ struct brcmf_pub { /* Internal brcmf items */ bool up; /* Driver up/down (to OS) */ bool txoff; /* Transmit flow-controlled */ - enum brcmf_bus_state busstate; uint hdrlen; /* Total BRCMF header length (proto + bus) */ uint maxctl; /* Max size rxctl request from proto to bus */ uint rxsz; /* Rx buffer size bus module should use */ @@ -661,7 +662,6 @@ struct brcmf_pub { u8 country_code[BRCM_CNTRY_BUF_SZ]; char eventmask[BRCMF_EVENTING_MASK_LEN]; - }; struct brcmf_if_event { @@ -687,7 +687,7 @@ extern uint brcmf_c_mkiovar(char *name, char *data, uint datalen, * bus_hdrlen specifies required headroom for bus module header. */ extern struct brcmf_pub *brcmf_attach(struct brcmf_sdio *bus, - uint bus_hdrlen); + uint bus_hdrlen, struct device *dev); extern int brcmf_net_attach(struct brcmf_pub *drvr, int idx); extern int brcmf_netdev_wait_pend8021x(struct net_device *ndev); diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c index e34c5c3d1d55..8e46bc64ca5f 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c @@ -280,7 +280,7 @@ brcmf_proto_dcmd(struct brcmf_pub *drvr, int ifidx, struct brcmf_dcmd *dcmd, struct brcmf_proto *prot = drvr->prot; int ret = -1; - if (drvr->busstate == BRCMF_BUS_DOWN) { + if (drvr->bus_if->state == BRCMF_BUS_DOWN) { brcmf_dbg(ERROR, "bus is down. we have nothing to do.\n"); return ret; } diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index e8f7f78f52cc..c13b30f6d220 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -292,7 +292,7 @@ int brcmf_sendpkt(struct brcmf_pub *drvr, int ifidx, struct sk_buff *pktbuf) struct brcmf_info *drvr_priv = drvr->info; /* Reject if down */ - if (!drvr->up || (drvr->busstate == BRCMF_BUS_DOWN)) + if (!drvr->up || (drvr->bus_if->state == BRCMF_BUS_DOWN)) return -ENODEV; /* Update multicast statistic */ @@ -322,9 +322,11 @@ static int brcmf_netdev_start_xmit(struct sk_buff *skb, struct net_device *ndev) brcmf_dbg(TRACE, "Enter\n"); /* Reject if down */ - if (!drvr_priv->pub.up || (drvr_priv->pub.busstate == BRCMF_BUS_DOWN)) { - brcmf_dbg(ERROR, "xmit rejected pub.up=%d busstate=%d\n", - drvr_priv->pub.up, drvr_priv->pub.busstate); + if (!drvr_priv->pub.up || + (drvr_priv->pub.bus_if->state == BRCMF_BUS_DOWN)) { + brcmf_dbg(ERROR, "xmit rejected pub.up=%d state=%d\n", + drvr_priv->pub.up, + drvr_priv->pub.bus_if->state); netif_stop_queue(ndev); return -ENODEV; } @@ -761,7 +763,7 @@ s32 brcmf_exec_dcmd(struct net_device *ndev, u32 cmd, void *arg, u32 len) buflen = min_t(uint, dcmd.len, BRCMF_DCMD_MAXLEN); /* send to dongle (must be up, and wl) */ - if ((drvr_priv->pub.busstate != BRCMF_BUS_DATA)) { + if ((drvr_priv->pub.bus_if->state != BRCMF_BUS_DATA)) { brcmf_dbg(ERROR, "DONGLE_DOWN\n"); err = -EIO; goto done; @@ -940,7 +942,8 @@ void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx) } } -struct brcmf_pub *brcmf_attach(struct brcmf_sdio *bus, uint bus_hdrlen) +struct brcmf_pub *brcmf_attach(struct brcmf_sdio *bus, uint bus_hdrlen, + struct device *dev) { struct brcmf_info *drvr_priv = NULL; @@ -959,6 +962,7 @@ struct brcmf_pub *brcmf_attach(struct brcmf_sdio *bus, uint bus_hdrlen) /* Link to bus module */ drvr_priv->pub.bus = bus; drvr_priv->pub.hdrlen = bus_hdrlen; + drvr_priv->pub.bus_if = dev_get_drvdata(dev); /* Attach and link in the protocol */ if (brcmf_proto_attach(&drvr_priv->pub) != 0) { @@ -995,7 +999,7 @@ int brcmf_bus_start(struct brcmf_pub *drvr) } /* If bus is not ready, can't come up */ - if (drvr_priv->pub.busstate != BRCMF_BUS_DATA) { + if (drvr_priv->pub.bus_if->state != BRCMF_BUS_DATA) { brcmf_dbg(ERROR, "failed bus is not ready\n"); return -ENODEV; } diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 9ab906a91c48..7c8b5f77042c 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -1068,7 +1068,7 @@ static void brcmf_sdbrcm_rxfail(struct brcmf_sdio *bus, bool abort, bool rtx) /* If we can't reach the device, signal failure */ if (err || brcmf_sdcard_regfail(bus->sdiodev)) - bus->drvr->busstate = BRCMF_BUS_DOWN; + bus->drvr->bus_if->state = BRCMF_BUS_DOWN; } /* copy a buffer into a pkt buffer chain */ @@ -1714,7 +1714,8 @@ brcmf_sdbrcm_readframes(struct brcmf_sdio *bus, uint maxframes, bool *finished) *finished = false; for (rxseq = bus->rx_seq, rxleft = maxframes; - !bus->rxskip && rxleft && bus->drvr->busstate != BRCMF_BUS_DOWN; + !bus->rxskip && rxleft && + bus->drvr->bus_if->state != BRCMF_BUS_DOWN; rxseq++, rxleft--) { /* Handle glomming separately */ @@ -2286,7 +2287,7 @@ static uint brcmf_sdbrcm_sendfromq(struct brcmf_sdio *bus, uint maxframes) } /* Deflow-control stack if needed */ - if (drvr->up && (drvr->busstate == BRCMF_BUS_DATA) && + if (drvr->up && (drvr->bus_if->state == BRCMF_BUS_DATA) && drvr->txoff && (pktq_len(&bus->txq) < TXLOW)) brcmf_txflowcontrol(drvr, 0, OFF); @@ -2321,7 +2322,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus) SBSDIO_DEVICE_CTL, &err); if (err) { brcmf_dbg(ERROR, "error reading DEVCTL: %d\n", err); - bus->drvr->busstate = BRCMF_BUS_DOWN; + bus->drvr->bus_if->state = BRCMF_BUS_DOWN; } #endif /* BCMDBG */ @@ -2331,7 +2332,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus) if (err) { brcmf_dbg(ERROR, "error reading CSR: %d\n", err); - bus->drvr->busstate = BRCMF_BUS_DOWN; + bus->drvr->bus_if->state = BRCMF_BUS_DOWN; } brcmf_dbg(INFO, "DPC: PENDING, devctl 0x%02x clkctl 0x%02x\n", @@ -2344,7 +2345,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus) if (err) { brcmf_dbg(ERROR, "error reading DEVCTL: %d\n", err); - bus->drvr->busstate = BRCMF_BUS_DOWN; + bus->drvr->bus_if->state = BRCMF_BUS_DOWN; } devctl &= ~SBSDIO_DEVCTL_CA_INT_ONLY; brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, @@ -2352,7 +2353,7 @@ static bool brcmf_sdbrcm_dpc(struct brcmf_sdio *bus) if (err) { brcmf_dbg(ERROR, "error writing DEVCTL: %d\n", err); - bus->drvr->busstate = BRCMF_BUS_DOWN; + bus->drvr->bus_if->state = BRCMF_BUS_DOWN; } bus->clkstate = CLK_AVAIL; } else { @@ -2508,11 +2509,11 @@ clkwait: else await next interrupt */ /* On failed register access, all bets are off: no resched or interrupts */ - if ((bus->drvr->busstate == BRCMF_BUS_DOWN) || + if ((bus->drvr->bus_if->state == BRCMF_BUS_DOWN) || brcmf_sdcard_regfail(bus->sdiodev)) { brcmf_dbg(ERROR, "failed backplane access over SDIO, halting operation %d\n", brcmf_sdcard_regfail(bus->sdiodev)); - bus->drvr->busstate = BRCMF_BUS_DOWN; + bus->drvr->bus_if->state = BRCMF_BUS_DOWN; bus->intstatus = 0; } else if (bus->clkstate == CLK_PENDING) { brcmf_dbg(INFO, "rescheduled due to CLK_PENDING awaiting I_CHIPACTIVE interrupt\n"); @@ -2549,7 +2550,7 @@ static int brcmf_sdbrcm_dpc_thread(void *data) if (!wait_for_completion_interruptible(&bus->dpc_wait)) { /* Call bus dpc unless it indicated down (then clean stop) */ - if (bus->drvr->busstate != BRCMF_BUS_DOWN) { + if (bus->drvr->bus_if->state != BRCMF_BUS_DOWN) { if (brcmf_sdbrcm_dpc(bus)) complete(&bus->dpc_wait); } else { @@ -3111,7 +3112,7 @@ static int brcmf_sdbrcm_download_state(struct brcmf_sdio *bus, bool enter) /* Allow HT Clock now that the ARM is running. */ bus->alp_only = false; - bus->drvr->busstate = BRCMF_BUS_LOAD; + bus->drvr->bus_if->state = BRCMF_BUS_LOAD; } fail: return bcmerror; @@ -3354,7 +3355,7 @@ void brcmf_sdbrcm_bus_stop(struct brcmf_sdio *bus) bus->hostintmask = 0; /* Change our idea of bus state */ - bus->drvr->busstate = BRCMF_BUS_DOWN; + bus->drvr->bus_if->state = BRCMF_BUS_DOWN; /* Force clocks on backplane to be sure F2 interrupt propagates */ saveclk = brcmf_sdcard_cfg_read(bus->sdiodev, SDIO_FUNC_1, @@ -3410,7 +3411,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr) brcmf_dbg(TRACE, "Enter\n"); /* try to download image and nvram to the dongle */ - if (drvr->busstate == BRCMF_BUS_DOWN) { + if (drvr->bus_if->state == BRCMF_BUS_DOWN) { if (!(brcmf_sdbrcm_download_firmware(bus))) return -1; } @@ -3476,7 +3477,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr) SBSDIO_WATERMARK, 8, &err); /* Set bus state according to enable result */ - drvr->busstate = BRCMF_BUS_DATA; + drvr->bus_if->state = BRCMF_BUS_DATA; } else { @@ -3491,7 +3492,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr) SBSDIO_FUNC1_CHIPCLKCSR, saveclk, &err); /* If we didn't come up, turn off backplane clock */ - if (drvr->busstate != BRCMF_BUS_DATA) + if (drvr->bus_if->state != BRCMF_BUS_DATA) brcmf_sdbrcm_clkctl(bus, CLK_NONE, false); exit: @@ -3511,7 +3512,7 @@ void brcmf_sdbrcm_isr(void *arg) return; } - if (bus->drvr->busstate == BRCMF_BUS_DOWN) { + if (bus->drvr->bus_if->state == BRCMF_BUS_DOWN) { brcmf_dbg(ERROR, "bus is down. we have nothing to do\n"); return; } @@ -3585,7 +3586,8 @@ static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *drvr) } #ifdef BCMDBG /* Poll for console output periodically */ - if (drvr->busstate == BRCMF_BUS_DATA && bus->console_interval != 0) { + if (drvr->bus_if->state == BRCMF_BUS_DATA && + bus->console_interval != 0) { bus->console.count += BRCMF_WD_POLL_MS; if (bus->console.count >= bus->console_interval) { bus->console.count -= bus->console_interval; @@ -3764,7 +3766,7 @@ static bool brcmf_sdbrcm_probe_init(struct brcmf_sdio *bus) brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_0, SDIO_CCCR_IOEx, SDIO_FUNC_ENABLE_1, NULL); - bus->drvr->busstate = BRCMF_BUS_DOWN; + bus->drvr->bus_if->state = BRCMF_BUS_DOWN; bus->sleeping = false; bus->rxflow = false; @@ -3924,7 +3926,7 @@ void *brcmf_sdbrcm_probe(u32 regsva, struct brcmf_sdio_dev *sdiodev) } /* Attach to the brcmf/OS/network interface */ - bus->drvr = brcmf_attach(bus, SDPCM_RESERVE); + bus->drvr = brcmf_attach(bus, SDPCM_RESERVE, bus->sdiodev->dev); if (!bus->drvr) { brcmf_dbg(ERROR, "brcmf_attach failed\n"); goto fail; @@ -4003,7 +4005,7 @@ brcmf_sdbrcm_wd_timer(struct brcmf_sdio *bus, uint wdtick) } /* don't start the wd until fw is loaded */ - if (bus->drvr->busstate == BRCMF_BUS_DOWN) + if (bus->drvr->bus_if->state == BRCMF_BUS_DOWN) return; if (wdtick) { -- cgit v1.2.3 From cad2b26b1010d0694d2f08d408486451b9f919d2 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Tue, 22 Nov 2011 17:21:53 -0800 Subject: brcm80211: fmac: stop using brcmf_pub in brcmf_sdbrcm_bus_watchdog structure brcmf_pub contains context for generic layer and should not be used in brcmf_sdbrcm_bus_watchdog. This patch is part of fullmac bus interface refactoring. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 7c8b5f77042c..885d16a57c80 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -3535,14 +3535,14 @@ void brcmf_sdbrcm_isr(void *arg) complete(&bus->dpc_wait); } -static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *drvr) +static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_sdio *bus) { - struct brcmf_sdio *bus; +#ifdef BCMDBG + struct brcmf_bus *bus_if = dev_get_drvdata(bus->sdiodev->dev); +#endif /* BCMDBG */ brcmf_dbg(TIMER, "Enter\n"); - bus = drvr->bus; - /* Ignore the timer if simulating bus down */ if (bus->sleeping) return false; @@ -3586,7 +3586,7 @@ static bool brcmf_sdbrcm_bus_watchdog(struct brcmf_pub *drvr) } #ifdef BCMDBG /* Poll for console output periodically */ - if (drvr->bus_if->state == BRCMF_BUS_DATA && + if (bus_if->state == BRCMF_BUS_DATA && bus->console_interval != 0) { bus->console.count += BRCMF_WD_POLL_MS; if (bus->console.count >= bus->console_interval) { @@ -3801,7 +3801,7 @@ brcmf_sdbrcm_watchdog_thread(void *data) if (kthread_should_stop()) break; if (!wait_for_completion_interruptible(&bus->watchdog_wait)) { - brcmf_sdbrcm_bus_watchdog(bus->drvr); + brcmf_sdbrcm_bus_watchdog(bus); /* Count the tick for reference */ bus->drvr->tickcnt++; } else -- cgit v1.2.3 From 532cdd3b99b7a89fdc128c2b58abea780f3bbb4d Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Tue, 22 Nov 2011 17:21:54 -0800 Subject: brcm80211: fmac: change function bus_rxctl parameter brcmf_sdbrcm_bus_rxctl acts as an interface function of bus layer. Change parameter from struct brcmf_sdio to device pointer in order to provide a more compatible interface for different bus layers. This is part of the fullmac bus interface refactoring. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/dhd.h | 1 + drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h | 2 +- drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c | 2 +- drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c | 1 + drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 5 ++++- 5 files changed, 8 insertions(+), 3 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h index a104b74e0004..b68d1363105c 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h @@ -591,6 +591,7 @@ struct brcmf_pub { struct brcmf_proto *prot; struct brcmf_info *info; struct brcmf_cfg80211_dev *config; + struct device *dev; /* fullmac dongle device pointer */ /* Internal brcmf items */ bool up; /* Driver up/down (to OS) */ diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h index 81fc1dbccc55..44f46d126186 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h @@ -46,7 +46,7 @@ extern int brcmf_sdbrcm_bus_txctl(struct brcmf_sdio *bus, unsigned char *msg, uint msglen); extern int -brcmf_sdbrcm_bus_rxctl(struct brcmf_sdio *bus, unsigned char *msg, uint msglen); +brcmf_sdbrcm_bus_rxctl(struct device *dev, unsigned char *msg, uint msglen); extern void brcmf_sdbrcm_wd_timer(struct brcmf_sdio *bus, uint wdtick); diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c index 8e46bc64ca5f..5ab8671d9f3c 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c @@ -128,7 +128,7 @@ static int brcmf_proto_cdc_cmplt(struct brcmf_pub *drvr, u32 id, u32 len) brcmf_dbg(TRACE, "Enter\n"); do { - ret = brcmf_sdbrcm_bus_rxctl(drvr->bus, + ret = brcmf_sdbrcm_bus_rxctl(drvr->dev, (unsigned char *)&prot->msg, len + sizeof(struct brcmf_proto_cdc_dcmd)); if (ret < 0) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index c13b30f6d220..c20c72df73ab 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -963,6 +963,7 @@ struct brcmf_pub *brcmf_attach(struct brcmf_sdio *bus, uint bus_hdrlen, drvr_priv->pub.bus = bus; drvr_priv->pub.hdrlen = bus_hdrlen; drvr_priv->pub.bus_if = dev_get_drvdata(dev); + drvr_priv->pub.dev = dev; /* Attach and link in the protocol */ if (brcmf_proto_attach(&drvr_priv->pub) != 0) { diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 885d16a57c80..e13c9e90fbdf 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -2912,11 +2912,14 @@ brcmf_sdbrcm_bus_txctl(struct brcmf_sdio *bus, unsigned char *msg, uint msglen) } int -brcmf_sdbrcm_bus_rxctl(struct brcmf_sdio *bus, unsigned char *msg, uint msglen) +brcmf_sdbrcm_bus_rxctl(struct device *dev, unsigned char *msg, uint msglen) { int timeleft; uint rxlen = 0; bool pending; + struct brcmf_bus *bus_if = dev_get_drvdata(dev); + struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv; + struct brcmf_sdio *bus = sdiodev->bus; brcmf_dbg(TRACE, "Enter\n"); -- cgit v1.2.3 From 47a1ce78d544b9fb3b776a62de3c084cf0020fda Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Tue, 22 Nov 2011 17:21:55 -0800 Subject: brcm80211: fmac: change function bus_txctl parameter Change paramter to device pointer for bus layer interface function brcmf_sdbrcm_bus_txctl. This is part of the fullmac bus interface refactoring. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h | 2 +- drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c | 2 +- drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h index 44f46d126186..be20e7dfa237 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h @@ -43,7 +43,7 @@ extern int brcmf_sdbrcm_bus_txdata(struct brcmf_sdio *bus, struct sk_buff *txp); * Expects caller to enforce a single outstanding transaction. */ extern int -brcmf_sdbrcm_bus_txctl(struct brcmf_sdio *bus, unsigned char *msg, uint msglen); +brcmf_sdbrcm_bus_txctl(struct device *dev, unsigned char *msg, uint msglen); extern int brcmf_sdbrcm_bus_rxctl(struct device *dev, unsigned char *msg, uint msglen); diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c index 5ab8671d9f3c..a527d5d4cc4e 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c @@ -116,7 +116,7 @@ static int brcmf_proto_cdc_msg(struct brcmf_pub *drvr) len = CDC_MAX_MSG_SIZE; /* Send request */ - return brcmf_sdbrcm_bus_txctl(drvr->bus, (unsigned char *)&prot->msg, + return brcmf_sdbrcm_bus_txctl(drvr->dev, (unsigned char *)&prot->msg, len); } diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index e13c9e90fbdf..b62dc980c2cd 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -2797,7 +2797,7 @@ static int brcmf_tx_frame(struct brcmf_sdio *bus, u8 *frame, u16 len) } int -brcmf_sdbrcm_bus_txctl(struct brcmf_sdio *bus, unsigned char *msg, uint msglen) +brcmf_sdbrcm_bus_txctl(struct device *dev, unsigned char *msg, uint msglen) { u8 *frame; u16 len; @@ -2805,6 +2805,9 @@ brcmf_sdbrcm_bus_txctl(struct brcmf_sdio *bus, unsigned char *msg, uint msglen) uint retries = 0; u8 doff = 0; int ret = -1; + struct brcmf_bus *bus_if = dev_get_drvdata(dev); + struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv; + struct brcmf_sdio *bus = sdiodev->bus; brcmf_dbg(TRACE, "Enter\n"); -- cgit v1.2.3 From bf347bb9768ab0da028a0d9f92142df738211deb Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Tue, 22 Nov 2011 17:21:56 -0800 Subject: brcm80211: fmac: change function bus_txdata parameter Change parameter to device pointer for bus layer interface function brcmf_sdbrcm_bus_txdata. This is part of the fullmac bus interface refactoring. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h | 2 +- drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c | 2 +- drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h index be20e7dfa237..c73679ebc567 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h @@ -37,7 +37,7 @@ extern void brcmf_sdbrcm_bus_stop(struct brcmf_sdio *bus); extern int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr); /* Send a data frame to the dongle. Callee disposes of txp. */ -extern int brcmf_sdbrcm_bus_txdata(struct brcmf_sdio *bus, struct sk_buff *txp); +extern int brcmf_sdbrcm_bus_txdata(struct device *dev, struct sk_buff *txp); /* Send/receive a control message to/from the dongle. * Expects caller to enforce a single outstanding transaction. diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index c20c72df73ab..1cfe9f3dbe0e 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -310,7 +310,7 @@ int brcmf_sendpkt(struct brcmf_pub *drvr, int ifidx, struct sk_buff *pktbuf) brcmf_proto_hdrpush(drvr, ifidx, pktbuf); /* Use bus module to send data frame */ - return brcmf_sdbrcm_bus_txdata(drvr->bus, pktbuf); + return brcmf_sdbrcm_bus_txdata(drvr->dev, pktbuf); } static int brcmf_netdev_start_xmit(struct sk_buff *skb, struct net_device *ndev) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index b62dc980c2cd..f80151b3696b 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -2565,10 +2565,13 @@ static int brcmf_sdbrcm_dpc_thread(void *data) return 0; } -int brcmf_sdbrcm_bus_txdata(struct brcmf_sdio *bus, struct sk_buff *pkt) +int brcmf_sdbrcm_bus_txdata(struct device *dev, struct sk_buff *pkt) { int ret = -EBADE; uint datalen, prec; + struct brcmf_bus *bus_if = dev_get_drvdata(dev); + struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv; + struct brcmf_sdio *bus = sdiodev->bus; brcmf_dbg(TRACE, "Enter\n"); -- cgit v1.2.3 From fa20b91143c616d402f1ed61f27693477279d0c6 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Tue, 22 Nov 2011 17:21:57 -0800 Subject: brcm80211: fmac: change function bus_init parameter Change parameter to device pointer for bus layer interface function brcmf_sdbrcm_bus_init. This is part of the fullmac bus interface refactoring. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h | 2 +- drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c | 2 +- drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 12 +++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h index c73679ebc567..cfcf5a9c1d23 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h @@ -34,7 +34,7 @@ extern struct device *brcmf_bus_get_device(struct brcmf_sdio *bus); extern void brcmf_sdbrcm_bus_stop(struct brcmf_sdio *bus); /* Initialize bus module: prepare for communication w/dongle */ -extern int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr); +extern int brcmf_sdbrcm_bus_init(struct device *dev); /* Send a data frame to the dongle. Callee disposes of txp. */ extern int brcmf_sdbrcm_bus_txdata(struct device *dev, struct sk_buff *txp); diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index 1cfe9f3dbe0e..f8c0ae4eb2e0 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -993,7 +993,7 @@ int brcmf_bus_start(struct brcmf_pub *drvr) brcmf_dbg(TRACE, "\n"); /* Bring up the bus */ - ret = brcmf_sdbrcm_bus_init(&drvr_priv->pub); + ret = brcmf_sdbrcm_bus_init(drvr_priv->pub.dev); if (ret != 0) { brcmf_dbg(ERROR, "brcmf_sdbrcm_bus_init failed %d\n", ret); return ret; diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index f80151b3696b..8c00014a760c 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -3408,9 +3408,11 @@ void brcmf_sdbrcm_bus_stop(struct brcmf_sdio *bus) up(&bus->sdsem); } -int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr) +int brcmf_sdbrcm_bus_init(struct device *dev) { - struct brcmf_sdio *bus = drvr->bus; + struct brcmf_bus *bus_if = dev_get_drvdata(dev); + struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv; + struct brcmf_sdio *bus = sdiodev->bus; unsigned long timeout; uint retries = 0; u8 ready, enable; @@ -3420,7 +3422,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr) brcmf_dbg(TRACE, "Enter\n"); /* try to download image and nvram to the dongle */ - if (drvr->bus_if->state == BRCMF_BUS_DOWN) { + if (bus_if->state == BRCMF_BUS_DOWN) { if (!(brcmf_sdbrcm_download_firmware(bus))) return -1; } @@ -3486,7 +3488,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr) SBSDIO_WATERMARK, 8, &err); /* Set bus state according to enable result */ - drvr->bus_if->state = BRCMF_BUS_DATA; + bus_if->state = BRCMF_BUS_DATA; } else { @@ -3501,7 +3503,7 @@ int brcmf_sdbrcm_bus_init(struct brcmf_pub *drvr) SBSDIO_FUNC1_CHIPCLKCSR, saveclk, &err); /* If we didn't come up, turn off backplane clock */ - if (drvr->bus_if->state != BRCMF_BUS_DATA) + if (bus_if->state != BRCMF_BUS_DATA) brcmf_sdbrcm_clkctl(bus, CLK_NONE, false); exit: -- cgit v1.2.3 From c0a7962ae72c9ebf42f623719a46c8f472f44067 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Tue, 22 Nov 2011 17:21:58 -0800 Subject: brcm80211: fmac: remove function brcmf_bus_get_device brcmf_bus_get_device is no longer necessary. Use dongle device pointer saved in brcmf_pub directly. This is part of the fullmac bus interface refactoring. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h | 3 --- drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c | 8 ++------ drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 5 ----- 3 files changed, 2 insertions(+), 14 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h index cfcf5a9c1d23..1b5786010f9f 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h @@ -27,9 +27,6 @@ * Exported from brcmf bus module (brcmf_usb, brcmf_sdio) */ -/* obtain linux device object providing bus function */ -extern struct device *brcmf_bus_get_device(struct brcmf_sdio *bus); - /* Stop bus module: clear pending frames, disable data flow */ extern void brcmf_sdbrcm_bus_stop(struct brcmf_sdio *bus); diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index f8c0ae4eb2e0..20d82215a849 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -608,8 +608,7 @@ static void brcmf_ethtool_get_drvinfo(struct net_device *ndev, sprintf(info->driver, KBUILD_MODNAME); sprintf(info->version, "%lu", drvr_priv->pub.drv_version); - sprintf(info->bus_info, "%s", - dev_name(brcmf_bus_get_device(drvr_priv->pub.bus))); + sprintf(info->bus_info, "%s", dev_name(drvr_priv->pub.dev)); } static struct ethtool_ops brcmf_ethtool_ops = { @@ -1082,10 +1081,7 @@ int brcmf_net_attach(struct brcmf_pub *drvr, int ifidx) /* attach to cfg80211 for primary interface */ if (!ifidx) { - drvr->config = - brcmf_cfg80211_attach(ndev, - brcmf_bus_get_device(drvr->bus), - drvr); + drvr->config = brcmf_cfg80211_attach(ndev, drvr->dev, drvr); if (drvr->config == NULL) { brcmf_dbg(ERROR, "wl_cfg80211_attach failed\n"); goto fail; diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 8c00014a760c..5d81052832b4 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -3999,11 +3999,6 @@ void brcmf_sdbrcm_disconnect(void *ptr) brcmf_dbg(TRACE, "Disconnected\n"); } -struct device *brcmf_bus_get_device(struct brcmf_sdio *bus) -{ - return &bus->sdiodev->func[2]->dev; -} - void brcmf_sdbrcm_wd_timer(struct brcmf_sdio *bus, uint wdtick) { -- cgit v1.2.3 From 94c2fb82bd7c9055bec8e410c387befce33d1299 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Tue, 22 Nov 2011 17:21:59 -0800 Subject: brcm80211: fmac: change function bus_stop parameter Change parameter to device pointer for bus layer interface function brcmf_sdbrcm_bus_stop. This is part of the fullmac bus interface refactoring. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h | 2 +- drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c | 2 +- drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h index 1b5786010f9f..1841f996110b 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_bus.h @@ -28,7 +28,7 @@ */ /* Stop bus module: clear pending frames, disable data flow */ -extern void brcmf_sdbrcm_bus_stop(struct brcmf_sdio *bus); +extern void brcmf_sdbrcm_bus_stop(struct device *dev); /* Initialize bus module: prepare for communication w/dongle */ extern int brcmf_sdbrcm_bus_init(struct device *dev); diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index 20d82215a849..58d92bca9ca2 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -1115,7 +1115,7 @@ static void brcmf_bus_detach(struct brcmf_pub *drvr) brcmf_proto_stop(&drvr_priv->pub); /* Stop the bus module */ - brcmf_sdbrcm_bus_stop(drvr_priv->pub.bus); + brcmf_sdbrcm_bus_stop(drvr_priv->pub.dev); } } } diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 5d81052832b4..18597fe5dfd6 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -2555,7 +2555,7 @@ static int brcmf_sdbrcm_dpc_thread(void *data) complete(&bus->dpc_wait); } else { /* after stopping the bus, exit thread */ - brcmf_sdbrcm_bus_stop(bus); + brcmf_sdbrcm_bus_stop(bus->sdiodev->dev); bus->dpc_tsk = NULL; break; } @@ -3330,12 +3330,15 @@ brcmf_sdbrcm_download_firmware(struct brcmf_sdio *bus) return ret; } -void brcmf_sdbrcm_bus_stop(struct brcmf_sdio *bus) +void brcmf_sdbrcm_bus_stop(struct device *dev) { u32 local_hostintmask; u8 saveclk; uint retries; int err; + struct brcmf_bus *bus_if = dev_get_drvdata(dev); + struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv; + struct brcmf_sdio *bus = sdiodev->bus; brcmf_dbg(TRACE, "Enter\n"); -- cgit v1.2.3 From de2e56cea25c80f91a6c6699de40fb3fe8b2479d Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 23 Nov 2011 21:30:19 -0600 Subject: rtlwifi: Fix incorrect return of IRQ_HANDLED The recent discussion regarding an incorrect return of IRQ_HANDLED from rt2800pci caused me to look at this PCI interrupt routine. I discovered that changes were needed. Signed-off-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/pci.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c index b6683a247b51..91f0525364ea 100644 --- a/drivers/net/wireless/rtlwifi/pci.c +++ b/drivers/net/wireless/rtlwifi/pci.c @@ -780,6 +780,7 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id) unsigned long flags; u32 inta = 0; u32 intb = 0; + irqreturn_t ret = IRQ_HANDLED; spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags); @@ -787,8 +788,10 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id) rtlpriv->cfg->ops->interrupt_recognized(hw, &inta, &intb); /*Shared IRQ or HW disappared */ - if (!inta || inta == 0xffff) + if (!inta || inta == 0xffff) { + ret = IRQ_NONE; goto done; + } /*<1> beacon related */ if (inta & rtlpriv->cfg->maps[RTL_IMR_TBDOK]) { @@ -892,7 +895,7 @@ static irqreturn_t _rtl_pci_interrupt(int irq, void *dev_id) done: spin_unlock_irqrestore(&rtlpriv->locks.irq_th_lock, flags); - return IRQ_HANDLED; + return ret; } static void _rtl_pci_irq_tasklet(struct ieee80211_hw *hw) -- cgit v1.2.3 From 4883993841638963fbae2f334899f29309466152 Mon Sep 17 00:00:00 2001 From: Helmut Schaa Date: Thu, 24 Nov 2011 09:13:26 +0100 Subject: rt2x00: Pass BlockAck and BlackAckReq frames to mac80211 in monitor mode Previously BlockAcks were always dropped by the rt2800 hardware while BlockAckReqs were always accepted. However, both are only useful on monitor interfaces at the moment and both are control frames. So pass them up when mac80211 sets FIF_CONTROL. Signed-off-by: Helmut Schaa Acked-by: Gertjan van Wingerde Acked-by: Ivo van Doorn Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2800lib.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index 3f183a15186e..25dab2987131 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c @@ -1203,8 +1203,10 @@ void rt2800_config_filter(struct rt2x00_dev *rt2x00dev, !(filter_flags & FIF_CONTROL)); rt2x00_set_field32(®, RX_FILTER_CFG_DROP_PSPOLL, !(filter_flags & FIF_PSPOLL)); - rt2x00_set_field32(®, RX_FILTER_CFG_DROP_BA, 1); - rt2x00_set_field32(®, RX_FILTER_CFG_DROP_BAR, 0); + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_BA, + !(filter_flags & FIF_CONTROL)); + rt2x00_set_field32(®, RX_FILTER_CFG_DROP_BAR, + !(filter_flags & FIF_CONTROL)); rt2x00_set_field32(®, RX_FILTER_CFG_DROP_CNTL, !(filter_flags & FIF_CONTROL)); rt2800_register_write(rt2x00dev, RX_FILTER_CFG, reg); -- cgit v1.2.3 From 4e3309ba95f0d642efacfcb972251b07c3d29c27 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 24 Nov 2011 16:29:20 +0100 Subject: wireless: Remove redundant spi driver bus initialization In ancient times it was necessary to manually initialize the bus field of an spi_driver to spi_bus_type. These days this is done in spi_driver_register(), so we can drop the manual assignment. The patch was generated using the following coccinelle semantic patch: // @@ identifier _driver; @@ struct spi_driver _driver = { .driver = { - .bus = &spi_bus_type, }, }; // Signed-off-by: Lars-Peter Clausen Cc: Dan Williams Cc: "John W. Linville" Cc: Christian Lamparter Cc: Luciano Coelho Cc: libertas-dev@lists.infradead.org Cc: linux-wireless@vger.kernel.org Acked-by: Luciano Coelho Signed-off-by: John W. Linville --- drivers/net/wireless/libertas/if_spi.c | 1 - drivers/net/wireless/p54/p54spi.c | 1 - drivers/net/wireless/wl1251/spi.c | 1 - drivers/net/wireless/wl12xx/spi.c | 1 - 4 files changed, 4 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/libertas/if_spi.c b/drivers/net/wireless/libertas/if_spi.c index 11b69b300dc0..0c87f42fa660 100644 --- a/drivers/net/wireless/libertas/if_spi.c +++ b/drivers/net/wireless/libertas/if_spi.c @@ -1290,7 +1290,6 @@ static struct spi_driver libertas_spi_driver = { .remove = __devexit_p(libertas_spi_remove), .driver = { .name = "libertas_spi", - .bus = &spi_bus_type, .owner = THIS_MODULE, .pm = &if_spi_pm_ops, }, diff --git a/drivers/net/wireless/p54/p54spi.c b/drivers/net/wireless/p54/p54spi.c index a454d487b14f..546551389a1d 100644 --- a/drivers/net/wireless/p54/p54spi.c +++ b/drivers/net/wireless/p54/p54spi.c @@ -699,7 +699,6 @@ static int __devexit p54spi_remove(struct spi_device *spi) static struct spi_driver p54spi_driver = { .driver = { .name = "p54spi", - .bus = &spi_bus_type, .owner = THIS_MODULE, }, diff --git a/drivers/net/wireless/wl1251/spi.c b/drivers/net/wireless/wl1251/spi.c index eaa5f9556200..6248c354fc5c 100644 --- a/drivers/net/wireless/wl1251/spi.c +++ b/drivers/net/wireless/wl1251/spi.c @@ -319,7 +319,6 @@ static int __devexit wl1251_spi_remove(struct spi_device *spi) static struct spi_driver wl1251_spi_driver = { .driver = { .name = DRIVER_NAME, - .bus = &spi_bus_type, .owner = THIS_MODULE, }, diff --git a/drivers/net/wireless/wl12xx/spi.c b/drivers/net/wireless/wl12xx/spi.c index 0f9718677860..12421a64d891 100644 --- a/drivers/net/wireless/wl12xx/spi.c +++ b/drivers/net/wireless/wl12xx/spi.c @@ -462,7 +462,6 @@ static int __devexit wl1271_remove(struct spi_device *spi) static struct spi_driver wl1271_spi_driver = { .driver = { .name = "wl1271_spi", - .bus = &spi_bus_type, .owner = THIS_MODULE, }, -- cgit v1.2.3 From 090891fb2c68eecf95c18c8ba117fc850d21abf8 Mon Sep 17 00:00:00 2001 From: Veli-Pekka Peltola Date: Thu, 24 Nov 2011 21:35:28 +0200 Subject: hostap_cs: add ID for Canon K30225 Signed-off-by: Veli-Pekka Peltola Signed-off-by: John W. Linville --- drivers/net/wireless/hostap/hostap_cs.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c index 5441ad195119..89e9d3a78c3c 100644 --- a/drivers/net/wireless/hostap/hostap_cs.c +++ b/drivers/net/wireless/hostap/hostap_cs.c @@ -655,6 +655,9 @@ static const struct pcmcia_device_id hostap_cs_ids[] = { PCMCIA_DEVICE_PROD_ID123( "Addtron", "AWP-100 Wireless PCMCIA", "Version 01.02", 0xe6ec52ce, 0x08649af2, 0x4b74baa0), + PCMCIA_DEVICE_PROD_ID123( + "Canon", "Wireless LAN CF Card K30225", "Version 01.00", + 0x96ef6fe2, 0x263fcbab, 0xa57adb8c), PCMCIA_DEVICE_PROD_ID123( "D", "Link DWL-650 11Mbps WLAN Card", "Version 01.02", 0x71b18589, 0xb6f1b0ab, 0x4b74baa0), -- cgit v1.2.3 From 7ff7c82ee4339af277cface9071f81c5c10a9283 Mon Sep 17 00:00:00 2001 From: Nick Kossifidis Date: Fri, 25 Nov 2011 20:40:20 +0200 Subject: ath5k: Switch from read-and-clear to write-to-clear method when handling PISR/SISR registers Since card has 12 tx queues and we want to keep track of the interrupts per queue we can't fit all these interrupt bits on a single register. So we have 5 registers, the primary interrupt status register (PISR) and the 4 secondary interupt status registers (SISRs). In order to be able to read them all at once (atomic operation) Atheros introduced the Read-And-Clear registers to make things easier. So when reading RAC_PISR register, hw does a read on PISR and all SISRs, returns the value of PISR, copies all SISR values to their shadow copies (RAC_SISRx) and clears PISR and SISRs. This saves us from reading PISR/SISRs in a sequence. So far we 've used this approach and MadWiFi/Windows driver etc also used it for years. It turns out this operation is not atomic after all (at least not on all cards) That means it's possible to loose some interrupts because they came after the copy step and hw cleared them on the clean step ! That's probably the reason we got missed beacons, got stuck queues etc and couldn't figure out what was going on. With this patch we switch from RaC operation to an alternative method (that makes more sense IMHO anyway, I just chose to be on the safe side so far). Instead of reading RAC registers, we read the normal PISR/SISR registers and clear any bits we got by writing them back on the register. This will clear only the bits we got on our read step and leave any new bits unaffected (at least that's what docs say). So if any new interrupts come up we won't miss it. I've tested this with an AR5213 and an AR2425 and it seems O.K. Many thanks to Adrian Chadd for debuging this and reviewing the patch ! v2: Make sure we don't clear PISR bits that map to SISR generated interrupts (added a comment on the code for this) Signed-off-by: Nick Kossifidis Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath5k/ath5k.h | 8 +- drivers/net/wireless/ath/ath5k/base.c | 2 +- drivers/net/wireless/ath/ath5k/dma.c | 245 +++++++++++++++++++++------------ drivers/net/wireless/ath/ath5k/reg.h | 27 +++- 4 files changed, 189 insertions(+), 93 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h index fecbcd9a4259..0f42a5792ca0 100644 --- a/drivers/net/wireless/ath/ath5k/ath5k.h +++ b/drivers/net/wireless/ath/ath5k/ath5k.h @@ -1187,7 +1187,13 @@ struct ath5k_hw { u32 ah_txq_imr_cbrurn; u32 ah_txq_imr_qtrig; u32 ah_txq_imr_nofrm; - u32 ah_txq_isr; + + u32 ah_txq_isr_txok_all; + u32 ah_txq_isr_txurn; + u32 ah_txq_isr_qcborn; + u32 ah_txq_isr_qcburn; + u32 ah_txq_isr_qtrig; + u32 *ah_rf_banks; size_t ah_rf_banks_size; size_t ah_rf_regs_count; diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c index b346d0492001..c18d31008978 100644 --- a/drivers/net/wireless/ath/ath5k/base.c +++ b/drivers/net/wireless/ath/ath5k/base.c @@ -1689,7 +1689,7 @@ ath5k_tasklet_tx(unsigned long data) struct ath5k_hw *ah = (void *)data; for (i = 0; i < AR5K_NUM_TX_QUEUES; i++) - if (ah->txqs[i].setup && (ah->ah_txq_isr & BIT(i))) + if (ah->txqs[i].setup && (ah->ah_txq_isr_txok_all & BIT(i))) ath5k_tx_processq(ah, &ah->txqs[i]); ah->tx_pending = false; diff --git a/drivers/net/wireless/ath/ath5k/dma.c b/drivers/net/wireless/ath/ath5k/dma.c index 2481f9c7f4b6..b5db6e78f88e 100644 --- a/drivers/net/wireless/ath/ath5k/dma.c +++ b/drivers/net/wireless/ath/ath5k/dma.c @@ -450,7 +450,6 @@ int ath5k_hw_set_txdp(struct ath5k_hw *ah, unsigned int queue, u32 phys_addr) * * XXX: Link this with tx DMA size ? * XXX: Use it to save interrupts ? - * TODO: Needs testing, i think it's related to bmiss... */ int ath5k_hw_update_tx_triglevel(struct ath5k_hw *ah, bool increase) { @@ -523,62 +522,161 @@ bool ath5k_hw_is_intr_pending(struct ath5k_hw *ah) * being mapped on some standard non hw-specific positions * (check out &ath5k_int). * - * NOTE: We use read-and-clear register, so after this function is called ISR - * is zeroed. + * NOTE: We do write-to-clear, so the active PISR/SISR bits at the time this + * function gets called are cleared on return. */ int ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask) { - u32 data; + u32 data = 0; /* - * Read interrupt status from the Interrupt Status register - * on 5210 + * Read interrupt status from Primary Interrupt + * Register. + * + * Note: PISR/SISR Not available on 5210 */ if (ah->ah_version == AR5K_AR5210) { - data = ath5k_hw_reg_read(ah, AR5K_ISR); - if (unlikely(data == AR5K_INT_NOCARD)) { - *interrupt_mask = data; + u32 isr = 0; + isr = ath5k_hw_reg_read(ah, AR5K_ISR); + if (unlikely(isr == AR5K_INT_NOCARD)) { + *interrupt_mask = isr; return -ENODEV; } - } else { + /* - * Read interrupt status from Interrupt - * Status Register shadow copy (Read And Clear) - * - * Note: PISR/SISR Not available on 5210 + * Filter out the non-common bits from the interrupt + * status. */ - data = ath5k_hw_reg_read(ah, AR5K_RAC_PISR); - if (unlikely(data == AR5K_INT_NOCARD)) { - *interrupt_mask = data; + *interrupt_mask = (isr & AR5K_INT_COMMON) & ah->ah_imr; + + /* Hanlde INT_FATAL */ + if (unlikely(isr & (AR5K_ISR_SSERR | AR5K_ISR_MCABT + | AR5K_ISR_DPERR))) + *interrupt_mask |= AR5K_INT_FATAL; + + /* + * XXX: BMISS interrupts may occur after association. + * I found this on 5210 code but it needs testing. If this is + * true we should disable them before assoc and re-enable them + * after a successful assoc + some jiffies. + interrupt_mask &= ~AR5K_INT_BMISS; + */ + + data = isr; + } else { + u32 pisr = 0; + u32 pisr_clear = 0; + u32 sisr0 = 0; + u32 sisr1 = 0; + u32 sisr2 = 0; + u32 sisr3 = 0; + u32 sisr4 = 0; + + /* Read PISR and SISRs... */ + pisr = ath5k_hw_reg_read(ah, AR5K_PISR); + if (unlikely(pisr == AR5K_INT_NOCARD)) { + *interrupt_mask = pisr; return -ENODEV; } - } - /* - * Get abstract interrupt mask (driver-compatible) - */ - *interrupt_mask = (data & AR5K_INT_COMMON) & ah->ah_imr; + sisr0 = ath5k_hw_reg_read(ah, AR5K_SISR0); + sisr1 = ath5k_hw_reg_read(ah, AR5K_SISR1); + sisr2 = ath5k_hw_reg_read(ah, AR5K_SISR2); + sisr3 = ath5k_hw_reg_read(ah, AR5K_SISR3); + sisr4 = ath5k_hw_reg_read(ah, AR5K_SISR4); - if (ah->ah_version != AR5K_AR5210) { - u32 sisr2 = ath5k_hw_reg_read(ah, AR5K_RAC_SISR2); + /* + * PISR holds the logical OR of interrupt bits + * from SISR registers: + * + * TXOK and TXDESC -> Logical OR of TXOK and TXDESC + * per-queue bits on SISR0 + * + * TXERR and TXEOL -> Logical OR of TXERR and TXEOL + * per-queue bits on SISR1 + * + * TXURN -> Logical OR of TXURN per-queue bits on SISR2 + * + * HIUERR -> Logical OR of MCABT, SSERR and DPER bits on SISR2 + * + * BCNMISC -> Logical OR of TIM, CAB_END, DTIM_SYNC + * BCN_TIMEOUT, CAB_TIMEOUT and DTIM + * (and TSFOOR ?) bits on SISR2 + * + * QCBRORN and QCBRURN -> Logical OR of QCBRORN and + * QCBRURN per-queue bits on SISR3 + * QTRIG -> Logical OR of QTRIG per-queue bits on SISR4 + * + * If we clean these bits on PISR we 'll also clear all + * related bits from SISRs, e.g. if we write the TXOK bit on + * PISR we 'll clean all TXOK bits from SISR0 so if a new TXOK + * interrupt got fired for another queue while we were reading + * the interrupt registers and we write back the TXOK bit on + * PISR we 'll lose it. So make sure that we don't write back + * on PISR any bits that come from SISRs. Clearing them from + * SISRs will also clear PISR so no need to worry here. + */ - /*HIU = Host Interface Unit (PCI etc)*/ - if (unlikely(data & (AR5K_ISR_HIUERR))) - *interrupt_mask |= AR5K_INT_FATAL; + pisr_clear = pisr & ~AR5K_ISR_BITS_FROM_SISRS; - /*Beacon Not Ready*/ - if (unlikely(data & (AR5K_ISR_BNR))) - *interrupt_mask |= AR5K_INT_BNR; + /* + * Write to clear them... + * Note: This means that each bit we write back + * to the registers will get cleared, leaving the + * rest unaffected. So this won't affect new interrupts + * we didn't catch while reading/processing, we 'll get + * them next time get_isr gets called. + */ + ath5k_hw_reg_write(ah, sisr0, AR5K_SISR0); + ath5k_hw_reg_write(ah, sisr1, AR5K_SISR1); + ath5k_hw_reg_write(ah, sisr2, AR5K_SISR2); + ath5k_hw_reg_write(ah, sisr3, AR5K_SISR3); + ath5k_hw_reg_write(ah, sisr4, AR5K_SISR4); + ath5k_hw_reg_write(ah, pisr_clear, AR5K_PISR); + /* Flush previous write */ + ath5k_hw_reg_read(ah, AR5K_PISR); - if (unlikely(sisr2 & (AR5K_SISR2_SSERR | - AR5K_SISR2_DPERR | - AR5K_SISR2_MCABT))) - *interrupt_mask |= AR5K_INT_FATAL; + /* + * Filter out the non-common bits from the interrupt + * status. + */ + *interrupt_mask = (pisr & AR5K_INT_COMMON) & ah->ah_imr; + + + /* We treat TXOK,TXDESC, TXERR and TXEOL + * the same way (schedule the tx tasklet) + * so we track them all together per queue */ + if (pisr & AR5K_ISR_TXOK) + ah->ah_txq_isr_txok_all |= AR5K_REG_MS(sisr0, + AR5K_SISR0_QCU_TXOK); + + if (pisr & AR5K_ISR_TXDESC) + ah->ah_txq_isr_txok_all |= AR5K_REG_MS(sisr0, + AR5K_SISR0_QCU_TXDESC); - if (data & AR5K_ISR_TIM) + if (pisr & AR5K_ISR_TXERR) + ah->ah_txq_isr_txok_all |= AR5K_REG_MS(sisr1, + AR5K_SISR1_QCU_TXERR); + + if (pisr & AR5K_ISR_TXEOL) + ah->ah_txq_isr_txok_all |= AR5K_REG_MS(sisr1, + AR5K_SISR1_QCU_TXEOL); + + /* Currently this is not much usefull since we treat + * all queues the same way if we get a TXURN (update + * tx trigger level) but we might need it later on*/ + if (pisr & AR5K_ISR_TXURN) + ah->ah_txq_isr_txurn |= AR5K_REG_MS(sisr2, + AR5K_SISR2_QCU_TXURN); + + /* Misc Beacon related interrupts */ + + /* For AR5211 */ + if (pisr & AR5K_ISR_TIM) *interrupt_mask |= AR5K_INT_TIM; - if (data & AR5K_ISR_BCNMISC) { + /* For AR5212+ */ + if (pisr & AR5K_ISR_BCNMISC) { if (sisr2 & AR5K_SISR2_TIM) *interrupt_mask |= AR5K_INT_TIM; if (sisr2 & AR5K_SISR2_DTIM) @@ -591,63 +689,40 @@ int ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask) *interrupt_mask |= AR5K_INT_CAB_TIMEOUT; } - if (data & AR5K_ISR_RXDOPPLER) + /* Below interrupts are unlikely to happen */ + + /* HIU = Host Interface Unit (PCI etc) + * Can be one of MCABT, SSERR, DPERR from SISR2 */ + if (unlikely(pisr & (AR5K_ISR_HIUERR))) + *interrupt_mask |= AR5K_INT_FATAL; + + + /*Beacon Not Ready*/ + if (unlikely(pisr & (AR5K_ISR_BNR))) + *interrupt_mask |= AR5K_INT_BNR; + + if (unlikely(pisr & (AR5K_ISR_RXDOPPLER))) *interrupt_mask |= AR5K_INT_RX_DOPPLER; - if (data & AR5K_ISR_QCBRORN) { + + if (unlikely(pisr & (AR5K_ISR_QCBRORN))) { *interrupt_mask |= AR5K_INT_QCBRORN; - ah->ah_txq_isr |= AR5K_REG_MS( - ath5k_hw_reg_read(ah, AR5K_RAC_SISR3), - AR5K_SISR3_QCBRORN); + ah->ah_txq_isr_qcborn |= AR5K_REG_MS(sisr3, + AR5K_SISR3_QCBRORN); } - if (data & AR5K_ISR_QCBRURN) { + + if (unlikely(pisr & (AR5K_ISR_QCBRURN))) { *interrupt_mask |= AR5K_INT_QCBRURN; - ah->ah_txq_isr |= AR5K_REG_MS( - ath5k_hw_reg_read(ah, AR5K_RAC_SISR3), - AR5K_SISR3_QCBRURN); + ah->ah_txq_isr_qcburn |= AR5K_REG_MS(sisr3, + AR5K_SISR3_QCBRURN); } - if (data & AR5K_ISR_QTRIG) { + + if (unlikely(pisr & (AR5K_ISR_QTRIG))) { *interrupt_mask |= AR5K_INT_QTRIG; - ah->ah_txq_isr |= AR5K_REG_MS( - ath5k_hw_reg_read(ah, AR5K_RAC_SISR4), - AR5K_SISR4_QTRIG); + ah->ah_txq_isr_qtrig |= AR5K_REG_MS(sisr4, + AR5K_SISR4_QTRIG); } - if (data & AR5K_ISR_TXOK) - ah->ah_txq_isr |= AR5K_REG_MS( - ath5k_hw_reg_read(ah, AR5K_RAC_SISR0), - AR5K_SISR0_QCU_TXOK); - - if (data & AR5K_ISR_TXDESC) - ah->ah_txq_isr |= AR5K_REG_MS( - ath5k_hw_reg_read(ah, AR5K_RAC_SISR0), - AR5K_SISR0_QCU_TXDESC); - - if (data & AR5K_ISR_TXERR) - ah->ah_txq_isr |= AR5K_REG_MS( - ath5k_hw_reg_read(ah, AR5K_RAC_SISR1), - AR5K_SISR1_QCU_TXERR); - - if (data & AR5K_ISR_TXEOL) - ah->ah_txq_isr |= AR5K_REG_MS( - ath5k_hw_reg_read(ah, AR5K_RAC_SISR1), - AR5K_SISR1_QCU_TXEOL); - - if (data & AR5K_ISR_TXURN) - ah->ah_txq_isr |= AR5K_REG_MS( - ath5k_hw_reg_read(ah, AR5K_RAC_SISR2), - AR5K_SISR2_QCU_TXURN); - } else { - if (unlikely(data & (AR5K_ISR_SSERR | AR5K_ISR_MCABT - | AR5K_ISR_HIUERR | AR5K_ISR_DPERR))) - *interrupt_mask |= AR5K_INT_FATAL; - - /* - * XXX: BMISS interrupts may occur after association. - * I found this on 5210 code but it needs testing. If this is - * true we should disable them before assoc and re-enable them - * after a successful assoc + some jiffies. - interrupt_mask &= ~AR5K_INT_BMISS; - */ + data = pisr; } /* diff --git a/drivers/net/wireless/ath/ath5k/reg.h b/drivers/net/wireless/ath/ath5k/reg.h index f5c1000045d3..0ea1608b47fd 100644 --- a/drivers/net/wireless/ath/ath5k/reg.h +++ b/drivers/net/wireless/ath/ath5k/reg.h @@ -280,6 +280,10 @@ * 5211/5212 we have one primary and 4 secondary registers. * So we have AR5K_ISR for 5210 and AR5K_PISR /SISRx for 5211/5212. * Most of these bits are common for all chipsets. + * + * NOTE: On 5211+ TXOK, TXDESC, TXERR, TXEOL and TXURN contain + * the logical OR from per-queue interrupt bits found on SISR registers + * (see below). */ #define AR5K_ISR 0x001c /* Register Address [5210] */ #define AR5K_PISR 0x0080 /* Register Address [5211+] */ @@ -292,7 +296,10 @@ #define AR5K_ISR_TXOK 0x00000040 /* Frame successfully transmitted */ #define AR5K_ISR_TXDESC 0x00000080 /* TX descriptor request */ #define AR5K_ISR_TXERR 0x00000100 /* Transmit error */ -#define AR5K_ISR_TXNOFRM 0x00000200 /* No frame transmitted (transmit timeout) */ +#define AR5K_ISR_TXNOFRM 0x00000200 /* No frame transmitted (transmit timeout) + * NOTE: We don't have per-queue info for this + * one, but we can enable it per-queue through + * TXNOFRM_QCU field on TXNOFRM register */ #define AR5K_ISR_TXEOL 0x00000400 /* Empty TX descriptor */ #define AR5K_ISR_TXURN 0x00000800 /* Transmit FIFO underrun */ #define AR5K_ISR_MIB 0x00001000 /* Update MIB counters */ @@ -302,21 +309,29 @@ #define AR5K_ISR_SWBA 0x00010000 /* Software beacon alert */ #define AR5K_ISR_BRSSI 0x00020000 /* Beacon rssi below threshold (?) */ #define AR5K_ISR_BMISS 0x00040000 /* Beacon missed */ -#define AR5K_ISR_HIUERR 0x00080000 /* Host Interface Unit error [5211+] */ +#define AR5K_ISR_HIUERR 0x00080000 /* Host Interface Unit error [5211+] + * 'or' of MCABT, SSERR, DPERR from SISR2 */ #define AR5K_ISR_BNR 0x00100000 /* Beacon not ready [5211+] */ #define AR5K_ISR_MCABT 0x00100000 /* Master Cycle Abort [5210] */ #define AR5K_ISR_RXCHIRP 0x00200000 /* CHIRP Received [5212+] */ #define AR5K_ISR_SSERR 0x00200000 /* Signaled System Error [5210] */ -#define AR5K_ISR_DPERR 0x00400000 /* Det par Error (?) [5210] */ +#define AR5K_ISR_DPERR 0x00400000 /* Bus parity error [5210] */ #define AR5K_ISR_RXDOPPLER 0x00400000 /* Doppler chirp received [5212+] */ #define AR5K_ISR_TIM 0x00800000 /* [5211+] */ -#define AR5K_ISR_BCNMISC 0x00800000 /* 'or' of TIM, CAB_END, DTIM_SYNC, BCN_TIMEOUT, - CAB_TIMEOUT and DTIM bits from SISR2 [5212+] */ +#define AR5K_ISR_BCNMISC 0x00800000 /* Misc beacon related interrupt + * 'or' of TIM, CAB_END, DTIM_SYNC, BCN_TIMEOUT, + * CAB_TIMEOUT and DTIM bits from SISR2 [5212+] */ #define AR5K_ISR_GPIO 0x01000000 /* GPIO (rf kill) */ #define AR5K_ISR_QCBRORN 0x02000000 /* QCU CBR overrun [5211+] */ #define AR5K_ISR_QCBRURN 0x04000000 /* QCU CBR underrun [5211+] */ #define AR5K_ISR_QTRIG 0x08000000 /* QCU scheduling trigger [5211+] */ +#define AR5K_ISR_BITS_FROM_SISRS (AR5K_ISR_TXOK | AR5K_ISR_TXDESC |\ + AR5K_ISR_TXERR | AR5K_ISR_TXEOL |\ + AR5K_ISR_TXURN | AR5K_ISR_HIUERR |\ + AR5K_ISR_BCNMISC | AR5K_ISR_QCBRORN |\ + AR5K_ISR_QCBRURN | AR5K_ISR_QTRIG) + /* * Secondary status registers [5211+] (0 - 4) * @@ -347,7 +362,7 @@ #define AR5K_SISR2_BCN_TIMEOUT 0x08000000 /* Beacon Timeout [5212+] */ #define AR5K_SISR2_CAB_TIMEOUT 0x10000000 /* CAB Timeout [5212+] */ #define AR5K_SISR2_DTIM 0x20000000 /* [5212+] */ -#define AR5K_SISR2_TSFOOR 0x80000000 /* TSF OOR (?) */ +#define AR5K_SISR2_TSFOOR 0x80000000 /* TSF Out of range */ #define AR5K_SISR3 0x0090 /* Register Address [5211+] */ #define AR5K_SISR3_QCBRORN 0x000003ff /* Mask for QCBRORN */ -- cgit v1.2.3 From fea9480786c0fc41901bddb9819dd036527a9e10 Mon Sep 17 00:00:00 2001 From: Nick Kossifidis Date: Fri, 25 Nov 2011 20:40:21 +0200 Subject: ath5k: Add TXNOFRM to INT_TX_ALL Add TXNOFRM to INT_TX_ALL since it's a TX interrupt too. Signed-off-by: Nick Kossifidis Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath5k/ath5k.h | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h index 0f42a5792ca0..b8abdbcfb7b6 100644 --- a/drivers/net/wireless/ath/ath5k/ath5k.h +++ b/drivers/net/wireless/ath/ath5k/ath5k.h @@ -856,6 +856,7 @@ enum ath5k_int { AR5K_INT_TX_ALL = AR5K_INT_TXOK | AR5K_INT_TXDESC | AR5K_INT_TXERR + | AR5K_INT_TXNOFRM | AR5K_INT_TXEOL | AR5K_INT_TXURN, -- cgit v1.2.3 From 34ce644aa8342f95eb1e187178f83febade4af37 Mon Sep 17 00:00:00 2001 From: Nick Kossifidis Date: Fri, 25 Nov 2011 20:40:22 +0200 Subject: ath5k: Cleanups v1 No functional changes, just a few comments/documentation/cleanup Signed-off-by: Nick Kossifidis Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath5k/base.c | 112 +++++++++++++++++++++++++--------- drivers/net/wireless/ath/ath5k/dma.c | 17 ++++-- 2 files changed, 96 insertions(+), 33 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c index c18d31008978..47194a4e3652 100644 --- a/drivers/net/wireless/ath/ath5k/base.c +++ b/drivers/net/wireless/ath/ath5k/base.c @@ -2149,69 +2149,110 @@ ath5k_intr(int irq, void *dev_id) enum ath5k_int status; unsigned int counter = 1000; + + /* + * If hw is not ready (or detached) and we get an + * interrupt, or if we have no interrupts pending + * (that means it's not for us) skip it. + * + * NOTE: Group 0/1 PCI interface registers are not + * supported on WiSOCs, so we can't check for pending + * interrupts (ISR belongs to another register group + * so we are ok). + */ if (unlikely(test_bit(ATH_STAT_INVALID, ah->status) || - ((ath5k_get_bus_type(ah) != ATH_AHB) && - !ath5k_hw_is_intr_pending(ah)))) + ((ath5k_get_bus_type(ah) != ATH_AHB) && + !ath5k_hw_is_intr_pending(ah)))) return IRQ_NONE; + /** Main loop **/ do { - ath5k_hw_get_isr(ah, &status); /* NB: clears IRQ too */ + ath5k_hw_get_isr(ah, &status); /* NB: clears IRQ too */ + ATH5K_DBG(ah, ATH5K_DEBUG_INTR, "status 0x%x/0x%x\n", status, ah->imask); + + /* + * Fatal hw error -> Log and reset + * + * Fatal errors are unrecoverable so we have to + * reset the card. These errors include bus and + * dma errors. + */ if (unlikely(status & AR5K_INT_FATAL)) { - /* - * Fatal errors are unrecoverable. - * Typically these are caused by DMA errors. - */ + ATH5K_DBG(ah, ATH5K_DEBUG_RESET, "fatal int, resetting\n"); ieee80211_queue_work(ah->hw, &ah->reset_work); + + /* + * RX Overrun -> Count and reset if needed + * + * Receive buffers are full. Either the bus is busy or + * the CPU is not fast enough to process all received + * frames. + */ } else if (unlikely(status & AR5K_INT_RXORN)) { + /* - * Receive buffers are full. Either the bus is busy or - * the CPU is not fast enough to process all received - * frames. * Older chipsets need a reset to come out of this * condition, but we treat it as RX for newer chips. - * We don't know exactly which versions need a reset - + * We don't know exactly which versions need a reset * this guess is copied from the HAL. */ ah->stats.rxorn_intr++; + if (ah->ah_mac_srev < AR5K_SREV_AR5212) { ATH5K_DBG(ah, ATH5K_DEBUG_RESET, "rx overrun, resetting\n"); ieee80211_queue_work(ah->hw, &ah->reset_work); } else ath5k_schedule_rx(ah); + } else { + + /* Software Beacon Alert -> Schedule beacon tasklet */ if (status & AR5K_INT_SWBA) tasklet_hi_schedule(&ah->beacontq); - if (status & AR5K_INT_RXEOL) { - /* - * NB: the hardware should re-read the link when - * RXE bit is written, but it doesn't work at - * least on older hardware revs. - */ + /* + * No more RX descriptors -> Just count + * + * NB: the hardware should re-read the link when + * RXE bit is written, but it doesn't work at + * least on older hardware revs. + */ + if (status & AR5K_INT_RXEOL) ah->stats.rxeol_intr++; - } - if (status & AR5K_INT_TXURN) { - /* bump tx trigger level */ + + + /* TX Underrun -> Bump tx trigger level */ + if (status & AR5K_INT_TXURN) ath5k_hw_update_tx_triglevel(ah, true); - } + + /* RX -> Schedule rx tasklet */ if (status & (AR5K_INT_RXOK | AR5K_INT_RXERR)) ath5k_schedule_rx(ah); - if (status & (AR5K_INT_TXOK | AR5K_INT_TXDESC - | AR5K_INT_TXERR | AR5K_INT_TXEOL)) + + /* TX -> Schedule tx tasklet */ + if (status & (AR5K_INT_TXOK + | AR5K_INT_TXDESC + | AR5K_INT_TXERR + | AR5K_INT_TXEOL)) ath5k_schedule_tx(ah); - if (status & AR5K_INT_BMISS) { - /* TODO */ - } + + /* Missed beacon -> TODO + if (status & AR5K_INT_BMISS) + */ + + /* MIB event -> Update counters and notify ANI */ if (status & AR5K_INT_MIB) { ah->stats.mib_intr++; ath5k_hw_update_mib_counters(ah); ath5k_ani_mib_intr(ah); } + + /* GPIO -> Notify RFKill layer */ if (status & AR5K_INT_GPIO) tasklet_schedule(&ah->rf_kill.toggleq); @@ -2222,12 +2263,19 @@ ath5k_intr(int irq, void *dev_id) } while (ath5k_hw_is_intr_pending(ah) && --counter > 0); + /* + * Until we handle rx/tx interrupts mask them on IMR + * + * NOTE: ah->(rx/tx)_pending are set when scheduling the tasklets + * and unset after we 've handled the interrupts. + */ if (ah->rx_pending || ah->tx_pending) ath5k_set_current_imask(ah); if (unlikely(!counter)) ATH5K_WARN(ah, "too many interrupts, giving up for now\n"); + /* Fire up calibration poll */ ath5k_intr_calibration_poll(ah); return IRQ_HANDLED; @@ -2544,9 +2592,15 @@ int ath5k_start(struct ieee80211_hw *hw) * and then setup of the interrupt mask. */ ah->curchan = ah->hw->conf.channel; - ah->imask = AR5K_INT_RXOK | AR5K_INT_RXERR | AR5K_INT_RXEOL | - AR5K_INT_RXORN | AR5K_INT_TXDESC | AR5K_INT_TXEOL | - AR5K_INT_FATAL | AR5K_INT_GLOBAL | AR5K_INT_MIB; + ah->imask = AR5K_INT_RXOK + | AR5K_INT_RXERR + | AR5K_INT_RXEOL + | AR5K_INT_RXORN + | AR5K_INT_TXDESC + | AR5K_INT_TXEOL + | AR5K_INT_FATAL + | AR5K_INT_GLOBAL + | AR5K_INT_MIB; ret = ath5k_reset(ah, NULL, false); if (ret) diff --git a/drivers/net/wireless/ath/ath5k/dma.c b/drivers/net/wireless/ath/ath5k/dma.c index b5db6e78f88e..97864d88d181 100644 --- a/drivers/net/wireless/ath/ath5k/dma.c +++ b/drivers/net/wireless/ath/ath5k/dma.c @@ -701,21 +701,25 @@ int ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask) if (unlikely(pisr & (AR5K_ISR_BNR))) *interrupt_mask |= AR5K_INT_BNR; + /* Doppler chirp received */ if (unlikely(pisr & (AR5K_ISR_RXDOPPLER))) *interrupt_mask |= AR5K_INT_RX_DOPPLER; + /* A queue got CBR overrun */ if (unlikely(pisr & (AR5K_ISR_QCBRORN))) { *interrupt_mask |= AR5K_INT_QCBRORN; ah->ah_txq_isr_qcborn |= AR5K_REG_MS(sisr3, AR5K_SISR3_QCBRORN); } + /* A queue got CBR underrun */ if (unlikely(pisr & (AR5K_ISR_QCBRURN))) { *interrupt_mask |= AR5K_INT_QCBRURN; ah->ah_txq_isr_qcburn |= AR5K_REG_MS(sisr3, AR5K_SISR3_QCBRURN); } + /* A queue got triggered */ if (unlikely(pisr & (AR5K_ISR_QTRIG))) { *interrupt_mask |= AR5K_INT_QTRIG; ah->ah_txq_isr_qtrig |= AR5K_REG_MS(sisr4, @@ -772,16 +776,14 @@ enum ath5k_int ath5k_hw_set_imr(struct ath5k_hw *ah, enum ath5k_int new_mask) u32 simr2 = ath5k_hw_reg_read(ah, AR5K_SIMR2) & AR5K_SIMR2_QCU_TXURN; + /* Fatal interrupt abstraction for 5211+ */ if (new_mask & AR5K_INT_FATAL) { int_mask |= AR5K_IMR_HIUERR; simr2 |= (AR5K_SIMR2_MCABT | AR5K_SIMR2_SSERR | AR5K_SIMR2_DPERR); } - /*Beacon Not Ready*/ - if (new_mask & AR5K_INT_BNR) - int_mask |= AR5K_INT_BNR; - + /* Misc beacon related interrupts */ if (new_mask & AR5K_INT_TIM) int_mask |= AR5K_IMR_TIM; @@ -796,6 +798,11 @@ enum ath5k_int ath5k_hw_set_imr(struct ath5k_hw *ah, enum ath5k_int new_mask) if (new_mask & AR5K_INT_CAB_TIMEOUT) simr2 |= AR5K_SISR2_CAB_TIMEOUT; + /*Beacon Not Ready*/ + if (new_mask & AR5K_INT_BNR) + int_mask |= AR5K_INT_BNR; + + /* RX doppler chirp */ if (new_mask & AR5K_INT_RX_DOPPLER) int_mask |= AR5K_IMR_RXDOPPLER; @@ -805,10 +812,12 @@ enum ath5k_int ath5k_hw_set_imr(struct ath5k_hw *ah, enum ath5k_int new_mask) ath5k_hw_reg_write(ah, simr2, AR5K_SIMR2); } else { + /* Fatal interrupt abstraction for 5210 */ if (new_mask & AR5K_INT_FATAL) int_mask |= (AR5K_IMR_SSERR | AR5K_IMR_MCABT | AR5K_IMR_HIUERR | AR5K_IMR_DPERR); + /* Only common interrupts left for 5210 (no SIMRs) */ ath5k_hw_reg_write(ah, int_mask, AR5K_IMR); } -- cgit v1.2.3 From ce169aca0d823d38465127023e3d571816e6666c Mon Sep 17 00:00:00 2001 From: Nick Kossifidis Date: Fri, 25 Nov 2011 20:40:23 +0200 Subject: ath5k: Calibration re-work Noise floor calibration does not interfere with traffic and should run more often as part of our "short calibration". The full calibration is not the noise floor calibration but the AGC + Gain_F (on RF5111 and RF5112) calibration and should run less often because it does interfere with traffic. So Short calibration -> I/Q & NF Calibration Long calibration -> Short + AGC + Gain_F This patch was for some time on my pub/ dir on www.kernel.org and has been tested by a few people and me. I think it's O.K. to go in. I also changed ah_calibration to ah_iq_cal_needed to make more sense. v2 Use a workqueue instead of a tasklet for calibration Signed-off-by: Nick Kossifidis Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath5k/ath5k.h | 15 +++-- drivers/net/wireless/ath/ath5k/base.c | 112 +++++++++++++++++++++++---------- drivers/net/wireless/ath/ath5k/phy.c | 82 ++++++++++++++++++------ 3 files changed, 147 insertions(+), 62 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h index b8abdbcfb7b6..3e75d029b0a3 100644 --- a/drivers/net/wireless/ath/ath5k/ath5k.h +++ b/drivers/net/wireless/ath/ath5k/ath5k.h @@ -187,10 +187,9 @@ #define AR5K_TUNE_MAX_TXPOWER 63 #define AR5K_TUNE_DEFAULT_TXPOWER 25 #define AR5K_TUNE_TPC_TXPOWER false -#define ATH5K_TUNE_CALIBRATION_INTERVAL_FULL 10000 /* 10 sec */ +#define ATH5K_TUNE_CALIBRATION_INTERVAL_FULL 60000 /* 60 sec */ +#define ATH5K_TUNE_CALIBRATION_INTERVAL_SHORT 10000 /* 10 sec */ #define ATH5K_TUNE_CALIBRATION_INTERVAL_ANI 1000 /* 1 sec */ -#define ATH5K_TUNE_CALIBRATION_INTERVAL_NF 60000 /* 60 sec */ - #define ATH5K_TX_COMPLETE_POLL_INT 3000 /* 3 sec */ #define AR5K_INIT_CARR_SENSE_EN 1 @@ -896,7 +895,8 @@ enum ath5k_int { enum ath5k_calibration_mask { AR5K_CALIBRATION_FULL = 0x01, AR5K_CALIBRATION_SHORT = 0x02, - AR5K_CALIBRATION_ANI = 0x04, + AR5K_CALIBRATION_NF = 0x04, + AR5K_CALIBRATION_ANI = 0x08, }; /* @@ -1098,6 +1098,7 @@ struct ath5k_hw { led_on; /* pin setting for LED on */ struct work_struct reset_work; /* deferred chip reset */ + struct work_struct calib_work; /* deferred phy calibration */ struct list_head rxbuf; /* receive buffer */ spinlock_t rxbuflock; @@ -1114,8 +1115,6 @@ struct ath5k_hw { struct ath5k_rfkill rf_kill; - struct tasklet_struct calib; /* calibration tasklet */ - spinlock_t block; /* protects beacon */ struct tasklet_struct beacontq; /* beacon intr tasklet */ struct list_head bcbuf; /* beacon buffer */ @@ -1145,7 +1144,7 @@ struct ath5k_hw { enum ath5k_int ah_imr; struct ieee80211_channel *ah_current_channel; - bool ah_calibration; + bool ah_iq_cal_needed; bool ah_single_chip; enum ath5k_version ah_version; @@ -1235,8 +1234,8 @@ struct ath5k_hw { /* Calibration timestamp */ unsigned long ah_cal_next_full; + unsigned long ah_cal_next_short; unsigned long ah_cal_next_ani; - unsigned long ah_cal_next_nf; /* Calibration mask */ u8 ah_cal_mask; diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c index 47194a4e3652..a8cb1c7f4bfe 100644 --- a/drivers/net/wireless/ath/ath5k/base.c +++ b/drivers/net/wireless/ath/ath5k/base.c @@ -2112,16 +2112,29 @@ static void ath5k_intr_calibration_poll(struct ath5k_hw *ah) { if (time_is_before_eq_jiffies(ah->ah_cal_next_ani) && - !(ah->ah_cal_mask & AR5K_CALIBRATION_FULL)) { - /* run ANI only when full calibration is not active */ + !(ah->ah_cal_mask & AR5K_CALIBRATION_FULL) && + !(ah->ah_cal_mask & AR5K_CALIBRATION_SHORT)) { + + /* Run ANI only when calibration is not active */ + ah->ah_cal_next_ani = jiffies + msecs_to_jiffies(ATH5K_TUNE_CALIBRATION_INTERVAL_ANI); tasklet_schedule(&ah->ani_tasklet); - } else if (time_is_before_eq_jiffies(ah->ah_cal_next_full)) { - ah->ah_cal_next_full = jiffies + - msecs_to_jiffies(ATH5K_TUNE_CALIBRATION_INTERVAL_FULL); - tasklet_schedule(&ah->calib); + } else if (time_is_before_eq_jiffies(ah->ah_cal_next_short) && + !(ah->ah_cal_mask & AR5K_CALIBRATION_FULL) && + !(ah->ah_cal_mask & AR5K_CALIBRATION_SHORT)) { + + /* Run calibration only when another calibration + * is not running. + * + * Note: This is for both full/short calibration, + * if it's time for a full one, ath5k_calibrate_work will deal + * with it. */ + + ah->ah_cal_next_short = jiffies + + msecs_to_jiffies(ATH5K_TUNE_CALIBRATION_INTERVAL_SHORT); + ieee80211_queue_work(ah->hw, &ah->calib_work); } /* we could use SWI to generate enough interrupts to meet our * calibration interval requirements, if necessary: @@ -2286,41 +2299,58 @@ ath5k_intr(int irq, void *dev_id) * for temperature/environment changes. */ static void -ath5k_tasklet_calibrate(unsigned long data) +ath5k_calibrate_work(struct work_struct *work) { - struct ath5k_hw *ah = (void *)data; + struct ath5k_hw *ah = container_of(work, struct ath5k_hw, + calib_work); + + /* Should we run a full calibration ? */ + if (time_is_before_eq_jiffies(ah->ah_cal_next_full)) { + + ah->ah_cal_next_full = jiffies + + msecs_to_jiffies(ATH5K_TUNE_CALIBRATION_INTERVAL_FULL); + ah->ah_cal_mask |= AR5K_CALIBRATION_FULL; + + ATH5K_DBG(ah, ATH5K_DEBUG_CALIBRATE, + "running full calibration\n"); + + if (ath5k_hw_gainf_calibrate(ah) == AR5K_RFGAIN_NEED_CHANGE) { + /* + * Rfgain is out of bounds, reset the chip + * to load new gain values. + */ + ATH5K_DBG(ah, ATH5K_DEBUG_RESET, + "got new rfgain, resetting\n"); + ieee80211_queue_work(ah->hw, &ah->reset_work); + } + + /* TODO: On full calibration we should stop TX here, + * so that it doesn't interfere (mostly due to gain_f + * calibration that messes with tx packets -see phy.c). + * + * NOTE: Stopping the queues from above is not enough + * to stop TX but saves us from disconecting (at least + * we don't lose packets). */ + ieee80211_stop_queues(ah->hw); + } else + ah->ah_cal_mask |= AR5K_CALIBRATION_SHORT; - /* Only full calibration for now */ - ah->ah_cal_mask |= AR5K_CALIBRATION_FULL; ATH5K_DBG(ah, ATH5K_DEBUG_CALIBRATE, "channel %u/%x\n", ieee80211_frequency_to_channel(ah->curchan->center_freq), ah->curchan->hw_value); - if (ath5k_hw_gainf_calibrate(ah) == AR5K_RFGAIN_NEED_CHANGE) { - /* - * Rfgain is out of bounds, reset the chip - * to load new gain values. - */ - ATH5K_DBG(ah, ATH5K_DEBUG_RESET, "calibration, resetting\n"); - ieee80211_queue_work(ah->hw, &ah->reset_work); - } if (ath5k_hw_phy_calibrate(ah, ah->curchan)) ATH5K_ERR(ah, "calibration of channel %u failed\n", ieee80211_frequency_to_channel( ah->curchan->center_freq)); - /* Noise floor calibration interrupts rx/tx path while I/Q calibration - * doesn't. - * TODO: We should stop TX here, so that it doesn't interfere. - * Note that stopping the queues is not enough to stop TX! */ - if (time_is_before_eq_jiffies(ah->ah_cal_next_nf)) { - ah->ah_cal_next_nf = jiffies + - msecs_to_jiffies(ATH5K_TUNE_CALIBRATION_INTERVAL_NF); - ath5k_hw_update_noise_floor(ah); - } - - ah->ah_cal_mask &= ~AR5K_CALIBRATION_FULL; + /* Clear calibration flags */ + if (ah->ah_cal_mask & AR5K_CALIBRATION_FULL) { + ieee80211_wake_queues(ah->hw); + ah->ah_cal_mask &= ~AR5K_CALIBRATION_FULL; + } else if (ah->ah_cal_mask & AR5K_CALIBRATION_SHORT) + ah->ah_cal_mask &= ~AR5K_CALIBRATION_SHORT; } @@ -2639,7 +2669,6 @@ static void ath5k_stop_tasklets(struct ath5k_hw *ah) ah->tx_pending = false; tasklet_kill(&ah->rxtq); tasklet_kill(&ah->txtq); - tasklet_kill(&ah->calib); tasklet_kill(&ah->beacontq); tasklet_kill(&ah->ani_tasklet); } @@ -2743,9 +2772,24 @@ ath5k_reset(struct ath5k_hw *ah, struct ieee80211_channel *chan, ath5k_ani_init(ah, ani_mode); - ah->ah_cal_next_full = jiffies + msecs_to_jiffies(100); - ah->ah_cal_next_ani = jiffies; - ah->ah_cal_next_nf = jiffies; + /* + * Set calibration intervals + * + * Note: We don't need to run calibration imediately + * since some initial calibration is done on reset + * even for fast channel switching. Also on scanning + * this will get set again and again and it won't get + * executed unless we connect somewhere and spend some + * time on the channel (that's what calibration needs + * anyway to be accurate). + */ + ah->ah_cal_next_full = jiffies + + msecs_to_jiffies(ATH5K_TUNE_CALIBRATION_INTERVAL_FULL); + ah->ah_cal_next_ani = jiffies + + msecs_to_jiffies(ATH5K_TUNE_CALIBRATION_INTERVAL_ANI); + ah->ah_cal_next_short = jiffies + + msecs_to_jiffies(ATH5K_TUNE_CALIBRATION_INTERVAL_SHORT); + ewma_init(&ah->ah_beacon_rssi_avg, 1024, 8); /* clear survey data and cycle counters */ @@ -2895,11 +2939,11 @@ ath5k_init(struct ieee80211_hw *hw) tasklet_init(&ah->rxtq, ath5k_tasklet_rx, (unsigned long)ah); tasklet_init(&ah->txtq, ath5k_tasklet_tx, (unsigned long)ah); - tasklet_init(&ah->calib, ath5k_tasklet_calibrate, (unsigned long)ah); tasklet_init(&ah->beacontq, ath5k_tasklet_beacon, (unsigned long)ah); tasklet_init(&ah->ani_tasklet, ath5k_tasklet_ani, (unsigned long)ah); INIT_WORK(&ah->reset_work, ath5k_reset_work); + INIT_WORK(&ah->calib_work, ath5k_calibrate_work); INIT_DELAYED_WORK(&ah->tx_complete_work, ath5k_tx_complete_poll_work); ret = ath5k_hw_common(ah)->bus_ops->eeprom_read_mac(ah, mac); diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c index 01cb72de44cb..ca4241d2a774 100644 --- a/drivers/net/wireless/ath/ath5k/phy.c +++ b/drivers/net/wireless/ath/ath5k/phy.c @@ -338,9 +338,6 @@ static void ath5k_hw_wait_for_synth(struct ath5k_hw *ah, * And this is the MadWiFi bug entry related to the above * http://madwifi-project.org/ticket/1659 * with various measurements and diagrams - * - * TODO: Deal with power drops due to probes by setting an appropriate - * tx power on the probe packets ! Make this part of the calibration process. */ /* Initialize ah_gain during attach */ @@ -372,10 +369,9 @@ int ath5k_hw_rfgain_opt_init(struct ath5k_hw *ah) * tx power and a Peak to Average Power Detector (PAPD) will try * to measure the gain. * - * XXX: How about forcing a tx packet (bypassing PCU arbitrator etc) + * TODO: Force a tx packet (bypassing PCU arbitrator etc) * just after we enable the probe so that we don't mess with - * standard traffic ? Maybe it's time to use sw interrupts and - * a probe tasklet !!! + * standard traffic. */ static void ath5k_hw_request_rfgain_probe(struct ath5k_hw *ah) { @@ -575,9 +571,7 @@ done: /* Main callback for thermal RF gain calibration engine * Check for a new gain reading and schedule an adjustment * if needed. - * - * TODO: Use sw interrupt to schedule reset if gain_F needs - * adjustment */ + */ enum ath5k_rfgain ath5k_hw_gainf_calibrate(struct ath5k_hw *ah) { u32 data, type; @@ -1390,6 +1384,8 @@ void ath5k_hw_update_noise_floor(struct ath5k_hw *ah) return; } + ah->ah_cal_mask |= AR5K_CALIBRATION_NF; + ee_mode = ath5k_eeprom_mode_from_channel(ah->ah_current_channel); /* completed NF calibration, test threshold */ @@ -1434,6 +1430,8 @@ void ath5k_hw_update_noise_floor(struct ath5k_hw *ah) ah->ah_noise_floor = nf; + ah->ah_cal_mask &= ~AR5K_CALIBRATION_NF; + ATH5K_DBG(ah, ATH5K_DEBUG_CALIBRATE, "noise floor calibrated: %d\n", nf); } @@ -1547,12 +1545,19 @@ ath5k_hw_rf511x_iq_calibrate(struct ath5k_hw *ah) s32 iq_corr, i_coff, i_coffd, q_coff, q_coffd; int i; - if (!ah->ah_calibration || - ath5k_hw_reg_read(ah, AR5K_PHY_IQ) & AR5K_PHY_IQ_RUN) - return 0; + /* Skip if I/Q calibration is not needed or if it's still running */ + if (!ah->ah_iq_cal_needed) + return -EINVAL; + else if (ath5k_hw_reg_read(ah, AR5K_PHY_IQ) & AR5K_PHY_IQ_RUN) { + ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_CALIBRATE, + "I/Q calibration still running"); + return -EBUSY; + } /* Calibration has finished, get the results and re-run */ - /* work around empty results which can apparently happen on 5212 */ + + /* Work around for empty results which can apparently happen on 5212: + * Read registers up to 10 times until we get both i_pr and q_pwr */ for (i = 0; i <= 10; i++) { iq_corr = ath5k_hw_reg_read(ah, AR5K_PHY_IQRES_CAL_CORR); i_pwr = ath5k_hw_reg_read(ah, AR5K_PHY_IQRES_CAL_PWR_I); @@ -1570,9 +1575,13 @@ ath5k_hw_rf511x_iq_calibrate(struct ath5k_hw *ah) else q_coffd = q_pwr >> 7; - /* protect against divide by 0 and loss of sign bits */ + /* In case i_coffd became zero, cancel calibration + * not only it's too small, it'll also result a divide + * by zero later on. */ if (i_coffd == 0 || q_coffd < 2) - return 0; + return -ECANCELED; + + /* Protect against loss of sign bits */ i_coff = (-iq_corr) / i_coffd; i_coff = clamp(i_coff, -32, 31); /* signed 6 bit */ @@ -1613,10 +1622,43 @@ int ath5k_hw_phy_calibrate(struct ath5k_hw *ah, return ath5k_hw_rf5110_calibrate(ah, channel); ret = ath5k_hw_rf511x_iq_calibrate(ah); + if (ret) { + ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_CALIBRATE, + "No I/Q correction performed (%uMHz)\n", + channel->center_freq); + + /* Happens all the time if there is not much + * traffic, consider it normal behaviour. */ + ret = 0; + } + + /* On full calibration do an AGC calibration and + * request a PAPD probe for gainf calibration if + * needed */ + if (ah->ah_cal_mask & AR5K_CALIBRATION_FULL) { + + AR5K_REG_ENABLE_BITS(ah, AR5K_PHY_AGCCTL, + AR5K_PHY_AGCCTL_CAL); + + ret = ath5k_hw_register_timeout(ah, AR5K_PHY_AGCCTL, + AR5K_PHY_AGCCTL_CAL | AR5K_PHY_AGCCTL_NF, + 0, false); + if (ret) { + ATH5K_ERR(ah, + "gain calibration timeout (%uMHz)\n", + channel->center_freq); + } + + if ((ah->ah_radio == AR5K_RF5111 || + ah->ah_radio == AR5K_RF5112) + && (channel->hw_value != AR5K_MODE_11B)) + ath5k_hw_request_rfgain_probe(ah); + } - if ((ah->ah_radio == AR5K_RF5111 || ah->ah_radio == AR5K_RF5112) && - (channel->hw_value != AR5K_MODE_11B)) - ath5k_hw_request_rfgain_probe(ah); + /* Update noise floor + * XXX: Only do this after AGC calibration */ + if (!(ah->ah_cal_mask & AR5K_CALIBRATION_NF)) + ath5k_hw_update_noise_floor(ah); return ret; } @@ -3433,9 +3475,9 @@ int ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel, /* At the same time start I/Q calibration for QAM constellation * -no need for CCK- */ - ah->ah_calibration = false; + ah->ah_iq_cal_needed = false; if (!(mode == AR5K_MODE_11B)) { - ah->ah_calibration = true; + ah->ah_iq_cal_needed = true; AR5K_REG_WRITE_BITS(ah, AR5K_PHY_IQ, AR5K_PHY_IQ_CAL_NUM_LOG_MAX, 15); AR5K_REG_ENABLE_BITS(ah, AR5K_PHY_IQ, -- cgit v1.2.3 From 1846ac3dbec0894095520b2756b68c4fd81e3fbb Mon Sep 17 00:00:00 2001 From: Nick Kossifidis Date: Fri, 25 Nov 2011 20:40:24 +0200 Subject: ath5k: Use usleep_range where possible Use usleep_range where possible to reduce busy waits Signed-off-by: Nick Kossifidis Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath5k/attach.c | 2 +- drivers/net/wireless/ath/ath5k/pci.c | 2 +- drivers/net/wireless/ath/ath5k/phy.c | 22 +++++++++++----------- drivers/net/wireless/ath/ath5k/reset.c | 14 +++++++------- 4 files changed, 20 insertions(+), 20 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath5k/attach.c b/drivers/net/wireless/ath/ath5k/attach.c index 91627dd2c26a..49fdc9333aa8 100644 --- a/drivers/net/wireless/ath/ath5k/attach.c +++ b/drivers/net/wireless/ath/ath5k/attach.c @@ -298,7 +298,7 @@ int ath5k_hw_init(struct ath5k_hw *ah) /* Reset SERDES to load new settings */ ath5k_hw_reg_write(ah, 0x00000000, AR5K_PCIE_SERDES_RESET); - mdelay(1); + usleep_range(1000, 1500); } /* Get misc capabilities */ diff --git a/drivers/net/wireless/ath/ath5k/pci.c b/drivers/net/wireless/ath/ath5k/pci.c index dfa48eb7d953..849fa060ebc4 100644 --- a/drivers/net/wireless/ath/ath5k/pci.c +++ b/drivers/net/wireless/ath/ath5k/pci.c @@ -98,7 +98,7 @@ ath5k_pci_eeprom_read(struct ath_common *common, u32 offset, u16 *data) 0xffff); return true; } - udelay(15); + usleep_range(15, 20); } return false; diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c index ca4241d2a774..bf097b118bd4 100644 --- a/drivers/net/wireless/ath/ath5k/phy.c +++ b/drivers/net/wireless/ath/ath5k/phy.c @@ -58,7 +58,7 @@ u16 ath5k_hw_radio_revision(struct ath5k_hw *ah, enum ieee80211_band band) return 0; } - mdelay(2); + usleep_range(2000, 2500); /* ...wait until PHY is ready and read the selected radio revision */ ath5k_hw_reg_write(ah, 0x00001c16, AR5K_PHY(0x34)); @@ -308,9 +308,9 @@ static void ath5k_hw_wait_for_synth(struct ath5k_hw *ah, delay = delay << 2; /* XXX: /2 on turbo ? Let's be safe * for now */ - udelay(100 + delay); + usleep_range(100 + delay, 100 + (2 * delay)); } else { - mdelay(1); + usleep_range(1000, 1500); } } @@ -1083,7 +1083,7 @@ static int ath5k_hw_rf5110_channel(struct ath5k_hw *ah, data = ath5k_hw_rf5110_chan2athchan(channel); ath5k_hw_reg_write(ah, data, AR5K_RF_BUFFER); ath5k_hw_reg_write(ah, 0, AR5K_RF_BUFFER_CONTROL_0); - mdelay(1); + usleep_range(1000, 1500); return 0; } @@ -1454,7 +1454,7 @@ static int ath5k_hw_rf5110_calibrate(struct ath5k_hw *ah, beacon = ath5k_hw_reg_read(ah, AR5K_BEACON_5210); ath5k_hw_reg_write(ah, beacon & ~AR5K_BEACON_ENABLE, AR5K_BEACON_5210); - mdelay(2); + usleep_range(2000, 2500); /* * Set the channel (with AGC turned off) @@ -1467,7 +1467,7 @@ static int ath5k_hw_rf5110_calibrate(struct ath5k_hw *ah, * Activate PHY and wait */ ath5k_hw_reg_write(ah, AR5K_PHY_ACT_ENABLE, AR5K_PHY_ACT); - mdelay(1); + usleep_range(1000, 1500); AR5K_REG_DISABLE_BITS(ah, AR5K_PHY_AGC, AR5K_PHY_AGC_DISABLE); @@ -1504,7 +1504,7 @@ static int ath5k_hw_rf5110_calibrate(struct ath5k_hw *ah, ath5k_hw_reg_write(ah, AR5K_PHY_RFSTG_DISABLE, AR5K_PHY_RFSTG); AR5K_REG_DISABLE_BITS(ah, AR5K_PHY_AGC, AR5K_PHY_AGC_DISABLE); - mdelay(1); + usleep_range(1000, 1500); /* * Enable calibration and wait until completion @@ -3397,7 +3397,7 @@ int ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel, if (ret) return ret; - mdelay(1); + usleep_range(1000, 1500); /* * Write RF buffer @@ -3418,10 +3418,10 @@ int ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel, } } else if (ah->ah_version == AR5K_AR5210) { - mdelay(1); + usleep_range(1000, 1500); /* Disable phy and wait */ ath5k_hw_reg_write(ah, AR5K_PHY_ACT_DISABLE, AR5K_PHY_ACT); - mdelay(1); + usleep_range(1000, 1500); } /* Set channel on PHY */ @@ -3447,7 +3447,7 @@ int ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel, for (i = 0; i <= 20; i++) { if (!(ath5k_hw_reg_read(ah, AR5K_PHY_ADC_TEST) & 0x10)) break; - udelay(200); + usleep_range(200, 250); } ath5k_hw_reg_write(ah, phy_tst1, AR5K_PHY_TST1); diff --git a/drivers/net/wireless/ath/ath5k/reset.c b/drivers/net/wireless/ath/ath5k/reset.c index 2abac257b4b4..de28be4296a6 100644 --- a/drivers/net/wireless/ath/ath5k/reset.c +++ b/drivers/net/wireless/ath/ath5k/reset.c @@ -357,7 +357,7 @@ static int ath5k_hw_nic_reset(struct ath5k_hw *ah, u32 val) ath5k_hw_reg_write(ah, val, AR5K_RESET_CTL); /* Wait at least 128 PCI clocks */ - udelay(15); + usleep_range(15, 20); if (ah->ah_version == AR5K_AR5210) { val &= AR5K_RESET_CTL_PCU | AR5K_RESET_CTL_DMA @@ -422,7 +422,7 @@ static int ath5k_hw_wisoc_reset(struct ath5k_hw *ah, u32 flags) regval = __raw_readl(reg); __raw_writel(regval | val, reg); regval = __raw_readl(reg); - udelay(100); + usleep_range(100, 150); /* Bring BB/MAC out of reset */ __raw_writel(regval & ~val, reg); @@ -493,7 +493,7 @@ static int ath5k_hw_set_power(struct ath5k_hw *ah, enum ath5k_power_mode mode, ath5k_hw_reg_write(ah, data | AR5K_SLEEP_CTL_SLE_WAKE, AR5K_SLEEP_CTL); - udelay(15); + usleep_range(15, 20); for (i = 200; i > 0; i--) { /* Check if the chip did wake up */ @@ -502,7 +502,7 @@ static int ath5k_hw_set_power(struct ath5k_hw *ah, enum ath5k_power_mode mode, break; /* Wait a bit and retry */ - udelay(50); + usleep_range(50, 75); ath5k_hw_reg_write(ah, data | AR5K_SLEEP_CTL_SLE_WAKE, AR5K_SLEEP_CTL); } @@ -563,7 +563,7 @@ int ath5k_hw_on_hold(struct ath5k_hw *ah) ret = ath5k_hw_nic_reset(ah, AR5K_RESET_CTL_PCU | AR5K_RESET_CTL_MAC | AR5K_RESET_CTL_DMA | AR5K_RESET_CTL_PHY | AR5K_RESET_CTL_PCI); - mdelay(2); + usleep_range(2000, 2500); } else { ret = ath5k_hw_nic_reset(ah, AR5K_RESET_CTL_PCU | AR5K_RESET_CTL_BASEBAND | bus_flags); @@ -621,7 +621,7 @@ int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, struct ieee80211_channel *channel) ret = ath5k_hw_nic_reset(ah, AR5K_RESET_CTL_PCU | AR5K_RESET_CTL_MAC | AR5K_RESET_CTL_DMA | AR5K_RESET_CTL_PHY | AR5K_RESET_CTL_PCI); - mdelay(2); + usleep_range(2000, 2500); } else { if (ath5k_get_bus_type(ah) == ATH_AHB) ret = ath5k_hw_wisoc_reset(ah, AR5K_RESET_CTL_PCU | @@ -739,7 +739,7 @@ int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, struct ieee80211_channel *channel) /* ...update PLL if needed */ if (ath5k_hw_reg_read(ah, AR5K_PHY_PLL) != clock) { ath5k_hw_reg_write(ah, clock, AR5K_PHY_PLL); - udelay(300); + usleep_range(300, 350); } /* ...set the PHY operating mode */ -- cgit v1.2.3 From c47faa364cfb249d5d7670fb7293a6f9acd8aa9e Mon Sep 17 00:00:00 2001 From: Nick Kossifidis Date: Fri, 25 Nov 2011 20:40:25 +0200 Subject: ath5k: Cleanups v2 + add kerneldoc on all hw functions No functional changes Add kernel doc for all ath5k_hw_* functions and strcucts. Also do some cleanup, rename ath5k_hw_init_beacon to ath5k_hw_init_beacon_timers, remove an unused variable from ath5k_hw_pcu_init and a few obsolete macros, mostly related to XR. Signed-off-by: Nick Kossifidis Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath5k/ani.c | 86 ++-- drivers/net/wireless/ath/ath5k/ani.h | 32 +- drivers/net/wireless/ath/ath5k/ath5k.h | 531 ++++++++++++++------- drivers/net/wireless/ath/ath5k/attach.c | 9 +- drivers/net/wireless/ath/ath5k/base.c | 3 +- drivers/net/wireless/ath/ath5k/desc.c | 217 +++++++-- drivers/net/wireless/ath/ath5k/desc.h | 124 +++-- drivers/net/wireless/ath/ath5k/dma.c | 120 +++-- drivers/net/wireless/ath/ath5k/gpio.c | 81 +++- drivers/net/wireless/ath/ath5k/initvals.c | 75 ++- drivers/net/wireless/ath/ath5k/pcu.c | 222 ++++++--- drivers/net/wireless/ath/ath5k/phy.c | 748 ++++++++++++++++++++++++------ drivers/net/wireless/ath/ath5k/qcu.c | 124 +++-- drivers/net/wireless/ath/ath5k/reset.c | 216 ++++++--- drivers/net/wireless/ath/ath5k/rfbuffer.h | 59 ++- drivers/net/wireless/ath/ath5k/rfgain.h | 22 +- 16 files changed, 1944 insertions(+), 725 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath5k/ani.c b/drivers/net/wireless/ath/ath5k/ani.c index bea90e6be70e..2dfcf1ae19f6 100644 --- a/drivers/net/wireless/ath/ath5k/ani.c +++ b/drivers/net/wireless/ath/ath5k/ani.c @@ -27,15 +27,21 @@ * or reducing sensitivity as necessary. * * The parameters are: + * * - "noise immunity" + * * - "spur immunity" + * * - "firstep level" + * * - "OFDM weak signal detection" + * * - "CCK weak signal detection" * * Basically we look at the amount of ODFM and CCK timing errors we get and then * raise or lower immunity accordingly by setting one or more of these * parameters. + * * Newer chipsets have PHY error counters in hardware which will generate a MIB * interrupt when they overflow. Older hardware has too enable PHY error frames * by setting a RX flag and then count every single PHY error. When a specified @@ -45,11 +51,13 @@ */ -/*** ANI parameter control ***/ +/***********************\ +* ANI parameter control * +\***********************/ /** * ath5k_ani_set_noise_immunity_level() - Set noise immunity level - * + * @ah: The &struct ath5k_hw * @level: level between 0 and @ATH5K_ANI_MAX_NOISE_IMM_LVL */ void @@ -91,12 +99,11 @@ ath5k_ani_set_noise_immunity_level(struct ath5k_hw *ah, int level) ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI, "new level %d", level); } - /** * ath5k_ani_set_spur_immunity_level() - Set spur immunity level - * + * @ah: The &struct ath5k_hw * @level: level between 0 and @max_spur_level (the maximum level is dependent - * on the chip revision). + * on the chip revision). */ void ath5k_ani_set_spur_immunity_level(struct ath5k_hw *ah, int level) @@ -117,10 +124,9 @@ ath5k_ani_set_spur_immunity_level(struct ath5k_hw *ah, int level) ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI, "new level %d", level); } - /** * ath5k_ani_set_firstep_level() - Set "firstep" level - * + * @ah: The &struct ath5k_hw * @level: level between 0 and @ATH5K_ANI_MAX_FIRSTEP_LVL */ void @@ -140,11 +146,9 @@ ath5k_ani_set_firstep_level(struct ath5k_hw *ah, int level) ATH5K_DBG_UNLIMIT(ah, ATH5K_DEBUG_ANI, "new level %d", level); } - /** - * ath5k_ani_set_ofdm_weak_signal_detection() - Control OFDM weak signal - * detection - * + * ath5k_ani_set_ofdm_weak_signal_detection() - Set OFDM weak signal detection + * @ah: The &struct ath5k_hw * @on: turn on or off */ void @@ -182,10 +186,9 @@ ath5k_ani_set_ofdm_weak_signal_detection(struct ath5k_hw *ah, bool on) on ? "on" : "off"); } - /** - * ath5k_ani_set_cck_weak_signal_detection() - control CCK weak signal detection - * + * ath5k_ani_set_cck_weak_signal_detection() - Set CCK weak signal detection + * @ah: The &struct ath5k_hw * @on: turn on or off */ void @@ -200,13 +203,16 @@ ath5k_ani_set_cck_weak_signal_detection(struct ath5k_hw *ah, bool on) } -/*** ANI algorithm ***/ +/***************\ +* ANI algorithm * +\***************/ /** * ath5k_ani_raise_immunity() - Increase noise immunity - * + * @ah: The &struct ath5k_hw + * @as: The &struct ath5k_ani_state * @ofdm_trigger: If this is true we are called because of too many OFDM errors, - * the algorithm will tune more parameters then. + * the algorithm will tune more parameters then. * * Try to raise noise immunity (=decrease sensitivity) in several steps * depending on the average RSSI of the beacons we received. @@ -290,9 +296,10 @@ ath5k_ani_raise_immunity(struct ath5k_hw *ah, struct ath5k_ani_state *as, */ } - /** * ath5k_ani_lower_immunity() - Decrease noise immunity + * @ah: The &struct ath5k_hw + * @as: The &struct ath5k_ani_state * * Try to lower noise immunity (=increase sensitivity) in several steps * depending on the average RSSI of the beacons we received. @@ -352,9 +359,10 @@ ath5k_ani_lower_immunity(struct ath5k_hw *ah, struct ath5k_ani_state *as) } } - /** * ath5k_hw_ani_get_listen_time() - Update counters and return listening time + * @ah: The &struct ath5k_hw + * @as: The &struct ath5k_ani_state * * Return an approximation of the time spent "listening" in milliseconds (ms) * since the last call of this function. @@ -379,9 +387,10 @@ ath5k_hw_ani_get_listen_time(struct ath5k_hw *ah, struct ath5k_ani_state *as) return listen; } - /** * ath5k_ani_save_and_clear_phy_errors() - Clear and save PHY error counters + * @ah: The &struct ath5k_hw + * @as: The &struct ath5k_ani_state * * Clear the PHY error counters as soon as possible, since this might be called * from a MIB interrupt and we want to make sure we don't get interrupted again. @@ -429,9 +438,10 @@ ath5k_ani_save_and_clear_phy_errors(struct ath5k_hw *ah, return 1; } - /** * ath5k_ani_period_restart() - Restart ANI period + * @ah: The &struct ath5k_hw + * @as: The &struct ath5k_ani_state * * Just reset counters, so they are clear for the next "ani period". */ @@ -448,9 +458,9 @@ ath5k_ani_period_restart(struct ath5k_hw *ah, struct ath5k_ani_state *as) as->listen_time = 0; } - /** * ath5k_ani_calibration() - The main ANI calibration function + * @ah: The &struct ath5k_hw * * We count OFDM and CCK errors relative to the time where we did not send or * receive ("listen" time) and raise or lower immunity accordingly. @@ -509,10 +519,13 @@ ath5k_ani_calibration(struct ath5k_hw *ah) } -/*** INTERRUPT HANDLER ***/ +/*******************\ +* Interrupt handler * +\*******************/ /** * ath5k_ani_mib_intr() - Interrupt handler for ANI MIB counters + * @ah: The &struct ath5k_hw * * Just read & reset the registers quickly, so they don't generate more * interrupts, save the counters and schedule the tasklet to decide whether @@ -549,9 +562,11 @@ ath5k_ani_mib_intr(struct ath5k_hw *ah) tasklet_schedule(&ah->ani_tasklet); } - /** - * ath5k_ani_phy_error_report() - Used by older HW to report PHY errors + * ath5k_ani_phy_error_report - Used by older HW to report PHY errors + * + * @ah: The &struct ath5k_hw + * @phyerr: One of enum ath5k_phy_error_code * * This is used by hardware without PHY error counters to report PHY errors * on a frame-by-frame basis, instead of the interrupt. @@ -574,10 +589,13 @@ ath5k_ani_phy_error_report(struct ath5k_hw *ah, } -/*** INIT ***/ +/****************\ +* Initialization * +\****************/ /** * ath5k_enable_phy_err_counters() - Enable PHY error counters + * @ah: The &struct ath5k_hw * * Enable PHY error counters for OFDM and CCK timing errors. */ @@ -596,9 +614,9 @@ ath5k_enable_phy_err_counters(struct ath5k_hw *ah) ath5k_hw_reg_write(ah, 0, AR5K_CCK_FIL_CNT); } - /** * ath5k_disable_phy_err_counters() - Disable PHY error counters + * @ah: The &struct ath5k_hw * * Disable PHY error counters for OFDM and CCK timing errors. */ @@ -615,10 +633,10 @@ ath5k_disable_phy_err_counters(struct ath5k_hw *ah) ath5k_hw_reg_write(ah, 0, AR5K_CCK_FIL_CNT); } - /** * ath5k_ani_init() - Initialize ANI - * @mode: Which mode to use (auto, manual high, manual low, off) + * @ah: The &struct ath5k_hw + * @mode: One of enum ath5k_ani_mode * * Initialize ANI according to mode. */ @@ -695,10 +713,18 @@ ath5k_ani_init(struct ath5k_hw *ah, enum ath5k_ani_mode mode) } -/*** DEBUG ***/ +/**************\ +* Debug output * +\**************/ #ifdef CONFIG_ATH5K_DEBUG +/** + * ath5k_ani_print_counters() - Print ANI counters + * @ah: The &struct ath5k_hw + * + * Used for debugging ANI + */ void ath5k_ani_print_counters(struct ath5k_hw *ah) { diff --git a/drivers/net/wireless/ath/ath5k/ani.h b/drivers/net/wireless/ath/ath5k/ani.h index 7358b6c83c6c..21aa355460bb 100644 --- a/drivers/net/wireless/ath/ath5k/ani.h +++ b/drivers/net/wireless/ath/ath5k/ani.h @@ -40,13 +40,13 @@ enum ath5k_phy_error_code; * enum ath5k_ani_mode - mode for ANI / noise sensitivity * * @ATH5K_ANI_MODE_OFF: Turn ANI off. This can be useful to just stop the ANI - * algorithm after it has been on auto mode. - * ATH5K_ANI_MODE_MANUAL_LOW: Manually set all immunity parameters to low, - * maximizing sensitivity. ANI will not run. - * ATH5K_ANI_MODE_MANUAL_HIGH: Manually set all immunity parameters to high, - * minimizing sensitivity. ANI will not run. - * ATH5K_ANI_MODE_AUTO: Automatically control immunity parameters based on the - * amount of OFDM and CCK frame errors (default). + * algorithm after it has been on auto mode. + * @ATH5K_ANI_MODE_MANUAL_LOW: Manually set all immunity parameters to low, + * maximizing sensitivity. ANI will not run. + * @ATH5K_ANI_MODE_MANUAL_HIGH: Manually set all immunity parameters to high, + * minimizing sensitivity. ANI will not run. + * @ATH5K_ANI_MODE_AUTO: Automatically control immunity parameters based on the + * amount of OFDM and CCK frame errors (default). */ enum ath5k_ani_mode { ATH5K_ANI_MODE_OFF = 0, @@ -58,8 +58,22 @@ enum ath5k_ani_mode { /** * struct ath5k_ani_state - ANI state and associated counters - * - * @max_spur_level: the maximum spur level is chip dependent + * @ani_mode: One of enum ath5k_ani_mode + * @noise_imm_level: Noise immunity level + * @spur_level: Spur immunity level + * @firstep_level: FIRstep level + * @ofdm_weak_sig: OFDM weak signal detection state (on/off) + * @cck_weak_sig: CCK weak signal detection state (on/off) + * @max_spur_level: Max spur immunity level (chip specific) + * @listen_time: Listen time + * @ofdm_errors: OFDM timing error count + * @cck_errors: CCK timing error count + * @last_cc: The &struct ath_cycle_counters (for stats) + * @last_listen: Listen time from previous run (for stats) + * @last_ofdm_errors: OFDM timing error count from previous run (for tats) + * @last_cck_errors: CCK timing error count from previous run (for stats) + * @sum_ofdm_errors: Sum of OFDM timing errors (for stats) + * @sum_cck_errors: Sum of all CCK timing errors (for stats) */ struct ath5k_ani_state { enum ath5k_ani_mode ani_mode; diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h index 3e75d029b0a3..819c4db5aab3 100644 --- a/drivers/net/wireless/ath/ath5k/ath5k.h +++ b/drivers/net/wireless/ath/ath5k/ath5k.h @@ -261,16 +261,34 @@ #define AR5K_AGC_SETTLING_TURBO 37 -/* GENERIC CHIPSET DEFINITIONS */ -/* MAC Chips */ +/*****************************\ +* GENERIC CHIPSET DEFINITIONS * +\*****************************/ + +/** + * enum ath5k_version - MAC Chips + * @AR5K_AR5210: AR5210 (Crete) + * @AR5K_AR5211: AR5211 (Oahu/Maui) + * @AR5K_AR5212: AR5212 (Venice) and newer + */ enum ath5k_version { AR5K_AR5210 = 0, AR5K_AR5211 = 1, AR5K_AR5212 = 2, }; -/* PHY Chips */ +/** + * enum ath5k_radio - PHY Chips + * @AR5K_RF5110: RF5110 (Fez) + * @AR5K_RF5111: RF5111 (Sombrero) + * @AR5K_RF5112: RF2112/5112(A) (Derby/Derby2) + * @AR5K_RF2413: RF2413/2414 (Griffin/Griffin-Lite) + * @AR5K_RF5413: RF5413/5414/5424 (Eagle/Condor) + * @AR5K_RF2316: RF2315/2316 (Cobra SoC) + * @AR5K_RF2317: RF2317 (Spider SoC) + * @AR5K_RF2425: RF2425/2417 (Swan/Nalla) + */ enum ath5k_radio { AR5K_RF5110 = 0, AR5K_RF5111 = 1, @@ -302,11 +320,11 @@ enum ath5k_radio { #define AR5K_SREV_AR5213A 0x59 /* Hainan */ #define AR5K_SREV_AR2413 0x78 /* Griffin lite */ #define AR5K_SREV_AR2414 0x70 /* Griffin */ -#define AR5K_SREV_AR2315_R6 0x86 /* AP51-Light */ -#define AR5K_SREV_AR2315_R7 0x87 /* AP51-Full */ +#define AR5K_SREV_AR2315_R6 0x86 /* AP51-Light */ +#define AR5K_SREV_AR2315_R7 0x87 /* AP51-Full */ #define AR5K_SREV_AR5424 0x90 /* Condor */ -#define AR5K_SREV_AR2317_R1 0x90 /* AP61-Light */ -#define AR5K_SREV_AR2317_R2 0x91 /* AP61-Full */ +#define AR5K_SREV_AR2317_R1 0x90 /* AP61-Light */ +#define AR5K_SREV_AR2317_R2 0x91 /* AP61-Full */ #define AR5K_SREV_AR5413 0xa4 /* Eagle lite */ #define AR5K_SREV_AR5414 0xa0 /* Eagle */ #define AR5K_SREV_AR2415 0xb0 /* Talon */ @@ -343,32 +361,40 @@ enum ath5k_radio { /* TODO add support to mac80211 for vendor-specific rates and modes */ -/* +/** + * DOC: Atheros XR + * * Some of this information is based on Documentation from: * * http://madwifi-project.org/wiki/ChipsetFeatures/SuperAG * - * Modulation for Atheros' eXtended Range - range enhancing extension that is - * supposed to double the distance an Atheros client device can keep a - * connection with an Atheros access point. This is achieved by increasing - * the receiver sensitivity up to, -105dBm, which is about 20dB above what - * the 802.11 specifications demand. In addition, new (proprietary) data rates - * are introduced: 3, 2, 1, 0.5 and 0.25 MBit/s. + * Atheros' eXtended Range - range enhancing extension is a modulation scheme + * that is supposed to double the link distance between an Atheros XR-enabled + * client device with an Atheros XR-enabled access point. This is achieved + * by increasing the receiver sensitivity up to, -105dBm, which is about 20dB + * above what the 802.11 specifications demand. In addition, new (proprietary) + * data rates are introduced: 3, 2, 1, 0.5 and 0.25 MBit/s. * * Please note that can you either use XR or TURBO but you cannot use both, * they are exclusive. * + * Also note that we do not plan to support XR mode at least for now. You can + * get a mode similar to XR by using 5MHz bwmode. */ -#define MODULATION_XR 0x00000200 -/* - * Modulation for Atheros' Turbo G and Turbo A, its supposed to provide a - * throughput transmission speed up to 40Mbit/s-60Mbit/s at a 108Mbit/s - * signaling rate achieved through the bonding of two 54Mbit/s 802.11g - * channels. To use this feature your Access Point must also support it. + + +/** + * DOC: Atheros SuperAG + * + * In addition to XR we have another modulation scheme called TURBO mode + * that is supposed to provide a throughput transmission speed up to 40Mbit/s + * -60Mbit/s at a 108Mbit/s signaling rate achieved through the bonding of two + * 54Mbit/s 802.11g channels. To use this feature both ends must support it. * There is also a distinction between "static" and "dynamic" turbo modes: * * - Static: is the dumb version: devices set to this mode stick to it until * the mode is turned off. + * * - Dynamic: is the intelligent version, the network decides itself if it * is ok to use turbo. As soon as traffic is detected on adjacent channels * (which would get used in turbo mode), or when a non-turbo station joins @@ -382,24 +408,39 @@ enum ath5k_radio { * * http://www.pcworld.com/article/id,113428-page,1/article.html * - * The channel bonding seems to be driver specific though. In addition to - * deciding what channels will be used, these "Turbo" modes are accomplished - * by also enabling the following features: + * The channel bonding seems to be driver specific though. + * + * In addition to TURBO modes we also have the following features for even + * greater speed-up: * * - Bursting: allows multiple frames to be sent at once, rather than pausing * after each frame. Bursting is a standards-compliant feature that can be * used with any Access Point. + * * - Fast frames: increases the amount of information that can be sent per * frame, also resulting in a reduction of transmission overhead. It is a * proprietary feature that needs to be supported by the Access Point. + * * - Compression: data frames are compressed in real time using a Lempel Ziv * algorithm. This is done transparently. Once this feature is enabled, * compression and decompression takes place inside the chipset, without * putting additional load on the host CPU. * + * As with XR we also don't plan to support SuperAG features for now. You can + * get a mode similar to TURBO by using 40MHz bwmode. */ -#define MODULATION_TURBO 0x00000080 + +/** + * enum ath5k_driver_mode - PHY operation mode + * @AR5K_MODE_11A: 802.11a + * @AR5K_MODE_11B: 802.11b + * @AR5K_MODE_11G: 801.11g + * @AR5K_MODE_MAX: Used for boundary checks + * + * Do not change the order here, we use these as + * array indices and it also maps EEPROM structures. + */ enum ath5k_driver_mode { AR5K_MODE_11A = 0, AR5K_MODE_11B = 1, @@ -407,30 +448,64 @@ enum ath5k_driver_mode { AR5K_MODE_MAX = 3 }; +/** + * enum ath5k_ant_mode - Antenna operation mode + * @AR5K_ANTMODE_DEFAULT: Default antenna setup + * @AR5K_ANTMODE_FIXED_A: Only antenna A is present + * @AR5K_ANTMODE_FIXED_B: Only antenna B is present + * @AR5K_ANTMODE_SINGLE_AP: STA locked on a single ap + * @AR5K_ANTMODE_SECTOR_AP: AP with tx antenna set on tx desc + * @AR5K_ANTMODE_SECTOR_STA: STA with tx antenna set on tx desc + * @AR5K_ANTMODE_DEBUG: Debug mode -A -> Rx, B-> Tx- + * @AR5K_ANTMODE_MAX: Used for boundary checks + * + * For more infos on antenna control check out phy.c + */ enum ath5k_ant_mode { - AR5K_ANTMODE_DEFAULT = 0, /* default antenna setup */ - AR5K_ANTMODE_FIXED_A = 1, /* only antenna A is present */ - AR5K_ANTMODE_FIXED_B = 2, /* only antenna B is present */ - AR5K_ANTMODE_SINGLE_AP = 3, /* sta locked on a single ap */ - AR5K_ANTMODE_SECTOR_AP = 4, /* AP with tx antenna set on tx desc */ - AR5K_ANTMODE_SECTOR_STA = 5, /* STA with tx antenna set on tx desc */ - AR5K_ANTMODE_DEBUG = 6, /* Debug mode -A -> Rx, B-> Tx- */ + AR5K_ANTMODE_DEFAULT = 0, + AR5K_ANTMODE_FIXED_A = 1, + AR5K_ANTMODE_FIXED_B = 2, + AR5K_ANTMODE_SINGLE_AP = 3, + AR5K_ANTMODE_SECTOR_AP = 4, + AR5K_ANTMODE_SECTOR_STA = 5, + AR5K_ANTMODE_DEBUG = 6, AR5K_ANTMODE_MAX, }; +/** + * enum ath5k_bw_mode - Bandwidth operation mode + * @AR5K_BWMODE_DEFAULT: 20MHz, default operation + * @AR5K_BWMODE_5MHZ: Quarter rate + * @AR5K_BWMODE_10MHZ: Half rate + * @AR5K_BWMODE_40MHZ: Turbo + */ enum ath5k_bw_mode { - AR5K_BWMODE_DEFAULT = 0, /* 20MHz, default operation */ - AR5K_BWMODE_5MHZ = 1, /* Quarter rate */ - AR5K_BWMODE_10MHZ = 2, /* Half rate */ - AR5K_BWMODE_40MHZ = 3 /* Turbo */ + AR5K_BWMODE_DEFAULT = 0, + AR5K_BWMODE_5MHZ = 1, + AR5K_BWMODE_10MHZ = 2, + AR5K_BWMODE_40MHZ = 3 }; + + /****************\ TX DEFINITIONS \****************/ -/* - * TX Status descriptor +/** + * struct ath5k_tx_status - TX Status descriptor + * @ts_seqnum: Sequence number + * @ts_tstamp: Timestamp + * @ts_status: Status code + * @ts_final_idx: Final transmission series index + * @ts_final_retry: Final retry count + * @ts_rssi: RSSI for received ACK + * @ts_shortretry: Short retry count + * @ts_virtcol: Virtual collision count + * @ts_antenna: Antenna used + * + * TX status descriptor gets filled by the hw + * on each transmission attempt. */ struct ath5k_tx_status { u16 ts_seqnum; @@ -453,7 +528,6 @@ struct ath5k_tx_status { * enum ath5k_tx_queue - Queue types used to classify tx queues. * @AR5K_TX_QUEUE_INACTIVE: q is unused -- see ath5k_hw_release_tx_queue * @AR5K_TX_QUEUE_DATA: A normal data queue - * @AR5K_TX_QUEUE_XR_DATA: An XR-data queue * @AR5K_TX_QUEUE_BEACON: The beacon queue * @AR5K_TX_QUEUE_CAB: The after-beacon queue * @AR5K_TX_QUEUE_UAPSD: Unscheduled Automatic Power Save Delivery queue @@ -461,7 +535,6 @@ struct ath5k_tx_status { enum ath5k_tx_queue { AR5K_TX_QUEUE_INACTIVE = 0, AR5K_TX_QUEUE_DATA, - AR5K_TX_QUEUE_XR_DATA, AR5K_TX_QUEUE_BEACON, AR5K_TX_QUEUE_CAB, AR5K_TX_QUEUE_UAPSD, @@ -470,36 +543,48 @@ enum ath5k_tx_queue { #define AR5K_NUM_TX_QUEUES 10 #define AR5K_NUM_TX_QUEUES_NOQCU 2 -/* - * Queue syb-types to classify normal data queues. +/** + * enum ath5k_tx_queue_subtype - Queue sub-types to classify normal data queues + * @AR5K_WME_AC_BK: Background traffic + * @AR5K_WME_AC_BE: Best-effort (normal) traffic + * @AR5K_WME_AC_VI: Video traffic + * @AR5K_WME_AC_VO: Voice traffic + * * These are the 4 Access Categories as defined in * WME spec. 0 is the lowest priority and 4 is the * highest. Normal data that hasn't been classified * goes to the Best Effort AC. */ enum ath5k_tx_queue_subtype { - AR5K_WME_AC_BK = 0, /*Background traffic*/ - AR5K_WME_AC_BE, /*Best-effort (normal) traffic*/ - AR5K_WME_AC_VI, /*Video traffic*/ - AR5K_WME_AC_VO, /*Voice traffic*/ + AR5K_WME_AC_BK = 0, + AR5K_WME_AC_BE, + AR5K_WME_AC_VI, + AR5K_WME_AC_VO, }; -/* - * Queue ID numbers as returned by the hw functions, each number - * represents a hw queue. If hw does not support hw queues +/** + * enum ath5k_tx_queue_id - Queue ID numbers as returned by the hw functions + * @AR5K_TX_QUEUE_ID_NOQCU_DATA: Data queue on AR5210 (no QCU available) + * @AR5K_TX_QUEUE_ID_NOQCU_BEACON: Beacon queue on AR5210 (no QCU available) + * @AR5K_TX_QUEUE_ID_DATA_MIN: Data queue min index + * @AR5K_TX_QUEUE_ID_DATA_MAX: Data queue max index + * @AR5K_TX_QUEUE_ID_CAB: Content after beacon queue + * @AR5K_TX_QUEUE_ID_BEACON: Beacon queue + * @AR5K_TX_QUEUE_ID_UAPSD: Urgent Automatic Power Save Delivery, + * @AR5K_TX_QUEUE_ID_XR_DATA: XR Data queue + * + * Each number represents a hw queue. If hw does not support hw queues * (eg 5210) all data goes in one queue. These match - * d80211 definitions (net80211/MadWiFi don't use them). + * mac80211 definitions. */ enum ath5k_tx_queue_id { AR5K_TX_QUEUE_ID_NOQCU_DATA = 0, AR5K_TX_QUEUE_ID_NOQCU_BEACON = 1, - AR5K_TX_QUEUE_ID_DATA_MIN = 0, /*IEEE80211_TX_QUEUE_DATA0*/ - AR5K_TX_QUEUE_ID_DATA_MAX = 3, /*IEEE80211_TX_QUEUE_DATA3*/ - AR5K_TX_QUEUE_ID_DATA_SVP = 5, /*IEEE80211_TX_QUEUE_SVP - Spectralink Voice Protocol*/ - AR5K_TX_QUEUE_ID_CAB = 6, /*IEEE80211_TX_QUEUE_AFTER_BEACON*/ - AR5K_TX_QUEUE_ID_BEACON = 7, /*IEEE80211_TX_QUEUE_BEACON*/ + AR5K_TX_QUEUE_ID_DATA_MIN = 0, + AR5K_TX_QUEUE_ID_DATA_MAX = 3, + AR5K_TX_QUEUE_ID_CAB = 6, + AR5K_TX_QUEUE_ID_BEACON = 7, AR5K_TX_QUEUE_ID_UAPSD = 8, - AR5K_TX_QUEUE_ID_XR_DATA = 9, }; /* @@ -520,46 +605,70 @@ enum ath5k_tx_queue_id { #define AR5K_TXQ_FLAG_POST_FR_BKOFF_DIS 0x1000 /* Disable backoff while bursting */ #define AR5K_TXQ_FLAG_COMPRESSION_ENABLE 0x2000 /* Enable hw compression -not implemented-*/ -/* - * Data transmit queue state. One of these exists for each - * hardware transmit queue. Packets sent to us from above - * are assigned to queues based on their priority. Not all - * devices support a complete set of hardware transmit queues. - * For those devices the array sc_ac2q will map multiple - * priorities to fewer hardware queues (typically all to one - * hardware queue). +/** + * struct ath5k_txq - Transmit queue state + * @qnum: Hardware q number + * @link: Link ptr in last TX desc + * @q: Transmit queue (&struct list_head) + * @lock: Lock on q and link + * @setup: Is the queue configured + * @txq_len:Number of queued buffers + * @txq_max: Max allowed num of queued buffers + * @txq_poll_mark: Used to check if queue got stuck + * @txq_stuck: Queue stuck counter + * + * One of these exists for each hardware transmit queue. + * Packets sent to us from above are assigned to queues based + * on their priority. Not all devices support a complete set + * of hardware transmit queues. For those devices the array + * sc_ac2q will map multiple priorities to fewer hardware queues + * (typically all to one hardware queue). */ struct ath5k_txq { - unsigned int qnum; /* hardware q number */ - u32 *link; /* link ptr in last TX desc */ - struct list_head q; /* transmit queue */ - spinlock_t lock; /* lock on q and link */ + unsigned int qnum; + u32 *link; + struct list_head q; + spinlock_t lock; bool setup; - int txq_len; /* number of queued buffers */ - int txq_max; /* max allowed num of queued buffers */ + int txq_len; + int txq_max; bool txq_poll_mark; - unsigned int txq_stuck; /* informational counter */ + unsigned int txq_stuck; }; -/* - * A struct to hold tx queue's parameters +/** + * struct ath5k_txq_info - A struct to hold TX queue's parameters + * @tqi_type: One of enum ath5k_tx_queue + * @tqi_subtype: One of enum ath5k_tx_queue_subtype + * @tqi_flags: TX queue flags (see above) + * @tqi_aifs: Arbitrated Inter-frame Space + * @tqi_cw_min: Minimum Contention Window + * @tqi_cw_max: Maximum Contention Window + * @tqi_cbr_period: Constant bit rate period + * @tqi_ready_time: Time queue waits after an event when RDYTIME is enabled */ struct ath5k_txq_info { enum ath5k_tx_queue tqi_type; enum ath5k_tx_queue_subtype tqi_subtype; - u16 tqi_flags; /* Tx queue flags (see above) */ - u8 tqi_aifs; /* Arbitrated Interframe Space */ - u16 tqi_cw_min; /* Minimum Contention Window */ - u16 tqi_cw_max; /* Maximum Contention Window */ - u32 tqi_cbr_period; /* Constant bit rate period */ + u16 tqi_flags; + u8 tqi_aifs; + u16 tqi_cw_min; + u16 tqi_cw_max; + u32 tqi_cbr_period; u32 tqi_cbr_overflow_limit; u32 tqi_burst_time; - u32 tqi_ready_time; /* Time queue waits after an event */ + u32 tqi_ready_time; }; -/* - * Transmit packet types. - * used on tx control descriptor +/** + * enum ath5k_pkt_type - Transmit packet types + * @AR5K_PKT_TYPE_NORMAL: Normal data + * @AR5K_PKT_TYPE_ATIM: ATIM + * @AR5K_PKT_TYPE_PSPOLL: PS-Poll + * @AR5K_PKT_TYPE_BEACON: Beacon + * @AR5K_PKT_TYPE_PROBE_RESP: Probe response + * @AR5K_PKT_TYPE_PIFS: PIFS + * Used on tx control descriptor */ enum ath5k_pkt_type { AR5K_PKT_TYPE_NORMAL = 0, @@ -582,27 +691,23 @@ enum ath5k_pkt_type { (ah->ah_txpower.txp_rates_power_table[(_r)] & 0x3f) << (_v) \ ) -/* - * DMA size definitions (2^(n+2)) - */ -enum ath5k_dmasize { - AR5K_DMASIZE_4B = 0, - AR5K_DMASIZE_8B, - AR5K_DMASIZE_16B, - AR5K_DMASIZE_32B, - AR5K_DMASIZE_64B, - AR5K_DMASIZE_128B, - AR5K_DMASIZE_256B, - AR5K_DMASIZE_512B -}; /****************\ RX DEFINITIONS \****************/ -/* - * RX Status descriptor +/** + * struct ath5k_rx_status - RX Status descriptor + * @rs_datalen: Data length + * @rs_tstamp: Timestamp + * @rs_status: Status code + * @rs_phyerr: PHY error mask + * @rs_rssi: RSSI in 0.5dbm units + * @rs_keyix: Index to the key used for decrypting + * @rs_rate: Rate used to decode the frame + * @rs_antenna: Antenna used to receive the frame + * @rs_more: Indicates this is a frame fragment (Fast frames) */ struct ath5k_rx_status { u16 rs_datalen; @@ -644,10 +749,18 @@ struct ath5k_rx_status { #define TSF_TO_TU(_tsf) (u32)((_tsf) >> 10) + /*******************************\ GAIN OPTIMIZATION DEFINITIONS \*******************************/ +/** + * enum ath5k_rfgain - RF Gain optimization engine state + * @AR5K_RFGAIN_INACTIVE: Engine disabled + * @AR5K_RFGAIN_ACTIVE: Probe active + * @AR5K_RFGAIN_READ_REQUESTED: Probe requested + * @AR5K_RFGAIN_NEED_CHANGE: Gain_F needs change + */ enum ath5k_rfgain { AR5K_RFGAIN_INACTIVE = 0, AR5K_RFGAIN_ACTIVE, @@ -655,6 +768,16 @@ enum ath5k_rfgain { AR5K_RFGAIN_NEED_CHANGE, }; +/** + * struct ath5k_gain - RF Gain optimization engine state data + * @g_step_idx: Current step index + * @g_current: Current gain + * @g_target: Target gain + * @g_low: Low gain boundary + * @g_high: High gain boundary + * @g_f_corr: Gain_F correction + * @g_state: One of enum ath5k_rfgain + */ struct ath5k_gain { u8 g_step_idx; u8 g_current; @@ -665,6 +788,8 @@ struct ath5k_gain { u8 g_state; }; + + /********************\ COMMON DEFINITIONS \********************/ @@ -673,9 +798,14 @@ struct ath5k_gain { #define AR5K_SLOT_TIME_20 880 #define AR5K_SLOT_TIME_MAX 0xffff -/* - * The following structure is used to map 2GHz channels to - * 5GHz Atheros channels. +/** + * struct ath5k_athchan_2ghz - 2GHz to 5GHZ map for RF5111 + * @a2_flags: Channel flags (internal) + * @a2_athchan: HW channel number (internal) + * + * This structure is used to map 2GHz channels to + * 5GHz Atheros channels on 2111 frequency converter + * that comes together with RF5111 * TODO: Clean up */ struct ath5k_athchan_2ghz { @@ -683,36 +813,80 @@ struct ath5k_athchan_2ghz { u16 a2_athchan; }; +/** + * enum ath5k_dmasize - DMA size definitions (2^(n+2)) + * @AR5K_DMASIZE_4B: 4Bytes + * @AR5K_DMASIZE_8B: 8Bytes + * @AR5K_DMASIZE_16B: 16Bytes + * @AR5K_DMASIZE_32B: 32Bytes + * @AR5K_DMASIZE_64B: 64Bytes (Default) + * @AR5K_DMASIZE_128B: 128Bytes + * @AR5K_DMASIZE_256B: 256Bytes + * @AR5K_DMASIZE_512B: 512Bytes + * + * These are used to set DMA burst size on hw + * + * Note: Some platforms can't handle more than 4Bytes + * be careful on embedded boards. + */ +enum ath5k_dmasize { + AR5K_DMASIZE_4B = 0, + AR5K_DMASIZE_8B, + AR5K_DMASIZE_16B, + AR5K_DMASIZE_32B, + AR5K_DMASIZE_64B, + AR5K_DMASIZE_128B, + AR5K_DMASIZE_256B, + AR5K_DMASIZE_512B +}; + + /******************\ RATE DEFINITIONS \******************/ /** + * DOC: Rate codes + * * Seems the ar5xxx hardware supports up to 32 rates, indexed by 1-32. * * The rate code is used to get the RX rate or set the TX rate on the * hardware descriptors. It is also used for internal modulation control * and settings. * - * This is the hardware rate map we are aware of: - * - * rate_code 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 - * rate_kbps 3000 1000 ? ? ? 2000 500 48000 - * - * rate_code 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F 0x10 - * rate_kbps 24000 12000 6000 54000 36000 18000 9000 ? + * This is the hardware rate map we are aware of (html unfriendly): * - * rate_code 17 18 19 20 21 22 23 24 - * rate_kbps ? ? ? ? ? ? ? 11000 + * Rate code Rate (Kbps) + * --------- ----------- + * 0x01 3000 (XR) + * 0x02 1000 (XR) + * 0x03 250 (XR) + * 0x04 - 05 -Reserved- + * 0x06 2000 (XR) + * 0x07 500 (XR) + * 0x08 48000 (OFDM) + * 0x09 24000 (OFDM) + * 0x0A 12000 (OFDM) + * 0x0B 6000 (OFDM) + * 0x0C 54000 (OFDM) + * 0x0D 36000 (OFDM) + * 0x0E 18000 (OFDM) + * 0x0F 9000 (OFDM) + * 0x10 - 17 -Reserved- + * 0x18 11000L (CCK) + * 0x19 5500L (CCK) + * 0x1A 2000L (CCK) + * 0x1B 1000L (CCK) + * 0x1C 11000S (CCK) + * 0x1D 5500S (CCK) + * 0x1E 2000S (CCK) + * 0x1F -Reserved- * - * rate_code 25 26 27 28 29 30 31 32 - * rate_kbps 5500 2000 1000 11000S 5500S 2000S ? ? - * - * "S" indicates CCK rates with short preamble. + * "S" indicates CCK rates with short preamble and "L" with long preamble. * * AR5211 has different rate codes for CCK (802.11B) rates. It only uses the - * lowest 4 bits, so they are the same as below with a 0xF mask. + * lowest 4 bits, so they are the same as above with a 0xF mask. * (0xB, 0xA, 0x9 and 0x8 for 1M, 2M, 5.5M and 11M). * We handle this in ath5k_setup_bands(). */ @@ -732,13 +906,9 @@ struct ath5k_athchan_2ghz { #define ATH5K_RATE_CODE_36M 0x0D #define ATH5K_RATE_CODE_48M 0x08 #define ATH5K_RATE_CODE_54M 0x0C -/* XR */ -#define ATH5K_RATE_CODE_XR_500K 0x07 -#define ATH5K_RATE_CODE_XR_1M 0x02 -#define ATH5K_RATE_CODE_XR_2M 0x06 -#define ATH5K_RATE_CODE_XR_3M 0x01 -/* adding this flag to rate_code enables short preamble */ +/* Adding this flag to rate_code on B rates + * enables short preamble */ #define AR5K_SET_SHORT_PREAMBLE 0x04 /* @@ -768,49 +938,65 @@ extern int ath5k_modparam_nohwcrypt; /** * enum ath5k_int - Hardware interrupt masks helpers + * @AR5K_INT_RXOK: Frame successfully received + * @AR5K_INT_RXDESC: Request RX descriptor/Read RX descriptor + * @AR5K_INT_RXERR: Frame reception failed + * @AR5K_INT_RXNOFRM: No frame received within a specified time period + * @AR5K_INT_RXEOL: Reached "End Of List", means we need more RX descriptors + * @AR5K_INT_RXORN: Indicates we got RX FIFO overrun. Note that Rx overrun is + * not always fatal, on some chips we can continue operation + * without resetting the card, that's why %AR5K_INT_FATAL is not + * common for all chips. + * @AR5K_INT_RX_ALL: Mask to identify all RX related interrupts + * + * @AR5K_INT_TXOK: Frame transmission success + * @AR5K_INT_TXDESC: Request TX descriptor/Read TX status descriptor + * @AR5K_INT_TXERR: Frame transmission failure + * @AR5K_INT_TXEOL: Received End Of List for VEOL (Virtual End Of List). The + * Queue Control Unit (QCU) signals an EOL interrupt only if a + * descriptor's LinkPtr is NULL. For more details, refer to: + * "http://www.freepatentsonline.com/20030225739.html" + * @AR5K_INT_TXNOFRM: No frame was transmitted within a specified time period + * @AR5K_INT_TXURN: Indicates we got TX FIFO underrun. In such case we should + * increase the TX trigger threshold. + * @AR5K_INT_TX_ALL: Mask to identify all TX related interrupts * - * @AR5K_INT_RX: mask to identify received frame interrupts, of type - * AR5K_ISR_RXOK or AR5K_ISR_RXERR - * @AR5K_INT_RXDESC: Request RX descriptor/Read RX descriptor (?) - * @AR5K_INT_RXNOFRM: No frame received (?) - * @AR5K_INT_RXEOL: received End Of List for VEOL (Virtual End Of List). The - * Queue Control Unit (QCU) signals an EOL interrupt only if a descriptor's - * LinkPtr is NULL. For more details, refer to: - * http://www.freepatentsonline.com/20030225739.html - * @AR5K_INT_RXORN: Indicates we got RX overrun (eg. no more descriptors). - * Note that Rx overrun is not always fatal, on some chips we can continue - * operation without resetting the card, that's why int_fatal is not - * common for all chips. - * @AR5K_INT_TX: mask to identify received frame interrupts, of type - * AR5K_ISR_TXOK or AR5K_ISR_TXERR - * @AR5K_INT_TXDESC: Request TX descriptor/Read TX status descriptor (?) - * @AR5K_INT_TXURN: received when we should increase the TX trigger threshold - * We currently do increments on interrupt by - * (AR5K_TUNE_MAX_TX_FIFO_THRES - current_trigger_level) / 2 * @AR5K_INT_MIB: Indicates the either Management Information Base counters or - * one of the PHY error counters reached the maximum value and should be - * read and cleared. + * one of the PHY error counters reached the maximum value and + * should be read and cleared. + * @AR5K_INT_SWI: Software triggered interrupt. * @AR5K_INT_RXPHY: RX PHY Error * @AR5K_INT_RXKCM: RX Key cache miss * @AR5K_INT_SWBA: SoftWare Beacon Alert - indicates its time to send a - * beacon that must be handled in software. The alternative is if you - * have VEOL support, in that case you let the hardware deal with things. + * beacon that must be handled in software. The alternative is if + * you have VEOL support, in that case you let the hardware deal + * with things. + * @AR5K_INT_BRSSI: Beacon received with an RSSI value below our threshold * @AR5K_INT_BMISS: If in STA mode this indicates we have stopped seeing - * beacons from the AP have associated with, we should probably try to - * reassociate. When in IBSS mode this might mean we have not received - * any beacons from any local stations. Note that every station in an - * IBSS schedules to send beacons at the Target Beacon Transmission Time - * (TBTT) with a random backoff. - * @AR5K_INT_BNR: Beacon Not Ready interrupt - ?? - * @AR5K_INT_GPIO: GPIO interrupt is used for RF Kill, disabled for now - * until properly handled - * @AR5K_INT_FATAL: Fatal errors were encountered, typically caused by DMA - * errors. These types of errors we can enable seem to be of type - * AR5K_SIMR2_MCABT, AR5K_SIMR2_SSERR and AR5K_SIMR2_DPERR. + * beacons from the AP have associated with, we should probably + * try to reassociate. When in IBSS mode this might mean we have + * not received any beacons from any local stations. Note that + * every station in an IBSS schedules to send beacons at the + * Target Beacon Transmission Time (TBTT) with a random backoff. + * @AR5K_INT_BNR: Beacon queue got triggered (DMA beacon alert) while empty. + * @AR5K_INT_TIM: Beacon with local station's TIM bit set + * @AR5K_INT_DTIM: Beacon with DTIM bit and zero DTIM count received + * @AR5K_INT_DTIM_SYNC: DTIM sync lost + * @AR5K_INT_GPIO: GPIO interrupt is used for RF Kill switches connected to + * our GPIO pins. + * @AR5K_INT_BCN_TIMEOUT: Beacon timeout, we waited after TBTT but got noting + * @AR5K_INT_CAB_TIMEOUT: We waited for CAB traffic after the beacon but got + * nothing or an incomplete CAB frame sequence. + * @AR5K_INT_QCBRORN: A queue got it's CBR counter expired + * @AR5K_INT_QCBRURN: A queue got triggered wile empty + * @AR5K_INT_QTRIG: A queue got triggered + * + * @AR5K_INT_FATAL: Fatal errors were encountered, typically caused by bus/DMA + * errors. Indicates we need to reset the card. * @AR5K_INT_GLOBAL: Used to clear and set the IER - * @AR5K_INT_NOCARD: signals the card has been removed - * @AR5K_INT_COMMON: common interrupts shared among MACs with the same - * bit value + * @AR5K_INT_NOCARD: Signals the card has been removed + * @AR5K_INT_COMMON: Common interrupts shared among MACs with the same + * bit value * * These are mapped to take advantage of some common bits * between the MACs, to be able to set intr properties @@ -846,10 +1032,9 @@ enum ath5k_int { AR5K_INT_GPIO = 0x01000000, AR5K_INT_BCN_TIMEOUT = 0x02000000, /* Non common */ AR5K_INT_CAB_TIMEOUT = 0x04000000, /* Non common */ - AR5K_INT_RX_DOPPLER = 0x08000000, /* Non common */ - AR5K_INT_QCBRORN = 0x10000000, /* Non common */ - AR5K_INT_QCBRURN = 0x20000000, /* Non common */ - AR5K_INT_QTRIG = 0x40000000, /* Non common */ + AR5K_INT_QCBRORN = 0x08000000, /* Non common */ + AR5K_INT_QCBRURN = 0x10000000, /* Non common */ + AR5K_INT_QTRIG = 0x20000000, /* Non common */ AR5K_INT_GLOBAL = 0x80000000, AR5K_INT_TX_ALL = AR5K_INT_TXOK @@ -891,7 +1076,13 @@ enum ath5k_int { AR5K_INT_NOCARD = 0xffffffff }; -/* mask which calibration is active at the moment */ +/** + * enum ath5k_calibration_mask - Mask which calibration is active at the moment + * @AR5K_CALIBRATION_FULL: Full calibration (AGC + SHORT) + * @AR5K_CALIBRATION_SHORT: Short calibration (NF + I/Q) + * @AR5K_CALIBRATION_NF: Noise Floor calibration + * @AR5K_CALIBRATION_ANI: Adaptive Noise Immunity + */ enum ath5k_calibration_mask { AR5K_CALIBRATION_FULL = 0x01, AR5K_CALIBRATION_SHORT = 0x02, @@ -899,8 +1090,18 @@ enum ath5k_calibration_mask { AR5K_CALIBRATION_ANI = 0x08, }; -/* - * Power management +/** + * enum ath5k_power_mode - Power management modes + * @AR5K_PM_UNDEFINED: Undefined + * @AR5K_PM_AUTO: Allow card to sleep if possible + * @AR5K_PM_AWAKE: Force card to wake up + * @AR5K_PM_FULL_SLEEP: Force card to full sleep (DANGEROUS) + * @AR5K_PM_NETWORK_SLEEP: Allow to sleep for a specified duration + * + * Currently only PM_AWAKE is used, FULL_SLEEP and NETWORK_SLEEP/AUTO + * are also known to have problems on some cards. This is not a big + * problem though because we can have almost the same effect as + * FULL_SLEEP by putting card on warm reset (it's almost powered down). */ enum ath5k_power_mode { AR5K_PM_UNDEFINED = 0, @@ -1344,11 +1545,11 @@ void ath5k_hw_stop_rx_pcu(struct ath5k_hw *ah); u64 ath5k_hw_get_tsf64(struct ath5k_hw *ah); void ath5k_hw_set_tsf64(struct ath5k_hw *ah, u64 tsf64); void ath5k_hw_reset_tsf(struct ath5k_hw *ah); -void ath5k_hw_init_beacon(struct ath5k_hw *ah, u32 next_beacon, u32 interval); +void ath5k_hw_init_beacon_timers(struct ath5k_hw *ah, u32 next_beacon, + u32 interval); bool ath5k_hw_check_beacon_timers(struct ath5k_hw *ah, int intval); /* Init function */ -void ath5k_hw_pcu_init(struct ath5k_hw *ah, enum nl80211_iftype op_mode, - u8 mode); +void ath5k_hw_pcu_init(struct ath5k_hw *ah, enum nl80211_iftype op_mode); /* Queue Control Unit, DFS Control Unit Functions */ int ath5k_hw_get_tx_queueprops(struct ath5k_hw *ah, int queue, diff --git a/drivers/net/wireless/ath/ath5k/attach.c b/drivers/net/wireless/ath/ath5k/attach.c index 49fdc9333aa8..b69e0570cf02 100644 --- a/drivers/net/wireless/ath/ath5k/attach.c +++ b/drivers/net/wireless/ath/ath5k/attach.c @@ -27,8 +27,7 @@ #include "debug.h" /** - * ath5k_hw_post - Power On Self Test helper function - * + * ath5k_hw_post() - Power On Self Test helper function * @ah: The &struct ath5k_hw */ static int ath5k_hw_post(struct ath5k_hw *ah) @@ -92,8 +91,7 @@ static int ath5k_hw_post(struct ath5k_hw *ah) } /** - * ath5k_hw_init - Check if hw is supported and init the needed structs - * + * ath5k_hw_init() - Check if hw is supported and init the needed structs * @ah: The &struct ath5k_hw associated with the device * * Check if the device is supported, perform a POST and initialize the needed @@ -349,8 +347,7 @@ err: } /** - * ath5k_hw_deinit - Free the ath5k_hw struct - * + * ath5k_hw_deinit() - Free the &struct ath5k_hw * @ah: The &struct ath5k_hw */ void ath5k_hw_deinit(struct ath5k_hw *ah) diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c index a8cb1c7f4bfe..9bb40b002fad 100644 --- a/drivers/net/wireless/ath/ath5k/base.c +++ b/drivers/net/wireless/ath/ath5k/base.c @@ -183,7 +183,6 @@ static const struct ieee80211_rate ath5k_rates[] = { { .bitrate = 540, .hw_value = ATH5K_RATE_CODE_54M, .flags = 0 }, - /* XR missing */ }; static inline u64 ath5k_extend_tsf(struct ath5k_hw *ah, u32 rstamp) @@ -2005,7 +2004,7 @@ ath5k_beacon_update_timers(struct ath5k_hw *ah, u64 bc_tsf) ah->nexttbtt = nexttbtt; intval |= AR5K_BEACON_ENA; - ath5k_hw_init_beacon(ah, nexttbtt, intval); + ath5k_hw_init_beacon_timers(ah, nexttbtt, intval); /* * debugging output last in order to preserve the time critical aspect diff --git a/drivers/net/wireless/ath/ath5k/desc.c b/drivers/net/wireless/ath/ath5k/desc.c index 7e88dda82221..f8bfa3ac2af0 100644 --- a/drivers/net/wireless/ath/ath5k/desc.c +++ b/drivers/net/wireless/ath/ath5k/desc.c @@ -26,20 +26,61 @@ #include "debug.h" +/** + * DOC: Hardware descriptor functions + * + * Here we handle the processing of the low-level hw descriptors + * that hw reads and writes via DMA for each TX and RX attempt (that means + * we can also have descriptors for failed TX/RX tries). We have two kind of + * descriptors for RX and TX, control descriptors tell the hw how to send or + * receive a packet where to read/write it from/to etc and status descriptors + * that contain information about how the packet was sent or received (errors + * included). + * + * Descriptor format is not exactly the same for each MAC chip version so we + * have function pointers on &struct ath5k_hw we initialize at runtime based on + * the chip used. + */ + + /************************\ * TX Control descriptors * \************************/ -/* - * Initialize the 2-word tx control descriptor on 5210/5211 +/** + * ath5k_hw_setup_2word_tx_desc() - Initialize a 2-word tx control descriptor + * @ah: The &struct ath5k_hw + * @desc: The &struct ath5k_desc + * @pkt_len: Frame length in bytes + * @hdr_len: Header length in bytes (only used on AR5210) + * @padsize: Any padding we've added to the frame length + * @type: One of enum ath5k_pkt_type + * @tx_power: Tx power in 0.5dB steps + * @tx_rate0: HW idx for transmission rate + * @tx_tries0: Max number of retransmissions + * @key_index: Index on key table to use for encryption + * @antenna_mode: Which antenna to use (0 for auto) + * @flags: One of AR5K_TXDESC_* flags (desc.h) + * @rtscts_rate: HW idx for RTS/CTS transmission rate + * @rtscts_duration: What to put on duration field on the header of RTS/CTS + * + * Internal function to initialize a 2-Word TX control descriptor + * found on AR5210 and AR5211 MACs chips. + * + * Returns 0 on success or -EINVAL on false input */ static int -ath5k_hw_setup_2word_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc, - unsigned int pkt_len, unsigned int hdr_len, int padsize, - enum ath5k_pkt_type type, - unsigned int tx_power, unsigned int tx_rate0, unsigned int tx_tries0, - unsigned int key_index, unsigned int antenna_mode, unsigned int flags, - unsigned int rtscts_rate, unsigned int rtscts_duration) +ath5k_hw_setup_2word_tx_desc(struct ath5k_hw *ah, + struct ath5k_desc *desc, + unsigned int pkt_len, unsigned int hdr_len, + int padsize, + enum ath5k_pkt_type type, + unsigned int tx_power, + unsigned int tx_rate0, unsigned int tx_tries0, + unsigned int key_index, + unsigned int antenna_mode, + unsigned int flags, + unsigned int rtscts_rate, unsigned int rtscts_duration) { u32 frame_type; struct ath5k_hw_2w_tx_ctl *tx_ctl; @@ -172,17 +213,40 @@ ath5k_hw_setup_2word_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc, return 0; } -/* - * Initialize the 4-word tx control descriptor on 5212 +/** + * ath5k_hw_setup_4word_tx_desc() - Initialize a 4-word tx control descriptor + * @ah: The &struct ath5k_hw + * @desc: The &struct ath5k_desc + * @pkt_len: Frame length in bytes + * @hdr_len: Header length in bytes (only used on AR5210) + * @padsize: Any padding we've added to the frame length + * @type: One of enum ath5k_pkt_type + * @tx_power: Tx power in 0.5dB steps + * @tx_rate0: HW idx for transmission rate + * @tx_tries0: Max number of retransmissions + * @key_index: Index on key table to use for encryption + * @antenna_mode: Which antenna to use (0 for auto) + * @flags: One of AR5K_TXDESC_* flags (desc.h) + * @rtscts_rate: HW idx for RTS/CTS transmission rate + * @rtscts_duration: What to put on duration field on the header of RTS/CTS + * + * Internal function to initialize a 4-Word TX control descriptor + * found on AR5212 and later MACs chips. + * + * Returns 0 on success or -EINVAL on false input */ -static int ath5k_hw_setup_4word_tx_desc(struct ath5k_hw *ah, - struct ath5k_desc *desc, unsigned int pkt_len, unsigned int hdr_len, - int padsize, - enum ath5k_pkt_type type, unsigned int tx_power, unsigned int tx_rate0, - unsigned int tx_tries0, unsigned int key_index, - unsigned int antenna_mode, unsigned int flags, - unsigned int rtscts_rate, - unsigned int rtscts_duration) +static int +ath5k_hw_setup_4word_tx_desc(struct ath5k_hw *ah, + struct ath5k_desc *desc, + unsigned int pkt_len, unsigned int hdr_len, + int padsize, + enum ath5k_pkt_type type, + unsigned int tx_power, + unsigned int tx_rate0, unsigned int tx_tries0, + unsigned int key_index, + unsigned int antenna_mode, + unsigned int flags, + unsigned int rtscts_rate, unsigned int rtscts_duration) { struct ath5k_hw_4w_tx_ctl *tx_ctl; unsigned int frame_len; @@ -292,13 +356,29 @@ static int ath5k_hw_setup_4word_tx_desc(struct ath5k_hw *ah, return 0; } -/* - * Initialize a 4-word multi rate retry tx control descriptor on 5212 +/** + * ath5k_hw_setup_mrr_tx_desc() - Initialize an MRR tx control descriptor + * @ah: The &struct ath5k_hw + * @desc: The &struct ath5k_desc + * @tx_rate1: HW idx for rate used on transmission series 1 + * @tx_tries1: Max number of retransmissions for transmission series 1 + * @tx_rate2: HW idx for rate used on transmission series 2 + * @tx_tries2: Max number of retransmissions for transmission series 2 + * @tx_rate3: HW idx for rate used on transmission series 3 + * @tx_tries3: Max number of retransmissions for transmission series 3 + * + * Multi rate retry (MRR) tx control descriptors are available only on AR5212 + * MACs, they are part of the normal 4-word tx control descriptor (see above) + * but we handle them through a separate function for better abstraction. + * + * Returns 0 on success or -EINVAL on invalid input */ int -ath5k_hw_setup_mrr_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc, - unsigned int tx_rate1, u_int tx_tries1, u_int tx_rate2, - u_int tx_tries2, unsigned int tx_rate3, u_int tx_tries3) +ath5k_hw_setup_mrr_tx_desc(struct ath5k_hw *ah, + struct ath5k_desc *desc, + u_int tx_rate1, u_int tx_tries1, + u_int tx_rate2, u_int tx_tries2, + u_int tx_rate3, u_int tx_tries3) { struct ath5k_hw_4w_tx_ctl *tx_ctl; @@ -350,11 +430,16 @@ ath5k_hw_setup_mrr_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc, * TX Status descriptors * \***********************/ -/* - * Process the tx status descriptor on 5210/5211 +/** + * ath5k_hw_proc_2word_tx_status() - Process a tx status descriptor on 5210/1 + * @ah: The &struct ath5k_hw + * @desc: The &struct ath5k_desc + * @ts: The &struct ath5k_tx_status */ -static int ath5k_hw_proc_2word_tx_status(struct ath5k_hw *ah, - struct ath5k_desc *desc, struct ath5k_tx_status *ts) +static int +ath5k_hw_proc_2word_tx_status(struct ath5k_hw *ah, + struct ath5k_desc *desc, + struct ath5k_tx_status *ts) { struct ath5k_hw_2w_tx_ctl *tx_ctl; struct ath5k_hw_tx_status *tx_status; @@ -399,11 +484,16 @@ static int ath5k_hw_proc_2word_tx_status(struct ath5k_hw *ah, return 0; } -/* - * Process a tx status descriptor on 5212 +/** + * ath5k_hw_proc_4word_tx_status() - Process a tx status descriptor on 5212 + * @ah: The &struct ath5k_hw + * @desc: The &struct ath5k_desc + * @ts: The &struct ath5k_tx_status */ -static int ath5k_hw_proc_4word_tx_status(struct ath5k_hw *ah, - struct ath5k_desc *desc, struct ath5k_tx_status *ts) +static int +ath5k_hw_proc_4word_tx_status(struct ath5k_hw *ah, + struct ath5k_desc *desc, + struct ath5k_tx_status *ts) { struct ath5k_hw_4w_tx_ctl *tx_ctl; struct ath5k_hw_tx_status *tx_status; @@ -460,11 +550,17 @@ static int ath5k_hw_proc_4word_tx_status(struct ath5k_hw *ah, * RX Descriptors * \****************/ -/* - * Initialize an rx control descriptor +/** + * ath5k_hw_setup_rx_desc() - Initialize an rx control descriptor + * @ah: The &struct ath5k_hw + * @desc: The &struct ath5k_desc + * @size: RX buffer length in bytes + * @flags: One of AR5K_RXDESC_* flags */ -int ath5k_hw_setup_rx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc, - u32 size, unsigned int flags) +int +ath5k_hw_setup_rx_desc(struct ath5k_hw *ah, + struct ath5k_desc *desc, + u32 size, unsigned int flags) { struct ath5k_hw_rx_ctl *rx_ctl; @@ -491,11 +587,22 @@ int ath5k_hw_setup_rx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc, return 0; } -/* - * Process the rx status descriptor on 5210/5211 +/** + * ath5k_hw_proc_5210_rx_status() - Process the rx status descriptor on 5210/1 + * @ah: The &struct ath5k_hw + * @desc: The &struct ath5k_desc + * @rs: The &struct ath5k_rx_status + * + * Internal function used to process an RX status descriptor + * on AR5210/5211 MAC. + * + * Returns 0 on success or -EINPROGRESS in case we haven't received the who;e + * frame yet. */ -static int ath5k_hw_proc_5210_rx_status(struct ath5k_hw *ah, - struct ath5k_desc *desc, struct ath5k_rx_status *rs) +static int +ath5k_hw_proc_5210_rx_status(struct ath5k_hw *ah, + struct ath5k_desc *desc, + struct ath5k_rx_status *rs) { struct ath5k_hw_rx_status *rx_status; @@ -574,12 +681,22 @@ static int ath5k_hw_proc_5210_rx_status(struct ath5k_hw *ah, return 0; } -/* - * Process the rx status descriptor on 5212 +/** + * ath5k_hw_proc_5212_rx_status() - Process the rx status descriptor on 5212 + * @ah: The &struct ath5k_hw + * @desc: The &struct ath5k_desc + * @rs: The &struct ath5k_rx_status + * + * Internal function used to process an RX status descriptor + * on AR5212 and later MAC. + * + * Returns 0 on success or -EINPROGRESS in case we haven't received the who;e + * frame yet. */ -static int ath5k_hw_proc_5212_rx_status(struct ath5k_hw *ah, - struct ath5k_desc *desc, - struct ath5k_rx_status *rs) +static int +ath5k_hw_proc_5212_rx_status(struct ath5k_hw *ah, + struct ath5k_desc *desc, + struct ath5k_rx_status *rs) { struct ath5k_hw_rx_status *rx_status; u32 rxstat0, rxstat1; @@ -646,10 +763,16 @@ static int ath5k_hw_proc_5212_rx_status(struct ath5k_hw *ah, * Attach * \********/ -/* - * Init function pointers inside ath5k_hw struct +/** + * ath5k_hw_init_desc_functions() - Init function pointers inside ah + * @ah: The &struct ath5k_hw + * + * Maps the internal descriptor functions to the function pointers on ah, used + * from above. This is used as an abstraction layer to handle the various chips + * the same way. */ -int ath5k_hw_init_desc_functions(struct ath5k_hw *ah) +int +ath5k_hw_init_desc_functions(struct ath5k_hw *ah) { if (ah->ah_version == AR5K_AR5212) { ah->ah_setup_tx_desc = ath5k_hw_setup_4word_tx_desc; diff --git a/drivers/net/wireless/ath/ath5k/desc.h b/drivers/net/wireless/ath/ath5k/desc.h index cfd529b548f3..8d6c01a49ea3 100644 --- a/drivers/net/wireless/ath/ath5k/desc.h +++ b/drivers/net/wireless/ath/ath5k/desc.h @@ -20,25 +20,30 @@ * RX/TX descriptor structures */ -/* - * Common hardware RX control descriptor +/** + * struct ath5k_hw_rx_ctl - Common hardware RX control descriptor + * @rx_control_0: RX control word 0 + * @rx_control_1: RX control word 1 */ struct ath5k_hw_rx_ctl { - u32 rx_control_0; /* RX control word 0 */ - u32 rx_control_1; /* RX control word 1 */ + u32 rx_control_0; + u32 rx_control_1; } __packed __aligned(4); /* RX control word 1 fields/flags */ #define AR5K_DESC_RX_CTL1_BUF_LEN 0x00000fff /* data buffer length */ #define AR5K_DESC_RX_CTL1_INTREQ 0x00002000 /* RX interrupt request */ -/* - * Common hardware RX status descriptor +/** + * struct ath5k_hw_rx_status - Common hardware RX status descriptor + * @rx_status_0: RX status word 0 + * @rx_status_1: RX status word 1 + * * 5210, 5211 and 5212 differ only in the fields and flags defined below */ struct ath5k_hw_rx_status { - u32 rx_status_0; /* RX status word 0 */ - u32 rx_status_1; /* RX status word 1 */ + u32 rx_status_0; + u32 rx_status_1; } __packed __aligned(4); /* 5210/5211 */ @@ -98,17 +103,36 @@ struct ath5k_hw_rx_status { /** * enum ath5k_phy_error_code - PHY Error codes + * @AR5K_RX_PHY_ERROR_UNDERRUN: Transmit underrun, [5210] No error + * @AR5K_RX_PHY_ERROR_TIMING: Timing error + * @AR5K_RX_PHY_ERROR_PARITY: Illegal parity + * @AR5K_RX_PHY_ERROR_RATE: Illegal rate + * @AR5K_RX_PHY_ERROR_LENGTH: Illegal length + * @AR5K_RX_PHY_ERROR_RADAR: Radar detect, [5210] 64 QAM rate + * @AR5K_RX_PHY_ERROR_SERVICE: Illegal service + * @AR5K_RX_PHY_ERROR_TOR: Transmit override receive + * @AR5K_RX_PHY_ERROR_OFDM_TIMING: OFDM Timing error [5212+] + * @AR5K_RX_PHY_ERROR_OFDM_SIGNAL_PARITY: OFDM Signal parity error [5212+] + * @AR5K_RX_PHY_ERROR_OFDM_RATE_ILLEGAL: OFDM Illegal rate [5212+] + * @AR5K_RX_PHY_ERROR_OFDM_LENGTH_ILLEGAL: OFDM Illegal length [5212+] + * @AR5K_RX_PHY_ERROR_OFDM_POWER_DROP: OFDM Power drop [5212+] + * @AR5K_RX_PHY_ERROR_OFDM_SERVICE: OFDM Service (?) [5212+] + * @AR5K_RX_PHY_ERROR_OFDM_RESTART: OFDM Restart (?) [5212+] + * @AR5K_RX_PHY_ERROR_CCK_TIMING: CCK Timing error [5212+] + * @AR5K_RX_PHY_ERROR_CCK_HEADER_CRC: Header CRC error [5212+] + * @AR5K_RX_PHY_ERROR_CCK_RATE_ILLEGAL: Illegal rate [5212+] + * @AR5K_RX_PHY_ERROR_CCK_SERVICE: CCK Service (?) [5212+] + * @AR5K_RX_PHY_ERROR_CCK_RESTART: CCK Restart (?) [5212+] */ enum ath5k_phy_error_code { - AR5K_RX_PHY_ERROR_UNDERRUN = 0, /* Transmit underrun, [5210] No error */ - AR5K_RX_PHY_ERROR_TIMING = 1, /* Timing error */ - AR5K_RX_PHY_ERROR_PARITY = 2, /* Illegal parity */ - AR5K_RX_PHY_ERROR_RATE = 3, /* Illegal rate */ - AR5K_RX_PHY_ERROR_LENGTH = 4, /* Illegal length */ - AR5K_RX_PHY_ERROR_RADAR = 5, /* Radar detect, [5210] 64 QAM rate */ - AR5K_RX_PHY_ERROR_SERVICE = 6, /* Illegal service */ - AR5K_RX_PHY_ERROR_TOR = 7, /* Transmit override receive */ - /* these are specific to the 5212 */ + AR5K_RX_PHY_ERROR_UNDERRUN = 0, + AR5K_RX_PHY_ERROR_TIMING = 1, + AR5K_RX_PHY_ERROR_PARITY = 2, + AR5K_RX_PHY_ERROR_RATE = 3, + AR5K_RX_PHY_ERROR_LENGTH = 4, + AR5K_RX_PHY_ERROR_RADAR = 5, + AR5K_RX_PHY_ERROR_SERVICE = 6, + AR5K_RX_PHY_ERROR_TOR = 7, AR5K_RX_PHY_ERROR_OFDM_TIMING = 17, AR5K_RX_PHY_ERROR_OFDM_SIGNAL_PARITY = 18, AR5K_RX_PHY_ERROR_OFDM_RATE_ILLEGAL = 19, @@ -123,12 +147,14 @@ enum ath5k_phy_error_code { AR5K_RX_PHY_ERROR_CCK_RESTART = 31, }; -/* - * 5210/5211 hardware 2-word TX control descriptor +/** + * struct ath5k_hw_2w_tx_ctl - 5210/5211 hardware 2-word TX control descriptor + * @tx_control_0: TX control word 0 + * @tx_control_1: TX control word 1 */ struct ath5k_hw_2w_tx_ctl { - u32 tx_control_0; /* TX control word 0 */ - u32 tx_control_1; /* TX control word 1 */ + u32 tx_control_0; + u32 tx_control_1; } __packed __aligned(4); /* TX control word 0 fields/flags */ @@ -177,14 +203,18 @@ struct ath5k_hw_2w_tx_ctl { #define AR5K_AR5210_TX_DESC_FRAME_TYPE_PIFS 4 #define AR5K_AR5211_TX_DESC_FRAME_TYPE_PRESP 4 -/* - * 5212 hardware 4-word TX control descriptor +/** + * struct ath5k_hw_4w_tx_ctl - 5212 hardware 4-word TX control descriptor + * @tx_control_0: TX control word 0 + * @tx_control_1: TX control word 1 + * @tx_control_2: TX control word 2 + * @tx_control_3: TX control word 3 */ struct ath5k_hw_4w_tx_ctl { - u32 tx_control_0; /* TX control word 0 */ - u32 tx_control_1; /* TX control word 1 */ - u32 tx_control_2; /* TX control word 2 */ - u32 tx_control_3; /* TX control word 3 */ + u32 tx_control_0; + u32 tx_control_1; + u32 tx_control_2; + u32 tx_control_3; } __packed __aligned(4); /* TX control word 0 fields/flags */ @@ -238,12 +268,14 @@ struct ath5k_hw_4w_tx_ctl { #define AR5K_4W_TX_DESC_CTL3_RTS_CTS_RATE 0x01f00000 /* RTS or CTS rate */ #define AR5K_4W_TX_DESC_CTL3_RTS_CTS_RATE_S 20 -/* - * Common TX status descriptor +/** + * struct ath5k_hw_tx_status - Common TX status descriptor + * @tx_status_0: TX status word 0 + * @tx_status_1: TX status word 1 */ struct ath5k_hw_tx_status { - u32 tx_status_0; /* TX status word 0 */ - u32 tx_status_1; /* TX status word 1 */ + u32 tx_status_0; + u32 tx_status_1; } __packed __aligned(4); /* TX status word 0 fields/flags */ @@ -276,37 +308,47 @@ struct ath5k_hw_tx_status { #define AR5K_DESC_TX_STATUS1_COMP_SUCCESS_5212 0x00800000 /* [5212] compression status */ #define AR5K_DESC_TX_STATUS1_XMIT_ANTENNA_5212 0x01000000 /* [5212] transmit antenna */ -/* - * 5210/5211 hardware TX descriptor +/** + * struct ath5k_hw_5210_tx_desc - 5210/5211 hardware TX descriptor + * @tx_ctl: The &struct ath5k_hw_2w_tx_ctl + * @tx_stat: The &struct ath5k_hw_tx_status */ struct ath5k_hw_5210_tx_desc { struct ath5k_hw_2w_tx_ctl tx_ctl; struct ath5k_hw_tx_status tx_stat; } __packed __aligned(4); -/* - * 5212 hardware TX descriptor +/** + * struct ath5k_hw_5212_tx_desc - 5212 hardware TX descriptor + * @tx_ctl: The &struct ath5k_hw_4w_tx_ctl + * @tx_stat: The &struct ath5k_hw_tx_status */ struct ath5k_hw_5212_tx_desc { struct ath5k_hw_4w_tx_ctl tx_ctl; struct ath5k_hw_tx_status tx_stat; } __packed __aligned(4); -/* - * Common hardware RX descriptor +/** + * struct ath5k_hw_all_rx_desc - Common hardware RX descriptor + * @rx_ctl: The &struct ath5k_hw_rx_ctl + * @rx_stat: The &struct ath5k_hw_rx_status */ struct ath5k_hw_all_rx_desc { struct ath5k_hw_rx_ctl rx_ctl; struct ath5k_hw_rx_status rx_stat; } __packed __aligned(4); -/* - * Atheros hardware DMA descriptor +/** + * struct ath5k_desc - Atheros hardware DMA descriptor + * @ds_link: Physical address of the next descriptor + * @ds_data: Physical address of data buffer (skb) + * @ud: Union containing hw_5xxx_tx_desc structs and hw_all_rx_desc + * * This is read and written to by the hardware */ struct ath5k_desc { - u32 ds_link; /* physical address of the next descriptor */ - u32 ds_data; /* physical address of data buffer (skb) */ + u32 ds_link; + u32 ds_data; union { struct ath5k_hw_5210_tx_desc ds_tx5210; diff --git a/drivers/net/wireless/ath/ath5k/dma.c b/drivers/net/wireless/ath/ath5k/dma.c index 97864d88d181..5cc9aa814697 100644 --- a/drivers/net/wireless/ath/ath5k/dma.c +++ b/drivers/net/wireless/ath/ath5k/dma.c @@ -20,16 +20,13 @@ * DMA and interrupt masking functions * \*************************************/ -/* - * dma.c - DMA and interrupt masking functions +/** + * DOC: DMA and interrupt masking functions * * Here we setup descriptor pointers (rxdp/txdp) start/stop dma engine and * handle queue setup for 5210 chipset (rest are handled on qcu.c). * Also we setup interrupt mask register (IMR) and read the various interrupt * status registers (ISR). - * - * TODO: Handle SISR on 5211+ and introduce a function to return the queue - * number that resulted the interrupt. */ #include "ath5k.h" @@ -42,22 +39,22 @@ \*********/ /** - * ath5k_hw_start_rx_dma - Start DMA receive - * + * ath5k_hw_start_rx_dma() - Start DMA receive * @ah: The &struct ath5k_hw */ -void ath5k_hw_start_rx_dma(struct ath5k_hw *ah) +void +ath5k_hw_start_rx_dma(struct ath5k_hw *ah) { ath5k_hw_reg_write(ah, AR5K_CR_RXE, AR5K_CR); ath5k_hw_reg_read(ah, AR5K_CR); } /** - * ath5k_hw_stop_rx_dma - Stop DMA receive - * + * ath5k_hw_stop_rx_dma() - Stop DMA receive * @ah: The &struct ath5k_hw */ -static int ath5k_hw_stop_rx_dma(struct ath5k_hw *ah) +static int +ath5k_hw_stop_rx_dma(struct ath5k_hw *ah) { unsigned int i; @@ -79,24 +76,24 @@ static int ath5k_hw_stop_rx_dma(struct ath5k_hw *ah) } /** - * ath5k_hw_get_rxdp - Get RX Descriptor's address - * + * ath5k_hw_get_rxdp() - Get RX Descriptor's address * @ah: The &struct ath5k_hw */ -u32 ath5k_hw_get_rxdp(struct ath5k_hw *ah) +u32 +ath5k_hw_get_rxdp(struct ath5k_hw *ah) { return ath5k_hw_reg_read(ah, AR5K_RXDP); } /** - * ath5k_hw_set_rxdp - Set RX Descriptor's address - * + * ath5k_hw_set_rxdp() - Set RX Descriptor's address * @ah: The &struct ath5k_hw * @phys_addr: RX descriptor address * * Returns -EIO if rx is active */ -int ath5k_hw_set_rxdp(struct ath5k_hw *ah, u32 phys_addr) +int +ath5k_hw_set_rxdp(struct ath5k_hw *ah, u32 phys_addr) { if (ath5k_hw_reg_read(ah, AR5K_CR) & AR5K_CR_RXE) { ATH5K_DBG(ah, ATH5K_DEBUG_DMA, @@ -114,8 +111,7 @@ int ath5k_hw_set_rxdp(struct ath5k_hw *ah, u32 phys_addr) \**********/ /** - * ath5k_hw_start_tx_dma - Start DMA transmit for a specific queue - * + * ath5k_hw_start_tx_dma() - Start DMA transmit for a specific queue * @ah: The &struct ath5k_hw * @queue: The hw queue number * @@ -128,7 +124,8 @@ int ath5k_hw_set_rxdp(struct ath5k_hw *ah, u32 phys_addr) * NOTE: Must be called after setting up tx control descriptor for that * queue (see below). */ -int ath5k_hw_start_tx_dma(struct ath5k_hw *ah, unsigned int queue) +int +ath5k_hw_start_tx_dma(struct ath5k_hw *ah, unsigned int queue) { u32 tx_queue; @@ -177,17 +174,16 @@ int ath5k_hw_start_tx_dma(struct ath5k_hw *ah, unsigned int queue) } /** - * ath5k_hw_stop_tx_dma - Stop DMA transmit on a specific queue - * + * ath5k_hw_stop_tx_dma() - Stop DMA transmit on a specific queue * @ah: The &struct ath5k_hw * @queue: The hw queue number * * Stop DMA transmit on a specific hw queue and drain queue so we don't * have any pending frames. Returns -EBUSY if we still have pending frames, * -EINVAL if queue number is out of range or inactive. - * */ -static int ath5k_hw_stop_tx_dma(struct ath5k_hw *ah, unsigned int queue) +static int +ath5k_hw_stop_tx_dma(struct ath5k_hw *ah, unsigned int queue) { unsigned int i = 40; u32 tx_queue, pending; @@ -320,14 +316,14 @@ static int ath5k_hw_stop_tx_dma(struct ath5k_hw *ah, unsigned int queue) } /** - * ath5k_hw_stop_beacon_queue - Stop beacon queue - * - * @ah The &struct ath5k_hw - * @queue The queue number + * ath5k_hw_stop_beacon_queue() - Stop beacon queue + * @ah: The &struct ath5k_hw + * @queue: The queue number * * Returns -EIO if queue didn't stop */ -int ath5k_hw_stop_beacon_queue(struct ath5k_hw *ah, unsigned int queue) +int +ath5k_hw_stop_beacon_queue(struct ath5k_hw *ah, unsigned int queue) { int ret; ret = ath5k_hw_stop_tx_dma(ah, queue); @@ -340,8 +336,7 @@ int ath5k_hw_stop_beacon_queue(struct ath5k_hw *ah, unsigned int queue) } /** - * ath5k_hw_get_txdp - Get TX Descriptor's address for a specific queue - * + * ath5k_hw_get_txdp() - Get TX Descriptor's address for a specific queue * @ah: The &struct ath5k_hw * @queue: The hw queue number * @@ -352,7 +347,8 @@ int ath5k_hw_stop_beacon_queue(struct ath5k_hw *ah, unsigned int queue) * * XXX: Is TXDP read and clear ? */ -u32 ath5k_hw_get_txdp(struct ath5k_hw *ah, unsigned int queue) +u32 +ath5k_hw_get_txdp(struct ath5k_hw *ah, unsigned int queue) { u16 tx_reg; @@ -382,10 +378,10 @@ u32 ath5k_hw_get_txdp(struct ath5k_hw *ah, unsigned int queue) } /** - * ath5k_hw_set_txdp - Set TX Descriptor's address for a specific queue - * + * ath5k_hw_set_txdp() - Set TX Descriptor's address for a specific queue * @ah: The &struct ath5k_hw * @queue: The hw queue number + * @phys_addr: The physical address * * Set TX descriptor's address for a specific queue. For 5210 we ignore * the queue number and we use tx queue type since we only have 2 queues @@ -394,7 +390,8 @@ u32 ath5k_hw_get_txdp(struct ath5k_hw *ah, unsigned int queue) * Returns -EINVAL if queue type is invalid for 5210 and -EIO if queue is still * active. */ -int ath5k_hw_set_txdp(struct ath5k_hw *ah, unsigned int queue, u32 phys_addr) +int +ath5k_hw_set_txdp(struct ath5k_hw *ah, unsigned int queue, u32 phys_addr) { u16 tx_reg; @@ -435,8 +432,7 @@ int ath5k_hw_set_txdp(struct ath5k_hw *ah, unsigned int queue, u32 phys_addr) } /** - * ath5k_hw_update_tx_triglevel - Update tx trigger level - * + * ath5k_hw_update_tx_triglevel() - Update tx trigger level * @ah: The &struct ath5k_hw * @increase: Flag to force increase of trigger level * @@ -444,14 +440,15 @@ int ath5k_hw_set_txdp(struct ath5k_hw *ah, unsigned int queue, u32 phys_addr) * buffer (aka FIFO threshold) that is used to indicate when PCU flushes * the buffer and transmits its data. Lowering this results sending small * frames more quickly but can lead to tx underruns, raising it a lot can - * result other problems (i think bmiss is related). Right now we start with - * the lowest possible (64Bytes) and if we get tx underrun we increase it using - * the increase flag. Returns -EIO if we have reached maximum/minimum. + * result other problems. Right now we start with the lowest possible + * (64Bytes) and if we get tx underrun we increase it using the increase + * flag. Returns -EIO if we have reached maximum/minimum. * * XXX: Link this with tx DMA size ? - * XXX: Use it to save interrupts ? + * XXX2: Use it to save interrupts ? */ -int ath5k_hw_update_tx_triglevel(struct ath5k_hw *ah, bool increase) +int +ath5k_hw_update_tx_triglevel(struct ath5k_hw *ah, bool increase) { u32 trigger_level, imr; int ret = -EIO; @@ -497,21 +494,20 @@ done: \*******************/ /** - * ath5k_hw_is_intr_pending - Check if we have pending interrupts - * + * ath5k_hw_is_intr_pending() - Check if we have pending interrupts * @ah: The &struct ath5k_hw * * Check if we have pending interrupts to process. Returns 1 if we * have pending interrupts and 0 if we haven't. */ -bool ath5k_hw_is_intr_pending(struct ath5k_hw *ah) +bool +ath5k_hw_is_intr_pending(struct ath5k_hw *ah) { return ath5k_hw_reg_read(ah, AR5K_INTPEND) == 1 ? 1 : 0; } /** - * ath5k_hw_get_isr - Get interrupt status - * + * ath5k_hw_get_isr() - Get interrupt status * @ah: The @struct ath5k_hw * @interrupt_mask: Driver's interrupt mask used to filter out * interrupts in sw. @@ -525,7 +521,8 @@ bool ath5k_hw_is_intr_pending(struct ath5k_hw *ah) * NOTE: We do write-to-clear, so the active PISR/SISR bits at the time this * function gets called are cleared on return. */ -int ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask) +int +ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask) { u32 data = 0; @@ -696,15 +693,10 @@ int ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask) if (unlikely(pisr & (AR5K_ISR_HIUERR))) *interrupt_mask |= AR5K_INT_FATAL; - /*Beacon Not Ready*/ if (unlikely(pisr & (AR5K_ISR_BNR))) *interrupt_mask |= AR5K_INT_BNR; - /* Doppler chirp received */ - if (unlikely(pisr & (AR5K_ISR_RXDOPPLER))) - *interrupt_mask |= AR5K_INT_RX_DOPPLER; - /* A queue got CBR overrun */ if (unlikely(pisr & (AR5K_ISR_QCBRORN))) { *interrupt_mask |= AR5K_INT_QCBRORN; @@ -740,8 +732,7 @@ int ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask) } /** - * ath5k_hw_set_imr - Set interrupt mask - * + * ath5k_hw_set_imr() - Set interrupt mask * @ah: The &struct ath5k_hw * @new_mask: The new interrupt mask to be set * @@ -749,7 +740,8 @@ int ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask) * ath5k_int bits to hw-specific bits to remove abstraction and writing * Interrupt Mask Register. */ -enum ath5k_int ath5k_hw_set_imr(struct ath5k_hw *ah, enum ath5k_int new_mask) +enum ath5k_int +ath5k_hw_set_imr(struct ath5k_hw *ah, enum ath5k_int new_mask) { enum ath5k_int old_mask, int_mask; @@ -802,10 +794,6 @@ enum ath5k_int ath5k_hw_set_imr(struct ath5k_hw *ah, enum ath5k_int new_mask) if (new_mask & AR5K_INT_BNR) int_mask |= AR5K_INT_BNR; - /* RX doppler chirp */ - if (new_mask & AR5K_INT_RX_DOPPLER) - int_mask |= AR5K_IMR_RXDOPPLER; - /* Note: Per queue interrupt masks * are set via ath5k_hw_reset_tx_queue() (qcu.c) */ ath5k_hw_reg_write(ah, int_mask, AR5K_PIMR); @@ -844,8 +832,7 @@ enum ath5k_int ath5k_hw_set_imr(struct ath5k_hw *ah, enum ath5k_int new_mask) \********************/ /** - * ath5k_hw_dma_init - Initialize DMA unit - * + * ath5k_hw_dma_init() - Initialize DMA unit * @ah: The &struct ath5k_hw * * Set DMA size and pre-enable interrupts @@ -854,7 +841,8 @@ enum ath5k_int ath5k_hw_set_imr(struct ath5k_hw *ah, enum ath5k_int new_mask) * * XXX: Save/restore RXDP/TXDP registers ? */ -void ath5k_hw_dma_init(struct ath5k_hw *ah) +void +ath5k_hw_dma_init(struct ath5k_hw *ah) { /* * Set Rx/Tx DMA Configuration @@ -883,8 +871,7 @@ void ath5k_hw_dma_init(struct ath5k_hw *ah) } /** - * ath5k_hw_dma_stop - stop DMA unit - * + * ath5k_hw_dma_stop() - stop DMA unit * @ah: The &struct ath5k_hw * * Stop tx/rx DMA and interrupts. Returns @@ -894,7 +881,8 @@ void ath5k_hw_dma_init(struct ath5k_hw *ah) * stuck frames on tx queues, only a reset * can fix that. */ -int ath5k_hw_dma_stop(struct ath5k_hw *ah) +int +ath5k_hw_dma_stop(struct ath5k_hw *ah) { int i, qmax, err; err = 0; diff --git a/drivers/net/wireless/ath/ath5k/gpio.c b/drivers/net/wireless/ath/ath5k/gpio.c index 859297811914..73d3dd8a306a 100644 --- a/drivers/net/wireless/ath/ath5k/gpio.c +++ b/drivers/net/wireless/ath/ath5k/gpio.c @@ -24,10 +24,33 @@ #include "reg.h" #include "debug.h" -/* - * Set led state + +/** + * DOC: GPIO/LED functions + * + * Here we control the 6 bidirectional GPIO pins provided by the hw. + * We can set a GPIO pin to be an input or an output pin on GPIO control + * register and then read or set its status from GPIO data input/output + * registers. + * + * We also control the two LED pins provided by the hw, LED_0 is our + * "power" LED and LED_1 is our "network activity" LED but many scenarios + * are available from hw. Vendors might also provide LEDs connected to the + * GPIO pins, we handle them through the LED subsystem on led.c + */ + + +/** + * ath5k_hw_set_ledstate() - Set led state + * @ah: The &struct ath5k_hw + * @state: One of AR5K_LED_* + * + * Used to set the LED blinking state. This only + * works for the LED connected to the LED_0, LED_1 pins, + * not the GPIO based. */ -void ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state) +void +ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state) { u32 led; /*5210 has different led mode handling*/ @@ -74,10 +97,13 @@ void ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state) AR5K_REG_ENABLE_BITS(ah, AR5K_PCICFG, led_5210); } -/* - * Set GPIO inputs +/** + * ath5k_hw_set_gpio_input() - Set GPIO inputs + * @ah: The &struct ath5k_hw + * @gpio: GPIO pin to set as input */ -int ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio) +int +ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio) { if (gpio >= AR5K_NUM_GPIO) return -EINVAL; @@ -89,10 +115,13 @@ int ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio) return 0; } -/* - * Set GPIO outputs +/** + * ath5k_hw_set_gpio_output() - Set GPIO outputs + * @ah: The &struct ath5k_hw + * @gpio: The GPIO pin to set as output */ -int ath5k_hw_set_gpio_output(struct ath5k_hw *ah, u32 gpio) +int +ath5k_hw_set_gpio_output(struct ath5k_hw *ah, u32 gpio) { if (gpio >= AR5K_NUM_GPIO) return -EINVAL; @@ -104,10 +133,13 @@ int ath5k_hw_set_gpio_output(struct ath5k_hw *ah, u32 gpio) return 0; } -/* - * Get GPIO state +/** + * ath5k_hw_get_gpio() - Get GPIO state + * @ah: The &struct ath5k_hw + * @gpio: The GPIO pin to read */ -u32 ath5k_hw_get_gpio(struct ath5k_hw *ah, u32 gpio) +u32 +ath5k_hw_get_gpio(struct ath5k_hw *ah, u32 gpio) { if (gpio >= AR5K_NUM_GPIO) return 0xffffffff; @@ -117,10 +149,14 @@ u32 ath5k_hw_get_gpio(struct ath5k_hw *ah, u32 gpio) 0x1; } -/* - * Set GPIO state +/** + * ath5k_hw_set_gpio() - Set GPIO state + * @ah: The &struct ath5k_hw + * @gpio: The GPIO pin to set + * @val: Value to set (boolean) */ -int ath5k_hw_set_gpio(struct ath5k_hw *ah, u32 gpio, u32 val) +int +ath5k_hw_set_gpio(struct ath5k_hw *ah, u32 gpio, u32 val) { u32 data; @@ -138,10 +174,19 @@ int ath5k_hw_set_gpio(struct ath5k_hw *ah, u32 gpio, u32 val) return 0; } -/* - * Initialize the GPIO interrupt (RFKill switch) +/** + * ath5k_hw_set_gpio_intr() - Initialize the GPIO interrupt (RFKill switch) + * @ah: The &struct ath5k_hw + * @gpio: The GPIO pin to use + * @interrupt_level: True to generate interrupt on active pin (high) + * + * This function is used to set up the GPIO interrupt for the hw RFKill switch. + * That switch is connected to a GPIO pin and it's number is stored on EEPROM. + * It can either open or close the circuit to indicate that we should disable + * RF/Wireless to save power (we also get that from EEPROM). */ -void ath5k_hw_set_gpio_intr(struct ath5k_hw *ah, unsigned int gpio, +void +ath5k_hw_set_gpio_intr(struct ath5k_hw *ah, unsigned int gpio, u32 interrupt_level) { u32 data; diff --git a/drivers/net/wireless/ath/ath5k/initvals.c b/drivers/net/wireless/ath/ath5k/initvals.c index 1ffecc0fd3ed..a1ea78e05b47 100644 --- a/drivers/net/wireless/ath/ath5k/initvals.c +++ b/drivers/net/wireless/ath/ath5k/initvals.c @@ -23,24 +23,27 @@ #include "reg.h" #include "debug.h" -/* - * Mode-independent initial register writes +/** + * struct ath5k_ini - Mode-independent initial register writes + * @ini_register: Register address + * @ini_value: Default value + * @ini_mode: 0 to write 1 to read (and clear) */ - struct ath5k_ini { u16 ini_register; u32 ini_value; enum { AR5K_INI_WRITE = 0, /* Default */ - AR5K_INI_READ = 1, /* Cleared on read */ + AR5K_INI_READ = 1, } ini_mode; }; -/* - * Mode specific initial register values +/** + * struct ath5k_ini_mode - Mode specific initial register values + * @mode_register: Register address + * @mode_value: Set of values for each enum ath5k_driver_mode */ - struct ath5k_ini_mode { u16 mode_register; u32 mode_value[3]; @@ -386,11 +389,10 @@ static const struct ath5k_ini ar5211_ini[] = { /* Initial mode-specific settings for AR5211 * 5211 supports OFDM-only g (draft g) but we - * need to test it ! - */ + * need to test it ! */ static const struct ath5k_ini_mode ar5211_ini_mode[] = { { AR5K_TXCFG, - /* A/XR B G */ + /* A B G */ { 0x00000015, 0x0000001d, 0x00000015 } }, { AR5K_QUEUE_DFS_LOCAL_IFS(0), { 0x002ffc0f, 0x002ffc1f, 0x002ffc0f } }, @@ -460,7 +462,7 @@ static const struct ath5k_ini_mode ar5211_ini_mode[] = { { 0x00000010, 0x00000010, 0x00000010 } }, }; -/* Initial register settings for AR5212 */ +/* Initial register settings for AR5212 and newer chips */ static const struct ath5k_ini ar5212_ini_common_start[] = { { AR5K_RXDP, 0x00000000 }, { AR5K_RXCFG, 0x00000005 }, @@ -724,7 +726,8 @@ static const struct ath5k_ini_mode ar5212_ini_mode_start[] = { { 0x00000000, 0x00000000, 0x00000108 } }, }; -/* Initial mode-specific settings for AR5212 + RF5111 (Written after ar5212_ini) */ +/* Initial mode-specific settings for AR5212 + RF5111 + * (Written after ar5212_ini) */ static const struct ath5k_ini_mode rf5111_ini_mode_end[] = { { AR5K_TXCFG, /* A/XR B G */ @@ -757,6 +760,7 @@ static const struct ath5k_ini_mode rf5111_ini_mode_end[] = { { 0x1883800a, 0x1873800a, 0x1883800a } }, }; +/* Common for all modes */ static const struct ath5k_ini rf5111_ini_common_end[] = { { AR5K_DCU_FP, 0x00000000 }, { AR5K_PHY_AGC, 0x00000000 }, @@ -774,7 +778,9 @@ static const struct ath5k_ini rf5111_ini_common_end[] = { { 0xa23c, 0x13c889af }, }; -/* Initial mode-specific settings for AR5212 + RF5112 (Written after ar5212_ini) */ + +/* Initial mode-specific settings for AR5212 + RF5112 + * (Written after ar5212_ini) */ static const struct ath5k_ini_mode rf5112_ini_mode_end[] = { { AR5K_TXCFG, /* A/XR B G */ @@ -825,7 +831,9 @@ static const struct ath5k_ini rf5112_ini_common_end[] = { { 0xa23c, 0x13c889af }, }; -/* Initial mode-specific settings for RF5413/5414 (Written after ar5212_ini) */ + +/* Initial mode-specific settings for RF5413/5414 + * (Written after ar5212_ini) */ static const struct ath5k_ini_mode rf5413_ini_mode_end[] = { { AR5K_TXCFG, /* A/XR B G */ @@ -963,7 +971,8 @@ static const struct ath5k_ini rf5413_ini_common_end[] = { { 0xa384, 0xf3307ff0 }, }; -/* Initial mode-specific settings for RF2413/2414 (Written after ar5212_ini) */ +/* Initial mode-specific settings for RF2413/2414 + * (Written after ar5212_ini) */ /* XXX: a mode ? */ static const struct ath5k_ini_mode rf2413_ini_mode_end[] = { { AR5K_TXCFG, @@ -1085,7 +1094,8 @@ static const struct ath5k_ini rf2413_ini_common_end[] = { { 0xa384, 0xf3307ff0 }, }; -/* Initial mode-specific settings for RF2425 (Written after ar5212_ini) */ +/* Initial mode-specific settings for RF2425 + * (Written after ar5212_ini) */ /* XXX: a mode ? */ static const struct ath5k_ini_mode rf2425_ini_mode_end[] = { { AR5K_TXCFG, @@ -1357,10 +1367,15 @@ static const struct ath5k_ini rf5112_ini_bbgain[] = { }; -/* - * Write initial register dump +/** + * ath5k_hw_ini_registers() - Write initial register dump common for all modes + * @ah: The &struct ath5k_hw + * @size: Dump size + * @ini_regs: The array of &struct ath5k_ini + * @skip_pcu: Skip PCU registers */ -static void ath5k_hw_ini_registers(struct ath5k_hw *ah, unsigned int size, +static void +ath5k_hw_ini_registers(struct ath5k_hw *ah, unsigned int size, const struct ath5k_ini *ini_regs, bool skip_pcu) { unsigned int i; @@ -1388,7 +1403,15 @@ static void ath5k_hw_ini_registers(struct ath5k_hw *ah, unsigned int size, } } -static void ath5k_hw_ini_mode_registers(struct ath5k_hw *ah, +/** + * ath5k_hw_ini_mode_registers() - Write initial mode-specific register dump + * @ah: The &struct ath5k_hw + * @size: Dump size + * @ini_mode: The array of &struct ath5k_ini_mode + * @mode: One of enum ath5k_driver_mode + */ +static void +ath5k_hw_ini_mode_registers(struct ath5k_hw *ah, unsigned int size, const struct ath5k_ini_mode *ini_mode, u8 mode) { @@ -1402,7 +1425,17 @@ static void ath5k_hw_ini_mode_registers(struct ath5k_hw *ah, } -int ath5k_hw_write_initvals(struct ath5k_hw *ah, u8 mode, bool skip_pcu) +/** + * ath5k_hw_write_initvals() - Write initial chip-specific register dump + * @ah: The &struct ath5k_hw + * @mode: One of enum ath5k_driver_mode + * @skip_pcu: Skip PCU registers + * + * Write initial chip-specific register dump, to get the chipset on a + * clean and ready-to-work state after warm reset. + */ +int +ath5k_hw_write_initvals(struct ath5k_hw *ah, u8 mode, bool skip_pcu) { /* * Write initial register settings diff --git a/drivers/net/wireless/ath/ath5k/pcu.c b/drivers/net/wireless/ath/ath5k/pcu.c index a7eafa3edc21..cebfd6fd31d3 100644 --- a/drivers/net/wireless/ath/ath5k/pcu.c +++ b/drivers/net/wireless/ath/ath5k/pcu.c @@ -30,11 +30,47 @@ #include "reg.h" #include "debug.h" -/* +/** + * DOC: Protocol Control Unit (PCU) functions + * + * Protocol control unit is responsible to maintain various protocol + * properties before a frame is send and after a frame is received to/from + * baseband. To be more specific, PCU handles: + * + * - Buffering of RX and TX frames (after QCU/DCUs) + * + * - Encrypting and decrypting (using the built-in engine) + * + * - Generating ACKs, RTS/CTS frames + * + * - Maintaining TSF + * + * - FCS + * + * - Updating beacon data (with TSF etc) + * + * - Generating virtual CCA + * + * - RX/Multicast filtering + * + * - BSSID filtering + * + * - Various statistics + * + * -Different operating modes: AP, STA, IBSS + * + * Note: Most of these functions can be tweaked/bypassed so you can do + * them on sw above for debugging or research. For more infos check out PCU + * registers on reg.h. + */ + +/** + * DOC: ACK rates + * * AR5212+ can use higher rates for ack transmission * based on current tx rate instead of the base rate. * It does this to better utilize channel usage. - * This is a mapping between G rates (that cover both + * There is a mapping between G rates (that cover both * CCK and OFDM) and ack rates that we use when setting * rate -> duration table. This mapping is hw-based so * don't change anything. @@ -63,17 +99,18 @@ static const unsigned int ack_rates_high[] = \*******************/ /** - * ath5k_hw_get_frame_duration - Get tx time of a frame - * + * ath5k_hw_get_frame_duration() - Get tx time of a frame * @ah: The &struct ath5k_hw * @len: Frame's length in bytes * @rate: The @struct ieee80211_rate + * @shortpre: Indicate short preample * * Calculate tx duration of a frame given it's rate and length * It extends ieee80211_generic_frame_duration for non standard * bwmodes. */ -int ath5k_hw_get_frame_duration(struct ath5k_hw *ah, +int +ath5k_hw_get_frame_duration(struct ath5k_hw *ah, int len, struct ieee80211_rate *rate, bool shortpre) { int sifs, preamble, plcp_bits, sym_time; @@ -129,11 +166,11 @@ int ath5k_hw_get_frame_duration(struct ath5k_hw *ah, } /** - * ath5k_hw_get_default_slottime - Get the default slot time for current mode - * + * ath5k_hw_get_default_slottime() - Get the default slot time for current mode * @ah: The &struct ath5k_hw */ -unsigned int ath5k_hw_get_default_slottime(struct ath5k_hw *ah) +unsigned int +ath5k_hw_get_default_slottime(struct ath5k_hw *ah) { struct ieee80211_channel *channel = ah->ah_current_channel; unsigned int slot_time; @@ -160,11 +197,11 @@ unsigned int ath5k_hw_get_default_slottime(struct ath5k_hw *ah) } /** - * ath5k_hw_get_default_sifs - Get the default SIFS for current mode - * + * ath5k_hw_get_default_sifs() - Get the default SIFS for current mode * @ah: The &struct ath5k_hw */ -unsigned int ath5k_hw_get_default_sifs(struct ath5k_hw *ah) +unsigned int +ath5k_hw_get_default_sifs(struct ath5k_hw *ah) { struct ieee80211_channel *channel = ah->ah_current_channel; unsigned int sifs; @@ -191,17 +228,17 @@ unsigned int ath5k_hw_get_default_sifs(struct ath5k_hw *ah) } /** - * ath5k_hw_update_mib_counters - Update MIB counters (mac layer statistics) - * + * ath5k_hw_update_mib_counters() - Update MIB counters (mac layer statistics) * @ah: The &struct ath5k_hw * * Reads MIB counters from PCU and updates sw statistics. Is called after a * MIB interrupt, because one of these counters might have reached their maximum * and triggered the MIB interrupt, to let us read and clear the counter. * - * Is called in interrupt context! + * NOTE: Is called in interrupt context! */ -void ath5k_hw_update_mib_counters(struct ath5k_hw *ah) +void +ath5k_hw_update_mib_counters(struct ath5k_hw *ah) { struct ath5k_statistics *stats = &ah->stats; @@ -219,10 +256,8 @@ void ath5k_hw_update_mib_counters(struct ath5k_hw *ah) \******************/ /** - * ath5k_hw_write_rate_duration - fill rate code to duration table - * - * @ah: the &struct ath5k_hw - * @mode: one of enum ath5k_driver_mode + * ath5k_hw_write_rate_duration() - Fill rate code to duration table + * @ah: The &struct ath5k_hw * * Write the rate code to duration table upon hw reset. This is a helper for * ath5k_hw_pcu_init(). It seems all this is doing is setting an ACK timeout on @@ -236,7 +271,8 @@ void ath5k_hw_update_mib_counters(struct ath5k_hw *ah) * that include all OFDM and CCK rates. * */ -static inline void ath5k_hw_write_rate_duration(struct ath5k_hw *ah) +static inline void +ath5k_hw_write_rate_duration(struct ath5k_hw *ah) { struct ieee80211_rate *rate; unsigned int i; @@ -280,12 +316,12 @@ static inline void ath5k_hw_write_rate_duration(struct ath5k_hw *ah) } /** - * ath5k_hw_set_ack_timeout - Set ACK timeout on PCU - * + * ath5k_hw_set_ack_timeout() - Set ACK timeout on PCU * @ah: The &struct ath5k_hw * @timeout: Timeout in usec */ -static int ath5k_hw_set_ack_timeout(struct ath5k_hw *ah, unsigned int timeout) +static int +ath5k_hw_set_ack_timeout(struct ath5k_hw *ah, unsigned int timeout) { if (ath5k_hw_clocktoh(ah, AR5K_REG_MS(0xffffffff, AR5K_TIME_OUT_ACK)) <= timeout) @@ -298,12 +334,12 @@ static int ath5k_hw_set_ack_timeout(struct ath5k_hw *ah, unsigned int timeout) } /** - * ath5k_hw_set_cts_timeout - Set CTS timeout on PCU - * + * ath5k_hw_set_cts_timeout() - Set CTS timeout on PCU * @ah: The &struct ath5k_hw * @timeout: Timeout in usec */ -static int ath5k_hw_set_cts_timeout(struct ath5k_hw *ah, unsigned int timeout) +static int +ath5k_hw_set_cts_timeout(struct ath5k_hw *ah, unsigned int timeout) { if (ath5k_hw_clocktoh(ah, AR5K_REG_MS(0xffffffff, AR5K_TIME_OUT_CTS)) <= timeout) @@ -321,14 +357,14 @@ static int ath5k_hw_set_cts_timeout(struct ath5k_hw *ah, unsigned int timeout) \*******************/ /** - * ath5k_hw_set_lladdr - Set station id - * + * ath5k_hw_set_lladdr() - Set station id * @ah: The &struct ath5k_hw - * @mac: The card's mac address + * @mac: The card's mac address (array of octets) * * Set station id on hw using the provided mac address */ -int ath5k_hw_set_lladdr(struct ath5k_hw *ah, const u8 *mac) +int +ath5k_hw_set_lladdr(struct ath5k_hw *ah, const u8 *mac) { struct ath_common *common = ath5k_hw_common(ah); u32 low_id, high_id; @@ -349,14 +385,14 @@ int ath5k_hw_set_lladdr(struct ath5k_hw *ah, const u8 *mac) } /** - * ath5k_hw_set_bssid - Set current BSSID on hw - * + * ath5k_hw_set_bssid() - Set current BSSID on hw * @ah: The &struct ath5k_hw * * Sets the current BSSID and BSSID mask we have from the * common struct into the hardware */ -void ath5k_hw_set_bssid(struct ath5k_hw *ah) +void +ath5k_hw_set_bssid(struct ath5k_hw *ah) { struct ath_common *common = ath5k_hw_common(ah); u16 tim_offset = 0; @@ -389,7 +425,23 @@ void ath5k_hw_set_bssid(struct ath5k_hw *ah) ath5k_hw_enable_pspoll(ah, NULL, 0); } -void ath5k_hw_set_bssid_mask(struct ath5k_hw *ah, const u8 *mask) +/** + * ath5k_hw_set_bssid_mask() - Filter out bssids we listen + * @ah: The &struct ath5k_hw + * @mask: The BSSID mask to set (array of octets) + * + * BSSID masking is a method used by AR5212 and newer hardware to inform PCU + * which bits of the interface's MAC address should be looked at when trying + * to decide which packets to ACK. In station mode and AP mode with a single + * BSS every bit matters since we lock to only one BSS. In AP mode with + * multiple BSSes (virtual interfaces) not every bit matters because hw must + * accept frames for all BSSes and so we tweak some bits of our mac address + * in order to have multiple BSSes. + * + * For more information check out ../hw.c of the common ath module. + */ +void +ath5k_hw_set_bssid_mask(struct ath5k_hw *ah, const u8 *mask) { struct ath_common *common = ath5k_hw_common(ah); @@ -400,18 +452,21 @@ void ath5k_hw_set_bssid_mask(struct ath5k_hw *ah, const u8 *mask) ath_hw_setbssidmask(common); } -/* - * Set multicast filter +/** + * ath5k_hw_set_mcast_filter() - Set multicast filter + * @ah: The &struct ath5k_hw + * @filter0: Lower 32bits of muticast filter + * @filter1: Higher 16bits of multicast filter */ -void ath5k_hw_set_mcast_filter(struct ath5k_hw *ah, u32 filter0, u32 filter1) +void +ath5k_hw_set_mcast_filter(struct ath5k_hw *ah, u32 filter0, u32 filter1) { ath5k_hw_reg_write(ah, filter0, AR5K_MCAST_FILTER0); ath5k_hw_reg_write(ah, filter1, AR5K_MCAST_FILTER1); } /** - * ath5k_hw_get_rx_filter - Get current rx filter - * + * ath5k_hw_get_rx_filter() - Get current rx filter * @ah: The &struct ath5k_hw * * Returns the RX filter by reading rx filter and @@ -420,7 +475,8 @@ void ath5k_hw_set_mcast_filter(struct ath5k_hw *ah, u32 filter0, u32 filter1) * and pass to the driver. For a list of frame types * check out reg.h. */ -u32 ath5k_hw_get_rx_filter(struct ath5k_hw *ah) +u32 +ath5k_hw_get_rx_filter(struct ath5k_hw *ah) { u32 data, filter = 0; @@ -440,8 +496,7 @@ u32 ath5k_hw_get_rx_filter(struct ath5k_hw *ah) } /** - * ath5k_hw_set_rx_filter - Set rx filter - * + * ath5k_hw_set_rx_filter() - Set rx filter * @ah: The &struct ath5k_hw * @filter: RX filter mask (see reg.h) * @@ -449,7 +504,8 @@ u32 ath5k_hw_get_rx_filter(struct ath5k_hw *ah) * register on 5212 and newer chips so that we have proper PHY * error reporting. */ -void ath5k_hw_set_rx_filter(struct ath5k_hw *ah, u32 filter) +void +ath5k_hw_set_rx_filter(struct ath5k_hw *ah, u32 filter) { u32 data = 0; @@ -493,13 +549,13 @@ void ath5k_hw_set_rx_filter(struct ath5k_hw *ah, u32 filter) #define ATH5K_MAX_TSF_READ 10 /** - * ath5k_hw_get_tsf64 - Get the full 64bit TSF - * + * ath5k_hw_get_tsf64() - Get the full 64bit TSF * @ah: The &struct ath5k_hw * * Returns the current TSF */ -u64 ath5k_hw_get_tsf64(struct ath5k_hw *ah) +u64 +ath5k_hw_get_tsf64(struct ath5k_hw *ah) { u32 tsf_lower, tsf_upper1, tsf_upper2; int i; @@ -536,28 +592,30 @@ u64 ath5k_hw_get_tsf64(struct ath5k_hw *ah) return ((u64)tsf_upper1 << 32) | tsf_lower; } +#undef ATH5K_MAX_TSF_READ + /** - * ath5k_hw_set_tsf64 - Set a new 64bit TSF - * + * ath5k_hw_set_tsf64() - Set a new 64bit TSF * @ah: The &struct ath5k_hw * @tsf64: The new 64bit TSF * * Sets the new TSF */ -void ath5k_hw_set_tsf64(struct ath5k_hw *ah, u64 tsf64) +void +ath5k_hw_set_tsf64(struct ath5k_hw *ah, u64 tsf64) { ath5k_hw_reg_write(ah, tsf64 & 0xffffffff, AR5K_TSF_L32); ath5k_hw_reg_write(ah, (tsf64 >> 32) & 0xffffffff, AR5K_TSF_U32); } /** - * ath5k_hw_reset_tsf - Force a TSF reset - * + * ath5k_hw_reset_tsf() - Force a TSF reset * @ah: The &struct ath5k_hw * * Forces a TSF reset on PCU */ -void ath5k_hw_reset_tsf(struct ath5k_hw *ah) +void +ath5k_hw_reset_tsf(struct ath5k_hw *ah) { u32 val; @@ -573,10 +631,17 @@ void ath5k_hw_reset_tsf(struct ath5k_hw *ah) ath5k_hw_reg_write(ah, val, AR5K_BEACON); } -/* - * Initialize beacon timers +/** + * ath5k_hw_init_beacon_timers() - Initialize beacon timers + * @ah: The &struct ath5k_hw + * @next_beacon: Next TBTT + * @interval: Current beacon interval + * + * This function is used to initialize beacon timers based on current + * operation mode and settings. */ -void ath5k_hw_init_beacon(struct ath5k_hw *ah, u32 next_beacon, u32 interval) +void +ath5k_hw_init_beacon_timers(struct ath5k_hw *ah, u32 next_beacon, u32 interval) { u32 timer1, timer2, timer3; @@ -655,8 +720,7 @@ void ath5k_hw_init_beacon(struct ath5k_hw *ah, u32 next_beacon, u32 interval) } /** - * ath5k_check_timer_win - Check if timer B is timer A + window - * + * ath5k_check_timer_win() - Check if timer B is timer A + window * @a: timer a (before b) * @b: timer b (after a) * @window: difference between a and b @@ -686,12 +750,11 @@ ath5k_check_timer_win(int a, int b, int window, int intval) } /** - * ath5k_hw_check_beacon_timers - Check if the beacon timers are correct - * + * ath5k_hw_check_beacon_timers() - Check if the beacon timers are correct * @ah: The &struct ath5k_hw * @intval: beacon interval * - * This is a workaround for IBSS mode: + * This is a workaround for IBSS mode * * The need for this function arises from the fact that we have 4 separate * HW timer registers (TIMER0 - TIMER3), which are closely related to the @@ -746,14 +809,14 @@ ath5k_hw_check_beacon_timers(struct ath5k_hw *ah, int intval) } /** - * ath5k_hw_set_coverage_class - Set IEEE 802.11 coverage class - * + * ath5k_hw_set_coverage_class() - Set IEEE 802.11 coverage class * @ah: The &struct ath5k_hw * @coverage_class: IEEE 802.11 coverage class number * * Sets IFS intervals and ACK/CTS timeouts for given coverage class. */ -void ath5k_hw_set_coverage_class(struct ath5k_hw *ah, u8 coverage_class) +void +ath5k_hw_set_coverage_class(struct ath5k_hw *ah, u8 coverage_class) { /* As defined by IEEE 802.11-2007 17.3.8.6 */ int slot_time = ath5k_hw_get_default_slottime(ah) + 3 * coverage_class; @@ -772,8 +835,7 @@ void ath5k_hw_set_coverage_class(struct ath5k_hw *ah, u8 coverage_class) \***************************/ /** - * ath5k_hw_start_rx_pcu - Start RX engine - * + * ath5k_hw_start_rx_pcu() - Start RX engine * @ah: The &struct ath5k_hw * * Starts RX engine on PCU so that hw can process RXed frames @@ -781,32 +843,33 @@ void ath5k_hw_set_coverage_class(struct ath5k_hw *ah, u8 coverage_class) * * NOTE: RX DMA should be already enabled using ath5k_hw_start_rx_dma */ -void ath5k_hw_start_rx_pcu(struct ath5k_hw *ah) +void +ath5k_hw_start_rx_pcu(struct ath5k_hw *ah) { AR5K_REG_DISABLE_BITS(ah, AR5K_DIAG_SW, AR5K_DIAG_SW_DIS_RX); } /** - * at5k_hw_stop_rx_pcu - Stop RX engine - * + * at5k_hw_stop_rx_pcu() - Stop RX engine * @ah: The &struct ath5k_hw * * Stops RX engine on PCU */ -void ath5k_hw_stop_rx_pcu(struct ath5k_hw *ah) +void +ath5k_hw_stop_rx_pcu(struct ath5k_hw *ah) { AR5K_REG_ENABLE_BITS(ah, AR5K_DIAG_SW, AR5K_DIAG_SW_DIS_RX); } /** - * ath5k_hw_set_opmode - Set PCU operating mode - * + * ath5k_hw_set_opmode() - Set PCU operating mode * @ah: The &struct ath5k_hw - * @op_mode: &enum nl80211_iftype operating mode + * @op_mode: One of enum nl80211_iftype * * Configure PCU for the various operating modes (AP/STA etc) */ -int ath5k_hw_set_opmode(struct ath5k_hw *ah, enum nl80211_iftype op_mode) +int +ath5k_hw_set_opmode(struct ath5k_hw *ah, enum nl80211_iftype op_mode) { struct ath_common *common = ath5k_hw_common(ah); u32 pcu_reg, beacon_reg, low_id, high_id; @@ -873,8 +936,17 @@ int ath5k_hw_set_opmode(struct ath5k_hw *ah, enum nl80211_iftype op_mode) return 0; } -void ath5k_hw_pcu_init(struct ath5k_hw *ah, enum nl80211_iftype op_mode, - u8 mode) +/** + * ath5k_hw_pcu_init() - Initialize PCU + * @ah: The &struct ath5k_hw + * @op_mode: One of enum nl80211_iftype + * @mode: One of enum ath5k_driver_mode + * + * This function is used to initialize PCU by setting current + * operation mode and various other settings. + */ +void +ath5k_hw_pcu_init(struct ath5k_hw *ah, enum nl80211_iftype op_mode) { /* Set bssid and bssid mask */ ath5k_hw_set_bssid(ah); diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c index bf097b118bd4..a635441d1fed 100644 --- a/drivers/net/wireless/ath/ath5k/phy.c +++ b/drivers/net/wireless/ath/ath5k/phy.c @@ -1,6 +1,4 @@ /* - * PHY functions - * * Copyright (c) 2004-2007 Reyk Floeter * Copyright (c) 2006-2009 Nick Kossifidis * Copyright (c) 2007-2008 Jiri Slaby @@ -20,6 +18,10 @@ * */ +/***********************\ +* PHY related functions * +\***********************/ + #include #include #include @@ -31,14 +33,53 @@ #include "../regd.h" +/** + * DOC: PHY related functions + * + * Here we handle the low-level functions related to baseband + * and analog frontend (RF) parts. This is by far the most complex + * part of the hw code so make sure you know what you are doing. + * + * Here is a list of what this is all about: + * + * - Channel setting/switching + * + * - Automatic Gain Control (AGC) calibration + * + * - Noise Floor calibration + * + * - I/Q imbalance calibration (QAM correction) + * + * - Calibration due to thermal changes (gain_F) + * + * - Spur noise mitigation + * + * - RF/PHY initialization for the various operating modes and bwmodes + * + * - Antenna control + * + * - TX power control per channel/rate/packet type + * + * Also have in mind we never got documentation for most of these + * functions, what we have comes mostly from Atheros's code, reverse + * engineering and patent docs/presentations etc. + */ + + /******************\ * Helper functions * \******************/ -/* - * Get the PHY Chip revision +/** + * ath5k_hw_radio_revision() - Get the PHY Chip revision + * @ah: The &struct ath5k_hw + * @band: One of enum ieee80211_band + * + * Returns the revision number of a 2GHz, 5GHz or single chip + * radio. */ -u16 ath5k_hw_radio_revision(struct ath5k_hw *ah, enum ieee80211_band band) +u16 +ath5k_hw_radio_revision(struct ath5k_hw *ah, enum ieee80211_band band) { unsigned int i; u32 srev; @@ -81,10 +122,16 @@ u16 ath5k_hw_radio_revision(struct ath5k_hw *ah, enum ieee80211_band band) return ret; } -/* - * Check if a channel is supported +/** + * ath5k_channel_ok() - Check if a channel is supported by the hw + * @ah: The &struct ath5k_hw + * @channel: The &struct ieee80211_channel + * + * Note: We don't do any regulatory domain checks here, it's just + * a sanity check. */ -bool ath5k_channel_ok(struct ath5k_hw *ah, struct ieee80211_channel *channel) +bool +ath5k_channel_ok(struct ath5k_hw *ah, struct ieee80211_channel *channel) { u16 freq = channel->center_freq; @@ -101,7 +148,13 @@ bool ath5k_channel_ok(struct ath5k_hw *ah, struct ieee80211_channel *channel) return false; } -bool ath5k_hw_chan_has_spur_noise(struct ath5k_hw *ah, +/** + * ath5k_hw_chan_has_spur_noise() - Check if channel is sensitive to spur noise + * @ah: The &struct ath5k_hw + * @channel: The &struct ieee80211_channel + */ +bool +ath5k_hw_chan_has_spur_noise(struct ath5k_hw *ah, struct ieee80211_channel *channel) { u8 refclk_freq; @@ -122,11 +175,20 @@ bool ath5k_hw_chan_has_spur_noise(struct ath5k_hw *ah, return false; } -/* - * Used to modify RF Banks before writing them to AR5K_RF_BUFFER +/** + * ath5k_hw_rfb_op() - Perform an operation on the given RF Buffer + * @ah: The &struct ath5k_hw + * @rf_regs: The struct ath5k_rf_reg + * @val: New value + * @reg_id: RF register ID + * @set: Indicate we need to swap data + * + * This is an internal function used to modify RF Banks before + * writing them to AR5K_RF_BUFFER. Check out rfbuffer.h for more + * infos. */ -static unsigned int ath5k_hw_rfb_op(struct ath5k_hw *ah, - const struct ath5k_rf_reg *rf_regs, +static unsigned int +ath5k_hw_rfb_op(struct ath5k_hw *ah, const struct ath5k_rf_reg *rf_regs, u32 val, u8 reg_id, bool set) { const struct ath5k_rf_reg *rfreg = NULL; @@ -204,8 +266,7 @@ static unsigned int ath5k_hw_rfb_op(struct ath5k_hw *ah, } /** - * ath5k_hw_write_ofdm_timings - set OFDM timings on AR5212 - * + * ath5k_hw_write_ofdm_timings() - set OFDM timings on AR5212 * @ah: the &struct ath5k_hw * @channel: the currently set channel upon reset * @@ -216,10 +277,11 @@ static unsigned int ath5k_hw_rfb_op(struct ath5k_hw *ah, * mantissa and provide these values on hw. * * For more infos i think this patent is related - * http://www.freepatentsonline.com/7184495.html + * "http://www.freepatentsonline.com/7184495.html" */ -static inline int ath5k_hw_write_ofdm_timings(struct ath5k_hw *ah, - struct ieee80211_channel *channel) +static inline int +ath5k_hw_write_ofdm_timings(struct ath5k_hw *ah, + struct ieee80211_channel *channel) { /* Get exponent and mantissa and set it */ u32 coef_scaled, coef_exp, coef_man, @@ -278,6 +340,10 @@ static inline int ath5k_hw_write_ofdm_timings(struct ath5k_hw *ah, return 0; } +/** + * ath5k_hw_phy_disable() - Disable PHY + * @ah: The &struct ath5k_hw + */ int ath5k_hw_phy_disable(struct ath5k_hw *ah) { /*Just a try M.F.*/ @@ -286,10 +352,13 @@ int ath5k_hw_phy_disable(struct ath5k_hw *ah) return 0; } -/* - * Wait for synth to settle +/** + * ath5k_hw_wait_for_synth() - Wait for synth to settle + * @ah: The &struct ath5k_hw + * @channel: The &struct ieee80211_channel */ -static void ath5k_hw_wait_for_synth(struct ath5k_hw *ah, +static void +ath5k_hw_wait_for_synth(struct ath5k_hw *ah, struct ieee80211_channel *channel) { /* @@ -319,7 +388,9 @@ static void ath5k_hw_wait_for_synth(struct ath5k_hw *ah, * RF Gain optimization * \**********************/ -/* +/** + * DOC: RF Gain optimization + * * This code is used to optimize RF gain on different environments * (temperature mostly) based on feedback from a power detector. * @@ -328,19 +399,22 @@ static void ath5k_hw_wait_for_synth(struct ath5k_hw *ah, * no gain optimization ladder-. * * For more infos check out this patent doc - * http://www.freepatentsonline.com/7400691.html + * "http://www.freepatentsonline.com/7400691.html" * * This paper describes power drops as seen on the receiver due to * probe packets - * http://www.cnri.dit.ie/publications/ICT08%20-%20Practical%20Issues - * %20of%20Power%20Control.pdf + * "http://www.cnri.dit.ie/publications/ICT08%20-%20Practical%20Issues + * %20of%20Power%20Control.pdf" * * And this is the MadWiFi bug entry related to the above - * http://madwifi-project.org/ticket/1659 + * "http://madwifi-project.org/ticket/1659" * with various measurements and diagrams */ -/* Initialize ah_gain during attach */ +/** + * ath5k_hw_rfgain_opt_init() - Initialize ah_gain during attach + * @ah: The &struct ath5k_hw + */ int ath5k_hw_rfgain_opt_init(struct ath5k_hw *ah) { /* Initialize the gain optimization values */ @@ -364,7 +438,11 @@ int ath5k_hw_rfgain_opt_init(struct ath5k_hw *ah) return 0; } -/* Schedule a gain probe check on the next transmitted packet. +/** + * ath5k_hw_request_rfgain_probe() - Request a PAPD probe packet + * @ah: The &struct ath5k_hw + * + * Schedules a gain probe check on the next transmitted packet. * That means our next packet is going to be sent with lower * tx power and a Peak to Average Power Detector (PAPD) will try * to measure the gain. @@ -373,7 +451,8 @@ int ath5k_hw_rfgain_opt_init(struct ath5k_hw *ah) * just after we enable the probe so that we don't mess with * standard traffic. */ -static void ath5k_hw_request_rfgain_probe(struct ath5k_hw *ah) +static void +ath5k_hw_request_rfgain_probe(struct ath5k_hw *ah) { /* Skip if gain calibration is inactive or @@ -391,9 +470,15 @@ static void ath5k_hw_request_rfgain_probe(struct ath5k_hw *ah) } -/* Calculate gain_F measurement correction - * based on the current step for RF5112 rev. 2 */ -static u32 ath5k_hw_rf_gainf_corr(struct ath5k_hw *ah) +/** + * ath5k_hw_rf_gainf_corr() - Calculate Gain_F measurement correction + * @ah: The &struct ath5k_hw + * + * Calculate Gain_F measurement correction + * based on the current step for RF5112 rev. 2 + */ +static u32 +ath5k_hw_rf_gainf_corr(struct ath5k_hw *ah) { u32 mix, step; u32 *rf; @@ -446,11 +531,19 @@ static u32 ath5k_hw_rf_gainf_corr(struct ath5k_hw *ah) return ah->ah_gain.g_f_corr; } -/* Check if current gain_F measurement is in the range of our +/** + * ath5k_hw_rf_check_gainf_readback() - Validate Gain_F feedback from detector + * @ah: The &struct ath5k_hw + * + * Check if current gain_F measurement is in the range of our * power detector windows. If we get a measurement outside range * we know it's not accurate (detectors can't measure anything outside - * their detection window) so we must ignore it */ -static bool ath5k_hw_rf_check_gainf_readback(struct ath5k_hw *ah) + * their detection window) so we must ignore it. + * + * Returns true if readback was O.K. or false on failure + */ +static bool +ath5k_hw_rf_check_gainf_readback(struct ath5k_hw *ah) { const struct ath5k_rf_reg *rf_regs; u32 step, mix_ovr, level[4]; @@ -502,9 +595,15 @@ static bool ath5k_hw_rf_check_gainf_readback(struct ath5k_hw *ah) ah->ah_gain.g_current <= level[3]); } -/* Perform gain_F adjustment by choosing the right set - * of parameters from RF gain optimization ladder */ -static s8 ath5k_hw_rf_gainf_adjust(struct ath5k_hw *ah) +/** + * ath5k_hw_rf_gainf_adjust() - Perform Gain_F adjustment + * @ah: The &struct ath5k_hw + * + * Choose the right target gain based on current gain + * and RF gain optimization ladder + */ +static s8 +ath5k_hw_rf_gainf_adjust(struct ath5k_hw *ah) { const struct ath5k_gain_opt *go; const struct ath5k_gain_opt_step *g_step; @@ -568,11 +667,18 @@ done: return ret; } -/* Main callback for thermal RF gain calibration engine +/** + * ath5k_hw_gainf_calibrate() - Do a gain_F calibration + * @ah: The &struct ath5k_hw + * + * Main callback for thermal RF gain calibration engine * Check for a new gain reading and schedule an adjustment * if needed. + * + * Returns one of enum ath5k_rfgain codes */ -enum ath5k_rfgain ath5k_hw_gainf_calibrate(struct ath5k_hw *ah) +enum ath5k_rfgain +ath5k_hw_gainf_calibrate(struct ath5k_hw *ah) { u32 data, type; struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom; @@ -632,10 +738,18 @@ done: return ah->ah_gain.g_state; } -/* Write initial RF gain table to set the RF sensitivity - * this one works on all RF chips and has nothing to do - * with gain_F calibration */ -static int ath5k_hw_rfgain_init(struct ath5k_hw *ah, enum ieee80211_band band) +/** + * ath5k_hw_rfgain_init() - Write initial RF gain settings to hw + * @ah: The &struct ath5k_hw + * @band: One of enum ieee80211_band + * + * Write initial RF gain table to set the RF sensitivity. + * + * NOTE: This one works on all RF chips and has nothing to do + * with Gain_F calibration + */ +static int +ath5k_hw_rfgain_init(struct ath5k_hw *ah, enum ieee80211_band band) { const struct ath5k_ini_rfgain *ath5k_rfg; unsigned int i, size, index; @@ -682,16 +796,23 @@ static int ath5k_hw_rfgain_init(struct ath5k_hw *ah, enum ieee80211_band band) } - /********************\ * RF Registers setup * \********************/ -/* - * Setup RF registers by writing RF buffer on hw +/** + * ath5k_hw_rfregs_init() - Initialize RF register settings + * @ah: The &struct ath5k_hw + * @channel: The &struct ieee80211_channel + * @mode: One of enum ath5k_driver_mode + * + * Setup RF registers by writing RF buffer on hw. For + * more infos on this, check out rfbuffer.h */ -static int ath5k_hw_rfregs_init(struct ath5k_hw *ah, - struct ieee80211_channel *channel, unsigned int mode) +static int +ath5k_hw_rfregs_init(struct ath5k_hw *ah, + struct ieee80211_channel *channel, + unsigned int mode) { const struct ath5k_rf_reg *rf_regs; const struct ath5k_ini_rfbuffer *ini_rfb; @@ -1049,19 +1170,18 @@ static int ath5k_hw_rfregs_init(struct ath5k_hw *ah, PHY/RF channel functions \**************************/ -/* - * Conversion needed for RF5110 +/** + * ath5k_hw_rf5110_chan2athchan() - Convert channel freq on RF5110 + * @channel: The &struct ieee80211_channel + * + * Map channel frequency to IEEE channel number and convert it + * to an internal channel value used by the RF5110 chipset. */ -static u32 ath5k_hw_rf5110_chan2athchan(struct ieee80211_channel *channel) +static u32 +ath5k_hw_rf5110_chan2athchan(struct ieee80211_channel *channel) { u32 athchan; - /* - * Convert IEEE channel/MHz to an internal channel value used - * by the AR5210 chipset. This has not been verified with - * newer chipsets like the AR5212A who have a completely - * different RF/PHY part. - */ athchan = (ath5k_hw_bitswap( (ieee80211_frequency_to_channel( channel->center_freq) - 24) / 2, 5) @@ -1069,10 +1189,13 @@ static u32 ath5k_hw_rf5110_chan2athchan(struct ieee80211_channel *channel) return athchan; } -/* - * Set channel on RF5110 +/** + * ath5k_hw_rf5110_channel() - Set channel frequency on RF5110 + * @ah: The &struct ath5k_hw + * @channel: The &struct ieee80211_channel */ -static int ath5k_hw_rf5110_channel(struct ath5k_hw *ah, +static int +ath5k_hw_rf5110_channel(struct ath5k_hw *ah, struct ieee80211_channel *channel) { u32 data; @@ -1088,10 +1211,18 @@ static int ath5k_hw_rf5110_channel(struct ath5k_hw *ah, return 0; } -/* - * Conversion needed for 5111 +/** + * ath5k_hw_rf5111_chan2athchan() - Handle 2GHz channels on RF5111/2111 + * @ieee: IEEE channel number + * @athchan: The &struct ath5k_athchan_2ghz + * + * In order to enable the RF2111 frequency converter on RF5111/2111 setups + * we need to add some offsets and extra flags to the data values we pass + * on to the PHY. So for every 2GHz channel this function gets called + * to do the conversion. */ -static int ath5k_hw_rf5111_chan2athchan(unsigned int ieee, +static int +ath5k_hw_rf5111_chan2athchan(unsigned int ieee, struct ath5k_athchan_2ghz *athchan) { int channel; @@ -1117,10 +1248,13 @@ static int ath5k_hw_rf5111_chan2athchan(unsigned int ieee, return 0; } -/* - * Set channel on 5111 +/** + * ath5k_hw_rf5111_channel() - Set channel frequency on RF5111/2111 + * @ah: The &struct ath5k_hw + * @channel: The &struct ieee80211_channel */ -static int ath5k_hw_rf5111_channel(struct ath5k_hw *ah, +static int +ath5k_hw_rf5111_channel(struct ath5k_hw *ah, struct ieee80211_channel *channel) { struct ath5k_athchan_2ghz ath5k_channel_2ghz; @@ -1165,10 +1299,20 @@ static int ath5k_hw_rf5111_channel(struct ath5k_hw *ah, return 0; } -/* - * Set channel on 5112 and newer +/** + * ath5k_hw_rf5112_channel() - Set channel frequency on 5112 and newer + * @ah: The &struct ath5k_hw + * @channel: The &struct ieee80211_channel + * + * On RF5112/2112 and newer we don't need to do any conversion. + * We pass the frequency value after a few modifications to the + * chip directly. + * + * NOTE: Make sure channel frequency given is within our range or else + * we might damage the chip ! Use ath5k_channel_ok before calling this one. */ -static int ath5k_hw_rf5112_channel(struct ath5k_hw *ah, +static int +ath5k_hw_rf5112_channel(struct ath5k_hw *ah, struct ieee80211_channel *channel) { u32 data, data0, data1, data2; @@ -1177,17 +1321,37 @@ static int ath5k_hw_rf5112_channel(struct ath5k_hw *ah, data = data0 = data1 = data2 = 0; c = channel->center_freq; + /* My guess based on code: + * 2GHz RF has 2 synth modes, one with a Local Oscillator + * at 2224Hz and one with a LO at 2192Hz. IF is 1520Hz + * (3040/2). data0 is used to set the PLL divider and data1 + * selects synth mode. */ if (c < 4800) { + /* Channel 14 and all frequencies with 2Hz spacing + * below/above (non-standard channels) */ if (!((c - 2224) % 5)) { + /* Same as (c - 2224) / 5 */ data0 = ((2 * (c - 704)) - 3040) / 10; data1 = 1; + /* Channel 1 and all frequencies with 5Hz spacing + * below/above (standard channels without channel 14) */ } else if (!((c - 2192) % 5)) { + /* Same as (c - 2192) / 5 */ data0 = ((2 * (c - 672)) - 3040) / 10; data1 = 0; } else return -EINVAL; data0 = ath5k_hw_bitswap((data0 << 2) & 0xff, 8); + /* This is more complex, we have a single synthesizer with + * 4 reference clock settings (?) based on frequency spacing + * and set using data2. LO is at 4800Hz and data0 is again used + * to set some divider. + * + * NOTE: There is an old atheros presentation at Stanford + * that mentions a method called dual direct conversion + * with 1GHz sliding IF for RF5110. Maybe that's what we + * have here, or an updated version. */ } else if ((c % 5) != 2 || c > 5435) { if (!(c % 20) && c >= 5120) { data0 = ath5k_hw_bitswap(((c - 4800) / 20 << 2), 8); @@ -1213,10 +1377,16 @@ static int ath5k_hw_rf5112_channel(struct ath5k_hw *ah, return 0; } -/* - * Set the channel on the RF2425 +/** + * ath5k_hw_rf2425_channel() - Set channel frequency on RF2425 + * @ah: The &struct ath5k_hw + * @channel: The &struct ieee80211_channel + * + * AR2425/2417 have a different 2GHz RF so code changes + * a little bit from RF5112. */ -static int ath5k_hw_rf2425_channel(struct ath5k_hw *ah, +static int +ath5k_hw_rf2425_channel(struct ath5k_hw *ah, struct ieee80211_channel *channel) { u32 data, data0, data2; @@ -1252,10 +1422,16 @@ static int ath5k_hw_rf2425_channel(struct ath5k_hw *ah, return 0; } -/* - * Set a channel on the radio chip +/** + * ath5k_hw_channel() - Set a channel on the radio chip + * @ah: The &struct ath5k_hw + * @channel: The &struct ieee80211_channel + * + * This is the main function called to set a channel on the + * radio chip based on the radio chip version. */ -static int ath5k_hw_channel(struct ath5k_hw *ah, +static int +ath5k_hw_channel(struct ath5k_hw *ah, struct ieee80211_channel *channel) { int ret; @@ -1307,11 +1483,46 @@ static int ath5k_hw_channel(struct ath5k_hw *ah, return 0; } + /*****************\ PHY calibration \*****************/ -static s32 ath5k_hw_read_measured_noise_floor(struct ath5k_hw *ah) +/** + * DOC: PHY Calibration routines + * + * Noise floor calibration: When we tell the hardware to + * perform a noise floor calibration by setting the + * AR5K_PHY_AGCCTL_NF bit on AR5K_PHY_AGCCTL, it will periodically + * sample-and-hold the minimum noise level seen at the antennas. + * This value is then stored in a ring buffer of recently measured + * noise floor values so we have a moving window of the last few + * samples. The median of the values in the history is then loaded + * into the hardware for its own use for RSSI and CCA measurements. + * This type of calibration doesn't interfere with traffic. + * + * AGC calibration: When we tell the hardware to perform + * an AGC (Automatic Gain Control) calibration by setting the + * AR5K_PHY_AGCCTL_CAL, hw disconnects the antennas and does + * a calibration on the DC offsets of ADCs. During this period + * rx/tx gets disabled so we have to deal with it on the driver + * part. + * + * I/Q calibration: When we tell the hardware to perform + * an I/Q calibration, it tries to correct I/Q imbalance and + * fix QAM constellation by sampling data from rxed frames. + * It doesn't interfere with traffic. + * + * For more infos on AGC and I/Q calibration check out patent doc + * #03/094463. + */ + +/** + * ath5k_hw_read_measured_noise_floor() - Read measured NF from hw + * @ah: The &struct ath5k_hw + */ +static s32 +ath5k_hw_read_measured_noise_floor(struct ath5k_hw *ah) { s32 val; @@ -1319,7 +1530,12 @@ static s32 ath5k_hw_read_measured_noise_floor(struct ath5k_hw *ah) return sign_extend32(AR5K_REG_MS(val, AR5K_PHY_NF_MINCCA_PWR), 8); } -void ath5k_hw_init_nfcal_hist(struct ath5k_hw *ah) +/** + * ath5k_hw_init_nfcal_hist() - Initialize NF calibration history buffer + * @ah: The &struct ath5k_hw + */ +void +ath5k_hw_init_nfcal_hist(struct ath5k_hw *ah) { int i; @@ -1328,6 +1544,11 @@ void ath5k_hw_init_nfcal_hist(struct ath5k_hw *ah) ah->ah_nfcal_hist.nfval[i] = AR5K_TUNE_CCA_MAX_GOOD_VALUE; } +/** + * ath5k_hw_update_nfcal_hist() - Update NF calibration history buffer + * @ah: The &struct ath5k_hw + * @noise_floor: The NF we got from hw + */ static void ath5k_hw_update_nfcal_hist(struct ath5k_hw *ah, s16 noise_floor) { struct ath5k_nfcal_hist *hist = &ah->ah_nfcal_hist; @@ -1335,7 +1556,12 @@ static void ath5k_hw_update_nfcal_hist(struct ath5k_hw *ah, s16 noise_floor) hist->nfval[hist->index] = noise_floor; } -static s16 ath5k_hw_get_median_noise_floor(struct ath5k_hw *ah) +/** + * ath5k_hw_get_median_noise_floor() - Get median NF from history buffer + * @ah: The &struct ath5k_hw + */ +static s16 +ath5k_hw_get_median_noise_floor(struct ath5k_hw *ah) { s16 sort[ATH5K_NF_CAL_HIST_MAX]; s16 tmp; @@ -1358,18 +1584,16 @@ static s16 ath5k_hw_get_median_noise_floor(struct ath5k_hw *ah) return sort[(ATH5K_NF_CAL_HIST_MAX - 1) / 2]; } -/* - * When we tell the hardware to perform a noise floor calibration - * by setting the AR5K_PHY_AGCCTL_NF bit, it will periodically - * sample-and-hold the minimum noise level seen at the antennas. - * This value is then stored in a ring buffer of recently measured - * noise floor values so we have a moving window of the last few - * samples. +/** + * ath5k_hw_update_noise_floor() - Update NF on hardware + * @ah: The &struct ath5k_hw * - * The median of the values in the history is then loaded into the - * hardware for its own use for RSSI and CCA measurements. + * This is the main function we call to perform a NF calibration, + * it reads NF from hardware, calculates the median and updates + * NF on hw. */ -void ath5k_hw_update_noise_floor(struct ath5k_hw *ah) +void +ath5k_hw_update_noise_floor(struct ath5k_hw *ah) { struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom; u32 val; @@ -1436,11 +1660,15 @@ void ath5k_hw_update_noise_floor(struct ath5k_hw *ah) "noise floor calibrated: %d\n", nf); } -/* - * Perform a PHY calibration on RF5110 - * -Fix BPSK/QAM Constellation (I/Q correction) +/** + * ath5k_hw_rf5110_calibrate() - Perform a PHY calibration on RF5110 + * @ah: The &struct ath5k_hw + * @channel: The &struct ieee80211_channel + * + * Do a complete PHY calibration (AGC + NF + I/Q) on RF5110 */ -static int ath5k_hw_rf5110_calibrate(struct ath5k_hw *ah, +static int +ath5k_hw_rf5110_calibrate(struct ath5k_hw *ah, struct ieee80211_channel *channel) { u32 phy_sig, phy_agc, phy_sat, beacon; @@ -1535,8 +1763,9 @@ static int ath5k_hw_rf5110_calibrate(struct ath5k_hw *ah, return 0; } -/* - * Perform I/Q calibration on RF5111/5112 and newer chips +/** + * ath5k_hw_rf511x_iq_calibrate() - Perform I/Q calibration on RF5111 and newer + * @ah: The &struct ath5k_hw */ static int ath5k_hw_rf511x_iq_calibrate(struct ath5k_hw *ah) @@ -1610,10 +1839,17 @@ ath5k_hw_rf511x_iq_calibrate(struct ath5k_hw *ah) return 0; } -/* - * Perform a PHY calibration +/** + * ath5k_hw_phy_calibrate() - Perform a PHY calibration + * @ah: The &struct ath5k_hw + * @channel: The &struct ieee80211_channel + * + * The main function we call from above to perform + * a short or full PHY calibration based on RF chip + * and current channel */ -int ath5k_hw_phy_calibrate(struct ath5k_hw *ah, +int +ath5k_hw_phy_calibrate(struct ath5k_hw *ah, struct ieee80211_channel *channel) { int ret; @@ -1668,6 +1904,16 @@ int ath5k_hw_phy_calibrate(struct ath5k_hw *ah, * Spur mitigation functions * \***************************/ +/** + * ath5k_hw_set_spur_mitigation_filter() - Configure SPUR filter + * @ah: The &struct ath5k_hw + * @channel: The &struct ieee80211_channel + * + * This function gets called during PHY initialization to + * configure the spur filter for the given channel. Spur is noise + * generated due to "reflection" effects, for more information on this + * method check out patent US7643810 + */ static void ath5k_hw_set_spur_mitigation_filter(struct ath5k_hw *ah, struct ieee80211_channel *channel) @@ -1907,15 +2153,73 @@ ath5k_hw_set_spur_mitigation_filter(struct ath5k_hw *ah, * Antenna control * \*****************/ -static void /*TODO:Boundary check*/ +/** + * DOC: Antenna control + * + * Hw supports up to 14 antennas ! I haven't found any card that implements + * that. The maximum number of antennas I've seen is up to 4 (2 for 2GHz and 2 + * for 5GHz). Antenna 1 (MAIN) should be omnidirectional, 2 (AUX) + * omnidirectional or sectorial and antennas 3-14 sectorial (or directional). + * + * We can have a single antenna for RX and multiple antennas for TX. + * RX antenna is our "default" antenna (usually antenna 1) set on + * DEFAULT_ANTENNA register and TX antenna is set on each TX control descriptor + * (0 for automatic selection, 1 - 14 antenna number). + * + * We can let hw do all the work doing fast antenna diversity for both + * tx and rx or we can do things manually. Here are the options we have + * (all are bits of STA_ID1 register): + * + * AR5K_STA_ID1_DEFAULT_ANTENNA -> When 0 is set as the TX antenna on TX + * control descriptor, use the default antenna to transmit or else use the last + * antenna on which we received an ACK. + * + * AR5K_STA_ID1_DESC_ANTENNA -> Update default antenna after each TX frame to + * the antenna on which we got the ACK for that frame. + * + * AR5K_STA_ID1_RTS_DEF_ANTENNA -> Use default antenna for RTS or else use the + * one on the TX descriptor. + * + * AR5K_STA_ID1_SELFGEN_DEF_ANT -> Use default antenna for self generated frames + * (ACKs etc), or else use current antenna (the one we just used for TX). + * + * Using the above we support the following scenarios: + * + * AR5K_ANTMODE_DEFAULT -> Hw handles antenna diversity etc automatically + * + * AR5K_ANTMODE_FIXED_A -> Only antenna A (MAIN) is present + * + * AR5K_ANTMODE_FIXED_B -> Only antenna B (AUX) is present + * + * AR5K_ANTMODE_SINGLE_AP -> Sta locked on a single ap + * + * AR5K_ANTMODE_SECTOR_AP -> AP with tx antenna set on tx desc + * + * AR5K_ANTMODE_SECTOR_STA -> STA with tx antenna set on tx desc + * + * AR5K_ANTMODE_DEBUG Debug mode -A -> Rx, B-> Tx- + * + * Also note that when setting antenna to F on tx descriptor card inverts + * current tx antenna. + */ + +/** + * ath5k_hw_set_def_antenna() - Set default rx antenna on AR5211/5212 and newer + * @ah: The &struct ath5k_hw + * @ant: Antenna number + */ +static void ath5k_hw_set_def_antenna(struct ath5k_hw *ah, u8 ant) { if (ah->ah_version != AR5K_AR5210) ath5k_hw_reg_write(ah, ant & 0x7, AR5K_DEFAULT_ANTENNA); } -/* - * Enable/disable fast rx antenna diversity +/** + * ath5k_hw_set_fast_div() - Enable/disable fast rx antenna diversity + * @ah: The &struct ath5k_hw + * @ee_mode: One of enum ath5k_driver_mode + * @enable: True to enable, false to disable */ static void ath5k_hw_set_fast_div(struct ath5k_hw *ah, u8 ee_mode, bool enable) @@ -1955,6 +2259,14 @@ ath5k_hw_set_fast_div(struct ath5k_hw *ah, u8 ee_mode, bool enable) } } +/** + * ath5k_hw_set_antenna_switch() - Set up antenna switch table + * @ah: The &struct ath5k_hw + * @ee_mode: One of enum ath5k_driver_mode + * + * Switch table comes from EEPROM and includes information on controlling + * the 2 antenna RX attenuators + */ void ath5k_hw_set_antenna_switch(struct ath5k_hw *ah, u8 ee_mode) { @@ -1986,8 +2298,10 @@ ath5k_hw_set_antenna_switch(struct ath5k_hw *ah, u8 ee_mode) AR5K_PHY_ANT_SWITCH_TABLE_1); } -/* - * Set antenna operating mode +/** + * ath5k_hw_set_antenna_mode() - Set antenna operating mode + * @ah: The &struct ath5k_hw + * @ant_mode: One of enum ath5k_ant_mode */ void ath5k_hw_set_antenna_mode(struct ath5k_hw *ah, u8 ant_mode) @@ -2110,8 +2424,13 @@ ath5k_hw_set_antenna_mode(struct ath5k_hw *ah, u8 ant_mode) * Helper functions */ -/* - * Do linear interpolation between two given (x, y) points +/** + * ath5k_get_interpolated_value() - Get interpolated Y val between two points + * @target: X value of the middle point + * @x_left: X value of the left point + * @x_right: X value of the right point + * @y_left: Y value of the left point + * @y_right: Y value of the right point */ static s16 ath5k_get_interpolated_value(s16 target, s16 x_left, s16 x_right, @@ -2138,13 +2457,18 @@ ath5k_get_interpolated_value(s16 target, s16 x_left, s16 x_right, return result; } -/* - * Find vertical boundary (min pwr) for the linear PCDAC curve. +/** + * ath5k_get_linear_pcdac_min() - Find vertical boundary (min pwr) for the + * linear PCDAC curve + * @stepL: Left array with y values (pcdac steps) + * @stepR: Right array with y values (pcdac steps) + * @pwrL: Left array with x values (power steps) + * @pwrR: Right array with x values (power steps) * * Since we have the top of the curve and we draw the line below * until we reach 1 (1 pcdac step) we need to know which point - * (x value) that is so that we don't go below y axis and have negative - * pcdac values when creating the curve, or fill the table with zeroes. + * (x value) that is so that we don't go below x axis and have negative + * pcdac values when creating the curve, or fill the table with zeros. */ static s16 ath5k_get_linear_pcdac_min(const u8 *stepL, const u8 *stepR, @@ -2190,7 +2514,16 @@ ath5k_get_linear_pcdac_min(const u8 *stepL, const u8 *stepR, return max(min_pwrL, min_pwrR); } -/* +/** + * ath5k_create_power_curve() - Create a Power to PDADC or PCDAC curve + * @pmin: Minimum power value (xmin) + * @pmax: Maximum power value (xmax) + * @pwr: Array of power steps (x values) + * @vpd: Array of matching PCDAC/PDADC steps (y values) + * @num_points: Number of provided points + * @vpd_table: Array to fill with the full PCDAC/PDADC values (y values) + * @type: One of enum ath5k_powertable_type (eeprom.h) + * * Interpolate (pwr,vpd) points to create a Power to PDADC or a * Power to PCDAC curve. * @@ -2248,7 +2581,14 @@ ath5k_create_power_curve(s16 pmin, s16 pmax, } } -/* +/** + * ath5k_get_chan_pcal_surrounding_piers() - Get surrounding calibration piers + * for a given channel. + * @ah: The &struct ath5k_hw + * @channel: The &struct ieee80211_channel + * @pcinfo_l: The &struct ath5k_chan_pcal_info to put the left cal. pier + * @pcinfo_r: The &struct ath5k_chan_pcal_info to put the right cal. pier + * * Get the surrounding per-channel power calibration piers * for a given frequency so that we can interpolate between * them and come up with an appropriate dataset for our current @@ -2331,11 +2671,17 @@ done: *pcinfo_r = &pcinfo[idx_r]; } -/* +/** + * ath5k_get_rate_pcal_data() - Get the interpolated per-rate power + * calibration data + * @ah: The &struct ath5k_hw *ah, + * @channel: The &struct ieee80211_channel + * @rates: The &struct ath5k_rate_pcal_info to fill + * * Get the surrounding per-rate power calibration data * for a given frequency and interpolate between power * values to set max target power supported by hw for - * each rate. + * each rate on this frequency. */ static void ath5k_get_rate_pcal_data(struct ath5k_hw *ah, @@ -2423,7 +2769,11 @@ done: rpinfo[idx_r].target_power_54); } -/* +/** + * ath5k_get_max_ctl_power() - Get max edge power for a given frequency + * @ah: the &struct ath5k_hw + * @channel: The &struct ieee80211_channel + * * Get the max edge power for this channel if * we have such data from EEPROM's Conformance Test * Limits (CTL), and limit max power if needed. @@ -2503,8 +2853,39 @@ ath5k_get_max_ctl_power(struct ath5k_hw *ah, * Power to PCDAC table functions */ -/* - * Fill Power to PCDAC table on RF5111 +/** + * DOC: Power to PCDAC table functions + * + * For RF5111 we have an XPD -eXternal Power Detector- curve + * for each calibrated channel. Each curve has 0,5dB Power steps + * on x axis and PCDAC steps (offsets) on y axis and looks like an + * exponential function. To recreate the curve we read 11 points + * from eeprom (eeprom.c) and interpolate here. + * + * For RF5112 we have 4 XPD -eXternal Power Detector- curves + * for each calibrated channel on 0, -6, -12 and -18dBm but we only + * use the higher (3) and the lower (0) curves. Each curve again has 0.5dB + * power steps on x axis and PCDAC steps on y axis and looks like a + * linear function. To recreate the curve and pass the power values + * on hw, we get 4 points for xpd 0 (lower gain -> max power) + * and 3 points for xpd 3 (higher gain -> lower power) from eeprom (eeprom.c) + * and interpolate here. + * + * For a given channel we get the calibrated points (piers) for it or + * -if we don't have calibration data for this specific channel- from the + * available surrounding channels we have calibration data for, after we do a + * linear interpolation between them. Then since we have our calibrated points + * for this channel, we do again a linear interpolation between them to get the + * whole curve. + * + * We finally write the Y values of the curve(s) (the PCDAC values) on hw + */ + +/** + * ath5k_fill_pwr_to_pcdac_table() - Fill Power to PCDAC table on RF5111 + * @ah: The &struct ath5k_hw + * @table_min: Minimum power (x min) + * @table_max: Maximum power (x max) * * No further processing is needed for RF5111, the only thing we have to * do is fill the values below and above calibration range since eeprom data @@ -2545,10 +2926,14 @@ ath5k_fill_pwr_to_pcdac_table(struct ath5k_hw *ah, s16* table_min, } -/* - * Combine available XPD Curves and fill Linear Power to PCDAC table - * on RF5112 +/** + * ath5k_combine_linear_pcdac_curves() - Combine available PCDAC Curves + * @ah: The &struct ath5k_hw + * @table_min: Minimum power (x min) + * @table_max: Maximum power (x max) + * @pdcurves: Number of pd curves * + * Combine available XPD Curves and fill Linear Power to PCDAC table on RF5112 * RFX112 can have up to 2 curves (one for low txpower range and one for * higher txpower range). We need to put them both on pcdac_out and place * them in the correct location. In case we only have one curve available @@ -2650,7 +3035,10 @@ ath5k_combine_linear_pcdac_curves(struct ath5k_hw *ah, s16* table_min, } } -/* Write PCDAC values on hw */ +/** + * ath5k_write_pcdac_table() - Write the PCDAC values on hw + * @ah: The &struct ath5k_hw + */ static void ath5k_write_pcdac_table(struct ath5k_hw *ah) { @@ -2673,9 +3061,32 @@ ath5k_write_pcdac_table(struct ath5k_hw *ah) * Power to PDADC table functions */ -/* - * Set the gain boundaries and create final Power to PDADC table +/** + * DOC: Power to PDADC table functions + * + * For RF2413 and later we have a Power to PDADC table (Power Detector) + * instead of a PCDAC (Power Control) and 4 pd gain curves for each + * calibrated channel. Each curve has power on x axis in 0.5 db steps and + * PDADC steps on y axis and looks like an exponential function like the + * RF5111 curve. + * + * To recreate the curves we read the points from eeprom (eeprom.c) + * and interpolate here. Note that in most cases only 2 (higher and lower) + * curves are used (like RF5112) but vendors have the opportunity to include + * all 4 curves on eeprom. The final curve (higher power) has an extra + * point for better accuracy like RF5112. * + * The process is similar to what we do above for RF5111/5112 + */ + +/** + * ath5k_combine_pwr_to_pdadc_curves() - Combine the various PDADC curves + * @ah: The &struct ath5k_hw + * @pwr_min: Minimum power (x min) + * @pwr_max: Maximum power (x max) + * @pdcurves: Number of available curves + * + * Combine the various pd curves and create the final Power to PDADC table * We can have up to 4 pd curves, we need to do a similar process * as we do for RF5112. This time we don't have an edge_flag but we * set the gain boundaries on a separate register. @@ -2799,7 +3210,11 @@ ath5k_combine_pwr_to_pdadc_curves(struct ath5k_hw *ah, } -/* Write PDADC values on hw */ +/** + * ath5k_write_pwr_to_pdadc_table() - Write the PDADC values on hw + * @ah: The &struct ath5k_hw + * @ee_mode: One of enum ath5k_driver_mode + */ static void ath5k_write_pwr_to_pdadc_table(struct ath5k_hw *ah, u8 ee_mode) { @@ -2856,7 +3271,13 @@ ath5k_write_pwr_to_pdadc_table(struct ath5k_hw *ah, u8 ee_mode) * Common code for PCDAC/PDADC tables */ -/* +/** + * ath5k_setup_channel_powertable() - Set up power table for this channel + * @ah: The &struct ath5k_hw + * @channel: The &struct ieee80211_channel + * @ee_mode: One of enum ath5k_driver_mode + * @type: One of enum ath5k_powertable_type (eeprom.h) + * * This is the main function that uses all of the above * to set PCDAC/PDADC table on hw for the current channel. * This table is used for tx power calibration on the baseband, @@ -3054,7 +3475,12 @@ ath5k_setup_channel_powertable(struct ath5k_hw *ah, return 0; } -/* Write power table for current channel to hw */ +/** + * ath5k_write_channel_powertable() - Set power table for current channel on hw + * @ah: The &struct ath5k_hw + * @ee_mode: One of enum ath5k_driver_mode + * @type: One of enum ath5k_powertable_type (eeprom.h) + */ static void ath5k_write_channel_powertable(struct ath5k_hw *ah, u8 ee_mode, u8 type) { @@ -3064,28 +3490,36 @@ ath5k_write_channel_powertable(struct ath5k_hw *ah, u8 ee_mode, u8 type) ath5k_write_pcdac_table(ah); } -/* - * Per-rate tx power setting + +/** + * DOC: Per-rate tx power setting * - * This is the code that sets the desired tx power (below + * This is the code that sets the desired tx power limit (below * maximum) on hw for each rate (we also have TPC that sets - * power per packet). We do that by providing an index on the - * PCDAC/PDADC table we set up. - */ - -/* - * Set rate power table + * power per packet type). We do that by providing an index on the + * PCDAC/PDADC table we set up above, for each rate. * * For now we only limit txpower based on maximum tx power - * supported by hw (what's inside rate_info). We need to limit - * this even more, based on regulatory domain etc. + * supported by hw (what's inside rate_info) + conformance test + * limits. We need to limit this even more, based on regulatory domain + * etc to be safe. Normally this is done from above so we don't care + * here, all we care is that the tx power we set will be O.K. + * for the hw (e.g. won't create noise on PA etc). * - * Rate power table contains indices to PCDAC/PDADC table (0.5dB steps) - * and is indexed as follows: + * Rate power table contains indices to PCDAC/PDADC table (0.5dB steps - + * x values) and is indexed as follows: * rates[0] - rates[7] -> OFDM rates * rates[8] - rates[14] -> CCK rates * rates[15] -> XR rates (they all have the same power) */ + +/** + * ath5k_setup_rate_powertable() - Set up rate power table for a given tx power + * @ah: The &struct ath5k_hw + * @max_pwr: The maximum tx power requested in 0.5dB steps + * @rate_info: The &struct ath5k_rate_pcal_info to fill + * @ee_mode: One of enum ath5k_driver_mode + */ static void ath5k_setup_rate_powertable(struct ath5k_hw *ah, u16 max_pwr, struct ath5k_rate_pcal_info *rate_info, @@ -3156,8 +3590,14 @@ ath5k_setup_rate_powertable(struct ath5k_hw *ah, u16 max_pwr, } -/* - * Set transmission power +/** + * ath5k_hw_txpower() - Set transmission power limit for a given channel + * @ah: The &struct ath5k_hw + * @channel: The &struct ieee80211_channel + * @txpower: Requested tx power in 0.5dB steps + * + * Combines all of the above to set the requested tx power limit + * on hw. */ static int ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel, @@ -3275,7 +3715,16 @@ ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel, return 0; } -int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower) +/** + * ath5k_hw_set_txpower_limit() - Set txpower limit for the current channel + * @ah: The &struct ath5k_hw + * @txpower: The requested tx power limit in 0.5dB steps + * + * This function provides access to ath5k_hw_txpower to the driver in + * case user or an application changes it while PHY is running. + */ +int +ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower) { ATH5K_DBG(ah, ATH5K_DEBUG_TXPOWER, "changing txpower to %d\n", txpower); @@ -3283,11 +3732,26 @@ int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower) return ath5k_hw_txpower(ah, ah->ah_current_channel, txpower); } + /*************\ Init function \*************/ -int ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel, +/** + * ath5k_hw_phy_init() - Initialize PHY + * @ah: The &struct ath5k_hw + * @channel: The @struct ieee80211_channel + * @mode: One of enum ath5k_driver_mode + * @fast: Try a fast channel switch instead + * + * This is the main function used during reset to initialize PHY + * or do a fast channel change if possible. + * + * NOTE: Do not call this one from the driver, it assumes PHY is in a + * warm reset state ! + */ +int +ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel, u8 mode, bool fast) { struct ieee80211_channel *curr_channel; diff --git a/drivers/net/wireless/ath/ath5k/qcu.c b/drivers/net/wireless/ath/ath5k/qcu.c index 776654228eaa..31924c319152 100644 --- a/drivers/net/wireless/ath/ath5k/qcu.c +++ b/drivers/net/wireless/ath/ath5k/qcu.c @@ -17,23 +17,47 @@ */ /********************************************\ -Queue Control Unit, DFS Control Unit Functions +Queue Control Unit, DCF Control Unit Functions \********************************************/ #include "ath5k.h" #include "reg.h" #include "debug.h" +/** + * DOC: Queue Control Unit (QCU)/DCF Control Unit (DCU) functions + * + * Here we setup parameters for the 12 available TX queues. Note that + * on the various registers we can usually only map the first 10 of them so + * basically we have 10 queues to play with. Each queue has a matching + * QCU that controls when the queue will get triggered and multiple QCUs + * can be mapped to a single DCU that controls the various DFS parameters + * for the various queues. In our setup we have a 1:1 mapping between QCUs + * and DCUs allowing us to have different DFS settings for each queue. + * + * When a frame goes into a TX queue, QCU decides when it'll trigger a + * transmission based on various criteria (such as how many data we have inside + * it's buffer or -if it's a beacon queue- if it's time to fire up the queue + * based on TSF etc), DCU adds backoff, IFSes etc and then a scheduler + * (arbitrator) decides the priority of each QCU based on it's configuration + * (e.g. beacons are always transmitted when they leave DCU bypassing all other + * frames from other queues waiting to be transmitted). After a frame leaves + * the DCU it goes to PCU for further processing and then to PHY for + * the actual transmission. + */ + /******************\ * Helper functions * \******************/ -/* - * Get number of pending frames - * for a specific queue [5211+] +/** + * ath5k_hw_num_tx_pending() - Get number of pending frames for a given queue + * @ah: The &struct ath5k_hw + * @queue: The hw queue number */ -u32 ath5k_hw_num_tx_pending(struct ath5k_hw *ah, unsigned int queue) +u32 +ath5k_hw_num_tx_pending(struct ath5k_hw *ah, unsigned int queue) { u32 pending; AR5K_ASSERT_ENTRY(queue, ah->ah_capabilities.cap_queues.q_tx_num); @@ -58,10 +82,13 @@ u32 ath5k_hw_num_tx_pending(struct ath5k_hw *ah, unsigned int queue) return pending; } -/* - * Set a transmit queue inactive +/** + * ath5k_hw_release_tx_queue() - Set a transmit queue inactive + * @ah: The &struct ath5k_hw + * @queue: The hw queue number */ -void ath5k_hw_release_tx_queue(struct ath5k_hw *ah, unsigned int queue) +void +ath5k_hw_release_tx_queue(struct ath5k_hw *ah, unsigned int queue) { if (WARN_ON(queue >= ah->ah_capabilities.cap_queues.q_tx_num)) return; @@ -72,10 +99,14 @@ void ath5k_hw_release_tx_queue(struct ath5k_hw *ah, unsigned int queue) AR5K_Q_DISABLE_BITS(ah->ah_txq_status, queue); } -/* +/** + * ath5k_cw_validate() - Make sure the given cw is valid + * @cw_req: The contention window value to check + * * Make sure cw is a power of 2 minus 1 and smaller than 1024 */ -static u16 ath5k_cw_validate(u16 cw_req) +static u16 +ath5k_cw_validate(u16 cw_req) { u32 cw = 1; cw_req = min(cw_req, (u16)1023); @@ -86,20 +117,30 @@ static u16 ath5k_cw_validate(u16 cw_req) return cw; } -/* - * Get properties for a transmit queue +/** + * ath5k_hw_get_tx_queueprops() - Get properties for a transmit queue + * @ah: The &struct ath5k_hw + * @queue: The hw queue number + * @queue_info: The &struct ath5k_txq_info to fill */ -int ath5k_hw_get_tx_queueprops(struct ath5k_hw *ah, int queue, +int +ath5k_hw_get_tx_queueprops(struct ath5k_hw *ah, int queue, struct ath5k_txq_info *queue_info) { memcpy(queue_info, &ah->ah_txq[queue], sizeof(struct ath5k_txq_info)); return 0; } -/* - * Set properties for a transmit queue +/** + * ath5k_hw_set_tx_queueprops() - Set properties for a transmit queue + * @ah: The &struct ath5k_hw + * @queue: The hw queue number + * @qinfo: The &struct ath5k_txq_info to use + * + * Returns 0 on success or -EIO if queue is inactive */ -int ath5k_hw_set_tx_queueprops(struct ath5k_hw *ah, int queue, +int +ath5k_hw_set_tx_queueprops(struct ath5k_hw *ah, int queue, const struct ath5k_txq_info *qinfo) { struct ath5k_txq_info *qi; @@ -139,10 +180,16 @@ int ath5k_hw_set_tx_queueprops(struct ath5k_hw *ah, int queue, return 0; } -/* - * Initialize a transmit queue +/** + * ath5k_hw_setup_tx_queue() - Initialize a transmit queue + * @ah: The &struct ath5k_hw + * @queue_type: One of enum ath5k_tx_queue + * @queue_info: The &struct ath5k_txq_info to use + * + * Returns 0 on success, -EINVAL on invalid arguments */ -int ath5k_hw_setup_tx_queue(struct ath5k_hw *ah, enum ath5k_tx_queue queue_type, +int +ath5k_hw_setup_tx_queue(struct ath5k_hw *ah, enum ath5k_tx_queue queue_type, struct ath5k_txq_info *queue_info) { unsigned int queue; @@ -217,10 +264,16 @@ int ath5k_hw_setup_tx_queue(struct ath5k_hw *ah, enum ath5k_tx_queue queue_type, * Single QCU/DCU initialization * \*******************************/ -/* - * Set tx retry limits on DCU +/** + * ath5k_hw_set_tx_retry_limits() - Set tx retry limits on DCU + * @ah: The &struct ath5k_hw + * @queue: The hw queue number + * + * This function is used when initializing a queue, to set + * retry limits based on ah->ah_retry_* and the chipset used. */ -void ath5k_hw_set_tx_retry_limits(struct ath5k_hw *ah, +void +ath5k_hw_set_tx_retry_limits(struct ath5k_hw *ah, unsigned int queue) { /* Single data queue on AR5210 */ @@ -255,15 +308,15 @@ void ath5k_hw_set_tx_retry_limits(struct ath5k_hw *ah, } /** - * ath5k_hw_reset_tx_queue - Initialize a single hw queue - * - * @ah The &struct ath5k_hw - * @queue The hw queue number + * ath5k_hw_reset_tx_queue() - Initialize a single hw queue + * @ah: The &struct ath5k_hw + * @queue: The hw queue number * * Set DFS properties for the given transmit queue on DCU * and configures all queue-specific parameters. */ -int ath5k_hw_reset_tx_queue(struct ath5k_hw *ah, unsigned int queue) +int +ath5k_hw_reset_tx_queue(struct ath5k_hw *ah, unsigned int queue) { struct ath5k_txq_info *tq = &ah->ah_txq[queue]; @@ -491,10 +544,9 @@ int ath5k_hw_reset_tx_queue(struct ath5k_hw *ah, unsigned int queue) \**************************/ /** - * ath5k_hw_set_ifs_intervals - Set global inter-frame spaces on DCU - * - * @ah The &struct ath5k_hw - * @slot_time Slot time in us + * ath5k_hw_set_ifs_intervals() - Set global inter-frame spaces on DCU + * @ah: The &struct ath5k_hw + * @slot_time: Slot time in us * * Sets the global IFS intervals on DCU (also works on AR5210) for * the given slot time and the current bwmode. @@ -597,7 +649,15 @@ int ath5k_hw_set_ifs_intervals(struct ath5k_hw *ah, unsigned int slot_time) } -int ath5k_hw_init_queues(struct ath5k_hw *ah) +/** + * ath5k_hw_init_queues() - Initialize tx queues + * @ah: The &struct ath5k_hw + * + * Initializes all tx queues based on information on + * ah->ah_txq* set by the driver + */ +int +ath5k_hw_init_queues(struct ath5k_hw *ah) { int i, ret; diff --git a/drivers/net/wireless/ath/ath5k/reset.c b/drivers/net/wireless/ath/ath5k/reset.c index de28be4296a6..4aed3a3ab109 100644 --- a/drivers/net/wireless/ath/ath5k/reset.c +++ b/drivers/net/wireless/ath/ath5k/reset.c @@ -19,9 +19,9 @@ * */ -/*****************************\ - Reset functions and helpers -\*****************************/ +/****************************\ + Reset function and helpers +\****************************/ #include @@ -33,14 +33,36 @@ #include "debug.h" +/** + * DOC: Reset function and helpers + * + * Here we implement the main reset routine, used to bring the card + * to a working state and ready to receive. We also handle routines + * that don't fit on other places such as clock, sleep and power control + */ + + /******************\ * Helper functions * \******************/ -/* - * Check if a register write has been completed +/** + * ath5k_hw_register_timeout() - Poll a register for a flag/field change + * @ah: The &struct ath5k_hw + * @reg: The register to read + * @flag: The flag/field to check on the register + * @val: The field value we expect (if we check a field) + * @is_set: Instead of checking if the flag got cleared, check if it got set + * + * Some registers contain flags that indicate that an operation is + * running. We use this function to poll these registers and check + * if these flags get cleared. We also use it to poll a register + * field (containing multiple flags) until it gets a specific value. + * + * Returns -EAGAIN if we exceeded AR5K_TUNE_REGISTER_TIMEOUT * 15us or 0 */ -int ath5k_hw_register_timeout(struct ath5k_hw *ah, u32 reg, u32 flag, u32 val, +int +ath5k_hw_register_timeout(struct ath5k_hw *ah, u32 reg, u32 flag, u32 val, bool is_set) { int i; @@ -64,35 +86,48 @@ int ath5k_hw_register_timeout(struct ath5k_hw *ah, u32 reg, u32 flag, u32 val, \*************************/ /** - * ath5k_hw_htoclock - Translate usec to hw clock units - * + * ath5k_hw_htoclock() - Translate usec to hw clock units * @ah: The &struct ath5k_hw * @usec: value in microseconds + * + * Translate usecs to hw clock units based on the current + * hw clock rate. + * + * Returns number of clock units */ -unsigned int ath5k_hw_htoclock(struct ath5k_hw *ah, unsigned int usec) +unsigned int +ath5k_hw_htoclock(struct ath5k_hw *ah, unsigned int usec) { struct ath_common *common = ath5k_hw_common(ah); return usec * common->clockrate; } /** - * ath5k_hw_clocktoh - Translate hw clock units to usec + * ath5k_hw_clocktoh() - Translate hw clock units to usec + * @ah: The &struct ath5k_hw * @clock: value in hw clock units + * + * Translate hw clock units to usecs based on the current + * hw clock rate. + * + * Returns number of usecs */ -unsigned int ath5k_hw_clocktoh(struct ath5k_hw *ah, unsigned int clock) +unsigned int +ath5k_hw_clocktoh(struct ath5k_hw *ah, unsigned int clock) { struct ath_common *common = ath5k_hw_common(ah); return clock / common->clockrate; } /** - * ath5k_hw_init_core_clock - Initialize core clock - * - * @ah The &struct ath5k_hw + * ath5k_hw_init_core_clock() - Initialize core clock + * @ah: The &struct ath5k_hw * - * Initialize core clock parameters (usec, usec32, latencies etc). + * Initialize core clock parameters (usec, usec32, latencies etc), + * based on current bwmode and chipset properties. */ -static void ath5k_hw_init_core_clock(struct ath5k_hw *ah) +static void +ath5k_hw_init_core_clock(struct ath5k_hw *ah) { struct ieee80211_channel *channel = ah->ah_current_channel; struct ath_common *common = ath5k_hw_common(ah); @@ -227,16 +262,21 @@ static void ath5k_hw_init_core_clock(struct ath5k_hw *ah) } } -/* +/** + * ath5k_hw_set_sleep_clock() - Setup sleep clock operation + * @ah: The &struct ath5k_hw + * @enable: Enable sleep clock operation (false to disable) + * * If there is an external 32KHz crystal available, use it * as ref. clock instead of 32/40MHz clock and baseband clocks * to save power during sleep or restore normal 32/40MHz * operation. * - * XXX: When operating on 32KHz certain PHY registers (27 - 31, - * 123 - 127) require delay on access. + * NOTE: When operating on 32KHz certain PHY registers (27 - 31, + * 123 - 127) require delay on access. */ -static void ath5k_hw_set_sleep_clock(struct ath5k_hw *ah, bool enable) +static void +ath5k_hw_set_sleep_clock(struct ath5k_hw *ah, bool enable) { struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom; u32 scal, spending, sclock; @@ -340,10 +380,19 @@ static void ath5k_hw_set_sleep_clock(struct ath5k_hw *ah, bool enable) * Reset/Sleep control * \*********************/ -/* - * Reset chipset +/** + * ath5k_hw_nic_reset() - Reset the various chipset units + * @ah: The &struct ath5k_hw + * @val: Mask to indicate what units to reset + * + * To reset the various chipset units we need to write + * the mask to AR5K_RESET_CTL and poll the register until + * all flags are cleared. + * + * Returns 0 if we are O.K. or -EAGAIN (from athk5_hw_register_timeout) */ -static int ath5k_hw_nic_reset(struct ath5k_hw *ah, u32 val) +static int +ath5k_hw_nic_reset(struct ath5k_hw *ah, u32 val) { int ret; u32 mask = val ? val : ~0U; @@ -382,12 +431,17 @@ static int ath5k_hw_nic_reset(struct ath5k_hw *ah, u32 val) return ret; } -/* - * Reset AHB chipset - * AR5K_RESET_CTL_PCU flag resets WMAC - * AR5K_RESET_CTL_BASEBAND flag resets WBB +/** + * ath5k_hw_wisoc_reset() - Reset AHB chipset + * @ah: The &struct ath5k_hw + * @flags: Mask to indicate what units to reset + * + * Same as ath5k_hw_nic_reset but for AHB based devices + * + * Returns 0 if we are O.K. or -EAGAIN (from athk5_hw_register_timeout) */ -static int ath5k_hw_wisoc_reset(struct ath5k_hw *ah, u32 flags) +static int +ath5k_hw_wisoc_reset(struct ath5k_hw *ah, u32 flags) { u32 mask = flags ? flags : ~0U; u32 __iomem *reg; @@ -439,11 +493,23 @@ static int ath5k_hw_wisoc_reset(struct ath5k_hw *ah, u32 flags) return 0; } - -/* - * Sleep control +/** + * ath5k_hw_set_power_mode() - Set power mode + * @ah: The &struct ath5k_hw + * @mode: One of enum ath5k_power_mode + * @set_chip: Set to true to write sleep control register + * @sleep_duration: How much time the device is allowed to sleep + * when sleep logic is enabled (in 128 microsecond increments). + * + * This function is used to configure sleep policy and allowed + * sleep modes. For more information check out the sleep control + * register on reg.h and STA_ID1. + * + * Returns 0 on success, -EIO if chip didn't wake up or -EINVAL if an invalid + * mode is requested. */ -static int ath5k_hw_set_power(struct ath5k_hw *ah, enum ath5k_power_mode mode, +static int +ath5k_hw_set_power_mode(struct ath5k_hw *ah, enum ath5k_power_mode mode, bool set_chip, u16 sleep_duration) { unsigned int i; @@ -523,17 +589,20 @@ commit: return 0; } -/* - * Put device on hold +/** + * ath5k_hw_on_hold() - Put device on hold + * @ah: The &struct ath5k_hw * - * Put MAC and Baseband on warm reset and - * keep that state (don't clean sleep control - * register). After this MAC and Baseband are - * disabled and a full reset is needed to come - * back. This way we save as much power as possible + * Put MAC and Baseband on warm reset and keep that state + * (don't clean sleep control register). After this MAC + * and Baseband are disabled and a full reset is needed + * to come back. This way we save as much power as possible * without putting the card on full sleep. + * + * Returns 0 on success or -EIO on error */ -int ath5k_hw_on_hold(struct ath5k_hw *ah) +int +ath5k_hw_on_hold(struct ath5k_hw *ah) { struct pci_dev *pdev = ah->pdev; u32 bus_flags; @@ -543,7 +612,7 @@ int ath5k_hw_on_hold(struct ath5k_hw *ah) return 0; /* Make sure device is awake */ - ret = ath5k_hw_set_power(ah, AR5K_PM_AWAKE, true, 0); + ret = ath5k_hw_set_power_mode(ah, AR5K_PM_AWAKE, true, 0); if (ret) { ATH5K_ERR(ah, "failed to wakeup the MAC Chip\n"); return ret; @@ -575,7 +644,7 @@ int ath5k_hw_on_hold(struct ath5k_hw *ah) } /* ...wakeup again!*/ - ret = ath5k_hw_set_power(ah, AR5K_PM_AWAKE, true, 0); + ret = ath5k_hw_set_power_mode(ah, AR5K_PM_AWAKE, true, 0); if (ret) { ATH5K_ERR(ah, "failed to put device on hold\n"); return ret; @@ -584,11 +653,18 @@ int ath5k_hw_on_hold(struct ath5k_hw *ah) return ret; } -/* +/** + * ath5k_hw_nic_wakeup() - Force card out of sleep + * @ah: The &struct ath5k_hw + * @channel: The &struct ieee80211_channel + * * Bring up MAC + PHY Chips and program PLL - * Channel is NULL for the initial wakeup. + * NOTE: Channel is NULL for the initial wakeup. + * + * Returns 0 on success, -EIO on hw failure or -EINVAL for false channel infos */ -int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, struct ieee80211_channel *channel) +int +ath5k_hw_nic_wakeup(struct ath5k_hw *ah, struct ieee80211_channel *channel) { struct pci_dev *pdev = ah->pdev; u32 turbo, mode, clock, bus_flags; @@ -600,7 +676,7 @@ int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, struct ieee80211_channel *channel) if ((ath5k_get_bus_type(ah) != ATH_AHB) || channel) { /* Wakeup the device */ - ret = ath5k_hw_set_power(ah, AR5K_PM_AWAKE, true, 0); + ret = ath5k_hw_set_power_mode(ah, AR5K_PM_AWAKE, true, 0); if (ret) { ATH5K_ERR(ah, "failed to wakeup the MAC Chip\n"); return ret; @@ -637,7 +713,7 @@ int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, struct ieee80211_channel *channel) } /* ...wakeup again!...*/ - ret = ath5k_hw_set_power(ah, AR5K_PM_AWAKE, true, 0); + ret = ath5k_hw_set_power_mode(ah, AR5K_PM_AWAKE, true, 0); if (ret) { ATH5K_ERR(ah, "failed to resume the MAC Chip\n"); return ret; @@ -755,8 +831,19 @@ int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, struct ieee80211_channel *channel) * Post-initvals register modifications * \**************************************/ -/* TODO: Half/Quarter rate */ -static void ath5k_hw_tweak_initval_settings(struct ath5k_hw *ah, +/** + * ath5k_hw_tweak_initval_settings() - Tweak initial settings + * @ah: The &struct ath5k_hw + * @channel: The &struct ieee80211_channel + * + * Some settings are not handled on initvals, e.g. bwmode + * settings, some phy settings, workarounds etc that in general + * don't fit anywhere else or are too small to introduce a separate + * function for each one. So we have this function to handle + * them all during reset and complete card's initialization. + */ +static void +ath5k_hw_tweak_initval_settings(struct ath5k_hw *ah, struct ieee80211_channel *channel) { if (ah->ah_version == AR5K_AR5212 && @@ -875,7 +962,16 @@ static void ath5k_hw_tweak_initval_settings(struct ath5k_hw *ah, } } -static void ath5k_hw_commit_eeprom_settings(struct ath5k_hw *ah, +/** + * ath5k_hw_commit_eeprom_settings() - Commit settings from EEPROM + * @ah: The &struct ath5k_hw + * @channel: The &struct ieee80211_channel + * + * Use settings stored on EEPROM to properly initialize the card + * based on various infos and per-mode calibration data. + */ +static void +ath5k_hw_commit_eeprom_settings(struct ath5k_hw *ah, struct ieee80211_channel *channel) { struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom; @@ -1029,7 +1125,23 @@ static void ath5k_hw_commit_eeprom_settings(struct ath5k_hw *ah, * Main reset function * \*********************/ -int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode, +/** + * ath5k_hw_reset() - The main reset function + * @ah: The &struct ath5k_hw + * @op_mode: One of enum nl80211_iftype + * @channel: The &struct ieee80211_channel + * @fast: Enable fast channel switching + * @skip_pcu: Skip pcu initialization + * + * This is the function we call each time we want to (re)initialize the + * card and pass new settings to hw. We also call it when hw runs into + * trouble to make it come back to a working state. + * + * Returns 0 on success, -EINVAL on false op_mode or channel infos, or -EIO + * on failure. + */ +int +ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode, struct ieee80211_channel *channel, bool fast, bool skip_pcu) { u32 s_seq[10], s_led[3], tsf_up, tsf_lo; @@ -1242,7 +1354,7 @@ int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode, /* * Initialize PCU */ - ath5k_hw_pcu_init(ah, op_mode, mode); + ath5k_hw_pcu_init(ah, op_mode); /* * Initialize PHY diff --git a/drivers/net/wireless/ath/ath5k/rfbuffer.h b/drivers/net/wireless/ath/ath5k/rfbuffer.h index 5d11c23b4297..aed34d9954c0 100644 --- a/drivers/net/wireless/ath/ath5k/rfbuffer.h +++ b/drivers/net/wireless/ath/ath5k/rfbuffer.h @@ -18,7 +18,9 @@ */ -/* +/** + * DOC: RF Buffer registers + * * There are some special registers on the RF chip * that control various operation settings related mostly to * the analog parts (channel, gain adjustment etc). @@ -44,40 +46,63 @@ */ -/* +/** + * struct ath5k_ini_rfbuffer - Initial RF Buffer settings + * @rfb_bank: RF Bank number + * @rfb_ctrl_register: RF Buffer control register + * @rfb_mode_data: RF Buffer data for each mode + * * Struct to hold default mode specific RF - * register values (RF Banks) + * register values (RF Banks) for each chip. */ struct ath5k_ini_rfbuffer { - u8 rfb_bank; /* RF Bank number */ - u16 rfb_ctrl_register; /* RF Buffer control register */ - u32 rfb_mode_data[3]; /* RF Buffer data for each mode */ + u8 rfb_bank; + u16 rfb_ctrl_register; + u32 rfb_mode_data[3]; }; -/* +/** + * struct ath5k_rfb_field - An RF Buffer field (register/value) + * @len: Field length + * @pos: Offset on the raw packet + * @col: Used for shifting + * * Struct to hold RF Buffer field * infos used to access certain RF * analog registers */ struct ath5k_rfb_field { - u8 len; /* Field length */ - u16 pos; /* Offset on the raw packet */ - u8 col; /* Column -used for shifting */ + u8 len; + u16 pos; + u8 col; }; -/* - * RF analog register definition +/** + * struct ath5k_rf_reg - RF analog register definition + * @bank: RF Buffer Bank number + * @index: Register's index on ath5k_rf_regx_idx + * @field: The &struct ath5k_rfb_field + * + * We use this struct to define the set of RF registers + * on each chip that we want to tweak. Some RF registers + * are common between different chip versions so this saves + * us space and complexity because we can refer to an rf + * register by it's index no matter what chip we work with + * as long as it has that register. */ struct ath5k_rf_reg { - u8 bank; /* RF Buffer Bank number */ - u8 index; /* Register's index on rf_regs_idx */ - struct ath5k_rfb_field field; /* RF Buffer field for this register */ + u8 bank; + u8 index; + struct ath5k_rfb_field field; }; -/* Map RF registers to indexes +/** + * enum ath5k_rf_regs_idx - Map RF registers to indexes + * * We do this to handle common bits and make our * life easier by using an index for each register - * instead of a full rfb_field */ + * instead of a full rfb_field + */ enum ath5k_rf_regs_idx { /* BANK 2 */ AR5K_RF_TURBO = 0, diff --git a/drivers/net/wireless/ath/ath5k/rfgain.h b/drivers/net/wireless/ath/ath5k/rfgain.h index ebfae052d89e..4d21df0e5975 100644 --- a/drivers/net/wireless/ath/ath5k/rfgain.h +++ b/drivers/net/wireless/ath/ath5k/rfgain.h @@ -18,13 +18,17 @@ * */ -/* +/** + * struct ath5k_ini_rfgain - RF Gain table + * @rfg_register: RF Gain register address + * @rfg_value: Register value for 5 and 2GHz + * * Mode-specific RF Gain table (64bytes) for RF5111/5112 * (RF5110 only comes with AR5210 and only supports a/turbo a mode so initial * RF Gain values are included in AR5K_AR5210_INI) */ struct ath5k_ini_rfgain { - u16 rfg_register; /* RF Gain register address */ + u16 rfg_register; u32 rfg_value[2]; /* [freq (see below)] */ }; @@ -455,18 +459,31 @@ static const struct ath5k_ini_rfgain rfgain_2425[] = { #define AR5K_GAIN_CHECK_ADJUST(_g) \ ((_g)->g_current <= (_g)->g_low || (_g)->g_current >= (_g)->g_high) +/** + * struct ath5k_gain_opt_step - An RF gain optimization step + * @gos_param: Set of parameters + * @gos_gain: Gain + */ struct ath5k_gain_opt_step { s8 gos_param[AR5K_GAIN_CRN_MAX_FIX_BITS]; s8 gos_gain; }; +/** + * struct ath5k_gain_opt - RF Gain optimization ladder + * @go_default: The default step + * @go_steps_count: How many optimization steps + * @go_step: Array of &struct ath5k_gain_opt_step + */ struct ath5k_gain_opt { u8 go_default; u8 go_steps_count; const struct ath5k_gain_opt_step go_step[AR5K_GAIN_STEP_COUNT]; }; + /* + * RF5111 * Parameters on gos_param: * 1) Tx clip PHY register * 2) PWD 90 RF register @@ -490,6 +507,7 @@ static const struct ath5k_gain_opt rfgain_opt_5111 = { }; /* + * RF5112 * Parameters on gos_param: * 1) Mixgain ovr RF register * 2) PWD 138 RF register -- cgit v1.2.3 From dafae6af0336958e9e2eb67cc5e4e31d6d13b308 Mon Sep 17 00:00:00 2001 From: Nick Kossifidis Date: Fri, 25 Nov 2011 20:40:26 +0200 Subject: ath5k: We always do full calibration on AR5210 There is no short calibration on AR5210, make sure we treat it always as full calibration. Signed-off-by: Nick Kossifidis Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath5k/phy.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c index a635441d1fed..e1f8613426a9 100644 --- a/drivers/net/wireless/ath/ath5k/phy.c +++ b/drivers/net/wireless/ath/ath5k/phy.c @@ -1674,6 +1674,9 @@ ath5k_hw_rf5110_calibrate(struct ath5k_hw *ah, u32 phy_sig, phy_agc, phy_sat, beacon; int ret; + if (!(ah->ah_cal_mask & AR5K_CALIBRATION_FULL)) + return 0; + /* * Disable beacons and RX/TX queues, wait */ -- cgit v1.2.3 From 84e1e7373b961713bde371b9391d91fe7150d7f2 Mon Sep 17 00:00:00 2001 From: Nick Kossifidis Date: Fri, 25 Nov 2011 20:40:27 +0200 Subject: ath5k: Add a module parameter to disable hw rf kill switch Add a module parameter to disable hw rf kill switch (GPIO interrupt) because in some cases when the card doesn't come with the laptop, EEPROM configuration doesn't match laptop's configuration and rf kill interrupt always fires up and disables hw. I thought of moving this to debugfs and make it per-card but this way it's easier for users and distros to handle. Signed-off-by: Nick Kossifidis Tested-by: Pavel Roskin Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath5k/base.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c index 9bb40b002fad..02207fa62675 100644 --- a/drivers/net/wireless/ath/ath5k/base.c +++ b/drivers/net/wireless/ath/ath5k/base.c @@ -80,6 +80,11 @@ static int modparam_fastchanswitch; module_param_named(fastchanswitch, modparam_fastchanswitch, bool, S_IRUGO); MODULE_PARM_DESC(fastchanswitch, "Enable fast channel switching for AR2413/AR5413 radios."); +static int ath5k_modparam_no_hw_rfkill_switch; +module_param_named(no_hw_rfkill_switch, ath5k_modparam_no_hw_rfkill_switch, + bool, S_IRUGO); +MODULE_PARM_DESC(no_hw_rfkill_switch, "Ignore the GPIO RFKill switch state"); + /* Module info */ MODULE_AUTHOR("Jiri Slaby"); @@ -2635,7 +2640,8 @@ int ath5k_start(struct ieee80211_hw *hw) if (ret) goto done; - ath5k_rfkill_hw_start(ah); + if (!ath5k_modparam_no_hw_rfkill_switch) + ath5k_rfkill_hw_start(ah); /* * Reset the key cache since some parts do not reset the @@ -2719,7 +2725,8 @@ void ath5k_stop(struct ieee80211_hw *hw) cancel_delayed_work_sync(&ah->tx_complete_work); - ath5k_rfkill_hw_stop(ah); + if (!ath5k_modparam_no_hw_rfkill_switch) + ath5k_rfkill_hw_stop(ah); } /* -- cgit v1.2.3 From 86f62d9b705cdd4f04da5387a5c71ca6ee0a37c9 Mon Sep 17 00:00:00 2001 From: Nick Kossifidis Date: Fri, 25 Nov 2011 20:40:28 +0200 Subject: ath5k: MRR support and 2GHz radio override belong in ah_capabilities MRR support and 2GHz radio override belong in ah_capabilities and we should use them (e.g. so far we used to set mrr descriptor without checking if MRR support is enabled + we checked for MRR support 2 times, one by trying to set up an MRR descriptor and another one based on MAC version). Signed-off-by: Nick Kossifidis Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath5k/ahb.c | 4 ++- drivers/net/wireless/ath/ath5k/ath5k.h | 12 ++++----- drivers/net/wireless/ath/ath5k/attach.c | 5 ---- drivers/net/wireless/ath/ath5k/base.c | 47 +++++++++++++-------------------- drivers/net/wireless/ath/ath5k/caps.c | 27 ++++++++++++++----- 5 files changed, 47 insertions(+), 48 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath5k/ahb.c b/drivers/net/wireless/ath/ath5k/ahb.c index e5be7e701816..ee7ea572b065 100644 --- a/drivers/net/wireless/ath/ath5k/ahb.c +++ b/drivers/net/wireless/ath/ath5k/ahb.c @@ -166,7 +166,9 @@ static int ath_ahb_probe(struct platform_device *pdev) if (to_platform_device(ah->dev)->id == 0 && (bcfg->config->flags & (BD_WLAN0 | BD_WLAN1)) == (BD_WLAN1 | BD_WLAN0)) - __set_bit(ATH_STAT_2G_DISABLED, ah->status); + ah->ah_capabilities.cap_needs_2GHz_ovr = true; + else + ah->ah_capabilities.cap_needs_2GHz_ovr = false; } ret = ath5k_init_ah(ah, &ath_ahb_bus_ops); diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h index 819c4db5aab3..c3815f708382 100644 --- a/drivers/net/wireless/ath/ath5k/ath5k.h +++ b/drivers/net/wireless/ath/ath5k/ath5k.h @@ -1159,6 +1159,8 @@ struct ath5k_capabilities { } cap_queues; bool cap_has_phyerr_counters; + bool cap_has_mrr_support; + bool cap_needs_2GHz_ovr; }; /* size of noise floor history (keep it a power of two) */ @@ -1274,13 +1276,11 @@ struct ath5k_hw { dma_addr_t desc_daddr; /* DMA (physical) address */ size_t desc_len; /* size of TX/RX descriptors */ - DECLARE_BITMAP(status, 6); + DECLARE_BITMAP(status, 4); #define ATH_STAT_INVALID 0 /* disable hardware accesses */ -#define ATH_STAT_MRRETRY 1 /* multi-rate retry support */ -#define ATH_STAT_PROMISC 2 -#define ATH_STAT_LEDSOFT 3 /* enable LED gpio status */ -#define ATH_STAT_STARTED 4 /* opened & irqs enabled */ -#define ATH_STAT_2G_DISABLED 5 /* multiband radio without 2G */ +#define ATH_STAT_PROMISC 1 +#define ATH_STAT_LEDSOFT 2 /* enable LED gpio status */ +#define ATH_STAT_STARTED 3 /* opened & irqs enabled */ unsigned int filter_flags; /* HW flags, AR5K_RX_FILTER_* */ struct ieee80211_channel *curchan; /* current h/w channel */ diff --git a/drivers/net/wireless/ath/ath5k/attach.c b/drivers/net/wireless/ath/ath5k/attach.c index b69e0570cf02..d7114c75fe9b 100644 --- a/drivers/net/wireless/ath/ath5k/attach.c +++ b/drivers/net/wireless/ath/ath5k/attach.c @@ -306,11 +306,6 @@ int ath5k_hw_init(struct ath5k_hw *ah) goto err; } - if (test_bit(ATH_STAT_2G_DISABLED, ah->status)) { - __clear_bit(AR5K_MODE_11B, ah->ah_capabilities.cap_mode); - __clear_bit(AR5K_MODE_11G, ah->ah_capabilities.cap_mode); - } - /* Crypto settings */ common->keymax = (ah->ah_version == AR5K_AR5210 ? AR5K_KEYTABLE_SIZE_5210 : AR5K_KEYTABLE_SIZE_5211); diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c index 02207fa62675..178a4dd10316 100644 --- a/drivers/net/wireless/ath/ath5k/base.c +++ b/drivers/net/wireless/ath/ath5k/base.c @@ -725,21 +725,24 @@ ath5k_txbuf_setup(struct ath5k_hw *ah, struct ath5k_buf *bf, if (ret) goto err_unmap; - memset(mrr_rate, 0, sizeof(mrr_rate)); - memset(mrr_tries, 0, sizeof(mrr_tries)); - for (i = 0; i < 3; i++) { - rate = ieee80211_get_alt_retry_rate(ah->hw, info, i); - if (!rate) - break; + /* Set up MRR descriptor */ + if (ah->ah_capabilities.cap_has_mrr_support) { + memset(mrr_rate, 0, sizeof(mrr_rate)); + memset(mrr_tries, 0, sizeof(mrr_tries)); + for (i = 0; i < 3; i++) { + rate = ieee80211_get_alt_retry_rate(ah->hw, info, i); + if (!rate) + break; - mrr_rate[i] = rate->hw_value; - mrr_tries[i] = info->control.rates[i + 1].count; - } + mrr_rate[i] = rate->hw_value; + mrr_tries[i] = info->control.rates[i + 1].count; + } - ath5k_hw_setup_mrr_tx_desc(ah, ds, - mrr_rate[0], mrr_tries[0], - mrr_rate[1], mrr_tries[1], - mrr_rate[2], mrr_tries[2]); + ath5k_hw_setup_mrr_tx_desc(ah, ds, + mrr_rate[0], mrr_tries[0], + mrr_rate[1], mrr_tries[1], + mrr_rate[2], mrr_tries[2]); + } ds->ds_link = 0; ds->ds_data = bf->skbaddr; @@ -2489,8 +2492,8 @@ ath5k_init_ah(struct ath5k_hw *ah, const struct ath_bus_ops *bus_ops) if (ret) goto err_irq; - /* set up multi-rate retry capabilities */ - if (ah->ah_version == AR5K_AR5212) { + /* Set up multi-rate retry capabilities */ + if (ah->ah_capabilities.cap_has_mrr_support) { hw->max_rates = 4; hw->max_rate_tries = max(AR5K_INIT_RETRY_SHORT, AR5K_INIT_RETRY_LONG); @@ -2848,20 +2851,6 @@ ath5k_init(struct ieee80211_hw *hw) int ret; - /* - * Check if the MAC has multi-rate retry support. - * We do this by trying to setup a fake extended - * descriptor. MACs that don't have support will - * return false w/o doing anything. MACs that do - * support it will return true w/o doing anything. - */ - ret = ath5k_hw_setup_mrr_tx_desc(ah, NULL, 0, 0, 0, 0, 0, 0); - - if (ret < 0) - goto err; - if (ret > 0) - __set_bit(ATH_STAT_MRRETRY, ah->status); - /* * Collect the channel list. The 802.11 layer * is responsible for filtering this list based diff --git a/drivers/net/wireless/ath/ath5k/caps.c b/drivers/net/wireless/ath/ath5k/caps.c index 810fba96702b..994169ad39cb 100644 --- a/drivers/net/wireless/ath/ath5k/caps.c +++ b/drivers/net/wireless/ath/ath5k/caps.c @@ -85,12 +85,19 @@ int ath5k_hw_set_capabilities(struct ath5k_hw *ah) caps->cap_range.range_2ghz_min = 2412; caps->cap_range.range_2ghz_max = 2732; - if (AR5K_EEPROM_HDR_11B(ee_header)) - __set_bit(AR5K_MODE_11B, caps->cap_mode); - - if (AR5K_EEPROM_HDR_11G(ee_header) && - ah->ah_version != AR5K_AR5211) - __set_bit(AR5K_MODE_11G, caps->cap_mode); + /* Override 2GHz modes on SoCs that need it + * NOTE: cap_needs_2GHz_ovr gets set from + * ath_ahb_probe */ + if (!caps->cap_needs_2GHz_ovr) { + if (AR5K_EEPROM_HDR_11B(ee_header)) + __set_bit(AR5K_MODE_11B, + caps->cap_mode); + + if (AR5K_EEPROM_HDR_11G(ee_header) && + ah->ah_version != AR5K_AR5211) + __set_bit(AR5K_MODE_11G, + caps->cap_mode); + } } } @@ -103,12 +110,18 @@ int ath5k_hw_set_capabilities(struct ath5k_hw *ah) else caps->cap_queues.q_tx_num = AR5K_NUM_TX_QUEUES; - /* newer hardware has PHY error counters */ + /* Newer hardware has PHY error counters */ if (ah->ah_mac_srev >= AR5K_SREV_AR5213A) caps->cap_has_phyerr_counters = true; else caps->cap_has_phyerr_counters = false; + /* MACs since AR5212 have MRR support */ + if (ah->ah_version == AR5K_AR5212) + caps->cap_has_mrr_support = true; + else + caps->cap_has_mrr_support = false; + return 0; } -- cgit v1.2.3 From 29355a4877d7b3219318f0be5b3af55128a4f0ce Mon Sep 17 00:00:00 2001 From: Nick Kossifidis Date: Fri, 25 Nov 2011 20:40:29 +0200 Subject: ath5k: ath5k_ani_period_restart only touches struct ath5k_ani_state No need to take ath5k_hw as an argument. Signed-off-by: Nick Kossifidis Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath5k/ani.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath5k/ani.c b/drivers/net/wireless/ath/ath5k/ani.c index 2dfcf1ae19f6..bf674161a217 100644 --- a/drivers/net/wireless/ath/ath5k/ani.c +++ b/drivers/net/wireless/ath/ath5k/ani.c @@ -440,13 +440,12 @@ ath5k_ani_save_and_clear_phy_errors(struct ath5k_hw *ah, /** * ath5k_ani_period_restart() - Restart ANI period - * @ah: The &struct ath5k_hw * @as: The &struct ath5k_ani_state * * Just reset counters, so they are clear for the next "ani period". */ static void -ath5k_ani_period_restart(struct ath5k_hw *ah, struct ath5k_ani_state *as) +ath5k_ani_period_restart(struct ath5k_ani_state *as) { /* keep last values for debugging */ as->last_ofdm_errors = as->ofdm_errors; @@ -502,7 +501,7 @@ ath5k_ani_calibration(struct ath5k_hw *ah) /* too many PHY errors - we have to raise immunity */ bool ofdm_flag = as->ofdm_errors > ofdm_high ? true : false; ath5k_ani_raise_immunity(ah, as, ofdm_flag); - ath5k_ani_period_restart(ah, as); + ath5k_ani_period_restart(as); } else if (as->listen_time > 5 * ATH5K_ANI_LISTEN_PERIOD) { /* If more than 5 (TODO: why 5?) periods have passed and we got @@ -514,7 +513,7 @@ ath5k_ani_calibration(struct ath5k_hw *ah) if (as->ofdm_errors <= ofdm_low && as->cck_errors <= cck_low) ath5k_ani_lower_immunity(ah, as); - ath5k_ani_period_restart(ah, as); + ath5k_ani_period_restart(as); } } -- cgit v1.2.3 From b4cfb5d574cd9e23e41462061941f6ac68a41c80 Mon Sep 17 00:00:00 2001 From: Nick Kossifidis Date: Fri, 25 Nov 2011 20:40:30 +0200 Subject: ath5k: Renumber hw queue ids According to documentation higher DCUs have higher priority and should be used for beacons and CAB traffic. More specifically DCU 9 should be used for beacons and DCU 8 for CAB traffic, I assumed DCU 7 should be OK for UAPSD traffic. Note that DCU 8 and 9 are special because they can only be mapped to a single QCU each but since we use a 1:1 mapping between QCUs and DCUs anyway we don't have to change much. P.S. I also did a few related cleanups on qcu.c and ath5k.h Signed-off-by: Nick Kossifidis Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath5k/ath5k.h | 10 ++++------ drivers/net/wireless/ath/ath5k/qcu.c | 14 +++++++------- 2 files changed, 11 insertions(+), 13 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h index c3815f708382..e564e585b221 100644 --- a/drivers/net/wireless/ath/ath5k/ath5k.h +++ b/drivers/net/wireless/ath/ath5k/ath5k.h @@ -571,20 +571,18 @@ enum ath5k_tx_queue_subtype { * @AR5K_TX_QUEUE_ID_CAB: Content after beacon queue * @AR5K_TX_QUEUE_ID_BEACON: Beacon queue * @AR5K_TX_QUEUE_ID_UAPSD: Urgent Automatic Power Save Delivery, - * @AR5K_TX_QUEUE_ID_XR_DATA: XR Data queue * * Each number represents a hw queue. If hw does not support hw queues - * (eg 5210) all data goes in one queue. These match - * mac80211 definitions. + * (eg 5210) all data goes in one queue. */ enum ath5k_tx_queue_id { AR5K_TX_QUEUE_ID_NOQCU_DATA = 0, AR5K_TX_QUEUE_ID_NOQCU_BEACON = 1, AR5K_TX_QUEUE_ID_DATA_MIN = 0, AR5K_TX_QUEUE_ID_DATA_MAX = 3, - AR5K_TX_QUEUE_ID_CAB = 6, - AR5K_TX_QUEUE_ID_BEACON = 7, - AR5K_TX_QUEUE_ID_UAPSD = 8, + AR5K_TX_QUEUE_ID_UAPSD = 7, + AR5K_TX_QUEUE_ID_CAB = 8, + AR5K_TX_QUEUE_ID_BEACON = 9, }; /* diff --git a/drivers/net/wireless/ath/ath5k/qcu.c b/drivers/net/wireless/ath/ath5k/qcu.c index 31924c319152..e50e64d2a876 100644 --- a/drivers/net/wireless/ath/ath5k/qcu.c +++ b/drivers/net/wireless/ath/ath5k/qcu.c @@ -54,7 +54,7 @@ Queue Control Unit, DCF Control Unit Functions /** * ath5k_hw_num_tx_pending() - Get number of pending frames for a given queue * @ah: The &struct ath5k_hw - * @queue: The hw queue number + * @queue: One of enum ath5k_tx_queue_id */ u32 ath5k_hw_num_tx_pending(struct ath5k_hw *ah, unsigned int queue) @@ -85,7 +85,7 @@ ath5k_hw_num_tx_pending(struct ath5k_hw *ah, unsigned int queue) /** * ath5k_hw_release_tx_queue() - Set a transmit queue inactive * @ah: The &struct ath5k_hw - * @queue: The hw queue number + * @queue: One of enum ath5k_tx_queue_id */ void ath5k_hw_release_tx_queue(struct ath5k_hw *ah, unsigned int queue) @@ -120,7 +120,7 @@ ath5k_cw_validate(u16 cw_req) /** * ath5k_hw_get_tx_queueprops() - Get properties for a transmit queue * @ah: The &struct ath5k_hw - * @queue: The hw queue number + * @queue: One of enum ath5k_tx_queue_id * @queue_info: The &struct ath5k_txq_info to fill */ int @@ -134,7 +134,7 @@ ath5k_hw_get_tx_queueprops(struct ath5k_hw *ah, int queue, /** * ath5k_hw_set_tx_queueprops() - Set properties for a transmit queue * @ah: The &struct ath5k_hw - * @queue: The hw queue number + * @queue: One of enum ath5k_tx_queue_id * @qinfo: The &struct ath5k_txq_info to use * * Returns 0 on success or -EIO if queue is inactive @@ -267,7 +267,7 @@ ath5k_hw_setup_tx_queue(struct ath5k_hw *ah, enum ath5k_tx_queue queue_type, /** * ath5k_hw_set_tx_retry_limits() - Set tx retry limits on DCU * @ah: The &struct ath5k_hw - * @queue: The hw queue number + * @queue: One of enum ath5k_tx_queue_id * * This function is used when initializing a queue, to set * retry limits based on ah->ah_retry_* and the chipset used. @@ -310,9 +310,9 @@ ath5k_hw_set_tx_retry_limits(struct ath5k_hw *ah, /** * ath5k_hw_reset_tx_queue() - Initialize a single hw queue * @ah: The &struct ath5k_hw - * @queue: The hw queue number + * @queue: One of enum ath5k_tx_queue_id * - * Set DFS properties for the given transmit queue on DCU + * Set DCF properties for the given transmit queue on DCU * and configures all queue-specific parameters. */ int -- cgit v1.2.3 From 9a3916910548e419f4da438406f84af9e05f72eb Mon Sep 17 00:00:00 2001 From: Nick Kossifidis Date: Fri, 25 Nov 2011 20:40:31 +0200 Subject: ath5k: Optimize ath5k_cw_validate Optimize ath5k_cw_validate by using the classic (X & (X - 1)) == 0 check to see if a number is power of 2. v2: Use functions from log2.h instead Signed-off-by: Nick Kossifidis Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath5k/qcu.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath5k/qcu.c b/drivers/net/wireless/ath/ath5k/qcu.c index e50e64d2a876..30b50f934172 100644 --- a/drivers/net/wireless/ath/ath5k/qcu.c +++ b/drivers/net/wireless/ath/ath5k/qcu.c @@ -23,6 +23,7 @@ Queue Control Unit, DCF Control Unit Functions #include "ath5k.h" #include "reg.h" #include "debug.h" +#include /** * DOC: Queue Control Unit (QCU)/DCF Control Unit (DCU) functions @@ -108,13 +109,21 @@ ath5k_hw_release_tx_queue(struct ath5k_hw *ah, unsigned int queue) static u16 ath5k_cw_validate(u16 cw_req) { - u32 cw = 1; cw_req = min(cw_req, (u16)1023); - while (cw < cw_req) - cw = (cw << 1) | 1; + /* Check if cw_req + 1 a power of 2 */ + if (is_power_of_2(cw_req + 1)) + return cw_req; - return cw; + /* Check if cw_req is a power of 2 */ + if (is_power_of_2(cw_req)) + return cw_req - 1; + + /* If none of the above is correct + * find the closest power of 2 */ + cw_req = (u16) roundup_pow_of_two(cw_req) - 1; + + return cw_req; } /** -- cgit v1.2.3 From aed666e5e88a27f600187f960d306a028f4883ea Mon Sep 17 00:00:00 2001 From: "Hsu, Kenny" Date: Fri, 25 Nov 2011 11:11:42 -0800 Subject: iwlwifi: add tm commands for indirect register access Create new testmode commands to suppot indirect access of peripheral register. - IWL_TM_CMD_APP2DEV_INDIRECT_REG_READ32 - IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32 Meanwhile, add affix "DIRECT" into original register access commands for better discrimination with new commands. - IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32 - IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32 - IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8 Signed-off-by: Kenny Hsu Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-sv-open.c | 40 ++++++++++++++++++++++++----- drivers/net/wireless/iwlwifi/iwl-testmode.h | 20 ++++++++++----- 2 files changed, 47 insertions(+), 13 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-sv-open.c b/drivers/net/wireless/iwlwifi/iwl-sv-open.c index e3882d0cfc85..be16cafbbc27 100644 --- a/drivers/net/wireless/iwlwifi/iwl-sv-open.c +++ b/drivers/net/wireless/iwlwifi/iwl-sv-open.c @@ -276,7 +276,7 @@ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) IWL_INFO(priv, "testmode register access command offset 0x%x\n", ofs); switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { - case IWL_TM_CMD_APP2DEV_REG_READ32: + case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32: val32 = iwl_read32(bus(priv), ofs); IWL_INFO(priv, "32bit value to read 0x%x\n", val32); @@ -291,7 +291,7 @@ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) IWL_DEBUG_INFO(priv, "Error sending msg : %d\n", status); break; - case IWL_TM_CMD_APP2DEV_REG_WRITE32: + case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32: if (!tb[IWL_TM_ATTR_REG_VALUE32]) { IWL_DEBUG_INFO(priv, "Error finding value to write\n"); @@ -302,7 +302,7 @@ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) iwl_write32(bus(priv), ofs, val32); } break; - case IWL_TM_CMD_APP2DEV_REG_WRITE8: + case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8: if (!tb[IWL_TM_ATTR_REG_VALUE8]) { IWL_DEBUG_INFO(priv, "Error finding value to write\n"); return -ENOMSG; @@ -312,6 +312,32 @@ static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) iwl_write8(bus(priv), ofs, val8); } break; + case IWL_TM_CMD_APP2DEV_INDIRECT_REG_READ32: + val32 = iwl_read_prph(bus(priv), ofs); + IWL_INFO(priv, "32bit value to read 0x%x\n", val32); + + skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); + if (!skb) { + IWL_DEBUG_INFO(priv, "Error allocating memory\n"); + return -ENOMEM; + } + NLA_PUT_U32(skb, IWL_TM_ATTR_REG_VALUE32, val32); + status = cfg80211_testmode_reply(skb); + if (status < 0) + IWL_DEBUG_INFO(priv, + "Error sending msg : %d\n", status); + break; + case IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32: + if (!tb[IWL_TM_ATTR_REG_VALUE32]) { + IWL_DEBUG_INFO(priv, + "Error finding value to write\n"); + return -ENOMSG; + } else { + val32 = nla_get_u32(tb[IWL_TM_ATTR_REG_VALUE32]); + IWL_INFO(priv, "32bit value to write 0x%x\n", val32); + iwl_write_prph(bus(priv), ofs, val32); + } + break; default: IWL_DEBUG_INFO(priv, "Unknown testmode register command ID\n"); return -ENOSYS; @@ -665,9 +691,11 @@ int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) IWL_DEBUG_INFO(priv, "testmode cmd to uCode\n"); result = iwl_testmode_ucode(hw, tb); break; - case IWL_TM_CMD_APP2DEV_REG_READ32: - case IWL_TM_CMD_APP2DEV_REG_WRITE32: - case IWL_TM_CMD_APP2DEV_REG_WRITE8: + case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32: + case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32: + case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8: + case IWL_TM_CMD_APP2DEV_INDIRECT_REG_READ32: + case IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32: IWL_DEBUG_INFO(priv, "testmode cmd to register\n"); result = iwl_testmode_reg(hw, tb); break; diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.h b/drivers/net/wireless/iwlwifi/iwl-testmode.h index b980bda4b0f8..177964850b7c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.h +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.h @@ -76,9 +76,9 @@ * the actual uCode host command ID is carried with * IWL_TM_ATTR_UCODE_CMD_ID * - * @IWL_TM_CMD_APP2DEV_REG_READ32: - * @IWL_TM_CMD_APP2DEV_REG_WRITE32: - * @IWL_TM_CMD_APP2DEV_REG_WRITE8: + * @IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32: + * @IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32: + * @IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8: * commands from user applicaiton to access register * * @IWL_TM_CMD_APP2DEV_GET_DEVICENAME: retrieve device name @@ -107,12 +107,16 @@ * commands from user application to own change the ownership of the uCode * if application has the ownership, the only host command from * testmode will deliver to uCode. Default owner is driver + * @IWL_TM_CMD_APP2DEV_INDIRECT_REG_READ32: + * @IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32: + * commands from user applicaiton to indirectly access peripheral register + * */ enum iwl_tm_cmd_t { IWL_TM_CMD_APP2DEV_UCODE = 1, - IWL_TM_CMD_APP2DEV_REG_READ32 = 2, - IWL_TM_CMD_APP2DEV_REG_WRITE32 = 3, - IWL_TM_CMD_APP2DEV_REG_WRITE8 = 4, + IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32 = 2, + IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32 = 3, + IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8 = 4, IWL_TM_CMD_APP2DEV_GET_DEVICENAME = 5, IWL_TM_CMD_APP2DEV_LOAD_INIT_FW = 6, IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB = 7, @@ -126,7 +130,9 @@ enum iwl_tm_cmd_t { IWL_TM_CMD_DEV2APP_UCODE_RX_PKT = 15, IWL_TM_CMD_DEV2APP_EEPROM_RSP = 16, IWL_TM_CMD_APP2DEV_OWNERSHIP = 17, - IWL_TM_CMD_MAX = 18, + IWL_TM_CMD_APP2DEV_INDIRECT_REG_READ32 = 18, + IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32 = 19, + IWL_TM_CMD_MAX = 20, }; /* -- cgit v1.2.3 From c27bdc84d6310914cfdd59280c2e663588392d01 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 25 Nov 2011 11:11:43 -0800 Subject: iwlagn: remove calibration knowledge The init microcode knows very well which calibrations are required and sends us results for those that are. Consequently, we can just send all of those to the RT uCode again. The problem with having the driver know about this is that it is a uCode feature, not a hardware feature so the config is completely unsuitable. The only thing we need to check is whether the device needs crystal calibration or not, add a new parameter to the configuration for that. This makes new uCode work on 6000 series devices. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-1000.c | 9 --------- drivers/net/wireless/iwlwifi/iwl-2000.c | 14 -------------- drivers/net/wireless/iwlwifi/iwl-5000.c | 16 +--------------- drivers/net/wireless/iwlwifi/iwl-6000.c | 15 --------------- drivers/net/wireless/iwlwifi/iwl-agn-calib.c | 28 +++++++++++++--------------- drivers/net/wireless/iwlwifi/iwl-agn-ucode.c | 8 +++++--- drivers/net/wireless/iwlwifi/iwl-core.h | 5 +++-- drivers/net/wireless/iwlwifi/iwl-shared.h | 2 -- 8 files changed, 22 insertions(+), 75 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c index e12b48c2cff6..bc9bbbb2b494 100644 --- a/drivers/net/wireless/iwlwifi/iwl-1000.c +++ b/drivers/net/wireless/iwlwifi/iwl-1000.c @@ -147,16 +147,7 @@ static int iwl1000_hw_set_hw_params(struct iwl_priv *priv) iwl1000_set_ct_threshold(priv); /* Set initial sensitivity parameters */ - /* Set initial calibration set */ hw_params(priv).sens = &iwl1000_sensitivity; - hw_params(priv).calib_init_cfg = - BIT(IWL_CALIB_XTAL) | - BIT(IWL_CALIB_LO) | - BIT(IWL_CALIB_TX_IQ) | - BIT(IWL_CALIB_TX_IQ_PERD) | - BIT(IWL_CALIB_BASE_BAND); - if (priv->cfg->need_dc_calib) - hw_params(priv).calib_init_cfg |= BIT(IWL_CALIB_DC); return 0; } diff --git a/drivers/net/wireless/iwlwifi/iwl-2000.c b/drivers/net/wireless/iwlwifi/iwl-2000.c index b3193571ed07..0c4688d95b65 100644 --- a/drivers/net/wireless/iwlwifi/iwl-2000.c +++ b/drivers/net/wireless/iwlwifi/iwl-2000.c @@ -143,17 +143,7 @@ static int iwl2000_hw_set_hw_params(struct iwl_priv *priv) iwl2000_set_ct_threshold(priv); /* Set initial sensitivity parameters */ - /* Set initial calibration set */ hw_params(priv).sens = &iwl2000_sensitivity; - hw_params(priv).calib_init_cfg = - BIT(IWL_CALIB_XTAL) | - BIT(IWL_CALIB_LO) | - BIT(IWL_CALIB_TX_IQ) | - BIT(IWL_CALIB_BASE_BAND); - if (priv->cfg->need_dc_calib) - hw_params(priv).calib_rt_cfg |= IWL_CALIB_CFG_DC_IDX; - if (priv->cfg->need_temp_offset_calib) - hw_params(priv).calib_init_cfg |= BIT(IWL_CALIB_TEMP_OFFSET); return 0; } @@ -258,7 +248,6 @@ static struct iwl_bt_params iwl2030_bt_params = { .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \ .lib = &iwl2000_lib, \ .base_params = &iwl2000_base_params, \ - .need_dc_calib = true, \ .need_temp_offset_calib = true, \ .temp_offset_v2 = true, \ .led_mode = IWL_LED_RF_STATE, \ @@ -286,7 +275,6 @@ struct iwl_cfg iwl2000_2bgn_d_cfg = { .lib = &iwl2030_lib, \ .base_params = &iwl2030_base_params, \ .bt_params = &iwl2030_bt_params, \ - .need_dc_calib = true, \ .need_temp_offset_calib = true, \ .temp_offset_v2 = true, \ .led_mode = IWL_LED_RF_STATE, \ @@ -308,7 +296,6 @@ struct iwl_cfg iwl2030_2bgn_cfg = { .eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION, \ .lib = &iwl2000_lib, \ .base_params = &iwl2000_base_params, \ - .need_dc_calib = true, \ .need_temp_offset_calib = true, \ .temp_offset_v2 = true, \ .led_mode = IWL_LED_RF_STATE, \ @@ -338,7 +325,6 @@ struct iwl_cfg iwl105_bgn_d_cfg = { .lib = &iwl2030_lib, \ .base_params = &iwl2030_base_params, \ .bt_params = &iwl2030_bt_params, \ - .need_dc_calib = true, \ .need_temp_offset_calib = true, \ .temp_offset_v2 = true, \ .led_mode = IWL_LED_RF_STATE, \ diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index c511c98a89a8..3a3f83032382 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c @@ -186,14 +186,7 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv) iwl5000_set_ct_threshold(priv); /* Set initial sensitivity parameters */ - /* Set initial calibration set */ hw_params(priv).sens = &iwl5000_sensitivity; - hw_params(priv).calib_init_cfg = - BIT(IWL_CALIB_XTAL) | - BIT(IWL_CALIB_LO) | - BIT(IWL_CALIB_TX_IQ) | - BIT(IWL_CALIB_TX_IQ_PERD) | - BIT(IWL_CALIB_BASE_BAND); return 0; } @@ -222,14 +215,7 @@ static int iwl5150_hw_set_hw_params(struct iwl_priv *priv) iwl5150_set_ct_threshold(priv); /* Set initial sensitivity parameters */ - /* Set initial calibration set */ hw_params(priv).sens = &iwl5150_sensitivity; - hw_params(priv).calib_init_cfg = - BIT(IWL_CALIB_LO) | - BIT(IWL_CALIB_TX_IQ) | - BIT(IWL_CALIB_BASE_BAND); - if (priv->cfg->need_dc_calib) - hw_params(priv).calib_init_cfg |= BIT(IWL_CALIB_DC); return 0; } @@ -433,7 +419,7 @@ struct iwl_cfg iwl5350_agn_cfg = { .eeprom_calib_ver = EEPROM_5050_TX_POWER_VERSION, \ .lib = &iwl5150_lib, \ .base_params = &iwl5000_base_params, \ - .need_dc_calib = true, \ + .no_xtal_calib = true, \ .led_mode = IWL_LED_BLINK, \ .internal_wimax_coex = true diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index ee3363fdf309..09f037824f81 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c @@ -164,17 +164,7 @@ static int iwl6000_hw_set_hw_params(struct iwl_priv *priv) iwl6000_set_ct_threshold(priv); /* Set initial sensitivity parameters */ - /* Set initial calibration set */ hw_params(priv).sens = &iwl6000_sensitivity; - hw_params(priv).calib_init_cfg = - BIT(IWL_CALIB_XTAL) | - BIT(IWL_CALIB_LO) | - BIT(IWL_CALIB_TX_IQ) | - BIT(IWL_CALIB_BASE_BAND); - if (priv->cfg->need_dc_calib) - hw_params(priv).calib_rt_cfg |= IWL_CALIB_CFG_DC_IDX; - if (priv->cfg->need_temp_offset_calib) - hw_params(priv).calib_init_cfg |= BIT(IWL_CALIB_TEMP_OFFSET); return 0; } @@ -364,7 +354,6 @@ static struct iwl_bt_params iwl6000_bt_params = { .eeprom_calib_ver = EEPROM_6005_TX_POWER_VERSION, \ .lib = &iwl6000_lib, \ .base_params = &iwl6000_g2_base_params, \ - .need_dc_calib = true, \ .need_temp_offset_calib = true, \ .led_mode = IWL_LED_RF_STATE @@ -406,7 +395,6 @@ struct iwl_cfg iwl6005_2agn_d_cfg = { .lib = &iwl6030_lib, \ .base_params = &iwl6000_g2_base_params, \ .bt_params = &iwl6000_bt_params, \ - .need_dc_calib = true, \ .need_temp_offset_calib = true, \ .led_mode = IWL_LED_RF_STATE, \ .adv_pm = true \ @@ -506,7 +494,6 @@ struct iwl_cfg iwl6000i_2bg_cfg = { .eeprom_ver = EEPROM_6050_EEPROM_VERSION, \ .eeprom_calib_ver = EEPROM_6050_TX_POWER_VERSION, \ .base_params = &iwl6050_base_params, \ - .need_dc_calib = true, \ .led_mode = IWL_LED_BLINK, \ .internal_wimax_coex = true @@ -530,7 +517,6 @@ struct iwl_cfg iwl6050_2abg_cfg = { .eeprom_ver = EEPROM_6150_EEPROM_VERSION, \ .eeprom_calib_ver = EEPROM_6150_TX_POWER_VERSION, \ .base_params = &iwl6050_base_params, \ - .need_dc_calib = true, \ .led_mode = IWL_LED_BLINK, \ .internal_wimax_coex = true @@ -555,7 +541,6 @@ struct iwl_cfg iwl6000_3agn_cfg = { .lib = &iwl6000_lib, .base_params = &iwl6000_base_params, .ht_params = &iwl6000_ht_params, - .need_dc_calib = true, .led_mode = IWL_LED_BLINK, }; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c index 03bac48558b2..c7bcafabb3b3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c @@ -84,30 +84,28 @@ struct statistics_general_data { int iwl_send_calib_results(struct iwl_priv *priv) { - int ret = 0; - int i = 0; - struct iwl_host_cmd hcmd = { .id = REPLY_PHY_CALIBRATION_CMD, .flags = CMD_SYNC, }; + int i = 0; for (i = 0; i < IWL_CALIB_MAX; i++) { - if ((BIT(i) & hw_params(priv).calib_init_cfg) && - priv->calib_results[i].buf) { - hcmd.len[0] = priv->calib_results[i].buf_len; - hcmd.data[0] = priv->calib_results[i].buf; - hcmd.dataflags[0] = IWL_HCMD_DFL_NOCOPY; - ret = iwl_trans_send_cmd(trans(priv), &hcmd); - if (ret) { - IWL_ERR(priv, "Error %d iteration %d\n", - ret, i); - break; - } + int ret; + + if (!priv->calib_results[i].buf) + continue; + hcmd.len[0] = priv->calib_results[i].buf_len; + hcmd.data[0] = priv->calib_results[i].buf; + hcmd.dataflags[0] = IWL_HCMD_DFL_NOCOPY; + ret = iwl_trans_send_cmd(trans(priv), &hcmd); + if (ret) { + IWL_ERR(priv, "Error %d iteration %d\n", ret, i); + return ret; } } - return ret; + return 0; } int iwl_calib_set(struct iwl_calib_result *res, const u8 *buf, int len) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c index 9ec315b31d45..7043fdb13986 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c @@ -477,9 +477,11 @@ static int iwlagn_alive_notify(struct iwl_priv *priv) if (ret) return ret; - ret = iwlagn_set_Xtal_calib(priv); - if (ret) - return ret; + if (!priv->cfg->no_xtal_calib) { + ret = iwlagn_set_Xtal_calib(priv); + if (ret) + return ret; + } return iwl_send_calib_results(priv); } diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h index fa47f75185df..f1d9d0c13e4c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/drivers/net/wireless/iwlwifi/iwl-core.h @@ -184,8 +184,9 @@ struct iwl_ht_params { * @ht_params: point to ht patameters * @bt_params: pointer to bt parameters * @pa_type: used by 6000 series only to identify the type of Power Amplifier - * @need_dc_calib: need to perform init dc calibration * @need_temp_offset_calib: need to perform temperature offset calibration + * @no_xtal_calib: some devices do not need crystal calibration data, + * don't send it to those * @scan_antennas: available antenna for scan operation * @led_mode: 0=blinking, 1=On(RF On)/Off(RF Off) * @adv_pm: advance power management @@ -222,8 +223,8 @@ struct iwl_cfg { struct iwl_ht_params *ht_params; struct iwl_bt_params *bt_params; enum iwl_pa_type pa_type; /* if used set to IWL_PA_SYSTEM */ - const bool need_dc_calib; /* if used set to true */ const bool need_temp_offset_calib; /* if used set to true */ + const bool no_xtal_calib; u8 scan_rx_antennas[IEEE80211_NUM_BANDS]; enum iwl_led_mode led_mode; const bool adv_pm; diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 1f7a93c67c45..47be77a8a0a7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -174,7 +174,6 @@ struct iwl_mod_params { * @ct_kill_exit_threshold: when to reeable the device - in hw dependent unit * relevant for 1000, 6000 and up * @wd_timeout: TX queues watchdog timeout - * @calib_init_cfg: setup initial calibrations for the hw * @calib_rt_cfg: setup runtime calibrations for the hw * @struct iwl_sensitivity_ranges: range of sensitivity values */ @@ -195,7 +194,6 @@ struct iwl_hw_params { u32 ct_kill_exit_threshold; unsigned int wd_timeout; - u32 calib_init_cfg; u32 calib_rt_cfg; const struct iwl_sensitivity_ranges *sens; }; -- cgit v1.2.3 From 80e83da7eb2cf4409a3ba08f3e39b363c617dd2a Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 25 Nov 2011 11:11:44 -0800 Subject: iwlagn: dynamically allocate & reflect calibration data This makes handling the calibration data more generic and no longer requires updating IWL_CALIB_MAX when a new uCode comes with more calibration packets. Since we just copy the data back, there's also no need for understanding which calibration we received -- we can just reflect it back to the runtime uCode. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-calib.c | 50 +++++++++++++++++----------- drivers/net/wireless/iwlwifi/iwl-agn-calib.h | 3 +- drivers/net/wireless/iwlwifi/iwl-agn-ucode.c | 40 ++++------------------ drivers/net/wireless/iwlwifi/iwl-agn.c | 2 ++ drivers/net/wireless/iwlwifi/iwl-dev.h | 24 +++---------- 5 files changed, 46 insertions(+), 73 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c index c7bcafabb3b3..4d0210594956 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c @@ -88,19 +88,18 @@ int iwl_send_calib_results(struct iwl_priv *priv) .id = REPLY_PHY_CALIBRATION_CMD, .flags = CMD_SYNC, }; - int i = 0; + struct iwl_calib_result *res; - for (i = 0; i < IWL_CALIB_MAX; i++) { + list_for_each_entry(res, &priv->calib_results, list) { int ret; - if (!priv->calib_results[i].buf) - continue; - hcmd.len[0] = priv->calib_results[i].buf_len; - hcmd.data[0] = priv->calib_results[i].buf; + hcmd.len[0] = res->cmd_len; + hcmd.data[0] = &res->hdr; hcmd.dataflags[0] = IWL_HCMD_DFL_NOCOPY; ret = iwl_trans_send_cmd(trans(priv), &hcmd); if (ret) { - IWL_ERR(priv, "Error %d iteration %d\n", ret, i); + IWL_ERR(priv, "Error %d on calib cmd %d\n", + ret, res->hdr.op_code); return ret; } } @@ -108,28 +107,39 @@ int iwl_send_calib_results(struct iwl_priv *priv) return 0; } -int iwl_calib_set(struct iwl_calib_result *res, const u8 *buf, int len) +int iwl_calib_set(struct iwl_priv *priv, + const struct iwl_calib_hdr *cmd, int len) { - if (res->buf_len != len) { - kfree(res->buf); - res->buf = kzalloc(len, GFP_ATOMIC); - } - if (unlikely(res->buf == NULL)) + struct iwl_calib_result *res, *tmp; + + res = kmalloc(sizeof(*res) + len - sizeof(struct iwl_calib_hdr), + GFP_ATOMIC); + if (!res) return -ENOMEM; + memcpy(&res->hdr, cmd, len); + res->cmd_len = len; + + list_for_each_entry(tmp, &priv->calib_results, list) { + if (tmp->hdr.op_code == res->hdr.op_code) { + list_replace(&tmp->list, &res->list); + kfree(tmp); + return 0; + } + } + + /* wasn't in list already */ + list_add_tail(&res->list, &priv->calib_results); - res->buf_len = len; - memcpy(res->buf, buf, len); return 0; } void iwl_calib_free_results(struct iwl_priv *priv) { - int i; + struct iwl_calib_result *res, *tmp; - for (i = 0; i < IWL_CALIB_MAX; i++) { - kfree(priv->calib_results[i].buf); - priv->calib_results[i].buf = NULL; - priv->calib_results[i].buf_len = 0; + list_for_each_entry_safe(res, tmp, &priv->calib_results, list) { + list_del(&res->list); + kfree(res); } } diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.h b/drivers/net/wireless/iwlwifi/iwl-agn-calib.h index a869fc9205d2..6ed806c8f80f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.h @@ -73,7 +73,8 @@ void iwl_init_sensitivity(struct iwl_priv *priv); void iwl_reset_run_time_calib(struct iwl_priv *priv); int iwl_send_calib_results(struct iwl_priv *priv); -int iwl_calib_set(struct iwl_calib_result *res, const u8 *buf, int len); +int iwl_calib_set(struct iwl_priv *priv, + const struct iwl_calib_hdr *cmd, int len); void iwl_calib_free_results(struct iwl_priv *priv); #endif /* __iwl_calib_h__ */ diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c index 7043fdb13986..76949106dafc 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c @@ -222,8 +222,7 @@ static int iwlagn_set_Xtal_calib(struct iwl_priv *priv) iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD); cmd.cap_pin1 = le16_to_cpu(xtal_calib[0]); cmd.cap_pin2 = le16_to_cpu(xtal_calib[1]); - return iwl_calib_set(&priv->calib_results[IWL_CALIB_XTAL], - (u8 *)&cmd, sizeof(cmd)); + return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); } static int iwlagn_set_temperature_offset_calib(struct iwl_priv *priv) @@ -240,8 +239,7 @@ static int iwlagn_set_temperature_offset_calib(struct iwl_priv *priv) IWL_DEBUG_CALIB(priv, "Radio sensor offset: %d\n", le16_to_cpu(cmd.radio_sensor_offset)); - return iwl_calib_set(&priv->calib_results[IWL_CALIB_TEMP_OFFSET], - (u8 *)&cmd, sizeof(cmd)); + return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); } static int iwlagn_set_temperature_offset_calib_v2(struct iwl_priv *priv) @@ -276,8 +274,7 @@ static int iwlagn_set_temperature_offset_calib_v2(struct iwl_priv *priv) IWL_DEBUG_CALIB(priv, "Voltage Ref: %d\n", le16_to_cpu(cmd.burntVoltageRef)); - return iwl_calib_set(&priv->calib_results[IWL_CALIB_TEMP_OFFSET], - (u8 *)&cmd, sizeof(cmd)); + return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); } static int iwlagn_send_calib_cfg(struct iwl_priv *priv) @@ -306,37 +303,14 @@ int iwlagn_rx_calib_result(struct iwl_priv *priv, struct iwl_rx_packet *pkt = rxb_addr(rxb); struct iwl_calib_hdr *hdr = (struct iwl_calib_hdr *)pkt->u.raw; int len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; - int index; /* reduce the size of the length field itself */ len -= 4; - /* Define the order in which the results will be sent to the runtime - * uCode. iwl_send_calib_results sends them in a row according to - * their index. We sort them here - */ - switch (hdr->op_code) { - case IWL_PHY_CALIBRATE_DC_CMD: - index = IWL_CALIB_DC; - break; - case IWL_PHY_CALIBRATE_LO_CMD: - index = IWL_CALIB_LO; - break; - case IWL_PHY_CALIBRATE_TX_IQ_CMD: - index = IWL_CALIB_TX_IQ; - break; - case IWL_PHY_CALIBRATE_TX_IQ_PERD_CMD: - index = IWL_CALIB_TX_IQ_PERD; - break; - case IWL_PHY_CALIBRATE_BASE_BAND_CMD: - index = IWL_CALIB_BASE_BAND; - break; - default: - IWL_ERR(priv, "Unknown calibration notification %d\n", - hdr->op_code); - return -1; - } - iwl_calib_set(&priv->calib_results[index], pkt->u.raw, len); + if (iwl_calib_set(priv, hdr, len)) + IWL_ERR(priv, "Failed to record calibration data %d\n", + hdr->op_code); + return 0; } diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index e235e84de8b4..8e571c356fb3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1575,6 +1575,8 @@ static int iwl_init_drv(struct iwl_priv *priv) mutex_init(&priv->shrd->mutex); + INIT_LIST_HEAD(&priv->calib_results); + priv->ieee_channels = NULL; priv->ieee_rates = NULL; priv->band = IEEE80211_BAND_2GHZ; diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 556e4a2c19bc..0c95ad3048a0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -442,26 +442,12 @@ enum iwlagn_chain_noise_state { }; -/* - * enum iwl_calib - * defines the order in which results of initial calibrations - * should be sent to the runtime uCode - */ -enum iwl_calib { - IWL_CALIB_XTAL, - IWL_CALIB_DC, - IWL_CALIB_LO, - IWL_CALIB_TX_IQ, - IWL_CALIB_TX_IQ_PERD, - IWL_CALIB_BASE_BAND, - IWL_CALIB_TEMP_OFFSET, - IWL_CALIB_MAX -}; - /* Opaque calibration results */ struct iwl_calib_result { - void *buf; - size_t buf_len; + struct list_head list; + size_t cmd_len; + struct iwl_calib_hdr hdr; + /* data follows */ }; /* Sensitivity calib data */ @@ -869,7 +855,7 @@ struct iwl_priv { s32 last_temperature; /* init calibration results */ - struct iwl_calib_result calib_results[IWL_CALIB_MAX]; + struct list_head calib_results; struct iwl_wipan_noa_data __rcu *noa_data; -- cgit v1.2.3 From a0d337f9a11d58ec7c9bd70ae260e397c091d157 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 25 Nov 2011 11:11:45 -0800 Subject: iwlagn: allow up to uCode API 6 for 6000 devices Since the uCode hasn't been released (yet?), warn only if using older than API 4, but load anything up to API 6. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-6000.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index 09f037824f81..617ad1c0df61 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c @@ -46,11 +46,12 @@ #include "iwl-cfg.h" /* Highest firmware API version supported */ -#define IWL6000_UCODE_API_MAX 4 +#define IWL6000_UCODE_API_MAX 6 #define IWL6050_UCODE_API_MAX 5 #define IWL6000G2_UCODE_API_MAX 6 /* Oldest version we won't warn about */ +#define IWL6000_UCODE_API_OK 4 #define IWL6000G2_UCODE_API_OK 5 /* Lowest firmware API version supported */ @@ -457,6 +458,7 @@ struct iwl_cfg iwl130_bg_cfg = { #define IWL_DEVICE_6000i \ .fw_name_pre = IWL6000_FW_PRE, \ .ucode_api_max = IWL6000_UCODE_API_MAX, \ + .ucode_api_ok = IWL6000_UCODE_API_OK, \ .ucode_api_min = IWL6000_UCODE_API_MIN, \ .valid_tx_ant = ANT_BC, /* .cfg overwrite */ \ .valid_rx_ant = ANT_BC, /* .cfg overwrite */ \ @@ -535,6 +537,7 @@ struct iwl_cfg iwl6000_3agn_cfg = { .name = "Intel(R) Centrino(R) Ultimate-N 6300 AGN", .fw_name_pre = IWL6000_FW_PRE, .ucode_api_max = IWL6000_UCODE_API_MAX, + .ucode_api_ok = IWL6000_UCODE_API_OK, .ucode_api_min = IWL6000_UCODE_API_MIN, .eeprom_ver = EEPROM_6000_EEPROM_VERSION, .eeprom_calib_ver = EEPROM_6000_TX_POWER_VERSION, @@ -544,7 +547,7 @@ struct iwl_cfg iwl6000_3agn_cfg = { .led_mode = IWL_LED_BLINK, }; -MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_MAX)); +MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_OK)); MODULE_FIRMWARE(IWL6050_MODULE_FIRMWARE(IWL6050_UCODE_API_MAX)); MODULE_FIRMWARE(IWL6005_MODULE_FIRMWARE(IWL6000G2_UCODE_API_MAX)); MODULE_FIRMWARE(IWL6030_MODULE_FIRMWARE(IWL6000G2_UCODE_API_MAX)); -- cgit v1.2.3 From 9d5fa6181914371883be880ed3adc1bca2f26cba Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Fri, 25 Nov 2011 11:11:46 -0800 Subject: iwlwifi: show command string for REPLY_D3_CONFIG missing the string, add it Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-rx.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index fdb4c3786114..087fd52e5727 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c @@ -117,6 +117,7 @@ const char *get_cmd_string(u8 cmd) IWL_CMD(REPLY_WOWLAN_TKIP_PARAMS); IWL_CMD(REPLY_WOWLAN_KEK_KCK_MATERIAL); IWL_CMD(REPLY_WOWLAN_GET_STATUS); + IWL_CMD(REPLY_D3_CONFIG); default: return "UNKNOWN"; -- cgit v1.2.3 From ebfa867dd939839436fe8fed8122b9e5d30841f6 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Fri, 25 Nov 2011 11:11:47 -0800 Subject: iwlwifi: show the configuration option Not sure it is the best way to do it, but many times we want to know what the configuration options were enabled for the compiled driver. Let's just log the options during load time; so there were be no confusion. Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 8e571c356fb3..db0d3a84b1e4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1682,6 +1682,35 @@ static int iwl_set_hw_params(struct iwl_priv *priv) +static void iwl_debug_config(struct iwl_priv *priv) +{ + dev_printk(KERN_INFO, bus(priv)->dev, "CONFIG_IWLWIFI_DEBUG " +#ifdef CONFIG_IWLWIFI_DEBUG + "enabled\n"); +#else + "disabled\n"); +#endif + dev_printk(KERN_INFO, bus(priv)->dev, "CONFIG_IWLWIFI_DEBUGFS " +#ifdef CONFIG_IWLWIFI_DEBUGFS + "enabled\n"); +#else + "disabled\n"); +#endif + dev_printk(KERN_INFO, bus(priv)->dev, "CONFIG_IWLWIFI_DEVICE_TRACING " +#ifdef CONFIG_IWLWIFI_DEVICE_TRACING + "enabled\n"); +#else + "disabled\n"); +#endif + + dev_printk(KERN_INFO, bus(priv)->dev, "CONFIG_IWLWIFI_DEVICE_SVTOOL " +#ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL + "enabled\n"); +#else + "disabled\n"); +#endif +} + int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, struct iwl_cfg *cfg) { @@ -1717,6 +1746,9 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, SET_IEEE80211_DEV(hw, bus(priv)->dev); + /* what debugging capabilities we have */ + iwl_debug_config(priv); + IWL_DEBUG_INFO(priv, "*** LOAD DRIVER ***\n"); priv->cfg = cfg; -- cgit v1.2.3 From 264827555bff54bc2c896b51777e89bd22d01c21 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Fri, 25 Nov 2011 11:11:48 -0800 Subject: iwlwifi: help to debug AGG SM inconsistencies Add more data when inconsistencies occur in the AGG state machine. Signed-off-by: Emmanuel Grumbach Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 527e7957c932..2ac75427f10b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1099,13 +1099,21 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb, hdr->seq_ctrl = hdr->seq_ctrl & cpu_to_le16(IEEE80211_SCTL_FRAG); hdr->seq_ctrl |= cpu_to_le16(seq_number); - seq_number += 0x10; /* aggregation is on for this */ if (info->flags & IEEE80211_TX_CTL_AMPDU) { - WARN_ON_ONCE(tid_data->agg.state != IWL_AGG_ON); + if (WARN_ON_ONCE(tid_data->agg.state != IWL_AGG_ON)) { + IWL_ERR(trans, "TX_CTL_AMPDU while not in AGG:" + " Tx flags = 0x%08x, agg.state = %d", + info->flags, tid_data->agg.state); + IWL_ERR(trans, "sta_id = %d, tid = %d " + "txq_id = %d, seq_num = %d", sta_id, + tid, tid_data->agg.txq_id, + seq_number >> 4); + } txq_id = tid_data->agg.txq_id; is_agg = true; } + seq_number += 0x10; } /* Copy MAC header from skb into command buffer */ -- cgit v1.2.3 From d3f311349adde6ac533f9acdee45c49ce20cdb12 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 28 Nov 2011 16:38:48 -0500 Subject: brcm80211: fix usage of set tx power mBm is passed but dBm was assumed... Signed-off-by: Luis R. Rodriguez Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c index cc19a733ac65..fc9898192ab4 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c @@ -1429,7 +1429,7 @@ brcmf_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *ndev, static s32 brcmf_cfg80211_set_tx_power(struct wiphy *wiphy, - enum nl80211_tx_power_setting type, s32 dbm) + enum nl80211_tx_power_setting type, s32 mbm) { struct brcmf_cfg80211_priv *cfg_priv = wiphy_to_cfg(wiphy); @@ -1437,6 +1437,7 @@ brcmf_cfg80211_set_tx_power(struct wiphy *wiphy, u16 txpwrmw; s32 err = 0; s32 disable = 0; + s32 dbm = MBM_TO_DBM(mbm); WL_TRACE("Enter\n"); if (!check_sys_up(wiphy)) -- cgit v1.2.3 From e957abb60e293761d47d647b811d8547ebfbf5c3 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 28 Nov 2011 16:38:49 -0500 Subject: brcm80211: avoid code duplication on set tx power Both cases are doing the same so treat the switch cases for both as an "or". Signed-off-by: Luis R. Rodriguez Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c index fc9898192ab4..f23b0c3e4ea3 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c @@ -1447,12 +1447,6 @@ brcmf_cfg80211_set_tx_power(struct wiphy *wiphy, case NL80211_TX_POWER_AUTOMATIC: break; case NL80211_TX_POWER_LIMITED: - if (dbm < 0) { - WL_ERR("TX_POWER_LIMITED - dbm is negative\n"); - err = -EINVAL; - goto done; - } - break; case NL80211_TX_POWER_FIXED: if (dbm < 0) { WL_ERR("TX_POWER_FIXED - dbm is negative\n"); -- cgit v1.2.3 From 742c29fd5bcd73f14facd6c7f3912c5ab66739ed Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 28 Nov 2011 16:38:50 -0500 Subject: mwifiex: fix usage of set tx power mBm is passed but dBm was assumed... Acked-by: Bing Zhao Signed-off-by: Luis R. Rodriguez Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/cfg80211.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c index e9ab9a3fbe9c..0db97cc84cb4 100644 --- a/drivers/net/wireless/mwifiex/cfg80211.c +++ b/drivers/net/wireless/mwifiex/cfg80211.c @@ -120,10 +120,11 @@ mwifiex_cfg80211_del_key(struct wiphy *wiphy, struct net_device *netdev, static int mwifiex_cfg80211_set_tx_power(struct wiphy *wiphy, enum nl80211_tx_power_setting type, - int dbm) + int mbm) { struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy); struct mwifiex_power_cfg power_cfg; + int dbm = MBM_TO_DBM(mbm); if (type == NL80211_TX_POWER_FIXED) { power_cfg.is_power_auto = 0; -- cgit v1.2.3 From 1a68abb0c85b5eb490971b622ff36168c64416a7 Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Tue, 29 Nov 2011 20:06:15 +0530 Subject: ath9k: Fix LED GPIO pin for AR9462 GPIO pin 4 is assigned AR9462 chipsets LED. while GPIO pin 0 worked for obselete AR9462 chipsets though they are meant for EEPROM as per Russell Cc: Senthil Balasubramanian Signed-off-by: Russell Hu Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ath9k.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index 93b45b4b3033..386402c37158 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h @@ -462,7 +462,7 @@ void ath9k_btcoex_timer_pause(struct ath_softc *sc); #define ATH_LED_PIN_9287 8 #define ATH_LED_PIN_9300 10 #define ATH_LED_PIN_9485 6 -#define ATH_LED_PIN_9462 0 +#define ATH_LED_PIN_9462 4 #ifdef CONFIG_MAC80211_LEDS void ath_init_leds(struct ath_softc *sc); -- cgit v1.2.3 From eb840a80d2e5f446ad58a6d4f14dcaa3d877a362 Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Tue, 29 Nov 2011 20:30:35 +0530 Subject: ath9k: change the default antenna settings based on diversity change the AR_DEF_ANTENNA register settings i.e setting default antenna setting only for antenna diversity enabled chipsets. no point in doing this for MIMO chipsets Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/recv.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c index 4c8e296f663b..b1b0ec76157b 100644 --- a/drivers/net/wireless/ath/ath9k/recv.c +++ b/drivers/net/wireless/ath/ath9k/recv.c @@ -1923,15 +1923,20 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) skb = hdr_skb; } - /* - * change the default rx antenna if rx diversity chooses the - * other antenna 3 times in a row. - */ - if (sc->rx.defant != rs.rs_antenna) { - if (++sc->rx.rxotherant >= 3) - ath_setdefantenna(sc, rs.rs_antenna); - } else { - sc->rx.rxotherant = 0; + + if (ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) { + + /* + * change the default rx antenna if rx diversity + * chooses the other antenna 3 times in a row. + */ + if (sc->rx.defant != rs.rs_antenna) { + if (++sc->rx.rxotherant >= 3) + ath_setdefantenna(sc, rs.rs_antenna); + } else { + sc->rx.rxotherant = 0; + } + } if (rxs->flag & RX_FLAG_MMIC_STRIPPED) -- cgit v1.2.3 From acda130b0e615596c63640f05febb02d2e681dde Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 29 Nov 2011 12:40:16 -0500 Subject: prism54: remove private driver ioctls As of hostap_0_7_1~358 the CONFIG_DRIVER_PRISM54 was removed from upstream wpa_supplicant/hostapd so lets just kill the useless old prism54 private ioctl crap. Cc: Jouni Malinen Cc: David Miller Reported-by: David Miller Signed-off-by: Luis R. Rodriguez Signed-off-by: John W. Linville --- drivers/net/wireless/prism54/isl_ioctl.c | 333 ------------------------------ drivers/net/wireless/prism54/isl_ioctl.h | 2 - drivers/net/wireless/prism54/islpci_dev.c | 1 - 3 files changed, 336 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/prism54/isl_ioctl.c b/drivers/net/wireless/prism54/isl_ioctl.c index d97a2caf582b..f83bc5a5e81f 100644 --- a/drivers/net/wireless/prism54/isl_ioctl.c +++ b/drivers/net/wireless/prism54/isl_ioctl.c @@ -2493,323 +2493,7 @@ prism54_set_mac_address(struct net_device *ndev, void *addr) return ret; } -/* Note: currently, use hostapd ioctl from the Host AP driver for WPA - * support. This is to be replaced with Linux wireless extensions once they - * get WPA support. */ - -/* Note II: please leave all this together as it will be easier to remove later, - * once wireless extensions add WPA support -mcgrof */ - -/* PRISM54_HOSTAPD ioctl() cmd: */ -enum { - PRISM2_SET_ENCRYPTION = 6, - PRISM2_HOSTAPD_SET_GENERIC_ELEMENT = 12, - PRISM2_HOSTAPD_MLME = 13, - PRISM2_HOSTAPD_SCAN_REQ = 14, -}; - #define PRISM54_SET_WPA SIOCIWFIRSTPRIV+12 -#define PRISM54_HOSTAPD SIOCIWFIRSTPRIV+25 -#define PRISM54_DROP_UNENCRYPTED SIOCIWFIRSTPRIV+26 - -#define PRISM2_HOSTAPD_MAX_BUF_SIZE 1024 -#define PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN \ - offsetof(struct prism2_hostapd_param, u.generic_elem.data) - -/* Maximum length for algorithm names (-1 for nul termination) - * used in ioctl() */ -#define HOSTAP_CRYPT_ALG_NAME_LEN 16 - -struct prism2_hostapd_param { - u32 cmd; - u8 sta_addr[ETH_ALEN]; - union { - struct { - u8 alg[HOSTAP_CRYPT_ALG_NAME_LEN]; - u32 flags; - u32 err; - u8 idx; - u8 seq[8]; /* sequence counter (set: RX, get: TX) */ - u16 key_len; - u8 key[0]; - } crypt; - struct { - u8 len; - u8 data[0]; - } generic_elem; - struct { -#define MLME_STA_DEAUTH 0 -#define MLME_STA_DISASSOC 1 - u16 cmd; - u16 reason_code; - } mlme; - struct { - u8 ssid_len; - u8 ssid[32]; - } scan_req; - } u; -}; - - -static int -prism2_ioctl_set_encryption(struct net_device *dev, - struct prism2_hostapd_param *param, - int param_len) -{ - islpci_private *priv = netdev_priv(dev); - int rvalue = 0, force = 0; - int authen = DOT11_AUTH_OS, invoke = 0, exunencrypt = 0; - union oid_res_t r; - - /* with the new API, it's impossible to get a NULL pointer. - * New version of iwconfig set the IW_ENCODE_NOKEY flag - * when no key is given, but older versions don't. */ - - if (param->u.crypt.key_len > 0) { - /* we have a key to set */ - int index = param->u.crypt.idx; - int current_index; - struct obj_key key = { DOT11_PRIV_TKIP, 0, "" }; - - /* get the current key index */ - rvalue = mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r); - current_index = r.u; - /* Verify that the key is not marked as invalid */ - if (!(param->u.crypt.flags & IW_ENCODE_NOKEY)) { - key.length = param->u.crypt.key_len > sizeof (param->u.crypt.key) ? - sizeof (param->u.crypt.key) : param->u.crypt.key_len; - memcpy(key.key, param->u.crypt.key, key.length); - if (key.length == 32) - /* we want WPA-PSK */ - key.type = DOT11_PRIV_TKIP; - if ((index < 0) || (index > 3)) - /* no index provided use the current one */ - index = current_index; - - /* now send the key to the card */ - rvalue |= - mgt_set_request(priv, DOT11_OID_DEFKEYX, index, - &key); - } - /* - * If a valid key is set, encryption should be enabled - * (user may turn it off later). - * This is also how "iwconfig ethX key on" works - */ - if ((index == current_index) && (key.length > 0)) - force = 1; - } else { - int index = (param->u.crypt.flags & IW_ENCODE_INDEX) - 1; - if ((index >= 0) && (index <= 3)) { - /* we want to set the key index */ - rvalue |= - mgt_set_request(priv, DOT11_OID_DEFKEYID, 0, - &index); - } else { - if (!(param->u.crypt.flags & IW_ENCODE_MODE)) { - /* we cannot do anything. Complain. */ - return -EINVAL; - } - } - } - /* now read the flags */ - if (param->u.crypt.flags & IW_ENCODE_DISABLED) { - /* Encoding disabled, - * authen = DOT11_AUTH_OS; - * invoke = 0; - * exunencrypt = 0; */ - } - if (param->u.crypt.flags & IW_ENCODE_OPEN) - /* Encode but accept non-encoded packets. No auth */ - invoke = 1; - if ((param->u.crypt.flags & IW_ENCODE_RESTRICTED) || force) { - /* Refuse non-encoded packets. Auth */ - authen = DOT11_AUTH_BOTH; - invoke = 1; - exunencrypt = 1; - } - /* do the change if requested */ - if ((param->u.crypt.flags & IW_ENCODE_MODE) || force) { - rvalue |= - mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0, &authen); - rvalue |= - mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0, &invoke); - rvalue |= - mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0, - &exunencrypt); - } - return rvalue; -} - -static int -prism2_ioctl_set_generic_element(struct net_device *ndev, - struct prism2_hostapd_param *param, - int param_len) -{ - islpci_private *priv = netdev_priv(ndev); - int max_len, len, alen, ret=0; - struct obj_attachment *attach; - - len = param->u.generic_elem.len; - max_len = param_len - PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN; - if (max_len < 0 || max_len < len) - return -EINVAL; - - alen = sizeof(*attach) + len; - attach = kzalloc(alen, GFP_KERNEL); - if (attach == NULL) - return -ENOMEM; - -#define WLAN_FC_TYPE_MGMT 0 -#define WLAN_FC_STYPE_ASSOC_REQ 0 -#define WLAN_FC_STYPE_REASSOC_REQ 2 - - /* Note: endianness is covered by mgt_set_varlen */ - - attach->type = (WLAN_FC_TYPE_MGMT << 2) | - (WLAN_FC_STYPE_ASSOC_REQ << 4); - attach->id = -1; - attach->size = len; - memcpy(attach->data, param->u.generic_elem.data, len); - - ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach, len); - - if (ret == 0) { - attach->type = (WLAN_FC_TYPE_MGMT << 2) | - (WLAN_FC_STYPE_REASSOC_REQ << 4); - - ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach, len); - - if (ret == 0) - printk(KERN_DEBUG "%s: WPA IE Attachment was set\n", - ndev->name); - } - - kfree(attach); - return ret; - -} - -static int -prism2_ioctl_mlme(struct net_device *dev, struct prism2_hostapd_param *param) -{ - return -EOPNOTSUPP; -} - -static int -prism2_ioctl_scan_req(struct net_device *ndev, - struct prism2_hostapd_param *param) -{ - islpci_private *priv = netdev_priv(ndev); - struct iw_request_info info; - int i, rvalue; - struct obj_bsslist *bsslist; - u32 noise = 0; - char *extra = ""; - char *current_ev = "foo"; - union oid_res_t r; - - if (islpci_get_state(priv) < PRV_STATE_INIT) { - /* device is not ready, fail gently */ - return 0; - } - - /* first get the noise value. We will use it to report the link quality */ - rvalue = mgt_get_request(priv, DOT11_OID_NOISEFLOOR, 0, NULL, &r); - noise = r.u; - - /* Ask the device for a list of known bss. We can report at most - * IW_MAX_AP=64 to the range struct. But the device won't repport anything - * if you change the value of IWMAX_BSS=24. - */ - rvalue |= mgt_get_request(priv, DOT11_OID_BSSLIST, 0, NULL, &r); - bsslist = r.ptr; - - info.cmd = PRISM54_HOSTAPD; - info.flags = 0; - - /* ok now, scan the list and translate its info */ - for (i = 0; i < min(IW_MAX_AP, (int) bsslist->nr); i++) - current_ev = prism54_translate_bss(ndev, &info, current_ev, - extra + IW_SCAN_MAX_DATA, - &(bsslist->bsslist[i]), - noise); - kfree(bsslist); - - return rvalue; -} - -static int -prism54_hostapd(struct net_device *ndev, struct iw_point *p) -{ - struct prism2_hostapd_param *param; - int ret = 0; - u32 uwrq; - - printk(KERN_DEBUG "prism54_hostapd - len=%d\n", p->length); - if (p->length < sizeof(struct prism2_hostapd_param) || - p->length > PRISM2_HOSTAPD_MAX_BUF_SIZE || !p->pointer) - return -EINVAL; - - param = memdup_user(p->pointer, p->length); - if (IS_ERR(param)) - return PTR_ERR(param); - - switch (param->cmd) { - case PRISM2_SET_ENCRYPTION: - printk(KERN_DEBUG "%s: Caught WPA supplicant set encryption request\n", - ndev->name); - ret = prism2_ioctl_set_encryption(ndev, param, p->length); - break; - case PRISM2_HOSTAPD_SET_GENERIC_ELEMENT: - printk(KERN_DEBUG "%s: Caught WPA supplicant set WPA IE request\n", - ndev->name); - ret = prism2_ioctl_set_generic_element(ndev, param, - p->length); - break; - case PRISM2_HOSTAPD_MLME: - printk(KERN_DEBUG "%s: Caught WPA supplicant MLME request\n", - ndev->name); - ret = prism2_ioctl_mlme(ndev, param); - break; - case PRISM2_HOSTAPD_SCAN_REQ: - printk(KERN_DEBUG "%s: Caught WPA supplicant scan request\n", - ndev->name); - ret = prism2_ioctl_scan_req(ndev, param); - break; - case PRISM54_SET_WPA: - printk(KERN_DEBUG "%s: Caught WPA supplicant wpa init request\n", - ndev->name); - uwrq = 1; - ret = prism54_set_wpa(ndev, NULL, &uwrq, NULL); - break; - case PRISM54_DROP_UNENCRYPTED: - printk(KERN_DEBUG "%s: Caught WPA drop unencrypted request\n", - ndev->name); -#if 0 - uwrq = 0x01; - mgt_set(priv, DOT11_OID_EXUNENCRYPTED, &uwrq); - down_write(&priv->mib_sem); - mgt_commit(priv); - up_write(&priv->mib_sem); -#endif - /* Not necessary, as set_wpa does it, should we just do it here though? */ - ret = 0; - break; - default: - printk(KERN_DEBUG "%s: Caught a WPA supplicant request that is not supported\n", - ndev->name); - ret = -EOPNOTSUPP; - break; - } - - if (ret == 0 && copy_to_user(p->pointer, param, p->length)) - ret = -EFAULT; - - kfree(param); - - return ret; -} static int prism54_set_wpa(struct net_device *ndev, struct iw_request_info *info, @@ -3223,20 +2907,3 @@ const struct iw_handler_def prism54_handler_def = { .private_args = (struct iw_priv_args *) prism54_private_args, .get_wireless_stats = prism54_get_wireless_stats, }; - -/* For wpa_supplicant */ - -int -prism54_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd) -{ - struct iwreq *wrq = (struct iwreq *) rq; - int ret = -1; - switch (cmd) { - case PRISM54_HOSTAPD: - if (!capable(CAP_NET_ADMIN)) - return -EPERM; - ret = prism54_hostapd(ndev, &wrq->u.data); - return ret; - } - return -EOPNOTSUPP; -} diff --git a/drivers/net/wireless/prism54/isl_ioctl.h b/drivers/net/wireless/prism54/isl_ioctl.h index bcfbfb9281d2..a34bceb6e3cd 100644 --- a/drivers/net/wireless/prism54/isl_ioctl.h +++ b/drivers/net/wireless/prism54/isl_ioctl.h @@ -43,8 +43,6 @@ void prism54_wpa_bss_ie_clean(islpci_private *priv); int prism54_set_mac_address(struct net_device *, void *); -int prism54_ioctl(struct net_device *, struct ifreq *, int); - extern const struct iw_handler_def prism54_handler_def; #endif /* _ISL_IOCTL_H */ diff --git a/drivers/net/wireless/prism54/islpci_dev.c b/drivers/net/wireless/prism54/islpci_dev.c index 8a3cf4fe376f..5970ff6f40cc 100644 --- a/drivers/net/wireless/prism54/islpci_dev.c +++ b/drivers/net/wireless/prism54/islpci_dev.c @@ -804,7 +804,6 @@ static const struct ethtool_ops islpci_ethtool_ops = { static const struct net_device_ops islpci_netdev_ops = { .ndo_open = islpci_open, .ndo_stop = islpci_close, - .ndo_do_ioctl = prism54_ioctl, .ndo_start_xmit = islpci_eth_transmit, .ndo_tx_timeout = islpci_eth_tx_timeout, .ndo_set_mac_address = prism54_set_mac_address, -- cgit v1.2.3 From 2ee4bd1e25f8752cc5c4d39219c7bf5079ffc21f Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Wed, 30 Nov 2011 10:41:13 +0530 Subject: ath9k_hw: add definitions to support MCI h/w code these definitions will be used by MCI state machine and the corresponding hardware code Cc: Wilson Tsao Cc: Senthil Balasubramanian Signed-off-by: Rajkumar Manoharan Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9003_mci.h | 102 ++++++++++ drivers/net/wireless/ath/ath9k/ar9003_phy.h | 3 + drivers/net/wireless/ath/ath9k/hw.h | 146 +++++++++++++ drivers/net/wireless/ath/ath9k/reg.h | 304 +++++++++++++++++++++++++--- 4 files changed, 529 insertions(+), 26 deletions(-) create mode 100644 drivers/net/wireless/ath/ath9k/ar9003_mci.h (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.h b/drivers/net/wireless/ath/ath9k/ar9003_mci.h new file mode 100644 index 000000000000..798da116a44c --- /dev/null +++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.h @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2010-2011 Atheros Communications Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef AR9003_MCI_H +#define AR9003_MCI_H + +#define MCI_FLAG_DISABLE_TIMESTAMP 0x00000001 /* Disable time stamp */ + +/* Default remote BT device MCI COEX version */ +#define MCI_GPM_COEX_MAJOR_VERSION_DEFAULT 3 +#define MCI_GPM_COEX_MINOR_VERSION_DEFAULT 0 + +/* Local WLAN MCI COEX version */ +#define MCI_GPM_COEX_MAJOR_VERSION_WLAN 3 +#define MCI_GPM_COEX_MINOR_VERSION_WLAN 0 + +enum mci_gpm_coex_query_type { + MCI_GPM_COEX_QUERY_BT_ALL_INFO = BIT(0), + MCI_GPM_COEX_QUERY_BT_TOPOLOGY = BIT(1), + MCI_GPM_COEX_QUERY_BT_DEBUG = BIT(2), +}; + +enum mci_gpm_coex_halt_bt_gpm { + MCI_GPM_COEX_BT_GPM_UNHALT, + MCI_GPM_COEX_BT_GPM_HALT +}; + +enum mci_gpm_coex_bt_update_flags_op { + MCI_GPM_COEX_BT_FLAGS_READ, + MCI_GPM_COEX_BT_FLAGS_SET, + MCI_GPM_COEX_BT_FLAGS_CLEAR +}; + +#define MCI_NUM_BT_CHANNELS 79 + +#define MCI_BT_MCI_FLAGS_UPDATE_CORR 0x00000002 +#define MCI_BT_MCI_FLAGS_UPDATE_HDR 0x00000004 +#define MCI_BT_MCI_FLAGS_UPDATE_PLD 0x00000008 +#define MCI_BT_MCI_FLAGS_LNA_CTRL 0x00000010 +#define MCI_BT_MCI_FLAGS_DEBUG 0x00000020 +#define MCI_BT_MCI_FLAGS_SCHED_MSG 0x00000040 +#define MCI_BT_MCI_FLAGS_CONT_MSG 0x00000080 +#define MCI_BT_MCI_FLAGS_COEX_GPM 0x00000100 +#define MCI_BT_MCI_FLAGS_CPU_INT_MSG 0x00000200 +#define MCI_BT_MCI_FLAGS_MCI_MODE 0x00000400 +#define MCI_BT_MCI_FLAGS_AR9462_MODE 0x00001000 +#define MCI_BT_MCI_FLAGS_OTHER 0x00010000 + +#define MCI_DEFAULT_BT_MCI_FLAGS 0x00011dde + +#define MCI_TOGGLE_BT_MCI_FLAGS (MCI_BT_MCI_FLAGS_UPDATE_CORR | \ + MCI_BT_MCI_FLAGS_UPDATE_HDR | \ + MCI_BT_MCI_FLAGS_UPDATE_PLD | \ + MCI_BT_MCI_FLAGS_MCI_MODE) + +#define MCI_2G_FLAGS_CLEAR_MASK 0x00000000 +#define MCI_2G_FLAGS_SET_MASK MCI_TOGGLE_BT_MCI_FLAGS +#define MCI_2G_FLAGS MCI_DEFAULT_BT_MCI_FLAGS + +#define MCI_5G_FLAGS_CLEAR_MASK MCI_TOGGLE_BT_MCI_FLAGS +#define MCI_5G_FLAGS_SET_MASK 0x00000000 +#define MCI_5G_FLAGS (MCI_DEFAULT_BT_MCI_FLAGS & \ + ~MCI_TOGGLE_BT_MCI_FLAGS) + +/* + * Default value for AR9462 is 0x00002201 + */ +#define ATH_MCI_CONFIG_CONCUR_TX 0x00000003 +#define ATH_MCI_CONFIG_MCI_OBS_MCI 0x00000004 +#define ATH_MCI_CONFIG_MCI_OBS_TXRX 0x00000008 +#define ATH_MCI_CONFIG_MCI_OBS_BT 0x00000010 +#define ATH_MCI_CONFIG_DISABLE_MCI_CAL 0x00000020 +#define ATH_MCI_CONFIG_DISABLE_OSLA 0x00000040 +#define ATH_MCI_CONFIG_DISABLE_FTP_STOMP 0x00000080 +#define ATH_MCI_CONFIG_AGGR_THRESH 0x00000700 +#define ATH_MCI_CONFIG_AGGR_THRESH_S 8 +#define ATH_MCI_CONFIG_DISABLE_AGGR_THRESH 0x00000800 +#define ATH_MCI_CONFIG_CLK_DIV 0x00003000 +#define ATH_MCI_CONFIG_CLK_DIV_S 12 +#define ATH_MCI_CONFIG_DISABLE_TUNING 0x00004000 +#define ATH_MCI_CONFIG_MCI_WEIGHT_DBG 0x40000000 +#define ATH_MCI_CONFIG_DISABLE_MCI 0x80000000 + +#define ATH_MCI_CONFIG_MCI_OBS_MASK (ATH_MCI_CONFIG_MCI_OBS_MCI | \ + ATH_MCI_CONFIG_MCI_OBS_TXRX | \ + ATH_MCI_CONFIG_MCI_OBS_BT) +#define ATH_MCI_CONFIG_MCI_OBS_GPIO 0x0000002F + +#endif diff --git a/drivers/net/wireless/ath/ath9k/ar9003_phy.h b/drivers/net/wireless/ath/ath9k/ar9003_phy.h index 497d7461838a..ed64114571fc 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h @@ -490,6 +490,8 @@ #define AR_PHY_TEST_CTL_TSTADC_EN_S 8 #define AR_PHY_TEST_CTL_RX_OBS_SEL 0x3C00 #define AR_PHY_TEST_CTL_RX_OBS_SEL_S 10 +#define AR_PHY_TEST_CTL_DEBUGPORT_SEL 0xe0000000 +#define AR_PHY_TEST_CTL_DEBUGPORT_SEL_S 29 #define AR_PHY_TSTDAC (AR_SM_BASE + 0x168) @@ -1001,6 +1003,7 @@ /* GLB Registers */ #define AR_GLB_BASE 0x20000 +#define AR_GLB_GPIO_CONTROL (AR_GLB_BASE) #define AR_PHY_GLB_CONTROL (AR_GLB_BASE + 0x44) #define AR_GLB_SCRATCH(_ah) (AR_GLB_BASE + \ (AR_SREV_9462_20(_ah) ? 0x4c : 0x50)) diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index 3cb878c28ccf..4f786cb3020a 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -266,6 +266,7 @@ enum ath9k_int { ATH9K_INT_TX = 0x00000040, ATH9K_INT_TXDESC = 0x00000080, ATH9K_INT_TIM_TIMER = 0x00000100, + ATH9K_INT_MCI = 0x00000200, ATH9K_INT_BB_WATCHDOG = 0x00000400, ATH9K_INT_TXURN = 0x00000800, ATH9K_INT_MIB = 0x00001000, @@ -417,6 +418,25 @@ enum ath9k_rx_qtype { ATH9K_RX_QUEUE_MAX, }; +enum mci_message_header { /* length of payload */ + MCI_LNA_CTRL = 0x10, /* len = 0 */ + MCI_CONT_NACK = 0x20, /* len = 0 */ + MCI_CONT_INFO = 0x30, /* len = 4 */ + MCI_CONT_RST = 0x40, /* len = 0 */ + MCI_SCHD_INFO = 0x50, /* len = 16 */ + MCI_CPU_INT = 0x60, /* len = 4 */ + MCI_SYS_WAKING = 0x70, /* len = 0 */ + MCI_GPM = 0x80, /* len = 16 */ + MCI_LNA_INFO = 0x90, /* len = 1 */ + MCI_LNA_STATE = 0x94, + MCI_LNA_TAKE = 0x98, + MCI_LNA_TRANS = 0x9c, + MCI_SYS_SLEEPING = 0xa0, /* len = 0 */ + MCI_REQ_WAKE = 0xc0, /* len = 0 */ + MCI_DEBUG_16 = 0xfe, /* len = 2 */ + MCI_REMOTE_RESET = 0xff /* len = 16 */ +}; + enum ath_mci_gpm_coex_profile_type { MCI_GPM_COEX_PROFILE_UNKNOWN, MCI_GPM_COEX_PROFILE_RFCOMM, @@ -427,6 +447,132 @@ enum ath_mci_gpm_coex_profile_type { MCI_GPM_COEX_PROFILE_MAX }; +/* MCI GPM/Coex opcode/type definitions */ +enum { + MCI_GPM_COEX_W_GPM_PAYLOAD = 1, + MCI_GPM_COEX_B_GPM_TYPE = 4, + MCI_GPM_COEX_B_GPM_OPCODE = 5, + /* MCI_GPM_WLAN_CAL_REQ, MCI_GPM_WLAN_CAL_DONE */ + MCI_GPM_WLAN_CAL_W_SEQUENCE = 2, + + /* MCI_GPM_COEX_VERSION_QUERY */ + /* MCI_GPM_COEX_VERSION_RESPONSE */ + MCI_GPM_COEX_B_MAJOR_VERSION = 6, + MCI_GPM_COEX_B_MINOR_VERSION = 7, + /* MCI_GPM_COEX_STATUS_QUERY */ + MCI_GPM_COEX_B_BT_BITMAP = 6, + MCI_GPM_COEX_B_WLAN_BITMAP = 7, + /* MCI_GPM_COEX_HALT_BT_GPM */ + MCI_GPM_COEX_B_HALT_STATE = 6, + /* MCI_GPM_COEX_WLAN_CHANNELS */ + MCI_GPM_COEX_B_CHANNEL_MAP = 6, + /* MCI_GPM_COEX_BT_PROFILE_INFO */ + MCI_GPM_COEX_B_PROFILE_TYPE = 6, + MCI_GPM_COEX_B_PROFILE_LINKID = 7, + MCI_GPM_COEX_B_PROFILE_STATE = 8, + MCI_GPM_COEX_B_PROFILE_ROLE = 9, + MCI_GPM_COEX_B_PROFILE_RATE = 10, + MCI_GPM_COEX_B_PROFILE_VOTYPE = 11, + MCI_GPM_COEX_H_PROFILE_T = 12, + MCI_GPM_COEX_B_PROFILE_W = 14, + MCI_GPM_COEX_B_PROFILE_A = 15, + /* MCI_GPM_COEX_BT_STATUS_UPDATE */ + MCI_GPM_COEX_B_STATUS_TYPE = 6, + MCI_GPM_COEX_B_STATUS_LINKID = 7, + MCI_GPM_COEX_B_STATUS_STATE = 8, + /* MCI_GPM_COEX_BT_UPDATE_FLAGS */ + MCI_GPM_COEX_W_BT_FLAGS = 6, + MCI_GPM_COEX_B_BT_FLAGS_OP = 10 +}; + +enum mci_gpm_subtype { + MCI_GPM_BT_CAL_REQ = 0, + MCI_GPM_BT_CAL_GRANT = 1, + MCI_GPM_BT_CAL_DONE = 2, + MCI_GPM_WLAN_CAL_REQ = 3, + MCI_GPM_WLAN_CAL_GRANT = 4, + MCI_GPM_WLAN_CAL_DONE = 5, + MCI_GPM_COEX_AGENT = 0x0c, + MCI_GPM_RSVD_PATTERN = 0xfe, + MCI_GPM_RSVD_PATTERN32 = 0xfefefefe, + MCI_GPM_BT_DEBUG = 0xff +}; + +enum mci_bt_state { + MCI_BT_SLEEP, + MCI_BT_AWAKE, + MCI_BT_CAL_START, + MCI_BT_CAL +}; + +/* Type of state query */ +enum mci_state_type { + MCI_STATE_ENABLE, + MCI_STATE_INIT_GPM_OFFSET, + MCI_STATE_NEXT_GPM_OFFSET, + MCI_STATE_LAST_GPM_OFFSET, + MCI_STATE_BT, + MCI_STATE_SET_BT_SLEEP, + MCI_STATE_SET_BT_AWAKE, + MCI_STATE_SET_BT_CAL_START, + MCI_STATE_SET_BT_CAL, + MCI_STATE_LAST_SCHD_MSG_OFFSET, + MCI_STATE_REMOTE_SLEEP, + MCI_STATE_CONT_RSSI_POWER, + MCI_STATE_CONT_PRIORITY, + MCI_STATE_CONT_TXRX, + MCI_STATE_RESET_REQ_WAKE, + MCI_STATE_SEND_WLAN_COEX_VERSION, + MCI_STATE_SET_BT_COEX_VERSION, + MCI_STATE_SEND_WLAN_CHANNELS, + MCI_STATE_SEND_VERSION_QUERY, + MCI_STATE_SEND_STATUS_QUERY, + MCI_STATE_NEED_FLUSH_BT_INFO, + MCI_STATE_SET_CONCUR_TX_PRI, + MCI_STATE_RECOVER_RX, + MCI_STATE_NEED_FTP_STOMP, + MCI_STATE_NEED_TUNING, + MCI_STATE_DEBUG, + MCI_STATE_MAX +}; + +enum mci_gpm_coex_opcode { + MCI_GPM_COEX_VERSION_QUERY, + MCI_GPM_COEX_VERSION_RESPONSE, + MCI_GPM_COEX_STATUS_QUERY, + MCI_GPM_COEX_HALT_BT_GPM, + MCI_GPM_COEX_WLAN_CHANNELS, + MCI_GPM_COEX_BT_PROFILE_INFO, + MCI_GPM_COEX_BT_STATUS_UPDATE, + MCI_GPM_COEX_BT_UPDATE_FLAGS +}; + +#define MCI_GPM_NOMORE 0 +#define MCI_GPM_MORE 1 +#define MCI_GPM_INVALID 0xffffffff + +#define MCI_GPM_RECYCLE(_p_gpm) do { \ + *(((u32 *)_p_gpm) + MCI_GPM_COEX_W_GPM_PAYLOAD) = \ + MCI_GPM_RSVD_PATTERN32; \ +} while (0) + +#define MCI_GPM_TYPE(_p_gpm) \ + (*(((u8 *)(_p_gpm)) + MCI_GPM_COEX_B_GPM_TYPE) & 0xff) + +#define MCI_GPM_OPCODE(_p_gpm) \ + (*(((u8 *)(_p_gpm)) + MCI_GPM_COEX_B_GPM_OPCODE) & 0xff) + +#define MCI_GPM_SET_CAL_TYPE(_p_gpm, _cal_type) do { \ + *(((u8 *)(_p_gpm)) + MCI_GPM_COEX_B_GPM_TYPE) = (_cal_type) & 0xff;\ +} while (0) + +#define MCI_GPM_SET_TYPE_OPCODE(_p_gpm, _type, _opcode) do { \ + *(((u8 *)(_p_gpm)) + MCI_GPM_COEX_B_GPM_TYPE) = (_type) & 0xff; \ + *(((u8 *)(_p_gpm)) + MCI_GPM_COEX_B_GPM_OPCODE) = (_opcode) & 0xff;\ +} while (0) + +#define MCI_GPM_IS_CAL_TYPE(_type) ((_type) <= MCI_GPM_WLAN_CAL_DONE) + struct ath9k_beacon_state { u32 bs_nexttbtt; u32 bs_nextdtim; diff --git a/drivers/net/wireless/ath/ath9k/reg.h b/drivers/net/wireless/ath/ath9k/reg.h index 45910975d853..ba3672f45a20 100644 --- a/drivers/net/wireless/ath/ath9k/reg.h +++ b/drivers/net/wireless/ath/ath9k/reg.h @@ -1006,6 +1006,8 @@ enum { #define AR_INTR_ASYNC_MASK (AR_SREV_9340(ah) ? 0x4018 : 0x4030) #define AR_INTR_ASYNC_MASK_GPIO 0xFFFC0000 #define AR_INTR_ASYNC_MASK_GPIO_S 18 +#define AR_INTR_ASYNC_MASK_MCI 0x00000080 +#define AR_INTR_ASYNC_MASK_MCI_S 7 #define AR_INTR_SYNC_MASK (AR_SREV_9340(ah) ? 0x401c : 0x4034) #define AR_INTR_SYNC_MASK_GPIO 0xFFFC0000 @@ -1013,6 +1015,14 @@ enum { #define AR_INTR_ASYNC_CAUSE_CLR (AR_SREV_9340(ah) ? 0x4020 : 0x4038) #define AR_INTR_ASYNC_CAUSE (AR_SREV_9340(ah) ? 0x4020 : 0x4038) +#define AR_INTR_ASYNC_CAUSE_MCI 0x00000080 +#define AR_INTR_ASYNC_USED (AR_INTR_MAC_IRQ | \ + AR_INTR_ASYNC_CAUSE_MCI) + +/* Asynchronous Interrupt Enable Register */ +#define AR_INTR_ASYNC_ENABLE_MCI 0x00000080 +#define AR_INTR_ASYNC_ENABLE_MCI_S 7 + #define AR_INTR_ASYNC_ENABLE (AR_SREV_9340(ah) ? 0x4024 : 0x403c) #define AR_INTR_ASYNC_ENABLE_GPIO 0xFFFC0000 @@ -1555,6 +1565,8 @@ enum { #define AR_DIAG_FRAME_NV0 0x00020000 #define AR_DIAG_OBS_PT_SEL1 0x000C0000 #define AR_DIAG_OBS_PT_SEL1_S 18 +#define AR_DIAG_OBS_PT_SEL2 0x08000000 +#define AR_DIAG_OBS_PT_SEL2_S 27 #define AR_DIAG_FORCE_RX_CLEAR 0x00100000 /* force rx_clear high */ #define AR_DIAG_IGNORE_VIRT_CS 0x00200000 #define AR_DIAG_FORCE_CH_IDLE_HIGH 0x00400000 @@ -1929,37 +1941,277 @@ enum { #define AR_PHY_AGC_CONTROL_YCOK_MAX_S 6 /* MCI Registers */ -#define AR_MCI_INTERRUPT_RX_MSG_EN 0x183c -#define AR_MCI_INTERRUPT_RX_MSG_REMOTE_RESET 0x00000001 -#define AR_MCI_INTERRUPT_RX_MSG_REMOTE_RESET_S 0 -#define AR_MCI_INTERRUPT_RX_MSG_LNA_CONTROL 0x00000002 -#define AR_MCI_INTERRUPT_RX_MSG_LNA_CONTROL_S 1 -#define AR_MCI_INTERRUPT_RX_MSG_CONT_NACK 0x00000004 -#define AR_MCI_INTERRUPT_RX_MSG_CONT_NACK_S 2 -#define AR_MCI_INTERRUPT_RX_MSG_CONT_INFO 0x00000008 -#define AR_MCI_INTERRUPT_RX_MSG_CONT_INFO_S 3 -#define AR_MCI_INTERRUPT_RX_MSG_CONT_RST 0x00000010 -#define AR_MCI_INTERRUPT_RX_MSG_CONT_RST_S 4 -#define AR_MCI_INTERRUPT_RX_MSG_SCHD_INFO 0x00000020 -#define AR_MCI_INTERRUPT_RX_MSG_SCHD_INFO_S 5 -#define AR_MCI_INTERRUPT_RX_MSG_CPU_INT 0x00000040 -#define AR_MCI_INTERRUPT_RX_MSG_CPU_INT_S 6 -#define AR_MCI_INTERRUPT_RX_MSG_GPM 0x00000100 -#define AR_MCI_INTERRUPT_RX_MSG_GPM_S 8 -#define AR_MCI_INTERRUPT_RX_MSG_LNA_INFO 0x00000200 -#define AR_MCI_INTERRUPT_RX_MSG_LNA_INFO_S 9 -#define AR_MCI_INTERRUPT_RX_MSG_SYS_SLEEPING 0x00000400 -#define AR_MCI_INTERRUPT_RX_MSG_SYS_SLEEPING_S 10 -#define AR_MCI_INTERRUPT_RX_MSG_SYS_WAKING 0x00000800 -#define AR_MCI_INTERRUPT_RX_MSG_SYS_WAKING_S 11 -#define AR_MCI_INTERRUPT_RX_MSG_REQ_WAKE 0x00001000 -#define AR_MCI_INTERRUPT_RX_MSG_REQ_WAKE_S 12 -#define AR_MCI_INTERRUPT_RX_HW_MSG_MASK (AR_MCI_INTERRUPT_RX_MSG_SCHD_INFO | \ + +#define AR_MCI_COMMAND0 0x1800 +#define AR_MCI_COMMAND0_HEADER 0xFF +#define AR_MCI_COMMAND0_HEADER_S 0 +#define AR_MCI_COMMAND0_LEN 0x1f00 +#define AR_MCI_COMMAND0_LEN_S 8 +#define AR_MCI_COMMAND0_DISABLE_TIMESTAMP 0x2000 +#define AR_MCI_COMMAND0_DISABLE_TIMESTAMP_S 13 + +#define AR_MCI_COMMAND1 0x1804 + +#define AR_MCI_COMMAND2 0x1808 +#define AR_MCI_COMMAND2_RESET_TX 0x01 +#define AR_MCI_COMMAND2_RESET_TX_S 0 +#define AR_MCI_COMMAND2_RESET_RX 0x02 +#define AR_MCI_COMMAND2_RESET_RX_S 1 +#define AR_MCI_COMMAND2_RESET_RX_NUM_CYCLES 0x3FC +#define AR_MCI_COMMAND2_RESET_RX_NUM_CYCLES_S 2 +#define AR_MCI_COMMAND2_RESET_REQ_WAKEUP 0x400 +#define AR_MCI_COMMAND2_RESET_REQ_WAKEUP_S 10 + +#define AR_MCI_RX_CTRL 0x180c + +#define AR_MCI_TX_CTRL 0x1810 +/* 0 = no division, 1 = divide by 2, 2 = divide by 4, 3 = divide by 8 */ +#define AR_MCI_TX_CTRL_CLK_DIV 0x03 +#define AR_MCI_TX_CTRL_CLK_DIV_S 0 +#define AR_MCI_TX_CTRL_DISABLE_LNA_UPDATE 0x04 +#define AR_MCI_TX_CTRL_DISABLE_LNA_UPDATE_S 2 +#define AR_MCI_TX_CTRL_GAIN_UPDATE_FREQ 0xFFFFF8 +#define AR_MCI_TX_CTRL_GAIN_UPDATE_FREQ_S 3 +#define AR_MCI_TX_CTRL_GAIN_UPDATE_NUM 0xF000000 +#define AR_MCI_TX_CTRL_GAIN_UPDATE_NUM_S 24 + +#define AR_MCI_MSG_ATTRIBUTES_TABLE 0x1814 +#define AR_MCI_MSG_ATTRIBUTES_TABLE_CHECKSUM 0xFFFF +#define AR_MCI_MSG_ATTRIBUTES_TABLE_CHECKSUM_S 0 +#define AR_MCI_MSG_ATTRIBUTES_TABLE_INVALID_HDR 0xFFFF0000 +#define AR_MCI_MSG_ATTRIBUTES_TABLE_INVALID_HDR_S 16 + +#define AR_MCI_SCHD_TABLE_0 0x1818 +#define AR_MCI_SCHD_TABLE_1 0x181c +#define AR_MCI_GPM_0 0x1820 +#define AR_MCI_GPM_1 0x1824 +#define AR_MCI_GPM_WRITE_PTR 0xFFFF0000 +#define AR_MCI_GPM_WRITE_PTR_S 16 +#define AR_MCI_GPM_BUF_LEN 0x0000FFFF +#define AR_MCI_GPM_BUF_LEN_S 0 + +#define AR_MCI_INTERRUPT_RAW 0x1828 +#define AR_MCI_INTERRUPT_EN 0x182c +#define AR_MCI_INTERRUPT_SW_MSG_DONE 0x00000001 +#define AR_MCI_INTERRUPT_SW_MSG_DONE_S 0 +#define AR_MCI_INTERRUPT_CPU_INT_MSG 0x00000002 +#define AR_MCI_INTERRUPT_CPU_INT_MSG_S 1 +#define AR_MCI_INTERRUPT_RX_CKSUM_FAIL 0x00000004 +#define AR_MCI_INTERRUPT_RX_CKSUM_FAIL_S 2 +#define AR_MCI_INTERRUPT_RX_INVALID_HDR 0x00000008 +#define AR_MCI_INTERRUPT_RX_INVALID_HDR_S 3 +#define AR_MCI_INTERRUPT_RX_HW_MSG_FAIL 0x00000010 +#define AR_MCI_INTERRUPT_RX_HW_MSG_FAIL_S 4 +#define AR_MCI_INTERRUPT_RX_SW_MSG_FAIL 0x00000020 +#define AR_MCI_INTERRUPT_RX_SW_MSG_FAIL_S 5 +#define AR_MCI_INTERRUPT_TX_HW_MSG_FAIL 0x00000080 +#define AR_MCI_INTERRUPT_TX_HW_MSG_FAIL_S 7 +#define AR_MCI_INTERRUPT_TX_SW_MSG_FAIL 0x00000100 +#define AR_MCI_INTERRUPT_TX_SW_MSG_FAIL_S 8 +#define AR_MCI_INTERRUPT_RX_MSG 0x00000200 +#define AR_MCI_INTERRUPT_RX_MSG_S 9 +#define AR_MCI_INTERRUPT_REMOTE_SLEEP_UPDATE 0x00000400 +#define AR_MCI_INTERRUPT_REMOTE_SLEEP_UPDATE_S 10 +#define AR_MCI_INTERRUPT_BT_PRI 0x07fff800 +#define AR_MCI_INTERRUPT_BT_PRI_S 11 +#define AR_MCI_INTERRUPT_BT_PRI_THRESH 0x08000000 +#define AR_MCI_INTERRUPT_BT_PRI_THRESH_S 27 +#define AR_MCI_INTERRUPT_BT_FREQ 0x10000000 +#define AR_MCI_INTERRUPT_BT_FREQ_S 28 +#define AR_MCI_INTERRUPT_BT_STOMP 0x20000000 +#define AR_MCI_INTERRUPT_BT_STOMP_S 29 +#define AR_MCI_INTERRUPT_BB_AIC_IRQ 0x40000000 +#define AR_MCI_INTERRUPT_BB_AIC_IRQ_S 30 +#define AR_MCI_INTERRUPT_CONT_INFO_TIMEOUT 0x80000000 +#define AR_MCI_INTERRUPT_CONT_INFO_TIMEOUT_S 31 + +#define AR_MCI_INTERRUPT_DEFAULT (AR_MCI_INTERRUPT_SW_MSG_DONE | \ + AR_MCI_INTERRUPT_RX_INVALID_HDR | \ + AR_MCI_INTERRUPT_RX_HW_MSG_FAIL | \ + AR_MCI_INTERRUPT_RX_SW_MSG_FAIL | \ + AR_MCI_INTERRUPT_TX_HW_MSG_FAIL | \ + AR_MCI_INTERRUPT_TX_SW_MSG_FAIL | \ + AR_MCI_INTERRUPT_RX_MSG | \ + AR_MCI_INTERRUPT_REMOTE_SLEEP_UPDATE | \ + AR_MCI_INTERRUPT_CONT_INFO_TIMEOUT) + +#define AR_MCI_INTERRUPT_MSG_FAIL_MASK (AR_MCI_INTERRUPT_RX_HW_MSG_FAIL | \ + AR_MCI_INTERRUPT_RX_SW_MSG_FAIL | \ + AR_MCI_INTERRUPT_TX_HW_MSG_FAIL | \ + AR_MCI_INTERRUPT_TX_SW_MSG_FAIL) + +#define AR_MCI_REMOTE_CPU_INT 0x1830 +#define AR_MCI_REMOTE_CPU_INT_EN 0x1834 +#define AR_MCI_INTERRUPT_RX_MSG_RAW 0x1838 +#define AR_MCI_INTERRUPT_RX_MSG_EN 0x183c +#define AR_MCI_INTERRUPT_RX_MSG_REMOTE_RESET 0x00000001 +#define AR_MCI_INTERRUPT_RX_MSG_REMOTE_RESET_S 0 +#define AR_MCI_INTERRUPT_RX_MSG_LNA_CONTROL 0x00000002 +#define AR_MCI_INTERRUPT_RX_MSG_LNA_CONTROL_S 1 +#define AR_MCI_INTERRUPT_RX_MSG_CONT_NACK 0x00000004 +#define AR_MCI_INTERRUPT_RX_MSG_CONT_NACK_S 2 +#define AR_MCI_INTERRUPT_RX_MSG_CONT_INFO 0x00000008 +#define AR_MCI_INTERRUPT_RX_MSG_CONT_INFO_S 3 +#define AR_MCI_INTERRUPT_RX_MSG_CONT_RST 0x00000010 +#define AR_MCI_INTERRUPT_RX_MSG_CONT_RST_S 4 +#define AR_MCI_INTERRUPT_RX_MSG_SCHD_INFO 0x00000020 +#define AR_MCI_INTERRUPT_RX_MSG_SCHD_INFO_S 5 +#define AR_MCI_INTERRUPT_RX_MSG_CPU_INT 0x00000040 +#define AR_MCI_INTERRUPT_RX_MSG_CPU_INT_S 6 +#define AR_MCI_INTERRUPT_RX_MSG_GPM 0x00000100 +#define AR_MCI_INTERRUPT_RX_MSG_GPM_S 8 +#define AR_MCI_INTERRUPT_RX_MSG_LNA_INFO 0x00000200 +#define AR_MCI_INTERRUPT_RX_MSG_LNA_INFO_S 9 +#define AR_MCI_INTERRUPT_RX_MSG_SYS_SLEEPING 0x00000400 +#define AR_MCI_INTERRUPT_RX_MSG_SYS_SLEEPING_S 10 +#define AR_MCI_INTERRUPT_RX_MSG_SYS_WAKING 0x00000800 +#define AR_MCI_INTERRUPT_RX_MSG_SYS_WAKING_S 11 +#define AR_MCI_INTERRUPT_RX_MSG_REQ_WAKE 0x00001000 +#define AR_MCI_INTERRUPT_RX_MSG_REQ_WAKE_S 12 +#define AR_MCI_INTERRUPT_RX_HW_MSG_MASK (AR_MCI_INTERRUPT_RX_MSG_SCHD_INFO | \ AR_MCI_INTERRUPT_RX_MSG_LNA_CONTROL| \ AR_MCI_INTERRUPT_RX_MSG_LNA_INFO | \ AR_MCI_INTERRUPT_RX_MSG_CONT_NACK | \ AR_MCI_INTERRUPT_RX_MSG_CONT_INFO | \ AR_MCI_INTERRUPT_RX_MSG_CONT_RST) +#define AR_MCI_INTERRUPT_RX_MSG_DEFAULT (AR_MCI_INTERRUPT_RX_MSG_GPM | \ + AR_MCI_INTERRUPT_RX_MSG_REMOTE_RESET| \ + AR_MCI_INTERRUPT_RX_MSG_SYS_WAKING | \ + AR_MCI_INTERRUPT_RX_MSG_SYS_SLEEPING| \ + AR_MCI_INTERRUPT_RX_MSG_SCHD_INFO | \ + AR_MCI_INTERRUPT_RX_MSG_LNA_CONTROL | \ + AR_MCI_INTERRUPT_RX_MSG_LNA_INFO | \ + AR_MCI_INTERRUPT_RX_MSG_CONT_NACK | \ + AR_MCI_INTERRUPT_RX_MSG_CONT_INFO | \ + AR_MCI_INTERRUPT_RX_MSG_CONT_RST | \ + AR_MCI_INTERRUPT_RX_MSG_REQ_WAKE) + +#define AR_MCI_CPU_INT 0x1840 + +#define AR_MCI_RX_STATUS 0x1844 +#define AR_MCI_RX_LAST_SCHD_MSG_INDEX 0x00000F00 +#define AR_MCI_RX_LAST_SCHD_MSG_INDEX_S 8 +#define AR_MCI_RX_REMOTE_SLEEP 0x00001000 +#define AR_MCI_RX_REMOTE_SLEEP_S 12 +#define AR_MCI_RX_MCI_CLK_REQ 0x00002000 +#define AR_MCI_RX_MCI_CLK_REQ_S 13 + +#define AR_MCI_CONT_STATUS 0x1848 +#define AR_MCI_CONT_RSSI_POWER 0x000000FF +#define AR_MCI_CONT_RSSI_POWER_S 0 +#define AR_MCI_CONT_RRIORITY 0x0000FF00 +#define AR_MCI_CONT_RRIORITY_S 8 +#define AR_MCI_CONT_TXRX 0x00010000 +#define AR_MCI_CONT_TXRX_S 16 + +#define AR_MCI_BT_PRI0 0x184c +#define AR_MCI_BT_PRI1 0x1850 +#define AR_MCI_BT_PRI2 0x1854 +#define AR_MCI_BT_PRI3 0x1858 +#define AR_MCI_BT_PRI 0x185c +#define AR_MCI_WL_FREQ0 0x1860 +#define AR_MCI_WL_FREQ1 0x1864 +#define AR_MCI_WL_FREQ2 0x1868 +#define AR_MCI_GAIN 0x186c +#define AR_MCI_WBTIMER1 0x1870 +#define AR_MCI_WBTIMER2 0x1874 +#define AR_MCI_WBTIMER3 0x1878 +#define AR_MCI_WBTIMER4 0x187c +#define AR_MCI_MAXGAIN 0x1880 +#define AR_MCI_HW_SCHD_TBL_CTL 0x1884 +#define AR_MCI_HW_SCHD_TBL_D0 0x1888 +#define AR_MCI_HW_SCHD_TBL_D1 0x188c +#define AR_MCI_HW_SCHD_TBL_D2 0x1890 +#define AR_MCI_HW_SCHD_TBL_D3 0x1894 +#define AR_MCI_TX_PAYLOAD0 0x1898 +#define AR_MCI_TX_PAYLOAD1 0x189c +#define AR_MCI_TX_PAYLOAD2 0x18a0 +#define AR_MCI_TX_PAYLOAD3 0x18a4 +#define AR_BTCOEX_WBTIMER 0x18a8 + +#define AR_BTCOEX_CTRL 0x18ac +#define AR_BTCOEX_CTRL_AR9462_MODE 0x00000001 +#define AR_BTCOEX_CTRL_AR9462_MODE_S 0 +#define AR_BTCOEX_CTRL_WBTIMER_EN 0x00000002 +#define AR_BTCOEX_CTRL_WBTIMER_EN_S 1 +#define AR_BTCOEX_CTRL_MCI_MODE_EN 0x00000004 +#define AR_BTCOEX_CTRL_MCI_MODE_EN_S 2 +#define AR_BTCOEX_CTRL_LNA_SHARED 0x00000008 +#define AR_BTCOEX_CTRL_LNA_SHARED_S 3 +#define AR_BTCOEX_CTRL_PA_SHARED 0x00000010 +#define AR_BTCOEX_CTRL_PA_SHARED_S 4 +#define AR_BTCOEX_CTRL_ONE_STEP_LOOK_AHEAD_EN 0x00000020 +#define AR_BTCOEX_CTRL_ONE_STEP_LOOK_AHEAD_EN_S 5 +#define AR_BTCOEX_CTRL_TIME_TO_NEXT_BT_THRESH_EN 0x00000040 +#define AR_BTCOEX_CTRL_TIME_TO_NEXT_BT_THRESH_EN_S 6 +#define AR_BTCOEX_CTRL_NUM_ANTENNAS 0x00000180 +#define AR_BTCOEX_CTRL_NUM_ANTENNAS_S 7 +#define AR_BTCOEX_CTRL_RX_CHAIN_MASK 0x00000E00 +#define AR_BTCOEX_CTRL_RX_CHAIN_MASK_S 9 +#define AR_BTCOEX_CTRL_AGGR_THRESH 0x00007000 +#define AR_BTCOEX_CTRL_AGGR_THRESH_S 12 +#define AR_BTCOEX_CTRL_1_CHAIN_BCN 0x00080000 +#define AR_BTCOEX_CTRL_1_CHAIN_BCN_S 19 +#define AR_BTCOEX_CTRL_1_CHAIN_ACK 0x00100000 +#define AR_BTCOEX_CTRL_1_CHAIN_ACK_S 20 +#define AR_BTCOEX_CTRL_WAIT_BA_MARGIN 0x1FE00000 +#define AR_BTCOEX_CTRL_WAIT_BA_MARGIN_S 28 +#define AR_BTCOEX_CTRL_REDUCE_TXPWR 0x20000000 +#define AR_BTCOEX_CTRL_REDUCE_TXPWR_S 29 +#define AR_BTCOEX_CTRL_SPDT_ENABLE_10 0x40000000 +#define AR_BTCOEX_CTRL_SPDT_ENABLE_10_S 30 +#define AR_BTCOEX_CTRL_SPDT_POLARITY 0x80000000 +#define AR_BTCOEX_CTRL_SPDT_POLARITY_S 31 + +#define AR_BTCOEX_WL_WEIGHTS0 0x18b0 +#define AR_BTCOEX_WL_WEIGHTS1 0x18b4 +#define AR_BTCOEX_WL_WEIGHTS2 0x18b8 +#define AR_BTCOEX_WL_WEIGHTS3 0x18bc +#define AR_BTCOEX_MAX_TXPWR(_x) (0x18c0 + ((_x) << 2)) +#define AR_BTCOEX_WL_LNA 0x1940 +#define AR_BTCOEX_RFGAIN_CTRL 0x1944 + +#define AR_BTCOEX_CTRL2 0x1948 +#define AR_BTCOEX_CTRL2_TXPWR_THRESH 0x0007F800 +#define AR_BTCOEX_CTRL2_TXPWR_THRESH_S 11 +#define AR_BTCOEX_CTRL2_TX_CHAIN_MASK 0x00380000 +#define AR_BTCOEX_CTRL2_TX_CHAIN_MASK_S 19 +#define AR_BTCOEX_CTRL2_RX_DEWEIGHT 0x00400000 +#define AR_BTCOEX_CTRL2_RX_DEWEIGHT_S 22 +#define AR_BTCOEX_CTRL2_GPIO_OBS_SEL 0x00800000 +#define AR_BTCOEX_CTRL2_GPIO_OBS_SEL_S 23 +#define AR_BTCOEX_CTRL2_MAC_BB_OBS_SEL 0x01000000 +#define AR_BTCOEX_CTRL2_MAC_BB_OBS_SEL_S 24 +#define AR_BTCOEX_CTRL2_DESC_BASED_TXPWR_ENABLE 0x02000000 +#define AR_BTCOEX_CTRL2_DESC_BASED_TXPWR_ENABLE_S 25 + +#define AR_BTCOEX_CTRL_SPDT_ENABLE 0x00000001 +#define AR_BTCOEX_CTRL_SPDT_ENABLE_S 0 +#define AR_BTCOEX_CTRL_BT_OWN_SPDT_CTRL 0x00000002 +#define AR_BTCOEX_CTRL_BT_OWN_SPDT_CTRL_S 1 +#define AR_BTCOEX_CTRL_USE_LATCHED_BT_ANT 0x00000004 +#define AR_BTCOEX_CTRL_USE_LATCHED_BT_ANT_S 2 +#define AR_GLB_WLAN_UART_INTF_EN 0x00020000 +#define AR_GLB_WLAN_UART_INTF_EN_S 17 +#define AR_GLB_DS_JTAG_DISABLE 0x00040000 +#define AR_GLB_DS_JTAG_DISABLE_S 18 + +#define AR_BTCOEX_RC 0x194c +#define AR_BTCOEX_MAX_RFGAIN(_x) (0x1950 + ((_x) << 2)) +#define AR_BTCOEX_DBG 0x1a50 +#define AR_MCI_LAST_HW_MSG_HDR 0x1a54 +#define AR_MCI_LAST_HW_MSG_BDY 0x1a58 + +#define AR_MCI_SCHD_TABLE_2 0x1a5c +#define AR_MCI_SCHD_TABLE_2_MEM_BASED 0x00000001 +#define AR_MCI_SCHD_TABLE_2_MEM_BASED_S 0 +#define AR_MCI_SCHD_TABLE_2_HW_BASED 0x00000002 +#define AR_MCI_SCHD_TABLE_2_HW_BASED_S 1 + +#define AR_BTCOEX_CTRL3 0x1a60 +#define AR_BTCOEX_CTRL3_CONT_INFO_TIMEOUT 0x00000fff +#define AR_BTCOEX_CTRL3_CONT_INFO_TIMEOUT_S 0 + #endif -- cgit v1.2.3 From 93d36e9939c2c3e90a060c1452844da0d292c5e8 Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Wed, 30 Nov 2011 10:41:14 +0530 Subject: ath9k_hw: add GPIO output MUX related macros Cc: Wilson Tsao Cc: Senthil Balasubramanian Signed-off-by: Rajkumar Manoharan Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/hw.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index 4f786cb3020a..cd43d5904567 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -126,6 +126,16 @@ #define AR_GPIO_OUTPUT_MUX_AS_RX_CLEAR_EXTERNAL 4 #define AR_GPIO_OUTPUT_MUX_AS_MAC_NETWORK_LED 5 #define AR_GPIO_OUTPUT_MUX_AS_MAC_POWER_LED 6 +#define AR_GPIO_OUTPUT_MUX_AS_MCI_WLAN_DATA 0x16 +#define AR_GPIO_OUTPUT_MUX_AS_MCI_WLAN_CLK 0x17 +#define AR_GPIO_OUTPUT_MUX_AS_MCI_BT_DATA 0x18 +#define AR_GPIO_OUTPUT_MUX_AS_MCI_BT_CLK 0x19 +#define AR_GPIO_OUTPUT_MUX_AS_WL_IN_TX 0x14 +#define AR_GPIO_OUTPUT_MUX_AS_WL_IN_RX 0x13 +#define AR_GPIO_OUTPUT_MUX_AS_BT_IN_TX 9 +#define AR_GPIO_OUTPUT_MUX_AS_BT_IN_RX 8 +#define AR_GPIO_OUTPUT_MUX_AS_RUCKUS_STROBE 0x1d +#define AR_GPIO_OUTPUT_MUX_AS_RUCKUS_DATA 0x1e #define AR_GPIOD_MASK 0x00001FFF #define AR_GPIO_BIT(_gpio) (1 << (_gpio)) -- cgit v1.2.3 From 6af24c49a3c4fb9755606d15e3699a483570afdb Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Wed, 30 Nov 2011 10:41:15 +0530 Subject: ath9k_hw: Add MCI h/w specific structure Cc: Wilson Tsao Cc: Senthil Balasubramanian Signed-off-by: Rajkumar Manoharan Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/btcoex.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/btcoex.h b/drivers/net/wireless/ath/ath9k/btcoex.h index d5e5db1faad9..278361c867ca 100644 --- a/drivers/net/wireless/ath/ath9k/btcoex.h +++ b/drivers/net/wireless/ath/ath9k/btcoex.h @@ -54,8 +54,39 @@ enum ath_btcoex_scheme { ATH_BTCOEX_CFG_MCI, }; +struct ath9k_hw_mci { + u32 raw_intr; + u32 rx_msg_intr; + u32 cont_status; + u32 gpm_addr; + u32 gpm_len; + u32 gpm_idx; + u32 sched_addr; + u32 wlan_channels[4]; + u32 wlan_cal_seq; + u32 wlan_cal_done; + u32 config; + u8 *gpm_buf; + u8 *sched_buf; + bool ready; + bool update_2g5g; + bool is_2g; + bool query_bt; + bool unhalt_bt_gpm; /* need send UNHALT */ + bool halted_bt_gpm; /* HALT sent */ + bool need_flush_btinfo; + bool bt_version_known; + bool wlan_channels_update; + u8 wlan_ver_major; + u8 wlan_ver_minor; + u8 bt_ver_major; + u8 bt_ver_minor; + u8 bt_state; +}; + struct ath_btcoex_hw { enum ath_btcoex_scheme scheme; + struct ath9k_hw_mci mci; bool enabled; u8 wlanactive_gpio; u8 btactive_gpio; -- cgit v1.2.3 From 16659f6ad86b0e73ef0409a87b74170fbaeda344 Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Wed, 30 Nov 2011 10:41:16 +0530 Subject: ath9k_hw: initialize MCI parameters these parameter will be utilized and modified in the MCI hardware codes state machine Cc: Wilson Tsao Cc: Senthil Balasubramanian Signed-off-by: Rajkumar Manoharan Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/init.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index e046de94836a..34b922bbe65d 100644 --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c @@ -408,6 +408,7 @@ fail: static int ath9k_init_btcoex(struct ath_softc *sc) { struct ath_txq *txq; + struct ath_hw *ah = sc->sc_ah; int r; switch (sc->sc_ah->btcoex_hw.scheme) { @@ -426,6 +427,27 @@ static int ath9k_init_btcoex(struct ath_softc *sc) sc->btcoex.bt_stomp_type = ATH_BTCOEX_STOMP_LOW; sc->btcoex.duty_cycle = ATH_BTCOEX_DEF_DUTY_CYCLE; INIT_LIST_HEAD(&sc->btcoex.mci.info); + if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_MCI) { + ah->btcoex_hw.mci.ready = false; + ah->btcoex_hw.mci.bt_state = 0; + ah->btcoex_hw.mci.bt_ver_major = 3; + ah->btcoex_hw.mci.bt_ver_minor = 0; + ah->btcoex_hw.mci.bt_version_known = false; + ah->btcoex_hw.mci.update_2g5g = true; + ah->btcoex_hw.mci.is_2g = true; + ah->btcoex_hw.mci.wlan_channels_update = false; + ah->btcoex_hw.mci.wlan_channels[0] = 0x00000000; + ah->btcoex_hw.mci.wlan_channels[1] = 0xffffffff; + ah->btcoex_hw.mci.wlan_channels[2] = 0xffffffff; + ah->btcoex_hw.mci.wlan_channels[3] = 0x7fffffff; + ah->btcoex_hw.mci.query_bt = true; + ah->btcoex_hw.mci.unhalt_bt_gpm = true; + ah->btcoex_hw.mci.halted_bt_gpm = false; + ah->btcoex_hw.mci.need_flush_btinfo = false; + ah->btcoex_hw.mci.wlan_cal_seq = 0; + ah->btcoex_hw.mci.wlan_cal_done = 0; + ah->btcoex_hw.mci.config = 0x2201; + } break; default: WARN_ON(1); -- cgit v1.2.3 From bbefb8715298ce8c6a1da03da16efaa6f1ff4237 Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Wed, 30 Nov 2011 10:41:17 +0530 Subject: ath9k_hw: Add MCI h/w code and state machine Cc: Wilson Tsao Cc: Senthil Balasubramanian Signed-off-by: Rajkumar Manoharan Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/Makefile | 3 +- drivers/net/wireless/ath/ath9k/ar9003_mci.c | 1464 +++++++++++++++++++++++++++ drivers/net/wireless/ath/ath9k/hw.h | 26 + 3 files changed, 1492 insertions(+), 1 deletion(-) create mode 100644 drivers/net/wireless/ath/ath9k/ar9003_mci.c (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/Makefile b/drivers/net/wireless/ath/ath9k/Makefile index 49d3f25f509d..390797db5273 100644 --- a/drivers/net/wireless/ath/ath9k/Makefile +++ b/drivers/net/wireless/ath/ath9k/Makefile @@ -34,7 +34,8 @@ ath9k_hw-y:= \ ar9002_mac.o \ ar9003_mac.o \ ar9003_eeprom.o \ - ar9003_paprd.o + ar9003_paprd.o \ + ar9003_mci.o obj-$(CONFIG_ATH9K_HW) += ath9k_hw.o diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.c b/drivers/net/wireless/ath/ath9k/ar9003_mci.c new file mode 100644 index 000000000000..8599822dc83f --- /dev/null +++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.c @@ -0,0 +1,1464 @@ +/* + * Copyright (c) 2008-2011 Atheros Communications Inc. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include "hw.h" +#include "ar9003_phy.h" +#include "ar9003_mci.h" + +static void ar9003_mci_reset_req_wakeup(struct ath_hw *ah) +{ + if (!AR_SREV_9462_20(ah)) + return; + + REG_RMW_FIELD(ah, AR_MCI_COMMAND2, + AR_MCI_COMMAND2_RESET_REQ_WAKEUP, 1); + udelay(1); + REG_RMW_FIELD(ah, AR_MCI_COMMAND2, + AR_MCI_COMMAND2_RESET_REQ_WAKEUP, 0); +} + +static int ar9003_mci_wait_for_interrupt(struct ath_hw *ah, u32 address, + u32 bit_position, int time_out) +{ + struct ath_common *common = ath9k_hw_common(ah); + + while (time_out) { + + if (REG_READ(ah, address) & bit_position) { + + REG_WRITE(ah, address, bit_position); + + if (address == AR_MCI_INTERRUPT_RX_MSG_RAW) { + + if (bit_position & + AR_MCI_INTERRUPT_RX_MSG_REQ_WAKE) + ar9003_mci_reset_req_wakeup(ah); + + if (bit_position & + (AR_MCI_INTERRUPT_RX_MSG_SYS_SLEEPING | + AR_MCI_INTERRUPT_RX_MSG_SYS_WAKING)) + REG_WRITE(ah, AR_MCI_INTERRUPT_RAW, + AR_MCI_INTERRUPT_REMOTE_SLEEP_UPDATE); + + REG_WRITE(ah, AR_MCI_INTERRUPT_RAW, + AR_MCI_INTERRUPT_RX_MSG); + } + break; + } + + udelay(10); + time_out -= 10; + + if (time_out < 0) + break; + } + + if (time_out <= 0) { + ath_dbg(common, ATH_DBG_MCI, + "MCI Wait for Reg 0x%08x = 0x%08x timeout.\n", + address, bit_position); + ath_dbg(common, ATH_DBG_MCI, + "MCI INT_RAW = 0x%08x, RX_MSG_RAW = 0x%08x", + REG_READ(ah, AR_MCI_INTERRUPT_RAW), + REG_READ(ah, AR_MCI_INTERRUPT_RX_MSG_RAW)); + time_out = 0; + } + + return time_out; +} + +void ar9003_mci_remote_reset(struct ath_hw *ah, bool wait_done) +{ + u32 payload[4] = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffff00}; + + ar9003_mci_send_message(ah, MCI_REMOTE_RESET, 0, payload, 16, + wait_done, false); + udelay(5); +} + +void ar9003_mci_send_lna_transfer(struct ath_hw *ah, bool wait_done) +{ + u32 payload = 0x00000000; + + ar9003_mci_send_message(ah, MCI_LNA_TRANS, 0, &payload, 1, + wait_done, false); +} + +static void ar9003_mci_send_req_wake(struct ath_hw *ah, bool wait_done) +{ + ar9003_mci_send_message(ah, MCI_REQ_WAKE, MCI_FLAG_DISABLE_TIMESTAMP, + NULL, 0, wait_done, false); + udelay(5); +} + +void ar9003_mci_send_sys_waking(struct ath_hw *ah, bool wait_done) +{ + ar9003_mci_send_message(ah, MCI_SYS_WAKING, MCI_FLAG_DISABLE_TIMESTAMP, + NULL, 0, wait_done, false); +} + +static void ar9003_mci_send_lna_take(struct ath_hw *ah, bool wait_done) +{ + u32 payload = 0x70000000; + + ar9003_mci_send_message(ah, MCI_LNA_TAKE, 0, &payload, 1, + wait_done, false); +} + +static void ar9003_mci_send_sys_sleeping(struct ath_hw *ah, bool wait_done) +{ + ar9003_mci_send_message(ah, MCI_SYS_SLEEPING, + MCI_FLAG_DISABLE_TIMESTAMP, + NULL, 0, wait_done, false); +} + +static void ar9003_mci_send_coex_version_query(struct ath_hw *ah, + bool wait_done) +{ + struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; + u32 payload[4] = {0, 0, 0, 0}; + + if (!mci->bt_version_known && + (mci->bt_state != MCI_BT_SLEEP)) { + ath_dbg(common, ATH_DBG_MCI, "MCI Send Coex version query\n"); + MCI_GPM_SET_TYPE_OPCODE(payload, + MCI_GPM_COEX_AGENT, MCI_GPM_COEX_VERSION_QUERY); + ar9003_mci_send_message(ah, MCI_GPM, 0, payload, 16, + wait_done, true); + } +} + +static void ar9003_mci_send_coex_version_response(struct ath_hw *ah, + bool wait_done) +{ + struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; + u32 payload[4] = {0, 0, 0, 0}; + + ath_dbg(common, ATH_DBG_MCI, "MCI Send Coex version response\n"); + MCI_GPM_SET_TYPE_OPCODE(payload, MCI_GPM_COEX_AGENT, + MCI_GPM_COEX_VERSION_RESPONSE); + *(((u8 *)payload) + MCI_GPM_COEX_B_MAJOR_VERSION) = + mci->wlan_ver_major; + *(((u8 *)payload) + MCI_GPM_COEX_B_MINOR_VERSION) = + mci->wlan_ver_minor; + ar9003_mci_send_message(ah, MCI_GPM, 0, payload, 16, wait_done, true); +} + +static void ar9003_mci_send_coex_wlan_channels(struct ath_hw *ah, + bool wait_done) +{ + struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; + u32 *payload = &mci->wlan_channels[0]; + + if ((mci->wlan_channels_update == true) && + (mci->bt_state != MCI_BT_SLEEP)) { + MCI_GPM_SET_TYPE_OPCODE(payload, + MCI_GPM_COEX_AGENT, MCI_GPM_COEX_WLAN_CHANNELS); + ar9003_mci_send_message(ah, MCI_GPM, 0, payload, 16, + wait_done, true); + MCI_GPM_SET_TYPE_OPCODE(payload, 0xff, 0xff); + } +} + +static void ar9003_mci_send_coex_bt_status_query(struct ath_hw *ah, + bool wait_done, u8 query_type) +{ + struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; + u32 payload[4] = {0, 0, 0, 0}; + bool query_btinfo = !!(query_type & (MCI_GPM_COEX_QUERY_BT_ALL_INFO | + MCI_GPM_COEX_QUERY_BT_TOPOLOGY)); + + if (mci->bt_state != MCI_BT_SLEEP) { + + ath_dbg(common, ATH_DBG_MCI, + "MCI Send Coex BT Status Query 0x%02X\n", query_type); + + MCI_GPM_SET_TYPE_OPCODE(payload, + MCI_GPM_COEX_AGENT, MCI_GPM_COEX_STATUS_QUERY); + + *(((u8 *)payload) + MCI_GPM_COEX_B_BT_BITMAP) = query_type; + /* + * If bt_status_query message is not sent successfully, + * then need_flush_btinfo should be set again. + */ + if (!ar9003_mci_send_message(ah, MCI_GPM, 0, payload, 16, + wait_done, true)) { + if (query_btinfo) { + mci->need_flush_btinfo = true; + + ath_dbg(common, ATH_DBG_MCI, + "MCI send bt_status_query fail, " + "set flush flag again\n"); + } + } + + if (query_btinfo) + mci->query_bt = false; + } +} + +void ar9003_mci_send_coex_halt_bt_gpm(struct ath_hw *ah, bool halt, + bool wait_done) +{ + struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; + u32 payload[4] = {0, 0, 0, 0}; + + ath_dbg(common, ATH_DBG_MCI, "MCI Send Coex %s BT GPM.\n", + (halt) ? "halt" : "unhalt"); + + MCI_GPM_SET_TYPE_OPCODE(payload, + MCI_GPM_COEX_AGENT, MCI_GPM_COEX_HALT_BT_GPM); + + if (halt) { + mci->query_bt = true; + /* Send next unhalt no matter halt sent or not */ + mci->unhalt_bt_gpm = true; + mci->need_flush_btinfo = true; + *(((u8 *)payload) + MCI_GPM_COEX_B_HALT_STATE) = + MCI_GPM_COEX_BT_GPM_HALT; + } else + *(((u8 *)payload) + MCI_GPM_COEX_B_HALT_STATE) = + MCI_GPM_COEX_BT_GPM_UNHALT; + + ar9003_mci_send_message(ah, MCI_GPM, 0, payload, 16, wait_done, true); +} + + +static void ar9003_mci_prep_interface(struct ath_hw *ah) +{ + struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; + u32 saved_mci_int_en; + u32 mci_timeout = 150; + + mci->bt_state = MCI_BT_SLEEP; + saved_mci_int_en = REG_READ(ah, AR_MCI_INTERRUPT_EN); + + REG_WRITE(ah, AR_MCI_INTERRUPT_EN, 0); + REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_RAW, + REG_READ(ah, AR_MCI_INTERRUPT_RX_MSG_RAW)); + REG_WRITE(ah, AR_MCI_INTERRUPT_RAW, + REG_READ(ah, AR_MCI_INTERRUPT_RAW)); + + /* Remote Reset */ + ath_dbg(common, ATH_DBG_MCI, "MCI Reset sequence start\n"); + ath_dbg(common, ATH_DBG_MCI, "MCI send REMOTE_RESET\n"); + ar9003_mci_remote_reset(ah, true); + + /* + * This delay is required for the reset delay worst case value 255 in + * MCI_COMMAND2 register + */ + + if (AR_SREV_9462_10(ah)) + udelay(252); + + ath_dbg(common, ATH_DBG_MCI, "MCI Send REQ_WAKE to remoter(BT)\n"); + ar9003_mci_send_req_wake(ah, true); + + if (ar9003_mci_wait_for_interrupt(ah, AR_MCI_INTERRUPT_RX_MSG_RAW, + AR_MCI_INTERRUPT_RX_MSG_SYS_WAKING, 500)) { + + ath_dbg(common, ATH_DBG_MCI, + "MCI SYS_WAKING from remote(BT)\n"); + mci->bt_state = MCI_BT_AWAKE; + + if (AR_SREV_9462_10(ah)) + udelay(10); + /* + * we don't need to send more remote_reset at this moment. + * If BT receive first remote_reset, then BT HW will + * be cleaned up and will be able to receive req_wake + * and BT HW will respond sys_waking. + * In this case, WLAN will receive BT's HW sys_waking. + * Otherwise, if BT SW missed initial remote_reset, + * that remote_reset will still clean up BT MCI RX, + * and the req_wake will wake BT up, + * and BT SW will respond this req_wake with a remote_reset and + * sys_waking. In this case, WLAN will receive BT's SW + * sys_waking. In either case, BT's RX is cleaned up. So we + * don't need to reply BT's remote_reset now, if any. + * Similarly, if in any case, WLAN can receive BT's sys_waking, + * that means WLAN's RX is also fine. + */ + + /* Send SYS_WAKING to BT */ + + ath_dbg(common, ATH_DBG_MCI, + "MCI send SW SYS_WAKING to remote BT\n"); + + ar9003_mci_send_sys_waking(ah, true); + udelay(10); + + /* + * Set BT priority interrupt value to be 0xff to + * avoid having too many BT PRIORITY interrupts. + */ + + REG_WRITE(ah, AR_MCI_BT_PRI0, 0xFFFFFFFF); + REG_WRITE(ah, AR_MCI_BT_PRI1, 0xFFFFFFFF); + REG_WRITE(ah, AR_MCI_BT_PRI2, 0xFFFFFFFF); + REG_WRITE(ah, AR_MCI_BT_PRI3, 0xFFFFFFFF); + REG_WRITE(ah, AR_MCI_BT_PRI, 0X000000FF); + + /* + * A contention reset will be received after send out + * sys_waking. Also BT priority interrupt bits will be set. + * Clear those bits before the next step. + */ + + REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_RAW, + AR_MCI_INTERRUPT_RX_MSG_CONT_RST); + REG_WRITE(ah, AR_MCI_INTERRUPT_RAW, + AR_MCI_INTERRUPT_BT_PRI); + + if (AR_SREV_9462_10(ah) || mci->is_2g) { + /* Send LNA_TRANS */ + ath_dbg(common, ATH_DBG_MCI, + "MCI send LNA_TRANS to BT\n"); + ar9003_mci_send_lna_transfer(ah, true); + udelay(5); + } + + if (AR_SREV_9462_10(ah) || (mci->is_2g && + !mci->update_2g5g)) { + if (ar9003_mci_wait_for_interrupt(ah, + AR_MCI_INTERRUPT_RX_MSG_RAW, + AR_MCI_INTERRUPT_RX_MSG_LNA_INFO, + mci_timeout)) + ath_dbg(common, ATH_DBG_MCI, + "MCI WLAN has control over the LNA & " + "BT obeys it\n"); + else + ath_dbg(common, ATH_DBG_MCI, + "MCI BT didn't respond to" + "LNA_TRANS\n"); + } + + if (AR_SREV_9462_10(ah)) { + /* Send another remote_reset to deassert BT clk_req. */ + ath_dbg(common, ATH_DBG_MCI, + "MCI another remote_reset to " + "deassert clk_req\n"); + ar9003_mci_remote_reset(ah, true); + udelay(252); + } + } + + /* Clear the extra redundant SYS_WAKING from BT */ + if ((mci->bt_state == MCI_BT_AWAKE) && + (REG_READ_FIELD(ah, AR_MCI_INTERRUPT_RX_MSG_RAW, + AR_MCI_INTERRUPT_RX_MSG_SYS_WAKING)) && + (REG_READ_FIELD(ah, AR_MCI_INTERRUPT_RX_MSG_RAW, + AR_MCI_INTERRUPT_RX_MSG_SYS_SLEEPING) == 0)) { + + REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_RAW, + AR_MCI_INTERRUPT_RX_MSG_SYS_WAKING); + REG_WRITE(ah, AR_MCI_INTERRUPT_RAW, + AR_MCI_INTERRUPT_REMOTE_SLEEP_UPDATE); + } + + REG_WRITE(ah, AR_MCI_INTERRUPT_EN, saved_mci_int_en); +} + +void ar9003_mci_disable_interrupt(struct ath_hw *ah) +{ + REG_WRITE(ah, AR_MCI_INTERRUPT_EN, 0); + REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_EN, 0); +} + +void ar9003_mci_enable_interrupt(struct ath_hw *ah) +{ + + REG_WRITE(ah, AR_MCI_INTERRUPT_EN, AR_MCI_INTERRUPT_DEFAULT); + REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_EN, + AR_MCI_INTERRUPT_RX_MSG_DEFAULT); +} + +bool ar9003_mci_check_int(struct ath_hw *ah, u32 ints) +{ + u32 intr; + + intr = REG_READ(ah, AR_MCI_INTERRUPT_RX_MSG_RAW); + return ((intr & ints) == ints); +} + +void ar9003_mci_get_interrupt(struct ath_hw *ah, u32 *raw_intr, + u32 *rx_msg_intr) +{ + struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; + *raw_intr = mci->raw_intr; + *rx_msg_intr = mci->rx_msg_intr; + + /* Clean int bits after the values are read. */ + mci->raw_intr = 0; + mci->rx_msg_intr = 0; +} +EXPORT_SYMBOL(ar9003_mci_get_interrupt); + +void ar9003_mci_2g5g_changed(struct ath_hw *ah, bool is_2g) +{ + struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; + + if (!mci->update_2g5g && + (mci->is_2g != is_2g)) + mci->update_2g5g = true; + + mci->is_2g = is_2g; +} + +static bool ar9003_mci_is_gpm_valid(struct ath_hw *ah, u32 msg_index) +{ + struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; + u32 *payload; + u32 recv_type, offset; + + if (msg_index == MCI_GPM_INVALID) + return false; + + offset = msg_index << 4; + + payload = (u32 *)(mci->gpm_buf + offset); + recv_type = MCI_GPM_TYPE(payload); + + if (recv_type == MCI_GPM_RSVD_PATTERN) { + ath_dbg(common, ATH_DBG_MCI, "MCI Skip RSVD GPM\n"); + return false; + } + + return true; +} + +static void ar9003_mci_observation_set_up(struct ath_hw *ah) +{ + struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; + if (mci->config & ATH_MCI_CONFIG_MCI_OBS_MCI) { + + ath9k_hw_cfg_output(ah, 3, + AR_GPIO_OUTPUT_MUX_AS_MCI_WLAN_DATA); + ath9k_hw_cfg_output(ah, 2, AR_GPIO_OUTPUT_MUX_AS_MCI_WLAN_CLK); + ath9k_hw_cfg_output(ah, 1, AR_GPIO_OUTPUT_MUX_AS_MCI_BT_DATA); + ath9k_hw_cfg_output(ah, 0, AR_GPIO_OUTPUT_MUX_AS_MCI_BT_CLK); + + } else if (mci->config & ATH_MCI_CONFIG_MCI_OBS_TXRX) { + + ath9k_hw_cfg_output(ah, 3, AR_GPIO_OUTPUT_MUX_AS_WL_IN_TX); + ath9k_hw_cfg_output(ah, 2, AR_GPIO_OUTPUT_MUX_AS_WL_IN_RX); + ath9k_hw_cfg_output(ah, 1, AR_GPIO_OUTPUT_MUX_AS_BT_IN_TX); + ath9k_hw_cfg_output(ah, 0, AR_GPIO_OUTPUT_MUX_AS_BT_IN_RX); + ath9k_hw_cfg_output(ah, 5, AR_GPIO_OUTPUT_MUX_AS_OUTPUT); + + } else if (mci->config & ATH_MCI_CONFIG_MCI_OBS_BT) { + + ath9k_hw_cfg_output(ah, 3, AR_GPIO_OUTPUT_MUX_AS_BT_IN_TX); + ath9k_hw_cfg_output(ah, 2, AR_GPIO_OUTPUT_MUX_AS_BT_IN_RX); + ath9k_hw_cfg_output(ah, 1, AR_GPIO_OUTPUT_MUX_AS_MCI_BT_DATA); + ath9k_hw_cfg_output(ah, 0, AR_GPIO_OUTPUT_MUX_AS_MCI_BT_CLK); + + } else + return; + + REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, AR_GPIO_JTAG_DISABLE); + + if (AR_SREV_9462_20_OR_LATER(ah)) { + REG_RMW_FIELD(ah, AR_PHY_GLB_CONTROL, + AR_GLB_DS_JTAG_DISABLE, 1); + REG_RMW_FIELD(ah, AR_PHY_GLB_CONTROL, + AR_GLB_WLAN_UART_INTF_EN, 0); + REG_SET_BIT(ah, AR_GLB_GPIO_CONTROL, + ATH_MCI_CONFIG_MCI_OBS_GPIO); + } + + REG_RMW_FIELD(ah, AR_BTCOEX_CTRL2, AR_BTCOEX_CTRL2_GPIO_OBS_SEL, 0); + REG_RMW_FIELD(ah, AR_BTCOEX_CTRL2, AR_BTCOEX_CTRL2_MAC_BB_OBS_SEL, 1); + REG_WRITE(ah, AR_OBS, 0x4b); + REG_RMW_FIELD(ah, AR_DIAG_SW, AR_DIAG_OBS_PT_SEL1, 0x03); + REG_RMW_FIELD(ah, AR_DIAG_SW, AR_DIAG_OBS_PT_SEL2, 0x01); + REG_RMW_FIELD(ah, AR_MACMISC, AR_MACMISC_MISC_OBS_BUS_LSB, 0x02); + REG_RMW_FIELD(ah, AR_MACMISC, AR_MACMISC_MISC_OBS_BUS_MSB, 0x03); + REG_RMW_FIELD(ah, AR_PHY_TEST_CTL_STATUS, + AR_PHY_TEST_CTL_DEBUGPORT_SEL, 0x07); +} + +static bool ar9003_mci_send_coex_bt_flags(struct ath_hw *ah, bool wait_done, + u8 opcode, u32 bt_flags) +{ + struct ath_common *common = ath9k_hw_common(ah); + u32 pld[4] = {0, 0, 0, 0}; + + MCI_GPM_SET_TYPE_OPCODE(pld, + MCI_GPM_COEX_AGENT, MCI_GPM_COEX_BT_UPDATE_FLAGS); + + *(((u8 *)pld) + MCI_GPM_COEX_B_BT_FLAGS_OP) = opcode; + *(((u8 *)pld) + MCI_GPM_COEX_W_BT_FLAGS + 0) = bt_flags & 0xFF; + *(((u8 *)pld) + MCI_GPM_COEX_W_BT_FLAGS + 1) = (bt_flags >> 8) & 0xFF; + *(((u8 *)pld) + MCI_GPM_COEX_W_BT_FLAGS + 2) = (bt_flags >> 16) & 0xFF; + *(((u8 *)pld) + MCI_GPM_COEX_W_BT_FLAGS + 3) = (bt_flags >> 24) & 0xFF; + + ath_dbg(common, ATH_DBG_MCI, + "MCI BT_MCI_FLAGS: Send Coex BT Update Flags %s 0x%08x\n", + (opcode == MCI_GPM_COEX_BT_FLAGS_READ) ? "READ" : + ((opcode == MCI_GPM_COEX_BT_FLAGS_SET) ? "SET" : "CLEAR"), + bt_flags); + + return ar9003_mci_send_message(ah, MCI_GPM, 0, pld, 16, + wait_done, true); +} + +void ar9003_mci_reset(struct ath_hw *ah, bool en_int, bool is_2g, + bool is_full_sleep) +{ + struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; + u32 regval, thresh; + + ath_dbg(common, ATH_DBG_MCI, "MCI full_sleep = %d, is_2g = %d\n", + is_full_sleep, is_2g); + + /* + * GPM buffer and scheduling message buffer are not allocated + */ + + if (!mci->gpm_addr && !mci->sched_addr) { + ath_dbg(common, ATH_DBG_MCI, + "MCI GPM and schedule buffers are not allocated"); + return; + } + + if (REG_READ(ah, AR_BTCOEX_CTRL) == 0xdeadbeef) { + ath_dbg(common, ATH_DBG_MCI, + "MCI it's deadbeef, quit mci_reset\n"); + return; + } + + /* Program MCI DMA related registers */ + REG_WRITE(ah, AR_MCI_GPM_0, mci->gpm_addr); + REG_WRITE(ah, AR_MCI_GPM_1, mci->gpm_len); + REG_WRITE(ah, AR_MCI_SCHD_TABLE_0, mci->sched_addr); + + /* + * To avoid MCI state machine be affected by incoming remote MCI msgs, + * MCI mode will be enabled later, right before reset the MCI TX and RX. + */ + + regval = SM(1, AR_BTCOEX_CTRL_AR9462_MODE) | + SM(1, AR_BTCOEX_CTRL_WBTIMER_EN) | + SM(1, AR_BTCOEX_CTRL_PA_SHARED) | + SM(1, AR_BTCOEX_CTRL_LNA_SHARED) | + SM(2, AR_BTCOEX_CTRL_NUM_ANTENNAS) | + SM(3, AR_BTCOEX_CTRL_RX_CHAIN_MASK) | + SM(0, AR_BTCOEX_CTRL_1_CHAIN_ACK) | + SM(0, AR_BTCOEX_CTRL_1_CHAIN_BCN) | + SM(0, AR_BTCOEX_CTRL_ONE_STEP_LOOK_AHEAD_EN); + + if (is_2g && (AR_SREV_9462_20(ah)) && + !(mci->config & ATH_MCI_CONFIG_DISABLE_OSLA)) { + + regval |= SM(1, AR_BTCOEX_CTRL_ONE_STEP_LOOK_AHEAD_EN); + ath_dbg(common, ATH_DBG_MCI, + "MCI sched one step look ahead\n"); + + if (!(mci->config & + ATH_MCI_CONFIG_DISABLE_AGGR_THRESH)) { + + thresh = MS(mci->config, + ATH_MCI_CONFIG_AGGR_THRESH); + thresh &= 7; + regval |= SM(1, + AR_BTCOEX_CTRL_TIME_TO_NEXT_BT_THRESH_EN); + regval |= SM(thresh, AR_BTCOEX_CTRL_AGGR_THRESH); + + REG_RMW_FIELD(ah, AR_MCI_SCHD_TABLE_2, + AR_MCI_SCHD_TABLE_2_HW_BASED, 1); + REG_RMW_FIELD(ah, AR_MCI_SCHD_TABLE_2, + AR_MCI_SCHD_TABLE_2_MEM_BASED, 1); + + } else + ath_dbg(common, ATH_DBG_MCI, + "MCI sched aggr thresh: off\n"); + } else + ath_dbg(common, ATH_DBG_MCI, + "MCI SCHED one step look ahead off\n"); + + if (AR_SREV_9462_10(ah)) + regval |= SM(1, AR_BTCOEX_CTRL_SPDT_ENABLE_10); + + REG_WRITE(ah, AR_BTCOEX_CTRL, regval); + + if (AR_SREV_9462_20(ah)) { + REG_SET_BIT(ah, AR_PHY_GLB_CONTROL, + AR_BTCOEX_CTRL_SPDT_ENABLE); + REG_RMW_FIELD(ah, AR_BTCOEX_CTRL3, + AR_BTCOEX_CTRL3_CONT_INFO_TIMEOUT, 20); + } + + REG_RMW_FIELD(ah, AR_BTCOEX_CTRL2, AR_BTCOEX_CTRL2_RX_DEWEIGHT, 1); + REG_RMW_FIELD(ah, AR_PCU_MISC, AR_PCU_BT_ANT_PREVENT_RX, 0); + + thresh = MS(mci->config, ATH_MCI_CONFIG_CLK_DIV); + REG_RMW_FIELD(ah, AR_MCI_TX_CTRL, AR_MCI_TX_CTRL_CLK_DIV, thresh); + REG_SET_BIT(ah, AR_BTCOEX_CTRL, AR_BTCOEX_CTRL_MCI_MODE_EN); + + /* Resetting the Rx and Tx paths of MCI */ + regval = REG_READ(ah, AR_MCI_COMMAND2); + regval |= SM(1, AR_MCI_COMMAND2_RESET_TX); + REG_WRITE(ah, AR_MCI_COMMAND2, regval); + + udelay(1); + + regval &= ~SM(1, AR_MCI_COMMAND2_RESET_TX); + REG_WRITE(ah, AR_MCI_COMMAND2, regval); + + if (is_full_sleep) { + ar9003_mci_mute_bt(ah); + udelay(100); + } + + regval |= SM(1, AR_MCI_COMMAND2_RESET_RX); + REG_WRITE(ah, AR_MCI_COMMAND2, regval); + udelay(1); + regval &= ~SM(1, AR_MCI_COMMAND2_RESET_RX); + REG_WRITE(ah, AR_MCI_COMMAND2, regval); + + ar9003_mci_state(ah, MCI_STATE_INIT_GPM_OFFSET, NULL); + REG_WRITE(ah, AR_MCI_MSG_ATTRIBUTES_TABLE, + (SM(0xe801, AR_MCI_MSG_ATTRIBUTES_TABLE_INVALID_HDR) | + SM(0x0000, AR_MCI_MSG_ATTRIBUTES_TABLE_CHECKSUM))); + + REG_CLR_BIT(ah, AR_MCI_TX_CTRL, + AR_MCI_TX_CTRL_DISABLE_LNA_UPDATE); + + if (AR_SREV_9462_20_OR_LATER(ah)) + ar9003_mci_observation_set_up(ah); + + mci->ready = true; + ar9003_mci_prep_interface(ah); + + if (en_int) + ar9003_mci_enable_interrupt(ah); +} + +void ar9003_mci_mute_bt(struct ath_hw *ah) +{ + struct ath_common *common = ath9k_hw_common(ah); + + /* disable all MCI messages */ + REG_WRITE(ah, AR_MCI_MSG_ATTRIBUTES_TABLE, 0xffff0000); + REG_WRITE(ah, AR_BTCOEX_WL_WEIGHTS0, 0xffffffff); + REG_WRITE(ah, AR_BTCOEX_WL_WEIGHTS1, 0xffffffff); + REG_WRITE(ah, AR_BTCOEX_WL_WEIGHTS2, 0xffffffff); + REG_WRITE(ah, AR_BTCOEX_WL_WEIGHTS3, 0xffffffff); + REG_SET_BIT(ah, AR_MCI_TX_CTRL, AR_MCI_TX_CTRL_DISABLE_LNA_UPDATE); + + /* wait pending HW messages to flush out */ + udelay(10); + + /* + * Send LNA_TAKE and SYS_SLEEPING when + * 1. reset not after resuming from full sleep + * 2. before reset MCI RX, to quiet BT and avoid MCI RX misalignment + */ + + ath_dbg(common, ATH_DBG_MCI, "MCI Send LNA take\n"); + ar9003_mci_send_lna_take(ah, true); + + udelay(5); + + ath_dbg(common, ATH_DBG_MCI, "MCI Send sys sleeping\n"); + ar9003_mci_send_sys_sleeping(ah, true); +} + +void ar9003_mci_sync_bt_state(struct ath_hw *ah) +{ + struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; + u32 cur_bt_state; + + cur_bt_state = ar9003_mci_state(ah, MCI_STATE_REMOTE_SLEEP, NULL); + + if (mci->bt_state != cur_bt_state) { + ath_dbg(common, ATH_DBG_MCI, + "MCI BT state mismatches. old: %d, new: %d\n", + mci->bt_state, cur_bt_state); + mci->bt_state = cur_bt_state; + } + + if (mci->bt_state != MCI_BT_SLEEP) { + + ar9003_mci_send_coex_version_query(ah, true); + ar9003_mci_send_coex_wlan_channels(ah, true); + + if (mci->unhalt_bt_gpm == true) { + ath_dbg(common, ATH_DBG_MCI, "MCI unhalt BT GPM"); + ar9003_mci_send_coex_halt_bt_gpm(ah, false, true); + } + } +} + +static void ar9003_mci_send_2g5g_status(struct ath_hw *ah, bool wait_done) +{ + struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; + u32 new_flags, to_set, to_clear; + + if (AR_SREV_9462_20(ah) && + mci->update_2g5g && + (mci->bt_state != MCI_BT_SLEEP)) { + + if (mci->is_2g) { + new_flags = MCI_2G_FLAGS; + to_clear = MCI_2G_FLAGS_CLEAR_MASK; + to_set = MCI_2G_FLAGS_SET_MASK; + } else { + new_flags = MCI_5G_FLAGS; + to_clear = MCI_5G_FLAGS_CLEAR_MASK; + to_set = MCI_5G_FLAGS_SET_MASK; + } + + ath_dbg(common, ATH_DBG_MCI, + "MCI BT_MCI_FLAGS: %s 0x%08x clr=0x%08x, set=0x%08x\n", + mci->is_2g ? "2G" : "5G", new_flags, to_clear, to_set); + + if (to_clear) + ar9003_mci_send_coex_bt_flags(ah, wait_done, + MCI_GPM_COEX_BT_FLAGS_CLEAR, to_clear); + + if (to_set) + ar9003_mci_send_coex_bt_flags(ah, wait_done, + MCI_GPM_COEX_BT_FLAGS_SET, to_set); + } + + if (AR_SREV_9462_10(ah) && (mci->bt_state != MCI_BT_SLEEP)) + mci->update_2g5g = false; +} + +static void ar9003_mci_queue_unsent_gpm(struct ath_hw *ah, u8 header, + u32 *payload, bool queue) +{ + struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; + u8 type, opcode; + + if (queue) { + + if (payload) + ath_dbg(common, ATH_DBG_MCI, + "MCI ERROR: Send fail: %02x: %02x %02x %02x\n", + header, + *(((u8 *)payload) + 4), + *(((u8 *)payload) + 5), + *(((u8 *)payload) + 6)); + else + ath_dbg(common, ATH_DBG_MCI, + "MCI ERROR: Send fail: %02x\n", header); + } + + /* check if the message is to be queued */ + if (header != MCI_GPM) + return; + + type = MCI_GPM_TYPE(payload); + opcode = MCI_GPM_OPCODE(payload); + + if (type != MCI_GPM_COEX_AGENT) + return; + + switch (opcode) { + case MCI_GPM_COEX_BT_UPDATE_FLAGS: + + if (AR_SREV_9462_10(ah)) + break; + + if (*(((u8 *)payload) + MCI_GPM_COEX_B_BT_FLAGS_OP) == + MCI_GPM_COEX_BT_FLAGS_READ) + break; + + mci->update_2g5g = queue; + + if (queue) + ath_dbg(common, ATH_DBG_MCI, + "MCI BT_MCI_FLAGS: 2G5G status %s.\n", + mci->is_2g ? "2G" : "5G"); + else + ath_dbg(common, ATH_DBG_MCI, + "MCI BT_MCI_FLAGS: 2G5G status %s.\n", + mci->is_2g ? "2G" : "5G"); + + break; + + case MCI_GPM_COEX_WLAN_CHANNELS: + + mci->wlan_channels_update = queue; + if (queue) + ath_dbg(common, ATH_DBG_MCI, + "MCI WLAN channel map \n"); + else + ath_dbg(common, ATH_DBG_MCI, + "MCI WLAN channel map \n"); + break; + + case MCI_GPM_COEX_HALT_BT_GPM: + + if (*(((u8 *)payload) + MCI_GPM_COEX_B_HALT_STATE) == + MCI_GPM_COEX_BT_GPM_UNHALT) { + + mci->unhalt_bt_gpm = queue; + + if (queue) + ath_dbg(common, ATH_DBG_MCI, + "MCI UNHALT BT GPM \n"); + else { + mci->halted_bt_gpm = false; + ath_dbg(common, ATH_DBG_MCI, + "MCI UNHALT BT GPM \n"); + } + } + + if (*(((u8 *)payload) + MCI_GPM_COEX_B_HALT_STATE) == + MCI_GPM_COEX_BT_GPM_HALT) { + + mci->halted_bt_gpm = !queue; + + if (queue) + ath_dbg(common, ATH_DBG_MCI, + "MCI HALT BT GPM \n"); + else + ath_dbg(common, ATH_DBG_MCI, + "MCI UNHALT BT GPM \n"); + } + + break; + default: + break; + } +} + +void ar9003_mci_2g5g_switch(struct ath_hw *ah, bool wait_done) +{ + struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; + + if (mci->update_2g5g) { + if (mci->is_2g) { + + ar9003_mci_send_2g5g_status(ah, true); + ath_dbg(common, ATH_DBG_MCI, "MCI Send LNA trans\n"); + ar9003_mci_send_lna_transfer(ah, true); + udelay(5); + + REG_CLR_BIT(ah, AR_MCI_TX_CTRL, + AR_MCI_TX_CTRL_DISABLE_LNA_UPDATE); + + if (AR_SREV_9462_20(ah)) { + REG_CLR_BIT(ah, AR_PHY_GLB_CONTROL, + AR_BTCOEX_CTRL_BT_OWN_SPDT_CTRL); + if (!(mci->config & + ATH_MCI_CONFIG_DISABLE_OSLA)) { + REG_SET_BIT(ah, AR_BTCOEX_CTRL, + AR_BTCOEX_CTRL_ONE_STEP_LOOK_AHEAD_EN); + } + } + } else { + ath_dbg(common, ATH_DBG_MCI, "MCI Send LNA take\n"); + ar9003_mci_send_lna_take(ah, true); + udelay(5); + + REG_SET_BIT(ah, AR_MCI_TX_CTRL, + AR_MCI_TX_CTRL_DISABLE_LNA_UPDATE); + + if (AR_SREV_9462_20(ah)) { + REG_SET_BIT(ah, AR_PHY_GLB_CONTROL, + AR_BTCOEX_CTRL_BT_OWN_SPDT_CTRL); + REG_CLR_BIT(ah, AR_BTCOEX_CTRL, + AR_BTCOEX_CTRL_ONE_STEP_LOOK_AHEAD_EN); + } + + ar9003_mci_send_2g5g_status(ah, true); + } + } +} + +bool ar9003_mci_send_message(struct ath_hw *ah, u8 header, u32 flag, + u32 *payload, u8 len, bool wait_done, + bool check_bt) +{ + struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; + bool msg_sent = false; + u32 regval; + u32 saved_mci_int_en; + int i; + + saved_mci_int_en = REG_READ(ah, AR_MCI_INTERRUPT_EN); + regval = REG_READ(ah, AR_BTCOEX_CTRL); + + if ((regval == 0xdeadbeef) || !(regval & AR_BTCOEX_CTRL_MCI_MODE_EN)) { + + ath_dbg(common, ATH_DBG_MCI, + "MCI Not sending 0x%x. MCI is not enabled. " + "full_sleep = %d\n", header, + (ah->power_mode == ATH9K_PM_FULL_SLEEP) ? 1 : 0); + + ar9003_mci_queue_unsent_gpm(ah, header, payload, true); + return false; + + } else if (check_bt && (mci->bt_state == MCI_BT_SLEEP)) { + + ath_dbg(common, ATH_DBG_MCI, + "MCI Don't send message 0x%x. BT is in sleep state\n", header); + + ar9003_mci_queue_unsent_gpm(ah, header, payload, true); + return false; + } + + if (wait_done) + REG_WRITE(ah, AR_MCI_INTERRUPT_EN, 0); + + /* Need to clear SW_MSG_DONE raw bit before wait */ + + REG_WRITE(ah, AR_MCI_INTERRUPT_RAW, + (AR_MCI_INTERRUPT_SW_MSG_DONE | + AR_MCI_INTERRUPT_MSG_FAIL_MASK)); + + if (payload) { + for (i = 0; (i * 4) < len; i++) + REG_WRITE(ah, (AR_MCI_TX_PAYLOAD0 + i * 4), + *(payload + i)); + } + + REG_WRITE(ah, AR_MCI_COMMAND0, + (SM((flag & MCI_FLAG_DISABLE_TIMESTAMP), + AR_MCI_COMMAND0_DISABLE_TIMESTAMP) | + SM(len, AR_MCI_COMMAND0_LEN) | + SM(header, AR_MCI_COMMAND0_HEADER))); + + if (wait_done && + !(ar9003_mci_wait_for_interrupt(ah, AR_MCI_INTERRUPT_RAW, + AR_MCI_INTERRUPT_SW_MSG_DONE, 500))) + ar9003_mci_queue_unsent_gpm(ah, header, payload, true); + else { + ar9003_mci_queue_unsent_gpm(ah, header, payload, false); + msg_sent = true; + } + + if (wait_done) + REG_WRITE(ah, AR_MCI_INTERRUPT_EN, saved_mci_int_en); + + return msg_sent; +} +EXPORT_SYMBOL(ar9003_mci_send_message); + +void ar9003_mci_setup(struct ath_hw *ah, u32 gpm_addr, void *gpm_buf, + u16 len, u32 sched_addr) +{ + struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; + void *sched_buf = (void *)((char *) gpm_buf + (sched_addr - gpm_addr)); + + mci->gpm_addr = gpm_addr; + mci->gpm_buf = gpm_buf; + mci->gpm_len = len; + mci->sched_addr = sched_addr; + mci->sched_buf = sched_buf; + + ar9003_mci_reset(ah, true, true, true); +} +EXPORT_SYMBOL(ar9003_mci_setup); + +void ar9003_mci_cleanup(struct ath_hw *ah) +{ + struct ath_common *common = ath9k_hw_common(ah); + + /* Turn off MCI and Jupiter mode. */ + REG_WRITE(ah, AR_BTCOEX_CTRL, 0x00); + ath_dbg(common, ATH_DBG_MCI, "MCI ar9003_mci_cleanup\n"); + ar9003_mci_disable_interrupt(ah); +} +EXPORT_SYMBOL(ar9003_mci_cleanup); + +static void ar9003_mci_process_gpm_extra(struct ath_hw *ah, u8 gpm_type, + u8 gpm_opcode, u32 *p_gpm) +{ + struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; + u8 *p_data = (u8 *) p_gpm; + + if (gpm_type != MCI_GPM_COEX_AGENT) + return; + + switch (gpm_opcode) { + case MCI_GPM_COEX_VERSION_QUERY: + ath_dbg(common, ATH_DBG_MCI, + "MCI Recv GPM COEX Version Query\n"); + ar9003_mci_send_coex_version_response(ah, true); + break; + case MCI_GPM_COEX_VERSION_RESPONSE: + ath_dbg(common, ATH_DBG_MCI, + "MCI Recv GPM COEX Version Response\n"); + mci->bt_ver_major = + *(p_data + MCI_GPM_COEX_B_MAJOR_VERSION); + mci->bt_ver_minor = + *(p_data + MCI_GPM_COEX_B_MINOR_VERSION); + mci->bt_version_known = true; + ath_dbg(common, ATH_DBG_MCI, + "MCI BT Coex version: %d.%d\n", + mci->bt_ver_major, + mci->bt_ver_minor); + break; + case MCI_GPM_COEX_STATUS_QUERY: + ath_dbg(common, ATH_DBG_MCI, + "MCI Recv GPM COEX Status Query = 0x%02X.\n", + *(p_data + MCI_GPM_COEX_B_WLAN_BITMAP)); + mci->wlan_channels_update = true; + ar9003_mci_send_coex_wlan_channels(ah, true); + break; + case MCI_GPM_COEX_BT_PROFILE_INFO: + mci->query_bt = true; + ath_dbg(common, ATH_DBG_MCI, + "MCI Recv GPM COEX BT_Profile_Info\n"); + break; + case MCI_GPM_COEX_BT_STATUS_UPDATE: + mci->query_bt = true; + ath_dbg(common, ATH_DBG_MCI, + "MCI Recv GPM COEX BT_Status_Update " + "SEQ=%d (drop&query)\n", *(p_gpm + 3)); + break; + default: + break; + } +} + +u32 ar9003_mci_wait_for_gpm(struct ath_hw *ah, u8 gpm_type, + u8 gpm_opcode, int time_out) +{ + struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; + u32 *p_gpm = NULL, mismatch = 0, more_data; + u32 offset; + u8 recv_type = 0, recv_opcode = 0; + bool b_is_bt_cal_done = (gpm_type == MCI_GPM_BT_CAL_DONE); + + more_data = time_out ? MCI_GPM_NOMORE : MCI_GPM_MORE; + + while (time_out > 0) { + if (p_gpm) { + MCI_GPM_RECYCLE(p_gpm); + p_gpm = NULL; + } + + if (more_data != MCI_GPM_MORE) + time_out = ar9003_mci_wait_for_interrupt(ah, + AR_MCI_INTERRUPT_RX_MSG_RAW, + AR_MCI_INTERRUPT_RX_MSG_GPM, + time_out); + + if (!time_out) + break; + + offset = ar9003_mci_state(ah, + MCI_STATE_NEXT_GPM_OFFSET, &more_data); + + if (offset == MCI_GPM_INVALID) + continue; + + p_gpm = (u32 *) (mci->gpm_buf + offset); + recv_type = MCI_GPM_TYPE(p_gpm); + recv_opcode = MCI_GPM_OPCODE(p_gpm); + + if (MCI_GPM_IS_CAL_TYPE(recv_type)) { + + if (recv_type == gpm_type) { + + if ((gpm_type == MCI_GPM_BT_CAL_DONE) && + !b_is_bt_cal_done) { + gpm_type = MCI_GPM_BT_CAL_GRANT; + ath_dbg(common, ATH_DBG_MCI, + "MCI Recv BT_CAL_DONE" + "wait BT_CAL_GRANT\n"); + continue; + } + + break; + } + } else if ((recv_type == gpm_type) && + (recv_opcode == gpm_opcode)) + break; + + /* not expected message */ + + /* + * check if it's cal_grant + * + * When we're waiting for cal_grant in reset routine, + * it's possible that BT sends out cal_request at the + * same time. Since BT's calibration doesn't happen + * that often, we'll let BT completes calibration then + * we continue to wait for cal_grant from BT. + * Orginal: Wait BT_CAL_GRANT. + * New: Receive BT_CAL_REQ -> send WLAN_CAL_GRANT->wait + * BT_CAL_DONE -> Wait BT_CAL_GRANT. + */ + + if ((gpm_type == MCI_GPM_BT_CAL_GRANT) && + (recv_type == MCI_GPM_BT_CAL_REQ)) { + + u32 payload[4] = {0, 0, 0, 0}; + + gpm_type = MCI_GPM_BT_CAL_DONE; + ath_dbg(common, ATH_DBG_MCI, + "MCI Rcv BT_CAL_REQ, send WLAN_CAL_GRANT\n"); + + MCI_GPM_SET_CAL_TYPE(payload, + MCI_GPM_WLAN_CAL_GRANT); + + ar9003_mci_send_message(ah, MCI_GPM, 0, payload, 16, + false, false); + + ath_dbg(common, ATH_DBG_MCI, + "MCI now wait for BT_CAL_DONE\n"); + + continue; + } else { + ath_dbg(common, ATH_DBG_MCI, "MCI GPM subtype" + "not match 0x%x\n", *(p_gpm + 1)); + mismatch++; + ar9003_mci_process_gpm_extra(ah, recv_type, + recv_opcode, p_gpm); + } + } + if (p_gpm) { + MCI_GPM_RECYCLE(p_gpm); + p_gpm = NULL; + } + + if (time_out <= 0) { + time_out = 0; + ath_dbg(common, ATH_DBG_MCI, + "MCI GPM received timeout, mismatch = %d\n", mismatch); + } else + ath_dbg(common, ATH_DBG_MCI, + "MCI Receive GPM type=0x%x, code=0x%x\n", + gpm_type, gpm_opcode); + + while (more_data == MCI_GPM_MORE) { + + ath_dbg(common, ATH_DBG_MCI, "MCI discard remaining GPM\n"); + offset = ar9003_mci_state(ah, MCI_STATE_NEXT_GPM_OFFSET, + &more_data); + + if (offset == MCI_GPM_INVALID) + break; + + p_gpm = (u32 *) (mci->gpm_buf + offset); + recv_type = MCI_GPM_TYPE(p_gpm); + recv_opcode = MCI_GPM_OPCODE(p_gpm); + + if (!MCI_GPM_IS_CAL_TYPE(recv_type)) + ar9003_mci_process_gpm_extra(ah, recv_type, + recv_opcode, p_gpm); + + MCI_GPM_RECYCLE(p_gpm); + } + + return time_out; +} + +u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type, u32 *p_data) +{ + struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; + u32 value = 0, more_gpm = 0, gpm_ptr; + u8 query_type; + + switch (state_type) { + case MCI_STATE_ENABLE: + if (mci->ready) { + + value = REG_READ(ah, AR_BTCOEX_CTRL); + + if ((value == 0xdeadbeef) || (value == 0xffffffff)) + value = 0; + } + value &= AR_BTCOEX_CTRL_MCI_MODE_EN; + break; + case MCI_STATE_INIT_GPM_OFFSET: + value = MS(REG_READ(ah, AR_MCI_GPM_1), AR_MCI_GPM_WRITE_PTR); + ath_dbg(common, ATH_DBG_MCI, + "MCI GPM initial WRITE_PTR=%d\n", value); + mci->gpm_idx = value; + break; + case MCI_STATE_NEXT_GPM_OFFSET: + case MCI_STATE_LAST_GPM_OFFSET: + /* + * This could be useful to avoid new GPM message interrupt which + * may lead to spurious interrupt after power sleep, or multiple + * entry of ath_mci_intr(). + * Adding empty GPM check by returning HAL_MCI_GPM_INVALID can + * alleviate this effect, but clearing GPM RX interrupt bit is + * safe, because whether this is called from hw or driver code + * there must be an interrupt bit set/triggered initially + */ + REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_RAW, + AR_MCI_INTERRUPT_RX_MSG_GPM); + + gpm_ptr = MS(REG_READ(ah, AR_MCI_GPM_1), AR_MCI_GPM_WRITE_PTR); + value = gpm_ptr; + + if (value == 0) + value = mci->gpm_len - 1; + else if (value >= mci->gpm_len) { + if (value != 0xFFFF) { + value = 0; + ath_dbg(common, ATH_DBG_MCI, "MCI GPM offset" + "out of range\n"); + } + } else + value--; + + if (value == 0xFFFF) { + value = MCI_GPM_INVALID; + more_gpm = MCI_GPM_NOMORE; + ath_dbg(common, ATH_DBG_MCI, "MCI GPM ptr invalid" + "@ptr=%d, offset=%d, more=GPM_NOMORE\n", + gpm_ptr, value); + } else if (state_type == MCI_STATE_NEXT_GPM_OFFSET) { + + if (gpm_ptr == mci->gpm_idx) { + value = MCI_GPM_INVALID; + more_gpm = MCI_GPM_NOMORE; + + ath_dbg(common, ATH_DBG_MCI, "MCI GPM message" + "not available @ptr=%d, @offset=%d," + "more=GPM_NOMORE\n", gpm_ptr, value); + } else { + for (;;) { + + u32 temp_index; + + /* skip reserved GPM if any */ + + if (value != mci->gpm_idx) + more_gpm = MCI_GPM_MORE; + else + more_gpm = MCI_GPM_NOMORE; + + temp_index = mci->gpm_idx; + mci->gpm_idx++; + + if (mci->gpm_idx >= + mci->gpm_len) + mci->gpm_idx = 0; + + ath_dbg(common, ATH_DBG_MCI, + "MCI GPM message got ptr=%d," + "@offset=%d, more=%d\n", + gpm_ptr, temp_index, + (more_gpm == MCI_GPM_MORE)); + + if (ar9003_mci_is_gpm_valid(ah, + temp_index)) { + value = temp_index; + break; + } + + if (more_gpm == MCI_GPM_NOMORE) { + value = MCI_GPM_INVALID; + break; + } + } + } + if (p_data) + *p_data = more_gpm; + } + + if (value != MCI_GPM_INVALID) + value <<= 4; + + break; + case MCI_STATE_LAST_SCHD_MSG_OFFSET: + value = MS(REG_READ(ah, AR_MCI_RX_STATUS), + AR_MCI_RX_LAST_SCHD_MSG_INDEX); + /* Make it in bytes */ + value <<= 4; + break; + + case MCI_STATE_REMOTE_SLEEP: + value = MS(REG_READ(ah, AR_MCI_RX_STATUS), + AR_MCI_RX_REMOTE_SLEEP) ? + MCI_BT_SLEEP : MCI_BT_AWAKE; + break; + + case MCI_STATE_CONT_RSSI_POWER: + value = MS(mci->cont_status, AR_MCI_CONT_RSSI_POWER); + break; + + case MCI_STATE_CONT_PRIORITY: + value = MS(mci->cont_status, AR_MCI_CONT_RRIORITY); + break; + + case MCI_STATE_CONT_TXRX: + value = MS(mci->cont_status, AR_MCI_CONT_TXRX); + break; + + case MCI_STATE_BT: + value = mci->bt_state; + break; + + case MCI_STATE_SET_BT_SLEEP: + mci->bt_state = MCI_BT_SLEEP; + break; + + case MCI_STATE_SET_BT_AWAKE: + mci->bt_state = MCI_BT_AWAKE; + ar9003_mci_send_coex_version_query(ah, true); + ar9003_mci_send_coex_wlan_channels(ah, true); + + if (mci->unhalt_bt_gpm) { + + ath_dbg(common, ATH_DBG_MCI, + "MCI unhalt BT GPM\n"); + ar9003_mci_send_coex_halt_bt_gpm(ah, false, true); + } + + ar9003_mci_2g5g_switch(ah, true); + break; + + case MCI_STATE_SET_BT_CAL_START: + mci->bt_state = MCI_BT_CAL_START; + break; + + case MCI_STATE_SET_BT_CAL: + mci->bt_state = MCI_BT_CAL; + break; + + case MCI_STATE_RESET_REQ_WAKE: + ar9003_mci_reset_req_wakeup(ah); + mci->update_2g5g = true; + + if ((AR_SREV_9462_20_OR_LATER(ah)) && + (mci->config & ATH_MCI_CONFIG_MCI_OBS_MASK)) { + /* Check if we still have control of the GPIOs */ + if ((REG_READ(ah, AR_GLB_GPIO_CONTROL) & + ATH_MCI_CONFIG_MCI_OBS_GPIO) != + ATH_MCI_CONFIG_MCI_OBS_GPIO) { + + ath_dbg(common, ATH_DBG_MCI, + "MCI reconfigure observation"); + ar9003_mci_observation_set_up(ah); + } + } + break; + + case MCI_STATE_SEND_WLAN_COEX_VERSION: + ar9003_mci_send_coex_version_response(ah, true); + break; + + case MCI_STATE_SET_BT_COEX_VERSION: + + if (!p_data) + ath_dbg(common, ATH_DBG_MCI, + "MCI Set BT Coex version with NULL data!!\n"); + else { + mci->bt_ver_major = (*p_data >> 8) & 0xff; + mci->bt_ver_minor = (*p_data) & 0xff; + mci->bt_version_known = true; + ath_dbg(common, ATH_DBG_MCI, + "MCI BT version set: %d.%d\n", + mci->bt_ver_major, + mci->bt_ver_minor); + } + break; + + case MCI_STATE_SEND_WLAN_CHANNELS: + if (p_data) { + if (((mci->wlan_channels[1] & 0xffff0000) == + (*(p_data + 1) & 0xffff0000)) && + (mci->wlan_channels[2] == *(p_data + 2)) && + (mci->wlan_channels[3] == *(p_data + 3))) + break; + + mci->wlan_channels[0] = *p_data++; + mci->wlan_channels[1] = *p_data++; + mci->wlan_channels[2] = *p_data++; + mci->wlan_channels[3] = *p_data++; + } + mci->wlan_channels_update = true; + ar9003_mci_send_coex_wlan_channels(ah, true); + break; + + case MCI_STATE_SEND_VERSION_QUERY: + ar9003_mci_send_coex_version_query(ah, true); + break; + + case MCI_STATE_SEND_STATUS_QUERY: + query_type = (AR_SREV_9462_10(ah)) ? + MCI_GPM_COEX_QUERY_BT_ALL_INFO : + MCI_GPM_COEX_QUERY_BT_TOPOLOGY; + + ar9003_mci_send_coex_bt_status_query(ah, true, query_type); + break; + + case MCI_STATE_NEED_FLUSH_BT_INFO: + /* + * btcoex_hw.mci.unhalt_bt_gpm means whether it's + * needed to send UNHALT message. It's set whenever + * there's a request to send HALT message. + * mci_halted_bt_gpm means whether HALT message is sent + * out successfully. + * + * Checking (mci_unhalt_bt_gpm == false) instead of + * checking (ah->mci_halted_bt_gpm == false) will make + * sure currently is in UNHALT-ed mode and BT can + * respond to status query. + */ + value = (!mci->unhalt_bt_gpm && + mci->need_flush_btinfo) ? 1 : 0; + if (p_data) + mci->need_flush_btinfo = + (*p_data != 0) ? true : false; + break; + + case MCI_STATE_RECOVER_RX: + + ath_dbg(common, ATH_DBG_MCI, "MCI hw RECOVER_RX\n"); + ar9003_mci_prep_interface(ah); + mci->query_bt = true; + mci->need_flush_btinfo = true; + ar9003_mci_send_coex_wlan_channels(ah, true); + ar9003_mci_2g5g_switch(ah, true); + break; + + case MCI_STATE_NEED_FTP_STOMP: + value = !(mci->config & ATH_MCI_CONFIG_DISABLE_FTP_STOMP); + break; + + case MCI_STATE_NEED_TUNING: + value = !(mci->config & ATH_MCI_CONFIG_DISABLE_TUNING); + break; + + default: + break; + + } + + return value; +} +EXPORT_SYMBOL(ar9003_mci_state); diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index cd43d5904567..c9c3b1889965 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -1203,6 +1203,32 @@ void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning); void ath9k_hw_proc_mib_event(struct ath_hw *ah); void ath9k_hw_ani_monitor(struct ath_hw *ah, struct ath9k_channel *chan); +bool ar9003_mci_send_message(struct ath_hw *ah, u8 header, u32 flag, + u32 *payload, u8 len, bool wait_done, + bool check_bt); +void ar9003_mci_mute_bt(struct ath_hw *ah); +u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type, u32 *p_data); +void ar9003_mci_setup(struct ath_hw *ah, u32 gpm_addr, void *gpm_buf, + u16 len, u32 sched_addr); +void ar9003_mci_cleanup(struct ath_hw *ah); +void ar9003_mci_send_coex_halt_bt_gpm(struct ath_hw *ah, bool halt, + bool wait_done); +u32 ar9003_mci_wait_for_gpm(struct ath_hw *ah, u8 gpm_type, + u8 gpm_opcode, int time_out); +void ar9003_mci_2g5g_changed(struct ath_hw *ah, bool is_2g); +void ar9003_mci_disable_interrupt(struct ath_hw *ah); +void ar9003_mci_enable_interrupt(struct ath_hw *ah); +void ar9003_mci_2g5g_switch(struct ath_hw *ah, bool wait_done); +void ar9003_mci_reset(struct ath_hw *ah, bool en_int, bool is_2g, + bool is_full_sleep); +bool ar9003_mci_check_int(struct ath_hw *ah, u32 ints); +void ar9003_mci_remote_reset(struct ath_hw *ah, bool wait_done); +void ar9003_mci_send_sys_waking(struct ath_hw *ah, bool wait_done); +void ar9003_mci_send_lna_transfer(struct ath_hw *ah, bool wait_done); +void ar9003_mci_sync_bt_state(struct ath_hw *ah); +void ar9003_mci_get_interrupt(struct ath_hw *ah, u32 *raw_intr, + u32 *rx_msg_intr); + #define ATH9K_CLOCK_RATE_CCK 22 #define ATH9K_CLOCK_RATE_5GHZ_OFDM 40 #define ATH9K_CLOCK_RATE_2GHZ_OFDM 44 -- cgit v1.2.3 From 40dc5392e6bfcd62b3c09c68df8b73c2bc6adf2a Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Wed, 30 Nov 2011 10:41:18 +0530 Subject: ath9k: Add MCI interrupt to interrupt mask Cc: Wilson Tsao Cc: Senthil Balasubramanian Signed-off-by: Rajkumar Manoharan Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index e43c41cff25b..90d35f265e3d 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -764,7 +764,8 @@ irqreturn_t ath_isr(int irq, void *dev) ATH9K_INT_BMISS | \ ATH9K_INT_CST | \ ATH9K_INT_TSFOOR | \ - ATH9K_INT_GENTIMER) + ATH9K_INT_GENTIMER | \ + ATH9K_INT_MCI) struct ath_softc *sc = dev; struct ath_hw *ah = sc->sc_ah; @@ -1119,6 +1120,9 @@ static int ath9k_start(struct ieee80211_hw *hw) if (ah->caps.hw_caps & ATH9K_HW_CAP_HT) ah->imask |= ATH9K_INT_CST; + if (ah->caps.hw_caps & ATH9K_HW_CAP_MCI) + ah->imask |= ATH9K_INT_MCI; + sc->sc_flags &= ~SC_OP_INVALID; sc->sc_ah->is_monitoring = false; -- cgit v1.2.3 From f229f815d26acea2e51ef073ef73ea37406cca98 Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Wed, 30 Nov 2011 10:41:19 +0530 Subject: ath9k_hw: take care of enabling MCI interrupts enable MCI interrupt when ath9k_hw_enable_interrupts is called, like during the completion of chip_reset before which the interrupts are disabled Cc: Wilson Tsao Cc: Senthil Balasubramanian Signed-off-by: Rajkumar Manoharan Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/mac.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/mac.c b/drivers/net/wireless/ath/ath9k/mac.c index ecdb6fd29079..9d693201b0b5 100644 --- a/drivers/net/wireless/ath/ath9k/mac.c +++ b/drivers/net/wireless/ath/ath9k/mac.c @@ -798,6 +798,7 @@ void ath9k_hw_enable_interrupts(struct ath_hw *ah) { struct ath_common *common = ath9k_hw_common(ah); u32 sync_default = AR_INTR_SYNC_DEFAULT; + u32 async_mask; if (!(ah->imask & ATH9K_INT_GLOBAL)) return; @@ -812,13 +813,16 @@ void ath9k_hw_enable_interrupts(struct ath_hw *ah) if (AR_SREV_9340(ah)) sync_default &= ~AR_INTR_SYNC_HOST1_FATAL; + async_mask = AR_INTR_MAC_IRQ; + + if (ah->imask & ATH9K_INT_MCI) + async_mask |= AR_INTR_ASYNC_MASK_MCI; + ath_dbg(common, ATH_DBG_INTERRUPT, "enable IER\n"); REG_WRITE(ah, AR_IER, AR_IER_ENABLE); if (!AR_SREV_9100(ah)) { - REG_WRITE(ah, AR_INTR_ASYNC_ENABLE, - AR_INTR_MAC_IRQ); - REG_WRITE(ah, AR_INTR_ASYNC_MASK, AR_INTR_MAC_IRQ); - + REG_WRITE(ah, AR_INTR_ASYNC_ENABLE, async_mask); + REG_WRITE(ah, AR_INTR_ASYNC_MASK, async_mask); REG_WRITE(ah, AR_INTR_SYNC_ENABLE, sync_default); REG_WRITE(ah, AR_INTR_SYNC_MASK, sync_default); -- cgit v1.2.3 From e35848134ccbd74fa8162d3b00461e189f913dfc Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Wed, 30 Nov 2011 10:41:20 +0530 Subject: ath9k_hw: check for asynchronous MCI interrupt pending MCI interrupt is an asynchronous one, so take care of it by having a check in ath9k_hw_intrpend, which actually decides whether the interrupt is really for the driver from ath_isr Cc: Wilson Tsao Cc: Senthil Balasubramanian Signed-off-by: Rajkumar Manoharan Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/mac.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/mac.c b/drivers/net/wireless/ath/ath9k/mac.c index 9d693201b0b5..0e4fbb3bea33 100644 --- a/drivers/net/wireless/ath/ath9k/mac.c +++ b/drivers/net/wireless/ath/ath9k/mac.c @@ -760,7 +760,10 @@ bool ath9k_hw_intrpend(struct ath_hw *ah) return true; host_isr = REG_READ(ah, AR_INTR_ASYNC_CAUSE); - if ((host_isr & AR_INTR_MAC_IRQ) && (host_isr != AR_INTR_SPURIOUS)) + + if (((host_isr & AR_INTR_MAC_IRQ) || + (host_isr & AR_INTR_ASYNC_MASK_MCI)) && + (host_isr != AR_INTR_SPURIOUS)) return true; host_isr = REG_READ(ah, AR_INTR_SYNC_CAUSE); -- cgit v1.2.3 From 4421d30ffa4b4271b48d8f1e8c7bd65186bf2cd5 Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Wed, 30 Nov 2011 10:41:21 +0530 Subject: ath9k_hw: check for MCI interrupt in get_isr check for the condition of MCI interrupt being triggered and appropriately obtain the values of MCI_INTERRUPT_RX_MSG_RAW and MCI_INTERRUPT_RAW Cc: Wilson Tsao Cc: Senthil Balasubramanian Signed-off-by: Rajkumar Manoharan Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9003_mac.c | 36 +++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c index ccde784a842f..95587e36ab9c 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c @@ -175,15 +175,47 @@ static bool ar9003_hw_get_isr(struct ath_hw *ah, enum ath9k_int *masked) u32 isr = 0; u32 mask2 = 0; struct ath9k_hw_capabilities *pCap = &ah->caps; - u32 sync_cause = 0; struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; + u32 sync_cause = 0, async_cause; - if (REG_READ(ah, AR_INTR_ASYNC_CAUSE) & AR_INTR_MAC_IRQ) { + async_cause = REG_READ(ah, AR_INTR_ASYNC_CAUSE); + + if (async_cause & (AR_INTR_MAC_IRQ | AR_INTR_ASYNC_MASK_MCI)) { if ((REG_READ(ah, AR_RTC_STATUS) & AR_RTC_STATUS_M) == AR_RTC_STATUS_ON) isr = REG_READ(ah, AR_ISR); } + if (async_cause & AR_INTR_ASYNC_MASK_MCI) { + u32 raw_intr, rx_msg_intr; + + rx_msg_intr = REG_READ(ah, AR_MCI_INTERRUPT_RX_MSG_RAW); + raw_intr = REG_READ(ah, AR_MCI_INTERRUPT_RAW); + + if ((raw_intr == 0xdeadbeef) || (rx_msg_intr == 0xdeadbeef)) + ath_dbg(common, ATH_DBG_MCI, + "MCI gets 0xdeadbeef during MCI int processing" + "new raw_intr=0x%08x, new rx_msg_raw=0x%08x, " + "raw_intr=0x%08x, rx_msg_raw=0x%08x\n", + raw_intr, rx_msg_intr, mci->raw_intr, + mci->rx_msg_intr); + else { + mci->rx_msg_intr |= rx_msg_intr; + mci->raw_intr |= raw_intr; + *masked |= ATH9K_INT_MCI; + + if (rx_msg_intr & AR_MCI_INTERRUPT_RX_MSG_CONT_INFO) + mci->cont_status = + REG_READ(ah, AR_MCI_CONT_STATUS); + + REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_RAW, rx_msg_intr); + REG_WRITE(ah, AR_MCI_INTERRUPT_RAW, raw_intr); + ath_dbg(common, ATH_DBG_MCI, "AR_INTR_SYNC_MCI\n"); + + } + } + sync_cause = REG_READ(ah, AR_INTR_SYNC_CAUSE) & AR_INTR_SYNC_DEFAULT; *masked = 0; -- cgit v1.2.3 From f2f2185679288ade3de1052a572daf9b5d1fd324 Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Wed, 30 Nov 2011 10:41:22 +0530 Subject: ath9k: add MCI specific definitions and structures Cc: Wilson Tsao Cc: Senthil Balasubramanian Signed-off-by: Rajkumar Manoharan Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/mci.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/mci.h b/drivers/net/wireless/ath/ath9k/mci.h index 9590c61822d1..5df0d607e881 100644 --- a/drivers/net/wireless/ath/ath9k/mci.h +++ b/drivers/net/wireless/ath/ath9k/mci.h @@ -17,6 +17,9 @@ #ifndef MCI_H #define MCI_H +#define ATH_MCI_SCHED_BUF_SIZE (16 * 16) /* 16 entries, 4 dword each */ +#define ATH_MCI_GPM_MAX_ENTRY 16 +#define ATH_MCI_GPM_BUF_SIZE (ATH_MCI_GPM_MAX_ENTRY * 16) #define ATH_MCI_DEF_BT_PERIOD 40 #define ATH_MCI_BDR_DUTY_CYCLE 20 #define ATH_MCI_MAX_DUTY_CYCLE 90 @@ -110,6 +113,20 @@ struct ath_mci_profile { u8 num_bdr; }; + +struct ath_mci_buf { + void *bf_addr; /* virtual addr of desc */ + dma_addr_t bf_paddr; /* physical addr of buffer */ + u32 bf_len; /* len of data */ +}; + +struct ath_mci_coex { + atomic_t mci_cal_flag; + struct ath_mci_buf sched_buf; + struct ath_mci_buf gpm_buf; + u32 bt_cal_start; +}; + void ath_mci_flush_profile(struct ath_mci_profile *mci); void ath_mci_process_profile(struct ath_softc *sc, struct ath_mci_profile_info *info); -- cgit v1.2.3 From 9e25365ffaa98626bdf7e1bb5fdddf73a1c131fb Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Wed, 30 Nov 2011 10:41:23 +0530 Subject: ath9k: Add functions to allocate/free buffers for MCI required buffers and dma allocation is done for GPM and SCHED messages Cc: Wilson Tsao Cc: Senthil Balasubramanian Signed-off-by: Rajkumar Manoharan Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ath9k.h | 1 + drivers/net/wireless/ath/ath9k/mci.c | 78 ++++++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath9k/mci.h | 2 + 3 files changed, 81 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index 386402c37158..afc156a0a2e3 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h @@ -647,6 +647,7 @@ struct ath_softc { struct delayed_work tx_complete_work; struct delayed_work hw_pll_work; struct ath_btcoex btcoex; + struct ath_mci_coex mci_coex; struct ath_descdma txsdma; diff --git a/drivers/net/wireless/ath/ath9k/mci.c b/drivers/net/wireless/ath/ath9k/mci.c index 0fbb141bc302..5b246766bde5 100644 --- a/drivers/net/wireless/ath/ath9k/mci.c +++ b/drivers/net/wireless/ath/ath9k/mci.c @@ -14,6 +14,9 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include +#include + #include "ath9k.h" #include "mci.h" @@ -252,3 +255,78 @@ void ath_mci_process_status(struct ath_softc *sc, if (old_num_mgmt != mci->num_mgmt) ath_mci_update_scheme(sc); } + + +static int ath_mci_buf_alloc(struct ath_softc *sc, struct ath_mci_buf *buf) +{ + int error = 0; + + buf->bf_addr = dma_alloc_coherent(sc->dev, buf->bf_len, + &buf->bf_paddr, GFP_KERNEL); + + if (buf->bf_addr == NULL) { + error = -ENOMEM; + goto fail; + } + + return 0; + +fail: + memset(buf, 0, sizeof(*buf)); + return error; +} + +static void ath_mci_buf_free(struct ath_softc *sc, struct ath_mci_buf *buf) +{ + if (buf->bf_addr) { + dma_free_coherent(sc->dev, buf->bf_len, buf->bf_addr, + buf->bf_paddr); + memset(buf, 0, sizeof(*buf)); + } +} + +int ath_mci_setup(struct ath_softc *sc) +{ + struct ath_common *common = ath9k_hw_common(sc->sc_ah); + struct ath_mci_coex *mci = &sc->mci_coex; + int error = 0; + + mci->sched_buf.bf_len = ATH_MCI_SCHED_BUF_SIZE + ATH_MCI_GPM_BUF_SIZE; + + if (ath_mci_buf_alloc(sc, &mci->sched_buf)) { + ath_dbg(common, ATH_DBG_FATAL, "MCI buffer alloc failed\n"); + error = -ENOMEM; + goto fail; + } + + mci->sched_buf.bf_len = ATH_MCI_SCHED_BUF_SIZE; + + memset(mci->sched_buf.bf_addr, MCI_GPM_RSVD_PATTERN, + mci->sched_buf.bf_len); + + mci->gpm_buf.bf_len = ATH_MCI_GPM_BUF_SIZE; + mci->gpm_buf.bf_addr = (u8 *)mci->sched_buf.bf_addr + + mci->sched_buf.bf_len; + mci->gpm_buf.bf_paddr = mci->sched_buf.bf_paddr + mci->sched_buf.bf_len; + + /* initialize the buffer */ + memset(mci->gpm_buf.bf_addr, MCI_GPM_RSVD_PATTERN, mci->gpm_buf.bf_len); + + ar9003_mci_setup(sc->sc_ah, mci->gpm_buf.bf_paddr, + mci->gpm_buf.bf_addr, (mci->gpm_buf.bf_len >> 4), + mci->sched_buf.bf_paddr); +fail: + return error; +} + +void ath_mci_cleanup(struct ath_softc *sc) +{ + struct ath_hw *ah = sc->sc_ah; + struct ath_mci_coex *mci = &sc->mci_coex; + + /* + * both schedule and gpm buffers will be released + */ + ath_mci_buf_free(sc, &mci->sched_buf); + ar9003_mci_cleanup(ah); +} diff --git a/drivers/net/wireless/ath/ath9k/mci.h b/drivers/net/wireless/ath/ath9k/mci.h index 5df0d607e881..4eeb0feafc06 100644 --- a/drivers/net/wireless/ath/ath9k/mci.h +++ b/drivers/net/wireless/ath/ath9k/mci.h @@ -132,4 +132,6 @@ void ath_mci_process_profile(struct ath_softc *sc, struct ath_mci_profile_info *info); void ath_mci_process_status(struct ath_softc *sc, struct ath_mci_profile_status *status); +int ath_mci_setup(struct ath_softc *sc); +void ath_mci_cleanup(struct ath_softc *sc); #endif -- cgit v1.2.3 From 1010911ec389fe7a342b9962877fdb88d7f04247 Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Wed, 30 Nov 2011 10:41:24 +0530 Subject: ath9k_hw: MCI related changes in chip management send halt BT GPM if the chip is in network sleep and BT state is awake Cc: Wilson Tsao Cc: Senthil Balasubramanian Signed-off-by: Rajkumar Manoharan Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/hw.c | 24 ++++++++++++++++++++++++ drivers/net/wireless/ath/ath9k/reg.h | 2 ++ 2 files changed, 26 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 662ab7e9a0f0..ba5734aa46c4 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -1933,6 +1933,7 @@ static bool ath9k_hw_set_power_awake(struct ath_hw *ah, int setChip) bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode) { struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; int status = true, setChip = true; static const char *modes[] = { "AWAKE", @@ -1950,12 +1951,35 @@ bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode) switch (mode) { case ATH9K_PM_AWAKE: status = ath9k_hw_set_power_awake(ah, setChip); + + if (ah->caps.hw_caps & ATH9K_HW_CAP_MCI) + REG_WRITE(ah, AR_RTC_KEEP_AWAKE, 0x2); + break; case ATH9K_PM_FULL_SLEEP: + + if (ah->caps.hw_caps & ATH9K_HW_CAP_MCI) { + if (ar9003_mci_state(ah, MCI_STATE_ENABLE, NULL) && + (mci->bt_state != MCI_BT_SLEEP) && + !mci->halted_bt_gpm) { + ath_dbg(common, ATH_DBG_MCI, "MCI halt BT GPM" + "(full_sleep)"); + ar9003_mci_send_coex_halt_bt_gpm(ah, + true, true); + } + + mci->ready = false; + REG_WRITE(ah, AR_RTC_KEEP_AWAKE, 0x2); + } + ath9k_set_power_sleep(ah, setChip); ah->chip_fullsleep = true; break; case ATH9K_PM_NETWORK_SLEEP: + + if (ah->caps.hw_caps & ATH9K_HW_CAP_MCI) + REG_WRITE(ah, AR_RTC_KEEP_AWAKE, 0x2); + ath9k_set_power_network_sleep(ah, setChip); break; default: diff --git a/drivers/net/wireless/ath/ath9k/reg.h b/drivers/net/wireless/ath/ath9k/reg.h index ba3672f45a20..6e2f18861f5d 100644 --- a/drivers/net/wireless/ath/ath9k/reg.h +++ b/drivers/net/wireless/ath/ath9k/reg.h @@ -1279,6 +1279,8 @@ enum { #define AR_RTC_INTR_MASK \ ((AR_SREV_9100(ah)) ? (AR_RTC_BASE + 0x0058) : 0x7058) +#define AR_RTC_KEEP_AWAKE 0x7034 + /* RTC_DERIVED_* - only for AR9100 */ #define AR_RTC_DERIVED_CLK \ -- cgit v1.2.3 From 7a9233ff6de823d14a26662697813bee82617268 Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Wed, 30 Nov 2011 10:41:25 +0530 Subject: ath9k_hw: MCI related changes in set_reset_reg Cc: Wilson Tsao Cc: Senthil Balasubramanian Signed-off-by: Rajkumar Manoharan Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/hw.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index ba5734aa46c4..1d71d1ba202c 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -1350,6 +1350,7 @@ static bool ath9k_hw_set_reset_power_on(struct ath_hw *ah) static bool ath9k_hw_set_reset_reg(struct ath_hw *ah, u32 type) { + bool ret = false; if (AR_SREV_9300_20_OR_LATER(ah)) { REG_WRITE(ah, AR_WA, ah->WARegVal); @@ -1361,13 +1362,20 @@ static bool ath9k_hw_set_reset_reg(struct ath_hw *ah, u32 type) switch (type) { case ATH9K_RESET_POWER_ON: - return ath9k_hw_set_reset_power_on(ah); + ret = ath9k_hw_set_reset_power_on(ah); + break; case ATH9K_RESET_WARM: case ATH9K_RESET_COLD: - return ath9k_hw_set_reset(ah, type); + ret = ath9k_hw_set_reset(ah, type); + break; default: - return false; + break; } + + if (ah->caps.hw_caps & ATH9K_HW_CAP_MCI) + REG_WRITE(ah, AR_RTC_KEEP_AWAKE, 0x2); + + return ret; } static bool ath9k_hw_chip_reset(struct ath_hw *ah, -- cgit v1.2.3 From 3ebfcdc43ae261e58e5b9b381ae1f278cda068e3 Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Wed, 30 Nov 2011 10:41:26 +0530 Subject: ath9k_hw: Add support for MCI WLAN calibration WLAN communicates with BT for its calibration by sending WLAN_CAL_REQ, waits for BT_CAL_GRANT. This is done with the help of GPM messages. also WLAN_CAL_DONE messages is sent once WLAN calibration is done. Cc: Wilson Tsao Cc: Senthil Balasubramanian Signed-off-by: Rajkumar Manoharan Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9003_calib.c | 43 +++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/ar9003_calib.c b/drivers/net/wireless/ath/ath9k/ar9003_calib.c index e5407df10ea0..ddeba8693fab 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c @@ -18,6 +18,7 @@ #include "hw-ops.h" #include "ar9003_phy.h" #include "ar9003_rtt.h" +#include "ar9003_mci.h" #define MAX_MEASUREMENT MAX_IQCAL_MEASUREMENT #define MAX_MAG_DELTA 11 @@ -934,10 +935,12 @@ static bool ar9003_hw_init_cal(struct ath_hw *ah, { struct ath_common *common = ath9k_hw_common(ah); struct ath9k_hw_cal_data *caldata = ah->caldata; + struct ath9k_hw_mci *mci_hw = &ah->btcoex_hw.mci; bool txiqcal_done = false, txclcal_done = false; bool is_reusable = true, status = true; bool run_rtt_cal = false, run_agc_cal; bool rtt = !!(ah->caps.hw_caps & ATH9K_HW_CAP_RTT); + bool mci = !!(ah->caps.hw_caps & ATH9K_HW_CAP_MCI); u32 agc_ctrl = 0, agc_supp_cals = AR_PHY_AGC_CONTROL_OFFSET_CAL | AR_PHY_AGC_CONTROL_FLTR_CAL | AR_PHY_AGC_CONTROL_PKDET_CAL; @@ -1005,6 +1008,31 @@ static bool ar9003_hw_init_cal(struct ath_hw *ah, } else if (caldata && !caldata->done_txiqcal_once) run_agc_cal = true; + if (mci && IS_CHAN_2GHZ(chan) && + (mci_hw->bt_state == MCI_BT_AWAKE) && + run_agc_cal && + !(mci_hw->config & ATH_MCI_CONFIG_DISABLE_MCI_CAL)) { + + u32 pld[4] = {0, 0, 0, 0}; + + /* send CAL_REQ only when BT is AWAKE. */ + ath_dbg(common, ATH_DBG_MCI, "MCI send WLAN_CAL_REQ 0x%x\n", + mci_hw->wlan_cal_seq); + MCI_GPM_SET_CAL_TYPE(pld, MCI_GPM_WLAN_CAL_REQ); + pld[MCI_GPM_WLAN_CAL_W_SEQUENCE] = mci_hw->wlan_cal_seq++; + ar9003_mci_send_message(ah, MCI_GPM, 0, pld, 16, true, false); + + /* Wait BT_CAL_GRANT for 50ms */ + ath_dbg(common, ATH_DBG_MCI, "MCI wait for BT_CAL_GRANT"); + + if (ar9003_mci_wait_for_gpm(ah, MCI_GPM_BT_CAL_GRANT, 0, 50000)) + ath_dbg(common, ATH_DBG_MCI, "MCI got BT_CAL_GRANT"); + else { + is_reusable = false; + ath_dbg(common, ATH_DBG_MCI, "\nMCI BT is not responding"); + } + } + txiqcal_done = ar9003_hw_tx_iq_cal_run(ah); REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_DIS); udelay(5); @@ -1022,6 +1050,21 @@ skip_tx_iqcal: AR_PHY_AGC_CONTROL_CAL, 0, AH_WAIT_TIMEOUT); } + + if (mci && IS_CHAN_2GHZ(chan) && + (mci_hw->bt_state == MCI_BT_AWAKE) && + run_agc_cal && + !(mci_hw->config & ATH_MCI_CONFIG_DISABLE_MCI_CAL)) { + + u32 pld[4] = {0, 0, 0, 0}; + + ath_dbg(common, ATH_DBG_MCI, "MCI Send WLAN_CAL_DONE 0x%x\n", + mci_hw->wlan_cal_done); + MCI_GPM_SET_CAL_TYPE(pld, MCI_GPM_WLAN_CAL_DONE); + pld[MCI_GPM_WLAN_CAL_W_SEQUENCE] = mci_hw->wlan_cal_done++; + ar9003_mci_send_message(ah, MCI_GPM, 0, pld, 16, true, false); + } + if (rtt && !run_rtt_cal) { agc_ctrl |= agc_supp_cals; REG_WRITE(ah, AR_PHY_AGC_CONTROL, agc_ctrl); -- cgit v1.2.3 From 63d3296741e9f556d1edbdc34c07ce7dbe54a471 Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Wed, 30 Nov 2011 10:41:27 +0530 Subject: ath9k_hw: Add MCI related changes in chip reset here we check for BT state and if BT calibration has started, give 25ms for BT Calibration to finish. we also take care of 2G/5G switch and LNA transfer incase WLAN is operating in 5G. in case the BT state is awake when we do WLAN calibration re-calibrate and we reset the message exchange between WLAN and BT. BT is given preference when simultaneous CAL request happens. calibration for WLAN/BT is done assuming that the other co-existing module is in awake state, if not we continue to do calibration while if the other module's state changes we need to do restart the calibration handshake Cc: Wilson Tsao Cc: Senthil Balasubramanian Signed-off-by: Rajkumar Manoharan Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/hw.c | 132 ++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 1d71d1ba202c..e2860d7cd684 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -1514,6 +1514,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, struct ath9k_hw_cal_data *caldata, bool bChannelChange) { struct ath_common *common = ath9k_hw_common(ah); + struct ath9k_hw_mci *mci_hw = &ah->btcoex_hw.mci; u32 saveLedState; struct ath9k_channel *curchan = ah->curchan; u32 saveDefAntenna; @@ -1521,6 +1522,53 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, u64 tsf = 0; int i, r; bool allow_fbs = false; + bool mci = !!(ah->caps.hw_caps & ATH9K_HW_CAP_MCI); + bool save_fullsleep = ah->chip_fullsleep; + + if (mci) { + + ar9003_mci_2g5g_changed(ah, IS_CHAN_2GHZ(chan)); + + if (mci_hw->bt_state == MCI_BT_CAL_START) { + u32 payload[4] = {0, 0, 0, 0}; + + ath_dbg(common, ATH_DBG_MCI, "MCI stop rx for BT CAL"); + + mci_hw->bt_state = MCI_BT_CAL; + + /* + * MCI FIX: disable mci interrupt here. This is to avoid + * SW_MSG_DONE or RX_MSG bits to trigger MCI_INT and + * lead to mci_intr reentry. + */ + + ar9003_mci_disable_interrupt(ah); + + ath_dbg(common, ATH_DBG_MCI, "send WLAN_CAL_GRANT"); + MCI_GPM_SET_CAL_TYPE(payload, MCI_GPM_WLAN_CAL_GRANT); + ar9003_mci_send_message(ah, MCI_GPM, 0, payload, + 16, true, false); + + ath_dbg(common, ATH_DBG_MCI, "\nMCI BT is calibrating"); + + /* Wait BT calibration to be completed for 25ms */ + + if (ar9003_mci_wait_for_gpm(ah, MCI_GPM_BT_CAL_DONE, + 0, 25000)) + ath_dbg(common, ATH_DBG_MCI, + "MCI got BT_CAL_DONE\n"); + else + ath_dbg(common, ATH_DBG_MCI, + "MCI ### BT cal takes to long, force" + "bt_state to be bt_awake\n"); + mci_hw->bt_state = MCI_BT_AWAKE; + /* MCI FIX: enable mci interrupt here */ + ar9003_mci_enable_interrupt(ah); + + return true; + } + } + if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) return -EIO; @@ -1558,12 +1606,29 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, if (ath9k_hw_channel_change(ah, chan)) { ath9k_hw_loadnf(ah, ah->curchan); ath9k_hw_start_nfcal(ah, true); + if (mci && mci_hw->ready) + ar9003_mci_2g5g_switch(ah, true); + if (AR_SREV_9271(ah)) ar9002_hw_load_ani_reg(ah, chan); return 0; } } + if (mci) { + ar9003_mci_disable_interrupt(ah); + + if (mci_hw->ready && !save_fullsleep) { + ar9003_mci_mute_bt(ah); + udelay(20); + REG_WRITE(ah, AR_BTCOEX_CTRL, 0); + } + + mci_hw->bt_state = MCI_BT_SLEEP; + mci_hw->ready = false; + } + + saveDefAntenna = REG_READ(ah, AR_DEF_ANTENNA); if (saveDefAntenna == 0) saveDefAntenna = 1; @@ -1619,6 +1684,9 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, if (r) return r; + if (mci) + ar9003_mci_reset(ah, false, IS_CHAN_2GHZ(chan), save_fullsleep); + /* * Some AR91xx SoC devices frequently fail to accept TSF writes * right after the chip reset. When that happens, write a new @@ -1736,6 +1804,55 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, ath9k_hw_loadnf(ah, chan); ath9k_hw_start_nfcal(ah, true); + if (mci && mci_hw->ready) { + + if (IS_CHAN_2GHZ(chan) && + (mci_hw->bt_state == MCI_BT_SLEEP)) { + + if (ar9003_mci_check_int(ah, + AR_MCI_INTERRUPT_RX_MSG_REMOTE_RESET) || + ar9003_mci_check_int(ah, + AR_MCI_INTERRUPT_RX_MSG_REQ_WAKE)) { + + /* + * BT is sleeping. Check if BT wakes up during + * WLAN calibration. If BT wakes up during + * WLAN calibration, need to go through all + * message exchanges again and recal. + */ + + ath_dbg(common, ATH_DBG_MCI, "MCI BT wakes up" + "during WLAN calibration\n"); + + REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_RAW, + AR_MCI_INTERRUPT_RX_MSG_REMOTE_RESET | + AR_MCI_INTERRUPT_RX_MSG_REQ_WAKE); + ath_dbg(common, ATH_DBG_MCI, "MCI send" + "REMOTE_RESET\n"); + ar9003_mci_remote_reset(ah, true); + ar9003_mci_send_sys_waking(ah, true); + udelay(1); + if (IS_CHAN_2GHZ(chan)) + ar9003_mci_send_lna_transfer(ah, true); + + mci_hw->bt_state = MCI_BT_AWAKE; + + ath_dbg(common, ATH_DBG_MCI, "MCI re-cal\n"); + + if (caldata) { + caldata->done_txiqcal_once = false; + caldata->done_txclcal_once = false; + caldata->rtt_hist.num_readings = 0; + } + + if (!ath9k_hw_init_cal(ah, chan)) + return -EIO; + + } + } + ar9003_mci_enable_interrupt(ah); + } + ENABLE_REGWRITE_BUFFER(ah); ath9k_hw_restore_chainmask(ah); @@ -1778,6 +1895,21 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, if (ah->btcoex_hw.enabled) ath9k_hw_btcoex_enable(ah); + if (mci && mci_hw->ready) { + /* + * check BT state again to make + * sure it's not changed. + */ + + ar9003_mci_sync_bt_state(ah); + ar9003_mci_2g5g_switch(ah, true); + + if ((mci_hw->bt_state == MCI_BT_AWAKE) && + (mci_hw->query_bt == true)) { + mci_hw->need_flush_btinfo = true; + } + } + if (AR_SREV_9300_20_OR_LATER(ah)) { ar9003_hw_bb_watchdog_config(ah); -- cgit v1.2.3 From 19686ddf638cac8c779216bb1f5e53b2666a9035 Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Wed, 30 Nov 2011 10:41:28 +0530 Subject: ath9k: MCI state machine based on MCI interrupt Cc: Wilson Tsao Cc: Senthil Balasubramanian Signed-off-by: Rajkumar Manoharan Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/hw.c | 4 +- drivers/net/wireless/ath/ath9k/init.c | 11 ++ drivers/net/wireless/ath/ath9k/main.c | 3 + drivers/net/wireless/ath/ath9k/mci.c | 341 ++++++++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath9k/mci.h | 1 + 5 files changed, 359 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index e2860d7cd684..5abe682f2513 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -2397,7 +2397,9 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah) pCap->hw_caps |= ATH9K_HW_CAP_4KB_SPLITTRANS; if (common->btcoex_enabled) { - if (AR_SREV_9300_20_OR_LATER(ah)) { + if (AR_SREV_9462(ah)) + btcoex_hw->scheme = ATH_BTCOEX_CFG_MCI; + else if (AR_SREV_9300_20_OR_LATER(ah)) { btcoex_hw->scheme = ATH_BTCOEX_CFG_3WIRE; btcoex_hw->btactive_gpio = ATH_BTACTIVE_GPIO_9300; btcoex_hw->wlanactive_gpio = ATH_WLANACTIVE_GPIO_9300; diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index 34b922bbe65d..e9711e2b48c6 100644 --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c @@ -424,9 +424,17 @@ static int ath9k_init_btcoex(struct ath_softc *sc) return -1; txq = sc->tx.txq_map[WME_AC_BE]; ath9k_hw_init_btcoex_hw(sc->sc_ah, txq->axq_qnum); + sc->btcoex.bt_stomp_type = ATH_BTCOEX_STOMP_LOW; + break; + case ATH_BTCOEX_CFG_MCI: sc->btcoex.bt_stomp_type = ATH_BTCOEX_STOMP_LOW; sc->btcoex.duty_cycle = ATH_BTCOEX_DEF_DUTY_CYCLE; INIT_LIST_HEAD(&sc->btcoex.mci.info); + + r = ath_mci_setup(sc); + if (r) + return r; + if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_MCI) { ah->btcoex_hw.mci.ready = false; ah->btcoex_hw.mci.bt_state = 0; @@ -861,6 +869,9 @@ static void ath9k_deinit_softc(struct ath_softc *sc) sc->sc_ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE) ath_gen_timer_free(sc->sc_ah, sc->btcoex.no_stomp_timer); + if (sc->sc_ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_MCI) + ath_mci_cleanup(sc); + for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) if (ATH_TXQ_SETUP(sc, i)) ath_tx_cleanupq(sc, &sc->tx.txq[i]); diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 90d35f265e3d..fd59c1f25c43 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -742,6 +742,9 @@ void ath9k_tasklet(unsigned long data) if (status & ATH9K_INT_GENTIMER) ath_gen_timer_isr(sc->sc_ah); + if (status & ATH9K_INT_MCI) + ath_mci_intr(sc); + out: /* re-enable hardware interrupt */ ath9k_hw_enable_interrupts(ah); diff --git a/drivers/net/wireless/ath/ath9k/mci.c b/drivers/net/wireless/ath/ath9k/mci.c index 5b246766bde5..d6780405d6f5 100644 --- a/drivers/net/wireless/ath/ath9k/mci.c +++ b/drivers/net/wireless/ath/ath9k/mci.c @@ -184,6 +184,56 @@ static void ath_mci_update_scheme(struct ath_softc *sc) ath9k_btcoex_timer_resume(sc); } + +static void ath_mci_cal_msg(struct ath_softc *sc, u8 opcode, u8 *rx_payload) +{ + struct ath_hw *ah = sc->sc_ah; + struct ath_common *common = ath9k_hw_common(ah); + u32 payload[4] = {0, 0, 0, 0}; + + switch (opcode) { + case MCI_GPM_BT_CAL_REQ: + + ath_dbg(common, ATH_DBG_MCI, "MCI received BT_CAL_REQ\n"); + + if (ar9003_mci_state(ah, MCI_STATE_BT, NULL) == MCI_BT_AWAKE) { + ar9003_mci_state(ah, MCI_STATE_SET_BT_CAL_START, NULL); + ieee80211_queue_work(sc->hw, &sc->hw_reset_work); + } else + ath_dbg(common, ATH_DBG_MCI, + "MCI State mismatches: %d\n", + ar9003_mci_state(ah, MCI_STATE_BT, NULL)); + + break; + + case MCI_GPM_BT_CAL_DONE: + + ath_dbg(common, ATH_DBG_MCI, "MCI received BT_CAL_DONE\n"); + + if (ar9003_mci_state(ah, MCI_STATE_BT, NULL) == MCI_BT_CAL) + ath_dbg(common, ATH_DBG_MCI, "MCI error illegal!\n"); + else + ath_dbg(common, ATH_DBG_MCI, "MCI BT not in CAL state\n"); + + break; + + case MCI_GPM_BT_CAL_GRANT: + + ath_dbg(common, ATH_DBG_MCI, "MCI received BT_CAL_GRANT\n"); + + /* Send WLAN_CAL_DONE for now */ + ath_dbg(common, ATH_DBG_MCI, "MCI send WLAN_CAL_DONE\n"); + MCI_GPM_SET_CAL_TYPE(payload, MCI_GPM_WLAN_CAL_DONE); + ar9003_mci_send_message(sc->sc_ah, MCI_GPM, 0, payload, + 16, false, true); + break; + + default: + ath_dbg(common, ATH_DBG_MCI, "MCI Unknown GPM CAL message\n"); + break; + } +} + void ath_mci_process_profile(struct ath_softc *sc, struct ath_mci_profile_info *info) { @@ -256,6 +306,90 @@ void ath_mci_process_status(struct ath_softc *sc, ath_mci_update_scheme(sc); } +static void ath_mci_msg(struct ath_softc *sc, u8 opcode, u8 *rx_payload) +{ + struct ath_hw *ah = sc->sc_ah; + struct ath_mci_profile_info profile_info; + struct ath_mci_profile_status profile_status; + struct ath_common *common = ath9k_hw_common(sc->sc_ah); + u32 version; + u8 major; + u8 minor; + u32 seq_num; + + switch (opcode) { + + case MCI_GPM_COEX_VERSION_QUERY: + ath_dbg(common, ATH_DBG_MCI, + "MCI Recv GPM COEX Version Query.\n"); + version = ar9003_mci_state(ah, + MCI_STATE_SEND_WLAN_COEX_VERSION, NULL); + break; + + case MCI_GPM_COEX_VERSION_RESPONSE: + ath_dbg(common, ATH_DBG_MCI, + "MCI Recv GPM COEX Version Response.\n"); + major = *(rx_payload + MCI_GPM_COEX_B_MAJOR_VERSION); + minor = *(rx_payload + MCI_GPM_COEX_B_MINOR_VERSION); + ath_dbg(common, ATH_DBG_MCI, + "MCI BT Coex version: %d.%d\n", major, minor); + version = (major << 8) + minor; + version = ar9003_mci_state(ah, + MCI_STATE_SET_BT_COEX_VERSION, &version); + break; + + case MCI_GPM_COEX_STATUS_QUERY: + ath_dbg(common, ATH_DBG_MCI, + "MCI Recv GPM COEX Status Query = 0x%02x.\n", + *(rx_payload + MCI_GPM_COEX_B_WLAN_BITMAP)); + ar9003_mci_state(ah, + MCI_STATE_SEND_WLAN_CHANNELS, NULL); + break; + + case MCI_GPM_COEX_BT_PROFILE_INFO: + ath_dbg(common, ATH_DBG_MCI, + "MCI Recv GPM Coex BT profile info\n"); + memcpy(&profile_info, + (rx_payload + MCI_GPM_COEX_B_PROFILE_TYPE), 10); + + if ((profile_info.type == MCI_GPM_COEX_PROFILE_UNKNOWN) + || (profile_info.type >= + MCI_GPM_COEX_PROFILE_MAX)) { + + ath_dbg(common, ATH_DBG_MCI, + "illegal profile type = %d," + "state = %d\n", profile_info.type, + profile_info.start); + break; + } + + ath_mci_process_profile(sc, &profile_info); + break; + + case MCI_GPM_COEX_BT_STATUS_UPDATE: + profile_status.is_link = *(rx_payload + + MCI_GPM_COEX_B_STATUS_TYPE); + profile_status.conn_handle = *(rx_payload + + MCI_GPM_COEX_B_STATUS_LINKID); + profile_status.is_critical = *(rx_payload + + MCI_GPM_COEX_B_STATUS_STATE); + + seq_num = *((u32 *)(rx_payload + 12)); + ath_dbg(common, ATH_DBG_MCI, + "MCI Recv GPM COEX BT_Status_Update: " + "is_link=%d, linkId=%d, state=%d, SEQ=%d\n", + profile_status.is_link, profile_status.conn_handle, + profile_status.is_critical, seq_num); + + ath_mci_process_status(sc, &profile_status); + break; + + default: + ath_dbg(common, ATH_DBG_MCI, + "MCI Unknown GPM COEX message = 0x%02x\n", opcode); + break; + } +} static int ath_mci_buf_alloc(struct ath_softc *sc, struct ath_mci_buf *buf) { @@ -330,3 +464,210 @@ void ath_mci_cleanup(struct ath_softc *sc) ath_mci_buf_free(sc, &mci->sched_buf); ar9003_mci_cleanup(ah); } + +void ath_mci_intr(struct ath_softc *sc) +{ + struct ath_mci_coex *mci = &sc->mci_coex; + struct ath_hw *ah = sc->sc_ah; + struct ath_common *common = ath9k_hw_common(ah); + u32 mci_int, mci_int_rxmsg; + u32 offset, subtype, opcode; + u32 *pgpm; + u32 more_data = MCI_GPM_MORE; + bool skip_gpm = false; + + ar9003_mci_get_interrupt(sc->sc_ah, &mci_int, &mci_int_rxmsg); + + if (ar9003_mci_state(ah, MCI_STATE_ENABLE, NULL) == 0) { + + ar9003_mci_state(sc->sc_ah, MCI_STATE_INIT_GPM_OFFSET, NULL); + ath_dbg(common, ATH_DBG_MCI, + "MCI interrupt but MCI disabled\n"); + + ath_dbg(common, ATH_DBG_MCI, + "MCI interrupt: intr = 0x%x, intr_rxmsg = 0x%x\n", + mci_int, mci_int_rxmsg); + return; + } + + if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_REQ_WAKE) { + u32 payload[4] = { 0xffffffff, 0xffffffff, + 0xffffffff, 0xffffff00}; + + /* + * The following REMOTE_RESET and SYS_WAKING used to sent + * only when BT wake up. Now they are always sent, as a + * recovery method to reset BT MCI's RX alignment. + */ + ath_dbg(common, ATH_DBG_MCI, "MCI interrupt send REMOTE_RESET\n"); + + ar9003_mci_send_message(ah, MCI_REMOTE_RESET, 0, + payload, 16, true, false); + ath_dbg(common, ATH_DBG_MCI, "MCI interrupt send SYS_WAKING\n"); + ar9003_mci_send_message(ah, MCI_SYS_WAKING, 0, + NULL, 0, true, false); + + mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_REQ_WAKE; + ar9003_mci_state(ah, MCI_STATE_RESET_REQ_WAKE, NULL); + + /* + * always do this for recovery and 2G/5G toggling and LNA_TRANS + */ + ath_dbg(common, ATH_DBG_MCI, "MCI Set BT state to AWAKE.\n"); + ar9003_mci_state(ah, MCI_STATE_SET_BT_AWAKE, NULL); + } + + /* Processing SYS_WAKING/SYS_SLEEPING */ + if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_SYS_WAKING) { + mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_SYS_WAKING; + + if (ar9003_mci_state(ah, MCI_STATE_BT, NULL) == MCI_BT_SLEEP) { + + if (ar9003_mci_state(ah, MCI_STATE_REMOTE_SLEEP, NULL) + == MCI_BT_SLEEP) + ath_dbg(common, ATH_DBG_MCI, + "MCI BT stays in sleep mode\n"); + else { + ath_dbg(common, ATH_DBG_MCI, + "MCI Set BT state to AWAKE.\n"); + ar9003_mci_state(ah, + MCI_STATE_SET_BT_AWAKE, NULL); + } + } else + ath_dbg(common, ATH_DBG_MCI, + "MCI BT stays in AWAKE mode.\n"); + } + + if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_SYS_SLEEPING) { + + mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_SYS_SLEEPING; + + if (ar9003_mci_state(ah, MCI_STATE_BT, NULL) == MCI_BT_AWAKE) { + + if (ar9003_mci_state(ah, MCI_STATE_REMOTE_SLEEP, NULL) + == MCI_BT_AWAKE) + ath_dbg(common, ATH_DBG_MCI, + "MCI BT stays in AWAKE mode.\n"); + else { + ath_dbg(common, ATH_DBG_MCI, + "MCI SetBT state to SLEEP\n"); + ar9003_mci_state(ah, MCI_STATE_SET_BT_SLEEP, + NULL); + } + } else + ath_dbg(common, ATH_DBG_MCI, + "MCI BT stays in SLEEP mode\n"); + } + + if ((mci_int & AR_MCI_INTERRUPT_RX_INVALID_HDR) || + (mci_int & AR_MCI_INTERRUPT_CONT_INFO_TIMEOUT)) { + + ath_dbg(common, ATH_DBG_MCI, "MCI RX broken, skip GPM msgs\n"); + ar9003_mci_state(ah, MCI_STATE_RECOVER_RX, NULL); + skip_gpm = true; + } + + if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_SCHD_INFO) { + + mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_SCHD_INFO; + offset = ar9003_mci_state(ah, MCI_STATE_LAST_SCHD_MSG_OFFSET, + NULL); + } + + if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_GPM) { + + mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_GPM; + + while (more_data == MCI_GPM_MORE) { + + pgpm = mci->gpm_buf.bf_addr; + offset = ar9003_mci_state(ah, + MCI_STATE_NEXT_GPM_OFFSET, &more_data); + + if (offset == MCI_GPM_INVALID) + break; + + pgpm += (offset >> 2); + + /* + * The first dword is timer. + * The real data starts from 2nd dword. + */ + + subtype = MCI_GPM_TYPE(pgpm); + opcode = MCI_GPM_OPCODE(pgpm); + + if (!skip_gpm) { + + if (MCI_GPM_IS_CAL_TYPE(subtype)) + ath_mci_cal_msg(sc, subtype, + (u8 *) pgpm); + else { + switch (subtype) { + case MCI_GPM_COEX_AGENT: + ath_mci_msg(sc, opcode, + (u8 *) pgpm); + break; + default: + break; + } + } + } + MCI_GPM_RECYCLE(pgpm); + } + } + + if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_HW_MSG_MASK) { + + if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_LNA_CONTROL) + mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_LNA_CONTROL; + + if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_LNA_INFO) { + mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_LNA_INFO; + ath_dbg(common, ATH_DBG_MCI, "MCI LNA_INFO\n"); + } + + if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_CONT_INFO) { + + int value_dbm = ar9003_mci_state(ah, + MCI_STATE_CONT_RSSI_POWER, NULL); + + mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_CONT_INFO; + + if (ar9003_mci_state(ah, MCI_STATE_CONT_TXRX, NULL)) + ath_dbg(common, ATH_DBG_MCI, + "MCI CONT_INFO: " + "(tx) pri = %d, pwr = %d dBm\n", + ar9003_mci_state(ah, + MCI_STATE_CONT_PRIORITY, NULL), + value_dbm); + else + ath_dbg(common, ATH_DBG_MCI, + "MCI CONT_INFO:" + "(rx) pri = %d,pwr = %d dBm\n", + ar9003_mci_state(ah, + MCI_STATE_CONT_PRIORITY, NULL), + value_dbm); + } + + if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_CONT_NACK) { + mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_CONT_NACK; + ath_dbg(common, ATH_DBG_MCI, "MCI CONT_NACK\n"); + } + + if (mci_int_rxmsg & AR_MCI_INTERRUPT_RX_MSG_CONT_RST) { + mci_int_rxmsg &= ~AR_MCI_INTERRUPT_RX_MSG_CONT_RST; + ath_dbg(common, ATH_DBG_MCI, "MCI CONT_RST\n"); + } + } + + if ((mci_int & AR_MCI_INTERRUPT_RX_INVALID_HDR) || + (mci_int & AR_MCI_INTERRUPT_CONT_INFO_TIMEOUT)) + mci_int &= ~(AR_MCI_INTERRUPT_RX_INVALID_HDR | + AR_MCI_INTERRUPT_CONT_INFO_TIMEOUT); + + if (mci_int_rxmsg & 0xfffffffe) + ath_dbg(common, ATH_DBG_MCI, + "MCI not processed mci_int_rxmsg = 0x%x\n", + mci_int_rxmsg); +} diff --git a/drivers/net/wireless/ath/ath9k/mci.h b/drivers/net/wireless/ath/ath9k/mci.h index 4eeb0feafc06..b71bdeda7c78 100644 --- a/drivers/net/wireless/ath/ath9k/mci.h +++ b/drivers/net/wireless/ath/ath9k/mci.h @@ -134,4 +134,5 @@ void ath_mci_process_status(struct ath_softc *sc, struct ath_mci_profile_status *status); int ath_mci_setup(struct ath_softc *sc); void ath_mci_cleanup(struct ath_softc *sc); +void ath_mci_intr(struct ath_softc *sc); #endif -- cgit v1.2.3 From 32b1076dc139881abaca772b2e3666ff547a0750 Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Wed, 30 Nov 2011 10:41:29 +0530 Subject: ath9k: fix a typo Cc: Wilson Tsao Cc: Senthil Balasubramanian Signed-off-by: Rajkumar Manoharan Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/btcoex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/btcoex.c b/drivers/net/wireless/ath/ath9k/btcoex.c index 9ac28d9de597..bbb20810ec10 100644 --- a/drivers/net/wireless/ath/ath9k/btcoex.c +++ b/drivers/net/wireless/ath/ath9k/btcoex.c @@ -21,7 +21,7 @@ enum ath_bt_mode { ATH_BT_COEX_MODE_LEGACY, /* legacy rx_clear mode */ ATH_BT_COEX_MODE_UNSLOTTED, /* untimed/unslotted mode */ ATH_BT_COEX_MODE_SLOTTED, /* slotted mode */ - ATH_BT_COEX_MODE_DISALBED, /* coexistence disabled */ + ATH_BT_COEX_MODE_DISABLED, /* coexistence disabled */ }; struct ath_btcoex_config { -- cgit v1.2.3 From 7468722b681ff4ea3f2cb612a28943c01c1b492a Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Wed, 30 Nov 2011 14:18:38 +0530 Subject: ath9k: minor cleanup Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/recv.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c index b1b0ec76157b..e0318415c2a0 100644 --- a/drivers/net/wireless/ath/ath9k/recv.c +++ b/drivers/net/wireless/ath/ath9k/recv.c @@ -475,7 +475,6 @@ u32 ath_calcrxfilter(struct ath_softc *sc) return rfilt; -#undef RX_FILTER_PRESERVE } int ath_startrecv(struct ath_softc *sc) -- cgit v1.2.3 From ad9547c0413686a23e48793665a9ebd3e65c474c Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 30 Nov 2011 11:49:38 +0300 Subject: brcm80211: fmac: small memory leak on error We should free "bus_if" here, it's a small leak but it makes the static checkers happy. Signed-off-by: Dan Carpenter Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c index 77f84f8a0081..b416e274c677 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -477,8 +477,10 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, if (!bus_if) return -ENOMEM; sdiodev = kzalloc(sizeof(struct brcmf_sdio_dev), GFP_KERNEL); - if (!sdiodev) + if (!sdiodev) { + kfree(bus_if); return -ENOMEM; + } sdiodev->dev = &func->card->dev; sdiodev->func[0] = func->card->sdio_func[0]; sdiodev->func[1] = func; -- cgit v1.2.3 From 6fea593d9c0e3ad8014c4080e95cb93e42c8915c Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Wed, 30 Nov 2011 21:01:31 +0530 Subject: ath9k_hw: Fix TX IQ calibration for AR9003 only for AR9485 (or) later chipsets TxIQ calibration runs as part of AGC calibration. without this patch TX IQ cal completion i.e. ar9003_hw_tx_iq_cal_run won't be executed for AR9003 Reviewed-by: Rajkumar Manoharan Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/hw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 5abe682f2513..5aa75c33d4a2 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -2497,7 +2497,7 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah) if (AR_SREV_9300_20_OR_LATER(ah)) { ah->enabled_cals |= TX_IQ_CAL; - if (!AR_SREV_9330(ah)) + if (AR_SREV_9485_OR_LATER(ah)) ah->enabled_cals |= TX_IQ_ON_AGC_CAL; } if (AR_SREV_9462(ah)) -- cgit v1.2.3 From ba5736a5e9ac20c378ae4179e8a0ed3cc4b44351 Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Wed, 30 Nov 2011 21:10:52 +0530 Subject: ath9k_hw: add default chainmask for AR9462 the default tx/rx chainmask for AR9462 is 0x3. this patch helps to assign 0x3 rather than 0x7 for AR9462 with the help of fix_chainmask module if something goes wrong in reading tx/rx chain mask from OTP/EEPROM card(though its very unlikely) Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/hw.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 5aa75c33d4a2..6ceb2e188080 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -2312,6 +2312,8 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah) if (AR_SREV_9485(ah) || AR_SREV_9285(ah) || AR_SREV_9330(ah)) chip_chainmask = 1; + else if (AR_SREV_9462(ah)) + chip_chainmask = 3; else if (!AR_SREV_9280_20_OR_LATER(ah)) chip_chainmask = 7; else if (!AR_SREV_9300_20_OR_LATER(ah) || AR_SREV_9340(ah)) -- cgit v1.2.3 From 2131d3c2f99b081806fdae7662c92fe6acda52af Mon Sep 17 00:00:00 2001 From: Pontus Fuchs Date: Tue, 18 Oct 2011 09:23:41 +0200 Subject: wl12xx: Validate FEM index from ini file and FW Check for out of bound FEM index to prevent reading beyond ini memory end. Signed-off-by: Pontus Fuchs Cc: stable@kernel.org Reviewed-by: Luciano Coelho Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/cmd.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c index afd597387e7e..e0d217979485 100644 --- a/drivers/net/wireless/wl12xx/cmd.c +++ b/drivers/net/wireless/wl12xx/cmd.c @@ -121,6 +121,11 @@ int wl1271_cmd_general_parms(struct wl1271 *wl) if (!wl->nvs) return -ENODEV; + if (gp->tx_bip_fem_manufacturer >= WL1271_INI_FEM_MODULE_COUNT) { + wl1271_warning("FEM index from INI out of bounds"); + return -EINVAL; + } + gen_parms = kzalloc(sizeof(*gen_parms), GFP_KERNEL); if (!gen_parms) return -ENOMEM; @@ -144,6 +149,12 @@ int wl1271_cmd_general_parms(struct wl1271 *wl) gp->tx_bip_fem_manufacturer = gen_parms->general_params.tx_bip_fem_manufacturer; + if (gp->tx_bip_fem_manufacturer >= WL1271_INI_FEM_MODULE_COUNT) { + wl1271_warning("FEM index from FW out of bounds"); + ret = -EINVAL; + goto out; + } + wl1271_debug(DEBUG_CMD, "FEM autodetect: %s, manufacturer: %d\n", answer ? "auto" : "manual", gp->tx_bip_fem_manufacturer); @@ -163,6 +174,11 @@ int wl128x_cmd_general_parms(struct wl1271 *wl) if (!wl->nvs) return -ENODEV; + if (gp->tx_bip_fem_manufacturer >= WL1271_INI_FEM_MODULE_COUNT) { + wl1271_warning("FEM index from ini out of bounds"); + return -EINVAL; + } + gen_parms = kzalloc(sizeof(*gen_parms), GFP_KERNEL); if (!gen_parms) return -ENOMEM; @@ -187,6 +203,12 @@ int wl128x_cmd_general_parms(struct wl1271 *wl) gp->tx_bip_fem_manufacturer = gen_parms->general_params.tx_bip_fem_manufacturer; + if (gp->tx_bip_fem_manufacturer >= WL1271_INI_FEM_MODULE_COUNT) { + wl1271_warning("FEM index from FW out of bounds"); + ret = -EINVAL; + goto out; + } + wl1271_debug(DEBUG_CMD, "FEM autodetect: %s, manufacturer: %d\n", answer ? "auto" : "manual", gp->tx_bip_fem_manufacturer); -- cgit v1.2.3 From f6efe96edd9c41c624c8f4ddbc4930c1a2d8f1e1 Mon Sep 17 00:00:00 2001 From: Pontus Fuchs Date: Tue, 18 Oct 2011 09:23:42 +0200 Subject: wl12xx: Check buffer bound when processing nvs data An nvs with malformed contents could cause the processing of the calibration data to read beyond the end of the buffer. Prevent this from happening by adding bound checking. Signed-off-by: Pontus Fuchs Cc: stable@kernel.org Reviewed-by: Luciano Coelho Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/boot.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/boot.c b/drivers/net/wireless/wl12xx/boot.c index 6e140bf4e236..8f9cf5a816ea 100644 --- a/drivers/net/wireless/wl12xx/boot.c +++ b/drivers/net/wireless/wl12xx/boot.c @@ -348,6 +348,9 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl) nvs_ptr += 3; for (i = 0; i < burst_len; i++) { + if (nvs_ptr + 3 >= (u8 *) wl->nvs + nvs_len) + goto out_badnvs; + val = (nvs_ptr[0] | (nvs_ptr[1] << 8) | (nvs_ptr[2] << 16) | (nvs_ptr[3] << 24)); @@ -359,6 +362,9 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl) nvs_ptr += 4; dest_addr += 4; } + + if (nvs_ptr >= (u8 *) wl->nvs + nvs_len) + goto out_badnvs; } /* @@ -370,6 +376,10 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl) */ nvs_ptr = (u8 *)wl->nvs + ALIGN(nvs_ptr - (u8 *)wl->nvs + 7, 4); + + if (nvs_ptr >= (u8 *) wl->nvs + nvs_len) + goto out_badnvs; + nvs_len -= nvs_ptr - (u8 *)wl->nvs; /* Now we must set the partition correctly */ @@ -385,6 +395,10 @@ static int wl1271_boot_upload_nvs(struct wl1271 *wl) kfree(nvs_aligned); return 0; + +out_badnvs: + wl1271_error("nvs data is malformed"); + return -EILSEQ; } static void wl1271_boot_enable_interrupts(struct wl1271 *wl) -- cgit v1.2.3 From 560f00241b6d95bde73a570c29d6919b36fdf852 Mon Sep 17 00:00:00 2001 From: Arik Nemtsov Date: Tue, 8 Nov 2011 18:46:54 +0200 Subject: wl12xx: configure probe-resp template according to notification When operating in AP-mode, replace our probe-response template when a notification is recieved from mac80211. We preserve the "legacy" way of configuring a probe-response according to beacon for IBSS mode and for versions of hostapd that do not support this feature. Signed-off-by: Guy Eilam Signed-off-by: Arik Nemtsov Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 57 +++++++++++++++++++++++++++++++----- drivers/net/wireless/wl12xx/wl12xx.h | 1 + 2 files changed, 51 insertions(+), 7 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index dbb088eadf71..3750a6e479f3 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -3299,11 +3299,30 @@ static void wl12xx_remove_vendor_ie(struct sk_buff *skb, skb_trim(skb, skb->len - len); } -static int wl1271_ap_set_probe_resp_tmpl(struct wl1271 *wl, - struct ieee80211_vif *vif, - u8 *probe_rsp_data, - size_t probe_rsp_len, - u32 rates) +static int wl1271_ap_set_probe_resp_tmpl(struct wl1271 *wl, u32 rates) +{ + struct sk_buff *skb; + int ret; + + skb = ieee80211_proberesp_get(wl->hw, wl->vif); + if (!skb) + return -EINVAL; + + ret = wl1271_cmd_template_set(wl, + CMD_TEMPL_AP_PROBE_RESPONSE, + skb->data, + skb->len, 0, + rates); + + dev_kfree_skb(skb); + return ret; +} + +static int wl1271_ap_set_probe_resp_tmpl_legacy(struct wl1271 *wl, + struct ieee80211_vif *vif, + u8 *probe_rsp_data, + size_t probe_rsp_len, + u32 rates) { struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif); struct ieee80211_bss_conf *bss_conf = &vif->bss_conf; @@ -3416,6 +3435,16 @@ static int wl1271_bss_beacon_info_changed(struct wl1271 *wl, wlvif->beacon_int = bss_conf->beacon_int; } + if ((changed & BSS_CHANGED_AP_PROBE_RESP) && is_ap) { + u32 rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); + ret = wl1271_ap_set_probe_resp_tmpl(wl, rate); + if (ret < 0) + goto out; + + wl1271_debug(DEBUG_AP, "probe response updated"); + set_bit(WLVIF_FLAG_AP_PROBE_RESP_SET, &wlvif->flags); + } + if ((changed & BSS_CHANGED_BEACON)) { struct ieee80211_hdr *hdr; u32 min_rate; @@ -3424,8 +3453,10 @@ static int wl1271_bss_beacon_info_changed(struct wl1271 *wl, struct sk_buff *beacon = ieee80211_beacon_get(wl->hw, vif); u16 tmpl_id; - if (!beacon) + if (!beacon) { + ret = -EINVAL; goto out; + } wl1271_debug(DEBUG_MASTER, "beacon updated"); @@ -3446,6 +3477,13 @@ static int wl1271_bss_beacon_info_changed(struct wl1271 *wl, goto out; } + /* + * In case we already have a probe-resp beacon set explicitly + * by usermode, don't use the beacon data. + */ + if (test_bit(WLVIF_FLAG_AP_PROBE_RESP_SET, &wlvif->flags)) + goto end_bcn; + /* remove TIM ie from probe response */ wl12xx_remove_ie(beacon, WLAN_EID_TIM, ieoffset); @@ -3464,7 +3502,7 @@ static int wl1271_bss_beacon_info_changed(struct wl1271 *wl, hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); if (is_ap) - ret = wl1271_ap_set_probe_resp_tmpl(wl, vif, + ret = wl1271_ap_set_probe_resp_tmpl_legacy(wl, vif, beacon->data, beacon->len, min_rate); @@ -3474,12 +3512,15 @@ static int wl1271_bss_beacon_info_changed(struct wl1271 *wl, beacon->data, beacon->len, 0, min_rate); +end_bcn: dev_kfree_skb(beacon); if (ret < 0) goto out; } out: + if (ret != 0) + wl1271_error("beacon info change failed: %d", ret); return ret; } @@ -3536,6 +3577,8 @@ static void wl1271_bss_info_changed_ap(struct wl1271 *wl, goto out; clear_bit(WLVIF_FLAG_AP_STARTED, &wlvif->flags); + clear_bit(WLVIF_FLAG_AP_PROBE_RESP_SET, + &wlvif->flags); wl1271_debug(DEBUG_AP, "stopped AP"); } } diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index e58e801f7aea..f1c911774bfd 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -268,6 +268,7 @@ enum wl12xx_vif_flags { WLVIF_FLAG_RX_STREAMING_STARTED, WLVIF_FLAG_PSPOLL_FAILURE, WLVIF_FLAG_CS_PROGRESS, + WLVIF_FLAG_AP_PROBE_RESP_SET, }; struct wl1271_link { -- cgit v1.2.3 From 9c1b190b10972be9c0d53c658e537c54de530b7f Mon Sep 17 00:00:00 2001 From: Arik Nemtsov Date: Tue, 8 Nov 2011 18:46:55 +0200 Subject: wl12xx: indicate probe-resp offloading support The wl12xx driver supports probe-response offloading, and the WPS, WPS2 and P2P special cases as well. Signed-off-by: Guy Eilam Signed-off-by: Arik Nemtsov Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 3750a6e479f3..08b06ee6d515 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -5017,6 +5017,13 @@ static int wl1271_init_ieee80211(struct wl1271 *wl) wl->hw->wiphy->reg_notifier = wl1271_reg_notify; + /* the FW answers probe-requests in AP-mode */ + wl->hw->wiphy->flags |= WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD; + wl->hw->wiphy->probe_resp_offload = + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS | + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2 | + NL80211_PROBE_RESP_OFFLOAD_SUPPORT_P2P; + SET_IEEE80211_DEV(wl->hw, wl->dev); wl->hw->sta_data_size = sizeof(struct wl1271_station); -- cgit v1.2.3 From 97127e67218e5970a5a7df0513ded730b19a67e9 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 9 Nov 2011 13:12:45 +0200 Subject: wl12xx: init CMD_TEMPL_KLV to sizeof(ieee80211_qos_hdr) The keep alive template should have a max size of sizeof(struct ieee80211_qos_hdr). Additionally, Remove the redundant wl12xx_qos_null_data_template struct. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/init.c | 6 +++--- drivers/net/wireless/wl12xx/wl12xx_80211.h | 5 ----- 2 files changed, 3 insertions(+), 8 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index c413abd26d1c..88891cdfdd4a 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -65,7 +65,7 @@ int wl1271_init_templates_config(struct wl1271 *wl) ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, NULL, sizeof - (struct wl12xx_qos_null_data_template), + (struct ieee80211_qos_hdr), 0, WL1271_RATE_AUTOMATIC); if (ret < 0) return ret; @@ -114,8 +114,8 @@ int wl1271_init_templates_config(struct wl1271 *wl) for (i = 0; i < CMD_TEMPL_KLV_IDX_MAX; i++) { ret = wl1271_cmd_template_set(wl, CMD_TEMPL_KLV, NULL, - WL1271_CMD_TEMPL_DFLT_SIZE, i, - WL1271_RATE_AUTOMATIC); + sizeof(struct ieee80211_qos_hdr), + i, WL1271_RATE_AUTOMATIC); if (ret < 0) return ret; } diff --git a/drivers/net/wireless/wl12xx/wl12xx_80211.h b/drivers/net/wireless/wl12xx/wl12xx_80211.h index f7971d3b0898..8f0ffaf62309 100644 --- a/drivers/net/wireless/wl12xx/wl12xx_80211.h +++ b/drivers/net/wireless/wl12xx/wl12xx_80211.h @@ -116,11 +116,6 @@ struct wl12xx_ps_poll_template { u8 ta[ETH_ALEN]; } __packed; -struct wl12xx_qos_null_data_template { - struct ieee80211_header header; - __le16 qos_ctl; -} __packed; - struct wl12xx_arp_rsp_template { struct ieee80211_hdr_3addr hdr; -- cgit v1.2.3 From 341f2c11b5ce7689d3f0acb04574fe6424aa6be0 Mon Sep 17 00:00:00 2001 From: Arik Nemtsov Date: Tue, 22 Nov 2011 19:52:59 +0200 Subject: wl12xx: avoid bail out when probe-resp is not set by mac80211 During reconfig we can get the BSS_CHANGED_AP_PROBE_RESP indication even if a probe-resp has not been set in the first place. Therefore ignore the error when not getting a probe-resp from mac80211. Resort to the legacy probe-resp in this case. Also take this opportunity to add a vif argument to the set_probe_resp function. Reported-by: Eliad Peller Signed-off-by: Arik Nemtsov Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 08b06ee6d515..8c58001c76d4 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -3299,14 +3299,15 @@ static void wl12xx_remove_vendor_ie(struct sk_buff *skb, skb_trim(skb, skb->len - len); } -static int wl1271_ap_set_probe_resp_tmpl(struct wl1271 *wl, u32 rates) +static int wl1271_ap_set_probe_resp_tmpl(struct wl1271 *wl, u32 rates, + struct ieee80211_vif *vif) { struct sk_buff *skb; int ret; - skb = ieee80211_proberesp_get(wl->hw, wl->vif); + skb = ieee80211_proberesp_get(wl->hw, vif); if (!skb) - return -EINVAL; + return -EOPNOTSUPP; ret = wl1271_cmd_template_set(wl, CMD_TEMPL_AP_PROBE_RESPONSE, @@ -3437,12 +3438,10 @@ static int wl1271_bss_beacon_info_changed(struct wl1271 *wl, if ((changed & BSS_CHANGED_AP_PROBE_RESP) && is_ap) { u32 rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set); - ret = wl1271_ap_set_probe_resp_tmpl(wl, rate); - if (ret < 0) - goto out; - - wl1271_debug(DEBUG_AP, "probe response updated"); - set_bit(WLVIF_FLAG_AP_PROBE_RESP_SET, &wlvif->flags); + if (!wl1271_ap_set_probe_resp_tmpl(wl, rate, vif)) { + wl1271_debug(DEBUG_AP, "probe response updated"); + set_bit(WLVIF_FLAG_AP_PROBE_RESP_SET, &wlvif->flags); + } } if ((changed & BSS_CHANGED_BEACON)) { -- cgit v1.2.3 From 358989352e70975d1c50ac2a49fc86d41d0518bd Mon Sep 17 00:00:00 2001 From: Pontus Fuchs Date: Wed, 30 Nov 2011 15:35:09 +0100 Subject: wl12xx: Print nvs/fw file name if loading fails. Print the name of nvs/fw if request_firmware fails. This will make troubleshooting a bit easier. Signed-off-by: Pontus Fuchs Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 8c58001c76d4..8ff1bf5be013 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1055,7 +1055,7 @@ static int wl1271_fetch_firmware(struct wl1271 *wl) ret = request_firmware(&fw, fw_name, wl->dev); if (ret < 0) { - wl1271_error("could not get firmware: %d", ret); + wl1271_error("could not get firmware %s: %d", fw_name, ret); return ret; } @@ -1093,7 +1093,8 @@ static int wl1271_fetch_nvs(struct wl1271 *wl) ret = request_firmware(&fw, WL12XX_NVS_NAME, wl->dev); if (ret < 0) { - wl1271_error("could not get nvs file: %d", ret); + wl1271_error("could not get nvs file %s: %d", WL12XX_NVS_NAME, + ret); return ret; } -- cgit v1.2.3 From 12d4b9759143aaa280195834820bc15d795e71c1 Mon Sep 17 00:00:00 2001 From: Arik Nemtsov Date: Sun, 23 Oct 2011 08:21:54 +0200 Subject: wl12xx: leave IV calculation to HW for CCMP Use an appropriate mac80211 flags in CCMP keys to indicate we are calculating the CCMP IV in HW, but require room for the IV to be reserved in the skb. The space is reserved by mac80211. depends on "mac80211: support adding IV-room in the skb for CCMP keys". Signed-off-by: Arik Nemtsov Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 8ff1bf5be013..d1416752feea 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -2986,7 +2986,7 @@ static int wl1271_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, case WLAN_CIPHER_SUITE_CCMP: key_type = KEY_AES; - key_conf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; + key_conf->flags |= IEEE80211_KEY_FLAG_PUT_IV_SPACE; tx_seq_32 = WL1271_TX_SECURITY_HI32(wlvif->tx_security_seq); tx_seq_16 = WL1271_TX_SECURITY_LO16(wlvif->tx_security_seq); break; -- cgit v1.2.3 From e0d62536d032db689adf9c8162a9d2caf4714f44 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 8 Nov 2011 16:07:52 +0200 Subject: wl12xx: don't explicitly check for unjoined ibss After the ibss carrier issue was fixed, we can revert the following patch: commit 48309fd477ef867babb6819f67fe082c133a5fa9 Author: Shahar Lev Date: Fri Oct 7 18:17:25 2011 +0200 wl12xx: remove warning message during IBSS Tx mac80211 sets the carrier on an IBSS interface even when no network is joined. Ignore garbage frames transmitted on a disconnected IBSS interface without printing warnings. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/tx.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index fa518a5b7c8b..36eb0d66fd66 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -427,15 +427,7 @@ static int wl1271_prepare_tx_frame(struct wl1271 *wl, struct wl12xx_vif *wlvif, } hlid = wl12xx_tx_get_hlid(wl, wlvif, skb); if (hlid == WL12XX_INVALID_LINK_ID) { - if (wlvif->bss_type == BSS_TYPE_IBSS && - !test_bit(WLVIF_FLAG_IBSS_JOINED, &wlvif->flags)) { - /* It's ok to drop packets when not joined to IBSS */ - wl1271_debug(DEBUG_TX, "dropping skb while IBSS not " - " joined"); - } else { - wl1271_error("invalid hlid. dropping skb 0x%p", skb); - } - + wl1271_error("invalid hlid. dropping skb 0x%p", skb); return -EINVAL; } -- cgit v1.2.3 From 137ce797e24855b738ef98411acbf88c6d918f27 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Tue, 22 Nov 2011 16:23:35 -0800 Subject: iwlwifi: do not re-configure HT40 after associated The ht40 setting should not change after association unless channel switch This fix a problem we are seeing which cause uCode assert because driver sending invalid information and make uCode confuse Here is the firmware assert message: kernel: iwlagn 0000:03:00.0: Microcode SW error detected. Restarting 0x82000000. kernel: iwlagn 0000:03:00.0: Loaded firmware version: 17.168.5.3 build 42301 kernel: iwlagn 0000:03:00.0: Start IWL Error Log Dump: kernel: iwlagn 0000:03:00.0: Status: 0x000512E4, count: 6 kernel: iwlagn 0000:03:00.0: 0x00002078 | ADVANCED_SYSASSERT kernel: iwlagn 0000:03:00.0: 0x00009514 | uPc kernel: iwlagn 0000:03:00.0: 0x00009496 | branchlink1 kernel: iwlagn 0000:03:00.0: 0x00009496 | branchlink2 kernel: iwlagn 0000:03:00.0: 0x0000D1F2 | interruptlink1 kernel: iwlagn 0000:03:00.0: 0x00000000 | interruptlink2 kernel: iwlagn 0000:03:00.0: 0x01008035 | data1 kernel: iwlagn 0000:03:00.0: 0x0000C90F | data2 kernel: iwlagn 0000:03:00.0: 0x000005A7 | line kernel: iwlagn 0000:03:00.0: 0x5080B520 | beacon time kernel: iwlagn 0000:03:00.0: 0xCC515AE0 | tsf low kernel: iwlagn 0000:03:00.0: 0x00000003 | tsf hi kernel: iwlagn 0000:03:00.0: 0x00000000 | time gp1 kernel: iwlagn 0000:03:00.0: 0x29703BF0 | time gp2 kernel: iwlagn 0000:03:00.0: 0x00000000 | time gp3 kernel: iwlagn 0000:03:00.0: 0x000111A8 | uCode version kernel: iwlagn 0000:03:00.0: 0x000000B0 | hw version kernel: iwlagn 0000:03:00.0: 0x00480303 | board version kernel: iwlagn 0000:03:00.0: 0x09E8004E | hcmd kernel: iwlagn 0000:03:00.0: CSR values: kernel: iwlagn 0000:03:00.0: (2nd byte of CSR_INT_COALESCING is CSR_INT_PERIODIC_REG) kernel: iwlagn 0000:03:00.0: CSR_HW_IF_CONFIG_REG: 0X00480303 kernel: iwlagn 0000:03:00.0: CSR_INT_COALESCING: 0X0000ff40 kernel: iwlagn 0000:03:00.0: CSR_INT: 0X00000000 kernel: iwlagn 0000:03:00.0: CSR_INT_MASK: 0X00000000 kernel: iwlagn 0000:03:00.0: CSR_FH_INT_STATUS: 0X00000000 kernel: iwlagn 0000:03:00.0: CSR_GPIO_IN: 0X00000030 kernel: iwlagn 0000:03:00.0: CSR_RESET: 0X00000000 kernel: iwlagn 0000:03:00.0: CSR_GP_CNTRL: 0X080403c5 kernel: iwlagn 0000:03:00.0: CSR_HW_REV: 0X000000b0 kernel: iwlagn 0000:03:00.0: CSR_EEPROM_REG: 0X07d60ffd kernel: iwlagn 0000:03:00.0: CSR_EEPROM_GP: 0X90000001 kernel: iwlagn 0000:03:00.0: CSR_OTP_GP_REG: 0X00030001 kernel: iwlagn 0000:03:00.0: CSR_GIO_REG: 0X00080044 kernel: iwlagn 0000:03:00.0: CSR_GP_UCODE_REG: 0X000093bb kernel: iwlagn 0000:03:00.0: CSR_GP_DRIVER_REG: 0X00000000 kernel: iwlagn 0000:03:00.0: CSR_UCODE_DRV_GP1: 0X00000000 kernel: iwlagn 0000:03:00.0: CSR_UCODE_DRV_GP2: 0X00000000 kernel: iwlagn 0000:03:00.0: CSR_LED_REG: 0X00000078 kernel: iwlagn 0000:03:00.0: CSR_DRAM_INT_TBL_REG: 0X88214dd2 kernel: iwlagn 0000:03:00.0: CSR_GIO_CHICKEN_BITS: 0X27800200 kernel: iwlagn 0000:03:00.0: CSR_ANA_PLL_CFG: 0X00000000 kernel: iwlagn 0000:03:00.0: CSR_HW_REV_WA_REG: 0X0001001a kernel: iwlagn 0000:03:00.0: CSR_DBG_HPET_MEM_REG: 0Xffff0010 kernel: iwlagn 0000:03:00.0: FH register values: kernel: iwlagn 0000:03:00.0: FH_RSCSR_CHNL0_STTS_WPTR_REG: 0X21316d00 kernel: iwlagn 0000:03:00.0: FH_RSCSR_CHNL0_RBDCB_BASE_REG: 0X021479c0 kernel: iwlagn 0000:03:00.0: FH_RSCSR_CHNL0_WPTR: 0X00000060 kernel: iwlagn 0000:03:00.0: FH_MEM_RCSR_CHNL0_CONFIG_REG: 0X80819104 kernel: iwlagn 0000:03:00.0: FH_MEM_RSSR_SHARED_CTRL_REG: 0X000000fc kernel: iwlagn 0000:03:00.0: FH_MEM_RSSR_RX_STATUS_REG: 0X07030000 kernel: iwlagn 0000:03:00.0: FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV: 0X00000000 kernel: iwlagn 0000:03:00.0: FH_TSSR_TX_STATUS_REG: 0X07ff0001 kernel: iwlagn 0000:03:00.0: FH_TSSR_TX_ERROR_REG: 0X00000000 kernel: iwlagn 0000:03:00.0: Start IWL Event Log Dump: display last 20 entries kernel: ------------[ cut here ]------------ WARNING: at net/mac80211/util.c:1208 ieee80211_reconfig+0x1f1/0x407() kernel: Hardware name: 4290W4H kernel: Pid: 1896, comm: kworker/0:0 Not tainted 3.1.0 #2 kernel: Call Trace: kernel: [] ? warn_slowpath_common+0x73/0x87 kernel: [] ? ieee80211_reconfig+0x1f1/0x407 kernel: [] ? ieee80211_recalc_smps_work+0x32/0x32 kernel: [] ? ieee80211_restart_work+0x7e/0x87 kernel: [] ? process_one_work+0x1c8/0x2e3 kernel: [] ? worker_thread+0x17a/0x23a kernel: [] ? manage_workers.clone.18+0x15b/0x15b kernel: [] ? manage_workers.clone.18+0x15b/0x15b kernel: [] ? kthread+0x7a/0x82 kernel: [] ? kernel_thread_helper+0x4/0x10 kernel: [] ? kthread_flush_work_fn+0x11/0x11 kernel: [] ? gs_change+0xb/0xb Cc: 3.1+ Reported-by: Udo Steinberg Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn-rxon.c | 36 ++++++++++++++++++----------- drivers/net/wireless/iwlwifi/iwl-agn.h | 2 ++ drivers/net/wireless/iwlwifi/iwl-mac80211.c | 18 +++------------ 3 files changed, 28 insertions(+), 28 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index 8de97f5a1825..00b38711c15d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c @@ -529,6 +529,24 @@ int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) return 0; } +void iwlagn_config_ht40(struct ieee80211_conf *conf, + struct iwl_rxon_context *ctx) +{ + if (conf_is_ht40_minus(conf)) { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_BELOW; + ctx->ht.is_40mhz = true; + } else if (conf_is_ht40_plus(conf)) { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_ABOVE; + ctx->ht.is_40mhz = true; + } else { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_NONE; + ctx->ht.is_40mhz = false; + } +} + int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed) { struct iwl_priv *priv = hw->priv; @@ -590,19 +608,11 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed) ctx->ht.enabled = conf_is_ht(conf); if (ctx->ht.enabled) { - if (conf_is_ht40_minus(conf)) { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_BELOW; - ctx->ht.is_40mhz = true; - } else if (conf_is_ht40_plus(conf)) { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_ABOVE; - ctx->ht.is_40mhz = true; - } else { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_NONE; - ctx->ht.is_40mhz = false; - } + /* if HT40 is used, it should not change + * after associated except channel switch */ + if (iwl_is_associated_ctx(ctx) && + !ctx->ht.is_40mhz) + iwlagn_config_ht40(conf, ctx); } else ctx->ht.is_40mhz = false; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 5d8d2f445923..2f446a353514 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -101,6 +101,8 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_bss_conf *bss_conf, u32 changes); +void iwlagn_config_ht40(struct ieee80211_conf *conf, + struct iwl_rxon_context *ctx); /* uCode */ int iwlagn_rx_calib_result(struct iwl_priv *priv, diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 05b1f0d2f387..ec31482435ba 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -804,21 +804,9 @@ static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw, /* Configure HT40 channels */ ctx->ht.enabled = conf_is_ht(conf); - if (ctx->ht.enabled) { - if (conf_is_ht40_minus(conf)) { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_BELOW; - ctx->ht.is_40mhz = true; - } else if (conf_is_ht40_plus(conf)) { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_ABOVE; - ctx->ht.is_40mhz = true; - } else { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_NONE; - ctx->ht.is_40mhz = false; - } - } else + if (ctx->ht.enabled) + iwlagn_config_ht40(conf, ctx); + else ctx->ht.is_40mhz = false; if ((le16_to_cpu(ctx->staging.channel) != ch)) -- cgit v1.2.3 From 306713fd1a04801ab3c9b5c0f76b615f1db46e6d Mon Sep 17 00:00:00 2001 From: "Hsu, Kenny" Date: Tue, 22 Nov 2011 23:03:39 -0800 Subject: iwlwifi: add tm commands for sram reading by dumpit Create new testmode commands and attributes to suppot sram data reading. Because the amount of sram data may exceed single skb packet size. Using the nl80211 dump it funtion to deliver sram data to userspace. - IWL_TM_CMD_APP2DEV_READ_SRAM - IWL_TM_CMD_APP2DEV_DUMP_SRAM - IWL_TM_ATTR_SRAM_ADDR - IWL_TM_ATTR_SRAM_SIZE - IWL_TM_ATTR_SRAM_DUMP Signed-off-by: Kenny Hsu Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-dev.h | 7 ++ drivers/net/wireless/iwlwifi/iwl-sv-open.c | 109 ++++++++++++++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-testmode.h | 27 ++++++- 3 files changed, 141 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 0c95ad3048a0..cb24adbae082 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -790,6 +790,12 @@ struct iwl_testmode_trace { dma_addr_t dma_addr; bool trace_enabled; }; +struct iwl_testmode_sram { + u32 buff_size; + u32 num_chunks; + u8 *buff_addr; + bool sram_readed; +}; #endif struct iwl_wipan_noa_data { @@ -1070,6 +1076,7 @@ struct iwl_priv { bool led_registered; #ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL struct iwl_testmode_trace testmode_trace; + struct iwl_testmode_sram testmode_sram; u32 tm_fixed_rate; #endif diff --git a/drivers/net/wireless/iwlwifi/iwl-sv-open.c b/drivers/net/wireless/iwlwifi/iwl-sv-open.c index be16cafbbc27..593f42d9fb0a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-sv-open.c +++ b/drivers/net/wireless/iwlwifi/iwl-sv-open.c @@ -106,6 +106,10 @@ struct nla_policy iwl_testmode_gnl_msg_policy[IWL_TM_ATTR_MAX] = { [IWL_TM_ATTR_FIXRATE] = { .type = NLA_U32, }, [IWL_TM_ATTR_UCODE_OWNER] = { .type = NLA_U8, }, + + [IWL_TM_ATTR_SRAM_ADDR] = { .type = NLA_U32, }, + [IWL_TM_ATTR_SRAM_SIZE] = { .type = NLA_U32, }, + [IWL_TM_ATTR_SRAM_DUMP] = { .type = NLA_UNSPEC, }, }; /* @@ -177,6 +181,18 @@ void iwl_testmode_init(struct iwl_priv *priv) { priv->pre_rx_handler = iwl_testmode_ucode_rx_pkt; priv->testmode_trace.trace_enabled = false; + priv->testmode_sram.sram_readed = false; +} + +void iwl_sram_cleanup(struct iwl_priv *priv) +{ + if (priv->testmode_sram.sram_readed) { + kfree(priv->testmode_sram.buff_addr); + priv->testmode_sram.buff_addr = NULL; + priv->testmode_sram.buff_size = 0; + priv->testmode_sram.num_chunks = 0; + priv->testmode_sram.sram_readed = false; + } } static void iwl_trace_cleanup(struct iwl_priv *priv) @@ -201,6 +217,7 @@ static void iwl_trace_cleanup(struct iwl_priv *priv) void iwl_testmode_cleanup(struct iwl_priv *priv) { iwl_trace_cleanup(priv); + iwl_sram_cleanup(priv); } /* @@ -644,6 +661,89 @@ static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb) return 0; } +/* + * This function handles the user application commands for SRAM data dump + * + * It retrieves the mandatory fields IWL_TM_ATTR_SRAM_ADDR and + * IWL_TM_ATTR_SRAM_SIZE to decide the memory area for SRAM data reading + * + * Several error will be retured, -EBUSY if the SRAM data retrieved by + * previous command has not been delivered to userspace, or -ENOMSG if + * the mandatory fields (IWL_TM_ATTR_SRAM_ADDR,IWL_TM_ATTR_SRAM_SIZE) + * are missing, or -ENOMEM if the buffer allocation fails. + * + * Otherwise 0 is replied indicating the success of the SRAM reading. + * + * @hw: ieee80211_hw object that represents the device + * @tb: gnl message fields from the user space + */ +static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb) +{ + struct iwl_priv *priv = hw->priv; + u32 base, ofs, size; + + if (priv->testmode_sram.sram_readed) + return -EBUSY; + + if (!tb[IWL_TM_ATTR_SRAM_ADDR]) { + IWL_DEBUG_INFO(priv, "Error finding SRAM offset address\n"); + return -ENOMSG; + } + ofs = nla_get_u32(tb[IWL_TM_ATTR_SRAM_ADDR]); + if (!tb[IWL_TM_ATTR_SRAM_SIZE]) { + IWL_DEBUG_INFO(priv, "Error finding size for SRAM reading\n"); + return -ENOMSG; + } + size = nla_get_u32(tb[IWL_TM_ATTR_SRAM_SIZE]); + priv->testmode_sram.buff_size = (size / 4) * 4; + priv->testmode_sram.buff_addr = + kmalloc(priv->testmode_sram.buff_size, GFP_KERNEL); + if (priv->testmode_sram.buff_addr == NULL) { + IWL_DEBUG_INFO(priv, "Error allocating memory\n"); + return -ENOMEM; + } + base = 0x800000; + _iwl_read_targ_mem_words(bus(priv), base + ofs, + priv->testmode_sram.buff_addr, + priv->testmode_sram.buff_size / 4); + priv->testmode_sram.num_chunks = + DIV_ROUND_UP(priv->testmode_sram.buff_size, TRACE_CHUNK_SIZE); + priv->testmode_sram.sram_readed = true; + return 0; +} + +static int iwl_testmode_sram_dump(struct ieee80211_hw *hw, struct nlattr **tb, + struct sk_buff *skb, + struct netlink_callback *cb) +{ + struct iwl_priv *priv = hw->priv; + int idx, length; + + if (priv->testmode_sram.sram_readed) { + idx = cb->args[4]; + if (idx >= priv->testmode_sram.num_chunks) { + iwl_sram_cleanup(priv); + return -ENOENT; + } + length = TRACE_CHUNK_SIZE; + if (((idx + 1) == priv->testmode_sram.num_chunks) && + (priv->testmode_sram.buff_size % TRACE_CHUNK_SIZE)) + length = priv->testmode_sram.buff_size % + TRACE_CHUNK_SIZE; + + NLA_PUT(skb, IWL_TM_ATTR_SRAM_DUMP, length, + priv->testmode_sram.buff_addr + + (TRACE_CHUNK_SIZE * idx)); + idx++; + cb->args[4] = idx; + return 0; + } else + return -EFAULT; + + nla_put_failure: + return -ENOBUFS; +} + /* The testmode gnl message handler that takes the gnl message from the * user space and parses it per the policy iwl_testmode_gnl_msg_policy, then @@ -721,6 +821,11 @@ int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) result = iwl_testmode_ownership(hw, tb); break; + case IWL_TM_CMD_APP2DEV_READ_SRAM: + IWL_DEBUG_INFO(priv, "testmode sram read cmd to driver\n"); + result = iwl_testmode_sram(hw, tb); + break; + default: IWL_DEBUG_INFO(priv, "Unknown testmode command\n"); result = -ENOSYS; @@ -769,6 +874,10 @@ int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb, IWL_DEBUG_INFO(priv, "uCode trace cmd to driver\n"); result = iwl_testmode_trace_dump(hw, tb, skb, cb); break; + case IWL_TM_CMD_APP2DEV_DUMP_SRAM: + IWL_DEBUG_INFO(priv, "testmode sram dump cmd to driver\n"); + result = iwl_testmode_sram_dump(hw, tb, skb, cb); + break; default: result = -EINVAL; break; diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.h b/drivers/net/wireless/iwlwifi/iwl-testmode.h index 177964850b7c..95c87058677b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.h +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.h @@ -103,14 +103,20 @@ * @IWL_TM_CMD_DEV2APP_EEPROM_RSP: * commands from kernel space to carry the eeprom response * to user application + * * @IWL_TM_CMD_APP2DEV_OWNERSHIP: * commands from user application to own change the ownership of the uCode * if application has the ownership, the only host command from * testmode will deliver to uCode. Default owner is driver + * * @IWL_TM_CMD_APP2DEV_INDIRECT_REG_READ32: * @IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32: * commands from user applicaiton to indirectly access peripheral register * + * @IWL_TM_CMD_APP2DEV_READ_SRAM: + * @IWL_TM_CMD_APP2DEV_DUMP_SRAM: + * commands from user applicaiton to read data in sram + * */ enum iwl_tm_cmd_t { IWL_TM_CMD_APP2DEV_UCODE = 1, @@ -132,7 +138,9 @@ enum iwl_tm_cmd_t { IWL_TM_CMD_APP2DEV_OWNERSHIP = 17, IWL_TM_CMD_APP2DEV_INDIRECT_REG_READ32 = 18, IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32 = 19, - IWL_TM_CMD_MAX = 20, + IWL_TM_CMD_APP2DEV_READ_SRAM = 20, + IWL_TM_CMD_APP2DEV_DUMP_SRAM = 21, + IWL_TM_CMD_MAX = 22, }; /* @@ -202,6 +210,18 @@ enum iwl_tm_cmd_t { * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_OWNERSHIP, * The mandatory fields are: * IWL_TM_ATTR_UCODE_OWNER for the new owner + * + * @IWL_TM_ATTR_SRAM_ADDR: + * @IWL_TM_ATTR_SRAM_SIZE: + * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_READ_SRAM, + * The mandatory fields are: + * IWL_TM_ATTR_SRAM_ADDR for the address in sram + * IWL_TM_ATTR_SRAM_SIZE for the buffer size of data reading + * + * @IWL_TM_ATTR_SRAM_DUMP: + * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_DUMP_SRAM, + * IWL_TM_ATTR_SRAM_DUMP for the data in sram + * */ enum iwl_tm_attr_t { IWL_TM_ATTR_NOT_APPLICABLE = 0, @@ -219,7 +239,10 @@ enum iwl_tm_attr_t { IWL_TM_ATTR_TRACE_DUMP = 12, IWL_TM_ATTR_FIXRATE = 13, IWL_TM_ATTR_UCODE_OWNER = 14, - IWL_TM_ATTR_MAX = 15, + IWL_TM_ATTR_SRAM_ADDR = 15, + IWL_TM_ATTR_SRAM_SIZE = 16, + IWL_TM_ATTR_SRAM_DUMP = 17, + IWL_TM_ATTR_MAX = 18, }; /* uCode trace buffer */ -- cgit v1.2.3 From 76de2f29d437fc1c9324e353e26c5879a4fa6dfb Mon Sep 17 00:00:00 2001 From: Kenny Hsu Date: Wed, 23 Nov 2011 06:57:22 -0800 Subject: iwlwifi: add range checking in tm sram read command The size of sram may alter according to ucode type. Retrieve the maximum sram size by current ucode type for range checking to prevent wrong data access. Signed-off-by: Kenny Hsu Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-sv-open.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-sv-open.c b/drivers/net/wireless/iwlwifi/iwl-sv-open.c index 593f42d9fb0a..a8d0ef649a7c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-sv-open.c +++ b/drivers/net/wireless/iwlwifi/iwl-sv-open.c @@ -680,7 +680,7 @@ static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb) static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb) { struct iwl_priv *priv = hw->priv; - u32 base, ofs, size; + u32 base, ofs, size, maxsize; if (priv->testmode_sram.sram_readed) return -EBUSY; @@ -695,6 +695,27 @@ static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb) return -ENOMSG; } size = nla_get_u32(tb[IWL_TM_ATTR_SRAM_SIZE]); + switch (priv->ucode_type) { + case IWL_UCODE_REGULAR: + maxsize = trans(priv)->ucode_rt.data.len; + break; + case IWL_UCODE_INIT: + maxsize = trans(priv)->ucode_init.data.len; + break; + case IWL_UCODE_WOWLAN: + maxsize = trans(priv)->ucode_wowlan.data.len; + break; + case IWL_UCODE_NONE: + IWL_DEBUG_INFO(priv, "Error, uCode does not been loaded\n"); + return -ENOSYS; + default: + IWL_DEBUG_INFO(priv, "Error, unsupported uCode type\n"); + return -ENOSYS; + } + if ((ofs + size) > maxsize) { + IWL_DEBUG_INFO(priv, "Invalid offset/size: out of range\n"); + return -EINVAL; + } priv->testmode_sram.buff_size = (size / 4) * 4; priv->testmode_sram.buff_addr = kmalloc(priv->testmode_sram.buff_size, GFP_KERNEL); -- cgit v1.2.3 From e056a6533b357fdaf4cc2c26e226530fe516ad1a Mon Sep 17 00:00:00 2001 From: "Hsu, Kenny" Date: Tue, 22 Nov 2011 23:05:02 -0800 Subject: iwlwifi: add generic chunk size of tm dumpit packet Use generic chunk size of dumpit packet for all necessary testmode commands instead of add declaration individually. Signed-off-by: Kenny Hsu Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-sv-open.c | 20 ++++++++++---------- drivers/net/wireless/iwlwifi/iwl-testmode.h | 4 +++- 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-sv-open.c b/drivers/net/wireless/iwlwifi/iwl-sv-open.c index a8d0ef649a7c..4ea64d65b35b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-sv-open.c +++ b/drivers/net/wireless/iwlwifi/iwl-sv-open.c @@ -575,7 +575,7 @@ static int iwl_testmode_trace(struct ieee80211_hw *hw, struct nlattr **tb) } priv->testmode_trace.num_chunks = DIV_ROUND_UP(priv->testmode_trace.buff_size, - TRACE_CHUNK_SIZE); + DUMP_CHUNK_SIZE); break; case IWL_TM_CMD_APP2DEV_END_TRACE: @@ -607,15 +607,15 @@ static int iwl_testmode_trace_dump(struct ieee80211_hw *hw, struct nlattr **tb, idx = cb->args[4]; if (idx >= priv->testmode_trace.num_chunks) return -ENOENT; - length = TRACE_CHUNK_SIZE; + length = DUMP_CHUNK_SIZE; if (((idx + 1) == priv->testmode_trace.num_chunks) && - (priv->testmode_trace.buff_size % TRACE_CHUNK_SIZE)) + (priv->testmode_trace.buff_size % DUMP_CHUNK_SIZE)) length = priv->testmode_trace.buff_size % - TRACE_CHUNK_SIZE; + DUMP_CHUNK_SIZE; NLA_PUT(skb, IWL_TM_ATTR_TRACE_DUMP, length, priv->testmode_trace.trace_addr + - (TRACE_CHUNK_SIZE * idx)); + (DUMP_CHUNK_SIZE * idx)); idx++; cb->args[4] = idx; return 0; @@ -728,7 +728,7 @@ static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb) priv->testmode_sram.buff_addr, priv->testmode_sram.buff_size / 4); priv->testmode_sram.num_chunks = - DIV_ROUND_UP(priv->testmode_sram.buff_size, TRACE_CHUNK_SIZE); + DIV_ROUND_UP(priv->testmode_sram.buff_size, DUMP_CHUNK_SIZE); priv->testmode_sram.sram_readed = true; return 0; } @@ -746,15 +746,15 @@ static int iwl_testmode_sram_dump(struct ieee80211_hw *hw, struct nlattr **tb, iwl_sram_cleanup(priv); return -ENOENT; } - length = TRACE_CHUNK_SIZE; + length = DUMP_CHUNK_SIZE; if (((idx + 1) == priv->testmode_sram.num_chunks) && - (priv->testmode_sram.buff_size % TRACE_CHUNK_SIZE)) + (priv->testmode_sram.buff_size % DUMP_CHUNK_SIZE)) length = priv->testmode_sram.buff_size % - TRACE_CHUNK_SIZE; + DUMP_CHUNK_SIZE; NLA_PUT(skb, IWL_TM_ATTR_SRAM_DUMP, length, priv->testmode_sram.buff_addr + - (TRACE_CHUNK_SIZE * idx)); + (DUMP_CHUNK_SIZE * idx)); idx++; cb->args[4] = idx; return 0; diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.h b/drivers/net/wireless/iwlwifi/iwl-testmode.h index 95c87058677b..e20f3d390271 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.h +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.h @@ -250,6 +250,8 @@ enum iwl_tm_attr_t { #define TRACE_BUFF_SIZE_MIN 0x20000 #define TRACE_BUFF_SIZE_DEF TRACE_BUFF_SIZE_MIN #define TRACE_BUFF_PADD 0x2000 -#define TRACE_CHUNK_SIZE (PAGE_SIZE - 1024) + +/* Maximum data size of each dump it packet */ +#define DUMP_CHUNK_SIZE (PAGE_SIZE - 1024) #endif -- cgit v1.2.3 From 6b5a26f50a91fe46032f7ec8f5cd786c80dad34c Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Wed, 23 Nov 2011 07:08:22 -0800 Subject: iwlwifi: declare static for iwl_sram_cleanup function Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-sv-open.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-sv-open.c b/drivers/net/wireless/iwlwifi/iwl-sv-open.c index 4ea64d65b35b..21b2fbb4dc3b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-sv-open.c +++ b/drivers/net/wireless/iwlwifi/iwl-sv-open.c @@ -184,7 +184,7 @@ void iwl_testmode_init(struct iwl_priv *priv) priv->testmode_sram.sram_readed = false; } -void iwl_sram_cleanup(struct iwl_priv *priv) +static void iwl_sram_cleanup(struct iwl_priv *priv) { if (priv->testmode_sram.sram_readed) { kfree(priv->testmode_sram.buff_addr); -- cgit v1.2.3 From a7e12c8e229b89fa23469718b605bfdbe66962d7 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 25 Nov 2011 03:20:09 -0800 Subject: iwlagn: fix HW crypto for TX-only keys Group keys in IBSS or AP mode are not programmed into the device since we give the key to it with every TX packet. However, we do need mac80211 to create the MMIC & PN in all cases. Move the code around to set the key flags all the time. We set them even when the key is removed again but that is obviously harmless. Cc: stable@vger.kernel.org Reported-by: Reinette Chatre Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn-sta.c | 5 ----- drivers/net/wireless/iwlwifi/iwl-mac80211.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index 901fd9485d75..626ed701100e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c @@ -1250,9 +1250,6 @@ int iwl_set_dynamic_key(struct iwl_priv *priv, switch (keyconf->cipher) { case WLAN_CIPHER_SUITE_TKIP: - keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; - keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; - if (sta) addr = sta->addr; else /* station mode case only */ @@ -1265,8 +1262,6 @@ int iwl_set_dynamic_key(struct iwl_priv *priv, seq.tkip.iv32, p1k, CMD_SYNC); break; case WLAN_CIPHER_SUITE_CCMP: - keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; - /* fall through */ case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP104: ret = iwlagn_send_sta_key(priv, keyconf, sta_id, diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index ec31482435ba..bafd52597678 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -521,6 +521,17 @@ static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, return -EOPNOTSUPP; } + switch (key->cipher) { + case WLAN_CIPHER_SUITE_TKIP: + key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; + /* fall through */ + case WLAN_CIPHER_SUITE_CCMP: + key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; + break; + default: + break; + } + /* * We could program these keys into the hardware as well, but we * don't expect much multicast traffic in IBSS and having keys -- cgit v1.2.3 From 5c05dc8ad832c84a48d7897468f3f3e2559b0959 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 25 Nov 2011 04:57:46 -0800 Subject: iwlagn: remove TX_REPLY_LIMIT debug This macro is unused right now. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-debug.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h index 44a7bdd7ccfd..a842d711fc13 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debug.h +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h @@ -206,8 +206,6 @@ static inline void iwl_dbgfs_unregister(struct iwl_priv *priv) #define IWL_DEBUG_STATS_LIMIT(p, f, a...) \ IWL_DEBUG_LIMIT(p, IWL_DL_STATS, f, ## a) #define IWL_DEBUG_TX_REPLY(p, f, a...) IWL_DEBUG(p, IWL_DL_TX_REPLY, f, ## a) -#define IWL_DEBUG_TX_REPLY_LIMIT(p, f, a...) \ - IWL_DEBUG_LIMIT(p, IWL_DL_TX_REPLY, f, ## a) #define IWL_DEBUG_TX_QUEUES(p, f, a...) IWL_DEBUG(p, IWL_DL_TX_QUEUES, f, ## a) #define IWL_DEBUG_RADIO(p, f, a...) IWL_DEBUG(p, IWL_DL_RADIO, f, ## a) #define IWL_DEBUG_POWER(p, f, a...) IWL_DEBUG(p, IWL_DL_POWER, f, ## a) -- cgit v1.2.3 From 6e66bb4aeec93ea40a9c8efd7cf53b0b445b0b27 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 25 Nov 2011 04:57:47 -0800 Subject: iwlagn: remove HC_DUMP debug This debug level is unused, remove it. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-debug.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h index a842d711fc13..32206088c646 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debug.h +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h @@ -140,7 +140,7 @@ static inline void iwl_dbgfs_unregister(struct iwl_priv *priv) #define IWL_DL_STATE (1 << 3) /* 0x000000F0 - 0x00000010 */ #define IWL_DL_MACDUMP (1 << 4) -#define IWL_DL_HCMD_DUMP (1 << 5) +/* unused (1 << 5) */ #define IWL_DL_EEPROM (1 << 6) #define IWL_DL_RADIO (1 << 7) /* 0x00000F00 - 0x00000100 */ @@ -184,7 +184,6 @@ static inline void iwl_dbgfs_unregister(struct iwl_priv *priv) #define IWL_DEBUG_LED(p, f, a...) IWL_DEBUG(p, IWL_DL_LED, f, ## a) #define IWL_DEBUG_WEP(p, f, a...) IWL_DEBUG(p, IWL_DL_WEP, f, ## a) #define IWL_DEBUG_HC(p, f, a...) IWL_DEBUG(p, IWL_DL_HCMD, f, ## a) -#define IWL_DEBUG_HC_DUMP(p, f, a...) IWL_DEBUG(p, IWL_DL_HCMD_DUMP, f, ## a) #define IWL_DEBUG_EEPROM(p, f, a...) IWL_DEBUG(p, IWL_DL_EEPROM, f, ## a) #define IWL_DEBUG_CALIB(p, f, a...) IWL_DEBUG(p, IWL_DL_CALIB, f, ## a) #define IWL_DEBUG_FW(p, f, a...) IWL_DEBUG(p, IWL_DL_FW, f, ## a) -- cgit v1.2.3 From 51057e5d4d89d13dd62dffb7708615479d20bdf6 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 25 Nov 2011 04:57:48 -0800 Subject: iwlagn: remove MACDUMP debug This is only used for TX debugging where there already is more debugging and tracing is more useful anyway, so remove it. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-debug.h | 3 +-- drivers/net/wireless/iwlwifi/iwl-mac80211.c | 4 ---- 2 files changed, 1 insertion(+), 6 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h index 32206088c646..95740c131a1f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debug.h +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h @@ -139,7 +139,7 @@ static inline void iwl_dbgfs_unregister(struct iwl_priv *priv) #define IWL_DL_HCMD (1 << 2) #define IWL_DL_STATE (1 << 3) /* 0x000000F0 - 0x00000010 */ -#define IWL_DL_MACDUMP (1 << 4) +/* unused (1 << 4) */ /* unused (1 << 5) */ #define IWL_DL_EEPROM (1 << 6) #define IWL_DL_RADIO (1 << 7) @@ -175,7 +175,6 @@ static inline void iwl_dbgfs_unregister(struct iwl_priv *priv) #define IWL_DEBUG_INFO(p, f, a...) IWL_DEBUG(p, IWL_DL_INFO, f, ## a) #define IWL_DEBUG_MAC80211(p, f, a...) IWL_DEBUG(p, IWL_DL_MAC80211, f, ## a) -#define IWL_DEBUG_MACDUMP(p, f, a...) IWL_DEBUG(p, IWL_DL_MACDUMP, f, ## a) #define IWL_DEBUG_TEMP(p, f, a...) IWL_DEBUG(p, IWL_DL_TEMP, f, ## a) #define IWL_DEBUG_SCAN(p, f, a...) IWL_DEBUG(p, IWL_DL_SCAN, f, ## a) #define IWL_DEBUG_RX(p, f, a...) IWL_DEBUG(p, IWL_DL_RX, f, ## a) diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index bafd52597678..2dd536c9e192 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -481,15 +481,11 @@ static void iwlagn_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { struct iwl_priv *priv = hw->priv; - IWL_DEBUG_MACDUMP(priv, "enter\n"); - IWL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); if (iwlagn_tx_skb(priv, skb)) dev_kfree_skb_any(skb); - - IWL_DEBUG_MACDUMP(priv, "leave\n"); } static void iwlagn_mac_update_tkip_key(struct ieee80211_hw *hw, -- cgit v1.2.3 From 9a0dd89547e419fce321f92ba80b8e22b623749d Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 25 Nov 2011 04:57:49 -0800 Subject: iwlagn: make debug levels more readable Using the actual shifted constants here allows one to read and or them more easily. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-debug.h | 58 +++++++++++++++----------------- 1 file changed, 27 insertions(+), 31 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h index 95740c131a1f..f8fc2393dd4c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debug.h +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h @@ -134,44 +134,40 @@ static inline void iwl_dbgfs_unregister(struct iwl_priv *priv) */ /* 0x0000000F - 0x00000001 */ -#define IWL_DL_INFO (1 << 0) -#define IWL_DL_MAC80211 (1 << 1) -#define IWL_DL_HCMD (1 << 2) -#define IWL_DL_STATE (1 << 3) +#define IWL_DL_INFO 0x00000001 +#define IWL_DL_MAC80211 0x00000002 +#define IWL_DL_HCMD 0x00000004 +#define IWL_DL_STATE 0x00000008 /* 0x000000F0 - 0x00000010 */ -/* unused (1 << 4) */ -/* unused (1 << 5) */ -#define IWL_DL_EEPROM (1 << 6) -#define IWL_DL_RADIO (1 << 7) +#define IWL_DL_EEPROM 0x00000040 +#define IWL_DL_RADIO 0x00000080 /* 0x00000F00 - 0x00000100 */ -#define IWL_DL_POWER (1 << 8) -#define IWL_DL_TEMP (1 << 9) -/* reserved (1 << 10) */ -#define IWL_DL_SCAN (1 << 11) +#define IWL_DL_POWER 0x00000100 +#define IWL_DL_TEMP 0x00000200 +#define IWL_DL_SCAN 0x00000800 /* 0x0000F000 - 0x00001000 */ -#define IWL_DL_ASSOC (1 << 12) -#define IWL_DL_DROP (1 << 13) -/* reserved (1 << 14) */ -#define IWL_DL_COEX (1 << 15) +#define IWL_DL_ASSOC 0x00001000 +#define IWL_DL_DROP 0x00002000 +#define IWL_DL_COEX 0x00008000 /* 0x000F0000 - 0x00010000 */ -#define IWL_DL_FW (1 << 16) -#define IWL_DL_RF_KILL (1 << 17) -#define IWL_DL_FW_ERRORS (1 << 18) -#define IWL_DL_LED (1 << 19) +#define IWL_DL_FW 0x00010000 +#define IWL_DL_RF_KILL 0x00020000 +#define IWL_DL_FW_ERRORS 0x00040000 +#define IWL_DL_LED 0x00080000 /* 0x00F00000 - 0x00100000 */ -#define IWL_DL_RATE (1 << 20) -#define IWL_DL_CALIB (1 << 21) -#define IWL_DL_WEP (1 << 22) -#define IWL_DL_TX (1 << 23) +#define IWL_DL_RATE 0x00100000 +#define IWL_DL_CALIB 0x00200000 +#define IWL_DL_WEP 0x00400000 +#define IWL_DL_TX 0x00800000 /* 0x0F000000 - 0x01000000 */ -#define IWL_DL_RX (1 << 24) -#define IWL_DL_ISR (1 << 25) -#define IWL_DL_HT (1 << 26) +#define IWL_DL_RX 0x01000000 +#define IWL_DL_ISR 0x02000000 +#define IWL_DL_HT 0x04000000 /* 0xF0000000 - 0x10000000 */ -#define IWL_DL_11H (1 << 28) -#define IWL_DL_STATS (1 << 29) -#define IWL_DL_TX_REPLY (1 << 30) -#define IWL_DL_TX_QUEUES (1 << 31) +#define IWL_DL_11H 0x10000000 +#define IWL_DL_STATS 0x20000000 +#define IWL_DL_TX_REPLY 0x40000000 +#define IWL_DL_TX_QUEUES 0x80000000 #define IWL_DEBUG_INFO(p, f, a...) IWL_DEBUG(p, IWL_DL_INFO, f, ## a) #define IWL_DEBUG_MAC80211(p, f, a...) IWL_DEBUG(p, IWL_DL_MAC80211, f, ## a) -- cgit v1.2.3 From d4af19fe6b70b54ddf37e14ba563eb705bc3baba Mon Sep 17 00:00:00 2001 From: "Hsu, Kenny" Date: Thu, 24 Nov 2011 22:26:53 -0800 Subject: iwlwifi: add WOWLAN uCode loading support by testmode Create new tm command for WOWLAN uCode loading to support further debugging function in userspace. - IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW Signed-off-by: Kenny Hsu Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-sv-open.c | 16 ++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-testmode.h | 5 ++++- 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-sv-open.c b/drivers/net/wireless/iwlwifi/iwl-sv-open.c index 21b2fbb4dc3b..3c9762628760 100644 --- a/drivers/net/wireless/iwlwifi/iwl-sv-open.c +++ b/drivers/net/wireless/iwlwifi/iwl-sv-open.c @@ -463,6 +463,21 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) "Error starting the device: %d\n", status); break; + case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: + iwl_scan_cancel_timeout(priv, 200); + iwl_trans_stop_device(trans(priv)); + status = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_WOWLAN); + if (status) { + IWL_DEBUG_INFO(priv, + "Error loading WOWLAN ucode: %d\n", status); + break; + } + status = iwl_alive_start(priv); + if (status) + IWL_DEBUG_INFO(priv, + "Error starting the device: %d\n", status); + break; + case IWL_TM_CMD_APP2DEV_GET_EEPROM: if (priv->eeprom) { skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, @@ -826,6 +841,7 @@ int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW: case IWL_TM_CMD_APP2DEV_GET_EEPROM: case IWL_TM_CMD_APP2DEV_FIXRATE_REQ: + case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: IWL_DEBUG_INFO(priv, "testmode cmd to driver\n"); result = iwl_testmode_driver(hw, tb); break; diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.h b/drivers/net/wireless/iwlwifi/iwl-testmode.h index e20f3d390271..deedd27c5f3d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.h +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.h @@ -117,6 +117,8 @@ * @IWL_TM_CMD_APP2DEV_DUMP_SRAM: * commands from user applicaiton to read data in sram * + * @IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: load Weak On Wireless LAN uCode image + * */ enum iwl_tm_cmd_t { IWL_TM_CMD_APP2DEV_UCODE = 1, @@ -140,7 +142,8 @@ enum iwl_tm_cmd_t { IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32 = 19, IWL_TM_CMD_APP2DEV_READ_SRAM = 20, IWL_TM_CMD_APP2DEV_DUMP_SRAM = 21, - IWL_TM_CMD_MAX = 22, + IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW = 22, + IWL_TM_CMD_MAX = 23, }; /* -- cgit v1.2.3 From 7152375d4daed8000e331492678be84b32c46027 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Fri, 25 Nov 2011 11:29:16 -0800 Subject: iwlwifi: Rename file name from iwl-sv-open.c to iwl-testmode.c The file dealing with all the operations through testmode, rename it. Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/Makefile | 2 +- drivers/net/wireless/iwlwifi/iwl-sv-open.c | 925 ---------------------------- drivers/net/wireless/iwlwifi/iwl-testmode.c | 925 ++++++++++++++++++++++++++++ 3 files changed, 926 insertions(+), 926 deletions(-) delete mode 100644 drivers/net/wireless/iwlwifi/iwl-sv-open.c create mode 100644 drivers/net/wireless/iwlwifi/iwl-testmode.c (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile index a7ab280994c8..5a052a5e4fb6 100644 --- a/drivers/net/wireless/iwlwifi/Makefile +++ b/drivers/net/wireless/iwlwifi/Makefile @@ -18,7 +18,7 @@ iwlwifi-objs += iwl-trans-pcie.o iwl-trans-pcie-rx.o iwl-trans-pcie-tx.o iwlwifi-$(CONFIG_IWLWIFI_DEBUGFS) += iwl-debugfs.o iwlwifi-$(CONFIG_IWLWIFI_DEVICE_TRACING) += iwl-devtrace.o -iwlwifi-$(CONFIG_IWLWIFI_DEVICE_SVTOOL) += iwl-sv-open.o +iwlwifi-$(CONFIG_IWLWIFI_DEVICE_SVTOOL) += iwl-testmode.o CFLAGS_iwl-devtrace.o := -I$(src) diff --git a/drivers/net/wireless/iwlwifi/iwl-sv-open.c b/drivers/net/wireless/iwlwifi/iwl-sv-open.c deleted file mode 100644 index 3c9762628760..000000000000 --- a/drivers/net/wireless/iwlwifi/iwl-sv-open.c +++ /dev/null @@ -1,925 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2010 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2010 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - *****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-debug.h" -#include "iwl-io.h" -#include "iwl-agn.h" -#include "iwl-testmode.h" -#include "iwl-trans.h" - -/* The TLVs used in the gnl message policy between the kernel module and - * user space application. iwl_testmode_gnl_msg_policy is to be carried - * through the NL80211_CMD_TESTMODE channel regulated by nl80211. - * See iwl-testmode.h - */ -static -struct nla_policy iwl_testmode_gnl_msg_policy[IWL_TM_ATTR_MAX] = { - [IWL_TM_ATTR_COMMAND] = { .type = NLA_U32, }, - - [IWL_TM_ATTR_UCODE_CMD_ID] = { .type = NLA_U8, }, - [IWL_TM_ATTR_UCODE_CMD_DATA] = { .type = NLA_UNSPEC, }, - - [IWL_TM_ATTR_REG_OFFSET] = { .type = NLA_U32, }, - [IWL_TM_ATTR_REG_VALUE8] = { .type = NLA_U8, }, - [IWL_TM_ATTR_REG_VALUE32] = { .type = NLA_U32, }, - - [IWL_TM_ATTR_SYNC_RSP] = { .type = NLA_UNSPEC, }, - [IWL_TM_ATTR_UCODE_RX_PKT] = { .type = NLA_UNSPEC, }, - - [IWL_TM_ATTR_EEPROM] = { .type = NLA_UNSPEC, }, - - [IWL_TM_ATTR_TRACE_ADDR] = { .type = NLA_UNSPEC, }, - [IWL_TM_ATTR_TRACE_DUMP] = { .type = NLA_UNSPEC, }, - [IWL_TM_ATTR_TRACE_SIZE] = { .type = NLA_U32, }, - - [IWL_TM_ATTR_FIXRATE] = { .type = NLA_U32, }, - - [IWL_TM_ATTR_UCODE_OWNER] = { .type = NLA_U8, }, - - [IWL_TM_ATTR_SRAM_ADDR] = { .type = NLA_U32, }, - [IWL_TM_ATTR_SRAM_SIZE] = { .type = NLA_U32, }, - [IWL_TM_ATTR_SRAM_DUMP] = { .type = NLA_UNSPEC, }, -}; - -/* - * See the struct iwl_rx_packet in iwl-commands.h for the format of the - * received events from the device - */ -static inline int get_event_length(struct iwl_rx_mem_buffer *rxb) -{ - struct iwl_rx_packet *pkt = rxb_addr(rxb); - if (pkt) - return le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; - else - return 0; -} - - -/* - * This function multicasts the spontaneous messages from the device to the - * user space. It is invoked whenever there is a received messages - * from the device. This function is called within the ISR of the rx handlers - * in iwlagn driver. - * - * The parsing of the message content is left to the user space application, - * The message content is treated as unattacked raw data and is encapsulated - * with IWL_TM_ATTR_UCODE_RX_PKT multicasting to the user space. - * - * @priv: the instance of iwlwifi device - * @rxb: pointer to rx data content received by the ISR - * - * See the message policies and TLVs in iwl_testmode_gnl_msg_policy[]. - * For the messages multicasting to the user application, the mandatory - * TLV fields are : - * IWL_TM_ATTR_COMMAND must be IWL_TM_CMD_DEV2APP_UCODE_RX_PKT - * IWL_TM_ATTR_UCODE_RX_PKT for carrying the message content - */ - -static void iwl_testmode_ucode_rx_pkt(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) -{ - struct ieee80211_hw *hw = priv->hw; - struct sk_buff *skb; - void *data; - int length; - - data = (void *)rxb_addr(rxb); - length = get_event_length(rxb); - - if (!data || length == 0) - return; - - skb = cfg80211_testmode_alloc_event_skb(hw->wiphy, 20 + length, - GFP_ATOMIC); - if (skb == NULL) { - IWL_DEBUG_INFO(priv, - "Run out of memory for messages to user space ?\n"); - return; - } - NLA_PUT_U32(skb, IWL_TM_ATTR_COMMAND, IWL_TM_CMD_DEV2APP_UCODE_RX_PKT); - NLA_PUT(skb, IWL_TM_ATTR_UCODE_RX_PKT, length, data); - cfg80211_testmode_event(skb, GFP_ATOMIC); - return; - -nla_put_failure: - kfree_skb(skb); - IWL_DEBUG_INFO(priv, "Ouch, overran buffer, check allocation!\n"); -} - -void iwl_testmode_init(struct iwl_priv *priv) -{ - priv->pre_rx_handler = iwl_testmode_ucode_rx_pkt; - priv->testmode_trace.trace_enabled = false; - priv->testmode_sram.sram_readed = false; -} - -static void iwl_sram_cleanup(struct iwl_priv *priv) -{ - if (priv->testmode_sram.sram_readed) { - kfree(priv->testmode_sram.buff_addr); - priv->testmode_sram.buff_addr = NULL; - priv->testmode_sram.buff_size = 0; - priv->testmode_sram.num_chunks = 0; - priv->testmode_sram.sram_readed = false; - } -} - -static void iwl_trace_cleanup(struct iwl_priv *priv) -{ - if (priv->testmode_trace.trace_enabled) { - if (priv->testmode_trace.cpu_addr && - priv->testmode_trace.dma_addr) - dma_free_coherent(bus(priv)->dev, - priv->testmode_trace.total_size, - priv->testmode_trace.cpu_addr, - priv->testmode_trace.dma_addr); - priv->testmode_trace.trace_enabled = false; - priv->testmode_trace.cpu_addr = NULL; - priv->testmode_trace.trace_addr = NULL; - priv->testmode_trace.dma_addr = 0; - priv->testmode_trace.buff_size = 0; - priv->testmode_trace.total_size = 0; - } -} - - -void iwl_testmode_cleanup(struct iwl_priv *priv) -{ - iwl_trace_cleanup(priv); - iwl_sram_cleanup(priv); -} - -/* - * This function handles the user application commands to the ucode. - * - * It retrieves the mandatory fields IWL_TM_ATTR_UCODE_CMD_ID and - * IWL_TM_ATTR_UCODE_CMD_DATA and calls to the handler to send the - * host command to the ucode. - * - * If any mandatory field is missing, -ENOMSG is replied to the user space - * application; otherwise, the actual execution result of the host command to - * ucode is replied. - * - * @hw: ieee80211_hw object that represents the device - * @tb: gnl message fields from the user space - */ -static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb) -{ - struct iwl_priv *priv = hw->priv; - struct iwl_host_cmd cmd; - - memset(&cmd, 0, sizeof(struct iwl_host_cmd)); - - if (!tb[IWL_TM_ATTR_UCODE_CMD_ID] || - !tb[IWL_TM_ATTR_UCODE_CMD_DATA]) { - IWL_DEBUG_INFO(priv, - "Error finding ucode command mandatory fields\n"); - return -ENOMSG; - } - - cmd.flags = CMD_ON_DEMAND; - cmd.id = nla_get_u8(tb[IWL_TM_ATTR_UCODE_CMD_ID]); - cmd.data[0] = nla_data(tb[IWL_TM_ATTR_UCODE_CMD_DATA]); - cmd.len[0] = nla_len(tb[IWL_TM_ATTR_UCODE_CMD_DATA]); - cmd.dataflags[0] = IWL_HCMD_DFL_NOCOPY; - IWL_INFO(priv, "testmode ucode command ID 0x%x, flags 0x%x," - " len %d\n", cmd.id, cmd.flags, cmd.len[0]); - /* ok, let's submit the command to ucode */ - return iwl_trans_send_cmd(trans(priv), &cmd); -} - - -/* - * This function handles the user application commands for register access. - * - * It retrieves command ID carried with IWL_TM_ATTR_COMMAND and calls to the - * handlers respectively. - * - * If it's an unknown commdn ID, -ENOSYS is returned; or -ENOMSG if the - * mandatory fields(IWL_TM_ATTR_REG_OFFSET,IWL_TM_ATTR_REG_VALUE32, - * IWL_TM_ATTR_REG_VALUE8) are missing; Otherwise 0 is replied indicating - * the success of the command execution. - * - * If IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_REG_READ32, the register read - * value is returned with IWL_TM_ATTR_REG_VALUE32. - * - * @hw: ieee80211_hw object that represents the device - * @tb: gnl message fields from the user space - */ -static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) -{ - struct iwl_priv *priv = hw->priv; - u32 ofs, val32; - u8 val8; - struct sk_buff *skb; - int status = 0; - - if (!tb[IWL_TM_ATTR_REG_OFFSET]) { - IWL_DEBUG_INFO(priv, "Error finding register offset\n"); - return -ENOMSG; - } - ofs = nla_get_u32(tb[IWL_TM_ATTR_REG_OFFSET]); - IWL_INFO(priv, "testmode register access command offset 0x%x\n", ofs); - - switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { - case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32: - val32 = iwl_read32(bus(priv), ofs); - IWL_INFO(priv, "32bit value to read 0x%x\n", val32); - - skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); - if (!skb) { - IWL_DEBUG_INFO(priv, "Error allocating memory\n"); - return -ENOMEM; - } - NLA_PUT_U32(skb, IWL_TM_ATTR_REG_VALUE32, val32); - status = cfg80211_testmode_reply(skb); - if (status < 0) - IWL_DEBUG_INFO(priv, - "Error sending msg : %d\n", status); - break; - case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32: - if (!tb[IWL_TM_ATTR_REG_VALUE32]) { - IWL_DEBUG_INFO(priv, - "Error finding value to write\n"); - return -ENOMSG; - } else { - val32 = nla_get_u32(tb[IWL_TM_ATTR_REG_VALUE32]); - IWL_INFO(priv, "32bit value to write 0x%x\n", val32); - iwl_write32(bus(priv), ofs, val32); - } - break; - case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8: - if (!tb[IWL_TM_ATTR_REG_VALUE8]) { - IWL_DEBUG_INFO(priv, "Error finding value to write\n"); - return -ENOMSG; - } else { - val8 = nla_get_u8(tb[IWL_TM_ATTR_REG_VALUE8]); - IWL_INFO(priv, "8bit value to write 0x%x\n", val8); - iwl_write8(bus(priv), ofs, val8); - } - break; - case IWL_TM_CMD_APP2DEV_INDIRECT_REG_READ32: - val32 = iwl_read_prph(bus(priv), ofs); - IWL_INFO(priv, "32bit value to read 0x%x\n", val32); - - skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); - if (!skb) { - IWL_DEBUG_INFO(priv, "Error allocating memory\n"); - return -ENOMEM; - } - NLA_PUT_U32(skb, IWL_TM_ATTR_REG_VALUE32, val32); - status = cfg80211_testmode_reply(skb); - if (status < 0) - IWL_DEBUG_INFO(priv, - "Error sending msg : %d\n", status); - break; - case IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32: - if (!tb[IWL_TM_ATTR_REG_VALUE32]) { - IWL_DEBUG_INFO(priv, - "Error finding value to write\n"); - return -ENOMSG; - } else { - val32 = nla_get_u32(tb[IWL_TM_ATTR_REG_VALUE32]); - IWL_INFO(priv, "32bit value to write 0x%x\n", val32); - iwl_write_prph(bus(priv), ofs, val32); - } - break; - default: - IWL_DEBUG_INFO(priv, "Unknown testmode register command ID\n"); - return -ENOSYS; - } - - return status; - -nla_put_failure: - kfree_skb(skb); - return -EMSGSIZE; -} - - -static int iwl_testmode_cfg_init_calib(struct iwl_priv *priv) -{ - struct iwl_notification_wait calib_wait; - int ret; - - iwlagn_init_notification_wait(priv, &calib_wait, - CALIBRATION_COMPLETE_NOTIFICATION, - NULL, NULL); - ret = iwlagn_init_alive_start(priv); - if (ret) { - IWL_DEBUG_INFO(priv, - "Error configuring init calibration: %d\n", ret); - goto cfg_init_calib_error; - } - - ret = iwlagn_wait_notification(priv, &calib_wait, 2 * HZ); - if (ret) - IWL_DEBUG_INFO(priv, "Error detecting" - " CALIBRATION_COMPLETE_NOTIFICATION: %d\n", ret); - return ret; - -cfg_init_calib_error: - iwlagn_remove_notification(priv, &calib_wait); - return ret; -} - -/* - * This function handles the user application commands for driver. - * - * It retrieves command ID carried with IWL_TM_ATTR_COMMAND and calls to the - * handlers respectively. - * - * If it's an unknown commdn ID, -ENOSYS is replied; otherwise, the returned - * value of the actual command execution is replied to the user application. - * - * If there's any message responding to the user space, IWL_TM_ATTR_SYNC_RSP - * is used for carry the message while IWL_TM_ATTR_COMMAND must set to - * IWL_TM_CMD_DEV2APP_SYNC_RSP. - * - * @hw: ieee80211_hw object that represents the device - * @tb: gnl message fields from the user space - */ -static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) -{ - struct iwl_priv *priv = hw->priv; - struct sk_buff *skb; - unsigned char *rsp_data_ptr = NULL; - int status = 0, rsp_data_len = 0; - - switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { - case IWL_TM_CMD_APP2DEV_GET_DEVICENAME: - rsp_data_ptr = (unsigned char *)priv->cfg->name; - rsp_data_len = strlen(priv->cfg->name); - skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, - rsp_data_len + 20); - if (!skb) { - IWL_DEBUG_INFO(priv, - "Error allocating memory\n"); - return -ENOMEM; - } - NLA_PUT_U32(skb, IWL_TM_ATTR_COMMAND, - IWL_TM_CMD_DEV2APP_SYNC_RSP); - NLA_PUT(skb, IWL_TM_ATTR_SYNC_RSP, - rsp_data_len, rsp_data_ptr); - status = cfg80211_testmode_reply(skb); - if (status < 0) - IWL_DEBUG_INFO(priv, "Error sending msg : %d\n", - status); - break; - - case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW: - status = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_INIT); - if (status) - IWL_DEBUG_INFO(priv, - "Error loading init ucode: %d\n", status); - break; - - case IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB: - iwl_testmode_cfg_init_calib(priv); - iwl_trans_stop_device(trans(priv)); - break; - - case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW: - status = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_REGULAR); - if (status) { - IWL_DEBUG_INFO(priv, - "Error loading runtime ucode: %d\n", status); - break; - } - status = iwl_alive_start(priv); - if (status) - IWL_DEBUG_INFO(priv, - "Error starting the device: %d\n", status); - break; - - case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: - iwl_scan_cancel_timeout(priv, 200); - iwl_trans_stop_device(trans(priv)); - status = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_WOWLAN); - if (status) { - IWL_DEBUG_INFO(priv, - "Error loading WOWLAN ucode: %d\n", status); - break; - } - status = iwl_alive_start(priv); - if (status) - IWL_DEBUG_INFO(priv, - "Error starting the device: %d\n", status); - break; - - case IWL_TM_CMD_APP2DEV_GET_EEPROM: - if (priv->eeprom) { - skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, - priv->cfg->base_params->eeprom_size + 20); - if (!skb) { - IWL_DEBUG_INFO(priv, - "Error allocating memory\n"); - return -ENOMEM; - } - NLA_PUT_U32(skb, IWL_TM_ATTR_COMMAND, - IWL_TM_CMD_DEV2APP_EEPROM_RSP); - NLA_PUT(skb, IWL_TM_ATTR_EEPROM, - priv->cfg->base_params->eeprom_size, - priv->eeprom); - status = cfg80211_testmode_reply(skb); - if (status < 0) - IWL_DEBUG_INFO(priv, - "Error sending msg : %d\n", - status); - } else - return -EFAULT; - break; - - case IWL_TM_CMD_APP2DEV_FIXRATE_REQ: - if (!tb[IWL_TM_ATTR_FIXRATE]) { - IWL_DEBUG_INFO(priv, - "Error finding fixrate setting\n"); - return -ENOMSG; - } - priv->tm_fixed_rate = nla_get_u32(tb[IWL_TM_ATTR_FIXRATE]); - break; - - default: - IWL_DEBUG_INFO(priv, "Unknown testmode driver command ID\n"); - return -ENOSYS; - } - return status; - -nla_put_failure: - kfree_skb(skb); - return -EMSGSIZE; -} - - -/* - * This function handles the user application commands for uCode trace - * - * It retrieves command ID carried with IWL_TM_ATTR_COMMAND and calls to the - * handlers respectively. - * - * If it's an unknown commdn ID, -ENOSYS is replied; otherwise, the returned - * value of the actual command execution is replied to the user application. - * - * @hw: ieee80211_hw object that represents the device - * @tb: gnl message fields from the user space - */ -static int iwl_testmode_trace(struct ieee80211_hw *hw, struct nlattr **tb) -{ - struct iwl_priv *priv = hw->priv; - struct sk_buff *skb; - int status = 0; - struct device *dev = bus(priv)->dev; - - switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { - case IWL_TM_CMD_APP2DEV_BEGIN_TRACE: - if (priv->testmode_trace.trace_enabled) - return -EBUSY; - - if (!tb[IWL_TM_ATTR_TRACE_SIZE]) - priv->testmode_trace.buff_size = TRACE_BUFF_SIZE_DEF; - else - priv->testmode_trace.buff_size = - nla_get_u32(tb[IWL_TM_ATTR_TRACE_SIZE]); - if (!priv->testmode_trace.buff_size) - return -EINVAL; - if (priv->testmode_trace.buff_size < TRACE_BUFF_SIZE_MIN || - priv->testmode_trace.buff_size > TRACE_BUFF_SIZE_MAX) - return -EINVAL; - - priv->testmode_trace.total_size = - priv->testmode_trace.buff_size + TRACE_BUFF_PADD; - priv->testmode_trace.cpu_addr = - dma_alloc_coherent(dev, - priv->testmode_trace.total_size, - &priv->testmode_trace.dma_addr, - GFP_KERNEL); - if (!priv->testmode_trace.cpu_addr) - return -ENOMEM; - priv->testmode_trace.trace_enabled = true; - priv->testmode_trace.trace_addr = (u8 *)PTR_ALIGN( - priv->testmode_trace.cpu_addr, 0x100); - memset(priv->testmode_trace.trace_addr, 0x03B, - priv->testmode_trace.buff_size); - skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, - sizeof(priv->testmode_trace.dma_addr) + 20); - if (!skb) { - IWL_DEBUG_INFO(priv, - "Error allocating memory\n"); - iwl_trace_cleanup(priv); - return -ENOMEM; - } - NLA_PUT(skb, IWL_TM_ATTR_TRACE_ADDR, - sizeof(priv->testmode_trace.dma_addr), - (u64 *)&priv->testmode_trace.dma_addr); - status = cfg80211_testmode_reply(skb); - if (status < 0) { - IWL_DEBUG_INFO(priv, - "Error sending msg : %d\n", - status); - } - priv->testmode_trace.num_chunks = - DIV_ROUND_UP(priv->testmode_trace.buff_size, - DUMP_CHUNK_SIZE); - break; - - case IWL_TM_CMD_APP2DEV_END_TRACE: - iwl_trace_cleanup(priv); - break; - default: - IWL_DEBUG_INFO(priv, "Unknown testmode mem command ID\n"); - return -ENOSYS; - } - return status; - -nla_put_failure: - kfree_skb(skb); - if (nla_get_u32(tb[IWL_TM_ATTR_COMMAND]) == - IWL_TM_CMD_APP2DEV_BEGIN_TRACE) - iwl_trace_cleanup(priv); - return -EMSGSIZE; -} - -static int iwl_testmode_trace_dump(struct ieee80211_hw *hw, struct nlattr **tb, - struct sk_buff *skb, - struct netlink_callback *cb) -{ - struct iwl_priv *priv = hw->priv; - int idx, length; - - if (priv->testmode_trace.trace_enabled && - priv->testmode_trace.trace_addr) { - idx = cb->args[4]; - if (idx >= priv->testmode_trace.num_chunks) - return -ENOENT; - length = DUMP_CHUNK_SIZE; - if (((idx + 1) == priv->testmode_trace.num_chunks) && - (priv->testmode_trace.buff_size % DUMP_CHUNK_SIZE)) - length = priv->testmode_trace.buff_size % - DUMP_CHUNK_SIZE; - - NLA_PUT(skb, IWL_TM_ATTR_TRACE_DUMP, length, - priv->testmode_trace.trace_addr + - (DUMP_CHUNK_SIZE * idx)); - idx++; - cb->args[4] = idx; - return 0; - } else - return -EFAULT; - - nla_put_failure: - return -ENOBUFS; -} - -/* - * This function handles the user application switch ucode ownership. - * - * It retrieves the mandatory fields IWL_TM_ATTR_UCODE_OWNER and - * decide who the current owner of the uCode - * - * If the current owner is OWNERSHIP_TM, then the only host command - * can deliver to uCode is from testmode, all the other host commands - * will dropped. - * - * default driver is the owner of uCode in normal operational mode - * - * @hw: ieee80211_hw object that represents the device - * @tb: gnl message fields from the user space - */ -static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb) -{ - struct iwl_priv *priv = hw->priv; - u8 owner; - - if (!tb[IWL_TM_ATTR_UCODE_OWNER]) { - IWL_DEBUG_INFO(priv, "Error finding ucode owner\n"); - return -ENOMSG; - } - - owner = nla_get_u8(tb[IWL_TM_ATTR_UCODE_OWNER]); - if ((owner == IWL_OWNERSHIP_DRIVER) || (owner == IWL_OWNERSHIP_TM)) - priv->shrd->ucode_owner = owner; - else { - IWL_DEBUG_INFO(priv, "Invalid owner\n"); - return -EINVAL; - } - return 0; -} - -/* - * This function handles the user application commands for SRAM data dump - * - * It retrieves the mandatory fields IWL_TM_ATTR_SRAM_ADDR and - * IWL_TM_ATTR_SRAM_SIZE to decide the memory area for SRAM data reading - * - * Several error will be retured, -EBUSY if the SRAM data retrieved by - * previous command has not been delivered to userspace, or -ENOMSG if - * the mandatory fields (IWL_TM_ATTR_SRAM_ADDR,IWL_TM_ATTR_SRAM_SIZE) - * are missing, or -ENOMEM if the buffer allocation fails. - * - * Otherwise 0 is replied indicating the success of the SRAM reading. - * - * @hw: ieee80211_hw object that represents the device - * @tb: gnl message fields from the user space - */ -static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb) -{ - struct iwl_priv *priv = hw->priv; - u32 base, ofs, size, maxsize; - - if (priv->testmode_sram.sram_readed) - return -EBUSY; - - if (!tb[IWL_TM_ATTR_SRAM_ADDR]) { - IWL_DEBUG_INFO(priv, "Error finding SRAM offset address\n"); - return -ENOMSG; - } - ofs = nla_get_u32(tb[IWL_TM_ATTR_SRAM_ADDR]); - if (!tb[IWL_TM_ATTR_SRAM_SIZE]) { - IWL_DEBUG_INFO(priv, "Error finding size for SRAM reading\n"); - return -ENOMSG; - } - size = nla_get_u32(tb[IWL_TM_ATTR_SRAM_SIZE]); - switch (priv->ucode_type) { - case IWL_UCODE_REGULAR: - maxsize = trans(priv)->ucode_rt.data.len; - break; - case IWL_UCODE_INIT: - maxsize = trans(priv)->ucode_init.data.len; - break; - case IWL_UCODE_WOWLAN: - maxsize = trans(priv)->ucode_wowlan.data.len; - break; - case IWL_UCODE_NONE: - IWL_DEBUG_INFO(priv, "Error, uCode does not been loaded\n"); - return -ENOSYS; - default: - IWL_DEBUG_INFO(priv, "Error, unsupported uCode type\n"); - return -ENOSYS; - } - if ((ofs + size) > maxsize) { - IWL_DEBUG_INFO(priv, "Invalid offset/size: out of range\n"); - return -EINVAL; - } - priv->testmode_sram.buff_size = (size / 4) * 4; - priv->testmode_sram.buff_addr = - kmalloc(priv->testmode_sram.buff_size, GFP_KERNEL); - if (priv->testmode_sram.buff_addr == NULL) { - IWL_DEBUG_INFO(priv, "Error allocating memory\n"); - return -ENOMEM; - } - base = 0x800000; - _iwl_read_targ_mem_words(bus(priv), base + ofs, - priv->testmode_sram.buff_addr, - priv->testmode_sram.buff_size / 4); - priv->testmode_sram.num_chunks = - DIV_ROUND_UP(priv->testmode_sram.buff_size, DUMP_CHUNK_SIZE); - priv->testmode_sram.sram_readed = true; - return 0; -} - -static int iwl_testmode_sram_dump(struct ieee80211_hw *hw, struct nlattr **tb, - struct sk_buff *skb, - struct netlink_callback *cb) -{ - struct iwl_priv *priv = hw->priv; - int idx, length; - - if (priv->testmode_sram.sram_readed) { - idx = cb->args[4]; - if (idx >= priv->testmode_sram.num_chunks) { - iwl_sram_cleanup(priv); - return -ENOENT; - } - length = DUMP_CHUNK_SIZE; - if (((idx + 1) == priv->testmode_sram.num_chunks) && - (priv->testmode_sram.buff_size % DUMP_CHUNK_SIZE)) - length = priv->testmode_sram.buff_size % - DUMP_CHUNK_SIZE; - - NLA_PUT(skb, IWL_TM_ATTR_SRAM_DUMP, length, - priv->testmode_sram.buff_addr + - (DUMP_CHUNK_SIZE * idx)); - idx++; - cb->args[4] = idx; - return 0; - } else - return -EFAULT; - - nla_put_failure: - return -ENOBUFS; -} - - -/* The testmode gnl message handler that takes the gnl message from the - * user space and parses it per the policy iwl_testmode_gnl_msg_policy, then - * invoke the corresponding handlers. - * - * This function is invoked when there is user space application sending - * gnl message through the testmode tunnel NL80211_CMD_TESTMODE regulated - * by nl80211. - * - * It retrieves the mandatory field, IWL_TM_ATTR_COMMAND, before - * dispatching it to the corresponding handler. - * - * If IWL_TM_ATTR_COMMAND is missing, -ENOMSG is replied to user application; - * -ENOSYS is replied to the user application if the command is unknown; - * Otherwise, the command is dispatched to the respective handler. - * - * @hw: ieee80211_hw object that represents the device - * @data: pointer to user space message - * @len: length in byte of @data - */ -int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) -{ - struct nlattr *tb[IWL_TM_ATTR_MAX]; - struct iwl_priv *priv = hw->priv; - int result; - - result = nla_parse(tb, IWL_TM_ATTR_MAX - 1, data, len, - iwl_testmode_gnl_msg_policy); - if (result != 0) { - IWL_DEBUG_INFO(priv, - "Error parsing the gnl message : %d\n", result); - return result; - } - - /* IWL_TM_ATTR_COMMAND is absolutely mandatory */ - if (!tb[IWL_TM_ATTR_COMMAND]) { - IWL_DEBUG_INFO(priv, "Error finding testmode command type\n"); - return -ENOMSG; - } - /* in case multiple accesses to the device happens */ - mutex_lock(&priv->shrd->mutex); - - switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { - case IWL_TM_CMD_APP2DEV_UCODE: - IWL_DEBUG_INFO(priv, "testmode cmd to uCode\n"); - result = iwl_testmode_ucode(hw, tb); - break; - case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32: - case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32: - case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8: - case IWL_TM_CMD_APP2DEV_INDIRECT_REG_READ32: - case IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32: - IWL_DEBUG_INFO(priv, "testmode cmd to register\n"); - result = iwl_testmode_reg(hw, tb); - break; - case IWL_TM_CMD_APP2DEV_GET_DEVICENAME: - case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW: - case IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB: - case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW: - case IWL_TM_CMD_APP2DEV_GET_EEPROM: - case IWL_TM_CMD_APP2DEV_FIXRATE_REQ: - case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: - IWL_DEBUG_INFO(priv, "testmode cmd to driver\n"); - result = iwl_testmode_driver(hw, tb); - break; - - case IWL_TM_CMD_APP2DEV_BEGIN_TRACE: - case IWL_TM_CMD_APP2DEV_END_TRACE: - case IWL_TM_CMD_APP2DEV_READ_TRACE: - IWL_DEBUG_INFO(priv, "testmode uCode trace cmd to driver\n"); - result = iwl_testmode_trace(hw, tb); - break; - - case IWL_TM_CMD_APP2DEV_OWNERSHIP: - IWL_DEBUG_INFO(priv, "testmode change uCode ownership\n"); - result = iwl_testmode_ownership(hw, tb); - break; - - case IWL_TM_CMD_APP2DEV_READ_SRAM: - IWL_DEBUG_INFO(priv, "testmode sram read cmd to driver\n"); - result = iwl_testmode_sram(hw, tb); - break; - - default: - IWL_DEBUG_INFO(priv, "Unknown testmode command\n"); - result = -ENOSYS; - break; - } - - mutex_unlock(&priv->shrd->mutex); - return result; -} - -int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb, - struct netlink_callback *cb, - void *data, int len) -{ - struct nlattr *tb[IWL_TM_ATTR_MAX]; - struct iwl_priv *priv = hw->priv; - int result; - u32 cmd; - - if (cb->args[3]) { - /* offset by 1 since commands start at 0 */ - cmd = cb->args[3] - 1; - } else { - result = nla_parse(tb, IWL_TM_ATTR_MAX - 1, data, len, - iwl_testmode_gnl_msg_policy); - if (result) { - IWL_DEBUG_INFO(priv, - "Error parsing the gnl message : %d\n", result); - return result; - } - - /* IWL_TM_ATTR_COMMAND is absolutely mandatory */ - if (!tb[IWL_TM_ATTR_COMMAND]) { - IWL_DEBUG_INFO(priv, - "Error finding testmode command type\n"); - return -ENOMSG; - } - cmd = nla_get_u32(tb[IWL_TM_ATTR_COMMAND]); - cb->args[3] = cmd + 1; - } - - /* in case multiple accesses to the device happens */ - mutex_lock(&priv->shrd->mutex); - switch (cmd) { - case IWL_TM_CMD_APP2DEV_READ_TRACE: - IWL_DEBUG_INFO(priv, "uCode trace cmd to driver\n"); - result = iwl_testmode_trace_dump(hw, tb, skb, cb); - break; - case IWL_TM_CMD_APP2DEV_DUMP_SRAM: - IWL_DEBUG_INFO(priv, "testmode sram dump cmd to driver\n"); - result = iwl_testmode_sram_dump(hw, tb, skb, cb); - break; - default: - result = -EINVAL; - break; - } - - mutex_unlock(&priv->shrd->mutex); - return result; -} diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c new file mode 100644 index 000000000000..3c9762628760 --- /dev/null +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -0,0 +1,925 @@ +/****************************************************************************** + * + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2010 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, + * USA + * + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + * BSD LICENSE + * + * Copyright(c) 2010 - 2011 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "iwl-dev.h" +#include "iwl-core.h" +#include "iwl-debug.h" +#include "iwl-io.h" +#include "iwl-agn.h" +#include "iwl-testmode.h" +#include "iwl-trans.h" + +/* The TLVs used in the gnl message policy between the kernel module and + * user space application. iwl_testmode_gnl_msg_policy is to be carried + * through the NL80211_CMD_TESTMODE channel regulated by nl80211. + * See iwl-testmode.h + */ +static +struct nla_policy iwl_testmode_gnl_msg_policy[IWL_TM_ATTR_MAX] = { + [IWL_TM_ATTR_COMMAND] = { .type = NLA_U32, }, + + [IWL_TM_ATTR_UCODE_CMD_ID] = { .type = NLA_U8, }, + [IWL_TM_ATTR_UCODE_CMD_DATA] = { .type = NLA_UNSPEC, }, + + [IWL_TM_ATTR_REG_OFFSET] = { .type = NLA_U32, }, + [IWL_TM_ATTR_REG_VALUE8] = { .type = NLA_U8, }, + [IWL_TM_ATTR_REG_VALUE32] = { .type = NLA_U32, }, + + [IWL_TM_ATTR_SYNC_RSP] = { .type = NLA_UNSPEC, }, + [IWL_TM_ATTR_UCODE_RX_PKT] = { .type = NLA_UNSPEC, }, + + [IWL_TM_ATTR_EEPROM] = { .type = NLA_UNSPEC, }, + + [IWL_TM_ATTR_TRACE_ADDR] = { .type = NLA_UNSPEC, }, + [IWL_TM_ATTR_TRACE_DUMP] = { .type = NLA_UNSPEC, }, + [IWL_TM_ATTR_TRACE_SIZE] = { .type = NLA_U32, }, + + [IWL_TM_ATTR_FIXRATE] = { .type = NLA_U32, }, + + [IWL_TM_ATTR_UCODE_OWNER] = { .type = NLA_U8, }, + + [IWL_TM_ATTR_SRAM_ADDR] = { .type = NLA_U32, }, + [IWL_TM_ATTR_SRAM_SIZE] = { .type = NLA_U32, }, + [IWL_TM_ATTR_SRAM_DUMP] = { .type = NLA_UNSPEC, }, +}; + +/* + * See the struct iwl_rx_packet in iwl-commands.h for the format of the + * received events from the device + */ +static inline int get_event_length(struct iwl_rx_mem_buffer *rxb) +{ + struct iwl_rx_packet *pkt = rxb_addr(rxb); + if (pkt) + return le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; + else + return 0; +} + + +/* + * This function multicasts the spontaneous messages from the device to the + * user space. It is invoked whenever there is a received messages + * from the device. This function is called within the ISR of the rx handlers + * in iwlagn driver. + * + * The parsing of the message content is left to the user space application, + * The message content is treated as unattacked raw data and is encapsulated + * with IWL_TM_ATTR_UCODE_RX_PKT multicasting to the user space. + * + * @priv: the instance of iwlwifi device + * @rxb: pointer to rx data content received by the ISR + * + * See the message policies and TLVs in iwl_testmode_gnl_msg_policy[]. + * For the messages multicasting to the user application, the mandatory + * TLV fields are : + * IWL_TM_ATTR_COMMAND must be IWL_TM_CMD_DEV2APP_UCODE_RX_PKT + * IWL_TM_ATTR_UCODE_RX_PKT for carrying the message content + */ + +static void iwl_testmode_ucode_rx_pkt(struct iwl_priv *priv, + struct iwl_rx_mem_buffer *rxb) +{ + struct ieee80211_hw *hw = priv->hw; + struct sk_buff *skb; + void *data; + int length; + + data = (void *)rxb_addr(rxb); + length = get_event_length(rxb); + + if (!data || length == 0) + return; + + skb = cfg80211_testmode_alloc_event_skb(hw->wiphy, 20 + length, + GFP_ATOMIC); + if (skb == NULL) { + IWL_DEBUG_INFO(priv, + "Run out of memory for messages to user space ?\n"); + return; + } + NLA_PUT_U32(skb, IWL_TM_ATTR_COMMAND, IWL_TM_CMD_DEV2APP_UCODE_RX_PKT); + NLA_PUT(skb, IWL_TM_ATTR_UCODE_RX_PKT, length, data); + cfg80211_testmode_event(skb, GFP_ATOMIC); + return; + +nla_put_failure: + kfree_skb(skb); + IWL_DEBUG_INFO(priv, "Ouch, overran buffer, check allocation!\n"); +} + +void iwl_testmode_init(struct iwl_priv *priv) +{ + priv->pre_rx_handler = iwl_testmode_ucode_rx_pkt; + priv->testmode_trace.trace_enabled = false; + priv->testmode_sram.sram_readed = false; +} + +static void iwl_sram_cleanup(struct iwl_priv *priv) +{ + if (priv->testmode_sram.sram_readed) { + kfree(priv->testmode_sram.buff_addr); + priv->testmode_sram.buff_addr = NULL; + priv->testmode_sram.buff_size = 0; + priv->testmode_sram.num_chunks = 0; + priv->testmode_sram.sram_readed = false; + } +} + +static void iwl_trace_cleanup(struct iwl_priv *priv) +{ + if (priv->testmode_trace.trace_enabled) { + if (priv->testmode_trace.cpu_addr && + priv->testmode_trace.dma_addr) + dma_free_coherent(bus(priv)->dev, + priv->testmode_trace.total_size, + priv->testmode_trace.cpu_addr, + priv->testmode_trace.dma_addr); + priv->testmode_trace.trace_enabled = false; + priv->testmode_trace.cpu_addr = NULL; + priv->testmode_trace.trace_addr = NULL; + priv->testmode_trace.dma_addr = 0; + priv->testmode_trace.buff_size = 0; + priv->testmode_trace.total_size = 0; + } +} + + +void iwl_testmode_cleanup(struct iwl_priv *priv) +{ + iwl_trace_cleanup(priv); + iwl_sram_cleanup(priv); +} + +/* + * This function handles the user application commands to the ucode. + * + * It retrieves the mandatory fields IWL_TM_ATTR_UCODE_CMD_ID and + * IWL_TM_ATTR_UCODE_CMD_DATA and calls to the handler to send the + * host command to the ucode. + * + * If any mandatory field is missing, -ENOMSG is replied to the user space + * application; otherwise, the actual execution result of the host command to + * ucode is replied. + * + * @hw: ieee80211_hw object that represents the device + * @tb: gnl message fields from the user space + */ +static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb) +{ + struct iwl_priv *priv = hw->priv; + struct iwl_host_cmd cmd; + + memset(&cmd, 0, sizeof(struct iwl_host_cmd)); + + if (!tb[IWL_TM_ATTR_UCODE_CMD_ID] || + !tb[IWL_TM_ATTR_UCODE_CMD_DATA]) { + IWL_DEBUG_INFO(priv, + "Error finding ucode command mandatory fields\n"); + return -ENOMSG; + } + + cmd.flags = CMD_ON_DEMAND; + cmd.id = nla_get_u8(tb[IWL_TM_ATTR_UCODE_CMD_ID]); + cmd.data[0] = nla_data(tb[IWL_TM_ATTR_UCODE_CMD_DATA]); + cmd.len[0] = nla_len(tb[IWL_TM_ATTR_UCODE_CMD_DATA]); + cmd.dataflags[0] = IWL_HCMD_DFL_NOCOPY; + IWL_INFO(priv, "testmode ucode command ID 0x%x, flags 0x%x," + " len %d\n", cmd.id, cmd.flags, cmd.len[0]); + /* ok, let's submit the command to ucode */ + return iwl_trans_send_cmd(trans(priv), &cmd); +} + + +/* + * This function handles the user application commands for register access. + * + * It retrieves command ID carried with IWL_TM_ATTR_COMMAND and calls to the + * handlers respectively. + * + * If it's an unknown commdn ID, -ENOSYS is returned; or -ENOMSG if the + * mandatory fields(IWL_TM_ATTR_REG_OFFSET,IWL_TM_ATTR_REG_VALUE32, + * IWL_TM_ATTR_REG_VALUE8) are missing; Otherwise 0 is replied indicating + * the success of the command execution. + * + * If IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_REG_READ32, the register read + * value is returned with IWL_TM_ATTR_REG_VALUE32. + * + * @hw: ieee80211_hw object that represents the device + * @tb: gnl message fields from the user space + */ +static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) +{ + struct iwl_priv *priv = hw->priv; + u32 ofs, val32; + u8 val8; + struct sk_buff *skb; + int status = 0; + + if (!tb[IWL_TM_ATTR_REG_OFFSET]) { + IWL_DEBUG_INFO(priv, "Error finding register offset\n"); + return -ENOMSG; + } + ofs = nla_get_u32(tb[IWL_TM_ATTR_REG_OFFSET]); + IWL_INFO(priv, "testmode register access command offset 0x%x\n", ofs); + + switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { + case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32: + val32 = iwl_read32(bus(priv), ofs); + IWL_INFO(priv, "32bit value to read 0x%x\n", val32); + + skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); + if (!skb) { + IWL_DEBUG_INFO(priv, "Error allocating memory\n"); + return -ENOMEM; + } + NLA_PUT_U32(skb, IWL_TM_ATTR_REG_VALUE32, val32); + status = cfg80211_testmode_reply(skb); + if (status < 0) + IWL_DEBUG_INFO(priv, + "Error sending msg : %d\n", status); + break; + case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32: + if (!tb[IWL_TM_ATTR_REG_VALUE32]) { + IWL_DEBUG_INFO(priv, + "Error finding value to write\n"); + return -ENOMSG; + } else { + val32 = nla_get_u32(tb[IWL_TM_ATTR_REG_VALUE32]); + IWL_INFO(priv, "32bit value to write 0x%x\n", val32); + iwl_write32(bus(priv), ofs, val32); + } + break; + case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8: + if (!tb[IWL_TM_ATTR_REG_VALUE8]) { + IWL_DEBUG_INFO(priv, "Error finding value to write\n"); + return -ENOMSG; + } else { + val8 = nla_get_u8(tb[IWL_TM_ATTR_REG_VALUE8]); + IWL_INFO(priv, "8bit value to write 0x%x\n", val8); + iwl_write8(bus(priv), ofs, val8); + } + break; + case IWL_TM_CMD_APP2DEV_INDIRECT_REG_READ32: + val32 = iwl_read_prph(bus(priv), ofs); + IWL_INFO(priv, "32bit value to read 0x%x\n", val32); + + skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); + if (!skb) { + IWL_DEBUG_INFO(priv, "Error allocating memory\n"); + return -ENOMEM; + } + NLA_PUT_U32(skb, IWL_TM_ATTR_REG_VALUE32, val32); + status = cfg80211_testmode_reply(skb); + if (status < 0) + IWL_DEBUG_INFO(priv, + "Error sending msg : %d\n", status); + break; + case IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32: + if (!tb[IWL_TM_ATTR_REG_VALUE32]) { + IWL_DEBUG_INFO(priv, + "Error finding value to write\n"); + return -ENOMSG; + } else { + val32 = nla_get_u32(tb[IWL_TM_ATTR_REG_VALUE32]); + IWL_INFO(priv, "32bit value to write 0x%x\n", val32); + iwl_write_prph(bus(priv), ofs, val32); + } + break; + default: + IWL_DEBUG_INFO(priv, "Unknown testmode register command ID\n"); + return -ENOSYS; + } + + return status; + +nla_put_failure: + kfree_skb(skb); + return -EMSGSIZE; +} + + +static int iwl_testmode_cfg_init_calib(struct iwl_priv *priv) +{ + struct iwl_notification_wait calib_wait; + int ret; + + iwlagn_init_notification_wait(priv, &calib_wait, + CALIBRATION_COMPLETE_NOTIFICATION, + NULL, NULL); + ret = iwlagn_init_alive_start(priv); + if (ret) { + IWL_DEBUG_INFO(priv, + "Error configuring init calibration: %d\n", ret); + goto cfg_init_calib_error; + } + + ret = iwlagn_wait_notification(priv, &calib_wait, 2 * HZ); + if (ret) + IWL_DEBUG_INFO(priv, "Error detecting" + " CALIBRATION_COMPLETE_NOTIFICATION: %d\n", ret); + return ret; + +cfg_init_calib_error: + iwlagn_remove_notification(priv, &calib_wait); + return ret; +} + +/* + * This function handles the user application commands for driver. + * + * It retrieves command ID carried with IWL_TM_ATTR_COMMAND and calls to the + * handlers respectively. + * + * If it's an unknown commdn ID, -ENOSYS is replied; otherwise, the returned + * value of the actual command execution is replied to the user application. + * + * If there's any message responding to the user space, IWL_TM_ATTR_SYNC_RSP + * is used for carry the message while IWL_TM_ATTR_COMMAND must set to + * IWL_TM_CMD_DEV2APP_SYNC_RSP. + * + * @hw: ieee80211_hw object that represents the device + * @tb: gnl message fields from the user space + */ +static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) +{ + struct iwl_priv *priv = hw->priv; + struct sk_buff *skb; + unsigned char *rsp_data_ptr = NULL; + int status = 0, rsp_data_len = 0; + + switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { + case IWL_TM_CMD_APP2DEV_GET_DEVICENAME: + rsp_data_ptr = (unsigned char *)priv->cfg->name; + rsp_data_len = strlen(priv->cfg->name); + skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, + rsp_data_len + 20); + if (!skb) { + IWL_DEBUG_INFO(priv, + "Error allocating memory\n"); + return -ENOMEM; + } + NLA_PUT_U32(skb, IWL_TM_ATTR_COMMAND, + IWL_TM_CMD_DEV2APP_SYNC_RSP); + NLA_PUT(skb, IWL_TM_ATTR_SYNC_RSP, + rsp_data_len, rsp_data_ptr); + status = cfg80211_testmode_reply(skb); + if (status < 0) + IWL_DEBUG_INFO(priv, "Error sending msg : %d\n", + status); + break; + + case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW: + status = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_INIT); + if (status) + IWL_DEBUG_INFO(priv, + "Error loading init ucode: %d\n", status); + break; + + case IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB: + iwl_testmode_cfg_init_calib(priv); + iwl_trans_stop_device(trans(priv)); + break; + + case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW: + status = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_REGULAR); + if (status) { + IWL_DEBUG_INFO(priv, + "Error loading runtime ucode: %d\n", status); + break; + } + status = iwl_alive_start(priv); + if (status) + IWL_DEBUG_INFO(priv, + "Error starting the device: %d\n", status); + break; + + case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: + iwl_scan_cancel_timeout(priv, 200); + iwl_trans_stop_device(trans(priv)); + status = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_WOWLAN); + if (status) { + IWL_DEBUG_INFO(priv, + "Error loading WOWLAN ucode: %d\n", status); + break; + } + status = iwl_alive_start(priv); + if (status) + IWL_DEBUG_INFO(priv, + "Error starting the device: %d\n", status); + break; + + case IWL_TM_CMD_APP2DEV_GET_EEPROM: + if (priv->eeprom) { + skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, + priv->cfg->base_params->eeprom_size + 20); + if (!skb) { + IWL_DEBUG_INFO(priv, + "Error allocating memory\n"); + return -ENOMEM; + } + NLA_PUT_U32(skb, IWL_TM_ATTR_COMMAND, + IWL_TM_CMD_DEV2APP_EEPROM_RSP); + NLA_PUT(skb, IWL_TM_ATTR_EEPROM, + priv->cfg->base_params->eeprom_size, + priv->eeprom); + status = cfg80211_testmode_reply(skb); + if (status < 0) + IWL_DEBUG_INFO(priv, + "Error sending msg : %d\n", + status); + } else + return -EFAULT; + break; + + case IWL_TM_CMD_APP2DEV_FIXRATE_REQ: + if (!tb[IWL_TM_ATTR_FIXRATE]) { + IWL_DEBUG_INFO(priv, + "Error finding fixrate setting\n"); + return -ENOMSG; + } + priv->tm_fixed_rate = nla_get_u32(tb[IWL_TM_ATTR_FIXRATE]); + break; + + default: + IWL_DEBUG_INFO(priv, "Unknown testmode driver command ID\n"); + return -ENOSYS; + } + return status; + +nla_put_failure: + kfree_skb(skb); + return -EMSGSIZE; +} + + +/* + * This function handles the user application commands for uCode trace + * + * It retrieves command ID carried with IWL_TM_ATTR_COMMAND and calls to the + * handlers respectively. + * + * If it's an unknown commdn ID, -ENOSYS is replied; otherwise, the returned + * value of the actual command execution is replied to the user application. + * + * @hw: ieee80211_hw object that represents the device + * @tb: gnl message fields from the user space + */ +static int iwl_testmode_trace(struct ieee80211_hw *hw, struct nlattr **tb) +{ + struct iwl_priv *priv = hw->priv; + struct sk_buff *skb; + int status = 0; + struct device *dev = bus(priv)->dev; + + switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { + case IWL_TM_CMD_APP2DEV_BEGIN_TRACE: + if (priv->testmode_trace.trace_enabled) + return -EBUSY; + + if (!tb[IWL_TM_ATTR_TRACE_SIZE]) + priv->testmode_trace.buff_size = TRACE_BUFF_SIZE_DEF; + else + priv->testmode_trace.buff_size = + nla_get_u32(tb[IWL_TM_ATTR_TRACE_SIZE]); + if (!priv->testmode_trace.buff_size) + return -EINVAL; + if (priv->testmode_trace.buff_size < TRACE_BUFF_SIZE_MIN || + priv->testmode_trace.buff_size > TRACE_BUFF_SIZE_MAX) + return -EINVAL; + + priv->testmode_trace.total_size = + priv->testmode_trace.buff_size + TRACE_BUFF_PADD; + priv->testmode_trace.cpu_addr = + dma_alloc_coherent(dev, + priv->testmode_trace.total_size, + &priv->testmode_trace.dma_addr, + GFP_KERNEL); + if (!priv->testmode_trace.cpu_addr) + return -ENOMEM; + priv->testmode_trace.trace_enabled = true; + priv->testmode_trace.trace_addr = (u8 *)PTR_ALIGN( + priv->testmode_trace.cpu_addr, 0x100); + memset(priv->testmode_trace.trace_addr, 0x03B, + priv->testmode_trace.buff_size); + skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, + sizeof(priv->testmode_trace.dma_addr) + 20); + if (!skb) { + IWL_DEBUG_INFO(priv, + "Error allocating memory\n"); + iwl_trace_cleanup(priv); + return -ENOMEM; + } + NLA_PUT(skb, IWL_TM_ATTR_TRACE_ADDR, + sizeof(priv->testmode_trace.dma_addr), + (u64 *)&priv->testmode_trace.dma_addr); + status = cfg80211_testmode_reply(skb); + if (status < 0) { + IWL_DEBUG_INFO(priv, + "Error sending msg : %d\n", + status); + } + priv->testmode_trace.num_chunks = + DIV_ROUND_UP(priv->testmode_trace.buff_size, + DUMP_CHUNK_SIZE); + break; + + case IWL_TM_CMD_APP2DEV_END_TRACE: + iwl_trace_cleanup(priv); + break; + default: + IWL_DEBUG_INFO(priv, "Unknown testmode mem command ID\n"); + return -ENOSYS; + } + return status; + +nla_put_failure: + kfree_skb(skb); + if (nla_get_u32(tb[IWL_TM_ATTR_COMMAND]) == + IWL_TM_CMD_APP2DEV_BEGIN_TRACE) + iwl_trace_cleanup(priv); + return -EMSGSIZE; +} + +static int iwl_testmode_trace_dump(struct ieee80211_hw *hw, struct nlattr **tb, + struct sk_buff *skb, + struct netlink_callback *cb) +{ + struct iwl_priv *priv = hw->priv; + int idx, length; + + if (priv->testmode_trace.trace_enabled && + priv->testmode_trace.trace_addr) { + idx = cb->args[4]; + if (idx >= priv->testmode_trace.num_chunks) + return -ENOENT; + length = DUMP_CHUNK_SIZE; + if (((idx + 1) == priv->testmode_trace.num_chunks) && + (priv->testmode_trace.buff_size % DUMP_CHUNK_SIZE)) + length = priv->testmode_trace.buff_size % + DUMP_CHUNK_SIZE; + + NLA_PUT(skb, IWL_TM_ATTR_TRACE_DUMP, length, + priv->testmode_trace.trace_addr + + (DUMP_CHUNK_SIZE * idx)); + idx++; + cb->args[4] = idx; + return 0; + } else + return -EFAULT; + + nla_put_failure: + return -ENOBUFS; +} + +/* + * This function handles the user application switch ucode ownership. + * + * It retrieves the mandatory fields IWL_TM_ATTR_UCODE_OWNER and + * decide who the current owner of the uCode + * + * If the current owner is OWNERSHIP_TM, then the only host command + * can deliver to uCode is from testmode, all the other host commands + * will dropped. + * + * default driver is the owner of uCode in normal operational mode + * + * @hw: ieee80211_hw object that represents the device + * @tb: gnl message fields from the user space + */ +static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb) +{ + struct iwl_priv *priv = hw->priv; + u8 owner; + + if (!tb[IWL_TM_ATTR_UCODE_OWNER]) { + IWL_DEBUG_INFO(priv, "Error finding ucode owner\n"); + return -ENOMSG; + } + + owner = nla_get_u8(tb[IWL_TM_ATTR_UCODE_OWNER]); + if ((owner == IWL_OWNERSHIP_DRIVER) || (owner == IWL_OWNERSHIP_TM)) + priv->shrd->ucode_owner = owner; + else { + IWL_DEBUG_INFO(priv, "Invalid owner\n"); + return -EINVAL; + } + return 0; +} + +/* + * This function handles the user application commands for SRAM data dump + * + * It retrieves the mandatory fields IWL_TM_ATTR_SRAM_ADDR and + * IWL_TM_ATTR_SRAM_SIZE to decide the memory area for SRAM data reading + * + * Several error will be retured, -EBUSY if the SRAM data retrieved by + * previous command has not been delivered to userspace, or -ENOMSG if + * the mandatory fields (IWL_TM_ATTR_SRAM_ADDR,IWL_TM_ATTR_SRAM_SIZE) + * are missing, or -ENOMEM if the buffer allocation fails. + * + * Otherwise 0 is replied indicating the success of the SRAM reading. + * + * @hw: ieee80211_hw object that represents the device + * @tb: gnl message fields from the user space + */ +static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb) +{ + struct iwl_priv *priv = hw->priv; + u32 base, ofs, size, maxsize; + + if (priv->testmode_sram.sram_readed) + return -EBUSY; + + if (!tb[IWL_TM_ATTR_SRAM_ADDR]) { + IWL_DEBUG_INFO(priv, "Error finding SRAM offset address\n"); + return -ENOMSG; + } + ofs = nla_get_u32(tb[IWL_TM_ATTR_SRAM_ADDR]); + if (!tb[IWL_TM_ATTR_SRAM_SIZE]) { + IWL_DEBUG_INFO(priv, "Error finding size for SRAM reading\n"); + return -ENOMSG; + } + size = nla_get_u32(tb[IWL_TM_ATTR_SRAM_SIZE]); + switch (priv->ucode_type) { + case IWL_UCODE_REGULAR: + maxsize = trans(priv)->ucode_rt.data.len; + break; + case IWL_UCODE_INIT: + maxsize = trans(priv)->ucode_init.data.len; + break; + case IWL_UCODE_WOWLAN: + maxsize = trans(priv)->ucode_wowlan.data.len; + break; + case IWL_UCODE_NONE: + IWL_DEBUG_INFO(priv, "Error, uCode does not been loaded\n"); + return -ENOSYS; + default: + IWL_DEBUG_INFO(priv, "Error, unsupported uCode type\n"); + return -ENOSYS; + } + if ((ofs + size) > maxsize) { + IWL_DEBUG_INFO(priv, "Invalid offset/size: out of range\n"); + return -EINVAL; + } + priv->testmode_sram.buff_size = (size / 4) * 4; + priv->testmode_sram.buff_addr = + kmalloc(priv->testmode_sram.buff_size, GFP_KERNEL); + if (priv->testmode_sram.buff_addr == NULL) { + IWL_DEBUG_INFO(priv, "Error allocating memory\n"); + return -ENOMEM; + } + base = 0x800000; + _iwl_read_targ_mem_words(bus(priv), base + ofs, + priv->testmode_sram.buff_addr, + priv->testmode_sram.buff_size / 4); + priv->testmode_sram.num_chunks = + DIV_ROUND_UP(priv->testmode_sram.buff_size, DUMP_CHUNK_SIZE); + priv->testmode_sram.sram_readed = true; + return 0; +} + +static int iwl_testmode_sram_dump(struct ieee80211_hw *hw, struct nlattr **tb, + struct sk_buff *skb, + struct netlink_callback *cb) +{ + struct iwl_priv *priv = hw->priv; + int idx, length; + + if (priv->testmode_sram.sram_readed) { + idx = cb->args[4]; + if (idx >= priv->testmode_sram.num_chunks) { + iwl_sram_cleanup(priv); + return -ENOENT; + } + length = DUMP_CHUNK_SIZE; + if (((idx + 1) == priv->testmode_sram.num_chunks) && + (priv->testmode_sram.buff_size % DUMP_CHUNK_SIZE)) + length = priv->testmode_sram.buff_size % + DUMP_CHUNK_SIZE; + + NLA_PUT(skb, IWL_TM_ATTR_SRAM_DUMP, length, + priv->testmode_sram.buff_addr + + (DUMP_CHUNK_SIZE * idx)); + idx++; + cb->args[4] = idx; + return 0; + } else + return -EFAULT; + + nla_put_failure: + return -ENOBUFS; +} + + +/* The testmode gnl message handler that takes the gnl message from the + * user space and parses it per the policy iwl_testmode_gnl_msg_policy, then + * invoke the corresponding handlers. + * + * This function is invoked when there is user space application sending + * gnl message through the testmode tunnel NL80211_CMD_TESTMODE regulated + * by nl80211. + * + * It retrieves the mandatory field, IWL_TM_ATTR_COMMAND, before + * dispatching it to the corresponding handler. + * + * If IWL_TM_ATTR_COMMAND is missing, -ENOMSG is replied to user application; + * -ENOSYS is replied to the user application if the command is unknown; + * Otherwise, the command is dispatched to the respective handler. + * + * @hw: ieee80211_hw object that represents the device + * @data: pointer to user space message + * @len: length in byte of @data + */ +int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) +{ + struct nlattr *tb[IWL_TM_ATTR_MAX]; + struct iwl_priv *priv = hw->priv; + int result; + + result = nla_parse(tb, IWL_TM_ATTR_MAX - 1, data, len, + iwl_testmode_gnl_msg_policy); + if (result != 0) { + IWL_DEBUG_INFO(priv, + "Error parsing the gnl message : %d\n", result); + return result; + } + + /* IWL_TM_ATTR_COMMAND is absolutely mandatory */ + if (!tb[IWL_TM_ATTR_COMMAND]) { + IWL_DEBUG_INFO(priv, "Error finding testmode command type\n"); + return -ENOMSG; + } + /* in case multiple accesses to the device happens */ + mutex_lock(&priv->shrd->mutex); + + switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { + case IWL_TM_CMD_APP2DEV_UCODE: + IWL_DEBUG_INFO(priv, "testmode cmd to uCode\n"); + result = iwl_testmode_ucode(hw, tb); + break; + case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32: + case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32: + case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8: + case IWL_TM_CMD_APP2DEV_INDIRECT_REG_READ32: + case IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32: + IWL_DEBUG_INFO(priv, "testmode cmd to register\n"); + result = iwl_testmode_reg(hw, tb); + break; + case IWL_TM_CMD_APP2DEV_GET_DEVICENAME: + case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW: + case IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB: + case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW: + case IWL_TM_CMD_APP2DEV_GET_EEPROM: + case IWL_TM_CMD_APP2DEV_FIXRATE_REQ: + case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: + IWL_DEBUG_INFO(priv, "testmode cmd to driver\n"); + result = iwl_testmode_driver(hw, tb); + break; + + case IWL_TM_CMD_APP2DEV_BEGIN_TRACE: + case IWL_TM_CMD_APP2DEV_END_TRACE: + case IWL_TM_CMD_APP2DEV_READ_TRACE: + IWL_DEBUG_INFO(priv, "testmode uCode trace cmd to driver\n"); + result = iwl_testmode_trace(hw, tb); + break; + + case IWL_TM_CMD_APP2DEV_OWNERSHIP: + IWL_DEBUG_INFO(priv, "testmode change uCode ownership\n"); + result = iwl_testmode_ownership(hw, tb); + break; + + case IWL_TM_CMD_APP2DEV_READ_SRAM: + IWL_DEBUG_INFO(priv, "testmode sram read cmd to driver\n"); + result = iwl_testmode_sram(hw, tb); + break; + + default: + IWL_DEBUG_INFO(priv, "Unknown testmode command\n"); + result = -ENOSYS; + break; + } + + mutex_unlock(&priv->shrd->mutex); + return result; +} + +int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb, + struct netlink_callback *cb, + void *data, int len) +{ + struct nlattr *tb[IWL_TM_ATTR_MAX]; + struct iwl_priv *priv = hw->priv; + int result; + u32 cmd; + + if (cb->args[3]) { + /* offset by 1 since commands start at 0 */ + cmd = cb->args[3] - 1; + } else { + result = nla_parse(tb, IWL_TM_ATTR_MAX - 1, data, len, + iwl_testmode_gnl_msg_policy); + if (result) { + IWL_DEBUG_INFO(priv, + "Error parsing the gnl message : %d\n", result); + return result; + } + + /* IWL_TM_ATTR_COMMAND is absolutely mandatory */ + if (!tb[IWL_TM_ATTR_COMMAND]) { + IWL_DEBUG_INFO(priv, + "Error finding testmode command type\n"); + return -ENOMSG; + } + cmd = nla_get_u32(tb[IWL_TM_ATTR_COMMAND]); + cb->args[3] = cmd + 1; + } + + /* in case multiple accesses to the device happens */ + mutex_lock(&priv->shrd->mutex); + switch (cmd) { + case IWL_TM_CMD_APP2DEV_READ_TRACE: + IWL_DEBUG_INFO(priv, "uCode trace cmd to driver\n"); + result = iwl_testmode_trace_dump(hw, tb, skb, cb); + break; + case IWL_TM_CMD_APP2DEV_DUMP_SRAM: + IWL_DEBUG_INFO(priv, "testmode sram dump cmd to driver\n"); + result = iwl_testmode_sram_dump(hw, tb, skb, cb); + break; + default: + result = -EINVAL; + break; + } + + mutex_unlock(&priv->shrd->mutex); + return result; +} -- cgit v1.2.3 From 8a3cb29c83697cab0f237217112df78439a1b2dd Mon Sep 17 00:00:00 2001 From: Don Fry Date: Mon, 28 Nov 2011 14:34:13 -0800 Subject: iwlwifi: rename iwl-agn-ucode as iwl-ucode iwl-agn-ucode is generic ucode operations, not limited just to iwlagn. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/Makefile | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-ucode.c | 688 --------------------------- drivers/net/wireless/iwlwifi/iwl-ucode.c | 688 +++++++++++++++++++++++++++ 3 files changed, 689 insertions(+), 689 deletions(-) delete mode 100644 drivers/net/wireless/iwlwifi/iwl-agn-ucode.c create mode 100644 drivers/net/wireless/iwlwifi/iwl-ucode.c (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile index 5a052a5e4fb6..86344cefd32f 100644 --- a/drivers/net/wireless/iwlwifi/Makefile +++ b/drivers/net/wireless/iwlwifi/Makefile @@ -1,7 +1,7 @@ # WIFI obj-$(CONFIG_IWLWIFI) += iwlwifi.o iwlwifi-objs := iwl-agn.o iwl-agn-rs.o iwl-mac80211.o -iwlwifi-objs += iwl-agn-ucode.o iwl-agn-tx.o +iwlwifi-objs += iwl-ucode.o iwl-agn-tx.o iwlwifi-objs += iwl-agn-lib.o iwl-agn-calib.o iwl-io.o iwlwifi-objs += iwl-agn-tt.o iwl-agn-sta.o iwl-agn-rx.o diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c deleted file mode 100644 index 76949106dafc..000000000000 --- a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c +++ /dev/null @@ -1,688 +0,0 @@ -/****************************************************************************** - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include -#include -#include -#include -#include - -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-io.h" -#include "iwl-agn-hw.h" -#include "iwl-agn.h" -#include "iwl-agn-calib.h" -#include "iwl-trans.h" -#include "iwl-fh.h" - -static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = { - {COEX_CU_UNASSOC_IDLE_RP, COEX_CU_UNASSOC_IDLE_WP, - 0, COEX_UNASSOC_IDLE_FLAGS}, - {COEX_CU_UNASSOC_MANUAL_SCAN_RP, COEX_CU_UNASSOC_MANUAL_SCAN_WP, - 0, COEX_UNASSOC_MANUAL_SCAN_FLAGS}, - {COEX_CU_UNASSOC_AUTO_SCAN_RP, COEX_CU_UNASSOC_AUTO_SCAN_WP, - 0, COEX_UNASSOC_AUTO_SCAN_FLAGS}, - {COEX_CU_CALIBRATION_RP, COEX_CU_CALIBRATION_WP, - 0, COEX_CALIBRATION_FLAGS}, - {COEX_CU_PERIODIC_CALIBRATION_RP, COEX_CU_PERIODIC_CALIBRATION_WP, - 0, COEX_PERIODIC_CALIBRATION_FLAGS}, - {COEX_CU_CONNECTION_ESTAB_RP, COEX_CU_CONNECTION_ESTAB_WP, - 0, COEX_CONNECTION_ESTAB_FLAGS}, - {COEX_CU_ASSOCIATED_IDLE_RP, COEX_CU_ASSOCIATED_IDLE_WP, - 0, COEX_ASSOCIATED_IDLE_FLAGS}, - {COEX_CU_ASSOC_MANUAL_SCAN_RP, COEX_CU_ASSOC_MANUAL_SCAN_WP, - 0, COEX_ASSOC_MANUAL_SCAN_FLAGS}, - {COEX_CU_ASSOC_AUTO_SCAN_RP, COEX_CU_ASSOC_AUTO_SCAN_WP, - 0, COEX_ASSOC_AUTO_SCAN_FLAGS}, - {COEX_CU_ASSOC_ACTIVE_LEVEL_RP, COEX_CU_ASSOC_ACTIVE_LEVEL_WP, - 0, COEX_ASSOC_ACTIVE_LEVEL_FLAGS}, - {COEX_CU_RF_ON_RP, COEX_CU_RF_ON_WP, 0, COEX_CU_RF_ON_FLAGS}, - {COEX_CU_RF_OFF_RP, COEX_CU_RF_OFF_WP, 0, COEX_RF_OFF_FLAGS}, - {COEX_CU_STAND_ALONE_DEBUG_RP, COEX_CU_STAND_ALONE_DEBUG_WP, - 0, COEX_STAND_ALONE_DEBUG_FLAGS}, - {COEX_CU_IPAN_ASSOC_LEVEL_RP, COEX_CU_IPAN_ASSOC_LEVEL_WP, - 0, COEX_IPAN_ASSOC_LEVEL_FLAGS}, - {COEX_CU_RSRVD1_RP, COEX_CU_RSRVD1_WP, 0, COEX_RSRVD1_FLAGS}, - {COEX_CU_RSRVD2_RP, COEX_CU_RSRVD2_WP, 0, COEX_RSRVD2_FLAGS} -}; - -/****************************************************************************** - * - * uCode download functions - * - ******************************************************************************/ - -static void iwl_free_fw_desc(struct iwl_bus *bus, struct fw_desc *desc) -{ - if (desc->v_addr) - dma_free_coherent(bus->dev, desc->len, - desc->v_addr, desc->p_addr); - desc->v_addr = NULL; - desc->len = 0; -} - -static void iwl_free_fw_img(struct iwl_bus *bus, struct fw_img *img) -{ - iwl_free_fw_desc(bus, &img->code); - iwl_free_fw_desc(bus, &img->data); -} - -void iwl_dealloc_ucode(struct iwl_trans *trans) -{ - iwl_free_fw_img(bus(trans), &trans->ucode_rt); - iwl_free_fw_img(bus(trans), &trans->ucode_init); - iwl_free_fw_img(bus(trans), &trans->ucode_wowlan); -} - -int iwl_alloc_fw_desc(struct iwl_bus *bus, struct fw_desc *desc, - const void *data, size_t len) -{ - if (!len) { - desc->v_addr = NULL; - return -EINVAL; - } - - desc->v_addr = dma_alloc_coherent(bus->dev, len, - &desc->p_addr, GFP_KERNEL); - if (!desc->v_addr) - return -ENOMEM; - - desc->len = len; - memcpy(desc->v_addr, data, len); - return 0; -} - -/* - * ucode - */ -static int iwlagn_load_section(struct iwl_trans *trans, const char *name, - struct fw_desc *image, u32 dst_addr) -{ - struct iwl_bus *bus = bus(trans); - dma_addr_t phy_addr = image->p_addr; - u32 byte_cnt = image->len; - int ret; - - trans->ucode_write_complete = 0; - - iwl_write_direct32(bus, - FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL), - FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE); - - iwl_write_direct32(bus, - FH_SRVC_CHNL_SRAM_ADDR_REG(FH_SRVC_CHNL), dst_addr); - - iwl_write_direct32(bus, - FH_TFDIB_CTRL0_REG(FH_SRVC_CHNL), - phy_addr & FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK); - - iwl_write_direct32(bus, - FH_TFDIB_CTRL1_REG(FH_SRVC_CHNL), - (iwl_get_dma_hi_addr(phy_addr) - << FH_MEM_TFDIB_REG1_ADDR_BITSHIFT) | byte_cnt); - - iwl_write_direct32(bus, - FH_TCSR_CHNL_TX_BUF_STS_REG(FH_SRVC_CHNL), - 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM | - 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX | - FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID); - - iwl_write_direct32(bus, - FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL), - FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | - FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE | - FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD); - - IWL_DEBUG_FW(bus, "%s uCode section being loaded...\n", name); - ret = wait_event_timeout(trans->shrd->wait_command_queue, - trans->ucode_write_complete, 5 * HZ); - if (!ret) { - IWL_ERR(trans, "Could not load the %s uCode section\n", - name); - return -ETIMEDOUT; - } - - return 0; -} - -static inline struct fw_img *iwl_get_ucode_image(struct iwl_trans *trans, - enum iwl_ucode_type ucode_type) -{ - switch (ucode_type) { - case IWL_UCODE_INIT: - return &trans->ucode_init; - case IWL_UCODE_WOWLAN: - return &trans->ucode_wowlan; - case IWL_UCODE_REGULAR: - return &trans->ucode_rt; - case IWL_UCODE_NONE: - break; - } - return NULL; -} - -static int iwlagn_load_given_ucode(struct iwl_trans *trans, - enum iwl_ucode_type ucode_type) -{ - int ret = 0; - struct fw_img *image = iwl_get_ucode_image(trans, ucode_type); - - - if (!image) { - IWL_ERR(trans, "Invalid ucode requested (%d)\n", - ucode_type); - return -EINVAL; - } - - ret = iwlagn_load_section(trans, "INST", &image->code, - IWLAGN_RTC_INST_LOWER_BOUND); - if (ret) - return ret; - - return iwlagn_load_section(trans, "DATA", &image->data, - IWLAGN_RTC_DATA_LOWER_BOUND); -} - -/* - * Calibration - */ -static int iwlagn_set_Xtal_calib(struct iwl_priv *priv) -{ - struct iwl_calib_xtal_freq_cmd cmd; - __le16 *xtal_calib = - (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_XTAL); - - iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD); - cmd.cap_pin1 = le16_to_cpu(xtal_calib[0]); - cmd.cap_pin2 = le16_to_cpu(xtal_calib[1]); - return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); -} - -static int iwlagn_set_temperature_offset_calib(struct iwl_priv *priv) -{ - struct iwl_calib_temperature_offset_cmd cmd; - __le16 *offset_calib = - (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_RAW_TEMPERATURE); - - memset(&cmd, 0, sizeof(cmd)); - iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD); - memcpy(&cmd.radio_sensor_offset, offset_calib, sizeof(*offset_calib)); - if (!(cmd.radio_sensor_offset)) - cmd.radio_sensor_offset = DEFAULT_RADIO_SENSOR_OFFSET; - - IWL_DEBUG_CALIB(priv, "Radio sensor offset: %d\n", - le16_to_cpu(cmd.radio_sensor_offset)); - return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); -} - -static int iwlagn_set_temperature_offset_calib_v2(struct iwl_priv *priv) -{ - struct iwl_calib_temperature_offset_v2_cmd cmd; - __le16 *offset_calib_high = (__le16 *)iwl_eeprom_query_addr(priv, - EEPROM_KELVIN_TEMPERATURE); - __le16 *offset_calib_low = - (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_RAW_TEMPERATURE); - struct iwl_eeprom_calib_hdr *hdr; - - memset(&cmd, 0, sizeof(cmd)); - iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD); - hdr = (struct iwl_eeprom_calib_hdr *)iwl_eeprom_query_addr(priv, - EEPROM_CALIB_ALL); - memcpy(&cmd.radio_sensor_offset_high, offset_calib_high, - sizeof(*offset_calib_high)); - memcpy(&cmd.radio_sensor_offset_low, offset_calib_low, - sizeof(*offset_calib_low)); - if (!(cmd.radio_sensor_offset_low)) { - IWL_DEBUG_CALIB(priv, "no info in EEPROM, use default\n"); - cmd.radio_sensor_offset_low = DEFAULT_RADIO_SENSOR_OFFSET; - cmd.radio_sensor_offset_high = DEFAULT_RADIO_SENSOR_OFFSET; - } - memcpy(&cmd.burntVoltageRef, &hdr->voltage, - sizeof(hdr->voltage)); - - IWL_DEBUG_CALIB(priv, "Radio sensor offset high: %d\n", - le16_to_cpu(cmd.radio_sensor_offset_high)); - IWL_DEBUG_CALIB(priv, "Radio sensor offset low: %d\n", - le16_to_cpu(cmd.radio_sensor_offset_low)); - IWL_DEBUG_CALIB(priv, "Voltage Ref: %d\n", - le16_to_cpu(cmd.burntVoltageRef)); - - return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); -} - -static int iwlagn_send_calib_cfg(struct iwl_priv *priv) -{ - struct iwl_calib_cfg_cmd calib_cfg_cmd; - struct iwl_host_cmd cmd = { - .id = CALIBRATION_CFG_CMD, - .len = { sizeof(struct iwl_calib_cfg_cmd), }, - .data = { &calib_cfg_cmd, }, - }; - - memset(&calib_cfg_cmd, 0, sizeof(calib_cfg_cmd)); - calib_cfg_cmd.ucd_calib_cfg.once.is_enable = IWL_CALIB_INIT_CFG_ALL; - calib_cfg_cmd.ucd_calib_cfg.once.start = IWL_CALIB_INIT_CFG_ALL; - calib_cfg_cmd.ucd_calib_cfg.once.send_res = IWL_CALIB_INIT_CFG_ALL; - calib_cfg_cmd.ucd_calib_cfg.flags = - IWL_CALIB_CFG_FLAG_SEND_COMPLETE_NTFY_MSK; - - return iwl_trans_send_cmd(trans(priv), &cmd); -} - -int iwlagn_rx_calib_result(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, - struct iwl_device_cmd *cmd) -{ - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_calib_hdr *hdr = (struct iwl_calib_hdr *)pkt->u.raw; - int len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; - - /* reduce the size of the length field itself */ - len -= 4; - - if (iwl_calib_set(priv, hdr, len)) - IWL_ERR(priv, "Failed to record calibration data %d\n", - hdr->op_code); - - return 0; -} - -int iwlagn_init_alive_start(struct iwl_priv *priv) -{ - int ret; - - if (priv->cfg->bt_params && - priv->cfg->bt_params->advanced_bt_coexist) { - /* - * Tell uCode we are ready to perform calibration - * need to perform this before any calibration - * no need to close the envlope since we are going - * to load the runtime uCode later. - */ - ret = iwlagn_send_bt_env(priv, IWL_BT_COEX_ENV_OPEN, - BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); - if (ret) - return ret; - - } - - ret = iwlagn_send_calib_cfg(priv); - if (ret) - return ret; - - /** - * temperature offset calibration is only needed for runtime ucode, - * so prepare the value now. - */ - if (priv->cfg->need_temp_offset_calib) { - if (priv->cfg->temp_offset_v2) - return iwlagn_set_temperature_offset_calib_v2(priv); - else - return iwlagn_set_temperature_offset_calib(priv); - } - - return 0; -} - -static int iwlagn_send_wimax_coex(struct iwl_priv *priv) -{ - struct iwl_wimax_coex_cmd coex_cmd; - - if (priv->cfg->base_params->support_wimax_coexist) { - /* UnMask wake up src at associated sleep */ - coex_cmd.flags = COEX_FLAGS_ASSOC_WA_UNMASK_MSK; - - /* UnMask wake up src at unassociated sleep */ - coex_cmd.flags |= COEX_FLAGS_UNASSOC_WA_UNMASK_MSK; - memcpy(coex_cmd.sta_prio, cu_priorities, - sizeof(struct iwl_wimax_coex_event_entry) * - COEX_NUM_OF_EVENTS); - - /* enabling the coexistence feature */ - coex_cmd.flags |= COEX_FLAGS_COEX_ENABLE_MSK; - - /* enabling the priorities tables */ - coex_cmd.flags |= COEX_FLAGS_STA_TABLE_VALID_MSK; - } else { - /* coexistence is disabled */ - memset(&coex_cmd, 0, sizeof(coex_cmd)); - } - return iwl_trans_send_cmd_pdu(trans(priv), - COEX_PRIORITY_TABLE_CMD, CMD_SYNC, - sizeof(coex_cmd), &coex_cmd); -} - -static const u8 iwlagn_bt_prio_tbl[BT_COEX_PRIO_TBL_EVT_MAX] = { - ((BT_COEX_PRIO_TBL_PRIO_BYPASS << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | - (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), - ((BT_COEX_PRIO_TBL_PRIO_BYPASS << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | - (1 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), - ((BT_COEX_PRIO_TBL_PRIO_LOW << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | - (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), - ((BT_COEX_PRIO_TBL_PRIO_LOW << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | - (1 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), - ((BT_COEX_PRIO_TBL_PRIO_HIGH << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | - (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), - ((BT_COEX_PRIO_TBL_PRIO_HIGH << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | - (1 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), - ((BT_COEX_PRIO_TBL_PRIO_BYPASS << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | - (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), - ((BT_COEX_PRIO_TBL_PRIO_COEX_OFF << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | - (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), - ((BT_COEX_PRIO_TBL_PRIO_COEX_ON << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | - (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), - 0, 0, 0, 0, 0, 0, 0 -}; - -void iwlagn_send_prio_tbl(struct iwl_priv *priv) -{ - struct iwl_bt_coex_prio_table_cmd prio_tbl_cmd; - - memcpy(prio_tbl_cmd.prio_tbl, iwlagn_bt_prio_tbl, - sizeof(iwlagn_bt_prio_tbl)); - if (iwl_trans_send_cmd_pdu(trans(priv), - REPLY_BT_COEX_PRIO_TABLE, CMD_SYNC, - sizeof(prio_tbl_cmd), &prio_tbl_cmd)) - IWL_ERR(priv, "failed to send BT prio tbl command\n"); -} - -int iwlagn_send_bt_env(struct iwl_priv *priv, u8 action, u8 type) -{ - struct iwl_bt_coex_prot_env_cmd env_cmd; - int ret; - - env_cmd.action = action; - env_cmd.type = type; - ret = iwl_trans_send_cmd_pdu(trans(priv), - REPLY_BT_COEX_PROT_ENV, CMD_SYNC, - sizeof(env_cmd), &env_cmd); - if (ret) - IWL_ERR(priv, "failed to send BT env command\n"); - return ret; -} - - -static int iwlagn_alive_notify(struct iwl_priv *priv) -{ - struct iwl_rxon_context *ctx; - int ret; - - if (!priv->tx_cmd_pool) - priv->tx_cmd_pool = - kmem_cache_create("iwlagn_dev_cmd", - sizeof(struct iwl_device_cmd), - sizeof(void *), 0, NULL); - - if (!priv->tx_cmd_pool) - return -ENOMEM; - - iwl_trans_tx_start(trans(priv)); - for_each_context(priv, ctx) - ctx->last_tx_rejected = false; - - ret = iwlagn_send_wimax_coex(priv); - if (ret) - return ret; - - if (!priv->cfg->no_xtal_calib) { - ret = iwlagn_set_Xtal_calib(priv); - if (ret) - return ret; - } - - return iwl_send_calib_results(priv); -} - - -/** - * iwl_verify_inst_sparse - verify runtime uCode image in card vs. host, - * using sample data 100 bytes apart. If these sample points are good, - * it's a pretty good bet that everything between them is good, too. - */ -static int iwl_verify_inst_sparse(struct iwl_bus *bus, - struct fw_desc *fw_desc) -{ - __le32 *image = (__le32 *)fw_desc->v_addr; - u32 len = fw_desc->len; - u32 val; - u32 i; - - IWL_DEBUG_FW(bus, "ucode inst image size is %u\n", len); - - for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { - /* read data comes through single port, auto-incr addr */ - /* NOTE: Use the debugless read so we don't flood kernel log - * if IWL_DL_IO is set */ - iwl_write_direct32(bus, HBUS_TARG_MEM_RADDR, - i + IWLAGN_RTC_INST_LOWER_BOUND); - val = iwl_read32(bus, HBUS_TARG_MEM_RDAT); - if (val != le32_to_cpu(*image)) - return -EIO; - } - - return 0; -} - -static void iwl_print_mismatch_inst(struct iwl_bus *bus, - struct fw_desc *fw_desc) -{ - __le32 *image = (__le32 *)fw_desc->v_addr; - u32 len = fw_desc->len; - u32 val; - u32 offs; - int errors = 0; - - IWL_DEBUG_FW(bus, "ucode inst image size is %u\n", len); - - iwl_write_direct32(bus, HBUS_TARG_MEM_RADDR, - IWLAGN_RTC_INST_LOWER_BOUND); - - for (offs = 0; - offs < len && errors < 20; - offs += sizeof(u32), image++) { - /* read data comes through single port, auto-incr addr */ - val = iwl_read32(bus, HBUS_TARG_MEM_RDAT); - if (val != le32_to_cpu(*image)) { - IWL_ERR(bus, "uCode INST section at " - "offset 0x%x, is 0x%x, s/b 0x%x\n", - offs, val, le32_to_cpu(*image)); - errors++; - } - } -} - -/** - * iwl_verify_ucode - determine which instruction image is in SRAM, - * and verify its contents - */ -static int iwl_verify_ucode(struct iwl_trans *trans, - enum iwl_ucode_type ucode_type) -{ - struct fw_img *img = iwl_get_ucode_image(trans, ucode_type); - - if (!img) { - IWL_ERR(trans, "Invalid ucode requested (%d)\n", ucode_type); - return -EINVAL; - } - - if (!iwl_verify_inst_sparse(bus(trans), &img->code)) { - IWL_DEBUG_FW(trans, "uCode is good in inst SRAM\n"); - return 0; - } - - IWL_ERR(trans, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n"); - - iwl_print_mismatch_inst(bus(trans), &img->code); - return -EIO; -} - -struct iwlagn_alive_data { - bool valid; - u8 subtype; -}; - -static void iwlagn_alive_fn(struct iwl_priv *priv, - struct iwl_rx_packet *pkt, - void *data) -{ - struct iwlagn_alive_data *alive_data = data; - struct iwl_alive_resp *palive; - - palive = &pkt->u.alive_frame; - - IWL_DEBUG_FW(priv, "Alive ucode status 0x%08X revision " - "0x%01X 0x%01X\n", - palive->is_valid, palive->ver_type, - palive->ver_subtype); - - priv->device_pointers.error_event_table = - le32_to_cpu(palive->error_event_table_ptr); - priv->device_pointers.log_event_table = - le32_to_cpu(palive->log_event_table_ptr); - - alive_data->subtype = palive->ver_subtype; - alive_data->valid = palive->is_valid == UCODE_VALID_OK; -} - -#define UCODE_ALIVE_TIMEOUT HZ -#define UCODE_CALIB_TIMEOUT (2*HZ) - -int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, - enum iwl_ucode_type ucode_type) -{ - struct iwl_notification_wait alive_wait; - struct iwlagn_alive_data alive_data; - int ret; - enum iwl_ucode_type old_type; - - ret = iwl_trans_start_device(trans(priv)); - if (ret) - return ret; - - iwlagn_init_notification_wait(priv, &alive_wait, REPLY_ALIVE, - iwlagn_alive_fn, &alive_data); - - old_type = priv->ucode_type; - priv->ucode_type = ucode_type; - - ret = iwlagn_load_given_ucode(trans(priv), ucode_type); - if (ret) { - priv->ucode_type = old_type; - iwlagn_remove_notification(priv, &alive_wait); - return ret; - } - - iwl_trans_kick_nic(trans(priv)); - - /* - * Some things may run in the background now, but we - * just wait for the ALIVE notification here. - */ - ret = iwlagn_wait_notification(priv, &alive_wait, UCODE_ALIVE_TIMEOUT); - if (ret) { - priv->ucode_type = old_type; - return ret; - } - - if (!alive_data.valid) { - IWL_ERR(priv, "Loaded ucode is not valid!\n"); - priv->ucode_type = old_type; - return -EIO; - } - - /* - * This step takes a long time (60-80ms!!) and - * WoWLAN image should be loaded quickly, so - * skip it for WoWLAN. - */ - if (ucode_type != IWL_UCODE_WOWLAN) { - ret = iwl_verify_ucode(trans(priv), ucode_type); - if (ret) { - priv->ucode_type = old_type; - return ret; - } - - /* delay a bit to give rfkill time to run */ - msleep(5); - } - - ret = iwlagn_alive_notify(priv); - if (ret) { - IWL_WARN(priv, - "Could not complete ALIVE transition: %d\n", ret); - priv->ucode_type = old_type; - return ret; - } - - return 0; -} - -int iwlagn_run_init_ucode(struct iwl_priv *priv) -{ - struct iwl_notification_wait calib_wait; - int ret; - - lockdep_assert_held(&priv->shrd->mutex); - - /* No init ucode required? Curious, but maybe ok */ - if (!trans(priv)->ucode_init.code.len) - return 0; - - if (priv->ucode_type != IWL_UCODE_NONE) - return 0; - - iwlagn_init_notification_wait(priv, &calib_wait, - CALIBRATION_COMPLETE_NOTIFICATION, - NULL, NULL); - - /* Will also start the device */ - ret = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_INIT); - if (ret) - goto error; - - ret = iwlagn_init_alive_start(priv); - if (ret) - goto error; - - /* - * Some things may run in the background now, but we - * just wait for the calibration complete notification. - */ - ret = iwlagn_wait_notification(priv, &calib_wait, UCODE_CALIB_TIMEOUT); - - goto out; - - error: - iwlagn_remove_notification(priv, &calib_wait); - out: - /* Whatever happened, stop the device */ - iwl_trans_stop_device(trans(priv)); - return ret; -} diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c new file mode 100644 index 000000000000..76949106dafc --- /dev/null +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -0,0 +1,688 @@ +/****************************************************************************** + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, + * USA + * + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + *****************************************************************************/ + +#include +#include +#include +#include +#include + +#include "iwl-dev.h" +#include "iwl-core.h" +#include "iwl-io.h" +#include "iwl-agn-hw.h" +#include "iwl-agn.h" +#include "iwl-agn-calib.h" +#include "iwl-trans.h" +#include "iwl-fh.h" + +static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = { + {COEX_CU_UNASSOC_IDLE_RP, COEX_CU_UNASSOC_IDLE_WP, + 0, COEX_UNASSOC_IDLE_FLAGS}, + {COEX_CU_UNASSOC_MANUAL_SCAN_RP, COEX_CU_UNASSOC_MANUAL_SCAN_WP, + 0, COEX_UNASSOC_MANUAL_SCAN_FLAGS}, + {COEX_CU_UNASSOC_AUTO_SCAN_RP, COEX_CU_UNASSOC_AUTO_SCAN_WP, + 0, COEX_UNASSOC_AUTO_SCAN_FLAGS}, + {COEX_CU_CALIBRATION_RP, COEX_CU_CALIBRATION_WP, + 0, COEX_CALIBRATION_FLAGS}, + {COEX_CU_PERIODIC_CALIBRATION_RP, COEX_CU_PERIODIC_CALIBRATION_WP, + 0, COEX_PERIODIC_CALIBRATION_FLAGS}, + {COEX_CU_CONNECTION_ESTAB_RP, COEX_CU_CONNECTION_ESTAB_WP, + 0, COEX_CONNECTION_ESTAB_FLAGS}, + {COEX_CU_ASSOCIATED_IDLE_RP, COEX_CU_ASSOCIATED_IDLE_WP, + 0, COEX_ASSOCIATED_IDLE_FLAGS}, + {COEX_CU_ASSOC_MANUAL_SCAN_RP, COEX_CU_ASSOC_MANUAL_SCAN_WP, + 0, COEX_ASSOC_MANUAL_SCAN_FLAGS}, + {COEX_CU_ASSOC_AUTO_SCAN_RP, COEX_CU_ASSOC_AUTO_SCAN_WP, + 0, COEX_ASSOC_AUTO_SCAN_FLAGS}, + {COEX_CU_ASSOC_ACTIVE_LEVEL_RP, COEX_CU_ASSOC_ACTIVE_LEVEL_WP, + 0, COEX_ASSOC_ACTIVE_LEVEL_FLAGS}, + {COEX_CU_RF_ON_RP, COEX_CU_RF_ON_WP, 0, COEX_CU_RF_ON_FLAGS}, + {COEX_CU_RF_OFF_RP, COEX_CU_RF_OFF_WP, 0, COEX_RF_OFF_FLAGS}, + {COEX_CU_STAND_ALONE_DEBUG_RP, COEX_CU_STAND_ALONE_DEBUG_WP, + 0, COEX_STAND_ALONE_DEBUG_FLAGS}, + {COEX_CU_IPAN_ASSOC_LEVEL_RP, COEX_CU_IPAN_ASSOC_LEVEL_WP, + 0, COEX_IPAN_ASSOC_LEVEL_FLAGS}, + {COEX_CU_RSRVD1_RP, COEX_CU_RSRVD1_WP, 0, COEX_RSRVD1_FLAGS}, + {COEX_CU_RSRVD2_RP, COEX_CU_RSRVD2_WP, 0, COEX_RSRVD2_FLAGS} +}; + +/****************************************************************************** + * + * uCode download functions + * + ******************************************************************************/ + +static void iwl_free_fw_desc(struct iwl_bus *bus, struct fw_desc *desc) +{ + if (desc->v_addr) + dma_free_coherent(bus->dev, desc->len, + desc->v_addr, desc->p_addr); + desc->v_addr = NULL; + desc->len = 0; +} + +static void iwl_free_fw_img(struct iwl_bus *bus, struct fw_img *img) +{ + iwl_free_fw_desc(bus, &img->code); + iwl_free_fw_desc(bus, &img->data); +} + +void iwl_dealloc_ucode(struct iwl_trans *trans) +{ + iwl_free_fw_img(bus(trans), &trans->ucode_rt); + iwl_free_fw_img(bus(trans), &trans->ucode_init); + iwl_free_fw_img(bus(trans), &trans->ucode_wowlan); +} + +int iwl_alloc_fw_desc(struct iwl_bus *bus, struct fw_desc *desc, + const void *data, size_t len) +{ + if (!len) { + desc->v_addr = NULL; + return -EINVAL; + } + + desc->v_addr = dma_alloc_coherent(bus->dev, len, + &desc->p_addr, GFP_KERNEL); + if (!desc->v_addr) + return -ENOMEM; + + desc->len = len; + memcpy(desc->v_addr, data, len); + return 0; +} + +/* + * ucode + */ +static int iwlagn_load_section(struct iwl_trans *trans, const char *name, + struct fw_desc *image, u32 dst_addr) +{ + struct iwl_bus *bus = bus(trans); + dma_addr_t phy_addr = image->p_addr; + u32 byte_cnt = image->len; + int ret; + + trans->ucode_write_complete = 0; + + iwl_write_direct32(bus, + FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL), + FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE); + + iwl_write_direct32(bus, + FH_SRVC_CHNL_SRAM_ADDR_REG(FH_SRVC_CHNL), dst_addr); + + iwl_write_direct32(bus, + FH_TFDIB_CTRL0_REG(FH_SRVC_CHNL), + phy_addr & FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK); + + iwl_write_direct32(bus, + FH_TFDIB_CTRL1_REG(FH_SRVC_CHNL), + (iwl_get_dma_hi_addr(phy_addr) + << FH_MEM_TFDIB_REG1_ADDR_BITSHIFT) | byte_cnt); + + iwl_write_direct32(bus, + FH_TCSR_CHNL_TX_BUF_STS_REG(FH_SRVC_CHNL), + 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM | + 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX | + FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID); + + iwl_write_direct32(bus, + FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL), + FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | + FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE | + FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD); + + IWL_DEBUG_FW(bus, "%s uCode section being loaded...\n", name); + ret = wait_event_timeout(trans->shrd->wait_command_queue, + trans->ucode_write_complete, 5 * HZ); + if (!ret) { + IWL_ERR(trans, "Could not load the %s uCode section\n", + name); + return -ETIMEDOUT; + } + + return 0; +} + +static inline struct fw_img *iwl_get_ucode_image(struct iwl_trans *trans, + enum iwl_ucode_type ucode_type) +{ + switch (ucode_type) { + case IWL_UCODE_INIT: + return &trans->ucode_init; + case IWL_UCODE_WOWLAN: + return &trans->ucode_wowlan; + case IWL_UCODE_REGULAR: + return &trans->ucode_rt; + case IWL_UCODE_NONE: + break; + } + return NULL; +} + +static int iwlagn_load_given_ucode(struct iwl_trans *trans, + enum iwl_ucode_type ucode_type) +{ + int ret = 0; + struct fw_img *image = iwl_get_ucode_image(trans, ucode_type); + + + if (!image) { + IWL_ERR(trans, "Invalid ucode requested (%d)\n", + ucode_type); + return -EINVAL; + } + + ret = iwlagn_load_section(trans, "INST", &image->code, + IWLAGN_RTC_INST_LOWER_BOUND); + if (ret) + return ret; + + return iwlagn_load_section(trans, "DATA", &image->data, + IWLAGN_RTC_DATA_LOWER_BOUND); +} + +/* + * Calibration + */ +static int iwlagn_set_Xtal_calib(struct iwl_priv *priv) +{ + struct iwl_calib_xtal_freq_cmd cmd; + __le16 *xtal_calib = + (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_XTAL); + + iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD); + cmd.cap_pin1 = le16_to_cpu(xtal_calib[0]); + cmd.cap_pin2 = le16_to_cpu(xtal_calib[1]); + return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); +} + +static int iwlagn_set_temperature_offset_calib(struct iwl_priv *priv) +{ + struct iwl_calib_temperature_offset_cmd cmd; + __le16 *offset_calib = + (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_RAW_TEMPERATURE); + + memset(&cmd, 0, sizeof(cmd)); + iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD); + memcpy(&cmd.radio_sensor_offset, offset_calib, sizeof(*offset_calib)); + if (!(cmd.radio_sensor_offset)) + cmd.radio_sensor_offset = DEFAULT_RADIO_SENSOR_OFFSET; + + IWL_DEBUG_CALIB(priv, "Radio sensor offset: %d\n", + le16_to_cpu(cmd.radio_sensor_offset)); + return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); +} + +static int iwlagn_set_temperature_offset_calib_v2(struct iwl_priv *priv) +{ + struct iwl_calib_temperature_offset_v2_cmd cmd; + __le16 *offset_calib_high = (__le16 *)iwl_eeprom_query_addr(priv, + EEPROM_KELVIN_TEMPERATURE); + __le16 *offset_calib_low = + (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_RAW_TEMPERATURE); + struct iwl_eeprom_calib_hdr *hdr; + + memset(&cmd, 0, sizeof(cmd)); + iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD); + hdr = (struct iwl_eeprom_calib_hdr *)iwl_eeprom_query_addr(priv, + EEPROM_CALIB_ALL); + memcpy(&cmd.radio_sensor_offset_high, offset_calib_high, + sizeof(*offset_calib_high)); + memcpy(&cmd.radio_sensor_offset_low, offset_calib_low, + sizeof(*offset_calib_low)); + if (!(cmd.radio_sensor_offset_low)) { + IWL_DEBUG_CALIB(priv, "no info in EEPROM, use default\n"); + cmd.radio_sensor_offset_low = DEFAULT_RADIO_SENSOR_OFFSET; + cmd.radio_sensor_offset_high = DEFAULT_RADIO_SENSOR_OFFSET; + } + memcpy(&cmd.burntVoltageRef, &hdr->voltage, + sizeof(hdr->voltage)); + + IWL_DEBUG_CALIB(priv, "Radio sensor offset high: %d\n", + le16_to_cpu(cmd.radio_sensor_offset_high)); + IWL_DEBUG_CALIB(priv, "Radio sensor offset low: %d\n", + le16_to_cpu(cmd.radio_sensor_offset_low)); + IWL_DEBUG_CALIB(priv, "Voltage Ref: %d\n", + le16_to_cpu(cmd.burntVoltageRef)); + + return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); +} + +static int iwlagn_send_calib_cfg(struct iwl_priv *priv) +{ + struct iwl_calib_cfg_cmd calib_cfg_cmd; + struct iwl_host_cmd cmd = { + .id = CALIBRATION_CFG_CMD, + .len = { sizeof(struct iwl_calib_cfg_cmd), }, + .data = { &calib_cfg_cmd, }, + }; + + memset(&calib_cfg_cmd, 0, sizeof(calib_cfg_cmd)); + calib_cfg_cmd.ucd_calib_cfg.once.is_enable = IWL_CALIB_INIT_CFG_ALL; + calib_cfg_cmd.ucd_calib_cfg.once.start = IWL_CALIB_INIT_CFG_ALL; + calib_cfg_cmd.ucd_calib_cfg.once.send_res = IWL_CALIB_INIT_CFG_ALL; + calib_cfg_cmd.ucd_calib_cfg.flags = + IWL_CALIB_CFG_FLAG_SEND_COMPLETE_NTFY_MSK; + + return iwl_trans_send_cmd(trans(priv), &cmd); +} + +int iwlagn_rx_calib_result(struct iwl_priv *priv, + struct iwl_rx_mem_buffer *rxb, + struct iwl_device_cmd *cmd) +{ + struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct iwl_calib_hdr *hdr = (struct iwl_calib_hdr *)pkt->u.raw; + int len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; + + /* reduce the size of the length field itself */ + len -= 4; + + if (iwl_calib_set(priv, hdr, len)) + IWL_ERR(priv, "Failed to record calibration data %d\n", + hdr->op_code); + + return 0; +} + +int iwlagn_init_alive_start(struct iwl_priv *priv) +{ + int ret; + + if (priv->cfg->bt_params && + priv->cfg->bt_params->advanced_bt_coexist) { + /* + * Tell uCode we are ready to perform calibration + * need to perform this before any calibration + * no need to close the envlope since we are going + * to load the runtime uCode later. + */ + ret = iwlagn_send_bt_env(priv, IWL_BT_COEX_ENV_OPEN, + BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); + if (ret) + return ret; + + } + + ret = iwlagn_send_calib_cfg(priv); + if (ret) + return ret; + + /** + * temperature offset calibration is only needed for runtime ucode, + * so prepare the value now. + */ + if (priv->cfg->need_temp_offset_calib) { + if (priv->cfg->temp_offset_v2) + return iwlagn_set_temperature_offset_calib_v2(priv); + else + return iwlagn_set_temperature_offset_calib(priv); + } + + return 0; +} + +static int iwlagn_send_wimax_coex(struct iwl_priv *priv) +{ + struct iwl_wimax_coex_cmd coex_cmd; + + if (priv->cfg->base_params->support_wimax_coexist) { + /* UnMask wake up src at associated sleep */ + coex_cmd.flags = COEX_FLAGS_ASSOC_WA_UNMASK_MSK; + + /* UnMask wake up src at unassociated sleep */ + coex_cmd.flags |= COEX_FLAGS_UNASSOC_WA_UNMASK_MSK; + memcpy(coex_cmd.sta_prio, cu_priorities, + sizeof(struct iwl_wimax_coex_event_entry) * + COEX_NUM_OF_EVENTS); + + /* enabling the coexistence feature */ + coex_cmd.flags |= COEX_FLAGS_COEX_ENABLE_MSK; + + /* enabling the priorities tables */ + coex_cmd.flags |= COEX_FLAGS_STA_TABLE_VALID_MSK; + } else { + /* coexistence is disabled */ + memset(&coex_cmd, 0, sizeof(coex_cmd)); + } + return iwl_trans_send_cmd_pdu(trans(priv), + COEX_PRIORITY_TABLE_CMD, CMD_SYNC, + sizeof(coex_cmd), &coex_cmd); +} + +static const u8 iwlagn_bt_prio_tbl[BT_COEX_PRIO_TBL_EVT_MAX] = { + ((BT_COEX_PRIO_TBL_PRIO_BYPASS << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | + (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), + ((BT_COEX_PRIO_TBL_PRIO_BYPASS << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | + (1 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), + ((BT_COEX_PRIO_TBL_PRIO_LOW << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | + (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), + ((BT_COEX_PRIO_TBL_PRIO_LOW << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | + (1 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), + ((BT_COEX_PRIO_TBL_PRIO_HIGH << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | + (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), + ((BT_COEX_PRIO_TBL_PRIO_HIGH << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | + (1 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), + ((BT_COEX_PRIO_TBL_PRIO_BYPASS << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | + (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), + ((BT_COEX_PRIO_TBL_PRIO_COEX_OFF << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | + (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), + ((BT_COEX_PRIO_TBL_PRIO_COEX_ON << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | + (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), + 0, 0, 0, 0, 0, 0, 0 +}; + +void iwlagn_send_prio_tbl(struct iwl_priv *priv) +{ + struct iwl_bt_coex_prio_table_cmd prio_tbl_cmd; + + memcpy(prio_tbl_cmd.prio_tbl, iwlagn_bt_prio_tbl, + sizeof(iwlagn_bt_prio_tbl)); + if (iwl_trans_send_cmd_pdu(trans(priv), + REPLY_BT_COEX_PRIO_TABLE, CMD_SYNC, + sizeof(prio_tbl_cmd), &prio_tbl_cmd)) + IWL_ERR(priv, "failed to send BT prio tbl command\n"); +} + +int iwlagn_send_bt_env(struct iwl_priv *priv, u8 action, u8 type) +{ + struct iwl_bt_coex_prot_env_cmd env_cmd; + int ret; + + env_cmd.action = action; + env_cmd.type = type; + ret = iwl_trans_send_cmd_pdu(trans(priv), + REPLY_BT_COEX_PROT_ENV, CMD_SYNC, + sizeof(env_cmd), &env_cmd); + if (ret) + IWL_ERR(priv, "failed to send BT env command\n"); + return ret; +} + + +static int iwlagn_alive_notify(struct iwl_priv *priv) +{ + struct iwl_rxon_context *ctx; + int ret; + + if (!priv->tx_cmd_pool) + priv->tx_cmd_pool = + kmem_cache_create("iwlagn_dev_cmd", + sizeof(struct iwl_device_cmd), + sizeof(void *), 0, NULL); + + if (!priv->tx_cmd_pool) + return -ENOMEM; + + iwl_trans_tx_start(trans(priv)); + for_each_context(priv, ctx) + ctx->last_tx_rejected = false; + + ret = iwlagn_send_wimax_coex(priv); + if (ret) + return ret; + + if (!priv->cfg->no_xtal_calib) { + ret = iwlagn_set_Xtal_calib(priv); + if (ret) + return ret; + } + + return iwl_send_calib_results(priv); +} + + +/** + * iwl_verify_inst_sparse - verify runtime uCode image in card vs. host, + * using sample data 100 bytes apart. If these sample points are good, + * it's a pretty good bet that everything between them is good, too. + */ +static int iwl_verify_inst_sparse(struct iwl_bus *bus, + struct fw_desc *fw_desc) +{ + __le32 *image = (__le32 *)fw_desc->v_addr; + u32 len = fw_desc->len; + u32 val; + u32 i; + + IWL_DEBUG_FW(bus, "ucode inst image size is %u\n", len); + + for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { + /* read data comes through single port, auto-incr addr */ + /* NOTE: Use the debugless read so we don't flood kernel log + * if IWL_DL_IO is set */ + iwl_write_direct32(bus, HBUS_TARG_MEM_RADDR, + i + IWLAGN_RTC_INST_LOWER_BOUND); + val = iwl_read32(bus, HBUS_TARG_MEM_RDAT); + if (val != le32_to_cpu(*image)) + return -EIO; + } + + return 0; +} + +static void iwl_print_mismatch_inst(struct iwl_bus *bus, + struct fw_desc *fw_desc) +{ + __le32 *image = (__le32 *)fw_desc->v_addr; + u32 len = fw_desc->len; + u32 val; + u32 offs; + int errors = 0; + + IWL_DEBUG_FW(bus, "ucode inst image size is %u\n", len); + + iwl_write_direct32(bus, HBUS_TARG_MEM_RADDR, + IWLAGN_RTC_INST_LOWER_BOUND); + + for (offs = 0; + offs < len && errors < 20; + offs += sizeof(u32), image++) { + /* read data comes through single port, auto-incr addr */ + val = iwl_read32(bus, HBUS_TARG_MEM_RDAT); + if (val != le32_to_cpu(*image)) { + IWL_ERR(bus, "uCode INST section at " + "offset 0x%x, is 0x%x, s/b 0x%x\n", + offs, val, le32_to_cpu(*image)); + errors++; + } + } +} + +/** + * iwl_verify_ucode - determine which instruction image is in SRAM, + * and verify its contents + */ +static int iwl_verify_ucode(struct iwl_trans *trans, + enum iwl_ucode_type ucode_type) +{ + struct fw_img *img = iwl_get_ucode_image(trans, ucode_type); + + if (!img) { + IWL_ERR(trans, "Invalid ucode requested (%d)\n", ucode_type); + return -EINVAL; + } + + if (!iwl_verify_inst_sparse(bus(trans), &img->code)) { + IWL_DEBUG_FW(trans, "uCode is good in inst SRAM\n"); + return 0; + } + + IWL_ERR(trans, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n"); + + iwl_print_mismatch_inst(bus(trans), &img->code); + return -EIO; +} + +struct iwlagn_alive_data { + bool valid; + u8 subtype; +}; + +static void iwlagn_alive_fn(struct iwl_priv *priv, + struct iwl_rx_packet *pkt, + void *data) +{ + struct iwlagn_alive_data *alive_data = data; + struct iwl_alive_resp *palive; + + palive = &pkt->u.alive_frame; + + IWL_DEBUG_FW(priv, "Alive ucode status 0x%08X revision " + "0x%01X 0x%01X\n", + palive->is_valid, palive->ver_type, + palive->ver_subtype); + + priv->device_pointers.error_event_table = + le32_to_cpu(palive->error_event_table_ptr); + priv->device_pointers.log_event_table = + le32_to_cpu(palive->log_event_table_ptr); + + alive_data->subtype = palive->ver_subtype; + alive_data->valid = palive->is_valid == UCODE_VALID_OK; +} + +#define UCODE_ALIVE_TIMEOUT HZ +#define UCODE_CALIB_TIMEOUT (2*HZ) + +int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, + enum iwl_ucode_type ucode_type) +{ + struct iwl_notification_wait alive_wait; + struct iwlagn_alive_data alive_data; + int ret; + enum iwl_ucode_type old_type; + + ret = iwl_trans_start_device(trans(priv)); + if (ret) + return ret; + + iwlagn_init_notification_wait(priv, &alive_wait, REPLY_ALIVE, + iwlagn_alive_fn, &alive_data); + + old_type = priv->ucode_type; + priv->ucode_type = ucode_type; + + ret = iwlagn_load_given_ucode(trans(priv), ucode_type); + if (ret) { + priv->ucode_type = old_type; + iwlagn_remove_notification(priv, &alive_wait); + return ret; + } + + iwl_trans_kick_nic(trans(priv)); + + /* + * Some things may run in the background now, but we + * just wait for the ALIVE notification here. + */ + ret = iwlagn_wait_notification(priv, &alive_wait, UCODE_ALIVE_TIMEOUT); + if (ret) { + priv->ucode_type = old_type; + return ret; + } + + if (!alive_data.valid) { + IWL_ERR(priv, "Loaded ucode is not valid!\n"); + priv->ucode_type = old_type; + return -EIO; + } + + /* + * This step takes a long time (60-80ms!!) and + * WoWLAN image should be loaded quickly, so + * skip it for WoWLAN. + */ + if (ucode_type != IWL_UCODE_WOWLAN) { + ret = iwl_verify_ucode(trans(priv), ucode_type); + if (ret) { + priv->ucode_type = old_type; + return ret; + } + + /* delay a bit to give rfkill time to run */ + msleep(5); + } + + ret = iwlagn_alive_notify(priv); + if (ret) { + IWL_WARN(priv, + "Could not complete ALIVE transition: %d\n", ret); + priv->ucode_type = old_type; + return ret; + } + + return 0; +} + +int iwlagn_run_init_ucode(struct iwl_priv *priv) +{ + struct iwl_notification_wait calib_wait; + int ret; + + lockdep_assert_held(&priv->shrd->mutex); + + /* No init ucode required? Curious, but maybe ok */ + if (!trans(priv)->ucode_init.code.len) + return 0; + + if (priv->ucode_type != IWL_UCODE_NONE) + return 0; + + iwlagn_init_notification_wait(priv, &calib_wait, + CALIBRATION_COMPLETE_NOTIFICATION, + NULL, NULL); + + /* Will also start the device */ + ret = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_INIT); + if (ret) + goto error; + + ret = iwlagn_init_alive_start(priv); + if (ret) + goto error; + + /* + * Some things may run in the background now, but we + * just wait for the calibration complete notification. + */ + ret = iwlagn_wait_notification(priv, &calib_wait, UCODE_CALIB_TIMEOUT); + + goto out; + + error: + iwlagn_remove_notification(priv, &calib_wait); + out: + /* Whatever happened, stop the device */ + iwl_trans_stop_device(trans(priv)); + return ret; +} -- cgit v1.2.3 From 66128b144b5107132966fabfc3843f8bdac68d2b Mon Sep 17 00:00:00 2001 From: Don Fry Date: Mon, 28 Nov 2011 14:35:14 -0800 Subject: iwlwifi: replace iwl_priv reference with iwl_trans for ucode. Replace the references to the iwl_priv structure with the iwl_trans structure as the priv structure is never referenced other than to access the trans structure. Rename from iwlagn to iwl. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn.c | 6 ++-- drivers/net/wireless/iwlwifi/iwl-agn.h | 4 +-- drivers/net/wireless/iwlwifi/iwl-ucode.c | 62 ++++++++++++++++---------------- 3 files changed, 36 insertions(+), 36 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index db0d3a84b1e4..10d3dc9cf9e6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1232,14 +1232,14 @@ int iwl_alive_start(struct iwl_priv *priv) priv->bt_valid = IWLAGN_BT_VALID_ENABLE_FLAGS; priv->cur_rssi_ctx = NULL; - iwlagn_send_prio_tbl(priv); + iwl_send_prio_tbl(trans(priv)); /* FIXME: w/a to force change uCode BT state machine */ - ret = iwlagn_send_bt_env(priv, IWL_BT_COEX_ENV_OPEN, + ret = iwl_send_bt_env(trans(priv), IWL_BT_COEX_ENV_OPEN, BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); if (ret) return ret; - ret = iwlagn_send_bt_env(priv, IWL_BT_COEX_ENV_CLOSE, + ret = iwl_send_bt_env(trans(priv), IWL_BT_COEX_ENV_CLOSE, BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); if (ret) return ret; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 2f446a353514..0db0a8fb5679 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -108,8 +108,8 @@ void iwlagn_config_ht40(struct ieee80211_conf *conf, int iwlagn_rx_calib_result(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, struct iwl_device_cmd *cmd); -int iwlagn_send_bt_env(struct iwl_priv *priv, u8 action, u8 type); -void iwlagn_send_prio_tbl(struct iwl_priv *priv); +int iwl_send_bt_env(struct iwl_trans *trans, u8 action, u8 type); +void iwl_send_prio_tbl(struct iwl_trans *trans); int iwlagn_run_init_ucode(struct iwl_priv *priv); int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, enum iwl_ucode_type ucode_type); diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 76949106dafc..0da4b8ece11c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -122,7 +122,7 @@ int iwl_alloc_fw_desc(struct iwl_bus *bus, struct fw_desc *desc, /* * ucode */ -static int iwlagn_load_section(struct iwl_trans *trans, const char *name, +static int iwl_load_section(struct iwl_trans *trans, const char *name, struct fw_desc *image, u32 dst_addr) { struct iwl_bus *bus = bus(trans); @@ -188,7 +188,7 @@ static inline struct fw_img *iwl_get_ucode_image(struct iwl_trans *trans, return NULL; } -static int iwlagn_load_given_ucode(struct iwl_trans *trans, +static int iwl_load_given_ucode(struct iwl_trans *trans, enum iwl_ucode_type ucode_type) { int ret = 0; @@ -201,19 +201,19 @@ static int iwlagn_load_given_ucode(struct iwl_trans *trans, return -EINVAL; } - ret = iwlagn_load_section(trans, "INST", &image->code, + ret = iwl_load_section(trans, "INST", &image->code, IWLAGN_RTC_INST_LOWER_BOUND); if (ret) return ret; - return iwlagn_load_section(trans, "DATA", &image->data, + return iwl_load_section(trans, "DATA", &image->data, IWLAGN_RTC_DATA_LOWER_BOUND); } /* * Calibration */ -static int iwlagn_set_Xtal_calib(struct iwl_priv *priv) +static int iwl_set_Xtal_calib(struct iwl_priv *priv) { struct iwl_calib_xtal_freq_cmd cmd; __le16 *xtal_calib = @@ -225,7 +225,7 @@ static int iwlagn_set_Xtal_calib(struct iwl_priv *priv) return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); } -static int iwlagn_set_temperature_offset_calib(struct iwl_priv *priv) +static int iwl_set_temperature_offset_calib(struct iwl_priv *priv) { struct iwl_calib_temperature_offset_cmd cmd; __le16 *offset_calib = @@ -242,7 +242,7 @@ static int iwlagn_set_temperature_offset_calib(struct iwl_priv *priv) return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); } -static int iwlagn_set_temperature_offset_calib_v2(struct iwl_priv *priv) +static int iwl_set_temperature_offset_calib_v2(struct iwl_priv *priv) { struct iwl_calib_temperature_offset_v2_cmd cmd; __le16 *offset_calib_high = (__le16 *)iwl_eeprom_query_addr(priv, @@ -277,7 +277,7 @@ static int iwlagn_set_temperature_offset_calib_v2(struct iwl_priv *priv) return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); } -static int iwlagn_send_calib_cfg(struct iwl_priv *priv) +static int iwl_send_calib_cfg(struct iwl_trans *trans) { struct iwl_calib_cfg_cmd calib_cfg_cmd; struct iwl_host_cmd cmd = { @@ -293,7 +293,7 @@ static int iwlagn_send_calib_cfg(struct iwl_priv *priv) calib_cfg_cmd.ucd_calib_cfg.flags = IWL_CALIB_CFG_FLAG_SEND_COMPLETE_NTFY_MSK; - return iwl_trans_send_cmd(trans(priv), &cmd); + return iwl_trans_send_cmd(trans, &cmd); } int iwlagn_rx_calib_result(struct iwl_priv *priv, @@ -326,14 +326,14 @@ int iwlagn_init_alive_start(struct iwl_priv *priv) * no need to close the envlope since we are going * to load the runtime uCode later. */ - ret = iwlagn_send_bt_env(priv, IWL_BT_COEX_ENV_OPEN, + ret = iwl_send_bt_env(trans(priv), IWL_BT_COEX_ENV_OPEN, BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); if (ret) return ret; } - ret = iwlagn_send_calib_cfg(priv); + ret = iwl_send_calib_cfg(trans(priv)); if (ret) return ret; @@ -343,15 +343,15 @@ int iwlagn_init_alive_start(struct iwl_priv *priv) */ if (priv->cfg->need_temp_offset_calib) { if (priv->cfg->temp_offset_v2) - return iwlagn_set_temperature_offset_calib_v2(priv); + return iwl_set_temperature_offset_calib_v2(priv); else - return iwlagn_set_temperature_offset_calib(priv); + return iwl_set_temperature_offset_calib(priv); } return 0; } -static int iwlagn_send_wimax_coex(struct iwl_priv *priv) +static int iwl_send_wimax_coex(struct iwl_priv *priv) { struct iwl_wimax_coex_cmd coex_cmd; @@ -379,7 +379,7 @@ static int iwlagn_send_wimax_coex(struct iwl_priv *priv) sizeof(coex_cmd), &coex_cmd); } -static const u8 iwlagn_bt_prio_tbl[BT_COEX_PRIO_TBL_EVT_MAX] = { +static const u8 iwl_bt_prio_tbl[BT_COEX_PRIO_TBL_EVT_MAX] = { ((BT_COEX_PRIO_TBL_PRIO_BYPASS << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), ((BT_COEX_PRIO_TBL_PRIO_BYPASS << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | @@ -401,42 +401,42 @@ static const u8 iwlagn_bt_prio_tbl[BT_COEX_PRIO_TBL_EVT_MAX] = { 0, 0, 0, 0, 0, 0, 0 }; -void iwlagn_send_prio_tbl(struct iwl_priv *priv) +void iwl_send_prio_tbl(struct iwl_trans *trans) { struct iwl_bt_coex_prio_table_cmd prio_tbl_cmd; - memcpy(prio_tbl_cmd.prio_tbl, iwlagn_bt_prio_tbl, - sizeof(iwlagn_bt_prio_tbl)); - if (iwl_trans_send_cmd_pdu(trans(priv), + memcpy(prio_tbl_cmd.prio_tbl, iwl_bt_prio_tbl, + sizeof(iwl_bt_prio_tbl)); + if (iwl_trans_send_cmd_pdu(trans, REPLY_BT_COEX_PRIO_TABLE, CMD_SYNC, sizeof(prio_tbl_cmd), &prio_tbl_cmd)) - IWL_ERR(priv, "failed to send BT prio tbl command\n"); + IWL_ERR(trans, "failed to send BT prio tbl command\n"); } -int iwlagn_send_bt_env(struct iwl_priv *priv, u8 action, u8 type) +int iwl_send_bt_env(struct iwl_trans *trans, u8 action, u8 type) { struct iwl_bt_coex_prot_env_cmd env_cmd; int ret; env_cmd.action = action; env_cmd.type = type; - ret = iwl_trans_send_cmd_pdu(trans(priv), + ret = iwl_trans_send_cmd_pdu(trans, REPLY_BT_COEX_PROT_ENV, CMD_SYNC, sizeof(env_cmd), &env_cmd); if (ret) - IWL_ERR(priv, "failed to send BT env command\n"); + IWL_ERR(trans, "failed to send BT env command\n"); return ret; } -static int iwlagn_alive_notify(struct iwl_priv *priv) +static int iwl_alive_notify(struct iwl_priv *priv) { struct iwl_rxon_context *ctx; int ret; if (!priv->tx_cmd_pool) priv->tx_cmd_pool = - kmem_cache_create("iwlagn_dev_cmd", + kmem_cache_create("iwl_dev_cmd", sizeof(struct iwl_device_cmd), sizeof(void *), 0, NULL); @@ -447,12 +447,12 @@ static int iwlagn_alive_notify(struct iwl_priv *priv) for_each_context(priv, ctx) ctx->last_tx_rejected = false; - ret = iwlagn_send_wimax_coex(priv); + ret = iwl_send_wimax_coex(priv); if (ret) return ret; if (!priv->cfg->no_xtal_calib) { - ret = iwlagn_set_Xtal_calib(priv); + ret = iwl_set_Xtal_calib(priv); if (ret) return ret; } @@ -548,7 +548,7 @@ struct iwlagn_alive_data { u8 subtype; }; -static void iwlagn_alive_fn(struct iwl_priv *priv, +static void iwl_alive_fn(struct iwl_priv *priv, struct iwl_rx_packet *pkt, void *data) { @@ -587,12 +587,12 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, return ret; iwlagn_init_notification_wait(priv, &alive_wait, REPLY_ALIVE, - iwlagn_alive_fn, &alive_data); + iwl_alive_fn, &alive_data); old_type = priv->ucode_type; priv->ucode_type = ucode_type; - ret = iwlagn_load_given_ucode(trans(priv), ucode_type); + ret = iwl_load_given_ucode(trans(priv), ucode_type); if (ret) { priv->ucode_type = old_type; iwlagn_remove_notification(priv, &alive_wait); @@ -633,7 +633,7 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, msleep(5); } - ret = iwlagn_alive_notify(priv); + ret = iwl_alive_notify(priv); if (ret) { IWL_WARN(priv, "Could not complete ALIVE transition: %d\n", ret); -- cgit v1.2.3 From 3d6acefc0a24bf90746c1f259e9d65d1ed7ea5e2 Mon Sep 17 00:00:00 2001 From: Don Fry Date: Mon, 28 Nov 2011 17:05:01 -0800 Subject: iwlwifi: move ucode_type from iwl_priv to iwl_shared Move the ucode_type variable from the iwl_priv to the iwl_shared structure with associated code changes. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-debugfs.c | 7 ++++--- drivers/net/wireless/iwlwifi/iwl-dev.h | 1 - drivers/net/wireless/iwlwifi/iwl-shared.h | 20 +++++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-testmode.c | 2 +- drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 10 +++++----- drivers/net/wireless/iwlwifi/iwl-trans.h | 7 ------- drivers/net/wireless/iwlwifi/iwl-ucode.c | 25 ++++++++++++------------ 7 files changed, 43 insertions(+), 29 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index 68b04f5b10ce..ccbcab40e78f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -234,11 +234,12 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file, /* default is to dump the entire data segment */ if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) { + struct iwl_trans *trans = trans(priv); priv->dbgfs_sram_offset = 0x800000; - if (priv->ucode_type == IWL_UCODE_INIT) - priv->dbgfs_sram_len = trans(priv)->ucode_init.data.len; + if (trans->shrd->ucode_type == IWL_UCODE_INIT) + priv->dbgfs_sram_len = trans->ucode_init.data.len; else - priv->dbgfs_sram_len = trans(priv)->ucode_rt.data.len; + priv->dbgfs_sram_len = trans->ucode_rt.data.len; } len = priv->dbgfs_sram_len; diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index cb24adbae082..0019a23d6d49 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -889,7 +889,6 @@ struct iwl_priv { u32 ucode_ver; /* version of ucode, copy of iwl_ucode.ver */ - enum iwl_ucode_type ucode_type; char firmware_name[25]; struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX]; diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 47be77a8a0a7..70bb9b83c6a1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -256,6 +256,23 @@ struct iwl_tid_data { struct iwl_ht_agg agg; }; +/** + * enum iwl_ucode_type + * + * The type of ucode currently loaded on the hardware. + * + * @IWL_UCODE_NONE: No ucode loaded + * @IWL_UCODE_REGULAR: Normal runtime ucode + * @IWL_UCODE_INIT: Initial ucode + * @IWL_UCODE_WOWLAN: Wake on Wireless enabled ucode + */ +enum iwl_ucode_type { + IWL_UCODE_NONE, + IWL_UCODE_REGULAR, + IWL_UCODE_INIT, + IWL_UCODE_WOWLAN, +}; + /** * struct iwl_shared - shared fields for all the layers of the driver * @@ -300,6 +317,9 @@ struct iwl_shared { struct iwl_tid_data tid_data[IWLAGN_STATION_COUNT][IWL_MAX_TID_COUNT]; wait_queue_head_t wait_command_queue; + + /* ucode related variables */ + enum iwl_ucode_type ucode_type; }; /*Whatever _m is (iwl_trans, iwl_priv, iwl_bus, these macros will work */ diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index 3c9762628760..ed2a3d749b1b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -710,7 +710,7 @@ static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb) return -ENOMSG; } size = nla_get_u32(tb[IWL_TM_ATTR_SRAM_SIZE]); - switch (priv->ucode_type) { + switch (priv->shrd->ucode_type) { case IWL_UCODE_REGULAR: maxsize = trans(priv)->ucode_rt.data.len; break; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index ee126f844a5c..becd92173ddd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -595,7 +595,7 @@ static void iwl_dump_nic_error_log(struct iwl_trans *trans) IWL_TRANS_GET_PCIE_TRANS(trans); base = priv->device_pointers.error_event_table; - if (priv->ucode_type == IWL_UCODE_INIT) { + if (trans->shrd->ucode_type == IWL_UCODE_INIT) { if (!base) base = priv->init_errlog_ptr; } else { @@ -607,7 +607,7 @@ static void iwl_dump_nic_error_log(struct iwl_trans *trans) IWL_ERR(trans, "Not valid error log pointer 0x%08X for %s uCode\n", base, - (priv->ucode_type == IWL_UCODE_INIT) + (trans->shrd->ucode_type == IWL_UCODE_INIT) ? "Init" : "RT"); return; } @@ -710,7 +710,7 @@ static int iwl_print_event_log(struct iwl_trans *trans, u32 start_idx, return pos; base = priv->device_pointers.log_event_table; - if (priv->ucode_type == IWL_UCODE_INIT) { + if (trans->shrd->ucode_type == IWL_UCODE_INIT) { if (!base) base = priv->init_evtlog_ptr; } else { @@ -824,7 +824,7 @@ int iwl_dump_nic_event_log(struct iwl_trans *trans, bool full_log, struct iwl_priv *priv = priv(trans); base = priv->device_pointers.log_event_table; - if (priv->ucode_type == IWL_UCODE_INIT) { + if (trans->shrd->ucode_type == IWL_UCODE_INIT) { logsize = priv->init_evtlog_size; if (!base) base = priv->init_evtlog_ptr; @@ -838,7 +838,7 @@ int iwl_dump_nic_event_log(struct iwl_trans *trans, bool full_log, IWL_ERR(trans, "Invalid event log pointer 0x%08X for %s uCode\n", base, - (priv->ucode_type == IWL_UCODE_INIT) + (trans->shrd->ucode_type == IWL_UCODE_INIT) ? "Init" : "RT"); return -EINVAL; } diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 50227ebc0ee2..4a29b8ab998e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -220,13 +220,6 @@ struct fw_img { struct fw_desc data; /* firmware data image */ }; -enum iwl_ucode_type { - IWL_UCODE_NONE, - IWL_UCODE_REGULAR, - IWL_UCODE_INIT, - IWL_UCODE_WOWLAN, -}; - /** * struct iwl_trans - transport common data * @ops - pointer to iwl_trans_ops diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 0da4b8ece11c..1b23b99c474c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -579,27 +579,28 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, { struct iwl_notification_wait alive_wait; struct iwlagn_alive_data alive_data; + struct iwl_trans *trans = trans(priv); int ret; enum iwl_ucode_type old_type; - ret = iwl_trans_start_device(trans(priv)); + ret = iwl_trans_start_device(trans); if (ret) return ret; iwlagn_init_notification_wait(priv, &alive_wait, REPLY_ALIVE, iwl_alive_fn, &alive_data); - old_type = priv->ucode_type; - priv->ucode_type = ucode_type; + old_type = trans->shrd->ucode_type; + trans->shrd->ucode_type = ucode_type; - ret = iwl_load_given_ucode(trans(priv), ucode_type); + ret = iwl_load_given_ucode(trans, ucode_type); if (ret) { - priv->ucode_type = old_type; + trans->shrd->ucode_type = old_type; iwlagn_remove_notification(priv, &alive_wait); return ret; } - iwl_trans_kick_nic(trans(priv)); + iwl_trans_kick_nic(trans); /* * Some things may run in the background now, but we @@ -607,13 +608,13 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, */ ret = iwlagn_wait_notification(priv, &alive_wait, UCODE_ALIVE_TIMEOUT); if (ret) { - priv->ucode_type = old_type; + trans->shrd->ucode_type = old_type; return ret; } if (!alive_data.valid) { IWL_ERR(priv, "Loaded ucode is not valid!\n"); - priv->ucode_type = old_type; + trans->shrd->ucode_type = old_type; return -EIO; } @@ -623,9 +624,9 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, * skip it for WoWLAN. */ if (ucode_type != IWL_UCODE_WOWLAN) { - ret = iwl_verify_ucode(trans(priv), ucode_type); + ret = iwl_verify_ucode(trans, ucode_type); if (ret) { - priv->ucode_type = old_type; + trans->shrd->ucode_type = old_type; return ret; } @@ -637,7 +638,7 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, if (ret) { IWL_WARN(priv, "Could not complete ALIVE transition: %d\n", ret); - priv->ucode_type = old_type; + trans->shrd->ucode_type = old_type; return ret; } @@ -655,7 +656,7 @@ int iwlagn_run_init_ucode(struct iwl_priv *priv) if (!trans(priv)->ucode_init.code.len) return 0; - if (priv->ucode_type != IWL_UCODE_NONE) + if (priv->shrd->ucode_type != IWL_UCODE_NONE) return 0; iwlagn_init_notification_wait(priv, &calib_wait, -- cgit v1.2.3 From dd5fe1046cb07d2a6665b6dbbfc6989b39ae063b Mon Sep 17 00:00:00 2001 From: Don Fry Date: Mon, 28 Nov 2011 16:13:19 -0800 Subject: iwlwifi: move ucode notification from iwl_priv to iwl_shared Move the notification structures for ucode operations from the iwl_priv structure to the iwl_shared structure, with associated code changes. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 51 ------------------- drivers/net/wireless/iwlwifi/iwl-agn-rx.c | 16 +++--- drivers/net/wireless/iwlwifi/iwl-agn-rxon.c | 6 +-- drivers/net/wireless/iwlwifi/iwl-agn.h | 16 ------ drivers/net/wireless/iwlwifi/iwl-core.c | 15 +----- drivers/net/wireless/iwlwifi/iwl-dev.h | 33 ------------ drivers/net/wireless/iwlwifi/iwl-shared.h | 56 +++++++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-testmode.c | 6 +-- drivers/net/wireless/iwlwifi/iwl-ucode.c | 78 ++++++++++++++++++++++++++--- 9 files changed, 143 insertions(+), 134 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 0bc962217351..575d1bb8e8cc 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -934,57 +934,6 @@ u8 iwl_toggle_tx_ant(struct iwl_priv *priv, u8 ant, u8 valid) return ant; } -/* notification wait support */ -void iwlagn_init_notification_wait(struct iwl_priv *priv, - struct iwl_notification_wait *wait_entry, - u8 cmd, - void (*fn)(struct iwl_priv *priv, - struct iwl_rx_packet *pkt, - void *data), - void *fn_data) -{ - wait_entry->fn = fn; - wait_entry->fn_data = fn_data; - wait_entry->cmd = cmd; - wait_entry->triggered = false; - wait_entry->aborted = false; - - spin_lock_bh(&priv->notif_wait_lock); - list_add(&wait_entry->list, &priv->notif_waits); - spin_unlock_bh(&priv->notif_wait_lock); -} - -int iwlagn_wait_notification(struct iwl_priv *priv, - struct iwl_notification_wait *wait_entry, - unsigned long timeout) -{ - int ret; - - ret = wait_event_timeout(priv->notif_waitq, - wait_entry->triggered || wait_entry->aborted, - timeout); - - spin_lock_bh(&priv->notif_wait_lock); - list_del(&wait_entry->list); - spin_unlock_bh(&priv->notif_wait_lock); - - if (wait_entry->aborted) - return -EIO; - - /* return value is always >= 0 */ - if (ret <= 0) - return -ETIMEDOUT; - return 0; -} - -void iwlagn_remove_notification(struct iwl_priv *priv, - struct iwl_notification_wait *wait_entry) -{ - spin_lock_bh(&priv->notif_wait_lock); - list_del(&wait_entry->list); - spin_unlock_bh(&priv->notif_wait_lock); -} - #ifdef CONFIG_PM_SLEEP static void iwlagn_convert_p1k(u16 *p1k, __le16 *out) { diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index 087fd52e5727..90c55ea4cc39 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c @@ -1131,9 +1131,9 @@ void iwl_setup_rx_handlers(struct iwl_priv *priv) priv->rx_handlers[REPLY_TX] = iwlagn_rx_reply_tx; /* set up notification wait support */ - spin_lock_init(&priv->notif_wait_lock); - INIT_LIST_HEAD(&priv->notif_waits); - init_waitqueue_head(&priv->notif_waitq); + spin_lock_init(&priv->shrd->notif_wait_lock); + INIT_LIST_HEAD(&priv->shrd->notif_waits); + init_waitqueue_head(&priv->shrd->notif_waitq); /* Set up BT Rx handlers */ if (priv->cfg->lib->bt_rx_handler_setup) @@ -1152,11 +1152,11 @@ int iwl_rx_dispatch(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, * even if the RX handler consumes the RXB we have * access to it in the notification wait entry. */ - if (!list_empty(&priv->notif_waits)) { + if (!list_empty(&priv->shrd->notif_waits)) { struct iwl_notification_wait *w; - spin_lock(&priv->notif_wait_lock); - list_for_each_entry(w, &priv->notif_waits, list) { + spin_lock(&priv->shrd->notif_wait_lock); + list_for_each_entry(w, &priv->shrd->notif_waits, list) { if (w->cmd != pkt->hdr.cmd) continue; IWL_DEBUG_RX(priv, @@ -1167,9 +1167,9 @@ int iwl_rx_dispatch(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, if (w->fn) w->fn(priv, pkt, w->fn_data); } - spin_unlock(&priv->notif_wait_lock); + spin_unlock(&priv->shrd->notif_wait_lock); - wake_up_all(&priv->notif_waitq); + wake_up_all(&priv->shrd->notif_waitq); } if (priv->pre_rx_handler) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index 00b38711c15d..466e4ab544f7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c @@ -60,7 +60,7 @@ static int iwlagn_disable_pan(struct iwl_priv *priv, u8 old_dev_type = send->dev_type; int ret; - iwlagn_init_notification_wait(priv, &disable_wait, + iwl_init_notification_wait(priv->shrd, &disable_wait, REPLY_WIPAN_DEACTIVATION_COMPLETE, NULL, NULL); @@ -74,9 +74,9 @@ static int iwlagn_disable_pan(struct iwl_priv *priv, if (ret) { IWL_ERR(priv, "Error disabling PAN (%d)\n", ret); - iwlagn_remove_notification(priv, &disable_wait); + iwl_remove_notification(priv->shrd, &disable_wait); } else { - ret = iwlagn_wait_notification(priv, &disable_wait, HZ); + ret = iwl_wait_notification(priv->shrd, &disable_wait, HZ); if (ret) IWL_ERR(priv, "Timed out waiting for PAN disable\n"); } diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 0db0a8fb5679..f2f10702754d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -356,22 +356,6 @@ static inline __le32 iwl_hw_set_rate_n_flags(u8 rate, u32 flags) void iwl_eeprom_enhanced_txpower(struct iwl_priv *priv); void iwl_eeprom_get_mac(const struct iwl_priv *priv, u8 *mac); -/* notification wait support */ -void __acquires(wait_entry) -iwlagn_init_notification_wait(struct iwl_priv *priv, - struct iwl_notification_wait *wait_entry, - u8 cmd, - void (*fn)(struct iwl_priv *priv, - struct iwl_rx_packet *pkt, - void *data), - void *fn_data); -int __must_check __releases(wait_entry) -iwlagn_wait_notification(struct iwl_priv *priv, - struct iwl_notification_wait *wait_entry, - unsigned long timeout); -void __releases(wait_entry) -iwlagn_remove_notification(struct iwl_priv *priv, - struct iwl_notification_wait *wait_entry); extern int iwlagn_init_alive_start(struct iwl_priv *priv); extern int iwl_alive_start(struct iwl_priv *priv); /* svtool */ diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index f9e9170e977a..b3205827ceb0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -836,19 +836,6 @@ void iwl_print_rx_config_cmd(struct iwl_priv *priv, } #endif -static void iwlagn_abort_notification_waits(struct iwl_priv *priv) -{ - unsigned long flags; - struct iwl_notification_wait *wait_entry; - - spin_lock_irqsave(&priv->notif_wait_lock, flags); - list_for_each_entry(wait_entry, &priv->notif_waits, list) - wait_entry->aborted = true; - spin_unlock_irqrestore(&priv->notif_wait_lock, flags); - - wake_up_all(&priv->notif_waitq); -} - void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand) { unsigned int reload_msec; @@ -860,7 +847,7 @@ void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand) /* Cancel currently queued command. */ clear_bit(STATUS_HCMD_ACTIVE, &priv->shrd->status); - iwlagn_abort_notification_waits(priv); + iwl_abort_notification_waits(priv->shrd); /* Keep the restart process from trying to send host * commands by clearing the ready bit */ diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 0019a23d6d49..6f6a647d34f6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -689,35 +689,6 @@ struct iwl_force_reset { */ #define IWLAGN_EXT_BEACON_TIME_POS 22 -/** - * struct iwl_notification_wait - notification wait entry - * @list: list head for global list - * @fn: function called with the notification - * @cmd: command ID - * - * This structure is not used directly, to wait for a - * notification declare it on the stack, and call - * iwlagn_init_notification_wait() with appropriate - * parameters. Then do whatever will cause the ucode - * to notify the driver, and to wait for that then - * call iwlagn_wait_notification(). - * - * Each notification is one-shot. If at some point we - * need to support multi-shot notifications (which - * can't be allocated on the stack) we need to modify - * the code for them. - */ -struct iwl_notification_wait { - struct list_head list; - - void (*fn)(struct iwl_priv *priv, struct iwl_rx_packet *pkt, - void *data); - void *fn_data; - - u8 cmd; - bool triggered, aborted; -}; - struct iwl_rxon_context { struct ieee80211_vif *vif; @@ -992,10 +963,6 @@ struct iwl_priv { /* counts reply_tx error */ struct reply_tx_error_statistics reply_tx_stats; struct reply_agg_tx_error_statistics reply_agg_tx_stats; - /* notification wait support */ - struct list_head notif_waits; - spinlock_t notif_wait_lock; - wait_queue_head_t notif_waitq; /* remain-on-channel offload support */ struct ieee80211_channel *hw_roc_channel; diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 70bb9b83c6a1..c23e26d7a7a7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -273,6 +273,35 @@ enum iwl_ucode_type { IWL_UCODE_WOWLAN, }; +/** + * struct iwl_notification_wait - notification wait entry + * @list: list head for global list + * @fn: function called with the notification + * @cmd: command ID + * + * This structure is not used directly, to wait for a + * notification declare it on the stack, and call + * iwlagn_init_notification_wait() with appropriate + * parameters. Then do whatever will cause the ucode + * to notify the driver, and to wait for that then + * call iwlagn_wait_notification(). + * + * Each notification is one-shot. If at some point we + * need to support multi-shot notifications (which + * can't be allocated on the stack) we need to modify + * the code for them. + */ +struct iwl_notification_wait { + struct list_head list; + + void (*fn)(struct iwl_priv *priv, struct iwl_rx_packet *pkt, + void *data); + void *fn_data; + + u8 cmd; + bool triggered, aborted; +}; + /** * struct iwl_shared - shared fields for all the layers of the driver * @@ -290,6 +319,10 @@ enum iwl_ucode_type { * @sta_lock: protects the station table. * If lock and sta_lock are needed, lock must be acquired first. * @mutex: + * @ucode_type: indicator of loaded ucode image + * @notif_waits: things waiting for notification + * @notif_wait_lock: lock protecting notification + * @notif_waitq: head of notification wait queue */ struct iwl_shared { #ifdef CONFIG_IWLWIFI_DEBUG @@ -320,6 +353,11 @@ struct iwl_shared { /* ucode related variables */ enum iwl_ucode_type ucode_type; + + /* notification wait support */ + struct list_head notif_waits; + spinlock_t notif_wait_lock; + wait_queue_head_t notif_waitq; }; /*Whatever _m is (iwl_trans, iwl_priv, iwl_bus, these macros will work */ @@ -463,6 +501,24 @@ bool iwl_check_for_ct_kill(struct iwl_priv *priv); void iwl_stop_sw_queue(struct iwl_priv *priv, u8 ac); void iwl_wake_sw_queue(struct iwl_priv *priv, u8 ac); +/* notification wait support */ +void iwl_abort_notification_waits(struct iwl_shared *shrd); +void __acquires(wait_entry) +iwl_init_notification_wait(struct iwl_shared *shrd, + struct iwl_notification_wait *wait_entry, + u8 cmd, + void (*fn)(struct iwl_priv *priv, + struct iwl_rx_packet *pkt, + void *data), + void *fn_data); +int __must_check __releases(wait_entry) +iwl_wait_notification(struct iwl_shared *shrd, + struct iwl_notification_wait *wait_entry, + unsigned long timeout); +void __releases(wait_entry) +iwl_remove_notification(struct iwl_shared *shrd, + struct iwl_notification_wait *wait_entry); + #ifdef CONFIG_IWLWIFI_DEBUGFS void iwl_reset_traffic_log(struct iwl_priv *priv); #endif /* CONFIG_IWLWIFI_DEBUGFS */ diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index ed2a3d749b1b..ff72dbcfd52d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -373,7 +373,7 @@ static int iwl_testmode_cfg_init_calib(struct iwl_priv *priv) struct iwl_notification_wait calib_wait; int ret; - iwlagn_init_notification_wait(priv, &calib_wait, + iwl_init_notification_wait(priv->shrd, &calib_wait, CALIBRATION_COMPLETE_NOTIFICATION, NULL, NULL); ret = iwlagn_init_alive_start(priv); @@ -383,14 +383,14 @@ static int iwl_testmode_cfg_init_calib(struct iwl_priv *priv) goto cfg_init_calib_error; } - ret = iwlagn_wait_notification(priv, &calib_wait, 2 * HZ); + ret = iwl_wait_notification(priv->shrd, &calib_wait, 2 * HZ); if (ret) IWL_DEBUG_INFO(priv, "Error detecting" " CALIBRATION_COMPLETE_NOTIFICATION: %d\n", ret); return ret; cfg_init_calib_error: - iwlagn_remove_notification(priv, &calib_wait); + iwl_remove_notification(priv->shrd, &calib_wait); return ret; } diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 1b23b99c474c..b365de457b1b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -571,6 +571,70 @@ static void iwl_alive_fn(struct iwl_priv *priv, alive_data->valid = palive->is_valid == UCODE_VALID_OK; } +/* notification wait support */ +void iwl_init_notification_wait(struct iwl_shared *shrd, + struct iwl_notification_wait *wait_entry, + u8 cmd, + void (*fn)(struct iwl_priv *priv, + struct iwl_rx_packet *pkt, + void *data), + void *fn_data) +{ + wait_entry->fn = fn; + wait_entry->fn_data = fn_data; + wait_entry->cmd = cmd; + wait_entry->triggered = false; + wait_entry->aborted = false; + + spin_lock_bh(&shrd->notif_wait_lock); + list_add(&wait_entry->list, &shrd->notif_waits); + spin_unlock_bh(&shrd->notif_wait_lock); +} + +int iwl_wait_notification(struct iwl_shared *shrd, + struct iwl_notification_wait *wait_entry, + unsigned long timeout) +{ + int ret; + + ret = wait_event_timeout(shrd->notif_waitq, + wait_entry->triggered || wait_entry->aborted, + timeout); + + spin_lock_bh(&shrd->notif_wait_lock); + list_del(&wait_entry->list); + spin_unlock_bh(&shrd->notif_wait_lock); + + if (wait_entry->aborted) + return -EIO; + + /* return value is always >= 0 */ + if (ret <= 0) + return -ETIMEDOUT; + return 0; +} + +void iwl_remove_notification(struct iwl_shared *shrd, + struct iwl_notification_wait *wait_entry) +{ + spin_lock_bh(&shrd->notif_wait_lock); + list_del(&wait_entry->list); + spin_unlock_bh(&shrd->notif_wait_lock); +} + +void iwl_abort_notification_waits(struct iwl_shared *shrd) +{ + unsigned long flags; + struct iwl_notification_wait *wait_entry; + + spin_lock_irqsave(&shrd->notif_wait_lock, flags); + list_for_each_entry(wait_entry, &shrd->notif_waits, list) + wait_entry->aborted = true; + spin_unlock_irqrestore(&shrd->notif_wait_lock, flags); + + wake_up_all(&shrd->notif_waitq); +} + #define UCODE_ALIVE_TIMEOUT HZ #define UCODE_CALIB_TIMEOUT (2*HZ) @@ -587,7 +651,7 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, if (ret) return ret; - iwlagn_init_notification_wait(priv, &alive_wait, REPLY_ALIVE, + iwl_init_notification_wait(trans->shrd, &alive_wait, REPLY_ALIVE, iwl_alive_fn, &alive_data); old_type = trans->shrd->ucode_type; @@ -596,7 +660,7 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, ret = iwl_load_given_ucode(trans, ucode_type); if (ret) { trans->shrd->ucode_type = old_type; - iwlagn_remove_notification(priv, &alive_wait); + iwl_remove_notification(trans->shrd, &alive_wait); return ret; } @@ -606,7 +670,8 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, * Some things may run in the background now, but we * just wait for the ALIVE notification here. */ - ret = iwlagn_wait_notification(priv, &alive_wait, UCODE_ALIVE_TIMEOUT); + ret = iwl_wait_notification(trans->shrd, &alive_wait, + UCODE_ALIVE_TIMEOUT); if (ret) { trans->shrd->ucode_type = old_type; return ret; @@ -659,7 +724,7 @@ int iwlagn_run_init_ucode(struct iwl_priv *priv) if (priv->shrd->ucode_type != IWL_UCODE_NONE) return 0; - iwlagn_init_notification_wait(priv, &calib_wait, + iwl_init_notification_wait(priv->shrd, &calib_wait, CALIBRATION_COMPLETE_NOTIFICATION, NULL, NULL); @@ -676,12 +741,13 @@ int iwlagn_run_init_ucode(struct iwl_priv *priv) * Some things may run in the background now, but we * just wait for the calibration complete notification. */ - ret = iwlagn_wait_notification(priv, &calib_wait, UCODE_CALIB_TIMEOUT); + ret = iwl_wait_notification(priv->shrd, &calib_wait, + UCODE_CALIB_TIMEOUT); goto out; error: - iwlagn_remove_notification(priv, &calib_wait); + iwl_remove_notification(priv->shrd, &calib_wait); out: /* Whatever happened, stop the device */ iwl_trans_stop_device(trans(priv)); -- cgit v1.2.3 From 274b89ca3b006926cb9b45d78ab5906f4c0fc0aa Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 2 Dec 2011 08:19:17 -0800 Subject: iwlagn: fix HW crypto for TX-only keys Group keys in IBSS or AP mode are not programmed into the device since we give the key to it with every TX packet. However, we do need mac80211 to create the MMIC & PN in all cases. Move the code around to set the key flags all the time. We set them even when the key is removed again but that is obviously harmless. Cc: stable@vger.kernel.org Reported-by: Reinette Chatre Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-sta.c | 5 ----- drivers/net/wireless/iwlwifi/iwl-agn.c | 11 +++++++++++ 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index ed6283623932..4b2aa1da0953 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c @@ -1268,9 +1268,6 @@ int iwl_set_dynamic_key(struct iwl_priv *priv, switch (keyconf->cipher) { case WLAN_CIPHER_SUITE_TKIP: - keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; - keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; - if (sta) addr = sta->addr; else /* station mode case only */ @@ -1283,8 +1280,6 @@ int iwl_set_dynamic_key(struct iwl_priv *priv, seq.tkip.iv32, p1k, CMD_SYNC); break; case WLAN_CIPHER_SUITE_CCMP: - keyconf->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; - /* fall through */ case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP104: ret = iwlagn_send_sta_key(priv, keyconf, sta_id, diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index ccba69b7f8a7..6094deab5106 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -2316,6 +2316,17 @@ static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, return -EOPNOTSUPP; } + switch (key->cipher) { + case WLAN_CIPHER_SUITE_TKIP: + key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; + /* fall through */ + case WLAN_CIPHER_SUITE_CCMP: + key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; + break; + default: + break; + } + /* * We could program these keys into the hardware as well, but we * don't expect much multicast traffic in IBSS and having keys -- cgit v1.2.3 From 34a5b4b6af104cf18eb50748509528b9bdbc4036 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Fri, 2 Dec 2011 08:19:18 -0800 Subject: iwlwifi: do not re-configure HT40 after associated The ht40 setting should not change after association unless channel switch This fix a problem we are seeing which cause uCode assert because driver sending invalid information and make uCode confuse Here is the firmware assert message: kernel: iwlagn 0000:03:00.0: Microcode SW error detected. Restarting 0x82000000. kernel: iwlagn 0000:03:00.0: Loaded firmware version: 17.168.5.3 build 42301 kernel: iwlagn 0000:03:00.0: Start IWL Error Log Dump: kernel: iwlagn 0000:03:00.0: Status: 0x000512E4, count: 6 kernel: iwlagn 0000:03:00.0: 0x00002078 | ADVANCED_SYSASSERT kernel: iwlagn 0000:03:00.0: 0x00009514 | uPc kernel: iwlagn 0000:03:00.0: 0x00009496 | branchlink1 kernel: iwlagn 0000:03:00.0: 0x00009496 | branchlink2 kernel: iwlagn 0000:03:00.0: 0x0000D1F2 | interruptlink1 kernel: iwlagn 0000:03:00.0: 0x00000000 | interruptlink2 kernel: iwlagn 0000:03:00.0: 0x01008035 | data1 kernel: iwlagn 0000:03:00.0: 0x0000C90F | data2 kernel: iwlagn 0000:03:00.0: 0x000005A7 | line kernel: iwlagn 0000:03:00.0: 0x5080B520 | beacon time kernel: iwlagn 0000:03:00.0: 0xCC515AE0 | tsf low kernel: iwlagn 0000:03:00.0: 0x00000003 | tsf hi kernel: iwlagn 0000:03:00.0: 0x00000000 | time gp1 kernel: iwlagn 0000:03:00.0: 0x29703BF0 | time gp2 kernel: iwlagn 0000:03:00.0: 0x00000000 | time gp3 kernel: iwlagn 0000:03:00.0: 0x000111A8 | uCode version kernel: iwlagn 0000:03:00.0: 0x000000B0 | hw version kernel: iwlagn 0000:03:00.0: 0x00480303 | board version kernel: iwlagn 0000:03:00.0: 0x09E8004E | hcmd kernel: iwlagn 0000:03:00.0: CSR values: kernel: iwlagn 0000:03:00.0: (2nd byte of CSR_INT_COALESCING is CSR_INT_PERIODIC_REG) kernel: iwlagn 0000:03:00.0: CSR_HW_IF_CONFIG_REG: 0X00480303 kernel: iwlagn 0000:03:00.0: CSR_INT_COALESCING: 0X0000ff40 kernel: iwlagn 0000:03:00.0: CSR_INT: 0X00000000 kernel: iwlagn 0000:03:00.0: CSR_INT_MASK: 0X00000000 kernel: iwlagn 0000:03:00.0: CSR_FH_INT_STATUS: 0X00000000 kernel: iwlagn 0000:03:00.0: CSR_GPIO_IN: 0X00000030 kernel: iwlagn 0000:03:00.0: CSR_RESET: 0X00000000 kernel: iwlagn 0000:03:00.0: CSR_GP_CNTRL: 0X080403c5 kernel: iwlagn 0000:03:00.0: CSR_HW_REV: 0X000000b0 kernel: iwlagn 0000:03:00.0: CSR_EEPROM_REG: 0X07d60ffd kernel: iwlagn 0000:03:00.0: CSR_EEPROM_GP: 0X90000001 kernel: iwlagn 0000:03:00.0: CSR_OTP_GP_REG: 0X00030001 kernel: iwlagn 0000:03:00.0: CSR_GIO_REG: 0X00080044 kernel: iwlagn 0000:03:00.0: CSR_GP_UCODE_REG: 0X000093bb kernel: iwlagn 0000:03:00.0: CSR_GP_DRIVER_REG: 0X00000000 kernel: iwlagn 0000:03:00.0: CSR_UCODE_DRV_GP1: 0X00000000 kernel: iwlagn 0000:03:00.0: CSR_UCODE_DRV_GP2: 0X00000000 kernel: iwlagn 0000:03:00.0: CSR_LED_REG: 0X00000078 kernel: iwlagn 0000:03:00.0: CSR_DRAM_INT_TBL_REG: 0X88214dd2 kernel: iwlagn 0000:03:00.0: CSR_GIO_CHICKEN_BITS: 0X27800200 kernel: iwlagn 0000:03:00.0: CSR_ANA_PLL_CFG: 0X00000000 kernel: iwlagn 0000:03:00.0: CSR_HW_REV_WA_REG: 0X0001001a kernel: iwlagn 0000:03:00.0: CSR_DBG_HPET_MEM_REG: 0Xffff0010 kernel: iwlagn 0000:03:00.0: FH register values: kernel: iwlagn 0000:03:00.0: FH_RSCSR_CHNL0_STTS_WPTR_REG: 0X21316d00 kernel: iwlagn 0000:03:00.0: FH_RSCSR_CHNL0_RBDCB_BASE_REG: 0X021479c0 kernel: iwlagn 0000:03:00.0: FH_RSCSR_CHNL0_WPTR: 0X00000060 kernel: iwlagn 0000:03:00.0: FH_MEM_RCSR_CHNL0_CONFIG_REG: 0X80819104 kernel: iwlagn 0000:03:00.0: FH_MEM_RSSR_SHARED_CTRL_REG: 0X000000fc kernel: iwlagn 0000:03:00.0: FH_MEM_RSSR_RX_STATUS_REG: 0X07030000 kernel: iwlagn 0000:03:00.0: FH_MEM_RSSR_RX_ENABLE_ERR_IRQ2DRV: 0X00000000 kernel: iwlagn 0000:03:00.0: FH_TSSR_TX_STATUS_REG: 0X07ff0001 kernel: iwlagn 0000:03:00.0: FH_TSSR_TX_ERROR_REG: 0X00000000 kernel: iwlagn 0000:03:00.0: Start IWL Event Log Dump: display last 20 entries kernel: ------------[ cut here ]------------ WARNING: at net/mac80211/util.c:1208 ieee80211_reconfig+0x1f1/0x407() kernel: Hardware name: 4290W4H kernel: Pid: 1896, comm: kworker/0:0 Not tainted 3.1.0 #2 kernel: Call Trace: kernel: [] ? warn_slowpath_common+0x73/0x87 kernel: [] ? ieee80211_reconfig+0x1f1/0x407 kernel: [] ? ieee80211_recalc_smps_work+0x32/0x32 kernel: [] ? ieee80211_restart_work+0x7e/0x87 kernel: [] ? process_one_work+0x1c8/0x2e3 kernel: [] ? worker_thread+0x17a/0x23a kernel: [] ? manage_workers.clone.18+0x15b/0x15b kernel: [] ? manage_workers.clone.18+0x15b/0x15b kernel: [] ? kthread+0x7a/0x82 kernel: [] ? kernel_thread_helper+0x4/0x10 kernel: [] ? kthread_flush_work_fn+0x11/0x11 kernel: [] ? gs_change+0xb/0xb Cc: 3.1+ Reported-by: Udo Steinberg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-rxon.c | 36 ++++++++++++++++++----------- drivers/net/wireless/iwlwifi/iwl-agn.c | 18 +++------------ drivers/net/wireless/iwlwifi/iwl-agn.h | 2 ++ 3 files changed, 28 insertions(+), 28 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index 58a381c01c89..a7a6def40d05 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c @@ -528,6 +528,24 @@ int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) return 0; } +void iwlagn_config_ht40(struct ieee80211_conf *conf, + struct iwl_rxon_context *ctx) +{ + if (conf_is_ht40_minus(conf)) { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_BELOW; + ctx->ht.is_40mhz = true; + } else if (conf_is_ht40_plus(conf)) { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_ABOVE; + ctx->ht.is_40mhz = true; + } else { + ctx->ht.extension_chan_offset = + IEEE80211_HT_PARAM_CHA_SEC_NONE; + ctx->ht.is_40mhz = false; + } +} + int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed) { struct iwl_priv *priv = hw->priv; @@ -586,19 +604,11 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed) ctx->ht.enabled = conf_is_ht(conf); if (ctx->ht.enabled) { - if (conf_is_ht40_minus(conf)) { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_BELOW; - ctx->ht.is_40mhz = true; - } else if (conf_is_ht40_plus(conf)) { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_ABOVE; - ctx->ht.is_40mhz = true; - } else { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_NONE; - ctx->ht.is_40mhz = false; - } + /* if HT40 is used, it should not change + * after associated except channel switch */ + if (iwl_is_associated_ctx(ctx) && + !ctx->ht.is_40mhz) + iwlagn_config_ht40(conf, ctx); } else ctx->ht.is_40mhz = false; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 6094deab5106..f5564514868e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -2610,21 +2610,9 @@ static void iwlagn_mac_channel_switch(struct ieee80211_hw *hw, /* Configure HT40 channels */ ctx->ht.enabled = conf_is_ht(conf); - if (ctx->ht.enabled) { - if (conf_is_ht40_minus(conf)) { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_BELOW; - ctx->ht.is_40mhz = true; - } else if (conf_is_ht40_plus(conf)) { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_ABOVE; - ctx->ht.is_40mhz = true; - } else { - ctx->ht.extension_chan_offset = - IEEE80211_HT_PARAM_CHA_SEC_NONE; - ctx->ht.is_40mhz = false; - } - } else + if (ctx->ht.enabled) + iwlagn_config_ht40(conf, ctx); + else ctx->ht.is_40mhz = false; if ((le16_to_cpu(ctx->staging.channel) != ch)) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 5b936ec1a541..3856abaea507 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -86,6 +86,8 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_bss_conf *bss_conf, u32 changes); +void iwlagn_config_ht40(struct ieee80211_conf *conf, + struct iwl_rxon_context *ctx); /* uCode */ int iwlagn_rx_calib_result(struct iwl_priv *priv, -- cgit v1.2.3 From 9995ffe5f5fdddcc73e4465cc3f8b38714df8108 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Fri, 2 Dec 2011 08:19:19 -0800 Subject: iwlwifi: change the default behavior of watchdog timer The current default watchdog timer is enabled, but we are seeing issues on legacy devices. So change the default setting of watchdog timer to per device based. But user still can use the "wd_disable" module parameter to overwrite the system setting Cc: stable@vger.kernel.org #3.0+ Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-1000.c | 1 + drivers/net/wireless/iwlwifi/iwl-5000.c | 1 + drivers/net/wireless/iwlwifi/iwl-agn.c | 5 +++-- drivers/net/wireless/iwlwifi/iwl-core.c | 22 +++++++++++++++++----- drivers/net/wireless/iwlwifi/iwl-core.h | 2 ++ drivers/net/wireless/iwlwifi/iwl-shared.h | 4 ++-- 6 files changed, 26 insertions(+), 9 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c index e12b48c2cff6..dd008b0e6417 100644 --- a/drivers/net/wireless/iwlwifi/iwl-1000.c +++ b/drivers/net/wireless/iwlwifi/iwl-1000.c @@ -191,6 +191,7 @@ static struct iwl_base_params iwl1000_base_params = { .chain_noise_scale = 1000, .wd_timeout = IWL_DEF_WD_TIMEOUT, .max_event_log_size = 128, + .wd_disable = true, }; static struct iwl_ht_params iwl1000_ht_params = { .ht_greenfield_support = true, diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index c511c98a89a8..f55fb2d1af52 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c @@ -364,6 +364,7 @@ static struct iwl_base_params iwl5000_base_params = { .wd_timeout = IWL_LONG_WD_TIMEOUT, .max_event_log_size = 512, .no_idle_support = true, + .wd_disable = true, }; static struct iwl_ht_params iwl5000_ht_params = { .ht_greenfield_support = true, diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index f5564514868e..bacc06c95e7a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -3498,9 +3498,10 @@ MODULE_PARM_DESC(plcp_check, "Check plcp health (default: 1 [enabled])"); module_param_named(ack_check, iwlagn_mod_params.ack_check, bool, S_IRUGO); MODULE_PARM_DESC(ack_check, "Check ack health (default: 0 [disabled])"); -module_param_named(wd_disable, iwlagn_mod_params.wd_disable, bool, S_IRUGO); +module_param_named(wd_disable, iwlagn_mod_params.wd_disable, int, S_IRUGO); MODULE_PARM_DESC(wd_disable, - "Disable stuck queue watchdog timer (default: 0 [enabled])"); + "Disable stuck queue watchdog timer 0=system default, " + "1=disable, 2=enable (default: 0)"); /* * set bt_coex_active to true, uCode will do kill/defer diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 001fdf140abb..fcf54160e4ed 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -1810,11 +1810,23 @@ void iwl_setup_watchdog(struct iwl_priv *priv) { unsigned int timeout = priv->cfg->base_params->wd_timeout; - if (timeout && !iwlagn_mod_params.wd_disable) - mod_timer(&priv->watchdog, - jiffies + msecs_to_jiffies(IWL_WD_TICK(timeout))); - else - del_timer(&priv->watchdog); + if (!iwlagn_mod_params.wd_disable) { + /* use system default */ + if (timeout && !priv->cfg->base_params->wd_disable) + mod_timer(&priv->watchdog, + jiffies + + msecs_to_jiffies(IWL_WD_TICK(timeout))); + else + del_timer(&priv->watchdog); + } else { + /* module parameter overwrite default configuration */ + if (timeout && iwlagn_mod_params.wd_disable == 2) + mod_timer(&priv->watchdog, + jiffies + + msecs_to_jiffies(IWL_WD_TICK(timeout))); + else + del_timer(&priv->watchdog); + } } /** diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h index 137da3380704..f2fc288f3dd3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/drivers/net/wireless/iwlwifi/iwl-core.h @@ -113,6 +113,7 @@ struct iwl_lib_ops { * @shadow_reg_enable: HW shadhow register bit * @no_idle_support: do not support idle mode * @hd_v2: v2 of enhanced sensitivity value, used for 2000 series and up + * wd_disable: disable watchdog timer */ struct iwl_base_params { int eeprom_size; @@ -134,6 +135,7 @@ struct iwl_base_params { const bool shadow_reg_enable; const bool no_idle_support; const bool hd_v2; + const bool wd_disable; }; /* * @advanced_bt_coexist: support advanced bt coexist diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 1f7a93c67c45..14eaf37ce3b1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -120,7 +120,7 @@ extern struct iwl_mod_params iwlagn_mod_params; * @restart_fw: restart firmware, default = 1 * @plcp_check: enable plcp health check, default = true * @ack_check: disable ack health check, default = false - * @wd_disable: enable stuck queue check, default = false + * @wd_disable: enable stuck queue check, default = 0 * @bt_coex_active: enable bt coex, default = true * @led_mode: system default, default = 0 * @no_sleep_autoadjust: disable autoadjust, default = true @@ -141,7 +141,7 @@ struct iwl_mod_params { int restart_fw; bool plcp_check; bool ack_check; - bool wd_disable; + int wd_disable; bool bt_coex_active; int led_mode; bool no_sleep_autoadjust; -- cgit v1.2.3 From 162d12de656bc76786ba5fad6dac7bd238de9657 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sun, 4 Dec 2011 08:38:54 +0100 Subject: ath9k: fix check for antenna diversity support fixes a regression on single-stream chips introduced in commit 43c3528430bd29f5e52438cad7cf7c0c62bf4583 "ath9k: implement .get_antenna and .set_antenna" Signed-off-by: Felix Fietkau Reported-by: Marek Lindner Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 93fbe6f40898..d2348a5a7809 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -286,7 +286,7 @@ static bool ath_complete_reset(struct ath_softc *sc, bool start) ath_start_ani(common); } - if (ath9k_hw_ops(ah)->antdiv_comb_conf_get && sc->ant_rx != 3) { + if ((ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) && sc->ant_rx != 3) { struct ath_hw_antcomb_conf div_ant_conf; u8 lna_conf; -- cgit v1.2.3 From 839fafbe0dc35fabeb9bd3be9727fd74d12c0b9d Mon Sep 17 00:00:00 2001 From: Thomas Meyer Date: Tue, 29 Nov 2011 22:08:00 +0100 Subject: rt2x00: Use kcalloc instead of kzalloc to allocate array The advantage of kcalloc is, that will prevent integer overflows which could result from the multiplication of number of elements and size and it is also a bit nicer to read. The semantic patch that makes this change is available in https://lkml.org/lkml/2011/11/25/107 Signed-off-by: Thomas Meyer Acked-by: Gertjan van Wingerde Acked-by: Ivo van Doorn Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2x00dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c index edd317fa7c0a..c3e1aa7c1a80 100644 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c @@ -831,11 +831,11 @@ static int rt2x00lib_probe_hw_modes(struct rt2x00_dev *rt2x00dev, if (spec->supported_rates & SUPPORT_RATE_OFDM) num_rates += 8; - channels = kzalloc(sizeof(*channels) * spec->num_channels, GFP_KERNEL); + channels = kcalloc(spec->num_channels, sizeof(*channels), GFP_KERNEL); if (!channels) return -ENOMEM; - rates = kzalloc(sizeof(*rates) * num_rates, GFP_KERNEL); + rates = kcalloc(num_rates, sizeof(*rates), GFP_KERNEL); if (!rates) goto exit_free_channels; -- cgit v1.2.3 From 2b50b8f58803f4c8521c6aa5401ed01cd36a1f77 Mon Sep 17 00:00:00 2001 From: Thomas Meyer Date: Tue, 29 Nov 2011 22:08:00 +0100 Subject: iwlegacy: Use kcalloc instead of kzalloc to allocate array The advantage of kcalloc is, that will prevent integer overflows which could result from the multiplication of number of elements and size and it is also a bit nicer to read. The semantic patch that makes this change is available in https://lkml.org/lkml/2011/11/25/107 Signed-off-by: Thomas Meyer Signed-off-by: John W. Linville --- drivers/net/wireless/iwlegacy/common.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlegacy/common.c b/drivers/net/wireless/iwlegacy/common.c index 7e2924f332a7..881ba043770a 100644 --- a/drivers/net/wireless/iwlegacy/common.c +++ b/drivers/net/wireless/iwlegacy/common.c @@ -2786,9 +2786,8 @@ il_tx_queue_alloc(struct il_priv *il, struct il_tx_queue *txq, u32 id) /* Driver ilate data, only for Tx (not command) queues, * not shared with device. */ if (id != il->cmd_queue) { - txq->txb = - kzalloc(sizeof(txq->txb[0]) * TFD_QUEUE_SIZE_MAX, - GFP_KERNEL); + txq->txb = kcalloc(TFD_QUEUE_SIZE_MAX, sizeof(txq->txb[0]), + GFP_KERNEL); if (!txq->txb) { IL_ERR("kmalloc for auxiliary BD " "structures failed\n"); -- cgit v1.2.3 From 8ff08b4318b06eb3661bea0067ae587afc01e649 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 30 Nov 2011 10:58:14 -0600 Subject: rtl8192c: Do not log firmware load message unless actually done A previous commit fixed a problem whereby the rtl8192c driver loaded the firmware from disk many times; however, the log message was not moved. Signed-off-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c index fa393dfe136c..931d97979b04 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c +++ b/drivers/net/wireless/rtlwifi/rtl8192c/fw_common.c @@ -262,10 +262,10 @@ int rtl92c_download_fw(struct ieee80211_hw *hw) u32 fwsize; enum version_8192c version = rtlhal->version; - pr_info("Loading firmware file %s\n", rtlpriv->cfg->fw_name); if (!rtlhal->pfirmware) return 1; + pr_info("Loading firmware file %s\n", rtlpriv->cfg->fw_name); pfwheader = (struct rtl92c_firmware_header *)rtlhal->pfirmware; pfwdata = (u8 *) rtlhal->pfirmware; fwsize = rtlhal->fwsize; -- cgit v1.2.3 From b9b6968b0d9d0fe3891c5f87aa6e53b7ee67cf7f Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Thu, 1 Dec 2011 11:14:19 +0530 Subject: ath9k_hw: sync to latest AR9462 INI based on systems change to improve rx dynamic range, and enables heavy clip for 5G HT40 MCS0 to improve spectral mask power. also remove an unused function declaration Cc: Wilson Tsao Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- .../net/wireless/ath/ath9k/ar9462_2p0_initvals.h | 42 +++++++++++----------- drivers/net/wireless/ath/ath9k/hw.h | 1 - 2 files changed, 21 insertions(+), 22 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h b/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h index 259a6f312afb..dc2054f0378e 100644 --- a/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h +++ b/drivers/net/wireless/ath/ath9k/ar9462_2p0_initvals.h @@ -41,24 +41,24 @@ static const u32 ar9462_pciephy_clkreq_enable_L1_2p0[][2] = { static const u32 ar9462_2p0_baseband_postamble[][5] = { /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ - {0x00009810, 0xd00a8005, 0xd00a8005, 0xd00a8011, 0xd00a8011}, - {0x00009820, 0x206a022e, 0x206a022e, 0x206a012e, 0x206a012e}, - {0x00009824, 0x5ac640de, 0x5ac640d0, 0x5ac640d0, 0x5ac640de}, - {0x00009828, 0x0796be89, 0x0696b081, 0x0696b881, 0x0796be89}, + {0x00009810, 0xd00a8005, 0xd00a8005, 0xd00a8011, 0xd00a800d}, + {0x00009820, 0x206a022e, 0x206a022e, 0x206a012e, 0x206a01ae}, + {0x00009824, 0x5ac640de, 0x5ac640d0, 0x5ac640d0, 0x63c640da}, + {0x00009828, 0x0796be89, 0x0696b081, 0x0696b881, 0x09143e81}, {0x0000982c, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4}, {0x00009830, 0x0000059c, 0x0000059c, 0x0000119c, 0x0000119c}, {0x00009c00, 0x000000c4, 0x000000c4, 0x000000c4, 0x000000c4}, {0x00009e00, 0x0372111a, 0x0372111a, 0x037216a0, 0x037216a0}, {0x00009e04, 0x001c2020, 0x001c2020, 0x001c2020, 0x001c2020}, - {0x00009e0c, 0x6c4000e2, 0x6d4000e2, 0x6d4000e2, 0x6c4000e2}, - {0x00009e10, 0x92c88d2e, 0x7ec88d2e, 0x7ec84d2e, 0x92c84d2e}, - {0x00009e14, 0x37b95d5e, 0x37b9605e, 0x3379605e, 0x33795d5e}, + {0x00009e0c, 0x6c4000e2, 0x6d4000e2, 0x6d4000e2, 0x6c4000d8}, + {0x00009e10, 0x92c88d2e, 0x7ec88d2e, 0x7ec84d2e, 0x7ec86d2e}, + {0x00009e14, 0x37b95d5e, 0x37b9605e, 0x3376605e, 0x33795d5e}, {0x00009e18, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, {0x00009e1c, 0x0001cf9c, 0x0001cf9c, 0x00021f9c, 0x00021f9c}, {0x00009e20, 0x000003b5, 0x000003b5, 0x000003ce, 0x000003ce}, {0x00009e2c, 0x0000001c, 0x0000001c, 0x00000021, 0x00000021}, - {0x00009e3c, 0xcf946220, 0xcf946220, 0xcfd5c782, 0xcfd5c782}, - {0x00009e44, 0xfe321e27, 0xfe321e27, 0xfe291e27, 0xfe291e27}, + {0x00009e3c, 0xcf946220, 0xcf946220, 0xcfd5c782, 0xcfd5c282}, + {0x00009e44, 0x62321e27, 0x62321e27, 0xfe291e27, 0xfe291e27}, {0x00009e48, 0x5030201a, 0x5030201a, 0x50302012, 0x50302012}, {0x00009fc8, 0x0003f000, 0x0003f000, 0x0001a000, 0x0001a000}, {0x0000a204, 0x013187c0, 0x013187c4, 0x013187c4, 0x013187c0}, @@ -81,6 +81,15 @@ static const u32 ar9462_2p0_baseband_postamble[][5] = { {0x0000a2d0, 0x00041981, 0x00041981, 0x00041981, 0x00041982}, {0x0000a2d8, 0x7999a83b, 0x7999a83b, 0x7999a83b, 0x7999a83b}, {0x0000a358, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, + {0x0000a3a4, 0x00000010, 0x00000010, 0x00000000, 0x00000000}, + {0x0000a3a8, 0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa}, + {0x0000a3ac, 0xaaaaaa00, 0xaaaaaa30, 0xaaaaaa00, 0xaaaaaa00}, + {0x0000a41c, 0x1ce739ce, 0x1ce739ce, 0x1ce739ce, 0x1ce739ce}, + {0x0000a420, 0x000001ce, 0x000001ce, 0x000001ce, 0x000001ce}, + {0x0000a424, 0x1ce739ce, 0x1ce739ce, 0x1ce739ce, 0x1ce739ce}, + {0x0000a428, 0x000001ce, 0x000001ce, 0x000001ce, 0x000001ce}, + {0x0000a42c, 0x1ce739ce, 0x1ce739ce, 0x1ce739ce, 0x1ce739ce}, + {0x0000a430, 0x1ce739ce, 0x1ce739ce, 0x1ce739ce, 0x1ce739ce}, {0x0000a830, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c}, {0x0000ae04, 0x001c0000, 0x001c0000, 0x001c0000, 0x00100000}, {0x0000ae18, 0x00000000, 0x00000000, 0x00000000, 0x00000000}, @@ -1107,11 +1116,11 @@ static const u32 ar9462_2p0_baseband_core[][2] = { {0x00009e30, 0x06336f77}, {0x00009e34, 0x6af6532f}, {0x00009e38, 0x0cc80c00}, - {0x00009e40, 0x0d261820}, + {0x00009e40, 0x15262820}, {0x00009e4c, 0x00001004}, {0x00009e50, 0x00ff03f1}, - {0x00009e54, 0xe4c355c7}, - {0x00009e58, 0xfd897735}, + {0x00009e54, 0xe4c555c2}, + {0x00009e58, 0xfd857722}, {0x00009e5c, 0xe9198724}, {0x00009fc0, 0x803e4788}, {0x00009fc4, 0x0001efb5}, @@ -1142,9 +1151,6 @@ static const u32 ar9462_2p0_baseband_core[][2] = { {0x0000a398, 0x001f0e0f}, {0x0000a39c, 0x0075393f}, {0x0000a3a0, 0xb79f6427}, - {0x0000a3a4, 0x00000000}, - {0x0000a3a8, 0xaaaaaaaa}, - {0x0000a3ac, 0x3c466478}, {0x0000a3c0, 0x20202020}, {0x0000a3c4, 0x22222220}, {0x0000a3c8, 0x20200020}, @@ -1167,12 +1173,6 @@ static const u32 ar9462_2p0_baseband_core[][2] = { {0x0000a40c, 0x00820820}, {0x0000a414, 0x1ce739ce}, {0x0000a418, 0x2d001dce}, - {0x0000a41c, 0x1ce739ce}, - {0x0000a420, 0x000001ce}, - {0x0000a424, 0x1ce739ce}, - {0x0000a428, 0x000001ce}, - {0x0000a42c, 0x1ce739ce}, - {0x0000a430, 0x1ce739ce}, {0x0000a434, 0x00000000}, {0x0000a438, 0x00001801}, {0x0000a43c, 0x00100000}, diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index c9c3b1889965..36968c046119 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -1110,7 +1110,6 @@ bool ath9k_hw_disable(struct ath_hw *ah); void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test); void ath9k_hw_setopmode(struct ath_hw *ah); void ath9k_hw_setmcastfilter(struct ath_hw *ah, u32 filter0, u32 filter1); -void ath9k_hw_setbssidmask(struct ath_hw *ah); void ath9k_hw_write_associd(struct ath_hw *ah); u32 ath9k_hw_gettsf32(struct ath_hw *ah); u64 ath9k_hw_gettsf64(struct ath_hw *ah); -- cgit v1.2.3 From e7104195a9b43f05d908ced9ce5db137e1f3616b Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Thu, 1 Dec 2011 18:14:01 +0530 Subject: ath9k: clarify max_streams for AR9462 max_streams for AR9462 is '2'. it does not fixes anything, but improves the code readability Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/init.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index e9711e2b48c6..41b72faca77f 100644 --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c @@ -258,6 +258,8 @@ static void setup_ht_cap(struct ath_softc *sc, if (AR_SREV_9330(ah) || AR_SREV_9485(ah)) max_streams = 1; + else if (AR_SREV_9462(ah)) + max_streams = 2; else if (AR_SREV_9300_20_OR_LATER(ah)) max_streams = 3; else -- cgit v1.2.3 From 158969a26553cba63b7ac674159413d32bb57489 Mon Sep 17 00:00:00 2001 From: "Hsu, Kenny" Date: Fri, 2 Dec 2011 08:48:26 -0800 Subject: iwlwifi: add tm commands for sram reading by dumpit Create new testmode commands and attributes to suppot sram data reading. Because the amount of sram data may exceed single skb packet size. Using the nl80211 dump it funtion to deliver sram data to userspace. - IWL_TM_CMD_APP2DEV_READ_SRAM - IWL_TM_CMD_APP2DEV_DUMP_SRAM - IWL_TM_ATTR_SRAM_ADDR - IWL_TM_ATTR_SRAM_SIZE - IWL_TM_ATTR_SRAM_DUMP Signed-off-by: Kenny Hsu Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-dev.h | 7 ++ drivers/net/wireless/iwlwifi/iwl-sv-open.c | 109 ++++++++++++++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-testmode.h | 27 ++++++- 3 files changed, 141 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 0c95ad3048a0..cb24adbae082 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -790,6 +790,12 @@ struct iwl_testmode_trace { dma_addr_t dma_addr; bool trace_enabled; }; +struct iwl_testmode_sram { + u32 buff_size; + u32 num_chunks; + u8 *buff_addr; + bool sram_readed; +}; #endif struct iwl_wipan_noa_data { @@ -1070,6 +1076,7 @@ struct iwl_priv { bool led_registered; #ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL struct iwl_testmode_trace testmode_trace; + struct iwl_testmode_sram testmode_sram; u32 tm_fixed_rate; #endif diff --git a/drivers/net/wireless/iwlwifi/iwl-sv-open.c b/drivers/net/wireless/iwlwifi/iwl-sv-open.c index be16cafbbc27..593f42d9fb0a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-sv-open.c +++ b/drivers/net/wireless/iwlwifi/iwl-sv-open.c @@ -106,6 +106,10 @@ struct nla_policy iwl_testmode_gnl_msg_policy[IWL_TM_ATTR_MAX] = { [IWL_TM_ATTR_FIXRATE] = { .type = NLA_U32, }, [IWL_TM_ATTR_UCODE_OWNER] = { .type = NLA_U8, }, + + [IWL_TM_ATTR_SRAM_ADDR] = { .type = NLA_U32, }, + [IWL_TM_ATTR_SRAM_SIZE] = { .type = NLA_U32, }, + [IWL_TM_ATTR_SRAM_DUMP] = { .type = NLA_UNSPEC, }, }; /* @@ -177,6 +181,18 @@ void iwl_testmode_init(struct iwl_priv *priv) { priv->pre_rx_handler = iwl_testmode_ucode_rx_pkt; priv->testmode_trace.trace_enabled = false; + priv->testmode_sram.sram_readed = false; +} + +void iwl_sram_cleanup(struct iwl_priv *priv) +{ + if (priv->testmode_sram.sram_readed) { + kfree(priv->testmode_sram.buff_addr); + priv->testmode_sram.buff_addr = NULL; + priv->testmode_sram.buff_size = 0; + priv->testmode_sram.num_chunks = 0; + priv->testmode_sram.sram_readed = false; + } } static void iwl_trace_cleanup(struct iwl_priv *priv) @@ -201,6 +217,7 @@ static void iwl_trace_cleanup(struct iwl_priv *priv) void iwl_testmode_cleanup(struct iwl_priv *priv) { iwl_trace_cleanup(priv); + iwl_sram_cleanup(priv); } /* @@ -644,6 +661,89 @@ static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb) return 0; } +/* + * This function handles the user application commands for SRAM data dump + * + * It retrieves the mandatory fields IWL_TM_ATTR_SRAM_ADDR and + * IWL_TM_ATTR_SRAM_SIZE to decide the memory area for SRAM data reading + * + * Several error will be retured, -EBUSY if the SRAM data retrieved by + * previous command has not been delivered to userspace, or -ENOMSG if + * the mandatory fields (IWL_TM_ATTR_SRAM_ADDR,IWL_TM_ATTR_SRAM_SIZE) + * are missing, or -ENOMEM if the buffer allocation fails. + * + * Otherwise 0 is replied indicating the success of the SRAM reading. + * + * @hw: ieee80211_hw object that represents the device + * @tb: gnl message fields from the user space + */ +static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb) +{ + struct iwl_priv *priv = hw->priv; + u32 base, ofs, size; + + if (priv->testmode_sram.sram_readed) + return -EBUSY; + + if (!tb[IWL_TM_ATTR_SRAM_ADDR]) { + IWL_DEBUG_INFO(priv, "Error finding SRAM offset address\n"); + return -ENOMSG; + } + ofs = nla_get_u32(tb[IWL_TM_ATTR_SRAM_ADDR]); + if (!tb[IWL_TM_ATTR_SRAM_SIZE]) { + IWL_DEBUG_INFO(priv, "Error finding size for SRAM reading\n"); + return -ENOMSG; + } + size = nla_get_u32(tb[IWL_TM_ATTR_SRAM_SIZE]); + priv->testmode_sram.buff_size = (size / 4) * 4; + priv->testmode_sram.buff_addr = + kmalloc(priv->testmode_sram.buff_size, GFP_KERNEL); + if (priv->testmode_sram.buff_addr == NULL) { + IWL_DEBUG_INFO(priv, "Error allocating memory\n"); + return -ENOMEM; + } + base = 0x800000; + _iwl_read_targ_mem_words(bus(priv), base + ofs, + priv->testmode_sram.buff_addr, + priv->testmode_sram.buff_size / 4); + priv->testmode_sram.num_chunks = + DIV_ROUND_UP(priv->testmode_sram.buff_size, TRACE_CHUNK_SIZE); + priv->testmode_sram.sram_readed = true; + return 0; +} + +static int iwl_testmode_sram_dump(struct ieee80211_hw *hw, struct nlattr **tb, + struct sk_buff *skb, + struct netlink_callback *cb) +{ + struct iwl_priv *priv = hw->priv; + int idx, length; + + if (priv->testmode_sram.sram_readed) { + idx = cb->args[4]; + if (idx >= priv->testmode_sram.num_chunks) { + iwl_sram_cleanup(priv); + return -ENOENT; + } + length = TRACE_CHUNK_SIZE; + if (((idx + 1) == priv->testmode_sram.num_chunks) && + (priv->testmode_sram.buff_size % TRACE_CHUNK_SIZE)) + length = priv->testmode_sram.buff_size % + TRACE_CHUNK_SIZE; + + NLA_PUT(skb, IWL_TM_ATTR_SRAM_DUMP, length, + priv->testmode_sram.buff_addr + + (TRACE_CHUNK_SIZE * idx)); + idx++; + cb->args[4] = idx; + return 0; + } else + return -EFAULT; + + nla_put_failure: + return -ENOBUFS; +} + /* The testmode gnl message handler that takes the gnl message from the * user space and parses it per the policy iwl_testmode_gnl_msg_policy, then @@ -721,6 +821,11 @@ int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) result = iwl_testmode_ownership(hw, tb); break; + case IWL_TM_CMD_APP2DEV_READ_SRAM: + IWL_DEBUG_INFO(priv, "testmode sram read cmd to driver\n"); + result = iwl_testmode_sram(hw, tb); + break; + default: IWL_DEBUG_INFO(priv, "Unknown testmode command\n"); result = -ENOSYS; @@ -769,6 +874,10 @@ int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb, IWL_DEBUG_INFO(priv, "uCode trace cmd to driver\n"); result = iwl_testmode_trace_dump(hw, tb, skb, cb); break; + case IWL_TM_CMD_APP2DEV_DUMP_SRAM: + IWL_DEBUG_INFO(priv, "testmode sram dump cmd to driver\n"); + result = iwl_testmode_sram_dump(hw, tb, skb, cb); + break; default: result = -EINVAL; break; diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.h b/drivers/net/wireless/iwlwifi/iwl-testmode.h index 177964850b7c..95c87058677b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.h +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.h @@ -103,14 +103,20 @@ * @IWL_TM_CMD_DEV2APP_EEPROM_RSP: * commands from kernel space to carry the eeprom response * to user application + * * @IWL_TM_CMD_APP2DEV_OWNERSHIP: * commands from user application to own change the ownership of the uCode * if application has the ownership, the only host command from * testmode will deliver to uCode. Default owner is driver + * * @IWL_TM_CMD_APP2DEV_INDIRECT_REG_READ32: * @IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32: * commands from user applicaiton to indirectly access peripheral register * + * @IWL_TM_CMD_APP2DEV_READ_SRAM: + * @IWL_TM_CMD_APP2DEV_DUMP_SRAM: + * commands from user applicaiton to read data in sram + * */ enum iwl_tm_cmd_t { IWL_TM_CMD_APP2DEV_UCODE = 1, @@ -132,7 +138,9 @@ enum iwl_tm_cmd_t { IWL_TM_CMD_APP2DEV_OWNERSHIP = 17, IWL_TM_CMD_APP2DEV_INDIRECT_REG_READ32 = 18, IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32 = 19, - IWL_TM_CMD_MAX = 20, + IWL_TM_CMD_APP2DEV_READ_SRAM = 20, + IWL_TM_CMD_APP2DEV_DUMP_SRAM = 21, + IWL_TM_CMD_MAX = 22, }; /* @@ -202,6 +210,18 @@ enum iwl_tm_cmd_t { * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_OWNERSHIP, * The mandatory fields are: * IWL_TM_ATTR_UCODE_OWNER for the new owner + * + * @IWL_TM_ATTR_SRAM_ADDR: + * @IWL_TM_ATTR_SRAM_SIZE: + * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_READ_SRAM, + * The mandatory fields are: + * IWL_TM_ATTR_SRAM_ADDR for the address in sram + * IWL_TM_ATTR_SRAM_SIZE for the buffer size of data reading + * + * @IWL_TM_ATTR_SRAM_DUMP: + * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_DUMP_SRAM, + * IWL_TM_ATTR_SRAM_DUMP for the data in sram + * */ enum iwl_tm_attr_t { IWL_TM_ATTR_NOT_APPLICABLE = 0, @@ -219,7 +239,10 @@ enum iwl_tm_attr_t { IWL_TM_ATTR_TRACE_DUMP = 12, IWL_TM_ATTR_FIXRATE = 13, IWL_TM_ATTR_UCODE_OWNER = 14, - IWL_TM_ATTR_MAX = 15, + IWL_TM_ATTR_SRAM_ADDR = 15, + IWL_TM_ATTR_SRAM_SIZE = 16, + IWL_TM_ATTR_SRAM_DUMP = 17, + IWL_TM_ATTR_MAX = 18, }; /* uCode trace buffer */ -- cgit v1.2.3 From 835df183011db2342b42d06e17c708854ab6defb Mon Sep 17 00:00:00 2001 From: Kenny Hsu Date: Fri, 2 Dec 2011 08:48:27 -0800 Subject: iwlwifi: add range checking in tm sram read command The size of sram may alter according to ucode type. Retrieve the maximum sram size by current ucode type for range checking to prevent wrong data access. Signed-off-by: Kenny Hsu Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-sv-open.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-sv-open.c b/drivers/net/wireless/iwlwifi/iwl-sv-open.c index 593f42d9fb0a..a8d0ef649a7c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-sv-open.c +++ b/drivers/net/wireless/iwlwifi/iwl-sv-open.c @@ -680,7 +680,7 @@ static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb) static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb) { struct iwl_priv *priv = hw->priv; - u32 base, ofs, size; + u32 base, ofs, size, maxsize; if (priv->testmode_sram.sram_readed) return -EBUSY; @@ -695,6 +695,27 @@ static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb) return -ENOMSG; } size = nla_get_u32(tb[IWL_TM_ATTR_SRAM_SIZE]); + switch (priv->ucode_type) { + case IWL_UCODE_REGULAR: + maxsize = trans(priv)->ucode_rt.data.len; + break; + case IWL_UCODE_INIT: + maxsize = trans(priv)->ucode_init.data.len; + break; + case IWL_UCODE_WOWLAN: + maxsize = trans(priv)->ucode_wowlan.data.len; + break; + case IWL_UCODE_NONE: + IWL_DEBUG_INFO(priv, "Error, uCode does not been loaded\n"); + return -ENOSYS; + default: + IWL_DEBUG_INFO(priv, "Error, unsupported uCode type\n"); + return -ENOSYS; + } + if ((ofs + size) > maxsize) { + IWL_DEBUG_INFO(priv, "Invalid offset/size: out of range\n"); + return -EINVAL; + } priv->testmode_sram.buff_size = (size / 4) * 4; priv->testmode_sram.buff_addr = kmalloc(priv->testmode_sram.buff_size, GFP_KERNEL); -- cgit v1.2.3 From a2f759fc41579205ad86ef17efe57e730a1af9e6 Mon Sep 17 00:00:00 2001 From: "Hsu, Kenny" Date: Fri, 2 Dec 2011 08:48:28 -0800 Subject: iwlwifi: add generic chunk size of tm dumpit packet Use generic chunk size of dumpit packet for all necessary testmode commands instead of add declaration individually. Signed-off-by: Kenny Hsu Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-sv-open.c | 20 ++++++++++---------- drivers/net/wireless/iwlwifi/iwl-testmode.h | 4 +++- 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-sv-open.c b/drivers/net/wireless/iwlwifi/iwl-sv-open.c index a8d0ef649a7c..4ea64d65b35b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-sv-open.c +++ b/drivers/net/wireless/iwlwifi/iwl-sv-open.c @@ -575,7 +575,7 @@ static int iwl_testmode_trace(struct ieee80211_hw *hw, struct nlattr **tb) } priv->testmode_trace.num_chunks = DIV_ROUND_UP(priv->testmode_trace.buff_size, - TRACE_CHUNK_SIZE); + DUMP_CHUNK_SIZE); break; case IWL_TM_CMD_APP2DEV_END_TRACE: @@ -607,15 +607,15 @@ static int iwl_testmode_trace_dump(struct ieee80211_hw *hw, struct nlattr **tb, idx = cb->args[4]; if (idx >= priv->testmode_trace.num_chunks) return -ENOENT; - length = TRACE_CHUNK_SIZE; + length = DUMP_CHUNK_SIZE; if (((idx + 1) == priv->testmode_trace.num_chunks) && - (priv->testmode_trace.buff_size % TRACE_CHUNK_SIZE)) + (priv->testmode_trace.buff_size % DUMP_CHUNK_SIZE)) length = priv->testmode_trace.buff_size % - TRACE_CHUNK_SIZE; + DUMP_CHUNK_SIZE; NLA_PUT(skb, IWL_TM_ATTR_TRACE_DUMP, length, priv->testmode_trace.trace_addr + - (TRACE_CHUNK_SIZE * idx)); + (DUMP_CHUNK_SIZE * idx)); idx++; cb->args[4] = idx; return 0; @@ -728,7 +728,7 @@ static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb) priv->testmode_sram.buff_addr, priv->testmode_sram.buff_size / 4); priv->testmode_sram.num_chunks = - DIV_ROUND_UP(priv->testmode_sram.buff_size, TRACE_CHUNK_SIZE); + DIV_ROUND_UP(priv->testmode_sram.buff_size, DUMP_CHUNK_SIZE); priv->testmode_sram.sram_readed = true; return 0; } @@ -746,15 +746,15 @@ static int iwl_testmode_sram_dump(struct ieee80211_hw *hw, struct nlattr **tb, iwl_sram_cleanup(priv); return -ENOENT; } - length = TRACE_CHUNK_SIZE; + length = DUMP_CHUNK_SIZE; if (((idx + 1) == priv->testmode_sram.num_chunks) && - (priv->testmode_sram.buff_size % TRACE_CHUNK_SIZE)) + (priv->testmode_sram.buff_size % DUMP_CHUNK_SIZE)) length = priv->testmode_sram.buff_size % - TRACE_CHUNK_SIZE; + DUMP_CHUNK_SIZE; NLA_PUT(skb, IWL_TM_ATTR_SRAM_DUMP, length, priv->testmode_sram.buff_addr + - (TRACE_CHUNK_SIZE * idx)); + (DUMP_CHUNK_SIZE * idx)); idx++; cb->args[4] = idx; return 0; diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.h b/drivers/net/wireless/iwlwifi/iwl-testmode.h index 95c87058677b..e20f3d390271 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.h +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.h @@ -250,6 +250,8 @@ enum iwl_tm_attr_t { #define TRACE_BUFF_SIZE_MIN 0x20000 #define TRACE_BUFF_SIZE_DEF TRACE_BUFF_SIZE_MIN #define TRACE_BUFF_PADD 0x2000 -#define TRACE_CHUNK_SIZE (PAGE_SIZE - 1024) + +/* Maximum data size of each dump it packet */ +#define DUMP_CHUNK_SIZE (PAGE_SIZE - 1024) #endif -- cgit v1.2.3 From f05f2efd84de22d3fa6e49145b601077f8ba8d2f Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Fri, 2 Dec 2011 08:48:29 -0800 Subject: iwlwifi: declare static for iwl_sram_cleanup function Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-sv-open.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-sv-open.c b/drivers/net/wireless/iwlwifi/iwl-sv-open.c index 4ea64d65b35b..21b2fbb4dc3b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-sv-open.c +++ b/drivers/net/wireless/iwlwifi/iwl-sv-open.c @@ -184,7 +184,7 @@ void iwl_testmode_init(struct iwl_priv *priv) priv->testmode_sram.sram_readed = false; } -void iwl_sram_cleanup(struct iwl_priv *priv) +static void iwl_sram_cleanup(struct iwl_priv *priv) { if (priv->testmode_sram.sram_readed) { kfree(priv->testmode_sram.buff_addr); -- cgit v1.2.3 From d6846347a0e1bc111b67a1366380419231b97984 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 2 Dec 2011 08:48:31 -0800 Subject: iwlagn: remove TX_REPLY_LIMIT debug This macro is unused right now. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-debug.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h index 44a7bdd7ccfd..a842d711fc13 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debug.h +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h @@ -206,8 +206,6 @@ static inline void iwl_dbgfs_unregister(struct iwl_priv *priv) #define IWL_DEBUG_STATS_LIMIT(p, f, a...) \ IWL_DEBUG_LIMIT(p, IWL_DL_STATS, f, ## a) #define IWL_DEBUG_TX_REPLY(p, f, a...) IWL_DEBUG(p, IWL_DL_TX_REPLY, f, ## a) -#define IWL_DEBUG_TX_REPLY_LIMIT(p, f, a...) \ - IWL_DEBUG_LIMIT(p, IWL_DL_TX_REPLY, f, ## a) #define IWL_DEBUG_TX_QUEUES(p, f, a...) IWL_DEBUG(p, IWL_DL_TX_QUEUES, f, ## a) #define IWL_DEBUG_RADIO(p, f, a...) IWL_DEBUG(p, IWL_DL_RADIO, f, ## a) #define IWL_DEBUG_POWER(p, f, a...) IWL_DEBUG(p, IWL_DL_POWER, f, ## a) -- cgit v1.2.3 From 145274408049d21274e3c645066aa7980165c71e Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 2 Dec 2011 08:48:32 -0800 Subject: iwlagn: remove HC_DUMP debug This debug level is unused, remove it. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-debug.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h index a842d711fc13..32206088c646 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debug.h +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h @@ -140,7 +140,7 @@ static inline void iwl_dbgfs_unregister(struct iwl_priv *priv) #define IWL_DL_STATE (1 << 3) /* 0x000000F0 - 0x00000010 */ #define IWL_DL_MACDUMP (1 << 4) -#define IWL_DL_HCMD_DUMP (1 << 5) +/* unused (1 << 5) */ #define IWL_DL_EEPROM (1 << 6) #define IWL_DL_RADIO (1 << 7) /* 0x00000F00 - 0x00000100 */ @@ -184,7 +184,6 @@ static inline void iwl_dbgfs_unregister(struct iwl_priv *priv) #define IWL_DEBUG_LED(p, f, a...) IWL_DEBUG(p, IWL_DL_LED, f, ## a) #define IWL_DEBUG_WEP(p, f, a...) IWL_DEBUG(p, IWL_DL_WEP, f, ## a) #define IWL_DEBUG_HC(p, f, a...) IWL_DEBUG(p, IWL_DL_HCMD, f, ## a) -#define IWL_DEBUG_HC_DUMP(p, f, a...) IWL_DEBUG(p, IWL_DL_HCMD_DUMP, f, ## a) #define IWL_DEBUG_EEPROM(p, f, a...) IWL_DEBUG(p, IWL_DL_EEPROM, f, ## a) #define IWL_DEBUG_CALIB(p, f, a...) IWL_DEBUG(p, IWL_DL_CALIB, f, ## a) #define IWL_DEBUG_FW(p, f, a...) IWL_DEBUG(p, IWL_DL_FW, f, ## a) -- cgit v1.2.3 From d28a21d8aaccadf930085cf581abc9b5e048026d Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 2 Dec 2011 08:48:33 -0800 Subject: iwlagn: remove MACDUMP debug This is only used for TX debugging where there already is more debugging and tracing is more useful anyway, so remove it. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-debug.h | 3 +-- drivers/net/wireless/iwlwifi/iwl-mac80211.c | 4 ---- 2 files changed, 1 insertion(+), 6 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h index 32206088c646..95740c131a1f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debug.h +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h @@ -139,7 +139,7 @@ static inline void iwl_dbgfs_unregister(struct iwl_priv *priv) #define IWL_DL_HCMD (1 << 2) #define IWL_DL_STATE (1 << 3) /* 0x000000F0 - 0x00000010 */ -#define IWL_DL_MACDUMP (1 << 4) +/* unused (1 << 4) */ /* unused (1 << 5) */ #define IWL_DL_EEPROM (1 << 6) #define IWL_DL_RADIO (1 << 7) @@ -175,7 +175,6 @@ static inline void iwl_dbgfs_unregister(struct iwl_priv *priv) #define IWL_DEBUG_INFO(p, f, a...) IWL_DEBUG(p, IWL_DL_INFO, f, ## a) #define IWL_DEBUG_MAC80211(p, f, a...) IWL_DEBUG(p, IWL_DL_MAC80211, f, ## a) -#define IWL_DEBUG_MACDUMP(p, f, a...) IWL_DEBUG(p, IWL_DL_MACDUMP, f, ## a) #define IWL_DEBUG_TEMP(p, f, a...) IWL_DEBUG(p, IWL_DL_TEMP, f, ## a) #define IWL_DEBUG_SCAN(p, f, a...) IWL_DEBUG(p, IWL_DL_SCAN, f, ## a) #define IWL_DEBUG_RX(p, f, a...) IWL_DEBUG(p, IWL_DL_RX, f, ## a) diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 05b1f0d2f387..794b735264e6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -481,15 +481,11 @@ static void iwlagn_mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { struct iwl_priv *priv = hw->priv; - IWL_DEBUG_MACDUMP(priv, "enter\n"); - IWL_DEBUG_TX(priv, "dev->xmit(%d bytes) at rate 0x%02x\n", skb->len, ieee80211_get_tx_rate(hw, IEEE80211_SKB_CB(skb))->bitrate); if (iwlagn_tx_skb(priv, skb)) dev_kfree_skb_any(skb); - - IWL_DEBUG_MACDUMP(priv, "leave\n"); } static void iwlagn_mac_update_tkip_key(struct ieee80211_hw *hw, -- cgit v1.2.3 From 112f11dc219ec8f9b0cf5cf9f55fef1096006908 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 2 Dec 2011 08:48:34 -0800 Subject: iwlagn: make debug levels more readable Using the actual shifted constants here allows one to read and or them more easily. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-debug.h | 58 +++++++++++++++----------------- 1 file changed, 27 insertions(+), 31 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h index 95740c131a1f..f8fc2393dd4c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debug.h +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h @@ -134,44 +134,40 @@ static inline void iwl_dbgfs_unregister(struct iwl_priv *priv) */ /* 0x0000000F - 0x00000001 */ -#define IWL_DL_INFO (1 << 0) -#define IWL_DL_MAC80211 (1 << 1) -#define IWL_DL_HCMD (1 << 2) -#define IWL_DL_STATE (1 << 3) +#define IWL_DL_INFO 0x00000001 +#define IWL_DL_MAC80211 0x00000002 +#define IWL_DL_HCMD 0x00000004 +#define IWL_DL_STATE 0x00000008 /* 0x000000F0 - 0x00000010 */ -/* unused (1 << 4) */ -/* unused (1 << 5) */ -#define IWL_DL_EEPROM (1 << 6) -#define IWL_DL_RADIO (1 << 7) +#define IWL_DL_EEPROM 0x00000040 +#define IWL_DL_RADIO 0x00000080 /* 0x00000F00 - 0x00000100 */ -#define IWL_DL_POWER (1 << 8) -#define IWL_DL_TEMP (1 << 9) -/* reserved (1 << 10) */ -#define IWL_DL_SCAN (1 << 11) +#define IWL_DL_POWER 0x00000100 +#define IWL_DL_TEMP 0x00000200 +#define IWL_DL_SCAN 0x00000800 /* 0x0000F000 - 0x00001000 */ -#define IWL_DL_ASSOC (1 << 12) -#define IWL_DL_DROP (1 << 13) -/* reserved (1 << 14) */ -#define IWL_DL_COEX (1 << 15) +#define IWL_DL_ASSOC 0x00001000 +#define IWL_DL_DROP 0x00002000 +#define IWL_DL_COEX 0x00008000 /* 0x000F0000 - 0x00010000 */ -#define IWL_DL_FW (1 << 16) -#define IWL_DL_RF_KILL (1 << 17) -#define IWL_DL_FW_ERRORS (1 << 18) -#define IWL_DL_LED (1 << 19) +#define IWL_DL_FW 0x00010000 +#define IWL_DL_RF_KILL 0x00020000 +#define IWL_DL_FW_ERRORS 0x00040000 +#define IWL_DL_LED 0x00080000 /* 0x00F00000 - 0x00100000 */ -#define IWL_DL_RATE (1 << 20) -#define IWL_DL_CALIB (1 << 21) -#define IWL_DL_WEP (1 << 22) -#define IWL_DL_TX (1 << 23) +#define IWL_DL_RATE 0x00100000 +#define IWL_DL_CALIB 0x00200000 +#define IWL_DL_WEP 0x00400000 +#define IWL_DL_TX 0x00800000 /* 0x0F000000 - 0x01000000 */ -#define IWL_DL_RX (1 << 24) -#define IWL_DL_ISR (1 << 25) -#define IWL_DL_HT (1 << 26) +#define IWL_DL_RX 0x01000000 +#define IWL_DL_ISR 0x02000000 +#define IWL_DL_HT 0x04000000 /* 0xF0000000 - 0x10000000 */ -#define IWL_DL_11H (1 << 28) -#define IWL_DL_STATS (1 << 29) -#define IWL_DL_TX_REPLY (1 << 30) -#define IWL_DL_TX_QUEUES (1 << 31) +#define IWL_DL_11H 0x10000000 +#define IWL_DL_STATS 0x20000000 +#define IWL_DL_TX_REPLY 0x40000000 +#define IWL_DL_TX_QUEUES 0x80000000 #define IWL_DEBUG_INFO(p, f, a...) IWL_DEBUG(p, IWL_DL_INFO, f, ## a) #define IWL_DEBUG_MAC80211(p, f, a...) IWL_DEBUG(p, IWL_DL_MAC80211, f, ## a) -- cgit v1.2.3 From ca4c18231935bafeb2a36eec67f6d11076223084 Mon Sep 17 00:00:00 2001 From: "Hsu, Kenny" Date: Fri, 2 Dec 2011 08:48:35 -0800 Subject: iwlwifi: add WOWLAN uCode loading support by testmode Create new tm command for WOWLAN uCode loading to support further debugging function in userspace. - IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW Signed-off-by: Kenny Hsu Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-sv-open.c | 16 ++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-testmode.h | 5 ++++- 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-sv-open.c b/drivers/net/wireless/iwlwifi/iwl-sv-open.c index 21b2fbb4dc3b..3c9762628760 100644 --- a/drivers/net/wireless/iwlwifi/iwl-sv-open.c +++ b/drivers/net/wireless/iwlwifi/iwl-sv-open.c @@ -463,6 +463,21 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) "Error starting the device: %d\n", status); break; + case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: + iwl_scan_cancel_timeout(priv, 200); + iwl_trans_stop_device(trans(priv)); + status = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_WOWLAN); + if (status) { + IWL_DEBUG_INFO(priv, + "Error loading WOWLAN ucode: %d\n", status); + break; + } + status = iwl_alive_start(priv); + if (status) + IWL_DEBUG_INFO(priv, + "Error starting the device: %d\n", status); + break; + case IWL_TM_CMD_APP2DEV_GET_EEPROM: if (priv->eeprom) { skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, @@ -826,6 +841,7 @@ int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW: case IWL_TM_CMD_APP2DEV_GET_EEPROM: case IWL_TM_CMD_APP2DEV_FIXRATE_REQ: + case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: IWL_DEBUG_INFO(priv, "testmode cmd to driver\n"); result = iwl_testmode_driver(hw, tb); break; diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.h b/drivers/net/wireless/iwlwifi/iwl-testmode.h index e20f3d390271..deedd27c5f3d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.h +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.h @@ -117,6 +117,8 @@ * @IWL_TM_CMD_APP2DEV_DUMP_SRAM: * commands from user applicaiton to read data in sram * + * @IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: load Weak On Wireless LAN uCode image + * */ enum iwl_tm_cmd_t { IWL_TM_CMD_APP2DEV_UCODE = 1, @@ -140,7 +142,8 @@ enum iwl_tm_cmd_t { IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32 = 19, IWL_TM_CMD_APP2DEV_READ_SRAM = 20, IWL_TM_CMD_APP2DEV_DUMP_SRAM = 21, - IWL_TM_CMD_MAX = 22, + IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW = 22, + IWL_TM_CMD_MAX = 23, }; /* -- cgit v1.2.3 From 6d5f3ec52939607511a660b01fc34d11ad71ae24 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Fri, 2 Dec 2011 08:48:36 -0800 Subject: iwlwifi: Rename file name from iwl-sv-open.c to iwl-testmode.c The file dealing with all the operations through testmode, rename it. Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/Makefile | 2 +- drivers/net/wireless/iwlwifi/iwl-sv-open.c | 925 ---------------------------- drivers/net/wireless/iwlwifi/iwl-testmode.c | 925 ++++++++++++++++++++++++++++ 3 files changed, 926 insertions(+), 926 deletions(-) delete mode 100644 drivers/net/wireless/iwlwifi/iwl-sv-open.c create mode 100644 drivers/net/wireless/iwlwifi/iwl-testmode.c (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile index a7ab280994c8..5a052a5e4fb6 100644 --- a/drivers/net/wireless/iwlwifi/Makefile +++ b/drivers/net/wireless/iwlwifi/Makefile @@ -18,7 +18,7 @@ iwlwifi-objs += iwl-trans-pcie.o iwl-trans-pcie-rx.o iwl-trans-pcie-tx.o iwlwifi-$(CONFIG_IWLWIFI_DEBUGFS) += iwl-debugfs.o iwlwifi-$(CONFIG_IWLWIFI_DEVICE_TRACING) += iwl-devtrace.o -iwlwifi-$(CONFIG_IWLWIFI_DEVICE_SVTOOL) += iwl-sv-open.o +iwlwifi-$(CONFIG_IWLWIFI_DEVICE_SVTOOL) += iwl-testmode.o CFLAGS_iwl-devtrace.o := -I$(src) diff --git a/drivers/net/wireless/iwlwifi/iwl-sv-open.c b/drivers/net/wireless/iwlwifi/iwl-sv-open.c deleted file mode 100644 index 3c9762628760..000000000000 --- a/drivers/net/wireless/iwlwifi/iwl-sv-open.c +++ /dev/null @@ -1,925 +0,0 @@ -/****************************************************************************** - * - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2010 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - * BSD LICENSE - * - * Copyright(c) 2010 - 2011 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - *****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-debug.h" -#include "iwl-io.h" -#include "iwl-agn.h" -#include "iwl-testmode.h" -#include "iwl-trans.h" - -/* The TLVs used in the gnl message policy between the kernel module and - * user space application. iwl_testmode_gnl_msg_policy is to be carried - * through the NL80211_CMD_TESTMODE channel regulated by nl80211. - * See iwl-testmode.h - */ -static -struct nla_policy iwl_testmode_gnl_msg_policy[IWL_TM_ATTR_MAX] = { - [IWL_TM_ATTR_COMMAND] = { .type = NLA_U32, }, - - [IWL_TM_ATTR_UCODE_CMD_ID] = { .type = NLA_U8, }, - [IWL_TM_ATTR_UCODE_CMD_DATA] = { .type = NLA_UNSPEC, }, - - [IWL_TM_ATTR_REG_OFFSET] = { .type = NLA_U32, }, - [IWL_TM_ATTR_REG_VALUE8] = { .type = NLA_U8, }, - [IWL_TM_ATTR_REG_VALUE32] = { .type = NLA_U32, }, - - [IWL_TM_ATTR_SYNC_RSP] = { .type = NLA_UNSPEC, }, - [IWL_TM_ATTR_UCODE_RX_PKT] = { .type = NLA_UNSPEC, }, - - [IWL_TM_ATTR_EEPROM] = { .type = NLA_UNSPEC, }, - - [IWL_TM_ATTR_TRACE_ADDR] = { .type = NLA_UNSPEC, }, - [IWL_TM_ATTR_TRACE_DUMP] = { .type = NLA_UNSPEC, }, - [IWL_TM_ATTR_TRACE_SIZE] = { .type = NLA_U32, }, - - [IWL_TM_ATTR_FIXRATE] = { .type = NLA_U32, }, - - [IWL_TM_ATTR_UCODE_OWNER] = { .type = NLA_U8, }, - - [IWL_TM_ATTR_SRAM_ADDR] = { .type = NLA_U32, }, - [IWL_TM_ATTR_SRAM_SIZE] = { .type = NLA_U32, }, - [IWL_TM_ATTR_SRAM_DUMP] = { .type = NLA_UNSPEC, }, -}; - -/* - * See the struct iwl_rx_packet in iwl-commands.h for the format of the - * received events from the device - */ -static inline int get_event_length(struct iwl_rx_mem_buffer *rxb) -{ - struct iwl_rx_packet *pkt = rxb_addr(rxb); - if (pkt) - return le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; - else - return 0; -} - - -/* - * This function multicasts the spontaneous messages from the device to the - * user space. It is invoked whenever there is a received messages - * from the device. This function is called within the ISR of the rx handlers - * in iwlagn driver. - * - * The parsing of the message content is left to the user space application, - * The message content is treated as unattacked raw data and is encapsulated - * with IWL_TM_ATTR_UCODE_RX_PKT multicasting to the user space. - * - * @priv: the instance of iwlwifi device - * @rxb: pointer to rx data content received by the ISR - * - * See the message policies and TLVs in iwl_testmode_gnl_msg_policy[]. - * For the messages multicasting to the user application, the mandatory - * TLV fields are : - * IWL_TM_ATTR_COMMAND must be IWL_TM_CMD_DEV2APP_UCODE_RX_PKT - * IWL_TM_ATTR_UCODE_RX_PKT for carrying the message content - */ - -static void iwl_testmode_ucode_rx_pkt(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb) -{ - struct ieee80211_hw *hw = priv->hw; - struct sk_buff *skb; - void *data; - int length; - - data = (void *)rxb_addr(rxb); - length = get_event_length(rxb); - - if (!data || length == 0) - return; - - skb = cfg80211_testmode_alloc_event_skb(hw->wiphy, 20 + length, - GFP_ATOMIC); - if (skb == NULL) { - IWL_DEBUG_INFO(priv, - "Run out of memory for messages to user space ?\n"); - return; - } - NLA_PUT_U32(skb, IWL_TM_ATTR_COMMAND, IWL_TM_CMD_DEV2APP_UCODE_RX_PKT); - NLA_PUT(skb, IWL_TM_ATTR_UCODE_RX_PKT, length, data); - cfg80211_testmode_event(skb, GFP_ATOMIC); - return; - -nla_put_failure: - kfree_skb(skb); - IWL_DEBUG_INFO(priv, "Ouch, overran buffer, check allocation!\n"); -} - -void iwl_testmode_init(struct iwl_priv *priv) -{ - priv->pre_rx_handler = iwl_testmode_ucode_rx_pkt; - priv->testmode_trace.trace_enabled = false; - priv->testmode_sram.sram_readed = false; -} - -static void iwl_sram_cleanup(struct iwl_priv *priv) -{ - if (priv->testmode_sram.sram_readed) { - kfree(priv->testmode_sram.buff_addr); - priv->testmode_sram.buff_addr = NULL; - priv->testmode_sram.buff_size = 0; - priv->testmode_sram.num_chunks = 0; - priv->testmode_sram.sram_readed = false; - } -} - -static void iwl_trace_cleanup(struct iwl_priv *priv) -{ - if (priv->testmode_trace.trace_enabled) { - if (priv->testmode_trace.cpu_addr && - priv->testmode_trace.dma_addr) - dma_free_coherent(bus(priv)->dev, - priv->testmode_trace.total_size, - priv->testmode_trace.cpu_addr, - priv->testmode_trace.dma_addr); - priv->testmode_trace.trace_enabled = false; - priv->testmode_trace.cpu_addr = NULL; - priv->testmode_trace.trace_addr = NULL; - priv->testmode_trace.dma_addr = 0; - priv->testmode_trace.buff_size = 0; - priv->testmode_trace.total_size = 0; - } -} - - -void iwl_testmode_cleanup(struct iwl_priv *priv) -{ - iwl_trace_cleanup(priv); - iwl_sram_cleanup(priv); -} - -/* - * This function handles the user application commands to the ucode. - * - * It retrieves the mandatory fields IWL_TM_ATTR_UCODE_CMD_ID and - * IWL_TM_ATTR_UCODE_CMD_DATA and calls to the handler to send the - * host command to the ucode. - * - * If any mandatory field is missing, -ENOMSG is replied to the user space - * application; otherwise, the actual execution result of the host command to - * ucode is replied. - * - * @hw: ieee80211_hw object that represents the device - * @tb: gnl message fields from the user space - */ -static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb) -{ - struct iwl_priv *priv = hw->priv; - struct iwl_host_cmd cmd; - - memset(&cmd, 0, sizeof(struct iwl_host_cmd)); - - if (!tb[IWL_TM_ATTR_UCODE_CMD_ID] || - !tb[IWL_TM_ATTR_UCODE_CMD_DATA]) { - IWL_DEBUG_INFO(priv, - "Error finding ucode command mandatory fields\n"); - return -ENOMSG; - } - - cmd.flags = CMD_ON_DEMAND; - cmd.id = nla_get_u8(tb[IWL_TM_ATTR_UCODE_CMD_ID]); - cmd.data[0] = nla_data(tb[IWL_TM_ATTR_UCODE_CMD_DATA]); - cmd.len[0] = nla_len(tb[IWL_TM_ATTR_UCODE_CMD_DATA]); - cmd.dataflags[0] = IWL_HCMD_DFL_NOCOPY; - IWL_INFO(priv, "testmode ucode command ID 0x%x, flags 0x%x," - " len %d\n", cmd.id, cmd.flags, cmd.len[0]); - /* ok, let's submit the command to ucode */ - return iwl_trans_send_cmd(trans(priv), &cmd); -} - - -/* - * This function handles the user application commands for register access. - * - * It retrieves command ID carried with IWL_TM_ATTR_COMMAND and calls to the - * handlers respectively. - * - * If it's an unknown commdn ID, -ENOSYS is returned; or -ENOMSG if the - * mandatory fields(IWL_TM_ATTR_REG_OFFSET,IWL_TM_ATTR_REG_VALUE32, - * IWL_TM_ATTR_REG_VALUE8) are missing; Otherwise 0 is replied indicating - * the success of the command execution. - * - * If IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_REG_READ32, the register read - * value is returned with IWL_TM_ATTR_REG_VALUE32. - * - * @hw: ieee80211_hw object that represents the device - * @tb: gnl message fields from the user space - */ -static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) -{ - struct iwl_priv *priv = hw->priv; - u32 ofs, val32; - u8 val8; - struct sk_buff *skb; - int status = 0; - - if (!tb[IWL_TM_ATTR_REG_OFFSET]) { - IWL_DEBUG_INFO(priv, "Error finding register offset\n"); - return -ENOMSG; - } - ofs = nla_get_u32(tb[IWL_TM_ATTR_REG_OFFSET]); - IWL_INFO(priv, "testmode register access command offset 0x%x\n", ofs); - - switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { - case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32: - val32 = iwl_read32(bus(priv), ofs); - IWL_INFO(priv, "32bit value to read 0x%x\n", val32); - - skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); - if (!skb) { - IWL_DEBUG_INFO(priv, "Error allocating memory\n"); - return -ENOMEM; - } - NLA_PUT_U32(skb, IWL_TM_ATTR_REG_VALUE32, val32); - status = cfg80211_testmode_reply(skb); - if (status < 0) - IWL_DEBUG_INFO(priv, - "Error sending msg : %d\n", status); - break; - case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32: - if (!tb[IWL_TM_ATTR_REG_VALUE32]) { - IWL_DEBUG_INFO(priv, - "Error finding value to write\n"); - return -ENOMSG; - } else { - val32 = nla_get_u32(tb[IWL_TM_ATTR_REG_VALUE32]); - IWL_INFO(priv, "32bit value to write 0x%x\n", val32); - iwl_write32(bus(priv), ofs, val32); - } - break; - case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8: - if (!tb[IWL_TM_ATTR_REG_VALUE8]) { - IWL_DEBUG_INFO(priv, "Error finding value to write\n"); - return -ENOMSG; - } else { - val8 = nla_get_u8(tb[IWL_TM_ATTR_REG_VALUE8]); - IWL_INFO(priv, "8bit value to write 0x%x\n", val8); - iwl_write8(bus(priv), ofs, val8); - } - break; - case IWL_TM_CMD_APP2DEV_INDIRECT_REG_READ32: - val32 = iwl_read_prph(bus(priv), ofs); - IWL_INFO(priv, "32bit value to read 0x%x\n", val32); - - skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); - if (!skb) { - IWL_DEBUG_INFO(priv, "Error allocating memory\n"); - return -ENOMEM; - } - NLA_PUT_U32(skb, IWL_TM_ATTR_REG_VALUE32, val32); - status = cfg80211_testmode_reply(skb); - if (status < 0) - IWL_DEBUG_INFO(priv, - "Error sending msg : %d\n", status); - break; - case IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32: - if (!tb[IWL_TM_ATTR_REG_VALUE32]) { - IWL_DEBUG_INFO(priv, - "Error finding value to write\n"); - return -ENOMSG; - } else { - val32 = nla_get_u32(tb[IWL_TM_ATTR_REG_VALUE32]); - IWL_INFO(priv, "32bit value to write 0x%x\n", val32); - iwl_write_prph(bus(priv), ofs, val32); - } - break; - default: - IWL_DEBUG_INFO(priv, "Unknown testmode register command ID\n"); - return -ENOSYS; - } - - return status; - -nla_put_failure: - kfree_skb(skb); - return -EMSGSIZE; -} - - -static int iwl_testmode_cfg_init_calib(struct iwl_priv *priv) -{ - struct iwl_notification_wait calib_wait; - int ret; - - iwlagn_init_notification_wait(priv, &calib_wait, - CALIBRATION_COMPLETE_NOTIFICATION, - NULL, NULL); - ret = iwlagn_init_alive_start(priv); - if (ret) { - IWL_DEBUG_INFO(priv, - "Error configuring init calibration: %d\n", ret); - goto cfg_init_calib_error; - } - - ret = iwlagn_wait_notification(priv, &calib_wait, 2 * HZ); - if (ret) - IWL_DEBUG_INFO(priv, "Error detecting" - " CALIBRATION_COMPLETE_NOTIFICATION: %d\n", ret); - return ret; - -cfg_init_calib_error: - iwlagn_remove_notification(priv, &calib_wait); - return ret; -} - -/* - * This function handles the user application commands for driver. - * - * It retrieves command ID carried with IWL_TM_ATTR_COMMAND and calls to the - * handlers respectively. - * - * If it's an unknown commdn ID, -ENOSYS is replied; otherwise, the returned - * value of the actual command execution is replied to the user application. - * - * If there's any message responding to the user space, IWL_TM_ATTR_SYNC_RSP - * is used for carry the message while IWL_TM_ATTR_COMMAND must set to - * IWL_TM_CMD_DEV2APP_SYNC_RSP. - * - * @hw: ieee80211_hw object that represents the device - * @tb: gnl message fields from the user space - */ -static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) -{ - struct iwl_priv *priv = hw->priv; - struct sk_buff *skb; - unsigned char *rsp_data_ptr = NULL; - int status = 0, rsp_data_len = 0; - - switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { - case IWL_TM_CMD_APP2DEV_GET_DEVICENAME: - rsp_data_ptr = (unsigned char *)priv->cfg->name; - rsp_data_len = strlen(priv->cfg->name); - skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, - rsp_data_len + 20); - if (!skb) { - IWL_DEBUG_INFO(priv, - "Error allocating memory\n"); - return -ENOMEM; - } - NLA_PUT_U32(skb, IWL_TM_ATTR_COMMAND, - IWL_TM_CMD_DEV2APP_SYNC_RSP); - NLA_PUT(skb, IWL_TM_ATTR_SYNC_RSP, - rsp_data_len, rsp_data_ptr); - status = cfg80211_testmode_reply(skb); - if (status < 0) - IWL_DEBUG_INFO(priv, "Error sending msg : %d\n", - status); - break; - - case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW: - status = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_INIT); - if (status) - IWL_DEBUG_INFO(priv, - "Error loading init ucode: %d\n", status); - break; - - case IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB: - iwl_testmode_cfg_init_calib(priv); - iwl_trans_stop_device(trans(priv)); - break; - - case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW: - status = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_REGULAR); - if (status) { - IWL_DEBUG_INFO(priv, - "Error loading runtime ucode: %d\n", status); - break; - } - status = iwl_alive_start(priv); - if (status) - IWL_DEBUG_INFO(priv, - "Error starting the device: %d\n", status); - break; - - case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: - iwl_scan_cancel_timeout(priv, 200); - iwl_trans_stop_device(trans(priv)); - status = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_WOWLAN); - if (status) { - IWL_DEBUG_INFO(priv, - "Error loading WOWLAN ucode: %d\n", status); - break; - } - status = iwl_alive_start(priv); - if (status) - IWL_DEBUG_INFO(priv, - "Error starting the device: %d\n", status); - break; - - case IWL_TM_CMD_APP2DEV_GET_EEPROM: - if (priv->eeprom) { - skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, - priv->cfg->base_params->eeprom_size + 20); - if (!skb) { - IWL_DEBUG_INFO(priv, - "Error allocating memory\n"); - return -ENOMEM; - } - NLA_PUT_U32(skb, IWL_TM_ATTR_COMMAND, - IWL_TM_CMD_DEV2APP_EEPROM_RSP); - NLA_PUT(skb, IWL_TM_ATTR_EEPROM, - priv->cfg->base_params->eeprom_size, - priv->eeprom); - status = cfg80211_testmode_reply(skb); - if (status < 0) - IWL_DEBUG_INFO(priv, - "Error sending msg : %d\n", - status); - } else - return -EFAULT; - break; - - case IWL_TM_CMD_APP2DEV_FIXRATE_REQ: - if (!tb[IWL_TM_ATTR_FIXRATE]) { - IWL_DEBUG_INFO(priv, - "Error finding fixrate setting\n"); - return -ENOMSG; - } - priv->tm_fixed_rate = nla_get_u32(tb[IWL_TM_ATTR_FIXRATE]); - break; - - default: - IWL_DEBUG_INFO(priv, "Unknown testmode driver command ID\n"); - return -ENOSYS; - } - return status; - -nla_put_failure: - kfree_skb(skb); - return -EMSGSIZE; -} - - -/* - * This function handles the user application commands for uCode trace - * - * It retrieves command ID carried with IWL_TM_ATTR_COMMAND and calls to the - * handlers respectively. - * - * If it's an unknown commdn ID, -ENOSYS is replied; otherwise, the returned - * value of the actual command execution is replied to the user application. - * - * @hw: ieee80211_hw object that represents the device - * @tb: gnl message fields from the user space - */ -static int iwl_testmode_trace(struct ieee80211_hw *hw, struct nlattr **tb) -{ - struct iwl_priv *priv = hw->priv; - struct sk_buff *skb; - int status = 0; - struct device *dev = bus(priv)->dev; - - switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { - case IWL_TM_CMD_APP2DEV_BEGIN_TRACE: - if (priv->testmode_trace.trace_enabled) - return -EBUSY; - - if (!tb[IWL_TM_ATTR_TRACE_SIZE]) - priv->testmode_trace.buff_size = TRACE_BUFF_SIZE_DEF; - else - priv->testmode_trace.buff_size = - nla_get_u32(tb[IWL_TM_ATTR_TRACE_SIZE]); - if (!priv->testmode_trace.buff_size) - return -EINVAL; - if (priv->testmode_trace.buff_size < TRACE_BUFF_SIZE_MIN || - priv->testmode_trace.buff_size > TRACE_BUFF_SIZE_MAX) - return -EINVAL; - - priv->testmode_trace.total_size = - priv->testmode_trace.buff_size + TRACE_BUFF_PADD; - priv->testmode_trace.cpu_addr = - dma_alloc_coherent(dev, - priv->testmode_trace.total_size, - &priv->testmode_trace.dma_addr, - GFP_KERNEL); - if (!priv->testmode_trace.cpu_addr) - return -ENOMEM; - priv->testmode_trace.trace_enabled = true; - priv->testmode_trace.trace_addr = (u8 *)PTR_ALIGN( - priv->testmode_trace.cpu_addr, 0x100); - memset(priv->testmode_trace.trace_addr, 0x03B, - priv->testmode_trace.buff_size); - skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, - sizeof(priv->testmode_trace.dma_addr) + 20); - if (!skb) { - IWL_DEBUG_INFO(priv, - "Error allocating memory\n"); - iwl_trace_cleanup(priv); - return -ENOMEM; - } - NLA_PUT(skb, IWL_TM_ATTR_TRACE_ADDR, - sizeof(priv->testmode_trace.dma_addr), - (u64 *)&priv->testmode_trace.dma_addr); - status = cfg80211_testmode_reply(skb); - if (status < 0) { - IWL_DEBUG_INFO(priv, - "Error sending msg : %d\n", - status); - } - priv->testmode_trace.num_chunks = - DIV_ROUND_UP(priv->testmode_trace.buff_size, - DUMP_CHUNK_SIZE); - break; - - case IWL_TM_CMD_APP2DEV_END_TRACE: - iwl_trace_cleanup(priv); - break; - default: - IWL_DEBUG_INFO(priv, "Unknown testmode mem command ID\n"); - return -ENOSYS; - } - return status; - -nla_put_failure: - kfree_skb(skb); - if (nla_get_u32(tb[IWL_TM_ATTR_COMMAND]) == - IWL_TM_CMD_APP2DEV_BEGIN_TRACE) - iwl_trace_cleanup(priv); - return -EMSGSIZE; -} - -static int iwl_testmode_trace_dump(struct ieee80211_hw *hw, struct nlattr **tb, - struct sk_buff *skb, - struct netlink_callback *cb) -{ - struct iwl_priv *priv = hw->priv; - int idx, length; - - if (priv->testmode_trace.trace_enabled && - priv->testmode_trace.trace_addr) { - idx = cb->args[4]; - if (idx >= priv->testmode_trace.num_chunks) - return -ENOENT; - length = DUMP_CHUNK_SIZE; - if (((idx + 1) == priv->testmode_trace.num_chunks) && - (priv->testmode_trace.buff_size % DUMP_CHUNK_SIZE)) - length = priv->testmode_trace.buff_size % - DUMP_CHUNK_SIZE; - - NLA_PUT(skb, IWL_TM_ATTR_TRACE_DUMP, length, - priv->testmode_trace.trace_addr + - (DUMP_CHUNK_SIZE * idx)); - idx++; - cb->args[4] = idx; - return 0; - } else - return -EFAULT; - - nla_put_failure: - return -ENOBUFS; -} - -/* - * This function handles the user application switch ucode ownership. - * - * It retrieves the mandatory fields IWL_TM_ATTR_UCODE_OWNER and - * decide who the current owner of the uCode - * - * If the current owner is OWNERSHIP_TM, then the only host command - * can deliver to uCode is from testmode, all the other host commands - * will dropped. - * - * default driver is the owner of uCode in normal operational mode - * - * @hw: ieee80211_hw object that represents the device - * @tb: gnl message fields from the user space - */ -static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb) -{ - struct iwl_priv *priv = hw->priv; - u8 owner; - - if (!tb[IWL_TM_ATTR_UCODE_OWNER]) { - IWL_DEBUG_INFO(priv, "Error finding ucode owner\n"); - return -ENOMSG; - } - - owner = nla_get_u8(tb[IWL_TM_ATTR_UCODE_OWNER]); - if ((owner == IWL_OWNERSHIP_DRIVER) || (owner == IWL_OWNERSHIP_TM)) - priv->shrd->ucode_owner = owner; - else { - IWL_DEBUG_INFO(priv, "Invalid owner\n"); - return -EINVAL; - } - return 0; -} - -/* - * This function handles the user application commands for SRAM data dump - * - * It retrieves the mandatory fields IWL_TM_ATTR_SRAM_ADDR and - * IWL_TM_ATTR_SRAM_SIZE to decide the memory area for SRAM data reading - * - * Several error will be retured, -EBUSY if the SRAM data retrieved by - * previous command has not been delivered to userspace, or -ENOMSG if - * the mandatory fields (IWL_TM_ATTR_SRAM_ADDR,IWL_TM_ATTR_SRAM_SIZE) - * are missing, or -ENOMEM if the buffer allocation fails. - * - * Otherwise 0 is replied indicating the success of the SRAM reading. - * - * @hw: ieee80211_hw object that represents the device - * @tb: gnl message fields from the user space - */ -static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb) -{ - struct iwl_priv *priv = hw->priv; - u32 base, ofs, size, maxsize; - - if (priv->testmode_sram.sram_readed) - return -EBUSY; - - if (!tb[IWL_TM_ATTR_SRAM_ADDR]) { - IWL_DEBUG_INFO(priv, "Error finding SRAM offset address\n"); - return -ENOMSG; - } - ofs = nla_get_u32(tb[IWL_TM_ATTR_SRAM_ADDR]); - if (!tb[IWL_TM_ATTR_SRAM_SIZE]) { - IWL_DEBUG_INFO(priv, "Error finding size for SRAM reading\n"); - return -ENOMSG; - } - size = nla_get_u32(tb[IWL_TM_ATTR_SRAM_SIZE]); - switch (priv->ucode_type) { - case IWL_UCODE_REGULAR: - maxsize = trans(priv)->ucode_rt.data.len; - break; - case IWL_UCODE_INIT: - maxsize = trans(priv)->ucode_init.data.len; - break; - case IWL_UCODE_WOWLAN: - maxsize = trans(priv)->ucode_wowlan.data.len; - break; - case IWL_UCODE_NONE: - IWL_DEBUG_INFO(priv, "Error, uCode does not been loaded\n"); - return -ENOSYS; - default: - IWL_DEBUG_INFO(priv, "Error, unsupported uCode type\n"); - return -ENOSYS; - } - if ((ofs + size) > maxsize) { - IWL_DEBUG_INFO(priv, "Invalid offset/size: out of range\n"); - return -EINVAL; - } - priv->testmode_sram.buff_size = (size / 4) * 4; - priv->testmode_sram.buff_addr = - kmalloc(priv->testmode_sram.buff_size, GFP_KERNEL); - if (priv->testmode_sram.buff_addr == NULL) { - IWL_DEBUG_INFO(priv, "Error allocating memory\n"); - return -ENOMEM; - } - base = 0x800000; - _iwl_read_targ_mem_words(bus(priv), base + ofs, - priv->testmode_sram.buff_addr, - priv->testmode_sram.buff_size / 4); - priv->testmode_sram.num_chunks = - DIV_ROUND_UP(priv->testmode_sram.buff_size, DUMP_CHUNK_SIZE); - priv->testmode_sram.sram_readed = true; - return 0; -} - -static int iwl_testmode_sram_dump(struct ieee80211_hw *hw, struct nlattr **tb, - struct sk_buff *skb, - struct netlink_callback *cb) -{ - struct iwl_priv *priv = hw->priv; - int idx, length; - - if (priv->testmode_sram.sram_readed) { - idx = cb->args[4]; - if (idx >= priv->testmode_sram.num_chunks) { - iwl_sram_cleanup(priv); - return -ENOENT; - } - length = DUMP_CHUNK_SIZE; - if (((idx + 1) == priv->testmode_sram.num_chunks) && - (priv->testmode_sram.buff_size % DUMP_CHUNK_SIZE)) - length = priv->testmode_sram.buff_size % - DUMP_CHUNK_SIZE; - - NLA_PUT(skb, IWL_TM_ATTR_SRAM_DUMP, length, - priv->testmode_sram.buff_addr + - (DUMP_CHUNK_SIZE * idx)); - idx++; - cb->args[4] = idx; - return 0; - } else - return -EFAULT; - - nla_put_failure: - return -ENOBUFS; -} - - -/* The testmode gnl message handler that takes the gnl message from the - * user space and parses it per the policy iwl_testmode_gnl_msg_policy, then - * invoke the corresponding handlers. - * - * This function is invoked when there is user space application sending - * gnl message through the testmode tunnel NL80211_CMD_TESTMODE regulated - * by nl80211. - * - * It retrieves the mandatory field, IWL_TM_ATTR_COMMAND, before - * dispatching it to the corresponding handler. - * - * If IWL_TM_ATTR_COMMAND is missing, -ENOMSG is replied to user application; - * -ENOSYS is replied to the user application if the command is unknown; - * Otherwise, the command is dispatched to the respective handler. - * - * @hw: ieee80211_hw object that represents the device - * @data: pointer to user space message - * @len: length in byte of @data - */ -int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) -{ - struct nlattr *tb[IWL_TM_ATTR_MAX]; - struct iwl_priv *priv = hw->priv; - int result; - - result = nla_parse(tb, IWL_TM_ATTR_MAX - 1, data, len, - iwl_testmode_gnl_msg_policy); - if (result != 0) { - IWL_DEBUG_INFO(priv, - "Error parsing the gnl message : %d\n", result); - return result; - } - - /* IWL_TM_ATTR_COMMAND is absolutely mandatory */ - if (!tb[IWL_TM_ATTR_COMMAND]) { - IWL_DEBUG_INFO(priv, "Error finding testmode command type\n"); - return -ENOMSG; - } - /* in case multiple accesses to the device happens */ - mutex_lock(&priv->shrd->mutex); - - switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { - case IWL_TM_CMD_APP2DEV_UCODE: - IWL_DEBUG_INFO(priv, "testmode cmd to uCode\n"); - result = iwl_testmode_ucode(hw, tb); - break; - case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32: - case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32: - case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8: - case IWL_TM_CMD_APP2DEV_INDIRECT_REG_READ32: - case IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32: - IWL_DEBUG_INFO(priv, "testmode cmd to register\n"); - result = iwl_testmode_reg(hw, tb); - break; - case IWL_TM_CMD_APP2DEV_GET_DEVICENAME: - case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW: - case IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB: - case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW: - case IWL_TM_CMD_APP2DEV_GET_EEPROM: - case IWL_TM_CMD_APP2DEV_FIXRATE_REQ: - case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: - IWL_DEBUG_INFO(priv, "testmode cmd to driver\n"); - result = iwl_testmode_driver(hw, tb); - break; - - case IWL_TM_CMD_APP2DEV_BEGIN_TRACE: - case IWL_TM_CMD_APP2DEV_END_TRACE: - case IWL_TM_CMD_APP2DEV_READ_TRACE: - IWL_DEBUG_INFO(priv, "testmode uCode trace cmd to driver\n"); - result = iwl_testmode_trace(hw, tb); - break; - - case IWL_TM_CMD_APP2DEV_OWNERSHIP: - IWL_DEBUG_INFO(priv, "testmode change uCode ownership\n"); - result = iwl_testmode_ownership(hw, tb); - break; - - case IWL_TM_CMD_APP2DEV_READ_SRAM: - IWL_DEBUG_INFO(priv, "testmode sram read cmd to driver\n"); - result = iwl_testmode_sram(hw, tb); - break; - - default: - IWL_DEBUG_INFO(priv, "Unknown testmode command\n"); - result = -ENOSYS; - break; - } - - mutex_unlock(&priv->shrd->mutex); - return result; -} - -int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb, - struct netlink_callback *cb, - void *data, int len) -{ - struct nlattr *tb[IWL_TM_ATTR_MAX]; - struct iwl_priv *priv = hw->priv; - int result; - u32 cmd; - - if (cb->args[3]) { - /* offset by 1 since commands start at 0 */ - cmd = cb->args[3] - 1; - } else { - result = nla_parse(tb, IWL_TM_ATTR_MAX - 1, data, len, - iwl_testmode_gnl_msg_policy); - if (result) { - IWL_DEBUG_INFO(priv, - "Error parsing the gnl message : %d\n", result); - return result; - } - - /* IWL_TM_ATTR_COMMAND is absolutely mandatory */ - if (!tb[IWL_TM_ATTR_COMMAND]) { - IWL_DEBUG_INFO(priv, - "Error finding testmode command type\n"); - return -ENOMSG; - } - cmd = nla_get_u32(tb[IWL_TM_ATTR_COMMAND]); - cb->args[3] = cmd + 1; - } - - /* in case multiple accesses to the device happens */ - mutex_lock(&priv->shrd->mutex); - switch (cmd) { - case IWL_TM_CMD_APP2DEV_READ_TRACE: - IWL_DEBUG_INFO(priv, "uCode trace cmd to driver\n"); - result = iwl_testmode_trace_dump(hw, tb, skb, cb); - break; - case IWL_TM_CMD_APP2DEV_DUMP_SRAM: - IWL_DEBUG_INFO(priv, "testmode sram dump cmd to driver\n"); - result = iwl_testmode_sram_dump(hw, tb, skb, cb); - break; - default: - result = -EINVAL; - break; - } - - mutex_unlock(&priv->shrd->mutex); - return result; -} diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c new file mode 100644 index 000000000000..3c9762628760 --- /dev/null +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -0,0 +1,925 @@ +/****************************************************************************** + * + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2010 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, + * USA + * + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + * BSD LICENSE + * + * Copyright(c) 2010 - 2011 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + *****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "iwl-dev.h" +#include "iwl-core.h" +#include "iwl-debug.h" +#include "iwl-io.h" +#include "iwl-agn.h" +#include "iwl-testmode.h" +#include "iwl-trans.h" + +/* The TLVs used in the gnl message policy between the kernel module and + * user space application. iwl_testmode_gnl_msg_policy is to be carried + * through the NL80211_CMD_TESTMODE channel regulated by nl80211. + * See iwl-testmode.h + */ +static +struct nla_policy iwl_testmode_gnl_msg_policy[IWL_TM_ATTR_MAX] = { + [IWL_TM_ATTR_COMMAND] = { .type = NLA_U32, }, + + [IWL_TM_ATTR_UCODE_CMD_ID] = { .type = NLA_U8, }, + [IWL_TM_ATTR_UCODE_CMD_DATA] = { .type = NLA_UNSPEC, }, + + [IWL_TM_ATTR_REG_OFFSET] = { .type = NLA_U32, }, + [IWL_TM_ATTR_REG_VALUE8] = { .type = NLA_U8, }, + [IWL_TM_ATTR_REG_VALUE32] = { .type = NLA_U32, }, + + [IWL_TM_ATTR_SYNC_RSP] = { .type = NLA_UNSPEC, }, + [IWL_TM_ATTR_UCODE_RX_PKT] = { .type = NLA_UNSPEC, }, + + [IWL_TM_ATTR_EEPROM] = { .type = NLA_UNSPEC, }, + + [IWL_TM_ATTR_TRACE_ADDR] = { .type = NLA_UNSPEC, }, + [IWL_TM_ATTR_TRACE_DUMP] = { .type = NLA_UNSPEC, }, + [IWL_TM_ATTR_TRACE_SIZE] = { .type = NLA_U32, }, + + [IWL_TM_ATTR_FIXRATE] = { .type = NLA_U32, }, + + [IWL_TM_ATTR_UCODE_OWNER] = { .type = NLA_U8, }, + + [IWL_TM_ATTR_SRAM_ADDR] = { .type = NLA_U32, }, + [IWL_TM_ATTR_SRAM_SIZE] = { .type = NLA_U32, }, + [IWL_TM_ATTR_SRAM_DUMP] = { .type = NLA_UNSPEC, }, +}; + +/* + * See the struct iwl_rx_packet in iwl-commands.h for the format of the + * received events from the device + */ +static inline int get_event_length(struct iwl_rx_mem_buffer *rxb) +{ + struct iwl_rx_packet *pkt = rxb_addr(rxb); + if (pkt) + return le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; + else + return 0; +} + + +/* + * This function multicasts the spontaneous messages from the device to the + * user space. It is invoked whenever there is a received messages + * from the device. This function is called within the ISR of the rx handlers + * in iwlagn driver. + * + * The parsing of the message content is left to the user space application, + * The message content is treated as unattacked raw data and is encapsulated + * with IWL_TM_ATTR_UCODE_RX_PKT multicasting to the user space. + * + * @priv: the instance of iwlwifi device + * @rxb: pointer to rx data content received by the ISR + * + * See the message policies and TLVs in iwl_testmode_gnl_msg_policy[]. + * For the messages multicasting to the user application, the mandatory + * TLV fields are : + * IWL_TM_ATTR_COMMAND must be IWL_TM_CMD_DEV2APP_UCODE_RX_PKT + * IWL_TM_ATTR_UCODE_RX_PKT for carrying the message content + */ + +static void iwl_testmode_ucode_rx_pkt(struct iwl_priv *priv, + struct iwl_rx_mem_buffer *rxb) +{ + struct ieee80211_hw *hw = priv->hw; + struct sk_buff *skb; + void *data; + int length; + + data = (void *)rxb_addr(rxb); + length = get_event_length(rxb); + + if (!data || length == 0) + return; + + skb = cfg80211_testmode_alloc_event_skb(hw->wiphy, 20 + length, + GFP_ATOMIC); + if (skb == NULL) { + IWL_DEBUG_INFO(priv, + "Run out of memory for messages to user space ?\n"); + return; + } + NLA_PUT_U32(skb, IWL_TM_ATTR_COMMAND, IWL_TM_CMD_DEV2APP_UCODE_RX_PKT); + NLA_PUT(skb, IWL_TM_ATTR_UCODE_RX_PKT, length, data); + cfg80211_testmode_event(skb, GFP_ATOMIC); + return; + +nla_put_failure: + kfree_skb(skb); + IWL_DEBUG_INFO(priv, "Ouch, overran buffer, check allocation!\n"); +} + +void iwl_testmode_init(struct iwl_priv *priv) +{ + priv->pre_rx_handler = iwl_testmode_ucode_rx_pkt; + priv->testmode_trace.trace_enabled = false; + priv->testmode_sram.sram_readed = false; +} + +static void iwl_sram_cleanup(struct iwl_priv *priv) +{ + if (priv->testmode_sram.sram_readed) { + kfree(priv->testmode_sram.buff_addr); + priv->testmode_sram.buff_addr = NULL; + priv->testmode_sram.buff_size = 0; + priv->testmode_sram.num_chunks = 0; + priv->testmode_sram.sram_readed = false; + } +} + +static void iwl_trace_cleanup(struct iwl_priv *priv) +{ + if (priv->testmode_trace.trace_enabled) { + if (priv->testmode_trace.cpu_addr && + priv->testmode_trace.dma_addr) + dma_free_coherent(bus(priv)->dev, + priv->testmode_trace.total_size, + priv->testmode_trace.cpu_addr, + priv->testmode_trace.dma_addr); + priv->testmode_trace.trace_enabled = false; + priv->testmode_trace.cpu_addr = NULL; + priv->testmode_trace.trace_addr = NULL; + priv->testmode_trace.dma_addr = 0; + priv->testmode_trace.buff_size = 0; + priv->testmode_trace.total_size = 0; + } +} + + +void iwl_testmode_cleanup(struct iwl_priv *priv) +{ + iwl_trace_cleanup(priv); + iwl_sram_cleanup(priv); +} + +/* + * This function handles the user application commands to the ucode. + * + * It retrieves the mandatory fields IWL_TM_ATTR_UCODE_CMD_ID and + * IWL_TM_ATTR_UCODE_CMD_DATA and calls to the handler to send the + * host command to the ucode. + * + * If any mandatory field is missing, -ENOMSG is replied to the user space + * application; otherwise, the actual execution result of the host command to + * ucode is replied. + * + * @hw: ieee80211_hw object that represents the device + * @tb: gnl message fields from the user space + */ +static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb) +{ + struct iwl_priv *priv = hw->priv; + struct iwl_host_cmd cmd; + + memset(&cmd, 0, sizeof(struct iwl_host_cmd)); + + if (!tb[IWL_TM_ATTR_UCODE_CMD_ID] || + !tb[IWL_TM_ATTR_UCODE_CMD_DATA]) { + IWL_DEBUG_INFO(priv, + "Error finding ucode command mandatory fields\n"); + return -ENOMSG; + } + + cmd.flags = CMD_ON_DEMAND; + cmd.id = nla_get_u8(tb[IWL_TM_ATTR_UCODE_CMD_ID]); + cmd.data[0] = nla_data(tb[IWL_TM_ATTR_UCODE_CMD_DATA]); + cmd.len[0] = nla_len(tb[IWL_TM_ATTR_UCODE_CMD_DATA]); + cmd.dataflags[0] = IWL_HCMD_DFL_NOCOPY; + IWL_INFO(priv, "testmode ucode command ID 0x%x, flags 0x%x," + " len %d\n", cmd.id, cmd.flags, cmd.len[0]); + /* ok, let's submit the command to ucode */ + return iwl_trans_send_cmd(trans(priv), &cmd); +} + + +/* + * This function handles the user application commands for register access. + * + * It retrieves command ID carried with IWL_TM_ATTR_COMMAND and calls to the + * handlers respectively. + * + * If it's an unknown commdn ID, -ENOSYS is returned; or -ENOMSG if the + * mandatory fields(IWL_TM_ATTR_REG_OFFSET,IWL_TM_ATTR_REG_VALUE32, + * IWL_TM_ATTR_REG_VALUE8) are missing; Otherwise 0 is replied indicating + * the success of the command execution. + * + * If IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_REG_READ32, the register read + * value is returned with IWL_TM_ATTR_REG_VALUE32. + * + * @hw: ieee80211_hw object that represents the device + * @tb: gnl message fields from the user space + */ +static int iwl_testmode_reg(struct ieee80211_hw *hw, struct nlattr **tb) +{ + struct iwl_priv *priv = hw->priv; + u32 ofs, val32; + u8 val8; + struct sk_buff *skb; + int status = 0; + + if (!tb[IWL_TM_ATTR_REG_OFFSET]) { + IWL_DEBUG_INFO(priv, "Error finding register offset\n"); + return -ENOMSG; + } + ofs = nla_get_u32(tb[IWL_TM_ATTR_REG_OFFSET]); + IWL_INFO(priv, "testmode register access command offset 0x%x\n", ofs); + + switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { + case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32: + val32 = iwl_read32(bus(priv), ofs); + IWL_INFO(priv, "32bit value to read 0x%x\n", val32); + + skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); + if (!skb) { + IWL_DEBUG_INFO(priv, "Error allocating memory\n"); + return -ENOMEM; + } + NLA_PUT_U32(skb, IWL_TM_ATTR_REG_VALUE32, val32); + status = cfg80211_testmode_reply(skb); + if (status < 0) + IWL_DEBUG_INFO(priv, + "Error sending msg : %d\n", status); + break; + case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32: + if (!tb[IWL_TM_ATTR_REG_VALUE32]) { + IWL_DEBUG_INFO(priv, + "Error finding value to write\n"); + return -ENOMSG; + } else { + val32 = nla_get_u32(tb[IWL_TM_ATTR_REG_VALUE32]); + IWL_INFO(priv, "32bit value to write 0x%x\n", val32); + iwl_write32(bus(priv), ofs, val32); + } + break; + case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8: + if (!tb[IWL_TM_ATTR_REG_VALUE8]) { + IWL_DEBUG_INFO(priv, "Error finding value to write\n"); + return -ENOMSG; + } else { + val8 = nla_get_u8(tb[IWL_TM_ATTR_REG_VALUE8]); + IWL_INFO(priv, "8bit value to write 0x%x\n", val8); + iwl_write8(bus(priv), ofs, val8); + } + break; + case IWL_TM_CMD_APP2DEV_INDIRECT_REG_READ32: + val32 = iwl_read_prph(bus(priv), ofs); + IWL_INFO(priv, "32bit value to read 0x%x\n", val32); + + skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); + if (!skb) { + IWL_DEBUG_INFO(priv, "Error allocating memory\n"); + return -ENOMEM; + } + NLA_PUT_U32(skb, IWL_TM_ATTR_REG_VALUE32, val32); + status = cfg80211_testmode_reply(skb); + if (status < 0) + IWL_DEBUG_INFO(priv, + "Error sending msg : %d\n", status); + break; + case IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32: + if (!tb[IWL_TM_ATTR_REG_VALUE32]) { + IWL_DEBUG_INFO(priv, + "Error finding value to write\n"); + return -ENOMSG; + } else { + val32 = nla_get_u32(tb[IWL_TM_ATTR_REG_VALUE32]); + IWL_INFO(priv, "32bit value to write 0x%x\n", val32); + iwl_write_prph(bus(priv), ofs, val32); + } + break; + default: + IWL_DEBUG_INFO(priv, "Unknown testmode register command ID\n"); + return -ENOSYS; + } + + return status; + +nla_put_failure: + kfree_skb(skb); + return -EMSGSIZE; +} + + +static int iwl_testmode_cfg_init_calib(struct iwl_priv *priv) +{ + struct iwl_notification_wait calib_wait; + int ret; + + iwlagn_init_notification_wait(priv, &calib_wait, + CALIBRATION_COMPLETE_NOTIFICATION, + NULL, NULL); + ret = iwlagn_init_alive_start(priv); + if (ret) { + IWL_DEBUG_INFO(priv, + "Error configuring init calibration: %d\n", ret); + goto cfg_init_calib_error; + } + + ret = iwlagn_wait_notification(priv, &calib_wait, 2 * HZ); + if (ret) + IWL_DEBUG_INFO(priv, "Error detecting" + " CALIBRATION_COMPLETE_NOTIFICATION: %d\n", ret); + return ret; + +cfg_init_calib_error: + iwlagn_remove_notification(priv, &calib_wait); + return ret; +} + +/* + * This function handles the user application commands for driver. + * + * It retrieves command ID carried with IWL_TM_ATTR_COMMAND and calls to the + * handlers respectively. + * + * If it's an unknown commdn ID, -ENOSYS is replied; otherwise, the returned + * value of the actual command execution is replied to the user application. + * + * If there's any message responding to the user space, IWL_TM_ATTR_SYNC_RSP + * is used for carry the message while IWL_TM_ATTR_COMMAND must set to + * IWL_TM_CMD_DEV2APP_SYNC_RSP. + * + * @hw: ieee80211_hw object that represents the device + * @tb: gnl message fields from the user space + */ +static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) +{ + struct iwl_priv *priv = hw->priv; + struct sk_buff *skb; + unsigned char *rsp_data_ptr = NULL; + int status = 0, rsp_data_len = 0; + + switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { + case IWL_TM_CMD_APP2DEV_GET_DEVICENAME: + rsp_data_ptr = (unsigned char *)priv->cfg->name; + rsp_data_len = strlen(priv->cfg->name); + skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, + rsp_data_len + 20); + if (!skb) { + IWL_DEBUG_INFO(priv, + "Error allocating memory\n"); + return -ENOMEM; + } + NLA_PUT_U32(skb, IWL_TM_ATTR_COMMAND, + IWL_TM_CMD_DEV2APP_SYNC_RSP); + NLA_PUT(skb, IWL_TM_ATTR_SYNC_RSP, + rsp_data_len, rsp_data_ptr); + status = cfg80211_testmode_reply(skb); + if (status < 0) + IWL_DEBUG_INFO(priv, "Error sending msg : %d\n", + status); + break; + + case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW: + status = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_INIT); + if (status) + IWL_DEBUG_INFO(priv, + "Error loading init ucode: %d\n", status); + break; + + case IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB: + iwl_testmode_cfg_init_calib(priv); + iwl_trans_stop_device(trans(priv)); + break; + + case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW: + status = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_REGULAR); + if (status) { + IWL_DEBUG_INFO(priv, + "Error loading runtime ucode: %d\n", status); + break; + } + status = iwl_alive_start(priv); + if (status) + IWL_DEBUG_INFO(priv, + "Error starting the device: %d\n", status); + break; + + case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: + iwl_scan_cancel_timeout(priv, 200); + iwl_trans_stop_device(trans(priv)); + status = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_WOWLAN); + if (status) { + IWL_DEBUG_INFO(priv, + "Error loading WOWLAN ucode: %d\n", status); + break; + } + status = iwl_alive_start(priv); + if (status) + IWL_DEBUG_INFO(priv, + "Error starting the device: %d\n", status); + break; + + case IWL_TM_CMD_APP2DEV_GET_EEPROM: + if (priv->eeprom) { + skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, + priv->cfg->base_params->eeprom_size + 20); + if (!skb) { + IWL_DEBUG_INFO(priv, + "Error allocating memory\n"); + return -ENOMEM; + } + NLA_PUT_U32(skb, IWL_TM_ATTR_COMMAND, + IWL_TM_CMD_DEV2APP_EEPROM_RSP); + NLA_PUT(skb, IWL_TM_ATTR_EEPROM, + priv->cfg->base_params->eeprom_size, + priv->eeprom); + status = cfg80211_testmode_reply(skb); + if (status < 0) + IWL_DEBUG_INFO(priv, + "Error sending msg : %d\n", + status); + } else + return -EFAULT; + break; + + case IWL_TM_CMD_APP2DEV_FIXRATE_REQ: + if (!tb[IWL_TM_ATTR_FIXRATE]) { + IWL_DEBUG_INFO(priv, + "Error finding fixrate setting\n"); + return -ENOMSG; + } + priv->tm_fixed_rate = nla_get_u32(tb[IWL_TM_ATTR_FIXRATE]); + break; + + default: + IWL_DEBUG_INFO(priv, "Unknown testmode driver command ID\n"); + return -ENOSYS; + } + return status; + +nla_put_failure: + kfree_skb(skb); + return -EMSGSIZE; +} + + +/* + * This function handles the user application commands for uCode trace + * + * It retrieves command ID carried with IWL_TM_ATTR_COMMAND and calls to the + * handlers respectively. + * + * If it's an unknown commdn ID, -ENOSYS is replied; otherwise, the returned + * value of the actual command execution is replied to the user application. + * + * @hw: ieee80211_hw object that represents the device + * @tb: gnl message fields from the user space + */ +static int iwl_testmode_trace(struct ieee80211_hw *hw, struct nlattr **tb) +{ + struct iwl_priv *priv = hw->priv; + struct sk_buff *skb; + int status = 0; + struct device *dev = bus(priv)->dev; + + switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { + case IWL_TM_CMD_APP2DEV_BEGIN_TRACE: + if (priv->testmode_trace.trace_enabled) + return -EBUSY; + + if (!tb[IWL_TM_ATTR_TRACE_SIZE]) + priv->testmode_trace.buff_size = TRACE_BUFF_SIZE_DEF; + else + priv->testmode_trace.buff_size = + nla_get_u32(tb[IWL_TM_ATTR_TRACE_SIZE]); + if (!priv->testmode_trace.buff_size) + return -EINVAL; + if (priv->testmode_trace.buff_size < TRACE_BUFF_SIZE_MIN || + priv->testmode_trace.buff_size > TRACE_BUFF_SIZE_MAX) + return -EINVAL; + + priv->testmode_trace.total_size = + priv->testmode_trace.buff_size + TRACE_BUFF_PADD; + priv->testmode_trace.cpu_addr = + dma_alloc_coherent(dev, + priv->testmode_trace.total_size, + &priv->testmode_trace.dma_addr, + GFP_KERNEL); + if (!priv->testmode_trace.cpu_addr) + return -ENOMEM; + priv->testmode_trace.trace_enabled = true; + priv->testmode_trace.trace_addr = (u8 *)PTR_ALIGN( + priv->testmode_trace.cpu_addr, 0x100); + memset(priv->testmode_trace.trace_addr, 0x03B, + priv->testmode_trace.buff_size); + skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, + sizeof(priv->testmode_trace.dma_addr) + 20); + if (!skb) { + IWL_DEBUG_INFO(priv, + "Error allocating memory\n"); + iwl_trace_cleanup(priv); + return -ENOMEM; + } + NLA_PUT(skb, IWL_TM_ATTR_TRACE_ADDR, + sizeof(priv->testmode_trace.dma_addr), + (u64 *)&priv->testmode_trace.dma_addr); + status = cfg80211_testmode_reply(skb); + if (status < 0) { + IWL_DEBUG_INFO(priv, + "Error sending msg : %d\n", + status); + } + priv->testmode_trace.num_chunks = + DIV_ROUND_UP(priv->testmode_trace.buff_size, + DUMP_CHUNK_SIZE); + break; + + case IWL_TM_CMD_APP2DEV_END_TRACE: + iwl_trace_cleanup(priv); + break; + default: + IWL_DEBUG_INFO(priv, "Unknown testmode mem command ID\n"); + return -ENOSYS; + } + return status; + +nla_put_failure: + kfree_skb(skb); + if (nla_get_u32(tb[IWL_TM_ATTR_COMMAND]) == + IWL_TM_CMD_APP2DEV_BEGIN_TRACE) + iwl_trace_cleanup(priv); + return -EMSGSIZE; +} + +static int iwl_testmode_trace_dump(struct ieee80211_hw *hw, struct nlattr **tb, + struct sk_buff *skb, + struct netlink_callback *cb) +{ + struct iwl_priv *priv = hw->priv; + int idx, length; + + if (priv->testmode_trace.trace_enabled && + priv->testmode_trace.trace_addr) { + idx = cb->args[4]; + if (idx >= priv->testmode_trace.num_chunks) + return -ENOENT; + length = DUMP_CHUNK_SIZE; + if (((idx + 1) == priv->testmode_trace.num_chunks) && + (priv->testmode_trace.buff_size % DUMP_CHUNK_SIZE)) + length = priv->testmode_trace.buff_size % + DUMP_CHUNK_SIZE; + + NLA_PUT(skb, IWL_TM_ATTR_TRACE_DUMP, length, + priv->testmode_trace.trace_addr + + (DUMP_CHUNK_SIZE * idx)); + idx++; + cb->args[4] = idx; + return 0; + } else + return -EFAULT; + + nla_put_failure: + return -ENOBUFS; +} + +/* + * This function handles the user application switch ucode ownership. + * + * It retrieves the mandatory fields IWL_TM_ATTR_UCODE_OWNER and + * decide who the current owner of the uCode + * + * If the current owner is OWNERSHIP_TM, then the only host command + * can deliver to uCode is from testmode, all the other host commands + * will dropped. + * + * default driver is the owner of uCode in normal operational mode + * + * @hw: ieee80211_hw object that represents the device + * @tb: gnl message fields from the user space + */ +static int iwl_testmode_ownership(struct ieee80211_hw *hw, struct nlattr **tb) +{ + struct iwl_priv *priv = hw->priv; + u8 owner; + + if (!tb[IWL_TM_ATTR_UCODE_OWNER]) { + IWL_DEBUG_INFO(priv, "Error finding ucode owner\n"); + return -ENOMSG; + } + + owner = nla_get_u8(tb[IWL_TM_ATTR_UCODE_OWNER]); + if ((owner == IWL_OWNERSHIP_DRIVER) || (owner == IWL_OWNERSHIP_TM)) + priv->shrd->ucode_owner = owner; + else { + IWL_DEBUG_INFO(priv, "Invalid owner\n"); + return -EINVAL; + } + return 0; +} + +/* + * This function handles the user application commands for SRAM data dump + * + * It retrieves the mandatory fields IWL_TM_ATTR_SRAM_ADDR and + * IWL_TM_ATTR_SRAM_SIZE to decide the memory area for SRAM data reading + * + * Several error will be retured, -EBUSY if the SRAM data retrieved by + * previous command has not been delivered to userspace, or -ENOMSG if + * the mandatory fields (IWL_TM_ATTR_SRAM_ADDR,IWL_TM_ATTR_SRAM_SIZE) + * are missing, or -ENOMEM if the buffer allocation fails. + * + * Otherwise 0 is replied indicating the success of the SRAM reading. + * + * @hw: ieee80211_hw object that represents the device + * @tb: gnl message fields from the user space + */ +static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb) +{ + struct iwl_priv *priv = hw->priv; + u32 base, ofs, size, maxsize; + + if (priv->testmode_sram.sram_readed) + return -EBUSY; + + if (!tb[IWL_TM_ATTR_SRAM_ADDR]) { + IWL_DEBUG_INFO(priv, "Error finding SRAM offset address\n"); + return -ENOMSG; + } + ofs = nla_get_u32(tb[IWL_TM_ATTR_SRAM_ADDR]); + if (!tb[IWL_TM_ATTR_SRAM_SIZE]) { + IWL_DEBUG_INFO(priv, "Error finding size for SRAM reading\n"); + return -ENOMSG; + } + size = nla_get_u32(tb[IWL_TM_ATTR_SRAM_SIZE]); + switch (priv->ucode_type) { + case IWL_UCODE_REGULAR: + maxsize = trans(priv)->ucode_rt.data.len; + break; + case IWL_UCODE_INIT: + maxsize = trans(priv)->ucode_init.data.len; + break; + case IWL_UCODE_WOWLAN: + maxsize = trans(priv)->ucode_wowlan.data.len; + break; + case IWL_UCODE_NONE: + IWL_DEBUG_INFO(priv, "Error, uCode does not been loaded\n"); + return -ENOSYS; + default: + IWL_DEBUG_INFO(priv, "Error, unsupported uCode type\n"); + return -ENOSYS; + } + if ((ofs + size) > maxsize) { + IWL_DEBUG_INFO(priv, "Invalid offset/size: out of range\n"); + return -EINVAL; + } + priv->testmode_sram.buff_size = (size / 4) * 4; + priv->testmode_sram.buff_addr = + kmalloc(priv->testmode_sram.buff_size, GFP_KERNEL); + if (priv->testmode_sram.buff_addr == NULL) { + IWL_DEBUG_INFO(priv, "Error allocating memory\n"); + return -ENOMEM; + } + base = 0x800000; + _iwl_read_targ_mem_words(bus(priv), base + ofs, + priv->testmode_sram.buff_addr, + priv->testmode_sram.buff_size / 4); + priv->testmode_sram.num_chunks = + DIV_ROUND_UP(priv->testmode_sram.buff_size, DUMP_CHUNK_SIZE); + priv->testmode_sram.sram_readed = true; + return 0; +} + +static int iwl_testmode_sram_dump(struct ieee80211_hw *hw, struct nlattr **tb, + struct sk_buff *skb, + struct netlink_callback *cb) +{ + struct iwl_priv *priv = hw->priv; + int idx, length; + + if (priv->testmode_sram.sram_readed) { + idx = cb->args[4]; + if (idx >= priv->testmode_sram.num_chunks) { + iwl_sram_cleanup(priv); + return -ENOENT; + } + length = DUMP_CHUNK_SIZE; + if (((idx + 1) == priv->testmode_sram.num_chunks) && + (priv->testmode_sram.buff_size % DUMP_CHUNK_SIZE)) + length = priv->testmode_sram.buff_size % + DUMP_CHUNK_SIZE; + + NLA_PUT(skb, IWL_TM_ATTR_SRAM_DUMP, length, + priv->testmode_sram.buff_addr + + (DUMP_CHUNK_SIZE * idx)); + idx++; + cb->args[4] = idx; + return 0; + } else + return -EFAULT; + + nla_put_failure: + return -ENOBUFS; +} + + +/* The testmode gnl message handler that takes the gnl message from the + * user space and parses it per the policy iwl_testmode_gnl_msg_policy, then + * invoke the corresponding handlers. + * + * This function is invoked when there is user space application sending + * gnl message through the testmode tunnel NL80211_CMD_TESTMODE regulated + * by nl80211. + * + * It retrieves the mandatory field, IWL_TM_ATTR_COMMAND, before + * dispatching it to the corresponding handler. + * + * If IWL_TM_ATTR_COMMAND is missing, -ENOMSG is replied to user application; + * -ENOSYS is replied to the user application if the command is unknown; + * Otherwise, the command is dispatched to the respective handler. + * + * @hw: ieee80211_hw object that represents the device + * @data: pointer to user space message + * @len: length in byte of @data + */ +int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) +{ + struct nlattr *tb[IWL_TM_ATTR_MAX]; + struct iwl_priv *priv = hw->priv; + int result; + + result = nla_parse(tb, IWL_TM_ATTR_MAX - 1, data, len, + iwl_testmode_gnl_msg_policy); + if (result != 0) { + IWL_DEBUG_INFO(priv, + "Error parsing the gnl message : %d\n", result); + return result; + } + + /* IWL_TM_ATTR_COMMAND is absolutely mandatory */ + if (!tb[IWL_TM_ATTR_COMMAND]) { + IWL_DEBUG_INFO(priv, "Error finding testmode command type\n"); + return -ENOMSG; + } + /* in case multiple accesses to the device happens */ + mutex_lock(&priv->shrd->mutex); + + switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { + case IWL_TM_CMD_APP2DEV_UCODE: + IWL_DEBUG_INFO(priv, "testmode cmd to uCode\n"); + result = iwl_testmode_ucode(hw, tb); + break; + case IWL_TM_CMD_APP2DEV_DIRECT_REG_READ32: + case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE32: + case IWL_TM_CMD_APP2DEV_DIRECT_REG_WRITE8: + case IWL_TM_CMD_APP2DEV_INDIRECT_REG_READ32: + case IWL_TM_CMD_APP2DEV_INDIRECT_REG_WRITE32: + IWL_DEBUG_INFO(priv, "testmode cmd to register\n"); + result = iwl_testmode_reg(hw, tb); + break; + case IWL_TM_CMD_APP2DEV_GET_DEVICENAME: + case IWL_TM_CMD_APP2DEV_LOAD_INIT_FW: + case IWL_TM_CMD_APP2DEV_CFG_INIT_CALIB: + case IWL_TM_CMD_APP2DEV_LOAD_RUNTIME_FW: + case IWL_TM_CMD_APP2DEV_GET_EEPROM: + case IWL_TM_CMD_APP2DEV_FIXRATE_REQ: + case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: + IWL_DEBUG_INFO(priv, "testmode cmd to driver\n"); + result = iwl_testmode_driver(hw, tb); + break; + + case IWL_TM_CMD_APP2DEV_BEGIN_TRACE: + case IWL_TM_CMD_APP2DEV_END_TRACE: + case IWL_TM_CMD_APP2DEV_READ_TRACE: + IWL_DEBUG_INFO(priv, "testmode uCode trace cmd to driver\n"); + result = iwl_testmode_trace(hw, tb); + break; + + case IWL_TM_CMD_APP2DEV_OWNERSHIP: + IWL_DEBUG_INFO(priv, "testmode change uCode ownership\n"); + result = iwl_testmode_ownership(hw, tb); + break; + + case IWL_TM_CMD_APP2DEV_READ_SRAM: + IWL_DEBUG_INFO(priv, "testmode sram read cmd to driver\n"); + result = iwl_testmode_sram(hw, tb); + break; + + default: + IWL_DEBUG_INFO(priv, "Unknown testmode command\n"); + result = -ENOSYS; + break; + } + + mutex_unlock(&priv->shrd->mutex); + return result; +} + +int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, struct sk_buff *skb, + struct netlink_callback *cb, + void *data, int len) +{ + struct nlattr *tb[IWL_TM_ATTR_MAX]; + struct iwl_priv *priv = hw->priv; + int result; + u32 cmd; + + if (cb->args[3]) { + /* offset by 1 since commands start at 0 */ + cmd = cb->args[3] - 1; + } else { + result = nla_parse(tb, IWL_TM_ATTR_MAX - 1, data, len, + iwl_testmode_gnl_msg_policy); + if (result) { + IWL_DEBUG_INFO(priv, + "Error parsing the gnl message : %d\n", result); + return result; + } + + /* IWL_TM_ATTR_COMMAND is absolutely mandatory */ + if (!tb[IWL_TM_ATTR_COMMAND]) { + IWL_DEBUG_INFO(priv, + "Error finding testmode command type\n"); + return -ENOMSG; + } + cmd = nla_get_u32(tb[IWL_TM_ATTR_COMMAND]); + cb->args[3] = cmd + 1; + } + + /* in case multiple accesses to the device happens */ + mutex_lock(&priv->shrd->mutex); + switch (cmd) { + case IWL_TM_CMD_APP2DEV_READ_TRACE: + IWL_DEBUG_INFO(priv, "uCode trace cmd to driver\n"); + result = iwl_testmode_trace_dump(hw, tb, skb, cb); + break; + case IWL_TM_CMD_APP2DEV_DUMP_SRAM: + IWL_DEBUG_INFO(priv, "testmode sram dump cmd to driver\n"); + result = iwl_testmode_sram_dump(hw, tb, skb, cb); + break; + default: + result = -EINVAL; + break; + } + + mutex_unlock(&priv->shrd->mutex); + return result; +} -- cgit v1.2.3 From 481f564ac72b2f6c77ba80e7a31932365bd21a35 Mon Sep 17 00:00:00 2001 From: Don Fry Date: Fri, 2 Dec 2011 08:48:37 -0800 Subject: iwlwifi: rename iwl-agn-ucode as iwl-ucode iwl-agn-ucode is generic ucode operations, not limited just to iwlagn. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/Makefile | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-ucode.c | 688 --------------------------- drivers/net/wireless/iwlwifi/iwl-ucode.c | 688 +++++++++++++++++++++++++++ 3 files changed, 689 insertions(+), 689 deletions(-) delete mode 100644 drivers/net/wireless/iwlwifi/iwl-agn-ucode.c create mode 100644 drivers/net/wireless/iwlwifi/iwl-ucode.c (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile index 5a052a5e4fb6..86344cefd32f 100644 --- a/drivers/net/wireless/iwlwifi/Makefile +++ b/drivers/net/wireless/iwlwifi/Makefile @@ -1,7 +1,7 @@ # WIFI obj-$(CONFIG_IWLWIFI) += iwlwifi.o iwlwifi-objs := iwl-agn.o iwl-agn-rs.o iwl-mac80211.o -iwlwifi-objs += iwl-agn-ucode.o iwl-agn-tx.o +iwlwifi-objs += iwl-ucode.o iwl-agn-tx.o iwlwifi-objs += iwl-agn-lib.o iwl-agn-calib.o iwl-io.o iwlwifi-objs += iwl-agn-tt.o iwl-agn-sta.o iwl-agn-rx.o diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c deleted file mode 100644 index 76949106dafc..000000000000 --- a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c +++ /dev/null @@ -1,688 +0,0 @@ -/****************************************************************************** - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, - * USA - * - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * Contact Information: - * Intel Linux Wireless - * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 - * - *****************************************************************************/ - -#include -#include -#include -#include -#include - -#include "iwl-dev.h" -#include "iwl-core.h" -#include "iwl-io.h" -#include "iwl-agn-hw.h" -#include "iwl-agn.h" -#include "iwl-agn-calib.h" -#include "iwl-trans.h" -#include "iwl-fh.h" - -static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = { - {COEX_CU_UNASSOC_IDLE_RP, COEX_CU_UNASSOC_IDLE_WP, - 0, COEX_UNASSOC_IDLE_FLAGS}, - {COEX_CU_UNASSOC_MANUAL_SCAN_RP, COEX_CU_UNASSOC_MANUAL_SCAN_WP, - 0, COEX_UNASSOC_MANUAL_SCAN_FLAGS}, - {COEX_CU_UNASSOC_AUTO_SCAN_RP, COEX_CU_UNASSOC_AUTO_SCAN_WP, - 0, COEX_UNASSOC_AUTO_SCAN_FLAGS}, - {COEX_CU_CALIBRATION_RP, COEX_CU_CALIBRATION_WP, - 0, COEX_CALIBRATION_FLAGS}, - {COEX_CU_PERIODIC_CALIBRATION_RP, COEX_CU_PERIODIC_CALIBRATION_WP, - 0, COEX_PERIODIC_CALIBRATION_FLAGS}, - {COEX_CU_CONNECTION_ESTAB_RP, COEX_CU_CONNECTION_ESTAB_WP, - 0, COEX_CONNECTION_ESTAB_FLAGS}, - {COEX_CU_ASSOCIATED_IDLE_RP, COEX_CU_ASSOCIATED_IDLE_WP, - 0, COEX_ASSOCIATED_IDLE_FLAGS}, - {COEX_CU_ASSOC_MANUAL_SCAN_RP, COEX_CU_ASSOC_MANUAL_SCAN_WP, - 0, COEX_ASSOC_MANUAL_SCAN_FLAGS}, - {COEX_CU_ASSOC_AUTO_SCAN_RP, COEX_CU_ASSOC_AUTO_SCAN_WP, - 0, COEX_ASSOC_AUTO_SCAN_FLAGS}, - {COEX_CU_ASSOC_ACTIVE_LEVEL_RP, COEX_CU_ASSOC_ACTIVE_LEVEL_WP, - 0, COEX_ASSOC_ACTIVE_LEVEL_FLAGS}, - {COEX_CU_RF_ON_RP, COEX_CU_RF_ON_WP, 0, COEX_CU_RF_ON_FLAGS}, - {COEX_CU_RF_OFF_RP, COEX_CU_RF_OFF_WP, 0, COEX_RF_OFF_FLAGS}, - {COEX_CU_STAND_ALONE_DEBUG_RP, COEX_CU_STAND_ALONE_DEBUG_WP, - 0, COEX_STAND_ALONE_DEBUG_FLAGS}, - {COEX_CU_IPAN_ASSOC_LEVEL_RP, COEX_CU_IPAN_ASSOC_LEVEL_WP, - 0, COEX_IPAN_ASSOC_LEVEL_FLAGS}, - {COEX_CU_RSRVD1_RP, COEX_CU_RSRVD1_WP, 0, COEX_RSRVD1_FLAGS}, - {COEX_CU_RSRVD2_RP, COEX_CU_RSRVD2_WP, 0, COEX_RSRVD2_FLAGS} -}; - -/****************************************************************************** - * - * uCode download functions - * - ******************************************************************************/ - -static void iwl_free_fw_desc(struct iwl_bus *bus, struct fw_desc *desc) -{ - if (desc->v_addr) - dma_free_coherent(bus->dev, desc->len, - desc->v_addr, desc->p_addr); - desc->v_addr = NULL; - desc->len = 0; -} - -static void iwl_free_fw_img(struct iwl_bus *bus, struct fw_img *img) -{ - iwl_free_fw_desc(bus, &img->code); - iwl_free_fw_desc(bus, &img->data); -} - -void iwl_dealloc_ucode(struct iwl_trans *trans) -{ - iwl_free_fw_img(bus(trans), &trans->ucode_rt); - iwl_free_fw_img(bus(trans), &trans->ucode_init); - iwl_free_fw_img(bus(trans), &trans->ucode_wowlan); -} - -int iwl_alloc_fw_desc(struct iwl_bus *bus, struct fw_desc *desc, - const void *data, size_t len) -{ - if (!len) { - desc->v_addr = NULL; - return -EINVAL; - } - - desc->v_addr = dma_alloc_coherent(bus->dev, len, - &desc->p_addr, GFP_KERNEL); - if (!desc->v_addr) - return -ENOMEM; - - desc->len = len; - memcpy(desc->v_addr, data, len); - return 0; -} - -/* - * ucode - */ -static int iwlagn_load_section(struct iwl_trans *trans, const char *name, - struct fw_desc *image, u32 dst_addr) -{ - struct iwl_bus *bus = bus(trans); - dma_addr_t phy_addr = image->p_addr; - u32 byte_cnt = image->len; - int ret; - - trans->ucode_write_complete = 0; - - iwl_write_direct32(bus, - FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL), - FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE); - - iwl_write_direct32(bus, - FH_SRVC_CHNL_SRAM_ADDR_REG(FH_SRVC_CHNL), dst_addr); - - iwl_write_direct32(bus, - FH_TFDIB_CTRL0_REG(FH_SRVC_CHNL), - phy_addr & FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK); - - iwl_write_direct32(bus, - FH_TFDIB_CTRL1_REG(FH_SRVC_CHNL), - (iwl_get_dma_hi_addr(phy_addr) - << FH_MEM_TFDIB_REG1_ADDR_BITSHIFT) | byte_cnt); - - iwl_write_direct32(bus, - FH_TCSR_CHNL_TX_BUF_STS_REG(FH_SRVC_CHNL), - 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM | - 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX | - FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID); - - iwl_write_direct32(bus, - FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL), - FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | - FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE | - FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD); - - IWL_DEBUG_FW(bus, "%s uCode section being loaded...\n", name); - ret = wait_event_timeout(trans->shrd->wait_command_queue, - trans->ucode_write_complete, 5 * HZ); - if (!ret) { - IWL_ERR(trans, "Could not load the %s uCode section\n", - name); - return -ETIMEDOUT; - } - - return 0; -} - -static inline struct fw_img *iwl_get_ucode_image(struct iwl_trans *trans, - enum iwl_ucode_type ucode_type) -{ - switch (ucode_type) { - case IWL_UCODE_INIT: - return &trans->ucode_init; - case IWL_UCODE_WOWLAN: - return &trans->ucode_wowlan; - case IWL_UCODE_REGULAR: - return &trans->ucode_rt; - case IWL_UCODE_NONE: - break; - } - return NULL; -} - -static int iwlagn_load_given_ucode(struct iwl_trans *trans, - enum iwl_ucode_type ucode_type) -{ - int ret = 0; - struct fw_img *image = iwl_get_ucode_image(trans, ucode_type); - - - if (!image) { - IWL_ERR(trans, "Invalid ucode requested (%d)\n", - ucode_type); - return -EINVAL; - } - - ret = iwlagn_load_section(trans, "INST", &image->code, - IWLAGN_RTC_INST_LOWER_BOUND); - if (ret) - return ret; - - return iwlagn_load_section(trans, "DATA", &image->data, - IWLAGN_RTC_DATA_LOWER_BOUND); -} - -/* - * Calibration - */ -static int iwlagn_set_Xtal_calib(struct iwl_priv *priv) -{ - struct iwl_calib_xtal_freq_cmd cmd; - __le16 *xtal_calib = - (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_XTAL); - - iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD); - cmd.cap_pin1 = le16_to_cpu(xtal_calib[0]); - cmd.cap_pin2 = le16_to_cpu(xtal_calib[1]); - return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); -} - -static int iwlagn_set_temperature_offset_calib(struct iwl_priv *priv) -{ - struct iwl_calib_temperature_offset_cmd cmd; - __le16 *offset_calib = - (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_RAW_TEMPERATURE); - - memset(&cmd, 0, sizeof(cmd)); - iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD); - memcpy(&cmd.radio_sensor_offset, offset_calib, sizeof(*offset_calib)); - if (!(cmd.radio_sensor_offset)) - cmd.radio_sensor_offset = DEFAULT_RADIO_SENSOR_OFFSET; - - IWL_DEBUG_CALIB(priv, "Radio sensor offset: %d\n", - le16_to_cpu(cmd.radio_sensor_offset)); - return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); -} - -static int iwlagn_set_temperature_offset_calib_v2(struct iwl_priv *priv) -{ - struct iwl_calib_temperature_offset_v2_cmd cmd; - __le16 *offset_calib_high = (__le16 *)iwl_eeprom_query_addr(priv, - EEPROM_KELVIN_TEMPERATURE); - __le16 *offset_calib_low = - (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_RAW_TEMPERATURE); - struct iwl_eeprom_calib_hdr *hdr; - - memset(&cmd, 0, sizeof(cmd)); - iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD); - hdr = (struct iwl_eeprom_calib_hdr *)iwl_eeprom_query_addr(priv, - EEPROM_CALIB_ALL); - memcpy(&cmd.radio_sensor_offset_high, offset_calib_high, - sizeof(*offset_calib_high)); - memcpy(&cmd.radio_sensor_offset_low, offset_calib_low, - sizeof(*offset_calib_low)); - if (!(cmd.radio_sensor_offset_low)) { - IWL_DEBUG_CALIB(priv, "no info in EEPROM, use default\n"); - cmd.radio_sensor_offset_low = DEFAULT_RADIO_SENSOR_OFFSET; - cmd.radio_sensor_offset_high = DEFAULT_RADIO_SENSOR_OFFSET; - } - memcpy(&cmd.burntVoltageRef, &hdr->voltage, - sizeof(hdr->voltage)); - - IWL_DEBUG_CALIB(priv, "Radio sensor offset high: %d\n", - le16_to_cpu(cmd.radio_sensor_offset_high)); - IWL_DEBUG_CALIB(priv, "Radio sensor offset low: %d\n", - le16_to_cpu(cmd.radio_sensor_offset_low)); - IWL_DEBUG_CALIB(priv, "Voltage Ref: %d\n", - le16_to_cpu(cmd.burntVoltageRef)); - - return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); -} - -static int iwlagn_send_calib_cfg(struct iwl_priv *priv) -{ - struct iwl_calib_cfg_cmd calib_cfg_cmd; - struct iwl_host_cmd cmd = { - .id = CALIBRATION_CFG_CMD, - .len = { sizeof(struct iwl_calib_cfg_cmd), }, - .data = { &calib_cfg_cmd, }, - }; - - memset(&calib_cfg_cmd, 0, sizeof(calib_cfg_cmd)); - calib_cfg_cmd.ucd_calib_cfg.once.is_enable = IWL_CALIB_INIT_CFG_ALL; - calib_cfg_cmd.ucd_calib_cfg.once.start = IWL_CALIB_INIT_CFG_ALL; - calib_cfg_cmd.ucd_calib_cfg.once.send_res = IWL_CALIB_INIT_CFG_ALL; - calib_cfg_cmd.ucd_calib_cfg.flags = - IWL_CALIB_CFG_FLAG_SEND_COMPLETE_NTFY_MSK; - - return iwl_trans_send_cmd(trans(priv), &cmd); -} - -int iwlagn_rx_calib_result(struct iwl_priv *priv, - struct iwl_rx_mem_buffer *rxb, - struct iwl_device_cmd *cmd) -{ - struct iwl_rx_packet *pkt = rxb_addr(rxb); - struct iwl_calib_hdr *hdr = (struct iwl_calib_hdr *)pkt->u.raw; - int len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; - - /* reduce the size of the length field itself */ - len -= 4; - - if (iwl_calib_set(priv, hdr, len)) - IWL_ERR(priv, "Failed to record calibration data %d\n", - hdr->op_code); - - return 0; -} - -int iwlagn_init_alive_start(struct iwl_priv *priv) -{ - int ret; - - if (priv->cfg->bt_params && - priv->cfg->bt_params->advanced_bt_coexist) { - /* - * Tell uCode we are ready to perform calibration - * need to perform this before any calibration - * no need to close the envlope since we are going - * to load the runtime uCode later. - */ - ret = iwlagn_send_bt_env(priv, IWL_BT_COEX_ENV_OPEN, - BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); - if (ret) - return ret; - - } - - ret = iwlagn_send_calib_cfg(priv); - if (ret) - return ret; - - /** - * temperature offset calibration is only needed for runtime ucode, - * so prepare the value now. - */ - if (priv->cfg->need_temp_offset_calib) { - if (priv->cfg->temp_offset_v2) - return iwlagn_set_temperature_offset_calib_v2(priv); - else - return iwlagn_set_temperature_offset_calib(priv); - } - - return 0; -} - -static int iwlagn_send_wimax_coex(struct iwl_priv *priv) -{ - struct iwl_wimax_coex_cmd coex_cmd; - - if (priv->cfg->base_params->support_wimax_coexist) { - /* UnMask wake up src at associated sleep */ - coex_cmd.flags = COEX_FLAGS_ASSOC_WA_UNMASK_MSK; - - /* UnMask wake up src at unassociated sleep */ - coex_cmd.flags |= COEX_FLAGS_UNASSOC_WA_UNMASK_MSK; - memcpy(coex_cmd.sta_prio, cu_priorities, - sizeof(struct iwl_wimax_coex_event_entry) * - COEX_NUM_OF_EVENTS); - - /* enabling the coexistence feature */ - coex_cmd.flags |= COEX_FLAGS_COEX_ENABLE_MSK; - - /* enabling the priorities tables */ - coex_cmd.flags |= COEX_FLAGS_STA_TABLE_VALID_MSK; - } else { - /* coexistence is disabled */ - memset(&coex_cmd, 0, sizeof(coex_cmd)); - } - return iwl_trans_send_cmd_pdu(trans(priv), - COEX_PRIORITY_TABLE_CMD, CMD_SYNC, - sizeof(coex_cmd), &coex_cmd); -} - -static const u8 iwlagn_bt_prio_tbl[BT_COEX_PRIO_TBL_EVT_MAX] = { - ((BT_COEX_PRIO_TBL_PRIO_BYPASS << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | - (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), - ((BT_COEX_PRIO_TBL_PRIO_BYPASS << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | - (1 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), - ((BT_COEX_PRIO_TBL_PRIO_LOW << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | - (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), - ((BT_COEX_PRIO_TBL_PRIO_LOW << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | - (1 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), - ((BT_COEX_PRIO_TBL_PRIO_HIGH << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | - (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), - ((BT_COEX_PRIO_TBL_PRIO_HIGH << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | - (1 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), - ((BT_COEX_PRIO_TBL_PRIO_BYPASS << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | - (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), - ((BT_COEX_PRIO_TBL_PRIO_COEX_OFF << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | - (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), - ((BT_COEX_PRIO_TBL_PRIO_COEX_ON << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | - (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), - 0, 0, 0, 0, 0, 0, 0 -}; - -void iwlagn_send_prio_tbl(struct iwl_priv *priv) -{ - struct iwl_bt_coex_prio_table_cmd prio_tbl_cmd; - - memcpy(prio_tbl_cmd.prio_tbl, iwlagn_bt_prio_tbl, - sizeof(iwlagn_bt_prio_tbl)); - if (iwl_trans_send_cmd_pdu(trans(priv), - REPLY_BT_COEX_PRIO_TABLE, CMD_SYNC, - sizeof(prio_tbl_cmd), &prio_tbl_cmd)) - IWL_ERR(priv, "failed to send BT prio tbl command\n"); -} - -int iwlagn_send_bt_env(struct iwl_priv *priv, u8 action, u8 type) -{ - struct iwl_bt_coex_prot_env_cmd env_cmd; - int ret; - - env_cmd.action = action; - env_cmd.type = type; - ret = iwl_trans_send_cmd_pdu(trans(priv), - REPLY_BT_COEX_PROT_ENV, CMD_SYNC, - sizeof(env_cmd), &env_cmd); - if (ret) - IWL_ERR(priv, "failed to send BT env command\n"); - return ret; -} - - -static int iwlagn_alive_notify(struct iwl_priv *priv) -{ - struct iwl_rxon_context *ctx; - int ret; - - if (!priv->tx_cmd_pool) - priv->tx_cmd_pool = - kmem_cache_create("iwlagn_dev_cmd", - sizeof(struct iwl_device_cmd), - sizeof(void *), 0, NULL); - - if (!priv->tx_cmd_pool) - return -ENOMEM; - - iwl_trans_tx_start(trans(priv)); - for_each_context(priv, ctx) - ctx->last_tx_rejected = false; - - ret = iwlagn_send_wimax_coex(priv); - if (ret) - return ret; - - if (!priv->cfg->no_xtal_calib) { - ret = iwlagn_set_Xtal_calib(priv); - if (ret) - return ret; - } - - return iwl_send_calib_results(priv); -} - - -/** - * iwl_verify_inst_sparse - verify runtime uCode image in card vs. host, - * using sample data 100 bytes apart. If these sample points are good, - * it's a pretty good bet that everything between them is good, too. - */ -static int iwl_verify_inst_sparse(struct iwl_bus *bus, - struct fw_desc *fw_desc) -{ - __le32 *image = (__le32 *)fw_desc->v_addr; - u32 len = fw_desc->len; - u32 val; - u32 i; - - IWL_DEBUG_FW(bus, "ucode inst image size is %u\n", len); - - for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { - /* read data comes through single port, auto-incr addr */ - /* NOTE: Use the debugless read so we don't flood kernel log - * if IWL_DL_IO is set */ - iwl_write_direct32(bus, HBUS_TARG_MEM_RADDR, - i + IWLAGN_RTC_INST_LOWER_BOUND); - val = iwl_read32(bus, HBUS_TARG_MEM_RDAT); - if (val != le32_to_cpu(*image)) - return -EIO; - } - - return 0; -} - -static void iwl_print_mismatch_inst(struct iwl_bus *bus, - struct fw_desc *fw_desc) -{ - __le32 *image = (__le32 *)fw_desc->v_addr; - u32 len = fw_desc->len; - u32 val; - u32 offs; - int errors = 0; - - IWL_DEBUG_FW(bus, "ucode inst image size is %u\n", len); - - iwl_write_direct32(bus, HBUS_TARG_MEM_RADDR, - IWLAGN_RTC_INST_LOWER_BOUND); - - for (offs = 0; - offs < len && errors < 20; - offs += sizeof(u32), image++) { - /* read data comes through single port, auto-incr addr */ - val = iwl_read32(bus, HBUS_TARG_MEM_RDAT); - if (val != le32_to_cpu(*image)) { - IWL_ERR(bus, "uCode INST section at " - "offset 0x%x, is 0x%x, s/b 0x%x\n", - offs, val, le32_to_cpu(*image)); - errors++; - } - } -} - -/** - * iwl_verify_ucode - determine which instruction image is in SRAM, - * and verify its contents - */ -static int iwl_verify_ucode(struct iwl_trans *trans, - enum iwl_ucode_type ucode_type) -{ - struct fw_img *img = iwl_get_ucode_image(trans, ucode_type); - - if (!img) { - IWL_ERR(trans, "Invalid ucode requested (%d)\n", ucode_type); - return -EINVAL; - } - - if (!iwl_verify_inst_sparse(bus(trans), &img->code)) { - IWL_DEBUG_FW(trans, "uCode is good in inst SRAM\n"); - return 0; - } - - IWL_ERR(trans, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n"); - - iwl_print_mismatch_inst(bus(trans), &img->code); - return -EIO; -} - -struct iwlagn_alive_data { - bool valid; - u8 subtype; -}; - -static void iwlagn_alive_fn(struct iwl_priv *priv, - struct iwl_rx_packet *pkt, - void *data) -{ - struct iwlagn_alive_data *alive_data = data; - struct iwl_alive_resp *palive; - - palive = &pkt->u.alive_frame; - - IWL_DEBUG_FW(priv, "Alive ucode status 0x%08X revision " - "0x%01X 0x%01X\n", - palive->is_valid, palive->ver_type, - palive->ver_subtype); - - priv->device_pointers.error_event_table = - le32_to_cpu(palive->error_event_table_ptr); - priv->device_pointers.log_event_table = - le32_to_cpu(palive->log_event_table_ptr); - - alive_data->subtype = palive->ver_subtype; - alive_data->valid = palive->is_valid == UCODE_VALID_OK; -} - -#define UCODE_ALIVE_TIMEOUT HZ -#define UCODE_CALIB_TIMEOUT (2*HZ) - -int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, - enum iwl_ucode_type ucode_type) -{ - struct iwl_notification_wait alive_wait; - struct iwlagn_alive_data alive_data; - int ret; - enum iwl_ucode_type old_type; - - ret = iwl_trans_start_device(trans(priv)); - if (ret) - return ret; - - iwlagn_init_notification_wait(priv, &alive_wait, REPLY_ALIVE, - iwlagn_alive_fn, &alive_data); - - old_type = priv->ucode_type; - priv->ucode_type = ucode_type; - - ret = iwlagn_load_given_ucode(trans(priv), ucode_type); - if (ret) { - priv->ucode_type = old_type; - iwlagn_remove_notification(priv, &alive_wait); - return ret; - } - - iwl_trans_kick_nic(trans(priv)); - - /* - * Some things may run in the background now, but we - * just wait for the ALIVE notification here. - */ - ret = iwlagn_wait_notification(priv, &alive_wait, UCODE_ALIVE_TIMEOUT); - if (ret) { - priv->ucode_type = old_type; - return ret; - } - - if (!alive_data.valid) { - IWL_ERR(priv, "Loaded ucode is not valid!\n"); - priv->ucode_type = old_type; - return -EIO; - } - - /* - * This step takes a long time (60-80ms!!) and - * WoWLAN image should be loaded quickly, so - * skip it for WoWLAN. - */ - if (ucode_type != IWL_UCODE_WOWLAN) { - ret = iwl_verify_ucode(trans(priv), ucode_type); - if (ret) { - priv->ucode_type = old_type; - return ret; - } - - /* delay a bit to give rfkill time to run */ - msleep(5); - } - - ret = iwlagn_alive_notify(priv); - if (ret) { - IWL_WARN(priv, - "Could not complete ALIVE transition: %d\n", ret); - priv->ucode_type = old_type; - return ret; - } - - return 0; -} - -int iwlagn_run_init_ucode(struct iwl_priv *priv) -{ - struct iwl_notification_wait calib_wait; - int ret; - - lockdep_assert_held(&priv->shrd->mutex); - - /* No init ucode required? Curious, but maybe ok */ - if (!trans(priv)->ucode_init.code.len) - return 0; - - if (priv->ucode_type != IWL_UCODE_NONE) - return 0; - - iwlagn_init_notification_wait(priv, &calib_wait, - CALIBRATION_COMPLETE_NOTIFICATION, - NULL, NULL); - - /* Will also start the device */ - ret = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_INIT); - if (ret) - goto error; - - ret = iwlagn_init_alive_start(priv); - if (ret) - goto error; - - /* - * Some things may run in the background now, but we - * just wait for the calibration complete notification. - */ - ret = iwlagn_wait_notification(priv, &calib_wait, UCODE_CALIB_TIMEOUT); - - goto out; - - error: - iwlagn_remove_notification(priv, &calib_wait); - out: - /* Whatever happened, stop the device */ - iwl_trans_stop_device(trans(priv)); - return ret; -} diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c new file mode 100644 index 000000000000..76949106dafc --- /dev/null +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -0,0 +1,688 @@ +/****************************************************************************** + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, + * USA + * + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * Contact Information: + * Intel Linux Wireless + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + * + *****************************************************************************/ + +#include +#include +#include +#include +#include + +#include "iwl-dev.h" +#include "iwl-core.h" +#include "iwl-io.h" +#include "iwl-agn-hw.h" +#include "iwl-agn.h" +#include "iwl-agn-calib.h" +#include "iwl-trans.h" +#include "iwl-fh.h" + +static struct iwl_wimax_coex_event_entry cu_priorities[COEX_NUM_OF_EVENTS] = { + {COEX_CU_UNASSOC_IDLE_RP, COEX_CU_UNASSOC_IDLE_WP, + 0, COEX_UNASSOC_IDLE_FLAGS}, + {COEX_CU_UNASSOC_MANUAL_SCAN_RP, COEX_CU_UNASSOC_MANUAL_SCAN_WP, + 0, COEX_UNASSOC_MANUAL_SCAN_FLAGS}, + {COEX_CU_UNASSOC_AUTO_SCAN_RP, COEX_CU_UNASSOC_AUTO_SCAN_WP, + 0, COEX_UNASSOC_AUTO_SCAN_FLAGS}, + {COEX_CU_CALIBRATION_RP, COEX_CU_CALIBRATION_WP, + 0, COEX_CALIBRATION_FLAGS}, + {COEX_CU_PERIODIC_CALIBRATION_RP, COEX_CU_PERIODIC_CALIBRATION_WP, + 0, COEX_PERIODIC_CALIBRATION_FLAGS}, + {COEX_CU_CONNECTION_ESTAB_RP, COEX_CU_CONNECTION_ESTAB_WP, + 0, COEX_CONNECTION_ESTAB_FLAGS}, + {COEX_CU_ASSOCIATED_IDLE_RP, COEX_CU_ASSOCIATED_IDLE_WP, + 0, COEX_ASSOCIATED_IDLE_FLAGS}, + {COEX_CU_ASSOC_MANUAL_SCAN_RP, COEX_CU_ASSOC_MANUAL_SCAN_WP, + 0, COEX_ASSOC_MANUAL_SCAN_FLAGS}, + {COEX_CU_ASSOC_AUTO_SCAN_RP, COEX_CU_ASSOC_AUTO_SCAN_WP, + 0, COEX_ASSOC_AUTO_SCAN_FLAGS}, + {COEX_CU_ASSOC_ACTIVE_LEVEL_RP, COEX_CU_ASSOC_ACTIVE_LEVEL_WP, + 0, COEX_ASSOC_ACTIVE_LEVEL_FLAGS}, + {COEX_CU_RF_ON_RP, COEX_CU_RF_ON_WP, 0, COEX_CU_RF_ON_FLAGS}, + {COEX_CU_RF_OFF_RP, COEX_CU_RF_OFF_WP, 0, COEX_RF_OFF_FLAGS}, + {COEX_CU_STAND_ALONE_DEBUG_RP, COEX_CU_STAND_ALONE_DEBUG_WP, + 0, COEX_STAND_ALONE_DEBUG_FLAGS}, + {COEX_CU_IPAN_ASSOC_LEVEL_RP, COEX_CU_IPAN_ASSOC_LEVEL_WP, + 0, COEX_IPAN_ASSOC_LEVEL_FLAGS}, + {COEX_CU_RSRVD1_RP, COEX_CU_RSRVD1_WP, 0, COEX_RSRVD1_FLAGS}, + {COEX_CU_RSRVD2_RP, COEX_CU_RSRVD2_WP, 0, COEX_RSRVD2_FLAGS} +}; + +/****************************************************************************** + * + * uCode download functions + * + ******************************************************************************/ + +static void iwl_free_fw_desc(struct iwl_bus *bus, struct fw_desc *desc) +{ + if (desc->v_addr) + dma_free_coherent(bus->dev, desc->len, + desc->v_addr, desc->p_addr); + desc->v_addr = NULL; + desc->len = 0; +} + +static void iwl_free_fw_img(struct iwl_bus *bus, struct fw_img *img) +{ + iwl_free_fw_desc(bus, &img->code); + iwl_free_fw_desc(bus, &img->data); +} + +void iwl_dealloc_ucode(struct iwl_trans *trans) +{ + iwl_free_fw_img(bus(trans), &trans->ucode_rt); + iwl_free_fw_img(bus(trans), &trans->ucode_init); + iwl_free_fw_img(bus(trans), &trans->ucode_wowlan); +} + +int iwl_alloc_fw_desc(struct iwl_bus *bus, struct fw_desc *desc, + const void *data, size_t len) +{ + if (!len) { + desc->v_addr = NULL; + return -EINVAL; + } + + desc->v_addr = dma_alloc_coherent(bus->dev, len, + &desc->p_addr, GFP_KERNEL); + if (!desc->v_addr) + return -ENOMEM; + + desc->len = len; + memcpy(desc->v_addr, data, len); + return 0; +} + +/* + * ucode + */ +static int iwlagn_load_section(struct iwl_trans *trans, const char *name, + struct fw_desc *image, u32 dst_addr) +{ + struct iwl_bus *bus = bus(trans); + dma_addr_t phy_addr = image->p_addr; + u32 byte_cnt = image->len; + int ret; + + trans->ucode_write_complete = 0; + + iwl_write_direct32(bus, + FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL), + FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE); + + iwl_write_direct32(bus, + FH_SRVC_CHNL_SRAM_ADDR_REG(FH_SRVC_CHNL), dst_addr); + + iwl_write_direct32(bus, + FH_TFDIB_CTRL0_REG(FH_SRVC_CHNL), + phy_addr & FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK); + + iwl_write_direct32(bus, + FH_TFDIB_CTRL1_REG(FH_SRVC_CHNL), + (iwl_get_dma_hi_addr(phy_addr) + << FH_MEM_TFDIB_REG1_ADDR_BITSHIFT) | byte_cnt); + + iwl_write_direct32(bus, + FH_TCSR_CHNL_TX_BUF_STS_REG(FH_SRVC_CHNL), + 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM | + 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX | + FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID); + + iwl_write_direct32(bus, + FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL), + FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE | + FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE | + FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD); + + IWL_DEBUG_FW(bus, "%s uCode section being loaded...\n", name); + ret = wait_event_timeout(trans->shrd->wait_command_queue, + trans->ucode_write_complete, 5 * HZ); + if (!ret) { + IWL_ERR(trans, "Could not load the %s uCode section\n", + name); + return -ETIMEDOUT; + } + + return 0; +} + +static inline struct fw_img *iwl_get_ucode_image(struct iwl_trans *trans, + enum iwl_ucode_type ucode_type) +{ + switch (ucode_type) { + case IWL_UCODE_INIT: + return &trans->ucode_init; + case IWL_UCODE_WOWLAN: + return &trans->ucode_wowlan; + case IWL_UCODE_REGULAR: + return &trans->ucode_rt; + case IWL_UCODE_NONE: + break; + } + return NULL; +} + +static int iwlagn_load_given_ucode(struct iwl_trans *trans, + enum iwl_ucode_type ucode_type) +{ + int ret = 0; + struct fw_img *image = iwl_get_ucode_image(trans, ucode_type); + + + if (!image) { + IWL_ERR(trans, "Invalid ucode requested (%d)\n", + ucode_type); + return -EINVAL; + } + + ret = iwlagn_load_section(trans, "INST", &image->code, + IWLAGN_RTC_INST_LOWER_BOUND); + if (ret) + return ret; + + return iwlagn_load_section(trans, "DATA", &image->data, + IWLAGN_RTC_DATA_LOWER_BOUND); +} + +/* + * Calibration + */ +static int iwlagn_set_Xtal_calib(struct iwl_priv *priv) +{ + struct iwl_calib_xtal_freq_cmd cmd; + __le16 *xtal_calib = + (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_XTAL); + + iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD); + cmd.cap_pin1 = le16_to_cpu(xtal_calib[0]); + cmd.cap_pin2 = le16_to_cpu(xtal_calib[1]); + return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); +} + +static int iwlagn_set_temperature_offset_calib(struct iwl_priv *priv) +{ + struct iwl_calib_temperature_offset_cmd cmd; + __le16 *offset_calib = + (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_RAW_TEMPERATURE); + + memset(&cmd, 0, sizeof(cmd)); + iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD); + memcpy(&cmd.radio_sensor_offset, offset_calib, sizeof(*offset_calib)); + if (!(cmd.radio_sensor_offset)) + cmd.radio_sensor_offset = DEFAULT_RADIO_SENSOR_OFFSET; + + IWL_DEBUG_CALIB(priv, "Radio sensor offset: %d\n", + le16_to_cpu(cmd.radio_sensor_offset)); + return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); +} + +static int iwlagn_set_temperature_offset_calib_v2(struct iwl_priv *priv) +{ + struct iwl_calib_temperature_offset_v2_cmd cmd; + __le16 *offset_calib_high = (__le16 *)iwl_eeprom_query_addr(priv, + EEPROM_KELVIN_TEMPERATURE); + __le16 *offset_calib_low = + (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_RAW_TEMPERATURE); + struct iwl_eeprom_calib_hdr *hdr; + + memset(&cmd, 0, sizeof(cmd)); + iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD); + hdr = (struct iwl_eeprom_calib_hdr *)iwl_eeprom_query_addr(priv, + EEPROM_CALIB_ALL); + memcpy(&cmd.radio_sensor_offset_high, offset_calib_high, + sizeof(*offset_calib_high)); + memcpy(&cmd.radio_sensor_offset_low, offset_calib_low, + sizeof(*offset_calib_low)); + if (!(cmd.radio_sensor_offset_low)) { + IWL_DEBUG_CALIB(priv, "no info in EEPROM, use default\n"); + cmd.radio_sensor_offset_low = DEFAULT_RADIO_SENSOR_OFFSET; + cmd.radio_sensor_offset_high = DEFAULT_RADIO_SENSOR_OFFSET; + } + memcpy(&cmd.burntVoltageRef, &hdr->voltage, + sizeof(hdr->voltage)); + + IWL_DEBUG_CALIB(priv, "Radio sensor offset high: %d\n", + le16_to_cpu(cmd.radio_sensor_offset_high)); + IWL_DEBUG_CALIB(priv, "Radio sensor offset low: %d\n", + le16_to_cpu(cmd.radio_sensor_offset_low)); + IWL_DEBUG_CALIB(priv, "Voltage Ref: %d\n", + le16_to_cpu(cmd.burntVoltageRef)); + + return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); +} + +static int iwlagn_send_calib_cfg(struct iwl_priv *priv) +{ + struct iwl_calib_cfg_cmd calib_cfg_cmd; + struct iwl_host_cmd cmd = { + .id = CALIBRATION_CFG_CMD, + .len = { sizeof(struct iwl_calib_cfg_cmd), }, + .data = { &calib_cfg_cmd, }, + }; + + memset(&calib_cfg_cmd, 0, sizeof(calib_cfg_cmd)); + calib_cfg_cmd.ucd_calib_cfg.once.is_enable = IWL_CALIB_INIT_CFG_ALL; + calib_cfg_cmd.ucd_calib_cfg.once.start = IWL_CALIB_INIT_CFG_ALL; + calib_cfg_cmd.ucd_calib_cfg.once.send_res = IWL_CALIB_INIT_CFG_ALL; + calib_cfg_cmd.ucd_calib_cfg.flags = + IWL_CALIB_CFG_FLAG_SEND_COMPLETE_NTFY_MSK; + + return iwl_trans_send_cmd(trans(priv), &cmd); +} + +int iwlagn_rx_calib_result(struct iwl_priv *priv, + struct iwl_rx_mem_buffer *rxb, + struct iwl_device_cmd *cmd) +{ + struct iwl_rx_packet *pkt = rxb_addr(rxb); + struct iwl_calib_hdr *hdr = (struct iwl_calib_hdr *)pkt->u.raw; + int len = le32_to_cpu(pkt->len_n_flags) & FH_RSCSR_FRAME_SIZE_MSK; + + /* reduce the size of the length field itself */ + len -= 4; + + if (iwl_calib_set(priv, hdr, len)) + IWL_ERR(priv, "Failed to record calibration data %d\n", + hdr->op_code); + + return 0; +} + +int iwlagn_init_alive_start(struct iwl_priv *priv) +{ + int ret; + + if (priv->cfg->bt_params && + priv->cfg->bt_params->advanced_bt_coexist) { + /* + * Tell uCode we are ready to perform calibration + * need to perform this before any calibration + * no need to close the envlope since we are going + * to load the runtime uCode later. + */ + ret = iwlagn_send_bt_env(priv, IWL_BT_COEX_ENV_OPEN, + BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); + if (ret) + return ret; + + } + + ret = iwlagn_send_calib_cfg(priv); + if (ret) + return ret; + + /** + * temperature offset calibration is only needed for runtime ucode, + * so prepare the value now. + */ + if (priv->cfg->need_temp_offset_calib) { + if (priv->cfg->temp_offset_v2) + return iwlagn_set_temperature_offset_calib_v2(priv); + else + return iwlagn_set_temperature_offset_calib(priv); + } + + return 0; +} + +static int iwlagn_send_wimax_coex(struct iwl_priv *priv) +{ + struct iwl_wimax_coex_cmd coex_cmd; + + if (priv->cfg->base_params->support_wimax_coexist) { + /* UnMask wake up src at associated sleep */ + coex_cmd.flags = COEX_FLAGS_ASSOC_WA_UNMASK_MSK; + + /* UnMask wake up src at unassociated sleep */ + coex_cmd.flags |= COEX_FLAGS_UNASSOC_WA_UNMASK_MSK; + memcpy(coex_cmd.sta_prio, cu_priorities, + sizeof(struct iwl_wimax_coex_event_entry) * + COEX_NUM_OF_EVENTS); + + /* enabling the coexistence feature */ + coex_cmd.flags |= COEX_FLAGS_COEX_ENABLE_MSK; + + /* enabling the priorities tables */ + coex_cmd.flags |= COEX_FLAGS_STA_TABLE_VALID_MSK; + } else { + /* coexistence is disabled */ + memset(&coex_cmd, 0, sizeof(coex_cmd)); + } + return iwl_trans_send_cmd_pdu(trans(priv), + COEX_PRIORITY_TABLE_CMD, CMD_SYNC, + sizeof(coex_cmd), &coex_cmd); +} + +static const u8 iwlagn_bt_prio_tbl[BT_COEX_PRIO_TBL_EVT_MAX] = { + ((BT_COEX_PRIO_TBL_PRIO_BYPASS << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | + (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), + ((BT_COEX_PRIO_TBL_PRIO_BYPASS << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | + (1 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), + ((BT_COEX_PRIO_TBL_PRIO_LOW << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | + (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), + ((BT_COEX_PRIO_TBL_PRIO_LOW << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | + (1 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), + ((BT_COEX_PRIO_TBL_PRIO_HIGH << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | + (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), + ((BT_COEX_PRIO_TBL_PRIO_HIGH << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | + (1 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), + ((BT_COEX_PRIO_TBL_PRIO_BYPASS << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | + (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), + ((BT_COEX_PRIO_TBL_PRIO_COEX_OFF << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | + (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), + ((BT_COEX_PRIO_TBL_PRIO_COEX_ON << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | + (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), + 0, 0, 0, 0, 0, 0, 0 +}; + +void iwlagn_send_prio_tbl(struct iwl_priv *priv) +{ + struct iwl_bt_coex_prio_table_cmd prio_tbl_cmd; + + memcpy(prio_tbl_cmd.prio_tbl, iwlagn_bt_prio_tbl, + sizeof(iwlagn_bt_prio_tbl)); + if (iwl_trans_send_cmd_pdu(trans(priv), + REPLY_BT_COEX_PRIO_TABLE, CMD_SYNC, + sizeof(prio_tbl_cmd), &prio_tbl_cmd)) + IWL_ERR(priv, "failed to send BT prio tbl command\n"); +} + +int iwlagn_send_bt_env(struct iwl_priv *priv, u8 action, u8 type) +{ + struct iwl_bt_coex_prot_env_cmd env_cmd; + int ret; + + env_cmd.action = action; + env_cmd.type = type; + ret = iwl_trans_send_cmd_pdu(trans(priv), + REPLY_BT_COEX_PROT_ENV, CMD_SYNC, + sizeof(env_cmd), &env_cmd); + if (ret) + IWL_ERR(priv, "failed to send BT env command\n"); + return ret; +} + + +static int iwlagn_alive_notify(struct iwl_priv *priv) +{ + struct iwl_rxon_context *ctx; + int ret; + + if (!priv->tx_cmd_pool) + priv->tx_cmd_pool = + kmem_cache_create("iwlagn_dev_cmd", + sizeof(struct iwl_device_cmd), + sizeof(void *), 0, NULL); + + if (!priv->tx_cmd_pool) + return -ENOMEM; + + iwl_trans_tx_start(trans(priv)); + for_each_context(priv, ctx) + ctx->last_tx_rejected = false; + + ret = iwlagn_send_wimax_coex(priv); + if (ret) + return ret; + + if (!priv->cfg->no_xtal_calib) { + ret = iwlagn_set_Xtal_calib(priv); + if (ret) + return ret; + } + + return iwl_send_calib_results(priv); +} + + +/** + * iwl_verify_inst_sparse - verify runtime uCode image in card vs. host, + * using sample data 100 bytes apart. If these sample points are good, + * it's a pretty good bet that everything between them is good, too. + */ +static int iwl_verify_inst_sparse(struct iwl_bus *bus, + struct fw_desc *fw_desc) +{ + __le32 *image = (__le32 *)fw_desc->v_addr; + u32 len = fw_desc->len; + u32 val; + u32 i; + + IWL_DEBUG_FW(bus, "ucode inst image size is %u\n", len); + + for (i = 0; i < len; i += 100, image += 100/sizeof(u32)) { + /* read data comes through single port, auto-incr addr */ + /* NOTE: Use the debugless read so we don't flood kernel log + * if IWL_DL_IO is set */ + iwl_write_direct32(bus, HBUS_TARG_MEM_RADDR, + i + IWLAGN_RTC_INST_LOWER_BOUND); + val = iwl_read32(bus, HBUS_TARG_MEM_RDAT); + if (val != le32_to_cpu(*image)) + return -EIO; + } + + return 0; +} + +static void iwl_print_mismatch_inst(struct iwl_bus *bus, + struct fw_desc *fw_desc) +{ + __le32 *image = (__le32 *)fw_desc->v_addr; + u32 len = fw_desc->len; + u32 val; + u32 offs; + int errors = 0; + + IWL_DEBUG_FW(bus, "ucode inst image size is %u\n", len); + + iwl_write_direct32(bus, HBUS_TARG_MEM_RADDR, + IWLAGN_RTC_INST_LOWER_BOUND); + + for (offs = 0; + offs < len && errors < 20; + offs += sizeof(u32), image++) { + /* read data comes through single port, auto-incr addr */ + val = iwl_read32(bus, HBUS_TARG_MEM_RDAT); + if (val != le32_to_cpu(*image)) { + IWL_ERR(bus, "uCode INST section at " + "offset 0x%x, is 0x%x, s/b 0x%x\n", + offs, val, le32_to_cpu(*image)); + errors++; + } + } +} + +/** + * iwl_verify_ucode - determine which instruction image is in SRAM, + * and verify its contents + */ +static int iwl_verify_ucode(struct iwl_trans *trans, + enum iwl_ucode_type ucode_type) +{ + struct fw_img *img = iwl_get_ucode_image(trans, ucode_type); + + if (!img) { + IWL_ERR(trans, "Invalid ucode requested (%d)\n", ucode_type); + return -EINVAL; + } + + if (!iwl_verify_inst_sparse(bus(trans), &img->code)) { + IWL_DEBUG_FW(trans, "uCode is good in inst SRAM\n"); + return 0; + } + + IWL_ERR(trans, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n"); + + iwl_print_mismatch_inst(bus(trans), &img->code); + return -EIO; +} + +struct iwlagn_alive_data { + bool valid; + u8 subtype; +}; + +static void iwlagn_alive_fn(struct iwl_priv *priv, + struct iwl_rx_packet *pkt, + void *data) +{ + struct iwlagn_alive_data *alive_data = data; + struct iwl_alive_resp *palive; + + palive = &pkt->u.alive_frame; + + IWL_DEBUG_FW(priv, "Alive ucode status 0x%08X revision " + "0x%01X 0x%01X\n", + palive->is_valid, palive->ver_type, + palive->ver_subtype); + + priv->device_pointers.error_event_table = + le32_to_cpu(palive->error_event_table_ptr); + priv->device_pointers.log_event_table = + le32_to_cpu(palive->log_event_table_ptr); + + alive_data->subtype = palive->ver_subtype; + alive_data->valid = palive->is_valid == UCODE_VALID_OK; +} + +#define UCODE_ALIVE_TIMEOUT HZ +#define UCODE_CALIB_TIMEOUT (2*HZ) + +int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, + enum iwl_ucode_type ucode_type) +{ + struct iwl_notification_wait alive_wait; + struct iwlagn_alive_data alive_data; + int ret; + enum iwl_ucode_type old_type; + + ret = iwl_trans_start_device(trans(priv)); + if (ret) + return ret; + + iwlagn_init_notification_wait(priv, &alive_wait, REPLY_ALIVE, + iwlagn_alive_fn, &alive_data); + + old_type = priv->ucode_type; + priv->ucode_type = ucode_type; + + ret = iwlagn_load_given_ucode(trans(priv), ucode_type); + if (ret) { + priv->ucode_type = old_type; + iwlagn_remove_notification(priv, &alive_wait); + return ret; + } + + iwl_trans_kick_nic(trans(priv)); + + /* + * Some things may run in the background now, but we + * just wait for the ALIVE notification here. + */ + ret = iwlagn_wait_notification(priv, &alive_wait, UCODE_ALIVE_TIMEOUT); + if (ret) { + priv->ucode_type = old_type; + return ret; + } + + if (!alive_data.valid) { + IWL_ERR(priv, "Loaded ucode is not valid!\n"); + priv->ucode_type = old_type; + return -EIO; + } + + /* + * This step takes a long time (60-80ms!!) and + * WoWLAN image should be loaded quickly, so + * skip it for WoWLAN. + */ + if (ucode_type != IWL_UCODE_WOWLAN) { + ret = iwl_verify_ucode(trans(priv), ucode_type); + if (ret) { + priv->ucode_type = old_type; + return ret; + } + + /* delay a bit to give rfkill time to run */ + msleep(5); + } + + ret = iwlagn_alive_notify(priv); + if (ret) { + IWL_WARN(priv, + "Could not complete ALIVE transition: %d\n", ret); + priv->ucode_type = old_type; + return ret; + } + + return 0; +} + +int iwlagn_run_init_ucode(struct iwl_priv *priv) +{ + struct iwl_notification_wait calib_wait; + int ret; + + lockdep_assert_held(&priv->shrd->mutex); + + /* No init ucode required? Curious, but maybe ok */ + if (!trans(priv)->ucode_init.code.len) + return 0; + + if (priv->ucode_type != IWL_UCODE_NONE) + return 0; + + iwlagn_init_notification_wait(priv, &calib_wait, + CALIBRATION_COMPLETE_NOTIFICATION, + NULL, NULL); + + /* Will also start the device */ + ret = iwlagn_load_ucode_wait_alive(priv, IWL_UCODE_INIT); + if (ret) + goto error; + + ret = iwlagn_init_alive_start(priv); + if (ret) + goto error; + + /* + * Some things may run in the background now, but we + * just wait for the calibration complete notification. + */ + ret = iwlagn_wait_notification(priv, &calib_wait, UCODE_CALIB_TIMEOUT); + + goto out; + + error: + iwlagn_remove_notification(priv, &calib_wait); + out: + /* Whatever happened, stop the device */ + iwl_trans_stop_device(trans(priv)); + return ret; +} -- cgit v1.2.3 From b96b09db60f8e0d9c6bc3ea00447953c16d8b2fc Mon Sep 17 00:00:00 2001 From: Don Fry Date: Fri, 2 Dec 2011 08:48:38 -0800 Subject: iwlwifi: replace iwl_priv reference with iwl_trans for ucode. Replace the references to the iwl_priv structure with the iwl_trans structure as the priv structure is never referenced other than to access the trans structure. Rename from iwlagn to iwl. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn.c | 6 ++-- drivers/net/wireless/iwlwifi/iwl-agn.h | 4 +-- drivers/net/wireless/iwlwifi/iwl-ucode.c | 62 ++++++++++++++++---------------- 3 files changed, 36 insertions(+), 36 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 4d20be9dea39..daf010dad70c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1232,14 +1232,14 @@ int iwl_alive_start(struct iwl_priv *priv) priv->bt_valid = IWLAGN_BT_VALID_ENABLE_FLAGS; priv->cur_rssi_ctx = NULL; - iwlagn_send_prio_tbl(priv); + iwl_send_prio_tbl(trans(priv)); /* FIXME: w/a to force change uCode BT state machine */ - ret = iwlagn_send_bt_env(priv, IWL_BT_COEX_ENV_OPEN, + ret = iwl_send_bt_env(trans(priv), IWL_BT_COEX_ENV_OPEN, BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); if (ret) return ret; - ret = iwlagn_send_bt_env(priv, IWL_BT_COEX_ENV_CLOSE, + ret = iwl_send_bt_env(trans(priv), IWL_BT_COEX_ENV_CLOSE, BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); if (ret) return ret; diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 2f446a353514..0db0a8fb5679 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -108,8 +108,8 @@ void iwlagn_config_ht40(struct ieee80211_conf *conf, int iwlagn_rx_calib_result(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, struct iwl_device_cmd *cmd); -int iwlagn_send_bt_env(struct iwl_priv *priv, u8 action, u8 type); -void iwlagn_send_prio_tbl(struct iwl_priv *priv); +int iwl_send_bt_env(struct iwl_trans *trans, u8 action, u8 type); +void iwl_send_prio_tbl(struct iwl_trans *trans); int iwlagn_run_init_ucode(struct iwl_priv *priv); int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, enum iwl_ucode_type ucode_type); diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 76949106dafc..0da4b8ece11c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -122,7 +122,7 @@ int iwl_alloc_fw_desc(struct iwl_bus *bus, struct fw_desc *desc, /* * ucode */ -static int iwlagn_load_section(struct iwl_trans *trans, const char *name, +static int iwl_load_section(struct iwl_trans *trans, const char *name, struct fw_desc *image, u32 dst_addr) { struct iwl_bus *bus = bus(trans); @@ -188,7 +188,7 @@ static inline struct fw_img *iwl_get_ucode_image(struct iwl_trans *trans, return NULL; } -static int iwlagn_load_given_ucode(struct iwl_trans *trans, +static int iwl_load_given_ucode(struct iwl_trans *trans, enum iwl_ucode_type ucode_type) { int ret = 0; @@ -201,19 +201,19 @@ static int iwlagn_load_given_ucode(struct iwl_trans *trans, return -EINVAL; } - ret = iwlagn_load_section(trans, "INST", &image->code, + ret = iwl_load_section(trans, "INST", &image->code, IWLAGN_RTC_INST_LOWER_BOUND); if (ret) return ret; - return iwlagn_load_section(trans, "DATA", &image->data, + return iwl_load_section(trans, "DATA", &image->data, IWLAGN_RTC_DATA_LOWER_BOUND); } /* * Calibration */ -static int iwlagn_set_Xtal_calib(struct iwl_priv *priv) +static int iwl_set_Xtal_calib(struct iwl_priv *priv) { struct iwl_calib_xtal_freq_cmd cmd; __le16 *xtal_calib = @@ -225,7 +225,7 @@ static int iwlagn_set_Xtal_calib(struct iwl_priv *priv) return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); } -static int iwlagn_set_temperature_offset_calib(struct iwl_priv *priv) +static int iwl_set_temperature_offset_calib(struct iwl_priv *priv) { struct iwl_calib_temperature_offset_cmd cmd; __le16 *offset_calib = @@ -242,7 +242,7 @@ static int iwlagn_set_temperature_offset_calib(struct iwl_priv *priv) return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); } -static int iwlagn_set_temperature_offset_calib_v2(struct iwl_priv *priv) +static int iwl_set_temperature_offset_calib_v2(struct iwl_priv *priv) { struct iwl_calib_temperature_offset_v2_cmd cmd; __le16 *offset_calib_high = (__le16 *)iwl_eeprom_query_addr(priv, @@ -277,7 +277,7 @@ static int iwlagn_set_temperature_offset_calib_v2(struct iwl_priv *priv) return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); } -static int iwlagn_send_calib_cfg(struct iwl_priv *priv) +static int iwl_send_calib_cfg(struct iwl_trans *trans) { struct iwl_calib_cfg_cmd calib_cfg_cmd; struct iwl_host_cmd cmd = { @@ -293,7 +293,7 @@ static int iwlagn_send_calib_cfg(struct iwl_priv *priv) calib_cfg_cmd.ucd_calib_cfg.flags = IWL_CALIB_CFG_FLAG_SEND_COMPLETE_NTFY_MSK; - return iwl_trans_send_cmd(trans(priv), &cmd); + return iwl_trans_send_cmd(trans, &cmd); } int iwlagn_rx_calib_result(struct iwl_priv *priv, @@ -326,14 +326,14 @@ int iwlagn_init_alive_start(struct iwl_priv *priv) * no need to close the envlope since we are going * to load the runtime uCode later. */ - ret = iwlagn_send_bt_env(priv, IWL_BT_COEX_ENV_OPEN, + ret = iwl_send_bt_env(trans(priv), IWL_BT_COEX_ENV_OPEN, BT_COEX_PRIO_TBL_EVT_INIT_CALIB2); if (ret) return ret; } - ret = iwlagn_send_calib_cfg(priv); + ret = iwl_send_calib_cfg(trans(priv)); if (ret) return ret; @@ -343,15 +343,15 @@ int iwlagn_init_alive_start(struct iwl_priv *priv) */ if (priv->cfg->need_temp_offset_calib) { if (priv->cfg->temp_offset_v2) - return iwlagn_set_temperature_offset_calib_v2(priv); + return iwl_set_temperature_offset_calib_v2(priv); else - return iwlagn_set_temperature_offset_calib(priv); + return iwl_set_temperature_offset_calib(priv); } return 0; } -static int iwlagn_send_wimax_coex(struct iwl_priv *priv) +static int iwl_send_wimax_coex(struct iwl_priv *priv) { struct iwl_wimax_coex_cmd coex_cmd; @@ -379,7 +379,7 @@ static int iwlagn_send_wimax_coex(struct iwl_priv *priv) sizeof(coex_cmd), &coex_cmd); } -static const u8 iwlagn_bt_prio_tbl[BT_COEX_PRIO_TBL_EVT_MAX] = { +static const u8 iwl_bt_prio_tbl[BT_COEX_PRIO_TBL_EVT_MAX] = { ((BT_COEX_PRIO_TBL_PRIO_BYPASS << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS)), ((BT_COEX_PRIO_TBL_PRIO_BYPASS << IWL_BT_COEX_PRIO_TBL_PRIO_POS) | @@ -401,42 +401,42 @@ static const u8 iwlagn_bt_prio_tbl[BT_COEX_PRIO_TBL_EVT_MAX] = { 0, 0, 0, 0, 0, 0, 0 }; -void iwlagn_send_prio_tbl(struct iwl_priv *priv) +void iwl_send_prio_tbl(struct iwl_trans *trans) { struct iwl_bt_coex_prio_table_cmd prio_tbl_cmd; - memcpy(prio_tbl_cmd.prio_tbl, iwlagn_bt_prio_tbl, - sizeof(iwlagn_bt_prio_tbl)); - if (iwl_trans_send_cmd_pdu(trans(priv), + memcpy(prio_tbl_cmd.prio_tbl, iwl_bt_prio_tbl, + sizeof(iwl_bt_prio_tbl)); + if (iwl_trans_send_cmd_pdu(trans, REPLY_BT_COEX_PRIO_TABLE, CMD_SYNC, sizeof(prio_tbl_cmd), &prio_tbl_cmd)) - IWL_ERR(priv, "failed to send BT prio tbl command\n"); + IWL_ERR(trans, "failed to send BT prio tbl command\n"); } -int iwlagn_send_bt_env(struct iwl_priv *priv, u8 action, u8 type) +int iwl_send_bt_env(struct iwl_trans *trans, u8 action, u8 type) { struct iwl_bt_coex_prot_env_cmd env_cmd; int ret; env_cmd.action = action; env_cmd.type = type; - ret = iwl_trans_send_cmd_pdu(trans(priv), + ret = iwl_trans_send_cmd_pdu(trans, REPLY_BT_COEX_PROT_ENV, CMD_SYNC, sizeof(env_cmd), &env_cmd); if (ret) - IWL_ERR(priv, "failed to send BT env command\n"); + IWL_ERR(trans, "failed to send BT env command\n"); return ret; } -static int iwlagn_alive_notify(struct iwl_priv *priv) +static int iwl_alive_notify(struct iwl_priv *priv) { struct iwl_rxon_context *ctx; int ret; if (!priv->tx_cmd_pool) priv->tx_cmd_pool = - kmem_cache_create("iwlagn_dev_cmd", + kmem_cache_create("iwl_dev_cmd", sizeof(struct iwl_device_cmd), sizeof(void *), 0, NULL); @@ -447,12 +447,12 @@ static int iwlagn_alive_notify(struct iwl_priv *priv) for_each_context(priv, ctx) ctx->last_tx_rejected = false; - ret = iwlagn_send_wimax_coex(priv); + ret = iwl_send_wimax_coex(priv); if (ret) return ret; if (!priv->cfg->no_xtal_calib) { - ret = iwlagn_set_Xtal_calib(priv); + ret = iwl_set_Xtal_calib(priv); if (ret) return ret; } @@ -548,7 +548,7 @@ struct iwlagn_alive_data { u8 subtype; }; -static void iwlagn_alive_fn(struct iwl_priv *priv, +static void iwl_alive_fn(struct iwl_priv *priv, struct iwl_rx_packet *pkt, void *data) { @@ -587,12 +587,12 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, return ret; iwlagn_init_notification_wait(priv, &alive_wait, REPLY_ALIVE, - iwlagn_alive_fn, &alive_data); + iwl_alive_fn, &alive_data); old_type = priv->ucode_type; priv->ucode_type = ucode_type; - ret = iwlagn_load_given_ucode(trans(priv), ucode_type); + ret = iwl_load_given_ucode(trans(priv), ucode_type); if (ret) { priv->ucode_type = old_type; iwlagn_remove_notification(priv, &alive_wait); @@ -633,7 +633,7 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, msleep(5); } - ret = iwlagn_alive_notify(priv); + ret = iwl_alive_notify(priv); if (ret) { IWL_WARN(priv, "Could not complete ALIVE transition: %d\n", ret); -- cgit v1.2.3 From a96b724d5ad7d44184d6a871bc1d35b005f2d53e Mon Sep 17 00:00:00 2001 From: Don Fry Date: Fri, 2 Dec 2011 08:48:39 -0800 Subject: iwlwifi: move ucode_type from iwl_priv to iwl_shared Move the ucode_type variable from the iwl_priv to the iwl_shared structure with associated code changes. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-debugfs.c | 7 ++++--- drivers/net/wireless/iwlwifi/iwl-dev.h | 1 - drivers/net/wireless/iwlwifi/iwl-shared.h | 20 +++++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-testmode.c | 2 +- drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 10 +++++----- drivers/net/wireless/iwlwifi/iwl-trans.h | 7 ------- drivers/net/wireless/iwlwifi/iwl-ucode.c | 25 ++++++++++++------------ 7 files changed, 43 insertions(+), 29 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index 68b04f5b10ce..ccbcab40e78f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -234,11 +234,12 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file, /* default is to dump the entire data segment */ if (!priv->dbgfs_sram_offset && !priv->dbgfs_sram_len) { + struct iwl_trans *trans = trans(priv); priv->dbgfs_sram_offset = 0x800000; - if (priv->ucode_type == IWL_UCODE_INIT) - priv->dbgfs_sram_len = trans(priv)->ucode_init.data.len; + if (trans->shrd->ucode_type == IWL_UCODE_INIT) + priv->dbgfs_sram_len = trans->ucode_init.data.len; else - priv->dbgfs_sram_len = trans(priv)->ucode_rt.data.len; + priv->dbgfs_sram_len = trans->ucode_rt.data.len; } len = priv->dbgfs_sram_len; diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index cb24adbae082..0019a23d6d49 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -889,7 +889,6 @@ struct iwl_priv { u32 ucode_ver; /* version of ucode, copy of iwl_ucode.ver */ - enum iwl_ucode_type ucode_type; char firmware_name[25]; struct iwl_rxon_context contexts[NUM_IWL_RXON_CTX]; diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 30af95b19f78..aa4905a2e794 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -256,6 +256,23 @@ struct iwl_tid_data { struct iwl_ht_agg agg; }; +/** + * enum iwl_ucode_type + * + * The type of ucode currently loaded on the hardware. + * + * @IWL_UCODE_NONE: No ucode loaded + * @IWL_UCODE_REGULAR: Normal runtime ucode + * @IWL_UCODE_INIT: Initial ucode + * @IWL_UCODE_WOWLAN: Wake on Wireless enabled ucode + */ +enum iwl_ucode_type { + IWL_UCODE_NONE, + IWL_UCODE_REGULAR, + IWL_UCODE_INIT, + IWL_UCODE_WOWLAN, +}; + /** * struct iwl_shared - shared fields for all the layers of the driver * @@ -300,6 +317,9 @@ struct iwl_shared { struct iwl_tid_data tid_data[IWLAGN_STATION_COUNT][IWL_MAX_TID_COUNT]; wait_queue_head_t wait_command_queue; + + /* ucode related variables */ + enum iwl_ucode_type ucode_type; }; /*Whatever _m is (iwl_trans, iwl_priv, iwl_bus, these macros will work */ diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index 3c9762628760..ed2a3d749b1b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -710,7 +710,7 @@ static int iwl_testmode_sram(struct ieee80211_hw *hw, struct nlattr **tb) return -ENOMSG; } size = nla_get_u32(tb[IWL_TM_ATTR_SRAM_SIZE]); - switch (priv->ucode_type) { + switch (priv->shrd->ucode_type) { case IWL_UCODE_REGULAR: maxsize = trans(priv)->ucode_rt.data.len; break; diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index ee126f844a5c..becd92173ddd 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -595,7 +595,7 @@ static void iwl_dump_nic_error_log(struct iwl_trans *trans) IWL_TRANS_GET_PCIE_TRANS(trans); base = priv->device_pointers.error_event_table; - if (priv->ucode_type == IWL_UCODE_INIT) { + if (trans->shrd->ucode_type == IWL_UCODE_INIT) { if (!base) base = priv->init_errlog_ptr; } else { @@ -607,7 +607,7 @@ static void iwl_dump_nic_error_log(struct iwl_trans *trans) IWL_ERR(trans, "Not valid error log pointer 0x%08X for %s uCode\n", base, - (priv->ucode_type == IWL_UCODE_INIT) + (trans->shrd->ucode_type == IWL_UCODE_INIT) ? "Init" : "RT"); return; } @@ -710,7 +710,7 @@ static int iwl_print_event_log(struct iwl_trans *trans, u32 start_idx, return pos; base = priv->device_pointers.log_event_table; - if (priv->ucode_type == IWL_UCODE_INIT) { + if (trans->shrd->ucode_type == IWL_UCODE_INIT) { if (!base) base = priv->init_evtlog_ptr; } else { @@ -824,7 +824,7 @@ int iwl_dump_nic_event_log(struct iwl_trans *trans, bool full_log, struct iwl_priv *priv = priv(trans); base = priv->device_pointers.log_event_table; - if (priv->ucode_type == IWL_UCODE_INIT) { + if (trans->shrd->ucode_type == IWL_UCODE_INIT) { logsize = priv->init_evtlog_size; if (!base) base = priv->init_evtlog_ptr; @@ -838,7 +838,7 @@ int iwl_dump_nic_event_log(struct iwl_trans *trans, bool full_log, IWL_ERR(trans, "Invalid event log pointer 0x%08X for %s uCode\n", base, - (priv->ucode_type == IWL_UCODE_INIT) + (trans->shrd->ucode_type == IWL_UCODE_INIT) ? "Init" : "RT"); return -EINVAL; } diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 50227ebc0ee2..4a29b8ab998e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -220,13 +220,6 @@ struct fw_img { struct fw_desc data; /* firmware data image */ }; -enum iwl_ucode_type { - IWL_UCODE_NONE, - IWL_UCODE_REGULAR, - IWL_UCODE_INIT, - IWL_UCODE_WOWLAN, -}; - /** * struct iwl_trans - transport common data * @ops - pointer to iwl_trans_ops diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 0da4b8ece11c..1b23b99c474c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -579,27 +579,28 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, { struct iwl_notification_wait alive_wait; struct iwlagn_alive_data alive_data; + struct iwl_trans *trans = trans(priv); int ret; enum iwl_ucode_type old_type; - ret = iwl_trans_start_device(trans(priv)); + ret = iwl_trans_start_device(trans); if (ret) return ret; iwlagn_init_notification_wait(priv, &alive_wait, REPLY_ALIVE, iwl_alive_fn, &alive_data); - old_type = priv->ucode_type; - priv->ucode_type = ucode_type; + old_type = trans->shrd->ucode_type; + trans->shrd->ucode_type = ucode_type; - ret = iwl_load_given_ucode(trans(priv), ucode_type); + ret = iwl_load_given_ucode(trans, ucode_type); if (ret) { - priv->ucode_type = old_type; + trans->shrd->ucode_type = old_type; iwlagn_remove_notification(priv, &alive_wait); return ret; } - iwl_trans_kick_nic(trans(priv)); + iwl_trans_kick_nic(trans); /* * Some things may run in the background now, but we @@ -607,13 +608,13 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, */ ret = iwlagn_wait_notification(priv, &alive_wait, UCODE_ALIVE_TIMEOUT); if (ret) { - priv->ucode_type = old_type; + trans->shrd->ucode_type = old_type; return ret; } if (!alive_data.valid) { IWL_ERR(priv, "Loaded ucode is not valid!\n"); - priv->ucode_type = old_type; + trans->shrd->ucode_type = old_type; return -EIO; } @@ -623,9 +624,9 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, * skip it for WoWLAN. */ if (ucode_type != IWL_UCODE_WOWLAN) { - ret = iwl_verify_ucode(trans(priv), ucode_type); + ret = iwl_verify_ucode(trans, ucode_type); if (ret) { - priv->ucode_type = old_type; + trans->shrd->ucode_type = old_type; return ret; } @@ -637,7 +638,7 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, if (ret) { IWL_WARN(priv, "Could not complete ALIVE transition: %d\n", ret); - priv->ucode_type = old_type; + trans->shrd->ucode_type = old_type; return ret; } @@ -655,7 +656,7 @@ int iwlagn_run_init_ucode(struct iwl_priv *priv) if (!trans(priv)->ucode_init.code.len) return 0; - if (priv->ucode_type != IWL_UCODE_NONE) + if (priv->shrd->ucode_type != IWL_UCODE_NONE) return 0; iwlagn_init_notification_wait(priv, &calib_wait, -- cgit v1.2.3 From 79e3b16b7123018610f2754ce1bd219c5dd844f5 Mon Sep 17 00:00:00 2001 From: Don Fry Date: Fri, 2 Dec 2011 08:48:40 -0800 Subject: iwlwifi: move ucode notification from iwl_priv to iwl_shared Move the notification structures for ucode operations from the iwl_priv structure to the iwl_shared structure, with associated code changes. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 51 ------------------- drivers/net/wireless/iwlwifi/iwl-agn-rx.c | 16 +++--- drivers/net/wireless/iwlwifi/iwl-agn-rxon.c | 6 +-- drivers/net/wireless/iwlwifi/iwl-agn.h | 16 ------ drivers/net/wireless/iwlwifi/iwl-core.c | 15 +----- drivers/net/wireless/iwlwifi/iwl-dev.h | 33 ------------ drivers/net/wireless/iwlwifi/iwl-shared.h | 56 +++++++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-testmode.c | 6 +-- drivers/net/wireless/iwlwifi/iwl-ucode.c | 78 ++++++++++++++++++++++++++--- 9 files changed, 143 insertions(+), 134 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 0bc962217351..575d1bb8e8cc 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -934,57 +934,6 @@ u8 iwl_toggle_tx_ant(struct iwl_priv *priv, u8 ant, u8 valid) return ant; } -/* notification wait support */ -void iwlagn_init_notification_wait(struct iwl_priv *priv, - struct iwl_notification_wait *wait_entry, - u8 cmd, - void (*fn)(struct iwl_priv *priv, - struct iwl_rx_packet *pkt, - void *data), - void *fn_data) -{ - wait_entry->fn = fn; - wait_entry->fn_data = fn_data; - wait_entry->cmd = cmd; - wait_entry->triggered = false; - wait_entry->aborted = false; - - spin_lock_bh(&priv->notif_wait_lock); - list_add(&wait_entry->list, &priv->notif_waits); - spin_unlock_bh(&priv->notif_wait_lock); -} - -int iwlagn_wait_notification(struct iwl_priv *priv, - struct iwl_notification_wait *wait_entry, - unsigned long timeout) -{ - int ret; - - ret = wait_event_timeout(priv->notif_waitq, - wait_entry->triggered || wait_entry->aborted, - timeout); - - spin_lock_bh(&priv->notif_wait_lock); - list_del(&wait_entry->list); - spin_unlock_bh(&priv->notif_wait_lock); - - if (wait_entry->aborted) - return -EIO; - - /* return value is always >= 0 */ - if (ret <= 0) - return -ETIMEDOUT; - return 0; -} - -void iwlagn_remove_notification(struct iwl_priv *priv, - struct iwl_notification_wait *wait_entry) -{ - spin_lock_bh(&priv->notif_wait_lock); - list_del(&wait_entry->list); - spin_unlock_bh(&priv->notif_wait_lock); -} - #ifdef CONFIG_PM_SLEEP static void iwlagn_convert_p1k(u16 *p1k, __le16 *out) { diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index 087fd52e5727..90c55ea4cc39 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c @@ -1131,9 +1131,9 @@ void iwl_setup_rx_handlers(struct iwl_priv *priv) priv->rx_handlers[REPLY_TX] = iwlagn_rx_reply_tx; /* set up notification wait support */ - spin_lock_init(&priv->notif_wait_lock); - INIT_LIST_HEAD(&priv->notif_waits); - init_waitqueue_head(&priv->notif_waitq); + spin_lock_init(&priv->shrd->notif_wait_lock); + INIT_LIST_HEAD(&priv->shrd->notif_waits); + init_waitqueue_head(&priv->shrd->notif_waitq); /* Set up BT Rx handlers */ if (priv->cfg->lib->bt_rx_handler_setup) @@ -1152,11 +1152,11 @@ int iwl_rx_dispatch(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, * even if the RX handler consumes the RXB we have * access to it in the notification wait entry. */ - if (!list_empty(&priv->notif_waits)) { + if (!list_empty(&priv->shrd->notif_waits)) { struct iwl_notification_wait *w; - spin_lock(&priv->notif_wait_lock); - list_for_each_entry(w, &priv->notif_waits, list) { + spin_lock(&priv->shrd->notif_wait_lock); + list_for_each_entry(w, &priv->shrd->notif_waits, list) { if (w->cmd != pkt->hdr.cmd) continue; IWL_DEBUG_RX(priv, @@ -1167,9 +1167,9 @@ int iwl_rx_dispatch(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, if (w->fn) w->fn(priv, pkt, w->fn_data); } - spin_unlock(&priv->notif_wait_lock); + spin_unlock(&priv->shrd->notif_wait_lock); - wake_up_all(&priv->notif_waitq); + wake_up_all(&priv->shrd->notif_waitq); } if (priv->pre_rx_handler) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index 00b38711c15d..466e4ab544f7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c @@ -60,7 +60,7 @@ static int iwlagn_disable_pan(struct iwl_priv *priv, u8 old_dev_type = send->dev_type; int ret; - iwlagn_init_notification_wait(priv, &disable_wait, + iwl_init_notification_wait(priv->shrd, &disable_wait, REPLY_WIPAN_DEACTIVATION_COMPLETE, NULL, NULL); @@ -74,9 +74,9 @@ static int iwlagn_disable_pan(struct iwl_priv *priv, if (ret) { IWL_ERR(priv, "Error disabling PAN (%d)\n", ret); - iwlagn_remove_notification(priv, &disable_wait); + iwl_remove_notification(priv->shrd, &disable_wait); } else { - ret = iwlagn_wait_notification(priv, &disable_wait, HZ); + ret = iwl_wait_notification(priv->shrd, &disable_wait, HZ); if (ret) IWL_ERR(priv, "Timed out waiting for PAN disable\n"); } diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index 0db0a8fb5679..f2f10702754d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -356,22 +356,6 @@ static inline __le32 iwl_hw_set_rate_n_flags(u8 rate, u32 flags) void iwl_eeprom_enhanced_txpower(struct iwl_priv *priv); void iwl_eeprom_get_mac(const struct iwl_priv *priv, u8 *mac); -/* notification wait support */ -void __acquires(wait_entry) -iwlagn_init_notification_wait(struct iwl_priv *priv, - struct iwl_notification_wait *wait_entry, - u8 cmd, - void (*fn)(struct iwl_priv *priv, - struct iwl_rx_packet *pkt, - void *data), - void *fn_data); -int __must_check __releases(wait_entry) -iwlagn_wait_notification(struct iwl_priv *priv, - struct iwl_notification_wait *wait_entry, - unsigned long timeout); -void __releases(wait_entry) -iwlagn_remove_notification(struct iwl_priv *priv, - struct iwl_notification_wait *wait_entry); extern int iwlagn_init_alive_start(struct iwl_priv *priv); extern int iwl_alive_start(struct iwl_priv *priv); /* svtool */ diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index b24623b3bdb3..3b6f48bfe0e3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c @@ -836,19 +836,6 @@ void iwl_print_rx_config_cmd(struct iwl_priv *priv, } #endif -static void iwlagn_abort_notification_waits(struct iwl_priv *priv) -{ - unsigned long flags; - struct iwl_notification_wait *wait_entry; - - spin_lock_irqsave(&priv->notif_wait_lock, flags); - list_for_each_entry(wait_entry, &priv->notif_waits, list) - wait_entry->aborted = true; - spin_unlock_irqrestore(&priv->notif_wait_lock, flags); - - wake_up_all(&priv->notif_waitq); -} - void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand) { unsigned int reload_msec; @@ -860,7 +847,7 @@ void iwlagn_fw_error(struct iwl_priv *priv, bool ondemand) /* Cancel currently queued command. */ clear_bit(STATUS_HCMD_ACTIVE, &priv->shrd->status); - iwlagn_abort_notification_waits(priv); + iwl_abort_notification_waits(priv->shrd); /* Keep the restart process from trying to send host * commands by clearing the ready bit */ diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 0019a23d6d49..6f6a647d34f6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -689,35 +689,6 @@ struct iwl_force_reset { */ #define IWLAGN_EXT_BEACON_TIME_POS 22 -/** - * struct iwl_notification_wait - notification wait entry - * @list: list head for global list - * @fn: function called with the notification - * @cmd: command ID - * - * This structure is not used directly, to wait for a - * notification declare it on the stack, and call - * iwlagn_init_notification_wait() with appropriate - * parameters. Then do whatever will cause the ucode - * to notify the driver, and to wait for that then - * call iwlagn_wait_notification(). - * - * Each notification is one-shot. If at some point we - * need to support multi-shot notifications (which - * can't be allocated on the stack) we need to modify - * the code for them. - */ -struct iwl_notification_wait { - struct list_head list; - - void (*fn)(struct iwl_priv *priv, struct iwl_rx_packet *pkt, - void *data); - void *fn_data; - - u8 cmd; - bool triggered, aborted; -}; - struct iwl_rxon_context { struct ieee80211_vif *vif; @@ -992,10 +963,6 @@ struct iwl_priv { /* counts reply_tx error */ struct reply_tx_error_statistics reply_tx_stats; struct reply_agg_tx_error_statistics reply_agg_tx_stats; - /* notification wait support */ - struct list_head notif_waits; - spinlock_t notif_wait_lock; - wait_queue_head_t notif_waitq; /* remain-on-channel offload support */ struct ieee80211_channel *hw_roc_channel; diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index aa4905a2e794..39aa9cf5b847 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -273,6 +273,35 @@ enum iwl_ucode_type { IWL_UCODE_WOWLAN, }; +/** + * struct iwl_notification_wait - notification wait entry + * @list: list head for global list + * @fn: function called with the notification + * @cmd: command ID + * + * This structure is not used directly, to wait for a + * notification declare it on the stack, and call + * iwlagn_init_notification_wait() with appropriate + * parameters. Then do whatever will cause the ucode + * to notify the driver, and to wait for that then + * call iwlagn_wait_notification(). + * + * Each notification is one-shot. If at some point we + * need to support multi-shot notifications (which + * can't be allocated on the stack) we need to modify + * the code for them. + */ +struct iwl_notification_wait { + struct list_head list; + + void (*fn)(struct iwl_priv *priv, struct iwl_rx_packet *pkt, + void *data); + void *fn_data; + + u8 cmd; + bool triggered, aborted; +}; + /** * struct iwl_shared - shared fields for all the layers of the driver * @@ -290,6 +319,10 @@ enum iwl_ucode_type { * @sta_lock: protects the station table. * If lock and sta_lock are needed, lock must be acquired first. * @mutex: + * @ucode_type: indicator of loaded ucode image + * @notif_waits: things waiting for notification + * @notif_wait_lock: lock protecting notification + * @notif_waitq: head of notification wait queue */ struct iwl_shared { #ifdef CONFIG_IWLWIFI_DEBUG @@ -320,6 +353,11 @@ struct iwl_shared { /* ucode related variables */ enum iwl_ucode_type ucode_type; + + /* notification wait support */ + struct list_head notif_waits; + spinlock_t notif_wait_lock; + wait_queue_head_t notif_waitq; }; /*Whatever _m is (iwl_trans, iwl_priv, iwl_bus, these macros will work */ @@ -463,6 +501,24 @@ bool iwl_check_for_ct_kill(struct iwl_priv *priv); void iwl_stop_sw_queue(struct iwl_priv *priv, u8 ac); void iwl_wake_sw_queue(struct iwl_priv *priv, u8 ac); +/* notification wait support */ +void iwl_abort_notification_waits(struct iwl_shared *shrd); +void __acquires(wait_entry) +iwl_init_notification_wait(struct iwl_shared *shrd, + struct iwl_notification_wait *wait_entry, + u8 cmd, + void (*fn)(struct iwl_priv *priv, + struct iwl_rx_packet *pkt, + void *data), + void *fn_data); +int __must_check __releases(wait_entry) +iwl_wait_notification(struct iwl_shared *shrd, + struct iwl_notification_wait *wait_entry, + unsigned long timeout); +void __releases(wait_entry) +iwl_remove_notification(struct iwl_shared *shrd, + struct iwl_notification_wait *wait_entry); + #ifdef CONFIG_IWLWIFI_DEBUGFS void iwl_reset_traffic_log(struct iwl_priv *priv); #endif /* CONFIG_IWLWIFI_DEBUGFS */ diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index ed2a3d749b1b..ff72dbcfd52d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -373,7 +373,7 @@ static int iwl_testmode_cfg_init_calib(struct iwl_priv *priv) struct iwl_notification_wait calib_wait; int ret; - iwlagn_init_notification_wait(priv, &calib_wait, + iwl_init_notification_wait(priv->shrd, &calib_wait, CALIBRATION_COMPLETE_NOTIFICATION, NULL, NULL); ret = iwlagn_init_alive_start(priv); @@ -383,14 +383,14 @@ static int iwl_testmode_cfg_init_calib(struct iwl_priv *priv) goto cfg_init_calib_error; } - ret = iwlagn_wait_notification(priv, &calib_wait, 2 * HZ); + ret = iwl_wait_notification(priv->shrd, &calib_wait, 2 * HZ); if (ret) IWL_DEBUG_INFO(priv, "Error detecting" " CALIBRATION_COMPLETE_NOTIFICATION: %d\n", ret); return ret; cfg_init_calib_error: - iwlagn_remove_notification(priv, &calib_wait); + iwl_remove_notification(priv->shrd, &calib_wait); return ret; } diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 1b23b99c474c..b365de457b1b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -571,6 +571,70 @@ static void iwl_alive_fn(struct iwl_priv *priv, alive_data->valid = palive->is_valid == UCODE_VALID_OK; } +/* notification wait support */ +void iwl_init_notification_wait(struct iwl_shared *shrd, + struct iwl_notification_wait *wait_entry, + u8 cmd, + void (*fn)(struct iwl_priv *priv, + struct iwl_rx_packet *pkt, + void *data), + void *fn_data) +{ + wait_entry->fn = fn; + wait_entry->fn_data = fn_data; + wait_entry->cmd = cmd; + wait_entry->triggered = false; + wait_entry->aborted = false; + + spin_lock_bh(&shrd->notif_wait_lock); + list_add(&wait_entry->list, &shrd->notif_waits); + spin_unlock_bh(&shrd->notif_wait_lock); +} + +int iwl_wait_notification(struct iwl_shared *shrd, + struct iwl_notification_wait *wait_entry, + unsigned long timeout) +{ + int ret; + + ret = wait_event_timeout(shrd->notif_waitq, + wait_entry->triggered || wait_entry->aborted, + timeout); + + spin_lock_bh(&shrd->notif_wait_lock); + list_del(&wait_entry->list); + spin_unlock_bh(&shrd->notif_wait_lock); + + if (wait_entry->aborted) + return -EIO; + + /* return value is always >= 0 */ + if (ret <= 0) + return -ETIMEDOUT; + return 0; +} + +void iwl_remove_notification(struct iwl_shared *shrd, + struct iwl_notification_wait *wait_entry) +{ + spin_lock_bh(&shrd->notif_wait_lock); + list_del(&wait_entry->list); + spin_unlock_bh(&shrd->notif_wait_lock); +} + +void iwl_abort_notification_waits(struct iwl_shared *shrd) +{ + unsigned long flags; + struct iwl_notification_wait *wait_entry; + + spin_lock_irqsave(&shrd->notif_wait_lock, flags); + list_for_each_entry(wait_entry, &shrd->notif_waits, list) + wait_entry->aborted = true; + spin_unlock_irqrestore(&shrd->notif_wait_lock, flags); + + wake_up_all(&shrd->notif_waitq); +} + #define UCODE_ALIVE_TIMEOUT HZ #define UCODE_CALIB_TIMEOUT (2*HZ) @@ -587,7 +651,7 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, if (ret) return ret; - iwlagn_init_notification_wait(priv, &alive_wait, REPLY_ALIVE, + iwl_init_notification_wait(trans->shrd, &alive_wait, REPLY_ALIVE, iwl_alive_fn, &alive_data); old_type = trans->shrd->ucode_type; @@ -596,7 +660,7 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, ret = iwl_load_given_ucode(trans, ucode_type); if (ret) { trans->shrd->ucode_type = old_type; - iwlagn_remove_notification(priv, &alive_wait); + iwl_remove_notification(trans->shrd, &alive_wait); return ret; } @@ -606,7 +670,8 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, * Some things may run in the background now, but we * just wait for the ALIVE notification here. */ - ret = iwlagn_wait_notification(priv, &alive_wait, UCODE_ALIVE_TIMEOUT); + ret = iwl_wait_notification(trans->shrd, &alive_wait, + UCODE_ALIVE_TIMEOUT); if (ret) { trans->shrd->ucode_type = old_type; return ret; @@ -659,7 +724,7 @@ int iwlagn_run_init_ucode(struct iwl_priv *priv) if (priv->shrd->ucode_type != IWL_UCODE_NONE) return 0; - iwlagn_init_notification_wait(priv, &calib_wait, + iwl_init_notification_wait(priv->shrd, &calib_wait, CALIBRATION_COMPLETE_NOTIFICATION, NULL, NULL); @@ -676,12 +741,13 @@ int iwlagn_run_init_ucode(struct iwl_priv *priv) * Some things may run in the background now, but we * just wait for the calibration complete notification. */ - ret = iwlagn_wait_notification(priv, &calib_wait, UCODE_CALIB_TIMEOUT); + ret = iwl_wait_notification(priv->shrd, &calib_wait, + UCODE_CALIB_TIMEOUT); goto out; error: - iwlagn_remove_notification(priv, &calib_wait); + iwl_remove_notification(priv->shrd, &calib_wait); out: /* Whatever happened, stop the device */ iwl_trans_stop_device(trans(priv)); -- cgit v1.2.3 From 91ddff8a3b9cc7ac2252aca138220939cf6cc2cf Mon Sep 17 00:00:00 2001 From: Philipp Dreimann Date: Wed, 7 Dec 2011 13:43:31 -0600 Subject: rtl8192{ce,cu,de,se}: avoid problems because of possible ERFOFF -> ERFSLEEP transition In drivers rtl8192ce, rtl8192cu, rtl8192se, and rtl8192de, break statements would allow ppsc->rfpwr_state to be changed to ERFSLEEP even though the device is actually in ERFOFF. Signed-off-by: Philipp Dreimann Signed-off-by: Larry Finger Cc: Stable Cc: Chaoming Li Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/rtl8192ce/phy.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192cu/phy.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192de/phy.c | 2 +- drivers/net/wireless/rtlwifi/rtl8192se/phy.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c index 592a10ac5929..3b585aadabfc 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192ce/phy.c @@ -569,7 +569,7 @@ static bool _rtl92ce_phy_set_rf_power_state(struct ieee80211_hw *hw, } case ERFSLEEP:{ if (ppsc->rfpwr_state == ERFOFF) - break; + return false; for (queue_id = 0, i = 0; queue_id < RTL_PCI_MAX_TX_QUEUE_COUNT;) { ring = &pcipriv->dev.tx_ring[queue_id]; diff --git a/drivers/net/wireless/rtlwifi/rtl8192cu/phy.c b/drivers/net/wireless/rtlwifi/rtl8192cu/phy.c index 72852900df84..e49cf2244c75 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192cu/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192cu/phy.c @@ -548,7 +548,7 @@ static bool _rtl92cu_phy_set_rf_power_state(struct ieee80211_hw *hw, break; case ERFSLEEP: if (ppsc->rfpwr_state == ERFOFF) - break; + return false; for (queue_id = 0, i = 0; queue_id < RTL_PCI_MAX_TX_QUEUE_COUNT;) { ring = &pcipriv->dev.tx_ring[queue_id]; diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/phy.c b/drivers/net/wireless/rtlwifi/rtl8192de/phy.c index 3ac7af1c5509..0883349e1c83 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192de/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192de/phy.c @@ -3374,7 +3374,7 @@ bool rtl92d_phy_set_rf_power_state(struct ieee80211_hw *hw, break; case ERFSLEEP: if (ppsc->rfpwr_state == ERFOFF) - break; + return false; for (queue_id = 0, i = 0; queue_id < RTL_PCI_MAX_TX_QUEUE_COUNT;) { diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c index f27171af979c..f10ac1ad9087 100644 --- a/drivers/net/wireless/rtlwifi/rtl8192se/phy.c +++ b/drivers/net/wireless/rtlwifi/rtl8192se/phy.c @@ -602,7 +602,7 @@ bool rtl92s_phy_set_rf_power_state(struct ieee80211_hw *hw, } case ERFSLEEP: if (ppsc->rfpwr_state == ERFOFF) - break; + return false; for (queue_id = 0, i = 0; queue_id < RTL_PCI_MAX_TX_QUEUE_COUNT;) { -- cgit v1.2.3 From c8e8868e3bf2ee0b6e606ce43af023b5f6edc954 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 16 Nov 2011 13:08:40 +0100 Subject: ath9k: always issue a full hw reset after waking up from full-sleep mode After waking up from full sleep, registers are accessible, but rx/tx typically fails. A fast channel change will not recover from this, so ensure that a full-sleep -> wake transition is always followed by a full reset. The reason why this hasn't created any serious problems yet is that it's hidden by the (wrong) behavior of enabling/disabling the radio when the wiphy idle state changes. Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/main.c | 12 ++++++++++-- drivers/net/wireless/ath/ath9k/xmit.c | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index fd59c1f25c43..3733828e72bc 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -118,7 +118,7 @@ void ath9k_ps_restore(struct ath_softc *sc) if (--sc->ps_usecount != 0) goto unlock; - if (sc->ps_idle) + if (sc->ps_idle && (sc->ps_flags & PS_WAIT_FOR_TX_ACK)) mode = ATH9K_PM_FULL_SLEEP; else if (sc->ps_enabled && !(sc->ps_flags & (PS_WAIT_FOR_BEACON | @@ -332,7 +332,8 @@ static int ath_reset_internal(struct ath_softc *sc, struct ath9k_channel *hchan, hchan = ah->curchan; } - if (fastcc && !ath9k_hw_check_alive(ah)) + if (fastcc && (ah->chip_fullsleep || + !ath9k_hw_check_alive(ah))) fastcc = false; if (!ath_prepare_reset(sc, retry_tx, flush)) @@ -1183,6 +1184,13 @@ static void ath9k_tx(struct ieee80211_hw *hw, struct sk_buff *skb) } } + /* + * Cannot tx while the hardware is in full sleep, it first needs a full + * chip reset to recover from that + */ + if (unlikely(sc->sc_ah->power_mode == ATH9K_PM_FULL_SLEEP)) + goto exit; + if (unlikely(sc->sc_ah->power_mode != ATH9K_PM_AWAKE)) { /* * We are using PS-Poll and mac80211 can request TX while in diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c index 80639e3e4ac9..9e65c3198ca7 100644 --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c @@ -1954,7 +1954,7 @@ static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb, skb_pull(skb, padsize); } - if (sc->ps_flags & PS_WAIT_FOR_TX_ACK) { + if ((sc->ps_flags & PS_WAIT_FOR_TX_ACK) && !txq->axq_depth) { sc->ps_flags &= ~PS_WAIT_FOR_TX_ACK; ath_dbg(common, ATH_DBG_PS, "Going back to sleep after having received TX status (0x%lx)\n", -- cgit v1.2.3 From c0c1174144dd619456be5930d733028a055ef425 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 16 Nov 2011 13:08:41 +0100 Subject: ath9k: rework power state handling Turning off the radio when mac80211 tells the driver that it's idle is not a good idea, as idle interfaces might still occasionally scan or send packets. The only time the radio can be safely turned off is when drv_stop has been called. In the mean time, use sc->ps_idle only to indicate network sleep vs full sleep. Move the LED GPIO changes out of the PCI suspend/resume path, the start/stop functions already take care of that. Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/main.c | 156 ++++++++++------------------------ drivers/net/wireless/ath/ath9k/pci.c | 21 +---- 2 files changed, 47 insertions(+), 130 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 3733828e72bc..8b0feecf3fae 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -887,82 +887,6 @@ chip_reset: #undef SCHED_INTR } -static void ath_radio_enable(struct ath_softc *sc, struct ieee80211_hw *hw) -{ - struct ath_hw *ah = sc->sc_ah; - struct ath_common *common = ath9k_hw_common(ah); - struct ieee80211_channel *channel = hw->conf.channel; - int r; - - ath9k_ps_wakeup(sc); - spin_lock_bh(&sc->sc_pcu_lock); - atomic_set(&ah->intr_ref_cnt, -1); - - ath9k_hw_configpcipowersave(ah, false); - - if (!ah->curchan) - ah->curchan = ath9k_cmn_get_curchannel(sc->hw, ah); - - r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false); - if (r) { - ath_err(common, - "Unable to reset channel (%u MHz), reset status %d\n", - channel->center_freq, r); - } - - ath_complete_reset(sc, true); - - /* Enable LED */ - ath9k_hw_cfg_output(ah, ah->led_pin, - AR_GPIO_OUTPUT_MUX_AS_OUTPUT); - ath9k_hw_set_gpio(ah, ah->led_pin, 0); - - spin_unlock_bh(&sc->sc_pcu_lock); - - ath9k_ps_restore(sc); -} - -void ath_radio_disable(struct ath_softc *sc, struct ieee80211_hw *hw) -{ - struct ath_hw *ah = sc->sc_ah; - struct ieee80211_channel *channel = hw->conf.channel; - int r; - - ath9k_ps_wakeup(sc); - - ath_cancel_work(sc); - - spin_lock_bh(&sc->sc_pcu_lock); - - /* - * Keep the LED on when the radio is disabled - * during idle unassociated state. - */ - if (!sc->ps_idle) { - ath9k_hw_set_gpio(ah, ah->led_pin, 1); - ath9k_hw_cfg_gpio_input(ah, ah->led_pin); - } - - ath_prepare_reset(sc, false, true); - - if (!ah->curchan) - ah->curchan = ath9k_cmn_get_curchannel(hw, ah); - - r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false); - if (r) { - ath_err(ath9k_hw_common(sc->sc_ah), - "Unable to reset channel (%u MHz), reset status %d\n", - channel->center_freq, r); - } - - ath9k_hw_phy_disable(ah); - - ath9k_hw_configpcipowersave(ah, true); - - spin_unlock_bh(&sc->sc_pcu_lock); - ath9k_ps_restore(sc); -} - static int ath_reset(struct ath_softc *sc, bool retry_tx) { int r; @@ -1098,6 +1022,9 @@ static int ath9k_start(struct ieee80211_hw *hw) * and then setup of the interrupt mask. */ spin_lock_bh(&sc->sc_pcu_lock); + + atomic_set(&ah->intr_ref_cnt, -1); + r = ath9k_hw_reset(ah, init_channel, ah->caldata, false); if (r) { ath_err(common, @@ -1139,6 +1066,18 @@ static int ath9k_start(struct ieee80211_hw *hw) goto mutex_unlock; } + if (ah->led_pin >= 0) { + ath9k_hw_cfg_output(ah, ah->led_pin, + AR_GPIO_OUTPUT_MUX_AS_OUTPUT); + ath9k_hw_set_gpio(ah, ah->led_pin, 0); + } + + /* + * Reset key cache to sane defaults (all entries cleared) instead of + * semi-random values after suspend/resume. + */ + ath9k_cmn_init_crypto(sc->sc_ah); + spin_unlock_bh(&sc->sc_pcu_lock); if ((ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE) && @@ -1237,6 +1176,7 @@ static void ath9k_stop(struct ieee80211_hw *hw) struct ath_softc *sc = hw->priv; struct ath_hw *ah = sc->sc_ah; struct ath_common *common = ath9k_hw_common(ah); + bool prev_idle; mutex_lock(&sc->mutex); @@ -1267,35 +1207,45 @@ static void ath9k_stop(struct ieee80211_hw *hw) * before setting the invalid flag. */ ath9k_hw_disable_interrupts(ah); - if (!(sc->sc_flags & SC_OP_INVALID)) { - ath_drain_all_txq(sc, false); - ath_stoprecv(sc); - ath9k_hw_phy_disable(ah); - } else - sc->rx.rxlink = NULL; + spin_unlock_bh(&sc->sc_pcu_lock); + + /* we can now sync irq and kill any running tasklets, since we already + * disabled interrupts and not holding a spin lock */ + synchronize_irq(sc->irq); + tasklet_kill(&sc->intr_tq); + tasklet_kill(&sc->bcon_tasklet); + + prev_idle = sc->ps_idle; + sc->ps_idle = true; + + spin_lock_bh(&sc->sc_pcu_lock); + + if (ah->led_pin >= 0) { + ath9k_hw_set_gpio(ah, ah->led_pin, 1); + ath9k_hw_cfg_gpio_input(ah, ah->led_pin); + } + + ath_prepare_reset(sc, false, true); if (sc->rx.frag) { dev_kfree_skb_any(sc->rx.frag); sc->rx.frag = NULL; } - /* disable HAL and put h/w to sleep */ - ath9k_hw_disable(ah); + if (!ah->curchan) + ah->curchan = ath9k_cmn_get_curchannel(hw, ah); - spin_unlock_bh(&sc->sc_pcu_lock); + ath9k_hw_reset(ah, ah->curchan, ah->caldata, false); + ath9k_hw_phy_disable(ah); - /* we can now sync irq and kill any running tasklets, since we already - * disabled interrupts and not holding a spin lock */ - synchronize_irq(sc->irq); - tasklet_kill(&sc->intr_tq); - tasklet_kill(&sc->bcon_tasklet); + ath9k_hw_configpcipowersave(ah, true); - ath9k_ps_restore(sc); + spin_unlock_bh(&sc->sc_pcu_lock); - sc->ps_idle = true; - ath_radio_disable(sc, hw); + ath9k_ps_restore(sc); sc->sc_flags |= SC_OP_INVALID; + sc->ps_idle = prev_idle; mutex_unlock(&sc->mutex); @@ -1635,8 +1585,8 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed) struct ath_hw *ah = sc->sc_ah; struct ath_common *common = ath9k_hw_common(ah); struct ieee80211_conf *conf = &hw->conf; - bool disable_radio = false; + ath9k_ps_wakeup(sc); mutex_lock(&sc->mutex); /* @@ -1645,16 +1595,8 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed) * of the changes. Likewise we must only disable the radio towards * the end. */ - if (changed & IEEE80211_CONF_CHANGE_IDLE) { + if (changed & IEEE80211_CONF_CHANGE_IDLE) sc->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE); - if (!sc->ps_idle) { - ath_radio_enable(sc, hw); - ath_dbg(common, ATH_DBG_CONFIG, - "not-idle: enabling radio\n"); - } else { - disable_radio = true; - } - } /* * We just prepare to enable PS. We have to wait until our AP has @@ -1760,18 +1702,12 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed) ath_dbg(common, ATH_DBG_CONFIG, "Set power: %d\n", conf->power_level); sc->config.txpowlimit = 2 * conf->power_level; - ath9k_ps_wakeup(sc); ath9k_cmn_update_txpow(ah, sc->curtxpow, sc->config.txpowlimit, &sc->curtxpow); - ath9k_ps_restore(sc); - } - - if (disable_radio) { - ath_dbg(common, ATH_DBG_CONFIG, "idle: disabling radio\n"); - ath_radio_disable(sc, hw); } mutex_unlock(&sc->mutex); + ath9k_ps_restore(sc); return 0; } diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c index 2dcdf63cb390..a439edc5dc06 100644 --- a/drivers/net/wireless/ath/ath9k/pci.c +++ b/drivers/net/wireless/ath/ath9k/pci.c @@ -307,12 +307,11 @@ static int ath_pci_suspend(struct device *device) struct ieee80211_hw *hw = pci_get_drvdata(pdev); struct ath_softc *sc = hw->priv; - ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 1); - /* The device has to be moved to FULLSLEEP forcibly. * Otherwise the chip never moved to full sleep, * when no interface is up. */ + ath9k_hw_disable(sc->sc_ah); ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_FULL_SLEEP); return 0; @@ -321,8 +320,6 @@ static int ath_pci_suspend(struct device *device) static int ath_pci_resume(struct device *device) { struct pci_dev *pdev = to_pci_dev(device); - struct ieee80211_hw *hw = pci_get_drvdata(pdev); - struct ath_softc *sc = hw->priv; u32 val; /* @@ -334,22 +331,6 @@ static int ath_pci_resume(struct device *device) if ((val & 0x0000ff00) != 0) pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); - ath9k_ps_wakeup(sc); - /* Enable LED */ - ath9k_hw_cfg_output(sc->sc_ah, sc->sc_ah->led_pin, - AR_GPIO_OUTPUT_MUX_AS_OUTPUT); - ath9k_hw_set_gpio(sc->sc_ah, sc->sc_ah->led_pin, 0); - - /* - * Reset key cache to sane defaults (all entries cleared) instead of - * semi-random values after suspend/resume. - */ - ath9k_cmn_init_crypto(sc->sc_ah); - ath9k_ps_restore(sc); - - sc->ps_idle = true; - ath_radio_disable(sc, hw); - return 0; } -- cgit v1.2.3 From 9df0d6a20a4e6d15684cc8f2e3f0155be0801592 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 16 Nov 2011 13:08:42 +0100 Subject: ath9k: only drop packets in drv_flush when asked to Recently more places in mac80211 call drv_flush to ensure proper order for state changes wrt. powersave, channel changes, etc. On some systems such calls lead to spurious logspam about failing to stop tx dma, as well as hardware resets that go along with that. Instead of dropping packets in a place where it's completely unnecessary, only do it when drop == true. Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/main.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 8b0feecf3fae..36315c83d4ca 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -2275,9 +2275,6 @@ static void ath9k_flush(struct ieee80211_hw *hw, bool drop) return; } - if (drop) - timeout = 1; - for (j = 0; j < timeout; j++) { bool npend = false; @@ -2295,21 +2292,22 @@ static void ath9k_flush(struct ieee80211_hw *hw, bool drop) } if (!npend) - goto out; + break; } - ath9k_ps_wakeup(sc); - spin_lock_bh(&sc->sc_pcu_lock); - drain_txq = ath_drain_all_txq(sc, false); - spin_unlock_bh(&sc->sc_pcu_lock); + if (drop) { + ath9k_ps_wakeup(sc); + spin_lock_bh(&sc->sc_pcu_lock); + drain_txq = ath_drain_all_txq(sc, false); + spin_unlock_bh(&sc->sc_pcu_lock); - if (!drain_txq) - ath_reset(sc, false); + if (!drain_txq) + ath_reset(sc, false); - ath9k_ps_restore(sc); - ieee80211_wake_queues(hw); + ath9k_ps_restore(sc); + ieee80211_wake_queues(hw); + } -out: ieee80211_queue_delayed_work(hw, &sc->tx_complete_work, 0); mutex_unlock(&sc->mutex); } -- cgit v1.2.3 From daa1b6ee45170404efb3002ae2ff06e572f7ceba Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 16 Nov 2011 13:08:43 +0100 Subject: ath9k: cancel all workqueue activity when going idle Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 36315c83d4ca..714c7d82eb53 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -1595,8 +1595,11 @@ static int ath9k_config(struct ieee80211_hw *hw, u32 changed) * of the changes. Likewise we must only disable the radio towards * the end. */ - if (changed & IEEE80211_CONF_CHANGE_IDLE) + if (changed & IEEE80211_CONF_CHANGE_IDLE) { sc->ps_idle = !!(conf->flags & IEEE80211_CONF_IDLE); + if (sc->ps_idle) + ath_cancel_work(sc); + } /* * We just prepare to enable PS. We have to wait until our AP has -- cgit v1.2.3 From a9b2ce03b2a071420c10f3873869480fbb7f4493 Mon Sep 17 00:00:00 2001 From: Nikolay Martynov Date: Fri, 2 Dec 2011 22:39:14 -0500 Subject: ath9k: trivial: cosmetic fix in calibration debug log Add missed space and change typo in calibration debugging log. Signed-off-by: Nikolay Martynov Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9002_calib.c | 2 +- drivers/net/wireless/ath/ath9k/ar9003_calib.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/ar9002_calib.c b/drivers/net/wireless/ath/ath9k/ar9002_calib.c index 88279e325dca..157337febc2b 100644 --- a/drivers/net/wireless/ath/ath9k/ar9002_calib.c +++ b/drivers/net/wireless/ath/ath9k/ar9002_calib.c @@ -203,7 +203,7 @@ static void ar9002_hw_iqcalibrate(struct ath_hw *ah, u8 numChains) i); ath_dbg(common, ATH_DBG_CALIBRATE, - "Orignal: Chn %diq_corr_meas = 0x%08x\n", + "Original: Chn %d iq_corr_meas = 0x%08x\n", i, ah->totalIqCorrMeas[i]); iqCorrNeg = 0; diff --git a/drivers/net/wireless/ath/ath9k/ar9003_calib.c b/drivers/net/wireless/ath/ath9k/ar9003_calib.c index ddeba8693fab..23b3a6c57800 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c @@ -226,7 +226,7 @@ static void ar9003_hw_iqcalibrate(struct ath_hw *ah, u8 numChains) i); ath_dbg(common, ATH_DBG_CALIBRATE, - "Orignal: Chn %diq_corr_meas = 0x%08x\n", + "Original: Chn %d iq_corr_meas = 0x%08x\n", i, ah->totalIqCorrMeas[i]); iqCorrNeg = 0; -- cgit v1.2.3 From 86951359c1ee35dbae5e11d7cd959e2cb8e6051f Mon Sep 17 00:00:00 2001 From: Nikolay Martynov Date: Fri, 2 Dec 2011 22:39:15 -0500 Subject: ath9k: change calibration debug log to output all calibration types To help debugging write a log entry when long calibration, short calibration or ANI is performed. Signed-off-by: Nikolay Martynov Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 714c7d82eb53..8c36362da1ea 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -562,7 +562,6 @@ void ath_ani_calibrate(unsigned long data) /* Long calibration runs independently of short calibration. */ if ((timestamp - common->ani.longcal_timer) >= long_cal_interval) { longcal = true; - ath_dbg(common, ATH_DBG_ANI, "longcal @%lu\n", jiffies); common->ani.longcal_timer = timestamp; } @@ -570,8 +569,6 @@ void ath_ani_calibrate(unsigned long data) if (!common->ani.caldone) { if ((timestamp - common->ani.shortcal_timer) >= short_cal_interval) { shortcal = true; - ath_dbg(common, ATH_DBG_ANI, - "shortcal @%lu\n", jiffies); common->ani.shortcal_timer = timestamp; common->ani.resetcal_timer = timestamp; } @@ -606,6 +603,11 @@ void ath_ani_calibrate(unsigned long data) ah->rxchainmask, longcal); } + ath_dbg(common, ATH_DBG_ANI, + "Calibration @%lu finished: %s %s %s, caldone: %s\n", jiffies, + longcal ? "long" : "", shortcal ? "short" : "", + aniflag ? "ani" : "", common->ani.caldone ? "true" : "false"); + ath9k_ps_restore(sc); set_timer: -- cgit v1.2.3 From 4279425cef58808c0cdc616b8fff17c8308617bd Mon Sep 17 00:00:00 2001 From: Nikolay Martynov Date: Fri, 2 Dec 2011 22:39:16 -0500 Subject: ath9k: use config.enable_ani to check if ani should be performed Currently in ath9k code there is an attempt which is meant to disable ANI for ar9100 and ar9340. But it doesn't really achieve this. All it does is disable ANI init and setup (i.e. calls to ath9k_hw_ani_setup and ath9k_hw_ani_init). Since ath9k_hw_ani_setup is not called ah->config.ani_poll_interval is never initialized (i.e. it is always zero) and ath_ani_calibrate always executes ANI procedures (over uninitialized ANI parameters). Moreover, ath_ani_calibrate is being called each 1ms because common->ani.timer is set to zero interval because ah->config.ani_poll_interval==0 (and thus smallest value of all intervals). Normally it should not be called this often. This patch changes the code so config.enable_ani is used to check if ANI should be performed. config.enable_ani is initialized to true by default. This patch sets it to false for ar9100 and ar9340. Signed-off-by: Nikolay Martynov Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/htc_drv_main.c | 5 +++-- drivers/net/wireless/ath/ath9k/hw.c | 6 +++++- drivers/net/wireless/ath/ath9k/main.c | 5 +++-- 3 files changed, 11 insertions(+), 5 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c index 0b9a0e8a4958..f8ce4ea6f65c 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c @@ -808,7 +808,8 @@ void ath9k_htc_ani_work(struct work_struct *work) } /* Verify whether we must check ANI */ - if ((timestamp - common->ani.checkani_timer) >= ATH_ANI_POLLINTERVAL) { + if (ah->config.enable_ani && + (timestamp - common->ani.checkani_timer) >= ATH_ANI_POLLINTERVAL) { aniflag = true; common->ani.checkani_timer = timestamp; } @@ -838,7 +839,7 @@ set_timer: * short calibration and long calibration. */ cal_interval = ATH_LONG_CALINTERVAL; - if (priv->ah->config.enable_ani) + if (ah->config.enable_ani) cal_interval = min(cal_interval, (u32)ATH_ANI_POLLINTERVAL); if (!common->ani.caldone) cal_interval = min(cal_interval, (u32)short_cal_interval); diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index caf572cf270f..9871072bbf01 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -504,7 +504,7 @@ static int ath9k_hw_post_init(struct ath_hw *ah) return ecode; } - if (!AR_SREV_9100(ah) && !AR_SREV_9340(ah)) { + if (ah->config.enable_ani) { ath9k_hw_ani_setup(ah); ath9k_hw_ani_init(ah); } @@ -610,6 +610,10 @@ static int __ath9k_hw_init(struct ath_hw *ah) if (!AR_SREV_9300_20_OR_LATER(ah)) ah->ani_function &= ~ATH9K_ANI_MRC_CCK; + /* disable ANI for 9100 and 9340 */ + if (AR_SREV_9100(ah) || AR_SREV_9340(ah)) + ah->config.enable_ani = false; + ath9k_hw_init_mode_regs(ah); if (!ah->is_pciexpress) diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 8c36362da1ea..5007297c9447 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -582,8 +582,9 @@ void ath_ani_calibrate(unsigned long data) } /* Verify whether we must check ANI */ - if ((timestamp - common->ani.checkani_timer) >= - ah->config.ani_poll_interval) { + if (sc->sc_ah->config.enable_ani + && (timestamp - common->ani.checkani_timer) >= + ah->config.ani_poll_interval) { aniflag = true; common->ani.checkani_timer = timestamp; } -- cgit v1.2.3 From 4f17c48e3902c823e4af68d2de9546f5b707533d Mon Sep 17 00:00:00 2001 From: Nikolay Martynov Date: Tue, 6 Dec 2011 21:57:17 -0500 Subject: ath9k: enable ANI for ar9100 chips Enable ANI for ar9100 since it seems to be working fine (and as a matter of fact ANI was always performed for ar9100 since code which was supposed to disable it didn't achieve this goal). This patch sets config.enable_ani to default (true) value for ar9100. Signed-off-by: Nikolay Martynov Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/hw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 9871072bbf01..7f8fc65f2cb4 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -610,8 +610,8 @@ static int __ath9k_hw_init(struct ath_hw *ah) if (!AR_SREV_9300_20_OR_LATER(ah)) ah->ani_function &= ~ATH9K_ANI_MRC_CCK; - /* disable ANI for 9100 and 9340 */ - if (AR_SREV_9100(ah) || AR_SREV_9340(ah)) + /* disable ANI for 9340 */ + if (AR_SREV_9340(ah)) ah->config.enable_ani = false; ath9k_hw_init_mode_regs(ah); -- cgit v1.2.3 From abc47470ef63cdde2efdf358ae373afb16f358c0 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 6 Dec 2011 12:15:05 +0200 Subject: wl12xx: fix testmode test/interrogate commands fix several issues in testmode test/interrogate commands: 1. check the driver state is not OFF. 2. wakeup the chip from elp (if needed) 3. fix memory leak in wl1271_tm_cmd_interrogate() Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/testmode.c | 72 +++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 19 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/testmode.c b/drivers/net/wireless/wl12xx/testmode.c index 61fff45686ad..2f9ebff2ded3 100644 --- a/drivers/net/wireless/wl12xx/testmode.c +++ b/drivers/net/wireless/wl12xx/testmode.c @@ -29,6 +29,7 @@ #include "debug.h" #include "acx.h" #include "reg.h" +#include "ps.h" #define WL1271_TM_MAX_DATA_LENGTH 1024 @@ -88,31 +89,47 @@ static int wl1271_tm_cmd_test(struct wl1271 *wl, struct nlattr *tb[]) return -EMSGSIZE; mutex_lock(&wl->mutex); - ret = wl1271_cmd_test(wl, buf, buf_len, answer); - mutex_unlock(&wl->mutex); + if (wl->state == WL1271_STATE_OFF) { + ret = -EINVAL; + goto out; + } + + ret = wl1271_ps_elp_wakeup(wl); + if (ret < 0) + goto out; + + ret = wl1271_cmd_test(wl, buf, buf_len, answer); if (ret < 0) { wl1271_warning("testmode cmd test failed: %d", ret); - return ret; + goto out_sleep; } if (answer) { len = nla_total_size(buf_len); skb = cfg80211_testmode_alloc_reply_skb(wl->hw->wiphy, len); - if (!skb) - return -ENOMEM; + if (!skb) { + ret = -ENOMEM; + goto out_sleep; + } NLA_PUT(skb, WL1271_TM_ATTR_DATA, buf_len, buf); ret = cfg80211_testmode_reply(skb); if (ret < 0) - return ret; + goto out_sleep; } - return 0; +out_sleep: + wl1271_ps_elp_sleep(wl); +out: + mutex_unlock(&wl->mutex); + + return ret; nla_put_failure: kfree_skb(skb); - return -EMSGSIZE; + ret = -EMSGSIZE; + goto out_sleep; } static int wl1271_tm_cmd_interrogate(struct wl1271 *wl, struct nlattr *tb[]) @@ -129,33 +146,50 @@ static int wl1271_tm_cmd_interrogate(struct wl1271 *wl, struct nlattr *tb[]) ie_id = nla_get_u8(tb[WL1271_TM_ATTR_IE_ID]); + mutex_lock(&wl->mutex); + + if (wl->state == WL1271_STATE_OFF) { + ret = -EINVAL; + goto out; + } + + ret = wl1271_ps_elp_wakeup(wl); + if (ret < 0) + goto out; + cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); - if (!cmd) - return -ENOMEM; + if (!cmd) { + ret = -ENOMEM; + goto out_sleep; + } - mutex_lock(&wl->mutex); ret = wl1271_cmd_interrogate(wl, ie_id, cmd, sizeof(*cmd)); - mutex_unlock(&wl->mutex); - if (ret < 0) { wl1271_warning("testmode cmd interrogate failed: %d", ret); - kfree(cmd); - return ret; + goto out_free; } skb = cfg80211_testmode_alloc_reply_skb(wl->hw->wiphy, sizeof(*cmd)); if (!skb) { - kfree(cmd); - return -ENOMEM; + ret = -ENOMEM; + goto out_free; } NLA_PUT(skb, WL1271_TM_ATTR_DATA, sizeof(*cmd), cmd); - return 0; +out_free: + kfree(cmd); +out_sleep: + wl1271_ps_elp_sleep(wl); +out: + mutex_unlock(&wl->mutex); + + return ret; nla_put_failure: kfree_skb(skb); - return -EMSGSIZE; + ret = -EMSGSIZE; + goto out_free; } static int wl1271_tm_cmd_configure(struct wl1271 *wl, struct nlattr *tb[]) -- cgit v1.2.3 From 188e7f54c38b9bf144ddc81b4b734cb6ea49f31e Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 6 Dec 2011 12:15:06 +0200 Subject: wl12xx: remove redundant commands from plt init During plt init we configure some redundant commands, which are not needed for plt (specifically, we shouldn't configure any role-specific params, as there are no active roles). remove them. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 61 +------------------------------------- 1 file changed, 1 insertion(+), 60 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index d1416752feea..2f7bfa86c8cd 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -641,9 +641,7 @@ static void wl1271_conf_init(struct wl1271 *wl) static int wl1271_plt_init(struct wl1271 *wl) { - struct conf_tx_ac_category *conf_ac; - struct conf_tx_tid *conf_tid; - int ret, i; + int ret; if (wl->chip.id == CHIP_ID_1283_PG20) ret = wl128x_cmd_general_parms(wl); @@ -672,10 +670,6 @@ static int wl1271_plt_init(struct wl1271 *wl) if (ret < 0) return ret; - ret = wl1271_init_templates_config(wl); - if (ret < 0) - return ret; - ret = wl1271_acx_init_mem_config(wl); if (ret < 0) return ret; @@ -685,63 +679,10 @@ static int wl1271_plt_init(struct wl1271 *wl) if (ret < 0) goto out_free_memmap; - ret = wl1271_acx_dco_itrim_params(wl); - if (ret < 0) - goto out_free_memmap; - - /* Initialize connection monitoring thresholds */ - ret = wl1271_acx_conn_monit_params(wl, NULL, false); /* TODO: fix */ - if (ret < 0) - goto out_free_memmap; - - /* Bluetooth WLAN coexistence */ - ret = wl1271_init_pta(wl); - if (ret < 0) - goto out_free_memmap; - - /* FM WLAN coexistence */ - ret = wl1271_acx_fm_coex(wl); - if (ret < 0) - goto out_free_memmap; - - /* Energy detection */ - ret = wl1271_init_energy_detection(wl); - if (ret < 0) - goto out_free_memmap; - ret = wl12xx_acx_mem_cfg(wl); if (ret < 0) goto out_free_memmap; - /* Default fragmentation threshold */ - ret = wl1271_acx_frag_threshold(wl, wl->conf.tx.frag_threshold); - if (ret < 0) - goto out_free_memmap; - - /* Default TID/AC configuration */ - BUG_ON(wl->conf.tx.tid_conf_count != wl->conf.tx.ac_conf_count); - for (i = 0; i < wl->conf.tx.tid_conf_count; i++) { - conf_ac = &wl->conf.tx.ac_conf[i]; - /* TODO: fix */ - ret = wl1271_acx_ac_cfg(wl, NULL, conf_ac->ac, conf_ac->cw_min, - conf_ac->cw_max, conf_ac->aifsn, - conf_ac->tx_op_limit); - if (ret < 0) - goto out_free_memmap; - - conf_tid = &wl->conf.tx.tid_conf[i]; - /* TODO: fix */ - ret = wl1271_acx_tid_cfg(wl, NULL, conf_tid->queue_id, - conf_tid->channel_type, - conf_tid->tsid, - conf_tid->ps_scheme, - conf_tid->ack_policy, - conf_tid->apsd_conf[0], - conf_tid->apsd_conf[1]); - if (ret < 0) - goto out_free_memmap; - } - /* Enable data path */ ret = wl1271_cmd_data_path(wl, 1); if (ret < 0) -- cgit v1.2.3 From 3dbb5846db1f5df3619b927cc2a7dcaf65a38f1e Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 6 Dec 2011 12:15:07 +0200 Subject: wl12xx: send testmode reply in wl1271_tm_cmd_interrogate wl1271_tm_cmd_interrogate creates a reply skb, but doesn't send it (and thus just leaks it). Add the missing cfg80211_testmode_reply() call. Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/testmode.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/testmode.c b/drivers/net/wireless/wl12xx/testmode.c index 2f9ebff2ded3..978cf2de713d 100644 --- a/drivers/net/wireless/wl12xx/testmode.c +++ b/drivers/net/wireless/wl12xx/testmode.c @@ -176,6 +176,9 @@ static int wl1271_tm_cmd_interrogate(struct wl1271 *wl, struct nlattr *tb[]) } NLA_PUT(skb, WL1271_TM_ATTR_DATA, sizeof(*cmd), cmd); + ret = cfg80211_testmode_reply(skb); + if (ret < 0) + goto out_free; out_free: kfree(cmd); -- cgit v1.2.3 From 1b04b739f4c1d053bebb29657fb69bf03f180a97 Mon Sep 17 00:00:00 2001 From: Eyal Shapira Date: Wed, 7 Dec 2011 12:37:04 +0200 Subject: wl12xx: minor fix in sched_scan_ssid_list The user can pass broadcast SSID (ssid="") in the list of SSIDs for active scan. In this case the loop was attempting to match SSIDs in the filter list to this empty entry and marking them as HIDDEN (sending probe request) by mistake Signed-off-by: Eyal Shapira Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/scan.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/scan.c b/drivers/net/wireless/wl12xx/scan.c index 330d6788a916..8599dab1fe2a 100644 --- a/drivers/net/wireless/wl12xx/scan.c +++ b/drivers/net/wireless/wl12xx/scan.c @@ -572,6 +572,9 @@ wl12xx_scan_sched_scan_ssid_list(struct wl1271 *wl, * so they're used in probe requests. */ for (i = 0; i < req->n_ssids; i++) { + if (!req->ssids[i].ssid_len) + continue; + for (j = 0; j < cmd->n_ssids; j++) if (!memcmp(req->ssids[i].ssid, cmd->ssids[j].ssid, -- cgit v1.2.3 From e1a38fe10f998e27ce8600379d1109be33d4f9c2 Mon Sep 17 00:00:00 2001 From: "Hsu, Kenny" Date: Mon, 28 Nov 2011 00:55:38 -0800 Subject: iwlwifi: add uCode version information support by testmode Create new tm command to report uCode version to userspace - IWL_TM_CMD_APP2DEV_GET_FW_VERSION Signed-off-by: Kenny Hsu Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-testmode.c | 18 ++++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-testmode.h | 11 +++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index ff72dbcfd52d..131a73d16f98 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -110,6 +110,8 @@ struct nla_policy iwl_testmode_gnl_msg_policy[IWL_TM_ATTR_MAX] = { [IWL_TM_ATTR_SRAM_ADDR] = { .type = NLA_U32, }, [IWL_TM_ATTR_SRAM_SIZE] = { .type = NLA_U32, }, [IWL_TM_ATTR_SRAM_DUMP] = { .type = NLA_UNSPEC, }, + + [IWL_TM_ATTR_FW_VERSION] = { .type = NLA_U32, }, }; /* @@ -510,6 +512,21 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) priv->tm_fixed_rate = nla_get_u32(tb[IWL_TM_ATTR_FIXRATE]); break; + case IWL_TM_CMD_APP2DEV_GET_FW_VERSION: + IWL_INFO(priv, "uCode version raw: 0x%x\n", priv->ucode_ver); + + skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); + if (!skb) { + IWL_DEBUG_INFO(priv, "Error allocating memory\n"); + return -ENOMEM; + } + NLA_PUT_U32(skb, IWL_TM_ATTR_FW_VERSION, priv->ucode_ver); + status = cfg80211_testmode_reply(skb); + if (status < 0) + IWL_DEBUG_INFO(priv, + "Error sending msg : %d\n", status); + break; + default: IWL_DEBUG_INFO(priv, "Unknown testmode driver command ID\n"); return -ENOSYS; @@ -842,6 +859,7 @@ int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) case IWL_TM_CMD_APP2DEV_GET_EEPROM: case IWL_TM_CMD_APP2DEV_FIXRATE_REQ: case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: + case IWL_TM_CMD_APP2DEV_GET_FW_VERSION: IWL_DEBUG_INFO(priv, "testmode cmd to driver\n"); result = iwl_testmode_driver(hw, tb); break; diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.h b/drivers/net/wireless/iwlwifi/iwl-testmode.h index deedd27c5f3d..60c6db157f2b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.h +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.h @@ -118,6 +118,7 @@ * commands from user applicaiton to read data in sram * * @IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: load Weak On Wireless LAN uCode image + * @IWL_TM_CMD_APP2DEV_GET_FW_VERSION: retrieve uCode version * */ enum iwl_tm_cmd_t { @@ -143,7 +144,8 @@ enum iwl_tm_cmd_t { IWL_TM_CMD_APP2DEV_READ_SRAM = 20, IWL_TM_CMD_APP2DEV_DUMP_SRAM = 21, IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW = 22, - IWL_TM_CMD_MAX = 23, + IWL_TM_CMD_APP2DEV_GET_FW_VERSION = 23, + IWL_TM_CMD_MAX = 24, }; /* @@ -225,6 +227,10 @@ enum iwl_tm_cmd_t { * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_DUMP_SRAM, * IWL_TM_ATTR_SRAM_DUMP for the data in sram * + * @IWL_TM_ATTR_FW_VERSION: + * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_GET_FW_VERSION, + * IWL_TM_ATTR_FW_VERSION for the uCode version + * */ enum iwl_tm_attr_t { IWL_TM_ATTR_NOT_APPLICABLE = 0, @@ -245,7 +251,8 @@ enum iwl_tm_attr_t { IWL_TM_ATTR_SRAM_ADDR = 15, IWL_TM_ATTR_SRAM_SIZE = 16, IWL_TM_ATTR_SRAM_DUMP = 17, - IWL_TM_ATTR_MAX = 18, + IWL_TM_ATTR_FW_VERSION = 18, + IWL_TM_ATTR_MAX = 19, }; /* uCode trace buffer */ -- cgit v1.2.3 From fe67c084cba9e50725f55281dc48fc29adb07cdd Mon Sep 17 00:00:00 2001 From: "Hsu, Kenny" Date: Mon, 28 Nov 2011 16:54:52 -0800 Subject: iwlwifi: hide kernel option IWLWIFI_DEVICE_SVTOOL Because the testmode support should be the mandatory foundation of test functionality, it is better to set kernel option IWLWIFI_DEVICE_SVTOOL automatically instead of user configuration. Signed-off-by: Kenny Hsu Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/Kconfig b/drivers/net/wireless/iwlwifi/Kconfig index 57703d5209d7..855b13555e87 100644 --- a/drivers/net/wireless/iwlwifi/Kconfig +++ b/drivers/net/wireless/iwlwifi/Kconfig @@ -103,9 +103,9 @@ config IWLWIFI_DEVICE_TRACING endmenu config IWLWIFI_DEVICE_SVTOOL - bool "iwlwifi device svtool support" + def_bool y depends on IWLWIFI - select NL80211_TESTMODE + depends on NL80211_TESTMODE help This option enables the svtool support for iwlwifi device through NL80211_TESTMODE. svtool is a software validation tool that runs in -- cgit v1.2.3 From d332f591daca5f5301782bad69f94e160b5fa665 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Wed, 30 Nov 2011 12:32:42 -0800 Subject: iwlwifi: Display more uCode debug info When uCode encounter problem, it pass a lot of debug data to help debugging the issue. We only show partial data before, why not display all of those. Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-commands.h | 24 ++++++++++++++---------- drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 15 +++++++++++++++ 2 files changed, 29 insertions(+), 10 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h index f4eccf583775..d98d09cc5df7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-commands.h +++ b/drivers/net/wireless/iwlwifi/iwl-commands.h @@ -466,23 +466,27 @@ struct iwl_error_event_table { u32 frame_ptr; /* frame pointer */ u32 stack_ptr; /* stack pointer */ u32 hcmd; /* last host command header */ -#if 0 - /* no need to read the remainder, we don't use the values */ - u32 isr0; /* isr status register LMPM_NIC_ISR0: rxtx_flag */ - u32 isr1; /* isr status register LMPM_NIC_ISR1: host_flag */ - u32 isr2; /* isr status register LMPM_NIC_ISR2: enc_flag */ - u32 isr3; /* isr status register LMPM_NIC_ISR3: time_flag */ - u32 isr4; /* isr status register LMPM_NIC_ISR4: wico interrupt */ + u32 isr0; /* isr status register LMPM_NIC_ISR0: + * rxtx_flag */ + u32 isr1; /* isr status register LMPM_NIC_ISR1: + * host_flag */ + u32 isr2; /* isr status register LMPM_NIC_ISR2: + * enc_flag */ + u32 isr3; /* isr status register LMPM_NIC_ISR3: + * time_flag */ + u32 isr4; /* isr status register LMPM_NIC_ISR4: + * wico interrupt */ u32 isr_pref; /* isr status register LMPM_NIC_PREF_STAT */ u32 wait_event; /* wait event() caller address */ u32 l2p_control; /* L2pControlField */ u32 l2p_duration; /* L2pDurationField */ u32 l2p_mhvalid; /* L2pMhValidBits */ u32 l2p_addr_match; /* L2pAddrMatchStat */ - u32 lmpm_pmg_sel; /* indicate which clocks are turned on (LMPM_PMG_SEL) */ - u32 u_timestamp; /* indicate when the date and time of the compilation */ + u32 lmpm_pmg_sel; /* indicate which clocks are turned on + * (LMPM_PMG_SEL) */ + u32 u_timestamp; /* indicate when the date and time of the + * compilation */ u32 flow_handler; /* FH read/write pointers, RX credit */ -#endif } __packed; struct iwl_alive_resp { diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index becd92173ddd..a0d43d6636f3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -648,6 +648,21 @@ static void iwl_dump_nic_error_log(struct iwl_trans *trans) IWL_ERR(trans, "0x%08X | hw version\n", table.hw_ver); IWL_ERR(trans, "0x%08X | board version\n", table.brd_ver); IWL_ERR(trans, "0x%08X | hcmd\n", table.hcmd); + + IWL_ERR(trans, "0x%08X | isr0\n", table.isr0); + IWL_ERR(trans, "0x%08X | isr1\n", table.isr1); + IWL_ERR(trans, "0x%08X | isr2\n", table.isr2); + IWL_ERR(trans, "0x%08X | isr3\n", table.isr3); + IWL_ERR(trans, "0x%08X | isr4\n", table.isr4); + IWL_ERR(trans, "0x%08X | isr_pref\n", table.isr_pref); + IWL_ERR(trans, "0x%08X | wait_event\n", table.wait_event); + IWL_ERR(trans, "0x%08X | l2p_control\n", table.l2p_control); + IWL_ERR(trans, "0x%08X | l2p_duration\n", table.l2p_duration); + IWL_ERR(trans, "0x%08X | l2p_mhvalid\n", table.l2p_mhvalid); + IWL_ERR(trans, "0x%08X | l2p_addr_match\n", table.l2p_addr_match); + IWL_ERR(trans, "0x%08X | lmpm_pmg_sel\n", table.lmpm_pmg_sel); + IWL_ERR(trans, "0x%08X | timestamp\n", table.u_timestamp); + IWL_ERR(trans, "0x%08X | flow_handler\n", table.flow_handler); } /** -- cgit v1.2.3 From 7f62cd17e0ed90f8a1e9fbbb6480fa48ebc4c0a6 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Wed, 30 Nov 2011 09:41:22 -0800 Subject: iwlwifi: minor cleanup Remove the defines only used by legacy devices Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn-sta.c | 4 +- drivers/net/wireless/iwlwifi/iwl-commands.h | 58 +++++++---------------------- 2 files changed, 15 insertions(+), 47 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c index 626ed701100e..63d948d21c04 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-sta.c @@ -135,8 +135,8 @@ static u16 iwlagn_build_addsta_hcmd(const struct iwl_addsta_cmd *cmd, u8 *data) u16 size = (u16)sizeof(struct iwl_addsta_cmd); struct iwl_addsta_cmd *addsta = (struct iwl_addsta_cmd *)data; memcpy(addsta, cmd, size); - /* resrved in 5000 */ - addsta->rate_n_flags = cpu_to_le16(0); + /* resrved in agn */ + addsta->legacy_reserved = cpu_to_le16(0); return size; } diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h index d98d09cc5df7..87bfdf6bdf6a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-commands.h +++ b/drivers/net/wireless/iwlwifi/iwl-commands.h @@ -109,10 +109,10 @@ enum { /* RX, TX, LEDs */ REPLY_TX = 0x1c, REPLY_LEDS_CMD = 0x48, - REPLY_TX_LINK_QUALITY_CMD = 0x4e, /* for 4965 and up */ + REPLY_TX_LINK_QUALITY_CMD = 0x4e, /* WiMAX coexistence */ - COEX_PRIORITY_TABLE_CMD = 0x5a, /* for 5000 series and up */ + COEX_PRIORITY_TABLE_CMD = 0x5a, COEX_MEDIUM_NOTIFICATION = 0x5b, COEX_EVENT_CMD = 0x5c, @@ -935,8 +935,7 @@ struct iwl_addsta_cmd { * corresponding to bit (e.g. bit 5 controls TID 5). * Set modify_mask bit STA_MODIFY_TID_DISABLE_TX to use this field. */ __le16 tid_disable_tx; - - __le16 rate_n_flags; /* 3945 only */ + __le16 legacy_reserved; /* TID for which to add block-ack support. * Set modify_mask bit STA_MODIFY_ADDBA_TID_MSK to use this field. */ @@ -1166,8 +1165,7 @@ struct iwl_rx_mpdu_res_start { * * uCode handles retrying Tx when an ACK is expected but not received. * This includes trying lower data rates than the one requested in the Tx - * command, as set up by the REPLY_RATE_SCALE (for 3945) or - * REPLY_TX_LINK_QUALITY_CMD (agn). + * command, as set up by the REPLY_TX_LINK_QUALITY_CMD (agn). * * Driver sets up transmit power for various rates via REPLY_TX_PWR_TABLE_CMD. * This command must be executed after every RXON command, before Tx can occur. @@ -1179,25 +1177,9 @@ struct iwl_rx_mpdu_res_start { * 1: Use RTS/CTS protocol or CTS-to-self if spec allows it * before this frame. if CTS-to-self required check * RXON_FLG_SELF_CTS_EN status. - * unused in 3945/4965, used in 5000 series and after */ #define TX_CMD_FLG_PROT_REQUIRE_MSK cpu_to_le32(1 << 0) -/* - * 1: Use Request-To-Send protocol before this frame. - * Mutually exclusive vs. TX_CMD_FLG_CTS_MSK. - * used in 3945/4965, unused in 5000 series and after - */ -#define TX_CMD_FLG_RTS_MSK cpu_to_le32(1 << 1) - -/* - * 1: Transmit Clear-To-Send to self before this frame. - * Driver should set this for AUTH/DEAUTH/ASSOC-REQ/REASSOC mgmnt frames. - * Mutually exclusive vs. TX_CMD_FLG_RTS_MSK. - * used in 3945/4965, unused in 5000 series and after - */ -#define TX_CMD_FLG_CTS_MSK cpu_to_le32(1 << 2) - /* 1: Expect ACK from receiving station * 0: Don't expect ACK (MAC header's duration field s/b 0) * Set this for unicast frames, but not broadcast/multicast. */ @@ -1215,18 +1197,8 @@ struct iwl_rx_mpdu_res_start { * Set when Txing a block-ack request frame. Also set TX_CMD_FLG_ACK_MSK. */ #define TX_CMD_FLG_IMM_BA_RSP_MASK cpu_to_le32(1 << 6) -/* - * 1: Frame requires full Tx-Op protection. - * Set this if either RTS or CTS Tx Flag gets set. - * used in 3945/4965, unused in 5000 series and after - */ -#define TX_CMD_FLG_FULL_TXOP_PROT_MSK cpu_to_le32(1 << 7) - -/* Tx antenna selection field; used only for 3945, reserved (0) for agn devices. - * Set field to "0" to allow 3945 uCode to select antenna (normal usage). */ +/* Tx antenna selection field; reserved (0) for agn devices. */ #define TX_CMD_FLG_ANT_SEL_MSK cpu_to_le32(0xf00) -#define TX_CMD_FLG_ANT_A_MSK cpu_to_le32(1 << 8) -#define TX_CMD_FLG_ANT_B_MSK cpu_to_le32(1 << 9) /* 1: Ignore Bluetooth priority for this frame. * 0: Delay Tx until Bluetooth device is done (normal usage). */ @@ -1572,7 +1544,6 @@ struct iwl_compressed_ba_resp { __le64 bitmap; __le16 scd_flow; __le16 scd_ssn; - /* following only for 5000 series and up */ u8 txed; /* number of frames sent */ u8 txed_2_done; /* number of frames acked */ } __packed; @@ -1674,7 +1645,7 @@ struct iwl_link_qual_agg_params { /* * REPLY_TX_LINK_QUALITY_CMD = 0x4e (command, has simple generic response) * - * For agn devices only; 3945 uses REPLY_RATE_SCALE. + * For agn devices * * Each station in the agn device's internal station table has its own table * of 16 @@ -1923,7 +1894,7 @@ struct iwl_link_quality_cmd { /* * REPLY_BT_CONFIG = 0x9b (command, has simple generic response) * - * 3945 and agn devices support hardware handshake with Bluetooth device on + * agn devices support hardware handshake with Bluetooth device on * same platform. Bluetooth device alerts wireless device when it will Tx; * wireless device can delay or kill its own Tx to accommodate. */ @@ -2207,8 +2178,8 @@ struct iwl_spectrum_notification { struct iwl_powertable_cmd { __le16 flags; - u8 keep_alive_seconds; /* 3945 reserved */ - u8 debug_flags; /* 3945 reserved */ + u8 keep_alive_seconds; + u8 debug_flags; __le32 rx_data_timeout; __le32 tx_data_timeout; __le32 sleep_interval[IWL_POWER_VEC_SIZE]; @@ -2329,9 +2300,9 @@ struct iwl_scan_channel { /** * struct iwl_ssid_ie - directed scan network information element * - * Up to 20 of these may appear in REPLY_SCAN_CMD (Note: Only 4 are in - * 3945 SCAN api), selected by "type" bit field in struct iwl_scan_channel; - * each channel may select different ssids from among the 20 (4) entries. + * Up to 20 of these may appear in REPLY_SCAN_CMD, + * selected by "type" bit field in struct iwl_scan_channel; + * each channel may select different ssids from among the 20 entries. * SSID IEs get transmitted in reverse order of entry. */ struct iwl_ssid_ie { @@ -2340,7 +2311,6 @@ struct iwl_ssid_ie { u8 ssid[32]; } __packed; -#define PROBE_OPTION_MAX_3945 4 #define PROBE_OPTION_MAX 20 #define TX_CMD_LIFE_TIME_INFINITE cpu_to_le32(0xFFFFFFFF) #define IWL_GOOD_CRC_TH_DISABLED 0 @@ -2421,8 +2391,6 @@ struct iwl_scan_cmd { * channel */ __le32 suspend_time; /* pause scan this long (in "extended beacon * format") when returning to service chnl: - * 3945; 31:24 # beacons, 19:0 additional usec, - * 4965; 31:22 # beacons, 21:0 additional usec. */ __le32 flags; /* RXON_FLG_* */ __le32 filter_flags; /* RXON_FILTER_* */ @@ -2738,7 +2706,7 @@ struct statistics_div { struct statistics_general_common { __le32 temperature; /* radio temperature */ - __le32 temperature_m; /* for 5000 and up, this is radio voltage */ + __le32 temperature_m; /* radio voltage */ struct statistics_dbg dbg; __le32 sleep_time; __le32 slots_out; -- cgit v1.2.3 From c4db616623030e9a75a990a2db4d733b5112acb1 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Wed, 30 Nov 2011 00:14:53 -0800 Subject: iwlwifi: remove reference to legacy devices After driver split, no need to reference to legacy devices, remove comments Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-dev.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 6f6a647d34f6..be26145f1da4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -60,11 +60,10 @@ struct iwl_tx_queue; /* Default noise level to report when noise measurement is not available. * This may be because we're: - * 1) Not associated (4965, no beacon statistics being sent to driver) + * 1) Not associated no beacon statistics being sent to driver) * 2) Scanning (noise measurement does not apply to associated channel) - * 3) Receiving CCK (3945 delivers noise info only for OFDM frames) * Use default noise value of -127 ... this is below the range of measurable - * Rx dBm for either 3945 or 4965, so it can indicate "unmeasurable" to user. + * Rx dBm for all agn devices, so it can indicate "unmeasurable" to user. * Also, -127 works better than 0 when averaging frames with/without * noise info (e.g. averaging might be done in app); measured dBm values are * always negative ... using a negative value as the default keeps all -- cgit v1.2.3 From 5ef15ccc648638a2cf00b3a13caa770559aa4e91 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Wed, 30 Nov 2011 13:24:06 -0800 Subject: iwlwifi: rename CONFIG_IWLWIFI_DEVICE_SVTOOL to CONFIG_IWLWIFI_DEVICE_TESTMODE Change the name to match the works Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/Kconfig | 10 +++++----- drivers/net/wireless/iwlwifi/Makefile | 2 +- drivers/net/wireless/iwlwifi/iwl-agn-rs.c | 6 +++--- drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn.c | 4 ++-- drivers/net/wireless/iwlwifi/iwl-agn.h | 2 +- drivers/net/wireless/iwlwifi/iwl-dev.h | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/Kconfig b/drivers/net/wireless/iwlwifi/Kconfig index 855b13555e87..82c8ccac513d 100644 --- a/drivers/net/wireless/iwlwifi/Kconfig +++ b/drivers/net/wireless/iwlwifi/Kconfig @@ -102,12 +102,12 @@ config IWLWIFI_DEVICE_TRACING occur. endmenu -config IWLWIFI_DEVICE_SVTOOL +config IWLWIFI_DEVICE_TESTMODE def_bool y depends on IWLWIFI depends on NL80211_TESTMODE help - This option enables the svtool support for iwlwifi device through - NL80211_TESTMODE. svtool is a software validation tool that runs in - the user space and interacts with the device in the kernel space - through the generic netlink message via NL80211_TESTMODE channel. + This option enables the testmode support for iwlwifi device through + NL80211_TESTMODE. This provide the capabilities of enable user space + validation applications to interacts with the device through the + generic netlink message via NL80211_TESTMODE channel. diff --git a/drivers/net/wireless/iwlwifi/Makefile b/drivers/net/wireless/iwlwifi/Makefile index 86344cefd32f..9dc84a7354db 100644 --- a/drivers/net/wireless/iwlwifi/Makefile +++ b/drivers/net/wireless/iwlwifi/Makefile @@ -18,7 +18,7 @@ iwlwifi-objs += iwl-trans-pcie.o iwl-trans-pcie-rx.o iwl-trans-pcie-tx.o iwlwifi-$(CONFIG_IWLWIFI_DEBUGFS) += iwl-debugfs.o iwlwifi-$(CONFIG_IWLWIFI_DEVICE_TRACING) += iwl-devtrace.o -iwlwifi-$(CONFIG_IWLWIFI_DEVICE_SVTOOL) += iwl-testmode.o +iwlwifi-$(CONFIG_IWLWIFI_DEVICE_TESTMODE) += iwl-testmode.o CFLAGS_iwl-devtrace.o := -I$(src) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c index 359c47a4fcea..78efa2bb526f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c @@ -352,7 +352,7 @@ static void rs_program_fix_rate(struct iwl_priv *priv, lq_sta->active_mimo2_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ lq_sta->active_mimo3_rate = 0x1FD0; /* 6 - 60 MBits, no 9, no CCK */ -#ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL +#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE /* testmode has higher priority to overwirte the fixed rate */ if (priv->tm_fixed_rate) lq_sta->dbg_fixed_rate = priv->tm_fixed_rate; @@ -1081,7 +1081,7 @@ done: if (sta && sta->supp_rates[sband->band]) rs_rate_scale_perform(priv, skb, sta, lq_sta); -#if defined(CONFIG_MAC80211_DEBUGFS) && defined(CONFIG_IWLWIFI_DEVICE_SVTOOL) +#if defined(CONFIG_MAC80211_DEBUGFS) && defined(CONFIG_IWLWIFI_DEVICE_TESTMODE) if ((priv->tm_fixed_rate) && (priv->tm_fixed_rate != lq_sta->dbg_fixed_rate)) rs_program_fix_rate(priv, lq_sta); @@ -2904,7 +2904,7 @@ void iwl_rs_rate_init(struct iwl_priv *priv, struct ieee80211_sta *sta, u8 sta_i if (sband->band == IEEE80211_BAND_5GHZ) lq_sta->last_txrate_idx += IWL_FIRST_OFDM_RATE; lq_sta->is_agg = 0; -#ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL +#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE priv->tm_fixed_rate = 0; #endif #ifdef CONFIG_MAC80211_DEBUGFS diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index a1a95d5f3923..cdf9efda8ace 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -148,7 +148,7 @@ static void iwlagn_tx_cmd_build_rate(struct iwl_priv *priv, if (ieee80211_is_data(fc)) { tx_cmd->initial_rate_index = 0; tx_cmd->tx_flags |= TX_CMD_FLG_STA_RATE_MSK; -#ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL +#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE if (priv->tm_fixed_rate) { /* * rate overwrite by testmode diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index daf010dad70c..5021cc984d3f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1703,8 +1703,8 @@ static void iwl_debug_config(struct iwl_priv *priv) "disabled\n"); #endif - dev_printk(KERN_INFO, bus(priv)->dev, "CONFIG_IWLWIFI_DEVICE_SVTOOL " -#ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL + dev_printk(KERN_INFO, bus(priv)->dev, "CONFIG_IWLWIFI_DEVICE_TESTMODE " +#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE "enabled\n"); #else "disabled\n"); diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index f2f10702754d..b891bd97af0c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -359,7 +359,7 @@ void iwl_eeprom_get_mac(const struct iwl_priv *priv, u8 *mac); extern int iwlagn_init_alive_start(struct iwl_priv *priv); extern int iwl_alive_start(struct iwl_priv *priv); /* svtool */ -#ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL +#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE extern int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len); extern int iwlagn_mac_testmode_dump(struct ieee80211_hw *hw, diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index be26145f1da4..d7b64af97f5a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -750,7 +750,7 @@ enum iwl_scan_type { IWL_SCAN_ROC, }; -#ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL +#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE struct iwl_testmode_trace { u32 buff_size; u32 total_size; @@ -1039,7 +1039,7 @@ struct iwl_priv { struct led_classdev led; unsigned long blink_on, blink_off; bool led_registered; -#ifdef CONFIG_IWLWIFI_DEVICE_SVTOOL +#ifdef CONFIG_IWLWIFI_DEVICE_TESTMODE struct iwl_testmode_trace testmode_trace; struct iwl_testmode_sram testmode_sram; u32 tm_fixed_rate; -- cgit v1.2.3 From 0bec12b838c8fe002a3ad7a1ca5a444c8beee5c3 Mon Sep 17 00:00:00 2001 From: "Hsu, Kenny" Date: Thu, 1 Dec 2011 01:12:50 -0800 Subject: iwlwifi: add device ID information support by testmode Create new tm command to report devce ID information to userspace - IWL_TM_CMD_APP2DEV_GET_DEVICE_ID Signed-off-by: Kenny Hsu Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-testmode.c | 27 +++++++++++++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-testmode.h | 11 +++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index 131a73d16f98..0b0ff11d5d58 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -77,6 +77,7 @@ #include "iwl-agn.h" #include "iwl-testmode.h" #include "iwl-trans.h" +#include "iwl-bus.h" /* The TLVs used in the gnl message policy between the kernel module and * user space application. iwl_testmode_gnl_msg_policy is to be carried @@ -112,6 +113,7 @@ struct nla_policy iwl_testmode_gnl_msg_policy[IWL_TM_ATTR_MAX] = { [IWL_TM_ATTR_SRAM_DUMP] = { .type = NLA_UNSPEC, }, [IWL_TM_ATTR_FW_VERSION] = { .type = NLA_U32, }, + [IWL_TM_ATTR_DEVICE_ID] = { .type = NLA_U32, }, }; /* @@ -418,6 +420,8 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) struct sk_buff *skb; unsigned char *rsp_data_ptr = NULL; int status = 0, rsp_data_len = 0; + char buf[32], *ptr = NULL; + unsigned int num, devid; switch (nla_get_u32(tb[IWL_TM_ATTR_COMMAND])) { case IWL_TM_CMD_APP2DEV_GET_DEVICENAME: @@ -527,6 +531,28 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) "Error sending msg : %d\n", status); break; + case IWL_TM_CMD_APP2DEV_GET_DEVICE_ID: + bus_get_hw_id(bus(priv), buf, sizeof(buf)); + ptr = buf; + strsep(&ptr, ":"); + sscanf(strsep(&ptr, ":"), "%x", &num); + sscanf(strsep(&ptr, ":"), "%x", &devid); + IWL_INFO(priv, "Device ID = 0x%04x, SubDevice ID= 0x%04x\n", + num, devid); + devid |= (num << 16); + + skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, 20); + if (!skb) { + IWL_DEBUG_INFO(priv, "Error allocating memory\n"); + return -ENOMEM; + } + NLA_PUT_U32(skb, IWL_TM_ATTR_DEVICE_ID, devid); + status = cfg80211_testmode_reply(skb); + if (status < 0) + IWL_DEBUG_INFO(priv, + "Error sending msg : %d\n", status); + break; + default: IWL_DEBUG_INFO(priv, "Unknown testmode driver command ID\n"); return -ENOSYS; @@ -860,6 +886,7 @@ int iwlagn_mac_testmode_cmd(struct ieee80211_hw *hw, void *data, int len) case IWL_TM_CMD_APP2DEV_FIXRATE_REQ: case IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: case IWL_TM_CMD_APP2DEV_GET_FW_VERSION: + case IWL_TM_CMD_APP2DEV_GET_DEVICE_ID: IWL_DEBUG_INFO(priv, "testmode cmd to driver\n"); result = iwl_testmode_driver(hw, tb); break; diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.h b/drivers/net/wireless/iwlwifi/iwl-testmode.h index 60c6db157f2b..26138f110340 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.h +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.h @@ -119,6 +119,7 @@ * * @IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW: load Weak On Wireless LAN uCode image * @IWL_TM_CMD_APP2DEV_GET_FW_VERSION: retrieve uCode version + * @IWL_TM_CMD_APP2DEV_GET_DEVICE_ID: retrieve ID information in device * */ enum iwl_tm_cmd_t { @@ -145,7 +146,8 @@ enum iwl_tm_cmd_t { IWL_TM_CMD_APP2DEV_DUMP_SRAM = 21, IWL_TM_CMD_APP2DEV_LOAD_WOWLAN_FW = 22, IWL_TM_CMD_APP2DEV_GET_FW_VERSION = 23, - IWL_TM_CMD_MAX = 24, + IWL_TM_CMD_APP2DEV_GET_DEVICE_ID = 24, + IWL_TM_CMD_MAX = 25, }; /* @@ -231,6 +233,10 @@ enum iwl_tm_cmd_t { * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_GET_FW_VERSION, * IWL_TM_ATTR_FW_VERSION for the uCode version * + * @IWL_TM_ATTR_DEVICE_ID: + * When IWL_TM_ATTR_COMMAND is IWL_TM_CMD_APP2DEV_GET_DEVICE_ID, + * IWL_TM_ATTR_DEVICE_ID for the device ID information + * */ enum iwl_tm_attr_t { IWL_TM_ATTR_NOT_APPLICABLE = 0, @@ -252,7 +258,8 @@ enum iwl_tm_attr_t { IWL_TM_ATTR_SRAM_SIZE = 16, IWL_TM_ATTR_SRAM_DUMP = 17, IWL_TM_ATTR_FW_VERSION = 18, - IWL_TM_ATTR_MAX = 19, + IWL_TM_ATTR_DEVICE_ID = 19, + IWL_TM_ATTR_MAX = 20, }; /* uCode trace buffer */ -- cgit v1.2.3 From 0cb38d65efa0304e9a948fd7aef9c7d38ad8cbb9 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Fri, 2 Dec 2011 07:33:57 -0800 Subject: iwlwifi: P2P is not enabled by default P2P still under development. it will not enabled by default, but user always can enable it manually for testing. Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/Kconfig | 16 ++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-agn.c | 10 +++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/Kconfig b/drivers/net/wireless/iwlwifi/Kconfig index 82c8ccac513d..ae08498dfcad 100644 --- a/drivers/net/wireless/iwlwifi/Kconfig +++ b/drivers/net/wireless/iwlwifi/Kconfig @@ -111,3 +111,19 @@ config IWLWIFI_DEVICE_TESTMODE NL80211_TESTMODE. This provide the capabilities of enable user space validation applications to interacts with the device through the generic netlink message via NL80211_TESTMODE channel. + +config IWLWIFI_P2P + bool "iwlwifi experimental P2P support" + depends on IWLWIFI + help + This option enables experimental P2P support for some devices + based on microcode support. Since P2P support is still under + development, this option may even enable it for some devices + now that turn out to not support it in the future due to + microcode restrictions. + + To determine if your microcode supports the experimental P2P + offered by this option, check if the driver advertises AP + support when it is loaded. + + Say Y only if you want to experiment with P2P. diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 5021cc984d3f..6dd1e10dc967 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1036,6 +1036,9 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) priv->inst_evtlog_size = priv->cfg->base_params->max_event_log_size; priv->inst_errlog_ptr = pieces.inst_errlog_ptr; +#ifndef CONFIG_IWLWIFI_P2P + ucode_capa.flags &= ~IWL_UCODE_TLV_FLAGS_PAN; +#endif priv->new_scan_threshold_behaviour = !!(ucode_capa.flags & IWL_UCODE_TLV_FLAGS_NEWSCAN); @@ -1057,7 +1060,6 @@ static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) priv->sta_key_max_num = STA_KEY_MAX_NUM; priv->shrd->cmd_queue = IWL_DEFAULT_CMD_QUEUE_NUM; } - /* * figure out the offset of chain noise reset and gain commands * base on the size of standard phy calibration commands table size @@ -1708,6 +1710,12 @@ static void iwl_debug_config(struct iwl_priv *priv) "enabled\n"); #else "disabled\n"); +#endif + dev_printk(KERN_INFO, bus(priv)->dev, "CONFIG_IWLWIFI_P2P " +#ifdef CONFIG_IWLWIFI_P2P + "enabled\n"); +#else + "disabled\n"); #endif } -- cgit v1.2.3 From b8deb4925f88c5052fc42dc52e9c7057f05deb0d Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Fri, 2 Dec 2011 08:09:10 -0800 Subject: iwlwifi: set TX_CMD_FLG_STA_RATE_MSK for BAR frame It is needed by firmware to use the correct rate for BAR frame transmission Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index cdf9efda8ace..2fab2e31bf36 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -161,7 +161,8 @@ static void iwlagn_tx_cmd_build_rate(struct iwl_priv *priv, } #endif return; - } + } else if (ieee80211_is_back_req(fc)) + tx_cmd->tx_flags |= TX_CMD_FLG_STA_RATE_MSK; /** * If the current TX rate stored in mac80211 has the MCS bit set, it's -- cgit v1.2.3 From ab36eab24e7847d6d92872c55b46554c8ac4c4b3 Mon Sep 17 00:00:00 2001 From: Don Fry Date: Wed, 30 Nov 2011 15:37:32 -0800 Subject: iwlwifi: move eeprom pointer from iwl_priv to iwl_shared The eeprom image is a device level component, move from iwl_priv to iwl_shared, with associated code changes. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-5000.c | 8 ++-- drivers/net/wireless/iwlwifi/iwl-6000.c | 4 +- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 32 +++++++-------- drivers/net/wireless/iwlwifi/iwl-agn.c | 8 ++-- drivers/net/wireless/iwlwifi/iwl-agn.h | 4 +- drivers/net/wireless/iwlwifi/iwl-debugfs.c | 4 +- drivers/net/wireless/iwlwifi/iwl-dev.h | 4 -- drivers/net/wireless/iwlwifi/iwl-eeprom.c | 60 +++++++++++++++-------------- drivers/net/wireless/iwlwifi/iwl-eeprom.h | 7 ++-- drivers/net/wireless/iwlwifi/iwl-shared.h | 3 ++ drivers/net/wireless/iwlwifi/iwl-testmode.c | 4 +- drivers/net/wireless/iwlwifi/iwl-ucode.c | 12 +++--- 12 files changed, 78 insertions(+), 72 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index cf2fb47529b3..6706d7c10bd8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c @@ -134,10 +134,10 @@ static struct iwl_sensitivity_ranges iwl5150_sensitivity = { #define IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF (-5) -static s32 iwl_temp_calib_to_offset(struct iwl_priv *priv) +static s32 iwl_temp_calib_to_offset(struct iwl_shared *shrd) { u16 temperature, voltage; - __le16 *temp_calib = (__le16 *)iwl_eeprom_query_addr(priv, + __le16 *temp_calib = (__le16 *)iwl_eeprom_query_addr(shrd, EEPROM_KELVIN_TEMPERATURE); temperature = le16_to_cpu(temp_calib[0]); @@ -151,7 +151,7 @@ static void iwl5150_set_ct_threshold(struct iwl_priv *priv) { const s32 volt2temp_coef = IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF; s32 threshold = (s32)CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY) - - iwl_temp_calib_to_offset(priv); + iwl_temp_calib_to_offset(priv->shrd); hw_params(priv).ct_kill_threshold = threshold * volt2temp_coef; } @@ -223,7 +223,7 @@ static int iwl5150_hw_set_hw_params(struct iwl_priv *priv) static void iwl5150_temperature(struct iwl_priv *priv) { u32 vt = 0; - s32 offset = iwl_temp_calib_to_offset(priv); + s32 offset = iwl_temp_calib_to_offset(priv->shrd); vt = le32_to_cpu(priv->statistics.common.temperature); vt = vt / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF + offset; diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c index 617ad1c0df61..3e277b6774f1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-6000.c +++ b/drivers/net/wireless/iwlwifi/iwl-6000.c @@ -81,7 +81,7 @@ static void iwl6000_set_ct_threshold(struct iwl_priv *priv) static void iwl6050_additional_nic_config(struct iwl_priv *priv) { /* Indicate calibration version to uCode. */ - if (iwlagn_eeprom_calib_version(priv) >= 6) + if (iwl_eeprom_calib_version(priv->shrd) >= 6) iwl_set_bit(bus(priv), CSR_GP_DRIVER_REG, CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6); } @@ -89,7 +89,7 @@ static void iwl6050_additional_nic_config(struct iwl_priv *priv) static void iwl6150_additional_nic_config(struct iwl_priv *priv) { /* Indicate calibration version to uCode. */ - if (iwlagn_eeprom_calib_version(priv) >= 6) + if (iwl_eeprom_calib_version(priv->shrd) >= 6) iwl_set_bit(bus(priv), CSR_GP_DRIVER_REG, CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6); iwl_set_bit(bus(priv), CSR_GP_DRIVER_REG, diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 575d1bb8e8cc..1d6342213443 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -92,11 +92,11 @@ void iwlagn_temperature(struct iwl_priv *priv) iwl_tt_handler(priv); } -u16 iwlagn_eeprom_calib_version(struct iwl_priv *priv) +u16 iwl_eeprom_calib_version(struct iwl_shared *shrd) { struct iwl_eeprom_calib_hdr *hdr; - hdr = (struct iwl_eeprom_calib_hdr *)iwl_eeprom_query_addr(priv, + hdr = (struct iwl_eeprom_calib_hdr *)iwl_eeprom_query_addr(shrd, EEPROM_CALIB_ALL); return hdr->version; @@ -105,7 +105,7 @@ u16 iwlagn_eeprom_calib_version(struct iwl_priv *priv) /* * EEPROM */ -static u32 eeprom_indirect_address(const struct iwl_priv *priv, u32 address) +static u32 eeprom_indirect_address(const struct iwl_shared *shrd, u32 address) { u16 offset = 0; @@ -114,31 +114,31 @@ static u32 eeprom_indirect_address(const struct iwl_priv *priv, u32 address) switch (address & INDIRECT_TYPE_MSK) { case INDIRECT_HOST: - offset = iwl_eeprom_query16(priv, EEPROM_LINK_HOST); + offset = iwl_eeprom_query16(shrd, EEPROM_LINK_HOST); break; case INDIRECT_GENERAL: - offset = iwl_eeprom_query16(priv, EEPROM_LINK_GENERAL); + offset = iwl_eeprom_query16(shrd, EEPROM_LINK_GENERAL); break; case INDIRECT_REGULATORY: - offset = iwl_eeprom_query16(priv, EEPROM_LINK_REGULATORY); + offset = iwl_eeprom_query16(shrd, EEPROM_LINK_REGULATORY); break; case INDIRECT_TXP_LIMIT: - offset = iwl_eeprom_query16(priv, EEPROM_LINK_TXP_LIMIT); + offset = iwl_eeprom_query16(shrd, EEPROM_LINK_TXP_LIMIT); break; case INDIRECT_TXP_LIMIT_SIZE: - offset = iwl_eeprom_query16(priv, EEPROM_LINK_TXP_LIMIT_SIZE); + offset = iwl_eeprom_query16(shrd, EEPROM_LINK_TXP_LIMIT_SIZE); break; case INDIRECT_CALIBRATION: - offset = iwl_eeprom_query16(priv, EEPROM_LINK_CALIBRATION); + offset = iwl_eeprom_query16(shrd, EEPROM_LINK_CALIBRATION); break; case INDIRECT_PROCESS_ADJST: - offset = iwl_eeprom_query16(priv, EEPROM_LINK_PROCESS_ADJST); + offset = iwl_eeprom_query16(shrd, EEPROM_LINK_PROCESS_ADJST); break; case INDIRECT_OTHERS: - offset = iwl_eeprom_query16(priv, EEPROM_LINK_OTHERS); + offset = iwl_eeprom_query16(shrd, EEPROM_LINK_OTHERS); break; default: - IWL_ERR(priv, "illegal indirect type: 0x%X\n", + IWL_ERR(shrd->trans, "illegal indirect type: 0x%X\n", address & INDIRECT_TYPE_MSK); break; } @@ -147,11 +147,11 @@ static u32 eeprom_indirect_address(const struct iwl_priv *priv, u32 address) return (address & ADDRESS_MSK) + (offset << 1); } -const u8 *iwl_eeprom_query_addr(const struct iwl_priv *priv, size_t offset) +const u8 *iwl_eeprom_query_addr(const struct iwl_shared *shrd, size_t offset) { - u32 address = eeprom_indirect_address(priv, offset); - BUG_ON(address >= priv->cfg->base_params->eeprom_size); - return &priv->eeprom[address]; + u32 address = eeprom_indirect_address(shrd, offset); + BUG_ON(address >= shrd->priv->cfg->base_params->eeprom_size); + return &shrd->eeprom[address]; } struct iwl_mod_params iwlagn_mod_params = { diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 6dd1e10dc967..6b99448d4548 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1822,11 +1822,11 @@ int iwl_probe(struct iwl_bus *bus, const struct iwl_trans_ops *trans_ops, goto out_free_eeprom; /* extract MAC Address */ - iwl_eeprom_get_mac(priv, priv->addresses[0].addr); + iwl_eeprom_get_mac(priv->shrd, priv->addresses[0].addr); IWL_DEBUG_INFO(priv, "MAC address: %pM\n", priv->addresses[0].addr); priv->hw->wiphy->addresses = priv->addresses; priv->hw->wiphy->n_addresses = 1; - num_mac = iwl_eeprom_query16(priv, EEPROM_NUM_MAC_ADDRESS); + num_mac = iwl_eeprom_query16(priv->shrd, EEPROM_NUM_MAC_ADDRESS); if (num_mac > 1) { memcpy(priv->addresses[1].addr, priv->addresses[0].addr, ETH_ALEN); @@ -1891,7 +1891,7 @@ out_destroy_workqueue: priv->shrd->workqueue = NULL; iwl_uninit_drv(priv); out_free_eeprom: - iwl_eeprom_free(priv); + iwl_eeprom_free(priv->shrd); out_free_trans: iwl_trans_free(trans(priv)); out_free_traffic_mem: @@ -1930,7 +1930,7 @@ void __devexit iwl_remove(struct iwl_priv * priv) iwl_dealloc_ucode(trans(priv)); - iwl_eeprom_free(priv); + iwl_eeprom_free(priv->shrd); /*netif_stop_queue(dev); */ flush_workqueue(priv->shrd->workqueue); diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h index b891bd97af0c..eb453ea41c41 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn.h @@ -117,7 +117,7 @@ int iwlagn_load_ucode_wait_alive(struct iwl_priv *priv, /* lib */ int iwlagn_send_tx_power(struct iwl_priv *priv); void iwlagn_temperature(struct iwl_priv *priv); -u16 iwlagn_eeprom_calib_version(struct iwl_priv *priv); +u16 iwl_eeprom_calib_version(struct iwl_shared *shrd); int iwlagn_txfifo_flush(struct iwl_priv *priv, u16 flush_control); void iwlagn_dev_txfifo_flush(struct iwl_priv *priv, u16 flush_control); int iwlagn_send_beacon_cmd(struct iwl_priv *priv); @@ -354,7 +354,7 @@ static inline __le32 iwl_hw_set_rate_n_flags(u8 rate, u32 flags) /* eeprom */ void iwl_eeprom_enhanced_txpower(struct iwl_priv *priv); -void iwl_eeprom_get_mac(const struct iwl_priv *priv, u8 *mac); +void iwl_eeprom_get_mac(const struct iwl_shared *shrd, u8 *mac); extern int iwlagn_init_alive_start(struct iwl_priv *priv); extern int iwl_alive_start(struct iwl_priv *priv); diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index ccbcab40e78f..6bf6845e1a51 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c @@ -416,7 +416,7 @@ static ssize_t iwl_dbgfs_nvm_read(struct file *file, return -ENODATA; } - ptr = priv->eeprom; + ptr = priv->shrd->eeprom; if (!ptr) { IWL_ERR(priv, "Invalid EEPROM/OTP memory\n"); return -ENOMEM; @@ -428,7 +428,7 @@ static ssize_t iwl_dbgfs_nvm_read(struct file *file, IWL_ERR(priv, "Can not allocate Buffer\n"); return -ENOMEM; } - eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION); + eeprom_ver = iwl_eeprom_query16(priv->shrd, EEPROM_VERSION); pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s, " "version: 0x%x\n", (trans(priv)->nvm_device_type == NVM_DEVICE_TYPE_OTP) diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index d7b64af97f5a..68f9dc5e9248 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -903,10 +903,6 @@ struct iwl_priv { /* Indication if ieee80211_ops->open has been called */ u8 is_open; - /* eeprom -- this is in the card's little endian byte order */ - u8 *eeprom; - struct iwl_eeprom_calib_info *calib_info; - enum nl80211_iftype iw_mode; /* Last Rx'd beacon timestamp */ diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c index dcada0827ea4..6fcc7d586b24 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c @@ -215,11 +215,11 @@ static int iwl_eeprom_verify_signature(struct iwl_trans *trans) return ret; } -u16 iwl_eeprom_query16(const struct iwl_priv *priv, size_t offset) +u16 iwl_eeprom_query16(const struct iwl_shared *shrd, size_t offset) { - if (!priv->eeprom) + if (!shrd->eeprom) return 0; - return (u16)priv->eeprom[offset] | ((u16)priv->eeprom[offset + 1] << 8); + return (u16)shrd->eeprom[offset] | ((u16)shrd->eeprom[offset + 1] << 8); } int iwl_eeprom_check_version(struct iwl_priv *priv) @@ -227,8 +227,8 @@ int iwl_eeprom_check_version(struct iwl_priv *priv) u16 eeprom_ver; u16 calib_ver; - eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION); - calib_ver = iwlagn_eeprom_calib_version(priv); + eeprom_ver = iwl_eeprom_query16(priv->shrd, EEPROM_VERSION); + calib_ver = iwl_eeprom_calib_version(priv->shrd); if (eeprom_ver < priv->cfg->eeprom_ver || calib_ver < priv->cfg->eeprom_calib_ver) @@ -249,11 +249,12 @@ err: int iwl_eeprom_check_sku(struct iwl_priv *priv) { + struct iwl_shared *shrd = priv->shrd; u16 radio_cfg; if (!priv->cfg->sku) { /* not using sku overwrite */ - priv->cfg->sku = iwl_eeprom_query16(priv, EEPROM_SKU_CAP); + priv->cfg->sku = iwl_eeprom_query16(shrd, EEPROM_SKU_CAP); if (priv->cfg->sku & EEPROM_SKU_CAP_11N_ENABLE && !priv->cfg->ht_params) { IWL_ERR(priv, "Invalid 11n configuration\n"); @@ -269,7 +270,7 @@ int iwl_eeprom_check_sku(struct iwl_priv *priv) if (!priv->cfg->valid_tx_ant && !priv->cfg->valid_rx_ant) { /* not using .cfg overwrite */ - radio_cfg = iwl_eeprom_query16(priv, EEPROM_RADIO_CONFIG); + radio_cfg = iwl_eeprom_query16(shrd, EEPROM_RADIO_CONFIG); priv->cfg->valid_tx_ant = EEPROM_RF_CFG_TX_ANT_MSK(radio_cfg); priv->cfg->valid_rx_ant = EEPROM_RF_CFG_RX_ANT_MSK(radio_cfg); if (!priv->cfg->valid_tx_ant || !priv->cfg->valid_rx_ant) { @@ -289,9 +290,9 @@ int iwl_eeprom_check_sku(struct iwl_priv *priv) return 0; } -void iwl_eeprom_get_mac(const struct iwl_priv *priv, u8 *mac) +void iwl_eeprom_get_mac(const struct iwl_shared *shrd, u8 *mac) { - const u8 *addr = iwl_eeprom_query_addr(priv, + const u8 *addr = iwl_eeprom_query_addr(shrd, EEPROM_MAC_ADDRESS); memcpy(mac, addr, ETH_ALEN); } @@ -582,6 +583,7 @@ iwl_eeprom_enh_txp_read_element(struct iwl_priv *priv, void iwl_eeprom_enhanced_txpower(struct iwl_priv *priv) { + struct iwl_shared *shrd = priv->shrd; struct iwl_eeprom_enhanced_txpwr *txp_array, *txp; int idx, entries; __le16 *txp_len; @@ -590,10 +592,10 @@ void iwl_eeprom_enhanced_txpower(struct iwl_priv *priv) BUILD_BUG_ON(sizeof(struct iwl_eeprom_enhanced_txpwr) != 8); /* the length is in 16-bit words, but we want entries */ - txp_len = (__le16 *) iwl_eeprom_query_addr(priv, EEPROM_TXP_SZ_OFFS); + txp_len = (__le16 *) iwl_eeprom_query_addr(shrd, EEPROM_TXP_SZ_OFFS); entries = le16_to_cpup(txp_len) * 2 / EEPROM_TXP_ENTRY_LEN; - txp_array = (void *) iwl_eeprom_query_addr(priv, EEPROM_TXP_OFFS); + txp_array = (void *) iwl_eeprom_query_addr(shrd, EEPROM_TXP_OFFS); for (idx = 0; idx < entries; idx++) { txp = &txp_array[idx]; @@ -646,12 +648,13 @@ void iwl_eeprom_enhanced_txpower(struct iwl_priv *priv) /** * iwl_eeprom_init - read EEPROM contents * - * Load the EEPROM contents from adapter into priv->eeprom + * Load the EEPROM contents from adapter into shrd->eeprom * * NOTE: This routine uses the non-debug IO access functions. */ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) { + struct iwl_shared *shrd = priv->shrd; __le16 *e; u32 gp = iwl_read32(bus(priv), CSR_EEPROM_GP); int sz; @@ -666,12 +669,12 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) /* allocate eeprom */ sz = priv->cfg->base_params->eeprom_size; IWL_DEBUG_EEPROM(priv, "NVM size = %d\n", sz); - priv->eeprom = kzalloc(sz, GFP_KERNEL); - if (!priv->eeprom) { + shrd->eeprom = kzalloc(sz, GFP_KERNEL); + if (!shrd->eeprom) { ret = -ENOMEM; goto alloc_err; } - e = (__le16 *)priv->eeprom; + e = (__le16 *)shrd->eeprom; iwl_apm_init(priv); @@ -746,7 +749,7 @@ int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev) IWL_DEBUG_EEPROM(priv, "NVM Type: %s, version: 0x%x\n", (trans(priv)->nvm_device_type == NVM_DEVICE_TYPE_OTP) ? "OTP" : "EEPROM", - iwl_eeprom_query16(priv, EEPROM_VERSION)); + iwl_eeprom_query16(shrd, EEPROM_VERSION)); ret = 0; done: @@ -754,17 +757,17 @@ done: err: if (ret) - iwl_eeprom_free(priv); + iwl_eeprom_free(priv->shrd); /* Reset chip to save power until we load uCode during "up". */ iwl_apm_stop(priv); alloc_err: return ret; } -void iwl_eeprom_free(struct iwl_priv *priv) +void iwl_eeprom_free(struct iwl_shared *shrd) { - kfree(priv->eeprom); - priv->eeprom = NULL; + kfree(shrd->eeprom); + shrd->eeprom = NULL; } static void iwl_init_band_reference(const struct iwl_priv *priv, @@ -772,49 +775,50 @@ static void iwl_init_band_reference(const struct iwl_priv *priv, const struct iwl_eeprom_channel **eeprom_ch_info, const u8 **eeprom_ch_index) { + struct iwl_shared *shrd = priv->shrd; u32 offset = priv->cfg->lib-> eeprom_ops.regulatory_bands[eep_band - 1]; switch (eep_band) { case 1: /* 2.4GHz band */ *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_1); *eeprom_ch_info = (struct iwl_eeprom_channel *) - iwl_eeprom_query_addr(priv, offset); + iwl_eeprom_query_addr(shrd, offset); *eeprom_ch_index = iwl_eeprom_band_1; break; case 2: /* 4.9GHz band */ *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_2); *eeprom_ch_info = (struct iwl_eeprom_channel *) - iwl_eeprom_query_addr(priv, offset); + iwl_eeprom_query_addr(shrd, offset); *eeprom_ch_index = iwl_eeprom_band_2; break; case 3: /* 5.2GHz band */ *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_3); *eeprom_ch_info = (struct iwl_eeprom_channel *) - iwl_eeprom_query_addr(priv, offset); + iwl_eeprom_query_addr(shrd, offset); *eeprom_ch_index = iwl_eeprom_band_3; break; case 4: /* 5.5GHz band */ *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_4); *eeprom_ch_info = (struct iwl_eeprom_channel *) - iwl_eeprom_query_addr(priv, offset); + iwl_eeprom_query_addr(shrd, offset); *eeprom_ch_index = iwl_eeprom_band_4; break; case 5: /* 5.7GHz band */ *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_5); *eeprom_ch_info = (struct iwl_eeprom_channel *) - iwl_eeprom_query_addr(priv, offset); + iwl_eeprom_query_addr(shrd, offset); *eeprom_ch_index = iwl_eeprom_band_5; break; case 6: /* 2.4GHz ht40 channels */ *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_6); *eeprom_ch_info = (struct iwl_eeprom_channel *) - iwl_eeprom_query_addr(priv, offset); + iwl_eeprom_query_addr(shrd, offset); *eeprom_ch_index = iwl_eeprom_band_6; break; case 7: /* 5 GHz ht40 channels */ *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_7); *eeprom_ch_info = (struct iwl_eeprom_channel *) - iwl_eeprom_query_addr(priv, offset); + iwl_eeprom_query_addr(shrd, offset); *eeprom_ch_index = iwl_eeprom_band_7; break; default: @@ -1064,7 +1068,7 @@ void iwl_rf_config(struct iwl_priv *priv) { u16 radio_cfg; - radio_cfg = iwl_eeprom_query16(priv, EEPROM_RADIO_CONFIG); + radio_cfg = iwl_eeprom_query16(priv->shrd, EEPROM_RADIO_CONFIG); /* write radio config values to register */ if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) <= EEPROM_RF_CONFIG_TYPE_MAX) { diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h index c94747e7299e..9fa937ec35e3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h @@ -66,6 +66,7 @@ #include struct iwl_priv; +struct iwl_shared; /* * EEPROM access time values: @@ -305,11 +306,11 @@ struct iwl_eeprom_ops { int iwl_eeprom_init(struct iwl_priv *priv, u32 hw_rev); -void iwl_eeprom_free(struct iwl_priv *priv); +void iwl_eeprom_free(struct iwl_shared *shrd); int iwl_eeprom_check_version(struct iwl_priv *priv); int iwl_eeprom_check_sku(struct iwl_priv *priv); -const u8 *iwl_eeprom_query_addr(const struct iwl_priv *priv, size_t offset); -u16 iwl_eeprom_query16(const struct iwl_priv *priv, size_t offset); +const u8 *iwl_eeprom_query_addr(const struct iwl_shared *shrd, size_t offset); +u16 iwl_eeprom_query16(const struct iwl_shared *shrd, size_t offset); int iwl_init_channel_map(struct iwl_priv *priv); void iwl_free_channel_map(struct iwl_priv *priv); const struct iwl_channel_info *iwl_get_channel_info( diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 39aa9cf5b847..53cddd32fb74 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -351,6 +351,9 @@ struct iwl_shared { wait_queue_head_t wait_command_queue; + /* eeprom -- this is in the card's little endian byte order */ + u8 *eeprom; + /* ucode related variables */ enum iwl_ucode_type ucode_type; diff --git a/drivers/net/wireless/iwlwifi/iwl-testmode.c b/drivers/net/wireless/iwlwifi/iwl-testmode.c index 0b0ff11d5d58..a874eb7b5f8e 100644 --- a/drivers/net/wireless/iwlwifi/iwl-testmode.c +++ b/drivers/net/wireless/iwlwifi/iwl-testmode.c @@ -485,7 +485,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) break; case IWL_TM_CMD_APP2DEV_GET_EEPROM: - if (priv->eeprom) { + if (priv->shrd->eeprom) { skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, priv->cfg->base_params->eeprom_size + 20); if (!skb) { @@ -497,7 +497,7 @@ static int iwl_testmode_driver(struct ieee80211_hw *hw, struct nlattr **tb) IWL_TM_CMD_DEV2APP_EEPROM_RSP); NLA_PUT(skb, IWL_TM_ATTR_EEPROM, priv->cfg->base_params->eeprom_size, - priv->eeprom); + priv->shrd->eeprom); status = cfg80211_testmode_reply(skb); if (status < 0) IWL_DEBUG_INFO(priv, diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index b365de457b1b..f56066964d88 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -217,7 +217,7 @@ static int iwl_set_Xtal_calib(struct iwl_priv *priv) { struct iwl_calib_xtal_freq_cmd cmd; __le16 *xtal_calib = - (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_XTAL); + (__le16 *)iwl_eeprom_query_addr(priv->shrd, EEPROM_XTAL); iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD); cmd.cap_pin1 = le16_to_cpu(xtal_calib[0]); @@ -229,7 +229,8 @@ static int iwl_set_temperature_offset_calib(struct iwl_priv *priv) { struct iwl_calib_temperature_offset_cmd cmd; __le16 *offset_calib = - (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_RAW_TEMPERATURE); + (__le16 *)iwl_eeprom_query_addr(priv->shrd, + EEPROM_RAW_TEMPERATURE); memset(&cmd, 0, sizeof(cmd)); iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD); @@ -245,15 +246,16 @@ static int iwl_set_temperature_offset_calib(struct iwl_priv *priv) static int iwl_set_temperature_offset_calib_v2(struct iwl_priv *priv) { struct iwl_calib_temperature_offset_v2_cmd cmd; - __le16 *offset_calib_high = (__le16 *)iwl_eeprom_query_addr(priv, + __le16 *offset_calib_high = (__le16 *)iwl_eeprom_query_addr(priv->shrd, EEPROM_KELVIN_TEMPERATURE); __le16 *offset_calib_low = - (__le16 *)iwl_eeprom_query_addr(priv, EEPROM_RAW_TEMPERATURE); + (__le16 *)iwl_eeprom_query_addr(priv->shrd, + EEPROM_RAW_TEMPERATURE); struct iwl_eeprom_calib_hdr *hdr; memset(&cmd, 0, sizeof(cmd)); iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD); - hdr = (struct iwl_eeprom_calib_hdr *)iwl_eeprom_query_addr(priv, + hdr = (struct iwl_eeprom_calib_hdr *)iwl_eeprom_query_addr(priv->shrd, EEPROM_CALIB_ALL); memcpy(&cmd.radio_sensor_offset_high, offset_calib_high, sizeof(*offset_calib_high)); -- cgit v1.2.3 From ae6130fc9b5e9957aaf26355b80e0a5ef7f8f537 Mon Sep 17 00:00:00 2001 From: Don Fry Date: Wed, 30 Nov 2011 16:12:59 -0800 Subject: iwlwifi: move device_pointers from iwl_priv to iwl_shared Move the low level ucode device_pointers structure to iwl_shared. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn-rx.c | 2 +- drivers/net/wireless/iwlwifi/iwl-agn.c | 2 +- drivers/net/wireless/iwlwifi/iwl-dev.h | 5 ----- drivers/net/wireless/iwlwifi/iwl-mac80211.c | 2 +- drivers/net/wireless/iwlwifi/iwl-shared.h | 12 ++++++++++-- drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c | 6 +++--- drivers/net/wireless/iwlwifi/iwl-ucode.c | 10 +++++----- 7 files changed, 21 insertions(+), 18 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c index 90c55ea4cc39..9001c23f27bb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rx.c @@ -1165,7 +1165,7 @@ int iwl_rx_dispatch(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb, pkt->hdr.cmd); w->triggered = true; if (w->fn) - w->fn(priv, pkt, w->fn_data); + w->fn(trans(priv), pkt, w->fn_data); } spin_unlock(&priv->shrd->notif_wait_lock); diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 6b99448d4548..02927faa6178 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -366,7 +366,7 @@ static void iwl_continuous_event_trace(struct iwl_priv *priv) u32 num_wraps; /* # times uCode wrapped to top of log */ u32 next_entry; /* index of next entry to be written by uCode */ - base = priv->device_pointers.error_event_table; + base = priv->shrd->device_pointers.error_event_table; if (iwlagn_hw_valid_rtc_data_addr(base)) { capacity = iwl_read_targ_mem(bus(priv), base); num_wraps = iwl_read_targ_mem(bus(priv), diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 68f9dc5e9248..aa225be8dee8 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -865,11 +865,6 @@ struct iwl_priv { __le16 switch_channel; - struct { - u32 error_event_table; - u32 log_event_table; - } device_pointers; - u16 active_rate; u8 start_calib; diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 2dd536c9e192..b3886d20c272 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -427,7 +427,7 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw) iwl_write32(bus(priv), CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_DRV_GP1_BIT_D3_CFG_COMPLETE); - base = priv->device_pointers.error_event_table; + base = priv->shrd->device_pointers.error_event_table; if (iwlagn_hw_valid_rtc_data_addr(base)) { spin_lock_irqsave(&bus(priv)->reg_lock, flags); ret = iwl_grab_nic_access_silent(bus(priv)); diff --git a/drivers/net/wireless/iwlwifi/iwl-shared.h b/drivers/net/wireless/iwlwifi/iwl-shared.h index 53cddd32fb74..29a7284aa3ef 100644 --- a/drivers/net/wireless/iwlwifi/iwl-shared.h +++ b/drivers/net/wireless/iwlwifi/iwl-shared.h @@ -97,6 +97,7 @@ struct iwl_cfg; struct iwl_bus; struct iwl_priv; +struct iwl_trans; struct iwl_sensitivity_ranges; struct iwl_trans_ops; @@ -294,7 +295,7 @@ enum iwl_ucode_type { struct iwl_notification_wait { struct list_head list; - void (*fn)(struct iwl_priv *priv, struct iwl_rx_packet *pkt, + void (*fn)(struct iwl_trans *trans, struct iwl_rx_packet *pkt, void *data); void *fn_data; @@ -323,6 +324,7 @@ struct iwl_notification_wait { * @notif_waits: things waiting for notification * @notif_wait_lock: lock protecting notification * @notif_waitq: head of notification wait queue + * @device_pointers: pointers to ucode event tables */ struct iwl_shared { #ifdef CONFIG_IWLWIFI_DEBUG @@ -361,6 +363,12 @@ struct iwl_shared { struct list_head notif_waits; spinlock_t notif_wait_lock; wait_queue_head_t notif_waitq; + + struct { + u32 error_event_table; + u32 log_event_table; + } device_pointers; + }; /*Whatever _m is (iwl_trans, iwl_priv, iwl_bus, these macros will work */ @@ -510,7 +518,7 @@ void __acquires(wait_entry) iwl_init_notification_wait(struct iwl_shared *shrd, struct iwl_notification_wait *wait_entry, u8 cmd, - void (*fn)(struct iwl_priv *priv, + void (*fn)(struct iwl_trans *trans, struct iwl_rx_packet *pkt, void *data), void *fn_data); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c index a0d43d6636f3..2ee00e0f39d3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie-rx.c @@ -594,7 +594,7 @@ static void iwl_dump_nic_error_log(struct iwl_trans *trans) struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); - base = priv->device_pointers.error_event_table; + base = trans->shrd->device_pointers.error_event_table; if (trans->shrd->ucode_type == IWL_UCODE_INIT) { if (!base) base = priv->init_errlog_ptr; @@ -724,7 +724,7 @@ static int iwl_print_event_log(struct iwl_trans *trans, u32 start_idx, if (num_events == 0) return pos; - base = priv->device_pointers.log_event_table; + base = trans->shrd->device_pointers.log_event_table; if (trans->shrd->ucode_type == IWL_UCODE_INIT) { if (!base) base = priv->init_evtlog_ptr; @@ -838,7 +838,7 @@ int iwl_dump_nic_event_log(struct iwl_trans *trans, bool full_log, size_t bufsz = 0; struct iwl_priv *priv = priv(trans); - base = priv->device_pointers.log_event_table; + base = trans->shrd->device_pointers.log_event_table; if (trans->shrd->ucode_type == IWL_UCODE_INIT) { logsize = priv->init_evtlog_size; if (!base) diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index f56066964d88..256f647763aa 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -550,7 +550,7 @@ struct iwlagn_alive_data { u8 subtype; }; -static void iwl_alive_fn(struct iwl_priv *priv, +static void iwl_alive_fn(struct iwl_trans *trans, struct iwl_rx_packet *pkt, void *data) { @@ -559,14 +559,14 @@ static void iwl_alive_fn(struct iwl_priv *priv, palive = &pkt->u.alive_frame; - IWL_DEBUG_FW(priv, "Alive ucode status 0x%08X revision " + IWL_DEBUG_FW(trans, "Alive ucode status 0x%08X revision " "0x%01X 0x%01X\n", palive->is_valid, palive->ver_type, palive->ver_subtype); - priv->device_pointers.error_event_table = + trans->shrd->device_pointers.error_event_table = le32_to_cpu(palive->error_event_table_ptr); - priv->device_pointers.log_event_table = + trans->shrd->device_pointers.log_event_table = le32_to_cpu(palive->log_event_table_ptr); alive_data->subtype = palive->ver_subtype; @@ -577,7 +577,7 @@ static void iwl_alive_fn(struct iwl_priv *priv, void iwl_init_notification_wait(struct iwl_shared *shrd, struct iwl_notification_wait *wait_entry, u8 cmd, - void (*fn)(struct iwl_priv *priv, + void (*fn)(struct iwl_trans *trans, struct iwl_rx_packet *pkt, void *data), void *fn_data) -- cgit v1.2.3 From 45c30dba1c9358b5446559eff07282c56ada3b4b Mon Sep 17 00:00:00 2001 From: Don Fry Date: Wed, 30 Nov 2011 16:58:39 -0800 Subject: iwlwifi: move calib_results list from iwl_priv to iwl_trans Move the calib_results list from the upper layer iwl_priv structure to the lower layer iwl_trans structure. Signed-off-by: Don Fry Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn-calib.c | 18 +++++++++--------- drivers/net/wireless/iwlwifi/iwl-agn-calib.h | 5 ----- drivers/net/wireless/iwlwifi/iwl-agn.c | 3 +-- drivers/net/wireless/iwlwifi/iwl-dev.h | 12 ------------ drivers/net/wireless/iwlwifi/iwl-trans-pcie.c | 1 + drivers/net/wireless/iwlwifi/iwl-trans.h | 18 ++++++++++++++++++ drivers/net/wireless/iwlwifi/iwl-ucode.c | 10 +++++----- 7 files changed, 34 insertions(+), 33 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c index 4d0210594956..16971a020297 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.c @@ -82,7 +82,7 @@ struct statistics_general_data { u32 beacon_energy_c; }; -int iwl_send_calib_results(struct iwl_priv *priv) +int iwl_send_calib_results(struct iwl_trans *trans) { struct iwl_host_cmd hcmd = { .id = REPLY_PHY_CALIBRATION_CMD, @@ -90,15 +90,15 @@ int iwl_send_calib_results(struct iwl_priv *priv) }; struct iwl_calib_result *res; - list_for_each_entry(res, &priv->calib_results, list) { + list_for_each_entry(res, &trans->calib_results, list) { int ret; hcmd.len[0] = res->cmd_len; hcmd.data[0] = &res->hdr; hcmd.dataflags[0] = IWL_HCMD_DFL_NOCOPY; - ret = iwl_trans_send_cmd(trans(priv), &hcmd); + ret = iwl_trans_send_cmd(trans, &hcmd); if (ret) { - IWL_ERR(priv, "Error %d on calib cmd %d\n", + IWL_ERR(trans, "Error %d on calib cmd %d\n", ret, res->hdr.op_code); return ret; } @@ -107,7 +107,7 @@ int iwl_send_calib_results(struct iwl_priv *priv) return 0; } -int iwl_calib_set(struct iwl_priv *priv, +int iwl_calib_set(struct iwl_trans *trans, const struct iwl_calib_hdr *cmd, int len) { struct iwl_calib_result *res, *tmp; @@ -119,7 +119,7 @@ int iwl_calib_set(struct iwl_priv *priv, memcpy(&res->hdr, cmd, len); res->cmd_len = len; - list_for_each_entry(tmp, &priv->calib_results, list) { + list_for_each_entry(tmp, &trans->calib_results, list) { if (tmp->hdr.op_code == res->hdr.op_code) { list_replace(&tmp->list, &res->list); kfree(tmp); @@ -128,16 +128,16 @@ int iwl_calib_set(struct iwl_priv *priv, } /* wasn't in list already */ - list_add_tail(&res->list, &priv->calib_results); + list_add_tail(&res->list, &trans->calib_results); return 0; } -void iwl_calib_free_results(struct iwl_priv *priv) +void iwl_calib_free_results(struct iwl_trans *trans) { struct iwl_calib_result *res, *tmp; - list_for_each_entry_safe(res, tmp, &priv->calib_results, list) { + list_for_each_entry_safe(res, tmp, &trans->calib_results, list) { list_del(&res->list); kfree(res); } diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-calib.h b/drivers/net/wireless/iwlwifi/iwl-agn-calib.h index 6ed806c8f80f..10275ce92bde 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-calib.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn-calib.h @@ -72,9 +72,4 @@ void iwl_sensitivity_calibration(struct iwl_priv *priv); void iwl_init_sensitivity(struct iwl_priv *priv); void iwl_reset_run_time_calib(struct iwl_priv *priv); -int iwl_send_calib_results(struct iwl_priv *priv); -int iwl_calib_set(struct iwl_priv *priv, - const struct iwl_calib_hdr *cmd, int len); -void iwl_calib_free_results(struct iwl_priv *priv); - #endif /* __iwl_calib_h__ */ diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 02927faa6178..f5fe42dbb3b0 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -1577,7 +1577,7 @@ static int iwl_init_drv(struct iwl_priv *priv) mutex_init(&priv->shrd->mutex); - INIT_LIST_HEAD(&priv->calib_results); + INIT_LIST_HEAD(&trans(priv)->calib_results); priv->ieee_channels = NULL; priv->ieee_rates = NULL; @@ -1635,7 +1635,6 @@ err: static void iwl_uninit_drv(struct iwl_priv *priv) { - iwl_calib_free_results(priv); iwl_free_geos(priv); iwl_free_channel_map(priv); if (priv->tx_cmd_pool) diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index aa225be8dee8..69ecf6e2e658 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h @@ -440,15 +440,6 @@ enum iwlagn_chain_noise_state { IWL_CHAIN_NOISE_DONE, }; - -/* Opaque calibration results */ -struct iwl_calib_result { - struct list_head list; - size_t cmd_len; - struct iwl_calib_hdr hdr; - /* data follows */ -}; - /* Sensitivity calib data */ struct iwl_sensitivity_data { u32 auto_corr_ofdm; @@ -830,9 +821,6 @@ struct iwl_priv { s32 temperature; /* Celsius */ s32 last_temperature; - /* init calibration results */ - struct list_head calib_results; - struct iwl_wipan_noa_data __rcu *noa_data; /* Scan related variables */ diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c index 304b2ea0375c..66e1b9fa0b8b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c +++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c @@ -1373,6 +1373,7 @@ static void iwl_trans_pcie_reclaim(struct iwl_trans *trans, int sta_id, int tid, static void iwl_trans_pcie_free(struct iwl_trans *trans) { + iwl_calib_free_results(trans); iwl_trans_pcie_tx_free(trans); iwl_trans_pcie_rx_free(trans); free_irq(bus(trans)->irq, trans); diff --git a/drivers/net/wireless/iwlwifi/iwl-trans.h b/drivers/net/wireless/iwlwifi/iwl-trans.h index 4a29b8ab998e..f94a6ee5f82f 100644 --- a/drivers/net/wireless/iwlwifi/iwl-trans.h +++ b/drivers/net/wireless/iwlwifi/iwl-trans.h @@ -220,6 +220,14 @@ struct fw_img { struct fw_desc data; /* firmware data image */ }; +/* Opaque calibration results */ +struct iwl_calib_result { + struct list_head list; + size_t cmd_len; + struct iwl_calib_hdr hdr; + /* data follows */ +}; + /** * struct iwl_trans - transport common data * @ops - pointer to iwl_trans_ops @@ -229,6 +237,8 @@ struct fw_img { * @ucode_rt: run time ucode image * @ucode_init: init ucode image * @ucode_wowlan: wake on wireless ucode image (optional) + * @nvm_device_type: indicates OTP or eeprom + * @calib_results: list head for init calibration results */ struct iwl_trans { const struct iwl_trans_ops *ops; @@ -243,6 +253,9 @@ struct iwl_trans { /* eeprom related variables */ int nvm_device_type; + /* init calibration results */ + struct list_head calib_results; + /* pointer to trans specific struct */ /*Ensure that this pointer will always be aligned to sizeof pointer */ char trans_specific[0] __attribute__((__aligned__(sizeof(void *)))); @@ -379,4 +392,9 @@ int iwl_alloc_fw_desc(struct iwl_bus *bus, struct fw_desc *desc, const void *data, size_t len); void iwl_dealloc_ucode(struct iwl_trans *trans); +int iwl_send_calib_results(struct iwl_trans *trans); +int iwl_calib_set(struct iwl_trans *trans, + const struct iwl_calib_hdr *cmd, int len); +void iwl_calib_free_results(struct iwl_trans *trans); + #endif /* __iwl_trans_h__ */ diff --git a/drivers/net/wireless/iwlwifi/iwl-ucode.c b/drivers/net/wireless/iwlwifi/iwl-ucode.c index 256f647763aa..0577212ad3f3 100644 --- a/drivers/net/wireless/iwlwifi/iwl-ucode.c +++ b/drivers/net/wireless/iwlwifi/iwl-ucode.c @@ -222,7 +222,7 @@ static int iwl_set_Xtal_calib(struct iwl_priv *priv) iwl_set_calib_hdr(&cmd.hdr, IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD); cmd.cap_pin1 = le16_to_cpu(xtal_calib[0]); cmd.cap_pin2 = le16_to_cpu(xtal_calib[1]); - return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); + return iwl_calib_set(trans(priv), (void *)&cmd, sizeof(cmd)); } static int iwl_set_temperature_offset_calib(struct iwl_priv *priv) @@ -240,7 +240,7 @@ static int iwl_set_temperature_offset_calib(struct iwl_priv *priv) IWL_DEBUG_CALIB(priv, "Radio sensor offset: %d\n", le16_to_cpu(cmd.radio_sensor_offset)); - return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); + return iwl_calib_set(trans(priv), (void *)&cmd, sizeof(cmd)); } static int iwl_set_temperature_offset_calib_v2(struct iwl_priv *priv) @@ -276,7 +276,7 @@ static int iwl_set_temperature_offset_calib_v2(struct iwl_priv *priv) IWL_DEBUG_CALIB(priv, "Voltage Ref: %d\n", le16_to_cpu(cmd.burntVoltageRef)); - return iwl_calib_set(priv, (void *)&cmd, sizeof(cmd)); + return iwl_calib_set(trans(priv), (void *)&cmd, sizeof(cmd)); } static int iwl_send_calib_cfg(struct iwl_trans *trans) @@ -309,7 +309,7 @@ int iwlagn_rx_calib_result(struct iwl_priv *priv, /* reduce the size of the length field itself */ len -= 4; - if (iwl_calib_set(priv, hdr, len)) + if (iwl_calib_set(trans(priv), hdr, len)) IWL_ERR(priv, "Failed to record calibration data %d\n", hdr->op_code); @@ -459,7 +459,7 @@ static int iwl_alive_notify(struct iwl_priv *priv) return ret; } - return iwl_send_calib_results(priv); + return iwl_send_calib_results(trans(priv)); } -- cgit v1.2.3 From 9a215e40d70ae63762963ab3ccc7f31dd966dc6a Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 2 Dec 2011 12:22:54 -0800 Subject: iwlagn: fix TID use bug The driver everywhere uses max TID count as 9, which is wrong, it should be 8. I think the reason it uses 9 here is off-by-one confusion by whoever wrote this. We do use the value IWL_MAX_TID_COUNT for "not QoS/no TID" but that is completely correct even if it is 8 and not 9 since 0-7 are only valid. As a side effect, this fixes the following bug: Open BA session requested for 00:23:cd:16:8a:7e tid 8 ------------[ cut here ]------------ kernel BUG at drivers/net/wireless/iwlwifi/iwl-trans-pcie-int.h:350! ... when you do echo "tx start 8" > /sys/kernel/debug/ieee80211/*/*/*/*/agg_status Cc: stable@vger.kernel.org Reported-by: Nikolay Martynov Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-commands.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h index 87bfdf6bdf6a..265de39d394c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-commands.h +++ b/drivers/net/wireless/iwlwifi/iwl-commands.h @@ -814,7 +814,7 @@ struct iwl_qosparam_cmd { #define IWLAGN_STATION_COUNT 16 #define IWL_INVALID_STATION 255 -#define IWL_MAX_TID_COUNT 9 +#define IWL_MAX_TID_COUNT 8 #define STA_FLG_TX_RATE_MSK cpu_to_le32(1 << 2) #define STA_FLG_PWR_SAVE_MSK cpu_to_le32(1 << 8) -- cgit v1.2.3 From e0467a30734a8dc2ecddbe892985ce5cfe5bf966 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 2 Dec 2011 12:24:45 -0800 Subject: iwlagn: use IWL_MAX_TID_COUNT for WoWLAN Now that I corrected IWL_MAX_TID_COUNT to be 8 instead of 9, we can use it in WoWLAN suspend. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn-lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c index 1d6342213443..057f95233567 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-lib.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-lib.c @@ -1157,7 +1157,7 @@ int iwlagn_suspend(struct iwl_priv *priv, * For QoS counters, we store the one to use next, so subtract 0x10 * since the uCode will add 0x10 before using the value. */ - for (i = 0; i < 8; i++) { + for (i = 0; i < IWL_MAX_TID_COUNT; i++) { seq = priv->shrd->tid_data[IWL_AP_ID][i].seq_number; seq -= 0x10; wakeup_filter_cmd.qos_seq[i] = cpu_to_le16(seq); -- cgit v1.2.3 From a844855344b035338bfbcb1d2b7ed0aaca241a95 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 2 Dec 2011 12:25:12 -0800 Subject: iwlagn: use IWL_MAX_TID_COUNT instead of TID_MAX_LOAD_COUNT We track the load only on 8 TIDs, previously this was TID_MAX_LOAD_COUNT. Since IWL_MAX_TID_COUNT is now 8 as well, use that to make the code more easily understandable. Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy --- drivers/net/wireless/iwlwifi/iwl-agn-rs.c | 10 +++++----- drivers/net/wireless/iwlwifi/iwl-agn-rs.h | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c index 78efa2bb526f..a23835a7797a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c @@ -298,7 +298,7 @@ static u8 rs_tl_add_packet(struct iwl_lq_sta *lq_data, } else return IWL_MAX_TID_COUNT; - if (unlikely(tid >= TID_MAX_LOAD_COUNT)) + if (unlikely(tid >= IWL_MAX_TID_COUNT)) return IWL_MAX_TID_COUNT; tl = &lq_data->load[tid]; @@ -379,7 +379,7 @@ static u32 rs_tl_get_load(struct iwl_lq_sta *lq_data, u8 tid) s32 index; struct iwl_traffic_load *tl = NULL; - if (tid >= TID_MAX_LOAD_COUNT) + if (tid >= IWL_MAX_TID_COUNT) return 0; tl = &(lq_data->load[tid]); @@ -444,11 +444,11 @@ static void rs_tl_turn_on_agg(struct iwl_priv *priv, u8 tid, struct iwl_lq_sta *lq_data, struct ieee80211_sta *sta) { - if (tid < TID_MAX_LOAD_COUNT) + if (tid < IWL_MAX_TID_COUNT) rs_tl_turn_on_agg_for_tid(priv, lq_data, tid, sta); else - IWL_ERR(priv, "tid exceeds max load count: %d/%d\n", - tid, TID_MAX_LOAD_COUNT); + IWL_ERR(priv, "tid exceeds max TID count: %d/%d\n", + tid, IWL_MAX_TID_COUNT); } static inline int get_num_of_ant_from_rate(u32 rate_n_flags) diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h index f4f6deb829ae..6675b3c816d9 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h @@ -281,7 +281,6 @@ enum { #define TID_QUEUE_CELL_SPACING 50 /*mS */ #define TID_QUEUE_MAX_SIZE 20 #define TID_ROUND_VALUE 5 /* mS */ -#define TID_MAX_LOAD_COUNT 8 #define TID_MAX_TIME_DIFF ((TID_QUEUE_MAX_SIZE - 1) * TID_QUEUE_CELL_SPACING) #define TIME_WRAP_AROUND(x, y) (((y) > (x)) ? (y) - (x) : (0-(x)) + (y)) @@ -402,7 +401,7 @@ struct iwl_lq_sta { struct iwl_link_quality_cmd lq; struct iwl_scale_tbl_info lq_info[LQ_SIZE]; /* "active", "search" */ - struct iwl_traffic_load load[TID_MAX_LOAD_COUNT]; + struct iwl_traffic_load load[IWL_MAX_TID_COUNT]; u8 tx_agg_tid_en; #ifdef CONFIG_MAC80211_DEBUGFS struct dentry *rs_sta_dbgfs_scale_table_file; -- cgit v1.2.3 From cf00f379d82d170712150588accd2ebe316c2226 Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Thu, 8 Dec 2011 16:15:58 -0500 Subject: wl12xx: silence tx_attr uninitialized warning in wl1271_tx_fill_hdr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CC [M] drivers/net/wireless/wl12xx/tx.o drivers/net/wireless/wl12xx/tx.c: In function ‘wl1271_tx_fill_hdr’: drivers/net/wireless/wl12xx/tx.c:288:6: warning: ‘tx_attr’ may be used uninitialized in this function Signed-off-by: John W. Linville --- drivers/net/wireless/wl12xx/tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 36eb0d66fd66..7d727ee6ddf6 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -285,7 +285,7 @@ static void wl1271_tx_fill_hdr(struct wl1271 *wl, struct wl12xx_vif *wlvif, struct wl1271_tx_hw_descr *desc; int aligned_len, ac, rate_idx; s64 hosttime; - u16 tx_attr; + u16 tx_attr = 0; bool is_dummy; desc = (struct wl1271_tx_hw_descr *) skb->data; -- cgit v1.2.3 From b6a27d1e6b8e163dee054c9cd03639c62756c2e2 Mon Sep 17 00:00:00 2001 From: Nikolay Martynov Date: Thu, 8 Dec 2011 21:43:39 -0500 Subject: iwlwifi regression in 20111205 merge It looks like the regression was introduced between 20111202 and 20111205 (linux-next tree). Symptoms: connection to AP seem to be established, but no data goes though it in any way. Tested on intel 5300. Peek at the changes have shown that it looks like at least part of the code wasn't merged properly. It was originally committed into iwl_agn.c but code in question was moved to iwl-mac80211.c. This patch puts code in place and my card works again. Signed-off-by: Nikolay Martynov Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-mac80211.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-mac80211.c b/drivers/net/wireless/iwlwifi/iwl-mac80211.c index 794b735264e6..55308b88faac 100644 --- a/drivers/net/wireless/iwlwifi/iwl-mac80211.c +++ b/drivers/net/wireless/iwlwifi/iwl-mac80211.c @@ -517,6 +517,17 @@ static int iwlagn_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, return -EOPNOTSUPP; } + switch (key->cipher) { + case WLAN_CIPHER_SUITE_TKIP: + key->flags |= IEEE80211_KEY_FLAG_GENERATE_MMIC; + /* fall through */ + case WLAN_CIPHER_SUITE_CCMP: + key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; + break; + default: + break; + } + /* * We could program these keys into the hardware as well, but we * don't expect much multicast traffic in IBSS and having keys -- cgit v1.2.3 From 123877b80ed62c3b897c53357b622574c023b642 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Thu, 8 Dec 2011 15:52:00 -0800 Subject: iwlwifi: do not set the sequence control bit is not needed Check the IEEE80211_TX_CTL_ASSIGN_SEQ flag from mac80211, then decide how to set the TX_CMD_FLG_SEQ_CTL_MSK bit. Setting the wrong bit in BAR frame whill make the firmware to increment the sequence number which is incorrect and cause unknown behavior. CC: stable@vger.kernel.org #3.0+ Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index 35a6b71f358c..df1540ca6102 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c @@ -91,7 +91,10 @@ static void iwlagn_tx_cmd_build_basic(struct iwl_priv *priv, tx_cmd->tid_tspec = qc[0] & 0xf; tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK; } else { - tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; + if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) + tx_flags |= TX_CMD_FLG_SEQ_CTL_MSK; + else + tx_flags &= ~TX_CMD_FLG_SEQ_CTL_MSK; } iwlagn_tx_cmd_protection(priv, info, fc, &tx_flags); -- cgit v1.2.3 From 10636bc2d60942254bda149827b922c41f4cb4af Mon Sep 17 00:00:00 2001 From: Rajkumar Manoharan Date: Sat, 10 Dec 2011 18:59:43 +0530 Subject: ath9k: fix max phy rate at rate control init The stations always chooses 1Mbps for all trasmitting frames, whenever the AP is configured to lock the supported rates. As the max phy rate is always set with the 4th from highest phy rate, this assumption might be wrong if we have less than that. Fix that. Cc: stable@kernel.org Cc: Paul Stewart Reported-by: Ajay Gummalla Signed-off-by: Rajkumar Manoharan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/rc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/rc.c b/drivers/net/wireless/ath/ath9k/rc.c index 8448281dd069..cc5703b853bc 100644 --- a/drivers/net/wireless/ath/ath9k/rc.c +++ b/drivers/net/wireless/ath/ath9k/rc.c @@ -1270,7 +1270,9 @@ static void ath_rc_init(struct ath_softc *sc, ath_rc_priv->max_valid_rate = k; ath_rc_sort_validrates(rate_table, ath_rc_priv); - ath_rc_priv->rate_max_phy = ath_rc_priv->valid_rate_index[k-4]; + ath_rc_priv->rate_max_phy = (k > 4) ? + ath_rc_priv->valid_rate_index[k-4] : + ath_rc_priv->valid_rate_index[k-1]; ath_rc_priv->rate_table = rate_table; ath_dbg(common, ATH_DBG_CONFIG, -- cgit v1.2.3 From 93fdd59463369f07b69cf7397ccb9b1d28a84df4 Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Thu, 8 Dec 2011 11:59:02 +0530 Subject: ath9k_hw: check for asynchronous interrupts before bailing out in ar9003_hw_get_isr we bail out if we don't have any primary interrupts and synchronous interrupts, also make sure we don't have any asynchronous interrupts Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9003_mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c index 95587e36ab9c..508c2022ea9f 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c @@ -220,7 +220,7 @@ static bool ar9003_hw_get_isr(struct ath_hw *ah, enum ath9k_int *masked) *masked = 0; - if (!isr && !sync_cause) + if (!isr && !sync_cause && !async_cause) return false; if (isr) { -- cgit v1.2.3 From cc78d6b16a6853a3f6c014a6173df41d80f65a35 Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Thu, 8 Dec 2011 11:59:03 +0530 Subject: ath9k_hw: Fix handling of MCI interrupt in my previous patches of handling MCI interrupt I overlooked the case of interrupt status/mask variable being zeroed out in the below code, so ath_isr does not cache the MCI interrupt in the intrstatus. finally MCI interrupt handling won't be handled in ath9k_tasklet for the scheduled interrupts. Fix this by moving the MCI interrupt code in the appropriate position in ar9003_hw_get_isr Cc: Wilson Tsao Cc: Rajkumar Manoharan Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ar9003_mac.c | 57 +++++++++++++++-------------- 1 file changed, 29 insertions(+), 28 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c index 508c2022ea9f..631fe4f2e495 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c @@ -187,34 +187,6 @@ static bool ar9003_hw_get_isr(struct ath_hw *ah, enum ath9k_int *masked) isr = REG_READ(ah, AR_ISR); } - if (async_cause & AR_INTR_ASYNC_MASK_MCI) { - u32 raw_intr, rx_msg_intr; - - rx_msg_intr = REG_READ(ah, AR_MCI_INTERRUPT_RX_MSG_RAW); - raw_intr = REG_READ(ah, AR_MCI_INTERRUPT_RAW); - - if ((raw_intr == 0xdeadbeef) || (rx_msg_intr == 0xdeadbeef)) - ath_dbg(common, ATH_DBG_MCI, - "MCI gets 0xdeadbeef during MCI int processing" - "new raw_intr=0x%08x, new rx_msg_raw=0x%08x, " - "raw_intr=0x%08x, rx_msg_raw=0x%08x\n", - raw_intr, rx_msg_intr, mci->raw_intr, - mci->rx_msg_intr); - else { - mci->rx_msg_intr |= rx_msg_intr; - mci->raw_intr |= raw_intr; - *masked |= ATH9K_INT_MCI; - - if (rx_msg_intr & AR_MCI_INTERRUPT_RX_MSG_CONT_INFO) - mci->cont_status = - REG_READ(ah, AR_MCI_CONT_STATUS); - - REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_RAW, rx_msg_intr); - REG_WRITE(ah, AR_MCI_INTERRUPT_RAW, raw_intr); - ath_dbg(common, ATH_DBG_MCI, "AR_INTR_SYNC_MCI\n"); - - } - } sync_cause = REG_READ(ah, AR_INTR_SYNC_CAUSE) & AR_INTR_SYNC_DEFAULT; @@ -326,6 +298,35 @@ static bool ar9003_hw_get_isr(struct ath_hw *ah, enum ath9k_int *masked) ar9003_hw_bb_watchdog_read(ah); } + if (async_cause & AR_INTR_ASYNC_MASK_MCI) { + u32 raw_intr, rx_msg_intr; + + rx_msg_intr = REG_READ(ah, AR_MCI_INTERRUPT_RX_MSG_RAW); + raw_intr = REG_READ(ah, AR_MCI_INTERRUPT_RAW); + + if ((raw_intr == 0xdeadbeef) || (rx_msg_intr == 0xdeadbeef)) + ath_dbg(common, ATH_DBG_MCI, + "MCI gets 0xdeadbeef during MCI int processing" + "new raw_intr=0x%08x, new rx_msg_raw=0x%08x, " + "raw_intr=0x%08x, rx_msg_raw=0x%08x\n", + raw_intr, rx_msg_intr, mci->raw_intr, + mci->rx_msg_intr); + else { + mci->rx_msg_intr |= rx_msg_intr; + mci->raw_intr |= raw_intr; + *masked |= ATH9K_INT_MCI; + + if (rx_msg_intr & AR_MCI_INTERRUPT_RX_MSG_CONT_INFO) + mci->cont_status = + REG_READ(ah, AR_MCI_CONT_STATUS); + + REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_RAW, rx_msg_intr); + REG_WRITE(ah, AR_MCI_INTERRUPT_RAW, raw_intr); + ath_dbg(common, ATH_DBG_MCI, "AR_INTR_SYNC_MCI\n"); + + } + } + if (sync_cause) { if (sync_cause & AR_INTR_SYNC_RADM_CPL_TIMEOUT) { REG_WRITE(ah, AR_RC, AR_RC_HOSTIF); -- cgit v1.2.3 From 43fcb430a4cfb7bd7c82600edeb3ca65f202a5f3 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 8 Dec 2011 23:59:23 +0530 Subject: ath: add a helper for processing reg data on init This has no functional change. The helper can be used later for other things like country IE changes and following the CTL for different countries. Signed-off-by: Luis R. Rodriguez Acked-by: Luis R. Rodriguez Signed-off-by: John W. Linville --- drivers/net/wireless/ath/regd.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/regd.c b/drivers/net/wireless/ath/regd.c index 65ecb5bab25a..ed4966fdb8d3 100644 --- a/drivers/net/wireless/ath/regd.c +++ b/drivers/net/wireless/ath/regd.c @@ -508,11 +508,7 @@ static void ath_regd_sanitize(struct ath_regulatory *reg) reg->current_rd = 0x64; } -int -ath_regd_init(struct ath_regulatory *reg, - struct wiphy *wiphy, - int (*reg_notifier)(struct wiphy *wiphy, - struct regulatory_request *request)) +static int __ath_regd_init(struct ath_regulatory *reg) { struct country_code_to_enum_rd *country = NULL; u16 regdmn; @@ -583,7 +579,23 @@ ath_regd_init(struct ath_regulatory *reg, printk(KERN_DEBUG "ath: Regpair used: 0x%0x\n", reg->regpair->regDmnEnum); + return 0; +} + +int +ath_regd_init(struct ath_regulatory *reg, + struct wiphy *wiphy, + int (*reg_notifier)(struct wiphy *wiphy, + struct regulatory_request *request)) +{ + int r; + + r = __ath_regd_init(reg); + if (r) + return r; + ath_regd_init_wiphy(reg, wiphy, reg_notifier); + return 0; } EXPORT_SYMBOL(ath_regd_init); -- cgit v1.2.3 From de1c732b1891a25f3f2f52ef7211a3d567bbd588 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 8 Dec 2011 23:59:24 +0530 Subject: ath: optimize processing of CTLs for country IEs for world roaming cards When we receive a country IE hint and we have a world roaming card we can optimize output power further by ensuring that we use the calibrated data for the country by using that country's own CTL data. That is -- when world roaming and when we process a country IE we no longer need to use the lowest output power of all CTLs instead we use an optimized CTL output power for that specific country. We accomplish this by copying the regulatory data prior on init and restoring it when cfg80211 tells us it gets a core hint. Core hints are only sent on init and when it wants to restore reguulatory settings. We take advantage of this fact and apply the cached regulatory data when we get a core hint. When we get a country IE hint though we process the regulatory data as if programmed for a specific country. Tested-by: Rajkumar Manoharan Signed-off-by: Luis R. Rodriguez Acked-by: Luis R. Rodriguez Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath.h | 1 + drivers/net/wireless/ath/regd.c | 55 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 52 insertions(+), 4 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h index 4596c33a7a69..3e4dd2d483b8 100644 --- a/drivers/net/wireless/ath/ath.h +++ b/drivers/net/wireless/ath/ath.h @@ -152,6 +152,7 @@ struct ath_common { struct ath_cycle_counters cc_survey; struct ath_regulatory regulatory; + struct ath_regulatory reg_world_copy; const struct ath_ops *ops; const struct ath_bus_ops *bus_ops; diff --git a/drivers/net/wireless/ath/regd.c b/drivers/net/wireless/ath/regd.c index ed4966fdb8d3..10dea37431b3 100644 --- a/drivers/net/wireless/ath/regd.c +++ b/drivers/net/wireless/ath/regd.c @@ -21,6 +21,8 @@ #include "regd.h" #include "regd_common.h" +static int __ath_regd_init(struct ath_regulatory *reg); + /* * This is a set of common rules used by our world regulatory domains. * We have 12 world regulatory domains. To save space we consolidate @@ -347,10 +349,26 @@ static void ath_reg_apply_world_flags(struct wiphy *wiphy, } } +static u16 ath_regd_find_country_by_name(char *alpha2) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(allCountries); i++) { + if (!memcmp(allCountries[i].isoName, alpha2, 2)) + return allCountries[i].countryCode; + } + + return -1; +} + int ath_reg_notifier_apply(struct wiphy *wiphy, struct regulatory_request *request, struct ath_regulatory *reg) { + struct ath_common *common = container_of(reg, struct ath_common, + regulatory); + u16 country_code; + /* We always apply this */ ath_reg_apply_radar_flags(wiphy); @@ -363,14 +381,37 @@ int ath_reg_notifier_apply(struct wiphy *wiphy, return 0; switch (request->initiator) { - case NL80211_REGDOM_SET_BY_DRIVER: case NL80211_REGDOM_SET_BY_CORE: + /* + * If common->reg_world_copy is world roaming it means we *were* + * world roaming... so we now have to restore that data. + */ + if (!ath_is_world_regd(&common->reg_world_copy)) + break; + + memcpy(reg, &common->reg_world_copy, + sizeof(struct ath_regulatory)); + break; + case NL80211_REGDOM_SET_BY_DRIVER: case NL80211_REGDOM_SET_BY_USER: break; case NL80211_REGDOM_SET_BY_COUNTRY_IE: - if (ath_is_world_regd(reg)) - ath_reg_apply_world_flags(wiphy, request->initiator, - reg); + if (!ath_is_world_regd(reg)) + break; + + country_code = ath_regd_find_country_by_name(request->alpha2); + if (country_code == (u16) -1) + break; + + reg->current_rd = COUNTRY_ERD_FLAG; + reg->current_rd |= country_code; + + printk(KERN_DEBUG "ath: regdomain 0x%0x updated by CountryIE\n", + reg->current_rd); + __ath_regd_init(reg); + + ath_reg_apply_world_flags(wiphy, request->initiator, reg); + break; } @@ -588,12 +629,18 @@ ath_regd_init(struct ath_regulatory *reg, int (*reg_notifier)(struct wiphy *wiphy, struct regulatory_request *request)) { + struct ath_common *common = container_of(reg, struct ath_common, + regulatory); int r; r = __ath_regd_init(reg); if (r) return r; + if (ath_is_world_regd(reg)) + memcpy(&common->reg_world_copy, reg, + sizeof(struct ath_regulatory)); + ath_regd_init_wiphy(reg, wiphy, reg_notifier); return 0; -- cgit v1.2.3 From 687f545ecf5600cf43717f937d94d859e105574c Mon Sep 17 00:00:00 2001 From: Rajkumar Manoharan Date: Thu, 8 Dec 2011 23:59:25 +0530 Subject: ath9k: Reconfigure tx power on regulatory update Whenever the regulatory got updated by country IE for the world roaming cards, need to reconfigure the tx power immediately to increase the power level. Reviewed-by: Sam Leffler Signed-off-by: Rajkumar Manoharan Acked-by: Luis R. Rodriguez Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/init.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c index 41b72faca77f..c5df98139c4d 100644 --- a/drivers/net/wireless/ath/ath9k/init.c +++ b/drivers/net/wireless/ath/ath9k/init.c @@ -297,9 +297,22 @@ static int ath9k_reg_notifier(struct wiphy *wiphy, { struct ieee80211_hw *hw = wiphy_to_ieee80211_hw(wiphy); struct ath_softc *sc = hw->priv; - struct ath_regulatory *reg = ath9k_hw_regulatory(sc->sc_ah); + struct ath_hw *ah = sc->sc_ah; + struct ath_regulatory *reg = ath9k_hw_regulatory(ah); + int ret; + + ret = ath_reg_notifier_apply(wiphy, request, reg); + + /* Set tx power */ + if (ah->curchan) { + sc->config.txpowlimit = 2 * ah->curchan->chan->max_power; + ath9k_ps_wakeup(sc); + ath9k_hw_set_txpowerlimit(ah, sc->config.txpowlimit, false); + sc->curtxpow = ath9k_hw_regulatory(ah)->power_limit; + ath9k_ps_restore(sc); + } - return ath_reg_notifier_apply(wiphy, request, reg); + return ret; } /* -- cgit v1.2.3 From d76d1c8c1deebe0c71872ac4e500d6a2233f80ff Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Thu, 8 Dec 2011 15:06:37 -0800 Subject: brcm80211: fmac: save bus interface structure in function 2 device bus interface was stored in sdio card device. The device pointer is used as parameter of interface functions between common layer and bus layer to make the function declaration generic for different bus type. But the card device is a parent device layer for SDIO function devices. It doesn't contain all contexts needed by udev. This patch moves the shared structure to private driver data pointer of SDIO function 2 device which is more appopriate for net device and cfg80211 registration. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c | 3 +-- .../net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 23 +++++++++++----------- .../net/wireless/brcm80211/brcmfmac/sdio_host.h | 1 + 3 files changed, 13 insertions(+), 14 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c index 74933dccf69e..6c85d668c9d7 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c @@ -40,8 +40,7 @@ static void brcmf_sdioh_irqhandler(struct sdio_func *func) { - struct brcmf_bus *bus_if = dev_get_drvdata(&func->card->dev); - struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv; + struct brcmf_sdio_dev *sdiodev = dev_get_drvdata(&func->card->dev); brcmf_dbg(TRACE, "***IRQHandler\n"); diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c index b416e274c677..bc992675eb98 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -481,12 +481,12 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, kfree(bus_if); return -ENOMEM; } - sdiodev->dev = &func->card->dev; sdiodev->func[0] = func->card->sdio_func[0]; sdiodev->func[1] = func; + sdiodev->bus_if = bus_if; bus_if->bus_priv = sdiodev; bus_if->type = SDIO_BUS; - dev_set_drvdata(&func->card->dev, bus_if); + dev_set_drvdata(&func->card->dev, sdiodev); atomic_set(&sdiodev->suspend, false); init_waitqueue_head(&sdiodev->request_byte_wait); @@ -496,12 +496,15 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, } if (func->num == 2) { - bus_if = dev_get_drvdata(&func->card->dev); - sdiodev = bus_if->bus_priv; + sdiodev = dev_get_drvdata(&func->card->dev); if ((!sdiodev) || (sdiodev->func[1]->card != func->card)) return -ENODEV; sdiodev->func[2] = func; + bus_if = sdiodev->bus_if; + sdiodev->dev = &func->dev; + dev_set_drvdata(&func->dev, bus_if); + brcmf_dbg(TRACE, "F2 found, calling brcmf_sdio_probe...\n"); ret = brcmf_sdio_probe(sdiodev); } @@ -520,11 +523,12 @@ static void brcmf_ops_sdio_remove(struct sdio_func *func) brcmf_dbg(INFO, "Function#: 0x%04x\n", func->num); if (func->num == 2) { - bus_if = dev_get_drvdata(&func->card->dev); + bus_if = dev_get_drvdata(&func->dev); sdiodev = bus_if->bus_priv; brcmf_dbg(TRACE, "F2 found, calling brcmf_sdio_remove...\n"); brcmf_sdio_remove(sdiodev); dev_set_drvdata(&func->card->dev, NULL); + dev_set_drvdata(&func->dev, NULL); kfree(bus_if); kfree(sdiodev); } @@ -534,15 +538,12 @@ static void brcmf_ops_sdio_remove(struct sdio_func *func) static int brcmf_sdio_suspend(struct device *dev) { mmc_pm_flag_t sdio_flags; - struct brcmf_sdio_dev *sdiodev; struct sdio_func *func = dev_to_sdio_func(dev); - struct brcmf_bus *bus_if = dev_get_drvdata(&func->card->dev); + struct brcmf_sdio_dev *sdiodev = dev_get_drvdata(&func->card->dev); int ret = 0; brcmf_dbg(TRACE, "\n"); - sdiodev = bus_if->bus_priv; - atomic_set(&sdiodev->suspend, true); sdio_flags = sdio_get_host_pm_caps(sdiodev->func[1]); @@ -564,11 +565,9 @@ static int brcmf_sdio_suspend(struct device *dev) static int brcmf_sdio_resume(struct device *dev) { - struct brcmf_sdio_dev *sdiodev; struct sdio_func *func = dev_to_sdio_func(dev); - struct brcmf_bus *bus_if = dev_get_drvdata(&func->card->dev); + struct brcmf_sdio_dev *sdiodev = dev_get_drvdata(&func->card->dev); - sdiodev = bus_if->bus_priv; brcmf_sdio_wdtmr_enable(sdiodev, true); atomic_set(&sdiodev->suspend, false); return 0; diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h b/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h index c4c2543438ec..d36a2a855a65 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_host.h @@ -135,6 +135,7 @@ struct brcmf_sdio_dev { wait_queue_head_t request_chain_wait; wait_queue_head_t request_buffer_wait; struct device *dev; + struct brcmf_bus *bus_if; }; /* Register/deregister device interrupt handler. */ -- cgit v1.2.3 From e40aed0638ac84d63a2ff33502e215ac81010a89 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Thu, 8 Dec 2011 15:06:38 -0800 Subject: brcm80211: fmac: fix firmware shared structures version Some shared structures in fullmac have a wrong combination of version number and declarations. This patch fixes it by upgrading them to the latest version. This allows brcmfmac to support new firmwares with new features. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Reviewed-by: Alwin Beukers Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmfmac/dhd.h | 2 +- drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h index b68d1363105c..ed60f4d69627 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd.h @@ -87,7 +87,7 @@ #define TOE_TX_CSUM_OL 0x00000001 #define TOE_RX_CSUM_OL 0x00000002 -#define BRCMF_BSS_INFO_VERSION 108 /* curr ver of brcmf_bss_info_le struct */ +#define BRCMF_BSS_INFO_VERSION 109 /* curr ver of brcmf_bss_info_le struct */ /* size of brcmf_scan_params not including variable length array */ #define BRCMF_SCAN_PARAMS_FIXED_SIZE 64 diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c index a527d5d4cc4e..ebd53aa7202b 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_cdc.c @@ -58,7 +58,7 @@ struct brcmf_proto_cdc_dcmd { * Used on data packets to convey priority across USB. */ #define BDC_HEADER_LEN 4 -#define BDC_PROTO_VER 1 /* Protocol version */ +#define BDC_PROTO_VER 2 /* Protocol version */ #define BDC_FLAG_VER_MASK 0xf0 /* Protocol version mask */ #define BDC_FLAG_VER_SHIFT 4 /* Protocol version shift */ #define BDC_FLAG_SUM_GOOD 0x04 /* Good RX checksums */ @@ -77,7 +77,7 @@ struct brcmf_proto_bdc_header { u8 flags; u8 priority; /* 802.1d Priority, 4:7 flow control info for usb */ u8 flags2; - u8 rssi; + u8 data_offset; }; @@ -372,7 +372,7 @@ void brcmf_proto_hdrpush(struct brcmf_pub *drvr, int ifidx, h->priority = (pktbuf->priority & BDC_PRIORITY_MASK); h->flags2 = 0; - h->rssi = 0; + h->data_offset = 0; BDC_SET_IF_IDX(h, ifidx); } -- cgit v1.2.3 From ce2d7d7e8fd88191f5d1c92a8b33aeb0cb12ea34 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Thu, 8 Dec 2011 15:06:39 -0800 Subject: brcm80211: fmac: add bcm4330 support This patch adds support for bcm4330 chip which has a SDIO device id 0x4330. All basic functionalities of bcm4330 are supported by brcmfmac after this patch. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- .../net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c | 2 ++ drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c | 2 ++ .../net/wireless/brcm80211/brcmfmac/sdio_chip.c | 34 ++++++++++++++++++++++ 3 files changed, 38 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c index bc992675eb98..b895f198a950 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh_sdmmc.c @@ -40,6 +40,7 @@ #define DMA_ALIGN_MASK 0x03 #define SDIO_DEVICE_ID_BROADCOM_4329 0x4329 +#define SDIO_DEVICE_ID_BROADCOM_4330 0x4330 #define SDIO_FUNC1_BLOCKSIZE 64 #define SDIO_FUNC2_BLOCKSIZE 512 @@ -47,6 +48,7 @@ /* devices we support, null terminated */ static const struct sdio_device_id brcmf_sdmmc_ids[] = { {SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4329)}, + {SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4330)}, { /* end: all zeroes */ }, }; MODULE_DEVICE_TABLE(sdio, brcmf_sdmmc_ids); diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 18597fe5dfd6..43ba0dd48354 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -3636,6 +3636,8 @@ static bool brcmf_sdbrcm_chipmatch(u16 chipid) { if (chipid == BCM4329_CHIP_ID) return true; + if (chipid == BCM4330_CHIP_ID) + return true; return false; } diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c index f6b1822031fe..d299059a2815 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c @@ -91,6 +91,18 @@ static const struct sdiod_drive_str sdiod_drive_strength_tab3[] = { 0, 0x0} }; +/* SDIO Drive Strength to sel value table for PMU Rev 11 (1.8V) */ +static const struct sdiod_drive_str sdiod_drvstr_tab4_1v8[] = { + {32, 0x6}, + {26, 0x7}, + {22, 0x4}, + {16, 0x5}, + {12, 0x2}, + {8, 0x3}, + {4, 0x0}, + {0, 0x1} +}; + u8 brcmf_sdio_chip_getinfidx(struct chip_info *ci, u16 coreid) { @@ -396,6 +408,23 @@ static int brcmf_sdio_chip_recognition(struct brcmf_sdio_dev *sdiodev, ci->c_inf[3].base = BCM4329_CORE_ARM_BASE; ci->ramsize = BCM4329_RAMSIZE; break; + case BCM4330_CHIP_ID: + ci->c_inf[0].wrapbase = 0x18100000; + ci->c_inf[0].cib = 0x27004211; + ci->c_inf[1].id = BCMA_CORE_SDIO_DEV; + ci->c_inf[1].base = 0x18002000; + ci->c_inf[1].wrapbase = 0x18102000; + ci->c_inf[1].cib = 0x07004211; + ci->c_inf[2].id = BCMA_CORE_INTERNAL_MEM; + ci->c_inf[2].base = 0x18004000; + ci->c_inf[2].wrapbase = 0x18104000; + ci->c_inf[2].cib = 0x0d080401; + ci->c_inf[3].id = BCMA_CORE_ARM_CM3; + ci->c_inf[3].base = 0x18003000; + ci->c_inf[3].wrapbase = 0x18103000; + ci->c_inf[3].cib = 0x03004211; + ci->ramsize = 0x48000; + break; default: brcmf_dbg(ERROR, "chipid 0x%x is not supported\n", ci->chip); return -ENODEV; @@ -585,6 +614,11 @@ brcmf_sdio_chip_drivestrengthinit(struct brcmf_sdio_dev *sdiodev, str_mask = 0x00003800; str_shift = 11; break; + case SDIOD_DRVSTR_KEY(BCM4330_CHIP_ID, 12): + str_tab = (struct sdiod_drive_str *)&sdiod_drvstr_tab4_1v8; + str_mask = 0x00003800; + str_shift = 11; + break; default: brcmf_dbg(ERROR, "No SDIO Drive strength init done for chip %s rev %d pmurev %d\n", brcmf_sdio_chip_name(ci->chip, chn, 8), -- cgit v1.2.3 From ffb2756511a90091185e9be0652cc10eee0890d0 Mon Sep 17 00:00:00 2001 From: Franky Lin Date: Thu, 8 Dec 2011 15:06:40 -0800 Subject: brcm80211: fmac: remove drive strength code for unsupported chips bcm4325 and bcm4336 are not supported by brcmfmac. Remove the drive strength setting code specific for these chips. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- .../net/wireless/brcm80211/brcmfmac/sdio_chip.c | 52 +--------------------- 1 file changed, 2 insertions(+), 50 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c index d299059a2815..a6048d78d294 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/sdio_chip.c @@ -59,40 +59,8 @@ struct sdiod_drive_str { u8 strength; /* Pad Drive Strength in mA */ u8 sel; /* Chip-specific select value */ }; -/* SDIO Drive Strength to sel value table for PMU Rev 1 */ -static const struct sdiod_drive_str sdiod_drive_strength_tab1[] = { - { - 4, 0x2}, { - 2, 0x3}, { - 1, 0x0}, { - 0, 0x0} - }; -/* SDIO Drive Strength to sel value table for PMU Rev 2, 3 */ -static const struct sdiod_drive_str sdiod_drive_strength_tab2[] = { - { - 12, 0x7}, { - 10, 0x6}, { - 8, 0x5}, { - 6, 0x4}, { - 4, 0x2}, { - 2, 0x1}, { - 0, 0x0} - }; -/* SDIO Drive Strength to sel value table for PMU Rev 8 (1.8V) */ -static const struct sdiod_drive_str sdiod_drive_strength_tab3[] = { - { - 32, 0x7}, { - 26, 0x6}, { - 22, 0x5}, { - 16, 0x4}, { - 12, 0x3}, { - 8, 0x2}, { - 4, 0x1}, { - 0, 0x0} - }; - /* SDIO Drive Strength to sel value table for PMU Rev 11 (1.8V) */ -static const struct sdiod_drive_str sdiod_drvstr_tab4_1v8[] = { +static const struct sdiod_drive_str sdiod_drvstr_tab1_1v8[] = { {32, 0x6}, {26, 0x7}, {22, 0x4}, @@ -598,24 +566,8 @@ brcmf_sdio_chip_drivestrengthinit(struct brcmf_sdio_dev *sdiodev, return; switch (SDIOD_DRVSTR_KEY(ci->chip, ci->pmurev)) { - case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 1): - str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab1; - str_mask = 0x30000000; - str_shift = 28; - break; - case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 2): - case SDIOD_DRVSTR_KEY(BCM4325_CHIP_ID, 3): - str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab2; - str_mask = 0x00003800; - str_shift = 11; - break; - case SDIOD_DRVSTR_KEY(BCM4336_CHIP_ID, 8): - str_tab = (struct sdiod_drive_str *)&sdiod_drive_strength_tab3; - str_mask = 0x00003800; - str_shift = 11; - break; case SDIOD_DRVSTR_KEY(BCM4330_CHIP_ID, 12): - str_tab = (struct sdiod_drive_str *)&sdiod_drvstr_tab4_1v8; + str_tab = (struct sdiod_drive_str *)&sdiod_drvstr_tab1_1v8; str_mask = 0x00003800; str_shift = 11; break; -- cgit v1.2.3 From c9eb65a4865a915e93847be19a546d47816d88e4 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 8 Dec 2011 15:06:43 -0800 Subject: brcm80211: smac: remove unused fields from struct si_pub definition Several fields from the si_pub structure were not used or only set once but never checked. These fields have been removed. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 7 ------- drivers/net/wireless/brcm80211/brcmsmac/aiutils.h | 7 ------- 2 files changed, 14 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c index 39e305443d7e..66c79f1aa081 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c @@ -932,10 +932,6 @@ ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx) /* get chipcommon capabilites */ sii->pub.cccaps = R_REG(&cc->capabilities); - /* get chipcommon extended capabilities */ - - if (sii->pub.ccrev >= 35) - sii->pub.cccaps_ext = R_REG(&cc->capabilities_ext); /* get pmu rev and caps */ if (sii->pub.cccaps & CC_CAP_PMU) { @@ -1023,7 +1019,6 @@ static __used void ai_nvram_process(struct si_info *sii) sii->pub.boardvendor = w & 0xffff; sii->pub.boardtype = (w >> 16) & 0xffff; - sii->pub.boardflags = getintvar(&sii->pub, BRCMS_SROM_BOARDFLAGS); } static struct si_info *ai_doattach(struct si_info *sii, @@ -1071,8 +1066,6 @@ static struct si_info *ai_doattach(struct si_info *sii, sih->chiprev = (w & CID_REV_MASK) >> CID_REV_SHIFT; sih->chippkg = (w & CID_PKG_MASK) >> CID_PKG_SHIFT; - sih->issim = false; - /* scan for cores */ if (socitype == SOCI_AI) { SI_MSG("Found chip type AI (0x%08x)\n", w); diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h index b51d1e421e24..1da9759eb7d8 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h @@ -149,21 +149,14 @@ struct si_pub { uint buscoreidx; /* buscore index */ int ccrev; /* chip common core rev */ u32 cccaps; /* chip common capabilities */ - u32 cccaps_ext; /* chip common capabilities extension */ int pmurev; /* pmu core rev */ u32 pmucaps; /* pmu capabilities */ uint boardtype; /* board type */ uint boardvendor; /* board vendor */ - uint boardflags; /* board flags */ - uint boardflags2; /* board flags2 */ uint chip; /* chip number */ uint chiprev; /* chip revision */ uint chippkg; /* chip package option */ u32 chipst; /* chip status */ - bool issim; /* chip is in simulation or emulation */ - uint socirev; /* SOC interconnect rev */ - bool pci_pr32414; - }; struct pci_dev; -- cgit v1.2.3 From 2e397c303807fadcf65f4e070603107453db4352 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 8 Dec 2011 15:06:44 -0800 Subject: brcm80211: smac: move fields from struct si_pub to struct si_info The structure si_pub contained couple of fields that were only used internally in aiutils.c. These have been moved to the si_info structure. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 24 ++++++++++++----------- drivers/net/wireless/brcm80211/brcmsmac/aiutils.h | 4 ++-- 2 files changed, 15 insertions(+), 13 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c index 66c79f1aa081..8586ab78f891 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c @@ -928,7 +928,7 @@ ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx) /* get chipcommon chipstatus */ if (sii->pub.ccrev >= 11) - sii->pub.chipst = R_REG(&cc->chipstatus); + sii->chipst = R_REG(&cc->chipstatus); /* get chipcommon capabilites */ sii->pub.cccaps = R_REG(&cc->capabilities); @@ -942,7 +942,7 @@ ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx) /* figure out bus/orignal core idx */ sii->pub.buscoretype = NODEV_CORE_ID; sii->pub.buscorerev = NOREV; - sii->pub.buscoreidx = BADIDX; + sii->buscoreidx = BADIDX; pci = pcie = false; pcirev = pcierev = NOREV; @@ -980,11 +980,11 @@ ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx) if (pci) { sii->pub.buscoretype = PCI_CORE_ID; sii->pub.buscorerev = pcirev; - sii->pub.buscoreidx = pciidx; + sii->buscoreidx = pciidx; } else if (pcie) { sii->pub.buscoretype = PCIE_CORE_ID; sii->pub.buscorerev = pcierev; - sii->pub.buscoreidx = pcieidx; + sii->buscoreidx = pcieidx; } /* fixup necessary chip/core configurations */ @@ -1034,7 +1034,7 @@ static struct si_info *ai_doattach(struct si_info *sii, savewin = 0; - sih->buscoreidx = BADIDX; + sii->buscoreidx = BADIDX; sii->curmap = regs; sii->pbus = pbus; @@ -1372,7 +1372,7 @@ uint ai_corereg(struct si_pub *sih, uint coreidx, uint regoff, uint mask, fast = true; r = (u32 __iomem *)((__iomem char *)sii->curmap + PCI_16KB0_CCREGS_OFFSET + regoff); - } else if (sii->pub.buscoreidx == coreidx) { + } else if (sii->buscoreidx == coreidx) { /* * pci registers are at either in the last 2KB of * an 8KB window or, in pcie and pci rev 13 at 8KB @@ -1904,7 +1904,7 @@ void ai_pci_setup(struct si_pub *sih, uint coremask) siflag = ai_flag(sih); /* switch over to pci core */ - regs = ai_setcoreidx(sih, sii->pub.buscoreidx); + regs = ai_setcoreidx(sih, sii->buscoreidx); } /* @@ -2035,8 +2035,9 @@ bool ai_deviceremoved(struct si_pub *sih) bool ai_is_sprom_available(struct si_pub *sih) { + struct si_info *sii = (struct si_info *)sih; + if (sih->ccrev >= 31) { - struct si_info *sii; uint origidx; struct chipcregs __iomem *cc; u32 sromctrl; @@ -2044,7 +2045,6 @@ bool ai_is_sprom_available(struct si_pub *sih) if ((sih->cccaps & CC_CAP_SROM) == 0) return false; - sii = (struct si_info *)sih; origidx = sii->curidx; cc = ai_setcoreidx(sih, SI_CC_IDX); sromctrl = R_REG(&cc->sromcontrol); @@ -2054,7 +2054,7 @@ bool ai_is_sprom_available(struct si_pub *sih) switch (sih->chip) { case BCM4313_CHIP_ID: - return (sih->chipst & CST4313_SPROM_PRESENT) != 0; + return (sii->chipst & CST4313_SPROM_PRESENT) != 0; default: return true; } @@ -2062,9 +2062,11 @@ bool ai_is_sprom_available(struct si_pub *sih) bool ai_is_otp_disabled(struct si_pub *sih) { + struct si_info *sii = (struct si_info *)sih; + switch (sih->chip) { case BCM4313_CHIP_ID: - return (sih->chipst & CST4313_OTP_PRESENT) == 0; + return (sii->chipst & CST4313_OTP_PRESENT) == 0; /* These chips always have their OTP on */ case BCM43224_CHIP_ID: case BCM43225_CHIP_ID: diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h index 1da9759eb7d8..f049179846e6 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h @@ -146,7 +146,6 @@ struct si_pub { uint buscoretype; /* PCI_CORE_ID, PCIE_CORE_ID, PCMCIA_CORE_ID */ uint buscorerev; /* buscore rev */ - uint buscoreidx; /* buscore index */ int ccrev; /* chip common core rev */ u32 cccaps; /* chip common capabilities */ int pmurev; /* pmu core rev */ @@ -156,7 +155,6 @@ struct si_pub { uint chip; /* chip number */ uint chiprev; /* chip revision */ uint chippkg; /* chip package option */ - u32 chipst; /* chip status */ }; struct pci_dev; @@ -188,7 +186,9 @@ struct si_info { void __iomem *curmap; /* current regs va */ void __iomem *regs[SI_MAXCORES]; /* other regs va */ + u32 chipst; /* chip status */ uint curidx; /* current core index */ + uint buscoreidx; /* buscore index */ uint numcores; /* # discovered cores */ uint coreid[SI_MAXCORES]; /* id of each core */ u32 coresba[SI_MAXCORES]; /* backplane address of each core */ -- cgit v1.2.3 From b2ffec46ea230acac52170dd0a747526328d25fe Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 8 Dec 2011 15:06:45 -0800 Subject: brcm80211: smac: use inline access functions for struct si_pub fields Instead of directly accessing the fields in struct si_pub the driver now uses inline access functions. This is in preparation of the bcma integration as a lot of information will be provided by bcma module. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Reviewed-by: Roland Vossen Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 118 +++++++++++---------- drivers/net/wireless/brcm80211/brcmsmac/aiutils.h | 46 ++++++++ drivers/net/wireless/brcm80211/brcmsmac/main.c | 56 +++++----- drivers/net/wireless/brcm80211/brcmsmac/nicpci.c | 35 +++--- drivers/net/wireless/brcm80211/brcmsmac/otp.c | 20 ++-- .../net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c | 2 - .../net/wireless/brcm80211/brcmsmac/phy/phy_hal.h | 2 - .../net/wireless/brcm80211/brcmsmac/phy/phy_int.h | 2 - drivers/net/wireless/brcm80211/brcmsmac/pmu.c | 20 ++-- drivers/net/wireless/brcm80211/brcmsmac/srom.c | 4 +- 10 files changed, 174 insertions(+), 131 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c index 8586ab78f891..83a013833678 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c @@ -321,9 +321,9 @@ /* Newer chips can access PCI/PCIE and CC core without requiring to change * PCI BAR0 WIN */ -#define SI_FAST(si) (((si)->pub.buscoretype == PCIE_CORE_ID) || \ - (((si)->pub.buscoretype == PCI_CORE_ID) && \ - (si)->pub.buscorerev >= 13)) +#define SI_FAST(sih) ((ai_get_buscoretype(sih) == PCIE_CORE_ID) || \ + ((ai_get_buscoretype(sih) == PCI_CORE_ID) && \ + ai_get_buscorerev(sih) >= 13)) #define CCREGS_FAST(si) (((char __iomem *)((si)->curmap) + \ PCI_16KB0_CCREGS_OFFSET)) @@ -345,10 +345,10 @@ (si)->coreid[(si)->curidx] == (si)->dev_coreid) \ (*(si)->intrsrestore_fn)((si)->intr_arg, intr_val) -#define PCI(si) ((si)->pub.buscoretype == PCI_CORE_ID) -#define PCIE(si) ((si)->pub.buscoretype == PCIE_CORE_ID) +#define PCI(sih) (ai_get_buscoretype(sih) == PCI_CORE_ID) +#define PCIE(sih) (ai_get_buscoretype(sih) == PCIE_CORE_ID) -#define PCI_FORCEHT(si) (PCIE(si) && (si->pub.chip == BCM4716_CHIP_ID)) +#define PCI_FORCEHT(sih) (PCIE(sih) && (ai_get_chip_id(sih) == BCM4716_CHIP_ID)) #ifdef BCMDBG #define SI_MSG(fmt, ...) pr_debug(fmt, ##__VA_ARGS__) @@ -927,14 +927,14 @@ ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx) sii->pub.ccrev = (int)ai_corerev(&sii->pub); /* get chipcommon chipstatus */ - if (sii->pub.ccrev >= 11) + if (ai_get_ccrev(&sii->pub) >= 11) sii->chipst = R_REG(&cc->chipstatus); /* get chipcommon capabilites */ sii->pub.cccaps = R_REG(&cc->capabilities); /* get pmu rev and caps */ - if (sii->pub.cccaps & CC_CAP_PMU) { + if (ai_get_cccaps(&sii->pub) & CC_CAP_PMU) { sii->pub.pmucaps = R_REG(&cc->pmucapabilities); sii->pub.pmurev = sii->pub.pmucaps & PCAP_REV_MASK; } @@ -988,7 +988,7 @@ ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx) } /* fixup necessary chip/core configurations */ - if (SI_FAST(sii)) { + if (SI_FAST(&sii->pub)) { if (!sii->pch) { sii->pch = pcicore_init(&sii->pub, sii->pbus, (__iomem void *)PCIEREGS(sii)); @@ -1097,7 +1097,7 @@ static struct si_info *ai_doattach(struct si_info *sii, ai_setcoreidx(sih, origidx); /* PMU specific initializations */ - if (sih->cccaps & CC_CAP_PMU) { + if (ai_get_cccaps(sih) & CC_CAP_PMU) { u32 xtalfreq; si_pmu_init(sih); si_pmu_chip_init(sih); @@ -1115,15 +1115,15 @@ static struct si_info *ai_doattach(struct si_info *sii, ai_corereg(sih, SI_CC_IDX, offsetof(struct chipcregs, gpiotimerval), ~0, w); - if (PCIE(sii)) + if (PCIE(sih)) pcicore_attach(sii->pch, SI_DOATTACH); - if (sih->chip == BCM43224_CHIP_ID) { + if (ai_get_chip_id(sih) == BCM43224_CHIP_ID) { /* * enable 12 mA drive strenth for 43224 and * set chipControl register bit 15 */ - if (sih->chiprev == 0) { + if (ai_get_chiprev(sih) == 0) { SI_MSG("Applying 43224A0 WARs\n"); ai_corereg(sih, SI_CC_IDX, offsetof(struct chipcregs, chipcontrol), @@ -1132,14 +1132,14 @@ static struct si_info *ai_doattach(struct si_info *sii, si_pmu_chipcontrol(sih, 0, CCTRL_43224A0_12MA_LED_DRIVE, CCTRL_43224A0_12MA_LED_DRIVE); } - if (sih->chiprev >= 1) { + if (ai_get_chiprev(sih) >= 1) { SI_MSG("Applying 43224B0+ WARs\n"); si_pmu_chipcontrol(sih, 0, CCTRL_43224B0_12MA_LED_DRIVE, CCTRL_43224B0_12MA_LED_DRIVE); } } - if (sih->chip == BCM4313_CHIP_ID) { + if (ai_get_chip_id(sih) == BCM4313_CHIP_ID) { /* * enable 12 mA drive strenth for 4313 and * set chipControl register bit 1 @@ -1249,7 +1249,7 @@ uint ai_coreidx(struct si_pub *sih) bool ai_backplane64(struct si_pub *sih) { - return (sih->cccaps & CC_CAP_BKPLN64) != 0; + return (ai_get_cccaps(sih) & CC_CAP_BKPLN64) != 0; } /* return index of coreid or BADIDX if not found */ @@ -1299,7 +1299,7 @@ void __iomem *ai_switch_core(struct si_pub *sih, uint coreid, uint *origidx, sii = (struct si_info *)sih; - if (SI_FAST(sii)) { + if (SI_FAST(sih)) { /* Overloading the origidx variable to remember the coreid, * this works because the core ids cannot be confused with * core indices. @@ -1307,7 +1307,7 @@ void __iomem *ai_switch_core(struct si_pub *sih, uint coreid, uint *origidx, *origidx = coreid; if (coreid == CC_CORE_ID) return CCREGS_FAST(sii); - else if (coreid == sih->buscoretype) + else if (coreid == ai_get_buscoretype(sih)) return PCIEREGS(sii); } INTR_OFF(sii, *intr_val); @@ -1322,8 +1322,8 @@ void ai_restore_core(struct si_pub *sih, uint coreid, uint intr_val) struct si_info *sii; sii = (struct si_info *)sih; - if (SI_FAST(sii) - && ((coreid == CC_CORE_ID) || (coreid == sih->buscoretype))) + if (SI_FAST(sih) + && ((coreid == CC_CORE_ID) || (coreid == ai_get_buscoretype(sih)))) return; ai_setcoreidx(sih, coreid); @@ -1367,7 +1367,7 @@ uint ai_corereg(struct si_pub *sih, uint coreidx, uint regoff, uint mask, * If pci/pcie, we can get at pci/pcie regs * and on newer cores to chipc */ - if ((sii->coreid[coreidx] == CC_CORE_ID) && SI_FAST(sii)) { + if ((sii->coreid[coreidx] == CC_CORE_ID) && SI_FAST(sih)) { /* Chipc registers are mapped at 12KB */ fast = true; r = (u32 __iomem *)((__iomem char *)sii->curmap + @@ -1378,7 +1378,7 @@ uint ai_corereg(struct si_pub *sih, uint coreidx, uint regoff, uint mask, * an 8KB window or, in pcie and pci rev 13 at 8KB */ fast = true; - if (SI_FAST(sii)) + if (SI_FAST(sih)) r = (u32 __iomem *)((__iomem char *)sii->curmap + PCI_16KB0_PCIREGS_OFFSET + regoff); else @@ -1480,13 +1480,13 @@ static uint ai_slowclk_src(struct si_info *sii) struct chipcregs __iomem *cc; u32 val; - if (sii->pub.ccrev < 6) { + if (ai_get_ccrev(&sii->pub) < 6) { pci_read_config_dword(sii->pbus, PCI_GPIO_OUT, &val); if (val & PCI_CFG_GPIO_SCS) return SCC_SS_PCI; return SCC_SS_XTAL; - } else if (sii->pub.ccrev < 10) { + } else if (ai_get_ccrev(&sii->pub) < 10) { cc = (struct chipcregs __iomem *) ai_setcoreidx(&sii->pub, sii->curidx); return R_REG(&cc->slow_clk_ctl) & SCC_SS_MASK; @@ -1505,14 +1505,14 @@ static uint ai_slowclk_freq(struct si_info *sii, bool max_freq, uint div; slowclk = ai_slowclk_src(sii); - if (sii->pub.ccrev < 6) { + if (ai_get_ccrev(&sii->pub) < 6) { if (slowclk == SCC_SS_PCI) return max_freq ? (PCIMAXFREQ / 64) : (PCIMINFREQ / 64); else return max_freq ? (XTALMAXFREQ / 32) : (XTALMINFREQ / 32); - } else if (sii->pub.ccrev < 10) { + } else if (ai_get_ccrev(&sii->pub) < 10) { div = 4 * (((R_REG(&cc->slow_clk_ctl) & SCC_CD_MASK) >> SCC_CD_SHIFT) + 1); @@ -1553,7 +1553,8 @@ ai_clkctl_setdelay(struct si_info *sii, struct chipcregs __iomem *cc) /* Starting with 4318 it is ILP that is used for the delays */ slowmaxfreq = - ai_slowclk_freq(sii, (sii->pub.ccrev >= 10) ? false : true, cc); + ai_slowclk_freq(sii, + (ai_get_ccrev(&sii->pub) >= 10) ? false : true, cc); pll_on_delay = ((slowmaxfreq * pll_delay) + 999999) / 1000000; fref_sel_delay = ((slowmaxfreq * FREF_DELAY) + 999999) / 1000000; @@ -1570,11 +1571,11 @@ void ai_clkctl_init(struct si_pub *sih) struct chipcregs __iomem *cc; bool fast; - if (!(sih->cccaps & CC_CAP_PWR_CTL)) + if (!(ai_get_cccaps(sih) & CC_CAP_PWR_CTL)) return; sii = (struct si_info *)sih; - fast = SI_FAST(sii); + fast = SI_FAST(sih); if (!fast) { origidx = sii->curidx; cc = (struct chipcregs __iomem *) @@ -1588,7 +1589,7 @@ void ai_clkctl_init(struct si_pub *sih) } /* set all Instaclk chip ILP to 1 MHz */ - if (sih->ccrev >= 10) + if (ai_get_ccrev(sih) >= 10) SET_REG(&cc->system_clk_ctl, SYCC_CD_MASK, (ILP_DIV_1MHZ << SYCC_CD_SHIFT)); @@ -1613,17 +1614,17 @@ u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih) bool fast; sii = (struct si_info *)sih; - if (sih->cccaps & CC_CAP_PMU) { + if (ai_get_cccaps(sih) & CC_CAP_PMU) { INTR_OFF(sii, intr_val); fpdelay = si_pmu_fast_pwrup_delay(sih); INTR_RESTORE(sii, intr_val); return fpdelay; } - if (!(sih->cccaps & CC_CAP_PWR_CTL)) + if (!(ai_get_cccaps(sih) & CC_CAP_PWR_CTL)) return 0; - fast = SI_FAST(sii); + fast = SI_FAST(sih); fpdelay = 0; if (!fast) { origidx = sii->curidx; @@ -1659,7 +1660,7 @@ int ai_clkctl_xtal(struct si_pub *sih, uint what, bool on) sii = (struct si_info *)sih; /* pcie core doesn't have any mapping to control the xtal pu */ - if (PCIE(sii)) + if (PCIE(sih)) return -1; pci_read_config_dword(sii->pbus, PCI_GPIO_IN, &in); @@ -1720,10 +1721,10 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode) struct chipcregs __iomem *cc; u32 scc; uint intr_val = 0; - bool fast = SI_FAST(sii); + bool fast = SI_FAST(&sii->pub); /* chipcommon cores prior to rev6 don't support dynamic clock control */ - if (sii->pub.ccrev < 6) + if (ai_get_ccrev(&sii->pub) < 6) return false; if (!fast) { @@ -1737,12 +1738,13 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode) goto done; } - if (!(sii->pub.cccaps & CC_CAP_PWR_CTL) && (sii->pub.ccrev < 20)) + if (!(ai_get_cccaps(&sii->pub) & CC_CAP_PWR_CTL) && + (ai_get_ccrev(&sii->pub) < 20)) goto done; switch (mode) { case CLK_FAST: /* FORCEHT, fast (pll) clock */ - if (sii->pub.ccrev < 10) { + if (ai_get_ccrev(&sii->pub) < 10) { /* * don't forget to force xtal back * on before we clear SCC_DYN_XTAL.. @@ -1750,14 +1752,14 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode) ai_clkctl_xtal(&sii->pub, XTAL, ON); SET_REG(&cc->slow_clk_ctl, (SCC_XC | SCC_FS | SCC_IP), SCC_IP); - } else if (sii->pub.ccrev < 20) { + } else if (ai_get_ccrev(&sii->pub) < 20) { OR_REG(&cc->system_clk_ctl, SYCC_HR); } else { OR_REG(&cc->clk_ctl_st, CCS_FORCEHT); } /* wait for the PLL */ - if (sii->pub.cccaps & CC_CAP_PMU) { + if (ai_get_cccaps(&sii->pub) & CC_CAP_PMU) { u32 htavail = CCS_HTAVAIL; SPINWAIT(((R_REG(&cc->clk_ctl_st) & htavail) == 0), PMU_MAX_TRANSITION_DLY); @@ -1767,7 +1769,7 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode) break; case CLK_DYNAMIC: /* enable dynamic clock control */ - if (sii->pub.ccrev < 10) { + if (ai_get_ccrev(&sii->pub) < 10) { scc = R_REG(&cc->slow_clk_ctl); scc &= ~(SCC_FS | SCC_IP | SCC_XC); if ((scc & SCC_SS_MASK) != SCC_SS_XTAL) @@ -1780,7 +1782,7 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode) */ if (scc & SCC_XC) ai_clkctl_xtal(&sii->pub, XTAL, OFF); - } else if (sii->pub.ccrev < 20) { + } else if (ai_get_ccrev(&sii->pub) < 20) { /* Instaclock */ AND_REG(&cc->system_clk_ctl, ~SYCC_HR); } else { @@ -1815,10 +1817,10 @@ bool ai_clkctl_cc(struct si_pub *sih, uint mode) sii = (struct si_info *)sih; /* chipcommon cores prior to rev6 don't support dynamic clock control */ - if (sih->ccrev < 6) + if (ai_get_ccrev(sih) < 6) return false; - if (PCI_FORCEHT(sii)) + if (PCI_FORCEHT(sih)) return mode == CLK_FAST; return _ai_clkctl_cc(sii, mode); @@ -1851,10 +1853,10 @@ void ai_pci_up(struct si_pub *sih) sii = (struct si_info *)sih; - if (PCI_FORCEHT(sii)) + if (PCI_FORCEHT(sih)) _ai_clkctl_cc(sii, CLK_FAST); - if (PCIE(sii)) + if (PCIE(sih)) pcicore_up(sii->pch, SI_PCIUP); } @@ -1877,7 +1879,7 @@ void ai_pci_down(struct si_pub *sih) sii = (struct si_info *)sih; /* release FORCEHT since chip is going to "down" state */ - if (PCI_FORCEHT(sii)) + if (PCI_FORCEHT(sih)) _ai_clkctl_cc(sii, CLK_DYNAMIC); pcicore_down(sii->pch, SI_PCIDOWN); @@ -1896,7 +1898,7 @@ void ai_pci_setup(struct si_pub *sih, uint coremask) sii = (struct si_info *)sih; - if (PCI(sii)) { + if (PCI(sih)) { /* get current core index */ idx = sii->curidx; @@ -1911,7 +1913,7 @@ void ai_pci_setup(struct si_pub *sih, uint coremask) * Enable sb->pci interrupts. Assume * PCI rev 2.3 support was added in pci core rev 6 and things changed.. */ - if (PCIE(sii) || (PCI(sii) && ((sii->pub.buscorerev) >= 6))) { + if (PCIE(sih) || (PCI(sih) && (ai_get_buscorerev(sih) >= 6))) { /* pci config write to set this core bit in PCIIntMask */ pci_read_config_dword(sii->pbus, PCI_INT_MASK, &w); w |= (coremask << PCI_SBIM_SHIFT); @@ -1921,7 +1923,7 @@ void ai_pci_setup(struct si_pub *sih, uint coremask) ai_setint(sih, siflag); } - if (PCI(sii)) { + if (PCI(sih)) { pcicore_pci_setup(sii->pch, regs); /* switch back to previous core */ @@ -1944,11 +1946,11 @@ int ai_pci_fixcfg(struct si_pub *sih) origidx = ai_coreidx(&sii->pub); /* check 'pi' is correct and fix it if not */ - regs = ai_setcore(&sii->pub, sii->pub.buscoretype, 0); - if (sii->pub.buscoretype == PCIE_CORE_ID) + regs = ai_setcore(&sii->pub, ai_get_buscoretype(sih), 0); + if (ai_get_buscoretype(sih) == PCIE_CORE_ID) pcicore_fixcfg_pcie(sii->pch, (struct sbpcieregs __iomem *)regs); - else if (sii->pub.buscoretype == PCI_CORE_ID) + else if (ai_get_buscoretype(sih) == PCI_CORE_ID) pcicore_fixcfg_pci(sii->pch, (struct sbpciregs __iomem *)regs); /* restore the original index */ @@ -1982,7 +1984,7 @@ void ai_chipcontrl_epa4331(struct si_pub *sih, bool on) val = R_REG(&cc->chipcontrol); if (on) { - if (sih->chippkg == 9 || sih->chippkg == 0xb) + if (ai_get_chippkg(sih) == 9 || ai_get_chippkg(sih) == 0xb) /* Ext PA Controls for 4331 12x9 Package */ W_REG(&cc->chipcontrol, val | CCTRL4331_EXTPA_EN | @@ -2037,12 +2039,12 @@ bool ai_is_sprom_available(struct si_pub *sih) { struct si_info *sii = (struct si_info *)sih; - if (sih->ccrev >= 31) { + if (ai_get_ccrev(sih) >= 31) { uint origidx; struct chipcregs __iomem *cc; u32 sromctrl; - if ((sih->cccaps & CC_CAP_SROM) == 0) + if ((ai_get_cccaps(sih) & CC_CAP_SROM) == 0) return false; origidx = sii->curidx; @@ -2052,7 +2054,7 @@ bool ai_is_sprom_available(struct si_pub *sih) return sromctrl & SRC_PRESENT; } - switch (sih->chip) { + switch (ai_get_chip_id(sih)) { case BCM4313_CHIP_ID: return (sii->chipst & CST4313_SPROM_PRESENT) != 0; default: @@ -2064,7 +2066,7 @@ bool ai_is_otp_disabled(struct si_pub *sih) { struct si_info *sii = (struct si_info *)sih; - switch (sih->chip) { + switch (ai_get_chip_id(sih)) { case BCM4313_CHIP_ID: return (sii->chipst & CST4313_OTP_PRESENT) == 0; /* These chips always have their OTP on */ diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h index f049179846e6..347b8a26f025 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h @@ -292,4 +292,50 @@ extern void ai_chipcontrl_epa4331(struct si_pub *sih, bool on); /* Enable Ex-PA for 4313 */ extern void ai_epa_4313war(struct si_pub *sih); +static inline uint ai_get_buscoretype(struct si_pub *sih) +{ + return sih->buscoretype; +} + +static inline uint ai_get_buscorerev(struct si_pub *sih) +{ + return sih->buscorerev; +} +static inline int ai_get_ccrev(struct si_pub *sih) +{ + return sih->ccrev; +} +static inline u32 ai_get_cccaps(struct si_pub *sih) +{ + return sih->cccaps; +} +static inline int ai_get_pmurev(struct si_pub *sih) +{ + return sih->pmurev; +} +static inline u32 ai_get_pmucaps(struct si_pub *sih) +{ + return sih->pmucaps; +} +static inline uint ai_get_boardtype(struct si_pub *sih) +{ + return sih->boardtype; +} +static inline uint ai_get_boardvendor(struct si_pub *sih) +{ + return sih->boardvendor; +} +static inline uint ai_get_chip_id(struct si_pub *sih) +{ + return sih->chip; +} +static inline uint ai_get_chiprev(struct si_pub *sih) +{ + return sih->chiprev; +} +static inline uint ai_get_chippkg(struct si_pub *sih) +{ + return sih->chippkg; +} + #endif /* _BRCM_AIUTILS_H_ */ diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index 87f8f5d3d91f..ed8fcb40b518 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -1205,7 +1205,7 @@ static void brcms_b_wait_for_wake(struct brcms_hardware *wlc_hw) /* control chip clock to save power, enable dynamic clock or force fast clock */ static void brcms_b_clkctl_clk(struct brcms_hardware *wlc_hw, uint mode) { - if (wlc_hw->sih->cccaps & CC_CAP_PMU) { + if (ai_get_cccaps(wlc_hw->sih) & CC_CAP_PMU) { /* new chips with PMU, CCS_FORCEHT will distribute the HT clock * on backplane, but mac core will still run on ALP(not HT) when * it enters powersave mode, which means the FCA bit may not be @@ -1227,7 +1227,7 @@ static void brcms_b_clkctl_clk(struct brcms_hardware *wlc_hw, uint mode) (&wlc_hw->regs-> clk_ctl_st) & CCS_HTAVAIL)); } else { - if ((wlc_hw->sih->pmurev == 0) && + if ((ai_get_pmurev(wlc_hw->sih) == 0) && (R_REG (&wlc_hw->regs-> clk_ctl_st) & (CCS_FORCEHT | CCS_HTAREQ))) @@ -1843,7 +1843,7 @@ static bool brcms_c_validboardtype(struct brcms_hardware *wlc_hw) uint b2 = boardrev & 0xf; /* voards from other vendors are always considered valid */ - if (wlc_hw->sih->boardvendor != PCI_VENDOR_ID_BROADCOM) + if (ai_get_boardvendor(wlc_hw->sih) != PCI_VENDOR_ID_BROADCOM) return true; /* do some boardrev sanity checks when boardvendor is Broadcom */ @@ -1935,8 +1935,8 @@ static bool brcms_b_radio_read_hwdisabled(struct brcms_hardware *wlc_hw) * AI chip doesn't restore bar0win2 on * hibernation/resume, need sw fixup */ - if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || - (wlc_hw->sih->chip == BCM43225_CHIP_ID)) + if ((ai_get_chip_id(wlc_hw->sih) == BCM43224_CHIP_ID) || + (ai_get_chip_id(wlc_hw->sih) == BCM43225_CHIP_ID)) wlc_hw->regs = (struct d11regs __iomem *) ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); ai_core_reset(wlc_hw->sih, flags, resetbits); @@ -2034,7 +2034,7 @@ void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags) brcms_c_mctrl_reset(wlc_hw); - if (wlc_hw->sih->cccaps & CC_CAP_PMU) + if (ai_get_cccaps(wlc_hw->sih) & CC_CAP_PMU) brcms_b_clkctl_clk(wlc_hw, CLK_FAST); brcms_b_phy_reset(wlc_hw); @@ -2117,8 +2117,8 @@ void brcms_b_switch_macfreq(struct brcms_hardware *wlc_hw, u8 spurmode) { struct d11regs __iomem *regs = wlc_hw->regs; - if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || - (wlc_hw->sih->chip == BCM43225_CHIP_ID)) { + if ((ai_get_chip_id(wlc_hw->sih) == BCM43224_CHIP_ID) || + (ai_get_chip_id(wlc_hw->sih) == BCM43225_CHIP_ID)) { if (spurmode == WL_SPURAVOID_ON2) { /* 126Mhz */ W_REG(®s->tsf_clk_frac_l, 0x2082); W_REG(®s->tsf_clk_frac_h, 0x8); @@ -2805,7 +2805,7 @@ void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on) regs = wlc_hw->regs; if (on) { - if ((wlc_hw->sih->chip == BCM4313_CHIP_ID)) { + if ((ai_get_chip_id(wlc_hw->sih) == BCM4313_CHIP_ID)) { OR_REG(®s->clk_ctl_st, (CCS_ERSRC_REQ_HT | CCS_ERSRC_REQ_D11PLL | CCS_ERSRC_REQ_PHYPLL)); @@ -4530,8 +4530,9 @@ static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, wlc_hw->boardrev = (u16) j; if (!brcms_c_validboardtype(wlc_hw)) { wiphy_err(wiphy, "wl%d: brcms_b_attach: Unsupported Broadcom " - "board type (0x%x)" " or revision level (0x%x)\n", - unit, wlc_hw->sih->boardtype, wlc_hw->boardrev); + "board type (0x%x)" " or revision level (0x%x)\n", + unit, ai_get_boardtype(wlc_hw->sih), + wlc_hw->boardrev); err = 15; goto fail; } @@ -4552,7 +4553,7 @@ static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, else wlc_hw->_nbands = 1; - if ((wlc_hw->sih->chip == BCM43225_CHIP_ID)) + if ((ai_get_chip_id(wlc_hw->sih) == BCM43225_CHIP_ID)) wlc_hw->_nbands = 1; /* BMAC_NOTE: remove init of pub values when brcms_c_attach() @@ -4584,16 +4585,14 @@ static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, sha_params.corerev = wlc_hw->corerev; sha_params.vid = wlc_hw->vendorid; sha_params.did = wlc_hw->deviceid; - sha_params.chip = wlc_hw->sih->chip; - sha_params.chiprev = wlc_hw->sih->chiprev; - sha_params.chippkg = wlc_hw->sih->chippkg; + sha_params.chip = ai_get_chip_id(wlc_hw->sih); + sha_params.chiprev = ai_get_chiprev(wlc_hw->sih); + sha_params.chippkg = ai_get_chippkg(wlc_hw->sih); sha_params.sromrev = wlc_hw->sromrev; - sha_params.boardtype = wlc_hw->sih->boardtype; + sha_params.boardtype = ai_get_boardtype(wlc_hw->sih); sha_params.boardrev = wlc_hw->boardrev; - sha_params.boardvendor = wlc_hw->sih->boardvendor; sha_params.boardflags = wlc_hw->boardflags; sha_params.boardflags2 = wlc_hw->boardflags2; - sha_params.buscorerev = wlc_hw->sih->buscorerev; /* alloc and save pointer to shared phy state area */ wlc_hw->phy_sh = wlc_phy_shared_attach(&sha_params); @@ -4734,10 +4733,9 @@ static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, goto fail; } - BCMMSG(wlc->wiphy, - "deviceid 0x%x nbands %d board 0x%x macaddr: %s\n", - wlc_hw->deviceid, wlc_hw->_nbands, - wlc_hw->sih->boardtype, macaddr); + BCMMSG(wlc->wiphy, "deviceid 0x%x nbands %d board 0x%x macaddr: %s\n", + wlc_hw->deviceid, wlc_hw->_nbands, ai_get_boardtype(wlc_hw->sih), + macaddr); return err; @@ -5073,8 +5071,8 @@ static void brcms_b_hw_up(struct brcms_hardware *wlc_hw) * AI chip doesn't restore bar0win2 on * hibernation/resume, need sw fixup */ - if ((wlc_hw->sih->chip == BCM43224_CHIP_ID) || - (wlc_hw->sih->chip == BCM43225_CHIP_ID)) + if ((ai_get_chip_id(wlc_hw->sih) == BCM43224_CHIP_ID) || + (ai_get_chip_id(wlc_hw->sih) == BCM43225_CHIP_ID)) wlc_hw->regs = (struct d11regs __iomem *) ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); @@ -5088,7 +5086,7 @@ static void brcms_b_hw_up(struct brcms_hardware *wlc_hw) wlc_hw->wlc->pub->hw_up = true; if ((wlc_hw->boardflags & BFL_FEM) - && (wlc_hw->sih->chip == BCM4313_CHIP_ID)) { + && (ai_get_chip_id(wlc_hw->sih) == BCM4313_CHIP_ID)) { if (! (wlc_hw->boardrev >= 0x1250 && (wlc_hw->boardflags & BFL_FEM_BT))) @@ -5183,7 +5181,7 @@ int brcms_c_up(struct brcms_c_info *wlc) } if ((wlc->pub->boardflags & BFL_FEM) - && (wlc->pub->sih->chip == BCM4313_CHIP_ID)) { + && (ai_get_chip_id(wlc->hw->sih) == BCM4313_CHIP_ID)) { if (wlc->pub->boardrev >= 0x1250 && (wlc->pub->boardflags & BFL_FEM_BT)) brcms_b_mhf(wlc->hw, MHF5, MHF5_4313_GPIOCTRL, @@ -8210,11 +8208,11 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) if (macintstatus & MI_GP0) { wiphy_err(wiphy, "wl%d: PSM microcode watchdog fired at %d " - "(seconds). Resetting.\n", wlc_hw->unit, wlc_hw->now); + "(seconds). Resetting.\n", wlc_hw->unit, wlc_hw->now); printk_once("%s : PSM Watchdog, chipid 0x%x, chiprev 0x%x\n", - __func__, wlc_hw->sih->chip, - wlc_hw->sih->chiprev); + __func__, ai_get_chip_id(wlc_hw->sih), + ai_get_chiprev(wlc_hw->sih)); brcms_fatal_error(wlc_hw->wlc->wl); } diff --git a/drivers/net/wireless/brcm80211/brcmsmac/nicpci.c b/drivers/net/wireless/brcm80211/brcmsmac/nicpci.c index 0bcb26792046..2e8b5a19ace7 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/nicpci.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/nicpci.c @@ -224,9 +224,9 @@ struct pcicore_info { }; #define PCIE_ASPM(sih) \ - (((sih)->buscoretype == PCIE_CORE_ID) && \ - (((sih)->buscorerev >= 3) && \ - ((sih)->buscorerev <= 5))) + ((ai_get_buscoretype(sih) == PCIE_CORE_ID) && \ + ((ai_get_buscorerev(sih) >= 3) && \ + (ai_get_buscorerev(sih) <= 5))) /* delay needed between the mdio control/ mdiodata register data access */ @@ -251,7 +251,7 @@ struct pcicore_info *pcicore_init(struct si_pub *sih, struct pci_dev *pdev, pi->sih = sih; pi->dev = pdev; - if (sih->buscoretype == PCIE_CORE_ID) { + if (ai_get_buscoretype(sih) == PCIE_CORE_ID) { u8 cap_ptr; pi->regs.pcieregs = regs; cap_ptr = pcicore_find_pci_capability(pi->dev, PCI_CAP_ID_EXP, @@ -504,7 +504,8 @@ static void pcie_extendL1timer(struct pcicore_info *pi, bool extend) struct si_pub *sih = pi->sih; struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs; - if (sih->buscoretype != PCIE_CORE_ID || sih->buscorerev < 7) + if (ai_get_buscoretype(sih) != PCIE_CORE_ID || + ai_get_buscorerev(sih) < 7) return; w = pcie_readreg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG); @@ -527,7 +528,8 @@ static void pcie_clkreq_upd(struct pcicore_info *pi, uint state) pcie_clkreq(pi, 1, 0); break; case SI_PCIDOWN: - if (sih->buscorerev == 6) { /* turn on serdes PLL down */ + /* turn on serdes PLL down */ + if (ai_get_buscorerev(sih) == 6) { ai_corereg(sih, SI_CC_IDX, offsetof(struct chipcregs, chipcontrol_addr), ~0, 0); @@ -539,7 +541,8 @@ static void pcie_clkreq_upd(struct pcicore_info *pi, uint state) } break; case SI_PCIUP: - if (sih->buscorerev == 6) { /* turn off serdes PLL down */ + /* turn off serdes PLL down */ + if (ai_get_buscorerev(sih) == 6) { ai_corereg(sih, SI_CC_IDX, offsetof(struct chipcregs, chipcontrol_addr), ~0, 0); @@ -678,7 +681,7 @@ static void pcie_war_pci_setup(struct pcicore_info *pi) struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs; u32 w; - if (sih->buscorerev == 0 || sih->buscorerev == 1) { + if (ai_get_buscorerev(sih) == 0 || ai_get_buscorerev(sih) == 1) { w = pcie_readreg(pcieregs, PCIE_PCIEREGS, PCIE_TLP_WORKAROUNDSREG); w |= 0x8; @@ -686,13 +689,13 @@ static void pcie_war_pci_setup(struct pcicore_info *pi) PCIE_TLP_WORKAROUNDSREG, w); } - if (sih->buscorerev == 1) { + if (ai_get_buscorerev(sih) == 1) { w = pcie_readreg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_LCREG); w |= 0x40; pcie_writereg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_LCREG, w); } - if (sih->buscorerev == 0) { + if (ai_get_buscorerev(sih) == 0) { pcie_mdiowrite(pi, MDIODATA_DEV_RX, SERDES_RX_TIMER1, 0x8128); pcie_mdiowrite(pi, MDIODATA_DEV_RX, SERDES_RX_CDR, 0x0100); pcie_mdiowrite(pi, MDIODATA_DEV_RX, SERDES_RX_CDRBW, 0x1466); @@ -708,13 +711,13 @@ static void pcie_war_pci_setup(struct pcicore_info *pi) pcie_war_serdes(pi); pcie_war_aspm_clkreq(pi); - } else if (pi->sih->buscorerev == 7) + } else if (ai_get_buscorerev(pi->sih) == 7) pcie_war_noplldown(pi); /* Note that the fix is actually in the SROM, * that's why this is open-ended */ - if (pi->sih->buscorerev >= 6) + if (ai_get_buscorerev(pi->sih) >= 6) pcie_misc_config_fixup(pi); } @@ -745,7 +748,7 @@ void pcicore_attach(struct pcicore_info *pi, int state) void pcicore_hwup(struct pcicore_info *pi) { - if (!pi || pi->sih->buscoretype != PCIE_CORE_ID) + if (!pi || ai_get_buscoretype(pi->sih) != PCIE_CORE_ID) return; pcie_war_pci_setup(pi); @@ -753,7 +756,7 @@ void pcicore_hwup(struct pcicore_info *pi) void pcicore_up(struct pcicore_info *pi, int state) { - if (!pi || pi->sih->buscoretype != PCIE_CORE_ID) + if (!pi || ai_get_buscoretype(pi->sih) != PCIE_CORE_ID) return; /* Restore L1 timer for better performance */ @@ -781,7 +784,7 @@ void pcicore_sleep(struct pcicore_info *pi) void pcicore_down(struct pcicore_info *pi, int state) { - if (!pi || pi->sih->buscoretype != PCIE_CORE_ID) + if (!pi || ai_get_buscoretype(pi->sih) != PCIE_CORE_ID) return; pcie_clkreq_upd(pi, state); @@ -826,7 +829,7 @@ pcicore_pci_setup(struct pcicore_info *pi, struct sbpciregs __iomem *pciregs) OR_REG(&pciregs->sbtopci2, SBTOPCI_PREF | SBTOPCI_BURST); - if (((struct si_info *)(pi->sih))->pub.buscorerev >= 11) { + if (ai_get_buscorerev(pi->sih) >= 11) { OR_REG(&pciregs->sbtopci2, SBTOPCI_RC_READMULTI); w = R_REG(&pciregs->clkrun); W_REG(&pciregs->clkrun, w | PCI_CLKRUN_DSBL); diff --git a/drivers/net/wireless/brcm80211/brcmsmac/otp.c b/drivers/net/wireless/brcm80211/brcmsmac/otp.c index edf551561fd8..612434ea952f 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/otp.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/otp.c @@ -146,7 +146,7 @@ static int ipxotp_max_rgnsz(struct si_pub *sih, int osizew) { int ret = 0; - switch (sih->chip) { + switch (ai_get_chip_id(sih)) { case BCM43224_CHIP_ID: case BCM43225_CHIP_ID: ret = osizew * 2 - OTP_SZ_FU_72 - OTP_SZ_CHECKSUM; @@ -170,10 +170,10 @@ static void _ipxotp_init(struct otpinfo *oi, struct chipcregs __iomem *cc) * record word offset of General Use Region * for various chipcommon revs */ - if (oi->sih->ccrev == 21 || oi->sih->ccrev == 24 - || oi->sih->ccrev == 27) { + if (oi->ccrev == 21 || oi->ccrev == 24 + || oi->ccrev == 27) { oi->otpgu_base = REVA4_OTPGU_BASE; - } else if (oi->sih->ccrev == 36) { + } else if (oi->ccrev == 36) { /* * OTP size greater than equal to 2KB (128 words), * otpgu_base is similar to rev23 @@ -182,7 +182,7 @@ static void _ipxotp_init(struct otpinfo *oi, struct chipcregs __iomem *cc) oi->otpgu_base = REVB8_OTPGU_BASE; else oi->otpgu_base = REV36_OTPGU_BASE; - } else if (oi->sih->ccrev == 23 || oi->sih->ccrev >= 25) { + } else if (oi->ccrev == 23 || oi->ccrev >= 25) { oi->otpgu_base = REVB8_OTPGU_BASE; } @@ -201,8 +201,8 @@ static void _ipxotp_init(struct otpinfo *oi, struct chipcregs __iomem *cc) /* Read OTP lock bits and subregion programmed indication bits */ oi->status = R_REG(&cc->otpstatus); - if ((oi->sih->chip == BCM43224_CHIP_ID) - || (oi->sih->chip == BCM43225_CHIP_ID)) { + if ((ai_get_chip_id(oi->sih) == BCM43224_CHIP_ID) + || (ai_get_chip_id(oi->sih) == BCM43225_CHIP_ID)) { u32 p_bits; p_bits = (ipxotp_otpr(oi, cc, oi->otpgu_base + OTPGU_P_OFF) & @@ -244,7 +244,7 @@ static int ipxotp_init(struct si_pub *sih, struct otpinfo *oi) struct chipcregs __iomem *cc; /* Make sure we're running IPX OTP */ - if (!OTPTYPE_IPX(sih->ccrev)) + if (!OTPTYPE_IPX(oi->ccrev)) return -EBADE; /* Make sure OTP is not disabled */ @@ -252,7 +252,7 @@ static int ipxotp_init(struct si_pub *sih, struct otpinfo *oi) return -EBADE; /* Check for otp size */ - switch ((sih->cccaps & CC_CAP_OTPSIZE) >> CC_CAP_OTPSIZE_SHIFT) { + switch ((ai_get_cccaps(sih) & CC_CAP_OTPSIZE) >> CC_CAP_OTPSIZE_SHIFT) { case 0: /* Nothing there */ return -EBADE; @@ -389,7 +389,7 @@ static int otp_init(struct si_pub *sih, struct otpinfo *oi) memset(oi, 0, sizeof(struct otpinfo)); - oi->ccrev = sih->ccrev; + oi->ccrev = ai_get_ccrev(sih); if (OTPTYPE_IPX(oi->ccrev)) oi->fn = &ipxotp_fn; diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c index 008aab9c777c..30cc558dbadc 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c @@ -404,10 +404,8 @@ struct shared_phy *wlc_phy_shared_attach(struct shared_phy_params *shp) sh->sromrev = shp->sromrev; sh->boardtype = shp->boardtype; sh->boardrev = shp->boardrev; - sh->boardvendor = shp->boardvendor; sh->boardflags = shp->boardflags; sh->boardflags2 = shp->boardflags2; - sh->buscorerev = shp->buscorerev; sh->fast_timer = PHY_SW_TIMER_FAST; sh->slow_timer = PHY_SW_TIMER_SLOW; diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_hal.h b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_hal.h index 96e15163222b..5549c7b0cfd6 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_hal.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_hal.h @@ -166,7 +166,6 @@ struct shared_phy_params { struct phy_shim_info *physhim; uint unit; uint corerev; - uint buscorerev; u16 vid; u16 did; uint chip; @@ -175,7 +174,6 @@ struct shared_phy_params { uint sromrev; uint boardtype; uint boardrev; - uint boardvendor; u32 boardflags; u32 boardflags2; }; diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h index 5f9478b1c993..02e640723a9c 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h @@ -503,10 +503,8 @@ struct shared_phy { uint sromrev; uint boardtype; uint boardrev; - uint boardvendor; u32 boardflags; u32 boardflags2; - uint buscorerev; uint fast_timer; uint slow_timer; uint glacial_timer; diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pmu.c b/drivers/net/wireless/brcm80211/brcmsmac/pmu.c index 12ba575f5785..d4e909a6f2ab 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/pmu.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/pmu.c @@ -115,10 +115,10 @@ static void si_pmu_res_masks(struct si_pub *sih, u32 * pmin, u32 * pmax) uint rsrcs; /* # resources */ - rsrcs = (sih->pmucaps & PCAP_RC_MASK) >> PCAP_RC_SHIFT; + rsrcs = (ai_get_pmucaps(sih) & PCAP_RC_MASK) >> PCAP_RC_SHIFT; /* determine min/max rsrc masks */ - switch (sih->chip) { + switch (ai_get_chip_id(sih)) { case BCM43224_CHIP_ID: case BCM43225_CHIP_ID: /* ??? */ @@ -145,7 +145,7 @@ si_pmu_spuravoid_pllupdate(struct si_pub *sih, struct chipcregs __iomem *cc, { u32 tmp = 0; - switch (sih->chip) { + switch (ai_get_chip_id(sih)) { case BCM43224_CHIP_ID: case BCM43225_CHIP_ID: if (spuravoid == 1) { @@ -207,7 +207,7 @@ u16 si_pmu_fast_pwrup_delay(struct si_pub *sih) { uint delay = PMU_MAX_TRANSITION_DLY; - switch (sih->chip) { + switch (ai_get_chip_id(sih)) { case BCM43224_CHIP_ID: case BCM43225_CHIP_ID: case BCM4313_CHIP_ID: @@ -276,10 +276,10 @@ u32 si_pmu_alp_clock(struct si_pub *sih) u32 clock = ALP_CLOCK; /* bail out with default */ - if (!(sih->cccaps & CC_CAP_PMU)) + if (!(ai_get_cccaps(sih) & CC_CAP_PMU)) return clock; - switch (sih->chip) { + switch (ai_get_chip_id(sih)) { case BCM43224_CHIP_ID: case BCM43225_CHIP_ID: case BCM4313_CHIP_ID: @@ -319,9 +319,9 @@ void si_pmu_init(struct si_pub *sih) origidx = ai_coreidx(sih); cc = ai_setcoreidx(sih, SI_CC_IDX); - if (sih->pmurev == 1) + if (ai_get_pmurev(sih) == 1) AND_REG(&cc->pmucontrol, ~PCTL_NOILP_ON_WAIT); - else if (sih->pmurev >= 2) + else if (ai_get_pmurev(sih) >= 2) OR_REG(&cc->pmucontrol, PCTL_NOILP_ON_WAIT); /* Return to original core */ @@ -358,7 +358,7 @@ void si_pmu_pll_init(struct si_pub *sih, uint xtalfreq) origidx = ai_coreidx(sih); cc = ai_setcoreidx(sih, SI_CC_IDX); - switch (sih->chip) { + switch (ai_get_chip_id(sih)) { case BCM4313_CHIP_ID: case BCM43224_CHIP_ID: case BCM43225_CHIP_ID: @@ -411,7 +411,7 @@ u32 si_pmu_measure_alpclk(struct si_pub *sih) uint origidx; u32 alp_khz; - if (sih->pmurev < 10) + if (ai_get_pmurev(sih) < 10) return 0; /* Remember original core before switch to chipc */ diff --git a/drivers/net/wireless/brcm80211/brcmsmac/srom.c b/drivers/net/wireless/brcm80211/brcmsmac/srom.c index b6987ea9fc68..95eb620fc7f0 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/srom.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/srom.c @@ -589,9 +589,9 @@ static u8 brcms_srom_crc8_table[CRC8_TABLE_SIZE]; static u8 __iomem * srom_window_address(struct si_pub *sih, u8 __iomem *curmap) { - if (sih->ccrev < 32) + if (ai_get_ccrev(sih) < 32) return curmap + PCI_BAR0_SPROM_OFFSET; - if (sih->cccaps & CC_CAP_SROM) + if (ai_get_cccaps(sih) & CC_CAP_SROM) return curmap + PCI_16KB0_CCREGS_OFFSET + CC_SROM_OTP; return NULL; -- cgit v1.2.3 From 2e756560a8a47ce754b852d0bc1ff7549433d0eb Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 8 Dec 2011 15:06:46 -0800 Subject: brcm80211: smac: change from pci device driver to bcma device driver A new bus driver called "bcma" has been introduced into the kernel tree which considers the Broadcom AMBA chip interconnect as a bus. Each core in the chip is a bcma device. This commit changes brcms_mac80211.c into a bcma device driver. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/Kconfig | 3 +- .../net/wireless/brcm80211/brcmsmac/mac80211_if.c | 168 ++++++++------------- .../net/wireless/brcm80211/brcmsmac/mac80211_if.h | 2 - 3 files changed, 64 insertions(+), 109 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/Kconfig b/drivers/net/wireless/brcm80211/Kconfig index 2069fc8f7ad1..8f54c2eb6824 100644 --- a/drivers/net/wireless/brcm80211/Kconfig +++ b/drivers/net/wireless/brcm80211/Kconfig @@ -3,9 +3,8 @@ config BRCMUTIL config BRCMSMAC tristate "Broadcom IEEE802.11n PCIe SoftMAC WLAN driver" - depends on PCI depends on MAC80211 - depends on BCMA=n + depends on BCMA select BRCMUTIL select FW_LOADER select CRC_CCITT diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c index 76376eb112fe..9e07dc4376f3 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c @@ -17,11 +17,11 @@ #define __UNDEF_NO_VERSION__ #include -#include #include #include #include #include +#include #include #include #include "nicpci.h" @@ -87,16 +87,14 @@ MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN driver."); MODULE_SUPPORTED_DEVICE("Broadcom 802.11n WLAN cards"); MODULE_LICENSE("Dual BSD/GPL"); -/* recognized PCI IDs */ -static DEFINE_PCI_DEVICE_TABLE(brcms_pci_id_table) = { - { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4357) }, /* 43225 2G */ - { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) }, /* 43224 DUAL */ - { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) }, /* 4313 DUAL */ - { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x0576) }, /* 43224 Ven */ - {0} -}; -MODULE_DEVICE_TABLE(pci, brcms_pci_id_table); +/* recognized BCMA Core IDs */ +static struct bcma_device_id brcms_coreid_table[] = { + BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, + BCMA_ANY_REV, BCMA_ANY_CLASS), + BCMA_CORETABLE_END +}; +MODULE_DEVICE_TABLE(bcma, brcms_coreid_table); #ifdef BCMDBG static int msglevel = 0xdeadbeef; @@ -724,7 +722,7 @@ static const struct ieee80211_ops brcms_ops = { }; /* - * is called in brcms_pci_probe() context, therefore no locking required. + * is called in brcms_bcma_probe() context, therefore no locking required. */ static int brcms_set_hint(struct brcms_info *wl, char *abbrev) { @@ -864,25 +862,15 @@ static void brcms_free(struct brcms_info *wl) #endif kfree(t); } - - /* - * unregister_netdev() calls get_stats() which may read chip - * registers so we cannot unmap the chip registers until - * after calling unregister_netdev() . - */ - if (wl->regsva) - iounmap(wl->regsva); - - wl->regsva = NULL; } /* * called from both kernel as from this kernel module (error flow on attach) * precondition: perimeter lock is not acquired. */ -static void brcms_remove(struct pci_dev *pdev) +static void brcms_remove(struct bcma_device *pdev) { - struct ieee80211_hw *hw = pci_get_drvdata(pdev); + struct ieee80211_hw *hw = bcma_get_drvdata(pdev); struct brcms_info *wl = hw->priv; if (wl->wlc) { @@ -890,11 +878,10 @@ static void brcms_remove(struct pci_dev *pdev) wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy); ieee80211_unregister_hw(hw); } - pci_disable_device(pdev); brcms_free(wl); - pci_set_drvdata(pdev, NULL); + bcma_set_drvdata(pdev, NULL); ieee80211_free_hw(hw); } @@ -1002,11 +989,9 @@ static int ieee_hw_init(struct ieee80211_hw *hw) * it as static. * * - * is called in brcms_pci_probe() context, therefore no locking required. + * is called in brcms_bcma_probe() context, therefore no locking required. */ -static struct brcms_info *brcms_attach(u16 vendor, u16 device, - resource_size_t regs, - struct pci_dev *btparam, uint irq) +static struct brcms_info *brcms_attach(struct bcma_device *pdev) { struct brcms_info *wl = NULL; int unit, err; @@ -1020,7 +1005,7 @@ static struct brcms_info *brcms_attach(u16 vendor, u16 device, return NULL; /* allocate private info */ - hw = pci_get_drvdata(btparam); /* btparam == pdev */ + hw = bcma_get_drvdata(pdev); if (hw != NULL) wl = hw->priv; if (WARN_ON(hw == NULL) || WARN_ON(wl == NULL)) @@ -1032,26 +1017,22 @@ static struct brcms_info *brcms_attach(u16 vendor, u16 device, /* setup the bottom half handler */ tasklet_init(&wl->tasklet, brcms_dpc, (unsigned long) wl); - wl->regsva = ioremap_nocache(regs, PCI_BAR0_WINSZ); - if (wl->regsva == NULL) { - wiphy_err(wl->wiphy, "wl%d: ioremap() failed\n", unit); - goto fail; - } spin_lock_init(&wl->lock); spin_lock_init(&wl->isr_lock); /* prepare ucode */ - if (brcms_request_fw(wl, btparam) < 0) { + if (brcms_request_fw(wl, pdev->bus->host_pci) < 0) { wiphy_err(wl->wiphy, "%s: Failed to find firmware usually in " "%s\n", KBUILD_MODNAME, "/lib/firmware/brcm"); brcms_release_fw(wl); - brcms_remove(btparam); + brcms_remove(pdev); return NULL; } /* common load-time initialization */ - wl->wlc = brcms_c_attach(wl, vendor, device, unit, false, - wl->regsva, btparam, &err); + wl->wlc = brcms_c_attach((void *)wl, pdev->bus->host_pci->vendor, + pdev->bus->host_pci->device, unit, false, + pdev->bus->mmio, pdev->bus->host_pci, &err); brcms_release_fw(wl); if (!wl->wlc) { wiphy_err(wl->wiphy, "%s: attach() failed with code %d\n", @@ -1063,11 +1044,12 @@ static struct brcms_info *brcms_attach(u16 vendor, u16 device, wl->pub->ieee_hw = hw; /* register our interrupt handler */ - if (request_irq(irq, brcms_isr, IRQF_SHARED, KBUILD_MODNAME, wl)) { + if (request_irq(pdev->bus->host_pci->irq, brcms_isr, + IRQF_SHARED, KBUILD_MODNAME, wl)) { wiphy_err(wl->wiphy, "wl%d: request_irq() failed\n", unit); goto fail; } - wl->irq = irq; + wl->irq = pdev->bus->host_pci->irq; /* register module */ brcms_c_module_register(wl->pub, "linux", wl, NULL); @@ -1114,37 +1096,18 @@ fail: * * Perimeter lock is initialized in the course of this function. */ -static int __devinit -brcms_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) +static int __devinit brcms_bcma_probe(struct bcma_device *pdev) { - int rc; struct brcms_info *wl; struct ieee80211_hw *hw; - u32 val; - - dev_info(&pdev->dev, "bus %d slot %d func %d irq %d\n", - pdev->bus->number, PCI_SLOT(pdev->devfn), - PCI_FUNC(pdev->devfn), pdev->irq); - if ((pdev->vendor != PCI_VENDOR_ID_BROADCOM) || - ((pdev->device != 0x0576) && - ((pdev->device & 0xff00) != 0x4300) && - ((pdev->device & 0xff00) != 0x4700) && - ((pdev->device < 43000) || (pdev->device > 43999)))) - return -ENODEV; + dev_info(&pdev->dev, "mfg %x core %x rev %d class %d irq %d\n", + pdev->id.manuf, pdev->id.id, pdev->id.rev, pdev->id.class, + pdev->bus->host_pci->irq); - rc = pci_enable_device(pdev); - if (rc) { - pr_err("%s: Cannot enable device %d-%d_%d\n", - __func__, pdev->bus->number, PCI_SLOT(pdev->devfn), - PCI_FUNC(pdev->devfn)); + if ((pdev->id.manuf != BCMA_MANUF_BCM) || + (pdev->id.id != BCMA_CORE_80211)) return -ENODEV; - } - pci_set_master(pdev); - - pci_read_config_dword(pdev, 0x40, &val); - if ((val & 0x0000ff00) != 0) - pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); hw = ieee80211_alloc_hw(sizeof(struct brcms_info), &brcms_ops); if (!hw) { @@ -1154,14 +1117,11 @@ brcms_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) SET_IEEE80211_DEV(hw, &pdev->dev); - pci_set_drvdata(pdev, hw); + bcma_set_drvdata(pdev, hw); memset(hw->priv, 0, sizeof(*wl)); - wl = brcms_attach(pdev->vendor, pdev->device, - pci_resource_start(pdev, 0), pdev, - pdev->irq); - + wl = brcms_attach(pdev); if (!wl) { pr_err("%s: %s: brcms_attach failed!\n", KBUILD_MODNAME, __func__); @@ -1170,16 +1130,23 @@ brcms_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) return 0; } -static int brcms_suspend(struct pci_dev *pdev, pm_message_t state) +static int brcms_pci_suspend(struct pci_dev *pdev) +{ + pci_save_state(pdev); + pci_disable_device(pdev); + return pci_set_power_state(pdev, PCI_D3hot); +} + +static int brcms_suspend(struct bcma_device *pdev, pm_message_t state) { struct brcms_info *wl; struct ieee80211_hw *hw; - hw = pci_get_drvdata(pdev); + hw = bcma_get_drvdata(pdev); wl = hw->priv; if (!wl) { wiphy_err(wl->wiphy, - "brcms_suspend: pci_get_drvdata failed\n"); + "brcms_suspend: bcma_get_drvdata failed\n"); return -ENODEV; } @@ -1188,25 +1155,14 @@ static int brcms_suspend(struct pci_dev *pdev, pm_message_t state) wl->pub->hw_up = false; spin_unlock_bh(&wl->lock); - pci_save_state(pdev); - pci_disable_device(pdev); - return pci_set_power_state(pdev, PCI_D3hot); + /* temporarily do suspend ourselves */ + return brcms_pci_suspend(pdev->bus->host_pci); } -static int brcms_resume(struct pci_dev *pdev) +static int brcms_pci_resume(struct pci_dev *pdev) { - struct brcms_info *wl; - struct ieee80211_hw *hw; int err = 0; - u32 val; - - hw = pci_get_drvdata(pdev); - wl = hw->priv; - if (!wl) { - wiphy_err(wl->wiphy, - "wl: brcms_resume: pci_get_drvdata failed\n"); - return -ENODEV; - } + uint val; err = pci_set_power_state(pdev, PCI_D0); if (err) @@ -1224,24 +1180,28 @@ static int brcms_resume(struct pci_dev *pdev) if ((val & 0x0000ff00) != 0) pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); + return 0; +} + +static int brcms_resume(struct bcma_device *pdev) +{ /* - * done. driver will be put in up state - * in brcms_ops_add_interface() call. + * just do pci resume for now until bcma supports it. */ - return err; + return brcms_pci_resume(pdev->bus->host_pci); } -static struct pci_driver brcms_pci_driver = { +static struct bcma_driver brcms_bcma_driver = { .name = KBUILD_MODNAME, - .probe = brcms_pci_probe, + .probe = brcms_bcma_probe, .suspend = brcms_suspend, .resume = brcms_resume, .remove = __devexit_p(brcms_remove), - .id_table = brcms_pci_id_table, + .id_table = brcms_coreid_table, }; /** - * This is the main entry point for the WL driver. + * This is the main entry point for the brcmsmac driver. * * This function determines if a device pointed to by pdev is a WL device, * and if so, performs a brcms_attach() on it. @@ -1256,26 +1216,24 @@ static int __init brcms_module_init(void) brcm_msg_level = msglevel; #endif /* BCMDBG */ - error = pci_register_driver(&brcms_pci_driver); + error = bcma_driver_register(&brcms_bcma_driver); + printk(KERN_ERR "%s: register returned %d\n", __func__, error); if (!error) return 0; - - return error; } /** - * This function unloads the WL driver from the system. + * This function unloads the brcmsmac driver from the system. * - * This function unconditionally unloads the WL driver module from the + * This function unconditionally unloads the brcmsmac driver module from the * system. * */ static void __exit brcms_module_exit(void) { - pci_unregister_driver(&brcms_pci_driver); - + bcma_driver_unregister(&brcms_bcma_driver); } module_init(brcms_module_init); @@ -1562,7 +1520,7 @@ fail: } /* - * Precondition: Since this function is called in brcms_pci_probe() context, + * Precondition: Since this function is called in brcms_bcma_probe() context, * no locking is required. */ int brcms_ucode_init_uint(struct brcms_info *wl, size_t *n_bytes, u32 idx) @@ -1602,7 +1560,7 @@ void brcms_ucode_free_buf(void *p) /* * checks validity of all firmware images loaded from user space * - * Precondition: Since this function is called in brcms_pci_probe() context, + * Precondition: Since this function is called in brcms_bcma_probe() context, * no locking is required. */ int brcms_check_firmwares(struct brcms_info *wl) diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h index 6242f188b717..8f60419c37bf 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h @@ -68,8 +68,6 @@ struct brcms_info { spinlock_t lock; /* per-device perimeter lock */ spinlock_t isr_lock; /* per-device ISR synchronization lock */ - /* regsva for unmap in brcms_free() */ - void __iomem *regsva; /* opaque chip registers virtual address */ /* timer related fields */ atomic_t callbacks; /* # outstanding callback functions */ -- cgit v1.2.3 From b63337a0344d7ebf3c8d710b1327d0b61c0f6f03 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 8 Dec 2011 15:06:47 -0800 Subject: brcm80211: smac: change attach interfaces in main.c for bcma support The driver is probed through bcma which provides a device representing the core. This device is now passed in brcms_c_attach and brcms_b_attach functions. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- .../net/wireless/brcm80211/brcmsmac/mac80211_if.c | 4 +-- drivers/net/wireless/brcm80211/brcmsmac/main.c | 31 +++++++++++----------- drivers/net/wireless/brcm80211/brcmsmac/pub.h | 6 ++--- 3 files changed, 19 insertions(+), 22 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c index 9e07dc4376f3..30ac8b4ce443 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c @@ -1030,9 +1030,7 @@ static struct brcms_info *brcms_attach(struct bcma_device *pdev) } /* common load-time initialization */ - wl->wlc = brcms_c_attach((void *)wl, pdev->bus->host_pci->vendor, - pdev->bus->host_pci->device, unit, false, - pdev->bus->mmio, pdev->bus->host_pci, &err); + wl->wlc = brcms_c_attach((void *)wl, pdev, unit, false, &err); brcms_release_fw(wl); if (!wl->wlc) { wiphy_err(wl->wiphy, "%s: attach() failed with code %d\n", diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index ed8fcb40b518..d329c900be79 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -4437,9 +4437,8 @@ struct brcms_pub *brcms_c_pub(struct brcms_c_info *wlc) * initialize software state for each core and band * put the whole chip in reset(driver down state), no clock */ -static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, - uint unit, bool piomode, void __iomem *regsva, - struct pci_dev *btparam) +static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core, + uint unit, bool piomode) { struct brcms_hardware *wlc_hw; struct d11regs __iomem *regs; @@ -4449,9 +4448,11 @@ static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, bool wme = false; struct shared_phy_params sha_params; struct wiphy *wiphy = wlc->wiphy; + struct pci_dev *pcidev = core->bus->host_pci; - BCMMSG(wlc->wiphy, "wl%d: vendor 0x%x device 0x%x\n", unit, vendor, - device); + BCMMSG(wlc->wiphy, "wl%d: vendor 0x%x device 0x%x\n", unit, + pcidev->vendor, + pcidev->device); wme = true; @@ -4468,7 +4469,7 @@ static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, * Do the hardware portion of the attach. Also initialize software * state that depends on the particular hardware we are running. */ - wlc_hw->sih = ai_attach(regsva, btparam); + wlc_hw->sih = ai_attach(core->bus->mmio, core->bus->host_pci); if (wlc_hw->sih == NULL) { wiphy_err(wiphy, "wl%d: brcms_b_attach: si_attach failed\n", unit); @@ -4477,16 +4478,16 @@ static int brcms_b_attach(struct brcms_c_info *wlc, u16 vendor, u16 device, } /* verify again the device is supported */ - if (!brcms_c_chipmatch(vendor, device)) { + if (!brcms_c_chipmatch(pcidev->vendor, pcidev->device)) { wiphy_err(wiphy, "wl%d: brcms_b_attach: Unsupported " "vendor/device (0x%x/0x%x)\n", - unit, vendor, device); + unit, pcidev->vendor, pcidev->device); err = 12; goto fail; } - wlc_hw->vendorid = vendor; - wlc_hw->deviceid = device; + wlc_hw->vendorid = pcidev->vendor; + wlc_hw->deviceid = pcidev->device; /* set bar0 window to point at D11 core */ wlc_hw->regs = (struct d11regs __iomem *) @@ -8351,9 +8352,8 @@ void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx) * The common driver entry routine. Error codes should be unique */ struct brcms_c_info * -brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, - bool piomode, void __iomem *regsva, struct pci_dev *btparam, - uint *perr) +brcms_c_attach(struct brcms_info *wl, struct bcma_device *core, uint unit, + bool piomode, uint *perr) { struct brcms_c_info *wlc; uint err = 0; @@ -8361,7 +8361,7 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, struct brcms_pub *pub; /* allocate struct brcms_c_info state and its substructures */ - wlc = (struct brcms_c_info *) brcms_c_attach_malloc(unit, &err, device); + wlc = (struct brcms_c_info *) brcms_c_attach_malloc(unit, &err, 0); if (wlc == NULL) goto fail; wlc->wiphy = wl->wiphy; @@ -8388,8 +8388,7 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, * low level attach steps(all hw accesses go * inside, no more in rest of the attach) */ - err = brcms_b_attach(wlc, vendor, device, unit, piomode, regsva, - btparam); + err = brcms_b_attach(wlc, core, unit, piomode); if (err) goto fail; diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pub.h b/drivers/net/wireless/brcm80211/brcmsmac/pub.h index 21ccf3a03987..f0038ad7d7bf 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/pub.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/pub.h @@ -17,6 +17,7 @@ #ifndef _BRCM_PUB_H_ #define _BRCM_PUB_H_ +#include #include #include "types.h" #include "defs.h" @@ -530,9 +531,8 @@ struct brcms_antselcfg { /* common functions for every port */ extern struct brcms_c_info * -brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, - bool piomode, void __iomem *regsva, struct pci_dev *btparam, - uint *perr); +brcms_c_attach(struct brcms_info *wl, struct bcma_device *core, uint unit, + bool piomode, uint *perr); extern uint brcms_c_detach(struct brcms_c_info *wlc); extern int brcms_c_up(struct brcms_c_info *wlc); extern uint brcms_c_down(struct brcms_c_info *wlc); -- cgit v1.2.3 From cbc80db2922112cf3c77a6121827ad662ea78c2d Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 8 Dec 2011 15:06:48 -0800 Subject: brcm80211: smac: rename struct si_info field pbus to pcibus When moving to bcma usage there are two busses in play. The pci bus connecting the device to the host and the bcma bus connecting the cores in the device. To distinguish this the attribute pbus has been renamed to a more explicit name, ie. pcibus. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 46 +++++++++++------------ drivers/net/wireless/brcm80211/brcmsmac/aiutils.h | 2 +- drivers/net/wireless/brcm80211/brcmsmac/dma.c | 2 +- 3 files changed, 25 insertions(+), 25 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c index 83a013833678..5c7311934f63 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c @@ -564,7 +564,7 @@ static void ai_scan(struct si_pub *sih, struct chipcregs __iomem *cc) sii->curwrap = (void *)((unsigned long)cc + SI_CORE_SIZE); /* Now point the window at the erom */ - pci_write_config_dword(sii->pbus, PCI_BAR0_WIN, erombase); + pci_write_config_dword(sii->pcibus, PCI_BAR0_WIN, erombase); eromptr = regs; eromlim = eromptr + (ER_REMAPCONTROL / sizeof(u32)); @@ -741,9 +741,9 @@ void __iomem *ai_setcoreidx(struct si_pub *sih, uint coreidx) return NULL; /* point bar0 window */ - pci_write_config_dword(sii->pbus, PCI_BAR0_WIN, addr); + pci_write_config_dword(sii->pcibus, PCI_BAR0_WIN, addr); /* point bar0 2nd 4KB window */ - pci_write_config_dword(sii->pbus, PCI_BAR0_WIN2, wrap); + pci_write_config_dword(sii->pcibus, PCI_BAR0_WIN2, wrap); sii->curidx = coreidx; return sii->curmap; @@ -880,7 +880,7 @@ static bool ai_ispcie(struct si_info *sii) u8 cap_ptr; cap_ptr = - pcicore_find_pci_capability(sii->pbus, PCI_CAP_ID_EXP, NULL, + pcicore_find_pci_capability(sii->pcibus, PCI_CAP_ID_EXP, NULL, NULL); if (!cap_ptr) return false; @@ -990,7 +990,7 @@ ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx) /* fixup necessary chip/core configurations */ if (SI_FAST(&sii->pub)) { if (!sii->pch) { - sii->pch = pcicore_init(&sii->pub, sii->pbus, + sii->pch = pcicore_init(&sii->pub, sii->pcibus, (__iomem void *)PCIEREGS(sii)); if (sii->pch == NULL) return false; @@ -1015,7 +1015,7 @@ static __used void ai_nvram_process(struct si_info *sii) uint w = 0; /* do a pci config read to get subsystem id and subvendor id */ - pci_read_config_dword(sii->pbus, PCI_SUBSYSTEM_VENDOR_ID, &w); + pci_read_config_dword(sii->pcibus, PCI_SUBSYSTEM_VENDOR_ID, &w); sii->pub.boardvendor = w & 0xffff; sii->pub.boardtype = (w >> 16) & 0xffff; @@ -1037,14 +1037,14 @@ static struct si_info *ai_doattach(struct si_info *sii, sii->buscoreidx = BADIDX; sii->curmap = regs; - sii->pbus = pbus; + sii->pcibus = pbus; /* find Chipcommon address */ - pci_read_config_dword(sii->pbus, PCI_BAR0_WIN, &savewin); + pci_read_config_dword(sii->pcibus, PCI_BAR0_WIN, &savewin); if (!GOODCOREADDR(savewin, SI_ENUM_BASE)) savewin = SI_ENUM_BASE; - pci_write_config_dword(sii->pbus, PCI_BAR0_WIN, + pci_write_config_dword(sii->pcibus, PCI_BAR0_WIN, SI_ENUM_BASE); cc = (struct chipcregs __iomem *) regs; @@ -1481,7 +1481,7 @@ static uint ai_slowclk_src(struct si_info *sii) u32 val; if (ai_get_ccrev(&sii->pub) < 6) { - pci_read_config_dword(sii->pbus, PCI_GPIO_OUT, + pci_read_config_dword(sii->pcibus, PCI_GPIO_OUT, &val); if (val & PCI_CFG_GPIO_SCS) return SCC_SS_PCI; @@ -1663,9 +1663,9 @@ int ai_clkctl_xtal(struct si_pub *sih, uint what, bool on) if (PCIE(sih)) return -1; - pci_read_config_dword(sii->pbus, PCI_GPIO_IN, &in); - pci_read_config_dword(sii->pbus, PCI_GPIO_OUT, &out); - pci_read_config_dword(sii->pbus, PCI_GPIO_OUTEN, &outen); + pci_read_config_dword(sii->pcibus, PCI_GPIO_IN, &in); + pci_read_config_dword(sii->pcibus, PCI_GPIO_OUT, &out); + pci_read_config_dword(sii->pcibus, PCI_GPIO_OUTEN, &outen); /* * Avoid glitching the clock if GPRS is already using it. @@ -1686,9 +1686,9 @@ int ai_clkctl_xtal(struct si_pub *sih, uint what, bool on) out |= PCI_CFG_GPIO_XTAL; if (what & PLL) out |= PCI_CFG_GPIO_PLL; - pci_write_config_dword(sii->pbus, + pci_write_config_dword(sii->pcibus, PCI_GPIO_OUT, out); - pci_write_config_dword(sii->pbus, + pci_write_config_dword(sii->pcibus, PCI_GPIO_OUTEN, outen); udelay(XTAL_ON_DELAY); } @@ -1696,7 +1696,7 @@ int ai_clkctl_xtal(struct si_pub *sih, uint what, bool on) /* turn pll on */ if (what & PLL) { out &= ~PCI_CFG_GPIO_PLL; - pci_write_config_dword(sii->pbus, + pci_write_config_dword(sii->pcibus, PCI_GPIO_OUT, out); mdelay(2); } @@ -1705,9 +1705,9 @@ int ai_clkctl_xtal(struct si_pub *sih, uint what, bool on) out &= ~PCI_CFG_GPIO_XTAL; if (what & PLL) out |= PCI_CFG_GPIO_PLL; - pci_write_config_dword(sii->pbus, + pci_write_config_dword(sii->pcibus, PCI_GPIO_OUT, out); - pci_write_config_dword(sii->pbus, + pci_write_config_dword(sii->pcibus, PCI_GPIO_OUTEN, outen); } @@ -1835,9 +1835,9 @@ int ai_devpath(struct si_pub *sih, char *path, int size) return -1; slen = snprintf(path, (size_t) size, "pci/%u/%u/", - ((struct si_info *)sih)->pbus->bus->number, + ((struct si_info *)sih)->pcibus->bus->number, PCI_SLOT(((struct pci_dev *) - (((struct si_info *)(sih))->pbus))->devfn)); + (((struct si_info *)(sih))->pcibus))->devfn)); if (slen < 0 || slen >= size) { path[0] = '\0'; @@ -1915,9 +1915,9 @@ void ai_pci_setup(struct si_pub *sih, uint coremask) */ if (PCIE(sih) || (PCI(sih) && (ai_get_buscorerev(sih) >= 6))) { /* pci config write to set this core bit in PCIIntMask */ - pci_read_config_dword(sii->pbus, PCI_INT_MASK, &w); + pci_read_config_dword(sii->pcibus, PCI_INT_MASK, &w); w |= (coremask << PCI_SBIM_SHIFT); - pci_write_config_dword(sii->pbus, PCI_INT_MASK, w); + pci_write_config_dword(sii->pcibus, PCI_INT_MASK, w); } else { /* set sbintvec bit for our flag number */ ai_setint(sih, siflag); @@ -2028,7 +2028,7 @@ bool ai_deviceremoved(struct si_pub *sih) sii = (struct si_info *)sih; - pci_read_config_dword(sii->pbus, PCI_VENDOR_ID, &w); + pci_read_config_dword(sii->pcibus, PCI_VENDOR_ID, &w); if ((w & 0xFFFF) != PCI_VENDOR_ID_BROADCOM) return true; diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h index 347b8a26f025..0a8e2f735956 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h @@ -170,7 +170,7 @@ struct gpioh_item { /* misc si info needed by some of the routines */ struct si_info { struct si_pub pub; /* back plane public state (must be first) */ - struct pci_dev *pbus; /* handle to pci bus */ + struct pci_dev *pcibus; /* handle to pci bus */ uint dev_coreid; /* the core provides driver functions */ void *intr_arg; /* interrupt callback function arg */ u32 (*intrsoff_fn) (void *intr_arg); /* turns chip interrupts off */ diff --git a/drivers/net/wireless/brcm80211/brcmsmac/dma.c b/drivers/net/wireless/brcm80211/brcmsmac/dma.c index b55b1f6bb4ba..3a60eb878ffa 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/dma.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/dma.c @@ -594,7 +594,7 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, strncpy(di->name, name, MAXNAMEL); di->name[MAXNAMEL - 1] = '\0'; - di->pbus = ((struct si_info *)sih)->pbus; + di->pbus = ((struct si_info *)sih)->pcibus; /* save tunables */ di->ntxd = (u16) ntxd; -- cgit v1.2.3 From 28a5344261753fadb1731b82c5eeecca708a877c Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 8 Dec 2011 15:06:49 -0800 Subject: brcm80211: smac: change ai_attach interface taking a bcma_bus object The ai_attach now takes a bcma_bus object as its parameter to obtain all required information needed for chip control. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 18 +++++++++--------- drivers/net/wireless/brcm80211/brcmsmac/aiutils.h | 5 ++++- drivers/net/wireless/brcm80211/brcmsmac/main.c | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c index 5c7311934f63..c1e4f35f2955 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c @@ -1022,22 +1022,25 @@ static __used void ai_nvram_process(struct si_info *sii) } static struct si_info *ai_doattach(struct si_info *sii, - void __iomem *regs, struct pci_dev *pbus) + struct bcma_bus *pbus) { + void __iomem *regs = pbus->mmio; struct si_pub *sih = &sii->pub; u32 w, savewin; struct chipcregs __iomem *cc; uint socitype; uint origidx; + /* assume the window is looking at chipcommon */ + WARN_ON(pbus->mapped_core->id.id != BCMA_CORE_CHIPCOMMON); memset((unsigned char *) sii, 0, sizeof(struct si_info)); savewin = 0; + sii->icbus = pbus; sii->buscoreidx = BADIDX; - sii->curmap = regs; - sii->pcibus = pbus; + sii->pcibus = pbus->host_pci; /* find Chipcommon address */ pci_read_config_dword(sii->pcibus, PCI_BAR0_WIN, &savewin); @@ -1160,13 +1163,10 @@ static struct si_info *ai_doattach(struct si_info *sii, } /* - * Allocate a si handle. - * devid - pci device id (used to determine chip#) - * osh - opaque OS handle - * regs - virtual address of initial core registers + * Allocate a si handle and do the attach. */ struct si_pub * -ai_attach(void __iomem *regs, struct pci_dev *sdh) +ai_attach(struct bcma_bus *pbus) { struct si_info *sii; @@ -1175,7 +1175,7 @@ ai_attach(void __iomem *regs, struct pci_dev *sdh) if (sii == NULL) return NULL; - if (ai_doattach(sii, regs, sdh) == NULL) { + if (ai_doattach(sii, pbus) == NULL) { kfree(sii); return NULL; } diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h index 0a8e2f735956..1e93599b6047 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h @@ -17,6 +17,8 @@ #ifndef _BRCM_AIUTILS_H_ #define _BRCM_AIUTILS_H_ +#include + #include "types.h" /* @@ -170,6 +172,7 @@ struct gpioh_item { /* misc si info needed by some of the routines */ struct si_info { struct si_pub pub; /* back plane public state (must be first) */ + struct bcma_bus *icbus; /* handle to soc interconnect bus */ struct pci_dev *pcibus; /* handle to pci bus */ uint dev_coreid; /* the core provides driver functions */ void *intr_arg; /* interrupt callback function arg */ @@ -235,7 +238,7 @@ extern u32 ai_addrspacesize(struct si_pub *sih, uint asidx); extern void ai_write_wrap_reg(struct si_pub *sih, u32 offset, u32 val); /* === exported functions === */ -extern struct si_pub *ai_attach(void __iomem *regs, struct pci_dev *sdh); +extern struct si_pub *ai_attach(struct bcma_bus *pbus); extern void ai_detach(struct si_pub *sih); extern uint ai_coreid(struct si_pub *sih); extern uint ai_corerev(struct si_pub *sih); diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index d329c900be79..73bc0ab78320 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -4469,7 +4469,7 @@ static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core, * Do the hardware portion of the attach. Also initialize software * state that depends on the particular hardware we are running. */ - wlc_hw->sih = ai_attach(core->bus->mmio, core->bus->host_pci); + wlc_hw->sih = ai_attach(core->bus); if (wlc_hw->sih == NULL) { wiphy_err(wiphy, "wl%d: brcms_b_attach: si_attach failed\n", unit); -- cgit v1.2.3 From 5204563ab841fbb5d6ef683635682e155a0a9e84 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 8 Dec 2011 15:06:50 -0800 Subject: brcm80211: smac: remove enumeration rom parsing function The core enumeration rom is already parsed by the bcma bus driver and there is no need to repeat the exercise. The ai_scan() function still exists but is targetted for removal as well. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 255 ++-------------------- 1 file changed, 18 insertions(+), 237 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c index c1e4f35f2955..989dd3ed5b88 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c @@ -481,247 +481,27 @@ struct aidmp { u32 componentid3; /* 0xffc */ }; -/* EROM parsing */ - -static u32 -get_erom_ent(struct si_pub *sih, u32 __iomem **eromptr, u32 mask, u32 match) -{ - u32 ent; - uint inv = 0, nom = 0; - - while (true) { - ent = R_REG(*eromptr); - (*eromptr)++; - - if (mask == 0) - break; - - if ((ent & ER_VALID) == 0) { - inv++; - continue; - } - - if (ent == (ER_END | ER_VALID)) - break; - - if ((ent & mask) == match) - break; - - nom++; - } - - return ent; -} - -static u32 -get_asd(struct si_pub *sih, u32 __iomem **eromptr, uint sp, uint ad, uint st, - u32 *addrl, u32 *addrh, u32 *sizel, u32 *sizeh) -{ - u32 asd, sz, szd; - - asd = get_erom_ent(sih, eromptr, ER_VALID, ER_VALID); - if (((asd & ER_TAG1) != ER_ADD) || - (((asd & AD_SP_MASK) >> AD_SP_SHIFT) != sp) || - ((asd & AD_ST_MASK) != st)) { - /* This is not what we want, "push" it back */ - (*eromptr)--; - return 0; - } - *addrl = asd & AD_ADDR_MASK; - if (asd & AD_AG32) - *addrh = get_erom_ent(sih, eromptr, 0, 0); - else - *addrh = 0; - *sizeh = 0; - sz = asd & AD_SZ_MASK; - if (sz == AD_SZ_SZD) { - szd = get_erom_ent(sih, eromptr, 0, 0); - *sizel = szd & SD_SZ_MASK; - if (szd & SD_SG32) - *sizeh = get_erom_ent(sih, eromptr, 0, 0); - } else - *sizel = AD_SZ_BASE << (sz >> AD_SZ_SHIFT); - - return asd; -} - -static void ai_hwfixup(struct si_info *sii) -{ -} - /* parse the enumeration rom to identify all cores */ -static void ai_scan(struct si_pub *sih, struct chipcregs __iomem *cc) +static void ai_scan(struct si_pub *sih, struct bcma_bus *bus) { struct si_info *sii = (struct si_info *)sih; + struct bcma_device *core; + uint idx; - u32 erombase; - u32 __iomem *eromptr, *eromlim; - void __iomem *regs = cc; - - erombase = R_REG(&cc->eromptr); - - /* Set wrappers address */ - sii->curwrap = (void *)((unsigned long)cc + SI_CORE_SIZE); - - /* Now point the window at the erom */ - pci_write_config_dword(sii->pcibus, PCI_BAR0_WIN, erombase); - eromptr = regs; - eromlim = eromptr + (ER_REMAPCONTROL / sizeof(u32)); - - while (eromptr < eromlim) { - u32 cia, cib, cid, mfg, crev, nmw, nsw, nmp, nsp; - u32 mpd, asd, addrl, addrh, sizel, sizeh; - u32 __iomem *base; - uint i, j, idx; - bool br; - - br = false; - - /* Grok a component */ - cia = get_erom_ent(sih, &eromptr, ER_TAG, ER_CI); - if (cia == (ER_END | ER_VALID)) { - /* Found END of erom */ - ai_hwfixup(sii); - return; - } - base = eromptr - 1; - cib = get_erom_ent(sih, &eromptr, 0, 0); - - if ((cib & ER_TAG) != ER_CI) { - /* CIA not followed by CIB */ - goto error; - } - - cid = (cia & CIA_CID_MASK) >> CIA_CID_SHIFT; - mfg = (cia & CIA_MFG_MASK) >> CIA_MFG_SHIFT; - crev = (cib & CIB_REV_MASK) >> CIB_REV_SHIFT; - nmw = (cib & CIB_NMW_MASK) >> CIB_NMW_SHIFT; - nsw = (cib & CIB_NSW_MASK) >> CIB_NSW_SHIFT; - nmp = (cib & CIB_NMP_MASK) >> CIB_NMP_SHIFT; - nsp = (cib & CIB_NSP_MASK) >> CIB_NSP_SHIFT; - - if (((mfg == MFGID_ARM) && (cid == DEF_AI_COMP)) || (nsp == 0)) - continue; - if ((nmw + nsw == 0)) { - /* A component which is not a core */ - if (cid == OOB_ROUTER_CORE_ID) { - asd = get_asd(sih, &eromptr, 0, 0, AD_ST_SLAVE, - &addrl, &addrh, &sizel, &sizeh); - if (asd != 0) - sii->oob_router = addrl; - } - continue; - } - - idx = sii->numcores; -/* sii->eromptr[idx] = base; */ - sii->cia[idx] = cia; - sii->cib[idx] = cib; - sii->coreid[idx] = cid; - - for (i = 0; i < nmp; i++) { - mpd = get_erom_ent(sih, &eromptr, ER_VALID, ER_VALID); - if ((mpd & ER_TAG) != ER_MP) { - /* Not enough MP entries for component */ - goto error; - } - } - - /* First Slave Address Descriptor should be port 0: - * the main register space for the core - */ - asd = - get_asd(sih, &eromptr, 0, 0, AD_ST_SLAVE, &addrl, &addrh, - &sizel, &sizeh); - if (asd == 0) { - /* Try again to see if it is a bridge */ - asd = - get_asd(sih, &eromptr, 0, 0, AD_ST_BRIDGE, &addrl, - &addrh, &sizel, &sizeh); - if (asd != 0) - br = true; - else if ((addrh != 0) || (sizeh != 0) - || (sizel != SI_CORE_SIZE)) { - /* First Slave ASD for core malformed */ - goto error; - } - } - sii->coresba[idx] = addrl; - sii->coresba_size[idx] = sizel; - /* Get any more ASDs in port 0 */ - j = 1; - do { - asd = - get_asd(sih, &eromptr, 0, j, AD_ST_SLAVE, &addrl, - &addrh, &sizel, &sizeh); - if ((asd != 0) && (j == 1) && (sizel == SI_CORE_SIZE)) { - sii->coresba2[idx] = addrl; - sii->coresba2_size[idx] = sizel; - } - j++; - } while (asd != 0); - - /* Go through the ASDs for other slave ports */ - for (i = 1; i < nsp; i++) { - j = 0; - do { - asd = - get_asd(sih, &eromptr, i, j++, AD_ST_SLAVE, - &addrl, &addrh, &sizel, &sizeh); - } while (asd != 0); - if (j == 0) { - /* SP has no address descriptors */ - goto error; - } - } - - /* Now get master wrappers */ - for (i = 0; i < nmw; i++) { - asd = - get_asd(sih, &eromptr, i, 0, AD_ST_MWRAP, &addrl, - &addrh, &sizel, &sizeh); - if (asd == 0) { - /* Missing descriptor for MW */ - goto error; - } - if ((sizeh != 0) || (sizel != SI_CORE_SIZE)) { - /* Master wrapper %d is not 4KB */ - goto error; - } - if (i == 0) - sii->wrapba[idx] = addrl; - } - - /* And finally slave wrappers */ - for (i = 0; i < nsw; i++) { - uint fwp = (nsp == 1) ? 0 : 1; - asd = - get_asd(sih, &eromptr, fwp + i, 0, AD_ST_SWRAP, - &addrl, &addrh, &sizel, &sizeh); - if (asd == 0) { - /* Missing descriptor for SW */ - goto error; - } - if ((sizeh != 0) || (sizel != SI_CORE_SIZE)) { - /* Slave wrapper is not 4KB */ - goto error; - } - if ((nmw == 0) && (i == 0)) - sii->wrapba[idx] = addrl; - } - - /* Don't record bridges */ - if (br) - continue; - - /* Done with core */ + list_for_each_entry(core, &bus->cores, list) { + idx = core->core_index; + sii->cia[idx] = core->id.manuf << CIA_MFG_SHIFT; + sii->cia[idx] |= core->id.id << CIA_CID_SHIFT; + sii->cia[idx] |= core->id.class << CIA_CCL_SHIFT; + sii->cib[idx] = core->id.rev << CIB_REV_SHIFT; + sii->coreid[idx] = core->id.id; + sii->coresba[idx] = core->addr; + sii->coresba_size[idx] = 0x1000; + sii->coresba2[idx] = 0; + sii->coresba2_size[idx] = 0; + sii->wrapba[idx] = core->wrap; sii->numcores++; } - - error: - /* Reached end of erom without finding END */ - sii->numcores = 0; - return; } /* @@ -1039,8 +819,9 @@ static struct si_info *ai_doattach(struct si_info *sii, sii->icbus = pbus; sii->buscoreidx = BADIDX; - sii->curmap = regs; sii->pcibus = pbus->host_pci; + sii->curmap = regs; + sii->curwrap = sii->curmap + SI_CORE_SIZE; /* find Chipcommon address */ pci_read_config_dword(sii->pcibus, PCI_BAR0_WIN, &savewin); @@ -1073,7 +854,7 @@ static struct si_info *ai_doattach(struct si_info *sii, if (socitype == SOCI_AI) { SI_MSG("Found chip type AI (0x%08x)\n", w); /* pass chipc address instead of original core base */ - ai_scan(&sii->pub, cc); + ai_scan(&sii->pub, pbus); } else { /* Found chip of unknown type */ return NULL; -- cgit v1.2.3 From 16d2812e9eaaa47ca952ea81e34b4f400c861dfc Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 8 Dec 2011 15:06:51 -0800 Subject: brcm80211: smac: use bcma core register access functions for 802.11 core The driver now uses the bcma register access functions to read and write the registers on the 802.11 core. The dma and phy code need to be modified next and access to the other cores. That will be done in coming patches. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 48 ++- drivers/net/wireless/brcm80211/brcmsmac/ampdu.c | 7 +- drivers/net/wireless/brcm80211/brcmsmac/d11.h | 3 + drivers/net/wireless/brcm80211/brcmsmac/main.c | 479 +++++++++++----------- drivers/net/wireless/brcm80211/brcmsmac/main.h | 4 +- 5 files changed, 274 insertions(+), 267 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c index 989dd3ed5b88..ef1441a9a4e0 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c @@ -504,6 +504,17 @@ static void ai_scan(struct si_pub *sih, struct bcma_bus *bus) } } +static struct bcma_device *ai_find_bcma_core(struct si_pub *sih, uint coreidx) +{ + struct si_info *sii = (struct si_info *)sih; + struct bcma_device *core; + + list_for_each_entry(core, &sii->icbus->cores, list) { + if (core->core_index == coreidx) + return core; + } + return NULL; +} /* * This function changes the logical "focus" to the indicated core. * Return the current core's virtual address. Since each core starts with the @@ -514,18 +525,16 @@ static void ai_scan(struct si_pub *sih, struct bcma_bus *bus) void __iomem *ai_setcoreidx(struct si_pub *sih, uint coreidx) { struct si_info *sii = (struct si_info *)sih; - u32 addr = sii->coresba[coreidx]; - u32 wrap = sii->wrapba[coreidx]; - - if (coreidx >= sii->numcores) - return NULL; + struct bcma_device *core; - /* point bar0 window */ - pci_write_config_dword(sii->pcibus, PCI_BAR0_WIN, addr); - /* point bar0 2nd 4KB window */ - pci_write_config_dword(sii->pcibus, PCI_BAR0_WIN2, wrap); - sii->curidx = coreidx; + if (sii->curidx != coreidx) { + core = ai_find_bcma_core(sih, coreidx); + if (core == NULL) + return NULL; + (void)bcma_aread32(core, BCMA_IOST); + sii->curidx = coreidx; + } return sii->curmap; } @@ -811,8 +820,6 @@ static struct si_info *ai_doattach(struct si_info *sii, uint socitype; uint origidx; - /* assume the window is looking at chipcommon */ - WARN_ON(pbus->mapped_core->id.id != BCMA_CORE_CHIPCOMMON); memset((unsigned char *) sii, 0, sizeof(struct si_info)); savewin = 0; @@ -823,13 +830,10 @@ static struct si_info *ai_doattach(struct si_info *sii, sii->curmap = regs; sii->curwrap = sii->curmap + SI_CORE_SIZE; - /* find Chipcommon address */ - pci_read_config_dword(sii->pcibus, PCI_BAR0_WIN, &savewin); - if (!GOODCOREADDR(savewin, SI_ENUM_BASE)) - savewin = SI_ENUM_BASE; + /* switch to Chipcommon core */ + bcma_read32(pbus->drv_cc.core, 0); + savewin = SI_ENUM_BASE; - pci_write_config_dword(sii->pcibus, PCI_BAR0_WIN, - SI_ENUM_BASE); cc = (struct chipcregs __iomem *) regs; /* bus/core/clk setup for register access */ @@ -1036,18 +1040,18 @@ bool ai_backplane64(struct si_pub *sih) /* return index of coreid or BADIDX if not found */ uint ai_findcoreidx(struct si_pub *sih, uint coreid, uint coreunit) { + struct bcma_device *core; struct si_info *sii; uint found; - uint i; sii = (struct si_info *)sih; found = 0; - for (i = 0; i < sii->numcores; i++) - if (sii->coreid[i] == coreid) { + list_for_each_entry(core, &sii->icbus->cores, list) + if (core->id.id == coreid) { if (found == coreunit) - return i; + return core->core_index; found++; } diff --git a/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c b/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c index 43f7a724dda8..90911eec0cf5 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/ampdu.c @@ -1118,14 +1118,17 @@ brcms_c_ampdu_dotxstatus(struct ampdu_info *ampdu, struct scb *scb, u8 status_delay = 0; /* wait till the next 8 bytes of txstatus is available */ - while (((s1 = R_REG(&wlc->regs->frmtxstatus)) & TXS_V) == 0) { + s1 = bcma_read32(wlc->hw->d11core, D11REGOFFS(frmtxstatus)); + while ((s1 & TXS_V) == 0) { udelay(1); status_delay++; if (status_delay > 10) return; /* error condition */ + s1 = bcma_read32(wlc->hw->d11core, + D11REGOFFS(frmtxstatus)); } - s2 = R_REG(&wlc->regs->frmtxstatus2); + s2 = bcma_read32(wlc->hw->d11core, D11REGOFFS(frmtxstatus2)); } if (scb) { diff --git a/drivers/net/wireless/brcm80211/brcmsmac/d11.h b/drivers/net/wireless/brcm80211/brcmsmac/d11.h index ed51616abc85..1948cb2771e9 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/d11.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/d11.h @@ -430,6 +430,9 @@ struct d11regs { u16 PAD[0x380]; /* 0x800 - 0xEFE */ }; +/* d11 register field offset */ +#define D11REGOFFS(field) offsetof(struct d11regs, field) + #define PIHR_BASE 0x0400 /* byte address of packed IHR region */ /* biststatus */ diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index 73bc0ab78320..f4a64652fdab 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -388,10 +388,13 @@ static u16 get_sifs(struct brcms_band *band) */ static bool brcms_deviceremoved(struct brcms_c_info *wlc) { + u32 macctrl; + if (!wlc->hw->clk) return ai_deviceremoved(wlc->hw->sih); - return (R_REG(&wlc->hw->regs->maccontrol) & - (MCTL_PSM_JMP_0 | MCTL_IHR_EN)) != MCTL_IHR_EN; + macctrl = bcma_read32(wlc->hw->d11core, + D11REGOFFS(maccontrol)); + return (macctrl & (MCTL_PSM_JMP_0 | MCTL_IHR_EN)) != MCTL_IHR_EN; } /* sum the individual fifo tx pending packet counts */ @@ -582,17 +585,15 @@ brcms_c_attach_malloc(uint unit, uint *err, uint devid) static void brcms_b_update_slot_timing(struct brcms_hardware *wlc_hw, bool shortslot) { - struct d11regs __iomem *regs; - - regs = wlc_hw->regs; + struct bcma_device *core = wlc_hw->d11core; if (shortslot) { /* 11g short slot: 11a timing */ - W_REG(®s->ifs_slot, 0x0207); /* APHY_SLOT_TIME */ + bcma_write16(core, D11REGOFFS(ifs_slot), 0x0207); brcms_b_write_shm(wlc_hw, M_DOT11_SLOT, APHY_SLOT_TIME); } else { /* 11g long slot: 11b timing */ - W_REG(®s->ifs_slot, 0x0212); /* BPHY_SLOT_TIME */ + bcma_write16(core, D11REGOFFS(ifs_slot), 0x0212); brcms_b_write_shm(wlc_hw, M_DOT11_SLOT, BPHY_SLOT_TIME); } } @@ -672,24 +673,22 @@ static uint brcms_c_calc_frame_time(struct brcms_c_info *wlc, u32 ratespec, static void brcms_c_write_inits(struct brcms_hardware *wlc_hw, const struct d11init *inits) { + struct bcma_device *core = wlc_hw->d11core; int i; - u8 __iomem *base; - u8 __iomem *addr; + uint offset; u16 size; u32 value; BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - base = (u8 __iomem *)wlc_hw->regs; - for (i = 0; inits[i].addr != cpu_to_le16(0xffff); i++) { size = le16_to_cpu(inits[i].size); - addr = base + le16_to_cpu(inits[i].addr); + offset = le16_to_cpu(inits[i].addr); value = le32_to_cpu(inits[i].value); if (size == 2) - W_REG((u16 __iomem *)addr, value); + bcma_write16(core, offset, value); else if (size == 4) - W_REG((u32 __iomem *)addr, value); + bcma_write32(core, offset, value); else break; } @@ -788,10 +787,12 @@ static u32 brcms_c_setband_inact(struct brcms_c_info *wlc, uint bandunit) { struct brcms_hardware *wlc_hw = wlc->hw; u32 macintmask; + u32 macctrl; BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); - - WARN_ON((R_REG(&wlc_hw->regs->maccontrol) & MCTL_EN_MAC) != 0); + macctrl = bcma_read32(wlc_hw->d11core, + D11REGOFFS(maccontrol)); + WARN_ON((macctrl & MCTL_EN_MAC) != 0); /* disable interrupts */ macintmask = brcms_intrsoff(wlc->wl); @@ -982,7 +983,7 @@ brcms_b_txstatus(struct brcms_hardware *wlc_hw, bool bound, bool *fatal) { bool morepending = false; struct brcms_c_info *wlc = wlc_hw->wlc; - struct d11regs __iomem *regs; + struct bcma_device *core; struct tx_status txstatus, *txs; u32 s1, s2; uint n = 0; @@ -995,18 +996,18 @@ brcms_b_txstatus(struct brcms_hardware *wlc_hw, bool bound, bool *fatal) BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); txs = &txstatus; - regs = wlc_hw->regs; + core = wlc_hw->d11core; *fatal = false; + s1 = bcma_read32(core, D11REGOFFS(frmtxstatus)); while (!(*fatal) - && (s1 = R_REG(®s->frmtxstatus)) & TXS_V) { + && (s1 & TXS_V)) { if (s1 == 0xffffffff) { wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit, __func__); return morepending; } - - s2 = R_REG(®s->frmtxstatus2); + s2 = bcma_read32(core, D11REGOFFS(frmtxstatus2)); txs->status = s1 & TXS_STATUS_MASK; txs->frameid = (s1 & TXS_FID_MASK) >> TXS_FID_SHIFT; @@ -1019,6 +1020,7 @@ brcms_b_txstatus(struct brcms_hardware *wlc_hw, bool bound, bool *fatal) /* !give others some time to run! */ if (++n >= max_tx_num) break; + s1 = bcma_read32(core, D11REGOFFS(frmtxstatus)); } if (*fatal) @@ -1066,9 +1068,11 @@ brcms_c_mhfdef(struct brcms_c_info *wlc, u16 *mhfs, u16 mhf2_init) static struct dma64regs __iomem * dmareg(struct brcms_hardware *hw, uint direction, uint fifonum) { + struct d11regs __iomem *regs = hw->d11core->bus->mmio; + if (direction == DMA_TX) - return &(hw->regs->fifo64regs[fifonum].dmaxmt); - return &(hw->regs->fifo64regs[fifonum].dmarcv); + return &(regs->fifo64regs[fifonum].dmaxmt); + return &(regs->fifo64regs[fifonum].dmarcv); } static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) @@ -1214,29 +1218,33 @@ static void brcms_b_clkctl_clk(struct brcms_hardware *wlc_hw, uint mode) if (wlc_hw->clk) { if (mode == CLK_FAST) { - OR_REG(&wlc_hw->regs->clk_ctl_st, - CCS_FORCEHT); + bcma_set32(wlc_hw->d11core, + D11REGOFFS(clk_ctl_st), + CCS_FORCEHT); udelay(64); - SPINWAIT(((R_REG - (&wlc_hw->regs-> - clk_ctl_st) & CCS_HTAVAIL) == 0), - PMU_MAX_TRANSITION_DLY); - WARN_ON(!(R_REG - (&wlc_hw->regs-> - clk_ctl_st) & CCS_HTAVAIL)); + SPINWAIT( + ((bcma_read32(wlc_hw->d11core, + D11REGOFFS(clk_ctl_st)) & + CCS_HTAVAIL) == 0), + PMU_MAX_TRANSITION_DLY); + WARN_ON(!(bcma_read32(wlc_hw->d11core, + D11REGOFFS(clk_ctl_st)) & + CCS_HTAVAIL)); } else { if ((ai_get_pmurev(wlc_hw->sih) == 0) && - (R_REG - (&wlc_hw->regs-> - clk_ctl_st) & (CCS_FORCEHT | CCS_HTAREQ))) - SPINWAIT(((R_REG - (&wlc_hw->regs-> - clk_ctl_st) & CCS_HTAVAIL) - == 0), - PMU_MAX_TRANSITION_DLY); - AND_REG(&wlc_hw->regs->clk_ctl_st, + (bcma_read32(wlc_hw->d11core, + D11REGOFFS(clk_ctl_st)) & + (CCS_FORCEHT | CCS_HTAREQ))) + SPINWAIT( + ((bcma_read32(wlc_hw->d11core, + offsetof(struct d11regs, + clk_ctl_st)) & + CCS_HTAVAIL) == 0), + PMU_MAX_TRANSITION_DLY); + bcma_mask32(wlc_hw->d11core, + D11REGOFFS(clk_ctl_st), ~CCS_FORCEHT); } } @@ -1368,7 +1376,8 @@ static void brcms_c_mctrl_write(struct brcms_hardware *wlc_hw) maccontrol |= MCTL_INFRA; } - W_REG(&wlc_hw->regs->maccontrol, maccontrol); + bcma_write32(wlc_hw->d11core, D11REGOFFS(maccontrol), + maccontrol); } /* set or clear maccontrol bits */ @@ -1462,7 +1471,7 @@ static void brcms_b_set_addrmatch(struct brcms_hardware *wlc_hw, int match_reg_offset, const u8 *addr) { - struct d11regs __iomem *regs; + struct bcma_device *core = wlc_hw->d11core; u16 mac_l; u16 mac_m; u16 mac_h; @@ -1470,38 +1479,36 @@ brcms_b_set_addrmatch(struct brcms_hardware *wlc_hw, int match_reg_offset, BCMMSG(wlc_hw->wlc->wiphy, "wl%d: brcms_b_set_addrmatch\n", wlc_hw->unit); - regs = wlc_hw->regs; mac_l = addr[0] | (addr[1] << 8); mac_m = addr[2] | (addr[3] << 8); mac_h = addr[4] | (addr[5] << 8); /* enter the MAC addr into the RXE match registers */ - W_REG(®s->rcm_ctl, RCM_INC_DATA | match_reg_offset); - W_REG(®s->rcm_mat_data, mac_l); - W_REG(®s->rcm_mat_data, mac_m); - W_REG(®s->rcm_mat_data, mac_h); - + bcma_write16(core, D11REGOFFS(rcm_ctl), + RCM_INC_DATA | match_reg_offset); + bcma_write16(core, D11REGOFFS(rcm_mat_data), mac_l); + bcma_write16(core, D11REGOFFS(rcm_mat_data), mac_m); + bcma_write16(core, D11REGOFFS(rcm_mat_data), mac_h); } void brcms_b_write_template_ram(struct brcms_hardware *wlc_hw, int offset, int len, void *buf) { - struct d11regs __iomem *regs; + struct bcma_device *core = wlc_hw->d11core; u32 word; __le32 word_le; __be32 word_be; bool be_bit; BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - regs = wlc_hw->regs; - W_REG(®s->tplatewrptr, offset); + bcma_write32(core, D11REGOFFS(tplatewrptr), offset); /* if MCTL_BIGEND bit set in mac control register, * the chip swaps data in fifo, as well as data in * template ram */ - be_bit = (R_REG(®s->maccontrol) & MCTL_BIGEND) != 0; + be_bit = (bcma_read32(core, D11REGOFFS(maccontrol)) & MCTL_BIGEND) != 0; while (len > 0) { memcpy(&word, buf, sizeof(u32)); @@ -1514,7 +1521,7 @@ brcms_b_write_template_ram(struct brcms_hardware *wlc_hw, int offset, int len, word = *(u32 *)&word_le; } - W_REG(®s->tplatewrdata, word); + bcma_write32(core, D11REGOFFS(tplatewrdata), word); buf = (u8 *) buf + sizeof(u32); len -= sizeof(u32); @@ -1525,18 +1532,20 @@ static void brcms_b_set_cwmin(struct brcms_hardware *wlc_hw, u16 newmin) { wlc_hw->band->CWmin = newmin; - W_REG(&wlc_hw->regs->objaddr, OBJADDR_SCR_SEL | S_DOT11_CWMIN); - (void)R_REG(&wlc_hw->regs->objaddr); - W_REG(&wlc_hw->regs->objdata, newmin); + bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), + OBJADDR_SCR_SEL | S_DOT11_CWMIN); + (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); + bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), newmin); } static void brcms_b_set_cwmax(struct brcms_hardware *wlc_hw, u16 newmax) { wlc_hw->band->CWmax = newmax; - W_REG(&wlc_hw->regs->objaddr, OBJADDR_SCR_SEL | S_DOT11_CWMAX); - (void)R_REG(&wlc_hw->regs->objaddr); - W_REG(&wlc_hw->regs->objdata, newmax); + bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), + OBJADDR_SCR_SEL | S_DOT11_CWMAX); + (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); + bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), newmax); } void brcms_b_bw_set(struct brcms_hardware *wlc_hw, u16 bw) @@ -1815,7 +1824,8 @@ static void brcms_b_setband(struct brcms_hardware *wlc_hw, uint bandunit, brcms_intrsrestore(wlc->wl, macintmask); /* ucode should still be suspended.. */ - WARN_ON((R_REG(&wlc_hw->regs->maccontrol) & MCTL_EN_MAC) != 0); + WARN_ON((bcma_read32(wlc_hw->d11core, D11REGOFFS(maccontrol)) & + MCTL_EN_MAC) != 0); } static bool brcms_c_isgoodchip(struct brcms_hardware *wlc_hw) @@ -1937,13 +1947,14 @@ static bool brcms_b_radio_read_hwdisabled(struct brcms_hardware *wlc_hw) */ if ((ai_get_chip_id(wlc_hw->sih) == BCM43224_CHIP_ID) || (ai_get_chip_id(wlc_hw->sih) == BCM43225_CHIP_ID)) - wlc_hw->regs = (struct d11regs __iomem *) - ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); + (void)ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); + ai_core_reset(wlc_hw->sih, flags, resetbits); brcms_c_mctrl_reset(wlc_hw); } - v = ((R_REG(&wlc_hw->regs->phydebug) & PDBG_RFD) != 0); + v = ((bcma_read32(wlc_hw->d11core, + D11REGOFFS(phydebug)) & PDBG_RFD) != 0); /* put core back into reset */ if (!clk) @@ -1971,7 +1982,6 @@ static bool wlc_dma_rxreset(struct brcms_hardware *wlc_hw, uint fifo) */ void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags) { - struct d11regs __iomem *regs; uint i; bool fastclk; u32 resetbits = 0; @@ -1981,8 +1991,6 @@ void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags) BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - regs = wlc_hw->regs; - /* request FAST clock if not on */ fastclk = wlc_hw->forcefastclk; if (!fastclk) @@ -2055,7 +2063,7 @@ void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags) */ static void brcms_b_corerev_fifofixup(struct brcms_hardware *wlc_hw) { - struct d11regs __iomem *regs = wlc_hw->regs; + struct bcma_device *core = wlc_hw->d11core; u16 fifo_nu; u16 txfifo_startblk = TXFIFO_START_BLK, txfifo_endblk; u16 txfifo_def, txfifo_def1; @@ -2076,11 +2084,11 @@ static void brcms_b_corerev_fifofixup(struct brcms_hardware *wlc_hw) txfifo_cmd = TXFIFOCMD_RESET_MASK | (fifo_nu << TXFIFOCMD_FIFOSEL_SHIFT); - W_REG(®s->xmtfifocmd, txfifo_cmd); - W_REG(®s->xmtfifodef, txfifo_def); - W_REG(®s->xmtfifodef1, txfifo_def1); + bcma_write16(core, D11REGOFFS(xmtfifocmd), txfifo_cmd); + bcma_write16(core, D11REGOFFS(xmtfifodef), txfifo_def); + bcma_write16(core, D11REGOFFS(xmtfifodef1), txfifo_def1); - W_REG(®s->xmtfifocmd, txfifo_cmd); + bcma_write16(core, D11REGOFFS(xmtfifocmd), txfifo_cmd); txfifo_startblk += wlc_hw->xmtfifo_sz[fifo_nu]; } @@ -2115,27 +2123,27 @@ static void brcms_b_corerev_fifofixup(struct brcms_hardware *wlc_hw) void brcms_b_switch_macfreq(struct brcms_hardware *wlc_hw, u8 spurmode) { - struct d11regs __iomem *regs = wlc_hw->regs; + struct bcma_device *core = wlc_hw->d11core; if ((ai_get_chip_id(wlc_hw->sih) == BCM43224_CHIP_ID) || (ai_get_chip_id(wlc_hw->sih) == BCM43225_CHIP_ID)) { if (spurmode == WL_SPURAVOID_ON2) { /* 126Mhz */ - W_REG(®s->tsf_clk_frac_l, 0x2082); - W_REG(®s->tsf_clk_frac_h, 0x8); + bcma_write16(core, D11REGOFFS(tsf_clk_frac_l), 0x2082); + bcma_write16(core, D11REGOFFS(tsf_clk_frac_h), 0x8); } else if (spurmode == WL_SPURAVOID_ON1) { /* 123Mhz */ - W_REG(®s->tsf_clk_frac_l, 0x5341); - W_REG(®s->tsf_clk_frac_h, 0x8); + bcma_write16(core, D11REGOFFS(tsf_clk_frac_l), 0x5341); + bcma_write16(core, D11REGOFFS(tsf_clk_frac_h), 0x8); } else { /* 120Mhz */ - W_REG(®s->tsf_clk_frac_l, 0x8889); - W_REG(®s->tsf_clk_frac_h, 0x8); + bcma_write16(core, D11REGOFFS(tsf_clk_frac_l), 0x8889); + bcma_write16(core, D11REGOFFS(tsf_clk_frac_h), 0x8); } } else if (BRCMS_ISLCNPHY(wlc_hw->band)) { if (spurmode == WL_SPURAVOID_ON1) { /* 82Mhz */ - W_REG(®s->tsf_clk_frac_l, 0x7CE0); - W_REG(®s->tsf_clk_frac_h, 0xC); + bcma_write16(core, D11REGOFFS(tsf_clk_frac_l), 0x7CE0); + bcma_write16(core, D11REGOFFS(tsf_clk_frac_h), 0xC); } else { /* 80Mhz */ - W_REG(®s->tsf_clk_frac_l, 0xCCCD); - W_REG(®s->tsf_clk_frac_h, 0xC); + bcma_write16(core, D11REGOFFS(tsf_clk_frac_l), 0xCCCD); + bcma_write16(core, D11REGOFFS(tsf_clk_frac_h), 0xC); } } } @@ -2144,11 +2152,8 @@ void brcms_b_switch_macfreq(struct brcms_hardware *wlc_hw, u8 spurmode) static void brcms_c_gpio_init(struct brcms_c_info *wlc) { struct brcms_hardware *wlc_hw = wlc->hw; - struct d11regs __iomem *regs; u32 gc, gm; - regs = wlc_hw->regs; - /* use GPIO select 0 to get all gpio signals from the gpio out reg */ brcms_b_mctrl(wlc_hw, MCTL_GPOUT_SEL_MASK, 0); @@ -2179,10 +2184,10 @@ static void brcms_c_gpio_init(struct brcms_c_info *wlc) * The board itself is powered by these GPIOs * (when not sending pattern) so set them high */ - OR_REG(®s->psm_gpio_oe, - (BOARD_GPIO_12 | BOARD_GPIO_13)); - OR_REG(®s->psm_gpio_out, - (BOARD_GPIO_12 | BOARD_GPIO_13)); + bcma_set16(wlc_hw->d11core, D11REGOFFS(psm_gpio_oe), + (BOARD_GPIO_12 | BOARD_GPIO_13)); + bcma_set16(wlc_hw->d11core, D11REGOFFS(psm_gpio_out), + (BOARD_GPIO_12 | BOARD_GPIO_13)); /* Enable antenna diversity, use 2x4 mode */ brcms_b_mhf(wlc_hw, MHF3, MHF3_ANTSEL_EN, @@ -2209,7 +2214,7 @@ static void brcms_c_gpio_init(struct brcms_c_info *wlc) static void brcms_ucode_write(struct brcms_hardware *wlc_hw, const __le32 ucode[], const size_t nbytes) { - struct d11regs __iomem *regs = wlc_hw->regs; + struct bcma_device *core = wlc_hw->d11core; uint i; uint count; @@ -2217,10 +2222,11 @@ static void brcms_ucode_write(struct brcms_hardware *wlc_hw, count = (nbytes / sizeof(u32)); - W_REG(®s->objaddr, (OBJADDR_AUTO_INC | OBJADDR_UCM_SEL)); - (void)R_REG(®s->objaddr); + bcma_write32(core, D11REGOFFS(objaddr), + OBJADDR_AUTO_INC | OBJADDR_UCM_SEL); + (void)bcma_read32(core, D11REGOFFS(objaddr)); for (i = 0; i < count; i++) - W_REG(®s->objdata, le32_to_cpu(ucode[i])); + bcma_write32(core, D11REGOFFS(objdata), le32_to_cpu(ucode[i])); } @@ -2286,7 +2292,7 @@ static void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw) bool fatal = false; uint unit; uint intstatus, idx; - struct d11regs __iomem *regs = wlc_hw->regs; + struct bcma_device *core = wlc_hw->d11core; struct wiphy *wiphy = wlc_hw->wlc->wiphy; unit = wlc_hw->unit; @@ -2294,7 +2300,9 @@ static void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw) for (idx = 0; idx < NFIFO; idx++) { /* read intstatus register and ignore any non-error bits */ intstatus = - R_REG(®s->intctrlregs[idx].intstatus) & I_ERRORS; + bcma_read32(core, + D11REGOFFS(intctrlregs[idx].intstatus)) & + I_ERRORS; if (!intstatus) continue; @@ -2339,8 +2347,9 @@ static void brcms_b_fifoerrors(struct brcms_hardware *wlc_hw) brcms_fatal_error(wlc_hw->wlc->wl); /* big hammer */ break; } else - W_REG(®s->intctrlregs[idx].intstatus, - intstatus); + bcma_write32(core, + D11REGOFFS(intctrlregs[idx].intstatus), + intstatus); } } @@ -2348,7 +2357,7 @@ void brcms_c_intrson(struct brcms_c_info *wlc) { struct brcms_hardware *wlc_hw = wlc->hw; wlc->macintmask = wlc->defmacintmask; - W_REG(&wlc_hw->regs->macintmask, wlc->macintmask); + bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), wlc->macintmask); } /* @@ -2382,8 +2391,8 @@ u32 brcms_c_intrsoff(struct brcms_c_info *wlc) macintmask = wlc->macintmask; /* isr can still happen */ - W_REG(&wlc_hw->regs->macintmask, 0); - (void)R_REG(&wlc_hw->regs->macintmask); /* sync readback */ + bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), 0); + (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(macintmask)); udelay(1); /* ensure int line is no longer driven */ wlc->macintmask = 0; @@ -2398,7 +2407,7 @@ void brcms_c_intrsrestore(struct brcms_c_info *wlc, u32 macintmask) return; wlc->macintmask = macintmask; - W_REG(&wlc_hw->regs->macintmask, wlc->macintmask); + bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), wlc->macintmask); } /* assumes that the d11 MAC is enabled */ @@ -2510,11 +2519,11 @@ brcms_c_mute(struct brcms_c_info *wlc, bool mute_tx) static inline u32 wlc_intstatus(struct brcms_c_info *wlc, bool in_isr) { struct brcms_hardware *wlc_hw = wlc->hw; - struct d11regs __iomem *regs = wlc_hw->regs; + struct bcma_device *core = wlc_hw->d11core; u32 macintstatus; /* macintstatus includes a DMA interrupt summary bit */ - macintstatus = R_REG(®s->macintstatus); + macintstatus = bcma_read32(core, D11REGOFFS(macintstatus)); BCMMSG(wlc->wiphy, "wl%d: macintstatus: 0x%x\n", wlc_hw->unit, macintstatus); @@ -2541,12 +2550,12 @@ static inline u32 wlc_intstatus(struct brcms_c_info *wlc, bool in_isr) * consequences */ /* turn off the interrupts */ - W_REG(®s->macintmask, 0); - (void)R_REG(®s->macintmask); /* sync readback */ + bcma_write32(core, D11REGOFFS(macintmask), 0); + (void)bcma_read32(core, D11REGOFFS(macintmask)); wlc->macintmask = 0; /* clear device interrupts */ - W_REG(®s->macintstatus, macintstatus); + bcma_write32(core, D11REGOFFS(macintstatus), macintstatus); /* MI_DMAINT is indication of non-zero intstatus */ if (macintstatus & MI_DMAINT) @@ -2555,8 +2564,8 @@ static inline u32 wlc_intstatus(struct brcms_c_info *wlc, bool in_isr) * RX_FIFO. If MI_DMAINT is set, assume it * is set and clear the interrupt. */ - W_REG(®s->intctrlregs[RX_FIFO].intstatus, - DEF_RXINTMASK); + bcma_write32(core, D11REGOFFS(intctrlregs[RX_FIFO].intstatus), + DEF_RXINTMASK); return macintstatus; } @@ -2619,7 +2628,7 @@ bool brcms_c_isr(struct brcms_c_info *wlc, bool *wantdpc) void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc) { struct brcms_hardware *wlc_hw = wlc->hw; - struct d11regs __iomem *regs = wlc_hw->regs; + struct bcma_device *core = wlc_hw->d11core; u32 mc, mi; struct wiphy *wiphy = wlc->wiphy; @@ -2636,7 +2645,7 @@ void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc) /* force the core awake */ brcms_c_ucode_wake_override_set(wlc_hw, BRCMS_WAKE_OVERRIDE_MACSUSPEND); - mc = R_REG(®s->maccontrol); + mc = bcma_read32(core, D11REGOFFS(maccontrol)); if (mc == 0xffffffff) { wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit, @@ -2648,7 +2657,7 @@ void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc) WARN_ON(!(mc & MCTL_PSM_RUN)); WARN_ON(!(mc & MCTL_EN_MAC)); - mi = R_REG(®s->macintstatus); + mi = bcma_read32(core, D11REGOFFS(macintstatus)); if (mi == 0xffffffff) { wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit, __func__); @@ -2659,21 +2668,21 @@ void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc) brcms_b_mctrl(wlc_hw, MCTL_EN_MAC, 0); - SPINWAIT(!(R_REG(®s->macintstatus) & MI_MACSSPNDD), + SPINWAIT(!(bcma_read32(core, D11REGOFFS(macintstatus)) & MI_MACSSPNDD), BRCMS_MAX_MAC_SUSPEND); - if (!(R_REG(®s->macintstatus) & MI_MACSSPNDD)) { + if (!(bcma_read32(core, D11REGOFFS(macintstatus)) & MI_MACSSPNDD)) { wiphy_err(wiphy, "wl%d: wlc_suspend_mac_and_wait: waited %d uS" " and MI_MACSSPNDD is still not on.\n", wlc_hw->unit, BRCMS_MAX_MAC_SUSPEND); wiphy_err(wiphy, "wl%d: psmdebug 0x%08x, phydebug 0x%08x, " "psm_brc 0x%04x\n", wlc_hw->unit, - R_REG(®s->psmdebug), - R_REG(®s->phydebug), - R_REG(®s->psm_brc)); + bcma_read32(core, D11REGOFFS(psmdebug)), + bcma_read32(core, D11REGOFFS(phydebug)), + bcma_read16(core, D11REGOFFS(psm_brc))); } - mc = R_REG(®s->maccontrol); + mc = bcma_read32(core, D11REGOFFS(maccontrol)); if (mc == 0xffffffff) { wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit, __func__); @@ -2688,7 +2697,7 @@ void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc) void brcms_c_enable_mac(struct brcms_c_info *wlc) { struct brcms_hardware *wlc_hw = wlc->hw; - struct d11regs __iomem *regs = wlc_hw->regs; + struct bcma_device *core = wlc_hw->d11core; u32 mc, mi; BCMMSG(wlc->wiphy, "wl%d: bandunit %d\n", wlc_hw->unit, @@ -2701,20 +2710,20 @@ void brcms_c_enable_mac(struct brcms_c_info *wlc) if (wlc_hw->mac_suspend_depth > 0) return; - mc = R_REG(®s->maccontrol); + mc = bcma_read32(core, D11REGOFFS(maccontrol)); WARN_ON(mc & MCTL_PSM_JMP_0); WARN_ON(mc & MCTL_EN_MAC); WARN_ON(!(mc & MCTL_PSM_RUN)); brcms_b_mctrl(wlc_hw, MCTL_EN_MAC, MCTL_EN_MAC); - W_REG(®s->macintstatus, MI_MACSSPNDD); + bcma_write32(core, D11REGOFFS(macintstatus), MI_MACSSPNDD); - mc = R_REG(®s->maccontrol); + mc = bcma_read32(core, D11REGOFFS(maccontrol)); WARN_ON(mc & MCTL_PSM_JMP_0); WARN_ON(!(mc & MCTL_EN_MAC)); WARN_ON(!(mc & MCTL_PSM_RUN)); - mi = R_REG(®s->macintstatus); + mi = bcma_read32(core, D11REGOFFS(macintstatus)); WARN_ON(mi & MI_MACSSPNDD); brcms_c_ucode_wake_override_clear(wlc_hw, @@ -2731,55 +2740,53 @@ void brcms_b_band_stf_ss_set(struct brcms_hardware *wlc_hw, u8 stf_mode) static bool brcms_b_validate_chip_access(struct brcms_hardware *wlc_hw) { - struct d11regs __iomem *regs; + struct bcma_device *core = wlc_hw->d11core; u32 w, val; struct wiphy *wiphy = wlc_hw->wlc->wiphy; BCMMSG(wiphy, "wl%d\n", wlc_hw->unit); - regs = wlc_hw->regs; - /* Validate dchip register access */ - W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); - (void)R_REG(®s->objaddr); - w = R_REG(®s->objdata); + bcma_write32(core, D11REGOFFS(objaddr), OBJADDR_SHM_SEL | 0); + (void)bcma_read32(core, D11REGOFFS(objaddr)); + w = bcma_read32(core, D11REGOFFS(objdata)); /* Can we write and read back a 32bit register? */ - W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); - (void)R_REG(®s->objaddr); - W_REG(®s->objdata, (u32) 0xaa5555aa); + bcma_write32(core, D11REGOFFS(objaddr), OBJADDR_SHM_SEL | 0); + (void)bcma_read32(core, D11REGOFFS(objaddr)); + bcma_write32(core, D11REGOFFS(objdata), (u32) 0xaa5555aa); - W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); - (void)R_REG(®s->objaddr); - val = R_REG(®s->objdata); + bcma_write32(core, D11REGOFFS(objaddr), OBJADDR_SHM_SEL | 0); + (void)bcma_read32(core, D11REGOFFS(objaddr)); + val = bcma_read32(core, D11REGOFFS(objdata)); if (val != (u32) 0xaa5555aa) { wiphy_err(wiphy, "wl%d: validate_chip_access: SHM = 0x%x, " "expected 0xaa5555aa\n", wlc_hw->unit, val); return false; } - W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); - (void)R_REG(®s->objaddr); - W_REG(®s->objdata, (u32) 0x55aaaa55); + bcma_write32(core, D11REGOFFS(objaddr), OBJADDR_SHM_SEL | 0); + (void)bcma_read32(core, D11REGOFFS(objaddr)); + bcma_write32(core, D11REGOFFS(objdata), (u32) 0x55aaaa55); - W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); - (void)R_REG(®s->objaddr); - val = R_REG(®s->objdata); + bcma_write32(core, D11REGOFFS(objaddr), OBJADDR_SHM_SEL | 0); + (void)bcma_read32(core, D11REGOFFS(objaddr)); + val = bcma_read32(core, D11REGOFFS(objdata)); if (val != (u32) 0x55aaaa55) { wiphy_err(wiphy, "wl%d: validate_chip_access: SHM = 0x%x, " "expected 0x55aaaa55\n", wlc_hw->unit, val); return false; } - W_REG(®s->objaddr, OBJADDR_SHM_SEL | 0); - (void)R_REG(®s->objaddr); - W_REG(®s->objdata, w); + bcma_write32(core, D11REGOFFS(objaddr), OBJADDR_SHM_SEL | 0); + (void)bcma_read32(core, D11REGOFFS(objaddr)); + bcma_write32(core, D11REGOFFS(objdata), w); /* clear CFPStart */ - W_REG(®s->tsf_cfpstart, 0); + bcma_write32(core, D11REGOFFS(tsf_cfpstart), 0); - w = R_REG(®s->maccontrol); + w = bcma_read32(core, D11REGOFFS(maccontrol)); if ((w != (MCTL_IHR_EN | MCTL_WAKE)) && (w != (MCTL_IHR_EN | MCTL_GMODE | MCTL_WAKE))) { wiphy_err(wiphy, "wl%d: validate_chip_access: maccontrol = " @@ -2796,38 +2803,38 @@ static bool brcms_b_validate_chip_access(struct brcms_hardware *wlc_hw) void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on) { - struct d11regs __iomem *regs; + struct bcma_device *core = wlc_hw->d11core; u32 tmp; BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); tmp = 0; - regs = wlc_hw->regs; if (on) { if ((ai_get_chip_id(wlc_hw->sih) == BCM4313_CHIP_ID)) { - OR_REG(®s->clk_ctl_st, - (CCS_ERSRC_REQ_HT | CCS_ERSRC_REQ_D11PLL | - CCS_ERSRC_REQ_PHYPLL)); - SPINWAIT((R_REG(®s->clk_ctl_st) & - (CCS_ERSRC_AVAIL_HT)) != (CCS_ERSRC_AVAIL_HT), + bcma_set32(core, D11REGOFFS(clk_ctl_st), + CCS_ERSRC_REQ_HT | + CCS_ERSRC_REQ_D11PLL | + CCS_ERSRC_REQ_PHYPLL); + SPINWAIT((bcma_read32(core, D11REGOFFS(clk_ctl_st)) & + CCS_ERSRC_AVAIL_HT) != CCS_ERSRC_AVAIL_HT, PHYPLL_WAIT_US); - tmp = R_REG(®s->clk_ctl_st); - if ((tmp & (CCS_ERSRC_AVAIL_HT)) != - (CCS_ERSRC_AVAIL_HT)) + tmp = bcma_read32(core, D11REGOFFS(clk_ctl_st)); + if ((tmp & CCS_ERSRC_AVAIL_HT) != CCS_ERSRC_AVAIL_HT) wiphy_err(wlc_hw->wlc->wiphy, "%s: turn on PHY" " PLL failed\n", __func__); } else { - OR_REG(®s->clk_ctl_st, - (CCS_ERSRC_REQ_D11PLL | CCS_ERSRC_REQ_PHYPLL)); - SPINWAIT((R_REG(®s->clk_ctl_st) & + bcma_set32(core, D11REGOFFS(clk_ctl_st), + tmp | CCS_ERSRC_REQ_D11PLL | + CCS_ERSRC_REQ_PHYPLL); + SPINWAIT((bcma_read32(core, D11REGOFFS(clk_ctl_st)) & (CCS_ERSRC_AVAIL_D11PLL | CCS_ERSRC_AVAIL_PHYPLL)) != (CCS_ERSRC_AVAIL_D11PLL | CCS_ERSRC_AVAIL_PHYPLL), PHYPLL_WAIT_US); - tmp = R_REG(®s->clk_ctl_st); + tmp = bcma_read32(core, D11REGOFFS(clk_ctl_st)); if ((tmp & (CCS_ERSRC_AVAIL_D11PLL | CCS_ERSRC_AVAIL_PHYPLL)) != @@ -2841,8 +2848,9 @@ void brcms_b_core_phypll_ctl(struct brcms_hardware *wlc_hw, bool on) * be requesting it; so we'll deassert the request but * not wait for status to comply. */ - AND_REG(®s->clk_ctl_st, ~CCS_ERSRC_REQ_PHYPLL); - tmp = R_REG(®s->clk_ctl_st); + bcma_mask32(core, D11REGOFFS(clk_ctl_st), + ~CCS_ERSRC_REQ_PHYPLL); + (void)bcma_read32(core, D11REGOFFS(clk_ctl_st)); } } @@ -2894,35 +2902,31 @@ static void brcms_c_flushqueues(struct brcms_c_info *wlc) static u16 brcms_b_read_objmem(struct brcms_hardware *wlc_hw, uint offset, u32 sel) { - struct d11regs __iomem *regs = wlc_hw->regs; - u16 __iomem *objdata_lo = (u16 __iomem *)®s->objdata; - u16 __iomem *objdata_hi = objdata_lo + 1; - u16 v; + struct bcma_device *core = wlc_hw->d11core; + u16 objoff = D11REGOFFS(objdata); - W_REG(®s->objaddr, sel | (offset >> 2)); - (void)R_REG(®s->objaddr); + bcma_write32(core, D11REGOFFS(objaddr), sel | (offset >> 2)); + (void)bcma_read32(core, D11REGOFFS(objaddr)); if (offset & 2) - v = R_REG(objdata_hi); - else - v = R_REG(objdata_lo); + objoff += 2; - return v; + return bcma_read16(core, objoff); +; } static void brcms_b_write_objmem(struct brcms_hardware *wlc_hw, uint offset, u16 v, u32 sel) { - struct d11regs __iomem *regs = wlc_hw->regs; - u16 __iomem *objdata_lo = (u16 __iomem *)®s->objdata; - u16 __iomem *objdata_hi = objdata_lo + 1; + struct bcma_device *core = wlc_hw->d11core; + u16 objoff = D11REGOFFS(objdata); - W_REG(®s->objaddr, sel | (offset >> 2)); - (void)R_REG(®s->objaddr); + bcma_write32(core, D11REGOFFS(objaddr), sel | (offset >> 2)); + (void)bcma_read32(core, D11REGOFFS(objaddr)); if (offset & 2) - W_REG(objdata_hi, v); - else - W_REG(objdata_lo, v); + objoff += 2; + + bcma_write16(core, objoff, v); } /* @@ -3008,14 +3012,14 @@ static void brcms_b_retrylimit_upd(struct brcms_hardware *wlc_hw, /* write retry limit to SCR, shouldn't need to suspend */ if (wlc_hw->up) { - W_REG(&wlc_hw->regs->objaddr, - OBJADDR_SCR_SEL | S_DOT11_SRC_LMT); - (void)R_REG(&wlc_hw->regs->objaddr); - W_REG(&wlc_hw->regs->objdata, wlc_hw->SRL); - W_REG(&wlc_hw->regs->objaddr, - OBJADDR_SCR_SEL | S_DOT11_LRC_LMT); - (void)R_REG(&wlc_hw->regs->objaddr); - W_REG(&wlc_hw->regs->objdata, wlc_hw->LRL); + bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), + OBJADDR_SCR_SEL | S_DOT11_SRC_LMT); + (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); + bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), wlc_hw->SRL); + bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), + OBJADDR_SCR_SEL | S_DOT11_LRC_LMT); + (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); + bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), wlc_hw->LRL); } } @@ -3197,9 +3201,9 @@ void brcms_c_init_scb(struct scb *scb) static void brcms_b_coreinit(struct brcms_c_info *wlc) { struct brcms_hardware *wlc_hw = wlc->hw; - struct d11regs __iomem *regs; + struct bcma_device *core = wlc_hw->d11core; u32 sflags; - uint bcnint_us; + u32 bcnint_us; uint i = 0; bool fifosz_fixup = false; int err = 0; @@ -3207,8 +3211,6 @@ static void brcms_b_coreinit(struct brcms_c_info *wlc) struct wiphy *wiphy = wlc->wiphy; struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; - regs = wlc_hw->regs; - BCMMSG(wlc->wiphy, "wl%d\n", wlc_hw->unit); /* reset PSM */ @@ -3221,14 +3223,14 @@ static void brcms_b_coreinit(struct brcms_c_info *wlc) fifosz_fixup = true; /* let the PSM run to the suspended state, set mode to BSS STA */ - W_REG(®s->macintstatus, -1); + bcma_write32(core, D11REGOFFS(macintstatus), -1); brcms_b_mctrl(wlc_hw, ~0, (MCTL_IHR_EN | MCTL_INFRA | MCTL_PSM_RUN | MCTL_WAKE)); /* wait for ucode to self-suspend after auto-init */ - SPINWAIT(((R_REG(®s->macintstatus) & MI_MACSSPNDD) == 0), - 1000 * 1000); - if ((R_REG(®s->macintstatus) & MI_MACSSPNDD) == 0) + SPINWAIT(((bcma_read32(core, D11REGOFFS(macintstatus)) & + MI_MACSSPNDD) == 0), 1000 * 1000); + if ((bcma_read32(core, D11REGOFFS(macintstatus)) & MI_MACSSPNDD) == 0) wiphy_err(wiphy, "wl%d: wlc_coreinit: ucode did not self-" "suspend!\n", wlc_hw->unit); @@ -3298,7 +3300,7 @@ static void brcms_b_coreinit(struct brcms_c_info *wlc) wlc_hw->xmtfifo_sz[i], i); /* make sure we can still talk to the mac */ - WARN_ON(R_REG(®s->maccontrol) == 0xffffffff); + WARN_ON(bcma_read32(core, D11REGOFFS(maccontrol)) == 0xffffffff); /* band-specific inits done by wlc_bsinit() */ @@ -3307,7 +3309,7 @@ static void brcms_b_coreinit(struct brcms_c_info *wlc) brcms_b_write_shm(wlc_hw, M_MAX_ANTCNT, ANTCNT); /* enable one rx interrupt per received frame */ - W_REG(®s->intrcvlazy[0], (1 << IRL_FC_SHIFT)); + bcma_write32(core, D11REGOFFS(intrcvlazy[0]), (1 << IRL_FC_SHIFT)); /* set the station mode (BSS STA) */ brcms_b_mctrl(wlc_hw, @@ -3316,19 +3318,21 @@ static void brcms_b_coreinit(struct brcms_c_info *wlc) /* set up Beacon interval */ bcnint_us = 0x8000 << 10; - W_REG(®s->tsf_cfprep, (bcnint_us << CFPREP_CBI_SHIFT)); - W_REG(®s->tsf_cfpstart, bcnint_us); - W_REG(®s->macintstatus, MI_GP1); + bcma_write32(core, D11REGOFFS(tsf_cfprep), + (bcnint_us << CFPREP_CBI_SHIFT)); + bcma_write32(core, D11REGOFFS(tsf_cfpstart), bcnint_us); + bcma_write32(core, D11REGOFFS(macintstatus), MI_GP1); /* write interrupt mask */ - W_REG(®s->intctrlregs[RX_FIFO].intmask, DEF_RXINTMASK); + bcma_write32(core, D11REGOFFS(intctrlregs[RX_FIFO].intmask), + DEF_RXINTMASK); /* allow the MAC to control the PHY clock (dynamic on/off) */ brcms_b_macphyclk_set(wlc_hw, ON); /* program dynamic clock control fast powerup delay register */ wlc->fastpwrup_dly = ai_clkctl_fast_pwrup_delay(wlc_hw->sih); - W_REG(®s->scc_fastpwrup_dly, wlc->fastpwrup_dly); + bcma_write16(core, D11REGOFFS(scc_fastpwrup_dly), wlc->fastpwrup_dly); /* tell the ucode the corerev */ brcms_b_write_shm(wlc_hw, M_MACHW_VER, (u16) wlc_hw->corerev); @@ -3341,19 +3345,21 @@ static void brcms_b_coreinit(struct brcms_c_info *wlc) machwcap >> 16) & 0xffff)); /* write retry limits to SCR, this done after PSM init */ - W_REG(®s->objaddr, OBJADDR_SCR_SEL | S_DOT11_SRC_LMT); - (void)R_REG(®s->objaddr); - W_REG(®s->objdata, wlc_hw->SRL); - W_REG(®s->objaddr, OBJADDR_SCR_SEL | S_DOT11_LRC_LMT); - (void)R_REG(®s->objaddr); - W_REG(®s->objdata, wlc_hw->LRL); + bcma_write32(core, D11REGOFFS(objaddr), + OBJADDR_SCR_SEL | S_DOT11_SRC_LMT); + (void)bcma_read32(core, D11REGOFFS(objaddr)); + bcma_write32(core, D11REGOFFS(objdata), wlc_hw->SRL); + bcma_write32(core, D11REGOFFS(objaddr), + OBJADDR_SCR_SEL | S_DOT11_LRC_LMT); + (void)bcma_read32(core, D11REGOFFS(objaddr)); + bcma_write32(core, D11REGOFFS(objdata), wlc_hw->LRL); /* write rate fallback retry limits */ brcms_b_write_shm(wlc_hw, M_SFRMTXCNTFBRTHSD, wlc_hw->SFBL); brcms_b_write_shm(wlc_hw, M_LFRMTXCNTFBRTHSD, wlc_hw->LFBL); - AND_REG(®s->ifs_ctl, 0x0FFF); - W_REG(®s->ifs_aifsn, EDCF_AIFSN_MIN); + bcma_mask16(core, D11REGOFFS(ifs_ctl), 0x0FFF); + bcma_write16(core, D11REGOFFS(ifs_aifsn), EDCF_AIFSN_MIN); /* init the tx dma engines */ for (i = 0; i < NFIFO; i++) { @@ -3810,7 +3816,7 @@ static void brcms_c_set_ps_ctrl(struct brcms_c_info *wlc) BCMMSG(wlc->wiphy, "wl%d: hps %d\n", wlc->pub->unit, hps); - v1 = R_REG(&wlc->regs->maccontrol); + v1 = bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol)); v2 = MCTL_WAKE; if (hps) v2 |= MCTL_HPS; @@ -4129,7 +4135,8 @@ void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci, acp_shm.cwmax = params->cw_max; acp_shm.cwcur = acp_shm.cwmin; acp_shm.bslots = - R_REG(&wlc->regs->tsf_random) & acp_shm.cwcur; + bcma_read16(wlc->hw->d11core, D11REGOFFS(tsf_random)) & + acp_shm.cwcur; acp_shm.reggap = acp_shm.bslots + acp_shm.aifs; /* Indicate the new params to the ucode */ acp_shm.status = brcms_b_read_shm(wlc->hw, (M_EDCF_QINFO + @@ -4441,7 +4448,6 @@ static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core, uint unit, bool piomode) { struct brcms_hardware *wlc_hw; - struct d11regs __iomem *regs; char *macaddr = NULL; uint err = 0; uint j; @@ -4490,13 +4496,9 @@ static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core, wlc_hw->deviceid = pcidev->device; /* set bar0 window to point at D11 core */ - wlc_hw->regs = (struct d11regs __iomem *) - ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); - wlc_hw->corerev = ai_corerev(wlc_hw->sih); - - regs = wlc_hw->regs; - - wlc->regs = wlc_hw->regs; + (void)ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); + wlc_hw->d11core = core; + wlc_hw->corerev = core->id.rev; /* validate chip, chiprev and corerev */ if (!brcms_c_isgoodchip(wlc_hw)) { @@ -4617,7 +4619,7 @@ static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core, wlc->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; wlc->core->coreidx = ai_coreidx(wlc_hw->sih); - wlc_hw->machwcap = R_REG(®s->machwcap); + wlc_hw->machwcap = bcma_read32(core, D11REGOFFS(machwcap)); wlc_hw->machwcap_backup = wlc_hw->machwcap; /* init tx fifo size */ @@ -4626,7 +4628,7 @@ static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core, /* Get a phy for this band */ wlc_hw->band->pi = - wlc_phy_attach(wlc_hw->phy_sh, regs, + wlc_phy_attach(wlc_hw->phy_sh, core->bus->mmio, wlc_hw->band->bandtype, wlc->wiphy); if (wlc_hw->band->pi == NULL) { @@ -5074,8 +5076,7 @@ static void brcms_b_hw_up(struct brcms_hardware *wlc_hw) */ if ((ai_get_chip_id(wlc_hw->sih) == BCM43224_CHIP_ID) || (ai_get_chip_id(wlc_hw->sih) == BCM43225_CHIP_ID)) - wlc_hw->regs = (struct d11regs __iomem *) - ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); + (void)ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); /* * Inform phy that a POR reset has occurred so @@ -5320,8 +5321,8 @@ static int brcms_b_down_finish(struct brcms_hardware *wlc_hw) /* Reset and disable the core */ if (ai_iscoreup(wlc_hw->sih)) { - if (R_REG(&wlc_hw->regs->maccontrol) & - MCTL_EN_MAC) + if (bcma_read32(wlc_hw->d11core, + D11REGOFFS(maccontrol)) & MCTL_EN_MAC) brcms_c_suspend_mac_and_wait(wlc_hw->wlc); callbacks += brcms_reset(wlc_hw->wlc->wl); brcms_c_coredisable(wlc_hw); @@ -7478,11 +7479,11 @@ static void brcms_b_read_tsf(struct brcms_hardware *wlc_hw, u32 *tsf_l_ptr, u32 *tsf_h_ptr) { - struct d11regs __iomem *regs = wlc_hw->regs; + struct bcma_device *core = wlc_hw->d11core; /* read the tsf timer low, then high to get an atomic read */ - *tsf_l_ptr = R_REG(®s->tsf_timerlow); - *tsf_h_ptr = R_REG(®s->tsf_timerhigh); + *tsf_l_ptr = bcma_read32(core, D11REGOFFS(tsf_timerlow)); + *tsf_h_ptr = bcma_read32(core, D11REGOFFS(tsf_timerhigh)); } /* @@ -8155,7 +8156,7 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) { u32 macintstatus; struct brcms_hardware *wlc_hw = wlc->hw; - struct d11regs __iomem *regs = wlc_hw->regs; + struct bcma_device *core = wlc_hw->d11core; struct wiphy *wiphy = wlc->wiphy; if (brcms_deviceremoved(wlc)) { @@ -8191,7 +8192,7 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) /* ATIM window end */ if (macintstatus & MI_ATIMWINEND) { BCMMSG(wlc->wiphy, "end of ATIM window\n"); - OR_REG(®s->maccommand, wlc->qvalid); + bcma_set32(core, D11REGOFFS(maccommand), wlc->qvalid); wlc->qvalid = 0; } @@ -8219,7 +8220,7 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) /* gptimer timeout */ if (macintstatus & MI_TO) - W_REG(®s->gptimer, 0); + bcma_write32(core, D11REGOFFS(gptimer), 0); if (macintstatus & MI_RFDISABLE) { BCMMSG(wlc->wiphy, "wl%d: BMAC Detected a change on the" @@ -8241,13 +8242,11 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx) { - struct d11regs __iomem *regs; + struct bcma_device *core = wlc->hw->d11core; u16 chanspec; BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); - regs = wlc->regs; - /* * This will happen if a big-hammer was executed. In * that case, we want to go back to the channel that @@ -8277,8 +8276,8 @@ void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx) * update since init path would reset * to default value */ - W_REG(®s->tsf_cfprep, - (bi << CFPREP_CBI_SHIFT)); + bcma_write32(core, D11REGOFFS(tsf_cfprep), + bi << CFPREP_CBI_SHIFT); /* Update maccontrol PM related bits */ brcms_c_set_ps_ctrl(wlc); @@ -8308,7 +8307,7 @@ void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx) brcms_c_bsinit(wlc); /* Enable EDCF mode (while the MAC is suspended) */ - OR_REG(®s->ifs_ctl, IFS_USEEDCF); + bcma_set16(core, D11REGOFFS(ifs_ctl), IFS_USEEDCF); brcms_c_edcf_setparams(wlc, false); /* Init precedence maps for empty FIFOs */ @@ -8332,7 +8331,7 @@ void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx) brcms_c_txflowcontrol_reset(wlc); /* enable the RF Disable Delay timer */ - W_REG(&wlc->regs->rfdisabledly, RFDISABLE_DEFAULT); + bcma_write32(core, D11REGOFFS(rfdisabledly), RFDISABLE_DEFAULT); /* * Initialize WME parameters; if they haven't been set by some other diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.h b/drivers/net/wireless/brcm80211/brcmsmac/main.h index e2de97d93635..adb136ec1f04 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.h @@ -334,7 +334,7 @@ struct brcms_hardware { u32 machwcap_backup; /* backup of machwcap */ struct si_pub *sih; /* SI handle (cookie for siutils calls) */ - struct d11regs __iomem *regs; /* pointer to device registers */ + struct bcma_device *d11core; /* pointer to 802.11 core */ struct phy_shim_info *physhim; /* phy shim layer handler */ struct shared_phy *phy_sh; /* pointer to shared phy state */ struct brcms_hw_band *band;/* pointer to active per-band state */ @@ -400,7 +400,6 @@ struct brcms_txq_info { * * pub: pointer to driver public state. * wl: pointer to specific private state. - * regs: pointer to device registers. * hw: HW related state. * clkreq_override: setting for clkreq for PCIE : Auto, 0, 1. * fastpwrup_dly: time in us needed to bring up d11 fast clock. @@ -477,7 +476,6 @@ struct brcms_txq_info { struct brcms_c_info { struct brcms_pub *pub; struct brcms_info *wl; - struct d11regs __iomem *regs; struct brcms_hardware *hw; /* clock */ -- cgit v1.2.3 From 2e81b9b19f20286425fed3b54df9b81189444cee Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 8 Dec 2011 15:06:52 -0800 Subject: brcm80211: smac: use DMA-API calls for descriptor allocations Using BCMA hides the specifics about the host interface. The driver is now using the DMA-API to do dma related calls. BCMA provides the device object to use in the DMA-API calls. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/dma.c | 47 ++++++++++++++------------ drivers/net/wireless/brcm80211/brcmsmac/dma.h | 10 +++--- drivers/net/wireless/brcm80211/brcmsmac/main.c | 8 ++--- 3 files changed, 35 insertions(+), 30 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/dma.c b/drivers/net/wireless/brcm80211/brcmsmac/dma.c index 3a60eb878ffa..0c5f31b044f9 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/dma.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/dma.c @@ -220,7 +220,8 @@ struct dma_info { uint *msg_level; /* message level pointer */ char name[MAXNAMEL]; /* callers name for diag msgs */ - struct pci_dev *pbus; /* bus handle */ + struct bcma_device *d11core; + struct device *dmadev; bool dma64; /* this dma engine is operating in 64-bit mode */ bool addrext; /* this dma engine supports DmaExtendedAddrChanges */ @@ -450,7 +451,7 @@ static bool _dma_descriptor_align(struct dma_info *di) * Descriptor table must start at the DMA hardware dictated alignment, so * allocated memory must be large enough to support this requirement. */ -static void *dma_alloc_consistent(struct pci_dev *pdev, uint size, +static void *dma_alloc_consistent(struct dma_info *di, uint size, u16 align_bits, uint *alloced, dma_addr_t *pap) { @@ -460,7 +461,7 @@ static void *dma_alloc_consistent(struct pci_dev *pdev, uint size, size += align; *alloced = size; } - return pci_alloc_consistent(pdev, size, pap); + return dma_alloc_coherent(di->dmadev, size, pap, GFP_ATOMIC); } static @@ -486,7 +487,7 @@ static void *dma_ringalloc(struct dma_info *di, u32 boundary, uint size, u32 desc_strtaddr; u32 alignbytes = 1 << *alignbits; - va = dma_alloc_consistent(di->pbus, size, *alignbits, alloced, descpa); + va = dma_alloc_consistent(di, size, *alignbits, alloced, descpa); if (NULL == va) return NULL; @@ -495,8 +496,8 @@ static void *dma_ringalloc(struct dma_info *di, u32 boundary, uint size, if (((desc_strtaddr + size - 1) & boundary) != (desc_strtaddr & boundary)) { *alignbits = dma_align_sizetobits(size); - pci_free_consistent(di->pbus, size, va, *descpa); - va = dma_alloc_consistent(di->pbus, size, *alignbits, + dma_free_coherent(di->dmadev, size, va, *descpa); + va = dma_alloc_consistent(di, size, *alignbits, alloced, descpa); } return va; @@ -556,10 +557,11 @@ static bool _dma_alloc(struct dma_info *di, uint direction) } struct dma_pub *dma_attach(char *name, struct si_pub *sih, - void __iomem *dmaregstx, void __iomem *dmaregsrx, - uint ntxd, uint nrxd, - uint rxbufsize, int rxextheadroom, - uint nrxpost, uint rxoffset, uint *msg_level) + struct bcma_device *d11core, + void __iomem *dmaregstx, void __iomem *dmaregsrx, + uint ntxd, uint nrxd, + uint rxbufsize, int rxextheadroom, + uint nrxpost, uint rxoffset, uint *msg_level) { struct dma_info *di; uint size; @@ -575,6 +577,7 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, di->dma64 = ((ai_core_sflags(sih, 0, 0) & SISF_DMA64) == SISF_DMA64); /* init dma reg pointer */ + di->d11core = d11core; di->d64txregs = (struct dma64regs __iomem *) dmaregstx; di->d64rxregs = (struct dma64regs __iomem *) dmaregsrx; @@ -594,7 +597,7 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, strncpy(di->name, name, MAXNAMEL); di->name[MAXNAMEL - 1] = '\0'; - di->pbus = ((struct si_info *)sih)->pcibus; + di->dmadev = d11core->dma_dev; /* save tunables */ di->ntxd = (u16) ntxd; @@ -749,13 +752,13 @@ void dma_detach(struct dma_pub *pub) /* free dma descriptor rings */ if (di->txd64) - pci_free_consistent(di->pbus, di->txdalloc, - ((s8 *)di->txd64 - di->txdalign), - (di->txdpaorig)); + dma_free_coherent(di->dmadev, di->txdalloc, + ((s8 *)di->txd64 - di->txdalign), + (di->txdpaorig)); if (di->rxd64) - pci_free_consistent(di->pbus, di->rxdalloc, - ((s8 *)di->rxd64 - di->rxdalign), - (di->rxdpaorig)); + dma_free_coherent(di->dmadev, di->rxdalloc, + ((s8 *)di->rxd64 - di->rxdalign), + (di->rxdpaorig)); /* free packet pointer vectors */ kfree(di->txp); @@ -882,7 +885,7 @@ static struct sk_buff *dma64_getnextrxp(struct dma_info *di, bool forceall) pa = le32_to_cpu(di->rxd64[i].addrlow) - di->dataoffsetlow; /* clear this packet from the descriptor ring */ - pci_unmap_single(di->pbus, pa, di->rxbufsize, PCI_DMA_FROMDEVICE); + dma_unmap_single(di->dmadev, pa, di->rxbufsize, DMA_FROM_DEVICE); di->rxd64[i].addrlow = cpu_to_le32(0xdeadbeef); di->rxd64[i].addrhigh = cpu_to_le32(0xdeadbeef); @@ -1048,8 +1051,8 @@ bool dma_rxfill(struct dma_pub *pub) */ *(u32 *) (p->data) = 0; - pa = pci_map_single(di->pbus, p->data, - di->rxbufsize, PCI_DMA_FROMDEVICE); + pa = dma_map_single(di->dmadev, p->data, di->rxbufsize, + DMA_FROM_DEVICE); /* save the free packet pointer */ di->rxp[rxout] = p; @@ -1267,7 +1270,7 @@ int dma_txfast(struct dma_pub *pub, struct sk_buff *p, bool commit) goto outoftxd; /* get physical address of buffer start */ - pa = pci_map_single(di->pbus, data, len, PCI_DMA_TODEVICE); + pa = dma_map_single(di->dmadev, data, len, DMA_TO_DEVICE); /* With a DMA segment list, Descriptor table is filled * using the segment list instead of looping over @@ -1376,7 +1379,7 @@ struct sk_buff *dma_getnexttxp(struct dma_pub *pub, enum txd_range range) txp = di->txp[i]; di->txp[i] = NULL; - pci_unmap_single(di->pbus, pa, size, PCI_DMA_TODEVICE); + dma_unmap_single(di->dmadev, pa, size, DMA_TO_DEVICE); } di->txin = i; diff --git a/drivers/net/wireless/brcm80211/brcmsmac/dma.h b/drivers/net/wireless/brcm80211/brcmsmac/dma.h index d317c7c12f91..2d59ad6ab8e0 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/dma.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/dma.h @@ -75,10 +75,12 @@ struct dma_pub { }; extern struct dma_pub *dma_attach(char *name, struct si_pub *sih, - void __iomem *dmaregstx, void __iomem *dmaregsrx, - uint ntxd, uint nrxd, - uint rxbufsize, int rxextheadroom, - uint nrxpost, uint rxoffset, uint *msg_level); + struct bcma_device *d11core, + void __iomem *dmaregstx, + void __iomem *dmaregsrx, + uint ntxd, uint nrxd, + uint rxbufsize, int rxextheadroom, + uint nrxpost, uint rxoffset, uint *msg_level); void dma_rxinit(struct dma_pub *pub); int dma_rx(struct dma_pub *pub, struct sk_buff_head *skb_list); diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index f4a64652fdab..f2491bdb1898 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -1098,7 +1098,7 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) * TX: TX_AC_BK_FIFO (TX AC Background data packets) * RX: RX_FIFO (RX data packets) */ - wlc_hw->di[0] = dma_attach(name, wlc_hw->sih, + wlc_hw->di[0] = dma_attach(name, wlc_hw->sih, wlc_hw->d11core, (wme ? dmareg(wlc_hw, DMA_TX, 0) : NULL), dmareg(wlc_hw, DMA_RX, 0), (wme ? NTXD : 0), NRXD, @@ -1112,7 +1112,7 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) * (legacy) TX_DATA_FIFO (TX data packets) * RX: UNUSED */ - wlc_hw->di[1] = dma_attach(name, wlc_hw->sih, + wlc_hw->di[1] = dma_attach(name, wlc_hw->sih, wlc_hw->d11core, dmareg(wlc_hw, DMA_TX, 1), NULL, NTXD, 0, 0, -1, 0, 0, &brcm_msg_level); @@ -1123,7 +1123,7 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) * TX: TX_AC_VI_FIFO (TX AC Video data packets) * RX: UNUSED */ - wlc_hw->di[2] = dma_attach(name, wlc_hw->sih, + wlc_hw->di[2] = dma_attach(name, wlc_hw->sih, wlc_hw->d11core, dmareg(wlc_hw, DMA_TX, 2), NULL, NTXD, 0, 0, -1, 0, 0, &brcm_msg_level); @@ -1133,7 +1133,7 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) * TX: TX_AC_VO_FIFO (TX AC Voice data packets) * (legacy) TX_CTL_FIFO (TX control & mgmt packets) */ - wlc_hw->di[3] = dma_attach(name, wlc_hw->sih, + wlc_hw->di[3] = dma_attach(name, wlc_hw->sih, wlc_hw->d11core, dmareg(wlc_hw, DMA_TX, 3), NULL, NTXD, 0, 0, -1, 0, 0, &brcm_msg_level); -- cgit v1.2.3 From e81da6501b433f757baa981a4e02fd9956cd3147 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 8 Dec 2011 15:06:53 -0800 Subject: brcm80211: smac: use bcma function for register access in dma.c The dma.c source file now uses the register access functions provided by bcma. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/dma.c | 174 ++++++++++++++----------- drivers/net/wireless/brcm80211/brcmsmac/dma.h | 3 +- drivers/net/wireless/brcm80211/brcmsmac/main.c | 22 ++-- 3 files changed, 108 insertions(+), 91 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/dma.c b/drivers/net/wireless/brcm80211/brcmsmac/dma.c index 0c5f31b044f9..dfcd9cf5af1a 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/dma.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/dma.c @@ -26,6 +26,13 @@ #include "dma.h" #include "soc.h" +/* + * dma register field offset calculation + */ +#define DMA64REGOFFS(field) offsetof(struct dma64regs, field) +#define DMA64TXREGOFFS(di, field) (di->d64txregbase + DMA64REGOFFS(field)) +#define DMA64RXREGOFFS(di, field) (di->d64rxregbase + DMA64REGOFFS(field)) + /* * DMA hardware requires each descriptor ring to be 8kB aligned, and fit within * a contiguous 8kB physical address. @@ -227,9 +234,9 @@ struct dma_info { bool addrext; /* this dma engine supports DmaExtendedAddrChanges */ /* 64-bit dma tx engine registers */ - struct dma64regs __iomem *d64txregs; + uint d64txregbase; /* 64-bit dma rx engine registers */ - struct dma64regs __iomem *d64rxregs; + uint d64rxregbase; /* pointer to dma64 tx descriptor ring */ struct dma64desc *txd64; /* pointer to dma64 rx descriptor ring */ @@ -376,15 +383,16 @@ static uint _dma_ctrlflags(struct dma_info *di, uint mask, uint flags) if (dmactrlflags & DMA_CTRL_PEN) { u32 control; - control = R_REG(&di->d64txregs->control); - W_REG(&di->d64txregs->control, + control = bcma_read32(di->d11core, DMA64TXREGOFFS(di, control)); + bcma_write32(di->d11core, DMA64TXREGOFFS(di, control), control | D64_XC_PD); - if (R_REG(&di->d64txregs->control) & D64_XC_PD) + if (bcma_read32(di->d11core, DMA64TXREGOFFS(di, control)) & + D64_XC_PD) /* We *can* disable it so it is supported, * restore control register */ - W_REG(&di->d64txregs->control, - control); + bcma_write32(di->d11core, DMA64TXREGOFFS(di, control), + control); else /* Not supported, don't allow it to be enabled */ dmactrlflags &= ~DMA_CTRL_PEN; @@ -395,12 +403,12 @@ static uint _dma_ctrlflags(struct dma_info *di, uint mask, uint flags) return dmactrlflags; } -static bool _dma64_addrext(struct dma64regs __iomem *dma64regs) +static bool _dma64_addrext(struct dma_info *di, uint ctrl_offset) { u32 w; - OR_REG(&dma64regs->control, D64_XC_AE); - w = R_REG(&dma64regs->control); - AND_REG(&dma64regs->control, ~D64_XC_AE); + bcma_set32(di->d11core, ctrl_offset, D64_XC_AE); + w = bcma_read32(di->d11core, ctrl_offset); + bcma_mask32(di->d11core, ctrl_offset, ~D64_XC_AE); return (w & D64_XC_AE) == D64_XC_AE; } @@ -413,13 +421,13 @@ static bool _dma_isaddrext(struct dma_info *di) /* DMA64 supports full 32- or 64-bit operation. AE is always valid */ /* not all tx or rx channel are available */ - if (di->d64txregs != NULL) { - if (!_dma64_addrext(di->d64txregs)) + if (di->d64txregbase != 0) { + if (!_dma64_addrext(di, DMA64TXREGOFFS(di, control))) DMA_ERROR("%s: DMA64 tx doesn't have AE set\n", di->name); return true; - } else if (di->d64rxregs != NULL) { - if (!_dma64_addrext(di->d64rxregs)) + } else if (di->d64rxregbase != 0) { + if (!_dma64_addrext(di, DMA64RXREGOFFS(di, control))) DMA_ERROR("%s: DMA64 rx doesn't have AE set\n", di->name); return true; @@ -433,14 +441,14 @@ static bool _dma_descriptor_align(struct dma_info *di) u32 addrl; /* Check to see if the descriptors need to be aligned on 4K/8K or not */ - if (di->d64txregs != NULL) { - W_REG(&di->d64txregs->addrlow, 0xff0); - addrl = R_REG(&di->d64txregs->addrlow); + if (di->d64txregbase != 0) { + bcma_write32(di->d11core, DMA64TXREGOFFS(di, addrlow), 0xff0); + addrl = bcma_read32(di->d11core, DMA64TXREGOFFS(di, addrlow)); if (addrl != 0) return false; - } else if (di->d64rxregs != NULL) { - W_REG(&di->d64rxregs->addrlow, 0xff0); - addrl = R_REG(&di->d64rxregs->addrlow); + } else if (di->d64rxregbase != 0) { + bcma_write32(di->d11core, DMA64RXREGOFFS(di, addrlow), 0xff0); + addrl = bcma_read32(di->d11core, DMA64RXREGOFFS(di, addrlow)); if (addrl != 0) return false; } @@ -558,8 +566,7 @@ static bool _dma_alloc(struct dma_info *di, uint direction) struct dma_pub *dma_attach(char *name, struct si_pub *sih, struct bcma_device *d11core, - void __iomem *dmaregstx, void __iomem *dmaregsrx, - uint ntxd, uint nrxd, + uint txregbase, uint rxregbase, uint ntxd, uint nrxd, uint rxbufsize, int rxextheadroom, uint nrxpost, uint rxoffset, uint *msg_level) { @@ -576,10 +583,10 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, di->dma64 = ((ai_core_sflags(sih, 0, 0) & SISF_DMA64) == SISF_DMA64); - /* init dma reg pointer */ + /* init dma reg info */ di->d11core = d11core; - di->d64txregs = (struct dma64regs __iomem *) dmaregstx; - di->d64rxregs = (struct dma64regs __iomem *) dmaregsrx; + di->d64txregbase = txregbase; + di->d64rxregbase = rxregbase; /* * Default flags (which can be changed by the driver calling @@ -588,10 +595,11 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, */ _dma_ctrlflags(di, DMA_CTRL_ROC | DMA_CTRL_PEN, 0); - DMA_TRACE("%s: %s flags 0x%x ntxd %d nrxd %d rxbufsize %d rxextheadroom %d nrxpost %d rxoffset %d dmaregstx %p dmaregsrx %p\n", - name, "DMA64", + DMA_TRACE("%s: %s flags 0x%x ntxd %d nrxd %d " + "rxbufsize %d rxextheadroom %d nrxpost %d rxoffset %d " + "txregbase %u rxregbase %u\n", name, "DMA64", di->dma.dmactrlflags, ntxd, nrxd, rxbufsize, - rxextheadroom, nrxpost, rxoffset, dmaregstx, dmaregsrx); + rxextheadroom, nrxpost, rxoffset, txregbase, rxregbase); /* make a private copy of our callers name */ strncpy(di->name, name, MAXNAMEL); @@ -783,11 +791,15 @@ _dma_ddtable_init(struct dma_info *di, uint direction, dma_addr_t pa) if ((di->ddoffsetlow == 0) || !(pa & PCI32ADDR_HIGH)) { if (direction == DMA_TX) { - W_REG(&di->d64txregs->addrlow, pa + di->ddoffsetlow); - W_REG(&di->d64txregs->addrhigh, di->ddoffsethigh); + bcma_write32(di->d11core, DMA64TXREGOFFS(di, addrlow), + pa + di->ddoffsetlow); + bcma_write32(di->d11core, DMA64TXREGOFFS(di, addrhigh), + di->ddoffsethigh); } else { - W_REG(&di->d64rxregs->addrlow, pa + di->ddoffsetlow); - W_REG(&di->d64rxregs->addrhigh, di->ddoffsethigh); + bcma_write32(di->d11core, DMA64RXREGOFFS(di, addrlow), + pa + di->ddoffsetlow); + bcma_write32(di->d11core, DMA64RXREGOFFS(di, addrhigh), + di->ddoffsethigh); } } else { /* DMA64 32bits address extension */ @@ -798,15 +810,19 @@ _dma_ddtable_init(struct dma_info *di, uint direction, dma_addr_t pa) pa &= ~PCI32ADDR_HIGH; if (direction == DMA_TX) { - W_REG(&di->d64txregs->addrlow, pa + di->ddoffsetlow); - W_REG(&di->d64txregs->addrhigh, di->ddoffsethigh); - SET_REG(&di->d64txregs->control, - D64_XC_AE, (ae << D64_XC_AE_SHIFT)); + bcma_write32(di->d11core, DMA64TXREGOFFS(di, addrlow), + pa + di->ddoffsetlow); + bcma_write32(di->d11core, DMA64TXREGOFFS(di, addrhigh), + di->ddoffsethigh); + bcma_maskset32(di->d11core, DMA64TXREGOFFS(di, control), + D64_XC_AE, (ae << D64_XC_AE_SHIFT)); } else { - W_REG(&di->d64rxregs->addrlow, pa + di->ddoffsetlow); - W_REG(&di->d64rxregs->addrhigh, di->ddoffsethigh); - SET_REG(&di->d64rxregs->control, - D64_RC_AE, (ae << D64_RC_AE_SHIFT)); + bcma_write32(di->d11core, DMA64RXREGOFFS(di, addrlow), + pa + di->ddoffsetlow); + bcma_write32(di->d11core, DMA64RXREGOFFS(di, addrhigh), + di->ddoffsethigh); + bcma_maskset32(di->d11core, DMA64RXREGOFFS(di, control), + D64_RC_AE, (ae << D64_RC_AE_SHIFT)); } } } @@ -818,9 +834,9 @@ static void _dma_rxenable(struct dma_info *di) DMA_TRACE("%s:\n", di->name); - control = - (R_REG(&di->d64rxregs->control) & D64_RC_AE) | - D64_RC_RE; + control = D64_RC_RE | (bcma_read32(di->d11core, + DMA64RXREGOFFS(di, control)) & + D64_RC_AE); if ((dmactrlflags & DMA_CTRL_PEN) == 0) control |= D64_RC_PD; @@ -828,7 +844,7 @@ static void _dma_rxenable(struct dma_info *di) if (dmactrlflags & DMA_CTRL_ROC) control |= D64_RC_OC; - W_REG(&di->d64rxregs->control, + bcma_write32(di->d11core, DMA64RXREGOFFS(di, control), ((di->rxoffset << D64_RC_RO_SHIFT) | control)); } @@ -871,7 +887,8 @@ static struct sk_buff *dma64_getnextrxp(struct dma_info *di, bool forceall) return NULL; curr = - B2I(((R_REG(&di->d64rxregs->status0) & D64_RS0_CD_MASK) - + B2I(((bcma_read32(di->d11core, + DMA64RXREGOFFS(di, status0)) & D64_RS0_CD_MASK) - di->rcvptrbase) & D64_RS0_CD_MASK, struct dma64desc); /* ignore curr if forceall */ @@ -953,12 +970,12 @@ int dma_rx(struct dma_pub *pub, struct sk_buff_head *skb_list) if (resid > 0) { uint cur; cur = - B2I(((R_REG(&di->d64rxregs->status0) & - D64_RS0_CD_MASK) - - di->rcvptrbase) & D64_RS0_CD_MASK, - struct dma64desc); + B2I(((bcma_read32(di->d11core, + DMA64RXREGOFFS(di, status0)) & + D64_RS0_CD_MASK) - di->rcvptrbase) & + D64_RS0_CD_MASK, struct dma64desc); DMA_ERROR("rxin %d rxout %d, hw_curr %d\n", - di->rxin, di->rxout, cur); + di->rxin, di->rxout, cur); } #endif /* BCMDBG */ @@ -986,8 +1003,10 @@ static bool dma64_rxidle(struct dma_info *di) if (di->nrxd == 0) return true; - return ((R_REG(&di->d64rxregs->status0) & D64_RS0_CD_MASK) == - (R_REG(&di->d64rxregs->ptr) & D64_RS0_CD_MASK)); + return ((bcma_read32(di->d11core, + DMA64RXREGOFFS(di, status0)) & D64_RS0_CD_MASK) == + (bcma_read32(di->d11core, DMA64RXREGOFFS(di, ptr)) & + D64_RS0_CD_MASK)); } /* @@ -1070,7 +1089,7 @@ bool dma_rxfill(struct dma_pub *pub) di->rxout = rxout; /* update the chip lastdscr pointer */ - W_REG(&di->d64rxregs->ptr, + bcma_write32(di->d11core, DMA64RXREGOFFS(di, ptr), di->rcvptrbase + I2B(rxout, struct dma64desc)); return ring_empty; @@ -1131,7 +1150,7 @@ void dma_txinit(struct dma_pub *pub) if ((di->dma.dmactrlflags & DMA_CTRL_PEN) == 0) control |= D64_XC_PD; - OR_REG(&di->d64txregs->control, control); + bcma_set32(di->d11core, DMA64TXREGOFFS(di, control), control); /* DMA engine with alignment requirement requires table to be inited * before enabling the engine @@ -1149,7 +1168,7 @@ void dma_txsuspend(struct dma_pub *pub) if (di->ntxd == 0) return; - OR_REG(&di->d64txregs->control, D64_XC_SE); + bcma_set32(di->d11core, DMA64TXREGOFFS(di, control), D64_XC_SE); } void dma_txresume(struct dma_pub *pub) @@ -1161,7 +1180,7 @@ void dma_txresume(struct dma_pub *pub) if (di->ntxd == 0) return; - AND_REG(&di->d64txregs->control, ~D64_XC_SE); + bcma_mask32(di->d11core, DMA64TXREGOFFS(di, control), ~D64_XC_SE); } bool dma_txsuspended(struct dma_pub *pub) @@ -1169,8 +1188,9 @@ bool dma_txsuspended(struct dma_pub *pub) struct dma_info *di = (struct dma_info *)pub; return (di->ntxd == 0) || - ((R_REG(&di->d64txregs->control) & D64_XC_SE) == - D64_XC_SE); + ((bcma_read32(di->d11core, + DMA64TXREGOFFS(di, control)) & D64_XC_SE) == + D64_XC_SE); } void dma_txreclaim(struct dma_pub *pub, enum txd_range range) @@ -1203,16 +1223,17 @@ bool dma_txreset(struct dma_pub *pub) return true; /* suspend tx DMA first */ - W_REG(&di->d64txregs->control, D64_XC_SE); + bcma_write32(di->d11core, DMA64TXREGOFFS(di, control), D64_XC_SE); SPINWAIT(((status = - (R_REG(&di->d64txregs->status0) & D64_XS0_XS_MASK)) - != D64_XS0_XS_DISABLED) && (status != D64_XS0_XS_IDLE) - && (status != D64_XS0_XS_STOPPED), 10000); + (bcma_read32(di->d11core, DMA64TXREGOFFS(di, status0)) & + D64_XS0_XS_MASK)) != D64_XS0_XS_DISABLED) && + (status != D64_XS0_XS_IDLE) && (status != D64_XS0_XS_STOPPED), + 10000); - W_REG(&di->d64txregs->control, 0); + bcma_write32(di->d11core, DMA64TXREGOFFS(di, control), 0); SPINWAIT(((status = - (R_REG(&di->d64txregs->status0) & D64_XS0_XS_MASK)) - != D64_XS0_XS_DISABLED), 10000); + (bcma_read32(di->d11core, DMA64TXREGOFFS(di, status0)) & + D64_XS0_XS_MASK)) != D64_XS0_XS_DISABLED), 10000); /* wait for the last transaction to complete */ udelay(300); @@ -1228,10 +1249,10 @@ bool dma_rxreset(struct dma_pub *pub) if (di->nrxd == 0) return true; - W_REG(&di->d64rxregs->control, 0); + bcma_write32(di->d11core, DMA64RXREGOFFS(di, control), 0); SPINWAIT(((status = - (R_REG(&di->d64rxregs->status0) & D64_RS0_RS_MASK)) - != D64_RS0_RS_DISABLED), 10000); + (bcma_read32(di->d11core, DMA64RXREGOFFS(di, status0)) & + D64_RS0_RS_MASK)) != D64_RS0_RS_DISABLED), 10000); return status == D64_RS0_RS_DISABLED; } @@ -1293,7 +1314,7 @@ int dma_txfast(struct dma_pub *pub, struct sk_buff *p, bool commit) /* kick the chip */ if (commit) - W_REG(&di->d64txregs->ptr, + bcma_write32(di->d11core, DMA64TXREGOFFS(di, ptr), di->xmtptrbase + I2B(txout, struct dma64desc)); /* tx flow control */ @@ -1341,16 +1362,15 @@ struct sk_buff *dma_getnexttxp(struct dma_pub *pub, enum txd_range range) if (range == DMA_RANGE_ALL) end = di->txout; else { - struct dma64regs __iomem *dregs = di->d64txregs; - - end = (u16) (B2I(((R_REG(&dregs->status0) & - D64_XS0_CD_MASK) - - di->xmtptrbase) & D64_XS0_CD_MASK, - struct dma64desc)); + end = (u16) (B2I(((bcma_read32(di->d11core, + DMA64TXREGOFFS(di, status0)) & + D64_XS0_CD_MASK) - di->xmtptrbase) & + D64_XS0_CD_MASK, struct dma64desc)); if (range == DMA_RANGE_TRANSFERED) { active_desc = - (u16) (R_REG(&dregs->status1) & + (u16)(bcma_read32(di->d11core, + DMA64TXREGOFFS(di, status1)) & D64_XS1_AD_MASK); active_desc = (active_desc - di->xmtptrbase) & D64_XS0_CD_MASK; diff --git a/drivers/net/wireless/brcm80211/brcmsmac/dma.h b/drivers/net/wireless/brcm80211/brcmsmac/dma.h index 2d59ad6ab8e0..cc269ee5c499 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/dma.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/dma.h @@ -76,8 +76,7 @@ struct dma_pub { extern struct dma_pub *dma_attach(char *name, struct si_pub *sih, struct bcma_device *d11core, - void __iomem *dmaregstx, - void __iomem *dmaregsrx, + uint txregbase, uint rxregbase, uint ntxd, uint nrxd, uint rxbufsize, int rxextheadroom, uint nrxpost, uint rxoffset, uint *msg_level); diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index f2491bdb1898..43172b3b8297 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -1065,14 +1065,12 @@ brcms_c_mhfdef(struct brcms_c_info *wlc, u16 *mhfs, u16 mhf2_init) } } -static struct dma64regs __iomem * -dmareg(struct brcms_hardware *hw, uint direction, uint fifonum) +static uint +dmareg(uint direction, uint fifonum) { - struct d11regs __iomem *regs = hw->d11core->bus->mmio; - if (direction == DMA_TX) - return &(regs->fifo64regs[fifonum].dmaxmt); - return &(regs->fifo64regs[fifonum].dmarcv); + return offsetof(struct d11regs, fifo64regs[fifonum].dmaxmt); + return offsetof(struct d11regs, fifo64regs[fifonum].dmarcv); } static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) @@ -1099,8 +1097,8 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) * RX: RX_FIFO (RX data packets) */ wlc_hw->di[0] = dma_attach(name, wlc_hw->sih, wlc_hw->d11core, - (wme ? dmareg(wlc_hw, DMA_TX, 0) : - NULL), dmareg(wlc_hw, DMA_RX, 0), + (wme ? dmareg(DMA_TX, 0) : 0), + dmareg(DMA_RX, 0), (wme ? NTXD : 0), NRXD, RXBUFSZ, -1, NRXBUFPOST, BRCMS_HWRXOFF, &brcm_msg_level); @@ -1113,7 +1111,7 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) * RX: UNUSED */ wlc_hw->di[1] = dma_attach(name, wlc_hw->sih, wlc_hw->d11core, - dmareg(wlc_hw, DMA_TX, 1), NULL, + dmareg(DMA_TX, 1), 0, NTXD, 0, 0, -1, 0, 0, &brcm_msg_level); dma_attach_err |= (NULL == wlc_hw->di[1]); @@ -1124,7 +1122,7 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) * RX: UNUSED */ wlc_hw->di[2] = dma_attach(name, wlc_hw->sih, wlc_hw->d11core, - dmareg(wlc_hw, DMA_TX, 2), NULL, + dmareg(DMA_TX, 2), 0, NTXD, 0, 0, -1, 0, 0, &brcm_msg_level); dma_attach_err |= (NULL == wlc_hw->di[2]); @@ -1134,8 +1132,8 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) * (legacy) TX_CTL_FIFO (TX control & mgmt packets) */ wlc_hw->di[3] = dma_attach(name, wlc_hw->sih, wlc_hw->d11core, - dmareg(wlc_hw, DMA_TX, 3), - NULL, NTXD, 0, 0, -1, + dmareg(DMA_TX, 3), + 0, NTXD, 0, 0, -1, 0, 0, &brcm_msg_level); dma_attach_err |= (NULL == wlc_hw->di[3]); /* Cleaner to leave this as if with AP defined */ -- cgit v1.2.3 From 4b006b11ca18995677c5f1cd03cc9c42fbe80693 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 8 Dec 2011 15:06:54 -0800 Subject: brcm80211: smac: use bcma functions for register access in phy code This adds the use of bcma functions to access the registers within the phy source code. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/main.c | 2 +- .../net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c | 183 ++++++++++----------- .../net/wireless/brcm80211/brcmsmac/phy/phy_hal.h | 2 +- .../net/wireless/brcm80211/brcmsmac/phy/phy_int.h | 4 +- .../net/wireless/brcm80211/brcmsmac/phy/phy_lcn.c | 69 ++++---- .../net/wireless/brcm80211/brcmsmac/phy/phy_n.c | 75 +++++---- drivers/net/wireless/brcm80211/brcmsmac/types.h | 3 + 7 files changed, 162 insertions(+), 176 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index 43172b3b8297..5db2bdc67a56 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -4626,7 +4626,7 @@ static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core, /* Get a phy for this band */ wlc_hw->band->pi = - wlc_phy_attach(wlc_hw->phy_sh, core->bus->mmio, + wlc_phy_attach(wlc_hw->phy_sh, core, wlc_hw->band->bandtype, wlc->wiphy); if (wlc_hw->band->pi == NULL) { diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c index 30cc558dbadc..8054ce253edc 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c @@ -149,9 +149,8 @@ void wlc_radioreg_enter(struct brcms_phy_pub *pih) void wlc_radioreg_exit(struct brcms_phy_pub *pih) { struct brcms_phy *pi = (struct brcms_phy *) pih; - u16 dummy; - dummy = R_REG(&pi->regs->phyversion); + (void)bcma_read16(pi->d11core, D11REGOFFS(phyversion)); pi->phy_wreg = 0; wlapi_bmac_mctrl(pi->sh->physhim, MCTL_LOCK_RADIO, 0); } @@ -186,11 +185,11 @@ u16 read_radio_reg(struct brcms_phy *pi, u16 addr) if ((D11REV_GE(pi->sh->corerev, 24)) || (D11REV_IS(pi->sh->corerev, 22) && (pi->pubpi.phy_type != PHY_TYPE_SSN))) { - W_REG_FLUSH(&pi->regs->radioregaddr, addr); - data = R_REG(&pi->regs->radioregdata); + bcma_wflush16(pi->d11core, D11REGOFFS(radioregaddr), addr); + data = bcma_read16(pi->d11core, D11REGOFFS(radioregdata)); } else { - W_REG_FLUSH(&pi->regs->phy4waddr, addr); - data = R_REG(&pi->regs->phy4wdatalo); + bcma_wflush16(pi->d11core, D11REGOFFS(phy4waddr), addr); + data = bcma_read16(pi->d11core, D11REGOFFS(phy4wdatalo)); } pi->phy_wreg = 0; @@ -203,15 +202,15 @@ void write_radio_reg(struct brcms_phy *pi, u16 addr, u16 val) (D11REV_IS(pi->sh->corerev, 22) && (pi->pubpi.phy_type != PHY_TYPE_SSN))) { - W_REG_FLUSH(&pi->regs->radioregaddr, addr); - W_REG(&pi->regs->radioregdata, val); + bcma_wflush16(pi->d11core, D11REGOFFS(radioregaddr), addr); + bcma_write16(pi->d11core, D11REGOFFS(radioregdata), val); } else { - W_REG_FLUSH(&pi->regs->phy4waddr, addr); - W_REG(&pi->regs->phy4wdatalo, val); + bcma_wflush16(pi->d11core, D11REGOFFS(phy4waddr), addr); + bcma_write16(pi->d11core, D11REGOFFS(phy4wdatalo), val); } if (++pi->phy_wreg >= pi->phy_wreg_limit) { - (void)R_REG(&pi->regs->maccontrol); + (void)bcma_read32(pi->d11core, D11REGOFFS(maccontrol)); pi->phy_wreg = 0; } } @@ -223,19 +222,20 @@ static u32 read_radio_id(struct brcms_phy *pi) if (D11REV_GE(pi->sh->corerev, 24)) { u32 b0, b1, b2; - W_REG_FLUSH(&pi->regs->radioregaddr, 0); - b0 = (u32) R_REG(&pi->regs->radioregdata); - W_REG_FLUSH(&pi->regs->radioregaddr, 1); - b1 = (u32) R_REG(&pi->regs->radioregdata); - W_REG_FLUSH(&pi->regs->radioregaddr, 2); - b2 = (u32) R_REG(&pi->regs->radioregdata); + bcma_wflush16(pi->d11core, D11REGOFFS(radioregaddr), 0); + b0 = (u32) bcma_read16(pi->d11core, D11REGOFFS(radioregdata)); + bcma_wflush16(pi->d11core, D11REGOFFS(radioregaddr), 1); + b1 = (u32) bcma_read16(pi->d11core, D11REGOFFS(radioregdata)); + bcma_wflush16(pi->d11core, D11REGOFFS(radioregaddr), 2); + b2 = (u32) bcma_read16(pi->d11core, D11REGOFFS(radioregdata)); id = ((b0 & 0xf) << 28) | (((b2 << 8) | b1) << 12) | ((b0 >> 4) & 0xf); } else { - W_REG_FLUSH(&pi->regs->phy4waddr, RADIO_IDCODE); - id = (u32) R_REG(&pi->regs->phy4wdatalo); - id |= (u32) R_REG(&pi->regs->phy4wdatahi) << 16; + bcma_wflush16(pi->d11core, D11REGOFFS(phy4waddr), RADIO_IDCODE); + id = (u32) bcma_read16(pi->d11core, D11REGOFFS(phy4wdatalo)); + id |= (u32) bcma_read16(pi->d11core, + D11REGOFFS(phy4wdatahi)) << 16; } pi->phy_wreg = 0; return id; @@ -275,75 +275,52 @@ void mod_radio_reg(struct brcms_phy *pi, u16 addr, u16 mask, u16 val) void write_phy_channel_reg(struct brcms_phy *pi, uint val) { - W_REG(&pi->regs->phychannel, val); + bcma_write16(pi->d11core, D11REGOFFS(phychannel), val); } u16 read_phy_reg(struct brcms_phy *pi, u16 addr) { - struct d11regs __iomem *regs; - - regs = pi->regs; - - W_REG_FLUSH(®s->phyregaddr, addr); + bcma_wflush16(pi->d11core, D11REGOFFS(phyregaddr), addr); pi->phy_wreg = 0; - return R_REG(®s->phyregdata); + return bcma_read16(pi->d11core, D11REGOFFS(phyregdata)); } void write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) { - struct d11regs __iomem *regs; - - regs = pi->regs; - #ifdef CONFIG_BCM47XX - W_REG_FLUSH(®s->phyregaddr, addr); - W_REG(®s->phyregdata, val); + bcma_wflush16(pi->d11core, D11REGOFFS(phyregaddr), addr); + bcma_write16(pi->d11core, D11REGOFFS(phyregdata), val); if (addr == 0x72) - (void)R_REG(®s->phyregdata); + (void)bcma_read16(pi->d11core, D11REGOFFS(phyversion)); #else - W_REG((u32 __iomem *)(®s->phyregaddr), addr | (val << 16)); + bcma_write32(pi->d11core, D11REGOFFS(phyregaddr), addr | (val << 16)); if (++pi->phy_wreg >= pi->phy_wreg_limit) { pi->phy_wreg = 0; - (void)R_REG(®s->phyversion); + (void)bcma_read16(pi->d11core, D11REGOFFS(phyversion)); } #endif } void and_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) { - struct d11regs __iomem *regs; - - regs = pi->regs; - - W_REG_FLUSH(®s->phyregaddr, addr); - - W_REG(®s->phyregdata, (R_REG(®s->phyregdata) & val)); + bcma_wflush16(pi->d11core, D11REGOFFS(phyregaddr), addr); + bcma_mask16(pi->d11core, D11REGOFFS(phyregdata), val); pi->phy_wreg = 0; } void or_phy_reg(struct brcms_phy *pi, u16 addr, u16 val) { - struct d11regs __iomem *regs; - - regs = pi->regs; - - W_REG_FLUSH(®s->phyregaddr, addr); - - W_REG(®s->phyregdata, (R_REG(®s->phyregdata) | val)); + bcma_wflush16(pi->d11core, D11REGOFFS(phyregaddr), addr); + bcma_set16(pi->d11core, D11REGOFFS(phyregdata), val); pi->phy_wreg = 0; } void mod_phy_reg(struct brcms_phy *pi, u16 addr, u16 mask, u16 val) { - struct d11regs __iomem *regs; - - regs = pi->regs; - - W_REG_FLUSH(®s->phyregaddr, addr); - - W_REG(®s->phyregdata, - ((R_REG(®s->phyregdata) & ~mask) | (val & mask))); + val &= mask; + bcma_wflush16(pi->d11core, D11REGOFFS(phyregaddr), addr); + bcma_maskset16(pi->d11core, D11REGOFFS(phyregdata), ~mask, val); pi->phy_wreg = 0; } @@ -448,7 +425,7 @@ static u32 wlc_phy_get_radio_ver(struct brcms_phy *pi) } struct brcms_phy_pub * -wlc_phy_attach(struct shared_phy *sh, struct d11regs __iomem *regs, +wlc_phy_attach(struct shared_phy *sh, struct bcma_device *d11core, int bandtype, struct wiphy *wiphy) { struct brcms_phy *pi; @@ -478,7 +455,7 @@ wlc_phy_attach(struct shared_phy *sh, struct d11regs __iomem *regs, if (pi == NULL) return NULL; pi->wiphy = wiphy; - pi->regs = regs; + pi->d11core = d11core; pi->sh = sh; pi->phy_init_por = true; pi->phy_wreg_limit = PHY_WREG_LIMIT; @@ -493,7 +470,7 @@ wlc_phy_attach(struct shared_phy *sh, struct d11regs __iomem *regs, pi->pubpi.coreflags = SICF_GMODE; wlapi_bmac_corereset(pi->sh->physhim, pi->pubpi.coreflags); - phyversion = R_REG(&pi->regs->phyversion); + phyversion = bcma_read16(pi->d11core, D11REGOFFS(phyversion)); pi->pubpi.phy_type = PHY_TYPE(phyversion); pi->pubpi.phy_rev = phyversion & PV_PV_MASK; @@ -777,7 +754,7 @@ void wlc_phy_init(struct brcms_phy_pub *pih, u16 chanspec) pi->radio_chanspec = chanspec; - mc = R_REG(&pi->regs->maccontrol); + mc = bcma_read32(pi->d11core, D11REGOFFS(maccontrol)); if (WARN(mc & MCTL_EN_MAC, "HW error MAC running on init")) return; @@ -823,8 +800,8 @@ void wlc_phy_cal_init(struct brcms_phy_pub *pih) struct brcms_phy *pi = (struct brcms_phy *) pih; void (*cal_init)(struct brcms_phy *) = NULL; - if (WARN((R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC) != 0, - "HW error: MAC enabled during phy cal\n")) + if (WARN((bcma_read32(pi->d11core, D11REGOFFS(maccontrol)) & + MCTL_EN_MAC) != 0, "HW error: MAC enabled during phy cal\n")) return; if (!pi->initialized) { @@ -1015,7 +992,7 @@ wlc_phy_init_radio_regs(struct brcms_phy *pi, void wlc_phy_do_dummy_tx(struct brcms_phy *pi, bool ofdm, bool pa_on) { #define DUMMY_PKT_LEN 20 - struct d11regs __iomem *regs = pi->regs; + struct bcma_device *core = pi->d11core; int i, count; u8 ofdmpkt[DUMMY_PKT_LEN] = { 0xcc, 0x01, 0x02, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, @@ -1031,26 +1008,28 @@ void wlc_phy_do_dummy_tx(struct brcms_phy *pi, bool ofdm, bool pa_on) wlapi_bmac_write_template_ram(pi->sh->physhim, 0, DUMMY_PKT_LEN, dummypkt); - W_REG(®s->xmtsel, 0); + bcma_write16(core, D11REGOFFS(xmtsel), 0); if (D11REV_GE(pi->sh->corerev, 11)) - W_REG(®s->wepctl, 0x100); + bcma_write16(core, D11REGOFFS(wepctl), 0x100); else - W_REG(®s->wepctl, 0); + bcma_write16(core, D11REGOFFS(wepctl), 0); - W_REG(®s->txe_phyctl, (ofdm ? 1 : 0) | PHY_TXC_ANT_0); + bcma_write16(core, D11REGOFFS(txe_phyctl), + (ofdm ? 1 : 0) | PHY_TXC_ANT_0); if (ISNPHY(pi) || ISLCNPHY(pi)) - W_REG(®s->txe_phyctl1, 0x1A02); + bcma_write16(core, D11REGOFFS(txe_phyctl1), 0x1A02); - W_REG(®s->txe_wm_0, 0); - W_REG(®s->txe_wm_1, 0); + bcma_write16(core, D11REGOFFS(txe_wm_0), 0); + bcma_write16(core, D11REGOFFS(txe_wm_1), 0); - W_REG(®s->xmttplatetxptr, 0); - W_REG(®s->xmttxcnt, DUMMY_PKT_LEN); + bcma_write16(core, D11REGOFFS(xmttplatetxptr), 0); + bcma_write16(core, D11REGOFFS(xmttxcnt), DUMMY_PKT_LEN); - W_REG(®s->xmtsel, ((8 << 8) | (1 << 5) | (1 << 2) | 2)); + bcma_write16(core, D11REGOFFS(xmtsel), + ((8 << 8) | (1 << 5) | (1 << 2) | 2)); - W_REG(®s->txe_ctl, 0); + bcma_write16(core, D11REGOFFS(txe_ctl), 0); if (!pa_on) { if (ISNPHY(pi)) @@ -1058,27 +1037,28 @@ void wlc_phy_do_dummy_tx(struct brcms_phy *pi, bool ofdm, bool pa_on) } if (ISNPHY(pi) || ISLCNPHY(pi)) - W_REG(®s->txe_aux, 0xD0); + bcma_write16(core, D11REGOFFS(txe_aux), 0xD0); else - W_REG(®s->txe_aux, ((1 << 5) | (1 << 4))); + bcma_write16(core, D11REGOFFS(txe_aux), ((1 << 5) | (1 << 4))); - (void)R_REG(®s->txe_aux); + (void)bcma_read16(core, D11REGOFFS(txe_aux)); i = 0; count = ofdm ? 30 : 250; while ((i++ < count) - && (R_REG(®s->txe_status) & (1 << 7))) + && (bcma_read16(core, D11REGOFFS(txe_status)) & (1 << 7))) udelay(10); i = 0; - while ((i++ < 10) - && ((R_REG(®s->txe_status) & (1 << 10)) == 0)) + while ((i++ < 10) && + ((bcma_read16(core, D11REGOFFS(txe_status)) & (1 << 10)) == 0)) udelay(10); i = 0; - while ((i++ < 10) && ((R_REG(®s->ifsstat) & (1 << 8)))) + while ((i++ < 10) && + ((bcma_read16(core, D11REGOFFS(ifsstat)) & (1 << 8)))) udelay(10); if (!pa_on) { @@ -1135,7 +1115,7 @@ static bool wlc_phy_cal_txpower_recalc_sw(struct brcms_phy *pi) void wlc_phy_switch_radio(struct brcms_phy_pub *pih, bool on) { struct brcms_phy *pi = (struct brcms_phy *) pih; - (void)R_REG(&pi->regs->maccontrol); + (void)bcma_read32(pi->d11core, D11REGOFFS(maccontrol)); if (ISNPHY(pi)) { wlc_phy_switch_radio_nphy(pi, on); @@ -1375,7 +1355,7 @@ void wlc_phy_txpower_target_set(struct brcms_phy_pub *ppi, memcpy(&pi->tx_user_target[TXP_FIRST_MCS_40_SDM], &txpwr->mcs_40_mimo[0], BRCMS_NUM_RATES_MCS_2_STREAM); - if (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC) + if (bcma_read32(pi->d11core, D11REGOFFS(maccontrol)) & MCTL_EN_MAC) mac_enabled = true; if (mac_enabled) @@ -1405,7 +1385,8 @@ int wlc_phy_txpower_set(struct brcms_phy_pub *ppi, uint qdbm, bool override) if (!SCAN_INPROG_PHY(pi)) { bool suspend; - suspend = (0 == (R_REG(&pi->regs->maccontrol) & + suspend = (0 == (bcma_read32(pi->d11core, + D11REGOFFS(maccontrol)) & MCTL_EN_MAC)); if (!suspend) @@ -1858,18 +1839,17 @@ void wlc_phy_runbist_config(struct brcms_phy_pub *ppi, bool start_end) if (NREV_IS(pi->pubpi.phy_rev, 3) || NREV_IS(pi->pubpi.phy_rev, 4)) { - W_REG(&pi->regs->phyregaddr, 0xa0); - (void)R_REG(&pi->regs->phyregaddr); - rxc = R_REG(&pi->regs->phyregdata); - W_REG(&pi->regs->phyregdata, - (0x1 << 15) | rxc); + bcma_wflush16(pi->d11core, D11REGOFFS(phyregaddr), + 0xa0); + bcma_set16(pi->d11core, D11REGOFFS(phyregdata), + 0x1 << 15); } } else { if (NREV_IS(pi->pubpi.phy_rev, 3) || NREV_IS(pi->pubpi.phy_rev, 4)) { - W_REG(&pi->regs->phyregaddr, 0xa0); - (void)R_REG(&pi->regs->phyregaddr); - W_REG(&pi->regs->phyregdata, rxc); + bcma_wflush16(pi->d11core, D11REGOFFS(phyregaddr), + 0xa0); + bcma_write16(pi->d11core, D11REGOFFS(phyregdata), rxc); } wlc_phy_por_inform(ppi); @@ -1989,7 +1969,9 @@ void wlc_phy_txpower_hw_ctrl_set(struct brcms_phy_pub *ppi, bool hwpwrctrl) pi->txpwrctrl = hwpwrctrl; if (ISNPHY(pi)) { - suspend = (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); + suspend = (0 == (bcma_read32(pi->d11core, + D11REGOFFS(maccontrol)) & + MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); @@ -2191,7 +2173,8 @@ void wlc_phy_ant_rxdiv_set(struct brcms_phy_pub *ppi, u8 val) if (!pi->sh->clk) return; - suspend = (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); + suspend = (0 == (bcma_read32(pi->d11core, D11REGOFFS(maccontrol)) & + MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); @@ -2409,8 +2392,8 @@ wlc_phy_noise_sample_request(struct brcms_phy_pub *pih, u8 reason, u8 ch) wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP2, 0); wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP3, 0); - OR_REG(&pi->regs->maccommand, - MCMD_BG_NOISE); + bcma_set32(pi->d11core, D11REGOFFS(maccommand), + MCMD_BG_NOISE); } else { wlapi_suspend_mac_and_wait(pi->sh->physhim); wlc_lcnphy_deaf_mode(pi, (bool) 0); @@ -2428,8 +2411,8 @@ wlc_phy_noise_sample_request(struct brcms_phy_pub *pih, u8 reason, u8 ch) wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP2, 0); wlapi_bmac_write_shm(pi->sh->physhim, M_PWRIND_MAP3, 0); - OR_REG(&pi->regs->maccommand, - MCMD_BG_NOISE); + bcma_set32(pi->d11core, D11REGOFFS(maccommand), + MCMD_BG_NOISE); } else { struct phy_iq_est est[PHY_CORE_MAX]; u32 cmplx_pwr[PHY_CORE_MAX]; diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_hal.h b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_hal.h index 5549c7b0cfd6..e34a71e7d242 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_hal.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_hal.h @@ -181,7 +181,7 @@ struct shared_phy_params { extern struct shared_phy *wlc_phy_shared_attach(struct shared_phy_params *shp); extern struct brcms_phy_pub *wlc_phy_attach(struct shared_phy *sh, - struct d11regs __iomem *regs, + struct bcma_device *d11core, int bandtype, struct wiphy *wiphy); extern void wlc_phy_detach(struct brcms_phy_pub *ppi); diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h index 02e640723a9c..af00e2c2b266 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_int.h @@ -557,7 +557,7 @@ struct brcms_phy { } u; bool user_txpwr_at_rfport; - struct d11regs __iomem *regs; + struct bcma_device *d11core; struct brcms_phy *next; struct brcms_phy_pub pubpi; @@ -1088,7 +1088,7 @@ extern void wlc_phy_table_write_nphy(struct brcms_phy *pi, u32, u32, u32, #define BRCMS_PHY_WAR_PR51571(pi) \ if (NREV_LT((pi)->pubpi.phy_rev, 3)) \ - (void)R_REG(&(pi)->regs->maccontrol) + (void)bcma_read32(pi->d11core, D11REGOFFS(maccontrol)) extern void wlc_phy_cal_perical_nphy_run(struct brcms_phy *pi, u8 caltype); extern void wlc_phy_aci_reset_nphy(struct brcms_phy *pi); diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_lcn.c index a63aa99d9810..efa0142bdad5 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_lcn.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_lcn.c @@ -2813,10 +2813,8 @@ static void wlc_lcnphy_idle_tssi_est(struct brcms_phy_pub *ppi) u16 SAVE_jtag_auxpga = read_radio_reg(pi, RADIO_2064_REG0FF) & 0x10; u16 SAVE_iqadc_aux_en = read_radio_reg(pi, RADIO_2064_REG11F) & 4; idleTssi = read_phy_reg(pi, 0x4ab); - suspend = - (0 == - (R_REG(&((struct brcms_phy *) pi)->regs->maccontrol) & - MCTL_EN_MAC)); + suspend = (0 == (bcma_read32(pi->d11core, D11REGOFFS(maccontrol)) & + MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); wlc_lcnphy_set_tx_pwr_ctrl(pi, LCNPHY_TX_PWR_CTRL_OFF); @@ -2890,7 +2888,8 @@ static void wlc_lcnphy_vbat_temp_sense_setup(struct brcms_phy *pi, u8 mode) for (i = 0; i < 14; i++) values_to_save[i] = read_phy_reg(pi, tempsense_phy_regs[i]); - suspend = (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); + suspend = (0 == (bcma_read32(pi->d11core, D11REGOFFS(maccontrol)) & + MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); save_txpwrCtrlEn = read_radio_reg(pi, 0x4a4); @@ -3016,8 +3015,8 @@ static void wlc_lcnphy_tx_pwr_ctrl_init(struct brcms_phy_pub *ppi) bool suspend; struct brcms_phy *pi = (struct brcms_phy *) ppi; - suspend = - (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); + suspend = (0 == (bcma_read32(pi->d11core, D11REGOFFS(maccontrol)) & + MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); @@ -3535,15 +3534,17 @@ wlc_lcnphy_samp_cap(struct brcms_phy *pi, int clip_detect_algo, u16 thresh, timer = 0; old_sslpnCalibClkEnCtrl = read_phy_reg(pi, 0x6da); - curval1 = R_REG(&pi->regs->psm_corectlsts); + curval1 = bcma_read16(pi->d11core, D11REGOFFS(psm_corectlsts)); ptr[130] = 0; - W_REG(&pi->regs->psm_corectlsts, ((1 << 6) | curval1)); + bcma_write16(pi->d11core, D11REGOFFS(psm_corectlsts), + ((1 << 6) | curval1)); - W_REG(&pi->regs->smpl_clct_strptr, 0x7E00); - W_REG(&pi->regs->smpl_clct_stpptr, 0x8000); + bcma_write16(pi->d11core, D11REGOFFS(smpl_clct_strptr), 0x7E00); + bcma_write16(pi->d11core, D11REGOFFS(smpl_clct_stpptr), 0x8000); udelay(20); - curval2 = R_REG(&pi->regs->psm_phy_hdr_param); - W_REG(&pi->regs->psm_phy_hdr_param, curval2 | 0x30); + curval2 = bcma_read16(pi->d11core, D11REGOFFS(psm_phy_hdr_param)); + bcma_write16(pi->d11core, D11REGOFFS(psm_phy_hdr_param), + curval2 | 0x30); write_phy_reg(pi, 0x555, 0x0); write_phy_reg(pi, 0x5a6, 0x5); @@ -3560,19 +3561,19 @@ wlc_lcnphy_samp_cap(struct brcms_phy *pi, int clip_detect_algo, u16 thresh, sslpnCalibClkEnCtrl = read_phy_reg(pi, 0x6da); write_phy_reg(pi, 0x6da, (u32) (sslpnCalibClkEnCtrl | 0x2008)); - stpptr = R_REG(&pi->regs->smpl_clct_stpptr); - curptr = R_REG(&pi->regs->smpl_clct_curptr); + stpptr = bcma_read16(pi->d11core, D11REGOFFS(smpl_clct_stpptr)); + curptr = bcma_read16(pi->d11core, D11REGOFFS(smpl_clct_curptr)); do { udelay(10); - curptr = R_REG(&pi->regs->smpl_clct_curptr); + curptr = bcma_read16(pi->d11core, D11REGOFFS(smpl_clct_curptr)); timer++; } while ((curptr != stpptr) && (timer < 500)); - W_REG(&pi->regs->psm_phy_hdr_param, 0x2); + bcma_write16(pi->d11core, D11REGOFFS(psm_phy_hdr_param), 0x2); strptr = 0x7E00; - W_REG(&pi->regs->tplatewrptr, strptr); + bcma_write32(pi->d11core, D11REGOFFS(tplatewrptr), strptr); while (strptr < 0x8000) { - val = R_REG(&pi->regs->tplatewrdata); + val = bcma_read32(pi->d11core, D11REGOFFS(tplatewrdata)); imag = ((val >> 16) & 0x3ff); real = ((val) & 0x3ff); if (imag > 511) @@ -3597,8 +3598,8 @@ wlc_lcnphy_samp_cap(struct brcms_phy *pi, int clip_detect_algo, u16 thresh, } write_phy_reg(pi, 0x6da, old_sslpnCalibClkEnCtrl); - W_REG(&pi->regs->psm_phy_hdr_param, curval2); - W_REG(&pi->regs->psm_corectlsts, curval1); + bcma_write16(pi->d11core, D11REGOFFS(psm_phy_hdr_param), curval2); + bcma_write16(pi->d11core, D11REGOFFS(psm_corectlsts), curval1); } static void @@ -3968,9 +3969,9 @@ s16 wlc_lcnphy_tempsense_new(struct brcms_phy *pi, bool mode) bool suspend = 0; if (mode == 1) { - suspend = - (0 == - (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); + suspend = (0 == (bcma_read32(pi->d11core, + D11REGOFFS(maccontrol)) & + MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); wlc_lcnphy_vbat_temp_sense_setup(pi, TEMPSENSE); @@ -4012,9 +4013,9 @@ u16 wlc_lcnphy_tempsense(struct brcms_phy *pi, bool mode) struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; if (mode == 1) { - suspend = - (0 == - (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); + suspend = (0 == (bcma_read32(pi->d11core, + D11REGOFFS(maccontrol)) & + MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); wlc_lcnphy_vbat_temp_sense_setup(pi, TEMPSENSE); @@ -4078,9 +4079,9 @@ s8 wlc_lcnphy_vbatsense(struct brcms_phy *pi, bool mode) bool suspend = 0; if (mode == 1) { - suspend = - (0 == - (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); + suspend = (0 == (bcma_read32(pi->d11core, + D11REGOFFS(maccontrol)) & + MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); wlc_lcnphy_vbat_temp_sense_setup(pi, VBATSENSE); @@ -4127,8 +4128,8 @@ static void wlc_lcnphy_glacial_timer_based_cal(struct brcms_phy *pi) s8 index; u16 SAVE_pwrctrl = wlc_lcnphy_get_tx_pwr_ctrl(pi); struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; - suspend = - (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); + suspend = (0 == (bcma_read32(pi->d11core, D11REGOFFS(maccontrol)) & + MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); wlc_lcnphy_deaf_mode(pi, true); @@ -4166,8 +4167,8 @@ static void wlc_lcnphy_periodic_cal(struct brcms_phy *pi) pi_lcn->lcnphy_full_cal_channel = CHSPEC_CHANNEL(pi->radio_chanspec); index = pi_lcn->lcnphy_current_index; - suspend = - (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); + suspend = (0 == (bcma_read32(pi->d11core, D11REGOFFS(maccontrol)) & + MCTL_EN_MAC)); if (!suspend) { wlapi_bmac_write_shm(pi->sh->physhim, M_CTS_DURATION, 10000); wlapi_suspend_mac_and_wait(pi->sh->physhim); diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c index ec9b56639d54..7a2091991f76 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c @@ -17802,7 +17802,7 @@ static void wlc_phy_txpwrctrl_pwr_setup_nphy(struct brcms_phy *pi) if (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) { wlapi_bmac_mctrl(pi->sh->physhim, MCTL_PHYLOCK, MCTL_PHYLOCK); - (void)R_REG(&pi->regs->maccontrol); + (void)bcma_read32(pi->d11core, D11REGOFFS(maccontrol)); udelay(1); } @@ -17953,7 +17953,7 @@ static void wlc_phy_txpwrctrl_pwr_setup_nphy(struct brcms_phy *pi) if (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) { wlapi_bmac_mctrl(pi->sh->physhim, MCTL_PHYLOCK, MCTL_PHYLOCK); - (void)R_REG(&pi->regs->maccontrol); + (void)bcma_read32(pi->d11core, D11REGOFFS(maccontrol)); udelay(1); } @@ -19448,7 +19448,6 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) bool do_nphy_cal = false; uint core; uint origidx, intr_val; - struct d11regs __iomem *regs; u32 d11_clk_ctl_st; bool do_rssi_cal = false; @@ -19470,15 +19469,15 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) if ((pi->nphy_gband_spurwar2_en) && CHSPEC_IS2G(pi->radio_chanspec) && CHSPEC_IS40(pi->radio_chanspec)) { - regs = (struct d11regs __iomem *) - ai_switch_core(pi->sh->sih, - D11_CORE_ID, &origidx, - &intr_val); - d11_clk_ctl_st = R_REG(®s->clk_ctl_st); - AND_REG(®s->clk_ctl_st, - ~(CCS_FORCEHT | CCS_HTAREQ)); + ai_switch_core(pi->sh->sih, D11_CORE_ID, &origidx, &intr_val); - W_REG(®s->clk_ctl_st, d11_clk_ctl_st); + d11_clk_ctl_st = bcma_read32(pi->d11core, + D11REGOFFS(clk_ctl_st)); + bcma_mask32(pi->d11core, D11REGOFFS(clk_ctl_st), + ~(CCS_FORCEHT | CCS_HTAREQ)); + + bcma_write32(pi->d11core, D11REGOFFS(clk_ctl_st), + d11_clk_ctl_st); ai_restore_core(pi->sh->sih, origidx, intr_val); } @@ -19885,7 +19884,8 @@ void wlc_phy_rxcore_setstate_nphy(struct brcms_phy_pub *pih, u8 rxcore_bitmask) if (!pi->sh->clk) return; - suspend = (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); + suspend = (0 == (bcma_read32(pi->d11core, D11REGOFFS(maccontrol)) & + MCTL_EN_MAC)); if (!suspend) wlapi_suspend_mac_and_wait(pi->sh->physhim); @@ -21263,28 +21263,28 @@ wlc_phy_chanspec_nphy_setup(struct brcms_phy *pi, u16 chanspec, val = read_phy_reg(pi, 0x09) & NPHY_BandControl_currentBand; if (CHSPEC_IS5G(chanspec) && !val) { - val = R_REG(&pi->regs->psm_phy_hdr_param); - W_REG(&pi->regs->psm_phy_hdr_param, + val = bcma_read16(pi->d11core, D11REGOFFS(psm_phy_hdr_param)); + bcma_write16(pi->d11core, D11REGOFFS(psm_phy_hdr_param), (val | MAC_PHY_FORCE_CLK)); or_phy_reg(pi, (NPHY_TO_BPHY_OFF + BPHY_BB_CONFIG), (BBCFG_RESETCCA | BBCFG_RESETRX)); - W_REG(&pi->regs->psm_phy_hdr_param, val); + bcma_write16(pi->d11core, D11REGOFFS(psm_phy_hdr_param), val); or_phy_reg(pi, 0x09, NPHY_BandControl_currentBand); } else if (!CHSPEC_IS5G(chanspec) && val) { and_phy_reg(pi, 0x09, ~NPHY_BandControl_currentBand); - val = R_REG(&pi->regs->psm_phy_hdr_param); - W_REG(&pi->regs->psm_phy_hdr_param, + val = bcma_read16(pi->d11core, D11REGOFFS(psm_phy_hdr_param)); + bcma_write16(pi->d11core, D11REGOFFS(psm_phy_hdr_param), (val | MAC_PHY_FORCE_CLK)); and_phy_reg(pi, (NPHY_TO_BPHY_OFF + BPHY_BB_CONFIG), (u16) (~(BBCFG_RESETCCA | BBCFG_RESETRX))); - W_REG(&pi->regs->psm_phy_hdr_param, val); + bcma_write16(pi->d11core, D11REGOFFS(psm_phy_hdr_param), val); } write_phy_reg(pi, 0x1ce, ci->PHY_BW1a); @@ -21347,19 +21347,18 @@ wlc_phy_chanspec_nphy_setup(struct brcms_phy *pi, u16 chanspec, if ((pi->sh->chip == BCM43224_CHIP_ID) || (pi->sh->chip == BCM43225_CHIP_ID)) { - if (spuravoid == 1) { - - W_REG(&pi->regs->tsf_clk_frac_l, - 0x5341); - W_REG(&pi->regs->tsf_clk_frac_h, - 0x8); + bcma_write16(pi->d11core, + D11REGOFFS(tsf_clk_frac_l), + 0x5341); + bcma_write16(pi->d11core, + D11REGOFFS(tsf_clk_frac_h), 0x8); } else { - - W_REG(&pi->regs->tsf_clk_frac_l, - 0x8889); - W_REG(&pi->regs->tsf_clk_frac_h, - 0x8); + bcma_write16(pi->d11core, + D11REGOFFS(tsf_clk_frac_l), + 0x8889); + bcma_write16(pi->d11core, + D11REGOFFS(tsf_clk_frac_h), 0x8); } } @@ -21499,13 +21498,13 @@ void wlc_phy_antsel_init(struct brcms_phy_pub *ppi, bool lut_init) ai_gpiocontrol(pi->sh->sih, mask, mask, GPIO_DRV_PRIORITY); - mc = R_REG(&pi->regs->maccontrol); + mc = bcma_read32(pi->d11core, D11REGOFFS(maccontrol)); mc &= ~MCTL_GPOUT_SEL_MASK; - W_REG(&pi->regs->maccontrol, mc); + bcma_write32(pi->d11core, D11REGOFFS(maccontrol), mc); - OR_REG(&pi->regs->psm_gpio_oe, mask); + bcma_set16(pi->d11core, D11REGOFFS(psm_gpio_oe), mask); - AND_REG(&pi->regs->psm_gpio_out, ~mask); + bcma_mask16(pi->d11core, D11REGOFFS(psm_gpio_out), ~mask); if (lut_init) { write_phy_reg(pi, 0xf8, 0x02d8); @@ -21522,9 +21521,8 @@ u16 wlc_phy_classifier_nphy(struct brcms_phy *pi, u16 mask, u16 val) bool suspended = false; if (D11REV_IS(pi->sh->corerev, 16)) { - suspended = - (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC) ? - false : true; + suspended = (bcma_read32(pi->d11core, D11REGOFFS(maccontrol)) & + MCTL_EN_MAC) ? false : true; if (!suspended) wlapi_suspend_mac_and_wait(pi->sh->physhim); } @@ -25383,7 +25381,8 @@ static void wlc_phy_a4(struct brcms_phy *pi, bool full_cal) if (pi->nphy_papd_skip == 1) return; - phy_b3 = (0 == (R_REG(&pi->regs->maccontrol) & MCTL_EN_MAC)); + phy_b3 = (0 == (bcma_read32(pi->d11core, D11REGOFFS(maccontrol)) & + MCTL_EN_MAC)); if (!phy_b3) wlapi_suspend_mac_and_wait(pi->sh->physhim); @@ -28357,7 +28356,7 @@ void wlc_phy_txpower_recalc_target_nphy(struct brcms_phy *pi) if (D11REV_IS(pi->sh->corerev, 11) || D11REV_IS(pi->sh->corerev, 12)) { wlapi_bmac_mctrl(pi->sh->physhim, MCTL_PHYLOCK, MCTL_PHYLOCK); - (void)R_REG(&pi->regs->maccontrol); + (void)bcma_read32(pi->d11core, D11REGOFFS(maccontrol)); udelay(1); } diff --git a/drivers/net/wireless/brcm80211/brcmsmac/types.h b/drivers/net/wireless/brcm80211/brcmsmac/types.h index 27a814b07462..e64971a759d3 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/types.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/types.h @@ -300,8 +300,11 @@ do { \ * in the code. Older chips and the newer 5357 family don't require this fix. */ #define W_REG_FLUSH(r, v) ({ W_REG((r), (v)); (void)R_REG(r); }) +#define bcma_wflush16(c, o, v) \ + ({ bcma_write16(c, o, v); (void)bcma_read16(c, o); }) #else #define W_REG_FLUSH(r, v) W_REG((r), (v)) +#define bcma_wflush16(c, o, v) bcma_write16(c, o, v) #endif /* CONFIG_BCM47XX */ #define AND_REG(r, v) W_REG((r), R_REG(r) & (v)) -- cgit v1.2.3 From ad5db1317c04ece569d18c692f8e49453c552d1e Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 8 Dec 2011 15:06:55 -0800 Subject: brcm80211: smac: remove SI_FAST() macro usage The use of SI_FAST() macro interferes with the BCMA integration as it causes BCMA and aiutils.c to get out of sync on what the current core is. When everything is using BCMA we will try to add SI_FAST functionality to BCMA to avoid unnecessary core switching. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 157 +++++----------------- 1 file changed, 35 insertions(+), 122 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c index ef1441a9a4e0..7aa47b3252c2 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c @@ -318,16 +318,6 @@ #define BADIDX (SI_MAXCORES + 1) -/* Newer chips can access PCI/PCIE and CC core without requiring to change - * PCI BAR0 WIN - */ -#define SI_FAST(sih) ((ai_get_buscoretype(sih) == PCIE_CORE_ID) || \ - ((ai_get_buscoretype(sih) == PCI_CORE_ID) && \ - ai_get_buscorerev(sih) >= 13)) - -#define CCREGS_FAST(si) (((char __iomem *)((si)->curmap) + \ - PCI_16KB0_CCREGS_OFFSET)) - #define IS_SIM(chippkg) \ ((chippkg == HDLSIM_PKG_ID) || (chippkg == HWSIM_PKG_ID)) @@ -360,9 +350,6 @@ (((x) >= (b)) && ((x) < ((b) + SI_MAXCORES * SI_CORE_SIZE)) && \ IS_ALIGNED((x), SI_CORE_SIZE)) -#define PCIEREGS(si) ((__iomem char *)((si)->curmap) + \ - PCI_16KB0_PCIREGS_OFFSET) - struct aidmp { u32 oobselina30; /* 0x000 */ u32 oobselina74; /* 0x004 */ @@ -777,13 +764,11 @@ ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx) } /* fixup necessary chip/core configurations */ - if (SI_FAST(&sii->pub)) { - if (!sii->pch) { - sii->pch = pcicore_init(&sii->pub, sii->pcibus, - (__iomem void *)PCIEREGS(sii)); - if (sii->pch == NULL) - return false; - } + if (!sii->pch) { + sii->pch = pcicore_init(&sii->pub, sii->pcibus, + sii->curmap + PCI_16KB0_PCIREGS_OFFSET); + if (sii->pch == NULL) + return false; } if (ai_pci_fixcfg(&sii->pub)) { /* si_doattach: si_pci_fixcfg failed */ @@ -1084,17 +1069,6 @@ void __iomem *ai_switch_core(struct si_pub *sih, uint coreid, uint *origidx, sii = (struct si_info *)sih; - if (SI_FAST(sih)) { - /* Overloading the origidx variable to remember the coreid, - * this works because the core ids cannot be confused with - * core indices. - */ - *origidx = coreid; - if (coreid == CC_CORE_ID) - return CCREGS_FAST(sii); - else if (coreid == ai_get_buscoretype(sih)) - return PCIEREGS(sii); - } INTR_OFF(sii, *intr_val); *origidx = sii->curidx; cc = ai_setcore(sih, coreid, 0); @@ -1107,9 +1081,6 @@ void ai_restore_core(struct si_pub *sih, uint coreid, uint intr_val) struct si_info *sii; sii = (struct si_info *)sih; - if (SI_FAST(sih) - && ((coreid == CC_CORE_ID) || (coreid == ai_get_buscoretype(sih)))) - return; ai_setcoreidx(sih, coreid); INTR_RESTORE(sii, intr_val); @@ -1140,7 +1111,6 @@ uint ai_corereg(struct si_pub *sih, uint coreidx, uint regoff, uint mask, u32 __iomem *r = NULL; uint w; uint intr_val = 0; - bool fast = false; struct si_info *sii; sii = (struct si_info *)sih; @@ -1148,41 +1118,14 @@ uint ai_corereg(struct si_pub *sih, uint coreidx, uint regoff, uint mask, if (coreidx >= SI_MAXCORES) return 0; - /* - * If pci/pcie, we can get at pci/pcie regs - * and on newer cores to chipc - */ - if ((sii->coreid[coreidx] == CC_CORE_ID) && SI_FAST(sih)) { - /* Chipc registers are mapped at 12KB */ - fast = true; - r = (u32 __iomem *)((__iomem char *)sii->curmap + - PCI_16KB0_CCREGS_OFFSET + regoff); - } else if (sii->buscoreidx == coreidx) { - /* - * pci registers are at either in the last 2KB of - * an 8KB window or, in pcie and pci rev 13 at 8KB - */ - fast = true; - if (SI_FAST(sih)) - r = (u32 __iomem *)((__iomem char *)sii->curmap + - PCI_16KB0_PCIREGS_OFFSET + regoff); - else - r = (u32 __iomem *)((__iomem char *)sii->curmap + - ((regoff >= SBCONFIGOFF) ? - PCI_BAR0_PCISBR_OFFSET : - PCI_BAR0_PCIREGS_OFFSET) + regoff); - } - - if (!fast) { - INTR_OFF(sii, intr_val); + INTR_OFF(sii, intr_val); - /* save current core index */ - origidx = ai_coreidx(&sii->pub); + /* save current core index */ + origidx = ai_coreidx(&sii->pub); - /* switch core */ - r = (u32 __iomem *) ((unsigned char __iomem *) - ai_setcoreidx(&sii->pub, coreidx) + regoff); - } + /* switch core */ + r = (u32 __iomem *) ((unsigned char __iomem *) + ai_setcoreidx(&sii->pub, coreidx) + regoff); /* mask and set */ if (mask || val) { @@ -1193,13 +1136,11 @@ uint ai_corereg(struct si_pub *sih, uint coreidx, uint regoff, uint mask, /* readback */ w = R_REG(r); - if (!fast) { - /* restore core index */ - if (origidx != coreidx) - ai_setcoreidx(&sii->pub, origidx); + /* restore core index */ + if (origidx != coreidx) + ai_setcoreidx(&sii->pub, origidx); - INTR_RESTORE(sii, intr_val); - } + INTR_RESTORE(sii, intr_val); return w; } @@ -1354,24 +1295,16 @@ void ai_clkctl_init(struct si_pub *sih) struct si_info *sii; uint origidx = 0; struct chipcregs __iomem *cc; - bool fast; if (!(ai_get_cccaps(sih) & CC_CAP_PWR_CTL)) return; sii = (struct si_info *)sih; - fast = SI_FAST(sih); - if (!fast) { - origidx = sii->curidx; - cc = (struct chipcregs __iomem *) - ai_setcore(sih, CC_CORE_ID, 0); - if (cc == NULL) - return; - } else { - cc = (struct chipcregs __iomem *) CCREGS_FAST(sii); - if (cc == NULL) - return; - } + origidx = sii->curidx; + cc = (struct chipcregs __iomem *) + ai_setcore(sih, CC_CORE_ID, 0); + if (cc == NULL) + return; /* set all Instaclk chip ILP to 1 MHz */ if (ai_get_ccrev(sih) >= 10) @@ -1380,8 +1313,7 @@ void ai_clkctl_init(struct si_pub *sih) ai_clkctl_setdelay(sii, cc); - if (!fast) - ai_setcoreidx(sih, origidx); + ai_setcoreidx(sih, origidx); } /* @@ -1396,7 +1328,6 @@ u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih) uint slowminfreq; u16 fpdelay; uint intr_val = 0; - bool fast; sii = (struct si_info *)sih; if (ai_get_cccaps(sih) & CC_CAP_PMU) { @@ -1409,30 +1340,21 @@ u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih) if (!(ai_get_cccaps(sih) & CC_CAP_PWR_CTL)) return 0; - fast = SI_FAST(sih); fpdelay = 0; - if (!fast) { - origidx = sii->curidx; - INTR_OFF(sii, intr_val); - cc = (struct chipcregs __iomem *) - ai_setcore(sih, CC_CORE_ID, 0); - if (cc == NULL) - goto done; - } else { - cc = (struct chipcregs __iomem *) CCREGS_FAST(sii); - if (cc == NULL) - goto done; - } + origidx = sii->curidx; + INTR_OFF(sii, intr_val); + cc = (struct chipcregs __iomem *) + ai_setcore(sih, CC_CORE_ID, 0); + if (cc == NULL) + goto done; slowminfreq = ai_slowclk_freq(sii, false, cc); fpdelay = (((R_REG(&cc->pll_on_delay) + 2) * 1000000) + (slowminfreq - 1)) / slowminfreq; done: - if (!fast) { - ai_setcoreidx(sih, origidx); - INTR_RESTORE(sii, intr_val); - } + ai_setcoreidx(sih, origidx); + INTR_RESTORE(sii, intr_val); return fpdelay; } @@ -1506,22 +1428,15 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode) struct chipcregs __iomem *cc; u32 scc; uint intr_val = 0; - bool fast = SI_FAST(&sii->pub); /* chipcommon cores prior to rev6 don't support dynamic clock control */ if (ai_get_ccrev(&sii->pub) < 6) return false; - if (!fast) { - INTR_OFF(sii, intr_val); - origidx = sii->curidx; - cc = (struct chipcregs __iomem *) - ai_setcore(&sii->pub, CC_CORE_ID, 0); - } else { - cc = (struct chipcregs __iomem *) CCREGS_FAST(sii); - if (cc == NULL) - goto done; - } + INTR_OFF(sii, intr_val); + origidx = sii->curidx; + cc = (struct chipcregs __iomem *) + ai_setcore(&sii->pub, CC_CORE_ID, 0); if (!(ai_get_cccaps(&sii->pub) & CC_CAP_PWR_CTL) && (ai_get_ccrev(&sii->pub) < 20)) @@ -1580,10 +1495,8 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode) } done: - if (!fast) { - ai_setcoreidx(&sii->pub, origidx); - INTR_RESTORE(sii, intr_val); - } + ai_setcoreidx(&sii->pub, origidx); + INTR_RESTORE(sii, intr_val); return mode == CLK_FAST; } -- cgit v1.2.3 From 7d8e18e456466c2247abe0658e4add598f85c98e Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 8 Dec 2011 15:06:56 -0800 Subject: brcm80211: smac: replace ai_corereg() function with ai_cc_reg() The ai_corereg() function is only used in the driver to safely access the chipcommon core. The function has been renamed to ai_cc_reg() removing the need to provide a core index parameter. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 36 ++++++++-------------- drivers/net/wireless/brcm80211/brcmsmac/aiutils.h | 5 +-- drivers/net/wireless/brcm80211/brcmsmac/main.c | 16 +++++----- drivers/net/wireless/brcm80211/brcmsmac/nicpci.c | 28 ++++++++--------- .../net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c | 36 +++++++++++----------- .../net/wireless/brcm80211/brcmsmac/phy/phy_n.c | 6 ++-- drivers/net/wireless/brcm80211/brcmsmac/pmu.c | 28 +++++++---------- 7 files changed, 68 insertions(+), 87 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c index 7aa47b3252c2..d72e99322bb1 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c @@ -885,8 +885,8 @@ static struct si_info *ai_doattach(struct si_info *sii, w = getintvar(sih, BRCMS_SROM_LEDDC); if (w == 0) w = DEFAULT_GPIOTIMERVAL; - ai_corereg(sih, SI_CC_IDX, offsetof(struct chipcregs, gpiotimerval), - ~0, w); + ai_cc_reg(sih, offsetof(struct chipcregs, gpiotimerval), + ~0, w); if (PCIE(sih)) pcicore_attach(sii->pch, SI_DOATTACH); @@ -898,10 +898,9 @@ static struct si_info *ai_doattach(struct si_info *sii, */ if (ai_get_chiprev(sih) == 0) { SI_MSG("Applying 43224A0 WARs\n"); - ai_corereg(sih, SI_CC_IDX, - offsetof(struct chipcregs, chipcontrol), - CCTRL43224_GPIO_TOGGLE, - CCTRL43224_GPIO_TOGGLE); + ai_cc_reg(sih, offsetof(struct chipcregs, chipcontrol), + CCTRL43224_GPIO_TOGGLE, + CCTRL43224_GPIO_TOGGLE); si_pmu_chipcontrol(sih, 0, CCTRL_43224A0_12MA_LED_DRIVE, CCTRL_43224A0_12MA_LED_DRIVE); } @@ -1104,41 +1103,32 @@ void ai_write_wrapperreg(struct si_pub *sih, u32 offset, u32 val) * Also, when using pci/pcie, we can optimize away the core switching for pci * registers and (on newer pci cores) chipcommon registers. */ -uint ai_corereg(struct si_pub *sih, uint coreidx, uint regoff, uint mask, - uint val) +uint ai_cc_reg(struct si_pub *sih, uint regoff, u32 mask, u32 val) { + struct bcma_device *cc; uint origidx = 0; - u32 __iomem *r = NULL; - uint w; + u32 w; uint intr_val = 0; struct si_info *sii; sii = (struct si_info *)sih; - - if (coreidx >= SI_MAXCORES) - return 0; + cc = sii->icbus->drv_cc.core; INTR_OFF(sii, intr_val); /* save current core index */ origidx = ai_coreidx(&sii->pub); - /* switch core */ - r = (u32 __iomem *) ((unsigned char __iomem *) - ai_setcoreidx(&sii->pub, coreidx) + regoff); - /* mask and set */ if (mask || val) { - w = (R_REG(r) & ~mask) | val; - W_REG(r, w); + bcma_maskset32(cc, regoff, ~mask, val); } /* readback */ - w = R_REG(r); + w = bcma_read32(cc, regoff); /* restore core index */ - if (origidx != coreidx) - ai_setcoreidx(&sii->pub, origidx); + ai_setcoreidx(&sii->pub, origidx); INTR_RESTORE(sii, intr_val); @@ -1664,7 +1654,7 @@ u32 ai_gpiocontrol(struct si_pub *sih, u32 mask, u32 val, u8 priority) uint regoff; regoff = offsetof(struct chipcregs, gpiocontrol); - return ai_corereg(sih, SI_CC_IDX, regoff, mask, val); + return ai_cc_reg(sih, regoff, mask, val); } void ai_chipcontrl_epa4331(struct si_pub *sih, bool on) diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h index 1e93599b6047..792310868f1c 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h @@ -228,8 +228,6 @@ extern bool ai_iscoreup(struct si_pub *sih); extern u32 ai_core_cflags(struct si_pub *sih, u32 mask, u32 val); extern void ai_core_cflags_wo(struct si_pub *sih, u32 mask, u32 val); extern u32 ai_core_sflags(struct si_pub *sih, u32 mask, u32 val); -extern uint ai_corereg(struct si_pub *sih, uint coreidx, uint regoff, uint mask, - uint val); extern void ai_core_reset(struct si_pub *sih, u32 bits, u32 resetbits); extern void ai_core_disable(struct si_pub *sih, u32 bits); extern int ai_numaddrspaces(struct si_pub *sih); @@ -242,8 +240,7 @@ extern struct si_pub *ai_attach(struct bcma_bus *pbus); extern void ai_detach(struct si_pub *sih); extern uint ai_coreid(struct si_pub *sih); extern uint ai_corerev(struct si_pub *sih); -extern uint ai_corereg(struct si_pub *sih, uint coreidx, uint regoff, uint mask, - uint val); +extern uint ai_cc_reg(struct si_pub *sih, uint regoff, u32 mask, u32 val); extern void ai_write_wrapperreg(struct si_pub *sih, u32 offset, u32 val); extern u32 ai_core_cflags(struct si_pub *sih, u32 mask, u32 val); extern u32 ai_core_sflags(struct si_pub *sih, u32 mask, u32 val); diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index 5db2bdc67a56..7ee86d4a056e 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -1709,17 +1709,17 @@ void brcms_b_core_phypll_reset(struct brcms_hardware *wlc_hw) { BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); - ai_corereg(wlc_hw->sih, SI_CC_IDX, - offsetof(struct chipcregs, chipcontrol_addr), ~0, 0); + ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_addr), + ~0, 0); udelay(1); - ai_corereg(wlc_hw->sih, SI_CC_IDX, - offsetof(struct chipcregs, chipcontrol_data), 0x4, 0); + ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_data), + 0x4, 0); udelay(1); - ai_corereg(wlc_hw->sih, SI_CC_IDX, - offsetof(struct chipcregs, chipcontrol_data), 0x4, 4); + ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_data), + 0x4, 4); udelay(1); - ai_corereg(wlc_hw->sih, SI_CC_IDX, - offsetof(struct chipcregs, chipcontrol_data), 0x4, 0); + ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_data), + 0x4, 0); udelay(1); } diff --git a/drivers/net/wireless/brcm80211/brcmsmac/nicpci.c b/drivers/net/wireless/brcm80211/brcmsmac/nicpci.c index 2e8b5a19ace7..6c3a9f9d5207 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/nicpci.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/nicpci.c @@ -530,12 +530,12 @@ static void pcie_clkreq_upd(struct pcicore_info *pi, uint state) case SI_PCIDOWN: /* turn on serdes PLL down */ if (ai_get_buscorerev(sih) == 6) { - ai_corereg(sih, SI_CC_IDX, - offsetof(struct chipcregs, chipcontrol_addr), - ~0, 0); - ai_corereg(sih, SI_CC_IDX, - offsetof(struct chipcregs, chipcontrol_data), - ~0x40, 0); + ai_cc_reg(sih, + offsetof(struct chipcregs, chipcontrol_addr), + ~0, 0); + ai_cc_reg(sih, + offsetof(struct chipcregs, chipcontrol_data), + ~0x40, 0); } else if (pi->pcie_pr42767) { pcie_clkreq(pi, 1, 1); } @@ -543,12 +543,12 @@ static void pcie_clkreq_upd(struct pcicore_info *pi, uint state) case SI_PCIUP: /* turn off serdes PLL down */ if (ai_get_buscorerev(sih) == 6) { - ai_corereg(sih, SI_CC_IDX, - offsetof(struct chipcregs, chipcontrol_addr), - ~0, 0); - ai_corereg(sih, SI_CC_IDX, - offsetof(struct chipcregs, chipcontrol_data), - ~0x40, 0x40); + ai_cc_reg(sih, + offsetof(struct chipcregs, chipcontrol_addr), + ~0, 0); + ai_cc_reg(sih, + offsetof(struct chipcregs, chipcontrol_data), + ~0x40, 0x40); } else if (PCIE_ASPM(sih)) { /* disable clkreq */ pcie_clkreq(pi, 1, 0); } @@ -666,8 +666,8 @@ static void pcie_war_noplldown(struct pcicore_info *pi) u16 __iomem *reg16; /* turn off serdes PLL down */ - ai_corereg(pi->sih, SI_CC_IDX, offsetof(struct chipcregs, chipcontrol), - CHIPCTRL_4321_PLL_DOWN, CHIPCTRL_4321_PLL_DOWN); + ai_cc_reg(pi->sih, offsetof(struct chipcregs, chipcontrol), + CHIPCTRL_4321_PLL_DOWN, CHIPCTRL_4321_PLL_DOWN); /* clear srom shadow backdoor */ reg16 = &pcieregs->sprom[SRSH_BD_OFFSET]; diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c index 8054ce253edc..5139820b88a7 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c @@ -2905,29 +2905,29 @@ void wlc_lcnphy_epa_switch(struct brcms_phy *pi, bool mode) mod_phy_reg(pi, 0x44c, (0x1 << 2), (1) << 2); } - ai_corereg(pi->sh->sih, SI_CC_IDX, - offsetof(struct chipcregs, gpiocontrol), - ~0x0, 0x0); - ai_corereg(pi->sh->sih, SI_CC_IDX, - offsetof(struct chipcregs, gpioout), 0x40, - 0x40); - ai_corereg(pi->sh->sih, SI_CC_IDX, - offsetof(struct chipcregs, gpioouten), 0x40, - 0x40); + ai_cc_reg(pi->sh->sih, + offsetof(struct chipcregs, gpiocontrol), + ~0x0, 0x0); + ai_cc_reg(pi->sh->sih, + offsetof(struct chipcregs, gpioout), + 0x40, 0x40); + ai_cc_reg(pi->sh->sih, + offsetof(struct chipcregs, gpioouten), + 0x40, 0x40); } else { mod_phy_reg(pi, 0x44c, (0x1 << 2), (0) << 2); mod_phy_reg(pi, 0x44d, (0x1 << 2), (0) << 2); - ai_corereg(pi->sh->sih, SI_CC_IDX, - offsetof(struct chipcregs, gpioout), 0x40, - 0x00); - ai_corereg(pi->sh->sih, SI_CC_IDX, - offsetof(struct chipcregs, gpioouten), 0x40, - 0x0); - ai_corereg(pi->sh->sih, SI_CC_IDX, - offsetof(struct chipcregs, gpiocontrol), - ~0x0, 0x40); + ai_cc_reg(pi->sh->sih, + offsetof(struct chipcregs, gpioout), + 0x40, 0x00); + ai_cc_reg(pi->sh->sih, + offsetof(struct chipcregs, gpioouten), + 0x40, 0x0); + ai_cc_reg(pi->sh->sih, + offsetof(struct chipcregs, gpiocontrol), + ~0x0, 0x40); } } } diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c index 7a2091991f76..e0237e497600 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c @@ -19461,9 +19461,9 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) (pi->sh->chippkg == BCM4718_PKG_ID))) { if ((pi->sh->boardflags & BFL_EXTLNA) && (CHSPEC_IS2G(pi->radio_chanspec))) - ai_corereg(pi->sh->sih, SI_CC_IDX, - offsetof(struct chipcregs, chipcontrol), - 0x40, 0x40); + ai_cc_reg(pi->sh->sih, + offsetof(struct chipcregs, chipcontrol), + 0x40, 0x40); } if ((pi->nphy_gband_spurwar2_en) && CHSPEC_IS2G(pi->radio_chanspec) && diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pmu.c b/drivers/net/wireless/brcm80211/brcmsmac/pmu.c index d4e909a6f2ab..ba319f31c9a9 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/pmu.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/pmu.c @@ -236,38 +236,32 @@ void si_pmu_sprom_enable(struct si_pub *sih, bool enable) /* Read/write a chipcontrol reg */ u32 si_pmu_chipcontrol(struct si_pub *sih, uint reg, u32 mask, u32 val) { - ai_corereg(sih, SI_CC_IDX, offsetof(struct chipcregs, chipcontrol_addr), - ~0, reg); - return ai_corereg(sih, SI_CC_IDX, - offsetof(struct chipcregs, chipcontrol_data), mask, - val); + ai_cc_reg(sih, offsetof(struct chipcregs, chipcontrol_addr), ~0, reg); + return ai_cc_reg(sih, offsetof(struct chipcregs, chipcontrol_data), + mask, val); } /* Read/write a regcontrol reg */ u32 si_pmu_regcontrol(struct si_pub *sih, uint reg, u32 mask, u32 val) { - ai_corereg(sih, SI_CC_IDX, offsetof(struct chipcregs, regcontrol_addr), - ~0, reg); - return ai_corereg(sih, SI_CC_IDX, - offsetof(struct chipcregs, regcontrol_data), mask, - val); + ai_cc_reg(sih, offsetof(struct chipcregs, regcontrol_addr), ~0, reg); + return ai_cc_reg(sih, offsetof(struct chipcregs, regcontrol_data), + mask, val); } /* Read/write a pllcontrol reg */ u32 si_pmu_pllcontrol(struct si_pub *sih, uint reg, u32 mask, u32 val) { - ai_corereg(sih, SI_CC_IDX, offsetof(struct chipcregs, pllcontrol_addr), - ~0, reg); - return ai_corereg(sih, SI_CC_IDX, - offsetof(struct chipcregs, pllcontrol_data), mask, - val); + ai_cc_reg(sih, offsetof(struct chipcregs, pllcontrol_addr), ~0, reg); + return ai_cc_reg(sih, offsetof(struct chipcregs, pllcontrol_data), + mask, val); } /* PMU PLL update */ void si_pmu_pllupd(struct si_pub *sih) { - ai_corereg(sih, SI_CC_IDX, offsetof(struct chipcregs, pmucontrol), - PCTL_PLL_PLLCTL_UPD, PCTL_PLL_PLLCTL_UPD); + ai_cc_reg(sih, offsetof(struct chipcregs, pmucontrol), + PCTL_PLL_PLLCTL_UPD, PCTL_PLL_PLLCTL_UPD); } /* query alp/xtal clock frequency */ -- cgit v1.2.3 From 834d5846d1b17114530e2f4e4e0e5a415065f1f8 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 8 Dec 2011 15:06:57 -0800 Subject: brcm80211: smac: remove unused functions and/or prototypes Several functions provided by aiutils.c are not used in brcmsmac driver and have been removed. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 127 +--------------------- drivers/net/wireless/brcm80211/brcmsmac/aiutils.h | 25 ----- 2 files changed, 1 insertion(+), 151 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c index d72e99322bb1..fa8067b0c5ba 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c @@ -525,75 +525,6 @@ void __iomem *ai_setcoreidx(struct si_pub *sih, uint coreidx) return sii->curmap; } -/* Return the number of address spaces in current core */ -int ai_numaddrspaces(struct si_pub *sih) -{ - return 2; -} - -/* Return the address of the nth address space in the current core */ -u32 ai_addrspace(struct si_pub *sih, uint asidx) -{ - struct si_info *sii; - uint cidx; - - sii = (struct si_info *)sih; - cidx = sii->curidx; - - if (asidx == 0) - return sii->coresba[cidx]; - else if (asidx == 1) - return sii->coresba2[cidx]; - else { - /* Need to parse the erom again to find addr space */ - return 0; - } -} - -/* Return the size of the nth address space in the current core */ -u32 ai_addrspacesize(struct si_pub *sih, uint asidx) -{ - struct si_info *sii; - uint cidx; - - sii = (struct si_info *)sih; - cidx = sii->curidx; - - if (asidx == 0) - return sii->coresba_size[cidx]; - else if (asidx == 1) - return sii->coresba2_size[cidx]; - else { - /* Need to parse the erom again to find addr */ - return 0; - } -} - -uint ai_flag(struct si_pub *sih) -{ - struct si_info *sii; - struct aidmp *ai; - - sii = (struct si_info *)sih; - ai = sii->curwrap; - - return R_REG(&ai->oobselouta30) & 0x1f; -} - -void ai_setint(struct si_pub *sih, int siflag) -{ -} - -uint ai_corevendor(struct si_pub *sih) -{ - struct si_info *sii; - u32 cia; - - sii = (struct si_info *)sih; - cia = sii->cia[sii->curidx]; - return (cia & CIA_MFG_MASK) >> CIA_MFG_SHIFT; -} - uint ai_corerev(struct si_pub *sih) { struct si_info *sii; @@ -617,22 +548,6 @@ bool ai_iscoreup(struct si_pub *sih) && ((R_REG(&ai->resetctrl) & AIRC_RESET) == 0)); } -void ai_core_cflags_wo(struct si_pub *sih, u32 mask, u32 val) -{ - struct si_info *sii; - struct aidmp *ai; - u32 w; - - sii = (struct si_info *)sih; - - ai = sii->curwrap; - - if (mask || val) { - w = ((R_REG(&ai->ioctrl) & ~mask) | val); - W_REG(&ai->ioctrl, w); - } -} - u32 ai_core_cflags(struct si_pub *sih, u32 mask, u32 val) { struct si_info *sii; @@ -1016,11 +931,6 @@ uint ai_coreidx(struct si_pub *sih) return sii->curidx; } -bool ai_backplane64(struct si_pub *sih) -{ - return (ai_get_cccaps(sih) & CC_CAP_BKPLN64) != 0; -} - /* return index of coreid or BADIDX if not found */ uint ai_findcoreidx(struct si_pub *sih, uint coreid, uint coreunit) { @@ -1085,14 +995,6 @@ void ai_restore_core(struct si_pub *sih, uint coreid, uint intr_val) INTR_RESTORE(sii, intr_val); } -void ai_write_wrapperreg(struct si_pub *sih, u32 offset, u32 val) -{ - struct si_info *sii = (struct si_info *)sih; - u32 *w = (u32 *) sii->curwrap; - W_REG(w + (offset / 4), val); - return; -} - /* * Switch to 'coreidx', issue a single arbitrary 32bit register mask&set * operation, switch back to the original core, and return the new value. @@ -1514,27 +1416,6 @@ bool ai_clkctl_cc(struct si_pub *sih, uint mode) return _ai_clkctl_cc(sii, mode); } -/* Build device path */ -int ai_devpath(struct si_pub *sih, char *path, int size) -{ - int slen; - - if (!path || size <= 0) - return -1; - - slen = snprintf(path, (size_t) size, "pci/%u/%u/", - ((struct si_info *)sih)->pcibus->bus->number, - PCI_SLOT(((struct pci_dev *) - (((struct si_info *)(sih))->pcibus))->devfn)); - - if (slen < 0 || slen >= size) { - path[0] = '\0'; - return -1; - } - - return 0; -} - void ai_pci_up(struct si_pub *sih) { struct si_info *sii; @@ -1581,7 +1462,7 @@ void ai_pci_setup(struct si_pub *sih, uint coremask) { struct si_info *sii; struct sbpciregs __iomem *regs = NULL; - u32 siflag = 0, w; + u32 w; uint idx = 0; sii = (struct si_info *)sih; @@ -1590,9 +1471,6 @@ void ai_pci_setup(struct si_pub *sih, uint coremask) /* get current core index */ idx = sii->curidx; - /* we interrupt on this backplane flag number */ - siflag = ai_flag(sih); - /* switch over to pci core */ regs = ai_setcoreidx(sih, sii->buscoreidx); } @@ -1606,9 +1484,6 @@ void ai_pci_setup(struct si_pub *sih, uint coremask) pci_read_config_dword(sii->pcibus, PCI_INT_MASK, &w); w |= (coremask << PCI_SBIM_SHIFT); pci_write_config_dword(sii->pcibus, PCI_INT_MASK, w); - } else { - /* set sbintvec bit for our flag number */ - ai_setint(sih, siflag); } if (PCI(sih)) { diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h index 792310868f1c..40d0070fed29 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h @@ -219,21 +219,13 @@ struct si_info { /* AMBA Interconnect exported externs */ -extern uint ai_flag(struct si_pub *sih); -extern void ai_setint(struct si_pub *sih, int siflag); extern uint ai_coreidx(struct si_pub *sih); -extern uint ai_corevendor(struct si_pub *sih); extern uint ai_corerev(struct si_pub *sih); extern bool ai_iscoreup(struct si_pub *sih); extern u32 ai_core_cflags(struct si_pub *sih, u32 mask, u32 val); -extern void ai_core_cflags_wo(struct si_pub *sih, u32 mask, u32 val); extern u32 ai_core_sflags(struct si_pub *sih, u32 mask, u32 val); extern void ai_core_reset(struct si_pub *sih, u32 bits, u32 resetbits); extern void ai_core_disable(struct si_pub *sih, u32 bits); -extern int ai_numaddrspaces(struct si_pub *sih); -extern u32 ai_addrspace(struct si_pub *sih, uint asidx); -extern u32 ai_addrspacesize(struct si_pub *sih, uint asidx); -extern void ai_write_wrap_reg(struct si_pub *sih, u32 offset, u32 val); /* === exported functions === */ extern struct si_pub *ai_attach(struct bcma_bus *pbus); @@ -241,23 +233,13 @@ extern void ai_detach(struct si_pub *sih); extern uint ai_coreid(struct si_pub *sih); extern uint ai_corerev(struct si_pub *sih); extern uint ai_cc_reg(struct si_pub *sih, uint regoff, u32 mask, u32 val); -extern void ai_write_wrapperreg(struct si_pub *sih, u32 offset, u32 val); -extern u32 ai_core_cflags(struct si_pub *sih, u32 mask, u32 val); -extern u32 ai_core_sflags(struct si_pub *sih, u32 mask, u32 val); -extern bool ai_iscoreup(struct si_pub *sih); extern uint ai_findcoreidx(struct si_pub *sih, uint coreid, uint coreunit); extern void __iomem *ai_setcoreidx(struct si_pub *sih, uint coreidx); extern void __iomem *ai_setcore(struct si_pub *sih, uint coreid, uint coreunit); extern void __iomem *ai_switch_core(struct si_pub *sih, uint coreid, uint *origidx, uint *intr_val); extern void ai_restore_core(struct si_pub *sih, uint coreid, uint intr_val); -extern void ai_core_reset(struct si_pub *sih, u32 bits, u32 resetbits); -extern void ai_core_disable(struct si_pub *sih, u32 bits); -extern u32 ai_alp_clock(struct si_pub *sih); -extern u32 ai_ilp_clock(struct si_pub *sih); extern void ai_pci_setup(struct si_pub *sih, uint coremask); -extern void ai_setint(struct si_pub *sih, int siflag); -extern bool ai_backplane64(struct si_pub *sih); extern void ai_register_intr_callback(struct si_pub *sih, void *intrsoff_fn, void *intrsrestore_fn, void *intrsenabled_fn, void *intr_arg); @@ -276,13 +258,6 @@ extern bool ai_is_otp_disabled(struct si_pub *sih); /* SPROM availability */ extern bool ai_is_sprom_available(struct si_pub *sih); -/* - * Build device path. Path size must be >= SI_DEVPATH_BUFSZ. - * The returned path is NULL terminated and has trailing '/'. - * Return 0 on success, nonzero otherwise. - */ -extern int ai_devpath(struct si_pub *sih, char *path, int size); - extern void ai_pci_sleep(struct si_pub *sih); extern void ai_pci_down(struct si_pub *sih); extern void ai_pci_up(struct si_pub *sih); -- cgit v1.2.3 From a8779e4a8e7f0f90ae169393cd72105134ce7c7b Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 8 Dec 2011 15:06:58 -0800 Subject: brcm80211: smac: use bcma core control functions BCMA provides functions to control the state of the cores so using that and remove similar implementation from the driver. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 102 --------------------- drivers/net/wireless/brcm80211/brcmsmac/aiutils.h | 6 +- drivers/net/wireless/brcm80211/brcmsmac/dma.c | 3 +- drivers/net/wireless/brcm80211/brcmsmac/main.c | 72 +++++++++------ .../net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c | 4 +- 5 files changed, 47 insertions(+), 140 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c index fa8067b0c5ba..a68f24a868f9 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c @@ -535,36 +535,6 @@ uint ai_corerev(struct si_pub *sih) return (cib & CIB_REV_MASK) >> CIB_REV_SHIFT; } -bool ai_iscoreup(struct si_pub *sih) -{ - struct si_info *sii; - struct aidmp *ai; - - sii = (struct si_info *)sih; - ai = sii->curwrap; - - return (((R_REG(&ai->ioctrl) & (SICF_FGC | SICF_CLOCK_EN)) == - SICF_CLOCK_EN) - && ((R_REG(&ai->resetctrl) & AIRC_RESET) == 0)); -} - -u32 ai_core_cflags(struct si_pub *sih, u32 mask, u32 val) -{ - struct si_info *sii; - struct aidmp *ai; - u32 w; - - sii = (struct si_info *)sih; - ai = sii->curwrap; - - if (mask || val) { - w = ((R_REG(&ai->ioctrl) & ~mask) | val); - W_REG(&ai->ioctrl, w); - } - - return R_REG(&ai->ioctrl); -} - /* return true if PCIE capability exists in the pci config space */ static bool ai_ispcie(struct si_info *sii) { @@ -587,23 +557,6 @@ static bool ai_buscore_prep(struct si_info *sii) return true; } -u32 ai_core_sflags(struct si_pub *sih, u32 mask, u32 val) -{ - struct si_info *sii; - struct aidmp *ai; - u32 w; - - sii = (struct si_info *)sih; - ai = sii->curwrap; - - if (mask || val) { - w = ((R_REG(&ai->iostatus) & ~mask) | val); - W_REG(&ai->iostatus, w); - } - - return R_REG(&ai->iostatus); -} - static bool ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx) { @@ -1037,61 +990,6 @@ uint ai_cc_reg(struct si_pub *sih, uint regoff, u32 mask, u32 val) return w; } -void ai_core_disable(struct si_pub *sih, u32 bits) -{ - struct si_info *sii; - u32 dummy; - struct aidmp *ai; - - sii = (struct si_info *)sih; - - ai = sii->curwrap; - - /* if core is already in reset, just return */ - if (R_REG(&ai->resetctrl) & AIRC_RESET) - return; - - W_REG(&ai->ioctrl, bits); - dummy = R_REG(&ai->ioctrl); - udelay(10); - - W_REG(&ai->resetctrl, AIRC_RESET); - udelay(1); -} - -/* reset and re-enable a core - * inputs: - * bits - core specific bits that are set during and after reset sequence - * resetbits - core specific bits that are set only during reset sequence - */ -void ai_core_reset(struct si_pub *sih, u32 bits, u32 resetbits) -{ - struct si_info *sii; - struct aidmp *ai; - u32 dummy; - - sii = (struct si_info *)sih; - ai = sii->curwrap; - - /* - * Must do the disable sequence first to work - * for arbitrary current core state. - */ - ai_core_disable(sih, (bits | resetbits)); - - /* - * Now do the initialization sequence. - */ - W_REG(&ai->ioctrl, (bits | SICF_FGC | SICF_CLOCK_EN)); - dummy = R_REG(&ai->ioctrl); - W_REG(&ai->resetctrl, 0); - udelay(1); - - W_REG(&ai->ioctrl, (bits | SICF_CLOCK_EN)); - dummy = R_REG(&ai->ioctrl); - udelay(1); -} - /* return the slow clock source - LPO, XTAL, or PCI */ static uint ai_slowclk_src(struct si_info *sii) { diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h index 40d0070fed29..67b378f2f57e 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h @@ -221,11 +221,7 @@ struct si_info { /* AMBA Interconnect exported externs */ extern uint ai_coreidx(struct si_pub *sih); extern uint ai_corerev(struct si_pub *sih); -extern bool ai_iscoreup(struct si_pub *sih); -extern u32 ai_core_cflags(struct si_pub *sih, u32 mask, u32 val); -extern u32 ai_core_sflags(struct si_pub *sih, u32 mask, u32 val); -extern void ai_core_reset(struct si_pub *sih, u32 bits, u32 resetbits); -extern void ai_core_disable(struct si_pub *sih, u32 bits); +extern u32 ai_core_cflags(struct bcma_device *core, u32 mask, u32 val); /* === exported functions === */ extern struct si_pub *ai_attach(struct bcma_bus *pbus); diff --git a/drivers/net/wireless/brcm80211/brcmsmac/dma.c b/drivers/net/wireless/brcm80211/brcmsmac/dma.c index dfcd9cf5af1a..dab04bbedc8b 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/dma.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/dma.c @@ -581,7 +581,8 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, di->msg_level = msg_level ? msg_level : &dma_msg_level; - di->dma64 = ((ai_core_sflags(sih, 0, 0) & SISF_DMA64) == SISF_DMA64); + di->dma64 = + ((bcma_aread32(d11core, BCMA_IOST) & SISF_DMA64) == SISF_DMA64); /* init dma reg info */ di->d11core = d11core; diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index 7ee86d4a056e..d974809fafc3 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -738,6 +738,14 @@ static void brcms_c_ucode_bsinit(struct brcms_hardware *wlc_hw) } } +static void brcms_b_core_ioctl(struct brcms_hardware *wlc_hw, u32 m, u32 v) +{ + struct bcma_device *core = wlc_hw->d11core; + u32 ioctl = bcma_aread32(core, BCMA_IOCTL) & ~m; + + bcma_awrite32(core, BCMA_IOCTL, ioctl | v); +} + static void brcms_b_core_phy_clk(struct brcms_hardware *wlc_hw, bool clk) { BCMMSG(wlc_hw->wlc->wiphy, "wl%d: clk %d\n", wlc_hw->unit, clk); @@ -746,17 +754,17 @@ static void brcms_b_core_phy_clk(struct brcms_hardware *wlc_hw, bool clk) if (OFF == clk) { /* clear gmode bit, put phy into reset */ - ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC | SICF_GMODE), - (SICF_PRST | SICF_FGC)); + brcms_b_core_ioctl(wlc_hw, (SICF_PRST | SICF_FGC | SICF_GMODE), + (SICF_PRST | SICF_FGC)); udelay(1); - ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC), SICF_PRST); + brcms_b_core_ioctl(wlc_hw, (SICF_PRST | SICF_FGC), SICF_PRST); udelay(1); } else { /* take phy out of reset */ - ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_FGC), SICF_FGC); + brcms_b_core_ioctl(wlc_hw, (SICF_PRST | SICF_FGC), SICF_FGC); udelay(1); - ai_core_cflags(wlc_hw->sih, (SICF_FGC), 0); + brcms_b_core_ioctl(wlc_hw, SICF_FGC, 0); udelay(1); } @@ -777,9 +785,14 @@ static void brcms_c_setxband(struct brcms_hardware *wlc_hw, uint bandunit) wlc_hw->wlc->band = wlc_hw->wlc->bandstate[bandunit]; /* set gmode core flag */ - if (wlc_hw->sbclk && !wlc_hw->noreset) - ai_core_cflags(wlc_hw->sih, SICF_GMODE, - ((bandunit == 0) ? SICF_GMODE : 0)); + if (wlc_hw->sbclk && !wlc_hw->noreset) { + u32 gmode = 0; + + if (bandunit == 0) + gmode = SICF_GMODE; + + brcms_b_core_ioctl(wlc_hw, SICF_GMODE, gmode); + } } /* switch to new band but leave it inactive */ @@ -1257,7 +1270,7 @@ static void brcms_b_clkctl_clk(struct brcms_hardware *wlc_hw, uint mode) /* check fast clock is available (if core is not in reset) */ if (wlc_hw->forcefastclk && wlc_hw->clk) - WARN_ON(!(ai_core_sflags(wlc_hw->sih, 0, 0) & + WARN_ON(!(bcma_aread32(wlc_hw->d11core, BCMA_IOST) & SISF_FCLKA)); /* @@ -1733,18 +1746,18 @@ void brcms_b_phyclk_fgc(struct brcms_hardware *wlc_hw, bool clk) return; if (ON == clk) - ai_core_cflags(wlc_hw->sih, SICF_FGC, SICF_FGC); + brcms_b_core_ioctl(wlc_hw, SICF_FGC, SICF_FGC); else - ai_core_cflags(wlc_hw->sih, SICF_FGC, 0); + brcms_b_core_ioctl(wlc_hw, SICF_FGC, 0); } void brcms_b_macphyclk_set(struct brcms_hardware *wlc_hw, bool clk) { if (ON == clk) - ai_core_cflags(wlc_hw->sih, SICF_MPCLKE, SICF_MPCLKE); + brcms_b_core_ioctl(wlc_hw, SICF_MPCLKE, SICF_MPCLKE); else - ai_core_cflags(wlc_hw->sih, SICF_MPCLKE, 0); + brcms_b_core_ioctl(wlc_hw, SICF_MPCLKE, 0); } void brcms_b_phy_reset(struct brcms_hardware *wlc_hw) @@ -1764,7 +1777,7 @@ void brcms_b_phy_reset(struct brcms_hardware *wlc_hw) if (BRCMS_ISNPHY(wlc_hw->band) && NREV_GE(wlc_hw->band->phyrev, 3) && NREV_LE(wlc_hw->band->phyrev, 4)) { /* Set the PHY bandwidth */ - ai_core_cflags(wlc_hw->sih, SICF_BWMASK, phy_bw_clkbits); + brcms_b_core_ioctl(wlc_hw, SICF_BWMASK, phy_bw_clkbits); udelay(1); @@ -1772,13 +1785,13 @@ void brcms_b_phy_reset(struct brcms_hardware *wlc_hw) brcms_b_core_phypll_reset(wlc_hw); /* reset the PHY */ - ai_core_cflags(wlc_hw->sih, (SICF_PRST | SICF_PCLKE), - (SICF_PRST | SICF_PCLKE)); + brcms_b_core_ioctl(wlc_hw, (SICF_PRST | SICF_PCLKE), + (SICF_PRST | SICF_PCLKE)); phy_in_reset = true; } else { - ai_core_cflags(wlc_hw->sih, - (SICF_PRST | SICF_PCLKE | SICF_BWMASK), - (SICF_PRST | SICF_PCLKE | phy_bw_clkbits)); + brcms_b_core_ioctl(wlc_hw, + (SICF_PRST | SICF_PCLKE | SICF_BWMASK), + (SICF_PRST | SICF_PCLKE | phy_bw_clkbits)); } udelay(2); @@ -1795,8 +1808,8 @@ static void brcms_b_setband(struct brcms_hardware *wlc_hw, uint bandunit, u32 macintmask; /* Enable the d11 core before accessing it */ - if (!ai_iscoreup(wlc_hw->sih)) { - ai_core_reset(wlc_hw->sih, 0, 0); + if (!bcma_core_is_enabled(wlc_hw->d11core)) { + bcma_core_enable(wlc_hw->d11core, 0); brcms_c_mctrl_reset(wlc_hw); } @@ -1923,7 +1936,7 @@ static void brcms_b_xtal(struct brcms_hardware *wlc_hw, bool want) static bool brcms_b_radio_read_hwdisabled(struct brcms_hardware *wlc_hw) { bool v, clk, xtal; - u32 resetbits = 0, flags = 0; + u32 flags = 0; xtal = wlc_hw->sbclk; if (!xtal) @@ -1947,7 +1960,7 @@ static bool brcms_b_radio_read_hwdisabled(struct brcms_hardware *wlc_hw) (ai_get_chip_id(wlc_hw->sih) == BCM43225_CHIP_ID)) (void)ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); - ai_core_reset(wlc_hw->sih, flags, resetbits); + bcma_core_enable(wlc_hw->d11core, flags); brcms_c_mctrl_reset(wlc_hw); } @@ -1956,7 +1969,7 @@ static bool brcms_b_radio_read_hwdisabled(struct brcms_hardware *wlc_hw) /* put core back into reset */ if (!clk) - ai_core_disable(wlc_hw->sih, 0); + bcma_core_disable(wlc_hw->d11core, 0); if (!xtal) brcms_b_xtal(wlc_hw, OFF); @@ -1982,7 +1995,6 @@ void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags) { uint i; bool fastclk; - u32 resetbits = 0; if (flags == BRCMS_USE_COREFLAGS) flags = (wlc_hw->band->pi ? wlc_hw->band->core_flags : 0); @@ -1995,7 +2007,7 @@ void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags) brcms_b_clkctl_clk(wlc_hw, CLK_FAST); /* reset the dma engines except first time thru */ - if (ai_iscoreup(wlc_hw->sih)) { + if (bcma_core_is_enabled(wlc_hw->d11core)) { for (i = 0; i < NFIFO; i++) if ((wlc_hw->di[i]) && (!dma_txreset(wlc_hw->di[i]))) wiphy_err(wlc_hw->wlc->wiphy, "wl%d: %s: " @@ -2033,7 +2045,7 @@ void brcms_b_corereset(struct brcms_hardware *wlc_hw, u32 flags) * they may touch chipcommon as well. */ wlc_hw->clk = false; - ai_core_reset(wlc_hw->sih, flags, resetbits); + bcma_core_enable(wlc_hw->d11core, flags); wlc_hw->clk = true; if (wlc_hw->band && wlc_hw->band->pi) wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, true); @@ -2876,7 +2888,7 @@ static void brcms_c_coredisable(struct brcms_hardware *wlc_hw) brcms_b_core_phypll_ctl(wlc_hw, false); wlc_hw->clk = false; - ai_core_disable(wlc_hw->sih, 0); + bcma_core_disable(wlc_hw->d11core, 0); wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); } @@ -3234,7 +3246,7 @@ static void brcms_b_coreinit(struct brcms_c_info *wlc) brcms_c_gpio_init(wlc); - sflags = ai_core_sflags(wlc_hw->sih, 0, 0); + sflags = bcma_aread32(core, BCMA_IOST); if (D11REV_IS(wlc_hw->corerev, 23)) { if (BRCMS_ISNPHY(wlc_hw->band)) @@ -5318,7 +5330,7 @@ static int brcms_b_down_finish(struct brcms_hardware *wlc_hw) } else { /* Reset and disable the core */ - if (ai_iscoreup(wlc_hw->sih)) { + if (bcma_core_is_enabled(wlc_hw->d11core)) { if (bcma_read32(wlc_hw->d11core, D11REGOFFS(maccontrol)) & MCTL_EN_MAC) brcms_c_suspend_mac_and_wait(wlc_hw->wlc); diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c index 5139820b88a7..5b57caa7c3af 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c @@ -437,7 +437,7 @@ wlc_phy_attach(struct shared_phy *sh, struct bcma_device *d11core, if (D11REV_IS(sh->corerev, 4)) sflags = SISF_2G_PHY | SISF_5G_PHY; else - sflags = ai_core_sflags(sh->sih, 0, 0); + sflags = bcma_aread32(d11core, BCMA_IOST); if (bandtype == BRCM_BAND_5G) { if ((sflags & (SISF_5G_PHY | SISF_DB_PHY)) == 0) @@ -761,7 +761,7 @@ void wlc_phy_init(struct brcms_phy_pub *pih, u16 chanspec) if (!(pi->measure_hold & PHY_HOLD_FOR_SCAN)) pi->measure_hold |= PHY_HOLD_FOR_NOT_ASSOC; - if (WARN(!(ai_core_sflags(pi->sh->sih, 0, 0) & SISF_FCLKA), + if (WARN(!(bcma_aread32(pi->d11core, BCMA_IOST) & SISF_FCLKA), "HW error SISF_FCLKA\n")) return; -- cgit v1.2.3 From b0327ffa8cfe69ce2d380200c2097b86c6b3efd9 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 8 Dec 2011 15:06:59 -0800 Subject: brcm80211: smac: use bcma core access functions in nicpci.c Code in nicpci.c now uses the PCI(E) core as provided by the BCMA bus driver to configure that core. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 11 +- drivers/net/wireless/brcm80211/brcmsmac/nicpci.c | 179 ++++++++++------------ drivers/net/wireless/brcm80211/brcmsmac/nicpci.h | 11 +- 3 files changed, 90 insertions(+), 111 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c index a68f24a868f9..8d3829a73190 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c @@ -633,8 +633,7 @@ ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx) /* fixup necessary chip/core configurations */ if (!sii->pch) { - sii->pch = pcicore_init(&sii->pub, sii->pcibus, - sii->curmap + PCI_16KB0_PCIREGS_OFFSET); + sii->pch = pcicore_init(&sii->pub, sii->icbus->drv_pci.core); if (sii->pch == NULL) return false; } @@ -1385,7 +1384,7 @@ void ai_pci_setup(struct si_pub *sih, uint coremask) } if (PCI(sih)) { - pcicore_pci_setup(sii->pch, regs); + pcicore_pci_setup(sii->pch); /* switch back to previous core */ ai_setcoreidx(sih, idx); @@ -1408,11 +1407,7 @@ int ai_pci_fixcfg(struct si_pub *sih) /* check 'pi' is correct and fix it if not */ regs = ai_setcore(&sii->pub, ai_get_buscoretype(sih), 0); - if (ai_get_buscoretype(sih) == PCIE_CORE_ID) - pcicore_fixcfg_pcie(sii->pch, - (struct sbpcieregs __iomem *)regs); - else if (ai_get_buscoretype(sih) == PCI_CORE_ID) - pcicore_fixcfg_pci(sii->pch, (struct sbpciregs __iomem *)regs); + pcicore_fixcfg(sii->pch); /* restore the original index */ ai_setcoreidx(&sii->pub, origidx); diff --git a/drivers/net/wireless/brcm80211/brcmsmac/nicpci.c b/drivers/net/wireless/brcm80211/brcmsmac/nicpci.c index 6c3a9f9d5207..a4330416b43b 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/nicpci.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/nicpci.c @@ -139,6 +139,9 @@ #define SRSH_PI_MASK 0xf000 /* bit 15:12 */ #define SRSH_PI_SHIFT 12 /* bit 15:12 */ +#define PCIREGOFFS(field) offsetof(struct sbpciregs, field) +#define PCIEREGOFFS(field) offsetof(struct sbpcieregs, field) + /* Sonics side: PCI core and host control registers */ struct sbpciregs { u32 control; /* PCI control */ @@ -205,11 +208,7 @@ struct sbpcieregs { }; struct pcicore_info { - union { - struct sbpcieregs __iomem *pcieregs; - struct sbpciregs __iomem *pciregs; - } regs; /* Memory mapped register to the core */ - + struct bcma_device *core; struct si_pub *sih; /* System interconnect handle */ struct pci_dev *dev; u8 pciecap_lcreg_offset;/* PCIE capability LCreg offset @@ -238,8 +237,7 @@ static void pr28829_delay(void) /* Initialize the PCI core. * It's caller's responsibility to make sure that this is done only once */ -struct pcicore_info *pcicore_init(struct si_pub *sih, struct pci_dev *pdev, - void __iomem *regs) +struct pcicore_info *pcicore_init(struct si_pub *sih, struct bcma_device *core) { struct pcicore_info *pi; @@ -249,17 +247,15 @@ struct pcicore_info *pcicore_init(struct si_pub *sih, struct pci_dev *pdev, return NULL; pi->sih = sih; - pi->dev = pdev; + pi->dev = core->bus->host_pci; + pi->core = core; - if (ai_get_buscoretype(sih) == PCIE_CORE_ID) { + if (core->id.id == PCIE_CORE_ID) { u8 cap_ptr; - pi->regs.pcieregs = regs; cap_ptr = pcicore_find_pci_capability(pi->dev, PCI_CAP_ID_EXP, NULL, NULL); pi->pciecap_lcreg_offset = cap_ptr + PCIE_CAP_LINKCTRL_OFFSET; - } else - pi->regs.pciregs = regs; - + } return pi; } @@ -334,37 +330,37 @@ end: /* ***** Register Access API */ static uint -pcie_readreg(struct sbpcieregs __iomem *pcieregs, uint addrtype, uint offset) +pcie_readreg(struct bcma_device *core, uint addrtype, uint offset) { uint retval = 0xFFFFFFFF; switch (addrtype) { case PCIE_CONFIGREGS: - W_REG(&pcieregs->configaddr, offset); - (void)R_REG((&pcieregs->configaddr)); - retval = R_REG(&pcieregs->configdata); + bcma_write32(core, PCIEREGOFFS(configaddr), offset); + (void)bcma_read32(core, PCIEREGOFFS(configaddr)); + retval = bcma_read32(core, PCIEREGOFFS(configdata)); break; case PCIE_PCIEREGS: - W_REG(&pcieregs->pcieindaddr, offset); - (void)R_REG(&pcieregs->pcieindaddr); - retval = R_REG(&pcieregs->pcieinddata); + bcma_write32(core, PCIEREGOFFS(pcieindaddr), offset); + (void)bcma_read32(core, PCIEREGOFFS(pcieindaddr)); + retval = bcma_read32(core, PCIEREGOFFS(pcieinddata)); break; } return retval; } -static uint pcie_writereg(struct sbpcieregs __iomem *pcieregs, uint addrtype, +static uint pcie_writereg(struct bcma_device *core, uint addrtype, uint offset, uint val) { switch (addrtype) { case PCIE_CONFIGREGS: - W_REG((&pcieregs->configaddr), offset); - W_REG((&pcieregs->configdata), val); + bcma_write32(core, PCIEREGOFFS(configaddr), offset); + bcma_write32(core, PCIEREGOFFS(configdata), val); break; case PCIE_PCIEREGS: - W_REG((&pcieregs->pcieindaddr), offset); - W_REG((&pcieregs->pcieinddata), val); + bcma_write32(core, PCIEREGOFFS(pcieindaddr), offset); + bcma_write32(core, PCIEREGOFFS(pcieinddata), val); break; default: break; @@ -374,7 +370,6 @@ static uint pcie_writereg(struct sbpcieregs __iomem *pcieregs, uint addrtype, static bool pcie_mdiosetblock(struct pcicore_info *pi, uint blk) { - struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs; uint mdiodata, i = 0; uint pcie_serdes_spinwait = 200; @@ -382,12 +377,13 @@ static bool pcie_mdiosetblock(struct pcicore_info *pi, uint blk) (MDIODATA_DEV_ADDR << MDIODATA_DEVADDR_SHF) | (MDIODATA_BLK_ADDR << MDIODATA_REGADDR_SHF) | (blk << 4)); - W_REG(&pcieregs->mdiodata, mdiodata); + bcma_write32(pi->core, PCIEREGOFFS(mdiodata), mdiodata); pr28829_delay(); /* retry till the transaction is complete */ while (i < pcie_serdes_spinwait) { - if (R_REG(&pcieregs->mdiocontrol) & MDIOCTL_ACCESS_DONE) + if (bcma_read32(pi->core, PCIEREGOFFS(mdiocontrol)) & + MDIOCTL_ACCESS_DONE) break; udelay(1000); @@ -404,13 +400,13 @@ static int pcie_mdioop(struct pcicore_info *pi, uint physmedia, uint regaddr, bool write, uint *val) { - struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs; uint mdiodata; uint i = 0; uint pcie_serdes_spinwait = 10; /* enable mdio access to SERDES */ - W_REG(&pcieregs->mdiocontrol, MDIOCTL_PREAM_EN | MDIOCTL_DIVISOR_VAL); + bcma_write32(pi->core, PCIEREGOFFS(mdiocontrol), + MDIOCTL_PREAM_EN | MDIOCTL_DIVISOR_VAL); if (pi->sih->buscorerev >= 10) { /* new serdes is slower in rw, @@ -432,20 +428,22 @@ pcie_mdioop(struct pcicore_info *pi, uint physmedia, uint regaddr, bool write, mdiodata |= (MDIODATA_START | MDIODATA_WRITE | MDIODATA_TA | *val); - W_REG(&pcieregs->mdiodata, mdiodata); + bcma_write32(pi->core, PCIEREGOFFS(mdiodata), mdiodata); pr28829_delay(); /* retry till the transaction is complete */ while (i < pcie_serdes_spinwait) { - if (R_REG(&pcieregs->mdiocontrol) & MDIOCTL_ACCESS_DONE) { + if (bcma_read32(pi->core, PCIEREGOFFS(mdiocontrol)) & + MDIOCTL_ACCESS_DONE) { if (!write) { pr28829_delay(); - *val = (R_REG(&pcieregs->mdiodata) & + *val = (bcma_read32(pi->core, + PCIEREGOFFS(mdiodata)) & MDIODATA_MASK); } /* Disable mdio access to SERDES */ - W_REG(&pcieregs->mdiocontrol, 0); + bcma_write32(pi->core, PCIEREGOFFS(mdiocontrol), 0); return 0; } udelay(1000); @@ -453,7 +451,7 @@ pcie_mdioop(struct pcicore_info *pi, uint physmedia, uint regaddr, bool write, } /* Timed out. Disable mdio access to SERDES. */ - W_REG(&pcieregs->mdiocontrol, 0); + bcma_write32(pi->core, PCIEREGOFFS(mdiocontrol), 0); return 1; } @@ -502,19 +500,18 @@ static void pcie_extendL1timer(struct pcicore_info *pi, bool extend) { u32 w; struct si_pub *sih = pi->sih; - struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs; if (ai_get_buscoretype(sih) != PCIE_CORE_ID || ai_get_buscorerev(sih) < 7) return; - w = pcie_readreg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG); + w = pcie_readreg(pi->core, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG); if (extend) w |= PCIE_ASPMTIMER_EXTEND; else w &= ~PCIE_ASPMTIMER_EXTEND; - pcie_writereg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG, w); - w = pcie_readreg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG); + pcie_writereg(pi->core, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG, w); + w = pcie_readreg(pi->core, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG); } /* centralized clkreq control policy */ @@ -565,7 +562,7 @@ static void pcie_war_polarity(struct pcicore_info *pi) if (pi->pcie_polarity != 0) return; - w = pcie_readreg(pi->regs.pcieregs, PCIE_PCIEREGS, PCIE_PLP_STATUSREG); + w = pcie_readreg(pi->core, PCIE_PCIEREGS, PCIE_PLP_STATUSREG); /* Detect the current polarity at attach and force that polarity and * disable changing the polarity @@ -584,18 +581,15 @@ static void pcie_war_polarity(struct pcicore_info *pi) */ static void pcie_war_aspm_clkreq(struct pcicore_info *pi) { - struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs; struct si_pub *sih = pi->sih; u16 val16; - u16 __iomem *reg16; u32 w; if (!PCIE_ASPM(sih)) return; /* bypass this on QT or VSIM */ - reg16 = &pcieregs->sprom[SRSH_ASPM_OFFSET]; - val16 = R_REG(reg16); + val16 = bcma_read16(pi->core, PCIEREGOFFS(sprom[SRSH_ASPM_OFFSET])); val16 &= ~SRSH_ASPM_ENB; if (pi->pcie_war_aspm_ovr == PCIE_ASPM_ENAB) @@ -605,15 +599,15 @@ static void pcie_war_aspm_clkreq(struct pcicore_info *pi) else if (pi->pcie_war_aspm_ovr == PCIE_ASPM_L0s_ENAB) val16 |= SRSH_ASPM_L0s_ENB; - W_REG(reg16, val16); + bcma_write16(pi->core, PCIEREGOFFS(sprom[SRSH_ASPM_OFFSET]), val16); pci_read_config_dword(pi->dev, pi->pciecap_lcreg_offset, &w); w &= ~PCIE_ASPM_ENAB; w |= pi->pcie_war_aspm_ovr; pci_write_config_dword(pi->dev, pi->pciecap_lcreg_offset, w); - reg16 = &pcieregs->sprom[SRSH_CLKREQ_OFFSET_REV5]; - val16 = R_REG(reg16); + val16 = bcma_read16(pi->core, + PCIEREGOFFS(sprom[SRSH_CLKREQ_OFFSET_REV5])); if (pi->pcie_war_aspm_ovr != PCIE_ASPM_DISAB) { val16 |= SRSH_CLKREQ_ENB; @@ -621,7 +615,8 @@ static void pcie_war_aspm_clkreq(struct pcicore_info *pi) } else val16 &= ~SRSH_CLKREQ_ENB; - W_REG(reg16, val16); + bcma_write16(pi->core, PCIEREGOFFS(sprom[SRSH_CLKREQ_OFFSET_REV5]), + val16); } /* Apply the polarity determined at the start */ @@ -645,16 +640,15 @@ static void pcie_war_serdes(struct pcicore_info *pi) /* Needs to happen when coming out of 'standby'/'hibernate' */ static void pcie_misc_config_fixup(struct pcicore_info *pi) { - struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs; u16 val16; - u16 __iomem *reg16; - reg16 = &pcieregs->sprom[SRSH_PCIE_MISC_CONFIG]; - val16 = R_REG(reg16); + val16 = bcma_read16(pi->core, + PCIEREGOFFS(sprom[SRSH_PCIE_MISC_CONFIG])); if ((val16 & SRSH_L23READY_EXIT_NOPERST) == 0) { val16 |= SRSH_L23READY_EXIT_NOPERST; - W_REG(reg16, val16); + bcma_write16(pi->core, + PCIEREGOFFS(sprom[SRSH_PCIE_MISC_CONFIG]), val16); } } @@ -662,37 +656,32 @@ static void pcie_misc_config_fixup(struct pcicore_info *pi) /* Needs to happen when coming out of 'standby'/'hibernate' */ static void pcie_war_noplldown(struct pcicore_info *pi) { - struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs; - u16 __iomem *reg16; - /* turn off serdes PLL down */ ai_cc_reg(pi->sih, offsetof(struct chipcregs, chipcontrol), CHIPCTRL_4321_PLL_DOWN, CHIPCTRL_4321_PLL_DOWN); /* clear srom shadow backdoor */ - reg16 = &pcieregs->sprom[SRSH_BD_OFFSET]; - W_REG(reg16, 0); + bcma_write16(pi->core, PCIEREGOFFS(sprom[SRSH_BD_OFFSET]), 0); } /* Needs to happen when coming out of 'standby'/'hibernate' */ static void pcie_war_pci_setup(struct pcicore_info *pi) { struct si_pub *sih = pi->sih; - struct sbpcieregs __iomem *pcieregs = pi->regs.pcieregs; u32 w; if (ai_get_buscorerev(sih) == 0 || ai_get_buscorerev(sih) == 1) { - w = pcie_readreg(pcieregs, PCIE_PCIEREGS, + w = pcie_readreg(pi->core, PCIE_PCIEREGS, PCIE_TLP_WORKAROUNDSREG); w |= 0x8; - pcie_writereg(pcieregs, PCIE_PCIEREGS, + pcie_writereg(pi->core, PCIE_PCIEREGS, PCIE_TLP_WORKAROUNDSREG, w); } if (ai_get_buscorerev(sih) == 1) { - w = pcie_readreg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_LCREG); + w = pcie_readreg(pi->core, PCIE_PCIEREGS, PCIE_DLLP_LCREG); w |= 0x40; - pcie_writereg(pcieregs, PCIE_PCIEREGS, PCIE_DLLP_LCREG, w); + pcie_writereg(pi->core, PCIE_PCIEREGS, PCIE_DLLP_LCREG, w); } if (ai_get_buscorerev(sih) == 0) { @@ -701,11 +690,11 @@ static void pcie_war_pci_setup(struct pcicore_info *pi) pcie_mdiowrite(pi, MDIODATA_DEV_RX, SERDES_RX_CDRBW, 0x1466); } else if (PCIE_ASPM(sih)) { /* Change the L1 threshold for better performance */ - w = pcie_readreg(pcieregs, PCIE_PCIEREGS, + w = pcie_readreg(pi->core, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG); w &= ~PCIE_L1THRESHOLDTIME_MASK; w |= PCIE_L1THRESHOLD_WARVAL << PCIE_L1THRESHOLDTIME_SHIFT; - pcie_writereg(pcieregs, PCIE_PCIEREGS, + pcie_writereg(pi->core, PCIE_PCIEREGS, PCIE_DLLP_PMTHRESHREG, w); pcie_war_serdes(pi); @@ -794,45 +783,45 @@ void pcicore_down(struct pcicore_info *pi, int state) } /* precondition: current core is sii->buscoretype */ -static void pcicore_fixcfg(struct pcicore_info *pi, u16 __iomem *reg16) +void pcicore_fixcfg(struct pcicore_info *pi) { - struct si_info *sii = (struct si_info *)(pi->sih); + struct bcma_device *core = pi->core; u16 val16; - uint pciidx; + uint regoff; - pciidx = ai_coreidx(&sii->pub); - val16 = R_REG(reg16); - if (((val16 & SRSH_PI_MASK) >> SRSH_PI_SHIFT) != (u16)pciidx) { - val16 = (u16)(pciidx << SRSH_PI_SHIFT) | - (val16 & ~SRSH_PI_MASK); - W_REG(reg16, val16); - } -} + switch (pi->core->id.id) { + case BCMA_CORE_PCI: + regoff = PCIREGOFFS(sprom[SRSH_PI_OFFSET]); + break; -void -pcicore_fixcfg_pci(struct pcicore_info *pi, struct sbpciregs __iomem *pciregs) -{ - pcicore_fixcfg(pi, &pciregs->sprom[SRSH_PI_OFFSET]); -} + case BCMA_CORE_PCIE: + regoff = PCIEREGOFFS(sprom[SRSH_PI_OFFSET]); + break; -void pcicore_fixcfg_pcie(struct pcicore_info *pi, - struct sbpcieregs __iomem *pcieregs) -{ - pcicore_fixcfg(pi, &pcieregs->sprom[SRSH_PI_OFFSET]); + default: + return; + } + + val16 = bcma_read16(pi->core, regoff); + if (((val16 & SRSH_PI_MASK) >> SRSH_PI_SHIFT) != + (u16)core->core_index) { + val16 = ((u16)core->core_index << SRSH_PI_SHIFT) | + (val16 & ~SRSH_PI_MASK); + bcma_write16(pi->core, regoff, val16); + } } /* precondition: current core is pci core */ void -pcicore_pci_setup(struct pcicore_info *pi, struct sbpciregs __iomem *pciregs) +pcicore_pci_setup(struct pcicore_info *pi) { - u32 w; - - OR_REG(&pciregs->sbtopci2, SBTOPCI_PREF | SBTOPCI_BURST); - - if (ai_get_buscorerev(pi->sih) >= 11) { - OR_REG(&pciregs->sbtopci2, SBTOPCI_RC_READMULTI); - w = R_REG(&pciregs->clkrun); - W_REG(&pciregs->clkrun, w | PCI_CLKRUN_DSBL); - w = R_REG(&pciregs->clkrun); + bcma_set32(pi->core, PCIREGOFFS(sbtopci2), + SBTOPCI_PREF | SBTOPCI_BURST); + + if (pi->core->id.rev >= 11) { + bcma_set32(pi->core, PCIREGOFFS(sbtopci2), + SBTOPCI_RC_READMULTI); + bcma_set32(pi->core, PCIREGOFFS(clkrun), PCI_CLKRUN_DSBL); + (void)bcma_read32(pi->core, PCIREGOFFS(clkrun)); } } diff --git a/drivers/net/wireless/brcm80211/brcmsmac/nicpci.h b/drivers/net/wireless/brcm80211/brcmsmac/nicpci.h index 58aa80dc3329..9fc3ead540a8 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/nicpci.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/nicpci.h @@ -62,8 +62,7 @@ struct sbpciregs; struct sbpcieregs; extern struct pcicore_info *pcicore_init(struct si_pub *sih, - struct pci_dev *pdev, - void __iomem *regs); + struct bcma_device *core); extern void pcicore_deinit(struct pcicore_info *pch); extern void pcicore_attach(struct pcicore_info *pch, int state); extern void pcicore_hwup(struct pcicore_info *pch); @@ -72,11 +71,7 @@ extern void pcicore_sleep(struct pcicore_info *pch); extern void pcicore_down(struct pcicore_info *pch, int state); extern u8 pcicore_find_pci_capability(struct pci_dev *dev, u8 req_cap_id, unsigned char *buf, u32 *buflen); -extern void pcicore_fixcfg_pci(struct pcicore_info *pch, - struct sbpciregs __iomem *pciregs); -extern void pcicore_fixcfg_pcie(struct pcicore_info *pch, - struct sbpcieregs __iomem *pciregs); -extern void pcicore_pci_setup(struct pcicore_info *pch, - struct sbpciregs __iomem *pciregs); +extern void pcicore_fixcfg(struct pcicore_info *pch); +extern void pcicore_pci_setup(struct pcicore_info *pch); #endif /* _BRCM_NICPCI_H_ */ -- cgit v1.2.3 From 8c53e42dea5905aee2a97e6af5874432f27b5c03 Mon Sep 17 00:00:00 2001 From: Amitkumar Karwar Date: Thu, 8 Dec 2011 20:41:03 -0800 Subject: mwifiex: failure case handling for PCIe events Event buffers for PCIe interface are allocated during driver initialisation, and respective physical addresses are sent to FW in *_PCIE_DESC_DETAILS command so that FW can do DMA. These buffers will be freed while unloading the driver. Therefore we should not free them in event handling error path. Also we should skip next pending events in failure case. Also fixed 'returning -1 instead of -ENOMEM is sloppy' warnings. Signed-off-by: Amitkumar Karwar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/pcie.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c index a2f32008f9a8..405350940a45 100644 --- a/drivers/net/wireless/mwifiex/pcie.c +++ b/drivers/net/wireless/mwifiex/pcie.c @@ -386,7 +386,7 @@ static int mwifiex_pcie_create_txbd_ring(struct mwifiex_adapter *adapter) card->txbd_ring_vbase = kzalloc(card->txbd_ring_size, GFP_KERNEL); if (!card->txbd_ring_vbase) { dev_err(adapter->dev, "Unable to allocate buffer for txbd ring.\n"); - return -1; + return -ENOMEM; } card->txbd_ring_pbase = virt_to_phys(card->txbd_ring_vbase); @@ -476,7 +476,7 @@ static int mwifiex_pcie_create_rxbd_ring(struct mwifiex_adapter *adapter) if (!card->rxbd_ring_vbase) { dev_err(adapter->dev, "Unable to allocate buffer for " "rxbd_ring.\n"); - return -1; + return -ENOMEM; } card->rxbd_ring_pbase = virt_to_phys(card->rxbd_ring_vbase); @@ -569,7 +569,7 @@ static int mwifiex_pcie_create_evtbd_ring(struct mwifiex_adapter *adapter) if (!card->evtbd_ring_vbase) { dev_err(adapter->dev, "Unable to allocate buffer. " "Terminating download\n"); - return -1; + return -ENOMEM; } card->evtbd_ring_pbase = virt_to_phys(card->evtbd_ring_vbase); @@ -1231,15 +1231,13 @@ static int mwifiex_pcie_event_complete(struct mwifiex_adapter *adapter, if (rdptr >= MWIFIEX_MAX_EVT_BD) { dev_err(adapter->dev, "event_complete: Invalid rdptr 0x%x\n", rdptr); - ret = -EINVAL; - goto done; + return -EINVAL; } /* Read the event ring write pointer set by firmware */ if (mwifiex_read_reg(adapter, REG_EVTBD_WRPTR, &wrptr)) { dev_err(adapter->dev, "event_complete: failed to read REG_EVTBD_WRPTR\n"); - ret = -1; - goto done; + return -1; } if (!card->evt_buf_list[rdptr]) { @@ -1268,15 +1266,9 @@ static int mwifiex_pcie_event_complete(struct mwifiex_adapter *adapter, /* Write the event ring read pointer in to REG_EVTBD_RDPTR */ if (mwifiex_write_reg(adapter, REG_EVTBD_RDPTR, card->evtbd_rdptr)) { dev_err(adapter->dev, "event_complete: failed to read REG_EVTBD_RDPTR\n"); - ret = -1; - goto done; + return -1; } -done: - /* Free the buffer for failure case */ - if (ret && skb) - dev_kfree_skb_any(skb); - dev_dbg(adapter->dev, "info: Check Events Again\n"); ret = mwifiex_pcie_process_event_ready(adapter); -- cgit v1.2.3 From 17a60b48193f32ab0c87e0d57df6ab408fbe9bca Mon Sep 17 00:00:00 2001 From: Avinash Patil Date: Thu, 8 Dec 2011 20:41:04 -0800 Subject: mwifiex: proper cleanup when RX multiport aggregation fails Free SKBs allocated during multiport aggrgation setup when RX multiport aggregation fails in the middle. With this handling freeing SKB in mwifiex_process_int_status() for failure case is removed. Also handles single RX transaction failure. Signed-off-by: Avinash Patil Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/sdio.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c index 702452b505c3..d39d8457f252 100644 --- a/drivers/net/wireless/mwifiex/sdio.c +++ b/drivers/net/wireless/mwifiex/sdio.c @@ -1087,7 +1087,7 @@ static int mwifiex_sdio_card_to_host_mp_aggr(struct mwifiex_adapter *adapter, (adapter->ioport | 0x1000 | (card->mpa_rx.ports << 4)) + card->mpa_rx.start_port, 1)) - return -1; + goto error; curr_ptr = card->mpa_rx.buf; @@ -1130,12 +1130,29 @@ rx_curr_single: if (mwifiex_sdio_card_to_host(adapter, &pkt_type, skb->data, skb->len, adapter->ioport + port)) - return -1; + goto error; mwifiex_decode_rx_packet(adapter, skb, pkt_type); } return 0; + +error: + if (MP_RX_AGGR_IN_PROGRESS(card)) { + /* Multiport-aggregation transfer failed - cleanup */ + for (pind = 0; pind < card->mpa_rx.pkt_cnt; pind++) { + /* copy pkt to deaggr buf */ + skb_deaggr = card->mpa_rx.skb_arr[pind]; + dev_kfree_skb_any(skb_deaggr); + } + MP_RX_AGGR_BUF_RESET(card); + } + + if (f_do_rx_cur) + /* Single transfer pending. Free curr buff also */ + dev_kfree_skb_any(skb); + + return -1; } /* @@ -1271,7 +1288,6 @@ static int mwifiex_process_int_status(struct mwifiex_adapter *adapter) dev_dbg(adapter->dev, "info: CFG reg val =%x\n", cr); - dev_kfree_skb_any(skb); return -1; } } -- cgit v1.2.3 From bbea3bc432dc5c08d09ca5c80afdd82515470688 Mon Sep 17 00:00:00 2001 From: Avinash Patil Date: Thu, 8 Dec 2011 20:41:05 -0800 Subject: mwifiex: wakeup and stop multiple tx queues in net_device replace single queue function calls with equivalent multiple queue functions. Wakeup queue and stop queue calls are guarded by spin lock. Signed-off-by: Avinash Patil Signed-off-by: Kiran Divekar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/init.c | 40 ++++++++++++++++++++++++++++++++ drivers/net/wireless/mwifiex/main.c | 11 +++++---- drivers/net/wireless/mwifiex/main.h | 9 +++++++ drivers/net/wireless/mwifiex/sta_event.c | 6 ++--- drivers/net/wireless/mwifiex/sta_ioctl.c | 4 ++-- drivers/net/wireless/mwifiex/txrx.c | 5 ++-- 6 files changed, 63 insertions(+), 12 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/mwifiex/init.c b/drivers/net/wireless/mwifiex/init.c index 26940455255b..244c728ef9dc 100644 --- a/drivers/net/wireless/mwifiex/init.c +++ b/drivers/net/wireless/mwifiex/init.c @@ -282,6 +282,45 @@ static void mwifiex_init_adapter(struct mwifiex_adapter *adapter) adapter->arp_filter_size = 0; } +/* + * This function sets trans_start per tx_queue + */ +void mwifiex_set_trans_start(struct net_device *dev) +{ + int i; + + for (i = 0; i < dev->num_tx_queues; i++) + netdev_get_tx_queue(dev, i)->trans_start = jiffies; + + dev->trans_start = jiffies; +} + +/* + * This function wakes up all queues in net_device + */ +void mwifiex_wake_up_net_dev_queue(struct net_device *netdev, + struct mwifiex_adapter *adapter) +{ + unsigned long dev_queue_flags; + + spin_lock_irqsave(&adapter->queue_lock, dev_queue_flags); + netif_tx_wake_all_queues(netdev); + spin_unlock_irqrestore(&adapter->queue_lock, dev_queue_flags); +} + +/* + * This function stops all queues in net_device + */ +void mwifiex_stop_net_dev_queue(struct net_device *netdev, + struct mwifiex_adapter *adapter) +{ + unsigned long dev_queue_flags; + + spin_lock_irqsave(&adapter->queue_lock, dev_queue_flags); + netif_tx_stop_all_queues(netdev); + spin_unlock_irqrestore(&adapter->queue_lock, dev_queue_flags); +} + /* * This function releases the lock variables and frees the locks and * associated locks. @@ -359,6 +398,7 @@ int mwifiex_init_lock_list(struct mwifiex_adapter *adapter) spin_lock_init(&adapter->int_lock); spin_lock_init(&adapter->main_proc_lock); spin_lock_init(&adapter->mwifiex_cmd_lock); + spin_lock_init(&adapter->queue_lock); for (i = 0; i < adapter->priv_num; i++) { if (adapter->priv[i]) { priv = adapter->priv[i]; diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c index 67e6db7d672d..d21cd4707f01 100644 --- a/drivers/net/wireless/mwifiex/main.c +++ b/drivers/net/wireless/mwifiex/main.c @@ -401,7 +401,7 @@ mwifiex_fill_buffer(struct sk_buff *skb) static int mwifiex_open(struct net_device *dev) { - netif_start_queue(dev); + netif_tx_start_all_queues(dev); return 0; } @@ -465,8 +465,8 @@ mwifiex_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) atomic_inc(&priv->adapter->tx_pending); if (atomic_read(&priv->adapter->tx_pending) >= MAX_TX_PENDING) { - netif_stop_queue(priv->netdev); - dev->trans_start = jiffies; + mwifiex_set_trans_start(dev); + mwifiex_stop_net_dev_queue(priv->netdev, priv->adapter); } queue_work(priv->adapter->workqueue, &priv->adapter->main_work); @@ -533,7 +533,7 @@ mwifiex_tx_timeout(struct net_device *dev) dev_err(priv->adapter->dev, "%lu : Tx timeout, bss_index=%d\n", jiffies, priv->bss_index); - dev->trans_start = jiffies; + mwifiex_set_trans_start(dev); priv->num_tx_timeout++; } @@ -793,7 +793,8 @@ int mwifiex_remove_card(struct mwifiex_adapter *adapter, struct semaphore *sem) priv = adapter->priv[i]; if (priv && priv->netdev) { if (!netif_queue_stopped(priv->netdev)) - netif_stop_queue(priv->netdev); + mwifiex_stop_net_dev_queue(priv->netdev, + adapter); if (netif_carrier_ok(priv->netdev)) netif_carrier_off(priv->netdev); } diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h index 3861a617c0e1..41f88631763c 100644 --- a/drivers/net/wireless/mwifiex/main.h +++ b/drivers/net/wireless/mwifiex/main.h @@ -655,10 +655,19 @@ struct mwifiex_adapter { struct mwifiex_wait_queue cmd_wait_q; u8 scan_wait_q_woken; struct cmd_ctrl_node *cmd_queued; + spinlock_t queue_lock; /* lock for tx queues */ }; int mwifiex_init_lock_list(struct mwifiex_adapter *adapter); +void mwifiex_set_trans_start(struct net_device *dev); + +void mwifiex_stop_net_dev_queue(struct net_device *netdev, + struct mwifiex_adapter *adapter); + +void mwifiex_wake_up_net_dev_queue(struct net_device *netdev, + struct mwifiex_adapter *adapter); + int mwifiex_init_fw(struct mwifiex_adapter *adapter); int mwifiex_init_fw_complete(struct mwifiex_adapter *adapter); diff --git a/drivers/net/wireless/mwifiex/sta_event.c b/drivers/net/wireless/mwifiex/sta_event.c index f204810e8338..40205f60be4d 100644 --- a/drivers/net/wireless/mwifiex/sta_event.c +++ b/drivers/net/wireless/mwifiex/sta_event.c @@ -126,7 +126,7 @@ mwifiex_reset_connect_state(struct mwifiex_private *priv) queue_work(priv->workqueue, &priv->cfg_workqueue); } if (!netif_queue_stopped(priv->netdev)) - netif_stop_queue(priv->netdev); + mwifiex_stop_net_dev_queue(priv->netdev, adapter); if (netif_carrier_ok(priv->netdev)) netif_carrier_off(priv->netdev); /* Reset wireless stats signal info */ @@ -201,7 +201,7 @@ int mwifiex_process_sta_event(struct mwifiex_private *priv) if (!netif_carrier_ok(priv->netdev)) netif_carrier_on(priv->netdev); if (netif_queue_stopped(priv->netdev)) - netif_wake_queue(priv->netdev); + mwifiex_wake_up_net_dev_queue(priv->netdev, adapter); break; case EVENT_DEAUTHENTICATED: @@ -292,7 +292,7 @@ int mwifiex_process_sta_event(struct mwifiex_private *priv) priv->adhoc_is_link_sensed = false; mwifiex_clean_txrx(priv); if (!netif_queue_stopped(priv->netdev)) - netif_stop_queue(priv->netdev); + mwifiex_stop_net_dev_queue(priv->netdev, adapter); if (netif_carrier_ok(priv->netdev)) netif_carrier_off(priv->netdev); break; diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c index 4b6f5539657d..6d990c798a20 100644 --- a/drivers/net/wireless/mwifiex/sta_ioctl.c +++ b/drivers/net/wireless/mwifiex/sta_ioctl.c @@ -234,7 +234,7 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss, "associating...\n"); if (!netif_queue_stopped(priv->netdev)) - netif_stop_queue(priv->netdev); + mwifiex_stop_net_dev_queue(priv->netdev, adapter); /* Clear any past association response stored for * application retrieval */ @@ -265,7 +265,7 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss, ret = mwifiex_check_network_compatibility(priv, bss_desc); if (!netif_queue_stopped(priv->netdev)) - netif_stop_queue(priv->netdev); + mwifiex_stop_net_dev_queue(priv->netdev, adapter); if (!ret) { dev_dbg(adapter->dev, "info: network found in scan" diff --git a/drivers/net/wireless/mwifiex/txrx.c b/drivers/net/wireless/mwifiex/txrx.c index a206f412875f..d9274a1b77ac 100644 --- a/drivers/net/wireless/mwifiex/txrx.c +++ b/drivers/net/wireless/mwifiex/txrx.c @@ -134,7 +134,7 @@ int mwifiex_write_data_complete(struct mwifiex_adapter *adapter, if (!priv) goto done; - priv->netdev->trans_start = jiffies; + mwifiex_set_trans_start(priv->netdev); if (!status) { priv->stats.tx_packets++; priv->stats.tx_bytes += skb->len; @@ -152,7 +152,8 @@ int mwifiex_write_data_complete(struct mwifiex_adapter *adapter, if ((GET_BSS_ROLE(tpriv) == MWIFIEX_BSS_ROLE_STA) && (tpriv->media_connected)) { if (netif_queue_stopped(tpriv->netdev)) - netif_wake_queue(tpriv->netdev); + mwifiex_wake_up_net_dev_queue(tpriv->netdev, + adapter); } } done: -- cgit v1.2.3 From e5f0a276213ffb080d0613d6c7fc1240ef5af67c Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sat, 10 Dec 2011 22:11:19 +0100 Subject: ath9k: make two mci related functions static Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/mci.c | 8 ++++---- drivers/net/wireless/ath/ath9k/mci.h | 4 ---- 2 files changed, 4 insertions(+), 8 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/mci.c b/drivers/net/wireless/ath/ath9k/mci.c index d6780405d6f5..691bf47906e2 100644 --- a/drivers/net/wireless/ath/ath9k/mci.c +++ b/drivers/net/wireless/ath/ath9k/mci.c @@ -234,8 +234,8 @@ static void ath_mci_cal_msg(struct ath_softc *sc, u8 opcode, u8 *rx_payload) } } -void ath_mci_process_profile(struct ath_softc *sc, - struct ath_mci_profile_info *info) +static void ath_mci_process_profile(struct ath_softc *sc, + struct ath_mci_profile_info *info) { struct ath_common *common = ath9k_hw_common(sc->sc_ah); struct ath_btcoex *btcoex = &sc->btcoex; @@ -261,8 +261,8 @@ void ath_mci_process_profile(struct ath_softc *sc, ath_mci_update_scheme(sc); } -void ath_mci_process_status(struct ath_softc *sc, - struct ath_mci_profile_status *status) +static void ath_mci_process_status(struct ath_softc *sc, + struct ath_mci_profile_status *status) { struct ath_common *common = ath9k_hw_common(sc->sc_ah); struct ath_btcoex *btcoex = &sc->btcoex; diff --git a/drivers/net/wireless/ath/ath9k/mci.h b/drivers/net/wireless/ath/ath9k/mci.h index b71bdeda7c78..29e3e51d078f 100644 --- a/drivers/net/wireless/ath/ath9k/mci.h +++ b/drivers/net/wireless/ath/ath9k/mci.h @@ -128,10 +128,6 @@ struct ath_mci_coex { }; void ath_mci_flush_profile(struct ath_mci_profile *mci); -void ath_mci_process_profile(struct ath_softc *sc, - struct ath_mci_profile_info *info); -void ath_mci_process_status(struct ath_softc *sc, - struct ath_mci_profile_status *status); int ath_mci_setup(struct ath_softc *sc); void ath_mci_cleanup(struct ath_softc *sc); void ath_mci_intr(struct ath_softc *sc); -- cgit v1.2.3 From c56da252a7608bd06c4527e3ce5dd2090c7922b8 Mon Sep 17 00:00:00 2001 From: Rafał Miłecki Date: Sun, 11 Dec 2011 02:55:29 +0100 Subject: b43: N-PHY: random trivial fixes for typos, missing writes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rafał Miłecki Signed-off-by: John W. Linville --- drivers/net/wireless/b43/phy_n.c | 23 +++++++++++++++-------- drivers/net/wireless/b43/tables_nphy.c | 2 +- drivers/net/wireless/b43/tables_nphy.h | 28 ++++++++++++++-------------- 3 files changed, 30 insertions(+), 23 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c index b17d9b6c33a5..f40d8049d310 100644 --- a/drivers/net/wireless/b43/phy_n.c +++ b/drivers/net/wireless/b43/phy_n.c @@ -1493,8 +1493,8 @@ static void b43_nphy_workarounds_rev3plus(struct b43_wldev *dev) struct ssb_sprom *sprom = dev->dev->bus_sprom; /* TX to RX */ - u8 tx2rx_events[9] = { 0x4, 0x3, 0x6, 0x5, 0x2, 0x1, 0x8, 0x1F }; - u8 tx2rx_delays[9] = { 8, 4, 2, 2, 4, 4, 6, 1 }; + u8 tx2rx_events[8] = { 0x4, 0x3, 0x6, 0x5, 0x2, 0x1, 0x8, 0x1F }; + u8 tx2rx_delays[8] = { 8, 4, 2, 2, 4, 4, 6, 1 }; /* RX to TX */ u8 rx2tx_events_ipa[9] = { 0x0, 0x1, 0x2, 0x8, 0x5, 0x6, 0xF, 0x3, 0x1F }; @@ -1505,6 +1505,9 @@ static void b43_nphy_workarounds_rev3plus(struct b43_wldev *dev) u16 tmp16; u32 tmp32; + b43_phy_write(dev, 0x23f, 0x1f8); + b43_phy_write(dev, 0x240, 0x1f8); + tmp32 = b43_ntab_read(dev, B43_NTAB32(30, 0)); tmp32 &= 0xffffff; b43_ntab_write(dev, B43_NTAB32(30, 0), tmp32); @@ -1520,12 +1523,13 @@ static void b43_nphy_workarounds_rev3plus(struct b43_wldev *dev) b43_phy_write(dev, 0x2AE, 0x000C); /* TX to RX */ - b43_nphy_set_rf_sequence(dev, 1, tx2rx_events, tx2rx_delays, 9); + b43_nphy_set_rf_sequence(dev, 1, tx2rx_events, tx2rx_delays, + ARRAY_SIZE(tx2rx_events)); /* RX to TX */ if (b43_nphy_ipa(dev)) - b43_nphy_set_rf_sequence(dev, 1, rx2tx_events_ipa, - rx2tx_delays_ipa, 9); + b43_nphy_set_rf_sequence(dev, 0, rx2tx_events_ipa, + rx2tx_delays_ipa, ARRAY_SIZE(rx2tx_events_ipa)); if (nphy->hw_phyrxchain != 3 && nphy->hw_phyrxchain != nphy->hw_phytxchain) { if (b43_nphy_ipa(dev)) { @@ -1533,7 +1537,8 @@ static void b43_nphy_workarounds_rev3plus(struct b43_wldev *dev) rx2tx_delays[6] = 1; rx2tx_events[7] = 0x1F; } - b43_nphy_set_rf_sequence(dev, 1, rx2tx_events, rx2tx_delays, 9); + b43_nphy_set_rf_sequence(dev, 1, rx2tx_events, rx2tx_delays, + ARRAY_SIZE(rx2tx_events)); } tmp16 = (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) ? @@ -1547,8 +1552,8 @@ static void b43_nphy_workarounds_rev3plus(struct b43_wldev *dev) b43_nphy_gain_ctrl_workarounds(dev); - b43_ntab_write(dev, B43_NTAB32(8, 0), 2); - b43_ntab_write(dev, B43_NTAB32(8, 16), 2); + b43_ntab_write(dev, B43_NTAB16(8, 0), 2); + b43_ntab_write(dev, B43_NTAB16(8, 16), 2); /* TODO */ @@ -1560,6 +1565,8 @@ static void b43_nphy_workarounds_rev3plus(struct b43_wldev *dev) b43_radio_write(dev, B2056_RX1 | B2056_RX_MIXA_BIAS_AUX, 0x07); b43_radio_write(dev, B2056_RX0 | B2056_RX_MIXA_LOB_BIAS, 0x88); b43_radio_write(dev, B2056_RX1 | B2056_RX_MIXA_LOB_BIAS, 0x88); + b43_radio_write(dev, B2056_RX0 | B2056_RX_MIXA_CMFB_IDAC, 0x00); + b43_radio_write(dev, B2056_RX1 | B2056_RX_MIXA_CMFB_IDAC, 0x00); b43_radio_write(dev, B2056_RX0 | B2056_RX_MIXG_CMFB_IDAC, 0x00); b43_radio_write(dev, B2056_RX1 | B2056_RX_MIXG_CMFB_IDAC, 0x00); diff --git a/drivers/net/wireless/b43/tables_nphy.c b/drivers/net/wireless/b43/tables_nphy.c index 7b326f2efdc9..4ec3d66439e6 100644 --- a/drivers/net/wireless/b43/tables_nphy.c +++ b/drivers/net/wireless/b43/tables_nphy.c @@ -2652,7 +2652,7 @@ const u16 tbl_tx_iqlo_cal_cmds_fullcal_nphyrev3[] = { const s16 tbl_tx_filter_coef_rev4[7][15] = { { -377, 137, -407, 208, -1527, 956, 93, 186, 93, 230, - -44, 230, 20, -191, 201 }, + -44, 230, 201, -191, 201 }, { -77, 20, -98, 49, -93, 60, 56, 111, 56, 26, -5, 26, 34, -32, 34 }, diff --git a/drivers/net/wireless/b43/tables_nphy.h b/drivers/net/wireless/b43/tables_nphy.h index a81696bff0ed..ddca0ddbb857 100644 --- a/drivers/net/wireless/b43/tables_nphy.h +++ b/drivers/net/wireless/b43/tables_nphy.h @@ -127,25 +127,25 @@ struct nphy_gain_ctl_workaround_entry *b43_nphy_get_gain_ctl_workaround_ent( #define B43_NTAB_C1_LOFEEDTH_SIZE 128 /* Static N-PHY tables, PHY revision >= 3 */ -#define B43_NTAB_FRAMESTRUCT_R3 B43_NTAB32(10, 000) /* frame struct */ -#define B43_NTAB_PILOT_R3 B43_NTAB16(11, 000) /* pilot */ -#define B43_NTAB_TMAP_R3 B43_NTAB32(12, 000) /* TM AP */ -#define B43_NTAB_INTLEVEL_R3 B43_NTAB32(13, 000) /* INT LV */ -#define B43_NTAB_TDTRN_R3 B43_NTAB32(14, 000) /* TD TRN */ -#define B43_NTAB_NOISEVAR0_R3 B43_NTAB32(16, 000) /* noise variance 0 */ +#define B43_NTAB_FRAMESTRUCT_R3 B43_NTAB32(10, 0) /* frame struct */ +#define B43_NTAB_PILOT_R3 B43_NTAB16(11, 0) /* pilot */ +#define B43_NTAB_TMAP_R3 B43_NTAB32(12, 0) /* TM AP */ +#define B43_NTAB_INTLEVEL_R3 B43_NTAB32(13, 0) /* INT LV */ +#define B43_NTAB_TDTRN_R3 B43_NTAB32(14, 0) /* TD TRN */ +#define B43_NTAB_NOISEVAR0_R3 B43_NTAB32(16, 0) /* noise variance 0 */ #define B43_NTAB_NOISEVAR1_R3 B43_NTAB32(16, 128) /* noise variance 1 */ -#define B43_NTAB_MCS_R3 B43_NTAB16(18, 000) /* MCS */ +#define B43_NTAB_MCS_R3 B43_NTAB16(18, 0) /* MCS */ #define B43_NTAB_TDI20A0_R3 B43_NTAB32(19, 128) /* TDI 20/0 */ #define B43_NTAB_TDI20A1_R3 B43_NTAB32(19, 256) /* TDI 20/1 */ #define B43_NTAB_TDI40A0_R3 B43_NTAB32(19, 640) /* TDI 40/0 */ #define B43_NTAB_TDI40A1_R3 B43_NTAB32(19, 768) /* TDI 40/1 */ -#define B43_NTAB_PILOTLT_R3 B43_NTAB32(20, 000) /* PLT lookup */ -#define B43_NTAB_CHANEST_R3 B43_NTAB32(22, 000) /* channel estimate */ -#define B43_NTAB_FRAMELT_R3 B43_NTAB8 (24, 000) /* frame lookup */ -#define B43_NTAB_C0_ESTPLT_R3 B43_NTAB8 (26, 000) /* estimated power lookup 0 */ -#define B43_NTAB_C1_ESTPLT_R3 B43_NTAB8 (27, 000) /* estimated power lookup 1 */ -#define B43_NTAB_C0_ADJPLT_R3 B43_NTAB8 (26, 064) /* adjusted power lookup 0 */ -#define B43_NTAB_C1_ADJPLT_R3 B43_NTAB8 (27, 064) /* adjusted power lookup 1 */ +#define B43_NTAB_PILOTLT_R3 B43_NTAB32(20, 0) /* PLT lookup */ +#define B43_NTAB_CHANEST_R3 B43_NTAB32(22, 0) /* channel estimate */ +#define B43_NTAB_FRAMELT_R3 B43_NTAB8(24, 0) /* frame lookup */ +#define B43_NTAB_C0_ESTPLT_R3 B43_NTAB8(26, 0) /* estimated power lookup 0 */ +#define B43_NTAB_C1_ESTPLT_R3 B43_NTAB8(27, 0) /* estimated power lookup 1 */ +#define B43_NTAB_C0_ADJPLT_R3 B43_NTAB8(26, 64) /* adjusted power lookup 0 */ +#define B43_NTAB_C1_ADJPLT_R3 B43_NTAB8(27, 64) /* adjusted power lookup 1 */ #define B43_NTAB_C0_GAINCTL_R3 B43_NTAB32(26, 192) /* gain control lookup 0 */ #define B43_NTAB_C1_GAINCTL_R3 B43_NTAB32(27, 192) /* gain control lookup 1 */ #define B43_NTAB_C0_IQLT_R3 B43_NTAB32(26, 320) /* I/Q lookup 0 */ -- cgit v1.2.3 From 3c17dd414864bbd637379455e2f4885ef3aa7778 Mon Sep 17 00:00:00 2001 From: Rafał Miłecki Date: Sun, 11 Dec 2011 02:55:30 +0100 Subject: b43: N-PHY: update some init values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes were obtained from MMIO dump from 5.100.82.112. Signed-off-by: Rafał Miłecki Signed-off-by: John W. Linville --- drivers/net/wireless/b43/phy_n.c | 24 ++++++++++++------------ drivers/net/wireless/b43/radio_2056.c | 10 +++++----- 2 files changed, 17 insertions(+), 17 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c index f40d8049d310..f540e482b3c7 100644 --- a/drivers/net/wireless/b43/phy_n.c +++ b/drivers/net/wireless/b43/phy_n.c @@ -1591,18 +1591,18 @@ static void b43_nphy_workarounds_rev3plus(struct b43_wldev *dev) 0x70); } - b43_phy_write(dev, 0x224, 0x039C); - b43_phy_write(dev, 0x225, 0x0357); - b43_phy_write(dev, 0x226, 0x0317); - b43_phy_write(dev, 0x227, 0x02D7); - b43_phy_write(dev, 0x228, 0x039C); - b43_phy_write(dev, 0x229, 0x0357); - b43_phy_write(dev, 0x22A, 0x0317); - b43_phy_write(dev, 0x22B, 0x02D7); - b43_phy_write(dev, 0x22C, 0x039C); - b43_phy_write(dev, 0x22D, 0x0357); - b43_phy_write(dev, 0x22E, 0x0317); - b43_phy_write(dev, 0x22F, 0x02D7); + b43_phy_write(dev, 0x224, 0x03eb); + b43_phy_write(dev, 0x225, 0x03eb); + b43_phy_write(dev, 0x226, 0x0341); + b43_phy_write(dev, 0x227, 0x0341); + b43_phy_write(dev, 0x228, 0x042b); + b43_phy_write(dev, 0x229, 0x042b); + b43_phy_write(dev, 0x22a, 0x0381); + b43_phy_write(dev, 0x22b, 0x0381); + b43_phy_write(dev, 0x22c, 0x042b); + b43_phy_write(dev, 0x22d, 0x042b); + b43_phy_write(dev, 0x22e, 0x0381); + b43_phy_write(dev, 0x22f, 0x0381); } static void b43_nphy_workarounds_rev1_2(struct b43_wldev *dev) diff --git a/drivers/net/wireless/b43/radio_2056.c b/drivers/net/wireless/b43/radio_2056.c index a01f776ca4de..4a42994f4933 100644 --- a/drivers/net/wireless/b43/radio_2056.c +++ b/drivers/net/wireless/b43/radio_2056.c @@ -1572,14 +1572,14 @@ static const struct b2056_inittab_entry b2056_inittab_rev6_syn[] = { [B2056_SYN_PLL_XTAL5] = { .ghz5 = 0x0077, .ghz2 = 0x0077, NOUPLOAD, }, [B2056_SYN_PLL_XTAL6] = { .ghz5 = 0x0007, .ghz2 = 0x0007, NOUPLOAD, }, [B2056_SYN_PLL_REFDIV] = { .ghz5 = 0x0001, .ghz2 = 0x0001, NOUPLOAD, }, - [B2056_SYN_PLL_PFD] = { .ghz5 = 0x0004, .ghz2 = 0x0004, NOUPLOAD, }, + [B2056_SYN_PLL_PFD] = { .ghz5 = 0x0006, .ghz2 = 0x0006, UPLOAD, }, [B2056_SYN_PLL_CP1] = { .ghz5 = 0x000f, .ghz2 = 0x000f, NOUPLOAD, }, - [B2056_SYN_PLL_CP2] = { .ghz5 = 0x0030, .ghz2 = 0x0030, NOUPLOAD, }, + [B2056_SYN_PLL_CP2] = { .ghz5 = 0x003f, .ghz2 = 0x003f, UPLOAD, }, [B2056_SYN_PLL_CP3] = { .ghz5 = 0x0032, .ghz2 = 0x0032, NOUPLOAD, }, - [B2056_SYN_PLL_LOOPFILTER1] = { .ghz5 = 0x000d, .ghz2 = 0x000d, NOUPLOAD, }, - [B2056_SYN_PLL_LOOPFILTER2] = { .ghz5 = 0x000d, .ghz2 = 0x000d, NOUPLOAD, }, + [B2056_SYN_PLL_LOOPFILTER1] = { .ghz5 = 0x0006, .ghz2 = 0x0006, UPLOAD, }, + [B2056_SYN_PLL_LOOPFILTER2] = { .ghz5 = 0x0006, .ghz2 = 0x0006, UPLOAD, }, [B2056_SYN_PLL_LOOPFILTER3] = { .ghz5 = 0x0004, .ghz2 = 0x0004, NOUPLOAD, }, - [B2056_SYN_PLL_LOOPFILTER4] = { .ghz5 = 0x0006, .ghz2 = 0x0006, NOUPLOAD, }, + [B2056_SYN_PLL_LOOPFILTER4] = { .ghz5 = 0x002b, .ghz2 = 0x002b, UPLOAD, }, [B2056_SYN_PLL_LOOPFILTER5] = { .ghz5 = 0x0001, .ghz2 = 0x0001, NOUPLOAD, }, [B2056_SYN_PLL_MMD1] = { .ghz5 = 0x001c, .ghz2 = 0x001c, NOUPLOAD, }, [B2056_SYN_PLL_MMD2] = { .ghz5 = 0x0002, .ghz2 = 0x0002, NOUPLOAD, }, -- cgit v1.2.3 From 9a2e85de2c2ff85bbf2891f8a29cded5dbff5e05 Mon Sep 17 00:00:00 2001 From: Rafał Miłecki Date: Sun, 11 Dec 2011 02:55:31 +0100 Subject: b43: N-PHY: workaround BCM43224 hw bug in writing table id 9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rafał Miłecki Signed-off-by: John W. Linville --- drivers/net/wireless/b43/tables_nphy.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/b43/tables_nphy.c b/drivers/net/wireless/b43/tables_nphy.c index 4ec3d66439e6..05ab6a466703 100644 --- a/drivers/net/wireless/b43/tables_nphy.c +++ b/drivers/net/wireless/b43/tables_nphy.c @@ -2932,6 +2932,13 @@ void b43_ntab_write_bulk(struct b43_wldev *dev, u32 offset, b43_phy_write(dev, B43_NPHY_TABLE_ADDR, offset); for (i = 0; i < nr_elements; i++) { + /* Auto increment broken + caching issue on BCM43224? */ + if ((offset >> 10) == 9 && dev->dev->chip_id == 43224 && + dev->dev->chip_rev == 1) { + b43_phy_read(dev, B43_NPHY_TABLE_DATALO); + b43_phy_write(dev, B43_NPHY_TABLE_ADDR, offset + i); + } + switch (type) { case B43_NTAB_8BIT: value = *data; -- cgit v1.2.3 From 66d80a51e8a6fbca35bdce69db813288826ce9aa Mon Sep 17 00:00:00 2001 From: Rafał Miłecki Date: Sun, 11 Dec 2011 02:55:32 +0100 Subject: b43: N-PHY: add table for antenna software control MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rafał Miłecki Signed-off-by: John W. Linville --- drivers/net/wireless/b43/tables_nphy.c | 50 +++++++++++++++++++++++++++++++++- drivers/net/wireless/b43/tables_nphy.h | 3 ++ 2 files changed, 52 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/b43/tables_nphy.c b/drivers/net/wireless/b43/tables_nphy.c index 05ab6a466703..691839e7541c 100644 --- a/drivers/net/wireless/b43/tables_nphy.c +++ b/drivers/net/wireless/b43/tables_nphy.c @@ -2171,6 +2171,48 @@ static const u16 b43_ntab_loftlt1_r3[] = { 0x0000, 0x0000, }; +/* volatile tables, PHY revision >= 3 */ + +/* indexed by antswctl2g */ +static const u16 b43_ntab_antswctl2g_r3[4][32] = { + { + 0x0082, 0x0082, 0x0211, 0x0222, 0x0328, + 0x0000, 0x0000, 0x0000, 0x0144, 0x0000, + 0x0000, 0x0000, 0x0188, 0x0000, 0x0000, + 0x0000, 0x0082, 0x0082, 0x0211, 0x0222, + 0x0328, 0x0000, 0x0000, 0x0000, 0x0144, + 0x0000, 0x0000, 0x0000, 0x0188, 0x0000, + 0x0000, 0x0000, + }, + { + 0x0022, 0x0022, 0x0011, 0x0022, 0x0022, + 0x0000, 0x0000, 0x0000, 0x0011, 0x0000, + 0x0000, 0x0000, 0x0022, 0x0000, 0x0000, + 0x0000, 0x0022, 0x0022, 0x0011, 0x0022, + 0x0022, 0x0000, 0x0000, 0x0000, 0x0011, + 0x0000, 0x0000, 0x0000, 0x0022, 0x0000, + 0x0000, 0x0000, + }, + { + 0x0088, 0x0088, 0x0044, 0x0088, 0x0088, + 0x0000, 0x0000, 0x0000, 0x0044, 0x0000, + 0x0000, 0x0000, 0x0088, 0x0000, 0x0000, + 0x0000, 0x0088, 0x0088, 0x0044, 0x0088, + 0x0088, 0x0000, 0x0000, 0x0000, 0x0044, + 0x0000, 0x0000, 0x0000, 0x0088, 0x0000, + 0x0000, 0x0000, + }, + { + 0x0022, 0x0022, 0x0011, 0x0022, 0x0000, + 0x0000, 0x0000, 0x0000, 0x0011, 0x0000, + 0x0000, 0x0000, 0x0022, 0x0000, 0x0000, + 0x03cc, 0x0022, 0x0022, 0x0011, 0x0022, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0011, + 0x0000, 0x0000, 0x0000, 0x0022, 0x0000, + 0x0000, 0x03cc, + } +}; + /* TX gain tables */ const u32 b43_ntab_tx_gain_rev0_1_2[] = { 0x03cc2b44, 0x03cc2b42, 0x03cc2a44, 0x03cc2a42, @@ -3006,6 +3048,8 @@ void b43_nphy_rev0_1_2_tables_init(struct b43_wldev *dev) } while (0) void b43_nphy_rev3plus_tables_init(struct b43_wldev *dev) { + struct ssb_sprom *sprom = dev->dev->bus_sprom; + /* Static tables */ ntab_upload_r3(dev, B43_NTAB_FRAMESTRUCT_R3, b43_ntab_framestruct_r3); ntab_upload_r3(dev, B43_NTAB_PILOT_R3, b43_ntab_pilot_r3); @@ -3036,7 +3080,11 @@ void b43_nphy_rev3plus_tables_init(struct b43_wldev *dev) ntab_upload_r3(dev, B43_NTAB_C1_LOFEEDTH_R3, b43_ntab_loftlt1_r3); /* Volatile tables */ - /* TODO */ + if (sprom->fem.ghz2.antswlut < ARRAY_SIZE(b43_ntab_antswctl2g_r3)) + ntab_upload_r3(dev, B43_NTAB_ANT_SW_CTL_R3, + b43_ntab_antswctl2g_r3[sprom->fem.ghz2.antswlut]); + else + B43_WARN_ON(1); } struct nphy_gain_ctl_workaround_entry *b43_nphy_get_gain_ctl_workaround_ent( diff --git a/drivers/net/wireless/b43/tables_nphy.h b/drivers/net/wireless/b43/tables_nphy.h index ddca0ddbb857..97038c481930 100644 --- a/drivers/net/wireless/b43/tables_nphy.h +++ b/drivers/net/wireless/b43/tables_nphy.h @@ -126,6 +126,9 @@ struct nphy_gain_ctl_workaround_entry *b43_nphy_get_gain_ctl_workaround_ent( #define B43_NTAB_C1_LOFEEDTH B43_NTAB16(0x1B, 0x1C0) /* Local Oscillator Feed Through Lookup Table Core 1 */ #define B43_NTAB_C1_LOFEEDTH_SIZE 128 +/* Volatile N-PHY tables, PHY revision >= 3 */ +#define B43_NTAB_ANT_SW_CTL_R3 B43_NTAB16( 9, 0) /* antenna software control */ + /* Static N-PHY tables, PHY revision >= 3 */ #define B43_NTAB_FRAMESTRUCT_R3 B43_NTAB32(10, 0) /* frame struct */ #define B43_NTAB_PILOT_R3 B43_NTAB16(11, 0) /* pilot */ -- cgit v1.2.3 From c7d6431035089565eec9f5138943498fa60f875c Mon Sep 17 00:00:00 2001 From: Rafał Miłecki Date: Sun, 11 Dec 2011 02:55:33 +0100 Subject: b43: N-PHY: determine various PHY params MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rafał Miłecki Signed-off-by: John W. Linville --- drivers/net/wireless/b43/phy_n.c | 35 +++++++++++++++++++++++++++++++++++ drivers/net/wireless/b43/phy_n.h | 8 ++++++++ 2 files changed, 43 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c index f540e482b3c7..4bd94dfef1eb 100644 --- a/drivers/net/wireless/b43/phy_n.c +++ b/drivers/net/wireless/b43/phy_n.c @@ -4062,10 +4062,13 @@ static void b43_nphy_op_prepare_structs(struct b43_wldev *dev) { struct b43_phy *phy = &dev->phy; struct b43_phy_n *nphy = phy->n; + struct ssb_sprom *sprom = dev->dev->bus_sprom; memset(nphy, 0, sizeof(*nphy)); nphy->hang_avoid = (phy->rev == 3 || phy->rev == 4); + nphy->spur_avoid = (phy->rev >= 3) ? + B43_SPUR_AVOID_AUTO : B43_SPUR_AVOID_DISABLE; nphy->gain_boost = true; /* this way we follow wl, assume it is true */ nphy->txrx_chain = 2; /* sth different than 0 and 1 for now */ nphy->phyrxchain = 3; /* to avoid b43_nphy_set_rx_core_state like wl */ @@ -4074,6 +4077,38 @@ static void b43_nphy_op_prepare_structs(struct b43_wldev *dev) * 0x7f == 127 and we check for 128 when restoring TX pwr ctl. */ nphy->tx_pwr_idx[0] = 128; nphy->tx_pwr_idx[1] = 128; + + /* Hardware TX power control and 5GHz power gain */ + nphy->txpwrctrl = false; + nphy->pwg_gain_5ghz = false; + if (dev->phy.rev >= 3 || + (dev->dev->board_vendor == PCI_VENDOR_ID_APPLE && + (dev->dev->core_rev == 11 || dev->dev->core_rev == 12))) { + nphy->txpwrctrl = true; + nphy->pwg_gain_5ghz = true; + } else if (sprom->revision >= 4) { + if (dev->phy.rev >= 2 && + (sprom->boardflags2_lo & B43_BFL2_TXPWRCTRL_EN)) { + nphy->txpwrctrl = true; +#ifdef CONFIG_B43_SSB + if (dev->dev->bus_type == B43_BUS_SSB && + dev->dev->sdev->bus->bustype == SSB_BUSTYPE_PCI) { + struct pci_dev *pdev = + dev->dev->sdev->bus->host_pci; + if (pdev->device == 0x4328 || + pdev->device == 0x432a) + nphy->pwg_gain_5ghz = true; + } +#endif + } else if (sprom->boardflags2_lo & B43_BFL2_5G_PWRGAIN) { + nphy->pwg_gain_5ghz = true; + } + } + + if (dev->phy.rev >= 3) { + nphy->ipa2g_on = sprom->fem.ghz2.extpa_gain == 2; + nphy->ipa5g_on = sprom->fem.ghz5.extpa_gain == 2; + } } static void b43_nphy_op_free(struct b43_wldev *dev) diff --git a/drivers/net/wireless/b43/phy_n.h b/drivers/net/wireless/b43/phy_n.h index fbf520285bd1..56ef97b5b815 100644 --- a/drivers/net/wireless/b43/phy_n.h +++ b/drivers/net/wireless/b43/phy_n.h @@ -716,6 +716,12 @@ struct b43_wldev; +enum b43_nphy_spur_avoid { + B43_SPUR_AVOID_DISABLE, + B43_SPUR_AVOID_AUTO, + B43_SPUR_AVOID_FORCE, +}; + struct b43_chanspec { u16 center_freq; enum nl80211_channel_type channel_type; @@ -785,6 +791,7 @@ struct b43_phy_n { u16 mphase_txcal_bestcoeffs[11]; bool txpwrctrl; + bool pwg_gain_5ghz; u8 tx_pwr_idx[2]; u16 adj_pwr_tbl[84]; u16 txcal_bbmult; @@ -803,6 +810,7 @@ struct b43_phy_n { u16 classifier_state; u16 clip_state[2]; + enum b43_nphy_spur_avoid spur_avoid; bool aband_spurwar_en; bool gband_spurwar_en; -- cgit v1.2.3 From 38646ebae710da024bdf6e9dcac733bfdb6dd3e1 Mon Sep 17 00:00:00 2001 From: Rafał Miłecki Date: Sun, 11 Dec 2011 02:55:34 +0100 Subject: b43: N-PHY: finish 2.4GHz 0x2056 radio setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rafał Miłecki Signed-off-by: John W. Linville --- drivers/net/wireless/b43/phy_n.c | 90 ++++++++++++++++++++++++++++++++++- drivers/net/wireless/b43/radio_2056.c | 15 ++++++ drivers/net/wireless/b43/radio_2056.h | 1 + 3 files changed, 105 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c index 4bd94dfef1eb..114c413db482 100644 --- a/drivers/net/wireless/b43/phy_n.c +++ b/drivers/net/wireless/b43/phy_n.c @@ -228,10 +228,98 @@ static void b43_chantab_radio_2056_upload(struct b43_wldev *dev, static void b43_radio_2056_setup(struct b43_wldev *dev, const struct b43_nphy_channeltab_entry_rev3 *e) { + struct ssb_sprom *sprom = dev->dev->bus_sprom; + enum ieee80211_band band = b43_current_band(dev->wl); + u16 offset; + u8 i; + u16 bias, cbias, pag_boost, pgag_boost, mixg_boost, padg_boost; + B43_WARN_ON(dev->phy.rev < 3); b43_chantab_radio_2056_upload(dev, e); - /* TODO */ + b2056_upload_syn_pll_cp2(dev, band == IEEE80211_BAND_5GHZ); + + if (sprom->boardflags2_lo & B43_BFL2_GPLL_WAR && + b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ) { + b43_radio_write(dev, B2056_SYN_PLL_LOOPFILTER1, 0x1F); + b43_radio_write(dev, B2056_SYN_PLL_LOOPFILTER2, 0x1F); + if (dev->dev->chip_id == 0x4716) { + b43_radio_write(dev, B2056_SYN_PLL_LOOPFILTER4, 0x14); + b43_radio_write(dev, B2056_SYN_PLL_CP2, 0); + } else { + b43_radio_write(dev, B2056_SYN_PLL_LOOPFILTER4, 0x0B); + b43_radio_write(dev, B2056_SYN_PLL_CP2, 0x14); + } + } + if (sprom->boardflags2_lo & B43_BFL2_APLL_WAR && + b43_current_band(dev->wl) == IEEE80211_BAND_5GHZ) { + b43_radio_write(dev, B2056_SYN_PLL_LOOPFILTER1, 0x1F); + b43_radio_write(dev, B2056_SYN_PLL_LOOPFILTER2, 0x1F); + b43_radio_write(dev, B2056_SYN_PLL_LOOPFILTER4, 0x05); + b43_radio_write(dev, B2056_SYN_PLL_CP2, 0x0C); + } + + if (dev->phy.n->ipa2g_on && band == IEEE80211_BAND_2GHZ) { + for (i = 0; i < 2; i++) { + offset = i ? B2056_TX1 : B2056_TX0; + if (dev->phy.rev >= 5) { + b43_radio_write(dev, + offset | B2056_TX_PADG_IDAC, 0xcc); + + if (dev->dev->chip_id == 0x4716) { + bias = 0x40; + cbias = 0x45; + pag_boost = 0x5; + pgag_boost = 0x33; + mixg_boost = 0x55; + } else { + bias = 0x25; + cbias = 0x20; + pag_boost = 0x4; + pgag_boost = 0x03; + mixg_boost = 0x65; + } + padg_boost = 0x77; + + b43_radio_write(dev, + offset | B2056_TX_INTPAG_IMAIN_STAT, + bias); + b43_radio_write(dev, + offset | B2056_TX_INTPAG_IAUX_STAT, + bias); + b43_radio_write(dev, + offset | B2056_TX_INTPAG_CASCBIAS, + cbias); + b43_radio_write(dev, + offset | B2056_TX_INTPAG_BOOST_TUNE, + pag_boost); + b43_radio_write(dev, + offset | B2056_TX_PGAG_BOOST_TUNE, + pgag_boost); + b43_radio_write(dev, + offset | B2056_TX_PADG_BOOST_TUNE, + padg_boost); + b43_radio_write(dev, + offset | B2056_TX_MIXG_BOOST_TUNE, + mixg_boost); + } else { + bias = dev->phy.is_40mhz ? 0x40 : 0x20; + b43_radio_write(dev, + offset | B2056_TX_INTPAG_IMAIN_STAT, + bias); + b43_radio_write(dev, + offset | B2056_TX_INTPAG_IAUX_STAT, + bias); + b43_radio_write(dev, + offset | B2056_TX_INTPAG_CASCBIAS, + 0x30); + } + b43_radio_write(dev, offset | B2056_TX_PA_SPARE1, 0xee); + } + } else if (dev->phy.n->ipa5g_on && band == IEEE80211_BAND_5GHZ) { + /* TODO */ + } + udelay(50); /* VCO calibration */ b43_radio_write(dev, B2056_SYN_PLL_VCOCAL12, 0x00); diff --git a/drivers/net/wireless/b43/radio_2056.c b/drivers/net/wireless/b43/radio_2056.c index 4a42994f4933..ce037fb6789a 100644 --- a/drivers/net/wireless/b43/radio_2056.c +++ b/drivers/net/wireless/b43/radio_2056.c @@ -9055,6 +9055,21 @@ void b2056_upload_inittabs(struct b43_wldev *dev, B2056_RX1, pts->rx, pts->rx_length); } +void b2056_upload_syn_pll_cp2(struct b43_wldev *dev, bool ghz5) +{ + struct b2056_inittabs_pts *pts; + const struct b2056_inittab_entry *e; + + if (dev->phy.rev >= ARRAY_SIZE(b2056_inittabs)) { + B43_WARN_ON(1); + return; + } + pts = &b2056_inittabs[dev->phy.rev]; + e = &pts->syn[B2056_SYN_PLL_CP2]; + + b43_radio_write(dev, B2056_SYN_PLL_CP2, ghz5 ? e->ghz5 : e->ghz2); +} + const struct b43_nphy_channeltab_entry_rev3 * b43_nphy_get_chantabent_rev3(struct b43_wldev *dev, u16 freq) { diff --git a/drivers/net/wireless/b43/radio_2056.h b/drivers/net/wireless/b43/radio_2056.h index a7159d8578be..5b86673459fa 100644 --- a/drivers/net/wireless/b43/radio_2056.h +++ b/drivers/net/wireless/b43/radio_2056.h @@ -1090,6 +1090,7 @@ struct b43_nphy_channeltab_entry_rev3 { void b2056_upload_inittabs(struct b43_wldev *dev, bool ghz5, bool ignore_uploadflag); +void b2056_upload_syn_pll_cp2(struct b43_wldev *dev, bool ghz5); /* Get the NPHY Channel Switch Table entry for a channel. * Returns NULL on failure to find an entry. */ -- cgit v1.2.3 From 49d55cef5b1925a5c1efb6aaddaa40fc7c693335 Mon Sep 17 00:00:00 2001 From: Rafał Miłecki Date: Sun, 11 Dec 2011 13:16:51 +0100 Subject: b43: N-PHY: implement spurious tone avoidance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rafał Miłecki Signed-off-by: John W. Linville --- drivers/net/wireless/b43/phy_n.c | 93 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c index 114c413db482..730f5a451de3 100644 --- a/drivers/net/wireless/b43/phy_n.c +++ b/drivers/net/wireless/b43/phy_n.c @@ -4023,6 +4023,61 @@ int b43_phy_initn(struct b43_wldev *dev) return 0; } +/* http://bcm-v4.sipsolutions.net/802.11/PmuSpurAvoid */ +static void b43_nphy_pmu_spur_avoid(struct b43_wldev *dev, bool avoid) +{ + struct bcma_drv_cc *cc = &dev->dev->bdev->bus->drv_cc; + u32 pmu_ctl; + if (dev->dev->chip_id == 43224 || dev->dev->chip_id == 43225) { + if (avoid) { + bcma_chipco_pll_write(cc, 0x0, 0x11500010); + bcma_chipco_pll_write(cc, 0x1, 0x000C0C06); + bcma_chipco_pll_write(cc, 0x2, 0x0F600a08); + bcma_chipco_pll_write(cc, 0x3, 0x00000000); + bcma_chipco_pll_write(cc, 0x4, 0x2001E920); + bcma_chipco_pll_write(cc, 0x5, 0x88888815); + } else { + bcma_chipco_pll_write(cc, 0x0, 0x11100010); + bcma_chipco_pll_write(cc, 0x1, 0x000c0c06); + bcma_chipco_pll_write(cc, 0x2, 0x03000a08); + bcma_chipco_pll_write(cc, 0x3, 0x00000000); + bcma_chipco_pll_write(cc, 0x4, 0x200005c0); + bcma_chipco_pll_write(cc, 0x5, 0x88888815); + } + pmu_ctl = BCMA_CC_PMU_CTL_PLL_UPD; + } else if (dev->dev->chip_id == 0x4716) { + if (avoid) { + bcma_chipco_pll_write(cc, 0x0, 0x11500060); + bcma_chipco_pll_write(cc, 0x1, 0x080C0C06); + bcma_chipco_pll_write(cc, 0x2, 0x0F600000); + bcma_chipco_pll_write(cc, 0x3, 0x00000000); + bcma_chipco_pll_write(cc, 0x4, 0x2001E924); + bcma_chipco_pll_write(cc, 0x5, 0x88888815); + } else { + bcma_chipco_pll_write(cc, 0x0, 0x11100060); + bcma_chipco_pll_write(cc, 0x1, 0x080c0c06); + bcma_chipco_pll_write(cc, 0x2, 0x03000000); + bcma_chipco_pll_write(cc, 0x3, 0x00000000); + bcma_chipco_pll_write(cc, 0x4, 0x200005c0); + bcma_chipco_pll_write(cc, 0x5, 0x88888815); + } + pmu_ctl = BCMA_CC_PMU_CTL_PLL_UPD | BCMA_CC_PMU_CTL_NOILPONW; + } else if (dev->dev->chip_id == 0x4322 || dev->dev->chip_id == 0x4340 || + dev->dev->chip_id == 0x4341) { + bcma_chipco_pll_write(cc, 0x0, 0x11100070); + bcma_chipco_pll_write(cc, 0x1, 0x1014140a); + bcma_chipco_pll_write(cc, 0x5, 0x88888854); + if (avoid) + bcma_chipco_pll_write(cc, 0x2, 0x05201828); + else + bcma_chipco_pll_write(cc, 0x2, 0x05001828); + pmu_ctl = BCMA_CC_PMU_CTL_PLL_UPD; + } else { + return; + } + bcma_cc_set32(cc, BCMA_CC_PMU_CTL, pmu_ctl); +} + /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/ChanspecSetup */ static void b43_nphy_channel_setup(struct b43_wldev *dev, const struct b43_phy_n_sfo_cfg *e, @@ -4030,6 +4085,7 @@ static void b43_nphy_channel_setup(struct b43_wldev *dev, { struct b43_phy *phy = &dev->phy; struct b43_phy_n *nphy = dev->phy.n; + int ch = new_channel->hw_value; u16 old_band_5ghz; u32 tmp32; @@ -4069,8 +4125,41 @@ static void b43_nphy_channel_setup(struct b43_wldev *dev, b43_nphy_tx_lp_fbw(dev); - if (dev->phy.rev >= 3 && 0) { - /* TODO */ + if (dev->phy.rev >= 3 && + dev->phy.n->spur_avoid != B43_SPUR_AVOID_DISABLE) { + bool avoid = false; + if (dev->phy.n->spur_avoid == B43_SPUR_AVOID_FORCE) { + avoid = true; + } else if (!b43_channel_type_is_40mhz(phy->channel_type)) { + if ((ch >= 5 && ch <= 8) || ch == 13 || ch == 14) + avoid = true; + } else { /* 40MHz */ + if (nphy->aband_spurwar_en && + (ch == 38 || ch == 102 || ch == 118)) + avoid = dev->dev->chip_id == 0x4716; + } + + b43_nphy_pmu_spur_avoid(dev, avoid); + + if (dev->dev->chip_id == 43222 || dev->dev->chip_id == 43224 || + dev->dev->chip_id == 43225) { + b43_write16(dev, B43_MMIO_TSF_CLK_FRAC_LOW, + avoid ? 0x5341 : 0x8889); + b43_write16(dev, B43_MMIO_TSF_CLK_FRAC_HIGH, 0x8); + } + + if (dev->phy.rev == 3 || dev->phy.rev == 4) + ; /* TODO: reset PLL */ + + if (avoid) + b43_phy_set(dev, B43_NPHY_BBCFG, B43_NPHY_BBCFG_RSTRX); + else + b43_phy_mask(dev, B43_NPHY_BBCFG, + ~B43_NPHY_BBCFG_RSTRX & 0xFFFF); + + b43_nphy_reset_cca(dev); + + /* wl sets useless phy_isspuravoid here */ } b43_phy_write(dev, B43_NPHY_NDATAT_DUP40, 0x3830); -- cgit v1.2.3 From 41affd5286fb91176eb99b34ecd8eb522ba22369 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 12 Dec 2011 12:43:23 +0100 Subject: rtlwifi: use work for lps Leaving leisure power save mode can take some time, so it's better to perform that action in process context with interrupts enabled. This patch changes lps_leave tasklet to work. Reported-by: Philipp Dreimann Tested-by: Larry Finger Cc: Mike McCormack Cc: Chaoming Li Signed-off-by: Stanislaw Gruszka Signed-off-by: Larry Finger Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/pci.c | 26 ++++++++++++++------------ drivers/net/wireless/rtlwifi/wifi.h | 3 ++- 2 files changed, 16 insertions(+), 13 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c index 91f0525364ea..0d4d242849b4 100644 --- a/drivers/net/wireless/rtlwifi/pci.c +++ b/drivers/net/wireless/rtlwifi/pci.c @@ -610,7 +610,7 @@ tx_status_ok: if (((rtlpriv->link_info.num_rx_inperiod + rtlpriv->link_info.num_tx_inperiod) > 8) || (rtlpriv->link_info.num_rx_inperiod > 2)) { - tasklet_schedule(&rtlpriv->works.ips_leave_tasklet); + schedule_work(&rtlpriv->works.lps_leave_work); } } @@ -736,7 +736,7 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw) if (((rtlpriv->link_info.num_rx_inperiod + rtlpriv->link_info.num_tx_inperiod) > 8) || (rtlpriv->link_info.num_rx_inperiod > 2)) { - tasklet_schedule(&rtlpriv->works.ips_leave_tasklet); + schedule_work(&rtlpriv->works.lps_leave_work); } dev_kfree_skb_any(skb); @@ -903,11 +903,6 @@ static void _rtl_pci_irq_tasklet(struct ieee80211_hw *hw) _rtl_pci_tx_chk_waitq(hw); } -static void _rtl_pci_ips_leave_tasklet(struct ieee80211_hw *hw) -{ - rtl_lps_leave(hw); -} - static void _rtl_pci_prepare_bcn_tasklet(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); @@ -945,6 +940,15 @@ static void _rtl_pci_prepare_bcn_tasklet(struct ieee80211_hw *hw) return; } +static void rtl_lps_leave_work_callback(struct work_struct *work) +{ + struct rtl_works *rtlworks = + container_of(work, struct rtl_works, lps_leave_work); + struct ieee80211_hw *hw = rtlworks->hw; + + rtl_lps_leave(hw); +} + static void _rtl_pci_init_trx_var(struct ieee80211_hw *hw) { struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); @@ -1006,9 +1010,7 @@ static void _rtl_pci_init_struct(struct ieee80211_hw *hw, tasklet_init(&rtlpriv->works.irq_prepare_bcn_tasklet, (void (*)(unsigned long))_rtl_pci_prepare_bcn_tasklet, (unsigned long)hw); - tasklet_init(&rtlpriv->works.ips_leave_tasklet, - (void (*)(unsigned long))_rtl_pci_ips_leave_tasklet, - (unsigned long)hw); + INIT_WORK(&rtlpriv->works.lps_leave_work, rtl_lps_leave_work_callback); } static int _rtl_pci_init_tx_ring(struct ieee80211_hw *hw, @@ -1478,7 +1480,7 @@ static void rtl_pci_deinit(struct ieee80211_hw *hw) synchronize_irq(rtlpci->pdev->irq); tasklet_kill(&rtlpriv->works.irq_tasklet); - tasklet_kill(&rtlpriv->works.ips_leave_tasklet); + cancel_work_sync(&rtlpriv->works.lps_leave_work); flush_workqueue(rtlpriv->works.rtl_wq); destroy_workqueue(rtlpriv->works.rtl_wq); @@ -1553,7 +1555,7 @@ static void rtl_pci_stop(struct ieee80211_hw *hw) set_hal_stop(rtlhal); rtlpriv->cfg->ops->disable_interrupt(hw); - tasklet_kill(&rtlpriv->works.ips_leave_tasklet); + cancel_work_sync(&rtlpriv->works.lps_leave_work); spin_lock_irqsave(&rtlpriv->locks.rf_ps_lock, flags); while (ppsc->rfchange_inprogress) { diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h index f3c132b55d42..6e6353bbc7b4 100644 --- a/drivers/net/wireless/rtlwifi/wifi.h +++ b/drivers/net/wireless/rtlwifi/wifi.h @@ -1576,7 +1576,8 @@ struct rtl_works { /* For SW LPS */ struct delayed_work ps_work; struct delayed_work ps_rfon_wq; - struct tasklet_struct ips_leave_tasklet; + + struct work_struct lps_leave_work; }; struct rtl_debug { -- cgit v1.2.3 From 6539306b2c3ceafbc4094cf68c58094c282da053 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Mon, 12 Dec 2011 12:43:24 +0100 Subject: rtlwifi: merge ips,lps spinlocks into one mutex With previous patch "rtlwifi: use work for lps" we can now use mutex for protecting ps mode changing critical sections. This fixes running system with interrupts disabled for long time. Merge ips_lock and lps_lock as they seems to protect the same data structures (accessed in rtl_ps_set_rf_state() function). Reported-by: Philipp Dreimann Tested-by: Larry Finger Cc: Mike McCormack Cc: Chaoming Li Signed-off-by: Stanislaw Gruszka Signed-off-by: Larry Finger Tested-by: Tim Gardner Signed-off-by: John W. Linville --- drivers/net/wireless/rtlwifi/base.c | 3 +-- drivers/net/wireless/rtlwifi/ps.c | 21 ++++++++++----------- drivers/net/wireless/rtlwifi/wifi.h | 3 +-- 3 files changed, 12 insertions(+), 15 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rtlwifi/base.c b/drivers/net/wireless/rtlwifi/base.c index a13ecfce4825..d81a6021a30f 100644 --- a/drivers/net/wireless/rtlwifi/base.c +++ b/drivers/net/wireless/rtlwifi/base.c @@ -448,12 +448,11 @@ int rtl_init_core(struct ieee80211_hw *hw) /* <4> locks */ mutex_init(&rtlpriv->locks.conf_mutex); - spin_lock_init(&rtlpriv->locks.ips_lock); + mutex_init(&rtlpriv->locks.ps_mutex); spin_lock_init(&rtlpriv->locks.irq_th_lock); spin_lock_init(&rtlpriv->locks.h2c_lock); spin_lock_init(&rtlpriv->locks.rf_ps_lock); spin_lock_init(&rtlpriv->locks.rf_lock); - spin_lock_init(&rtlpriv->locks.lps_lock); spin_lock_init(&rtlpriv->locks.waitq_lock); spin_lock_init(&rtlpriv->locks.cck_and_rw_pagea_lock); diff --git a/drivers/net/wireless/rtlwifi/ps.c b/drivers/net/wireless/rtlwifi/ps.c index 55c8e50f45fd..a14a68b24635 100644 --- a/drivers/net/wireless/rtlwifi/ps.c +++ b/drivers/net/wireless/rtlwifi/ps.c @@ -241,7 +241,7 @@ void rtl_ips_nic_on(struct ieee80211_hw *hw) if (mac->opmode != NL80211_IFTYPE_STATION) return; - spin_lock(&rtlpriv->locks.ips_lock); + mutex_lock(&rtlpriv->locks.ps_mutex); if (ppsc->inactiveps) { rtstate = ppsc->rfpwr_state; @@ -257,7 +257,7 @@ void rtl_ips_nic_on(struct ieee80211_hw *hw) } } - spin_unlock(&rtlpriv->locks.ips_lock); + mutex_unlock(&rtlpriv->locks.ps_mutex); } /*for FW LPS*/ @@ -395,7 +395,7 @@ void rtl_lps_enter(struct ieee80211_hw *hw) if (mac->link_state != MAC80211_LINKED) return; - spin_lock_irq(&rtlpriv->locks.lps_lock); + mutex_lock(&rtlpriv->locks.ps_mutex); /* Idle for a while if we connect to AP a while ago. */ if (mac->cnt_after_linked >= 2) { @@ -407,7 +407,7 @@ void rtl_lps_enter(struct ieee80211_hw *hw) } } - spin_unlock_irq(&rtlpriv->locks.lps_lock); + mutex_unlock(&rtlpriv->locks.ps_mutex); } /*Leave the leisure power save mode.*/ @@ -416,9 +416,8 @@ void rtl_lps_leave(struct ieee80211_hw *hw) struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); - unsigned long flags; - spin_lock_irqsave(&rtlpriv->locks.lps_lock, flags); + mutex_lock(&rtlpriv->locks.ps_mutex); if (ppsc->fwctrl_lps) { if (ppsc->dot11_psmode != EACTIVE) { @@ -439,7 +438,7 @@ void rtl_lps_leave(struct ieee80211_hw *hw) rtl_lps_set_psmode(hw, EACTIVE); } } - spin_unlock_irqrestore(&rtlpriv->locks.lps_lock, flags); + mutex_unlock(&rtlpriv->locks.ps_mutex); } /* For sw LPS*/ @@ -540,9 +539,9 @@ void rtl_swlps_rf_awake(struct ieee80211_hw *hw) RT_CLEAR_PS_LEVEL(ppsc, RT_PS_LEVEL_ASPM); } - spin_lock_irq(&rtlpriv->locks.lps_lock); + mutex_lock(&rtlpriv->locks.ps_mutex); rtl_ps_set_rf_state(hw, ERFON, RF_CHANGE_BY_PS); - spin_unlock_irq(&rtlpriv->locks.lps_lock); + mutex_unlock(&rtlpriv->locks.ps_mutex); } void rtl_swlps_rfon_wq_callback(void *data) @@ -575,9 +574,9 @@ void rtl_swlps_rf_sleep(struct ieee80211_hw *hw) if (rtlpriv->link_info.busytraffic) return; - spin_lock_irq(&rtlpriv->locks.lps_lock); + mutex_lock(&rtlpriv->locks.ps_mutex); rtl_ps_set_rf_state(hw, ERFSLEEP, RF_CHANGE_BY_PS); - spin_unlock_irq(&rtlpriv->locks.lps_lock); + mutex_unlock(&rtlpriv->locks.ps_mutex); if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_ASPM && !RT_IN_PS_LEVEL(ppsc, RT_PS_LEVEL_ASPM)) { diff --git a/drivers/net/wireless/rtlwifi/wifi.h b/drivers/net/wireless/rtlwifi/wifi.h index 6e6353bbc7b4..085dccdbd1b6 100644 --- a/drivers/net/wireless/rtlwifi/wifi.h +++ b/drivers/net/wireless/rtlwifi/wifi.h @@ -1544,14 +1544,13 @@ struct rtl_hal_cfg { struct rtl_locks { /* mutex */ struct mutex conf_mutex; + struct mutex ps_mutex; /*spin lock */ - spinlock_t ips_lock; spinlock_t irq_th_lock; spinlock_t h2c_lock; spinlock_t rf_ps_lock; spinlock_t rf_lock; - spinlock_t lps_lock; spinlock_t waitq_lock; /*Dual mac*/ -- cgit v1.2.3 From 03f665c895fa9801ef4701d3e4e0918055370ee2 Mon Sep 17 00:00:00 2001 From: Rafał Miłecki Date: Mon, 12 Dec 2011 21:38:35 +0100 Subject: b43: N-PHY: fix 32-bit reads of tables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The order is different than on older PHYs. Signed-off-by: Rafał Miłecki Signed-off-by: John W. Linville --- drivers/net/wireless/b43/tables_nphy.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/b43/tables_nphy.c b/drivers/net/wireless/b43/tables_nphy.c index 691839e7541c..e1fc337df84b 100644 --- a/drivers/net/wireless/b43/tables_nphy.c +++ b/drivers/net/wireless/b43/tables_nphy.c @@ -2880,9 +2880,8 @@ u32 b43_ntab_read(struct b43_wldev *dev, u32 offset) break; case B43_NTAB_32BIT: b43_phy_write(dev, B43_NPHY_TABLE_ADDR, offset); - value = b43_phy_read(dev, B43_NPHY_TABLE_DATAHI); - value <<= 16; - value |= b43_phy_read(dev, B43_NPHY_TABLE_DATALO); + value = b43_phy_read(dev, B43_NPHY_TABLE_DATALO); + value |= b43_phy_read(dev, B43_NPHY_TABLE_DATAHI) << 16; break; default: B43_WARN_ON(1); @@ -2916,9 +2915,10 @@ void b43_ntab_read_bulk(struct b43_wldev *dev, u32 offset, data += 2; break; case B43_NTAB_32BIT: - *((u32 *)data) = b43_phy_read(dev, B43_NPHY_TABLE_DATAHI); - *((u32 *)data) <<= 16; - *((u32 *)data) |= b43_phy_read(dev, B43_NPHY_TABLE_DATALO); + *((u32 *)data) = + b43_phy_read(dev, B43_NPHY_TABLE_DATALO); + *((u32 *)data) |= + b43_phy_read(dev, B43_NPHY_TABLE_DATAHI) << 16; data += 4; break; default: -- cgit v1.2.3 From 6a6865ef32065102a32ebe1a604d3b88426410fa Mon Sep 17 00:00:00 2001 From: Rafał Miłecki Date: Mon, 12 Dec 2011 21:38:36 +0100 Subject: b43: N-PHY: workaround broken auto-increment on BCM43224 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rafał Miłecki Signed-off-by: John W. Linville --- drivers/net/wireless/b43/tables_nphy.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/b43/tables_nphy.c b/drivers/net/wireless/b43/tables_nphy.c index e1fc337df84b..3252560e9fa1 100644 --- a/drivers/net/wireless/b43/tables_nphy.c +++ b/drivers/net/wireless/b43/tables_nphy.c @@ -2905,6 +2905,12 @@ void b43_ntab_read_bulk(struct b43_wldev *dev, u32 offset, b43_phy_write(dev, B43_NPHY_TABLE_ADDR, offset); for (i = 0; i < nr_elements; i++) { + /* Auto increment broken + caching issue on BCM43224? */ + if (dev->dev->chip_id == 43224 && dev->dev->chip_rev == 1) { + b43_phy_read(dev, B43_NPHY_TABLE_DATALO); + b43_phy_write(dev, B43_NPHY_TABLE_ADDR, offset + i); + } + switch (type) { case B43_NTAB_8BIT: *data = b43_phy_read(dev, B43_NPHY_TABLE_DATALO) & 0xFF; -- cgit v1.2.3 From dd5f13b8a4b5f86e645e7e6662075004d116d5ad Mon Sep 17 00:00:00 2001 From: Rafał Miłecki Date: Mon, 12 Dec 2011 23:40:22 +0100 Subject: b43: N-PHY: update TX power fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Specs were updated. Signed-off-by: Rafał Miłecki Signed-off-by: John W. Linville --- drivers/net/wireless/b43/phy_n.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c index 730f5a451de3..6b95fd29514f 100644 --- a/drivers/net/wireless/b43/phy_n.c +++ b/drivers/net/wireless/b43/phy_n.c @@ -475,7 +475,9 @@ static void b43_nphy_tx_power_fix(struct b43_wldev *dev) if (nphy->hang_avoid) b43_nphy_stay_in_carrier_search(dev, 1); - if (dev->phy.rev >= 3) { + if (dev->phy.rev >= 7) { + txpi[0] = txpi[1] = 30; + } else if (dev->phy.rev >= 3) { txpi[0] = 40; txpi[1] = 40; } else if (sprom->revision < 4) { @@ -499,6 +501,9 @@ static void b43_nphy_tx_power_fix(struct b43_wldev *dev) txpi[1] = 91; } } + if (dev->phy.rev < 7 && + (txpi[0] < 40 || txpi[0] > 100 || txpi[1] < 40 || txpi[1] > 10)) + txpi[0] = txpi[1] = 91; /* for (i = 0; i < 2; i++) { @@ -509,15 +514,31 @@ static void b43_nphy_tx_power_fix(struct b43_wldev *dev) for (i = 0; i < 2; i++) { if (dev->phy.rev >= 3) { - /* FIXME: support 5GHz */ - txgain = b43_ntab_tx_gain_rev3plus_2ghz[txpi[i]]; + if (b43_nphy_ipa(dev)) { + txgain = *(b43_nphy_get_ipa_gain_table(dev) + + txpi[i]); + } else if (b43_current_band(dev->wl) == + IEEE80211_BAND_5GHZ) { + /* FIXME: use 5GHz tables */ + txgain = + b43_ntab_tx_gain_rev3plus_2ghz[txpi[i]]; + } else { + if (dev->phy.rev >= 5 && + sprom->fem.ghz5.extpa_gain == 3) + ; /* FIXME: 5GHz_txgain_HiPwrEPA */ + txgain = + b43_ntab_tx_gain_rev3plus_2ghz[txpi[i]]; + } radio_gain = (txgain >> 16) & 0x1FFFF; } else { txgain = b43_ntab_tx_gain_rev0_1_2[txpi[i]]; radio_gain = (txgain >> 16) & 0x1FFF; } - dac_gain = (txgain >> 8) & 0x3F; + if (dev->phy.rev >= 7) + dac_gain = (txgain >> 8) & 0x7; + else + dac_gain = (txgain >> 8) & 0x3F; bbmult = txgain & 0xFF; if (dev->phy.rev >= 3) { @@ -547,7 +568,8 @@ static void b43_nphy_tx_power_fix(struct b43_wldev *dev) u32 tmp32; u16 reg = (i == 0) ? B43_NPHY_PAPD_EN0 : B43_NPHY_PAPD_EN1; - tmp32 = b43_ntab_read(dev, B43_NTAB32(26 + i, txpi[i])); + tmp32 = b43_ntab_read(dev, B43_NTAB32(26 + i, + 576 + txpi[i])); b43_phy_maskset(dev, reg, 0xE00F, (u32) tmp32 << 4); b43_phy_set(dev, reg, 0x4); } -- cgit v1.2.3 From d3126c52eb7f3239b45481facc4078b08ed1027c Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 12 Dec 2011 15:14:59 -0800 Subject: brcm80211: smac: change ai_findcoreidx() to ai_findcore() Instead of returning the core index the function now returns the bcma device for the requested core id. This function is now exposed in the header file. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 14 +++++++------- drivers/net/wireless/brcm80211/brcmsmac/aiutils.h | 2 ++ 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c index 8d3829a73190..a54cf32d1eb5 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c @@ -884,7 +884,7 @@ uint ai_coreidx(struct si_pub *sih) } /* return index of coreid or BADIDX if not found */ -uint ai_findcoreidx(struct si_pub *sih, uint coreid, uint coreunit) +struct bcma_device *ai_findcore(struct si_pub *sih, u16 coreid, u16 coreunit) { struct bcma_device *core; struct si_info *sii; @@ -897,11 +897,11 @@ uint ai_findcoreidx(struct si_pub *sih, uint coreid, uint coreunit) list_for_each_entry(core, &sii->icbus->cores, list) if (core->id.id == coreid) { if (found == coreunit) - return core->core_index; + return core; found++; } - return BADIDX; + return NULL; } /* @@ -912,13 +912,13 @@ uint ai_findcoreidx(struct si_pub *sih, uint coreid, uint coreunit) */ void __iomem *ai_setcore(struct si_pub *sih, uint coreid, uint coreunit) { - uint idx; + struct bcma_device *core; - idx = ai_findcoreidx(sih, coreid, coreunit); - if (idx >= SI_MAXCORES) + core = ai_findcore(sih, coreid, coreunit); + if (core == NULL) return NULL; - return ai_setcoreidx(sih, idx); + return ai_setcoreidx(sih, core->core_index); } /* Turn off interrupt as required by ai_setcore, before switch core */ diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h index 67b378f2f57e..b0b0bfffe162 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h @@ -219,6 +219,8 @@ struct si_info { /* AMBA Interconnect exported externs */ +extern struct bcma_device *ai_findcore(struct si_pub *sih, + u16 coreid, u16 coreunit); extern uint ai_coreidx(struct si_pub *sih); extern uint ai_corerev(struct si_pub *sih); extern u32 ai_core_cflags(struct bcma_device *core, u32 mask, u32 val); -- cgit v1.2.3 From 373c78e19d6c00ff87fc251584d8bab65150e751 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 12 Dec 2011 15:15:00 -0800 Subject: brcm80211: smac: use bcma core access functions in otp.c The code in otp.c now uses the bcma core access functions to read the OTP information from the device. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/otp.c | 68 +++++++++------------- .../net/wireless/brcm80211/include/chipcommon.h | 2 + 2 files changed, 28 insertions(+), 42 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/otp.c b/drivers/net/wireless/brcm80211/brcmsmac/otp.c index 612434ea952f..f1ca12625860 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/otp.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/otp.c @@ -77,7 +77,7 @@ struct otp_fn_s { }; struct otpinfo { - uint ccrev; /* chipc revision */ + struct bcma_device *core; /* chipc core */ const struct otp_fn_s *fn; /* OTP functions */ struct si_pub *sih; /* Saved sb handle */ @@ -133,9 +133,10 @@ struct otpinfo { #define OTP_SZ_FU_144 (144/8) /* 144 bits */ static u16 -ipxotp_otpr(struct otpinfo *oi, struct chipcregs __iomem *cc, uint wn) +ipxotp_otpr(struct otpinfo *oi, uint wn) { - return R_REG(&cc->sromotp[wn]); + return bcma_read16(oi->core, + CHIPCREGOFFS(sromotp[wn])); } /* @@ -161,19 +162,21 @@ static int ipxotp_max_rgnsz(struct si_pub *sih, int osizew) return ret; } -static void _ipxotp_init(struct otpinfo *oi, struct chipcregs __iomem *cc) +static void _ipxotp_init(struct otpinfo *oi) { uint k; u32 otpp, st; + int ccrev = ai_get_ccrev(oi->sih); + /* * record word offset of General Use Region * for various chipcommon revs */ - if (oi->ccrev == 21 || oi->ccrev == 24 - || oi->ccrev == 27) { + if (ccrev == 21 || ccrev == 24 + || ccrev == 27) { oi->otpgu_base = REVA4_OTPGU_BASE; - } else if (oi->ccrev == 36) { + } else if (ccrev == 36) { /* * OTP size greater than equal to 2KB (128 words), * otpgu_base is similar to rev23 @@ -182,7 +185,7 @@ static void _ipxotp_init(struct otpinfo *oi, struct chipcregs __iomem *cc) oi->otpgu_base = REVB8_OTPGU_BASE; else oi->otpgu_base = REV36_OTPGU_BASE; - } else if (oi->ccrev == 23 || oi->ccrev >= 25) { + } else if (ccrev == 23 || ccrev >= 25) { oi->otpgu_base = REVB8_OTPGU_BASE; } @@ -190,24 +193,21 @@ static void _ipxotp_init(struct otpinfo *oi, struct chipcregs __iomem *cc) otpp = OTPP_START_BUSY | ((OTPPOC_INIT << OTPP_OC_SHIFT) & OTPP_OC_MASK); - W_REG(&cc->otpprog, otpp); - for (k = 0; - ((st = R_REG(&cc->otpprog)) & OTPP_START_BUSY) - && (k < OTPP_TRIES); k++) - ; + bcma_write32(oi->core, CHIPCREGOFFS(otpprog), otpp); + st = bcma_read32(oi->core, CHIPCREGOFFS(otpprog)); + for (k = 0; (st & OTPP_START_BUSY) && (k < OTPP_TRIES); k++) + st = bcma_read32(oi->core, CHIPCREGOFFS(otpprog)); if (k >= OTPP_TRIES) return; /* Read OTP lock bits and subregion programmed indication bits */ - oi->status = R_REG(&cc->otpstatus); + oi->status = bcma_read32(oi->core, CHIPCREGOFFS(otpstatus)); if ((ai_get_chip_id(oi->sih) == BCM43224_CHIP_ID) || (ai_get_chip_id(oi->sih) == BCM43225_CHIP_ID)) { u32 p_bits; - p_bits = - (ipxotp_otpr(oi, cc, oi->otpgu_base + OTPGU_P_OFF) & - OTPGU_P_MSK) - >> OTPGU_P_SHIFT; + p_bits = (ipxotp_otpr(oi, oi->otpgu_base + OTPGU_P_OFF) & + OTPGU_P_MSK) >> OTPGU_P_SHIFT; oi->status |= (p_bits << OTPS_GUP_SHIFT); } @@ -220,7 +220,7 @@ static void _ipxotp_init(struct otpinfo *oi, struct chipcregs __iomem *cc) oi->hwlim = oi->wsize; if (oi->status & OTPS_GUP_HW) { oi->hwlim = - ipxotp_otpr(oi, cc, oi->otpgu_base + OTPGU_HSB_OFF) / 16; + ipxotp_otpr(oi, oi->otpgu_base + OTPGU_HSB_OFF) / 16; oi->swbase = oi->hwlim; } else oi->swbase = oi->hwbase; @@ -230,7 +230,7 @@ static void _ipxotp_init(struct otpinfo *oi, struct chipcregs __iomem *cc) if (oi->status & OTPS_GUP_SW) { oi->swlim = - ipxotp_otpr(oi, cc, oi->otpgu_base + OTPGU_SFB_OFF) / 16; + ipxotp_otpr(oi, oi->otpgu_base + OTPGU_SFB_OFF) / 16; oi->fbase = oi->swlim; } else oi->fbase = oi->swbase; @@ -240,11 +240,8 @@ static void _ipxotp_init(struct otpinfo *oi, struct chipcregs __iomem *cc) static int ipxotp_init(struct si_pub *sih, struct otpinfo *oi) { - uint idx; - struct chipcregs __iomem *cc; - /* Make sure we're running IPX OTP */ - if (!OTPTYPE_IPX(oi->ccrev)) + if (!OTPTYPE_IPX(ai_get_ccrev(sih))) return -EBADE; /* Make sure OTP is not disabled */ @@ -282,21 +279,13 @@ static int ipxotp_init(struct si_pub *sih, struct otpinfo *oi) } /* Retrieve OTP region info */ - idx = ai_coreidx(sih); - cc = ai_setcoreidx(sih, SI_CC_IDX); - - _ipxotp_init(oi, cc); - - ai_setcoreidx(sih, idx); - + _ipxotp_init(oi); return 0; } static int ipxotp_read_region(struct otpinfo *oi, int region, u16 *data, uint *wlen) { - uint idx; - struct chipcregs __iomem *cc; uint base, i, sz; /* Validate region selection */ @@ -365,14 +354,10 @@ ipxotp_read_region(struct otpinfo *oi, int region, u16 *data, uint *wlen) return -EINVAL; } - idx = ai_coreidx(oi->sih); - cc = ai_setcoreidx(oi->sih, SI_CC_IDX); - /* Read the data */ for (i = 0; i < sz; i++) - data[i] = ipxotp_otpr(oi, cc, base + i); + data[i] = ipxotp_otpr(oi, base + i); - ai_setcoreidx(oi->sih, idx); *wlen = sz; return 0; } @@ -384,14 +369,13 @@ static const struct otp_fn_s ipxotp_fn = { static int otp_init(struct si_pub *sih, struct otpinfo *oi) { - int ret; memset(oi, 0, sizeof(struct otpinfo)); - oi->ccrev = ai_get_ccrev(sih); + oi->core = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0); - if (OTPTYPE_IPX(oi->ccrev)) + if (OTPTYPE_IPX(ai_get_ccrev(sih))) oi->fn = &ipxotp_fn; if (oi->fn == NULL) @@ -399,7 +383,7 @@ static int otp_init(struct si_pub *sih, struct otpinfo *oi) oi->sih = sih; - ret = (oi->fn->init) (sih, oi); + ret = (oi->fn->init)(sih, oi); return ret; } diff --git a/drivers/net/wireless/brcm80211/include/chipcommon.h b/drivers/net/wireless/brcm80211/include/chipcommon.h index fefabc39e646..f96834a7c055 100644 --- a/drivers/net/wireless/brcm80211/include/chipcommon.h +++ b/drivers/net/wireless/brcm80211/include/chipcommon.h @@ -19,6 +19,8 @@ #include "defs.h" /* for PAD macro */ +#define CHIPCREGOFFS(field) offsetof(struct chipcregs, field) + struct chipcregs { u32 chipid; /* 0x0 */ u32 capabilities; -- cgit v1.2.3 From b14f16747f143b330d0cef84ff2c590c3f1744a4 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 12 Dec 2011 15:15:01 -0800 Subject: brcm80211: smac: use bcma core access function in srom.c The code in srom.c now uses the core access function provided by BCMA so no need to pass __iomem pointer any longer. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 2 +- drivers/net/wireless/brcm80211/brcmsmac/srom.c | 50 +++++++---------------- drivers/net/wireless/brcm80211/brcmsmac/srom.h | 2 +- 3 files changed, 17 insertions(+), 37 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c index a54cf32d1eb5..bb12ebc20377 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c @@ -725,7 +725,7 @@ static struct si_info *ai_doattach(struct si_info *sii, goto exit; /* Init nvram from sprom/otp if they exist */ - if (srom_var_init(&sii->pub, cc)) + if (srom_var_init(&sii->pub)) goto exit; ai_nvram_process(sii); diff --git a/drivers/net/wireless/brcm80211/brcmsmac/srom.c b/drivers/net/wireless/brcm80211/brcmsmac/srom.c index 95eb620fc7f0..61092156755e 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/srom.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/srom.c @@ -586,17 +586,6 @@ static const struct brcms_sromvar perpath_pci_sromvars[] = { * shared between devices. */ static u8 brcms_srom_crc8_table[CRC8_TABLE_SIZE]; -static u8 __iomem * -srom_window_address(struct si_pub *sih, u8 __iomem *curmap) -{ - if (ai_get_ccrev(sih) < 32) - return curmap + PCI_BAR0_SPROM_OFFSET; - if (ai_get_cccaps(sih) & CC_CAP_SROM) - return curmap + PCI_16KB0_CCREGS_OFFSET + CC_SROM_OTP; - - return NULL; -} - static uint mask_shift(u16 mask) { uint i; @@ -779,17 +768,27 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, struct list_head *var_list) * Return 0 on success, nonzero on error. */ static int -sprom_read_pci(struct si_pub *sih, u8 __iomem *sprom, uint wordoff, - u16 *buf, uint nwords, bool check_crc) +sprom_read_pci(struct si_pub *sih, u16 *buf, uint nwords, bool check_crc) { int err = 0; uint i; u8 *bbuf = (u8 *)buf; /* byte buffer */ uint nbytes = nwords << 1; + struct bcma_device *core; + uint sprom_offset; + + /* determine core to read */ + if (ai_get_ccrev(sih) < 32) { + core = ai_findcore(sih, BCMA_CORE_80211, 0); + sprom_offset = PCI_BAR0_SPROM_OFFSET; + } else { + core = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0); + sprom_offset = CHIPCREGOFFS(sromotp); + } /* read the sprom in bytes */ for (i = 0; i < nbytes; i++) - bbuf[i] = readb(sprom+i); + bbuf[i] = bcma_read8(core, sprom_offset+i); if (buf[0] == 0xffff) /* @@ -851,10 +850,9 @@ static int otp_read_pci(struct si_pub *sih, u16 *buf, uint nwords) * Initialize nonvolatile variable table from sprom. * Return 0 on success, nonzero on error. */ -static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap) +int srom_var_init(struct si_pub *sih) { u16 *srom; - u8 __iomem *sromwindow; u8 sromrev = 0; u32 sr; int err = 0; @@ -866,12 +864,9 @@ static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap) if (!srom) return -ENOMEM; - sromwindow = srom_window_address(sih, curmap); - crc8_populate_lsb(brcms_srom_crc8_table, SROM_CRC8_POLY); if (ai_is_sprom_available(sih)) { - err = sprom_read_pci(sih, sromwindow, 0, srom, - SROM4_WORDS, true); + err = sprom_read_pci(sih, srom, SROM4_WORDS, true); if (err == 0) /* srom read and passed crc */ @@ -921,21 +916,6 @@ void srom_free_vars(struct si_pub *sih) kfree(entry); } } -/* - * Initialize local vars from the right source for this platform. - * Return 0 on success, nonzero on error. - */ -int srom_var_init(struct si_pub *sih, void __iomem *curmap) -{ - uint len; - - len = 0; - - if (curmap != NULL) - return initvars_srom_pci(sih, curmap); - - return -EINVAL; -} /* * Search the name=value vars for a specific one and return its value. diff --git a/drivers/net/wireless/brcm80211/brcmsmac/srom.h b/drivers/net/wireless/brcm80211/brcmsmac/srom.h index c81df9798e50..f2a58f262c99 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/srom.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/srom.h @@ -20,7 +20,7 @@ #include "types.h" /* Prototypes */ -extern int srom_var_init(struct si_pub *sih, void __iomem *curmap); +extern int srom_var_init(struct si_pub *sih); extern void srom_free_vars(struct si_pub *sih); extern int srom_read(struct si_pub *sih, uint bus, void *curmap, -- cgit v1.2.3 From 8d30b708b82ffa98e04197547e89fd8f18313ce2 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 12 Dec 2011 15:15:02 -0800 Subject: brcm80211: smac: use bcma core access functions in pmu.c The code in pmu.c now uses the functions provided by BCMA to access the core registers. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/pmu.c | 153 ++++++++++++-------------- 1 file changed, 73 insertions(+), 80 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pmu.c b/drivers/net/wireless/brcm80211/brcmsmac/pmu.c index ba319f31c9a9..9a4d367228a0 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/pmu.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/pmu.c @@ -140,7 +140,7 @@ static void si_pmu_res_masks(struct si_pub *sih, u32 * pmin, u32 * pmax) } static void -si_pmu_spuravoid_pllupdate(struct si_pub *sih, struct chipcregs __iomem *cc, +si_pmu_spuravoid_pllupdate(struct si_pub *sih, struct bcma_device *core, u8 spuravoid) { u32 tmp = 0; @@ -149,58 +149,65 @@ si_pmu_spuravoid_pllupdate(struct si_pub *sih, struct chipcregs __iomem *cc, case BCM43224_CHIP_ID: case BCM43225_CHIP_ID: if (spuravoid == 1) { - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); - W_REG(&cc->pllcontrol_data, 0x11500010); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); - W_REG(&cc->pllcontrol_data, 0x000C0C06); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); - W_REG(&cc->pllcontrol_data, 0x0F600a08); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); - W_REG(&cc->pllcontrol_data, 0x00000000); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); - W_REG(&cc->pllcontrol_data, 0x2001E920); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); - W_REG(&cc->pllcontrol_data, 0x88888815); + bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr), + PMU1_PLL0_PLLCTL0); + bcma_write32(core, CHIPCREGOFFS(pllcontrol_data), + 0x11500010); + bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr), + PMU1_PLL0_PLLCTL1); + bcma_write32(core, CHIPCREGOFFS(pllcontrol_data), + 0x000C0C06); + bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr), + PMU1_PLL0_PLLCTL2); + bcma_write32(core, CHIPCREGOFFS(pllcontrol_data), + 0x0F600a08); + bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr), + PMU1_PLL0_PLLCTL3); + bcma_write32(core, CHIPCREGOFFS(pllcontrol_data), + 0x00000000); + bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr), + PMU1_PLL0_PLLCTL4); + bcma_write32(core, CHIPCREGOFFS(pllcontrol_data), + 0x2001E920); + bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr), + PMU1_PLL0_PLLCTL5); + bcma_write32(core, CHIPCREGOFFS(pllcontrol_data), + 0x88888815); } else { - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); - W_REG(&cc->pllcontrol_data, 0x11100010); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); - W_REG(&cc->pllcontrol_data, 0x000c0c06); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); - W_REG(&cc->pllcontrol_data, 0x03000a08); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); - W_REG(&cc->pllcontrol_data, 0x00000000); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); - W_REG(&cc->pllcontrol_data, 0x200005c0); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); - W_REG(&cc->pllcontrol_data, 0x88888815); + bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr), + PMU1_PLL0_PLLCTL0); + bcma_write32(core, CHIPCREGOFFS(pllcontrol_data), + 0x11100010); + bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr), + PMU1_PLL0_PLLCTL1); + bcma_write32(core, CHIPCREGOFFS(pllcontrol_data), + 0x000c0c06); + bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr), + PMU1_PLL0_PLLCTL2); + bcma_write32(core, CHIPCREGOFFS(pllcontrol_data), + 0x03000a08); + bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr), + PMU1_PLL0_PLLCTL3); + bcma_write32(core, CHIPCREGOFFS(pllcontrol_data), + 0x00000000); + bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr), + PMU1_PLL0_PLLCTL4); + bcma_write32(core, CHIPCREGOFFS(pllcontrol_data), + 0x200005c0); + bcma_write32(core, CHIPCREGOFFS(pllcontrol_addr), + PMU1_PLL0_PLLCTL5); + bcma_write32(core, CHIPCREGOFFS(pllcontrol_data), + 0x88888815); } tmp = 1 << 10; break; - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL0); - W_REG(&cc->pllcontrol_data, 0x11100008); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL1); - W_REG(&cc->pllcontrol_data, 0x0c000c06); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL2); - W_REG(&cc->pllcontrol_data, 0x03000a08); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL3); - W_REG(&cc->pllcontrol_data, 0x00000000); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL4); - W_REG(&cc->pllcontrol_data, 0x200005c0); - W_REG(&cc->pllcontrol_addr, PMU1_PLL0_PLLCTL5); - W_REG(&cc->pllcontrol_data, 0x88888855); - - tmp = 1 << 10; - break; - default: /* bail out */ return; } - tmp |= R_REG(&cc->pmucontrol); - W_REG(&cc->pmucontrol, tmp); + bcma_set32(core, CHIPCREGOFFS(pmucontrol), tmp); } u16 si_pmu_fast_pwrup_delay(struct si_pub *sih) @@ -289,12 +296,12 @@ u32 si_pmu_alp_clock(struct si_pub *sih) void si_pmu_spuravoid(struct si_pub *sih, u8 spuravoid) { - struct chipcregs __iomem *cc; + struct bcma_device *cc; uint origidx, intr_val; - /* Remember original core before switch to chipc */ - cc = (struct chipcregs __iomem *) - ai_switch_core(sih, CC_CORE_ID, &origidx, &intr_val); + /* switch to chipc */ + cc = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0); + ai_switch_core(sih, CC_CORE_ID, &origidx, &intr_val); /* update the pll changes */ si_pmu_spuravoid_pllupdate(sih, cc, spuravoid); @@ -306,20 +313,16 @@ void si_pmu_spuravoid(struct si_pub *sih, u8 spuravoid) /* initialize PMU */ void si_pmu_init(struct si_pub *sih) { - struct chipcregs __iomem *cc; - uint origidx; + struct bcma_device *core; - /* Remember original core before switch to chipc */ - origidx = ai_coreidx(sih); - cc = ai_setcoreidx(sih, SI_CC_IDX); + /* select chipc */ + core = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0); if (ai_get_pmurev(sih) == 1) - AND_REG(&cc->pmucontrol, ~PCTL_NOILP_ON_WAIT); + bcma_mask32(core, CHIPCREGOFFS(pmucontrol), + ~PCTL_NOILP_ON_WAIT); else if (ai_get_pmurev(sih) >= 2) - OR_REG(&cc->pmucontrol, PCTL_NOILP_ON_WAIT); - - /* Return to original core */ - ai_setcoreidx(sih, origidx); + bcma_set32(core, CHIPCREGOFFS(pmucontrol), PCTL_NOILP_ON_WAIT); } /* initialize PMU chip controls and other chip level stuff */ @@ -369,13 +372,11 @@ void si_pmu_pll_init(struct si_pub *sih, uint xtalfreq) /* initialize PMU resources */ void si_pmu_res_init(struct si_pub *sih) { - struct chipcregs __iomem *cc; - uint origidx; + struct bcma_device *core; u32 min_mask = 0, max_mask = 0; - /* Remember original core before switch to chipc */ - origidx = ai_coreidx(sih); - cc = ai_setcoreidx(sih, SI_CC_IDX); + /* select to chipc */ + core = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0); /* Determine min/max rsrc masks */ si_pmu_res_masks(sih, &min_mask, &max_mask); @@ -385,55 +386,50 @@ void si_pmu_res_init(struct si_pub *sih) /* Program max resource mask */ if (max_mask) - W_REG(&cc->max_res_mask, max_mask); + bcma_write32(core, CHIPCREGOFFS(max_res_mask), max_mask); /* Program min resource mask */ if (min_mask) - W_REG(&cc->min_res_mask, min_mask); + bcma_write32(core, CHIPCREGOFFS(min_res_mask), min_mask); /* Add some delay; allow resources to come up and settle. */ mdelay(2); - - /* Return to original core */ - ai_setcoreidx(sih, origidx); } u32 si_pmu_measure_alpclk(struct si_pub *sih) { - struct chipcregs __iomem *cc; - uint origidx; + struct bcma_device *core; u32 alp_khz; if (ai_get_pmurev(sih) < 10) return 0; /* Remember original core before switch to chipc */ - origidx = ai_coreidx(sih); - cc = ai_setcoreidx(sih, SI_CC_IDX); + core = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0); - if (R_REG(&cc->pmustatus) & PST_EXTLPOAVAIL) { + if (bcma_read32(core, CHIPCREGOFFS(pmustatus)) & PST_EXTLPOAVAIL) { u32 ilp_ctr, alp_hz; /* * Enable the reg to measure the freq, * in case it was disabled before */ - W_REG(&cc->pmu_xtalfreq, - 1U << PMU_XTALFREQ_REG_MEASURE_SHIFT); + bcma_write32(core, CHIPCREGOFFS(pmu_xtalfreq), + 1U << PMU_XTALFREQ_REG_MEASURE_SHIFT); /* Delay for well over 4 ILP clocks */ udelay(1000); /* Read the latched number of ALP ticks per 4 ILP ticks */ - ilp_ctr = - R_REG(&cc->pmu_xtalfreq) & PMU_XTALFREQ_REG_ILPCTR_MASK; + ilp_ctr = bcma_read32(core, CHIPCREGOFFS(pmu_xtalfreq)) & + PMU_XTALFREQ_REG_ILPCTR_MASK; /* * Turn off the PMU_XTALFREQ_REG_MEASURE_SHIFT * bit to save power */ - W_REG(&cc->pmu_xtalfreq, 0); + bcma_write32(core, CHIPCREGOFFS(pmu_xtalfreq), 0); /* Calculate ALP frequency */ alp_hz = (ilp_ctr * EXT_ILP_HZ) / 4; @@ -446,8 +442,5 @@ u32 si_pmu_measure_alpclk(struct si_pub *sih) } else alp_khz = 0; - /* Return to original core */ - ai_setcoreidx(sih, origidx); - return alp_khz; } -- cgit v1.2.3 From c8086745215435281ca319b5243bf8b11a366ef3 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 12 Dec 2011 15:15:03 -0800 Subject: brcm80211: smac: use bcma core access functions in aiutils.c The code in aiutils.c now uses the BCMA function for control the registers in the device cores. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 190 ++++++++-------------- 1 file changed, 70 insertions(+), 120 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c index bb12ebc20377..7e5d41bd994a 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c @@ -558,28 +558,26 @@ static bool ai_buscore_prep(struct si_info *sii) } static bool -ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx) +ai_buscore_setup(struct si_info *sii, struct bcma_device *cc) { bool pci, pcie; uint i; uint pciidx, pcieidx, pcirev, pcierev; - struct chipcregs __iomem *cc; - - cc = ai_setcoreidx(&sii->pub, SI_CC_IDX); /* get chipcommon rev */ - sii->pub.ccrev = (int)ai_corerev(&sii->pub); + sii->pub.ccrev = cc->id.rev; /* get chipcommon chipstatus */ if (ai_get_ccrev(&sii->pub) >= 11) - sii->chipst = R_REG(&cc->chipstatus); + sii->chipst = bcma_read32(cc, CHIPCREGOFFS(chipstatus)); /* get chipcommon capabilites */ - sii->pub.cccaps = R_REG(&cc->capabilities); + sii->pub.cccaps = bcma_read32(cc, CHIPCREGOFFS(capabilities)); /* get pmu rev and caps */ if (ai_get_cccaps(&sii->pub) & CC_CAP_PMU) { - sii->pub.pmucaps = R_REG(&cc->pmucapabilities); + sii->pub.pmucaps = bcma_read32(cc, + CHIPCREGOFFS(pmucapabilities)); sii->pub.pmurev = sii->pub.pmucaps & PCAP_REV_MASK; } @@ -608,11 +606,6 @@ ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx) pcierev = crev; pcie = true; } - - /* find the core idx before entering this func. */ - if ((savewin && (savewin == sii->coresba[i])) || - (cc == sii->regs[i])) - *origidx = i; } if (pci && pcie) { @@ -642,9 +635,6 @@ ai_buscore_setup(struct si_info *sii, u32 savewin, uint *origidx) return false; } - /* return to the original core */ - ai_setcoreidx(&sii->pub, *origidx); - return true; } @@ -668,9 +658,8 @@ static struct si_info *ai_doattach(struct si_info *sii, void __iomem *regs = pbus->mmio; struct si_pub *sih = &sii->pub; u32 w, savewin; - struct chipcregs __iomem *cc; + struct bcma_device *cc; uint socitype; - uint origidx; memset((unsigned char *) sii, 0, sizeof(struct si_info)); @@ -683,10 +672,7 @@ static struct si_info *ai_doattach(struct si_info *sii, sii->curwrap = sii->curmap + SI_CORE_SIZE; /* switch to Chipcommon core */ - bcma_read32(pbus->drv_cc.core, 0); - savewin = SI_ENUM_BASE; - - cc = (struct chipcregs __iomem *) regs; + cc = pbus->drv_cc.core; /* bus/core/clk setup for register access */ if (!ai_buscore_prep(sii)) @@ -699,7 +685,7 @@ static struct si_info *ai_doattach(struct si_info *sii, * hosts w/o chipcommon), some way of recognizing them needs to * be added here. */ - w = R_REG(&cc->chipid); + w = bcma_read32(cc, CHIPCREGOFFS(chipid)); socitype = (w & CID_TYPE_MASK) >> CID_TYPE_SHIFT; /* Might as wll fill in chip id rev & pkg */ sih->chip = w & CID_ID_MASK; @@ -720,8 +706,7 @@ static struct si_info *ai_doattach(struct si_info *sii, return NULL; /* bus/core/clk setup */ - origidx = SI_CC_IDX; - if (!ai_buscore_setup(sii, savewin, &origidx)) + if (!ai_buscore_setup(sii, cc)) goto exit; /* Init nvram from sprom/otp if they exist */ @@ -731,10 +716,8 @@ static struct si_info *ai_doattach(struct si_info *sii, ai_nvram_process(sii); /* === NVRAM, clock is ready === */ - cc = (struct chipcregs __iomem *) ai_setcore(sih, CC_CORE_ID, 0); - W_REG(&cc->gpiopullup, 0); - W_REG(&cc->gpiopulldown, 0); - ai_setcoreidx(sih, origidx); + bcma_write32(cc, CHIPCREGOFFS(gpiopullup), 0); + bcma_write32(cc, CHIPCREGOFFS(gpiopulldown), 0); /* PMU specific initializations */ if (ai_get_cccaps(sih) & CC_CAP_PMU) { @@ -990,11 +973,12 @@ uint ai_cc_reg(struct si_pub *sih, uint regoff, u32 mask, u32 val) } /* return the slow clock source - LPO, XTAL, or PCI */ -static uint ai_slowclk_src(struct si_info *sii) +static uint ai_slowclk_src(struct si_pub *sih, struct bcma_device *cc) { - struct chipcregs __iomem *cc; + struct si_info *sii; u32 val; + sii = (struct si_info *)sih; if (ai_get_ccrev(&sii->pub) < 6) { pci_read_config_dword(sii->pcibus, PCI_GPIO_OUT, &val); @@ -1002,9 +986,8 @@ static uint ai_slowclk_src(struct si_info *sii) return SCC_SS_PCI; return SCC_SS_XTAL; } else if (ai_get_ccrev(&sii->pub) < 10) { - cc = (struct chipcregs __iomem *) - ai_setcoreidx(&sii->pub, sii->curidx); - return R_REG(&cc->slow_clk_ctl) & SCC_SS_MASK; + return bcma_read32(cc, CHIPCREGOFFS(slow_clk_ctl)) & + SCC_SS_MASK; } else /* Insta-clock */ return SCC_SS_XTAL; } @@ -1013,24 +996,24 @@ static uint ai_slowclk_src(struct si_info *sii) * return the ILP (slowclock) min or max frequency * precondition: we've established the chip has dynamic clk control */ -static uint ai_slowclk_freq(struct si_info *sii, bool max_freq, - struct chipcregs __iomem *cc) +static uint ai_slowclk_freq(struct si_pub *sih, bool max_freq, + struct bcma_device *cc) { u32 slowclk; uint div; - slowclk = ai_slowclk_src(sii); - if (ai_get_ccrev(&sii->pub) < 6) { + slowclk = ai_slowclk_src(sih, cc); + if (ai_get_ccrev(sih) < 6) { if (slowclk == SCC_SS_PCI) return max_freq ? (PCIMAXFREQ / 64) : (PCIMINFREQ / 64); else return max_freq ? (XTALMAXFREQ / 32) : (XTALMINFREQ / 32); - } else if (ai_get_ccrev(&sii->pub) < 10) { + } else if (ai_get_ccrev(sih) < 10) { div = 4 * - (((R_REG(&cc->slow_clk_ctl) & SCC_CD_MASK) >> - SCC_CD_SHIFT) + 1); + (((bcma_read32(cc, CHIPCREGOFFS(slow_clk_ctl)) & + SCC_CD_MASK) >> SCC_CD_SHIFT) + 1); if (slowclk == SCC_SS_LPO) return max_freq ? LPOMAXFREQ : LPOMINFREQ; else if (slowclk == SCC_SS_XTAL) @@ -1041,15 +1024,15 @@ static uint ai_slowclk_freq(struct si_info *sii, bool max_freq, : (PCIMINFREQ / div); } else { /* Chipc rev 10 is InstaClock */ - div = R_REG(&cc->system_clk_ctl) >> SYCC_CD_SHIFT; - div = 4 * (div + 1); + div = bcma_read32(cc, CHIPCREGOFFS(system_clk_ctl)); + div = 4 * ((div >> SYCC_CD_SHIFT) + 1); return max_freq ? XTALMAXFREQ : (XTALMINFREQ / div); } return 0; } static void -ai_clkctl_setdelay(struct si_info *sii, struct chipcregs __iomem *cc) +ai_clkctl_setdelay(struct si_pub *sih, struct bcma_device *cc) { uint slowmaxfreq, pll_delay, slowclk; uint pll_on_delay, fref_sel_delay; @@ -1062,47 +1045,40 @@ ai_clkctl_setdelay(struct si_info *sii, struct chipcregs __iomem *cc) * powered down by dynamic clk control logic. */ - slowclk = ai_slowclk_src(sii); + slowclk = ai_slowclk_src(sih, cc); if (slowclk != SCC_SS_XTAL) pll_delay += XTAL_ON_DELAY; /* Starting with 4318 it is ILP that is used for the delays */ slowmaxfreq = - ai_slowclk_freq(sii, - (ai_get_ccrev(&sii->pub) >= 10) ? false : true, cc); + ai_slowclk_freq(sih, + (ai_get_ccrev(sih) >= 10) ? false : true, cc); pll_on_delay = ((slowmaxfreq * pll_delay) + 999999) / 1000000; fref_sel_delay = ((slowmaxfreq * FREF_DELAY) + 999999) / 1000000; - W_REG(&cc->pll_on_delay, pll_on_delay); - W_REG(&cc->fref_sel_delay, fref_sel_delay); + bcma_write32(cc, CHIPCREGOFFS(pll_on_delay), pll_on_delay); + bcma_write32(cc, CHIPCREGOFFS(fref_sel_delay), fref_sel_delay); } /* initialize power control delay registers */ void ai_clkctl_init(struct si_pub *sih) { - struct si_info *sii; - uint origidx = 0; - struct chipcregs __iomem *cc; + struct bcma_device *cc; if (!(ai_get_cccaps(sih) & CC_CAP_PWR_CTL)) return; - sii = (struct si_info *)sih; - origidx = sii->curidx; - cc = (struct chipcregs __iomem *) - ai_setcore(sih, CC_CORE_ID, 0); + cc = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0); if (cc == NULL) return; /* set all Instaclk chip ILP to 1 MHz */ if (ai_get_ccrev(sih) >= 10) - SET_REG(&cc->system_clk_ctl, SYCC_CD_MASK, - (ILP_DIV_1MHZ << SYCC_CD_SHIFT)); - - ai_clkctl_setdelay(sii, cc); + bcma_maskset32(cc, CHIPCREGOFFS(system_clk_ctl), SYCC_CD_MASK, + (ILP_DIV_1MHZ << SYCC_CD_SHIFT)); - ai_setcoreidx(sih, origidx); + ai_clkctl_setdelay(sih, cc); } /* @@ -1112,8 +1088,7 @@ void ai_clkctl_init(struct si_pub *sih) u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih) { struct si_info *sii; - uint origidx = 0; - struct chipcregs __iomem *cc; + struct bcma_device *cc; uint slowminfreq; u16 fpdelay; uint intr_val = 0; @@ -1130,19 +1105,17 @@ u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih) return 0; fpdelay = 0; - origidx = sii->curidx; INTR_OFF(sii, intr_val); - cc = (struct chipcregs __iomem *) - ai_setcore(sih, CC_CORE_ID, 0); + cc = ai_findcore(sih, CC_CORE_ID, 0); if (cc == NULL) goto done; - slowminfreq = ai_slowclk_freq(sii, false, cc); - fpdelay = (((R_REG(&cc->pll_on_delay) + 2) * 1000000) + - (slowminfreq - 1)) / slowminfreq; + + slowminfreq = ai_slowclk_freq(sih, false, cc); + fpdelay = (((bcma_read32(cc, CHIPCREGOFFS(pll_on_delay)) + 2) * 1000000) + + (slowminfreq - 1)) / slowminfreq; done: - ai_setcoreidx(sih, origidx); INTR_RESTORE(sii, intr_val); return fpdelay; } @@ -1213,8 +1186,7 @@ int ai_clkctl_xtal(struct si_pub *sih, uint what, bool on) /* clk control mechanism through chipcommon, no policy checking */ static bool _ai_clkctl_cc(struct si_info *sii, uint mode) { - uint origidx = 0; - struct chipcregs __iomem *cc; + struct bcma_device *cc; u32 scc; uint intr_val = 0; @@ -1223,9 +1195,7 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode) return false; INTR_OFF(sii, intr_val); - origidx = sii->curidx; - cc = (struct chipcregs __iomem *) - ai_setcore(&sii->pub, CC_CORE_ID, 0); + cc = ai_findcore(&sii->pub, BCMA_CORE_CHIPCOMMON, 0); if (!(ai_get_cccaps(&sii->pub) & CC_CAP_PWR_CTL) && (ai_get_ccrev(&sii->pub) < 20)) @@ -1239,19 +1209,19 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode) * on before we clear SCC_DYN_XTAL.. */ ai_clkctl_xtal(&sii->pub, XTAL, ON); - SET_REG(&cc->slow_clk_ctl, - (SCC_XC | SCC_FS | SCC_IP), SCC_IP); + bcma_maskset32(cc, CHIPCREGOFFS(slow_clk_ctl), + (SCC_XC | SCC_FS | SCC_IP), SCC_IP); } else if (ai_get_ccrev(&sii->pub) < 20) { - OR_REG(&cc->system_clk_ctl, SYCC_HR); + bcma_set32(cc, CHIPCREGOFFS(system_clk_ctl), SYCC_HR); } else { - OR_REG(&cc->clk_ctl_st, CCS_FORCEHT); + bcma_set32(cc, CHIPCREGOFFS(clk_ctl_st), CCS_FORCEHT); } /* wait for the PLL */ if (ai_get_cccaps(&sii->pub) & CC_CAP_PMU) { u32 htavail = CCS_HTAVAIL; - SPINWAIT(((R_REG(&cc->clk_ctl_st) & htavail) - == 0), PMU_MAX_TRANSITION_DLY); + SPINWAIT(((bcma_read32(cc, CHIPCREGOFFS(clk_ctl_st)) & + htavail) == 0), PMU_MAX_TRANSITION_DLY); } else { udelay(PLL_DELAY); } @@ -1259,11 +1229,11 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode) case CLK_DYNAMIC: /* enable dynamic clock control */ if (ai_get_ccrev(&sii->pub) < 10) { - scc = R_REG(&cc->slow_clk_ctl); + scc = bcma_read32(cc, CHIPCREGOFFS(slow_clk_ctl)); scc &= ~(SCC_FS | SCC_IP | SCC_XC); if ((scc & SCC_SS_MASK) != SCC_SS_XTAL) scc |= SCC_XC; - W_REG(&cc->slow_clk_ctl, scc); + bcma_write32(cc, CHIPCREGOFFS(slow_clk_ctl), scc); /* * for dynamic control, we have to @@ -1273,9 +1243,9 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode) ai_clkctl_xtal(&sii->pub, XTAL, OFF); } else if (ai_get_ccrev(&sii->pub) < 20) { /* Instaclock */ - AND_REG(&cc->system_clk_ctl, ~SYCC_HR); + bcma_mask32(cc, CHIPCREGOFFS(system_clk_ctl), ~SYCC_HR); } else { - AND_REG(&cc->clk_ctl_st, ~CCS_FORCEHT); + bcma_mask32(cc, CHIPCREGOFFS(clk_ctl_st), ~CCS_FORCEHT); } break; @@ -1284,7 +1254,6 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode) } done: - ai_setcoreidx(&sii->pub, origidx); INTR_RESTORE(sii, intr_val); return mode == CLK_FAST; } @@ -1427,53 +1396,37 @@ u32 ai_gpiocontrol(struct si_pub *sih, u32 mask, u32 val, u8 priority) void ai_chipcontrl_epa4331(struct si_pub *sih, bool on) { - struct si_info *sii; - struct chipcregs __iomem *cc; - uint origidx; + struct bcma_device *cc; u32 val; - sii = (struct si_info *)sih; - origidx = ai_coreidx(sih); - - cc = (struct chipcregs __iomem *) ai_setcore(sih, CC_CORE_ID, 0); - - val = R_REG(&cc->chipcontrol); + cc = ai_findcore(sih, CC_CORE_ID, 0); if (on) { if (ai_get_chippkg(sih) == 9 || ai_get_chippkg(sih) == 0xb) /* Ext PA Controls for 4331 12x9 Package */ - W_REG(&cc->chipcontrol, val | - CCTRL4331_EXTPA_EN | - CCTRL4331_EXTPA_ON_GPIO2_5); + bcma_set32(cc, CHIPCREGOFFS(chipcontrol), + CCTRL4331_EXTPA_EN | + CCTRL4331_EXTPA_ON_GPIO2_5); else /* Ext PA Controls for 4331 12x12 Package */ - W_REG(&cc->chipcontrol, - val | CCTRL4331_EXTPA_EN); + bcma_set32(cc, CHIPCREGOFFS(chipcontrol), + CCTRL4331_EXTPA_EN); } else { val &= ~(CCTRL4331_EXTPA_EN | CCTRL4331_EXTPA_ON_GPIO2_5); - W_REG(&cc->chipcontrol, val); + bcma_mask32(cc, CHIPCREGOFFS(chipcontrol), + ~(CCTRL4331_EXTPA_EN | CCTRL4331_EXTPA_ON_GPIO2_5)); } - - ai_setcoreidx(sih, origidx); } /* Enable BT-COEX & Ex-PA for 4313 */ void ai_epa_4313war(struct si_pub *sih) { - struct si_info *sii; - struct chipcregs __iomem *cc; - uint origidx; - - sii = (struct si_info *)sih; - origidx = ai_coreidx(sih); + struct bcma_device *cc; - cc = ai_setcore(sih, CC_CORE_ID, 0); + cc = ai_findcore(sih, CC_CORE_ID, 0); /* EPA Fix */ - W_REG(&cc->gpiocontrol, - R_REG(&cc->gpiocontrol) | GPIO_CTRL_EPA_EN_MASK); - - ai_setcoreidx(sih, origidx); + bcma_set32(cc, CHIPCREGOFFS(gpiocontrol), GPIO_CTRL_EPA_EN_MASK); } /* check if the device is removed */ @@ -1496,17 +1449,14 @@ bool ai_is_sprom_available(struct si_pub *sih) struct si_info *sii = (struct si_info *)sih; if (ai_get_ccrev(sih) >= 31) { - uint origidx; - struct chipcregs __iomem *cc; + struct bcma_device *cc; u32 sromctrl; if ((ai_get_cccaps(sih) & CC_CAP_SROM) == 0) return false; - origidx = sii->curidx; - cc = ai_setcoreidx(sih, SI_CC_IDX); - sromctrl = R_REG(&cc->sromcontrol); - ai_setcoreidx(sih, origidx); + cc = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0); + sromctrl = bcma_read32(cc, CHIPCREGOFFS(sromcontrol)); return sromctrl & SRC_PRESENT; } -- cgit v1.2.3 From 646e2615d21d6438e033fd28888b8a6a62cda851 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 12 Dec 2011 15:15:04 -0800 Subject: brcm80211: smac: remove register access macro definitions The register access macros like R_REG/W_REG/etc. are no longer needed as the driver uses the BCMA provided functions. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/types.h | 51 ------------------------- 1 file changed, 51 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/types.h b/drivers/net/wireless/brcm80211/brcmsmac/types.h index e64971a759d3..e11ae83111e4 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/types.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/types.h @@ -250,69 +250,18 @@ do { \ wiphy_err(dev, "%s: " fmt, __func__, ##args); \ } while (0) -/* - * Register access macros. - * - * These macro's take a pointer to the address to read as one of their - * arguments. The macro itself deduces the size of the IO transaction (u8, u16 - * or u32). Advantage of this approach in combination with using a struct to - * define the registers in a register block, is that access size and access - * location are defined in only one spot. This reduces the risk of the - * programmer trying to use an unsupported transaction size on a register. - * - */ - -#define R_REG(r) \ - ({ \ - __typeof(*(r)) __osl_v; \ - switch (sizeof(*(r))) { \ - case sizeof(u8): \ - __osl_v = readb((u8 __iomem *)(r)); \ - break; \ - case sizeof(u16): \ - __osl_v = readw((u16 __iomem *)(r)); \ - break; \ - case sizeof(u32): \ - __osl_v = readl((u32 __iomem *)(r)); \ - break; \ - } \ - __osl_v; \ - }) - -#define W_REG(r, v) do { \ - switch (sizeof(*(r))) { \ - case sizeof(u8): \ - writeb((u8)((v) & 0xFF), (u8 __iomem *)(r)); \ - break; \ - case sizeof(u16): \ - writew((u16)((v) & 0xFFFF), (u16 __iomem *)(r)); \ - break; \ - case sizeof(u32): \ - writel((u32)(v), (u32 __iomem *)(r)); \ - break; \ - } \ - } while (0) - #ifdef CONFIG_BCM47XX /* * bcm4716 (which includes 4717 & 4718), plus 4706 on PCIe can reorder * transactions. As a fix, a read after write is performed on certain places * in the code. Older chips and the newer 5357 family don't require this fix. */ -#define W_REG_FLUSH(r, v) ({ W_REG((r), (v)); (void)R_REG(r); }) #define bcma_wflush16(c, o, v) \ ({ bcma_write16(c, o, v); (void)bcma_read16(c, o); }) #else -#define W_REG_FLUSH(r, v) W_REG((r), (v)) #define bcma_wflush16(c, o, v) bcma_write16(c, o, v) #endif /* CONFIG_BCM47XX */ -#define AND_REG(r, v) W_REG((r), R_REG(r) & (v)) -#define OR_REG(r, v) W_REG((r), R_REG(r) | (v)) - -#define SET_REG(r, mask, val) \ - W_REG((r), ((R_REG(r) & ~(mask)) | (val))) - /* multi-bool data type: set of bools, mbool is true if any is set */ /* set one bool */ -- cgit v1.2.3 From 291ed3dcd5334c7987272494373751f86e5b61ee Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 12 Dec 2011 15:15:05 -0800 Subject: brcm80211: smac: remove empty or unused functions from pmu.c A number of functions in pmu.c are not used or adding no functionality at all. These have been removed. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 7 +-- drivers/net/wireless/brcm80211/brcmsmac/pmu.c | 57 ----------------------- drivers/net/wireless/brcm80211/brcmsmac/pmu.h | 3 -- 3 files changed, 1 insertion(+), 66 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c index 7e5d41bd994a..3d37b0a437cc 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c @@ -721,14 +721,9 @@ static struct si_info *ai_doattach(struct si_info *sii, /* PMU specific initializations */ if (ai_get_cccaps(sih) & CC_CAP_PMU) { - u32 xtalfreq; si_pmu_init(sih); - si_pmu_chip_init(sih); - - xtalfreq = si_pmu_measure_alpclk(sih); - si_pmu_pll_init(sih, xtalfreq); + (void)si_pmu_measure_alpclk(sih); si_pmu_res_init(sih); - si_pmu_swreg_init(sih); } /* setup the GPIO based LED powersave register */ diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pmu.c b/drivers/net/wireless/brcm80211/brcmsmac/pmu.c index 9a4d367228a0..d972e9c8d2df 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/pmu.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/pmu.c @@ -227,19 +227,6 @@ u16 si_pmu_fast_pwrup_delay(struct si_pub *sih) return (u16) delay; } -void si_pmu_sprom_enable(struct si_pub *sih, bool enable) -{ - struct chipcregs __iomem *cc; - uint origidx; - - /* Remember original core before switch to chipc */ - origidx = ai_coreidx(sih); - cc = ai_setcoreidx(sih, SI_CC_IDX); - - /* Return to original core */ - ai_setcoreidx(sih, origidx); -} - /* Read/write a chipcontrol reg */ u32 si_pmu_chipcontrol(struct si_pub *sih, uint reg, u32 mask, u32 val) { @@ -325,50 +312,6 @@ void si_pmu_init(struct si_pub *sih) bcma_set32(core, CHIPCREGOFFS(pmucontrol), PCTL_NOILP_ON_WAIT); } -/* initialize PMU chip controls and other chip level stuff */ -void si_pmu_chip_init(struct si_pub *sih) -{ - uint origidx; - - /* Gate off SPROM clock and chip select signals */ - si_pmu_sprom_enable(sih, false); - - /* Remember original core */ - origidx = ai_coreidx(sih); - - /* Return to original core */ - ai_setcoreidx(sih, origidx); -} - -/* initialize PMU switch/regulators */ -void si_pmu_swreg_init(struct si_pub *sih) -{ -} - -/* initialize PLL */ -void si_pmu_pll_init(struct si_pub *sih, uint xtalfreq) -{ - struct chipcregs __iomem *cc; - uint origidx; - - /* Remember original core before switch to chipc */ - origidx = ai_coreidx(sih); - cc = ai_setcoreidx(sih, SI_CC_IDX); - - switch (ai_get_chip_id(sih)) { - case BCM4313_CHIP_ID: - case BCM43224_CHIP_ID: - case BCM43225_CHIP_ID: - /* ??? */ - break; - default: - break; - } - - /* Return to original core */ - ai_setcoreidx(sih, origidx); -} - /* initialize PMU resources */ void si_pmu_res_init(struct si_pub *sih) { diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pmu.h b/drivers/net/wireless/brcm80211/brcmsmac/pmu.h index 3a08c620640e..dcd893c68f9a 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/pmu.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/pmu.h @@ -29,10 +29,7 @@ extern void si_pmu_pllupd(struct si_pub *sih); extern void si_pmu_spuravoid(struct si_pub *sih, u8 spuravoid); extern u32 si_pmu_pllcontrol(struct si_pub *sih, uint reg, u32 mask, u32 val); extern void si_pmu_init(struct si_pub *sih); -extern void si_pmu_chip_init(struct si_pub *sih); -extern void si_pmu_pll_init(struct si_pub *sih, u32 xtalfreq); extern void si_pmu_res_init(struct si_pub *sih); -extern void si_pmu_swreg_init(struct si_pub *sih); extern u32 si_pmu_measure_alpclk(struct si_pub *sih); #endif /* _BRCM_PMU_H_ */ -- cgit v1.2.3 From a232c8a12a0fe55a2e671d24626c98a21b57a332 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 12 Dec 2011 15:15:06 -0800 Subject: brcm80211: smac: INTROFF/INTRESTORE macros removed The macros were used to assure that the correct core was accessed in the ISR, but register access is now done giving the explicit core so no need to change interrupt state. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 30 +++++------------------ 1 file changed, 6 insertions(+), 24 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c index 3d37b0a437cc..3a78f5f8db7d 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c @@ -940,14 +940,11 @@ uint ai_cc_reg(struct si_pub *sih, uint regoff, u32 mask, u32 val) struct bcma_device *cc; uint origidx = 0; u32 w; - uint intr_val = 0; struct si_info *sii; sii = (struct si_info *)sih; cc = sii->icbus->drv_cc.core; - INTR_OFF(sii, intr_val); - /* save current core index */ origidx = ai_coreidx(&sii->pub); @@ -962,8 +959,6 @@ uint ai_cc_reg(struct si_pub *sih, uint regoff, u32 mask, u32 val) /* restore core index */ ai_setcoreidx(&sii->pub, origidx); - INTR_RESTORE(sii, intr_val); - return w; } @@ -1086,13 +1081,10 @@ u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih) struct bcma_device *cc; uint slowminfreq; u16 fpdelay; - uint intr_val = 0; sii = (struct si_info *)sih; if (ai_get_cccaps(sih) & CC_CAP_PMU) { - INTR_OFF(sii, intr_val); fpdelay = si_pmu_fast_pwrup_delay(sih); - INTR_RESTORE(sii, intr_val); return fpdelay; } @@ -1100,18 +1092,12 @@ u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih) return 0; fpdelay = 0; - INTR_OFF(sii, intr_val); cc = ai_findcore(sih, CC_CORE_ID, 0); - if (cc == NULL) - goto done; - - - slowminfreq = ai_slowclk_freq(sih, false, cc); - fpdelay = (((bcma_read32(cc, CHIPCREGOFFS(pll_on_delay)) + 2) * 1000000) - + (slowminfreq - 1)) / slowminfreq; - - done: - INTR_RESTORE(sii, intr_val); + if (cc) { + slowminfreq = ai_slowclk_freq(sih, false, cc); + fpdelay = (((bcma_read32(cc, CHIPCREGOFFS(pll_on_delay)) + 2) + * 1000000) + (slowminfreq - 1)) / slowminfreq; + } return fpdelay; } @@ -1183,18 +1169,16 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode) { struct bcma_device *cc; u32 scc; - uint intr_val = 0; /* chipcommon cores prior to rev6 don't support dynamic clock control */ if (ai_get_ccrev(&sii->pub) < 6) return false; - INTR_OFF(sii, intr_val); cc = ai_findcore(&sii->pub, BCMA_CORE_CHIPCOMMON, 0); if (!(ai_get_cccaps(&sii->pub) & CC_CAP_PWR_CTL) && (ai_get_ccrev(&sii->pub) < 20)) - goto done; + return mode == CLK_FAST; switch (mode) { case CLK_FAST: /* FORCEHT, fast (pll) clock */ @@ -1248,8 +1232,6 @@ static bool _ai_clkctl_cc(struct si_info *sii, uint mode) break; } - done: - INTR_RESTORE(sii, intr_val); return mode == CLK_FAST; } -- cgit v1.2.3 From 937642f55ef7f8b9dcb202754d53853c7b36e15f Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 12 Dec 2011 15:15:07 -0800 Subject: brcm80211: smac: remove interrupt disable callback functionality There is no need to interrupt disable/enable functionality any longer due to BCMA usage assures the correct core is accessed in any context. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 27 ----------------------- drivers/net/wireless/brcm80211/brcmsmac/aiutils.h | 4 ---- drivers/net/wireless/brcm80211/brcmsmac/main.c | 26 ---------------------- 3 files changed, 57 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c index 3a78f5f8db7d..86e33f953770 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c @@ -818,33 +818,6 @@ void ai_detach(struct si_pub *sih) kfree(sii); } -/* register driver interrupt disabling and restoring callback functions */ -void -ai_register_intr_callback(struct si_pub *sih, void *intrsoff_fn, - void *intrsrestore_fn, - void *intrsenabled_fn, void *intr_arg) -{ - struct si_info *sii; - - sii = (struct si_info *)sih; - sii->intr_arg = intr_arg; - sii->intrsoff_fn = (u32 (*)(void *)) intrsoff_fn; - sii->intrsrestore_fn = (void (*) (void *, u32)) intrsrestore_fn; - sii->intrsenabled_fn = (bool (*)(void *)) intrsenabled_fn; - /* save current core id. when this function called, the current core - * must be the core which provides driver functions(il, et, wl, etc.) - */ - sii->dev_coreid = sii->coreid[sii->curidx]; -} - -void ai_deregister_intr_callback(struct si_pub *sih) -{ - struct si_info *sii; - - sii = (struct si_info *)sih; - sii->intrsoff_fn = NULL; -} - uint ai_coreid(struct si_pub *sih) { struct si_info *sii; diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h index b0b0bfffe162..8c513456643f 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h @@ -238,10 +238,6 @@ extern void __iomem *ai_switch_core(struct si_pub *sih, uint coreid, uint *origidx, uint *intr_val); extern void ai_restore_core(struct si_pub *sih, uint coreid, uint intr_val); extern void ai_pci_setup(struct si_pub *sih, uint coremask); -extern void ai_register_intr_callback(struct si_pub *sih, void *intrsoff_fn, - void *intrsrestore_fn, - void *intrsenabled_fn, void *intr_arg); -extern void ai_deregister_intr_callback(struct si_pub *sih); extern void ai_clkctl_init(struct si_pub *sih); extern u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih); extern bool ai_clkctl_cc(struct si_pub *sih, uint mode); diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index d974809fafc3..1c75e2f52d20 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -2370,27 +2370,6 @@ void brcms_c_intrson(struct brcms_c_info *wlc) bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), wlc->macintmask); } -/* - * callback for siutils.c, which has only wlc handler, no wl they both check - * up, not only because there is no need to off/restore d11 interrupt but also - * because per-port code may require sync with valid interrupt. - */ -static u32 brcms_c_wlintrsoff(struct brcms_c_info *wlc) -{ - if (!wlc->hw->up) - return 0; - - return brcms_intrsoff(wlc->wl); -} - -static void brcms_c_wlintrsrestore(struct brcms_c_info *wlc, u32 macintmask) -{ - if (!wlc->hw->up) - return; - - brcms_intrsrestore(wlc->wl, macintmask); -} - u32 brcms_c_intrsoff(struct brcms_c_info *wlc) { struct brcms_hardware *wlc_hw = wlc->hw; @@ -4712,10 +4691,6 @@ static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core, /* Match driver "down" state */ ai_pci_down(wlc_hw->sih); - /* register sb interrupt callback functions */ - ai_register_intr_callback(wlc_hw->sih, (void *)brcms_c_wlintrsoff, - (void *)brcms_c_wlintrsrestore, NULL, wlc); - /* turn off pll and xtal to match driver "down" state */ brcms_b_xtal(wlc_hw, OFF); @@ -4986,7 +4961,6 @@ static int brcms_b_detach(struct brcms_c_info *wlc) * and per-port interrupt object may has been freed. this must * be done before sb core switch */ - ai_deregister_intr_callback(wlc_hw->sih); ai_pci_sleep(wlc_hw->sih); } -- cgit v1.2.3 From e3d5af56e1a50c9bc3c24810e6b25df91d37bc77 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 12 Dec 2011 15:15:08 -0800 Subject: brcm80211: smac: remove ai_switch_core() function The function ai_switch_core() is no longer needed and its counterpart ai_restore_core() as well, because interrupts disabling is not needed anymore. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 40 ---------------------- drivers/net/wireless/brcm80211/brcmsmac/aiutils.h | 3 -- .../net/wireless/brcm80211/brcmsmac/phy/phy_n.c | 7 +--- drivers/net/wireless/brcm80211/brcmsmac/pmu.c | 24 +++---------- drivers/net/wireless/brcm80211/brcmsmac/pmu.h | 2 +- 5 files changed, 7 insertions(+), 69 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c index 86e33f953770..a99a1633cc10 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c @@ -321,20 +321,6 @@ #define IS_SIM(chippkg) \ ((chippkg == HDLSIM_PKG_ID) || (chippkg == HWSIM_PKG_ID)) -/* - * Macros to disable/restore function core(D11, ENET, ILINE20, etc) interrupts - * before after core switching to avoid invalid register accesss inside ISR. - */ -#define INTR_OFF(si, intr_val) \ - if ((si)->intrsoff_fn && \ - (si)->coreid[(si)->curidx] == (si)->dev_coreid) \ - intr_val = (*(si)->intrsoff_fn)((si)->intr_arg) - -#define INTR_RESTORE(si, intr_val) \ - if ((si)->intrsrestore_fn && \ - (si)->coreid[(si)->curidx] == (si)->dev_coreid) \ - (*(si)->intrsrestore_fn)((si)->intr_arg, intr_val) - #define PCI(sih) (ai_get_buscoretype(sih) == PCI_CORE_ID) #define PCIE(sih) (ai_get_buscoretype(sih) == PCIE_CORE_ID) @@ -872,32 +858,6 @@ void __iomem *ai_setcore(struct si_pub *sih, uint coreid, uint coreunit) return ai_setcoreidx(sih, core->core_index); } -/* Turn off interrupt as required by ai_setcore, before switch core */ -void __iomem *ai_switch_core(struct si_pub *sih, uint coreid, uint *origidx, - uint *intr_val) -{ - void __iomem *cc; - struct si_info *sii; - - sii = (struct si_info *)sih; - - INTR_OFF(sii, *intr_val); - *origidx = sii->curidx; - cc = ai_setcore(sih, coreid, 0); - return cc; -} - -/* restore coreidx and restore interrupt */ -void ai_restore_core(struct si_pub *sih, uint coreid, uint intr_val) -{ - struct si_info *sii; - - sii = (struct si_info *)sih; - - ai_setcoreidx(sih, coreid); - INTR_RESTORE(sii, intr_val); -} - /* * Switch to 'coreidx', issue a single arbitrary 32bit register mask&set * operation, switch back to the original core, and return the new value. diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h index 8c513456643f..e37c9f4d843d 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h @@ -234,9 +234,6 @@ extern uint ai_cc_reg(struct si_pub *sih, uint regoff, u32 mask, u32 val); extern uint ai_findcoreidx(struct si_pub *sih, uint coreid, uint coreunit); extern void __iomem *ai_setcoreidx(struct si_pub *sih, uint coreidx); extern void __iomem *ai_setcore(struct si_pub *sih, uint coreid, uint coreunit); -extern void __iomem *ai_switch_core(struct si_pub *sih, uint coreid, - uint *origidx, uint *intr_val); -extern void ai_restore_core(struct si_pub *sih, uint coreid, uint intr_val); extern void ai_pci_setup(struct si_pub *sih, uint coremask); extern void ai_clkctl_init(struct si_pub *sih); extern u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih); diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c index e0237e497600..a16f1ab292fd 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_n.c @@ -19447,7 +19447,6 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) u8 tx_pwr_ctrl_state; bool do_nphy_cal = false; uint core; - uint origidx, intr_val; u32 d11_clk_ctl_st; bool do_rssi_cal = false; @@ -19469,8 +19468,6 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) if ((pi->nphy_gband_spurwar2_en) && CHSPEC_IS2G(pi->radio_chanspec) && CHSPEC_IS40(pi->radio_chanspec)) { - ai_switch_core(pi->sh->sih, D11_CORE_ID, &origidx, &intr_val); - d11_clk_ctl_st = bcma_read32(pi->d11core, D11REGOFFS(clk_ctl_st)); bcma_mask32(pi->d11core, D11REGOFFS(clk_ctl_st), @@ -19478,8 +19475,6 @@ void wlc_phy_init_nphy(struct brcms_phy *pi) bcma_write32(pi->d11core, D11REGOFFS(clk_ctl_st), d11_clk_ctl_st); - - ai_restore_core(pi->sh->sih, origidx, intr_val); } pi->use_int_tx_iqlo_cal_nphy = @@ -21342,7 +21337,7 @@ wlc_phy_chanspec_nphy_setup(struct brcms_phy *pi, u16 chanspec, spuravoid = 1; wlapi_bmac_core_phypll_ctl(pi->sh->physhim, false); - si_pmu_spuravoid(pi->sh->sih, spuravoid); + si_pmu_spuravoid_pllupdate(pi->sh->sih, spuravoid); wlapi_bmac_core_phypll_ctl(pi->sh->physhim, true); if ((pi->sh->chip == BCM43224_CHIP_ID) || diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pmu.c b/drivers/net/wireless/brcm80211/brcmsmac/pmu.c index d972e9c8d2df..4931d29d077b 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/pmu.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/pmu.c @@ -139,11 +139,13 @@ static void si_pmu_res_masks(struct si_pub *sih, u32 * pmin, u32 * pmax) *pmax = max_mask; } -static void -si_pmu_spuravoid_pllupdate(struct si_pub *sih, struct bcma_device *core, - u8 spuravoid) +void si_pmu_spuravoid_pllupdate(struct si_pub *sih, u8 spuravoid) { u32 tmp = 0; + struct bcma_device *core; + + /* switch to chipc */ + core = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0); switch (ai_get_chip_id(sih)) { case BCM43224_CHIP_ID: @@ -281,22 +283,6 @@ u32 si_pmu_alp_clock(struct si_pub *sih) return clock; } -void si_pmu_spuravoid(struct si_pub *sih, u8 spuravoid) -{ - struct bcma_device *cc; - uint origidx, intr_val; - - /* switch to chipc */ - cc = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0); - ai_switch_core(sih, CC_CORE_ID, &origidx, &intr_val); - - /* update the pll changes */ - si_pmu_spuravoid_pllupdate(sih, cc, spuravoid); - - /* Return to original core */ - ai_restore_core(sih, origidx, intr_val); -} - /* initialize PMU */ void si_pmu_init(struct si_pub *sih) { diff --git a/drivers/net/wireless/brcm80211/brcmsmac/pmu.h b/drivers/net/wireless/brcm80211/brcmsmac/pmu.h index dcd893c68f9a..3e39c5e0f9ff 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/pmu.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/pmu.h @@ -26,7 +26,7 @@ extern u32 si_pmu_chipcontrol(struct si_pub *sih, uint reg, u32 mask, u32 val); extern u32 si_pmu_regcontrol(struct si_pub *sih, uint reg, u32 mask, u32 val); extern u32 si_pmu_alp_clock(struct si_pub *sih); extern void si_pmu_pllupd(struct si_pub *sih); -extern void si_pmu_spuravoid(struct si_pub *sih, u8 spuravoid); +extern void si_pmu_spuravoid_pllupdate(struct si_pub *sih, u8 spuravoid); extern u32 si_pmu_pllcontrol(struct si_pub *sih, uint reg, u32 mask, u32 val); extern void si_pmu_init(struct si_pub *sih); extern void si_pmu_res_init(struct si_pub *sih); -- cgit v1.2.3 From 3b758a68402fc5b1c2dbc246595dbdc062bf0da9 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 12 Dec 2011 15:15:09 -0800 Subject: brcm80211: smac: remove mapped core related function from aiutils.c In aiutils.c the selected core was maintained by its index number. This is obsolete using BCMA functions so several functions using that index have been removed. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 121 +--------------------- drivers/net/wireless/brcm80211/brcmsmac/aiutils.h | 7 -- drivers/net/wireless/brcm80211/brcmsmac/dma.c | 101 +++++++++--------- drivers/net/wireless/brcm80211/brcmsmac/main.c | 14 +-- 4 files changed, 59 insertions(+), 184 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c index a99a1633cc10..f78350a668df 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c @@ -477,50 +477,6 @@ static void ai_scan(struct si_pub *sih, struct bcma_bus *bus) } } -static struct bcma_device *ai_find_bcma_core(struct si_pub *sih, uint coreidx) -{ - struct si_info *sii = (struct si_info *)sih; - struct bcma_device *core; - - list_for_each_entry(core, &sii->icbus->cores, list) { - if (core->core_index == coreidx) - return core; - } - return NULL; -} -/* - * This function changes the logical "focus" to the indicated core. - * Return the current core's virtual address. Since each core starts with the - * same set of registers (BIST, clock control, etc), the returned address - * contains the first register of this 'common' register block (not to be - * confused with 'common core'). - */ -void __iomem *ai_setcoreidx(struct si_pub *sih, uint coreidx) -{ - struct si_info *sii = (struct si_info *)sih; - struct bcma_device *core; - - if (sii->curidx != coreidx) { - core = ai_find_bcma_core(sih, coreidx); - if (core == NULL) - return NULL; - - (void)bcma_aread32(core, BCMA_IOST); - sii->curidx = coreidx; - } - return sii->curmap; -} - -uint ai_corerev(struct si_pub *sih) -{ - struct si_info *sii; - u32 cib; - - sii = (struct si_info *)sih; - cib = sii->cib[sii->curidx]; - return (cib & CIB_REV_MASK) >> CIB_REV_SHIFT; -} - /* return true if PCIE capability exists in the pci config space */ static bool ai_ispcie(struct si_info *sii) { @@ -579,9 +535,8 @@ ai_buscore_setup(struct si_info *sii, struct bcma_device *cc) for (i = 0; i < sii->numcores; i++) { uint cid, crev; - ai_setcoreidx(&sii->pub, i); - cid = ai_coreid(&sii->pub); - crev = ai_corerev(&sii->pub); + cid = sii->coreid[i]; + crev = (sii->cib[i] & CIB_REV_MASK) >> CIB_REV_SHIFT; if (cid == PCI_CORE_ID) { pciidx = i; @@ -804,22 +759,6 @@ void ai_detach(struct si_pub *sih) kfree(sii); } -uint ai_coreid(struct si_pub *sih) -{ - struct si_info *sii; - - sii = (struct si_info *)sih; - return sii->coreid[sii->curidx]; -} - -uint ai_coreidx(struct si_pub *sih) -{ - struct si_info *sii; - - sii = (struct si_info *)sih; - return sii->curidx; -} - /* return index of coreid or BADIDX if not found */ struct bcma_device *ai_findcore(struct si_pub *sih, u16 coreid, u16 coreunit) { @@ -842,45 +781,17 @@ struct bcma_device *ai_findcore(struct si_pub *sih, u16 coreid, u16 coreunit) } /* - * This function changes logical "focus" to the indicated core; - * must be called with interrupts off. - * Moreover, callers should keep interrupts off during switching - * out of and back to d11 core. - */ -void __iomem *ai_setcore(struct si_pub *sih, uint coreid, uint coreunit) -{ - struct bcma_device *core; - - core = ai_findcore(sih, coreid, coreunit); - if (core == NULL) - return NULL; - - return ai_setcoreidx(sih, core->core_index); -} - -/* - * Switch to 'coreidx', issue a single arbitrary 32bit register mask&set - * operation, switch back to the original core, and return the new value. - * - * When using the silicon backplane, no fiddling with interrupts or core - * switches is needed. - * - * Also, when using pci/pcie, we can optimize away the core switching for pci - * registers and (on newer pci cores) chipcommon registers. + * read/modify chipcommon core register. */ uint ai_cc_reg(struct si_pub *sih, uint regoff, u32 mask, u32 val) { struct bcma_device *cc; - uint origidx = 0; u32 w; struct si_info *sii; sii = (struct si_info *)sih; cc = sii->icbus->drv_cc.core; - /* save current core index */ - origidx = ai_coreidx(&sii->pub); - /* mask and set */ if (mask || val) { bcma_maskset32(cc, regoff, ~mask, val); @@ -889,9 +800,6 @@ uint ai_cc_reg(struct si_pub *sih, uint regoff, u32 mask, u32 val) /* readback */ w = bcma_read32(cc, regoff); - /* restore core index */ - ai_setcoreidx(&sii->pub, origidx); - return w; } @@ -1237,20 +1145,10 @@ void ai_pci_down(struct si_pub *sih) void ai_pci_setup(struct si_pub *sih, uint coremask) { struct si_info *sii; - struct sbpciregs __iomem *regs = NULL; u32 w; - uint idx = 0; sii = (struct si_info *)sih; - if (PCI(sih)) { - /* get current core index */ - idx = sii->curidx; - - /* switch over to pci core */ - regs = ai_setcoreidx(sih, sii->buscoreidx); - } - /* * Enable sb->pci interrupts. Assume * PCI rev 2.3 support was added in pci core rev 6 and things changed.. @@ -1264,9 +1162,6 @@ void ai_pci_setup(struct si_pub *sih, uint coremask) if (PCI(sih)) { pcicore_pci_setup(sii->pch); - - /* switch back to previous core */ - ai_setcoreidx(sih, idx); } } @@ -1276,21 +1171,11 @@ void ai_pci_setup(struct si_pub *sih, uint coremask) */ int ai_pci_fixcfg(struct si_pub *sih) { - uint origidx; - void __iomem *regs = NULL; struct si_info *sii = (struct si_info *)sih; /* Fixup PI in SROM shadow area to enable the correct PCI core access */ - /* save the current index */ - origidx = ai_coreidx(&sii->pub); - /* check 'pi' is correct and fix it if not */ - regs = ai_setcore(&sii->pub, ai_get_buscoretype(sih), 0); pcicore_fixcfg(sii->pch); - - /* restore the original index */ - ai_setcoreidx(&sii->pub, origidx); - pcicore_hwup(sii->pch); return 0; } diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h index e37c9f4d843d..6742758e4d45 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h @@ -221,19 +221,12 @@ struct si_info { /* AMBA Interconnect exported externs */ extern struct bcma_device *ai_findcore(struct si_pub *sih, u16 coreid, u16 coreunit); -extern uint ai_coreidx(struct si_pub *sih); -extern uint ai_corerev(struct si_pub *sih); extern u32 ai_core_cflags(struct bcma_device *core, u32 mask, u32 val); /* === exported functions === */ extern struct si_pub *ai_attach(struct bcma_bus *pbus); extern void ai_detach(struct si_pub *sih); -extern uint ai_coreid(struct si_pub *sih); -extern uint ai_corerev(struct si_pub *sih); extern uint ai_cc_reg(struct si_pub *sih, uint regoff, u32 mask, u32 val); -extern uint ai_findcoreidx(struct si_pub *sih, uint coreid, uint coreunit); -extern void __iomem *ai_setcoreidx(struct si_pub *sih, uint coreidx); -extern void __iomem *ai_setcore(struct si_pub *sih, uint coreid, uint coreunit); extern void ai_pci_setup(struct si_pub *sih, uint coremask); extern void ai_clkctl_init(struct si_pub *sih); extern u16 ai_clkctl_fast_pwrup_delay(struct si_pub *sih); diff --git a/drivers/net/wireless/brcm80211/brcmsmac/dma.c b/drivers/net/wireless/brcm80211/brcmsmac/dma.c index dab04bbedc8b..b4cf617276c9 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/dma.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/dma.c @@ -227,7 +227,7 @@ struct dma_info { uint *msg_level; /* message level pointer */ char name[MAXNAMEL]; /* callers name for diag msgs */ - struct bcma_device *d11core; + struct bcma_device *core; struct device *dmadev; bool dma64; /* this dma engine is operating in 64-bit mode */ @@ -383,15 +383,15 @@ static uint _dma_ctrlflags(struct dma_info *di, uint mask, uint flags) if (dmactrlflags & DMA_CTRL_PEN) { u32 control; - control = bcma_read32(di->d11core, DMA64TXREGOFFS(di, control)); - bcma_write32(di->d11core, DMA64TXREGOFFS(di, control), + control = bcma_read32(di->core, DMA64TXREGOFFS(di, control)); + bcma_write32(di->core, DMA64TXREGOFFS(di, control), control | D64_XC_PD); - if (bcma_read32(di->d11core, DMA64TXREGOFFS(di, control)) & + if (bcma_read32(di->core, DMA64TXREGOFFS(di, control)) & D64_XC_PD) /* We *can* disable it so it is supported, * restore control register */ - bcma_write32(di->d11core, DMA64TXREGOFFS(di, control), + bcma_write32(di->core, DMA64TXREGOFFS(di, control), control); else /* Not supported, don't allow it to be enabled */ @@ -406,9 +406,9 @@ static uint _dma_ctrlflags(struct dma_info *di, uint mask, uint flags) static bool _dma64_addrext(struct dma_info *di, uint ctrl_offset) { u32 w; - bcma_set32(di->d11core, ctrl_offset, D64_XC_AE); - w = bcma_read32(di->d11core, ctrl_offset); - bcma_mask32(di->d11core, ctrl_offset, ~D64_XC_AE); + bcma_set32(di->core, ctrl_offset, D64_XC_AE); + w = bcma_read32(di->core, ctrl_offset); + bcma_mask32(di->core, ctrl_offset, ~D64_XC_AE); return (w & D64_XC_AE) == D64_XC_AE; } @@ -442,13 +442,13 @@ static bool _dma_descriptor_align(struct dma_info *di) /* Check to see if the descriptors need to be aligned on 4K/8K or not */ if (di->d64txregbase != 0) { - bcma_write32(di->d11core, DMA64TXREGOFFS(di, addrlow), 0xff0); - addrl = bcma_read32(di->d11core, DMA64TXREGOFFS(di, addrlow)); + bcma_write32(di->core, DMA64TXREGOFFS(di, addrlow), 0xff0); + addrl = bcma_read32(di->core, DMA64TXREGOFFS(di, addrlow)); if (addrl != 0) return false; } else if (di->d64rxregbase != 0) { - bcma_write32(di->d11core, DMA64RXREGOFFS(di, addrlow), 0xff0); - addrl = bcma_read32(di->d11core, DMA64RXREGOFFS(di, addrlow)); + bcma_write32(di->core, DMA64RXREGOFFS(di, addrlow), 0xff0); + addrl = bcma_read32(di->core, DMA64RXREGOFFS(di, addrlow)); if (addrl != 0) return false; } @@ -565,12 +565,13 @@ static bool _dma_alloc(struct dma_info *di, uint direction) } struct dma_pub *dma_attach(char *name, struct si_pub *sih, - struct bcma_device *d11core, + struct bcma_device *core, uint txregbase, uint rxregbase, uint ntxd, uint nrxd, uint rxbufsize, int rxextheadroom, uint nrxpost, uint rxoffset, uint *msg_level) { struct dma_info *di; + u8 rev = core->id.rev; uint size; /* allocate private info structure */ @@ -582,10 +583,10 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, di->dma64 = - ((bcma_aread32(d11core, BCMA_IOST) & SISF_DMA64) == SISF_DMA64); + ((bcma_aread32(core, BCMA_IOST) & SISF_DMA64) == SISF_DMA64); /* init dma reg info */ - di->d11core = d11core; + di->core = core; di->d64txregbase = txregbase; di->d64rxregbase = rxregbase; @@ -606,7 +607,7 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, strncpy(di->name, name, MAXNAMEL); di->name[MAXNAMEL - 1] = '\0'; - di->dmadev = d11core->dma_dev; + di->dmadev = core->dma_dev; /* save tunables */ di->ntxd = (u16) ntxd; @@ -638,11 +639,11 @@ struct dma_pub *dma_attach(char *name, struct si_pub *sih, di->dataoffsetlow = di->ddoffsetlow; di->dataoffsethigh = di->ddoffsethigh; /* WAR64450 : DMACtl.Addr ext fields are not supported in SDIOD core. */ - if ((ai_coreid(sih) == SDIOD_CORE_ID) - && ((ai_corerev(sih) > 0) && (ai_corerev(sih) <= 2))) + if ((core->id.id == SDIOD_CORE_ID) + && ((rev > 0) && (rev <= 2))) di->addrext = 0; - else if ((ai_coreid(sih) == I2S_CORE_ID) && - ((ai_corerev(sih) == 0) || (ai_corerev(sih) == 1))) + else if ((core->id.id == I2S_CORE_ID) && + ((rev == 0) || (rev == 1))) di->addrext = 0; else di->addrext = _dma_isaddrext(di); @@ -792,14 +793,14 @@ _dma_ddtable_init(struct dma_info *di, uint direction, dma_addr_t pa) if ((di->ddoffsetlow == 0) || !(pa & PCI32ADDR_HIGH)) { if (direction == DMA_TX) { - bcma_write32(di->d11core, DMA64TXREGOFFS(di, addrlow), + bcma_write32(di->core, DMA64TXREGOFFS(di, addrlow), pa + di->ddoffsetlow); - bcma_write32(di->d11core, DMA64TXREGOFFS(di, addrhigh), + bcma_write32(di->core, DMA64TXREGOFFS(di, addrhigh), di->ddoffsethigh); } else { - bcma_write32(di->d11core, DMA64RXREGOFFS(di, addrlow), + bcma_write32(di->core, DMA64RXREGOFFS(di, addrlow), pa + di->ddoffsetlow); - bcma_write32(di->d11core, DMA64RXREGOFFS(di, addrhigh), + bcma_write32(di->core, DMA64RXREGOFFS(di, addrhigh), di->ddoffsethigh); } } else { @@ -811,18 +812,18 @@ _dma_ddtable_init(struct dma_info *di, uint direction, dma_addr_t pa) pa &= ~PCI32ADDR_HIGH; if (direction == DMA_TX) { - bcma_write32(di->d11core, DMA64TXREGOFFS(di, addrlow), + bcma_write32(di->core, DMA64TXREGOFFS(di, addrlow), pa + di->ddoffsetlow); - bcma_write32(di->d11core, DMA64TXREGOFFS(di, addrhigh), + bcma_write32(di->core, DMA64TXREGOFFS(di, addrhigh), di->ddoffsethigh); - bcma_maskset32(di->d11core, DMA64TXREGOFFS(di, control), + bcma_maskset32(di->core, DMA64TXREGOFFS(di, control), D64_XC_AE, (ae << D64_XC_AE_SHIFT)); } else { - bcma_write32(di->d11core, DMA64RXREGOFFS(di, addrlow), + bcma_write32(di->core, DMA64RXREGOFFS(di, addrlow), pa + di->ddoffsetlow); - bcma_write32(di->d11core, DMA64RXREGOFFS(di, addrhigh), + bcma_write32(di->core, DMA64RXREGOFFS(di, addrhigh), di->ddoffsethigh); - bcma_maskset32(di->d11core, DMA64RXREGOFFS(di, control), + bcma_maskset32(di->core, DMA64RXREGOFFS(di, control), D64_RC_AE, (ae << D64_RC_AE_SHIFT)); } } @@ -835,7 +836,7 @@ static void _dma_rxenable(struct dma_info *di) DMA_TRACE("%s:\n", di->name); - control = D64_RC_RE | (bcma_read32(di->d11core, + control = D64_RC_RE | (bcma_read32(di->core, DMA64RXREGOFFS(di, control)) & D64_RC_AE); @@ -845,7 +846,7 @@ static void _dma_rxenable(struct dma_info *di) if (dmactrlflags & DMA_CTRL_ROC) control |= D64_RC_OC; - bcma_write32(di->d11core, DMA64RXREGOFFS(di, control), + bcma_write32(di->core, DMA64RXREGOFFS(di, control), ((di->rxoffset << D64_RC_RO_SHIFT) | control)); } @@ -888,7 +889,7 @@ static struct sk_buff *dma64_getnextrxp(struct dma_info *di, bool forceall) return NULL; curr = - B2I(((bcma_read32(di->d11core, + B2I(((bcma_read32(di->core, DMA64RXREGOFFS(di, status0)) & D64_RS0_CD_MASK) - di->rcvptrbase) & D64_RS0_CD_MASK, struct dma64desc); @@ -971,7 +972,7 @@ int dma_rx(struct dma_pub *pub, struct sk_buff_head *skb_list) if (resid > 0) { uint cur; cur = - B2I(((bcma_read32(di->d11core, + B2I(((bcma_read32(di->core, DMA64RXREGOFFS(di, status0)) & D64_RS0_CD_MASK) - di->rcvptrbase) & D64_RS0_CD_MASK, struct dma64desc); @@ -1004,9 +1005,9 @@ static bool dma64_rxidle(struct dma_info *di) if (di->nrxd == 0) return true; - return ((bcma_read32(di->d11core, + return ((bcma_read32(di->core, DMA64RXREGOFFS(di, status0)) & D64_RS0_CD_MASK) == - (bcma_read32(di->d11core, DMA64RXREGOFFS(di, ptr)) & + (bcma_read32(di->core, DMA64RXREGOFFS(di, ptr)) & D64_RS0_CD_MASK)); } @@ -1090,7 +1091,7 @@ bool dma_rxfill(struct dma_pub *pub) di->rxout = rxout; /* update the chip lastdscr pointer */ - bcma_write32(di->d11core, DMA64RXREGOFFS(di, ptr), + bcma_write32(di->core, DMA64RXREGOFFS(di, ptr), di->rcvptrbase + I2B(rxout, struct dma64desc)); return ring_empty; @@ -1151,7 +1152,7 @@ void dma_txinit(struct dma_pub *pub) if ((di->dma.dmactrlflags & DMA_CTRL_PEN) == 0) control |= D64_XC_PD; - bcma_set32(di->d11core, DMA64TXREGOFFS(di, control), control); + bcma_set32(di->core, DMA64TXREGOFFS(di, control), control); /* DMA engine with alignment requirement requires table to be inited * before enabling the engine @@ -1169,7 +1170,7 @@ void dma_txsuspend(struct dma_pub *pub) if (di->ntxd == 0) return; - bcma_set32(di->d11core, DMA64TXREGOFFS(di, control), D64_XC_SE); + bcma_set32(di->core, DMA64TXREGOFFS(di, control), D64_XC_SE); } void dma_txresume(struct dma_pub *pub) @@ -1181,7 +1182,7 @@ void dma_txresume(struct dma_pub *pub) if (di->ntxd == 0) return; - bcma_mask32(di->d11core, DMA64TXREGOFFS(di, control), ~D64_XC_SE); + bcma_mask32(di->core, DMA64TXREGOFFS(di, control), ~D64_XC_SE); } bool dma_txsuspended(struct dma_pub *pub) @@ -1189,7 +1190,7 @@ bool dma_txsuspended(struct dma_pub *pub) struct dma_info *di = (struct dma_info *)pub; return (di->ntxd == 0) || - ((bcma_read32(di->d11core, + ((bcma_read32(di->core, DMA64TXREGOFFS(di, control)) & D64_XC_SE) == D64_XC_SE); } @@ -1224,16 +1225,16 @@ bool dma_txreset(struct dma_pub *pub) return true; /* suspend tx DMA first */ - bcma_write32(di->d11core, DMA64TXREGOFFS(di, control), D64_XC_SE); + bcma_write32(di->core, DMA64TXREGOFFS(di, control), D64_XC_SE); SPINWAIT(((status = - (bcma_read32(di->d11core, DMA64TXREGOFFS(di, status0)) & + (bcma_read32(di->core, DMA64TXREGOFFS(di, status0)) & D64_XS0_XS_MASK)) != D64_XS0_XS_DISABLED) && (status != D64_XS0_XS_IDLE) && (status != D64_XS0_XS_STOPPED), 10000); - bcma_write32(di->d11core, DMA64TXREGOFFS(di, control), 0); + bcma_write32(di->core, DMA64TXREGOFFS(di, control), 0); SPINWAIT(((status = - (bcma_read32(di->d11core, DMA64TXREGOFFS(di, status0)) & + (bcma_read32(di->core, DMA64TXREGOFFS(di, status0)) & D64_XS0_XS_MASK)) != D64_XS0_XS_DISABLED), 10000); /* wait for the last transaction to complete */ @@ -1250,9 +1251,9 @@ bool dma_rxreset(struct dma_pub *pub) if (di->nrxd == 0) return true; - bcma_write32(di->d11core, DMA64RXREGOFFS(di, control), 0); + bcma_write32(di->core, DMA64RXREGOFFS(di, control), 0); SPINWAIT(((status = - (bcma_read32(di->d11core, DMA64RXREGOFFS(di, status0)) & + (bcma_read32(di->core, DMA64RXREGOFFS(di, status0)) & D64_RS0_RS_MASK)) != D64_RS0_RS_DISABLED), 10000); return status == D64_RS0_RS_DISABLED; @@ -1315,7 +1316,7 @@ int dma_txfast(struct dma_pub *pub, struct sk_buff *p, bool commit) /* kick the chip */ if (commit) - bcma_write32(di->d11core, DMA64TXREGOFFS(di, ptr), + bcma_write32(di->core, DMA64TXREGOFFS(di, ptr), di->xmtptrbase + I2B(txout, struct dma64desc)); /* tx flow control */ @@ -1363,14 +1364,14 @@ struct sk_buff *dma_getnexttxp(struct dma_pub *pub, enum txd_range range) if (range == DMA_RANGE_ALL) end = di->txout; else { - end = (u16) (B2I(((bcma_read32(di->d11core, + end = (u16) (B2I(((bcma_read32(di->core, DMA64TXREGOFFS(di, status0)) & D64_XS0_CD_MASK) - di->xmtptrbase) & D64_XS0_CD_MASK, struct dma64desc)); if (range == DMA_RANGE_TRANSFERED) { active_desc = - (u16)(bcma_read32(di->d11core, + (u16)(bcma_read32(di->core, DMA64TXREGOFFS(di, status1)) & D64_XS1_AD_MASK); active_desc = diff --git a/drivers/net/wireless/brcm80211/brcmsmac/main.c b/drivers/net/wireless/brcm80211/brcmsmac/main.c index 1c75e2f52d20..f7ed34034f88 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c @@ -1953,12 +1953,11 @@ static bool brcms_b_radio_read_hwdisabled(struct brcms_hardware *wlc_hw) flags |= SICF_PCLKE; /* + * TODO: test suspend/resume + * * AI chip doesn't restore bar0win2 on * hibernation/resume, need sw fixup */ - if ((ai_get_chip_id(wlc_hw->sih) == BCM43224_CHIP_ID) || - (ai_get_chip_id(wlc_hw->sih) == BCM43225_CHIP_ID)) - (void)ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); bcma_core_enable(wlc_hw->d11core, flags); brcms_c_mctrl_reset(wlc_hw); @@ -4484,8 +4483,6 @@ static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core, wlc_hw->vendorid = pcidev->vendor; wlc_hw->deviceid = pcidev->device; - /* set bar0 window to point at D11 core */ - (void)ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); wlc_hw->d11core = core; wlc_hw->corerev = core->id.rev; @@ -4606,7 +4603,7 @@ static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core, wlc_hw->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; wlc->band->bandunit = j; wlc->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; - wlc->core->coreidx = ai_coreidx(wlc_hw->sih); + wlc->core->coreidx = core->core_index; wlc_hw->machwcap = bcma_read32(core, D11REGOFFS(machwcap)); wlc_hw->machwcap_backup = wlc_hw->machwcap; @@ -5055,12 +5052,11 @@ static void brcms_b_hw_up(struct brcms_hardware *wlc_hw) ai_pci_fixcfg(wlc_hw->sih); /* + * TODO: test suspend/resume + * * AI chip doesn't restore bar0win2 on * hibernation/resume, need sw fixup */ - if ((ai_get_chip_id(wlc_hw->sih) == BCM43224_CHIP_ID) || - (ai_get_chip_id(wlc_hw->sih) == BCM43225_CHIP_ID)) - (void)ai_setcore(wlc_hw->sih, D11_CORE_ID, 0); /* * Inform phy that a POR reset has occurred so -- cgit v1.2.3 From 99559f136559e6822f20fcf1b63e6910df126941 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 12 Dec 2011 15:15:10 -0800 Subject: brcm80211: smac: cleanup si_info structure definition Number of fields are no longer needed as the BCMA provides it or makes them redundant. These have been removed. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 51 +++++------------------ drivers/net/wireless/brcm80211/brcmsmac/aiutils.h | 27 ------------ 2 files changed, 11 insertions(+), 67 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c index f78350a668df..34a5e022509e 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c @@ -454,29 +454,6 @@ struct aidmp { u32 componentid3; /* 0xffc */ }; -/* parse the enumeration rom to identify all cores */ -static void ai_scan(struct si_pub *sih, struct bcma_bus *bus) -{ - struct si_info *sii = (struct si_info *)sih; - struct bcma_device *core; - uint idx; - - list_for_each_entry(core, &bus->cores, list) { - idx = core->core_index; - sii->cia[idx] = core->id.manuf << CIA_MFG_SHIFT; - sii->cia[idx] |= core->id.id << CIA_CID_SHIFT; - sii->cia[idx] |= core->id.class << CIA_CCL_SHIFT; - sii->cib[idx] = core->id.rev << CIB_REV_SHIFT; - sii->coreid[idx] = core->id.id; - sii->coresba[idx] = core->addr; - sii->coresba_size[idx] = 0x1000; - sii->coresba2[idx] = 0; - sii->coresba2_size[idx] = 0; - sii->wrapba[idx] = core->wrap; - sii->numcores++; - } -} - /* return true if PCIE capability exists in the pci config space */ static bool ai_ispcie(struct si_info *sii) { @@ -502,10 +479,16 @@ static bool ai_buscore_prep(struct si_info *sii) static bool ai_buscore_setup(struct si_info *sii, struct bcma_device *cc) { + struct bcma_device *core; bool pci, pcie; uint i; uint pciidx, pcieidx, pcirev, pcierev; + + /* no cores found, bail out */ + if (cc->bus->nr_cores == 0) + return false; + /* get chipcommon rev */ sii->pub.ccrev = cc->id.rev; @@ -532,11 +515,11 @@ ai_buscore_setup(struct si_info *sii, struct bcma_device *cc) pcirev = pcierev = NOREV; pciidx = pcieidx = BADIDX; - for (i = 0; i < sii->numcores; i++) { + list_for_each_entry(core, &cc->bus->cores, list) { uint cid, crev; - cid = sii->coreid[i]; - crev = (sii->cib[i] & CIB_REV_MASK) >> CIB_REV_SHIFT; + cid = core->id.id; + crev = core->id.rev; if (cid == PCI_CORE_ID) { pciidx = i; @@ -596,7 +579,6 @@ static __used void ai_nvram_process(struct si_info *sii) static struct si_info *ai_doattach(struct si_info *sii, struct bcma_bus *pbus) { - void __iomem *regs = pbus->mmio; struct si_pub *sih = &sii->pub; u32 w, savewin; struct bcma_device *cc; @@ -609,8 +591,6 @@ static struct si_info *ai_doattach(struct si_info *sii, sii->icbus = pbus; sii->buscoreidx = BADIDX; sii->pcibus = pbus->host_pci; - sii->curmap = regs; - sii->curwrap = sii->curmap + SI_CORE_SIZE; /* switch to Chipcommon core */ cc = pbus->drv_cc.core; @@ -634,19 +614,10 @@ static struct si_info *ai_doattach(struct si_info *sii, sih->chippkg = (w & CID_PKG_MASK) >> CID_PKG_SHIFT; /* scan for cores */ - if (socitype == SOCI_AI) { - SI_MSG("Found chip type AI (0x%08x)\n", w); - /* pass chipc address instead of original core base */ - ai_scan(&sii->pub, pbus); - } else { - /* Found chip of unknown type */ - return NULL; - } - /* no cores found, bail out */ - if (sii->numcores == 0) + if (socitype != SOCI_AI) return NULL; - /* bus/core/clk setup */ + SI_MSG("Found chip type AI (0x%08x)\n", w); if (!ai_buscore_setup(sii, cc)) goto exit; diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h index 6742758e4d45..f9f88ddbe4af 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h @@ -174,39 +174,12 @@ struct si_info { struct si_pub pub; /* back plane public state (must be first) */ struct bcma_bus *icbus; /* handle to soc interconnect bus */ struct pci_dev *pcibus; /* handle to pci bus */ - uint dev_coreid; /* the core provides driver functions */ - void *intr_arg; /* interrupt callback function arg */ - u32 (*intrsoff_fn) (void *intr_arg); /* turns chip interrupts off */ - /* restore chip interrupts */ - void (*intrsrestore_fn) (void *intr_arg, u32 arg); - /* check if interrupts are enabled */ - bool (*intrsenabled_fn) (void *intr_arg); - struct pcicore_info *pch; /* PCI/E core handle */ struct list_head var_list; /* list of srom variables */ - void __iomem *curmap; /* current regs va */ - void __iomem *regs[SI_MAXCORES]; /* other regs va */ - u32 chipst; /* chip status */ - uint curidx; /* current core index */ uint buscoreidx; /* buscore index */ - uint numcores; /* # discovered cores */ - uint coreid[SI_MAXCORES]; /* id of each core */ - u32 coresba[SI_MAXCORES]; /* backplane address of each core */ - void *regs2[SI_MAXCORES]; /* 2nd virtual address per core (usbh20) */ - u32 coresba2[SI_MAXCORES]; /* 2nd phys address per core (usbh20) */ - u32 coresba_size[SI_MAXCORES]; /* backplane address space size */ - u32 coresba2_size[SI_MAXCORES]; /* second address space size */ - - void *curwrap; /* current wrapper va */ - void *wrappers[SI_MAXCORES]; /* other cores wrapper va */ - u32 wrapba[SI_MAXCORES]; /* address of controlling wrapper */ - - u32 cia[SI_MAXCORES]; /* erom cia entry for each core */ - u32 cib[SI_MAXCORES]; /* erom cia entry for each core */ - u32 oob_router; /* oob router registers for axi */ }; /* -- cgit v1.2.3 From e922602edad30d1f225c32c1cddd80fb3740a8d3 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 12 Dec 2011 15:15:11 -0800 Subject: brcm80211: smac: cleanup buscore handling in aiutils.c Instead of storing the buscore information now the BCMA core device is kept for quick reference in si_info structure. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 52 ++++++++++------------- drivers/net/wireless/brcm80211/brcmsmac/aiutils.h | 23 +++++----- drivers/net/wireless/brcm80211/brcmsmac/nicpci.c | 3 +- 3 files changed, 34 insertions(+), 44 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c index 34a5e022509e..372bee8dd926 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c @@ -479,10 +479,9 @@ static bool ai_buscore_prep(struct si_info *sii) static bool ai_buscore_setup(struct si_info *sii, struct bcma_device *cc) { + struct bcma_device *pci = NULL; + struct bcma_device *pcie = NULL; struct bcma_device *core; - bool pci, pcie; - uint i; - uint pciidx, pcieidx, pcirev, pcierev; /* no cores found, bail out */ @@ -506,15 +505,7 @@ ai_buscore_setup(struct si_info *sii, struct bcma_device *cc) sii->pub.pmurev = sii->pub.pmucaps & PCAP_REV_MASK; } - /* figure out bus/orignal core idx */ - sii->pub.buscoretype = NODEV_CORE_ID; - sii->pub.buscorerev = NOREV; - sii->buscoreidx = BADIDX; - - pci = pcie = false; - pcirev = pcierev = NOREV; - pciidx = pcieidx = BADIDX; - + /* figure out buscore */ list_for_each_entry(core, &cc->bus->cores, list) { uint cid, crev; @@ -522,30 +513,22 @@ ai_buscore_setup(struct si_info *sii, struct bcma_device *cc) crev = core->id.rev; if (cid == PCI_CORE_ID) { - pciidx = i; - pcirev = crev; - pci = true; + pci = core; } else if (cid == PCIE_CORE_ID) { - pcieidx = i; - pcierev = crev; - pcie = true; + pcie = core; } } if (pci && pcie) { if (ai_ispcie(sii)) - pci = false; + pci = NULL; else - pcie = false; + pcie = NULL; } if (pci) { - sii->pub.buscoretype = PCI_CORE_ID; - sii->pub.buscorerev = pcirev; - sii->buscoreidx = pciidx; + sii->buscore = pci; } else if (pcie) { - sii->pub.buscoretype = PCIE_CORE_ID; - sii->pub.buscorerev = pcierev; - sii->buscoreidx = pcieidx; + sii->buscore = pcie; } /* fixup necessary chip/core configurations */ @@ -554,10 +537,8 @@ ai_buscore_setup(struct si_info *sii, struct bcma_device *cc) if (sii->pch == NULL) return false; } - if (ai_pci_fixcfg(&sii->pub)) { - /* si_doattach: si_pci_fixcfg failed */ + if (ai_pci_fixcfg(&sii->pub)) return false; - } return true; } @@ -589,7 +570,6 @@ static struct si_info *ai_doattach(struct si_info *sii, savewin = 0; sii->icbus = pbus; - sii->buscoreidx = BADIDX; sii->pcibus = pbus->host_pci; /* switch to Chipcommon core */ @@ -1248,3 +1228,15 @@ bool ai_is_otp_disabled(struct si_pub *sih) return false; } } + +uint ai_get_buscoretype(struct si_pub *sih) +{ + struct si_info *sii = (struct si_info *)sih; + return sii->buscore->id.id; +} + +uint ai_get_buscorerev(struct si_pub *sih) +{ + struct si_info *sii = (struct si_info *)sih; + return sii->buscore->id.rev; +} diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h index f9f88ddbe4af..f84c6f781692 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h @@ -146,8 +146,6 @@ * public (read-only) portion of aiutils handle returned by si_attach() */ struct si_pub { - uint buscoretype; /* PCI_CORE_ID, PCIE_CORE_ID, PCMCIA_CORE_ID */ - uint buscorerev; /* buscore rev */ int ccrev; /* chip common core rev */ u32 cccaps; /* chip common capabilities */ int pmurev; /* pmu core rev */ @@ -175,11 +173,10 @@ struct si_info { struct bcma_bus *icbus; /* handle to soc interconnect bus */ struct pci_dev *pcibus; /* handle to pci bus */ struct pcicore_info *pch; /* PCI/E core handle */ - + struct bcma_device *buscore; struct list_head var_list; /* list of srom variables */ u32 chipst; /* chip status */ - uint buscoreidx; /* buscore index */ }; /* @@ -224,47 +221,49 @@ extern void ai_chipcontrl_epa4331(struct si_pub *sih, bool on); /* Enable Ex-PA for 4313 */ extern void ai_epa_4313war(struct si_pub *sih); -static inline uint ai_get_buscoretype(struct si_pub *sih) -{ - return sih->buscoretype; -} +extern uint ai_get_buscoretype(struct si_pub *sih); +extern uint ai_get_buscorerev(struct si_pub *sih); -static inline uint ai_get_buscorerev(struct si_pub *sih) -{ - return sih->buscorerev; -} static inline int ai_get_ccrev(struct si_pub *sih) { return sih->ccrev; } + static inline u32 ai_get_cccaps(struct si_pub *sih) { return sih->cccaps; } + static inline int ai_get_pmurev(struct si_pub *sih) { return sih->pmurev; } + static inline u32 ai_get_pmucaps(struct si_pub *sih) { return sih->pmucaps; } + static inline uint ai_get_boardtype(struct si_pub *sih) { return sih->boardtype; } + static inline uint ai_get_boardvendor(struct si_pub *sih) { return sih->boardvendor; } + static inline uint ai_get_chip_id(struct si_pub *sih) { return sih->chip; } + static inline uint ai_get_chiprev(struct si_pub *sih) { return sih->chiprev; } + static inline uint ai_get_chippkg(struct si_pub *sih) { return sih->chippkg; diff --git a/drivers/net/wireless/brcm80211/brcmsmac/nicpci.c b/drivers/net/wireless/brcm80211/brcmsmac/nicpci.c index a4330416b43b..7fad6dc19258 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/nicpci.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/nicpci.c @@ -408,7 +408,7 @@ pcie_mdioop(struct pcicore_info *pi, uint physmedia, uint regaddr, bool write, bcma_write32(pi->core, PCIEREGOFFS(mdiocontrol), MDIOCTL_PREAM_EN | MDIOCTL_DIVISOR_VAL); - if (pi->sih->buscorerev >= 10) { + if (ai_get_buscorerev(pi->sih) >= 10) { /* new serdes is slower in rw, * using two layers of reg address mapping */ @@ -782,7 +782,6 @@ void pcicore_down(struct pcicore_info *pi, int state) pcie_extendL1timer(pi, false); } -/* precondition: current core is sii->buscoretype */ void pcicore_fixcfg(struct pcicore_info *pi) { struct bcma_device *core = pi->core; -- cgit v1.2.3 From eb032f03cbf7ac7baf78ae89a832100561bf0e29 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Mon, 12 Dec 2011 15:15:12 -0800 Subject: brcm80211: smac: register with bcma for specific 802.11 core revisions The brcmsmac driver has been verified on chipsets that were supported when it was a pci device driver, ie. bcm4313, bcm43224, and bcm43225. This patch restricts the driver to 802.11 core revisions that are found in these chipsets. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Alwin Beukers Signed-off-by: Arend van Spriel Signed-off-by: Franky Lin Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c index 30ac8b4ce443..77fdc45b43ef 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c @@ -90,8 +90,8 @@ MODULE_LICENSE("Dual BSD/GPL"); /* recognized BCMA Core IDs */ static struct bcma_device_id brcms_coreid_table[] = { - BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, - BCMA_ANY_REV, BCMA_ANY_CLASS), + BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 23, BCMA_ANY_CLASS), + BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 24, BCMA_ANY_CLASS), BCMA_CORETABLE_END }; MODULE_DEVICE_TABLE(bcma, brcms_coreid_table); -- cgit v1.2.3 From c2521653f4f299b8946fb7073ac90ed5d3d5de7c Mon Sep 17 00:00:00 2001 From: Amitkumar Karwar Date: Mon, 12 Dec 2011 19:56:58 -0800 Subject: mwifiex: do not advertise custom regulatory domain capability mwifiex driver no longer supports it's own custom regulatory rules, but custom regulatory domain capability is still advertised during wiphy registration by the driver. Signed-off-by: Amitkumar Karwar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/cfg80211.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c index 0db97cc84cb4..ffd293e2b87f 100644 --- a/drivers/net/wireless/mwifiex/cfg80211.c +++ b/drivers/net/wireless/mwifiex/cfg80211.c @@ -1376,9 +1376,6 @@ int mwifiex_register_cfg80211(struct mwifiex_private *priv) memcpy(wdev->wiphy->perm_addr, priv->curr_addr, ETH_ALEN); wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; - /* We are using custom domains */ - wdev->wiphy->flags |= WIPHY_FLAG_CUSTOM_REGULATORY; - /* Reserve space for bss band information */ wdev->wiphy->bss_priv_size = sizeof(u8); -- cgit v1.2.3 From 8b1fdb53075bd794a209a611bc94aedaf7ecf9e2 Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Wed, 14 Dec 2011 09:03:52 -0500 Subject: b43: avoid calling bcma_* if CONFIG_B43_BCMA is not set Avoids this: ERROR: "bcma_chipco_pll_write" [drivers/net/wireless/b43/b43.ko] undefined! Signed-off-by: John W. Linville --- drivers/net/wireless/b43/phy_n.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c index 6b95fd29514f..154f97dc3780 100644 --- a/drivers/net/wireless/b43/phy_n.c +++ b/drivers/net/wireless/b43/phy_n.c @@ -4048,6 +4048,7 @@ int b43_phy_initn(struct b43_wldev *dev) /* http://bcm-v4.sipsolutions.net/802.11/PmuSpurAvoid */ static void b43_nphy_pmu_spur_avoid(struct b43_wldev *dev, bool avoid) { +#ifdef CONFIG_B43_BCMA struct bcma_drv_cc *cc = &dev->dev->bdev->bus->drv_cc; u32 pmu_ctl; if (dev->dev->chip_id == 43224 || dev->dev->chip_id == 43225) { @@ -4098,6 +4099,9 @@ static void b43_nphy_pmu_spur_avoid(struct b43_wldev *dev, bool avoid) return; } bcma_cc_set32(cc, BCMA_CC_PMU_CTL, pmu_ctl); +#else + return; +#endif } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/ChanspecSetup */ -- cgit v1.2.3 From 51e708c1049e721b9c5c48d026bc97ca8497d39a Mon Sep 17 00:00:00 2001 From: Yogesh Ashok Powar Date: Tue, 13 Dec 2011 20:43:16 -0800 Subject: mwifiex: avoid double list_del in command cancel path Command cancel path cancels the current command and moves it to free command queue. While doing that it deletes the command entry from the pending list. This is not correct as the entry has been already deleted from the pending list at 'mwifiex_exec_next_cmd'. Fixing it. Also making sure the stale command pointer is cleaned and unaccessible for later use. Signed-off-by: Yogesh Ashok Powar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/cmdevt.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/mwifiex/cmdevt.c b/drivers/net/wireless/mwifiex/cmdevt.c index ac278156d390..6e0a3eaecf70 100644 --- a/drivers/net/wireless/mwifiex/cmdevt.c +++ b/drivers/net/wireless/mwifiex/cmdevt.c @@ -939,7 +939,6 @@ mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter) { struct cmd_ctrl_node *cmd_node = NULL, *tmp_node = NULL; unsigned long cmd_flags; - unsigned long cmd_pending_q_flags; unsigned long scan_pending_q_flags; uint16_t cancel_scan_cmd = false; @@ -949,12 +948,9 @@ mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter) cmd_node = adapter->curr_cmd; cmd_node->wait_q_enabled = false; cmd_node->cmd_flag |= CMD_F_CANCELED; - spin_lock_irqsave(&adapter->cmd_pending_q_lock, - cmd_pending_q_flags); - list_del(&cmd_node->list); - spin_unlock_irqrestore(&adapter->cmd_pending_q_lock, - cmd_pending_q_flags); mwifiex_insert_cmd_to_free_q(adapter, cmd_node); + mwifiex_complete_cmd(adapter, adapter->curr_cmd); + adapter->curr_cmd = NULL; spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, cmd_flags); } @@ -981,7 +977,6 @@ mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter) spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, cmd_flags); } adapter->cmd_wait_q.status = -1; - mwifiex_complete_cmd(adapter, adapter->curr_cmd); } /* -- cgit v1.2.3 From 81670a491849127cd5f86defd2cd03cef1b08d07 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 14 Dec 2011 08:22:35 -0800 Subject: iwlwifi: tx_sync only on PAN context Ted reported that he couldn't connect to some APs and bisected it to the tx_sync implementation. Disable it for the BSS context to fix this issue. Reported-by: Ted Ts'o Signed-off-by: Johannes Berg Signed-off-by: Wey-Yi Guy Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index bacc06c95e7a..e0e9a3dfbc00 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c @@ -2850,6 +2850,9 @@ static int iwlagn_mac_tx_sync(struct ieee80211_hw *hw, int ret; u8 sta_id; + if (ctx->ctxid != IWL_RXON_CTX_PAN) + return 0; + IWL_DEBUG_MAC80211(priv, "enter\n"); mutex_lock(&priv->shrd->mutex); @@ -2898,6 +2901,9 @@ static void iwlagn_mac_finish_tx_sync(struct ieee80211_hw *hw, struct iwl_vif_priv *vif_priv = (void *)vif->drv_priv; struct iwl_rxon_context *ctx = vif_priv->ctx; + if (ctx->ctxid != IWL_RXON_CTX_PAN) + return; + IWL_DEBUG_MAC80211(priv, "enter\n"); mutex_lock(&priv->shrd->mutex); -- cgit v1.2.3 From 78feb35b8161acd95c33a703ed6ab6f554d29387 Mon Sep 17 00:00:00 2001 From: Wey-Yi Guy Date: Wed, 14 Dec 2011 08:22:36 -0800 Subject: iwlwifi: allow to switch to HT40 if not associated My previous patch 34a5b4b6af104cf18eb50748509528b9bdbc4036 iwlwifi: do not re-configure HT40 after associated Fix the case of HT40 after association on specified AP, but it break the association for some APs and cause not able to establish connection. We need to address HT40 before and after addociation. CC: stable@vger.kernel.org #3.0+ Reported-by: Andrej Gelenberg Signed-off-by: Wey-Yi Guy Tested-by: Andrej Gelenberg Signed-off-by: John W. Linville --- drivers/net/wireless/iwlwifi/iwl-agn-rxon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c index a7a6def40d05..5c7c17c7166a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-rxon.c @@ -606,8 +606,8 @@ int iwlagn_mac_config(struct ieee80211_hw *hw, u32 changed) if (ctx->ht.enabled) { /* if HT40 is used, it should not change * after associated except channel switch */ - if (iwl_is_associated_ctx(ctx) && - !ctx->ht.is_40mhz) + if (!ctx->ht.is_40mhz || + !iwl_is_associated_ctx(ctx)) iwlagn_config_ht40(conf, ctx); } else ctx->ht.is_40mhz = false; -- cgit v1.2.3 From 38c9d6641ff0664911aebe4ba67124f28169a972 Mon Sep 17 00:00:00 2001 From: Amitkumar Karwar Date: Tue, 13 Dec 2011 20:43:17 -0800 Subject: mwifiex: remove cfg_workqueue cfg_workqueue was added to notify cfg80211 that scan, connect or disconnect is done by calling respective completion handlers. We can avoid use of this workqueue by calling those handlers from other places. 1) Call connect, disconnect completion handlers in their callback functions. ex. Call cfg80211_connect_result() in mwifiex_cfg80211_connect() 2) Call scan completion handler after parsing response of last scan command in a queue. After removing the workqueue, variables (assoc_request etc.) and checks used for mutual exclusion become redundant. Those are also removed in this patch. Signed-off-by: Amitkumar Karwar Signed-off-by: Yogesh Ashok Powar Signed-off-by: Nishant Sarmukadam Signed-off-by: Kiran Divekar Signed-off-by: Bing Zhao Signed-off-by: John W. Linville --- drivers/net/wireless/mwifiex/cfg80211.c | 191 +++++++++---------------------- drivers/net/wireless/mwifiex/cfg80211.h | 1 - drivers/net/wireless/mwifiex/main.c | 2 - drivers/net/wireless/mwifiex/main.h | 9 +- drivers/net/wireless/mwifiex/scan.c | 13 ++- drivers/net/wireless/mwifiex/sta_event.c | 17 ++- 6 files changed, 75 insertions(+), 158 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c index ffd293e2b87f..787dbe2aa408 100644 --- a/drivers/net/wireless/mwifiex/cfg80211.c +++ b/drivers/net/wireless/mwifiex/cfg80211.c @@ -751,17 +751,13 @@ mwifiex_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *dev, { struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); - if (priv->disconnect) - return -EBUSY; - - priv->disconnect = 1; if (mwifiex_deauthenticate(priv, NULL)) return -EFAULT; wiphy_dbg(wiphy, "info: successfully disconnected from %pM:" " reason code %d\n", priv->cfg_bssid, reason_code); - queue_work(priv->workqueue, &priv->cfg_workqueue); + memset(priv->cfg_bssid, 0, ETH_ALEN); return 0; } @@ -981,27 +977,32 @@ mwifiex_cfg80211_connect(struct wiphy *wiphy, struct net_device *dev, struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); int ret = 0; - if (priv->assoc_request) - return -EBUSY; - if (priv->bss_mode == NL80211_IFTYPE_ADHOC) { wiphy_err(wiphy, "received infra assoc request " "when station is in ibss mode\n"); goto done; } - priv->assoc_request = -EINPROGRESS; - wiphy_dbg(wiphy, "info: Trying to associate to %s and bssid %pM\n", (char *) sme->ssid, sme->bssid); ret = mwifiex_cfg80211_assoc(priv, sme->ssid_len, sme->ssid, sme->bssid, priv->bss_mode, sme->channel, sme, 0); - - priv->assoc_request = 1; done: - priv->assoc_result = ret; - queue_work(priv->workqueue, &priv->cfg_workqueue); + if (!ret) { + cfg80211_connect_result(priv->netdev, priv->cfg_bssid, NULL, 0, + NULL, 0, WLAN_STATUS_SUCCESS, + GFP_KERNEL); + dev_dbg(priv->adapter->dev, + "info: associated to bssid %pM successfully\n", + priv->cfg_bssid); + } else { + dev_dbg(priv->adapter->dev, + "info: association to bssid %pM failed\n", + priv->cfg_bssid); + memset(priv->cfg_bssid, 0, ETH_ALEN); + } + return ret; } @@ -1018,28 +1019,29 @@ mwifiex_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev, struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy); int ret = 0; - if (priv->ibss_join_request) - return -EBUSY; - if (priv->bss_mode != NL80211_IFTYPE_ADHOC) { wiphy_err(wiphy, "request to join ibss received " "when station is not in ibss mode\n"); goto done; } - priv->ibss_join_request = -EINPROGRESS; - wiphy_dbg(wiphy, "info: trying to join to %s and bssid %pM\n", (char *) params->ssid, params->bssid); ret = mwifiex_cfg80211_assoc(priv, params->ssid_len, params->ssid, params->bssid, priv->bss_mode, params->channel, NULL, params->privacy); - - priv->ibss_join_request = 1; done: - priv->ibss_join_result = ret; - queue_work(priv->workqueue, &priv->cfg_workqueue); + if (!ret) { + cfg80211_ibss_joined(priv->netdev, priv->cfg_bssid, GFP_KERNEL); + dev_dbg(priv->adapter->dev, + "info: joined/created adhoc network with bssid" + " %pM successfully\n", priv->cfg_bssid); + } else { + dev_dbg(priv->adapter->dev, + "info: failed creating/joining adhoc network\n"); + } + return ret; } @@ -1054,17 +1056,12 @@ mwifiex_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) { struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy); - if (priv->disconnect) - return -EBUSY; - - priv->disconnect = 1; - wiphy_dbg(wiphy, "info: disconnecting from essid %pM\n", priv->cfg_bssid); if (mwifiex_deauthenticate(priv, NULL)) return -EFAULT; - queue_work(priv->workqueue, &priv->cfg_workqueue); + memset(priv->cfg_bssid, 0, ETH_ALEN); return 0; } @@ -1081,15 +1078,42 @@ mwifiex_cfg80211_scan(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_scan_request *request) { struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev); + int i; + struct ieee80211_channel *chan; wiphy_dbg(wiphy, "info: received scan request on %s\n", dev->name); - if (priv->scan_request && priv->scan_request != request) - return -EBUSY; - priv->scan_request = request; - queue_work(priv->workqueue, &priv->cfg_workqueue); + priv->user_scan_cfg = kzalloc(sizeof(struct mwifiex_user_scan_cfg), + GFP_KERNEL); + if (!priv->user_scan_cfg) { + dev_err(priv->adapter->dev, "failed to alloc scan_req\n"); + return -ENOMEM; + } + for (i = 0; i < request->n_ssids; i++) { + memcpy(priv->user_scan_cfg->ssid_list[i].ssid, + request->ssids[i].ssid, request->ssids[i].ssid_len); + priv->user_scan_cfg->ssid_list[i].max_len = + request->ssids[i].ssid_len; + } + for (i = 0; i < request->n_channels; i++) { + chan = request->channels[i]; + priv->user_scan_cfg->chan_list[i].chan_number = chan->hw_value; + priv->user_scan_cfg->chan_list[i].radio_type = chan->band; + + if (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN) + priv->user_scan_cfg->chan_list[i].scan_type = + MWIFIEX_SCAN_TYPE_PASSIVE; + else + priv->user_scan_cfg->chan_list[i].scan_type = + MWIFIEX_SCAN_TYPE_ACTIVE; + + priv->user_scan_cfg->chan_list[i].scan_time = 0; + } + if (mwifiex_set_user_scan_ioctl(priv, priv->user_scan_cfg)) + return -EFAULT; + return 0; } @@ -1295,10 +1319,6 @@ int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct net_device *dev) priv->media_connected = false; - cancel_work_sync(&priv->cfg_workqueue); - flush_workqueue(priv->workqueue); - destroy_workqueue(priv->workqueue); - priv->bss_mode = NL80211_IFTYPE_UNSPECIFIED; return 0; @@ -1404,100 +1424,3 @@ int mwifiex_register_cfg80211(struct mwifiex_private *priv) return ret; } - -/* - * This function handles the result of different pending network operations. - * - * The following operations are handled and CFG802.11 subsystem is - * notified accordingly - - * - Scan request completion - * - Association request completion - * - IBSS join request completion - * - Disconnect request completion - */ -void -mwifiex_cfg80211_results(struct work_struct *work) -{ - struct mwifiex_private *priv = - container_of(work, struct mwifiex_private, cfg_workqueue); - struct mwifiex_user_scan_cfg *scan_req; - int ret = 0, i; - struct ieee80211_channel *chan; - - if (priv->scan_request) { - scan_req = kzalloc(sizeof(struct mwifiex_user_scan_cfg), - GFP_KERNEL); - if (!scan_req) { - dev_err(priv->adapter->dev, "failed to alloc " - "scan_req\n"); - return; - } - for (i = 0; i < priv->scan_request->n_ssids; i++) { - memcpy(scan_req->ssid_list[i].ssid, - priv->scan_request->ssids[i].ssid, - priv->scan_request->ssids[i].ssid_len); - scan_req->ssid_list[i].max_len = - priv->scan_request->ssids[i].ssid_len; - } - for (i = 0; i < priv->scan_request->n_channels; i++) { - chan = priv->scan_request->channels[i]; - scan_req->chan_list[i].chan_number = chan->hw_value; - scan_req->chan_list[i].radio_type = chan->band; - if (chan->flags & IEEE80211_CHAN_DISABLED) - scan_req->chan_list[i].scan_type = - MWIFIEX_SCAN_TYPE_PASSIVE; - else - scan_req->chan_list[i].scan_type = - MWIFIEX_SCAN_TYPE_ACTIVE; - scan_req->chan_list[i].scan_time = 0; - } - if (mwifiex_set_user_scan_ioctl(priv, scan_req)) - ret = -EFAULT; - priv->scan_result_status = ret; - dev_dbg(priv->adapter->dev, "info: %s: sending scan results\n", - __func__); - cfg80211_scan_done(priv->scan_request, - (priv->scan_result_status < 0)); - priv->scan_request = NULL; - kfree(scan_req); - } - - if (priv->assoc_request == 1) { - if (!priv->assoc_result) { - cfg80211_connect_result(priv->netdev, priv->cfg_bssid, - NULL, 0, NULL, 0, - WLAN_STATUS_SUCCESS, - GFP_KERNEL); - dev_dbg(priv->adapter->dev, - "info: associated to bssid %pM successfully\n", - priv->cfg_bssid); - } else { - dev_dbg(priv->adapter->dev, - "info: association to bssid %pM failed\n", - priv->cfg_bssid); - memset(priv->cfg_bssid, 0, ETH_ALEN); - } - priv->assoc_request = 0; - priv->assoc_result = 0; - } - - if (priv->ibss_join_request == 1) { - if (!priv->ibss_join_result) { - cfg80211_ibss_joined(priv->netdev, priv->cfg_bssid, - GFP_KERNEL); - dev_dbg(priv->adapter->dev, - "info: joined/created adhoc network with bssid" - " %pM successfully\n", priv->cfg_bssid); - } else { - dev_dbg(priv->adapter->dev, - "info: failed creating/joining adhoc network\n"); - } - priv->ibss_join_request = 0; - priv->ibss_join_result = 0; - } - - if (priv->disconnect) { - memset(priv->cfg_bssid, 0, ETH_ALEN); - priv->disconnect = 0; - } -} diff --git a/drivers/net/wireless/mwifiex/cfg80211.h b/drivers/net/wireless/mwifiex/cfg80211.h index 8d010f2500c5..76c76c60438b 100644 --- a/drivers/net/wireless/mwifiex/cfg80211.h +++ b/drivers/net/wireless/mwifiex/cfg80211.h @@ -26,5 +26,4 @@ int mwifiex_register_cfg80211(struct mwifiex_private *); -void mwifiex_cfg80211_results(struct work_struct *work); #endif diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c index d21cd4707f01..84be196188cc 100644 --- a/drivers/net/wireless/mwifiex/main.c +++ b/drivers/net/wireless/mwifiex/main.c @@ -586,8 +586,6 @@ void mwifiex_init_priv_params(struct mwifiex_private *priv, priv->media_connected = false; memset(&priv->nick_name, 0, sizeof(priv->nick_name)); priv->num_tx_timeout = 0; - priv->workqueue = create_singlethread_workqueue("cfg80211_wq"); - INIT_WORK(&priv->cfg_workqueue, mwifiex_cfg80211_results); memcpy(dev->dev_addr, priv->curr_addr, ETH_ALEN); } diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h index 41f88631763c..9207fc64641e 100644 --- a/drivers/net/wireless/mwifiex/main.h +++ b/drivers/net/wireless/mwifiex/main.h @@ -453,15 +453,8 @@ struct mwifiex_private { u8 scan_pending_on_block; u8 report_scan_result; struct cfg80211_scan_request *scan_request; - int scan_result_status; - int assoc_request; - u16 assoc_result; - int ibss_join_request; - u16 ibss_join_result; - bool disconnect; + struct mwifiex_user_scan_cfg *user_scan_cfg; u8 cfg_bssid[6]; - struct workqueue_struct *workqueue; - struct work_struct cfg_workqueue; u8 country_code[IEEE80211_COUNTRY_STRING_LEN]; struct wps wps; u8 scan_block; diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c index b8b9d37b01a9..e2e715666bca 100644 --- a/drivers/net/wireless/mwifiex/scan.c +++ b/drivers/net/wireless/mwifiex/scan.c @@ -1391,11 +1391,8 @@ int mwifiex_set_user_scan_ioctl(struct mwifiex_private *priv, { int status; - priv->adapter->scan_wait_q_woken = false; - status = mwifiex_scan_networks(priv, scan_req); - if (!status) - status = mwifiex_wait_queue_complete(priv->adapter); + queue_work(priv->adapter->workqueue, &priv->adapter->main_work); return status; } @@ -1796,6 +1793,14 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, up(&priv->async_sem); } + if (priv->user_scan_cfg) { + dev_dbg(priv->adapter->dev, "info: %s: sending scan " + "results\n", __func__); + cfg80211_scan_done(priv->scan_request, 0); + priv->scan_request = NULL; + kfree(priv->user_scan_cfg); + priv->user_scan_cfg = NULL; + } } else { /* Get scan command from scan_pending_q and put to cmd_pending_q */ diff --git a/drivers/net/wireless/mwifiex/sta_event.c b/drivers/net/wireless/mwifiex/sta_event.c index 40205f60be4d..d7aa21da84d0 100644 --- a/drivers/net/wireless/mwifiex/sta_event.c +++ b/drivers/net/wireless/mwifiex/sta_event.c @@ -115,16 +115,15 @@ mwifiex_reset_connect_state(struct mwifiex_private *priv) if (adapter->num_cmd_timeout && adapter->curr_cmd) return; priv->media_connected = false; - if (!priv->disconnect) { - priv->disconnect = 1; - dev_dbg(adapter->dev, "info: successfully disconnected from" - " %pM: reason code %d\n", priv->cfg_bssid, - WLAN_REASON_DEAUTH_LEAVING); - cfg80211_disconnected(priv->netdev, - WLAN_REASON_DEAUTH_LEAVING, NULL, 0, - GFP_KERNEL); - queue_work(priv->workqueue, &priv->cfg_workqueue); + dev_dbg(adapter->dev, "info: successfully disconnected from" + " %pM: reason code %d\n", priv->cfg_bssid, + WLAN_REASON_DEAUTH_LEAVING); + if (priv->bss_mode == NL80211_IFTYPE_STATION) { + cfg80211_disconnected(priv->netdev, WLAN_REASON_DEAUTH_LEAVING, + NULL, 0, GFP_KERNEL); } + memset(priv->cfg_bssid, 0, ETH_ALEN); + if (!netif_queue_stopped(priv->netdev)) mwifiex_stop_net_dev_queue(priv->netdev, adapter); if (netif_carrier_ok(priv->netdev)) -- cgit v1.2.3 From e4522ab1c469a65857ddd2d22d0d3f5606965aaa Mon Sep 17 00:00:00 2001 From: Helmut Schaa Date: Wed, 14 Dec 2011 16:28:41 +0100 Subject: rt2x00: Make use of ieee80211_free_txskb in tx path ieee80211_free_txskb should be used when dropping a frame in the device rx path such that mac80211 knows about this frame being dropped. Signed-off-by: Helmut Schaa Acked-by: Gertjan van Wingerde Acked-by: Ivo van Doorn Signed-off-by: John W. Linville --- drivers/net/wireless/rt2x00/rt2x00mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c index bf0acff07807..ede3c58e6783 100644 --- a/drivers/net/wireless/rt2x00/rt2x00mac.c +++ b/drivers/net/wireless/rt2x00/rt2x00mac.c @@ -160,7 +160,7 @@ void rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb) exit_fail: rt2x00queue_pause_queue(queue); exit_free_skb: - dev_kfree_skb_any(skb); + ieee80211_free_txskb(hw, skb); } EXPORT_SYMBOL_GPL(rt2x00mac_tx); -- cgit v1.2.3 From 3f1764945eaac532c20ab1f23afa352a40f797b2 Mon Sep 17 00:00:00 2001 From: Pontus Fuchs Date: Thu, 1 Dec 2011 12:13:44 +0100 Subject: wl12xx: Restore testmode ABI Commit 80900d0140a7648587982c8f299830e900e49165 accidently broke the ABI for testmode commands. Restore the ABI again. Signed-off-by: Pontus Fuchs Cc: stable@kernel.org Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/testmode.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/testmode.c b/drivers/net/wireless/wl12xx/testmode.c index 978cf2de713d..25093c0cb0ed 100644 --- a/drivers/net/wireless/wl12xx/testmode.c +++ b/drivers/net/wireless/wl12xx/testmode.c @@ -38,6 +38,7 @@ enum wl1271_tm_commands { WL1271_TM_CMD_TEST, WL1271_TM_CMD_INTERROGATE, WL1271_TM_CMD_CONFIGURE, + WL1271_TM_CMD_NVS_PUSH, /* Not in use. Keep to not break ABI */ WL1271_TM_CMD_SET_PLT_MODE, WL1271_TM_CMD_RECOVER, -- cgit v1.2.3 From f414218ed8bc716825755c9cf59f16a19f28314a Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Tue, 13 Dec 2011 11:39:02 +0200 Subject: wl12xx: don't write out of bounds when hlid > WL12XX_MAX_LINKS We should not get an hlid value bigger than WL12XX_MAX_LINKS from wl1271_rx_handle_data(). We have a WARN_ON in case it happens. But despite the warning, we would still go ahead and write the hlid bit into active_hlids (a stack variable). This would cause us to overwrite other data in the stack. To avoid this problem, we now skip the write when issuing the warning, so at least we don't corrupt data. Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/rx.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/rx.c b/drivers/net/wireless/wl12xx/rx.c index 8c277c0cb372..4fbd2a722ffa 100644 --- a/drivers/net/wireless/wl12xx/rx.c +++ b/drivers/net/wireless/wl12xx/rx.c @@ -258,8 +258,12 @@ void wl12xx_rx(struct wl1271 *wl, struct wl12xx_fw_status *status) wl->aggr_buf + pkt_offset, pkt_length, unaligned, &hlid) == 1) { - WARN_ON(hlid >= WL12XX_MAX_LINKS); - __set_bit(hlid, active_hlids); + if (hlid < WL12XX_MAX_LINKS) + __set_bit(hlid, active_hlids); + else + WARN(1, + "hlid exceeded WL12XX_MAX_LINKS " + "(%d)\n", hlid); } wl->rx_counter++; -- cgit v1.2.3 From 2c8f82eabc6b3b6d1fc97954377e67f2d83db687 Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Tue, 13 Dec 2011 11:39:50 +0200 Subject: wl12xx: call extended radio parameters for wl127x AP mode We need to set the extended radio parameters for wl127x only. Currently, we were only calling this command with wl127x STA mode, but we should also do it for AP mode. Move the call to the extended radio paramaters to the common hw_init and use a single if for the chip type to do everything at once. Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/init.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index 88891cdfdd4a..76625145e32e 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -328,12 +328,6 @@ static int wl1271_sta_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif) { int ret; - if (wl->chip.id != CHIP_ID_1283_PG20) { - ret = wl1271_cmd_ext_radio_parms(wl); - if (ret < 0) - return ret; - } - /* PS config */ ret = wl12xx_acx_config_ps(wl, wlvif); if (ret < 0) @@ -659,19 +653,24 @@ int wl1271_hw_init(struct wl1271 *wl) { int ret; - if (wl->chip.id == CHIP_ID_1283_PG20) + if (wl->chip.id == CHIP_ID_1283_PG20) { ret = wl128x_cmd_general_parms(wl); - else - ret = wl1271_cmd_general_parms(wl); - if (ret < 0) - return ret; - - if (wl->chip.id == CHIP_ID_1283_PG20) + if (ret < 0) + return ret; ret = wl128x_cmd_radio_parms(wl); - else + if (ret < 0) + return ret; + } else { + ret = wl1271_cmd_general_parms(wl); + if (ret < 0) + return ret; ret = wl1271_cmd_radio_parms(wl); - if (ret < 0) - return ret; + if (ret < 0) + return ret; + ret = wl1271_cmd_ext_radio_parms(wl); + if (ret < 0) + return ret; + } /* Chip-specific init */ ret = wl1271_chip_specific_init(wl); -- cgit v1.2.3 From 5de8eef4fdd2044f6981ebf62330720bcdba8ee3 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Tue, 13 Dec 2011 15:26:38 +0200 Subject: wl12xx: use ieee80211_free_txskb() Use the newly introduced ieee80211_free_txskb() instead of dev_kfree_skb() for failed tx packets. Additionally, if the skb is a dummy packet, re-enqueue it (as the fw expects it) instead of freeing it. Reported-by: Arik Nemtsov Signed-off-by: Eliad Peller Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 2 +- drivers/net/wireless/wl12xx/tx.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 2f7bfa86c8cd..333bc294f1d9 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1448,7 +1448,7 @@ static void wl1271_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) if (hlid == WL12XX_INVALID_LINK_ID || (wlvif && !test_bit(hlid, wlvif->links_map))) { wl1271_debug(DEBUG_TX, "DROP skb hlid %d q %d", hlid, q); - dev_kfree_skb(skb); + ieee80211_free_txskb(hw, skb); goto out; } diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/tx.c index 7d727ee6ddf6..4508ccd78328 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/tx.c @@ -740,7 +740,14 @@ void wl1271_tx_work_locked(struct wl1271 *wl) set_bit(WL1271_FLAG_FW_TX_BUSY, &wl->flags); goto out_ack; } else if (ret < 0) { - dev_kfree_skb(skb); + if (wl12xx_is_dummy_packet(wl, skb)) + /* + * fw still expects dummy packet, + * so re-enqueue it + */ + wl1271_skb_queue_head(wl, wlvif, skb); + else + ieee80211_free_txskb(wl->hw, skb); goto out_ack; } buf_offset += ret; -- cgit v1.2.3 From 36b2082434e956e6048a26bbf4c14ad7488db153 Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Tue, 13 Dec 2011 15:45:54 +0200 Subject: wl12xx: remove deprecated packet detection threshold config The ACX_PD_THRESHOLD configuration command is deprecated and should not be used anymore. Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/acx.c | 26 -------------------------- drivers/net/wireless/wl12xx/acx.h | 8 -------- drivers/net/wireless/wl12xx/init.c | 16 ---------------- drivers/net/wireless/wl12xx/init.h | 1 - drivers/net/wireless/wl12xx/main.c | 5 ----- 5 files changed, 56 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/acx.c b/drivers/net/wireless/wl12xx/acx.c index bde1d862bdd5..7537c401a448 100644 --- a/drivers/net/wireless/wl12xx/acx.c +++ b/drivers/net/wireless/wl12xx/acx.c @@ -186,32 +186,6 @@ out: return ret; } -int wl1271_acx_pd_threshold(struct wl1271 *wl) -{ - struct acx_packet_detection *pd; - int ret; - - wl1271_debug(DEBUG_ACX, "acx data pd threshold"); - - pd = kzalloc(sizeof(*pd), GFP_KERNEL); - if (!pd) { - ret = -ENOMEM; - goto out; - } - - pd->threshold = cpu_to_le32(wl->conf.rx.packet_detection_threshold); - - ret = wl1271_cmd_configure(wl, ACX_PD_THRESHOLD, pd, sizeof(*pd)); - if (ret < 0) { - wl1271_warning("failed to set pd threshold: %d", ret); - goto out; - } - -out: - kfree(pd); - return ret; -} - int wl1271_acx_slot(struct wl1271 *wl, struct wl12xx_vif *wlvif, enum acx_slot_type slot_time) { diff --git a/drivers/net/wireless/wl12xx/acx.h b/drivers/net/wireless/wl12xx/acx.h index b2d85bea6378..69892b40c2df 100644 --- a/drivers/net/wireless/wl12xx/acx.h +++ b/drivers/net/wireless/wl12xx/acx.h @@ -171,13 +171,6 @@ struct acx_rx_msdu_lifetime { __le32 lifetime; } __packed; -struct acx_packet_detection { - struct acx_header header; - - __le32 threshold; -} __packed; - - enum acx_slot_type { SLOT_TIME_LONG = 0, SLOT_TIME_SHORT = 1, @@ -1238,7 +1231,6 @@ int wl1271_acx_feature_cfg(struct wl1271 *wl, struct wl12xx_vif *wlvif); int wl1271_acx_mem_map(struct wl1271 *wl, struct acx_header *mem_map, size_t len); int wl1271_acx_rx_msdu_life_time(struct wl1271 *wl); -int wl1271_acx_pd_threshold(struct wl1271 *wl); int wl1271_acx_slot(struct wl1271 *wl, struct wl12xx_vif *wlvif, enum acx_slot_type slot_time); int wl1271_acx_group_address_tbl(struct wl1271 *wl, struct wl12xx_vif *wlvif, diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c index 76625145e32e..ca7ee59e4505 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/init.c @@ -223,17 +223,6 @@ static int wl12xx_init_rx_config(struct wl1271 *wl) return 0; } -int wl1271_init_phy_config(struct wl1271 *wl) -{ - int ret; - - ret = wl1271_acx_pd_threshold(wl); - if (ret < 0) - return ret; - - return 0; -} - static int wl12xx_init_phy_vif_config(struct wl1271 *wl, struct wl12xx_vif *wlvif) { @@ -706,11 +695,6 @@ int wl1271_hw_init(struct wl1271 *wl) if (ret < 0) goto out_free_memmap; - /* PHY layer config */ - ret = wl1271_init_phy_config(wl); - if (ret < 0) - goto out_free_memmap; - ret = wl1271_acx_dco_itrim_params(wl); if (ret < 0) goto out_free_memmap; diff --git a/drivers/net/wireless/wl12xx/init.h b/drivers/net/wireless/wl12xx/init.h index 81140b81f654..2da0f404ef6e 100644 --- a/drivers/net/wireless/wl12xx/init.h +++ b/drivers/net/wireless/wl12xx/init.h @@ -28,7 +28,6 @@ int wl1271_hw_init_power_auth(struct wl1271 *wl); int wl1271_init_templates_config(struct wl1271 *wl); -int wl1271_init_phy_config(struct wl1271 *wl); int wl1271_init_pta(struct wl1271 *wl); int wl1271_init_energy_detection(struct wl1271 *wl); int wl1271_chip_specific_init(struct wl1271 *wl); diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index 333bc294f1d9..ec446710ebb3 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -674,11 +674,6 @@ static int wl1271_plt_init(struct wl1271 *wl) if (ret < 0) return ret; - /* PHY layer config */ - ret = wl1271_init_phy_config(wl); - if (ret < 0) - goto out_free_memmap; - ret = wl12xx_acx_mem_cfg(wl); if (ret < 0) goto out_free_memmap; -- cgit v1.2.3 From 7f74484a460f6bb8656725babf2e977e47a3dab4 Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Wed, 14 Dec 2011 14:57:58 +0200 Subject: wl12xx: remove unused firmware version macros We don't use WL12XX_BA_SUPPORT_FW_COST_VER2_START nor WL12XX_BA_SUPPORT_FW_COST_VER2_END anymore. Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/wl12xx.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h index f1c911774bfd..d21f71ff6f64 100644 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ b/drivers/net/wireless/wl12xx/wl12xx.h @@ -35,13 +35,6 @@ #include "conf.h" #include "ini.h" -/* - * FW versions support BA 11n - * versions marks x.x.x.50-60.x - */ -#define WL12XX_BA_SUPPORT_FW_COST_VER2_START 50 -#define WL12XX_BA_SUPPORT_FW_COST_VER2_END 60 - #define WL127X_FW_NAME "ti-connectivity/wl127x-fw-3.bin" #define WL128X_FW_NAME "ti-connectivity/wl128x-fw-3.bin" -- cgit v1.2.3 From ef1870673dc3b66d8daec2b1fd1048992440e0e5 Mon Sep 17 00:00:00 2001 From: Pontus Fuchs Date: Wed, 14 Dec 2011 14:32:23 +0100 Subject: Set wlvif->ps_compl to NULL in before return wl1271_configure_suspend_sta leaves a stale stack declared completion in wlvif->ps_compl. Set it to NULL before returning. Signed-off-by: Pontus Fuchs [small fix to use wlvif->ps_compl instead of wl->ps_compl] Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c index ec446710ebb3..c3058419e227 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/main.c @@ -1580,24 +1580,24 @@ static int wl1271_configure_suspend_sta(struct wl1271 *wl, ret = wait_for_completion_timeout( &compl, msecs_to_jiffies(WL1271_PS_COMPLETE_TIMEOUT)); + + mutex_lock(&wl->mutex); if (ret <= 0) { wl1271_warning("couldn't enter ps mode!"); ret = -EBUSY; - goto out; + goto out_cleanup; } - /* take mutex again, and wakeup */ - mutex_lock(&wl->mutex); - ret = wl1271_ps_elp_wakeup(wl); if (ret < 0) - goto out_unlock; + goto out_cleanup; } out_sleep: wl1271_ps_elp_sleep(wl); +out_cleanup: + wlvif->ps_compl = NULL; out_unlock: mutex_unlock(&wl->mutex); -out: return ret; } -- cgit v1.2.3 From c99f895a231b2dfeedd27e4d218a1b2d22cf4d02 Mon Sep 17 00:00:00 2001 From: Luciano Coelho Date: Thu, 15 Dec 2011 14:58:08 +0200 Subject: wl12xx: alloc buffer in driver_state_read to prevent compilation warning When compiling wl12xx for x86, there was a warning complaining about the size of the buffer we were allocating in the stack: drivers/net/wireless/wl12xx/debugfs.c: In function 'driver_state_read': drivers/net/wireless/wl12xx/debugfs.c:380:1: warning: the frame size of 1040 bytes is larger than 1024 bytes To prevent this, allocate the buffer in the heap instead. Signed-off-by: Luciano Coelho --- drivers/net/wireless/wl12xx/debugfs.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c index 2e14b436101f..15eb3a9c30ca 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/debugfs.c @@ -317,12 +317,19 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, { struct wl1271 *wl = file->private_data; int res = 0; - char buf[1024]; + ssize_t ret; + char *buf; + +#define DRIVER_STATE_BUF_LEN 1024 + + buf = kmalloc(DRIVER_STATE_BUF_LEN, GFP_KERNEL); + if (!buf) + return -ENOMEM; mutex_lock(&wl->mutex); #define DRIVER_STATE_PRINT(x, fmt) \ - (res += scnprintf(buf + res, sizeof(buf) - res,\ + (res += scnprintf(buf + res, DRIVER_STATE_BUF_LEN - res,\ #x " = " fmt "\n", wl->x)) #define DRIVER_STATE_PRINT_LONG(x) DRIVER_STATE_PRINT(x, "%ld") @@ -373,10 +380,13 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf, #undef DRIVER_STATE_PRINT_LHEX #undef DRIVER_STATE_PRINT_STR #undef DRIVER_STATE_PRINT +#undef DRIVER_STATE_BUF_LEN mutex_unlock(&wl->mutex); - return simple_read_from_buffer(user_buf, count, ppos, buf, res); + ret = simple_read_from_buffer(user_buf, count, ppos, buf, res); + kfree(buf); + return ret; } static const struct file_operations driver_state_ops = { -- cgit v1.2.3 From da647626c7aa854755d32dc8e33d3c58314d2fdb Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 14 Dec 2011 22:08:03 +0100 Subject: ath9k: change maximum software retransmission handling Instead of limiting a subframe to 10 A-MPDU software transmission attempts, count hardware retransmissions as well and raise the limit a bit. That way there will be fewer software retransmission attempts when traffic suffers from lots of hardware retransmissions. Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ath9k.h | 2 +- drivers/net/wireless/ath/ath9k/xmit.c | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index afc156a0a2e3..fa6c9050a8af 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h @@ -542,7 +542,7 @@ struct ath_ant_comb { #define DEFAULT_CACHELINE 32 #define ATH_REGCLASSIDS_MAX 10 #define ATH_CABQ_READY_TIME 80 /* % of beacon interval */ -#define ATH_MAX_SW_RETRIES 10 +#define ATH_MAX_SW_RETRIES 30 #define ATH_CHAN_MAX 255 #define ATH_TXPOWER_MAX 100 /* .5 dBm units */ diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c index 9e65c3198ca7..a46b4e2f045c 100644 --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c @@ -264,14 +264,17 @@ static void ath_tid_drain(struct ath_softc *sc, struct ath_txq *txq, } static void ath_tx_set_retry(struct ath_softc *sc, struct ath_txq *txq, - struct sk_buff *skb) + struct sk_buff *skb, int count) { struct ath_frame_info *fi = get_frame_info(skb); struct ath_buf *bf = fi->bf; struct ieee80211_hdr *hdr; + int prev = fi->retries; TX_STAT_INC(txq->axq_qnum, a_retries); - if (fi->retries++ > 0) + fi->retries += count; + + if (prev > 0) return; hdr = (struct ieee80211_hdr *)skb->data; @@ -379,6 +382,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, int nframes; u8 tidno; bool flush = !!(ts->ts_status & ATH9K_TX_FLUSH); + int i, retries; skb = bf->bf_mpdu; hdr = (struct ieee80211_hdr *)skb->data; @@ -387,6 +391,10 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, memcpy(rates, tx_info->control.rates, sizeof(rates)); + retries = ts->ts_longretry + 1; + for (i = 0; i < ts->ts_rateindex; i++) + retries += rates[i].count; + rcu_read_lock(); sta = ieee80211_find_sta_by_ifaddr(hw, hdr->addr1, hdr->addr2); @@ -471,7 +479,8 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, txpending = 1; } else if (fi->retries < ATH_MAX_SW_RETRIES) { if (txok || !an->sleeping) - ath_tx_set_retry(sc, txq, bf->bf_mpdu); + ath_tx_set_retry(sc, txq, bf->bf_mpdu, + retries); txpending = 1; } else { -- cgit v1.2.3 From 156369faa3f49c4fa37cf1f5254b1f3903b23dfd Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 14 Dec 2011 22:08:04 +0100 Subject: ath9k: reduce the number of unnecessary BAR tx packets When processing A-MPDU tx status, only send a BAR for the failed packet with the highest sequence number. Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ath9k.h | 6 ++-- drivers/net/wireless/ath/ath9k/debug.c | 2 +- drivers/net/wireless/ath/ath9k/main.c | 2 +- drivers/net/wireless/ath/ath9k/xmit.c | 50 +++++++++++++++++++++------------- 4 files changed, 37 insertions(+), 23 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index fa6c9050a8af..6beaff5e5be3 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h @@ -159,6 +159,9 @@ void ath_descdma_cleanup(struct ath_softc *sc, struct ath_descdma *dd, /* return block-ack bitmap index given sequence and starting sequence */ #define ATH_BA_INDEX(_st, _seq) (((_seq) - (_st)) & (IEEE80211_SEQ_MAX - 1)) +/* return the seqno for _start + _offset */ +#define ATH_BA_INDEX2SEQ(_seq, _offset) (((_seq) + (_offset)) & (IEEE80211_SEQ_MAX - 1)) + /* returns delimiter padding required given the packet length */ #define ATH_AGGR_GET_NDELIM(_len) \ (((_len) >= ATH_AGGR_MINPLEN) ? 0 : \ @@ -252,9 +255,9 @@ struct ath_atx_tid { struct ath_node { #ifdef CONFIG_ATH9K_DEBUGFS struct list_head list; /* for sc->nodes */ +#endif struct ieee80211_sta *sta; /* station struct we're part of */ struct ieee80211_vif *vif; /* interface with which we're associated */ -#endif struct ath_atx_tid tid[WME_NUM_TID]; struct ath_atx_ac ac[WME_NUM_AC]; int ps_key; @@ -276,7 +279,6 @@ struct ath_tx_control { }; #define ATH_TX_ERROR 0x01 -#define ATH_TX_BAR 0x02 /** * @txq_map: Index is mac80211 queue number. This is diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c index 6fb719d85b37..5cb8cceffd0b 100644 --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c @@ -856,7 +856,7 @@ void ath_debug_stat_tx(struct ath_softc *sc, struct ath_buf *bf, sc->debug.stats.txstats[qnum].tx_bytes_all += bf->bf_mpdu->len; if (bf_isampdu(bf)) { - if (flags & ATH_TX_BAR) + if (flags & ATH_TX_ERROR) TX_STAT_INC(qnum, a_xretries); else TX_STAT_INC(qnum, a_completed); diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 7d920044d031..4475b0d5b3ae 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -644,9 +644,9 @@ static void ath_node_attach(struct ath_softc *sc, struct ieee80211_sta *sta, spin_lock(&sc->nodes_lock); list_add(&an->list, &sc->nodes); spin_unlock(&sc->nodes_lock); +#endif an->sta = sta; an->vif = vif; -#endif if (sc->sc_flags & SC_OP_TXAGGR) { ath_tx_node_init(sc, an); an->maxampdu = 1 << (IEEE80211_HT_MAX_AMPDU_FACTOR + diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c index a46b4e2f045c..649a11e52030 100644 --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c @@ -53,7 +53,7 @@ static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb, int tx_flags, struct ath_txq *txq); static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf, struct ath_txq *txq, struct list_head *bf_q, - struct ath_tx_status *ts, int txok, int sendbar); + struct ath_tx_status *ts, int txok); static void ath_tx_txqaddbuf(struct ath_softc *sc, struct ath_txq *txq, struct list_head *head, bool internal); static void ath_tx_rc_status(struct ath_softc *sc, struct ath_buf *bf, @@ -150,6 +150,12 @@ static struct ath_frame_info *get_frame_info(struct sk_buff *skb) return (struct ath_frame_info *) &tx_info->rate_driver_data[0]; } +static void ath_send_bar(struct ath_atx_tid *tid, u16 seqno) +{ + ieee80211_send_bar(tid->an->vif, tid->an->sta->addr, tid->tidno, + seqno << IEEE80211_SEQ_SEQ_SHIFT); +} + static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid) { struct ath_txq *txq = tid->ac->txq; @@ -158,6 +164,7 @@ static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid) struct list_head bf_head; struct ath_tx_status ts; struct ath_frame_info *fi; + bool sendbar = false; INIT_LIST_HEAD(&bf_head); @@ -172,7 +179,8 @@ static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid) if (bf && fi->retries) { list_add_tail(&bf->list, &bf_head); ath_tx_update_baw(sc, tid, bf->bf_state.seqno); - ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0, 1); + ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0); + sendbar = true; } else { ath_tx_send_normal(sc, txq, NULL, skb); } @@ -185,6 +193,9 @@ static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid) } spin_unlock_bh(&txq->axq_lock); + + if (sendbar) + ath_send_bar(tid, tid->seq_start); } static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid, @@ -255,7 +266,7 @@ static void ath_tid_drain(struct ath_softc *sc, struct ath_txq *txq, ath_tx_update_baw(sc, tid, bf->bf_state.seqno); spin_unlock(&txq->axq_lock); - ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0, 0); + ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0); spin_lock(&txq->axq_lock); } @@ -373,7 +384,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, struct ath_buf *bf_next, *bf_last = bf->bf_lastbf; struct list_head bf_head; struct sk_buff_head bf_pending; - u16 seq_st = 0, acked_cnt = 0, txfail_cnt = 0; + u16 seq_st = 0, acked_cnt = 0, txfail_cnt = 0, seq_first; u32 ba[WME_BA_BMP_SIZE >> 5]; int isaggr, txfail, txpending, sendbar = 0, needreset = 0, nbad = 0; bool rc_update = true; @@ -383,6 +394,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, u8 tidno; bool flush = !!(ts->ts_status & ATH9K_TX_FLUSH); int i, retries; + int bar_index = -1; skb = bf->bf_mpdu; hdr = (struct ieee80211_hdr *)skb->data; @@ -408,8 +420,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, if (!bf->bf_stale || bf_next != NULL) list_move_tail(&bf->list, &bf_head); - ath_tx_complete_buf(sc, bf, txq, &bf_head, ts, - 0, 0); + ath_tx_complete_buf(sc, bf, txq, &bf_head, ts, 0); bf = bf_next; } @@ -419,6 +430,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, an = (struct ath_node *)sta->drv_priv; tidno = ieee80211_get_qos_ctl(hdr)[0] & IEEE80211_QOS_CTL_TID_MASK; tid = ATH_AN_2_TID(an, tidno); + seq_first = tid->seq_start; /* * The hardware occasionally sends a tx status for the wrong TID. @@ -485,8 +497,9 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, txpending = 1; } else { txfail = 1; - sendbar = 1; txfail_cnt++; + bar_index = max_t(int, bar_index, + ATH_BA_INDEX(seq_first, seqno)); } } @@ -515,7 +528,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, } ath_tx_complete_buf(sc, bf, txq, &bf_head, ts, - !txfail, sendbar); + !txfail); } else { /* retry the un-acked ones */ if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)) { @@ -535,8 +548,10 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, ath_tx_complete_buf(sc, bf, txq, &bf_head, - ts, 0, - !flush); + ts, 0); + bar_index = max_t(int, bar_index, + ATH_BA_INDEX(seq_first, + seqno)); break; } @@ -554,6 +569,9 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, bf = bf_next; } + if (bar_index >= 0) + ath_send_bar(tid, ATH_BA_INDEX2SEQ(seq_first, bar_index + 1)); + /* prepend un-acked frames to the beginning of the pending frame queue */ if (!skb_queue_empty(&bf_pending)) { if (an->sleeping) @@ -1441,7 +1459,7 @@ static void ath_drain_txq_list(struct ath_softc *sc, struct ath_txq *txq, ath_tx_complete_aggr(sc, txq, bf, &bf_head, &ts, 0, retry_tx); else - ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0, 0); + ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0); spin_lock_bh(&txq->axq_lock); } } @@ -1945,9 +1963,6 @@ static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb, ath_dbg(common, ATH_DBG_XMIT, "TX complete: skb: %p\n", skb); - if (tx_flags & ATH_TX_BAR) - tx_info->flags |= IEEE80211_TX_STAT_AMPDU_NO_BACK; - if (!(tx_flags & ATH_TX_ERROR)) /* Frame was ACKed */ tx_info->flags |= IEEE80211_TX_STAT_ACK; @@ -1991,16 +2006,13 @@ static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb, static void ath_tx_complete_buf(struct ath_softc *sc, struct ath_buf *bf, struct ath_txq *txq, struct list_head *bf_q, - struct ath_tx_status *ts, int txok, int sendbar) + struct ath_tx_status *ts, int txok) { struct sk_buff *skb = bf->bf_mpdu; struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); unsigned long flags; int tx_flags = 0; - if (sendbar) - tx_flags = ATH_TX_BAR; - if (!txok) tx_flags |= ATH_TX_ERROR; @@ -2107,7 +2119,7 @@ static void ath_tx_process_buffer(struct ath_softc *sc, struct ath_txq *txq, if (!bf_isampdu(bf)) { ath_tx_rc_status(sc, bf, ts, 1, txok ? 0 : 1, txok); - ath_tx_complete_buf(sc, bf, txq, bf_head, ts, txok, 0); + ath_tx_complete_buf(sc, bf, txq, bf_head, ts, txok); } else ath_tx_complete_aggr(sc, txq, bf, bf_head, ts, txok, true); -- cgit v1.2.3 From b047701383cf886ee18124db0a8c027af6ccc07b Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 14 Dec 2011 22:08:05 +0100 Subject: ath9k: reduce indentation level in a few places Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/xmit.c | 125 ++++++++++++++++------------------ 1 file changed, 60 insertions(+), 65 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c index 649a11e52030..b1a37d28deee 100644 --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c @@ -480,27 +480,25 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, } else if (!isaggr && txok) { /* transmit completion */ acked_cnt++; + } else if ((tid->state & AGGR_CLEANUP) || !retry) { + /* + * cleanup in progress, just fail + * the un-acked sub-frames + */ + txfail = 1; + } else if (flush) { + txpending = 1; + } else if (fi->retries < ATH_MAX_SW_RETRIES) { + if (txok || !an->sleeping) + ath_tx_set_retry(sc, txq, bf->bf_mpdu, + retries); + + txpending = 1; } else { - if ((tid->state & AGGR_CLEANUP) || !retry) { - /* - * cleanup in progress, just fail - * the un-acked sub-frames - */ - txfail = 1; - } else if (flush) { - txpending = 1; - } else if (fi->retries < ATH_MAX_SW_RETRIES) { - if (txok || !an->sleeping) - ath_tx_set_retry(sc, txq, bf->bf_mpdu, - retries); - - txpending = 1; - } else { - txfail = 1; - txfail_cnt++; - bar_index = max_t(int, bar_index, - ATH_BA_INDEX(seq_first, seqno)); - } + txfail = 1; + txfail_cnt++; + bar_index = max_t(int, bar_index, + ATH_BA_INDEX(seq_first, seqno)); } /* @@ -531,32 +529,29 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, !txfail); } else { /* retry the un-acked ones */ - if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)) { - if (bf->bf_next == NULL && bf_last->bf_stale) { - struct ath_buf *tbf; - - tbf = ath_clone_txbuf(sc, bf_last); - /* - * Update tx baw and complete the - * frame with failed status if we - * run out of tx buf. - */ - if (!tbf) { - spin_lock_bh(&txq->axq_lock); - ath_tx_update_baw(sc, tid, seqno); - spin_unlock_bh(&txq->axq_lock); - - ath_tx_complete_buf(sc, bf, txq, - &bf_head, - ts, 0); - bar_index = max_t(int, bar_index, - ATH_BA_INDEX(seq_first, - seqno)); - break; - } - - fi->bf = tbf; + if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) && + bf->bf_next == NULL && bf_last->bf_stale) { + struct ath_buf *tbf; + + tbf = ath_clone_txbuf(sc, bf_last); + /* + * Update tx baw and complete the + * frame with failed status if we + * run out of tx buf. + */ + if (!tbf) { + spin_lock_bh(&txq->axq_lock); + ath_tx_update_baw(sc, tid, seqno); + spin_unlock_bh(&txq->axq_lock); + + ath_tx_complete_buf(sc, bf, txq, + &bf_head, ts, 0); + bar_index = max_t(int, bar_index, + ATH_BA_INDEX(seq_first, seqno)); + break; } + + fi->bf = tbf; } /* @@ -644,24 +639,26 @@ static u32 ath_lookup_rate(struct ath_softc *sc, struct ath_buf *bf, max_4ms_framelen = ATH_AMPDU_LIMIT_MAX; for (i = 0; i < 4; i++) { - if (rates[i].count) { - int modeidx; - if (!(rates[i].flags & IEEE80211_TX_RC_MCS)) { - legacy = 1; - break; - } - - if (rates[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH) - modeidx = MCS_HT40; - else - modeidx = MCS_HT20; + int modeidx; - if (rates[i].flags & IEEE80211_TX_RC_SHORT_GI) - modeidx++; + if (!rates[i].count) + continue; - frmlen = ath_max_4ms_framelen[modeidx][rates[i].idx]; - max_4ms_framelen = min(max_4ms_framelen, frmlen); + if (!(rates[i].flags & IEEE80211_TX_RC_MCS)) { + legacy = 1; + break; } + + if (rates[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH) + modeidx = MCS_HT40; + else + modeidx = MCS_HT20; + + if (rates[i].flags & IEEE80211_TX_RC_SHORT_GI) + modeidx++; + + frmlen = ath_max_4ms_framelen[modeidx][rates[i].idx]; + max_4ms_framelen = min(max_4ms_framelen, frmlen); } /* @@ -1587,11 +1584,9 @@ void ath_txq_schedule(struct ath_softc *sc, struct ath_txq *txq) break; } - if (!list_empty(&ac->tid_q)) { - if (!ac->sched) { - ac->sched = true; - list_add_tail(&ac->list, &txq->axq_acq); - } + if (!list_empty(&ac->tid_q) && !ac->sched) { + ac->sched = true; + list_add_tail(&ac->list, &txq->axq_acq); } if (ac == last_ac || -- cgit v1.2.3 From 6ee8284edb9be5cd567ff3f772de3bf55c73fc7a Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 14 Dec 2011 22:08:06 +0100 Subject: ath9k: remove bogus sequence number increment tid->seq_next is initialized on A-MPDU start anyway, and the comment next to this chunk of code seems to be bogus as well. Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/xmit.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c index b1a37d28deee..8f38efbea5dc 100644 --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c @@ -1729,10 +1729,6 @@ static void ath_tx_send_normal(struct ath_softc *sc, struct ath_txq *txq, list_add_tail(&bf->list, &bf_head); bf->bf_state.bf_type = 0; - /* update starting sequence number for subsequent ADDBA request */ - if (tid) - INCR(tid->seq_start, IEEE80211_SEQ_MAX); - bf->bf_lastbf = bf; ath_tx_fill_desc(sc, bf, txq, fi->framelen); ath_tx_txqaddbuf(sc, txq, &bf_head, false); -- cgit v1.2.3 From 3ad2952998b08442044690fa9b4ec38c6c3fc4a9 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 14 Dec 2011 22:08:07 +0100 Subject: ath9k: simplify tx locking Instead of releasing and taking back the lock over and over again in the tx path, hold the lock a bit longer, requiring much fewer lock/unlock pairs. This makes locking much easier to review and should not have any noticeable performance/latency impact. Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/xmit.c | 39 +++++------------------------------ 1 file changed, 5 insertions(+), 34 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c index 8f38efbea5dc..8766796b48b8 100644 --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c @@ -169,13 +169,11 @@ static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid) INIT_LIST_HEAD(&bf_head); memset(&ts, 0, sizeof(ts)); - spin_lock_bh(&txq->axq_lock); while ((skb = __skb_dequeue(&tid->buf_q))) { fi = get_frame_info(skb); bf = fi->bf; - spin_unlock_bh(&txq->axq_lock); if (bf && fi->retries) { list_add_tail(&bf->list, &bf_head); ath_tx_update_baw(sc, tid, bf->bf_state.seqno); @@ -184,7 +182,6 @@ static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid) } else { ath_tx_send_normal(sc, txq, NULL, skb); } - spin_lock_bh(&txq->axq_lock); } if (tid->baw_head == tid->baw_tail) { @@ -192,8 +189,6 @@ static void ath_tx_flush_tid(struct ath_softc *sc, struct ath_atx_tid *tid) tid->state &= ~AGGR_CLEANUP; } - spin_unlock_bh(&txq->axq_lock); - if (sendbar) ath_send_bar(tid, tid->seq_start); } @@ -254,9 +249,7 @@ static void ath_tid_drain(struct ath_softc *sc, struct ath_txq *txq, bf = fi->bf; if (!bf) { - spin_unlock(&txq->axq_lock); ath_tx_complete(sc, skb, ATH_TX_ERROR, txq); - spin_lock(&txq->axq_lock); continue; } @@ -265,9 +258,7 @@ static void ath_tid_drain(struct ath_softc *sc, struct ath_txq *txq, if (fi->retries) ath_tx_update_baw(sc, tid, bf->bf_state.seqno); - spin_unlock(&txq->axq_lock); ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0); - spin_lock(&txq->axq_lock); } tid->seq_next = tid->seq_start; @@ -515,9 +506,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, * complete the acked-ones/xretried ones; update * block-ack window */ - spin_lock_bh(&txq->axq_lock); ath_tx_update_baw(sc, tid, seqno); - spin_unlock_bh(&txq->axq_lock); if (rc_update && (acked_cnt == 1 || txfail_cnt == 1)) { memcpy(tx_info->control.rates, rates, sizeof(rates)); @@ -540,9 +529,7 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, * run out of tx buf. */ if (!tbf) { - spin_lock_bh(&txq->axq_lock); ath_tx_update_baw(sc, tid, seqno); - spin_unlock_bh(&txq->axq_lock); ath_tx_complete_buf(sc, bf, txq, &bf_head, ts, 0); @@ -572,7 +559,6 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, if (an->sleeping) ieee80211_sta_set_buffered(sta, tid->tidno, true); - spin_lock_bh(&txq->axq_lock); skb_queue_splice(&bf_pending, &tid->buf_q); if (!an->sleeping) { ath_tx_queue_tid(txq, tid); @@ -580,7 +566,6 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, if (ts->ts_status & ATH9K_TXERR_FILT) tid->ac->clear_ps_filter = true; } - spin_unlock_bh(&txq->axq_lock); } if (tid->state & AGGR_CLEANUP) @@ -1179,9 +1164,9 @@ void ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid) txtid->state |= AGGR_CLEANUP; else txtid->state &= ~AGGR_ADDBA_COMPLETE; - spin_unlock_bh(&txq->axq_lock); ath_tx_flush_tid(sc, txtid); + spin_unlock_bh(&txq->axq_lock); } void ath_tx_aggr_sleep(struct ieee80211_sta *sta, struct ath_softc *sc, @@ -1423,8 +1408,6 @@ static bool bf_is_ampdu_not_probing(struct ath_buf *bf) static void ath_drain_txq_list(struct ath_softc *sc, struct ath_txq *txq, struct list_head *list, bool retry_tx) - __releases(txq->axq_lock) - __acquires(txq->axq_lock) { struct ath_buf *bf, *lastbf; struct list_head bf_head; @@ -1451,13 +1434,11 @@ static void ath_drain_txq_list(struct ath_softc *sc, struct ath_txq *txq, if (bf_is_ampdu_not_probing(bf)) txq->axq_ampdu_depth--; - spin_unlock_bh(&txq->axq_lock); if (bf_isampdu(bf)) ath_tx_complete_aggr(sc, txq, bf, &bf_head, &ts, 0, retry_tx); else ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0); - spin_lock_bh(&txq->axq_lock); } } @@ -1836,7 +1817,6 @@ static void ath_tx_start_dma(struct ath_softc *sc, struct sk_buff *skb, struct ath_buf *bf; u8 tidno; - spin_lock_bh(&txctl->txq->axq_lock); if ((sc->sc_flags & SC_OP_TXAGGR) && txctl->an && ieee80211_is_data_qos(hdr->frame_control)) { tidno = ieee80211_get_qos_ctl(hdr)[0] & @@ -1855,7 +1835,7 @@ static void ath_tx_start_dma(struct ath_softc *sc, struct sk_buff *skb, } else { bf = ath_tx_setup_buffer(sc, txctl->txq, tid, skb); if (!bf) - goto out; + return; bf->bf_state.bfs_paprd = txctl->paprd; @@ -1864,9 +1844,6 @@ static void ath_tx_start_dma(struct ath_softc *sc, struct sk_buff *skb, ath_tx_send_normal(sc, txctl->txq, tid, skb); } - -out: - spin_unlock_bh(&txctl->txq->axq_lock); } /* Upon failure caller should free skb */ @@ -1933,9 +1910,11 @@ int ath_tx_start(struct ieee80211_hw *hw, struct sk_buff *skb, ieee80211_stop_queue(sc->hw, q); txq->stopped = 1; } - spin_unlock_bh(&txq->axq_lock); ath_tx_start_dma(sc, skb, txctl); + + spin_unlock_bh(&txq->axq_lock); + return 0; } @@ -1981,7 +1960,6 @@ static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb, q = skb_get_queue_mapping(skb); if (txq == sc->tx.txq_map[q]) { - spin_lock_bh(&txq->axq_lock); if (WARN_ON(--txq->pending_frames < 0)) txq->pending_frames = 0; @@ -1989,7 +1967,6 @@ static void ath_tx_complete(struct ath_softc *sc, struct sk_buff *skb, ieee80211_wake_queue(sc->hw, q); txq->stopped = 0; } - spin_unlock_bh(&txq->axq_lock); } ieee80211_tx_status(hw, skb); @@ -2095,8 +2072,6 @@ static void ath_tx_rc_status(struct ath_softc *sc, struct ath_buf *bf, static void ath_tx_process_buffer(struct ath_softc *sc, struct ath_txq *txq, struct ath_tx_status *ts, struct ath_buf *bf, struct list_head *bf_head) - __releases(txq->axq_lock) - __acquires(txq->axq_lock) { int txok; @@ -2106,16 +2081,12 @@ static void ath_tx_process_buffer(struct ath_softc *sc, struct ath_txq *txq, if (bf_is_ampdu_not_probing(bf)) txq->axq_ampdu_depth--; - spin_unlock_bh(&txq->axq_lock); - if (!bf_isampdu(bf)) { ath_tx_rc_status(sc, bf, ts, 1, txok ? 0 : 1, txok); ath_tx_complete_buf(sc, bf, txq, bf_head, ts, txok); } else ath_tx_complete_aggr(sc, txq, bf, bf_head, ts, txok, true); - spin_lock_bh(&txq->axq_lock); - if (sc->sc_flags & SC_OP_TXAGGR) ath_txq_schedule(sc, txq); } -- cgit v1.2.3 From f94375431749d555a16659051d8033ba9a0fe83b Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 14 Dec 2011 22:08:08 +0100 Subject: ath9k: avoid retransmitting aggregation frames that a BAR was sent for The receiver will discard them anyway. Signed-off-by: Felix Fietkau Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/ath9k.h | 1 + drivers/net/wireless/ath/ath9k/xmit.c | 27 ++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index 6beaff5e5be3..130e5dba9555 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h @@ -241,6 +241,7 @@ struct ath_atx_tid { struct ath_node *an; struct ath_atx_ac *ac; unsigned long tx_buf[BITS_TO_LONGS(ATH_TID_MAX_BUFS)]; + int bar_index; u16 seq_start; u16 seq_next; u16 baw_size; diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c index 8766796b48b8..23e80e63bca9 100644 --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c @@ -206,6 +206,8 @@ static void ath_tx_update_baw(struct ath_softc *sc, struct ath_atx_tid *tid, while (tid->baw_head != tid->baw_tail && !test_bit(tid->baw_head, tid->tx_buf)) { INCR(tid->seq_start, IEEE80211_SEQ_MAX); INCR(tid->baw_head, ATH_TID_MAX_BUFS); + if (tid->bar_index >= 0) + tid->bar_index--; } } @@ -263,6 +265,7 @@ static void ath_tid_drain(struct ath_softc *sc, struct ath_txq *txq, tid->seq_next = tid->seq_start; tid->baw_tail = tid->baw_head; + tid->bar_index = -1; } static void ath_tx_set_retry(struct ath_softc *sc, struct ath_txq *txq, @@ -551,8 +554,12 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, bf = bf_next; } - if (bar_index >= 0) + if (bar_index >= 0) { + u16 bar_seq = ATH_BA_INDEX2SEQ(seq_first, bar_index); ath_send_bar(tid, ATH_BA_INDEX2SEQ(seq_first, bar_index + 1)); + if (BAW_WITHIN(tid->seq_start, tid->baw_size, bar_seq)) + tid->bar_index = ATH_BA_INDEX(tid->seq_start, bar_seq); + } /* prepend un-acked frames to the beginning of the pending frame queue */ if (!skb_queue_empty(&bf_pending)) { @@ -779,8 +786,6 @@ static enum ATH_AGGR_STATUS ath_tx_form_aggr(struct ath_softc *sc, bf->bf_state.bf_type = BUF_AMPDU | BUF_AGGR; seqno = bf->bf_state.seqno; - if (!bf_first) - bf_first = bf; /* do not step over block-ack window */ if (!BAW_WITHIN(tid->seq_start, tid->baw_size, seqno)) { @@ -788,6 +793,21 @@ static enum ATH_AGGR_STATUS ath_tx_form_aggr(struct ath_softc *sc, break; } + if (tid->bar_index > ATH_BA_INDEX(tid->seq_start, seqno)) { + struct ath_tx_status ts = {}; + struct list_head bf_head; + + INIT_LIST_HEAD(&bf_head); + list_add(&bf->list, &bf_head); + __skb_unlink(skb, &tid->buf_q); + ath_tx_update_baw(sc, tid, seqno); + ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, 0); + continue; + } + + if (!bf_first) + bf_first = bf; + if (!rl) { aggr_limit = ath_lookup_rate(sc, bf, tid); rl = 1; @@ -1130,6 +1150,7 @@ int ath_tx_aggr_start(struct ath_softc *sc, struct ieee80211_sta *sta, txtid->state |= AGGR_ADDBA_PROGRESS; txtid->paused = true; *ssn = txtid->seq_start = txtid->seq_next; + txtid->bar_index = -1; memset(txtid->tx_buf, 0, sizeof(txtid->tx_buf)); txtid->baw_head = txtid->baw_tail = 0; -- cgit v1.2.3 From 55e435de9153581fda21631f0e68bb793072234d Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 14 Dec 2011 13:56:36 -0800 Subject: ath: document ATH_DBG_MCI A debug level was added to the ath module for printing MCI messages but no documentation was provided. Clarify that MCI is the Message Coexistence Interface, a private protocol used exclusively for WLAN-BT coexistence starting from AR9462. Cc: wtsao@qca.qualcomm.com Cc: rmanohar@qca.qualcomm.com Cc: mohammed@qca.qualcomm.com Cc: senthilb@qca.qualcomm.com Signed-off-by: Luis R. Rodriguez Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h index 3e4dd2d483b8..0b93babcaa1b 100644 --- a/drivers/net/wireless/ath/ath.h +++ b/drivers/net/wireless/ath/ath.h @@ -215,6 +215,9 @@ do { \ * @ATH_DBG_HWTIMER: hardware timer handling * @ATH_DBG_BTCOEX: bluetooth coexistance * @ATH_DBG_BSTUCK: stuck beacons + * @ATH_DBG_MCI: Message Coexistence Interface, a private protocol + * used exclusively for WLAN-BT coexistence starting from + * AR9462. * @ATH_DBG_ANY: enable all debugging * * The debug level is used to control the amount and type of debugging output -- cgit v1.2.3 From 00d2ec0c5f5ae8507931efd8feb174f30370c12e Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 14 Dec 2011 20:23:03 -0600 Subject: brcmsmac: Replace kmalloc/memset with kzalloc In ai_attach(), space is allocated for an si_info struct. Immediately after the allocation, routine ai_doattach() is called and that allocated space is set to zero. As no other routine calls ai_doattach(), kzalloc() can be utilized. Signed-off-by: Larry Finger Acked-by: Arend van Spriel Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/aiutils.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c index 372bee8dd926..ab9bb11abfbb 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c @@ -565,8 +565,6 @@ static struct si_info *ai_doattach(struct si_info *sii, struct bcma_device *cc; uint socitype; - memset((unsigned char *) sii, 0, sizeof(struct si_info)); - savewin = 0; sii->icbus = pbus; @@ -677,7 +675,7 @@ ai_attach(struct bcma_bus *pbus) struct si_info *sii; /* alloc struct si_info */ - sii = kmalloc(sizeof(struct si_info), GFP_ATOMIC); + sii = kzalloc(sizeof(struct si_info), GFP_ATOMIC); if (sii == NULL) return NULL; -- cgit v1.2.3 From 9b203c8fc2aa05d7bc28261d7c2bee52a0945789 Mon Sep 17 00:00:00 2001 From: Zefir Kurtisi Date: Wed, 14 Dec 2011 20:16:32 -0800 Subject: ath: add a debug level for DFS This can later be used by other drivers that implement DFS support. Signed-off-by: Zefir Kurtisi Signed-off-by: Luis R. Rodriguez Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath.h b/drivers/net/wireless/ath/ath.h index 0b93babcaa1b..c1d699fd5717 100644 --- a/drivers/net/wireless/ath/ath.h +++ b/drivers/net/wireless/ath/ath.h @@ -218,6 +218,7 @@ do { \ * @ATH_DBG_MCI: Message Coexistence Interface, a private protocol * used exclusively for WLAN-BT coexistence starting from * AR9462. + * @ATH_DBG_DFS: radar datection * @ATH_DBG_ANY: enable all debugging * * The debug level is used to control the amount and type of debugging output @@ -244,6 +245,7 @@ enum ATH_DEBUG { ATH_DBG_WMI = 0x00004000, ATH_DBG_BSTUCK = 0x00008000, ATH_DBG_MCI = 0x00010000, + ATH_DBG_DFS = 0x00020000, ATH_DBG_ANY = 0xffffffff }; -- cgit v1.2.3 From 9a66af3317be2b2ceea38f403d2f682f255de82a Mon Sep 17 00:00:00 2001 From: Zefir Kurtisi Date: Wed, 14 Dec 2011 20:16:33 -0800 Subject: ath9k_hw: add DFS testing check In order to enable DFS upstream we want to be sure DFS has been tested for each chipset. Push for public documentation of the requirements we want in place and allow for enabling each chipset through a single upstream commit. Signed-off-by: Zefir Kurtisi Signed-off-by: Luis R. Rodriguez Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/hw-ops.h | 9 +++++++++ drivers/net/wireless/ath/ath9k/hw.c | 27 +++++++++++++++++++++++++++ drivers/net/wireless/ath/ath9k/hw.h | 1 + 3 files changed, 37 insertions(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/hw-ops.h b/drivers/net/wireless/ath/ath9k/hw-ops.h index e74c233757a2..c4ad0b06bdbc 100644 --- a/drivers/net/wireless/ath/ath9k/hw-ops.h +++ b/drivers/net/wireless/ath/ath9k/hw-ops.h @@ -212,4 +212,13 @@ static inline int ath9k_hw_fast_chan_change(struct ath_hw *ah, return ath9k_hw_private_ops(ah)->fast_chan_change(ah, chan, ini_reloaded); } + +static inline void ath9k_hw_set_radar_params(struct ath_hw *ah) +{ + if (!ath9k_hw_private_ops(ah)->set_radar_params) + return; + + ath9k_hw_private_ops(ah)->set_radar_params(ah, &ah->radar_conf); +} + #endif /* ATH9K_HW_OPS_H */ diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 7f8fc65f2cb4..080fac4d2e33 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -2277,6 +2277,30 @@ static u8 fixup_chainmask(u8 chip_chainmask, u8 eeprom_chainmask) return chip_chainmask; } +/** + * ath9k_hw_dfs_tested - checks if DFS has been tested with used chipset + * @ah: the atheros hardware data structure + * + * We enable DFS support upstream on chipsets which have passed a series + * of tests. The testing requirements are going to be documented. Desired + * test requirements are documented at: + * + * http://wireless.kernel.org/en/users/Drivers/ath9k/dfs + * + * Once a new chipset gets properly tested an individual commit can be used + * to document the testing for DFS for that chipset. + */ +static bool ath9k_hw_dfs_tested(struct ath_hw *ah) +{ + + switch (ah->hw_version.macVersion) { + /* AR9580 will likely be our first target to get testing on */ + case AR_SREV_VERSION_9580: + default: + return false; + } +} + int ath9k_hw_fill_cap_info(struct ath_hw *ah) { struct ath9k_hw_capabilities *pCap = &ah->caps; @@ -2490,6 +2514,9 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah) pCap->pcie_lcr_offset = 0x80; } + if (ath9k_hw_dfs_tested(ah)) + pCap->hw_caps |= ATH9K_HW_CAP_DFS; + tx_chainmask = pCap->tx_chainmask; rx_chainmask = pCap->rx_chainmask; while (tx_chainmask || rx_chainmask) { diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index 36968c046119..aadc7923b0c0 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -211,6 +211,7 @@ enum ath9k_hw_caps { ATH9K_HW_CAP_APM = BIT(15), ATH9K_HW_CAP_RTT = BIT(16), ATH9K_HW_CAP_MCI = BIT(17), + ATH9K_HW_CAP_DFS = BIT(18), }; struct ath9k_hw_capabilities { -- cgit v1.2.3 From 29942bc125374b5aa049a438fb628ea729538ca5 Mon Sep 17 00:00:00 2001 From: Zefir Kurtisi Date: Wed, 14 Dec 2011 20:16:34 -0800 Subject: ath9k: add DFS radar pulse processing This initial DFS module provides basic functionality to deal with radar pulses reported by the Atheros DFS HW pulse detector. The reported data is evaluated and basic plausibility checks are performed to filter false pulses. Passing radar pulses are forwarded to pattern detectors which are not yet implemented. (Some modifications to actually use ATH9K_DFS_DEBUGFS based on comments from Julian Calaby . -- JWL) Signed-off-by: Zefir Kurtisi Signed-off-by: Luis R. Rodriguez Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/Kconfig | 22 +++ drivers/net/wireless/ath/ath9k/Makefile | 2 + drivers/net/wireless/ath/ath9k/debug.c | 3 + drivers/net/wireless/ath/ath9k/debug.h | 2 + drivers/net/wireless/ath/ath9k/dfs.c | 215 +++++++++++++++++++++++++++++ drivers/net/wireless/ath/ath9k/dfs.h | 43 ++++++ drivers/net/wireless/ath/ath9k/dfs_debug.c | 81 +++++++++++ drivers/net/wireless/ath/ath9k/dfs_debug.h | 57 ++++++++ 8 files changed, 425 insertions(+) create mode 100644 drivers/net/wireless/ath/ath9k/dfs.c create mode 100644 drivers/net/wireless/ath/ath9k/dfs.h create mode 100644 drivers/net/wireless/ath/ath9k/dfs_debug.c create mode 100644 drivers/net/wireless/ath/ath9k/dfs_debug.h (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/Kconfig b/drivers/net/wireless/ath/ath9k/Kconfig index 7b4c074e12fa..1b4786ae00ac 100644 --- a/drivers/net/wireless/ath/ath9k/Kconfig +++ b/drivers/net/wireless/ath/ath9k/Kconfig @@ -2,6 +2,9 @@ config ATH9K_HW tristate config ATH9K_COMMON tristate +config ATH9K_DFS_DEBUGFS + def_bool y + depends on ATH9K_DEBUGFS && ATH9K_DFS_CERTIFIED config ATH9K tristate "Atheros 802.11n wireless cards support" @@ -51,6 +54,25 @@ config ATH9K_DEBUGFS Also required for changing debug message flags at run time. +config ATH9K_DFS_CERTIFIED + bool "Atheros DFS support for certified platforms" + depends on ATH9K && EXPERT + default n + ---help--- + This option enables DFS support for initiating radiation on + ath9k. There is no way to dynamically detect if a card was DFS + certified and as such this is left as a build time option. This + option should only be enabled by system integrators that can + guarantee that all the platforms that their kernel will run on + have obtained appropriate regulatory body certification for a + respective Atheros card by using ath9k on the target shipping + platforms. + + This is currently only a placeholder for future DFS support, + as DFS support requires more components that still need to be + developed. At this point enabling this option won't do anything + except increase code size. + config ATH9K_RATE_CONTROL bool "Atheros ath9k rate control" depends on ATH9K diff --git a/drivers/net/wireless/ath/ath9k/Makefile b/drivers/net/wireless/ath/ath9k/Makefile index 390797db5273..da02242499af 100644 --- a/drivers/net/wireless/ath/ath9k/Makefile +++ b/drivers/net/wireless/ath/ath9k/Makefile @@ -10,6 +10,8 @@ ath9k-$(CONFIG_ATH9K_RATE_CONTROL) += rc.o ath9k-$(CONFIG_ATH9K_PCI) += pci.o ath9k-$(CONFIG_ATH9K_AHB) += ahb.o ath9k-$(CONFIG_ATH9K_DEBUGFS) += debug.o +ath9k-$(CONFIG_ATH9K_DFS_DEBUGFS) += dfs_debug.o +ath9k-$(CONFIG_ATH9K_DFS_CERTIFIED) += dfs.o obj-$(CONFIG_ATH9K) += ath9k.o diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c index 5cb8cceffd0b..68d972bf232d 100644 --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c @@ -1630,6 +1630,9 @@ int ath9k_init_debug(struct ath_hw *ah) debugfs_create_file("debug", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, sc, &fops_debug); #endif + + ath9k_dfs_init_debug(sc); + debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc, &fops_dma); debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy, sc, diff --git a/drivers/net/wireless/ath/ath9k/debug.h b/drivers/net/wireless/ath/ath9k/debug.h index 356352ac2d6e..776a24ada600 100644 --- a/drivers/net/wireless/ath/ath9k/debug.h +++ b/drivers/net/wireless/ath/ath9k/debug.h @@ -19,6 +19,7 @@ #include "hw.h" #include "rc.h" +#include "dfs_debug.h" struct ath_txq; struct ath_buf; @@ -187,6 +188,7 @@ struct ath_stats { struct ath_interrupt_stats istats; struct ath_tx_stats txstats[ATH9K_NUM_TX_QUEUES]; struct ath_rx_stats rxstats; + struct ath_dfs_stats dfs_stats; u32 reset[__RESET_TYPE_MAX]; }; diff --git a/drivers/net/wireless/ath/ath9k/dfs.c b/drivers/net/wireless/ath/ath9k/dfs.c new file mode 100644 index 000000000000..e4e84a9e6273 --- /dev/null +++ b/drivers/net/wireless/ath/ath9k/dfs.c @@ -0,0 +1,215 @@ +/* + * Copyright (c) 2008-2011 Atheros Communications Inc. + * Copyright (c) 2011 Neratec Solutions AG + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "hw.h" +#include "hw-ops.h" +#include "ath9k.h" +#include "dfs.h" +#include "dfs_debug.h" + +/* + * TODO: move into or synchronize this with generic header + * as soon as IF is defined + */ +struct dfs_radar_pulse { + u16 freq; + u64 ts; + u32 width; + u8 rssi; +}; + +/* internal struct to pass radar data */ +struct ath_radar_data { + u8 pulse_bw_info; + u8 rssi; + u8 ext_rssi; + u8 pulse_length_ext; + u8 pulse_length_pri; +}; + +/* convert pulse duration to usecs, considering clock mode */ +static u32 dur_to_usecs(struct ath_hw *ah, u32 dur) +{ + const u32 AR93X_NSECS_PER_DUR = 800; + const u32 AR93X_NSECS_PER_DUR_FAST = (8000 / 11); + u32 nsecs; + + if (IS_CHAN_A_FAST_CLOCK(ah, ah->curchan)) + nsecs = dur * AR93X_NSECS_PER_DUR_FAST; + else + nsecs = dur * AR93X_NSECS_PER_DUR; + + return (nsecs + 500) / 1000; +} + +#define PRI_CH_RADAR_FOUND 0x01 +#define EXT_CH_RADAR_FOUND 0x02 +static bool +ath9k_postprocess_radar_event(struct ath_softc *sc, + struct ath_radar_data *are, + struct dfs_radar_pulse *drp) +{ + u8 rssi; + u16 dur; + + ath_dbg(ath9k_hw_common(sc->sc_ah), ATH_DBG_DFS, + "pulse_bw_info=0x%x, pri,ext len/rssi=(%u/%u, %u/%u)\n", + are->pulse_bw_info, + are->pulse_length_pri, are->rssi, + are->pulse_length_ext, are->ext_rssi); + + /* + * Only the last 2 bits of the BW info are relevant, they indicate + * which channel the radar was detected in. + */ + are->pulse_bw_info &= 0x03; + + switch (are->pulse_bw_info) { + case PRI_CH_RADAR_FOUND: + /* radar in ctrl channel */ + dur = are->pulse_length_pri; + DFS_STAT_INC(sc, pri_phy_errors); + /* + * cannot use ctrl channel RSSI + * if extension channel is stronger + */ + rssi = (are->ext_rssi >= (are->rssi + 3)) ? 0 : are->rssi; + break; + case EXT_CH_RADAR_FOUND: + /* radar in extension channel */ + dur = are->pulse_length_ext; + DFS_STAT_INC(sc, ext_phy_errors); + /* + * cannot use extension channel RSSI + * if control channel is stronger + */ + rssi = (are->rssi >= (are->ext_rssi + 12)) ? 0 : are->ext_rssi; + break; + case (PRI_CH_RADAR_FOUND | EXT_CH_RADAR_FOUND): + /* + * Conducted testing, when pulse is on DC, both pri and ext + * durations are reported to be same + * + * Radiated testing, when pulse is on DC, different pri and + * ext durations are reported, so take the larger of the two + */ + if (are->pulse_length_ext >= are->pulse_length_pri) + dur = are->pulse_length_ext; + else + dur = are->pulse_length_pri; + DFS_STAT_INC(sc, dc_phy_errors); + + /* when both are present use stronger one */ + rssi = (are->rssi < are->ext_rssi) ? are->ext_rssi : are->rssi; + break; + default: + /* + * Bogus bandwidth info was received in descriptor, + * so ignore this PHY error + */ + DFS_STAT_INC(sc, bwinfo_discards); + return false; + } + + if (rssi == 0) { + DFS_STAT_INC(sc, rssi_discards); + return false; + } + + /* + * TODO: check chirping pulses + * checks for chirping are dependent on the DFS regulatory domain + * used, which is yet TBD + */ + + /* convert duration to usecs */ + drp->width = dur_to_usecs(sc->sc_ah, dur); + drp->rssi = rssi; + + DFS_STAT_INC(sc, pulses_detected); + return true; +} +#undef PRI_CH_RADAR_FOUND +#undef EXT_CH_RADAR_FOUND + +/* + * DFS: check PHY-error for radar pulse and feed the detector + */ +void ath9k_dfs_process_phyerr(struct ath_softc *sc, void *data, + struct ath_rx_status *rs, u64 mactime) +{ + struct ath_radar_data ard; + u16 datalen; + char *vdata_end; + struct dfs_radar_pulse drp; + struct ath_hw *ah = sc->sc_ah; + struct ath_common *common = ath9k_hw_common(ah); + + if ((!(rs->rs_phyerr != ATH9K_PHYERR_RADAR)) && + (!(rs->rs_phyerr != ATH9K_PHYERR_FALSE_RADAR_EXT))) { + ath_dbg(common, ATH_DBG_DFS, + "Error: rs_phyer=0x%x not a radar error\n", + rs->rs_phyerr); + return; + } + + datalen = rs->rs_datalen; + if (datalen == 0) { + DFS_STAT_INC(sc, datalen_discards); + return; + } + + ard.rssi = rs->rs_rssi_ctl0; + ard.ext_rssi = rs->rs_rssi_ext0; + + /* + * hardware stores this as 8 bit signed value. + * we will cap it at 0 if it is a negative number + */ + if (ard.rssi & 0x80) + ard.rssi = 0; + if (ard.ext_rssi & 0x80) + ard.ext_rssi = 0; + + vdata_end = (char *)data + datalen; + ard.pulse_bw_info = vdata_end[-1]; + ard.pulse_length_ext = vdata_end[-2]; + ard.pulse_length_pri = vdata_end[-3]; + + ath_dbg(common, ATH_DBG_DFS, + "bw_info=%d, length_pri=%d, length_ext=%d, " + "rssi_pri=%d, rssi_ext=%d\n", + ard.pulse_bw_info, ard.pulse_length_pri, ard.pulse_length_ext, + ard.rssi, ard.ext_rssi); + + drp.freq = ah->curchan->channel; + drp.ts = mactime; + if (ath9k_postprocess_radar_event(sc, &ard, &drp)) { + static u64 last_ts; + ath_dbg(common, ATH_DBG_DFS, + "ath9k_dfs_process_phyerr: channel=%d, ts=%llu, " + "width=%d, rssi=%d, delta_ts=%llu\n", + drp.freq, drp.ts, drp.width, drp.rssi, drp.ts-last_ts); + last_ts = drp.ts; + /* + * TODO: forward pulse to pattern detector + * + * ieee80211_add_radar_pulse(drp.freq, drp.ts, + * drp.width, drp.rssi); + */ + } +} diff --git a/drivers/net/wireless/ath/ath9k/dfs.h b/drivers/net/wireless/ath/ath9k/dfs.h new file mode 100644 index 000000000000..c2412857f122 --- /dev/null +++ b/drivers/net/wireless/ath/ath9k/dfs.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2008-2011 Atheros Communications Inc. + * Copyright (c) 2011 Neratec Solutions AG + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef ATH9K_DFS_H +#define ATH9K_DFS_H + +#if defined(CONFIG_ATH9K_DFS_CERTIFIED) +/** + * ath9k_dfs_process_phyerr - process radar PHY error + * @sc: ath_softc + * @data: RX payload data + * @rs: RX status after processing descriptor + * @mactime: receive time + * + * This function is called whenever the HW DFS module detects a radar + * pulse and reports it as a PHY error. + * + * The radar information provided as raw payload data is validated and + * filtered for false pulses. Events passing all tests are forwarded to + * the upper layer for pattern detection. + */ +void ath9k_dfs_process_phyerr(struct ath_softc *sc, void *data, + struct ath_rx_status *rs, u64 mactime); +#else +static inline void ath9k_dfs_process_phyerr(struct ath_softc *sc, void *data, + struct ath_rx_status *rs, u64 mactime) { } +#endif + +#endif /* ATH9K_DFS_H */ diff --git a/drivers/net/wireless/ath/ath9k/dfs_debug.c b/drivers/net/wireless/ath/ath9k/dfs_debug.c new file mode 100644 index 000000000000..106d031d834a --- /dev/null +++ b/drivers/net/wireless/ath/ath9k/dfs_debug.c @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2008-2011 Atheros Communications Inc. + * Copyright (c) 2011 Neratec Solutions AG + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include + +#include "ath9k.h" +#include "dfs_debug.h" + +#define ATH9K_DFS_STAT(s, p) \ + len += snprintf(buf + len, size - len, "%28s : %10u\n", s, \ + sc->debug.stats.dfs_stats.p); + +static ssize_t read_file_dfs(struct file *file, char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct ath_softc *sc = file->private_data; + struct ath9k_hw_version *hw_ver = &sc->sc_ah->hw_version; + char *buf; + unsigned int len = 0, size = 8000; + ssize_t retval = 0; + + buf = kzalloc(size, GFP_KERNEL); + if (buf == NULL) + return -ENOMEM; + + len += snprintf(buf + len, size - len, "DFS support for " + "macVersion = 0x%x, macRev = 0x%x: %s\n", + hw_ver->macVersion, hw_ver->macRev, + (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_DFS) ? + "enabled" : "disabled"); + ATH9K_DFS_STAT("DFS pulses detected ", pulses_detected); + ATH9K_DFS_STAT("Datalen discards ", datalen_discards); + ATH9K_DFS_STAT("RSSI discards ", rssi_discards); + ATH9K_DFS_STAT("BW info discards ", bwinfo_discards); + ATH9K_DFS_STAT("Primary channel pulses ", pri_phy_errors); + ATH9K_DFS_STAT("Secondary channel pulses", ext_phy_errors); + ATH9K_DFS_STAT("Dual channel pulses ", dc_phy_errors); + + if (len > size) + len = size; + + retval = simple_read_from_buffer(user_buf, count, ppos, buf, len); + kfree(buf); + + return retval; +} + +static int ath9k_dfs_debugfs_open(struct inode *inode, struct file *file) +{ + file->private_data = inode->i_private; + + return 0; +} + +static const struct file_operations fops_dfs_stats = { + .read = read_file_dfs, + .open = ath9k_dfs_debugfs_open, + .owner = THIS_MODULE, + .llseek = default_llseek, +}; + +void ath9k_dfs_init_debug(struct ath_softc *sc) +{ + debugfs_create_file("dfs_stats", S_IRUSR, + sc->debug.debugfs_phy, sc, &fops_dfs_stats); +} diff --git a/drivers/net/wireless/ath/ath9k/dfs_debug.h b/drivers/net/wireless/ath/ath9k/dfs_debug.h new file mode 100644 index 000000000000..6e1e2a71659e --- /dev/null +++ b/drivers/net/wireless/ath/ath9k/dfs_debug.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2008-2011 Atheros Communications Inc. + * Copyright (c) 2011 Neratec Solutions AG + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +#ifndef DFS_DEBUG_H +#define DFS_DEBUG_H + +#include "hw.h" + +/** + * struct ath_dfs_stats - DFS Statistics + * + * @pulses_detected: No. of pulses detected so far + * @datalen_discards: No. of pulses discarded due to invalid datalen + * @rssi_discards: No. of pulses discarded due to invalid RSSI + * @bwinfo_discards: No. of pulses discarded due to invalid BW info + * @pri_phy_errors: No. of pulses reported for primary channel + * @ext_phy_errors: No. of pulses reported for extension channel + * @dc_phy_errors: No. of pulses reported for primary + extension channel + */ +struct ath_dfs_stats { + u32 pulses_detected; + u32 datalen_discards; + u32 rssi_discards; + u32 bwinfo_discards; + u32 pri_phy_errors; + u32 ext_phy_errors; + u32 dc_phy_errors; +}; + +#if defined(CONFIG_ATH9K_DFS_DEBUGFS) + +#define DFS_STAT_INC(sc, c) (sc->debug.stats.dfs_stats.c++) +void ath9k_dfs_init_debug(struct ath_softc *sc); + +#else + +#define DFS_STAT_INC(sc, c) do { } while (0) +static inline void ath9k_dfs_init_debug(struct ath_softc *sc) { } + +#endif /* CONFIG_ATH9K_DFS_DEBUGFS */ + +#endif /* DFS_DEBUG_H */ -- cgit v1.2.3 From aa1f2f0a3218a9b6ce979fca3d6ebdb1c5544dd8 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 15 Dec 2011 14:23:32 +0300 Subject: brcm80211: smac: precendence bug in wlc_phy_attach() Negate has higher precendence than compare and since neither zero nor one are equal to four or eight the original condition is always false. Signed-off-by: Dan Carpenter Acked-by: Arend van Spriel Signed-off-by: John W. Linville --- drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c index 5b57caa7c3af..264f8c4c703d 100644 --- a/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c +++ b/drivers/net/wireless/brcm80211/brcmsmac/phy/phy_cmn.c @@ -482,8 +482,8 @@ wlc_phy_attach(struct shared_phy *sh, struct bcma_device *d11core, pi->pubpi.phy_corenum = PHY_CORE_NUM_2; pi->pubpi.ana_rev = (phyversion & PV_AV_MASK) >> PV_AV_SHIFT; - if (!pi->pubpi.phy_type == PHY_TYPE_N && - !pi->pubpi.phy_type == PHY_TYPE_LCN) + if (pi->pubpi.phy_type != PHY_TYPE_N && + pi->pubpi.phy_type != PHY_TYPE_LCN) goto err; if (bandtype == BRCM_BAND_5G) { -- cgit v1.2.3 From d66be8294289346ceba4c6abc022954b682d4959 Mon Sep 17 00:00:00 2001 From: Rafał Miłecki Date: Thu, 15 Dec 2011 14:17:21 +0100 Subject: b43: N-PHY: check for bustype before touching BCMA CC PLLs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported-by: John W. Linville Signed-off-by: Rafał Miłecki Signed-off-by: John W. Linville --- drivers/net/wireless/b43/phy_n.c | 111 +++++++++++++++++++++------------------ 1 file changed, 61 insertions(+), 50 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/b43/phy_n.c b/drivers/net/wireless/b43/phy_n.c index 154f97dc3780..c8fa2cd97e64 100644 --- a/drivers/net/wireless/b43/phy_n.c +++ b/drivers/net/wireless/b43/phy_n.c @@ -4048,60 +4048,71 @@ int b43_phy_initn(struct b43_wldev *dev) /* http://bcm-v4.sipsolutions.net/802.11/PmuSpurAvoid */ static void b43_nphy_pmu_spur_avoid(struct b43_wldev *dev, bool avoid) { -#ifdef CONFIG_B43_BCMA - struct bcma_drv_cc *cc = &dev->dev->bdev->bus->drv_cc; + struct bcma_drv_cc *cc; u32 pmu_ctl; - if (dev->dev->chip_id == 43224 || dev->dev->chip_id == 43225) { - if (avoid) { - bcma_chipco_pll_write(cc, 0x0, 0x11500010); - bcma_chipco_pll_write(cc, 0x1, 0x000C0C06); - bcma_chipco_pll_write(cc, 0x2, 0x0F600a08); - bcma_chipco_pll_write(cc, 0x3, 0x00000000); - bcma_chipco_pll_write(cc, 0x4, 0x2001E920); - bcma_chipco_pll_write(cc, 0x5, 0x88888815); - } else { - bcma_chipco_pll_write(cc, 0x0, 0x11100010); - bcma_chipco_pll_write(cc, 0x1, 0x000c0c06); - bcma_chipco_pll_write(cc, 0x2, 0x03000a08); - bcma_chipco_pll_write(cc, 0x3, 0x00000000); - bcma_chipco_pll_write(cc, 0x4, 0x200005c0); - bcma_chipco_pll_write(cc, 0x5, 0x88888815); - } - pmu_ctl = BCMA_CC_PMU_CTL_PLL_UPD; - } else if (dev->dev->chip_id == 0x4716) { - if (avoid) { - bcma_chipco_pll_write(cc, 0x0, 0x11500060); - bcma_chipco_pll_write(cc, 0x1, 0x080C0C06); - bcma_chipco_pll_write(cc, 0x2, 0x0F600000); - bcma_chipco_pll_write(cc, 0x3, 0x00000000); - bcma_chipco_pll_write(cc, 0x4, 0x2001E924); - bcma_chipco_pll_write(cc, 0x5, 0x88888815); + + switch (dev->dev->bus_type) { +#ifdef CONFIG_B43_BCMA + case B43_BUS_BCMA: + cc = &dev->dev->bdev->bus->drv_cc; + if (dev->dev->chip_id == 43224 || dev->dev->chip_id == 43225) { + if (avoid) { + bcma_chipco_pll_write(cc, 0x0, 0x11500010); + bcma_chipco_pll_write(cc, 0x1, 0x000C0C06); + bcma_chipco_pll_write(cc, 0x2, 0x0F600a08); + bcma_chipco_pll_write(cc, 0x3, 0x00000000); + bcma_chipco_pll_write(cc, 0x4, 0x2001E920); + bcma_chipco_pll_write(cc, 0x5, 0x88888815); + } else { + bcma_chipco_pll_write(cc, 0x0, 0x11100010); + bcma_chipco_pll_write(cc, 0x1, 0x000c0c06); + bcma_chipco_pll_write(cc, 0x2, 0x03000a08); + bcma_chipco_pll_write(cc, 0x3, 0x00000000); + bcma_chipco_pll_write(cc, 0x4, 0x200005c0); + bcma_chipco_pll_write(cc, 0x5, 0x88888815); + } + pmu_ctl = BCMA_CC_PMU_CTL_PLL_UPD; + } else if (dev->dev->chip_id == 0x4716) { + if (avoid) { + bcma_chipco_pll_write(cc, 0x0, 0x11500060); + bcma_chipco_pll_write(cc, 0x1, 0x080C0C06); + bcma_chipco_pll_write(cc, 0x2, 0x0F600000); + bcma_chipco_pll_write(cc, 0x3, 0x00000000); + bcma_chipco_pll_write(cc, 0x4, 0x2001E924); + bcma_chipco_pll_write(cc, 0x5, 0x88888815); + } else { + bcma_chipco_pll_write(cc, 0x0, 0x11100060); + bcma_chipco_pll_write(cc, 0x1, 0x080c0c06); + bcma_chipco_pll_write(cc, 0x2, 0x03000000); + bcma_chipco_pll_write(cc, 0x3, 0x00000000); + bcma_chipco_pll_write(cc, 0x4, 0x200005c0); + bcma_chipco_pll_write(cc, 0x5, 0x88888815); + } + pmu_ctl = BCMA_CC_PMU_CTL_PLL_UPD | + BCMA_CC_PMU_CTL_NOILPONW; + } else if (dev->dev->chip_id == 0x4322 || + dev->dev->chip_id == 0x4340 || + dev->dev->chip_id == 0x4341) { + bcma_chipco_pll_write(cc, 0x0, 0x11100070); + bcma_chipco_pll_write(cc, 0x1, 0x1014140a); + bcma_chipco_pll_write(cc, 0x5, 0x88888854); + if (avoid) + bcma_chipco_pll_write(cc, 0x2, 0x05201828); + else + bcma_chipco_pll_write(cc, 0x2, 0x05001828); + pmu_ctl = BCMA_CC_PMU_CTL_PLL_UPD; } else { - bcma_chipco_pll_write(cc, 0x0, 0x11100060); - bcma_chipco_pll_write(cc, 0x1, 0x080c0c06); - bcma_chipco_pll_write(cc, 0x2, 0x03000000); - bcma_chipco_pll_write(cc, 0x3, 0x00000000); - bcma_chipco_pll_write(cc, 0x4, 0x200005c0); - bcma_chipco_pll_write(cc, 0x5, 0x88888815); + return; } - pmu_ctl = BCMA_CC_PMU_CTL_PLL_UPD | BCMA_CC_PMU_CTL_NOILPONW; - } else if (dev->dev->chip_id == 0x4322 || dev->dev->chip_id == 0x4340 || - dev->dev->chip_id == 0x4341) { - bcma_chipco_pll_write(cc, 0x0, 0x11100070); - bcma_chipco_pll_write(cc, 0x1, 0x1014140a); - bcma_chipco_pll_write(cc, 0x5, 0x88888854); - if (avoid) - bcma_chipco_pll_write(cc, 0x2, 0x05201828); - else - bcma_chipco_pll_write(cc, 0x2, 0x05001828); - pmu_ctl = BCMA_CC_PMU_CTL_PLL_UPD; - } else { - return; - } - bcma_cc_set32(cc, BCMA_CC_PMU_CTL, pmu_ctl); -#else - return; + bcma_cc_set32(cc, BCMA_CC_PMU_CTL, pmu_ctl); + break; #endif +#ifdef CONFIG_B43_SSB + case B43_BUS_SSB: + /* FIXME */ + break; +#endif + } } /* http://bcm-v4.sipsolutions.net/802.11/PHY/N/ChanspecSetup */ -- cgit v1.2.3 From 356cb55d81d1692bd74b96c71deeb7e1cf956196 Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Wed, 7 Dec 2011 16:51:38 +0530 Subject: ath9k: validate for non-zero BSSID before concluding that the recieved beacon is for us, let us make sure that the BSSID is non-zero. when I configured ad-hoc mode as creator and left it for some time without joining I found we recieved few frames whose BSSID is zero, which we concluded wrongly as 'my_beacons' Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/recv.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c index e0318415c2a0..ad5176de07dc 100644 --- a/drivers/net/wireless/ath/ath9k/recv.c +++ b/drivers/net/wireless/ath/ath9k/recv.c @@ -1823,6 +1823,7 @@ int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp) hdr = (struct ieee80211_hdr *) (hdr_skb->data + rx_status_len); rxs = IEEE80211_SKB_RXCB(hdr_skb); if (ieee80211_is_beacon(hdr->frame_control) && + !is_zero_ether_addr(common->curbssid) && !compare_ether_addr(hdr->addr3, common->curbssid)) rs.is_mybeacon = true; else -- cgit v1.2.3 From 1b2538b2ab8f37e55b91b3cce98d2df5c126125d Mon Sep 17 00:00:00 2001 From: Mohammed Shafi Shajakhan Date: Wed, 7 Dec 2011 16:51:39 +0530 Subject: ath9k_hw: remove ATH9K_HW_CAP_CST its not used anywhere in the current code Signed-off-by: Mohammed Shafi Shajakhan Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/hw.c | 6 ++---- drivers/net/wireless/ath/ath9k/hw.h | 31 +++++++++++++++---------------- 2 files changed, 17 insertions(+), 20 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 080fac4d2e33..8cda9a1513a7 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c @@ -2399,12 +2399,10 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah) else pCap->num_gpio_pins = AR_NUM_GPIO; - if (AR_SREV_9160_10_OR_LATER(ah) || AR_SREV_9100(ah)) { - pCap->hw_caps |= ATH9K_HW_CAP_CST; + if (AR_SREV_9160_10_OR_LATER(ah) || AR_SREV_9100(ah)) pCap->rts_aggr_limit = ATH_AMPDU_LIMIT_MAX; - } else { + else pCap->rts_aggr_limit = (8 * 1024); - } #if defined(CONFIG_RFKILL) || defined(CONFIG_RFKILL_MODULE) ah->rfsilent = ah->eep_ops->get_eeprom(ah, EEP_RF_SILENT); diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h index aadc7923b0c0..615cc839f0de 100644 --- a/drivers/net/wireless/ath/ath9k/hw.h +++ b/drivers/net/wireless/ath/ath9k/hw.h @@ -196,22 +196,21 @@ enum ath_ini_subsys { enum ath9k_hw_caps { ATH9K_HW_CAP_HT = BIT(0), ATH9K_HW_CAP_RFSILENT = BIT(1), - ATH9K_HW_CAP_CST = BIT(2), - ATH9K_HW_CAP_AUTOSLEEP = BIT(4), - ATH9K_HW_CAP_4KB_SPLITTRANS = BIT(5), - ATH9K_HW_CAP_EDMA = BIT(6), - ATH9K_HW_CAP_RAC_SUPPORTED = BIT(7), - ATH9K_HW_CAP_LDPC = BIT(8), - ATH9K_HW_CAP_FASTCLOCK = BIT(9), - ATH9K_HW_CAP_SGI_20 = BIT(10), - ATH9K_HW_CAP_PAPRD = BIT(11), - ATH9K_HW_CAP_ANT_DIV_COMB = BIT(12), - ATH9K_HW_CAP_2GHZ = BIT(13), - ATH9K_HW_CAP_5GHZ = BIT(14), - ATH9K_HW_CAP_APM = BIT(15), - ATH9K_HW_CAP_RTT = BIT(16), - ATH9K_HW_CAP_MCI = BIT(17), - ATH9K_HW_CAP_DFS = BIT(18), + ATH9K_HW_CAP_AUTOSLEEP = BIT(2), + ATH9K_HW_CAP_4KB_SPLITTRANS = BIT(3), + ATH9K_HW_CAP_EDMA = BIT(4), + ATH9K_HW_CAP_RAC_SUPPORTED = BIT(5), + ATH9K_HW_CAP_LDPC = BIT(6), + ATH9K_HW_CAP_FASTCLOCK = BIT(7), + ATH9K_HW_CAP_SGI_20 = BIT(8), + ATH9K_HW_CAP_PAPRD = BIT(9), + ATH9K_HW_CAP_ANT_DIV_COMB = BIT(10), + ATH9K_HW_CAP_2GHZ = BIT(11), + ATH9K_HW_CAP_5GHZ = BIT(12), + ATH9K_HW_CAP_APM = BIT(13), + ATH9K_HW_CAP_RTT = BIT(14), + ATH9K_HW_CAP_MCI = BIT(15), + ATH9K_HW_CAP_DFS = BIT(16), }; struct ath9k_hw_capabilities { -- cgit v1.2.3 From a1910f9cad2b4b9cc0d5d326aa65632a23c16088 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 7 Dec 2011 12:35:17 +0100 Subject: mac80211_hwsim: fix wmediumd_pid Fix a few minor issues with wmediumd_pid: a) make static b) use u32 to match the snd_pid type c) use ACCESS_ONCE since we don't lock it d) don't explicitly initialize to 0 Signed-off-by: Johannes Berg Signed-off-by: John W. Linville --- drivers/net/wireless/mac80211_hwsim.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 6cf6d6d25e21..52bcdf40d5bd 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -37,7 +37,8 @@ MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Software simulator of 802.11 radio(s) for mac80211"); MODULE_LICENSE("GPL"); -int wmediumd_pid; +static u32 wmediumd_pid; + static int radios = 2; module_param(radios, int, 0444); MODULE_PARM_DESC(radios, "Number of simulated radios"); @@ -665,7 +666,7 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw, struct sk_buff *skb) { bool ack; struct ieee80211_tx_info *txi; - int _pid; + u32 _pid; mac80211_hwsim_monitor_rx(hw, skb); @@ -676,7 +677,7 @@ static void mac80211_hwsim_tx(struct ieee80211_hw *hw, struct sk_buff *skb) } /* wmediumd mode check */ - _pid = wmediumd_pid; + _pid = ACCESS_ONCE(wmediumd_pid); if (_pid) return mac80211_hwsim_tx_frame_nl(hw, skb, _pid); @@ -764,7 +765,7 @@ static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac, struct ieee80211_hw *hw = arg; struct sk_buff *skb; struct ieee80211_tx_info *info; - int _pid; + u32 _pid; hwsim_check_magic(vif); @@ -781,7 +782,7 @@ static void mac80211_hwsim_beacon_tx(void *arg, u8 *mac, mac80211_hwsim_monitor_rx(hw, skb); /* wmediumd mode check */ - _pid = wmediumd_pid; + _pid = ACCESS_ONCE(wmediumd_pid); if (_pid) return mac80211_hwsim_tx_frame_nl(hw, skb, _pid); @@ -1254,7 +1255,7 @@ static void hwsim_send_ps_poll(void *dat, u8 *mac, struct ieee80211_vif *vif) struct hwsim_vif_priv *vp = (void *)vif->drv_priv; struct sk_buff *skb; struct ieee80211_pspoll *pspoll; - int _pid; + u32 _pid; if (!vp->assoc) return; @@ -1275,7 +1276,7 @@ static void hwsim_send_ps_poll(void *dat, u8 *mac, struct ieee80211_vif *vif) memcpy(pspoll->ta, mac, ETH_ALEN); /* wmediumd mode check */ - _pid = wmediumd_pid; + _pid = ACCESS_ONCE(wmediumd_pid); if (_pid) return mac80211_hwsim_tx_frame_nl(data->hw, skb, _pid); @@ -1292,7 +1293,7 @@ static void hwsim_send_nullfunc(struct mac80211_hwsim_data *data, u8 *mac, struct hwsim_vif_priv *vp = (void *)vif->drv_priv; struct sk_buff *skb; struct ieee80211_hdr *hdr; - int _pid; + u32 _pid; if (!vp->assoc) return; @@ -1314,7 +1315,7 @@ static void hwsim_send_nullfunc(struct mac80211_hwsim_data *data, u8 *mac, memcpy(hdr->addr3, vp->bssid, ETH_ALEN); /* wmediumd mode check */ - _pid = wmediumd_pid; + _pid = ACCESS_ONCE(wmediumd_pid); if (_pid) return mac80211_hwsim_tx_frame_nl(data->hw, skb, _pid); @@ -1634,8 +1635,6 @@ static int hwsim_init_netlink(void) int rc; printk(KERN_INFO "mac80211_hwsim: initializing netlink\n"); - wmediumd_pid = 0; - rc = genl_register_family_with_ops(&hwsim_genl_family, hwsim_ops, ARRAY_SIZE(hwsim_ops)); if (rc) -- cgit v1.2.3 From 5bd5e9a6ae5137a61d0b5c277eac61892d89fc4f Mon Sep 17 00:00:00 2001 From: Chun-Yeow Yeoh Date: Wed, 7 Dec 2011 12:45:46 -0800 Subject: ath9k: Support RSN Mesh Signed-off-by: Chun-Yeow Yeoh Acked-by: Luis R. Rodriguez Signed-off-by: John W. Linville --- drivers/net/wireless/ath/ath9k/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/net/wireless') diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 4475b0d5b3ae..7fbc4bdd4efe 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c @@ -1873,7 +1873,8 @@ static int ath9k_set_key(struct ieee80211_hw *hw, if (ath9k_modparam_nohwcrypt) return -ENOSPC; - if (vif->type == NL80211_IFTYPE_ADHOC && + if ((vif->type == NL80211_IFTYPE_ADHOC || + vif->type == NL80211_IFTYPE_MESH_POINT) && (key->cipher == WLAN_CIPHER_SUITE_TKIP || key->cipher == WLAN_CIPHER_SUITE_CCMP) && !(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) { -- cgit v1.2.3